aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-05-15 03:34:44 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-15 03:34:44 -0400
commit63fe46da9c380b3f2bbdf3765044649517cc717c (patch)
tree9478c1aca1d692b408955aea20c9cd9a37e589c0
parent99dd1a2b8347ac2ae802300b7862f6f7bcf17139 (diff)
parent066b2118976e6e7cc50eed39e2747c75343a23c4 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts: drivers/net/wireless/iwlwifi/iwl-4965-rs.c drivers/net/wireless/rt2x00/rt61pci.c
-rw-r--r--Documentation/DocBook/kgdb.tmpl8
-rw-r--r--Documentation/cgroups.txt4
-rw-r--r--Documentation/feature-removal-schedule.txt8
-rw-r--r--Documentation/filesystems/Locking2
-rw-r--r--Documentation/filesystems/vfs.txt4
-rw-r--r--Documentation/hwmon/adt74733
-rw-r--r--Documentation/i2c/functionality95
-rw-r--r--Documentation/i2c/smbus-protocol81
-rw-r--r--Documentation/kernel-parameters.txt5
-rw-r--r--Documentation/memory-barriers.txt12
-rw-r--r--Documentation/s390/CommonIO11
-rw-r--r--Documentation/scheduler/sched-design.txt165
-rw-r--r--Documentation/video4linux/CARDLIST.cx238852
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx2
-rw-r--r--MAINTAINERS19
-rw-r--r--Makefile2
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c21
-rw-r--r--arch/arm/mach-ep93xx/core.c2
-rw-r--r--arch/arm/mach-ns9xxx/irq.c22
-rw-r--r--arch/arm/mach-orion5x/addr-map.c66
-rw-r--r--arch/arm/mach-orion5x/common.c11
-rw-r--r--arch/arm/mach-orion5x/common.h1
-rw-r--r--arch/arm/mach-pxa/Makefile12
-rw-r--r--arch/arm/mach-pxa/corgi.c4
-rw-r--r--arch/arm/mach-pxa/cpu-pxa.c310
-rw-r--r--arch/arm/mach-pxa/lubbock.c2
-rw-r--r--arch/arm/mach-pxa/pm.c10
-rw-r--r--arch/arm/mach-pxa/poodle.c2
-rw-r--r--arch/arm/mach-pxa/pxa25x.c11
-rw-r--r--arch/arm/mach-pxa/pxa27x.c11
-rw-r--r--arch/arm/mach-pxa/pxa3xx.c7
-rw-r--r--arch/arm/mach-pxa/spitz.c2
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c3
-rw-r--r--arch/arm/mach-pxa/tosa.c2
-rw-r--r--arch/arm/mach-sa1100/pm.c8
-rw-r--r--arch/arm/plat-s3c24xx/clock.c4
-rw-r--r--arch/blackfin/Kconfig18
-rw-r--r--arch/blackfin/kernel/asm-offsets.c3
-rw-r--r--arch/blackfin/kernel/fixed_code.S2
-rw-r--r--arch/blackfin/kernel/module.c37
-rw-r--r--arch/blackfin/kernel/process.c2
-rw-r--r--arch/blackfin/kernel/ptrace.c4
-rw-r--r--arch/blackfin/kernel/signal.c13
-rw-r--r--arch/blackfin/kernel/time-ts.c10
-rw-r--r--arch/blackfin/mach-bf527/boards/ezkit.c104
-rw-r--r--arch/blackfin/mach-bf533/boards/cm_bf533.c33
-rw-r--r--arch/blackfin/mach-bf533/boards/ezkit.c31
-rw-r--r--arch/blackfin/mach-bf533/boards/stamp.c31
-rw-r--r--arch/blackfin/mach-bf537/boards/cm_bf537.c33
-rw-r--r--arch/blackfin/mach-bf537/boards/stamp.c31
-rw-r--r--arch/blackfin/mach-bf548/boards/cm_bf548.c34
-rw-r--r--arch/blackfin/mach-bf548/boards/ezkit.c32
-rw-r--r--arch/blackfin/mach-bf561/boards/cm_bf561.c32
-rw-r--r--arch/blackfin/mach-bf561/boards/ezkit.c31
-rw-r--r--arch/blackfin/mach-common/Makefile5
-rw-r--r--arch/blackfin/mach-common/cpufreq.c26
-rw-r--r--arch/blackfin/mach-common/dpmc.c137
-rw-r--r--arch/blackfin/mach-common/dpmc_modes.S (renamed from arch/blackfin/mach-common/dpmc.S)27
-rw-r--r--arch/blackfin/mach-common/entry.S113
-rw-r--r--arch/cris/kernel/sys_cris.c19
-rw-r--r--arch/m32r/kernel/sys_m32r.c20
-rw-r--r--arch/m68k/kernel/traps.c17
-rw-r--r--arch/m68k/mac/config.c24
-rw-r--r--arch/m68knommu/Kconfig3
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S10
-rw-r--r--arch/mips/au1000/common/Makefile7
-rw-r--r--arch/mips/au1000/common/au1xxx_irqmap.c145
-rw-r--r--arch/mips/au1000/common/clocks.c24
-rw-r--r--arch/mips/au1000/common/cputable.c5
-rw-r--r--arch/mips/au1000/common/dbdma.c389
-rw-r--r--arch/mips/au1000/common/dbg_io.c32
-rw-r--r--arch/mips/au1000/common/dma.c56
-rw-r--r--arch/mips/au1000/common/gpio.c6
-rw-r--r--arch/mips/au1000/common/irq.c6
-rw-r--r--arch/mips/au1000/common/pci.c11
-rw-r--r--arch/mips/au1000/common/platform.c11
-rw-r--r--arch/mips/au1000/common/power.c157
-rw-r--r--arch/mips/au1000/common/prom.c21
-rw-r--r--arch/mips/au1000/common/puts.c35
-rw-r--r--arch/mips/au1000/common/reset.c33
-rw-r--r--arch/mips/au1000/common/setup.c60
-rw-r--r--arch/mips/au1000/common/time.c78
-rw-r--r--arch/mips/au1000/db1x00/Makefile8
-rw-r--r--arch/mips/au1000/db1x00/board_setup.c61
-rw-r--r--arch/mips/au1000/db1x00/init.c11
-rw-r--r--arch/mips/au1000/db1x00/irqmap.c22
-rw-r--r--arch/mips/au1000/mtx-1/Makefile3
-rw-r--r--arch/mips/au1000/mtx-1/board_setup.c63
-rw-r--r--arch/mips/au1000/mtx-1/init.c11
-rw-r--r--arch/mips/au1000/mtx-1/irqmap.c18
-rw-r--r--arch/mips/au1000/mtx-1/platform.c3
-rw-r--r--arch/mips/au1000/pb1000/Makefile8
-rw-r--r--arch/mips/au1000/pb1000/board_setup.c117
-rw-r--r--arch/mips/au1000/pb1000/init.c20
-rw-r--r--arch/mips/au1000/pb1100/Makefile6
-rw-r--r--arch/mips/au1000/pb1100/board_setup.c50
-rw-r--r--arch/mips/au1000/pb1100/init.c11
-rw-r--r--arch/mips/au1000/pb1100/irqmap.c10
-rw-r--r--arch/mips/au1000/pb1200/Makefile2
-rw-r--r--arch/mips/au1000/pb1200/board_setup.c139
-rw-r--r--arch/mips/au1000/pb1200/init.c18
-rw-r--r--arch/mips/au1000/pb1200/irqmap.c66
-rw-r--r--arch/mips/au1000/pb1500/Makefile6
-rw-r--r--arch/mips/au1000/pb1500/board_setup.c46
-rw-r--r--arch/mips/au1000/pb1500/init.c20
-rw-r--r--arch/mips/au1000/pb1500/irqmap.c6
-rw-r--r--arch/mips/au1000/pb1550/Makefile7
-rw-r--r--arch/mips/au1000/pb1550/board_setup.c16
-rw-r--r--arch/mips/au1000/pb1550/init.c20
-rw-r--r--arch/mips/au1000/pb1550/irqmap.c6
-rw-r--r--arch/mips/au1000/xxs1500/Makefile3
-rw-r--r--arch/mips/au1000/xxs1500/board_setup.c39
-rw-r--r--arch/mips/au1000/xxs1500/init.c11
-rw-r--r--arch/mips/au1000/xxs1500/irqmap.c2
-rw-r--r--arch/mips/emma2rh/markeins/setup.c7
-rw-r--r--arch/mips/kernel/Makefile2
-rw-r--r--arch/mips/kernel/cpu-bugs64.c2
-rw-r--r--arch/mips/kernel/irixelf.c11
-rw-r--r--arch/mips/kernel/kspd.c5
-rw-r--r--arch/mips/kernel/rtlx.c65
-rw-r--r--arch/mips/kernel/setup.c1
-rw-r--r--arch/mips/kernel/smp.c4
-rw-r--r--arch/mips/kernel/vpe.c29
-rw-r--r--arch/mips/mm/highmem.c1
-rw-r--r--arch/mips/oprofile/op_model_mipsxx.c6
-rw-r--r--arch/mips/pci/fixup-au1000.c7
-rw-r--r--arch/mips/pci/ops-au1000.c115
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c5
-rw-r--r--arch/mips/sgi-ip27/ip27-timer.c4
-rw-r--r--arch/mn10300/Kconfig11
-rw-r--r--arch/mn10300/boot/install.sh16
-rw-r--r--arch/parisc/mm/init.c2
-rw-r--r--arch/powerpc/boot/dts/sequoia.dts9
-rw-r--r--arch/powerpc/kernel/Makefile6
-rw-r--r--arch/powerpc/kernel/btext.c1
-rw-r--r--arch/powerpc/kernel/cputable.c53
-rw-r--r--arch/powerpc/kernel/head_44x.S9
-rw-r--r--arch/powerpc/kernel/head_64.S4
-rw-r--r--arch/powerpc/kernel/isa-bridge.c3
-rw-r--r--arch/powerpc/kernel/setup_64.c10
-rw-r--r--arch/powerpc/lib/Makefile1
-rw-r--r--arch/powerpc/lib/devres.c42
-rw-r--r--arch/powerpc/platforms/cell/interrupt.c53
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c31
-rw-r--r--arch/powerpc/platforms/cell/spu_priv1_mmio.c16
-rw-r--r--arch/powerpc/platforms/cell/spufs/fault.c17
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c10
-rw-r--r--arch/powerpc/platforms/cell/spufs/run.c38
-rw-r--r--arch/powerpc/platforms/cell/spufs/sched.c7
-rw-r--r--arch/powerpc/platforms/cell/spufs/spufs.h3
-rw-r--r--arch/powerpc/platforms/cell/spufs/switch.c71
-rw-r--r--arch/powerpc/platforms/chrp/pegasos_eth.c4
-rw-r--r--arch/powerpc/platforms/pseries/scanlog.c19
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c2
-rw-r--r--arch/powerpc/sysdev/ppc4xx_pci.c180
-rw-r--r--arch/powerpc/xmon/xmon.c6
-rw-r--r--arch/ppc/Makefile2
-rw-r--r--arch/ppc/kernel/ppc_ksyms.c1
-rw-r--r--arch/ppc/kernel/setup.c1
-rw-r--r--arch/ppc/platforms/residual.c1
-rw-r--r--arch/ppc/syslib/mv64x60.c3
-rw-r--r--arch/s390/Kconfig7
-rw-r--r--arch/s390/kernel/compat_wrapper.S2
-rw-r--r--arch/s390/kernel/entry.S29
-rw-r--r--arch/s390/kernel/entry64.S57
-rw-r--r--arch/s390/kernel/ptrace.c100
-rw-r--r--arch/s390/kvm/Kconfig1
-rw-r--r--arch/s390/kvm/intercept.c3
-rw-r--r--arch/s390/kvm/kvm-s390.c5
-rw-r--r--arch/s390/mm/Makefile1
-rw-r--r--arch/s390/mm/init.c3
-rw-r--r--arch/s390/mm/page-states.c79
-rw-r--r--arch/sh/Kconfig17
-rw-r--r--arch/sh/Kconfig.debug1
-rw-r--r--arch/sh/Makefile1
-rw-r--r--arch/sh/boards/mpc1211/Makefile8
-rw-r--r--arch/sh/boards/mpc1211/pci.c295
-rw-r--r--arch/sh/boards/mpc1211/rtc.c136
-rw-r--r--arch/sh/boards/mpc1211/setup.c347
-rw-r--r--arch/sh/boards/renesas/migor/setup.c11
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq-r7780mp.c2
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq-r7780rp.c2
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq-r7785rp.c2
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c24
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/setup.c7
-rw-r--r--arch/sh/boards/se/7206/setup.c17
-rw-r--r--arch/sh/boards/se/7722/setup.c6
-rw-r--r--arch/sh/boot/compressed/Makefile_321
-rw-r--r--arch/sh/boot/compressed/Makefile_641
-rw-r--r--arch/sh/kernel/cpu/irq/intc-sh5.c73
-rw-r--r--arch/sh/kernel/cpu/irq/intc.c93
-rw-r--r--arch/sh/kernel/cpu/sh2a/fpu.c4
-rw-r--r--arch/sh/kernel/cpu/sh3/Makefile2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh3.c71
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7705.c22
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c32
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7710.c25
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7720.c35
-rw-r--r--arch/sh/kernel/cpu/sh5/entry.S28
-rw-r--r--arch/sh/kernel/cpu/sh5/probe.c4
-rw-r--r--arch/sh/kernel/early_printk.c30
-rw-r--r--arch/sh/kernel/kgdb_stub.c8
-rw-r--r--arch/sh/kernel/setup.c46
-rw-r--r--arch/sh/kernel/sh_ksyms_32.c2
-rw-r--r--arch/sh/kernel/sh_ksyms_64.c26
-rw-r--r--arch/sh/kernel/time_64.c5
-rw-r--r--arch/sh/lib64/dbg.c2
-rw-r--r--arch/sh/mm/Makefile_647
-rw-r--r--arch/sh/mm/cache-sh5.c2
-rw-r--r--arch/sh/mm/ioremap_64.c2
-rw-r--r--arch/sh/mm/numa.c2
-rw-r--r--arch/sh/tools/mach-types1
-rw-r--r--arch/sparc/kernel/entry.S2
-rw-r--r--arch/sparc/kernel/process.c25
-rw-r--r--arch/sparc/kernel/ptrace.c6
-rw-r--r--arch/sparc/kernel/rtrap.S11
-rw-r--r--arch/sparc/kernel/signal.c84
-rw-r--r--arch/sparc/kernel/sys_sparc.c51
-rw-r--r--arch/sparc64/kernel/etrap.S7
-rw-r--r--arch/sparc64/kernel/process.c18
-rw-r--r--arch/sparc64/kernel/ptrace.c16
-rw-r--r--arch/sparc64/kernel/rtrap.S7
-rw-r--r--arch/sparc64/kernel/signal.c102
-rw-r--r--arch/sparc64/kernel/signal32.c57
-rw-r--r--arch/sparc64/kernel/smp.c27
-rw-r--r--arch/sparc64/kernel/sys_sparc.c40
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c64
-rw-r--r--arch/sparc64/kernel/systbls.S2
-rw-r--r--arch/sparc64/mm/init.c32
-rw-r--r--arch/um/Kconfig.char6
-rw-r--r--arch/um/Makefile5
-rw-r--r--arch/um/drivers/chan_user.c1
-rw-r--r--arch/um/drivers/cow_sys.h2
-rw-r--r--arch/um/drivers/daemon_user.c4
-rw-r--r--arch/um/drivers/fd.c2
-rw-r--r--arch/um/drivers/hostaudio_kern.c2
-rw-r--r--arch/um/drivers/line.c4
-rw-r--r--arch/um/drivers/mcast_user.c3
-rw-r--r--arch/um/drivers/net_user.c2
-rw-r--r--arch/um/drivers/port_user.c2
-rw-r--r--arch/um/drivers/pty.c2
-rw-r--r--arch/um/drivers/random.c122
-rw-r--r--arch/um/drivers/slip_user.c2
-rw-r--r--arch/um/drivers/tty.c2
-rw-r--r--arch/um/drivers/ubd_kern.c4
-rw-r--r--arch/um/drivers/xterm.c2
-rw-r--r--arch/um/include/as-layout.h14
-rw-r--r--arch/um/include/line.h6
-rw-r--r--arch/um/include/os.h1
-rw-r--r--arch/um/include/process.h20
-rw-r--r--arch/um/include/skas_ptrace.h13
-rw-r--r--arch/um/include/sysdep-i386/ptrace_user.h30
-rw-r--r--arch/um/include/sysdep-i386/sigcontext.h2
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace_user.h17
-rw-r--r--arch/um/include/um_malloc.h9
-rw-r--r--arch/um/kernel/dyn.lds.S7
-rw-r--r--arch/um/kernel/mem.c5
-rw-r--r--arch/um/kernel/time.c4
-rw-r--r--arch/um/kernel/um_arch.c7
-rw-r--r--arch/um/kernel/uml.lds.S7
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c4
-rw-r--r--arch/um/os-Linux/helper.c4
-rw-r--r--arch/um/os-Linux/main.c2
-rw-r--r--arch/um/os-Linux/sigio.c39
-rw-r--r--arch/um/os-Linux/signal.c1
-rw-r--r--arch/um/os-Linux/skas/process.c2
-rw-r--r--arch/um/os-Linux/start_up.c81
-rw-r--r--arch/um/os-Linux/sys-i386/registers.c5
-rw-r--r--arch/um/os-Linux/time.c54
-rw-r--r--arch/um/sys-i386/ptrace.c30
-rw-r--r--arch/um/sys-i386/user-offsets.c2
-rw-r--r--arch/um/sys-x86_64/user-offsets.c1
-rw-r--r--arch/x86/Kconfig3
-rw-r--r--arch/x86/kernel/Makefile4
-rw-r--r--arch/x86/kernel/acpi/realmode/wakeup.lds.S10
-rw-r--r--arch/x86/kernel/cpu/addon_cpuid_features.c21
-rw-r--r--arch/x86/kernel/cpu/common.c27
-rw-r--r--arch/x86/kernel/geode_32.c19
-rw-r--r--arch/x86/kernel/i387.c12
-rw-r--r--arch/x86/kernel/pci-dma.c8
-rw-r--r--arch/x86/kernel/ptrace.c7
-rw-r--r--arch/x86/kernel/setup.c6
-rw-r--r--arch/x86/kernel/setup_32.c7
-rw-r--r--arch/x86/kernel/setup_64.c15
-rw-r--r--arch/x86/kernel/smp.c3
-rw-r--r--arch/x86/kernel/smpboot.c24
-rw-r--r--arch/x86/kernel/x8664_ksyms_64.c3
-rw-r--r--arch/x86/lib/csum-partial_64.c2
-rw-r--r--arch/x86/mm/init_32.c12
-rw-r--r--arch/x86/mm/pat.c54
-rw-r--r--arch/x86/mm/pgtable_32.c7
-rw-r--r--arch/x86/pci/acpi.c41
-rw-r--r--arch/x86/pci/common.c69
-rw-r--r--arch/x86/pci/fixup.c2
-rw-r--r--arch/x86/pci/i386.c4
-rw-r--r--arch/x86/pci/init.c4
-rw-r--r--arch/x86/pci/k8-bus_64.c8
-rw-r--r--arch/x86/pci/pci.h3
-rw-r--r--block/blk-core.c31
-rw-r--r--block/blk-ioc.c2
-rw-r--r--block/blk-merge.c12
-rw-r--r--block/blk-settings.c8
-rw-r--r--block/blk-sysfs.c6
-rw-r--r--block/blk-tag.c9
-rw-r--r--block/blktrace.c2
-rw-r--r--block/cfq-iosched.c23
-rw-r--r--block/compat_ioctl.c2
-rw-r--r--block/genhd.c9
-rw-r--r--crypto/hmac.c25
-rw-r--r--drivers/accessibility/Kconfig12
-rw-r--r--drivers/ata/Kconfig13
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci.c4
-rw-r--r--drivers/ata/ata_generic.c6
-rw-r--r--drivers/ata/ata_piix.c25
-rw-r--r--drivers/ata/libata-core.c1
-rw-r--r--drivers/ata/libata-eh.c2
-rw-r--r--drivers/ata/libata-sff.c6
-rw-r--r--drivers/ata/pata_acpi.c6
-rw-r--r--drivers/ata/pata_sch.c206
-rw-r--r--drivers/ata/sata_inic162x.c646
-rw-r--r--drivers/ata/sata_mv.c690
-rw-r--r--drivers/atm/iphase.h3
-rw-r--r--drivers/base/class.c1
-rw-r--r--drivers/base/core.c8
-rw-r--r--drivers/base/memory.c2
-rw-r--r--drivers/base/sys.c3
-rw-r--r--drivers/block/aoe/aoecmd.c10
-rw-r--r--drivers/char/Kconfig1
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c10
-rw-r--r--drivers/char/serial167.c2
-rw-r--r--drivers/char/sx.c9
-rw-r--r--drivers/char/synclink_gt.c2
-rw-r--r--drivers/char/tty_io.c7
-rw-r--r--drivers/char/vt.c6
-rw-r--r--drivers/edac/edac_core.h2
-rw-r--r--drivers/edac/edac_device.c6
-rw-r--r--drivers/edac/edac_mc.c6
-rw-r--r--drivers/edac/edac_pci.c6
-rw-r--r--drivers/i2c/busses/i2c-au1550.c2
-rw-r--r--drivers/i2c/busses/i2c-mpc.c16
-rw-r--r--drivers/i2c/busses/i2c-piix4.c47
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c6
-rw-r--r--drivers/i2c/i2c-core.c14
-rw-r--r--drivers/ide/Kconfig54
-rw-r--r--drivers/ide/ide-iops.c2
-rw-r--r--drivers/ide/legacy/falconide.c2
-rw-r--r--drivers/ide/mips/swarm.c16
-rw-r--r--drivers/ide/pci/alim15x3.c42
-rw-r--r--drivers/ide/pci/cs5520.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c107
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.h12
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_resource.c36
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cm.c6
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_mem.c75
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c68
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.h8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_qp.c13
-rw-r--r--drivers/infiniband/hw/ehca/ehca_classes.h2
-rw-r--r--drivers/infiniband/hw/ehca/ehca_hca.c7
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c4
-rw-r--r--drivers/infiniband/hw/ehca/ehca_qp.c5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_driver.c158
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c91
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba7220.c26
-rw-r--r--drivers/infiniband/hw/ipath/ipath_init_chip.c95
-rw-r--r--drivers/infiniband/hw/ipath/ipath_intr.c80
-rw-r--r--drivers/infiniband/hw/ipath/ipath_kernel.h18
-rw-r--r--drivers/infiniband/hw/ipath/ipath_qp.c237
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c291
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c332
-rw-r--r--drivers/infiniband/hw/ipath/ipath_sdma.c44
-rw-r--r--drivers/infiniband/hw/ipath/ipath_uc.c57
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ud.c66
-rw-r--r--drivers/infiniband/hw/ipath/ipath_user_sdma.h2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c178
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.h64
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c4
-rw-r--r--drivers/infiniband/hw/nes/nes.c4
-rw-r--r--drivers/infiniband/hw/nes/nes.h1
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c6
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c47
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c3
-rw-r--r--drivers/input/misc/Kconfig2
-rw-r--r--drivers/input/serio/hp_sdc.c1
-rw-r--r--drivers/input/serio/i8042-io.h2
-rw-r--r--drivers/isdn/capi/capiutil.c6
-rw-r--r--drivers/isdn/hysdn/Kconfig2
-rw-r--r--drivers/isdn/hysdn/boardergo.c14
-rw-r--r--drivers/macintosh/adb.c30
-rw-r--r--drivers/macintosh/therm_pm72.c31
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c10
-rw-r--r--drivers/md/linear.c1
-rw-r--r--drivers/md/multipath.c1
-rw-r--r--drivers/md/raid0.c1
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c26
-rw-r--r--drivers/media/Kconfig3
-rw-r--r--drivers/media/Makefile2
-rw-r--r--drivers/media/common/tuners/Kconfig50
-rw-r--r--drivers/media/common/tuners/Makefile1
-rw-r--r--drivers/media/common/tuners/mxl5005s.c4110
-rw-r--r--drivers/media/common/tuners/mxl5005s.h131
-rw-r--r--drivers/media/common/tuners/tda18271-common.c24
-rw-r--r--drivers/media/common/tuners/tda18271-fe.c168
-rw-r--r--drivers/media/common/tuners/tda18271-priv.h9
-rw-r--r--drivers/media/common/tuners/tea5767.c6
-rw-r--r--drivers/media/common/tuners/xc5000.c9
-rw-r--r--drivers/media/common/tuners/xc5000.h22
-rw-r--r--drivers/media/common/tuners/xc5000_priv.h2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c2
-rw-r--r--drivers/media/dvb/bt8xx/Kconfig1
-rw-r--r--drivers/media/dvb/cinergyT2/Kconfig2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c28
-rw-r--r--drivers/media/dvb/dvb-usb/Kconfig1
-rw-r--r--drivers/media/dvb/frontends/Kconfig18
-rw-r--r--drivers/media/dvb/frontends/itd1000.c2
-rw-r--r--drivers/media/dvb/frontends/mt312.c9
-rw-r--r--drivers/media/dvb/frontends/mt312.h4
-rw-r--r--drivers/media/dvb/ttpci/Kconfig2
-rw-r--r--drivers/media/dvb/ttusb-dec/Kconfig1
-rw-r--r--drivers/media/video/Kconfig10
-rw-r--r--drivers/media/video/Makefile2
-rw-r--r--drivers/media/video/au0828/Kconfig3
-rw-r--r--drivers/media/video/au0828/au0828-dvb.c6
-rw-r--r--drivers/media/video/bt8xx/Kconfig3
-rw-r--r--drivers/media/video/cx18/Kconfig5
-rw-r--r--drivers/media/video/cx18/cx18-cards.c25
-rw-r--r--drivers/media/video/cx18/cx18-cards.h5
-rw-r--r--drivers/media/video/cx18/cx18-driver.c31
-rw-r--r--drivers/media/video/cx18/cx18-driver.h3
-rw-r--r--drivers/media/video/cx18/cx18-dvb.c40
-rw-r--r--drivers/media/video/cx18/cx18-fileops.c6
-rw-r--r--drivers/media/video/cx18/cx18-fileops.h9
-rw-r--r--drivers/media/video/cx18/cx18-gpio.c47
-rw-r--r--drivers/media/video/cx18/cx18-i2c.c1
-rw-r--r--drivers/media/video/cx18/cx18-queue.c22
-rw-r--r--drivers/media/video/cx18/cx18-queue.h4
-rw-r--r--drivers/media/video/cx18/cx18-streams.c13
-rw-r--r--drivers/media/video/cx18/cx18-streams.h2
-rw-r--r--drivers/media/video/cx23885/Kconfig6
-rw-r--r--drivers/media/video/cx23885/cx23885-cards.c36
-rw-r--r--drivers/media/video/cx23885/cx23885-dvb.c7
-rw-r--r--drivers/media/video/cx25840/Kconfig1
-rw-r--r--drivers/media/video/cx88/Kconfig6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c253
-rw-r--r--drivers/media/video/em28xx/Kconfig3
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c1
-rw-r--r--drivers/media/video/ivtv/Kconfig4
-rw-r--r--drivers/media/video/ivtv/ivtv-controls.c4
-rw-r--r--drivers/media/video/ivtv/ivtv-driver.c8
-rw-r--r--drivers/media/video/ivtv/ivtv-fileops.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.c16
-rw-r--r--drivers/media/video/ivtv/ivtv-ioctl.h6
-rw-r--r--drivers/media/video/ivtv/ivtv-queue.c12
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.c13
-rw-r--r--drivers/media/video/ivtv/ivtv-streams.h2
-rw-r--r--drivers/media/video/ivtv/ivtv-vbi.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-yuv.c2
-rw-r--r--drivers/media/video/ivtv/ivtvfb.c6
-rw-r--r--drivers/media/video/mt9m001.c5
-rw-r--r--drivers/media/video/mt9v022.c7
-rw-r--r--drivers/media/video/pvrusb2/Kconfig4
-rw-r--r--drivers/media/video/saa7134/Kconfig3
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c140
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c2
-rw-r--r--drivers/media/video/stk-webcam.c7
-rw-r--r--drivers/media/video/tcm825x.c7
-rw-r--r--drivers/media/video/tlv320aic23b.c6
-rw-r--r--drivers/media/video/tuner-core.c38
-rw-r--r--drivers/media/video/tvaudio.c13
-rw-r--r--drivers/media/video/tveeprom.c10
-rw-r--r--drivers/media/video/usbvision/Kconfig2
-rw-r--r--drivers/misc/kgdbts.c75
-rw-r--r--drivers/misc/sgi-xp/xp.h305
-rw-r--r--drivers/misc/sgi-xp/xp_main.c44
-rw-r--r--drivers/misc/sgi-xp/xpc.h83
-rw-r--r--drivers/misc/sgi-xp/xpc_channel.c186
-rw-r--r--drivers/misc/sgi-xp/xpc_main.c60
-rw-r--r--drivers/misc/sgi-xp/xpc_partition.c74
-rw-r--r--drivers/misc/sgi-xp/xpnet.c22
-rw-r--r--drivers/mmc/host/mmci.c14
-rw-r--r--drivers/mmc/host/sdhci.h2
-rw-r--r--drivers/mtd/maps/Kconfig9
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/mpc1211.c80
-rw-r--r--drivers/net/3c59x.c73
-rw-r--r--drivers/net/Kconfig16
-rw-r--r--drivers/net/appletalk/cops.c16
-rw-r--r--drivers/net/atlx/atl1.c157
-rw-r--r--drivers/net/atlx/atl1.h2
-rw-r--r--drivers/net/atlx/atlx.c2
-rw-r--r--drivers/net/atlx/atlx.h7
-rw-r--r--drivers/net/bonding/bond_main.c24
-rw-r--r--drivers/net/bonding/bond_sysfs.c28
-rw-r--r--drivers/net/cxgb3/adapter.h1
-rw-r--r--drivers/net/cxgb3/common.h1
-rw-r--r--drivers/net/cxgb3/cxgb3_main.c44
-rw-r--r--drivers/net/cxgb3/regs.h8
-rw-r--r--drivers/net/cxgb3/sge.c29
-rw-r--r--drivers/net/cxgb3/t3_hw.c28
-rw-r--r--drivers/net/dm9000.c37
-rw-r--r--drivers/net/e1000e/defines.h10
-rw-r--r--drivers/net/e1000e/e1000.h7
-rw-r--r--drivers/net/e1000e/ethtool.c45
-rw-r--r--drivers/net/e1000e/hw.h22
-rw-r--r--drivers/net/e1000e/ich8lan.c83
-rw-r--r--drivers/net/e1000e/netdev.c330
-rw-r--r--drivers/net/e1000e/phy.c278
-rw-r--r--drivers/net/eexpress.c11
-rw-r--r--drivers/net/ehea/ehea.h27
-rw-r--r--drivers/net/ehea/ehea_main.c25
-rw-r--r--drivers/net/ehea/ehea_qmr.c286
-rw-r--r--drivers/net/fs_enet/mii-fec.c3
-rw-r--r--drivers/net/gianfar.c7
-rw-r--r--drivers/net/gianfar.h3
-rw-r--r--drivers/net/gianfar_sysfs.c10
-rw-r--r--drivers/net/irda/nsc-ircc.c6
-rw-r--r--drivers/net/irda/smsc-ircc2.c5
-rw-r--r--drivers/net/macvlan.c2
-rw-r--r--drivers/net/mlx4/mr.c2
-rw-r--r--drivers/net/mv643xx_eth.c160
-rw-r--r--drivers/net/myri10ge/myri10ge.c730
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp.h56
-rw-r--r--drivers/net/myri10ge/myri10ge_mcp_gen_header.h39
-rw-r--r--drivers/net/niu.c64
-rw-r--r--drivers/net/niu.h9
-rw-r--r--drivers/net/pcnet32.c61
-rw-r--r--drivers/net/phy/phy.c2
-rw-r--r--drivers/net/ppp_generic.c1
-rw-r--r--drivers/net/pppol2tp.c13
-rw-r--r--drivers/net/ps3_gelic_wireless.c2
-rw-r--r--drivers/net/sfc/Makefile4
-rw-r--r--drivers/net/sfc/boards.h2
-rw-r--r--drivers/net/sfc/efx.c4
-rw-r--r--drivers/net/sfc/enum.h49
-rw-r--r--drivers/net/sfc/ethtool.c259
-rw-r--r--drivers/net/sfc/falcon.c8
-rw-r--r--drivers/net/sfc/falcon_hwdefs.h16
-rw-r--r--drivers/net/sfc/falcon_xmac.c82
-rw-r--r--drivers/net/sfc/mdio_10g.c78
-rw-r--r--drivers/net/sfc/mdio_10g.h24
-rw-r--r--drivers/net/sfc/net_driver.h28
-rw-r--r--drivers/net/sfc/rx.c11
-rw-r--r--drivers/net/sfc/selftest.c717
-rw-r--r--drivers/net/sfc/selftest.h50
-rw-r--r--drivers/net/sfc/sfe4001.c14
-rw-r--r--drivers/net/sfc/tenxpress.c91
-rw-r--r--drivers/net/sfc/tx.c664
-rw-r--r--drivers/net/sfc/xfp_phy.c36
-rw-r--r--drivers/net/sky2.h4
-rw-r--r--drivers/net/tulip/uli526x.c38
-rw-r--r--drivers/net/ucc_geth.c278
-rw-r--r--drivers/net/ucc_geth.h48
-rw-r--r--drivers/net/ucc_geth_ethtool.c6
-rw-r--r--drivers/net/ucc_geth_mii.c4
-rw-r--r--drivers/net/usb/asix.c4
-rw-r--r--drivers/net/wan/Kconfig4
-rw-r--r--drivers/net/wan/cosa.c14
-rw-r--r--drivers/net/wan/hdlc_ppp.c2
-rw-r--r--drivers/net/wan/hostess_sv11.c12
-rw-r--r--drivers/net/wan/lapbether.c1
-rw-r--r--drivers/net/wan/lmc/lmc_main.c1
-rw-r--r--drivers/net/wan/sealevel.c1
-rw-r--r--drivers/net/wireless/iwlwifi/Kconfig3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965-rs.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_dev.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00pci.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c31
-rw-r--r--drivers/net/wireless/strip.c2
-rw-r--r--drivers/net/wireless/wavelan.c4
-rw-r--r--drivers/net/wireless/wavelan_cs.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c6
-rw-r--r--drivers/oprofile/cpu_buffer.c2
-rw-r--r--drivers/oprofile/cpu_buffer.h2
-rw-r--r--drivers/pci/intel-iommu.c6
-rw-r--r--drivers/pci/pci-acpi.c109
-rw-r--r--drivers/pci/probe.c33
-rw-r--r--drivers/pci/quirks.c1
-rw-r--r--drivers/pnp/base.h1
-rw-r--r--drivers/pnp/interface.c2
-rw-r--r--drivers/pnp/quirks.c132
-rw-r--r--drivers/pnp/resource.c2
-rw-r--r--drivers/pnp/support.c8
-rw-r--r--drivers/rtc/rtc-ds1511.c4
-rw-r--r--drivers/rtc/rtc-lib.c2
-rw-r--r--drivers/rtc/rtc-m41t80.c3
-rw-r--r--drivers/rtc/rtc-s35390a.c2
-rw-r--r--drivers/rtc/rtc-sh.c14
-rw-r--r--drivers/s390/char/tty3270.c15
-rw-r--r--drivers/s390/cio/blacklist.c323
-rw-r--r--drivers/s390/cio/cio.c39
-rw-r--r--drivers/s390/cio/cio.h2
-rw-r--r--drivers/s390/cio/cio_debug.h6
-rw-r--r--drivers/s390/cio/css.c4
-rw-r--r--drivers/s390/cio/device.c25
-rw-r--r--drivers/s390/cio/device_fsm.c44
-rw-r--r--drivers/s390/cio/device_id.c4
-rw-r--r--drivers/s390/cio/device_pgid.c12
-rw-r--r--drivers/s390/s390mach.c3
-rw-r--r--drivers/sbus/char/bpp.c2
-rw-r--r--drivers/scsi/Kconfig1
-rw-r--r--drivers/scsi/aha152x.c8
-rw-r--r--drivers/scsi/dpt_i2o.c78
-rw-r--r--drivers/scsi/dpti.h13
-rw-r--r--drivers/scsi/gdth.c51
-rw-r--r--drivers/scsi/libiscsi.c29
-rw-r--r--drivers/scsi/qla1280.c4
-rw-r--r--drivers/serial/Kconfig6
-rw-r--r--drivers/serial/bfin_5xx.c98
-rw-r--r--drivers/serial/crisv10.c2
-rw-r--r--drivers/serial/mcfserial.c1
-rw-r--r--drivers/serial/serial_core.c3
-rw-r--r--drivers/serial/sh-sci.c32
-rw-r--r--drivers/serial/sh-sci.h27
-rw-r--r--drivers/spi/Kconfig1
-rw-r--r--drivers/spi/mpc52xx_psc_spi.c2
-rw-r--r--drivers/spi/pxa2xx_spi.c2
-rw-r--r--drivers/spi/spi_mpc83xx.c411
-rw-r--r--drivers/usb/c67x00/c67x00-ll-hpi.c1
-rw-r--r--drivers/usb/class/cdc-acm.c3
-rw-r--r--drivers/usb/core/endpoint.c11
-rw-r--r--drivers/usb/core/message.c1
-rw-r--r--drivers/usb/core/sysfs.c137
-rw-r--r--drivers/usb/core/usb.c1
-rw-r--r--drivers/usb/core/usb.h4
-rw-r--r--drivers/usb/gadget/amd5536udc.c10
-rw-r--r--drivers/usb/gadget/atmel_usba_udc.c48
-rw-r--r--drivers/usb/gadget/pxa27x_udc.c17
-rw-r--r--drivers/usb/gadget/pxa27x_udc.h8
-rw-r--r--drivers/usb/gadget/serial.c778
-rw-r--r--drivers/usb/host/Kconfig2
-rw-r--r--drivers/usb/host/isp1760-hcd.c4
-rw-r--r--drivers/usb/host/isp1760-if.c2
-rw-r--r--drivers/usb/host/ohci-sm501.c2
-rw-r--r--drivers/usb/misc/ldusb.c4
-rw-r--r--drivers/usb/misc/usbtest.c5
-rw-r--r--drivers/usb/serial/Kconfig9
-rw-r--r--drivers/usb/serial/Makefile1
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/iuu_phoenix.c6
-rw-r--r--drivers/usb/serial/moto_modem.c70
-rw-r--r--drivers/usb/serial/option.c9
-rw-r--r--drivers/usb/storage/unusual_devs.h71
-rw-r--r--drivers/video/Kconfig1
-rw-r--r--drivers/video/atmel_lcdfb.c11
-rw-r--r--drivers/video/bw2.c8
-rw-r--r--drivers/video/cg14.c5
-rw-r--r--drivers/video/cg3.c8
-rw-r--r--drivers/video/cg6.c6
-rw-r--r--drivers/video/console/fbcon.c31
-rw-r--r--drivers/video/ffb.c7
-rw-r--r--drivers/video/geode/lxfb_ops.c22
-rw-r--r--drivers/video/leo.c7
-rw-r--r--drivers/video/logo/Kconfig10
-rw-r--r--drivers/video/logo/Makefile2
-rw-r--r--drivers/video/logo/logo.c10
-rw-r--r--drivers/video/logo/logo_blackfin_clut224.ppm1127
-rw-r--r--drivers/video/logo/logo_blackfin_vga16.ppm1127
-rw-r--r--drivers/video/p9100.c7
-rw-r--r--drivers/video/pnx4008/pnxrgbfb.c11
-rw-r--r--drivers/video/pxafb.c8
-rw-r--r--drivers/video/sbuslib.c9
-rw-r--r--drivers/video/sbuslib.h5
-rw-r--r--drivers/video/sunxvr2500.c3
-rw-r--r--drivers/video/sunxvr500.c3
-rw-r--r--drivers/video/tcx.c25
-rw-r--r--drivers/video/tridentfb.c25
-rw-r--r--fs/9p/fid.h15
-rw-r--r--fs/9p/v9fs.c57
-rw-r--r--fs/9p/v9fs.h85
-rw-r--r--fs/9p/vfs_addr.c2
-rw-r--r--fs/9p/vfs_dir.c2
-rw-r--r--fs/9p/vfs_file.c11
-rw-r--r--fs/9p/vfs_inode.c50
-rw-r--r--fs/9p/vfs_super.c35
-rw-r--r--fs/affs/affs.h4
-rw-r--r--fs/affs/file.c25
-rw-r--r--fs/affs/inode.c34
-rw-r--r--fs/affs/namei.c6
-rw-r--r--fs/affs/super.c18
-rw-r--r--fs/bio.c3
-rw-r--r--fs/cifs/CHANGES3
-rw-r--r--fs/cifs/asn1.c10
-rw-r--r--fs/cifs/cifs_dfs_ref.c25
-rw-r--r--fs/cifs/cifsacl.c16
-rw-r--r--fs/cifs/cifsfs.c72
-rw-r--r--fs/cifs/cifsfs.h10
-rw-r--r--fs/cifs/cifsglob.h44
-rw-r--r--fs/cifs/cifspdu.h3
-rw-r--r--fs/cifs/cifsproto.h15
-rw-r--r--fs/cifs/cifssmb.c54
-rw-r--r--fs/cifs/connect.c232
-rw-r--r--fs/cifs/dir.c34
-rw-r--r--fs/cifs/dns_resolve.c62
-rw-r--r--fs/cifs/fcntl.c2
-rw-r--r--fs/cifs/file.c80
-rw-r--r--fs/cifs/inode.c81
-rw-r--r--fs/cifs/link.c2
-rw-r--r--fs/cifs/misc.c33
-rw-r--r--fs/cifs/netmisc.c32
-rw-r--r--fs/cifs/readdir.c12
-rw-r--r--fs/cifs/smbencrypt.c8
-rw-r--r--fs/cifs/xattr.c2
-rw-r--r--fs/dquot.c10
-rw-r--r--fs/ecryptfs/inode.c13
-rw-r--r--fs/ecryptfs/miscdev.c2
-rw-r--r--fs/exec.c2
-rw-r--r--fs/ext3/xattr.c5
-rw-r--r--fs/ext4/mballoc.c6
-rw-r--r--fs/ext4/xattr.c5
-rw-r--r--fs/fuse/file.c2
-rw-r--r--fs/fuse/fuse_i.h3
-rw-r--r--fs/fuse/inode.c5
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hppfs/Makefile6
-rw-r--r--fs/hppfs/hppfs.c (renamed from fs/hppfs/hppfs_kern.c)82
-rw-r--r--fs/inode.c5
-rw-r--r--fs/jbd/commit.c2
-rw-r--r--fs/jbd2/journal.c4
-rw-r--r--fs/locks.c19
-rw-r--r--fs/pipe.c6
-rw-r--r--fs/proc/array.c1
-rw-r--r--fs/proc/task_mmu.c2
-rw-r--r--fs/splice.c31
-rw-r--r--fs/sysfs/dir.c6
-rw-r--r--fs/udf/namei.c145
-rw-r--r--fs/udf/partition.c4
-rw-r--r--fs/udf/super.c1
-rw-r--r--fs/udf/udfdecl.h1
-rw-r--r--fs/ufs/ufs.h1
-rw-r--r--include/asm-alpha/barrier.h2
-rw-r--r--include/asm-alpha/param.h4
-rw-r--r--include/asm-alpha/pgtable.h21
-rw-r--r--include/asm-arm/arch-pxa/pm.h2
-rw-r--r--include/asm-arm/arch-pxa/system.h3
-rw-r--r--include/asm-blackfin/dpmc.h10
-rw-r--r--include/asm-blackfin/entry.h5
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_serial_5xx.h5
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_serial_5xx.h5
-rw-r--r--include/asm-blackfin/mach-bf533/defBF532.h2
-rw-r--r--include/asm-blackfin/mach-bf533/irq.h14
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_serial_5xx.h5
-rw-r--r--include/asm-blackfin/mach-bf537/irq.h35
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_serial_5xx.h3
-rw-r--r--include/asm-blackfin/mach-bf548/defBF54x_base.h20
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_serial_5xx.h5
-rw-r--r--include/asm-blackfin/mach-bf561/defBF561.h28
-rw-r--r--include/asm-blackfin/mach-bf561/irq.h13
-rw-r--r--include/asm-blackfin/mach-common/context.S5
-rw-r--r--include/asm-blackfin/time.h4
-rw-r--r--include/asm-frv/system.h2
-rw-r--r--include/asm-h8300/param.h8
-rw-r--r--include/asm-m68k/machw.h30
-rw-r--r--include/asm-mips/bitops.h14
-rw-r--r--include/asm-mips/compiler.h4
-rw-r--r--include/asm-mips/mach-au1x00/au1000.h1644
-rw-r--r--include/asm-mips/mach-au1x00/au1000_dma.h179
-rw-r--r--include/asm-mips/mach-au1x00/au1000_gpio.h18
-rw-r--r--include/asm-mips/mach-au1x00/au1550_spi.h2
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx.h4
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_dbdma.h155
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_ide.h251
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_psc.h131
-rw-r--r--include/asm-mips/mach-db1x00/db1200.h73
-rw-r--r--include/asm-mips/mach-db1x00/db1x00.h83
-rw-r--r--include/asm-mips/mach-pb1x00/pb1000.h189
-rw-r--r--include/asm-mips/mach-pb1x00/pb1100.h96
-rw-r--r--include/asm-mips/mach-pb1x00/pb1200.h93
-rw-r--r--include/asm-mips/mach-pb1x00/pb1500.h38
-rw-r--r--include/asm-mips/mach-pb1x00/pb1550.h51
-rw-r--r--include/asm-mips/rtlx.h4
-rw-r--r--include/asm-mn10300/processor.h2
-rw-r--r--include/asm-powerpc/io.h8
-rw-r--r--include/asm-powerpc/pgtable-ppc32.h7
-rw-r--r--include/asm-powerpc/spu.h9
-rw-r--r--include/asm-powerpc/spu_csa.h3
-rw-r--r--include/asm-ppc/system.h2
-rw-r--r--include/asm-s390/kvm_host.h1
-rw-r--r--include/asm-s390/page.h11
-rw-r--r--include/asm-s390/ptrace.h2
-rw-r--r--include/asm-s390/system.h6
-rw-r--r--include/asm-s390/types.h4
-rw-r--r--include/asm-sh/cpu-sh3/dma.h10
-rw-r--r--include/asm-sh/hw_irq.h19
-rw-r--r--include/asm-sh/io.h12
-rw-r--r--include/asm-sh/keyboard.h13
-rw-r--r--include/asm-sh/mmu_context.h4
-rw-r--r--include/asm-sh/mmzone.h2
-rw-r--r--include/asm-sh/mpc1211/dma.h303
-rw-r--r--include/asm-sh/mpc1211/io.h22
-rw-r--r--include/asm-sh/mpc1211/keyboard.h60
-rw-r--r--include/asm-sh/mpc1211/m1543c.h200
-rw-r--r--include/asm-sh/mpc1211/mc146818rtc.h6
-rw-r--r--include/asm-sh/mpc1211/mpc1211.h18
-rw-r--r--include/asm-sh/mpc1211/pci.h38
-rw-r--r--include/asm-sh/r7780rp.h4
-rw-r--r--include/asm-sh/tlb_64.h10
-rw-r--r--include/asm-sh/topology.h11
-rw-r--r--include/asm-sh/uaccess_64.h2
-rw-r--r--include/asm-sparc/mman.h5
-rw-r--r--include/asm-sparc/psr.h1
-rw-r--r--include/asm-sparc/ptrace.h13
-rw-r--r--include/asm-sparc/signal.h8
-rw-r--r--include/asm-sparc64/mman.h5
-rw-r--r--include/asm-sparc64/psrcompat.h2
-rw-r--r--include/asm-sparc64/pstate.h1
-rw-r--r--include/asm-sparc64/ptrace.h11
-rw-r--r--include/asm-sparc64/signal.h8
-rw-r--r--include/asm-sparc64/thread_info.h28
-rw-r--r--include/asm-sparc64/ttable.h7
-rw-r--r--include/asm-um/irq.h3
-rw-r--r--include/asm-um/keyboard.h6
-rw-r--r--include/asm-um/page.h17
-rw-r--r--include/asm-um/param.h2
-rw-r--r--include/asm-v850/param.h2
-rw-r--r--include/asm-x86/bitops.h37
-rw-r--r--include/asm-x86/geode.h12
-rw-r--r--include/asm-x86/i387.h10
-rw-r--r--include/asm-x86/pat.h8
-rw-r--r--include/asm-x86/pgtable.h16
-rw-r--r--include/asm-x86/pgtable_32.h9
-rw-r--r--include/asm-x86/pgtable_64.h6
-rw-r--r--include/asm-x86/spinlock.h18
-rw-r--r--include/asm-x86/topology.h18
-rw-r--r--include/asm-xtensa/param.h2
-rw-r--r--include/linux/atm.h7
-rw-r--r--include/linux/atm_tcp.h12
-rw-r--r--include/linux/bitmap.h1
-rw-r--r--include/linux/compiler.h12
-rw-r--r--include/linux/cpumask.h7
-rw-r--r--include/linux/device.h1
-rw-r--r--include/linux/exportfs.h21
-rw-r--r--include/linux/fs.h6
-rw-r--r--include/linux/fuse.h1
-rw-r--r--include/linux/genhd.h39
-rw-r--r--include/linux/hardirq.h18
-rw-r--r--include/linux/i2c.h2
-rw-r--r--include/linux/ide.h9
-rw-r--r--include/linux/io.h1
-rw-r--r--include/linux/ioprio.h14
-rw-r--r--include/linux/kernel.h12
-rw-r--r--include/linux/kgdb.h4
-rw-r--r--include/linux/libata.h13
-rw-r--r--include/linux/mm_types.h13
-rw-r--r--include/linux/mv643xx_eth.h16
-rw-r--r--include/linux/netdevice.h35
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h1
-rw-r--r--include/linux/of_i2c.h4
-rw-r--r--include/linux/parser.h2
-rw-r--r--include/linux/pci.h5
-rw-r--r--include/linux/percpu.h8
-rw-r--r--include/linux/phy.h5
-rw-r--r--include/linux/rcupdate.h12
-rw-r--r--include/linux/sched.h44
-rw-r--r--include/linux/usb/association.h150
-rw-r--r--include/linux/vermagic.h8
-rw-r--r--include/media/v4l2-i2c-drv-legacy.h2
-rw-r--r--include/media/v4l2-i2c-drv.h2
-rw-r--r--include/net/9p/9p.h240
-rw-r--r--include/net/9p/client.h35
-rw-r--r--include/net/9p/transport.h44
-rw-r--r--include/net/ip.h2
-rw-r--r--include/net/irda/discovery.h3
-rw-r--r--include/net/syncppp.h2
-rw-r--r--include/net/xfrm.h48
-rw-r--r--include/sound/soc.h2
-rw-r--r--init/Kconfig25
-rw-r--r--init/do_mounts.c27
-rw-r--r--init/main.c19
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/cpuset.c52
-rw-r--r--kernel/futex.c176
-rw-r--r--kernel/kgdb.c16
-rw-r--r--kernel/module.c25
-rw-r--r--kernel/relay.c2
-rw-r--r--kernel/sched.c354
-rw-r--r--kernel/sched_clock.c236
-rw-r--r--kernel/sched_debug.c7
-rw-r--r--kernel/sched_fair.c50
-rw-r--r--kernel/sched_idletask.c2
-rw-r--r--kernel/sched_rt.c9
-rw-r--r--lib/Kconfig.kgdb16
-rw-r--r--lib/bitmap.c16
-rw-r--r--lib/devres.c2
-rw-r--r--lib/hexdump.c7
-rw-r--r--lib/kernel_lock.c120
-rw-r--r--lib/lmb.c45
-rw-r--r--lib/parser.c32
-rw-r--r--mm/filemap.c7
-rw-r--r--mm/memory.c26
-rw-r--r--mm/memory_hotplug.c86
-rw-r--r--mm/mprotect.c11
-rw-r--r--mm/page_alloc.c3
-rw-r--r--mm/pdflush.c4
-rw-r--r--mm/slub.c2
-rw-r--r--mm/vmstat.c2
-rw-r--r--net/9p/Kconfig10
-rw-r--r--net/9p/Makefile3
-rw-r--r--net/9p/client.c32
-rw-r--r--net/9p/conv.c128
-rw-r--r--net/9p/error.c15
-rw-r--r--net/9p/fcprint.c8
-rw-r--r--net/9p/mod.c8
-rw-r--r--net/9p/trans_fd.c204
-rw-r--r--net/9p/trans_virtio.c175
-rw-r--r--net/9p/util.c36
-rw-r--r--net/atm/br2684.c4
-rw-r--r--net/bridge/br_if.c12
-rw-r--r--net/can/af_can.c16
-rw-r--r--net/core/dev.c18
-rw-r--r--net/core/netpoll.c2
-rw-r--r--net/core/skbuff.c4
-rw-r--r--net/core/sock.c2
-rw-r--r--net/dccp/feat.c2
-rw-r--r--net/decnet/dn_route.c12
-rw-r--r--net/econet/af_econet.c2
-rw-r--r--net/ipv4/arp.c2
-rw-r--r--net/ipv4/cipso_ipv4.c4
-rw-r--r--net/ipv4/igmp.c4
-rw-r--r--net/ipv4/ip_input.c2
-rw-r--r--net/ipv4/ipconfig.c6
-rw-r--r--net/ipv4/raw.c10
-rw-r--r--net/ipv4/route.c18
-rw-r--r--net/ipv4/tcp_input.c45
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/mcast.c4
-rw-r--r--net/ipv6/ndisc.c4
-rw-r--r--net/ipv6/raw.c10
-rw-r--r--net/ipv6/route.c6
-rw-r--r--net/ipv6/sit.c2
-rw-r--r--net/irda/discovery.c8
-rw-r--r--net/irda/irlmp.c5
-rw-r--r--net/irda/irnet/irnet_irda.c5
-rw-r--r--net/mac80211/debugfs_key.c15
-rw-r--r--net/mac80211/iface.c9
-rw-r--r--net/mac80211/main.c7
-rw-r--r--net/mac80211/mesh.c2
-rw-r--r--net/mac80211/mesh_hwmp.c2
-rw-r--r--net/mac80211/mesh_pathtbl.c17
-rw-r--r--net/mac80211/mlme.c64
-rw-r--r--net/mac80211/rc80211_pid_debugfs.c4
-rw-r--r--net/mac80211/rx.c12
-rw-r--r--net/mac80211/tx.c5
-rw-r--r--net/mac80211/util.c10
-rw-r--r--net/mac80211/wme.c3
-rw-r--r--net/netfilter/Kconfig4
-rw-r--r--net/netfilter/nf_conntrack_netlink.c3
-rw-r--r--net/netfilter/nf_conntrack_sip.c22
-rw-r--r--net/netfilter/xt_iprange.c2
-rw-r--r--net/packet/af_packet.c2
-rw-r--r--net/sched/act_simple.c45
-rw-r--r--net/sched/sch_htb.c8
-rw-r--r--net/sctp/sm_make_chunk.c16
-rw-r--r--net/sunrpc/svc.c1
-rw-r--r--net/tipc/core.h11
-rw-r--r--net/xfrm/xfrm_output.c6
-rw-r--r--sound/drivers/Kconfig4
-rw-r--r--sound/drivers/pcsp/pcsp.c4
-rw-r--r--sound/oss/kahlua.c2
-rw-r--r--sound/pci/Kconfig5
-rw-r--r--sound/pci/ac97/ac97_patch.c9
-rw-r--r--sound/pci/hda/patch_realtek.c5
-rw-r--r--sound/pci/hda/patch_sigmatel.c2
-rw-r--r--sound/soc/at91/at91-pcm.c11
-rw-r--r--sound/soc/at91/at91-ssc.c2
-rw-r--r--sound/soc/codecs/tlv320aic3x.c4
-rw-r--r--sound/soc/fsl/fsl_ssi.c2
-rw-r--r--sound/soc/omap/n810.c4
-rw-r--r--sound/soc/s3c24xx/s3c24xx-i2s.c2
-rw-r--r--sound/soc/s3c24xx/s3c24xx-pcm.c2
-rw-r--r--sound/synth/emux/emux_synth.c6
980 files changed, 25442 insertions, 13021 deletions
diff --git a/Documentation/DocBook/kgdb.tmpl b/Documentation/DocBook/kgdb.tmpl
index 97618bed4d65..028a8444d95e 100644
--- a/Documentation/DocBook/kgdb.tmpl
+++ b/Documentation/DocBook/kgdb.tmpl
@@ -72,7 +72,7 @@
72 kgdb is a source level debugger for linux kernel. It is used along 72 kgdb is a source level debugger for linux kernel. It is used along
73 with gdb to debug a linux kernel. The expectation is that gdb can 73 with gdb to debug a linux kernel. The expectation is that gdb can
74 be used to "break in" to the kernel to inspect memory, variables 74 be used to "break in" to the kernel to inspect memory, variables
75 and look through a cal stack information similar to what an 75 and look through call stack information similar to what an
76 application developer would use gdb for. It is possible to place 76 application developer would use gdb for. It is possible to place
77 breakpoints in kernel code and perform some limited execution 77 breakpoints in kernel code and perform some limited execution
78 stepping. 78 stepping.
@@ -93,8 +93,10 @@
93 <chapter id="CompilingAKernel"> 93 <chapter id="CompilingAKernel">
94 <title>Compiling a kernel</title> 94 <title>Compiling a kernel</title>
95 <para> 95 <para>
96 To enable <symbol>CONFIG_KGDB</symbol>, look under the "Kernel debugging" 96 To enable <symbol>CONFIG_KGDB</symbol> you should first turn on
97 and then select "KGDB: kernel debugging with remote gdb". 97 "Prompt for development and/or incomplete code/drivers"
98 (CONFIG_EXPERIMENTAL) in "General setup", then under the
99 "Kernel debugging" select "KGDB: kernel debugging with remote gdb".
98 </para> 100 </para>
99 <para> 101 <para>
100 Next you should choose one of more I/O drivers to interconnect debugging 102 Next you should choose one of more I/O drivers to interconnect debugging
diff --git a/Documentation/cgroups.txt b/Documentation/cgroups.txt
index c298a6690e0d..824fc0274471 100644
--- a/Documentation/cgroups.txt
+++ b/Documentation/cgroups.txt
@@ -310,8 +310,8 @@ and then start a subshell 'sh' in that cgroup:
310 cd /dev/cgroup 310 cd /dev/cgroup
311 mkdir Charlie 311 mkdir Charlie
312 cd Charlie 312 cd Charlie
313 /bin/echo 2-3 > cpus 313 /bin/echo 2-3 > cpuset.cpus
314 /bin/echo 1 > mems 314 /bin/echo 1 > cpuset.mems
315 /bin/echo $$ > tasks 315 /bin/echo $$ > tasks
316 sh 316 sh
317 # The subshell 'sh' is now running in cgroup Charlie 317 # The subshell 'sh' is now running in cgroup Charlie
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 3c35d452b1a9..5b3f31faed56 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -289,6 +289,14 @@ Who: Glauber Costa <gcosta@redhat.com>
289 289
290--------------------------- 290---------------------------
291 291
292What: old style serial driver for ColdFire (CONFIG_SERIAL_COLDFIRE)
293When: 2.6.28
294Why: This driver still uses the old interface and has been replaced
295 by CONFIG_SERIAL_MCF.
296Who: Sebastian Siewior <sebastian@breakpoint.cc>
297
298---------------------------
299
292What: /sys/o2cb symlink 300What: /sys/o2cb symlink
293When: January 2010 301When: January 2010
294Why: /sys/fs/o2cb is the proper location for this information - /sys/o2cb 302Why: /sys/fs/o2cb is the proper location for this information - /sys/o2cb
diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking
index c2992bc54f2f..8b22d7d8b991 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -92,7 +92,6 @@ prototypes:
92 void (*destroy_inode)(struct inode *); 92 void (*destroy_inode)(struct inode *);
93 void (*dirty_inode) (struct inode *); 93 void (*dirty_inode) (struct inode *);
94 int (*write_inode) (struct inode *, int); 94 int (*write_inode) (struct inode *, int);
95 void (*put_inode) (struct inode *);
96 void (*drop_inode) (struct inode *); 95 void (*drop_inode) (struct inode *);
97 void (*delete_inode) (struct inode *); 96 void (*delete_inode) (struct inode *);
98 void (*put_super) (struct super_block *); 97 void (*put_super) (struct super_block *);
@@ -115,7 +114,6 @@ alloc_inode: no no no
115destroy_inode: no 114destroy_inode: no
116dirty_inode: no (must not sleep) 115dirty_inode: no (must not sleep)
117write_inode: no 116write_inode: no
118put_inode: no
119drop_inode: no !!!inode_lock!!! 117drop_inode: no !!!inode_lock!!!
120delete_inode: no 118delete_inode: no
121put_super: yes yes no 119put_super: yes yes no
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index 81e5be6e6e35..b7522c6cbae3 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -205,7 +205,6 @@ struct super_operations {
205 205
206 void (*dirty_inode) (struct inode *); 206 void (*dirty_inode) (struct inode *);
207 int (*write_inode) (struct inode *, int); 207 int (*write_inode) (struct inode *, int);
208 void (*put_inode) (struct inode *);
209 void (*drop_inode) (struct inode *); 208 void (*drop_inode) (struct inode *);
210 void (*delete_inode) (struct inode *); 209 void (*delete_inode) (struct inode *);
211 void (*put_super) (struct super_block *); 210 void (*put_super) (struct super_block *);
@@ -246,9 +245,6 @@ or bottom half).
246 inode to disc. The second parameter indicates whether the write 245 inode to disc. The second parameter indicates whether the write
247 should be synchronous or not, not all filesystems check this flag. 246 should be synchronous or not, not all filesystems check this flag.
248 247
249 put_inode: called when the VFS inode is removed from the inode
250 cache.
251
252 drop_inode: called when the last access to the inode is dropped, 248 drop_inode: called when the last access to the inode is dropped,
253 with the inode_lock spinlock held. 249 with the inode_lock spinlock held.
254 250
diff --git a/Documentation/hwmon/adt7473 b/Documentation/hwmon/adt7473
index 22d8b19046ab..2126de34c711 100644
--- a/Documentation/hwmon/adt7473
+++ b/Documentation/hwmon/adt7473
@@ -69,7 +69,8 @@ point2: Set the pwm speed at a higher temperature bound.
69 69
70The ADT7473 will scale the pwm between the lower and higher pwm speed when 70The ADT7473 will scale the pwm between the lower and higher pwm speed when
71the temperature is between the two temperature boundaries. PWM values range 71the temperature is between the two temperature boundaries. PWM values range
72from 0 (off) to 255 (full speed). 72from 0 (off) to 255 (full speed). Fan speed will be set to maximum when the
73temperature sensor associated with the PWM control exceeds temp#_max.
73 74
74Notes 75Notes
75----- 76-----
diff --git a/Documentation/i2c/functionality b/Documentation/i2c/functionality
index 60cca249e452..42c17c1fb3cd 100644
--- a/Documentation/i2c/functionality
+++ b/Documentation/i2c/functionality
@@ -51,26 +51,38 @@ A few combinations of the above flags are also defined for your convenience:
51 the transparent emulation layer) 51 the transparent emulation layer)
52 52
53 53
54ALGORITHM/ADAPTER IMPLEMENTATION 54ADAPTER IMPLEMENTATION
55-------------------------------- 55----------------------
56 56
57When you write a new algorithm driver, you will have to implement a 57When you write a new adapter driver, you will have to implement a
58function callback `functionality', that gets an i2c_adapter structure 58function callback `functionality'. Typical implementations are given
59pointer as its only parameter: 59below.
60 60
61 struct i2c_algorithm { 61A typical SMBus-only adapter would list all the SMBus transactions it
62 /* Many other things of course; check <linux/i2c.h>! */ 62supports. This example comes from the i2c-piix4 driver:
63 u32 (*functionality) (struct i2c_adapter *); 63
64 static u32 piix4_func(struct i2c_adapter *adapter)
65 {
66 return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
67 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
68 I2C_FUNC_SMBUS_BLOCK_DATA;
64 } 69 }
65 70
66A typically implementation is given below, from i2c-algo-bit.c: 71A typical full-I2C adapter would use the following (from the i2c-pxa
72driver):
67 73
68 static u32 bit_func(struct i2c_adapter *adap) 74 static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
69 { 75 {
70 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 76 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
71 I2C_FUNC_PROTOCOL_MANGLING;
72 } 77 }
73 78
79I2C_FUNC_SMBUS_EMUL includes all the SMBus transactions (with the
80addition of I2C block transactions) which i2c-core can emulate using
81I2C_FUNC_I2C without any help from the adapter driver. The idea is
82to let the client drivers check for the support of SMBus functions
83without having to care whether the said functions are implemented in
84hardware by the adapter, or emulated in software by i2c-core on top
85of an I2C adapter.
74 86
75 87
76CLIENT CHECKING 88CLIENT CHECKING
@@ -78,36 +90,33 @@ CLIENT CHECKING
78 90
79Before a client tries to attach to an adapter, or even do tests to check 91Before a client tries to attach to an adapter, or even do tests to check
80whether one of the devices it supports is present on an adapter, it should 92whether one of the devices it supports is present on an adapter, it should
81check whether the needed functionality is present. There are two functions 93check whether the needed functionality is present. The typical way to do
82defined which should be used instead of calling the functionality hook 94this is (from the lm75 driver):
83in the algorithm structure directly:
84
85 /* Return the functionality mask */
86 extern u32 i2c_get_functionality (struct i2c_adapter *adap);
87
88 /* Return 1 if adapter supports everything we need, 0 if not. */
89 extern int i2c_check_functionality (struct i2c_adapter *adap, u32 func);
90 95
91This is a typical way to use these functions (from the writing-clients 96 static int lm75_detect(...)
92document):
93 int foo_detect_client(struct i2c_adapter *adapter, int address,
94 unsigned short flags, int kind)
95 { 97 {
96 /* Define needed variables */ 98 (...)
97 99 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA |
98 /* As the very first action, we check whether the adapter has the 100 I2C_FUNC_SMBUS_WORD_DATA))
99 needed functionality: we need the SMBus read_word_data, 101 goto exit;
100 write_word_data and write_byte functions in this example. */ 102 (...)
101 if (!i2c_check_functionality(adapter,I2C_FUNC_SMBUS_WORD_DATA |
102 I2C_FUNC_SMBUS_WRITE_BYTE))
103 goto ERROR0;
104
105 /* Now we can do the real detection */
106
107 ERROR0:
108 /* Return an error */
109 } 103 }
110 104
105Here, the lm75 driver checks if the adapter can do both SMBus byte data
106and SMBus word data transactions. If not, then the driver won't work on
107this adapter and there's no point in going on. If the check above is
108successful, then the driver knows that it can call the following
109functions: i2c_smbus_read_byte_data(), i2c_smbus_write_byte_data(),
110i2c_smbus_read_word_data() and i2c_smbus_write_word_data(). As a rule of
111thumb, the functionality constants you test for with
112i2c_check_functionality() should match exactly the i2c_smbus_* functions
113which you driver is calling.
114
115Note that the check above doesn't tell whether the functionalities are
116implemented in hardware by the underlying adapter or emulated in
117software by i2c-core. Client drivers don't have to care about this, as
118i2c-core will transparently implement SMBus transactions on top of I2C
119adapters.
111 120
112 121
113CHECKING THROUGH /DEV 122CHECKING THROUGH /DEV
@@ -116,19 +125,19 @@ CHECKING THROUGH /DEV
116If you try to access an adapter from a userspace program, you will have 125If you try to access an adapter from a userspace program, you will have
117to use the /dev interface. You will still have to check whether the 126to use the /dev interface. You will still have to check whether the
118functionality you need is supported, of course. This is done using 127functionality you need is supported, of course. This is done using
119the I2C_FUNCS ioctl. An example, adapted from the lm_sensors i2cdetect 128the I2C_FUNCS ioctl. An example, adapted from the i2cdetect program, is
120program, is below: 129below:
121 130
122 int file; 131 int file;
123 if (file = open("/dev/i2c-0",O_RDWR) < 0) { 132 if (file = open("/dev/i2c-0", O_RDWR) < 0) {
124 /* Some kind of error handling */ 133 /* Some kind of error handling */
125 exit(1); 134 exit(1);
126 } 135 }
127 if (ioctl(file,I2C_FUNCS,&funcs) < 0) { 136 if (ioctl(file, I2C_FUNCS, &funcs) < 0) {
128 /* Some kind of error handling */ 137 /* Some kind of error handling */
129 exit(1); 138 exit(1);
130 } 139 }
131 if (! (funcs & I2C_FUNC_SMBUS_QUICK)) { 140 if (!(funcs & I2C_FUNC_SMBUS_QUICK)) {
132 /* Oops, the needed functionality (SMBus write_quick function) is 141 /* Oops, the needed functionality (SMBus write_quick function) is
133 not available! */ 142 not available! */
134 exit(1); 143 exit(1);
diff --git a/Documentation/i2c/smbus-protocol b/Documentation/i2c/smbus-protocol
index 8a653c60d25a..03f08fb491cc 100644
--- a/Documentation/i2c/smbus-protocol
+++ b/Documentation/i2c/smbus-protocol
@@ -1,5 +1,6 @@
1SMBus Protocol Summary 1SMBus Protocol Summary
2====================== 2======================
3
3The following is a summary of the SMBus protocol. It applies to 4The following is a summary of the SMBus protocol. It applies to
4all revisions of the protocol (1.0, 1.1, and 2.0). 5all revisions of the protocol (1.0, 1.1, and 2.0).
5Certain protocol features which are not supported by 6Certain protocol features which are not supported by
@@ -8,6 +9,7 @@ this package are briefly described at the end of this document.
8Some adapters understand only the SMBus (System Management Bus) protocol, 9Some adapters understand only the SMBus (System Management Bus) protocol,
9which is a subset from the I2C protocol. Fortunately, many devices use 10which is a subset from the I2C protocol. Fortunately, many devices use
10only the same subset, which makes it possible to put them on an SMBus. 11only the same subset, which makes it possible to put them on an SMBus.
12
11If you write a driver for some I2C device, please try to use the SMBus 13If you write a driver for some I2C device, please try to use the SMBus
12commands if at all possible (if the device uses only that subset of the 14commands if at all possible (if the device uses only that subset of the
13I2C protocol). This makes it possible to use the device driver on both 15I2C protocol). This makes it possible to use the device driver on both
@@ -15,7 +17,12 @@ SMBus adapters and I2C adapters (the SMBus command set is automatically
15translated to I2C on I2C adapters, but plain I2C commands can not be 17translated to I2C on I2C adapters, but plain I2C commands can not be
16handled at all on most pure SMBus adapters). 18handled at all on most pure SMBus adapters).
17 19
18Below is a list of SMBus commands. 20Below is a list of SMBus protocol operations, and the functions executing
21them. Note that the names used in the SMBus protocol specifications usually
22don't match these function names. For some of the operations which pass a
23single data byte, the functions using SMBus protocol operation names execute
24a different protocol operation entirely.
25
19 26
20Key to symbols 27Key to symbols
21============== 28==============
@@ -35,17 +42,16 @@ Count (8 bits): A data byte containing the length of a block operation.
35[..]: Data sent by I2C device, as opposed to data sent by the host adapter. 42[..]: Data sent by I2C device, as opposed to data sent by the host adapter.
36 43
37 44
38SMBus Write Quick 45SMBus Quick Command: i2c_smbus_write_quick()
39================= 46=============================================
40 47
41This sends a single bit to the device, at the place of the Rd/Wr bit. 48This sends a single bit to the device, at the place of the Rd/Wr bit.
42There is no equivalent Read Quick command.
43 49
44A Addr Rd/Wr [A] P 50A Addr Rd/Wr [A] P
45 51
46 52
47SMBus Read Byte 53SMBus Receive Byte: i2c_smbus_read_byte()
48=============== 54==========================================
49 55
50This reads a single byte from a device, without specifying a device 56This reads a single byte from a device, without specifying a device
51register. Some devices are so simple that this interface is enough; for 57register. Some devices are so simple that this interface is enough; for
@@ -55,17 +61,17 @@ the previous SMBus command.
55S Addr Rd [A] [Data] NA P 61S Addr Rd [A] [Data] NA P
56 62
57 63
58SMBus Write Byte 64SMBus Send Byte: i2c_smbus_write_byte()
59================ 65========================================
60 66
61This is the reverse of Read Byte: it sends a single byte to a device. 67This operation is the reverse of Receive Byte: it sends a single byte
62See Read Byte for more information. 68to a device. See Receive Byte for more information.
63 69
64S Addr Wr [A] Data [A] P 70S Addr Wr [A] Data [A] P
65 71
66 72
67SMBus Read Byte Data 73SMBus Read Byte: i2c_smbus_read_byte_data()
68==================== 74============================================
69 75
70This reads a single byte from a device, from a designated register. 76This reads a single byte from a device, from a designated register.
71The register is specified through the Comm byte. 77The register is specified through the Comm byte.
@@ -73,30 +79,30 @@ The register is specified through the Comm byte.
73S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P 79S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
74 80
75 81
76SMBus Read Word Data 82SMBus Read Word: i2c_smbus_read_word_data()
77==================== 83============================================
78 84
79This command is very like Read Byte Data; again, data is read from a 85This operation is very like Read Byte; again, data is read from a
80device, from a designated register that is specified through the Comm 86device, from a designated register that is specified through the Comm
81byte. But this time, the data is a complete word (16 bits). 87byte. But this time, the data is a complete word (16 bits).
82 88
83S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P 89S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
84 90
85 91
86SMBus Write Byte Data 92SMBus Write Byte: i2c_smbus_write_byte_data()
87===================== 93==============================================
88 94
89This writes a single byte to a device, to a designated register. The 95This writes a single byte to a device, to a designated register. The
90register is specified through the Comm byte. This is the opposite of 96register is specified through the Comm byte. This is the opposite of
91the Read Byte Data command. 97the Read Byte operation.
92 98
93S Addr Wr [A] Comm [A] Data [A] P 99S Addr Wr [A] Comm [A] Data [A] P
94 100
95 101
96SMBus Write Word Data 102SMBus Write Word: i2c_smbus_write_word_data()
97===================== 103==============================================
98 104
99This is the opposite operation of the Read Word Data command. 16 bits 105This is the opposite of the Read Word operation. 16 bits
100of data is written to a device, to the designated register that is 106of data is written to a device, to the designated register that is
101specified through the Comm byte. 107specified through the Comm byte.
102 108
@@ -113,8 +119,8 @@ S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
113 S Addr Rd [A] [DataLow] A [DataHigh] NA P 119 S Addr Rd [A] [DataLow] A [DataHigh] NA P
114 120
115 121
116SMBus Block Read 122SMBus Block Read: i2c_smbus_read_block_data()
117================ 123==============================================
118 124
119This command reads a block of up to 32 bytes from a device, from a 125This command reads a block of up to 32 bytes from a device, from a
120designated register that is specified through the Comm byte. The amount 126designated register that is specified through the Comm byte. The amount
@@ -124,8 +130,8 @@ S Addr Wr [A] Comm [A]
124 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P 130 S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
125 131
126 132
127SMBus Block Write 133SMBus Block Write: i2c_smbus_write_block_data()
128================= 134================================================
129 135
130The opposite of the Block Read command, this writes up to 32 bytes to 136The opposite of the Block Read command, this writes up to 32 bytes to
131a device, to a designated register that is specified through the 137a device, to a designated register that is specified through the
@@ -134,10 +140,11 @@ Comm byte. The amount of data is specified in the Count byte.
134S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P 140S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
135 141
136 142
137SMBus Block Process Call 143SMBus Block Write - Block Read Process Call
138======================== 144===========================================
139 145
140SMBus Block Process Call was introduced in Revision 2.0 of the specification. 146SMBus Block Write - Block Read Process Call was introduced in
147Revision 2.0 of the specification.
141 148
142This command selects a device register (through the Comm byte), sends 149This command selects a device register (through the Comm byte), sends
1431 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return. 1501 to 31 bytes of data to it, and reads 1 to 31 bytes of data in return.
@@ -159,13 +166,16 @@ alerting device's address.
159 166
160Packet Error Checking (PEC) 167Packet Error Checking (PEC)
161=========================== 168===========================
169
162Packet Error Checking was introduced in Revision 1.1 of the specification. 170Packet Error Checking was introduced in Revision 1.1 of the specification.
163 171
164PEC adds a CRC-8 error-checking byte to all transfers. 172PEC adds a CRC-8 error-checking byte to transfers using it, immediately
173before the terminating STOP.
165 174
166 175
167Address Resolution Protocol (ARP) 176Address Resolution Protocol (ARP)
168================================= 177=================================
178
169The Address Resolution Protocol was introduced in Revision 2.0 of 179The Address Resolution Protocol was introduced in Revision 2.0 of
170the specification. It is a higher-layer protocol which uses the 180the specification. It is a higher-layer protocol which uses the
171messages above. 181messages above.
@@ -177,14 +187,17 @@ require PEC checksums.
177 187
178I2C Block Transactions 188I2C Block Transactions
179====================== 189======================
190
180The following I2C block transactions are supported by the 191The following I2C block transactions are supported by the
181SMBus layer and are described here for completeness. 192SMBus layer and are described here for completeness.
193They are *NOT* defined by the SMBus specification.
194
182I2C block transactions do not limit the number of bytes transferred 195I2C block transactions do not limit the number of bytes transferred
183but the SMBus layer places a limit of 32 bytes. 196but the SMBus layer places a limit of 32 bytes.
184 197
185 198
186I2C Block Read 199I2C Block Read: i2c_smbus_read_i2c_block_data()
187============== 200================================================
188 201
189This command reads a block of bytes from a device, from a 202This command reads a block of bytes from a device, from a
190designated register that is specified through the Comm byte. 203designated register that is specified through the Comm byte.
@@ -203,8 +216,8 @@ S Addr Wr [A] Comm1 [A] Comm2 [A]
203 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P 216 S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
204 217
205 218
206I2C Block Write 219I2C Block Write: i2c_smbus_write_i2c_block_data()
207=============== 220==================================================
208 221
209The opposite of the Block Read command, this writes bytes to 222The opposite of the Block Read command, this writes bytes to
210a device, to a designated register that is specified through the 223a device, to a designated register that is specified through the
@@ -212,5 +225,3 @@ Comm byte. Note that command lengths of 0, 2, or more bytes are
212supported as they are indistinguishable from data. 225supported as they are indistinguishable from data.
213 226
214S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P 227S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
215
216
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index a3c35446e755..cdd5b934f43e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1094,9 +1094,6 @@ and is between 256 and 4096 characters. It is defined in the file
1094 mac5380= [HW,SCSI] Format: 1094 mac5380= [HW,SCSI] Format:
1095 <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags> 1095 <can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
1096 1096
1097 mac53c9x= [HW,SCSI] Format:
1098 <num_esps>,<disconnect>,<nosync>,<can_queue>,<cmd_per_lun>,<sg_tablesize>,<hostid>,<use_tags>
1099
1100 machvec= [IA64] Force the use of a particular machine-vector 1097 machvec= [IA64] Force the use of a particular machine-vector
1101 (machvec) in a generic kernel. 1098 (machvec) in a generic kernel.
1102 Example: machvec=hpzx1_swiotlb 1099 Example: machvec=hpzx1_swiotlb
@@ -1525,6 +1522,8 @@ and is between 256 and 4096 characters. It is defined in the file
1525 This is normally done in pci_enable_device(), 1522 This is normally done in pci_enable_device(),
1526 so this option is a temporary workaround 1523 so this option is a temporary workaround
1527 for broken drivers that don't call it. 1524 for broken drivers that don't call it.
1525 skip_isa_align [X86] do not align io start addr, so can
1526 handle more pci cards
1528 firmware [ARM] Do not re-enumerate the bus but instead 1527 firmware [ARM] Do not re-enumerate the bus but instead
1529 just use the configuration from the 1528 just use the configuration from the
1530 bootloader. This is currently used on 1529 bootloader. This is currently used on
diff --git a/Documentation/memory-barriers.txt b/Documentation/memory-barriers.txt
index e5a819a4f0c9..f5b7127f54ac 100644
--- a/Documentation/memory-barriers.txt
+++ b/Documentation/memory-barriers.txt
@@ -994,7 +994,17 @@ The Linux kernel has eight basic CPU memory barriers:
994 DATA DEPENDENCY read_barrier_depends() smp_read_barrier_depends() 994 DATA DEPENDENCY read_barrier_depends() smp_read_barrier_depends()
995 995
996 996
997All CPU memory barriers unconditionally imply compiler barriers. 997All memory barriers except the data dependency barriers imply a compiler
998barrier. Data dependencies do not impose any additional compiler ordering.
999
1000Aside: In the case of data dependencies, the compiler would be expected to
1001issue the loads in the correct order (eg. `a[b]` would have to load the value
1002of b before loading a[b]), however there is no guarantee in the C specification
1003that the compiler may not speculate the value of b (eg. is equal to 1) and load
1004a before b (eg. tmp = a[1]; if (b != 1) tmp = a[b]; ). There is also the
1005problem of a compiler reloading b after having loaded a[b], thus having a newer
1006copy of b than a[b]. A consensus has not yet been reached about these problems,
1007however the ACCESS_ONCE macro is a good place to start looking.
998 1008
999SMP memory barriers are reduced to compiler barriers on uniprocessor compiled 1009SMP memory barriers are reduced to compiler barriers on uniprocessor compiled
1000systems because it is assumed that a CPU will appear to be self-consistent, 1010systems because it is assumed that a CPU will appear to be self-consistent,
diff --git a/Documentation/s390/CommonIO b/Documentation/s390/CommonIO
index 8fbc0a852870..bf0baa19ec24 100644
--- a/Documentation/s390/CommonIO
+++ b/Documentation/s390/CommonIO
@@ -8,17 +8,6 @@ Command line parameters
8 8
9 Enable logging of debug information in case of ccw device timeouts. 9 Enable logging of debug information in case of ccw device timeouts.
10 10
11
12* cio_msg = yes | no
13
14 Determines whether information on found devices and sensed device
15 characteristics should be shown during startup or when new devices are
16 found, i. e. messages of the types "Detected device 0.0.4711 on subchannel
17 0.0.0042" and "SenseID: Device 0.0.4711 reports: ...".
18
19 Default is off.
20
21
22* cio_ignore = {all} | 11* cio_ignore = {all} |
23 {<device> | <range of devices>} | 12 {<device> | <range of devices>} |
24 {!<device> | !<range of devices>} 13 {!<device> | !<range of devices>}
diff --git a/Documentation/scheduler/sched-design.txt b/Documentation/scheduler/sched-design.txt
deleted file mode 100644
index 1605bf0cba8b..000000000000
--- a/Documentation/scheduler/sched-design.txt
+++ /dev/null
@@ -1,165 +0,0 @@
1 Goals, Design and Implementation of the
2 new ultra-scalable O(1) scheduler
3
4
5 This is an edited version of an email Ingo Molnar sent to
6 lkml on 4 Jan 2002. It describes the goals, design, and
7 implementation of Ingo's new ultra-scalable O(1) scheduler.
8 Last Updated: 18 April 2002.
9
10
11Goal
12====
13
14The main goal of the new scheduler is to keep all the good things we know
15and love about the current Linux scheduler:
16
17 - good interactive performance even during high load: if the user
18 types or clicks then the system must react instantly and must execute
19 the user tasks smoothly, even during considerable background load.
20
21 - good scheduling/wakeup performance with 1-2 runnable processes.
22
23 - fairness: no process should stay without any timeslice for any
24 unreasonable amount of time. No process should get an unjustly high
25 amount of CPU time.
26
27 - priorities: less important tasks can be started with lower priority,
28 more important tasks with higher priority.
29
30 - SMP efficiency: no CPU should stay idle if there is work to do.
31
32 - SMP affinity: processes which run on one CPU should stay affine to
33 that CPU. Processes should not bounce between CPUs too frequently.
34
35 - plus additional scheduler features: RT scheduling, CPU binding.
36
37and the goal is also to add a few new things:
38
39 - fully O(1) scheduling. Are you tired of the recalculation loop
40 blowing the L1 cache away every now and then? Do you think the goodness
41 loop is taking a bit too long to finish if there are lots of runnable
42 processes? This new scheduler takes no prisoners: wakeup(), schedule(),
43 the timer interrupt are all O(1) algorithms. There is no recalculation
44 loop. There is no goodness loop either.
45
46 - 'perfect' SMP scalability. With the new scheduler there is no 'big'
47 runqueue_lock anymore - it's all per-CPU runqueues and locks - two
48 tasks on two separate CPUs can wake up, schedule and context-switch
49 completely in parallel, without any interlocking. All
50 scheduling-relevant data is structured for maximum scalability.
51
52 - better SMP affinity. The old scheduler has a particular weakness that
53 causes the random bouncing of tasks between CPUs if/when higher
54 priority/interactive tasks, this was observed and reported by many
55 people. The reason is that the timeslice recalculation loop first needs
56 every currently running task to consume its timeslice. But when this
57 happens on eg. an 8-way system, then this property starves an
58 increasing number of CPUs from executing any process. Once the last
59 task that has a timeslice left has finished using up that timeslice,
60 the recalculation loop is triggered and other CPUs can start executing
61 tasks again - after having idled around for a number of timer ticks.
62 The more CPUs, the worse this effect.
63
64 Furthermore, this same effect causes the bouncing effect as well:
65 whenever there is such a 'timeslice squeeze' of the global runqueue,
66 idle processors start executing tasks which are not affine to that CPU.
67 (because the affine tasks have finished off their timeslices already.)
68
69 The new scheduler solves this problem by distributing timeslices on a
70 per-CPU basis, without having any global synchronization or
71 recalculation.
72
73 - batch scheduling. A significant proportion of computing-intensive tasks
74 benefit from batch-scheduling, where timeslices are long and processes
75 are roundrobin scheduled. The new scheduler does such batch-scheduling
76 of the lowest priority tasks - so nice +19 jobs will get
77 'batch-scheduled' automatically. With this scheduler, nice +19 jobs are
78 in essence SCHED_IDLE, from an interactiveness point of view.
79
80 - handle extreme loads more smoothly, without breakdown and scheduling
81 storms.
82
83 - O(1) RT scheduling. For those RT folks who are paranoid about the
84 O(nr_running) property of the goodness loop and the recalculation loop.
85
86 - run fork()ed children before the parent. Andrea has pointed out the
87 advantages of this a few months ago, but patches for this feature
88 do not work with the old scheduler as well as they should,
89 because idle processes often steal the new child before the fork()ing
90 CPU gets to execute it.
91
92
93Design
94======
95
96The core of the new scheduler contains the following mechanisms:
97
98 - *two* priority-ordered 'priority arrays' per CPU. There is an 'active'
99 array and an 'expired' array. The active array contains all tasks that
100 are affine to this CPU and have timeslices left. The expired array
101 contains all tasks which have used up their timeslices - but this array
102 is kept sorted as well. The active and expired array is not accessed
103 directly, it's accessed through two pointers in the per-CPU runqueue
104 structure. If all active tasks are used up then we 'switch' the two
105 pointers and from now on the ready-to-go (former-) expired array is the
106 active array - and the empty active array serves as the new collector
107 for expired tasks.
108
109 - there is a 64-bit bitmap cache for array indices. Finding the highest
110 priority task is thus a matter of two x86 BSFL bit-search instructions.
111
112the split-array solution enables us to have an arbitrary number of active
113and expired tasks, and the recalculation of timeslices can be done
114immediately when the timeslice expires. Because the arrays are always
115access through the pointers in the runqueue, switching the two arrays can
116be done very quickly.
117
118this is a hybride priority-list approach coupled with roundrobin
119scheduling and the array-switch method of distributing timeslices.
120
121 - there is a per-task 'load estimator'.
122
123one of the toughest things to get right is good interactive feel during
124heavy system load. While playing with various scheduler variants i found
125that the best interactive feel is achieved not by 'boosting' interactive
126tasks, but by 'punishing' tasks that want to use more CPU time than there
127is available. This method is also much easier to do in an O(1) fashion.
128
129to establish the actual 'load' the task contributes to the system, a
130complex-looking but pretty accurate method is used: there is a 4-entry
131'history' ringbuffer of the task's activities during the last 4 seconds.
132This ringbuffer is operated without much overhead. The entries tell the
133scheduler a pretty accurate load-history of the task: has it used up more
134CPU time or less during the past N seconds. [the size '4' and the interval
135of 4x 1 seconds was found by lots of experimentation - this part is
136flexible and can be changed in both directions.]
137
138the penalty a task gets for generating more load than the CPU can handle
139is a priority decrease - there is a maximum amount to this penalty
140relative to their static priority, so even fully CPU-bound tasks will
141observe each other's priorities, and will share the CPU accordingly.
142
143the SMP load-balancer can be extended/switched with additional parallel
144computing and cache hierarchy concepts: NUMA scheduling, multi-core CPUs
145can be supported easily by changing the load-balancer. Right now it's
146tuned for my SMP systems.
147
148i skipped the prev->mm == next->mm advantage - no workload i know of shows
149any sensitivity to this. It can be added back by sacrificing O(1)
150schedule() [the current and one-lower priority list can be searched for a
151that->mm == current->mm condition], but costs a fair number of cycles
152during a number of important workloads, so i wanted to avoid this as much
153as possible.
154
155- the SMP idle-task startup code was still racy and the new scheduler
156triggered this. So i streamlined the idle-setup code a bit. We do not call
157into schedule() before all processors have started up fully and all idle
158threads are in place.
159
160- the patch also cleans up a number of aspects of sched.c - moves code
161into other areas of the kernel where it's appropriate, and simplifies
162certain code paths and data constructs. As a result, the new scheduler's
163code is smaller than the old one.
164
165 Ingo
diff --git a/Documentation/video4linux/CARDLIST.cx23885 b/Documentation/video4linux/CARDLIST.cx23885
index 929b90c8387f..191194ea1e25 100644
--- a/Documentation/video4linux/CARDLIST.cx23885
+++ b/Documentation/video4linux/CARDLIST.cx23885
@@ -5,6 +5,6 @@
5 4 -> DViCO FusionHDTV5 Express [18ac:d500] 5 4 -> DViCO FusionHDTV5 Express [18ac:d500]
6 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797] 6 5 -> Hauppauge WinTV-HVR1500Q [0070:7790,0070:7797]
7 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717] 7 6 -> Hauppauge WinTV-HVR1500 [0070:7710,0070:7717]
8 7 -> Hauppauge WinTV-HVR1200 [0070:71d1] 8 7 -> Hauppauge WinTV-HVR1200 [0070:71d1,0070:71d3]
9 8 -> Hauppauge WinTV-HVR1700 [0070:8101] 9 8 -> Hauppauge WinTV-HVR1700 [0070:8101]
10 9 -> Hauppauge WinTV-HVR1400 [0070:8010] 10 9 -> Hauppauge WinTV-HVR1400 [0070:8010]
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index f40e09296f30..1d6a245c828f 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -14,4 +14,4 @@
14 13 -> Terratec Prodigy XS (em2880) [0ccd:0047] 14 13 -> Terratec Prodigy XS (em2880) [0ccd:0047]
15 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840) 15 14 -> Pixelview Prolink PlayTV USB 2.0 (em2820/em2840)
16 15 -> V-Gear PocketTV (em2800) 16 15 -> V-Gear PocketTV (em2800)
17 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513] 17 16 -> Hauppauge WinTV HVR 950 (em2880) [2040:6513,2040:6517,2040:651b,2040:651f]
diff --git a/MAINTAINERS b/MAINTAINERS
index abe27871ad6a..bc1c0088dc49 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -367,12 +367,12 @@ S: Maintained for 2.4; PCI support for 2.6.
367AMD GEODE CS5536 USB DEVICE CONTROLLER DRIVER 367AMD GEODE CS5536 USB DEVICE CONTROLLER DRIVER
368P: Thomas Dahlmann 368P: Thomas Dahlmann
369M: thomas.dahlmann@amd.com 369M: thomas.dahlmann@amd.com
370L: info-linux@geode.amd.com (subscribers-only) 370L: linux-geode@lists.infradead.org (moderated for non-subscribers)
371S: Supported 371S: Supported
372 372
373AMD GEODE PROCESSOR/CHIPSET SUPPORT 373AMD GEODE PROCESSOR/CHIPSET SUPPORT
374P: Jordan Crouse 374P: Jordan Crouse
375L: info-linux@geode.amd.com (subscribers-only) 375L: linux-geode@lists.infradead.org (moderated for non-subscribers)
376W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html 376W: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2452_11363,00.html
377S: Supported 377S: Supported
378 378
@@ -1230,6 +1230,15 @@ P: Jaya Kumar
1230M: jayakumar.alsa@gmail.com 1230M: jayakumar.alsa@gmail.com
1231S: Maintained 1231S: Maintained
1232 1232
1233CX18 VIDEO4LINUX DRIVER
1234P: Hans Verkuil, Andy Walls
1235M: hverkuil@xs4all.nl, awalls@radix.net
1236L: ivtv-devel@ivtvdriver.org
1237L: ivtv-users@ivtvdriver.org
1238L: video4linux-list@redhat.com
1239W: http://linuxtv.org
1240S: Maintained
1241
1233CYBERPRO FB DRIVER 1242CYBERPRO FB DRIVER
1234P: Russell King 1243P: Russell King
1235M: rmk@arm.linux.org.uk 1244M: rmk@arm.linux.org.uk
@@ -2112,12 +2121,10 @@ L: netdev@vger.kernel.org
2112S: Maintained 2121S: Maintained
2113 2122
2114INTEL ETHERNET DRIVERS (e100/e1000/e1000e/igb/ixgb/ixgbe) 2123INTEL ETHERNET DRIVERS (e100/e1000/e1000e/igb/ixgb/ixgbe)
2115P: Auke Kok
2116M: auke-jan.h.kok@intel.com
2117P: Jesse Brandeburg
2118M: jesse.brandeburg@intel.com
2119P: Jeff Kirsher 2124P: Jeff Kirsher
2120M: jeffrey.t.kirsher@intel.com 2125M: jeffrey.t.kirsher@intel.com
2126P: Jesse Brandeburg
2127M: jesse.brandeburg@intel.com
2121P: Bruce Allan 2128P: Bruce Allan
2122M: bruce.w.allan@intel.com 2129M: bruce.w.allan@intel.com
2123P: John Ronciak 2130P: John Ronciak
diff --git a/Makefile b/Makefile
index 4492984efc09..3140145fdfe2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 26 3SUBLEVEL = 26
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc2
5NAME = Funky Weasel is Jiggy wit it 5NAME = Funky Weasel is Jiggy wit it
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 728bb8f39441..0babb645b83c 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -544,10 +544,10 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
544 struct resource *fb_res = &lcdc_resources[2]; 544 struct resource *fb_res = &lcdc_resources[2];
545 size_t fb_len = fb_res->end - fb_res->start + 1; 545 size_t fb_len = fb_res->end - fb_res->start + 1;
546 546
547 fb = ioremap_writecombine(fb_res->start, fb_len); 547 fb = ioremap(fb_res->start, fb_len);
548 if (fb) { 548 if (fb) {
549 memset(fb, 0, fb_len); 549 memset(fb, 0, fb_len);
550 iounmap(fb, fb_len); 550 iounmap(fb);
551 } 551 }
552 } 552 }
553 lcdc_data = *data; 553 lcdc_data = *data;
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index 054689804e77..450db304936f 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -332,13 +332,6 @@ static struct resource lcdc_resources[] = {
332 .end = AT91SAM9RL_ID_LCDC, 332 .end = AT91SAM9RL_ID_LCDC,
333 .flags = IORESOURCE_IRQ, 333 .flags = IORESOURCE_IRQ,
334 }, 334 },
335#if defined(CONFIG_FB_INTSRAM)
336 [2] = {
337 .start = AT91SAM9RL_SRAM_BASE,
338 .end = AT91SAM9RL_SRAM_BASE + AT91SAM9RL_SRAM_SIZE - 1,
339 .flags = IORESOURCE_MEM,
340 },
341#endif
342}; 335};
343 336
344static struct platform_device at91_lcdc_device = { 337static struct platform_device at91_lcdc_device = {
@@ -381,20 +374,6 @@ void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
381 at91_set_B_periph(AT91_PIN_PC24, 0); /* LCDD22 */ 374 at91_set_B_periph(AT91_PIN_PC24, 0); /* LCDD22 */
382 at91_set_B_periph(AT91_PIN_PC25, 0); /* LCDD23 */ 375 at91_set_B_periph(AT91_PIN_PC25, 0); /* LCDD23 */
383 376
384#ifdef CONFIG_FB_INTSRAM
385 {
386 void __iomem *fb;
387 struct resource *fb_res = &lcdc_resources[2];
388 size_t fb_len = fb_res->end - fb_res->start + 1;
389
390 fb = ioremap_writecombine(fb_res->start, fb_len);
391 if (fb) {
392 memset(fb, 0, fb_len);
393 iounmap(fb, fb_len);
394 }
395 }
396#endif
397
398 lcdc_data = *data; 377 lcdc_data = *data;
399 platform_device_register(&at91_lcdc_device); 378 platform_device_register(&at91_lcdc_device);
400} 379}
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 8bc187240542..1d7bca6aa441 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -280,7 +280,7 @@ static int ep93xx_gpio_irq_type(unsigned int irq, unsigned int type)
280 const int port = gpio >> 3; 280 const int port = gpio >> 3;
281 const int port_mask = 1 << (gpio & 7); 281 const int port_mask = 1 << (gpio & 7);
282 282
283 gpio_direction_output(gpio, gpio_get_value(gpio)); 283 gpio_direction_input(gpio);
284 284
285 switch (type) { 285 switch (type) {
286 case IRQT_RISING: 286 case IRQT_RISING:
diff --git a/arch/arm/mach-ns9xxx/irq.c b/arch/arm/mach-ns9xxx/irq.c
index 36e5835e6097..ca85d24cf39f 100644
--- a/arch/arm/mach-ns9xxx/irq.c
+++ b/arch/arm/mach-ns9xxx/irq.c
@@ -62,7 +62,7 @@ static struct irq_chip ns9xxx_chip = {
62#if 0 62#if 0
63#define handle_irq handle_level_irq 63#define handle_irq handle_level_irq
64#else 64#else
65void handle_prio_irq(unsigned int irq, struct irq_desc *desc) 65static void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
66{ 66{
67 unsigned int cpu = smp_processor_id(); 67 unsigned int cpu = smp_processor_id();
68 struct irqaction *action; 68 struct irqaction *action;
@@ -70,27 +70,35 @@ void handle_prio_irq(unsigned int irq, struct irq_desc *desc)
70 70
71 spin_lock(&desc->lock); 71 spin_lock(&desc->lock);
72 72
73 if (unlikely(desc->status & IRQ_INPROGRESS)) 73 BUG_ON(desc->status & IRQ_INPROGRESS);
74 goto out_unlock;
75 74
76 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING); 75 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
77 kstat_cpu(cpu).irqs[irq]++; 76 kstat_cpu(cpu).irqs[irq]++;
78 77
79 action = desc->action; 78 action = desc->action;
80 if (unlikely(!action || (desc->status & IRQ_DISABLED))) 79 if (unlikely(!action || (desc->status & IRQ_DISABLED)))
81 goto out_unlock; 80 goto out_mask;
82 81
83 desc->status |= IRQ_INPROGRESS; 82 desc->status |= IRQ_INPROGRESS;
84 spin_unlock(&desc->lock); 83 spin_unlock(&desc->lock);
85 84
86 action_ret = handle_IRQ_event(irq, action); 85 action_ret = handle_IRQ_event(irq, action);
87 86
87 /* XXX: There is no direct way to access noirqdebug, so check
88 * unconditionally for spurious irqs...
89 * Maybe this function should go to kernel/irq/chip.c? */
90 note_interrupt(irq, desc, action_ret);
91
88 spin_lock(&desc->lock); 92 spin_lock(&desc->lock);
89 desc->status &= ~IRQ_INPROGRESS; 93 desc->status &= ~IRQ_INPROGRESS;
90 if (!(desc->status & IRQ_DISABLED) && desc->chip->ack)
91 desc->chip->ack(irq);
92 94
93out_unlock: 95 if (desc->status & IRQ_DISABLED)
96out_mask:
97 desc->chip->mask(irq);
98
99 /* ack unconditionally to unmask lower prio irqs */
100 desc->chip->ack(irq);
101
94 spin_unlock(&desc->lock); 102 spin_unlock(&desc->lock);
95} 103}
96#define handle_irq handle_prio_irq 104#define handle_irq handle_prio_irq
diff --git a/arch/arm/mach-orion5x/addr-map.c b/arch/arm/mach-orion5x/addr-map.c
index 9608503d67f5..e63fb05dc893 100644
--- a/arch/arm/mach-orion5x/addr-map.c
+++ b/arch/arm/mach-orion5x/addr-map.c
@@ -34,11 +34,7 @@
34 * Non-CPU Masters address decoding -- 34 * Non-CPU Masters address decoding --
35 * Unlike the CPU, we setup the access from Orion's master interfaces to DDR 35 * Unlike the CPU, we setup the access from Orion's master interfaces to DDR
36 * banks only (the typical use case). 36 * banks only (the typical use case).
37 * Setup access for each master to DDR is issued by common.c. 37 * Setup access for each master to DDR is issued by platform device setup.
38 *
39 * Note: although orion_setbits() and orion_clrbits() are not atomic
40 * no locking is necessary here since code in this file is only called
41 * at boot time when there is no concurrency issues.
42 */ 38 */
43 39
44/* 40/*
@@ -48,10 +44,6 @@
48#define TARGET_DEV_BUS 1 44#define TARGET_DEV_BUS 1
49#define TARGET_PCI 3 45#define TARGET_PCI 3
50#define TARGET_PCIE 4 46#define TARGET_PCIE 4
51#define ATTR_DDR_CS(n) (((n) ==0) ? 0xe : \
52 ((n) == 1) ? 0xd : \
53 ((n) == 2) ? 0xb : \
54 ((n) == 3) ? 0x7 : 0xf)
55#define ATTR_PCIE_MEM 0x59 47#define ATTR_PCIE_MEM 0x59
56#define ATTR_PCIE_IO 0x51 48#define ATTR_PCIE_IO 0x51
57#define ATTR_PCIE_WA 0x79 49#define ATTR_PCIE_WA 0x79
@@ -61,17 +53,12 @@
61#define ATTR_DEV_CS1 0x1d 53#define ATTR_DEV_CS1 0x1d
62#define ATTR_DEV_CS2 0x1b 54#define ATTR_DEV_CS2 0x1b
63#define ATTR_DEV_BOOT 0xf 55#define ATTR_DEV_BOOT 0xf
64#define WIN_EN 1
65 56
66/* 57/*
67 * Helpers to get DDR bank info 58 * Helpers to get DDR bank info
68 */ 59 */
69#define DDR_BASE_CS(n) ORION5X_DDR_REG(0x1500 + ((n) * 8)) 60#define DDR_BASE_CS(n) ORION5X_DDR_REG(0x1500 + ((n) << 3))
70#define DDR_SIZE_CS(n) ORION5X_DDR_REG(0x1504 + ((n) * 8)) 61#define DDR_SIZE_CS(n) ORION5X_DDR_REG(0x1504 + ((n) << 3))
71#define DDR_MAX_CS 4
72#define DDR_REG_TO_SIZE(reg) (((reg) | 0xffffff) + 1)
73#define DDR_REG_TO_BASE(reg) ((reg) & 0xff000000)
74#define DDR_BANK_EN 1
75 62
76/* 63/*
77 * CPU Address Decode Windows registers 64 * CPU Address Decode Windows registers
@@ -81,17 +68,6 @@
81#define CPU_WIN_REMAP_LO(n) ORION5X_BRIDGE_REG(0x008 | ((n) << 4)) 68#define CPU_WIN_REMAP_LO(n) ORION5X_BRIDGE_REG(0x008 | ((n) << 4))
82#define CPU_WIN_REMAP_HI(n) ORION5X_BRIDGE_REG(0x00c | ((n) << 4)) 69#define CPU_WIN_REMAP_HI(n) ORION5X_BRIDGE_REG(0x00c | ((n) << 4))
83 70
84/*
85 * Gigabit Ethernet Address Decode Windows registers
86 */
87#define ETH_WIN_BASE(win) ORION5X_ETH_REG(0x200 + ((win) * 8))
88#define ETH_WIN_SIZE(win) ORION5X_ETH_REG(0x204 + ((win) * 8))
89#define ETH_WIN_REMAP(win) ORION5X_ETH_REG(0x280 + ((win) * 4))
90#define ETH_WIN_EN ORION5X_ETH_REG(0x290)
91#define ETH_WIN_PROT ORION5X_ETH_REG(0x294)
92#define ETH_MAX_WIN 6
93#define ETH_MAX_REMAP_WIN 4
94
95 71
96struct mbus_dram_target_info orion5x_mbus_dram_info; 72struct mbus_dram_target_info orion5x_mbus_dram_info;
97 73
@@ -202,39 +178,3 @@ void __init orion5x_setup_pcie_wa_win(u32 base, u32 size)
202{ 178{
203 setup_cpu_win(7, base, size, TARGET_PCIE, ATTR_PCIE_WA, -1); 179 setup_cpu_win(7, base, size, TARGET_PCIE, ATTR_PCIE_WA, -1);
204} 180}
205
206void __init orion5x_setup_eth_wins(void)
207{
208 int i;
209
210 /*
211 * First, disable and clear windows
212 */
213 for (i = 0; i < ETH_MAX_WIN; i++) {
214 orion5x_write(ETH_WIN_BASE(i), 0);
215 orion5x_write(ETH_WIN_SIZE(i), 0);
216 orion5x_setbits(ETH_WIN_EN, 1 << i);
217 orion5x_clrbits(ETH_WIN_PROT, 0x3 << (i * 2));
218 if (i < ETH_MAX_REMAP_WIN)
219 orion5x_write(ETH_WIN_REMAP(i), 0);
220 }
221
222 /*
223 * Setup windows for DDR banks.
224 */
225 for (i = 0; i < DDR_MAX_CS; i++) {
226 u32 base, size;
227 size = orion5x_read(DDR_SIZE_CS(i));
228 base = orion5x_read(DDR_BASE_CS(i));
229 if (size & DDR_BANK_EN) {
230 base = DDR_REG_TO_BASE(base);
231 size = DDR_REG_TO_SIZE(size);
232 orion5x_write(ETH_WIN_SIZE(i), (size-1) & 0xffff0000);
233 orion5x_write(ETH_WIN_BASE(i), (base & 0xffff0000) |
234 (ATTR_DDR_CS(i) << 8) |
235 TARGET_DDR);
236 orion5x_clrbits(ETH_WIN_EN, 1 << i);
237 orion5x_setbits(ETH_WIN_PROT, 0x3 << (i * 2));
238 }
239 }
240}
diff --git a/arch/arm/mach-orion5x/common.c b/arch/arm/mach-orion5x/common.c
index 968deb58be01..4f13fd037f04 100644
--- a/arch/arm/mach-orion5x/common.c
+++ b/arch/arm/mach-orion5x/common.c
@@ -190,6 +190,11 @@ static struct platform_device orion5x_ehci1 = {
190 * (The Orion and Discovery (MV643xx) families use the same Ethernet driver) 190 * (The Orion and Discovery (MV643xx) families use the same Ethernet driver)
191 ****************************************************************************/ 191 ****************************************************************************/
192 192
193struct mv643xx_eth_shared_platform_data orion5x_eth_shared_data = {
194 .dram = &orion5x_mbus_dram_info,
195 .t_clk = ORION5X_TCLK,
196};
197
193static struct resource orion5x_eth_shared_resources[] = { 198static struct resource orion5x_eth_shared_resources[] = {
194 { 199 {
195 .start = ORION5X_ETH_PHYS_BASE + 0x2000, 200 .start = ORION5X_ETH_PHYS_BASE + 0x2000,
@@ -201,6 +206,9 @@ static struct resource orion5x_eth_shared_resources[] = {
201static struct platform_device orion5x_eth_shared = { 206static struct platform_device orion5x_eth_shared = {
202 .name = MV643XX_ETH_SHARED_NAME, 207 .name = MV643XX_ETH_SHARED_NAME,
203 .id = 0, 208 .id = 0,
209 .dev = {
210 .platform_data = &orion5x_eth_shared_data,
211 },
204 .num_resources = 1, 212 .num_resources = 1,
205 .resource = orion5x_eth_shared_resources, 213 .resource = orion5x_eth_shared_resources,
206}; 214};
@@ -223,7 +231,9 @@ static struct platform_device orion5x_eth = {
223 231
224void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data) 232void __init orion5x_eth_init(struct mv643xx_eth_platform_data *eth_data)
225{ 233{
234 eth_data->shared = &orion5x_eth_shared;
226 orion5x_eth.dev.platform_data = eth_data; 235 orion5x_eth.dev.platform_data = eth_data;
236
227 platform_device_register(&orion5x_eth_shared); 237 platform_device_register(&orion5x_eth_shared);
228 platform_device_register(&orion5x_eth); 238 platform_device_register(&orion5x_eth);
229} 239}
@@ -360,7 +370,6 @@ void __init orion5x_init(void)
360 * Setup Orion address map 370 * Setup Orion address map
361 */ 371 */
362 orion5x_setup_cpu_mbus_bridge(); 372 orion5x_setup_cpu_mbus_bridge();
363 orion5x_setup_eth_wins();
364 373
365 /* 374 /*
366 * Register devices. 375 * Register devices.
diff --git a/arch/arm/mach-orion5x/common.h b/arch/arm/mach-orion5x/common.h
index 14adf8d1a54a..bd0f05de6e18 100644
--- a/arch/arm/mach-orion5x/common.h
+++ b/arch/arm/mach-orion5x/common.h
@@ -22,7 +22,6 @@ void orion5x_setup_dev0_win(u32 base, u32 size);
22void orion5x_setup_dev1_win(u32 base, u32 size); 22void orion5x_setup_dev1_win(u32 base, u32 size);
23void orion5x_setup_dev2_win(u32 base, u32 size); 23void orion5x_setup_dev2_win(u32 base, u32 size);
24void orion5x_setup_pcie_wa_win(u32 base, u32 size); 24void orion5x_setup_pcie_wa_win(u32 base, u32 size);
25void orion5x_setup_eth_wins(void);
26 25
27/* 26/*
28 * Shared code used internally by other Orion core functions. 27 * Shared code used internally by other Orion core functions.
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 6a830853aa6a..0e6d05bb81aa 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -5,6 +5,13 @@
5# Common support (must be linked before board specific support) 5# Common support (must be linked before board specific support)
6obj-y += clock.o devices.o generic.o irq.o dma.o \ 6obj-y += clock.o devices.o generic.o irq.o dma.o \
7 time.o gpio.o 7 time.o gpio.o
8obj-$(CONFIG_PM) += pm.o sleep.o standby.o
9obj-$(CONFIG_CPU_FREQ) += cpu-pxa.o
10
11# Generic drivers that other drivers may depend upon
12obj-$(CONFIG_PXA_SSP) += ssp.o
13
14# SoC-specific code
8obj-$(CONFIG_PXA25x) += mfp-pxa2xx.o pxa25x.o 15obj-$(CONFIG_PXA25x) += mfp-pxa2xx.o pxa25x.o
9obj-$(CONFIG_PXA27x) += mfp-pxa2xx.o pxa27x.o 16obj-$(CONFIG_PXA27x) += mfp-pxa2xx.o pxa27x.o
10obj-$(CONFIG_PXA3xx) += mfp-pxa3xx.o pxa3xx.o smemc.o 17obj-$(CONFIG_PXA3xx) += mfp-pxa3xx.o pxa3xx.o smemc.o
@@ -48,11 +55,6 @@ led-$(CONFIG_MACH_TRIZEPS4) += leds-trizeps4.o
48 55
49obj-$(CONFIG_LEDS) += $(led-y) 56obj-$(CONFIG_LEDS) += $(led-y)
50 57
51# Misc features
52obj-$(CONFIG_PM) += pm.o sleep.o standby.o
53obj-$(CONFIG_CPU_FREQ) += cpu-pxa.o
54obj-$(CONFIG_PXA_SSP) += ssp.o
55
56ifeq ($(CONFIG_PCI),y) 58ifeq ($(CONFIG_PCI),y)
57obj-$(CONFIG_MACH_ARMCORE) += cm-x270-pci.o 59obj-$(CONFIG_MACH_ARMCORE) += cm-x270-pci.o
58endif 60endif
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 259ca821e464..b757dd756655 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -493,8 +493,6 @@ static struct platform_device *devices[] __initdata = {
493 493
494static void corgi_poweroff(void) 494static void corgi_poweroff(void)
495{ 495{
496 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
497
498 if (!machine_is_corgi()) 496 if (!machine_is_corgi())
499 /* Green LED off tells the bootloader to halt */ 497 /* Green LED off tells the bootloader to halt */
500 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); 498 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
@@ -503,8 +501,6 @@ static void corgi_poweroff(void)
503 501
504static void corgi_restart(char mode) 502static void corgi_restart(char mode)
505{ 503{
506 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
507
508 if (!machine_is_corgi()) 504 if (!machine_is_corgi())
509 /* Green LED on tells the bootloader to reboot */ 505 /* Green LED on tells the bootloader to reboot */
510 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN); 506 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
diff --git a/arch/arm/mach-pxa/cpu-pxa.c b/arch/arm/mach-pxa/cpu-pxa.c
index 4b21479332ae..fb9ba1ab2826 100644
--- a/arch/arm/mach-pxa/cpu-pxa.c
+++ b/arch/arm/mach-pxa/cpu-pxa.c
@@ -49,125 +49,216 @@ MODULE_PARM_DESC(freq_debug, "Set the debug messages to on=1/off=0");
49#define freq_debug 0 49#define freq_debug 0
50#endif 50#endif
51 51
52static unsigned int pxa27x_maxfreq;
53module_param(pxa27x_maxfreq, uint, 0);
54MODULE_PARM_DESC(pxa27x_maxfreq, "Set the pxa27x maxfreq in MHz"
55 "(typically 624=>pxa270, 416=>pxa271, 520=>pxa272)");
56
52typedef struct { 57typedef struct {
53 unsigned int khz; 58 unsigned int khz;
54 unsigned int membus; 59 unsigned int membus;
55 unsigned int cccr; 60 unsigned int cccr;
56 unsigned int div2; 61 unsigned int div2;
62 unsigned int cclkcfg;
57} pxa_freqs_t; 63} pxa_freqs_t;
58 64
59/* Define the refresh period in mSec for the SDRAM and the number of rows */ 65/* Define the refresh period in mSec for the SDRAM and the number of rows */
60#define SDRAM_TREF 64 /* standard 64ms SDRAM */ 66#define SDRAM_TREF 64 /* standard 64ms SDRAM */
61#define SDRAM_ROWS 4096 /* 64MB=8192 32MB=4096 */ 67#define SDRAM_ROWS 4096 /* 64MB=8192 32MB=4096 */
62#define MDREFR_DRI(x) (((x) * SDRAM_TREF) / (SDRAM_ROWS * 32))
63
64#define CCLKCFG_TURBO 0x1
65#define CCLKCFG_FCS 0x2
66#define PXA25x_MIN_FREQ 99500
67#define PXA25x_MAX_FREQ 398100
68#define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2)
69#define MDREFR_DRI_MASK 0xFFF
70 68
69#define CCLKCFG_TURBO 0x1
70#define CCLKCFG_FCS 0x2
71#define CCLKCFG_HALFTURBO 0x4
72#define CCLKCFG_FASTBUS 0x8
73#define MDREFR_DB2_MASK (MDREFR_K2DB2 | MDREFR_K1DB2)
74#define MDREFR_DRI_MASK 0xFFF
71 75
76/*
77 * PXA255 definitions
78 */
72/* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */ 79/* Use the run mode frequencies for the CPUFREQ_POLICY_PERFORMANCE policy */
80#define CCLKCFG CCLKCFG_TURBO | CCLKCFG_FCS
81
73static pxa_freqs_t pxa255_run_freqs[] = 82static pxa_freqs_t pxa255_run_freqs[] =
74{ 83{
75 /* CPU MEMBUS CCCR DIV2*/ 84 /* CPU MEMBUS CCCR DIV2 CCLKCFG run turbo PXbus SDRAM */
76 { 99500, 99500, 0x121, 1}, /* run= 99, turbo= 99, PXbus=50, SDRAM=50 */ 85 { 99500, 99500, 0x121, 1, CCLKCFG}, /* 99, 99, 50, 50 */
77 {132700, 132700, 0x123, 1}, /* run=133, turbo=133, PXbus=66, SDRAM=66 */ 86 {132700, 132700, 0x123, 1, CCLKCFG}, /* 133, 133, 66, 66 */
78 {199100, 99500, 0x141, 0}, /* run=199, turbo=199, PXbus=99, SDRAM=99 */ 87 {199100, 99500, 0x141, 0, CCLKCFG}, /* 199, 199, 99, 99 */
79 {265400, 132700, 0x143, 1}, /* run=265, turbo=265, PXbus=133, SDRAM=66 */ 88 {265400, 132700, 0x143, 1, CCLKCFG}, /* 265, 265, 133, 66 */
80 {331800, 165900, 0x145, 1}, /* run=331, turbo=331, PXbus=166, SDRAM=83 */ 89 {331800, 165900, 0x145, 1, CCLKCFG}, /* 331, 331, 166, 83 */
81 {398100, 99500, 0x161, 0}, /* run=398, turbo=398, PXbus=196, SDRAM=99 */ 90 {398100, 99500, 0x161, 0, CCLKCFG}, /* 398, 398, 196, 99 */
82 {0,}
83}; 91};
84#define NUM_RUN_FREQS ARRAY_SIZE(pxa255_run_freqs)
85
86static struct cpufreq_frequency_table pxa255_run_freq_table[NUM_RUN_FREQS+1];
87 92
88/* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */ 93/* Use the turbo mode frequencies for the CPUFREQ_POLICY_POWERSAVE policy */
89static pxa_freqs_t pxa255_turbo_freqs[] = 94static pxa_freqs_t pxa255_turbo_freqs[] =
90{ 95{
91 /* CPU MEMBUS CCCR DIV2*/ 96 /* CPU MEMBUS CCCR DIV2 CCLKCFG run turbo PXbus SDRAM */
92 { 99500, 99500, 0x121, 1}, /* run=99, turbo= 99, PXbus=50, SDRAM=50 */ 97 { 99500, 99500, 0x121, 1, CCLKCFG}, /* 99, 99, 50, 50 */
93 {199100, 99500, 0x221, 0}, /* run=99, turbo=199, PXbus=50, SDRAM=99 */ 98 {199100, 99500, 0x221, 0, CCLKCFG}, /* 99, 199, 50, 99 */
94 {298500, 99500, 0x321, 0}, /* run=99, turbo=287, PXbus=50, SDRAM=99 */ 99 {298500, 99500, 0x321, 0, CCLKCFG}, /* 99, 287, 50, 99 */
95 {298600, 99500, 0x1c1, 0}, /* run=199, turbo=287, PXbus=99, SDRAM=99 */ 100 {298600, 99500, 0x1c1, 0, CCLKCFG}, /* 199, 287, 99, 99 */
96 {398100, 99500, 0x241, 0}, /* run=199, turbo=398, PXbus=99, SDRAM=99 */ 101 {398100, 99500, 0x241, 0, CCLKCFG}, /* 199, 398, 99, 99 */
97 {0,} 102};
103
104#define NUM_PXA25x_RUN_FREQS ARRAY_SIZE(pxa255_run_freqs)
105#define NUM_PXA25x_TURBO_FREQS ARRAY_SIZE(pxa255_turbo_freqs)
106
107static struct cpufreq_frequency_table
108 pxa255_run_freq_table[NUM_PXA25x_RUN_FREQS+1];
109static struct cpufreq_frequency_table
110 pxa255_turbo_freq_table[NUM_PXA25x_TURBO_FREQS+1];
111
112/*
113 * PXA270 definitions
114 *
115 * For the PXA27x:
116 * Control variables are A, L, 2N for CCCR; B, HT, T for CLKCFG.
117 *
118 * A = 0 => memory controller clock from table 3-7,
119 * A = 1 => memory controller clock = system bus clock
120 * Run mode frequency = 13 MHz * L
121 * Turbo mode frequency = 13 MHz * L * N
122 * System bus frequency = 13 MHz * L / (B + 1)
123 *
124 * In CCCR:
125 * A = 1
126 * L = 16 oscillator to run mode ratio
127 * 2N = 6 2 * (turbo mode to run mode ratio)
128 *
129 * In CCLKCFG:
130 * B = 1 Fast bus mode
131 * HT = 0 Half-Turbo mode
132 * T = 1 Turbo mode
133 *
134 * For now, just support some of the combinations in table 3-7 of
135 * PXA27x Processor Family Developer's Manual to simplify frequency
136 * change sequences.
137 */
138#define PXA27x_CCCR(A, L, N2) (A << 25 | N2 << 7 | L)
139#define CCLKCFG2(B, HT, T) \
140 (CCLKCFG_FCS | \
141 ((B) ? CCLKCFG_FASTBUS : 0) | \
142 ((HT) ? CCLKCFG_HALFTURBO : 0) | \
143 ((T) ? CCLKCFG_TURBO : 0))
144
145static pxa_freqs_t pxa27x_freqs[] = {
146 {104000, 104000, PXA27x_CCCR(1, 8, 2), 0, CCLKCFG2(1, 0, 1)},
147 {156000, 104000, PXA27x_CCCR(1, 8, 6), 0, CCLKCFG2(1, 1, 1)},
148 {208000, 208000, PXA27x_CCCR(0, 16, 2), 1, CCLKCFG2(0, 0, 1)},
149 {312000, 208000, PXA27x_CCCR(1, 16, 3), 1, CCLKCFG2(1, 0, 1)},
150 {416000, 208000, PXA27x_CCCR(1, 16, 4), 1, CCLKCFG2(1, 0, 1)},
151 {520000, 208000, PXA27x_CCCR(1, 16, 5), 1, CCLKCFG2(1, 0, 1)},
152 {624000, 208000, PXA27x_CCCR(1, 16, 6), 1, CCLKCFG2(1, 0, 1)}
98}; 153};
99#define NUM_TURBO_FREQS ARRAY_SIZE(pxa255_turbo_freqs)
100 154
101static struct cpufreq_frequency_table pxa255_turbo_freq_table[NUM_TURBO_FREQS+1]; 155#define NUM_PXA27x_FREQS ARRAY_SIZE(pxa27x_freqs)
156static struct cpufreq_frequency_table
157 pxa27x_freq_table[NUM_PXA27x_FREQS+1];
102 158
103extern unsigned get_clk_frequency_khz(int info); 159extern unsigned get_clk_frequency_khz(int info);
104 160
161static void find_freq_tables(struct cpufreq_policy *policy,
162 struct cpufreq_frequency_table **freq_table,
163 pxa_freqs_t **pxa_freqs)
164{
165 if (cpu_is_pxa25x()) {
166 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) {
167 *pxa_freqs = pxa255_run_freqs;
168 *freq_table = pxa255_run_freq_table;
169 } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) {
170 *pxa_freqs = pxa255_turbo_freqs;
171 *freq_table = pxa255_turbo_freq_table;
172 } else {
173 printk("CPU PXA: Unknown policy found. "
174 "Using CPUFREQ_POLICY_PERFORMANCE\n");
175 *pxa_freqs = pxa255_run_freqs;
176 *freq_table = pxa255_run_freq_table;
177 }
178 }
179 if (cpu_is_pxa27x()) {
180 *pxa_freqs = pxa27x_freqs;
181 *freq_table = pxa27x_freq_table;
182 }
183}
184
185static void pxa27x_guess_max_freq(void)
186{
187 if (!pxa27x_maxfreq) {
188 pxa27x_maxfreq = 416000;
189 printk(KERN_INFO "PXA CPU 27x max frequency not defined "
190 "(pxa27x_maxfreq), assuming pxa271 with %dkHz maxfreq\n",
191 pxa27x_maxfreq);
192 } else {
193 pxa27x_maxfreq *= 1000;
194 }
195}
196
197static u32 mdrefr_dri(unsigned int freq)
198{
199 u32 dri = 0;
200
201 if (cpu_is_pxa25x())
202 dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS * 32));
203 if (cpu_is_pxa27x())
204 dri = ((freq * SDRAM_TREF) / (SDRAM_ROWS - 31)) / 32;
205 return dri;
206}
207
105/* find a valid frequency point */ 208/* find a valid frequency point */
106static int pxa_verify_policy(struct cpufreq_policy *policy) 209static int pxa_verify_policy(struct cpufreq_policy *policy)
107{ 210{
108 struct cpufreq_frequency_table *pxa_freqs_table; 211 struct cpufreq_frequency_table *pxa_freqs_table;
212 pxa_freqs_t *pxa_freqs;
109 int ret; 213 int ret;
110 214
111 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { 215 find_freq_tables(policy, &pxa_freqs_table, &pxa_freqs);
112 pxa_freqs_table = pxa255_run_freq_table;
113 } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) {
114 pxa_freqs_table = pxa255_turbo_freq_table;
115 } else {
116 printk("CPU PXA: Unknown policy found. "
117 "Using CPUFREQ_POLICY_PERFORMANCE\n");
118 pxa_freqs_table = pxa255_run_freq_table;
119 }
120
121 ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table); 216 ret = cpufreq_frequency_table_verify(policy, pxa_freqs_table);
122 217
123 if (freq_debug) 218 if (freq_debug)
124 pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n", 219 pr_debug("Verified CPU policy: %dKhz min to %dKhz max\n",
125 policy->min, policy->max); 220 policy->min, policy->max);
126 221
127 return ret; 222 return ret;
128} 223}
129 224
225static unsigned int pxa_cpufreq_get(unsigned int cpu)
226{
227 return get_clk_frequency_khz(0);
228}
229
130static int pxa_set_target(struct cpufreq_policy *policy, 230static int pxa_set_target(struct cpufreq_policy *policy,
131 unsigned int target_freq, 231 unsigned int target_freq,
132 unsigned int relation) 232 unsigned int relation)
133{ 233{
134 struct cpufreq_frequency_table *pxa_freqs_table; 234 struct cpufreq_frequency_table *pxa_freqs_table;
135 pxa_freqs_t *pxa_freq_settings; 235 pxa_freqs_t *pxa_freq_settings;
136 struct cpufreq_freqs freqs; 236 struct cpufreq_freqs freqs;
137 unsigned int idx; 237 unsigned int idx;
138 unsigned long flags; 238 unsigned long flags;
139 unsigned int unused, preset_mdrefr, postset_mdrefr; 239 unsigned int new_freq_cpu, new_freq_mem;
140 void *ramstart = phys_to_virt(0xa0000000); 240 unsigned int unused, preset_mdrefr, postset_mdrefr, cclkcfg;
141 241
142 /* Get the current policy */ 242 /* Get the current policy */
143 if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { 243 find_freq_tables(policy, &pxa_freqs_table, &pxa_freq_settings);
144 pxa_freq_settings = pxa255_run_freqs;
145 pxa_freqs_table = pxa255_run_freq_table;
146 } else if (policy->policy == CPUFREQ_POLICY_POWERSAVE) {
147 pxa_freq_settings = pxa255_turbo_freqs;
148 pxa_freqs_table = pxa255_turbo_freq_table;
149 } else {
150 printk("CPU PXA: Unknown policy found. "
151 "Using CPUFREQ_POLICY_PERFORMANCE\n");
152 pxa_freq_settings = pxa255_run_freqs;
153 pxa_freqs_table = pxa255_run_freq_table;
154 }
155 244
156 /* Lookup the next frequency */ 245 /* Lookup the next frequency */
157 if (cpufreq_frequency_table_target(policy, pxa_freqs_table, 246 if (cpufreq_frequency_table_target(policy, pxa_freqs_table,
158 target_freq, relation, &idx)) { 247 target_freq, relation, &idx)) {
159 return -EINVAL; 248 return -EINVAL;
160 } 249 }
161 250
251 new_freq_cpu = pxa_freq_settings[idx].khz;
252 new_freq_mem = pxa_freq_settings[idx].membus;
162 freqs.old = policy->cur; 253 freqs.old = policy->cur;
163 freqs.new = pxa_freq_settings[idx].khz; 254 freqs.new = new_freq_cpu;
164 freqs.cpu = policy->cpu; 255 freqs.cpu = policy->cpu;
165 256
166 if (freq_debug) 257 if (freq_debug)
167 pr_debug(KERN_INFO "Changing CPU frequency to %d Mhz, (SDRAM %d Mhz)\n", 258 pr_debug(KERN_INFO "Changing CPU frequency to %d Mhz, "
168 freqs.new / 1000, (pxa_freq_settings[idx].div2) ? 259 "(SDRAM %d Mhz)\n",
169 (pxa_freq_settings[idx].membus / 2000) : 260 freqs.new / 1000, (pxa_freq_settings[idx].div2) ?
170 (pxa_freq_settings[idx].membus / 1000)); 261 (new_freq_mem / 2000) : (new_freq_mem / 1000));
171 262
172 /* 263 /*
173 * Tell everyone what we're about to do... 264 * Tell everyone what we're about to do...
@@ -177,16 +268,16 @@ static int pxa_set_target(struct cpufreq_policy *policy,
177 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); 268 cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE);
178 269
179 /* Calculate the next MDREFR. If we're slowing down the SDRAM clock 270 /* Calculate the next MDREFR. If we're slowing down the SDRAM clock
180 * we need to preset the smaller DRI before the change. If we're speeding 271 * we need to preset the smaller DRI before the change. If we're
181 * up we need to set the larger DRI value after the change. 272 * speeding up we need to set the larger DRI value after the change.
182 */ 273 */
183 preset_mdrefr = postset_mdrefr = MDREFR; 274 preset_mdrefr = postset_mdrefr = MDREFR;
184 if ((MDREFR & MDREFR_DRI_MASK) > MDREFR_DRI(pxa_freq_settings[idx].membus)) { 275 if ((MDREFR & MDREFR_DRI_MASK) > mdrefr_dri(new_freq_mem)) {
185 preset_mdrefr = (preset_mdrefr & ~MDREFR_DRI_MASK) | 276 preset_mdrefr = (preset_mdrefr & ~MDREFR_DRI_MASK);
186 MDREFR_DRI(pxa_freq_settings[idx].membus); 277 preset_mdrefr |= mdrefr_dri(new_freq_mem);
187 } 278 }
188 postset_mdrefr = (postset_mdrefr & ~MDREFR_DRI_MASK) | 279 postset_mdrefr =
189 MDREFR_DRI(pxa_freq_settings[idx].membus); 280 (postset_mdrefr & ~MDREFR_DRI_MASK) | mdrefr_dri(new_freq_mem);
190 281
191 /* If we're dividing the memory clock by two for the SDRAM clock, this 282 /* If we're dividing the memory clock by two for the SDRAM clock, this
192 * must be set prior to the change. Clearing the divide must be done 283 * must be set prior to the change. Clearing the divide must be done
@@ -201,26 +292,27 @@ static int pxa_set_target(struct cpufreq_policy *policy,
201 292
202 local_irq_save(flags); 293 local_irq_save(flags);
203 294
204 /* Set new the CCCR */ 295 /* Set new the CCCR and prepare CCLKCFG */
205 CCCR = pxa_freq_settings[idx].cccr; 296 CCCR = pxa_freq_settings[idx].cccr;
297 cclkcfg = pxa_freq_settings[idx].cclkcfg;
206 298
207 asm volatile(" \n\ 299 asm volatile(" \n\
208 ldr r4, [%1] /* load MDREFR */ \n\ 300 ldr r4, [%1] /* load MDREFR */ \n\
209 b 2f \n\ 301 b 2f \n\
210 .align 5 \n\ 302 .align 5 \n\
2111: \n\ 3031: \n\
212 str %4, [%1] /* preset the MDREFR */ \n\ 304 str %3, [%1] /* preset the MDREFR */ \n\
213 mcr p14, 0, %2, c6, c0, 0 /* set CCLKCFG[FCS] */ \n\ 305 mcr p14, 0, %2, c6, c0, 0 /* set CCLKCFG[FCS] */ \n\
214 str %5, [%1] /* postset the MDREFR */ \n\ 306 str %4, [%1] /* postset the MDREFR */ \n\
215 \n\ 307 \n\
216 b 3f \n\ 308 b 3f \n\
2172: b 1b \n\ 3092: b 1b \n\
2183: nop \n\ 3103: nop \n\
219 " 311 "
220 : "=&r" (unused) 312 : "=&r" (unused)
221 : "r" (&MDREFR), "r" (CCLKCFG_TURBO|CCLKCFG_FCS), "r" (ramstart), 313 : "r" (&MDREFR), "r" (cclkcfg),
222 "r" (preset_mdrefr), "r" (postset_mdrefr) 314 "r" (preset_mdrefr), "r" (postset_mdrefr)
223 : "r4", "r5"); 315 : "r4", "r5");
224 local_irq_restore(flags); 316 local_irq_restore(flags);
225 317
226 /* 318 /*
@@ -233,38 +325,57 @@ static int pxa_set_target(struct cpufreq_policy *policy,
233 return 0; 325 return 0;
234} 326}
235 327
236static unsigned int pxa_cpufreq_get(unsigned int cpu) 328static __init int pxa_cpufreq_init(struct cpufreq_policy *policy)
237{
238 return get_clk_frequency_khz(0);
239}
240
241static int pxa_cpufreq_init(struct cpufreq_policy *policy)
242{ 329{
243 int i; 330 int i;
331 unsigned int freq;
332
333 /* try to guess pxa27x cpu */
334 if (cpu_is_pxa27x())
335 pxa27x_guess_max_freq();
244 336
245 /* set default policy and cpuinfo */ 337 /* set default policy and cpuinfo */
246 policy->governor = CPUFREQ_DEFAULT_GOVERNOR; 338 policy->governor = CPUFREQ_DEFAULT_GOVERNOR;
247 policy->policy = CPUFREQ_POLICY_PERFORMANCE; 339 if (cpu_is_pxa25x())
248 policy->cpuinfo.max_freq = PXA25x_MAX_FREQ; 340 policy->policy = CPUFREQ_POLICY_PERFORMANCE;
249 policy->cpuinfo.min_freq = PXA25x_MIN_FREQ;
250 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */ 341 policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
251 policy->cur = get_clk_frequency_khz(0); /* current freq */ 342 policy->cur = get_clk_frequency_khz(0); /* current freq */
252 policy->min = policy->max = policy->cur; 343 policy->min = policy->max = policy->cur;
253 344
254 /* Generate the run cpufreq_frequency_table struct */ 345 /* Generate pxa25x the run cpufreq_frequency_table struct */
255 for (i = 0; i < NUM_RUN_FREQS; i++) { 346 for (i = 0; i < NUM_PXA25x_RUN_FREQS; i++) {
256 pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz; 347 pxa255_run_freq_table[i].frequency = pxa255_run_freqs[i].khz;
257 pxa255_run_freq_table[i].index = i; 348 pxa255_run_freq_table[i].index = i;
258 } 349 }
259
260 pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END; 350 pxa255_run_freq_table[i].frequency = CPUFREQ_TABLE_END;
261 /* Generate the turbo cpufreq_frequency_table struct */ 351
262 for (i = 0; i < NUM_TURBO_FREQS; i++) { 352 /* Generate pxa25x the turbo cpufreq_frequency_table struct */
263 pxa255_turbo_freq_table[i].frequency = pxa255_turbo_freqs[i].khz; 353 for (i = 0; i < NUM_PXA25x_TURBO_FREQS; i++) {
354 pxa255_turbo_freq_table[i].frequency =
355 pxa255_turbo_freqs[i].khz;
264 pxa255_turbo_freq_table[i].index = i; 356 pxa255_turbo_freq_table[i].index = i;
265 } 357 }
266 pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END; 358 pxa255_turbo_freq_table[i].frequency = CPUFREQ_TABLE_END;
267 359
360 /* Generate the pxa27x cpufreq_frequency_table struct */
361 for (i = 0; i < NUM_PXA27x_FREQS; i++) {
362 freq = pxa27x_freqs[i].khz;
363 if (freq > pxa27x_maxfreq)
364 break;
365 pxa27x_freq_table[i].frequency = freq;
366 pxa27x_freq_table[i].index = i;
367 }
368 pxa27x_freq_table[i].frequency = CPUFREQ_TABLE_END;
369
370 /*
371 * Set the policy's minimum and maximum frequencies from the tables
372 * just constructed. This sets cpuinfo.mxx_freq, min and max.
373 */
374 if (cpu_is_pxa25x())
375 cpufreq_frequency_table_cpuinfo(policy, pxa255_run_freq_table);
376 else if (cpu_is_pxa27x())
377 cpufreq_frequency_table_cpuinfo(policy, pxa27x_freq_table);
378
268 printk(KERN_INFO "PXA CPU frequency change support initialized\n"); 379 printk(KERN_INFO "PXA CPU frequency change support initialized\n");
269 380
270 return 0; 381 return 0;
@@ -275,26 +386,25 @@ static struct cpufreq_driver pxa_cpufreq_driver = {
275 .target = pxa_set_target, 386 .target = pxa_set_target,
276 .init = pxa_cpufreq_init, 387 .init = pxa_cpufreq_init,
277 .get = pxa_cpufreq_get, 388 .get = pxa_cpufreq_get,
278 .name = "PXA25x", 389 .name = "PXA2xx",
279}; 390};
280 391
281static int __init pxa_cpu_init(void) 392static int __init pxa_cpu_init(void)
282{ 393{
283 int ret = -ENODEV; 394 int ret = -ENODEV;
284 if (cpu_is_pxa25x()) 395 if (cpu_is_pxa25x() || cpu_is_pxa27x())
285 ret = cpufreq_register_driver(&pxa_cpufreq_driver); 396 ret = cpufreq_register_driver(&pxa_cpufreq_driver);
286 return ret; 397 return ret;
287} 398}
288 399
289static void __exit pxa_cpu_exit(void) 400static void __exit pxa_cpu_exit(void)
290{ 401{
291 if (cpu_is_pxa25x()) 402 cpufreq_unregister_driver(&pxa_cpufreq_driver);
292 cpufreq_unregister_driver(&pxa_cpufreq_driver);
293} 403}
294 404
295 405
296MODULE_AUTHOR ("Intrinsyc Software Inc."); 406MODULE_AUTHOR("Intrinsyc Software Inc.");
297MODULE_DESCRIPTION ("CPU frequency changing driver for the PXA architecture"); 407MODULE_DESCRIPTION("CPU frequency changing driver for the PXA architecture");
298MODULE_LICENSE("GPL"); 408MODULE_LICENSE("GPL");
299module_init(pxa_cpu_init); 409module_init(pxa_cpu_init);
300module_exit(pxa_cpu_exit); 410module_exit(pxa_cpu_exit);
diff --git a/arch/arm/mach-pxa/lubbock.c b/arch/arm/mach-pxa/lubbock.c
index 0993f4d1a0bc..7b9bdd0c6665 100644
--- a/arch/arm/mach-pxa/lubbock.c
+++ b/arch/arm/mach-pxa/lubbock.c
@@ -396,7 +396,7 @@ static struct pxafb_mach_info sharp_lm8v31 = {
396 .cmap_inverse = 0, 396 .cmap_inverse = 0,
397 .cmap_static = 0, 397 .cmap_static = 0,
398 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL | 398 .lcd_conn = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
399 LCD_AC_BIAS_FREQ(255); 399 LCD_AC_BIAS_FREQ(255),
400}; 400};
401 401
402#define MMC_POLL_RATE msecs_to_jiffies(1000) 402#define MMC_POLL_RATE msecs_to_jiffies(1000)
diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
index ec1bbf333a3a..7d4debbdcca3 100644
--- a/arch/arm/mach-pxa/pm.c
+++ b/arch/arm/mach-pxa/pm.c
@@ -42,20 +42,17 @@ int pxa_pm_enter(suspend_state_t state)
42 if (state != PM_SUSPEND_STANDBY) { 42 if (state != PM_SUSPEND_STANDBY) {
43 pxa_cpu_pm_fns->save(sleep_save); 43 pxa_cpu_pm_fns->save(sleep_save);
44 /* before sleeping, calculate and save a checksum */ 44 /* before sleeping, calculate and save a checksum */
45 for (i = 0; i < pxa_cpu_pm_fns->save_size - 1; i++) 45 for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
46 sleep_save_checksum += sleep_save[i]; 46 sleep_save_checksum += sleep_save[i];
47 } 47 }
48 48
49 /* Clear reset status */
50 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
51
52 /* *** go zzz *** */ 49 /* *** go zzz *** */
53 pxa_cpu_pm_fns->enter(state); 50 pxa_cpu_pm_fns->enter(state);
54 cpu_init(); 51 cpu_init();
55 52
56 if (state != PM_SUSPEND_STANDBY) { 53 if (state != PM_SUSPEND_STANDBY) {
57 /* after sleeping, validate the checksum */ 54 /* after sleeping, validate the checksum */
58 for (i = 0; i < pxa_cpu_pm_fns->save_size - 1; i++) 55 for (i = 0; i < pxa_cpu_pm_fns->save_count - 1; i++)
59 checksum += sleep_save[i]; 56 checksum += sleep_save[i];
60 57
61 /* if invalid, display message and wait for a hardware reset */ 58 /* if invalid, display message and wait for a hardware reset */
@@ -101,7 +98,8 @@ static int __init pxa_pm_init(void)
101 return -EINVAL; 98 return -EINVAL;
102 } 99 }
103 100
104 sleep_save = kmalloc(pxa_cpu_pm_fns->save_size, GFP_KERNEL); 101 sleep_save = kmalloc(pxa_cpu_pm_fns->save_count * sizeof(unsigned long),
102 GFP_KERNEL);
105 if (!sleep_save) { 103 if (!sleep_save) {
106 printk(KERN_ERR "failed to alloc memory for pm save\n"); 104 printk(KERN_ERR "failed to alloc memory for pm save\n");
107 return -ENOMEM; 105 return -ENOMEM;
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index ca5ac196b47b..0b30f25cff3c 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -326,13 +326,11 @@ static struct platform_device *devices[] __initdata = {
326 326
327static void poodle_poweroff(void) 327static void poodle_poweroff(void)
328{ 328{
329 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
330 arm_machine_restart('h'); 329 arm_machine_restart('h');
331} 330}
332 331
333static void poodle_restart(char mode) 332static void poodle_restart(char mode)
334{ 333{
335 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
336 arm_machine_restart('h'); 334 arm_machine_restart('h');
337} 335}
338 336
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index d9b5450aee5b..e5b417d14bb0 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -150,9 +150,7 @@ static struct clk pxa25x_clks[] = {
150 * More ones like CP and general purpose register values are preserved 150 * More ones like CP and general purpose register values are preserved
151 * with the stack pointer in sleep.S. 151 * with the stack pointer in sleep.S.
152 */ 152 */
153enum { SLEEP_SAVE_START = 0, 153enum { SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2,
154
155 SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2,
156 154
157 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U, 155 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
158 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U, 156 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
@@ -162,7 +160,7 @@ enum { SLEEP_SAVE_START = 0,
162 160
163 SLEEP_SAVE_CKEN, 161 SLEEP_SAVE_CKEN,
164 162
165 SLEEP_SAVE_SIZE 163 SLEEP_SAVE_COUNT
166}; 164};
167 165
168 166
@@ -200,6 +198,9 @@ static void pxa25x_cpu_pm_restore(unsigned long *sleep_save)
200 198
201static void pxa25x_cpu_pm_enter(suspend_state_t state) 199static void pxa25x_cpu_pm_enter(suspend_state_t state)
202{ 200{
201 /* Clear reset status */
202 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
203
203 switch (state) { 204 switch (state) {
204 case PM_SUSPEND_MEM: 205 case PM_SUSPEND_MEM:
205 /* set resume return address */ 206 /* set resume return address */
@@ -210,7 +211,7 @@ static void pxa25x_cpu_pm_enter(suspend_state_t state)
210} 211}
211 212
212static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = { 213static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = {
213 .save_size = SLEEP_SAVE_SIZE, 214 .save_count = SLEEP_SAVE_COUNT,
214 .valid = suspend_valid_only_mem, 215 .valid = suspend_valid_only_mem,
215 .save = pxa25x_cpu_pm_save, 216 .save = pxa25x_cpu_pm_save,
216 .restore = pxa25x_cpu_pm_restore, 217 .restore = pxa25x_cpu_pm_restore,
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index 7a2449dd0fd4..7e945836e129 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -181,9 +181,7 @@ static struct clk pxa27x_clks[] = {
181 * More ones like CP and general purpose register values are preserved 181 * More ones like CP and general purpose register values are preserved
182 * with the stack pointer in sleep.S. 182 * with the stack pointer in sleep.S.
183 */ 183 */
184enum { SLEEP_SAVE_START = 0, 184enum { SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
185
186 SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
187 185
188 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U, 186 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
189 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U, 187 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
@@ -198,7 +196,7 @@ enum { SLEEP_SAVE_START = 0,
198 SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER, 196 SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
199 SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR, 197 SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
200 198
201 SLEEP_SAVE_SIZE 199 SLEEP_SAVE_COUNT
202}; 200};
203 201
204void pxa27x_cpu_pm_save(unsigned long *sleep_save) 202void pxa27x_cpu_pm_save(unsigned long *sleep_save)
@@ -251,6 +249,9 @@ void pxa27x_cpu_pm_enter(suspend_state_t state)
251 /* Clear edge-detect status register. */ 249 /* Clear edge-detect status register. */
252 PEDR = 0xDF12FE1B; 250 PEDR = 0xDF12FE1B;
253 251
252 /* Clear reset status */
253 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
254
254 switch (state) { 255 switch (state) {
255 case PM_SUSPEND_STANDBY: 256 case PM_SUSPEND_STANDBY:
256 pxa_cpu_standby(); 257 pxa_cpu_standby();
@@ -269,7 +270,7 @@ static int pxa27x_cpu_pm_valid(suspend_state_t state)
269} 270}
270 271
271static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = { 272static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = {
272 .save_size = SLEEP_SAVE_SIZE, 273 .save_count = SLEEP_SAVE_COUNT,
273 .save = pxa27x_cpu_pm_save, 274 .save = pxa27x_cpu_pm_save,
274 .restore = pxa27x_cpu_pm_restore, 275 .restore = pxa27x_cpu_pm_restore,
275 .valid = pxa27x_cpu_pm_valid, 276 .valid = pxa27x_cpu_pm_valid,
diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c
index b6a6f5fcc77a..644550bfa330 100644
--- a/arch/arm/mach-pxa/pxa3xx.c
+++ b/arch/arm/mach-pxa/pxa3xx.c
@@ -256,12 +256,11 @@ static unsigned long wakeup_src;
256#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x 256#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
257#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x] 257#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
258 258
259enum { SLEEP_SAVE_START = 0, 259enum { SLEEP_SAVE_CKENA,
260 SLEEP_SAVE_CKENA,
261 SLEEP_SAVE_CKENB, 260 SLEEP_SAVE_CKENB,
262 SLEEP_SAVE_ACCR, 261 SLEEP_SAVE_ACCR,
263 262
264 SLEEP_SAVE_SIZE, 263 SLEEP_SAVE_COUNT,
265}; 264};
266 265
267static void pxa3xx_cpu_pm_save(unsigned long *sleep_save) 266static void pxa3xx_cpu_pm_save(unsigned long *sleep_save)
@@ -376,7 +375,7 @@ static int pxa3xx_cpu_pm_valid(suspend_state_t state)
376} 375}
377 376
378static struct pxa_cpu_pm_fns pxa3xx_cpu_pm_fns = { 377static struct pxa_cpu_pm_fns pxa3xx_cpu_pm_fns = {
379 .save_size = SLEEP_SAVE_SIZE, 378 .save_count = SLEEP_SAVE_COUNT,
380 .save = pxa3xx_cpu_pm_save, 379 .save = pxa3xx_cpu_pm_save,
381 .restore = pxa3xx_cpu_pm_restore, 380 .restore = pxa3xx_cpu_pm_restore,
382 .valid = pxa3xx_cpu_pm_valid, 381 .valid = pxa3xx_cpu_pm_valid,
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index 62a02c3927c5..e7d0fcd9b43f 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -529,8 +529,6 @@ static struct platform_device *devices[] __initdata = {
529 529
530static void spitz_poweroff(void) 530static void spitz_poweroff(void)
531{ 531{
532 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
533
534 pxa_gpio_mode(SPITZ_GPIO_ON_RESET | GPIO_OUT); 532 pxa_gpio_mode(SPITZ_GPIO_ON_RESET | GPIO_OUT);
535 GPSR(SPITZ_GPIO_ON_RESET) = GPIO_bit(SPITZ_GPIO_ON_RESET); 533 GPSR(SPITZ_GPIO_ON_RESET) = GPIO_bit(SPITZ_GPIO_ON_RESET);
536 534
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 7a7f5f947cc5..23f050feb208 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -119,9 +119,6 @@ static void spitz_presuspend(void)
119 /* nRESET_OUT Disable */ 119 /* nRESET_OUT Disable */
120 PSLR |= PSLR_SL_ROD; 120 PSLR |= PSLR_SL_ROD;
121 121
122 /* Clear reset status */
123 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
124
125 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ 122 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
126 PCFR = PCFR_GPR_EN | PCFR_OPDE; 123 PCFR = PCFR_GPR_EN | PCFR_OPDE;
127} 124}
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index 6458f6d371d9..c2cbd66db814 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -467,8 +467,6 @@ static struct platform_device *devices[] __initdata = {
467 467
468static void tosa_poweroff(void) 468static void tosa_poweroff(void)
469{ 469{
470 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
471
472 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT); 470 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT);
473 GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET); 471 GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET);
474 472
diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c
index 246c573e7252..1693d447a224 100644
--- a/arch/arm/mach-sa1100/pm.c
+++ b/arch/arm/mach-sa1100/pm.c
@@ -43,20 +43,18 @@ extern void sa1100_cpu_resume(void);
43 * More ones like CP and general purpose register values are preserved 43 * More ones like CP and general purpose register values are preserved
44 * on the stack and then the stack pointer is stored last in sleep.S. 44 * on the stack and then the stack pointer is stored last in sleep.S.
45 */ 45 */
46enum { SLEEP_SAVE_SP = 0, 46enum { SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR,
47
48 SLEEP_SAVE_GPDR, SLEEP_SAVE_GAFR,
49 SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR, 47 SLEEP_SAVE_PPDR, SLEEP_SAVE_PPSR, SLEEP_SAVE_PPAR, SLEEP_SAVE_PSDR,
50 48
51 SLEEP_SAVE_Ser1SDCR0, 49 SLEEP_SAVE_Ser1SDCR0,
52 50
53 SLEEP_SAVE_SIZE 51 SLEEP_SAVE_COUNT
54}; 52};
55 53
56 54
57static int sa11x0_pm_enter(suspend_state_t state) 55static int sa11x0_pm_enter(suspend_state_t state)
58{ 56{
59 unsigned long gpio, sleep_save[SLEEP_SAVE_SIZE]; 57 unsigned long gpio, sleep_save[SLEEP_SAVE_COUNT];
60 58
61 gpio = GPLR; 59 gpio = GPLR;
62 60
diff --git a/arch/arm/plat-s3c24xx/clock.c b/arch/arm/plat-s3c24xx/clock.c
index d84167fb33b1..3ac8d8d781b3 100644
--- a/arch/arm/plat-s3c24xx/clock.c
+++ b/arch/arm/plat-s3c24xx/clock.c
@@ -411,7 +411,7 @@ static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
411 411
412 clk->parent = parent; 412 clk->parent = parent;
413 413
414 if (clk == &s3c24xx_dclk0) 414 if (clk == &s3c24xx_clkout0)
415 mask = S3C2410_MISCCR_CLK0_MASK; 415 mask = S3C2410_MISCCR_CLK0_MASK;
416 else { 416 else {
417 source <<= 4; 417 source <<= 4;
@@ -437,7 +437,7 @@ struct clk s3c24xx_dclk0 = {
437struct clk s3c24xx_dclk1 = { 437struct clk s3c24xx_dclk1 = {
438 .name = "dclk1", 438 .name = "dclk1",
439 .id = -1, 439 .id = -1,
440 .ctrlbit = S3C2410_DCLKCON_DCLK0EN, 440 .ctrlbit = S3C2410_DCLKCON_DCLK1EN,
441 .enable = s3c24xx_dclk_enable, 441 .enable = s3c24xx_dclk_enable,
442 .set_parent = s3c24xx_dclk_setparent, 442 .set_parent = s3c24xx_dclk_setparent,
443 .set_rate = s3c24xx_set_dclk_rate, 443 .set_rate = s3c24xx_set_dclk_rate,
diff --git a/arch/blackfin/Kconfig b/arch/blackfin/Kconfig
index 795d0ac67c21..fd5708523f2e 100644
--- a/arch/blackfin/Kconfig
+++ b/arch/blackfin/Kconfig
@@ -832,6 +832,7 @@ config BANK_0
832config BANK_1 832config BANK_1
833 hex "Bank 1" 833 hex "Bank 1"
834 default 0x7BB0 834 default 0x7BB0
835 default 0x5558 if BF54x
835 836
836config BANK_2 837config BANK_2
837 hex "Bank 2" 838 hex "Bank 2"
@@ -963,21 +964,22 @@ endchoice
963 964
964endmenu 965endmenu
965 966
966if (BF537 || BF533 || BF54x)
967
968menu "CPU Frequency scaling" 967menu "CPU Frequency scaling"
969 968
970source "drivers/cpufreq/Kconfig" 969source "drivers/cpufreq/Kconfig"
971 970
972config CPU_FREQ 971config CPU_VOLTAGE
973 bool 972 bool "CPU Voltage scaling"
973 depends on EXPERIMENTAL
974 depends on CPU_FREQ
974 default n 975 default n
975 help 976 help
976 If you want to enable this option, you should select the 977 Say Y here if you want CPU voltage scaling according to the CPU frequency.
977 DPMC driver from Character Devices. 978 This option violates the PLL BYPASS recommendation in the Blackfin Processor
978endmenu 979 manuals. There is a theoretical risk that during VDDINT transitions
980 the PLL may unlock.
979 981
980endif 982endmenu
981 983
982source "net/Kconfig" 984source "net/Kconfig"
983 985
diff --git a/arch/blackfin/kernel/asm-offsets.c b/arch/blackfin/kernel/asm-offsets.c
index 721f15f3cebf..881afe9082c7 100644
--- a/arch/blackfin/kernel/asm-offsets.c
+++ b/arch/blackfin/kernel/asm-offsets.c
@@ -56,9 +56,6 @@ int main(void)
56 /* offsets into the thread struct */ 56 /* offsets into the thread struct */
57 DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp)); 57 DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
58 DEFINE(THREAD_USP, offsetof(struct thread_struct, usp)); 58 DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
59 DEFINE(THREAD_SR, offsetof(struct thread_struct, seqstat));
60 DEFINE(PT_SR, offsetof(struct thread_struct, seqstat));
61 DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
62 DEFINE(THREAD_PC, offsetof(struct thread_struct, pc)); 59 DEFINE(THREAD_PC, offsetof(struct thread_struct, pc));
63 DEFINE(KERNEL_STACK_SIZE, THREAD_SIZE); 60 DEFINE(KERNEL_STACK_SIZE, THREAD_SIZE);
64 61
diff --git a/arch/blackfin/kernel/fixed_code.S b/arch/blackfin/kernel/fixed_code.S
index 5ed47228a390..4b03ba025488 100644
--- a/arch/blackfin/kernel/fixed_code.S
+++ b/arch/blackfin/kernel/fixed_code.S
@@ -1,6 +1,6 @@
1/* 1/*
2 * This file contains sequences of code that will be copied to a 2 * This file contains sequences of code that will be copied to a
3 * fixed location, defined in <asm/atomic_seq.h>. The interrupt 3 * fixed location, defined in <asm/fixed_code.h>. The interrupt
4 * handlers ensure that these sequences appear to be atomic when 4 * handlers ensure that these sequences appear to be atomic when
5 * executed from userspace. 5 * executed from userspace.
6 * These are aligned to 16 bytes, so that we have some space to replace 6 * These are aligned to 16 bytes, so that we have some space to replace
diff --git a/arch/blackfin/kernel/module.c b/arch/blackfin/kernel/module.c
index 8b9fe29d03f4..14a42848f37f 100644
--- a/arch/blackfin/kernel/module.c
+++ b/arch/blackfin/kernel/module.c
@@ -160,6 +160,13 @@ int
160module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs, 160module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
161 char *secstrings, struct module *mod) 161 char *secstrings, struct module *mod)
162{ 162{
163 /*
164 * XXX: sechdrs are vmalloced in kernel/module.c
165 * and would be vfreed just after module is loaded,
166 * so we hack to keep the only information we needed
167 * in mod->arch to correctly free L1 I/D sram later.
168 * NOTE: this breaks the semantic of mod->arch structure.
169 */
163 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum; 170 Elf_Shdr *s, *sechdrs_end = sechdrs + hdr->e_shnum;
164 void *dest = NULL; 171 void *dest = NULL;
165 172
@@ -167,8 +174,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
167 if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) || 174 if ((strcmp(".l1.text", secstrings + s->sh_name) == 0) ||
168 ((strcmp(".text", secstrings + s->sh_name) == 0) && 175 ((strcmp(".text", secstrings + s->sh_name) == 0) &&
169 (hdr->e_flags & FLG_CODE_IN_L1) && (s->sh_size > 0))) { 176 (hdr->e_flags & FLG_CODE_IN_L1) && (s->sh_size > 0))) {
170 mod->arch.text_l1 = s;
171 dest = l1_inst_sram_alloc(s->sh_size); 177 dest = l1_inst_sram_alloc(s->sh_size);
178 mod->arch.text_l1 = dest;
172 if (dest == NULL) { 179 if (dest == NULL) {
173 printk(KERN_ERR 180 printk(KERN_ERR
174 "module %s: L1 instruction memory allocation failed\n", 181 "module %s: L1 instruction memory allocation failed\n",
@@ -182,8 +189,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
182 if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) || 189 if ((strcmp(".l1.data", secstrings + s->sh_name) == 0) ||
183 ((strcmp(".data", secstrings + s->sh_name) == 0) && 190 ((strcmp(".data", secstrings + s->sh_name) == 0) &&
184 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) { 191 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
185 mod->arch.data_a_l1 = s;
186 dest = l1_data_sram_alloc(s->sh_size); 192 dest = l1_data_sram_alloc(s->sh_size);
193 mod->arch.data_a_l1 = dest;
187 if (dest == NULL) { 194 if (dest == NULL) {
188 printk(KERN_ERR 195 printk(KERN_ERR
189 "module %s: L1 data memory allocation failed\n", 196 "module %s: L1 data memory allocation failed\n",
@@ -197,8 +204,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
197 if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 || 204 if (strcmp(".l1.bss", secstrings + s->sh_name) == 0 ||
198 ((strcmp(".bss", secstrings + s->sh_name) == 0) && 205 ((strcmp(".bss", secstrings + s->sh_name) == 0) &&
199 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) { 206 (hdr->e_flags & FLG_DATA_IN_L1) && (s->sh_size > 0))) {
200 mod->arch.bss_a_l1 = s;
201 dest = l1_data_sram_alloc(s->sh_size); 207 dest = l1_data_sram_alloc(s->sh_size);
208 mod->arch.bss_a_l1 = dest;
202 if (dest == NULL) { 209 if (dest == NULL) {
203 printk(KERN_ERR 210 printk(KERN_ERR
204 "module %s: L1 data memory allocation failed\n", 211 "module %s: L1 data memory allocation failed\n",
@@ -210,8 +217,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
210 s->sh_addr = (unsigned long)dest; 217 s->sh_addr = (unsigned long)dest;
211 } 218 }
212 if (strcmp(".l1.data.B", secstrings + s->sh_name) == 0) { 219 if (strcmp(".l1.data.B", secstrings + s->sh_name) == 0) {
213 mod->arch.data_b_l1 = s;
214 dest = l1_data_B_sram_alloc(s->sh_size); 220 dest = l1_data_B_sram_alloc(s->sh_size);
221 mod->arch.data_b_l1 = dest;
215 if (dest == NULL) { 222 if (dest == NULL) {
216 printk(KERN_ERR 223 printk(KERN_ERR
217 "module %s: L1 data memory allocation failed\n", 224 "module %s: L1 data memory allocation failed\n",
@@ -223,8 +230,8 @@ module_frob_arch_sections(Elf_Ehdr * hdr, Elf_Shdr * sechdrs,
223 s->sh_addr = (unsigned long)dest; 230 s->sh_addr = (unsigned long)dest;
224 } 231 }
225 if (strcmp(".l1.bss.B", secstrings + s->sh_name) == 0) { 232 if (strcmp(".l1.bss.B", secstrings + s->sh_name) == 0) {
226 mod->arch.bss_b_l1 = s;
227 dest = l1_data_B_sram_alloc(s->sh_size); 233 dest = l1_data_B_sram_alloc(s->sh_size);
234 mod->arch.bss_b_l1 = dest;
228 if (dest == NULL) { 235 if (dest == NULL) {
229 printk(KERN_ERR 236 printk(KERN_ERR
230 "module %s: L1 data memory allocation failed\n", 237 "module %s: L1 data memory allocation failed\n",
@@ -416,14 +423,14 @@ module_finalize(const Elf_Ehdr * hdr,
416 423
417void module_arch_cleanup(struct module *mod) 424void module_arch_cleanup(struct module *mod)
418{ 425{
419 if ((mod->arch.text_l1) && (mod->arch.text_l1->sh_addr)) 426 if (mod->arch.text_l1)
420 l1_inst_sram_free((void *)mod->arch.text_l1->sh_addr); 427 l1_inst_sram_free((void *)mod->arch.text_l1);
421 if ((mod->arch.data_a_l1) && (mod->arch.data_a_l1->sh_addr)) 428 if (mod->arch.data_a_l1)
422 l1_data_sram_free((void *)mod->arch.data_a_l1->sh_addr); 429 l1_data_sram_free((void *)mod->arch.data_a_l1);
423 if ((mod->arch.bss_a_l1) && (mod->arch.bss_a_l1->sh_addr)) 430 if (mod->arch.bss_a_l1)
424 l1_data_sram_free((void *)mod->arch.bss_a_l1->sh_addr); 431 l1_data_sram_free((void *)mod->arch.bss_a_l1);
425 if ((mod->arch.data_b_l1) && (mod->arch.data_b_l1->sh_addr)) 432 if (mod->arch.data_b_l1)
426 l1_data_B_sram_free((void *)mod->arch.data_b_l1->sh_addr); 433 l1_data_B_sram_free((void *)mod->arch.data_b_l1);
427 if ((mod->arch.bss_b_l1) && (mod->arch.bss_b_l1->sh_addr)) 434 if (mod->arch.bss_b_l1)
428 l1_data_B_sram_free((void *)mod->arch.bss_b_l1->sh_addr); 435 l1_data_B_sram_free((void *)mod->arch.bss_b_l1);
429} 436}
diff --git a/arch/blackfin/kernel/process.c b/arch/blackfin/kernel/process.c
index be9fdd00d7cb..53c2cd255441 100644
--- a/arch/blackfin/kernel/process.c
+++ b/arch/blackfin/kernel/process.c
@@ -245,7 +245,7 @@ unsigned long get_wchan(struct task_struct *p)
245 245
246void finish_atomic_sections (struct pt_regs *regs) 246void finish_atomic_sections (struct pt_regs *regs)
247{ 247{
248 int __user *up0 = (int __user *)&regs->p0; 248 int __user *up0 = (int __user *)regs->p0;
249 249
250 if (regs->pc < ATOMIC_SEQS_START || regs->pc >= ATOMIC_SEQS_END) 250 if (regs->pc < ATOMIC_SEQS_START || regs->pc >= ATOMIC_SEQS_END)
251 return; 251 return;
diff --git a/arch/blackfin/kernel/ptrace.c b/arch/blackfin/kernel/ptrace.c
index b4f062c172c6..f51ab088098e 100644
--- a/arch/blackfin/kernel/ptrace.c
+++ b/arch/blackfin/kernel/ptrace.c
@@ -185,8 +185,8 @@ void ptrace_disable(struct task_struct *child)
185{ 185{
186 unsigned long tmp; 186 unsigned long tmp;
187 /* make sure the single step bit is not set. */ 187 /* make sure the single step bit is not set. */
188 tmp = get_reg(child, PT_SR) & ~(TRACE_BITS << 16); 188 tmp = get_reg(child, PT_SYSCFG) & ~TRACE_BITS;
189 put_reg(child, PT_SR, tmp); 189 put_reg(child, PT_SYSCFG, tmp);
190} 190}
191 191
192long arch_ptrace(struct task_struct *child, long request, long addr, long data) 192long arch_ptrace(struct task_struct *child, long request, long addr, long data)
diff --git a/arch/blackfin/kernel/signal.c b/arch/blackfin/kernel/signal.c
index cb9d883d493c..dbc3bbf846be 100644
--- a/arch/blackfin/kernel/signal.c
+++ b/arch/blackfin/kernel/signal.c
@@ -42,6 +42,9 @@
42 42
43#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 43#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
44 44
45/* Location of the trace bit in SYSCFG. */
46#define TRACE_BITS 0x0001
47
45struct fdpic_func_descriptor { 48struct fdpic_func_descriptor {
46 unsigned long text; 49 unsigned long text;
47 unsigned long GOT; 50 unsigned long GOT;
@@ -225,6 +228,16 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t * info,
225 regs->r1 = (unsigned long)(&frame->info); 228 regs->r1 = (unsigned long)(&frame->info);
226 regs->r2 = (unsigned long)(&frame->uc); 229 regs->r2 = (unsigned long)(&frame->uc);
227 230
231 /*
232 * Clear the trace flag when entering the signal handler, but
233 * notify any tracer that was single-stepping it. The tracer
234 * may want to single-step inside the handler too.
235 */
236 if (regs->syscfg & TRACE_BITS) {
237 regs->syscfg &= ~TRACE_BITS;
238 ptrace_notify(SIGTRAP);
239 }
240
228 return 0; 241 return 0;
229 242
230 give_sigsegv: 243 give_sigsegv:
diff --git a/arch/blackfin/kernel/time-ts.c b/arch/blackfin/kernel/time-ts.c
index 4482c47c09e5..e887efc86c29 100644
--- a/arch/blackfin/kernel/time-ts.c
+++ b/arch/blackfin/kernel/time-ts.c
@@ -60,7 +60,7 @@ static inline unsigned long long cycles_2_ns(cycle_t cyc)
60 60
61static cycle_t read_cycles(void) 61static cycle_t read_cycles(void)
62{ 62{
63 return get_cycles(); 63 return __bfin_cycles_off + (get_cycles() << __bfin_cycles_mod);
64} 64}
65 65
66unsigned long long sched_clock(void) 66unsigned long long sched_clock(void)
@@ -117,7 +117,7 @@ static void bfin_timer_set_mode(enum clock_event_mode mode,
117 break; 117 break;
118 } 118 }
119 case CLOCK_EVT_MODE_ONESHOT: 119 case CLOCK_EVT_MODE_ONESHOT:
120 bfin_write_TSCALE(0); 120 bfin_write_TSCALE(TIME_SCALE - 1);
121 bfin_write_TCOUNT(0); 121 bfin_write_TCOUNT(0);
122 bfin_write_TCNTL(TMPWR | TMREN); 122 bfin_write_TCNTL(TMPWR | TMREN);
123 CSYNC(); 123 CSYNC();
@@ -183,10 +183,14 @@ irqreturn_t timer_interrupt(int irq, void *dev_id)
183 183
184static int __init bfin_clockevent_init(void) 184static int __init bfin_clockevent_init(void)
185{ 185{
186 unsigned long timer_clk;
187
188 timer_clk = get_cclk() / TIME_SCALE;
189
186 setup_irq(IRQ_CORETMR, &bfin_timer_irq); 190 setup_irq(IRQ_CORETMR, &bfin_timer_irq);
187 bfin_timer_init(); 191 bfin_timer_init();
188 192
189 clockevent_bfin.mult = div_sc(get_cclk(), NSEC_PER_SEC, clockevent_bfin.shift); 193 clockevent_bfin.mult = div_sc(timer_clk, NSEC_PER_SEC, clockevent_bfin.shift);
190 clockevent_bfin.max_delta_ns = clockevent_delta2ns(-1, &clockevent_bfin); 194 clockevent_bfin.max_delta_ns = clockevent_delta2ns(-1, &clockevent_bfin);
191 clockevent_bfin.min_delta_ns = clockevent_delta2ns(100, &clockevent_bfin); 195 clockevent_bfin.min_delta_ns = clockevent_delta2ns(100, &clockevent_bfin);
192 clockevents_register_device(&clockevent_bfin); 196 clockevents_register_device(&clockevent_bfin);
diff --git a/arch/blackfin/mach-bf527/boards/ezkit.c b/arch/blackfin/mach-bf527/boards/ezkit.c
index 583d53811f03..8aa49f804228 100644
--- a/arch/blackfin/mach-bf527/boards/ezkit.c
+++ b/arch/blackfin/mach-bf527/boards/ezkit.c
@@ -32,12 +32,14 @@
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/mtd/mtd.h> 33#include <linux/mtd/mtd.h>
34#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
35#include <linux/mtd/physmap.h>
35#include <linux/spi/spi.h> 36#include <linux/spi/spi.h>
36#include <linux/spi/flash.h> 37#include <linux/spi/flash.h>
37#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE) 38#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb/isp1362.h> 39#include <linux/usb/isp1362.h>
39#endif 40#endif
40#include <linux/ata_platform.h> 41#include <linux/ata_platform.h>
42#include <linux/i2c.h>
41#include <linux/irq.h> 43#include <linux/irq.h>
42#include <linux/interrupt.h> 44#include <linux/interrupt.h>
43#include <linux/usb/sl811.h> 45#include <linux/usb/sl811.h>
@@ -50,6 +52,7 @@
50#include <asm/reboot.h> 52#include <asm/reboot.h>
51#include <asm/nand.h> 53#include <asm/nand.h>
52#include <asm/portmux.h> 54#include <asm/portmux.h>
55#include <asm/dpmc.h>
53#include <linux/spi/ad7877.h> 56#include <linux/spi/ad7877.h>
54 57
55/* 58/*
@@ -171,6 +174,46 @@ static struct platform_device bf52x_t350mcqb_device = {
171}; 174};
172#endif 175#endif
173 176
177#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
178static struct mtd_partition ezkit_partitions[] = {
179 {
180 .name = "Bootloader",
181 .size = 0x40000,
182 .offset = 0,
183 }, {
184 .name = "Kernel",
185 .size = 0x1C0000,
186 .offset = MTDPART_OFS_APPEND,
187 }, {
188 .name = "RootFS",
189 .size = MTDPART_SIZ_FULL,
190 .offset = MTDPART_OFS_APPEND,
191 }
192};
193
194static struct physmap_flash_data ezkit_flash_data = {
195 .width = 2,
196 .parts = ezkit_partitions,
197 .nr_parts = ARRAY_SIZE(ezkit_partitions),
198};
199
200static struct resource ezkit_flash_resource = {
201 .start = 0x20000000,
202 .end = 0x203fffff,
203 .flags = IORESOURCE_MEM,
204};
205
206static struct platform_device ezkit_flash_device = {
207 .name = "physmap-flash",
208 .id = 0,
209 .dev = {
210 .platform_data = &ezkit_flash_data,
211 },
212 .num_resources = 1,
213 .resource = &ezkit_flash_resource,
214};
215#endif
216
174#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 217#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
175static struct mtd_partition partition_info[] = { 218static struct mtd_partition partition_info[] = {
176 { 219 {
@@ -420,11 +463,7 @@ static struct mtd_partition bfin_spi_flash_partitions[] = {
420 .offset = 0, 463 .offset = 0,
421 .mask_flags = MTD_CAP_ROM 464 .mask_flags = MTD_CAP_ROM
422 }, { 465 }, {
423 .name = "kernel", 466 .name = "linux kernel",
424 .size = 0xe0000,
425 .offset = MTDPART_OFS_APPEND,
426 }, {
427 .name = "file system",
428 .size = MTDPART_SIZ_FULL, 467 .size = MTDPART_SIZ_FULL,
429 .offset = MTDPART_OFS_APPEND, 468 .offset = MTDPART_OFS_APPEND,
430 } 469 }
@@ -434,7 +473,7 @@ static struct flash_platform_data bfin_spi_flash_data = {
434 .name = "m25p80", 473 .name = "m25p80",
435 .parts = bfin_spi_flash_partitions, 474 .parts = bfin_spi_flash_partitions,
436 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions), 475 .nr_parts = ARRAY_SIZE(bfin_spi_flash_partitions),
437 .type = "m25p64", 476 .type = "m25p16",
438}; 477};
439 478
440/* SPI flash chip (m25p64) */ 479/* SPI flash chip (m25p64) */
@@ -755,6 +794,24 @@ static struct platform_device i2c_bfin_twi_device = {
755}; 794};
756#endif 795#endif
757 796
797#ifdef CONFIG_I2C_BOARDINFO
798static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
799#if defined(CONFIG_TWI_LCD) || defined(CONFIG_TWI_LCD_MODULE)
800 {
801 I2C_BOARD_INFO("pcf8574_lcd", 0x22),
802 .type = "pcf8574_lcd",
803 },
804#endif
805#if defined(CONFIG_TWI_KEYPAD) || defined(CONFIG_TWI_KEYPAD_MODULE)
806 {
807 I2C_BOARD_INFO("pcf8574_keypad", 0x27),
808 .type = "pcf8574_keypad",
809 .irq = IRQ_PF8,
810 },
811#endif
812};
813#endif
814
758#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE) 815#if defined(CONFIG_SERIAL_BFIN_SPORT) || defined(CONFIG_SERIAL_BFIN_SPORT_MODULE)
759static struct platform_device bfin_sport0_uart_device = { 816static struct platform_device bfin_sport0_uart_device = {
760 .name = "bfin-sport-uart", 817 .name = "bfin-sport-uart",
@@ -839,7 +896,32 @@ static struct platform_device bfin_gpios_device = {
839 .resource = &bfin_gpios_resources, 896 .resource = &bfin_gpios_resources,
840}; 897};
841 898
899static const unsigned int cclk_vlev_datasheet[] =
900{
901 VRPAIR(VLEV_100, 400000000),
902 VRPAIR(VLEV_105, 426000000),
903 VRPAIR(VLEV_110, 500000000),
904 VRPAIR(VLEV_115, 533000000),
905 VRPAIR(VLEV_120, 600000000),
906};
907
908static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
909 .tuple_tab = cclk_vlev_datasheet,
910 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
911 .vr_settling_time = 25 /* us */,
912};
913
914static struct platform_device bfin_dpmc = {
915 .name = "bfin dpmc",
916 .dev = {
917 .platform_data = &bfin_dmpc_vreg_data,
918 },
919};
920
842static struct platform_device *stamp_devices[] __initdata = { 921static struct platform_device *stamp_devices[] __initdata = {
922
923 &bfin_dpmc,
924
843#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE) 925#if defined(CONFIG_MTD_NAND_BF5XX) || defined(CONFIG_MTD_NAND_BF5XX_MODULE)
844 &bf5xx_nand_device, 926 &bf5xx_nand_device,
845#endif 927#endif
@@ -921,12 +1003,22 @@ static struct platform_device *stamp_devices[] __initdata = {
921 &bfin_device_gpiokeys, 1003 &bfin_device_gpiokeys,
922#endif 1004#endif
923 1005
1006#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
1007 &ezkit_flash_device,
1008#endif
1009
924 &bfin_gpios_device, 1010 &bfin_gpios_device,
925}; 1011};
926 1012
927static int __init stamp_init(void) 1013static int __init stamp_init(void)
928{ 1014{
929 printk(KERN_INFO "%s(): registering device resources\n", __func__); 1015 printk(KERN_INFO "%s(): registering device resources\n", __func__);
1016
1017#ifdef CONFIG_I2C_BOARDINFO
1018 i2c_register_board_info(0, bfin_i2c_board_info,
1019 ARRAY_SIZE(bfin_i2c_board_info));
1020#endif
1021
930 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices)); 1022 platform_add_devices(stamp_devices, ARRAY_SIZE(stamp_devices));
931#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE) 1023#if defined(CONFIG_SPI_BFIN) || defined(CONFIG_SPI_BFIN_MODULE)
932 spi_register_board_info(bfin_spi_board_info, 1024 spi_register_board_info(bfin_spi_board_info,
diff --git a/arch/blackfin/mach-bf533/boards/cm_bf533.c b/arch/blackfin/mach-bf533/boards/cm_bf533.c
index a03149c72681..ed2b0b8f5dc9 100644
--- a/arch/blackfin/mach-bf533/boards/cm_bf533.c
+++ b/arch/blackfin/mach-bf533/boards/cm_bf533.c
@@ -33,12 +33,15 @@
33#include <linux/mtd/partitions.h> 33#include <linux/mtd/partitions.h>
34#include <linux/spi/spi.h> 34#include <linux/spi/spi.h>
35#include <linux/spi/flash.h> 35#include <linux/spi/flash.h>
36#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
36#include <linux/usb/isp1362.h> 37#include <linux/usb/isp1362.h>
38#endif
37#include <linux/ata_platform.h> 39#include <linux/ata_platform.h>
38#include <linux/irq.h> 40#include <linux/irq.h>
39#include <asm/dma.h> 41#include <asm/dma.h>
40#include <asm/bfin5xx_spi.h> 42#include <asm/bfin5xx_spi.h>
41#include <asm/portmux.h> 43#include <asm/portmux.h>
44#include <asm/dpmc.h>
42 45
43/* 46/*
44 * Name the Board for the /proc/cpuinfo 47 * Name the Board for the /proc/cpuinfo
@@ -341,7 +344,37 @@ static struct platform_device bfin_pata_device = {
341}; 344};
342#endif 345#endif
343 346
347static const unsigned int cclk_vlev_datasheet[] =
348{
349 VRPAIR(VLEV_085, 250000000),
350 VRPAIR(VLEV_090, 376000000),
351 VRPAIR(VLEV_095, 426000000),
352 VRPAIR(VLEV_100, 426000000),
353 VRPAIR(VLEV_105, 476000000),
354 VRPAIR(VLEV_110, 476000000),
355 VRPAIR(VLEV_115, 476000000),
356 VRPAIR(VLEV_120, 600000000),
357 VRPAIR(VLEV_125, 600000000),
358 VRPAIR(VLEV_130, 600000000),
359};
360
361static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
362 .tuple_tab = cclk_vlev_datasheet,
363 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
364 .vr_settling_time = 25 /* us */,
365};
366
367static struct platform_device bfin_dpmc = {
368 .name = "bfin dpmc",
369 .dev = {
370 .platform_data = &bfin_dmpc_vreg_data,
371 },
372};
373
344static struct platform_device *cm_bf533_devices[] __initdata = { 374static struct platform_device *cm_bf533_devices[] __initdata = {
375
376 &bfin_dpmc,
377
345#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE) 378#if defined(CONFIG_SERIAL_BFIN) || defined(CONFIG_SERIAL_BFIN_MODULE)
346 &bfin_uart_device, 379 &bfin_uart_device,
347#endif 380#endif
diff --git a/arch/blackfin/mach-bf533/boards/ezkit.c b/arch/blackfin/mach-bf533/boards/ezkit.c
index 08a7943949ae..9d28415163ea 100644
--- a/arch/blackfin/mach-bf533/boards/ezkit.c
+++ b/arch/blackfin/mach-bf533/boards/ezkit.c
@@ -42,6 +42,7 @@
42#include <asm/dma.h> 42#include <asm/dma.h>
43#include <asm/bfin5xx_spi.h> 43#include <asm/bfin5xx_spi.h>
44#include <asm/portmux.h> 44#include <asm/portmux.h>
45#include <asm/dpmc.h>
45 46
46/* 47/*
47 * Name the Board for the /proc/cpuinfo 48 * Name the Board for the /proc/cpuinfo
@@ -350,7 +351,37 @@ static struct platform_device i2c_gpio_device = {
350}; 351};
351#endif 352#endif
352 353
354static const unsigned int cclk_vlev_datasheet[] =
355{
356 VRPAIR(VLEV_085, 250000000),
357 VRPAIR(VLEV_090, 376000000),
358 VRPAIR(VLEV_095, 426000000),
359 VRPAIR(VLEV_100, 426000000),
360 VRPAIR(VLEV_105, 476000000),
361 VRPAIR(VLEV_110, 476000000),
362 VRPAIR(VLEV_115, 476000000),
363 VRPAIR(VLEV_120, 600000000),
364 VRPAIR(VLEV_125, 600000000),
365 VRPAIR(VLEV_130, 600000000),
366};
367
368static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
369 .tuple_tab = cclk_vlev_datasheet,
370 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
371 .vr_settling_time = 25 /* us */,
372};
373
374static struct platform_device bfin_dpmc = {
375 .name = "bfin dpmc",
376 .dev = {
377 .platform_data = &bfin_dmpc_vreg_data,
378 },
379};
380
353static struct platform_device *ezkit_devices[] __initdata = { 381static struct platform_device *ezkit_devices[] __initdata = {
382
383 &bfin_dpmc,
384
354#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 385#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
355 &smc91x_device, 386 &smc91x_device,
356#endif 387#endif
diff --git a/arch/blackfin/mach-bf533/boards/stamp.c b/arch/blackfin/mach-bf533/boards/stamp.c
index 024f418ae543..7fd35fb32fd5 100644
--- a/arch/blackfin/mach-bf533/boards/stamp.c
+++ b/arch/blackfin/mach-bf533/boards/stamp.c
@@ -45,6 +45,7 @@
45#include <asm/bfin5xx_spi.h> 45#include <asm/bfin5xx_spi.h>
46#include <asm/reboot.h> 46#include <asm/reboot.h>
47#include <asm/portmux.h> 47#include <asm/portmux.h>
48#include <asm/dpmc.h>
48 49
49/* 50/*
50 * Name the Board for the /proc/cpuinfo 51 * Name the Board for the /proc/cpuinfo
@@ -516,7 +517,37 @@ static struct i2c_board_info __initdata bfin_i2c_board_info[] = {
516}; 517};
517#endif 518#endif
518 519
520static const unsigned int cclk_vlev_datasheet[] =
521{
522 VRPAIR(VLEV_085, 250000000),
523 VRPAIR(VLEV_090, 376000000),
524 VRPAIR(VLEV_095, 426000000),
525 VRPAIR(VLEV_100, 426000000),
526 VRPAIR(VLEV_105, 476000000),
527 VRPAIR(VLEV_110, 476000000),
528 VRPAIR(VLEV_115, 476000000),
529 VRPAIR(VLEV_120, 600000000),
530 VRPAIR(VLEV_125, 600000000),
531 VRPAIR(VLEV_130, 600000000),
532};
533
534static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
535 .tuple_tab = cclk_vlev_datasheet,
536 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
537 .vr_settling_time = 25 /* us */,
538};
539
540static struct platform_device bfin_dpmc = {
541 .name = "bfin dpmc",
542 .dev = {
543 .platform_data = &bfin_dmpc_vreg_data,
544 },
545};
546
519static struct platform_device *stamp_devices[] __initdata = { 547static struct platform_device *stamp_devices[] __initdata = {
548
549 &bfin_dpmc,
550
520#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 551#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
521 &rtc_device, 552 &rtc_device,
522#endif 553#endif
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537.c b/arch/blackfin/mach-bf537/boards/cm_bf537.c
index d8a23cd9b9ed..73f2142875e2 100644
--- a/arch/blackfin/mach-bf537/boards/cm_bf537.c
+++ b/arch/blackfin/mach-bf537/boards/cm_bf537.c
@@ -35,12 +35,15 @@
35#include <linux/mtd/partitions.h> 35#include <linux/mtd/partitions.h>
36#include <linux/spi/spi.h> 36#include <linux/spi/spi.h>
37#include <linux/spi/flash.h> 37#include <linux/spi/flash.h>
38#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
38#include <linux/usb/isp1362.h> 39#include <linux/usb/isp1362.h>
40#endif
39#include <linux/ata_platform.h> 41#include <linux/ata_platform.h>
40#include <linux/irq.h> 42#include <linux/irq.h>
41#include <asm/dma.h> 43#include <asm/dma.h>
42#include <asm/bfin5xx_spi.h> 44#include <asm/bfin5xx_spi.h>
43#include <asm/portmux.h> 45#include <asm/portmux.h>
46#include <asm/dpmc.h>
44 47
45/* 48/*
46 * Name the Board for the /proc/cpuinfo 49 * Name the Board for the /proc/cpuinfo
@@ -428,7 +431,37 @@ static struct platform_device bfin_pata_device = {
428}; 431};
429#endif 432#endif
430 433
434static const unsigned int cclk_vlev_datasheet[] =
435{
436 VRPAIR(VLEV_085, 250000000),
437 VRPAIR(VLEV_090, 376000000),
438 VRPAIR(VLEV_095, 426000000),
439 VRPAIR(VLEV_100, 426000000),
440 VRPAIR(VLEV_105, 476000000),
441 VRPAIR(VLEV_110, 476000000),
442 VRPAIR(VLEV_115, 476000000),
443 VRPAIR(VLEV_120, 500000000),
444 VRPAIR(VLEV_125, 533000000),
445 VRPAIR(VLEV_130, 600000000),
446};
447
448static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
449 .tuple_tab = cclk_vlev_datasheet,
450 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
451 .vr_settling_time = 25 /* us */,
452};
453
454static struct platform_device bfin_dpmc = {
455 .name = "bfin dpmc",
456 .dev = {
457 .platform_data = &bfin_dmpc_vreg_data,
458 },
459};
460
431static struct platform_device *cm_bf537_devices[] __initdata = { 461static struct platform_device *cm_bf537_devices[] __initdata = {
462
463 &bfin_dpmc,
464
432#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 465#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
433 &hitachi_fb_device, 466 &hitachi_fb_device,
434#endif 467#endif
diff --git a/arch/blackfin/mach-bf537/boards/stamp.c b/arch/blackfin/mach-bf537/boards/stamp.c
index d3727b7c2d7d..9a756d1f3d73 100644
--- a/arch/blackfin/mach-bf537/boards/stamp.c
+++ b/arch/blackfin/mach-bf537/boards/stamp.c
@@ -47,6 +47,7 @@
47#include <asm/bfin5xx_spi.h> 47#include <asm/bfin5xx_spi.h>
48#include <asm/reboot.h> 48#include <asm/reboot.h>
49#include <asm/portmux.h> 49#include <asm/portmux.h>
50#include <asm/dpmc.h>
50#include <linux/spi/ad7877.h> 51#include <linux/spi/ad7877.h>
51 52
52/* 53/*
@@ -817,7 +818,37 @@ static struct platform_device bfin_pata_device = {
817}; 818};
818#endif 819#endif
819 820
821static const unsigned int cclk_vlev_datasheet[] =
822{
823 VRPAIR(VLEV_085, 250000000),
824 VRPAIR(VLEV_090, 376000000),
825 VRPAIR(VLEV_095, 426000000),
826 VRPAIR(VLEV_100, 426000000),
827 VRPAIR(VLEV_105, 476000000),
828 VRPAIR(VLEV_110, 476000000),
829 VRPAIR(VLEV_115, 476000000),
830 VRPAIR(VLEV_120, 500000000),
831 VRPAIR(VLEV_125, 533000000),
832 VRPAIR(VLEV_130, 600000000),
833};
834
835static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
836 .tuple_tab = cclk_vlev_datasheet,
837 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
838 .vr_settling_time = 25 /* us */,
839};
840
841static struct platform_device bfin_dpmc = {
842 .name = "bfin dpmc",
843 .dev = {
844 .platform_data = &bfin_dmpc_vreg_data,
845 },
846};
847
820static struct platform_device *stamp_devices[] __initdata = { 848static struct platform_device *stamp_devices[] __initdata = {
849
850 &bfin_dpmc,
851
821#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE) 852#if defined(CONFIG_BFIN_CFPCMCIA) || defined(CONFIG_BFIN_CFPCMCIA_MODULE)
822 &bfin_pcmcia_cf_device, 853 &bfin_pcmcia_cf_device,
823#endif 854#endif
diff --git a/arch/blackfin/mach-bf548/boards/cm_bf548.c b/arch/blackfin/mach-bf548/boards/cm_bf548.c
index e3e8479fffb5..3b74f96d3590 100644
--- a/arch/blackfin/mach-bf548/boards/cm_bf548.c
+++ b/arch/blackfin/mach-bf548/boards/cm_bf548.c
@@ -36,7 +36,9 @@
36#include <linux/spi/flash.h> 36#include <linux/spi/flash.h>
37#include <linux/irq.h> 37#include <linux/irq.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
39#include <linux/usb/musb.h> 40#include <linux/usb/musb.h>
41#endif
40#include <asm/bfin5xx_spi.h> 42#include <asm/bfin5xx_spi.h>
41#include <asm/cplb.h> 43#include <asm/cplb.h>
42#include <asm/dma.h> 44#include <asm/dma.h>
@@ -44,6 +46,7 @@
44#include <asm/nand.h> 46#include <asm/nand.h>
45#include <asm/portmux.h> 47#include <asm/portmux.h>
46#include <asm/mach/bf54x_keys.h> 48#include <asm/mach/bf54x_keys.h>
49#include <asm/dpmc.h>
47#include <linux/input.h> 50#include <linux/input.h>
48#include <linux/spi/ad7877.h> 51#include <linux/spi/ad7877.h>
49 52
@@ -590,7 +593,38 @@ static struct platform_device bfin_device_gpiokeys = {
590}; 593};
591#endif 594#endif
592 595
596static const unsigned int cclk_vlev_datasheet[] =
597{
598/*
599 * Internal VLEV BF54XSBBC1533
600 ****temporarily using these values until data sheet is updated
601 */
602 VRPAIR(VLEV_085, 150000000),
603 VRPAIR(VLEV_090, 250000000),
604 VRPAIR(VLEV_110, 276000000),
605 VRPAIR(VLEV_115, 301000000),
606 VRPAIR(VLEV_120, 525000000),
607 VRPAIR(VLEV_125, 550000000),
608 VRPAIR(VLEV_130, 600000000),
609};
610
611static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
612 .tuple_tab = cclk_vlev_datasheet,
613 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
614 .vr_settling_time = 25 /* us */,
615};
616
617static struct platform_device bfin_dpmc = {
618 .name = "bfin dpmc",
619 .dev = {
620 .platform_data = &bfin_dmpc_vreg_data,
621 },
622};
623
593static struct platform_device *cm_bf548_devices[] __initdata = { 624static struct platform_device *cm_bf548_devices[] __initdata = {
625
626 &bfin_dpmc,
627
594#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 628#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
595 &rtc_device, 629 &rtc_device,
596#endif 630#endif
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c
index b00f68ac6bc9..d1682bb37509 100644
--- a/arch/blackfin/mach-bf548/boards/ezkit.c
+++ b/arch/blackfin/mach-bf548/boards/ezkit.c
@@ -46,6 +46,7 @@
46#include <asm/dma.h> 46#include <asm/dma.h>
47#include <asm/gpio.h> 47#include <asm/gpio.h>
48#include <asm/nand.h> 48#include <asm/nand.h>
49#include <asm/dpmc.h>
49#include <asm/portmux.h> 50#include <asm/portmux.h>
50#include <asm/mach/bf54x_keys.h> 51#include <asm/mach/bf54x_keys.h>
51#include <linux/input.h> 52#include <linux/input.h>
@@ -689,7 +690,38 @@ static struct platform_device bfin_gpios_device = {
689 .resource = &bfin_gpios_resources, 690 .resource = &bfin_gpios_resources,
690}; 691};
691 692
693static const unsigned int cclk_vlev_datasheet[] =
694{
695/*
696 * Internal VLEV BF54XSBBC1533
697 ****temporarily using these values until data sheet is updated
698 */
699 VRPAIR(VLEV_085, 150000000),
700 VRPAIR(VLEV_090, 250000000),
701 VRPAIR(VLEV_110, 276000000),
702 VRPAIR(VLEV_115, 301000000),
703 VRPAIR(VLEV_120, 525000000),
704 VRPAIR(VLEV_125, 550000000),
705 VRPAIR(VLEV_130, 600000000),
706};
707
708static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
709 .tuple_tab = cclk_vlev_datasheet,
710 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
711 .vr_settling_time = 25 /* us */,
712};
713
714static struct platform_device bfin_dpmc = {
715 .name = "bfin dpmc",
716 .dev = {
717 .platform_data = &bfin_dmpc_vreg_data,
718 },
719};
720
692static struct platform_device *ezkit_devices[] __initdata = { 721static struct platform_device *ezkit_devices[] __initdata = {
722
723 &bfin_dpmc,
724
693#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE) 725#if defined(CONFIG_RTC_DRV_BFIN) || defined(CONFIG_RTC_DRV_BFIN_MODULE)
694 &rtc_device, 726 &rtc_device,
695#endif 727#endif
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c
index 9fd580952fd8..466ef5929a25 100644
--- a/arch/blackfin/mach-bf561/boards/cm_bf561.c
+++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c
@@ -33,12 +33,15 @@
33#include <linux/mtd/partitions.h> 33#include <linux/mtd/partitions.h>
34#include <linux/spi/spi.h> 34#include <linux/spi/spi.h>
35#include <linux/spi/flash.h> 35#include <linux/spi/flash.h>
36#if defined(CONFIG_USB_ISP1362_HCD) || defined(CONFIG_USB_ISP1362_HCD_MODULE)
36#include <linux/usb/isp1362.h> 37#include <linux/usb/isp1362.h>
38#endif
37#include <linux/ata_platform.h> 39#include <linux/ata_platform.h>
38#include <linux/irq.h> 40#include <linux/irq.h>
39#include <asm/dma.h> 41#include <asm/dma.h>
40#include <asm/bfin5xx_spi.h> 42#include <asm/bfin5xx_spi.h>
41#include <asm/portmux.h> 43#include <asm/portmux.h>
44#include <asm/dpmc.h>
42 45
43/* 46/*
44 * Name the Board for the /proc/cpuinfo 47 * Name the Board for the /proc/cpuinfo
@@ -339,8 +342,37 @@ static struct platform_device bfin_pata_device = {
339}; 342};
340#endif 343#endif
341 344
345static const unsigned int cclk_vlev_datasheet[] =
346{
347 VRPAIR(VLEV_085, 250000000),
348 VRPAIR(VLEV_090, 300000000),
349 VRPAIR(VLEV_095, 313000000),
350 VRPAIR(VLEV_100, 350000000),
351 VRPAIR(VLEV_105, 400000000),
352 VRPAIR(VLEV_110, 444000000),
353 VRPAIR(VLEV_115, 450000000),
354 VRPAIR(VLEV_120, 475000000),
355 VRPAIR(VLEV_125, 500000000),
356 VRPAIR(VLEV_130, 600000000),
357};
358
359static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
360 .tuple_tab = cclk_vlev_datasheet,
361 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
362 .vr_settling_time = 25 /* us */,
363};
364
365static struct platform_device bfin_dpmc = {
366 .name = "bfin dpmc",
367 .dev = {
368 .platform_data = &bfin_dmpc_vreg_data,
369 },
370};
371
342static struct platform_device *cm_bf561_devices[] __initdata = { 372static struct platform_device *cm_bf561_devices[] __initdata = {
343 373
374 &bfin_dpmc,
375
344#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE) 376#if defined(CONFIG_FB_HITACHI_TX09) || defined(CONFIG_FB_HITACHI_TX09_MODULE)
345 &hitachi_fb_device, 377 &hitachi_fb_device,
346#endif 378#endif
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c
index 0d74b7d99209..61d8f7648b24 100644
--- a/arch/blackfin/mach-bf561/boards/ezkit.c
+++ b/arch/blackfin/mach-bf561/boards/ezkit.c
@@ -39,6 +39,7 @@
39#include <asm/dma.h> 39#include <asm/dma.h>
40#include <asm/bfin5xx_spi.h> 40#include <asm/bfin5xx_spi.h>
41#include <asm/portmux.h> 41#include <asm/portmux.h>
42#include <asm/dpmc.h>
42 43
43/* 44/*
44 * Name the Board for the /proc/cpuinfo 45 * Name the Board for the /proc/cpuinfo
@@ -443,7 +444,37 @@ static struct platform_device i2c_gpio_device = {
443}; 444};
444#endif 445#endif
445 446
447static const unsigned int cclk_vlev_datasheet[] =
448{
449 VRPAIR(VLEV_085, 250000000),
450 VRPAIR(VLEV_090, 300000000),
451 VRPAIR(VLEV_095, 313000000),
452 VRPAIR(VLEV_100, 350000000),
453 VRPAIR(VLEV_105, 400000000),
454 VRPAIR(VLEV_110, 444000000),
455 VRPAIR(VLEV_115, 450000000),
456 VRPAIR(VLEV_120, 475000000),
457 VRPAIR(VLEV_125, 500000000),
458 VRPAIR(VLEV_130, 600000000),
459};
460
461static struct bfin_dpmc_platform_data bfin_dmpc_vreg_data = {
462 .tuple_tab = cclk_vlev_datasheet,
463 .tabsize = ARRAY_SIZE(cclk_vlev_datasheet),
464 .vr_settling_time = 25 /* us */,
465};
466
467static struct platform_device bfin_dpmc = {
468 .name = "bfin dpmc",
469 .dev = {
470 .platform_data = &bfin_dmpc_vreg_data,
471 },
472};
473
446static struct platform_device *ezkit_devices[] __initdata = { 474static struct platform_device *ezkit_devices[] __initdata = {
475
476 &bfin_dpmc,
477
447#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE) 478#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
448 &smc91x_device, 479 &smc91x_device,
449#endif 480#endif
diff --git a/arch/blackfin/mach-common/Makefile b/arch/blackfin/mach-common/Makefile
index 393081e9b680..422bfee34adc 100644
--- a/arch/blackfin/mach-common/Makefile
+++ b/arch/blackfin/mach-common/Makefile
@@ -6,5 +6,6 @@ obj-y := \
6 cache.o cacheinit.o entry.o \ 6 cache.o cacheinit.o entry.o \
7 interrupt.o lock.o irqpanic.o arch_checks.o ints-priority.o 7 interrupt.o lock.o irqpanic.o arch_checks.o ints-priority.o
8 8
9obj-$(CONFIG_PM) += pm.o dpmc.o 9obj-$(CONFIG_PM) += pm.o dpmc_modes.o
10obj-$(CONFIG_CPU_FREQ) += cpufreq.o 10obj-$(CONFIG_CPU_FREQ) += cpufreq.o
11obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o
diff --git a/arch/blackfin/mach-common/cpufreq.c b/arch/blackfin/mach-common/cpufreq.c
index ed81e00d20e1..75cdad291e88 100644
--- a/arch/blackfin/mach-common/cpufreq.c
+++ b/arch/blackfin/mach-common/cpufreq.c
@@ -62,6 +62,14 @@ static struct bfin_dpm_state {
62 unsigned int tscale; /* change the divider on the core timer interrupt */ 62 unsigned int tscale; /* change the divider on the core timer interrupt */
63} dpm_state_table[3]; 63} dpm_state_table[3];
64 64
65/*
66 normalized to maximum frequncy offset for CYCLES,
67 used in time-ts cycles clock source, but could be used
68 somewhere also.
69 */
70unsigned long long __bfin_cycles_off;
71unsigned int __bfin_cycles_mod;
72
65/**************************************************************************/ 73/**************************************************************************/
66 74
67static unsigned int bfin_getfreq(unsigned int cpu) 75static unsigned int bfin_getfreq(unsigned int cpu)
@@ -80,6 +88,7 @@ static int bfin_target(struct cpufreq_policy *policy,
80 unsigned int index, plldiv, tscale; 88 unsigned int index, plldiv, tscale;
81 unsigned long flags, cclk_hz; 89 unsigned long flags, cclk_hz;
82 struct cpufreq_freqs freqs; 90 struct cpufreq_freqs freqs;
91 cycles_t cycles;
83 92
84 if (cpufreq_frequency_table_target(policy, bfin_freq_table, 93 if (cpufreq_frequency_table_target(policy, bfin_freq_table,
85 target_freq, relation, &index)) 94 target_freq, relation, &index))
@@ -101,8 +110,14 @@ static int bfin_target(struct cpufreq_policy *policy,
101 bfin_write_PLL_DIV(plldiv); 110 bfin_write_PLL_DIV(plldiv);
102 /* we have to adjust the core timer, because it is using cclk */ 111 /* we have to adjust the core timer, because it is using cclk */
103 bfin_write_TSCALE(tscale); 112 bfin_write_TSCALE(tscale);
113 cycles = get_cycles();
104 SSYNC(); 114 SSYNC();
115 cycles += 10; /* ~10 cycles we loose after get_cycles() */
116 __bfin_cycles_off += (cycles << __bfin_cycles_mod) - (cycles << index);
117 __bfin_cycles_mod = index;
105 local_irq_restore(flags); 118 local_irq_restore(flags);
119 /* TODO: just test case for cycles clock source, remove later */
120 pr_debug("cpufreq: done\n");
106 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); 121 cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE);
107 122
108 return 0; 123 return 0;
@@ -119,22 +134,13 @@ static int __init __bfin_cpu_init(struct cpufreq_policy *policy)
119 unsigned long cclk, sclk, csel, min_cclk; 134 unsigned long cclk, sclk, csel, min_cclk;
120 int index; 135 int index;
121 136
122#ifdef CONFIG_CYCLES_CLOCKSOURCE
123/*
124 * Clocksource CYCLES is still CONTINUOUS but not longer MONOTONIC in case we enable
125 * CPU frequency scaling, since CYCLES runs off Core Clock.
126 */
127 printk(KERN_WARNING "CPU frequency scaling not supported: Clocksource not suitable\n"
128 return -ENODEV;
129#endif
130
131 if (policy->cpu != 0) 137 if (policy->cpu != 0)
132 return -EINVAL; 138 return -EINVAL;
133 139
134 cclk = get_cclk(); 140 cclk = get_cclk();
135 sclk = get_sclk(); 141 sclk = get_sclk();
136 142
137#if ANOMALY_05000273 143#if ANOMALY_05000273 || (!defined(CONFIG_BF54x) && defined(CONFIG_BFIN_DCACHE))
138 min_cclk = sclk * 2; 144 min_cclk = sclk * 2;
139#else 145#else
140 min_cclk = sclk; 146 min_cclk = sclk;
diff --git a/arch/blackfin/mach-common/dpmc.c b/arch/blackfin/mach-common/dpmc.c
new file mode 100644
index 000000000000..02c7efd1bcf4
--- /dev/null
+++ b/arch/blackfin/mach-common/dpmc.c
@@ -0,0 +1,137 @@
1/*
2 * Copyright 2008 Analog Devices Inc.
3 *
4 * Licensed under the GPL-2 or later.
5 */
6
7#include <linux/cdev.h>
8#include <linux/device.h>
9#include <linux/errno.h>
10#include <linux/fs.h>
11#include <linux/kernel.h>
12#include <linux/module.h>
13#include <linux/platform_device.h>
14#include <linux/types.h>
15#include <linux/cpufreq.h>
16
17#include <asm/delay.h>
18#include <asm/dpmc.h>
19
20#define DRIVER_NAME "bfin dpmc"
21
22#define dprintk(msg...) \
23 cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, DRIVER_NAME, msg)
24
25struct bfin_dpmc_platform_data *pdata;
26
27/**
28 * bfin_set_vlev - Update VLEV field in VR_CTL Reg.
29 * Avoid BYPASS sequence
30 */
31static void bfin_set_vlev(unsigned int vlev)
32{
33 unsigned pll_lcnt;
34
35 pll_lcnt = bfin_read_PLL_LOCKCNT();
36
37 bfin_write_PLL_LOCKCNT(1);
38 bfin_write_VR_CTL((bfin_read_VR_CTL() & ~VLEV) | vlev);
39 bfin_write_PLL_LOCKCNT(pll_lcnt);
40}
41
42/**
43 * bfin_get_vlev - Get CPU specific VLEV from platform device data
44 */
45static unsigned int bfin_get_vlev(unsigned int freq)
46{
47 int i;
48
49 if (!pdata)
50 goto err_out;
51
52 freq >>= 16;
53
54 for (i = 0; i < pdata->tabsize; i++)
55 if (freq <= (pdata->tuple_tab[i] & 0xFFFF))
56 return pdata->tuple_tab[i] >> 16;
57
58err_out:
59 printk(KERN_WARNING "DPMC: No suitable CCLK VDDINT voltage pair found\n");
60 return VLEV_120;
61}
62
63#ifdef CONFIG_CPU_FREQ
64static int
65vreg_cpufreq_notifier(struct notifier_block *nb, unsigned long val, void *data)
66{
67 struct cpufreq_freqs *freq = data;
68
69 if (val == CPUFREQ_PRECHANGE && freq->old < freq->new) {
70 bfin_set_vlev(bfin_get_vlev(freq->new));
71 udelay(pdata->vr_settling_time); /* Wait until Volatge settled */
72
73 } else if (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)
74 bfin_set_vlev(bfin_get_vlev(freq->new));
75
76 return 0;
77}
78
79static struct notifier_block vreg_cpufreq_notifier_block = {
80 .notifier_call = vreg_cpufreq_notifier
81};
82#endif /* CONFIG_CPU_FREQ */
83
84/**
85 * bfin_dpmc_probe -
86 *
87 */
88static int __devinit bfin_dpmc_probe(struct platform_device *pdev)
89{
90 if (pdev->dev.platform_data)
91 pdata = pdev->dev.platform_data;
92 else
93 return -EINVAL;
94
95 return cpufreq_register_notifier(&vreg_cpufreq_notifier_block,
96 CPUFREQ_TRANSITION_NOTIFIER);
97}
98
99/**
100 * bfin_dpmc_remove -
101 */
102static int __devexit bfin_dpmc_remove(struct platform_device *pdev)
103{
104 pdata = NULL;
105 return cpufreq_unregister_notifier(&vreg_cpufreq_notifier_block,
106 CPUFREQ_TRANSITION_NOTIFIER);
107}
108
109struct platform_driver bfin_dpmc_device_driver = {
110 .probe = bfin_dpmc_probe,
111 .remove = __devexit_p(bfin_dpmc_remove),
112 .driver = {
113 .name = DRIVER_NAME,
114 }
115};
116
117/**
118 * bfin_dpmc_init - Init driver
119 */
120static int __init bfin_dpmc_init(void)
121{
122 return platform_driver_register(&bfin_dpmc_device_driver);
123}
124module_init(bfin_dpmc_init);
125
126/**
127 * bfin_dpmc_exit - break down driver
128 */
129static void __exit bfin_dpmc_exit(void)
130{
131 platform_driver_unregister(&bfin_dpmc_device_driver);
132}
133module_exit(bfin_dpmc_exit);
134
135MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>");
136MODULE_DESCRIPTION("cpu power management driver for Blackfin");
137MODULE_LICENSE("GPL");
diff --git a/arch/blackfin/mach-common/dpmc.S b/arch/blackfin/mach-common/dpmc_modes.S
index 9d45aa3265b1..b7981d31c392 100644
--- a/arch/blackfin/mach-common/dpmc.S
+++ b/arch/blackfin/mach-common/dpmc_modes.S
@@ -1,30 +1,7 @@
1/* 1/*
2 * File: arch/blackfin/mach-common/dpmc.S 2 * Copyright 2004-2008 Analog Devices Inc.
3 * Based on:
4 * Author: LG Soft India
5 * 3 *
6 * Created: ? 4 * Licensed under the GPL-2 or later.
7 * Description: Watchdog Timer APIs
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 5 */
29 6
30#include <linux/linkage.h> 7#include <linux/linkage.h>
diff --git a/arch/blackfin/mach-common/entry.S b/arch/blackfin/mach-common/entry.S
index f2fb87e9a46e..038f70e0be65 100644
--- a/arch/blackfin/mach-common/entry.S
+++ b/arch/blackfin/mach-common/entry.S
@@ -151,26 +151,62 @@ ENTRY(_ex_soft_bp)
151ENDPROC(_ex_soft_bp) 151ENDPROC(_ex_soft_bp)
152 152
153ENTRY(_ex_single_step) 153ENTRY(_ex_single_step)
154 /* If we just returned from an interrupt, the single step event is
155 for the RTI instruction. */
154 r7 = retx; 156 r7 = retx;
155 r6 = reti; 157 r6 = reti;
156 cc = r7 == r6; 158 cc = r7 == r6;
157 if cc jump _bfin_return_from_exception 159 if cc jump _bfin_return_from_exception;
158 r7 = syscfg;
159 bitclr (r7, 0);
160 syscfg = R7;
161 160
161 /* If we were in user mode, do the single step normally. */
162 p5.l = lo(IPEND); 162 p5.l = lo(IPEND);
163 p5.h = hi(IPEND); 163 p5.h = hi(IPEND);
164 r6 = [p5]; 164 r6 = [p5];
165 cc = bittst(r6, 5); 165 r7 = 0xffe0 (z);
166 if !cc jump _ex_trap_c; 166 r7 = r7 & r6;
167 p4.l = lo(EVT5); 167 cc = r7 == 0;
168 p4.h = hi(EVT5); 168 if !cc jump 1f;
169 r6.h = _exception_to_level5; 169
170 r6.l = _exception_to_level5; 170 /* Single stepping only a single instruction, so clear the trace
171 r7 = [p4]; 171 * bit here. */
172 cc = r6 == r7; 172 r7 = syscfg;
173 if !cc jump _ex_trap_c; 173 bitclr (r7, 0);
174 syscfg = R7;
175 jump _ex_trap_c;
176
1771:
178 /*
179 * We were in an interrupt handler. By convention, all of them save
180 * SYSCFG with their first instruction, so by checking whether our
181 * RETX points at the entry point, we can determine whether to allow
182 * a single step, or whether to clear SYSCFG.
183 *
184 * First, find out the interrupt level and the event vector for it.
185 */
186 p5.l = lo(EVT0);
187 p5.h = hi(EVT0);
188 p5 += -4;
1892:
190 r7 = rot r7 by -1;
191 p5 += 4;
192 if !cc jump 2b;
193
194 /* What we actually do is test for the _second_ instruction in the
195 * IRQ handler. That way, if there are insns following the restore
196 * of SYSCFG after leaving the handler, we will not turn off SYSCFG
197 * for them. */
198
199 r7 = [p5];
200 r7 += 2;
201 r6 = RETX;
202 cc = R7 == R6;
203 if !cc jump _bfin_return_from_exception;
204
205 r7 = syscfg;
206 bitclr (r7, 0);
207 syscfg = R7;
208
209 /* Fall through to _bfin_return_from_exception. */
174ENDPROC(_ex_single_step) 210ENDPROC(_ex_single_step)
175 211
176ENTRY(_bfin_return_from_exception) 212ENTRY(_bfin_return_from_exception)
@@ -234,20 +270,26 @@ ENTRY(_ex_trap_c)
234 p5.l = _saved_icplb_fault_addr; 270 p5.l = _saved_icplb_fault_addr;
235 [p5] = r7; 271 [p5] = r7;
236 272
237 p4.l = __retx; 273 p4.l = _excpt_saved_stuff;
238 p4.h = __retx; 274 p4.h = _excpt_saved_stuff;
275
239 r6 = retx; 276 r6 = retx;
240 [p4] = r6; 277 [p4] = r6;
241 p4.l = lo(SAFE_USER_INSTRUCTION); 278
242 p4.h = hi(SAFE_USER_INSTRUCTION); 279 r6 = SYSCFG;
243 retx = p4; 280 [p4 + 4] = r6;
281 BITCLR(r6, 0);
282 SYSCFG = r6;
244 283
245 /* Disable all interrupts, but make sure level 5 is enabled so 284 /* Disable all interrupts, but make sure level 5 is enabled so
246 * we can switch to that level. Save the old mask. */ 285 * we can switch to that level. Save the old mask. */
247 cli r6; 286 cli r6;
248 p4.l = _excpt_saved_imask; 287 [p4 + 8] = r6;
249 p4.h = _excpt_saved_imask; 288
250 [p4] = r6; 289 p4.l = lo(SAFE_USER_INSTRUCTION);
290 p4.h = hi(SAFE_USER_INSTRUCTION);
291 retx = p4;
292
251 r6 = 0x3f; 293 r6 = 0x3f;
252 sti r6; 294 sti r6;
253 295
@@ -295,6 +337,11 @@ ENTRY(_double_fault)
295 */ 337 */
296 SAVE_ALL_SYS 338 SAVE_ALL_SYS
297 339
340 /* The dumping functions expect the return address in the RETI
341 * slot. */
342 r6 = retx;
343 [sp + PT_PC] = r6;
344
298 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */ 345 r0 = sp; /* stack frame pt_regs pointer argument ==> r0 */
299 SP += -12; 346 SP += -12;
300 call _double_fault_c; 347 call _double_fault_c;
@@ -307,16 +354,17 @@ ENDPROC(_double_fault)
307ENTRY(_exception_to_level5) 354ENTRY(_exception_to_level5)
308 SAVE_ALL_SYS 355 SAVE_ALL_SYS
309 356
310 p4.l = __retx; 357 p4.l = _excpt_saved_stuff;
311 p4.h = __retx; 358 p4.h = _excpt_saved_stuff;
312 r6 = [p4]; 359 r6 = [p4];
313 [sp + PT_PC] = r6; 360 [sp + PT_PC] = r6;
314 361
362 r6 = [p4 + 4];
363 [sp + PT_SYSCFG] = r6;
364
315 /* Restore interrupt mask. We haven't pushed RETI, so this 365 /* Restore interrupt mask. We haven't pushed RETI, so this
316 * doesn't enable interrupts until we return from this handler. */ 366 * doesn't enable interrupts until we return from this handler. */
317 p4.l = _excpt_saved_imask; 367 r6 = [p4 + 8];
318 p4.h = _excpt_saved_imask;
319 r6 = [p4];
320 sti r6; 368 sti r6;
321 369
322 /* Restore the hardware error vector. */ 370 /* Restore the hardware error vector. */
@@ -1344,7 +1392,14 @@ ENTRY(_sys_call_table)
1344 .rept NR_syscalls-(.-_sys_call_table)/4 1392 .rept NR_syscalls-(.-_sys_call_table)/4
1345 .long _sys_ni_syscall 1393 .long _sys_ni_syscall
1346 .endr 1394 .endr
1347_excpt_saved_imask: 1395
1396 /*
1397 * Used to save the real RETX, IMASK and SYSCFG when temporarily
1398 * storing safe values across the transition from exception to IRQ5.
1399 */
1400_excpt_saved_stuff:
1401 .long 0;
1402 .long 0;
1348 .long 0; 1403 .long 0;
1349 1404
1350_exception_stack: 1405_exception_stack:
@@ -1358,7 +1413,3 @@ _exception_stack_top:
1358_last_cplb_fault_retx: 1413_last_cplb_fault_retx:
1359 .long 0; 1414 .long 0;
1360#endif 1415#endif
1361 /* Used to save the real RETX when temporarily storing a safe
1362 * return address. */
1363__retx:
1364 .long 0;
diff --git a/arch/cris/kernel/sys_cris.c b/arch/cris/kernel/sys_cris.c
index 8b9984197edc..a79fbd87021b 100644
--- a/arch/cris/kernel/sys_cris.c
+++ b/arch/cris/kernel/sys_cris.c
@@ -27,25 +27,6 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/segment.h> 28#include <asm/segment.h>
29 29
30/*
31 * sys_pipe() is the normal C calling standard for creating
32 * a pipe. It's not the way Unix traditionally does this, though.
33 */
34asmlinkage int sys_pipe(unsigned long __user * fildes)
35{
36 int fd[2];
37 int error;
38
39 lock_kernel();
40 error = do_pipe(fd);
41 unlock_kernel();
42 if (!error) {
43 if (copy_to_user(fildes, fd, 2*sizeof(int)))
44 error = -EFAULT;
45 }
46 return error;
47}
48
49/* common code for old and new mmaps */ 30/* common code for old and new mmaps */
50static inline long 31static inline long
51do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 32do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index 6d7a80fdad48..305ac852bbed 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -76,26 +76,6 @@ asmlinkage int sys_tas(int __user *addr)
76 return oldval; 76 return oldval;
77} 77}
78 78
79/*
80 * sys_pipe() is the normal C calling standard for creating
81 * a pipe. It's not the way Unix traditionally does this, though.
82 */
83asmlinkage int
84sys_pipe(unsigned long r0, unsigned long r1, unsigned long r2,
85 unsigned long r3, unsigned long r4, unsigned long r5,
86 unsigned long r6, struct pt_regs regs)
87{
88 int fd[2];
89 int error;
90
91 error = do_pipe(fd);
92 if (!error) {
93 if (copy_to_user((void __user *)r0, fd, 2*sizeof(int)))
94 error = -EFAULT;
95 }
96 return error;
97}
98
99asmlinkage long sys_mmap2(unsigned long addr, unsigned long len, 79asmlinkage long sys_mmap2(unsigned long addr, unsigned long len,
100 unsigned long prot, unsigned long flags, 80 unsigned long prot, unsigned long flags,
101 unsigned long fd, unsigned long pgoff) 81 unsigned long fd, unsigned long pgoff)
diff --git a/arch/m68k/kernel/traps.c b/arch/m68k/kernel/traps.c
index fd4858e2dd63..75b8340b254b 100644
--- a/arch/m68k/kernel/traps.c
+++ b/arch/m68k/kernel/traps.c
@@ -468,15 +468,26 @@ static inline void access_error040(struct frame *fp)
468 * (if do_page_fault didn't fix the mapping, 468 * (if do_page_fault didn't fix the mapping,
469 * the writeback won't do good) 469 * the writeback won't do good)
470 */ 470 */
471disable_wb:
471#ifdef DEBUG 472#ifdef DEBUG
472 printk(".. disabling wb2\n"); 473 printk(".. disabling wb2\n");
473#endif 474#endif
474 if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr) 475 if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
475 fp->un.fmt7.wb2s &= ~WBV_040; 476 fp->un.fmt7.wb2s &= ~WBV_040;
477 if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr)
478 fp->un.fmt7.wb3s &= ~WBV_040;
476 } 479 }
477 } else if (send_fault_sig(&fp->ptregs) > 0) { 480 } else {
478 printk("68040 access error, ssw=%x\n", ssw); 481 /* In case of a bus error we either kill the process or expect
479 trap_c(fp); 482 * the kernel to catch the fault, which then is also responsible
483 * for cleaning up the mess.
484 */
485 current->thread.signo = SIGBUS;
486 current->thread.faddr = fp->un.fmt7.faddr;
487 if (send_fault_sig(&fp->ptregs) >= 0)
488 printk("68040 bus error (ssw=%x, faddr=%lx)\n", ssw,
489 fp->un.fmt7.faddr);
490 goto disable_wb;
480 } 491 }
481 492
482 do_040writebacks(fp); 493 do_040writebacks(fp);
diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
index 735a49b4b936..ad3e3bacae39 100644
--- a/arch/m68k/mac/config.c
+++ b/arch/m68k/mac/config.c
@@ -48,9 +48,6 @@
48struct mac_booter_data mac_bi_data; 48struct mac_booter_data mac_bi_data;
49int mac_bisize = sizeof mac_bi_data; 49int mac_bisize = sizeof mac_bi_data;
50 50
51struct mac_hw_present mac_hw_present;
52EXPORT_SYMBOL(mac_hw_present);
53
54/* New m68k bootinfo stuff and videobase */ 51/* New m68k bootinfo stuff and videobase */
55 52
56extern int m68k_num_memory; 53extern int m68k_num_memory;
@@ -817,27 +814,6 @@ void __init mac_identify(void)
817 m68k_ramdisk.addr, m68k_ramdisk.size); 814 m68k_ramdisk.addr, m68k_ramdisk.size);
818#endif 815#endif
819 816
820 /*
821 * TODO: set the various fields in macintosh_config->hw_present here!
822 */
823 switch (macintosh_config->scsi_type) {
824 case MAC_SCSI_OLD:
825 MACHW_SET(MAC_SCSI_80);
826 break;
827 case MAC_SCSI_QUADRA:
828 case MAC_SCSI_QUADRA2:
829 case MAC_SCSI_QUADRA3:
830 MACHW_SET(MAC_SCSI_96);
831 if ((macintosh_config->ident == MAC_MODEL_Q900) ||
832 (macintosh_config->ident == MAC_MODEL_Q950))
833 MACHW_SET(MAC_SCSI_96_2);
834 break;
835 default:
836 printk(KERN_WARNING "config.c: wtf: unknown scsi, using 53c80\n");
837 MACHW_SET(MAC_SCSI_80);
838 break;
839 }
840
841 iop_init(); 817 iop_init();
842 via_init(); 818 via_init();
843 oss_init(); 819 oss_init();
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index 07eb4c4bab82..8e8441587c22 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -671,6 +671,9 @@ config ROMKERNEL
671 671
672endchoice 672endchoice
673 673
674if COLDFIRE
675source "kernel/Kconfig.preempt"
676endif
674source "mm/Kconfig" 677source "mm/Kconfig"
675 678
676endmenu 679endmenu
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 5592e0bf951f..93e69236ed6f 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -114,6 +114,16 @@ SECTIONS {
114 *(__kcrctab_gpl) 114 *(__kcrctab_gpl)
115 __stop___kcrctab_gpl = .; 115 __stop___kcrctab_gpl = .;
116 116
117 /* Kernel symbol table: Normal unused symbols */
118 __start___kcrctab_unused = .;
119 *(__kcrctab_unused)
120 __stop___kcrctab_unused = .;
121
122 /* Kernel symbol table: GPL-only unused symbols */
123 __start___kcrctab_unused_gpl = .;
124 *(__kcrctab_unused_gpl)
125 __stop___kcrctab_unused_gpl = .;
126
117 /* Kernel symbol table: GPL-future symbols */ 127 /* Kernel symbol table: GPL-future symbols */
118 __start___kcrctab_gpl_future = .; 128 __start___kcrctab_gpl_future = .;
119 *(__kcrctab_gpl_future) 129 *(__kcrctab_gpl_future)
diff --git a/arch/mips/au1000/common/Makefile b/arch/mips/au1000/common/Makefile
index 90e2d7a46e8e..dd0e19dacfcf 100644
--- a/arch/mips/au1000/common/Makefile
+++ b/arch/mips/au1000/common/Makefile
@@ -1,9 +1,8 @@
1# 1#
2# Copyright 2000 MontaVista Software Inc. 2# Copyright 2000, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# 4#
6# Makefile for the Alchemy Au1000 CPU, generic files. 5# Makefile for the Alchemy Au1xx0 CPUs, generic files.
7# 6#
8 7
9obj-y += prom.o irq.o puts.o time.o reset.o \ 8obj-y += prom.o irq.o puts.o time.o reset.o \
diff --git a/arch/mips/au1000/common/au1xxx_irqmap.c b/arch/mips/au1000/common/au1xxx_irqmap.c
index 37a10a01de9d..c7ca1596394c 100644
--- a/arch/mips/au1000/common/au1xxx_irqmap.c
+++ b/arch/mips/au1000/common/au1xxx_irqmap.c
@@ -40,20 +40,20 @@
40struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = { 40struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
41 41
42#if defined(CONFIG_SOC_AU1000) 42#if defined(CONFIG_SOC_AU1000)
43 { AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 43 { AU1000_UART0_INT, INTC_INT_HIGH_LEVEL, 0 },
44 { AU1000_UART1_INT, INTC_INT_HIGH_LEVEL, 0}, 44 { AU1000_UART1_INT, INTC_INT_HIGH_LEVEL, 0 },
45 { AU1000_UART2_INT, INTC_INT_HIGH_LEVEL, 0}, 45 { AU1000_UART2_INT, INTC_INT_HIGH_LEVEL, 0 },
46 { AU1000_UART3_INT, INTC_INT_HIGH_LEVEL, 0}, 46 { AU1000_UART3_INT, INTC_INT_HIGH_LEVEL, 0 },
47 { AU1000_SSI0_INT, INTC_INT_HIGH_LEVEL, 0}, 47 { AU1000_SSI0_INT, INTC_INT_HIGH_LEVEL, 0 },
48 { AU1000_SSI1_INT, INTC_INT_HIGH_LEVEL, 0}, 48 { AU1000_SSI1_INT, INTC_INT_HIGH_LEVEL, 0 },
49 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0}, 49 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0 },
50 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0}, 50 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0 },
51 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0}, 51 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0 },
52 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0}, 52 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0 },
53 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0}, 53 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0 },
54 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0}, 54 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0 },
55 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0}, 55 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0 },
56 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0}, 56 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0 },
57 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, 57 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
58 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 58 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
59 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 59 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
@@ -62,32 +62,32 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
62 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 62 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
63 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 63 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
64 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, 64 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
65 { AU1000_IRDA_TX_INT, INTC_INT_HIGH_LEVEL, 0}, 65 { AU1000_IRDA_TX_INT, INTC_INT_HIGH_LEVEL, 0 },
66 { AU1000_IRDA_RX_INT, INTC_INT_HIGH_LEVEL, 0}, 66 { AU1000_IRDA_RX_INT, INTC_INT_HIGH_LEVEL, 0 },
67 { AU1000_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 }, 67 { AU1000_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 },
68 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 }, 68 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
69 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 }, 69 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
70 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 }, 70 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 },
71 { AU1000_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 71 { AU1000_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
72 { AU1000_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 72 { AU1000_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
73 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 }, 73 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 },
74 74
75#elif defined(CONFIG_SOC_AU1500) 75#elif defined(CONFIG_SOC_AU1500)
76 76
77 { AU1500_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 77 { AU1500_UART0_INT, INTC_INT_HIGH_LEVEL, 0 },
78 { AU1000_PCI_INTA, INTC_INT_LOW_LEVEL, 0 }, 78 { AU1000_PCI_INTA, INTC_INT_LOW_LEVEL, 0 },
79 { AU1000_PCI_INTB, INTC_INT_LOW_LEVEL, 0 }, 79 { AU1000_PCI_INTB, INTC_INT_LOW_LEVEL, 0 },
80 { AU1500_UART3_INT, INTC_INT_HIGH_LEVEL, 0}, 80 { AU1500_UART3_INT, INTC_INT_HIGH_LEVEL, 0 },
81 { AU1000_PCI_INTC, INTC_INT_LOW_LEVEL, 0 }, 81 { AU1000_PCI_INTC, INTC_INT_LOW_LEVEL, 0 },
82 { AU1000_PCI_INTD, INTC_INT_LOW_LEVEL, 0 }, 82 { AU1000_PCI_INTD, INTC_INT_LOW_LEVEL, 0 },
83 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0}, 83 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0 },
84 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0}, 84 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0 },
85 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0}, 85 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0 },
86 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0}, 86 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0 },
87 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0}, 87 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0 },
88 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0}, 88 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0 },
89 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0}, 89 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0 },
90 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0}, 90 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0 },
91 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, 91 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
92 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 92 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
93 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 93 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
@@ -100,26 +100,26 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
100 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 }, 100 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
101 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 }, 101 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
102 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 }, 102 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 },
103 { AU1500_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 103 { AU1500_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
104 { AU1500_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 104 { AU1500_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
105 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 }, 105 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 },
106 106
107#elif defined(CONFIG_SOC_AU1100) 107#elif defined(CONFIG_SOC_AU1100)
108 108
109 { AU1100_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 109 { AU1100_UART0_INT, INTC_INT_HIGH_LEVEL, 0 },
110 { AU1100_UART1_INT, INTC_INT_HIGH_LEVEL, 0}, 110 { AU1100_UART1_INT, INTC_INT_HIGH_LEVEL, 0 },
111 { AU1100_SD_INT, INTC_INT_HIGH_LEVEL, 0}, 111 { AU1100_SD_INT, INTC_INT_HIGH_LEVEL, 0 },
112 { AU1100_UART3_INT, INTC_INT_HIGH_LEVEL, 0}, 112 { AU1100_UART3_INT, INTC_INT_HIGH_LEVEL, 0 },
113 { AU1000_SSI0_INT, INTC_INT_HIGH_LEVEL, 0}, 113 { AU1000_SSI0_INT, INTC_INT_HIGH_LEVEL, 0 },
114 { AU1000_SSI1_INT, INTC_INT_HIGH_LEVEL, 0}, 114 { AU1000_SSI1_INT, INTC_INT_HIGH_LEVEL, 0 },
115 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0}, 115 { AU1000_DMA_INT_BASE, INTC_INT_HIGH_LEVEL, 0 },
116 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0}, 116 { AU1000_DMA_INT_BASE+1, INTC_INT_HIGH_LEVEL, 0 },
117 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0}, 117 { AU1000_DMA_INT_BASE+2, INTC_INT_HIGH_LEVEL, 0 },
118 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0}, 118 { AU1000_DMA_INT_BASE+3, INTC_INT_HIGH_LEVEL, 0 },
119 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0}, 119 { AU1000_DMA_INT_BASE+4, INTC_INT_HIGH_LEVEL, 0 },
120 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0}, 120 { AU1000_DMA_INT_BASE+5, INTC_INT_HIGH_LEVEL, 0 },
121 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0}, 121 { AU1000_DMA_INT_BASE+6, INTC_INT_HIGH_LEVEL, 0 },
122 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0}, 122 { AU1000_DMA_INT_BASE+7, INTC_INT_HIGH_LEVEL, 0 },
123 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, 123 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
124 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 124 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
125 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 125 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
@@ -128,33 +128,33 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
128 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 128 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
129 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 129 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
130 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, 130 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
131 { AU1000_IRDA_TX_INT, INTC_INT_HIGH_LEVEL, 0}, 131 { AU1000_IRDA_TX_INT, INTC_INT_HIGH_LEVEL, 0 },
132 { AU1000_IRDA_RX_INT, INTC_INT_HIGH_LEVEL, 0}, 132 { AU1000_IRDA_RX_INT, INTC_INT_HIGH_LEVEL, 0 },
133 { AU1000_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 }, 133 { AU1000_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 },
134 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 }, 134 { AU1000_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
135 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 }, 135 { AU1000_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
136 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 }, 136 { AU1000_ACSYNC_INT, INTC_INT_RISE_EDGE, 0 },
137 { AU1100_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 137 { AU1100_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
138 /*{ AU1000_GPIO215_208_INT, INTC_INT_HIGH_LEVEL, 0},*/ 138 /* { AU1000_GPIO215_208_INT, INTC_INT_HIGH_LEVEL, 0 }, */
139 { AU1100_LCD_INT, INTC_INT_HIGH_LEVEL, 0}, 139 { AU1100_LCD_INT, INTC_INT_HIGH_LEVEL, 0 },
140 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 }, 140 { AU1000_AC97C_INT, INTC_INT_RISE_EDGE, 0 },
141 141
142#elif defined(CONFIG_SOC_AU1550) 142#elif defined(CONFIG_SOC_AU1550)
143 143
144 { AU1550_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 144 { AU1550_UART0_INT, INTC_INT_HIGH_LEVEL, 0 },
145 { AU1550_PCI_INTA, INTC_INT_LOW_LEVEL, 0 }, 145 { AU1550_PCI_INTA, INTC_INT_LOW_LEVEL, 0 },
146 { AU1550_PCI_INTB, INTC_INT_LOW_LEVEL, 0 }, 146 { AU1550_PCI_INTB, INTC_INT_LOW_LEVEL, 0 },
147 { AU1550_DDMA_INT, INTC_INT_HIGH_LEVEL, 0}, 147 { AU1550_DDMA_INT, INTC_INT_HIGH_LEVEL, 0 },
148 { AU1550_CRYPTO_INT, INTC_INT_HIGH_LEVEL, 0}, 148 { AU1550_CRYPTO_INT, INTC_INT_HIGH_LEVEL, 0 },
149 { AU1550_PCI_INTC, INTC_INT_LOW_LEVEL, 0 }, 149 { AU1550_PCI_INTC, INTC_INT_LOW_LEVEL, 0 },
150 { AU1550_PCI_INTD, INTC_INT_LOW_LEVEL, 0 }, 150 { AU1550_PCI_INTD, INTC_INT_LOW_LEVEL, 0 },
151 { AU1550_PCI_RST_INT, INTC_INT_LOW_LEVEL, 0 }, 151 { AU1550_PCI_RST_INT, INTC_INT_LOW_LEVEL, 0 },
152 { AU1550_UART1_INT, INTC_INT_HIGH_LEVEL, 0}, 152 { AU1550_UART1_INT, INTC_INT_HIGH_LEVEL, 0 },
153 { AU1550_UART3_INT, INTC_INT_HIGH_LEVEL, 0}, 153 { AU1550_UART3_INT, INTC_INT_HIGH_LEVEL, 0 },
154 { AU1550_PSC0_INT, INTC_INT_HIGH_LEVEL, 0}, 154 { AU1550_PSC0_INT, INTC_INT_HIGH_LEVEL, 0 },
155 { AU1550_PSC1_INT, INTC_INT_HIGH_LEVEL, 0}, 155 { AU1550_PSC1_INT, INTC_INT_HIGH_LEVEL, 0 },
156 { AU1550_PSC2_INT, INTC_INT_HIGH_LEVEL, 0}, 156 { AU1550_PSC2_INT, INTC_INT_HIGH_LEVEL, 0 },
157 { AU1550_PSC3_INT, INTC_INT_HIGH_LEVEL, 0}, 157 { AU1550_PSC3_INT, INTC_INT_HIGH_LEVEL, 0 },
158 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, 158 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
159 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 159 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
160 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 160 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
@@ -163,26 +163,26 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
163 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 163 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
164 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 164 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
165 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, 165 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
166 { AU1550_NAND_INT, INTC_INT_RISE_EDGE, 0}, 166 { AU1550_NAND_INT, INTC_INT_RISE_EDGE, 0 },
167 { AU1550_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 }, 167 { AU1550_USB_DEV_REQ_INT, INTC_INT_HIGH_LEVEL, 0 },
168 { AU1550_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 }, 168 { AU1550_USB_DEV_SUS_INT, INTC_INT_RISE_EDGE, 0 },
169 { AU1550_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 }, 169 { AU1550_USB_HOST_INT, INTC_INT_LOW_LEVEL, 0 },
170 { AU1550_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 170 { AU1550_MAC0_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
171 { AU1550_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0}, 171 { AU1550_MAC1_DMA_INT, INTC_INT_HIGH_LEVEL, 0 },
172 172
173#elif defined(CONFIG_SOC_AU1200) 173#elif defined(CONFIG_SOC_AU1200)
174 174
175 { AU1200_UART0_INT, INTC_INT_HIGH_LEVEL, 0}, 175 { AU1200_UART0_INT, INTC_INT_HIGH_LEVEL, 0 },
176 { AU1200_SWT_INT, INTC_INT_RISE_EDGE, 0 }, 176 { AU1200_SWT_INT, INTC_INT_RISE_EDGE, 0 },
177 { AU1200_SD_INT, INTC_INT_HIGH_LEVEL, 0}, 177 { AU1200_SD_INT, INTC_INT_HIGH_LEVEL, 0 },
178 { AU1200_DDMA_INT, INTC_INT_HIGH_LEVEL, 0}, 178 { AU1200_DDMA_INT, INTC_INT_HIGH_LEVEL, 0 },
179 { AU1200_MAE_BE_INT, INTC_INT_HIGH_LEVEL, 0 }, 179 { AU1200_MAE_BE_INT, INTC_INT_HIGH_LEVEL, 0 },
180 { AU1200_UART1_INT, INTC_INT_HIGH_LEVEL, 0}, 180 { AU1200_UART1_INT, INTC_INT_HIGH_LEVEL, 0 },
181 { AU1200_MAE_FE_INT, INTC_INT_HIGH_LEVEL, 0 }, 181 { AU1200_MAE_FE_INT, INTC_INT_HIGH_LEVEL, 0 },
182 { AU1200_PSC0_INT, INTC_INT_HIGH_LEVEL, 0}, 182 { AU1200_PSC0_INT, INTC_INT_HIGH_LEVEL, 0 },
183 { AU1200_PSC1_INT, INTC_INT_HIGH_LEVEL, 0}, 183 { AU1200_PSC1_INT, INTC_INT_HIGH_LEVEL, 0 },
184 { AU1200_AES_INT, INTC_INT_HIGH_LEVEL, 0}, 184 { AU1200_AES_INT, INTC_INT_HIGH_LEVEL, 0 },
185 { AU1200_CAMERA_INT, INTC_INT_HIGH_LEVEL, 0}, 185 { AU1200_CAMERA_INT, INTC_INT_HIGH_LEVEL, 0 },
186 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 }, 186 { AU1000_TOY_INT, INTC_INT_RISE_EDGE, 0 },
187 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 187 { AU1000_TOY_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
188 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 188 { AU1000_TOY_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
@@ -191,10 +191,10 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
191 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 }, 191 { AU1000_RTC_MATCH0_INT, INTC_INT_RISE_EDGE, 0 },
192 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 }, 192 { AU1000_RTC_MATCH1_INT, INTC_INT_RISE_EDGE, 0 },
193 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 }, 193 { AU1000_RTC_MATCH2_INT, INTC_INT_RISE_EDGE, 0 },
194 { AU1200_NAND_INT, INTC_INT_RISE_EDGE, 0}, 194 { AU1200_NAND_INT, INTC_INT_RISE_EDGE, 0 },
195 { AU1200_USB_INT, INTC_INT_HIGH_LEVEL, 0 }, 195 { AU1200_USB_INT, INTC_INT_HIGH_LEVEL, 0 },
196 { AU1200_LCD_INT, INTC_INT_HIGH_LEVEL, 0}, 196 { AU1200_LCD_INT, INTC_INT_HIGH_LEVEL, 0 },
197 { AU1200_MAE_BOTH_INT, INTC_INT_HIGH_LEVEL, 0}, 197 { AU1200_MAE_BOTH_INT, INTC_INT_HIGH_LEVEL, 0 },
198 198
199#else 199#else
200#error "Error: Unknown Alchemy SOC" 200#error "Error: Unknown Alchemy SOC"
@@ -203,4 +203,3 @@ struct au1xxx_irqmap __initdata au1xxx_ic0_map[] = {
203}; 203};
204 204
205int __initdata au1xxx_ic0_nr_irqs = ARRAY_SIZE(au1xxx_ic0_map); 205int __initdata au1xxx_ic0_nr_irqs = ARRAY_SIZE(au1xxx_ic0_map);
206
diff --git a/arch/mips/au1000/common/clocks.c b/arch/mips/au1000/common/clocks.c
index 3ce6cace0eb0..46f8ee0e2657 100644
--- a/arch/mips/au1000/common/clocks.c
+++ b/arch/mips/au1000/common/clocks.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Simple Au1000 clocks routines. 3 * Simple Au1xx0 clocks routines.
4 * 4 *
5 * Copyright 2001 MontaVista Software Inc. 5 * Copyright 2001, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
@@ -30,8 +29,8 @@
30#include <linux/module.h> 29#include <linux/module.h>
31#include <asm/mach-au1x00/au1000.h> 30#include <asm/mach-au1x00/au1000.h>
32 31
33static unsigned int au1x00_clock; // Hz 32static unsigned int au1x00_clock; /* Hz */
34static unsigned int lcd_clock; // KHz 33static unsigned int lcd_clock; /* KHz */
35static unsigned long uart_baud_base; 34static unsigned long uart_baud_base;
36 35
37/* 36/*
@@ -47,8 +46,6 @@ unsigned int get_au1x00_speed(void)
47 return au1x00_clock; 46 return au1x00_clock;
48} 47}
49 48
50
51
52/* 49/*
53 * The UART baud base is not known at compile time ... if 50 * The UART baud base is not known at compile time ... if
54 * we want to be able to use the same code on different 51 * we want to be able to use the same code on different
@@ -73,24 +70,23 @@ void set_au1x00_uart_baud_base(unsigned long new_baud_base)
73void set_au1x00_lcd_clock(void) 70void set_au1x00_lcd_clock(void)
74{ 71{
75 unsigned int static_cfg0; 72 unsigned int static_cfg0;
76 unsigned int sys_busclk = 73 unsigned int sys_busclk = (get_au1x00_speed() / 1000) /
77 (get_au1x00_speed()/1000) / 74 ((int)(au_readl(SYS_POWERCTRL) & 0x03) + 2);
78 ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2);
79 75
80 static_cfg0 = au_readl(MEM_STCFG0); 76 static_cfg0 = au_readl(MEM_STCFG0);
81 77
82 if (static_cfg0 & (1<<11)) 78 if (static_cfg0 & (1 << 11))
83 lcd_clock = sys_busclk / 5; /* note: BCLK switching fails with D5 */ 79 lcd_clock = sys_busclk / 5; /* note: BCLK switching fails with D5 */
84 else 80 else
85 lcd_clock = sys_busclk / 4; 81 lcd_clock = sys_busclk / 4;
86 82
87 if (lcd_clock > 50000) /* Epson MAX */ 83 if (lcd_clock > 50000) /* Epson MAX */
88 printk("warning: LCD clock too high (%d KHz)\n", lcd_clock); 84 printk(KERN_WARNING "warning: LCD clock too high (%u KHz)\n",
85 lcd_clock);
89} 86}
90 87
91unsigned int get_au1x00_lcd_clock(void) 88unsigned int get_au1x00_lcd_clock(void)
92{ 89{
93 return lcd_clock; 90 return lcd_clock;
94} 91}
95
96EXPORT_SYMBOL(get_au1x00_lcd_clock); 92EXPORT_SYMBOL(get_au1x00_lcd_clock);
diff --git a/arch/mips/au1000/common/cputable.c b/arch/mips/au1000/common/cputable.c
index 8c93a05d7382..ba6430bc2d03 100644
--- a/arch/mips/au1000/common/cputable.c
+++ b/arch/mips/au1000/common/cputable.c
@@ -14,7 +14,7 @@
14 14
15#include <asm/mach-au1x00/au1000.h> 15#include <asm/mach-au1x00/au1000.h>
16 16
17struct cpu_spec* cur_cpu_spec[NR_CPUS]; 17struct cpu_spec *cur_cpu_spec[NR_CPUS];
18 18
19/* With some thought, we can probably use the mask to reduce the 19/* With some thought, we can probably use the mask to reduce the
20 * size of the table. 20 * size of the table.
@@ -39,8 +39,7 @@ struct cpu_spec cpu_specs[] = {
39 { 0x00000000, 0x00000000, "Unknown Au1xxx", 1, 0, 0 } 39 { 0x00000000, 0x00000000, "Unknown Au1xxx", 1, 0, 0 }
40}; 40};
41 41
42void 42void set_cpuspec(void)
43set_cpuspec(void)
44{ 43{
45 struct cpu_spec *sp; 44 struct cpu_spec *sp;
46 u32 prid; 45 u32 prid;
diff --git a/arch/mips/au1000/common/dbdma.c b/arch/mips/au1000/common/dbdma.c
index 53377dfc0640..42d555236de1 100644
--- a/arch/mips/au1000/common/dbdma.c
+++ b/arch/mips/au1000/common/dbdma.c
@@ -53,12 +53,11 @@
53 */ 53 */
54static DEFINE_SPINLOCK(au1xxx_dbdma_spin_lock); 54static DEFINE_SPINLOCK(au1xxx_dbdma_spin_lock);
55 55
56/* I couldn't find a macro that did this...... 56/* I couldn't find a macro that did this... */
57*/
58#define ALIGN_ADDR(x, a) ((((u32)(x)) + (a-1)) & ~(a-1)) 57#define ALIGN_ADDR(x, a) ((((u32)(x)) + (a-1)) & ~(a-1))
59 58
60static dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE; 59static dbdma_global_t *dbdma_gptr = (dbdma_global_t *)DDMA_GLOBAL_BASE;
61static int dbdma_initialized=0; 60static int dbdma_initialized;
62static void au1xxx_dbdma_init(void); 61static void au1xxx_dbdma_init(void);
63 62
64static dbdev_tab_t dbdev_tab[] = { 63static dbdev_tab_t dbdev_tab[] = {
@@ -149,7 +148,7 @@ static dbdev_tab_t dbdev_tab[] = {
149 148
150 { DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 }, 149 { DSCR_CMD0_NAND_FLASH, DEV_FLAGS_IN, 0, 0, 0x00000000, 0, 0 },
151 150
152#endif // CONFIG_SOC_AU1200 151#endif /* CONFIG_SOC_AU1200 */
153 152
154 { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, 153 { DSCR_CMD0_THROTTLE, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
155 { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 }, 154 { DSCR_CMD0_ALWAYS, DEV_FLAGS_ANYUSE, 0, 0, 0x00000000, 0, 0 },
@@ -177,8 +176,7 @@ static dbdev_tab_t dbdev_tab[] = {
177 176
178static chan_tab_t *chan_tab_ptr[NUM_DBDMA_CHANS]; 177static chan_tab_t *chan_tab_ptr[NUM_DBDMA_CHANS];
179 178
180static dbdev_tab_t * 179static dbdev_tab_t *find_dbdev_id(u32 id)
181find_dbdev_id(u32 id)
182{ 180{
183 int i; 181 int i;
184 dbdev_tab_t *p; 182 dbdev_tab_t *p;
@@ -190,29 +188,27 @@ find_dbdev_id(u32 id)
190 return NULL; 188 return NULL;
191} 189}
192 190
193void * au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp) 191void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp)
194{ 192{
195 return phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 193 return phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
196} 194}
197EXPORT_SYMBOL(au1xxx_ddma_get_nextptr_virt); 195EXPORT_SYMBOL(au1xxx_ddma_get_nextptr_virt);
198 196
199u32 197u32 au1xxx_ddma_add_device(dbdev_tab_t *dev)
200au1xxx_ddma_add_device(dbdev_tab_t *dev)
201{ 198{
202 u32 ret = 0; 199 u32 ret = 0;
203 dbdev_tab_t *p=NULL; 200 dbdev_tab_t *p;
204 static u16 new_id=0x1000; 201 static u16 new_id = 0x1000;
205 202
206 p = find_dbdev_id(~0); 203 p = find_dbdev_id(~0);
207 if ( NULL != p ) 204 if (NULL != p) {
208 {
209 memcpy(p, dev, sizeof(dbdev_tab_t)); 205 memcpy(p, dev, sizeof(dbdev_tab_t));
210 p->dev_id = DSCR_DEV2CUSTOM_ID(new_id, dev->dev_id); 206 p->dev_id = DSCR_DEV2CUSTOM_ID(new_id, dev->dev_id);
211 ret = p->dev_id; 207 ret = p->dev_id;
212 new_id++; 208 new_id++;
213#if 0 209#if 0
214 printk("add_device: id:%x flags:%x padd:%x\n", 210 printk(KERN_DEBUG "add_device: id:%x flags:%x padd:%x\n",
215 p->dev_id, p->dev_flags, p->dev_physaddr ); 211 p->dev_id, p->dev_flags, p->dev_physaddr);
216#endif 212#endif
217 } 213 }
218 214
@@ -220,10 +216,8 @@ au1xxx_ddma_add_device(dbdev_tab_t *dev)
220} 216}
221EXPORT_SYMBOL(au1xxx_ddma_add_device); 217EXPORT_SYMBOL(au1xxx_ddma_add_device);
222 218
223/* Allocate a channel and return a non-zero descriptor if successful. 219/* Allocate a channel and return a non-zero descriptor if successful. */
224*/ 220u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
225u32
226au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
227 void (*callback)(int, void *), void *callparam) 221 void (*callback)(int, void *), void *callparam)
228{ 222{
229 unsigned long flags; 223 unsigned long flags;
@@ -234,7 +228,8 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
234 chan_tab_t *ctp; 228 chan_tab_t *ctp;
235 au1x_dma_chan_t *cp; 229 au1x_dma_chan_t *cp;
236 230
237 /* We do the intialization on the first channel allocation. 231 /*
232 * We do the intialization on the first channel allocation.
238 * We have to wait because of the interrupt handler initialization 233 * We have to wait because of the interrupt handler initialization
239 * which can't be done successfully during board set up. 234 * which can't be done successfully during board set up.
240 */ 235 */
@@ -242,16 +237,17 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
242 au1xxx_dbdma_init(); 237 au1xxx_dbdma_init();
243 dbdma_initialized = 1; 238 dbdma_initialized = 1;
244 239
245 if ((stp = find_dbdev_id(srcid)) == NULL) 240 stp = find_dbdev_id(srcid);
241 if (stp == NULL)
246 return 0; 242 return 0;
247 if ((dtp = find_dbdev_id(destid)) == NULL) 243 dtp = find_dbdev_id(destid);
244 if (dtp == NULL)
248 return 0; 245 return 0;
249 246
250 used = 0; 247 used = 0;
251 rv = 0; 248 rv = 0;
252 249
253 /* Check to see if we can get both channels. 250 /* Check to see if we can get both channels. */
254 */
255 spin_lock_irqsave(&au1xxx_dbdma_spin_lock, flags); 251 spin_lock_irqsave(&au1xxx_dbdma_spin_lock, flags);
256 if (!(stp->dev_flags & DEV_FLAGS_INUSE) || 252 if (!(stp->dev_flags & DEV_FLAGS_INUSE) ||
257 (stp->dev_flags & DEV_FLAGS_ANYUSE)) { 253 (stp->dev_flags & DEV_FLAGS_ANYUSE)) {
@@ -261,35 +257,30 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
261 (dtp->dev_flags & DEV_FLAGS_ANYUSE)) { 257 (dtp->dev_flags & DEV_FLAGS_ANYUSE)) {
262 /* Got destination */ 258 /* Got destination */
263 dtp->dev_flags |= DEV_FLAGS_INUSE; 259 dtp->dev_flags |= DEV_FLAGS_INUSE;
264 } 260 } else {
265 else { 261 /* Can't get dest. Release src. */
266 /* Can't get dest. Release src.
267 */
268 stp->dev_flags &= ~DEV_FLAGS_INUSE; 262 stp->dev_flags &= ~DEV_FLAGS_INUSE;
269 used++; 263 used++;
270 } 264 }
271 } 265 } else
272 else {
273 used++; 266 used++;
274 }
275 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags); 267 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags);
276 268
277 if (!used) { 269 if (!used) {
278 /* Let's see if we can allocate a channel for it. 270 /* Let's see if we can allocate a channel for it. */
279 */
280 ctp = NULL; 271 ctp = NULL;
281 chan = 0; 272 chan = 0;
282 spin_lock_irqsave(&au1xxx_dbdma_spin_lock, flags); 273 spin_lock_irqsave(&au1xxx_dbdma_spin_lock, flags);
283 for (i=0; i<NUM_DBDMA_CHANS; i++) { 274 for (i = 0; i < NUM_DBDMA_CHANS; i++)
284 if (chan_tab_ptr[i] == NULL) { 275 if (chan_tab_ptr[i] == NULL) {
285 /* If kmalloc fails, it is caught below same 276 /*
277 * If kmalloc fails, it is caught below same
286 * as a channel not available. 278 * as a channel not available.
287 */ 279 */
288 ctp = kmalloc(sizeof(chan_tab_t), GFP_ATOMIC); 280 ctp = kmalloc(sizeof(chan_tab_t), GFP_ATOMIC);
289 chan_tab_ptr[i] = ctp; 281 chan_tab_ptr[i] = ctp;
290 break; 282 break;
291 } 283 }
292 }
293 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags); 284 spin_unlock_irqrestore(&au1xxx_dbdma_spin_lock, flags);
294 285
295 if (ctp != NULL) { 286 if (ctp != NULL) {
@@ -304,8 +295,7 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
304 ctp->chan_callback = callback; 295 ctp->chan_callback = callback;
305 ctp->chan_callparam = callparam; 296 ctp->chan_callparam = callparam;
306 297
307 /* Initialize channel configuration. 298 /* Initialize channel configuration. */
308 */
309 i = 0; 299 i = 0;
310 if (stp->dev_intlevel) 300 if (stp->dev_intlevel)
311 i |= DDMA_CFG_SED; 301 i |= DDMA_CFG_SED;
@@ -326,8 +316,7 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
326 * operations. 316 * operations.
327 */ 317 */
328 rv = (u32)(&chan_tab_ptr[chan]); 318 rv = (u32)(&chan_tab_ptr[chan]);
329 } 319 } else {
330 else {
331 /* Release devices */ 320 /* Release devices */
332 stp->dev_flags &= ~DEV_FLAGS_INUSE; 321 stp->dev_flags &= ~DEV_FLAGS_INUSE;
333 dtp->dev_flags &= ~DEV_FLAGS_INUSE; 322 dtp->dev_flags &= ~DEV_FLAGS_INUSE;
@@ -337,11 +326,11 @@ au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
337} 326}
338EXPORT_SYMBOL(au1xxx_dbdma_chan_alloc); 327EXPORT_SYMBOL(au1xxx_dbdma_chan_alloc);
339 328
340/* Set the device width if source or destination is a FIFO. 329/*
330 * Set the device width if source or destination is a FIFO.
341 * Should be 8, 16, or 32 bits. 331 * Should be 8, 16, or 32 bits.
342 */ 332 */
343u32 333u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits)
344au1xxx_dbdma_set_devwidth(u32 chanid, int bits)
345{ 334{
346 u32 rv; 335 u32 rv;
347 chan_tab_t *ctp; 336 chan_tab_t *ctp;
@@ -365,10 +354,8 @@ au1xxx_dbdma_set_devwidth(u32 chanid, int bits)
365} 354}
366EXPORT_SYMBOL(au1xxx_dbdma_set_devwidth); 355EXPORT_SYMBOL(au1xxx_dbdma_set_devwidth);
367 356
368/* Allocate a descriptor ring, initializing as much as possible. 357/* Allocate a descriptor ring, initializing as much as possible. */
369*/ 358u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
370u32
371au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
372{ 359{
373 int i; 360 int i;
374 u32 desc_base, srcid, destid; 361 u32 desc_base, srcid, destid;
@@ -378,43 +365,45 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
378 dbdev_tab_t *stp, *dtp; 365 dbdev_tab_t *stp, *dtp;
379 au1x_ddma_desc_t *dp; 366 au1x_ddma_desc_t *dp;
380 367
381 /* I guess we could check this to be within the 368 /*
369 * I guess we could check this to be within the
382 * range of the table...... 370 * range of the table......
383 */ 371 */
384 ctp = *((chan_tab_t **)chanid); 372 ctp = *((chan_tab_t **)chanid);
385 stp = ctp->chan_src; 373 stp = ctp->chan_src;
386 dtp = ctp->chan_dest; 374 dtp = ctp->chan_dest;
387 375
388 /* The descriptors must be 32-byte aligned. There is a 376 /*
377 * The descriptors must be 32-byte aligned. There is a
389 * possibility the allocation will give us such an address, 378 * possibility the allocation will give us such an address,
390 * and if we try that first we are likely to not waste larger 379 * and if we try that first we are likely to not waste larger
391 * slabs of memory. 380 * slabs of memory.
392 */ 381 */
393 desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), 382 desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
394 GFP_KERNEL|GFP_DMA); 383 GFP_KERNEL|GFP_DMA);
395 if (desc_base == 0) 384 if (desc_base == 0)
396 return 0; 385 return 0;
397 386
398 if (desc_base & 0x1f) { 387 if (desc_base & 0x1f) {
399 /* Lost....do it again, allocate extra, and round 388 /*
389 * Lost....do it again, allocate extra, and round
400 * the address base. 390 * the address base.
401 */ 391 */
402 kfree((const void *)desc_base); 392 kfree((const void *)desc_base);
403 i = entries * sizeof(au1x_ddma_desc_t); 393 i = entries * sizeof(au1x_ddma_desc_t);
404 i += (sizeof(au1x_ddma_desc_t) - 1); 394 i += (sizeof(au1x_ddma_desc_t) - 1);
405 if ((desc_base = (u32)kmalloc(i, GFP_KERNEL|GFP_DMA)) == 0) 395 desc_base = (u32)kmalloc(i, GFP_KERNEL|GFP_DMA);
396 if (desc_base == 0)
406 return 0; 397 return 0;
407 398
408 desc_base = ALIGN_ADDR(desc_base, sizeof(au1x_ddma_desc_t)); 399 desc_base = ALIGN_ADDR(desc_base, sizeof(au1x_ddma_desc_t));
409 } 400 }
410 dp = (au1x_ddma_desc_t *)desc_base; 401 dp = (au1x_ddma_desc_t *)desc_base;
411 402
412 /* Keep track of the base descriptor. 403 /* Keep track of the base descriptor. */
413 */
414 ctp->chan_desc_base = dp; 404 ctp->chan_desc_base = dp;
415 405
416 /* Initialize the rings with as much information as we know. 406 /* Initialize the rings with as much information as we know. */
417 */
418 srcid = stp->dev_id; 407 srcid = stp->dev_id;
419 destid = dtp->dev_id; 408 destid = dtp->dev_id;
420 409
@@ -426,11 +415,12 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
426 cmd0 |= DSCR_CMD0_IE | DSCR_CMD0_CV; 415 cmd0 |= DSCR_CMD0_IE | DSCR_CMD0_CV;
427 cmd0 |= DSCR_CMD0_ST(DSCR_CMD0_ST_NOCHANGE); 416 cmd0 |= DSCR_CMD0_ST(DSCR_CMD0_ST_NOCHANGE);
428 417
429 /* is it mem to mem transfer? */ 418 /* Is it mem to mem transfer? */
430 if(((DSCR_CUSTOM2DEV_ID(srcid) == DSCR_CMD0_THROTTLE) || (DSCR_CUSTOM2DEV_ID(srcid) == DSCR_CMD0_ALWAYS)) && 419 if (((DSCR_CUSTOM2DEV_ID(srcid) == DSCR_CMD0_THROTTLE) ||
431 ((DSCR_CUSTOM2DEV_ID(destid) == DSCR_CMD0_THROTTLE) || (DSCR_CUSTOM2DEV_ID(destid) == DSCR_CMD0_ALWAYS))) { 420 (DSCR_CUSTOM2DEV_ID(srcid) == DSCR_CMD0_ALWAYS)) &&
432 cmd0 |= DSCR_CMD0_MEM; 421 ((DSCR_CUSTOM2DEV_ID(destid) == DSCR_CMD0_THROTTLE) ||
433 } 422 (DSCR_CUSTOM2DEV_ID(destid) == DSCR_CMD0_ALWAYS)))
423 cmd0 |= DSCR_CMD0_MEM;
434 424
435 switch (stp->dev_devwidth) { 425 switch (stp->dev_devwidth) {
436 case 8: 426 case 8:
@@ -458,15 +448,17 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
458 break; 448 break;
459 } 449 }
460 450
461 /* If the device is marked as an in/out FIFO, ensure it is 451 /*
452 * If the device is marked as an in/out FIFO, ensure it is
462 * set non-coherent. 453 * set non-coherent.
463 */ 454 */
464 if (stp->dev_flags & DEV_FLAGS_IN) 455 if (stp->dev_flags & DEV_FLAGS_IN)
465 cmd0 |= DSCR_CMD0_SN; /* Source in fifo */ 456 cmd0 |= DSCR_CMD0_SN; /* Source in FIFO */
466 if (dtp->dev_flags & DEV_FLAGS_OUT) 457 if (dtp->dev_flags & DEV_FLAGS_OUT)
467 cmd0 |= DSCR_CMD0_DN; /* Destination out fifo */ 458 cmd0 |= DSCR_CMD0_DN; /* Destination out FIFO */
468 459
469 /* Set up source1. For now, assume no stride and increment. 460 /*
461 * Set up source1. For now, assume no stride and increment.
470 * A channel attribute update can change this later. 462 * A channel attribute update can change this later.
471 */ 463 */
472 switch (stp->dev_tsize) { 464 switch (stp->dev_tsize) {
@@ -485,19 +477,19 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
485 break; 477 break;
486 } 478 }
487 479
488 /* If source input is fifo, set static address. 480 /* If source input is FIFO, set static address. */
489 */
490 if (stp->dev_flags & DEV_FLAGS_IN) { 481 if (stp->dev_flags & DEV_FLAGS_IN) {
491 if ( stp->dev_flags & DEV_FLAGS_BURSTABLE ) 482 if (stp->dev_flags & DEV_FLAGS_BURSTABLE)
492 src1 |= DSCR_SRC1_SAM(DSCR_xAM_BURST); 483 src1 |= DSCR_SRC1_SAM(DSCR_xAM_BURST);
493 else 484 else
494 src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC); 485 src1 |= DSCR_SRC1_SAM(DSCR_xAM_STATIC);
495
496 } 486 }
487
497 if (stp->dev_physaddr) 488 if (stp->dev_physaddr)
498 src0 = stp->dev_physaddr; 489 src0 = stp->dev_physaddr;
499 490
500 /* Set up dest1. For now, assume no stride and increment. 491 /*
492 * Set up dest1. For now, assume no stride and increment.
501 * A channel attribute update can change this later. 493 * A channel attribute update can change this later.
502 */ 494 */
503 switch (dtp->dev_tsize) { 495 switch (dtp->dev_tsize) {
@@ -516,22 +508,24 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
516 break; 508 break;
517 } 509 }
518 510
519 /* If destination output is fifo, set static address. 511 /* If destination output is FIFO, set static address. */
520 */
521 if (dtp->dev_flags & DEV_FLAGS_OUT) { 512 if (dtp->dev_flags & DEV_FLAGS_OUT) {
522 if ( dtp->dev_flags & DEV_FLAGS_BURSTABLE ) 513 if (dtp->dev_flags & DEV_FLAGS_BURSTABLE)
523 dest1 |= DSCR_DEST1_DAM(DSCR_xAM_BURST); 514 dest1 |= DSCR_DEST1_DAM(DSCR_xAM_BURST);
524 else 515 else
525 dest1 |= DSCR_DEST1_DAM(DSCR_xAM_STATIC); 516 dest1 |= DSCR_DEST1_DAM(DSCR_xAM_STATIC);
526 } 517 }
518
527 if (dtp->dev_physaddr) 519 if (dtp->dev_physaddr)
528 dest0 = dtp->dev_physaddr; 520 dest0 = dtp->dev_physaddr;
529 521
530#if 0 522#if 0
531 printk("did:%x sid:%x cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", 523 printk(KERN_DEBUG "did:%x sid:%x cmd0:%x cmd1:%x source0:%x "
532 dtp->dev_id, stp->dev_id, cmd0, cmd1, src0, src1, dest0, dest1 ); 524 "source1:%x dest0:%x dest1:%x\n",
525 dtp->dev_id, stp->dev_id, cmd0, cmd1, src0,
526 src1, dest0, dest1);
533#endif 527#endif
534 for (i=0; i<entries; i++) { 528 for (i = 0; i < entries; i++) {
535 dp->dscr_cmd0 = cmd0; 529 dp->dscr_cmd0 = cmd0;
536 dp->dscr_cmd1 = cmd1; 530 dp->dscr_cmd1 = cmd1;
537 dp->dscr_source0 = src0; 531 dp->dscr_source0 = src0;
@@ -545,49 +539,49 @@ au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
545 dp++; 539 dp++;
546 } 540 }
547 541
548 /* Make last descrptor point to the first. 542 /* Make last descrptor point to the first. */
549 */
550 dp--; 543 dp--;
551 dp->dscr_nxtptr = DSCR_NXTPTR(virt_to_phys(ctp->chan_desc_base)); 544 dp->dscr_nxtptr = DSCR_NXTPTR(virt_to_phys(ctp->chan_desc_base));
552 ctp->get_ptr = ctp->put_ptr = ctp->cur_ptr = ctp->chan_desc_base; 545 ctp->get_ptr = ctp->put_ptr = ctp->cur_ptr = ctp->chan_desc_base;
553 546
554 return (u32)(ctp->chan_desc_base); 547 return (u32)ctp->chan_desc_base;
555} 548}
556EXPORT_SYMBOL(au1xxx_dbdma_ring_alloc); 549EXPORT_SYMBOL(au1xxx_dbdma_ring_alloc);
557 550
558/* Put a source buffer into the DMA ring. 551/*
552 * Put a source buffer into the DMA ring.
559 * This updates the source pointer and byte count. Normally used 553 * This updates the source pointer and byte count. Normally used
560 * for memory to fifo transfers. 554 * for memory to fifo transfers.
561 */ 555 */
562u32 556u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags)
563_au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags)
564{ 557{
565 chan_tab_t *ctp; 558 chan_tab_t *ctp;
566 au1x_ddma_desc_t *dp; 559 au1x_ddma_desc_t *dp;
567 560
568 /* I guess we could check this to be within the 561 /*
562 * I guess we could check this to be within the
569 * range of the table...... 563 * range of the table......
570 */ 564 */
571 ctp = *((chan_tab_t **)chanid); 565 ctp = *(chan_tab_t **)chanid;
572 566
573 /* We should have multiple callers for a particular channel, 567 /*
568 * We should have multiple callers for a particular channel,
574 * an interrupt doesn't affect this pointer nor the descriptor, 569 * an interrupt doesn't affect this pointer nor the descriptor,
575 * so no locking should be needed. 570 * so no locking should be needed.
576 */ 571 */
577 dp = ctp->put_ptr; 572 dp = ctp->put_ptr;
578 573
579 /* If the descriptor is valid, we are way ahead of the DMA 574 /*
575 * If the descriptor is valid, we are way ahead of the DMA
580 * engine, so just return an error condition. 576 * engine, so just return an error condition.
581 */ 577 */
582 if (dp->dscr_cmd0 & DSCR_CMD0_V) { 578 if (dp->dscr_cmd0 & DSCR_CMD0_V)
583 return 0; 579 return 0;
584 }
585 580
586 /* Load up buffer address and byte count. 581 /* Load up buffer address and byte count. */
587 */
588 dp->dscr_source0 = virt_to_phys(buf); 582 dp->dscr_source0 = virt_to_phys(buf);
589 dp->dscr_cmd1 = nbytes; 583 dp->dscr_cmd1 = nbytes;
590 /* Check flags */ 584 /* Check flags */
591 if (flags & DDMA_FLAGS_IE) 585 if (flags & DDMA_FLAGS_IE)
592 dp->dscr_cmd0 |= DSCR_CMD0_IE; 586 dp->dscr_cmd0 |= DSCR_CMD0_IE;
593 if (flags & DDMA_FLAGS_NOIE) 587 if (flags & DDMA_FLAGS_NOIE)
@@ -595,23 +589,21 @@ _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags)
595 589
596 /* 590 /*
597 * There is an errata on the Au1200/Au1550 parts that could result 591 * There is an errata on the Au1200/Au1550 parts that could result
598 * in "stale" data being DMA'd. It has to do with the snoop logic on 592 * in "stale" data being DMA'ed. It has to do with the snoop logic on
599 * the dache eviction buffer. NONCOHERENT_IO is on by default for 593 * the cache eviction buffer. DMA_NONCOHERENT is on by default for
600 * these parts. If it is fixedin the future, these dma_cache_inv will 594 * these parts. If it is fixed in the future, these dma_cache_inv will
601 * just be nothing more than empty macros. See io.h. 595 * just be nothing more than empty macros. See io.h.
602 * */ 596 */
603 dma_cache_wback_inv((unsigned long)buf, nbytes); 597 dma_cache_wback_inv((unsigned long)buf, nbytes);
604 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ 598 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
605 au_sync(); 599 au_sync();
606 dma_cache_wback_inv((unsigned long)dp, sizeof(dp)); 600 dma_cache_wback_inv((unsigned long)dp, sizeof(dp));
607 ctp->chan_ptr->ddma_dbell = 0; 601 ctp->chan_ptr->ddma_dbell = 0;
608 602
609 /* Get next descriptor pointer. 603 /* Get next descriptor pointer. */
610 */
611 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 604 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
612 605
613 /* return something not zero. 606 /* Return something non-zero. */
614 */
615 return nbytes; 607 return nbytes;
616} 608}
617EXPORT_SYMBOL(_au1xxx_dbdma_put_source); 609EXPORT_SYMBOL(_au1xxx_dbdma_put_source);
@@ -654,81 +646,77 @@ _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags)
654 dp->dscr_dest0 = virt_to_phys(buf); 646 dp->dscr_dest0 = virt_to_phys(buf);
655 dp->dscr_cmd1 = nbytes; 647 dp->dscr_cmd1 = nbytes;
656#if 0 648#if 0
657 printk("cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n", 649 printk(KERN_DEBUG "cmd0:%x cmd1:%x source0:%x source1:%x dest0:%x dest1:%x\n",
658 dp->dscr_cmd0, dp->dscr_cmd1, dp->dscr_source0, 650 dp->dscr_cmd0, dp->dscr_cmd1, dp->dscr_source0,
659 dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1 ); 651 dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1);
660#endif 652#endif
661 /* 653 /*
662 * There is an errata on the Au1200/Au1550 parts that could result in 654 * There is an errata on the Au1200/Au1550 parts that could result in
663 * "stale" data being DMA'd. It has to do with the snoop logic on the 655 * "stale" data being DMA'ed. It has to do with the snoop logic on the
664 * dache eviction buffer. NONCOHERENT_IO is on by default for these 656 * cache eviction buffer. DMA_NONCOHERENT is on by default for these
665 * parts. If it is fixedin the future, these dma_cache_inv will just 657 * parts. If it is fixed in the future, these dma_cache_inv will just
666 * be nothing more than empty macros. See io.h. 658 * be nothing more than empty macros. See io.h.
667 * */ 659 */
668 dma_cache_inv((unsigned long)buf, nbytes); 660 dma_cache_inv((unsigned long)buf, nbytes);
669 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */ 661 dp->dscr_cmd0 |= DSCR_CMD0_V; /* Let it rip */
670 au_sync(); 662 au_sync();
671 dma_cache_wback_inv((unsigned long)dp, sizeof(dp)); 663 dma_cache_wback_inv((unsigned long)dp, sizeof(dp));
672 ctp->chan_ptr->ddma_dbell = 0; 664 ctp->chan_ptr->ddma_dbell = 0;
673 665
674 /* Get next descriptor pointer. 666 /* Get next descriptor pointer. */
675 */
676 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 667 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
677 668
678 /* return something not zero. 669 /* Return something non-zero. */
679 */
680 return nbytes; 670 return nbytes;
681} 671}
682EXPORT_SYMBOL(_au1xxx_dbdma_put_dest); 672EXPORT_SYMBOL(_au1xxx_dbdma_put_dest);
683 673
684/* Get a destination buffer into the DMA ring. 674/*
675 * Get a destination buffer into the DMA ring.
685 * Normally used to get a full buffer from the ring during fifo 676 * Normally used to get a full buffer from the ring during fifo
686 * to memory transfers. This does not set the valid bit, you will 677 * to memory transfers. This does not set the valid bit, you will
687 * have to put another destination buffer to keep the DMA going. 678 * have to put another destination buffer to keep the DMA going.
688 */ 679 */
689u32 680u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes)
690au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes)
691{ 681{
692 chan_tab_t *ctp; 682 chan_tab_t *ctp;
693 au1x_ddma_desc_t *dp; 683 au1x_ddma_desc_t *dp;
694 u32 rv; 684 u32 rv;
695 685
696 /* I guess we could check this to be within the 686 /*
687 * I guess we could check this to be within the
697 * range of the table...... 688 * range of the table......
698 */ 689 */
699 ctp = *((chan_tab_t **)chanid); 690 ctp = *((chan_tab_t **)chanid);
700 691
701 /* We should have multiple callers for a particular channel, 692 /*
693 * We should have multiple callers for a particular channel,
702 * an interrupt doesn't affect this pointer nor the descriptor, 694 * an interrupt doesn't affect this pointer nor the descriptor,
703 * so no locking should be needed. 695 * so no locking should be needed.
704 */ 696 */
705 dp = ctp->get_ptr; 697 dp = ctp->get_ptr;
706 698
707 /* If the descriptor is valid, we are way ahead of the DMA 699 /*
700 * If the descriptor is valid, we are way ahead of the DMA
708 * engine, so just return an error condition. 701 * engine, so just return an error condition.
709 */ 702 */
710 if (dp->dscr_cmd0 & DSCR_CMD0_V) 703 if (dp->dscr_cmd0 & DSCR_CMD0_V)
711 return 0; 704 return 0;
712 705
713 /* Return buffer address and byte count. 706 /* Return buffer address and byte count. */
714 */
715 *buf = (void *)(phys_to_virt(dp->dscr_dest0)); 707 *buf = (void *)(phys_to_virt(dp->dscr_dest0));
716 *nbytes = dp->dscr_cmd1; 708 *nbytes = dp->dscr_cmd1;
717 rv = dp->dscr_stat; 709 rv = dp->dscr_stat;
718 710
719 /* Get next descriptor pointer. 711 /* Get next descriptor pointer. */
720 */
721 ctp->get_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 712 ctp->get_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
722 713
723 /* return something not zero. 714 /* Return something non-zero. */
724 */
725 return rv; 715 return rv;
726} 716}
727
728EXPORT_SYMBOL_GPL(au1xxx_dbdma_get_dest); 717EXPORT_SYMBOL_GPL(au1xxx_dbdma_get_dest);
729 718
730void 719void au1xxx_dbdma_stop(u32 chanid)
731au1xxx_dbdma_stop(u32 chanid)
732{ 720{
733 chan_tab_t *ctp; 721 chan_tab_t *ctp;
734 au1x_dma_chan_t *cp; 722 au1x_dma_chan_t *cp;
@@ -743,7 +731,7 @@ au1xxx_dbdma_stop(u32 chanid)
743 udelay(1); 731 udelay(1);
744 halt_timeout++; 732 halt_timeout++;
745 if (halt_timeout > 100) { 733 if (halt_timeout > 100) {
746 printk("warning: DMA channel won't halt\n"); 734 printk(KERN_WARNING "warning: DMA channel won't halt\n");
747 break; 735 break;
748 } 736 }
749 } 737 }
@@ -753,12 +741,12 @@ au1xxx_dbdma_stop(u32 chanid)
753} 741}
754EXPORT_SYMBOL(au1xxx_dbdma_stop); 742EXPORT_SYMBOL(au1xxx_dbdma_stop);
755 743
756/* Start using the current descriptor pointer. If the dbdma encounters 744/*
757 * a not valid descriptor, it will stop. In this case, we can just 745 * Start using the current descriptor pointer. If the DBDMA encounters
746 * a non-valid descriptor, it will stop. In this case, we can just
758 * continue by adding a buffer to the list and starting again. 747 * continue by adding a buffer to the list and starting again.
759 */ 748 */
760void 749void au1xxx_dbdma_start(u32 chanid)
761au1xxx_dbdma_start(u32 chanid)
762{ 750{
763 chan_tab_t *ctp; 751 chan_tab_t *ctp;
764 au1x_dma_chan_t *cp; 752 au1x_dma_chan_t *cp;
@@ -773,8 +761,7 @@ au1xxx_dbdma_start(u32 chanid)
773} 761}
774EXPORT_SYMBOL(au1xxx_dbdma_start); 762EXPORT_SYMBOL(au1xxx_dbdma_start);
775 763
776void 764void au1xxx_dbdma_reset(u32 chanid)
777au1xxx_dbdma_reset(u32 chanid)
778{ 765{
779 chan_tab_t *ctp; 766 chan_tab_t *ctp;
780 au1x_ddma_desc_t *dp; 767 au1x_ddma_desc_t *dp;
@@ -784,14 +771,14 @@ au1xxx_dbdma_reset(u32 chanid)
784 ctp = *((chan_tab_t **)chanid); 771 ctp = *((chan_tab_t **)chanid);
785 ctp->get_ptr = ctp->put_ptr = ctp->cur_ptr = ctp->chan_desc_base; 772 ctp->get_ptr = ctp->put_ptr = ctp->cur_ptr = ctp->chan_desc_base;
786 773
787 /* Run through the descriptors and reset the valid indicator. 774 /* Run through the descriptors and reset the valid indicator. */
788 */
789 dp = ctp->chan_desc_base; 775 dp = ctp->chan_desc_base;
790 776
791 do { 777 do {
792 dp->dscr_cmd0 &= ~DSCR_CMD0_V; 778 dp->dscr_cmd0 &= ~DSCR_CMD0_V;
793 /* reset our SW status -- this is used to determine 779 /*
794 * if a descriptor is in use by upper level SW. Since 780 * Reset our software status -- this is used to determine
781 * if a descriptor is in use by upper level software. Since
795 * posting can reset 'V' bit. 782 * posting can reset 'V' bit.
796 */ 783 */
797 dp->sw_status = 0; 784 dp->sw_status = 0;
@@ -800,8 +787,7 @@ au1xxx_dbdma_reset(u32 chanid)
800} 787}
801EXPORT_SYMBOL(au1xxx_dbdma_reset); 788EXPORT_SYMBOL(au1xxx_dbdma_reset);
802 789
803u32 790u32 au1xxx_get_dma_residue(u32 chanid)
804au1xxx_get_dma_residue(u32 chanid)
805{ 791{
806 chan_tab_t *ctp; 792 chan_tab_t *ctp;
807 au1x_dma_chan_t *cp; 793 au1x_dma_chan_t *cp;
@@ -810,18 +796,15 @@ au1xxx_get_dma_residue(u32 chanid)
810 ctp = *((chan_tab_t **)chanid); 796 ctp = *((chan_tab_t **)chanid);
811 cp = ctp->chan_ptr; 797 cp = ctp->chan_ptr;
812 798
813 /* This is only valid if the channel is stopped. 799 /* This is only valid if the channel is stopped. */
814 */
815 rv = cp->ddma_bytecnt; 800 rv = cp->ddma_bytecnt;
816 au_sync(); 801 au_sync();
817 802
818 return rv; 803 return rv;
819} 804}
820
821EXPORT_SYMBOL_GPL(au1xxx_get_dma_residue); 805EXPORT_SYMBOL_GPL(au1xxx_get_dma_residue);
822 806
823void 807void au1xxx_dbdma_chan_free(u32 chanid)
824au1xxx_dbdma_chan_free(u32 chanid)
825{ 808{
826 chan_tab_t *ctp; 809 chan_tab_t *ctp;
827 dbdev_tab_t *stp, *dtp; 810 dbdev_tab_t *stp, *dtp;
@@ -842,8 +825,7 @@ au1xxx_dbdma_chan_free(u32 chanid)
842} 825}
843EXPORT_SYMBOL(au1xxx_dbdma_chan_free); 826EXPORT_SYMBOL(au1xxx_dbdma_chan_free);
844 827
845static irqreturn_t 828static irqreturn_t dbdma_interrupt(int irq, void *dev_id)
846dbdma_interrupt(int irq, void *dev_id)
847{ 829{
848 u32 intstat; 830 u32 intstat;
849 u32 chan_index; 831 u32 chan_index;
@@ -859,13 +841,12 @@ dbdma_interrupt(int irq, void *dev_id)
859 cp = ctp->chan_ptr; 841 cp = ctp->chan_ptr;
860 dp = ctp->cur_ptr; 842 dp = ctp->cur_ptr;
861 843
862 /* Reset interrupt. 844 /* Reset interrupt. */
863 */
864 cp->ddma_irq = 0; 845 cp->ddma_irq = 0;
865 au_sync(); 846 au_sync();
866 847
867 if (ctp->chan_callback) 848 if (ctp->chan_callback)
868 (ctp->chan_callback)(irq, ctp->chan_callparam); 849 ctp->chan_callback(irq, ctp->chan_callparam);
869 850
870 ctp->cur_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 851 ctp->cur_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
871 return IRQ_RETVAL(1); 852 return IRQ_RETVAL(1);
@@ -890,47 +871,47 @@ static void au1xxx_dbdma_init(void)
890 871
891 if (request_irq(irq_nr, dbdma_interrupt, IRQF_DISABLED, 872 if (request_irq(irq_nr, dbdma_interrupt, IRQF_DISABLED,
892 "Au1xxx dbdma", (void *)dbdma_gptr)) 873 "Au1xxx dbdma", (void *)dbdma_gptr))
893 printk("Can't get 1550 dbdma irq"); 874 printk(KERN_ERR "Can't get 1550 dbdma irq");
894} 875}
895 876
896void 877void au1xxx_dbdma_dump(u32 chanid)
897au1xxx_dbdma_dump(u32 chanid)
898{ 878{
899 chan_tab_t *ctp; 879 chan_tab_t *ctp;
900 au1x_ddma_desc_t *dp; 880 au1x_ddma_desc_t *dp;
901 dbdev_tab_t *stp, *dtp; 881 dbdev_tab_t *stp, *dtp;
902 au1x_dma_chan_t *cp; 882 au1x_dma_chan_t *cp;
903 u32 i = 0; 883 u32 i = 0;
904 884
905 ctp = *((chan_tab_t **)chanid); 885 ctp = *((chan_tab_t **)chanid);
906 stp = ctp->chan_src; 886 stp = ctp->chan_src;
907 dtp = ctp->chan_dest; 887 dtp = ctp->chan_dest;
908 cp = ctp->chan_ptr; 888 cp = ctp->chan_ptr;
909 889
910 printk("Chan %x, stp %x (dev %d) dtp %x (dev %d) \n", 890 printk(KERN_DEBUG "Chan %x, stp %x (dev %d) dtp %x (dev %d) \n",
911 (u32)ctp, (u32)stp, stp - dbdev_tab, (u32)dtp, dtp - dbdev_tab); 891 (u32)ctp, (u32)stp, stp - dbdev_tab, (u32)dtp,
912 printk("desc base %x, get %x, put %x, cur %x\n", 892 dtp - dbdev_tab);
913 (u32)(ctp->chan_desc_base), (u32)(ctp->get_ptr), 893 printk(KERN_DEBUG "desc base %x, get %x, put %x, cur %x\n",
914 (u32)(ctp->put_ptr), (u32)(ctp->cur_ptr)); 894 (u32)(ctp->chan_desc_base), (u32)(ctp->get_ptr),
915 895 (u32)(ctp->put_ptr), (u32)(ctp->cur_ptr));
916 printk("dbdma chan %x\n", (u32)cp); 896
917 printk("cfg %08x, desptr %08x, statptr %08x\n", 897 printk(KERN_DEBUG "dbdma chan %x\n", (u32)cp);
918 cp->ddma_cfg, cp->ddma_desptr, cp->ddma_statptr); 898 printk(KERN_DEBUG "cfg %08x, desptr %08x, statptr %08x\n",
919 printk("dbell %08x, irq %08x, stat %08x, bytecnt %08x\n", 899 cp->ddma_cfg, cp->ddma_desptr, cp->ddma_statptr);
920 cp->ddma_dbell, cp->ddma_irq, cp->ddma_stat, cp->ddma_bytecnt); 900 printk(KERN_DEBUG "dbell %08x, irq %08x, stat %08x, bytecnt %08x\n",
921 901 cp->ddma_dbell, cp->ddma_irq, cp->ddma_stat,
922 902 cp->ddma_bytecnt);
923 /* Run through the descriptors 903
924 */ 904 /* Run through the descriptors */
925 dp = ctp->chan_desc_base; 905 dp = ctp->chan_desc_base;
926 906
927 do { 907 do {
928 printk("Dp[%d]= %08x, cmd0 %08x, cmd1 %08x\n", 908 printk(KERN_DEBUG "Dp[%d]= %08x, cmd0 %08x, cmd1 %08x\n",
929 i++, (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1); 909 i++, (u32)dp, dp->dscr_cmd0, dp->dscr_cmd1);
930 printk("src0 %08x, src1 %08x, dest0 %08x, dest1 %08x\n", 910 printk(KERN_DEBUG "src0 %08x, src1 %08x, dest0 %08x, dest1 %08x\n",
931 dp->dscr_source0, dp->dscr_source1, dp->dscr_dest0, dp->dscr_dest1); 911 dp->dscr_source0, dp->dscr_source1,
932 printk("stat %08x, nxtptr %08x\n", 912 dp->dscr_dest0, dp->dscr_dest1);
933 dp->dscr_stat, dp->dscr_nxtptr); 913 printk(KERN_DEBUG "stat %08x, nxtptr %08x\n",
914 dp->dscr_stat, dp->dscr_nxtptr);
934 dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 915 dp = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
935 } while (dp != ctp->chan_desc_base); 916 } while (dp != ctp->chan_desc_base);
936} 917}
@@ -938,32 +919,33 @@ au1xxx_dbdma_dump(u32 chanid)
938/* Put a descriptor into the DMA ring. 919/* Put a descriptor into the DMA ring.
939 * This updates the source/destination pointers and byte count. 920 * This updates the source/destination pointers and byte count.
940 */ 921 */
941u32 922u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr)
942au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr )
943{ 923{
944 chan_tab_t *ctp; 924 chan_tab_t *ctp;
945 au1x_ddma_desc_t *dp; 925 au1x_ddma_desc_t *dp;
946 u32 nbytes=0; 926 u32 nbytes = 0;
947 927
948 /* I guess we could check this to be within the 928 /*
949 * range of the table...... 929 * I guess we could check this to be within the
950 */ 930 * range of the table......
931 */
951 ctp = *((chan_tab_t **)chanid); 932 ctp = *((chan_tab_t **)chanid);
952 933
953 /* We should have multiple callers for a particular channel, 934 /*
954 * an interrupt doesn't affect this pointer nor the descriptor, 935 * We should have multiple callers for a particular channel,
955 * so no locking should be needed. 936 * an interrupt doesn't affect this pointer nor the descriptor,
956 */ 937 * so no locking should be needed.
938 */
957 dp = ctp->put_ptr; 939 dp = ctp->put_ptr;
958 940
959 /* If the descriptor is valid, we are way ahead of the DMA 941 /*
960 * engine, so just return an error condition. 942 * If the descriptor is valid, we are way ahead of the DMA
961 */ 943 * engine, so just return an error condition.
944 */
962 if (dp->dscr_cmd0 & DSCR_CMD0_V) 945 if (dp->dscr_cmd0 & DSCR_CMD0_V)
963 return 0; 946 return 0;
964 947
965 /* Load up buffer addresses and byte count. 948 /* Load up buffer addresses and byte count. */
966 */
967 dp->dscr_dest0 = dscr->dscr_dest0; 949 dp->dscr_dest0 = dscr->dscr_dest0;
968 dp->dscr_source0 = dscr->dscr_source0; 950 dp->dscr_source0 = dscr->dscr_source0;
969 dp->dscr_dest1 = dscr->dscr_dest1; 951 dp->dscr_dest1 = dscr->dscr_dest1;
@@ -975,14 +957,11 @@ au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr )
975 dp->dscr_cmd0 |= dscr->dscr_cmd0 | DSCR_CMD0_V; 957 dp->dscr_cmd0 |= dscr->dscr_cmd0 | DSCR_CMD0_V;
976 ctp->chan_ptr->ddma_dbell = 0; 958 ctp->chan_ptr->ddma_dbell = 0;
977 959
978 /* Get next descriptor pointer. 960 /* Get next descriptor pointer. */
979 */
980 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr)); 961 ctp->put_ptr = phys_to_virt(DSCR_GET_NXTPTR(dp->dscr_nxtptr));
981 962
982 /* return something not zero. 963 /* Return something non-zero. */
983 */
984 return nbytes; 964 return nbytes;
985} 965}
986 966
987#endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */ 967#endif /* defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) */
988
diff --git a/arch/mips/au1000/common/dbg_io.c b/arch/mips/au1000/common/dbg_io.c
index eae1bb2ca26e..af5be7df2f2a 100644
--- a/arch/mips/au1000/common/dbg_io.c
+++ b/arch/mips/au1000/common/dbg_io.c
@@ -1,3 +1,4 @@
1#include <linux/types.h>
1 2
2#include <asm/mach-au1x00/au1000.h> 3#include <asm/mach-au1x00/au1000.h>
3 4
@@ -8,12 +9,6 @@
8 * uart to be used for debugging. 9 * uart to be used for debugging.
9 */ 10 */
10#define DEBUG_BASE UART_DEBUG_BASE 11#define DEBUG_BASE UART_DEBUG_BASE
11/**/
12
13/* we need uint32 uint8 */
14/* #include "types.h" */
15typedef unsigned char uint8;
16typedef unsigned int uint32;
17 12
18#define UART16550_BAUD_2400 2400 13#define UART16550_BAUD_2400 2400
19#define UART16550_BAUD_4800 4800 14#define UART16550_BAUD_4800 4800
@@ -51,17 +46,15 @@ typedef unsigned int uint32;
51#define UART_MOD_CNTRL 0x100 /* Module Control */ 46#define UART_MOD_CNTRL 0x100 /* Module Control */
52 47
53/* memory-mapped read/write of the port */ 48/* memory-mapped read/write of the port */
54#define UART16550_READ(y) (au_readl(DEBUG_BASE + y) & 0xff) 49#define UART16550_READ(y) (au_readl(DEBUG_BASE + y) & 0xff)
55#define UART16550_WRITE(y, z) (au_writel(z&0xff, DEBUG_BASE + y)) 50#define UART16550_WRITE(y, z) (au_writel(z & 0xff, DEBUG_BASE + y))
56 51
57extern unsigned long calc_clock(void); 52extern unsigned long calc_clock(void);
58 53
59void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop) 54void debugInit(u32 baud, u8 data, u8 parity, u8 stop)
60{ 55{
61 56 if (UART16550_READ(UART_MOD_CNTRL) != 0x3)
62 if (UART16550_READ(UART_MOD_CNTRL) != 0x3) {
63 UART16550_WRITE(UART_MOD_CNTRL, 3); 57 UART16550_WRITE(UART_MOD_CNTRL, 3);
64 }
65 calc_clock(); 58 calc_clock();
66 59
67 /* disable interrupts */ 60 /* disable interrupts */
@@ -69,7 +62,7 @@ void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
69 62
70 /* set up baud rate */ 63 /* set up baud rate */
71 { 64 {
72 uint32 divisor; 65 u32 divisor;
73 66
74 /* set divisor */ 67 /* set divisor */
75 divisor = get_au1x00_uart_baud_base() / baud; 68 divisor = get_au1x00_uart_baud_base() / baud;
@@ -80,9 +73,9 @@ void debugInit(uint32 baud, uint8 data, uint8 parity, uint8 stop)
80 UART16550_WRITE(UART_LCR, (data | parity | stop)); 73 UART16550_WRITE(UART_LCR, (data | parity | stop));
81} 74}
82 75
83static int remoteDebugInitialized = 0; 76static int remoteDebugInitialized;
84 77
85uint8 getDebugChar(void) 78u8 getDebugChar(void)
86{ 79{
87 if (!remoteDebugInitialized) { 80 if (!remoteDebugInitialized) {
88 remoteDebugInitialized = 1; 81 remoteDebugInitialized = 1;
@@ -92,15 +85,13 @@ uint8 getDebugChar(void)
92 UART16550_STOP_1BIT); 85 UART16550_STOP_1BIT);
93 } 86 }
94 87
95 while((UART16550_READ(UART_LSR) & 0x1) == 0); 88 while ((UART16550_READ(UART_LSR) & 0x1) == 0);
96 return UART16550_READ(UART_RX); 89 return UART16550_READ(UART_RX);
97} 90}
98 91
99 92
100int putDebugChar(uint8 byte) 93int putDebugChar(u8 byte)
101{ 94{
102// int i;
103
104 if (!remoteDebugInitialized) { 95 if (!remoteDebugInitialized) {
105 remoteDebugInitialized = 1; 96 remoteDebugInitialized = 1;
106 debugInit(UART16550_BAUD_115200, 97 debugInit(UART16550_BAUD_115200,
@@ -109,9 +100,8 @@ int putDebugChar(uint8 byte)
109 UART16550_STOP_1BIT); 100 UART16550_STOP_1BIT);
110 } 101 }
111 102
112 while ((UART16550_READ(UART_LSR)&0x40) == 0); 103 while ((UART16550_READ(UART_LSR) & 0x40) == 0);
113 UART16550_WRITE(UART_TX, byte); 104 UART16550_WRITE(UART_TX, byte);
114 //for (i=0;i<0xfff;i++);
115 105
116 return 1; 106 return 1;
117} 107}
diff --git a/arch/mips/au1000/common/dma.c b/arch/mips/au1000/common/dma.c
index 95f69ea146e9..d6fbda232e6a 100644
--- a/arch/mips/au1000/common/dma.c
+++ b/arch/mips/au1000/common/dma.c
@@ -1,12 +1,11 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * A DMA channel allocator for Au1000. API is modeled loosely off of 4 * A DMA channel allocator for Au1x00. API is modeled loosely off of
5 * linux/kernel/dma.c. 5 * linux/kernel/dma.c.
6 * 6 *
7 * Copyright 2000 MontaVista Software Inc. 7 * Copyright 2000, 2008 MontaVista Software Inc.
8 * Author: MontaVista Software, Inc. 8 * Author: MontaVista Software, Inc. <source@mvista.com>
9 * stevel@mvista.com or source@mvista.com
10 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org) 9 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
11 * 10 *
12 * This program is free software; you can redistribute it and/or modify it 11 * This program is free software; you can redistribute it and/or modify it
@@ -39,7 +38,8 @@
39#include <asm/mach-au1x00/au1000.h> 38#include <asm/mach-au1x00/au1000.h>
40#include <asm/mach-au1x00/au1000_dma.h> 39#include <asm/mach-au1x00/au1000_dma.h>
41 40
42#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1100) 41#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || \
42 defined(CONFIG_SOC_AU1100)
43/* 43/*
44 * A note on resource allocation: 44 * A note on resource allocation:
45 * 45 *
@@ -56,7 +56,6 @@
56 * returned from request_dma. 56 * returned from request_dma.
57 */ 57 */
58 58
59
60DEFINE_SPINLOCK(au1000_dma_spin_lock); 59DEFINE_SPINLOCK(au1000_dma_spin_lock);
61 60
62struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = { 61struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = {
@@ -71,7 +70,7 @@ struct dma_chan au1000_dma_table[NUM_AU1000_DMA_CHANNELS] = {
71}; 70};
72EXPORT_SYMBOL(au1000_dma_table); 71EXPORT_SYMBOL(au1000_dma_table);
73 72
74// Device FIFO addresses and default DMA modes 73/* Device FIFO addresses and default DMA modes */
75static const struct dma_dev { 74static const struct dma_dev {
76 unsigned int fifo_addr; 75 unsigned int fifo_addr;
77 unsigned int dma_mode; 76 unsigned int dma_mode;
@@ -80,8 +79,8 @@ static const struct dma_dev {
80 {UART0_ADDR + UART_RX, 0}, 79 {UART0_ADDR + UART_RX, 0},
81 {0, 0}, 80 {0, 0},
82 {0, 0}, 81 {0, 0},
83 {AC97C_DATA, DMA_DW16 }, // coherent 82 {AC97C_DATA, DMA_DW16 }, /* coherent */
84 {AC97C_DATA, DMA_DR | DMA_DW16 }, // coherent 83 {AC97C_DATA, DMA_DR | DMA_DW16 }, /* coherent */
85 {UART3_ADDR + UART_TX, DMA_DW8 | DMA_NC}, 84 {UART3_ADDR + UART_TX, DMA_DW8 | DMA_NC},
86 {UART3_ADDR + UART_RX, DMA_DR | DMA_DW8 | DMA_NC}, 85 {UART3_ADDR + UART_RX, DMA_DR | DMA_DW8 | DMA_NC},
87 {USBD_EP0RD, DMA_DR | DMA_DW8 | DMA_NC}, 86 {USBD_EP0RD, DMA_DR | DMA_DW8 | DMA_NC},
@@ -101,10 +100,10 @@ int au1000_dma_read_proc(char *buf, char **start, off_t fpos,
101 struct dma_chan *chan; 100 struct dma_chan *chan;
102 101
103 for (i = 0; i < NUM_AU1000_DMA_CHANNELS; i++) { 102 for (i = 0; i < NUM_AU1000_DMA_CHANNELS; i++) {
104 if ((chan = get_dma_chan(i)) != NULL) { 103 chan = get_dma_chan(i);
104 if (chan != NULL)
105 len += sprintf(buf + len, "%2d: %s\n", 105 len += sprintf(buf + len, "%2d: %s\n",
106 i, chan->dev_str); 106 i, chan->dev_str);
107 }
108 } 107 }
109 108
110 if (fpos >= len) { 109 if (fpos >= len) {
@@ -113,18 +112,19 @@ int au1000_dma_read_proc(char *buf, char **start, off_t fpos,
113 return 0; 112 return 0;
114 } 113 }
115 *start = buf + fpos; 114 *start = buf + fpos;
116 if ((len -= fpos) > length) 115 len -= fpos;
116 if (len > length)
117 return length; 117 return length;
118 *eof = 1; 118 *eof = 1;
119 return len; 119 return len;
120} 120}
121 121
122// Device FIFO addresses and default DMA modes - 2nd bank 122/* Device FIFO addresses and default DMA modes - 2nd bank */
123static const struct dma_dev dma_dev_table_bank2[DMA_NUM_DEV_BANK2] = { 123static const struct dma_dev dma_dev_table_bank2[DMA_NUM_DEV_BANK2] = {
124 {SD0_XMIT_FIFO, DMA_DS | DMA_DW8}, // coherent 124 { SD0_XMIT_FIFO, DMA_DS | DMA_DW8 }, /* coherent */
125 {SD0_RECV_FIFO, DMA_DS | DMA_DR | DMA_DW8}, // coherent 125 { SD0_RECV_FIFO, DMA_DS | DMA_DR | DMA_DW8 }, /* coherent */
126 {SD1_XMIT_FIFO, DMA_DS | DMA_DW8}, // coherent 126 { SD1_XMIT_FIFO, DMA_DS | DMA_DW8 }, /* coherent */
127 {SD1_RECV_FIFO, DMA_DS | DMA_DR | DMA_DW8} // coherent 127 { SD1_RECV_FIFO, DMA_DS | DMA_DR | DMA_DW8 } /* coherent */
128}; 128};
129 129
130void dump_au1000_dma_channel(unsigned int dmanr) 130void dump_au1000_dma_channel(unsigned int dmanr)
@@ -150,7 +150,6 @@ void dump_au1000_dma_channel(unsigned int dmanr)
150 au_readl(chan->io + DMA_BUFFER1_COUNT)); 150 au_readl(chan->io + DMA_BUFFER1_COUNT));
151} 151}
152 152
153
154/* 153/*
155 * Finds a free channel, and binds the requested device to it. 154 * Finds a free channel, and binds the requested device to it.
156 * Returns the allocated channel number, or negative on error. 155 * Returns the allocated channel number, or negative on error.
@@ -169,14 +168,14 @@ int request_au1000_dma(int dev_id, const char *dev_str,
169 if (dev_id < 0 || dev_id >= (DMA_NUM_DEV + DMA_NUM_DEV_BANK2)) 168 if (dev_id < 0 || dev_id >= (DMA_NUM_DEV + DMA_NUM_DEV_BANK2))
170 return -EINVAL; 169 return -EINVAL;
171#else 170#else
172 if (dev_id < 0 || dev_id >= DMA_NUM_DEV) 171 if (dev_id < 0 || dev_id >= DMA_NUM_DEV)
173 return -EINVAL; 172 return -EINVAL;
174#endif 173#endif
175 174
176 for (i = 0; i < NUM_AU1000_DMA_CHANNELS; i++) { 175 for (i = 0; i < NUM_AU1000_DMA_CHANNELS; i++)
177 if (au1000_dma_table[i].dev_id < 0) 176 if (au1000_dma_table[i].dev_id < 0)
178 break; 177 break;
179 } 178
180 if (i == NUM_AU1000_DMA_CHANNELS) 179 if (i == NUM_AU1000_DMA_CHANNELS)
181 return -ENODEV; 180 return -ENODEV;
182 181
@@ -185,15 +184,15 @@ int request_au1000_dma(int dev_id, const char *dev_str,
185 if (dev_id >= DMA_NUM_DEV) { 184 if (dev_id >= DMA_NUM_DEV) {
186 dev_id -= DMA_NUM_DEV; 185 dev_id -= DMA_NUM_DEV;
187 dev = &dma_dev_table_bank2[dev_id]; 186 dev = &dma_dev_table_bank2[dev_id];
188 } else { 187 } else
189 dev = &dma_dev_table[dev_id]; 188 dev = &dma_dev_table[dev_id];
190 }
191 189
192 if (irqhandler) { 190 if (irqhandler) {
193 chan->irq = AU1000_DMA_INT_BASE + i; 191 chan->irq = AU1000_DMA_INT_BASE + i;
194 chan->irq_dev = irq_dev_id; 192 chan->irq_dev = irq_dev_id;
195 if ((ret = request_irq(chan->irq, irqhandler, irqflags, 193 ret = request_irq(chan->irq, irqhandler, irqflags, dev_str,
196 dev_str, chan->irq_dev))) { 194 chan->irq_dev);
195 if (ret) {
197 chan->irq = 0; 196 chan->irq = 0;
198 chan->irq_dev = NULL; 197 chan->irq_dev = NULL;
199 return ret; 198 return ret;
@@ -203,7 +202,7 @@ int request_au1000_dma(int dev_id, const char *dev_str,
203 chan->irq_dev = NULL; 202 chan->irq_dev = NULL;
204 } 203 }
205 204
206 // fill it in 205 /* fill it in */
207 chan->io = DMA_CHANNEL_BASE + i * DMA_CHANNEL_LEN; 206 chan->io = DMA_CHANNEL_BASE + i * DMA_CHANNEL_LEN;
208 chan->dev_id = dev_id; 207 chan->dev_id = dev_id;
209 chan->dev_str = dev_str; 208 chan->dev_str = dev_str;
@@ -220,8 +219,9 @@ EXPORT_SYMBOL(request_au1000_dma);
220void free_au1000_dma(unsigned int dmanr) 219void free_au1000_dma(unsigned int dmanr)
221{ 220{
222 struct dma_chan *chan = get_dma_chan(dmanr); 221 struct dma_chan *chan = get_dma_chan(dmanr);
222
223 if (!chan) { 223 if (!chan) {
224 printk("Trying to free DMA%d\n", dmanr); 224 printk(KERN_ERR "Error trying to free DMA%d\n", dmanr);
225 return; 225 return;
226 } 226 }
227 227
@@ -235,4 +235,4 @@ void free_au1000_dma(unsigned int dmanr)
235} 235}
236EXPORT_SYMBOL(free_au1000_dma); 236EXPORT_SYMBOL(free_au1000_dma);
237 237
238#endif // AU1000 AU1500 AU1100 238#endif /* AU1000 AU1500 AU1100 */
diff --git a/arch/mips/au1000/common/gpio.c b/arch/mips/au1000/common/gpio.c
index 525452589971..b485d94ce8a5 100644
--- a/arch/mips/au1000/common/gpio.c
+++ b/arch/mips/au1000/common/gpio.c
@@ -69,7 +69,7 @@ static int au1xxx_gpio2_direction_output(unsigned gpio, int value)
69 69
70static int au1xxx_gpio1_read(unsigned gpio) 70static int au1xxx_gpio1_read(unsigned gpio)
71{ 71{
72 return ((gpio1->pinstaterd >> gpio) & 0x01); 72 return (gpio1->pinstaterd >> gpio) & 0x01;
73} 73}
74 74
75static void au1xxx_gpio1_write(unsigned gpio, int value) 75static void au1xxx_gpio1_write(unsigned gpio, int value)
@@ -104,7 +104,6 @@ int au1xxx_gpio_get_value(unsigned gpio)
104 else 104 else
105 return au1xxx_gpio1_read(gpio); 105 return au1xxx_gpio1_read(gpio);
106} 106}
107
108EXPORT_SYMBOL(au1xxx_gpio_get_value); 107EXPORT_SYMBOL(au1xxx_gpio_get_value);
109 108
110void au1xxx_gpio_set_value(unsigned gpio, int value) 109void au1xxx_gpio_set_value(unsigned gpio, int value)
@@ -118,7 +117,6 @@ void au1xxx_gpio_set_value(unsigned gpio, int value)
118 else 117 else
119 au1xxx_gpio1_write(gpio, value); 118 au1xxx_gpio1_write(gpio, value);
120} 119}
121
122EXPORT_SYMBOL(au1xxx_gpio_set_value); 120EXPORT_SYMBOL(au1xxx_gpio_set_value);
123 121
124int au1xxx_gpio_direction_input(unsigned gpio) 122int au1xxx_gpio_direction_input(unsigned gpio)
@@ -132,7 +130,6 @@ int au1xxx_gpio_direction_input(unsigned gpio)
132 130
133 return au1xxx_gpio1_direction_input(gpio); 131 return au1xxx_gpio1_direction_input(gpio);
134} 132}
135
136EXPORT_SYMBOL(au1xxx_gpio_direction_input); 133EXPORT_SYMBOL(au1xxx_gpio_direction_input);
137 134
138int au1xxx_gpio_direction_output(unsigned gpio, int value) 135int au1xxx_gpio_direction_output(unsigned gpio, int value)
@@ -146,5 +143,4 @@ int au1xxx_gpio_direction_output(unsigned gpio, int value)
146 143
147 return au1xxx_gpio1_direction_output(gpio, value); 144 return au1xxx_gpio1_direction_output(gpio, value);
148} 145}
149
150EXPORT_SYMBOL(au1xxx_gpio_direction_output); 146EXPORT_SYMBOL(au1xxx_gpio_direction_output);
diff --git a/arch/mips/au1000/common/irq.c b/arch/mips/au1000/common/irq.c
index f0626992fd75..40c6ceceb5f9 100644
--- a/arch/mips/au1000/common/irq.c
+++ b/arch/mips/au1000/common/irq.c
@@ -210,10 +210,8 @@ static inline void mask_and_ack_either_edge_irq(unsigned int irq_nr)
210 au_sync(); 210 au_sync();
211} 211}
212 212
213
214static inline void mask_and_ack_level_irq(unsigned int irq_nr) 213static inline void mask_and_ack_level_irq(unsigned int irq_nr)
215{ 214{
216
217 local_disable_irq(irq_nr); 215 local_disable_irq(irq_nr);
218 au_sync(); 216 au_sync();
219#if defined(CONFIG_MIPS_PB1000) 217#if defined(CONFIG_MIPS_PB1000)
@@ -263,14 +261,14 @@ void restore_local_and_enable(int controller, unsigned long mask)
263 unsigned long flags, new_mask; 261 unsigned long flags, new_mask;
264 262
265 spin_lock_irqsave(&irq_lock, flags); 263 spin_lock_irqsave(&irq_lock, flags);
266 for (i = 0; i < 32; i++) { 264 for (i = 0; i < 32; i++)
267 if (mask & (1 << i)) { 265 if (mask & (1 << i)) {
268 if (controller) 266 if (controller)
269 local_enable_irq(i + 32); 267 local_enable_irq(i + 32);
270 else 268 else
271 local_enable_irq(i); 269 local_enable_irq(i);
272 } 270 }
273 } 271
274 if (controller) 272 if (controller)
275 new_mask = au_readl(IC1_MASKSET); 273 new_mask = au_readl(IC1_MASKSET);
276 else 274 else
diff --git a/arch/mips/au1000/common/pci.c b/arch/mips/au1000/common/pci.c
index 7e966b31e3e1..7866cf50cf99 100644
--- a/arch/mips/au1000/common/pci.c
+++ b/arch/mips/au1000/common/pci.c
@@ -2,9 +2,8 @@
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Alchemy/AMD Au1x00 PCI support. 3 * Alchemy/AMD Au1x00 PCI support.
4 * 4 *
5 * Copyright 2001-2003, 2007 MontaVista Software Inc. 5 * Copyright 2001-2003, 2007-2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org) 8 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
10 * 9 *
@@ -86,9 +85,9 @@ static int __init au1x_pci_setup(void)
86 u32 prid = read_c0_prid(); 85 u32 prid = read_c0_prid();
87 86
88 if ((prid & 0xFF000000) == 0x01000000 && prid < 0x01030202) { 87 if ((prid & 0xFF000000) == 0x01000000 && prid < 0x01030202) {
89 au_writel((1 << 16) | au_readl(Au1500_PCI_CFG), 88 au_writel((1 << 16) | au_readl(Au1500_PCI_CFG),
90 Au1500_PCI_CFG); 89 Au1500_PCI_CFG);
91 printk("Non-coherent PCI accesses enabled\n"); 90 printk(KERN_INFO "Non-coherent PCI accesses enabled\n");
92 } 91 }
93 } 92 }
94#endif 93#endif
diff --git a/arch/mips/au1000/common/platform.c b/arch/mips/au1000/common/platform.c
index 31d2a2270878..8cae7753ef79 100644
--- a/arch/mips/au1000/common/platform.c
+++ b/arch/mips/au1000/common/platform.c
@@ -269,8 +269,8 @@ static struct platform_device au1x00_pcmcia_device = {
269#ifdef SMBUS_PSC_BASE 269#ifdef SMBUS_PSC_BASE
270static struct resource pbdb_smbus_resources[] = { 270static struct resource pbdb_smbus_resources[] = {
271 { 271 {
272 .start = SMBUS_PSC_BASE, 272 .start = CPHYSADDR(SMBUS_PSC_BASE),
273 .end = SMBUS_PSC_BASE + 0x24 - 1, 273 .end = CPHYSADDR(SMBUS_PSC_BASE + 0xfffff),
274 .flags = IORESOURCE_MEM, 274 .flags = IORESOURCE_MEM,
275 }, 275 },
276}; 276};
@@ -302,16 +302,17 @@ static struct platform_device *au1xxx_platform_devices[] __initdata = {
302#endif 302#endif
303}; 303};
304 304
305int __init au1xxx_platform_init(void) 305static int __init au1xxx_platform_init(void)
306{ 306{
307 unsigned int uartclk = get_au1x00_uart_baud_base() * 16; 307 unsigned int uartclk = get_au1x00_uart_baud_base() * 16;
308 int i; 308 int i;
309 309
310 /* Fill up uartclk. */ 310 /* Fill up uartclk. */
311 for (i = 0; au1x00_uart_data[i].flags ; i++) 311 for (i = 0; au1x00_uart_data[i].flags; i++)
312 au1x00_uart_data[i].uartclk = uartclk; 312 au1x00_uart_data[i].uartclk = uartclk;
313 313
314 return platform_add_devices(au1xxx_platform_devices, ARRAY_SIZE(au1xxx_platform_devices)); 314 return platform_add_devices(au1xxx_platform_devices,
315 ARRAY_SIZE(au1xxx_platform_devices));
315} 316}
316 317
317arch_initcall(au1xxx_platform_init); 318arch_initcall(au1xxx_platform_init);
diff --git a/arch/mips/au1000/common/power.c b/arch/mips/au1000/common/power.c
index a8cd2c1b9e1b..2166b9e1e80c 100644
--- a/arch/mips/au1000/common/power.c
+++ b/arch/mips/au1000/common/power.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Au1000 Power Management routines. 3 * Au1xx0 Power Management routines.
4 * 4 *
5 * Copyright 2001 MontaVista Software Inc. 5 * Copyright 2001, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * Some of the routines are right out of init/main.c, whose 8 * Some of the routines are right out of init/main.c, whose
10 * copyrights apply here. 9 * copyrights apply here.
@@ -43,10 +42,10 @@
43#ifdef CONFIG_PM 42#ifdef CONFIG_PM
44 43
45#define DEBUG 1 44#define DEBUG 1
46#ifdef DEBUG 45#ifdef DEBUG
47# define DPRINTK(fmt, args...) printk("%s: " fmt, __func__, ## args) 46#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__, ## args)
48#else 47#else
49# define DPRINTK(fmt, args...) 48#define DPRINTK(fmt, args...)
50#endif 49#endif
51 50
52static void au1000_calibrate_delay(void); 51static void au1000_calibrate_delay(void);
@@ -57,7 +56,8 @@ extern void local_enable_irq(unsigned int irq_nr);
57 56
58static DEFINE_SPINLOCK(pm_lock); 57static DEFINE_SPINLOCK(pm_lock);
59 58
60/* We need to save/restore a bunch of core registers that are 59/*
60 * We need to save/restore a bunch of core registers that are
61 * either volatile or reset to some state across a processor sleep. 61 * either volatile or reset to some state across a processor sleep.
62 * If reading a register doesn't provide a proper result for a 62 * If reading a register doesn't provide a proper result for a
63 * later restore, we have to provide a function for loading that 63 * later restore, we have to provide a function for loading that
@@ -78,24 +78,25 @@ static unsigned int sleep_usbhost_enable;
78static unsigned int sleep_usbdev_enable; 78static unsigned int sleep_usbdev_enable;
79static unsigned int sleep_static_memctlr[4][3]; 79static unsigned int sleep_static_memctlr[4][3];
80 80
81/* Define this to cause the value you write to /proc/sys/pm/sleep to 81/*
82 * Define this to cause the value you write to /proc/sys/pm/sleep to
82 * set the TOY timer for the amount of time you want to sleep. 83 * set the TOY timer for the amount of time you want to sleep.
83 * This is done mainly for testing, but may be useful in other cases. 84 * This is done mainly for testing, but may be useful in other cases.
84 * The value is number of 32KHz ticks to sleep. 85 * The value is number of 32KHz ticks to sleep.
85 */ 86 */
86#define SLEEP_TEST_TIMEOUT 1 87#define SLEEP_TEST_TIMEOUT 1
87#ifdef SLEEP_TEST_TIMEOUT 88#ifdef SLEEP_TEST_TIMEOUT
88static int sleep_ticks; 89static int sleep_ticks;
89void wakeup_counter0_set(int ticks); 90void wakeup_counter0_set(int ticks);
90#endif 91#endif
91 92
92static void 93static void save_core_regs(void)
93save_core_regs(void)
94{ 94{
95 extern void save_au1xxx_intctl(void); 95 extern void save_au1xxx_intctl(void);
96 extern void pm_eth0_shutdown(void); 96 extern void pm_eth0_shutdown(void);
97 97
98 /* Do the serial ports.....these really should be a pm_* 98 /*
99 * Do the serial ports.....these really should be a pm_*
99 * registered function by the driver......but of course the 100 * registered function by the driver......but of course the
100 * standard serial driver doesn't understand our Au1xxx 101 * standard serial driver doesn't understand our Au1xxx
101 * unique registers. 102 * unique registers.
@@ -106,27 +107,24 @@ save_core_regs(void)
106 sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK); 107 sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK);
107 sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL); 108 sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL);
108 109
109 /* Shutdown USB host/device. 110 /* Shutdown USB host/device. */
110 */
111 sleep_usbhost_enable = au_readl(USB_HOST_CONFIG); 111 sleep_usbhost_enable = au_readl(USB_HOST_CONFIG);
112 112
113 /* There appears to be some undocumented reset register.... 113 /* There appears to be some undocumented reset register.... */
114 */
115 au_writel(0, 0xb0100004); au_sync(); 114 au_writel(0, 0xb0100004); au_sync();
116 au_writel(0, USB_HOST_CONFIG); au_sync(); 115 au_writel(0, USB_HOST_CONFIG); au_sync();
117 116
118 sleep_usbdev_enable = au_readl(USBD_ENABLE); 117 sleep_usbdev_enable = au_readl(USBD_ENABLE);
119 au_writel(0, USBD_ENABLE); au_sync(); 118 au_writel(0, USBD_ENABLE); au_sync();
120 119
121 /* Save interrupt controller state. 120 /* Save interrupt controller state. */
122 */
123 save_au1xxx_intctl(); 121 save_au1xxx_intctl();
124 122
125 /* Clocks and PLLs. 123 /* Clocks and PLLs. */
126 */
127 sleep_aux_pll_cntrl = au_readl(SYS_AUXPLL); 124 sleep_aux_pll_cntrl = au_readl(SYS_AUXPLL);
128 125
129 /* We don't really need to do this one, but unless we 126 /*
127 * We don't really need to do this one, but unless we
130 * write it again it won't have a valid value if we 128 * write it again it won't have a valid value if we
131 * happen to read it. 129 * happen to read it.
132 */ 130 */
@@ -134,8 +132,7 @@ save_core_regs(void)
134 132
135 sleep_pin_function = au_readl(SYS_PINFUNC); 133 sleep_pin_function = au_readl(SYS_PINFUNC);
136 134
137 /* Save the static memory controller configuration. 135 /* Save the static memory controller configuration. */
138 */
139 sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0); 136 sleep_static_memctlr[0][0] = au_readl(MEM_STCFG0);
140 sleep_static_memctlr[0][1] = au_readl(MEM_STTIME0); 137 sleep_static_memctlr[0][1] = au_readl(MEM_STTIME0);
141 sleep_static_memctlr[0][2] = au_readl(MEM_STADDR0); 138 sleep_static_memctlr[0][2] = au_readl(MEM_STADDR0);
@@ -150,8 +147,7 @@ save_core_regs(void)
150 sleep_static_memctlr[3][2] = au_readl(MEM_STADDR3); 147 sleep_static_memctlr[3][2] = au_readl(MEM_STADDR3);
151} 148}
152 149
153static void 150static void restore_core_regs(void)
154restore_core_regs(void)
155{ 151{
156 extern void restore_au1xxx_intctl(void); 152 extern void restore_au1xxx_intctl(void);
157 extern void wakeup_counter0_adjust(void); 153 extern void wakeup_counter0_adjust(void);
@@ -160,8 +156,7 @@ restore_core_regs(void)
160 au_writel(sleep_cpu_pll_cntrl, SYS_CPUPLL); au_sync(); 156 au_writel(sleep_cpu_pll_cntrl, SYS_CPUPLL); au_sync();
161 au_writel(sleep_pin_function, SYS_PINFUNC); au_sync(); 157 au_writel(sleep_pin_function, SYS_PINFUNC); au_sync();
162 158
163 /* Restore the static memory controller configuration. 159 /* Restore the static memory controller configuration. */
164 */
165 au_writel(sleep_static_memctlr[0][0], MEM_STCFG0); 160 au_writel(sleep_static_memctlr[0][0], MEM_STCFG0);
166 au_writel(sleep_static_memctlr[0][1], MEM_STTIME0); 161 au_writel(sleep_static_memctlr[0][1], MEM_STTIME0);
167 au_writel(sleep_static_memctlr[0][2], MEM_STADDR0); 162 au_writel(sleep_static_memctlr[0][2], MEM_STADDR0);
@@ -175,7 +170,8 @@ restore_core_regs(void)
175 au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); 170 au_writel(sleep_static_memctlr[3][1], MEM_STTIME3);
176 au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); 171 au_writel(sleep_static_memctlr[3][2], MEM_STADDR3);
177 172
178 /* Enable the UART if it was enabled before sleep. 173 /*
174 * Enable the UART if it was enabled before sleep.
179 * I guess I should define module control bits........ 175 * I guess I should define module control bits........
180 */ 176 */
181 if (sleep_uart0_enable & 0x02) { 177 if (sleep_uart0_enable & 0x02) {
@@ -202,7 +198,7 @@ void wakeup_from_suspend(void)
202int au_sleep(void) 198int au_sleep(void)
203{ 199{
204 unsigned long wakeup, flags; 200 unsigned long wakeup, flags;
205 extern void save_and_sleep(void); 201 extern void save_and_sleep(void);
206 202
207 spin_lock_irqsave(&pm_lock, flags); 203 spin_lock_irqsave(&pm_lock, flags);
208 204
@@ -210,23 +206,22 @@ int au_sleep(void)
210 206
211 flush_cache_all(); 207 flush_cache_all();
212 208
213 /** The code below is all system dependent and we should probably 209 /**
210 ** The code below is all system dependent and we should probably
214 ** have a function call out of here to set this up. You need 211 ** have a function call out of here to set this up. You need
215 ** to configure the GPIO or timer interrupts that will bring 212 ** to configure the GPIO or timer interrupts that will bring
216 ** you out of sleep. 213 ** you out of sleep.
217 ** For testing, the TOY counter wakeup is useful. 214 ** For testing, the TOY counter wakeup is useful.
218 **/ 215 **/
219
220#if 0 216#if 0
221 au_writel(au_readl(SYS_PINSTATERD) & ~(1 << 11), SYS_PINSTATERD); 217 au_writel(au_readl(SYS_PINSTATERD) & ~(1 << 11), SYS_PINSTATERD);
222 218
223 /* gpio 6 can cause a wake up event */ 219 /* GPIO 6 can cause a wake up event */
224 wakeup = au_readl(SYS_WAKEMSK); 220 wakeup = au_readl(SYS_WAKEMSK);
225 wakeup &= ~(1 << 8); /* turn off match20 wakeup */ 221 wakeup &= ~(1 << 8); /* turn off match20 wakeup */
226 wakeup |= 1 << 6; /* turn on gpio 6 wakeup */ 222 wakeup |= 1 << 6; /* turn on GPIO 6 wakeup */
227#else 223#else
228 /* For testing, allow match20 to wake us up. 224 /* For testing, allow match20 to wake us up. */
229 */
230#ifdef SLEEP_TEST_TIMEOUT 225#ifdef SLEEP_TEST_TIMEOUT
231 wakeup_counter0_set(sleep_ticks); 226 wakeup_counter0_set(sleep_ticks);
232#endif 227#endif
@@ -240,7 +235,8 @@ int au_sleep(void)
240 235
241 save_and_sleep(); 236 save_and_sleep();
242 237
243 /* after a wakeup, the cpu vectors back to 0x1fc00000 so 238 /*
239 * After a wakeup, the cpu vectors back to 0x1fc00000, so
244 * it's up to the boot code to get us back here. 240 * it's up to the boot code to get us back here.
245 */ 241 */
246 restore_core_regs(); 242 restore_core_regs();
@@ -248,24 +244,22 @@ int au_sleep(void)
248 return 0; 244 return 0;
249} 245}
250 246
251static int pm_do_sleep(ctl_table * ctl, int write, struct file *file, 247static int pm_do_sleep(ctl_table *ctl, int write, struct file *file,
252 void __user *buffer, size_t * len, loff_t *ppos) 248 void __user *buffer, size_t *len, loff_t *ppos)
253{ 249{
254#ifdef SLEEP_TEST_TIMEOUT 250#ifdef SLEEP_TEST_TIMEOUT
255#define TMPBUFLEN2 16 251#define TMPBUFLEN2 16
256 char buf[TMPBUFLEN2], *p; 252 char buf[TMPBUFLEN2], *p;
257#endif 253#endif
258 254
259 if (!write) { 255 if (!write)
260 *len = 0; 256 *len = 0;
261 } else { 257 else {
262#ifdef SLEEP_TEST_TIMEOUT 258#ifdef SLEEP_TEST_TIMEOUT
263 if (*len > TMPBUFLEN2 - 1) { 259 if (*len > TMPBUFLEN2 - 1)
264 return -EFAULT; 260 return -EFAULT;
265 } 261 if (copy_from_user(buf, buffer, *len))
266 if (copy_from_user(buf, buffer, *len)) {
267 return -EFAULT; 262 return -EFAULT;
268 }
269 buf[*len] = 0; 263 buf[*len] = 0;
270 p = buf; 264 p = buf;
271 sleep_ticks = simple_strtoul(p, &p, 0); 265 sleep_ticks = simple_strtoul(p, &p, 0);
@@ -276,8 +270,8 @@ static int pm_do_sleep(ctl_table * ctl, int write, struct file *file,
276 return 0; 270 return 0;
277} 271}
278 272
279static int pm_do_freq(ctl_table * ctl, int write, struct file *file, 273static int pm_do_freq(ctl_table *ctl, int write, struct file *file,
280 void __user *buffer, size_t * len, loff_t *ppos) 274 void __user *buffer, size_t *len, loff_t *ppos)
281{ 275{
282 int retval = 0, i; 276 int retval = 0, i;
283 unsigned long val, pll; 277 unsigned long val, pll;
@@ -285,14 +279,14 @@ static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
285#define MAX_CPU_FREQ 396 279#define MAX_CPU_FREQ 396
286 char buf[TMPBUFLEN], *p; 280 char buf[TMPBUFLEN], *p;
287 unsigned long flags, intc0_mask, intc1_mask; 281 unsigned long flags, intc0_mask, intc1_mask;
288 unsigned long old_baud_base, old_cpu_freq, baud_rate, old_clk, 282 unsigned long old_baud_base, old_cpu_freq, old_clk, old_refresh;
289 old_refresh;
290 unsigned long new_baud_base, new_cpu_freq, new_clk, new_refresh; 283 unsigned long new_baud_base, new_cpu_freq, new_clk, new_refresh;
284 unsigned long baud_rate;
291 285
292 spin_lock_irqsave(&pm_lock, flags); 286 spin_lock_irqsave(&pm_lock, flags);
293 if (!write) { 287 if (!write)
294 *len = 0; 288 *len = 0;
295 } else { 289 else {
296 /* Parse the new frequency */ 290 /* Parse the new frequency */
297 if (*len > TMPBUFLEN - 1) { 291 if (*len > TMPBUFLEN - 1) {
298 spin_unlock_irqrestore(&pm_lock, flags); 292 spin_unlock_irqrestore(&pm_lock, flags);
@@ -312,7 +306,7 @@ static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
312 306
313 pll = val / 12; 307 pll = val / 12;
314 if ((pll > 33) || (pll < 7)) { /* 396 MHz max, 84 MHz min */ 308 if ((pll > 33) || (pll < 7)) { /* 396 MHz max, 84 MHz min */
315 /* revisit this for higher speed cpus */ 309 /* Revisit this for higher speed CPUs */
316 spin_unlock_irqrestore(&pm_lock, flags); 310 spin_unlock_irqrestore(&pm_lock, flags);
317 return -EFAULT; 311 return -EFAULT;
318 } 312 }
@@ -321,30 +315,28 @@ static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
321 old_cpu_freq = get_au1x00_speed(); 315 old_cpu_freq = get_au1x00_speed();
322 316
323 new_cpu_freq = pll * 12 * 1000000; 317 new_cpu_freq = pll * 12 * 1000000;
324 new_baud_base = (new_cpu_freq / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); 318 new_baud_base = (new_cpu_freq / (2 * ((int)(au_readl(SYS_POWERCTRL)
319 & 0x03) + 2) * 16));
325 set_au1x00_speed(new_cpu_freq); 320 set_au1x00_speed(new_cpu_freq);
326 set_au1x00_uart_baud_base(new_baud_base); 321 set_au1x00_uart_baud_base(new_baud_base);
327 322
328 old_refresh = au_readl(MEM_SDREFCFG) & 0x1ffffff; 323 old_refresh = au_readl(MEM_SDREFCFG) & 0x1ffffff;
329 new_refresh = 324 new_refresh = ((old_refresh * new_cpu_freq) / old_cpu_freq) |
330 ((old_refresh * new_cpu_freq) / 325 (au_readl(MEM_SDREFCFG) & ~0x1ffffff);
331 old_cpu_freq) | (au_readl(MEM_SDREFCFG) & ~0x1ffffff);
332 326
333 au_writel(pll, SYS_CPUPLL); 327 au_writel(pll, SYS_CPUPLL);
334 au_sync_delay(1); 328 au_sync_delay(1);
335 au_writel(new_refresh, MEM_SDREFCFG); 329 au_writel(new_refresh, MEM_SDREFCFG);
336 au_sync_delay(1); 330 au_sync_delay(1);
337 331
338 for (i = 0; i < 4; i++) { 332 for (i = 0; i < 4; i++)
339 if (au_readl 333 if (au_readl(UART_BASE + UART_MOD_CNTRL +
340 (UART_BASE + UART_MOD_CNTRL + 334 i * 0x00100000) == 3) {
341 i * 0x00100000) == 3) { 335 old_clk = au_readl(UART_BASE + UART_CLK +
342 old_clk = 336 i * 0x00100000);
343 au_readl(UART_BASE + UART_CLK +
344 i * 0x00100000);
345 // baud_rate = baud_base/clk
346 baud_rate = old_baud_base / old_clk; 337 baud_rate = old_baud_base / old_clk;
347 /* we won't get an exact baud rate and the error 338 /*
339 * We won't get an exact baud rate and the error
348 * could be significant enough that our new 340 * could be significant enough that our new
349 * calculation will result in a clock that will 341 * calculation will result in a clock that will
350 * give us a baud rate that's too far off from 342 * give us a baud rate that's too far off from
@@ -359,18 +351,14 @@ static int pm_do_freq(ctl_table * ctl, int write, struct file *file,
359 else if (baud_rate > 17000) 351 else if (baud_rate > 17000)
360 baud_rate = 19200; 352 baud_rate = 19200;
361 else 353 else
362 (baud_rate = 9600); 354 baud_rate = 9600;
363 // new_clk = new_baud_base/baud_rate
364 new_clk = new_baud_base / baud_rate; 355 new_clk = new_baud_base / baud_rate;
365 au_writel(new_clk, 356 au_writel(new_clk, UART_BASE + UART_CLK +
366 UART_BASE + UART_CLK + 357 i * 0x00100000);
367 i * 0x00100000);
368 au_sync_delay(10); 358 au_sync_delay(10);
369 } 359 }
370 }
371 } 360 }
372 361
373
374 /* 362 /*
375 * We don't want _any_ interrupts other than match20. Otherwise our 363 * We don't want _any_ interrupts other than match20. Otherwise our
376 * au1000_calibrate_delay() calculation will be off, potentially a lot. 364 * au1000_calibrate_delay() calculation will be off, potentially a lot.
@@ -428,14 +416,15 @@ static int __init pm_init(void)
428 416
429__initcall(pm_init); 417__initcall(pm_init);
430 418
431
432/* 419/*
433 * This is right out of init/main.c 420 * This is right out of init/main.c
434 */ 421 */
435 422
436/* This is the number of bits of precision for the loops_per_jiffy. Each 423/*
437 bit takes on average 1.5/HZ seconds. This (like the original) is a little 424 * This is the number of bits of precision for the loops_per_jiffy.
438 better than 1% */ 425 * Each bit takes on average 1.5/HZ seconds. This (like the original)
426 * is a little better than 1%.
427 */
439#define LPS_PREC 8 428#define LPS_PREC 8
440 429
441static void au1000_calibrate_delay(void) 430static void au1000_calibrate_delay(void)
@@ -443,14 +432,14 @@ static void au1000_calibrate_delay(void)
443 unsigned long ticks, loopbit; 432 unsigned long ticks, loopbit;
444 int lps_precision = LPS_PREC; 433 int lps_precision = LPS_PREC;
445 434
446 loops_per_jiffy = (1 << 12); 435 loops_per_jiffy = 1 << 12;
447 436
448 while (loops_per_jiffy <<= 1) { 437 while (loops_per_jiffy <<= 1) {
449 /* wait for "start of" clock tick */ 438 /* Wait for "start of" clock tick */
450 ticks = jiffies; 439 ticks = jiffies;
451 while (ticks == jiffies) 440 while (ticks == jiffies)
452 /* nothing */ ; 441 /* nothing */ ;
453 /* Go .. */ 442 /* Go ... */
454 ticks = jiffies; 443 ticks = jiffies;
455 __delay(loops_per_jiffy); 444 __delay(loops_per_jiffy);
456 ticks = jiffies - ticks; 445 ticks = jiffies - ticks;
@@ -458,8 +447,10 @@ static void au1000_calibrate_delay(void)
458 break; 447 break;
459 } 448 }
460 449
461/* Do a binary approximation to get loops_per_jiffy set to equal one clock 450 /*
462 (up to lps_precision bits) */ 451 * Do a binary approximation to get loops_per_jiffy set to be equal
452 * one clock (up to lps_precision bits)
453 */
463 loops_per_jiffy >>= 1; 454 loops_per_jiffy >>= 1;
464 loopbit = loops_per_jiffy; 455 loopbit = loops_per_jiffy;
465 while (lps_precision-- && (loopbit >>= 1)) { 456 while (lps_precision-- && (loopbit >>= 1)) {
@@ -472,4 +463,4 @@ static void au1000_calibrate_delay(void)
472 loops_per_jiffy &= ~loopbit; 463 loops_per_jiffy &= ~loopbit;
473 } 464 }
474} 465}
475#endif /* CONFIG_PM */ 466#endif /* CONFIG_PM */
diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c
index f10af829e4ec..18b310b475ca 100644
--- a/arch/mips/au1000/common/prom.c
+++ b/arch/mips/au1000/common/prom.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * PROM library initialisation code, supports YAMON and U-Boot. 4 * PROM library initialisation code, supports YAMON and U-Boot.
5 * 5 *
6 * Copyright 2000, 2001, 2006 MontaVista Software Inc. 6 * Copyright 2000-2001, 2006, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This file was derived from Carsten Langgaard's 9 * This file was derived from Carsten Langgaard's
11 * arch/mips/mips-boards/xx files. 10 * arch/mips/mips-boards/xx files.
@@ -57,7 +56,7 @@ void prom_init_cmdline(void)
57 actr = 1; /* Always ignore argv[0] */ 56 actr = 1; /* Always ignore argv[0] */
58 57
59 cp = &(arcs_cmdline[0]); 58 cp = &(arcs_cmdline[0]);
60 while(actr < prom_argc) { 59 while (actr < prom_argc) {
61 strcpy(cp, prom_argv[actr]); 60 strcpy(cp, prom_argv[actr]);
62 cp += strlen(prom_argv[actr]); 61 cp += strlen(prom_argv[actr]);
63 *cp++ = ' '; 62 *cp++ = ' ';
@@ -84,10 +83,8 @@ char *prom_getenv(char *envname)
84 if (yamon) { 83 if (yamon) {
85 if (strcmp(envname, *env++) == 0) 84 if (strcmp(envname, *env++) == 0)
86 return *env; 85 return *env;
87 } else { 86 } else if (strncmp(envname, *env, i) == 0 && (*env)[i] == '=')
88 if (strncmp(envname, *env, i) == 0 && (*env)[i] == '=') 87 return *env + i + 1;
89 return *env + i + 1;
90 }
91 env++; 88 env++;
92 } 89 }
93 90
@@ -110,13 +107,13 @@ static inline void str2eaddr(unsigned char *ea, unsigned char *str)
110{ 107{
111 int i; 108 int i;
112 109
113 for(i = 0; i < 6; i++) { 110 for (i = 0; i < 6; i++) {
114 unsigned char num; 111 unsigned char num;
115 112
116 if((*str == '.') || (*str == ':')) 113 if ((*str == '.') || (*str == ':'))
117 str++; 114 str++;
118 num = str2hexnum(*str++) << 4; 115 num = str2hexnum(*str++) << 4;
119 num |= (str2hexnum(*str++)); 116 num |= str2hexnum(*str++);
120 ea[i] = num; 117 ea[i] = num;
121 } 118 }
122} 119}
diff --git a/arch/mips/au1000/common/puts.c b/arch/mips/au1000/common/puts.c
index e34c67e89293..55bbe24d45b6 100644
--- a/arch/mips/au1000/common/puts.c
+++ b/arch/mips/au1000/common/puts.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Low level uart routines to directly access a 16550 uart. 4 * Low level UART routines to directly access Alchemy UART.
5 * 5 *
6 * Copyright 2001 MontaVista Software Inc. 6 * Copyright 2001, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -40,12 +39,12 @@
40 39
41static volatile unsigned long * const com1 = (unsigned long *)SERIAL_BASE; 40static volatile unsigned long * const com1 = (unsigned long *)SERIAL_BASE;
42 41
43
44#ifdef SLOW_DOWN 42#ifdef SLOW_DOWN
45static inline void slow_down(void) 43static inline void slow_down(void)
46{ 44{
47 int k; 45 int k;
48 for (k=0; k<10000; k++); 46
47 for (k = 0; k < 10000; k++);
49} 48}
50#else 49#else
51#define slow_down() 50#define slow_down()
@@ -54,16 +53,16 @@ static inline void slow_down(void)
54void 53void
55prom_putchar(const unsigned char c) 54prom_putchar(const unsigned char c)
56{ 55{
57 unsigned char ch; 56 unsigned char ch;
58 int i = 0; 57 int i = 0;
58
59 do {
60 ch = com1[SER_CMD];
61 slow_down();
62 i++;
63 if (i > TIMEOUT)
64 break;
65 } while (0 == (ch & TX_BUSY));
59 66
60 do { 67 com1[SER_DATA] = c;
61 ch = com1[SER_CMD];
62 slow_down();
63 i++;
64 if (i>TIMEOUT) {
65 break;
66 }
67 } while (0 == (ch & TX_BUSY));
68 com1[SER_DATA] = c;
69} 68}
diff --git a/arch/mips/au1000/common/reset.c b/arch/mips/au1000/common/reset.c
index 60cec537c745..d555429c8d6f 100644
--- a/arch/mips/au1000/common/reset.c
+++ b/arch/mips/au1000/common/reset.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Au1000 reset routines. 4 * Au1xx0 reset routines.
5 * 5 *
6 * Copyright 2001 MontaVista Software Inc. 6 * Copyright 2001, 2006, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -28,10 +27,11 @@
28 * 675 Mass Ave, Cambridge, MA 02139, USA. 27 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 28 */
30 29
30#include <asm/cacheflush.h>
31
31#include <asm/mach-au1x00/au1000.h> 32#include <asm/mach-au1x00/au1000.h>
32 33
33extern int au_sleep(void); 34extern int au_sleep(void);
34extern void (*flush_cache_all)(void);
35 35
36void au1000_restart(char *command) 36void au1000_restart(char *command)
37{ 37{
@@ -40,8 +40,8 @@ void au1000_restart(char *command)
40 u32 prid = read_c0_prid(); 40 u32 prid = read_c0_prid();
41 41
42 printk(KERN_NOTICE "\n** Resetting Integrated Peripherals\n"); 42 printk(KERN_NOTICE "\n** Resetting Integrated Peripherals\n");
43 switch (prid & 0xFF000000) 43
44 { 44 switch (prid & 0xFF000000) {
45 case 0x00000000: /* Au1000 */ 45 case 0x00000000: /* Au1000 */
46 au_writel(0x02, 0xb0000010); /* ac97_enable */ 46 au_writel(0x02, 0xb0000010); /* ac97_enable */
47 au_writel(0x08, 0xb017fffc); /* usbh_enable - early errata */ 47 au_writel(0x08, 0xb017fffc); /* usbh_enable - early errata */
@@ -138,9 +138,6 @@ void au1000_restart(char *command)
138 au_writel(0x00, 0xb1900064); /* sys_auxpll */ 138 au_writel(0x00, 0xb1900064); /* sys_auxpll */
139 au_writel(0x00, 0xb1900100); /* sys_pininputen */ 139 au_writel(0x00, 0xb1900100); /* sys_pininputen */
140 break; 140 break;
141
142 default:
143 break;
144 } 141 }
145 142
146 set_c0_status(ST0_BEV | ST0_ERL); 143 set_c0_status(ST0_BEV | ST0_ERL);
@@ -158,25 +155,25 @@ void au1000_restart(char *command)
158void au1000_halt(void) 155void au1000_halt(void)
159{ 156{
160#if defined(CONFIG_MIPS_PB1550) || defined(CONFIG_MIPS_DB1550) 157#if defined(CONFIG_MIPS_PB1550) || defined(CONFIG_MIPS_DB1550)
161 /* power off system */ 158 /* Power off system */
162 printk("\n** Powering off...\n"); 159 printk(KERN_NOTICE "\n** Powering off...\n");
163 au_writew(au_readw(0xAF00001C) | (3<<14), 0xAF00001C); 160 au_writew(au_readw(0xAF00001C) | (3 << 14), 0xAF00001C);
164 au_sync(); 161 au_sync();
165 while(1); /* should not get here */ 162 while (1); /* should not get here */
166#else 163#else
167 printk(KERN_NOTICE "\n** You can safely turn off the power\n"); 164 printk(KERN_NOTICE "\n** You can safely turn off the power\n");
168#ifdef CONFIG_MIPS_MIRAGE 165#ifdef CONFIG_MIPS_MIRAGE
169 au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT); 166 au_writel((1 << 26) | (1 << 10), GPIO2_OUTPUT);
170#endif 167#endif
171#ifdef CONFIG_MIPS_DB1200 168#ifdef CONFIG_MIPS_DB1200
172 au_writew(au_readw(0xB980001C) | (1<<14), 0xB980001C); 169 au_writew(au_readw(0xB980001C) | (1 << 14), 0xB980001C);
173#endif 170#endif
174#ifdef CONFIG_PM 171#ifdef CONFIG_PM
175 au_sleep(); 172 au_sleep();
176 173
177 /* should not get here */ 174 /* Should not get here */
178 printk(KERN_ERR "Unable to put cpu in sleep mode\n"); 175 printk(KERN_ERR "Unable to put CPU in sleep mode\n");
179 while(1); 176 while (1);
180#else 177#else
181 while (1) 178 while (1)
182 __asm__(".set\tmips3\n\t" 179 __asm__(".set\tmips3\n\t"
diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c
index 0e86f7a6b4a7..1ac6b06f42a3 100644
--- a/arch/mips/au1000/common/setup.c
+++ b/arch/mips/au1000/common/setup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Copyright 2000 MontaVista Software Inc. 2 * Copyright 2000, 2007-2008 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc. 3 * Author: MontaVista Software, Inc. <source@mvista.com
4 * ppopov@mvista.com or source@mvista.com
5 * 4 *
6 * Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc. 5 * Updates to 2.6, Pete Popov, Embedded Alley Solutions, Inc.
7 * 6 *
@@ -48,7 +47,7 @@ void __init plat_mem_setup(void)
48{ 47{
49 struct cpu_spec *sp; 48 struct cpu_spec *sp;
50 char *argptr; 49 char *argptr;
51 unsigned long prid, cpufreq, bclk = 1; 50 unsigned long prid, cpufreq, bclk;
52 51
53 set_cpuspec(); 52 set_cpuspec();
54 sp = cur_cpu_spec[0]; 53 sp = cur_cpu_spec[0];
@@ -66,42 +65,39 @@ void __init plat_mem_setup(void)
66 cpufreq = (au_readl(SYS_CPUPLL) & 0x3F) * 12; 65 cpufreq = (au_readl(SYS_CPUPLL) & 0x3F) * 12;
67 printk(KERN_INFO "(PRID %08lx) @ %ld MHz\n", prid, cpufreq); 66 printk(KERN_INFO "(PRID %08lx) @ %ld MHz\n", prid, cpufreq);
68 67
69 bclk = sp->cpu_bclk; 68 if (sp->cpu_bclk) {
70 if (bclk)
71 {
72 /* Enable BCLK switching */ 69 /* Enable BCLK switching */
73 bclk = au_readl(0xB190003C); 70 bclk = au_readl(SYS_POWERCTRL);
74 au_writel(bclk | 0x60, 0xB190003C); 71 au_writel(bclk | 0x60, SYS_POWERCTRL);
75 printk("BCLK switching enabled!\n"); 72 printk(KERN_INFO "BCLK switching enabled!\n");
76 } 73 }
77 74
78 if (sp->cpu_od) { 75 if (sp->cpu_od)
79 /* Various early Au1000 Errata corrected by this */ 76 /* Various early Au1xx0 errata corrected by this */
80 set_c0_config(1<<19); /* Set Config[OD] */ 77 set_c0_config(1 << 19); /* Set Config[OD] */
81 } 78 else
82 else {
83 /* Clear to obtain best system bus performance */ 79 /* Clear to obtain best system bus performance */
84 clear_c0_config(1<<19); /* Clear Config[OD] */ 80 clear_c0_config(1 << 19); /* Clear Config[OD] */
85 }
86 81
87 argptr = prom_getcmdline(); 82 argptr = prom_getcmdline();
88 83
89#ifdef CONFIG_SERIAL_8250_CONSOLE 84#ifdef CONFIG_SERIAL_8250_CONSOLE
90 if ((argptr = strstr(argptr, "console=")) == NULL) { 85 argptr = strstr(argptr, "console=");
86 if (argptr == NULL) {
91 argptr = prom_getcmdline(); 87 argptr = prom_getcmdline();
92 strcat(argptr, " console=ttyS0,115200"); 88 strcat(argptr, " console=ttyS0,115200");
93 } 89 }
94#endif 90#endif
95 91
96#ifdef CONFIG_FB_AU1100 92#ifdef CONFIG_FB_AU1100
97 if ((argptr = strstr(argptr, "video=")) == NULL) { 93 argptr = strstr(argptr, "video=");
98 argptr = prom_getcmdline(); 94 if (argptr == NULL) {
99 /* default panel */ 95 argptr = prom_getcmdline();
100 /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/ 96 /* default panel */
101 } 97 /*strcat(argptr, " video=au1100fb:panel:Sharp_320x240_16");*/
98 }
102#endif 99#endif
103 100
104
105#if defined(CONFIG_SOUND_AU1X00) && !defined(CONFIG_SOC_AU1000) 101#if defined(CONFIG_SOUND_AU1X00) && !defined(CONFIG_SOC_AU1000)
106 /* au1000 does not support vra, au1500 and au1100 do */ 102 /* au1000 does not support vra, au1500 and au1100 do */
107 strcat(argptr, " au1000_audio=vra"); 103 strcat(argptr, " au1000_audio=vra");
@@ -129,7 +125,7 @@ void __init plat_mem_setup(void)
129/* This routine should be valid for all Au1x based boards */ 125/* This routine should be valid for all Au1x based boards */
130phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size) 126phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
131{ 127{
132 /* Don't fixup 36 bit addresses */ 128 /* Don't fixup 36-bit addresses */
133 if ((phys_addr >> 32) != 0) 129 if ((phys_addr >> 32) != 0)
134 return phys_addr; 130 return phys_addr;
135 131
@@ -145,17 +141,17 @@ phys_t __fixup_bigphys_addr(phys_t phys_addr, phys_t size)
145 } 141 }
146#endif 142#endif
147 143
148 /* All Au1x SOCs have a pcmcia controller */ 144 /*
149 /* We setup our 32 bit pseudo addresses to be equal to the 145 * All Au1xx0 SOCs have a PCMCIA controller.
150 * 36 bit addr >> 4, to make it easier to check the address 146 * We setup our 32-bit pseudo addresses to be equal to the
147 * 36-bit addr >> 4, to make it easier to check the address
151 * and fix it. 148 * and fix it.
152 * The Au1x socket 0 phys attribute address is 0xF 4000 0000. 149 * The PCMCIA socket 0 physical attribute address is 0xF 4000 0000.
153 * The pseudo address we use is 0xF400 0000. Any address over 150 * The pseudo address we use is 0xF400 0000. Any address over
154 * 0xF400 0000 is a pcmcia pseudo address. 151 * 0xF400 0000 is a PCMCIA pseudo address.
155 */ 152 */
156 if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF)) { 153 if ((phys_addr >= 0xF4000000) && (phys_addr < 0xFFFFFFFF))
157 return (phys_t)(phys_addr << 4); 154 return (phys_t)(phys_addr << 4);
158 }
159 155
160 /* default nop */ 156 /* default nop */
161 return phys_addr; 157 return phys_addr;
diff --git a/arch/mips/au1000/common/time.c b/arch/mips/au1000/common/time.c
index bdb6d73b26fb..563d9390a872 100644
--- a/arch/mips/au1000/common/time.c
+++ b/arch/mips/au1000/common/time.c
@@ -25,11 +25,9 @@
25 * 25 *
26 * Setting up the clock on the MIPS boards. 26 * Setting up the clock on the MIPS boards.
27 * 27 *
28 * Update. Always configure the kernel with CONFIG_NEW_TIME_C. This 28 * We provide the clock interrupt processing and the timer offset compute
29 * will use the user interface gettimeofday() functions from the 29 * functions. If CONFIG_PM is selected, we also ensure the 32KHz timer is
30 * arch/mips/kernel/time.c, and we provide the clock interrupt processing 30 * available. -- Dan
31 * and the timer offset compute functions. If CONFIG_PM is selected,
32 * we also ensure the 32KHz timer is available. -- Dan
33 */ 31 */
34 32
35#include <linux/types.h> 33#include <linux/types.h>
@@ -47,8 +45,7 @@ extern int allow_au1k_wait; /* default off for CP0 Counter */
47#if HZ < 100 || HZ > 1000 45#if HZ < 100 || HZ > 1000
48#error "unsupported HZ value! Must be in [100,1000]" 46#error "unsupported HZ value! Must be in [100,1000]"
49#endif 47#endif
50#define MATCH20_INC (328*100/HZ) /* magic number 328 is for HZ=100... */ 48#define MATCH20_INC (328 * 100 / HZ) /* magic number 328 is for HZ=100... */
51extern void startup_match20_interrupt(irq_handler_t handler);
52static unsigned long last_pc0, last_match20; 49static unsigned long last_pc0, last_match20;
53#endif 50#endif
54 51
@@ -61,7 +58,7 @@ static irqreturn_t counter0_irq(int irq, void *dev_id)
61{ 58{
62 unsigned long pc0; 59 unsigned long pc0;
63 int time_elapsed; 60 int time_elapsed;
64 static int jiffie_drift = 0; 61 static int jiffie_drift;
65 62
66 if (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) { 63 if (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20) {
67 /* should never happen! */ 64 /* should never happen! */
@@ -70,13 +67,11 @@ static irqreturn_t counter0_irq(int irq, void *dev_id)
70 } 67 }
71 68
72 pc0 = au_readl(SYS_TOYREAD); 69 pc0 = au_readl(SYS_TOYREAD);
73 if (pc0 < last_match20) { 70 if (pc0 < last_match20)
74 /* counter overflowed */ 71 /* counter overflowed */
75 time_elapsed = (0xffffffff - last_match20) + pc0; 72 time_elapsed = (0xffffffff - last_match20) + pc0;
76 } 73 else
77 else {
78 time_elapsed = pc0 - last_match20; 74 time_elapsed = pc0 - last_match20;
79 }
80 75
81 while (time_elapsed > 0) { 76 while (time_elapsed > 0) {
82 do_timer(1); 77 do_timer(1);
@@ -92,8 +87,9 @@ static irqreturn_t counter0_irq(int irq, void *dev_id)
92 au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); 87 au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2);
93 au_sync(); 88 au_sync();
94 89
95 /* our counter ticks at 10.009765625 ms/tick, we we're running 90 /*
96 * almost 10uS too slow per tick. 91 * Our counter ticks at 10.009765625 ms/tick, we we're running
92 * almost 10 uS too slow per tick.
97 */ 93 */
98 94
99 if (jiffie_drift >= 999) { 95 if (jiffie_drift >= 999) {
@@ -117,20 +113,17 @@ struct irqaction counter0_action = {
117/* When we wakeup from sleep, we have to "catch up" on all of the 113/* When we wakeup from sleep, we have to "catch up" on all of the
118 * timer ticks we have missed. 114 * timer ticks we have missed.
119 */ 115 */
120void 116void wakeup_counter0_adjust(void)
121wakeup_counter0_adjust(void)
122{ 117{
123 unsigned long pc0; 118 unsigned long pc0;
124 int time_elapsed; 119 int time_elapsed;
125 120
126 pc0 = au_readl(SYS_TOYREAD); 121 pc0 = au_readl(SYS_TOYREAD);
127 if (pc0 < last_match20) { 122 if (pc0 < last_match20)
128 /* counter overflowed */ 123 /* counter overflowed */
129 time_elapsed = (0xffffffff - last_match20) + pc0; 124 time_elapsed = (0xffffffff - last_match20) + pc0;
130 } 125 else
131 else {
132 time_elapsed = pc0 - last_match20; 126 time_elapsed = pc0 - last_match20;
133 }
134 127
135 while (time_elapsed > 0) { 128 while (time_elapsed > 0) {
136 time_elapsed -= MATCH20_INC; 129 time_elapsed -= MATCH20_INC;
@@ -143,10 +136,8 @@ wakeup_counter0_adjust(void)
143 136
144} 137}
145 138
146/* This is just for debugging to set the timer for a sleep delay. 139/* This is just for debugging to set the timer for a sleep delay. */
147*/ 140void wakeup_counter0_set(int ticks)
148void
149wakeup_counter0_set(int ticks)
150{ 141{
151 unsigned long pc0; 142 unsigned long pc0;
152 143
@@ -157,21 +148,22 @@ wakeup_counter0_set(int ticks)
157} 148}
158#endif 149#endif
159 150
160/* I haven't found anyone that doesn't use a 12 MHz source clock, 151/*
152 * I haven't found anyone that doesn't use a 12 MHz source clock,
161 * but just in case..... 153 * but just in case.....
162 */ 154 */
163#define AU1000_SRC_CLK 12000000 155#define AU1000_SRC_CLK 12000000
164 156
165/* 157/*
166 * We read the real processor speed from the PLL. This is important 158 * We read the real processor speed from the PLL. This is important
167 * because it is more accurate than computing it from the 32KHz 159 * because it is more accurate than computing it from the 32 KHz
168 * counter, if it exists. If we don't have an accurate processor 160 * counter, if it exists. If we don't have an accurate processor
169 * speed, all of the peripherals that derive their clocks based on 161 * speed, all of the peripherals that derive their clocks based on
170 * this advertised speed will introduce error and sometimes not work 162 * this advertised speed will introduce error and sometimes not work
171 * properly. This function is futher convoluted to still allow configurations 163 * properly. This function is futher convoluted to still allow configurations
172 * to do that in case they have really, really old silicon with a 164 * to do that in case they have really, really old silicon with a
173 * write-only PLL register, that we need the 32KHz when power management 165 * write-only PLL register, that we need the 32 KHz when power management
174 * "wait" is enabled, and we need to detect if the 32KHz isn't present 166 * "wait" is enabled, and we need to detect if the 32 KHz isn't present
175 * but requested......got it? :-) -- Dan 167 * but requested......got it? :-) -- Dan
176 */ 168 */
177unsigned long calc_clock(void) 169unsigned long calc_clock(void)
@@ -182,8 +174,7 @@ unsigned long calc_clock(void)
182 174
183 spin_lock_irqsave(&time_lock, flags); 175 spin_lock_irqsave(&time_lock, flags);
184 176
185 /* Power management cares if we don't have a 32KHz counter. 177 /* Power management cares if we don't have a 32 KHz counter. */
186 */
187 no_au1xxx_32khz = 0; 178 no_au1xxx_32khz = 0;
188 counter = au_readl(SYS_COUNTER_CNTRL); 179 counter = au_readl(SYS_COUNTER_CNTRL);
189 if (counter & SYS_CNTRL_E0) { 180 if (counter & SYS_CNTRL_E0) {
@@ -193,7 +184,7 @@ unsigned long calc_clock(void)
193 184
194 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); 185 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S);
195 /* RTC now ticks at 32.768/16 kHz */ 186 /* RTC now ticks at 32.768/16 kHz */
196 au_writel(trim_divide-1, SYS_RTCTRIM); 187 au_writel(trim_divide - 1, SYS_RTCTRIM);
197 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S); 188 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S);
198 189
199 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S); 190 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S);
@@ -215,9 +206,11 @@ unsigned long calc_clock(void)
215#endif 206#endif
216 else 207 else
217 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK; 208 cpu_speed = (au_readl(SYS_CPUPLL) & 0x0000003f) * AU1000_SRC_CLK;
209 /* On Alchemy CPU:counter ratio is 1:1 */
218 mips_hpt_frequency = cpu_speed; 210 mips_hpt_frequency = cpu_speed;
219 // Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) 211 /* Equation: Baudrate = CPU / (SD * 2 * CLKDIV * 16) */
220 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)&0x03) + 2) * 16)); 212 set_au1x00_uart_baud_base(cpu_speed / (2 * ((int)(au_readl(SYS_POWERCTRL)
213 & 0x03) + 2) * 16));
221 spin_unlock_irqrestore(&time_lock, flags); 214 spin_unlock_irqrestore(&time_lock, flags);
222 return cpu_speed; 215 return cpu_speed;
223} 216}
@@ -228,10 +221,10 @@ void __init plat_time_init(void)
228 221
229 est_freq += 5000; /* round */ 222 est_freq += 5000; /* round */
230 est_freq -= est_freq%10000; 223 est_freq -= est_freq%10000;
231 printk("CPU frequency %d.%02d MHz\n", est_freq/1000000, 224 printk(KERN_INFO "CPU frequency %u.%02u MHz\n",
232 (est_freq%1000000)*100/1000000); 225 est_freq / 1000000, ((est_freq % 1000000) * 100) / 1000000);
233 set_au1x00_speed(est_freq); 226 set_au1x00_speed(est_freq);
234 set_au1x00_lcd_clock(); // program the LCD clock 227 set_au1x00_lcd_clock(); /* program the LCD clock */
235 228
236#ifdef CONFIG_PM 229#ifdef CONFIG_PM
237 /* 230 /*
@@ -243,30 +236,29 @@ void __init plat_time_init(void)
243 * counter 0 interrupt as a special irq and it doesn't show 236 * counter 0 interrupt as a special irq and it doesn't show
244 * up under /proc/interrupts. 237 * up under /proc/interrupts.
245 * 238 *
246 * Check to ensure we really have a 32KHz oscillator before 239 * Check to ensure we really have a 32 KHz oscillator before
247 * we do this. 240 * we do this.
248 */ 241 */
249 if (no_au1xxx_32khz) 242 if (no_au1xxx_32khz)
250 printk("WARNING: no 32KHz clock found.\n"); 243 printk(KERN_WARNING "WARNING: no 32KHz clock found.\n");
251 else { 244 else {
252 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); 245 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S);
253 au_writel(0, SYS_TOYWRITE); 246 au_writel(0, SYS_TOYWRITE);
254 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S); 247 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C0S);
255 248
256 au_writel(au_readl(SYS_WAKEMSK) | (1<<8), SYS_WAKEMSK); 249 au_writel(au_readl(SYS_WAKEMSK) | (1 << 8), SYS_WAKEMSK);
257 au_writel(~0, SYS_WAKESRC); 250 au_writel(~0, SYS_WAKESRC);
258 au_sync(); 251 au_sync();
259 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); 252 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
260 253
261 /* setup match20 to interrupt once every HZ */ 254 /* Setup match20 to interrupt once every HZ */
262 last_pc0 = last_match20 = au_readl(SYS_TOYREAD); 255 last_pc0 = last_match20 = au_readl(SYS_TOYREAD);
263 au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2); 256 au_writel(last_match20 + MATCH20_INC, SYS_TOYMATCH2);
264 au_sync(); 257 au_sync();
265 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20); 258 while (au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_M20);
266 setup_irq(AU1000_TOY_MATCH2_INT, &counter0_action); 259 setup_irq(AU1000_TOY_MATCH2_INT, &counter0_action);
267 260
268 /* We can use the real 'wait' instruction. 261 /* We can use the real 'wait' instruction. */
269 */
270 allow_au1k_wait = 1; 262 allow_au1k_wait = 1;
271 } 263 }
272 264
diff --git a/arch/mips/au1000/db1x00/Makefile b/arch/mips/au1000/db1x00/Makefile
index 51d62bd5d900..274db3b55d82 100644
--- a/arch/mips/au1000/db1x00/Makefile
+++ b/arch/mips/au1000/db1x00/Makefile
@@ -1,8 +1,8 @@
1# 1#
2# Copyright 2000 MontaVista Software Inc. 2# Copyright 2000, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com 4#
5# Makefile for the Alchemy Semiconductor DBAu1xx0 boards.
5# 6#
6# Makefile for the Alchemy Semiconductor Db1x00 board.
7 7
8lib-y := init.o board_setup.o irqmap.o 8lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/db1x00/board_setup.c b/arch/mips/au1000/db1x00/board_setup.c
index b7dcbad5c586..9e5ccbbfcedd 100644
--- a/arch/mips/au1000/db1x00/board_setup.c
+++ b/arch/mips/au1000/db1x00/board_setup.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Alchemy Db1x00 board setup. 4 * Alchemy Db1x00 board setup.
5 * 5 *
6 * Copyright 2000 MontaVista Software Inc. 6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -37,49 +36,49 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
37 36
38void board_reset(void) 37void board_reset(void)
39{ 38{
40 /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ 39 /* Hit BCSR.SW_RESET[RESET] */
41 bcsr->swreset = 0x0000; 40 bcsr->swreset = 0x0000;
42} 41}
43 42
44void __init board_setup(void) 43void __init board_setup(void)
45{ 44{
46 u32 pin_func; 45 u32 pin_func = 0;
47 46
48 pin_func = 0; 47 /* Not valid for Au1550 */
49 /* not valid for 1550 */ 48#if defined(CONFIG_IRDA) && \
50 49 (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100))
51#if defined(CONFIG_IRDA) && (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) 50 /* Set IRFIRSEL instead of GPIO15 */
52 /* set IRFIRSEL instead of GPIO15 */ 51 pin_func = au_readl(SYS_PINFUNC) | SYS_PF_IRF;
53 pin_func = au_readl(SYS_PINFUNC) | (u32)((1<<8));
54 au_writel(pin_func, SYS_PINFUNC); 52 au_writel(pin_func, SYS_PINFUNC);
55 /* power off until the driver is in use */ 53 /* Power off until the driver is in use */
56 bcsr->resets &= ~BCSR_RESETS_IRDA_MODE_MASK; 54 bcsr->resets &= ~BCSR_RESETS_IRDA_MODE_MASK;
57 bcsr->resets |= BCSR_RESETS_IRDA_MODE_OFF; 55 bcsr->resets |= BCSR_RESETS_IRDA_MODE_OFF;
58 au_sync(); 56 au_sync();
59#endif 57#endif
60 bcsr->pcmcia = 0x0000; /* turn off PCMCIA power */ 58 bcsr->pcmcia = 0x0000; /* turn off PCMCIA power */
61 59
62#ifdef CONFIG_MIPS_MIRAGE 60#ifdef CONFIG_MIPS_MIRAGE
63 /* enable GPIO[31:0] inputs */ 61 /* Enable GPIO[31:0] inputs */
64 au_writel(0, SYS_PININPUTEN); 62 au_writel(0, SYS_PININPUTEN);
65 63
66 /* GPIO[20] is output, tristate the other input primary GPIO's */ 64 /* GPIO[20] is output, tristate the other input primary GPIOs */
67 au_writel((u32)(~(1<<20)), SYS_TRIOUTCLR); 65 au_writel(~(1 << 20), SYS_TRIOUTCLR);
68 66
69 /* set GPIO[210:208] instead of SSI_0 */ 67 /* Set GPIO[210:208] instead of SSI_0 */
70 pin_func = au_readl(SYS_PINFUNC) | (u32)(1); 68 pin_func = au_readl(SYS_PINFUNC) | SYS_PF_S0;
71 69
72 /* set GPIO[215:211] for LED's */ 70 /* Set GPIO[215:211] for LEDs */
73 pin_func |= (u32)((5<<2)); 71 pin_func |= 5 << 2;
74 72
75 /* set GPIO[214:213] for more LED's */ 73 /* Set GPIO[214:213] for more LEDs */
76 pin_func |= (u32)((5<<12)); 74 pin_func |= 5 << 12;
77 75
78 /* set GPIO[207:200] instead of PCMCIA/LCD */ 76 /* Set GPIO[207:200] instead of PCMCIA/LCD */
79 pin_func |= (u32)((3<<17)); 77 pin_func |= SYS_PF_LCD | SYS_PF_PC;
80 au_writel(pin_func, SYS_PINFUNC); 78 au_writel(pin_func, SYS_PINFUNC);
81 79
82 /* Enable speaker amplifier. This should 80 /*
81 * Enable speaker amplifier. This should
83 * be part of the audio driver. 82 * be part of the audio driver.
84 */ 83 */
85 au_writel(au_readl(GPIO2_DIR) | 0x200, GPIO2_DIR); 84 au_writel(au_readl(GPIO2_DIR) | 0x200, GPIO2_DIR);
@@ -89,21 +88,21 @@ void __init board_setup(void)
89 au_sync(); 88 au_sync();
90 89
91#ifdef CONFIG_MIPS_DB1000 90#ifdef CONFIG_MIPS_DB1000
92 printk("AMD Alchemy Au1000/Db1000 Board\n"); 91 printk(KERN_INFO "AMD Alchemy Au1000/Db1000 Board\n");
93#endif 92#endif
94#ifdef CONFIG_MIPS_DB1500 93#ifdef CONFIG_MIPS_DB1500
95 printk("AMD Alchemy Au1500/Db1500 Board\n"); 94 printk(KERN_INFO "AMD Alchemy Au1500/Db1500 Board\n");
96#endif 95#endif
97#ifdef CONFIG_MIPS_DB1100 96#ifdef CONFIG_MIPS_DB1100
98 printk("AMD Alchemy Au1100/Db1100 Board\n"); 97 printk(KERN_INFO "AMD Alchemy Au1100/Db1100 Board\n");
99#endif 98#endif
100#ifdef CONFIG_MIPS_BOSPORUS 99#ifdef CONFIG_MIPS_BOSPORUS
101 printk("AMD Alchemy Bosporus Board\n"); 100 printk(KERN_INFO "AMD Alchemy Bosporus Board\n");
102#endif 101#endif
103#ifdef CONFIG_MIPS_MIRAGE 102#ifdef CONFIG_MIPS_MIRAGE
104 printk("AMD Alchemy Mirage Board\n"); 103 printk(KERN_INFO "AMD Alchemy Mirage Board\n");
105#endif 104#endif
106#ifdef CONFIG_MIPS_DB1550 105#ifdef CONFIG_MIPS_DB1550
107 printk("AMD Alchemy Au1550/Db1550 Board\n"); 106 printk(KERN_INFO "AMD Alchemy Au1550/Db1550 Board\n");
108#endif 107#endif
109} 108}
diff --git a/arch/mips/au1000/db1x00/init.c b/arch/mips/au1000/db1x00/init.c
index d3b967caf70c..5ebe0de5e459 100644
--- a/arch/mips/au1000/db1x00/init.c
+++ b/arch/mips/au1000/db1x00/init.c
@@ -2,9 +2,8 @@
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * PB1000 board setup 3 * PB1000 board setup
4 * 4 *
5 * Copyright 2001 MontaVista Software Inc. 5 * Copyright 2001, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
@@ -49,8 +48,8 @@ void __init prom_init(void)
49 unsigned long memsize; 48 unsigned long memsize;
50 49
51 prom_argc = fw_arg0; 50 prom_argc = fw_arg0;
52 prom_argv = (char **) fw_arg1; 51 prom_argv = (char **)fw_arg1;
53 prom_envp = (char **) fw_arg2; 52 prom_envp = (char **)fw_arg2;
54 53
55 prom_init_cmdline(); 54 prom_init_cmdline();
56 55
@@ -58,6 +57,6 @@ void __init prom_init(void)
58 if (!memsize_str) 57 if (!memsize_str)
59 memsize = 0x04000000; 58 memsize = 0x04000000;
60 else 59 else
61 memsize = simple_strtol(memsize_str, NULL, 0); 60 memsize = strict_strtol(memsize_str, 0, NULL);
62 add_memory_region(0, memsize, BOOT_MEM_RAM); 61 add_memory_region(0, memsize, BOOT_MEM_RAM);
63} 62}
diff --git a/arch/mips/au1000/db1x00/irqmap.c b/arch/mips/au1000/db1x00/irqmap.c
index eaa50c7b6341..94c090e8bf7a 100644
--- a/arch/mips/au1000/db1x00/irqmap.c
+++ b/arch/mips/au1000/db1x00/irqmap.c
@@ -32,32 +32,32 @@
32 32
33#ifdef CONFIG_MIPS_DB1500 33#ifdef CONFIG_MIPS_DB1500
34char irq_tab_alchemy[][5] __initdata = { 34char irq_tab_alchemy[][5] __initdata = {
35 [12] = { -1, INTA, INTX, INTX, INTX}, /* IDSEL 12 - HPT371 */ 35 [12] = { -1, INTA, INTX, INTX, INTX }, /* IDSEL 12 - HPT371 */
36 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot */ 36 [13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot */
37}; 37};
38#endif 38#endif
39 39
40#ifdef CONFIG_MIPS_BOSPORUS 40#ifdef CONFIG_MIPS_BOSPORUS
41char irq_tab_alchemy[][5] __initdata = { 41char irq_tab_alchemy[][5] __initdata = {
42 [11] = { -1, INTA, INTB, INTX, INTX}, /* IDSEL 11 - miniPCI */ 42 [11] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 11 - miniPCI */
43 [12] = { -1, INTA, INTX, INTX, INTX}, /* IDSEL 12 - SN1741 */ 43 [12] = { -1, INTA, INTX, INTX, INTX }, /* IDSEL 12 - SN1741 */
44 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot */ 44 [13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot */
45}; 45};
46#endif 46#endif
47 47
48#ifdef CONFIG_MIPS_MIRAGE 48#ifdef CONFIG_MIPS_MIRAGE
49char irq_tab_alchemy[][5] __initdata = { 49char irq_tab_alchemy[][5] __initdata = {
50 [11] = { -1, INTD, INTX, INTX, INTX}, /* IDSEL 11 - SMI VGX */ 50 [11] = { -1, INTD, INTX, INTX, INTX }, /* IDSEL 11 - SMI VGX */
51 [12] = { -1, INTX, INTX, INTC, INTX}, /* IDSEL 12 - PNX1300 */ 51 [12] = { -1, INTX, INTX, INTC, INTX }, /* IDSEL 12 - PNX1300 */
52 [13] = { -1, INTA, INTB, INTX, INTX}, /* IDSEL 13 - miniPCI */ 52 [13] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 13 - miniPCI */
53}; 53};
54#endif 54#endif
55 55
56#ifdef CONFIG_MIPS_DB1550 56#ifdef CONFIG_MIPS_DB1550
57char irq_tab_alchemy[][5] __initdata = { 57char irq_tab_alchemy[][5] __initdata = {
58 [11] = { -1, INTC, INTX, INTX, INTX}, /* IDSEL 11 - on-board HPT371 */ 58 [11] = { -1, INTC, INTX, INTX, INTX }, /* IDSEL 11 - on-board HPT371 */
59 [12] = { -1, INTB, INTC, INTD, INTA}, /* IDSEL 12 - PCI slot 2 (left) */ 59 [12] = { -1, INTB, INTC, INTD, INTA }, /* IDSEL 12 - PCI slot 2 (left) */
60 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot 1 (right) */ 60 [13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot 1 (right) */
61}; 61};
62#endif 62#endif
63 63
diff --git a/arch/mips/au1000/mtx-1/Makefile b/arch/mips/au1000/mtx-1/Makefile
index 85a90941de4f..7c67b3d33bec 100644
--- a/arch/mips/au1000/mtx-1/Makefile
+++ b/arch/mips/au1000/mtx-1/Makefile
@@ -1,7 +1,6 @@
1# 1#
2# Copyright 2003 MontaVista Software Inc. 2# Copyright 2003 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# Bruno Randolf <bruno.randolf@4g-systems.biz> 4# Bruno Randolf <bruno.randolf@4g-systems.biz>
6# 5#
7# Makefile for 4G Systems MTX-1 board. 6# Makefile for 4G Systems MTX-1 board.
diff --git a/arch/mips/au1000/mtx-1/board_setup.c b/arch/mips/au1000/mtx-1/board_setup.c
index 5736354829c6..3f8079186cf2 100644
--- a/arch/mips/au1000/mtx-1/board_setup.c
+++ b/arch/mips/au1000/mtx-1/board_setup.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * 4G Systems MTX-1 board setup. 4 * 4G Systems MTX-1 board setup.
5 * 5 *
6 * Copyright 2003 MontaVista Software Inc. 6 * Copyright 2003, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * Bruno Randolf <bruno.randolf@4g-systems.biz> 8 * Bruno Randolf <bruno.randolf@4g-systems.biz>
10 * 9 *
11 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
@@ -34,7 +33,7 @@
34#include <asm/mach-au1x00/au1000.h> 33#include <asm/mach-au1x00/au1000.h>
35 34
36extern int (*board_pci_idsel)(unsigned int devsel, int assert); 35extern int (*board_pci_idsel)(unsigned int devsel, int assert);
37int mtx1_pci_idsel(unsigned int devsel, int assert); 36int mtx1_pci_idsel(unsigned int devsel, int assert);
38 37
39void board_reset(void) 38void board_reset(void)
40{ 39{
@@ -45,36 +44,36 @@ void board_reset(void)
45void __init board_setup(void) 44void __init board_setup(void)
46{ 45{
47#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 46#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
48 // enable USB power switch 47 /* Enable USB power switch */
49 au_writel( au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR ); 48 au_writel(au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR);
50 au_writel( 0x100000, GPIO2_OUTPUT ); 49 au_writel(0x100000, GPIO2_OUTPUT);
51#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 50#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
52 51
53#ifdef CONFIG_PCI 52#ifdef CONFIG_PCI
54#if defined(__MIPSEB__) 53#if defined(__MIPSEB__)
55 au_writel(0xf | (2<<6) | (1<<4), Au1500_PCI_CFG); 54 au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
56#else 55#else
57 au_writel(0xf, Au1500_PCI_CFG); 56 au_writel(0xf, Au1500_PCI_CFG);
58#endif 57#endif
59#endif 58#endif
60 59
61 // initialize sys_pinfunc: 60 /* Initialize sys_pinfunc */
62 au_writel( SYS_PF_NI2, SYS_PINFUNC ); 61 au_writel(SYS_PF_NI2, SYS_PINFUNC);
63 62
64 // initialize GPIO 63 /* Initialize GPIO */
65 au_writel( 0xFFFFFFFF, SYS_TRIOUTCLR ); 64 au_writel(0xFFFFFFFF, SYS_TRIOUTCLR);
66 au_writel( 0x00000001, SYS_OUTPUTCLR ); // set M66EN (PCI 66MHz) to OFF 65 au_writel(0x00000001, SYS_OUTPUTCLR); /* set M66EN (PCI 66MHz) to OFF */
67 au_writel( 0x00000008, SYS_OUTPUTSET ); // set PCI CLKRUN# to OFF 66 au_writel(0x00000008, SYS_OUTPUTSET); /* set PCI CLKRUN# to OFF */
68 au_writel( 0x00000002, SYS_OUTPUTSET ); // set EXT_IO3 ON 67 au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
69 au_writel( 0x00000020, SYS_OUTPUTCLR ); // set eth PHY TX_ER to OFF 68 au_writel(0x00000020, SYS_OUTPUTCLR); /* set eth PHY TX_ER to OFF */
70 69
71 // enable LED and set it to green 70 /* Enable LED and set it to green */
72 au_writel( au_readl(GPIO2_DIR) | 0x1800, GPIO2_DIR ); 71 au_writel(au_readl(GPIO2_DIR) | 0x1800, GPIO2_DIR);
73 au_writel( 0x18000800, GPIO2_OUTPUT ); 72 au_writel(0x18000800, GPIO2_OUTPUT);
74 73
75 board_pci_idsel = mtx1_pci_idsel; 74 board_pci_idsel = mtx1_pci_idsel;
76 75
77 printk("4G Systems MTX-1 Board\n"); 76 printk(KERN_INFO "4G Systems MTX-1 Board\n");
78} 77}
79 78
80int 79int
@@ -82,20 +81,18 @@ mtx1_pci_idsel(unsigned int devsel, int assert)
82{ 81{
83#define MTX_IDSEL_ONLY_0_AND_3 0 82#define MTX_IDSEL_ONLY_0_AND_3 0
84#if MTX_IDSEL_ONLY_0_AND_3 83#if MTX_IDSEL_ONLY_0_AND_3
85 if (devsel != 0 && devsel != 3) { 84 if (devsel != 0 && devsel != 3) {
86 printk("*** not 0 or 3\n"); 85 printk(KERN_ERR "*** not 0 or 3\n");
87 return 0; 86 return 0;
88 } 87 }
89#endif 88#endif
90 89
91 if (assert && devsel != 0) { 90 if (assert && devsel != 0)
92 // suppress signal to cardbus 91 /* Suppress signal to Cardbus */
93 au_writel( 0x00000002, SYS_OUTPUTCLR ); // set EXT_IO3 OFF 92 au_writel(0x00000002, SYS_OUTPUTCLR); /* set EXT_IO3 OFF */
94 } 93 else
95 else { 94 au_writel(0x00000002, SYS_OUTPUTSET); /* set EXT_IO3 ON */
96 au_writel( 0x00000002, SYS_OUTPUTSET ); // set EXT_IO3 ON 95 au_sync_udelay(1);
97 } 96 return 1;
98 au_sync_udelay(1);
99 return 1;
100} 97}
101 98
diff --git a/arch/mips/au1000/mtx-1/init.c b/arch/mips/au1000/mtx-1/init.c
index c015cbce1cca..33a4aebe0cba 100644
--- a/arch/mips/au1000/mtx-1/init.c
+++ b/arch/mips/au1000/mtx-1/init.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * 4G Systems MTX-1 board setup 4 * 4G Systems MTX-1 board setup
5 * 5 *
6 * Copyright 2003 MontaVista Software Inc. 6 * Copyright 2003, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * Bruno Randolf <bruno.randolf@4g-systems.biz> 8 * Bruno Randolf <bruno.randolf@4g-systems.biz>
10 * 9 *
11 * This program is free software; you can redistribute it and/or modify it 10 * This program is free software; you can redistribute it and/or modify it
@@ -47,8 +46,8 @@ void __init prom_init(void)
47 unsigned long memsize; 46 unsigned long memsize;
48 47
49 prom_argc = fw_arg0; 48 prom_argc = fw_arg0;
50 prom_argv = (char **) fw_arg1; 49 prom_argv = (char **)fw_arg1;
51 prom_envp = (char **) fw_arg2; 50 prom_envp = (char **)fw_arg2;
52 51
53 prom_init_cmdline(); 52 prom_init_cmdline();
54 53
@@ -56,6 +55,6 @@ void __init prom_init(void)
56 if (!memsize_str) 55 if (!memsize_str)
57 memsize = 0x04000000; 56 memsize = 0x04000000;
58 else 57 else
59 memsize = simple_strtol(memsize_str, NULL, 0); 58 memsize = strict_strtol(memsize_str, 0, NULL);
60 add_memory_region(0, memsize, BOOT_MEM_RAM); 59 add_memory_region(0, memsize, BOOT_MEM_RAM);
61} 60}
diff --git a/arch/mips/au1000/mtx-1/irqmap.c b/arch/mips/au1000/mtx-1/irqmap.c
index 78d70c42c9db..f2bf02951e9c 100644
--- a/arch/mips/au1000/mtx-1/irqmap.c
+++ b/arch/mips/au1000/mtx-1/irqmap.c
@@ -31,18 +31,18 @@
31#include <asm/mach-au1x00/au1000.h> 31#include <asm/mach-au1x00/au1000.h>
32 32
33char irq_tab_alchemy[][5] __initdata = { 33char irq_tab_alchemy[][5] __initdata = {
34 [0] = { -1, INTA, INTA, INTX, INTX}, /* IDSEL 00 - AdapterA-Slot0 (top) */ 34 [0] = { -1, INTA, INTA, INTX, INTX }, /* IDSEL 00 - AdapterA-Slot0 (top) */
35 [1] = { -1, INTB, INTA, INTX, INTX}, /* IDSEL 01 - AdapterA-Slot1 (bottom) */ 35 [1] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 01 - AdapterA-Slot1 (bottom) */
36 [2] = { -1, INTC, INTD, INTX, INTX}, /* IDSEL 02 - AdapterB-Slot0 (top) */ 36 [2] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 02 - AdapterB-Slot0 (top) */
37 [3] = { -1, INTD, INTC, INTX, INTX}, /* IDSEL 03 - AdapterB-Slot1 (bottom) */ 37 [3] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 03 - AdapterB-Slot1 (bottom) */
38 [4] = { -1, INTA, INTB, INTX, INTX}, /* IDSEL 04 - AdapterC-Slot0 (top) */ 38 [4] = { -1, INTA, INTB, INTX, INTX }, /* IDSEL 04 - AdapterC-Slot0 (top) */
39 [5] = { -1, INTB, INTA, INTX, INTX}, /* IDSEL 05 - AdapterC-Slot1 (bottom) */ 39 [5] = { -1, INTB, INTA, INTX, INTX }, /* IDSEL 05 - AdapterC-Slot1 (bottom) */
40 [6] = { -1, INTC, INTD, INTX, INTX}, /* IDSEL 06 - AdapterD-Slot0 (top) */ 40 [6] = { -1, INTC, INTD, INTX, INTX }, /* IDSEL 06 - AdapterD-Slot0 (top) */
41 [7] = { -1, INTD, INTC, INTX, INTX}, /* IDSEL 07 - AdapterD-Slot1 (bottom) */ 41 [7] = { -1, INTD, INTC, INTX, INTX }, /* IDSEL 07 - AdapterD-Slot1 (bottom) */
42}; 42};
43 43
44struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 44struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
45 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 45 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0 },
46 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 46 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
47 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 47 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
48 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 }, 48 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 },
diff --git a/arch/mips/au1000/mtx-1/platform.c b/arch/mips/au1000/mtx-1/platform.c
index a7edbf0829ac..9807be37c32f 100644
--- a/arch/mips/au1000/mtx-1/platform.c
+++ b/arch/mips/au1000/mtx-1/platform.c
@@ -21,11 +21,10 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23#include <linux/leds.h> 23#include <linux/leds.h>
24#include <linux/gpio.h>
24#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
25#include <linux/input.h> 26#include <linux/input.h>
26 27
27#include <asm/gpio.h>
28
29static struct gpio_keys_button mtx1_gpio_button[] = { 28static struct gpio_keys_button mtx1_gpio_button[] = {
30 { 29 {
31 .gpio = 207, 30 .gpio = 207,
diff --git a/arch/mips/au1000/pb1000/Makefile b/arch/mips/au1000/pb1000/Makefile
index daa1a507e72f..99bbec0ca41b 100644
--- a/arch/mips/au1000/pb1000/Makefile
+++ b/arch/mips/au1000/pb1000/Makefile
@@ -1,8 +1,8 @@
1# 1#
2# Copyright 2000 MontaVista Software Inc. 2# Copyright 2000, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com 4#
5# Makefile for the Alchemy Semiconductor Pb1000 board.
5# 6#
6# Makefile for the Alchemy Semiconductor PB1000 board.
7 7
8lib-y := init.o board_setup.o irqmap.o 8lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/pb1000/board_setup.c b/arch/mips/au1000/pb1000/board_setup.c
index 33f15acc1b17..25df167a95b3 100644
--- a/arch/mips/au1000/pb1000/board_setup.c
+++ b/arch/mips/au1000/pb1000/board_setup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Copyright 2000 MontaVista Software Inc. 2 * Copyright 2000, 2008 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc. 3 * Author: MontaVista Software, Inc. <source@mvista.com>
4 * ppopov@mvista.com or source@mvista.com
5 * 4 *
6 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 6 * under the terms of the GNU General Public License as published by the
@@ -40,128 +39,126 @@ void __init board_setup(void)
40 u32 sys_freqctrl, sys_clksrc; 39 u32 sys_freqctrl, sys_clksrc;
41 u32 prid = read_c0_prid(); 40 u32 prid = read_c0_prid();
42 41
43 // set AUX clock to 12MHz * 8 = 96 MHz 42 /* Set AUX clock to 12 MHz * 8 = 96 MHz */
44 au_writel(8, SYS_AUXPLL); 43 au_writel(8, SYS_AUXPLL);
45 au_writel(0, SYS_PINSTATERD); 44 au_writel(0, SYS_PINSTATERD);
46 udelay(100); 45 udelay(100);
47 46
48#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 47#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
49 /* zero and disable FREQ2 */ 48 /* Zero and disable FREQ2 */
50 sys_freqctrl = au_readl(SYS_FREQCTRL0); 49 sys_freqctrl = au_readl(SYS_FREQCTRL0);
51 sys_freqctrl &= ~0xFFF00000; 50 sys_freqctrl &= ~0xFFF00000;
52 au_writel(sys_freqctrl, SYS_FREQCTRL0); 51 au_writel(sys_freqctrl, SYS_FREQCTRL0);
53 52
54 /* zero and disable USBH/USBD clocks */ 53 /* Zero and disable USBH/USBD clocks */
55 sys_clksrc = au_readl(SYS_CLKSRC); 54 sys_clksrc = au_readl(SYS_CLKSRC);
56 sys_clksrc &= ~0x00007FE0; 55 sys_clksrc &= ~(SYS_CS_CUD | SYS_CS_DUD | SYS_CS_MUD_MASK |
56 SYS_CS_CUH | SYS_CS_DUH | SYS_CS_MUH_MASK);
57 au_writel(sys_clksrc, SYS_CLKSRC); 57 au_writel(sys_clksrc, SYS_CLKSRC);
58 58
59 sys_freqctrl = au_readl(SYS_FREQCTRL0); 59 sys_freqctrl = au_readl(SYS_FREQCTRL0);
60 sys_freqctrl &= ~0xFFF00000; 60 sys_freqctrl &= ~0xFFF00000;
61 61
62 sys_clksrc = au_readl(SYS_CLKSRC); 62 sys_clksrc = au_readl(SYS_CLKSRC);
63 sys_clksrc &= ~0x00007FE0; 63 sys_clksrc &= ~(SYS_CS_CUD | SYS_CS_DUD | SYS_CS_MUD_MASK |
64 SYS_CS_CUH | SYS_CS_DUH | SYS_CS_MUH_MASK);
64 65
65 switch (prid & 0x000000FF) 66 switch (prid & 0x000000FF) {
66 {
67 case 0x00: /* DA */ 67 case 0x00: /* DA */
68 case 0x01: /* HA */ 68 case 0x01: /* HA */
69 case 0x02: /* HB */ 69 case 0x02: /* HB */
70 /* CPU core freq to 48MHz to slow it way down... */ 70 /* CPU core freq to 48 MHz to slow it way down... */
71 au_writel(4, SYS_CPUPLL); 71 au_writel(4, SYS_CPUPLL);
72 72
73 /* 73 /*
74 * Setup 48MHz FREQ2 from CPUPLL for USB Host 74 * Setup 48 MHz FREQ2 from CPUPLL for USB Host
75 */ 75 * FRDIV2 = 3 -> div by 8 of 384 MHz -> 48 MHz
76 /* FRDIV2=3 -> div by 8 of 384MHz -> 48MHz */ 76 */
77 sys_freqctrl |= ((3<<22) | (1<<21) | (0<<20)); 77 sys_freqctrl |= (3 << SYS_FC_FRDIV2_BIT) | SYS_FC_FE2;
78 au_writel(sys_freqctrl, SYS_FREQCTRL0); 78 au_writel(sys_freqctrl, SYS_FREQCTRL0);
79 79
80 /* CPU core freq to 384MHz */ 80 /* CPU core freq to 384 MHz */
81 au_writel(0x20, SYS_CPUPLL); 81 au_writel(0x20, SYS_CPUPLL);
82 82
83 printk("Au1000: 48MHz OHCI workaround enabled\n"); 83 printk(KERN_INFO "Au1000: 48 MHz OHCI workaround enabled\n");
84 break; 84 break;
85 85
86 default: /* HC and newer */ 86 default: /* HC and newer */
87 // FREQ2 = aux/2 = 48 MHz 87 /* FREQ2 = aux / 2 = 48 MHz */
88 sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20)); 88 sys_freqctrl |= (0 << SYS_FC_FRDIV2_BIT) |
89 au_writel(sys_freqctrl, SYS_FREQCTRL0); 89 SYS_FC_FE2 | SYS_FC_FS2;
90 au_writel(sys_freqctrl, SYS_FREQCTRL0);
90 break; 91 break;
91 } 92 }
92 93
93 /* 94 /*
94 * Route 48MHz FREQ2 into USB Host and/or Device 95 * Route 48 MHz FREQ2 into USB Host and/or Device
95 */ 96 */
96#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 97 sys_clksrc |= SYS_CS_MUX_FQ2 << SYS_CS_MUH_BIT;
97 sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
98#endif
99 au_writel(sys_clksrc, SYS_CLKSRC); 98 au_writel(sys_clksrc, SYS_CLKSRC);
100 99
101 // configure pins GPIO[14:9] as GPIO 100 /* Configure pins GPIO[14:9] as GPIO */
102 pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080); 101 pin_func = au_readl(SYS_PINFUNC) & ~(SYS_PF_UR3 | SYS_PF_USB);
103 102
104 // 2nd USB port is USB host 103 /* 2nd USB port is USB host */
105 pin_func |= 0x8000; 104 pin_func |= SYS_PF_USB;
106 105
107 au_writel(pin_func, SYS_PINFUNC); 106 au_writel(pin_func, SYS_PINFUNC);
108 au_writel(0x2800, SYS_TRIOUTCLR); 107 au_writel(0x2800, SYS_TRIOUTCLR);
109 au_writel(0x0030, SYS_OUTPUTCLR); 108 au_writel(0x0030, SYS_OUTPUTCLR);
110#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 109#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
111 110
112 // make gpio 15 an input (for interrupt line) 111 /* Make GPIO 15 an input (for interrupt line) */
113 pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x100); 112 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_IRF;
114 // we don't need I2S, so make it available for GPIO[31:29] 113 /* We don't need I2S, so make it available for GPIO[31:29] */
115 pin_func |= (1<<5); 114 pin_func |= SYS_PF_I2S;
116 au_writel(pin_func, SYS_PINFUNC); 115 au_writel(pin_func, SYS_PINFUNC);
117 116
118 au_writel(0x8000, SYS_TRIOUTCLR); 117 au_writel(0x8000, SYS_TRIOUTCLR);
119 118
120 static_cfg0 = au_readl(MEM_STCFG0) & (u32)(~0xc00); 119 static_cfg0 = au_readl(MEM_STCFG0) & ~0xc00;
121 au_writel(static_cfg0, MEM_STCFG0); 120 au_writel(static_cfg0, MEM_STCFG0);
122 121
123 // configure RCE2* for LCD 122 /* configure RCE2* for LCD */
124 au_writel(0x00000004, MEM_STCFG2); 123 au_writel(0x00000004, MEM_STCFG2);
125 124
126 // MEM_STTIME2 125 /* MEM_STTIME2 */
127 au_writel(0x09000000, MEM_STTIME2); 126 au_writel(0x09000000, MEM_STTIME2);
128 127
129 // Set 32-bit base address decoding for RCE2* 128 /* Set 32-bit base address decoding for RCE2* */
130 au_writel(0x10003ff0, MEM_STADDR2); 129 au_writel(0x10003ff0, MEM_STADDR2);
131 130
132 // PCI CPLD setup 131 /*
133 // expand CE0 to cover PCI 132 * PCI CPLD setup
133 * Expand CE0 to cover PCI
134 */
134 au_writel(0x11803e40, MEM_STADDR1); 135 au_writel(0x11803e40, MEM_STADDR1);
135 136
136 // burst visibility on 137 /* Burst visibility on */
137 au_writel(au_readl(MEM_STCFG0) | 0x1000, MEM_STCFG0); 138 au_writel(au_readl(MEM_STCFG0) | 0x1000, MEM_STCFG0);
138 139
139 au_writel(0x83, MEM_STCFG1); // ewait enabled, flash timing 140 au_writel(0x83, MEM_STCFG1); /* ewait enabled, flash timing */
140 au_writel(0x33030a10, MEM_STTIME1); // slower timing for FPGA 141 au_writel(0x33030a10, MEM_STTIME1); /* slower timing for FPGA */
141 142
142 /* setup the static bus controller */ 143 /* Setup the static bus controller */
143 au_writel(0x00000002, MEM_STCFG3); /* type = PCMCIA */ 144 au_writel(0x00000002, MEM_STCFG3); /* type = PCMCIA */
144 au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */ 145 au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */
145 au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */ 146 au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */
146 147
147#ifdef CONFIG_PCI 148 /*
148 au_writel(0, PCI_BRIDGE_CONFIG); // set extend byte to 0 149 * Enable Au1000 BCLK switching - note: sed1356 must not use
149 au_writel(0, SDRAM_MBAR); // set mbar to 0 150 * its BCLK (Au1000 LCLK) for any timings
150 au_writel(0x2, SDRAM_CMD); // enable memory accesses 151 */
151 au_sync_delay(1); 152 switch (prid & 0x000000FF) {
152#endif
153
154 /* Enable Au1000 BCLK switching - note: sed1356 must not use
155 * its BCLK (Au1000 LCLK) for any timings */
156 switch (prid & 0x000000FF)
157 {
158 case 0x00: /* DA */ 153 case 0x00: /* DA */
159 case 0x01: /* HA */ 154 case 0x01: /* HA */
160 case 0x02: /* HB */ 155 case 0x02: /* HB */
161 break; 156 break;
162 default: /* HC and newer */ 157 default: /* HC and newer */
163 /* Enable sys bus clock divider when IDLE state or no bus 158 /*
164 activity. */ 159 * Enable sys bus clock divider when IDLE state or no bus
160 * activity.
161 */
165 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); 162 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
166 break; 163 break;
167 } 164 }
diff --git a/arch/mips/au1000/pb1000/init.c b/arch/mips/au1000/pb1000/init.c
index 549447df71d6..3837365d613d 100644
--- a/arch/mips/au1000/pb1000/init.c
+++ b/arch/mips/au1000/pb1000/init.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * PB1000 board setup 3 * Pb1000 board setup
4 * 4 *
5 * Copyright 2001 MontaVista Software Inc. 5 * Copyright 2001, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
@@ -44,16 +43,15 @@ void __init prom_init(void)
44 unsigned char *memsize_str; 43 unsigned char *memsize_str;
45 unsigned long memsize; 44 unsigned long memsize;
46 45
47 prom_argc = (int) fw_arg0; 46 prom_argc = (int)fw_arg0;
48 prom_argv = (char **) fw_arg1; 47 prom_argv = (char **)fw_arg1;
49 prom_envp = (char **) fw_arg2; 48 prom_envp = (char **)fw_arg2;
50 49
51 prom_init_cmdline(); 50 prom_init_cmdline();
52 memsize_str = prom_getenv("memsize"); 51 memsize_str = prom_getenv("memsize");
53 if (!memsize_str) { 52 if (!memsize_str)
54 memsize = 0x04000000; 53 memsize = 0x04000000;
55 } else { 54 else
56 memsize = simple_strtol(memsize_str, NULL, 0); 55 memsize = strict_strtol(memsize_str, 0, NULL);
57 }
58 add_memory_region(0, memsize, BOOT_MEM_RAM); 56 add_memory_region(0, memsize, BOOT_MEM_RAM);
59} 57}
diff --git a/arch/mips/au1000/pb1100/Makefile b/arch/mips/au1000/pb1100/Makefile
index 996236df6375..793e97c49e46 100644
--- a/arch/mips/au1000/pb1100/Makefile
+++ b/arch/mips/au1000/pb1100/Makefile
@@ -1,8 +1,8 @@
1# 1#
2# Copyright 2000,2001 MontaVista Software Inc. 2# Copyright 2000, 2001, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# 4#
6# Makefile for the Alchemy Semiconductor Pb1100 board. 5# Makefile for the Alchemy Semiconductor Pb1100 board.
6#
7 7
8lib-y := init.o board_setup.o irqmap.o 8lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/pb1100/board_setup.c b/arch/mips/au1000/pb1100/board_setup.c
index 656164c8e9ca..c0bfd59a7a36 100644
--- a/arch/mips/au1000/pb1100/board_setup.c
+++ b/arch/mips/au1000/pb1100/board_setup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Copyright 2002 MontaVista Software Inc. 2 * Copyright 2002, 2008 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc. 3 * Author: MontaVista Software, Inc. <source@mvista.com>
4 * ppopov@mvista.com or source@mvista.com
5 * 4 *
6 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 6 * under the terms of the GNU General Public License as published by the
@@ -32,15 +31,15 @@
32 31
33void board_reset(void) 32void board_reset(void)
34{ 33{
35 /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ 34 /* Hit BCSR.RST_VDDI[SOFT_RESET] */
36 au_writel(0x00000000, 0xAE00001C); 35 au_writel(0x00000000, PB1100_RST_VDDI);
37} 36}
38 37
39void __init board_setup(void) 38void __init board_setup(void)
40{ 39{
41 volatile void __iomem * base = (volatile void __iomem *) 0xac000000UL; 40 volatile void __iomem *base = (volatile void __iomem *)0xac000000UL;
42 41
43 // set AUX clock to 12MHz * 8 = 96 MHz 42 /* Set AUX clock to 12 MHz * 8 = 96 MHz */
44 au_writel(8, SYS_AUXPLL); 43 au_writel(8, SYS_AUXPLL);
45 au_writel(0, SYS_PININPUTEN); 44 au_writel(0, SYS_PININPUTEN);
46 udelay(100); 45 udelay(100);
@@ -49,44 +48,47 @@ void __init board_setup(void)
49 { 48 {
50 u32 pin_func, sys_freqctrl, sys_clksrc; 49 u32 pin_func, sys_freqctrl, sys_clksrc;
51 50
52 // configure pins GPIO[14:9] as GPIO 51 /* Configure pins GPIO[14:9] as GPIO */
53 pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x80); 52 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
54 53
55 /* zero and disable FREQ2 */ 54 /* Zero and disable FREQ2 */
56 sys_freqctrl = au_readl(SYS_FREQCTRL0); 55 sys_freqctrl = au_readl(SYS_FREQCTRL0);
57 sys_freqctrl &= ~0xFFF00000; 56 sys_freqctrl &= ~0xFFF00000;
58 au_writel(sys_freqctrl, SYS_FREQCTRL0); 57 au_writel(sys_freqctrl, SYS_FREQCTRL0);
59 58
60 /* zero and disable USBH/USBD/IrDA clock */ 59 /* Zero and disable USBH/USBD/IrDA clock */
61 sys_clksrc = au_readl(SYS_CLKSRC); 60 sys_clksrc = au_readl(SYS_CLKSRC);
62 sys_clksrc &= ~0x0000001F; 61 sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
63 au_writel(sys_clksrc, SYS_CLKSRC); 62 au_writel(sys_clksrc, SYS_CLKSRC);
64 63
65 sys_freqctrl = au_readl(SYS_FREQCTRL0); 64 sys_freqctrl = au_readl(SYS_FREQCTRL0);
66 sys_freqctrl &= ~0xFFF00000; 65 sys_freqctrl &= ~0xFFF00000;
67 66
68 sys_clksrc = au_readl(SYS_CLKSRC); 67 sys_clksrc = au_readl(SYS_CLKSRC);
69 sys_clksrc &= ~0x0000001F; 68 sys_clksrc &= ~(SYS_CS_CIR | SYS_CS_DIR | SYS_CS_MIR_MASK);
70 69
71 // FREQ2 = aux/2 = 48 MHz 70 /* FREQ2 = aux / 2 = 48 MHz */
72 sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20)); 71 sys_freqctrl |= (0 << SYS_FC_FRDIV2_BIT) |
72 SYS_FC_FE2 | SYS_FC_FS2;
73 au_writel(sys_freqctrl, SYS_FREQCTRL0); 73 au_writel(sys_freqctrl, SYS_FREQCTRL0);
74 74
75 /* 75 /*
76 * Route 48MHz FREQ2 into USBH/USBD/IrDA 76 * Route 48 MHz FREQ2 into USBH/USBD/IrDA
77 */ 77 */
78 sys_clksrc |= ((4<<2) | (0<<1) | 0 ); 78 sys_clksrc |= SYS_CS_MUX_FQ2 << SYS_CS_MIR_BIT;
79 au_writel(sys_clksrc, SYS_CLKSRC); 79 au_writel(sys_clksrc, SYS_CLKSRC);
80 80
81 /* setup the static bus controller */ 81 /* Setup the static bus controller */
82 au_writel(0x00000002, MEM_STCFG3); /* type = PCMCIA */ 82 au_writel(0x00000002, MEM_STCFG3); /* type = PCMCIA */
83 au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */ 83 au_writel(0x280E3D07, MEM_STTIME3); /* 250ns cycle time */
84 au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */ 84 au_writel(0x10000000, MEM_STADDR3); /* any PCMCIA select */
85 85
86 // get USB Functionality pin state (device vs host drive pins) 86 /*
87 pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); 87 * Get USB Functionality pin state (device vs host drive pins).
88 // 2nd USB port is USB host 88 */
89 pin_func |= 0x8000; 89 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_USB;
90 /* 2nd USB port is USB host. */
91 pin_func |= SYS_PF_USB;
90 au_writel(pin_func, SYS_PINFUNC); 92 au_writel(pin_func, SYS_PINFUNC);
91 } 93 }
92#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 94#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
@@ -94,12 +96,12 @@ void __init board_setup(void)
94 /* Enable sys bus clock divider when IDLE state or no bus activity. */ 96 /* Enable sys bus clock divider when IDLE state or no bus activity. */
95 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); 97 au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL);
96 98
97 // Enable the RTC if not already enabled 99 /* Enable the RTC if not already enabled. */
98 if (!(readb(base + 0x28) & 0x20)) { 100 if (!(readb(base + 0x28) & 0x20)) {
99 writeb(readb(base + 0x28) | 0x20, base + 0x28); 101 writeb(readb(base + 0x28) | 0x20, base + 0x28);
100 au_sync(); 102 au_sync();
101 } 103 }
102 // Put the clock in BCD mode 104 /* Put the clock in BCD mode. */
103 if (readb(base + 0x2C) & 0x4) { /* reg B */ 105 if (readb(base + 0x2C) & 0x4) { /* reg B */
104 writeb(readb(base + 0x2c) & ~0x4, base + 0x2c); 106 writeb(readb(base + 0x2c) & ~0x4, base + 0x2c);
105 au_sync(); 107 au_sync();
diff --git a/arch/mips/au1000/pb1100/init.c b/arch/mips/au1000/pb1100/init.c
index c91344648ed3..8355483f3de2 100644
--- a/arch/mips/au1000/pb1100/init.c
+++ b/arch/mips/au1000/pb1100/init.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Pb1100 board setup 4 * Pb1100 board setup
5 * 5 *
6 * Copyright 2002 MontaVista Software Inc. 6 * Copyright 2002, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -46,8 +45,8 @@ void __init prom_init(void)
46 unsigned long memsize; 45 unsigned long memsize;
47 46
48 prom_argc = fw_arg0; 47 prom_argc = fw_arg0;
49 prom_argv = (char **) fw_arg1; 48 prom_argv = (char **)fw_arg1;
50 prom_envp = (char **) fw_arg3; 49 prom_envp = (char **)fw_arg3;
51 50
52 prom_init_cmdline(); 51 prom_init_cmdline();
53 52
@@ -55,7 +54,7 @@ void __init prom_init(void)
55 if (!memsize_str) 54 if (!memsize_str)
56 memsize = 0x04000000; 55 memsize = 0x04000000;
57 else 56 else
58 memsize = simple_strtol(memsize_str, NULL, 0); 57 memsize = strict_strtol(memsize_str, 0, NULL);
59 58
60 add_memory_region(0, memsize, BOOT_MEM_RAM); 59 add_memory_region(0, memsize, BOOT_MEM_RAM);
61} 60}
diff --git a/arch/mips/au1000/pb1100/irqmap.c b/arch/mips/au1000/pb1100/irqmap.c
index b5021e3d477f..9b7dd8b41283 100644
--- a/arch/mips/au1000/pb1100/irqmap.c
+++ b/arch/mips/au1000/pb1100/irqmap.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Au1xxx irq map table 3 * Au1xx0 IRQ map table
4 * 4 *
5 * Copyright 2003 Embedded Edge, LLC 5 * Copyright 2003 Embedded Edge, LLC
6 * dan@embeddededge.com 6 * dan@embeddededge.com
@@ -31,10 +31,10 @@
31#include <asm/mach-au1x00/au1000.h> 31#include <asm/mach-au1x00/au1000.h>
32 32
33struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 33struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
34 { AU1000_GPIO_9, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card Fully_Interted# 34 { AU1000_GPIO_9, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card Fully_Inserted# */
35 { AU1000_GPIO_10, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card STSCHG# 35 { AU1000_GPIO_10, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card STSCHG# */
36 { AU1000_GPIO_11, INTC_INT_LOW_LEVEL, 0 }, // PCMCIA Card IRQ# 36 { AU1000_GPIO_11, INTC_INT_LOW_LEVEL, 0 }, /* PCMCIA Card IRQ# */
37 { AU1000_GPIO_13, INTC_INT_LOW_LEVEL, 0 }, // DC_IRQ# 37 { AU1000_GPIO_13, INTC_INT_LOW_LEVEL, 0 }, /* DC_IRQ# */
38}; 38};
39 39
40int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map); 40int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
diff --git a/arch/mips/au1000/pb1200/Makefile b/arch/mips/au1000/pb1200/Makefile
index 4fe02ea65a60..d678adf7ce85 100644
--- a/arch/mips/au1000/pb1200/Makefile
+++ b/arch/mips/au1000/pb1200/Makefile
@@ -1,5 +1,5 @@
1# 1#
2# Makefile for the Alchemy Semiconductor PB1200 board. 2# Makefile for the Alchemy Semiconductor Pb1200/DBAu1200 boards.
3# 3#
4 4
5lib-y := init.o board_setup.o irqmap.o 5lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/pb1200/board_setup.c b/arch/mips/au1000/pb1200/board_setup.c
index 4493a792cc4c..6cb2115059ad 100644
--- a/arch/mips/au1000/pb1200/board_setup.c
+++ b/arch/mips/au1000/pb1200/board_setup.c
@@ -27,16 +27,8 @@
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/sched.h> 28#include <linux/sched.h>
29 29
30#include <au1000.h>
31#include <prom.h> 30#include <prom.h>
32 31#include <au1xxx.h>
33#ifdef CONFIG_MIPS_PB1200
34#include <asm/mach-pb1x00/pb1200.h>
35#endif
36
37#ifdef CONFIG_MIPS_DB1200
38#include <asm/mach-db1x00/db1200.h>
39#endif
40 32
41extern void _board_init_irq(void); 33extern void _board_init_irq(void);
42extern void (*board_init_irq)(void); 34extern void (*board_init_irq)(void);
@@ -53,56 +45,57 @@ void __init board_setup(void)
53 45
54#if 0 46#if 0
55 { 47 {
56 u32 pin_func; 48 u32 pin_func;
57 49
58 /* Enable PSC1 SYNC for AC97. Normaly done in audio driver, 50 /*
59 * but it is board specific code, so put it here. 51 * Enable PSC1 SYNC for AC97. Normaly done in audio driver,
60 */ 52 * but it is board specific code, so put it here.
61 pin_func = au_readl(SYS_PINFUNC); 53 */
62 au_sync(); 54 pin_func = au_readl(SYS_PINFUNC);
63 pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; 55 au_sync();
64 au_writel(pin_func, SYS_PINFUNC); 56 pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1;
65 57 au_writel(pin_func, SYS_PINFUNC);
66 au_writel(0, (u32)bcsr|0x10); /* turn off pcmcia power */ 58
67 au_sync(); 59 au_writel(0, (u32)bcsr | 0x10); /* turn off PCMCIA power */
60 au_sync();
68 } 61 }
69#endif 62#endif
70 63
71#if defined(CONFIG_I2C_AU1550) 64#if defined(CONFIG_I2C_AU1550)
72 { 65 {
73 u32 freq0, clksrc; 66 u32 freq0, clksrc;
74 u32 pin_func; 67 u32 pin_func;
75 68
76 /* Select SMBUS in CPLD */ 69 /* Select SMBus in CPLD */
77 bcsr->resets &= ~(BCSR_RESETS_PCS0MUX); 70 bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
78 71
79 pin_func = au_readl(SYS_PINFUNC); 72 pin_func = au_readl(SYS_PINFUNC);
80 au_sync(); 73 au_sync();
81 pin_func &= ~(3<<17 | 1<<4); 74 pin_func &= ~(SYS_PINFUNC_P0A | SYS_PINFUNC_P0B);
82 /* Set GPIOs correctly */ 75 /* Set GPIOs correctly */
83 pin_func |= 2<<17; 76 pin_func |= 2 << 17;
84 au_writel(pin_func, SYS_PINFUNC); 77 au_writel(pin_func, SYS_PINFUNC);
85 au_sync(); 78 au_sync();
86 79
87 /* The i2c driver depends on 50Mhz clock */ 80 /* The I2C driver depends on 50 MHz clock */
88 freq0 = au_readl(SYS_FREQCTRL0); 81 freq0 = au_readl(SYS_FREQCTRL0);
89 au_sync(); 82 au_sync();
90 freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1); 83 freq0 &= ~(SYS_FC_FRDIV1_MASK | SYS_FC_FS1 | SYS_FC_FE1);
91 freq0 |= (3<<SYS_FC_FRDIV1_BIT); 84 freq0 |= 3 << SYS_FC_FRDIV1_BIT;
92 /* 396Mhz / (3+1)*2 == 49.5Mhz */ 85 /* 396 MHz / (3 + 1) * 2 == 49.5 MHz */
93 au_writel(freq0, SYS_FREQCTRL0); 86 au_writel(freq0, SYS_FREQCTRL0);
94 au_sync(); 87 au_sync();
95 freq0 |= SYS_FC_FE1; 88 freq0 |= SYS_FC_FE1;
96 au_writel(freq0, SYS_FREQCTRL0); 89 au_writel(freq0, SYS_FREQCTRL0);
97 au_sync(); 90 au_sync();
98 91
99 clksrc = au_readl(SYS_CLKSRC); 92 clksrc = au_readl(SYS_CLKSRC);
100 au_sync(); 93 au_sync();
101 clksrc &= ~0x01f00000; 94 clksrc &= ~(SYS_CS_CE0 | SYS_CS_DE0 | SYS_CS_ME0_MASK);
102 /* bit 22 is EXTCLK0 for PSC0 */ 95 /* Bit 22 is EXTCLK0 for PSC0 */
103 clksrc |= (0x3 << 22); 96 clksrc |= SYS_CS_MUX_FQ1 << SYS_CS_ME0_BIT;
104 au_writel(clksrc, SYS_CLKSRC); 97 au_writel(clksrc, SYS_CLKSRC);
105 au_sync(); 98 au_sync();
106 } 99 }
107#endif 100#endif
108 101
@@ -116,27 +109,27 @@ void __init board_setup(void)
116#endif 109#endif
117#endif 110#endif
118 111
119 /* The Pb1200 development board uses external MUX for PSC0 to 112 /*
120 support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI 113 * The Pb1200 development board uses external MUX for PSC0 to
121 */ 114 * support SMB/SPI. bcsr->resets bit 12: 0=SMB 1=SPI
115 */
122#ifdef CONFIG_I2C_AU1550 116#ifdef CONFIG_I2C_AU1550
123 bcsr->resets &= (~BCSR_RESETS_PCS0MUX); 117 bcsr->resets &= ~BCSR_RESETS_PCS0MUX;
124#endif 118#endif
125 au_sync(); 119 au_sync();
126 120
127#ifdef CONFIG_MIPS_PB1200 121#ifdef CONFIG_MIPS_PB1200
128 printk("AMD Alchemy Pb1200 Board\n"); 122 printk(KERN_INFO "AMD Alchemy Pb1200 Board\n");
129#endif 123#endif
130#ifdef CONFIG_MIPS_DB1200 124#ifdef CONFIG_MIPS_DB1200
131 printk("AMD Alchemy Db1200 Board\n"); 125 printk(KERN_INFO "AMD Alchemy Db1200 Board\n");
132#endif 126#endif
133 127
134 /* Setup Pb1200 External Interrupt Controller */ 128 /* Setup Pb1200 External Interrupt Controller */
135 board_init_irq = _board_init_irq; 129 board_init_irq = _board_init_irq;
136} 130}
137 131
138int 132int board_au1200fb_panel(void)
139board_au1200fb_panel(void)
140{ 133{
141 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; 134 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
142 int p; 135 int p;
@@ -147,23 +140,23 @@ board_au1200fb_panel(void)
147 return p; 140 return p;
148} 141}
149 142
150int 143int board_au1200fb_panel_init(void)
151board_au1200fb_panel_init(void)
152{ 144{
153 /* Apply power */ 145 /* Apply power */
154 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; 146 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
155 bcsr->board |= (BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL); 147
156 /*printk("board_au1200fb_panel_init()\n"); */ 148 bcsr->board |= BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL;
149 /* printk(KERN_DEBUG "board_au1200fb_panel_init()\n"); */
157 return 0; 150 return 0;
158} 151}
159 152
160int 153int board_au1200fb_panel_shutdown(void)
161board_au1200fb_panel_shutdown(void)
162{ 154{
163 /* Remove power */ 155 /* Remove power */
164 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR; 156 BCSR *bcsr = (BCSR *)BCSR_KSEG1_ADDR;
165 bcsr->board &= ~(BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD | BCSR_BOARD_LCDBL); 157
166 /*printk("board_au1200fb_panel_shutdown()\n"); */ 158 bcsr->board &= ~(BCSR_BOARD_LCDVEE | BCSR_BOARD_LCDVDD |
159 BCSR_BOARD_LCDBL);
160 /* printk(KERN_DEBUG "board_au1200fb_panel_shutdown()\n"); */
167 return 0; 161 return 0;
168} 162}
169
diff --git a/arch/mips/au1000/pb1200/init.c b/arch/mips/au1000/pb1200/init.c
index 72af5500660b..09fd63b86062 100644
--- a/arch/mips/au1000/pb1200/init.c
+++ b/arch/mips/au1000/pb1200/init.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * PB1200 board setup 4 * PB1200 board setup
5 * 5 *
6 * Copyright 2001 MontaVista Software Inc. 6 * Copyright 2001, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -45,16 +44,15 @@ void __init prom_init(void)
45 unsigned char *memsize_str; 44 unsigned char *memsize_str;
46 unsigned long memsize; 45 unsigned long memsize;
47 46
48 prom_argc = (int) fw_arg0; 47 prom_argc = (int)fw_arg0;
49 prom_argv = (char **) fw_arg1; 48 prom_argv = (char **)fw_arg1;
50 prom_envp = (char **) fw_arg2; 49 prom_envp = (char **)fw_arg2;
51 50
52 prom_init_cmdline(); 51 prom_init_cmdline();
53 memsize_str = prom_getenv("memsize"); 52 memsize_str = prom_getenv("memsize");
54 if (!memsize_str) { 53 if (!memsize_str)
55 memsize = 0x08000000; 54 memsize = 0x08000000;
56 } else { 55 else
57 memsize = simple_strtol(memsize_str, NULL, 0); 56 memsize = strict_strtol(memsize_str, 0, NULL);
58 }
59 add_memory_region(0, memsize, BOOT_MEM_RAM); 57 add_memory_region(0, memsize, BOOT_MEM_RAM);
60} 58}
diff --git a/arch/mips/au1000/pb1200/irqmap.c b/arch/mips/au1000/pb1200/irqmap.c
index e61eb8e0b76b..2a505ad8715b 100644
--- a/arch/mips/au1000/pb1200/irqmap.c
+++ b/arch/mips/au1000/pb1200/irqmap.c
@@ -39,25 +39,25 @@
39#endif 39#endif
40 40
41struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 41struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
42 { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 }, // This is exteranl interrupt cascade 42 /* This is external interrupt cascade */
43 { AU1000_GPIO_7, INTC_INT_LOW_LEVEL, 0 },
43}; 44};
44 45
45int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map); 46int __initdata au1xxx_nr_irqs = ARRAY_SIZE(au1xxx_irq_map);
46 47
47/* 48/*
48 * Support for External interrupts on the PbAu1200 Development platform. 49 * Support for External interrupts on the Pb1200 Development platform.
49 */ 50 */
50static volatile int pb1200_cascade_en=0; 51static volatile int pb1200_cascade_en;
51 52
52irqreturn_t pb1200_cascade_handler( int irq, void *dev_id) 53irqreturn_t pb1200_cascade_handler(int irq, void *dev_id)
53{ 54{
54 unsigned short bisr = bcsr->int_status; 55 unsigned short bisr = bcsr->int_status;
55 int extirq_nr = 0; 56 int extirq_nr = 0;
56 57
57 /* Clear all the edge interrupts. This has no effect on level */ 58 /* Clear all the edge interrupts. This has no effect on level. */
58 bcsr->int_status = bisr; 59 bcsr->int_status = bisr;
59 for( ; bisr; bisr &= (bisr-1) ) 60 for ( ; bisr; bisr &= bisr - 1) {
60 {
61 extirq_nr = PB1200_INT_BEGIN + __ffs(bisr); 61 extirq_nr = PB1200_INT_BEGIN + __ffs(bisr);
62 /* Ack and dispatch IRQ */ 62 /* Ack and dispatch IRQ */
63 do_IRQ(extirq_nr); 63 do_IRQ(extirq_nr);
@@ -68,26 +68,20 @@ irqreturn_t pb1200_cascade_handler( int irq, void *dev_id)
68 68
69inline void pb1200_enable_irq(unsigned int irq_nr) 69inline void pb1200_enable_irq(unsigned int irq_nr)
70{ 70{
71 bcsr->intset_mask = 1<<(irq_nr - PB1200_INT_BEGIN); 71 bcsr->intset_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
72 bcsr->intset = 1<<(irq_nr - PB1200_INT_BEGIN); 72 bcsr->intset = 1 << (irq_nr - PB1200_INT_BEGIN);
73} 73}
74 74
75inline void pb1200_disable_irq(unsigned int irq_nr) 75inline void pb1200_disable_irq(unsigned int irq_nr)
76{ 76{
77 bcsr->intclr_mask = 1<<(irq_nr - PB1200_INT_BEGIN); 77 bcsr->intclr_mask = 1 << (irq_nr - PB1200_INT_BEGIN);
78 bcsr->intclr = 1<<(irq_nr - PB1200_INT_BEGIN); 78 bcsr->intclr = 1 << (irq_nr - PB1200_INT_BEGIN);
79} 79}
80 80
81static unsigned int pb1200_setup_cascade(void) 81static unsigned int pb1200_setup_cascade(void)
82{ 82{
83 int err; 83 return request_irq(AU1000_GPIO_7, &pb1200_cascade_handler,
84 84 0, "Pb1200 Cascade", &pb1200_cascade_handler);
85 err = request_irq(AU1000_GPIO_7, &pb1200_cascade_handler,
86 0, "Pb1200 Cascade", &pb1200_cascade_handler);
87 if (err)
88 return err;
89
90 return 0;
91} 85}
92 86
93static unsigned int pb1200_startup_irq(unsigned int irq) 87static unsigned int pb1200_startup_irq(unsigned int irq)
@@ -132,23 +126,23 @@ void _board_init_irq(void)
132 unsigned int irq; 126 unsigned int irq;
133 127
134#ifdef CONFIG_MIPS_PB1200 128#ifdef CONFIG_MIPS_PB1200
135 /* We have a problem with CPLD rev3. Enable a workaround */ 129 /* We have a problem with CPLD rev 3. */
136 if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) { 130 if (((bcsr->whoami & BCSR_WHOAMI_CPLD) >> 4) <= 3) {
137 printk("\nWARNING!!!\n"); 131 printk(KERN_ERR "WARNING!!!\n");
138 printk("\nWARNING!!!\n"); 132 printk(KERN_ERR "WARNING!!!\n");
139 printk("\nWARNING!!!\n"); 133 printk(KERN_ERR "WARNING!!!\n");
140 printk("\nWARNING!!!\n"); 134 printk(KERN_ERR "WARNING!!!\n");
141 printk("\nWARNING!!!\n"); 135 printk(KERN_ERR "WARNING!!!\n");
142 printk("\nWARNING!!!\n"); 136 printk(KERN_ERR "WARNING!!!\n");
143 printk("Pb1200 must be at CPLD rev4. Please have Pb1200\n"); 137 printk(KERN_ERR "Pb1200 must be at CPLD rev 4. Please have Pb1200\n");
144 printk("updated to latest revision. This software will not\n"); 138 printk(KERN_ERR "updated to latest revision. This software will\n");
145 printk("work on anything less than CPLD rev4\n"); 139 printk(KERN_ERR "not work on anything less than CPLD rev 4.\n");
146 printk("\nWARNING!!!\n"); 140 printk(KERN_ERR "WARNING!!!\n");
147 printk("\nWARNING!!!\n"); 141 printk(KERN_ERR "WARNING!!!\n");
148 printk("\nWARNING!!!\n"); 142 printk(KERN_ERR "WARNING!!!\n");
149 printk("\nWARNING!!!\n"); 143 printk(KERN_ERR "WARNING!!!\n");
150 printk("\nWARNING!!!\n"); 144 printk(KERN_ERR "WARNING!!!\n");
151 printk("\nWARNING!!!\n"); 145 printk(KERN_ERR "WARNING!!!\n");
152 panic("Game over. Your score is 0."); 146 panic("Game over. Your score is 0.");
153 } 147 }
154#endif 148#endif
@@ -161,6 +155,6 @@ void _board_init_irq(void)
161 155
162 /* 156 /*
163 * GPIO_7 can not be hooked here, so it is hooked upon first 157 * GPIO_7 can not be hooked here, so it is hooked upon first
164 * request of any source attached to the cascade 158 * request of any source attached to the cascade.
165 */ 159 */
166} 160}
diff --git a/arch/mips/au1000/pb1500/Makefile b/arch/mips/au1000/pb1500/Makefile
index 97a730813cd3..602f38df20bb 100644
--- a/arch/mips/au1000/pb1500/Makefile
+++ b/arch/mips/au1000/pb1500/Makefile
@@ -1,8 +1,8 @@
1# 1#
2# Copyright 2000,2001 MontaVista Software Inc. 2# Copyright 2000, 2001, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# 4#
6# Makefile for the Alchemy Semiconductor Pb1500 board. 5# Makefile for the Alchemy Semiconductor Pb1500 board.
6#
7 7
8lib-y := init.o board_setup.o irqmap.o 8lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/pb1500/board_setup.c b/arch/mips/au1000/pb1500/board_setup.c
index 24c652e8ec4b..035771c6e5b8 100644
--- a/arch/mips/au1000/pb1500/board_setup.c
+++ b/arch/mips/au1000/pb1500/board_setup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Copyright 2000 MontaVista Software Inc. 2 * Copyright 2000, 2008 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc. 3 * Author: MontaVista Software, Inc. <source@mvista.com>
4 * ppopov@mvista.com or source@mvista.com
5 * 4 *
6 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 6 * under the terms of the GNU General Public License as published by the
@@ -32,8 +31,8 @@
32 31
33void board_reset(void) 32void board_reset(void)
34{ 33{
35 /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ 34 /* Hit BCSR.RST_VDDI[SOFT_RESET] */
36 au_writel(0x00000000, 0xAE00001C); 35 au_writel(0x00000000, PB1500_RST_VDDI);
37} 36}
38 37
39void __init board_setup(void) 38void __init board_setup(void)
@@ -42,7 +41,7 @@ void __init board_setup(void)
42 u32 sys_freqctrl, sys_clksrc; 41 u32 sys_freqctrl, sys_clksrc;
43 42
44 sys_clksrc = sys_freqctrl = pin_func = 0; 43 sys_clksrc = sys_freqctrl = pin_func = 0;
45 // set AUX clock to 12MHz * 8 = 96 MHz 44 /* Set AUX clock to 12 MHz * 8 = 96 MHz */
46 au_writel(8, SYS_AUXPLL); 45 au_writel(8, SYS_AUXPLL);
47 au_writel(0, SYS_PINSTATERD); 46 au_writel(0, SYS_PINSTATERD);
48 udelay(100); 47 udelay(100);
@@ -51,51 +50,48 @@ void __init board_setup(void)
51 50
52 /* GPIO201 is input for PCMCIA card detect */ 51 /* GPIO201 is input for PCMCIA card detect */
53 /* GPIO203 is input for PCMCIA interrupt request */ 52 /* GPIO203 is input for PCMCIA interrupt request */
54 au_writel(au_readl(GPIO2_DIR) & (u32)(~((1<<1)|(1<<3))), GPIO2_DIR); 53 au_writel(au_readl(GPIO2_DIR) & ~((1 << 1) | (1 << 3)), GPIO2_DIR);
55 54
56 /* zero and disable FREQ2 */ 55 /* Zero and disable FREQ2 */
57 sys_freqctrl = au_readl(SYS_FREQCTRL0); 56 sys_freqctrl = au_readl(SYS_FREQCTRL0);
58 sys_freqctrl &= ~0xFFF00000; 57 sys_freqctrl &= ~0xFFF00000;
59 au_writel(sys_freqctrl, SYS_FREQCTRL0); 58 au_writel(sys_freqctrl, SYS_FREQCTRL0);
60 59
61 /* zero and disable USBH/USBD clocks */ 60 /* zero and disable USBH/USBD clocks */
62 sys_clksrc = au_readl(SYS_CLKSRC); 61 sys_clksrc = au_readl(SYS_CLKSRC);
63 sys_clksrc &= ~0x00007FE0; 62 sys_clksrc &= ~(SYS_CS_CUD | SYS_CS_DUD | SYS_CS_MUD_MASK |
63 SYS_CS_CUH | SYS_CS_DUH | SYS_CS_MUH_MASK);
64 au_writel(sys_clksrc, SYS_CLKSRC); 64 au_writel(sys_clksrc, SYS_CLKSRC);
65 65
66 sys_freqctrl = au_readl(SYS_FREQCTRL0); 66 sys_freqctrl = au_readl(SYS_FREQCTRL0);
67 sys_freqctrl &= ~0xFFF00000; 67 sys_freqctrl &= ~0xFFF00000;
68 68
69 sys_clksrc = au_readl(SYS_CLKSRC); 69 sys_clksrc = au_readl(SYS_CLKSRC);
70 sys_clksrc &= ~0x00007FE0; 70 sys_clksrc &= ~(SYS_CS_CUD | SYS_CS_DUD | SYS_CS_MUD_MASK |
71 SYS_CS_CUH | SYS_CS_DUH | SYS_CS_MUH_MASK);
71 72
72 // FREQ2 = aux/2 = 48 MHz 73 /* FREQ2 = aux/2 = 48 MHz */
73 sys_freqctrl |= ((0<<22) | (1<<21) | (1<<20)); 74 sys_freqctrl |= (0 << SYS_FC_FRDIV2_BIT) | SYS_FC_FE2 | SYS_FC_FS2;
74 au_writel(sys_freqctrl, SYS_FREQCTRL0); 75 au_writel(sys_freqctrl, SYS_FREQCTRL0);
75 76
76 /* 77 /*
77 * Route 48MHz FREQ2 into USB Host and/or Device 78 * Route 48MHz FREQ2 into USB Host and/or Device
78 */ 79 */
79#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 80 sys_clksrc |= SYS_CS_MUX_FQ2 << SYS_CS_MUH_BIT;
80 sys_clksrc |= ((4<<12) | (0<<11) | (0<<10));
81#endif
82 au_writel(sys_clksrc, SYS_CLKSRC); 81 au_writel(sys_clksrc, SYS_CLKSRC);
83 82
84 83 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_USB;
85 pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); 84 /* 2nd USB port is USB host */
86 // 2nd USB port is USB host 85 pin_func |= SYS_PF_USB;
87 pin_func |= 0x8000;
88 au_writel(pin_func, SYS_PINFUNC); 86 au_writel(pin_func, SYS_PINFUNC);
89#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */ 87#endif /* defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) */
90 88
91
92
93#ifdef CONFIG_PCI 89#ifdef CONFIG_PCI
94 // Setup PCI bus controller 90 /* Setup PCI bus controller */
95 au_writel(0, Au1500_PCI_CMEM); 91 au_writel(0, Au1500_PCI_CMEM);
96 au_writel(0x00003fff, Au1500_CFG_BASE); 92 au_writel(0x00003fff, Au1500_CFG_BASE);
97#if defined(__MIPSEB__) 93#if defined(__MIPSEB__)
98 au_writel(0xf | (2<<6) | (1<<4), Au1500_PCI_CFG); 94 au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
99#else 95#else
100 au_writel(0xf, Au1500_PCI_CFG); 96 au_writel(0xf, Au1500_PCI_CFG);
101#endif 97#endif
@@ -112,11 +108,11 @@ void __init board_setup(void)
112 108
113 /* Enable the RTC if not already enabled */ 109 /* Enable the RTC if not already enabled */
114 if (!(au_readl(0xac000028) & 0x20)) { 110 if (!(au_readl(0xac000028) & 0x20)) {
115 printk("enabling clock ...\n"); 111 printk(KERN_INFO "enabling clock ...\n");
116 au_writel((au_readl(0xac000028) | 0x20), 0xac000028); 112 au_writel((au_readl(0xac000028) | 0x20), 0xac000028);
117 } 113 }
118 /* Put the clock in BCD mode */ 114 /* Put the clock in BCD mode */
119 if (au_readl(0xac00002C) & 0x4) { /* reg B */ 115 if (au_readl(0xac00002c) & 0x4) { /* reg B */
120 au_writel(au_readl(0xac00002c) & ~0x4, 0xac00002c); 116 au_writel(au_readl(0xac00002c) & ~0x4, 0xac00002c);
121 au_sync(); 117 au_sync();
122 } 118 }
diff --git a/arch/mips/au1000/pb1500/init.c b/arch/mips/au1000/pb1500/init.c
index 488507c07db9..49f51e165863 100644
--- a/arch/mips/au1000/pb1500/init.c
+++ b/arch/mips/au1000/pb1500/init.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * PB1500 board setup 4 * Pb1500 board setup
5 * 5 *
6 * Copyright 2001 MontaVista Software Inc. 6 * Copyright 2001, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -45,16 +44,15 @@ void __init prom_init(void)
45 unsigned char *memsize_str; 44 unsigned char *memsize_str;
46 unsigned long memsize; 45 unsigned long memsize;
47 46
48 prom_argc = (int) fw_arg0; 47 prom_argc = (int)fw_arg0;
49 prom_argv = (char **) fw_arg1; 48 prom_argv = (char **)fw_arg1;
50 prom_envp = (char **) fw_arg2; 49 prom_envp = (char **)fw_arg2;
51 50
52 prom_init_cmdline(); 51 prom_init_cmdline();
53 memsize_str = prom_getenv("memsize"); 52 memsize_str = prom_getenv("memsize");
54 if (!memsize_str) { 53 if (!memsize_str)
55 memsize = 0x04000000; 54 memsize = 0x04000000;
56 } else { 55 else
57 memsize = simple_strtol(memsize_str, NULL, 0); 56 memsize = strict_strtol(memsize_str, 0, NULL);
58 }
59 add_memory_region(0, memsize, BOOT_MEM_RAM); 57 add_memory_region(0, memsize, BOOT_MEM_RAM);
60} 58}
diff --git a/arch/mips/au1000/pb1500/irqmap.c b/arch/mips/au1000/pb1500/irqmap.c
index 4817ab44d07f..39c4682766a8 100644
--- a/arch/mips/au1000/pb1500/irqmap.c
+++ b/arch/mips/au1000/pb1500/irqmap.c
@@ -31,12 +31,12 @@
31#include <asm/mach-au1x00/au1000.h> 31#include <asm/mach-au1x00/au1000.h>
32 32
33char irq_tab_alchemy[][5] __initdata = { 33char irq_tab_alchemy[][5] __initdata = {
34 [12] = { -1, INTA, INTX, INTX, INTX}, /* IDSEL 12 - HPT370 */ 34 [12] = { -1, INTA, INTX, INTX, INTX }, /* IDSEL 12 - HPT370 */
35 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot */ 35 [13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot */
36}; 36};
37 37
38struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 38struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
39 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 39 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0 },
40 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 40 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
41 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 41 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
42 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 }, 42 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 },
diff --git a/arch/mips/au1000/pb1550/Makefile b/arch/mips/au1000/pb1550/Makefile
index aa35bc6cb8cf..7d8beca87fa5 100644
--- a/arch/mips/au1000/pb1550/Makefile
+++ b/arch/mips/au1000/pb1550/Makefile
@@ -1,9 +1,8 @@
1# 1#
2# Copyright 2000 MontaVista Software Inc. 2# Copyright 2000, 2008 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# 4#
6# Makefile for the Alchemy Semiconductor PB1000 board. 5# Makefile for the Alchemy Semiconductor Pb1550 board.
7# 6#
8 7
9lib-y := init.o board_setup.o irqmap.o 8lib-y := init.o board_setup.o irqmap.o
diff --git a/arch/mips/au1000/pb1550/board_setup.c b/arch/mips/au1000/pb1550/board_setup.c
index 45d60872b565..0ed76b64b6ab 100644
--- a/arch/mips/au1000/pb1550/board_setup.c
+++ b/arch/mips/au1000/pb1550/board_setup.c
@@ -3,9 +3,8 @@
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * Alchemy Pb1550 board setup. 4 * Alchemy Pb1550 board setup.
5 * 5 *
6 * Copyright 2000 MontaVista Software Inc. 6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -35,15 +34,16 @@
35 34
36void board_reset(void) 35void board_reset(void)
37{ 36{
38 /* Hit BCSR.SYSTEM_CONTROL[SW_RST] */ 37 /* Hit BCSR.SYSTEM[RESET] */
39 au_writew(au_readw(0xAF00001C) & ~(1<<15), 0xAF00001C); 38 au_writew(au_readw(0xAF00001C) & ~BCSR_SYSTEM_RESET, 0xAF00001C);
40} 39}
41 40
42void __init board_setup(void) 41void __init board_setup(void)
43{ 42{
44 u32 pin_func; 43 u32 pin_func;
45 44
46 /* Enable PSC1 SYNC for AC97. Normaly done in audio driver, 45 /*
46 * Enable PSC1 SYNC for AC'97. Normaly done in audio driver,
47 * but it is board specific code, so put it here. 47 * but it is board specific code, so put it here.
48 */ 48 */
49 pin_func = au_readl(SYS_PINFUNC); 49 pin_func = au_readl(SYS_PINFUNC);
@@ -51,8 +51,8 @@ void __init board_setup(void)
51 pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1; 51 pin_func |= SYS_PF_MUST_BE_SET | SYS_PF_PSC1_S1;
52 au_writel(pin_func, SYS_PINFUNC); 52 au_writel(pin_func, SYS_PINFUNC);
53 53
54 au_writel(0, (u32)bcsr|0x10); /* turn off pcmcia power */ 54 au_writel(0, (u32)bcsr | 0x10); /* turn off PCMCIA power */
55 au_sync(); 55 au_sync();
56 56
57 printk("AMD Alchemy Pb1550 Board\n"); 57 printk(KERN_INFO "AMD Alchemy Pb1550 Board\n");
58} 58}
diff --git a/arch/mips/au1000/pb1550/init.c b/arch/mips/au1000/pb1550/init.c
index f6b2fc587980..1b5f58434bb7 100644
--- a/arch/mips/au1000/pb1550/init.c
+++ b/arch/mips/au1000/pb1550/init.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * 2 *
3 * BRIEF MODULE DESCRIPTION 3 * BRIEF MODULE DESCRIPTION
4 * PB1550 board setup 4 * Pb1550 board setup
5 * 5 *
6 * Copyright 2001 MontaVista Software Inc. 6 * Copyright 2001, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * ppopov@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -45,16 +44,15 @@ void __init prom_init(void)
45 unsigned char *memsize_str; 44 unsigned char *memsize_str;
46 unsigned long memsize; 45 unsigned long memsize;
47 46
48 prom_argc = (int) fw_arg0; 47 prom_argc = (int)fw_arg0;
49 prom_argv = (char **) fw_arg1; 48 prom_argv = (char **)fw_arg1;
50 prom_envp = (char **) fw_arg2; 49 prom_envp = (char **)fw_arg2;
51 50
52 prom_init_cmdline(); 51 prom_init_cmdline();
53 memsize_str = prom_getenv("memsize"); 52 memsize_str = prom_getenv("memsize");
54 if (!memsize_str) { 53 if (!memsize_str)
55 memsize = 0x08000000; 54 memsize = 0x08000000;
56 } else { 55 else
57 memsize = simple_strtol(memsize_str, NULL, 0); 56 memsize = strict_strtol(memsize_str, 0, NULL);
58 }
59 add_memory_region(0, memsize, BOOT_MEM_RAM); 57 add_memory_region(0, memsize, BOOT_MEM_RAM);
60} 58}
diff --git a/arch/mips/au1000/pb1550/irqmap.c b/arch/mips/au1000/pb1550/irqmap.c
index e1dac37af08a..a02a4d1fa899 100644
--- a/arch/mips/au1000/pb1550/irqmap.c
+++ b/arch/mips/au1000/pb1550/irqmap.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Au1xxx irq map table 3 * Au1xx0 IRQ map table
4 * 4 *
5 * Copyright 2003 Embedded Edge, LLC 5 * Copyright 2003 Embedded Edge, LLC
6 * dan@embeddededge.com 6 * dan@embeddededge.com
@@ -31,8 +31,8 @@
31#include <asm/mach-au1x00/au1000.h> 31#include <asm/mach-au1x00/au1000.h>
32 32
33char irq_tab_alchemy[][5] __initdata = { 33char irq_tab_alchemy[][5] __initdata = {
34 [12] = { -1, INTB, INTC, INTD, INTA}, /* IDSEL 12 - PCI slot 2 (left) */ 34 [12] = { -1, INTB, INTC, INTD, INTA }, /* IDSEL 12 - PCI slot 2 (left) */
35 [13] = { -1, INTA, INTB, INTC, INTD}, /* IDSEL 13 - PCI slot 1 (right) */ 35 [13] = { -1, INTA, INTB, INTC, INTD }, /* IDSEL 13 - PCI slot 1 (right) */
36}; 36};
37 37
38struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 38struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
diff --git a/arch/mips/au1000/xxs1500/Makefile b/arch/mips/au1000/xxs1500/Makefile
index 44d7f7056ae7..db3c526f64d8 100644
--- a/arch/mips/au1000/xxs1500/Makefile
+++ b/arch/mips/au1000/xxs1500/Makefile
@@ -1,7 +1,6 @@
1# 1#
2# Copyright 2003 MontaVista Software Inc. 2# Copyright 2003 MontaVista Software Inc.
3# Author: MontaVista Software, Inc. 3# Author: MontaVista Software, Inc. <source@mvista.com>
4# ppopov@mvista.com or source@mvista.com
5# 4#
6# Makefile for MyCable XXS1500 board. 5# Makefile for MyCable XXS1500 board.
7# 6#
diff --git a/arch/mips/au1000/xxs1500/board_setup.c b/arch/mips/au1000/xxs1500/board_setup.c
index 79d1798621bf..4c587acac5c3 100644
--- a/arch/mips/au1000/xxs1500/board_setup.c
+++ b/arch/mips/au1000/xxs1500/board_setup.c
@@ -1,7 +1,6 @@
1/* 1/*
2 * Copyright 2000-2003 MontaVista Software Inc. 2 * Copyright 2000-2003, 2008 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc. 3 * Author: MontaVista Software, Inc. <source@mvista.com>
4 * ppopov@mvista.com or source@mvista.com
5 * 4 *
6 * This program is free software; you can redistribute it and/or modify it 5 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 6 * under the terms of the GNU General Public License as published by the
@@ -39,40 +38,40 @@ void __init board_setup(void)
39{ 38{
40 u32 pin_func; 39 u32 pin_func;
41 40
42 // set multiple use pins (UART3/GPIO) to UART (it's used as UART too) 41 /* Set multiple use pins (UART3/GPIO) to UART (it's used as UART too) */
43 pin_func = au_readl(SYS_PINFUNC) & (u32)(~SYS_PF_UR3); 42 pin_func = au_readl(SYS_PINFUNC) & ~SYS_PF_UR3;
44 pin_func |= SYS_PF_UR3; 43 pin_func |= SYS_PF_UR3;
45 au_writel(pin_func, SYS_PINFUNC); 44 au_writel(pin_func, SYS_PINFUNC);
46 45
47 // enable UART 46 /* Enable UART */
48 au_writel(0x01, UART3_ADDR+UART_MOD_CNTRL); // clock enable (CE) 47 au_writel(0x01, UART3_ADDR + UART_MOD_CNTRL); /* clock enable (CE) */
49 mdelay(10); 48 mdelay(10);
50 au_writel(0x03, UART3_ADDR+UART_MOD_CNTRL); // CE and "enable" 49 au_writel(0x03, UART3_ADDR + UART_MOD_CNTRL); /* CE and "enable" */
51 mdelay(10); 50 mdelay(10);
52 51
53 // enable DTR = USB power up 52 /* Enable DTR = USB power up */
54 au_writel(0x01, UART3_ADDR+UART_MCR); //? UART_MCR_DTR is 0x01??? 53 au_writel(0x01, UART3_ADDR + UART_MCR); /* UART_MCR_DTR is 0x01??? */
55 54
56#ifdef CONFIG_PCMCIA_XXS1500 55#ifdef CONFIG_PCMCIA_XXS1500
57 /* setup pcmcia signals */ 56 /* Setup PCMCIA signals */
58 au_writel(0, SYS_PININPUTEN); 57 au_writel(0, SYS_PININPUTEN);
59 58
60 /* gpio 0, 1, and 4 are inputs */ 59 /* GPIO 0, 1, and 4 are inputs */
61 au_writel(1 | (1<<1) | (1<<4), SYS_TRIOUTCLR); 60 au_writel(1 | (1 << 1) | (1 << 4), SYS_TRIOUTCLR);
62 61
63 /* enable GPIO2 if not already enabled */ 62 /* Enable GPIO2 if not already enabled */
64 au_writel(1, GPIO2_ENABLE); 63 au_writel(1, GPIO2_ENABLE);
65 /* gpio2 208/9/10/11 are inputs */ 64 /* GPIO2 208/9/10/11 are inputs */
66 au_writel((1<<8) | (1<<9) | (1<<10) | (1<<11), GPIO2_DIR); 65 au_writel((1 << 8) | (1 << 9) | (1 << 10) | (1 << 11), GPIO2_DIR);
67 66
68 /* turn off power */ 67 /* Turn off power */
69 au_writel((au_readl(GPIO2_PINSTATE) & ~(1<<14))|(1<<30), GPIO2_OUTPUT); 68 au_writel((au_readl(GPIO2_PINSTATE) & ~(1 << 14)) | (1 << 30),
69 GPIO2_OUTPUT);
70#endif 70#endif
71 71
72
73#ifdef CONFIG_PCI 72#ifdef CONFIG_PCI
74#if defined(__MIPSEB__) 73#if defined(__MIPSEB__)
75 au_writel(0xf | (2<<6) | (1<<4), Au1500_PCI_CFG); 74 au_writel(0xf | (2 << 6) | (1 << 4), Au1500_PCI_CFG);
76#else 75#else
77 au_writel(0xf, Au1500_PCI_CFG); 76 au_writel(0xf, Au1500_PCI_CFG);
78#endif 77#endif
diff --git a/arch/mips/au1000/xxs1500/init.c b/arch/mips/au1000/xxs1500/init.c
index 24fc6e132dc0..b849bf501c04 100644
--- a/arch/mips/au1000/xxs1500/init.c
+++ b/arch/mips/au1000/xxs1500/init.c
@@ -2,9 +2,8 @@
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * XXS1500 board setup 3 * XXS1500 board setup
4 * 4 *
5 * Copyright 2003 MontaVista Software Inc. 5 * Copyright 2003, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
@@ -45,8 +44,8 @@ void __init prom_init(void)
45 unsigned long memsize; 44 unsigned long memsize;
46 45
47 prom_argc = fw_arg0; 46 prom_argc = fw_arg0;
48 prom_argv = (char **) fw_arg1; 47 prom_argv = (char **)fw_arg1;
49 prom_envp = (char **) fw_arg2; 48 prom_envp = (char **)fw_arg2;
50 49
51 prom_init_cmdline(); 50 prom_init_cmdline();
52 51
@@ -54,6 +53,6 @@ void __init prom_init(void)
54 if (!memsize_str) 53 if (!memsize_str)
55 memsize = 0x04000000; 54 memsize = 0x04000000;
56 else 55 else
57 memsize = simple_strtol(memsize_str, NULL, 0); 56 memsize = strict_strtol(memsize_str, 0, NULL);
58 add_memory_region(0, memsize, BOOT_MEM_RAM); 57 add_memory_region(0, memsize, BOOT_MEM_RAM);
59} 58}
diff --git a/arch/mips/au1000/xxs1500/irqmap.c b/arch/mips/au1000/xxs1500/irqmap.c
index dd6e3d1eb4d4..edf06ed11870 100644
--- a/arch/mips/au1000/xxs1500/irqmap.c
+++ b/arch/mips/au1000/xxs1500/irqmap.c
@@ -31,7 +31,7 @@
31#include <asm/mach-au1x00/au1000.h> 31#include <asm/mach-au1x00/au1000.h>
32 32
33struct au1xxx_irqmap __initdata au1xxx_irq_map[] = { 33struct au1xxx_irqmap __initdata au1xxx_irq_map[] = {
34 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0}, 34 { AU1500_GPIO_204, INTC_INT_HIGH_LEVEL, 0 },
35 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 }, 35 { AU1500_GPIO_201, INTC_INT_LOW_LEVEL, 0 },
36 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 }, 36 { AU1500_GPIO_202, INTC_INT_LOW_LEVEL, 0 },
37 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 }, 37 { AU1500_GPIO_203, INTC_INT_LOW_LEVEL, 0 },
diff --git a/arch/mips/emma2rh/markeins/setup.c b/arch/mips/emma2rh/markeins/setup.c
index 82f9e9013e70..62bfb455d1b1 100644
--- a/arch/mips/emma2rh/markeins/setup.c
+++ b/arch/mips/emma2rh/markeins/setup.c
@@ -76,7 +76,9 @@ static void markeins_machine_power_off(void)
76 while (1) ; 76 while (1) ;
77} 77}
78 78
79static unsigned long clock[4] = { 166500000, 187312500, 199800000, 210600000 }; 79static unsigned long __initdata emma2rh_clock[4] = {
80 166500000, 187312500, 199800000, 210600000
81};
80 82
81static unsigned int __init detect_bus_frequency(unsigned long rtc_base) 83static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
82{ 84{
@@ -85,7 +87,8 @@ static unsigned int __init detect_bus_frequency(unsigned long rtc_base)
85 /* detect from boot strap */ 87 /* detect from boot strap */
86 reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0); 88 reg = emma2rh_in32(EMMA2RH_BHIF_STRAP_0);
87 reg = (reg >> 4) & 0x3; 89 reg = (reg >> 4) & 0x3;
88 return clock[reg]; 90
91 return emma2rh_clock[reg];
89} 92}
90 93
91void __init plat_time_init(void) 94void __init plat_time_init(void)
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 45545be3eb86..cc0244036aec 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -56,9 +56,9 @@ obj-$(CONFIG_MIPS_MT_SMP) += smp-mt.o
56obj-$(CONFIG_MIPS_CMP) += smp-cmp.o 56obj-$(CONFIG_MIPS_CMP) += smp-cmp.o
57obj-$(CONFIG_CPU_MIPSR2) += spram.o 57obj-$(CONFIG_CPU_MIPSR2) += spram.o
58 58
59obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o
60obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o 59obj-$(CONFIG_MIPS_VPE_LOADER) += vpe.o
61obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o 60obj-$(CONFIG_MIPS_VPE_APSP_API) += rtlx.o
61obj-$(CONFIG_MIPS_APSP_KSPD) += kspd.o
62 62
63obj-$(CONFIG_I8259) += i8259.o 63obj-$(CONFIG_I8259) += i8259.o
64obj-$(CONFIG_IRQ_CPU) += irq_cpu.o 64obj-$(CONFIG_IRQ_CPU) += irq_cpu.o
diff --git a/arch/mips/kernel/cpu-bugs64.c b/arch/mips/kernel/cpu-bugs64.c
index a1b48af0992f..02b7713cf71c 100644
--- a/arch/mips/kernel/cpu-bugs64.c
+++ b/arch/mips/kernel/cpu-bugs64.c
@@ -38,7 +38,7 @@ static inline void align_mod(const int align, const int mod)
38 ".endr\n\t" 38 ".endr\n\t"
39 ".set pop" 39 ".set pop"
40 : 40 :
41 : GCC_IMM_ASM(align), GCC_IMM_ASM(mod)); 41 : GCC_IMM_ASM() (align), GCC_IMM_ASM() (mod));
42} 42}
43 43
44static inline void mult_sh_align_mod(long *v1, long *v2, long *w, 44static inline void mult_sh_align_mod(long *v1, long *v2, long *w,
diff --git a/arch/mips/kernel/irixelf.c b/arch/mips/kernel/irixelf.c
index 290d8e3a664d..469c7237e5ba 100644
--- a/arch/mips/kernel/irixelf.c
+++ b/arch/mips/kernel/irixelf.c
@@ -578,7 +578,7 @@ static inline int map_interpreter(struct elf_phdr *epp, struct elfhdr *ihp,
578 * process and the system, here we map the page and fill the 578 * process and the system, here we map the page and fill the
579 * structure 579 * structure
580 */ 580 */
581static void irix_map_prda_page(void) 581static int irix_map_prda_page(void)
582{ 582{
583 unsigned long v; 583 unsigned long v;
584 struct prda *pp; 584 struct prda *pp;
@@ -587,8 +587,8 @@ static void irix_map_prda_page(void)
587 v = do_brk(PRDA_ADDRESS, PAGE_SIZE); 587 v = do_brk(PRDA_ADDRESS, PAGE_SIZE);
588 up_write(&current->mm->mmap_sem); 588 up_write(&current->mm->mmap_sem);
589 589
590 if (v < 0) 590 if (v != PRDA_ADDRESS)
591 return; 591 return v; /* v must be an error code */
592 592
593 pp = (struct prda *) v; 593 pp = (struct prda *) v;
594 pp->prda_sys.t_pid = task_pid_vnr(current); 594 pp->prda_sys.t_pid = task_pid_vnr(current);
@@ -596,6 +596,8 @@ static void irix_map_prda_page(void)
596 pp->prda_sys.t_rpid = task_pid_vnr(current); 596 pp->prda_sys.t_rpid = task_pid_vnr(current);
597 597
598 /* We leave the rest set to zero */ 598 /* We leave the rest set to zero */
599
600 return 0;
599} 601}
600 602
601 603
@@ -781,7 +783,8 @@ static int load_irix_binary(struct linux_binprm * bprm, struct pt_regs * regs)
781 * IRIX maps a page at 0x200000 which holds some system 783 * IRIX maps a page at 0x200000 which holds some system
782 * information. Programs depend on this. 784 * information. Programs depend on this.
783 */ 785 */
784 irix_map_prda_page(); 786 if (irix_map_prda_page())
787 goto out_free_dentry;
785 788
786 padzero(elf_bss); 789 padzero(elf_bss);
787 790
diff --git a/arch/mips/kernel/kspd.c b/arch/mips/kernel/kspd.c
index ceb62dce1c9c..b0591ae0ce56 100644
--- a/arch/mips/kernel/kspd.c
+++ b/arch/mips/kernel/kspd.c
@@ -257,7 +257,7 @@ void sp_work_handle_request(void)
257 257
258 vcwd = vpe_getcwd(tclimit); 258 vcwd = vpe_getcwd(tclimit);
259 259
260 /* change to the cwd of the process that loaded the SP program */ 260 /* change to cwd of the process that loaded the SP program */
261 old_fs = get_fs(); 261 old_fs = get_fs();
262 set_fs(KERNEL_DS); 262 set_fs(KERNEL_DS);
263 sys_chdir(vcwd); 263 sys_chdir(vcwd);
@@ -323,6 +323,9 @@ static void sp_cleanup(void)
323 set >>= 1; 323 set >>= 1;
324 } 324 }
325 } 325 }
326
327 /* Put daemon cwd back to root to avoid umount problems */
328 sys_chdir("/");
326} 329}
327 330
328static int channel_open = 0; 331static int channel_open = 0;
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c
index 0233798f7155..b88f1c18ff4d 100644
--- a/arch/mips/kernel/rtlx.c
+++ b/arch/mips/kernel/rtlx.c
@@ -72,6 +72,15 @@ static void rtlx_dispatch(void)
72static irqreturn_t rtlx_interrupt(int irq, void *dev_id) 72static irqreturn_t rtlx_interrupt(int irq, void *dev_id)
73{ 73{
74 int i; 74 int i;
75 unsigned int flags, vpeflags;
76
77 /* Ought not to be strictly necessary for SMTC builds */
78 local_irq_save(flags);
79 vpeflags = dvpe();
80 set_c0_status(0x100 << MIPS_CPU_RTLX_IRQ);
81 irq_enable_hazard();
82 evpe(vpeflags);
83 local_irq_restore(flags);
75 84
76 for (i = 0; i < RTLX_CHANNELS; i++) { 85 for (i = 0; i < RTLX_CHANNELS; i++) {
77 wake_up(&channel_wqs[i].lx_queue); 86 wake_up(&channel_wqs[i].lx_queue);
@@ -108,7 +117,8 @@ static void __used dump_rtlx(void)
108static int rtlx_init(struct rtlx_info *rtlxi) 117static int rtlx_init(struct rtlx_info *rtlxi)
109{ 118{
110 if (rtlxi->id != RTLX_ID) { 119 if (rtlxi->id != RTLX_ID) {
111 printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n", rtlxi, rtlxi->id); 120 printk(KERN_ERR "no valid RTLX id at 0x%p 0x%lx\n",
121 rtlxi, rtlxi->id);
112 return -ENOEXEC; 122 return -ENOEXEC;
113 } 123 }
114 124
@@ -162,18 +172,17 @@ int rtlx_open(int index, int can_sleep)
162 172
163 if (rtlx == NULL) { 173 if (rtlx == NULL) {
164 if( (p = vpe_get_shared(tclimit)) == NULL) { 174 if( (p = vpe_get_shared(tclimit)) == NULL) {
165 if (can_sleep) { 175 if (can_sleep) {
166 __wait_event_interruptible(channel_wqs[index].lx_queue, 176 __wait_event_interruptible(channel_wqs[index].lx_queue,
167 (p = vpe_get_shared(tclimit)), 177 (p = vpe_get_shared(tclimit)), ret);
168 ret); 178 if (ret)
169 if (ret)
170 goto out_fail;
171 } else {
172 printk(KERN_DEBUG "No SP program loaded, and device "
173 "opened with O_NONBLOCK\n");
174 ret = -ENOSYS;
175 goto out_fail; 179 goto out_fail;
176 } 180 } else {
181 printk(KERN_DEBUG "No SP program loaded, and device "
182 "opened with O_NONBLOCK\n");
183 ret = -ENOSYS;
184 goto out_fail;
185 }
177 } 186 }
178 187
179 smp_rmb(); 188 smp_rmb();
@@ -182,7 +191,9 @@ int rtlx_open(int index, int can_sleep)
182 DEFINE_WAIT(wait); 191 DEFINE_WAIT(wait);
183 192
184 for (;;) { 193 for (;;) {
185 prepare_to_wait(&channel_wqs[index].lx_queue, &wait, TASK_INTERRUPTIBLE); 194 prepare_to_wait(
195 &channel_wqs[index].lx_queue,
196 &wait, TASK_INTERRUPTIBLE);
186 smp_rmb(); 197 smp_rmb();
187 if (*p != NULL) 198 if (*p != NULL)
188 break; 199 break;
@@ -195,7 +206,7 @@ int rtlx_open(int index, int can_sleep)
195 } 206 }
196 finish_wait(&channel_wqs[index].lx_queue, &wait); 207 finish_wait(&channel_wqs[index].lx_queue, &wait);
197 } else { 208 } else {
198 printk(" *vpe_get_shared is NULL. " 209 pr_err(" *vpe_get_shared is NULL. "
199 "Has an SP program been loaded?\n"); 210 "Has an SP program been loaded?\n");
200 ret = -ENOSYS; 211 ret = -ENOSYS;
201 goto out_fail; 212 goto out_fail;
@@ -203,8 +214,9 @@ int rtlx_open(int index, int can_sleep)
203 } 214 }
204 215
205 if ((unsigned int)*p < KSEG0) { 216 if ((unsigned int)*p < KSEG0) {
206 printk(KERN_WARNING "vpe_get_shared returned an invalid pointer " 217 printk(KERN_WARNING "vpe_get_shared returned an "
207 "maybe an error code %d\n", (int)*p); 218 "invalid pointer maybe an error code %d\n",
219 (int)*p);
208 ret = -ENOSYS; 220 ret = -ENOSYS;
209 goto out_fail; 221 goto out_fail;
210 } 222 }
@@ -232,6 +244,10 @@ out_ret:
232 244
233int rtlx_release(int index) 245int rtlx_release(int index)
234{ 246{
247 if (rtlx == NULL) {
248 pr_err("rtlx_release() with null rtlx\n");
249 return 0;
250 }
235 rtlx->channel[index].lx_state = RTLX_STATE_UNUSED; 251 rtlx->channel[index].lx_state = RTLX_STATE_UNUSED;
236 return 0; 252 return 0;
237} 253}
@@ -251,8 +267,8 @@ unsigned int rtlx_read_poll(int index, int can_sleep)
251 int ret = 0; 267 int ret = 0;
252 268
253 __wait_event_interruptible(channel_wqs[index].lx_queue, 269 __wait_event_interruptible(channel_wqs[index].lx_queue,
254 chan->lx_read != chan->lx_write || sp_stopping, 270 (chan->lx_read != chan->lx_write) ||
255 ret); 271 sp_stopping, ret);
256 if (ret) 272 if (ret)
257 return ret; 273 return ret;
258 274
@@ -282,7 +298,9 @@ static inline int write_spacefree(int read, int write, int size)
282unsigned int rtlx_write_poll(int index) 298unsigned int rtlx_write_poll(int index)
283{ 299{
284 struct rtlx_channel *chan = &rtlx->channel[index]; 300 struct rtlx_channel *chan = &rtlx->channel[index];
285 return write_spacefree(chan->rt_read, chan->rt_write, chan->buffer_size); 301
302 return write_spacefree(chan->rt_read, chan->rt_write,
303 chan->buffer_size);
286} 304}
287 305
288ssize_t rtlx_read(int index, void __user *buff, size_t count) 306ssize_t rtlx_read(int index, void __user *buff, size_t count)
@@ -344,8 +362,8 @@ ssize_t rtlx_write(int index, const void __user *buffer, size_t count)
344 rt_read = rt->rt_read; 362 rt_read = rt->rt_read;
345 363
346 /* total number of bytes to copy */ 364 /* total number of bytes to copy */
347 count = min(count, 365 count = min(count, (size_t)write_spacefree(rt_read, rt->rt_write,
348 (size_t)write_spacefree(rt_read, rt->rt_write, rt->buffer_size)); 366 rt->buffer_size));
349 367
350 /* first bit from write pointer to the end of the buffer, or count */ 368 /* first bit from write pointer to the end of the buffer, or count */
351 fl = min(count, (size_t) rt->buffer_size - rt->rt_write); 369 fl = min(count, (size_t) rt->buffer_size - rt->rt_write);
@@ -514,6 +532,11 @@ static int __init rtlx_module_init(void)
514 532
515 if (cpu_has_vint) 533 if (cpu_has_vint)
516 set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch); 534 set_vi_handler(MIPS_CPU_RTLX_IRQ, rtlx_dispatch);
535 else {
536 pr_err("APRP RTLX init on non-vectored-interrupt processor\n");
537 err = -ENODEV;
538 goto out_chrdev;
539 }
517 540
518 rtlx_irq.dev_id = rtlx; 541 rtlx_irq.dev_id = rtlx;
519 setup_irq(rtlx_irq_num, &rtlx_irq); 542 setup_irq(rtlx_irq_num, &rtlx_irq);
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 39f3dfe134fb..c6a063b2a0d9 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -331,6 +331,7 @@ static void __init bootmem_init(void)
331 /* 331 /*
332 * Determine low and high memory ranges 332 * Determine low and high memory ranges
333 */ 333 */
334 max_pfn = max_low_pfn;
334 if (max_low_pfn > PFN_DOWN(HIGHMEM_START)) { 335 if (max_low_pfn > PFN_DOWN(HIGHMEM_START)) {
335#ifdef CONFIG_HIGHMEM 336#ifdef CONFIG_HIGHMEM
336 highstart_pfn = PFN_DOWN(HIGHMEM_START); 337 highstart_pfn = PFN_DOWN(HIGHMEM_START);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 33780cc61ce9..63370cdd3c90 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -87,8 +87,8 @@ struct plat_smp_ops *mp_ops;
87 87
88__cpuinit void register_smp_ops(struct plat_smp_ops *ops) 88__cpuinit void register_smp_ops(struct plat_smp_ops *ops)
89{ 89{
90 if (ops) 90 if (mp_ops)
91 printk(KERN_WARNING "Overriding previous set SMP ops\n"); 91 printk(KERN_WARNING "Overriding previously set SMP ops\n");
92 92
93 mp_ops = ops; 93 mp_ops = ops;
94} 94}
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 39804c584edd..2794501ff302 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -269,7 +269,7 @@ static void *alloc_progmem(unsigned long len)
269 * This means you must tell Linux to use less memory than you 269 * This means you must tell Linux to use less memory than you
270 * physically have, for example by passing a mem= boot argument. 270 * physically have, for example by passing a mem= boot argument.
271 */ 271 */
272 addr = pfn_to_kaddr(max_pfn); 272 addr = pfn_to_kaddr(max_low_pfn);
273 memset(addr, 0, len); 273 memset(addr, 0, len);
274#else 274#else
275 /* simple grab some mem for now */ 275 /* simple grab some mem for now */
@@ -781,10 +781,15 @@ static int vpe_run(struct vpe * v)
781 /* take system out of configuration state */ 781 /* take system out of configuration state */
782 clear_c0_mvpcontrol(MVPCONTROL_VPC); 782 clear_c0_mvpcontrol(MVPCONTROL_VPC);
783 783
784 /*
785 * SMTC/SMVP kernels manage VPE enable independently,
786 * but uniprocessor kernels need to turn it on, even
787 * if that wasn't the pre-dvpe() state.
788 */
784#ifdef CONFIG_SMP 789#ifdef CONFIG_SMP
785 evpe(EVPE_ENABLE);
786#else
787 evpe(vpeflags); 790 evpe(vpeflags);
791#else
792 evpe(EVPE_ENABLE);
788#endif 793#endif
789 emt(dmt_flag); 794 emt(dmt_flag);
790 local_irq_restore(flags); 795 local_irq_restore(flags);
@@ -840,7 +845,7 @@ static int vpe_elfload(struct vpe * v)
840 845
841 /* Sanity checks against insmoding binaries or wrong arch, 846 /* Sanity checks against insmoding binaries or wrong arch,
842 weird elf version */ 847 weird elf version */
843 if (memcmp(hdr->e_ident, ELFMAG, 4) != 0 848 if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0
844 || (hdr->e_type != ET_REL && hdr->e_type != ET_EXEC) 849 || (hdr->e_type != ET_REL && hdr->e_type != ET_EXEC)
845 || !elf_check_arch(hdr) 850 || !elf_check_arch(hdr)
846 || hdr->e_shentsize != sizeof(*sechdrs)) { 851 || hdr->e_shentsize != sizeof(*sechdrs)) {
@@ -947,12 +952,14 @@ static int vpe_elfload(struct vpe * v)
947 struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff); 952 struct elf_phdr *phdr = (struct elf_phdr *) ((char *)hdr + hdr->e_phoff);
948 953
949 for (i = 0; i < hdr->e_phnum; i++) { 954 for (i = 0; i < hdr->e_phnum; i++) {
950 if (phdr->p_type != PT_LOAD) 955 if (phdr->p_type == PT_LOAD) {
951 continue; 956 memcpy((void *)phdr->p_paddr,
952 957 (char *)hdr + phdr->p_offset,
953 memcpy((void *)phdr->p_paddr, (char *)hdr + phdr->p_offset, phdr->p_filesz); 958 phdr->p_filesz);
954 memset((void *)phdr->p_paddr + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); 959 memset((void *)phdr->p_paddr + phdr->p_filesz,
955 phdr++; 960 0, phdr->p_memsz - phdr->p_filesz);
961 }
962 phdr++;
956 } 963 }
957 964
958 for (i = 0; i < hdr->e_shnum; i++) { 965 for (i = 0; i < hdr->e_shnum; i++) {
@@ -1107,7 +1114,7 @@ static int vpe_release(struct inode *inode, struct file *filp)
1107 return -ENODEV; 1114 return -ENODEV;
1108 1115
1109 hdr = (Elf_Ehdr *) v->pbuffer; 1116 hdr = (Elf_Ehdr *) v->pbuffer;
1110 if (memcmp(hdr->e_ident, ELFMAG, 4) == 0) { 1117 if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) == 0) {
1111 if (vpe_elfload(v) >= 0) { 1118 if (vpe_elfload(v) >= 0) {
1112 vpe_run(v); 1119 vpe_run(v);
1113 } else { 1120 } else {
diff --git a/arch/mips/mm/highmem.c b/arch/mips/mm/highmem.c
index 10dd2af2343b..8f2cd8eda741 100644
--- a/arch/mips/mm/highmem.c
+++ b/arch/mips/mm/highmem.c
@@ -116,4 +116,3 @@ EXPORT_SYMBOL(__kmap);
116EXPORT_SYMBOL(__kunmap); 116EXPORT_SYMBOL(__kunmap);
117EXPORT_SYMBOL(__kmap_atomic); 117EXPORT_SYMBOL(__kmap_atomic);
118EXPORT_SYMBOL(__kunmap_atomic); 118EXPORT_SYMBOL(__kunmap_atomic);
119EXPORT_SYMBOL(__kmap_atomic_to_page);
diff --git a/arch/mips/oprofile/op_model_mipsxx.c b/arch/mips/oprofile/op_model_mipsxx.c
index da8cbb6899dc..b40df7d2cf44 100644
--- a/arch/mips/oprofile/op_model_mipsxx.c
+++ b/arch/mips/oprofile/op_model_mipsxx.c
@@ -281,7 +281,7 @@ static inline int n_counters(void)
281 281
282static void reset_counters(void *arg) 282static void reset_counters(void *arg)
283{ 283{
284 int counters = (int)arg; 284 int counters = (int)(long)arg;
285 switch (counters) { 285 switch (counters) {
286 case 4: 286 case 4:
287 w_c0_perfctrl3(0); 287 w_c0_perfctrl3(0);
@@ -313,7 +313,7 @@ static int __init mipsxx_init(void)
313 if (!cpu_has_mipsmt_pertccounters) 313 if (!cpu_has_mipsmt_pertccounters)
314 counters = counters_total_to_per_cpu(counters); 314 counters = counters_total_to_per_cpu(counters);
315#endif 315#endif
316 on_each_cpu(reset_counters, (void *)counters, 0, 1); 316 on_each_cpu(reset_counters, (void *)(long)counters, 0, 1);
317 317
318 op_model_mipsxx_ops.num_counters = counters; 318 op_model_mipsxx_ops.num_counters = counters;
319 switch (current_cpu_type()) { 319 switch (current_cpu_type()) {
@@ -382,7 +382,7 @@ static void mipsxx_exit(void)
382 int counters = op_model_mipsxx_ops.num_counters; 382 int counters = op_model_mipsxx_ops.num_counters;
383 383
384 counters = counters_per_cpu_to_total(counters); 384 counters = counters_per_cpu_to_total(counters);
385 on_each_cpu(reset_counters, (void *)counters, 0, 1); 385 on_each_cpu(reset_counters, (void *)(long)counters, 0, 1);
386 386
387 perf_irq = save_perf_irq; 387 perf_irq = save_perf_irq;
388} 388}
diff --git a/arch/mips/pci/fixup-au1000.c b/arch/mips/pci/fixup-au1000.c
index 00c36c9dbe0e..e2ddfc49237c 100644
--- a/arch/mips/pci/fixup-au1000.c
+++ b/arch/mips/pci/fixup-au1000.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Board specific pci fixups. 3 * Board specific PCI fixups.
4 * 4 *
5 * Copyright 2001-2003 MontaVista Software Inc. 5 * Copyright 2001-2003, 2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * This program is free software; you can redistribute it and/or modify it 8 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the 9 * under the terms of the GNU General Public License as published by the
diff --git a/arch/mips/pci/ops-au1000.c b/arch/mips/pci/ops-au1000.c
index 1314bd58f036..9a57c5ab91dd 100644
--- a/arch/mips/pci/ops-au1000.c
+++ b/arch/mips/pci/ops-au1000.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Alchemy/AMD Au1x00 PCI support. 3 * Alchemy/AMD Au1xx0 PCI support.
4 * 4 *
5 * Copyright 2001-2003, 2007 MontaVista Software Inc. 5 * Copyright 2001-2003, 2007-2008 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc. 6 * Author: MontaVista Software, Inc. <source@mvista.com>
7 * ppopov@mvista.com or source@mvista.com
8 * 7 *
9 * Support for all devices (greater than 16) added by David Gathright. 8 * Support for all devices (greater than 16) added by David Gathright.
10 * 9 *
@@ -28,6 +27,7 @@
28 * with this program; if not, write to the Free Software Foundation, Inc., 27 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */ 29 */
30
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/pci.h> 32#include <linux/pci.h>
33#include <linux/kernel.h> 33#include <linux/kernel.h>
@@ -36,9 +36,9 @@
36 36
37#include <asm/mach-au1x00/au1000.h> 37#include <asm/mach-au1x00/au1000.h>
38 38
39#undef DEBUG 39#undef DEBUG
40#ifdef DEBUG 40#ifdef DEBUG
41#define DBG(x...) printk(x) 41#define DBG(x...) printk(KERN_DEBUG x)
42#else 42#else
43#define DBG(x...) 43#define DBG(x...)
44#endif 44#endif
@@ -46,7 +46,6 @@
46#define PCI_ACCESS_READ 0 46#define PCI_ACCESS_READ 0
47#define PCI_ACCESS_WRITE 1 47#define PCI_ACCESS_WRITE 1
48 48
49
50int (*board_pci_idsel)(unsigned int devsel, int assert); 49int (*board_pci_idsel)(unsigned int devsel, int assert);
51 50
52void mod_wired_entry(int entry, unsigned long entrylo0, 51void mod_wired_entry(int entry, unsigned long entrylo0,
@@ -92,10 +91,9 @@ void __init au1x_pci_cfg_init(void)
92} 91}
93 92
94static int config_access(unsigned char access_type, struct pci_bus *bus, 93static int config_access(unsigned char access_type, struct pci_bus *bus,
95 unsigned int dev_fn, unsigned char where, 94 unsigned int dev_fn, unsigned char where, u32 *data)
96 u32 * data)
97{ 95{
98#if defined( CONFIG_SOC_AU1500 ) || defined( CONFIG_SOC_AU1550 ) 96#if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
99 unsigned int device = PCI_SLOT(dev_fn); 97 unsigned int device = PCI_SLOT(dev_fn);
100 unsigned int function = PCI_FUNC(dev_fn); 98 unsigned int function = PCI_FUNC(dev_fn);
101 unsigned long offset, status; 99 unsigned long offset, status;
@@ -114,38 +112,36 @@ static int config_access(unsigned char access_type, struct pci_bus *bus,
114 Au1500_PCI_STATCMD); 112 Au1500_PCI_STATCMD);
115 au_sync_udelay(1); 113 au_sync_udelay(1);
116 114
117 /* Allow board vendors to implement their own off-chip idsel. 115 /*
116 * Allow board vendors to implement their own off-chip IDSEL.
118 * If it doesn't succeed, may as well bail out at this point. 117 * If it doesn't succeed, may as well bail out at this point.
119 */ 118 */
120 if (board_pci_idsel) { 119 if (board_pci_idsel && board_pci_idsel(device, 1) == 0) {
121 if (board_pci_idsel(device, 1) == 0) { 120 *data = 0xffffffff;
122 *data = 0xffffffff; 121 local_irq_restore(flags);
123 local_irq_restore(flags); 122 return -1;
124 return -1;
125 }
126 } 123 }
127 124
128 /* setup the config window */ 125 /* Setup the config window */
129 if (bus->number == 0) { 126 if (bus->number == 0)
130 cfg_base = ((1<<device)<<11); 127 cfg_base = (1 << device) << 11;
131 } else { 128 else
132 cfg_base = 0x80000000 | (bus->number<<16) | (device<<11); 129 cfg_base = 0x80000000 | (bus->number << 16) | (device << 11);
133 }
134 130
135 /* setup the lower bits of the 36 bit address */ 131 /* Setup the lower bits of the 36-bit address */
136 offset = (function << 8) | (where & ~0x3); 132 offset = (function << 8) | (where & ~0x3);
137 /* pick up any address that falls below the page mask */ 133 /* Pick up any address that falls below the page mask */
138 offset |= cfg_base & ~PAGE_MASK; 134 offset |= cfg_base & ~PAGE_MASK;
139 135
140 /* page boundary */ 136 /* Page boundary */
141 cfg_base = cfg_base & PAGE_MASK; 137 cfg_base = cfg_base & PAGE_MASK;
142 138
143 /* 139 /*
144 * To improve performance, if the current device is the same as 140 * To improve performance, if the current device is the same as
145 * the last device accessed, we don't touch the TLB. 141 * the last device accessed, we don't touch the TLB.
146 */ 142 */
147 entryLo0 = (6 << 26) | (cfg_base >> 6) | (2 << 3) | 7; 143 entryLo0 = (6 << 26) | (cfg_base >> 6) | (2 << 3) | 7;
148 entryLo1 = (6 << 26) | (cfg_base >> 6) | (0x1000 >> 6) | (2 << 3) | 7; 144 entryLo1 = (6 << 26) | (cfg_base >> 6) | (0x1000 >> 6) | (2 << 3) | 7;
149 if ((entryLo0 != last_entryLo0) || (entryLo1 != last_entryLo1)) { 145 if ((entryLo0 != last_entryLo0) || (entryLo1 != last_entryLo1)) {
150 mod_wired_entry(pci_cfg_wired_entry, entryLo0, entryLo1, 146 mod_wired_entry(pci_cfg_wired_entry, entryLo0, entryLo1,
151 (unsigned long)pci_cfg_vm->addr, PM_4K); 147 (unsigned long)pci_cfg_vm->addr, PM_4K);
@@ -153,38 +149,37 @@ static int config_access(unsigned char access_type, struct pci_bus *bus,
153 last_entryLo1 = entryLo1; 149 last_entryLo1 = entryLo1;
154 } 150 }
155 151
156 if (access_type == PCI_ACCESS_WRITE) { 152 if (access_type == PCI_ACCESS_WRITE)
157 au_writel(*data, (int)(pci_cfg_vm->addr + offset)); 153 au_writel(*data, (int)(pci_cfg_vm->addr + offset));
158 } else { 154 else
159 *data = au_readl((int)(pci_cfg_vm->addr + offset)); 155 *data = au_readl((int)(pci_cfg_vm->addr + offset));
160 } 156
161 au_sync_udelay(2); 157 au_sync_udelay(2);
162 158
163 DBG("cfg_access %d bus->number %d dev %d at %x *data %x conf %x\n", 159 DBG("cfg_access %d bus->number %u dev %u at %x *data %x conf %lx\n",
164 access_type, bus->number, device, where, *data, offset); 160 access_type, bus->number, device, where, *data, offset);
165 161
166 /* check master abort */ 162 /* Check master abort */
167 status = au_readl(Au1500_PCI_STATCMD); 163 status = au_readl(Au1500_PCI_STATCMD);
168 164
169 if (status & (1<<29)) { 165 if (status & (1 << 29)) {
170 *data = 0xffffffff; 166 *data = 0xffffffff;
171 error = -1; 167 error = -1;
172 DBG("Au1x Master Abort\n"); 168 DBG("Au1x Master Abort\n");
173 } else if ((status >> 28) & 0xf) { 169 } else if ((status >> 28) & 0xf) {
174 DBG("PCI ERR detected: device %d, status %x\n", device, ((status >> 28) & 0xf)); 170 DBG("PCI ERR detected: device %u, status %lx\n",
171 device, (status >> 28) & 0xf);
175 172
176 /* clear errors */ 173 /* Clear errors */
177 au_writel(status & 0xf000ffff, Au1500_PCI_STATCMD); 174 au_writel(status & 0xf000ffff, Au1500_PCI_STATCMD);
178 175
179 *data = 0xffffffff; 176 *data = 0xffffffff;
180 error = -1; 177 error = -1;
181 } 178 }
182 179
183 /* Take away the idsel. 180 /* Take away the IDSEL. */
184 */ 181 if (board_pci_idsel)
185 if (board_pci_idsel) {
186 (void)board_pci_idsel(device, 0); 182 (void)board_pci_idsel(device, 0);
187 }
188 183
189 local_irq_restore(flags); 184 local_irq_restore(flags);
190 return error; 185 return error;
@@ -192,7 +187,7 @@ static int config_access(unsigned char access_type, struct pci_bus *bus,
192} 187}
193 188
194static int read_config_byte(struct pci_bus *bus, unsigned int devfn, 189static int read_config_byte(struct pci_bus *bus, unsigned int devfn,
195 int where, u8 * val) 190 int where, u8 *val)
196{ 191{
197 u32 data; 192 u32 data;
198 int ret; 193 int ret;
@@ -206,9 +201,8 @@ static int read_config_byte(struct pci_bus *bus, unsigned int devfn,
206 return ret; 201 return ret;
207} 202}
208 203
209
210static int read_config_word(struct pci_bus *bus, unsigned int devfn, 204static int read_config_word(struct pci_bus *bus, unsigned int devfn,
211 int where, u16 * val) 205 int where, u16 *val)
212{ 206{
213 u32 data; 207 u32 data;
214 int ret; 208 int ret;
@@ -221,7 +215,7 @@ static int read_config_word(struct pci_bus *bus, unsigned int devfn,
221} 215}
222 216
223static int read_config_dword(struct pci_bus *bus, unsigned int devfn, 217static int read_config_dword(struct pci_bus *bus, unsigned int devfn,
224 int where, u32 * val) 218 int where, u32 *val)
225{ 219{
226 int ret; 220 int ret;
227 221
@@ -229,9 +223,8 @@ static int read_config_dword(struct pci_bus *bus, unsigned int devfn,
229 return ret; 223 return ret;
230} 224}
231 225
232static int 226static int write_config_byte(struct pci_bus *bus, unsigned int devfn,
233write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, 227 int where, u8 val)
234 u8 val)
235{ 228{
236 u32 data = 0; 229 u32 data = 0;
237 230
@@ -239,7 +232,7 @@ write_config_byte(struct pci_bus *bus, unsigned int devfn, int where,
239 return -1; 232 return -1;
240 233
241 data = (data & ~(0xff << ((where & 3) << 3))) | 234 data = (data & ~(0xff << ((where & 3) << 3))) |
242 (val << ((where & 3) << 3)); 235 (val << ((where & 3) << 3));
243 236
244 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data)) 237 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
245 return -1; 238 return -1;
@@ -247,9 +240,8 @@ write_config_byte(struct pci_bus *bus, unsigned int devfn, int where,
247 return PCIBIOS_SUCCESSFUL; 240 return PCIBIOS_SUCCESSFUL;
248} 241}
249 242
250static int 243static int write_config_word(struct pci_bus *bus, unsigned int devfn,
251write_config_word(struct pci_bus *bus, unsigned int devfn, int where, 244 int where, u16 val)
252 u16 val)
253{ 245{
254 u32 data = 0; 246 u32 data = 0;
255 247
@@ -257,18 +249,16 @@ write_config_word(struct pci_bus *bus, unsigned int devfn, int where,
257 return -1; 249 return -1;
258 250
259 data = (data & ~(0xffff << ((where & 3) << 3))) | 251 data = (data & ~(0xffff << ((where & 3) << 3))) |
260 (val << ((where & 3) << 3)); 252 (val << ((where & 3) << 3));
261 253
262 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data)) 254 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
263 return -1; 255 return -1;
264 256
265
266 return PCIBIOS_SUCCESSFUL; 257 return PCIBIOS_SUCCESSFUL;
267} 258}
268 259
269static int 260static int write_config_dword(struct pci_bus *bus, unsigned int devfn,
270write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, 261 int where, u32 val)
271 u32 val)
272{ 262{
273 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val)) 263 if (config_access(PCI_ACCESS_WRITE, bus, devfn, where, &val))
274 return -1; 264 return -1;
@@ -277,18 +267,20 @@ write_config_dword(struct pci_bus *bus, unsigned int devfn, int where,
277} 267}
278 268
279static int config_read(struct pci_bus *bus, unsigned int devfn, 269static int config_read(struct pci_bus *bus, unsigned int devfn,
280 int where, int size, u32 * val) 270 int where, int size, u32 *val)
281{ 271{
282 switch (size) { 272 switch (size) {
283 case 1: { 273 case 1: {
284 u8 _val; 274 u8 _val;
285 int rc = read_config_byte(bus, devfn, where, &_val); 275 int rc = read_config_byte(bus, devfn, where, &_val);
276
286 *val = _val; 277 *val = _val;
287 return rc; 278 return rc;
288 } 279 }
289 case 2: { 280 case 2: {
290 u16 _val; 281 u16 _val;
291 int rc = read_config_word(bus, devfn, where, &_val); 282 int rc = read_config_word(bus, devfn, where, &_val);
283
292 *val = _val; 284 *val = _val;
293 return rc; 285 return rc;
294 } 286 }
@@ -310,7 +302,6 @@ static int config_write(struct pci_bus *bus, unsigned int devfn,
310 } 302 }
311} 303}
312 304
313
314struct pci_ops au1x_pci_ops = { 305struct pci_ops au1x_pci_ops = {
315 config_read, 306 config_read,
316 config_write 307 config_write
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c b/arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c
index ab96a2d7f4c4..11769b55438c 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_hwbutton.c
@@ -126,9 +126,6 @@ static irqreturn_t hwbutton_handler(int irq, void *data)
126 struct hwbutton_interrupt *hirq = data; 126 struct hwbutton_interrupt *hirq = data;
127 unsigned long cic_ext = *CIC_EXT_CFG_REG; 127 unsigned long cic_ext = *CIC_EXT_CFG_REG;
128 128
129 if (irq != hirq->irq)
130 return IRQ_NONE;
131
132 if (CIC_EXT_IS_ACTIVE_HI(cic_ext, hirq->eirq)) { 129 if (CIC_EXT_IS_ACTIVE_HI(cic_ext, hirq->eirq)) {
133 /* Interrupt: pin is now HI */ 130 /* Interrupt: pin is now HI */
134 CIC_EXT_SET_ACTIVE_LO(cic_ext, hirq->eirq); 131 CIC_EXT_SET_ACTIVE_LO(cic_ext, hirq->eirq);
@@ -164,7 +161,7 @@ static int msp_hwbutton_register(struct hwbutton_interrupt *hirq)
164 *CIC_EXT_CFG_REG = cic_ext; 161 *CIC_EXT_CFG_REG = cic_ext;
165 162
166 return request_irq(hirq->irq, hwbutton_handler, IRQF_DISABLED, 163 return request_irq(hirq->irq, hwbutton_handler, IRQF_DISABLED,
167 hirq->name, (void *)hirq); 164 hirq->name, hirq);
168} 165}
169 166
170static int __init msp_hwbutton_setup(void) 167static int __init msp_hwbutton_setup(void)
diff --git a/arch/mips/sgi-ip27/ip27-timer.c b/arch/mips/sgi-ip27/ip27-timer.c
index 25d3baf0ebc4..9cebc9e7da63 100644
--- a/arch/mips/sgi-ip27/ip27-timer.c
+++ b/arch/mips/sgi-ip27/ip27-timer.c
@@ -158,7 +158,7 @@ static void rt_set_mode(enum clock_event_mode mode,
158 } 158 }
159} 159}
160 160
161unsigned int rt_timer_irq; 161int rt_timer_irq;
162 162
163static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id) 163static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id)
164{ 164{
@@ -219,7 +219,7 @@ static void __cpuinit hub_rt_clock_event_init(void)
219 219
220static void __init hub_rt_clock_event_global_init(void) 220static void __init hub_rt_clock_event_global_init(void)
221{ 221{
222 unsigned int irq; 222 int irq;
223 223
224 do { 224 do {
225 smp_wmb(); 225 smp_wmb();
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 6a6409adc564..e856218da90d 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -186,17 +186,6 @@ config PREEMPT
186 Say Y here if you are building a kernel for a desktop, embedded 186 Say Y here if you are building a kernel for a desktop, embedded
187 or real-time system. Say N if you are unsure. 187 or real-time system. Say N if you are unsure.
188 188
189config PREEMPT_BKL
190 bool "Preempt The Big Kernel Lock"
191 depends on PREEMPT
192 default y
193 help
194 This option reduces the latency of the kernel by making the
195 big kernel lock preemptible.
196
197 Say Y here if you are building a kernel for a desktop system.
198 Say N if you are unsure.
199
200config MN10300_CURRENT_IN_E2 189config MN10300_CURRENT_IN_E2
201 bool "Hold current task address in E2 register" 190 bool "Hold current task address in E2 register"
202 default y 191 default y
diff --git a/arch/mn10300/boot/install.sh b/arch/mn10300/boot/install.sh
index 072951c83976..abba30971191 100644
--- a/arch/mn10300/boot/install.sh
+++ b/arch/mn10300/boot/install.sh
@@ -26,42 +26,42 @@ rm -fr $4/../usr/include/linux $4/../usr/include/asm
26install -c -m 0755 $2 $4/vmlinuz 26install -c -m 0755 $2 $4/vmlinuz
27install -c -m 0755 $5 $4/boot.rom 27install -c -m 0755 $5 $4/boot.rom
28install -c -m 0755 -d $4/../usr/include/linux 28install -c -m 0755 -d $4/../usr/include/linux
29cd $TOPDIR/include/linux 29cd ${srctree}/include/linux
30for i in `find . -maxdepth 1 -name '*.h' -print`; do 30for i in `find . -maxdepth 1 -name '*.h' -print`; do
31 install -c -m 0644 $i $4/../usr/include/linux 31 install -c -m 0644 $i $4/../usr/include/linux
32done 32done
33install -c -m 0755 -d $4/../usr/include/linux/byteorder 33install -c -m 0755 -d $4/../usr/include/linux/byteorder
34cd $TOPDIR/include/linux/byteorder 34cd ${srctree}/include/linux/byteorder
35for i in `find . -name '*.h' -print`; do 35for i in `find . -name '*.h' -print`; do
36 install -c -m 0644 $i $4/../usr/include/linux/byteorder 36 install -c -m 0644 $i $4/../usr/include/linux/byteorder
37done 37done
38install -c -m 0755 -d $4/../usr/include/linux/lockd 38install -c -m 0755 -d $4/../usr/include/linux/lockd
39cd $TOPDIR/include/linux/lockd 39cd ${srctree}/include/linux/lockd
40for i in `find . -name '*.h' -print`; do 40for i in `find . -name '*.h' -print`; do
41 install -c -m 0644 $i $4/../usr/include/linux/lockd 41 install -c -m 0644 $i $4/../usr/include/linux/lockd
42done 42done
43install -c -m 0755 -d $4/../usr/include/linux/netfilter_ipv4 43install -c -m 0755 -d $4/../usr/include/linux/netfilter_ipv4
44cd $TOPDIR/include/linux/netfilter_ipv4 44cd ${srctree}/include/linux/netfilter_ipv4
45for i in `find . -name '*.h' -print`; do 45for i in `find . -name '*.h' -print`; do
46 install -c -m 0644 $i $4/../usr/include/linux/netfilter_ipv4 46 install -c -m 0644 $i $4/../usr/include/linux/netfilter_ipv4
47done 47done
48install -c -m 0755 -d $4/../usr/include/linux/nfsd 48install -c -m 0755 -d $4/../usr/include/linux/nfsd
49cd $TOPDIR/include/linux/nfsd 49cd ${srctree}/include/linux/nfsd
50for i in `find . -name '*.h' -print`; do 50for i in `find . -name '*.h' -print`; do
51 install -c -m 0644 $i $4/../usr/include/linux/nfsd/$i 51 install -c -m 0644 $i $4/../usr/include/linux/nfsd/$i
52done 52done
53install -c -m 0755 -d $4/../usr/include/linux/raid 53install -c -m 0755 -d $4/../usr/include/linux/raid
54cd $TOPDIR/include/linux/raid 54cd ${srctree}/include/linux/raid
55for i in `find . -name '*.h' -print`; do 55for i in `find . -name '*.h' -print`; do
56 install -c -m 0644 $i $4/../usr/include/linux/raid 56 install -c -m 0644 $i $4/../usr/include/linux/raid
57done 57done
58install -c -m 0755 -d $4/../usr/include/linux/sunrpc 58install -c -m 0755 -d $4/../usr/include/linux/sunrpc
59cd $TOPDIR/include/linux/sunrpc 59cd ${srctree}/include/linux/sunrpc
60for i in `find . -name '*.h' -print`; do 60for i in `find . -name '*.h' -print`; do
61 install -c -m 0644 $i $4/../usr/include/linux/sunrpc 61 install -c -m 0644 $i $4/../usr/include/linux/sunrpc
62done 62done
63install -c -m 0755 -d $4/../usr/include/asm 63install -c -m 0755 -d $4/../usr/include/asm
64cd $TOPDIR/include/asm 64cd ${srctree}/include/asm
65for i in `find . -name '*.h' -print`; do 65for i in `find . -name '*.h' -print`; do
66 install -c -m 0644 $i $4/../usr/include/asm 66 install -c -m 0644 $i $4/../usr/include/asm
67done 67done
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 1f012843150f..b0ed709d5743 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -606,7 +606,7 @@ void show_mem(void)
606 int i, j; 606 int i, j;
607 607
608 for (i = 0; i < npmem_ranges; i++) { 608 for (i = 0; i < npmem_ranges; i++) {
609 zl = node_zonelist(i); 609 zl = node_zonelist(i, 0);
610 for (j = 0; j < MAX_NR_ZONES; j++) { 610 for (j = 0; j < MAX_NR_ZONES; j++) {
611 struct zoneref *z; 611 struct zoneref *z;
612 struct zone *zone; 612 struct zone *zone;
diff --git a/arch/powerpc/boot/dts/sequoia.dts b/arch/powerpc/boot/dts/sequoia.dts
index a1ae4d6ec990..72d67564bdfc 100644
--- a/arch/powerpc/boot/dts/sequoia.dts
+++ b/arch/powerpc/boot/dts/sequoia.dts
@@ -342,9 +342,14 @@
342 /* Outbound ranges, one memory and one IO, 342 /* Outbound ranges, one memory and one IO,
343 * later cannot be changed. Chip supports a second 343 * later cannot be changed. Chip supports a second
344 * IO range but we don't use it for now 344 * IO range but we don't use it for now
345 * From the 440EPx user manual:
346 * PCI 1 Memory 1 8000 0000 1 BFFF FFFF 1GB
347 * I/O 1 E800 0000 1 E800 FFFF 64KB
348 * I/O 1 E880 0000 1 EBFF FFFF 56MB
345 */ 349 */
346 ranges = <02000000 0 80000000 1 80000000 0 10000000 350 ranges = <02000000 0 80000000 1 80000000 0 40000000
347 01000000 0 00000000 1 e8000000 0 00100000>; 351 01000000 0 00000000 1 e8000000 0 00010000
352 01000000 0 00000000 1 e8800000 0 03800000>;
348 353
349 /* Inbound 2GB range starting at 0 */ 354 /* Inbound 2GB range starting at 0 */
350 dma-ranges = <42000000 0 0 0 0 0 80000000>; 355 dma-ranges = <42000000 0 0 0 0 0 80000000>;
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index d14cebf62bb0..2346d271fbfd 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -105,6 +105,9 @@ PHONY += systbl_chk
105systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i 105systbl_chk: $(src)/systbl_chk.sh $(obj)/systbl_chk.i
106 $(call cmd,systbl_chk) 106 $(call cmd,systbl_chk)
107 107
108
109ifeq ($(CONFIG_PPC_MERGE),y)
110
108$(obj)/built-in.o: prom_init_check 111$(obj)/built-in.o: prom_init_check
109 112
110quiet_cmd_prom_init_check = CALL $< 113quiet_cmd_prom_init_check = CALL $<
@@ -114,4 +117,7 @@ PHONY += prom_init_check
114prom_init_check: $(src)/prom_init_check.sh $(obj)/prom_init.o 117prom_init_check: $(src)/prom_init_check.sh $(obj)/prom_init.o
115 $(call cmd,prom_init_check) 118 $(call cmd,prom_init_check)
116 119
120endif
121
122
117clean-files := vmlinux.lds 123clean-files := vmlinux.lds
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 9f9377745490..d8f0329b1344 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -16,7 +16,6 @@
16#include <asm/mmu.h> 16#include <asm/mmu.h>
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/prom.h>
20#include <asm/processor.h> 19#include <asm/processor.h>
21#include <asm/udbg.h> 20#include <asm/udbg.h>
22 21
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index 36080d4d1922..e44d5530f0a6 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -1208,6 +1208,18 @@ static struct cpu_spec __initdata cpu_specs[] = {
1208 .machine_check = machine_check_4xx, 1208 .machine_check = machine_check_4xx,
1209 .platform = "ppc405", 1209 .platform = "ppc405",
1210 }, 1210 },
1211 { /* default match */
1212 .pvr_mask = 0x00000000,
1213 .pvr_value = 0x00000000,
1214 .cpu_name = "(generic 40x PPC)",
1215 .cpu_features = CPU_FTRS_40X,
1216 .cpu_user_features = PPC_FEATURE_32 |
1217 PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
1218 .icache_bsize = 32,
1219 .dcache_bsize = 32,
1220 .machine_check = machine_check_4xx,
1221 .platform = "ppc405",
1222 }
1211 1223
1212#endif /* CONFIG_40x */ 1224#endif /* CONFIG_40x */
1213#ifdef CONFIG_44x 1225#ifdef CONFIG_44x
@@ -1421,8 +1433,18 @@ static struct cpu_spec __initdata cpu_specs[] = {
1421 .machine_check = machine_check_440A, 1433 .machine_check = machine_check_440A,
1422 .platform = "ppc440", 1434 .platform = "ppc440",
1423 }, 1435 },
1436 { /* default match */
1437 .pvr_mask = 0x00000000,
1438 .pvr_value = 0x00000000,
1439 .cpu_name = "(generic 44x PPC)",
1440 .cpu_features = CPU_FTRS_44X,
1441 .cpu_user_features = COMMON_USER_BOOKE,
1442 .icache_bsize = 32,
1443 .dcache_bsize = 32,
1444 .machine_check = machine_check_4xx,
1445 .platform = "ppc440",
1446 }
1424#endif /* CONFIG_44x */ 1447#endif /* CONFIG_44x */
1425#ifdef CONFIG_FSL_BOOKE
1426#ifdef CONFIG_E200 1448#ifdef CONFIG_E200
1427 { /* e200z5 */ 1449 { /* e200z5 */
1428 .pvr_mask = 0xfff00000, 1450 .pvr_mask = 0xfff00000,
@@ -1451,7 +1473,20 @@ static struct cpu_spec __initdata cpu_specs[] = {
1451 .machine_check = machine_check_e200, 1473 .machine_check = machine_check_e200,
1452 .platform = "ppc5554", 1474 .platform = "ppc5554",
1453 }, 1475 },
1454#elif defined(CONFIG_E500) 1476 { /* default match */
1477 .pvr_mask = 0x00000000,
1478 .pvr_value = 0x00000000,
1479 .cpu_name = "(generic E200 PPC)",
1480 .cpu_features = CPU_FTRS_E200,
1481 .cpu_user_features = COMMON_USER_BOOKE |
1482 PPC_FEATURE_HAS_EFP_SINGLE |
1483 PPC_FEATURE_UNIFIED_CACHE,
1484 .dcache_bsize = 32,
1485 .machine_check = machine_check_e200,
1486 .platform = "ppc5554",
1487 }
1488#endif /* CONFIG_E200 */
1489#ifdef CONFIG_E500
1455 { /* e500 */ 1490 { /* e500 */
1456 .pvr_mask = 0xffff0000, 1491 .pvr_mask = 0xffff0000,
1457 .pvr_value = 0x80200000, 1492 .pvr_value = 0x80200000,
@@ -1487,20 +1522,20 @@ static struct cpu_spec __initdata cpu_specs[] = {
1487 .machine_check = machine_check_e500, 1522 .machine_check = machine_check_e500,
1488 .platform = "ppc8548", 1523 .platform = "ppc8548",
1489 }, 1524 },
1490#endif
1491#endif
1492#if !CLASSIC_PPC
1493 { /* default match */ 1525 { /* default match */
1494 .pvr_mask = 0x00000000, 1526 .pvr_mask = 0x00000000,
1495 .pvr_value = 0x00000000, 1527 .pvr_value = 0x00000000,
1496 .cpu_name = "(generic PPC)", 1528 .cpu_name = "(generic E500 PPC)",
1497 .cpu_features = CPU_FTRS_GENERIC_32, 1529 .cpu_features = CPU_FTRS_E500,
1498 .cpu_user_features = PPC_FEATURE_32, 1530 .cpu_user_features = COMMON_USER_BOOKE |
1531 PPC_FEATURE_HAS_SPE_COMP |
1532 PPC_FEATURE_HAS_EFP_SINGLE_COMP,
1499 .icache_bsize = 32, 1533 .icache_bsize = 32,
1500 .dcache_bsize = 32, 1534 .dcache_bsize = 32,
1535 .machine_check = machine_check_e500,
1501 .platform = "powerpc", 1536 .platform = "powerpc",
1502 } 1537 }
1503#endif /* !CLASSIC_PPC */ 1538#endif /* CONFIG_E500 */
1504#endif /* CONFIG_PPC32 */ 1539#endif /* CONFIG_PPC32 */
1505}; 1540};
1506 1541
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index b84ec6a2fc94..c2b9dc4fce5d 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -653,7 +653,14 @@ finish_tlb_load:
653 rlwimi r10, r11, 0, 26, 26 /* UX = HWEXEC & USER */ 653 rlwimi r10, r11, 0, 26, 26 /* UX = HWEXEC & USER */
654 654
655 rlwimi r12, r10, 0, 26, 31 /* Insert static perms */ 655 rlwimi r12, r10, 0, 26, 31 /* Insert static perms */
656 rlwinm r12, r12, 0, 20, 15 /* Clear U0-U3 */ 656
657 /*
658 * Clear U0-U3 and WL1 IL1I IL1D IL2I IL2D bits which are added
659 * on newer 440 cores like the 440x6 used on AMCC 460EX/460GT (see
660 * include/asm-powerpc/pgtable-ppc32.h for details).
661 */
662 rlwinm r12, r12, 0, 20, 10
663
657 tlbwe r12, r13, PPC44x_TLB_ATTRIB /* Write ATTRIB */ 664 tlbwe r12, r13, PPC44x_TLB_ATTRIB /* Write ATTRIB */
658 665
659 /* Done...restore registers and get out of here. 666 /* Done...restore registers and get out of here.
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 024805e1747d..25e84c0e1166 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -1517,10 +1517,6 @@ _INIT_STATIC(start_here_multiplatform)
1517 addi r2,r2,0x4000 1517 addi r2,r2,0x4000
1518 add r2,r2,r26 1518 add r2,r2,r26
1519 1519
1520 /* Set initial ptr to current */
1521 LOAD_REG_IMMEDIATE(r4, init_task)
1522 std r4,PACACURRENT(r13)
1523
1524 /* Do very early kernel initializations, including initial hash table, 1520 /* Do very early kernel initializations, including initial hash table,
1525 * stab and slb setup before we turn on relocation. */ 1521 * stab and slb setup before we turn on relocation. */
1526 1522
diff --git a/arch/powerpc/kernel/isa-bridge.c b/arch/powerpc/kernel/isa-bridge.c
index 289af348978d..4d5731b2429a 100644
--- a/arch/powerpc/kernel/isa-bridge.c
+++ b/arch/powerpc/kernel/isa-bridge.c
@@ -108,9 +108,6 @@ static void __devinit pci_process_ISA_OF_ranges(struct device_node *isa_node,
108 if (size > 0x10000) 108 if (size > 0x10000)
109 size = 0x10000; 109 size = 0x10000;
110 110
111 printk(KERN_ERR "no ISA IO ranges or unexpected isa range, "
112 "mapping 64k\n");
113
114 __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE, 111 __ioremap_at(phb_io_base_phys, (void *)ISA_IO_BASE,
115 size, _PAGE_NO_CACHE|_PAGE_GUARDED); 112 size, _PAGE_NO_CACHE|_PAGE_GUARDED);
116 return; 113 return;
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 25e3fd8606ab..098fd96a394a 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -170,6 +170,8 @@ void __init setup_paca(int cpu)
170 170
171void __init early_setup(unsigned long dt_ptr) 171void __init early_setup(unsigned long dt_ptr)
172{ 172{
173 /* -------- printk is _NOT_ safe to use here ! ------- */
174
173 /* Fill in any unititialised pacas */ 175 /* Fill in any unititialised pacas */
174 initialise_pacas(); 176 initialise_pacas();
175 177
@@ -179,12 +181,14 @@ void __init early_setup(unsigned long dt_ptr)
179 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */ 181 /* Assume we're on cpu 0 for now. Don't write to the paca yet! */
180 setup_paca(0); 182 setup_paca(0);
181 183
182 /* Enable early debugging if any specified (see udbg.h) */
183 udbg_early_init();
184
185 /* Initialize lockdep early or else spinlocks will blow */ 184 /* Initialize lockdep early or else spinlocks will blow */
186 lockdep_init(); 185 lockdep_init();
187 186
187 /* -------- printk is now safe to use ------- */
188
189 /* Enable early debugging if any specified (see udbg.h) */
190 udbg_early_init();
191
188 DBG(" -> early_setup(), dt_ptr: 0x%lx\n", dt_ptr); 192 DBG(" -> early_setup(), dt_ptr: 0x%lx\n", dt_ptr);
189 193
190 /* 194 /*
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 4bb023f4c869..c71d37dc6a88 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -10,6 +10,7 @@ ifeq ($(CONFIG_PPC_MERGE),y)
10obj-y := string.o alloc.o \ 10obj-y := string.o alloc.o \
11 checksum_$(CONFIG_WORD_SIZE).o 11 checksum_$(CONFIG_WORD_SIZE).o
12obj-$(CONFIG_PPC32) += div64.o copy_32.o 12obj-$(CONFIG_PPC32) += div64.o copy_32.o
13obj-$(CONFIG_HAS_IOMEM) += devres.o
13endif 14endif
14 15
15obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \ 16obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \
diff --git a/arch/powerpc/lib/devres.c b/arch/powerpc/lib/devres.c
new file mode 100644
index 000000000000..292115d98ea9
--- /dev/null
+++ b/arch/powerpc/lib/devres.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright (C) 2008 Freescale Semiconductor, Inc.
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
10#include <linux/device.h> /* devres_*(), devm_ioremap_release() */
11#include <linux/io.h> /* ioremap_flags() */
12#include <linux/module.h> /* EXPORT_SYMBOL() */
13
14/**
15 * devm_ioremap_prot - Managed ioremap_flags()
16 * @dev: Generic device to remap IO address for
17 * @offset: BUS offset to map
18 * @size: Size of map
19 * @flags: Page flags
20 *
21 * Managed ioremap_prot(). Map is automatically unmapped on driver
22 * detach.
23 */
24void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
25 size_t size, unsigned long flags)
26{
27 void __iomem **ptr, *addr;
28
29 ptr = devres_alloc(devm_ioremap_release, sizeof(*ptr), GFP_KERNEL);
30 if (!ptr)
31 return NULL;
32
33 addr = ioremap_flags(offset, size, flags);
34 if (addr) {
35 *ptr = addr;
36 devres_add(dev, ptr);
37 } else
38 devres_free(ptr);
39
40 return addr;
41}
42EXPORT_SYMBOL(devm_ioremap_prot);
diff --git a/arch/powerpc/platforms/cell/interrupt.c b/arch/powerpc/platforms/cell/interrupt.c
index 04f74f9f9ab6..5bf7df146022 100644
--- a/arch/powerpc/platforms/cell/interrupt.c
+++ b/arch/powerpc/platforms/cell/interrupt.c
@@ -35,6 +35,7 @@
35#include <linux/percpu.h> 35#include <linux/percpu.h>
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/ioport.h> 37#include <linux/ioport.h>
38#include <linux/kernel_stat.h>
38 39
39#include <asm/io.h> 40#include <asm/io.h>
40#include <asm/pgtable.h> 41#include <asm/pgtable.h>
@@ -231,6 +232,54 @@ static int iic_host_match(struct irq_host *h, struct device_node *node)
231 "IBM,CBEA-Internal-Interrupt-Controller"); 232 "IBM,CBEA-Internal-Interrupt-Controller");
232} 233}
233 234
235extern int noirqdebug;
236
237static void handle_iic_irq(unsigned int irq, struct irq_desc *desc)
238{
239 const unsigned int cpu = smp_processor_id();
240
241 spin_lock(&desc->lock);
242
243 desc->status &= ~(IRQ_REPLAY | IRQ_WAITING);
244
245 /*
246 * If we're currently running this IRQ, or its disabled,
247 * we shouldn't process the IRQ. Mark it pending, handle
248 * the necessary masking and go out
249 */
250 if (unlikely((desc->status & (IRQ_INPROGRESS | IRQ_DISABLED)) ||
251 !desc->action)) {
252 desc->status |= IRQ_PENDING;
253 goto out_eoi;
254 }
255
256 kstat_cpu(cpu).irqs[irq]++;
257
258 /* Mark the IRQ currently in progress.*/
259 desc->status |= IRQ_INPROGRESS;
260
261 do {
262 struct irqaction *action = desc->action;
263 irqreturn_t action_ret;
264
265 if (unlikely(!action))
266 goto out_eoi;
267
268 desc->status &= ~IRQ_PENDING;
269 spin_unlock(&desc->lock);
270 action_ret = handle_IRQ_event(irq, action);
271 if (!noirqdebug)
272 note_interrupt(irq, desc, action_ret);
273 spin_lock(&desc->lock);
274
275 } while ((desc->status & (IRQ_PENDING | IRQ_DISABLED)) == IRQ_PENDING);
276
277 desc->status &= ~IRQ_INPROGRESS;
278out_eoi:
279 desc->chip->eoi(irq);
280 spin_unlock(&desc->lock);
281}
282
234static int iic_host_map(struct irq_host *h, unsigned int virq, 283static int iic_host_map(struct irq_host *h, unsigned int virq,
235 irq_hw_number_t hw) 284 irq_hw_number_t hw)
236{ 285{
@@ -240,10 +289,10 @@ static int iic_host_map(struct irq_host *h, unsigned int virq,
240 break; 289 break;
241 case IIC_IRQ_TYPE_IOEXC: 290 case IIC_IRQ_TYPE_IOEXC:
242 set_irq_chip_and_handler(virq, &iic_ioexc_chip, 291 set_irq_chip_and_handler(virq, &iic_ioexc_chip,
243 handle_fasteoi_irq); 292 handle_iic_irq);
244 break; 293 break;
245 default: 294 default:
246 set_irq_chip_and_handler(virq, &iic_chip, handle_fasteoi_irq); 295 set_irq_chip_and_handler(virq, &iic_chip, handle_iic_irq);
247 } 296 }
248 return 0; 297 return 0;
249} 298}
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 6bab44b7716b..70c660121ec4 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -141,6 +141,10 @@ static void spu_restart_dma(struct spu *spu)
141 141
142 if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags)) 142 if (!test_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags))
143 out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND); 143 out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
144 else {
145 set_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags);
146 mb();
147 }
144} 148}
145 149
146static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb) 150static inline void spu_load_slb(struct spu *spu, int slbe, struct spu_slb *slb)
@@ -226,11 +230,13 @@ static int __spu_trap_data_map(struct spu *spu, unsigned long ea, u64 dsisr)
226 return 0; 230 return 0;
227 } 231 }
228 232
229 spu->class_0_pending = 0; 233 spu->class_1_dar = ea;
230 spu->dar = ea; 234 spu->class_1_dsisr = dsisr;
231 spu->dsisr = dsisr; 235
236 spu->stop_callback(spu, 1);
232 237
233 spu->stop_callback(spu); 238 spu->class_1_dar = 0;
239 spu->class_1_dsisr = 0;
234 240
235 return 0; 241 return 0;
236} 242}
@@ -318,11 +324,15 @@ spu_irq_class_0(int irq, void *data)
318 stat = spu_int_stat_get(spu, 0) & mask; 324 stat = spu_int_stat_get(spu, 0) & mask;
319 325
320 spu->class_0_pending |= stat; 326 spu->class_0_pending |= stat;
321 spu->dsisr = spu_mfc_dsisr_get(spu); 327 spu->class_0_dsisr = spu_mfc_dsisr_get(spu);
322 spu->dar = spu_mfc_dar_get(spu); 328 spu->class_0_dar = spu_mfc_dar_get(spu);
323 spin_unlock(&spu->register_lock); 329 spin_unlock(&spu->register_lock);
324 330
325 spu->stop_callback(spu); 331 spu->stop_callback(spu, 0);
332
333 spu->class_0_pending = 0;
334 spu->class_0_dsisr = 0;
335 spu->class_0_dar = 0;
326 336
327 spu_int_stat_clear(spu, 0, stat); 337 spu_int_stat_clear(spu, 0, stat);
328 338
@@ -363,6 +373,9 @@ spu_irq_class_1(int irq, void *data)
363 if (stat & CLASS1_LS_COMPARE_SUSPEND_ON_PUT_INTR) 373 if (stat & CLASS1_LS_COMPARE_SUSPEND_ON_PUT_INTR)
364 ; 374 ;
365 375
376 spu->class_1_dsisr = 0;
377 spu->class_1_dar = 0;
378
366 return stat ? IRQ_HANDLED : IRQ_NONE; 379 return stat ? IRQ_HANDLED : IRQ_NONE;
367} 380}
368 381
@@ -396,10 +409,10 @@ spu_irq_class_2(int irq, void *data)
396 spu->ibox_callback(spu); 409 spu->ibox_callback(spu);
397 410
398 if (stat & CLASS2_SPU_STOP_INTR) 411 if (stat & CLASS2_SPU_STOP_INTR)
399 spu->stop_callback(spu); 412 spu->stop_callback(spu, 2);
400 413
401 if (stat & CLASS2_SPU_HALT_INTR) 414 if (stat & CLASS2_SPU_HALT_INTR)
402 spu->stop_callback(spu); 415 spu->stop_callback(spu, 2);
403 416
404 if (stat & CLASS2_SPU_DMA_TAG_GROUP_COMPLETE_INTR) 417 if (stat & CLASS2_SPU_DMA_TAG_GROUP_COMPLETE_INTR)
405 spu->mfc_callback(spu); 418 spu->mfc_callback(spu);
diff --git a/arch/powerpc/platforms/cell/spu_priv1_mmio.c b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
index 67fa7247b80a..906a0a2a9fe1 100644
--- a/arch/powerpc/platforms/cell/spu_priv1_mmio.c
+++ b/arch/powerpc/platforms/cell/spu_priv1_mmio.c
@@ -28,6 +28,7 @@
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/mutex.h> 29#include <linux/mutex.h>
30#include <linux/device.h> 30#include <linux/device.h>
31#include <linux/sched.h>
31 32
32#include <asm/spu.h> 33#include <asm/spu.h>
33#include <asm/spu_priv1.h> 34#include <asm/spu_priv1.h>
@@ -75,8 +76,19 @@ static u64 int_stat_get(struct spu *spu, int class)
75 76
76static void cpu_affinity_set(struct spu *spu, int cpu) 77static void cpu_affinity_set(struct spu *spu, int cpu)
77{ 78{
78 u64 target = iic_get_target_id(cpu); 79 u64 target;
79 u64 route = target << 48 | target << 32 | target << 16; 80 u64 route;
81
82 if (nr_cpus_node(spu->node)) {
83 cpumask_t spumask = node_to_cpumask(spu->node);
84 cpumask_t cpumask = node_to_cpumask(cpu_to_node(cpu));
85
86 if (!cpus_intersects(spumask, cpumask))
87 return;
88 }
89
90 target = iic_get_target_id(cpu);
91 route = target << 48 | target << 32 | target << 16;
80 out_be64(&spu->priv1->int_route_RW, route); 92 out_be64(&spu->priv1->int_route_RW, route);
81} 93}
82 94
diff --git a/arch/powerpc/platforms/cell/spufs/fault.c b/arch/powerpc/platforms/cell/spufs/fault.c
index e46d300e21a5..f093a581ac74 100644
--- a/arch/powerpc/platforms/cell/spufs/fault.c
+++ b/arch/powerpc/platforms/cell/spufs/fault.c
@@ -83,13 +83,18 @@ int spufs_handle_class0(struct spu_context *ctx)
83 return 0; 83 return 0;
84 84
85 if (stat & CLASS0_DMA_ALIGNMENT_INTR) 85 if (stat & CLASS0_DMA_ALIGNMENT_INTR)
86 spufs_handle_event(ctx, ctx->csa.dar, SPE_EVENT_DMA_ALIGNMENT); 86 spufs_handle_event(ctx, ctx->csa.class_0_dar,
87 SPE_EVENT_DMA_ALIGNMENT);
87 88
88 if (stat & CLASS0_INVALID_DMA_COMMAND_INTR) 89 if (stat & CLASS0_INVALID_DMA_COMMAND_INTR)
89 spufs_handle_event(ctx, ctx->csa.dar, SPE_EVENT_INVALID_DMA); 90 spufs_handle_event(ctx, ctx->csa.class_0_dar,
91 SPE_EVENT_INVALID_DMA);
90 92
91 if (stat & CLASS0_SPU_ERROR_INTR) 93 if (stat & CLASS0_SPU_ERROR_INTR)
92 spufs_handle_event(ctx, ctx->csa.dar, SPE_EVENT_SPE_ERROR); 94 spufs_handle_event(ctx, ctx->csa.class_0_dar,
95 SPE_EVENT_SPE_ERROR);
96
97 ctx->csa.class_0_pending = 0;
93 98
94 return -EIO; 99 return -EIO;
95} 100}
@@ -119,8 +124,8 @@ int spufs_handle_class1(struct spu_context *ctx)
119 * in time, we can still expect to get the same fault 124 * in time, we can still expect to get the same fault
120 * the immediately after the context restore. 125 * the immediately after the context restore.
121 */ 126 */
122 ea = ctx->csa.dar; 127 ea = ctx->csa.class_1_dar;
123 dsisr = ctx->csa.dsisr; 128 dsisr = ctx->csa.class_1_dsisr;
124 129
125 if (!(dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED))) 130 if (!(dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED)))
126 return 0; 131 return 0;
@@ -158,7 +163,7 @@ int spufs_handle_class1(struct spu_context *ctx)
158 * time slicing will not preempt the context while the page fault 163 * time slicing will not preempt the context while the page fault
159 * handler is running. Context switch code removes mappings. 164 * handler is running. Context switch code removes mappings.
160 */ 165 */
161 ctx->csa.dar = ctx->csa.dsisr = 0; 166 ctx->csa.class_1_dar = ctx->csa.class_1_dsisr = 0;
162 167
163 /* 168 /*
164 * If we handled the fault successfully and are in runnable 169 * If we handled the fault successfully and are in runnable
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 0c32a05ab068..f407b2471855 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -23,6 +23,7 @@
23 23
24#include <linux/file.h> 24#include <linux/file.h>
25#include <linux/fs.h> 25#include <linux/fs.h>
26#include <linux/fsnotify.h>
26#include <linux/backing-dev.h> 27#include <linux/backing-dev.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/ioctl.h> 29#include <linux/ioctl.h>
@@ -223,7 +224,7 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
223 parent = dir->d_parent->d_inode; 224 parent = dir->d_parent->d_inode;
224 ctx = SPUFS_I(dir->d_inode)->i_ctx; 225 ctx = SPUFS_I(dir->d_inode)->i_ctx;
225 226
226 mutex_lock(&parent->i_mutex); 227 mutex_lock_nested(&parent->i_mutex, I_MUTEX_PARENT);
227 ret = spufs_rmdir(parent, dir); 228 ret = spufs_rmdir(parent, dir);
228 mutex_unlock(&parent->i_mutex); 229 mutex_unlock(&parent->i_mutex);
229 WARN_ON(ret); 230 WARN_ON(ret);
@@ -618,12 +619,15 @@ long spufs_create(struct nameidata *nd, unsigned int flags, mode_t mode,
618 mode &= ~current->fs->umask; 619 mode &= ~current->fs->umask;
619 620
620 if (flags & SPU_CREATE_GANG) 621 if (flags & SPU_CREATE_GANG)
621 return spufs_create_gang(nd->path.dentry->d_inode, 622 ret = spufs_create_gang(nd->path.dentry->d_inode,
622 dentry, nd->path.mnt, mode); 623 dentry, nd->path.mnt, mode);
623 else 624 else
624 return spufs_create_context(nd->path.dentry->d_inode, 625 ret = spufs_create_context(nd->path.dentry->d_inode,
625 dentry, nd->path.mnt, flags, mode, 626 dentry, nd->path.mnt, flags, mode,
626 filp); 627 filp);
628 if (ret >= 0)
629 fsnotify_mkdir(nd->path.dentry->d_inode, dentry);
630 return ret;
627 631
628out_dput: 632out_dput:
629 dput(dentry); 633 dput(dentry);
diff --git a/arch/powerpc/platforms/cell/spufs/run.c b/arch/powerpc/platforms/cell/spufs/run.c
index a9c35b7b719f..b7493b865812 100644
--- a/arch/powerpc/platforms/cell/spufs/run.c
+++ b/arch/powerpc/platforms/cell/spufs/run.c
@@ -11,7 +11,7 @@
11#include "spufs.h" 11#include "spufs.h"
12 12
13/* interrupt-level stop callback function. */ 13/* interrupt-level stop callback function. */
14void spufs_stop_callback(struct spu *spu) 14void spufs_stop_callback(struct spu *spu, int irq)
15{ 15{
16 struct spu_context *ctx = spu->ctx; 16 struct spu_context *ctx = spu->ctx;
17 17
@@ -24,9 +24,19 @@ void spufs_stop_callback(struct spu *spu)
24 */ 24 */
25 if (ctx) { 25 if (ctx) {
26 /* Copy exception arguments into module specific structure */ 26 /* Copy exception arguments into module specific structure */
27 ctx->csa.class_0_pending = spu->class_0_pending; 27 switch(irq) {
28 ctx->csa.dsisr = spu->dsisr; 28 case 0 :
29 ctx->csa.dar = spu->dar; 29 ctx->csa.class_0_pending = spu->class_0_pending;
30 ctx->csa.class_0_dsisr = spu->class_0_dsisr;
31 ctx->csa.class_0_dar = spu->class_0_dar;
32 break;
33 case 1 :
34 ctx->csa.class_1_dsisr = spu->class_1_dsisr;
35 ctx->csa.class_1_dar = spu->class_1_dar;
36 break;
37 case 2 :
38 break;
39 }
30 40
31 /* ensure that the exception status has hit memory before a 41 /* ensure that the exception status has hit memory before a
32 * thread waiting on the context's stop queue is woken */ 42 * thread waiting on the context's stop queue is woken */
@@ -34,11 +44,6 @@ void spufs_stop_callback(struct spu *spu)
34 44
35 wake_up_all(&ctx->stop_wq); 45 wake_up_all(&ctx->stop_wq);
36 } 46 }
37
38 /* Clear callback arguments from spu structure */
39 spu->class_0_pending = 0;
40 spu->dsisr = 0;
41 spu->dar = 0;
42} 47}
43 48
44int spu_stopped(struct spu_context *ctx, u32 *stat) 49int spu_stopped(struct spu_context *ctx, u32 *stat)
@@ -56,7 +61,11 @@ int spu_stopped(struct spu_context *ctx, u32 *stat)
56 if (!(*stat & SPU_STATUS_RUNNING) && (*stat & stopped)) 61 if (!(*stat & SPU_STATUS_RUNNING) && (*stat & stopped))
57 return 1; 62 return 1;
58 63
59 dsisr = ctx->csa.dsisr; 64 dsisr = ctx->csa.class_0_dsisr;
65 if (dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED))
66 return 1;
67
68 dsisr = ctx->csa.class_1_dsisr;
60 if (dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED)) 69 if (dsisr & (MFC_DSISR_PTE_NOT_FOUND | MFC_DSISR_ACCESS_DENIED))
61 return 1; 70 return 1;
62 71
@@ -294,7 +303,7 @@ static int spu_process_callback(struct spu_context *ctx)
294 u32 ls_pointer, npc; 303 u32 ls_pointer, npc;
295 void __iomem *ls; 304 void __iomem *ls;
296 long spu_ret; 305 long spu_ret;
297 int ret, ret2; 306 int ret;
298 307
299 /* get syscall block from local store */ 308 /* get syscall block from local store */
300 npc = ctx->ops->npc_read(ctx) & ~3; 309 npc = ctx->ops->npc_read(ctx) & ~3;
@@ -316,11 +325,9 @@ static int spu_process_callback(struct spu_context *ctx)
316 if (spu_ret <= -ERESTARTSYS) { 325 if (spu_ret <= -ERESTARTSYS) {
317 ret = spu_handle_restartsys(ctx, &spu_ret, &npc); 326 ret = spu_handle_restartsys(ctx, &spu_ret, &npc);
318 } 327 }
319 ret2 = spu_acquire(ctx); 328 mutex_lock(&ctx->state_mutex);
320 if (ret == -ERESTARTSYS) 329 if (ret == -ERESTARTSYS)
321 return ret; 330 return ret;
322 if (ret2)
323 return -EINTR;
324 } 331 }
325 332
326 /* need to re-get the ls, as it may have changed when we released the 333 /* need to re-get the ls, as it may have changed when we released the
@@ -343,13 +350,14 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)
343 if (mutex_lock_interruptible(&ctx->run_mutex)) 350 if (mutex_lock_interruptible(&ctx->run_mutex))
344 return -ERESTARTSYS; 351 return -ERESTARTSYS;
345 352
346 spu_enable_spu(ctx);
347 ctx->event_return = 0; 353 ctx->event_return = 0;
348 354
349 ret = spu_acquire(ctx); 355 ret = spu_acquire(ctx);
350 if (ret) 356 if (ret)
351 goto out_unlock; 357 goto out_unlock;
352 358
359 spu_enable_spu(ctx);
360
353 spu_update_sched_info(ctx); 361 spu_update_sched_info(ctx);
354 362
355 ret = spu_run_init(ctx, npc); 363 ret = spu_run_init(ctx, npc);
diff --git a/arch/powerpc/platforms/cell/spufs/sched.c b/arch/powerpc/platforms/cell/spufs/sched.c
index 7298e7db2c83..2e411f23462b 100644
--- a/arch/powerpc/platforms/cell/spufs/sched.c
+++ b/arch/powerpc/platforms/cell/spufs/sched.c
@@ -140,6 +140,9 @@ void __spu_update_sched_info(struct spu_context *ctx)
140 * if it is timesliced or preempted. 140 * if it is timesliced or preempted.
141 */ 141 */
142 ctx->cpus_allowed = current->cpus_allowed; 142 ctx->cpus_allowed = current->cpus_allowed;
143
144 /* Save the current cpu id for spu interrupt routing. */
145 ctx->last_ran = raw_smp_processor_id();
143} 146}
144 147
145void spu_update_sched_info(struct spu_context *ctx) 148void spu_update_sched_info(struct spu_context *ctx)
@@ -243,7 +246,6 @@ static void spu_bind_context(struct spu *spu, struct spu_context *ctx)
243 spu_switch_log_notify(spu, ctx, SWITCH_LOG_START, 0); 246 spu_switch_log_notify(spu, ctx, SWITCH_LOG_START, 0);
244 spu_restore(&ctx->csa, spu); 247 spu_restore(&ctx->csa, spu);
245 spu->timestamp = jiffies; 248 spu->timestamp = jiffies;
246 spu_cpu_affinity_set(spu, raw_smp_processor_id());
247 spu_switch_notify(spu, ctx); 249 spu_switch_notify(spu, ctx);
248 ctx->state = SPU_STATE_RUNNABLE; 250 ctx->state = SPU_STATE_RUNNABLE;
249 251
@@ -657,7 +659,8 @@ static struct spu *find_victim(struct spu_context *ctx)
657 659
658 victim->stats.invol_ctx_switch++; 660 victim->stats.invol_ctx_switch++;
659 spu->stats.invol_ctx_switch++; 661 spu->stats.invol_ctx_switch++;
660 spu_add_to_rq(victim); 662 if (test_bit(SPU_SCHED_SPU_RUN, &ctx->sched_flags))
663 spu_add_to_rq(victim);
661 664
662 mutex_unlock(&victim->state_mutex); 665 mutex_unlock(&victim->state_mutex);
663 666
diff --git a/arch/powerpc/platforms/cell/spufs/spufs.h b/arch/powerpc/platforms/cell/spufs/spufs.h
index 7312745b7540..454c277c1457 100644
--- a/arch/powerpc/platforms/cell/spufs/spufs.h
+++ b/arch/powerpc/platforms/cell/spufs/spufs.h
@@ -121,6 +121,7 @@ struct spu_context {
121 cpumask_t cpus_allowed; 121 cpumask_t cpus_allowed;
122 int policy; 122 int policy;
123 int prio; 123 int prio;
124 int last_ran;
124 125
125 /* statistics */ 126 /* statistics */
126 struct { 127 struct {
@@ -331,7 +332,7 @@ size_t spu_ibox_read(struct spu_context *ctx, u32 *data);
331/* irq callback funcs. */ 332/* irq callback funcs. */
332void spufs_ibox_callback(struct spu *spu); 333void spufs_ibox_callback(struct spu *spu);
333void spufs_wbox_callback(struct spu *spu); 334void spufs_wbox_callback(struct spu *spu);
334void spufs_stop_callback(struct spu *spu); 335void spufs_stop_callback(struct spu *spu, int irq);
335void spufs_mfc_callback(struct spu *spu); 336void spufs_mfc_callback(struct spu *spu);
336void spufs_dma_callback(struct spu *spu, int type); 337void spufs_dma_callback(struct spu *spu, int type);
337 338
diff --git a/arch/powerpc/platforms/cell/spufs/switch.c b/arch/powerpc/platforms/cell/spufs/switch.c
index d2a1249d36dd..3df9a36eb2f5 100644
--- a/arch/powerpc/platforms/cell/spufs/switch.c
+++ b/arch/powerpc/platforms/cell/spufs/switch.c
@@ -132,6 +132,14 @@ static inline void disable_interrupts(struct spu_state *csa, struct spu *spu)
132 spu_int_mask_set(spu, 2, 0ul); 132 spu_int_mask_set(spu, 2, 0ul);
133 eieio(); 133 eieio();
134 spin_unlock_irq(&spu->register_lock); 134 spin_unlock_irq(&spu->register_lock);
135
136 /*
137 * This flag needs to be set before calling synchronize_irq so
138 * that the update will be visible to the relevant handlers
139 * via a simple load.
140 */
141 set_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
142 clear_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags);
135 synchronize_irq(spu->irqs[0]); 143 synchronize_irq(spu->irqs[0]);
136 synchronize_irq(spu->irqs[1]); 144 synchronize_irq(spu->irqs[1]);
137 synchronize_irq(spu->irqs[2]); 145 synchronize_irq(spu->irqs[2]);
@@ -166,9 +174,8 @@ static inline void set_switch_pending(struct spu_state *csa, struct spu *spu)
166 /* Save, Step 7: 174 /* Save, Step 7:
167 * Restore, Step 5: 175 * Restore, Step 5:
168 * Set a software context switch pending flag. 176 * Set a software context switch pending flag.
177 * Done above in Step 3 - disable_interrupts().
169 */ 178 */
170 set_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
171 mb();
172} 179}
173 180
174static inline void save_mfc_cntl(struct spu_state *csa, struct spu *spu) 181static inline void save_mfc_cntl(struct spu_state *csa, struct spu *spu)
@@ -186,20 +193,21 @@ static inline void save_mfc_cntl(struct spu_state *csa, struct spu *spu)
186 MFC_CNTL_SUSPEND_COMPLETE); 193 MFC_CNTL_SUSPEND_COMPLETE);
187 /* fall through */ 194 /* fall through */
188 case MFC_CNTL_SUSPEND_COMPLETE: 195 case MFC_CNTL_SUSPEND_COMPLETE:
189 if (csa) { 196 if (csa)
190 csa->priv2.mfc_control_RW = 197 csa->priv2.mfc_control_RW =
191 MFC_CNTL_SUSPEND_MASK | 198 in_be64(&priv2->mfc_control_RW) |
192 MFC_CNTL_SUSPEND_DMA_QUEUE; 199 MFC_CNTL_SUSPEND_DMA_QUEUE;
193 }
194 break; 200 break;
195 case MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION: 201 case MFC_CNTL_NORMAL_DMA_QUEUE_OPERATION:
196 out_be64(&priv2->mfc_control_RW, MFC_CNTL_SUSPEND_DMA_QUEUE); 202 out_be64(&priv2->mfc_control_RW, MFC_CNTL_SUSPEND_DMA_QUEUE);
197 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) & 203 POLL_WHILE_FALSE((in_be64(&priv2->mfc_control_RW) &
198 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) == 204 MFC_CNTL_SUSPEND_DMA_STATUS_MASK) ==
199 MFC_CNTL_SUSPEND_COMPLETE); 205 MFC_CNTL_SUSPEND_COMPLETE);
200 if (csa) { 206 if (csa)
201 csa->priv2.mfc_control_RW = 0; 207 csa->priv2.mfc_control_RW =
202 } 208 in_be64(&priv2->mfc_control_RW) &
209 ~MFC_CNTL_SUSPEND_DMA_QUEUE &
210 ~MFC_CNTL_SUSPEND_MASK;
203 break; 211 break;
204 } 212 }
205} 213}
@@ -249,16 +257,21 @@ static inline void save_spu_status(struct spu_state *csa, struct spu *spu)
249 } 257 }
250} 258}
251 259
252static inline void save_mfc_decr(struct spu_state *csa, struct spu *spu) 260static inline void save_mfc_stopped_status(struct spu_state *csa,
261 struct spu *spu)
253{ 262{
254 struct spu_priv2 __iomem *priv2 = spu->priv2; 263 struct spu_priv2 __iomem *priv2 = spu->priv2;
264 const u64 mask = MFC_CNTL_DECREMENTER_RUNNING |
265 MFC_CNTL_DMA_QUEUES_EMPTY;
255 266
256 /* Save, Step 12: 267 /* Save, Step 12:
257 * Read MFC_CNTL[Ds]. Update saved copy of 268 * Read MFC_CNTL[Ds]. Update saved copy of
258 * CSA.MFC_CNTL[Ds]. 269 * CSA.MFC_CNTL[Ds].
270 *
271 * update: do the same with MFC_CNTL[Q].
259 */ 272 */
260 csa->priv2.mfc_control_RW |= 273 csa->priv2.mfc_control_RW &= ~mask;
261 in_be64(&priv2->mfc_control_RW) & MFC_CNTL_DECREMENTER_RUNNING; 274 csa->priv2.mfc_control_RW |= in_be64(&priv2->mfc_control_RW) & mask;
262} 275}
263 276
264static inline void halt_mfc_decr(struct spu_state *csa, struct spu *spu) 277static inline void halt_mfc_decr(struct spu_state *csa, struct spu *spu)
@@ -462,7 +475,9 @@ static inline void purge_mfc_queue(struct spu_state *csa, struct spu *spu)
462 * Restore, Step 14. 475 * Restore, Step 14.
463 * Write MFC_CNTL[Pc]=1 (purge queue). 476 * Write MFC_CNTL[Pc]=1 (purge queue).
464 */ 477 */
465 out_be64(&priv2->mfc_control_RW, MFC_CNTL_PURGE_DMA_REQUEST); 478 out_be64(&priv2->mfc_control_RW,
479 MFC_CNTL_PURGE_DMA_REQUEST |
480 MFC_CNTL_SUSPEND_MASK);
466 eieio(); 481 eieio();
467} 482}
468 483
@@ -725,10 +740,14 @@ static inline void set_switch_active(struct spu_state *csa, struct spu *spu)
725 /* Save, Step 48: 740 /* Save, Step 48:
726 * Restore, Step 23. 741 * Restore, Step 23.
727 * Change the software context switch pending flag 742 * Change the software context switch pending flag
728 * to context switch active. 743 * to context switch active. This implementation does
744 * not uses a switch active flag.
729 * 745 *
730 * This implementation does not uses a switch active flag. 746 * Now that we have saved the mfc in the csa, we can add in the
747 * restart command if an exception occurred.
731 */ 748 */
749 if (test_bit(SPU_CONTEXT_FAULT_PENDING, &spu->flags))
750 csa->priv2.mfc_control_RW |= MFC_CNTL_RESTART_DMA_COMMAND;
732 clear_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags); 751 clear_bit(SPU_CONTEXT_SWITCH_PENDING, &spu->flags);
733 mb(); 752 mb();
734} 753}
@@ -1690,6 +1709,13 @@ static inline void restore_mfc_sr1(struct spu_state *csa, struct spu *spu)
1690 eieio(); 1709 eieio();
1691} 1710}
1692 1711
1712static inline void set_int_route(struct spu_state *csa, struct spu *spu)
1713{
1714 struct spu_context *ctx = spu->ctx;
1715
1716 spu_cpu_affinity_set(spu, ctx->last_ran);
1717}
1718
1693static inline void restore_other_spu_access(struct spu_state *csa, 1719static inline void restore_other_spu_access(struct spu_state *csa,
1694 struct spu *spu) 1720 struct spu *spu)
1695{ 1721{
@@ -1721,15 +1747,15 @@ static inline void restore_mfc_cntl(struct spu_state *csa, struct spu *spu)
1721 */ 1747 */
1722 out_be64(&priv2->mfc_control_RW, csa->priv2.mfc_control_RW); 1748 out_be64(&priv2->mfc_control_RW, csa->priv2.mfc_control_RW);
1723 eieio(); 1749 eieio();
1750
1724 /* 1751 /*
1725 * FIXME: this is to restart a DMA that we were processing 1752 * The queue is put back into the same state that was evident prior to
1726 * before the save. better remember the fault information 1753 * the context switch. The suspend flag is added to the saved state in
1727 * in the csa instead. 1754 * the csa, if the operational state was suspending or suspended. In
1755 * this case, the code that suspended the mfc is responsible for
1756 * continuing it. Note that SPE faults do not change the operational
1757 * state of the spu.
1728 */ 1758 */
1729 if ((csa->priv2.mfc_control_RW & MFC_CNTL_SUSPEND_DMA_QUEUE_MASK)) {
1730 out_be64(&priv2->mfc_control_RW, MFC_CNTL_RESTART_DMA_COMMAND);
1731 eieio();
1732 }
1733} 1759}
1734 1760
1735static inline void enable_user_access(struct spu_state *csa, struct spu *spu) 1761static inline void enable_user_access(struct spu_state *csa, struct spu *spu)
@@ -1788,7 +1814,7 @@ static int quiece_spu(struct spu_state *prev, struct spu *spu)
1788 save_spu_runcntl(prev, spu); /* Step 9. */ 1814 save_spu_runcntl(prev, spu); /* Step 9. */
1789 save_mfc_sr1(prev, spu); /* Step 10. */ 1815 save_mfc_sr1(prev, spu); /* Step 10. */
1790 save_spu_status(prev, spu); /* Step 11. */ 1816 save_spu_status(prev, spu); /* Step 11. */
1791 save_mfc_decr(prev, spu); /* Step 12. */ 1817 save_mfc_stopped_status(prev, spu); /* Step 12. */
1792 halt_mfc_decr(prev, spu); /* Step 13. */ 1818 halt_mfc_decr(prev, spu); /* Step 13. */
1793 save_timebase(prev, spu); /* Step 14. */ 1819 save_timebase(prev, spu); /* Step 14. */
1794 remove_other_spu_access(prev, spu); /* Step 15. */ 1820 remove_other_spu_access(prev, spu); /* Step 15. */
@@ -2000,6 +2026,7 @@ static void restore_csa(struct spu_state *next, struct spu *spu)
2000 check_ppuint_mb_stat(next, spu); /* Step 67. */ 2026 check_ppuint_mb_stat(next, spu); /* Step 67. */
2001 spu_invalidate_slbs(spu); /* Modified Step 68. */ 2027 spu_invalidate_slbs(spu); /* Modified Step 68. */
2002 restore_mfc_sr1(next, spu); /* Step 69. */ 2028 restore_mfc_sr1(next, spu); /* Step 69. */
2029 set_int_route(next, spu); /* NEW */
2003 restore_other_spu_access(next, spu); /* Step 70. */ 2030 restore_other_spu_access(next, spu); /* Step 70. */
2004 restore_spu_runcntl(next, spu); /* Step 71. */ 2031 restore_spu_runcntl(next, spu); /* Step 71. */
2005 restore_mfc_cntl(next, spu); /* Step 72. */ 2032 restore_mfc_cntl(next, spu); /* Step 72. */
diff --git a/arch/powerpc/platforms/chrp/pegasos_eth.c b/arch/powerpc/platforms/chrp/pegasos_eth.c
index 5bcc58d9a4dd..130ff72d99dd 100644
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -58,7 +58,9 @@ static struct resource mv643xx_eth0_resources[] = {
58 58
59 59
60static struct mv643xx_eth_platform_data eth0_pd = { 60static struct mv643xx_eth_platform_data eth0_pd = {
61 .shared = &mv643xx_eth_shared_device,
61 .port_number = 0, 62 .port_number = 0,
63
62 .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0, 64 .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0,
63 .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE, 65 .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
64 .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16, 66 .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
@@ -88,7 +90,9 @@ static struct resource mv643xx_eth1_resources[] = {
88}; 90};
89 91
90static struct mv643xx_eth_platform_data eth1_pd = { 92static struct mv643xx_eth_platform_data eth1_pd = {
93 .shared = &mv643xx_eth_shared_device,
91 .port_number = 1, 94 .port_number = 1,
95
92 .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1, 96 .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1,
93 .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE, 97 .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
94 .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16, 98 .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
diff --git a/arch/powerpc/platforms/pseries/scanlog.c b/arch/powerpc/platforms/pseries/scanlog.c
index bec3803f0618..417eca79df69 100644
--- a/arch/powerpc/platforms/pseries/scanlog.c
+++ b/arch/powerpc/platforms/pseries/scanlog.c
@@ -55,11 +55,6 @@ static ssize_t scanlog_read(struct file *file, char __user *buf,
55 dp = PDE(inode); 55 dp = PDE(inode);
56 data = (unsigned int *)dp->data; 56 data = (unsigned int *)dp->data;
57 57
58 if (!data) {
59 printk(KERN_ERR "scanlog: read failed no data\n");
60 return -EIO;
61 }
62
63 if (count > RTAS_DATA_BUF_SIZE) 58 if (count > RTAS_DATA_BUF_SIZE)
64 count = RTAS_DATA_BUF_SIZE; 59 count = RTAS_DATA_BUF_SIZE;
65 60
@@ -146,11 +141,6 @@ static int scanlog_open(struct inode * inode, struct file * file)
146 struct proc_dir_entry *dp = PDE(inode); 141 struct proc_dir_entry *dp = PDE(inode);
147 unsigned int *data = (unsigned int *)dp->data; 142 unsigned int *data = (unsigned int *)dp->data;
148 143
149 if (!data) {
150 printk(KERN_ERR "scanlog: open failed no data\n");
151 return -EIO;
152 }
153
154 if (data[0] != 0) { 144 if (data[0] != 0) {
155 /* This imperfect test stops a second copy of the 145 /* This imperfect test stops a second copy of the
156 * data (or a reset while data is being copied) 146 * data (or a reset while data is being copied)
@@ -168,10 +158,6 @@ static int scanlog_release(struct inode * inode, struct file * file)
168 struct proc_dir_entry *dp = PDE(inode); 158 struct proc_dir_entry *dp = PDE(inode);
169 unsigned int *data = (unsigned int *)dp->data; 159 unsigned int *data = (unsigned int *)dp->data;
170 160
171 if (!data) {
172 printk(KERN_ERR "scanlog: release failed no data\n");
173 return -EIO;
174 }
175 data[0] = 0; 161 data[0] = 0;
176 162
177 return 0; 163 return 0;
@@ -200,12 +186,11 @@ static int __init scanlog_init(void)
200 if (!data) 186 if (!data)
201 goto err; 187 goto err;
202 188
203 ent = proc_create("ppc64/rtas/scan-log-dump", S_IRUSR, NULL, 189 ent = proc_create_data("ppc64/rtas/scan-log-dump", S_IRUSR, NULL,
204 &scanlog_fops); 190 &scanlog_fops, data);
205 if (!ent) 191 if (!ent)
206 goto err; 192 goto err;
207 193
208 ent->data = data;
209 proc_ppc64_scan_log_dump = ent; 194 proc_ppc64_scan_log_dump = ent;
210 195
211 return 0; 196 return 0;
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 41af1223e2a0..a132e0de8ca5 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -239,6 +239,8 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id,
239 239
240 memset(&pdata, 0, sizeof(pdata)); 240 memset(&pdata, 0, sizeof(pdata));
241 241
242 pdata.shared = shared_pdev;
243
242 prop = of_get_property(np, "reg", NULL); 244 prop = of_get_property(np, "reg", NULL);
243 if (!prop) 245 if (!prop)
244 return -ENODEV; 246 return -ENODEV;
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index 1814adbd2236..b4a54c52e880 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -1387,28 +1387,59 @@ static void __init ppc4xx_configure_pciex_PIMs(struct ppc4xx_pciex_port *port,
1387 resource_size_t size = res->end - res->start + 1; 1387 resource_size_t size = res->end - res->start + 1;
1388 u64 sa; 1388 u64 sa;
1389 1389
1390 /* Calculate window size */ 1390 if (port->endpoint) {
1391 sa = (0xffffffffffffffffull << ilog2(size));; 1391 resource_size_t ep_addr = 0;
1392 if (res->flags & IORESOURCE_PREFETCH) 1392 resource_size_t ep_size = 32 << 20;
1393 sa |= 0x8; 1393
1394 /* Currently we map a fixed 64MByte window to PLB address
1395 * 0 (SDRAM). This should probably be configurable via a dts
1396 * property.
1397 */
1398
1399 /* Calculate window size */
1400 sa = (0xffffffffffffffffull << ilog2(ep_size));;
1401
1402 /* Setup BAR0 */
1403 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa));
1404 out_le32(mbase + PECFG_BAR0LMPA, RES_TO_U32_LOW(sa) |
1405 PCI_BASE_ADDRESS_MEM_TYPE_64);
1394 1406
1395 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa)); 1407 /* Disable BAR1 & BAR2 */
1396 out_le32(mbase + PECFG_BAR0LMPA, RES_TO_U32_LOW(sa)); 1408 out_le32(mbase + PECFG_BAR1MPA, 0);
1409 out_le32(mbase + PECFG_BAR2HMPA, 0);
1410 out_le32(mbase + PECFG_BAR2LMPA, 0);
1397 1411
1398 /* The setup of the split looks weird to me ... let's see if it works */ 1412 out_le32(mbase + PECFG_PIM01SAH, RES_TO_U32_HIGH(sa));
1399 out_le32(mbase + PECFG_PIM0LAL, 0x00000000); 1413 out_le32(mbase + PECFG_PIM01SAL, RES_TO_U32_LOW(sa));
1400 out_le32(mbase + PECFG_PIM0LAH, 0x00000000); 1414
1401 out_le32(mbase + PECFG_PIM1LAL, 0x00000000); 1415 out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(ep_addr));
1402 out_le32(mbase + PECFG_PIM1LAH, 0x00000000); 1416 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(ep_addr));
1403 out_le32(mbase + PECFG_PIM01SAH, 0xffff0000); 1417 } else {
1404 out_le32(mbase + PECFG_PIM01SAL, 0x00000000); 1418 /* Calculate window size */
1419 sa = (0xffffffffffffffffull << ilog2(size));;
1420 if (res->flags & IORESOURCE_PREFETCH)
1421 sa |= 0x8;
1422
1423 out_le32(mbase + PECFG_BAR0HMPA, RES_TO_U32_HIGH(sa));
1424 out_le32(mbase + PECFG_BAR0LMPA, RES_TO_U32_LOW(sa));
1425
1426 /* The setup of the split looks weird to me ... let's see
1427 * if it works
1428 */
1429 out_le32(mbase + PECFG_PIM0LAL, 0x00000000);
1430 out_le32(mbase + PECFG_PIM0LAH, 0x00000000);
1431 out_le32(mbase + PECFG_PIM1LAL, 0x00000000);
1432 out_le32(mbase + PECFG_PIM1LAH, 0x00000000);
1433 out_le32(mbase + PECFG_PIM01SAH, 0xffff0000);
1434 out_le32(mbase + PECFG_PIM01SAL, 0x00000000);
1435
1436 out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
1437 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
1438 }
1405 1439
1406 /* Enable inbound mapping */ 1440 /* Enable inbound mapping */
1407 out_le32(mbase + PECFG_PIMEN, 0x1); 1441 out_le32(mbase + PECFG_PIMEN, 0x1);
1408 1442
1409 out_le32(mbase + PCI_BASE_ADDRESS_0, RES_TO_U32_LOW(res->start));
1410 out_le32(mbase + PCI_BASE_ADDRESS_1, RES_TO_U32_HIGH(res->start));
1411
1412 /* Enable I/O, Mem, and Busmaster cycles */ 1443 /* Enable I/O, Mem, and Busmaster cycles */
1413 out_le16(mbase + PCI_COMMAND, 1444 out_le16(mbase + PCI_COMMAND,
1414 in_le16(mbase + PCI_COMMAND) | 1445 in_le16(mbase + PCI_COMMAND) |
@@ -1422,13 +1453,8 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1422 const int *bus_range; 1453 const int *bus_range;
1423 int primary = 0, busses; 1454 int primary = 0, busses;
1424 void __iomem *mbase = NULL, *cfg_data = NULL; 1455 void __iomem *mbase = NULL, *cfg_data = NULL;
1425 1456 const u32 *pval;
1426 /* XXX FIXME: Handle endpoint mode properly */ 1457 u32 val;
1427 if (port->endpoint) {
1428 printk(KERN_WARNING "PCIE%d: Port in endpoint mode !\n",
1429 port->index);
1430 return;
1431 }
1432 1458
1433 /* Check if primary bridge */ 1459 /* Check if primary bridge */
1434 if (of_get_property(port->node, "primary", NULL)) 1460 if (of_get_property(port->node, "primary", NULL))
@@ -1462,21 +1488,30 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1462 hose->last_busno = hose->first_busno + busses; 1488 hose->last_busno = hose->first_busno + busses;
1463 } 1489 }
1464 1490
1465 /* We map the external config space in cfg_data and the host config 1491 if (!port->endpoint) {
1466 * space in cfg_addr. External space is 1M per bus, internal space 1492 /* Only map the external config space in cfg_data for
1467 * is 4K 1493 * PCIe root-complexes. External space is 1M per bus
1494 */
1495 cfg_data = ioremap(port->cfg_space.start +
1496 (hose->first_busno + 1) * 0x100000,
1497 busses * 0x100000);
1498 if (cfg_data == NULL) {
1499 printk(KERN_ERR "%s: Can't map external config space !",
1500 port->node->full_name);
1501 goto fail;
1502 }
1503 hose->cfg_data = cfg_data;
1504 }
1505
1506 /* Always map the host config space in cfg_addr.
1507 * Internal space is 4K
1468 */ 1508 */
1469 cfg_data = ioremap(port->cfg_space.start +
1470 (hose->first_busno + 1) * 0x100000,
1471 busses * 0x100000);
1472 mbase = ioremap(port->cfg_space.start + 0x10000000, 0x1000); 1509 mbase = ioremap(port->cfg_space.start + 0x10000000, 0x1000);
1473 if (cfg_data == NULL || mbase == NULL) { 1510 if (mbase == NULL) {
1474 printk(KERN_ERR "%s: Can't map config space !", 1511 printk(KERN_ERR "%s: Can't map internal config space !",
1475 port->node->full_name); 1512 port->node->full_name);
1476 goto fail; 1513 goto fail;
1477 } 1514 }
1478
1479 hose->cfg_data = cfg_data;
1480 hose->cfg_addr = mbase; 1515 hose->cfg_addr = mbase;
1481 1516
1482 pr_debug("PCIE %s, bus %d..%d\n", port->node->full_name, 1517 pr_debug("PCIE %s, bus %d..%d\n", port->node->full_name,
@@ -1489,12 +1524,14 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1489 port->hose = hose; 1524 port->hose = hose;
1490 mbase = (void __iomem *)hose->cfg_addr; 1525 mbase = (void __iomem *)hose->cfg_addr;
1491 1526
1492 /* 1527 if (!port->endpoint) {
1493 * Set bus numbers on our root port 1528 /*
1494 */ 1529 * Set bus numbers on our root port
1495 out_8(mbase + PCI_PRIMARY_BUS, hose->first_busno); 1530 */
1496 out_8(mbase + PCI_SECONDARY_BUS, hose->first_busno + 1); 1531 out_8(mbase + PCI_PRIMARY_BUS, hose->first_busno);
1497 out_8(mbase + PCI_SUBORDINATE_BUS, hose->last_busno); 1532 out_8(mbase + PCI_SECONDARY_BUS, hose->first_busno + 1);
1533 out_8(mbase + PCI_SUBORDINATE_BUS, hose->last_busno);
1534 }
1498 1535
1499 /* 1536 /*
1500 * OMRs are already reset, also disable PIMs 1537 * OMRs are already reset, also disable PIMs
@@ -1515,17 +1552,49 @@ static void __init ppc4xx_pciex_port_setup_hose(struct ppc4xx_pciex_port *port)
1515 ppc4xx_configure_pciex_PIMs(port, hose, mbase, &dma_window); 1552 ppc4xx_configure_pciex_PIMs(port, hose, mbase, &dma_window);
1516 1553
1517 /* The root complex doesn't show up if we don't set some vendor 1554 /* The root complex doesn't show up if we don't set some vendor
1518 * and device IDs into it. Those are the same bogus one that the 1555 * and device IDs into it. The defaults below are the same bogus
1519 * initial code in arch/ppc add. We might want to change that. 1556 * one that the initial code in arch/ppc had. This can be
1557 * overwritten by setting the "vendor-id/device-id" properties
1558 * in the pciex node.
1520 */ 1559 */
1521 out_le16(mbase + 0x200, 0xaaa0 + port->index);
1522 out_le16(mbase + 0x202, 0xbed0 + port->index);
1523 1560
1524 /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */ 1561 /* Get the (optional) vendor-/device-id from the device-tree */
1525 out_le32(mbase + 0x208, 0x06040001); 1562 pval = of_get_property(port->node, "vendor-id", NULL);
1563 if (pval) {
1564 val = *pval;
1565 } else {
1566 if (!port->endpoint)
1567 val = 0xaaa0 + port->index;
1568 else
1569 val = 0xeee0 + port->index;
1570 }
1571 out_le16(mbase + 0x200, val);
1572
1573 pval = of_get_property(port->node, "device-id", NULL);
1574 if (pval) {
1575 val = *pval;
1576 } else {
1577 if (!port->endpoint)
1578 val = 0xbed0 + port->index;
1579 else
1580 val = 0xfed0 + port->index;
1581 }
1582 out_le16(mbase + 0x202, val);
1583
1584 if (!port->endpoint) {
1585 /* Set Class Code to PCI-PCI bridge and Revision Id to 1 */
1586 out_le32(mbase + 0x208, 0x06040001);
1587
1588 printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
1589 port->index);
1590 } else {
1591 /* Set Class Code to Processor/PPC */
1592 out_le32(mbase + 0x208, 0x0b200001);
1593
1594 printk(KERN_INFO "PCIE%d: successfully set as endpoint\n",
1595 port->index);
1596 }
1526 1597
1527 printk(KERN_INFO "PCIE%d: successfully set as root-complex\n",
1528 port->index);
1529 return; 1598 return;
1530 fail: 1599 fail:
1531 if (hose) 1600 if (hose)
@@ -1542,6 +1611,7 @@ static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
1542 const u32 *pval; 1611 const u32 *pval;
1543 int portno; 1612 int portno;
1544 unsigned int dcrs; 1613 unsigned int dcrs;
1614 const char *val;
1545 1615
1546 /* First, proceed to core initialization as we assume there's 1616 /* First, proceed to core initialization as we assume there's
1547 * only one PCIe core in the system 1617 * only one PCIe core in the system
@@ -1573,8 +1643,20 @@ static void __init ppc4xx_probe_pciex_bridge(struct device_node *np)
1573 } 1643 }
1574 port->sdr_base = *pval; 1644 port->sdr_base = *pval;
1575 1645
1576 /* XXX Currently, we only support root complex mode */ 1646 /* Check if device_type property is set to "pci" or "pci-endpoint".
1577 port->endpoint = 0; 1647 * Resulting from this setup this PCIe port will be configured
1648 * as root-complex or as endpoint.
1649 */
1650 val = of_get_property(port->node, "device_type", NULL);
1651 if (!strcmp(val, "pci-endpoint")) {
1652 port->endpoint = 1;
1653 } else if (!strcmp(val, "pci")) {
1654 port->endpoint = 0;
1655 } else {
1656 printk(KERN_ERR "PCIE: missing or incorrect device_type for %s\n",
1657 np->full_name);
1658 return;
1659 }
1578 1660
1579 /* Fetch config space registers address */ 1661 /* Fetch config space registers address */
1580 if (of_address_to_resource(np, 0, &port->cfg_space)) { 1662 if (of_address_to_resource(np, 0, &port->cfg_space)) {
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 52c74780f403..1702de9395ee 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2842,9 +2842,11 @@ static void dump_spu_fields(struct spu *spu)
2842 DUMP_FIELD(spu, "0x%lx", ls_size); 2842 DUMP_FIELD(spu, "0x%lx", ls_size);
2843 DUMP_FIELD(spu, "0x%x", node); 2843 DUMP_FIELD(spu, "0x%x", node);
2844 DUMP_FIELD(spu, "0x%lx", flags); 2844 DUMP_FIELD(spu, "0x%lx", flags);
2845 DUMP_FIELD(spu, "0x%lx", dar);
2846 DUMP_FIELD(spu, "0x%lx", dsisr);
2847 DUMP_FIELD(spu, "%d", class_0_pending); 2845 DUMP_FIELD(spu, "%d", class_0_pending);
2846 DUMP_FIELD(spu, "0x%lx", class_0_dar);
2847 DUMP_FIELD(spu, "0x%lx", class_0_dsisr);
2848 DUMP_FIELD(spu, "0x%lx", class_1_dar);
2849 DUMP_FIELD(spu, "0x%lx", class_1_dsisr);
2848 DUMP_FIELD(spu, "0x%lx", irqs[0]); 2850 DUMP_FIELD(spu, "0x%lx", irqs[0]);
2849 DUMP_FIELD(spu, "0x%lx", irqs[1]); 2851 DUMP_FIELD(spu, "0x%lx", irqs[1]);
2850 DUMP_FIELD(spu, "0x%lx", irqs[2]); 2852 DUMP_FIELD(spu, "0x%lx", irqs[2]);
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 8df7f0e4c3a6..2352d139b262 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -43,7 +43,7 @@ KBUILD_AFLAGS += $(cpu-as-y)
43KBUILD_CFLAGS += $(cpu-as-y) 43KBUILD_CFLAGS += $(cpu-as-y)
44 44
45# Default to the common case. 45# Default to the common case.
46KBUILD_DEFCONFIG := common_defconfig 46KBUILD_DEFCONFIG := ebony_defconfig
47 47
48head-y := arch/ppc/kernel/head.o 48head-y := arch/ppc/kernel/head.o
49head-$(CONFIG_8xx) := arch/ppc/kernel/head_8xx.o 49head-$(CONFIG_8xx) := arch/ppc/kernel/head_8xx.o
diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c
index 16ac11ca7ba0..602c268fc8a2 100644
--- a/arch/ppc/kernel/ppc_ksyms.c
+++ b/arch/ppc/kernel/ppc_ksyms.c
@@ -24,6 +24,7 @@
24#include <asm/checksum.h> 24#include <asm/checksum.h>
25#include <asm/pgtable.h> 25#include <asm/pgtable.h>
26#include <asm/tlbflush.h> 26#include <asm/tlbflush.h>
27#include <asm/cacheflush.h>
27#include <linux/adb.h> 28#include <linux/adb.h>
28#include <linux/cuda.h> 29#include <linux/cuda.h>
29#include <linux/pmu.h> 30#include <linux/pmu.h>
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index bfddfdee0b65..51e8094f52d6 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -36,6 +36,7 @@
36#include <asm/nvram.h> 36#include <asm/nvram.h>
37#include <asm/xmon.h> 37#include <asm/xmon.h>
38#include <asm/ocp.h> 38#include <asm/ocp.h>
39#include <asm/irq.h>
39 40
40#define USES_PPC_SYS (defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \ 41#define USES_PPC_SYS (defined(CONFIG_MPC10X_BRIDGE) || defined(CONFIG_8260) || \
41 defined(CONFIG_PPC_MPC52xx)) 42 defined(CONFIG_PPC_MPC52xx))
diff --git a/arch/ppc/platforms/residual.c b/arch/ppc/platforms/residual.c
index 18495e754e30..d687b0f8763b 100644
--- a/arch/ppc/platforms/residual.c
+++ b/arch/ppc/platforms/residual.c
@@ -38,6 +38,7 @@
38#include <linux/init.h> 38#include <linux/init.h>
39#include <linux/ioport.h> 39#include <linux/ioport.h>
40#include <linux/pci.h> 40#include <linux/pci.h>
41#include <linux/proc_fs.h>
41 42
42#include <asm/sections.h> 43#include <asm/sections.h>
43#include <asm/mmu.h> 44#include <asm/mmu.h>
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index 90fe904d3614..418f3053de52 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -341,6 +341,7 @@ static struct resource mv64x60_eth0_resources[] = {
341}; 341};
342 342
343static struct mv643xx_eth_platform_data eth0_pd = { 343static struct mv643xx_eth_platform_data eth0_pd = {
344 .shared = &mv64x60_eth_shared_device;
344 .port_number = 0, 345 .port_number = 0,
345}; 346};
346 347
@@ -366,6 +367,7 @@ static struct resource mv64x60_eth1_resources[] = {
366}; 367};
367 368
368static struct mv643xx_eth_platform_data eth1_pd = { 369static struct mv643xx_eth_platform_data eth1_pd = {
370 .shared = &mv64x60_eth_shared_device;
369 .port_number = 1, 371 .port_number = 1,
370}; 372};
371 373
@@ -391,6 +393,7 @@ static struct resource mv64x60_eth2_resources[] = {
391}; 393};
392 394
393static struct mv643xx_eth_platform_data eth2_pd = { 395static struct mv643xx_eth_platform_data eth2_pd = {
396 .shared = &mv64x60_eth_shared_device;
394 .port_number = 2, 397 .port_number = 2,
395}; 398};
396 399
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 29a7940f284f..1d035082e78e 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -430,6 +430,13 @@ config CMM_IUCV
430 Select this option to enable the special message interface to 430 Select this option to enable the special message interface to
431 the cooperative memory management. 431 the cooperative memory management.
432 432
433config PAGE_STATES
434 bool "Unused page notification"
435 help
436 This enables the notification of unused pages to the
437 hypervisor. The ESSA instruction is used to do the states
438 changes between a page that has content and the unused state.
439
433config VIRT_TIMER 440config VIRT_TIMER
434 bool "Virtual CPU timer support" 441 bool "Virtual CPU timer support"
435 help 442 help
diff --git a/arch/s390/kernel/compat_wrapper.S b/arch/s390/kernel/compat_wrapper.S
index 743d54f0b8db..d003a6e16afb 100644
--- a/arch/s390/kernel/compat_wrapper.S
+++ b/arch/s390/kernel/compat_wrapper.S
@@ -121,7 +121,7 @@ sys32_ptrace_wrapper:
121 lgfr %r3,%r3 # long 121 lgfr %r3,%r3 # long
122 llgtr %r4,%r4 # long 122 llgtr %r4,%r4 # long
123 llgfr %r5,%r5 # long 123 llgfr %r5,%r5 # long
124 jg sys_ptrace # branch to system call 124 jg compat_sys_ptrace # branch to system call
125 125
126 .globl sys32_alarm_wrapper 126 .globl sys32_alarm_wrapper
127sys32_alarm_wrapper: 127sys32_alarm_wrapper:
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index bdbb3bcd78a5..708cf9cf9a35 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -279,8 +279,6 @@ sysc_do_restart:
279 st %r2,SP_R2(%r15) # store return value (change R2 on stack) 279 st %r2,SP_R2(%r15) # store return value (change R2 on stack)
280 280
281sysc_return: 281sysc_return:
282 tm SP_PSW+1(%r15),0x01 # returning to user ?
283 bno BASED(sysc_restore)
284 tm __TI_flags+3(%r9),_TIF_WORK_SVC 282 tm __TI_flags+3(%r9),_TIF_WORK_SVC
285 bnz BASED(sysc_work) # there is work to do (signals etc.) 283 bnz BASED(sysc_work) # there is work to do (signals etc.)
286sysc_restore: 284sysc_restore:
@@ -312,6 +310,8 @@ sysc_work_loop:
312# One of the work bits is on. Find out which one. 310# One of the work bits is on. Find out which one.
313# 311#
314sysc_work: 312sysc_work:
313 tm SP_PSW+1(%r15),0x01 # returning to user ?
314 bno BASED(sysc_restore)
315 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING 315 tm __TI_flags+3(%r9),_TIF_MCCK_PENDING
316 bo BASED(sysc_mcck_pending) 316 bo BASED(sysc_mcck_pending)
317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED 317 tm __TI_flags+3(%r9),_TIF_NEED_RESCHED
@@ -602,12 +602,6 @@ io_no_vtime:
602 la %r2,SP_PTREGS(%r15) # address of register-save area 602 la %r2,SP_PTREGS(%r15) # address of register-save area
603 basr %r14,%r1 # branch to standard irq handler 603 basr %r14,%r1 # branch to standard irq handler
604io_return: 604io_return:
605 tm SP_PSW+1(%r15),0x01 # returning to user ?
606#ifdef CONFIG_PREEMPT
607 bno BASED(io_preempt) # no -> check for preemptive scheduling
608#else
609 bno BASED(io_restore) # no-> skip resched & signal
610#endif
611 tm __TI_flags+3(%r9),_TIF_WORK_INT 605 tm __TI_flags+3(%r9),_TIF_WORK_INT
612 bnz BASED(io_work) # there is work to do (signals etc.) 606 bnz BASED(io_work) # there is work to do (signals etc.)
613io_restore: 607io_restore:
@@ -629,10 +623,18 @@ io_restore_trace_psw:
629 .long 0, io_restore_trace + 0x80000000 623 .long 0, io_restore_trace + 0x80000000
630#endif 624#endif
631 625
632#ifdef CONFIG_PREEMPT 626#
633io_preempt: 627# switch to kernel stack, then check the TIF bits
628#
629io_work:
630 tm SP_PSW+1(%r15),0x01 # returning to user ?
631#ifndef CONFIG_PREEMPT
632 bno BASED(io_restore) # no-> skip resched & signal
633#else
634 bnz BASED(io_work_user) # no -> check for preemptive scheduling
635 # check for preemptive scheduling
634 icm %r0,15,__TI_precount(%r9) 636 icm %r0,15,__TI_precount(%r9)
635 bnz BASED(io_restore) 637 bnz BASED(io_restore) # preemption disabled
636 l %r1,SP_R15(%r15) 638 l %r1,SP_R15(%r15)
637 s %r1,BASED(.Lc_spsize) 639 s %r1,BASED(.Lc_spsize)
638 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 640 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
@@ -646,10 +648,7 @@ io_resume_loop:
646 br %r1 # call schedule 648 br %r1 # call schedule
647#endif 649#endif
648 650
649# 651io_work_user:
650# switch to kernel stack, then check the TIF bits
651#
652io_work:
653 l %r1,__LC_KERNEL_STACK 652 l %r1,__LC_KERNEL_STACK
654 s %r1,BASED(.Lc_spsize) 653 s %r1,BASED(.Lc_spsize)
655 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 654 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 5a4a7bcd2bba..fee10177dbfc 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -271,8 +271,6 @@ sysc_noemu:
271 stg %r2,SP_R2(%r15) # store return value (change R2 on stack) 271 stg %r2,SP_R2(%r15) # store return value (change R2 on stack)
272 272
273sysc_return: 273sysc_return:
274 tm SP_PSW+1(%r15),0x01 # returning to user ?
275 jno sysc_restore
276 tm __TI_flags+7(%r9),_TIF_WORK_SVC 274 tm __TI_flags+7(%r9),_TIF_WORK_SVC
277 jnz sysc_work # there is work to do (signals etc.) 275 jnz sysc_work # there is work to do (signals etc.)
278sysc_restore: 276sysc_restore:
@@ -304,6 +302,8 @@ sysc_work_loop:
304# One of the work bits is on. Find out which one. 302# One of the work bits is on. Find out which one.
305# 303#
306sysc_work: 304sysc_work:
305 tm SP_PSW+1(%r15),0x01 # returning to user ?
306 jno sysc_restore
307 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING 307 tm __TI_flags+7(%r9),_TIF_MCCK_PENDING
308 jo sysc_mcck_pending 308 jo sysc_mcck_pending
309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED 309 tm __TI_flags+7(%r9),_TIF_NEED_RESCHED
@@ -585,12 +585,6 @@ io_no_vtime:
585 la %r2,SP_PTREGS(%r15) # address of register-save area 585 la %r2,SP_PTREGS(%r15) # address of register-save area
586 brasl %r14,do_IRQ # call standard irq handler 586 brasl %r14,do_IRQ # call standard irq handler
587io_return: 587io_return:
588 tm SP_PSW+1(%r15),0x01 # returning to user ?
589#ifdef CONFIG_PREEMPT
590 jno io_preempt # no -> check for preemptive scheduling
591#else
592 jno io_restore # no-> skip resched & signal
593#endif
594 tm __TI_flags+7(%r9),_TIF_WORK_INT 588 tm __TI_flags+7(%r9),_TIF_WORK_INT
595 jnz io_work # there is work to do (signals etc.) 589 jnz io_work # there is work to do (signals etc.)
596io_restore: 590io_restore:
@@ -612,10 +606,41 @@ io_restore_trace_psw:
612 .quad 0, io_restore_trace 606 .quad 0, io_restore_trace
613#endif 607#endif
614 608
615#ifdef CONFIG_PREEMPT 609#
616io_preempt: 610# There is work todo, we need to check if we return to userspace, then
611# check, if we are in SIE, if yes leave it
612#
613io_work:
614 tm SP_PSW+1(%r15),0x01 # returning to user ?
615#ifndef CONFIG_PREEMPT
616#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
617 jnz io_work_user # yes -> no need to check for SIE
618 la %r1, BASED(sie_opcode) # we return to kernel here
619 lg %r2, SP_PSW+8(%r15)
620 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
621 jne io_restore # no-> return to kernel
622 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
623 aghi %r1, 4
624 stg %r1, SP_PSW+8(%r15)
625 j io_restore # return to kernel
626#else
627 jno io_restore # no-> skip resched & signal
628#endif
629#else
630 jnz io_work_user # yes -> do resched & signal
631#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
632 la %r1, BASED(sie_opcode)
633 lg %r2, SP_PSW+8(%r15)
634 clc 0(2,%r1), 0(%r2) # is current instruction = SIE?
635 jne 0f # no -> leave PSW alone
636 lg %r1, SP_PSW+8(%r15) # yes-> add 4 bytes to leave SIE
637 aghi %r1, 4
638 stg %r1, SP_PSW+8(%r15)
6390:
640#endif
641 # check for preemptive scheduling
617 icm %r0,15,__TI_precount(%r9) 642 icm %r0,15,__TI_precount(%r9)
618 jnz io_restore 643 jnz io_restore # preemption is disabled
619 # switch to kernel stack 644 # switch to kernel stack
620 lg %r1,SP_R15(%r15) 645 lg %r1,SP_R15(%r15)
621 aghi %r1,-SP_SIZE 646 aghi %r1,-SP_SIZE
@@ -629,10 +654,7 @@ io_resume_loop:
629 jg preempt_schedule_irq 654 jg preempt_schedule_irq
630#endif 655#endif
631 656
632# 657io_work_user:
633# switch to kernel stack, then check TIF bits
634#
635io_work:
636 lg %r1,__LC_KERNEL_STACK 658 lg %r1,__LC_KERNEL_STACK
637 aghi %r1,-SP_SIZE 659 aghi %r1,-SP_SIZE
638 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15) 660 mvc SP_PTREGS(__PT_SIZE,%r1),SP_PTREGS(%r15)
@@ -653,6 +675,11 @@ io_work_loop:
653 j io_restore 675 j io_restore
654io_work_done: 676io_work_done:
655 677
678#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
679sie_opcode:
680 .long 0xb2140000
681#endif
682
656# 683#
657# _TIF_MCCK_PENDING is set, call handler 684# _TIF_MCCK_PENDING is set, call handler
658# 685#
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c
index 7f4270163744..35827b9bd4d1 100644
--- a/arch/s390/kernel/ptrace.c
+++ b/arch/s390/kernel/ptrace.c
@@ -292,8 +292,7 @@ poke_user(struct task_struct *child, addr_t addr, addr_t data)
292 return 0; 292 return 0;
293} 293}
294 294
295static int 295long arch_ptrace(struct task_struct *child, long request, long addr, long data)
296do_ptrace_normal(struct task_struct *child, long request, long addr, long data)
297{ 296{
298 ptrace_area parea; 297 ptrace_area parea;
299 int copied, ret; 298 int copied, ret;
@@ -529,35 +528,19 @@ poke_user_emu31(struct task_struct *child, addr_t addr, addr_t data)
529 return 0; 528 return 0;
530} 529}
531 530
532static int 531long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
533do_ptrace_emu31(struct task_struct *child, long request, long addr, long data) 532 compat_ulong_t caddr, compat_ulong_t cdata)
534{ 533{
535 unsigned int tmp; /* 4 bytes !! */ 534 unsigned long addr = caddr;
535 unsigned long data = cdata;
536 ptrace_area_emu31 parea; 536 ptrace_area_emu31 parea;
537 int copied, ret; 537 int copied, ret;
538 538
539 switch (request) { 539 switch (request) {
540 case PTRACE_PEEKTEXT:
541 case PTRACE_PEEKDATA:
542 /* read word at location addr. */
543 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
544 if (copied != sizeof(tmp))
545 return -EIO;
546 return put_user(tmp, (unsigned int __force __user *) data);
547
548 case PTRACE_PEEKUSR: 540 case PTRACE_PEEKUSR:
549 /* read the word at location addr in the USER area. */ 541 /* read the word at location addr in the USER area. */
550 return peek_user_emu31(child, addr, data); 542 return peek_user_emu31(child, addr, data);
551 543
552 case PTRACE_POKETEXT:
553 case PTRACE_POKEDATA:
554 /* write the word at location addr. */
555 tmp = data;
556 copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 1);
557 if (copied != sizeof(tmp))
558 return -EIO;
559 return 0;
560
561 case PTRACE_POKEUSR: 544 case PTRACE_POKEUSR:
562 /* write the word at location addr in the USER area */ 545 /* write the word at location addr in the USER area */
563 return poke_user_emu31(child, addr, data); 546 return poke_user_emu31(child, addr, data);
@@ -587,82 +570,11 @@ do_ptrace_emu31(struct task_struct *child, long request, long addr, long data)
587 copied += sizeof(unsigned int); 570 copied += sizeof(unsigned int);
588 } 571 }
589 return 0; 572 return 0;
590 case PTRACE_GETEVENTMSG:
591 return put_user((__u32) child->ptrace_message,
592 (unsigned int __force __user *) data);
593 case PTRACE_GETSIGINFO:
594 if (child->last_siginfo == NULL)
595 return -EINVAL;
596 return copy_siginfo_to_user32((compat_siginfo_t
597 __force __user *) data,
598 child->last_siginfo);
599 case PTRACE_SETSIGINFO:
600 if (child->last_siginfo == NULL)
601 return -EINVAL;
602 return copy_siginfo_from_user32(child->last_siginfo,
603 (compat_siginfo_t
604 __force __user *) data);
605 } 573 }
606 return ptrace_request(child, request, addr, data); 574 return compat_ptrace_request(child, request, addr, data);
607} 575}
608#endif 576#endif
609 577
610long arch_ptrace(struct task_struct *child, long request, long addr, long data)
611{
612 switch (request) {
613 case PTRACE_SYSCALL:
614 /* continue and stop at next (return from) syscall */
615 case PTRACE_CONT:
616 /* restart after signal. */
617 if (!valid_signal(data))
618 return -EIO;
619 if (request == PTRACE_SYSCALL)
620 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
621 else
622 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
623 child->exit_code = data;
624 /* make sure the single step bit is not set. */
625 user_disable_single_step(child);
626 wake_up_process(child);
627 return 0;
628
629 case PTRACE_KILL:
630 /*
631 * make the child exit. Best I can do is send it a sigkill.
632 * perhaps it should be put in the status that it wants to
633 * exit.
634 */
635 if (child->exit_state == EXIT_ZOMBIE) /* already dead */
636 return 0;
637 child->exit_code = SIGKILL;
638 /* make sure the single step bit is not set. */
639 user_disable_single_step(child);
640 wake_up_process(child);
641 return 0;
642
643 case PTRACE_SINGLESTEP:
644 /* set the trap flag. */
645 if (!valid_signal(data))
646 return -EIO;
647 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
648 child->exit_code = data;
649 user_enable_single_step(child);
650 /* give it a chance to run. */
651 wake_up_process(child);
652 return 0;
653
654 /* Do requests that differ for 31/64 bit */
655 default:
656#ifdef CONFIG_COMPAT
657 if (test_thread_flag(TIF_31BIT))
658 return do_ptrace_emu31(child, request, addr, data);
659#endif
660 return do_ptrace_normal(child, request, addr, data);
661 }
662 /* Not reached. */
663 return -EIO;
664}
665
666asmlinkage void 578asmlinkage void
667syscall_trace(struct pt_regs *regs, int entryexit) 579syscall_trace(struct pt_regs *regs, int entryexit)
668{ 580{
diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig
index 1761b74d639b..e051cad1f1e0 100644
--- a/arch/s390/kvm/Kconfig
+++ b/arch/s390/kvm/Kconfig
@@ -22,7 +22,6 @@ config KVM
22 select PREEMPT_NOTIFIERS 22 select PREEMPT_NOTIFIERS
23 select ANON_INODES 23 select ANON_INODES
24 select S390_SWITCH_AMODE 24 select S390_SWITCH_AMODE
25 select PREEMPT
26 ---help--- 25 ---help---
27 Support hosting paravirtualized guest machines using the SIE 26 Support hosting paravirtualized guest machines using the SIE
28 virtualization capability on the mainframe. This should work 27 virtualization capability on the mainframe. This should work
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c
index 349581a26103..47a0b642174c 100644
--- a/arch/s390/kvm/intercept.c
+++ b/arch/s390/kvm/intercept.c
@@ -105,6 +105,9 @@ static intercept_handler_t instruction_handlers[256] = {
105static int handle_noop(struct kvm_vcpu *vcpu) 105static int handle_noop(struct kvm_vcpu *vcpu)
106{ 106{
107 switch (vcpu->arch.sie_block->icptcode) { 107 switch (vcpu->arch.sie_block->icptcode) {
108 case 0x0:
109 vcpu->stat.exit_null++;
110 break;
108 case 0x10: 111 case 0x10:
109 vcpu->stat.exit_external_request++; 112 vcpu->stat.exit_external_request++;
110 break; 113 break;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 98d1e73e01f1..0ac36a649eba 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -31,6 +31,7 @@
31 31
32struct kvm_stats_debugfs_item debugfs_entries[] = { 32struct kvm_stats_debugfs_item debugfs_entries[] = {
33 { "userspace_handled", VCPU_STAT(exit_userspace) }, 33 { "userspace_handled", VCPU_STAT(exit_userspace) },
34 { "exit_null", VCPU_STAT(exit_null) },
34 { "exit_validity", VCPU_STAT(exit_validity) }, 35 { "exit_validity", VCPU_STAT(exit_validity) },
35 { "exit_stop_request", VCPU_STAT(exit_stop_request) }, 36 { "exit_stop_request", VCPU_STAT(exit_stop_request) },
36 { "exit_external_request", VCPU_STAT(exit_external_request) }, 37 { "exit_external_request", VCPU_STAT(exit_external_request) },
@@ -221,10 +222,6 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
221 vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK; 222 vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK;
222 restore_fp_regs(&vcpu->arch.guest_fpregs); 223 restore_fp_regs(&vcpu->arch.guest_fpregs);
223 restore_access_regs(vcpu->arch.guest_acrs); 224 restore_access_regs(vcpu->arch.guest_acrs);
224
225 if (signal_pending(current))
226 atomic_set_mask(CPUSTAT_STOP_INT,
227 &vcpu->arch.sie_block->cpuflags);
228} 225}
229 226
230void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) 227void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
diff --git a/arch/s390/mm/Makefile b/arch/s390/mm/Makefile
index fb988a48a754..2a7458134544 100644
--- a/arch/s390/mm/Makefile
+++ b/arch/s390/mm/Makefile
@@ -5,3 +5,4 @@
5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o 5obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o
6obj-$(CONFIG_CMM) += cmm.o 6obj-$(CONFIG_CMM) += cmm.o
7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 7obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
8obj-$(CONFIG_PAGE_STATES) += page-states.o
diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c
index fa31de6ae97a..29f3a63806b9 100644
--- a/arch/s390/mm/init.c
+++ b/arch/s390/mm/init.c
@@ -126,6 +126,9 @@ void __init mem_init(void)
126 /* clear the zero-page */ 126 /* clear the zero-page */
127 memset(empty_zero_page, 0, PAGE_SIZE); 127 memset(empty_zero_page, 0, PAGE_SIZE);
128 128
129 /* Setup guest page hinting */
130 cmma_init();
131
129 /* this will put all low memory onto the freelists */ 132 /* this will put all low memory onto the freelists */
130 totalram_pages += free_all_bootmem(); 133 totalram_pages += free_all_bootmem();
131 134
diff --git a/arch/s390/mm/page-states.c b/arch/s390/mm/page-states.c
new file mode 100644
index 000000000000..fc0ad73ffd90
--- /dev/null
+++ b/arch/s390/mm/page-states.c
@@ -0,0 +1,79 @@
1/*
2 * arch/s390/mm/page-states.c
3 *
4 * Copyright IBM Corp. 2008
5 *
6 * Guest page hinting for unused pages.
7 *
8 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com>
9 */
10
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/types.h>
14#include <linux/mm.h>
15#include <linux/init.h>
16
17#define ESSA_SET_STABLE 1
18#define ESSA_SET_UNUSED 2
19
20static int cmma_flag;
21
22static int __init cmma(char *str)
23{
24 char *parm;
25 parm = strstrip(str);
26 if (strcmp(parm, "yes") == 0 || strcmp(parm, "on") == 0) {
27 cmma_flag = 1;
28 return 1;
29 }
30 cmma_flag = 0;
31 if (strcmp(parm, "no") == 0 || strcmp(parm, "off") == 0)
32 return 1;
33 return 0;
34}
35
36__setup("cmma=", cmma);
37
38void __init cmma_init(void)
39{
40 register unsigned long tmp asm("0") = 0;
41 register int rc asm("1") = -EOPNOTSUPP;
42
43 if (!cmma_flag)
44 return;
45 asm volatile(
46 " .insn rrf,0xb9ab0000,%1,%1,0,0\n"
47 "0: la %0,0\n"
48 "1:\n"
49 EX_TABLE(0b,1b)
50 : "+&d" (rc), "+&d" (tmp));
51 if (rc)
52 cmma_flag = 0;
53}
54
55void arch_free_page(struct page *page, int order)
56{
57 int i, rc;
58
59 if (!cmma_flag)
60 return;
61 for (i = 0; i < (1 << order); i++)
62 asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
63 : "=&d" (rc)
64 : "a" ((page_to_pfn(page) + i) << PAGE_SHIFT),
65 "i" (ESSA_SET_UNUSED));
66}
67
68void arch_alloc_page(struct page *page, int order)
69{
70 int i, rc;
71
72 if (!cmma_flag)
73 return;
74 for (i = 0; i < (1 << order); i++)
75 asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0"
76 : "=&d" (rc)
77 : "a" ((page_to_pfn(page) + i) << PAGE_SHIFT),
78 "i" (ESSA_SET_STABLE));
79}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 6a679c3e15e8..8a68160079a9 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -448,14 +448,6 @@ config SH_DREAMCAST
448 Select Dreamcast if configuring for a SEGA Dreamcast. 448 Select Dreamcast if configuring for a SEGA Dreamcast.
449 More information at <http://www.linux-sh.org> 449 More information at <http://www.linux-sh.org>
450 450
451config SH_MPC1211
452 bool "Interface MPC1211"
453 depends on CPU_SUBTYPE_SH7751 && BROKEN
454 help
455 CTP/PCI-SH02 is a CPU module computer that is produced
456 by Interface Corporation.
457 More information at <http://www.interface.co.jp>
458
459config SH_SH03 451config SH_SH03
460 bool "Interface CTP/PCI-SH03" 452 bool "Interface CTP/PCI-SH03"
461 depends on CPU_SUBTYPE_SH7751 453 depends on CPU_SUBTYPE_SH7751
@@ -657,8 +649,7 @@ source "arch/sh/drivers/Kconfig"
657endmenu 649endmenu
658 650
659config ISA_DMA_API 651config ISA_DMA_API
660 def_bool y 652 bool
661 depends on SH_MPC1211
662 653
663menu "Kernel features" 654menu "Kernel features"
664 655
@@ -666,7 +657,7 @@ source kernel/Kconfig.hz
666 657
667config KEXEC 658config KEXEC
668 bool "kexec system call (EXPERIMENTAL)" 659 bool "kexec system call (EXPERIMENTAL)"
669 depends on EXPERIMENTAL 660 depends on SUPERH32 && EXPERIMENTAL
670 help 661 help
671 kexec is a system call that implements the ability to shutdown your 662 kexec is a system call that implements the ability to shutdown your
672 current kernel, and to start another kernel. It is like a reboot 663 current kernel, and to start another kernel. It is like a reboot
@@ -683,7 +674,7 @@ config KEXEC
683 674
684config CRASH_DUMP 675config CRASH_DUMP
685 bool "kernel crash dumps (EXPERIMENTAL)" 676 bool "kernel crash dumps (EXPERIMENTAL)"
686 depends on EXPERIMENTAL 677 depends on SUPERH32 && EXPERIMENTAL
687 help 678 help
688 Generate crash dump after being started by kexec. 679 Generate crash dump after being started by kexec.
689 This should be normally only set in special crash dump kernels 680 This should be normally only set in special crash dump kernels
@@ -763,7 +754,7 @@ menu "Boot options"
763 754
764config ZERO_PAGE_OFFSET 755config ZERO_PAGE_OFFSET
765 hex "Zero page offset" 756 hex "Zero page offset"
766 default "0x00004000" if SH_MPC1211 || SH_SH03 757 default "0x00004000" if SH_SH03
767 default "0x00010000" if PAGE_SIZE_64KB 758 default "0x00010000" if PAGE_SIZE_64KB
768 default "0x00002000" if PAGE_SIZE_8KB 759 default "0x00002000" if PAGE_SIZE_8KB
769 default "0x00001000" 760 default "0x00001000"
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index d9d28f9dd0db..0d2ef1e9a6fd 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -7,6 +7,7 @@ source "lib/Kconfig.debug"
7 7
8config SH_STANDARD_BIOS 8config SH_STANDARD_BIOS
9 bool "Use LinuxSH standard BIOS" 9 bool "Use LinuxSH standard BIOS"
10 depends on SUPERH32
10 help 11 help
11 Say Y here if your target has the gdb-sh-stub 12 Say Y here if your target has the gdb-sh-stub
12 package from www.m17n.org (or any conforming standard LinuxSH BIOS) 13 package from www.m17n.org (or any conforming standard LinuxSH BIOS)
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index bb06f83e6239..8050b03d51fc 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -110,7 +110,6 @@ machdir-$(CONFIG_SH_7343_SOLUTION_ENGINE) += se/7343
110machdir-$(CONFIG_SH_7721_SOLUTION_ENGINE) += se/7721 110machdir-$(CONFIG_SH_7721_SOLUTION_ENGINE) += se/7721
111machdir-$(CONFIG_SH_HP6XX) += hp6xx 111machdir-$(CONFIG_SH_HP6XX) += hp6xx
112machdir-$(CONFIG_SH_DREAMCAST) += dreamcast 112machdir-$(CONFIG_SH_DREAMCAST) += dreamcast
113machdir-$(CONFIG_SH_MPC1211) += mpc1211
114machdir-$(CONFIG_SH_SH03) += sh03 113machdir-$(CONFIG_SH_SH03) += sh03
115machdir-$(CONFIG_SH_SECUREEDGE5410) += snapgear 114machdir-$(CONFIG_SH_SECUREEDGE5410) += snapgear
116machdir-$(CONFIG_SH_RTS7751R2D) += renesas/rts7751r2d 115machdir-$(CONFIG_SH_RTS7751R2D) += renesas/rts7751r2d
diff --git a/arch/sh/boards/mpc1211/Makefile b/arch/sh/boards/mpc1211/Makefile
deleted file mode 100644
index 8cd31b5d200b..000000000000
--- a/arch/sh/boards/mpc1211/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the Interface (CTP/PCI/MPC-SH02) specific parts of the kernel
3#
4
5obj-y := setup.o rtc.o
6
7obj-$(CONFIG_PCI) += pci.o
8
diff --git a/arch/sh/boards/mpc1211/pci.c b/arch/sh/boards/mpc1211/pci.c
deleted file mode 100644
index 23849f70f133..000000000000
--- a/arch/sh/boards/mpc1211/pci.c
+++ /dev/null
@@ -1,295 +0,0 @@
1/*
2 * Low-Level PCI Support for the MPC-1211(CTP/PCI/MPC-SH02)
3 *
4 * (c) 2002-2003 Saito.K & Jeanne
5 *
6 * Dustin McIntire (dustin@sensoria.com)
7 * Derived from arch/i386/kernel/pci-*.c which bore the message:
8 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
9 *
10 * May be copied or modified under the terms of the GNU General Public
11 * License. See linux/COPYING for more information.
12 *
13 */
14#include <linux/types.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pci.h>
19#include <linux/sched.h>
20#include <linux/ioport.h>
21#include <linux/errno.h>
22#include <linux/irq.h>
23#include <linux/interrupt.h>
24
25#include <asm/machvec.h>
26#include <asm/io.h>
27#include <asm/mpc1211/pci.h>
28
29static struct resource mpcpci_io_resource = {
30 "MPCPCI IO",
31 0x00000000,
32 0xffffffff,
33 IORESOURCE_IO
34};
35
36static struct resource mpcpci_mem_resource = {
37 "MPCPCI mem",
38 0x00000000,
39 0xffffffff,
40 IORESOURCE_MEM
41};
42
43static struct pci_ops pci_direct_conf1;
44struct pci_channel board_pci_channels[] = {
45 {&pci_direct_conf1, &mpcpci_io_resource, &mpcpci_mem_resource, 0, 256},
46 {NULL, NULL, NULL, 0, 0},
47};
48
49/*
50 * Direct access to PCI hardware...
51 */
52
53
54#define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
55
56/*
57 * Functions for accessing PCI configuration space with type 1 accesses
58 */
59static int pci_conf1_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *value)
60{
61 u32 word;
62 unsigned long flags;
63
64 /*
65 * PCIPDR may only be accessed as 32 bit words,
66 * so we must do byte alignment by hand
67 */
68 local_irq_save(flags);
69 writel(CONFIG_CMD(bus,devfn,where), PCIPAR);
70 word = readl(PCIPDR);
71 local_irq_restore(flags);
72
73 switch (size) {
74 case 1:
75 switch (where & 0x3) {
76 case 3:
77 *value = (u8)(word >> 24);
78 break;
79 case 2:
80 *value = (u8)(word >> 16);
81 break;
82 case 1:
83 *value = (u8)(word >> 8);
84 break;
85 default:
86 *value = (u8)word;
87 break;
88 }
89 break;
90 case 2:
91 switch (where & 0x3) {
92 case 3:
93 *value = (u16)(word >> 24);
94 local_irq_save(flags);
95 writel(CONFIG_CMD(bus,devfn,(where+1)), PCIPAR);
96 word = readl(PCIPDR);
97 local_irq_restore(flags);
98 *value |= ((word & 0xff) << 8);
99 break;
100 case 2:
101 *value = (u16)(word >> 16);
102 break;
103 case 1:
104 *value = (u16)(word >> 8);
105 break;
106 default:
107 *value = (u16)word;
108 break;
109 }
110 break;
111 case 4:
112 *value = word;
113 break;
114 }
115 PCIDBG(4,"pci_conf1_read@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),*value);
116 return PCIBIOS_SUCCESSFUL;
117}
118
119/*
120 * Since MPC-1211 only does 32bit access we'll have to do a read,mask,write operation.
121 * We'll allow an odd byte offset, though it should be illegal.
122 */
123static int pci_conf1_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 value)
124{
125 u32 word,mask = 0;
126 unsigned long flags;
127 u32 shift = (where & 3) * 8;
128
129 if(size == 1) {
130 mask = ((1 << 8) - 1) << shift; // create the byte mask
131 } else if(size == 2){
132 if(shift == 24)
133 return PCIBIOS_BAD_REGISTER_NUMBER;
134 mask = ((1 << 16) - 1) << shift; // create the word mask
135 }
136 local_irq_save(flags);
137 writel(CONFIG_CMD(bus,devfn,where), PCIPAR);
138 if(size == 4){
139 writel(value, PCIPDR);
140 local_irq_restore(flags);
141 PCIDBG(4,"pci_conf1_write@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),value);
142 return PCIBIOS_SUCCESSFUL;
143 }
144 word = readl(PCIPDR);
145 word &= ~mask;
146 word |= ((value << shift) & mask);
147 writel(word, PCIPDR);
148 local_irq_restore(flags);
149 PCIDBG(4,"pci_conf1_write@0x%08x=0x%x\n", CONFIG_CMD(bus,devfn,where),word);
150 return PCIBIOS_SUCCESSFUL;
151}
152
153#undef CONFIG_CMD
154
155static struct pci_ops pci_direct_conf1 = {
156 .read = pci_conf1_read,
157 .write = pci_conf1_write,
158};
159
160static void __devinit quirk_ali_ide_ports(struct pci_dev *dev)
161{
162 dev->resource[0].start = 0x1f0;
163 dev->resource[0].end = 0x1f7;
164 dev->resource[0].flags = IORESOURCE_IO;
165 dev->resource[1].start = 0x3f6;
166 dev->resource[1].end = 0x3f6;
167 dev->resource[1].flags = IORESOURCE_IO;
168 dev->resource[2].start = 0x170;
169 dev->resource[2].end = 0x177;
170 dev->resource[2].flags = IORESOURCE_IO;
171 dev->resource[3].start = 0x376;
172 dev->resource[3].end = 0x376;
173 dev->resource[3].flags = IORESOURCE_IO;
174 dev->resource[4].start = 0xf000;
175 dev->resource[4].end = 0xf00f;
176 dev->resource[4].flags = IORESOURCE_IO;
177}
178DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M5229, quirk_ali_ide_ports);
179
180char * __devinit pcibios_setup(char *str)
181{
182 return str;
183}
184
185/*
186 * Called after each bus is probed, but before its children
187 * are examined.
188 */
189
190void __devinit pcibios_fixup_bus(struct pci_bus *b)
191{
192 pci_read_bridge_bases(b);
193}
194
195/*
196 * IRQ functions
197 */
198static inline u8 bridge_swizzle(u8 pin, u8 slot)
199{
200 return (((pin-1) + slot) % 4) + 1;
201}
202
203static inline u8 bridge_swizzle_pci_1(u8 pin, u8 slot)
204{
205 return (((pin-1) - slot) & 3) + 1;
206}
207
208static u8 __init mpc1211_swizzle(struct pci_dev *dev, u8 *pinp)
209{
210 unsigned long flags;
211 u8 pin = *pinp;
212 u32 word;
213
214 for ( ; dev->bus->self; dev = dev->bus->self) {
215 if (!pin)
216 continue;
217
218 if (dev->bus->number == 1) {
219 local_irq_save(flags);
220 writel(0x80000000 | 0x2c, PCIPAR);
221 word = readl(PCIPDR);
222 local_irq_restore(flags);
223 word >>= 16;
224
225 if (word == 0x0001)
226 pin = bridge_swizzle_pci_1(pin, PCI_SLOT(dev->devfn));
227 else
228 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
229 } else
230 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
231 }
232
233 *pinp = pin;
234
235 return PCI_SLOT(dev->devfn);
236}
237
238static int __init map_mpc1211_irq(struct pci_dev *dev, u8 slot, u8 pin)
239{
240 int irq = -1;
241
242 /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
243 if (dev->bus->number == 0) {
244 switch (slot) {
245 case 13: irq = 9; break; /* USB */
246 case 22: irq = 10; break; /* LAN */
247 default: irq = 0; break;
248 }
249 } else {
250 switch (pin) {
251 case 0: irq = 0; break;
252 case 1: irq = 7; break;
253 case 2: irq = 9; break;
254 case 3: irq = 10; break;
255 case 4: irq = 11; break;
256 }
257 }
258
259 if( irq < 0 ) {
260 PCIDBG(3, "PCI: Error mapping IRQ on device %s\n", pci_name(dev));
261 return irq;
262 }
263
264 PCIDBG(2, "Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
265
266 return irq;
267}
268
269void __init pcibios_fixup_irqs(void)
270{
271 pci_fixup_irqs(mpc1211_swizzle, map_mpc1211_irq);
272}
273
274void pcibios_align_resource(void *data, struct resource *res,
275 resource_size_t size, resource_size_t align)
276{
277 resource_size_t start = res->start;
278
279 if (res->flags & IORESOURCE_IO) {
280 if (start >= 0x10000UL) {
281 if ((start & 0xffffUL) < 0x4000UL) {
282 start = (start & 0xffff0000UL) + 0x4000UL;
283 } else if ((start & 0xffffUL) >= 0xf000UL) {
284 start = (start & 0xffff0000UL) + 0x10000UL;
285 }
286 res->start = start;
287 } else {
288 if (start & 0x300) {
289 start = (start + 0x3ff) & ~0x3ff;
290 res->start = start;
291 }
292 }
293 }
294}
295
diff --git a/arch/sh/boards/mpc1211/rtc.c b/arch/sh/boards/mpc1211/rtc.c
deleted file mode 100644
index 03b123a4bba4..000000000000
--- a/arch/sh/boards/mpc1211/rtc.c
+++ /dev/null
@@ -1,136 +0,0 @@
1/*
2 * linux/arch/sh/kernel/rtc-mpc1211.c -- MPC-1211 on-chip RTC support
3 *
4 * Copyright (C) 2002 Saito.K & Jeanne
5 *
6 */
7
8#include <linux/init.h>
9#include <linux/kernel.h>
10#include <linux/sched.h>
11#include <linux/time.h>
12#include <linux/bcd.h>
13#include <linux/mc146818rtc.h>
14
15unsigned long get_cmos_time(void)
16{
17 unsigned int year, mon, day, hour, min, sec;
18
19 spin_lock(&rtc_lock);
20
21 do {
22 sec = CMOS_READ(RTC_SECONDS);
23 min = CMOS_READ(RTC_MINUTES);
24 hour = CMOS_READ(RTC_HOURS);
25 day = CMOS_READ(RTC_DAY_OF_MONTH);
26 mon = CMOS_READ(RTC_MONTH);
27 year = CMOS_READ(RTC_YEAR);
28 } while (sec != CMOS_READ(RTC_SECONDS));
29
30 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
31 BCD_TO_BIN(sec);
32 BCD_TO_BIN(min);
33 BCD_TO_BIN(hour);
34 BCD_TO_BIN(day);
35 BCD_TO_BIN(mon);
36 BCD_TO_BIN(year);
37 }
38
39 spin_unlock(&rtc_lock);
40
41 year += 1900;
42 if (year < 1970)
43 year += 100;
44
45 return mktime(year, mon, day, hour, min, sec);
46}
47
48void mpc1211_rtc_gettimeofday(struct timeval *tv)
49{
50
51 tv->tv_sec = get_cmos_time();
52 tv->tv_usec = 0;
53}
54
55/* arc/i386/kernel/time.c */
56/*
57 * In order to set the CMOS clock precisely, set_rtc_mmss has to be
58 * called 500 ms after the second nowtime has started, because when
59 * nowtime is written into the registers of the CMOS clock, it will
60 * jump to the next second precisely 500 ms later. Check the Motorola
61 * MC146818A or Dallas DS12887 data sheet for details.
62 *
63 * BUG: This routine does not handle hour overflow properly; it just
64 * sets the minutes. Usually you'll only notice that after reboot!
65 */
66static int set_rtc_mmss(unsigned long nowtime)
67{
68 int retval = 0;
69 int real_seconds, real_minutes, cmos_minutes;
70 unsigned char save_control, save_freq_select;
71
72 /* gets recalled with irq locally disabled */
73 spin_lock(&rtc_lock);
74 save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
75 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
76
77 save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
78 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
79
80 cmos_minutes = CMOS_READ(RTC_MINUTES);
81 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
82 BCD_TO_BIN(cmos_minutes);
83
84 /*
85 * since we're only adjusting minutes and seconds,
86 * don't interfere with hour overflow. This avoids
87 * messing with unknown time zones but requires your
88 * RTC not to be off by more than 15 minutes
89 */
90 real_seconds = nowtime % 60;
91 real_minutes = nowtime / 60;
92 if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
93 real_minutes += 30; /* correct for half hour time zone */
94 real_minutes %= 60;
95
96 if (abs(real_minutes - cmos_minutes) < 30) {
97 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
98 BIN_TO_BCD(real_seconds);
99 BIN_TO_BCD(real_minutes);
100 }
101 CMOS_WRITE(real_seconds,RTC_SECONDS);
102 CMOS_WRITE(real_minutes,RTC_MINUTES);
103 } else {
104 printk(KERN_WARNING
105 "set_rtc_mmss: can't update from %d to %d\n",
106 cmos_minutes, real_minutes);
107 retval = -1;
108 }
109
110 /* The following flags have to be released exactly in this order,
111 * otherwise the DS12887 (popular MC146818A clone with integrated
112 * battery and quartz) will not reset the oscillator and will not
113 * update precisely 500 ms later. You won't find this mentioned in
114 * the Dallas Semiconductor data sheets, but who believes data
115 * sheets anyway ... -- Markus Kuhn
116 */
117 CMOS_WRITE(save_control, RTC_CONTROL);
118 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
119 spin_unlock(&rtc_lock);
120
121 return retval;
122}
123
124int mpc1211_rtc_settimeofday(const struct timeval *tv)
125{
126 unsigned long nowtime = tv->tv_sec;
127
128 return set_rtc_mmss(nowtime);
129}
130
131void mpc1211_time_init(void)
132{
133 rtc_sh_get_time = mpc1211_rtc_gettimeofday;
134 rtc_sh_set_time = mpc1211_rtc_settimeofday;
135}
136
diff --git a/arch/sh/boards/mpc1211/setup.c b/arch/sh/boards/mpc1211/setup.c
deleted file mode 100644
index fede36361dc7..000000000000
--- a/arch/sh/boards/mpc1211/setup.c
+++ /dev/null
@@ -1,347 +0,0 @@
1/*
2 * linux/arch/sh/boards/mpc1211/setup.c
3 *
4 * Copyright (C) 2002 Saito.K & Jeanne, Fujii.Y
5 *
6 */
7
8#include <linux/init.h>
9#include <linux/irq.h>
10#include <linux/hdreg.h>
11#include <linux/ide.h>
12#include <linux/interrupt.h>
13#include <linux/platform_device.h>
14#include <asm/io.h>
15#include <asm/machvec.h>
16#include <asm/mpc1211/mpc1211.h>
17#include <asm/mpc1211/pci.h>
18#include <asm/mpc1211/m1543c.h>
19
20/* ALI15X3 SMBus address offsets */
21#define SMBHSTSTS (0 + 0x3100)
22#define SMBHSTCNT (1 + 0x3100)
23#define SMBHSTSTART (2 + 0x3100)
24#define SMBHSTCMD (7 + 0x3100)
25#define SMBHSTADD (3 + 0x3100)
26#define SMBHSTDAT0 (4 + 0x3100)
27#define SMBHSTDAT1 (5 + 0x3100)
28#define SMBBLKDAT (6 + 0x3100)
29
30/* Other settings */
31#define MAX_TIMEOUT 500 /* times 1/100 sec */
32
33/* ALI15X3 command constants */
34#define ALI15X3_ABORT 0x04
35#define ALI15X3_T_OUT 0x08
36#define ALI15X3_QUICK 0x00
37#define ALI15X3_BYTE 0x10
38#define ALI15X3_BYTE_DATA 0x20
39#define ALI15X3_WORD_DATA 0x30
40#define ALI15X3_BLOCK_DATA 0x40
41#define ALI15X3_BLOCK_CLR 0x80
42
43/* ALI15X3 status register bits */
44#define ALI15X3_STS_IDLE 0x04
45#define ALI15X3_STS_BUSY 0x08
46#define ALI15X3_STS_DONE 0x10
47#define ALI15X3_STS_DEV 0x20 /* device error */
48#define ALI15X3_STS_COLL 0x40 /* collision or no response */
49#define ALI15X3_STS_TERM 0x80 /* terminated by abort */
50#define ALI15X3_STS_ERR 0xE0 /* all the bad error bits */
51
52static void __init pci_write_config(unsigned long busNo,
53 unsigned long devNo,
54 unsigned long fncNo,
55 unsigned long cnfAdd,
56 unsigned long cnfData)
57{
58 ctrl_outl((0x80000000
59 + ((busNo & 0xff) << 16)
60 + ((devNo & 0x1f) << 11)
61 + ((fncNo & 0x07) << 8)
62 + (cnfAdd & 0xfc)), PCIPAR);
63
64 ctrl_outl(cnfData, PCIPDR);
65}
66
67/*
68 Initialize IRQ setting
69*/
70
71static unsigned char m_irq_mask = 0xfb;
72static unsigned char s_irq_mask = 0xff;
73
74static void disable_mpc1211_irq(unsigned int irq)
75{
76 if( irq < 8) {
77 m_irq_mask |= (1 << irq);
78 outb(m_irq_mask,I8259_M_MR);
79 } else {
80 s_irq_mask |= (1 << (irq - 8));
81 outb(s_irq_mask,I8259_S_MR);
82 }
83
84}
85
86static void enable_mpc1211_irq(unsigned int irq)
87{
88 if( irq < 8) {
89 m_irq_mask &= ~(1 << irq);
90 outb(m_irq_mask,I8259_M_MR);
91 } else {
92 s_irq_mask &= ~(1 << (irq - 8));
93 outb(s_irq_mask,I8259_S_MR);
94 }
95}
96
97static inline int mpc1211_irq_real(unsigned int irq)
98{
99 int value;
100 int irqmask;
101
102 if ( irq < 8) {
103 irqmask = 1<<irq;
104 outb(0x0b,I8259_M_CR); /* ISR register */
105 value = inb(I8259_M_CR) & irqmask;
106 outb(0x0a,I8259_M_CR); /* back ro the IPR reg */
107 return value;
108 }
109 irqmask = 1<<(irq - 8);
110 outb(0x0b,I8259_S_CR); /* ISR register */
111 value = inb(I8259_S_CR) & irqmask;
112 outb(0x0a,I8259_S_CR); /* back ro the IPR reg */
113 return value;
114}
115
116static void mask_and_ack_mpc1211(unsigned int irq)
117{
118 if(irq < 8) {
119 if(m_irq_mask & (1<<irq)){
120 if(!mpc1211_irq_real(irq)){
121 atomic_inc(&irq_err_count)
122 printk("spurious 8259A interrupt: IRQ %x\n",irq);
123 }
124 } else {
125 m_irq_mask |= (1<<irq);
126 }
127 inb(I8259_M_MR); /* DUMMY */
128 outb(m_irq_mask,I8259_M_MR); /* disable */
129 outb(0x60+irq,I8259_M_CR); /* EOI */
130
131 } else {
132 if(s_irq_mask & (1<<(irq - 8))){
133 if(!mpc1211_irq_real(irq)){
134 atomic_inc(&irq_err_count);
135 printk("spurious 8259A interrupt: IRQ %x\n",irq);
136 }
137 } else {
138 s_irq_mask |= (1<<(irq - 8));
139 }
140 inb(I8259_S_MR); /* DUMMY */
141 outb(s_irq_mask,I8259_S_MR); /* disable */
142 outb(0x60+(irq-8),I8259_S_CR); /* EOI */
143 outb(0x60+2,I8259_M_CR);
144 }
145}
146
147static void end_mpc1211_irq(unsigned int irq)
148{
149 enable_mpc1211_irq(irq);
150}
151
152static unsigned int startup_mpc1211_irq(unsigned int irq)
153{
154 enable_mpc1211_irq(irq);
155 return 0;
156}
157
158static void shutdown_mpc1211_irq(unsigned int irq)
159{
160 disable_mpc1211_irq(irq);
161}
162
163static struct hw_interrupt_type mpc1211_irq_type = {
164 .typename = "MPC1211-IRQ",
165 .startup = startup_mpc1211_irq,
166 .shutdown = shutdown_mpc1211_irq,
167 .enable = enable_mpc1211_irq,
168 .disable = disable_mpc1211_irq,
169 .ack = mask_and_ack_mpc1211,
170 .end = end_mpc1211_irq
171};
172
173static void make_mpc1211_irq(unsigned int irq)
174{
175 irq_desc[irq].chip = &mpc1211_irq_type;
176 irq_desc[irq].status = IRQ_DISABLED;
177 irq_desc[irq].action = 0;
178 irq_desc[irq].depth = 1;
179 disable_mpc1211_irq(irq);
180}
181
182int mpc1211_irq_demux(int irq)
183{
184 unsigned int poll;
185
186 if( irq == 2 ) {
187 outb(0x0c,I8259_M_CR);
188 poll = inb(I8259_M_CR);
189 if(poll & 0x80) {
190 irq = (poll & 0x07);
191 }
192 if( irq == 2) {
193 outb(0x0c,I8259_S_CR);
194 poll = inb(I8259_S_CR);
195 irq = (poll & 0x07) + 8;
196 }
197 }
198 return irq;
199}
200
201static void __init init_mpc1211_IRQ(void)
202{
203 int i;
204 /*
205 * Super I/O (Just mimic PC):
206 * 1: keyboard
207 * 3: serial 1
208 * 4: serial 0
209 * 5: printer
210 * 6: floppy
211 * 8: rtc
212 * 10: lan
213 * 12: mouse
214 * 14: ide0
215 * 15: ide1
216 */
217
218 pci_write_config(0,0,0,0x54, 0xb0b0002d);
219 outb(0x11, I8259_M_CR); /* mater icw1 edge trigger */
220 outb(0x11, I8259_S_CR); /* slave icw1 edge trigger */
221 outb(0x20, I8259_M_MR); /* m icw2 base vec 0x08 */
222 outb(0x28, I8259_S_MR); /* s icw2 base vec 0x70 */
223 outb(0x04, I8259_M_MR); /* m icw3 slave irq2 */
224 outb(0x02, I8259_S_MR); /* s icw3 slave id */
225 outb(0x01, I8259_M_MR); /* m icw4 non buf normal eoi*/
226 outb(0x01, I8259_S_MR); /* s icw4 non buf normal eo1*/
227 outb(0xfb, I8259_M_MR); /* disable irq0--irq7 */
228 outb(0xff, I8259_S_MR); /* disable irq8--irq15 */
229
230 for ( i=0; i < 16; i++) {
231 if(i != 2) {
232 make_mpc1211_irq(i);
233 }
234 }
235}
236
237static void delay1000(void)
238{
239 int i;
240
241 for (i=0; i<1000; i++)
242 ctrl_delay();
243}
244
245static int put_smb_blk(unsigned char *p, int address, int command, int no)
246{
247 int temp;
248 int timeout;
249 int i;
250
251 outb(0xff, SMBHSTSTS);
252 temp = inb(SMBHSTSTS);
253 for (timeout = 0; (timeout < MAX_TIMEOUT) && !(temp & ALI15X3_STS_IDLE); timeout++) {
254 delay1000();
255 temp = inb(SMBHSTSTS);
256 }
257 if (timeout >= MAX_TIMEOUT){
258 return -1;
259 }
260
261 outb(((address & 0x7f) << 1), SMBHSTADD);
262 outb(0xc0, SMBHSTCNT);
263 outb(command & 0xff, SMBHSTCMD);
264 outb(no & 0x1f, SMBHSTDAT0);
265
266 for(i = 1; i <= no; i++) {
267 outb(*p++, SMBBLKDAT);
268 }
269 outb(0xff, SMBHSTSTART);
270
271 temp = inb(SMBHSTSTS);
272 for (timeout = 0; (timeout < MAX_TIMEOUT) && !(temp & (ALI15X3_STS_ERR | ALI15X3_STS_DONE)); timeout++) {
273 delay1000();
274 temp = inb(SMBHSTSTS);
275 }
276 if (timeout >= MAX_TIMEOUT) {
277 return -2;
278 }
279 if ( temp & ALI15X3_STS_ERR ){
280 return -3;
281 }
282 return 0;
283}
284
285static struct resource heartbeat_resources[] = {
286 [0] = {
287 .start = 0xa2000000,
288 .end = 0xa2000000,
289 .flags = IORESOURCE_MEM,
290 },
291};
292
293static struct platform_device heartbeat_device = {
294 .name = "heartbeat",
295 .id = -1,
296 .num_resources = ARRAY_SIZE(heartbeat_resources),
297 .resource = heartbeat_resources,
298};
299
300static struct platform_device *mpc1211_devices[] __initdata = {
301 &heartbeat_device,
302};
303
304static int __init mpc1211_devices_setup(void)
305{
306 return platform_add_devices(mpc1211_devices,
307 ARRAY_SIZE(mpc1211_devices));
308}
309__initcall(mpc1211_devices_setup);
310
311/* arch/sh/boards/mpc1211/rtc.c */
312void mpc1211_time_init(void);
313
314static void __init mpc1211_setup(char **cmdline_p)
315{
316 unsigned char spd_buf[128];
317
318 __set_io_port_base(PA_PCI_IO);
319
320 pci_write_config(0,0,0,0x54, 0xb0b00000);
321
322 do {
323 outb(ALI15X3_ABORT, SMBHSTCNT);
324 spd_buf[0] = 0x0c;
325 spd_buf[1] = 0x43;
326 spd_buf[2] = 0x7f;
327 spd_buf[3] = 0x03;
328 spd_buf[4] = 0x00;
329 spd_buf[5] = 0x03;
330 spd_buf[6] = 0x00;
331 } while (put_smb_blk(spd_buf, 0x69, 0, 7) < 0);
332
333 board_time_init = mpc1211_time_init;
334
335 return 0;
336}
337
338/*
339 * The Machine Vector
340 */
341static struct sh_machine_vector mv_mpc1211 __initmv = {
342 .mv_name = "Interface MPC-1211(CTP/PCI/MPC-SH02)",
343 .mv_setup = mpc1211_setup,
344 .mv_nr_irqs = 48,
345 .mv_irq_demux = mpc1211_irq_demux,
346 .mv_init_irq = init_mpc1211_IRQ,
347};
diff --git a/arch/sh/boards/renesas/migor/setup.c b/arch/sh/boards/renesas/migor/setup.c
index e7c150d49702..01af44245b57 100644
--- a/arch/sh/boards/renesas/migor/setup.c
+++ b/arch/sh/boards/renesas/migor/setup.c
@@ -14,6 +14,7 @@
14#include <linux/mtd/physmap.h> 14#include <linux/mtd/physmap.h>
15#include <linux/mtd/nand.h> 15#include <linux/mtd/nand.h>
16#include <linux/i2c.h> 16#include <linux/i2c.h>
17#include <linux/smc91x.h>
17#include <asm/machvec.h> 18#include <asm/machvec.h>
18#include <asm/io.h> 19#include <asm/io.h>
19#include <asm/sh_keysc.h> 20#include <asm/sh_keysc.h>
@@ -27,6 +28,11 @@
27 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A) 28 * 0x18000000 8GB 8 NAND Flash (K9K8G08U0A)
28 */ 29 */
29 30
31static struct smc91x_platdata smc91x_info = {
32 .flags = SMC91X_USE_16BIT,
33 .irq_flags = IRQF_TRIGGER_HIGH,
34};
35
30static struct resource smc91x_eth_resources[] = { 36static struct resource smc91x_eth_resources[] = {
31 [0] = { 37 [0] = {
32 .name = "SMC91C111" , 38 .name = "SMC91C111" ,
@@ -36,7 +42,7 @@ static struct resource smc91x_eth_resources[] = {
36 }, 42 },
37 [1] = { 43 [1] = {
38 .start = 32, /* IRQ0 */ 44 .start = 32, /* IRQ0 */
39 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH, 45 .flags = IORESOURCE_IRQ,
40 }, 46 },
41}; 47};
42 48
@@ -44,6 +50,9 @@ static struct platform_device smc91x_eth_device = {
44 .name = "smc91x", 50 .name = "smc91x",
45 .num_resources = ARRAY_SIZE(smc91x_eth_resources), 51 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
46 .resource = smc91x_eth_resources, 52 .resource = smc91x_eth_resources,
53 .dev = {
54 .platform_data = &smc91x_info,
55 },
47}; 56};
48 57
49static struct sh_keysc_info sh_keysc_info = { 58static struct sh_keysc_info sh_keysc_info = {
diff --git a/arch/sh/boards/renesas/r7780rp/irq-r7780mp.c b/arch/sh/boards/renesas/r7780rp/irq-r7780mp.c
index 68f0ad1b637d..ae1cfcb29700 100644
--- a/arch/sh/boards/renesas/r7780rp/irq-r7780mp.c
+++ b/arch/sh/boards/renesas/r7780rp/irq-r7780mp.c
@@ -62,7 +62,7 @@ static unsigned char irl2irq[HL_NR_IRL] __initdata = {
62static DECLARE_INTC_DESC(intc_desc, "r7780mp", vectors, 62static DECLARE_INTC_DESC(intc_desc, "r7780mp", vectors,
63 NULL, mask_registers, NULL, NULL); 63 NULL, mask_registers, NULL, NULL);
64 64
65unsigned char * __init highlander_init_irq_r7780mp(void) 65unsigned char * __init highlander_plat_irq_setup(void)
66{ 66{
67 if ((ctrl_inw(0xa4000700) & 0xf000) == 0x2000) { 67 if ((ctrl_inw(0xa4000700) & 0xf000) == 0x2000) {
68 printk(KERN_INFO "Using r7780mp interrupt controller.\n"); 68 printk(KERN_INFO "Using r7780mp interrupt controller.\n");
diff --git a/arch/sh/boards/renesas/r7780rp/irq-r7780rp.c b/arch/sh/boards/renesas/r7780rp/irq-r7780rp.c
index bd34048ed0e1..9d3921fe27c0 100644
--- a/arch/sh/boards/renesas/r7780rp/irq-r7780rp.c
+++ b/arch/sh/boards/renesas/r7780rp/irq-r7780rp.c
@@ -55,7 +55,7 @@ static unsigned char irl2irq[HL_NR_IRL] __initdata = {
55static DECLARE_INTC_DESC(intc_desc, "r7780rp", vectors, 55static DECLARE_INTC_DESC(intc_desc, "r7780rp", vectors,
56 NULL, mask_registers, NULL, NULL); 56 NULL, mask_registers, NULL, NULL);
57 57
58unsigned char * __init highlander_init_irq_r7780rp(void) 58unsigned char * __init highlander_plat_irq_setup(void)
59{ 59{
60 if (ctrl_inw(0xa5000600)) { 60 if (ctrl_inw(0xa5000600)) {
61 printk(KERN_INFO "Using r7780rp interrupt controller.\n"); 61 printk(KERN_INFO "Using r7780rp interrupt controller.\n");
diff --git a/arch/sh/boards/renesas/r7780rp/irq-r7785rp.c b/arch/sh/boards/renesas/r7780rp/irq-r7785rp.c
index bf7ec107fbc6..896c045aa39d 100644
--- a/arch/sh/boards/renesas/r7780rp/irq-r7785rp.c
+++ b/arch/sh/boards/renesas/r7780rp/irq-r7785rp.c
@@ -64,7 +64,7 @@ static unsigned char irl2irq[HL_NR_IRL] __initdata = {
64static DECLARE_INTC_DESC(intc_desc, "r7785rp", vectors, 64static DECLARE_INTC_DESC(intc_desc, "r7785rp", vectors,
65 NULL, mask_registers, NULL, NULL); 65 NULL, mask_registers, NULL, NULL);
66 66
67unsigned char * __init highlander_init_irq_r7785rp(void) 67unsigned char * __init highlander_plat_irq_setup(void)
68{ 68{
69 if ((ctrl_inw(0xa4000158) & 0xf000) != 0x1000) 69 if ((ctrl_inw(0xa4000158) & 0xf000) != 0x1000)
70 return NULL; 70 return NULL;
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
index ac0a96522e45..bc79afb6fc4c 100644
--- a/arch/sh/boards/renesas/r7780rp/setup.c
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -316,7 +316,7 @@ static void __init highlander_setup(char **cmdline_p)
316 316
317static unsigned char irl2irq[HL_NR_IRL]; 317static unsigned char irl2irq[HL_NR_IRL];
318 318
319int highlander_irq_demux(int irq) 319static int highlander_irq_demux(int irq)
320{ 320{
321 if (irq >= HL_NR_IRL || !irl2irq[irq]) 321 if (irq >= HL_NR_IRL || !irl2irq[irq])
322 return irq; 322 return irq;
@@ -324,27 +324,9 @@ int highlander_irq_demux(int irq)
324 return irl2irq[irq]; 324 return irl2irq[irq];
325} 325}
326 326
327void __init highlander_init_irq(void) 327static void __init highlander_init_irq(void)
328{ 328{
329 unsigned char *ucp = NULL; 329 unsigned char *ucp = highlander_plat_irq_setup();
330
331 do {
332#ifdef CONFIG_SH_R7780MP
333 ucp = highlander_init_irq_r7780mp();
334 if (ucp)
335 break;
336#endif
337#ifdef CONFIG_SH_R7785RP
338 ucp = highlander_init_irq_r7785rp();
339 if (ucp)
340 break;
341#endif
342#ifdef CONFIG_SH_R7780RP
343 ucp = highlander_init_irq_r7780rp();
344 if (ucp)
345 break;
346#endif
347 } while (0);
348 330
349 if (ucp) { 331 if (ucp) {
350 plat_irq_setup_pins(IRQ_MODE_IRL3210); 332 plat_irq_setup_pins(IRQ_MODE_IRL3210);
diff --git a/arch/sh/boards/renesas/rts7751r2d/setup.c b/arch/sh/boards/renesas/rts7751r2d/setup.c
index f21ee49ef3a5..452d0d6459a4 100644
--- a/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ b/arch/sh/boards/renesas/rts7751r2d/setup.c
@@ -109,7 +109,6 @@ static struct platform_device heartbeat_device = {
109 .resource = heartbeat_resources, 109 .resource = heartbeat_resources,
110}; 110};
111 111
112#ifdef CONFIG_MFD_SM501
113static struct plat_serial8250_port uart_platform_data[] = { 112static struct plat_serial8250_port uart_platform_data[] = {
114 { 113 {
115 .membase = (void __iomem *)0xb3e30000, 114 .membase = (void __iomem *)0xb3e30000,
@@ -208,13 +207,9 @@ static struct platform_device sm501_device = {
208 .resource = sm501_resources, 207 .resource = sm501_resources,
209}; 208};
210 209
211#endif /* CONFIG_MFD_SM501 */
212
213static struct platform_device *rts7751r2d_devices[] __initdata = { 210static struct platform_device *rts7751r2d_devices[] __initdata = {
214#ifdef CONFIG_MFD_SM501
215 &uart_device, 211 &uart_device,
216 &sm501_device, 212 &sm501_device,
217#endif
218 &heartbeat_device, 213 &heartbeat_device,
219 &spi_sh_sci_device, 214 &spi_sh_sci_device,
220}; 215};
@@ -234,7 +229,9 @@ static int __init rts7751r2d_devices_setup(void)
234{ 229{
235 if (register_trapped_io(&cf_trapped_io) == 0) 230 if (register_trapped_io(&cf_trapped_io) == 0)
236 platform_device_register(&cf_ide_device); 231 platform_device_register(&cf_ide_device);
232
237 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); 233 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus));
234
238 return platform_add_devices(rts7751r2d_devices, 235 return platform_add_devices(rts7751r2d_devices,
239 ARRAY_SIZE(rts7751r2d_devices)); 236 ARRAY_SIZE(rts7751r2d_devices));
240} 237}
diff --git a/arch/sh/boards/se/7206/setup.c b/arch/sh/boards/se/7206/setup.c
index 5b3ee089d91d..4fe84cc08406 100644
--- a/arch/sh/boards/se/7206/setup.c
+++ b/arch/sh/boards/se/7206/setup.c
@@ -3,12 +3,13 @@
3 * linux/arch/sh/boards/se/7206/setup.c 3 * linux/arch/sh/boards/se/7206/setup.c
4 * 4 *
5 * Copyright (C) 2006 Yoshinori Sato 5 * Copyright (C) 2006 Yoshinori Sato
6 * Copyright (C) 2007 Paul Mundt 6 * Copyright (C) 2007 - 2008 Paul Mundt
7 * 7 *
8 * Hitachi 7206 SolutionEngine Support. 8 * Hitachi 7206 SolutionEngine Support.
9 */ 9 */
10#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/smc91x.h>
12#include <asm/se7206.h> 13#include <asm/se7206.h>
13#include <asm/io.h> 14#include <asm/io.h>
14#include <asm/machvec.h> 15#include <asm/machvec.h>
@@ -16,8 +17,9 @@
16 17
17static struct resource smc91x_resources[] = { 18static struct resource smc91x_resources[] = {
18 [0] = { 19 [0] = {
19 .start = 0x300, 20 .name = "smc91x-regs",
20 .end = 0x300 + 0x020 - 1, 21 .start = PA_SMSC + 0x300,
22 .end = PA_SMSC + 0x300 + 0x020 - 1,
21 .flags = IORESOURCE_MEM, 23 .flags = IORESOURCE_MEM,
22 }, 24 },
23 [1] = { 25 [1] = {
@@ -27,9 +29,18 @@ static struct resource smc91x_resources[] = {
27 }, 29 },
28}; 30};
29 31
32static struct smc91x_platdata smc91x_info = {
33 .flags = SMC91X_USE_16BIT,
34};
35
30static struct platform_device smc91x_device = { 36static struct platform_device smc91x_device = {
31 .name = "smc91x", 37 .name = "smc91x",
32 .id = -1, 38 .id = -1,
39 .dev = {
40 .dma_mask = NULL,
41 .coherent_dma_mask = 0xffffffff,
42 .platform_data = &smc91x_info,
43 },
33 .num_resources = ARRAY_SIZE(smc91x_resources), 44 .num_resources = ARRAY_SIZE(smc91x_resources),
34 .resource = smc91x_resources, 45 .resource = smc91x_resources,
35}; 46};
diff --git a/arch/sh/boards/se/7722/setup.c b/arch/sh/boards/se/7722/setup.c
index 33f6ee71f848..ede3957fc14a 100644
--- a/arch/sh/boards/se/7722/setup.c
+++ b/arch/sh/boards/se/7722/setup.c
@@ -14,6 +14,7 @@
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/ata_platform.h> 15#include <linux/ata_platform.h>
16#include <linux/input.h> 16#include <linux/input.h>
17#include <linux/smc91x.h>
17#include <asm/machvec.h> 18#include <asm/machvec.h>
18#include <asm/se7722.h> 19#include <asm/se7722.h>
19#include <asm/io.h> 20#include <asm/io.h>
@@ -44,6 +45,10 @@ static struct platform_device heartbeat_device = {
44}; 45};
45 46
46/* SMC91x */ 47/* SMC91x */
48static struct smc91x_platdata smc91x_info = {
49 .flags = SMC91X_USE_16BIT,
50};
51
47static struct resource smc91x_eth_resources[] = { 52static struct resource smc91x_eth_resources[] = {
48 [0] = { 53 [0] = {
49 .name = "smc91x-regs" , 54 .name = "smc91x-regs" ,
@@ -64,6 +69,7 @@ static struct platform_device smc91x_eth_device = {
64 .dev = { 69 .dev = {
65 .dma_mask = NULL, /* don't use dma */ 70 .dma_mask = NULL, /* don't use dma */
66 .coherent_dma_mask = 0xffffffff, 71 .coherent_dma_mask = 0xffffffff,
72 .platform_data = &smc91x_info,
67 }, 73 },
68 .num_resources = ARRAY_SIZE(smc91x_eth_resources), 74 .num_resources = ARRAY_SIZE(smc91x_eth_resources),
69 .resource = smc91x_eth_resources, 75 .resource = smc91x_eth_resources,
diff --git a/arch/sh/boot/compressed/Makefile_32 b/arch/sh/boot/compressed/Makefile_32
index 6ac8d4a4ed1d..c0d25fb1aa60 100644
--- a/arch/sh/boot/compressed/Makefile_32
+++ b/arch/sh/boot/compressed/Makefile_32
@@ -6,7 +6,6 @@
6 6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz \ 7targets := vmlinux vmlinux.bin vmlinux.bin.gz \
8 head_32.o misc_32.o piggy.o 8 head_32.o misc_32.o piggy.o
9EXTRA_AFLAGS := -traditional
10 9
11OBJECTS = $(obj)/head_32.o $(obj)/misc_32.o 10OBJECTS = $(obj)/head_32.o $(obj)/misc_32.o
12 11
diff --git a/arch/sh/boot/compressed/Makefile_64 b/arch/sh/boot/compressed/Makefile_64
index 4334f2b86d8f..912f3e205a0d 100644
--- a/arch/sh/boot/compressed/Makefile_64
+++ b/arch/sh/boot/compressed/Makefile_64
@@ -13,7 +13,6 @@
13 13
14targets := vmlinux vmlinux.bin vmlinux.bin.gz \ 14targets := vmlinux vmlinux.bin vmlinux.bin.gz \
15 head_64.o misc_64.o cache.o piggy.o 15 head_64.o misc_64.o cache.o piggy.o
16EXTRA_AFLAGS := -traditional
17 16
18OBJECTS := $(obj)/vmlinux_64.lds $(obj)/head_64.o $(obj)/misc_64.o \ 17OBJECTS := $(obj)/vmlinux_64.lds $(obj)/head_64.o $(obj)/misc_64.o \
19 $(obj)/cache.o 18 $(obj)/cache.o
diff --git a/arch/sh/kernel/cpu/irq/intc-sh5.c b/arch/sh/kernel/cpu/irq/intc-sh5.c
index d6e0e2bdaad5..de45c6a3e33b 100644
--- a/arch/sh/kernel/cpu/irq/intc-sh5.c
+++ b/arch/sh/kernel/cpu/irq/intc-sh5.c
@@ -184,9 +184,8 @@ int intc_irq_describe(char* p, int irq)
184 184
185void __init plat_irq_setup(void) 185void __init plat_irq_setup(void)
186{ 186{
187 unsigned long long __dummy0, __dummy1=~0x00000000100000f0; 187 unsigned long long __dummy0, __dummy1=~0x00000000100000f0;
188 unsigned long reg; 188 unsigned long reg;
189 unsigned long data;
190 int i; 189 int i;
191 190
192 intc_virt = onchip_remap(INTC_BASE, 1024, "INTC"); 191 intc_virt = onchip_remap(INTC_BASE, 1024, "INTC");
@@ -196,11 +195,8 @@ void __init plat_irq_setup(void)
196 195
197 196
198 /* Set default: per-line enable/disable, priority driven ack/eoi */ 197 /* Set default: per-line enable/disable, priority driven ack/eoi */
199 for (i = 0; i < NR_INTC_IRQS; i++) { 198 for (i = 0; i < NR_INTC_IRQS; i++)
200 if (platform_int_priority[i] != NO_PRIORITY) { 199 irq_desc[i].chip = &intc_irq_type;
201 irq_desc[i].chip = &intc_irq_type;
202 }
203 }
204 200
205 201
206 /* Disable all interrupts and set all priorities to 0 to avoid trouble */ 202 /* Disable all interrupts and set all priorities to 0 to avoid trouble */
@@ -211,35 +207,42 @@ void __init plat_irq_setup(void)
211 ctrl_outl( NO_PRIORITY, reg); 207 ctrl_outl( NO_PRIORITY, reg);
212 208
213 209
214 /* Set IRLM */ 210#ifdef CONFIG_SH_CAYMAN
215 /* If all the priorities are set to 'no priority', then 211 {
216 * assume we are using encoded mode. 212 unsigned long data;
217 */ 213
218 irlm = platform_int_priority[IRQ_IRL0] + platform_int_priority[IRQ_IRL1] + \ 214 /* Set IRLM */
219 platform_int_priority[IRQ_IRL2] + platform_int_priority[IRQ_IRL3]; 215 /* If all the priorities are set to 'no priority', then
220 216 * assume we are using encoded mode.
221 if (irlm == NO_PRIORITY) { 217 */
222 /* IRLM = 0 */ 218 irlm = platform_int_priority[IRQ_IRL0] +
223 reg = INTC_ICR_CLEAR; 219 platform_int_priority[IRQ_IRL1] +
224 i = IRQ_INTA; 220 platform_int_priority[IRQ_IRL2] +
225 printk("Trying to use encoded IRL0-3. IRLs unsupported.\n"); 221 platform_int_priority[IRQ_IRL3];
226 } else { 222 if (irlm == NO_PRIORITY) {
227 /* IRLM = 1 */ 223 /* IRLM = 0 */
228 reg = INTC_ICR_SET; 224 reg = INTC_ICR_CLEAR;
229 i = IRQ_IRL0; 225 i = IRQ_INTA;
230 } 226 printk("Trying to use encoded IRL0-3. IRLs unsupported.\n");
231 ctrl_outl(INTC_ICR_IRLM, reg); 227 } else {
232 228 /* IRLM = 1 */
233 /* Set interrupt priorities according to platform description */ 229 reg = INTC_ICR_SET;
234 for (data = 0, reg = INTC_INTPRI_0; i < NR_INTC_IRQS; i++) { 230 i = IRQ_IRL0;
235 data |= platform_int_priority[i] << ((i % INTC_INTPRI_PPREG) * 4);
236 if ((i % INTC_INTPRI_PPREG) == (INTC_INTPRI_PPREG - 1)) {
237 /* Upon the 7th, set Priority Register */
238 ctrl_outl(data, reg);
239 data = 0;
240 reg += 8;
241 } 231 }
242 } 232 ctrl_outl(INTC_ICR_IRLM, reg);
233
234 /* Set interrupt priorities according to platform description */
235 for (data = 0, reg = INTC_INTPRI_0; i < NR_INTC_IRQS; i++) {
236 data |= platform_int_priority[i] <<
237 ((i % INTC_INTPRI_PPREG) * 4);
238 if ((i % INTC_INTPRI_PPREG) == (INTC_INTPRI_PPREG - 1)) {
239 /* Upon the 7th, set Priority Register */
240 ctrl_outl(data, reg);
241 data = 0;
242 reg += 8;
243 }
244 }
245#endif
243 246
244 /* 247 /*
245 * And now let interrupts come in. 248 * And now let interrupts come in.
diff --git a/arch/sh/kernel/cpu/irq/intc.c b/arch/sh/kernel/cpu/irq/intc.c
index 84806b2027f8..da5dae787888 100644
--- a/arch/sh/kernel/cpu/irq/intc.c
+++ b/arch/sh/kernel/cpu/irq/intc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Shared interrupt handling code for IPR and INTC2 types of IRQs. 2 * Shared interrupt handling code for IPR and INTC2 types of IRQs.
3 * 3 *
4 * Copyright (C) 2007 Magnus Damm 4 * Copyright (C) 2007, 2008 Magnus Damm
5 * 5 *
6 * Based on intc2.c and ipr.c 6 * Based on intc2.c and ipr.c
7 * 7 *
@@ -62,6 +62,9 @@ struct intc_desc_int {
62#endif 62#endif
63 63
64static unsigned int intc_prio_level[NR_IRQS]; /* for now */ 64static unsigned int intc_prio_level[NR_IRQS]; /* for now */
65#ifdef CONFIG_CPU_SH3
66static unsigned long ack_handle[NR_IRQS];
67#endif
65 68
66static inline struct intc_desc_int *get_intc_desc(unsigned int irq) 69static inline struct intc_desc_int *get_intc_desc(unsigned int irq)
67{ 70{
@@ -98,17 +101,26 @@ static void write_32(unsigned long addr, unsigned long h, unsigned long data)
98 101
99static void modify_8(unsigned long addr, unsigned long h, unsigned long data) 102static void modify_8(unsigned long addr, unsigned long h, unsigned long data)
100{ 103{
104 unsigned long flags;
105 local_irq_save(flags);
101 ctrl_outb(set_field(ctrl_inb(addr), data, h), addr); 106 ctrl_outb(set_field(ctrl_inb(addr), data, h), addr);
107 local_irq_restore(flags);
102} 108}
103 109
104static void modify_16(unsigned long addr, unsigned long h, unsigned long data) 110static void modify_16(unsigned long addr, unsigned long h, unsigned long data)
105{ 111{
112 unsigned long flags;
113 local_irq_save(flags);
106 ctrl_outw(set_field(ctrl_inw(addr), data, h), addr); 114 ctrl_outw(set_field(ctrl_inw(addr), data, h), addr);
115 local_irq_restore(flags);
107} 116}
108 117
109static void modify_32(unsigned long addr, unsigned long h, unsigned long data) 118static void modify_32(unsigned long addr, unsigned long h, unsigned long data)
110{ 119{
120 unsigned long flags;
121 local_irq_save(flags);
111 ctrl_outl(set_field(ctrl_inl(addr), data, h), addr); 122 ctrl_outl(set_field(ctrl_inl(addr), data, h), addr);
123 local_irq_restore(flags);
112} 124}
113 125
114enum { REG_FN_ERR = 0, REG_FN_WRITE_BASE = 1, REG_FN_MODIFY_BASE = 5 }; 126enum { REG_FN_ERR = 0, REG_FN_WRITE_BASE = 1, REG_FN_MODIFY_BASE = 5 };
@@ -219,6 +231,25 @@ static void intc_disable(unsigned int irq)
219 } 231 }
220} 232}
221 233
234#ifdef CONFIG_CPU_SH3
235static void intc_mask_ack(unsigned int irq)
236{
237 struct intc_desc_int *d = get_intc_desc(irq);
238 unsigned long handle = ack_handle[irq];
239 unsigned long addr;
240
241 intc_disable(irq);
242
243 /* read register and write zero only to the assocaited bit */
244
245 if (handle) {
246 addr = INTC_REG(d, _INTC_ADDR_D(handle), 0);
247 ctrl_inb(addr);
248 ctrl_outb(0x3f ^ set_field(0, 1, handle), addr);
249 }
250}
251#endif
252
222static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp, 253static struct intc_handle_int *intc_find_irq(struct intc_handle_int *hp,
223 unsigned int nr_hp, 254 unsigned int nr_hp,
224 unsigned int irq) 255 unsigned int irq)
@@ -280,7 +311,12 @@ static unsigned char intc_irq_sense_table[IRQ_TYPE_SENSE_MASK + 1] = {
280 [IRQ_TYPE_EDGE_FALLING] = VALID(0), 311 [IRQ_TYPE_EDGE_FALLING] = VALID(0),
281 [IRQ_TYPE_EDGE_RISING] = VALID(1), 312 [IRQ_TYPE_EDGE_RISING] = VALID(1),
282 [IRQ_TYPE_LEVEL_LOW] = VALID(2), 313 [IRQ_TYPE_LEVEL_LOW] = VALID(2),
314 /* SH7706, SH7707 and SH7709 do not support high level triggered */
315#if !defined(CONFIG_CPU_SUBTYPE_SH7706) && \
316 !defined(CONFIG_CPU_SUBTYPE_SH7707) && \
317 !defined(CONFIG_CPU_SUBTYPE_SH7709)
283 [IRQ_TYPE_LEVEL_HIGH] = VALID(3), 318 [IRQ_TYPE_LEVEL_HIGH] = VALID(3),
319#endif
284}; 320};
285 321
286static int intc_set_sense(unsigned int irq, unsigned int type) 322static int intc_set_sense(unsigned int irq, unsigned int type)
@@ -430,6 +466,40 @@ static unsigned int __init intc_prio_data(struct intc_desc *desc,
430 return 0; 466 return 0;
431} 467}
432 468
469#ifdef CONFIG_CPU_SH3
470static unsigned int __init intc_ack_data(struct intc_desc *desc,
471 struct intc_desc_int *d,
472 intc_enum enum_id)
473{
474 struct intc_mask_reg *mr = desc->ack_regs;
475 unsigned int i, j, fn, mode;
476 unsigned long reg_e, reg_d;
477
478 for (i = 0; mr && enum_id && i < desc->nr_ack_regs; i++) {
479 mr = desc->ack_regs + i;
480
481 for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) {
482 if (mr->enum_ids[j] != enum_id)
483 continue;
484
485 fn = REG_FN_MODIFY_BASE;
486 mode = MODE_ENABLE_REG;
487 reg_e = mr->set_reg;
488 reg_d = mr->set_reg;
489
490 fn += (mr->reg_width >> 3) - 1;
491 return _INTC_MK(fn, mode,
492 intc_get_reg(d, reg_e),
493 intc_get_reg(d, reg_d),
494 1,
495 (mr->reg_width - 1) - j);
496 }
497 }
498
499 return 0;
500}
501#endif
502
433static unsigned int __init intc_sense_data(struct intc_desc *desc, 503static unsigned int __init intc_sense_data(struct intc_desc *desc,
434 struct intc_desc_int *d, 504 struct intc_desc_int *d,
435 intc_enum enum_id) 505 intc_enum enum_id)
@@ -530,6 +600,11 @@ static void __init intc_register_irq(struct intc_desc *desc,
530 600
531 /* irq should be disabled by default */ 601 /* irq should be disabled by default */
532 d->chip.mask(irq); 602 d->chip.mask(irq);
603
604#ifdef CONFIG_CPU_SH3
605 if (desc->ack_regs)
606 ack_handle[irq] = intc_ack_data(desc, d, enum_id);
607#endif
533} 608}
534 609
535static unsigned int __init save_reg(struct intc_desc_int *d, 610static unsigned int __init save_reg(struct intc_desc_int *d,
@@ -560,6 +635,9 @@ void __init register_intc_controller(struct intc_desc *desc)
560 d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; 635 d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0;
561 d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; 636 d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0;
562 637
638#ifdef CONFIG_CPU_SH3
639 d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0;
640#endif
563 d->reg = alloc_bootmem(d->nr_reg * sizeof(*d->reg)); 641 d->reg = alloc_bootmem(d->nr_reg * sizeof(*d->reg));
564#ifdef CONFIG_SMP 642#ifdef CONFIG_SMP
565 d->smp = alloc_bootmem(d->nr_reg * sizeof(*d->smp)); 643 d->smp = alloc_bootmem(d->nr_reg * sizeof(*d->smp));
@@ -592,14 +670,23 @@ void __init register_intc_controller(struct intc_desc *desc)
592 } 670 }
593 } 671 }
594 672
595 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */
596
597 d->chip.name = desc->name; 673 d->chip.name = desc->name;
598 d->chip.mask = intc_disable; 674 d->chip.mask = intc_disable;
599 d->chip.unmask = intc_enable; 675 d->chip.unmask = intc_enable;
600 d->chip.mask_ack = intc_disable; 676 d->chip.mask_ack = intc_disable;
601 d->chip.set_type = intc_set_sense; 677 d->chip.set_type = intc_set_sense;
602 678
679#ifdef CONFIG_CPU_SH3
680 if (desc->ack_regs) {
681 for (i = 0; i < desc->nr_ack_regs; i++)
682 k += save_reg(d, k, desc->ack_regs[i].set_reg, 0);
683
684 d->chip.mask_ack = intc_mask_ack;
685 }
686#endif
687
688 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */
689
603 for (i = 0; i < desc->nr_vectors; i++) { 690 for (i = 0; i < desc->nr_vectors; i++) {
604 struct intc_vect *vect = desc->vectors + i; 691 struct intc_vect *vect = desc->vectors + i;
605 692
diff --git a/arch/sh/kernel/cpu/sh2a/fpu.c b/arch/sh/kernel/cpu/sh2a/fpu.c
index 5627c0b3ffa8..6df2fb98eb30 100644
--- a/arch/sh/kernel/cpu/sh2a/fpu.c
+++ b/arch/sh/kernel/cpu/sh2a/fpu.c
@@ -300,7 +300,7 @@ static int denormal_addf(int hx, int hy)
300 iy = hy & 0x7fffffff; 300 iy = hy & 0x7fffffff;
301 if (iy < 0x00800000) { 301 if (iy < 0x00800000) {
302 ix = denormal_subf1(ix, iy); 302 ix = denormal_subf1(ix, iy);
303 if (ix < 0) { 303 if ((int) ix < 0) {
304 ix = -ix; 304 ix = -ix;
305 sign ^= 0x80000000; 305 sign ^= 0x80000000;
306 } 306 }
@@ -385,7 +385,7 @@ static long long denormal_addd(long long hx, long long hy)
385 iy = hy & 0x7fffffffffffffffLL; 385 iy = hy & 0x7fffffffffffffffLL;
386 if (iy < 0x0010000000000000LL) { 386 if (iy < 0x0010000000000000LL) {
387 ix = denormal_subd1(ix, iy); 387 ix = denormal_subd1(ix, iy);
388 if (ix < 0) { 388 if ((int) ix < 0) {
389 ix = -ix; 389 ix = -ix;
390 sign ^= 0x8000000000000000LL; 390 sign ^= 0x8000000000000000LL;
391 } 391 }
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
index 3ae4d9111f19..511de55af832 100644
--- a/arch/sh/kernel/cpu/sh3/Makefile
+++ b/arch/sh/kernel/cpu/sh3/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux/SuperH SH-3 backends. 2# Makefile for the Linux/SuperH SH-3 backends.
3# 3#
4 4
5obj-y := ex.o probe.o entry.o 5obj-y := ex.o probe.o entry.o setup-sh3.o
6 6
7# CPU subtype setup 7# CPU subtype setup
8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o 8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh3.c b/arch/sh/kernel/cpu/sh3/setup-sh3.c
new file mode 100644
index 000000000000..c98846857855
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh3.c
@@ -0,0 +1,71 @@
1/*
2 * Shared SH3 Setup code
3 *
4 * Copyright (C) 2008 Magnus Damm
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/init.h>
12#include <linux/irq.h>
13#include <linux/io.h>
14
15/* All SH3 devices are equipped with IRQ0->5 (except sh7708) */
16
17enum {
18 UNUSED = 0,
19
20 /* interrupt sources */
21 IRQ0, IRQ1, IRQ2, IRQ3, IRQ4, IRQ5,
22};
23
24static struct intc_vect vectors_irq0123[] __initdata = {
25 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
26 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
27};
28
29static struct intc_vect vectors_irq45[] __initdata = {
30 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
31};
32
33static struct intc_prio_reg prio_registers[] __initdata = {
34 { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
35 { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
36};
37
38static struct intc_mask_reg ack_registers[] __initdata = {
39 { 0xa4000004, 0, 8, /* IRR0 */
40 { 0, 0, IRQ5, IRQ4, IRQ3, IRQ2, IRQ1, IRQ0 } },
41};
42
43static struct intc_sense_reg sense_registers[] __initdata = {
44 { 0xa4000010, 16, 2, { 0, 0, IRQ5, IRQ4, IRQ3, IRQ2, IRQ1, IRQ0 } },
45};
46
47static DECLARE_INTC_DESC_ACK(intc_desc_irq0123, "sh3-irq0123",
48 vectors_irq0123, NULL, NULL,
49 prio_registers, sense_registers, ack_registers);
50
51static DECLARE_INTC_DESC_ACK(intc_desc_irq45, "sh3-irq45",
52 vectors_irq45, NULL, NULL,
53 prio_registers, sense_registers, ack_registers);
54
55#define INTC_ICR1 0xa4000010UL
56#define INTC_ICR1_IRQLVL (1<<14)
57
58void __init plat_irq_setup_pins(int mode)
59{
60 if (mode == IRQ_MODE_IRQ) {
61 ctrl_outw(ctrl_inw(INTC_ICR1) & ~INTC_ICR1_IRQLVL, INTC_ICR1);
62 register_intc_controller(&intc_desc_irq0123);
63 return;
64 }
65 BUG();
66}
67
68void __init plat_irq_setup_sh3(void)
69{
70 register_intc_controller(&intc_desc_irq45);
71}
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7705.c b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
index f581534cb732..6468ae86b944 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7705.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
@@ -37,7 +37,7 @@ enum {
37}; 37};
38 38
39static struct intc_vect vectors[] __initdata = { 39static struct intc_vect vectors[] __initdata = {
40 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0), 40 /* IRQ0->5 are handled in setup-sh3.c */
41 INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720), 41 INTC_VECT(PINT07, 0x700), INTC_VECT(PINT815, 0x720),
42 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820), 42 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820),
43 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860), 43 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860),
@@ -48,7 +48,7 @@ static struct intc_vect vectors[] __initdata = {
48 INTC_VECT(ADC_ADI, 0x980), 48 INTC_VECT(ADC_ADI, 0x980),
49 INTC_VECT(USB_USI0, 0xa20), INTC_VECT(USB_USI1, 0xa40), 49 INTC_VECT(USB_USI0, 0xa20), INTC_VECT(USB_USI1, 0xa40),
50 INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20), 50 INTC_VECT(TPU0, 0xc00), INTC_VECT(TPU1, 0xc20),
51 INTC_VECT(TPU3, 0xc80), INTC_VECT(TPU1, 0xca0), 51 INTC_VECT(TPU2, 0xc80), INTC_VECT(TPU3, 0xca0),
52 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 52 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
53 INTC_VECT(TMU2_TUNI, 0x440), INTC_VECT(TMU2_TICPI, 0x460), 53 INTC_VECT(TMU2_TUNI, 0x440), INTC_VECT(TMU2_TICPI, 0x460),
54 INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0), 54 INTC_VECT(RTC_ATI, 0x480), INTC_VECT(RTC_PRI, 0x4a0),
@@ -81,14 +81,6 @@ static struct intc_prio_reg prio_registers[] __initdata = {
81static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, groups, 81static DECLARE_INTC_DESC(intc_desc, "sh7705", vectors, groups,
82 NULL, prio_registers, NULL); 82 NULL, prio_registers, NULL);
83 83
84static struct intc_vect vectors_irq[] __initdata = {
85 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
86 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
87};
88
89static DECLARE_INTC_DESC(intc_desc_irq, "sh7705-irq", vectors_irq, NULL,
90 NULL, prio_registers, NULL);
91
92static struct plat_sci_port sci_platform_data[] = { 84static struct plat_sci_port sci_platform_data[] = {
93 { 85 {
94 .mapbase = 0xa4410000, 86 .mapbase = 0xa4410000,
@@ -159,16 +151,8 @@ static int __init sh7705_devices_setup(void)
159} 151}
160__initcall(sh7705_devices_setup); 152__initcall(sh7705_devices_setup);
161 153
162void __init plat_irq_setup_pins(int mode)
163{
164 if (mode == IRQ_MODE_IRQ) {
165 register_intc_controller(&intc_desc_irq);
166 return;
167 }
168 BUG();
169}
170
171void __init plat_irq_setup(void) 154void __init plat_irq_setup(void)
172{ 155{
173 register_intc_controller(&intc_desc); 156 register_intc_controller(&intc_desc);
157 plat_irq_setup_sh3();
174} 158}
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
index d3733b13ea52..93c55e2ed952 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -52,7 +52,7 @@ static struct intc_vect vectors[] __initdata = {
52#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 52#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
53 defined(CONFIG_CPU_SUBTYPE_SH7707) || \ 53 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
54 defined(CONFIG_CPU_SUBTYPE_SH7709) 54 defined(CONFIG_CPU_SUBTYPE_SH7709)
55 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0), 55 /* IRQ0->5 are handled in setup-sh3.c */
56 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820), 56 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820),
57 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860), 57 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860),
58 INTC_VECT(ADC_ADI, 0x980), 58 INTC_VECT(ADC_ADI, 0x980),
@@ -104,18 +104,6 @@ static struct intc_prio_reg prio_registers[] __initdata = {
104static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, groups, 104static DECLARE_INTC_DESC(intc_desc, "sh770x", vectors, groups,
105 NULL, prio_registers, NULL); 105 NULL, prio_registers, NULL);
106 106
107#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
108 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
109 defined(CONFIG_CPU_SUBTYPE_SH7709)
110static struct intc_vect vectors_irq[] __initdata = {
111 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
112 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
113};
114
115static DECLARE_INTC_DESC(intc_desc_irq, "sh770x-irq", vectors_irq, NULL,
116 NULL, prio_registers, NULL);
117#endif
118
119static struct resource rtc_resources[] = { 107static struct resource rtc_resources[] = {
120 [0] = { 108 [0] = {
121 .start = 0xfffffec0, 109 .start = 0xfffffec0,
@@ -194,24 +182,12 @@ static int __init sh770x_devices_setup(void)
194} 182}
195__initcall(sh770x_devices_setup); 183__initcall(sh770x_devices_setup);
196 184
197#define INTC_ICR1 0xa4000010UL 185void __init plat_irq_setup(void)
198#define INTC_ICR1_IRQLVL (1<<14)
199
200void __init plat_irq_setup_pins(int mode)
201{ 186{
202 if (mode == IRQ_MODE_IRQ) { 187 register_intc_controller(&intc_desc);
203#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \ 188#if defined(CONFIG_CPU_SUBTYPE_SH7706) || \
204 defined(CONFIG_CPU_SUBTYPE_SH7707) || \ 189 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
205 defined(CONFIG_CPU_SUBTYPE_SH7709) 190 defined(CONFIG_CPU_SUBTYPE_SH7709)
206 ctrl_outw(ctrl_inw(INTC_ICR1) & ~INTC_ICR1_IRQLVL, INTC_ICR1); 191 plat_irq_setup_sh3();
207 register_intc_controller(&intc_desc_irq);
208 return;
209#endif 192#endif
210 }
211 BUG();
212}
213
214void __init plat_irq_setup(void)
215{
216 register_intc_controller(&intc_desc);
217} 193}
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7710.c b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
index 7406c9ad9259..77eee481de47 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7710.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
@@ -38,7 +38,7 @@ enum {
38}; 38};
39 39
40static struct intc_vect vectors[] __initdata = { 40static struct intc_vect vectors[] __initdata = {
41 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0), 41 /* IRQ0->5 are handled in setup-sh3.c */
42 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820), 42 INTC_VECT(DMAC_DEI0, 0x800), INTC_VECT(DMAC_DEI1, 0x820),
43 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860), 43 INTC_VECT(DMAC_DEI2, 0x840), INTC_VECT(DMAC_DEI3, 0x860),
44 INTC_VECT(SCIF0_ERI, 0x880), INTC_VECT(SCIF0_RXI, 0x8a0), 44 INTC_VECT(SCIF0_ERI, 0x880), INTC_VECT(SCIF0_RXI, 0x8a0),
@@ -79,10 +79,7 @@ static struct intc_prio_reg prio_registers[] __initdata = {
79 { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 79 { 0xa4000016, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
80 { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } }, 80 { 0xa4000018, 0, 16, 4, /* IPRD */ { 0, 0, IRQ5, IRQ4 } },
81 { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } }, 81 { 0xa400001a, 0, 16, 4, /* IPRE */ { DMAC1, SCIF0, SCIF1 } },
82 { 0xa4080000, 0, 16, 4, /* IPRF */ { 0, DMAC2 } }, 82 { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC, DMAC2 } },
83#ifdef CONFIG_CPU_SUBTYPE_SH7710
84 { 0xa4080000, 0, 16, 4, /* IPRF */ { IPSEC } },
85#endif
86 { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } }, 83 { 0xa4080002, 0, 16, 4, /* IPRG */ { EDMAC0, EDMAC1, EDMAC2 } },
87 { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } }, 84 { 0xa4080004, 0, 16, 4, /* IPRH */ { 0, 0, 0, SIOF0 } },
88 { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } }, 85 { 0xa4080006, 0, 16, 4, /* IPRI */ { 0, 0, SIOF1 } },
@@ -91,14 +88,6 @@ static struct intc_prio_reg prio_registers[] __initdata = {
91static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, groups, 88static DECLARE_INTC_DESC(intc_desc, "sh7710", vectors, groups,
92 NULL, prio_registers, NULL); 89 NULL, prio_registers, NULL);
93 90
94static struct intc_vect vectors_irq[] __initdata = {
95 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
96 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
97};
98
99static DECLARE_INTC_DESC(intc_desc_irq, "sh7710-irq", vectors_irq, NULL,
100 NULL, prio_registers, NULL);
101
102static struct resource rtc_resources[] = { 91static struct resource rtc_resources[] = {
103 [0] = { 92 [0] = {
104 .start = 0xa413fec0, 93 .start = 0xa413fec0,
@@ -170,16 +159,8 @@ static int __init sh7710_devices_setup(void)
170} 159}
171__initcall(sh7710_devices_setup); 160__initcall(sh7710_devices_setup);
172 161
173void __init plat_irq_setup_pins(int mode)
174{
175 if (mode == IRQ_MODE_IRQ) {
176 register_intc_controller(&intc_desc_irq);
177 return;
178 }
179 BUG();
180}
181
182void __init plat_irq_setup(void) 162void __init plat_irq_setup(void)
183{ 163{
184 register_intc_controller(&intc_desc); 164 register_intc_controller(&intc_desc);
165 plat_irq_setup_sh3();
185} 166}
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
index 8028082527c5..f807a21b066c 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
@@ -19,10 +19,6 @@
19#include <linux/serial_sci.h> 19#include <linux/serial_sci.h>
20#include <asm/rtc.h> 20#include <asm/rtc.h>
21 21
22#define INTC_ICR1 0xA4140010UL
23#define INTC_ICR_IRLM 0x4000
24#define INTC_ICR_IRQ (~INTC_ICR_IRLM)
25
26static struct resource rtc_resources[] = { 22static struct resource rtc_resources[] = {
27 [0] = { 23 [0] = {
28 .start = 0xa413fec0, 24 .start = 0xa413fec0,
@@ -170,6 +166,7 @@ enum {
170}; 166};
171 167
172static struct intc_vect vectors[] __initdata = { 168static struct intc_vect vectors[] __initdata = {
169 /* IRQ0->5 are handled in setup-sh3.c */
173 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420), 170 INTC_VECT(TMU0, 0x400), INTC_VECT(TMU1, 0x420),
174 INTC_VECT(TMU2, 0x440), INTC_VECT(RTC_ATI, 0x480), 171 INTC_VECT(TMU2, 0x440), INTC_VECT(RTC_ATI, 0x480),
175 INTC_VECT(RTC_PRI, 0x4a0), INTC_VECT(RTC_CUI, 0x4c0), 172 INTC_VECT(RTC_PRI, 0x4a0), INTC_VECT(RTC_CUI, 0x4c0),
@@ -214,11 +211,7 @@ static struct intc_prio_reg prio_registers[] __initdata = {
214 { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } }, 211 { 0xA414FEE4UL, 0, 16, 4, /* IPRB */ { WDT, REF_RCMI, SIM, 0 } },
215 { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } }, 212 { 0xA4140016UL, 0, 16, 4, /* IPRC */ { IRQ3, IRQ2, IRQ1, IRQ0 } },
216 { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } }, 213 { 0xA4140018UL, 0, 16, 4, /* IPRD */ { USBF_SPD, TMU_SUNI, IRQ5, IRQ4 } },
217#if defined(CONFIG_CPU_SUBTYPE_SH7720)
218 { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } }, 214 { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, SSL } },
219#else
220 { 0xA414001AUL, 0, 16, 4, /* IPRE */ { DMAC1, 0, LCDC, 0 } },
221#endif
222 { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } }, 215 { 0xA4080000UL, 0, 16, 4, /* IPRF */ { ADC, DMAC2, USBFI, CMT } },
223 { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } }, 216 { 0xA4080002UL, 0, 16, 4, /* IPRG */ { SCIF0, SCIF1, 0, 0 } },
224 { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } }, 217 { 0xA4080004UL, 0, 16, 4, /* IPRH */ { PINT07, PINT815, TPU, IIC } },
@@ -229,32 +222,8 @@ static struct intc_prio_reg prio_registers[] __initdata = {
229static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, groups, 222static DECLARE_INTC_DESC(intc_desc, "sh7720", vectors, groups,
230 NULL, prio_registers, NULL); 223 NULL, prio_registers, NULL);
231 224
232static struct intc_sense_reg sense_registers[] __initdata = {
233 { INTC_ICR1, 16, 2, { 0, 0, IRQ5, IRQ4, IRQ3, IRQ2, IRQ1, IRQ0 } },
234};
235
236static struct intc_vect vectors_irq[] __initdata = {
237 INTC_VECT(IRQ0, 0x600), INTC_VECT(IRQ1, 0x620),
238 INTC_VECT(IRQ2, 0x640), INTC_VECT(IRQ3, 0x660),
239 INTC_VECT(IRQ4, 0x680), INTC_VECT(IRQ5, 0x6a0),
240};
241
242static DECLARE_INTC_DESC(intc_irq_desc, "sh7720-irq", vectors_irq,
243 NULL, NULL, prio_registers, sense_registers);
244
245void __init plat_irq_setup_pins(int mode)
246{
247 switch (mode) {
248 case IRQ_MODE_IRQ:
249 ctrl_outw(ctrl_inw(INTC_ICR1) & INTC_ICR_IRQ, INTC_ICR1);
250 register_intc_controller(&intc_irq_desc);
251 break;
252 default:
253 BUG();
254 }
255}
256
257void __init plat_irq_setup(void) 225void __init plat_irq_setup(void)
258{ 226{
259 register_intc_controller(&intc_desc); 227 register_intc_controller(&intc_desc);
228 plat_irq_setup_sh3();
260} 229}
diff --git a/arch/sh/kernel/cpu/sh5/entry.S b/arch/sh/kernel/cpu/sh5/entry.S
index ba8750176d91..05372ed6c568 100644
--- a/arch/sh/kernel/cpu/sh5/entry.S
+++ b/arch/sh/kernel/cpu/sh5/entry.S
@@ -143,12 +143,22 @@ resvec_save_area:
143trap_jtable: 143trap_jtable:
144 .long do_exception_error /* 0x000 */ 144 .long do_exception_error /* 0x000 */
145 .long do_exception_error /* 0x020 */ 145 .long do_exception_error /* 0x020 */
146#ifdef CONFIG_MMU
146 .long tlb_miss_load /* 0x040 */ 147 .long tlb_miss_load /* 0x040 */
147 .long tlb_miss_store /* 0x060 */ 148 .long tlb_miss_store /* 0x060 */
149#else
150 .long do_exception_error
151 .long do_exception_error
152#endif
148 ! ARTIFICIAL pseudo-EXPEVT setting 153 ! ARTIFICIAL pseudo-EXPEVT setting
149 .long do_debug_interrupt /* 0x080 */ 154 .long do_debug_interrupt /* 0x080 */
155#ifdef CONFIG_MMU
150 .long tlb_miss_load /* 0x0A0 */ 156 .long tlb_miss_load /* 0x0A0 */
151 .long tlb_miss_store /* 0x0C0 */ 157 .long tlb_miss_store /* 0x0C0 */
158#else
159 .long do_exception_error
160 .long do_exception_error
161#endif
152 .long do_address_error_load /* 0x0E0 */ 162 .long do_address_error_load /* 0x0E0 */
153 .long do_address_error_store /* 0x100 */ 163 .long do_address_error_store /* 0x100 */
154#ifdef CONFIG_SH_FPU 164#ifdef CONFIG_SH_FPU
@@ -185,10 +195,18 @@ trap_jtable:
185 .endr 195 .endr
186 .long do_IRQ /* 0xA00 */ 196 .long do_IRQ /* 0xA00 */
187 .long do_IRQ /* 0xA20 */ 197 .long do_IRQ /* 0xA20 */
198#ifdef CONFIG_MMU
188 .long itlb_miss_or_IRQ /* 0xA40 */ 199 .long itlb_miss_or_IRQ /* 0xA40 */
200#else
201 .long do_IRQ
202#endif
189 .long do_IRQ /* 0xA60 */ 203 .long do_IRQ /* 0xA60 */
190 .long do_IRQ /* 0xA80 */ 204 .long do_IRQ /* 0xA80 */
205#ifdef CONFIG_MMU
191 .long itlb_miss_or_IRQ /* 0xAA0 */ 206 .long itlb_miss_or_IRQ /* 0xAA0 */
207#else
208 .long do_IRQ
209#endif
192 .long do_exception_error /* 0xAC0 */ 210 .long do_exception_error /* 0xAC0 */
193 .long do_address_error_exec /* 0xAE0 */ 211 .long do_address_error_exec /* 0xAE0 */
194 .rept 8 212 .rept 8
@@ -274,6 +292,7 @@ not_a_tlb_miss:
274 * Instead of '.space 1024-TEXT_SIZE' place the RESVEC 292 * Instead of '.space 1024-TEXT_SIZE' place the RESVEC
275 * block making sure the final alignment is correct. 293 * block making sure the final alignment is correct.
276 */ 294 */
295#ifdef CONFIG_MMU
277tlb_miss: 296tlb_miss:
278 synco /* TAKum03020 (but probably a good idea anyway.) */ 297 synco /* TAKum03020 (but probably a good idea anyway.) */
279 putcon SP, KCR1 298 putcon SP, KCR1
@@ -377,6 +396,9 @@ fixup_to_invoke_general_handler:
377 getcon KCR1, SP 396 getcon KCR1, SP
378 pta handle_exception, tr0 397 pta handle_exception, tr0
379 blink tr0, ZERO 398 blink tr0, ZERO
399#else /* CONFIG_MMU */
400 .balign 256
401#endif
380 402
381/* NB TAKE GREAT CARE HERE TO ENSURE THAT THE INTERRUPT CODE 403/* NB TAKE GREAT CARE HERE TO ENSURE THAT THE INTERRUPT CODE
382 DOES END UP AT VBR+0x600 */ 404 DOES END UP AT VBR+0x600 */
@@ -1103,6 +1125,7 @@ restore_all:
1103 * fpu_error_or_IRQ? is a helper to deflect to the right cause. 1125 * fpu_error_or_IRQ? is a helper to deflect to the right cause.
1104 * 1126 *
1105 */ 1127 */
1128#ifdef CONFIG_MMU
1106tlb_miss_load: 1129tlb_miss_load:
1107 or SP, ZERO, r2 1130 or SP, ZERO, r2
1108 or ZERO, ZERO, r3 /* Read */ 1131 or ZERO, ZERO, r3 /* Read */
@@ -1132,6 +1155,7 @@ call_do_page_fault:
1132 movi do_page_fault, r6 1155 movi do_page_fault, r6
1133 ptabs r6, tr0 1156 ptabs r6, tr0
1134 blink tr0, ZERO 1157 blink tr0, ZERO
1158#endif /* CONFIG_MMU */
1135 1159
1136fpu_error_or_IRQA: 1160fpu_error_or_IRQA:
1137 pta its_IRQ, tr0 1161 pta its_IRQ, tr0
@@ -1481,6 +1505,7 @@ poke_real_address_q:
1481 ptabs LINK, tr0 1505 ptabs LINK, tr0
1482 blink tr0, r63 1506 blink tr0, r63
1483 1507
1508#ifdef CONFIG_MMU
1484/* 1509/*
1485 * --- User Access Handling Section 1510 * --- User Access Handling Section
1486 */ 1511 */
@@ -1604,6 +1629,7 @@ ___clear_user_exit:
1604 ptabs LINK, tr0 1629 ptabs LINK, tr0
1605 blink tr0, ZERO 1630 blink tr0, ZERO
1606 1631
1632#endif /* CONFIG_MMU */
1607 1633
1608/* 1634/*
1609 * int __strncpy_from_user(unsigned long __dest, unsigned long __src, 1635 * int __strncpy_from_user(unsigned long __dest, unsigned long __src,
@@ -2014,9 +2040,11 @@ sa_default_restorer:
2014 .global asm_uaccess_start /* Just a marker */ 2040 .global asm_uaccess_start /* Just a marker */
2015asm_uaccess_start: 2041asm_uaccess_start:
2016 2042
2043#ifdef CONFIG_MMU
2017 .long ___copy_user1, ___copy_user_exit 2044 .long ___copy_user1, ___copy_user_exit
2018 .long ___copy_user2, ___copy_user_exit 2045 .long ___copy_user2, ___copy_user_exit
2019 .long ___clear_user1, ___clear_user_exit 2046 .long ___clear_user1, ___clear_user_exit
2047#endif
2020 .long ___strncpy_from_user1, ___strncpy_from_user_exit 2048 .long ___strncpy_from_user1, ___strncpy_from_user_exit
2021 .long ___strnlen_user1, ___strnlen_user_exit 2049 .long ___strnlen_user1, ___strnlen_user_exit
2022 .long ___get_user_asm_b1, ___get_user_asm_b_exit 2050 .long ___get_user_asm_b1, ___get_user_asm_b_exit
diff --git a/arch/sh/kernel/cpu/sh5/probe.c b/arch/sh/kernel/cpu/sh5/probe.c
index 31f8cb0f6374..92ad844b5c12 100644
--- a/arch/sh/kernel/cpu/sh5/probe.c
+++ b/arch/sh/kernel/cpu/sh5/probe.c
@@ -15,6 +15,7 @@
15#include <linux/string.h> 15#include <linux/string.h>
16#include <asm/processor.h> 16#include <asm/processor.h>
17#include <asm/cache.h> 17#include <asm/cache.h>
18#include <asm/tlb.h>
18 19
19int __init detect_cpu_and_cache_system(void) 20int __init detect_cpu_and_cache_system(void)
20{ 21{
@@ -67,5 +68,8 @@ int __init detect_cpu_and_cache_system(void)
67 set_bit(SH_CACHE_MODE_WB, &(boot_cpu_data.dcache.flags)); 68 set_bit(SH_CACHE_MODE_WB, &(boot_cpu_data.dcache.flags));
68#endif 69#endif
69 70
71 /* Setup some I/D TLB defaults */
72 sh64_tlb_init();
73
70 return 0; 74 return 0;
71} 75}
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
index 957f25611543..6b7d166694e2 100644
--- a/arch/sh/kernel/early_printk.c
+++ b/arch/sh/kernel/early_printk.c
@@ -141,7 +141,9 @@ static void scif_sercon_init(char *s)
141 */ 141 */
142static void scif_sercon_init(char *s) 142static void scif_sercon_init(char *s)
143{ 143{
144 struct uart_port *port = &scif_port;
144 unsigned baud = DEFAULT_BAUD; 145 unsigned baud = DEFAULT_BAUD;
146 unsigned int status;
145 char *e; 147 char *e;
146 148
147 if (*s == ',') 149 if (*s == ',')
@@ -160,19 +162,25 @@ static void scif_sercon_init(char *s)
160 baud = DEFAULT_BAUD; 162 baud = DEFAULT_BAUD;
161 } 163 }
162 164
163 ctrl_outw(0, scif_port.mapbase + 8); 165 do {
164 ctrl_outw(0, scif_port.mapbase); 166 status = sci_in(port, SCxSR);
167 } while (!(status & SCxSR_TEND(port)));
168
169 sci_out(port, SCSCR, 0); /* TE=0, RE=0 */
170 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
171 sci_out(port, SCSMR, 0);
165 172
166 /* Set baud rate */ 173 /* Set baud rate */
167 ctrl_outb((CONFIG_SH_PCLK_FREQ + 16 * baud) / 174 sci_out(port, SCBRR, (CONFIG_SH_PCLK_FREQ + 16 * baud) /
168 (32 * baud) - 1, scif_port.mapbase + 4); 175 (32 * baud) - 1);
169 176 udelay((1000000+(baud-1)) / baud); /* Wait one bit interval */
170 ctrl_outw(12, scif_port.mapbase + 24); 177
171 ctrl_outw(8, scif_port.mapbase + 24); 178 sci_out(port, SCSPTR, 0);
172 ctrl_outw(0, scif_port.mapbase + 32); 179 sci_out(port, SCxSR, 0x60);
173 ctrl_outw(0x60, scif_port.mapbase + 16); 180 sci_out(port, SCLSR, 0);
174 ctrl_outw(0, scif_port.mapbase + 36); 181
175 ctrl_outw(0x30, scif_port.mapbase + 8); 182 sci_out(port, SCFCR, 0);
183 sci_out(port, SCSCR, 0x30); /* TE=1, RE=1 */
176} 184}
177#endif /* defined(CONFIG_CPU_SUBTYPE_SH7720) */ 185#endif /* defined(CONFIG_CPU_SUBTYPE_SH7720) */
178#endif /* !defined(CONFIG_SH_STANDARD_BIOS) */ 186#endif /* !defined(CONFIG_SH_STANDARD_BIOS) */
diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c
index d453c3a1c79f..832641bbd47d 100644
--- a/arch/sh/kernel/kgdb_stub.c
+++ b/arch/sh/kernel/kgdb_stub.c
@@ -330,14 +330,6 @@ static char *ebin_to_mem(const char *buf, char *mem, int count)
330 return mem; 330 return mem;
331} 331}
332 332
333/* Pack a hex byte */
334static char *pack_hex_byte(char *pkt, int byte)
335{
336 *pkt++ = hexchars[(byte >> 4) & 0xf];
337 *pkt++ = hexchars[(byte & 0xf)];
338 return pkt;
339}
340
341/* Scan for the start char '$', read the packet and check the checksum */ 333/* Scan for the start char '$', read the packet and check the checksum */
342static void get_packet(char *buffer, int buflen) 334static void get_packet(char *buffer, int buflen)
343{ 335{
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 284f66f1ebbe..516bde9c50fa 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -53,6 +53,7 @@ EXPORT_SYMBOL(cpu_data);
53 * sh_mv= on the command line, prior to .machvec.init teardown. 53 * sh_mv= on the command line, prior to .machvec.init teardown.
54 */ 54 */
55struct sh_machine_vector sh_mv = { .mv_name = "generic", }; 55struct sh_machine_vector sh_mv = { .mv_name = "generic", };
56EXPORT_SYMBOL(sh_mv);
56 57
57#ifdef CONFIG_VT 58#ifdef CONFIG_VT
58struct screen_info screen_info; 59struct screen_info screen_info;
@@ -76,11 +77,18 @@ static struct resource data_resource = {
76 .flags = IORESOURCE_BUSY | IORESOURCE_MEM, 77 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
77}; 78};
78 79
80static struct resource bss_resource = {
81 .name = "Kernel bss",
82 .flags = IORESOURCE_BUSY | IORESOURCE_MEM,
83};
84
79unsigned long memory_start; 85unsigned long memory_start;
80EXPORT_SYMBOL(memory_start); 86EXPORT_SYMBOL(memory_start);
81unsigned long memory_end = 0; 87unsigned long memory_end = 0;
82EXPORT_SYMBOL(memory_end); 88EXPORT_SYMBOL(memory_end);
83 89
90static struct resource mem_resources[MAX_NUMNODES];
91
84int l1i_cache_shape, l1d_cache_shape, l2_cache_shape; 92int l1i_cache_shape, l1d_cache_shape, l2_cache_shape;
85 93
86static int __init early_parse_mem(char *p) 94static int __init early_parse_mem(char *p)
@@ -169,6 +177,40 @@ static inline void __init reserve_crashkernel(void)
169{} 177{}
170#endif 178#endif
171 179
180void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
181 unsigned long end_pfn)
182{
183 struct resource *res = &mem_resources[nid];
184
185 WARN_ON(res->name); /* max one active range per node for now */
186
187 res->name = "System RAM";
188 res->start = start_pfn << PAGE_SHIFT;
189 res->end = (end_pfn << PAGE_SHIFT) - 1;
190 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
191 if (request_resource(&iomem_resource, res)) {
192 pr_err("unable to request memory_resource 0x%lx 0x%lx\n",
193 start_pfn, end_pfn);
194 return;
195 }
196
197 /*
198 * We don't know which RAM region contains kernel data,
199 * so we try it repeatedly and let the resource manager
200 * test it.
201 */
202 request_resource(res, &code_resource);
203 request_resource(res, &data_resource);
204 request_resource(res, &bss_resource);
205
206#ifdef CONFIG_KEXEC
207 if (crashk_res.start != crashk_res.end)
208 request_resource(res, &crashk_res);
209#endif
210
211 add_active_range(nid, start_pfn, end_pfn);
212}
213
172void __init setup_bootmem_allocator(unsigned long free_pfn) 214void __init setup_bootmem_allocator(unsigned long free_pfn)
173{ 215{
174 unsigned long bootmap_size; 216 unsigned long bootmap_size;
@@ -181,7 +223,7 @@ void __init setup_bootmem_allocator(unsigned long free_pfn)
181 bootmap_size = init_bootmem_node(NODE_DATA(0), free_pfn, 223 bootmap_size = init_bootmem_node(NODE_DATA(0), free_pfn,
182 min_low_pfn, max_low_pfn); 224 min_low_pfn, max_low_pfn);
183 225
184 add_active_range(0, min_low_pfn, max_low_pfn); 226 __add_active_range(0, min_low_pfn, max_low_pfn);
185 register_bootmem_low_pages(); 227 register_bootmem_low_pages();
186 228
187 node_set_online(0); 229 node_set_online(0);
@@ -267,6 +309,8 @@ void __init setup_arch(char **cmdline_p)
267 code_resource.end = virt_to_phys(_etext)-1; 309 code_resource.end = virt_to_phys(_etext)-1;
268 data_resource.start = virt_to_phys(_etext); 310 data_resource.start = virt_to_phys(_etext);
269 data_resource.end = virt_to_phys(_edata)-1; 311 data_resource.end = virt_to_phys(_edata)-1;
312 bss_resource.start = virt_to_phys(__bss_start);
313 bss_resource.end = virt_to_phys(_ebss)-1;
270 314
271 memory_start = (unsigned long)__va(__MEMORY_START); 315 memory_start = (unsigned long)__va(__MEMORY_START);
272 if (!memory_end) 316 if (!memory_end)
diff --git a/arch/sh/kernel/sh_ksyms_32.c b/arch/sh/kernel/sh_ksyms_32.c
index 6d405462cee8..8f916536719c 100644
--- a/arch/sh/kernel/sh_ksyms_32.c
+++ b/arch/sh/kernel/sh_ksyms_32.c
@@ -20,8 +20,6 @@
20extern int dump_fpu(struct pt_regs *, elf_fpregset_t *); 20extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
21extern struct hw_interrupt_type no_irq_type; 21extern struct hw_interrupt_type no_irq_type;
22 22
23EXPORT_SYMBOL(sh_mv);
24
25/* platform dependent support */ 23/* platform dependent support */
26EXPORT_SYMBOL(dump_fpu); 24EXPORT_SYMBOL(dump_fpu);
27EXPORT_SYMBOL(kernel_thread); 25EXPORT_SYMBOL(kernel_thread);
diff --git a/arch/sh/kernel/sh_ksyms_64.c b/arch/sh/kernel/sh_ksyms_64.c
index a310c9707f03..9324d32adacc 100644
--- a/arch/sh/kernel/sh_ksyms_64.c
+++ b/arch/sh/kernel/sh_ksyms_64.c
@@ -16,6 +16,7 @@
16#include <linux/in6.h> 16#include <linux/in6.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/screen_info.h> 18#include <linux/screen_info.h>
19#include <asm/cacheflush.h>
19#include <asm/processor.h> 20#include <asm/processor.h>
20#include <asm/uaccess.h> 21#include <asm/uaccess.h>
21#include <asm/checksum.h> 22#include <asm/checksum.h>
@@ -29,25 +30,50 @@ extern int dump_fpu(struct pt_regs *, elf_fpregset_t *);
29EXPORT_SYMBOL(dump_fpu); 30EXPORT_SYMBOL(dump_fpu);
30EXPORT_SYMBOL(kernel_thread); 31EXPORT_SYMBOL(kernel_thread);
31 32
33#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU)
34EXPORT_SYMBOL(clear_user_page);
35#endif
36
37#ifndef CONFIG_CACHE_OFF
38EXPORT_SYMBOL(flush_dcache_page);
39#endif
40
32/* Networking helper routines. */ 41/* Networking helper routines. */
42EXPORT_SYMBOL(csum_partial);
33EXPORT_SYMBOL(csum_partial_copy_nocheck); 43EXPORT_SYMBOL(csum_partial_copy_nocheck);
44#ifdef CONFIG_IPV6
45EXPORT_SYMBOL(csum_ipv6_magic);
46#endif
34 47
35#ifdef CONFIG_VT 48#ifdef CONFIG_VT
36EXPORT_SYMBOL(screen_info); 49EXPORT_SYMBOL(screen_info);
37#endif 50#endif
38 51
52EXPORT_SYMBOL(__put_user_asm_b);
53EXPORT_SYMBOL(__put_user_asm_w);
39EXPORT_SYMBOL(__put_user_asm_l); 54EXPORT_SYMBOL(__put_user_asm_l);
55EXPORT_SYMBOL(__put_user_asm_q);
56EXPORT_SYMBOL(__get_user_asm_b);
57EXPORT_SYMBOL(__get_user_asm_w);
40EXPORT_SYMBOL(__get_user_asm_l); 58EXPORT_SYMBOL(__get_user_asm_l);
59EXPORT_SYMBOL(__get_user_asm_q);
60EXPORT_SYMBOL(__strnlen_user);
61EXPORT_SYMBOL(__strncpy_from_user);
62EXPORT_SYMBOL(clear_page);
63EXPORT_SYMBOL(__clear_user);
41EXPORT_SYMBOL(copy_page); 64EXPORT_SYMBOL(copy_page);
42EXPORT_SYMBOL(__copy_user); 65EXPORT_SYMBOL(__copy_user);
43EXPORT_SYMBOL(empty_zero_page); 66EXPORT_SYMBOL(empty_zero_page);
44EXPORT_SYMBOL(memcpy); 67EXPORT_SYMBOL(memcpy);
45EXPORT_SYMBOL(__udelay); 68EXPORT_SYMBOL(__udelay);
46EXPORT_SYMBOL(__ndelay); 69EXPORT_SYMBOL(__ndelay);
70EXPORT_SYMBOL(__const_udelay);
47 71
48/* Ugh. These come in from libgcc.a at link time. */ 72/* Ugh. These come in from libgcc.a at link time. */
49#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name) 73#define DECLARE_EXPORT(name) extern void name(void);EXPORT_SYMBOL(name)
50 74
51DECLARE_EXPORT(__sdivsi3); 75DECLARE_EXPORT(__sdivsi3);
76DECLARE_EXPORT(__sdivsi3_2);
52DECLARE_EXPORT(__muldi3); 77DECLARE_EXPORT(__muldi3);
53DECLARE_EXPORT(__udivsi3); 78DECLARE_EXPORT(__udivsi3);
79DECLARE_EXPORT(__div_table);
diff --git a/arch/sh/kernel/time_64.c b/arch/sh/kernel/time_64.c
index 898977ee2030..022a55f1c1d4 100644
--- a/arch/sh/kernel/time_64.c
+++ b/arch/sh/kernel/time_64.c
@@ -172,6 +172,7 @@ void do_gettimeofday(struct timeval *tv)
172 tv->tv_sec = sec; 172 tv->tv_sec = sec;
173 tv->tv_usec = usec; 173 tv->tv_usec = usec;
174} 174}
175EXPORT_SYMBOL(do_gettimeofday);
175 176
176int do_settimeofday(struct timespec *tv) 177int do_settimeofday(struct timespec *tv)
177{ 178{
@@ -240,7 +241,7 @@ static inline void do_timer_interrupt(void)
240 * the irq version of write_lock because as just said we have irq 241 * the irq version of write_lock because as just said we have irq
241 * locally disabled. -arca 242 * locally disabled. -arca
242 */ 243 */
243 write_lock(&xtime_lock); 244 write_seqlock(&xtime_lock);
244 asm ("getcon cr62, %0" : "=r" (current_ctc)); 245 asm ("getcon cr62, %0" : "=r" (current_ctc));
245 ctc_last_interrupt = (unsigned long) current_ctc; 246 ctc_last_interrupt = (unsigned long) current_ctc;
246 247
@@ -266,7 +267,7 @@ static inline void do_timer_interrupt(void)
266 /* do it again in 60 s */ 267 /* do it again in 60 s */
267 last_rtc_update = xtime.tv_sec - 600; 268 last_rtc_update = xtime.tv_sec - 600;
268 } 269 }
269 write_unlock(&xtime_lock); 270 write_sequnlock(&xtime_lock);
270 271
271#ifndef CONFIG_SMP 272#ifndef CONFIG_SMP
272 update_process_times(user_mode(get_irq_regs())); 273 update_process_times(user_mode(get_irq_regs()));
diff --git a/arch/sh/lib64/dbg.c b/arch/sh/lib64/dbg.c
index 75825ef6e084..2fb8eaf6de60 100644
--- a/arch/sh/lib64/dbg.c
+++ b/arch/sh/lib64/dbg.c
@@ -186,8 +186,8 @@ void evt_debug(int evt, int ret_addr, int event, int tra, struct pt_regs *regs)
186 rr->pc = regs->pc; 186 rr->pc = regs->pc;
187 187
188 if (sp < stack_bottom + 3092) { 188 if (sp < stack_bottom + 3092) {
189 printk("evt_debug : stack underflow report\n");
190 int i, j; 189 int i, j;
190 printk("evt_debug : stack underflow report\n");
191 for (j=0, i = event_ptr; j<16; j++) { 191 for (j=0, i = event_ptr; j<16; j++) {
192 rr = event_ring + i; 192 rr = event_ring + i;
193 printk("evt=%08x event=%08x tra=%08x pid=%5d sp=%08lx pc=%08lx\n", 193 printk("evt=%08x event=%08x tra=%08x pid=%5d sp=%08lx pc=%08lx\n",
diff --git a/arch/sh/mm/Makefile_64 b/arch/sh/mm/Makefile_64
index cbd6aa33c5ac..0d92a8a3ac9a 100644
--- a/arch/sh/mm/Makefile_64
+++ b/arch/sh/mm/Makefile_64
@@ -2,10 +2,11 @@
2# Makefile for the Linux SuperH-specific parts of the memory manager. 2# Makefile for the Linux SuperH-specific parts of the memory manager.
3# 3#
4 4
5obj-y := init.o extable_64.o consistent.o 5obj-y := init.o consistent.o
6 6
7mmu-y := tlb-nommu.o pg-nommu.o 7mmu-y := tlb-nommu.o pg-nommu.o extable_32.o
8mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o 8mmu-$(CONFIG_MMU) := fault_64.o ioremap_64.o tlbflush_64.o tlb-sh5.o \
9 extable_64.o
9 10
10ifndef CONFIG_CACHE_OFF 11ifndef CONFIG_CACHE_OFF
11obj-y += cache-sh5.o 12obj-y += cache-sh5.o
diff --git a/arch/sh/mm/cache-sh5.c b/arch/sh/mm/cache-sh5.c
index 3877321fcede..9e277ec7d536 100644
--- a/arch/sh/mm/cache-sh5.c
+++ b/arch/sh/mm/cache-sh5.c
@@ -714,6 +714,7 @@ void flush_cache_sigtramp(unsigned long vaddr)
714 sh64_icache_inv_current_user_range(vaddr, end); 714 sh64_icache_inv_current_user_range(vaddr, end);
715} 715}
716 716
717#ifdef CONFIG_MMU
717/* 718/*
718 * These *MUST* lie in an area of virtual address space that's otherwise 719 * These *MUST* lie in an area of virtual address space that's otherwise
719 * unused. 720 * unused.
@@ -830,3 +831,4 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
830 else 831 else
831 sh64_clear_user_page_coloured(to, address); 832 sh64_clear_user_page_coloured(to, address);
832} 833}
834#endif
diff --git a/arch/sh/mm/ioremap_64.c b/arch/sh/mm/ioremap_64.c
index cea224c3e49b..6e0be24d26e2 100644
--- a/arch/sh/mm/ioremap_64.c
+++ b/arch/sh/mm/ioremap_64.c
@@ -343,6 +343,7 @@ unsigned long onchip_remap(unsigned long phys, unsigned long size, const char *n
343 343
344 return shmedia_alloc_io(phys, size, name); 344 return shmedia_alloc_io(phys, size, name);
345} 345}
346EXPORT_SYMBOL(onchip_remap);
346 347
347void onchip_unmap(unsigned long vaddr) 348void onchip_unmap(unsigned long vaddr)
348{ 349{
@@ -370,6 +371,7 @@ void onchip_unmap(unsigned long vaddr)
370 kfree(res); 371 kfree(res);
371 } 372 }
372} 373}
374EXPORT_SYMBOL(onchip_unmap);
373 375
374#ifdef CONFIG_PROC_FS 376#ifdef CONFIG_PROC_FS
375static int 377static int
diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c
index 2de7302724fc..1663199ce888 100644
--- a/arch/sh/mm/numa.c
+++ b/arch/sh/mm/numa.c
@@ -59,7 +59,7 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
59 free_pfn = start_pfn = start >> PAGE_SHIFT; 59 free_pfn = start_pfn = start >> PAGE_SHIFT;
60 end_pfn = end >> PAGE_SHIFT; 60 end_pfn = end >> PAGE_SHIFT;
61 61
62 add_active_range(nid, start_pfn, end_pfn); 62 __add_active_range(nid, start_pfn, end_pfn);
63 63
64 /* Node-local pgdat */ 64 /* Node-local pgdat */
65 NODE_DATA(nid) = pfn_to_kaddr(free_pfn); 65 NODE_DATA(nid) = pfn_to_kaddr(free_pfn);
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index 987c6682bf99..1bba7d36be90 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -28,7 +28,6 @@ HD64465 HD64465
287751SYSTEMH SH_7751_SYSTEMH 287751SYSTEMH SH_7751_SYSTEMH
29HP6XX SH_HP6XX 29HP6XX SH_HP6XX
30DREAMCAST SH_DREAMCAST 30DREAMCAST SH_DREAMCAST
31MPC1211 SH_MPC1211
32SNAPGEAR SH_SECUREEDGE5410 31SNAPGEAR SH_SECUREEDGE5410
33EDOSK7705 SH_EDOSK7705 32EDOSK7705 SH_EDOSK7705
34SH4202_MICRODEV SH_SH4202_MICRODEV 33SH4202_MICRODEV SH_SH4202_MICRODEV
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 57d1bbdd0bd2..4bcfe54f878d 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -1306,6 +1306,8 @@ ret_from_fork:
1306 .align 4 1306 .align 4
1307 .globl linux_sparc_syscall 1307 .globl linux_sparc_syscall
1308linux_sparc_syscall: 1308linux_sparc_syscall:
1309 sethi %hi(PSR_SYSCALL), %l4
1310 or %l0, %l4, %l0
1309 /* Direct access to user regs, must faster. */ 1311 /* Direct access to user regs, must faster. */
1310 cmp %g1, NR_SYSCALLS 1312 cmp %g1, NR_SYSCALLS
1311 bgeu linux_sparc_ni_syscall 1313 bgeu linux_sparc_ni_syscall
diff --git a/arch/sparc/kernel/process.c b/arch/sparc/kernel/process.c
index e7f35198ae34..da48d248cc17 100644
--- a/arch/sparc/kernel/process.c
+++ b/arch/sparc/kernel/process.c
@@ -419,14 +419,26 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags,
419 unsigned long stack_size) 419 unsigned long stack_size)
420{ 420{
421 unsigned long parent_tid_ptr, child_tid_ptr; 421 unsigned long parent_tid_ptr, child_tid_ptr;
422 unsigned long orig_i1 = regs->u_regs[UREG_I1];
423 long ret;
422 424
423 parent_tid_ptr = regs->u_regs[UREG_I2]; 425 parent_tid_ptr = regs->u_regs[UREG_I2];
424 child_tid_ptr = regs->u_regs[UREG_I4]; 426 child_tid_ptr = regs->u_regs[UREG_I4];
425 427
426 return do_fork(clone_flags, stack_start, 428 ret = do_fork(clone_flags, stack_start,
427 regs, stack_size, 429 regs, stack_size,
428 (int __user *) parent_tid_ptr, 430 (int __user *) parent_tid_ptr,
429 (int __user *) child_tid_ptr); 431 (int __user *) child_tid_ptr);
432
433 /* If we get an error and potentially restart the system
434 * call, we're screwed because copy_thread() clobbered
435 * the parent's %o1. So detect that case and restore it
436 * here.
437 */
438 if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
439 regs->u_regs[UREG_I1] = orig_i1;
440
441 return ret;
430} 442}
431 443
432/* Copy a Sparc thread. The fork() return value conventions 444/* Copy a Sparc thread. The fork() return value conventions
@@ -626,11 +638,6 @@ asmlinkage int sparc_execve(struct pt_regs *regs)
626 (char __user * __user *)regs->u_regs[base + UREG_I2], 638 (char __user * __user *)regs->u_regs[base + UREG_I2],
627 regs); 639 regs);
628 putname(filename); 640 putname(filename);
629 if (error == 0) {
630 task_lock(current);
631 current->ptrace &= ~PT_DTRACE;
632 task_unlock(current);
633 }
634out: 641out:
635 return error; 642 return error;
636} 643}
diff --git a/arch/sparc/kernel/ptrace.c b/arch/sparc/kernel/ptrace.c
index 7f44ae69b29e..81f3b929743f 100644
--- a/arch/sparc/kernel/ptrace.c
+++ b/arch/sparc/kernel/ptrace.c
@@ -170,8 +170,8 @@ static int genregs32_set(struct task_struct *target,
170 switch (pos) { 170 switch (pos) {
171 case 32: /* PSR */ 171 case 32: /* PSR */
172 psr = regs->psr; 172 psr = regs->psr;
173 psr &= ~PSR_ICC; 173 psr &= ~(PSR_ICC | PSR_SYSCALL);
174 psr |= (reg & PSR_ICC); 174 psr |= (reg & (PSR_ICC | PSR_SYSCALL));
175 regs->psr = psr; 175 regs->psr = psr;
176 break; 176 break;
177 case 33: /* PC */ 177 case 33: /* PC */
@@ -441,6 +441,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
441 break; 441 break;
442 442
443 default: 443 default:
444 if (request == PTRACE_SPARC_DETACH)
445 request = PTRACE_DETACH;
444 ret = ptrace_request(child, request, addr, data); 446 ret = ptrace_request(child, request, addr, data);
445 break; 447 break;
446 } 448 }
diff --git a/arch/sparc/kernel/rtrap.S b/arch/sparc/kernel/rtrap.S
index 77ca6fd81253..ab818cdc4cc0 100644
--- a/arch/sparc/kernel/rtrap.S
+++ b/arch/sparc/kernel/rtrap.S
@@ -50,8 +50,9 @@ rtrap_7win_patch5: and %g1, 0x7f, %g1
50ret_trap_entry: 50ret_trap_entry:
51ret_trap_lockless_ipi: 51ret_trap_lockless_ipi:
52 andcc %t_psr, PSR_PS, %g0 52 andcc %t_psr, PSR_PS, %g0
53 sethi %hi(PSR_SYSCALL), %g1
53 be 1f 54 be 1f
54 nop 55 andn %t_psr, %g1, %t_psr
55 56
56 wr %t_psr, 0x0, %psr 57 wr %t_psr, 0x0, %psr
57 b ret_trap_kernel 58 b ret_trap_kernel
@@ -73,7 +74,6 @@ signal_p:
73 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr 74 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr
74 75
75 mov %l5, %o1 76 mov %l5, %o1
76 mov %l6, %o2
77 call do_signal 77 call do_signal
78 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr 78 add %sp, STACKFRAME_SZ, %o0 ! pt_regs ptr
79 79
@@ -81,6 +81,8 @@ signal_p:
81 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr 81 ld [%sp + STACKFRAME_SZ + PT_PSR], %t_psr
82 clr %l6 82 clr %l6
83ret_trap_continue: 83ret_trap_continue:
84 sethi %hi(PSR_SYSCALL), %g1
85 andn %t_psr, %g1, %t_psr
84 wr %t_psr, 0x0, %psr 86 wr %t_psr, 0x0, %psr
85 WRITE_PAUSE 87 WRITE_PAUSE
86 88
@@ -137,8 +139,9 @@ ret_trap_userwins_ok:
137 LOAD_PT_PRIV(sp, t_psr, t_pc, t_npc) 139 LOAD_PT_PRIV(sp, t_psr, t_pc, t_npc)
138 or %t_pc, %t_npc, %g2 140 or %t_pc, %t_npc, %g2
139 andcc %g2, 0x3, %g0 141 andcc %g2, 0x3, %g0
142 sethi %hi(PSR_SYSCALL), %g2
140 be 1f 143 be 1f
141 nop 144 andn %t_psr, %g2, %t_psr
142 145
143 b ret_trap_unaligned_pc 146 b ret_trap_unaligned_pc
144 add %sp, STACKFRAME_SZ, %o0 147 add %sp, STACKFRAME_SZ, %o0
@@ -201,6 +204,8 @@ rtrap_patch5: and %g1, 0xff, %g1
2011: 2041:
202 LOAD_PT_ALL(sp, t_psr, t_pc, t_npc, g1) 205 LOAD_PT_ALL(sp, t_psr, t_pc, t_npc, g1)
2032: 2062:
207 sethi %hi(PSR_SYSCALL), %twin_tmp1
208 andn %t_psr, %twin_tmp1, %t_psr
204 wr %t_psr, 0x0, %psr 209 wr %t_psr, 0x0, %psr
205 WRITE_PAUSE 210 WRITE_PAUSE
206 211
diff --git a/arch/sparc/kernel/signal.c b/arch/sparc/kernel/signal.c
index 3c312290c3c2..3fd1df9f9ba7 100644
--- a/arch/sparc/kernel/signal.c
+++ b/arch/sparc/kernel/signal.c
@@ -145,6 +145,9 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)
145 regs->psr = (up_psr & ~(PSR_ICC | PSR_EF)) 145 regs->psr = (up_psr & ~(PSR_ICC | PSR_EF))
146 | (regs->psr & (PSR_ICC | PSR_EF)); 146 | (regs->psr & (PSR_ICC | PSR_EF));
147 147
148 /* Prevent syscall restart. */
149 pt_regs_clear_syscall(regs);
150
148 err |= __get_user(fpu_save, &sf->fpu_save); 151 err |= __get_user(fpu_save, &sf->fpu_save);
149 152
150 if (fpu_save) 153 if (fpu_save)
@@ -199,6 +202,9 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
199 202
200 regs->psr = (regs->psr & ~PSR_ICC) | (psr & PSR_ICC); 203 regs->psr = (regs->psr & ~PSR_ICC) | (psr & PSR_ICC);
201 204
205 /* Prevent syscall restart. */
206 pt_regs_clear_syscall(regs);
207
202 err |= __get_user(fpu_save, &sf->fpu_save); 208 err |= __get_user(fpu_save, &sf->fpu_save);
203 209
204 if (fpu_save) 210 if (fpu_save)
@@ -245,15 +251,29 @@ static inline int invalid_frame_pointer(void __user *fp, int fplen)
245 251
246static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize) 252static inline void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, unsigned long framesize)
247{ 253{
248 unsigned long sp; 254 unsigned long sp = regs->u_regs[UREG_FP];
249 255
250 sp = regs->u_regs[UREG_FP]; 256 /*
257 * If we are on the alternate signal stack and would overflow it, don't.
258 * Return an always-bogus address instead so we will die with SIGSEGV.
259 */
260 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
261 return (void __user *) -1L;
251 262
252 /* This is the X/Open sanctioned signal stack switching. */ 263 /* This is the X/Open sanctioned signal stack switching. */
253 if (sa->sa_flags & SA_ONSTACK) { 264 if (sa->sa_flags & SA_ONSTACK) {
254 if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7)) 265 if (sas_ss_flags(sp) == 0)
255 sp = current->sas_ss_sp + current->sas_ss_size; 266 sp = current->sas_ss_sp + current->sas_ss_size;
256 } 267 }
268
269 /* Always align the stack frame. This handles two cases. First,
270 * sigaltstack need not be mindful of platform specific stack
271 * alignment. Second, if we took this signal because the stack
272 * is not aligned properly, we'd like to take the signal cleanly
273 * and report that.
274 */
275 sp &= ~7UL;
276
257 return (void __user *)(sp - framesize); 277 return (void __user *)(sp - framesize);
258} 278}
259 279
@@ -493,26 +513,36 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
493 * want to handle. Thus you cannot kill init even with a SIGKILL even by 513 * want to handle. Thus you cannot kill init even with a SIGKILL even by
494 * mistake. 514 * mistake.
495 */ 515 */
496asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int restart_syscall) 516asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0)
497{ 517{
498 siginfo_t info;
499 struct sparc_deliver_cookie cookie;
500 struct k_sigaction ka; 518 struct k_sigaction ka;
501 int signr; 519 int restart_syscall;
502 sigset_t *oldset; 520 sigset_t *oldset;
521 siginfo_t info;
522 int signr;
503 523
504 cookie.restart_syscall = restart_syscall; 524 if (pt_regs_is_syscall(regs) && (regs->psr & PSR_C))
505 cookie.orig_i0 = orig_i0; 525 restart_syscall = 1;
526 else
527 restart_syscall = 0;
506 528
507 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 529 if (test_thread_flag(TIF_RESTORE_SIGMASK))
508 oldset = &current->saved_sigmask; 530 oldset = &current->saved_sigmask;
509 else 531 else
510 oldset = &current->blocked; 532 oldset = &current->blocked;
511 533
512 signr = get_signal_to_deliver(&info, &ka, regs, &cookie); 534 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
535
536 /* If the debugger messes with the program counter, it clears
537 * the software "in syscall" bit, directing us to not perform
538 * a syscall restart.
539 */
540 if (restart_syscall && !pt_regs_is_syscall(regs))
541 restart_syscall = 0;
542
513 if (signr > 0) { 543 if (signr > 0) {
514 if (cookie.restart_syscall) 544 if (restart_syscall)
515 syscall_restart(cookie.orig_i0, regs, &ka.sa); 545 syscall_restart(orig_i0, regs, &ka.sa);
516 handle_signal(signr, &ka, &info, oldset, regs); 546 handle_signal(signr, &ka, &info, oldset, regs);
517 547
518 /* a signal was successfully delivered; the saved 548 /* a signal was successfully delivered; the saved
@@ -524,16 +554,16 @@ asmlinkage void do_signal(struct pt_regs * regs, unsigned long orig_i0, int rest
524 clear_thread_flag(TIF_RESTORE_SIGMASK); 554 clear_thread_flag(TIF_RESTORE_SIGMASK);
525 return; 555 return;
526 } 556 }
527 if (cookie.restart_syscall && 557 if (restart_syscall &&
528 (regs->u_regs[UREG_I0] == ERESTARTNOHAND || 558 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
529 regs->u_regs[UREG_I0] == ERESTARTSYS || 559 regs->u_regs[UREG_I0] == ERESTARTSYS ||
530 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) { 560 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
531 /* replay the system call when we are done */ 561 /* replay the system call when we are done */
532 regs->u_regs[UREG_I0] = cookie.orig_i0; 562 regs->u_regs[UREG_I0] = orig_i0;
533 regs->pc -= 4; 563 regs->pc -= 4;
534 regs->npc -= 4; 564 regs->npc -= 4;
535 } 565 }
536 if (cookie.restart_syscall && 566 if (restart_syscall &&
537 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) { 567 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
538 regs->u_regs[UREG_G1] = __NR_restart_syscall; 568 regs->u_regs[UREG_G1] = __NR_restart_syscall;
539 regs->pc -= 4; 569 regs->pc -= 4;
@@ -585,27 +615,3 @@ do_sys_sigstack(struct sigstack __user *ssptr, struct sigstack __user *ossptr,
585out: 615out:
586 return ret; 616 return ret;
587} 617}
588
589void ptrace_signal_deliver(struct pt_regs *regs, void *cookie)
590{
591 struct sparc_deliver_cookie *cp = cookie;
592
593 if (cp->restart_syscall &&
594 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
595 regs->u_regs[UREG_I0] == ERESTARTSYS ||
596 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
597 /* replay the system call when we are done */
598 regs->u_regs[UREG_I0] = cp->orig_i0;
599 regs->pc -= 4;
600 regs->npc -= 4;
601 cp->restart_syscall = 0;
602 }
603
604 if (cp->restart_syscall &&
605 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
606 regs->u_regs[UREG_G1] = __NR_restart_syscall;
607 regs->pc -= 4;
608 regs->npc -= 4;
609 cp->restart_syscall = 0;
610 }
611}
diff --git a/arch/sparc/kernel/sys_sparc.c b/arch/sparc/kernel/sys_sparc.c
index f188b5dc9fd0..3c6b49a53ae8 100644
--- a/arch/sparc/kernel/sys_sparc.c
+++ b/arch/sparc/kernel/sys_sparc.c
@@ -219,12 +219,11 @@ out:
219 return err; 219 return err;
220} 220}
221 221
222int sparc_mmap_check(unsigned long addr, unsigned long len, unsigned long flags) 222int sparc_mmap_check(unsigned long addr, unsigned long len)
223{ 223{
224 if (ARCH_SUN4C_SUN4 && 224 if (ARCH_SUN4C_SUN4 &&
225 (len > 0x20000000 || 225 (len > 0x20000000 ||
226 ((flags & MAP_FIXED) && 226 (addr < 0xe0000000 && addr + len > 0x20000000)))
227 addr < 0xe0000000 && addr + len > 0x20000000)))
228 return -EINVAL; 227 return -EINVAL;
229 228
230 /* See asm-sparc/uaccess.h */ 229 /* See asm-sparc/uaccess.h */
@@ -296,52 +295,14 @@ asmlinkage unsigned long sparc_mremap(unsigned long addr,
296 unsigned long old_len, unsigned long new_len, 295 unsigned long old_len, unsigned long new_len,
297 unsigned long flags, unsigned long new_addr) 296 unsigned long flags, unsigned long new_addr)
298{ 297{
299 struct vm_area_struct *vma;
300 unsigned long ret = -EINVAL; 298 unsigned long ret = -EINVAL;
301 if (ARCH_SUN4C_SUN4) { 299
302 if (old_len > 0x20000000 || new_len > 0x20000000) 300 if (unlikely(sparc_mmap_check(addr, old_len)))
303 goto out; 301 goto out;
304 if (addr < 0xe0000000 && addr + old_len > 0x20000000) 302 if (unlikely(sparc_mmap_check(new_addr, new_len)))
305 goto out;
306 }
307 if (old_len > TASK_SIZE - PAGE_SIZE ||
308 new_len > TASK_SIZE - PAGE_SIZE)
309 goto out; 303 goto out;
310 down_write(&current->mm->mmap_sem); 304 down_write(&current->mm->mmap_sem);
311 if (flags & MREMAP_FIXED) {
312 if (ARCH_SUN4C_SUN4 &&
313 new_addr < 0xe0000000 &&
314 new_addr + new_len > 0x20000000)
315 goto out_sem;
316 if (new_addr + new_len > TASK_SIZE - PAGE_SIZE)
317 goto out_sem;
318 } else if ((ARCH_SUN4C_SUN4 && addr < 0xe0000000 &&
319 addr + new_len > 0x20000000) ||
320 addr + new_len > TASK_SIZE - PAGE_SIZE) {
321 unsigned long map_flags = 0;
322 struct file *file = NULL;
323
324 ret = -ENOMEM;
325 if (!(flags & MREMAP_MAYMOVE))
326 goto out_sem;
327
328 vma = find_vma(current->mm, addr);
329 if (vma) {
330 if (vma->vm_flags & VM_SHARED)
331 map_flags |= MAP_SHARED;
332 file = vma->vm_file;
333 }
334
335 new_addr = get_unmapped_area(file, addr, new_len,
336 vma ? vma->vm_pgoff : 0,
337 map_flags);
338 ret = new_addr;
339 if (new_addr & ~PAGE_MASK)
340 goto out_sem;
341 flags |= MREMAP_FIXED;
342 }
343 ret = do_mremap(addr, old_len, new_len, flags, new_addr); 305 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
344out_sem:
345 up_write(&current->mm->mmap_sem); 306 up_write(&current->mm->mmap_sem);
346out: 307out:
347 return ret; 308 return ret;
diff --git a/arch/sparc64/kernel/etrap.S b/arch/sparc64/kernel/etrap.S
index b49d3b60bc0c..f25e1da3fd03 100644
--- a/arch/sparc64/kernel/etrap.S
+++ b/arch/sparc64/kernel/etrap.S
@@ -27,11 +27,12 @@
27 27
28 .text 28 .text
29 .align 64 29 .align 64
30 .globl etrap, etrap_irq, etraptl1 30 .globl etrap_syscall, etrap, etrap_irq, etraptl1
31etrap: rdpr %pil, %g2 31etrap: rdpr %pil, %g2
32etrap_irq: 32etrap_irq: clr %g3
33 TRAP_LOAD_THREAD_REG(%g6, %g1) 33etrap_syscall: TRAP_LOAD_THREAD_REG(%g6, %g1)
34 rdpr %tstate, %g1 34 rdpr %tstate, %g1
35 or %g1, %g3, %g1
35 sllx %g2, 20, %g3 36 sllx %g2, 20, %g3
36 andcc %g1, TSTATE_PRIV, %g0 37 andcc %g1, TSTATE_PRIV, %g0
37 or %g1, %g3, %g1 38 or %g1, %g3, %g1
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c
index 500ac6d483a0..4129c0449856 100644
--- a/arch/sparc64/kernel/process.c
+++ b/arch/sparc64/kernel/process.c
@@ -503,6 +503,8 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
503 unsigned long stack_size) 503 unsigned long stack_size)
504{ 504{
505 int __user *parent_tid_ptr, *child_tid_ptr; 505 int __user *parent_tid_ptr, *child_tid_ptr;
506 unsigned long orig_i1 = regs->u_regs[UREG_I1];
507 long ret;
506 508
507#ifdef CONFIG_COMPAT 509#ifdef CONFIG_COMPAT
508 if (test_thread_flag(TIF_32BIT)) { 510 if (test_thread_flag(TIF_32BIT)) {
@@ -515,9 +517,19 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
515 child_tid_ptr = (int __user *) regs->u_regs[UREG_I4]; 517 child_tid_ptr = (int __user *) regs->u_regs[UREG_I4];
516 } 518 }
517 519
518 return do_fork(clone_flags, stack_start, 520 ret = do_fork(clone_flags, stack_start,
519 regs, stack_size, 521 regs, stack_size,
520 parent_tid_ptr, child_tid_ptr); 522 parent_tid_ptr, child_tid_ptr);
523
524 /* If we get an error and potentially restart the system
525 * call, we're screwed because copy_thread() clobbered
526 * the parent's %o1. So detect that case and restore it
527 * here.
528 */
529 if ((unsigned long)ret >= -ERESTART_RESTARTBLOCK)
530 regs->u_regs[UREG_I1] = orig_i1;
531
532 return ret;
521} 533}
522 534
523/* Copy a Sparc thread. The fork() return value conventions 535/* Copy a Sparc thread. The fork() return value conventions
diff --git a/arch/sparc64/kernel/ptrace.c b/arch/sparc64/kernel/ptrace.c
index e9fc0aa2da38..f6c9fc92921d 100644
--- a/arch/sparc64/kernel/ptrace.c
+++ b/arch/sparc64/kernel/ptrace.c
@@ -287,11 +287,11 @@ static int genregs64_set(struct task_struct *target,
287 32 * sizeof(u64), 287 32 * sizeof(u64),
288 33 * sizeof(u64)); 288 33 * sizeof(u64));
289 if (!ret) { 289 if (!ret) {
290 /* Only the condition codes can be modified 290 /* Only the condition codes and the "in syscall"
291 * in the %tstate register. 291 * state can be modified in the %tstate register.
292 */ 292 */
293 tstate &= (TSTATE_ICC | TSTATE_XCC); 293 tstate &= (TSTATE_ICC | TSTATE_XCC | TSTATE_SYSCALL);
294 regs->tstate &= ~(TSTATE_ICC | TSTATE_XCC); 294 regs->tstate &= ~(TSTATE_ICC | TSTATE_XCC | TSTATE_SYSCALL);
295 regs->tstate |= tstate; 295 regs->tstate |= tstate;
296 } 296 }
297 } 297 }
@@ -657,8 +657,10 @@ static int genregs32_set(struct task_struct *target,
657 switch (pos) { 657 switch (pos) {
658 case 32: /* PSR */ 658 case 32: /* PSR */
659 tstate = regs->tstate; 659 tstate = regs->tstate;
660 tstate &= ~(TSTATE_ICC | TSTATE_XCC); 660 tstate &= ~(TSTATE_ICC | TSTATE_XCC | TSTATE_SYSCALL);
661 tstate |= psr_to_tstate_icc(reg); 661 tstate |= psr_to_tstate_icc(reg);
662 if (reg & PSR_SYSCALL)
663 tstate |= TSTATE_SYSCALL;
662 regs->tstate = tstate; 664 regs->tstate = tstate;
663 break; 665 break;
664 case 33: /* PC */ 666 case 33: /* PC */
@@ -944,6 +946,8 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
944 break; 946 break;
945 947
946 default: 948 default:
949 if (request == PTRACE_SPARC_DETACH)
950 request = PTRACE_DETACH;
947 ret = compat_ptrace_request(child, request, addr, data); 951 ret = compat_ptrace_request(child, request, addr, data);
948 break; 952 break;
949 } 953 }
@@ -1036,6 +1040,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1036 break; 1040 break;
1037 1041
1038 default: 1042 default:
1043 if (request == PTRACE_SPARC_DETACH)
1044 request = PTRACE_DETACH;
1039 ret = ptrace_request(child, request, addr, data); 1045 ret = ptrace_request(child, request, addr, data);
1040 break; 1046 break;
1041 } 1047 }
diff --git a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S
index ecf6753b204a..16689b2930db 100644
--- a/arch/sparc64/kernel/rtrap.S
+++ b/arch/sparc64/kernel/rtrap.S
@@ -46,7 +46,7 @@ __handle_user_windows:
46 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 46 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
47 ldx [%g6 + TI_FLAGS], %l0 47 ldx [%g6 + TI_FLAGS], %l0
48 48
491: andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0 491: andcc %l0, _TIF_SIGPENDING, %g0
50 be,pt %xcc, __handle_user_windows_continue 50 be,pt %xcc, __handle_user_windows_continue
51 nop 51 nop
52 mov %l5, %o1 52 mov %l5, %o1
@@ -86,7 +86,7 @@ __handle_perfctrs:
86 wrpr %g0, RTRAP_PSTATE, %pstate 86 wrpr %g0, RTRAP_PSTATE, %pstate
87 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate 87 wrpr %g0, RTRAP_PSTATE_IRQOFF, %pstate
88 ldx [%g6 + TI_FLAGS], %l0 88 ldx [%g6 + TI_FLAGS], %l0
891: andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0 891: andcc %l0, _TIF_SIGPENDING, %g0
90 90
91 be,pt %xcc, __handle_perfctrs_continue 91 be,pt %xcc, __handle_perfctrs_continue
92 sethi %hi(TSTATE_PEF), %o0 92 sethi %hi(TSTATE_PEF), %o0
@@ -195,7 +195,7 @@ __handle_preemption_continue:
195 andcc %l1, %o0, %g0 195 andcc %l1, %o0, %g0
196 andcc %l0, _TIF_NEED_RESCHED, %g0 196 andcc %l0, _TIF_NEED_RESCHED, %g0
197 bne,pn %xcc, __handle_preemption 197 bne,pn %xcc, __handle_preemption
198 andcc %l0, (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), %g0 198 andcc %l0, _TIF_SIGPENDING, %g0
199 bne,pn %xcc, __handle_signal 199 bne,pn %xcc, __handle_signal
200__handle_signal_continue: 200__handle_signal_continue:
201 ldub [%g6 + TI_WSAVED], %o2 201 ldub [%g6 + TI_WSAVED], %o2
@@ -257,6 +257,7 @@ rt_continue: ldx [%sp + PTREGS_OFF + PT_V9_G1], %g1
257 wr %o3, %g0, %y 257 wr %o3, %g0, %y
258 wrpr %l4, 0x0, %pil 258 wrpr %l4, 0x0, %pil
259 wrpr %g0, 0x1, %tl 259 wrpr %g0, 0x1, %tl
260 andn %l1, TSTATE_SYSCALL, %l1
260 wrpr %l1, %g0, %tstate 261 wrpr %l1, %g0, %tstate
261 wrpr %l2, %g0, %tpc 262 wrpr %l2, %g0, %tpc
262 wrpr %o2, %g0, %tnpc 263 wrpr %o2, %g0, %tnpc
diff --git a/arch/sparc64/kernel/signal.c b/arch/sparc64/kernel/signal.c
index 45d6bf632daa..6e4dc67d16af 100644
--- a/arch/sparc64/kernel/signal.c
+++ b/arch/sparc64/kernel/signal.c
@@ -247,7 +247,9 @@ static long _sigpause_common(old_sigset_t set)
247 247
248 current->state = TASK_INTERRUPTIBLE; 248 current->state = TASK_INTERRUPTIBLE;
249 schedule(); 249 schedule();
250 set_thread_flag(TIF_RESTORE_SIGMASK); 250
251 set_restore_sigmask();
252
251 return -ERESTARTNOHAND; 253 return -ERESTARTNOHAND;
252} 254}
253 255
@@ -333,7 +335,7 @@ void do_rt_sigreturn(struct pt_regs *regs)
333 regs->tnpc = tnpc; 335 regs->tnpc = tnpc;
334 336
335 /* Prevent syscall restart. */ 337 /* Prevent syscall restart. */
336 pt_regs_clear_trap_type(regs); 338 pt_regs_clear_syscall(regs);
337 339
338 sigdelsetmask(&set, ~_BLOCKABLE); 340 sigdelsetmask(&set, ~_BLOCKABLE);
339 spin_lock_irq(&current->sighand->siglock); 341 spin_lock_irq(&current->sighand->siglock);
@@ -376,16 +378,29 @@ save_fpu_state(struct pt_regs *regs, __siginfo_fpu_t __user *fpu)
376 378
377static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize) 379static inline void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, unsigned long framesize)
378{ 380{
379 unsigned long sp; 381 unsigned long sp = regs->u_regs[UREG_FP] + STACK_BIAS;
380 382
381 sp = regs->u_regs[UREG_FP] + STACK_BIAS; 383 /*
384 * If we are on the alternate signal stack and would overflow it, don't.
385 * Return an always-bogus address instead so we will die with SIGSEGV.
386 */
387 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
388 return (void __user *) -1L;
382 389
383 /* This is the X/Open sanctioned signal stack switching. */ 390 /* This is the X/Open sanctioned signal stack switching. */
384 if (ka->sa.sa_flags & SA_ONSTACK) { 391 if (ka->sa.sa_flags & SA_ONSTACK) {
385 if (!on_sig_stack(sp) && 392 if (sas_ss_flags(sp) == 0)
386 !((current->sas_ss_sp + current->sas_ss_size) & 7))
387 sp = current->sas_ss_sp + current->sas_ss_size; 393 sp = current->sas_ss_sp + current->sas_ss_size;
388 } 394 }
395
396 /* Always align the stack frame. This handles two cases. First,
397 * sigaltstack need not be mindful of platform specific stack
398 * alignment. Second, if we took this signal because the stack
399 * is not aligned properly, we'd like to take the signal cleanly
400 * and report that.
401 */
402 sp &= ~7UL;
403
389 return (void __user *)(sp - framesize); 404 return (void __user *)(sp - framesize);
390} 405}
391 406
@@ -486,7 +501,7 @@ static inline void handle_signal(unsigned long signr, struct k_sigaction *ka,
486} 501}
487 502
488static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs, 503static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
489 struct sigaction *sa) 504 struct sigaction *sa)
490{ 505{
491 switch (regs->u_regs[UREG_I0]) { 506 switch (regs->u_regs[UREG_I0]) {
492 case ERESTART_RESTARTBLOCK: 507 case ERESTART_RESTARTBLOCK:
@@ -512,21 +527,19 @@ static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
512 */ 527 */
513static void do_signal(struct pt_regs *regs, unsigned long orig_i0) 528static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
514{ 529{
515 struct signal_deliver_cookie cookie;
516 struct k_sigaction ka; 530 struct k_sigaction ka;
531 int restart_syscall;
517 sigset_t *oldset; 532 sigset_t *oldset;
518 siginfo_t info; 533 siginfo_t info;
519 int signr; 534 int signr;
520 535
521 if (pt_regs_is_syscall(regs) && 536 if (pt_regs_is_syscall(regs) &&
522 (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) { 537 (regs->tstate & (TSTATE_XCARRY | TSTATE_ICARRY))) {
523 pt_regs_clear_trap_type(regs); 538 restart_syscall = 1;
524 cookie.restart_syscall = 1;
525 } else 539 } else
526 cookie.restart_syscall = 0; 540 restart_syscall = 0;
527 cookie.orig_i0 = orig_i0;
528 541
529 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 542 if (current_thread_info()->status & TS_RESTORE_SIGMASK)
530 oldset = &current->saved_sigmask; 543 oldset = &current->saved_sigmask;
531 else 544 else
532 oldset = &current->blocked; 545 oldset = &current->blocked;
@@ -534,77 +547,62 @@ static void do_signal(struct pt_regs *regs, unsigned long orig_i0)
534#ifdef CONFIG_COMPAT 547#ifdef CONFIG_COMPAT
535 if (test_thread_flag(TIF_32BIT)) { 548 if (test_thread_flag(TIF_32BIT)) {
536 extern void do_signal32(sigset_t *, struct pt_regs *, 549 extern void do_signal32(sigset_t *, struct pt_regs *,
537 struct signal_deliver_cookie *); 550 int restart_syscall,
538 do_signal32(oldset, regs, &cookie); 551 unsigned long orig_i0);
552 do_signal32(oldset, regs, restart_syscall, orig_i0);
539 return; 553 return;
540 } 554 }
541#endif 555#endif
542 556
543 signr = get_signal_to_deliver(&info, &ka, regs, &cookie); 557 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
558
559 /* If the debugger messes with the program counter, it clears
560 * the software "in syscall" bit, directing us to not perform
561 * a syscall restart.
562 */
563 if (restart_syscall && !pt_regs_is_syscall(regs))
564 restart_syscall = 0;
565
544 if (signr > 0) { 566 if (signr > 0) {
545 if (cookie.restart_syscall) 567 if (restart_syscall)
546 syscall_restart(cookie.orig_i0, regs, &ka.sa); 568 syscall_restart(orig_i0, regs, &ka.sa);
547 handle_signal(signr, &ka, &info, oldset, regs); 569 handle_signal(signr, &ka, &info, oldset, regs);
548 570
549 /* a signal was successfully delivered; the saved 571 /* A signal was successfully delivered; the saved
550 * sigmask will have been stored in the signal frame, 572 * sigmask will have been stored in the signal frame,
551 * and will be restored by sigreturn, so we can simply 573 * and will be restored by sigreturn, so we can simply
552 * clear the TIF_RESTORE_SIGMASK flag. 574 * clear the TS_RESTORE_SIGMASK flag.
553 */ 575 */
554 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 576 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
555 clear_thread_flag(TIF_RESTORE_SIGMASK);
556 return; 577 return;
557 } 578 }
558 if (cookie.restart_syscall && 579 if (restart_syscall &&
559 (regs->u_regs[UREG_I0] == ERESTARTNOHAND || 580 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
560 regs->u_regs[UREG_I0] == ERESTARTSYS || 581 regs->u_regs[UREG_I0] == ERESTARTSYS ||
561 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) { 582 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
562 /* replay the system call when we are done */ 583 /* replay the system call when we are done */
563 regs->u_regs[UREG_I0] = cookie.orig_i0; 584 regs->u_regs[UREG_I0] = orig_i0;
564 regs->tpc -= 4; 585 regs->tpc -= 4;
565 regs->tnpc -= 4; 586 regs->tnpc -= 4;
566 } 587 }
567 if (cookie.restart_syscall && 588 if (restart_syscall &&
568 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) { 589 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
569 regs->u_regs[UREG_G1] = __NR_restart_syscall; 590 regs->u_regs[UREG_G1] = __NR_restart_syscall;
570 regs->tpc -= 4; 591 regs->tpc -= 4;
571 regs->tnpc -= 4; 592 regs->tnpc -= 4;
572 } 593 }
573 594
574 /* if there's no signal to deliver, we just put the saved sigmask 595 /* If there's no signal to deliver, we just put the saved sigmask
575 * back 596 * back
576 */ 597 */
577 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 598 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
578 clear_thread_flag(TIF_RESTORE_SIGMASK); 599 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
579 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 600 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
580 } 601 }
581} 602}
582 603
583void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags) 604void do_notify_resume(struct pt_regs *regs, unsigned long orig_i0, unsigned long thread_info_flags)
584{ 605{
585 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) 606 if (thread_info_flags & _TIF_SIGPENDING)
586 do_signal(regs, orig_i0); 607 do_signal(regs, orig_i0);
587} 608}
588
589void ptrace_signal_deliver(struct pt_regs *regs, void *cookie)
590{
591 struct signal_deliver_cookie *cp = cookie;
592
593 if (cp->restart_syscall &&
594 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
595 regs->u_regs[UREG_I0] == ERESTARTSYS ||
596 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
597 /* replay the system call when we are done */
598 regs->u_regs[UREG_I0] = cp->orig_i0;
599 regs->tpc -= 4;
600 regs->tnpc -= 4;
601 cp->restart_syscall = 0;
602 }
603 if (cp->restart_syscall &&
604 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
605 regs->u_regs[UREG_G1] = __NR_restart_syscall;
606 regs->tpc -= 4;
607 regs->tnpc -= 4;
608 cp->restart_syscall = 0;
609 }
610}
diff --git a/arch/sparc64/kernel/signal32.c b/arch/sparc64/kernel/signal32.c
index 9415d2c918c5..97cdd1bf4a10 100644
--- a/arch/sparc64/kernel/signal32.c
+++ b/arch/sparc64/kernel/signal32.c
@@ -269,7 +269,7 @@ void do_sigreturn32(struct pt_regs *regs)
269 regs->tstate |= psr_to_tstate_icc(psr); 269 regs->tstate |= psr_to_tstate_icc(psr);
270 270
271 /* Prevent syscall restart. */ 271 /* Prevent syscall restart. */
272 pt_regs_clear_trap_type(regs); 272 pt_regs_clear_syscall(regs);
273 273
274 err |= __get_user(fpu_save, &sf->fpu_save); 274 err |= __get_user(fpu_save, &sf->fpu_save);
275 if (fpu_save) 275 if (fpu_save)
@@ -355,7 +355,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
355 regs->tstate |= psr_to_tstate_icc(psr); 355 regs->tstate |= psr_to_tstate_icc(psr);
356 356
357 /* Prevent syscall restart. */ 357 /* Prevent syscall restart. */
358 pt_regs_clear_trap_type(regs); 358 pt_regs_clear_syscall(regs);
359 359
360 err |= __get_user(fpu_save, &sf->fpu_save); 360 err |= __get_user(fpu_save, &sf->fpu_save);
361 if (fpu_save) 361 if (fpu_save)
@@ -406,11 +406,27 @@ static void __user *get_sigframe(struct sigaction *sa, struct pt_regs *regs, uns
406 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL; 406 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
407 sp = regs->u_regs[UREG_FP]; 407 sp = regs->u_regs[UREG_FP];
408 408
409 /*
410 * If we are on the alternate signal stack and would overflow it, don't.
411 * Return an always-bogus address instead so we will die with SIGSEGV.
412 */
413 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - framesize)))
414 return (void __user *) -1L;
415
409 /* This is the X/Open sanctioned signal stack switching. */ 416 /* This is the X/Open sanctioned signal stack switching. */
410 if (sa->sa_flags & SA_ONSTACK) { 417 if (sa->sa_flags & SA_ONSTACK) {
411 if (!on_sig_stack(sp) && !((current->sas_ss_sp + current->sas_ss_size) & 7)) 418 if (sas_ss_flags(sp) == 0)
412 sp = current->sas_ss_sp + current->sas_ss_size; 419 sp = current->sas_ss_sp + current->sas_ss_size;
413 } 420 }
421
422 /* Always align the stack frame. This handles two cases. First,
423 * sigaltstack need not be mindful of platform specific stack
424 * alignment. Second, if we took this signal because the stack
425 * is not aligned properly, we'd like to take the signal cleanly
426 * and report that.
427 */
428 sp &= ~7UL;
429
414 return (void __user *)(sp - framesize); 430 return (void __user *)(sp - framesize);
415} 431}
416 432
@@ -752,48 +768,55 @@ static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs
752 * mistake. 768 * mistake.
753 */ 769 */
754void do_signal32(sigset_t *oldset, struct pt_regs * regs, 770void do_signal32(sigset_t *oldset, struct pt_regs * regs,
755 struct signal_deliver_cookie *cookie) 771 int restart_syscall, unsigned long orig_i0)
756{ 772{
757 struct k_sigaction ka; 773 struct k_sigaction ka;
758 siginfo_t info; 774 siginfo_t info;
759 int signr; 775 int signr;
760 776
761 signr = get_signal_to_deliver(&info, &ka, regs, cookie); 777 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
778
779 /* If the debugger messes with the program counter, it clears
780 * the "in syscall" bit, directing us to not perform a syscall
781 * restart.
782 */
783 if (restart_syscall && !pt_regs_is_syscall(regs))
784 restart_syscall = 0;
785
762 if (signr > 0) { 786 if (signr > 0) {
763 if (cookie->restart_syscall) 787 if (restart_syscall)
764 syscall_restart32(cookie->orig_i0, regs, &ka.sa); 788 syscall_restart32(orig_i0, regs, &ka.sa);
765 handle_signal32(signr, &ka, &info, oldset, regs); 789 handle_signal32(signr, &ka, &info, oldset, regs);
766 790
767 /* a signal was successfully delivered; the saved 791 /* A signal was successfully delivered; the saved
768 * sigmask will have been stored in the signal frame, 792 * sigmask will have been stored in the signal frame,
769 * and will be restored by sigreturn, so we can simply 793 * and will be restored by sigreturn, so we can simply
770 * clear the TIF_RESTORE_SIGMASK flag. 794 * clear the TS_RESTORE_SIGMASK flag.
771 */ 795 */
772 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 796 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
773 clear_thread_flag(TIF_RESTORE_SIGMASK);
774 return; 797 return;
775 } 798 }
776 if (cookie->restart_syscall && 799 if (restart_syscall &&
777 (regs->u_regs[UREG_I0] == ERESTARTNOHAND || 800 (regs->u_regs[UREG_I0] == ERESTARTNOHAND ||
778 regs->u_regs[UREG_I0] == ERESTARTSYS || 801 regs->u_regs[UREG_I0] == ERESTARTSYS ||
779 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) { 802 regs->u_regs[UREG_I0] == ERESTARTNOINTR)) {
780 /* replay the system call when we are done */ 803 /* replay the system call when we are done */
781 regs->u_regs[UREG_I0] = cookie->orig_i0; 804 regs->u_regs[UREG_I0] = orig_i0;
782 regs->tpc -= 4; 805 regs->tpc -= 4;
783 regs->tnpc -= 4; 806 regs->tnpc -= 4;
784 } 807 }
785 if (cookie->restart_syscall && 808 if (restart_syscall &&
786 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) { 809 regs->u_regs[UREG_I0] == ERESTART_RESTARTBLOCK) {
787 regs->u_regs[UREG_G1] = __NR_restart_syscall; 810 regs->u_regs[UREG_G1] = __NR_restart_syscall;
788 regs->tpc -= 4; 811 regs->tpc -= 4;
789 regs->tnpc -= 4; 812 regs->tnpc -= 4;
790 } 813 }
791 814
792 /* if there's no signal to deliver, we just put the saved sigmask 815 /* If there's no signal to deliver, we just put the saved sigmask
793 * back 816 * back
794 */ 817 */
795 if (test_thread_flag(TIF_RESTORE_SIGMASK)) { 818 if (current_thread_info()->status & TS_RESTORE_SIGMASK) {
796 clear_thread_flag(TIF_RESTORE_SIGMASK); 819 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
797 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL); 820 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
798 } 821 }
799} 822}
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 3aba47624df4..0d6403a630ac 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -865,21 +865,14 @@ void smp_call_function_client(int irq, struct pt_regs *regs)
865 void *info = call_data->info; 865 void *info = call_data->info;
866 866
867 clear_softint(1 << irq); 867 clear_softint(1 << irq);
868
869 irq_enter();
870
871 if (!call_data->wait) {
872 /* let initiator proceed after getting data */
873 atomic_inc(&call_data->finished);
874 }
875
876 func(info);
877
878 irq_exit();
879
880 if (call_data->wait) { 868 if (call_data->wait) {
881 /* let initiator proceed only after completion */ 869 /* let initiator proceed only after completion */
870 func(info);
882 atomic_inc(&call_data->finished); 871 atomic_inc(&call_data->finished);
872 } else {
873 /* let initiator proceed after getting data */
874 atomic_inc(&call_data->finished);
875 func(info);
883 } 876 }
884} 877}
885 878
@@ -1041,9 +1034,7 @@ void smp_receive_signal(int cpu)
1041 1034
1042void smp_receive_signal_client(int irq, struct pt_regs *regs) 1035void smp_receive_signal_client(int irq, struct pt_regs *regs)
1043{ 1036{
1044 irq_enter();
1045 clear_softint(1 << irq); 1037 clear_softint(1 << irq);
1046 irq_exit();
1047} 1038}
1048 1039
1049void smp_new_mmu_context_version_client(int irq, struct pt_regs *regs) 1040void smp_new_mmu_context_version_client(int irq, struct pt_regs *regs)
@@ -1051,8 +1042,6 @@ void smp_new_mmu_context_version_client(int irq, struct pt_regs *regs)
1051 struct mm_struct *mm; 1042 struct mm_struct *mm;
1052 unsigned long flags; 1043 unsigned long flags;
1053 1044
1054 irq_enter();
1055
1056 clear_softint(1 << irq); 1045 clear_softint(1 << irq);
1057 1046
1058 /* See if we need to allocate a new TLB context because 1047 /* See if we need to allocate a new TLB context because
@@ -1072,8 +1061,6 @@ void smp_new_mmu_context_version_client(int irq, struct pt_regs *regs)
1072 load_secondary_context(mm); 1061 load_secondary_context(mm);
1073 __flush_tlb_mm(CTX_HWBITS(mm->context), 1062 __flush_tlb_mm(CTX_HWBITS(mm->context),
1074 SECONDARY_CONTEXT); 1063 SECONDARY_CONTEXT);
1075
1076 irq_exit();
1077} 1064}
1078 1065
1079void smp_new_mmu_context_version(void) 1066void smp_new_mmu_context_version(void)
@@ -1239,8 +1226,6 @@ void smp_penguin_jailcell(int irq, struct pt_regs *regs)
1239{ 1226{
1240 clear_softint(1 << irq); 1227 clear_softint(1 << irq);
1241 1228
1242 irq_enter();
1243
1244 preempt_disable(); 1229 preempt_disable();
1245 1230
1246 __asm__ __volatile__("flushw"); 1231 __asm__ __volatile__("flushw");
@@ -1253,8 +1238,6 @@ void smp_penguin_jailcell(int irq, struct pt_regs *regs)
1253 prom_world(0); 1238 prom_world(0);
1254 1239
1255 preempt_enable(); 1240 preempt_enable();
1256
1257 irq_exit();
1258} 1241}
1259 1242
1260/* /proc/profile writes can call this, don't __init it please. */ 1243/* /proc/profile writes can call this, don't __init it please. */
diff --git a/arch/sparc64/kernel/sys_sparc.c b/arch/sparc64/kernel/sys_sparc.c
index 8d4761f15fa9..ac1bff58c1ac 100644
--- a/arch/sparc64/kernel/sys_sparc.c
+++ b/arch/sparc64/kernel/sys_sparc.c
@@ -542,20 +542,19 @@ asmlinkage long sparc64_personality(unsigned long personality)
542 return ret; 542 return ret;
543} 543}
544 544
545int sparc64_mmap_check(unsigned long addr, unsigned long len, 545int sparc64_mmap_check(unsigned long addr, unsigned long len)
546 unsigned long flags)
547{ 546{
548 if (test_thread_flag(TIF_32BIT)) { 547 if (test_thread_flag(TIF_32BIT)) {
549 if (len >= STACK_TOP32) 548 if (len >= STACK_TOP32)
550 return -EINVAL; 549 return -EINVAL;
551 550
552 if ((flags & MAP_FIXED) && addr > STACK_TOP32 - len) 551 if (addr > STACK_TOP32 - len)
553 return -EINVAL; 552 return -EINVAL;
554 } else { 553 } else {
555 if (len >= VA_EXCLUDE_START) 554 if (len >= VA_EXCLUDE_START)
556 return -EINVAL; 555 return -EINVAL;
557 556
558 if ((flags & MAP_FIXED) && invalid_64bit_range(addr, len)) 557 if (invalid_64bit_range(addr, len))
559 return -EINVAL; 558 return -EINVAL;
560 } 559 }
561 560
@@ -609,46 +608,19 @@ asmlinkage unsigned long sys64_mremap(unsigned long addr,
609 unsigned long old_len, unsigned long new_len, 608 unsigned long old_len, unsigned long new_len,
610 unsigned long flags, unsigned long new_addr) 609 unsigned long flags, unsigned long new_addr)
611{ 610{
612 struct vm_area_struct *vma;
613 unsigned long ret = -EINVAL; 611 unsigned long ret = -EINVAL;
614 612
615 if (test_thread_flag(TIF_32BIT)) 613 if (test_thread_flag(TIF_32BIT))
616 goto out; 614 goto out;
617 if (unlikely(new_len >= VA_EXCLUDE_START)) 615 if (unlikely(new_len >= VA_EXCLUDE_START))
618 goto out; 616 goto out;
619 if (unlikely(invalid_64bit_range(addr, old_len))) 617 if (unlikely(sparc64_mmap_check(addr, old_len)))
618 goto out;
619 if (unlikely(sparc64_mmap_check(new_addr, new_len)))
620 goto out; 620 goto out;
621 621
622 down_write(&current->mm->mmap_sem); 622 down_write(&current->mm->mmap_sem);
623 if (flags & MREMAP_FIXED) {
624 if (invalid_64bit_range(new_addr, new_len))
625 goto out_sem;
626 } else if (invalid_64bit_range(addr, new_len)) {
627 unsigned long map_flags = 0;
628 struct file *file = NULL;
629
630 ret = -ENOMEM;
631 if (!(flags & MREMAP_MAYMOVE))
632 goto out_sem;
633
634 vma = find_vma(current->mm, addr);
635 if (vma) {
636 if (vma->vm_flags & VM_SHARED)
637 map_flags |= MAP_SHARED;
638 file = vma->vm_file;
639 }
640
641 /* MREMAP_FIXED checked above. */
642 new_addr = get_unmapped_area(file, addr, new_len,
643 vma ? vma->vm_pgoff : 0,
644 map_flags);
645 ret = new_addr;
646 if (new_addr & ~PAGE_MASK)
647 goto out_sem;
648 flags |= MREMAP_FIXED;
649 }
650 ret = do_mremap(addr, old_len, new_len, flags, new_addr); 623 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
651out_sem:
652 up_write(&current->mm->mmap_sem); 624 up_write(&current->mm->mmap_sem);
653out: 625out:
654 return ret; 626 return ret;
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index 161ce4710fe7..ba5bd626b39e 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -236,13 +236,6 @@ asmlinkage long sys32_getegid16(void)
236 236
237/* 32-bit timeval and related flotsam. */ 237/* 32-bit timeval and related flotsam. */
238 238
239static long get_tv32(struct timeval *o, struct compat_timeval __user *i)
240{
241 return (!access_ok(VERIFY_READ, i, sizeof(*i)) ||
242 (__get_user(o->tv_sec, &i->tv_sec) |
243 __get_user(o->tv_usec, &i->tv_usec)));
244}
245
246static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i) 239static inline long put_tv32(struct compat_timeval __user *o, struct timeval *i)
247{ 240{
248 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) || 241 return (!access_ok(VERIFY_WRITE, o, sizeof(*o)) ||
@@ -757,30 +750,6 @@ asmlinkage long sys32_settimeofday(struct compat_timeval __user *tv,
757 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 750 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL);
758} 751}
759 752
760asmlinkage long sys32_utimes(char __user *filename,
761 struct compat_timeval __user *tvs)
762{
763 struct timespec tv[2];
764
765 if (tvs) {
766 struct timeval ktvs[2];
767 if (get_tv32(&ktvs[0], tvs) ||
768 get_tv32(&ktvs[1], 1+tvs))
769 return -EFAULT;
770
771 if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 ||
772 ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000)
773 return -EINVAL;
774
775 tv[0].tv_sec = ktvs[0].tv_sec;
776 tv[0].tv_nsec = 1000 * ktvs[0].tv_usec;
777 tv[1].tv_sec = ktvs[1].tv_sec;
778 tv[1].tv_nsec = 1000 * ktvs[1].tv_usec;
779 }
780
781 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
782}
783
784/* These are here just in case some old sparc32 binary calls it. */ 753/* These are here just in case some old sparc32 binary calls it. */
785asmlinkage long sys32_pause(void) 754asmlinkage long sys32_pause(void)
786{ 755{
@@ -898,44 +867,15 @@ asmlinkage unsigned long sys32_mremap(unsigned long addr,
898 unsigned long old_len, unsigned long new_len, 867 unsigned long old_len, unsigned long new_len,
899 unsigned long flags, u32 __new_addr) 868 unsigned long flags, u32 __new_addr)
900{ 869{
901 struct vm_area_struct *vma;
902 unsigned long ret = -EINVAL; 870 unsigned long ret = -EINVAL;
903 unsigned long new_addr = __new_addr; 871 unsigned long new_addr = __new_addr;
904 872
905 if (old_len > STACK_TOP32 || new_len > STACK_TOP32) 873 if (unlikely(sparc64_mmap_check(addr, old_len)))
906 goto out; 874 goto out;
907 if (addr > STACK_TOP32 - old_len) 875 if (unlikely(sparc64_mmap_check(new_addr, new_len)))
908 goto out; 876 goto out;
909 down_write(&current->mm->mmap_sem); 877 down_write(&current->mm->mmap_sem);
910 if (flags & MREMAP_FIXED) {
911 if (new_addr > STACK_TOP32 - new_len)
912 goto out_sem;
913 } else if (addr > STACK_TOP32 - new_len) {
914 unsigned long map_flags = 0;
915 struct file *file = NULL;
916
917 ret = -ENOMEM;
918 if (!(flags & MREMAP_MAYMOVE))
919 goto out_sem;
920
921 vma = find_vma(current->mm, addr);
922 if (vma) {
923 if (vma->vm_flags & VM_SHARED)
924 map_flags |= MAP_SHARED;
925 file = vma->vm_file;
926 }
927
928 /* MREMAP_FIXED checked above. */
929 new_addr = get_unmapped_area(file, addr, new_len,
930 vma ? vma->vm_pgoff : 0,
931 map_flags);
932 ret = new_addr;
933 if (new_addr & ~PAGE_MASK)
934 goto out_sem;
935 flags |= MREMAP_FIXED;
936 }
937 ret = do_mremap(addr, old_len, new_len, flags, new_addr); 878 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
938out_sem:
939 up_write(&current->mm->mmap_sem); 879 up_write(&current->mm->mmap_sem);
940out: 880out:
941 return ret; 881 return ret;
diff --git a/arch/sparc64/kernel/systbls.S b/arch/sparc64/kernel/systbls.S
index a4fef2ba1ae1..8b5282d433c4 100644
--- a/arch/sparc64/kernel/systbls.S
+++ b/arch/sparc64/kernel/systbls.S
@@ -45,7 +45,7 @@ sys_call_table32:
45/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod 45/*120*/ .word compat_sys_readv, compat_sys_writev, sys32_settimeofday, sys32_fchown16, sys_fchmod
46 .word sys_nis_syscall, sys32_setreuid16, sys32_setregid16, sys_rename, sys_truncate 46 .word sys_nis_syscall, sys32_setreuid16, sys32_setregid16, sys_rename, sys_truncate
47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall 47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, sys32_utimes, compat_sys_stat64 48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit 49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit
50 .word compat_sys_setrlimit, sys_pivot_root, sys32_prctl, sys_pciconfig_read, sys_pciconfig_write 50 .word compat_sys_setrlimit, sys_pivot_root, sys32_prctl, sys_pciconfig_read, sys_pciconfig_write
51/*150*/ .word sys_nis_syscall, sys_inotify_init, sys_inotify_add_watch, sys_poll, sys_getdents64 51/*150*/ .word sys_nis_syscall, sys_inotify_init, sys_inotify_add_watch, sys_poll, sys_getdents64
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index 4cad0b32b0af..a9828d748e2c 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -610,8 +610,6 @@ static void __init remap_kernel(void)
610 610
611static void __init inherit_prom_mappings(void) 611static void __init inherit_prom_mappings(void)
612{ 612{
613 read_obp_translations();
614
615 /* Now fixup OBP's idea about where we really are mapped. */ 613 /* Now fixup OBP's idea about where we really are mapped. */
616 printk("Remapping the kernel... "); 614 printk("Remapping the kernel... ");
617 remap_kernel(); 615 remap_kernel();
@@ -771,6 +769,9 @@ static void __init find_ramdisk(unsigned long phys_base)
771 initrd_end = ramdisk_image + sparc_ramdisk_size; 769 initrd_end = ramdisk_image + sparc_ramdisk_size;
772 770
773 lmb_reserve(initrd_start, initrd_end); 771 lmb_reserve(initrd_start, initrd_end);
772
773 initrd_start += PAGE_OFFSET;
774 initrd_end += PAGE_OFFSET;
774 } 775 }
775#endif 776#endif
776} 777}
@@ -1744,7 +1745,17 @@ void __init paging_init(void)
1744 1745
1745 lmb_init(); 1746 lmb_init();
1746 1747
1747 /* Find available physical memory... */ 1748 /* Find available physical memory...
1749 *
1750 * Read it twice in order to work around a bug in openfirmware.
1751 * The call to grab this table itself can cause openfirmware to
1752 * allocate memory, which in turn can take away some space from
1753 * the list of available memory. Reading it twice makes sure
1754 * we really do get the final value.
1755 */
1756 read_obp_translations();
1757 read_obp_memory("reg", &pall[0], &pall_ents);
1758 read_obp_memory("available", &pavail[0], &pavail_ents);
1748 read_obp_memory("available", &pavail[0], &pavail_ents); 1759 read_obp_memory("available", &pavail[0], &pavail_ents);
1749 1760
1750 phys_base = 0xffffffffffffffffUL; 1761 phys_base = 0xffffffffffffffffUL;
@@ -1785,8 +1796,6 @@ void __init paging_init(void)
1785 1796
1786 inherit_prom_mappings(); 1797 inherit_prom_mappings();
1787 1798
1788 read_obp_memory("reg", &pall[0], &pall_ents);
1789
1790 init_kpte_bitmap(); 1799 init_kpte_bitmap();
1791 1800
1792 /* Ok, we can use our TLB miss and window trap handlers safely. */ 1801 /* Ok, we can use our TLB miss and window trap handlers safely. */
@@ -2362,16 +2371,3 @@ void __flush_tlb_all(void)
2362 __asm__ __volatile__("wrpr %0, 0, %%pstate" 2371 __asm__ __volatile__("wrpr %0, 0, %%pstate"
2363 : : "r" (pstate)); 2372 : : "r" (pstate));
2364} 2373}
2365
2366#ifdef CONFIG_MEMORY_HOTPLUG
2367
2368void online_page(struct page *page)
2369{
2370 ClearPageReserved(page);
2371 init_page_count(page);
2372 __free_page(page);
2373 totalram_pages++;
2374 num_physpages++;
2375}
2376
2377#endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/um/Kconfig.char b/arch/um/Kconfig.char
index 3a4b396d7979..1b238ebae6b3 100644
--- a/arch/um/Kconfig.char
+++ b/arch/um/Kconfig.char
@@ -145,14 +145,14 @@ config LEGACY_PTYS
145 systems, it is safe to say N. 145 systems, it is safe to say N.
146 146
147config RAW_DRIVER 147config RAW_DRIVER
148 tristate "RAW driver (/dev/raw/rawN) (OBSOLETE)" 148 tristate "RAW driver (/dev/raw/rawN)"
149 depends on BLOCK
149 help 150 help
150 The raw driver permits block devices to be bound to /dev/raw/rawN. 151 The raw driver permits block devices to be bound to /dev/raw/rawN.
151 Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O. 152 Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O.
152 See the raw(8) manpage for more details. 153 See the raw(8) manpage for more details.
153 154
154 The raw driver is deprecated and will be removed soon. 155 Applications should preferably open the device (eg /dev/hda1)
155 Applications should simply open the device (eg /dev/hda1)
156 with the O_DIRECT flag. 156 with the O_DIRECT flag.
157 157
158config MAX_RAW_DEVS 158config MAX_RAW_DEVS
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 01b97c19a8ba..dbeab15e7bb7 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -77,10 +77,7 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
77KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 77KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
78 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 78 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
79KBUILD_CFLAGS += $(KERNEL_DEFINES) 79KBUILD_CFLAGS += $(KERNEL_DEFINES)
80# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use 80KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
81# a lot more stack due to the lack of sharing of stacklots:
82KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \
83 echo $(call cc-option,-fno-unit-at-a-time); fi ;)
84 81
85PHONY += linux 82PHONY += linux
86 83
diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
index 025764089ac8..cfeb3f4a44af 100644
--- a/arch/um/drivers/chan_user.c
+++ b/arch/um/drivers/chan_user.c
@@ -11,6 +11,7 @@
11#include <termios.h> 11#include <termios.h>
12#include <sys/ioctl.h> 12#include <sys/ioctl.h>
13#include "chan_user.h" 13#include "chan_user.h"
14#include "kern_constants.h"
14#include "os.h" 15#include "os.h"
15#include "um_malloc.h" 16#include "um_malloc.h"
16#include "user.h" 17#include "user.h"
diff --git a/arch/um/drivers/cow_sys.h b/arch/um/drivers/cow_sys.h
index ca8c9e11a39b..f5701fd2ef90 100644
--- a/arch/um/drivers/cow_sys.h
+++ b/arch/um/drivers/cow_sys.h
@@ -8,7 +8,7 @@
8 8
9static inline void *cow_malloc(int size) 9static inline void *cow_malloc(int size)
10{ 10{
11 return kmalloc(size, UM_GFP_KERNEL); 11 return uml_kmalloc(size, UM_GFP_KERNEL);
12} 12}
13 13
14static inline void cow_free(void *ptr) 14static inline void cow_free(void *ptr)
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c
index f23c109a055c..f8e85e0bdace 100644
--- a/arch/um/drivers/daemon_user.c
+++ b/arch/um/drivers/daemon_user.c
@@ -34,7 +34,7 @@ static struct sockaddr_un *new_addr(void *name, int len)
34{ 34{
35 struct sockaddr_un *sun; 35 struct sockaddr_un *sun;
36 36
37 sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); 37 sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
38 if (sun == NULL) { 38 if (sun == NULL) {
39 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " 39 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
40 "failed\n"); 40 "failed\n");
@@ -83,7 +83,7 @@ static int connect_to_switch(struct daemon_data *pri)
83 goto out_close; 83 goto out_close;
84 } 84 }
85 85
86 sun = kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL); 86 sun = uml_kmalloc(sizeof(struct sockaddr_un), UM_GFP_KERNEL);
87 if (sun == NULL) { 87 if (sun == NULL) {
88 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un " 88 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_un "
89 "failed\n"); 89 "failed\n");
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c
index 0a2bb5b64b82..f5a981a16240 100644
--- a/arch/um/drivers/fd.c
+++ b/arch/um/drivers/fd.c
@@ -40,7 +40,7 @@ static void *fd_init(char *str, int device, const struct chan_opts *opts)
40 return NULL; 40 return NULL;
41 } 41 }
42 42
43 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 43 data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
44 if (data == NULL) 44 if (data == NULL)
45 return NULL; 45 return NULL;
46 46
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index ff1b22b69e9c..368219cc2366 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -154,7 +154,7 @@ static int hostaudio_ioctl(struct inode *inode, struct file *file,
154 case SNDCTL_DSP_SUBDIVIDE: 154 case SNDCTL_DSP_SUBDIVIDE:
155 case SNDCTL_DSP_SETFRAGMENT: 155 case SNDCTL_DSP_SETFRAGMENT:
156 if (get_user(data, (int __user *) arg)) 156 if (get_user(data, (int __user *) arg))
157 return EFAULT; 157 return -EFAULT;
158 break; 158 break;
159 default: 159 default:
160 break; 160 break;
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 10b86e1cc659..5047490fc299 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -191,9 +191,9 @@ void line_flush_chars(struct tty_struct *tty)
191 line_flush_buffer(tty); 191 line_flush_buffer(tty);
192} 192}
193 193
194void line_put_char(struct tty_struct *tty, unsigned char ch) 194int line_put_char(struct tty_struct *tty, unsigned char ch)
195{ 195{
196 line_write(tty, &ch, sizeof(ch)); 196 return line_write(tty, &ch, sizeof(ch));
197} 197}
198 198
199int line_write(struct tty_struct *tty, const unsigned char *buf, int len) 199int line_write(struct tty_struct *tty, const unsigned char *buf, int len)
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index 5f647d7a7292..ee19e91568a2 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -15,6 +15,7 @@
15#include <unistd.h> 15#include <unistd.h>
16#include <errno.h> 16#include <errno.h>
17#include <netinet/in.h> 17#include <netinet/in.h>
18#include "kern_constants.h"
18#include "mcast.h" 19#include "mcast.h"
19#include "net_user.h" 20#include "net_user.h"
20#include "um_malloc.h" 21#include "um_malloc.h"
@@ -24,7 +25,7 @@ static struct sockaddr_in *new_addr(char *addr, unsigned short port)
24{ 25{
25 struct sockaddr_in *sin; 26 struct sockaddr_in *sin;
26 27
27 sin = kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL); 28 sin = uml_kmalloc(sizeof(struct sockaddr_in), UM_GFP_KERNEL);
28 if (sin == NULL) { 29 if (sin == NULL) {
29 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in " 30 printk(UM_KERN_ERR "new_addr: allocation of sockaddr_in "
30 "failed\n"); 31 "failed\n");
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index abf2653f5517..9415dd9e63ef 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -222,7 +222,7 @@ static void change(char *dev, char *what, unsigned char *addr,
222 netmask[2], netmask[3]); 222 netmask[2], netmask[3]);
223 223
224 output_len = UM_KERN_PAGE_SIZE; 224 output_len = UM_KERN_PAGE_SIZE;
225 output = kmalloc(output_len, UM_GFP_KERNEL); 225 output = uml_kmalloc(output_len, UM_GFP_KERNEL);
226 if (output == NULL) 226 if (output == NULL)
227 printk(UM_KERN_ERR "change : failed to allocate output " 227 printk(UM_KERN_ERR "change : failed to allocate output "
228 "buffer\n"); 228 "buffer\n");
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index d269ca387f10..b49bf56a56aa 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -47,7 +47,7 @@ static void *port_init(char *str, int device, const struct chan_opts *opts)
47 if (kern_data == NULL) 47 if (kern_data == NULL)
48 return NULL; 48 return NULL;
49 49
50 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 50 data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
51 if (data == NULL) 51 if (data == NULL)
52 goto err; 52 goto err;
53 53
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c
index 49c79dda6046..1113911dcb2b 100644
--- a/arch/um/drivers/pty.c
+++ b/arch/um/drivers/pty.c
@@ -29,7 +29,7 @@ static void *pty_chan_init(char *str, int device, const struct chan_opts *opts)
29{ 29{
30 struct pty_chan *data; 30 struct pty_chan *data;
31 31
32 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 32 data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 if (data == NULL) 33 if (data == NULL)
34 return NULL; 34 return NULL;
35 35
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index 71f0959c1535..4949044773ba 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -1,4 +1,5 @@
1/* Copyright (C) 2005 Jeff Dike <jdike@addtoit.com> */ 1/* Copyright (C) 2005 - 2008 Jeff Dike <jdike@{linux.intel,addtoit}.com> */
2
2/* Much of this ripped from drivers/char/hw_random.c, see there for other 3/* Much of this ripped from drivers/char/hw_random.c, see there for other
3 * copyright. 4 * copyright.
4 * 5 *
@@ -8,16 +9,18 @@
8#include <linux/sched.h> 9#include <linux/sched.h>
9#include <linux/module.h> 10#include <linux/module.h>
10#include <linux/fs.h> 11#include <linux/fs.h>
12#include <linux/interrupt.h>
11#include <linux/miscdevice.h> 13#include <linux/miscdevice.h>
12#include <linux/delay.h> 14#include <linux/delay.h>
13#include <asm/uaccess.h> 15#include <asm/uaccess.h>
16#include "irq_kern.h"
14#include "os.h" 17#include "os.h"
15 18
16/* 19/*
17 * core module and version information 20 * core module and version information
18 */ 21 */
19#define RNG_VERSION "1.0.0" 22#define RNG_VERSION "1.0.0"
20#define RNG_MODULE_NAME "random" 23#define RNG_MODULE_NAME "hw_random"
21 24
22#define RNG_MISCDEV_MINOR 183 /* official */ 25#define RNG_MISCDEV_MINOR 183 /* official */
23 26
@@ -26,47 +29,67 @@
26 * protects against a module being loaded twice at the same time. 29 * protects against a module being loaded twice at the same time.
27 */ 30 */
28static int random_fd = -1; 31static int random_fd = -1;
32static DECLARE_WAIT_QUEUE_HEAD(host_read_wait);
29 33
30static int rng_dev_open (struct inode *inode, struct file *filp) 34static int rng_dev_open (struct inode *inode, struct file *filp)
31{ 35{
32 /* enforce read-only access to this chrdev */ 36 /* enforce read-only access to this chrdev */
33 if ((filp->f_mode & FMODE_READ) == 0) 37 if ((filp->f_mode & FMODE_READ) == 0)
34 return -EINVAL; 38 return -EINVAL;
35 if (filp->f_mode & FMODE_WRITE) 39 if ((filp->f_mode & FMODE_WRITE) != 0)
36 return -EINVAL; 40 return -EINVAL;
37 41
38 return 0; 42 return 0;
39} 43}
40 44
45static atomic_t host_sleep_count = ATOMIC_INIT(0);
46
41static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size, 47static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
42 loff_t * offp) 48 loff_t *offp)
43{ 49{
44 u32 data; 50 u32 data;
45 int n, ret = 0, have_data; 51 int n, ret = 0, have_data;
46 52
47 while(size){ 53 while (size) {
48 n = os_read_file(random_fd, &data, sizeof(data)); 54 n = os_read_file(random_fd, &data, sizeof(data));
49 if(n > 0){ 55 if (n > 0) {
50 have_data = n; 56 have_data = n;
51 while (have_data && size) { 57 while (have_data && size) {
52 if (put_user((u8)data, buf++)) { 58 if (put_user((u8) data, buf++)) {
53 ret = ret ? : -EFAULT; 59 ret = ret ? : -EFAULT;
54 break; 60 break;
55 } 61 }
56 size--; 62 size--;
57 ret++; 63 ret++;
58 have_data--; 64 have_data--;
59 data>>=8; 65 data >>= 8;
60 } 66 }
61 } 67 }
62 else if(n == -EAGAIN){ 68 else if (n == -EAGAIN) {
63 if (filp->f_flags & O_NONBLOCK) 69 DECLARE_WAITQUEUE(wait, current);
64 return ret ? : -EAGAIN; 70
65 71 if (filp->f_flags & O_NONBLOCK)
66 if(need_resched()) 72 return ret ? : -EAGAIN;
67 schedule_timeout_interruptible(1); 73
68 } 74 atomic_inc(&host_sleep_count);
69 else return n; 75 reactivate_fd(random_fd, RANDOM_IRQ);
76 add_sigio_fd(random_fd);
77
78 add_wait_queue(&host_read_wait, &wait);
79 set_task_state(current, TASK_INTERRUPTIBLE);
80
81 schedule();
82 set_task_state(current, TASK_RUNNING);
83 remove_wait_queue(&host_read_wait, &wait);
84
85 if (atomic_dec_and_test(&host_sleep_count)) {
86 ignore_sigio_fd(random_fd);
87 deactivate_fd(random_fd, RANDOM_IRQ);
88 }
89 }
90 else
91 return n;
92
70 if (signal_pending (current)) 93 if (signal_pending (current))
71 return ret ? : -ERESTARTSYS; 94 return ret ? : -ERESTARTSYS;
72 } 95 }
@@ -86,6 +109,13 @@ static struct miscdevice rng_miscdev = {
86 &rng_chrdev_ops, 109 &rng_chrdev_ops,
87}; 110};
88 111
112static irqreturn_t random_interrupt(int irq, void *data)
113{
114 wake_up(&host_read_wait);
115
116 return IRQ_HANDLED;
117}
118
89/* 119/*
90 * rng_init - initialize RNG module 120 * rng_init - initialize RNG module
91 */ 121 */
@@ -93,28 +123,33 @@ static int __init rng_init (void)
93{ 123{
94 int err; 124 int err;
95 125
96 err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0); 126 err = os_open_file("/dev/random", of_read(OPENFLAGS()), 0);
97 if(err < 0) 127 if (err < 0)
98 goto out; 128 goto out;
99 129
100 random_fd = err; 130 random_fd = err;
101 131
102 err = os_set_fd_block(random_fd, 0); 132 err = um_request_irq(RANDOM_IRQ, random_fd, IRQ_READ, random_interrupt,
103 if(err) 133 IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "random",
134 NULL);
135 if (err)
104 goto err_out_cleanup_hw; 136 goto err_out_cleanup_hw;
105 137
138 sigio_broken(random_fd, 1);
139
106 err = misc_register (&rng_miscdev); 140 err = misc_register (&rng_miscdev);
107 if (err) { 141 if (err) {
108 printk (KERN_ERR RNG_MODULE_NAME ": misc device register failed\n"); 142 printk (KERN_ERR RNG_MODULE_NAME ": misc device register "
143 "failed\n");
109 goto err_out_cleanup_hw; 144 goto err_out_cleanup_hw;
110 } 145 }
146out:
147 return err;
111 148
112 out: 149err_out_cleanup_hw:
113 return err; 150 os_close_file(random_fd);
114 151 random_fd = -1;
115 err_out_cleanup_hw: 152 goto out;
116 random_fd = -1;
117 goto out;
118} 153}
119 154
120/* 155/*
@@ -122,6 +157,7 @@ static int __init rng_init (void)
122 */ 157 */
123static void __exit rng_cleanup (void) 158static void __exit rng_cleanup (void)
124{ 159{
160 os_close_file(random_fd);
125 misc_deregister (&rng_miscdev); 161 misc_deregister (&rng_miscdev);
126} 162}
127 163
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
index 8b80505a3fb0..a1c2d2c98a94 100644
--- a/arch/um/drivers/slip_user.c
+++ b/arch/um/drivers/slip_user.c
@@ -96,7 +96,7 @@ static int slip_tramp(char **argv, int fd)
96 pid = err; 96 pid = err;
97 97
98 output_len = UM_KERN_PAGE_SIZE; 98 output_len = UM_KERN_PAGE_SIZE;
99 output = kmalloc(output_len, UM_GFP_KERNEL); 99 output = uml_kmalloc(output_len, UM_GFP_KERNEL);
100 if (output == NULL) { 100 if (output == NULL) {
101 printk(UM_KERN_ERR "slip_tramp : failed to allocate output " 101 printk(UM_KERN_ERR "slip_tramp : failed to allocate output "
102 "buffer\n"); 102 "buffer\n");
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c
index c930fedc5172..495858a090e4 100644
--- a/arch/um/drivers/tty.c
+++ b/arch/um/drivers/tty.c
@@ -29,7 +29,7 @@ static void *tty_chan_init(char *str, int device, const struct chan_opts *opts)
29 } 29 }
30 str++; 30 str++;
31 31
32 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 32 data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
33 if (data == NULL) 33 if (data == NULL)
34 return NULL; 34 return NULL;
35 *data = ((struct tty_chan) { .dev = str, 35 *data = ((struct tty_chan) { .dev = str,
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 5e45e39a8a8d..44ad1607be2d 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1178,8 +1178,8 @@ static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,
1178 * by one word. Thanks to Lynn Kerby for the fix and James McMechan 1178 * by one word. Thanks to Lynn Kerby for the fix and James McMechan
1179 * for the original diagnosis. 1179 * for the original diagnosis.
1180 */ 1180 */
1181 if(*cow_offset == ((bitmap_len + sizeof(unsigned long) - 1) / 1181 if (*cow_offset == (DIV_ROUND_UP(bitmap_len,
1182 sizeof(unsigned long) - 1)) 1182 sizeof(unsigned long)) - 1))
1183 (*cow_offset)--; 1183 (*cow_offset)--;
1184 1184
1185 bitmap_words[0] = bitmap[*cow_offset]; 1185 bitmap_words[0] = bitmap[*cow_offset];
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index 8a1c18a9b240..da2caa5a21ef 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -30,7 +30,7 @@ static void *xterm_init(char *str, int device, const struct chan_opts *opts)
30{ 30{
31 struct xterm_chan *data; 31 struct xterm_chan *data;
32 32
33 data = kmalloc(sizeof(*data), UM_GFP_KERNEL); 33 data = uml_kmalloc(sizeof(*data), UM_GFP_KERNEL);
34 if (data == NULL) 34 if (data == NULL)
35 return NULL; 35 return NULL;
36 *data = ((struct xterm_chan) { .pid = -1, 36 *data = ((struct xterm_chan) { .pid = -1,
diff --git a/arch/um/include/as-layout.h b/arch/um/include/as-layout.h
index cac542d8ff70..58e852dfb0ce 100644
--- a/arch/um/include/as-layout.h
+++ b/arch/um/include/as-layout.h
@@ -23,16 +23,16 @@
23 */ 23 */
24 24
25#ifdef __ASSEMBLY__ 25#ifdef __ASSEMBLY__
26#define _AC(X, Y) (Y) 26#define _UML_AC(X, Y) (Y)
27#else 27#else
28#define __AC(X, Y) (X (Y)) 28#define __UML_AC(X, Y) (X(Y))
29#define _AC(X, Y) __AC(X, Y) 29#define _UML_AC(X, Y) __UML_AC(X, Y)
30#endif 30#endif
31 31
32#define STUB_START _AC(, 0x100000) 32#define STUB_START _UML_AC(, 0x100000)
33#define STUB_CODE _AC((unsigned long), STUB_START) 33#define STUB_CODE _UML_AC((unsigned long), STUB_START)
34#define STUB_DATA _AC((unsigned long), STUB_CODE + UM_KERN_PAGE_SIZE) 34#define STUB_DATA _UML_AC((unsigned long), STUB_CODE + UM_KERN_PAGE_SIZE)
35#define STUB_END _AC((unsigned long), STUB_DATA + UM_KERN_PAGE_SIZE) 35#define STUB_END _UML_AC((unsigned long), STUB_DATA + UM_KERN_PAGE_SIZE)
36 36
37#ifndef __ASSEMBLY__ 37#ifndef __ASSEMBLY__
38 38
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 1223f2c844b4..311a0d3d93af 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -58,11 +58,11 @@ struct line {
58}; 58};
59 59
60#define LINE_INIT(str, d) \ 60#define LINE_INIT(str, d) \
61 { .count_lock = SPIN_LOCK_UNLOCKED, \ 61 { .count_lock = __SPIN_LOCK_UNLOCKED((str).count_lock), \
62 .init_str = str, \ 62 .init_str = str, \
63 .init_pri = INIT_STATIC, \ 63 .init_pri = INIT_STATIC, \
64 .valid = 1, \ 64 .valid = 1, \
65 .lock = SPIN_LOCK_UNLOCKED, \ 65 .lock = __SPIN_LOCK_UNLOCKED((str).lock), \
66 .driver = d } 66 .driver = d }
67 67
68extern void line_close(struct tty_struct *tty, struct file * filp); 68extern void line_close(struct tty_struct *tty, struct file * filp);
@@ -71,7 +71,7 @@ extern int line_setup(struct line *lines, unsigned int sizeof_lines,
71 char *init, char **error_out); 71 char *init, char **error_out);
72extern int line_write(struct tty_struct *tty, const unsigned char *buf, 72extern int line_write(struct tty_struct *tty, const unsigned char *buf,
73 int len); 73 int len);
74extern void line_put_char(struct tty_struct *tty, unsigned char ch); 74extern int line_put_char(struct tty_struct *tty, unsigned char ch);
75extern void line_set_termios(struct tty_struct *tty, struct ktermios * old); 75extern void line_set_termios(struct tty_struct *tty, struct ktermios * old);
76extern int line_chars_in_buffer(struct tty_struct *tty); 76extern int line_chars_in_buffer(struct tty_struct *tty);
77extern void line_flush_buffer(struct tty_struct *tty); 77extern void line_flush_buffer(struct tty_struct *tty);
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 32c799e3a495..e2716ac8889a 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -290,6 +290,7 @@ extern void os_set_ioignore(void);
290extern int add_sigio_fd(int fd); 290extern int add_sigio_fd(int fd);
291extern int ignore_sigio_fd(int fd); 291extern int ignore_sigio_fd(int fd);
292extern void maybe_sigio_broken(int fd, int read); 292extern void maybe_sigio_broken(int fd, int read);
293extern void sigio_broken(int fd, int read);
293 294
294/* sys-x86_64/prctl.c */ 295/* sys-x86_64/prctl.c */
295extern int os_arch_prctl(int pid, int code, unsigned long *addr); 296extern int os_arch_prctl(int pid, int code, unsigned long *addr);
diff --git a/arch/um/include/process.h b/arch/um/include/process.h
index 5af9157ff54f..bb873a51262e 100644
--- a/arch/um/include/process.h
+++ b/arch/um/include/process.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
@@ -8,18 +8,10 @@
8 8
9#include <signal.h> 9#include <signal.h>
10 10
11extern void sig_handler(int sig, struct sigcontext sc); 11/* Copied from linux/compiler-gcc.h since we can't include it directly */
12extern void alarm_handler(int sig, struct sigcontext sc); 12#define barrier() __asm__ __volatile__("": : :"memory")
13 13
14#endif 14extern void sig_handler(int sig, struct sigcontext *sc);
15extern void alarm_handler(int sig, struct sigcontext *sc);
15 16
16/* 17#endif
17 * Overrides for Emacs so that we follow Linus's tabbing style.
18 * Emacs will notice this stuff at the end of the file and automatically
19 * adjust the settings for this buffer only. This must remain at the end
20 * of the file.
21 * ---------------------------------------------------------------------------
22 * Local variables:
23 * c-file-style: "linux"
24 * End:
25 */
diff --git a/arch/um/include/skas_ptrace.h b/arch/um/include/skas_ptrace.h
index cd2327d09c8d..3d31bbacd016 100644
--- a/arch/um/include/skas_ptrace.h
+++ b/arch/um/include/skas_ptrace.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
@@ -12,14 +12,3 @@
12#include "sysdep/skas_ptrace.h" 12#include "sysdep/skas_ptrace.h"
13 13
14#endif 14#endif
15
16/*
17 * Overrides for Emacs so that we follow Linus's tabbing style.
18 * Emacs will notice this stuff at the end of the file and automatically
19 * adjust the settings for this buffer only. This must remain at the end
20 * of the file.
21 * ---------------------------------------------------------------------------
22 * Local variables:
23 * c-file-style: "linux"
24 * End:
25 */
diff --git a/arch/um/include/sysdep-i386/ptrace_user.h b/arch/um/include/sysdep-i386/ptrace_user.h
index 75650723c38f..ef56247e4143 100644
--- a/arch/um/include/sysdep-i386/ptrace_user.h
+++ b/arch/um/include/sysdep-i386/ptrace_user.h
@@ -41,38 +41,10 @@
41#define PT_SP_OFFSET PT_OFFSET(UESP) 41#define PT_SP_OFFSET PT_OFFSET(UESP)
42#define PT_SP(regs) ((regs)[UESP]) 42#define PT_SP(regs) ((regs)[UESP])
43 43
44#define FP_SIZE ((HOST_XFP_SIZE > HOST_FP_SIZE) ? HOST_XFP_SIZE : HOST_FP_SIZE) 44#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE)
45 45
46#ifndef FRAME_SIZE 46#ifndef FRAME_SIZE
47#define FRAME_SIZE (17) 47#define FRAME_SIZE (17)
48#endif 48#endif
49#define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long))
50
51#define FP_FRAME_SIZE (27)
52#define FPX_FRAME_SIZE (128)
53
54#ifdef PTRACE_GETREGS
55#define UM_HAVE_GETREGS
56#endif
57
58#ifdef PTRACE_SETREGS
59#define UM_HAVE_SETREGS
60#endif
61
62#ifdef PTRACE_GETFPREGS
63#define UM_HAVE_GETFPREGS
64#endif
65
66#ifdef PTRACE_SETFPREGS
67#define UM_HAVE_SETFPREGS
68#endif
69
70#ifdef PTRACE_GETFPXREGS
71#define UM_HAVE_GETFPXREGS
72#endif
73
74#ifdef PTRACE_SETFPXREGS
75#define UM_HAVE_SETFPXREGS
76#endif
77 49
78#endif 50#endif
diff --git a/arch/um/include/sysdep-i386/sigcontext.h b/arch/um/include/sysdep-i386/sigcontext.h
index 67e77122aa45..f583c87111a0 100644
--- a/arch/um/include/sysdep-i386/sigcontext.h
+++ b/arch/um/include/sysdep-i386/sigcontext.h
@@ -10,7 +10,7 @@
10 10
11#define IP_RESTART_SYSCALL(ip) ((ip) -= 2) 11#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
12 12
13#define GET_FAULTINFO_FROM_SC(fi,sc) \ 13#define GET_FAULTINFO_FROM_SC(fi, sc) \
14 { \ 14 { \
15 (fi).cr2 = SC_CR2(sc); \ 15 (fi).cr2 = SC_CR2(sc); \
16 (fi).error_code = SC_ERR(sc); \ 16 (fi).error_code = SC_ERR(sc); \
diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/include/sysdep-x86_64/ptrace_user.h
index 45c0bd881cb3..4dbccdb58f48 100644
--- a/arch/um/include/sysdep-x86_64/ptrace_user.h
+++ b/arch/um/include/sysdep-x86_64/ptrace_user.h
@@ -48,7 +48,8 @@
48#define PT_ORIG_RAX_OFFSET (ORIG_RAX) 48#define PT_ORIG_RAX_OFFSET (ORIG_RAX)
49#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) 49#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
50 50
51/* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though 51/*
52 * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
52 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the 53 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
53 * 2.4 name and value for 2.4 host compatibility. 54 * 2.4 name and value for 2.4 host compatibility.
54 */ 55 */
@@ -56,7 +57,8 @@
56#define PTRACE_OLDSETOPTIONS 21 57#define PTRACE_OLDSETOPTIONS 21
57#endif 58#endif
58 59
59/* These are before the system call, so the system call number is RAX 60/*
61 * These are before the system call, so the system call number is RAX
60 * rather than ORIG_RAX, and arg4 is R10 rather than RCX 62 * rather than ORIG_RAX, and arg4 is R10 rather than RCX
61 */ 63 */
62#define REGS_SYSCALL_NR PT_INDEX(RAX) 64#define REGS_SYSCALL_NR PT_INDEX(RAX)
@@ -73,14 +75,3 @@
73#define FP_SIZE (HOST_FP_SIZE) 75#define FP_SIZE (HOST_FP_SIZE)
74 76
75#endif 77#endif
76
77/*
78 * Overrides for Emacs so that we follow Linus's tabbing style.
79 * Emacs will notice this stuff at the end of the file and automatically
80 * adjust the settings for this buffer only. This must remain at the end
81 * of the file.
82 * ---------------------------------------------------------------------------
83 * Local variables:
84 * c-file-style: "linux"
85 * End:
86 */
diff --git a/arch/um/include/um_malloc.h b/arch/um/include/um_malloc.h
index 0ad17cb83d96..c554d706d106 100644
--- a/arch/um/include/um_malloc.h
+++ b/arch/um/include/um_malloc.h
@@ -8,15 +8,12 @@
8 8
9#include "kern_constants.h" 9#include "kern_constants.h"
10 10
11extern void *__kmalloc(int size, int flags); 11extern void *uml_kmalloc(int size, int flags);
12static inline void *kmalloc(int size, int flags)
13{
14 return __kmalloc(size, flags);
15}
16
17extern void kfree(const void *ptr); 12extern void kfree(const void *ptr);
18 13
19extern void *vmalloc(unsigned long size); 14extern void *vmalloc(unsigned long size);
20extern void vfree(void *ptr); 15extern void vfree(void *ptr);
21 16
22#endif /* __UM_MALLOC_H__ */ 17#endif /* __UM_MALLOC_H__ */
18
19
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 26090b7f323e..9975e1ab44fb 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -1,4 +1,5 @@
1#include <asm-generic/vmlinux.lds.h> 1#include <asm-generic/vmlinux.lds.h>
2#include <asm/page.h>
2 3
3OUTPUT_FORMAT(ELF_FORMAT) 4OUTPUT_FORMAT(ELF_FORMAT)
4OUTPUT_ARCH(ELF_ARCH) 5OUTPUT_ARCH(ELF_ARCH)
@@ -21,7 +22,7 @@ SECTIONS
21 _einittext = .; 22 _einittext = .;
22 } 23 }
23 24
24 . = ALIGN(4096); 25 . = ALIGN(PAGE_SIZE);
25 26
26 /* Read-only sections, merged into text segment: */ 27 /* Read-only sections, merged into text segment: */
27 .hash : { *(.hash) } 28 .hash : { *(.hash) }
@@ -68,9 +69,9 @@ SECTIONS
68 /* .gnu.warning sections are handled specially by elf32.em. */ 69 /* .gnu.warning sections are handled specially by elf32.em. */
69 *(.gnu.warning) 70 *(.gnu.warning)
70 71
71 . = ALIGN(4096); 72 . = ALIGN(PAGE_SIZE);
72 } =0x90909090 73 } =0x90909090
73 . = ALIGN(4096); 74 . = ALIGN(PAGE_SIZE);
74 .syscall_stub : { 75 .syscall_stub : {
75 __syscall_stub_start = .; 76 __syscall_stub_start = .;
76 *(.__syscall_stub*) 77 *(.__syscall_stub*)
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 2eea1ff235e6..b0ee64622ff7 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -375,3 +375,8 @@ pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
375 return pmd; 375 return pmd;
376} 376}
377#endif 377#endif
378
379void *uml_kmalloc(int size, int flags)
380{
381 return kmalloc(size, flags);
382}
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 0d0cea2ac98d..c3e2f369c33c 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -75,7 +75,7 @@ static irqreturn_t um_timer(int irq, void *dev)
75 75
76static cycle_t itimer_read(void) 76static cycle_t itimer_read(void)
77{ 77{
78 return os_nsecs(); 78 return os_nsecs() / 1000;
79} 79}
80 80
81static struct clocksource itimer_clocksource = { 81static struct clocksource itimer_clocksource = {
@@ -83,7 +83,7 @@ static struct clocksource itimer_clocksource = {
83 .rating = 300, 83 .rating = 300,
84 .read = itimer_read, 84 .read = itimer_read,
85 .mask = CLOCKSOURCE_MASK(64), 85 .mask = CLOCKSOURCE_MASK(64),
86 .mult = 1, 86 .mult = 1000,
87 .shift = 0, 87 .shift = 0,
88 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 88 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
89}; 89};
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 56deed623446..9db85b2ce698 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -150,7 +150,7 @@ __uml_setup("root=", uml_root_setup,
150static int __init no_skas_debug_setup(char *line, int *add) 150static int __init no_skas_debug_setup(char *line, int *add)
151{ 151{
152 printf("'debug' is not necessary to gdb UML in skas mode - run \n"); 152 printf("'debug' is not necessary to gdb UML in skas mode - run \n");
153 printf("'gdb linux'"); 153 printf("'gdb linux'\n");
154 154
155 return 0; 155 return 0;
156} 156}
@@ -258,6 +258,7 @@ int __init linux_main(int argc, char **argv)
258{ 258{
259 unsigned long avail, diff; 259 unsigned long avail, diff;
260 unsigned long virtmem_size, max_physmem; 260 unsigned long virtmem_size, max_physmem;
261 unsigned long stack;
261 unsigned int i; 262 unsigned int i;
262 int add; 263 int add;
263 char * mode; 264 char * mode;
@@ -348,7 +349,9 @@ int __init linux_main(int argc, char **argv)
348 } 349 }
349 350
350 virtmem_size = physmem_size; 351 virtmem_size = physmem_size;
351 avail = TASK_SIZE - start_vm; 352 stack = (unsigned long) argv;
353 stack &= ~(1024 * 1024 - 1);
354 avail = stack - start_vm;
352 if (physmem_size > avail) 355 if (physmem_size > avail)
353 virtmem_size = avail; 356 virtmem_size = avail;
354 end_vm = start_vm + virtmem_size; 357 end_vm = start_vm + virtmem_size;
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index 5828c1d54505..11b835248b86 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -1,4 +1,5 @@
1#include <asm-generic/vmlinux.lds.h> 1#include <asm-generic/vmlinux.lds.h>
2#include <asm/page.h>
2 3
3OUTPUT_FORMAT(ELF_FORMAT) 4OUTPUT_FORMAT(ELF_FORMAT)
4OUTPUT_ARCH(ELF_ARCH) 5OUTPUT_ARCH(ELF_ARCH)
@@ -26,7 +27,7 @@ SECTIONS
26 INIT_TEXT 27 INIT_TEXT
27 _einittext = .; 28 _einittext = .;
28 } 29 }
29 . = ALIGN(4096); 30 . = ALIGN(PAGE_SIZE);
30 31
31 .text : 32 .text :
32 { 33 {
@@ -39,7 +40,7 @@ SECTIONS
39 *(.gnu.linkonce.t*) 40 *(.gnu.linkonce.t*)
40 } 41 }
41 42
42 . = ALIGN(4096); 43 . = ALIGN(PAGE_SIZE);
43 .syscall_stub : { 44 .syscall_stub : {
44 __syscall_stub_start = .; 45 __syscall_stub_start = .;
45 *(.__syscall_stub*) 46 *(.__syscall_stub*)
@@ -79,7 +80,7 @@ SECTIONS
79 .sdata : { *(.sdata) } 80 .sdata : { *(.sdata) }
80 _edata = .; 81 _edata = .;
81 PROVIDE (edata = .); 82 PROVIDE (edata = .);
82 . = ALIGN(0x1000); 83 . = ALIGN(PAGE_SIZE);
83 .sbss : 84 .sbss :
84 { 85 {
85 __bss_start = .; 86 __bss_start = .;
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index 6fb0b174f538..cc72cb2c1af6 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -52,7 +52,7 @@ static void etap_change(int op, unsigned char *addr, unsigned char *netmask,
52 return; 52 return;
53 } 53 }
54 54
55 output = kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL); 55 output = uml_kmalloc(UM_KERN_PAGE_SIZE, UM_GFP_KERNEL);
56 if (output == NULL) 56 if (output == NULL)
57 printk(UM_KERN_ERR "etap_change : Failed to allocate output " 57 printk(UM_KERN_ERR "etap_change : Failed to allocate output "
58 "buffer\n"); 58 "buffer\n");
@@ -165,7 +165,7 @@ static int etap_open(void *data)
165 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0], 165 err = etap_tramp(pri->dev_name, pri->gate_addr, control_fds[0],
166 control_fds[1], data_fds[0], data_fds[1]); 166 control_fds[1], data_fds[0], data_fds[1]);
167 output_len = UM_KERN_PAGE_SIZE; 167 output_len = UM_KERN_PAGE_SIZE;
168 output = kmalloc(output_len, UM_GFP_KERNEL); 168 output = uml_kmalloc(output_len, UM_GFP_KERNEL);
169 read_output(control_fds[0], output, output_len); 169 read_output(control_fds[0], output, output_len);
170 170
171 if (output == NULL) 171 if (output == NULL)
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index f25c29a12d00..74ca7aabf4e1 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -71,8 +71,8 @@ int run_helper(void (*pre_exec)(void *), void *pre_data, char **argv)
71 data.pre_data = pre_data; 71 data.pre_data = pre_data;
72 data.argv = argv; 72 data.argv = argv;
73 data.fd = fds[1]; 73 data.fd = fds[1];
74 data.buf = __cant_sleep() ? kmalloc(PATH_MAX, UM_GFP_ATOMIC) : 74 data.buf = __cant_sleep() ? uml_kmalloc(PATH_MAX, UM_GFP_ATOMIC) :
75 kmalloc(PATH_MAX, UM_GFP_KERNEL); 75 uml_kmalloc(PATH_MAX, UM_GFP_KERNEL);
76 pid = clone(helper_child, (void *) sp, CLONE_VM, &data); 76 pid = clone(helper_child, (void *) sp, CLONE_VM, &data);
77 if (pid < 0) { 77 if (pid < 0) {
78 ret = -errno; 78 ret = -errno;
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index abb9b0ffd960..eee69b9f52c9 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -199,7 +199,7 @@ void *__wrap_malloc(int size)
199 return __real_malloc(size); 199 return __real_malloc(size);
200 else if (size <= UM_KERN_PAGE_SIZE) 200 else if (size <= UM_KERN_PAGE_SIZE)
201 /* finding contiguous pages can be hard*/ 201 /* finding contiguous pages can be hard*/
202 ret = kmalloc(size, UM_GFP_KERNEL); 202 ret = uml_kmalloc(size, UM_GFP_KERNEL);
203 else ret = vmalloc(size); 203 else ret = vmalloc(size);
204 204
205 /* 205 /*
diff --git a/arch/um/os-Linux/sigio.c b/arch/um/os-Linux/sigio.c
index abf47a7c4abd..eb8f2e4be192 100644
--- a/arch/um/os-Linux/sigio.c
+++ b/arch/um/os-Linux/sigio.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 2 * Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
@@ -15,6 +15,7 @@
15#include "kern_util.h" 15#include "kern_util.h"
16#include "init.h" 16#include "init.h"
17#include "os.h" 17#include "os.h"
18#include "process.h"
18#include "sigio.h" 19#include "sigio.h"
19#include "um_malloc.h" 20#include "um_malloc.h"
20#include "user.h" 21#include "user.h"
@@ -109,7 +110,7 @@ static int need_poll(struct pollfds *polls, int n)
109 if (n <= polls->size) 110 if (n <= polls->size)
110 return 0; 111 return 0;
111 112
112 new = kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC); 113 new = uml_kmalloc(n * sizeof(struct pollfd), UM_GFP_ATOMIC);
113 if (new == NULL) { 114 if (new == NULL) {
114 printk(UM_KERN_ERR "need_poll : failed to allocate new " 115 printk(UM_KERN_ERR "need_poll : failed to allocate new "
115 "pollfds\n"); 116 "pollfds\n");
@@ -243,7 +244,7 @@ static struct pollfd *setup_initial_poll(int fd)
243{ 244{
244 struct pollfd *p; 245 struct pollfd *p;
245 246
246 p = kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL); 247 p = uml_kmalloc(sizeof(struct pollfd), UM_GFP_KERNEL);
247 if (p == NULL) { 248 if (p == NULL) {
248 printk(UM_KERN_ERR "setup_initial_poll : failed to allocate " 249 printk(UM_KERN_ERR "setup_initial_poll : failed to allocate "
249 "poll\n"); 250 "poll\n");
@@ -338,20 +339,10 @@ out_close1:
338 close(l_write_sigio_fds[1]); 339 close(l_write_sigio_fds[1]);
339} 340}
340 341
341/* Changed during early boot */ 342void sigio_broken(int fd, int read)
342static int pty_output_sigio = 0;
343static int pty_close_sigio = 0;
344
345void maybe_sigio_broken(int fd, int read)
346{ 343{
347 int err; 344 int err;
348 345
349 if (!isatty(fd))
350 return;
351
352 if ((read || pty_output_sigio) && (!read || pty_close_sigio))
353 return;
354
355 write_sigio_workaround(); 346 write_sigio_workaround();
356 347
357 sigio_lock(); 348 sigio_lock();
@@ -370,6 +361,21 @@ out:
370 sigio_unlock(); 361 sigio_unlock();
371} 362}
372 363
364/* Changed during early boot */
365static int pty_output_sigio;
366static int pty_close_sigio;
367
368void maybe_sigio_broken(int fd, int read)
369{
370 if (!isatty(fd))
371 return;
372
373 if ((read || pty_output_sigio) && (!read || pty_close_sigio))
374 return;
375
376 sigio_broken(fd, read);
377}
378
373static void sigio_cleanup(void) 379static void sigio_cleanup(void)
374{ 380{
375 if (write_sigio_pid == -1) 381 if (write_sigio_pid == -1)
@@ -383,7 +389,7 @@ static void sigio_cleanup(void)
383__uml_exitcall(sigio_cleanup); 389__uml_exitcall(sigio_cleanup);
384 390
385/* Used as a flag during SIGIO testing early in boot */ 391/* Used as a flag during SIGIO testing early in boot */
386static volatile int got_sigio = 0; 392static int got_sigio;
387 393
388static void __init handler(int sig) 394static void __init handler(int sig)
389{ 395{
@@ -498,7 +504,8 @@ static void tty_output(int master, int slave)
498 if (errno != EAGAIN) 504 if (errno != EAGAIN)
499 printk(UM_KERN_ERR "tty_output : write failed, errno = %d\n", 505 printk(UM_KERN_ERR "tty_output : write failed, errno = %d\n",
500 errno); 506 errno);
501 while (((n = read(slave, buf, sizeof(buf))) > 0) && !got_sigio) 507 while (((n = read(slave, buf, sizeof(buf))) > 0) &&
508 !({ barrier(); got_sigio; }))
502 ; 509 ;
503 510
504 if (got_sigio) { 511 if (got_sigio) {
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index 3f1694b134cb..5aade6027e40 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -12,6 +12,7 @@
12#include "as-layout.h" 12#include "as-layout.h"
13#include "kern_util.h" 13#include "kern_util.h"
14#include "os.h" 14#include "os.h"
15#include "process.h"
15#include "sysdep/barrier.h" 16#include "sysdep/barrier.h"
16#include "sysdep/sigcontext.h" 17#include "sysdep/sigcontext.h"
17#include "user.h" 18#include "user.h"
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 1e8cba6550a9..6be028ca1817 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -442,7 +442,7 @@ void userspace(struct uml_pt_regs *regs)
442 unblock_signals(); 442 unblock_signals();
443 break; 443 break;
444 default: 444 default:
445 printk(UM_KERN_ERR "userspace - child stopped " 445 printk(UM_KERN_ERR "userspace - child stopped "
446 "with signal %d\n", sig); 446 "with signal %d\n", sig);
447 fatal_sigsegv(); 447 fatal_sigsegv();
448 } 448 }
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index 997d01944f91..b4b36e0f2e89 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -23,6 +23,7 @@
23#include "mem_user.h" 23#include "mem_user.h"
24#include "ptrace_user.h" 24#include "ptrace_user.h"
25#include "registers.h" 25#include "registers.h"
26#include "skas.h"
26#include "skas_ptrace.h" 27#include "skas_ptrace.h"
27 28
28static void ptrace_child(void) 29static void ptrace_child(void)
@@ -140,14 +141,27 @@ static int stop_ptraced_child(int pid, int exitcode, int mustexit)
140} 141}
141 142
142/* Changed only during early boot */ 143/* Changed only during early boot */
143int ptrace_faultinfo = 1; 144int ptrace_faultinfo;
144int ptrace_ldt = 1; 145static int disable_ptrace_faultinfo;
145int proc_mm = 1; 146
146int skas_needs_stub = 0; 147int ptrace_ldt;
148static int disable_ptrace_ldt;
149
150int proc_mm;
151static int disable_proc_mm;
152
153int have_switch_mm;
154static int disable_switch_mm;
155
156int skas_needs_stub;
147 157
148static int __init skas0_cmd_param(char *str, int* add) 158static int __init skas0_cmd_param(char *str, int* add)
149{ 159{
150 ptrace_faultinfo = proc_mm = 0; 160 disable_ptrace_faultinfo = 1;
161 disable_ptrace_ldt = 1;
162 disable_proc_mm = 1;
163 disable_switch_mm = 1;
164
151 return 0; 165 return 0;
152} 166}
153 167
@@ -157,15 +171,12 @@ static int __init mode_skas0_cmd_param(char *str, int* add)
157 __attribute__((alias("skas0_cmd_param"))); 171 __attribute__((alias("skas0_cmd_param")));
158 172
159__uml_setup("skas0", skas0_cmd_param, 173__uml_setup("skas0", skas0_cmd_param,
160 "skas0\n" 174"skas0\n"
161 " Disables SKAS3 usage, so that SKAS0 is used, unless \n" 175" Disables SKAS3 and SKAS4 usage, so that SKAS0 is used\n\n");
162 " you specify mode=tt.\n\n");
163 176
164__uml_setup("mode=skas0", mode_skas0_cmd_param, 177__uml_setup("mode=skas0", mode_skas0_cmd_param,
165 "mode=skas0\n" 178"mode=skas0\n"
166 " Disables SKAS3 usage, so that SKAS0 is used, unless you \n" 179" Disables SKAS3 and SKAS4 usage, so that SKAS0 is used.\n\n");
167 " specify mode=tt. Note that this was recently added - on \n"
168 " older kernels you must use simply \"skas0\".\n\n");
169 180
170/* Changed only during early boot */ 181/* Changed only during early boot */
171static int force_sysemu_disabled = 0; 182static int force_sysemu_disabled = 0;
@@ -360,7 +371,7 @@ void __init os_early_checks(void)
360 371
361static int __init noprocmm_cmd_param(char *str, int* add) 372static int __init noprocmm_cmd_param(char *str, int* add)
362{ 373{
363 proc_mm = 0; 374 disable_proc_mm = 1;
364 return 0; 375 return 0;
365} 376}
366 377
@@ -372,7 +383,7 @@ __uml_setup("noprocmm", noprocmm_cmd_param,
372 383
373static int __init noptracefaultinfo_cmd_param(char *str, int* add) 384static int __init noptracefaultinfo_cmd_param(char *str, int* add)
374{ 385{
375 ptrace_faultinfo = 0; 386 disable_ptrace_faultinfo = 1;
376 return 0; 387 return 0;
377} 388}
378 389
@@ -384,7 +395,7 @@ __uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param,
384 395
385static int __init noptraceldt_cmd_param(char *str, int* add) 396static int __init noptraceldt_cmd_param(char *str, int* add)
386{ 397{
387 ptrace_ldt = 0; 398 disable_ptrace_ldt = 1;
388 return 0; 399 return 0;
389} 400}
390 401
@@ -404,17 +415,15 @@ static inline void check_skas3_ptrace_faultinfo(void)
404 415
405 n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); 416 n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi);
406 if (n < 0) { 417 if (n < 0) {
407 ptrace_faultinfo = 0;
408 if (errno == EIO) 418 if (errno == EIO)
409 non_fatal("not found\n"); 419 non_fatal("not found\n");
410 else 420 else
411 perror("not found"); 421 perror("not found");
412 } 422 } else if (disable_ptrace_faultinfo)
423 non_fatal("found but disabled on command line\n");
413 else { 424 else {
414 if (!ptrace_faultinfo) 425 ptrace_faultinfo = 1;
415 non_fatal("found but disabled on command line\n"); 426 non_fatal("found\n");
416 else
417 non_fatal("found\n");
418 } 427 }
419 428
420 stop_ptraced_child(pid, 1, 1); 429 stop_ptraced_child(pid, 1, 1);
@@ -437,38 +446,30 @@ static inline void check_skas3_ptrace_ldt(void)
437 if (n < 0) { 446 if (n < 0) {
438 if (errno == EIO) 447 if (errno == EIO)
439 non_fatal("not found\n"); 448 non_fatal("not found\n");
440 else { 449 else
441 perror("not found"); 450 perror("not found");
442 } 451 } else if (disable_ptrace_ldt)
443 ptrace_ldt = 0; 452 non_fatal("found, but use is disabled\n");
444 }
445 else { 453 else {
446 if (ptrace_ldt) 454 ptrace_ldt = 1;
447 non_fatal("found\n"); 455 non_fatal("found\n");
448 else
449 non_fatal("found, but use is disabled\n");
450 } 456 }
451 457
452 stop_ptraced_child(pid, 1, 1); 458 stop_ptraced_child(pid, 1, 1);
453#else
454 /* PTRACE_LDT might be disabled via cmdline option.
455 * We want to override this, else we might use the stub
456 * without real need
457 */
458 ptrace_ldt = 1;
459#endif 459#endif
460} 460}
461 461
462static inline void check_skas3_proc_mm(void) 462static inline void check_skas3_proc_mm(void)
463{ 463{
464 non_fatal(" - /proc/mm..."); 464 non_fatal(" - /proc/mm...");
465 if (access("/proc/mm", W_OK) < 0) { 465 if (access("/proc/mm", W_OK) < 0)
466 proc_mm = 0;
467 perror("not found"); 466 perror("not found");
468 } 467 else if (disable_proc_mm)
469 else if (!proc_mm)
470 non_fatal("found but disabled on command line\n"); 468 non_fatal("found but disabled on command line\n");
471 else non_fatal("found\n"); 469 else {
470 proc_mm = 1;
471 non_fatal("found\n");
472 }
472} 473}
473 474
474void can_do_skas(void) 475void can_do_skas(void)
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c
index b613473b3ec1..c6183e7aec3d 100644
--- a/arch/um/os-Linux/sys-i386/registers.c
+++ b/arch/um/os-Linux/sys-i386/registers.c
@@ -5,6 +5,7 @@
5 */ 5 */
6 6
7#include <errno.h> 7#include <errno.h>
8#include <asm/user.h>
8#include "kern_constants.h" 9#include "kern_constants.h"
9#include "longjmp.h" 10#include "longjmp.h"
10#include "user.h" 11#include "user.h"
@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned long *regs)
74 75
75void arch_init_registers(int pid) 76void arch_init_registers(int pid)
76{ 77{
77 unsigned long fpx_regs[HOST_XFP_SIZE]; 78 struct user_fxsr_struct fpx_regs;
78 int err; 79 int err;
79 80
80 err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs); 81 err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs);
81 if (!err) 82 if (!err)
82 return; 83 return;
83 84
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index e49280599465..bee98f466d66 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -9,7 +9,9 @@
9#include <time.h> 9#include <time.h>
10#include <sys/time.h> 10#include <sys/time.h>
11#include "kern_constants.h" 11#include "kern_constants.h"
12#include "kern_util.h"
12#include "os.h" 13#include "os.h"
14#include "process.h"
13#include "user.h" 15#include "user.h"
14 16
15int set_interval(void) 17int set_interval(void)
@@ -58,12 +60,17 @@ static inline long long timeval_to_ns(const struct timeval *tv)
58long long disable_timer(void) 60long long disable_timer(void)
59{ 61{
60 struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } }); 62 struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });
63 int remain, max = UM_NSEC_PER_SEC / UM_HZ;
61 64
62 if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0) 65 if (setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
63 printk(UM_KERN_ERR "disable_timer - setitimer failed, " 66 printk(UM_KERN_ERR "disable_timer - setitimer failed, "
64 "errno = %d\n", errno); 67 "errno = %d\n", errno);
65 68
66 return timeval_to_ns(&time.it_value); 69 remain = timeval_to_ns(&time.it_value);
70 if (remain > max)
71 remain = max;
72
73 return remain;
67} 74}
68 75
69long long os_nsecs(void) 76long long os_nsecs(void)
@@ -79,7 +86,44 @@ static int after_sleep_interval(struct timespec *ts)
79{ 86{
80 return 0; 87 return 0;
81} 88}
89
90static void deliver_alarm(void)
91{
92 alarm_handler(SIGVTALRM, NULL);
93}
94
95static unsigned long long sleep_time(unsigned long long nsecs)
96{
97 return nsecs;
98}
99
82#else 100#else
101unsigned long long last_tick;
102unsigned long long skew;
103
104static void deliver_alarm(void)
105{
106 unsigned long long this_tick = os_nsecs();
107 int one_tick = UM_NSEC_PER_SEC / UM_HZ;
108
109 if (last_tick == 0)
110 last_tick = this_tick - one_tick;
111
112 skew += this_tick - last_tick;
113
114 while (skew >= one_tick) {
115 alarm_handler(SIGVTALRM, NULL);
116 skew -= one_tick;
117 }
118
119 last_tick = this_tick;
120}
121
122static unsigned long long sleep_time(unsigned long long nsecs)
123{
124 return nsecs > skew ? nsecs - skew : 0;
125}
126
83static inline long long timespec_to_us(const struct timespec *ts) 127static inline long long timespec_to_us(const struct timespec *ts)
84{ 128{
85 return ((long long) ts->tv_sec * UM_USEC_PER_SEC) + 129 return ((long long) ts->tv_sec * UM_USEC_PER_SEC) +
@@ -102,6 +146,8 @@ static int after_sleep_interval(struct timespec *ts)
102 */ 146 */
103 if (start_usecs > usec) 147 if (start_usecs > usec)
104 start_usecs = usec; 148 start_usecs = usec;
149
150 start_usecs -= skew / UM_NSEC_PER_USEC;
105 tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC, 151 tv = ((struct timeval) { .tv_sec = start_usecs / UM_USEC_PER_SEC,
106 .tv_usec = start_usecs % UM_USEC_PER_SEC }); 152 .tv_usec = start_usecs % UM_USEC_PER_SEC });
107 interval = ((struct itimerval) { { 0, usec }, tv }); 153 interval = ((struct itimerval) { { 0, usec }, tv });
@@ -113,8 +159,6 @@ static int after_sleep_interval(struct timespec *ts)
113} 159}
114#endif 160#endif
115 161
116extern void alarm_handler(int sig, struct sigcontext *sc);
117
118void idle_sleep(unsigned long long nsecs) 162void idle_sleep(unsigned long long nsecs)
119{ 163{
120 struct timespec ts; 164 struct timespec ts;
@@ -126,10 +170,12 @@ void idle_sleep(unsigned long long nsecs)
126 */ 170 */
127 if (nsecs == 0) 171 if (nsecs == 0)
128 nsecs = UM_NSEC_PER_SEC / UM_HZ; 172 nsecs = UM_NSEC_PER_SEC / UM_HZ;
173
174 nsecs = sleep_time(nsecs);
129 ts = ((struct timespec) { .tv_sec = nsecs / UM_NSEC_PER_SEC, 175 ts = ((struct timespec) { .tv_sec = nsecs / UM_NSEC_PER_SEC,
130 .tv_nsec = nsecs % UM_NSEC_PER_SEC }); 176 .tv_nsec = nsecs % UM_NSEC_PER_SEC });
131 177
132 if (nanosleep(&ts, &ts) == 0) 178 if (nanosleep(&ts, &ts) == 0)
133 alarm_handler(SIGVTALRM, NULL); 179 deliver_alarm();
134 after_sleep_interval(&ts); 180 after_sleep_interval(&ts);
135} 181}
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index 6b4499906a6c..c9b176534d65 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -148,14 +148,13 @@ int peek_user(struct task_struct *child, long addr, long data)
148int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 148int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
149{ 149{
150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu; 150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
151 long fpregs[HOST_FP_SIZE]; 151 struct user_i387_struct fpregs;
152 152
153 BUG_ON(sizeof(*buf) != sizeof(fpregs)); 153 err = save_fp_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
154 err = save_fp_registers(userspace_pid[cpu], fpregs);
155 if (err) 154 if (err)
156 return err; 155 return err;
157 156
158 n = copy_to_user(buf, fpregs, sizeof(fpregs)); 157 n = copy_to_user(buf, &fpregs, sizeof(fpregs));
159 if(n > 0) 158 if(n > 0)
160 return -EFAULT; 159 return -EFAULT;
161 160
@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
165int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 164int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
166{ 165{
167 int n, cpu = ((struct thread_info *) child->stack)->cpu; 166 int n, cpu = ((struct thread_info *) child->stack)->cpu;
168 long fpregs[HOST_FP_SIZE]; 167 struct user_i387_struct fpregs;
169 168
170 BUG_ON(sizeof(*buf) != sizeof(fpregs)); 169 n = copy_from_user(&fpregs, buf, sizeof(fpregs));
171 n = copy_from_user(fpregs, buf, sizeof(fpregs));
172 if (n > 0) 170 if (n > 0)
173 return -EFAULT; 171 return -EFAULT;
174 172
175 return restore_fp_registers(userspace_pid[cpu], fpregs); 173 return restore_fp_registers(userspace_pid[cpu],
174 (unsigned long *) &fpregs);
176} 175}
177 176
178int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) 177int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
179{ 178{
180 int err, n, cpu = ((struct thread_info *) child->stack)->cpu; 179 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
181 long fpregs[HOST_XFP_SIZE]; 180 struct user_fxsr_struct fpregs;
182 181
183 BUG_ON(sizeof(*buf) != sizeof(fpregs)); 182 err = save_fpx_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
184 err = save_fpx_registers(userspace_pid[cpu], fpregs);
185 if (err) 183 if (err)
186 return err; 184 return err;
187 185
188 n = copy_to_user(buf, fpregs, sizeof(fpregs)); 186 n = copy_to_user(buf, &fpregs, sizeof(fpregs));
189 if(n > 0) 187 if(n > 0)
190 return -EFAULT; 188 return -EFAULT;
191 189
@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
195int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) 193int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
196{ 194{
197 int n, cpu = ((struct thread_info *) child->stack)->cpu; 195 int n, cpu = ((struct thread_info *) child->stack)->cpu;
198 long fpregs[HOST_XFP_SIZE]; 196 struct user_fxsr_struct fpregs;
199 197
200 BUG_ON(sizeof(*buf) != sizeof(fpregs)); 198 n = copy_from_user(&fpregs, buf, sizeof(fpregs));
201 n = copy_from_user(fpregs, buf, sizeof(fpregs));
202 if (n > 0) 199 if (n > 0)
203 return -EFAULT; 200 return -EFAULT;
204 201
205 return restore_fpx_registers(userspace_pid[cpu], fpregs); 202 return restore_fpx_registers(userspace_pid[cpu],
203 (unsigned long *) &fpregs);
206} 204}
207 205
208long subarch_ptrace(struct task_struct *child, long request, long addr, 206long subarch_ptrace(struct task_struct *child, long request, long addr,
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c
index 39bd32bf84f0..5f883bfe773f 100644
--- a/arch/um/sys-i386/user-offsets.c
+++ b/arch/um/sys-i386/user-offsets.c
@@ -22,7 +22,7 @@ void foo(void)
22 OFFSET(HOST_SC_CR2, sigcontext, cr2); 22 OFFSET(HOST_SC_CR2, sigcontext, cr2);
23 23
24 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); 24 DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
25 DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct)); 25 DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
26 26
27 DEFINE(HOST_IP, EIP); 27 DEFINE(HOST_IP, EIP);
28 DEFINE(HOST_SP, UESP); 28 DEFINE(HOST_SP, UESP);
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c
index 2f3443c6e859..973585414a66 100644
--- a/arch/um/sys-x86_64/user-offsets.c
+++ b/arch/um/sys-x86_64/user-offsets.c
@@ -24,7 +24,6 @@ void foo(void)
24 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); 24 OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
25 25
26 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); 26 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
27 DEFINE(HOST_XFP_SIZE, 0);
28 DEFINE_LONGS(HOST_RBX, RBX); 27 DEFINE_LONGS(HOST_RBX, RBX);
29 DEFINE_LONGS(HOST_RCX, RCX); 28 DEFINE_LONGS(HOST_RCX, RCX);
30 DEFINE_LONGS(HOST_RDI, RDI); 29 DEFINE_LONGS(HOST_RDI, RDI);
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 845ea2b2d487..fe361ae7ef2f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -18,6 +18,7 @@ config X86_64
18### Arch settings 18### Arch settings
19config X86 19config X86
20 def_bool y 20 def_bool y
21 select HAVE_UNSTABLE_SCHED_CLOCK
21 select HAVE_IDE 22 select HAVE_IDE
22 select HAVE_OPROFILE 23 select HAVE_OPROFILE
23 select HAVE_KPROBES 24 select HAVE_KPROBES
@@ -334,6 +335,7 @@ config X86_RDC321X
334 select GENERIC_GPIO 335 select GENERIC_GPIO
335 select LEDS_CLASS 336 select LEDS_CLASS
336 select LEDS_GPIO 337 select LEDS_GPIO
338 select NEW_LEDS
337 help 339 help
338 This option is needed for RDC R-321x system-on-chip, also known 340 This option is needed for RDC R-321x system-on-chip, also known
339 as R-8610-(G). 341 as R-8610-(G).
@@ -1661,7 +1663,6 @@ config GEODE_MFGPT_TIMER
1661 1663
1662config OLPC 1664config OLPC
1663 bool "One Laptop Per Child support" 1665 bool "One Laptop Per Child support"
1664 depends on MGEODE_LX
1665 default n 1666 default n
1666 help 1667 help
1667 Add support for detecting the unique features of the OLPC 1668 Add support for detecting the unique features of the OLPC
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index bbdacb398d48..5e618c3b4720 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -83,9 +83,7 @@ obj-$(CONFIG_KVM_GUEST) += kvm.o
83obj-$(CONFIG_KVM_CLOCK) += kvmclock.o 83obj-$(CONFIG_KVM_CLOCK) += kvmclock.o
84obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o 84obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch_$(BITS).o
85 85
86ifdef CONFIG_INPUT_PCSPKR 86obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o
87obj-y += pcspeaker.o
88endif
89 87
90obj-$(CONFIG_SCx200) += scx200.o 88obj-$(CONFIG_SCx200) += scx200.o
91scx200-y += scx200_32.o 89scx200-y += scx200_32.o
diff --git a/arch/x86/kernel/acpi/realmode/wakeup.lds.S b/arch/x86/kernel/acpi/realmode/wakeup.lds.S
index 22fab6c4be15..7da00b799cda 100644
--- a/arch/x86/kernel/acpi/realmode/wakeup.lds.S
+++ b/arch/x86/kernel/acpi/realmode/wakeup.lds.S
@@ -12,11 +12,6 @@ ENTRY(_start)
12 12
13SECTIONS 13SECTIONS
14{ 14{
15 . = HEADER_OFFSET;
16 .header : {
17 *(.header)
18 }
19
20 . = 0; 15 . = 0;
21 .text : { 16 .text : {
22 *(.text*) 17 *(.text*)
@@ -50,6 +45,11 @@ SECTIONS
50 __bss_end = .; 45 __bss_end = .;
51 } 46 }
52 47
48 . = HEADER_OFFSET;
49 .header : {
50 *(.header)
51 }
52
53 . = ALIGN(16); 53 . = ALIGN(16);
54 _end = .; 54 _end = .;
55 55
diff --git a/arch/x86/kernel/cpu/addon_cpuid_features.c b/arch/x86/kernel/cpu/addon_cpuid_features.c
index 238468ae1993..c2e1ce33c7cb 100644
--- a/arch/x86/kernel/cpu/addon_cpuid_features.c
+++ b/arch/x86/kernel/cpu/addon_cpuid_features.c
@@ -6,6 +6,7 @@
6 6
7#include <linux/cpu.h> 7#include <linux/cpu.h>
8 8
9#include <asm/pat.h>
9#include <asm/processor.h> 10#include <asm/processor.h>
10 11
11struct cpuid_bit { 12struct cpuid_bit {
@@ -48,3 +49,23 @@ void __cpuinit init_scattered_cpuid_features(struct cpuinfo_x86 *c)
48 set_cpu_cap(c, cb->feature); 49 set_cpu_cap(c, cb->feature);
49 } 50 }
50} 51}
52
53#ifdef CONFIG_X86_PAT
54void __cpuinit validate_pat_support(struct cpuinfo_x86 *c)
55{
56 switch (c->x86_vendor) {
57 case X86_VENDOR_AMD:
58 if (c->x86 >= 0xf && c->x86 <= 0x11)
59 return;
60 break;
61 case X86_VENDOR_INTEL:
62 if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
63 return;
64 break;
65 }
66
67 pat_disable(cpu_has_pat ?
68 "PAT disabled. Not yet verified on this CPU type." :
69 "PAT not supported by CPU.");
70}
71#endif
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 35b4f6a9c8ef..d0463a946247 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -12,6 +12,7 @@
12#include <asm/mmu_context.h> 12#include <asm/mmu_context.h>
13#include <asm/mtrr.h> 13#include <asm/mtrr.h>
14#include <asm/mce.h> 14#include <asm/mce.h>
15#include <asm/pat.h>
15#ifdef CONFIG_X86_LOCAL_APIC 16#ifdef CONFIG_X86_LOCAL_APIC
16#include <asm/mpspec.h> 17#include <asm/mpspec.h>
17#include <asm/apic.h> 18#include <asm/apic.h>
@@ -308,19 +309,6 @@ static void __cpuinit early_get_cap(struct cpuinfo_x86 *c)
308 309
309 } 310 }
310 311
311 clear_cpu_cap(c, X86_FEATURE_PAT);
312
313 switch (c->x86_vendor) {
314 case X86_VENDOR_AMD:
315 if (c->x86 >= 0xf && c->x86 <= 0x11)
316 set_cpu_cap(c, X86_FEATURE_PAT);
317 break;
318 case X86_VENDOR_INTEL:
319 if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
320 set_cpu_cap(c, X86_FEATURE_PAT);
321 break;
322 }
323
324} 312}
325 313
326/* 314/*
@@ -409,18 +397,6 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
409 init_scattered_cpuid_features(c); 397 init_scattered_cpuid_features(c);
410 } 398 }
411 399
412 clear_cpu_cap(c, X86_FEATURE_PAT);
413
414 switch (c->x86_vendor) {
415 case X86_VENDOR_AMD:
416 if (c->x86 >= 0xf && c->x86 <= 0x11)
417 set_cpu_cap(c, X86_FEATURE_PAT);
418 break;
419 case X86_VENDOR_INTEL:
420 if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
421 set_cpu_cap(c, X86_FEATURE_PAT);
422 break;
423 }
424} 400}
425 401
426static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c) 402static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
@@ -651,6 +627,7 @@ void __init early_cpu_init(void)
651 cpu_devs[cvdev->vendor] = cvdev->cpu_dev; 627 cpu_devs[cvdev->vendor] = cvdev->cpu_dev;
652 628
653 early_cpu_detect(); 629 early_cpu_detect();
630 validate_pat_support(&boot_cpu_data);
654} 631}
655 632
656/* Make sure %fs is initialized properly in idle threads */ 633/* Make sure %fs is initialized properly in idle threads */
diff --git a/arch/x86/kernel/geode_32.c b/arch/x86/kernel/geode_32.c
index 9dad6ca6cd70..e8edd63ab000 100644
--- a/arch/x86/kernel/geode_32.c
+++ b/arch/x86/kernel/geode_32.c
@@ -161,6 +161,25 @@ void geode_gpio_setup_event(unsigned int gpio, int pair, int pme)
161} 161}
162EXPORT_SYMBOL_GPL(geode_gpio_setup_event); 162EXPORT_SYMBOL_GPL(geode_gpio_setup_event);
163 163
164int geode_has_vsa2(void)
165{
166 static int has_vsa2 = -1;
167
168 if (has_vsa2 == -1) {
169 /*
170 * The VSA has virtual registers that we can query for a
171 * signature.
172 */
173 outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
174 outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX);
175
176 has_vsa2 = (inw(VSA_VRC_DATA) == VSA_SIG);
177 }
178
179 return has_vsa2;
180}
181EXPORT_SYMBOL_GPL(geode_has_vsa2);
182
164static int __init geode_southbridge_init(void) 183static int __init geode_southbridge_init(void)
165{ 184{
166 if (!is_geode()) 185 if (!is_geode())
diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index db6839b53195..e03cc952f233 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -450,7 +450,6 @@ static inline int restore_i387_fsave(struct _fpstate_ia32 __user *buf)
450{ 450{
451 struct task_struct *tsk = current; 451 struct task_struct *tsk = current;
452 452
453 clear_fpu(tsk);
454 return __copy_from_user(&tsk->thread.xstate->fsave, buf, 453 return __copy_from_user(&tsk->thread.xstate->fsave, buf,
455 sizeof(struct i387_fsave_struct)); 454 sizeof(struct i387_fsave_struct));
456} 455}
@@ -461,7 +460,6 @@ static int restore_i387_fxsave(struct _fpstate_ia32 __user *buf)
461 struct user_i387_ia32_struct env; 460 struct user_i387_ia32_struct env;
462 int err; 461 int err;
463 462
464 clear_fpu(tsk);
465 err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0], 463 err = __copy_from_user(&tsk->thread.xstate->fxsave, &buf->_fxsr_env[0],
466 sizeof(struct i387_fxsave_struct)); 464 sizeof(struct i387_fxsave_struct));
467 /* mxcsr reserved bits must be masked to zero for security reasons */ 465 /* mxcsr reserved bits must be masked to zero for security reasons */
@@ -478,6 +476,16 @@ int restore_i387_ia32(struct _fpstate_ia32 __user *buf)
478 int err; 476 int err;
479 477
480 if (HAVE_HWFP) { 478 if (HAVE_HWFP) {
479 struct task_struct *tsk = current;
480
481 clear_fpu(tsk);
482
483 if (!used_math()) {
484 err = init_fpu(tsk);
485 if (err)
486 return err;
487 }
488
481 if (cpu_has_fxsr) 489 if (cpu_has_fxsr)
482 err = restore_i387_fxsave(buf); 490 err = restore_i387_fxsave(buf);
483 else 491 else
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 0c37f16b6950..c5ef1af8e79d 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -385,11 +385,13 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
385 if (dma_alloc_from_coherent_mem(dev, size, dma_handle, &memory)) 385 if (dma_alloc_from_coherent_mem(dev, size, dma_handle, &memory))
386 return memory; 386 return memory;
387 387
388 if (!dev) 388 if (!dev) {
389 dev = &fallback_dev; 389 dev = &fallback_dev;
390 gfp |= GFP_DMA;
391 }
390 dma_mask = dev->coherent_dma_mask; 392 dma_mask = dev->coherent_dma_mask;
391 if (dma_mask == 0) 393 if (dma_mask == 0)
392 dma_mask = DMA_32BIT_MASK; 394 dma_mask = (gfp & GFP_DMA) ? DMA_24BIT_MASK : DMA_32BIT_MASK;
393 395
394 /* Device not DMA able */ 396 /* Device not DMA able */
395 if (dev->dma_mask == NULL) 397 if (dev->dma_mask == NULL)
@@ -403,7 +405,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
403 larger than 16MB and in this case we have a chance of 405 larger than 16MB and in this case we have a chance of
404 finding fitting memory in the next higher zone first. If 406 finding fitting memory in the next higher zone first. If
405 not retry with true GFP_DMA. -AK */ 407 not retry with true GFP_DMA. -AK */
406 if (dma_mask <= DMA_32BIT_MASK) 408 if (dma_mask <= DMA_32BIT_MASK && !(gfp & GFP_DMA))
407 gfp |= GFP_DMA32; 409 gfp |= GFP_DMA32;
408#endif 410#endif
409 411
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index fb03ef380f0e..a7835f282936 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1303,6 +1303,9 @@ static const struct user_regset_view user_x86_64_view = {
1303#define genregs32_get genregs_get 1303#define genregs32_get genregs_get
1304#define genregs32_set genregs_set 1304#define genregs32_set genregs_set
1305 1305
1306#define user_i387_ia32_struct user_i387_struct
1307#define user32_fxsr_struct user_fxsr_struct
1308
1306#endif /* CONFIG_X86_64 */ 1309#endif /* CONFIG_X86_64 */
1307 1310
1308#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION 1311#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
@@ -1315,13 +1318,13 @@ static const struct user_regset x86_32_regsets[] = {
1315 }, 1318 },
1316 [REGSET_FP] = { 1319 [REGSET_FP] = {
1317 .core_note_type = NT_PRFPREG, 1320 .core_note_type = NT_PRFPREG,
1318 .n = sizeof(struct user_i387_struct) / sizeof(u32), 1321 .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
1319 .size = sizeof(u32), .align = sizeof(u32), 1322 .size = sizeof(u32), .align = sizeof(u32),
1320 .active = fpregs_active, .get = fpregs_get, .set = fpregs_set 1323 .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
1321 }, 1324 },
1322 [REGSET_XFP] = { 1325 [REGSET_XFP] = {
1323 .core_note_type = NT_PRXFPREG, 1326 .core_note_type = NT_PRXFPREG,
1324 .n = sizeof(struct user_i387_struct) / sizeof(u32), 1327 .n = sizeof(struct user32_fxsr_struct) / sizeof(u32),
1325 .size = sizeof(u32), .align = sizeof(u32), 1328 .size = sizeof(u32), .align = sizeof(u32),
1326 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set 1329 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1327 }, 1330 },
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index cc6f5eb20b24..6f80b852a196 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -12,6 +12,7 @@
12#include <asm/mpspec.h> 12#include <asm/mpspec.h>
13#include <asm/apicdef.h> 13#include <asm/apicdef.h>
14 14
15#ifdef CONFIG_X86_LOCAL_APIC
15unsigned int num_processors; 16unsigned int num_processors;
16unsigned disabled_cpus __cpuinitdata; 17unsigned disabled_cpus __cpuinitdata;
17/* Processor that is doing the boot up */ 18/* Processor that is doing the boot up */
@@ -23,8 +24,9 @@ EXPORT_PER_CPU_SYMBOL(x86_cpu_to_apicid);
23 24
24/* Bitmask of physically existing CPUs */ 25/* Bitmask of physically existing CPUs */
25physid_mask_t phys_cpu_present_map; 26physid_mask_t phys_cpu_present_map;
27#endif
26 28
27#if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_SMP) 29#if defined(CONFIG_HAVE_SETUP_PER_CPU_AREA) && defined(CONFIG_X86_SMP)
28/* 30/*
29 * Copy data used in early init routines from the initial arrays to the 31 * Copy data used in early init routines from the initial arrays to the
30 * per cpu data areas. These arrays then become expendable and the 32 * per cpu data areas. These arrays then become expendable and the
@@ -95,7 +97,7 @@ void __init setup_per_cpu_areas(void)
95 97
96 /* Copy section for each CPU (we discard the original) */ 98 /* Copy section for each CPU (we discard the original) */
97 size = PERCPU_ENOUGH_ROOM; 99 size = PERCPU_ENOUGH_ROOM;
98 printk(KERN_INFO "PERCPU: Allocating %zd bytes of per cpu data\n", 100 printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n",
99 size); 101 size);
100 102
101 for_each_possible_cpu(i) { 103 for_each_possible_cpu(i) {
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index 2283422af794..2c5f8b213e86 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -127,7 +127,12 @@ static struct resource standard_io_resources[] = { {
127}, { 127}, {
128 .name = "keyboard", 128 .name = "keyboard",
129 .start = 0x0060, 129 .start = 0x0060,
130 .end = 0x006f, 130 .end = 0x0060,
131 .flags = IORESOURCE_BUSY | IORESOURCE_IO
132}, {
133 .name = "keyboard",
134 .start = 0x0064,
135 .end = 0x0064,
131 .flags = IORESOURCE_BUSY | IORESOURCE_IO 136 .flags = IORESOURCE_BUSY | IORESOURCE_IO
132}, { 137}, {
133 .name = "dma page reg", 138 .name = "dma page reg",
diff --git a/arch/x86/kernel/setup_64.c b/arch/x86/kernel/setup_64.c
index 22c14e21c97c..6dff1286ad8a 100644
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -70,6 +70,7 @@
70#include <asm/ds.h> 70#include <asm/ds.h>
71#include <asm/topology.h> 71#include <asm/topology.h>
72#include <asm/trampoline.h> 72#include <asm/trampoline.h>
73#include <asm/pat.h>
73 74
74#include <mach_apic.h> 75#include <mach_apic.h>
75#ifdef CONFIG_PARAVIRT 76#ifdef CONFIG_PARAVIRT
@@ -128,7 +129,9 @@ static struct resource standard_io_resources[] = {
128 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 129 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
129 { .name = "timer1", .start = 0x50, .end = 0x53, 130 { .name = "timer1", .start = 0x50, .end = 0x53,
130 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 131 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
131 { .name = "keyboard", .start = 0x60, .end = 0x6f, 132 { .name = "keyboard", .start = 0x60, .end = 0x60,
133 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
134 { .name = "keyboard", .start = 0x64, .end = 0x64,
132 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 135 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
133 { .name = "dma page reg", .start = 0x80, .end = 0x8f, 136 { .name = "dma page reg", .start = 0x80, .end = 0x8f,
134 .flags = IORESOURCE_BUSY | IORESOURCE_IO }, 137 .flags = IORESOURCE_BUSY | IORESOURCE_IO },
@@ -948,7 +951,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
948static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c) 951static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
949{ 952{
950 if (c->x86 == 0x6 && c->x86_model >= 0xf) 953 if (c->x86 == 0x6 && c->x86_model >= 0xf)
951 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 954 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
952} 955}
953 956
954static void __cpuinit init_centaur(struct cpuinfo_x86 *c) 957static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
@@ -1063,25 +1066,19 @@ static void __cpuinit early_identify_cpu(struct cpuinfo_x86 *c)
1063 if (c->extended_cpuid_level >= 0x80000007) 1066 if (c->extended_cpuid_level >= 0x80000007)
1064 c->x86_power = cpuid_edx(0x80000007); 1067 c->x86_power = cpuid_edx(0x80000007);
1065 1068
1066
1067 clear_cpu_cap(c, X86_FEATURE_PAT);
1068
1069 switch (c->x86_vendor) { 1069 switch (c->x86_vendor) {
1070 case X86_VENDOR_AMD: 1070 case X86_VENDOR_AMD:
1071 early_init_amd(c); 1071 early_init_amd(c);
1072 if (c->x86 >= 0xf && c->x86 <= 0x11)
1073 set_cpu_cap(c, X86_FEATURE_PAT);
1074 break; 1072 break;
1075 case X86_VENDOR_INTEL: 1073 case X86_VENDOR_INTEL:
1076 early_init_intel(c); 1074 early_init_intel(c);
1077 if (c->x86 == 0xF || (c->x86 == 6 && c->x86_model >= 15))
1078 set_cpu_cap(c, X86_FEATURE_PAT);
1079 break; 1075 break;
1080 case X86_VENDOR_CENTAUR: 1076 case X86_VENDOR_CENTAUR:
1081 early_init_centaur(c); 1077 early_init_centaur(c);
1082 break; 1078 break;
1083 } 1079 }
1084 1080
1081 validate_pat_support(c);
1085} 1082}
1086 1083
1087/* 1084/*
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
index 8f75893a6467..0cb7aadc87cd 100644
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -231,7 +231,8 @@ native_smp_call_function_mask(cpumask_t mask,
231 wmb(); 231 wmb();
232 232
233 /* Send a message to other CPUs */ 233 /* Send a message to other CPUs */
234 if (cpus_equal(mask, allbutself)) 234 if (cpus_equal(mask, allbutself) &&
235 cpus_equal(cpu_online_map, cpu_callout_map))
235 send_IPI_allbutself(CALL_FUNCTION_VECTOR); 236 send_IPI_allbutself(CALL_FUNCTION_VECTOR);
236 else 237 else
237 send_IPI_mask(mask, CALL_FUNCTION_VECTOR); 238 send_IPI_mask(mask, CALL_FUNCTION_VECTOR);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 6b087ab6cd8f..38988491c622 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -86,6 +86,7 @@ void *x86_bios_cpu_apicid_early_ptr;
86 86
87#ifdef CONFIG_X86_32 87#ifdef CONFIG_X86_32
88u8 apicid_2_node[MAX_APICID]; 88u8 apicid_2_node[MAX_APICID];
89static int low_mappings;
89#endif 90#endif
90 91
91/* State of each CPU */ 92/* State of each CPU */
@@ -326,6 +327,12 @@ static void __cpuinit start_secondary(void *unused)
326 enable_8259A_irq(0); 327 enable_8259A_irq(0);
327 } 328 }
328 329
330#ifdef CONFIG_X86_32
331 while (low_mappings)
332 cpu_relax();
333 __flush_tlb_all();
334#endif
335
329 /* This must be done before setting cpu_online_map */ 336 /* This must be done before setting cpu_online_map */
330 set_cpu_sibling_map(raw_smp_processor_id()); 337 set_cpu_sibling_map(raw_smp_processor_id());
331 wmb(); 338 wmb();
@@ -1040,14 +1047,20 @@ int __cpuinit native_cpu_up(unsigned int cpu)
1040#ifdef CONFIG_X86_32 1047#ifdef CONFIG_X86_32
1041 /* init low mem mapping */ 1048 /* init low mem mapping */
1042 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY, 1049 clone_pgd_range(swapper_pg_dir, swapper_pg_dir + KERNEL_PGD_BOUNDARY,
1043 min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY)); 1050 min_t(unsigned long, KERNEL_PGD_PTRS, KERNEL_PGD_BOUNDARY));
1044 flush_tlb_all(); 1051 flush_tlb_all();
1045#endif 1052 low_mappings = 1;
1046 1053
1047 err = do_boot_cpu(apicid, cpu); 1054 err = do_boot_cpu(apicid, cpu);
1048 if (err < 0) { 1055
1056 zap_low_mappings();
1057 low_mappings = 0;
1058#else
1059 err = do_boot_cpu(apicid, cpu);
1060#endif
1061 if (err) {
1049 Dprintk("do_boot_cpu failed %d\n", err); 1062 Dprintk("do_boot_cpu failed %d\n", err);
1050 return err; 1063 return -EIO;
1051 } 1064 }
1052 1065
1053 /* 1066 /*
@@ -1259,9 +1272,6 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
1259 setup_ioapic_dest(); 1272 setup_ioapic_dest();
1260#endif 1273#endif
1261 check_nmi_watchdog(); 1274 check_nmi_watchdog();
1262#ifdef CONFIG_X86_32
1263 zap_low_mappings();
1264#endif
1265} 1275}
1266 1276
1267#ifdef CONFIG_HOTPLUG_CPU 1277#ifdef CONFIG_HOTPLUG_CPU
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
index 58882f9f2637..f6c05d0410fb 100644
--- a/arch/x86/kernel/x8664_ksyms_64.c
+++ b/arch/x86/kernel/x8664_ksyms_64.c
@@ -2,6 +2,7 @@
2 All C exports should go in the respective C files. */ 2 All C exports should go in the respective C files. */
3 3
4#include <linux/module.h> 4#include <linux/module.h>
5#include <net/checksum.h>
5#include <linux/smp.h> 6#include <linux/smp.h>
6 7
7#include <asm/processor.h> 8#include <asm/processor.h>
@@ -29,6 +30,8 @@ EXPORT_SYMBOL(__copy_from_user_inatomic);
29EXPORT_SYMBOL(copy_page); 30EXPORT_SYMBOL(copy_page);
30EXPORT_SYMBOL(clear_page); 31EXPORT_SYMBOL(clear_page);
31 32
33EXPORT_SYMBOL(csum_partial);
34
32/* 35/*
33 * Export string functions. We normally rely on gcc builtin for most of these, 36 * Export string functions. We normally rely on gcc builtin for most of these,
34 * but gcc sometimes decides not to inline them. 37 * but gcc sometimes decides not to inline them.
diff --git a/arch/x86/lib/csum-partial_64.c b/arch/x86/lib/csum-partial_64.c
index bc503f506903..bf51144d97e1 100644
--- a/arch/x86/lib/csum-partial_64.c
+++ b/arch/x86/lib/csum-partial_64.c
@@ -136,8 +136,6 @@ __wsum csum_partial(const void *buff, int len, __wsum sum)
136 (__force u32)sum); 136 (__force u32)sum);
137} 137}
138 138
139EXPORT_SYMBOL(csum_partial);
140
141/* 139/*
142 * this routine is used for miscellaneous IP-like checksums, mainly 140 * this routine is used for miscellaneous IP-like checksums, mainly
143 * in icmp.c 141 * in icmp.c
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index de236e419cb5..ec30d10154b6 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -438,8 +438,6 @@ void zap_low_mappings(void)
438{ 438{
439 int i; 439 int i;
440 440
441 save_pg_dir();
442
443 /* 441 /*
444 * Zap initial low-memory mappings. 442 * Zap initial low-memory mappings.
445 * 443 *
@@ -663,16 +661,8 @@ void __init mem_init(void)
663 test_wp_bit(); 661 test_wp_bit();
664 662
665 cpa_init(); 663 cpa_init();
666 664 save_pg_dir();
667 /*
668 * Subtle. SMP is doing it's boot stuff late (because it has to
669 * fork idle threads) - but it also needs low mappings for the
670 * protected-mode entry to work. We zap these entries only after
671 * the WP-bit has been tested.
672 */
673#ifndef CONFIG_SMP
674 zap_low_mappings(); 665 zap_low_mappings();
675#endif
676} 666}
677 667
678#ifdef CONFIG_MEMORY_HOTPLUG 668#ifdef CONFIG_MEMORY_HOTPLUG
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 277446cd30b6..bcb1a8e4b2db 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -25,31 +25,24 @@
25#include <asm/mtrr.h> 25#include <asm/mtrr.h>
26#include <asm/io.h> 26#include <asm/io.h>
27 27
28int pat_wc_enabled = 1; 28#ifdef CONFIG_X86_PAT
29int __read_mostly pat_wc_enabled = 1;
29 30
30static u64 __read_mostly boot_pat_state; 31void __init pat_disable(char *reason)
31
32static int nopat(char *str)
33{ 32{
34 pat_wc_enabled = 0; 33 pat_wc_enabled = 0;
35 printk(KERN_INFO "x86: PAT support disabled.\n"); 34 printk(KERN_INFO "%s\n", reason);
36
37 return 0;
38} 35}
39early_param("nopat", nopat);
40 36
41static int pat_known_cpu(void) 37static int nopat(char *str)
42{ 38{
43 if (!pat_wc_enabled) 39 pat_disable("PAT support disabled.");
44 return 0;
45
46 if (cpu_has_pat)
47 return 1;
48
49 pat_wc_enabled = 0;
50 printk(KERN_INFO "CPU and/or kernel does not support PAT.\n");
51 return 0; 40 return 0;
52} 41}
42early_param("nopat", nopat);
43#endif
44
45static u64 __read_mostly boot_pat_state;
53 46
54enum { 47enum {
55 PAT_UC = 0, /* uncached */ 48 PAT_UC = 0, /* uncached */
@@ -66,17 +59,19 @@ void pat_init(void)
66{ 59{
67 u64 pat; 60 u64 pat;
68 61
69#ifndef CONFIG_X86_PAT 62 if (!pat_wc_enabled)
70 nopat(NULL);
71#endif
72
73 /* Boot CPU enables PAT based on CPU feature */
74 if (!smp_processor_id() && !pat_known_cpu())
75 return; 63 return;
76 64
77 /* APs enable PAT iff boot CPU has enabled it before */ 65 /* Paranoia check. */
78 if (smp_processor_id() && !pat_wc_enabled) 66 if (!cpu_has_pat) {
79 return; 67 printk(KERN_ERR "PAT enabled, but CPU feature cleared\n");
68 /*
69 * Panic if this happens on the secondary CPU, and we
70 * switched to PAT on the boot CPU. We have no way to
71 * undo PAT.
72 */
73 BUG_ON(boot_pat_state);
74 }
80 75
81 /* Set PWT to Write-Combining. All other bits stay the same */ 76 /* Set PWT to Write-Combining. All other bits stay the same */
82 /* 77 /*
@@ -95,9 +90,8 @@ void pat_init(void)
95 PAT(4,WB) | PAT(5,WC) | PAT(6,UC_MINUS) | PAT(7,UC); 90 PAT(4,WB) | PAT(5,WC) | PAT(6,UC_MINUS) | PAT(7,UC);
96 91
97 /* Boot CPU check */ 92 /* Boot CPU check */
98 if (!smp_processor_id()) { 93 if (!boot_pat_state)
99 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state); 94 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
100 }
101 95
102 wrmsrl(MSR_IA32_CR_PAT, pat); 96 wrmsrl(MSR_IA32_CR_PAT, pat);
103 printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n", 97 printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n",
@@ -561,7 +555,7 @@ int phys_mem_access_prot_allowed(struct file *file, unsigned long pfn,
561 "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n", 555 "%s:%d /dev/mem ioremap_change_attr failed %s for %Lx-%Lx\n",
562 current->comm, current->pid, 556 current->comm, current->pid,
563 cattr_name(flags), 557 cattr_name(flags),
564 offset, offset + size); 558 offset, (unsigned long long)(offset + size));
565 return 0; 559 return 0;
566 } 560 }
567 561
@@ -582,7 +576,7 @@ void map_devmem(unsigned long pfn, unsigned long size, pgprot_t vma_prot)
582 "%s:%d /dev/mem expected mapping type %s for %Lx-%Lx, got %s\n", 576 "%s:%d /dev/mem expected mapping type %s for %Lx-%Lx, got %s\n",
583 current->comm, current->pid, 577 current->comm, current->pid,
584 cattr_name(want_flags), 578 cattr_name(want_flags),
585 addr, addr + size, 579 addr, (unsigned long long)(addr + size),
586 cattr_name(flags)); 580 cattr_name(flags));
587 } 581 }
588} 582}
diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
index 9ee007be9142..369cf065b6a4 100644
--- a/arch/x86/mm/pgtable_32.c
+++ b/arch/x86/mm/pgtable_32.c
@@ -172,10 +172,3 @@ void reserve_top_address(unsigned long reserve)
172 __FIXADDR_TOP = -reserve - PAGE_SIZE; 172 __FIXADDR_TOP = -reserve - PAGE_SIZE;
173 __VMALLOC_RESERVE += reserve; 173 __VMALLOC_RESERVE += reserve;
174} 174}
175
176int pmd_bad(pmd_t pmd)
177{
178 WARN_ON_ONCE(pmd_bad_v1(pmd) != pmd_bad_v2(pmd));
179
180 return pmd_bad_v1(pmd);
181}
diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c
index 1a9c0c6a1a18..d95de2f199cd 100644
--- a/arch/x86/pci/acpi.c
+++ b/arch/x86/pci/acpi.c
@@ -6,45 +6,6 @@
6#include <asm/numa.h> 6#include <asm/numa.h>
7#include "pci.h" 7#include "pci.h"
8 8
9static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
10{
11 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
12 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
13 return 0;
14}
15
16static struct dmi_system_id acpi_pciprobe_dmi_table[] __devinitdata = {
17/*
18 * Systems where PCI IO resource ISA alignment can be skipped
19 * when the ISA enable bit in the bridge control is not set
20 */
21 {
22 .callback = can_skip_ioresource_align,
23 .ident = "IBM System x3800",
24 .matches = {
25 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
26 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
27 },
28 },
29 {
30 .callback = can_skip_ioresource_align,
31 .ident = "IBM System x3850",
32 .matches = {
33 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
34 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
35 },
36 },
37 {
38 .callback = can_skip_ioresource_align,
39 .ident = "IBM System x3950",
40 .matches = {
41 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
42 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
43 },
44 },
45 {}
46};
47
48struct pci_root_info { 9struct pci_root_info {
49 char *name; 10 char *name;
50 unsigned int res_num; 11 unsigned int res_num;
@@ -196,8 +157,6 @@ struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int do
196 int pxm; 157 int pxm;
197#endif 158#endif
198 159
199 dmi_check_system(acpi_pciprobe_dmi_table);
200
201 if (domain && !pci_domains_supported) { 160 if (domain && !pci_domains_supported) {
202 printk(KERN_WARNING "PCI: Multiple domains not supported " 161 printk(KERN_WARNING "PCI: Multiple domains not supported "
203 "(dom %d, bus %d)\n", domain, busnum); 162 "(dom %d, bus %d)\n", domain, busnum);
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 2a4d751818b7..8545c8a9d107 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -77,17 +77,48 @@ int pcibios_scanned;
77 */ 77 */
78DEFINE_SPINLOCK(pci_config_lock); 78DEFINE_SPINLOCK(pci_config_lock);
79 79
80static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev) 80static int __devinit can_skip_ioresource_align(const struct dmi_system_id *d)
81{ 81{
82 struct resource *rom_r = &dev->resource[PCI_ROM_RESOURCE]; 82 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
83 83 printk(KERN_INFO "PCI: %s detected, can skip ISA alignment\n", d->ident);
84 if (rom_r->parent) 84 return 0;
85 return; 85}
86 if (rom_r->start) 86
87 /* we deal with BIOS assigned ROM later */ 87static struct dmi_system_id can_skip_pciprobe_dmi_table[] __devinitdata = {
88 return; 88/*
89 if (!(pci_probe & PCI_ASSIGN_ROMS)) 89 * Systems where PCI IO resource ISA alignment can be skipped
90 rom_r->start = rom_r->end = rom_r->flags = 0; 90 * when the ISA enable bit in the bridge control is not set
91 */
92 {
93 .callback = can_skip_ioresource_align,
94 .ident = "IBM System x3800",
95 .matches = {
96 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
97 DMI_MATCH(DMI_PRODUCT_NAME, "x3800"),
98 },
99 },
100 {
101 .callback = can_skip_ioresource_align,
102 .ident = "IBM System x3850",
103 .matches = {
104 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
105 DMI_MATCH(DMI_PRODUCT_NAME, "x3850"),
106 },
107 },
108 {
109 .callback = can_skip_ioresource_align,
110 .ident = "IBM System x3950",
111 .matches = {
112 DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
113 DMI_MATCH(DMI_PRODUCT_NAME, "x3950"),
114 },
115 },
116 {}
117};
118
119void __init dmi_check_skip_isa_align(void)
120{
121 dmi_check_system(can_skip_pciprobe_dmi_table);
91} 122}
92 123
93/* 124/*
@@ -97,11 +128,7 @@ static void __devinit pcibios_fixup_device_resources(struct pci_dev *dev)
97 128
98void __devinit pcibios_fixup_bus(struct pci_bus *b) 129void __devinit pcibios_fixup_bus(struct pci_bus *b)
99{ 130{
100 struct pci_dev *dev;
101
102 pci_read_bridge_bases(b); 131 pci_read_bridge_bases(b);
103 list_for_each_entry(dev, &b->devices, bus_list)
104 pcibios_fixup_device_resources(dev);
105} 132}
106 133
107/* 134/*
@@ -318,13 +345,16 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
318 {} 345 {}
319}; 346};
320 347
348void __init dmi_check_pciprobe(void)
349{
350 dmi_check_system(pciprobe_dmi_table);
351}
352
321struct pci_bus * __devinit pcibios_scan_root(int busnum) 353struct pci_bus * __devinit pcibios_scan_root(int busnum)
322{ 354{
323 struct pci_bus *bus = NULL; 355 struct pci_bus *bus = NULL;
324 struct pci_sysdata *sd; 356 struct pci_sysdata *sd;
325 357
326 dmi_check_system(pciprobe_dmi_table);
327
328 while ((bus = pci_find_next_bus(bus)) != NULL) { 358 while ((bus = pci_find_next_bus(bus)) != NULL) {
329 if (bus->number == busnum) { 359 if (bus->number == busnum) {
330 /* Already scanned */ 360 /* Already scanned */
@@ -462,6 +492,9 @@ char * __devinit pcibios_setup(char *str)
462 } else if (!strcmp(str, "routeirq")) { 492 } else if (!strcmp(str, "routeirq")) {
463 pci_routeirq = 1; 493 pci_routeirq = 1;
464 return NULL; 494 return NULL;
495 } else if (!strcmp(str, "skip_isa_align")) {
496 pci_probe |= PCI_CAN_SKIP_ISA_ALIGN;
497 return NULL;
465 } 498 }
466 return str; 499 return str;
467} 500}
@@ -489,7 +522,7 @@ void pcibios_disable_device (struct pci_dev *dev)
489 pcibios_disable_irq(dev); 522 pcibios_disable_irq(dev);
490} 523}
491 524
492struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node) 525struct pci_bus * __devinit pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
493{ 526{
494 struct pci_bus *bus = NULL; 527 struct pci_bus *bus = NULL;
495 struct pci_sysdata *sd; 528 struct pci_sysdata *sd;
@@ -512,7 +545,7 @@ struct pci_bus *pci_scan_bus_on_node(int busno, struct pci_ops *ops, int node)
512 return bus; 545 return bus;
513} 546}
514 547
515struct pci_bus *pci_scan_bus_with_sysdata(int busno) 548struct pci_bus * __devinit pci_scan_bus_with_sysdata(int busno)
516{ 549{
517 return pci_scan_bus_on_node(busno, &pci_root_ops, -1); 550 return pci_scan_bus_on_node(busno, &pci_root_ops, -1);
518} 551}
diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
index b60b2abd480c..ff3a6a336342 100644
--- a/arch/x86/pci/fixup.c
+++ b/arch/x86/pci/fixup.c
@@ -502,7 +502,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SIEMENS, 0x0015,
502 */ 502 */
503static void fam10h_pci_cfg_space_size(struct pci_dev *dev) 503static void fam10h_pci_cfg_space_size(struct pci_dev *dev)
504{ 504{
505 dev->cfg_size = pci_cfg_space_size_ext(dev, 0); 505 dev->cfg_size = pci_cfg_space_size_ext(dev);
506} 506}
507 507
508DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1200, fam10h_pci_cfg_space_size); 508DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, 0x1200, fam10h_pci_cfg_space_size);
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 8af0f0bae2af..10fb308fded8 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -301,15 +301,13 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
301 prot = pgprot_val(vma->vm_page_prot); 301 prot = pgprot_val(vma->vm_page_prot);
302 if (pat_wc_enabled && write_combine) 302 if (pat_wc_enabled && write_combine)
303 prot |= _PAGE_CACHE_WC; 303 prot |= _PAGE_CACHE_WC;
304 else if (pat_wc_enabled) 304 else if (pat_wc_enabled || boot_cpu_data.x86 > 3)
305 /* 305 /*
306 * ioremap() and ioremap_nocache() defaults to UC MINUS for now. 306 * ioremap() and ioremap_nocache() defaults to UC MINUS for now.
307 * To avoid attribute conflicts, request UC MINUS here 307 * To avoid attribute conflicts, request UC MINUS here
308 * aswell. 308 * aswell.
309 */ 309 */
310 prot |= _PAGE_CACHE_UC_MINUS; 310 prot |= _PAGE_CACHE_UC_MINUS;
311 else if (boot_cpu_data.x86 > 3)
312 prot |= _PAGE_CACHE_UC;
313 311
314 vma->vm_page_prot = __pgprot(prot); 312 vma->vm_page_prot = __pgprot(prot);
315 313
diff --git a/arch/x86/pci/init.c b/arch/x86/pci/init.c
index dd30c6076b5d..e70b9c57b88e 100644
--- a/arch/x86/pci/init.c
+++ b/arch/x86/pci/init.c
@@ -33,6 +33,10 @@ static __init int pci_access_init(void)
33 printk(KERN_ERR 33 printk(KERN_ERR
34 "PCI: Fatal: No config space access function found\n"); 34 "PCI: Fatal: No config space access function found\n");
35 35
36 dmi_check_pciprobe();
37
38 dmi_check_skip_isa_align();
39
36 return 0; 40 return 0;
37} 41}
38arch_initcall(pci_access_init); 42arch_initcall(pci_access_init);
diff --git a/arch/x86/pci/k8-bus_64.c b/arch/x86/pci/k8-bus_64.c
index ab6d4b18a88f..5c2799c20e47 100644
--- a/arch/x86/pci/k8-bus_64.c
+++ b/arch/x86/pci/k8-bus_64.c
@@ -504,14 +504,6 @@ static int __init early_fill_mp_bus_info(void)
504 } 504 }
505 } 505 }
506 506
507#ifdef CONFIG_NUMA
508 for (i = 0; i < BUS_NR; i++) {
509 node = mp_bus_to_node[i];
510 if (node >= 0)
511 printk(KERN_DEBUG "bus: %02x to node: %02x\n", i, node);
512 }
513#endif
514
515 for (i = 0; i < pci_root_num; i++) { 507 for (i = 0; i < pci_root_num; i++) {
516 int res_num; 508 int res_num;
517 int busnum; 509 int busnum;
diff --git a/arch/x86/pci/pci.h b/arch/x86/pci/pci.h
index c58805a92db5..f3972b12c60a 100644
--- a/arch/x86/pci/pci.h
+++ b/arch/x86/pci/pci.h
@@ -38,6 +38,9 @@ enum pci_bf_sort_state {
38 pci_dmi_bf, 38 pci_dmi_bf,
39}; 39};
40 40
41extern void __init dmi_check_pciprobe(void);
42extern void __init dmi_check_skip_isa_align(void);
43
41/* pci-i386.c */ 44/* pci-i386.c */
42 45
43extern unsigned int pcibios_max_latency; 46extern unsigned int pcibios_max_latency;
diff --git a/block/blk-core.c b/block/blk-core.c
index b754a4a2f9bd..6a9cc0d22a61 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -54,15 +54,16 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
54 54
55static void drive_stat_acct(struct request *rq, int new_io) 55static void drive_stat_acct(struct request *rq, int new_io)
56{ 56{
57 struct hd_struct *part;
57 int rw = rq_data_dir(rq); 58 int rw = rq_data_dir(rq);
58 59
59 if (!blk_fs_request(rq) || !rq->rq_disk) 60 if (!blk_fs_request(rq) || !rq->rq_disk)
60 return; 61 return;
61 62
62 if (!new_io) { 63 part = get_part(rq->rq_disk, rq->sector);
63 __all_stat_inc(rq->rq_disk, merges[rw], rq->sector); 64 if (!new_io)
64 } else { 65 __all_stat_inc(rq->rq_disk, part, merges[rw], rq->sector);
65 struct hd_struct *part = get_part(rq->rq_disk, rq->sector); 66 else {
66 disk_round_stats(rq->rq_disk); 67 disk_round_stats(rq->rq_disk);
67 rq->rq_disk->in_flight++; 68 rq->rq_disk->in_flight++;
68 if (part) { 69 if (part) {
@@ -253,9 +254,11 @@ EXPORT_SYMBOL(__generic_unplug_device);
253 **/ 254 **/
254void generic_unplug_device(struct request_queue *q) 255void generic_unplug_device(struct request_queue *q)
255{ 256{
256 spin_lock_irq(q->queue_lock); 257 if (blk_queue_plugged(q)) {
257 __generic_unplug_device(q); 258 spin_lock_irq(q->queue_lock);
258 spin_unlock_irq(q->queue_lock); 259 __generic_unplug_device(q);
260 spin_unlock_irq(q->queue_lock);
261 }
259} 262}
260EXPORT_SYMBOL(generic_unplug_device); 263EXPORT_SYMBOL(generic_unplug_device);
261 264
@@ -479,6 +482,7 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
479 kobject_init(&q->kobj, &blk_queue_ktype); 482 kobject_init(&q->kobj, &blk_queue_ktype);
480 483
481 mutex_init(&q->sysfs_lock); 484 mutex_init(&q->sysfs_lock);
485 spin_lock_init(&q->__queue_lock);
482 486
483 return q; 487 return q;
484} 488}
@@ -541,10 +545,8 @@ blk_init_queue_node(request_fn_proc *rfn, spinlock_t *lock, int node_id)
541 * if caller didn't supply a lock, they get per-queue locking with 545 * if caller didn't supply a lock, they get per-queue locking with
542 * our embedded lock 546 * our embedded lock
543 */ 547 */
544 if (!lock) { 548 if (!lock)
545 spin_lock_init(&q->__queue_lock);
546 lock = &q->__queue_lock; 549 lock = &q->__queue_lock;
547 }
548 550
549 q->request_fn = rfn; 551 q->request_fn = rfn;
550 q->prep_rq_fn = NULL; 552 q->prep_rq_fn = NULL;
@@ -1536,10 +1538,11 @@ static int __end_that_request_first(struct request *req, int error,
1536 } 1538 }
1537 1539
1538 if (blk_fs_request(req) && req->rq_disk) { 1540 if (blk_fs_request(req) && req->rq_disk) {
1541 struct hd_struct *part = get_part(req->rq_disk, req->sector);
1539 const int rw = rq_data_dir(req); 1542 const int rw = rq_data_dir(req);
1540 1543
1541 all_stat_add(req->rq_disk, sectors[rw], 1544 all_stat_add(req->rq_disk, part, sectors[rw],
1542 nr_bytes >> 9, req->sector); 1545 nr_bytes >> 9, req->sector);
1543 } 1546 }
1544 1547
1545 total_bytes = bio_nbytes = 0; 1548 total_bytes = bio_nbytes = 0;
@@ -1725,8 +1728,8 @@ static void end_that_request_last(struct request *req, int error)
1725 const int rw = rq_data_dir(req); 1728 const int rw = rq_data_dir(req);
1726 struct hd_struct *part = get_part(disk, req->sector); 1729 struct hd_struct *part = get_part(disk, req->sector);
1727 1730
1728 __all_stat_inc(disk, ios[rw], req->sector); 1731 __all_stat_inc(disk, part, ios[rw], req->sector);
1729 __all_stat_add(disk, ticks[rw], duration, req->sector); 1732 __all_stat_add(disk, part, ticks[rw], duration, req->sector);
1730 disk_round_stats(disk); 1733 disk_round_stats(disk);
1731 disk->in_flight--; 1734 disk->in_flight--;
1732 if (part) { 1735 if (part) {
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index e34df7c9fc36..012f065ac8e2 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -41,8 +41,8 @@ int put_io_context(struct io_context *ioc)
41 rcu_read_lock(); 41 rcu_read_lock();
42 if (ioc->aic && ioc->aic->dtor) 42 if (ioc->aic && ioc->aic->dtor)
43 ioc->aic->dtor(ioc->aic); 43 ioc->aic->dtor(ioc->aic);
44 rcu_read_unlock();
45 cfq_dtor(ioc); 44 cfq_dtor(ioc);
45 rcu_read_unlock();
46 46
47 kmem_cache_free(iocontext_cachep, ioc); 47 kmem_cache_free(iocontext_cachep, ioc);
48 return 1; 48 return 1;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 73b23562af20..651136aae76e 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -149,9 +149,9 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
149static int blk_hw_contig_segment(struct request_queue *q, struct bio *bio, 149static int blk_hw_contig_segment(struct request_queue *q, struct bio *bio,
150 struct bio *nxt) 150 struct bio *nxt)
151{ 151{
152 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 152 if (!bio_flagged(bio, BIO_SEG_VALID))
153 blk_recount_segments(q, bio); 153 blk_recount_segments(q, bio);
154 if (unlikely(!bio_flagged(nxt, BIO_SEG_VALID))) 154 if (!bio_flagged(nxt, BIO_SEG_VALID))
155 blk_recount_segments(q, nxt); 155 blk_recount_segments(q, nxt);
156 if (!BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)) || 156 if (!BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(nxt)) ||
157 BIOVEC_VIRT_OVERSIZE(bio->bi_hw_back_size + nxt->bi_hw_front_size)) 157 BIOVEC_VIRT_OVERSIZE(bio->bi_hw_back_size + nxt->bi_hw_front_size))
@@ -312,9 +312,9 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req,
312 q->last_merge = NULL; 312 q->last_merge = NULL;
313 return 0; 313 return 0;
314 } 314 }
315 if (unlikely(!bio_flagged(req->biotail, BIO_SEG_VALID))) 315 if (!bio_flagged(req->biotail, BIO_SEG_VALID))
316 blk_recount_segments(q, req->biotail); 316 blk_recount_segments(q, req->biotail);
317 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 317 if (!bio_flagged(bio, BIO_SEG_VALID))
318 blk_recount_segments(q, bio); 318 blk_recount_segments(q, bio);
319 len = req->biotail->bi_hw_back_size + bio->bi_hw_front_size; 319 len = req->biotail->bi_hw_back_size + bio->bi_hw_front_size;
320 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(req->biotail), __BVEC_START(bio)) 320 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(req->biotail), __BVEC_START(bio))
@@ -352,9 +352,9 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req,
352 return 0; 352 return 0;
353 } 353 }
354 len = bio->bi_hw_back_size + req->bio->bi_hw_front_size; 354 len = bio->bi_hw_back_size + req->bio->bi_hw_front_size;
355 if (unlikely(!bio_flagged(bio, BIO_SEG_VALID))) 355 if (!bio_flagged(bio, BIO_SEG_VALID))
356 blk_recount_segments(q, bio); 356 blk_recount_segments(q, bio);
357 if (unlikely(!bio_flagged(req->bio, BIO_SEG_VALID))) 357 if (!bio_flagged(req->bio, BIO_SEG_VALID))
358 blk_recount_segments(q, req->bio); 358 blk_recount_segments(q, req->bio);
359 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(req->bio)) && 359 if (BIOVEC_VIRT_MERGEABLE(__BVEC_END(bio), __BVEC_START(req->bio)) &&
360 !BIOVEC_VIRT_OVERSIZE(len)) { 360 !BIOVEC_VIRT_OVERSIZE(len)) {
diff --git a/block/blk-settings.c b/block/blk-settings.c
index bb93d4c32775..8dd86418f35d 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -286,8 +286,14 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
286 t->max_hw_segments = min(t->max_hw_segments, b->max_hw_segments); 286 t->max_hw_segments = min(t->max_hw_segments, b->max_hw_segments);
287 t->max_segment_size = min(t->max_segment_size, b->max_segment_size); 287 t->max_segment_size = min(t->max_segment_size, b->max_segment_size);
288 t->hardsect_size = max(t->hardsect_size, b->hardsect_size); 288 t->hardsect_size = max(t->hardsect_size, b->hardsect_size);
289 if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) 289 if (!t->queue_lock)
290 WARN_ON_ONCE(1);
291 else if (!test_bit(QUEUE_FLAG_CLUSTER, &b->queue_flags)) {
292 unsigned long flags;
293 spin_lock_irqsave(t->queue_lock, flags);
290 queue_flag_clear(QUEUE_FLAG_CLUSTER, t); 294 queue_flag_clear(QUEUE_FLAG_CLUSTER, t);
295 spin_unlock_irqrestore(t->queue_lock, flags);
296 }
291} 297}
292EXPORT_SYMBOL(blk_queue_stack_limits); 298EXPORT_SYMBOL(blk_queue_stack_limits);
293 299
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e85c4013e8a2..304ec73ab821 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -146,11 +146,13 @@ static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
146 unsigned long nm; 146 unsigned long nm;
147 ssize_t ret = queue_var_store(&nm, page, count); 147 ssize_t ret = queue_var_store(&nm, page, count);
148 148
149 spin_lock_irq(q->queue_lock);
149 if (nm) 150 if (nm)
150 set_bit(QUEUE_FLAG_NOMERGES, &q->queue_flags); 151 queue_flag_set(QUEUE_FLAG_NOMERGES, q);
151 else 152 else
152 clear_bit(QUEUE_FLAG_NOMERGES, &q->queue_flags); 153 queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
153 154
155 spin_unlock_irq(q->queue_lock);
154 return ret; 156 return ret;
155} 157}
156 158
diff --git a/block/blk-tag.c b/block/blk-tag.c
index de64e0429977..32667beb03ee 100644
--- a/block/blk-tag.c
+++ b/block/blk-tag.c
@@ -70,7 +70,7 @@ void __blk_queue_free_tags(struct request_queue *q)
70 __blk_free_tags(bqt); 70 __blk_free_tags(bqt);
71 71
72 q->queue_tags = NULL; 72 q->queue_tags = NULL;
73 queue_flag_clear(QUEUE_FLAG_QUEUED, q); 73 queue_flag_clear_unlocked(QUEUE_FLAG_QUEUED, q);
74} 74}
75 75
76/** 76/**
@@ -98,7 +98,7 @@ EXPORT_SYMBOL(blk_free_tags);
98 **/ 98 **/
99void blk_queue_free_tags(struct request_queue *q) 99void blk_queue_free_tags(struct request_queue *q)
100{ 100{
101 queue_flag_clear(QUEUE_FLAG_QUEUED, q); 101 queue_flag_clear_unlocked(QUEUE_FLAG_QUEUED, q);
102} 102}
103EXPORT_SYMBOL(blk_queue_free_tags); 103EXPORT_SYMBOL(blk_queue_free_tags);
104 104
@@ -171,6 +171,9 @@ EXPORT_SYMBOL(blk_init_tags);
171 * @q: the request queue for the device 171 * @q: the request queue for the device
172 * @depth: the maximum queue depth supported 172 * @depth: the maximum queue depth supported
173 * @tags: the tag to use 173 * @tags: the tag to use
174 *
175 * Queue lock must be held here if the function is called to resize an
176 * existing map.
174 **/ 177 **/
175int blk_queue_init_tags(struct request_queue *q, int depth, 178int blk_queue_init_tags(struct request_queue *q, int depth,
176 struct blk_queue_tag *tags) 179 struct blk_queue_tag *tags)
@@ -197,7 +200,7 @@ int blk_queue_init_tags(struct request_queue *q, int depth,
197 * assign it, all done 200 * assign it, all done
198 */ 201 */
199 q->queue_tags = tags; 202 q->queue_tags = tags;
200 queue_flag_set(QUEUE_FLAG_QUEUED, q); 203 queue_flag_set_unlocked(QUEUE_FLAG_QUEUED, q);
201 INIT_LIST_HEAD(&q->tag_busy_list); 204 INIT_LIST_HEAD(&q->tag_busy_list);
202 return 0; 205 return 0;
203fail: 206fail:
diff --git a/block/blktrace.c b/block/blktrace.c
index 568588cd16b2..b2cbb4e5d767 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -476,7 +476,7 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
476 476
477 switch (cmd) { 477 switch (cmd) {
478 case BLKTRACESETUP: 478 case BLKTRACESETUP:
479 strcpy(b, bdevname(bdev, b)); 479 bdevname(bdev, b);
480 ret = blk_trace_setup(q, b, bdev->bd_dev, arg); 480 ret = blk_trace_setup(q, b, bdev->bd_dev, arg);
481 break; 481 break;
482 case BLKTRACESTART: 482 case BLKTRACESTART:
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index f4e1006c253d..b399c62936e0 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1142,6 +1142,17 @@ static void cfq_put_queue(struct cfq_queue *cfqq)
1142 kmem_cache_free(cfq_pool, cfqq); 1142 kmem_cache_free(cfq_pool, cfqq);
1143} 1143}
1144 1144
1145static void
1146__call_for_each_cic(struct io_context *ioc,
1147 void (*func)(struct io_context *, struct cfq_io_context *))
1148{
1149 struct cfq_io_context *cic;
1150 struct hlist_node *n;
1151
1152 hlist_for_each_entry_rcu(cic, n, &ioc->cic_list, cic_list)
1153 func(ioc, cic);
1154}
1155
1145/* 1156/*
1146 * Call func for each cic attached to this ioc. 1157 * Call func for each cic attached to this ioc.
1147 */ 1158 */
@@ -1149,12 +1160,8 @@ static void
1149call_for_each_cic(struct io_context *ioc, 1160call_for_each_cic(struct io_context *ioc,
1150 void (*func)(struct io_context *, struct cfq_io_context *)) 1161 void (*func)(struct io_context *, struct cfq_io_context *))
1151{ 1162{
1152 struct cfq_io_context *cic;
1153 struct hlist_node *n;
1154
1155 rcu_read_lock(); 1163 rcu_read_lock();
1156 hlist_for_each_entry_rcu(cic, n, &ioc->cic_list, cic_list) 1164 __call_for_each_cic(ioc, func);
1157 func(ioc, cic);
1158 rcu_read_unlock(); 1165 rcu_read_unlock();
1159} 1166}
1160 1167
@@ -1198,7 +1205,7 @@ static void cfq_free_io_context(struct io_context *ioc)
1198 * should be ok to iterate over the known list, we will see all cic's 1205 * should be ok to iterate over the known list, we will see all cic's
1199 * since no new ones are added. 1206 * since no new ones are added.
1200 */ 1207 */
1201 call_for_each_cic(ioc, cic_free_func); 1208 __call_for_each_cic(ioc, cic_free_func);
1202} 1209}
1203 1210
1204static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq) 1211static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
@@ -1296,10 +1303,10 @@ static void cfq_init_prio_data(struct cfq_queue *cfqq, struct io_context *ioc)
1296 printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class); 1303 printk(KERN_ERR "cfq: bad prio %x\n", ioprio_class);
1297 case IOPRIO_CLASS_NONE: 1304 case IOPRIO_CLASS_NONE:
1298 /* 1305 /*
1299 * no prio set, place us in the middle of the BE classes 1306 * no prio set, inherit CPU scheduling settings
1300 */ 1307 */
1301 cfqq->ioprio = task_nice_ioprio(tsk); 1308 cfqq->ioprio = task_nice_ioprio(tsk);
1302 cfqq->ioprio_class = IOPRIO_CLASS_BE; 1309 cfqq->ioprio_class = task_nice_ioclass(tsk);
1303 break; 1310 break;
1304 case IOPRIO_CLASS_RT: 1311 case IOPRIO_CLASS_RT:
1305 cfqq->ioprio = task_ioprio(ioc); 1312 cfqq->ioprio = task_ioprio(ioc);
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
index c70d0b6f666f..c23177e4623f 100644
--- a/block/compat_ioctl.c
+++ b/block/compat_ioctl.c
@@ -555,7 +555,7 @@ static int compat_blk_trace_setup(struct block_device *bdev, char __user *arg)
555 if (copy_from_user(&cbuts, arg, sizeof(cbuts))) 555 if (copy_from_user(&cbuts, arg, sizeof(cbuts)))
556 return -EFAULT; 556 return -EFAULT;
557 557
558 strcpy(b, bdevname(bdev, b)); 558 bdevname(bdev, b);
559 559
560 buts = (struct blk_user_trace_setup) { 560 buts = (struct blk_user_trace_setup) {
561 .act_mask = cbuts.act_mask, 561 .act_mask = cbuts.act_mask,
diff --git a/block/genhd.c b/block/genhd.c
index fda9c7a63c29..129ad939f9dd 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -653,7 +653,7 @@ void genhd_media_change_notify(struct gendisk *disk)
653EXPORT_SYMBOL_GPL(genhd_media_change_notify); 653EXPORT_SYMBOL_GPL(genhd_media_change_notify);
654#endif /* 0 */ 654#endif /* 0 */
655 655
656dev_t blk_lookup_devt(const char *name) 656dev_t blk_lookup_devt(const char *name, int part)
657{ 657{
658 struct device *dev; 658 struct device *dev;
659 dev_t devt = MKDEV(0, 0); 659 dev_t devt = MKDEV(0, 0);
@@ -661,7 +661,11 @@ dev_t blk_lookup_devt(const char *name)
661 mutex_lock(&block_class_lock); 661 mutex_lock(&block_class_lock);
662 list_for_each_entry(dev, &block_class.devices, node) { 662 list_for_each_entry(dev, &block_class.devices, node) {
663 if (strcmp(dev->bus_id, name) == 0) { 663 if (strcmp(dev->bus_id, name) == 0) {
664 devt = dev->devt; 664 struct gendisk *disk = dev_to_disk(dev);
665
666 if (part < disk->minors)
667 devt = MKDEV(MAJOR(dev->devt),
668 MINOR(dev->devt) + part);
665 break; 669 break;
666 } 670 }
667 } 671 }
@@ -669,7 +673,6 @@ dev_t blk_lookup_devt(const char *name)
669 673
670 return devt; 674 return devt;
671} 675}
672
673EXPORT_SYMBOL(blk_lookup_devt); 676EXPORT_SYMBOL(blk_lookup_devt);
674 677
675struct gendisk *alloc_disk(int minors) 678struct gendisk *alloc_disk(int minors)
diff --git a/crypto/hmac.c b/crypto/hmac.c
index b60c3c7aa320..14c6351e639d 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -57,14 +57,35 @@ static int hmac_setkey(struct crypto_hash *parent,
57 if (keylen > bs) { 57 if (keylen > bs) {
58 struct hash_desc desc; 58 struct hash_desc desc;
59 struct scatterlist tmp; 59 struct scatterlist tmp;
60 int tmplen;
60 int err; 61 int err;
61 62
62 desc.tfm = tfm; 63 desc.tfm = tfm;
63 desc.flags = crypto_hash_get_flags(parent); 64 desc.flags = crypto_hash_get_flags(parent);
64 desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP; 65 desc.flags &= CRYPTO_TFM_REQ_MAY_SLEEP;
65 sg_init_one(&tmp, inkey, keylen);
66 66
67 err = crypto_hash_digest(&desc, &tmp, keylen, digest); 67 err = crypto_hash_init(&desc);
68 if (err)
69 return err;
70
71 tmplen = bs * 2 + ds;
72 sg_init_one(&tmp, ipad, tmplen);
73
74 for (; keylen > tmplen; inkey += tmplen, keylen -= tmplen) {
75 memcpy(ipad, inkey, tmplen);
76 err = crypto_hash_update(&desc, &tmp, tmplen);
77 if (err)
78 return err;
79 }
80
81 if (keylen) {
82 memcpy(ipad, inkey, keylen);
83 err = crypto_hash_update(&desc, &tmp, keylen);
84 if (err)
85 return err;
86 }
87
88 err = crypto_hash_final(&desc, digest);
68 if (err) 89 if (err)
69 return err; 90 return err;
70 91
diff --git a/drivers/accessibility/Kconfig b/drivers/accessibility/Kconfig
index 1264c4b98094..ef3b65bfdd0a 100644
--- a/drivers/accessibility/Kconfig
+++ b/drivers/accessibility/Kconfig
@@ -1,7 +1,17 @@
1menuconfig ACCESSIBILITY 1menuconfig ACCESSIBILITY
2 bool "Accessibility support" 2 bool "Accessibility support"
3 ---help--- 3 ---help---
4 Enable a submenu where accessibility items may be enabled. 4 Accessibility handles all special kinds of hardware devices or
5 software adapters which help people with disabilities (e.g.
6 blindness) to use computers.
7
8 That includes braille devices, speech synthesis, keyboard
9 remapping, etc.
10
11 Say Y here to get to see options for accessibility.
12 This option alone does not add any kernel code.
13
14 If you say N, all options in this submenu will be skipped and disabled.
5 15
6 If unsure, say N. 16 If unsure, say N.
7 17
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 1c11df9a5f32..9bf2986a2788 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -205,8 +205,8 @@ config SATA_VITESSE
205 If unsure, say N. 205 If unsure, say N.
206 206
207config SATA_INIC162X 207config SATA_INIC162X
208 tristate "Initio 162x SATA support (HIGHLY EXPERIMENTAL)" 208 tristate "Initio 162x SATA support"
209 depends on PCI && EXPERIMENTAL 209 depends on PCI
210 help 210 help
211 This option enables support for Initio 162x Serial ATA. 211 This option enables support for Initio 162x Serial ATA.
212 212
@@ -697,6 +697,15 @@ config PATA_SCC
697 697
698 If unsure, say N. 698 If unsure, say N.
699 699
700config PATA_SCH
701 tristate "Intel SCH PATA support"
702 depends on PCI
703 help
704 This option enables support for Intel SCH PATA on the Intel
705 SCH (US15W, US15L, UL11L) series host controllers.
706
707 If unsure, say N.
708
700config PATA_BF54X 709config PATA_BF54X
701 tristate "Blackfin 54x ATAPI support" 710 tristate "Blackfin 54x ATAPI support"
702 depends on BF542 || BF548 || BF549 711 depends on BF542 || BF548 || BF549
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index b693d829383a..674965fa326d 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -67,6 +67,7 @@ obj-$(CONFIG_PATA_SIS) += pata_sis.o
67obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o 67obj-$(CONFIG_PATA_TRIFLEX) += pata_triflex.o
68obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o 68obj-$(CONFIG_PATA_IXP4XX_CF) += pata_ixp4xx_cf.o
69obj-$(CONFIG_PATA_SCC) += pata_scc.o 69obj-$(CONFIG_PATA_SCC) += pata_scc.o
70obj-$(CONFIG_PATA_SCH) += pata_sch.o
70obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o 71obj-$(CONFIG_PATA_BF54X) += pata_bf54x.o
71obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o 72obj-$(CONFIG_PATA_PLATFORM) += pata_platform.o
72obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o 73obj-$(CONFIG_PATA_OF_PLATFORM) += pata_of_platform.o
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 8cace9aa9c03..97f83fb2ee2e 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1267,9 +1267,7 @@ static int ahci_check_ready(struct ata_link *link)
1267 void __iomem *port_mmio = ahci_port_base(link->ap); 1267 void __iomem *port_mmio = ahci_port_base(link->ap);
1268 u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF; 1268 u8 status = readl(port_mmio + PORT_TFDATA) & 0xFF;
1269 1269
1270 if (!(status & ATA_BUSY)) 1270 return ata_check_ready(status);
1271 return 1;
1272 return 0;
1273} 1271}
1274 1272
1275static int ahci_softreset(struct ata_link *link, unsigned int *class, 1273static int ahci_softreset(struct ata_link *link, unsigned int *class,
diff --git a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
index 47aeccd52fa9..75a406f5e694 100644
--- a/drivers/ata/ata_generic.c
+++ b/drivers/ata/ata_generic.c
@@ -152,6 +152,12 @@ static int ata_generic_init_one(struct pci_dev *dev, const struct pci_device_id
152 if (dev->vendor == PCI_VENDOR_ID_AL) 152 if (dev->vendor == PCI_VENDOR_ID_AL)
153 ata_pci_bmdma_clear_simplex(dev); 153 ata_pci_bmdma_clear_simplex(dev);
154 154
155 if (dev->vendor == PCI_VENDOR_ID_ATI) {
156 int rc = pcim_enable_device(dev);
157 if (rc < 0)
158 return rc;
159 pcim_pin_device(dev);
160 }
155 return ata_pci_sff_init_one(dev, ppi, &generic_sht, NULL); 161 return ata_pci_sff_init_one(dev, ppi, &generic_sht, NULL);
156} 162}
157 163
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index ea2c7649d399..a9027b8fbdd5 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -1348,6 +1348,8 @@ static void __devinit piix_init_sidpr(struct ata_host *host)
1348{ 1348{
1349 struct pci_dev *pdev = to_pci_dev(host->dev); 1349 struct pci_dev *pdev = to_pci_dev(host->dev);
1350 struct piix_host_priv *hpriv = host->private_data; 1350 struct piix_host_priv *hpriv = host->private_data;
1351 struct ata_device *dev0 = &host->ports[0]->link.device[0];
1352 u32 scontrol;
1351 int i; 1353 int i;
1352 1354
1353 /* check for availability */ 1355 /* check for availability */
@@ -1366,6 +1368,29 @@ static void __devinit piix_init_sidpr(struct ata_host *host)
1366 return; 1368 return;
1367 1369
1368 hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR]; 1370 hpriv->sidpr = pcim_iomap_table(pdev)[PIIX_SIDPR_BAR];
1371
1372 /* SCR access via SIDPR doesn't work on some configurations.
1373 * Give it a test drive by inhibiting power save modes which
1374 * we'll do anyway.
1375 */
1376 scontrol = piix_sidpr_read(dev0, SCR_CONTROL);
1377
1378 /* if IPM is already 3, SCR access is probably working. Don't
1379 * un-inhibit power save modes as BIOS might have inhibited
1380 * them for a reason.
1381 */
1382 if ((scontrol & 0xf00) != 0x300) {
1383 scontrol |= 0x300;
1384 piix_sidpr_write(dev0, SCR_CONTROL, scontrol);
1385 scontrol = piix_sidpr_read(dev0, SCR_CONTROL);
1386
1387 if ((scontrol & 0xf00) != 0x300) {
1388 dev_printk(KERN_INFO, host->dev, "SCR access via "
1389 "SIDPR is available but doesn't work\n");
1390 return;
1391 }
1392 }
1393
1369 host->ports[0]->ops = &piix_sidpr_sata_ops; 1394 host->ports[0]->ops = &piix_sidpr_sata_ops;
1370 host->ports[1]->ops = &piix_sidpr_sata_ops; 1395 host->ports[1]->ops = &piix_sidpr_sata_ops;
1371} 1396}
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3bc488538204..927b692d723c 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -6292,6 +6292,7 @@ EXPORT_SYMBOL_GPL(ata_eh_freeze_port);
6292EXPORT_SYMBOL_GPL(ata_eh_thaw_port); 6292EXPORT_SYMBOL_GPL(ata_eh_thaw_port);
6293EXPORT_SYMBOL_GPL(ata_eh_qc_complete); 6293EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
6294EXPORT_SYMBOL_GPL(ata_eh_qc_retry); 6294EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
6295EXPORT_SYMBOL_GPL(ata_eh_analyze_ncq_error);
6295EXPORT_SYMBOL_GPL(ata_do_eh); 6296EXPORT_SYMBOL_GPL(ata_do_eh);
6296EXPORT_SYMBOL_GPL(ata_std_error_handler); 6297EXPORT_SYMBOL_GPL(ata_std_error_handler);
6297 6298
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 61dcd0026c64..62e033146bed 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -1357,7 +1357,7 @@ static void ata_eh_analyze_serror(struct ata_link *link)
1357 * LOCKING: 1357 * LOCKING:
1358 * Kernel thread context (may sleep). 1358 * Kernel thread context (may sleep).
1359 */ 1359 */
1360static void ata_eh_analyze_ncq_error(struct ata_link *link) 1360void ata_eh_analyze_ncq_error(struct ata_link *link)
1361{ 1361{
1362 struct ata_port *ap = link->ap; 1362 struct ata_port *ap = link->ap;
1363 struct ata_eh_context *ehc = &link->eh_context; 1363 struct ata_eh_context *ehc = &link->eh_context;
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 2ec65a8fda79..3c2d2289f85e 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -314,11 +314,7 @@ static int ata_sff_check_ready(struct ata_link *link)
314{ 314{
315 u8 status = link->ap->ops->sff_check_status(link->ap); 315 u8 status = link->ap->ops->sff_check_status(link->ap);
316 316
317 if (!(status & ATA_BUSY)) 317 return ata_check_ready(status);
318 return 1;
319 if (status == 0xff)
320 return -ENODEV;
321 return 0;
322} 318}
323 319
324/** 320/**
diff --git a/drivers/ata/pata_acpi.c b/drivers/ata/pata_acpi.c
index c5f91e629945..fbe605711554 100644
--- a/drivers/ata/pata_acpi.c
+++ b/drivers/ata/pata_acpi.c
@@ -259,6 +259,12 @@ static int pacpi_init_one (struct pci_dev *pdev, const struct pci_device_id *id)
259 .port_ops = &pacpi_ops, 259 .port_ops = &pacpi_ops,
260 }; 260 };
261 const struct ata_port_info *ppi[] = { &info, NULL }; 261 const struct ata_port_info *ppi[] = { &info, NULL };
262 if (pdev->vendor == PCI_VENDOR_ID_ATI) {
263 int rc = pcim_enable_device(pdev);
264 if (rc < 0)
265 return rc;
266 pcim_pin_device(pdev);
267 }
262 return ata_pci_sff_init_one(pdev, ppi, &pacpi_sht, NULL); 268 return ata_pci_sff_init_one(pdev, ppi, &pacpi_sht, NULL);
263} 269}
264 270
diff --git a/drivers/ata/pata_sch.c b/drivers/ata/pata_sch.c
new file mode 100644
index 000000000000..c8cc027789fe
--- /dev/null
+++ b/drivers/ata/pata_sch.c
@@ -0,0 +1,206 @@
1/*
2 * pata_sch.c - Intel SCH PATA controllers
3 *
4 * Copyright (c) 2008 Alek Du <alek.du@intel.com>
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 2 as published
8 * by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 */
20
21/*
22 * Supports:
23 * Intel SCH (AF82US15W, AF82US15L, AF82UL11L) chipsets -- see spec at:
24 * http://download.intel.com/design/chipsets/embedded/datashts/319537.pdf
25 */
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/pci.h>
30#include <linux/init.h>
31#include <linux/blkdev.h>
32#include <linux/delay.h>
33#include <linux/device.h>
34#include <scsi/scsi_host.h>
35#include <linux/libata.h>
36#include <linux/dmi.h>
37
38#define DRV_NAME "pata_sch"
39#define DRV_VERSION "0.2"
40
41/* see SCH datasheet page 351 */
42enum {
43 D0TIM = 0x80, /* Device 0 Timing Register */
44 D1TIM = 0x84, /* Device 1 Timing Register */
45 PM = 0x07, /* PIO Mode Bit Mask */
46 MDM = (0x03 << 8), /* Multi-word DMA Mode Bit Mask */
47 UDM = (0x07 << 16), /* Ultra DMA Mode Bit Mask */
48 PPE = (1 << 30), /* Prefetch/Post Enable */
49 USD = (1 << 31), /* Use Synchronous DMA */
50};
51
52static int sch_init_one(struct pci_dev *pdev,
53 const struct pci_device_id *ent);
54static void sch_set_piomode(struct ata_port *ap, struct ata_device *adev);
55static void sch_set_dmamode(struct ata_port *ap, struct ata_device *adev);
56
57static const struct pci_device_id sch_pci_tbl[] = {
58 /* Intel SCH PATA Controller */
59 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_SCH_IDE), 0 },
60 { } /* terminate list */
61};
62
63static struct pci_driver sch_pci_driver = {
64 .name = DRV_NAME,
65 .id_table = sch_pci_tbl,
66 .probe = sch_init_one,
67 .remove = ata_pci_remove_one,
68#ifdef CONFIG_PM
69 .suspend = ata_pci_device_suspend,
70 .resume = ata_pci_device_resume,
71#endif
72};
73
74static struct scsi_host_template sch_sht = {
75 ATA_BMDMA_SHT(DRV_NAME),
76};
77
78static struct ata_port_operations sch_pata_ops = {
79 .inherits = &ata_bmdma_port_ops,
80 .cable_detect = ata_cable_unknown,
81 .set_piomode = sch_set_piomode,
82 .set_dmamode = sch_set_dmamode,
83};
84
85static struct ata_port_info sch_port_info = {
86 .flags = 0,
87 .pio_mask = ATA_PIO4, /* pio0-4 */
88 .mwdma_mask = ATA_MWDMA2, /* mwdma0-2 */
89 .udma_mask = ATA_UDMA5, /* udma0-5 */
90 .port_ops = &sch_pata_ops,
91};
92
93MODULE_AUTHOR("Alek Du <alek.du@intel.com>");
94MODULE_DESCRIPTION("SCSI low-level driver for Intel SCH PATA controllers");
95MODULE_LICENSE("GPL");
96MODULE_DEVICE_TABLE(pci, sch_pci_tbl);
97MODULE_VERSION(DRV_VERSION);
98
99/**
100 * sch_set_piomode - Initialize host controller PATA PIO timings
101 * @ap: Port whose timings we are configuring
102 * @adev: ATA device
103 *
104 * Set PIO mode for device, in host controller PCI config space.
105 *
106 * LOCKING:
107 * None (inherited from caller).
108 */
109
110static void sch_set_piomode(struct ata_port *ap, struct ata_device *adev)
111{
112 unsigned int pio = adev->pio_mode - XFER_PIO_0;
113 struct pci_dev *dev = to_pci_dev(ap->host->dev);
114 unsigned int port = adev->devno ? D1TIM : D0TIM;
115 unsigned int data;
116
117 pci_read_config_dword(dev, port, &data);
118 /* see SCH datasheet page 351 */
119 /* set PIO mode */
120 data &= ~(PM | PPE);
121 data |= pio;
122 /* enable PPE for block device */
123 if (adev->class == ATA_DEV_ATA)
124 data |= PPE;
125 pci_write_config_dword(dev, port, data);
126}
127
128/**
129 * sch_set_dmamode - Initialize host controller PATA DMA timings
130 * @ap: Port whose timings we are configuring
131 * @adev: ATA device
132 *
133 * Set MW/UDMA mode for device, in host controller PCI config space.
134 *
135 * LOCKING:
136 * None (inherited from caller).
137 */
138
139static void sch_set_dmamode(struct ata_port *ap, struct ata_device *adev)
140{
141 unsigned int dma_mode = adev->dma_mode;
142 struct pci_dev *dev = to_pci_dev(ap->host->dev);
143 unsigned int port = adev->devno ? D1TIM : D0TIM;
144 unsigned int data;
145
146 pci_read_config_dword(dev, port, &data);
147 /* see SCH datasheet page 351 */
148 if (dma_mode >= XFER_UDMA_0) {
149 /* enable Synchronous DMA mode */
150 data |= USD;
151 data &= ~UDM;
152 data |= (dma_mode - XFER_UDMA_0) << 16;
153 } else { /* must be MWDMA mode, since we masked SWDMA already */
154 data &= ~(USD | MDM);
155 data |= (dma_mode - XFER_MW_DMA_0) << 8;
156 }
157 pci_write_config_dword(dev, port, data);
158}
159
160/**
161 * sch_init_one - Register SCH ATA PCI device with kernel services
162 * @pdev: PCI device to register
163 * @ent: Entry in sch_pci_tbl matching with @pdev
164 *
165 * LOCKING:
166 * Inherited from PCI layer (may sleep).
167 *
168 * RETURNS:
169 * Zero on success, or -ERRNO value.
170 */
171
172static int __devinit sch_init_one(struct pci_dev *pdev,
173 const struct pci_device_id *ent)
174{
175 static int printed_version;
176 const struct ata_port_info *ppi[] = { &sch_port_info, NULL };
177 struct ata_host *host;
178 int rc;
179
180 if (!printed_version++)
181 dev_printk(KERN_DEBUG, &pdev->dev,
182 "version " DRV_VERSION "\n");
183
184 /* enable device and prepare host */
185 rc = pcim_enable_device(pdev);
186 if (rc)
187 return rc;
188 rc = ata_pci_sff_prepare_host(pdev, ppi, &host);
189 if (rc)
190 return rc;
191 pci_set_master(pdev);
192 return ata_pci_sff_activate_host(host, ata_sff_interrupt, &sch_sht);
193}
194
195static int __init sch_init(void)
196{
197 return pci_register_driver(&sch_pci_driver);
198}
199
200static void __exit sch_exit(void)
201{
202 pci_unregister_driver(&sch_pci_driver);
203}
204
205module_init(sch_init);
206module_exit(sch_exit);
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index d27bb9a2568f..3ead02fe379e 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -10,13 +10,33 @@
10 * right. Documentation is available at initio's website but it only 10 * right. Documentation is available at initio's website but it only
11 * documents registers (not programming model). 11 * documents registers (not programming model).
12 * 12 *
13 * - ATA disks work. 13 * This driver has interesting history. The first version was written
14 * - Hotplug works. 14 * from the documentation and a 2.4 IDE driver posted on a Taiwan
15 * - ATAPI read works but burning doesn't. This thing is really 15 * company, which didn't use any IDMA features and couldn't handle
16 * peculiar about ATAPI and I couldn't figure out how ATAPI PIO and 16 * LBA48. The resulting driver couldn't handle LBA48 devices either
17 * ATAPI DMA WRITE should be programmed. If you've got a clue, be 17 * making it pretty useless.
18 * my guest. 18 *
19 * - Both STR and STD work. 19 * After a while, initio picked the driver up, renamed it to
20 * sata_initio162x, updated it to use IDMA for ATA DMA commands and
21 * posted it on their website. It only used ATA_PROT_DMA for IDMA and
22 * attaching both devices and issuing IDMA and !IDMA commands
23 * simultaneously broke it due to PIRQ masking interaction but it did
24 * show how to use the IDMA (ADMA + some initio specific twists)
25 * engine.
26 *
27 * Then, I picked up their changes again and here's the usable driver
28 * which uses IDMA for everything. Everything works now including
29 * LBA48, CD/DVD burning, suspend/resume and hotplug. There are some
30 * issues tho. Result Tf is not resported properly, NCQ isn't
31 * supported yet and CD/DVD writing works with DMA assisted PIO
32 * protocol (which, for native SATA devices, shouldn't cause any
33 * noticeable difference).
34 *
35 * Anyways, so, here's finally a working driver for inic162x. Enjoy!
36 *
37 * initio: If you guys wanna improve the driver regarding result TF
38 * access and other stuff, please feel free to contact me. I'll be
39 * happy to assist.
20 */ 40 */
21 41
22#include <linux/kernel.h> 42#include <linux/kernel.h>
@@ -28,13 +48,19 @@
28#include <scsi/scsi_device.h> 48#include <scsi/scsi_device.h>
29 49
30#define DRV_NAME "sata_inic162x" 50#define DRV_NAME "sata_inic162x"
31#define DRV_VERSION "0.3" 51#define DRV_VERSION "0.4"
32 52
33enum { 53enum {
34 MMIO_BAR = 5, 54 MMIO_BAR_PCI = 5,
55 MMIO_BAR_CARDBUS = 1,
35 56
36 NR_PORTS = 2, 57 NR_PORTS = 2,
37 58
59 IDMA_CPB_TBL_SIZE = 4 * 32,
60
61 INIC_DMA_BOUNDARY = 0xffffff,
62
63 HOST_ACTRL = 0x08,
38 HOST_CTL = 0x7c, 64 HOST_CTL = 0x7c,
39 HOST_STAT = 0x7e, 65 HOST_STAT = 0x7e,
40 HOST_IRQ_STAT = 0xbc, 66 HOST_IRQ_STAT = 0xbc,
@@ -43,22 +69,37 @@ enum {
43 PORT_SIZE = 0x40, 69 PORT_SIZE = 0x40,
44 70
45 /* registers for ATA TF operation */ 71 /* registers for ATA TF operation */
46 PORT_TF = 0x00, 72 PORT_TF_DATA = 0x00,
47 PORT_ALT_STAT = 0x08, 73 PORT_TF_FEATURE = 0x01,
74 PORT_TF_NSECT = 0x02,
75 PORT_TF_LBAL = 0x03,
76 PORT_TF_LBAM = 0x04,
77 PORT_TF_LBAH = 0x05,
78 PORT_TF_DEVICE = 0x06,
79 PORT_TF_COMMAND = 0x07,
80 PORT_TF_ALT_STAT = 0x08,
48 PORT_IRQ_STAT = 0x09, 81 PORT_IRQ_STAT = 0x09,
49 PORT_IRQ_MASK = 0x0a, 82 PORT_IRQ_MASK = 0x0a,
50 PORT_PRD_CTL = 0x0b, 83 PORT_PRD_CTL = 0x0b,
51 PORT_PRD_ADDR = 0x0c, 84 PORT_PRD_ADDR = 0x0c,
52 PORT_PRD_XFERLEN = 0x10, 85 PORT_PRD_XFERLEN = 0x10,
86 PORT_CPB_CPBLAR = 0x18,
87 PORT_CPB_PTQFIFO = 0x1c,
53 88
54 /* IDMA register */ 89 /* IDMA register */
55 PORT_IDMA_CTL = 0x14, 90 PORT_IDMA_CTL = 0x14,
91 PORT_IDMA_STAT = 0x16,
92
93 PORT_RPQ_FIFO = 0x1e,
94 PORT_RPQ_CNT = 0x1f,
56 95
57 PORT_SCR = 0x20, 96 PORT_SCR = 0x20,
58 97
59 /* HOST_CTL bits */ 98 /* HOST_CTL bits */
60 HCTL_IRQOFF = (1 << 8), /* global IRQ off */ 99 HCTL_IRQOFF = (1 << 8), /* global IRQ off */
61 HCTL_PWRDWN = (1 << 13), /* power down PHYs */ 100 HCTL_FTHD0 = (1 << 10), /* fifo threshold 0 */
101 HCTL_FTHD1 = (1 << 11), /* fifo threshold 1*/
102 HCTL_PWRDWN = (1 << 12), /* power down PHYs */
62 HCTL_SOFTRST = (1 << 13), /* global reset (no phy reset) */ 103 HCTL_SOFTRST = (1 << 13), /* global reset (no phy reset) */
63 HCTL_RPGSEL = (1 << 15), /* register page select */ 104 HCTL_RPGSEL = (1 << 15), /* register page select */
64 105
@@ -81,9 +122,7 @@ enum {
81 PIRQ_PENDING = (1 << 7), /* port IRQ pending (STAT only) */ 122 PIRQ_PENDING = (1 << 7), /* port IRQ pending (STAT only) */
82 123
83 PIRQ_ERR = PIRQ_OFFLINE | PIRQ_ONLINE | PIRQ_FATAL, 124 PIRQ_ERR = PIRQ_OFFLINE | PIRQ_ONLINE | PIRQ_FATAL,
84 125 PIRQ_MASK_DEFAULT = PIRQ_REPLY | PIRQ_ATA,
85 PIRQ_MASK_DMA_READ = PIRQ_REPLY | PIRQ_ATA,
86 PIRQ_MASK_OTHER = PIRQ_REPLY | PIRQ_COMPLETE,
87 PIRQ_MASK_FREEZE = 0xff, 126 PIRQ_MASK_FREEZE = 0xff,
88 127
89 /* PORT_PRD_CTL bits */ 128 /* PORT_PRD_CTL bits */
@@ -96,20 +135,104 @@ enum {
96 IDMA_CTL_RST_IDMA = (1 << 5), /* reset IDMA machinary */ 135 IDMA_CTL_RST_IDMA = (1 << 5), /* reset IDMA machinary */
97 IDMA_CTL_GO = (1 << 7), /* IDMA mode go */ 136 IDMA_CTL_GO = (1 << 7), /* IDMA mode go */
98 IDMA_CTL_ATA_NIEN = (1 << 8), /* ATA IRQ disable */ 137 IDMA_CTL_ATA_NIEN = (1 << 8), /* ATA IRQ disable */
138
139 /* PORT_IDMA_STAT bits */
140 IDMA_STAT_PERR = (1 << 0), /* PCI ERROR MODE */
141 IDMA_STAT_CPBERR = (1 << 1), /* ADMA CPB error */
142 IDMA_STAT_LGCY = (1 << 3), /* ADMA legacy */
143 IDMA_STAT_UIRQ = (1 << 4), /* ADMA unsolicited irq */
144 IDMA_STAT_STPD = (1 << 5), /* ADMA stopped */
145 IDMA_STAT_PSD = (1 << 6), /* ADMA pause */
146 IDMA_STAT_DONE = (1 << 7), /* ADMA done */
147
148 IDMA_STAT_ERR = IDMA_STAT_PERR | IDMA_STAT_CPBERR,
149
150 /* CPB Control Flags*/
151 CPB_CTL_VALID = (1 << 0), /* CPB valid */
152 CPB_CTL_QUEUED = (1 << 1), /* queued command */
153 CPB_CTL_DATA = (1 << 2), /* data, rsvd in datasheet */
154 CPB_CTL_IEN = (1 << 3), /* PCI interrupt enable */
155 CPB_CTL_DEVDIR = (1 << 4), /* device direction control */
156
157 /* CPB Response Flags */
158 CPB_RESP_DONE = (1 << 0), /* ATA command complete */
159 CPB_RESP_REL = (1 << 1), /* ATA release */
160 CPB_RESP_IGNORED = (1 << 2), /* CPB ignored */
161 CPB_RESP_ATA_ERR = (1 << 3), /* ATA command error */
162 CPB_RESP_SPURIOUS = (1 << 4), /* ATA spurious interrupt error */
163 CPB_RESP_UNDERFLOW = (1 << 5), /* APRD deficiency length error */
164 CPB_RESP_OVERFLOW = (1 << 6), /* APRD exccess length error */
165 CPB_RESP_CPB_ERR = (1 << 7), /* CPB error flag */
166
167 /* PRD Control Flags */
168 PRD_DRAIN = (1 << 1), /* ignore data excess */
169 PRD_CDB = (1 << 2), /* atapi packet command pointer */
170 PRD_DIRECT_INTR = (1 << 3), /* direct interrupt */
171 PRD_DMA = (1 << 4), /* data transfer method */
172 PRD_WRITE = (1 << 5), /* data dir, rsvd in datasheet */
173 PRD_IOM = (1 << 6), /* io/memory transfer */
174 PRD_END = (1 << 7), /* APRD chain end */
99}; 175};
100 176
177/* Comman Parameter Block */
178struct inic_cpb {
179 u8 resp_flags; /* Response Flags */
180 u8 error; /* ATA Error */
181 u8 status; /* ATA Status */
182 u8 ctl_flags; /* Control Flags */
183 __le32 len; /* Total Transfer Length */
184 __le32 prd; /* First PRD pointer */
185 u8 rsvd[4];
186 /* 16 bytes */
187 u8 feature; /* ATA Feature */
188 u8 hob_feature; /* ATA Ex. Feature */
189 u8 device; /* ATA Device/Head */
190 u8 mirctl; /* Mirror Control */
191 u8 nsect; /* ATA Sector Count */
192 u8 hob_nsect; /* ATA Ex. Sector Count */
193 u8 lbal; /* ATA Sector Number */
194 u8 hob_lbal; /* ATA Ex. Sector Number */
195 u8 lbam; /* ATA Cylinder Low */
196 u8 hob_lbam; /* ATA Ex. Cylinder Low */
197 u8 lbah; /* ATA Cylinder High */
198 u8 hob_lbah; /* ATA Ex. Cylinder High */
199 u8 command; /* ATA Command */
200 u8 ctl; /* ATA Control */
201 u8 slave_error; /* Slave ATA Error */
202 u8 slave_status; /* Slave ATA Status */
203 /* 32 bytes */
204} __packed;
205
206/* Physical Region Descriptor */
207struct inic_prd {
208 __le32 mad; /* Physical Memory Address */
209 __le16 len; /* Transfer Length */
210 u8 rsvd;
211 u8 flags; /* Control Flags */
212} __packed;
213
214struct inic_pkt {
215 struct inic_cpb cpb;
216 struct inic_prd prd[LIBATA_MAX_PRD + 1]; /* + 1 for cdb */
217 u8 cdb[ATAPI_CDB_LEN];
218} __packed;
219
101struct inic_host_priv { 220struct inic_host_priv {
102 u16 cached_hctl; 221 void __iomem *mmio_base;
222 u16 cached_hctl;
103}; 223};
104 224
105struct inic_port_priv { 225struct inic_port_priv {
106 u8 dfl_prdctl; 226 struct inic_pkt *pkt;
107 u8 cached_prdctl; 227 dma_addr_t pkt_dma;
108 u8 cached_pirq_mask; 228 u32 *cpb_tbl;
229 dma_addr_t cpb_tbl_dma;
109}; 230};
110 231
111static struct scsi_host_template inic_sht = { 232static struct scsi_host_template inic_sht = {
112 ATA_BMDMA_SHT(DRV_NAME), 233 ATA_BASE_SHT(DRV_NAME),
234 .sg_tablesize = LIBATA_MAX_PRD, /* maybe it can be larger? */
235 .dma_boundary = INIC_DMA_BOUNDARY,
113}; 236};
114 237
115static const int scr_map[] = { 238static const int scr_map[] = {
@@ -120,54 +243,34 @@ static const int scr_map[] = {
120 243
121static void __iomem *inic_port_base(struct ata_port *ap) 244static void __iomem *inic_port_base(struct ata_port *ap)
122{ 245{
123 return ap->host->iomap[MMIO_BAR] + ap->port_no * PORT_SIZE; 246 struct inic_host_priv *hpriv = ap->host->private_data;
124}
125
126static void __inic_set_pirq_mask(struct ata_port *ap, u8 mask)
127{
128 void __iomem *port_base = inic_port_base(ap);
129 struct inic_port_priv *pp = ap->private_data;
130 247
131 writeb(mask, port_base + PORT_IRQ_MASK); 248 return hpriv->mmio_base + ap->port_no * PORT_SIZE;
132 pp->cached_pirq_mask = mask;
133}
134
135static void inic_set_pirq_mask(struct ata_port *ap, u8 mask)
136{
137 struct inic_port_priv *pp = ap->private_data;
138
139 if (pp->cached_pirq_mask != mask)
140 __inic_set_pirq_mask(ap, mask);
141} 249}
142 250
143static void inic_reset_port(void __iomem *port_base) 251static void inic_reset_port(void __iomem *port_base)
144{ 252{
145 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL; 253 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
146 u16 ctl;
147 254
148 ctl = readw(idma_ctl); 255 /* stop IDMA engine */
149 ctl &= ~(IDMA_CTL_RST_IDMA | IDMA_CTL_ATA_NIEN | IDMA_CTL_GO); 256 readw(idma_ctl); /* flush */
257 msleep(1);
150 258
151 /* mask IRQ and assert reset */ 259 /* mask IRQ and assert reset */
152 writew(ctl | IDMA_CTL_RST_IDMA | IDMA_CTL_ATA_NIEN, idma_ctl); 260 writew(IDMA_CTL_RST_IDMA, idma_ctl);
153 readw(idma_ctl); /* flush */ 261 readw(idma_ctl); /* flush */
154
155 /* give it some time */
156 msleep(1); 262 msleep(1);
157 263
158 /* release reset */ 264 /* release reset */
159 writew(ctl | IDMA_CTL_ATA_NIEN, idma_ctl); 265 writew(0, idma_ctl);
160 266
161 /* clear irq */ 267 /* clear irq */
162 writeb(0xff, port_base + PORT_IRQ_STAT); 268 writeb(0xff, port_base + PORT_IRQ_STAT);
163
164 /* reenable ATA IRQ, turn off IDMA mode */
165 writew(ctl, idma_ctl);
166} 269}
167 270
168static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val) 271static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val)
169{ 272{
170 void __iomem *scr_addr = ap->ioaddr.scr_addr; 273 void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR;
171 void __iomem *addr; 274 void __iomem *addr;
172 275
173 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) 276 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
@@ -184,120 +287,126 @@ static int inic_scr_read(struct ata_port *ap, unsigned sc_reg, u32 *val)
184 287
185static int inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val) 288static int inic_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val)
186{ 289{
187 void __iomem *scr_addr = ap->ioaddr.scr_addr; 290 void __iomem *scr_addr = inic_port_base(ap) + PORT_SCR;
188 void __iomem *addr;
189 291
190 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map))) 292 if (unlikely(sc_reg >= ARRAY_SIZE(scr_map)))
191 return -EINVAL; 293 return -EINVAL;
192 294
193 addr = scr_addr + scr_map[sc_reg] * 4;
194 writel(val, scr_addr + scr_map[sc_reg] * 4); 295 writel(val, scr_addr + scr_map[sc_reg] * 4);
195 return 0; 296 return 0;
196} 297}
197 298
198/* 299static void inic_stop_idma(struct ata_port *ap)
199 * In TF mode, inic162x is very similar to SFF device. TF registers
200 * function the same. DMA engine behaves similary using the same PRD
201 * format as BMDMA but different command register, interrupt and event
202 * notification methods are used. The following inic_bmdma_*()
203 * functions do the impedance matching.
204 */
205static void inic_bmdma_setup(struct ata_queued_cmd *qc)
206{ 300{
207 struct ata_port *ap = qc->ap;
208 struct inic_port_priv *pp = ap->private_data;
209 void __iomem *port_base = inic_port_base(ap); 301 void __iomem *port_base = inic_port_base(ap);
210 int rw = qc->tf.flags & ATA_TFLAG_WRITE;
211
212 /* make sure device sees PRD table writes */
213 wmb();
214
215 /* load transfer length */
216 writel(qc->nbytes, port_base + PORT_PRD_XFERLEN);
217
218 /* turn on DMA and specify data direction */
219 pp->cached_prdctl = pp->dfl_prdctl | PRD_CTL_DMAEN;
220 if (!rw)
221 pp->cached_prdctl |= PRD_CTL_WR;
222 writeb(pp->cached_prdctl, port_base + PORT_PRD_CTL);
223 302
224 /* issue r/w command */ 303 readb(port_base + PORT_RPQ_FIFO);
225 ap->ops->sff_exec_command(ap, &qc->tf); 304 readb(port_base + PORT_RPQ_CNT);
305 writew(0, port_base + PORT_IDMA_CTL);
226} 306}
227 307
228static void inic_bmdma_start(struct ata_queued_cmd *qc) 308static void inic_host_err_intr(struct ata_port *ap, u8 irq_stat, u16 idma_stat)
229{ 309{
230 struct ata_port *ap = qc->ap; 310 struct ata_eh_info *ehi = &ap->link.eh_info;
231 struct inic_port_priv *pp = ap->private_data; 311 struct inic_port_priv *pp = ap->private_data;
232 void __iomem *port_base = inic_port_base(ap); 312 struct inic_cpb *cpb = &pp->pkt->cpb;
313 bool freeze = false;
233 314
234 /* start host DMA transaction */ 315 ata_ehi_clear_desc(ehi);
235 pp->cached_prdctl |= PRD_CTL_START; 316 ata_ehi_push_desc(ehi, "irq_stat=0x%x idma_stat=0x%x",
236 writeb(pp->cached_prdctl, port_base + PORT_PRD_CTL); 317 irq_stat, idma_stat);
237}
238 318
239static void inic_bmdma_stop(struct ata_queued_cmd *qc) 319 inic_stop_idma(ap);
240{
241 struct ata_port *ap = qc->ap;
242 struct inic_port_priv *pp = ap->private_data;
243 void __iomem *port_base = inic_port_base(ap);
244 320
245 /* stop DMA engine */ 321 if (irq_stat & (PIRQ_OFFLINE | PIRQ_ONLINE)) {
246 writeb(pp->dfl_prdctl, port_base + PORT_PRD_CTL); 322 ata_ehi_push_desc(ehi, "hotplug");
247} 323 ata_ehi_hotplugged(ehi);
324 freeze = true;
325 }
248 326
249static u8 inic_bmdma_status(struct ata_port *ap) 327 if (idma_stat & IDMA_STAT_PERR) {
250{ 328 ata_ehi_push_desc(ehi, "PCI error");
251 /* event is already verified by the interrupt handler */ 329 freeze = true;
252 return ATA_DMA_INTR; 330 }
331
332 if (idma_stat & IDMA_STAT_CPBERR) {
333 ata_ehi_push_desc(ehi, "CPB error");
334
335 if (cpb->resp_flags & CPB_RESP_IGNORED) {
336 __ata_ehi_push_desc(ehi, " ignored");
337 ehi->err_mask |= AC_ERR_INVALID;
338 freeze = true;
339 }
340
341 if (cpb->resp_flags & CPB_RESP_ATA_ERR)
342 ehi->err_mask |= AC_ERR_DEV;
343
344 if (cpb->resp_flags & CPB_RESP_SPURIOUS) {
345 __ata_ehi_push_desc(ehi, " spurious-intr");
346 ehi->err_mask |= AC_ERR_HSM;
347 freeze = true;
348 }
349
350 if (cpb->resp_flags &
351 (CPB_RESP_UNDERFLOW | CPB_RESP_OVERFLOW)) {
352 __ata_ehi_push_desc(ehi, " data-over/underflow");
353 ehi->err_mask |= AC_ERR_HSM;
354 freeze = true;
355 }
356 }
357
358 if (freeze)
359 ata_port_freeze(ap);
360 else
361 ata_port_abort(ap);
253} 362}
254 363
255static void inic_host_intr(struct ata_port *ap) 364static void inic_host_intr(struct ata_port *ap)
256{ 365{
257 void __iomem *port_base = inic_port_base(ap); 366 void __iomem *port_base = inic_port_base(ap);
258 struct ata_eh_info *ehi = &ap->link.eh_info; 367 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag);
259 u8 irq_stat; 368 u8 irq_stat;
369 u16 idma_stat;
260 370
261 /* fetch and clear irq */ 371 /* read and clear IRQ status */
262 irq_stat = readb(port_base + PORT_IRQ_STAT); 372 irq_stat = readb(port_base + PORT_IRQ_STAT);
263 writeb(irq_stat, port_base + PORT_IRQ_STAT); 373 writeb(irq_stat, port_base + PORT_IRQ_STAT);
374 idma_stat = readw(port_base + PORT_IDMA_STAT);
264 375
265 if (likely(!(irq_stat & PIRQ_ERR))) { 376 if (unlikely((irq_stat & PIRQ_ERR) || (idma_stat & IDMA_STAT_ERR)))
266 struct ata_queued_cmd *qc = 377 inic_host_err_intr(ap, irq_stat, idma_stat);
267 ata_qc_from_tag(ap, ap->link.active_tag);
268 378
269 if (unlikely(!qc || (qc->tf.flags & ATA_TFLAG_POLLING))) { 379 if (unlikely(!qc))
270 ap->ops->sff_check_status(ap); /* clear ATA interrupt */ 380 goto spurious;
271 return;
272 }
273 381
274 if (likely(ata_sff_host_intr(ap, qc))) 382 if (likely(idma_stat & IDMA_STAT_DONE)) {
275 return; 383 inic_stop_idma(ap);
276 384
277 ap->ops->sff_check_status(ap); /* clear ATA interrupt */ 385 /* Depending on circumstances, device error
278 ata_port_printk(ap, KERN_WARNING, "unhandled " 386 * isn't reported by IDMA, check it explicitly.
279 "interrupt, irq_stat=%x\n", irq_stat); 387 */
388 if (unlikely(readb(port_base + PORT_TF_COMMAND) &
389 (ATA_DF | ATA_ERR)))
390 qc->err_mask |= AC_ERR_DEV;
391
392 ata_qc_complete(qc);
280 return; 393 return;
281 } 394 }
282 395
283 /* error */ 396 spurious:
284 ata_ehi_push_desc(ehi, "irq_stat=0x%x", irq_stat); 397 ata_port_printk(ap, KERN_WARNING, "unhandled interrupt: "
285 398 "cmd=0x%x irq_stat=0x%x idma_stat=0x%x\n",
286 if (irq_stat & (PIRQ_OFFLINE | PIRQ_ONLINE)) { 399 qc ? qc->tf.command : 0xff, irq_stat, idma_stat);
287 ata_ehi_hotplugged(ehi);
288 ata_port_freeze(ap);
289 } else
290 ata_port_abort(ap);
291} 400}
292 401
293static irqreturn_t inic_interrupt(int irq, void *dev_instance) 402static irqreturn_t inic_interrupt(int irq, void *dev_instance)
294{ 403{
295 struct ata_host *host = dev_instance; 404 struct ata_host *host = dev_instance;
296 void __iomem *mmio_base = host->iomap[MMIO_BAR]; 405 struct inic_host_priv *hpriv = host->private_data;
297 u16 host_irq_stat; 406 u16 host_irq_stat;
298 int i, handled = 0;; 407 int i, handled = 0;;
299 408
300 host_irq_stat = readw(mmio_base + HOST_IRQ_STAT); 409 host_irq_stat = readw(hpriv->mmio_base + HOST_IRQ_STAT);
301 410
302 if (unlikely(!(host_irq_stat & HIRQ_GLOBAL))) 411 if (unlikely(!(host_irq_stat & HIRQ_GLOBAL)))
303 goto out; 412 goto out;
@@ -327,60 +436,173 @@ static irqreturn_t inic_interrupt(int irq, void *dev_instance)
327 return IRQ_RETVAL(handled); 436 return IRQ_RETVAL(handled);
328} 437}
329 438
439static int inic_check_atapi_dma(struct ata_queued_cmd *qc)
440{
441 /* For some reason ATAPI_PROT_DMA doesn't work for some
442 * commands including writes and other misc ops. Use PIO
443 * protocol instead, which BTW is driven by the DMA engine
444 * anyway, so it shouldn't make much difference for native
445 * SATA devices.
446 */
447 if (atapi_cmd_type(qc->cdb[0]) == READ)
448 return 0;
449 return 1;
450}
451
452static void inic_fill_sg(struct inic_prd *prd, struct ata_queued_cmd *qc)
453{
454 struct scatterlist *sg;
455 unsigned int si;
456 u8 flags = 0;
457
458 if (qc->tf.flags & ATA_TFLAG_WRITE)
459 flags |= PRD_WRITE;
460
461 if (ata_is_dma(qc->tf.protocol))
462 flags |= PRD_DMA;
463
464 for_each_sg(qc->sg, sg, qc->n_elem, si) {
465 prd->mad = cpu_to_le32(sg_dma_address(sg));
466 prd->len = cpu_to_le16(sg_dma_len(sg));
467 prd->flags = flags;
468 prd++;
469 }
470
471 WARN_ON(!si);
472 prd[-1].flags |= PRD_END;
473}
474
475static void inic_qc_prep(struct ata_queued_cmd *qc)
476{
477 struct inic_port_priv *pp = qc->ap->private_data;
478 struct inic_pkt *pkt = pp->pkt;
479 struct inic_cpb *cpb = &pkt->cpb;
480 struct inic_prd *prd = pkt->prd;
481 bool is_atapi = ata_is_atapi(qc->tf.protocol);
482 bool is_data = ata_is_data(qc->tf.protocol);
483 unsigned int cdb_len = 0;
484
485 VPRINTK("ENTER\n");
486
487 if (is_atapi)
488 cdb_len = qc->dev->cdb_len;
489
490 /* prepare packet, based on initio driver */
491 memset(pkt, 0, sizeof(struct inic_pkt));
492
493 cpb->ctl_flags = CPB_CTL_VALID | CPB_CTL_IEN;
494 if (is_atapi || is_data)
495 cpb->ctl_flags |= CPB_CTL_DATA;
496
497 cpb->len = cpu_to_le32(qc->nbytes + cdb_len);
498 cpb->prd = cpu_to_le32(pp->pkt_dma + offsetof(struct inic_pkt, prd));
499
500 cpb->device = qc->tf.device;
501 cpb->feature = qc->tf.feature;
502 cpb->nsect = qc->tf.nsect;
503 cpb->lbal = qc->tf.lbal;
504 cpb->lbam = qc->tf.lbam;
505 cpb->lbah = qc->tf.lbah;
506
507 if (qc->tf.flags & ATA_TFLAG_LBA48) {
508 cpb->hob_feature = qc->tf.hob_feature;
509 cpb->hob_nsect = qc->tf.hob_nsect;
510 cpb->hob_lbal = qc->tf.hob_lbal;
511 cpb->hob_lbam = qc->tf.hob_lbam;
512 cpb->hob_lbah = qc->tf.hob_lbah;
513 }
514
515 cpb->command = qc->tf.command;
516 /* don't load ctl - dunno why. it's like that in the initio driver */
517
518 /* setup PRD for CDB */
519 if (is_atapi) {
520 memcpy(pkt->cdb, qc->cdb, ATAPI_CDB_LEN);
521 prd->mad = cpu_to_le32(pp->pkt_dma +
522 offsetof(struct inic_pkt, cdb));
523 prd->len = cpu_to_le16(cdb_len);
524 prd->flags = PRD_CDB | PRD_WRITE;
525 if (!is_data)
526 prd->flags |= PRD_END;
527 prd++;
528 }
529
530 /* setup sg table */
531 if (is_data)
532 inic_fill_sg(prd, qc);
533
534 pp->cpb_tbl[0] = pp->pkt_dma;
535}
536
330static unsigned int inic_qc_issue(struct ata_queued_cmd *qc) 537static unsigned int inic_qc_issue(struct ata_queued_cmd *qc)
331{ 538{
332 struct ata_port *ap = qc->ap; 539 struct ata_port *ap = qc->ap;
540 void __iomem *port_base = inic_port_base(ap);
333 541
334 /* ATA IRQ doesn't wait for DMA transfer completion and vice 542 /* fire up the ADMA engine */
335 * versa. Mask IRQ selectively to detect command completion. 543 writew(HCTL_FTHD0, port_base + HOST_CTL);
336 * Without it, ATA DMA read command can cause data corruption. 544 writew(IDMA_CTL_GO, port_base + PORT_IDMA_CTL);
337 * 545 writeb(0, port_base + PORT_CPB_PTQFIFO);
338 * Something similar might be needed for ATAPI writes. I 546
339 * tried a lot of combinations but couldn't find the solution. 547 return 0;
340 */ 548}
341 if (qc->tf.protocol == ATA_PROT_DMA && 549
342 !(qc->tf.flags & ATA_TFLAG_WRITE)) 550static void inic_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
343 inic_set_pirq_mask(ap, PIRQ_MASK_DMA_READ); 551{
344 else 552 void __iomem *port_base = inic_port_base(ap);
345 inic_set_pirq_mask(ap, PIRQ_MASK_OTHER); 553
554 tf->feature = readb(port_base + PORT_TF_FEATURE);
555 tf->nsect = readb(port_base + PORT_TF_NSECT);
556 tf->lbal = readb(port_base + PORT_TF_LBAL);
557 tf->lbam = readb(port_base + PORT_TF_LBAM);
558 tf->lbah = readb(port_base + PORT_TF_LBAH);
559 tf->device = readb(port_base + PORT_TF_DEVICE);
560 tf->command = readb(port_base + PORT_TF_COMMAND);
561}
346 562
347 /* Issuing a command to yet uninitialized port locks up the 563static bool inic_qc_fill_rtf(struct ata_queued_cmd *qc)
348 * controller. Most of the time, this happens for the first 564{
349 * command after reset which are ATA and ATAPI IDENTIFYs. 565 struct ata_taskfile *rtf = &qc->result_tf;
350 * Fast fail if stat is 0x7f or 0xff for those commands. 566 struct ata_taskfile tf;
567
568 /* FIXME: Except for status and error, result TF access
569 * doesn't work. I tried reading from BAR0/2, CPB and BAR5.
570 * None works regardless of which command interface is used.
571 * For now return true iff status indicates device error.
572 * This means that we're reporting bogus sector for RW
573 * failures. Eeekk....
351 */ 574 */
352 if (unlikely(qc->tf.command == ATA_CMD_ID_ATA || 575 inic_tf_read(qc->ap, &tf);
353 qc->tf.command == ATA_CMD_ID_ATAPI)) {
354 u8 stat = ap->ops->sff_check_status(ap);
355 if (stat == 0x7f || stat == 0xff)
356 return AC_ERR_HSM;
357 }
358 576
359 return ata_sff_qc_issue(qc); 577 if (!(tf.command & ATA_ERR))
578 return false;
579
580 rtf->command = tf.command;
581 rtf->feature = tf.feature;
582 return true;
360} 583}
361 584
362static void inic_freeze(struct ata_port *ap) 585static void inic_freeze(struct ata_port *ap)
363{ 586{
364 void __iomem *port_base = inic_port_base(ap); 587 void __iomem *port_base = inic_port_base(ap);
365 588
366 __inic_set_pirq_mask(ap, PIRQ_MASK_FREEZE); 589 writeb(PIRQ_MASK_FREEZE, port_base + PORT_IRQ_MASK);
367
368 ap->ops->sff_check_status(ap);
369 writeb(0xff, port_base + PORT_IRQ_STAT); 590 writeb(0xff, port_base + PORT_IRQ_STAT);
370
371 readb(port_base + PORT_IRQ_STAT); /* flush */
372} 591}
373 592
374static void inic_thaw(struct ata_port *ap) 593static void inic_thaw(struct ata_port *ap)
375{ 594{
376 void __iomem *port_base = inic_port_base(ap); 595 void __iomem *port_base = inic_port_base(ap);
377 596
378 ap->ops->sff_check_status(ap);
379 writeb(0xff, port_base + PORT_IRQ_STAT); 597 writeb(0xff, port_base + PORT_IRQ_STAT);
598 writeb(PIRQ_MASK_DEFAULT, port_base + PORT_IRQ_MASK);
599}
380 600
381 __inic_set_pirq_mask(ap, PIRQ_MASK_OTHER); 601static int inic_check_ready(struct ata_link *link)
602{
603 void __iomem *port_base = inic_port_base(link->ap);
382 604
383 readb(port_base + PORT_IRQ_STAT); /* flush */ 605 return ata_check_ready(readb(port_base + PORT_TF_COMMAND));
384} 606}
385 607
386/* 608/*
@@ -394,17 +616,15 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
394 void __iomem *port_base = inic_port_base(ap); 616 void __iomem *port_base = inic_port_base(ap);
395 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL; 617 void __iomem *idma_ctl = port_base + PORT_IDMA_CTL;
396 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); 618 const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
397 u16 val;
398 int rc; 619 int rc;
399 620
400 /* hammer it into sane state */ 621 /* hammer it into sane state */
401 inic_reset_port(port_base); 622 inic_reset_port(port_base);
402 623
403 val = readw(idma_ctl); 624 writew(IDMA_CTL_RST_ATA, idma_ctl);
404 writew(val | IDMA_CTL_RST_ATA, idma_ctl);
405 readw(idma_ctl); /* flush */ 625 readw(idma_ctl); /* flush */
406 msleep(1); 626 msleep(1);
407 writew(val & ~IDMA_CTL_RST_ATA, idma_ctl); 627 writew(0, idma_ctl);
408 628
409 rc = sata_link_resume(link, timing, deadline); 629 rc = sata_link_resume(link, timing, deadline);
410 if (rc) { 630 if (rc) {
@@ -418,7 +638,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
418 struct ata_taskfile tf; 638 struct ata_taskfile tf;
419 639
420 /* wait for link to become ready */ 640 /* wait for link to become ready */
421 rc = ata_sff_wait_after_reset(link, 1, deadline); 641 rc = ata_wait_after_reset(link, deadline, inic_check_ready);
422 /* link occupied, -ENODEV too is an error */ 642 /* link occupied, -ENODEV too is an error */
423 if (rc) { 643 if (rc) {
424 ata_link_printk(link, KERN_WARNING, "device not ready " 644 ata_link_printk(link, KERN_WARNING, "device not ready "
@@ -426,7 +646,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
426 return rc; 646 return rc;
427 } 647 }
428 648
429 ata_sff_tf_read(ap, &tf); 649 inic_tf_read(ap, &tf);
430 *class = ata_dev_classify(&tf); 650 *class = ata_dev_classify(&tf);
431 } 651 }
432 652
@@ -436,18 +656,8 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
436static void inic_error_handler(struct ata_port *ap) 656static void inic_error_handler(struct ata_port *ap)
437{ 657{
438 void __iomem *port_base = inic_port_base(ap); 658 void __iomem *port_base = inic_port_base(ap);
439 struct inic_port_priv *pp = ap->private_data;
440 unsigned long flags;
441 659
442 /* reset PIO HSM and stop DMA engine */
443 inic_reset_port(port_base); 660 inic_reset_port(port_base);
444
445 spin_lock_irqsave(ap->lock, flags);
446 ap->hsm_task_state = HSM_ST_IDLE;
447 writeb(pp->dfl_prdctl, port_base + PORT_PRD_CTL);
448 spin_unlock_irqrestore(ap->lock, flags);
449
450 /* PIO and DMA engines have been stopped, perform recovery */
451 ata_std_error_handler(ap); 661 ata_std_error_handler(ap);
452} 662}
453 663
@@ -458,26 +668,18 @@ static void inic_post_internal_cmd(struct ata_queued_cmd *qc)
458 inic_reset_port(inic_port_base(qc->ap)); 668 inic_reset_port(inic_port_base(qc->ap));
459} 669}
460 670
461static void inic_dev_config(struct ata_device *dev)
462{
463 /* inic can only handle upto LBA28 max sectors */
464 if (dev->max_sectors > ATA_MAX_SECTORS)
465 dev->max_sectors = ATA_MAX_SECTORS;
466
467 if (dev->n_sectors >= 1 << 28) {
468 ata_dev_printk(dev, KERN_ERR,
469 "ERROR: This driver doesn't support LBA48 yet and may cause\n"
470 " data corruption on such devices. Disabling.\n");
471 ata_dev_disable(dev);
472 }
473}
474
475static void init_port(struct ata_port *ap) 671static void init_port(struct ata_port *ap)
476{ 672{
477 void __iomem *port_base = inic_port_base(ap); 673 void __iomem *port_base = inic_port_base(ap);
674 struct inic_port_priv *pp = ap->private_data;
478 675
479 /* Setup PRD address */ 676 /* clear packet and CPB table */
677 memset(pp->pkt, 0, sizeof(struct inic_pkt));
678 memset(pp->cpb_tbl, 0, IDMA_CPB_TBL_SIZE);
679
680 /* setup PRD and CPB lookup table addresses */
480 writel(ap->prd_dma, port_base + PORT_PRD_ADDR); 681 writel(ap->prd_dma, port_base + PORT_PRD_ADDR);
682 writel(pp->cpb_tbl_dma, port_base + PORT_CPB_CPBLAR);
481} 683}
482 684
483static int inic_port_resume(struct ata_port *ap) 685static int inic_port_resume(struct ata_port *ap)
@@ -488,28 +690,30 @@ static int inic_port_resume(struct ata_port *ap)
488 690
489static int inic_port_start(struct ata_port *ap) 691static int inic_port_start(struct ata_port *ap)
490{ 692{
491 void __iomem *port_base = inic_port_base(ap); 693 struct device *dev = ap->host->dev;
492 struct inic_port_priv *pp; 694 struct inic_port_priv *pp;
493 u8 tmp;
494 int rc; 695 int rc;
495 696
496 /* alloc and initialize private data */ 697 /* alloc and initialize private data */
497 pp = devm_kzalloc(ap->host->dev, sizeof(*pp), GFP_KERNEL); 698 pp = devm_kzalloc(dev, sizeof(*pp), GFP_KERNEL);
498 if (!pp) 699 if (!pp)
499 return -ENOMEM; 700 return -ENOMEM;
500 ap->private_data = pp; 701 ap->private_data = pp;
501 702
502 /* default PRD_CTL value, DMAEN, WR and START off */
503 tmp = readb(port_base + PORT_PRD_CTL);
504 tmp &= ~(PRD_CTL_DMAEN | PRD_CTL_WR | PRD_CTL_START);
505 pp->dfl_prdctl = tmp;
506
507 /* Alloc resources */ 703 /* Alloc resources */
508 rc = ata_port_start(ap); 704 rc = ata_port_start(ap);
509 if (rc) { 705 if (rc)
510 kfree(pp);
511 return rc; 706 return rc;
512 } 707
708 pp->pkt = dmam_alloc_coherent(dev, sizeof(struct inic_pkt),
709 &pp->pkt_dma, GFP_KERNEL);
710 if (!pp->pkt)
711 return -ENOMEM;
712
713 pp->cpb_tbl = dmam_alloc_coherent(dev, IDMA_CPB_TBL_SIZE,
714 &pp->cpb_tbl_dma, GFP_KERNEL);
715 if (!pp->cpb_tbl)
716 return -ENOMEM;
513 717
514 init_port(ap); 718 init_port(ap);
515 719
@@ -517,21 +721,18 @@ static int inic_port_start(struct ata_port *ap)
517} 721}
518 722
519static struct ata_port_operations inic_port_ops = { 723static struct ata_port_operations inic_port_ops = {
520 .inherits = &ata_sff_port_ops, 724 .inherits = &sata_port_ops,
521 725
522 .bmdma_setup = inic_bmdma_setup, 726 .check_atapi_dma = inic_check_atapi_dma,
523 .bmdma_start = inic_bmdma_start, 727 .qc_prep = inic_qc_prep,
524 .bmdma_stop = inic_bmdma_stop,
525 .bmdma_status = inic_bmdma_status,
526 .qc_issue = inic_qc_issue, 728 .qc_issue = inic_qc_issue,
729 .qc_fill_rtf = inic_qc_fill_rtf,
527 730
528 .freeze = inic_freeze, 731 .freeze = inic_freeze,
529 .thaw = inic_thaw, 732 .thaw = inic_thaw,
530 .softreset = ATA_OP_NULL, /* softreset is broken */
531 .hardreset = inic_hardreset, 733 .hardreset = inic_hardreset,
532 .error_handler = inic_error_handler, 734 .error_handler = inic_error_handler,
533 .post_internal_cmd = inic_post_internal_cmd, 735 .post_internal_cmd = inic_post_internal_cmd,
534 .dev_config = inic_dev_config,
535 736
536 .scr_read = inic_scr_read, 737 .scr_read = inic_scr_read,
537 .scr_write = inic_scr_write, 738 .scr_write = inic_scr_write,
@@ -541,12 +742,6 @@ static struct ata_port_operations inic_port_ops = {
541}; 742};
542 743
543static struct ata_port_info inic_port_info = { 744static struct ata_port_info inic_port_info = {
544 /* For some reason, ATAPI_PROT_PIO is broken on this
545 * controller, and no, PIO_POLLING does't fix it. It somehow
546 * manages to report the wrong ireason and ignoring ireason
547 * results in machine lock up. Tell libata to always prefer
548 * DMA.
549 */
550 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA, 745 .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA,
551 .pio_mask = 0x1f, /* pio0-4 */ 746 .pio_mask = 0x1f, /* pio0-4 */
552 .mwdma_mask = 0x07, /* mwdma0-2 */ 747 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -599,7 +794,6 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
599{ 794{
600 struct ata_host *host = dev_get_drvdata(&pdev->dev); 795 struct ata_host *host = dev_get_drvdata(&pdev->dev);
601 struct inic_host_priv *hpriv = host->private_data; 796 struct inic_host_priv *hpriv = host->private_data;
602 void __iomem *mmio_base = host->iomap[MMIO_BAR];
603 int rc; 797 int rc;
604 798
605 rc = ata_pci_device_do_resume(pdev); 799 rc = ata_pci_device_do_resume(pdev);
@@ -607,7 +801,7 @@ static int inic_pci_device_resume(struct pci_dev *pdev)
607 return rc; 801 return rc;
608 802
609 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) { 803 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
610 rc = init_controller(mmio_base, hpriv->cached_hctl); 804 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl);
611 if (rc) 805 if (rc)
612 return rc; 806 return rc;
613 } 807 }
@@ -625,6 +819,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
625 struct ata_host *host; 819 struct ata_host *host;
626 struct inic_host_priv *hpriv; 820 struct inic_host_priv *hpriv;
627 void __iomem * const *iomap; 821 void __iomem * const *iomap;
822 int mmio_bar;
628 int i, rc; 823 int i, rc;
629 824
630 if (!printed_version++) 825 if (!printed_version++)
@@ -638,38 +833,31 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
638 833
639 host->private_data = hpriv; 834 host->private_data = hpriv;
640 835
641 /* acquire resources and fill host */ 836 /* Acquire resources and fill host. Note that PCI and cardbus
837 * use different BARs.
838 */
642 rc = pcim_enable_device(pdev); 839 rc = pcim_enable_device(pdev);
643 if (rc) 840 if (rc)
644 return rc; 841 return rc;
645 842
646 rc = pcim_iomap_regions(pdev, 0x3f, DRV_NAME); 843 if (pci_resource_flags(pdev, MMIO_BAR_PCI) & IORESOURCE_MEM)
844 mmio_bar = MMIO_BAR_PCI;
845 else
846 mmio_bar = MMIO_BAR_CARDBUS;
847
848 rc = pcim_iomap_regions(pdev, 1 << mmio_bar, DRV_NAME);
647 if (rc) 849 if (rc)
648 return rc; 850 return rc;
649 host->iomap = iomap = pcim_iomap_table(pdev); 851 host->iomap = iomap = pcim_iomap_table(pdev);
852 hpriv->mmio_base = iomap[mmio_bar];
853 hpriv->cached_hctl = readw(hpriv->mmio_base + HOST_CTL);
650 854
651 for (i = 0; i < NR_PORTS; i++) { 855 for (i = 0; i < NR_PORTS; i++) {
652 struct ata_port *ap = host->ports[i]; 856 struct ata_port *ap = host->ports[i];
653 struct ata_ioports *port = &ap->ioaddr;
654 unsigned int offset = i * PORT_SIZE;
655
656 port->cmd_addr = iomap[2 * i];
657 port->altstatus_addr =
658 port->ctl_addr = (void __iomem *)
659 ((unsigned long)iomap[2 * i + 1] | ATA_PCI_CTL_OFS);
660 port->scr_addr = iomap[MMIO_BAR] + offset + PORT_SCR;
661
662 ata_sff_std_ports(port);
663
664 ata_port_pbar_desc(ap, MMIO_BAR, -1, "mmio");
665 ata_port_pbar_desc(ap, MMIO_BAR, offset, "port");
666 ata_port_desc(ap, "cmd 0x%llx ctl 0x%llx",
667 (unsigned long long)pci_resource_start(pdev, 2 * i),
668 (unsigned long long)pci_resource_start(pdev, (2 * i + 1)) |
669 ATA_PCI_CTL_OFS);
670 }
671 857
672 hpriv->cached_hctl = readw(iomap[MMIO_BAR] + HOST_CTL); 858 ata_port_pbar_desc(ap, mmio_bar, -1, "mmio");
859 ata_port_pbar_desc(ap, mmio_bar, i * PORT_SIZE, "port");
860 }
673 861
674 /* Set dma_mask. This devices doesn't support 64bit addressing. */ 862 /* Set dma_mask. This devices doesn't support 64bit addressing. */
675 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK); 863 rc = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
@@ -698,7 +886,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
698 return rc; 886 return rc;
699 } 887 }
700 888
701 rc = init_controller(iomap[MMIO_BAR], hpriv->cached_hctl); 889 rc = init_controller(hpriv->mmio_base, hpriv->cached_hctl);
702 if (rc) { 890 if (rc) {
703 dev_printk(KERN_ERR, &pdev->dev, 891 dev_printk(KERN_ERR, &pdev->dev,
704 "failed to initialize controller\n"); 892 "failed to initialize controller\n");
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 842b1a15b78c..bb73b2222627 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -65,6 +65,7 @@
65#include <linux/platform_device.h> 65#include <linux/platform_device.h>
66#include <linux/ata_platform.h> 66#include <linux/ata_platform.h>
67#include <linux/mbus.h> 67#include <linux/mbus.h>
68#include <linux/bitops.h>
68#include <scsi/scsi_host.h> 69#include <scsi/scsi_host.h>
69#include <scsi/scsi_cmnd.h> 70#include <scsi/scsi_cmnd.h>
70#include <scsi/scsi_device.h> 71#include <scsi/scsi_device.h>
@@ -91,9 +92,9 @@ enum {
91 MV_IRQ_COAL_TIME_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xd0), 92 MV_IRQ_COAL_TIME_THRESHOLD = (MV_IRQ_COAL_REG_BASE + 0xd0),
92 93
93 MV_SATAHC0_REG_BASE = 0x20000, 94 MV_SATAHC0_REG_BASE = 0x20000,
94 MV_FLASH_CTL = 0x1046c, 95 MV_FLASH_CTL_OFS = 0x1046c,
95 MV_GPIO_PORT_CTL = 0x104f0, 96 MV_GPIO_PORT_CTL_OFS = 0x104f0,
96 MV_RESET_CFG = 0x180d8, 97 MV_RESET_CFG_OFS = 0x180d8,
97 98
98 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ, 99 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ,
99 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ, 100 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ,
@@ -147,18 +148,21 @@ enum {
147 /* PCI interface registers */ 148 /* PCI interface registers */
148 149
149 PCI_COMMAND_OFS = 0xc00, 150 PCI_COMMAND_OFS = 0xc00,
151 PCI_COMMAND_MRDTRIG = (1 << 7), /* PCI Master Read Trigger */
150 152
151 PCI_MAIN_CMD_STS_OFS = 0xd30, 153 PCI_MAIN_CMD_STS_OFS = 0xd30,
152 STOP_PCI_MASTER = (1 << 2), 154 STOP_PCI_MASTER = (1 << 2),
153 PCI_MASTER_EMPTY = (1 << 3), 155 PCI_MASTER_EMPTY = (1 << 3),
154 GLOB_SFT_RST = (1 << 4), 156 GLOB_SFT_RST = (1 << 4),
155 157
156 MV_PCI_MODE = 0xd00, 158 MV_PCI_MODE_OFS = 0xd00,
159 MV_PCI_MODE_MASK = 0x30,
160
157 MV_PCI_EXP_ROM_BAR_CTL = 0xd2c, 161 MV_PCI_EXP_ROM_BAR_CTL = 0xd2c,
158 MV_PCI_DISC_TIMER = 0xd04, 162 MV_PCI_DISC_TIMER = 0xd04,
159 MV_PCI_MSI_TRIGGER = 0xc38, 163 MV_PCI_MSI_TRIGGER = 0xc38,
160 MV_PCI_SERR_MASK = 0xc28, 164 MV_PCI_SERR_MASK = 0xc28,
161 MV_PCI_XBAR_TMOUT = 0x1d04, 165 MV_PCI_XBAR_TMOUT_OFS = 0x1d04,
162 MV_PCI_ERR_LOW_ADDRESS = 0x1d40, 166 MV_PCI_ERR_LOW_ADDRESS = 0x1d40,
163 MV_PCI_ERR_HIGH_ADDRESS = 0x1d44, 167 MV_PCI_ERR_HIGH_ADDRESS = 0x1d44,
164 MV_PCI_ERR_ATTRIBUTE = 0x1d48, 168 MV_PCI_ERR_ATTRIBUTE = 0x1d48,
@@ -225,16 +229,18 @@ enum {
225 PHY_MODE4 = 0x314, 229 PHY_MODE4 = 0x314,
226 PHY_MODE2 = 0x330, 230 PHY_MODE2 = 0x330,
227 SATA_IFCTL_OFS = 0x344, 231 SATA_IFCTL_OFS = 0x344,
232 SATA_TESTCTL_OFS = 0x348,
228 SATA_IFSTAT_OFS = 0x34c, 233 SATA_IFSTAT_OFS = 0x34c,
229 VENDOR_UNIQUE_FIS_OFS = 0x35c, 234 VENDOR_UNIQUE_FIS_OFS = 0x35c,
230 235
231 FIS_CFG_OFS = 0x360, 236 FISCFG_OFS = 0x360,
232 FIS_CFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */ 237 FISCFG_WAIT_DEV_ERR = (1 << 8), /* wait for host on DevErr */
238 FISCFG_SINGLE_SYNC = (1 << 16), /* SYNC on DMA activation */
233 239
234 MV5_PHY_MODE = 0x74, 240 MV5_PHY_MODE = 0x74,
235 MV5_LT_MODE = 0x30, 241 MV5_LTMODE_OFS = 0x30,
236 MV5_PHY_CTL = 0x0C, 242 MV5_PHY_CTL_OFS = 0x0C,
237 SATA_INTERFACE_CFG = 0x050, 243 SATA_INTERFACE_CFG_OFS = 0x050,
238 244
239 MV_M2_PREAMP_MASK = 0x7e0, 245 MV_M2_PREAMP_MASK = 0x7e0,
240 246
@@ -332,10 +338,16 @@ enum {
332 EDMA_CMD_OFS = 0x28, /* EDMA command register */ 338 EDMA_CMD_OFS = 0x28, /* EDMA command register */
333 EDMA_EN = (1 << 0), /* enable EDMA */ 339 EDMA_EN = (1 << 0), /* enable EDMA */
334 EDMA_DS = (1 << 1), /* disable EDMA; self-negated */ 340 EDMA_DS = (1 << 1), /* disable EDMA; self-negated */
335 ATA_RST = (1 << 2), /* reset trans/link/phy */ 341 EDMA_RESET = (1 << 2), /* reset eng/trans/link/phy */
342
343 EDMA_STATUS_OFS = 0x30, /* EDMA engine status */
344 EDMA_STATUS_CACHE_EMPTY = (1 << 6), /* GenIIe command cache empty */
345 EDMA_STATUS_IDLE = (1 << 7), /* GenIIe EDMA enabled/idle */
336 346
337 EDMA_IORDY_TMOUT = 0x34, 347 EDMA_IORDY_TMOUT_OFS = 0x34,
338 EDMA_ARB_CFG = 0x38, 348 EDMA_ARB_CFG_OFS = 0x38,
349
350 EDMA_HALTCOND_OFS = 0x60, /* GenIIe halt conditions */
339 351
340 GEN_II_NCQ_MAX_SECTORS = 256, /* max sects/io on Gen2 w/NCQ */ 352 GEN_II_NCQ_MAX_SECTORS = 256, /* max sects/io on Gen2 w/NCQ */
341 353
@@ -350,15 +362,19 @@ enum {
350 MV_HP_GEN_II = (1 << 7), /* Generation II: 60xx */ 362 MV_HP_GEN_II = (1 << 7), /* Generation II: 60xx */
351 MV_HP_GEN_IIE = (1 << 8), /* Generation IIE: 6042/7042 */ 363 MV_HP_GEN_IIE = (1 << 8), /* Generation IIE: 6042/7042 */
352 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */ 364 MV_HP_PCIE = (1 << 9), /* PCIe bus/regs: 7042 */
365 MV_HP_CUT_THROUGH = (1 << 10), /* can use EDMA cut-through */
353 366
354 /* Port private flags (pp_flags) */ 367 /* Port private flags (pp_flags) */
355 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */ 368 MV_PP_FLAG_EDMA_EN = (1 << 0), /* is EDMA engine enabled? */
356 MV_PP_FLAG_NCQ_EN = (1 << 1), /* is EDMA set up for NCQ? */ 369 MV_PP_FLAG_NCQ_EN = (1 << 1), /* is EDMA set up for NCQ? */
370 MV_PP_FLAG_FBS_EN = (1 << 2), /* is EDMA set up for FBS? */
371 MV_PP_FLAG_DELAYED_EH = (1 << 3), /* delayed dev err handling */
357}; 372};
358 373
359#define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I) 374#define IS_GEN_I(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_I)
360#define IS_GEN_II(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_II) 375#define IS_GEN_II(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_II)
361#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE) 376#define IS_GEN_IIE(hpriv) ((hpriv)->hp_flags & MV_HP_GEN_IIE)
377#define IS_PCIE(hpriv) ((hpriv)->hp_flags & MV_HP_PCIE)
362#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC)) 378#define HAS_PCI(host) (!((host)->ports[0]->flags & MV_FLAG_SOC))
363 379
364#define WINDOW_CTRL(i) (0x20030 + ((i) << 4)) 380#define WINDOW_CTRL(i) (0x20030 + ((i) << 4))
@@ -433,6 +449,7 @@ struct mv_port_priv {
433 unsigned int resp_idx; 449 unsigned int resp_idx;
434 450
435 u32 pp_flags; 451 u32 pp_flags;
452 unsigned int delayed_eh_pmp_map;
436}; 453};
437 454
438struct mv_port_signal { 455struct mv_port_signal {
@@ -479,6 +496,7 @@ static int mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in, u32 *val);
479static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 496static int mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
480static int mv_port_start(struct ata_port *ap); 497static int mv_port_start(struct ata_port *ap);
481static void mv_port_stop(struct ata_port *ap); 498static void mv_port_stop(struct ata_port *ap);
499static int mv_qc_defer(struct ata_queued_cmd *qc);
482static void mv_qc_prep(struct ata_queued_cmd *qc); 500static void mv_qc_prep(struct ata_queued_cmd *qc);
483static void mv_qc_prep_iie(struct ata_queued_cmd *qc); 501static void mv_qc_prep_iie(struct ata_queued_cmd *qc);
484static unsigned int mv_qc_issue(struct ata_queued_cmd *qc); 502static unsigned int mv_qc_issue(struct ata_queued_cmd *qc);
@@ -527,6 +545,9 @@ static int mv_pmp_hardreset(struct ata_link *link, unsigned int *class,
527 unsigned long deadline); 545 unsigned long deadline);
528static int mv_softreset(struct ata_link *link, unsigned int *class, 546static int mv_softreset(struct ata_link *link, unsigned int *class,
529 unsigned long deadline); 547 unsigned long deadline);
548static void mv_pmp_error_handler(struct ata_port *ap);
549static void mv_process_crpb_entries(struct ata_port *ap,
550 struct mv_port_priv *pp);
530 551
531/* .sg_tablesize is (MV_MAX_SG_CT / 2) in the structures below 552/* .sg_tablesize is (MV_MAX_SG_CT / 2) in the structures below
532 * because we have to allow room for worst case splitting of 553 * because we have to allow room for worst case splitting of
@@ -548,6 +569,7 @@ static struct scsi_host_template mv6_sht = {
548static struct ata_port_operations mv5_ops = { 569static struct ata_port_operations mv5_ops = {
549 .inherits = &ata_sff_port_ops, 570 .inherits = &ata_sff_port_ops,
550 571
572 .qc_defer = mv_qc_defer,
551 .qc_prep = mv_qc_prep, 573 .qc_prep = mv_qc_prep,
552 .qc_issue = mv_qc_issue, 574 .qc_issue = mv_qc_issue,
553 575
@@ -566,7 +588,6 @@ static struct ata_port_operations mv5_ops = {
566 588
567static struct ata_port_operations mv6_ops = { 589static struct ata_port_operations mv6_ops = {
568 .inherits = &mv5_ops, 590 .inherits = &mv5_ops,
569 .qc_defer = sata_pmp_qc_defer_cmd_switch,
570 .dev_config = mv6_dev_config, 591 .dev_config = mv6_dev_config,
571 .scr_read = mv_scr_read, 592 .scr_read = mv_scr_read,
572 .scr_write = mv_scr_write, 593 .scr_write = mv_scr_write,
@@ -574,12 +595,11 @@ static struct ata_port_operations mv6_ops = {
574 .pmp_hardreset = mv_pmp_hardreset, 595 .pmp_hardreset = mv_pmp_hardreset,
575 .pmp_softreset = mv_softreset, 596 .pmp_softreset = mv_softreset,
576 .softreset = mv_softreset, 597 .softreset = mv_softreset,
577 .error_handler = sata_pmp_error_handler, 598 .error_handler = mv_pmp_error_handler,
578}; 599};
579 600
580static struct ata_port_operations mv_iie_ops = { 601static struct ata_port_operations mv_iie_ops = {
581 .inherits = &mv6_ops, 602 .inherits = &mv6_ops,
582 .qc_defer = ata_std_qc_defer, /* FIS-based switching */
583 .dev_config = ATA_OP_NULL, 603 .dev_config = ATA_OP_NULL,
584 .qc_prep = mv_qc_prep_iie, 604 .qc_prep = mv_qc_prep_iie,
585}; 605};
@@ -875,6 +895,29 @@ static void mv_start_dma(struct ata_port *ap, void __iomem *port_mmio,
875 } 895 }
876} 896}
877 897
898static void mv_wait_for_edma_empty_idle(struct ata_port *ap)
899{
900 void __iomem *port_mmio = mv_ap_base(ap);
901 const u32 empty_idle = (EDMA_STATUS_CACHE_EMPTY | EDMA_STATUS_IDLE);
902 const int per_loop = 5, timeout = (15 * 1000 / per_loop);
903 int i;
904
905 /*
906 * Wait for the EDMA engine to finish transactions in progress.
907 * No idea what a good "timeout" value might be, but measurements
908 * indicate that it often requires hundreds of microseconds
909 * with two drives in-use. So we use the 15msec value above
910 * as a rough guess at what even more drives might require.
911 */
912 for (i = 0; i < timeout; ++i) {
913 u32 edma_stat = readl(port_mmio + EDMA_STATUS_OFS);
914 if ((edma_stat & empty_idle) == empty_idle)
915 break;
916 udelay(per_loop);
917 }
918 /* ata_port_printk(ap, KERN_INFO, "%s: %u+ usecs\n", __func__, i); */
919}
920
878/** 921/**
879 * mv_stop_edma_engine - Disable eDMA engine 922 * mv_stop_edma_engine - Disable eDMA engine
880 * @port_mmio: io base address 923 * @port_mmio: io base address
@@ -907,6 +950,7 @@ static int mv_stop_edma(struct ata_port *ap)
907 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) 950 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN))
908 return 0; 951 return 0;
909 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN; 952 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
953 mv_wait_for_edma_empty_idle(ap);
910 if (mv_stop_edma_engine(port_mmio)) { 954 if (mv_stop_edma_engine(port_mmio)) {
911 ata_port_printk(ap, KERN_ERR, "Unable to stop eDMA\n"); 955 ata_port_printk(ap, KERN_ERR, "Unable to stop eDMA\n");
912 return -EIO; 956 return -EIO;
@@ -1057,26 +1101,95 @@ static void mv6_dev_config(struct ata_device *adev)
1057 } 1101 }
1058} 1102}
1059 1103
1060static void mv_config_fbs(void __iomem *port_mmio, int enable_fbs) 1104static int mv_qc_defer(struct ata_queued_cmd *qc)
1061{ 1105{
1062 u32 old_fcfg, new_fcfg, old_ltmode, new_ltmode; 1106 struct ata_link *link = qc->dev->link;
1107 struct ata_port *ap = link->ap;
1108 struct mv_port_priv *pp = ap->private_data;
1109
1110 /*
1111 * Don't allow new commands if we're in a delayed EH state
1112 * for NCQ and/or FIS-based switching.
1113 */
1114 if (pp->pp_flags & MV_PP_FLAG_DELAYED_EH)
1115 return ATA_DEFER_PORT;
1063 /* 1116 /*
1064 * Various bit settings required for operation 1117 * If the port is completely idle, then allow the new qc.
1065 * in FIS-based switching (fbs) mode on GenIIe:
1066 */ 1118 */
1067 old_fcfg = readl(port_mmio + FIS_CFG_OFS); 1119 if (ap->nr_active_links == 0)
1068 old_ltmode = readl(port_mmio + LTMODE_OFS); 1120 return 0;
1069 if (enable_fbs) { 1121
1070 new_fcfg = old_fcfg | FIS_CFG_SINGLE_SYNC; 1122 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) {
1071 new_ltmode = old_ltmode | LTMODE_BIT8; 1123 /*
1072 } else { /* disable fbs */ 1124 * The port is operating in host queuing mode (EDMA).
1073 new_fcfg = old_fcfg & ~FIS_CFG_SINGLE_SYNC; 1125 * It can accomodate a new qc if the qc protocol
1074 new_ltmode = old_ltmode & ~LTMODE_BIT8; 1126 * is compatible with the current host queue mode.
1075 } 1127 */
1076 if (new_fcfg != old_fcfg) 1128 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN) {
1077 writelfl(new_fcfg, port_mmio + FIS_CFG_OFS); 1129 /*
1130 * The host queue (EDMA) is in NCQ mode.
1131 * If the new qc is also an NCQ command,
1132 * then allow the new qc.
1133 */
1134 if (qc->tf.protocol == ATA_PROT_NCQ)
1135 return 0;
1136 } else {
1137 /*
1138 * The host queue (EDMA) is in non-NCQ, DMA mode.
1139 * If the new qc is also a non-NCQ, DMA command,
1140 * then allow the new qc.
1141 */
1142 if (qc->tf.protocol == ATA_PROT_DMA)
1143 return 0;
1144 }
1145 }
1146 return ATA_DEFER_PORT;
1147}
1148
1149static void mv_config_fbs(void __iomem *port_mmio, int want_ncq, int want_fbs)
1150{
1151 u32 new_fiscfg, old_fiscfg;
1152 u32 new_ltmode, old_ltmode;
1153 u32 new_haltcond, old_haltcond;
1154
1155 old_fiscfg = readl(port_mmio + FISCFG_OFS);
1156 old_ltmode = readl(port_mmio + LTMODE_OFS);
1157 old_haltcond = readl(port_mmio + EDMA_HALTCOND_OFS);
1158
1159 new_fiscfg = old_fiscfg & ~(FISCFG_SINGLE_SYNC | FISCFG_WAIT_DEV_ERR);
1160 new_ltmode = old_ltmode & ~LTMODE_BIT8;
1161 new_haltcond = old_haltcond | EDMA_ERR_DEV;
1162
1163 if (want_fbs) {
1164 new_fiscfg = old_fiscfg | FISCFG_SINGLE_SYNC;
1165 new_ltmode = old_ltmode | LTMODE_BIT8;
1166 if (want_ncq)
1167 new_haltcond &= ~EDMA_ERR_DEV;
1168 else
1169 new_fiscfg |= FISCFG_WAIT_DEV_ERR;
1170 }
1171
1172 if (new_fiscfg != old_fiscfg)
1173 writelfl(new_fiscfg, port_mmio + FISCFG_OFS);
1078 if (new_ltmode != old_ltmode) 1174 if (new_ltmode != old_ltmode)
1079 writelfl(new_ltmode, port_mmio + LTMODE_OFS); 1175 writelfl(new_ltmode, port_mmio + LTMODE_OFS);
1176 if (new_haltcond != old_haltcond)
1177 writelfl(new_haltcond, port_mmio + EDMA_HALTCOND_OFS);
1178}
1179
1180static void mv_60x1_errata_sata25(struct ata_port *ap, int want_ncq)
1181{
1182 struct mv_host_priv *hpriv = ap->host->private_data;
1183 u32 old, new;
1184
1185 /* workaround for 88SX60x1 FEr SATA#25 (part 1) */
1186 old = readl(hpriv->base + MV_GPIO_PORT_CTL_OFS);
1187 if (want_ncq)
1188 new = old | (1 << 22);
1189 else
1190 new = old & ~(1 << 22);
1191 if (new != old)
1192 writel(new, hpriv->base + MV_GPIO_PORT_CTL_OFS);
1080} 1193}
1081 1194
1082static void mv_edma_cfg(struct ata_port *ap, int want_ncq) 1195static void mv_edma_cfg(struct ata_port *ap, int want_ncq)
@@ -1088,25 +1201,40 @@ static void mv_edma_cfg(struct ata_port *ap, int want_ncq)
1088 1201
1089 /* set up non-NCQ EDMA configuration */ 1202 /* set up non-NCQ EDMA configuration */
1090 cfg = EDMA_CFG_Q_DEPTH; /* always 0x1f for *all* chips */ 1203 cfg = EDMA_CFG_Q_DEPTH; /* always 0x1f for *all* chips */
1204 pp->pp_flags &= ~MV_PP_FLAG_FBS_EN;
1091 1205
1092 if (IS_GEN_I(hpriv)) 1206 if (IS_GEN_I(hpriv))
1093 cfg |= (1 << 8); /* enab config burst size mask */ 1207 cfg |= (1 << 8); /* enab config burst size mask */
1094 1208
1095 else if (IS_GEN_II(hpriv)) 1209 else if (IS_GEN_II(hpriv)) {
1096 cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN; 1210 cfg |= EDMA_CFG_RD_BRST_EXT | EDMA_CFG_WR_BUFF_LEN;
1211 mv_60x1_errata_sata25(ap, want_ncq);
1097 1212
1098 else if (IS_GEN_IIE(hpriv)) { 1213 } else if (IS_GEN_IIE(hpriv)) {
1099 cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */ 1214 int want_fbs = sata_pmp_attached(ap);
1100 cfg |= (1 << 22); /* enab 4-entry host queue cache */ 1215 /*
1101 cfg |= (1 << 18); /* enab early completion */ 1216 * Possible future enhancement:
1102 cfg |= (1 << 17); /* enab cut-through (dis stor&forwrd) */ 1217 *
1218 * The chip can use FBS with non-NCQ, if we allow it,
1219 * But first we need to have the error handling in place
1220 * for this mode (datasheet section 7.3.15.4.2.3).
1221 * So disallow non-NCQ FBS for now.
1222 */
1223 want_fbs &= want_ncq;
1224
1225 mv_config_fbs(port_mmio, want_ncq, want_fbs);
1103 1226
1104 if (want_ncq && sata_pmp_attached(ap)) { 1227 if (want_fbs) {
1228 pp->pp_flags |= MV_PP_FLAG_FBS_EN;
1105 cfg |= EDMA_CFG_EDMA_FBS; /* FIS-based switching */ 1229 cfg |= EDMA_CFG_EDMA_FBS; /* FIS-based switching */
1106 mv_config_fbs(port_mmio, 1);
1107 } else {
1108 mv_config_fbs(port_mmio, 0);
1109 } 1230 }
1231
1232 cfg |= (1 << 23); /* do not mask PM field in rx'd FIS */
1233 cfg |= (1 << 22); /* enab 4-entry host queue cache */
1234 if (HAS_PCI(ap->host))
1235 cfg |= (1 << 18); /* enab early completion */
1236 if (hpriv->hp_flags & MV_HP_CUT_THROUGH)
1237 cfg |= (1 << 17); /* enab cut-thru (dis stor&forwrd) */
1110 } 1238 }
1111 1239
1112 if (want_ncq) { 1240 if (want_ncq) {
@@ -1483,25 +1611,186 @@ static struct ata_queued_cmd *mv_get_active_qc(struct ata_port *ap)
1483 return qc; 1611 return qc;
1484} 1612}
1485 1613
1486static void mv_unexpected_intr(struct ata_port *ap) 1614static void mv_pmp_error_handler(struct ata_port *ap)
1487{ 1615{
1616 unsigned int pmp, pmp_map;
1488 struct mv_port_priv *pp = ap->private_data; 1617 struct mv_port_priv *pp = ap->private_data;
1489 struct ata_eh_info *ehi = &ap->link.eh_info;
1490 char *when = "";
1491 1618
1619 if (pp->pp_flags & MV_PP_FLAG_DELAYED_EH) {
1620 /*
1621 * Perform NCQ error analysis on failed PMPs
1622 * before we freeze the port entirely.
1623 *
1624 * The failed PMPs are marked earlier by mv_pmp_eh_prep().
1625 */
1626 pmp_map = pp->delayed_eh_pmp_map;
1627 pp->pp_flags &= ~MV_PP_FLAG_DELAYED_EH;
1628 for (pmp = 0; pmp_map != 0; pmp++) {
1629 unsigned int this_pmp = (1 << pmp);
1630 if (pmp_map & this_pmp) {
1631 struct ata_link *link = &ap->pmp_link[pmp];
1632 pmp_map &= ~this_pmp;
1633 ata_eh_analyze_ncq_error(link);
1634 }
1635 }
1636 ata_port_freeze(ap);
1637 }
1638 sata_pmp_error_handler(ap);
1639}
1640
1641static unsigned int mv_get_err_pmp_map(struct ata_port *ap)
1642{
1643 void __iomem *port_mmio = mv_ap_base(ap);
1644
1645 return readl(port_mmio + SATA_TESTCTL_OFS) >> 16;
1646}
1647
1648static void mv_pmp_eh_prep(struct ata_port *ap, unsigned int pmp_map)
1649{
1650 struct ata_eh_info *ehi;
1651 unsigned int pmp;
1652
1653 /*
1654 * Initialize EH info for PMPs which saw device errors
1655 */
1656 ehi = &ap->link.eh_info;
1657 for (pmp = 0; pmp_map != 0; pmp++) {
1658 unsigned int this_pmp = (1 << pmp);
1659 if (pmp_map & this_pmp) {
1660 struct ata_link *link = &ap->pmp_link[pmp];
1661
1662 pmp_map &= ~this_pmp;
1663 ehi = &link->eh_info;
1664 ata_ehi_clear_desc(ehi);
1665 ata_ehi_push_desc(ehi, "dev err");
1666 ehi->err_mask |= AC_ERR_DEV;
1667 ehi->action |= ATA_EH_RESET;
1668 ata_link_abort(link);
1669 }
1670 }
1671}
1672
1673static int mv_handle_fbs_ncq_dev_err(struct ata_port *ap)
1674{
1675 struct mv_port_priv *pp = ap->private_data;
1676 int failed_links;
1677 unsigned int old_map, new_map;
1678
1679 /*
1680 * Device error during FBS+NCQ operation:
1681 *
1682 * Set a port flag to prevent further I/O being enqueued.
1683 * Leave the EDMA running to drain outstanding commands from this port.
1684 * Perform the post-mortem/EH only when all responses are complete.
1685 * Follow recovery sequence from 6042/7042 datasheet (7.3.15.4.2.2).
1686 */
1687 if (!(pp->pp_flags & MV_PP_FLAG_DELAYED_EH)) {
1688 pp->pp_flags |= MV_PP_FLAG_DELAYED_EH;
1689 pp->delayed_eh_pmp_map = 0;
1690 }
1691 old_map = pp->delayed_eh_pmp_map;
1692 new_map = old_map | mv_get_err_pmp_map(ap);
1693
1694 if (old_map != new_map) {
1695 pp->delayed_eh_pmp_map = new_map;
1696 mv_pmp_eh_prep(ap, new_map & ~old_map);
1697 }
1698 failed_links = hweight16(new_map);
1699
1700 ata_port_printk(ap, KERN_INFO, "%s: pmp_map=%04x qc_map=%04x "
1701 "failed_links=%d nr_active_links=%d\n",
1702 __func__, pp->delayed_eh_pmp_map,
1703 ap->qc_active, failed_links,
1704 ap->nr_active_links);
1705
1706 if (ap->nr_active_links <= failed_links) {
1707 mv_process_crpb_entries(ap, pp);
1708 mv_stop_edma(ap);
1709 mv_eh_freeze(ap);
1710 ata_port_printk(ap, KERN_INFO, "%s: done\n", __func__);
1711 return 1; /* handled */
1712 }
1713 ata_port_printk(ap, KERN_INFO, "%s: waiting\n", __func__);
1714 return 1; /* handled */
1715}
1716
1717static int mv_handle_fbs_non_ncq_dev_err(struct ata_port *ap)
1718{
1492 /* 1719 /*
1493 * We got a device interrupt from something that 1720 * Possible future enhancement:
1494 * was supposed to be using EDMA or polling. 1721 *
1722 * FBS+non-NCQ operation is not yet implemented.
1723 * See related notes in mv_edma_cfg().
1724 *
1725 * Device error during FBS+non-NCQ operation:
1726 *
1727 * We need to snapshot the shadow registers for each failed command.
1728 * Follow recovery sequence from 6042/7042 datasheet (7.3.15.4.2.3).
1495 */ 1729 */
1730 return 0; /* not handled */
1731}
1732
1733static int mv_handle_dev_err(struct ata_port *ap, u32 edma_err_cause)
1734{
1735 struct mv_port_priv *pp = ap->private_data;
1736
1737 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN))
1738 return 0; /* EDMA was not active: not handled */
1739 if (!(pp->pp_flags & MV_PP_FLAG_FBS_EN))
1740 return 0; /* FBS was not active: not handled */
1741
1742 if (!(edma_err_cause & EDMA_ERR_DEV))
1743 return 0; /* non DEV error: not handled */
1744 edma_err_cause &= ~EDMA_ERR_IRQ_TRANSIENT;
1745 if (edma_err_cause & ~(EDMA_ERR_DEV | EDMA_ERR_SELF_DIS))
1746 return 0; /* other problems: not handled */
1747
1748 if (pp->pp_flags & MV_PP_FLAG_NCQ_EN) {
1749 /*
1750 * EDMA should NOT have self-disabled for this case.
1751 * If it did, then something is wrong elsewhere,
1752 * and we cannot handle it here.
1753 */
1754 if (edma_err_cause & EDMA_ERR_SELF_DIS) {
1755 ata_port_printk(ap, KERN_WARNING,
1756 "%s: err_cause=0x%x pp_flags=0x%x\n",
1757 __func__, edma_err_cause, pp->pp_flags);
1758 return 0; /* not handled */
1759 }
1760 return mv_handle_fbs_ncq_dev_err(ap);
1761 } else {
1762 /*
1763 * EDMA should have self-disabled for this case.
1764 * If it did not, then something is wrong elsewhere,
1765 * and we cannot handle it here.
1766 */
1767 if (!(edma_err_cause & EDMA_ERR_SELF_DIS)) {
1768 ata_port_printk(ap, KERN_WARNING,
1769 "%s: err_cause=0x%x pp_flags=0x%x\n",
1770 __func__, edma_err_cause, pp->pp_flags);
1771 return 0; /* not handled */
1772 }
1773 return mv_handle_fbs_non_ncq_dev_err(ap);
1774 }
1775 return 0; /* not handled */
1776}
1777
1778static void mv_unexpected_intr(struct ata_port *ap, int edma_was_enabled)
1779{
1780 struct ata_eh_info *ehi = &ap->link.eh_info;
1781 char *when = "idle";
1782
1496 ata_ehi_clear_desc(ehi); 1783 ata_ehi_clear_desc(ehi);
1497 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN) { 1784 if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
1498 when = " while EDMA enabled"; 1785 when = "disabled";
1786 } else if (edma_was_enabled) {
1787 when = "EDMA enabled";
1499 } else { 1788 } else {
1500 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag); 1789 struct ata_queued_cmd *qc = ata_qc_from_tag(ap, ap->link.active_tag);
1501 if (qc && (qc->tf.flags & ATA_TFLAG_POLLING)) 1790 if (qc && (qc->tf.flags & ATA_TFLAG_POLLING))
1502 when = " while polling"; 1791 when = "polling";
1503 } 1792 }
1504 ata_ehi_push_desc(ehi, "unexpected device interrupt%s", when); 1793 ata_ehi_push_desc(ehi, "unexpected device interrupt while %s", when);
1505 ehi->err_mask |= AC_ERR_OTHER; 1794 ehi->err_mask |= AC_ERR_OTHER;
1506 ehi->action |= ATA_EH_RESET; 1795 ehi->action |= ATA_EH_RESET;
1507 ata_port_freeze(ap); 1796 ata_port_freeze(ap);
@@ -1519,7 +1808,7 @@ static void mv_unexpected_intr(struct ata_port *ap)
1519 * LOCKING: 1808 * LOCKING:
1520 * Inherited from caller. 1809 * Inherited from caller.
1521 */ 1810 */
1522static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc) 1811static void mv_err_intr(struct ata_port *ap)
1523{ 1812{
1524 void __iomem *port_mmio = mv_ap_base(ap); 1813 void __iomem *port_mmio = mv_ap_base(ap);
1525 u32 edma_err_cause, eh_freeze_mask, serr = 0; 1814 u32 edma_err_cause, eh_freeze_mask, serr = 0;
@@ -1527,24 +1816,42 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
1527 struct mv_host_priv *hpriv = ap->host->private_data; 1816 struct mv_host_priv *hpriv = ap->host->private_data;
1528 unsigned int action = 0, err_mask = 0; 1817 unsigned int action = 0, err_mask = 0;
1529 struct ata_eh_info *ehi = &ap->link.eh_info; 1818 struct ata_eh_info *ehi = &ap->link.eh_info;
1530 1819 struct ata_queued_cmd *qc;
1531 ata_ehi_clear_desc(ehi); 1820 int abort = 0;
1532 1821
1533 /* 1822 /*
1534 * Read and clear the err_cause bits. This won't actually 1823 * Read and clear the SError and err_cause bits.
1535 * clear for some errors (eg. SError), but we will be doing
1536 * a hard reset in those cases regardless, which *will* clear it.
1537 */ 1824 */
1825 sata_scr_read(&ap->link, SCR_ERROR, &serr);
1826 sata_scr_write_flush(&ap->link, SCR_ERROR, serr);
1827
1538 edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1828 edma_err_cause = readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1539 writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS); 1829 writelfl(~edma_err_cause, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1540 1830
1541 ata_ehi_push_desc(ehi, "edma_err_cause=%08x", edma_err_cause); 1831 ata_port_printk(ap, KERN_INFO, "%s: err_cause=%08x pp_flags=0x%x\n",
1832 __func__, edma_err_cause, pp->pp_flags);
1833
1834 if (edma_err_cause & EDMA_ERR_DEV) {
1835 /*
1836 * Device errors during FIS-based switching operation
1837 * require special handling.
1838 */
1839 if (mv_handle_dev_err(ap, edma_err_cause))
1840 return;
1841 }
1542 1842
1843 qc = mv_get_active_qc(ap);
1844 ata_ehi_clear_desc(ehi);
1845 ata_ehi_push_desc(ehi, "edma_err_cause=%08x pp_flags=%08x",
1846 edma_err_cause, pp->pp_flags);
1543 /* 1847 /*
1544 * All generations share these EDMA error cause bits: 1848 * All generations share these EDMA error cause bits:
1545 */ 1849 */
1546 if (edma_err_cause & EDMA_ERR_DEV) 1850 if (edma_err_cause & EDMA_ERR_DEV) {
1547 err_mask |= AC_ERR_DEV; 1851 err_mask |= AC_ERR_DEV;
1852 action |= ATA_EH_RESET;
1853 ata_ehi_push_desc(ehi, "dev error");
1854 }
1548 if (edma_err_cause & (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR | 1855 if (edma_err_cause & (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR |
1549 EDMA_ERR_CRQB_PAR | EDMA_ERR_CRPB_PAR | 1856 EDMA_ERR_CRQB_PAR | EDMA_ERR_CRPB_PAR |
1550 EDMA_ERR_INTRL_PAR)) { 1857 EDMA_ERR_INTRL_PAR)) {
@@ -1576,13 +1883,6 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
1576 ata_ehi_push_desc(ehi, "EDMA self-disable"); 1883 ata_ehi_push_desc(ehi, "EDMA self-disable");
1577 } 1884 }
1578 if (edma_err_cause & EDMA_ERR_SERR) { 1885 if (edma_err_cause & EDMA_ERR_SERR) {
1579 /*
1580 * Ensure that we read our own SCR, not a pmp link SCR:
1581 */
1582 ap->ops->scr_read(ap, SCR_ERROR, &serr);
1583 /*
1584 * Don't clear SError here; leave it for libata-eh:
1585 */
1586 ata_ehi_push_desc(ehi, "SError=%08x", serr); 1886 ata_ehi_push_desc(ehi, "SError=%08x", serr);
1587 err_mask |= AC_ERR_ATA_BUS; 1887 err_mask |= AC_ERR_ATA_BUS;
1588 action |= ATA_EH_RESET; 1888 action |= ATA_EH_RESET;
@@ -1602,10 +1902,29 @@ static void mv_err_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
1602 else 1902 else
1603 ehi->err_mask |= err_mask; 1903 ehi->err_mask |= err_mask;
1604 1904
1605 if (edma_err_cause & eh_freeze_mask) 1905 if (err_mask == AC_ERR_DEV) {
1906 /*
1907 * Cannot do ata_port_freeze() here,
1908 * because it would kill PIO access,
1909 * which is needed for further diagnosis.
1910 */
1911 mv_eh_freeze(ap);
1912 abort = 1;
1913 } else if (edma_err_cause & eh_freeze_mask) {
1914 /*
1915 * Note to self: ata_port_freeze() calls ata_port_abort()
1916 */
1606 ata_port_freeze(ap); 1917 ata_port_freeze(ap);
1607 else 1918 } else {
1608 ata_port_abort(ap); 1919 abort = 1;
1920 }
1921
1922 if (abort) {
1923 if (qc)
1924 ata_link_abort(qc->dev->link);
1925 else
1926 ata_port_abort(ap);
1927 }
1609} 1928}
1610 1929
1611static void mv_process_crpb_response(struct ata_port *ap, 1930static void mv_process_crpb_response(struct ata_port *ap,
@@ -1632,8 +1951,9 @@ static void mv_process_crpb_response(struct ata_port *ap,
1632 } 1951 }
1633 } 1952 }
1634 ata_status = edma_status >> CRPB_FLAG_STATUS_SHIFT; 1953 ata_status = edma_status >> CRPB_FLAG_STATUS_SHIFT;
1635 qc->err_mask |= ac_err_mask(ata_status); 1954 if (!ac_err_mask(ata_status))
1636 ata_qc_complete(qc); 1955 ata_qc_complete(qc);
1956 /* else: leave it for mv_err_intr() */
1637 } else { 1957 } else {
1638 ata_port_printk(ap, KERN_ERR, "%s: no qc for tag=%d\n", 1958 ata_port_printk(ap, KERN_ERR, "%s: no qc for tag=%d\n",
1639 __func__, tag); 1959 __func__, tag);
@@ -1677,6 +1997,44 @@ static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp
1677 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1997 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
1678} 1998}
1679 1999
2000static void mv_port_intr(struct ata_port *ap, u32 port_cause)
2001{
2002 struct mv_port_priv *pp;
2003 int edma_was_enabled;
2004
2005 if (!ap || (ap->flags & ATA_FLAG_DISABLED)) {
2006 mv_unexpected_intr(ap, 0);
2007 return;
2008 }
2009 /*
2010 * Grab a snapshot of the EDMA_EN flag setting,
2011 * so that we have a consistent view for this port,
2012 * even if something we call of our routines changes it.
2013 */
2014 pp = ap->private_data;
2015 edma_was_enabled = (pp->pp_flags & MV_PP_FLAG_EDMA_EN);
2016 /*
2017 * Process completed CRPB response(s) before other events.
2018 */
2019 if (edma_was_enabled && (port_cause & DONE_IRQ)) {
2020 mv_process_crpb_entries(ap, pp);
2021 if (pp->pp_flags & MV_PP_FLAG_DELAYED_EH)
2022 mv_handle_fbs_ncq_dev_err(ap);
2023 }
2024 /*
2025 * Handle chip-reported errors, or continue on to handle PIO.
2026 */
2027 if (unlikely(port_cause & ERR_IRQ)) {
2028 mv_err_intr(ap);
2029 } else if (!edma_was_enabled) {
2030 struct ata_queued_cmd *qc = mv_get_active_qc(ap);
2031 if (qc)
2032 ata_sff_host_intr(ap, qc);
2033 else
2034 mv_unexpected_intr(ap, edma_was_enabled);
2035 }
2036}
2037
1680/** 2038/**
1681 * mv_host_intr - Handle all interrupts on the given host controller 2039 * mv_host_intr - Handle all interrupts on the given host controller
1682 * @host: host specific structure 2040 * @host: host specific structure
@@ -1688,66 +2046,58 @@ static void mv_process_crpb_entries(struct ata_port *ap, struct mv_port_priv *pp
1688static int mv_host_intr(struct ata_host *host, u32 main_irq_cause) 2046static int mv_host_intr(struct ata_host *host, u32 main_irq_cause)
1689{ 2047{
1690 struct mv_host_priv *hpriv = host->private_data; 2048 struct mv_host_priv *hpriv = host->private_data;
1691 void __iomem *mmio = hpriv->base, *hc_mmio = NULL; 2049 void __iomem *mmio = hpriv->base, *hc_mmio;
1692 u32 hc_irq_cause = 0;
1693 unsigned int handled = 0, port; 2050 unsigned int handled = 0, port;
1694 2051
1695 for (port = 0; port < hpriv->n_ports; port++) { 2052 for (port = 0; port < hpriv->n_ports; port++) {
1696 struct ata_port *ap = host->ports[port]; 2053 struct ata_port *ap = host->ports[port];
1697 struct mv_port_priv *pp; 2054 unsigned int p, shift, hardport, port_cause;
1698 unsigned int shift, hardport, port_cause; 2055
1699 /*
1700 * When we move to the second hc, flag our cached
1701 * copies of hc_mmio (and hc_irq_cause) as invalid again.
1702 */
1703 if (port == MV_PORTS_PER_HC)
1704 hc_mmio = NULL;
1705 /*
1706 * Do nothing if port is not interrupting or is disabled:
1707 */
1708 MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport); 2056 MV_PORT_TO_SHIFT_AND_HARDPORT(port, shift, hardport);
1709 port_cause = (main_irq_cause >> shift) & (DONE_IRQ | ERR_IRQ);
1710 if (!port_cause || !ap || (ap->flags & ATA_FLAG_DISABLED))
1711 continue;
1712 /* 2057 /*
1713 * Each hc within the host has its own hc_irq_cause register. 2058 * Each hc within the host has its own hc_irq_cause register,
1714 * We defer reading it until we know we need it, right now: 2059 * where the interrupting ports bits get ack'd.
1715 *
1716 * FIXME later: we don't really need to read this register
1717 * (some logic changes required below if we go that way),
1718 * because it doesn't tell us anything new. But we do need
1719 * to write to it, outside the top of this loop,
1720 * to reset the interrupt triggers for next time.
1721 */ 2060 */
1722 if (!hc_mmio) { 2061 if (hardport == 0) { /* first port on this hc ? */
2062 u32 hc_cause = (main_irq_cause >> shift) & HC0_IRQ_PEND;
2063 u32 port_mask, ack_irqs;
2064 /*
2065 * Skip this entire hc if nothing pending for any ports
2066 */
2067 if (!hc_cause) {
2068 port += MV_PORTS_PER_HC - 1;
2069 continue;
2070 }
2071 /*
2072 * We don't need/want to read the hc_irq_cause register,
2073 * because doing so hurts performance, and
2074 * main_irq_cause already gives us everything we need.
2075 *
2076 * But we do have to *write* to the hc_irq_cause to ack
2077 * the ports that we are handling this time through.
2078 *
2079 * This requires that we create a bitmap for those
2080 * ports which interrupted us, and use that bitmap
2081 * to ack (only) those ports via hc_irq_cause.
2082 */
2083 ack_irqs = 0;
2084 for (p = 0; p < MV_PORTS_PER_HC; ++p) {
2085 if ((port + p) >= hpriv->n_ports)
2086 break;
2087 port_mask = (DONE_IRQ | ERR_IRQ) << (p * 2);
2088 if (hc_cause & port_mask)
2089 ack_irqs |= (DMA_IRQ | DEV_IRQ) << p;
2090 }
1723 hc_mmio = mv_hc_base_from_port(mmio, port); 2091 hc_mmio = mv_hc_base_from_port(mmio, port);
1724 hc_irq_cause = readl(hc_mmio + HC_IRQ_CAUSE_OFS); 2092 writelfl(~ack_irqs, hc_mmio + HC_IRQ_CAUSE_OFS);
1725 writelfl(~hc_irq_cause, hc_mmio + HC_IRQ_CAUSE_OFS);
1726 handled = 1; 2093 handled = 1;
1727 } 2094 }
1728 /* 2095 /*
1729 * Process completed CRPB response(s) before other events. 2096 * Handle interrupts signalled for this port:
1730 */
1731 pp = ap->private_data;
1732 if (hc_irq_cause & (DMA_IRQ << hardport)) {
1733 if (pp->pp_flags & MV_PP_FLAG_EDMA_EN)
1734 mv_process_crpb_entries(ap, pp);
1735 }
1736 /*
1737 * Handle chip-reported errors, or continue on to handle PIO.
1738 */ 2097 */
1739 if (unlikely(port_cause & ERR_IRQ)) { 2098 port_cause = (main_irq_cause >> shift) & (DONE_IRQ | ERR_IRQ);
1740 mv_err_intr(ap, mv_get_active_qc(ap)); 2099 if (port_cause)
1741 } else if (hc_irq_cause & (DEV_IRQ << hardport)) { 2100 mv_port_intr(ap, port_cause);
1742 if (!(pp->pp_flags & MV_PP_FLAG_EDMA_EN)) {
1743 struct ata_queued_cmd *qc = mv_get_active_qc(ap);
1744 if (qc) {
1745 ata_sff_host_intr(ap, qc);
1746 continue;
1747 }
1748 }
1749 mv_unexpected_intr(ap);
1750 }
1751 } 2101 }
1752 return handled; 2102 return handled;
1753} 2103}
@@ -1894,7 +2244,7 @@ static void mv5_reset_bus(struct ata_host *host, void __iomem *mmio)
1894 2244
1895static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio) 2245static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
1896{ 2246{
1897 writel(0x0fcfffff, mmio + MV_FLASH_CTL); 2247 writel(0x0fcfffff, mmio + MV_FLASH_CTL_OFS);
1898} 2248}
1899 2249
1900static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx, 2250static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx,
@@ -1913,7 +2263,7 @@ static void mv5_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio)
1913{ 2263{
1914 u32 tmp; 2264 u32 tmp;
1915 2265
1916 writel(0, mmio + MV_GPIO_PORT_CTL); 2266 writel(0, mmio + MV_GPIO_PORT_CTL_OFS);
1917 2267
1918 /* FIXME: handle MV_HP_ERRATA_50XXB2 errata */ 2268 /* FIXME: handle MV_HP_ERRATA_50XXB2 errata */
1919 2269
@@ -1931,14 +2281,14 @@ static void mv5_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
1931 int fix_apm_sq = (hpriv->hp_flags & MV_HP_ERRATA_50XXB0); 2281 int fix_apm_sq = (hpriv->hp_flags & MV_HP_ERRATA_50XXB0);
1932 2282
1933 if (fix_apm_sq) { 2283 if (fix_apm_sq) {
1934 tmp = readl(phy_mmio + MV5_LT_MODE); 2284 tmp = readl(phy_mmio + MV5_LTMODE_OFS);
1935 tmp |= (1 << 19); 2285 tmp |= (1 << 19);
1936 writel(tmp, phy_mmio + MV5_LT_MODE); 2286 writel(tmp, phy_mmio + MV5_LTMODE_OFS);
1937 2287
1938 tmp = readl(phy_mmio + MV5_PHY_CTL); 2288 tmp = readl(phy_mmio + MV5_PHY_CTL_OFS);
1939 tmp &= ~0x3; 2289 tmp &= ~0x3;
1940 tmp |= 0x1; 2290 tmp |= 0x1;
1941 writel(tmp, phy_mmio + MV5_PHY_CTL); 2291 writel(tmp, phy_mmio + MV5_PHY_CTL_OFS);
1942 } 2292 }
1943 2293
1944 tmp = readl(phy_mmio + MV5_PHY_MODE); 2294 tmp = readl(phy_mmio + MV5_PHY_MODE);
@@ -1956,11 +2306,6 @@ static void mv5_reset_hc_port(struct mv_host_priv *hpriv, void __iomem *mmio,
1956{ 2306{
1957 void __iomem *port_mmio = mv_port_base(mmio, port); 2307 void __iomem *port_mmio = mv_port_base(mmio, port);
1958 2308
1959 /*
1960 * The datasheet warns against setting ATA_RST when EDMA is active
1961 * (but doesn't say what the problem might be). So we first try
1962 * to disable the EDMA engine before doing the ATA_RST operation.
1963 */
1964 mv_reset_channel(hpriv, mmio, port); 2309 mv_reset_channel(hpriv, mmio, port);
1965 2310
1966 ZERO(0x028); /* command */ 2311 ZERO(0x028); /* command */
@@ -1975,7 +2320,7 @@ static void mv5_reset_hc_port(struct mv_host_priv *hpriv, void __iomem *mmio,
1975 ZERO(0x024); /* respq outp */ 2320 ZERO(0x024); /* respq outp */
1976 ZERO(0x020); /* respq inp */ 2321 ZERO(0x020); /* respq inp */
1977 ZERO(0x02c); /* test control */ 2322 ZERO(0x02c); /* test control */
1978 writel(0xbc, port_mmio + EDMA_IORDY_TMOUT); 2323 writel(0xbc, port_mmio + EDMA_IORDY_TMOUT_OFS);
1979} 2324}
1980#undef ZERO 2325#undef ZERO
1981 2326
@@ -2021,13 +2366,13 @@ static void mv_reset_pci_bus(struct ata_host *host, void __iomem *mmio)
2021 struct mv_host_priv *hpriv = host->private_data; 2366 struct mv_host_priv *hpriv = host->private_data;
2022 u32 tmp; 2367 u32 tmp;
2023 2368
2024 tmp = readl(mmio + MV_PCI_MODE); 2369 tmp = readl(mmio + MV_PCI_MODE_OFS);
2025 tmp &= 0xff00ffff; 2370 tmp &= 0xff00ffff;
2026 writel(tmp, mmio + MV_PCI_MODE); 2371 writel(tmp, mmio + MV_PCI_MODE_OFS);
2027 2372
2028 ZERO(MV_PCI_DISC_TIMER); 2373 ZERO(MV_PCI_DISC_TIMER);
2029 ZERO(MV_PCI_MSI_TRIGGER); 2374 ZERO(MV_PCI_MSI_TRIGGER);
2030 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT); 2375 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT_OFS);
2031 ZERO(PCI_HC_MAIN_IRQ_MASK_OFS); 2376 ZERO(PCI_HC_MAIN_IRQ_MASK_OFS);
2032 ZERO(MV_PCI_SERR_MASK); 2377 ZERO(MV_PCI_SERR_MASK);
2033 ZERO(hpriv->irq_cause_ofs); 2378 ZERO(hpriv->irq_cause_ofs);
@@ -2045,10 +2390,10 @@ static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
2045 2390
2046 mv5_reset_flash(hpriv, mmio); 2391 mv5_reset_flash(hpriv, mmio);
2047 2392
2048 tmp = readl(mmio + MV_GPIO_PORT_CTL); 2393 tmp = readl(mmio + MV_GPIO_PORT_CTL_OFS);
2049 tmp &= 0x3; 2394 tmp &= 0x3;
2050 tmp |= (1 << 5) | (1 << 6); 2395 tmp |= (1 << 5) | (1 << 6);
2051 writel(tmp, mmio + MV_GPIO_PORT_CTL); 2396 writel(tmp, mmio + MV_GPIO_PORT_CTL_OFS);
2052} 2397}
2053 2398
2054/** 2399/**
@@ -2121,7 +2466,7 @@ static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx,
2121 void __iomem *port_mmio; 2466 void __iomem *port_mmio;
2122 u32 tmp; 2467 u32 tmp;
2123 2468
2124 tmp = readl(mmio + MV_RESET_CFG); 2469 tmp = readl(mmio + MV_RESET_CFG_OFS);
2125 if ((tmp & (1 << 0)) == 0) { 2470 if ((tmp & (1 << 0)) == 0) {
2126 hpriv->signal[idx].amps = 0x7 << 8; 2471 hpriv->signal[idx].amps = 0x7 << 8;
2127 hpriv->signal[idx].pre = 0x1 << 5; 2472 hpriv->signal[idx].pre = 0x1 << 5;
@@ -2137,7 +2482,7 @@ static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx,
2137 2482
2138static void mv6_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio) 2483static void mv6_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio)
2139{ 2484{
2140 writel(0x00000060, mmio + MV_GPIO_PORT_CTL); 2485 writel(0x00000060, mmio + MV_GPIO_PORT_CTL_OFS);
2141} 2486}
2142 2487
2143static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio, 2488static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
@@ -2235,11 +2580,6 @@ static void mv_soc_reset_hc_port(struct mv_host_priv *hpriv,
2235{ 2580{
2236 void __iomem *port_mmio = mv_port_base(mmio, port); 2581 void __iomem *port_mmio = mv_port_base(mmio, port);
2237 2582
2238 /*
2239 * The datasheet warns against setting ATA_RST when EDMA is active
2240 * (but doesn't say what the problem might be). So we first try
2241 * to disable the EDMA engine before doing the ATA_RST operation.
2242 */
2243 mv_reset_channel(hpriv, mmio, port); 2583 mv_reset_channel(hpriv, mmio, port);
2244 2584
2245 ZERO(0x028); /* command */ 2585 ZERO(0x028); /* command */
@@ -2254,7 +2594,7 @@ static void mv_soc_reset_hc_port(struct mv_host_priv *hpriv,
2254 ZERO(0x024); /* respq outp */ 2594 ZERO(0x024); /* respq outp */
2255 ZERO(0x020); /* respq inp */ 2595 ZERO(0x020); /* respq inp */
2256 ZERO(0x02c); /* test control */ 2596 ZERO(0x02c); /* test control */
2257 writel(0xbc, port_mmio + EDMA_IORDY_TMOUT); 2597 writel(0xbc, port_mmio + EDMA_IORDY_TMOUT_OFS);
2258} 2598}
2259 2599
2260#undef ZERO 2600#undef ZERO
@@ -2297,38 +2637,39 @@ static void mv_soc_reset_bus(struct ata_host *host, void __iomem *mmio)
2297 return; 2637 return;
2298} 2638}
2299 2639
2300static void mv_setup_ifctl(void __iomem *port_mmio, int want_gen2i) 2640static void mv_setup_ifcfg(void __iomem *port_mmio, int want_gen2i)
2301{ 2641{
2302 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CFG); 2642 u32 ifcfg = readl(port_mmio + SATA_INTERFACE_CFG_OFS);
2303 2643
2304 ifctl = (ifctl & 0xf7f) | 0x9b1000; /* from chip spec */ 2644 ifcfg = (ifcfg & 0xf7f) | 0x9b1000; /* from chip spec */
2305 if (want_gen2i) 2645 if (want_gen2i)
2306 ifctl |= (1 << 7); /* enable gen2i speed */ 2646 ifcfg |= (1 << 7); /* enable gen2i speed */
2307 writelfl(ifctl, port_mmio + SATA_INTERFACE_CFG); 2647 writelfl(ifcfg, port_mmio + SATA_INTERFACE_CFG_OFS);
2308} 2648}
2309 2649
2310/*
2311 * Caller must ensure that EDMA is not active,
2312 * by first doing mv_stop_edma() where needed.
2313 */
2314static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio, 2650static void mv_reset_channel(struct mv_host_priv *hpriv, void __iomem *mmio,
2315 unsigned int port_no) 2651 unsigned int port_no)
2316{ 2652{
2317 void __iomem *port_mmio = mv_port_base(mmio, port_no); 2653 void __iomem *port_mmio = mv_port_base(mmio, port_no);
2318 2654
2655 /*
2656 * The datasheet warns against setting EDMA_RESET when EDMA is active
2657 * (but doesn't say what the problem might be). So we first try
2658 * to disable the EDMA engine before doing the EDMA_RESET operation.
2659 */
2319 mv_stop_edma_engine(port_mmio); 2660 mv_stop_edma_engine(port_mmio);
2320 writelfl(ATA_RST, port_mmio + EDMA_CMD_OFS); 2661 writelfl(EDMA_RESET, port_mmio + EDMA_CMD_OFS);
2321 2662
2322 if (!IS_GEN_I(hpriv)) { 2663 if (!IS_GEN_I(hpriv)) {
2323 /* Enable 3.0gb/s link speed */ 2664 /* Enable 3.0gb/s link speed: this survives EDMA_RESET */
2324 mv_setup_ifctl(port_mmio, 1); 2665 mv_setup_ifcfg(port_mmio, 1);
2325 } 2666 }
2326 /* 2667 /*
2327 * Strobing ATA_RST here causes a hard reset of the SATA transport, 2668 * Strobing EDMA_RESET here causes a hard reset of the SATA transport,
2328 * link, and physical layers. It resets all SATA interface registers 2669 * link, and physical layers. It resets all SATA interface registers
2329 * (except for SATA_INTERFACE_CFG), and issues a COMRESET to the dev. 2670 * (except for SATA_INTERFACE_CFG), and issues a COMRESET to the dev.
2330 */ 2671 */
2331 writelfl(ATA_RST, port_mmio + EDMA_CMD_OFS); 2672 writelfl(EDMA_RESET, port_mmio + EDMA_CMD_OFS);
2332 udelay(25); /* allow reset propagation */ 2673 udelay(25); /* allow reset propagation */
2333 writelfl(0, port_mmio + EDMA_CMD_OFS); 2674 writelfl(0, port_mmio + EDMA_CMD_OFS);
2334 2675
@@ -2392,7 +2733,7 @@ static int mv_hardreset(struct ata_link *link, unsigned int *class,
2392 sata_scr_read(link, SCR_STATUS, &sstatus); 2733 sata_scr_read(link, SCR_STATUS, &sstatus);
2393 if (!IS_GEN_I(hpriv) && ++attempts >= 5 && sstatus == 0x121) { 2734 if (!IS_GEN_I(hpriv) && ++attempts >= 5 && sstatus == 0x121) {
2394 /* Force 1.5gb/s link speed and try again */ 2735 /* Force 1.5gb/s link speed and try again */
2395 mv_setup_ifctl(mv_ap_base(ap), 0); 2736 mv_setup_ifcfg(mv_ap_base(ap), 0);
2396 if (time_after(jiffies + HZ, deadline)) 2737 if (time_after(jiffies + HZ, deadline))
2397 extra = HZ; /* only extend it once, max */ 2738 extra = HZ; /* only extend it once, max */
2398 } 2739 }
@@ -2493,6 +2834,34 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
2493 readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS)); 2834 readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS));
2494} 2835}
2495 2836
2837static unsigned int mv_in_pcix_mode(struct ata_host *host)
2838{
2839 struct mv_host_priv *hpriv = host->private_data;
2840 void __iomem *mmio = hpriv->base;
2841 u32 reg;
2842
2843 if (!HAS_PCI(host) || !IS_PCIE(hpriv))
2844 return 0; /* not PCI-X capable */
2845 reg = readl(mmio + MV_PCI_MODE_OFS);
2846 if ((reg & MV_PCI_MODE_MASK) == 0)
2847 return 0; /* conventional PCI mode */
2848 return 1; /* chip is in PCI-X mode */
2849}
2850
2851static int mv_pci_cut_through_okay(struct ata_host *host)
2852{
2853 struct mv_host_priv *hpriv = host->private_data;
2854 void __iomem *mmio = hpriv->base;
2855 u32 reg;
2856
2857 if (!mv_in_pcix_mode(host)) {
2858 reg = readl(mmio + PCI_COMMAND_OFS);
2859 if (reg & PCI_COMMAND_MRDTRIG)
2860 return 0; /* not okay */
2861 }
2862 return 1; /* okay */
2863}
2864
2496static int mv_chip_id(struct ata_host *host, unsigned int board_idx) 2865static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
2497{ 2866{
2498 struct pci_dev *pdev = to_pci_dev(host->dev); 2867 struct pci_dev *pdev = to_pci_dev(host->dev);
@@ -2560,7 +2929,7 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
2560 break; 2929 break;
2561 2930
2562 case chip_7042: 2931 case chip_7042:
2563 hp_flags |= MV_HP_PCIE; 2932 hp_flags |= MV_HP_PCIE | MV_HP_CUT_THROUGH;
2564 if (pdev->vendor == PCI_VENDOR_ID_TTI && 2933 if (pdev->vendor == PCI_VENDOR_ID_TTI &&
2565 (pdev->device == 0x2300 || pdev->device == 0x2310)) 2934 (pdev->device == 0x2300 || pdev->device == 0x2310))
2566 { 2935 {
@@ -2590,9 +2959,12 @@ static int mv_chip_id(struct ata_host *host, unsigned int board_idx)
2590 " and avoid the final two gigabytes on" 2959 " and avoid the final two gigabytes on"
2591 " all RocketRAID BIOS initialized drives.\n"); 2960 " all RocketRAID BIOS initialized drives.\n");
2592 } 2961 }
2962 /* drop through */
2593 case chip_6042: 2963 case chip_6042:
2594 hpriv->ops = &mv6xxx_ops; 2964 hpriv->ops = &mv6xxx_ops;
2595 hp_flags |= MV_HP_GEN_IIE; 2965 hp_flags |= MV_HP_GEN_IIE;
2966 if (board_idx == chip_6042 && mv_pci_cut_through_okay(host))
2967 hp_flags |= MV_HP_CUT_THROUGH;
2596 2968
2597 switch (pdev->revision) { 2969 switch (pdev->revision) {
2598 case 0x0: 2970 case 0x0:
diff --git a/drivers/atm/iphase.h b/drivers/atm/iphase.h
index 133eefcc0475..b2cd20f549cb 100644
--- a/drivers/atm/iphase.h
+++ b/drivers/atm/iphase.h
@@ -1025,7 +1025,8 @@ typedef struct iadev_t {
1025 spinlock_t rx_lock, misc_lock; 1025 spinlock_t rx_lock, misc_lock;
1026 struct atm_vcc **rx_open; /* list of all open VCs */ 1026 struct atm_vcc **rx_open; /* list of all open VCs */
1027 u16 num_rx_desc, rx_buf_sz, rxing; 1027 u16 num_rx_desc, rx_buf_sz, rxing;
1028 u32 rx_pkt_ram, rx_tmp_cnt, rx_tmp_jif; 1028 u32 rx_pkt_ram, rx_tmp_cnt;
1029 unsigned long rx_tmp_jif;
1029 void __iomem *RX_DESC_BASE_ADDR; 1030 void __iomem *RX_DESC_BASE_ADDR;
1030 u32 drop_rxpkt, drop_rxcell, rx_cell_cnt, rx_pkt_cnt; 1031 u32 drop_rxpkt, drop_rxcell, rx_cell_cnt, rx_pkt_cnt;
1031 struct atm_dev *next_board; /* other iphase devices */ 1032 struct atm_dev *next_board; /* other iphase devices */
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 0ef00e8d4153..e085af0ff94f 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -140,7 +140,6 @@ int class_register(struct class *cls)
140 140
141 pr_debug("device class '%s': registering\n", cls->name); 141 pr_debug("device class '%s': registering\n", cls->name);
142 142
143 INIT_LIST_HEAD(&cls->children);
144 INIT_LIST_HEAD(&cls->devices); 143 INIT_LIST_HEAD(&cls->devices);
145 INIT_LIST_HEAD(&cls->interfaces); 144 INIT_LIST_HEAD(&cls->interfaces);
146 kset_init(&cls->class_dirs); 145 kset_init(&cls->class_dirs);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index be288b5e4180..3eeac5a78581 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1218,13 +1218,11 @@ int device_rename(struct device *dev, char *new_name)
1218 } 1218 }
1219#else 1219#else
1220 if (dev->class) { 1220 if (dev->class) {
1221 sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
1222 error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj, 1221 error = sysfs_create_link(&dev->class->subsys.kobj, &dev->kobj,
1223 dev->bus_id); 1222 dev->bus_id);
1224 if (error) { 1223 if (error)
1225 dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", 1224 goto out;
1226 __func__, error); 1225 sysfs_remove_link(&dev->class->subsys.kobj, old_device_name);
1227 }
1228 } 1226 }
1229#endif 1227#endif
1230 1228
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index 8ce6de5a7e28..937e8258981d 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -53,11 +53,13 @@ int register_memory_notifier(struct notifier_block *nb)
53{ 53{
54 return blocking_notifier_chain_register(&memory_chain, nb); 54 return blocking_notifier_chain_register(&memory_chain, nb);
55} 55}
56EXPORT_SYMBOL(register_memory_notifier);
56 57
57void unregister_memory_notifier(struct notifier_block *nb) 58void unregister_memory_notifier(struct notifier_block *nb)
58{ 59{
59 blocking_notifier_chain_unregister(&memory_chain, nb); 60 blocking_notifier_chain_unregister(&memory_chain, nb);
60} 61}
62EXPORT_SYMBOL(unregister_memory_notifier);
61 63
62/* 64/*
63 * register_memory - Setup a sysfs device for a memory block 65 * register_memory - Setup a sysfs device for a memory block
diff --git a/drivers/base/sys.c b/drivers/base/sys.c
index 4fbb56bcb1ee..358bb0be3c08 100644
--- a/drivers/base/sys.c
+++ b/drivers/base/sys.c
@@ -175,8 +175,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
175 } 175 }
176 176
177 /* Check whether this driver has already been added to a class. */ 177 /* Check whether this driver has already been added to a class. */
178 if ((drv->entry.next != drv->entry.prev) || 178 if (drv->entry.next && !list_empty(&drv->entry)) {
179 (drv->entry.next != NULL)) {
180 printk(KERN_WARNING "sysdev: class %s: driver (%p) has already" 179 printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
181 " been registered to a class, something is wrong, but " 180 " been registered to a class, something is wrong, but "
182 "will forge on!\n", cls->name, drv); 181 "will forge on!\n", cls->name, drv);
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 8fc429cf82b6..41f818be2f7e 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -755,11 +755,13 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector
755{ 755{
756 unsigned long n_sect = bio->bi_size >> 9; 756 unsigned long n_sect = bio->bi_size >> 9;
757 const int rw = bio_data_dir(bio); 757 const int rw = bio_data_dir(bio);
758 struct hd_struct *part;
758 759
759 all_stat_inc(disk, ios[rw], sector); 760 part = get_part(disk, sector);
760 all_stat_add(disk, ticks[rw], duration, sector); 761 all_stat_inc(disk, part, ios[rw], sector);
761 all_stat_add(disk, sectors[rw], n_sect, sector); 762 all_stat_add(disk, part, ticks[rw], duration, sector);
762 all_stat_add(disk, io_ticks, duration, sector); 763 all_stat_add(disk, part, sectors[rw], n_sect, sector);
764 all_stat_add(disk, part, io_ticks, duration, sector);
763} 765}
764 766
765void 767void
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 5dce3877eee5..595a925c62a9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -196,6 +196,7 @@ config ESPSERIAL
196config MOXA_INTELLIO 196config MOXA_INTELLIO
197 tristate "Moxa Intellio support" 197 tristate "Moxa Intellio support"
198 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) 198 depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
199 select FW_LOADER
199 help 200 help
200 Say Y here if you have a Moxa Intellio multiport serial card. 201 Say Y here if you have a Moxa Intellio multiport serial card.
201 202
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 5a5455585c1d..192688344ed2 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2352,10 +2352,16 @@ static int __devinit ipmi_of_probe(struct of_device *dev,
2352 2352
2353 info->si_type = (enum si_type) match->data; 2353 info->si_type = (enum si_type) match->data;
2354 info->addr_source = "device-tree"; 2354 info->addr_source = "device-tree";
2355 info->io_setup = mem_setup;
2356 info->irq_setup = std_irq_setup; 2355 info->irq_setup = std_irq_setup;
2357 2356
2358 info->io.addr_type = IPMI_MEM_ADDR_SPACE; 2357 if (resource.flags & IORESOURCE_IO) {
2358 info->io_setup = port_setup;
2359 info->io.addr_type = IPMI_IO_ADDR_SPACE;
2360 } else {
2361 info->io_setup = mem_setup;
2362 info->io.addr_type = IPMI_MEM_ADDR_SPACE;
2363 }
2364
2359 info->io.addr_data = resource.start; 2365 info->io.addr_data = resource.start;
2360 2366
2361 info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE; 2367 info->io.regsize = regsize ? *regsize : DEFAULT_REGSIZE;
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c
index fd2db07a50fc..3b23270eaa65 100644
--- a/drivers/char/serial167.c
+++ b/drivers/char/serial167.c
@@ -1073,7 +1073,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch)
1073 return 0; 1073 return 0;
1074 1074
1075 if (!info->xmit_buf) 1075 if (!info->xmit_buf)
1076 return; 1076 return 0;
1077 1077
1078 local_irq_save(flags); 1078 local_irq_save(flags);
1079 if (info->xmit_cnt >= PAGE_SIZE - 1) { 1079 if (info->xmit_cnt >= PAGE_SIZE - 1) {
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index f39f6fd89350..b1a7a8cb65ea 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -970,7 +970,8 @@ static int sx_set_real_termios(void *ptr)
970 sx_write_channel_byte(port, hi_mask, 0x1f); 970 sx_write_channel_byte(port, hi_mask, 0x1f);
971 break; 971 break;
972 default: 972 default:
973 printk(KERN_INFO "sx: Invalid wordsize: %u\n", CFLAG & CSIZE); 973 printk(KERN_INFO "sx: Invalid wordsize: %u\n",
974 (unsigned int)CFLAG & CSIZE);
974 break; 975 break;
975 } 976 }
976 977
@@ -997,7 +998,8 @@ static int sx_set_real_termios(void *ptr)
997 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags); 998 set_bit(TTY_HW_COOK_IN, &port->gs.tty->flags);
998 } 999 }
999 sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ", 1000 sx_dprintk(SX_DEBUG_TERMIOS, "iflags: %x(%d) ",
1000 port->gs.tty->termios->c_iflag, I_OTHER(port->gs.tty)); 1001 (unsigned int)port->gs.tty->termios->c_iflag,
1002 I_OTHER(port->gs.tty));
1001 1003
1002/* Tell line discipline whether we will do output cooking. 1004/* Tell line discipline whether we will do output cooking.
1003 * If OPOST is set and no other output flags are set then we can do output 1005 * If OPOST is set and no other output flags are set then we can do output
@@ -1010,7 +1012,8 @@ static int sx_set_real_termios(void *ptr)
1010 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags); 1012 clear_bit(TTY_HW_COOK_OUT, &port->gs.tty->flags);
1011 } 1013 }
1012 sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n", 1014 sx_dprintk(SX_DEBUG_TERMIOS, "oflags: %x(%d)\n",
1013 port->gs.tty->termios->c_oflag, O_OTHER(port->gs.tty)); 1015 (unsigned int)port->gs.tty->termios->c_oflag,
1016 O_OTHER(port->gs.tty));
1014 /* port->c_dcd = sx_get_CD (port); */ 1017 /* port->c_dcd = sx_get_CD (port); */
1015 func_exit(); 1018 func_exit();
1016 return 0; 1019 return 0;
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index 2001b0e52dc6..55c1653be00c 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -916,7 +916,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch)
916{ 916{
917 struct slgt_info *info = tty->driver_data; 917 struct slgt_info *info = tty->driver_data;
918 unsigned long flags; 918 unsigned long flags;
919 int ret; 919 int ret = 0;
920 920
921 if (sanity_check(info, tty->name, "put_char")) 921 if (sanity_check(info, tty->name, "put_char"))
922 return 0; 922 return 0;
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 49c1a2267a55..e94bee032314 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -1215,10 +1215,11 @@ int tty_check_change(struct tty_struct *tty)
1215 1215
1216 if (!tty->pgrp) { 1216 if (!tty->pgrp) {
1217 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n"); 1217 printk(KERN_WARNING "tty_check_change: tty->pgrp == NULL!\n");
1218 goto out; 1218 goto out_unlock;
1219 } 1219 }
1220 if (task_pgrp(current) == tty->pgrp) 1220 if (task_pgrp(current) == tty->pgrp)
1221 goto out; 1221 goto out_unlock;
1222 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1222 if (is_ignored(SIGTTOU)) 1223 if (is_ignored(SIGTTOU))
1223 goto out; 1224 goto out;
1224 if (is_current_pgrp_orphaned()) { 1225 if (is_current_pgrp_orphaned()) {
@@ -1229,6 +1230,8 @@ int tty_check_change(struct tty_struct *tty)
1229 set_thread_flag(TIF_SIGPENDING); 1230 set_thread_flag(TIF_SIGPENDING);
1230 ret = -ERESTARTSYS; 1231 ret = -ERESTARTSYS;
1231out: 1232out:
1233 return ret;
1234out_unlock:
1232 spin_unlock_irqrestore(&tty->ctrl_lock, flags); 1235 spin_unlock_irqrestore(&tty->ctrl_lock, flags);
1233 return ret; 1236 return ret;
1234} 1237}
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index e458b08139af..fa1ffbf2c621 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2742,6 +2742,10 @@ static int con_open(struct tty_struct *tty, struct file *filp)
2742 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows; 2742 tty->winsize.ws_row = vc_cons[currcons].d->vc_rows;
2743 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols; 2743 tty->winsize.ws_col = vc_cons[currcons].d->vc_cols;
2744 } 2744 }
2745 if (vc->vc_utf)
2746 tty->termios->c_iflag |= IUTF8;
2747 else
2748 tty->termios->c_iflag &= ~IUTF8;
2745 release_console_sem(); 2749 release_console_sem();
2746 vcs_make_sysfs(tty); 2750 vcs_make_sysfs(tty);
2747 return ret; 2751 return ret;
@@ -2918,6 +2922,8 @@ int __init vty_init(void)
2918 console_driver->minor_start = 1; 2922 console_driver->minor_start = 1;
2919 console_driver->type = TTY_DRIVER_TYPE_CONSOLE; 2923 console_driver->type = TTY_DRIVER_TYPE_CONSOLE;
2920 console_driver->init_termios = tty_std_termios; 2924 console_driver->init_termios = tty_std_termios;
2925 if (default_utf8)
2926 console_driver->init_termios.c_iflag |= IUTF8;
2921 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS; 2927 console_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_RESET_TERMIOS;
2922 tty_set_operations(console_driver, &con_ops); 2928 tty_set_operations(console_driver, &con_ops);
2923 if (tty_register_driver(console_driver)) 2929 if (tty_register_driver(console_driver))
diff --git a/drivers/edac/edac_core.h b/drivers/edac/edac_core.h
index a9aa845dbe74..b27b13c5eb5a 100644
--- a/drivers/edac/edac_core.h
+++ b/drivers/edac/edac_core.h
@@ -97,7 +97,7 @@ extern int edac_debug_level;
97#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \ 97#define PCI_VEND_DEV(vend, dev) PCI_VENDOR_ID_ ## vend, \
98 PCI_DEVICE_ID_ ## vend ## _ ## dev 98 PCI_DEVICE_ID_ ## vend ## _ ## dev
99 99
100#define dev_name(dev) (dev)->dev_name 100#define edac_dev_name(dev) (dev)->dev_name
101 101
102/* memory devices */ 102/* memory devices */
103enum dev_type { 103enum dev_type {
diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
index 63372fa7ecfe..5fcd3d89c75d 100644
--- a/drivers/edac/edac_device.c
+++ b/drivers/edac/edac_device.c
@@ -333,7 +333,7 @@ static int add_edac_dev_to_global_list(struct edac_device_ctl_info *edac_dev)
333fail0: 333fail0:
334 edac_printk(KERN_WARNING, EDAC_MC, 334 edac_printk(KERN_WARNING, EDAC_MC,
335 "%s (%s) %s %s already assigned %d\n", 335 "%s (%s) %s %s already assigned %d\n",
336 rover->dev->bus_id, dev_name(rover), 336 rover->dev->bus_id, edac_dev_name(rover),
337 rover->mod_name, rover->ctl_name, rover->dev_idx); 337 rover->mod_name, rover->ctl_name, rover->dev_idx);
338 return 1; 338 return 1;
339 339
@@ -538,7 +538,7 @@ int edac_device_add_device(struct edac_device_ctl_info *edac_dev)
538 "'%s': DEV '%s' (%s)\n", 538 "'%s': DEV '%s' (%s)\n",
539 edac_dev->mod_name, 539 edac_dev->mod_name,
540 edac_dev->ctl_name, 540 edac_dev->ctl_name,
541 dev_name(edac_dev), 541 edac_dev_name(edac_dev),
542 edac_op_state_to_string(edac_dev->op_state)); 542 edac_op_state_to_string(edac_dev->op_state));
543 543
544 mutex_unlock(&device_ctls_mutex); 544 mutex_unlock(&device_ctls_mutex);
@@ -599,7 +599,7 @@ struct edac_device_ctl_info *edac_device_del_device(struct device *dev)
599 edac_printk(KERN_INFO, EDAC_MC, 599 edac_printk(KERN_INFO, EDAC_MC,
600 "Removed device %d for %s %s: DEV %s\n", 600 "Removed device %d for %s %s: DEV %s\n",
601 edac_dev->dev_idx, 601 edac_dev->dev_idx,
602 edac_dev->mod_name, edac_dev->ctl_name, dev_name(edac_dev)); 602 edac_dev->mod_name, edac_dev->ctl_name, edac_dev_name(edac_dev));
603 603
604 return edac_dev; 604 return edac_dev;
605} 605}
diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index a4cf1645f588..d110392d48f4 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -402,7 +402,7 @@ static int add_mc_to_global_list(struct mem_ctl_info *mci)
402fail0: 402fail0:
403 edac_printk(KERN_WARNING, EDAC_MC, 403 edac_printk(KERN_WARNING, EDAC_MC,
404 "%s (%s) %s %s already assigned %d\n", p->dev->bus_id, 404 "%s (%s) %s %s already assigned %d\n", p->dev->bus_id,
405 dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx); 405 edac_dev_name(mci), p->mod_name, p->ctl_name, p->mc_idx);
406 return 1; 406 return 1;
407 407
408fail1: 408fail1:
@@ -517,7 +517,7 @@ int edac_mc_add_mc(struct mem_ctl_info *mci)
517 517
518 /* Report action taken */ 518 /* Report action taken */
519 edac_mc_printk(mci, KERN_INFO, "Giving out device to '%s' '%s':" 519 edac_mc_printk(mci, KERN_INFO, "Giving out device to '%s' '%s':"
520 " DEV %s\n", mci->mod_name, mci->ctl_name, dev_name(mci)); 520 " DEV %s\n", mci->mod_name, mci->ctl_name, edac_dev_name(mci));
521 521
522 mutex_unlock(&mem_ctls_mutex); 522 mutex_unlock(&mem_ctls_mutex);
523 return 0; 523 return 0;
@@ -565,7 +565,7 @@ struct mem_ctl_info *edac_mc_del_mc(struct device *dev)
565 565
566 edac_printk(KERN_INFO, EDAC_MC, 566 edac_printk(KERN_INFO, EDAC_MC,
567 "Removed device %d for %s %s: DEV %s\n", mci->mc_idx, 567 "Removed device %d for %s %s: DEV %s\n", mci->mc_idx,
568 mci->mod_name, mci->ctl_name, dev_name(mci)); 568 mci->mod_name, mci->ctl_name, edac_dev_name(mci));
569 569
570 return mci; 570 return mci;
571} 571}
diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
index 9b24340b52e1..22ec9d5d4312 100644
--- a/drivers/edac/edac_pci.c
+++ b/drivers/edac/edac_pci.c
@@ -150,7 +150,7 @@ static int add_edac_pci_to_global_list(struct edac_pci_ctl_info *pci)
150fail0: 150fail0:
151 edac_printk(KERN_WARNING, EDAC_PCI, 151 edac_printk(KERN_WARNING, EDAC_PCI,
152 "%s (%s) %s %s already assigned %d\n", 152 "%s (%s) %s %s already assigned %d\n",
153 rover->dev->bus_id, dev_name(rover), 153 rover->dev->bus_id, edac_dev_name(rover),
154 rover->mod_name, rover->ctl_name, rover->pci_idx); 154 rover->mod_name, rover->ctl_name, rover->pci_idx);
155 return 1; 155 return 1;
156 156
@@ -360,7 +360,7 @@ int edac_pci_add_device(struct edac_pci_ctl_info *pci, int edac_idx)
360 " DEV '%s' (%s)\n", 360 " DEV '%s' (%s)\n",
361 pci->mod_name, 361 pci->mod_name,
362 pci->ctl_name, 362 pci->ctl_name,
363 dev_name(pci), edac_op_state_to_string(pci->op_state)); 363 edac_dev_name(pci), edac_op_state_to_string(pci->op_state));
364 364
365 mutex_unlock(&edac_pci_ctls_mutex); 365 mutex_unlock(&edac_pci_ctls_mutex);
366 return 0; 366 return 0;
@@ -415,7 +415,7 @@ struct edac_pci_ctl_info *edac_pci_del_device(struct device *dev)
415 415
416 edac_printk(KERN_INFO, EDAC_PCI, 416 edac_printk(KERN_INFO, EDAC_PCI,
417 "Removed device %d for %s %s: DEV %s\n", 417 "Removed device %d for %s %s: DEV %s\n",
418 pci->pci_idx, pci->mod_name, pci->ctl_name, dev_name(pci)); 418 pci->pci_idx, pci->mod_name, pci->ctl_name, edac_dev_name(pci));
419 419
420 return pci; 420 return pci;
421} 421}
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index 491718fe46b7..cae9dc89d88c 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -335,7 +335,7 @@ i2c_au1550_probe(struct platform_device *pdev)
335 goto out_mem; 335 goto out_mem;
336 } 336 }
337 337
338 priv->psc_base = r->start; 338 priv->psc_base = CKSEG1ADDR(r->start);
339 priv->xfer_timeout = 200; 339 priv->xfer_timeout = 200;
340 priv->ack_timeout = 200; 340 priv->ack_timeout = 200;
341 341
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 18beb0ad7bf3..a076129de7e8 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -99,7 +99,7 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
99 u32 x; 99 u32 x;
100 int result = 0; 100 int result = 0;
101 101
102 if (i2c->irq == 0) 102 if (i2c->irq == NO_IRQ)
103 { 103 {
104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) { 104 while (!(readb(i2c->base + MPC_I2C_SR) & CSR_MIF)) {
105 schedule(); 105 schedule();
@@ -329,10 +329,9 @@ static int fsl_i2c_probe(struct platform_device *pdev)
329 return -ENOMEM; 329 return -ENOMEM;
330 330
331 i2c->irq = platform_get_irq(pdev, 0); 331 i2c->irq = platform_get_irq(pdev, 0);
332 if (i2c->irq < 0) { 332 if (i2c->irq < 0)
333 result = -ENXIO; 333 i2c->irq = NO_IRQ; /* Use polling */
334 goto fail_get_irq; 334
335 }
336 i2c->flags = pdata->device_flags; 335 i2c->flags = pdata->device_flags;
337 init_waitqueue_head(&i2c->queue); 336 init_waitqueue_head(&i2c->queue);
338 337
@@ -344,7 +343,7 @@ static int fsl_i2c_probe(struct platform_device *pdev)
344 goto fail_map; 343 goto fail_map;
345 } 344 }
346 345
347 if (i2c->irq != 0) 346 if (i2c->irq != NO_IRQ)
348 if ((result = request_irq(i2c->irq, mpc_i2c_isr, 347 if ((result = request_irq(i2c->irq, mpc_i2c_isr,
349 IRQF_SHARED, "i2c-mpc", i2c)) < 0) { 348 IRQF_SHARED, "i2c-mpc", i2c)) < 0) {
350 printk(KERN_ERR 349 printk(KERN_ERR
@@ -367,12 +366,11 @@ static int fsl_i2c_probe(struct platform_device *pdev)
367 return result; 366 return result;
368 367
369 fail_add: 368 fail_add:
370 if (i2c->irq != 0) 369 if (i2c->irq != NO_IRQ)
371 free_irq(i2c->irq, i2c); 370 free_irq(i2c->irq, i2c);
372 fail_irq: 371 fail_irq:
373 iounmap(i2c->base); 372 iounmap(i2c->base);
374 fail_map: 373 fail_map:
375 fail_get_irq:
376 kfree(i2c); 374 kfree(i2c);
377 return result; 375 return result;
378}; 376};
@@ -384,7 +382,7 @@ static int fsl_i2c_remove(struct platform_device *pdev)
384 i2c_del_adapter(&i2c->adap); 382 i2c_del_adapter(&i2c->adap);
385 platform_set_drvdata(pdev, NULL); 383 platform_set_drvdata(pdev, NULL);
386 384
387 if (i2c->irq != 0) 385 if (i2c->irq != NO_IRQ)
388 free_irq(i2c->irq, i2c); 386 free_irq(i2c->irq, i2c);
389 387
390 iounmap(i2c->base); 388 iounmap(i2c->base);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index fdc9ad805e35..ac9165968587 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -104,10 +104,31 @@ MODULE_PARM_DESC(force_addr,
104static int piix4_transaction(void); 104static int piix4_transaction(void);
105 105
106static unsigned short piix4_smba; 106static unsigned short piix4_smba;
107static int srvrworks_csb5_delay;
107static struct pci_driver piix4_driver; 108static struct pci_driver piix4_driver;
108static struct i2c_adapter piix4_adapter; 109static struct i2c_adapter piix4_adapter;
109 110
110static struct dmi_system_id __devinitdata piix4_dmi_table[] = { 111static struct dmi_system_id __devinitdata piix4_dmi_blacklist[] = {
112 {
113 .ident = "Sapphire AM2RD790",
114 .matches = {
115 DMI_MATCH(DMI_BOARD_VENDOR, "SAPPHIRE Inc."),
116 DMI_MATCH(DMI_BOARD_NAME, "PC-AM2RD790"),
117 },
118 },
119 {
120 .ident = "DFI Lanparty UT 790FX",
121 .matches = {
122 DMI_MATCH(DMI_BOARD_VENDOR, "DFI Inc."),
123 DMI_MATCH(DMI_BOARD_NAME, "LP UT 790FX"),
124 },
125 },
126 { }
127};
128
129/* The IBM entry is in a separate table because we only check it
130 on Intel-based systems */
131static struct dmi_system_id __devinitdata piix4_dmi_ibm[] = {
111 { 132 {
112 .ident = "IBM", 133 .ident = "IBM",
113 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), }, 134 .matches = { DMI_MATCH(DMI_SYS_VENDOR, "IBM"), },
@@ -122,8 +143,20 @@ static int __devinit piix4_setup(struct pci_dev *PIIX4_dev,
122 143
123 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev)); 144 dev_info(&PIIX4_dev->dev, "Found %s device\n", pci_name(PIIX4_dev));
124 145
146 if ((PIIX4_dev->vendor == PCI_VENDOR_ID_SERVERWORKS) &&
147 (PIIX4_dev->device == PCI_DEVICE_ID_SERVERWORKS_CSB5))
148 srvrworks_csb5_delay = 1;
149
150 /* On some motherboards, it was reported that accessing the SMBus
151 caused severe hardware problems */
152 if (dmi_check_system(piix4_dmi_blacklist)) {
153 dev_err(&PIIX4_dev->dev,
154 "Accessing the SMBus on this system is unsafe!\n");
155 return -EPERM;
156 }
157
125 /* Don't access SMBus on IBM systems which get corrupted eeproms */ 158 /* Don't access SMBus on IBM systems which get corrupted eeproms */
126 if (dmi_check_system(piix4_dmi_table) && 159 if (dmi_check_system(piix4_dmi_ibm) &&
127 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) { 160 PIIX4_dev->vendor == PCI_VENDOR_ID_INTEL) {
128 dev_err(&PIIX4_dev->dev, "IBM system detected; this module " 161 dev_err(&PIIX4_dev->dev, "IBM system detected; this module "
129 "may corrupt your serial eeprom! Refusing to load " 162 "may corrupt your serial eeprom! Refusing to load "
@@ -230,10 +263,14 @@ static int piix4_transaction(void)
230 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT); 263 outb_p(inb(SMBHSTCNT) | 0x040, SMBHSTCNT);
231 264
232 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */ 265 /* We will always wait for a fraction of a second! (See PIIX4 docs errata) */
233 do { 266 if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
267 msleep(2);
268 else
269 msleep(1);
270
271 while ((timeout++ < MAX_TIMEOUT) &&
272 ((temp = inb_p(SMBHSTSTS)) & 0x01))
234 msleep(1); 273 msleep(1);
235 temp = inb_p(SMBHSTSTS);
236 } while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
237 274
238 /* If the SMBus is still busy, we give up */ 275 /* If the SMBus is still busy, we give up */
239 if (timeout >= MAX_TIMEOUT) { 276 if (timeout >= MAX_TIMEOUT) {
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index 8fbbdb4c2f35..114634da6c6e 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -132,14 +132,14 @@ static const struct i2c_algorithm i2c_sibyte_algo = {
132/* 132/*
133 * registering functions to load algorithms at runtime 133 * registering functions to load algorithms at runtime
134 */ 134 */
135int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed) 135static int __init i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
136{ 136{
137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data; 137 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
138 138
139 /* register new adapter to i2c module... */ 139 /* Register new adapter to i2c module... */
140 i2c_adap->algo = &i2c_sibyte_algo; 140 i2c_adap->algo = &i2c_sibyte_algo;
141 141
142 /* Set the frequency to 100 kHz */ 142 /* Set the requested frequency. */
143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ)); 143 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL)); 144 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
145 145
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 26384daccb96..c99ebeadb558 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -327,6 +327,11 @@ void i2c_unregister_device(struct i2c_client *client)
327EXPORT_SYMBOL_GPL(i2c_unregister_device); 327EXPORT_SYMBOL_GPL(i2c_unregister_device);
328 328
329 329
330static const struct i2c_device_id dummy_id[] = {
331 { "dummy", 0 },
332 { },
333};
334
330static int dummy_probe(struct i2c_client *client, 335static int dummy_probe(struct i2c_client *client,
331 const struct i2c_device_id *id) 336 const struct i2c_device_id *id)
332{ 337{
@@ -342,13 +347,13 @@ static struct i2c_driver dummy_driver = {
342 .driver.name = "dummy", 347 .driver.name = "dummy",
343 .probe = dummy_probe, 348 .probe = dummy_probe,
344 .remove = dummy_remove, 349 .remove = dummy_remove,
350 .id_table = dummy_id,
345}; 351};
346 352
347/** 353/**
348 * i2c_new_dummy - return a new i2c device bound to a dummy driver 354 * i2c_new_dummy - return a new i2c device bound to a dummy driver
349 * @adapter: the adapter managing the device 355 * @adapter: the adapter managing the device
350 * @address: seven bit address to be used 356 * @address: seven bit address to be used
351 * @type: optional label used for i2c_client.name
352 * Context: can sleep 357 * Context: can sleep
353 * 358 *
354 * This returns an I2C client bound to the "dummy" driver, intended for use 359 * This returns an I2C client bound to the "dummy" driver, intended for use
@@ -364,15 +369,12 @@ static struct i2c_driver dummy_driver = {
364 * i2c_unregister_device(); or NULL to indicate an error. 369 * i2c_unregister_device(); or NULL to indicate an error.
365 */ 370 */
366struct i2c_client * 371struct i2c_client *
367i2c_new_dummy(struct i2c_adapter *adapter, u16 address, const char *type) 372i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
368{ 373{
369 struct i2c_board_info info = { 374 struct i2c_board_info info = {
370 .driver_name = "dummy", 375 I2C_BOARD_INFO("dummy", address),
371 .addr = address,
372 }; 376 };
373 377
374 if (type)
375 strlcpy(info.type, type, sizeof info.type);
376 return i2c_new_device(adapter, &info); 378 return i2c_new_device(adapter, &info);
377} 379}
378EXPORT_SYMBOL_GPL(i2c_new_dummy); 380EXPORT_SYMBOL_GPL(i2c_new_dummy);
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index f702f9152ce6..b4f3aefa12b6 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -1,8 +1,6 @@
1# 1#
2# IDE ATA ATAPI Block device driver configuration 2# IDE ATA ATAPI Block device driver configuration
3# 3#
4# Andre Hedrick <andre@linux-ide.org>
5#
6 4
7# Select HAVE_IDE if IDE is supported 5# Select HAVE_IDE if IDE is supported
8config HAVE_IDE 6config HAVE_IDE
@@ -335,7 +333,7 @@ config BLK_DEV_CMD640
335 This driver will work automatically in PCI based systems (most new 333 This driver will work automatically in PCI based systems (most new
336 systems have PCI slots). But if your system uses VESA local bus 334 systems have PCI slots). But if your system uses VESA local bus
337 (VLB) instead of PCI, you must also supply a kernel boot parameter 335 (VLB) instead of PCI, you must also supply a kernel boot parameter
338 to enable the CMD640 bugfix/support: "ide0=cmd640_vlb". (Try "man 336 to enable the CMD640 bugfix/support: "cmd640.probe_vlb". (Try "man
339 bootparam" or see the documentation of your boot loader about how to 337 bootparam" or see the documentation of your boot loader about how to
340 pass options to the kernel.) 338 pass options to the kernel.)
341 339
@@ -457,27 +455,11 @@ config BLK_DEV_ALI15X3
457 onboard chipsets. It also tests for Simplex mode and enables 455 onboard chipsets. It also tests for Simplex mode and enables
458 normal dual channel support. 456 normal dual channel support.
459 457
460 If you say Y here, you also need to say Y to "Use DMA by default 458 Please read the comments at the top of
461 when available", above. Please read the comments at the top of
462 <file:drivers/ide/pci/alim15x3.c>. 459 <file:drivers/ide/pci/alim15x3.c>.
463 460
464 If unsure, say N. 461 If unsure, say N.
465 462
466config WDC_ALI15X3
467 bool "ALI M15x3 WDC support (DANGEROUS)"
468 depends on BLK_DEV_ALI15X3
469 ---help---
470 This allows for UltraDMA support for WDC drives that ignore CRC
471 checking. You are a fool for enabling this option, but there have
472 been requests. DO NOT COMPLAIN IF YOUR DRIVE HAS FS CORRUPTION, IF
473 YOU ENABLE THIS! No one will listen, just laugh for ignoring this
474 SERIOUS WARNING.
475
476 Using this option can allow WDC drives to run at ATA-4/5 transfer
477 rates with only an ATA-2 support structure.
478
479 SAY N!
480
481config BLK_DEV_AMD74XX 463config BLK_DEV_AMD74XX
482 tristate "AMD and nVidia IDE support" 464 tristate "AMD and nVidia IDE support"
483 depends on !ARM 465 depends on !ARM
@@ -520,9 +502,6 @@ config BLK_DEV_CY82C693
520 This driver adds detection and support for the CY82C693 chipset 502 This driver adds detection and support for the CY82C693 chipset
521 used on Digital's PC-Alpha 164SX boards. 503 used on Digital's PC-Alpha 164SX boards.
522 504
523 If you say Y here, you need to say Y to "Use DMA by default
524 when available" as well.
525
526config BLK_DEV_CS5520 505config BLK_DEV_CS5520
527 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" 506 tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)"
528 depends on EXPERIMENTAL 507 depends on EXPERIMENTAL
@@ -613,13 +592,12 @@ config BLK_DEV_SC1200
613 National SCx200 series of embedded x86 "Geode" systems. 592 National SCx200 series of embedded x86 "Geode" systems.
614 593
615config BLK_DEV_PIIX 594config BLK_DEV_PIIX
616 tristate "Intel PIIXn chipsets support" 595 tristate "Intel PIIX/ICH chipsets support"
617 select BLK_DEV_IDEDMA_PCI 596 select BLK_DEV_IDEDMA_PCI
618 help 597 help
619 This driver adds explicit support for Intel PIIX and ICH chips 598 This driver adds explicit support for Intel PIIX and ICH chips.
620 and also for the Efar Victory66 (slc90e66) chip. This allows 599 This allows the kernel to change PIO, DMA and UDMA speeds and to
621 the kernel to change PIO, DMA and UDMA speeds and to configure 600 configure the chip to optimum performance.
622 the chip to optimum performance.
623 601
624config BLK_DEV_IT8213 602config BLK_DEV_IT8213
625 tristate "IT8213 IDE support" 603 tristate "IT8213 IDE support"
@@ -657,11 +635,7 @@ config BLK_DEV_PDC202XX_OLD
657 happen if the BIOS revisions of all installed cards (three-max) do 635 happen if the BIOS revisions of all installed cards (three-max) do
658 not match, the driver attempts to do dynamic tuning of the chipset 636 not match, the driver attempts to do dynamic tuning of the chipset
659 at boot-time for max-speed. Ultra33 BIOS 1.25 or newer is required 637 at boot-time for max-speed. Ultra33 BIOS 1.25 or newer is required
660 for more than one card. This card may require that you say Y to 638 for more than one card.
661 "Special UDMA Feature".
662
663 If you say Y here, you need to say Y to "Use DMA by default when
664 available" as well.
665 639
666 Please read the comments at the top of 640 Please read the comments at the top of
667 <file:drivers/ide/pci/pdc202xx_old.c>. 641 <file:drivers/ide/pci/pdc202xx_old.c>.
@@ -710,9 +684,6 @@ config BLK_DEV_SIS5513
710 ATA100: SiS635, SiS645, SiS650, SiS730, SiS735, SiS740, 684 ATA100: SiS635, SiS645, SiS650, SiS730, SiS735, SiS740,
711 SiS745, SiS750 685 SiS745, SiS750
712 686
713 If you say Y here, you need to say Y to "Use DMA by default when
714 available" as well.
715
716 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>. 687 Please read the comments at the top of <file:drivers/ide/pci/sis5513.c>.
717 688
718config BLK_DEV_SL82C105 689config BLK_DEV_SL82C105
@@ -734,9 +705,6 @@ config BLK_DEV_SLC90E66
734 and it will handle timing cycles. Since this is an improved 705 and it will handle timing cycles. Since this is an improved
735 look-a-like to the PIIX4 it should be a nice addition. 706 look-a-like to the PIIX4 it should be a nice addition.
736 707
737 If you say Y here, you need to say Y to "Use DMA by default when
738 available" as well.
739
740 Please read the comments at the top of 708 Please read the comments at the top of
741 <file:drivers/ide/pci/slc90e66.c>. 709 <file:drivers/ide/pci/slc90e66.c>.
742 710
@@ -888,17 +856,17 @@ config BLK_DEV_IDEDOUBLER
888 bool "Amiga IDE Doubler support (EXPERIMENTAL)" 856 bool "Amiga IDE Doubler support (EXPERIMENTAL)"
889 depends on BLK_DEV_GAYLE && EXPERIMENTAL 857 depends on BLK_DEV_GAYLE && EXPERIMENTAL
890 ---help--- 858 ---help---
891 This driver provides support for the so-called `IDE doublers' (made 859 This feature provides support for the so-called `IDE doublers' (made
892 by various manufacturers, e.g. Eyetech) that can be connected to 860 by various manufacturers, e.g. Eyetech) that can be connected to
893 the on-board IDE interface of some Amiga models. Using such an IDE 861 the on-board IDE interface of some Amiga models. Using such an IDE
894 doubler, you can connect up to four instead of two IDE devices to 862 doubler, you can connect up to four instead of two IDE devices to
895 the Amiga's on-board IDE interface. 863 the Amiga's on-board IDE interface.
896 864
897 Note that the normal Amiga Gayle IDE driver may not work correctly 865 Note that the normal Amiga Gayle IDE driver may not work correctly
898 if you have an IDE doubler and don't enable this driver! 866 if you have an IDE doubler and don't enable this feature!
899 867
900 Say Y if you have an IDE doubler. The driver is enabled at kernel 868 Say Y if you have an IDE doubler. The feature is enabled at kernel
901 runtime using the "ide=doubler" kernel boot parameter. 869 runtime using the "gayle.doubler" kernel boot parameter.
902 870
903config BLK_DEV_BUDDHA 871config BLK_DEV_BUDDHA
904 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)" 872 tristate "Buddha/Catweasel/X-Surf IDE interface support (EXPERIMENTAL)"
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 57d9a9a79a6f..0daf923541ff 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -95,7 +95,7 @@ void SELECT_DRIVE (ide_drive_t *drive)
95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr); 95 hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
96} 96}
97 97
98void SELECT_MASK (ide_drive_t *drive, int mask) 98static void SELECT_MASK(ide_drive_t *drive, int mask)
99{ 99{
100 const struct ide_port_ops *port_ops = drive->hwif->port_ops; 100 const struct ide_port_ops *port_ops = drive->hwif->port_ops;
101 101
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c
index 83555ca513b5..9e449a0c623f 100644
--- a/drivers/ide/legacy/falconide.c
+++ b/drivers/ide/legacy/falconide.c
@@ -61,7 +61,7 @@ static void falconide_output_data(ide_drive_t *drive, struct request *rq,
61 unsigned long data_addr = drive->hwif->io_ports.data_addr; 61 unsigned long data_addr = drive->hwif->io_ports.data_addr;
62 62
63 if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) 63 if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS)
64 return outsw(data_adr, buf, (len + 1) / 2); 64 return outsw(data_addr, buf, (len + 1) / 2);
65 65
66 outsw_swapw(data_addr, buf, (len + 1) / 2); 66 outsw_swapw(data_addr, buf, (len + 1) / 2);
67} 67}
diff --git a/drivers/ide/mips/swarm.c b/drivers/ide/mips/swarm.c
index 712d17bdd470..52fee3d2771a 100644
--- a/drivers/ide/mips/swarm.c
+++ b/drivers/ide/mips/swarm.c
@@ -4,7 +4,7 @@
4 * Author: Manish Lachwani, mlachwani@mvista.com 4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved. 5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com> 6 * Author: Maciej W. Rozycki <macro@mips.com>
7 * Copyright (c) 2006 Maciej W. Rozycki 7 * Copyright (c) 2006, 2008 Maciej W. Rozycki
8 * 8 *
9 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License 10 * modify it under the terms of the GNU General Public License
@@ -70,8 +70,9 @@ static int __devinit swarm_ide_probe(struct device *dev)
70 ide_hwif_t *hwif; 70 ide_hwif_t *hwif;
71 u8 __iomem *base; 71 u8 __iomem *base;
72 phys_t offset, size; 72 phys_t offset, size;
73 hw_regs_t hw;
73 int i; 74 int i;
74 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 75 u8 idx[] = { 0xff, 0xff, 0xff, 0xff };
75 76
76 if (!SIBYTE_HAVE_IDE) 77 if (!SIBYTE_HAVE_IDE)
77 return -ENODEV; 78 return -ENODEV;
@@ -112,14 +113,15 @@ static int __devinit swarm_ide_probe(struct device *dev)
112 hwif->host_flags = IDE_HFLAG_MMIO; 113 hwif->host_flags = IDE_HFLAG_MMIO;
113 default_hwif_mmiops(hwif); 114 default_hwif_mmiops(hwif);
114 115
115 hwif->chipset = ide_generic;
116
117 for (i = 0; i <= 7; i++) 116 for (i = 0; i <= 7; i++)
118 hwif->io_ports_array[i] = 117 hw.io_ports_array[i] =
119 (unsigned long)(base + ((0x1f0 + i) << 5)); 118 (unsigned long)(base + ((0x1f0 + i) << 5));
120 hwif->io_ports.ctl_addr = 119 hw.io_ports.ctl_addr =
121 (unsigned long)(base + (0x3f6 << 5)); 120 (unsigned long)(base + (0x3f6 << 5));
122 hwif->irq = K_INT_GB_IDE; 121 hw.irq = K_INT_GB_IDE;
122 hw.chipset = ide_generic;
123
124 ide_init_port_hw(hwif, &hw);
123 125
124 idx[0] = hwif->index; 126 idx[0] = hwif->index;
125 127
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index c1922f9cfe80..f2129d5e07f2 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -39,6 +39,16 @@
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41/* 41/*
42 * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking
43 * (this is DANGEROUS and could result in data corruption).
44 */
45static int wdc_udma;
46
47module_param(wdc_udma, bool, 0);
48MODULE_PARM_DESC(wdc_udma,
49 "allow UDMA on M1543C-E chipset for WDC disks (DANGEROUS)");
50
51/*
42 * ALi devices are not plug in. Otherwise these static values would 52 * ALi devices are not plug in. Otherwise these static values would
43 * need to go. They ought to go away anyway 53 * need to go. They ought to go away anyway
44 */ 54 */
@@ -76,11 +86,6 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
76 a_clc = 0; 86 a_clc = 0;
77 c_time = ide_pio_timings[pio].cycle_time; 87 c_time = ide_pio_timings[pio].cycle_time;
78 88
79#if 0
80 if ((r_clc = ((c_time - s_time - a_time) * bus_speed + 999) / 1000) >= 16)
81 r_clc = 0;
82#endif
83
84 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) { 89 if (!(r_clc = (c_time * bus_speed + 999) / 1000 - a_clc - s_clc)) {
85 r_clc = 1; 90 r_clc = 1;
86 } else { 91 } else {
@@ -110,16 +115,6 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
110 pci_write_config_byte(dev, port, s_clc); 115 pci_write_config_byte(dev, port, s_clc);
111 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc); 116 pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc);
112 local_irq_restore(flags); 117 local_irq_restore(flags);
113
114 /*
115 * setup active rec
116 * { 70, 165, 365 }, PIO Mode 0
117 * { 50, 125, 208 }, PIO Mode 1
118 * { 30, 100, 110 }, PIO Mode 2
119 * { 30, 80, 70 }, PIO Mode 3 with IORDY
120 * { 25, 70, 25 }, PIO Mode 4 with IORDY ns
121 * { 20, 50, 30 } PIO Mode 5 with IORDY (nonstandard)
122 */
123} 118}
124 119
125/** 120/**
@@ -131,9 +126,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
131 * The actual rules for the ALi are: 126 * The actual rules for the ALi are:
132 * No UDMA on revisions <= 0x20 127 * No UDMA on revisions <= 0x20
133 * Disk only for revisions < 0xC2 128 * Disk only for revisions < 0xC2
134 * Not WDC drives for revisions < 0xC2 129 * Not WDC drives on M1543C-E (?)
135 *
136 * FIXME: WDC ifdef needs to die
137 */ 130 */
138 131
139static u8 ali_udma_filter(ide_drive_t *drive) 132static u8 ali_udma_filter(ide_drive_t *drive)
@@ -141,10 +134,9 @@ static u8 ali_udma_filter(ide_drive_t *drive)
141 if (m5229_revision > 0x20 && m5229_revision < 0xC2) { 134 if (m5229_revision > 0x20 && m5229_revision < 0xC2) {
142 if (drive->media != ide_disk) 135 if (drive->media != ide_disk)
143 return 0; 136 return 0;
144#ifndef CONFIG_WDC_ALI15X3 137 if (chip_is_1543c_e && strstr(drive->id->model, "WDC ") &&
145 if (chip_is_1543c_e && strstr(drive->id->model, "WDC ")) 138 wdc_udma == 0)
146 return 0; 139 return 0;
147#endif
148 } 140 }
149 141
150 return drive->hwif->ultra_mask; 142 return drive->hwif->ultra_mask;
@@ -537,17 +529,9 @@ static const struct ide_port_info ali15x3_chipset __devinitdata = {
537 529
538static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 530static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
539{ 531{
540 static struct pci_device_id ati_rs100[] = {
541 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100) },
542 { },
543 };
544
545 struct ide_port_info d = ali15x3_chipset; 532 struct ide_port_info d = ali15x3_chipset;
546 u8 rev = dev->revision, idx = id->driver_data; 533 u8 rev = dev->revision, idx = id->driver_data;
547 534
548 if (pci_dev_present(ati_rs100))
549 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n");
550
551 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */ 535 /* don't use LBA48 DMA on ALi devices before rev 0xC5 */
552 if (rev <= 0xC4) 536 if (rev <= 0xC4)
553 d.host_flags |= IDE_HFLAG_NO_LBA48_DMA; 537 d.host_flags |= IDE_HFLAG_NO_LBA48_DMA;
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 17669a434438..992b1cf8db69 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -119,6 +119,7 @@ static const struct ide_dma_ops cs5520_dma_ops = {
119 .dma_timeout = ide_dma_timeout, 119 .dma_timeout = ide_dma_timeout,
120}; 120};
121 121
122/* FIXME: VDMA is disabled because it caused system hangs */
122#define DECLARE_CS_DEV(name_str) \ 123#define DECLARE_CS_DEV(name_str) \
123 { \ 124 { \
124 .name = name_str, \ 125 .name = name_str, \
@@ -126,7 +127,6 @@ static const struct ide_dma_ops cs5520_dma_ops = {
126 .dma_ops = &cs5520_dma_ops, \ 127 .dma_ops = &cs5520_dma_ops, \
127 .host_flags = IDE_HFLAG_ISA_PORTS | \ 128 .host_flags = IDE_HFLAG_ISA_PORTS | \
128 IDE_HFLAG_CS5520 | \ 129 IDE_HFLAG_CS5520 | \
129 IDE_HFLAG_VDMA | \
130 IDE_HFLAG_NO_ATAPI_DMA | \ 130 IDE_HFLAG_NO_ATAPI_DMA | \
131 IDE_HFLAG_ABUSE_SET_DMA_MODE, \ 131 IDE_HFLAG_ABUSE_SET_DMA_MODE, \
132 .pio_mask = ATA_PIO4, \ 132 .pio_mask = ATA_PIO4, \
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index ed2ee4ba4b7c..3f441fc57c17 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -359,9 +359,10 @@ static void insert_recv_cqe(struct t3_wq *wq, struct t3_cq *cq)
359 cq->sw_wptr++; 359 cq->sw_wptr++;
360} 360}
361 361
362void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count) 362int cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count)
363{ 363{
364 u32 ptr; 364 u32 ptr;
365 int flushed = 0;
365 366
366 PDBG("%s wq %p cq %p\n", __func__, wq, cq); 367 PDBG("%s wq %p cq %p\n", __func__, wq, cq);
367 368
@@ -369,8 +370,11 @@ void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count)
369 PDBG("%s rq_rptr %u rq_wptr %u skip count %u\n", __func__, 370 PDBG("%s rq_rptr %u rq_wptr %u skip count %u\n", __func__,
370 wq->rq_rptr, wq->rq_wptr, count); 371 wq->rq_rptr, wq->rq_wptr, count);
371 ptr = wq->rq_rptr + count; 372 ptr = wq->rq_rptr + count;
372 while (ptr++ != wq->rq_wptr) 373 while (ptr++ != wq->rq_wptr) {
373 insert_recv_cqe(wq, cq); 374 insert_recv_cqe(wq, cq);
375 flushed++;
376 }
377 return flushed;
374} 378}
375 379
376static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq, 380static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq,
@@ -394,18 +398,21 @@ static void insert_sq_cqe(struct t3_wq *wq, struct t3_cq *cq,
394 cq->sw_wptr++; 398 cq->sw_wptr++;
395} 399}
396 400
397void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count) 401int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count)
398{ 402{
399 __u32 ptr; 403 __u32 ptr;
404 int flushed = 0;
400 struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2); 405 struct t3_swsq *sqp = wq->sq + Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2);
401 406
402 ptr = wq->sq_rptr + count; 407 ptr = wq->sq_rptr + count;
403 sqp += count; 408 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
404 while (ptr != wq->sq_wptr) { 409 while (ptr != wq->sq_wptr) {
405 insert_sq_cqe(wq, cq, sqp); 410 insert_sq_cqe(wq, cq, sqp);
406 sqp++;
407 ptr++; 411 ptr++;
412 sqp = wq->sq + Q_PTR2IDX(ptr, wq->sq_size_log2);
413 flushed++;
408 } 414 }
415 return flushed;
409} 416}
410 417
411/* 418/*
@@ -581,7 +588,7 @@ static int cxio_hal_destroy_ctrl_qp(struct cxio_rdev *rdev_p)
581 * caller aquires the ctrl_qp lock before the call 588 * caller aquires the ctrl_qp lock before the call
582 */ 589 */
583static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr, 590static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr,
584 u32 len, void *data, int completion) 591 u32 len, void *data)
585{ 592{
586 u32 i, nr_wqe, copy_len; 593 u32 i, nr_wqe, copy_len;
587 u8 *copy_data; 594 u8 *copy_data;
@@ -617,7 +624,7 @@ static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr,
617 flag = 0; 624 flag = 0;
618 if (i == (nr_wqe - 1)) { 625 if (i == (nr_wqe - 1)) {
619 /* last WQE */ 626 /* last WQE */
620 flag = completion ? T3_COMPLETION_FLAG : 0; 627 flag = T3_COMPLETION_FLAG;
621 if (len % 32) 628 if (len % 32)
622 utx_len = len / 32 + 1; 629 utx_len = len / 32 + 1;
623 else 630 else
@@ -676,21 +683,20 @@ static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr,
676 return 0; 683 return 0;
677} 684}
678 685
679/* IN: stag key, pdid, perm, zbva, to, len, page_size, pbl, and pbl_size 686/* IN: stag key, pdid, perm, zbva, to, len, page_size, pbl_size and pbl_addr
680 * OUT: stag index, actual pbl_size, pbl_addr allocated. 687 * OUT: stag index
681 * TBD: shared memory region support 688 * TBD: shared memory region support
682 */ 689 */
683static int __cxio_tpt_op(struct cxio_rdev *rdev_p, u32 reset_tpt_entry, 690static int __cxio_tpt_op(struct cxio_rdev *rdev_p, u32 reset_tpt_entry,
684 u32 *stag, u8 stag_state, u32 pdid, 691 u32 *stag, u8 stag_state, u32 pdid,
685 enum tpt_mem_type type, enum tpt_mem_perm perm, 692 enum tpt_mem_type type, enum tpt_mem_perm perm,
686 u32 zbva, u64 to, u32 len, u8 page_size, __be64 *pbl, 693 u32 zbva, u64 to, u32 len, u8 page_size,
687 u32 *pbl_size, u32 *pbl_addr) 694 u32 pbl_size, u32 pbl_addr)
688{ 695{
689 int err; 696 int err;
690 struct tpt_entry tpt; 697 struct tpt_entry tpt;
691 u32 stag_idx; 698 u32 stag_idx;
692 u32 wptr; 699 u32 wptr;
693 int rereg = (*stag != T3_STAG_UNSET);
694 700
695 stag_state = stag_state > 0; 701 stag_state = stag_state > 0;
696 stag_idx = (*stag) >> 8; 702 stag_idx = (*stag) >> 8;
@@ -704,30 +710,8 @@ static int __cxio_tpt_op(struct cxio_rdev *rdev_p, u32 reset_tpt_entry,
704 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n", 710 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
705 __func__, stag_state, type, pdid, stag_idx); 711 __func__, stag_state, type, pdid, stag_idx);
706 712
707 if (reset_tpt_entry)
708 cxio_hal_pblpool_free(rdev_p, *pbl_addr, *pbl_size << 3);
709 else if (!rereg) {
710 *pbl_addr = cxio_hal_pblpool_alloc(rdev_p, *pbl_size << 3);
711 if (!*pbl_addr) {
712 return -ENOMEM;
713 }
714 }
715
716 mutex_lock(&rdev_p->ctrl_qp.lock); 713 mutex_lock(&rdev_p->ctrl_qp.lock);
717 714
718 /* write PBL first if any - update pbl only if pbl list exist */
719 if (pbl) {
720
721 PDBG("%s *pdb_addr 0x%x, pbl_base 0x%x, pbl_size %d\n",
722 __func__, *pbl_addr, rdev_p->rnic_info.pbl_base,
723 *pbl_size);
724 err = cxio_hal_ctrl_qp_write_mem(rdev_p,
725 (*pbl_addr >> 5),
726 (*pbl_size << 3), pbl, 0);
727 if (err)
728 goto ret;
729 }
730
731 /* write TPT entry */ 715 /* write TPT entry */
732 if (reset_tpt_entry) 716 if (reset_tpt_entry)
733 memset(&tpt, 0, sizeof(tpt)); 717 memset(&tpt, 0, sizeof(tpt));
@@ -742,23 +726,23 @@ static int __cxio_tpt_op(struct cxio_rdev *rdev_p, u32 reset_tpt_entry,
742 V_TPT_ADDR_TYPE((zbva ? TPT_ZBTO : TPT_VATO)) | 726 V_TPT_ADDR_TYPE((zbva ? TPT_ZBTO : TPT_VATO)) |
743 V_TPT_PAGE_SIZE(page_size)); 727 V_TPT_PAGE_SIZE(page_size));
744 tpt.rsvd_pbl_addr = reset_tpt_entry ? 0 : 728 tpt.rsvd_pbl_addr = reset_tpt_entry ? 0 :
745 cpu_to_be32(V_TPT_PBL_ADDR(PBL_OFF(rdev_p, *pbl_addr)>>3)); 729 cpu_to_be32(V_TPT_PBL_ADDR(PBL_OFF(rdev_p, pbl_addr)>>3));
746 tpt.len = cpu_to_be32(len); 730 tpt.len = cpu_to_be32(len);
747 tpt.va_hi = cpu_to_be32((u32) (to >> 32)); 731 tpt.va_hi = cpu_to_be32((u32) (to >> 32));
748 tpt.va_low_or_fbo = cpu_to_be32((u32) (to & 0xFFFFFFFFULL)); 732 tpt.va_low_or_fbo = cpu_to_be32((u32) (to & 0xFFFFFFFFULL));
749 tpt.rsvd_bind_cnt_or_pstag = 0; 733 tpt.rsvd_bind_cnt_or_pstag = 0;
750 tpt.rsvd_pbl_size = reset_tpt_entry ? 0 : 734 tpt.rsvd_pbl_size = reset_tpt_entry ? 0 :
751 cpu_to_be32(V_TPT_PBL_SIZE((*pbl_size) >> 2)); 735 cpu_to_be32(V_TPT_PBL_SIZE(pbl_size >> 2));
752 } 736 }
753 err = cxio_hal_ctrl_qp_write_mem(rdev_p, 737 err = cxio_hal_ctrl_qp_write_mem(rdev_p,
754 stag_idx + 738 stag_idx +
755 (rdev_p->rnic_info.tpt_base >> 5), 739 (rdev_p->rnic_info.tpt_base >> 5),
756 sizeof(tpt), &tpt, 1); 740 sizeof(tpt), &tpt);
757 741
758 /* release the stag index to free pool */ 742 /* release the stag index to free pool */
759 if (reset_tpt_entry) 743 if (reset_tpt_entry)
760 cxio_hal_put_stag(rdev_p->rscp, stag_idx); 744 cxio_hal_put_stag(rdev_p->rscp, stag_idx);
761ret: 745
762 wptr = rdev_p->ctrl_qp.wptr; 746 wptr = rdev_p->ctrl_qp.wptr;
763 mutex_unlock(&rdev_p->ctrl_qp.lock); 747 mutex_unlock(&rdev_p->ctrl_qp.lock);
764 if (!err) 748 if (!err)
@@ -769,44 +753,67 @@ ret:
769 return err; 753 return err;
770} 754}
771 755
756int cxio_write_pbl(struct cxio_rdev *rdev_p, __be64 *pbl,
757 u32 pbl_addr, u32 pbl_size)
758{
759 u32 wptr;
760 int err;
761
762 PDBG("%s *pdb_addr 0x%x, pbl_base 0x%x, pbl_size %d\n",
763 __func__, pbl_addr, rdev_p->rnic_info.pbl_base,
764 pbl_size);
765
766 mutex_lock(&rdev_p->ctrl_qp.lock);
767 err = cxio_hal_ctrl_qp_write_mem(rdev_p, pbl_addr >> 5, pbl_size << 3,
768 pbl);
769 wptr = rdev_p->ctrl_qp.wptr;
770 mutex_unlock(&rdev_p->ctrl_qp.lock);
771 if (err)
772 return err;
773
774 if (wait_event_interruptible(rdev_p->ctrl_qp.waitq,
775 SEQ32_GE(rdev_p->ctrl_qp.rptr,
776 wptr)))
777 return -ERESTARTSYS;
778
779 return 0;
780}
781
772int cxio_register_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, 782int cxio_register_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid,
773 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, 783 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,
774 u8 page_size, __be64 *pbl, u32 *pbl_size, 784 u8 page_size, u32 pbl_size, u32 pbl_addr)
775 u32 *pbl_addr)
776{ 785{
777 *stag = T3_STAG_UNSET; 786 *stag = T3_STAG_UNSET;
778 return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm, 787 return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm,
779 zbva, to, len, page_size, pbl, pbl_size, pbl_addr); 788 zbva, to, len, page_size, pbl_size, pbl_addr);
780} 789}
781 790
782int cxio_reregister_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, 791int cxio_reregister_phys_mem(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid,
783 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, 792 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,
784 u8 page_size, __be64 *pbl, u32 *pbl_size, 793 u8 page_size, u32 pbl_size, u32 pbl_addr)
785 u32 *pbl_addr)
786{ 794{
787 return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm, 795 return __cxio_tpt_op(rdev_p, 0, stag, 1, pdid, TPT_NON_SHARED_MR, perm,
788 zbva, to, len, page_size, pbl, pbl_size, pbl_addr); 796 zbva, to, len, page_size, pbl_size, pbl_addr);
789} 797}
790 798
791int cxio_dereg_mem(struct cxio_rdev *rdev_p, u32 stag, u32 pbl_size, 799int cxio_dereg_mem(struct cxio_rdev *rdev_p, u32 stag, u32 pbl_size,
792 u32 pbl_addr) 800 u32 pbl_addr)
793{ 801{
794 return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0, NULL, 802 return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0,
795 &pbl_size, &pbl_addr); 803 pbl_size, pbl_addr);
796} 804}
797 805
798int cxio_allocate_window(struct cxio_rdev *rdev_p, u32 * stag, u32 pdid) 806int cxio_allocate_window(struct cxio_rdev *rdev_p, u32 * stag, u32 pdid)
799{ 807{
800 u32 pbl_size = 0;
801 *stag = T3_STAG_UNSET; 808 *stag = T3_STAG_UNSET;
802 return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_MW, 0, 0, 0ULL, 0, 0, 809 return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_MW, 0, 0, 0ULL, 0, 0,
803 NULL, &pbl_size, NULL); 810 0, 0);
804} 811}
805 812
806int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag) 813int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag)
807{ 814{
808 return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0, NULL, 815 return __cxio_tpt_op(rdev_p, 1, &stag, 0, 0, 0, 0, 0, 0ULL, 0, 0,
809 NULL, NULL); 816 0, 0);
810} 817}
811 818
812int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) 819int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr)
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h
index 2bcff7f5046e..6e128f6bab05 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h
@@ -154,14 +154,14 @@ int cxio_create_qp(struct cxio_rdev *rdev, u32 kernel_domain, struct t3_wq *wq,
154int cxio_destroy_qp(struct cxio_rdev *rdev, struct t3_wq *wq, 154int cxio_destroy_qp(struct cxio_rdev *rdev, struct t3_wq *wq,
155 struct cxio_ucontext *uctx); 155 struct cxio_ucontext *uctx);
156int cxio_peek_cq(struct t3_wq *wr, struct t3_cq *cq, int opcode); 156int cxio_peek_cq(struct t3_wq *wr, struct t3_cq *cq, int opcode);
157int cxio_write_pbl(struct cxio_rdev *rdev_p, __be64 *pbl,
158 u32 pbl_addr, u32 pbl_size);
157int cxio_register_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid, 159int cxio_register_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,
158 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, 160 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,
159 u8 page_size, __be64 *pbl, u32 *pbl_size, 161 u8 page_size, u32 pbl_size, u32 pbl_addr);
160 u32 *pbl_addr);
161int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid, 162int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,
162 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len, 163 enum tpt_mem_perm perm, u32 zbva, u64 to, u32 len,
163 u8 page_size, __be64 *pbl, u32 *pbl_size, 164 u8 page_size, u32 pbl_size, u32 pbl_addr);
164 u32 *pbl_addr);
165int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, 165int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size,
166 u32 pbl_addr); 166 u32 pbl_addr);
167int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); 167int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid);
@@ -173,8 +173,8 @@ u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp);
173void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid); 173void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid);
174int __init cxio_hal_init(void); 174int __init cxio_hal_init(void);
175void __exit cxio_hal_exit(void); 175void __exit cxio_hal_exit(void);
176void cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count); 176int cxio_flush_rq(struct t3_wq *wq, struct t3_cq *cq, int count);
177void cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count); 177int cxio_flush_sq(struct t3_wq *wq, struct t3_cq *cq, int count);
178void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count); 178void cxio_count_rcqes(struct t3_cq *cq, struct t3_wq *wq, int *count);
179void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count); 179void cxio_count_scqes(struct t3_cq *cq, struct t3_wq *wq, int *count);
180void cxio_flush_hw_cq(struct t3_cq *cq); 180void cxio_flush_hw_cq(struct t3_cq *cq);
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c
index 45ed4f25ef78..bd233c087653 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_resource.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c
@@ -250,7 +250,6 @@ void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp)
250 */ 250 */
251 251
252#define MIN_PBL_SHIFT 8 /* 256B == min PBL size (32 entries) */ 252#define MIN_PBL_SHIFT 8 /* 256B == min PBL size (32 entries) */
253#define PBL_CHUNK 2*1024*1024
254 253
255u32 cxio_hal_pblpool_alloc(struct cxio_rdev *rdev_p, int size) 254u32 cxio_hal_pblpool_alloc(struct cxio_rdev *rdev_p, int size)
256{ 255{
@@ -267,14 +266,35 @@ void cxio_hal_pblpool_free(struct cxio_rdev *rdev_p, u32 addr, int size)
267 266
268int cxio_hal_pblpool_create(struct cxio_rdev *rdev_p) 267int cxio_hal_pblpool_create(struct cxio_rdev *rdev_p)
269{ 268{
270 unsigned long i; 269 unsigned pbl_start, pbl_chunk;
270
271 rdev_p->pbl_pool = gen_pool_create(MIN_PBL_SHIFT, -1); 271 rdev_p->pbl_pool = gen_pool_create(MIN_PBL_SHIFT, -1);
272 if (rdev_p->pbl_pool) 272 if (!rdev_p->pbl_pool)
273 for (i = rdev_p->rnic_info.pbl_base; 273 return -ENOMEM;
274 i <= rdev_p->rnic_info.pbl_top - PBL_CHUNK + 1; 274
275 i += PBL_CHUNK) 275 pbl_start = rdev_p->rnic_info.pbl_base;
276 gen_pool_add(rdev_p->pbl_pool, i, PBL_CHUNK, -1); 276 pbl_chunk = rdev_p->rnic_info.pbl_top - pbl_start + 1;
277 return rdev_p->pbl_pool ? 0 : -ENOMEM; 277
278 while (pbl_start < rdev_p->rnic_info.pbl_top) {
279 pbl_chunk = min(rdev_p->rnic_info.pbl_top - pbl_start + 1,
280 pbl_chunk);
281 if (gen_pool_add(rdev_p->pbl_pool, pbl_start, pbl_chunk, -1)) {
282 PDBG("%s failed to add PBL chunk (%x/%x)\n",
283 __func__, pbl_start, pbl_chunk);
284 if (pbl_chunk <= 1024 << MIN_PBL_SHIFT) {
285 printk(KERN_WARNING MOD "%s: Failed to add all PBL chunks (%x/%x)\n",
286 __func__, pbl_start, rdev_p->rnic_info.pbl_top - pbl_start);
287 return 0;
288 }
289 pbl_chunk >>= 1;
290 } else {
291 PDBG("%s added PBL chunk (%x/%x)\n",
292 __func__, pbl_start, pbl_chunk);
293 pbl_start += pbl_chunk;
294 }
295 }
296
297 return 0;
278} 298}
279 299
280void cxio_hal_pblpool_destroy(struct cxio_rdev *rdev_p) 300void cxio_hal_pblpool_destroy(struct cxio_rdev *rdev_p)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index d44a6df9ad8c..c325c44807e8 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -67,10 +67,10 @@ int peer2peer = 0;
67module_param(peer2peer, int, 0644); 67module_param(peer2peer, int, 0644);
68MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)"); 68MODULE_PARM_DESC(peer2peer, "Support peer2peer ULPs (default=0)");
69 69
70static int ep_timeout_secs = 10; 70static int ep_timeout_secs = 60;
71module_param(ep_timeout_secs, int, 0644); 71module_param(ep_timeout_secs, int, 0644);
72MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout " 72MODULE_PARM_DESC(ep_timeout_secs, "CM Endpoint operation timeout "
73 "in seconds (default=10)"); 73 "in seconds (default=60)");
74 74
75static int mpa_rev = 1; 75static int mpa_rev = 1;
76module_param(mpa_rev, int, 0644); 76module_param(mpa_rev, int, 0644);
@@ -1650,8 +1650,8 @@ static int close_con_rpl(struct t3cdev *tdev, struct sk_buff *skb, void *ctx)
1650 release = 1; 1650 release = 1;
1651 break; 1651 break;
1652 case ABORTING: 1652 case ABORTING:
1653 break;
1654 case DEAD: 1653 case DEAD:
1654 break;
1655 default: 1655 default:
1656 BUG_ON(1); 1656 BUG_ON(1);
1657 break; 1657 break;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_mem.c b/drivers/infiniband/hw/cxgb3/iwch_mem.c
index 58c3d61bcd14..ec49a5cbdebb 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_mem.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_mem.c
@@ -35,17 +35,26 @@
35#include <rdma/ib_verbs.h> 35#include <rdma/ib_verbs.h>
36 36
37#include "cxio_hal.h" 37#include "cxio_hal.h"
38#include "cxio_resource.h"
38#include "iwch.h" 39#include "iwch.h"
39#include "iwch_provider.h" 40#include "iwch_provider.h"
40 41
41int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, 42static void iwch_finish_mem_reg(struct iwch_mr *mhp, u32 stag)
42 struct iwch_mr *mhp,
43 int shift,
44 __be64 *page_list)
45{ 43{
46 u32 stag;
47 u32 mmid; 44 u32 mmid;
48 45
46 mhp->attr.state = 1;
47 mhp->attr.stag = stag;
48 mmid = stag >> 8;
49 mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
50 insert_handle(mhp->rhp, &mhp->rhp->mmidr, mhp, mmid);
51 PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp);
52}
53
54int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
55 struct iwch_mr *mhp, int shift)
56{
57 u32 stag;
49 58
50 if (cxio_register_phys_mem(&rhp->rdev, 59 if (cxio_register_phys_mem(&rhp->rdev,
51 &stag, mhp->attr.pdid, 60 &stag, mhp->attr.pdid,
@@ -53,28 +62,21 @@ int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
53 mhp->attr.zbva, 62 mhp->attr.zbva,
54 mhp->attr.va_fbo, 63 mhp->attr.va_fbo,
55 mhp->attr.len, 64 mhp->attr.len,
56 shift-12, 65 shift - 12,
57 page_list, 66 mhp->attr.pbl_size, mhp->attr.pbl_addr))
58 &mhp->attr.pbl_size, &mhp->attr.pbl_addr))
59 return -ENOMEM; 67 return -ENOMEM;
60 mhp->attr.state = 1; 68
61 mhp->attr.stag = stag; 69 iwch_finish_mem_reg(mhp, stag);
62 mmid = stag >> 8; 70
63 mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
64 insert_handle(rhp, &rhp->mmidr, mhp, mmid);
65 PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp);
66 return 0; 71 return 0;
67} 72}
68 73
69int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, 74int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
70 struct iwch_mr *mhp, 75 struct iwch_mr *mhp,
71 int shift, 76 int shift,
72 __be64 *page_list,
73 int npages) 77 int npages)
74{ 78{
75 u32 stag; 79 u32 stag;
76 u32 mmid;
77
78 80
79 /* We could support this... */ 81 /* We could support this... */
80 if (npages > mhp->attr.pbl_size) 82 if (npages > mhp->attr.pbl_size)
@@ -87,19 +89,40 @@ int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
87 mhp->attr.zbva, 89 mhp->attr.zbva,
88 mhp->attr.va_fbo, 90 mhp->attr.va_fbo,
89 mhp->attr.len, 91 mhp->attr.len,
90 shift-12, 92 shift - 12,
91 page_list, 93 mhp->attr.pbl_size, mhp->attr.pbl_addr))
92 &mhp->attr.pbl_size, &mhp->attr.pbl_addr))
93 return -ENOMEM; 94 return -ENOMEM;
94 mhp->attr.state = 1; 95
95 mhp->attr.stag = stag; 96 iwch_finish_mem_reg(mhp, stag);
96 mmid = stag >> 8; 97
97 mhp->ibmr.rkey = mhp->ibmr.lkey = stag; 98 return 0;
98 insert_handle(rhp, &rhp->mmidr, mhp, mmid); 99}
99 PDBG("%s mmid 0x%x mhp %p\n", __func__, mmid, mhp); 100
101int iwch_alloc_pbl(struct iwch_mr *mhp, int npages)
102{
103 mhp->attr.pbl_addr = cxio_hal_pblpool_alloc(&mhp->rhp->rdev,
104 npages << 3);
105
106 if (!mhp->attr.pbl_addr)
107 return -ENOMEM;
108
109 mhp->attr.pbl_size = npages;
110
100 return 0; 111 return 0;
101} 112}
102 113
114void iwch_free_pbl(struct iwch_mr *mhp)
115{
116 cxio_hal_pblpool_free(&mhp->rhp->rdev, mhp->attr.pbl_addr,
117 mhp->attr.pbl_size << 3);
118}
119
120int iwch_write_pbl(struct iwch_mr *mhp, __be64 *pages, int npages, int offset)
121{
122 return cxio_write_pbl(&mhp->rhp->rdev, pages,
123 mhp->attr.pbl_addr + (offset << 3), npages);
124}
125
103int build_phys_page_list(struct ib_phys_buf *buffer_list, 126int build_phys_page_list(struct ib_phys_buf *buffer_list,
104 int num_phys_buf, 127 int num_phys_buf,
105 u64 *iova_start, 128 u64 *iova_start,
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index d07d3a377b5f..8934178a23ee 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -442,6 +442,7 @@ static int iwch_dereg_mr(struct ib_mr *ib_mr)
442 mmid = mhp->attr.stag >> 8; 442 mmid = mhp->attr.stag >> 8;
443 cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size, 443 cxio_dereg_mem(&rhp->rdev, mhp->attr.stag, mhp->attr.pbl_size,
444 mhp->attr.pbl_addr); 444 mhp->attr.pbl_addr);
445 iwch_free_pbl(mhp);
445 remove_handle(rhp, &rhp->mmidr, mmid); 446 remove_handle(rhp, &rhp->mmidr, mmid);
446 if (mhp->kva) 447 if (mhp->kva)
447 kfree((void *) (unsigned long) mhp->kva); 448 kfree((void *) (unsigned long) mhp->kva);
@@ -475,6 +476,8 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
475 if (!mhp) 476 if (!mhp)
476 return ERR_PTR(-ENOMEM); 477 return ERR_PTR(-ENOMEM);
477 478
479 mhp->rhp = rhp;
480
478 /* First check that we have enough alignment */ 481 /* First check that we have enough alignment */
479 if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) { 482 if ((*iova_start & ~PAGE_MASK) != (buffer_list[0].addr & ~PAGE_MASK)) {
480 ret = -EINVAL; 483 ret = -EINVAL;
@@ -492,7 +495,17 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
492 if (ret) 495 if (ret)
493 goto err; 496 goto err;
494 497
495 mhp->rhp = rhp; 498 ret = iwch_alloc_pbl(mhp, npages);
499 if (ret) {
500 kfree(page_list);
501 goto err_pbl;
502 }
503
504 ret = iwch_write_pbl(mhp, page_list, npages, 0);
505 kfree(page_list);
506 if (ret)
507 goto err_pbl;
508
496 mhp->attr.pdid = php->pdid; 509 mhp->attr.pdid = php->pdid;
497 mhp->attr.zbva = 0; 510 mhp->attr.zbva = 0;
498 511
@@ -502,12 +515,15 @@ static struct ib_mr *iwch_register_phys_mem(struct ib_pd *pd,
502 515
503 mhp->attr.len = (u32) total_size; 516 mhp->attr.len = (u32) total_size;
504 mhp->attr.pbl_size = npages; 517 mhp->attr.pbl_size = npages;
505 ret = iwch_register_mem(rhp, php, mhp, shift, page_list); 518 ret = iwch_register_mem(rhp, php, mhp, shift);
506 kfree(page_list); 519 if (ret)
507 if (ret) { 520 goto err_pbl;
508 goto err; 521
509 }
510 return &mhp->ibmr; 522 return &mhp->ibmr;
523
524err_pbl:
525 iwch_free_pbl(mhp);
526
511err: 527err:
512 kfree(mhp); 528 kfree(mhp);
513 return ERR_PTR(ret); 529 return ERR_PTR(ret);
@@ -560,7 +576,7 @@ static int iwch_reregister_phys_mem(struct ib_mr *mr,
560 return ret; 576 return ret;
561 } 577 }
562 578
563 ret = iwch_reregister_mem(rhp, php, &mh, shift, page_list, npages); 579 ret = iwch_reregister_mem(rhp, php, &mh, shift, npages);
564 kfree(page_list); 580 kfree(page_list);
565 if (ret) { 581 if (ret) {
566 return ret; 582 return ret;
@@ -602,6 +618,8 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
602 if (!mhp) 618 if (!mhp)
603 return ERR_PTR(-ENOMEM); 619 return ERR_PTR(-ENOMEM);
604 620
621 mhp->rhp = rhp;
622
605 mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0); 623 mhp->umem = ib_umem_get(pd->uobject->context, start, length, acc, 0);
606 if (IS_ERR(mhp->umem)) { 624 if (IS_ERR(mhp->umem)) {
607 err = PTR_ERR(mhp->umem); 625 err = PTR_ERR(mhp->umem);
@@ -615,10 +633,14 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
615 list_for_each_entry(chunk, &mhp->umem->chunk_list, list) 633 list_for_each_entry(chunk, &mhp->umem->chunk_list, list)
616 n += chunk->nents; 634 n += chunk->nents;
617 635
618 pages = kmalloc(n * sizeof(u64), GFP_KERNEL); 636 err = iwch_alloc_pbl(mhp, n);
637 if (err)
638 goto err;
639
640 pages = (__be64 *) __get_free_page(GFP_KERNEL);
619 if (!pages) { 641 if (!pages) {
620 err = -ENOMEM; 642 err = -ENOMEM;
621 goto err; 643 goto err_pbl;
622 } 644 }
623 645
624 i = n = 0; 646 i = n = 0;
@@ -630,25 +652,38 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
630 pages[i++] = cpu_to_be64(sg_dma_address( 652 pages[i++] = cpu_to_be64(sg_dma_address(
631 &chunk->page_list[j]) + 653 &chunk->page_list[j]) +
632 mhp->umem->page_size * k); 654 mhp->umem->page_size * k);
655 if (i == PAGE_SIZE / sizeof *pages) {
656 err = iwch_write_pbl(mhp, pages, i, n);
657 if (err)
658 goto pbl_done;
659 n += i;
660 i = 0;
661 }
633 } 662 }
634 } 663 }
635 664
636 mhp->rhp = rhp; 665 if (i)
666 err = iwch_write_pbl(mhp, pages, i, n);
667
668pbl_done:
669 free_page((unsigned long) pages);
670 if (err)
671 goto err_pbl;
672
637 mhp->attr.pdid = php->pdid; 673 mhp->attr.pdid = php->pdid;
638 mhp->attr.zbva = 0; 674 mhp->attr.zbva = 0;
639 mhp->attr.perms = iwch_ib_to_tpt_access(acc); 675 mhp->attr.perms = iwch_ib_to_tpt_access(acc);
640 mhp->attr.va_fbo = virt; 676 mhp->attr.va_fbo = virt;
641 mhp->attr.page_size = shift - 12; 677 mhp->attr.page_size = shift - 12;
642 mhp->attr.len = (u32) length; 678 mhp->attr.len = (u32) length;
643 mhp->attr.pbl_size = i; 679
644 err = iwch_register_mem(rhp, php, mhp, shift, pages); 680 err = iwch_register_mem(rhp, php, mhp, shift);
645 kfree(pages);
646 if (err) 681 if (err)
647 goto err; 682 goto err_pbl;
648 683
649 if (udata && !t3a_device(rhp)) { 684 if (udata && !t3a_device(rhp)) {
650 uresp.pbl_addr = (mhp->attr.pbl_addr - 685 uresp.pbl_addr = (mhp->attr.pbl_addr -
651 rhp->rdev.rnic_info.pbl_base) >> 3; 686 rhp->rdev.rnic_info.pbl_base) >> 3;
652 PDBG("%s user resp pbl_addr 0x%x\n", __func__, 687 PDBG("%s user resp pbl_addr 0x%x\n", __func__,
653 uresp.pbl_addr); 688 uresp.pbl_addr);
654 689
@@ -661,6 +696,9 @@ static struct ib_mr *iwch_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
661 696
662 return &mhp->ibmr; 697 return &mhp->ibmr;
663 698
699err_pbl:
700 iwch_free_pbl(mhp);
701
664err: 702err:
665 ib_umem_release(mhp->umem); 703 ib_umem_release(mhp->umem);
666 kfree(mhp); 704 kfree(mhp);
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index db5100d27ca2..836163fc5429 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -340,14 +340,14 @@ int iwch_quiesce_qps(struct iwch_cq *chp);
340int iwch_resume_qps(struct iwch_cq *chp); 340int iwch_resume_qps(struct iwch_cq *chp);
341void stop_read_rep_timer(struct iwch_qp *qhp); 341void stop_read_rep_timer(struct iwch_qp *qhp);
342int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php, 342int iwch_register_mem(struct iwch_dev *rhp, struct iwch_pd *php,
343 struct iwch_mr *mhp, 343 struct iwch_mr *mhp, int shift);
344 int shift,
345 __be64 *page_list);
346int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php, 344int iwch_reregister_mem(struct iwch_dev *rhp, struct iwch_pd *php,
347 struct iwch_mr *mhp, 345 struct iwch_mr *mhp,
348 int shift, 346 int shift,
349 __be64 *page_list,
350 int npages); 347 int npages);
348int iwch_alloc_pbl(struct iwch_mr *mhp, int npages);
349void iwch_free_pbl(struct iwch_mr *mhp);
350int iwch_write_pbl(struct iwch_mr *mhp, __be64 *pages, int npages, int offset);
351int build_phys_page_list(struct ib_phys_buf *buffer_list, 351int build_phys_page_list(struct ib_phys_buf *buffer_list,
352 int num_phys_buf, 352 int num_phys_buf,
353 u64 *iova_start, 353 u64 *iova_start,
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index 9b4be889c58e..79dbe5beae52 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -655,6 +655,7 @@ static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag)
655{ 655{
656 struct iwch_cq *rchp, *schp; 656 struct iwch_cq *rchp, *schp;
657 int count; 657 int count;
658 int flushed;
658 659
659 rchp = get_chp(qhp->rhp, qhp->attr.rcq); 660 rchp = get_chp(qhp->rhp, qhp->attr.rcq);
660 schp = get_chp(qhp->rhp, qhp->attr.scq); 661 schp = get_chp(qhp->rhp, qhp->attr.scq);
@@ -669,20 +670,22 @@ static void __flush_qp(struct iwch_qp *qhp, unsigned long *flag)
669 spin_lock(&qhp->lock); 670 spin_lock(&qhp->lock);
670 cxio_flush_hw_cq(&rchp->cq); 671 cxio_flush_hw_cq(&rchp->cq);
671 cxio_count_rcqes(&rchp->cq, &qhp->wq, &count); 672 cxio_count_rcqes(&rchp->cq, &qhp->wq, &count);
672 cxio_flush_rq(&qhp->wq, &rchp->cq, count); 673 flushed = cxio_flush_rq(&qhp->wq, &rchp->cq, count);
673 spin_unlock(&qhp->lock); 674 spin_unlock(&qhp->lock);
674 spin_unlock_irqrestore(&rchp->lock, *flag); 675 spin_unlock_irqrestore(&rchp->lock, *flag);
675 (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context); 676 if (flushed)
677 (*rchp->ibcq.comp_handler)(&rchp->ibcq, rchp->ibcq.cq_context);
676 678
677 /* locking heirarchy: cq lock first, then qp lock. */ 679 /* locking heirarchy: cq lock first, then qp lock. */
678 spin_lock_irqsave(&schp->lock, *flag); 680 spin_lock_irqsave(&schp->lock, *flag);
679 spin_lock(&qhp->lock); 681 spin_lock(&qhp->lock);
680 cxio_flush_hw_cq(&schp->cq); 682 cxio_flush_hw_cq(&schp->cq);
681 cxio_count_scqes(&schp->cq, &qhp->wq, &count); 683 cxio_count_scqes(&schp->cq, &qhp->wq, &count);
682 cxio_flush_sq(&qhp->wq, &schp->cq, count); 684 flushed = cxio_flush_sq(&qhp->wq, &schp->cq, count);
683 spin_unlock(&qhp->lock); 685 spin_unlock(&qhp->lock);
684 spin_unlock_irqrestore(&schp->lock, *flag); 686 spin_unlock_irqrestore(&schp->lock, *flag);
685 (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context); 687 if (flushed)
688 (*schp->ibcq.comp_handler)(&schp->ibcq, schp->ibcq.cq_context);
686 689
687 /* deref */ 690 /* deref */
688 if (atomic_dec_and_test(&qhp->refcnt)) 691 if (atomic_dec_and_test(&qhp->refcnt))
@@ -880,7 +883,6 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp,
880 ep = qhp->ep; 883 ep = qhp->ep;
881 get_ep(&ep->com); 884 get_ep(&ep->com);
882 } 885 }
883 flush_qp(qhp, &flag);
884 break; 886 break;
885 case IWCH_QP_STATE_TERMINATE: 887 case IWCH_QP_STATE_TERMINATE:
886 qhp->attr.state = IWCH_QP_STATE_TERMINATE; 888 qhp->attr.state = IWCH_QP_STATE_TERMINATE;
@@ -911,6 +913,7 @@ int iwch_modify_qp(struct iwch_dev *rhp, struct iwch_qp *qhp,
911 } 913 }
912 switch (attrs->next_state) { 914 switch (attrs->next_state) {
913 case IWCH_QP_STATE_IDLE: 915 case IWCH_QP_STATE_IDLE:
916 flush_qp(qhp, &flag);
914 qhp->attr.state = IWCH_QP_STATE_IDLE; 917 qhp->attr.state = IWCH_QP_STATE_IDLE;
915 qhp->attr.llp_stream_handle = NULL; 918 qhp->attr.llp_stream_handle = NULL;
916 put_ep(&qhp->ep->com); 919 put_ep(&qhp->ep->com);
diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
index 00bab60f6de4..1e9e99a13933 100644
--- a/drivers/infiniband/hw/ehca/ehca_classes.h
+++ b/drivers/infiniband/hw/ehca/ehca_classes.h
@@ -192,6 +192,8 @@ struct ehca_qp {
192 int mtu_shift; 192 int mtu_shift;
193 u32 message_count; 193 u32 message_count;
194 u32 packet_count; 194 u32 packet_count;
195 atomic_t nr_events; /* events seen */
196 wait_queue_head_t wait_completion;
195}; 197};
196 198
197#define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ) 199#define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ)
diff --git a/drivers/infiniband/hw/ehca/ehca_hca.c b/drivers/infiniband/hw/ehca/ehca_hca.c
index 2515cbde7e65..bc3b37d2070f 100644
--- a/drivers/infiniband/hw/ehca/ehca_hca.c
+++ b/drivers/infiniband/hw/ehca/ehca_hca.c
@@ -101,7 +101,6 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
101 props->max_ee = limit_uint(rblock->max_rd_ee_context); 101 props->max_ee = limit_uint(rblock->max_rd_ee_context);
102 props->max_rdd = limit_uint(rblock->max_rd_domain); 102 props->max_rdd = limit_uint(rblock->max_rd_domain);
103 props->max_fmr = limit_uint(rblock->max_mr); 103 props->max_fmr = limit_uint(rblock->max_mr);
104 props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay);
105 props->max_qp_rd_atom = limit_uint(rblock->max_rr_qp); 104 props->max_qp_rd_atom = limit_uint(rblock->max_rr_qp);
106 props->max_ee_rd_atom = limit_uint(rblock->max_rr_ee_context); 105 props->max_ee_rd_atom = limit_uint(rblock->max_rr_ee_context);
107 props->max_res_rd_atom = limit_uint(rblock->max_rr_hca); 106 props->max_res_rd_atom = limit_uint(rblock->max_rr_hca);
@@ -115,7 +114,7 @@ int ehca_query_device(struct ib_device *ibdev, struct ib_device_attr *props)
115 } 114 }
116 115
117 props->max_pkeys = 16; 116 props->max_pkeys = 16;
118 props->local_ca_ack_delay = limit_uint(rblock->local_ca_ack_delay); 117 props->local_ca_ack_delay = min_t(u8, rblock->local_ca_ack_delay, 255);
119 props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp); 118 props->max_raw_ipv6_qp = limit_uint(rblock->max_raw_ipv6_qp);
120 props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp); 119 props->max_raw_ethy_qp = limit_uint(rblock->max_raw_ethy_qp);
121 props->max_mcast_grp = limit_uint(rblock->max_mcast_grp); 120 props->max_mcast_grp = limit_uint(rblock->max_mcast_grp);
@@ -136,7 +135,7 @@ query_device1:
136 return ret; 135 return ret;
137} 136}
138 137
139static int map_mtu(struct ehca_shca *shca, u32 fw_mtu) 138static enum ib_mtu map_mtu(struct ehca_shca *shca, u32 fw_mtu)
140{ 139{
141 switch (fw_mtu) { 140 switch (fw_mtu) {
142 case 0x1: 141 case 0x1:
@@ -156,7 +155,7 @@ static int map_mtu(struct ehca_shca *shca, u32 fw_mtu)
156 } 155 }
157} 156}
158 157
159static int map_number_of_vls(struct ehca_shca *shca, u32 vl_cap) 158static u8 map_number_of_vls(struct ehca_shca *shca, u32 vl_cap)
160{ 159{
161 switch (vl_cap) { 160 switch (vl_cap) {
162 case 0x1: 161 case 0x1:
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index ca5eb0cb628c..ce1ab0571be3 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -204,6 +204,8 @@ static void qp_event_callback(struct ehca_shca *shca, u64 eqe,
204 204
205 read_lock(&ehca_qp_idr_lock); 205 read_lock(&ehca_qp_idr_lock);
206 qp = idr_find(&ehca_qp_idr, token); 206 qp = idr_find(&ehca_qp_idr, token);
207 if (qp)
208 atomic_inc(&qp->nr_events);
207 read_unlock(&ehca_qp_idr_lock); 209 read_unlock(&ehca_qp_idr_lock);
208 210
209 if (!qp) 211 if (!qp)
@@ -223,6 +225,8 @@ static void qp_event_callback(struct ehca_shca *shca, u64 eqe,
223 if (fatal && qp->ext_type == EQPT_SRQBASE) 225 if (fatal && qp->ext_type == EQPT_SRQBASE)
224 dispatch_qp_event(shca, qp, IB_EVENT_QP_LAST_WQE_REACHED); 226 dispatch_qp_event(shca, qp, IB_EVENT_QP_LAST_WQE_REACHED);
225 227
228 if (atomic_dec_and_test(&qp->nr_events))
229 wake_up(&qp->wait_completion);
226 return; 230 return;
227} 231}
228 232
diff --git a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
index 18fba92fa7ae..3f59587338ea 100644
--- a/drivers/infiniband/hw/ehca/ehca_qp.c
+++ b/drivers/infiniband/hw/ehca/ehca_qp.c
@@ -566,6 +566,8 @@ static struct ehca_qp *internal_create_qp(
566 return ERR_PTR(-ENOMEM); 566 return ERR_PTR(-ENOMEM);
567 } 567 }
568 568
569 atomic_set(&my_qp->nr_events, 0);
570 init_waitqueue_head(&my_qp->wait_completion);
569 spin_lock_init(&my_qp->spinlock_s); 571 spin_lock_init(&my_qp->spinlock_s);
570 spin_lock_init(&my_qp->spinlock_r); 572 spin_lock_init(&my_qp->spinlock_r);
571 my_qp->qp_type = qp_type; 573 my_qp->qp_type = qp_type;
@@ -1934,6 +1936,9 @@ static int internal_destroy_qp(struct ib_device *dev, struct ehca_qp *my_qp,
1934 idr_remove(&ehca_qp_idr, my_qp->token); 1936 idr_remove(&ehca_qp_idr, my_qp->token);
1935 write_unlock_irqrestore(&ehca_qp_idr_lock, flags); 1937 write_unlock_irqrestore(&ehca_qp_idr_lock, flags);
1936 1938
1939 /* now wait until all pending events have completed */
1940 wait_event(my_qp->wait_completion, !atomic_read(&my_qp->nr_events));
1941
1937 h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp); 1942 h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp);
1938 if (h_ret != H_SUCCESS) { 1943 if (h_ret != H_SUCCESS) {
1939 ehca_err(dev, "hipz_h_destroy_qp() failed h_ret=%li " 1944 ehca_err(dev, "hipz_h_destroy_qp() failed h_ret=%li "
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c
index acf30c06a0c0..daad09a45910 100644
--- a/drivers/infiniband/hw/ipath/ipath_driver.c
+++ b/drivers/infiniband/hw/ipath/ipath_driver.c
@@ -1197,7 +1197,7 @@ void ipath_kreceive(struct ipath_portdata *pd)
1197 } 1197 }
1198 1198
1199reloop: 1199reloop:
1200 for (last = 0, i = 1; !last; i++) { 1200 for (last = 0, i = 1; !last; i += !last) {
1201 hdr = dd->ipath_f_get_msgheader(dd, rhf_addr); 1201 hdr = dd->ipath_f_get_msgheader(dd, rhf_addr);
1202 eflags = ipath_hdrget_err_flags(rhf_addr); 1202 eflags = ipath_hdrget_err_flags(rhf_addr);
1203 etype = ipath_hdrget_rcv_type(rhf_addr); 1203 etype = ipath_hdrget_rcv_type(rhf_addr);
@@ -1428,6 +1428,40 @@ static void ipath_update_pio_bufs(struct ipath_devdata *dd)
1428 spin_unlock_irqrestore(&ipath_pioavail_lock, flags); 1428 spin_unlock_irqrestore(&ipath_pioavail_lock, flags);
1429} 1429}
1430 1430
1431/*
1432 * used to force update of pioavailshadow if we can't get a pio buffer.
1433 * Needed primarily due to exitting freeze mode after recovering
1434 * from errors. Done lazily, because it's safer (known to not
1435 * be writing pio buffers).
1436 */
1437static void ipath_reset_availshadow(struct ipath_devdata *dd)
1438{
1439 int i, im;
1440 unsigned long flags;
1441
1442 spin_lock_irqsave(&ipath_pioavail_lock, flags);
1443 for (i = 0; i < dd->ipath_pioavregs; i++) {
1444 u64 val, oldval;
1445 /* deal with 6110 chip bug on high register #s */
1446 im = (i > 3 && (dd->ipath_flags & IPATH_SWAP_PIOBUFS)) ?
1447 i ^ 1 : i;
1448 val = le64_to_cpu(dd->ipath_pioavailregs_dma[im]);
1449 /*
1450 * busy out the buffers not in the kernel avail list,
1451 * without changing the generation bits.
1452 */
1453 oldval = dd->ipath_pioavailshadow[i];
1454 dd->ipath_pioavailshadow[i] = val |
1455 ((~dd->ipath_pioavailkernel[i] <<
1456 INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT) &
1457 0xaaaaaaaaaaaaaaaaULL); /* All BUSY bits in qword */
1458 if (oldval != dd->ipath_pioavailshadow[i])
1459 ipath_dbg("shadow[%d] was %Lx, now %lx\n",
1460 i, oldval, dd->ipath_pioavailshadow[i]);
1461 }
1462 spin_unlock_irqrestore(&ipath_pioavail_lock, flags);
1463}
1464
1431/** 1465/**
1432 * ipath_setrcvhdrsize - set the receive header size 1466 * ipath_setrcvhdrsize - set the receive header size
1433 * @dd: the infinipath device 1467 * @dd: the infinipath device
@@ -1482,9 +1516,12 @@ static noinline void no_pio_bufs(struct ipath_devdata *dd)
1482 */ 1516 */
1483 ipath_stats.sps_nopiobufs++; 1517 ipath_stats.sps_nopiobufs++;
1484 if (!(++dd->ipath_consec_nopiobuf % 100000)) { 1518 if (!(++dd->ipath_consec_nopiobuf % 100000)) {
1485 ipath_dbg("%u pio sends with no bufavail; dmacopy: " 1519 ipath_force_pio_avail_update(dd); /* at start */
1486 "%llx %llx %llx %llx; shadow: %lx %lx %lx %lx\n", 1520 ipath_dbg("%u tries no piobufavail ts%lx; dmacopy: "
1521 "%llx %llx %llx %llx\n"
1522 "ipath shadow: %lx %lx %lx %lx\n",
1487 dd->ipath_consec_nopiobuf, 1523 dd->ipath_consec_nopiobuf,
1524 (unsigned long)get_cycles(),
1488 (unsigned long long) le64_to_cpu(dma[0]), 1525 (unsigned long long) le64_to_cpu(dma[0]),
1489 (unsigned long long) le64_to_cpu(dma[1]), 1526 (unsigned long long) le64_to_cpu(dma[1]),
1490 (unsigned long long) le64_to_cpu(dma[2]), 1527 (unsigned long long) le64_to_cpu(dma[2]),
@@ -1496,14 +1533,17 @@ static noinline void no_pio_bufs(struct ipath_devdata *dd)
1496 */ 1533 */
1497 if ((dd->ipath_piobcnt2k + dd->ipath_piobcnt4k) > 1534 if ((dd->ipath_piobcnt2k + dd->ipath_piobcnt4k) >
1498 (sizeof(shadow[0]) * 4 * 4)) 1535 (sizeof(shadow[0]) * 4 * 4))
1499 ipath_dbg("2nd group: dmacopy: %llx %llx " 1536 ipath_dbg("2nd group: dmacopy: "
1500 "%llx %llx; shadow: %lx %lx %lx %lx\n", 1537 "%llx %llx %llx %llx\n"
1538 "ipath shadow: %lx %lx %lx %lx\n",
1501 (unsigned long long)le64_to_cpu(dma[4]), 1539 (unsigned long long)le64_to_cpu(dma[4]),
1502 (unsigned long long)le64_to_cpu(dma[5]), 1540 (unsigned long long)le64_to_cpu(dma[5]),
1503 (unsigned long long)le64_to_cpu(dma[6]), 1541 (unsigned long long)le64_to_cpu(dma[6]),
1504 (unsigned long long)le64_to_cpu(dma[7]), 1542 (unsigned long long)le64_to_cpu(dma[7]),
1505 shadow[4], shadow[5], shadow[6], 1543 shadow[4], shadow[5], shadow[6], shadow[7]);
1506 shadow[7]); 1544
1545 /* at end, so update likely happened */
1546 ipath_reset_availshadow(dd);
1507 } 1547 }
1508} 1548}
1509 1549
@@ -1652,19 +1692,46 @@ void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
1652 unsigned len, int avail) 1692 unsigned len, int avail)
1653{ 1693{
1654 unsigned long flags; 1694 unsigned long flags;
1655 unsigned end; 1695 unsigned end, cnt = 0, next;
1656 1696
1657 /* There are two bits per send buffer (busy and generation) */ 1697 /* There are two bits per send buffer (busy and generation) */
1658 start *= 2; 1698 start *= 2;
1659 len *= 2; 1699 end = start + len * 2;
1660 end = start + len;
1661 1700
1662 /* Set or clear the generation bits. */
1663 spin_lock_irqsave(&ipath_pioavail_lock, flags); 1701 spin_lock_irqsave(&ipath_pioavail_lock, flags);
1702 /* Set or clear the busy bit in the shadow. */
1664 while (start < end) { 1703 while (start < end) {
1665 if (avail) { 1704 if (avail) {
1666 __clear_bit(start + INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT, 1705 unsigned long dma;
1667 dd->ipath_pioavailshadow); 1706 int i, im;
1707 /*
1708 * the BUSY bit will never be set, because we disarm
1709 * the user buffers before we hand them back to the
1710 * kernel. We do have to make sure the generation
1711 * bit is set correctly in shadow, since it could
1712 * have changed many times while allocated to user.
1713 * We can't use the bitmap functions on the full
1714 * dma array because it is always little-endian, so
1715 * we have to flip to host-order first.
1716 * BITS_PER_LONG is slightly wrong, since it's
1717 * always 64 bits per register in chip...
1718 * We only work on 64 bit kernels, so that's OK.
1719 */
1720 /* deal with 6110 chip bug on high register #s */
1721 i = start / BITS_PER_LONG;
1722 im = (i > 3 && (dd->ipath_flags & IPATH_SWAP_PIOBUFS)) ?
1723 i ^ 1 : i;
1724 __clear_bit(INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT
1725 + start, dd->ipath_pioavailshadow);
1726 dma = (unsigned long) le64_to_cpu(
1727 dd->ipath_pioavailregs_dma[im]);
1728 if (test_bit((INFINIPATH_SENDPIOAVAIL_CHECK_SHIFT
1729 + start) % BITS_PER_LONG, &dma))
1730 __set_bit(INFINIPATH_SENDPIOAVAIL_CHECK_SHIFT
1731 + start, dd->ipath_pioavailshadow);
1732 else
1733 __clear_bit(INFINIPATH_SENDPIOAVAIL_CHECK_SHIFT
1734 + start, dd->ipath_pioavailshadow);
1668 __set_bit(start, dd->ipath_pioavailkernel); 1735 __set_bit(start, dd->ipath_pioavailkernel);
1669 } else { 1736 } else {
1670 __set_bit(start + INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT, 1737 __set_bit(start + INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT,
@@ -1673,7 +1740,44 @@ void ipath_chg_pioavailkernel(struct ipath_devdata *dd, unsigned start,
1673 } 1740 }
1674 start += 2; 1741 start += 2;
1675 } 1742 }
1743
1744 if (dd->ipath_pioupd_thresh) {
1745 end = 2 * (dd->ipath_piobcnt2k + dd->ipath_piobcnt4k);
1746 next = find_first_bit(dd->ipath_pioavailkernel, end);
1747 while (next < end) {
1748 cnt++;
1749 next = find_next_bit(dd->ipath_pioavailkernel, end,
1750 next + 1);
1751 }
1752 }
1676 spin_unlock_irqrestore(&ipath_pioavail_lock, flags); 1753 spin_unlock_irqrestore(&ipath_pioavail_lock, flags);
1754
1755 /*
1756 * When moving buffers from kernel to user, if number assigned to
1757 * the user is less than the pio update threshold, and threshold
1758 * is supported (cnt was computed > 0), drop the update threshold
1759 * so we update at least once per allocated number of buffers.
1760 * In any case, if the kernel buffers are less than the threshold,
1761 * drop the threshold. We don't bother increasing it, having once
1762 * decreased it, since it would typically just cycle back and forth.
1763 * If we don't decrease below buffers in use, we can wait a long
1764 * time for an update, until some other context uses PIO buffers.
1765 */
1766 if (!avail && len < cnt)
1767 cnt = len;
1768 if (cnt < dd->ipath_pioupd_thresh) {
1769 dd->ipath_pioupd_thresh = cnt;
1770 ipath_dbg("Decreased pio update threshold to %u\n",
1771 dd->ipath_pioupd_thresh);
1772 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
1773 dd->ipath_sendctrl &= ~(INFINIPATH_S_UPDTHRESH_MASK
1774 << INFINIPATH_S_UPDTHRESH_SHIFT);
1775 dd->ipath_sendctrl |= dd->ipath_pioupd_thresh
1776 << INFINIPATH_S_UPDTHRESH_SHIFT;
1777 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
1778 dd->ipath_sendctrl);
1779 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
1780 }
1677} 1781}
1678 1782
1679/** 1783/**
@@ -1790,12 +1894,12 @@ void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1790 */ 1894 */
1791 if (dd->ipath_flags & IPATH_HAS_SEND_DMA) { 1895 if (dd->ipath_flags & IPATH_HAS_SEND_DMA) {
1792 int skip_cancel; 1896 int skip_cancel;
1793 u64 *statp = &dd->ipath_sdma_status; 1897 unsigned long *statp = &dd->ipath_sdma_status;
1794 1898
1795 spin_lock_irqsave(&dd->ipath_sdma_lock, flags); 1899 spin_lock_irqsave(&dd->ipath_sdma_lock, flags);
1796 skip_cancel = 1900 skip_cancel =
1797 !test_bit(IPATH_SDMA_DISABLED, statp) && 1901 test_and_set_bit(IPATH_SDMA_ABORTING, statp)
1798 test_and_set_bit(IPATH_SDMA_ABORTING, statp); 1902 && !test_bit(IPATH_SDMA_DISABLED, statp);
1799 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags); 1903 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags);
1800 if (skip_cancel) 1904 if (skip_cancel)
1801 goto bail; 1905 goto bail;
@@ -1826,6 +1930,9 @@ void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1826 ipath_disarm_piobufs(dd, 0, 1930 ipath_disarm_piobufs(dd, 0,
1827 dd->ipath_piobcnt2k + dd->ipath_piobcnt4k); 1931 dd->ipath_piobcnt2k + dd->ipath_piobcnt4k);
1828 1932
1933 if (dd->ipath_flags & IPATH_HAS_SEND_DMA)
1934 set_bit(IPATH_SDMA_DISARMED, &dd->ipath_sdma_status);
1935
1829 if (restore_sendctrl) { 1936 if (restore_sendctrl) {
1830 /* else done by caller later if needed */ 1937 /* else done by caller later if needed */
1831 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags); 1938 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
@@ -1845,7 +1952,6 @@ void ipath_cancel_sends(struct ipath_devdata *dd, int restore_sendctrl)
1845 /* only wait so long for intr */ 1952 /* only wait so long for intr */
1846 dd->ipath_sdma_abort_intr_timeout = jiffies + HZ; 1953 dd->ipath_sdma_abort_intr_timeout = jiffies + HZ;
1847 dd->ipath_sdma_reset_wait = 200; 1954 dd->ipath_sdma_reset_wait = 200;
1848 __set_bit(IPATH_SDMA_DISARMED, &dd->ipath_sdma_status);
1849 if (!test_bit(IPATH_SDMA_SHUTDOWN, &dd->ipath_sdma_status)) 1955 if (!test_bit(IPATH_SDMA_SHUTDOWN, &dd->ipath_sdma_status))
1850 tasklet_hi_schedule(&dd->ipath_sdma_abort_task); 1956 tasklet_hi_schedule(&dd->ipath_sdma_abort_task);
1851 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags); 1957 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags);
@@ -2510,7 +2616,7 @@ int ipath_reset_device(int unit)
2510 ipath_dbg("unit %u port %d is in use " 2616 ipath_dbg("unit %u port %d is in use "
2511 "(PID %u cmd %s), can't reset\n", 2617 "(PID %u cmd %s), can't reset\n",
2512 unit, i, 2618 unit, i,
2513 dd->ipath_pd[i]->port_pid, 2619 pid_nr(dd->ipath_pd[i]->port_pid),
2514 dd->ipath_pd[i]->port_comm); 2620 dd->ipath_pd[i]->port_comm);
2515 ret = -EBUSY; 2621 ret = -EBUSY;
2516 goto bail; 2622 goto bail;
@@ -2548,19 +2654,21 @@ bail:
2548static int ipath_signal_procs(struct ipath_devdata *dd, int sig) 2654static int ipath_signal_procs(struct ipath_devdata *dd, int sig)
2549{ 2655{
2550 int i, sub, any = 0; 2656 int i, sub, any = 0;
2551 pid_t pid; 2657 struct pid *pid;
2552 2658
2553 if (!dd->ipath_pd) 2659 if (!dd->ipath_pd)
2554 return 0; 2660 return 0;
2555 for (i = 1; i < dd->ipath_cfgports; i++) { 2661 for (i = 1; i < dd->ipath_cfgports; i++) {
2556 if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt || 2662 if (!dd->ipath_pd[i] || !dd->ipath_pd[i]->port_cnt)
2557 !dd->ipath_pd[i]->port_pid)
2558 continue; 2663 continue;
2559 pid = dd->ipath_pd[i]->port_pid; 2664 pid = dd->ipath_pd[i]->port_pid;
2665 if (!pid)
2666 continue;
2667
2560 dev_info(&dd->pcidev->dev, "context %d in use " 2668 dev_info(&dd->pcidev->dev, "context %d in use "
2561 "(PID %u), sending signal %d\n", 2669 "(PID %u), sending signal %d\n",
2562 i, pid, sig); 2670 i, pid_nr(pid), sig);
2563 kill_proc(pid, sig, 1); 2671 kill_pid(pid, sig, 1);
2564 any++; 2672 any++;
2565 for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) { 2673 for (sub = 0; sub < INFINIPATH_MAX_SUBPORT; sub++) {
2566 pid = dd->ipath_pd[i]->port_subpid[sub]; 2674 pid = dd->ipath_pd[i]->port_subpid[sub];
@@ -2568,8 +2676,8 @@ static int ipath_signal_procs(struct ipath_devdata *dd, int sig)
2568 continue; 2676 continue;
2569 dev_info(&dd->pcidev->dev, "sub-context " 2677 dev_info(&dd->pcidev->dev, "sub-context "
2570 "%d:%d in use (PID %u), sending " 2678 "%d:%d in use (PID %u), sending "
2571 "signal %d\n", i, sub, pid, sig); 2679 "signal %d\n", i, sub, pid_nr(pid), sig);
2572 kill_proc(pid, sig, 1); 2680 kill_pid(pid, sig, 1);
2573 any++; 2681 any++;
2574 } 2682 }
2575 } 2683 }
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index 8b1752202e78..b472b15637f0 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -173,47 +173,25 @@ static int ipath_get_base_info(struct file *fp,
173 (void *) dd->ipath_statusp - 173 (void *) dd->ipath_statusp -
174 (void *) dd->ipath_pioavailregs_dma; 174 (void *) dd->ipath_pioavailregs_dma;
175 if (!shared) { 175 if (!shared) {
176 kinfo->spi_piocnt = dd->ipath_pbufsport; 176 kinfo->spi_piocnt = pd->port_piocnt;
177 kinfo->spi_piobufbase = (u64) pd->port_piobufs; 177 kinfo->spi_piobufbase = (u64) pd->port_piobufs;
178 kinfo->__spi_uregbase = (u64) dd->ipath_uregbase + 178 kinfo->__spi_uregbase = (u64) dd->ipath_uregbase +
179 dd->ipath_ureg_align * pd->port_port; 179 dd->ipath_ureg_align * pd->port_port;
180 } else if (master) { 180 } else if (master) {
181 kinfo->spi_piocnt = (dd->ipath_pbufsport / subport_cnt) + 181 kinfo->spi_piocnt = (pd->port_piocnt / subport_cnt) +
182 (dd->ipath_pbufsport % subport_cnt); 182 (pd->port_piocnt % subport_cnt);
183 /* Master's PIO buffers are after all the slave's */ 183 /* Master's PIO buffers are after all the slave's */
184 kinfo->spi_piobufbase = (u64) pd->port_piobufs + 184 kinfo->spi_piobufbase = (u64) pd->port_piobufs +
185 dd->ipath_palign * 185 dd->ipath_palign *
186 (dd->ipath_pbufsport - kinfo->spi_piocnt); 186 (pd->port_piocnt - kinfo->spi_piocnt);
187 } else { 187 } else {
188 unsigned slave = subport_fp(fp) - 1; 188 unsigned slave = subport_fp(fp) - 1;
189 189
190 kinfo->spi_piocnt = dd->ipath_pbufsport / subport_cnt; 190 kinfo->spi_piocnt = pd->port_piocnt / subport_cnt;
191 kinfo->spi_piobufbase = (u64) pd->port_piobufs + 191 kinfo->spi_piobufbase = (u64) pd->port_piobufs +
192 dd->ipath_palign * kinfo->spi_piocnt * slave; 192 dd->ipath_palign * kinfo->spi_piocnt * slave;
193 } 193 }
194 194
195 /*
196 * Set the PIO avail update threshold to no larger
197 * than the number of buffers per process. Note that
198 * we decrease it here, but won't ever increase it.
199 */
200 if (dd->ipath_pioupd_thresh &&
201 kinfo->spi_piocnt < dd->ipath_pioupd_thresh) {
202 unsigned long flags;
203
204 dd->ipath_pioupd_thresh = kinfo->spi_piocnt;
205 ipath_dbg("Decreased pio update threshold to %u\n",
206 dd->ipath_pioupd_thresh);
207 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
208 dd->ipath_sendctrl &= ~(INFINIPATH_S_UPDTHRESH_MASK
209 << INFINIPATH_S_UPDTHRESH_SHIFT);
210 dd->ipath_sendctrl |= dd->ipath_pioupd_thresh
211 << INFINIPATH_S_UPDTHRESH_SHIFT;
212 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl,
213 dd->ipath_sendctrl);
214 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
215 }
216
217 if (shared) { 195 if (shared) {
218 kinfo->spi_port_uregbase = (u64) dd->ipath_uregbase + 196 kinfo->spi_port_uregbase = (u64) dd->ipath_uregbase +
219 dd->ipath_ureg_align * pd->port_port; 197 dd->ipath_ureg_align * pd->port_port;
@@ -577,7 +555,7 @@ static int ipath_tid_free(struct ipath_portdata *pd, unsigned subport,
577 p = dd->ipath_pageshadow[porttid + tid]; 555 p = dd->ipath_pageshadow[porttid + tid];
578 dd->ipath_pageshadow[porttid + tid] = NULL; 556 dd->ipath_pageshadow[porttid + tid] = NULL;
579 ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n", 557 ipath_cdbg(VERBOSE, "PID %u freeing TID %u\n",
580 pd->port_pid, tid); 558 pid_nr(pd->port_pid), tid);
581 dd->ipath_f_put_tid(dd, &tidbase[tid], 559 dd->ipath_f_put_tid(dd, &tidbase[tid],
582 RCVHQ_RCV_TYPE_EXPECTED, 560 RCVHQ_RCV_TYPE_EXPECTED,
583 dd->ipath_tidinvalid); 561 dd->ipath_tidinvalid);
@@ -1309,19 +1287,19 @@ static int ipath_mmap(struct file *fp, struct vm_area_struct *vma)
1309 ureg = dd->ipath_uregbase + dd->ipath_ureg_align * pd->port_port; 1287 ureg = dd->ipath_uregbase + dd->ipath_ureg_align * pd->port_port;
1310 if (!pd->port_subport_cnt) { 1288 if (!pd->port_subport_cnt) {
1311 /* port is not shared */ 1289 /* port is not shared */
1312 piocnt = dd->ipath_pbufsport; 1290 piocnt = pd->port_piocnt;
1313 piobufs = pd->port_piobufs; 1291 piobufs = pd->port_piobufs;
1314 } else if (!subport_fp(fp)) { 1292 } else if (!subport_fp(fp)) {
1315 /* caller is the master */ 1293 /* caller is the master */
1316 piocnt = (dd->ipath_pbufsport / pd->port_subport_cnt) + 1294 piocnt = (pd->port_piocnt / pd->port_subport_cnt) +
1317 (dd->ipath_pbufsport % pd->port_subport_cnt); 1295 (pd->port_piocnt % pd->port_subport_cnt);
1318 piobufs = pd->port_piobufs + 1296 piobufs = pd->port_piobufs +
1319 dd->ipath_palign * (dd->ipath_pbufsport - piocnt); 1297 dd->ipath_palign * (pd->port_piocnt - piocnt);
1320 } else { 1298 } else {
1321 unsigned slave = subport_fp(fp) - 1; 1299 unsigned slave = subport_fp(fp) - 1;
1322 1300
1323 /* caller is a slave */ 1301 /* caller is a slave */
1324 piocnt = dd->ipath_pbufsport / pd->port_subport_cnt; 1302 piocnt = pd->port_piocnt / pd->port_subport_cnt;
1325 piobufs = pd->port_piobufs + dd->ipath_palign * piocnt * slave; 1303 piobufs = pd->port_piobufs + dd->ipath_palign * piocnt * slave;
1326 } 1304 }
1327 1305
@@ -1631,11 +1609,8 @@ static int try_alloc_port(struct ipath_devdata *dd, int port,
1631 port); 1609 port);
1632 pd->port_cnt = 1; 1610 pd->port_cnt = 1;
1633 port_fp(fp) = pd; 1611 port_fp(fp) = pd;
1634 pd->port_pid = current->pid; 1612 pd->port_pid = get_pid(task_pid(current));
1635 strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm)); 1613 strncpy(pd->port_comm, current->comm, sizeof(pd->port_comm));
1636 ipath_chg_pioavailkernel(dd,
1637 dd->ipath_pbufsport * (pd->port_port - 1),
1638 dd->ipath_pbufsport, 0);
1639 ipath_stats.sps_ports++; 1614 ipath_stats.sps_ports++;
1640 ret = 0; 1615 ret = 0;
1641 } else 1616 } else
@@ -1818,14 +1793,15 @@ static int find_shared_port(struct file *fp,
1818 } 1793 }
1819 port_fp(fp) = pd; 1794 port_fp(fp) = pd;
1820 subport_fp(fp) = pd->port_cnt++; 1795 subport_fp(fp) = pd->port_cnt++;
1821 pd->port_subpid[subport_fp(fp)] = current->pid; 1796 pd->port_subpid[subport_fp(fp)] =
1797 get_pid(task_pid(current));
1822 tidcursor_fp(fp) = 0; 1798 tidcursor_fp(fp) = 0;
1823 pd->active_slaves |= 1 << subport_fp(fp); 1799 pd->active_slaves |= 1 << subport_fp(fp);
1824 ipath_cdbg(PROC, 1800 ipath_cdbg(PROC,
1825 "%s[%u] %u sharing %s[%u] unit:port %u:%u\n", 1801 "%s[%u] %u sharing %s[%u] unit:port %u:%u\n",
1826 current->comm, current->pid, 1802 current->comm, current->pid,
1827 subport_fp(fp), 1803 subport_fp(fp),
1828 pd->port_comm, pd->port_pid, 1804 pd->port_comm, pid_nr(pd->port_pid),
1829 dd->ipath_unit, pd->port_port); 1805 dd->ipath_unit, pd->port_port);
1830 ret = 1; 1806 ret = 1;
1831 goto done; 1807 goto done;
@@ -1938,11 +1914,25 @@ static int ipath_do_user_init(struct file *fp,
1938 1914
1939 /* for now we do nothing with rcvhdrcnt: uinfo->spu_rcvhdrcnt */ 1915 /* for now we do nothing with rcvhdrcnt: uinfo->spu_rcvhdrcnt */
1940 1916
1917 /* some ports may get extra buffers, calculate that here */
1918 if (pd->port_port <= dd->ipath_ports_extrabuf)
1919 pd->port_piocnt = dd->ipath_pbufsport + 1;
1920 else
1921 pd->port_piocnt = dd->ipath_pbufsport;
1922
1941 /* for right now, kernel piobufs are at end, so port 1 is at 0 */ 1923 /* for right now, kernel piobufs are at end, so port 1 is at 0 */
1924 if (pd->port_port <= dd->ipath_ports_extrabuf)
1925 pd->port_pio_base = (dd->ipath_pbufsport + 1)
1926 * (pd->port_port - 1);
1927 else
1928 pd->port_pio_base = dd->ipath_ports_extrabuf +
1929 dd->ipath_pbufsport * (pd->port_port - 1);
1942 pd->port_piobufs = dd->ipath_piobufbase + 1930 pd->port_piobufs = dd->ipath_piobufbase +
1943 dd->ipath_pbufsport * (pd->port_port - 1) * dd->ipath_palign; 1931 pd->port_pio_base * dd->ipath_palign;
1944 ipath_cdbg(VERBOSE, "Set base of piobufs for port %u to 0x%x\n", 1932 ipath_cdbg(VERBOSE, "piobuf base for port %u is 0x%x, piocnt %u,"
1945 pd->port_port, pd->port_piobufs); 1933 " first pio %u\n", pd->port_port, pd->port_piobufs,
1934 pd->port_piocnt, pd->port_pio_base);
1935 ipath_chg_pioavailkernel(dd, pd->port_pio_base, pd->port_piocnt, 0);
1946 1936
1947 /* 1937 /*
1948 * Now allocate the rcvhdr Q and eager TIDs; skip the TID 1938 * Now allocate the rcvhdr Q and eager TIDs; skip the TID
@@ -2077,7 +2067,8 @@ static int ipath_close(struct inode *in, struct file *fp)
2077 * the slave(s) don't wait for receive data forever. 2067 * the slave(s) don't wait for receive data forever.
2078 */ 2068 */
2079 pd->active_slaves &= ~(1 << fd->subport); 2069 pd->active_slaves &= ~(1 << fd->subport);
2080 pd->port_subpid[fd->subport] = 0; 2070 put_pid(pd->port_subpid[fd->subport]);
2071 pd->port_subpid[fd->subport] = NULL;
2081 mutex_unlock(&ipath_mutex); 2072 mutex_unlock(&ipath_mutex);
2082 goto bail; 2073 goto bail;
2083 } 2074 }
@@ -2085,7 +2076,7 @@ static int ipath_close(struct inode *in, struct file *fp)
2085 2076
2086 if (pd->port_hdrqfull) { 2077 if (pd->port_hdrqfull) {
2087 ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors " 2078 ipath_cdbg(PROC, "%s[%u] had %u rcvhdrqfull errors "
2088 "during run\n", pd->port_comm, pd->port_pid, 2079 "during run\n", pd->port_comm, pid_nr(pd->port_pid),
2089 pd->port_hdrqfull); 2080 pd->port_hdrqfull);
2090 pd->port_hdrqfull = 0; 2081 pd->port_hdrqfull = 0;
2091 } 2082 }
@@ -2107,7 +2098,6 @@ static int ipath_close(struct inode *in, struct file *fp)
2107 } 2098 }
2108 2099
2109 if (dd->ipath_kregbase) { 2100 if (dd->ipath_kregbase) {
2110 int i;
2111 /* atomically clear receive enable port and intr avail. */ 2101 /* atomically clear receive enable port and intr avail. */
2112 clear_bit(dd->ipath_r_portenable_shift + port, 2102 clear_bit(dd->ipath_r_portenable_shift + port,
2113 &dd->ipath_rcvctrl); 2103 &dd->ipath_rcvctrl);
@@ -2136,9 +2126,9 @@ static int ipath_close(struct inode *in, struct file *fp)
2136 ipath_write_kreg_port(dd, dd->ipath_kregs->kr_rcvhdraddr, 2126 ipath_write_kreg_port(dd, dd->ipath_kregs->kr_rcvhdraddr,
2137 pd->port_port, dd->ipath_dummy_hdrq_phys); 2127 pd->port_port, dd->ipath_dummy_hdrq_phys);
2138 2128
2139 i = dd->ipath_pbufsport * (port - 1); 2129 ipath_disarm_piobufs(dd, pd->port_pio_base, pd->port_piocnt);
2140 ipath_disarm_piobufs(dd, i, dd->ipath_pbufsport); 2130 ipath_chg_pioavailkernel(dd, pd->port_pio_base,
2141 ipath_chg_pioavailkernel(dd, i, dd->ipath_pbufsport, 1); 2131 pd->port_piocnt, 1);
2142 2132
2143 dd->ipath_f_clear_tids(dd, pd->port_port); 2133 dd->ipath_f_clear_tids(dd, pd->port_port);
2144 2134
@@ -2146,11 +2136,12 @@ static int ipath_close(struct inode *in, struct file *fp)
2146 unlock_expected_tids(pd); 2136 unlock_expected_tids(pd);
2147 ipath_stats.sps_ports--; 2137 ipath_stats.sps_ports--;
2148 ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n", 2138 ipath_cdbg(PROC, "%s[%u] closed port %u:%u\n",
2149 pd->port_comm, pd->port_pid, 2139 pd->port_comm, pid_nr(pd->port_pid),
2150 dd->ipath_unit, port); 2140 dd->ipath_unit, port);
2151 } 2141 }
2152 2142
2153 pd->port_pid = 0; 2143 put_pid(pd->port_pid);
2144 pd->port_pid = NULL;
2154 dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */ 2145 dd->ipath_pd[pd->port_port] = NULL; /* before releasing mutex */
2155 mutex_unlock(&ipath_mutex); 2146 mutex_unlock(&ipath_mutex);
2156 ipath_free_pddata(dd, pd); /* after releasing the mutex */ 2147 ipath_free_pddata(dd, pd); /* after releasing the mutex */
diff --git a/drivers/infiniband/hw/ipath/ipath_iba7220.c b/drivers/infiniband/hw/ipath/ipath_iba7220.c
index e3ec0d1bdf50..8eee7830f042 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba7220.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba7220.c
@@ -595,7 +595,7 @@ static void ipath_7220_txe_recover(struct ipath_devdata *dd)
595 595
596 dev_info(&dd->pcidev->dev, 596 dev_info(&dd->pcidev->dev,
597 "Recovering from TXE PIO parity error\n"); 597 "Recovering from TXE PIO parity error\n");
598 ipath_disarm_senderrbufs(dd, 1); 598 ipath_disarm_senderrbufs(dd);
599} 599}
600 600
601 601
@@ -675,10 +675,8 @@ static void ipath_7220_handle_hwerrors(struct ipath_devdata *dd, char *msg,
675 ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control); 675 ctrl = ipath_read_kreg32(dd, dd->ipath_kregs->kr_control);
676 if ((ctrl & INFINIPATH_C_FREEZEMODE) && !ipath_diag_inuse) { 676 if ((ctrl & INFINIPATH_C_FREEZEMODE) && !ipath_diag_inuse) {
677 /* 677 /*
678 * Parity errors in send memory are recoverable, 678 * Parity errors in send memory are recoverable by h/w
679 * just cancel the send (if indicated in * sendbuffererror), 679 * just do housekeeping, exit freeze mode and continue.
680 * count the occurrence, unfreeze (if no other handled
681 * hardware error bits are set), and continue.
682 */ 680 */
683 if (hwerrs & ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | 681 if (hwerrs & ((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF |
684 INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) 682 INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC)
@@ -687,13 +685,6 @@ static void ipath_7220_handle_hwerrors(struct ipath_devdata *dd, char *msg,
687 hwerrs &= ~((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF | 685 hwerrs &= ~((INFINIPATH_HWE_TXEMEMPARITYERR_PIOBUF |
688 INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC) 686 INFINIPATH_HWE_TXEMEMPARITYERR_PIOPBC)
689 << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT); 687 << INFINIPATH_HWE_TXEMEMPARITYERR_SHIFT);
690 if (!hwerrs) {
691 /* else leave in freeze mode */
692 ipath_write_kreg(dd,
693 dd->ipath_kregs->kr_control,
694 dd->ipath_control);
695 goto bail;
696 }
697 } 688 }
698 if (hwerrs) { 689 if (hwerrs) {
699 /* 690 /*
@@ -723,8 +714,8 @@ static void ipath_7220_handle_hwerrors(struct ipath_devdata *dd, char *msg,
723 *dd->ipath_statusp |= IPATH_STATUS_HWERROR; 714 *dd->ipath_statusp |= IPATH_STATUS_HWERROR;
724 dd->ipath_flags &= ~IPATH_INITTED; 715 dd->ipath_flags &= ~IPATH_INITTED;
725 } else { 716 } else {
726 ipath_dbg("Clearing freezemode on ignored hardware " 717 ipath_dbg("Clearing freezemode on ignored or "
727 "error\n"); 718 "recovered hardware error\n");
728 ipath_clear_freeze(dd); 719 ipath_clear_freeze(dd);
729 } 720 }
730 } 721 }
@@ -870,8 +861,9 @@ static int ipath_7220_boardname(struct ipath_devdata *dd, char *name,
870 "revision %u.%u!\n", 861 "revision %u.%u!\n",
871 dd->ipath_majrev, dd->ipath_minrev); 862 dd->ipath_majrev, dd->ipath_minrev);
872 ret = 1; 863 ret = 1;
873 } else if (dd->ipath_minrev == 1) { 864 } else if (dd->ipath_minrev == 1 &&
874 /* Rev1 chips are prototype. Complain, but allow use */ 865 !(dd->ipath_flags & IPATH_INITTED)) {
866 /* Rev1 chips are prototype. Complain at init, but allow use */
875 ipath_dev_err(dd, "Unsupported hardware " 867 ipath_dev_err(dd, "Unsupported hardware "
876 "revision %u.%u, Contact support@qlogic.com\n", 868 "revision %u.%u, Contact support@qlogic.com\n",
877 dd->ipath_majrev, dd->ipath_minrev); 869 dd->ipath_majrev, dd->ipath_minrev);
@@ -1966,7 +1958,7 @@ static void ipath_7220_config_ports(struct ipath_devdata *dd, ushort cfgports)
1966 dd->ipath_rcvctrl); 1958 dd->ipath_rcvctrl);
1967 dd->ipath_p0_rcvegrcnt = 2048; /* always */ 1959 dd->ipath_p0_rcvegrcnt = 2048; /* always */
1968 if (dd->ipath_flags & IPATH_HAS_SEND_DMA) 1960 if (dd->ipath_flags & IPATH_HAS_SEND_DMA)
1969 dd->ipath_pioreserved = 1; /* reserve a buffer */ 1961 dd->ipath_pioreserved = 3; /* kpiobufs used for PIO */
1970} 1962}
1971 1963
1972 1964
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c
index 27dd89476660..3e5baa43fc82 100644
--- a/drivers/infiniband/hw/ipath/ipath_init_chip.c
+++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c
@@ -41,7 +41,7 @@
41/* 41/*
42 * min buffers we want to have per port, after driver 42 * min buffers we want to have per port, after driver
43 */ 43 */
44#define IPATH_MIN_USER_PORT_BUFCNT 8 44#define IPATH_MIN_USER_PORT_BUFCNT 7
45 45
46/* 46/*
47 * Number of ports we are configured to use (to allow for more pio 47 * Number of ports we are configured to use (to allow for more pio
@@ -54,13 +54,9 @@ MODULE_PARM_DESC(cfgports, "Set max number of ports to use");
54 54
55/* 55/*
56 * Number of buffers reserved for driver (verbs and layered drivers.) 56 * Number of buffers reserved for driver (verbs and layered drivers.)
57 * Reserved at end of buffer list. Initialized based on 57 * Initialized based on number of PIO buffers if not set via module interface.
58 * number of PIO buffers if not set via module interface.
59 * The problem with this is that it's global, but we'll use different 58 * The problem with this is that it's global, but we'll use different
60 * numbers for different chip types. So the default value is not 59 * numbers for different chip types.
61 * very useful. I've redefined it for the 1.3 release so that it's
62 * zero unless set by the user to something else, in which case we
63 * try to respect it.
64 */ 60 */
65static ushort ipath_kpiobufs; 61static ushort ipath_kpiobufs;
66 62
@@ -546,9 +542,12 @@ static void enable_chip(struct ipath_devdata *dd, int reinit)
546 pioavail = dd->ipath_pioavailregs_dma[i ^ 1]; 542 pioavail = dd->ipath_pioavailregs_dma[i ^ 1];
547 else 543 else
548 pioavail = dd->ipath_pioavailregs_dma[i]; 544 pioavail = dd->ipath_pioavailregs_dma[i];
549 dd->ipath_pioavailshadow[i] = le64_to_cpu(pioavail) | 545 /*
550 (~dd->ipath_pioavailkernel[i] << 546 * don't need to worry about ipath_pioavailkernel here
551 INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT); 547 * because we will call ipath_chg_pioavailkernel() later
548 * in initialization, to busy out buffers as needed
549 */
550 dd->ipath_pioavailshadow[i] = le64_to_cpu(pioavail);
552 } 551 }
553 /* can get counters, stats, etc. */ 552 /* can get counters, stats, etc. */
554 dd->ipath_flags |= IPATH_PRESENT; 553 dd->ipath_flags |= IPATH_PRESENT;
@@ -708,12 +707,11 @@ static void verify_interrupt(unsigned long opaque)
708int ipath_init_chip(struct ipath_devdata *dd, int reinit) 707int ipath_init_chip(struct ipath_devdata *dd, int reinit)
709{ 708{
710 int ret = 0; 709 int ret = 0;
711 u32 val32, kpiobufs; 710 u32 kpiobufs, defkbufs;
712 u32 piobufs, uports; 711 u32 piobufs, uports;
713 u64 val; 712 u64 val;
714 struct ipath_portdata *pd; 713 struct ipath_portdata *pd;
715 gfp_t gfp_flags = GFP_USER | __GFP_COMP; 714 gfp_t gfp_flags = GFP_USER | __GFP_COMP;
716 unsigned long flags;
717 715
718 ret = init_housekeeping(dd, reinit); 716 ret = init_housekeeping(dd, reinit);
719 if (ret) 717 if (ret)
@@ -753,56 +751,46 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
753 dd->ipath_pioavregs = ALIGN(piobufs, sizeof(u64) * BITS_PER_BYTE / 2) 751 dd->ipath_pioavregs = ALIGN(piobufs, sizeof(u64) * BITS_PER_BYTE / 2)
754 / (sizeof(u64) * BITS_PER_BYTE / 2); 752 / (sizeof(u64) * BITS_PER_BYTE / 2);
755 uports = dd->ipath_cfgports ? dd->ipath_cfgports - 1 : 0; 753 uports = dd->ipath_cfgports ? dd->ipath_cfgports - 1 : 0;
756 if (ipath_kpiobufs == 0) { 754 if (piobufs > 144)
757 /* not set by user (this is default) */ 755 defkbufs = 32 + dd->ipath_pioreserved;
758 if (piobufs > 144)
759 kpiobufs = 32;
760 else
761 kpiobufs = 16;
762 }
763 else 756 else
764 kpiobufs = ipath_kpiobufs; 757 defkbufs = 16 + dd->ipath_pioreserved;
765 758
766 if (kpiobufs + (uports * IPATH_MIN_USER_PORT_BUFCNT) > piobufs) { 759 if (ipath_kpiobufs && (ipath_kpiobufs +
760 (uports * IPATH_MIN_USER_PORT_BUFCNT)) > piobufs) {
767 int i = (int) piobufs - 761 int i = (int) piobufs -
768 (int) (uports * IPATH_MIN_USER_PORT_BUFCNT); 762 (int) (uports * IPATH_MIN_USER_PORT_BUFCNT);
769 if (i < 1) 763 if (i < 1)
770 i = 1; 764 i = 1;
771 dev_info(&dd->pcidev->dev, "Allocating %d PIO bufs of " 765 dev_info(&dd->pcidev->dev, "Allocating %d PIO bufs of "
772 "%d for kernel leaves too few for %d user ports " 766 "%d for kernel leaves too few for %d user ports "
773 "(%d each); using %u\n", kpiobufs, 767 "(%d each); using %u\n", ipath_kpiobufs,
774 piobufs, uports, IPATH_MIN_USER_PORT_BUFCNT, i); 768 piobufs, uports, IPATH_MIN_USER_PORT_BUFCNT, i);
775 /* 769 /*
776 * shouldn't change ipath_kpiobufs, because could be 770 * shouldn't change ipath_kpiobufs, because could be
777 * different for different devices... 771 * different for different devices...
778 */ 772 */
779 kpiobufs = i; 773 kpiobufs = i;
780 } 774 } else if (ipath_kpiobufs)
775 kpiobufs = ipath_kpiobufs;
776 else
777 kpiobufs = defkbufs;
781 dd->ipath_lastport_piobuf = piobufs - kpiobufs; 778 dd->ipath_lastport_piobuf = piobufs - kpiobufs;
782 dd->ipath_pbufsport = 779 dd->ipath_pbufsport =
783 uports ? dd->ipath_lastport_piobuf / uports : 0; 780 uports ? dd->ipath_lastport_piobuf / uports : 0;
784 val32 = dd->ipath_lastport_piobuf - (dd->ipath_pbufsport * uports); 781 /* if not an even divisor, some user ports get extra buffers */
785 if (val32 > 0) { 782 dd->ipath_ports_extrabuf = dd->ipath_lastport_piobuf -
786 ipath_dbg("allocating %u pbufs/port leaves %u unused, " 783 (dd->ipath_pbufsport * uports);
787 "add to kernel\n", dd->ipath_pbufsport, val32); 784 if (dd->ipath_ports_extrabuf)
788 dd->ipath_lastport_piobuf -= val32; 785 ipath_dbg("%u pbufs/port leaves some unused, add 1 buffer to "
789 kpiobufs += val32; 786 "ports <= %u\n", dd->ipath_pbufsport,
790 ipath_dbg("%u pbufs/port leaves %u unused, add to kernel\n", 787 dd->ipath_ports_extrabuf);
791 dd->ipath_pbufsport, val32);
792 }
793 dd->ipath_lastpioindex = 0; 788 dd->ipath_lastpioindex = 0;
794 dd->ipath_lastpioindexl = dd->ipath_piobcnt2k; 789 dd->ipath_lastpioindexl = dd->ipath_piobcnt2k;
795 ipath_chg_pioavailkernel(dd, 0, piobufs, 1); 790 /* ipath_pioavailshadow initialized earlier */
796 ipath_cdbg(VERBOSE, "%d PIO bufs for kernel out of %d total %u " 791 ipath_cdbg(VERBOSE, "%d PIO bufs for kernel out of %d total %u "
797 "each for %u user ports\n", kpiobufs, 792 "each for %u user ports\n", kpiobufs,
798 piobufs, dd->ipath_pbufsport, uports); 793 piobufs, dd->ipath_pbufsport, uports);
799 if (dd->ipath_pioupd_thresh) {
800 if (dd->ipath_pbufsport < dd->ipath_pioupd_thresh)
801 dd->ipath_pioupd_thresh = dd->ipath_pbufsport;
802 if (kpiobufs < dd->ipath_pioupd_thresh)
803 dd->ipath_pioupd_thresh = kpiobufs;
804 }
805
806 ret = dd->ipath_f_early_init(dd); 794 ret = dd->ipath_f_early_init(dd);
807 if (ret) { 795 if (ret) {
808 ipath_dev_err(dd, "Early initialization failure\n"); 796 ipath_dev_err(dd, "Early initialization failure\n");
@@ -810,13 +798,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
810 } 798 }
811 799
812 /* 800 /*
813 * Cancel any possible active sends from early driver load.
814 * Follows early_init because some chips have to initialize
815 * PIO buffers in early_init to avoid false parity errors.
816 */
817 ipath_cancel_sends(dd, 0);
818
819 /*
820 * Early_init sets rcvhdrentsize and rcvhdrsize, so this must be 801 * Early_init sets rcvhdrentsize and rcvhdrsize, so this must be
821 * done after early_init. 802 * done after early_init.
822 */ 803 */
@@ -836,6 +817,7 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
836 817
837 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendpioavailaddr, 818 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendpioavailaddr,
838 dd->ipath_pioavailregs_phys); 819 dd->ipath_pioavailregs_phys);
820
839 /* 821 /*
840 * this is to detect s/w errors, which the h/w works around by 822 * this is to detect s/w errors, which the h/w works around by
841 * ignoring the low 6 bits of address, if it wasn't aligned. 823 * ignoring the low 6 bits of address, if it wasn't aligned.
@@ -862,12 +844,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
862 ~0ULL&~INFINIPATH_HWE_MEMBISTFAILED); 844 ~0ULL&~INFINIPATH_HWE_MEMBISTFAILED);
863 ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 0ULL); 845 ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 0ULL);
864 846
865 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
866 dd->ipath_sendctrl = INFINIPATH_S_PIOENABLE;
867 ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, dd->ipath_sendctrl);
868 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
869 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
870
871 /* 847 /*
872 * before error clears, since we expect serdes pll errors during 848 * before error clears, since we expect serdes pll errors during
873 * this, the first time after reset 849 * this, the first time after reset
@@ -940,6 +916,19 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit)
940 else 916 else
941 enable_chip(dd, reinit); 917 enable_chip(dd, reinit);
942 918
919 /* after enable_chip, so pioavailshadow setup */
920 ipath_chg_pioavailkernel(dd, 0, piobufs, 1);
921
922 /*
923 * Cancel any possible active sends from early driver load.
924 * Follows early_init because some chips have to initialize
925 * PIO buffers in early_init to avoid false parity errors.
926 * After enable and ipath_chg_pioavailkernel so we can safely
927 * enable pioavail updates and PIOENABLE; packets are now
928 * ready to go out.
929 */
930 ipath_cancel_sends(dd, 1);
931
943 if (!reinit) { 932 if (!reinit) {
944 /* 933 /*
945 * Used when we close a port, for DMA already in flight 934 * Used when we close a port, for DMA already in flight
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c
index 1b58f4737c71..26900b3b7a4e 100644
--- a/drivers/infiniband/hw/ipath/ipath_intr.c
+++ b/drivers/infiniband/hw/ipath/ipath_intr.c
@@ -38,42 +38,12 @@
38#include "ipath_verbs.h" 38#include "ipath_verbs.h"
39#include "ipath_common.h" 39#include "ipath_common.h"
40 40
41/*
42 * clear (write) a pio buffer, to clear a parity error. This routine
43 * should only be called when in freeze mode, and the buffer should be
44 * canceled afterwards.
45 */
46static void ipath_clrpiobuf(struct ipath_devdata *dd, u32 pnum)
47{
48 u32 __iomem *pbuf;
49 u32 dwcnt; /* dword count to write */
50 if (pnum < dd->ipath_piobcnt2k) {
51 pbuf = (u32 __iomem *) (dd->ipath_pio2kbase + pnum *
52 dd->ipath_palign);
53 dwcnt = dd->ipath_piosize2k >> 2;
54 }
55 else {
56 pbuf = (u32 __iomem *) (dd->ipath_pio4kbase +
57 (pnum - dd->ipath_piobcnt2k) * dd->ipath_4kalign);
58 dwcnt = dd->ipath_piosize4k >> 2;
59 }
60 dev_info(&dd->pcidev->dev,
61 "Rewrite PIO buffer %u, to recover from parity error\n",
62 pnum);
63
64 /* no flush required, since already in freeze */
65 writel(dwcnt + 1, pbuf);
66 while (--dwcnt)
67 writel(0, pbuf++);
68}
69 41
70/* 42/*
71 * Called when we might have an error that is specific to a particular 43 * Called when we might have an error that is specific to a particular
72 * PIO buffer, and may need to cancel that buffer, so it can be re-used. 44 * PIO buffer, and may need to cancel that buffer, so it can be re-used.
73 * If rewrite is true, and bits are set in the sendbufferror registers,
74 * we'll write to the buffer, for error recovery on parity errors.
75 */ 45 */
76void ipath_disarm_senderrbufs(struct ipath_devdata *dd, int rewrite) 46void ipath_disarm_senderrbufs(struct ipath_devdata *dd)
77{ 47{
78 u32 piobcnt; 48 u32 piobcnt;
79 unsigned long sbuf[4]; 49 unsigned long sbuf[4];
@@ -109,11 +79,8 @@ void ipath_disarm_senderrbufs(struct ipath_devdata *dd, int rewrite)
109 } 79 }
110 80
111 for (i = 0; i < piobcnt; i++) 81 for (i = 0; i < piobcnt; i++)
112 if (test_bit(i, sbuf)) { 82 if (test_bit(i, sbuf))
113 if (rewrite)
114 ipath_clrpiobuf(dd, i);
115 ipath_disarm_piobufs(dd, i, 1); 83 ipath_disarm_piobufs(dd, i, 1);
116 }
117 /* ignore armlaunch errs for a bit */ 84 /* ignore armlaunch errs for a bit */
118 dd->ipath_lastcancel = jiffies+3; 85 dd->ipath_lastcancel = jiffies+3;
119 } 86 }
@@ -164,7 +131,7 @@ static u64 handle_e_sum_errs(struct ipath_devdata *dd, ipath_err_t errs)
164{ 131{
165 u64 ignore_this_time = 0; 132 u64 ignore_this_time = 0;
166 133
167 ipath_disarm_senderrbufs(dd, 0); 134 ipath_disarm_senderrbufs(dd);
168 if ((errs & E_SUM_LINK_PKTERRS) && 135 if ((errs & E_SUM_LINK_PKTERRS) &&
169 !(dd->ipath_flags & IPATH_LINKACTIVE)) { 136 !(dd->ipath_flags & IPATH_LINKACTIVE)) {
170 /* 137 /*
@@ -909,8 +876,8 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
909 * processes (causing armlaunch), send errors due to going into freeze mode, 876 * processes (causing armlaunch), send errors due to going into freeze mode,
910 * etc., and try to avoid causing extra interrupts while doing so. 877 * etc., and try to avoid causing extra interrupts while doing so.
911 * Forcibly update the in-memory pioavail register copies after cleanup 878 * Forcibly update the in-memory pioavail register copies after cleanup
912 * because the chip won't do it for anything changing while in freeze mode 879 * because the chip won't do it while in freeze mode (the register values
913 * (we don't want to wait for the next pio buffer state change). 880 * themselves are kept correct).
914 * Make sure that we don't lose any important interrupts by using the chip 881 * Make sure that we don't lose any important interrupts by using the chip
915 * feature that says that writing 0 to a bit in *clear that is set in 882 * feature that says that writing 0 to a bit in *clear that is set in
916 * *status will cause an interrupt to be generated again (if allowed by 883 * *status will cause an interrupt to be generated again (if allowed by
@@ -918,44 +885,23 @@ static int handle_errors(struct ipath_devdata *dd, ipath_err_t errs)
918 */ 885 */
919void ipath_clear_freeze(struct ipath_devdata *dd) 886void ipath_clear_freeze(struct ipath_devdata *dd)
920{ 887{
921 int i, im;
922 u64 val;
923
924 /* disable error interrupts, to avoid confusion */ 888 /* disable error interrupts, to avoid confusion */
925 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 0ULL); 889 ipath_write_kreg(dd, dd->ipath_kregs->kr_errormask, 0ULL);
926 890
927 /* also disable interrupts; errormask is sometimes overwriten */ 891 /* also disable interrupts; errormask is sometimes overwriten */
928 ipath_write_kreg(dd, dd->ipath_kregs->kr_intmask, 0ULL); 892 ipath_write_kreg(dd, dd->ipath_kregs->kr_intmask, 0ULL);
929 893
930 /* 894 ipath_cancel_sends(dd, 1);
931 * clear all sends, because they have may been 895
932 * completed by usercode while in freeze mode, and 896 /* clear the freeze, and be sure chip saw it */
933 * therefore would not be sent, and eventually
934 * might cause the process to run out of bufs
935 */
936 ipath_cancel_sends(dd, 0);
937 ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 897 ipath_write_kreg(dd, dd->ipath_kregs->kr_control,
938 dd->ipath_control); 898 dd->ipath_control);
899 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
939 900
940 /* ensure pio avail updates continue */ 901 /* force in-memory update now we are out of freeze */
941 ipath_force_pio_avail_update(dd); 902 ipath_force_pio_avail_update(dd);
942 903
943 /* 904 /*
944 * We just enabled pioavailupdate, so dma copy is almost certainly
945 * not yet right, so read the registers directly. Similar to init
946 */
947 for (i = 0; i < dd->ipath_pioavregs; i++) {
948 /* deal with 6110 chip bug */
949 im = (i > 3 && (dd->ipath_flags & IPATH_SWAP_PIOBUFS)) ?
950 i ^ 1 : i;
951 val = ipath_read_kreg64(dd, (0x1000 / sizeof(u64)) + im);
952 dd->ipath_pioavailregs_dma[i] = cpu_to_le64(val);
953 dd->ipath_pioavailshadow[i] = val |
954 (~dd->ipath_pioavailkernel[i] <<
955 INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT);
956 }
957
958 /*
959 * force new interrupt if any hwerr, error or interrupt bits are 905 * force new interrupt if any hwerr, error or interrupt bits are
960 * still set, and clear "safe" send packet errors related to freeze 906 * still set, and clear "safe" send packet errors related to freeze
961 * and cancelling sends. Re-enable error interrupts before possible 907 * and cancelling sends. Re-enable error interrupts before possible
@@ -1312,10 +1258,8 @@ irqreturn_t ipath_intr(int irq, void *data)
1312 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 1258 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
1313 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags); 1259 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
1314 1260
1315 if (!(dd->ipath_flags & IPATH_HAS_SEND_DMA)) 1261 /* always process; sdma verbs uses PIO for acks and VL15 */
1316 handle_layer_pioavail(dd); 1262 handle_layer_pioavail(dd);
1317 else
1318 ipath_dbg("unexpected BUFAVAIL intr\n");
1319 } 1263 }
1320 1264
1321 ret = IRQ_HANDLED; 1265 ret = IRQ_HANDLED;
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h
index 202337ae90dc..59a8b254b97f 100644
--- a/drivers/infiniband/hw/ipath/ipath_kernel.h
+++ b/drivers/infiniband/hw/ipath/ipath_kernel.h
@@ -117,6 +117,10 @@ struct ipath_portdata {
117 u16 port_subport_cnt; 117 u16 port_subport_cnt;
118 /* non-zero if port is being shared. */ 118 /* non-zero if port is being shared. */
119 u16 port_subport_id; 119 u16 port_subport_id;
120 /* number of pio bufs for this port (all procs, if shared) */
121 u32 port_piocnt;
122 /* first pio buffer for this port */
123 u32 port_pio_base;
120 /* chip offset of PIO buffers for this port */ 124 /* chip offset of PIO buffers for this port */
121 u32 port_piobufs; 125 u32 port_piobufs;
122 /* how many alloc_pages() chunks in port_rcvegrbuf_pages */ 126 /* how many alloc_pages() chunks in port_rcvegrbuf_pages */
@@ -155,8 +159,8 @@ struct ipath_portdata {
155 /* saved total number of polled urgent packets for poll edge trigger */ 159 /* saved total number of polled urgent packets for poll edge trigger */
156 u32 port_urgent_poll; 160 u32 port_urgent_poll;
157 /* pid of process using this port */ 161 /* pid of process using this port */
158 pid_t port_pid; 162 struct pid *port_pid;
159 pid_t port_subpid[INFINIPATH_MAX_SUBPORT]; 163 struct pid *port_subpid[INFINIPATH_MAX_SUBPORT];
160 /* same size as task_struct .comm[] */ 164 /* same size as task_struct .comm[] */
161 char port_comm[16]; 165 char port_comm[16];
162 /* pkeys set by this use of this port */ 166 /* pkeys set by this use of this port */
@@ -384,6 +388,8 @@ struct ipath_devdata {
384 u32 ipath_lastrpkts; 388 u32 ipath_lastrpkts;
385 /* pio bufs allocated per port */ 389 /* pio bufs allocated per port */
386 u32 ipath_pbufsport; 390 u32 ipath_pbufsport;
391 /* if remainder on bufs/port, ports < extrabuf get 1 extra */
392 u32 ipath_ports_extrabuf;
387 u32 ipath_pioupd_thresh; /* update threshold, some chips */ 393 u32 ipath_pioupd_thresh; /* update threshold, some chips */
388 /* 394 /*
389 * number of ports configured as max; zero is set to number chip 395 * number of ports configured as max; zero is set to number chip
@@ -477,7 +483,7 @@ struct ipath_devdata {
477 483
478 /* SendDMA related entries */ 484 /* SendDMA related entries */
479 spinlock_t ipath_sdma_lock; 485 spinlock_t ipath_sdma_lock;
480 u64 ipath_sdma_status; 486 unsigned long ipath_sdma_status;
481 unsigned long ipath_sdma_abort_jiffies; 487 unsigned long ipath_sdma_abort_jiffies;
482 unsigned long ipath_sdma_abort_intr_timeout; 488 unsigned long ipath_sdma_abort_intr_timeout;
483 unsigned long ipath_sdma_buf_jiffies; 489 unsigned long ipath_sdma_buf_jiffies;
@@ -816,8 +822,8 @@ struct ipath_devdata {
816#define IPATH_SDMA_DISARMED 1 822#define IPATH_SDMA_DISARMED 1
817#define IPATH_SDMA_DISABLED 2 823#define IPATH_SDMA_DISABLED 2
818#define IPATH_SDMA_LAYERBUF 3 824#define IPATH_SDMA_LAYERBUF 3
819#define IPATH_SDMA_RUNNING 62 825#define IPATH_SDMA_RUNNING 30
820#define IPATH_SDMA_SHUTDOWN 63 826#define IPATH_SDMA_SHUTDOWN 31
821 827
822/* bit combinations that correspond to abort states */ 828/* bit combinations that correspond to abort states */
823#define IPATH_SDMA_ABORT_NONE 0 829#define IPATH_SDMA_ABORT_NONE 0
@@ -1011,7 +1017,7 @@ void ipath_get_eeprom_info(struct ipath_devdata *);
1011int ipath_update_eeprom_log(struct ipath_devdata *dd); 1017int ipath_update_eeprom_log(struct ipath_devdata *dd);
1012void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr); 1018void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr);
1013u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg); 1019u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
1014void ipath_disarm_senderrbufs(struct ipath_devdata *, int); 1020void ipath_disarm_senderrbufs(struct ipath_devdata *);
1015void ipath_force_pio_avail_update(struct ipath_devdata *); 1021void ipath_force_pio_avail_update(struct ipath_devdata *);
1016void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev); 1022void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev);
1017 1023
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c
index dd5b6e9d57c2..4715911101e4 100644
--- a/drivers/infiniband/hw/ipath/ipath_qp.c
+++ b/drivers/infiniband/hw/ipath/ipath_qp.c
@@ -242,7 +242,6 @@ static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp)
242{ 242{
243 struct ipath_qp *q, **qpp; 243 struct ipath_qp *q, **qpp;
244 unsigned long flags; 244 unsigned long flags;
245 int fnd = 0;
246 245
247 spin_lock_irqsave(&qpt->lock, flags); 246 spin_lock_irqsave(&qpt->lock, flags);
248 247
@@ -253,51 +252,40 @@ static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp)
253 *qpp = qp->next; 252 *qpp = qp->next;
254 qp->next = NULL; 253 qp->next = NULL;
255 atomic_dec(&qp->refcount); 254 atomic_dec(&qp->refcount);
256 fnd = 1;
257 break; 255 break;
258 } 256 }
259 } 257 }
260 258
261 spin_unlock_irqrestore(&qpt->lock, flags); 259 spin_unlock_irqrestore(&qpt->lock, flags);
262
263 if (!fnd)
264 return;
265
266 free_qpn(qpt, qp->ibqp.qp_num);
267
268 wait_event(qp->wait, !atomic_read(&qp->refcount));
269} 260}
270 261
271/** 262/**
272 * ipath_free_all_qps - remove all QPs from the table 263 * ipath_free_all_qps - check for QPs still in use
273 * @qpt: the QP table to empty 264 * @qpt: the QP table to empty
265 *
266 * There should not be any QPs still in use.
267 * Free memory for table.
274 */ 268 */
275void ipath_free_all_qps(struct ipath_qp_table *qpt) 269unsigned ipath_free_all_qps(struct ipath_qp_table *qpt)
276{ 270{
277 unsigned long flags; 271 unsigned long flags;
278 struct ipath_qp *qp, *nqp; 272 struct ipath_qp *qp;
279 u32 n; 273 u32 n, qp_inuse = 0;
280 274
275 spin_lock_irqsave(&qpt->lock, flags);
281 for (n = 0; n < qpt->max; n++) { 276 for (n = 0; n < qpt->max; n++) {
282 spin_lock_irqsave(&qpt->lock, flags);
283 qp = qpt->table[n]; 277 qp = qpt->table[n];
284 qpt->table[n] = NULL; 278 qpt->table[n] = NULL;
285 spin_unlock_irqrestore(&qpt->lock, flags); 279
286 280 for (; qp; qp = qp->next)
287 while (qp) { 281 qp_inuse++;
288 nqp = qp->next;
289 free_qpn(qpt, qp->ibqp.qp_num);
290 if (!atomic_dec_and_test(&qp->refcount) ||
291 !ipath_destroy_qp(&qp->ibqp))
292 ipath_dbg("QP memory leak!\n");
293 qp = nqp;
294 }
295 } 282 }
283 spin_unlock_irqrestore(&qpt->lock, flags);
296 284
297 for (n = 0; n < ARRAY_SIZE(qpt->map); n++) { 285 for (n = 0; n < ARRAY_SIZE(qpt->map); n++)
298 if (qpt->map[n].page) 286 if (qpt->map[n].page)
299 free_page((unsigned long)qpt->map[n].page); 287 free_page((unsigned long) qpt->map[n].page);
300 } 288 return qp_inuse;
301} 289}
302 290
303/** 291/**
@@ -336,11 +324,12 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
336 qp->remote_qpn = 0; 324 qp->remote_qpn = 0;
337 qp->qkey = 0; 325 qp->qkey = 0;
338 qp->qp_access_flags = 0; 326 qp->qp_access_flags = 0;
339 qp->s_busy = 0; 327 atomic_set(&qp->s_dma_busy, 0);
340 qp->s_flags &= IPATH_S_SIGNAL_REQ_WR; 328 qp->s_flags &= IPATH_S_SIGNAL_REQ_WR;
341 qp->s_hdrwords = 0; 329 qp->s_hdrwords = 0;
342 qp->s_wqe = NULL; 330 qp->s_wqe = NULL;
343 qp->s_pkt_delay = 0; 331 qp->s_pkt_delay = 0;
332 qp->s_draining = 0;
344 qp->s_psn = 0; 333 qp->s_psn = 0;
345 qp->r_psn = 0; 334 qp->r_psn = 0;
346 qp->r_msn = 0; 335 qp->r_msn = 0;
@@ -353,7 +342,8 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
353 } 342 }
354 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; 343 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE;
355 qp->r_nak_state = 0; 344 qp->r_nak_state = 0;
356 qp->r_wrid_valid = 0; 345 qp->r_aflags = 0;
346 qp->r_flags = 0;
357 qp->s_rnr_timeout = 0; 347 qp->s_rnr_timeout = 0;
358 qp->s_head = 0; 348 qp->s_head = 0;
359 qp->s_tail = 0; 349 qp->s_tail = 0;
@@ -361,7 +351,6 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
361 qp->s_last = 0; 351 qp->s_last = 0;
362 qp->s_ssn = 1; 352 qp->s_ssn = 1;
363 qp->s_lsn = 0; 353 qp->s_lsn = 0;
364 qp->s_wait_credit = 0;
365 memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue)); 354 memset(qp->s_ack_queue, 0, sizeof(qp->s_ack_queue));
366 qp->r_head_ack_queue = 0; 355 qp->r_head_ack_queue = 0;
367 qp->s_tail_ack_queue = 0; 356 qp->s_tail_ack_queue = 0;
@@ -370,17 +359,17 @@ static void ipath_reset_qp(struct ipath_qp *qp, enum ib_qp_type type)
370 qp->r_rq.wq->head = 0; 359 qp->r_rq.wq->head = 0;
371 qp->r_rq.wq->tail = 0; 360 qp->r_rq.wq->tail = 0;
372 } 361 }
373 qp->r_reuse_sge = 0;
374} 362}
375 363
376/** 364/**
377 * ipath_error_qp - put a QP into an error state 365 * ipath_error_qp - put a QP into the error state
378 * @qp: the QP to put into an error state 366 * @qp: the QP to put into the error state
379 * @err: the receive completion error to signal if a RWQE is active 367 * @err: the receive completion error to signal if a RWQE is active
380 * 368 *
381 * Flushes both send and receive work queues. 369 * Flushes both send and receive work queues.
382 * Returns true if last WQE event should be generated. 370 * Returns true if last WQE event should be generated.
383 * The QP s_lock should be held and interrupts disabled. 371 * The QP s_lock should be held and interrupts disabled.
372 * If we are already in error state, just return.
384 */ 373 */
385 374
386int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err) 375int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
@@ -389,8 +378,10 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
389 struct ib_wc wc; 378 struct ib_wc wc;
390 int ret = 0; 379 int ret = 0;
391 380
392 ipath_dbg("QP%d/%d in error state (%d)\n", 381 if (qp->state == IB_QPS_ERR)
393 qp->ibqp.qp_num, qp->remote_qpn, err); 382 goto bail;
383
384 qp->state = IB_QPS_ERR;
394 385
395 spin_lock(&dev->pending_lock); 386 spin_lock(&dev->pending_lock);
396 if (!list_empty(&qp->timerwait)) 387 if (!list_empty(&qp->timerwait))
@@ -399,39 +390,21 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
399 list_del_init(&qp->piowait); 390 list_del_init(&qp->piowait);
400 spin_unlock(&dev->pending_lock); 391 spin_unlock(&dev->pending_lock);
401 392
402 wc.vendor_err = 0; 393 /* Schedule the sending tasklet to drain the send work queue. */
403 wc.byte_len = 0; 394 if (qp->s_last != qp->s_head)
404 wc.imm_data = 0; 395 ipath_schedule_send(qp);
396
397 memset(&wc, 0, sizeof(wc));
405 wc.qp = &qp->ibqp; 398 wc.qp = &qp->ibqp;
406 wc.src_qp = 0; 399 wc.opcode = IB_WC_RECV;
407 wc.wc_flags = 0; 400
408 wc.pkey_index = 0; 401 if (test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags)) {
409 wc.slid = 0;
410 wc.sl = 0;
411 wc.dlid_path_bits = 0;
412 wc.port_num = 0;
413 if (qp->r_wrid_valid) {
414 qp->r_wrid_valid = 0;
415 wc.wr_id = qp->r_wr_id; 402 wc.wr_id = qp->r_wr_id;
416 wc.opcode = IB_WC_RECV;
417 wc.status = err; 403 wc.status = err;
418 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); 404 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1);
419 } 405 }
420 wc.status = IB_WC_WR_FLUSH_ERR; 406 wc.status = IB_WC_WR_FLUSH_ERR;
421 407
422 while (qp->s_last != qp->s_head) {
423 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
424
425 wc.wr_id = wqe->wr.wr_id;
426 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
427 if (++qp->s_last >= qp->s_size)
428 qp->s_last = 0;
429 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1);
430 }
431 qp->s_cur = qp->s_tail = qp->s_head;
432 qp->s_hdrwords = 0;
433 qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE;
434
435 if (qp->r_rq.wq) { 408 if (qp->r_rq.wq) {
436 struct ipath_rwq *wq; 409 struct ipath_rwq *wq;
437 u32 head; 410 u32 head;
@@ -447,7 +420,6 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
447 tail = wq->tail; 420 tail = wq->tail;
448 if (tail >= qp->r_rq.size) 421 if (tail >= qp->r_rq.size)
449 tail = 0; 422 tail = 0;
450 wc.opcode = IB_WC_RECV;
451 while (tail != head) { 423 while (tail != head) {
452 wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id; 424 wc.wr_id = get_rwqe_ptr(&qp->r_rq, tail)->wr_id;
453 if (++tail >= qp->r_rq.size) 425 if (++tail >= qp->r_rq.size)
@@ -460,6 +432,7 @@ int ipath_error_qp(struct ipath_qp *qp, enum ib_wc_status err)
460 } else if (qp->ibqp.event_handler) 432 } else if (qp->ibqp.event_handler)
461 ret = 1; 433 ret = 1;
462 434
435bail:
463 return ret; 436 return ret;
464} 437}
465 438
@@ -478,11 +451,10 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
478 struct ipath_ibdev *dev = to_idev(ibqp->device); 451 struct ipath_ibdev *dev = to_idev(ibqp->device);
479 struct ipath_qp *qp = to_iqp(ibqp); 452 struct ipath_qp *qp = to_iqp(ibqp);
480 enum ib_qp_state cur_state, new_state; 453 enum ib_qp_state cur_state, new_state;
481 unsigned long flags;
482 int lastwqe = 0; 454 int lastwqe = 0;
483 int ret; 455 int ret;
484 456
485 spin_lock_irqsave(&qp->s_lock, flags); 457 spin_lock_irq(&qp->s_lock);
486 458
487 cur_state = attr_mask & IB_QP_CUR_STATE ? 459 cur_state = attr_mask & IB_QP_CUR_STATE ?
488 attr->cur_qp_state : qp->state; 460 attr->cur_qp_state : qp->state;
@@ -535,16 +507,42 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
535 507
536 switch (new_state) { 508 switch (new_state) {
537 case IB_QPS_RESET: 509 case IB_QPS_RESET:
510 if (qp->state != IB_QPS_RESET) {
511 qp->state = IB_QPS_RESET;
512 spin_lock(&dev->pending_lock);
513 if (!list_empty(&qp->timerwait))
514 list_del_init(&qp->timerwait);
515 if (!list_empty(&qp->piowait))
516 list_del_init(&qp->piowait);
517 spin_unlock(&dev->pending_lock);
518 qp->s_flags &= ~IPATH_S_ANY_WAIT;
519 spin_unlock_irq(&qp->s_lock);
520 /* Stop the sending tasklet */
521 tasklet_kill(&qp->s_task);
522 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy));
523 spin_lock_irq(&qp->s_lock);
524 }
538 ipath_reset_qp(qp, ibqp->qp_type); 525 ipath_reset_qp(qp, ibqp->qp_type);
539 break; 526 break;
540 527
528 case IB_QPS_SQD:
529 qp->s_draining = qp->s_last != qp->s_cur;
530 qp->state = new_state;
531 break;
532
533 case IB_QPS_SQE:
534 if (qp->ibqp.qp_type == IB_QPT_RC)
535 goto inval;
536 qp->state = new_state;
537 break;
538
541 case IB_QPS_ERR: 539 case IB_QPS_ERR:
542 lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR); 540 lastwqe = ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
543 break; 541 break;
544 542
545 default: 543 default:
544 qp->state = new_state;
546 break; 545 break;
547
548 } 546 }
549 547
550 if (attr_mask & IB_QP_PKEY_INDEX) 548 if (attr_mask & IB_QP_PKEY_INDEX)
@@ -597,8 +595,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
597 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC) 595 if (attr_mask & IB_QP_MAX_QP_RD_ATOMIC)
598 qp->s_max_rd_atomic = attr->max_rd_atomic; 596 qp->s_max_rd_atomic = attr->max_rd_atomic;
599 597
600 qp->state = new_state; 598 spin_unlock_irq(&qp->s_lock);
601 spin_unlock_irqrestore(&qp->s_lock, flags);
602 599
603 if (lastwqe) { 600 if (lastwqe) {
604 struct ib_event ev; 601 struct ib_event ev;
@@ -612,7 +609,7 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
612 goto bail; 609 goto bail;
613 610
614inval: 611inval:
615 spin_unlock_irqrestore(&qp->s_lock, flags); 612 spin_unlock_irq(&qp->s_lock);
616 ret = -EINVAL; 613 ret = -EINVAL;
617 614
618bail: 615bail:
@@ -643,7 +640,7 @@ int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
643 attr->pkey_index = qp->s_pkey_index; 640 attr->pkey_index = qp->s_pkey_index;
644 attr->alt_pkey_index = 0; 641 attr->alt_pkey_index = 0;
645 attr->en_sqd_async_notify = 0; 642 attr->en_sqd_async_notify = 0;
646 attr->sq_draining = 0; 643 attr->sq_draining = qp->s_draining;
647 attr->max_rd_atomic = qp->s_max_rd_atomic; 644 attr->max_rd_atomic = qp->s_max_rd_atomic;
648 attr->max_dest_rd_atomic = qp->r_max_rd_atomic; 645 attr->max_dest_rd_atomic = qp->r_max_rd_atomic;
649 attr->min_rnr_timer = qp->r_min_rnr_timer; 646 attr->min_rnr_timer = qp->r_min_rnr_timer;
@@ -833,6 +830,7 @@ struct ib_qp *ipath_create_qp(struct ib_pd *ibpd,
833 spin_lock_init(&qp->r_rq.lock); 830 spin_lock_init(&qp->r_rq.lock);
834 atomic_set(&qp->refcount, 0); 831 atomic_set(&qp->refcount, 0);
835 init_waitqueue_head(&qp->wait); 832 init_waitqueue_head(&qp->wait);
833 init_waitqueue_head(&qp->wait_dma);
836 tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp); 834 tasklet_init(&qp->s_task, ipath_do_send, (unsigned long)qp);
837 INIT_LIST_HEAD(&qp->piowait); 835 INIT_LIST_HEAD(&qp->piowait);
838 INIT_LIST_HEAD(&qp->timerwait); 836 INIT_LIST_HEAD(&qp->timerwait);
@@ -926,6 +924,7 @@ bail_ip:
926 else 924 else
927 vfree(qp->r_rq.wq); 925 vfree(qp->r_rq.wq);
928 ipath_free_qp(&dev->qp_table, qp); 926 ipath_free_qp(&dev->qp_table, qp);
927 free_qpn(&dev->qp_table, qp->ibqp.qp_num);
929bail_qp: 928bail_qp:
930 kfree(qp); 929 kfree(qp);
931bail_swq: 930bail_swq:
@@ -947,41 +946,44 @@ int ipath_destroy_qp(struct ib_qp *ibqp)
947{ 946{
948 struct ipath_qp *qp = to_iqp(ibqp); 947 struct ipath_qp *qp = to_iqp(ibqp);
949 struct ipath_ibdev *dev = to_idev(ibqp->device); 948 struct ipath_ibdev *dev = to_idev(ibqp->device);
950 unsigned long flags;
951 949
952 spin_lock_irqsave(&qp->s_lock, flags); 950 /* Make sure HW and driver activity is stopped. */
953 qp->state = IB_QPS_ERR; 951 spin_lock_irq(&qp->s_lock);
954 spin_unlock_irqrestore(&qp->s_lock, flags); 952 if (qp->state != IB_QPS_RESET) {
955 spin_lock(&dev->n_qps_lock); 953 qp->state = IB_QPS_RESET;
956 dev->n_qps_allocated--; 954 spin_lock(&dev->pending_lock);
957 spin_unlock(&dev->n_qps_lock); 955 if (!list_empty(&qp->timerwait))
956 list_del_init(&qp->timerwait);
957 if (!list_empty(&qp->piowait))
958 list_del_init(&qp->piowait);
959 spin_unlock(&dev->pending_lock);
960 qp->s_flags &= ~IPATH_S_ANY_WAIT;
961 spin_unlock_irq(&qp->s_lock);
962 /* Stop the sending tasklet */
963 tasklet_kill(&qp->s_task);
964 wait_event(qp->wait_dma, !atomic_read(&qp->s_dma_busy));
965 } else
966 spin_unlock_irq(&qp->s_lock);
958 967
959 /* Stop the sending tasklet. */ 968 ipath_free_qp(&dev->qp_table, qp);
960 tasklet_kill(&qp->s_task);
961 969
962 if (qp->s_tx) { 970 if (qp->s_tx) {
963 atomic_dec(&qp->refcount); 971 atomic_dec(&qp->refcount);
964 if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) 972 if (qp->s_tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF)
965 kfree(qp->s_tx->txreq.map_addr); 973 kfree(qp->s_tx->txreq.map_addr);
974 spin_lock_irq(&dev->pending_lock);
975 list_add(&qp->s_tx->txreq.list, &dev->txreq_free);
976 spin_unlock_irq(&dev->pending_lock);
977 qp->s_tx = NULL;
966 } 978 }
967 979
968 /* Make sure the QP isn't on the timeout list. */ 980 wait_event(qp->wait, !atomic_read(&qp->refcount));
969 spin_lock_irqsave(&dev->pending_lock, flags);
970 if (!list_empty(&qp->timerwait))
971 list_del_init(&qp->timerwait);
972 if (!list_empty(&qp->piowait))
973 list_del_init(&qp->piowait);
974 if (qp->s_tx)
975 list_add(&qp->s_tx->txreq.list, &dev->txreq_free);
976 spin_unlock_irqrestore(&dev->pending_lock, flags);
977 981
978 /* 982 /* all user's cleaned up, mark it available */
979 * Make sure that the QP is not in the QPN table so receive 983 free_qpn(&dev->qp_table, qp->ibqp.qp_num);
980 * interrupts will discard packets for this QP. XXX Also remove QP 984 spin_lock(&dev->n_qps_lock);
981 * from multicast table. 985 dev->n_qps_allocated--;
982 */ 986 spin_unlock(&dev->n_qps_lock);
983 if (atomic_read(&qp->refcount) != 0)
984 ipath_free_qp(&dev->qp_table, qp);
985 987
986 if (qp->ip) 988 if (qp->ip)
987 kref_put(&qp->ip->ref, ipath_release_mmap_info); 989 kref_put(&qp->ip->ref, ipath_release_mmap_info);
@@ -1026,48 +1028,6 @@ bail:
1026} 1028}
1027 1029
1028/** 1030/**
1029 * ipath_sqerror_qp - put a QP's send queue into an error state
1030 * @qp: QP who's send queue will be put into an error state
1031 * @wc: the WC responsible for putting the QP in this state
1032 *
1033 * Flushes the send work queue.
1034 * The QP s_lock should be held and interrupts disabled.
1035 */
1036
1037void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc)
1038{
1039 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
1040 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
1041
1042 ipath_dbg("Send queue error on QP%d/%d: err: %d\n",
1043 qp->ibqp.qp_num, qp->remote_qpn, wc->status);
1044
1045 spin_lock(&dev->pending_lock);
1046 if (!list_empty(&qp->timerwait))
1047 list_del_init(&qp->timerwait);
1048 if (!list_empty(&qp->piowait))
1049 list_del_init(&qp->piowait);
1050 spin_unlock(&dev->pending_lock);
1051
1052 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
1053 if (++qp->s_last >= qp->s_size)
1054 qp->s_last = 0;
1055
1056 wc->status = IB_WC_WR_FLUSH_ERR;
1057
1058 while (qp->s_last != qp->s_head) {
1059 wqe = get_swqe_ptr(qp, qp->s_last);
1060 wc->wr_id = wqe->wr.wr_id;
1061 wc->opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
1062 ipath_cq_enter(to_icq(qp->ibqp.send_cq), wc, 1);
1063 if (++qp->s_last >= qp->s_size)
1064 qp->s_last = 0;
1065 }
1066 qp->s_cur = qp->s_tail = qp->s_head;
1067 qp->state = IB_QPS_SQE;
1068}
1069
1070/**
1071 * ipath_get_credit - flush the send work queue of a QP 1031 * ipath_get_credit - flush the send work queue of a QP
1072 * @qp: the qp who's send work queue to flush 1032 * @qp: the qp who's send work queue to flush
1073 * @aeth: the Acknowledge Extended Transport Header 1033 * @aeth: the Acknowledge Extended Transport Header
@@ -1093,9 +1053,10 @@ void ipath_get_credit(struct ipath_qp *qp, u32 aeth)
1093 } 1053 }
1094 1054
1095 /* Restart sending if it was blocked due to lack of credits. */ 1055 /* Restart sending if it was blocked due to lack of credits. */
1096 if (qp->s_cur != qp->s_head && 1056 if ((qp->s_flags & IPATH_S_WAIT_SSN_CREDIT) &&
1057 qp->s_cur != qp->s_head &&
1097 (qp->s_lsn == (u32) -1 || 1058 (qp->s_lsn == (u32) -1 ||
1098 ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn, 1059 ipath_cmp24(get_swqe_ptr(qp, qp->s_cur)->ssn,
1099 qp->s_lsn + 1) <= 0)) 1060 qp->s_lsn + 1) <= 0))
1100 tasklet_hi_schedule(&qp->s_task); 1061 ipath_schedule_send(qp);
1101} 1062}
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index c405dfba5531..108df667d2ee 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -92,6 +92,10 @@ static int ipath_make_rc_ack(struct ipath_ibdev *dev, struct ipath_qp *qp,
92 u32 bth0; 92 u32 bth0;
93 u32 bth2; 93 u32 bth2;
94 94
95 /* Don't send an ACK if we aren't supposed to. */
96 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
97 goto bail;
98
95 /* header size in 32-bit words LRH+BTH = (8+12)/4. */ 99 /* header size in 32-bit words LRH+BTH = (8+12)/4. */
96 hwords = 5; 100 hwords = 5;
97 101
@@ -238,14 +242,25 @@ int ipath_make_rc_req(struct ipath_qp *qp)
238 ipath_make_rc_ack(dev, qp, ohdr, pmtu)) 242 ipath_make_rc_ack(dev, qp, ohdr, pmtu))
239 goto done; 243 goto done;
240 244
241 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) || 245 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) {
242 qp->s_rnr_timeout || qp->s_wait_credit) 246 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
243 goto bail; 247 goto bail;
248 /* We are in the error state, flush the work request. */
249 if (qp->s_last == qp->s_head)
250 goto bail;
251 /* If DMAs are in progress, we can't flush immediately. */
252 if (atomic_read(&qp->s_dma_busy)) {
253 qp->s_flags |= IPATH_S_WAIT_DMA;
254 goto bail;
255 }
256 wqe = get_swqe_ptr(qp, qp->s_last);
257 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
258 goto done;
259 }
244 260
245 /* Limit the number of packets sent without an ACK. */ 261 /* Leave BUSY set until RNR timeout. */
246 if (ipath_cmp24(qp->s_psn, qp->s_last_psn + IPATH_PSN_CREDIT) > 0) { 262 if (qp->s_rnr_timeout) {
247 qp->s_wait_credit = 1; 263 qp->s_flags |= IPATH_S_WAITING;
248 dev->n_rc_stalls++;
249 goto bail; 264 goto bail;
250 } 265 }
251 266
@@ -257,6 +272,9 @@ int ipath_make_rc_req(struct ipath_qp *qp)
257 wqe = get_swqe_ptr(qp, qp->s_cur); 272 wqe = get_swqe_ptr(qp, qp->s_cur);
258 switch (qp->s_state) { 273 switch (qp->s_state) {
259 default: 274 default:
275 if (!(ib_ipath_state_ops[qp->state] &
276 IPATH_PROCESS_NEXT_SEND_OK))
277 goto bail;
260 /* 278 /*
261 * Resend an old request or start a new one. 279 * Resend an old request or start a new one.
262 * 280 *
@@ -294,8 +312,10 @@ int ipath_make_rc_req(struct ipath_qp *qp)
294 case IB_WR_SEND_WITH_IMM: 312 case IB_WR_SEND_WITH_IMM:
295 /* If no credit, return. */ 313 /* If no credit, return. */
296 if (qp->s_lsn != (u32) -1 && 314 if (qp->s_lsn != (u32) -1 &&
297 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) 315 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) {
316 qp->s_flags |= IPATH_S_WAIT_SSN_CREDIT;
298 goto bail; 317 goto bail;
318 }
299 wqe->lpsn = wqe->psn; 319 wqe->lpsn = wqe->psn;
300 if (len > pmtu) { 320 if (len > pmtu) {
301 wqe->lpsn += (len - 1) / pmtu; 321 wqe->lpsn += (len - 1) / pmtu;
@@ -325,8 +345,10 @@ int ipath_make_rc_req(struct ipath_qp *qp)
325 case IB_WR_RDMA_WRITE_WITH_IMM: 345 case IB_WR_RDMA_WRITE_WITH_IMM:
326 /* If no credit, return. */ 346 /* If no credit, return. */
327 if (qp->s_lsn != (u32) -1 && 347 if (qp->s_lsn != (u32) -1 &&
328 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) 348 ipath_cmp24(wqe->ssn, qp->s_lsn + 1) > 0) {
349 qp->s_flags |= IPATH_S_WAIT_SSN_CREDIT;
329 goto bail; 350 goto bail;
351 }
330 ohdr->u.rc.reth.vaddr = 352 ohdr->u.rc.reth.vaddr =
331 cpu_to_be64(wqe->wr.wr.rdma.remote_addr); 353 cpu_to_be64(wqe->wr.wr.rdma.remote_addr);
332 ohdr->u.rc.reth.rkey = 354 ohdr->u.rc.reth.rkey =
@@ -570,7 +592,11 @@ int ipath_make_rc_req(struct ipath_qp *qp)
570 ipath_make_ruc_header(dev, qp, ohdr, bth0 | (qp->s_state << 24), bth2); 592 ipath_make_ruc_header(dev, qp, ohdr, bth0 | (qp->s_state << 24), bth2);
571done: 593done:
572 ret = 1; 594 ret = 1;
595 goto unlock;
596
573bail: 597bail:
598 qp->s_flags &= ~IPATH_S_BUSY;
599unlock:
574 spin_unlock_irqrestore(&qp->s_lock, flags); 600 spin_unlock_irqrestore(&qp->s_lock, flags);
575 return ret; 601 return ret;
576} 602}
@@ -606,7 +632,11 @@ static void send_rc_ack(struct ipath_qp *qp)
606 632
607 spin_unlock_irqrestore(&qp->s_lock, flags); 633 spin_unlock_irqrestore(&qp->s_lock, flags);
608 634
635 /* Don't try to send ACKs if the link isn't ACTIVE */
609 dd = dev->dd; 636 dd = dev->dd;
637 if (!(dd->ipath_flags & IPATH_LINKACTIVE))
638 goto done;
639
610 piobuf = ipath_getpiobuf(dd, 0, NULL); 640 piobuf = ipath_getpiobuf(dd, 0, NULL);
611 if (!piobuf) { 641 if (!piobuf) {
612 /* 642 /*
@@ -668,15 +698,16 @@ static void send_rc_ack(struct ipath_qp *qp)
668 goto done; 698 goto done;
669 699
670queue_ack: 700queue_ack:
671 dev->n_rc_qacks++; 701 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK) {
672 qp->s_flags |= IPATH_S_ACK_PENDING; 702 dev->n_rc_qacks++;
673 qp->s_nak_state = qp->r_nak_state; 703 qp->s_flags |= IPATH_S_ACK_PENDING;
674 qp->s_ack_psn = qp->r_ack_psn; 704 qp->s_nak_state = qp->r_nak_state;
705 qp->s_ack_psn = qp->r_ack_psn;
706
707 /* Schedule the send tasklet. */
708 ipath_schedule_send(qp);
709 }
675 spin_unlock_irqrestore(&qp->s_lock, flags); 710 spin_unlock_irqrestore(&qp->s_lock, flags);
676
677 /* Call ipath_do_rc_send() in another thread. */
678 tasklet_hi_schedule(&qp->s_task);
679
680done: 711done:
681 return; 712 return;
682} 713}
@@ -735,7 +766,7 @@ static void reset_psn(struct ipath_qp *qp, u32 psn)
735 /* 766 /*
736 * Set the state to restart in the middle of a request. 767 * Set the state to restart in the middle of a request.
737 * Don't change the s_sge, s_cur_sge, or s_cur_size. 768 * Don't change the s_sge, s_cur_sge, or s_cur_size.
738 * See ipath_do_rc_send(). 769 * See ipath_make_rc_req().
739 */ 770 */
740 switch (opcode) { 771 switch (opcode) {
741 case IB_WR_SEND: 772 case IB_WR_SEND:
@@ -771,27 +802,14 @@ done:
771 * 802 *
772 * The QP s_lock should be held and interrupts disabled. 803 * The QP s_lock should be held and interrupts disabled.
773 */ 804 */
774void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc) 805void ipath_restart_rc(struct ipath_qp *qp, u32 psn)
775{ 806{
776 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last); 807 struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last);
777 struct ipath_ibdev *dev; 808 struct ipath_ibdev *dev;
778 809
779 if (qp->s_retry == 0) { 810 if (qp->s_retry == 0) {
780 wc->wr_id = wqe->wr.wr_id; 811 ipath_send_complete(qp, wqe, IB_WC_RETRY_EXC_ERR);
781 wc->status = IB_WC_RETRY_EXC_ERR; 812 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
782 wc->opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
783 wc->vendor_err = 0;
784 wc->byte_len = 0;
785 wc->qp = &qp->ibqp;
786 wc->imm_data = 0;
787 wc->src_qp = qp->remote_qpn;
788 wc->wc_flags = 0;
789 wc->pkey_index = 0;
790 wc->slid = qp->remote_ah_attr.dlid;
791 wc->sl = qp->remote_ah_attr.sl;
792 wc->dlid_path_bits = 0;
793 wc->port_num = 0;
794 ipath_sqerror_qp(qp, wc);
795 goto bail; 813 goto bail;
796 } 814 }
797 qp->s_retry--; 815 qp->s_retry--;
@@ -804,6 +822,8 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
804 spin_lock(&dev->pending_lock); 822 spin_lock(&dev->pending_lock);
805 if (!list_empty(&qp->timerwait)) 823 if (!list_empty(&qp->timerwait))
806 list_del_init(&qp->timerwait); 824 list_del_init(&qp->timerwait);
825 if (!list_empty(&qp->piowait))
826 list_del_init(&qp->piowait);
807 spin_unlock(&dev->pending_lock); 827 spin_unlock(&dev->pending_lock);
808 828
809 if (wqe->wr.opcode == IB_WR_RDMA_READ) 829 if (wqe->wr.opcode == IB_WR_RDMA_READ)
@@ -812,7 +832,7 @@ void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc)
812 dev->n_rc_resends += (qp->s_psn - psn) & IPATH_PSN_MASK; 832 dev->n_rc_resends += (qp->s_psn - psn) & IPATH_PSN_MASK;
813 833
814 reset_psn(qp, psn); 834 reset_psn(qp, psn);
815 tasklet_hi_schedule(&qp->s_task); 835 ipath_schedule_send(qp);
816 836
817bail: 837bail:
818 return; 838 return;
@@ -820,13 +840,7 @@ bail:
820 840
821static inline void update_last_psn(struct ipath_qp *qp, u32 psn) 841static inline void update_last_psn(struct ipath_qp *qp, u32 psn)
822{ 842{
823 if (qp->s_last_psn != psn) { 843 qp->s_last_psn = psn;
824 qp->s_last_psn = psn;
825 if (qp->s_wait_credit) {
826 qp->s_wait_credit = 0;
827 tasklet_hi_schedule(&qp->s_task);
828 }
829 }
830} 844}
831 845
832/** 846/**
@@ -845,6 +859,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
845{ 859{
846 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 860 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
847 struct ib_wc wc; 861 struct ib_wc wc;
862 enum ib_wc_status status;
848 struct ipath_swqe *wqe; 863 struct ipath_swqe *wqe;
849 int ret = 0; 864 int ret = 0;
850 u32 ack_psn; 865 u32 ack_psn;
@@ -909,7 +924,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
909 */ 924 */
910 update_last_psn(qp, wqe->psn - 1); 925 update_last_psn(qp, wqe->psn - 1);
911 /* Retry this request. */ 926 /* Retry this request. */
912 ipath_restart_rc(qp, wqe->psn, &wc); 927 ipath_restart_rc(qp, wqe->psn);
913 /* 928 /*
914 * No need to process the ACK/NAK since we are 929 * No need to process the ACK/NAK since we are
915 * restarting an earlier request. 930 * restarting an earlier request.
@@ -925,32 +940,23 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
925 wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD)) { 940 wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD)) {
926 qp->s_num_rd_atomic--; 941 qp->s_num_rd_atomic--;
927 /* Restart sending task if fence is complete */ 942 /* Restart sending task if fence is complete */
928 if ((qp->s_flags & IPATH_S_FENCE_PENDING) && 943 if (((qp->s_flags & IPATH_S_FENCE_PENDING) &&
929 !qp->s_num_rd_atomic) { 944 !qp->s_num_rd_atomic) ||
930 qp->s_flags &= ~IPATH_S_FENCE_PENDING; 945 qp->s_flags & IPATH_S_RDMAR_PENDING)
931 tasklet_hi_schedule(&qp->s_task); 946 ipath_schedule_send(qp);
932 } else if (qp->s_flags & IPATH_S_RDMAR_PENDING) {
933 qp->s_flags &= ~IPATH_S_RDMAR_PENDING;
934 tasklet_hi_schedule(&qp->s_task);
935 }
936 } 947 }
937 /* Post a send completion queue entry if requested. */ 948 /* Post a send completion queue entry if requested. */
938 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || 949 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) ||
939 (wqe->wr.send_flags & IB_SEND_SIGNALED)) { 950 (wqe->wr.send_flags & IB_SEND_SIGNALED)) {
951 memset(&wc, 0, sizeof wc);
940 wc.wr_id = wqe->wr.wr_id; 952 wc.wr_id = wqe->wr.wr_id;
941 wc.status = IB_WC_SUCCESS; 953 wc.status = IB_WC_SUCCESS;
942 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 954 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
943 wc.vendor_err = 0;
944 wc.byte_len = wqe->length; 955 wc.byte_len = wqe->length;
945 wc.imm_data = 0;
946 wc.qp = &qp->ibqp; 956 wc.qp = &qp->ibqp;
947 wc.src_qp = qp->remote_qpn; 957 wc.src_qp = qp->remote_qpn;
948 wc.wc_flags = 0;
949 wc.pkey_index = 0;
950 wc.slid = qp->remote_ah_attr.dlid; 958 wc.slid = qp->remote_ah_attr.dlid;
951 wc.sl = qp->remote_ah_attr.sl; 959 wc.sl = qp->remote_ah_attr.sl;
952 wc.dlid_path_bits = 0;
953 wc.port_num = 0;
954 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0); 960 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0);
955 } 961 }
956 qp->s_retry = qp->s_retry_cnt; 962 qp->s_retry = qp->s_retry_cnt;
@@ -971,6 +977,8 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
971 } else { 977 } else {
972 if (++qp->s_last >= qp->s_size) 978 if (++qp->s_last >= qp->s_size)
973 qp->s_last = 0; 979 qp->s_last = 0;
980 if (qp->state == IB_QPS_SQD && qp->s_last == qp->s_cur)
981 qp->s_draining = 0;
974 if (qp->s_last == qp->s_tail) 982 if (qp->s_last == qp->s_tail)
975 break; 983 break;
976 wqe = get_swqe_ptr(qp, qp->s_last); 984 wqe = get_swqe_ptr(qp, qp->s_last);
@@ -994,7 +1002,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
994 */ 1002 */
995 if (ipath_cmp24(qp->s_psn, psn) <= 0) { 1003 if (ipath_cmp24(qp->s_psn, psn) <= 0) {
996 reset_psn(qp, psn + 1); 1004 reset_psn(qp, psn + 1);
997 tasklet_hi_schedule(&qp->s_task); 1005 ipath_schedule_send(qp);
998 } 1006 }
999 } else if (ipath_cmp24(qp->s_psn, psn) <= 0) { 1007 } else if (ipath_cmp24(qp->s_psn, psn) <= 0) {
1000 qp->s_state = OP(SEND_LAST); 1008 qp->s_state = OP(SEND_LAST);
@@ -1012,7 +1020,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1012 if (qp->s_last == qp->s_tail) 1020 if (qp->s_last == qp->s_tail)
1013 goto bail; 1021 goto bail;
1014 if (qp->s_rnr_retry == 0) { 1022 if (qp->s_rnr_retry == 0) {
1015 wc.status = IB_WC_RNR_RETRY_EXC_ERR; 1023 status = IB_WC_RNR_RETRY_EXC_ERR;
1016 goto class_b; 1024 goto class_b;
1017 } 1025 }
1018 if (qp->s_rnr_retry_cnt < 7) 1026 if (qp->s_rnr_retry_cnt < 7)
@@ -1033,6 +1041,7 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1033 ib_ipath_rnr_table[(aeth >> IPATH_AETH_CREDIT_SHIFT) & 1041 ib_ipath_rnr_table[(aeth >> IPATH_AETH_CREDIT_SHIFT) &
1034 IPATH_AETH_CREDIT_MASK]; 1042 IPATH_AETH_CREDIT_MASK];
1035 ipath_insert_rnr_queue(qp); 1043 ipath_insert_rnr_queue(qp);
1044 ipath_schedule_send(qp);
1036 goto bail; 1045 goto bail;
1037 1046
1038 case 3: /* NAK */ 1047 case 3: /* NAK */
@@ -1050,37 +1059,25 @@ static int do_rc_ack(struct ipath_qp *qp, u32 aeth, u32 psn, int opcode,
1050 * RDMA READ response which terminates the RDMA 1059 * RDMA READ response which terminates the RDMA
1051 * READ. 1060 * READ.
1052 */ 1061 */
1053 ipath_restart_rc(qp, psn, &wc); 1062 ipath_restart_rc(qp, psn);
1054 break; 1063 break;
1055 1064
1056 case 1: /* Invalid Request */ 1065 case 1: /* Invalid Request */
1057 wc.status = IB_WC_REM_INV_REQ_ERR; 1066 status = IB_WC_REM_INV_REQ_ERR;
1058 dev->n_other_naks++; 1067 dev->n_other_naks++;
1059 goto class_b; 1068 goto class_b;
1060 1069
1061 case 2: /* Remote Access Error */ 1070 case 2: /* Remote Access Error */
1062 wc.status = IB_WC_REM_ACCESS_ERR; 1071 status = IB_WC_REM_ACCESS_ERR;
1063 dev->n_other_naks++; 1072 dev->n_other_naks++;
1064 goto class_b; 1073 goto class_b;
1065 1074
1066 case 3: /* Remote Operation Error */ 1075 case 3: /* Remote Operation Error */
1067 wc.status = IB_WC_REM_OP_ERR; 1076 status = IB_WC_REM_OP_ERR;
1068 dev->n_other_naks++; 1077 dev->n_other_naks++;
1069 class_b: 1078 class_b:
1070 wc.wr_id = wqe->wr.wr_id; 1079 ipath_send_complete(qp, wqe, status);
1071 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 1080 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
1072 wc.vendor_err = 0;
1073 wc.byte_len = 0;
1074 wc.qp = &qp->ibqp;
1075 wc.imm_data = 0;
1076 wc.src_qp = qp->remote_qpn;
1077 wc.wc_flags = 0;
1078 wc.pkey_index = 0;
1079 wc.slid = qp->remote_ah_attr.dlid;
1080 wc.sl = qp->remote_ah_attr.sl;
1081 wc.dlid_path_bits = 0;
1082 wc.port_num = 0;
1083 ipath_sqerror_qp(qp, &wc);
1084 break; 1081 break;
1085 1082
1086 default: 1083 default:
@@ -1126,8 +1123,8 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1126 int header_in_data) 1123 int header_in_data)
1127{ 1124{
1128 struct ipath_swqe *wqe; 1125 struct ipath_swqe *wqe;
1126 enum ib_wc_status status;
1129 unsigned long flags; 1127 unsigned long flags;
1130 struct ib_wc wc;
1131 int diff; 1128 int diff;
1132 u32 pad; 1129 u32 pad;
1133 u32 aeth; 1130 u32 aeth;
@@ -1135,6 +1132,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1135 1132
1136 spin_lock_irqsave(&qp->s_lock, flags); 1133 spin_lock_irqsave(&qp->s_lock, flags);
1137 1134
1135 /* Double check we can process this now that we hold the s_lock. */
1136 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1137 goto ack_done;
1138
1138 /* Ignore invalid responses. */ 1139 /* Ignore invalid responses. */
1139 if (ipath_cmp24(psn, qp->s_next_psn) >= 0) 1140 if (ipath_cmp24(psn, qp->s_next_psn) >= 0)
1140 goto ack_done; 1141 goto ack_done;
@@ -1159,6 +1160,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1159 if (unlikely(qp->s_last == qp->s_tail)) 1160 if (unlikely(qp->s_last == qp->s_tail))
1160 goto ack_done; 1161 goto ack_done;
1161 wqe = get_swqe_ptr(qp, qp->s_last); 1162 wqe = get_swqe_ptr(qp, qp->s_last);
1163 status = IB_WC_SUCCESS;
1162 1164
1163 switch (opcode) { 1165 switch (opcode) {
1164 case OP(ACKNOWLEDGE): 1166 case OP(ACKNOWLEDGE):
@@ -1187,6 +1189,7 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1187 wqe = get_swqe_ptr(qp, qp->s_last); 1189 wqe = get_swqe_ptr(qp, qp->s_last);
1188 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1190 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
1189 goto ack_op_err; 1191 goto ack_op_err;
1192 qp->r_flags &= ~IPATH_R_RDMAR_SEQ;
1190 /* 1193 /*
1191 * If this is a response to a resent RDMA read, we 1194 * If this is a response to a resent RDMA read, we
1192 * have to be careful to copy the data to the right 1195 * have to be careful to copy the data to the right
@@ -1200,7 +1203,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1200 /* no AETH, no ACK */ 1203 /* no AETH, no ACK */
1201 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) { 1204 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) {
1202 dev->n_rdma_seq++; 1205 dev->n_rdma_seq++;
1203 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 1206 if (qp->r_flags & IPATH_R_RDMAR_SEQ)
1207 goto ack_done;
1208 qp->r_flags |= IPATH_R_RDMAR_SEQ;
1209 ipath_restart_rc(qp, qp->s_last_psn + 1);
1204 goto ack_done; 1210 goto ack_done;
1205 } 1211 }
1206 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1212 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
@@ -1261,7 +1267,10 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1261 /* ACKs READ req. */ 1267 /* ACKs READ req. */
1262 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) { 1268 if (unlikely(ipath_cmp24(psn, qp->s_last_psn + 1))) {
1263 dev->n_rdma_seq++; 1269 dev->n_rdma_seq++;
1264 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 1270 if (qp->r_flags & IPATH_R_RDMAR_SEQ)
1271 goto ack_done;
1272 qp->r_flags |= IPATH_R_RDMAR_SEQ;
1273 ipath_restart_rc(qp, qp->s_last_psn + 1);
1265 goto ack_done; 1274 goto ack_done;
1266 } 1275 }
1267 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ)) 1276 if (unlikely(wqe->wr.opcode != IB_WR_RDMA_READ))
@@ -1291,31 +1300,16 @@ static inline void ipath_rc_rcv_resp(struct ipath_ibdev *dev,
1291 goto ack_done; 1300 goto ack_done;
1292 } 1301 }
1293 1302
1294ack_done:
1295 spin_unlock_irqrestore(&qp->s_lock, flags);
1296 goto bail;
1297
1298ack_op_err: 1303ack_op_err:
1299 wc.status = IB_WC_LOC_QP_OP_ERR; 1304 status = IB_WC_LOC_QP_OP_ERR;
1300 goto ack_err; 1305 goto ack_err;
1301 1306
1302ack_len_err: 1307ack_len_err:
1303 wc.status = IB_WC_LOC_LEN_ERR; 1308 status = IB_WC_LOC_LEN_ERR;
1304ack_err: 1309ack_err:
1305 wc.wr_id = wqe->wr.wr_id; 1310 ipath_send_complete(qp, wqe, status);
1306 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 1311 ipath_error_qp(qp, IB_WC_WR_FLUSH_ERR);
1307 wc.vendor_err = 0; 1312ack_done:
1308 wc.byte_len = 0;
1309 wc.imm_data = 0;
1310 wc.qp = &qp->ibqp;
1311 wc.src_qp = qp->remote_qpn;
1312 wc.wc_flags = 0;
1313 wc.pkey_index = 0;
1314 wc.slid = qp->remote_ah_attr.dlid;
1315 wc.sl = qp->remote_ah_attr.sl;
1316 wc.dlid_path_bits = 0;
1317 wc.port_num = 0;
1318 ipath_sqerror_qp(qp, &wc);
1319 spin_unlock_irqrestore(&qp->s_lock, flags); 1313 spin_unlock_irqrestore(&qp->s_lock, flags);
1320bail: 1314bail:
1321 return; 1315 return;
@@ -1384,7 +1378,12 @@ static inline int ipath_rc_rcv_error(struct ipath_ibdev *dev,
1384 psn &= IPATH_PSN_MASK; 1378 psn &= IPATH_PSN_MASK;
1385 e = NULL; 1379 e = NULL;
1386 old_req = 1; 1380 old_req = 1;
1381
1387 spin_lock_irqsave(&qp->s_lock, flags); 1382 spin_lock_irqsave(&qp->s_lock, flags);
1383 /* Double check we can process this now that we hold the s_lock. */
1384 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1385 goto unlock_done;
1386
1388 for (i = qp->r_head_ack_queue; ; i = prev) { 1387 for (i = qp->r_head_ack_queue; ; i = prev) {
1389 if (i == qp->s_tail_ack_queue) 1388 if (i == qp->s_tail_ack_queue)
1390 old_req = 0; 1389 old_req = 0;
@@ -1512,7 +1511,7 @@ static inline int ipath_rc_rcv_error(struct ipath_ibdev *dev,
1512 break; 1511 break;
1513 } 1512 }
1514 qp->r_nak_state = 0; 1513 qp->r_nak_state = 0;
1515 tasklet_hi_schedule(&qp->s_task); 1514 ipath_schedule_send(qp);
1516 1515
1517unlock_done: 1516unlock_done:
1518 spin_unlock_irqrestore(&qp->s_lock, flags); 1517 spin_unlock_irqrestore(&qp->s_lock, flags);
@@ -1523,13 +1522,12 @@ send_ack:
1523 return 0; 1522 return 0;
1524} 1523}
1525 1524
1526static void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err) 1525void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err)
1527{ 1526{
1528 unsigned long flags; 1527 unsigned long flags;
1529 int lastwqe; 1528 int lastwqe;
1530 1529
1531 spin_lock_irqsave(&qp->s_lock, flags); 1530 spin_lock_irqsave(&qp->s_lock, flags);
1532 qp->state = IB_QPS_ERR;
1533 lastwqe = ipath_error_qp(qp, err); 1531 lastwqe = ipath_error_qp(qp, err);
1534 spin_unlock_irqrestore(&qp->s_lock, flags); 1532 spin_unlock_irqrestore(&qp->s_lock, flags);
1535 1533
@@ -1545,18 +1543,15 @@ static void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err)
1545 1543
1546static inline void ipath_update_ack_queue(struct ipath_qp *qp, unsigned n) 1544static inline void ipath_update_ack_queue(struct ipath_qp *qp, unsigned n)
1547{ 1545{
1548 unsigned long flags;
1549 unsigned next; 1546 unsigned next;
1550 1547
1551 next = n + 1; 1548 next = n + 1;
1552 if (next > IPATH_MAX_RDMA_ATOMIC) 1549 if (next > IPATH_MAX_RDMA_ATOMIC)
1553 next = 0; 1550 next = 0;
1554 spin_lock_irqsave(&qp->s_lock, flags);
1555 if (n == qp->s_tail_ack_queue) { 1551 if (n == qp->s_tail_ack_queue) {
1556 qp->s_tail_ack_queue = next; 1552 qp->s_tail_ack_queue = next;
1557 qp->s_ack_state = OP(ACKNOWLEDGE); 1553 qp->s_ack_state = OP(ACKNOWLEDGE);
1558 } 1554 }
1559 spin_unlock_irqrestore(&qp->s_lock, flags);
1560} 1555}
1561 1556
1562/** 1557/**
@@ -1585,6 +1580,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1585 int diff; 1580 int diff;
1586 struct ib_reth *reth; 1581 struct ib_reth *reth;
1587 int header_in_data; 1582 int header_in_data;
1583 unsigned long flags;
1588 1584
1589 /* Validate the SLID. See Ch. 9.6.1.5 */ 1585 /* Validate the SLID. See Ch. 9.6.1.5 */
1590 if (unlikely(be16_to_cpu(hdr->lrh[3]) != qp->remote_ah_attr.dlid)) 1586 if (unlikely(be16_to_cpu(hdr->lrh[3]) != qp->remote_ah_attr.dlid))
@@ -1643,11 +1639,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1643 opcode == OP(SEND_LAST) || 1639 opcode == OP(SEND_LAST) ||
1644 opcode == OP(SEND_LAST_WITH_IMMEDIATE)) 1640 opcode == OP(SEND_LAST_WITH_IMMEDIATE))
1645 break; 1641 break;
1646 nack_inv: 1642 goto nack_inv;
1647 ipath_rc_error(qp, IB_WC_REM_INV_REQ_ERR);
1648 qp->r_nak_state = IB_NAK_INVALID_REQUEST;
1649 qp->r_ack_psn = qp->r_psn;
1650 goto send_ack;
1651 1643
1652 case OP(RDMA_WRITE_FIRST): 1644 case OP(RDMA_WRITE_FIRST):
1653 case OP(RDMA_WRITE_MIDDLE): 1645 case OP(RDMA_WRITE_MIDDLE):
@@ -1673,18 +1665,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1673 break; 1665 break;
1674 } 1666 }
1675 1667
1676 wc.imm_data = 0; 1668 memset(&wc, 0, sizeof wc);
1677 wc.wc_flags = 0;
1678 1669
1679 /* OK, process the packet. */ 1670 /* OK, process the packet. */
1680 switch (opcode) { 1671 switch (opcode) {
1681 case OP(SEND_FIRST): 1672 case OP(SEND_FIRST):
1682 if (!ipath_get_rwqe(qp, 0)) { 1673 if (!ipath_get_rwqe(qp, 0))
1683 rnr_nak: 1674 goto rnr_nak;
1684 qp->r_nak_state = IB_RNR_NAK | qp->r_min_rnr_timer;
1685 qp->r_ack_psn = qp->r_psn;
1686 goto send_ack;
1687 }
1688 qp->r_rcv_len = 0; 1675 qp->r_rcv_len = 0;
1689 /* FALLTHROUGH */ 1676 /* FALLTHROUGH */
1690 case OP(SEND_MIDDLE): 1677 case OP(SEND_MIDDLE):
@@ -1741,20 +1728,19 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1741 goto nack_inv; 1728 goto nack_inv;
1742 ipath_copy_sge(&qp->r_sge, data, tlen); 1729 ipath_copy_sge(&qp->r_sge, data, tlen);
1743 qp->r_msn++; 1730 qp->r_msn++;
1744 if (!qp->r_wrid_valid) 1731 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
1745 break; 1732 break;
1746 qp->r_wrid_valid = 0;
1747 wc.wr_id = qp->r_wr_id; 1733 wc.wr_id = qp->r_wr_id;
1748 wc.status = IB_WC_SUCCESS; 1734 wc.status = IB_WC_SUCCESS;
1749 wc.opcode = IB_WC_RECV; 1735 if (opcode == OP(RDMA_WRITE_LAST_WITH_IMMEDIATE) ||
1750 wc.vendor_err = 0; 1736 opcode == OP(RDMA_WRITE_ONLY_WITH_IMMEDIATE))
1737 wc.opcode = IB_WC_RECV_RDMA_WITH_IMM;
1738 else
1739 wc.opcode = IB_WC_RECV;
1751 wc.qp = &qp->ibqp; 1740 wc.qp = &qp->ibqp;
1752 wc.src_qp = qp->remote_qpn; 1741 wc.src_qp = qp->remote_qpn;
1753 wc.pkey_index = 0;
1754 wc.slid = qp->remote_ah_attr.dlid; 1742 wc.slid = qp->remote_ah_attr.dlid;
1755 wc.sl = qp->remote_ah_attr.sl; 1743 wc.sl = qp->remote_ah_attr.sl;
1756 wc.dlid_path_bits = 0;
1757 wc.port_num = 0;
1758 /* Signal completion event if the solicited bit is set. */ 1744 /* Signal completion event if the solicited bit is set. */
1759 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1745 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
1760 (ohdr->bth[0] & 1746 (ohdr->bth[0] &
@@ -1815,9 +1801,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1815 next = qp->r_head_ack_queue + 1; 1801 next = qp->r_head_ack_queue + 1;
1816 if (next > IPATH_MAX_RDMA_ATOMIC) 1802 if (next > IPATH_MAX_RDMA_ATOMIC)
1817 next = 0; 1803 next = 0;
1804 spin_lock_irqsave(&qp->s_lock, flags);
1805 /* Double check we can process this while holding the s_lock. */
1806 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1807 goto unlock;
1818 if (unlikely(next == qp->s_tail_ack_queue)) { 1808 if (unlikely(next == qp->s_tail_ack_queue)) {
1819 if (!qp->s_ack_queue[next].sent) 1809 if (!qp->s_ack_queue[next].sent)
1820 goto nack_inv; 1810 goto nack_inv_unlck;
1821 ipath_update_ack_queue(qp, next); 1811 ipath_update_ack_queue(qp, next);
1822 } 1812 }
1823 e = &qp->s_ack_queue[qp->r_head_ack_queue]; 1813 e = &qp->s_ack_queue[qp->r_head_ack_queue];
@@ -1838,7 +1828,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1838 ok = ipath_rkey_ok(qp, &e->rdma_sge, len, vaddr, 1828 ok = ipath_rkey_ok(qp, &e->rdma_sge, len, vaddr,
1839 rkey, IB_ACCESS_REMOTE_READ); 1829 rkey, IB_ACCESS_REMOTE_READ);
1840 if (unlikely(!ok)) 1830 if (unlikely(!ok))
1841 goto nack_acc; 1831 goto nack_acc_unlck;
1842 /* 1832 /*
1843 * Update the next expected PSN. We add 1 later 1833 * Update the next expected PSN. We add 1 later
1844 * below, so only add the remainder here. 1834 * below, so only add the remainder here.
@@ -1865,13 +1855,12 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1865 qp->r_psn++; 1855 qp->r_psn++;
1866 qp->r_state = opcode; 1856 qp->r_state = opcode;
1867 qp->r_nak_state = 0; 1857 qp->r_nak_state = 0;
1868 barrier();
1869 qp->r_head_ack_queue = next; 1858 qp->r_head_ack_queue = next;
1870 1859
1871 /* Call ipath_do_rc_send() in another thread. */ 1860 /* Schedule the send tasklet. */
1872 tasklet_hi_schedule(&qp->s_task); 1861 ipath_schedule_send(qp);
1873 1862
1874 goto done; 1863 goto unlock;
1875 } 1864 }
1876 1865
1877 case OP(COMPARE_SWAP): 1866 case OP(COMPARE_SWAP):
@@ -1890,9 +1879,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1890 next = qp->r_head_ack_queue + 1; 1879 next = qp->r_head_ack_queue + 1;
1891 if (next > IPATH_MAX_RDMA_ATOMIC) 1880 if (next > IPATH_MAX_RDMA_ATOMIC)
1892 next = 0; 1881 next = 0;
1882 spin_lock_irqsave(&qp->s_lock, flags);
1883 /* Double check we can process this while holding the s_lock. */
1884 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK))
1885 goto unlock;
1893 if (unlikely(next == qp->s_tail_ack_queue)) { 1886 if (unlikely(next == qp->s_tail_ack_queue)) {
1894 if (!qp->s_ack_queue[next].sent) 1887 if (!qp->s_ack_queue[next].sent)
1895 goto nack_inv; 1888 goto nack_inv_unlck;
1896 ipath_update_ack_queue(qp, next); 1889 ipath_update_ack_queue(qp, next);
1897 } 1890 }
1898 if (!header_in_data) 1891 if (!header_in_data)
@@ -1902,13 +1895,13 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1902 vaddr = ((u64) be32_to_cpu(ateth->vaddr[0]) << 32) | 1895 vaddr = ((u64) be32_to_cpu(ateth->vaddr[0]) << 32) |
1903 be32_to_cpu(ateth->vaddr[1]); 1896 be32_to_cpu(ateth->vaddr[1]);
1904 if (unlikely(vaddr & (sizeof(u64) - 1))) 1897 if (unlikely(vaddr & (sizeof(u64) - 1)))
1905 goto nack_inv; 1898 goto nack_inv_unlck;
1906 rkey = be32_to_cpu(ateth->rkey); 1899 rkey = be32_to_cpu(ateth->rkey);
1907 /* Check rkey & NAK */ 1900 /* Check rkey & NAK */
1908 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, 1901 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge,
1909 sizeof(u64), vaddr, rkey, 1902 sizeof(u64), vaddr, rkey,
1910 IB_ACCESS_REMOTE_ATOMIC))) 1903 IB_ACCESS_REMOTE_ATOMIC)))
1911 goto nack_acc; 1904 goto nack_acc_unlck;
1912 /* Perform atomic OP and save result. */ 1905 /* Perform atomic OP and save result. */
1913 maddr = (atomic64_t *) qp->r_sge.sge.vaddr; 1906 maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
1914 sdata = be64_to_cpu(ateth->swap_data); 1907 sdata = be64_to_cpu(ateth->swap_data);
@@ -1925,13 +1918,12 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1925 qp->r_psn++; 1918 qp->r_psn++;
1926 qp->r_state = opcode; 1919 qp->r_state = opcode;
1927 qp->r_nak_state = 0; 1920 qp->r_nak_state = 0;
1928 barrier();
1929 qp->r_head_ack_queue = next; 1921 qp->r_head_ack_queue = next;
1930 1922
1931 /* Call ipath_do_rc_send() in another thread. */ 1923 /* Schedule the send tasklet. */
1932 tasklet_hi_schedule(&qp->s_task); 1924 ipath_schedule_send(qp);
1933 1925
1934 goto done; 1926 goto unlock;
1935 } 1927 }
1936 1928
1937 default: 1929 default:
@@ -1947,14 +1939,31 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1947 goto send_ack; 1939 goto send_ack;
1948 goto done; 1940 goto done;
1949 1941
1942rnr_nak:
1943 qp->r_nak_state = IB_RNR_NAK | qp->r_min_rnr_timer;
1944 qp->r_ack_psn = qp->r_psn;
1945 goto send_ack;
1946
1947nack_inv_unlck:
1948 spin_unlock_irqrestore(&qp->s_lock, flags);
1949nack_inv:
1950 ipath_rc_error(qp, IB_WC_LOC_QP_OP_ERR);
1951 qp->r_nak_state = IB_NAK_INVALID_REQUEST;
1952 qp->r_ack_psn = qp->r_psn;
1953 goto send_ack;
1954
1955nack_acc_unlck:
1956 spin_unlock_irqrestore(&qp->s_lock, flags);
1950nack_acc: 1957nack_acc:
1951 ipath_rc_error(qp, IB_WC_REM_ACCESS_ERR); 1958 ipath_rc_error(qp, IB_WC_LOC_PROT_ERR);
1952 qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR; 1959 qp->r_nak_state = IB_NAK_REMOTE_ACCESS_ERROR;
1953 qp->r_ack_psn = qp->r_psn; 1960 qp->r_ack_psn = qp->r_psn;
1954
1955send_ack: 1961send_ack:
1956 send_rc_ack(qp); 1962 send_rc_ack(qp);
1963 goto done;
1957 1964
1965unlock:
1966 spin_unlock_irqrestore(&qp->s_lock, flags);
1958done: 1967done:
1959 return; 1968 return;
1960} 1969}
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index 8ac5c1d82ccd..a4b5521567fe 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
@@ -78,6 +78,7 @@ const u32 ib_ipath_rnr_table[32] = {
78 * ipath_insert_rnr_queue - put QP on the RNR timeout list for the device 78 * ipath_insert_rnr_queue - put QP on the RNR timeout list for the device
79 * @qp: the QP 79 * @qp: the QP
80 * 80 *
81 * Called with the QP s_lock held and interrupts disabled.
81 * XXX Use a simple list for now. We might need a priority 82 * XXX Use a simple list for now. We might need a priority
82 * queue if we have lots of QPs waiting for RNR timeouts 83 * queue if we have lots of QPs waiting for RNR timeouts
83 * but that should be rare. 84 * but that should be rare.
@@ -85,9 +86,9 @@ const u32 ib_ipath_rnr_table[32] = {
85void ipath_insert_rnr_queue(struct ipath_qp *qp) 86void ipath_insert_rnr_queue(struct ipath_qp *qp)
86{ 87{
87 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 88 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
88 unsigned long flags;
89 89
90 spin_lock_irqsave(&dev->pending_lock, flags); 90 /* We already did a spin_lock_irqsave(), so just use spin_lock */
91 spin_lock(&dev->pending_lock);
91 if (list_empty(&dev->rnrwait)) 92 if (list_empty(&dev->rnrwait))
92 list_add(&qp->timerwait, &dev->rnrwait); 93 list_add(&qp->timerwait, &dev->rnrwait);
93 else { 94 else {
@@ -109,7 +110,7 @@ void ipath_insert_rnr_queue(struct ipath_qp *qp)
109 nqp->s_rnr_timeout -= qp->s_rnr_timeout; 110 nqp->s_rnr_timeout -= qp->s_rnr_timeout;
110 list_add(&qp->timerwait, l); 111 list_add(&qp->timerwait, l);
111 } 112 }
112 spin_unlock_irqrestore(&dev->pending_lock, flags); 113 spin_unlock(&dev->pending_lock);
113} 114}
114 115
115/** 116/**
@@ -140,20 +141,11 @@ int ipath_init_sge(struct ipath_qp *qp, struct ipath_rwqe *wqe,
140 goto bail; 141 goto bail;
141 142
142bad_lkey: 143bad_lkey:
144 memset(&wc, 0, sizeof(wc));
143 wc.wr_id = wqe->wr_id; 145 wc.wr_id = wqe->wr_id;
144 wc.status = IB_WC_LOC_PROT_ERR; 146 wc.status = IB_WC_LOC_PROT_ERR;
145 wc.opcode = IB_WC_RECV; 147 wc.opcode = IB_WC_RECV;
146 wc.vendor_err = 0;
147 wc.byte_len = 0;
148 wc.imm_data = 0;
149 wc.qp = &qp->ibqp; 148 wc.qp = &qp->ibqp;
150 wc.src_qp = 0;
151 wc.wc_flags = 0;
152 wc.pkey_index = 0;
153 wc.slid = 0;
154 wc.sl = 0;
155 wc.dlid_path_bits = 0;
156 wc.port_num = 0;
157 /* Signal solicited completion event. */ 149 /* Signal solicited completion event. */
158 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); 150 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1);
159 ret = 0; 151 ret = 0;
@@ -194,6 +186,11 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
194 } 186 }
195 187
196 spin_lock_irqsave(&rq->lock, flags); 188 spin_lock_irqsave(&rq->lock, flags);
189 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
190 ret = 0;
191 goto unlock;
192 }
193
197 wq = rq->wq; 194 wq = rq->wq;
198 tail = wq->tail; 195 tail = wq->tail;
199 /* Validate tail before using it since it is user writable. */ 196 /* Validate tail before using it since it is user writable. */
@@ -201,9 +198,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
201 tail = 0; 198 tail = 0;
202 do { 199 do {
203 if (unlikely(tail == wq->head)) { 200 if (unlikely(tail == wq->head)) {
204 spin_unlock_irqrestore(&rq->lock, flags);
205 ret = 0; 201 ret = 0;
206 goto bail; 202 goto unlock;
207 } 203 }
208 /* Make sure entry is read after head index is read. */ 204 /* Make sure entry is read after head index is read. */
209 smp_rmb(); 205 smp_rmb();
@@ -216,7 +212,7 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
216 wq->tail = tail; 212 wq->tail = tail;
217 213
218 ret = 1; 214 ret = 1;
219 qp->r_wrid_valid = 1; 215 set_bit(IPATH_R_WRID_VALID, &qp->r_aflags);
220 if (handler) { 216 if (handler) {
221 u32 n; 217 u32 n;
222 218
@@ -243,8 +239,8 @@ int ipath_get_rwqe(struct ipath_qp *qp, int wr_id_only)
243 goto bail; 239 goto bail;
244 } 240 }
245 } 241 }
242unlock:
246 spin_unlock_irqrestore(&rq->lock, flags); 243 spin_unlock_irqrestore(&rq->lock, flags);
247
248bail: 244bail:
249 return ret; 245 return ret;
250} 246}
@@ -270,38 +266,63 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
270 struct ib_wc wc; 266 struct ib_wc wc;
271 u64 sdata; 267 u64 sdata;
272 atomic64_t *maddr; 268 atomic64_t *maddr;
269 enum ib_wc_status send_status;
273 270
271 /*
272 * Note that we check the responder QP state after
273 * checking the requester's state.
274 */
274 qp = ipath_lookup_qpn(&dev->qp_table, sqp->remote_qpn); 275 qp = ipath_lookup_qpn(&dev->qp_table, sqp->remote_qpn);
275 if (!qp) {
276 dev->n_pkt_drops++;
277 return;
278 }
279 276
280again:
281 spin_lock_irqsave(&sqp->s_lock, flags); 277 spin_lock_irqsave(&sqp->s_lock, flags);
282 278
283 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_SEND_OK) || 279 /* Return if we are already busy processing a work request. */
284 sqp->s_rnr_timeout) { 280 if ((sqp->s_flags & (IPATH_S_BUSY | IPATH_S_ANY_WAIT)) ||
285 spin_unlock_irqrestore(&sqp->s_lock, flags); 281 !(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_OR_FLUSH_SEND))
286 goto done; 282 goto unlock;
287 }
288 283
289 /* Get the next send request. */ 284 sqp->s_flags |= IPATH_S_BUSY;
290 if (sqp->s_last == sqp->s_head) { 285
291 /* Send work queue is empty. */ 286again:
292 spin_unlock_irqrestore(&sqp->s_lock, flags); 287 if (sqp->s_last == sqp->s_head)
293 goto done; 288 goto clr_busy;
289 wqe = get_swqe_ptr(sqp, sqp->s_last);
290
291 /* Return if it is not OK to start a new work reqeust. */
292 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_NEXT_SEND_OK)) {
293 if (!(ib_ipath_state_ops[sqp->state] & IPATH_FLUSH_SEND))
294 goto clr_busy;
295 /* We are in the error state, flush the work request. */
296 send_status = IB_WC_WR_FLUSH_ERR;
297 goto flush_send;
294 } 298 }
295 299
296 /* 300 /*
297 * We can rely on the entry not changing without the s_lock 301 * We can rely on the entry not changing without the s_lock
298 * being held until we update s_last. 302 * being held until we update s_last.
303 * We increment s_cur to indicate s_last is in progress.
299 */ 304 */
300 wqe = get_swqe_ptr(sqp, sqp->s_last); 305 if (sqp->s_last == sqp->s_cur) {
306 if (++sqp->s_cur >= sqp->s_size)
307 sqp->s_cur = 0;
308 }
301 spin_unlock_irqrestore(&sqp->s_lock, flags); 309 spin_unlock_irqrestore(&sqp->s_lock, flags);
302 310
303 wc.wc_flags = 0; 311 if (!qp || !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
304 wc.imm_data = 0; 312 dev->n_pkt_drops++;
313 /*
314 * For RC, the requester would timeout and retry so
315 * shortcut the timeouts and just signal too many retries.
316 */
317 if (sqp->ibqp.qp_type == IB_QPT_RC)
318 send_status = IB_WC_RETRY_EXC_ERR;
319 else
320 send_status = IB_WC_SUCCESS;
321 goto serr;
322 }
323
324 memset(&wc, 0, sizeof wc);
325 send_status = IB_WC_SUCCESS;
305 326
306 sqp->s_sge.sge = wqe->sg_list[0]; 327 sqp->s_sge.sge = wqe->sg_list[0];
307 sqp->s_sge.sg_list = wqe->sg_list + 1; 328 sqp->s_sge.sg_list = wqe->sg_list + 1;
@@ -313,75 +334,33 @@ again:
313 wc.imm_data = wqe->wr.ex.imm_data; 334 wc.imm_data = wqe->wr.ex.imm_data;
314 /* FALLTHROUGH */ 335 /* FALLTHROUGH */
315 case IB_WR_SEND: 336 case IB_WR_SEND:
316 if (!ipath_get_rwqe(qp, 0)) { 337 if (!ipath_get_rwqe(qp, 0))
317 rnr_nak: 338 goto rnr_nak;
318 /* Handle RNR NAK */
319 if (qp->ibqp.qp_type == IB_QPT_UC)
320 goto send_comp;
321 if (sqp->s_rnr_retry == 0) {
322 wc.status = IB_WC_RNR_RETRY_EXC_ERR;
323 goto err;
324 }
325 if (sqp->s_rnr_retry_cnt < 7)
326 sqp->s_rnr_retry--;
327 dev->n_rnr_naks++;
328 sqp->s_rnr_timeout =
329 ib_ipath_rnr_table[qp->r_min_rnr_timer];
330 ipath_insert_rnr_queue(sqp);
331 goto done;
332 }
333 break; 339 break;
334 340
335 case IB_WR_RDMA_WRITE_WITH_IMM: 341 case IB_WR_RDMA_WRITE_WITH_IMM:
336 if (unlikely(!(qp->qp_access_flags & 342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
337 IB_ACCESS_REMOTE_WRITE))) { 343 goto inv_err;
338 wc.status = IB_WC_REM_INV_REQ_ERR;
339 goto err;
340 }
341 wc.wc_flags = IB_WC_WITH_IMM; 344 wc.wc_flags = IB_WC_WITH_IMM;
342 wc.imm_data = wqe->wr.ex.imm_data; 345 wc.imm_data = wqe->wr.ex.imm_data;
343 if (!ipath_get_rwqe(qp, 1)) 346 if (!ipath_get_rwqe(qp, 1))
344 goto rnr_nak; 347 goto rnr_nak;
345 /* FALLTHROUGH */ 348 /* FALLTHROUGH */
346 case IB_WR_RDMA_WRITE: 349 case IB_WR_RDMA_WRITE:
347 if (unlikely(!(qp->qp_access_flags & 350 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
348 IB_ACCESS_REMOTE_WRITE))) { 351 goto inv_err;
349 wc.status = IB_WC_REM_INV_REQ_ERR;
350 goto err;
351 }
352 if (wqe->length == 0) 352 if (wqe->length == 0)
353 break; 353 break;
354 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length, 354 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, wqe->length,
355 wqe->wr.wr.rdma.remote_addr, 355 wqe->wr.wr.rdma.remote_addr,
356 wqe->wr.wr.rdma.rkey, 356 wqe->wr.wr.rdma.rkey,
357 IB_ACCESS_REMOTE_WRITE))) { 357 IB_ACCESS_REMOTE_WRITE)))
358 acc_err: 358 goto acc_err;
359 wc.status = IB_WC_REM_ACCESS_ERR;
360 err:
361 wc.wr_id = wqe->wr.wr_id;
362 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
363 wc.vendor_err = 0;
364 wc.byte_len = 0;
365 wc.qp = &sqp->ibqp;
366 wc.src_qp = sqp->remote_qpn;
367 wc.pkey_index = 0;
368 wc.slid = sqp->remote_ah_attr.dlid;
369 wc.sl = sqp->remote_ah_attr.sl;
370 wc.dlid_path_bits = 0;
371 wc.port_num = 0;
372 spin_lock_irqsave(&sqp->s_lock, flags);
373 ipath_sqerror_qp(sqp, &wc);
374 spin_unlock_irqrestore(&sqp->s_lock, flags);
375 goto done;
376 }
377 break; 359 break;
378 360
379 case IB_WR_RDMA_READ: 361 case IB_WR_RDMA_READ:
380 if (unlikely(!(qp->qp_access_flags & 362 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_READ)))
381 IB_ACCESS_REMOTE_READ))) { 363 goto inv_err;
382 wc.status = IB_WC_REM_INV_REQ_ERR;
383 goto err;
384 }
385 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length, 364 if (unlikely(!ipath_rkey_ok(qp, &sqp->s_sge, wqe->length,
386 wqe->wr.wr.rdma.remote_addr, 365 wqe->wr.wr.rdma.remote_addr,
387 wqe->wr.wr.rdma.rkey, 366 wqe->wr.wr.rdma.rkey,
@@ -394,11 +373,8 @@ again:
394 373
395 case IB_WR_ATOMIC_CMP_AND_SWP: 374 case IB_WR_ATOMIC_CMP_AND_SWP:
396 case IB_WR_ATOMIC_FETCH_AND_ADD: 375 case IB_WR_ATOMIC_FETCH_AND_ADD:
397 if (unlikely(!(qp->qp_access_flags & 376 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_ATOMIC)))
398 IB_ACCESS_REMOTE_ATOMIC))) { 377 goto inv_err;
399 wc.status = IB_WC_REM_INV_REQ_ERR;
400 goto err;
401 }
402 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64), 378 if (unlikely(!ipath_rkey_ok(qp, &qp->r_sge, sizeof(u64),
403 wqe->wr.wr.atomic.remote_addr, 379 wqe->wr.wr.atomic.remote_addr,
404 wqe->wr.wr.atomic.rkey, 380 wqe->wr.wr.atomic.rkey,
@@ -415,7 +391,8 @@ again:
415 goto send_comp; 391 goto send_comp;
416 392
417 default: 393 default:
418 goto done; 394 send_status = IB_WC_LOC_QP_OP_ERR;
395 goto serr;
419 } 396 }
420 397
421 sge = &sqp->s_sge.sge; 398 sge = &sqp->s_sge.sge;
@@ -448,8 +425,7 @@ again:
448 sqp->s_len -= len; 425 sqp->s_len -= len;
449 } 426 }
450 427
451 if (wqe->wr.opcode == IB_WR_RDMA_WRITE || 428 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
452 wqe->wr.opcode == IB_WR_RDMA_READ)
453 goto send_comp; 429 goto send_comp;
454 430
455 if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM) 431 if (wqe->wr.opcode == IB_WR_RDMA_WRITE_WITH_IMM)
@@ -458,32 +434,89 @@ again:
458 wc.opcode = IB_WC_RECV; 434 wc.opcode = IB_WC_RECV;
459 wc.wr_id = qp->r_wr_id; 435 wc.wr_id = qp->r_wr_id;
460 wc.status = IB_WC_SUCCESS; 436 wc.status = IB_WC_SUCCESS;
461 wc.vendor_err = 0;
462 wc.byte_len = wqe->length; 437 wc.byte_len = wqe->length;
463 wc.qp = &qp->ibqp; 438 wc.qp = &qp->ibqp;
464 wc.src_qp = qp->remote_qpn; 439 wc.src_qp = qp->remote_qpn;
465 wc.pkey_index = 0;
466 wc.slid = qp->remote_ah_attr.dlid; 440 wc.slid = qp->remote_ah_attr.dlid;
467 wc.sl = qp->remote_ah_attr.sl; 441 wc.sl = qp->remote_ah_attr.sl;
468 wc.dlid_path_bits = 0;
469 wc.port_num = 1; 442 wc.port_num = 1;
470 /* Signal completion event if the solicited bit is set. */ 443 /* Signal completion event if the solicited bit is set. */
471 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 444 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
472 wqe->wr.send_flags & IB_SEND_SOLICITED); 445 wqe->wr.send_flags & IB_SEND_SOLICITED);
473 446
474send_comp: 447send_comp:
448 spin_lock_irqsave(&sqp->s_lock, flags);
449flush_send:
475 sqp->s_rnr_retry = sqp->s_rnr_retry_cnt; 450 sqp->s_rnr_retry = sqp->s_rnr_retry_cnt;
476 ipath_send_complete(sqp, wqe, IB_WC_SUCCESS); 451 ipath_send_complete(sqp, wqe, send_status);
477 goto again; 452 goto again;
478 453
454rnr_nak:
455 /* Handle RNR NAK */
456 if (qp->ibqp.qp_type == IB_QPT_UC)
457 goto send_comp;
458 /*
459 * Note: we don't need the s_lock held since the BUSY flag
460 * makes this single threaded.
461 */
462 if (sqp->s_rnr_retry == 0) {
463 send_status = IB_WC_RNR_RETRY_EXC_ERR;
464 goto serr;
465 }
466 if (sqp->s_rnr_retry_cnt < 7)
467 sqp->s_rnr_retry--;
468 spin_lock_irqsave(&sqp->s_lock, flags);
469 if (!(ib_ipath_state_ops[sqp->state] & IPATH_PROCESS_RECV_OK))
470 goto clr_busy;
471 sqp->s_flags |= IPATH_S_WAITING;
472 dev->n_rnr_naks++;
473 sqp->s_rnr_timeout = ib_ipath_rnr_table[qp->r_min_rnr_timer];
474 ipath_insert_rnr_queue(sqp);
475 goto clr_busy;
476
477inv_err:
478 send_status = IB_WC_REM_INV_REQ_ERR;
479 wc.status = IB_WC_LOC_QP_OP_ERR;
480 goto err;
481
482acc_err:
483 send_status = IB_WC_REM_ACCESS_ERR;
484 wc.status = IB_WC_LOC_PROT_ERR;
485err:
486 /* responder goes to error state */
487 ipath_rc_error(qp, wc.status);
488
489serr:
490 spin_lock_irqsave(&sqp->s_lock, flags);
491 ipath_send_complete(sqp, wqe, send_status);
492 if (sqp->ibqp.qp_type == IB_QPT_RC) {
493 int lastwqe = ipath_error_qp(sqp, IB_WC_WR_FLUSH_ERR);
494
495 sqp->s_flags &= ~IPATH_S_BUSY;
496 spin_unlock_irqrestore(&sqp->s_lock, flags);
497 if (lastwqe) {
498 struct ib_event ev;
499
500 ev.device = sqp->ibqp.device;
501 ev.element.qp = &sqp->ibqp;
502 ev.event = IB_EVENT_QP_LAST_WQE_REACHED;
503 sqp->ibqp.event_handler(&ev, sqp->ibqp.qp_context);
504 }
505 goto done;
506 }
507clr_busy:
508 sqp->s_flags &= ~IPATH_S_BUSY;
509unlock:
510 spin_unlock_irqrestore(&sqp->s_lock, flags);
479done: 511done:
480 if (atomic_dec_and_test(&qp->refcount)) 512 if (qp && atomic_dec_and_test(&qp->refcount))
481 wake_up(&qp->wait); 513 wake_up(&qp->wait);
482} 514}
483 515
484static void want_buffer(struct ipath_devdata *dd) 516static void want_buffer(struct ipath_devdata *dd, struct ipath_qp *qp)
485{ 517{
486 if (!(dd->ipath_flags & IPATH_HAS_SEND_DMA)) { 518 if (!(dd->ipath_flags & IPATH_HAS_SEND_DMA) ||
519 qp->ibqp.qp_type == IB_QPT_SMI) {
487 unsigned long flags; 520 unsigned long flags;
488 521
489 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags); 522 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
@@ -501,26 +534,36 @@ static void want_buffer(struct ipath_devdata *dd)
501 * @dev: the device we ran out of buffers on 534 * @dev: the device we ran out of buffers on
502 * 535 *
503 * Called when we run out of PIO buffers. 536 * Called when we run out of PIO buffers.
537 * If we are now in the error state, return zero to flush the
538 * send work request.
504 */ 539 */
505static void ipath_no_bufs_available(struct ipath_qp *qp, 540static int ipath_no_bufs_available(struct ipath_qp *qp,
506 struct ipath_ibdev *dev) 541 struct ipath_ibdev *dev)
507{ 542{
508 unsigned long flags; 543 unsigned long flags;
544 int ret = 1;
509 545
510 /* 546 /*
511 * Note that as soon as want_buffer() is called and 547 * Note that as soon as want_buffer() is called and
512 * possibly before it returns, ipath_ib_piobufavail() 548 * possibly before it returns, ipath_ib_piobufavail()
513 * could be called. If we are still in the tasklet function, 549 * could be called. Therefore, put QP on the piowait list before
514 * tasklet_hi_schedule() will not call us until the next time 550 * enabling the PIO avail interrupt.
515 * tasklet_hi_schedule() is called.
516 * We leave the busy flag set so that another post send doesn't
517 * try to put the same QP on the piowait list again.
518 */ 551 */
519 spin_lock_irqsave(&dev->pending_lock, flags); 552 spin_lock_irqsave(&qp->s_lock, flags);
520 list_add_tail(&qp->piowait, &dev->piowait); 553 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) {
521 spin_unlock_irqrestore(&dev->pending_lock, flags); 554 dev->n_piowait++;
522 want_buffer(dev->dd); 555 qp->s_flags |= IPATH_S_WAITING;
523 dev->n_piowait++; 556 qp->s_flags &= ~IPATH_S_BUSY;
557 spin_lock(&dev->pending_lock);
558 if (list_empty(&qp->piowait))
559 list_add_tail(&qp->piowait, &dev->piowait);
560 spin_unlock(&dev->pending_lock);
561 } else
562 ret = 0;
563 spin_unlock_irqrestore(&qp->s_lock, flags);
564 if (ret)
565 want_buffer(dev->dd, qp);
566 return ret;
524} 567}
525 568
526/** 569/**
@@ -596,15 +639,13 @@ void ipath_do_send(unsigned long data)
596 struct ipath_qp *qp = (struct ipath_qp *)data; 639 struct ipath_qp *qp = (struct ipath_qp *)data;
597 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 640 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
598 int (*make_req)(struct ipath_qp *qp); 641 int (*make_req)(struct ipath_qp *qp);
599 642 unsigned long flags;
600 if (test_and_set_bit(IPATH_S_BUSY, &qp->s_busy))
601 goto bail;
602 643
603 if ((qp->ibqp.qp_type == IB_QPT_RC || 644 if ((qp->ibqp.qp_type == IB_QPT_RC ||
604 qp->ibqp.qp_type == IB_QPT_UC) && 645 qp->ibqp.qp_type == IB_QPT_UC) &&
605 qp->remote_ah_attr.dlid == dev->dd->ipath_lid) { 646 qp->remote_ah_attr.dlid == dev->dd->ipath_lid) {
606 ipath_ruc_loopback(qp); 647 ipath_ruc_loopback(qp);
607 goto clear; 648 goto bail;
608 } 649 }
609 650
610 if (qp->ibqp.qp_type == IB_QPT_RC) 651 if (qp->ibqp.qp_type == IB_QPT_RC)
@@ -614,6 +655,19 @@ void ipath_do_send(unsigned long data)
614 else 655 else
615 make_req = ipath_make_ud_req; 656 make_req = ipath_make_ud_req;
616 657
658 spin_lock_irqsave(&qp->s_lock, flags);
659
660 /* Return if we are already busy processing a work request. */
661 if ((qp->s_flags & (IPATH_S_BUSY | IPATH_S_ANY_WAIT)) ||
662 !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND)) {
663 spin_unlock_irqrestore(&qp->s_lock, flags);
664 goto bail;
665 }
666
667 qp->s_flags |= IPATH_S_BUSY;
668
669 spin_unlock_irqrestore(&qp->s_lock, flags);
670
617again: 671again:
618 /* Check for a constructed packet to be sent. */ 672 /* Check for a constructed packet to be sent. */
619 if (qp->s_hdrwords != 0) { 673 if (qp->s_hdrwords != 0) {
@@ -623,8 +677,8 @@ again:
623 */ 677 */
624 if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords, 678 if (ipath_verbs_send(qp, &qp->s_hdr, qp->s_hdrwords,
625 qp->s_cur_sge, qp->s_cur_size)) { 679 qp->s_cur_sge, qp->s_cur_size)) {
626 ipath_no_bufs_available(qp, dev); 680 if (ipath_no_bufs_available(qp, dev))
627 goto bail; 681 goto bail;
628 } 682 }
629 dev->n_unicast_xmit++; 683 dev->n_unicast_xmit++;
630 /* Record that we sent the packet and s_hdr is empty. */ 684 /* Record that we sent the packet and s_hdr is empty. */
@@ -633,16 +687,20 @@ again:
633 687
634 if (make_req(qp)) 688 if (make_req(qp))
635 goto again; 689 goto again;
636clear: 690
637 clear_bit(IPATH_S_BUSY, &qp->s_busy);
638bail:; 691bail:;
639} 692}
640 693
694/*
695 * This should be called with s_lock held.
696 */
641void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe, 697void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe,
642 enum ib_wc_status status) 698 enum ib_wc_status status)
643{ 699{
644 unsigned long flags; 700 u32 old_last, last;
645 u32 last; 701
702 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_OR_FLUSH_SEND))
703 return;
646 704
647 /* See ch. 11.2.4.1 and 10.7.3.1 */ 705 /* See ch. 11.2.4.1 and 10.7.3.1 */
648 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) || 706 if (!(qp->s_flags & IPATH_S_SIGNAL_REQ_WR) ||
@@ -650,27 +708,25 @@ void ipath_send_complete(struct ipath_qp *qp, struct ipath_swqe *wqe,
650 status != IB_WC_SUCCESS) { 708 status != IB_WC_SUCCESS) {
651 struct ib_wc wc; 709 struct ib_wc wc;
652 710
711 memset(&wc, 0, sizeof wc);
653 wc.wr_id = wqe->wr.wr_id; 712 wc.wr_id = wqe->wr.wr_id;
654 wc.status = status; 713 wc.status = status;
655 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; 714 wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode];
656 wc.vendor_err = 0;
657 wc.byte_len = wqe->length;
658 wc.imm_data = 0;
659 wc.qp = &qp->ibqp; 715 wc.qp = &qp->ibqp;
660 wc.src_qp = 0; 716 if (status == IB_WC_SUCCESS)
661 wc.wc_flags = 0; 717 wc.byte_len = wqe->length;
662 wc.pkey_index = 0; 718 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc,
663 wc.slid = 0; 719 status != IB_WC_SUCCESS);
664 wc.sl = 0;
665 wc.dlid_path_bits = 0;
666 wc.port_num = 0;
667 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 0);
668 } 720 }
669 721
670 spin_lock_irqsave(&qp->s_lock, flags); 722 old_last = last = qp->s_last;
671 last = qp->s_last;
672 if (++last >= qp->s_size) 723 if (++last >= qp->s_size)
673 last = 0; 724 last = 0;
674 qp->s_last = last; 725 qp->s_last = last;
675 spin_unlock_irqrestore(&qp->s_lock, flags); 726 if (qp->s_cur == old_last)
727 qp->s_cur = last;
728 if (qp->s_tail == old_last)
729 qp->s_tail = last;
730 if (qp->state == IB_QPS_SQD && last == qp->s_cur)
731 qp->s_draining = 0;
676} 732}
diff --git a/drivers/infiniband/hw/ipath/ipath_sdma.c b/drivers/infiniband/hw/ipath/ipath_sdma.c
index 1974df7a9f78..3697449c1ba4 100644
--- a/drivers/infiniband/hw/ipath/ipath_sdma.c
+++ b/drivers/infiniband/hw/ipath/ipath_sdma.c
@@ -308,13 +308,15 @@ static void sdma_abort_task(unsigned long opaque)
308 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags); 308 spin_unlock_irqrestore(&dd->ipath_sdma_lock, flags);
309 309
310 /* 310 /*
311 * Don't restart sdma here. Wait until link is up to ACTIVE. 311 * Don't restart sdma here (with the exception
312 * VL15 MADs used to bring the link up use PIO, and multiple 312 * below). Wait until link is up to ACTIVE. VL15 MADs
313 * link transitions otherwise cause the sdma engine to be 313 * used to bring the link up use PIO, and multiple link
314 * transitions otherwise cause the sdma engine to be
314 * stopped and started multiple times. 315 * stopped and started multiple times.
315 * The disable is done here, including the shadow, so the 316 * The disable is done here, including the shadow,
316 * state is kept consistent. 317 * so the state is kept consistent.
317 * See ipath_restart_sdma() for the actual starting of sdma. 318 * See ipath_restart_sdma() for the actual starting
319 * of sdma.
318 */ 320 */
319 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags); 321 spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags);
320 dd->ipath_sendctrl &= ~INFINIPATH_S_SDMAENABLE; 322 dd->ipath_sendctrl &= ~INFINIPATH_S_SDMAENABLE;
@@ -326,6 +328,13 @@ static void sdma_abort_task(unsigned long opaque)
326 /* make sure I see next message */ 328 /* make sure I see next message */
327 dd->ipath_sdma_abort_jiffies = 0; 329 dd->ipath_sdma_abort_jiffies = 0;
328 330
331 /*
332 * Not everything that takes SDMA offline is a link
333 * status change. If the link was up, restart SDMA.
334 */
335 if (dd->ipath_flags & IPATH_LINKACTIVE)
336 ipath_restart_sdma(dd);
337
329 goto done; 338 goto done;
330 } 339 }
331 340
@@ -427,7 +436,12 @@ int setup_sdma(struct ipath_devdata *dd)
427 goto done; 436 goto done;
428 } 437 }
429 438
430 dd->ipath_sdma_status = 0; 439 /*
440 * Set initial status as if we had been up, then gone down.
441 * This lets initial start on transition to ACTIVE be the
442 * same as restart after link flap.
443 */
444 dd->ipath_sdma_status = IPATH_SDMA_ABORT_ABORTED;
431 dd->ipath_sdma_abort_jiffies = 0; 445 dd->ipath_sdma_abort_jiffies = 0;
432 dd->ipath_sdma_generation = 0; 446 dd->ipath_sdma_generation = 0;
433 dd->ipath_sdma_descq_tail = 0; 447 dd->ipath_sdma_descq_tail = 0;
@@ -449,16 +463,19 @@ int setup_sdma(struct ipath_devdata *dd)
449 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmaheadaddr, 463 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmaheadaddr,
450 dd->ipath_sdma_head_phys); 464 dd->ipath_sdma_head_phys);
451 465
452 /* Reserve all the former "kernel" piobufs */ 466 /*
453 n = dd->ipath_piobcnt2k + dd->ipath_piobcnt4k - dd->ipath_pioreserved; 467 * Reserve all the former "kernel" piobufs, using high number range
454 for (i = dd->ipath_lastport_piobuf; i < n; ++i) { 468 * so we get as many 4K buffers as possible
469 */
470 n = dd->ipath_piobcnt2k + dd->ipath_piobcnt4k;
471 i = dd->ipath_lastport_piobuf + dd->ipath_pioreserved;
472 ipath_chg_pioavailkernel(dd, i, n - i , 0);
473 for (; i < n; ++i) {
455 unsigned word = i / 64; 474 unsigned word = i / 64;
456 unsigned bit = i & 63; 475 unsigned bit = i & 63;
457 BUG_ON(word >= 3); 476 BUG_ON(word >= 3);
458 senddmabufmask[word] |= 1ULL << bit; 477 senddmabufmask[word] |= 1ULL << bit;
459 } 478 }
460 ipath_chg_pioavailkernel(dd, dd->ipath_lastport_piobuf,
461 n - dd->ipath_lastport_piobuf, 0);
462 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmabufmask0, 479 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmabufmask0,
463 senddmabufmask[0]); 480 senddmabufmask[0]);
464 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmabufmask1, 481 ipath_write_kreg(dd, dd->ipath_kregs->kr_senddmabufmask1,
@@ -615,6 +632,9 @@ void ipath_restart_sdma(struct ipath_devdata *dd)
615 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); 632 ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch);
616 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags); 633 spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags);
617 634
635 /* notify upper layers */
636 ipath_ib_piobufavail(dd->verbs_dev);
637
618bail: 638bail:
619 return; 639 return;
620} 640}
diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c
index bfe8926b5514..7fd18e833907 100644
--- a/drivers/infiniband/hw/ipath/ipath_uc.c
+++ b/drivers/infiniband/hw/ipath/ipath_uc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008 QLogic Corporation. All rights reserved.
3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved. 3 * Copyright (c) 2005, 2006 PathScale, Inc. All rights reserved.
4 * 4 *
5 * This software is available to you under a choice of one of two 5 * This software is available to you under a choice of one of two
@@ -47,14 +47,30 @@ int ipath_make_uc_req(struct ipath_qp *qp)
47{ 47{
48 struct ipath_other_headers *ohdr; 48 struct ipath_other_headers *ohdr;
49 struct ipath_swqe *wqe; 49 struct ipath_swqe *wqe;
50 unsigned long flags;
50 u32 hwords; 51 u32 hwords;
51 u32 bth0; 52 u32 bth0;
52 u32 len; 53 u32 len;
53 u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu); 54 u32 pmtu = ib_mtu_enum_to_int(qp->path_mtu);
54 int ret = 0; 55 int ret = 0;
55 56
56 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) 57 spin_lock_irqsave(&qp->s_lock, flags);
58
59 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)) {
60 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
61 goto bail;
62 /* We are in the error state, flush the work request. */
63 if (qp->s_last == qp->s_head)
64 goto bail;
65 /* If DMAs are in progress, we can't flush immediately. */
66 if (atomic_read(&qp->s_dma_busy)) {
67 qp->s_flags |= IPATH_S_WAIT_DMA;
68 goto bail;
69 }
70 wqe = get_swqe_ptr(qp, qp->s_last);
71 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
57 goto done; 72 goto done;
73 }
58 74
59 ohdr = &qp->s_hdr.u.oth; 75 ohdr = &qp->s_hdr.u.oth;
60 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH) 76 if (qp->remote_ah_attr.ah_flags & IB_AH_GRH)
@@ -69,9 +85,12 @@ int ipath_make_uc_req(struct ipath_qp *qp)
69 qp->s_wqe = NULL; 85 qp->s_wqe = NULL;
70 switch (qp->s_state) { 86 switch (qp->s_state) {
71 default: 87 default:
88 if (!(ib_ipath_state_ops[qp->state] &
89 IPATH_PROCESS_NEXT_SEND_OK))
90 goto bail;
72 /* Check if send work queue is empty. */ 91 /* Check if send work queue is empty. */
73 if (qp->s_cur == qp->s_head) 92 if (qp->s_cur == qp->s_head)
74 goto done; 93 goto bail;
75 /* 94 /*
76 * Start a new request. 95 * Start a new request.
77 */ 96 */
@@ -134,7 +153,7 @@ int ipath_make_uc_req(struct ipath_qp *qp)
134 break; 153 break;
135 154
136 default: 155 default:
137 goto done; 156 goto bail;
138 } 157 }
139 break; 158 break;
140 159
@@ -194,9 +213,14 @@ int ipath_make_uc_req(struct ipath_qp *qp)
194 ipath_make_ruc_header(to_idev(qp->ibqp.device), 213 ipath_make_ruc_header(to_idev(qp->ibqp.device),
195 qp, ohdr, bth0 | (qp->s_state << 24), 214 qp, ohdr, bth0 | (qp->s_state << 24),
196 qp->s_next_psn++ & IPATH_PSN_MASK); 215 qp->s_next_psn++ & IPATH_PSN_MASK);
216done:
197 ret = 1; 217 ret = 1;
218 goto unlock;
198 219
199done: 220bail:
221 qp->s_flags &= ~IPATH_S_BUSY;
222unlock:
223 spin_unlock_irqrestore(&qp->s_lock, flags);
200 return ret; 224 return ret;
201} 225}
202 226
@@ -258,8 +282,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
258 */ 282 */
259 opcode = be32_to_cpu(ohdr->bth[0]) >> 24; 283 opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
260 284
261 wc.imm_data = 0; 285 memset(&wc, 0, sizeof wc);
262 wc.wc_flags = 0;
263 286
264 /* Compare the PSN verses the expected PSN. */ 287 /* Compare the PSN verses the expected PSN. */
265 if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) { 288 if (unlikely(ipath_cmp24(psn, qp->r_psn) != 0)) {
@@ -322,8 +345,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
322 case OP(SEND_ONLY): 345 case OP(SEND_ONLY):
323 case OP(SEND_ONLY_WITH_IMMEDIATE): 346 case OP(SEND_ONLY_WITH_IMMEDIATE):
324 send_first: 347 send_first:
325 if (qp->r_reuse_sge) { 348 if (qp->r_flags & IPATH_R_REUSE_SGE) {
326 qp->r_reuse_sge = 0; 349 qp->r_flags &= ~IPATH_R_REUSE_SGE;
327 qp->r_sge = qp->s_rdma_read_sge; 350 qp->r_sge = qp->s_rdma_read_sge;
328 } else if (!ipath_get_rwqe(qp, 0)) { 351 } else if (!ipath_get_rwqe(qp, 0)) {
329 dev->n_pkt_drops++; 352 dev->n_pkt_drops++;
@@ -340,13 +363,13 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
340 case OP(SEND_MIDDLE): 363 case OP(SEND_MIDDLE):
341 /* Check for invalid length PMTU or posted rwqe len. */ 364 /* Check for invalid length PMTU or posted rwqe len. */
342 if (unlikely(tlen != (hdrsize + pmtu + 4))) { 365 if (unlikely(tlen != (hdrsize + pmtu + 4))) {
343 qp->r_reuse_sge = 1; 366 qp->r_flags |= IPATH_R_REUSE_SGE;
344 dev->n_pkt_drops++; 367 dev->n_pkt_drops++;
345 goto done; 368 goto done;
346 } 369 }
347 qp->r_rcv_len += pmtu; 370 qp->r_rcv_len += pmtu;
348 if (unlikely(qp->r_rcv_len > qp->r_len)) { 371 if (unlikely(qp->r_rcv_len > qp->r_len)) {
349 qp->r_reuse_sge = 1; 372 qp->r_flags |= IPATH_R_REUSE_SGE;
350 dev->n_pkt_drops++; 373 dev->n_pkt_drops++;
351 goto done; 374 goto done;
352 } 375 }
@@ -372,7 +395,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
372 /* Check for invalid length. */ 395 /* Check for invalid length. */
373 /* XXX LAST len should be >= 1 */ 396 /* XXX LAST len should be >= 1 */
374 if (unlikely(tlen < (hdrsize + pad + 4))) { 397 if (unlikely(tlen < (hdrsize + pad + 4))) {
375 qp->r_reuse_sge = 1; 398 qp->r_flags |= IPATH_R_REUSE_SGE;
376 dev->n_pkt_drops++; 399 dev->n_pkt_drops++;
377 goto done; 400 goto done;
378 } 401 }
@@ -380,7 +403,7 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
380 tlen -= (hdrsize + pad + 4); 403 tlen -= (hdrsize + pad + 4);
381 wc.byte_len = tlen + qp->r_rcv_len; 404 wc.byte_len = tlen + qp->r_rcv_len;
382 if (unlikely(wc.byte_len > qp->r_len)) { 405 if (unlikely(wc.byte_len > qp->r_len)) {
383 qp->r_reuse_sge = 1; 406 qp->r_flags |= IPATH_R_REUSE_SGE;
384 dev->n_pkt_drops++; 407 dev->n_pkt_drops++;
385 goto done; 408 goto done;
386 } 409 }
@@ -390,14 +413,10 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
390 wc.wr_id = qp->r_wr_id; 413 wc.wr_id = qp->r_wr_id;
391 wc.status = IB_WC_SUCCESS; 414 wc.status = IB_WC_SUCCESS;
392 wc.opcode = IB_WC_RECV; 415 wc.opcode = IB_WC_RECV;
393 wc.vendor_err = 0;
394 wc.qp = &qp->ibqp; 416 wc.qp = &qp->ibqp;
395 wc.src_qp = qp->remote_qpn; 417 wc.src_qp = qp->remote_qpn;
396 wc.pkey_index = 0;
397 wc.slid = qp->remote_ah_attr.dlid; 418 wc.slid = qp->remote_ah_attr.dlid;
398 wc.sl = qp->remote_ah_attr.sl; 419 wc.sl = qp->remote_ah_attr.sl;
399 wc.dlid_path_bits = 0;
400 wc.port_num = 0;
401 /* Signal completion event if the solicited bit is set. */ 420 /* Signal completion event if the solicited bit is set. */
402 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 421 ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
403 (ohdr->bth[0] & 422 (ohdr->bth[0] &
@@ -488,8 +507,8 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
488 dev->n_pkt_drops++; 507 dev->n_pkt_drops++;
489 goto done; 508 goto done;
490 } 509 }
491 if (qp->r_reuse_sge) 510 if (qp->r_flags & IPATH_R_REUSE_SGE)
492 qp->r_reuse_sge = 0; 511 qp->r_flags &= ~IPATH_R_REUSE_SGE;
493 else if (!ipath_get_rwqe(qp, 1)) { 512 else if (!ipath_get_rwqe(qp, 1)) {
494 dev->n_pkt_drops++; 513 dev->n_pkt_drops++;
495 goto done; 514 goto done;
diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c
index 8b6a261c89e3..77ca8ca74e78 100644
--- a/drivers/infiniband/hw/ipath/ipath_ud.c
+++ b/drivers/infiniband/hw/ipath/ipath_ud.c
@@ -65,9 +65,9 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
65 u32 length; 65 u32 length;
66 66
67 qp = ipath_lookup_qpn(&dev->qp_table, swqe->wr.wr.ud.remote_qpn); 67 qp = ipath_lookup_qpn(&dev->qp_table, swqe->wr.wr.ud.remote_qpn);
68 if (!qp) { 68 if (!qp || !(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_RECV_OK)) {
69 dev->n_pkt_drops++; 69 dev->n_pkt_drops++;
70 goto send_comp; 70 goto done;
71 } 71 }
72 72
73 rsge.sg_list = NULL; 73 rsge.sg_list = NULL;
@@ -91,14 +91,12 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
91 * present on the wire. 91 * present on the wire.
92 */ 92 */
93 length = swqe->length; 93 length = swqe->length;
94 memset(&wc, 0, sizeof wc);
94 wc.byte_len = length + sizeof(struct ib_grh); 95 wc.byte_len = length + sizeof(struct ib_grh);
95 96
96 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) { 97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
97 wc.wc_flags = IB_WC_WITH_IMM; 98 wc.wc_flags = IB_WC_WITH_IMM;
98 wc.imm_data = swqe->wr.ex.imm_data; 99 wc.imm_data = swqe->wr.ex.imm_data;
99 } else {
100 wc.wc_flags = 0;
101 wc.imm_data = 0;
102 } 100 }
103 101
104 /* 102 /*
@@ -229,7 +227,6 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
229 } 227 }
230 wc.status = IB_WC_SUCCESS; 228 wc.status = IB_WC_SUCCESS;
231 wc.opcode = IB_WC_RECV; 229 wc.opcode = IB_WC_RECV;
232 wc.vendor_err = 0;
233 wc.qp = &qp->ibqp; 230 wc.qp = &qp->ibqp;
234 wc.src_qp = sqp->ibqp.qp_num; 231 wc.src_qp = sqp->ibqp.qp_num;
235 /* XXX do we know which pkey matched? Only needed for GSI. */ 232 /* XXX do we know which pkey matched? Only needed for GSI. */
@@ -248,8 +245,7 @@ drop:
248 kfree(rsge.sg_list); 245 kfree(rsge.sg_list);
249 if (atomic_dec_and_test(&qp->refcount)) 246 if (atomic_dec_and_test(&qp->refcount))
250 wake_up(&qp->wait); 247 wake_up(&qp->wait);
251send_comp: 248done:;
252 ipath_send_complete(sqp, swqe, IB_WC_SUCCESS);
253} 249}
254 250
255/** 251/**
@@ -264,6 +260,7 @@ int ipath_make_ud_req(struct ipath_qp *qp)
264 struct ipath_other_headers *ohdr; 260 struct ipath_other_headers *ohdr;
265 struct ib_ah_attr *ah_attr; 261 struct ib_ah_attr *ah_attr;
266 struct ipath_swqe *wqe; 262 struct ipath_swqe *wqe;
263 unsigned long flags;
267 u32 nwords; 264 u32 nwords;
268 u32 extra_bytes; 265 u32 extra_bytes;
269 u32 bth0; 266 u32 bth0;
@@ -271,13 +268,30 @@ int ipath_make_ud_req(struct ipath_qp *qp)
271 u16 lid; 268 u16 lid;
272 int ret = 0; 269 int ret = 0;
273 270
274 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK))) 271 spin_lock_irqsave(&qp->s_lock, flags);
275 goto bail; 272
273 if (!(ib_ipath_state_ops[qp->state] & IPATH_PROCESS_NEXT_SEND_OK)) {
274 if (!(ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND))
275 goto bail;
276 /* We are in the error state, flush the work request. */
277 if (qp->s_last == qp->s_head)
278 goto bail;
279 /* If DMAs are in progress, we can't flush immediately. */
280 if (atomic_read(&qp->s_dma_busy)) {
281 qp->s_flags |= IPATH_S_WAIT_DMA;
282 goto bail;
283 }
284 wqe = get_swqe_ptr(qp, qp->s_last);
285 ipath_send_complete(qp, wqe, IB_WC_WR_FLUSH_ERR);
286 goto done;
287 }
276 288
277 if (qp->s_cur == qp->s_head) 289 if (qp->s_cur == qp->s_head)
278 goto bail; 290 goto bail;
279 291
280 wqe = get_swqe_ptr(qp, qp->s_cur); 292 wqe = get_swqe_ptr(qp, qp->s_cur);
293 if (++qp->s_cur >= qp->s_size)
294 qp->s_cur = 0;
281 295
282 /* Construct the header. */ 296 /* Construct the header. */
283 ah_attr = &to_iah(wqe->wr.wr.ud.ah)->attr; 297 ah_attr = &to_iah(wqe->wr.wr.ud.ah)->attr;
@@ -288,10 +302,23 @@ int ipath_make_ud_req(struct ipath_qp *qp)
288 dev->n_unicast_xmit++; 302 dev->n_unicast_xmit++;
289 } else { 303 } else {
290 dev->n_unicast_xmit++; 304 dev->n_unicast_xmit++;
291 lid = ah_attr->dlid & 305 lid = ah_attr->dlid & ~((1 << dev->dd->ipath_lmc) - 1);
292 ~((1 << dev->dd->ipath_lmc) - 1);
293 if (unlikely(lid == dev->dd->ipath_lid)) { 306 if (unlikely(lid == dev->dd->ipath_lid)) {
307 /*
308 * If DMAs are in progress, we can't generate
309 * a completion for the loopback packet since
310 * it would be out of order.
311 * XXX Instead of waiting, we could queue a
312 * zero length descriptor so we get a callback.
313 */
314 if (atomic_read(&qp->s_dma_busy)) {
315 qp->s_flags |= IPATH_S_WAIT_DMA;
316 goto bail;
317 }
318 spin_unlock_irqrestore(&qp->s_lock, flags);
294 ipath_ud_loopback(qp, wqe); 319 ipath_ud_loopback(qp, wqe);
320 spin_lock_irqsave(&qp->s_lock, flags);
321 ipath_send_complete(qp, wqe, IB_WC_SUCCESS);
295 goto done; 322 goto done;
296 } 323 }
297 } 324 }
@@ -368,11 +395,13 @@ int ipath_make_ud_req(struct ipath_qp *qp)
368 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num); 395 ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
369 396
370done: 397done:
371 if (++qp->s_cur >= qp->s_size)
372 qp->s_cur = 0;
373 ret = 1; 398 ret = 1;
399 goto unlock;
374 400
375bail: 401bail:
402 qp->s_flags &= ~IPATH_S_BUSY;
403unlock:
404 spin_unlock_irqrestore(&qp->s_lock, flags);
376 return ret; 405 return ret;
377} 406}
378 407
@@ -506,8 +535,8 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
506 /* 535 /*
507 * Get the next work request entry to find where to put the data. 536 * Get the next work request entry to find where to put the data.
508 */ 537 */
509 if (qp->r_reuse_sge) 538 if (qp->r_flags & IPATH_R_REUSE_SGE)
510 qp->r_reuse_sge = 0; 539 qp->r_flags &= ~IPATH_R_REUSE_SGE;
511 else if (!ipath_get_rwqe(qp, 0)) { 540 else if (!ipath_get_rwqe(qp, 0)) {
512 /* 541 /*
513 * Count VL15 packets dropped due to no receive buffer. 542 * Count VL15 packets dropped due to no receive buffer.
@@ -523,7 +552,7 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
523 } 552 }
524 /* Silently drop packets which are too big. */ 553 /* Silently drop packets which are too big. */
525 if (wc.byte_len > qp->r_len) { 554 if (wc.byte_len > qp->r_len) {
526 qp->r_reuse_sge = 1; 555 qp->r_flags |= IPATH_R_REUSE_SGE;
527 dev->n_pkt_drops++; 556 dev->n_pkt_drops++;
528 goto bail; 557 goto bail;
529 } 558 }
@@ -535,7 +564,8 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
535 ipath_skip_sge(&qp->r_sge, sizeof(struct ib_grh)); 564 ipath_skip_sge(&qp->r_sge, sizeof(struct ib_grh));
536 ipath_copy_sge(&qp->r_sge, data, 565 ipath_copy_sge(&qp->r_sge, data,
537 wc.byte_len - sizeof(struct ib_grh)); 566 wc.byte_len - sizeof(struct ib_grh));
538 qp->r_wrid_valid = 0; 567 if (!test_and_clear_bit(IPATH_R_WRID_VALID, &qp->r_aflags))
568 goto bail;
539 wc.wr_id = qp->r_wr_id; 569 wc.wr_id = qp->r_wr_id;
540 wc.status = IB_WC_SUCCESS; 570 wc.status = IB_WC_SUCCESS;
541 wc.opcode = IB_WC_RECV; 571 wc.opcode = IB_WC_RECV;
diff --git a/drivers/infiniband/hw/ipath/ipath_user_sdma.h b/drivers/infiniband/hw/ipath/ipath_user_sdma.h
index e70946c1428c..fc76316c4a58 100644
--- a/drivers/infiniband/hw/ipath/ipath_user_sdma.h
+++ b/drivers/infiniband/hw/ipath/ipath_user_sdma.h
@@ -45,8 +45,6 @@ int ipath_user_sdma_writev(struct ipath_devdata *dd,
45int ipath_user_sdma_make_progress(struct ipath_devdata *dd, 45int ipath_user_sdma_make_progress(struct ipath_devdata *dd,
46 struct ipath_user_sdma_queue *pq); 46 struct ipath_user_sdma_queue *pq);
47 47
48int ipath_user_sdma_pkt_sent(const struct ipath_user_sdma_queue *pq,
49 u32 counter);
50void ipath_user_sdma_queue_drain(struct ipath_devdata *dd, 48void ipath_user_sdma_queue_drain(struct ipath_devdata *dd,
51 struct ipath_user_sdma_queue *pq); 49 struct ipath_user_sdma_queue *pq);
52 50
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index e63927cce5b5..e0ec540042bf 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -111,16 +111,24 @@ static unsigned int ib_ipath_disable_sma;
111module_param_named(disable_sma, ib_ipath_disable_sma, uint, S_IWUSR | S_IRUGO); 111module_param_named(disable_sma, ib_ipath_disable_sma, uint, S_IWUSR | S_IRUGO);
112MODULE_PARM_DESC(disable_sma, "Disable the SMA"); 112MODULE_PARM_DESC(disable_sma, "Disable the SMA");
113 113
114/*
115 * Note that it is OK to post send work requests in the SQE and ERR
116 * states; ipath_do_send() will process them and generate error
117 * completions as per IB 1.2 C10-96.
118 */
114const int ib_ipath_state_ops[IB_QPS_ERR + 1] = { 119const int ib_ipath_state_ops[IB_QPS_ERR + 1] = {
115 [IB_QPS_RESET] = 0, 120 [IB_QPS_RESET] = 0,
116 [IB_QPS_INIT] = IPATH_POST_RECV_OK, 121 [IB_QPS_INIT] = IPATH_POST_RECV_OK,
117 [IB_QPS_RTR] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK, 122 [IB_QPS_RTR] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK,
118 [IB_QPS_RTS] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK | 123 [IB_QPS_RTS] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
119 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK, 124 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK |
125 IPATH_PROCESS_NEXT_SEND_OK,
120 [IB_QPS_SQD] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK | 126 [IB_QPS_SQD] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
121 IPATH_POST_SEND_OK, 127 IPATH_POST_SEND_OK | IPATH_PROCESS_SEND_OK,
122 [IB_QPS_SQE] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK, 128 [IB_QPS_SQE] = IPATH_POST_RECV_OK | IPATH_PROCESS_RECV_OK |
123 [IB_QPS_ERR] = 0, 129 IPATH_POST_SEND_OK | IPATH_FLUSH_SEND,
130 [IB_QPS_ERR] = IPATH_POST_RECV_OK | IPATH_FLUSH_RECV |
131 IPATH_POST_SEND_OK | IPATH_FLUSH_SEND,
124}; 132};
125 133
126struct ipath_ucontext { 134struct ipath_ucontext {
@@ -230,18 +238,6 @@ void ipath_skip_sge(struct ipath_sge_state *ss, u32 length)
230 } 238 }
231} 239}
232 240
233static void ipath_flush_wqe(struct ipath_qp *qp, struct ib_send_wr *wr)
234{
235 struct ib_wc wc;
236
237 memset(&wc, 0, sizeof(wc));
238 wc.wr_id = wr->wr_id;
239 wc.status = IB_WC_WR_FLUSH_ERR;
240 wc.opcode = ib_ipath_wc_opcode[wr->opcode];
241 wc.qp = &qp->ibqp;
242 ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1);
243}
244
245/* 241/*
246 * Count the number of DMA descriptors needed to send length bytes of data. 242 * Count the number of DMA descriptors needed to send length bytes of data.
247 * Don't modify the ipath_sge_state to get the count. 243 * Don't modify the ipath_sge_state to get the count.
@@ -347,14 +343,8 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr)
347 spin_lock_irqsave(&qp->s_lock, flags); 343 spin_lock_irqsave(&qp->s_lock, flags);
348 344
349 /* Check that state is OK to post send. */ 345 /* Check that state is OK to post send. */
350 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_POST_SEND_OK))) { 346 if (unlikely(!(ib_ipath_state_ops[qp->state] & IPATH_POST_SEND_OK)))
351 if (qp->state != IB_QPS_SQE && qp->state != IB_QPS_ERR) 347 goto bail_inval;
352 goto bail_inval;
353 /* C10-96 says generate a flushed completion entry. */
354 ipath_flush_wqe(qp, wr);
355 ret = 0;
356 goto bail;
357 }
358 348
359 /* IB spec says that num_sge == 0 is OK. */ 349 /* IB spec says that num_sge == 0 is OK. */
360 if (wr->num_sge > qp->s_max_sge) 350 if (wr->num_sge > qp->s_max_sge)
@@ -396,7 +386,6 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr)
396 386
397 wqe = get_swqe_ptr(qp, qp->s_head); 387 wqe = get_swqe_ptr(qp, qp->s_head);
398 wqe->wr = *wr; 388 wqe->wr = *wr;
399 wqe->ssn = qp->s_ssn++;
400 wqe->length = 0; 389 wqe->length = 0;
401 if (wr->num_sge) { 390 if (wr->num_sge) {
402 acc = wr->opcode >= IB_WR_RDMA_READ ? 391 acc = wr->opcode >= IB_WR_RDMA_READ ?
@@ -422,6 +411,7 @@ static int ipath_post_one_send(struct ipath_qp *qp, struct ib_send_wr *wr)
422 goto bail_inval; 411 goto bail_inval;
423 } else if (wqe->length > to_idev(qp->ibqp.device)->dd->ipath_ibmtu) 412 } else if (wqe->length > to_idev(qp->ibqp.device)->dd->ipath_ibmtu)
424 goto bail_inval; 413 goto bail_inval;
414 wqe->ssn = qp->s_ssn++;
425 qp->s_head = next; 415 qp->s_head = next;
426 416
427 ret = 0; 417 ret = 0;
@@ -677,6 +667,7 @@ bail:;
677static void ipath_ib_timer(struct ipath_ibdev *dev) 667static void ipath_ib_timer(struct ipath_ibdev *dev)
678{ 668{
679 struct ipath_qp *resend = NULL; 669 struct ipath_qp *resend = NULL;
670 struct ipath_qp *rnr = NULL;
680 struct list_head *last; 671 struct list_head *last;
681 struct ipath_qp *qp; 672 struct ipath_qp *qp;
682 unsigned long flags; 673 unsigned long flags;
@@ -703,7 +694,9 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
703 if (--qp->s_rnr_timeout == 0) { 694 if (--qp->s_rnr_timeout == 0) {
704 do { 695 do {
705 list_del_init(&qp->timerwait); 696 list_del_init(&qp->timerwait);
706 tasklet_hi_schedule(&qp->s_task); 697 qp->timer_next = rnr;
698 rnr = qp;
699 atomic_inc(&qp->refcount);
707 if (list_empty(last)) 700 if (list_empty(last))
708 break; 701 break;
709 qp = list_entry(last->next, struct ipath_qp, 702 qp = list_entry(last->next, struct ipath_qp,
@@ -743,13 +736,15 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
743 spin_unlock_irqrestore(&dev->pending_lock, flags); 736 spin_unlock_irqrestore(&dev->pending_lock, flags);
744 737
745 /* XXX What if timer fires again while this is running? */ 738 /* XXX What if timer fires again while this is running? */
746 for (qp = resend; qp != NULL; qp = qp->timer_next) { 739 while (resend != NULL) {
747 struct ib_wc wc; 740 qp = resend;
741 resend = qp->timer_next;
748 742
749 spin_lock_irqsave(&qp->s_lock, flags); 743 spin_lock_irqsave(&qp->s_lock, flags);
750 if (qp->s_last != qp->s_tail && qp->state == IB_QPS_RTS) { 744 if (qp->s_last != qp->s_tail &&
745 ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK) {
751 dev->n_timeouts++; 746 dev->n_timeouts++;
752 ipath_restart_rc(qp, qp->s_last_psn + 1, &wc); 747 ipath_restart_rc(qp, qp->s_last_psn + 1);
753 } 748 }
754 spin_unlock_irqrestore(&qp->s_lock, flags); 749 spin_unlock_irqrestore(&qp->s_lock, flags);
755 750
@@ -757,6 +752,19 @@ static void ipath_ib_timer(struct ipath_ibdev *dev)
757 if (atomic_dec_and_test(&qp->refcount)) 752 if (atomic_dec_and_test(&qp->refcount))
758 wake_up(&qp->wait); 753 wake_up(&qp->wait);
759 } 754 }
755 while (rnr != NULL) {
756 qp = rnr;
757 rnr = qp->timer_next;
758
759 spin_lock_irqsave(&qp->s_lock, flags);
760 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)
761 ipath_schedule_send(qp);
762 spin_unlock_irqrestore(&qp->s_lock, flags);
763
764 /* Notify ipath_destroy_qp() if it is waiting. */
765 if (atomic_dec_and_test(&qp->refcount))
766 wake_up(&qp->wait);
767 }
760} 768}
761 769
762static void update_sge(struct ipath_sge_state *ss, u32 length) 770static void update_sge(struct ipath_sge_state *ss, u32 length)
@@ -1012,13 +1020,24 @@ static void sdma_complete(void *cookie, int status)
1012 struct ipath_verbs_txreq *tx = cookie; 1020 struct ipath_verbs_txreq *tx = cookie;
1013 struct ipath_qp *qp = tx->qp; 1021 struct ipath_qp *qp = tx->qp;
1014 struct ipath_ibdev *dev = to_idev(qp->ibqp.device); 1022 struct ipath_ibdev *dev = to_idev(qp->ibqp.device);
1023 unsigned int flags;
1024 enum ib_wc_status ibs = status == IPATH_SDMA_TXREQ_S_OK ?
1025 IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR;
1015 1026
1016 /* Generate a completion queue entry if needed */ 1027 if (atomic_dec_and_test(&qp->s_dma_busy)) {
1017 if (qp->ibqp.qp_type != IB_QPT_RC && tx->wqe) { 1028 spin_lock_irqsave(&qp->s_lock, flags);
1018 enum ib_wc_status ibs = status == IPATH_SDMA_TXREQ_S_OK ? 1029 if (tx->wqe)
1019 IB_WC_SUCCESS : IB_WC_WR_FLUSH_ERR; 1030 ipath_send_complete(qp, tx->wqe, ibs);
1020 1031 if ((ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND &&
1032 qp->s_last != qp->s_head) ||
1033 (qp->s_flags & IPATH_S_WAIT_DMA))
1034 ipath_schedule_send(qp);
1035 spin_unlock_irqrestore(&qp->s_lock, flags);
1036 wake_up(&qp->wait_dma);
1037 } else if (tx->wqe) {
1038 spin_lock_irqsave(&qp->s_lock, flags);
1021 ipath_send_complete(qp, tx->wqe, ibs); 1039 ipath_send_complete(qp, tx->wqe, ibs);
1040 spin_unlock_irqrestore(&qp->s_lock, flags);
1022 } 1041 }
1023 1042
1024 if (tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF) 1043 if (tx->txreq.flags & IPATH_SDMA_TXREQ_F_FREEBUF)
@@ -1029,6 +1048,21 @@ static void sdma_complete(void *cookie, int status)
1029 wake_up(&qp->wait); 1048 wake_up(&qp->wait);
1030} 1049}
1031 1050
1051static void decrement_dma_busy(struct ipath_qp *qp)
1052{
1053 unsigned int flags;
1054
1055 if (atomic_dec_and_test(&qp->s_dma_busy)) {
1056 spin_lock_irqsave(&qp->s_lock, flags);
1057 if ((ib_ipath_state_ops[qp->state] & IPATH_FLUSH_SEND &&
1058 qp->s_last != qp->s_head) ||
1059 (qp->s_flags & IPATH_S_WAIT_DMA))
1060 ipath_schedule_send(qp);
1061 spin_unlock_irqrestore(&qp->s_lock, flags);
1062 wake_up(&qp->wait_dma);
1063 }
1064}
1065
1032/* 1066/*
1033 * Compute the number of clock cycles of delay before sending the next packet. 1067 * Compute the number of clock cycles of delay before sending the next packet.
1034 * The multipliers reflect the number of clocks for the fastest rate so 1068 * The multipliers reflect the number of clocks for the fastest rate so
@@ -1067,9 +1101,12 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1067 if (tx) { 1101 if (tx) {
1068 qp->s_tx = NULL; 1102 qp->s_tx = NULL;
1069 /* resend previously constructed packet */ 1103 /* resend previously constructed packet */
1104 atomic_inc(&qp->s_dma_busy);
1070 ret = ipath_sdma_verbs_send(dd, tx->ss, tx->len, tx); 1105 ret = ipath_sdma_verbs_send(dd, tx->ss, tx->len, tx);
1071 if (ret) 1106 if (ret) {
1072 qp->s_tx = tx; 1107 qp->s_tx = tx;
1108 decrement_dma_busy(qp);
1109 }
1073 goto bail; 1110 goto bail;
1074 } 1111 }
1075 1112
@@ -1120,12 +1157,14 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1120 tx->txreq.sg_count = ndesc; 1157 tx->txreq.sg_count = ndesc;
1121 tx->map_len = (hdrwords + 2) << 2; 1158 tx->map_len = (hdrwords + 2) << 2;
1122 tx->txreq.map_addr = &tx->hdr; 1159 tx->txreq.map_addr = &tx->hdr;
1160 atomic_inc(&qp->s_dma_busy);
1123 ret = ipath_sdma_verbs_send(dd, ss, dwords, tx); 1161 ret = ipath_sdma_verbs_send(dd, ss, dwords, tx);
1124 if (ret) { 1162 if (ret) {
1125 /* save ss and length in dwords */ 1163 /* save ss and length in dwords */
1126 tx->ss = ss; 1164 tx->ss = ss;
1127 tx->len = dwords; 1165 tx->len = dwords;
1128 qp->s_tx = tx; 1166 qp->s_tx = tx;
1167 decrement_dma_busy(qp);
1129 } 1168 }
1130 goto bail; 1169 goto bail;
1131 } 1170 }
@@ -1146,6 +1185,7 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1146 memcpy(piobuf, hdr, hdrwords << 2); 1185 memcpy(piobuf, hdr, hdrwords << 2);
1147 ipath_copy_from_sge(piobuf + hdrwords, ss, len); 1186 ipath_copy_from_sge(piobuf + hdrwords, ss, len);
1148 1187
1188 atomic_inc(&qp->s_dma_busy);
1149 ret = ipath_sdma_verbs_send(dd, NULL, 0, tx); 1189 ret = ipath_sdma_verbs_send(dd, NULL, 0, tx);
1150 /* 1190 /*
1151 * If we couldn't queue the DMA request, save the info 1191 * If we couldn't queue the DMA request, save the info
@@ -1156,6 +1196,7 @@ static int ipath_verbs_send_dma(struct ipath_qp *qp,
1156 tx->ss = NULL; 1196 tx->ss = NULL;
1157 tx->len = 0; 1197 tx->len = 0;
1158 qp->s_tx = tx; 1198 qp->s_tx = tx;
1199 decrement_dma_busy(qp);
1159 } 1200 }
1160 dev->n_unaligned++; 1201 dev->n_unaligned++;
1161 goto bail; 1202 goto bail;
@@ -1179,6 +1220,7 @@ static int ipath_verbs_send_pio(struct ipath_qp *qp,
1179 unsigned flush_wc; 1220 unsigned flush_wc;
1180 u32 control; 1221 u32 control;
1181 int ret; 1222 int ret;
1223 unsigned int flags;
1182 1224
1183 piobuf = ipath_getpiobuf(dd, plen, NULL); 1225 piobuf = ipath_getpiobuf(dd, plen, NULL);
1184 if (unlikely(piobuf == NULL)) { 1226 if (unlikely(piobuf == NULL)) {
@@ -1249,8 +1291,11 @@ static int ipath_verbs_send_pio(struct ipath_qp *qp,
1249 } 1291 }
1250 copy_io(piobuf, ss, len, flush_wc); 1292 copy_io(piobuf, ss, len, flush_wc);
1251done: 1293done:
1252 if (qp->s_wqe) 1294 if (qp->s_wqe) {
1295 spin_lock_irqsave(&qp->s_lock, flags);
1253 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS); 1296 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS);
1297 spin_unlock_irqrestore(&qp->s_lock, flags);
1298 }
1254 ret = 0; 1299 ret = 0;
1255bail: 1300bail:
1256 return ret; 1301 return ret;
@@ -1283,19 +1328,12 @@ int ipath_verbs_send(struct ipath_qp *qp, struct ipath_ib_header *hdr,
1283 * can defer SDMA restart until link goes ACTIVE without 1328 * can defer SDMA restart until link goes ACTIVE without
1284 * worrying about just how we got there. 1329 * worrying about just how we got there.
1285 */ 1330 */
1286 if (qp->ibqp.qp_type == IB_QPT_SMI) 1331 if (qp->ibqp.qp_type == IB_QPT_SMI ||
1332 !(dd->ipath_flags & IPATH_HAS_SEND_DMA))
1287 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len, 1333 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len,
1288 plen, dwords); 1334 plen, dwords);
1289 /* All non-VL15 packets are dropped if link is not ACTIVE */
1290 else if (!(dd->ipath_flags & IPATH_LINKACTIVE)) {
1291 if (qp->s_wqe)
1292 ipath_send_complete(qp, qp->s_wqe, IB_WC_SUCCESS);
1293 ret = 0;
1294 } else if (dd->ipath_flags & IPATH_HAS_SEND_DMA)
1295 ret = ipath_verbs_send_dma(qp, hdr, hdrwords, ss, len,
1296 plen, dwords);
1297 else 1335 else
1298 ret = ipath_verbs_send_pio(qp, hdr, hdrwords, ss, len, 1336 ret = ipath_verbs_send_dma(qp, hdr, hdrwords, ss, len,
1299 plen, dwords); 1337 plen, dwords);
1300 1338
1301 return ret; 1339 return ret;
@@ -1403,27 +1441,46 @@ bail:
1403 * This is called from ipath_intr() at interrupt level when a PIO buffer is 1441 * This is called from ipath_intr() at interrupt level when a PIO buffer is
1404 * available after ipath_verbs_send() returned an error that no buffers were 1442 * available after ipath_verbs_send() returned an error that no buffers were
1405 * available. Return 1 if we consumed all the PIO buffers and we still have 1443 * available. Return 1 if we consumed all the PIO buffers and we still have
1406 * QPs waiting for buffers (for now, just do a tasklet_hi_schedule and 1444 * QPs waiting for buffers (for now, just restart the send tasklet and
1407 * return zero). 1445 * return zero).
1408 */ 1446 */
1409int ipath_ib_piobufavail(struct ipath_ibdev *dev) 1447int ipath_ib_piobufavail(struct ipath_ibdev *dev)
1410{ 1448{
1449 struct list_head *list;
1450 struct ipath_qp *qplist;
1411 struct ipath_qp *qp; 1451 struct ipath_qp *qp;
1412 unsigned long flags; 1452 unsigned long flags;
1413 1453
1414 if (dev == NULL) 1454 if (dev == NULL)
1415 goto bail; 1455 goto bail;
1416 1456
1457 list = &dev->piowait;
1458 qplist = NULL;
1459
1417 spin_lock_irqsave(&dev->pending_lock, flags); 1460 spin_lock_irqsave(&dev->pending_lock, flags);
1418 while (!list_empty(&dev->piowait)) { 1461 while (!list_empty(list)) {
1419 qp = list_entry(dev->piowait.next, struct ipath_qp, 1462 qp = list_entry(list->next, struct ipath_qp, piowait);
1420 piowait);
1421 list_del_init(&qp->piowait); 1463 list_del_init(&qp->piowait);
1422 clear_bit(IPATH_S_BUSY, &qp->s_busy); 1464 qp->pio_next = qplist;
1423 tasklet_hi_schedule(&qp->s_task); 1465 qplist = qp;
1466 atomic_inc(&qp->refcount);
1424 } 1467 }
1425 spin_unlock_irqrestore(&dev->pending_lock, flags); 1468 spin_unlock_irqrestore(&dev->pending_lock, flags);
1426 1469
1470 while (qplist != NULL) {
1471 qp = qplist;
1472 qplist = qp->pio_next;
1473
1474 spin_lock_irqsave(&qp->s_lock, flags);
1475 if (ib_ipath_state_ops[qp->state] & IPATH_PROCESS_SEND_OK)
1476 ipath_schedule_send(qp);
1477 spin_unlock_irqrestore(&qp->s_lock, flags);
1478
1479 /* Notify ipath_destroy_qp() if it is waiting. */
1480 if (atomic_dec_and_test(&qp->refcount))
1481 wake_up(&qp->wait);
1482 }
1483
1427bail: 1484bail:
1428 return 0; 1485 return 0;
1429} 1486}
@@ -2145,11 +2202,12 @@ bail:
2145void ipath_unregister_ib_device(struct ipath_ibdev *dev) 2202void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2146{ 2203{
2147 struct ib_device *ibdev = &dev->ibdev; 2204 struct ib_device *ibdev = &dev->ibdev;
2148 2205 u32 qps_inuse;
2149 disable_timer(dev->dd);
2150 2206
2151 ib_unregister_device(ibdev); 2207 ib_unregister_device(ibdev);
2152 2208
2209 disable_timer(dev->dd);
2210
2153 if (!list_empty(&dev->pending[0]) || 2211 if (!list_empty(&dev->pending[0]) ||
2154 !list_empty(&dev->pending[1]) || 2212 !list_empty(&dev->pending[1]) ||
2155 !list_empty(&dev->pending[2])) 2213 !list_empty(&dev->pending[2]))
@@ -2164,7 +2222,10 @@ void ipath_unregister_ib_device(struct ipath_ibdev *dev)
2164 * Note that ipath_unregister_ib_device() can be called before all 2222 * Note that ipath_unregister_ib_device() can be called before all
2165 * the QPs are destroyed! 2223 * the QPs are destroyed!
2166 */ 2224 */
2167 ipath_free_all_qps(&dev->qp_table); 2225 qps_inuse = ipath_free_all_qps(&dev->qp_table);
2226 if (qps_inuse)
2227 ipath_dev_err(dev->dd, "QP memory leak! %u still in use\n",
2228 qps_inuse);
2168 kfree(dev->qp_table.table); 2229 kfree(dev->qp_table.table);
2169 kfree(dev->lk_table.table); 2230 kfree(dev->lk_table.table);
2170 kfree(dev->txreq_bufs); 2231 kfree(dev->txreq_bufs);
@@ -2215,17 +2276,14 @@ static ssize_t show_stats(struct device *device, struct device_attribute *attr,
2215 "RC OTH NAKs %d\n" 2276 "RC OTH NAKs %d\n"
2216 "RC timeouts %d\n" 2277 "RC timeouts %d\n"
2217 "RC RDMA dup %d\n" 2278 "RC RDMA dup %d\n"
2218 "RC stalls %d\n"
2219 "piobuf wait %d\n" 2279 "piobuf wait %d\n"
2220 "no piobuf %d\n"
2221 "unaligned %d\n" 2280 "unaligned %d\n"
2222 "PKT drops %d\n" 2281 "PKT drops %d\n"
2223 "WQE errs %d\n", 2282 "WQE errs %d\n",
2224 dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks, 2283 dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks,
2225 dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks, 2284 dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks,
2226 dev->n_other_naks, dev->n_timeouts, 2285 dev->n_other_naks, dev->n_timeouts,
2227 dev->n_rdma_dup_busy, dev->n_rc_stalls, dev->n_piowait, 2286 dev->n_rdma_dup_busy, dev->n_piowait, dev->n_unaligned,
2228 dev->n_no_piobuf, dev->n_unaligned,
2229 dev->n_pkt_drops, dev->n_wqe_errs); 2287 dev->n_pkt_drops, dev->n_wqe_errs);
2230 for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) { 2288 for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) {
2231 const struct ipath_opcode_stats *si = &dev->opstats[i]; 2289 const struct ipath_opcode_stats *si = &dev->opstats[i];
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.h b/drivers/infiniband/hw/ipath/ipath_verbs.h
index 6514aa8306cd..9d12ae8a778e 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.h
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.h
@@ -74,6 +74,11 @@
74#define IPATH_POST_RECV_OK 0x02 74#define IPATH_POST_RECV_OK 0x02
75#define IPATH_PROCESS_RECV_OK 0x04 75#define IPATH_PROCESS_RECV_OK 0x04
76#define IPATH_PROCESS_SEND_OK 0x08 76#define IPATH_PROCESS_SEND_OK 0x08
77#define IPATH_PROCESS_NEXT_SEND_OK 0x10
78#define IPATH_FLUSH_SEND 0x20
79#define IPATH_FLUSH_RECV 0x40
80#define IPATH_PROCESS_OR_FLUSH_SEND \
81 (IPATH_PROCESS_SEND_OK | IPATH_FLUSH_SEND)
77 82
78/* IB Performance Manager status values */ 83/* IB Performance Manager status values */
79#define IB_PMA_SAMPLE_STATUS_DONE 0x00 84#define IB_PMA_SAMPLE_STATUS_DONE 0x00
@@ -353,12 +358,14 @@ struct ipath_qp {
353 struct ib_qp ibqp; 358 struct ib_qp ibqp;
354 struct ipath_qp *next; /* link list for QPN hash table */ 359 struct ipath_qp *next; /* link list for QPN hash table */
355 struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */ 360 struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */
361 struct ipath_qp *pio_next; /* link for ipath_ib_piobufavail() */
356 struct list_head piowait; /* link for wait PIO buf */ 362 struct list_head piowait; /* link for wait PIO buf */
357 struct list_head timerwait; /* link for waiting for timeouts */ 363 struct list_head timerwait; /* link for waiting for timeouts */
358 struct ib_ah_attr remote_ah_attr; 364 struct ib_ah_attr remote_ah_attr;
359 struct ipath_ib_header s_hdr; /* next packet header to send */ 365 struct ipath_ib_header s_hdr; /* next packet header to send */
360 atomic_t refcount; 366 atomic_t refcount;
361 wait_queue_head_t wait; 367 wait_queue_head_t wait;
368 wait_queue_head_t wait_dma;
362 struct tasklet_struct s_task; 369 struct tasklet_struct s_task;
363 struct ipath_mmap_info *ip; 370 struct ipath_mmap_info *ip;
364 struct ipath_sge_state *s_cur_sge; 371 struct ipath_sge_state *s_cur_sge;
@@ -369,7 +376,7 @@ struct ipath_qp {
369 struct ipath_sge_state s_rdma_read_sge; 376 struct ipath_sge_state s_rdma_read_sge;
370 struct ipath_sge_state r_sge; /* current receive data */ 377 struct ipath_sge_state r_sge; /* current receive data */
371 spinlock_t s_lock; 378 spinlock_t s_lock;
372 unsigned long s_busy; 379 atomic_t s_dma_busy;
373 u16 s_pkt_delay; 380 u16 s_pkt_delay;
374 u16 s_hdrwords; /* size of s_hdr in 32 bit words */ 381 u16 s_hdrwords; /* size of s_hdr in 32 bit words */
375 u32 s_cur_size; /* size of send packet in bytes */ 382 u32 s_cur_size; /* size of send packet in bytes */
@@ -383,6 +390,7 @@ struct ipath_qp {
383 u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */ 390 u32 s_rnr_timeout; /* number of milliseconds for RNR timeout */
384 u32 r_ack_psn; /* PSN for next ACK or atomic ACK */ 391 u32 r_ack_psn; /* PSN for next ACK or atomic ACK */
385 u64 r_wr_id; /* ID for current receive WQE */ 392 u64 r_wr_id; /* ID for current receive WQE */
393 unsigned long r_aflags;
386 u32 r_len; /* total length of r_sge */ 394 u32 r_len; /* total length of r_sge */
387 u32 r_rcv_len; /* receive data len processed */ 395 u32 r_rcv_len; /* receive data len processed */
388 u32 r_psn; /* expected rcv packet sequence number */ 396 u32 r_psn; /* expected rcv packet sequence number */
@@ -394,8 +402,7 @@ struct ipath_qp {
394 u8 r_state; /* opcode of last packet received */ 402 u8 r_state; /* opcode of last packet received */
395 u8 r_nak_state; /* non-zero if NAK is pending */ 403 u8 r_nak_state; /* non-zero if NAK is pending */
396 u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */ 404 u8 r_min_rnr_timer; /* retry timeout value for RNR NAKs */
397 u8 r_reuse_sge; /* for UC receive errors */ 405 u8 r_flags;
398 u8 r_wrid_valid; /* r_wrid set but CQ entry not yet made */
399 u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */ 406 u8 r_max_rd_atomic; /* max number of RDMA read/atomic to receive */
400 u8 r_head_ack_queue; /* index into s_ack_queue[] */ 407 u8 r_head_ack_queue; /* index into s_ack_queue[] */
401 u8 qp_access_flags; 408 u8 qp_access_flags;
@@ -404,13 +411,13 @@ struct ipath_qp {
404 u8 s_rnr_retry_cnt; 411 u8 s_rnr_retry_cnt;
405 u8 s_retry; /* requester retry counter */ 412 u8 s_retry; /* requester retry counter */
406 u8 s_rnr_retry; /* requester RNR retry counter */ 413 u8 s_rnr_retry; /* requester RNR retry counter */
407 u8 s_wait_credit; /* limit number of unacked packets sent */
408 u8 s_pkey_index; /* PKEY index to use */ 414 u8 s_pkey_index; /* PKEY index to use */
409 u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */ 415 u8 s_max_rd_atomic; /* max number of RDMA read/atomic to send */
410 u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */ 416 u8 s_num_rd_atomic; /* number of RDMA read/atomic pending */
411 u8 s_tail_ack_queue; /* index into s_ack_queue[] */ 417 u8 s_tail_ack_queue; /* index into s_ack_queue[] */
412 u8 s_flags; 418 u8 s_flags;
413 u8 s_dmult; 419 u8 s_dmult;
420 u8 s_draining;
414 u8 timeout; /* Timeout for this QP */ 421 u8 timeout; /* Timeout for this QP */
415 enum ib_mtu path_mtu; 422 enum ib_mtu path_mtu;
416 u32 remote_qpn; 423 u32 remote_qpn;
@@ -428,16 +435,40 @@ struct ipath_qp {
428 struct ipath_sge r_sg_list[0]; /* verified SGEs */ 435 struct ipath_sge r_sg_list[0]; /* verified SGEs */
429}; 436};
430 437
431/* Bit definition for s_busy. */ 438/*
432#define IPATH_S_BUSY 0 439 * Atomic bit definitions for r_aflags.
440 */
441#define IPATH_R_WRID_VALID 0
442
443/*
444 * Bit definitions for r_flags.
445 */
446#define IPATH_R_REUSE_SGE 0x01
447#define IPATH_R_RDMAR_SEQ 0x02
433 448
434/* 449/*
435 * Bit definitions for s_flags. 450 * Bit definitions for s_flags.
451 *
452 * IPATH_S_FENCE_PENDING - waiting for all prior RDMA read or atomic SWQEs
453 * before processing the next SWQE
454 * IPATH_S_RDMAR_PENDING - waiting for any RDMA read or atomic SWQEs
455 * before processing the next SWQE
456 * IPATH_S_WAITING - waiting for RNR timeout or send buffer available.
457 * IPATH_S_WAIT_SSN_CREDIT - waiting for RC credits to process next SWQE
458 * IPATH_S_WAIT_DMA - waiting for send DMA queue to drain before generating
459 * next send completion entry not via send DMA.
436 */ 460 */
437#define IPATH_S_SIGNAL_REQ_WR 0x01 461#define IPATH_S_SIGNAL_REQ_WR 0x01
438#define IPATH_S_FENCE_PENDING 0x02 462#define IPATH_S_FENCE_PENDING 0x02
439#define IPATH_S_RDMAR_PENDING 0x04 463#define IPATH_S_RDMAR_PENDING 0x04
440#define IPATH_S_ACK_PENDING 0x08 464#define IPATH_S_ACK_PENDING 0x08
465#define IPATH_S_BUSY 0x10
466#define IPATH_S_WAITING 0x20
467#define IPATH_S_WAIT_SSN_CREDIT 0x40
468#define IPATH_S_WAIT_DMA 0x80
469
470#define IPATH_S_ANY_WAIT (IPATH_S_FENCE_PENDING | IPATH_S_RDMAR_PENDING | \
471 IPATH_S_WAITING | IPATH_S_WAIT_SSN_CREDIT | IPATH_S_WAIT_DMA)
441 472
442#define IPATH_PSN_CREDIT 512 473#define IPATH_PSN_CREDIT 512
443 474
@@ -573,13 +604,11 @@ struct ipath_ibdev {
573 u32 n_rnr_naks; 604 u32 n_rnr_naks;
574 u32 n_other_naks; 605 u32 n_other_naks;
575 u32 n_timeouts; 606 u32 n_timeouts;
576 u32 n_rc_stalls;
577 u32 n_pkt_drops; 607 u32 n_pkt_drops;
578 u32 n_vl15_dropped; 608 u32 n_vl15_dropped;
579 u32 n_wqe_errs; 609 u32 n_wqe_errs;
580 u32 n_rdma_dup_busy; 610 u32 n_rdma_dup_busy;
581 u32 n_piowait; 611 u32 n_piowait;
582 u32 n_no_piobuf;
583 u32 n_unaligned; 612 u32 n_unaligned;
584 u32 port_cap_flags; 613 u32 port_cap_flags;
585 u32 pma_sample_start; 614 u32 pma_sample_start;
@@ -657,6 +686,17 @@ static inline struct ipath_ibdev *to_idev(struct ib_device *ibdev)
657 return container_of(ibdev, struct ipath_ibdev, ibdev); 686 return container_of(ibdev, struct ipath_ibdev, ibdev);
658} 687}
659 688
689/*
690 * This must be called with s_lock held.
691 */
692static inline void ipath_schedule_send(struct ipath_qp *qp)
693{
694 if (qp->s_flags & IPATH_S_ANY_WAIT)
695 qp->s_flags &= ~IPATH_S_ANY_WAIT;
696 if (!(qp->s_flags & IPATH_S_BUSY))
697 tasklet_hi_schedule(&qp->s_task);
698}
699
660int ipath_process_mad(struct ib_device *ibdev, 700int ipath_process_mad(struct ib_device *ibdev,
661 int mad_flags, 701 int mad_flags,
662 u8 port_num, 702 u8 port_num,
@@ -706,12 +746,10 @@ int ipath_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
706int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 746int ipath_query_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
707 int attr_mask, struct ib_qp_init_attr *init_attr); 747 int attr_mask, struct ib_qp_init_attr *init_attr);
708 748
709void ipath_free_all_qps(struct ipath_qp_table *qpt); 749unsigned ipath_free_all_qps(struct ipath_qp_table *qpt);
710 750
711int ipath_init_qp_table(struct ipath_ibdev *idev, int size); 751int ipath_init_qp_table(struct ipath_ibdev *idev, int size);
712 752
713void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc);
714
715void ipath_get_credit(struct ipath_qp *qp, u32 aeth); 753void ipath_get_credit(struct ipath_qp *qp, u32 aeth);
716 754
717unsigned ipath_ib_rate_to_mult(enum ib_rate rate); 755unsigned ipath_ib_rate_to_mult(enum ib_rate rate);
@@ -729,7 +767,9 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
729void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, 767void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
730 int has_grh, void *data, u32 tlen, struct ipath_qp *qp); 768 int has_grh, void *data, u32 tlen, struct ipath_qp *qp);
731 769
732void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc); 770void ipath_restart_rc(struct ipath_qp *qp, u32 psn);
771
772void ipath_rc_error(struct ipath_qp *qp, enum ib_wc_status err);
733 773
734int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr); 774int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr);
735 775
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 2f199c5c4a72..4521319b1406 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -246,7 +246,7 @@ err_mtt:
246 if (context) 246 if (context)
247 ib_umem_release(cq->umem); 247 ib_umem_release(cq->umem);
248 else 248 else
249 mlx4_ib_free_cq_buf(dev, &cq->buf, entries); 249 mlx4_ib_free_cq_buf(dev, &cq->buf, cq->ibcq.cqe);
250 250
251err_db: 251err_db:
252 if (!context) 252 if (!context)
@@ -434,7 +434,7 @@ int mlx4_ib_destroy_cq(struct ib_cq *cq)
434 mlx4_ib_db_unmap_user(to_mucontext(cq->uobject->context), &mcq->db); 434 mlx4_ib_db_unmap_user(to_mucontext(cq->uobject->context), &mcq->db);
435 ib_umem_release(mcq->umem); 435 ib_umem_release(mcq->umem);
436 } else { 436 } else {
437 mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe + 1); 437 mlx4_ib_free_cq_buf(dev, &mcq->buf, cq->cqe);
438 mlx4_db_free(dev->dev, &mcq->db); 438 mlx4_db_free(dev->dev, &mcq->db);
439 } 439 }
440 440
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index 9f7364a9096d..a4e9269a29bd 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -91,10 +91,6 @@ unsigned int nes_debug_level = 0;
91module_param_named(debug_level, nes_debug_level, uint, 0644); 91module_param_named(debug_level, nes_debug_level, uint, 0644);
92MODULE_PARM_DESC(debug_level, "Enable debug output level"); 92MODULE_PARM_DESC(debug_level, "Enable debug output level");
93 93
94unsigned int nes_lro_max_aggr = NES_LRO_MAX_AGGR;
95module_param(nes_lro_max_aggr, int, NES_LRO_MAX_AGGR);
96MODULE_PARM_DESC(nes_mro_max_aggr, " nic LRO MAX packet aggregation");
97
98LIST_HEAD(nes_adapter_list); 94LIST_HEAD(nes_adapter_list);
99static LIST_HEAD(nes_dev_list); 95static LIST_HEAD(nes_dev_list);
100 96
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 1f9f7bf73862..61b46e9c7d2d 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -173,7 +173,6 @@ extern int disable_mpa_crc;
173extern unsigned int send_first; 173extern unsigned int send_first;
174extern unsigned int nes_drv_opt; 174extern unsigned int nes_drv_opt;
175extern unsigned int nes_debug_level; 175extern unsigned int nes_debug_level;
176extern unsigned int nes_lro_max_aggr;
177 176
178extern struct list_head nes_adapter_list; 177extern struct list_head nes_adapter_list;
179 178
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index 8dc70f9bad2f..d3278f111ca7 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -42,6 +42,10 @@
42 42
43#include "nes.h" 43#include "nes.h"
44 44
45static unsigned int nes_lro_max_aggr = NES_LRO_MAX_AGGR;
46module_param(nes_lro_max_aggr, uint, 0444);
47MODULE_PARM_DESC(nes_lro_max_aggr, "NIC LRO max packet aggregation");
48
45static u32 crit_err_count; 49static u32 crit_err_count;
46u32 int_mod_timer_init; 50u32 int_mod_timer_init;
47u32 int_mod_cq_depth_256; 51u32 int_mod_cq_depth_256;
@@ -1738,7 +1742,7 @@ int nes_init_nic_qp(struct nes_device *nesdev, struct net_device *netdev)
1738 jumbomode = 1; 1742 jumbomode = 1;
1739 nes_nic_init_timer_defaults(nesdev, jumbomode); 1743 nes_nic_init_timer_defaults(nesdev, jumbomode);
1740 } 1744 }
1741 nesvnic->lro_mgr.max_aggr = NES_LRO_MAX_AGGR; 1745 nesvnic->lro_mgr.max_aggr = nes_lro_max_aggr;
1742 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS; 1746 nesvnic->lro_mgr.max_desc = NES_MAX_LRO_DESCRIPTORS;
1743 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc; 1747 nesvnic->lro_mgr.lro_arr = nesvnic->lro_desc;
1744 nesvnic->lro_mgr.get_skb_header = nes_lro_get_skb_hdr; 1748 nesvnic->lro_mgr.get_skb_header = nes_lro_get_skb_hdr;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 9044f8803532..ca126fc2b853 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -334,6 +334,7 @@ struct ipoib_dev_priv {
334#endif 334#endif
335 int hca_caps; 335 int hca_caps;
336 struct ipoib_ethtool_st ethtool; 336 struct ipoib_ethtool_st ethtool;
337 struct timer_list poll_timer;
337}; 338};
338 339
339struct ipoib_ah { 340struct ipoib_ah {
@@ -404,6 +405,7 @@ extern struct workqueue_struct *ipoib_workqueue;
404 405
405int ipoib_poll(struct napi_struct *napi, int budget); 406int ipoib_poll(struct napi_struct *napi, int budget);
406void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr); 407void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr);
408void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr);
407 409
408struct ipoib_ah *ipoib_create_ah(struct net_device *dev, 410struct ipoib_ah *ipoib_create_ah(struct net_device *dev,
409 struct ib_pd *pd, struct ib_ah_attr *attr); 411 struct ib_pd *pd, struct ib_ah_attr *attr);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 97b815c1a3fc..f429bce24c20 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -461,6 +461,26 @@ void ipoib_ib_completion(struct ib_cq *cq, void *dev_ptr)
461 netif_rx_schedule(dev, &priv->napi); 461 netif_rx_schedule(dev, &priv->napi);
462} 462}
463 463
464static void drain_tx_cq(struct net_device *dev)
465{
466 struct ipoib_dev_priv *priv = netdev_priv(dev);
467 unsigned long flags;
468
469 spin_lock_irqsave(&priv->tx_lock, flags);
470 while (poll_tx(priv))
471 ; /* nothing */
472
473 if (netif_queue_stopped(dev))
474 mod_timer(&priv->poll_timer, jiffies + 1);
475
476 spin_unlock_irqrestore(&priv->tx_lock, flags);
477}
478
479void ipoib_send_comp_handler(struct ib_cq *cq, void *dev_ptr)
480{
481 drain_tx_cq((struct net_device *)dev_ptr);
482}
483
464static inline int post_send(struct ipoib_dev_priv *priv, 484static inline int post_send(struct ipoib_dev_priv *priv,
465 unsigned int wr_id, 485 unsigned int wr_id,
466 struct ib_ah *address, u32 qpn, 486 struct ib_ah *address, u32 qpn,
@@ -555,12 +575,22 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
555 else 575 else
556 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM; 576 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
557 577
578 if (++priv->tx_outstanding == ipoib_sendq_size) {
579 ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
580 if (ib_req_notify_cq(priv->send_cq, IB_CQ_NEXT_COMP))
581 ipoib_warn(priv, "request notify on send CQ failed\n");
582 netif_stop_queue(dev);
583 }
584
558 if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1), 585 if (unlikely(post_send(priv, priv->tx_head & (ipoib_sendq_size - 1),
559 address->ah, qpn, tx_req, phead, hlen))) { 586 address->ah, qpn, tx_req, phead, hlen))) {
560 ipoib_warn(priv, "post_send failed\n"); 587 ipoib_warn(priv, "post_send failed\n");
561 ++dev->stats.tx_errors; 588 ++dev->stats.tx_errors;
589 --priv->tx_outstanding;
562 ipoib_dma_unmap_tx(priv->ca, tx_req); 590 ipoib_dma_unmap_tx(priv->ca, tx_req);
563 dev_kfree_skb_any(skb); 591 dev_kfree_skb_any(skb);
592 if (netif_queue_stopped(dev))
593 netif_wake_queue(dev);
564 } else { 594 } else {
565 dev->trans_start = jiffies; 595 dev->trans_start = jiffies;
566 596
@@ -568,14 +598,11 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
568 ++priv->tx_head; 598 ++priv->tx_head;
569 skb_orphan(skb); 599 skb_orphan(skb);
570 600
571 if (++priv->tx_outstanding == ipoib_sendq_size) {
572 ipoib_dbg(priv, "TX ring full, stopping kernel net queue\n");
573 netif_stop_queue(dev);
574 }
575 } 601 }
576 602
577 if (unlikely(priv->tx_outstanding > MAX_SEND_CQE)) 603 if (unlikely(priv->tx_outstanding > MAX_SEND_CQE))
578 poll_tx(priv); 604 while (poll_tx(priv))
605 ; /* nothing */
579} 606}
580 607
581static void __ipoib_reap_ah(struct net_device *dev) 608static void __ipoib_reap_ah(struct net_device *dev)
@@ -609,6 +636,11 @@ void ipoib_reap_ah(struct work_struct *work)
609 round_jiffies_relative(HZ)); 636 round_jiffies_relative(HZ));
610} 637}
611 638
639static void ipoib_ib_tx_timer_func(unsigned long ctx)
640{
641 drain_tx_cq((struct net_device *)ctx);
642}
643
612int ipoib_ib_dev_open(struct net_device *dev) 644int ipoib_ib_dev_open(struct net_device *dev)
613{ 645{
614 struct ipoib_dev_priv *priv = netdev_priv(dev); 646 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -645,6 +677,10 @@ int ipoib_ib_dev_open(struct net_device *dev)
645 queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task, 677 queue_delayed_work(ipoib_workqueue, &priv->ah_reap_task,
646 round_jiffies_relative(HZ)); 678 round_jiffies_relative(HZ));
647 679
680 init_timer(&priv->poll_timer);
681 priv->poll_timer.function = ipoib_ib_tx_timer_func;
682 priv->poll_timer.data = (unsigned long)dev;
683
648 set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags); 684 set_bit(IPOIB_FLAG_INITIALIZED, &priv->flags);
649 685
650 return 0; 686 return 0;
@@ -810,6 +846,7 @@ int ipoib_ib_dev_stop(struct net_device *dev, int flush)
810 ipoib_dbg(priv, "All sends and receives done.\n"); 846 ipoib_dbg(priv, "All sends and receives done.\n");
811 847
812timeout: 848timeout:
849 del_timer_sync(&priv->poll_timer);
813 qp_attr.qp_state = IB_QPS_RESET; 850 qp_attr.qp_state = IB_QPS_RESET;
814 if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE)) 851 if (ib_modify_qp(priv->qp, &qp_attr, IB_QP_STATE))
815 ipoib_warn(priv, "Failed to modify QP to RESET state\n"); 852 ipoib_warn(priv, "Failed to modify QP to RESET state\n");
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index c1e7ece1fd44..8766d29ce3b7 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -187,7 +187,8 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
187 goto out_free_mr; 187 goto out_free_mr;
188 } 188 }
189 189
190 priv->send_cq = ib_create_cq(priv->ca, NULL, NULL, dev, ipoib_sendq_size, 0); 190 priv->send_cq = ib_create_cq(priv->ca, ipoib_send_comp_handler, NULL,
191 dev, ipoib_sendq_size, 0);
191 if (IS_ERR(priv->send_cq)) { 192 if (IS_ERR(priv->send_cq)) {
192 printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name); 193 printk(KERN_WARNING "%s: failed to create send CQ\n", ca->name);
193 goto out_free_recv_cq; 194 goto out_free_recv_cq;
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 92b683411d5a..3ad8bd9f7543 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -14,7 +14,7 @@ if INPUT_MISC
14 14
15config INPUT_PCSPKR 15config INPUT_PCSPKR
16 tristate "PC Speaker support" 16 tristate "PC Speaker support"
17 depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP || PPC_PSERIES 17 depends on PCSPKR_PLATFORM
18 depends on SND_PCSP=n 18 depends on SND_PCSP=n
19 help 19 help
20 Say Y here if you want the standard PC Speaker to be used for 20 Say Y here if you want the standard PC Speaker to be used for
diff --git a/drivers/input/serio/hp_sdc.c b/drivers/input/serio/hp_sdc.c
index 02b3ad8c0826..edfedd9a166c 100644
--- a/drivers/input/serio/hp_sdc.c
+++ b/drivers/input/serio/hp_sdc.c
@@ -69,6 +69,7 @@
69#include <linux/time.h> 69#include <linux/time.h>
70#include <linux/slab.h> 70#include <linux/slab.h>
71#include <linux/hil.h> 71#include <linux/hil.h>
72#include <linux/semaphore.h>
72#include <asm/io.h> 73#include <asm/io.h>
73#include <asm/system.h> 74#include <asm/system.h>
74 75
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h
index 3b4e13b9ce1b..f451c7351a9d 100644
--- a/drivers/input/serio/i8042-io.h
+++ b/drivers/input/serio/i8042-io.h
@@ -25,7 +25,7 @@
25#elif defined(__arm__) 25#elif defined(__arm__)
26/* defined in include/asm-arm/arch-xxx/irqs.h */ 26/* defined in include/asm-arm/arch-xxx/irqs.h */
27#include <asm/irq.h> 27#include <asm/irq.h>
28#elif defined(CONFIG_SUPERH64) 28#elif defined(CONFIG_SH_CAYMAN)
29#include <asm/irq.h> 29#include <asm/irq.h>
30#else 30#else
31# define I8042_KBD_IRQ 1 31# define I8042_KBD_IRQ 1
diff --git a/drivers/isdn/capi/capiutil.c b/drivers/isdn/capi/capiutil.c
index ebef4ce1b00c..29419a8d31dc 100644
--- a/drivers/isdn/capi/capiutil.c
+++ b/drivers/isdn/capi/capiutil.c
@@ -948,17 +948,17 @@ int __init cdebug_init(void)
948{ 948{
949 g_cmsg= kmalloc(sizeof(_cmsg), GFP_KERNEL); 949 g_cmsg= kmalloc(sizeof(_cmsg), GFP_KERNEL);
950 if (!g_cmsg) 950 if (!g_cmsg)
951 return ENOMEM; 951 return -ENOMEM;
952 g_debbuf = kmalloc(sizeof(_cdebbuf), GFP_KERNEL); 952 g_debbuf = kmalloc(sizeof(_cdebbuf), GFP_KERNEL);
953 if (!g_debbuf) { 953 if (!g_debbuf) {
954 kfree(g_cmsg); 954 kfree(g_cmsg);
955 return ENOMEM; 955 return -ENOMEM;
956 } 956 }
957 g_debbuf->buf = kmalloc(CDEBUG_GSIZE, GFP_KERNEL); 957 g_debbuf->buf = kmalloc(CDEBUG_GSIZE, GFP_KERNEL);
958 if (!g_debbuf->buf) { 958 if (!g_debbuf->buf) {
959 kfree(g_cmsg); 959 kfree(g_cmsg);
960 kfree(g_debbuf); 960 kfree(g_debbuf);
961 return ENOMEM;; 961 return -ENOMEM;;
962 } 962 }
963 g_debbuf->size = CDEBUG_GSIZE; 963 g_debbuf->size = CDEBUG_GSIZE;
964 g_debbuf->buf[0] = 0; 964 g_debbuf->buf[0] = 0;
diff --git a/drivers/isdn/hysdn/Kconfig b/drivers/isdn/hysdn/Kconfig
index c6d8a7042988..c9e4231968ef 100644
--- a/drivers/isdn/hysdn/Kconfig
+++ b/drivers/isdn/hysdn/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config HYSDN 4config HYSDN
5 tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)" 5 tristate "Hypercope HYSDN cards (Champ, Ergo, Metro) support (module only)"
6 depends on m && PROC_FS && PCI && BROKEN_ON_SMP 6 depends on m && PROC_FS && PCI
7 help 7 help
8 Say Y here if you have one of Hypercope's active PCI ISDN cards 8 Say Y here if you have one of Hypercope's active PCI ISDN cards
9 Champ, Ergo and Metro. You will then get a module called hysdn. 9 Champ, Ergo and Metro. You will then get a module called hysdn.
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index 6cdbad3a9926..3eb096f0ae1b 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -64,10 +64,11 @@ ergo_interrupt(int intno, void *dev_id)
64} /* ergo_interrupt */ 64} /* ergo_interrupt */
65 65
66/******************************************************************************/ 66/******************************************************************************/
67/* ergo_irq_bh is the function called by the immediate kernel task list after */ 67/* ergo_irq_bh will be called as part of the kernel clearing its shared work */
68/* being activated with queue_task and no interrupts active. This task is the */ 68/* queue sometime after a call to schedule_work has been made passing our */
69/* only one handling data transfer from or to the card after booting. The task */ 69/* work_struct. This task is the only one handling data transfer from or to */
70/* may be queued from everywhere (interrupts included). */ 70/* the card after booting. The task may be queued from everywhere */
71/* (interrupts included). */
71/******************************************************************************/ 72/******************************************************************************/
72static void 73static void
73ergo_irq_bh(struct work_struct *ugli_api) 74ergo_irq_bh(struct work_struct *ugli_api)
@@ -90,7 +91,6 @@ ergo_irq_bh(struct work_struct *ugli_api)
90 card->hw_lock = 1; /* we now lock the hardware */ 91 card->hw_lock = 1; /* we now lock the hardware */
91 92
92 do { 93 do {
93 sti(); /* reenable other ints */
94 again = 0; /* assume loop not to be repeated */ 94 again = 0; /* assume loop not to be repeated */
95 95
96 if (!dpr->ToHyFlag) { 96 if (!dpr->ToHyFlag) {
@@ -110,7 +110,6 @@ ergo_irq_bh(struct work_struct *ugli_api)
110 again = 1; /* restart loop */ 110 again = 1; /* restart loop */
111 } 111 }
112 } /* a message has arrived for us */ 112 } /* a message has arrived for us */
113 cli(); /* no further ints */
114 if (again) { 113 if (again) {
115 dpr->ToHyInt = 1; 114 dpr->ToHyInt = 1;
116 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */ 115 dpr->ToPcInt = 1; /* interrupt to E1 for all cards */
@@ -242,7 +241,6 @@ ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf,
242 byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RUN); /* start E1 processor */ 241 byteout(card->iobase + PCI9050_USER_IO, PCI9050_E1_RUN); /* start E1 processor */
243 /* the interrupts are still masked */ 242 /* the interrupts are still masked */
244 243
245 sti();
246 msleep_interruptible(20); /* Timeout 20ms */ 244 msleep_interruptible(20); /* Timeout 20ms */
247 245
248 if (((tDpramBootSpooler *) card->dpram)->Len != DPRAM_SPOOLER_DATA_SIZE) { 246 if (((tDpramBootSpooler *) card->dpram)->Len != DPRAM_SPOOLER_DATA_SIZE) {
@@ -276,7 +274,6 @@ ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len)
276 dst = sp->Data; /* point to data in spool structure */ 274 dst = sp->Data; /* point to data in spool structure */
277 buflen = sp->Len; /* maximum len of spooled data */ 275 buflen = sp->Len; /* maximum len of spooled data */
278 wr_mirror = sp->WrPtr; /* only once read */ 276 wr_mirror = sp->WrPtr; /* only once read */
279 sti();
280 277
281 /* try until all bytes written or error */ 278 /* try until all bytes written or error */
282 i = 0x1000; /* timeout value */ 279 i = 0x1000; /* timeout value */
@@ -380,7 +377,6 @@ ergo_waitpofready(struct HYSDN_CARD *card)
380#endif /* CONFIG_HYSDN_CAPI */ 377#endif /* CONFIG_HYSDN_CAPI */
381 return (0); /* success */ 378 return (0); /* success */
382 } /* data has arrived */ 379 } /* data has arrived */
383 sti();
384 msleep_interruptible(50); /* Timeout 50ms */ 380 msleep_interruptible(50); /* Timeout 50ms */
385 } /* wait until timeout */ 381 } /* wait until timeout */
386 382
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c
index 20978205cd02..b8b9e44f7f4e 100644
--- a/drivers/macintosh/adb.c
+++ b/drivers/macintosh/adb.c
@@ -37,7 +37,7 @@
37#include <linux/device.h> 37#include <linux/device.h>
38#include <linux/kthread.h> 38#include <linux/kthread.h>
39#include <linux/platform_device.h> 39#include <linux/platform_device.h>
40#include <linux/semaphore.h> 40#include <linux/mutex.h>
41 41
42#include <asm/uaccess.h> 42#include <asm/uaccess.h>
43#ifdef CONFIG_PPC 43#ifdef CONFIG_PPC
@@ -102,7 +102,7 @@ static struct adb_handler {
102} adb_handler[16]; 102} adb_handler[16];
103 103
104/* 104/*
105 * The adb_handler_sem mutex protects all accesses to the original_address 105 * The adb_handler_mutex mutex protects all accesses to the original_address
106 * and handler_id fields of adb_handler[i] for all i, and changes to the 106 * and handler_id fields of adb_handler[i] for all i, and changes to the
107 * handler field. 107 * handler field.
108 * Accesses to the handler field are protected by the adb_handler_lock 108 * Accesses to the handler field are protected by the adb_handler_lock
@@ -110,7 +110,7 @@ static struct adb_handler {
110 * time adb_unregister returns, we know that the old handler isn't being 110 * time adb_unregister returns, we know that the old handler isn't being
111 * called. 111 * called.
112 */ 112 */
113static DECLARE_MUTEX(adb_handler_sem); 113static DEFINE_MUTEX(adb_handler_mutex);
114static DEFINE_RWLOCK(adb_handler_lock); 114static DEFINE_RWLOCK(adb_handler_lock);
115 115
116#if 0 116#if 0
@@ -355,7 +355,7 @@ do_adb_reset_bus(void)
355 msleep(500); 355 msleep(500);
356 } 356 }
357 357
358 down(&adb_handler_sem); 358 mutex_lock(&adb_handler_mutex);
359 write_lock_irq(&adb_handler_lock); 359 write_lock_irq(&adb_handler_lock);
360 memset(adb_handler, 0, sizeof(adb_handler)); 360 memset(adb_handler, 0, sizeof(adb_handler));
361 write_unlock_irq(&adb_handler_lock); 361 write_unlock_irq(&adb_handler_lock);
@@ -376,7 +376,7 @@ do_adb_reset_bus(void)
376 if (adb_controller->autopoll) 376 if (adb_controller->autopoll)
377 adb_controller->autopoll(autopoll_devs); 377 adb_controller->autopoll(autopoll_devs);
378 } 378 }
379 up(&adb_handler_sem); 379 mutex_unlock(&adb_handler_mutex);
380 380
381 blocking_notifier_call_chain(&adb_client_list, 381 blocking_notifier_call_chain(&adb_client_list,
382 ADB_MSG_POST_RESET, NULL); 382 ADB_MSG_POST_RESET, NULL);
@@ -454,7 +454,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids,
454{ 454{
455 int i; 455 int i;
456 456
457 down(&adb_handler_sem); 457 mutex_lock(&adb_handler_mutex);
458 ids->nids = 0; 458 ids->nids = 0;
459 for (i = 1; i < 16; i++) { 459 for (i = 1; i < 16; i++) {
460 if ((adb_handler[i].original_address == default_id) && 460 if ((adb_handler[i].original_address == default_id) &&
@@ -472,7 +472,7 @@ adb_register(int default_id, int handler_id, struct adb_ids *ids,
472 ids->id[ids->nids++] = i; 472 ids->id[ids->nids++] = i;
473 } 473 }
474 } 474 }
475 up(&adb_handler_sem); 475 mutex_unlock(&adb_handler_mutex);
476 return ids->nids; 476 return ids->nids;
477} 477}
478 478
@@ -481,7 +481,7 @@ adb_unregister(int index)
481{ 481{
482 int ret = -ENODEV; 482 int ret = -ENODEV;
483 483
484 down(&adb_handler_sem); 484 mutex_lock(&adb_handler_mutex);
485 write_lock_irq(&adb_handler_lock); 485 write_lock_irq(&adb_handler_lock);
486 if (adb_handler[index].handler) { 486 if (adb_handler[index].handler) {
487 while(adb_handler[index].busy) { 487 while(adb_handler[index].busy) {
@@ -493,7 +493,7 @@ adb_unregister(int index)
493 adb_handler[index].handler = NULL; 493 adb_handler[index].handler = NULL;
494 } 494 }
495 write_unlock_irq(&adb_handler_lock); 495 write_unlock_irq(&adb_handler_lock);
496 up(&adb_handler_sem); 496 mutex_unlock(&adb_handler_mutex);
497 return ret; 497 return ret;
498} 498}
499 499
@@ -557,19 +557,19 @@ adb_try_handler_change(int address, int new_id)
557{ 557{
558 int ret; 558 int ret;
559 559
560 down(&adb_handler_sem); 560 mutex_lock(&adb_handler_mutex);
561 ret = try_handler_change(address, new_id); 561 ret = try_handler_change(address, new_id);
562 up(&adb_handler_sem); 562 mutex_unlock(&adb_handler_mutex);
563 return ret; 563 return ret;
564} 564}
565 565
566int 566int
567adb_get_infos(int address, int *original_address, int *handler_id) 567adb_get_infos(int address, int *original_address, int *handler_id)
568{ 568{
569 down(&adb_handler_sem); 569 mutex_lock(&adb_handler_mutex);
570 *original_address = adb_handler[address].original_address; 570 *original_address = adb_handler[address].original_address;
571 *handler_id = adb_handler[address].handler_id; 571 *handler_id = adb_handler[address].handler_id;
572 up(&adb_handler_sem); 572 mutex_unlock(&adb_handler_mutex);
573 573
574 return (*original_address != 0); 574 return (*original_address != 0);
575} 575}
@@ -628,10 +628,10 @@ do_adb_query(struct adb_request *req)
628 case ADB_QUERY_GETDEVINFO: 628 case ADB_QUERY_GETDEVINFO:
629 if (req->nbytes < 3) 629 if (req->nbytes < 3)
630 break; 630 break;
631 down(&adb_handler_sem); 631 mutex_lock(&adb_handler_mutex);
632 req->reply[0] = adb_handler[req->data[2]].original_address; 632 req->reply[0] = adb_handler[req->data[2]].original_address;
633 req->reply[1] = adb_handler[req->data[2]].handler_id; 633 req->reply[1] = adb_handler[req->data[2]].handler_id;
634 up(&adb_handler_sem); 634 mutex_unlock(&adb_handler_mutex);
635 req->complete = 1; 635 req->complete = 1;
636 req->reply_len = 2; 636 req->reply_len = 2;
637 adb_write_done(req); 637 adb_write_done(req);
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 1e0a69a5e815..ddfb426a9abd 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -122,6 +122,7 @@
122#include <linux/kmod.h> 122#include <linux/kmod.h>
123#include <linux/i2c.h> 123#include <linux/i2c.h>
124#include <linux/kthread.h> 124#include <linux/kthread.h>
125#include <linux/mutex.h>
125#include <asm/prom.h> 126#include <asm/prom.h>
126#include <asm/machdep.h> 127#include <asm/machdep.h>
127#include <asm/io.h> 128#include <asm/io.h>
@@ -169,7 +170,7 @@ static int rackmac;
169static s32 dimm_output_clamp; 170static s32 dimm_output_clamp;
170static int fcu_rpm_shift; 171static int fcu_rpm_shift;
171static int fcu_tickle_ticks; 172static int fcu_tickle_ticks;
172static DECLARE_MUTEX(driver_lock); 173static DEFINE_MUTEX(driver_lock);
173 174
174/* 175/*
175 * We have 3 types of CPU PID control. One is "split" old style control 176 * We have 3 types of CPU PID control. One is "split" old style control
@@ -729,9 +730,9 @@ static void fetch_cpu_pumps_minmax(void)
729static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ 730static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
730{ \ 731{ \
731 ssize_t r; \ 732 ssize_t r; \
732 down(&driver_lock); \ 733 mutex_lock(&driver_lock); \
733 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \ 734 r = sprintf(buf, "%d.%03d", FIX32TOPRINT(data)); \
734 up(&driver_lock); \ 735 mutex_unlock(&driver_lock); \
735 return r; \ 736 return r; \
736} 737}
737#define BUILD_SHOW_FUNC_INT(name, data) \ 738#define BUILD_SHOW_FUNC_INT(name, data) \
@@ -1803,11 +1804,11 @@ static int main_control_loop(void *x)
1803{ 1804{
1804 DBG("main_control_loop started\n"); 1805 DBG("main_control_loop started\n");
1805 1806
1806 down(&driver_lock); 1807 mutex_lock(&driver_lock);
1807 1808
1808 if (start_fcu() < 0) { 1809 if (start_fcu() < 0) {
1809 printk(KERN_ERR "kfand: failed to start FCU\n"); 1810 printk(KERN_ERR "kfand: failed to start FCU\n");
1810 up(&driver_lock); 1811 mutex_unlock(&driver_lock);
1811 goto out; 1812 goto out;
1812 } 1813 }
1813 1814
@@ -1822,14 +1823,14 @@ static int main_control_loop(void *x)
1822 1823
1823 fcu_tickle_ticks = FCU_TICKLE_TICKS; 1824 fcu_tickle_ticks = FCU_TICKLE_TICKS;
1824 1825
1825 up(&driver_lock); 1826 mutex_unlock(&driver_lock);
1826 1827
1827 while (state == state_attached) { 1828 while (state == state_attached) {
1828 unsigned long elapsed, start; 1829 unsigned long elapsed, start;
1829 1830
1830 start = jiffies; 1831 start = jiffies;
1831 1832
1832 down(&driver_lock); 1833 mutex_lock(&driver_lock);
1833 1834
1834 /* Tickle the FCU just in case */ 1835 /* Tickle the FCU just in case */
1835 if (--fcu_tickle_ticks < 0) { 1836 if (--fcu_tickle_ticks < 0) {
@@ -1861,7 +1862,7 @@ static int main_control_loop(void *x)
1861 do_monitor_slots(&slots_state); 1862 do_monitor_slots(&slots_state);
1862 else 1863 else
1863 do_monitor_drives(&drives_state); 1864 do_monitor_drives(&drives_state);
1864 up(&driver_lock); 1865 mutex_unlock(&driver_lock);
1865 1866
1866 if (critical_state == 1) { 1867 if (critical_state == 1) {
1867 printk(KERN_WARNING "Temperature control detected a critical condition\n"); 1868 printk(KERN_WARNING "Temperature control detected a critical condition\n");
@@ -2019,13 +2020,13 @@ static void detach_fcu(void)
2019 */ 2020 */
2020static int therm_pm72_attach(struct i2c_adapter *adapter) 2021static int therm_pm72_attach(struct i2c_adapter *adapter)
2021{ 2022{
2022 down(&driver_lock); 2023 mutex_lock(&driver_lock);
2023 2024
2024 /* Check state */ 2025 /* Check state */
2025 if (state == state_detached) 2026 if (state == state_detached)
2026 state = state_attaching; 2027 state = state_attaching;
2027 if (state != state_attaching) { 2028 if (state != state_attaching) {
2028 up(&driver_lock); 2029 mutex_unlock(&driver_lock);
2029 return 0; 2030 return 0;
2030 } 2031 }
2031 2032
@@ -2054,7 +2055,7 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
2054 state = state_attached; 2055 state = state_attached;
2055 start_control_loops(); 2056 start_control_loops();
2056 } 2057 }
2057 up(&driver_lock); 2058 mutex_unlock(&driver_lock);
2058 2059
2059 return 0; 2060 return 0;
2060} 2061}
@@ -2065,16 +2066,16 @@ static int therm_pm72_attach(struct i2c_adapter *adapter)
2065 */ 2066 */
2066static int therm_pm72_detach(struct i2c_adapter *adapter) 2067static int therm_pm72_detach(struct i2c_adapter *adapter)
2067{ 2068{
2068 down(&driver_lock); 2069 mutex_lock(&driver_lock);
2069 2070
2070 if (state != state_detached) 2071 if (state != state_detached)
2071 state = state_detaching; 2072 state = state_detaching;
2072 2073
2073 /* Stop control loops if any */ 2074 /* Stop control loops if any */
2074 DBG("stopping control loops\n"); 2075 DBG("stopping control loops\n");
2075 up(&driver_lock); 2076 mutex_unlock(&driver_lock);
2076 stop_control_loops(); 2077 stop_control_loops();
2077 down(&driver_lock); 2078 mutex_lock(&driver_lock);
2078 2079
2079 if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) { 2080 if (u3_0 != NULL && !strcmp(adapter->name, "u3 0")) {
2080 DBG("lost U3-0, disposing control loops\n"); 2081 DBG("lost U3-0, disposing control loops\n");
@@ -2090,7 +2091,7 @@ static int therm_pm72_detach(struct i2c_adapter *adapter)
2090 if (u3_0 == NULL && u3_1 == NULL) 2091 if (u3_0 == NULL && u3_1 == NULL)
2091 state = state_detached; 2092 state = state_detached;
2092 2093
2093 up(&driver_lock); 2094 mutex_unlock(&driver_lock);
2094 2095
2095 return 0; 2096 return 0;
2096} 2097}
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 797918d0e59c..7f2be4baaeda 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/wait.h> 14#include <linux/wait.h>
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16#include <linux/semaphore.h> 16#include <linux/mutex.h>
17#include <asm/prom.h> 17#include <asm/prom.h>
18#include <asm/smu.h> 18#include <asm/smu.h>
19#include <asm/pmac_low_i2c.h> 19#include <asm/pmac_low_i2c.h>
@@ -36,7 +36,7 @@
36struct wf_sat { 36struct wf_sat {
37 int nr; 37 int nr;
38 atomic_t refcnt; 38 atomic_t refcnt;
39 struct semaphore mutex; 39 struct mutex mutex;
40 unsigned long last_read; /* jiffies when cache last updated */ 40 unsigned long last_read; /* jiffies when cache last updated */
41 u8 cache[16]; 41 u8 cache[16];
42 struct i2c_client i2c; 42 struct i2c_client i2c;
@@ -163,7 +163,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
163 if (sat->i2c.adapter == NULL) 163 if (sat->i2c.adapter == NULL)
164 return -ENODEV; 164 return -ENODEV;
165 165
166 down(&sat->mutex); 166 mutex_lock(&sat->mutex);
167 if (time_after(jiffies, (sat->last_read + MAX_AGE))) { 167 if (time_after(jiffies, (sat->last_read + MAX_AGE))) {
168 err = wf_sat_read_cache(sat); 168 err = wf_sat_read_cache(sat);
169 if (err) 169 if (err)
@@ -182,7 +182,7 @@ static int wf_sat_get(struct wf_sensor *sr, s32 *value)
182 err = 0; 182 err = 0;
183 183
184 fail: 184 fail:
185 up(&sat->mutex); 185 mutex_unlock(&sat->mutex);
186 return err; 186 return err;
187} 187}
188 188
@@ -233,7 +233,7 @@ static void wf_sat_create(struct i2c_adapter *adapter, struct device_node *dev)
233 sat->nr = -1; 233 sat->nr = -1;
234 sat->node = of_node_get(dev); 234 sat->node = of_node_get(dev);
235 atomic_set(&sat->refcnt, 0); 235 atomic_set(&sat->refcnt, 0);
236 init_MUTEX(&sat->mutex); 236 mutex_init(&sat->mutex);
237 sat->i2c.addr = (addr >> 1) & 0x7f; 237 sat->i2c.addr = (addr >> 1) & 0x7f;
238 sat->i2c.adapter = adapter; 238 sat->i2c.adapter = adapter;
239 sat->i2c.driver = &wf_sat_driver; 239 sat->i2c.driver = &wf_sat_driver;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 0b8511776b3e..10748240cb2f 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -250,6 +250,7 @@ static int linear_run (mddev_t *mddev)
250{ 250{
251 linear_conf_t *conf; 251 linear_conf_t *conf;
252 252
253 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
253 conf = linear_conf(mddev, mddev->raid_disks); 254 conf = linear_conf(mddev, mddev->raid_disks);
254 255
255 if (!conf) 256 if (!conf)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 42ee1a2dc144..4f4d1f383842 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -417,6 +417,7 @@ static int multipath_run (mddev_t *mddev)
417 * bookkeeping area. [whatever we allocate in multipath_run(), 417 * bookkeeping area. [whatever we allocate in multipath_run(),
418 * should be freed in multipath_stop()] 418 * should be freed in multipath_stop()]
419 */ 419 */
420 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
420 421
421 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL); 422 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
422 mddev->private = conf; 423 mddev->private = conf;
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 818b48284096..914c04ddec7c 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -280,6 +280,7 @@ static int raid0_run (mddev_t *mddev)
280 (mddev->chunk_size>>1)-1); 280 (mddev->chunk_size>>1)-1);
281 blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9); 281 blk_queue_max_sectors(mddev->queue, mddev->chunk_size >> 9);
282 blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1); 282 blk_queue_segment_boundary(mddev->queue, (mddev->chunk_size>>1) - 1);
283 mddev->queue->queue_lock = &mddev->queue->__queue_lock;
283 284
284 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL); 285 conf = kmalloc(sizeof (raid0_conf_t), GFP_KERNEL);
285 if (!conf) 286 if (!conf)
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 6778b7cb39bd..ac409b7d83f5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1935,6 +1935,9 @@ static int run(mddev_t *mddev)
1935 if (!conf->r1bio_pool) 1935 if (!conf->r1bio_pool)
1936 goto out_no_mem; 1936 goto out_no_mem;
1937 1937
1938 spin_lock_init(&conf->device_lock);
1939 mddev->queue->queue_lock = &conf->device_lock;
1940
1938 rdev_for_each(rdev, tmp, mddev) { 1941 rdev_for_each(rdev, tmp, mddev) {
1939 disk_idx = rdev->raid_disk; 1942 disk_idx = rdev->raid_disk;
1940 if (disk_idx >= mddev->raid_disks 1943 if (disk_idx >= mddev->raid_disks
@@ -1958,7 +1961,6 @@ static int run(mddev_t *mddev)
1958 } 1961 }
1959 conf->raid_disks = mddev->raid_disks; 1962 conf->raid_disks = mddev->raid_disks;
1960 conf->mddev = mddev; 1963 conf->mddev = mddev;
1961 spin_lock_init(&conf->device_lock);
1962 INIT_LIST_HEAD(&conf->retry_list); 1964 INIT_LIST_HEAD(&conf->retry_list);
1963 1965
1964 spin_lock_init(&conf->resync_lock); 1966 spin_lock_init(&conf->resync_lock);
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 5938fa962922..8536ede1e712 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -886,7 +886,7 @@ static int make_request(struct request_queue *q, struct bio * bio)
886 */ 886 */
887 raid10_find_phys(conf, r10_bio); 887 raid10_find_phys(conf, r10_bio);
888 retry_write: 888 retry_write:
889 blocked_rdev = 0; 889 blocked_rdev = NULL;
890 rcu_read_lock(); 890 rcu_read_lock();
891 for (i = 0; i < conf->copies; i++) { 891 for (i = 0; i < conf->copies; i++) {
892 int d = r10_bio->devs[i].devnum; 892 int d = r10_bio->devs[i].devnum;
@@ -2082,6 +2082,9 @@ static int run(mddev_t *mddev)
2082 goto out_free_conf; 2082 goto out_free_conf;
2083 } 2083 }
2084 2084
2085 spin_lock_init(&conf->device_lock);
2086 mddev->queue->queue_lock = &conf->device_lock;
2087
2085 rdev_for_each(rdev, tmp, mddev) { 2088 rdev_for_each(rdev, tmp, mddev) {
2086 disk_idx = rdev->raid_disk; 2089 disk_idx = rdev->raid_disk;
2087 if (disk_idx >= mddev->raid_disks 2090 if (disk_idx >= mddev->raid_disks
@@ -2103,7 +2106,6 @@ static int run(mddev_t *mddev)
2103 2106
2104 disk->head_position = 0; 2107 disk->head_position = 0;
2105 } 2108 }
2106 spin_lock_init(&conf->device_lock);
2107 INIT_LIST_HEAD(&conf->retry_list); 2109 INIT_LIST_HEAD(&conf->retry_list);
2108 2110
2109 spin_lock_init(&conf->resync_lock); 2111 spin_lock_init(&conf->resync_lock);
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 087eee0cb809..93fde48c0f42 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2369,8 +2369,8 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2369 2369
2370 /* complete a check operation */ 2370 /* complete a check operation */
2371 if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) { 2371 if (test_and_clear_bit(STRIPE_OP_CHECK, &sh->ops.complete)) {
2372 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack); 2372 clear_bit(STRIPE_OP_CHECK, &sh->ops.ack);
2373 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending); 2373 clear_bit(STRIPE_OP_CHECK, &sh->ops.pending);
2374 if (s->failed == 0) { 2374 if (s->failed == 0) {
2375 if (sh->ops.zero_sum_result == 0) 2375 if (sh->ops.zero_sum_result == 0)
2376 /* parity is correct (on disc, 2376 /* parity is correct (on disc,
@@ -2400,16 +2400,6 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2400 canceled_check = 1; /* STRIPE_INSYNC is not set */ 2400 canceled_check = 1; /* STRIPE_INSYNC is not set */
2401 } 2401 }
2402 2402
2403 /* check if we can clear a parity disk reconstruct */
2404 if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) &&
2405 test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2406
2407 clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending);
2408 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete);
2409 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack);
2410 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending);
2411 }
2412
2413 /* start a new check operation if there are no failures, the stripe is 2403 /* start a new check operation if there are no failures, the stripe is
2414 * not insync, and a repair is not in flight 2404 * not insync, and a repair is not in flight
2415 */ 2405 */
@@ -2424,6 +2414,17 @@ static void handle_parity_checks5(raid5_conf_t *conf, struct stripe_head *sh,
2424 } 2414 }
2425 } 2415 }
2426 2416
2417 /* check if we can clear a parity disk reconstruct */
2418 if (test_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete) &&
2419 test_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending)) {
2420
2421 clear_bit(STRIPE_OP_MOD_REPAIR_PD, &sh->ops.pending);
2422 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.complete);
2423 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.ack);
2424 clear_bit(STRIPE_OP_COMPUTE_BLK, &sh->ops.pending);
2425 }
2426
2427
2427 /* Wait for check parity and compute block operations to complete 2428 /* Wait for check parity and compute block operations to complete
2428 * before write-back. If a failure occurred while the check operation 2429 * before write-back. If a failure occurred while the check operation
2429 * was in flight we need to cycle this stripe through handle_stripe 2430 * was in flight we need to cycle this stripe through handle_stripe
@@ -4256,6 +4257,7 @@ static int run(mddev_t *mddev)
4256 goto abort; 4257 goto abort;
4257 } 4258 }
4258 spin_lock_init(&conf->device_lock); 4259 spin_lock_init(&conf->device_lock);
4260 mddev->queue->queue_lock = &conf->device_lock;
4259 init_waitqueue_head(&conf->wait_for_stripe); 4261 init_waitqueue_head(&conf->wait_for_stripe);
4260 init_waitqueue_head(&conf->wait_for_overlap); 4262 init_waitqueue_head(&conf->wait_for_overlap);
4261 INIT_LIST_HEAD(&conf->handle_list); 4263 INIT_LIST_HEAD(&conf->handle_list);
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index ddf57e135c6c..7a7803b5d497 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -89,8 +89,7 @@ config DVB_CORE
89 89
90config VIDEO_MEDIA 90config VIDEO_MEDIA
91 tristate 91 tristate
92 default DVB_CORE || VIDEO_DEV 92 default (DVB_CORE && (VIDEO_DEV = n)) || (VIDEO_DEV && (DVB_CORE = n)) || (DVB_CORE && VIDEO_DEV)
93 depends on DVB_CORE || VIDEO_DEV
94 93
95comment "Multimedia drivers" 94comment "Multimedia drivers"
96 95
diff --git a/drivers/media/Makefile b/drivers/media/Makefile
index 73f742c7e818..cc11c4c0e7e7 100644
--- a/drivers/media/Makefile
+++ b/drivers/media/Makefile
@@ -2,6 +2,8 @@
2# Makefile for the kernel multimedia device drivers. 2# Makefile for the kernel multimedia device drivers.
3# 3#
4 4
5obj-y := common/
6
5obj-$(CONFIG_VIDEO_MEDIA) += common/ 7obj-$(CONFIG_VIDEO_MEDIA) += common/
6 8
7# Since hybrid devices are here, should be compiled if DVB and/or V4L 9# Since hybrid devices are here, should be compiled if DVB and/or V4L
diff --git a/drivers/media/common/tuners/Kconfig b/drivers/media/common/tuners/Kconfig
index 5be85ff53e12..d6206540476b 100644
--- a/drivers/media/common/tuners/Kconfig
+++ b/drivers/media/common/tuners/Kconfig
@@ -1,6 +1,6 @@
1config MEDIA_ATTACH 1config MEDIA_ATTACH
2 bool "Load and attach frontend and tuner driver modules as needed" 2 bool "Load and attach frontend and tuner driver modules as needed"
3 depends on DVB_CORE 3 depends on VIDEO_MEDIA
4 depends on MODULES 4 depends on MODULES
5 help 5 help
6 Remove the static dependency of DVB card drivers on all 6 Remove the static dependency of DVB card drivers on all
@@ -19,10 +19,10 @@ config MEDIA_ATTACH
19 19
20config MEDIA_TUNER 20config MEDIA_TUNER
21 tristate 21 tristate
22 default DVB_CORE || VIDEO_DEV 22 default VIDEO_MEDIA && I2C
23 depends on DVB_CORE || VIDEO_DEV 23 depends on VIDEO_MEDIA && I2C
24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE 24 select MEDIA_TUNER_XC2028 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE 25 select MEDIA_TUNER_XC5000 if !MEDIA_TUNER_CUSTOMIZE && HOTPLUG
26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE 26 select MEDIA_TUNER_MT20XX if !MEDIA_TUNER_CUSTOMIZE
27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE 27 select MEDIA_TUNER_TDA8290 if !MEDIA_TUNER_CUSTOMIZE
28 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE 28 select MEDIA_TUNER_TEA5761 if !MEDIA_TUNER_CUSTOMIZE
@@ -46,7 +46,7 @@ if MEDIA_TUNER_CUSTOMIZE
46 46
47config MEDIA_TUNER_SIMPLE 47config MEDIA_TUNER_SIMPLE
48 tristate "Simple tuner support" 48 tristate "Simple tuner support"
49 depends on I2C 49 depends on VIDEO_MEDIA && I2C
50 select MEDIA_TUNER_TDA9887 50 select MEDIA_TUNER_TDA9887
51 default m if MEDIA_TUNER_CUSTOMIZE 51 default m if MEDIA_TUNER_CUSTOMIZE
52 help 52 help
@@ -54,7 +54,7 @@ config MEDIA_TUNER_SIMPLE
54 54
55config MEDIA_TUNER_TDA8290 55config MEDIA_TUNER_TDA8290
56 tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo" 56 tristate "TDA 8290/8295 + 8275(a)/18271 tuner combo"
57 depends on I2C 57 depends on VIDEO_MEDIA && I2C
58 select MEDIA_TUNER_TDA827X 58 select MEDIA_TUNER_TDA827X
59 select MEDIA_TUNER_TDA18271 59 select MEDIA_TUNER_TDA18271
60 default m if MEDIA_TUNER_CUSTOMIZE 60 default m if MEDIA_TUNER_CUSTOMIZE
@@ -63,21 +63,21 @@ config MEDIA_TUNER_TDA8290
63 63
64config MEDIA_TUNER_TDA827X 64config MEDIA_TUNER_TDA827X
65 tristate "Philips TDA827X silicon tuner" 65 tristate "Philips TDA827X silicon tuner"
66 depends on DVB_CORE && I2C 66 depends on VIDEO_MEDIA && I2C
67 default m if DVB_FE_CUSTOMISE 67 default m if DVB_FE_CUSTOMISE
68 help 68 help
69 A DVB-T silicon tuner module. Say Y when you want to support this tuner. 69 A DVB-T silicon tuner module. Say Y when you want to support this tuner.
70 70
71config MEDIA_TUNER_TDA18271 71config MEDIA_TUNER_TDA18271
72 tristate "NXP TDA18271 silicon tuner" 72 tristate "NXP TDA18271 silicon tuner"
73 depends on I2C 73 depends on VIDEO_MEDIA && I2C
74 default m if DVB_FE_CUSTOMISE 74 default m if DVB_FE_CUSTOMISE
75 help 75 help
76 A silicon tuner module. Say Y when you want to support this tuner. 76 A silicon tuner module. Say Y when you want to support this tuner.
77 77
78config MEDIA_TUNER_TDA9887 78config MEDIA_TUNER_TDA9887
79 tristate "TDA 9885/6/7 analog IF demodulator" 79 tristate "TDA 9885/6/7 analog IF demodulator"
80 depends on I2C 80 depends on VIDEO_MEDIA && I2C
81 default m if MEDIA_TUNER_CUSTOMIZE 81 default m if MEDIA_TUNER_CUSTOMIZE
82 help 82 help
83 Say Y here to include support for Philips TDA9885/6/7 83 Say Y here to include support for Philips TDA9885/6/7
@@ -85,67 +85,79 @@ config MEDIA_TUNER_TDA9887
85 85
86config MEDIA_TUNER_TEA5761 86config MEDIA_TUNER_TEA5761
87 tristate "TEA 5761 radio tuner (EXPERIMENTAL)" 87 tristate "TEA 5761 radio tuner (EXPERIMENTAL)"
88 depends on I2C && EXPERIMENTAL 88 depends on VIDEO_MEDIA && I2C
89 depends on EXPERIMENTAL
89 default m if MEDIA_TUNER_CUSTOMIZE 90 default m if MEDIA_TUNER_CUSTOMIZE
90 help 91 help
91 Say Y here to include support for the Philips TEA5761 radio tuner. 92 Say Y here to include support for the Philips TEA5761 radio tuner.
92 93
93config MEDIA_TUNER_TEA5767 94config MEDIA_TUNER_TEA5767
94 tristate "TEA 5767 radio tuner" 95 tristate "TEA 5767 radio tuner"
95 depends on I2C 96 depends on VIDEO_MEDIA && I2C
96 default m if MEDIA_TUNER_CUSTOMIZE 97 default m if MEDIA_TUNER_CUSTOMIZE
97 help 98 help
98 Say Y here to include support for the Philips TEA5767 radio tuner. 99 Say Y here to include support for the Philips TEA5767 radio tuner.
99 100
100config MEDIA_TUNER_MT20XX 101config MEDIA_TUNER_MT20XX
101 tristate "Microtune 2032 / 2050 tuners" 102 tristate "Microtune 2032 / 2050 tuners"
102 depends on I2C 103 depends on VIDEO_MEDIA && I2C
103 default m if MEDIA_TUNER_CUSTOMIZE 104 default m if MEDIA_TUNER_CUSTOMIZE
104 help 105 help
105 Say Y here to include support for the MT2032 / MT2050 tuner. 106 Say Y here to include support for the MT2032 / MT2050 tuner.
106 107
107config MEDIA_TUNER_MT2060 108config MEDIA_TUNER_MT2060
108 tristate "Microtune MT2060 silicon IF tuner" 109 tristate "Microtune MT2060 silicon IF tuner"
109 depends on I2C 110 depends on VIDEO_MEDIA && I2C
110 default m if DVB_FE_CUSTOMISE 111 default m if DVB_FE_CUSTOMISE
111 help 112 help
112 A driver for the silicon IF tuner MT2060 from Microtune. 113 A driver for the silicon IF tuner MT2060 from Microtune.
113 114
114config MEDIA_TUNER_MT2266 115config MEDIA_TUNER_MT2266
115 tristate "Microtune MT2266 silicon tuner" 116 tristate "Microtune MT2266 silicon tuner"
116 depends on I2C 117 depends on VIDEO_MEDIA && I2C
117 default m if DVB_FE_CUSTOMISE 118 default m if DVB_FE_CUSTOMISE
118 help 119 help
119 A driver for the silicon baseband tuner MT2266 from Microtune. 120 A driver for the silicon baseband tuner MT2266 from Microtune.
120 121
121config MEDIA_TUNER_MT2131 122config MEDIA_TUNER_MT2131
122 tristate "Microtune MT2131 silicon tuner" 123 tristate "Microtune MT2131 silicon tuner"
123 depends on I2C 124 depends on VIDEO_MEDIA && I2C
124 default m if DVB_FE_CUSTOMISE 125 default m if DVB_FE_CUSTOMISE
125 help 126 help
126 A driver for the silicon baseband tuner MT2131 from Microtune. 127 A driver for the silicon baseband tuner MT2131 from Microtune.
127 128
128config MEDIA_TUNER_QT1010 129config MEDIA_TUNER_QT1010
129 tristate "Quantek QT1010 silicon tuner" 130 tristate "Quantek QT1010 silicon tuner"
130 depends on DVB_CORE && I2C 131 depends on VIDEO_MEDIA && I2C
131 default m if DVB_FE_CUSTOMISE 132 default m if DVB_FE_CUSTOMISE
132 help 133 help
133 A driver for the silicon tuner QT1010 from Quantek. 134 A driver for the silicon tuner QT1010 from Quantek.
134 135
135config MEDIA_TUNER_XC2028 136config MEDIA_TUNER_XC2028
136 tristate "XCeive xc2028/xc3028 tuners" 137 tristate "XCeive xc2028/xc3028 tuners"
137 depends on I2C && FW_LOADER 138 depends on VIDEO_MEDIA && I2C
139 depends on HOTPLUG
140 select FW_LOADER
138 default m if MEDIA_TUNER_CUSTOMIZE 141 default m if MEDIA_TUNER_CUSTOMIZE
139 help 142 help
140 Say Y here to include support for the xc2028/xc3028 tuners. 143 Say Y here to include support for the xc2028/xc3028 tuners.
141 144
142config MEDIA_TUNER_XC5000 145config MEDIA_TUNER_XC5000
143 tristate "Xceive XC5000 silicon tuner" 146 tristate "Xceive XC5000 silicon tuner"
144 depends on I2C 147 depends on VIDEO_MEDIA && I2C
148 depends on HOTPLUG
149 select FW_LOADER
145 default m if DVB_FE_CUSTOMISE 150 default m if DVB_FE_CUSTOMISE
146 help 151 help
147 A driver for the silicon tuner XC5000 from Xceive. 152 A driver for the silicon tuner XC5000 from Xceive.
148 This device is only used inside a SiP called togther with a 153 This device is only used inside a SiP called togther with a
149 demodulator for now. 154 demodulator for now.
150 155
156config MEDIA_TUNER_MXL5005S
157 tristate "MaxLinear MSL5005S silicon tuner"
158 depends on VIDEO_MEDIA && I2C
159 default m if DVB_FE_CUSTOMISE
160 help
161 A driver for the silicon tuner MXL5005S from MaxLinear.
162
151endif # MEDIA_TUNER_CUSTOMIZE 163endif # MEDIA_TUNER_CUSTOMIZE
diff --git a/drivers/media/common/tuners/Makefile b/drivers/media/common/tuners/Makefile
index 236d9932fd92..55f7e6706297 100644
--- a/drivers/media/common/tuners/Makefile
+++ b/drivers/media/common/tuners/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_MEDIA_TUNER_MT2060) += mt2060.o
20obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o 20obj-$(CONFIG_MEDIA_TUNER_MT2266) += mt2266.o
21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o 21obj-$(CONFIG_MEDIA_TUNER_QT1010) += qt1010.o
22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o 22obj-$(CONFIG_MEDIA_TUNER_MT2131) += mt2131.o
23obj-$(CONFIG_MEDIA_TUNER_MXL5005S) += mxl5005s.o
23 24
24EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 25EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
25EXTRA_CFLAGS += -Idrivers/media/dvb/frontends 26EXTRA_CFLAGS += -Idrivers/media/dvb/frontends
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c
new file mode 100644
index 000000000000..5d05b5390f66
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.c
@@ -0,0 +1,4110 @@
1/*
2 MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
3
4 Copyright (C) 2008 MaxLinear
5 Copyright (C) 2006 Steven Toth <stoth@hauppauge.com>
6 Functions:
7 mxl5005s_reset()
8 mxl5005s_writereg()
9 mxl5005s_writeregs()
10 mxl5005s_init()
11 mxl5005s_reconfigure()
12 mxl5005s_AssignTunerMode()
13 mxl5005s_set_params()
14 mxl5005s_get_frequency()
15 mxl5005s_get_bandwidth()
16 mxl5005s_release()
17 mxl5005s_attach()
18
19 Copyright (C) 2008 Realtek
20 Copyright (C) 2008 Jan Hoogenraad
21 Functions:
22 mxl5005s_SetRfFreqHz()
23
24 This program is free software; you can redistribute it and/or modify
25 it under the terms of the GNU General Public License as published by
26 the Free Software Foundation; either version 2 of the License, or
27 (at your option) any later version.
28
29 This program is distributed in the hope that it will be useful,
30 but WITHOUT ANY WARRANTY; without even the implied warranty of
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 GNU General Public License for more details.
33
34 You should have received a copy of the GNU General Public License
35 along with this program; if not, write to the Free Software
36 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37
38*/
39
40/*
41 History of this driver (Steven Toth):
42 I was given a public release of a linux driver that included
43 support for the MaxLinear MXL5005S silicon tuner. Analysis of
44 the tuner driver showed clearly three things.
45
46 1. The tuner driver didn't support the LinuxTV tuner API
47 so the code Realtek added had to be removed.
48
49 2. A significant amount of the driver is reference driver code
50 from MaxLinear, I felt it was important to identify and
51 preserve this.
52
53 3. New code has to be added to interface correctly with the
54 LinuxTV API, as a regular kernel module.
55
56 Other than the reference driver enum's, I've clearly marked
57 sections of the code and retained the copyright of the
58 respective owners.
59*/
60#include <linux/kernel.h>
61#include <linux/init.h>
62#include <linux/module.h>
63#include <linux/string.h>
64#include <linux/slab.h>
65#include <linux/delay.h>
66#include "dvb_frontend.h"
67#include "mxl5005s.h"
68
69static int debug;
70
71#define dprintk(level, arg...) do { \
72 if (level <= debug) \
73 printk(arg); \
74 } while (0)
75
76#define TUNER_REGS_NUM 104
77#define INITCTRL_NUM 40
78
79#ifdef _MXL_PRODUCTION
80#define CHCTRL_NUM 39
81#else
82#define CHCTRL_NUM 36
83#endif
84
85#define MXLCTRL_NUM 189
86#define MASTER_CONTROL_ADDR 9
87
88/* Enumeration of Master Control Register State */
89enum master_control_state {
90 MC_LOAD_START = 1,
91 MC_POWER_DOWN,
92 MC_SYNTH_RESET,
93 MC_SEQ_OFF
94};
95
96/* Enumeration of MXL5005 Tuner Modulation Type */
97enum {
98 MXL_DEFAULT_MODULATION = 0,
99 MXL_DVBT,
100 MXL_ATSC,
101 MXL_QAM,
102 MXL_ANALOG_CABLE,
103 MXL_ANALOG_OTA
104} tuner_modu_type;
105
106/* MXL5005 Tuner Register Struct */
107struct TunerReg {
108 u16 Reg_Num; /* Tuner Register Address */
109 u16 Reg_Val; /* Current sw programmed value waiting to be writen */
110};
111
112enum {
113 /* Initialization Control Names */
114 DN_IQTN_AMP_CUT = 1, /* 1 */
115 BB_MODE, /* 2 */
116 BB_BUF, /* 3 */
117 BB_BUF_OA, /* 4 */
118 BB_ALPF_BANDSELECT, /* 5 */
119 BB_IQSWAP, /* 6 */
120 BB_DLPF_BANDSEL, /* 7 */
121 RFSYN_CHP_GAIN, /* 8 */
122 RFSYN_EN_CHP_HIGAIN, /* 9 */
123 AGC_IF, /* 10 */
124 AGC_RF, /* 11 */
125 IF_DIVVAL, /* 12 */
126 IF_VCO_BIAS, /* 13 */
127 CHCAL_INT_MOD_IF, /* 14 */
128 CHCAL_FRAC_MOD_IF, /* 15 */
129 DRV_RES_SEL, /* 16 */
130 I_DRIVER, /* 17 */
131 EN_AAF, /* 18 */
132 EN_3P, /* 19 */
133 EN_AUX_3P, /* 20 */
134 SEL_AAF_BAND, /* 21 */
135 SEQ_ENCLK16_CLK_OUT, /* 22 */
136 SEQ_SEL4_16B, /* 23 */
137 XTAL_CAPSELECT, /* 24 */
138 IF_SEL_DBL, /* 25 */
139 RFSYN_R_DIV, /* 26 */
140 SEQ_EXTSYNTHCALIF, /* 27 */
141 SEQ_EXTDCCAL, /* 28 */
142 AGC_EN_RSSI, /* 29 */
143 RFA_ENCLKRFAGC, /* 30 */
144 RFA_RSSI_REFH, /* 31 */
145 RFA_RSSI_REF, /* 32 */
146 RFA_RSSI_REFL, /* 33 */
147 RFA_FLR, /* 34 */
148 RFA_CEIL, /* 35 */
149 SEQ_EXTIQFSMPULSE, /* 36 */
150 OVERRIDE_1, /* 37 */
151 BB_INITSTATE_DLPF_TUNE, /* 38 */
152 TG_R_DIV, /* 39 */
153 EN_CHP_LIN_B, /* 40 */
154
155 /* Channel Change Control Names */
156 DN_POLY = 51, /* 51 */
157 DN_RFGAIN, /* 52 */
158 DN_CAP_RFLPF, /* 53 */
159 DN_EN_VHFUHFBAR, /* 54 */
160 DN_GAIN_ADJUST, /* 55 */
161 DN_IQTNBUF_AMP, /* 56 */
162 DN_IQTNGNBFBIAS_BST, /* 57 */
163 RFSYN_EN_OUTMUX, /* 58 */
164 RFSYN_SEL_VCO_OUT, /* 59 */
165 RFSYN_SEL_VCO_HI, /* 60 */
166 RFSYN_SEL_DIVM, /* 61 */
167 RFSYN_RF_DIV_BIAS, /* 62 */
168 DN_SEL_FREQ, /* 63 */
169 RFSYN_VCO_BIAS, /* 64 */
170 CHCAL_INT_MOD_RF, /* 65 */
171 CHCAL_FRAC_MOD_RF, /* 66 */
172 RFSYN_LPF_R, /* 67 */
173 CHCAL_EN_INT_RF, /* 68 */
174 TG_LO_DIVVAL, /* 69 */
175 TG_LO_SELVAL, /* 70 */
176 TG_DIV_VAL, /* 71 */
177 TG_VCO_BIAS, /* 72 */
178 SEQ_EXTPOWERUP, /* 73 */
179 OVERRIDE_2, /* 74 */
180 OVERRIDE_3, /* 75 */
181 OVERRIDE_4, /* 76 */
182 SEQ_FSM_PULSE, /* 77 */
183 GPIO_4B, /* 78 */
184 GPIO_3B, /* 79 */
185 GPIO_4, /* 80 */
186 GPIO_3, /* 81 */
187 GPIO_1B, /* 82 */
188 DAC_A_ENABLE, /* 83 */
189 DAC_B_ENABLE, /* 84 */
190 DAC_DIN_A, /* 85 */
191 DAC_DIN_B, /* 86 */
192#ifdef _MXL_PRODUCTION
193 RFSYN_EN_DIV, /* 87 */
194 RFSYN_DIVM, /* 88 */
195 DN_BYPASS_AGC_I2C /* 89 */
196#endif
197} MXL5005_ControlName;
198
199/*
200 * The following context is source code provided by MaxLinear.
201 * MaxLinear source code - Common_MXL.h (?)
202 */
203
204/* Constants */
205#define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104
206#define MXL5005S_LATCH_BYTE 0xfe
207
208/* Register address, MSB, and LSB */
209#define MXL5005S_BB_IQSWAP_ADDR 59
210#define MXL5005S_BB_IQSWAP_MSB 0
211#define MXL5005S_BB_IQSWAP_LSB 0
212
213#define MXL5005S_BB_DLPF_BANDSEL_ADDR 53
214#define MXL5005S_BB_DLPF_BANDSEL_MSB 4
215#define MXL5005S_BB_DLPF_BANDSEL_LSB 3
216
217/* Standard modes */
218enum {
219 MXL5005S_STANDARD_DVBT,
220 MXL5005S_STANDARD_ATSC,
221};
222#define MXL5005S_STANDARD_MODE_NUM 2
223
224/* Bandwidth modes */
225enum {
226 MXL5005S_BANDWIDTH_6MHZ = 6000000,
227 MXL5005S_BANDWIDTH_7MHZ = 7000000,
228 MXL5005S_BANDWIDTH_8MHZ = 8000000,
229};
230#define MXL5005S_BANDWIDTH_MODE_NUM 3
231
232/* MXL5005 Tuner Control Struct */
233struct TunerControl {
234 u16 Ctrl_Num; /* Control Number */
235 u16 size; /* Number of bits to represent Value */
236 u16 addr[25]; /* Array of Tuner Register Address for each bit pos */
237 u16 bit[25]; /* Array of bit pos in Reg Addr for each bit pos */
238 u16 val[25]; /* Binary representation of Value */
239};
240
241/* MXL5005 Tuner Struct */
242struct mxl5005s_state {
243 u8 Mode; /* 0: Analog Mode ; 1: Digital Mode */
244 u8 IF_Mode; /* for Analog Mode, 0: zero IF; 1: low IF */
245 u32 Chan_Bandwidth; /* filter channel bandwidth (6, 7, 8) */
246 u32 IF_OUT; /* Desired IF Out Frequency */
247 u16 IF_OUT_LOAD; /* IF Out Load Resistor (200/300 Ohms) */
248 u32 RF_IN; /* RF Input Frequency */
249 u32 Fxtal; /* XTAL Frequency */
250 u8 AGC_Mode; /* AGC Mode 0: Dual AGC; 1: Single AGC */
251 u16 TOP; /* Value: take over point */
252 u8 CLOCK_OUT; /* 0: turn off clk out; 1: turn on clock out */
253 u8 DIV_OUT; /* 4MHz or 16MHz */
254 u8 CAPSELECT; /* 0: disable On-Chip pulling cap; 1: enable */
255 u8 EN_RSSI; /* 0: disable RSSI; 1: enable RSSI */
256
257 /* Modulation Type; */
258 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
259 u8 Mod_Type;
260
261 /* Tracking Filter Type */
262 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
263 u8 TF_Type;
264
265 /* Calculated Settings */
266 u32 RF_LO; /* Synth RF LO Frequency */
267 u32 IF_LO; /* Synth IF LO Frequency */
268 u32 TG_LO; /* Synth TG_LO Frequency */
269
270 /* Pointers to ControlName Arrays */
271 u16 Init_Ctrl_Num; /* Number of INIT Control Names */
272 struct TunerControl
273 Init_Ctrl[INITCTRL_NUM]; /* INIT Control Names Array Pointer */
274
275 u16 CH_Ctrl_Num; /* Number of CH Control Names */
276 struct TunerControl
277 CH_Ctrl[CHCTRL_NUM]; /* CH Control Name Array Pointer */
278
279 u16 MXL_Ctrl_Num; /* Number of MXL Control Names */
280 struct TunerControl
281 MXL_Ctrl[MXLCTRL_NUM]; /* MXL Control Name Array Pointer */
282
283 /* Pointer to Tuner Register Array */
284 u16 TunerRegs_Num; /* Number of Tuner Registers */
285 struct TunerReg
286 TunerRegs[TUNER_REGS_NUM]; /* Tuner Register Array Pointer */
287
288 /* Linux driver framework specific */
289 struct mxl5005s_config *config;
290 struct dvb_frontend *frontend;
291 struct i2c_adapter *i2c;
292
293 /* Cache values */
294 u32 current_mode;
295
296};
297
298static u16 MXL_GetMasterControl(u8 *MasterReg, int state);
299static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value);
300static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value);
301static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
302 u8 bitVal);
303static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum,
304 u8 *RegVal, int *count);
305static u32 MXL_Ceiling(u32 value, u32 resolution);
306static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal);
307static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
308 u32 value, u16 controlGroup);
309static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val);
310static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
311 u8 *RegVal, int *count);
312static u32 MXL_GetXtalInt(u32 Xtal_Freq);
313static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq);
314static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe);
315static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe);
316static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
317 u8 *RegVal, int *count);
318static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
319 u8 *datatable, u8 len);
320static u16 MXL_IFSynthInit(struct dvb_frontend *fe);
321static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
322 u32 bandwidth);
323static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
324 u32 bandwidth);
325
326/* ----------------------------------------------------------------
327 * Begin: Custom code salvaged from the Realtek driver.
328 * Copyright (C) 2008 Realtek
329 * Copyright (C) 2008 Jan Hoogenraad
330 * This code is placed under the terms of the GNU General Public License
331 *
332 * Released by Realtek under GPLv2.
333 * Thanks to Realtek for a lot of support we received !
334 *
335 * Revision: 080314 - original version
336 */
337
338static int mxl5005s_SetRfFreqHz(struct dvb_frontend *fe, unsigned long RfFreqHz)
339{
340 struct mxl5005s_state *state = fe->tuner_priv;
341 unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
342 unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
343 int TableLen;
344
345 u32 IfDivval = 0;
346 unsigned char MasterControlByte;
347
348 dprintk(1, "%s() freq=%ld\n", __func__, RfFreqHz);
349
350 /* Set MxL5005S tuner RF frequency according to example code. */
351
352 /* Tuner RF frequency setting stage 0 */
353 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
354 AddrTable[0] = MASTER_CONTROL_ADDR;
355 ByteTable[0] |= state->config->AgcMasterByte;
356
357 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
358
359 /* Tuner RF frequency setting stage 1 */
360 MXL_TuneRF(fe, RfFreqHz);
361
362 MXL_ControlRead(fe, IF_DIVVAL, &IfDivval);
363
364 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 0);
365 MXL_ControlWrite(fe, SEQ_EXTPOWERUP, 1);
366 MXL_ControlWrite(fe, IF_DIVVAL, 8);
367 MXL_GetCHRegister(fe, AddrTable, ByteTable, &TableLen);
368
369 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
370 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
371 ByteTable[TableLen] = MasterControlByte |
372 state->config->AgcMasterByte;
373 TableLen += 1;
374
375 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
376
377 /* Wait 30 ms. */
378 msleep(150);
379
380 /* Tuner RF frequency setting stage 2 */
381 MXL_ControlWrite(fe, SEQ_FSM_PULSE, 1);
382 MXL_ControlWrite(fe, IF_DIVVAL, IfDivval);
383 MXL_GetCHRegister_ZeroIF(fe, AddrTable, ByteTable, &TableLen);
384
385 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START);
386 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
387 ByteTable[TableLen] = MasterControlByte |
388 state->config->AgcMasterByte ;
389 TableLen += 1;
390
391 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
392
393 msleep(100);
394
395 return 0;
396}
397/* End: Custom code taken from the Realtek driver */
398
399/* ----------------------------------------------------------------
400 * Begin: Reference driver code found in the Realtek driver.
401 * Copyright (C) 2008 MaxLinear
402 */
403static u16 MXL5005_RegisterInit(struct dvb_frontend *fe)
404{
405 struct mxl5005s_state *state = fe->tuner_priv;
406 state->TunerRegs_Num = TUNER_REGS_NUM ;
407
408 state->TunerRegs[0].Reg_Num = 9 ;
409 state->TunerRegs[0].Reg_Val = 0x40 ;
410
411 state->TunerRegs[1].Reg_Num = 11 ;
412 state->TunerRegs[1].Reg_Val = 0x19 ;
413
414 state->TunerRegs[2].Reg_Num = 12 ;
415 state->TunerRegs[2].Reg_Val = 0x60 ;
416
417 state->TunerRegs[3].Reg_Num = 13 ;
418 state->TunerRegs[3].Reg_Val = 0x00 ;
419
420 state->TunerRegs[4].Reg_Num = 14 ;
421 state->TunerRegs[4].Reg_Val = 0x00 ;
422
423 state->TunerRegs[5].Reg_Num = 15 ;
424 state->TunerRegs[5].Reg_Val = 0xC0 ;
425
426 state->TunerRegs[6].Reg_Num = 16 ;
427 state->TunerRegs[6].Reg_Val = 0x00 ;
428
429 state->TunerRegs[7].Reg_Num = 17 ;
430 state->TunerRegs[7].Reg_Val = 0x00 ;
431
432 state->TunerRegs[8].Reg_Num = 18 ;
433 state->TunerRegs[8].Reg_Val = 0x00 ;
434
435 state->TunerRegs[9].Reg_Num = 19 ;
436 state->TunerRegs[9].Reg_Val = 0x34 ;
437
438 state->TunerRegs[10].Reg_Num = 21 ;
439 state->TunerRegs[10].Reg_Val = 0x00 ;
440
441 state->TunerRegs[11].Reg_Num = 22 ;
442 state->TunerRegs[11].Reg_Val = 0x6B ;
443
444 state->TunerRegs[12].Reg_Num = 23 ;
445 state->TunerRegs[12].Reg_Val = 0x35 ;
446
447 state->TunerRegs[13].Reg_Num = 24 ;
448 state->TunerRegs[13].Reg_Val = 0x70 ;
449
450 state->TunerRegs[14].Reg_Num = 25 ;
451 state->TunerRegs[14].Reg_Val = 0x3E ;
452
453 state->TunerRegs[15].Reg_Num = 26 ;
454 state->TunerRegs[15].Reg_Val = 0x82 ;
455
456 state->TunerRegs[16].Reg_Num = 31 ;
457 state->TunerRegs[16].Reg_Val = 0x00 ;
458
459 state->TunerRegs[17].Reg_Num = 32 ;
460 state->TunerRegs[17].Reg_Val = 0x40 ;
461
462 state->TunerRegs[18].Reg_Num = 33 ;
463 state->TunerRegs[18].Reg_Val = 0x53 ;
464
465 state->TunerRegs[19].Reg_Num = 34 ;
466 state->TunerRegs[19].Reg_Val = 0x81 ;
467
468 state->TunerRegs[20].Reg_Num = 35 ;
469 state->TunerRegs[20].Reg_Val = 0xC9 ;
470
471 state->TunerRegs[21].Reg_Num = 36 ;
472 state->TunerRegs[21].Reg_Val = 0x01 ;
473
474 state->TunerRegs[22].Reg_Num = 37 ;
475 state->TunerRegs[22].Reg_Val = 0x00 ;
476
477 state->TunerRegs[23].Reg_Num = 41 ;
478 state->TunerRegs[23].Reg_Val = 0x00 ;
479
480 state->TunerRegs[24].Reg_Num = 42 ;
481 state->TunerRegs[24].Reg_Val = 0xF8 ;
482
483 state->TunerRegs[25].Reg_Num = 43 ;
484 state->TunerRegs[25].Reg_Val = 0x43 ;
485
486 state->TunerRegs[26].Reg_Num = 44 ;
487 state->TunerRegs[26].Reg_Val = 0x20 ;
488
489 state->TunerRegs[27].Reg_Num = 45 ;
490 state->TunerRegs[27].Reg_Val = 0x80 ;
491
492 state->TunerRegs[28].Reg_Num = 46 ;
493 state->TunerRegs[28].Reg_Val = 0x88 ;
494
495 state->TunerRegs[29].Reg_Num = 47 ;
496 state->TunerRegs[29].Reg_Val = 0x86 ;
497
498 state->TunerRegs[30].Reg_Num = 48 ;
499 state->TunerRegs[30].Reg_Val = 0x00 ;
500
501 state->TunerRegs[31].Reg_Num = 49 ;
502 state->TunerRegs[31].Reg_Val = 0x00 ;
503
504 state->TunerRegs[32].Reg_Num = 53 ;
505 state->TunerRegs[32].Reg_Val = 0x94 ;
506
507 state->TunerRegs[33].Reg_Num = 54 ;
508 state->TunerRegs[33].Reg_Val = 0xFA ;
509
510 state->TunerRegs[34].Reg_Num = 55 ;
511 state->TunerRegs[34].Reg_Val = 0x92 ;
512
513 state->TunerRegs[35].Reg_Num = 56 ;
514 state->TunerRegs[35].Reg_Val = 0x80 ;
515
516 state->TunerRegs[36].Reg_Num = 57 ;
517 state->TunerRegs[36].Reg_Val = 0x41 ;
518
519 state->TunerRegs[37].Reg_Num = 58 ;
520 state->TunerRegs[37].Reg_Val = 0xDB ;
521
522 state->TunerRegs[38].Reg_Num = 59 ;
523 state->TunerRegs[38].Reg_Val = 0x00 ;
524
525 state->TunerRegs[39].Reg_Num = 60 ;
526 state->TunerRegs[39].Reg_Val = 0x00 ;
527
528 state->TunerRegs[40].Reg_Num = 61 ;
529 state->TunerRegs[40].Reg_Val = 0x00 ;
530
531 state->TunerRegs[41].Reg_Num = 62 ;
532 state->TunerRegs[41].Reg_Val = 0x00 ;
533
534 state->TunerRegs[42].Reg_Num = 65 ;
535 state->TunerRegs[42].Reg_Val = 0xF8 ;
536
537 state->TunerRegs[43].Reg_Num = 66 ;
538 state->TunerRegs[43].Reg_Val = 0xE4 ;
539
540 state->TunerRegs[44].Reg_Num = 67 ;
541 state->TunerRegs[44].Reg_Val = 0x90 ;
542
543 state->TunerRegs[45].Reg_Num = 68 ;
544 state->TunerRegs[45].Reg_Val = 0xC0 ;
545
546 state->TunerRegs[46].Reg_Num = 69 ;
547 state->TunerRegs[46].Reg_Val = 0x01 ;
548
549 state->TunerRegs[47].Reg_Num = 70 ;
550 state->TunerRegs[47].Reg_Val = 0x50 ;
551
552 state->TunerRegs[48].Reg_Num = 71 ;
553 state->TunerRegs[48].Reg_Val = 0x06 ;
554
555 state->TunerRegs[49].Reg_Num = 72 ;
556 state->TunerRegs[49].Reg_Val = 0x00 ;
557
558 state->TunerRegs[50].Reg_Num = 73 ;
559 state->TunerRegs[50].Reg_Val = 0x20 ;
560
561 state->TunerRegs[51].Reg_Num = 76 ;
562 state->TunerRegs[51].Reg_Val = 0xBB ;
563
564 state->TunerRegs[52].Reg_Num = 77 ;
565 state->TunerRegs[52].Reg_Val = 0x13 ;
566
567 state->TunerRegs[53].Reg_Num = 81 ;
568 state->TunerRegs[53].Reg_Val = 0x04 ;
569
570 state->TunerRegs[54].Reg_Num = 82 ;
571 state->TunerRegs[54].Reg_Val = 0x75 ;
572
573 state->TunerRegs[55].Reg_Num = 83 ;
574 state->TunerRegs[55].Reg_Val = 0x00 ;
575
576 state->TunerRegs[56].Reg_Num = 84 ;
577 state->TunerRegs[56].Reg_Val = 0x00 ;
578
579 state->TunerRegs[57].Reg_Num = 85 ;
580 state->TunerRegs[57].Reg_Val = 0x00 ;
581
582 state->TunerRegs[58].Reg_Num = 91 ;
583 state->TunerRegs[58].Reg_Val = 0x70 ;
584
585 state->TunerRegs[59].Reg_Num = 92 ;
586 state->TunerRegs[59].Reg_Val = 0x00 ;
587
588 state->TunerRegs[60].Reg_Num = 93 ;
589 state->TunerRegs[60].Reg_Val = 0x00 ;
590
591 state->TunerRegs[61].Reg_Num = 94 ;
592 state->TunerRegs[61].Reg_Val = 0x00 ;
593
594 state->TunerRegs[62].Reg_Num = 95 ;
595 state->TunerRegs[62].Reg_Val = 0x0C ;
596
597 state->TunerRegs[63].Reg_Num = 96 ;
598 state->TunerRegs[63].Reg_Val = 0x00 ;
599
600 state->TunerRegs[64].Reg_Num = 97 ;
601 state->TunerRegs[64].Reg_Val = 0x00 ;
602
603 state->TunerRegs[65].Reg_Num = 98 ;
604 state->TunerRegs[65].Reg_Val = 0xE2 ;
605
606 state->TunerRegs[66].Reg_Num = 99 ;
607 state->TunerRegs[66].Reg_Val = 0x00 ;
608
609 state->TunerRegs[67].Reg_Num = 100 ;
610 state->TunerRegs[67].Reg_Val = 0x00 ;
611
612 state->TunerRegs[68].Reg_Num = 101 ;
613 state->TunerRegs[68].Reg_Val = 0x12 ;
614
615 state->TunerRegs[69].Reg_Num = 102 ;
616 state->TunerRegs[69].Reg_Val = 0x80 ;
617
618 state->TunerRegs[70].Reg_Num = 103 ;
619 state->TunerRegs[70].Reg_Val = 0x32 ;
620
621 state->TunerRegs[71].Reg_Num = 104 ;
622 state->TunerRegs[71].Reg_Val = 0xB4 ;
623
624 state->TunerRegs[72].Reg_Num = 105 ;
625 state->TunerRegs[72].Reg_Val = 0x60 ;
626
627 state->TunerRegs[73].Reg_Num = 106 ;
628 state->TunerRegs[73].Reg_Val = 0x83 ;
629
630 state->TunerRegs[74].Reg_Num = 107 ;
631 state->TunerRegs[74].Reg_Val = 0x84 ;
632
633 state->TunerRegs[75].Reg_Num = 108 ;
634 state->TunerRegs[75].Reg_Val = 0x9C ;
635
636 state->TunerRegs[76].Reg_Num = 109 ;
637 state->TunerRegs[76].Reg_Val = 0x02 ;
638
639 state->TunerRegs[77].Reg_Num = 110 ;
640 state->TunerRegs[77].Reg_Val = 0x81 ;
641
642 state->TunerRegs[78].Reg_Num = 111 ;
643 state->TunerRegs[78].Reg_Val = 0xC0 ;
644
645 state->TunerRegs[79].Reg_Num = 112 ;
646 state->TunerRegs[79].Reg_Val = 0x10 ;
647
648 state->TunerRegs[80].Reg_Num = 131 ;
649 state->TunerRegs[80].Reg_Val = 0x8A ;
650
651 state->TunerRegs[81].Reg_Num = 132 ;
652 state->TunerRegs[81].Reg_Val = 0x10 ;
653
654 state->TunerRegs[82].Reg_Num = 133 ;
655 state->TunerRegs[82].Reg_Val = 0x24 ;
656
657 state->TunerRegs[83].Reg_Num = 134 ;
658 state->TunerRegs[83].Reg_Val = 0x00 ;
659
660 state->TunerRegs[84].Reg_Num = 135 ;
661 state->TunerRegs[84].Reg_Val = 0x00 ;
662
663 state->TunerRegs[85].Reg_Num = 136 ;
664 state->TunerRegs[85].Reg_Val = 0x7E ;
665
666 state->TunerRegs[86].Reg_Num = 137 ;
667 state->TunerRegs[86].Reg_Val = 0x40 ;
668
669 state->TunerRegs[87].Reg_Num = 138 ;
670 state->TunerRegs[87].Reg_Val = 0x38 ;
671
672 state->TunerRegs[88].Reg_Num = 146 ;
673 state->TunerRegs[88].Reg_Val = 0xF6 ;
674
675 state->TunerRegs[89].Reg_Num = 147 ;
676 state->TunerRegs[89].Reg_Val = 0x1A ;
677
678 state->TunerRegs[90].Reg_Num = 148 ;
679 state->TunerRegs[90].Reg_Val = 0x62 ;
680
681 state->TunerRegs[91].Reg_Num = 149 ;
682 state->TunerRegs[91].Reg_Val = 0x33 ;
683
684 state->TunerRegs[92].Reg_Num = 150 ;
685 state->TunerRegs[92].Reg_Val = 0x80 ;
686
687 state->TunerRegs[93].Reg_Num = 156 ;
688 state->TunerRegs[93].Reg_Val = 0x56 ;
689
690 state->TunerRegs[94].Reg_Num = 157 ;
691 state->TunerRegs[94].Reg_Val = 0x17 ;
692
693 state->TunerRegs[95].Reg_Num = 158 ;
694 state->TunerRegs[95].Reg_Val = 0xA9 ;
695
696 state->TunerRegs[96].Reg_Num = 159 ;
697 state->TunerRegs[96].Reg_Val = 0x00 ;
698
699 state->TunerRegs[97].Reg_Num = 160 ;
700 state->TunerRegs[97].Reg_Val = 0x00 ;
701
702 state->TunerRegs[98].Reg_Num = 161 ;
703 state->TunerRegs[98].Reg_Val = 0x00 ;
704
705 state->TunerRegs[99].Reg_Num = 162 ;
706 state->TunerRegs[99].Reg_Val = 0x40 ;
707
708 state->TunerRegs[100].Reg_Num = 166 ;
709 state->TunerRegs[100].Reg_Val = 0xAE ;
710
711 state->TunerRegs[101].Reg_Num = 167 ;
712 state->TunerRegs[101].Reg_Val = 0x1B ;
713
714 state->TunerRegs[102].Reg_Num = 168 ;
715 state->TunerRegs[102].Reg_Val = 0xF2 ;
716
717 state->TunerRegs[103].Reg_Num = 195 ;
718 state->TunerRegs[103].Reg_Val = 0x00 ;
719
720 return 0 ;
721}
722
723static u16 MXL5005_ControlInit(struct dvb_frontend *fe)
724{
725 struct mxl5005s_state *state = fe->tuner_priv;
726 state->Init_Ctrl_Num = INITCTRL_NUM;
727
728 state->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ;
729 state->Init_Ctrl[0].size = 1 ;
730 state->Init_Ctrl[0].addr[0] = 73;
731 state->Init_Ctrl[0].bit[0] = 7;
732 state->Init_Ctrl[0].val[0] = 0;
733
734 state->Init_Ctrl[1].Ctrl_Num = BB_MODE ;
735 state->Init_Ctrl[1].size = 1 ;
736 state->Init_Ctrl[1].addr[0] = 53;
737 state->Init_Ctrl[1].bit[0] = 2;
738 state->Init_Ctrl[1].val[0] = 1;
739
740 state->Init_Ctrl[2].Ctrl_Num = BB_BUF ;
741 state->Init_Ctrl[2].size = 2 ;
742 state->Init_Ctrl[2].addr[0] = 53;
743 state->Init_Ctrl[2].bit[0] = 1;
744 state->Init_Ctrl[2].val[0] = 0;
745 state->Init_Ctrl[2].addr[1] = 57;
746 state->Init_Ctrl[2].bit[1] = 0;
747 state->Init_Ctrl[2].val[1] = 1;
748
749 state->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ;
750 state->Init_Ctrl[3].size = 1 ;
751 state->Init_Ctrl[3].addr[0] = 53;
752 state->Init_Ctrl[3].bit[0] = 0;
753 state->Init_Ctrl[3].val[0] = 0;
754
755 state->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ;
756 state->Init_Ctrl[4].size = 3 ;
757 state->Init_Ctrl[4].addr[0] = 53;
758 state->Init_Ctrl[4].bit[0] = 5;
759 state->Init_Ctrl[4].val[0] = 0;
760 state->Init_Ctrl[4].addr[1] = 53;
761 state->Init_Ctrl[4].bit[1] = 6;
762 state->Init_Ctrl[4].val[1] = 0;
763 state->Init_Ctrl[4].addr[2] = 53;
764 state->Init_Ctrl[4].bit[2] = 7;
765 state->Init_Ctrl[4].val[2] = 1;
766
767 state->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ;
768 state->Init_Ctrl[5].size = 1 ;
769 state->Init_Ctrl[5].addr[0] = 59;
770 state->Init_Ctrl[5].bit[0] = 0;
771 state->Init_Ctrl[5].val[0] = 0;
772
773 state->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ;
774 state->Init_Ctrl[6].size = 2 ;
775 state->Init_Ctrl[6].addr[0] = 53;
776 state->Init_Ctrl[6].bit[0] = 3;
777 state->Init_Ctrl[6].val[0] = 0;
778 state->Init_Ctrl[6].addr[1] = 53;
779 state->Init_Ctrl[6].bit[1] = 4;
780 state->Init_Ctrl[6].val[1] = 1;
781
782 state->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ;
783 state->Init_Ctrl[7].size = 4 ;
784 state->Init_Ctrl[7].addr[0] = 22;
785 state->Init_Ctrl[7].bit[0] = 4;
786 state->Init_Ctrl[7].val[0] = 0;
787 state->Init_Ctrl[7].addr[1] = 22;
788 state->Init_Ctrl[7].bit[1] = 5;
789 state->Init_Ctrl[7].val[1] = 1;
790 state->Init_Ctrl[7].addr[2] = 22;
791 state->Init_Ctrl[7].bit[2] = 6;
792 state->Init_Ctrl[7].val[2] = 1;
793 state->Init_Ctrl[7].addr[3] = 22;
794 state->Init_Ctrl[7].bit[3] = 7;
795 state->Init_Ctrl[7].val[3] = 0;
796
797 state->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ;
798 state->Init_Ctrl[8].size = 1 ;
799 state->Init_Ctrl[8].addr[0] = 22;
800 state->Init_Ctrl[8].bit[0] = 2;
801 state->Init_Ctrl[8].val[0] = 0;
802
803 state->Init_Ctrl[9].Ctrl_Num = AGC_IF ;
804 state->Init_Ctrl[9].size = 4 ;
805 state->Init_Ctrl[9].addr[0] = 76;
806 state->Init_Ctrl[9].bit[0] = 0;
807 state->Init_Ctrl[9].val[0] = 1;
808 state->Init_Ctrl[9].addr[1] = 76;
809 state->Init_Ctrl[9].bit[1] = 1;
810 state->Init_Ctrl[9].val[1] = 1;
811 state->Init_Ctrl[9].addr[2] = 76;
812 state->Init_Ctrl[9].bit[2] = 2;
813 state->Init_Ctrl[9].val[2] = 0;
814 state->Init_Ctrl[9].addr[3] = 76;
815 state->Init_Ctrl[9].bit[3] = 3;
816 state->Init_Ctrl[9].val[3] = 1;
817
818 state->Init_Ctrl[10].Ctrl_Num = AGC_RF ;
819 state->Init_Ctrl[10].size = 4 ;
820 state->Init_Ctrl[10].addr[0] = 76;
821 state->Init_Ctrl[10].bit[0] = 4;
822 state->Init_Ctrl[10].val[0] = 1;
823 state->Init_Ctrl[10].addr[1] = 76;
824 state->Init_Ctrl[10].bit[1] = 5;
825 state->Init_Ctrl[10].val[1] = 1;
826 state->Init_Ctrl[10].addr[2] = 76;
827 state->Init_Ctrl[10].bit[2] = 6;
828 state->Init_Ctrl[10].val[2] = 0;
829 state->Init_Ctrl[10].addr[3] = 76;
830 state->Init_Ctrl[10].bit[3] = 7;
831 state->Init_Ctrl[10].val[3] = 1;
832
833 state->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ;
834 state->Init_Ctrl[11].size = 5 ;
835 state->Init_Ctrl[11].addr[0] = 43;
836 state->Init_Ctrl[11].bit[0] = 3;
837 state->Init_Ctrl[11].val[0] = 0;
838 state->Init_Ctrl[11].addr[1] = 43;
839 state->Init_Ctrl[11].bit[1] = 4;
840 state->Init_Ctrl[11].val[1] = 0;
841 state->Init_Ctrl[11].addr[2] = 43;
842 state->Init_Ctrl[11].bit[2] = 5;
843 state->Init_Ctrl[11].val[2] = 0;
844 state->Init_Ctrl[11].addr[3] = 43;
845 state->Init_Ctrl[11].bit[3] = 6;
846 state->Init_Ctrl[11].val[3] = 1;
847 state->Init_Ctrl[11].addr[4] = 43;
848 state->Init_Ctrl[11].bit[4] = 7;
849 state->Init_Ctrl[11].val[4] = 0;
850
851 state->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ;
852 state->Init_Ctrl[12].size = 6 ;
853 state->Init_Ctrl[12].addr[0] = 44;
854 state->Init_Ctrl[12].bit[0] = 2;
855 state->Init_Ctrl[12].val[0] = 0;
856 state->Init_Ctrl[12].addr[1] = 44;
857 state->Init_Ctrl[12].bit[1] = 3;
858 state->Init_Ctrl[12].val[1] = 0;
859 state->Init_Ctrl[12].addr[2] = 44;
860 state->Init_Ctrl[12].bit[2] = 4;
861 state->Init_Ctrl[12].val[2] = 0;
862 state->Init_Ctrl[12].addr[3] = 44;
863 state->Init_Ctrl[12].bit[3] = 5;
864 state->Init_Ctrl[12].val[3] = 1;
865 state->Init_Ctrl[12].addr[4] = 44;
866 state->Init_Ctrl[12].bit[4] = 6;
867 state->Init_Ctrl[12].val[4] = 0;
868 state->Init_Ctrl[12].addr[5] = 44;
869 state->Init_Ctrl[12].bit[5] = 7;
870 state->Init_Ctrl[12].val[5] = 0;
871
872 state->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ;
873 state->Init_Ctrl[13].size = 7 ;
874 state->Init_Ctrl[13].addr[0] = 11;
875 state->Init_Ctrl[13].bit[0] = 0;
876 state->Init_Ctrl[13].val[0] = 1;
877 state->Init_Ctrl[13].addr[1] = 11;
878 state->Init_Ctrl[13].bit[1] = 1;
879 state->Init_Ctrl[13].val[1] = 0;
880 state->Init_Ctrl[13].addr[2] = 11;
881 state->Init_Ctrl[13].bit[2] = 2;
882 state->Init_Ctrl[13].val[2] = 0;
883 state->Init_Ctrl[13].addr[3] = 11;
884 state->Init_Ctrl[13].bit[3] = 3;
885 state->Init_Ctrl[13].val[3] = 1;
886 state->Init_Ctrl[13].addr[4] = 11;
887 state->Init_Ctrl[13].bit[4] = 4;
888 state->Init_Ctrl[13].val[4] = 1;
889 state->Init_Ctrl[13].addr[5] = 11;
890 state->Init_Ctrl[13].bit[5] = 5;
891 state->Init_Ctrl[13].val[5] = 0;
892 state->Init_Ctrl[13].addr[6] = 11;
893 state->Init_Ctrl[13].bit[6] = 6;
894 state->Init_Ctrl[13].val[6] = 0;
895
896 state->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ;
897 state->Init_Ctrl[14].size = 16 ;
898 state->Init_Ctrl[14].addr[0] = 13;
899 state->Init_Ctrl[14].bit[0] = 0;
900 state->Init_Ctrl[14].val[0] = 0;
901 state->Init_Ctrl[14].addr[1] = 13;
902 state->Init_Ctrl[14].bit[1] = 1;
903 state->Init_Ctrl[14].val[1] = 0;
904 state->Init_Ctrl[14].addr[2] = 13;
905 state->Init_Ctrl[14].bit[2] = 2;
906 state->Init_Ctrl[14].val[2] = 0;
907 state->Init_Ctrl[14].addr[3] = 13;
908 state->Init_Ctrl[14].bit[3] = 3;
909 state->Init_Ctrl[14].val[3] = 0;
910 state->Init_Ctrl[14].addr[4] = 13;
911 state->Init_Ctrl[14].bit[4] = 4;
912 state->Init_Ctrl[14].val[4] = 0;
913 state->Init_Ctrl[14].addr[5] = 13;
914 state->Init_Ctrl[14].bit[5] = 5;
915 state->Init_Ctrl[14].val[5] = 0;
916 state->Init_Ctrl[14].addr[6] = 13;
917 state->Init_Ctrl[14].bit[6] = 6;
918 state->Init_Ctrl[14].val[6] = 0;
919 state->Init_Ctrl[14].addr[7] = 13;
920 state->Init_Ctrl[14].bit[7] = 7;
921 state->Init_Ctrl[14].val[7] = 0;
922 state->Init_Ctrl[14].addr[8] = 12;
923 state->Init_Ctrl[14].bit[8] = 0;
924 state->Init_Ctrl[14].val[8] = 0;
925 state->Init_Ctrl[14].addr[9] = 12;
926 state->Init_Ctrl[14].bit[9] = 1;
927 state->Init_Ctrl[14].val[9] = 0;
928 state->Init_Ctrl[14].addr[10] = 12;
929 state->Init_Ctrl[14].bit[10] = 2;
930 state->Init_Ctrl[14].val[10] = 0;
931 state->Init_Ctrl[14].addr[11] = 12;
932 state->Init_Ctrl[14].bit[11] = 3;
933 state->Init_Ctrl[14].val[11] = 0;
934 state->Init_Ctrl[14].addr[12] = 12;
935 state->Init_Ctrl[14].bit[12] = 4;
936 state->Init_Ctrl[14].val[12] = 0;
937 state->Init_Ctrl[14].addr[13] = 12;
938 state->Init_Ctrl[14].bit[13] = 5;
939 state->Init_Ctrl[14].val[13] = 1;
940 state->Init_Ctrl[14].addr[14] = 12;
941 state->Init_Ctrl[14].bit[14] = 6;
942 state->Init_Ctrl[14].val[14] = 1;
943 state->Init_Ctrl[14].addr[15] = 12;
944 state->Init_Ctrl[14].bit[15] = 7;
945 state->Init_Ctrl[14].val[15] = 0;
946
947 state->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ;
948 state->Init_Ctrl[15].size = 3 ;
949 state->Init_Ctrl[15].addr[0] = 147;
950 state->Init_Ctrl[15].bit[0] = 2;
951 state->Init_Ctrl[15].val[0] = 0;
952 state->Init_Ctrl[15].addr[1] = 147;
953 state->Init_Ctrl[15].bit[1] = 3;
954 state->Init_Ctrl[15].val[1] = 1;
955 state->Init_Ctrl[15].addr[2] = 147;
956 state->Init_Ctrl[15].bit[2] = 4;
957 state->Init_Ctrl[15].val[2] = 1;
958
959 state->Init_Ctrl[16].Ctrl_Num = I_DRIVER ;
960 state->Init_Ctrl[16].size = 2 ;
961 state->Init_Ctrl[16].addr[0] = 147;
962 state->Init_Ctrl[16].bit[0] = 0;
963 state->Init_Ctrl[16].val[0] = 0;
964 state->Init_Ctrl[16].addr[1] = 147;
965 state->Init_Ctrl[16].bit[1] = 1;
966 state->Init_Ctrl[16].val[1] = 1;
967
968 state->Init_Ctrl[17].Ctrl_Num = EN_AAF ;
969 state->Init_Ctrl[17].size = 1 ;
970 state->Init_Ctrl[17].addr[0] = 147;
971 state->Init_Ctrl[17].bit[0] = 7;
972 state->Init_Ctrl[17].val[0] = 0;
973
974 state->Init_Ctrl[18].Ctrl_Num = EN_3P ;
975 state->Init_Ctrl[18].size = 1 ;
976 state->Init_Ctrl[18].addr[0] = 147;
977 state->Init_Ctrl[18].bit[0] = 6;
978 state->Init_Ctrl[18].val[0] = 0;
979
980 state->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ;
981 state->Init_Ctrl[19].size = 1 ;
982 state->Init_Ctrl[19].addr[0] = 156;
983 state->Init_Ctrl[19].bit[0] = 0;
984 state->Init_Ctrl[19].val[0] = 0;
985
986 state->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ;
987 state->Init_Ctrl[20].size = 1 ;
988 state->Init_Ctrl[20].addr[0] = 147;
989 state->Init_Ctrl[20].bit[0] = 5;
990 state->Init_Ctrl[20].val[0] = 0;
991
992 state->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ;
993 state->Init_Ctrl[21].size = 1 ;
994 state->Init_Ctrl[21].addr[0] = 137;
995 state->Init_Ctrl[21].bit[0] = 4;
996 state->Init_Ctrl[21].val[0] = 0;
997
998 state->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ;
999 state->Init_Ctrl[22].size = 1 ;
1000 state->Init_Ctrl[22].addr[0] = 137;
1001 state->Init_Ctrl[22].bit[0] = 7;
1002 state->Init_Ctrl[22].val[0] = 0;
1003
1004 state->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ;
1005 state->Init_Ctrl[23].size = 1 ;
1006 state->Init_Ctrl[23].addr[0] = 91;
1007 state->Init_Ctrl[23].bit[0] = 5;
1008 state->Init_Ctrl[23].val[0] = 1;
1009
1010 state->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ;
1011 state->Init_Ctrl[24].size = 1 ;
1012 state->Init_Ctrl[24].addr[0] = 43;
1013 state->Init_Ctrl[24].bit[0] = 0;
1014 state->Init_Ctrl[24].val[0] = 1;
1015
1016 state->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ;
1017 state->Init_Ctrl[25].size = 2 ;
1018 state->Init_Ctrl[25].addr[0] = 22;
1019 state->Init_Ctrl[25].bit[0] = 0;
1020 state->Init_Ctrl[25].val[0] = 1;
1021 state->Init_Ctrl[25].addr[1] = 22;
1022 state->Init_Ctrl[25].bit[1] = 1;
1023 state->Init_Ctrl[25].val[1] = 1;
1024
1025 state->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ;
1026 state->Init_Ctrl[26].size = 1 ;
1027 state->Init_Ctrl[26].addr[0] = 134;
1028 state->Init_Ctrl[26].bit[0] = 2;
1029 state->Init_Ctrl[26].val[0] = 0;
1030
1031 state->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ;
1032 state->Init_Ctrl[27].size = 1 ;
1033 state->Init_Ctrl[27].addr[0] = 137;
1034 state->Init_Ctrl[27].bit[0] = 3;
1035 state->Init_Ctrl[27].val[0] = 0;
1036
1037 state->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ;
1038 state->Init_Ctrl[28].size = 1 ;
1039 state->Init_Ctrl[28].addr[0] = 77;
1040 state->Init_Ctrl[28].bit[0] = 7;
1041 state->Init_Ctrl[28].val[0] = 0;
1042
1043 state->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ;
1044 state->Init_Ctrl[29].size = 1 ;
1045 state->Init_Ctrl[29].addr[0] = 166;
1046 state->Init_Ctrl[29].bit[0] = 7;
1047 state->Init_Ctrl[29].val[0] = 1;
1048
1049 state->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ;
1050 state->Init_Ctrl[30].size = 3 ;
1051 state->Init_Ctrl[30].addr[0] = 166;
1052 state->Init_Ctrl[30].bit[0] = 0;
1053 state->Init_Ctrl[30].val[0] = 0;
1054 state->Init_Ctrl[30].addr[1] = 166;
1055 state->Init_Ctrl[30].bit[1] = 1;
1056 state->Init_Ctrl[30].val[1] = 1;
1057 state->Init_Ctrl[30].addr[2] = 166;
1058 state->Init_Ctrl[30].bit[2] = 2;
1059 state->Init_Ctrl[30].val[2] = 1;
1060
1061 state->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ;
1062 state->Init_Ctrl[31].size = 3 ;
1063 state->Init_Ctrl[31].addr[0] = 166;
1064 state->Init_Ctrl[31].bit[0] = 3;
1065 state->Init_Ctrl[31].val[0] = 1;
1066 state->Init_Ctrl[31].addr[1] = 166;
1067 state->Init_Ctrl[31].bit[1] = 4;
1068 state->Init_Ctrl[31].val[1] = 0;
1069 state->Init_Ctrl[31].addr[2] = 166;
1070 state->Init_Ctrl[31].bit[2] = 5;
1071 state->Init_Ctrl[31].val[2] = 1;
1072
1073 state->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ;
1074 state->Init_Ctrl[32].size = 3 ;
1075 state->Init_Ctrl[32].addr[0] = 167;
1076 state->Init_Ctrl[32].bit[0] = 0;
1077 state->Init_Ctrl[32].val[0] = 1;
1078 state->Init_Ctrl[32].addr[1] = 167;
1079 state->Init_Ctrl[32].bit[1] = 1;
1080 state->Init_Ctrl[32].val[1] = 1;
1081 state->Init_Ctrl[32].addr[2] = 167;
1082 state->Init_Ctrl[32].bit[2] = 2;
1083 state->Init_Ctrl[32].val[2] = 0;
1084
1085 state->Init_Ctrl[33].Ctrl_Num = RFA_FLR ;
1086 state->Init_Ctrl[33].size = 4 ;
1087 state->Init_Ctrl[33].addr[0] = 168;
1088 state->Init_Ctrl[33].bit[0] = 0;
1089 state->Init_Ctrl[33].val[0] = 0;
1090 state->Init_Ctrl[33].addr[1] = 168;
1091 state->Init_Ctrl[33].bit[1] = 1;
1092 state->Init_Ctrl[33].val[1] = 1;
1093 state->Init_Ctrl[33].addr[2] = 168;
1094 state->Init_Ctrl[33].bit[2] = 2;
1095 state->Init_Ctrl[33].val[2] = 0;
1096 state->Init_Ctrl[33].addr[3] = 168;
1097 state->Init_Ctrl[33].bit[3] = 3;
1098 state->Init_Ctrl[33].val[3] = 0;
1099
1100 state->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ;
1101 state->Init_Ctrl[34].size = 4 ;
1102 state->Init_Ctrl[34].addr[0] = 168;
1103 state->Init_Ctrl[34].bit[0] = 4;
1104 state->Init_Ctrl[34].val[0] = 1;
1105 state->Init_Ctrl[34].addr[1] = 168;
1106 state->Init_Ctrl[34].bit[1] = 5;
1107 state->Init_Ctrl[34].val[1] = 1;
1108 state->Init_Ctrl[34].addr[2] = 168;
1109 state->Init_Ctrl[34].bit[2] = 6;
1110 state->Init_Ctrl[34].val[2] = 1;
1111 state->Init_Ctrl[34].addr[3] = 168;
1112 state->Init_Ctrl[34].bit[3] = 7;
1113 state->Init_Ctrl[34].val[3] = 1;
1114
1115 state->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ;
1116 state->Init_Ctrl[35].size = 1 ;
1117 state->Init_Ctrl[35].addr[0] = 135;
1118 state->Init_Ctrl[35].bit[0] = 0;
1119 state->Init_Ctrl[35].val[0] = 0;
1120
1121 state->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ;
1122 state->Init_Ctrl[36].size = 1 ;
1123 state->Init_Ctrl[36].addr[0] = 56;
1124 state->Init_Ctrl[36].bit[0] = 3;
1125 state->Init_Ctrl[36].val[0] = 0;
1126
1127 state->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ;
1128 state->Init_Ctrl[37].size = 7 ;
1129 state->Init_Ctrl[37].addr[0] = 59;
1130 state->Init_Ctrl[37].bit[0] = 1;
1131 state->Init_Ctrl[37].val[0] = 0;
1132 state->Init_Ctrl[37].addr[1] = 59;
1133 state->Init_Ctrl[37].bit[1] = 2;
1134 state->Init_Ctrl[37].val[1] = 0;
1135 state->Init_Ctrl[37].addr[2] = 59;
1136 state->Init_Ctrl[37].bit[2] = 3;
1137 state->Init_Ctrl[37].val[2] = 0;
1138 state->Init_Ctrl[37].addr[3] = 59;
1139 state->Init_Ctrl[37].bit[3] = 4;
1140 state->Init_Ctrl[37].val[3] = 0;
1141 state->Init_Ctrl[37].addr[4] = 59;
1142 state->Init_Ctrl[37].bit[4] = 5;
1143 state->Init_Ctrl[37].val[4] = 0;
1144 state->Init_Ctrl[37].addr[5] = 59;
1145 state->Init_Ctrl[37].bit[5] = 6;
1146 state->Init_Ctrl[37].val[5] = 0;
1147 state->Init_Ctrl[37].addr[6] = 59;
1148 state->Init_Ctrl[37].bit[6] = 7;
1149 state->Init_Ctrl[37].val[6] = 0;
1150
1151 state->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ;
1152 state->Init_Ctrl[38].size = 6 ;
1153 state->Init_Ctrl[38].addr[0] = 32;
1154 state->Init_Ctrl[38].bit[0] = 2;
1155 state->Init_Ctrl[38].val[0] = 0;
1156 state->Init_Ctrl[38].addr[1] = 32;
1157 state->Init_Ctrl[38].bit[1] = 3;
1158 state->Init_Ctrl[38].val[1] = 0;
1159 state->Init_Ctrl[38].addr[2] = 32;
1160 state->Init_Ctrl[38].bit[2] = 4;
1161 state->Init_Ctrl[38].val[2] = 0;
1162 state->Init_Ctrl[38].addr[3] = 32;
1163 state->Init_Ctrl[38].bit[3] = 5;
1164 state->Init_Ctrl[38].val[3] = 0;
1165 state->Init_Ctrl[38].addr[4] = 32;
1166 state->Init_Ctrl[38].bit[4] = 6;
1167 state->Init_Ctrl[38].val[4] = 1;
1168 state->Init_Ctrl[38].addr[5] = 32;
1169 state->Init_Ctrl[38].bit[5] = 7;
1170 state->Init_Ctrl[38].val[5] = 0;
1171
1172 state->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ;
1173 state->Init_Ctrl[39].size = 1 ;
1174 state->Init_Ctrl[39].addr[0] = 25;
1175 state->Init_Ctrl[39].bit[0] = 3;
1176 state->Init_Ctrl[39].val[0] = 1;
1177
1178
1179 state->CH_Ctrl_Num = CHCTRL_NUM ;
1180
1181 state->CH_Ctrl[0].Ctrl_Num = DN_POLY ;
1182 state->CH_Ctrl[0].size = 2 ;
1183 state->CH_Ctrl[0].addr[0] = 68;
1184 state->CH_Ctrl[0].bit[0] = 6;
1185 state->CH_Ctrl[0].val[0] = 1;
1186 state->CH_Ctrl[0].addr[1] = 68;
1187 state->CH_Ctrl[0].bit[1] = 7;
1188 state->CH_Ctrl[0].val[1] = 1;
1189
1190 state->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ;
1191 state->CH_Ctrl[1].size = 2 ;
1192 state->CH_Ctrl[1].addr[0] = 70;
1193 state->CH_Ctrl[1].bit[0] = 6;
1194 state->CH_Ctrl[1].val[0] = 1;
1195 state->CH_Ctrl[1].addr[1] = 70;
1196 state->CH_Ctrl[1].bit[1] = 7;
1197 state->CH_Ctrl[1].val[1] = 0;
1198
1199 state->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ;
1200 state->CH_Ctrl[2].size = 9 ;
1201 state->CH_Ctrl[2].addr[0] = 69;
1202 state->CH_Ctrl[2].bit[0] = 5;
1203 state->CH_Ctrl[2].val[0] = 0;
1204 state->CH_Ctrl[2].addr[1] = 69;
1205 state->CH_Ctrl[2].bit[1] = 6;
1206 state->CH_Ctrl[2].val[1] = 0;
1207 state->CH_Ctrl[2].addr[2] = 69;
1208 state->CH_Ctrl[2].bit[2] = 7;
1209 state->CH_Ctrl[2].val[2] = 0;
1210 state->CH_Ctrl[2].addr[3] = 68;
1211 state->CH_Ctrl[2].bit[3] = 0;
1212 state->CH_Ctrl[2].val[3] = 0;
1213 state->CH_Ctrl[2].addr[4] = 68;
1214 state->CH_Ctrl[2].bit[4] = 1;
1215 state->CH_Ctrl[2].val[4] = 0;
1216 state->CH_Ctrl[2].addr[5] = 68;
1217 state->CH_Ctrl[2].bit[5] = 2;
1218 state->CH_Ctrl[2].val[5] = 0;
1219 state->CH_Ctrl[2].addr[6] = 68;
1220 state->CH_Ctrl[2].bit[6] = 3;
1221 state->CH_Ctrl[2].val[6] = 0;
1222 state->CH_Ctrl[2].addr[7] = 68;
1223 state->CH_Ctrl[2].bit[7] = 4;
1224 state->CH_Ctrl[2].val[7] = 0;
1225 state->CH_Ctrl[2].addr[8] = 68;
1226 state->CH_Ctrl[2].bit[8] = 5;
1227 state->CH_Ctrl[2].val[8] = 0;
1228
1229 state->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ;
1230 state->CH_Ctrl[3].size = 1 ;
1231 state->CH_Ctrl[3].addr[0] = 70;
1232 state->CH_Ctrl[3].bit[0] = 5;
1233 state->CH_Ctrl[3].val[0] = 0;
1234
1235 state->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ;
1236 state->CH_Ctrl[4].size = 3 ;
1237 state->CH_Ctrl[4].addr[0] = 73;
1238 state->CH_Ctrl[4].bit[0] = 4;
1239 state->CH_Ctrl[4].val[0] = 0;
1240 state->CH_Ctrl[4].addr[1] = 73;
1241 state->CH_Ctrl[4].bit[1] = 5;
1242 state->CH_Ctrl[4].val[1] = 1;
1243 state->CH_Ctrl[4].addr[2] = 73;
1244 state->CH_Ctrl[4].bit[2] = 6;
1245 state->CH_Ctrl[4].val[2] = 0;
1246
1247 state->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ;
1248 state->CH_Ctrl[5].size = 4 ;
1249 state->CH_Ctrl[5].addr[0] = 70;
1250 state->CH_Ctrl[5].bit[0] = 0;
1251 state->CH_Ctrl[5].val[0] = 0;
1252 state->CH_Ctrl[5].addr[1] = 70;
1253 state->CH_Ctrl[5].bit[1] = 1;
1254 state->CH_Ctrl[5].val[1] = 0;
1255 state->CH_Ctrl[5].addr[2] = 70;
1256 state->CH_Ctrl[5].bit[2] = 2;
1257 state->CH_Ctrl[5].val[2] = 0;
1258 state->CH_Ctrl[5].addr[3] = 70;
1259 state->CH_Ctrl[5].bit[3] = 3;
1260 state->CH_Ctrl[5].val[3] = 0;
1261
1262 state->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ;
1263 state->CH_Ctrl[6].size = 1 ;
1264 state->CH_Ctrl[6].addr[0] = 70;
1265 state->CH_Ctrl[6].bit[0] = 4;
1266 state->CH_Ctrl[6].val[0] = 1;
1267
1268 state->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ;
1269 state->CH_Ctrl[7].size = 1 ;
1270 state->CH_Ctrl[7].addr[0] = 111;
1271 state->CH_Ctrl[7].bit[0] = 4;
1272 state->CH_Ctrl[7].val[0] = 0;
1273
1274 state->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ;
1275 state->CH_Ctrl[8].size = 1 ;
1276 state->CH_Ctrl[8].addr[0] = 111;
1277 state->CH_Ctrl[8].bit[0] = 7;
1278 state->CH_Ctrl[8].val[0] = 1;
1279
1280 state->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ;
1281 state->CH_Ctrl[9].size = 1 ;
1282 state->CH_Ctrl[9].addr[0] = 111;
1283 state->CH_Ctrl[9].bit[0] = 6;
1284 state->CH_Ctrl[9].val[0] = 1;
1285
1286 state->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ;
1287 state->CH_Ctrl[10].size = 1 ;
1288 state->CH_Ctrl[10].addr[0] = 111;
1289 state->CH_Ctrl[10].bit[0] = 5;
1290 state->CH_Ctrl[10].val[0] = 0;
1291
1292 state->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ;
1293 state->CH_Ctrl[11].size = 2 ;
1294 state->CH_Ctrl[11].addr[0] = 110;
1295 state->CH_Ctrl[11].bit[0] = 0;
1296 state->CH_Ctrl[11].val[0] = 1;
1297 state->CH_Ctrl[11].addr[1] = 110;
1298 state->CH_Ctrl[11].bit[1] = 1;
1299 state->CH_Ctrl[11].val[1] = 0;
1300
1301 state->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ;
1302 state->CH_Ctrl[12].size = 3 ;
1303 state->CH_Ctrl[12].addr[0] = 69;
1304 state->CH_Ctrl[12].bit[0] = 2;
1305 state->CH_Ctrl[12].val[0] = 0;
1306 state->CH_Ctrl[12].addr[1] = 69;
1307 state->CH_Ctrl[12].bit[1] = 3;
1308 state->CH_Ctrl[12].val[1] = 0;
1309 state->CH_Ctrl[12].addr[2] = 69;
1310 state->CH_Ctrl[12].bit[2] = 4;
1311 state->CH_Ctrl[12].val[2] = 0;
1312
1313 state->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ;
1314 state->CH_Ctrl[13].size = 6 ;
1315 state->CH_Ctrl[13].addr[0] = 110;
1316 state->CH_Ctrl[13].bit[0] = 2;
1317 state->CH_Ctrl[13].val[0] = 0;
1318 state->CH_Ctrl[13].addr[1] = 110;
1319 state->CH_Ctrl[13].bit[1] = 3;
1320 state->CH_Ctrl[13].val[1] = 0;
1321 state->CH_Ctrl[13].addr[2] = 110;
1322 state->CH_Ctrl[13].bit[2] = 4;
1323 state->CH_Ctrl[13].val[2] = 0;
1324 state->CH_Ctrl[13].addr[3] = 110;
1325 state->CH_Ctrl[13].bit[3] = 5;
1326 state->CH_Ctrl[13].val[3] = 0;
1327 state->CH_Ctrl[13].addr[4] = 110;
1328 state->CH_Ctrl[13].bit[4] = 6;
1329 state->CH_Ctrl[13].val[4] = 0;
1330 state->CH_Ctrl[13].addr[5] = 110;
1331 state->CH_Ctrl[13].bit[5] = 7;
1332 state->CH_Ctrl[13].val[5] = 1;
1333
1334 state->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ;
1335 state->CH_Ctrl[14].size = 7 ;
1336 state->CH_Ctrl[14].addr[0] = 14;
1337 state->CH_Ctrl[14].bit[0] = 0;
1338 state->CH_Ctrl[14].val[0] = 0;
1339 state->CH_Ctrl[14].addr[1] = 14;
1340 state->CH_Ctrl[14].bit[1] = 1;
1341 state->CH_Ctrl[14].val[1] = 0;
1342 state->CH_Ctrl[14].addr[2] = 14;
1343 state->CH_Ctrl[14].bit[2] = 2;
1344 state->CH_Ctrl[14].val[2] = 0;
1345 state->CH_Ctrl[14].addr[3] = 14;
1346 state->CH_Ctrl[14].bit[3] = 3;
1347 state->CH_Ctrl[14].val[3] = 0;
1348 state->CH_Ctrl[14].addr[4] = 14;
1349 state->CH_Ctrl[14].bit[4] = 4;
1350 state->CH_Ctrl[14].val[4] = 0;
1351 state->CH_Ctrl[14].addr[5] = 14;
1352 state->CH_Ctrl[14].bit[5] = 5;
1353 state->CH_Ctrl[14].val[5] = 0;
1354 state->CH_Ctrl[14].addr[6] = 14;
1355 state->CH_Ctrl[14].bit[6] = 6;
1356 state->CH_Ctrl[14].val[6] = 0;
1357
1358 state->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ;
1359 state->CH_Ctrl[15].size = 18 ;
1360 state->CH_Ctrl[15].addr[0] = 17;
1361 state->CH_Ctrl[15].bit[0] = 6;
1362 state->CH_Ctrl[15].val[0] = 0;
1363 state->CH_Ctrl[15].addr[1] = 17;
1364 state->CH_Ctrl[15].bit[1] = 7;
1365 state->CH_Ctrl[15].val[1] = 0;
1366 state->CH_Ctrl[15].addr[2] = 16;
1367 state->CH_Ctrl[15].bit[2] = 0;
1368 state->CH_Ctrl[15].val[2] = 0;
1369 state->CH_Ctrl[15].addr[3] = 16;
1370 state->CH_Ctrl[15].bit[3] = 1;
1371 state->CH_Ctrl[15].val[3] = 0;
1372 state->CH_Ctrl[15].addr[4] = 16;
1373 state->CH_Ctrl[15].bit[4] = 2;
1374 state->CH_Ctrl[15].val[4] = 0;
1375 state->CH_Ctrl[15].addr[5] = 16;
1376 state->CH_Ctrl[15].bit[5] = 3;
1377 state->CH_Ctrl[15].val[5] = 0;
1378 state->CH_Ctrl[15].addr[6] = 16;
1379 state->CH_Ctrl[15].bit[6] = 4;
1380 state->CH_Ctrl[15].val[6] = 0;
1381 state->CH_Ctrl[15].addr[7] = 16;
1382 state->CH_Ctrl[15].bit[7] = 5;
1383 state->CH_Ctrl[15].val[7] = 0;
1384 state->CH_Ctrl[15].addr[8] = 16;
1385 state->CH_Ctrl[15].bit[8] = 6;
1386 state->CH_Ctrl[15].val[8] = 0;
1387 state->CH_Ctrl[15].addr[9] = 16;
1388 state->CH_Ctrl[15].bit[9] = 7;
1389 state->CH_Ctrl[15].val[9] = 0;
1390 state->CH_Ctrl[15].addr[10] = 15;
1391 state->CH_Ctrl[15].bit[10] = 0;
1392 state->CH_Ctrl[15].val[10] = 0;
1393 state->CH_Ctrl[15].addr[11] = 15;
1394 state->CH_Ctrl[15].bit[11] = 1;
1395 state->CH_Ctrl[15].val[11] = 0;
1396 state->CH_Ctrl[15].addr[12] = 15;
1397 state->CH_Ctrl[15].bit[12] = 2;
1398 state->CH_Ctrl[15].val[12] = 0;
1399 state->CH_Ctrl[15].addr[13] = 15;
1400 state->CH_Ctrl[15].bit[13] = 3;
1401 state->CH_Ctrl[15].val[13] = 0;
1402 state->CH_Ctrl[15].addr[14] = 15;
1403 state->CH_Ctrl[15].bit[14] = 4;
1404 state->CH_Ctrl[15].val[14] = 0;
1405 state->CH_Ctrl[15].addr[15] = 15;
1406 state->CH_Ctrl[15].bit[15] = 5;
1407 state->CH_Ctrl[15].val[15] = 0;
1408 state->CH_Ctrl[15].addr[16] = 15;
1409 state->CH_Ctrl[15].bit[16] = 6;
1410 state->CH_Ctrl[15].val[16] = 1;
1411 state->CH_Ctrl[15].addr[17] = 15;
1412 state->CH_Ctrl[15].bit[17] = 7;
1413 state->CH_Ctrl[15].val[17] = 1;
1414
1415 state->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ;
1416 state->CH_Ctrl[16].size = 5 ;
1417 state->CH_Ctrl[16].addr[0] = 112;
1418 state->CH_Ctrl[16].bit[0] = 0;
1419 state->CH_Ctrl[16].val[0] = 0;
1420 state->CH_Ctrl[16].addr[1] = 112;
1421 state->CH_Ctrl[16].bit[1] = 1;
1422 state->CH_Ctrl[16].val[1] = 0;
1423 state->CH_Ctrl[16].addr[2] = 112;
1424 state->CH_Ctrl[16].bit[2] = 2;
1425 state->CH_Ctrl[16].val[2] = 0;
1426 state->CH_Ctrl[16].addr[3] = 112;
1427 state->CH_Ctrl[16].bit[3] = 3;
1428 state->CH_Ctrl[16].val[3] = 0;
1429 state->CH_Ctrl[16].addr[4] = 112;
1430 state->CH_Ctrl[16].bit[4] = 4;
1431 state->CH_Ctrl[16].val[4] = 1;
1432
1433 state->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ;
1434 state->CH_Ctrl[17].size = 1 ;
1435 state->CH_Ctrl[17].addr[0] = 14;
1436 state->CH_Ctrl[17].bit[0] = 7;
1437 state->CH_Ctrl[17].val[0] = 0;
1438
1439 state->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ;
1440 state->CH_Ctrl[18].size = 4 ;
1441 state->CH_Ctrl[18].addr[0] = 107;
1442 state->CH_Ctrl[18].bit[0] = 3;
1443 state->CH_Ctrl[18].val[0] = 0;
1444 state->CH_Ctrl[18].addr[1] = 107;
1445 state->CH_Ctrl[18].bit[1] = 4;
1446 state->CH_Ctrl[18].val[1] = 0;
1447 state->CH_Ctrl[18].addr[2] = 107;
1448 state->CH_Ctrl[18].bit[2] = 5;
1449 state->CH_Ctrl[18].val[2] = 0;
1450 state->CH_Ctrl[18].addr[3] = 107;
1451 state->CH_Ctrl[18].bit[3] = 6;
1452 state->CH_Ctrl[18].val[3] = 0;
1453
1454 state->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ;
1455 state->CH_Ctrl[19].size = 3 ;
1456 state->CH_Ctrl[19].addr[0] = 107;
1457 state->CH_Ctrl[19].bit[0] = 7;
1458 state->CH_Ctrl[19].val[0] = 1;
1459 state->CH_Ctrl[19].addr[1] = 106;
1460 state->CH_Ctrl[19].bit[1] = 0;
1461 state->CH_Ctrl[19].val[1] = 1;
1462 state->CH_Ctrl[19].addr[2] = 106;
1463 state->CH_Ctrl[19].bit[2] = 1;
1464 state->CH_Ctrl[19].val[2] = 1;
1465
1466 state->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ;
1467 state->CH_Ctrl[20].size = 11 ;
1468 state->CH_Ctrl[20].addr[0] = 109;
1469 state->CH_Ctrl[20].bit[0] = 2;
1470 state->CH_Ctrl[20].val[0] = 0;
1471 state->CH_Ctrl[20].addr[1] = 109;
1472 state->CH_Ctrl[20].bit[1] = 3;
1473 state->CH_Ctrl[20].val[1] = 0;
1474 state->CH_Ctrl[20].addr[2] = 109;
1475 state->CH_Ctrl[20].bit[2] = 4;
1476 state->CH_Ctrl[20].val[2] = 0;
1477 state->CH_Ctrl[20].addr[3] = 109;
1478 state->CH_Ctrl[20].bit[3] = 5;
1479 state->CH_Ctrl[20].val[3] = 0;
1480 state->CH_Ctrl[20].addr[4] = 109;
1481 state->CH_Ctrl[20].bit[4] = 6;
1482 state->CH_Ctrl[20].val[4] = 0;
1483 state->CH_Ctrl[20].addr[5] = 109;
1484 state->CH_Ctrl[20].bit[5] = 7;
1485 state->CH_Ctrl[20].val[5] = 0;
1486 state->CH_Ctrl[20].addr[6] = 108;
1487 state->CH_Ctrl[20].bit[6] = 0;
1488 state->CH_Ctrl[20].val[6] = 0;
1489 state->CH_Ctrl[20].addr[7] = 108;
1490 state->CH_Ctrl[20].bit[7] = 1;
1491 state->CH_Ctrl[20].val[7] = 0;
1492 state->CH_Ctrl[20].addr[8] = 108;
1493 state->CH_Ctrl[20].bit[8] = 2;
1494 state->CH_Ctrl[20].val[8] = 1;
1495 state->CH_Ctrl[20].addr[9] = 108;
1496 state->CH_Ctrl[20].bit[9] = 3;
1497 state->CH_Ctrl[20].val[9] = 1;
1498 state->CH_Ctrl[20].addr[10] = 108;
1499 state->CH_Ctrl[20].bit[10] = 4;
1500 state->CH_Ctrl[20].val[10] = 1;
1501
1502 state->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ;
1503 state->CH_Ctrl[21].size = 6 ;
1504 state->CH_Ctrl[21].addr[0] = 106;
1505 state->CH_Ctrl[21].bit[0] = 2;
1506 state->CH_Ctrl[21].val[0] = 0;
1507 state->CH_Ctrl[21].addr[1] = 106;
1508 state->CH_Ctrl[21].bit[1] = 3;
1509 state->CH_Ctrl[21].val[1] = 0;
1510 state->CH_Ctrl[21].addr[2] = 106;
1511 state->CH_Ctrl[21].bit[2] = 4;
1512 state->CH_Ctrl[21].val[2] = 0;
1513 state->CH_Ctrl[21].addr[3] = 106;
1514 state->CH_Ctrl[21].bit[3] = 5;
1515 state->CH_Ctrl[21].val[3] = 0;
1516 state->CH_Ctrl[21].addr[4] = 106;
1517 state->CH_Ctrl[21].bit[4] = 6;
1518 state->CH_Ctrl[21].val[4] = 0;
1519 state->CH_Ctrl[21].addr[5] = 106;
1520 state->CH_Ctrl[21].bit[5] = 7;
1521 state->CH_Ctrl[21].val[5] = 1;
1522
1523 state->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ;
1524 state->CH_Ctrl[22].size = 1 ;
1525 state->CH_Ctrl[22].addr[0] = 138;
1526 state->CH_Ctrl[22].bit[0] = 4;
1527 state->CH_Ctrl[22].val[0] = 1;
1528
1529 state->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ;
1530 state->CH_Ctrl[23].size = 1 ;
1531 state->CH_Ctrl[23].addr[0] = 17;
1532 state->CH_Ctrl[23].bit[0] = 5;
1533 state->CH_Ctrl[23].val[0] = 0;
1534
1535 state->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ;
1536 state->CH_Ctrl[24].size = 1 ;
1537 state->CH_Ctrl[24].addr[0] = 111;
1538 state->CH_Ctrl[24].bit[0] = 3;
1539 state->CH_Ctrl[24].val[0] = 0;
1540
1541 state->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ;
1542 state->CH_Ctrl[25].size = 1 ;
1543 state->CH_Ctrl[25].addr[0] = 112;
1544 state->CH_Ctrl[25].bit[0] = 7;
1545 state->CH_Ctrl[25].val[0] = 0;
1546
1547 state->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ;
1548 state->CH_Ctrl[26].size = 1 ;
1549 state->CH_Ctrl[26].addr[0] = 136;
1550 state->CH_Ctrl[26].bit[0] = 7;
1551 state->CH_Ctrl[26].val[0] = 0;
1552
1553 state->CH_Ctrl[27].Ctrl_Num = GPIO_4B ;
1554 state->CH_Ctrl[27].size = 1 ;
1555 state->CH_Ctrl[27].addr[0] = 149;
1556 state->CH_Ctrl[27].bit[0] = 7;
1557 state->CH_Ctrl[27].val[0] = 0;
1558
1559 state->CH_Ctrl[28].Ctrl_Num = GPIO_3B ;
1560 state->CH_Ctrl[28].size = 1 ;
1561 state->CH_Ctrl[28].addr[0] = 149;
1562 state->CH_Ctrl[28].bit[0] = 6;
1563 state->CH_Ctrl[28].val[0] = 0;
1564
1565 state->CH_Ctrl[29].Ctrl_Num = GPIO_4 ;
1566 state->CH_Ctrl[29].size = 1 ;
1567 state->CH_Ctrl[29].addr[0] = 149;
1568 state->CH_Ctrl[29].bit[0] = 5;
1569 state->CH_Ctrl[29].val[0] = 1;
1570
1571 state->CH_Ctrl[30].Ctrl_Num = GPIO_3 ;
1572 state->CH_Ctrl[30].size = 1 ;
1573 state->CH_Ctrl[30].addr[0] = 149;
1574 state->CH_Ctrl[30].bit[0] = 4;
1575 state->CH_Ctrl[30].val[0] = 1;
1576
1577 state->CH_Ctrl[31].Ctrl_Num = GPIO_1B ;
1578 state->CH_Ctrl[31].size = 1 ;
1579 state->CH_Ctrl[31].addr[0] = 149;
1580 state->CH_Ctrl[31].bit[0] = 3;
1581 state->CH_Ctrl[31].val[0] = 0;
1582
1583 state->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ;
1584 state->CH_Ctrl[32].size = 1 ;
1585 state->CH_Ctrl[32].addr[0] = 93;
1586 state->CH_Ctrl[32].bit[0] = 1;
1587 state->CH_Ctrl[32].val[0] = 0;
1588
1589 state->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ;
1590 state->CH_Ctrl[33].size = 1 ;
1591 state->CH_Ctrl[33].addr[0] = 93;
1592 state->CH_Ctrl[33].bit[0] = 0;
1593 state->CH_Ctrl[33].val[0] = 0;
1594
1595 state->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ;
1596 state->CH_Ctrl[34].size = 6 ;
1597 state->CH_Ctrl[34].addr[0] = 92;
1598 state->CH_Ctrl[34].bit[0] = 2;
1599 state->CH_Ctrl[34].val[0] = 0;
1600 state->CH_Ctrl[34].addr[1] = 92;
1601 state->CH_Ctrl[34].bit[1] = 3;
1602 state->CH_Ctrl[34].val[1] = 0;
1603 state->CH_Ctrl[34].addr[2] = 92;
1604 state->CH_Ctrl[34].bit[2] = 4;
1605 state->CH_Ctrl[34].val[2] = 0;
1606 state->CH_Ctrl[34].addr[3] = 92;
1607 state->CH_Ctrl[34].bit[3] = 5;
1608 state->CH_Ctrl[34].val[3] = 0;
1609 state->CH_Ctrl[34].addr[4] = 92;
1610 state->CH_Ctrl[34].bit[4] = 6;
1611 state->CH_Ctrl[34].val[4] = 0;
1612 state->CH_Ctrl[34].addr[5] = 92;
1613 state->CH_Ctrl[34].bit[5] = 7;
1614 state->CH_Ctrl[34].val[5] = 0;
1615
1616 state->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ;
1617 state->CH_Ctrl[35].size = 6 ;
1618 state->CH_Ctrl[35].addr[0] = 93;
1619 state->CH_Ctrl[35].bit[0] = 2;
1620 state->CH_Ctrl[35].val[0] = 0;
1621 state->CH_Ctrl[35].addr[1] = 93;
1622 state->CH_Ctrl[35].bit[1] = 3;
1623 state->CH_Ctrl[35].val[1] = 0;
1624 state->CH_Ctrl[35].addr[2] = 93;
1625 state->CH_Ctrl[35].bit[2] = 4;
1626 state->CH_Ctrl[35].val[2] = 0;
1627 state->CH_Ctrl[35].addr[3] = 93;
1628 state->CH_Ctrl[35].bit[3] = 5;
1629 state->CH_Ctrl[35].val[3] = 0;
1630 state->CH_Ctrl[35].addr[4] = 93;
1631 state->CH_Ctrl[35].bit[4] = 6;
1632 state->CH_Ctrl[35].val[4] = 0;
1633 state->CH_Ctrl[35].addr[5] = 93;
1634 state->CH_Ctrl[35].bit[5] = 7;
1635 state->CH_Ctrl[35].val[5] = 0;
1636
1637#ifdef _MXL_PRODUCTION
1638 state->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
1639 state->CH_Ctrl[36].size = 1 ;
1640 state->CH_Ctrl[36].addr[0] = 109;
1641 state->CH_Ctrl[36].bit[0] = 1;
1642 state->CH_Ctrl[36].val[0] = 1;
1643
1644 state->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
1645 state->CH_Ctrl[37].size = 2 ;
1646 state->CH_Ctrl[37].addr[0] = 112;
1647 state->CH_Ctrl[37].bit[0] = 5;
1648 state->CH_Ctrl[37].val[0] = 0;
1649 state->CH_Ctrl[37].addr[1] = 112;
1650 state->CH_Ctrl[37].bit[1] = 6;
1651 state->CH_Ctrl[37].val[1] = 0;
1652
1653 state->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
1654 state->CH_Ctrl[38].size = 1 ;
1655 state->CH_Ctrl[38].addr[0] = 65;
1656 state->CH_Ctrl[38].bit[0] = 1;
1657 state->CH_Ctrl[38].val[0] = 0;
1658#endif
1659
1660 return 0 ;
1661}
1662
1663static void InitTunerControls(struct dvb_frontend *fe)
1664{
1665 MXL5005_RegisterInit(fe);
1666 MXL5005_ControlInit(fe);
1667#ifdef _MXL_INTERNAL
1668 MXL5005_MXLControlInit(fe);
1669#endif
1670}
1671
1672static u16 MXL5005_TunerConfig(struct dvb_frontend *fe,
1673 u8 Mode, /* 0: Analog Mode ; 1: Digital Mode */
1674 u8 IF_mode, /* for Analog Mode, 0: zero IF; 1: low IF */
1675 u32 Bandwidth, /* filter channel bandwidth (6, 7, 8) */
1676 u32 IF_out, /* Desired IF Out Frequency */
1677 u32 Fxtal, /* XTAL Frequency */
1678 u8 AGC_Mode, /* AGC Mode - Dual AGC: 0, Single AGC: 1 */
1679 u16 TOP, /* 0: Dual AGC; Value: take over point */
1680 u16 IF_OUT_LOAD, /* IF Out Load Resistor (200 / 300 Ohms) */
1681 u8 CLOCK_OUT, /* 0: turn off clk out; 1: turn on clock out */
1682 u8 DIV_OUT, /* 0: Div-1; 1: Div-4 */
1683 u8 CAPSELECT, /* 0: disable On-Chip pulling cap; 1: enable */
1684 u8 EN_RSSI, /* 0: disable RSSI; 1: enable RSSI */
1685
1686 /* Modulation Type; */
1687 /* 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable */
1688 u8 Mod_Type,
1689
1690 /* Tracking Filter */
1691 /* 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H */
1692 u8 TF_Type
1693 )
1694{
1695 struct mxl5005s_state *state = fe->tuner_priv;
1696 u16 status = 0;
1697
1698 state->Mode = Mode;
1699 state->IF_Mode = IF_mode;
1700 state->Chan_Bandwidth = Bandwidth;
1701 state->IF_OUT = IF_out;
1702 state->Fxtal = Fxtal;
1703 state->AGC_Mode = AGC_Mode;
1704 state->TOP = TOP;
1705 state->IF_OUT_LOAD = IF_OUT_LOAD;
1706 state->CLOCK_OUT = CLOCK_OUT;
1707 state->DIV_OUT = DIV_OUT;
1708 state->CAPSELECT = CAPSELECT;
1709 state->EN_RSSI = EN_RSSI;
1710 state->Mod_Type = Mod_Type;
1711 state->TF_Type = TF_Type;
1712
1713 /* Initialize all the controls and registers */
1714 InitTunerControls(fe);
1715
1716 /* Synthesizer LO frequency calculation */
1717 MXL_SynthIFLO_Calc(fe);
1718
1719 return status;
1720}
1721
1722static void MXL_SynthIFLO_Calc(struct dvb_frontend *fe)
1723{
1724 struct mxl5005s_state *state = fe->tuner_priv;
1725 if (state->Mode == 1) /* Digital Mode */
1726 state->IF_LO = state->IF_OUT;
1727 else /* Analog Mode */ {
1728 if (state->IF_Mode == 0) /* Analog Zero IF mode */
1729 state->IF_LO = state->IF_OUT + 400000;
1730 else /* Analog Low IF mode */
1731 state->IF_LO = state->IF_OUT + state->Chan_Bandwidth/2;
1732 }
1733}
1734
1735static void MXL_SynthRFTGLO_Calc(struct dvb_frontend *fe)
1736{
1737 struct mxl5005s_state *state = fe->tuner_priv;
1738
1739 if (state->Mode == 1) /* Digital Mode */ {
1740 /* remove 20.48MHz setting for 2.6.10 */
1741 state->RF_LO = state->RF_IN;
1742 /* change for 2.6.6 */
1743 state->TG_LO = state->RF_IN - 750000;
1744 } else /* Analog Mode */ {
1745 if (state->IF_Mode == 0) /* Analog Zero IF mode */ {
1746 state->RF_LO = state->RF_IN - 400000;
1747 state->TG_LO = state->RF_IN - 1750000;
1748 } else /* Analog Low IF mode */ {
1749 state->RF_LO = state->RF_IN - state->Chan_Bandwidth/2;
1750 state->TG_LO = state->RF_IN -
1751 state->Chan_Bandwidth + 500000;
1752 }
1753 }
1754}
1755
1756static u16 MXL_OverwriteICDefault(struct dvb_frontend *fe)
1757{
1758 u16 status = 0;
1759
1760 status += MXL_ControlWrite(fe, OVERRIDE_1, 1);
1761 status += MXL_ControlWrite(fe, OVERRIDE_2, 1);
1762 status += MXL_ControlWrite(fe, OVERRIDE_3, 1);
1763 status += MXL_ControlWrite(fe, OVERRIDE_4, 1);
1764
1765 return status;
1766}
1767
1768static u16 MXL_BlockInit(struct dvb_frontend *fe)
1769{
1770 struct mxl5005s_state *state = fe->tuner_priv;
1771 u16 status = 0;
1772
1773 status += MXL_OverwriteICDefault(fe);
1774
1775 /* Downconverter Control Dig Ana */
1776 status += MXL_ControlWrite(fe, DN_IQTN_AMP_CUT, state->Mode ? 1 : 0);
1777
1778 /* Filter Control Dig Ana */
1779 status += MXL_ControlWrite(fe, BB_MODE, state->Mode ? 0 : 1);
1780 status += MXL_ControlWrite(fe, BB_BUF, state->Mode ? 3 : 2);
1781 status += MXL_ControlWrite(fe, BB_BUF_OA, state->Mode ? 1 : 0);
1782 status += MXL_ControlWrite(fe, BB_IQSWAP, state->Mode ? 0 : 1);
1783 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 0);
1784
1785 /* Initialize Low-Pass Filter */
1786 if (state->Mode) { /* Digital Mode */
1787 switch (state->Chan_Bandwidth) {
1788 case 8000000:
1789 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 0);
1790 break;
1791 case 7000000:
1792 status += MXL_ControlWrite(fe, BB_DLPF_BANDSEL, 2);
1793 break;
1794 case 6000000:
1795 status += MXL_ControlWrite(fe,
1796 BB_DLPF_BANDSEL, 3);
1797 break;
1798 }
1799 } else { /* Analog Mode */
1800 switch (state->Chan_Bandwidth) {
1801 case 8000000: /* Low Zero */
1802 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1803 (state->IF_Mode ? 0 : 3));
1804 break;
1805 case 7000000:
1806 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1807 (state->IF_Mode ? 1 : 4));
1808 break;
1809 case 6000000:
1810 status += MXL_ControlWrite(fe, BB_ALPF_BANDSELECT,
1811 (state->IF_Mode ? 2 : 5));
1812 break;
1813 }
1814 }
1815
1816 /* Charge Pump Control Dig Ana */
1817 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, state->Mode ? 5 : 8);
1818 status += MXL_ControlWrite(fe,
1819 RFSYN_EN_CHP_HIGAIN, state->Mode ? 1 : 1);
1820 status += MXL_ControlWrite(fe, EN_CHP_LIN_B, state->Mode ? 0 : 0);
1821
1822 /* AGC TOP Control */
1823 if (state->AGC_Mode == 0) /* Dual AGC */ {
1824 status += MXL_ControlWrite(fe, AGC_IF, 15);
1825 status += MXL_ControlWrite(fe, AGC_RF, 15);
1826 } else /* Single AGC Mode Dig Ana */
1827 status += MXL_ControlWrite(fe, AGC_RF, state->Mode ? 15 : 12);
1828
1829 if (state->TOP == 55) /* TOP == 5.5 */
1830 status += MXL_ControlWrite(fe, AGC_IF, 0x0);
1831
1832 if (state->TOP == 72) /* TOP == 7.2 */
1833 status += MXL_ControlWrite(fe, AGC_IF, 0x1);
1834
1835 if (state->TOP == 92) /* TOP == 9.2 */
1836 status += MXL_ControlWrite(fe, AGC_IF, 0x2);
1837
1838 if (state->TOP == 110) /* TOP == 11.0 */
1839 status += MXL_ControlWrite(fe, AGC_IF, 0x3);
1840
1841 if (state->TOP == 129) /* TOP == 12.9 */
1842 status += MXL_ControlWrite(fe, AGC_IF, 0x4);
1843
1844 if (state->TOP == 147) /* TOP == 14.7 */
1845 status += MXL_ControlWrite(fe, AGC_IF, 0x5);
1846
1847 if (state->TOP == 168) /* TOP == 16.8 */
1848 status += MXL_ControlWrite(fe, AGC_IF, 0x6);
1849
1850 if (state->TOP == 194) /* TOP == 19.4 */
1851 status += MXL_ControlWrite(fe, AGC_IF, 0x7);
1852
1853 if (state->TOP == 212) /* TOP == 21.2 */
1854 status += MXL_ControlWrite(fe, AGC_IF, 0x9);
1855
1856 if (state->TOP == 232) /* TOP == 23.2 */
1857 status += MXL_ControlWrite(fe, AGC_IF, 0xA);
1858
1859 if (state->TOP == 252) /* TOP == 25.2 */
1860 status += MXL_ControlWrite(fe, AGC_IF, 0xB);
1861
1862 if (state->TOP == 271) /* TOP == 27.1 */
1863 status += MXL_ControlWrite(fe, AGC_IF, 0xC);
1864
1865 if (state->TOP == 292) /* TOP == 29.2 */
1866 status += MXL_ControlWrite(fe, AGC_IF, 0xD);
1867
1868 if (state->TOP == 317) /* TOP == 31.7 */
1869 status += MXL_ControlWrite(fe, AGC_IF, 0xE);
1870
1871 if (state->TOP == 349) /* TOP == 34.9 */
1872 status += MXL_ControlWrite(fe, AGC_IF, 0xF);
1873
1874 /* IF Synthesizer Control */
1875 status += MXL_IFSynthInit(fe);
1876
1877 /* IF UpConverter Control */
1878 if (state->IF_OUT_LOAD == 200) {
1879 status += MXL_ControlWrite(fe, DRV_RES_SEL, 6);
1880 status += MXL_ControlWrite(fe, I_DRIVER, 2);
1881 }
1882 if (state->IF_OUT_LOAD == 300) {
1883 status += MXL_ControlWrite(fe, DRV_RES_SEL, 4);
1884 status += MXL_ControlWrite(fe, I_DRIVER, 1);
1885 }
1886
1887 /* Anti-Alias Filtering Control
1888 * initialise Anti-Aliasing Filter
1889 */
1890 if (state->Mode) { /* Digital Mode */
1891 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 6280000UL) {
1892 status += MXL_ControlWrite(fe, EN_AAF, 1);
1893 status += MXL_ControlWrite(fe, EN_3P, 1);
1894 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1895 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1896 }
1897 if ((state->IF_OUT == 36125000UL) ||
1898 (state->IF_OUT == 36150000UL)) {
1899 status += MXL_ControlWrite(fe, EN_AAF, 1);
1900 status += MXL_ControlWrite(fe, EN_3P, 1);
1901 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1902 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
1903 }
1904 if (state->IF_OUT > 36150000UL) {
1905 status += MXL_ControlWrite(fe, EN_AAF, 0);
1906 status += MXL_ControlWrite(fe, EN_3P, 1);
1907 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1908 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 1);
1909 }
1910 } else { /* Analog Mode */
1911 if (state->IF_OUT >= 4000000UL && state->IF_OUT <= 5000000UL) {
1912 status += MXL_ControlWrite(fe, EN_AAF, 1);
1913 status += MXL_ControlWrite(fe, EN_3P, 1);
1914 status += MXL_ControlWrite(fe, EN_AUX_3P, 1);
1915 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1916 }
1917 if (state->IF_OUT > 5000000UL) {
1918 status += MXL_ControlWrite(fe, EN_AAF, 0);
1919 status += MXL_ControlWrite(fe, EN_3P, 0);
1920 status += MXL_ControlWrite(fe, EN_AUX_3P, 0);
1921 status += MXL_ControlWrite(fe, SEL_AAF_BAND, 0);
1922 }
1923 }
1924
1925 /* Demod Clock Out */
1926 if (state->CLOCK_OUT)
1927 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 1);
1928 else
1929 status += MXL_ControlWrite(fe, SEQ_ENCLK16_CLK_OUT, 0);
1930
1931 if (state->DIV_OUT == 1)
1932 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 1);
1933 if (state->DIV_OUT == 0)
1934 status += MXL_ControlWrite(fe, SEQ_SEL4_16B, 0);
1935
1936 /* Crystal Control */
1937 if (state->CAPSELECT)
1938 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 1);
1939 else
1940 status += MXL_ControlWrite(fe, XTAL_CAPSELECT, 0);
1941
1942 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
1943 status += MXL_ControlWrite(fe, IF_SEL_DBL, 1);
1944 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
1945 status += MXL_ControlWrite(fe, IF_SEL_DBL, 0);
1946
1947 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
1948 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 3);
1949 if (state->Fxtal > 22000000UL && state->Fxtal <= 32000000UL)
1950 status += MXL_ControlWrite(fe, RFSYN_R_DIV, 0);
1951
1952 /* Misc Controls */
1953 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog LowIF mode */
1954 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 0);
1955 else
1956 status += MXL_ControlWrite(fe, SEQ_EXTIQFSMPULSE, 1);
1957
1958 /* status += MXL_ControlRead(fe, IF_DIVVAL, &IF_DIVVAL_Val); */
1959
1960 /* Set TG_R_DIV */
1961 status += MXL_ControlWrite(fe, TG_R_DIV,
1962 MXL_Ceiling(state->Fxtal, 1000000));
1963
1964 /* Apply Default value to BB_INITSTATE_DLPF_TUNE */
1965
1966 /* RSSI Control */
1967 if (state->EN_RSSI) {
1968 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
1969 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
1970 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
1971 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
1972
1973 /* RSSI reference point */
1974 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
1975 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 3);
1976 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
1977
1978 /* TOP point */
1979 status += MXL_ControlWrite(fe, RFA_FLR, 0);
1980 status += MXL_ControlWrite(fe, RFA_CEIL, 12);
1981 }
1982
1983 /* Modulation type bit settings
1984 * Override the control values preset
1985 */
1986 if (state->Mod_Type == MXL_DVBT) /* DVB-T Mode */ {
1987 state->AGC_Mode = 1; /* Single AGC Mode */
1988
1989 /* Enable RSSI */
1990 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
1991 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
1992 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
1993 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
1994
1995 /* RSSI reference point */
1996 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
1997 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
1998 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
1999
2000 /* TOP point */
2001 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2002 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2003 if (state->IF_OUT <= 6280000UL) /* Low IF */
2004 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2005 else /* High IF */
2006 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2007
2008 }
2009 if (state->Mod_Type == MXL_ATSC) /* ATSC Mode */ {
2010 state->AGC_Mode = 1; /* Single AGC Mode */
2011
2012 /* Enable RSSI */
2013 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2014 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2015 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2016 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2017
2018 /* RSSI reference point */
2019 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 2);
2020 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 4);
2021 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 1);
2022
2023 /* TOP point */
2024 status += MXL_ControlWrite(fe, RFA_FLR, 2);
2025 status += MXL_ControlWrite(fe, RFA_CEIL, 13);
2026 status += MXL_ControlWrite(fe, BB_INITSTATE_DLPF_TUNE, 1);
2027 /* Low Zero */
2028 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
2029
2030 if (state->IF_OUT <= 6280000UL) /* Low IF */
2031 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2032 else /* High IF */
2033 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2034 }
2035 if (state->Mod_Type == MXL_QAM) /* QAM Mode */ {
2036 state->Mode = MXL_DIGITAL_MODE;
2037
2038 /* state->AGC_Mode = 1; */ /* Single AGC Mode */
2039
2040 /* Disable RSSI */ /* change here for v2.6.5 */
2041 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2042 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2043 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2044 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2045
2046 /* RSSI reference point */
2047 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2048 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2049 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2050 /* change here for v2.6.5 */
2051 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2052
2053 if (state->IF_OUT <= 6280000UL) /* Low IF */
2054 status += MXL_ControlWrite(fe, BB_IQSWAP, 0);
2055 else /* High IF */
2056 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2057 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
2058
2059 }
2060 if (state->Mod_Type == MXL_ANALOG_CABLE) {
2061 /* Analog Cable Mode */
2062 /* state->Mode = MXL_DIGITAL_MODE; */
2063
2064 state->AGC_Mode = 1; /* Single AGC Mode */
2065
2066 /* Disable RSSI */
2067 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2068 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2069 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2070 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2071 /* change for 2.6.3 */
2072 status += MXL_ControlWrite(fe, AGC_IF, 1);
2073 status += MXL_ControlWrite(fe, AGC_RF, 15);
2074 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2075 }
2076
2077 if (state->Mod_Type == MXL_ANALOG_OTA) {
2078 /* Analog OTA Terrestrial mode add for 2.6.7 */
2079 /* state->Mode = MXL_ANALOG_MODE; */
2080
2081 /* Enable RSSI */
2082 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2083 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2084 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
2085 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2086
2087 /* RSSI reference point */
2088 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
2089 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
2090 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
2091 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2092 status += MXL_ControlWrite(fe, BB_IQSWAP, 1);
2093 }
2094
2095 /* RSSI disable */
2096 if (state->EN_RSSI == 0) {
2097 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
2098 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
2099 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
2100 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
2101 }
2102
2103 return status;
2104}
2105
2106static u16 MXL_IFSynthInit(struct dvb_frontend *fe)
2107{
2108 struct mxl5005s_state *state = fe->tuner_priv;
2109 u16 status = 0 ;
2110 u32 Fref = 0 ;
2111 u32 Kdbl, intModVal ;
2112 u32 fracModVal ;
2113 Kdbl = 2 ;
2114
2115 if (state->Fxtal >= 12000000UL && state->Fxtal <= 16000000UL)
2116 Kdbl = 2 ;
2117 if (state->Fxtal > 16000000UL && state->Fxtal <= 32000000UL)
2118 Kdbl = 1 ;
2119
2120 /* IF Synthesizer Control */
2121 if (state->Mode == 0 && state->IF_Mode == 1) /* Analog Low IF mode */ {
2122 if (state->IF_LO == 41000000UL) {
2123 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2124 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2125 Fref = 328000000UL ;
2126 }
2127 if (state->IF_LO == 47000000UL) {
2128 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2129 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2130 Fref = 376000000UL ;
2131 }
2132 if (state->IF_LO == 54000000UL) {
2133 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2134 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2135 Fref = 324000000UL ;
2136 }
2137 if (state->IF_LO == 60000000UL) {
2138 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2139 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2140 Fref = 360000000UL ;
2141 }
2142 if (state->IF_LO == 39250000UL) {
2143 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2144 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2145 Fref = 314000000UL ;
2146 }
2147 if (state->IF_LO == 39650000UL) {
2148 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2149 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2150 Fref = 317200000UL ;
2151 }
2152 if (state->IF_LO == 40150000UL) {
2153 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2154 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2155 Fref = 321200000UL ;
2156 }
2157 if (state->IF_LO == 40650000UL) {
2158 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2159 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2160 Fref = 325200000UL ;
2161 }
2162 }
2163
2164 if (state->Mode || (state->Mode == 0 && state->IF_Mode == 0)) {
2165 if (state->IF_LO == 57000000UL) {
2166 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2167 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2168 Fref = 342000000UL ;
2169 }
2170 if (state->IF_LO == 44000000UL) {
2171 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2172 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2173 Fref = 352000000UL ;
2174 }
2175 if (state->IF_LO == 43750000UL) {
2176 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2177 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2178 Fref = 350000000UL ;
2179 }
2180 if (state->IF_LO == 36650000UL) {
2181 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2182 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2183 Fref = 366500000UL ;
2184 }
2185 if (state->IF_LO == 36150000UL) {
2186 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2187 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2188 Fref = 361500000UL ;
2189 }
2190 if (state->IF_LO == 36000000UL) {
2191 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2192 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2193 Fref = 360000000UL ;
2194 }
2195 if (state->IF_LO == 35250000UL) {
2196 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2197 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2198 Fref = 352500000UL ;
2199 }
2200 if (state->IF_LO == 34750000UL) {
2201 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2202 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2203 Fref = 347500000UL ;
2204 }
2205 if (state->IF_LO == 6280000UL) {
2206 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2207 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2208 Fref = 376800000UL ;
2209 }
2210 if (state->IF_LO == 5000000UL) {
2211 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2212 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2213 Fref = 360000000UL ;
2214 }
2215 if (state->IF_LO == 4500000UL) {
2216 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2217 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2218 Fref = 360000000UL ;
2219 }
2220 if (state->IF_LO == 4570000UL) {
2221 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2222 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2223 Fref = 365600000UL ;
2224 }
2225 if (state->IF_LO == 4000000UL) {
2226 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05);
2227 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2228 Fref = 360000000UL ;
2229 }
2230 if (state->IF_LO == 57400000UL) {
2231 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x10);
2232 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2233 Fref = 344400000UL ;
2234 }
2235 if (state->IF_LO == 44400000UL) {
2236 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2237 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2238 Fref = 355200000UL ;
2239 }
2240 if (state->IF_LO == 44150000UL) {
2241 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x08);
2242 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2243 Fref = 353200000UL ;
2244 }
2245 if (state->IF_LO == 37050000UL) {
2246 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2247 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2248 Fref = 370500000UL ;
2249 }
2250 if (state->IF_LO == 36550000UL) {
2251 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2252 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2253 Fref = 365500000UL ;
2254 }
2255 if (state->IF_LO == 36125000UL) {
2256 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x04);
2257 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2258 Fref = 361250000UL ;
2259 }
2260 if (state->IF_LO == 6000000UL) {
2261 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2262 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2263 Fref = 360000000UL ;
2264 }
2265 if (state->IF_LO == 5400000UL) {
2266 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2267 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2268 Fref = 324000000UL ;
2269 }
2270 if (state->IF_LO == 5380000UL) {
2271 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x07);
2272 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x0C);
2273 Fref = 322800000UL ;
2274 }
2275 if (state->IF_LO == 5200000UL) {
2276 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2277 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2278 Fref = 374400000UL ;
2279 }
2280 if (state->IF_LO == 4900000UL) {
2281 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x09);
2282 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2283 Fref = 352800000UL ;
2284 }
2285 if (state->IF_LO == 4400000UL) {
2286 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x06);
2287 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2288 Fref = 352000000UL ;
2289 }
2290 if (state->IF_LO == 4063000UL) /* add for 2.6.8 */ {
2291 status += MXL_ControlWrite(fe, IF_DIVVAL, 0x05);
2292 status += MXL_ControlWrite(fe, IF_VCO_BIAS, 0x08);
2293 Fref = 365670000UL ;
2294 }
2295 }
2296 /* CHCAL_INT_MOD_IF */
2297 /* CHCAL_FRAC_MOD_IF */
2298 intModVal = Fref / (state->Fxtal * Kdbl/2);
2299 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_IF, intModVal);
2300
2301 fracModVal = (2<<15)*(Fref/1000 - (state->Fxtal/1000 * Kdbl/2) *
2302 intModVal);
2303
2304 fracModVal = fracModVal / ((state->Fxtal * Kdbl/2)/1000);
2305 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_IF, fracModVal);
2306
2307 return status ;
2308}
2309
2310static u32 MXL_GetXtalInt(u32 Xtal_Freq)
2311{
2312 if ((Xtal_Freq % 1000000) == 0)
2313 return (Xtal_Freq / 10000);
2314 else
2315 return (((Xtal_Freq / 1000000) + 1)*100);
2316}
2317
2318static u16 MXL_TuneRF(struct dvb_frontend *fe, u32 RF_Freq)
2319{
2320 struct mxl5005s_state *state = fe->tuner_priv;
2321 u16 status = 0;
2322 u32 divider_val, E3, E4, E5, E5A;
2323 u32 Fmax, Fmin, FmaxBin, FminBin;
2324 u32 Kdbl_RF = 2;
2325 u32 tg_divval;
2326 u32 tg_lo;
2327 u32 Xtal_Int;
2328
2329 u32 Fref_TG;
2330 u32 Fvco;
2331
2332 Xtal_Int = MXL_GetXtalInt(state->Fxtal);
2333
2334 state->RF_IN = RF_Freq;
2335
2336 MXL_SynthRFTGLO_Calc(fe);
2337
2338 if (state->Fxtal >= 12000000UL && state->Fxtal <= 22000000UL)
2339 Kdbl_RF = 2;
2340 if (state->Fxtal > 22000000 && state->Fxtal <= 32000000)
2341 Kdbl_RF = 1;
2342
2343 /* Downconverter Controls
2344 * Look-Up Table Implementation for:
2345 * DN_POLY
2346 * DN_RFGAIN
2347 * DN_CAP_RFLPF
2348 * DN_EN_VHFUHFBAR
2349 * DN_GAIN_ADJUST
2350 * Change the boundary reference from RF_IN to RF_LO
2351 */
2352 if (state->RF_LO < 40000000UL)
2353 return -1;
2354
2355 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
2356 status += MXL_ControlWrite(fe, DN_POLY, 2);
2357 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2358 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 423);
2359 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2360 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
2361 }
2362 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
2363 status += MXL_ControlWrite(fe, DN_POLY, 3);
2364 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2365 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 222);
2366 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2367 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 1);
2368 }
2369 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
2370 status += MXL_ControlWrite(fe, DN_POLY, 3);
2371 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2372 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 147);
2373 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2374 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
2375 }
2376 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
2377 status += MXL_ControlWrite(fe, DN_POLY, 3);
2378 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2379 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 9);
2380 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2381 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 2);
2382 }
2383 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
2384 status += MXL_ControlWrite(fe, DN_POLY, 3);
2385 status += MXL_ControlWrite(fe, DN_RFGAIN, 3);
2386 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2387 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 1);
2388 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2389 }
2390 if (state->RF_LO > 300000000UL && state->RF_LO <= 650000000UL) {
2391 status += MXL_ControlWrite(fe, DN_POLY, 3);
2392 status += MXL_ControlWrite(fe, DN_RFGAIN, 1);
2393 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2394 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0);
2395 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2396 }
2397 if (state->RF_LO > 650000000UL && state->RF_LO <= 900000000UL) {
2398 status += MXL_ControlWrite(fe, DN_POLY, 3);
2399 status += MXL_ControlWrite(fe, DN_RFGAIN, 2);
2400 status += MXL_ControlWrite(fe, DN_CAP_RFLPF, 0);
2401 status += MXL_ControlWrite(fe, DN_EN_VHFUHFBAR, 0);
2402 status += MXL_ControlWrite(fe, DN_GAIN_ADJUST, 3);
2403 }
2404 if (state->RF_LO > 900000000UL)
2405 return -1;
2406
2407 /* DN_IQTNBUF_AMP */
2408 /* DN_IQTNGNBFBIAS_BST */
2409 if (state->RF_LO >= 40000000UL && state->RF_LO <= 75000000UL) {
2410 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2411 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2412 }
2413 if (state->RF_LO > 75000000UL && state->RF_LO <= 100000000UL) {
2414 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2415 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2416 }
2417 if (state->RF_LO > 100000000UL && state->RF_LO <= 150000000UL) {
2418 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2419 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2420 }
2421 if (state->RF_LO > 150000000UL && state->RF_LO <= 200000000UL) {
2422 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2423 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2424 }
2425 if (state->RF_LO > 200000000UL && state->RF_LO <= 300000000UL) {
2426 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2427 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2428 }
2429 if (state->RF_LO > 300000000UL && state->RF_LO <= 400000000UL) {
2430 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2431 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2432 }
2433 if (state->RF_LO > 400000000UL && state->RF_LO <= 450000000UL) {
2434 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2435 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2436 }
2437 if (state->RF_LO > 450000000UL && state->RF_LO <= 500000000UL) {
2438 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2439 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2440 }
2441 if (state->RF_LO > 500000000UL && state->RF_LO <= 550000000UL) {
2442 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2443 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2444 }
2445 if (state->RF_LO > 550000000UL && state->RF_LO <= 600000000UL) {
2446 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2447 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2448 }
2449 if (state->RF_LO > 600000000UL && state->RF_LO <= 650000000UL) {
2450 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2451 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2452 }
2453 if (state->RF_LO > 650000000UL && state->RF_LO <= 700000000UL) {
2454 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2455 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2456 }
2457 if (state->RF_LO > 700000000UL && state->RF_LO <= 750000000UL) {
2458 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2459 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2460 }
2461 if (state->RF_LO > 750000000UL && state->RF_LO <= 800000000UL) {
2462 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 1);
2463 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 0);
2464 }
2465 if (state->RF_LO > 800000000UL && state->RF_LO <= 850000000UL) {
2466 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2467 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
2468 }
2469 if (state->RF_LO > 850000000UL && state->RF_LO <= 900000000UL) {
2470 status += MXL_ControlWrite(fe, DN_IQTNBUF_AMP, 10);
2471 status += MXL_ControlWrite(fe, DN_IQTNGNBFBIAS_BST, 1);
2472 }
2473
2474 /*
2475 * Set RF Synth and LO Path Control
2476 *
2477 * Look-Up table implementation for:
2478 * RFSYN_EN_OUTMUX
2479 * RFSYN_SEL_VCO_OUT
2480 * RFSYN_SEL_VCO_HI
2481 * RFSYN_SEL_DIVM
2482 * RFSYN_RF_DIV_BIAS
2483 * DN_SEL_FREQ
2484 *
2485 * Set divider_val, Fmax, Fmix to use in Equations
2486 */
2487 FminBin = 28000000UL ;
2488 FmaxBin = 42500000UL ;
2489 if (state->RF_LO >= 40000000UL && state->RF_LO <= FmaxBin) {
2490 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2491 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2492 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2493 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2494 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2495 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2496 divider_val = 64 ;
2497 Fmax = FmaxBin ;
2498 Fmin = FminBin ;
2499 }
2500 FminBin = 42500000UL ;
2501 FmaxBin = 56000000UL ;
2502 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2503 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2504 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2505 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2506 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2507 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2508 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2509 divider_val = 64 ;
2510 Fmax = FmaxBin ;
2511 Fmin = FminBin ;
2512 }
2513 FminBin = 56000000UL ;
2514 FmaxBin = 85000000UL ;
2515 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2516 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2517 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2518 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2519 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2520 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2521 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2522 divider_val = 32 ;
2523 Fmax = FmaxBin ;
2524 Fmin = FminBin ;
2525 }
2526 FminBin = 85000000UL ;
2527 FmaxBin = 112000000UL ;
2528 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2529 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2530 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2531 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2532 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2533 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2534 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 1);
2535 divider_val = 32 ;
2536 Fmax = FmaxBin ;
2537 Fmin = FminBin ;
2538 }
2539 FminBin = 112000000UL ;
2540 FmaxBin = 170000000UL ;
2541 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2542 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2543 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2544 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2545 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2546 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2547 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2);
2548 divider_val = 16 ;
2549 Fmax = FmaxBin ;
2550 Fmin = FminBin ;
2551 }
2552 FminBin = 170000000UL ;
2553 FmaxBin = 225000000UL ;
2554 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2555 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2556 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2557 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2558 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2559 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2560 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 2);
2561 divider_val = 16 ;
2562 Fmax = FmaxBin ;
2563 Fmin = FminBin ;
2564 }
2565 FminBin = 225000000UL ;
2566 FmaxBin = 300000000UL ;
2567 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2568 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2569 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2570 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2571 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2572 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2573 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 4);
2574 divider_val = 8 ;
2575 Fmax = 340000000UL ;
2576 Fmin = FminBin ;
2577 }
2578 FminBin = 300000000UL ;
2579 FmaxBin = 340000000UL ;
2580 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2581 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2582 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2583 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2584 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2585 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2586 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2587 divider_val = 8 ;
2588 Fmax = FmaxBin ;
2589 Fmin = 225000000UL ;
2590 }
2591 FminBin = 340000000UL ;
2592 FmaxBin = 450000000UL ;
2593 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2594 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 1);
2595 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 0);
2596 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2597 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
2598 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 2);
2599 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2600 divider_val = 8 ;
2601 Fmax = FmaxBin ;
2602 Fmin = FminBin ;
2603 }
2604 FminBin = 450000000UL ;
2605 FmaxBin = 680000000UL ;
2606 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2607 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2608 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2609 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
2610 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1);
2611 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2612 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2613 divider_val = 4 ;
2614 Fmax = FmaxBin ;
2615 Fmin = FminBin ;
2616 }
2617 FminBin = 680000000UL ;
2618 FmaxBin = 900000000UL ;
2619 if (state->RF_LO > FminBin && state->RF_LO <= FmaxBin) {
2620 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
2621 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
2622 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
2623 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 1);
2624 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
2625 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
2626 divider_val = 4 ;
2627 Fmax = FmaxBin ;
2628 Fmin = FminBin ;
2629 }
2630
2631 /* CHCAL_INT_MOD_RF
2632 * CHCAL_FRAC_MOD_RF
2633 * RFSYN_LPF_R
2634 * CHCAL_EN_INT_RF
2635 */
2636 /* Equation E3 RFSYN_VCO_BIAS */
2637 E3 = (((Fmax-state->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
2638 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, E3);
2639
2640 /* Equation E4 CHCAL_INT_MOD_RF */
2641 E4 = (state->RF_LO*divider_val/1000)/(2*state->Fxtal*Kdbl_RF/1000);
2642 MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, E4);
2643
2644 /* Equation E5 CHCAL_FRAC_MOD_RF CHCAL_EN_INT_RF */
2645 E5 = ((2<<17)*(state->RF_LO/10000*divider_val -
2646 (E4*(2*state->Fxtal*Kdbl_RF)/10000))) /
2647 (2*state->Fxtal*Kdbl_RF/10000);
2648
2649 status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
2650
2651 /* Equation E5A RFSYN_LPF_R */
2652 E5A = (((Fmax - state->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
2653 status += MXL_ControlWrite(fe, RFSYN_LPF_R, E5A);
2654
2655 /* Euqation E5B CHCAL_EN_INIT_RF */
2656 status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0));
2657 /*if (E5 == 0)
2658 * status += MXL_ControlWrite(fe, CHCAL_EN_INT_RF, 1);
2659 *else
2660 * status += MXL_ControlWrite(fe, CHCAL_FRAC_MOD_RF, E5);
2661 */
2662
2663 /*
2664 * Set TG Synth
2665 *
2666 * Look-Up table implementation for:
2667 * TG_LO_DIVVAL
2668 * TG_LO_SELVAL
2669 *
2670 * Set divider_val, Fmax, Fmix to use in Equations
2671 */
2672 if (state->TG_LO < 33000000UL)
2673 return -1;
2674
2675 FminBin = 33000000UL ;
2676 FmaxBin = 50000000UL ;
2677 if (state->TG_LO >= FminBin && state->TG_LO <= FmaxBin) {
2678 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x6);
2679 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0);
2680 divider_val = 36 ;
2681 Fmax = FmaxBin ;
2682 Fmin = FminBin ;
2683 }
2684 FminBin = 50000000UL ;
2685 FmaxBin = 67000000UL ;
2686 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2687 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x1);
2688 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x0);
2689 divider_val = 24 ;
2690 Fmax = FmaxBin ;
2691 Fmin = FminBin ;
2692 }
2693 FminBin = 67000000UL ;
2694 FmaxBin = 100000000UL ;
2695 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2696 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0xC);
2697 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2698 divider_val = 18 ;
2699 Fmax = FmaxBin ;
2700 Fmin = FminBin ;
2701 }
2702 FminBin = 100000000UL ;
2703 FmaxBin = 150000000UL ;
2704 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2705 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2706 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2707 divider_val = 12 ;
2708 Fmax = FmaxBin ;
2709 Fmin = FminBin ;
2710 }
2711 FminBin = 150000000UL ;
2712 FmaxBin = 200000000UL ;
2713 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2714 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2715 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x2);
2716 divider_val = 8 ;
2717 Fmax = FmaxBin ;
2718 Fmin = FminBin ;
2719 }
2720 FminBin = 200000000UL ;
2721 FmaxBin = 300000000UL ;
2722 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2723 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2724 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3);
2725 divider_val = 6 ;
2726 Fmax = FmaxBin ;
2727 Fmin = FminBin ;
2728 }
2729 FminBin = 300000000UL ;
2730 FmaxBin = 400000000UL ;
2731 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2732 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2733 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x3);
2734 divider_val = 4 ;
2735 Fmax = FmaxBin ;
2736 Fmin = FminBin ;
2737 }
2738 FminBin = 400000000UL ;
2739 FmaxBin = 600000000UL ;
2740 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2741 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x8);
2742 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7);
2743 divider_val = 3 ;
2744 Fmax = FmaxBin ;
2745 Fmin = FminBin ;
2746 }
2747 FminBin = 600000000UL ;
2748 FmaxBin = 900000000UL ;
2749 if (state->TG_LO > FminBin && state->TG_LO <= FmaxBin) {
2750 status += MXL_ControlWrite(fe, TG_LO_DIVVAL, 0x0);
2751 status += MXL_ControlWrite(fe, TG_LO_SELVAL, 0x7);
2752 divider_val = 2 ;
2753 Fmax = FmaxBin ;
2754 Fmin = FminBin ;
2755 }
2756
2757 /* TG_DIV_VAL */
2758 tg_divval = (state->TG_LO*divider_val/100000) *
2759 (MXL_Ceiling(state->Fxtal, 1000000) * 100) /
2760 (state->Fxtal/1000);
2761
2762 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval);
2763
2764 if (state->TG_LO > 600000000UL)
2765 status += MXL_ControlWrite(fe, TG_DIV_VAL, tg_divval + 1);
2766
2767 Fmax = 1800000000UL ;
2768 Fmin = 1200000000UL ;
2769
2770 /* prevent overflow of 32 bit unsigned integer, use
2771 * following equation. Edit for v2.6.4
2772 */
2773 /* Fref_TF = Fref_TG * 1000 */
2774 Fref_TG = (state->Fxtal/1000) / MXL_Ceiling(state->Fxtal, 1000000);
2775
2776 /* Fvco = Fvco/10 */
2777 Fvco = (state->TG_LO/10000) * divider_val * Fref_TG;
2778
2779 tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
2780
2781 /* below equation is same as above but much harder to debug.
2782 * tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) -
2783 * ((state->TG_LO/10000)*divider_val *
2784 * (state->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 *
2785 * Xtal_Int/100) + 8;
2786 */
2787
2788 status += MXL_ControlWrite(fe, TG_VCO_BIAS , tg_lo);
2789
2790 /* add for 2.6.5 Special setting for QAM */
2791 if (state->Mod_Type == MXL_QAM) {
2792 if (state->RF_IN < 680000000)
2793 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
2794 else
2795 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 2);
2796 }
2797
2798 /* Off Chip Tracking Filter Control */
2799 if (state->TF_Type == MXL_TF_OFF) {
2800 /* Tracking Filter Off State; turn off all the banks */
2801 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2802 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2803 status += MXL_SetGPIO(fe, 3, 1); /* Bank1 Off */
2804 status += MXL_SetGPIO(fe, 1, 1); /* Bank2 Off */
2805 status += MXL_SetGPIO(fe, 4, 1); /* Bank3 Off */
2806 }
2807
2808 if (state->TF_Type == MXL_TF_C) /* Tracking Filter type C */ {
2809 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2810 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2811
2812 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
2813 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2814 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2815 status += MXL_SetGPIO(fe, 3, 0);
2816 status += MXL_SetGPIO(fe, 1, 1);
2817 status += MXL_SetGPIO(fe, 4, 1);
2818 }
2819 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
2820 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2821 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2822 status += MXL_SetGPIO(fe, 3, 1);
2823 status += MXL_SetGPIO(fe, 1, 0);
2824 status += MXL_SetGPIO(fe, 4, 1);
2825 }
2826 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
2827 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2828 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2829 status += MXL_SetGPIO(fe, 3, 1);
2830 status += MXL_SetGPIO(fe, 1, 0);
2831 status += MXL_SetGPIO(fe, 4, 0);
2832 }
2833 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
2834 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2835 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2836 status += MXL_SetGPIO(fe, 3, 1);
2837 status += MXL_SetGPIO(fe, 1, 1);
2838 status += MXL_SetGPIO(fe, 4, 0);
2839 }
2840 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
2841 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2842 status += MXL_ControlWrite(fe, DAC_DIN_B, 29);
2843 status += MXL_SetGPIO(fe, 3, 1);
2844 status += MXL_SetGPIO(fe, 1, 1);
2845 status += MXL_SetGPIO(fe, 4, 0);
2846 }
2847 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
2848 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2849 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2850 status += MXL_SetGPIO(fe, 3, 1);
2851 status += MXL_SetGPIO(fe, 1, 1);
2852 status += MXL_SetGPIO(fe, 4, 0);
2853 }
2854 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
2855 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2856 status += MXL_ControlWrite(fe, DAC_DIN_B, 16);
2857 status += MXL_SetGPIO(fe, 3, 1);
2858 status += MXL_SetGPIO(fe, 1, 1);
2859 status += MXL_SetGPIO(fe, 4, 1);
2860 }
2861 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
2862 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2863 status += MXL_ControlWrite(fe, DAC_DIN_B, 7);
2864 status += MXL_SetGPIO(fe, 3, 1);
2865 status += MXL_SetGPIO(fe, 1, 1);
2866 status += MXL_SetGPIO(fe, 4, 1);
2867 }
2868 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
2869 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2870 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2871 status += MXL_SetGPIO(fe, 3, 1);
2872 status += MXL_SetGPIO(fe, 1, 1);
2873 status += MXL_SetGPIO(fe, 4, 1);
2874 }
2875 }
2876
2877 if (state->TF_Type == MXL_TF_C_H) {
2878
2879 /* Tracking Filter type C-H for Hauppauge only */
2880 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2881
2882 if (state->RF_IN >= 43000000 && state->RF_IN < 150000000) {
2883 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2884 status += MXL_SetGPIO(fe, 4, 0);
2885 status += MXL_SetGPIO(fe, 3, 1);
2886 status += MXL_SetGPIO(fe, 1, 1);
2887 }
2888 if (state->RF_IN >= 150000000 && state->RF_IN < 280000000) {
2889 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2890 status += MXL_SetGPIO(fe, 4, 1);
2891 status += MXL_SetGPIO(fe, 3, 0);
2892 status += MXL_SetGPIO(fe, 1, 1);
2893 }
2894 if (state->RF_IN >= 280000000 && state->RF_IN < 360000000) {
2895 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2896 status += MXL_SetGPIO(fe, 4, 1);
2897 status += MXL_SetGPIO(fe, 3, 0);
2898 status += MXL_SetGPIO(fe, 1, 0);
2899 }
2900 if (state->RF_IN >= 360000000 && state->RF_IN < 560000000) {
2901 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2902 status += MXL_SetGPIO(fe, 4, 1);
2903 status += MXL_SetGPIO(fe, 3, 1);
2904 status += MXL_SetGPIO(fe, 1, 0);
2905 }
2906 if (state->RF_IN >= 560000000 && state->RF_IN < 580000000) {
2907 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2908 status += MXL_SetGPIO(fe, 4, 1);
2909 status += MXL_SetGPIO(fe, 3, 1);
2910 status += MXL_SetGPIO(fe, 1, 0);
2911 }
2912 if (state->RF_IN >= 580000000 && state->RF_IN < 630000000) {
2913 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2914 status += MXL_SetGPIO(fe, 4, 1);
2915 status += MXL_SetGPIO(fe, 3, 1);
2916 status += MXL_SetGPIO(fe, 1, 0);
2917 }
2918 if (state->RF_IN >= 630000000 && state->RF_IN < 700000000) {
2919 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2920 status += MXL_SetGPIO(fe, 4, 1);
2921 status += MXL_SetGPIO(fe, 3, 1);
2922 status += MXL_SetGPIO(fe, 1, 1);
2923 }
2924 if (state->RF_IN >= 700000000 && state->RF_IN < 760000000) {
2925 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2926 status += MXL_SetGPIO(fe, 4, 1);
2927 status += MXL_SetGPIO(fe, 3, 1);
2928 status += MXL_SetGPIO(fe, 1, 1);
2929 }
2930 if (state->RF_IN >= 760000000 && state->RF_IN <= 900000000) {
2931 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
2932 status += MXL_SetGPIO(fe, 4, 1);
2933 status += MXL_SetGPIO(fe, 3, 1);
2934 status += MXL_SetGPIO(fe, 1, 1);
2935 }
2936 }
2937
2938 if (state->TF_Type == MXL_TF_D) { /* Tracking Filter type D */
2939
2940 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
2941
2942 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
2943 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2944 status += MXL_SetGPIO(fe, 4, 0);
2945 status += MXL_SetGPIO(fe, 1, 1);
2946 status += MXL_SetGPIO(fe, 3, 1);
2947 }
2948 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
2949 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2950 status += MXL_SetGPIO(fe, 4, 0);
2951 status += MXL_SetGPIO(fe, 1, 0);
2952 status += MXL_SetGPIO(fe, 3, 1);
2953 }
2954 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
2955 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2956 status += MXL_SetGPIO(fe, 4, 1);
2957 status += MXL_SetGPIO(fe, 1, 0);
2958 status += MXL_SetGPIO(fe, 3, 1);
2959 }
2960 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
2961 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2962 status += MXL_SetGPIO(fe, 4, 1);
2963 status += MXL_SetGPIO(fe, 1, 0);
2964 status += MXL_SetGPIO(fe, 3, 0);
2965 }
2966 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
2967 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
2968 status += MXL_SetGPIO(fe, 4, 1);
2969 status += MXL_SetGPIO(fe, 1, 1);
2970 status += MXL_SetGPIO(fe, 3, 0);
2971 }
2972 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
2973 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2974 status += MXL_SetGPIO(fe, 4, 1);
2975 status += MXL_SetGPIO(fe, 1, 1);
2976 status += MXL_SetGPIO(fe, 3, 0);
2977 }
2978 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
2979 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
2980 status += MXL_SetGPIO(fe, 4, 1);
2981 status += MXL_SetGPIO(fe, 1, 1);
2982 status += MXL_SetGPIO(fe, 3, 1);
2983 }
2984 }
2985
2986 if (state->TF_Type == MXL_TF_D_L) {
2987
2988 /* Tracking Filter type D-L for Lumanate ONLY change 2.6.3 */
2989 status += MXL_ControlWrite(fe, DAC_DIN_A, 0);
2990
2991 /* if UHF and terrestrial => Turn off Tracking Filter */
2992 if (state->RF_IN >= 471000000 &&
2993 (state->RF_IN - 471000000)%6000000 != 0) {
2994 /* Turn off all the banks */
2995 status += MXL_SetGPIO(fe, 3, 1);
2996 status += MXL_SetGPIO(fe, 1, 1);
2997 status += MXL_SetGPIO(fe, 4, 1);
2998 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
2999 status += MXL_ControlWrite(fe, AGC_IF, 10);
3000 } else {
3001 /* if VHF or cable => Turn on Tracking Filter */
3002 if (state->RF_IN >= 43000000 &&
3003 state->RF_IN < 140000000) {
3004
3005 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3006 status += MXL_SetGPIO(fe, 4, 1);
3007 status += MXL_SetGPIO(fe, 1, 1);
3008 status += MXL_SetGPIO(fe, 3, 0);
3009 }
3010 if (state->RF_IN >= 140000000 &&
3011 state->RF_IN < 240000000) {
3012 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3013 status += MXL_SetGPIO(fe, 4, 1);
3014 status += MXL_SetGPIO(fe, 1, 0);
3015 status += MXL_SetGPIO(fe, 3, 0);
3016 }
3017 if (state->RF_IN >= 240000000 &&
3018 state->RF_IN < 340000000) {
3019 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3020 status += MXL_SetGPIO(fe, 4, 0);
3021 status += MXL_SetGPIO(fe, 1, 1);
3022 status += MXL_SetGPIO(fe, 3, 0);
3023 }
3024 if (state->RF_IN >= 340000000 &&
3025 state->RF_IN < 430000000) {
3026 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3027 status += MXL_SetGPIO(fe, 4, 0);
3028 status += MXL_SetGPIO(fe, 1, 0);
3029 status += MXL_SetGPIO(fe, 3, 1);
3030 }
3031 if (state->RF_IN >= 430000000 &&
3032 state->RF_IN < 470000000) {
3033 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3034 status += MXL_SetGPIO(fe, 4, 1);
3035 status += MXL_SetGPIO(fe, 1, 0);
3036 status += MXL_SetGPIO(fe, 3, 1);
3037 }
3038 if (state->RF_IN >= 470000000 &&
3039 state->RF_IN < 570000000) {
3040 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3041 status += MXL_SetGPIO(fe, 4, 0);
3042 status += MXL_SetGPIO(fe, 1, 0);
3043 status += MXL_SetGPIO(fe, 3, 1);
3044 }
3045 if (state->RF_IN >= 570000000 &&
3046 state->RF_IN < 620000000) {
3047 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 0);
3048 status += MXL_SetGPIO(fe, 4, 0);
3049 status += MXL_SetGPIO(fe, 1, 1);
3050 status += MXL_SetGPIO(fe, 3, 1);
3051 }
3052 if (state->RF_IN >= 620000000 &&
3053 state->RF_IN < 760000000) {
3054 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3055 status += MXL_SetGPIO(fe, 4, 0);
3056 status += MXL_SetGPIO(fe, 1, 1);
3057 status += MXL_SetGPIO(fe, 3, 1);
3058 }
3059 if (state->RF_IN >= 760000000 &&
3060 state->RF_IN <= 900000000) {
3061 status += MXL_ControlWrite(fe, DAC_A_ENABLE, 1);
3062 status += MXL_SetGPIO(fe, 4, 1);
3063 status += MXL_SetGPIO(fe, 1, 1);
3064 status += MXL_SetGPIO(fe, 3, 1);
3065 }
3066 }
3067 }
3068
3069 if (state->TF_Type == MXL_TF_E) /* Tracking Filter type E */ {
3070
3071 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3072
3073 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3074 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3075 status += MXL_SetGPIO(fe, 4, 0);
3076 status += MXL_SetGPIO(fe, 1, 1);
3077 status += MXL_SetGPIO(fe, 3, 1);
3078 }
3079 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3080 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3081 status += MXL_SetGPIO(fe, 4, 0);
3082 status += MXL_SetGPIO(fe, 1, 0);
3083 status += MXL_SetGPIO(fe, 3, 1);
3084 }
3085 if (state->RF_IN >= 250000000 && state->RF_IN < 310000000) {
3086 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3087 status += MXL_SetGPIO(fe, 4, 1);
3088 status += MXL_SetGPIO(fe, 1, 0);
3089 status += MXL_SetGPIO(fe, 3, 1);
3090 }
3091 if (state->RF_IN >= 310000000 && state->RF_IN < 360000000) {
3092 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3093 status += MXL_SetGPIO(fe, 4, 1);
3094 status += MXL_SetGPIO(fe, 1, 0);
3095 status += MXL_SetGPIO(fe, 3, 0);
3096 }
3097 if (state->RF_IN >= 360000000 && state->RF_IN < 470000000) {
3098 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3099 status += MXL_SetGPIO(fe, 4, 1);
3100 status += MXL_SetGPIO(fe, 1, 1);
3101 status += MXL_SetGPIO(fe, 3, 0);
3102 }
3103 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
3104 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3105 status += MXL_SetGPIO(fe, 4, 1);
3106 status += MXL_SetGPIO(fe, 1, 1);
3107 status += MXL_SetGPIO(fe, 3, 0);
3108 }
3109 if (state->RF_IN >= 640000000 && state->RF_IN <= 900000000) {
3110 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3111 status += MXL_SetGPIO(fe, 4, 1);
3112 status += MXL_SetGPIO(fe, 1, 1);
3113 status += MXL_SetGPIO(fe, 3, 1);
3114 }
3115 }
3116
3117 if (state->TF_Type == MXL_TF_F) {
3118
3119 /* Tracking Filter type F */
3120 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3121
3122 if (state->RF_IN >= 43000000 && state->RF_IN < 160000000) {
3123 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3124 status += MXL_SetGPIO(fe, 4, 0);
3125 status += MXL_SetGPIO(fe, 1, 1);
3126 status += MXL_SetGPIO(fe, 3, 1);
3127 }
3128 if (state->RF_IN >= 160000000 && state->RF_IN < 210000000) {
3129 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3130 status += MXL_SetGPIO(fe, 4, 0);
3131 status += MXL_SetGPIO(fe, 1, 0);
3132 status += MXL_SetGPIO(fe, 3, 1);
3133 }
3134 if (state->RF_IN >= 210000000 && state->RF_IN < 300000000) {
3135 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3136 status += MXL_SetGPIO(fe, 4, 1);
3137 status += MXL_SetGPIO(fe, 1, 0);
3138 status += MXL_SetGPIO(fe, 3, 1);
3139 }
3140 if (state->RF_IN >= 300000000 && state->RF_IN < 390000000) {
3141 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3142 status += MXL_SetGPIO(fe, 4, 1);
3143 status += MXL_SetGPIO(fe, 1, 0);
3144 status += MXL_SetGPIO(fe, 3, 0);
3145 }
3146 if (state->RF_IN >= 390000000 && state->RF_IN < 515000000) {
3147 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3148 status += MXL_SetGPIO(fe, 4, 1);
3149 status += MXL_SetGPIO(fe, 1, 1);
3150 status += MXL_SetGPIO(fe, 3, 0);
3151 }
3152 if (state->RF_IN >= 515000000 && state->RF_IN < 650000000) {
3153 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3154 status += MXL_SetGPIO(fe, 4, 1);
3155 status += MXL_SetGPIO(fe, 1, 1);
3156 status += MXL_SetGPIO(fe, 3, 0);
3157 }
3158 if (state->RF_IN >= 650000000 && state->RF_IN <= 900000000) {
3159 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3160 status += MXL_SetGPIO(fe, 4, 1);
3161 status += MXL_SetGPIO(fe, 1, 1);
3162 status += MXL_SetGPIO(fe, 3, 1);
3163 }
3164 }
3165
3166 if (state->TF_Type == MXL_TF_E_2) {
3167
3168 /* Tracking Filter type E_2 */
3169 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3170
3171 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3172 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3173 status += MXL_SetGPIO(fe, 4, 0);
3174 status += MXL_SetGPIO(fe, 1, 1);
3175 status += MXL_SetGPIO(fe, 3, 1);
3176 }
3177 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3178 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3179 status += MXL_SetGPIO(fe, 4, 0);
3180 status += MXL_SetGPIO(fe, 1, 0);
3181 status += MXL_SetGPIO(fe, 3, 1);
3182 }
3183 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
3184 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3185 status += MXL_SetGPIO(fe, 4, 1);
3186 status += MXL_SetGPIO(fe, 1, 0);
3187 status += MXL_SetGPIO(fe, 3, 1);
3188 }
3189 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3190 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3191 status += MXL_SetGPIO(fe, 4, 1);
3192 status += MXL_SetGPIO(fe, 1, 0);
3193 status += MXL_SetGPIO(fe, 3, 0);
3194 }
3195 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
3196 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3197 status += MXL_SetGPIO(fe, 4, 1);
3198 status += MXL_SetGPIO(fe, 1, 1);
3199 status += MXL_SetGPIO(fe, 3, 0);
3200 }
3201 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
3202 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3203 status += MXL_SetGPIO(fe, 4, 1);
3204 status += MXL_SetGPIO(fe, 1, 1);
3205 status += MXL_SetGPIO(fe, 3, 0);
3206 }
3207 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
3208 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3209 status += MXL_SetGPIO(fe, 4, 1);
3210 status += MXL_SetGPIO(fe, 1, 1);
3211 status += MXL_SetGPIO(fe, 3, 1);
3212 }
3213 }
3214
3215 if (state->TF_Type == MXL_TF_G) {
3216
3217 /* Tracking Filter type G add for v2.6.8 */
3218 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3219
3220 if (state->RF_IN >= 50000000 && state->RF_IN < 190000000) {
3221
3222 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3223 status += MXL_SetGPIO(fe, 4, 0);
3224 status += MXL_SetGPIO(fe, 1, 1);
3225 status += MXL_SetGPIO(fe, 3, 1);
3226 }
3227 if (state->RF_IN >= 190000000 && state->RF_IN < 280000000) {
3228 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3229 status += MXL_SetGPIO(fe, 4, 0);
3230 status += MXL_SetGPIO(fe, 1, 0);
3231 status += MXL_SetGPIO(fe, 3, 1);
3232 }
3233 if (state->RF_IN >= 280000000 && state->RF_IN < 350000000) {
3234 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3235 status += MXL_SetGPIO(fe, 4, 1);
3236 status += MXL_SetGPIO(fe, 1, 0);
3237 status += MXL_SetGPIO(fe, 3, 1);
3238 }
3239 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3240 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3241 status += MXL_SetGPIO(fe, 4, 1);
3242 status += MXL_SetGPIO(fe, 1, 0);
3243 status += MXL_SetGPIO(fe, 3, 0);
3244 }
3245 if (state->RF_IN >= 400000000 && state->RF_IN < 470000000) {
3246 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3247 status += MXL_SetGPIO(fe, 4, 1);
3248 status += MXL_SetGPIO(fe, 1, 0);
3249 status += MXL_SetGPIO(fe, 3, 1);
3250 }
3251 if (state->RF_IN >= 470000000 && state->RF_IN < 640000000) {
3252 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3253 status += MXL_SetGPIO(fe, 4, 1);
3254 status += MXL_SetGPIO(fe, 1, 1);
3255 status += MXL_SetGPIO(fe, 3, 0);
3256 }
3257 if (state->RF_IN >= 640000000 && state->RF_IN < 820000000) {
3258 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3259 status += MXL_SetGPIO(fe, 4, 1);
3260 status += MXL_SetGPIO(fe, 1, 1);
3261 status += MXL_SetGPIO(fe, 3, 0);
3262 }
3263 if (state->RF_IN >= 820000000 && state->RF_IN <= 900000000) {
3264 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3265 status += MXL_SetGPIO(fe, 4, 1);
3266 status += MXL_SetGPIO(fe, 1, 1);
3267 status += MXL_SetGPIO(fe, 3, 1);
3268 }
3269 }
3270
3271 if (state->TF_Type == MXL_TF_E_NA) {
3272
3273 /* Tracking Filter type E-NA for Empia ONLY change for 2.6.8 */
3274 status += MXL_ControlWrite(fe, DAC_DIN_B, 0);
3275
3276 /* if UHF and terrestrial=> Turn off Tracking Filter */
3277 if (state->RF_IN >= 471000000 &&
3278 (state->RF_IN - 471000000)%6000000 != 0) {
3279
3280 /* Turn off all the banks */
3281 status += MXL_SetGPIO(fe, 3, 1);
3282 status += MXL_SetGPIO(fe, 1, 1);
3283 status += MXL_SetGPIO(fe, 4, 1);
3284 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3285
3286 /* 2.6.12 Turn on RSSI */
3287 status += MXL_ControlWrite(fe, SEQ_EXTSYNTHCALIF, 1);
3288 status += MXL_ControlWrite(fe, SEQ_EXTDCCAL, 1);
3289 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 1);
3290 status += MXL_ControlWrite(fe, RFA_ENCLKRFAGC, 1);
3291
3292 /* RSSI reference point */
3293 status += MXL_ControlWrite(fe, RFA_RSSI_REFH, 5);
3294 status += MXL_ControlWrite(fe, RFA_RSSI_REF, 3);
3295 status += MXL_ControlWrite(fe, RFA_RSSI_REFL, 2);
3296
3297 /* following parameter is from analog OTA mode,
3298 * can be change to seek better performance */
3299 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 3);
3300 } else {
3301 /* if VHF or Cable => Turn on Tracking Filter */
3302
3303 /* 2.6.12 Turn off RSSI */
3304 status += MXL_ControlWrite(fe, AGC_EN_RSSI, 0);
3305
3306 /* change back from above condition */
3307 status += MXL_ControlWrite(fe, RFSYN_CHP_GAIN, 5);
3308
3309
3310 if (state->RF_IN >= 43000000 && state->RF_IN < 174000000) {
3311
3312 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3313 status += MXL_SetGPIO(fe, 4, 0);
3314 status += MXL_SetGPIO(fe, 1, 1);
3315 status += MXL_SetGPIO(fe, 3, 1);
3316 }
3317 if (state->RF_IN >= 174000000 && state->RF_IN < 250000000) {
3318 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3319 status += MXL_SetGPIO(fe, 4, 0);
3320 status += MXL_SetGPIO(fe, 1, 0);
3321 status += MXL_SetGPIO(fe, 3, 1);
3322 }
3323 if (state->RF_IN >= 250000000 && state->RF_IN < 350000000) {
3324 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3325 status += MXL_SetGPIO(fe, 4, 1);
3326 status += MXL_SetGPIO(fe, 1, 0);
3327 status += MXL_SetGPIO(fe, 3, 1);
3328 }
3329 if (state->RF_IN >= 350000000 && state->RF_IN < 400000000) {
3330 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3331 status += MXL_SetGPIO(fe, 4, 1);
3332 status += MXL_SetGPIO(fe, 1, 0);
3333 status += MXL_SetGPIO(fe, 3, 0);
3334 }
3335 if (state->RF_IN >= 400000000 && state->RF_IN < 570000000) {
3336 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 0);
3337 status += MXL_SetGPIO(fe, 4, 1);
3338 status += MXL_SetGPIO(fe, 1, 1);
3339 status += MXL_SetGPIO(fe, 3, 0);
3340 }
3341 if (state->RF_IN >= 570000000 && state->RF_IN < 770000000) {
3342 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3343 status += MXL_SetGPIO(fe, 4, 1);
3344 status += MXL_SetGPIO(fe, 1, 1);
3345 status += MXL_SetGPIO(fe, 3, 0);
3346 }
3347 if (state->RF_IN >= 770000000 && state->RF_IN <= 900000000) {
3348 status += MXL_ControlWrite(fe, DAC_B_ENABLE, 1);
3349 status += MXL_SetGPIO(fe, 4, 1);
3350 status += MXL_SetGPIO(fe, 1, 1);
3351 status += MXL_SetGPIO(fe, 3, 1);
3352 }
3353 }
3354 }
3355 return status ;
3356}
3357
3358static u16 MXL_SetGPIO(struct dvb_frontend *fe, u8 GPIO_Num, u8 GPIO_Val)
3359{
3360 u16 status = 0;
3361
3362 if (GPIO_Num == 1)
3363 status += MXL_ControlWrite(fe, GPIO_1B, GPIO_Val ? 0 : 1);
3364
3365 /* GPIO2 is not available */
3366
3367 if (GPIO_Num == 3) {
3368 if (GPIO_Val == 1) {
3369 status += MXL_ControlWrite(fe, GPIO_3, 0);
3370 status += MXL_ControlWrite(fe, GPIO_3B, 0);
3371 }
3372 if (GPIO_Val == 0) {
3373 status += MXL_ControlWrite(fe, GPIO_3, 1);
3374 status += MXL_ControlWrite(fe, GPIO_3B, 1);
3375 }
3376 if (GPIO_Val == 3) { /* tri-state */
3377 status += MXL_ControlWrite(fe, GPIO_3, 0);
3378 status += MXL_ControlWrite(fe, GPIO_3B, 1);
3379 }
3380 }
3381 if (GPIO_Num == 4) {
3382 if (GPIO_Val == 1) {
3383 status += MXL_ControlWrite(fe, GPIO_4, 0);
3384 status += MXL_ControlWrite(fe, GPIO_4B, 0);
3385 }
3386 if (GPIO_Val == 0) {
3387 status += MXL_ControlWrite(fe, GPIO_4, 1);
3388 status += MXL_ControlWrite(fe, GPIO_4B, 1);
3389 }
3390 if (GPIO_Val == 3) { /* tri-state */
3391 status += MXL_ControlWrite(fe, GPIO_4, 0);
3392 status += MXL_ControlWrite(fe, GPIO_4B, 1);
3393 }
3394 }
3395
3396 return status;
3397}
3398
3399static u16 MXL_ControlWrite(struct dvb_frontend *fe, u16 ControlNum, u32 value)
3400{
3401 u16 status = 0;
3402
3403 /* Will write ALL Matching Control Name */
3404 /* Write Matching INIT Control */
3405 status += MXL_ControlWrite_Group(fe, ControlNum, value, 1);
3406 /* Write Matching CH Control */
3407 status += MXL_ControlWrite_Group(fe, ControlNum, value, 2);
3408#ifdef _MXL_INTERNAL
3409 /* Write Matching MXL Control */
3410 status += MXL_ControlWrite_Group(fe, ControlNum, value, 3);
3411#endif
3412 return status;
3413}
3414
3415static u16 MXL_ControlWrite_Group(struct dvb_frontend *fe, u16 controlNum,
3416 u32 value, u16 controlGroup)
3417{
3418 struct mxl5005s_state *state = fe->tuner_priv;
3419 u16 i, j, k;
3420 u32 highLimit;
3421 u32 ctrlVal;
3422
3423 if (controlGroup == 1) /* Initial Control */ {
3424
3425 for (i = 0; i < state->Init_Ctrl_Num; i++) {
3426
3427 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3428
3429 highLimit = 1 << state->Init_Ctrl[i].size;
3430 if (value < highLimit) {
3431 for (j = 0; j < state->Init_Ctrl[i].size; j++) {
3432 state->Init_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3433 MXL_RegWriteBit(fe, (u8)(state->Init_Ctrl[i].addr[j]),
3434 (u8)(state->Init_Ctrl[i].bit[j]),
3435 (u8)((value>>j) & 0x01));
3436 }
3437 ctrlVal = 0;
3438 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3439 ctrlVal += state->Init_Ctrl[i].val[k] * (1 << k);
3440 } else
3441 return -1;
3442 }
3443 }
3444 }
3445 if (controlGroup == 2) /* Chan change Control */ {
3446
3447 for (i = 0; i < state->CH_Ctrl_Num; i++) {
3448
3449 if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
3450
3451 highLimit = 1 << state->CH_Ctrl[i].size;
3452 if (value < highLimit) {
3453 for (j = 0; j < state->CH_Ctrl[i].size; j++) {
3454 state->CH_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3455 MXL_RegWriteBit(fe, (u8)(state->CH_Ctrl[i].addr[j]),
3456 (u8)(state->CH_Ctrl[i].bit[j]),
3457 (u8)((value>>j) & 0x01));
3458 }
3459 ctrlVal = 0;
3460 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3461 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
3462 } else
3463 return -1;
3464 }
3465 }
3466 }
3467#ifdef _MXL_INTERNAL
3468 if (controlGroup == 3) /* Maxlinear Control */ {
3469
3470 for (i = 0; i < state->MXL_Ctrl_Num; i++) {
3471
3472 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
3473
3474 highLimit = (1 << state->MXL_Ctrl[i].size);
3475 if (value < highLimit) {
3476 for (j = 0; j < state->MXL_Ctrl[i].size; j++) {
3477 state->MXL_Ctrl[i].val[j] = (u8)((value >> j) & 0x01);
3478 MXL_RegWriteBit(fe, (u8)(state->MXL_Ctrl[i].addr[j]),
3479 (u8)(state->MXL_Ctrl[i].bit[j]),
3480 (u8)((value>>j) & 0x01));
3481 }
3482 ctrlVal = 0;
3483 for (k = 0; k < state->MXL_Ctrl[i].size; k++)
3484 ctrlVal += state->MXL_Ctrl[i].val[k] * (1 << k);
3485 } else
3486 return -1;
3487 }
3488 }
3489 }
3490#endif
3491 return 0 ; /* successful return */
3492}
3493
3494static u16 MXL_RegRead(struct dvb_frontend *fe, u8 RegNum, u8 *RegVal)
3495{
3496 struct mxl5005s_state *state = fe->tuner_priv;
3497 int i ;
3498
3499 for (i = 0; i < 104; i++) {
3500 if (RegNum == state->TunerRegs[i].Reg_Num) {
3501 *RegVal = (u8)(state->TunerRegs[i].Reg_Val);
3502 return 0;
3503 }
3504 }
3505
3506 return 1;
3507}
3508
3509static u16 MXL_ControlRead(struct dvb_frontend *fe, u16 controlNum, u32 *value)
3510{
3511 struct mxl5005s_state *state = fe->tuner_priv;
3512 u32 ctrlVal ;
3513 u16 i, k ;
3514
3515 for (i = 0; i < state->Init_Ctrl_Num ; i++) {
3516
3517 if (controlNum == state->Init_Ctrl[i].Ctrl_Num) {
3518
3519 ctrlVal = 0;
3520 for (k = 0; k < state->Init_Ctrl[i].size; k++)
3521 ctrlVal += state->Init_Ctrl[i].val[k] * (1<<k);
3522 *value = ctrlVal;
3523 return 0;
3524 }
3525 }
3526
3527 for (i = 0; i < state->CH_Ctrl_Num ; i++) {
3528
3529 if (controlNum == state->CH_Ctrl[i].Ctrl_Num) {
3530
3531 ctrlVal = 0;
3532 for (k = 0; k < state->CH_Ctrl[i].size; k++)
3533 ctrlVal += state->CH_Ctrl[i].val[k] * (1 << k);
3534 *value = ctrlVal;
3535 return 0;
3536
3537 }
3538 }
3539
3540#ifdef _MXL_INTERNAL
3541 for (i = 0; i < state->MXL_Ctrl_Num ; i++) {
3542
3543 if (controlNum == state->MXL_Ctrl[i].Ctrl_Num) {
3544
3545 ctrlVal = 0;
3546 for (k = 0; k < state->MXL_Ctrl[i].size; k++)
3547 ctrlVal += state->MXL_Ctrl[i].val[k] * (1<<k);
3548 *value = ctrlVal;
3549 return 0;
3550
3551 }
3552 }
3553#endif
3554 return 1;
3555}
3556
3557static void MXL_RegWriteBit(struct dvb_frontend *fe, u8 address, u8 bit,
3558 u8 bitVal)
3559{
3560 struct mxl5005s_state *state = fe->tuner_priv;
3561 int i ;
3562
3563 const u8 AND_MAP[8] = {
3564 0xFE, 0xFD, 0xFB, 0xF7,
3565 0xEF, 0xDF, 0xBF, 0x7F } ;
3566
3567 const u8 OR_MAP[8] = {
3568 0x01, 0x02, 0x04, 0x08,
3569 0x10, 0x20, 0x40, 0x80 } ;
3570
3571 for (i = 0; i < state->TunerRegs_Num; i++) {
3572 if (state->TunerRegs[i].Reg_Num == address) {
3573 if (bitVal)
3574 state->TunerRegs[i].Reg_Val |= OR_MAP[bit];
3575 else
3576 state->TunerRegs[i].Reg_Val &= AND_MAP[bit];
3577 break ;
3578 }
3579 }
3580}
3581
3582static u32 MXL_Ceiling(u32 value, u32 resolution)
3583{
3584 return (value/resolution + (value % resolution > 0 ? 1 : 0));
3585}
3586
3587/* Retrieve the Initialzation Registers */
3588static u16 MXL_GetInitRegister(struct dvb_frontend *fe, u8 *RegNum,
3589 u8 *RegVal, int *count)
3590{
3591 u16 status = 0;
3592 int i ;
3593
3594 u8 RegAddr[] = {
3595 11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
3596 76, 77, 91, 134, 135, 137, 147,
3597 156, 166, 167, 168, 25 };
3598
3599 *count = sizeof(RegAddr) / sizeof(u8);
3600
3601 status += MXL_BlockInit(fe);
3602
3603 for (i = 0 ; i < *count; i++) {
3604 RegNum[i] = RegAddr[i];
3605 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3606 }
3607
3608 return status;
3609}
3610
3611static u16 MXL_GetCHRegister(struct dvb_frontend *fe, u8 *RegNum, u8 *RegVal,
3612 int *count)
3613{
3614 u16 status = 0;
3615 int i ;
3616
3617/* add 77, 166, 167, 168 register for 2.6.12 */
3618#ifdef _MXL_PRODUCTION
3619 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
3620 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3621#else
3622 u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
3623 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
3624 /*
3625 u8 RegAddr[171];
3626 for (i = 0; i <= 170; i++)
3627 RegAddr[i] = i;
3628 */
3629#endif
3630
3631 *count = sizeof(RegAddr) / sizeof(u8);
3632
3633 for (i = 0 ; i < *count; i++) {
3634 RegNum[i] = RegAddr[i];
3635 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3636 }
3637
3638 return status;
3639}
3640
3641static u16 MXL_GetCHRegister_ZeroIF(struct dvb_frontend *fe, u8 *RegNum,
3642 u8 *RegVal, int *count)
3643{
3644 u16 status = 0;
3645 int i;
3646
3647 u8 RegAddr[] = {43, 136};
3648
3649 *count = sizeof(RegAddr) / sizeof(u8);
3650
3651 for (i = 0; i < *count; i++) {
3652 RegNum[i] = RegAddr[i];
3653 status += MXL_RegRead(fe, RegNum[i], &RegVal[i]);
3654 }
3655
3656 return status;
3657}
3658
3659static u16 MXL_GetMasterControl(u8 *MasterReg, int state)
3660{
3661 if (state == 1) /* Load_Start */
3662 *MasterReg = 0xF3;
3663 if (state == 2) /* Power_Down */
3664 *MasterReg = 0x41;
3665 if (state == 3) /* Synth_Reset */
3666 *MasterReg = 0xB1;
3667 if (state == 4) /* Seq_Off */
3668 *MasterReg = 0xF1;
3669
3670 return 0;
3671}
3672
3673#ifdef _MXL_PRODUCTION
3674static u16 MXL_VCORange_Test(struct dvb_frontend *fe, int VCO_Range)
3675{
3676 struct mxl5005s_state *state = fe->tuner_priv;
3677 u16 status = 0 ;
3678
3679 if (VCO_Range == 1) {
3680 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3681 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3682 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3683 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3684 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3685 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3686 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3687 if (state->Mode == 0 && state->IF_Mode == 1) {
3688 /* Analog Low IF Mode */
3689 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3690 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3691 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3692 status += MXL_ControlWrite(fe,
3693 CHCAL_FRAC_MOD_RF, 180224);
3694 }
3695 if (state->Mode == 0 && state->IF_Mode == 0) {
3696 /* Analog Zero IF Mode */
3697 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3698 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3699 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3700 status += MXL_ControlWrite(fe,
3701 CHCAL_FRAC_MOD_RF, 222822);
3702 }
3703 if (state->Mode == 1) /* Digital Mode */ {
3704 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3705 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3706 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 56);
3707 status += MXL_ControlWrite(fe,
3708 CHCAL_FRAC_MOD_RF, 229376);
3709 }
3710 }
3711
3712 if (VCO_Range == 2) {
3713 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3714 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3715 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3716 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3717 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3718 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3719 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3720 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3721 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3722 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
3723 if (state->Mode == 0 && state->IF_Mode == 1) {
3724 /* Analog Low IF Mode */
3725 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3726 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3727 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3728 status += MXL_ControlWrite(fe,
3729 CHCAL_FRAC_MOD_RF, 206438);
3730 }
3731 if (state->Mode == 0 && state->IF_Mode == 0) {
3732 /* Analog Zero IF Mode */
3733 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3734 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3735 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3736 status += MXL_ControlWrite(fe,
3737 CHCAL_FRAC_MOD_RF, 206438);
3738 }
3739 if (state->Mode == 1) /* Digital Mode */ {
3740 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 1);
3741 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3742 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 41);
3743 status += MXL_ControlWrite(fe,
3744 CHCAL_FRAC_MOD_RF, 16384);
3745 }
3746 }
3747
3748 if (VCO_Range == 3) {
3749 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3750 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3751 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3752 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3753 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3754 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3755 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3756 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3757 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3758 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3759 if (state->Mode == 0 && state->IF_Mode == 1) {
3760 /* Analog Low IF Mode */
3761 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3762 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3763 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
3764 status += MXL_ControlWrite(fe,
3765 CHCAL_FRAC_MOD_RF, 173670);
3766 }
3767 if (state->Mode == 0 && state->IF_Mode == 0) {
3768 /* Analog Zero IF Mode */
3769 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3770 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3771 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 44);
3772 status += MXL_ControlWrite(fe,
3773 CHCAL_FRAC_MOD_RF, 173670);
3774 }
3775 if (state->Mode == 1) /* Digital Mode */ {
3776 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3777 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 8);
3778 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 42);
3779 status += MXL_ControlWrite(fe,
3780 CHCAL_FRAC_MOD_RF, 245760);
3781 }
3782 }
3783
3784 if (VCO_Range == 4) {
3785 status += MXL_ControlWrite(fe, RFSYN_EN_DIV, 1);
3786 status += MXL_ControlWrite(fe, RFSYN_EN_OUTMUX, 0);
3787 status += MXL_ControlWrite(fe, RFSYN_SEL_DIVM, 0);
3788 status += MXL_ControlWrite(fe, RFSYN_DIVM, 1);
3789 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_OUT, 1);
3790 status += MXL_ControlWrite(fe, RFSYN_RF_DIV_BIAS, 1);
3791 status += MXL_ControlWrite(fe, DN_SEL_FREQ, 0);
3792 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3793 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3794 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3795 if (state->Mode == 0 && state->IF_Mode == 1) {
3796 /* Analog Low IF Mode */
3797 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3798 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3799 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3800 status += MXL_ControlWrite(fe,
3801 CHCAL_FRAC_MOD_RF, 206438);
3802 }
3803 if (state->Mode == 0 && state->IF_Mode == 0) {
3804 /* Analog Zero IF Mode */
3805 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3806 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3807 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3808 status += MXL_ControlWrite(fe,
3809 CHCAL_FRAC_MOD_RF, 206438);
3810 }
3811 if (state->Mode == 1) /* Digital Mode */ {
3812 status += MXL_ControlWrite(fe, RFSYN_SEL_VCO_HI, 0);
3813 status += MXL_ControlWrite(fe, RFSYN_VCO_BIAS, 40);
3814 status += MXL_ControlWrite(fe, CHCAL_INT_MOD_RF, 27);
3815 status += MXL_ControlWrite(fe,
3816 CHCAL_FRAC_MOD_RF, 212992);
3817 }
3818 }
3819
3820 return status;
3821}
3822
3823static u16 MXL_Hystersis_Test(struct dvb_frontend *fe, int Hystersis)
3824{
3825 struct mxl5005s_state *state = fe->tuner_priv;
3826 u16 status = 0;
3827
3828 if (Hystersis == 1)
3829 status += MXL_ControlWrite(fe, DN_BYPASS_AGC_I2C, 1);
3830
3831 return status;
3832}
3833#endif
3834/* End: Reference driver code found in the Realtek driver that
3835 * is copyright MaxLinear */
3836
3837/* ----------------------------------------------------------------
3838 * Begin: Everything after here is new code to adapt the
3839 * proprietary Realtek driver into a Linux API tuner.
3840 * Copyright (C) 2008 Steven Toth <stoth@hauppauge.com>
3841 */
3842static int mxl5005s_reset(struct dvb_frontend *fe)
3843{
3844 struct mxl5005s_state *state = fe->tuner_priv;
3845 int ret = 0;
3846
3847 u8 buf[2] = { 0xff, 0x00 };
3848 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
3849 .buf = buf, .len = 2 };
3850
3851 dprintk(2, "%s()\n", __func__);
3852
3853 if (fe->ops.i2c_gate_ctrl)
3854 fe->ops.i2c_gate_ctrl(fe, 1);
3855
3856 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
3857 printk(KERN_WARNING "mxl5005s I2C reset failed\n");
3858 ret = -EREMOTEIO;
3859 }
3860
3861 if (fe->ops.i2c_gate_ctrl)
3862 fe->ops.i2c_gate_ctrl(fe, 0);
3863
3864 return ret;
3865}
3866
3867/* Write a single byte to a single reg, latch the value if required by
3868 * following the transaction with the latch byte.
3869 */
3870static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch)
3871{
3872 struct mxl5005s_state *state = fe->tuner_priv;
3873 u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE };
3874 struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
3875 .buf = buf, .len = 3 };
3876
3877 if (latch == 0)
3878 msg.len = 2;
3879
3880 dprintk(2, "%s(0x%x, 0x%x, 0x%x)\n", __func__, reg, val, msg.addr);
3881
3882 if (i2c_transfer(state->i2c, &msg, 1) != 1) {
3883 printk(KERN_WARNING "mxl5005s I2C write failed\n");
3884 return -EREMOTEIO;
3885 }
3886 return 0;
3887}
3888
3889static int mxl5005s_writeregs(struct dvb_frontend *fe, u8 *addrtable,
3890 u8 *datatable, u8 len)
3891{
3892 int ret = 0, i;
3893
3894 if (fe->ops.i2c_gate_ctrl)
3895 fe->ops.i2c_gate_ctrl(fe, 1);
3896
3897 for (i = 0 ; i < len-1; i++) {
3898 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 0);
3899 if (ret < 0)
3900 break;
3901 }
3902
3903 ret = mxl5005s_writereg(fe, addrtable[i], datatable[i], 1);
3904
3905 if (fe->ops.i2c_gate_ctrl)
3906 fe->ops.i2c_gate_ctrl(fe, 0);
3907
3908 return ret;
3909}
3910
3911static int mxl5005s_init(struct dvb_frontend *fe)
3912{
3913 dprintk(1, "%s()\n", __func__);
3914 return mxl5005s_reconfigure(fe, MXL_QAM, MXL5005S_BANDWIDTH_6MHZ);
3915}
3916
3917static int mxl5005s_reconfigure(struct dvb_frontend *fe, u32 mod_type,
3918 u32 bandwidth)
3919{
3920 struct mxl5005s_state *state = fe->tuner_priv;
3921
3922 u8 AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3923 u8 ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
3924 int TableLen;
3925
3926 dprintk(1, "%s(type=%d, bw=%d)\n", __func__, mod_type, bandwidth);
3927
3928 mxl5005s_reset(fe);
3929
3930 /* Tuner initialization stage 0 */
3931 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
3932 AddrTable[0] = MASTER_CONTROL_ADDR;
3933 ByteTable[0] |= state->config->AgcMasterByte;
3934
3935 mxl5005s_writeregs(fe, AddrTable, ByteTable, 1);
3936
3937 mxl5005s_AssignTunerMode(fe, mod_type, bandwidth);
3938
3939 /* Tuner initialization stage 1 */
3940 MXL_GetInitRegister(fe, AddrTable, ByteTable, &TableLen);
3941
3942 mxl5005s_writeregs(fe, AddrTable, ByteTable, TableLen);
3943
3944 return 0;
3945}
3946
3947static int mxl5005s_AssignTunerMode(struct dvb_frontend *fe, u32 mod_type,
3948 u32 bandwidth)
3949{
3950 struct mxl5005s_state *state = fe->tuner_priv;
3951 struct mxl5005s_config *c = state->config;
3952
3953 InitTunerControls(fe);
3954
3955 /* Set MxL5005S parameters. */
3956 MXL5005_TunerConfig(
3957 fe,
3958 c->mod_mode,
3959 c->if_mode,
3960 bandwidth,
3961 c->if_freq,
3962 c->xtal_freq,
3963 c->agc_mode,
3964 c->top,
3965 c->output_load,
3966 c->clock_out,
3967 c->div_out,
3968 c->cap_select,
3969 c->rssi_enable,
3970 mod_type,
3971 c->tracking_filter);
3972
3973 return 0;
3974}
3975
3976static int mxl5005s_set_params(struct dvb_frontend *fe,
3977 struct dvb_frontend_parameters *params)
3978{
3979 struct mxl5005s_state *state = fe->tuner_priv;
3980 u32 req_mode, req_bw = 0;
3981 int ret;
3982
3983 dprintk(1, "%s()\n", __func__);
3984
3985 if (fe->ops.info.type == FE_ATSC) {
3986 switch (params->u.vsb.modulation) {
3987 case VSB_8:
3988 req_mode = MXL_ATSC; break;
3989 default:
3990 case QAM_64:
3991 case QAM_256:
3992 case QAM_AUTO:
3993 req_mode = MXL_QAM; break;
3994 }
3995 } else
3996 req_mode = MXL_DVBT;
3997
3998 /* Change tuner for new modulation type if reqd */
3999 if (req_mode != state->current_mode) {
4000 switch (req_mode) {
4001 case VSB_8:
4002 case QAM_64:
4003 case QAM_256:
4004 case QAM_AUTO:
4005 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4006 break;
4007 default:
4008 /* Assume DVB-T */
4009 switch (params->u.ofdm.bandwidth) {
4010 case BANDWIDTH_6_MHZ:
4011 req_bw = MXL5005S_BANDWIDTH_6MHZ;
4012 break;
4013 case BANDWIDTH_7_MHZ:
4014 req_bw = MXL5005S_BANDWIDTH_7MHZ;
4015 break;
4016 case BANDWIDTH_AUTO:
4017 case BANDWIDTH_8_MHZ:
4018 req_bw = MXL5005S_BANDWIDTH_8MHZ;
4019 break;
4020 }
4021 }
4022
4023 state->current_mode = req_mode;
4024 ret = mxl5005s_reconfigure(fe, req_mode, req_bw);
4025
4026 } else
4027 ret = 0;
4028
4029 if (ret == 0) {
4030 dprintk(1, "%s() freq=%d\n", __func__, params->frequency);
4031 ret = mxl5005s_SetRfFreqHz(fe, params->frequency);
4032 }
4033
4034 return ret;
4035}
4036
4037static int mxl5005s_get_frequency(struct dvb_frontend *fe, u32 *frequency)
4038{
4039 struct mxl5005s_state *state = fe->tuner_priv;
4040 dprintk(1, "%s()\n", __func__);
4041
4042 *frequency = state->RF_IN;
4043
4044 return 0;
4045}
4046
4047static int mxl5005s_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
4048{
4049 struct mxl5005s_state *state = fe->tuner_priv;
4050 dprintk(1, "%s()\n", __func__);
4051
4052 *bandwidth = state->Chan_Bandwidth;
4053
4054 return 0;
4055}
4056
4057static int mxl5005s_release(struct dvb_frontend *fe)
4058{
4059 dprintk(1, "%s()\n", __func__);
4060 kfree(fe->tuner_priv);
4061 fe->tuner_priv = NULL;
4062 return 0;
4063}
4064
4065static const struct dvb_tuner_ops mxl5005s_tuner_ops = {
4066 .info = {
4067 .name = "MaxLinear MXL5005S",
4068 .frequency_min = 48000000,
4069 .frequency_max = 860000000,
4070 .frequency_step = 50000,
4071 },
4072
4073 .release = mxl5005s_release,
4074 .init = mxl5005s_init,
4075
4076 .set_params = mxl5005s_set_params,
4077 .get_frequency = mxl5005s_get_frequency,
4078 .get_bandwidth = mxl5005s_get_bandwidth,
4079};
4080
4081struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
4082 struct i2c_adapter *i2c,
4083 struct mxl5005s_config *config)
4084{
4085 struct mxl5005s_state *state = NULL;
4086 dprintk(1, "%s()\n", __func__);
4087
4088 state = kzalloc(sizeof(struct mxl5005s_state), GFP_KERNEL);
4089 if (state == NULL)
4090 return NULL;
4091
4092 state->frontend = fe;
4093 state->config = config;
4094 state->i2c = i2c;
4095 state->current_mode = MXL_QAM;
4096
4097 printk(KERN_INFO "MXL5005S: Attached at address 0x%02x\n",
4098 config->i2c_address);
4099
4100 memcpy(&fe->ops.tuner_ops, &mxl5005s_tuner_ops,
4101 sizeof(struct dvb_tuner_ops));
4102
4103 fe->tuner_priv = state;
4104 return fe;
4105}
4106EXPORT_SYMBOL(mxl5005s_attach);
4107
4108MODULE_DESCRIPTION("MaxLinear MXL5005S silicon tuner driver");
4109MODULE_AUTHOR("Steven Toth");
4110MODULE_LICENSE("GPL");
diff --git a/drivers/media/common/tuners/mxl5005s.h b/drivers/media/common/tuners/mxl5005s.h
new file mode 100644
index 000000000000..396db150bf0c
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.h
@@ -0,0 +1,131 @@
1/*
2 MaxLinear MXL5005S VSB/QAM/DVBT tuner driver
3
4 Copyright (C) 2008 MaxLinear
5 Copyright (C) 2008 Steven Toth <stoth@hauppauge.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 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21*/
22
23#ifndef __MXL5005S_H
24#define __MXL5005S_H
25
26#include <linux/i2c.h>
27#include "dvb_frontend.h"
28
29struct mxl5005s_config {
30
31 /* 7 bit i2c address */
32 u8 i2c_address;
33
34#define IF_FREQ_4570000HZ 4570000
35#define IF_FREQ_4571429HZ 4571429
36#define IF_FREQ_5380000HZ 5380000
37#define IF_FREQ_36000000HZ 36000000
38#define IF_FREQ_36125000HZ 36125000
39#define IF_FREQ_36166667HZ 36166667
40#define IF_FREQ_44000000HZ 44000000
41 u32 if_freq;
42
43#define CRYSTAL_FREQ_4000000HZ 4000000
44#define CRYSTAL_FREQ_16000000HZ 16000000
45#define CRYSTAL_FREQ_25000000HZ 25000000
46#define CRYSTAL_FREQ_28800000HZ 28800000
47 u32 xtal_freq;
48
49#define MXL_DUAL_AGC 0
50#define MXL_SINGLE_AGC 1
51 u8 agc_mode;
52
53#define MXL_TF_DEFAULT 0
54#define MXL_TF_OFF 1
55#define MXL_TF_C 2
56#define MXL_TF_C_H 3
57#define MXL_TF_D 4
58#define MXL_TF_D_L 5
59#define MXL_TF_E 6
60#define MXL_TF_F 7
61#define MXL_TF_E_2 8
62#define MXL_TF_E_NA 9
63#define MXL_TF_G 10
64 u8 tracking_filter;
65
66#define MXL_RSSI_DISABLE 0
67#define MXL_RSSI_ENABLE 1
68 u8 rssi_enable;
69
70#define MXL_CAP_SEL_DISABLE 0
71#define MXL_CAP_SEL_ENABLE 1
72 u8 cap_select;
73
74#define MXL_DIV_OUT_1 0
75#define MXL_DIV_OUT_4 1
76 u8 div_out;
77
78#define MXL_CLOCK_OUT_DISABLE 0
79#define MXL_CLOCK_OUT_ENABLE 1
80 u8 clock_out;
81
82#define MXL5005S_IF_OUTPUT_LOAD_200_OHM 200
83#define MXL5005S_IF_OUTPUT_LOAD_300_OHM 300
84 u32 output_load;
85
86#define MXL5005S_TOP_5P5 55
87#define MXL5005S_TOP_7P2 72
88#define MXL5005S_TOP_9P2 92
89#define MXL5005S_TOP_11P0 110
90#define MXL5005S_TOP_12P9 129
91#define MXL5005S_TOP_14P7 147
92#define MXL5005S_TOP_16P8 168
93#define MXL5005S_TOP_19P4 194
94#define MXL5005S_TOP_21P2 212
95#define MXL5005S_TOP_23P2 232
96#define MXL5005S_TOP_25P2 252
97#define MXL5005S_TOP_27P1 271
98#define MXL5005S_TOP_29P2 292
99#define MXL5005S_TOP_31P7 317
100#define MXL5005S_TOP_34P9 349
101 u32 top;
102
103#define MXL_ANALOG_MODE 0
104#define MXL_DIGITAL_MODE 1
105 u8 mod_mode;
106
107#define MXL_ZERO_IF 0
108#define MXL_LOW_IF 1
109 u8 if_mode;
110
111 /* Stuff I don't know what to do with */
112 u8 AgcMasterByte;
113};
114
115#if defined(CONFIG_MEDIA_TUNER_MXL5005S) || \
116 (defined(CONFIG_MEDIA_TUNER_MXL5005S_MODULE) && defined(MODULE))
117extern struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
118 struct i2c_adapter *i2c,
119 struct mxl5005s_config *config);
120#else
121static inline struct dvb_frontend *mxl5005s_attach(struct dvb_frontend *fe,
122 struct i2c_adapter *i2c,
123 struct mxl5005s_config *config)
124{
125 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
126 return NULL;
127}
128#endif /* CONFIG_DVB_TUNER_MXL5005S */
129
130#endif /* __MXL5005S_H */
131
diff --git a/drivers/media/common/tuners/tda18271-common.c b/drivers/media/common/tuners/tda18271-common.c
index e27a7620a32f..42b5f5d4bfe6 100644
--- a/drivers/media/common/tuners/tda18271-common.c
+++ b/drivers/media/common/tuners/tda18271-common.c
@@ -227,9 +227,8 @@ int tda18271_charge_pump_source(struct dvb_frontend *fe,
227 227
228 regs[r_cp] &= ~0x20; 228 regs[r_cp] &= ~0x20;
229 regs[r_cp] |= ((force & 1) << 5); 229 regs[r_cp] |= ((force & 1) << 5);
230 tda18271_write_regs(fe, r_cp, 1);
231 230
232 return 0; 231 return tda18271_write_regs(fe, r_cp, 1);
233} 232}
234 233
235int tda18271_init_regs(struct dvb_frontend *fe) 234int tda18271_init_regs(struct dvb_frontend *fe)
@@ -487,16 +486,15 @@ int tda18271_set_standby_mode(struct dvb_frontend *fe,
487 struct tda18271_priv *priv = fe->tuner_priv; 486 struct tda18271_priv *priv = fe->tuner_priv;
488 unsigned char *regs = priv->tda18271_regs; 487 unsigned char *regs = priv->tda18271_regs;
489 488
490 tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt); 489 if (tda18271_debug & DBG_ADV)
490 tda_dbg("sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt);
491 491
492 regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */ 492 regs[R_EP3] &= ~0xe0; /* clear sm, sm_lt, sm_xt */
493 regs[R_EP3] |= sm ? (1 << 7) : 0 | 493 regs[R_EP3] |= sm ? (1 << 7) : 0 |
494 sm_lt ? (1 << 6) : 0 | 494 sm_lt ? (1 << 6) : 0 |
495 sm_xt ? (1 << 5) : 0; 495 sm_xt ? (1 << 5) : 0;
496 496
497 tda18271_write_regs(fe, R_EP3, 1); 497 return tda18271_write_regs(fe, R_EP3, 1);
498
499 return 0;
500} 498}
501 499
502/*---------------------------------------------------------------------*/ 500/*---------------------------------------------------------------------*/
@@ -510,7 +508,7 @@ int tda18271_calc_main_pll(struct dvb_frontend *fe, u32 freq)
510 u32 div; 508 u32 div;
511 509
512 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d); 510 int ret = tda18271_lookup_pll_map(fe, MAIN_PLL, &freq, &pd, &d);
513 if (ret < 0) 511 if (tda_fail(ret))
514 goto fail; 512 goto fail;
515 513
516 regs[R_MPD] = (0x77 & pd); 514 regs[R_MPD] = (0x77 & pd);
@@ -542,7 +540,7 @@ int tda18271_calc_cal_pll(struct dvb_frontend *fe, u32 freq)
542 u32 div; 540 u32 div;
543 541
544 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d); 542 int ret = tda18271_lookup_pll_map(fe, CAL_PLL, &freq, &pd, &d);
545 if (ret < 0) 543 if (tda_fail(ret))
546 goto fail; 544 goto fail;
547 545
548 regs[R_CPD] = pd; 546 regs[R_CPD] = pd;
@@ -566,7 +564,7 @@ int tda18271_calc_bp_filter(struct dvb_frontend *fe, u32 *freq)
566 u8 val; 564 u8 val;
567 565
568 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val); 566 int ret = tda18271_lookup_map(fe, BP_FILTER, freq, &val);
569 if (ret < 0) 567 if (tda_fail(ret))
570 goto fail; 568 goto fail;
571 569
572 regs[R_EP1] &= ~0x07; /* clear bp filter bits */ 570 regs[R_EP1] &= ~0x07; /* clear bp filter bits */
@@ -583,7 +581,7 @@ int tda18271_calc_km(struct dvb_frontend *fe, u32 *freq)
583 u8 val; 581 u8 val;
584 582
585 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val); 583 int ret = tda18271_lookup_map(fe, RF_CAL_KMCO, freq, &val);
586 if (ret < 0) 584 if (tda_fail(ret))
587 goto fail; 585 goto fail;
588 586
589 regs[R_EB13] &= ~0x7c; /* clear k & m bits */ 587 regs[R_EB13] &= ~0x7c; /* clear k & m bits */
@@ -600,7 +598,7 @@ int tda18271_calc_rf_band(struct dvb_frontend *fe, u32 *freq)
600 u8 val; 598 u8 val;
601 599
602 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val); 600 int ret = tda18271_lookup_map(fe, RF_BAND, freq, &val);
603 if (ret < 0) 601 if (tda_fail(ret))
604 goto fail; 602 goto fail;
605 603
606 regs[R_EP2] &= ~0xe0; /* clear rf band bits */ 604 regs[R_EP2] &= ~0xe0; /* clear rf band bits */
@@ -617,7 +615,7 @@ int tda18271_calc_gain_taper(struct dvb_frontend *fe, u32 *freq)
617 u8 val; 615 u8 val;
618 616
619 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val); 617 int ret = tda18271_lookup_map(fe, GAIN_TAPER, freq, &val);
620 if (ret < 0) 618 if (tda_fail(ret))
621 goto fail; 619 goto fail;
622 620
623 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */ 621 regs[R_EP2] &= ~0x1f; /* clear gain taper bits */
@@ -634,7 +632,7 @@ int tda18271_calc_ir_measure(struct dvb_frontend *fe, u32 *freq)
634 u8 val; 632 u8 val;
635 633
636 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val); 634 int ret = tda18271_lookup_map(fe, IR_MEASURE, freq, &val);
637 if (ret < 0) 635 if (tda_fail(ret))
638 goto fail; 636 goto fail;
639 637
640 regs[R_EP5] &= ~0x07; 638 regs[R_EP5] &= ~0x07;
diff --git a/drivers/media/common/tuners/tda18271-fe.c b/drivers/media/common/tuners/tda18271-fe.c
index b262100ae897..89c01fb1f859 100644
--- a/drivers/media/common/tuners/tda18271-fe.c
+++ b/drivers/media/common/tuners/tda18271-fe.c
@@ -51,6 +51,7 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
51{ 51{
52 struct tda18271_priv *priv = fe->tuner_priv; 52 struct tda18271_priv *priv = fe->tuner_priv;
53 unsigned char *regs = priv->tda18271_regs; 53 unsigned char *regs = priv->tda18271_regs;
54 int ret;
54 u32 N; 55 u32 N;
55 56
56 /* update TV broadcast parameters */ 57 /* update TV broadcast parameters */
@@ -85,7 +86,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
85 /* update rf top / if top */ 86 /* update rf top / if top */
86 regs[R_EB22] = 0x00; 87 regs[R_EB22] = 0x00;
87 regs[R_EB22] |= map->rfagc_top; 88 regs[R_EB22] |= map->rfagc_top;
88 tda18271_write_regs(fe, R_EB22, 1); 89 ret = tda18271_write_regs(fe, R_EB22, 1);
90 if (tda_fail(ret))
91 goto fail;
89 92
90 /* --------------------------------------------------------------- */ 93 /* --------------------------------------------------------------- */
91 94
@@ -121,7 +124,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
121 /* agc1 has priority on agc2 */ 124 /* agc1 has priority on agc2 */
122 regs[R_EB1] &= ~0x01; 125 regs[R_EB1] &= ~0x01;
123 126
124 tda18271_write_regs(fe, R_EB1, 1); 127 ret = tda18271_write_regs(fe, R_EB1, 1);
128 if (tda_fail(ret))
129 goto fail;
125 130
126 /* --------------------------------------------------------------- */ 131 /* --------------------------------------------------------------- */
127 132
@@ -141,7 +146,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
141 break; 146 break;
142 } 147 }
143 148
144 tda18271_write_regs(fe, R_TM, 7); 149 ret = tda18271_write_regs(fe, R_TM, 7);
150 if (tda_fail(ret))
151 goto fail;
145 152
146 /* force charge pump source */ 153 /* force charge pump source */
147 charge_pump_source(fe, 1); 154 charge_pump_source(fe, 1);
@@ -158,9 +165,9 @@ static int tda18271_channel_configuration(struct dvb_frontend *fe,
158 regs[R_EP3] &= ~0x04; 165 regs[R_EP3] &= ~0x04;
159 else 166 else
160 regs[R_EP3] |= 0x04; 167 regs[R_EP3] |= 0x04;
161 tda18271_write_regs(fe, R_EP3, 1); 168 ret = tda18271_write_regs(fe, R_EP3, 1);
162 169fail:
163 return 0; 170 return ret;
164} 171}
165 172
166static int tda18271_read_thermometer(struct dvb_frontend *fe) 173static int tda18271_read_thermometer(struct dvb_frontend *fe)
@@ -213,11 +220,13 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
213 struct tda18271_priv *priv = fe->tuner_priv; 220 struct tda18271_priv *priv = fe->tuner_priv;
214 struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state; 221 struct tda18271_rf_tracking_filter_cal *map = priv->rf_cal_state;
215 unsigned char *regs = priv->tda18271_regs; 222 unsigned char *regs = priv->tda18271_regs;
216 int tm_current, rfcal_comp, approx, i; 223 int tm_current, rfcal_comp, approx, i, ret;
217 u8 dc_over_dt, rf_tab; 224 u8 dc_over_dt, rf_tab;
218 225
219 /* power up */ 226 /* power up */
220 tda18271_set_standby_mode(fe, 0, 0, 0); 227 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
228 if (tda_fail(ret))
229 goto fail;
221 230
222 /* read die current temperature */ 231 /* read die current temperature */
223 tm_current = tda18271_read_thermometer(fe); 232 tm_current = tda18271_read_thermometer(fe);
@@ -228,8 +237,8 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
228 rf_tab = regs[R_EB14]; 237 rf_tab = regs[R_EB14];
229 238
230 i = tda18271_lookup_rf_band(fe, &freq, NULL); 239 i = tda18271_lookup_rf_band(fe, &freq, NULL);
231 if (i < 0) 240 if (tda_fail(i))
232 return -EINVAL; 241 return i;
233 242
234 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) { 243 if ((0 == map[i].rf3) || (freq / 1000 < map[i].rf2)) {
235 approx = map[i].rf_a1 * 244 approx = map[i].rf_a1 *
@@ -250,35 +259,42 @@ static int tda18271c2_rf_tracking_filters_correction(struct dvb_frontend *fe,
250 rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal); 259 rfcal_comp = dc_over_dt * (tm_current - priv->tm_rfcal);
251 260
252 regs[R_EB14] = approx + rfcal_comp; 261 regs[R_EB14] = approx + rfcal_comp;
253 tda18271_write_regs(fe, R_EB14, 1); 262 ret = tda18271_write_regs(fe, R_EB14, 1);
254 263fail:
255 return 0; 264 return ret;
256} 265}
257 266
258static int tda18271_por(struct dvb_frontend *fe) 267static int tda18271_por(struct dvb_frontend *fe)
259{ 268{
260 struct tda18271_priv *priv = fe->tuner_priv; 269 struct tda18271_priv *priv = fe->tuner_priv;
261 unsigned char *regs = priv->tda18271_regs; 270 unsigned char *regs = priv->tda18271_regs;
271 int ret;
262 272
263 /* power up detector 1 */ 273 /* power up detector 1 */
264 regs[R_EB12] &= ~0x20; 274 regs[R_EB12] &= ~0x20;
265 tda18271_write_regs(fe, R_EB12, 1); 275 ret = tda18271_write_regs(fe, R_EB12, 1);
276 if (tda_fail(ret))
277 goto fail;
266 278
267 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */ 279 regs[R_EB18] &= ~0x80; /* turn agc1 loop on */
268 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 280 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
269 tda18271_write_regs(fe, R_EB18, 1); 281 ret = tda18271_write_regs(fe, R_EB18, 1);
282 if (tda_fail(ret))
283 goto fail;
270 284
271 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */ 285 regs[R_EB21] |= 0x03; /* set agc2_gain to -6 dB */
272 286
273 /* POR mode */ 287 /* POR mode */
274 tda18271_set_standby_mode(fe, 1, 0, 0); 288 ret = tda18271_set_standby_mode(fe, 1, 0, 0);
289 if (tda_fail(ret))
290 goto fail;
275 291
276 /* disable 1.5 MHz low pass filter */ 292 /* disable 1.5 MHz low pass filter */
277 regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */ 293 regs[R_EB23] &= ~0x04; /* forcelp_fc2_en = 0 */
278 regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */ 294 regs[R_EB23] &= ~0x02; /* XXX: lp_fc[2] = 0 */
279 tda18271_write_regs(fe, R_EB21, 3); 295 ret = tda18271_write_regs(fe, R_EB21, 3);
280 296fail:
281 return 0; 297 return ret;
282} 298}
283 299
284static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq) 300static int tda18271_calibrate_rf(struct dvb_frontend *fe, u32 freq)
@@ -389,7 +405,7 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
389{ 405{
390 struct tda18271_priv *priv = fe->tuner_priv; 406 struct tda18271_priv *priv = fe->tuner_priv;
391 unsigned char *regs = priv->tda18271_regs; 407 unsigned char *regs = priv->tda18271_regs;
392 int sgn, bcal, count, wait; 408 int sgn, bcal, count, wait, ret;
393 u8 cid_target; 409 u8 cid_target;
394 u16 count_limit; 410 u16 count_limit;
395 u32 freq; 411 u32 freq;
@@ -421,7 +437,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
421 tda18271_write_regs(fe, R_EP2, 1); 437 tda18271_write_regs(fe, R_EP2, 1);
422 438
423 /* read power detection info, stored in EB10 */ 439 /* read power detection info, stored in EB10 */
424 tda18271_read_extended(fe); 440 ret = tda18271_read_extended(fe);
441 if (tda_fail(ret))
442 return ret;
425 443
426 /* algorithm initialization */ 444 /* algorithm initialization */
427 sgn = 1; 445 sgn = 1;
@@ -447,7 +465,9 @@ static int tda18271_powerscan(struct dvb_frontend *fe,
447 tda18271_write_regs(fe, R_EP2, 1); 465 tda18271_write_regs(fe, R_EP2, 1);
448 466
449 /* read power detection info, stored in EB10 */ 467 /* read power detection info, stored in EB10 */
450 tda18271_read_extended(fe); 468 ret = tda18271_read_extended(fe);
469 if (tda_fail(ret))
470 return ret;
451 471
452 count += 200; 472 count += 200;
453 473
@@ -478,6 +498,7 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
478{ 498{
479 struct tda18271_priv *priv = fe->tuner_priv; 499 struct tda18271_priv *priv = fe->tuner_priv;
480 unsigned char *regs = priv->tda18271_regs; 500 unsigned char *regs = priv->tda18271_regs;
501 int ret;
481 502
482 /* set standard to digital */ 503 /* set standard to digital */
483 regs[R_EP3] &= ~0x1f; /* clear std bits */ 504 regs[R_EP3] &= ~0x1f; /* clear std bits */
@@ -489,10 +510,14 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
489 /* update IF output level & IF notch frequency */ 510 /* update IF output level & IF notch frequency */
490 regs[R_EP4] &= ~0x1c; /* clear if level bits */ 511 regs[R_EP4] &= ~0x1c; /* clear if level bits */
491 512
492 tda18271_write_regs(fe, R_EP3, 2); 513 ret = tda18271_write_regs(fe, R_EP3, 2);
514 if (tda_fail(ret))
515 goto fail;
493 516
494 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */ 517 regs[R_EB18] &= ~0x03; /* set agc1_gain to 6 dB */
495 tda18271_write_regs(fe, R_EB18, 1); 518 ret = tda18271_write_regs(fe, R_EB18, 1);
519 if (tda_fail(ret))
520 goto fail;
496 521
497 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */ 522 regs[R_EB21] &= ~0x03; /* set agc2_gain to -15 dB */
498 523
@@ -500,9 +525,9 @@ static int tda18271_powerscan_init(struct dvb_frontend *fe)
500 regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */ 525 regs[R_EB23] |= 0x04; /* forcelp_fc2_en = 1 */
501 regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */ 526 regs[R_EB23] |= 0x02; /* lp_fc[2] = 1 */
502 527
503 tda18271_write_regs(fe, R_EB21, 3); 528 ret = tda18271_write_regs(fe, R_EB21, 3);
504 529fail:
505 return 0; 530 return ret;
506} 531}
507 532
508static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq) 533static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
@@ -521,7 +546,7 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
521 546
522 i = tda18271_lookup_rf_band(fe, &freq, NULL); 547 i = tda18271_lookup_rf_band(fe, &freq, NULL);
523 548
524 if (i < 0) 549 if (tda_fail(i))
525 return i; 550 return i;
526 551
527 rf_default[RF1] = 1000 * map[i].rf1_def; 552 rf_default[RF1] = 1000 * map[i].rf1_def;
@@ -535,6 +560,8 @@ static int tda18271_rf_tracking_filters_init(struct dvb_frontend *fe, u32 freq)
535 560
536 /* look for optimized calibration frequency */ 561 /* look for optimized calibration frequency */
537 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]); 562 bcal = tda18271_powerscan(fe, &rf_default[rf], &rf_freq[rf]);
563 if (tda_fail(bcal))
564 return bcal;
538 565
539 tda18271_calc_rf_cal(fe, &rf_freq[rf]); 566 tda18271_calc_rf_cal(fe, &rf_freq[rf]);
540 prog_tab[rf] = regs[R_EB14]; 567 prog_tab[rf] = regs[R_EB14];
@@ -575,22 +602,29 @@ static int tda18271_calc_rf_filter_curve(struct dvb_frontend *fe)
575{ 602{
576 struct tda18271_priv *priv = fe->tuner_priv; 603 struct tda18271_priv *priv = fe->tuner_priv;
577 unsigned int i; 604 unsigned int i;
605 int ret;
578 606
579 tda_info("tda18271: performing RF tracking filter calibration\n"); 607 tda_info("tda18271: performing RF tracking filter calibration\n");
580 608
581 /* wait for die temperature stabilization */ 609 /* wait for die temperature stabilization */
582 msleep(200); 610 msleep(200);
583 611
584 tda18271_powerscan_init(fe); 612 ret = tda18271_powerscan_init(fe);
613 if (tda_fail(ret))
614 goto fail;
585 615
586 /* rf band calibration */ 616 /* rf band calibration */
587 for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) 617 for (i = 0; priv->rf_cal_state[i].rfmax != 0; i++) {
618 ret =
588 tda18271_rf_tracking_filters_init(fe, 1000 * 619 tda18271_rf_tracking_filters_init(fe, 1000 *
589 priv->rf_cal_state[i].rfmax); 620 priv->rf_cal_state[i].rfmax);
621 if (tda_fail(ret))
622 goto fail;
623 }
590 624
591 priv->tm_rfcal = tda18271_read_thermometer(fe); 625 priv->tm_rfcal = tda18271_read_thermometer(fe);
592 626fail:
593 return 0; 627 return ret;
594} 628}
595 629
596/* ------------------------------------------------------------------ */ 630/* ------------------------------------------------------------------ */
@@ -599,6 +633,7 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
599{ 633{
600 struct tda18271_priv *priv = fe->tuner_priv; 634 struct tda18271_priv *priv = fe->tuner_priv;
601 unsigned char *regs = priv->tda18271_regs; 635 unsigned char *regs = priv->tda18271_regs;
636 int ret;
602 637
603 /* test RF_CAL_OK to see if we need init */ 638 /* test RF_CAL_OK to see if we need init */
604 if ((regs[R_EP1] & 0x10) == 0) 639 if ((regs[R_EP1] & 0x10) == 0)
@@ -607,15 +642,22 @@ static int tda18271c2_rf_cal_init(struct dvb_frontend *fe)
607 if (priv->cal_initialized) 642 if (priv->cal_initialized)
608 return 0; 643 return 0;
609 644
610 tda18271_calc_rf_filter_curve(fe); 645 ret = tda18271_calc_rf_filter_curve(fe);
646 if (tda_fail(ret))
647 goto fail;
611 648
612 tda18271_por(fe); 649 ret = tda18271_por(fe);
650 if (tda_fail(ret))
651 goto fail;
613 652
614 tda_info("tda18271: RF tracking filter calibration complete\n"); 653 tda_info("tda18271: RF tracking filter calibration complete\n");
615 654
616 priv->cal_initialized = true; 655 priv->cal_initialized = true;
617 656 goto end;
618 return 0; 657fail:
658 tda_info("tda18271: RF tracking filter calibration failed!\n");
659end:
660 return ret;
619} 661}
620 662
621static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe, 663static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
@@ -623,6 +665,7 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
623{ 665{
624 struct tda18271_priv *priv = fe->tuner_priv; 666 struct tda18271_priv *priv = fe->tuner_priv;
625 unsigned char *regs = priv->tda18271_regs; 667 unsigned char *regs = priv->tda18271_regs;
668 int ret;
626 u32 N = 0; 669 u32 N = 0;
627 670
628 /* calculate bp filter */ 671 /* calculate bp filter */
@@ -671,7 +714,10 @@ static int tda18271c1_rf_tracking_filter_calibration(struct dvb_frontend *fe,
671 714
672 tda18271_calc_main_pll(fe, N); 715 tda18271_calc_main_pll(fe, N);
673 716
674 tda18271_write_regs(fe, R_EP3, 11); 717 ret = tda18271_write_regs(fe, R_EP3, 11);
718 if (tda_fail(ret))
719 return ret;
720
675 msleep(5); /* RF tracking filter calibration initialization */ 721 msleep(5); /* RF tracking filter calibration initialization */
676 722
677 /* search for K,M,CO for RF calibration */ 723 /* search for K,M,CO for RF calibration */
@@ -719,45 +765,56 @@ static int tda18271_ir_cal_init(struct dvb_frontend *fe)
719{ 765{
720 struct tda18271_priv *priv = fe->tuner_priv; 766 struct tda18271_priv *priv = fe->tuner_priv;
721 unsigned char *regs = priv->tda18271_regs; 767 unsigned char *regs = priv->tda18271_regs;
768 int ret;
722 769
723 tda18271_read_regs(fe); 770 ret = tda18271_read_regs(fe);
771 if (tda_fail(ret))
772 goto fail;
724 773
725 /* test IR_CAL_OK to see if we need init */ 774 /* test IR_CAL_OK to see if we need init */
726 if ((regs[R_EP1] & 0x08) == 0) 775 if ((regs[R_EP1] & 0x08) == 0)
727 tda18271_init_regs(fe); 776 ret = tda18271_init_regs(fe);
728 777fail:
729 return 0; 778 return ret;
730} 779}
731 780
732static int tda18271_init(struct dvb_frontend *fe) 781static int tda18271_init(struct dvb_frontend *fe)
733{ 782{
734 struct tda18271_priv *priv = fe->tuner_priv; 783 struct tda18271_priv *priv = fe->tuner_priv;
784 int ret;
735 785
736 mutex_lock(&priv->lock); 786 mutex_lock(&priv->lock);
737 787
738 /* power up */ 788 /* power up */
739 tda18271_set_standby_mode(fe, 0, 0, 0); 789 ret = tda18271_set_standby_mode(fe, 0, 0, 0);
790 if (tda_fail(ret))
791 goto fail;
740 792
741 /* initialization */ 793 /* initialization */
742 tda18271_ir_cal_init(fe); 794 ret = tda18271_ir_cal_init(fe);
795 if (tda_fail(ret))
796 goto fail;
743 797
744 if (priv->id == TDA18271HDC2) 798 if (priv->id == TDA18271HDC2)
745 tda18271c2_rf_cal_init(fe); 799 tda18271c2_rf_cal_init(fe);
746 800fail:
747 mutex_unlock(&priv->lock); 801 mutex_unlock(&priv->lock);
748 802
749 return 0; 803 return ret;
750} 804}
751 805
752static int tda18271_tune(struct dvb_frontend *fe, 806static int tda18271_tune(struct dvb_frontend *fe,
753 struct tda18271_std_map_item *map, u32 freq, u32 bw) 807 struct tda18271_std_map_item *map, u32 freq, u32 bw)
754{ 808{
755 struct tda18271_priv *priv = fe->tuner_priv; 809 struct tda18271_priv *priv = fe->tuner_priv;
810 int ret;
756 811
757 tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n", 812 tda_dbg("freq = %d, ifc = %d, bw = %d, agc_mode = %d, std = %d\n",
758 freq, map->if_freq, bw, map->agc_mode, map->std); 813 freq, map->if_freq, bw, map->agc_mode, map->std);
759 814
760 tda18271_init(fe); 815 ret = tda18271_init(fe);
816 if (tda_fail(ret))
817 goto fail;
761 818
762 mutex_lock(&priv->lock); 819 mutex_lock(&priv->lock);
763 820
@@ -769,11 +826,11 @@ static int tda18271_tune(struct dvb_frontend *fe,
769 tda18271c2_rf_tracking_filters_correction(fe, freq); 826 tda18271c2_rf_tracking_filters_correction(fe, freq);
770 break; 827 break;
771 } 828 }
772 tda18271_channel_configuration(fe, map, freq, bw); 829 ret = tda18271_channel_configuration(fe, map, freq, bw);
773 830
774 mutex_unlock(&priv->lock); 831 mutex_unlock(&priv->lock);
775 832fail:
776 return 0; 833 return ret;
777} 834}
778 835
779/* ------------------------------------------------------------------ */ 836/* ------------------------------------------------------------------ */
@@ -837,7 +894,7 @@ static int tda18271_set_params(struct dvb_frontend *fe,
837 894
838 ret = tda18271_tune(fe, map, freq, bw); 895 ret = tda18271_tune(fe, map, freq, bw);
839 896
840 if (ret < 0) 897 if (tda_fail(ret))
841 goto fail; 898 goto fail;
842 899
843 priv->frequency = freq; 900 priv->frequency = freq;
@@ -893,7 +950,7 @@ static int tda18271_set_analog_params(struct dvb_frontend *fe,
893 950
894 ret = tda18271_tune(fe, map, freq, 0); 951 ret = tda18271_tune(fe, map, freq, 0);
895 952
896 if (ret < 0) 953 if (tda_fail(ret))
897 goto fail; 954 goto fail;
898 955
899 priv->frequency = freq; 956 priv->frequency = freq;
@@ -905,16 +962,17 @@ fail:
905static int tda18271_sleep(struct dvb_frontend *fe) 962static int tda18271_sleep(struct dvb_frontend *fe)
906{ 963{
907 struct tda18271_priv *priv = fe->tuner_priv; 964 struct tda18271_priv *priv = fe->tuner_priv;
965 int ret;
908 966
909 mutex_lock(&priv->lock); 967 mutex_lock(&priv->lock);
910 968
911 /* standby mode w/ slave tuner output 969 /* standby mode w/ slave tuner output
912 * & loop thru & xtal oscillator on */ 970 * & loop thru & xtal oscillator on */
913 tda18271_set_standby_mode(fe, 1, 0, 0); 971 ret = tda18271_set_standby_mode(fe, 1, 0, 0);
914 972
915 mutex_unlock(&priv->lock); 973 mutex_unlock(&priv->lock);
916 974
917 return 0; 975 return ret;
918} 976}
919 977
920static int tda18271_release(struct dvb_frontend *fe) 978static int tda18271_release(struct dvb_frontend *fe)
@@ -1095,10 +1153,10 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
1095 if (cfg) 1153 if (cfg)
1096 priv->small_i2c = cfg->small_i2c; 1154 priv->small_i2c = cfg->small_i2c;
1097 1155
1098 if (tda18271_get_id(fe) < 0) 1156 if (tda_fail(tda18271_get_id(fe)))
1099 goto fail; 1157 goto fail;
1100 1158
1101 if (tda18271_assign_map_layout(fe) < 0) 1159 if (tda_fail(tda18271_assign_map_layout(fe)))
1102 goto fail; 1160 goto fail;
1103 1161
1104 mutex_lock(&priv->lock); 1162 mutex_lock(&priv->lock);
diff --git a/drivers/media/common/tuners/tda18271-priv.h b/drivers/media/common/tuners/tda18271-priv.h
index 2bc5eb368ea2..81a739365f8c 100644
--- a/drivers/media/common/tuners/tda18271-priv.h
+++ b/drivers/media/common/tuners/tda18271-priv.h
@@ -153,6 +153,15 @@ extern int tda18271_debug;
153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg) 153#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg)
154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg) 154#define tda_cal(fmt, arg...) dprintk(KERN_DEBUG, DBG_CAL, fmt, ##arg)
155 155
156#define tda_fail(ret) \
157({ \
158 int __ret; \
159 __ret = (ret < 0); \
160 if (__ret) \
161 tda_printk(KERN_ERR, "error %d on line %d\n", ret, __LINE__);\
162 __ret; \
163})
164
156/*---------------------------------------------------------------------*/ 165/*---------------------------------------------------------------------*/
157 166
158enum tda18271_map_type { 167enum tda18271_map_type {
diff --git a/drivers/media/common/tuners/tea5767.c b/drivers/media/common/tuners/tea5767.c
index f6e7d7ad8424..1f5646334a8f 100644
--- a/drivers/media/common/tuners/tea5767.c
+++ b/drivers/media/common/tuners/tea5767.c
@@ -373,14 +373,14 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
373 373
374 if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) { 374 if ((rc = tuner_i2c_xfer_recv(&i2c, buffer, 7))< 5) {
375 printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc); 375 printk(KERN_WARNING "It is not a TEA5767. Received %i bytes.\n", rc);
376 return EINVAL; 376 return -EINVAL;
377 } 377 }
378 378
379 /* If all bytes are the same then it's a TV tuner and not a tea5767 */ 379 /* If all bytes are the same then it's a TV tuner and not a tea5767 */
380 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] && 380 if (buffer[0] == buffer[1] && buffer[0] == buffer[2] &&
381 buffer[0] == buffer[3] && buffer[0] == buffer[4]) { 381 buffer[0] == buffer[3] && buffer[0] == buffer[4]) {
382 printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n"); 382 printk(KERN_WARNING "All bytes are equal. It is not a TEA5767\n");
383 return EINVAL; 383 return -EINVAL;
384 } 384 }
385 385
386 /* Status bytes: 386 /* Status bytes:
@@ -390,7 +390,7 @@ int tea5767_autodetection(struct i2c_adapter* i2c_adap, u8 i2c_addr)
390 */ 390 */
391 if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) { 391 if (((buffer[3] & 0x0f) != 0x00) || (buffer[4] != 0x00)) {
392 printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n"); 392 printk(KERN_WARNING "Chip ID is not zero. It is not a TEA5767\n");
393 return EINVAL; 393 return -EINVAL;
394 } 394 }
395 395
396 396
diff --git a/drivers/media/common/tuners/xc5000.c b/drivers/media/common/tuners/xc5000.c
index 43d35bdb221f..ceae6db901ec 100644
--- a/drivers/media/common/tuners/xc5000.c
+++ b/drivers/media/common/tuners/xc5000.c
@@ -212,7 +212,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
212 dprintk(1, "%s()\n", __func__); 212 dprintk(1, "%s()\n", __func__);
213 213
214 if (priv->cfg->tuner_callback) { 214 if (priv->cfg->tuner_callback) {
215 ret = priv->cfg->tuner_callback(priv->cfg->priv, 215 ret = priv->cfg->tuner_callback(priv->devptr,
216 XC5000_TUNER_RESET, 0); 216 XC5000_TUNER_RESET, 0);
217 if (ret) 217 if (ret)
218 printk(KERN_ERR "xc5000: reset failed\n"); 218 printk(KERN_ERR "xc5000: reset failed\n");
@@ -900,9 +900,9 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
900 .get_status = xc5000_get_status 900 .get_status = xc5000_get_status
901}; 901};
902 902
903struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, 903struct dvb_frontend *xc5000_attach(struct dvb_frontend *fe,
904 struct i2c_adapter *i2c, 904 struct i2c_adapter *i2c,
905 struct xc5000_config *cfg) 905 struct xc5000_config *cfg, void *devptr)
906{ 906{
907 struct xc5000_priv *priv = NULL; 907 struct xc5000_priv *priv = NULL;
908 u16 id = 0; 908 u16 id = 0;
@@ -916,6 +916,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe,
916 priv->cfg = cfg; 916 priv->cfg = cfg;
917 priv->bandwidth = BANDWIDTH_6_MHZ; 917 priv->bandwidth = BANDWIDTH_6_MHZ;
918 priv->i2c = i2c; 918 priv->i2c = i2c;
919 priv->devptr = devptr;
919 920
920 /* Check if firmware has been loaded. It is possible that another 921 /* Check if firmware has been loaded. It is possible that another
921 instance of the driver has loaded the firmware. 922 instance of the driver has loaded the firmware.
diff --git a/drivers/media/common/tuners/xc5000.h b/drivers/media/common/tuners/xc5000.h
index 0ee80f9d19b8..c910715addc9 100644
--- a/drivers/media/common/tuners/xc5000.h
+++ b/drivers/media/common/tuners/xc5000.h
@@ -31,29 +31,31 @@ struct xc5000_config {
31 u8 i2c_address; 31 u8 i2c_address;
32 u32 if_khz; 32 u32 if_khz;
33 33
34 /* For each bridge framework, when it attaches either analog or digital,
35 * it has to store a reference back to its _core equivalent structure,
36 * so that it can service the hardware by steering gpio's etc.
37 * Each bridge implementation is different so cast priv accordingly.
38 * The xc5000 driver cares not for this value, other than ensuring
39 * it's passed back to a bridge during tuner_callback().
40 */
41 void *priv;
42 int (*tuner_callback) (void *priv, int command, int arg); 34 int (*tuner_callback) (void *priv, int command, int arg);
43}; 35};
44 36
45/* xc5000 callback command */ 37/* xc5000 callback command */
46#define XC5000_TUNER_RESET 0 38#define XC5000_TUNER_RESET 0
47 39
40/* For each bridge framework, when it attaches either analog or digital,
41 * it has to store a reference back to its _core equivalent structure,
42 * so that it can service the hardware by steering gpio's etc.
43 * Each bridge implementation is different so cast devptr accordingly.
44 * The xc5000 driver cares not for this value, other than ensuring
45 * it's passed back to a bridge during tuner_callback().
46 */
47
48#if defined(CONFIG_MEDIA_TUNER_XC5000) || \ 48#if defined(CONFIG_MEDIA_TUNER_XC5000) || \
49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE)) 49 (defined(CONFIG_MEDIA_TUNER_XC5000_MODULE) && defined(MODULE))
50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 50extern struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
51 struct i2c_adapter *i2c, 51 struct i2c_adapter *i2c,
52 struct xc5000_config *cfg); 52 struct xc5000_config *cfg,
53 void *devptr);
53#else 54#else
54static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe, 55static inline struct dvb_frontend* xc5000_attach(struct dvb_frontend *fe,
55 struct i2c_adapter *i2c, 56 struct i2c_adapter *i2c,
56 struct xc5000_config *cfg) 57 struct xc5000_config *cfg,
58 void *devptr)
57{ 59{
58 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 60 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
59 return NULL; 61 return NULL;
diff --git a/drivers/media/common/tuners/xc5000_priv.h b/drivers/media/common/tuners/xc5000_priv.h
index 13b2d19341da..ecebfe4745ad 100644
--- a/drivers/media/common/tuners/xc5000_priv.h
+++ b/drivers/media/common/tuners/xc5000_priv.h
@@ -31,6 +31,8 @@ struct xc5000_priv {
31 u8 video_standard; 31 u8 video_standard;
32 u8 rf_mode; 32 u8 rf_mode;
33 u8 fwloaded; 33 u8 fwloaded;
34
35 void *devptr;
34}; 36};
35 37
36#endif 38#endif
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index 7b0ea3bdfafb..f9d087669d5d 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -634,7 +634,7 @@ int flexcop_frontend_init(struct flexcop_device *fc)
634 } 634 }
635 635
636 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */ 636 /* try the sky v2.3 (vp310/Samsung tbdu18132(tsa5059)) */
637 fc->fe = dvb_attach(vp310_mt312_attach, 637 fc->fe = dvb_attach(mt312_attach,
638 &skystar23_samsung_tbdu18132_config, i2c); 638 &skystar23_samsung_tbdu18132_config, i2c);
639 if (fc->fe != NULL) { 639 if (fc->fe != NULL) {
640 ops = &fc->fe->ops; 640 ops = &fc->fe->ops;
diff --git a/drivers/media/dvb/bt8xx/Kconfig b/drivers/media/dvb/bt8xx/Kconfig
index d1239b8342f8..7588db1319d0 100644
--- a/drivers/media/dvb/bt8xx/Kconfig
+++ b/drivers/media/dvb/bt8xx/Kconfig
@@ -1,6 +1,7 @@
1config DVB_BT8XX 1config DVB_BT8XX
2 tristate "BT8xx based PCI cards" 2 tristate "BT8xx based PCI cards"
3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848 3 depends on DVB_CORE && PCI && I2C && VIDEO_BT848
4 depends on HOTPLUG # due to FW_LOADER
4 select DVB_MT352 if !DVB_FE_CUSTOMISE 5 select DVB_MT352 if !DVB_FE_CUSTOMISE
5 select DVB_SP887X if !DVB_FE_CUSTOMISE 6 select DVB_SP887X if !DVB_FE_CUSTOMISE
6 select DVB_NXT6000 if !DVB_FE_CUSTOMISE 7 select DVB_NXT6000 if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/cinergyT2/Kconfig b/drivers/media/dvb/cinergyT2/Kconfig
index 3d778c5aba68..c03513b2ccae 100644
--- a/drivers/media/dvb/cinergyT2/Kconfig
+++ b/drivers/media/dvb/cinergyT2/Kconfig
@@ -1,6 +1,6 @@
1config DVB_CINERGYT2 1config DVB_CINERGYT2
2 tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver" 2 tristate "Terratec CinergyT2/qanu USB2 DVB-T receiver"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB && INPUT
4 help 4 help
5 Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers 5 Support for "TerraTec CinergyT2" USB2.0 Highspeed DVB Receivers
6 6
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index 8cbdb0ec67e2..588fbe105c27 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -910,15 +910,21 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
910 int curdelay = 100000000; 910 int curdelay = 100000000;
911 int slot; 911 int slot;
912 912
913 /* Beware of too high polling frequency, because one polling
914 * call might take several hundred milliseconds until timeout!
915 */
913 for (slot = 0; slot < ca->slot_count; slot++) { 916 for (slot = 0; slot < ca->slot_count; slot++) {
914 switch (ca->slot_info[slot].slot_state) { 917 switch (ca->slot_info[slot].slot_state) {
915 default: 918 default:
916 case DVB_CA_SLOTSTATE_NONE: 919 case DVB_CA_SLOTSTATE_NONE:
920 delay = HZ * 60; /* 60s */
921 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
922 delay = HZ * 5; /* 5s */
923 break;
917 case DVB_CA_SLOTSTATE_INVALID: 924 case DVB_CA_SLOTSTATE_INVALID:
918 delay = HZ * 60; 925 delay = HZ * 60; /* 60s */
919 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { 926 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
920 delay = HZ / 10; 927 delay = HZ / 10; /* 100ms */
921 }
922 break; 928 break;
923 929
924 case DVB_CA_SLOTSTATE_UNINITIALISED: 930 case DVB_CA_SLOTSTATE_UNINITIALISED:
@@ -926,19 +932,17 @@ static void dvb_ca_en50221_thread_update_delay(struct dvb_ca_private *ca)
926 case DVB_CA_SLOTSTATE_VALIDATE: 932 case DVB_CA_SLOTSTATE_VALIDATE:
927 case DVB_CA_SLOTSTATE_WAITFR: 933 case DVB_CA_SLOTSTATE_WAITFR:
928 case DVB_CA_SLOTSTATE_LINKINIT: 934 case DVB_CA_SLOTSTATE_LINKINIT:
929 delay = HZ / 10; 935 delay = HZ / 10; /* 100ms */
930 break; 936 break;
931 937
932 case DVB_CA_SLOTSTATE_RUNNING: 938 case DVB_CA_SLOTSTATE_RUNNING:
933 delay = HZ * 60; 939 delay = HZ * 60; /* 60s */
934 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE)) { 940 if (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_CAMCHANGE))
935 delay = HZ / 10; 941 delay = HZ / 10; /* 100ms */
936 }
937 if (ca->open) { 942 if (ca->open) {
938 if ((!ca->slot_info[slot].da_irq_supported) || 943 if ((!ca->slot_info[slot].da_irq_supported) ||
939 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA))) { 944 (!(ca->flags & DVB_CA_EN50221_FLAG_IRQ_DA)))
940 delay = HZ / 10; 945 delay = HZ / 10; /* 100ms */
941 }
942 } 946 }
943 break; 947 break;
944 } 948 }
diff --git a/drivers/media/dvb/dvb-usb/Kconfig b/drivers/media/dvb/dvb-usb/Kconfig
index 4c1cff9feb2e..cf4584e48b6d 100644
--- a/drivers/media/dvb/dvb-usb/Kconfig
+++ b/drivers/media/dvb/dvb-usb/Kconfig
@@ -1,6 +1,7 @@
1config DVB_USB 1config DVB_USB
2 tristate "Support for various USB DVB devices" 2 tristate "Support for various USB DVB devices"
3 depends on DVB_CORE && USB && I2C 3 depends on DVB_CORE && USB && I2C
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 help 6 help
6 By enabling this you will be able to choose the various supported 7 By enabling this you will be able to choose the various supported
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig
index 6d2384605927..c20553c4da1f 100644
--- a/drivers/media/dvb/frontends/Kconfig
+++ b/drivers/media/dvb/frontends/Kconfig
@@ -30,7 +30,7 @@ config DVB_CX24123
30 A DVB-S tuner module. Say Y when you want to support this frontend. 30 A DVB-S tuner module. Say Y when you want to support this frontend.
31 31
32config DVB_MT312 32config DVB_MT312
33 tristate "Zarlink VP310/MT312 based" 33 tristate "Zarlink VP310/MT312/ZL10313 based"
34 depends on DVB_CORE && I2C 34 depends on DVB_CORE && I2C
35 default m if DVB_FE_CUSTOMISE 35 default m if DVB_FE_CUSTOMISE
36 help 36 help
@@ -97,7 +97,7 @@ comment "DVB-T (terrestrial) frontends"
97 97
98config DVB_SP8870 98config DVB_SP8870
99 tristate "Spase sp8870 based" 99 tristate "Spase sp8870 based"
100 depends on DVB_CORE && I2C 100 depends on DVB_CORE && I2C && HOTPLUG
101 default m if DVB_FE_CUSTOMISE 101 default m if DVB_FE_CUSTOMISE
102 select FW_LOADER 102 select FW_LOADER
103 help 103 help
@@ -110,7 +110,7 @@ config DVB_SP8870
110 110
111config DVB_SP887X 111config DVB_SP887X
112 tristate "Spase sp887x based" 112 tristate "Spase sp887x based"
113 depends on DVB_CORE && I2C 113 depends on DVB_CORE && I2C && HOTPLUG
114 default m if DVB_FE_CUSTOMISE 114 default m if DVB_FE_CUSTOMISE
115 select FW_LOADER 115 select FW_LOADER
116 help 116 help
@@ -144,7 +144,7 @@ config DVB_L64781
144 144
145config DVB_TDA1004X 145config DVB_TDA1004X
146 tristate "Philips TDA10045H/TDA10046H based" 146 tristate "Philips TDA10045H/TDA10046H based"
147 depends on DVB_CORE && I2C 147 depends on DVB_CORE && I2C && HOTPLUG
148 default m if DVB_FE_CUSTOMISE 148 default m if DVB_FE_CUSTOMISE
149 select FW_LOADER 149 select FW_LOADER
150 help 150 help
@@ -211,7 +211,7 @@ config DVB_DIB7000P
211 211
212config DVB_TDA10048 212config DVB_TDA10048
213 tristate "Philips TDA10048HN based" 213 tristate "Philips TDA10048HN based"
214 depends on DVB_CORE && I2C 214 depends on DVB_CORE && I2C && HOTPLUG
215 default m if DVB_FE_CUSTOMISE 215 default m if DVB_FE_CUSTOMISE
216 select FW_LOADER 216 select FW_LOADER
217 help 217 help
@@ -253,7 +253,7 @@ comment "ATSC (North American/Korean Terrestrial/Cable DTV) frontends"
253 253
254config DVB_NXT200X 254config DVB_NXT200X
255 tristate "NxtWave Communications NXT2002/NXT2004 based" 255 tristate "NxtWave Communications NXT2002/NXT2004 based"
256 depends on DVB_CORE && I2C 256 depends on DVB_CORE && I2C && HOTPLUG
257 default m if DVB_FE_CUSTOMISE 257 default m if DVB_FE_CUSTOMISE
258 select FW_LOADER 258 select FW_LOADER
259 help 259 help
@@ -268,7 +268,7 @@ config DVB_NXT200X
268 268
269config DVB_OR51211 269config DVB_OR51211
270 tristate "Oren OR51211 based" 270 tristate "Oren OR51211 based"
271 depends on DVB_CORE && I2C 271 depends on DVB_CORE && I2C && HOTPLUG
272 default m if DVB_FE_CUSTOMISE 272 default m if DVB_FE_CUSTOMISE
273 select FW_LOADER 273 select FW_LOADER
274 help 274 help
@@ -281,7 +281,7 @@ config DVB_OR51211
281 281
282config DVB_OR51132 282config DVB_OR51132
283 tristate "Oren OR51132 based" 283 tristate "Oren OR51132 based"
284 depends on DVB_CORE && I2C 284 depends on DVB_CORE && I2C && HOTPLUG
285 default m if DVB_FE_CUSTOMISE 285 default m if DVB_FE_CUSTOMISE
286 select FW_LOADER 286 select FW_LOADER
287 help 287 help
@@ -297,7 +297,7 @@ config DVB_OR51132
297 297
298config DVB_BCM3510 298config DVB_BCM3510
299 tristate "Broadcom BCM3510" 299 tristate "Broadcom BCM3510"
300 depends on DVB_CORE && I2C 300 depends on DVB_CORE && I2C && HOTPLUG
301 default m if DVB_FE_CUSTOMISE 301 default m if DVB_FE_CUSTOMISE
302 select FW_LOADER 302 select FW_LOADER
303 help 303 help
diff --git a/drivers/media/dvb/frontends/itd1000.c b/drivers/media/dvb/frontends/itd1000.c
index 04c562ccf990..600dad6b41ea 100644
--- a/drivers/media/dvb/frontends/itd1000.c
+++ b/drivers/media/dvb/frontends/itd1000.c
@@ -195,7 +195,7 @@ static void itd1000_set_vco(struct itd1000_state *state, u32 freq_khz)
195 } 195 }
196} 196}
197 197
198struct { 198static const struct {
199 u32 freq; 199 u32 freq;
200 u8 values[10]; /* RFTR, RFST1 - RFST9 */ 200 u8 values[10]; /* RFTR, RFST1 - RFST9 */
201} itd1000_fre_values[] = { 201} itd1000_fre_values[] = {
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index 081ca3398c76..5ac9b15920f8 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -737,7 +737,7 @@ static void mt312_release(struct dvb_frontend *fe)
737} 737}
738 738
739#define MT312_SYS_CLK 90000000UL /* 90 MHz */ 739#define MT312_SYS_CLK 90000000UL /* 90 MHz */
740static struct dvb_frontend_ops vp310_mt312_ops = { 740static struct dvb_frontend_ops mt312_ops = {
741 741
742 .info = { 742 .info = {
743 .name = "Zarlink ???? DVB-S", 743 .name = "Zarlink ???? DVB-S",
@@ -776,7 +776,7 @@ static struct dvb_frontend_ops vp310_mt312_ops = {
776 .set_voltage = mt312_set_voltage, 776 .set_voltage = mt312_set_voltage,
777}; 777};
778 778
779struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, 779struct dvb_frontend *mt312_attach(const struct mt312_config *config,
780 struct i2c_adapter *i2c) 780 struct i2c_adapter *i2c)
781{ 781{
782 struct mt312_state *state = NULL; 782 struct mt312_state *state = NULL;
@@ -795,7 +795,7 @@ struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config,
795 goto error; 795 goto error;
796 796
797 /* create dvb_frontend */ 797 /* create dvb_frontend */
798 memcpy(&state->frontend.ops, &vp310_mt312_ops, 798 memcpy(&state->frontend.ops, &mt312_ops,
799 sizeof(struct dvb_frontend_ops)); 799 sizeof(struct dvb_frontend_ops));
800 state->frontend.demodulator_priv = state; 800 state->frontend.demodulator_priv = state;
801 801
@@ -827,12 +827,13 @@ error:
827 kfree(state); 827 kfree(state);
828 return NULL; 828 return NULL;
829} 829}
830EXPORT_SYMBOL(vp310_mt312_attach); 830EXPORT_SYMBOL(mt312_attach);
831 831
832module_param(debug, int, 0644); 832module_param(debug, int, 0644);
833MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off)."); 833MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
834 834
835MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver"); 835MODULE_DESCRIPTION("Zarlink VP310/MT312/ZL10313 DVB-S Demodulator driver");
836MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>"); 836MODULE_AUTHOR("Andreas Oberritter <obi@linuxtv.org>");
837MODULE_AUTHOR("Matthias Schwarzott <zzam@gentoo.org>");
837MODULE_LICENSE("GPL"); 838MODULE_LICENSE("GPL");
838 839
diff --git a/drivers/media/dvb/frontends/mt312.h b/drivers/media/dvb/frontends/mt312.h
index de796eab3911..29e3bb5496b8 100644
--- a/drivers/media/dvb/frontends/mt312.h
+++ b/drivers/media/dvb/frontends/mt312.h
@@ -37,10 +37,10 @@ struct mt312_config {
37}; 37};
38 38
39#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE)) 39#if defined(CONFIG_DVB_MT312) || (defined(CONFIG_DVB_MT312_MODULE) && defined(MODULE))
40struct dvb_frontend *vp310_mt312_attach(const struct mt312_config *config, 40struct dvb_frontend *mt312_attach(const struct mt312_config *config,
41 struct i2c_adapter *i2c); 41 struct i2c_adapter *i2c);
42#else 42#else
43static inline struct dvb_frontend *vp310_mt312_attach( 43static inline struct dvb_frontend *mt312_attach(
44 const struct mt312_config *config, struct i2c_adapter *i2c) 44 const struct mt312_config *config, struct i2c_adapter *i2c)
45{ 45{
46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 46 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index ae882432dd3d..d4339b1b3b68 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -5,6 +5,7 @@ config TTPCI_EEPROM
5config DVB_AV7110 5config DVB_AV7110
6 tristate "AV7110 cards" 6 tristate "AV7110 cards"
7 depends on DVB_CORE && PCI && I2C 7 depends on DVB_CORE && PCI && I2C
8 depends on HOTPLUG
8 select FW_LOADER if !DVB_AV7110_FIRMWARE 9 select FW_LOADER if !DVB_AV7110_FIRMWARE
9 select TTPCI_EEPROM 10 select TTPCI_EEPROM
10 select VIDEO_SAA7146_VV 11 select VIDEO_SAA7146_VV
@@ -123,6 +124,7 @@ config DVB_BUDGET_AV
123 depends on DVB_BUDGET_CORE && I2C 124 depends on DVB_BUDGET_CORE && I2C
124 select VIDEO_SAA7146_VV 125 select VIDEO_SAA7146_VV
125 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV 126 depends on VIDEO_DEV # dependencies of VIDEO_SAA7146_VV
127 depends on HOTPLUG # dependency of FW_LOADER
126 select DVB_PLL if !DVB_FE_CUSTOMISE 128 select DVB_PLL if !DVB_FE_CUSTOMISE
127 select DVB_STV0299 if !DVB_FE_CUSTOMISE 129 select DVB_STV0299 if !DVB_FE_CUSTOMISE
128 select DVB_TDA1004X if !DVB_FE_CUSTOMISE 130 select DVB_TDA1004X if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/dvb/ttusb-dec/Kconfig b/drivers/media/dvb/ttusb-dec/Kconfig
index 83611012ef34..0712899e39a4 100644
--- a/drivers/media/dvb/ttusb-dec/Kconfig
+++ b/drivers/media/dvb/ttusb-dec/Kconfig
@@ -1,6 +1,7 @@
1config DVB_TTUSB_DEC 1config DVB_TTUSB_DEC
2 tristate "Technotrend/Hauppauge USB DEC devices" 2 tristate "Technotrend/Hauppauge USB DEC devices"
3 depends on DVB_CORE && USB 3 depends on DVB_CORE && USB
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 select CRC32 6 select CRC32
6 help 7 help
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index fe743aa7f645..89d8d37838a3 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -44,6 +44,10 @@ config VIDEO_TVEEPROM
44 tristate 44 tristate
45 depends on I2C 45 depends on I2C
46 46
47config VIDEO_TUNER
48 tristate
49 depends on MEDIA_TUNER
50
47# 51#
48# Multimedia Video device configuration 52# Multimedia Video device configuration
49# 53#
@@ -690,7 +694,7 @@ config VIDEO_MXB
690 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'" 694 tristate "Siemens-Nixdorf 'Multimedia eXtension Board'"
691 depends on PCI && VIDEO_V4L1 && I2C 695 depends on PCI && VIDEO_V4L1 && I2C
692 select VIDEO_SAA7146_VV 696 select VIDEO_SAA7146_VV
693 select MEDIA_TUNER 697 select VIDEO_TUNER
694 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO 698 select VIDEO_SAA7111 if VIDEO_HELPER_CHIPS_AUTO
695 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO 699 select VIDEO_TDA9840 if VIDEO_HELPER_CHIPS_AUTO
696 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO 700 select VIDEO_TEA6415C if VIDEO_HELPER_CHIPS_AUTO
@@ -906,7 +910,7 @@ config SOC_CAMERA
906 910
907config SOC_CAMERA_MT9M001 911config SOC_CAMERA_MT9M001
908 tristate "mt9m001 support" 912 tristate "mt9m001 support"
909 depends on SOC_CAMERA 913 depends on SOC_CAMERA && I2C
910 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH 914 select GPIO_PCA953X if MT9M001_PCA9536_SWITCH
911 help 915 help
912 This driver supports MT9M001 cameras from Micron, monochrome 916 This driver supports MT9M001 cameras from Micron, monochrome
@@ -921,7 +925,7 @@ config MT9M001_PCA9536_SWITCH
921 925
922config SOC_CAMERA_MT9V022 926config SOC_CAMERA_MT9V022
923 tristate "mt9v022 support" 927 tristate "mt9v022 support"
924 depends on SOC_CAMERA 928 depends on SOC_CAMERA && I2C
925 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH 929 select GPIO_PCA953X if MT9V022_PCA9536_SWITCH
926 help 930 help
927 This driver supports MT9V022 cameras from Micron 931 This driver supports MT9V022 cameras from Micron
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index a352c6e31f0c..dff0d6abe917 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -84,7 +84,7 @@ obj-$(CONFIG_VIDEO_HEXIUM_GEMINI) += hexium_gemini.o
84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o 84obj-$(CONFIG_VIDEO_DPC) += dpc7146.o
85obj-$(CONFIG_TUNER_3036) += tuner-3036.o 85obj-$(CONFIG_TUNER_3036) += tuner-3036.o
86 86
87obj-$(CONFIG_MEDIA_TUNER) += tuner.o 87obj-$(CONFIG_VIDEO_TUNER) += tuner.o
88 88
89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o 89obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o
90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o 90obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o
diff --git a/drivers/media/video/au0828/Kconfig b/drivers/media/video/au0828/Kconfig
index cab277fafa63..def10d086373 100644
--- a/drivers/media/video/au0828/Kconfig
+++ b/drivers/media/video/au0828/Kconfig
@@ -1,8 +1,9 @@
1 1
2config VIDEO_AU0828 2config VIDEO_AU0828
3 tristate "Auvitek AU0828 support" 3 tristate "Auvitek AU0828 support"
4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE 4 depends on VIDEO_DEV && I2C && INPUT && DVB_CORE && USB
5 select I2C_ALGOBIT 5 select I2C_ALGOBIT
6 select VIDEO_TVEEPROM
6 select DVB_AU8522 if !DVB_FE_CUSTOMIZE 7 select DVB_AU8522 if !DVB_FE_CUSTOMIZE
7 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE 8 select MEDIA_TUNER_XC5000 if !DVB_FE_CUSTOMIZE
8 ---help--- 9 ---help---
diff --git a/drivers/media/video/au0828/au0828-dvb.c b/drivers/media/video/au0828/au0828-dvb.c
index 1371b4e4b5f1..c86a5f17eca8 100644
--- a/drivers/media/video/au0828/au0828-dvb.c
+++ b/drivers/media/video/au0828/au0828-dvb.c
@@ -337,12 +337,10 @@ int au0828_dvb_register(struct au0828_dev *dev)
337 dvb->frontend = dvb_attach(au8522_attach, 337 dvb->frontend = dvb_attach(au8522_attach,
338 &hauppauge_hvr950q_config, 338 &hauppauge_hvr950q_config,
339 &dev->i2c_adap); 339 &dev->i2c_adap);
340 if (dvb->frontend != NULL) { 340 if (dvb->frontend != NULL)
341 hauppauge_hvr950q_tunerconfig.priv = dev;
342 dvb_attach(xc5000_attach, dvb->frontend, 341 dvb_attach(xc5000_attach, dvb->frontend,
343 &dev->i2c_adap, 342 &dev->i2c_adap,
344 &hauppauge_hvr950q_tunerconfig); 343 &hauppauge_hvr950q_tunerconfig, dev);
345 }
346 break; 344 break;
347 default: 345 default:
348 printk(KERN_WARNING "The frontend of your DVB/ATSC card " 346 printk(KERN_WARNING "The frontend of your DVB/ATSC card "
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
index 7431ef6de9f1..24a34fc1f2b3 100644
--- a/drivers/media/video/bt8xx/Kconfig
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -1,12 +1,13 @@
1config VIDEO_BT848 1config VIDEO_BT848
2 tristate "BT848 Video For Linux" 2 tristate "BT848 Video For Linux"
3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT 3 depends on VIDEO_DEV && PCI && I2C && VIDEO_V4L2 && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 8 select VIDEOBUF_DMA_SG
8 select VIDEO_IR 9 select VIDEO_IR
9 select MEDIA_TUNER 10 select VIDEO_TUNER
10 select VIDEO_TVEEPROM 11 select VIDEO_TVEEPROM
11 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO 12 select VIDEO_MSP3400 if VIDEO_HELPER_CHIPS_AUTO
12 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO 13 select VIDEO_TVAUDIO if VIDEO_HELPER_CHIPS_AUTO
diff --git a/drivers/media/video/cx18/Kconfig b/drivers/media/video/cx18/Kconfig
index acc4b47f1d1d..5f942690570c 100644
--- a/drivers/media/video/cx18/Kconfig
+++ b/drivers/media/video/cx18/Kconfig
@@ -1,14 +1,17 @@
1config VIDEO_CX18 1config VIDEO_CX18
2 tristate "Conexant cx23418 MPEG encoder support" 2 tristate "Conexant cx23418 MPEG encoder support"
3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && DVB_CORE && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CS5345 12 select VIDEO_CS5345
11 select DVB_S5H1409 13 select DVB_S5H1409
14 select MEDIA_TUNER_MXL5005S
12 ---help--- 15 ---help---
13 This is a video4linux driver for Conexant cx23418 based 16 This is a video4linux driver for Conexant cx23418 based
14 PCI combo video recorder devices. 17 PCI combo video recorder devices.
diff --git a/drivers/media/video/cx18/cx18-cards.c b/drivers/media/video/cx18/cx18-cards.c
index f5e3ba1f5354..553adbf2cd44 100644
--- a/drivers/media/video/cx18/cx18-cards.c
+++ b/drivers/media/video/cx18/cx18-cards.c
@@ -47,11 +47,12 @@ static struct cx18_card_tuner_i2c cx18_i2c_std = {
47static const struct cx18_card cx18_card_hvr1600_esmt = { 47static const struct cx18_card cx18_card_hvr1600_esmt = {
48 .type = CX18_CARD_HVR_1600_ESMT, 48 .type = CX18_CARD_HVR_1600_ESMT,
49 .name = "Hauppauge HVR-1600", 49 .name = "Hauppauge HVR-1600",
50 .comment = "DVB & VBI are not yet supported\n", 50 .comment = "VBI is not yet supported\n",
51 .v4l2_capabilities = CX18_CAP_ENCODER, 51 .v4l2_capabilities = CX18_CAP_ENCODER,
52 .hw_audio_ctrl = CX18_HW_CX23418, 52 .hw_audio_ctrl = CX18_HW_CX23418,
53 .hw_muxer = CX18_HW_CS5345, 53 .hw_muxer = CX18_HW_CS5345,
54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 54 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
55 CX18_HW_CS5345 | CX18_HW_DVB,
55 .video_inputs = { 56 .video_inputs = {
56 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 57 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
57 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 58 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -86,11 +87,12 @@ static const struct cx18_card cx18_card_hvr1600_esmt = {
86static const struct cx18_card cx18_card_hvr1600_samsung = { 87static const struct cx18_card cx18_card_hvr1600_samsung = {
87 .type = CX18_CARD_HVR_1600_SAMSUNG, 88 .type = CX18_CARD_HVR_1600_SAMSUNG,
88 .name = "Hauppauge HVR-1600 (Preproduction)", 89 .name = "Hauppauge HVR-1600 (Preproduction)",
89 .comment = "DVB & VBI are not yet supported\n", 90 .comment = "VBI is not yet supported\n",
90 .v4l2_capabilities = CX18_CAP_ENCODER, 91 .v4l2_capabilities = CX18_CAP_ENCODER,
91 .hw_audio_ctrl = CX18_HW_CX23418, 92 .hw_audio_ctrl = CX18_HW_CX23418,
92 .hw_muxer = CX18_HW_CS5345, 93 .hw_muxer = CX18_HW_CS5345,
93 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER | CX18_HW_CS5345, 94 .hw_all = CX18_HW_TVEEPROM | CX18_HW_TUNER |
95 CX18_HW_CS5345 | CX18_HW_DVB,
94 .video_inputs = { 96 .video_inputs = {
95 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 97 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 },
96 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 98 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 },
@@ -134,14 +136,15 @@ static const struct cx18_card_pci_info cx18_pci_h900[] = {
134static const struct cx18_card cx18_card_h900 = { 136static const struct cx18_card cx18_card_h900 = {
135 .type = CX18_CARD_COMPRO_H900, 137 .type = CX18_CARD_COMPRO_H900,
136 .name = "Compro VideoMate H900", 138 .name = "Compro VideoMate H900",
137 .comment = "Not yet supported!\n", 139 .comment = "DVB & VBI are not yet supported\n",
138 .v4l2_capabilities = 0, 140 .v4l2_capabilities = CX18_CAP_ENCODER,
139 .hw_audio_ctrl = CX18_HW_CX23418, 141 .hw_audio_ctrl = CX18_HW_CX23418,
140 .hw_all = CX18_HW_TUNER, 142 .hw_all = CX18_HW_TUNER,
141 .video_inputs = { 143 .video_inputs = {
142 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE7 }, 144 { CX18_CARD_INPUT_VID_TUNER, 0, CX23418_COMPOSITE2 },
143 { CX18_CARD_INPUT_SVIDEO1, 1, CX23418_SVIDEO1 }, 145 { CX18_CARD_INPUT_SVIDEO1, 1,
144 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE3 }, 146 CX23418_SVIDEO_LUMA3 | CX23418_SVIDEO_CHROMA4 },
147 { CX18_CARD_INPUT_COMPOSITE1, 1, CX23418_COMPOSITE1 },
145 }, 148 },
146 .audio_inputs = { 149 .audio_inputs = {
147 { CX18_CARD_INPUT_AUD_TUNER, 150 { CX18_CARD_INPUT_AUD_TUNER,
@@ -163,6 +166,7 @@ static const struct cx18_card cx18_card_h900 = {
163 .tune_lane = 0, 166 .tune_lane = 0,
164 .initial_emrs = 0, 167 .initial_emrs = 0,
165 }, 168 },
169 .xceive_pin = 15,
166 .pci_list = cx18_pci_h900, 170 .pci_list = cx18_pci_h900,
167 .i2c = &cx18_i2c_std, 171 .i2c = &cx18_i2c_std,
168}; 172};
@@ -200,8 +204,6 @@ static const struct cx18_card cx18_card_mpc718 = {
200 /* XC3028 tuner */ 204 /* XC3028 tuner */
201 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 }, 205 { .std = V4L2_STD_ALL, .tuner = TUNER_XC2028 },
202 }, 206 },
203 /* tuner reset */
204 .gpio_init = { .direction = 0x1000, .initial_value = 0x1000 },
205 .ddr = { 207 .ddr = {
206 /* Probably Samsung K4D263238G-VC33 memory */ 208 /* Probably Samsung K4D263238G-VC33 memory */
207 .chip_config = 0x003, 209 .chip_config = 0x003,
@@ -211,6 +213,7 @@ static const struct cx18_card cx18_card_mpc718 = {
211 .tune_lane = 0, 213 .tune_lane = 0,
212 .initial_emrs = 2, 214 .initial_emrs = 2,
213 }, 215 },
216 .xceive_pin = 15,
214 .pci_list = cx18_pci_mpc718, 217 .pci_list = cx18_pci_mpc718,
215 .i2c = &cx18_i2c_std, 218 .i2c = &cx18_i2c_std,
216}; 219};
diff --git a/drivers/media/video/cx18/cx18-cards.h b/drivers/media/video/cx18/cx18-cards.h
index bca249bdd337..bccb67f0db16 100644
--- a/drivers/media/video/cx18/cx18-cards.h
+++ b/drivers/media/video/cx18/cx18-cards.h
@@ -114,8 +114,8 @@ struct cx18_card_pci_info {
114/* The mask is the set of bits used by the operation */ 114/* The mask is the set of bits used by the operation */
115 115
116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */ 116struct cx18_gpio_init { /* set initial GPIO DIR and OUT values */
117 u16 direction; /* DIR setting. Leave to 0 if no init is needed */ 117 u32 direction; /* DIR setting. Leave to 0 if no init is needed */
118 u16 initial_value; 118 u32 initial_value;
119}; 119};
120 120
121struct cx18_card_tuner { 121struct cx18_card_tuner {
@@ -153,6 +153,7 @@ struct cx18_card {
153 struct cx18_card_audio_input radio_input; 153 struct cx18_card_audio_input radio_input;
154 154
155 /* GPIO card-specific settings */ 155 /* GPIO card-specific settings */
156 u8 xceive_pin; /* XCeive tuner GPIO reset pin */
156 struct cx18_gpio_init gpio_init; 157 struct cx18_gpio_init gpio_init;
157 158
158 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS]; 159 struct cx18_card_tuner tuners[CX18_CARD_MAX_TUNERS];
diff --git a/drivers/media/video/cx18/cx18-driver.c b/drivers/media/video/cx18/cx18-driver.c
index 8f5ed9b4bf83..0dd4e0529970 100644
--- a/drivers/media/video/cx18/cx18-driver.c
+++ b/drivers/media/video/cx18/cx18-driver.c
@@ -164,16 +164,6 @@ MODULE_LICENSE("GPL");
164 164
165MODULE_VERSION(CX18_VERSION); 165MODULE_VERSION(CX18_VERSION);
166 166
167int cx18_waitq(wait_queue_head_t *waitq)
168{
169 DEFINE_WAIT(wait);
170
171 prepare_to_wait(waitq, &wait, TASK_INTERRUPTIBLE);
172 schedule();
173 finish_wait(waitq, &wait);
174 return signal_pending(current) ? -EINTR : 0;
175}
176
177/* Generic utility functions */ 167/* Generic utility functions */
178int cx18_msleep_timeout(unsigned int msecs, int intr) 168int cx18_msleep_timeout(unsigned int msecs, int intr)
179{ 169{
@@ -220,13 +210,13 @@ static void cx18_process_eeprom(struct cx18 *cx)
220 210
221 /* Many thanks to Steven Toth from Hauppauge for providing the 211 /* Many thanks to Steven Toth from Hauppauge for providing the
222 model numbers */ 212 model numbers */
213 /* Note: the Samsung memory models cannot be reliably determined
214 from the model number. Use the cardtype module option if you
215 have one of these preproduction models. */
223 switch (tv.model) { 216 switch (tv.model) {
224 case 74000 ... 74099: 217 case 74000 ... 74999:
225 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT); 218 cx->card = cx18_get_card(CX18_CARD_HVR_1600_ESMT);
226 break; 219 break;
227 case 74700 ... 74799:
228 cx->card = cx18_get_card(CX18_CARD_HVR_1600_SAMSUNG);
229 break;
230 case 0: 220 case 0:
231 CX18_ERR("Invalid EEPROM\n"); 221 CX18_ERR("Invalid EEPROM\n");
232 return; 222 return;
@@ -548,6 +538,7 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *dev,
548 return 0; 538 return 0;
549} 539}
550 540
541#ifdef MODULE
551static u32 cx18_request_module(struct cx18 *cx, u32 hw, 542static u32 cx18_request_module(struct cx18 *cx, u32 hw,
552 const char *name, u32 id) 543 const char *name, u32 id)
553{ 544{
@@ -560,12 +551,14 @@ static u32 cx18_request_module(struct cx18 *cx, u32 hw,
560 CX18_DEBUG_INFO("Loaded module %s\n", name); 551 CX18_DEBUG_INFO("Loaded module %s\n", name);
561 return hw; 552 return hw;
562} 553}
554#endif
563 555
564static void cx18_load_and_init_modules(struct cx18 *cx) 556static void cx18_load_and_init_modules(struct cx18 *cx)
565{ 557{
566 u32 hw = cx->card->hw_all; 558 u32 hw = cx->card->hw_all;
567 int i; 559 int i;
568 560
561#ifdef MODULE
569 /* load modules */ 562 /* load modules */
570#ifndef CONFIG_MEDIA_TUNER 563#ifndef CONFIG_MEDIA_TUNER
571 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER); 564 hw = cx18_request_module(cx, hw, "tuner", CX18_HW_TUNER);
@@ -573,6 +566,7 @@ static void cx18_load_and_init_modules(struct cx18 *cx)
573#ifndef CONFIG_VIDEO_CS5345 566#ifndef CONFIG_VIDEO_CS5345
574 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345); 567 hw = cx18_request_module(cx, hw, "cs5345", CX18_HW_CS5345);
575#endif 568#endif
569#endif
576 570
577 /* check which i2c devices are actually found */ 571 /* check which i2c devices are actually found */
578 for (i = 0; i < 32; i++) { 572 for (i = 0; i < 32; i++) {
@@ -613,7 +607,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
613 } 607 }
614 608
615 cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); 609 cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC);
616 if (cx == 0) { 610 if (!cx) {
617 spin_unlock(&cx18_cards_lock); 611 spin_unlock(&cx18_cards_lock);
618 return -ENOMEM; 612 return -ENOMEM;
619 } 613 }
@@ -801,7 +795,7 @@ static int __devinit cx18_probe(struct pci_dev *dev,
801 return 0; 795 return 0;
802 796
803free_streams: 797free_streams:
804 cx18_streams_cleanup(cx); 798 cx18_streams_cleanup(cx, 1);
805free_irq: 799free_irq:
806 free_irq(cx->dev->irq, (void *)cx); 800 free_irq(cx->dev->irq, (void *)cx);
807free_i2c: 801free_i2c:
@@ -904,14 +898,13 @@ static void cx18_remove(struct pci_dev *pci_dev)
904 898
905 cx18_halt_firmware(cx); 899 cx18_halt_firmware(cx);
906 900
907 cx18_streams_cleanup(cx); 901 cx18_streams_cleanup(cx, 1);
908 902
909 exit_cx18_i2c(cx); 903 exit_cx18_i2c(cx);
910 904
911 free_irq(cx->dev->irq, (void *)cx); 905 free_irq(cx->dev->irq, (void *)cx);
912 906
913 if (cx->dev) 907 cx18_iounmap(cx);
914 cx18_iounmap(cx);
915 908
916 release_mem_region(cx->base_addr, CX18_MEM_SIZE); 909 release_mem_region(cx->base_addr, CX18_MEM_SIZE);
917 910
diff --git a/drivers/media/video/cx18/cx18-driver.h b/drivers/media/video/cx18/cx18-driver.h
index 2ee939193bb7..a2a6c58d12fe 100644
--- a/drivers/media/video/cx18/cx18-driver.h
+++ b/drivers/media/video/cx18/cx18-driver.h
@@ -444,9 +444,6 @@ extern spinlock_t cx18_cards_lock;
444/* Return non-zero if a signal is pending */ 444/* Return non-zero if a signal is pending */
445int cx18_msleep_timeout(unsigned int msecs, int intr); 445int cx18_msleep_timeout(unsigned int msecs, int intr);
446 446
447/* Wait on queue, returns -EINTR if interrupted */
448int cx18_waitq(wait_queue_head_t *waitq);
449
450/* Read Hauppauge eeprom */ 447/* Read Hauppauge eeprom */
451struct tveeprom; /* forward reference */ 448struct tveeprom; /* forward reference */
452void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv); 449void cx18_read_eeprom(struct cx18 *cx, struct tveeprom *tv);
diff --git a/drivers/media/video/cx18/cx18-dvb.c b/drivers/media/video/cx18/cx18-dvb.c
index 65efe69d939a..c9744173f969 100644
--- a/drivers/media/video/cx18/cx18-dvb.c
+++ b/drivers/media/video/cx18/cx18-dvb.c
@@ -24,25 +24,27 @@
24#include "cx18-streams.h" 24#include "cx18-streams.h"
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "s5h1409.h" 26#include "s5h1409.h"
27 27#include "mxl5005s.h"
28/* Wait until the MXL500X driver is merged */
29#ifdef HAVE_MXL500X
30#include "mxl500x.h"
31#endif
32 28
33DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); 29DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
34 30
35#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000 31#define CX18_REG_DMUX_NUM_PORT_0_CONTROL 0xd5a000
36 32
37#ifdef HAVE_MXL500X 33static struct mxl5005s_config hauppauge_hvr1600_tuner = {
38static struct mxl500x_config hauppauge_hvr1600_tuner = { 34 .i2c_address = 0xC6 >> 1,
39 .delsys = MXL500x_MODE_ATSC, 35 .if_freq = IF_FREQ_5380000HZ,
40 .octf = MXL500x_OCTF_CH, 36 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
41 .xtal_freq = 16000000, 37 .agc_mode = MXL_SINGLE_AGC,
42 .iflo_freq = 5380000, 38 .tracking_filter = MXL_TF_C_H,
43 .ref_freq = 322800000, 39 .rssi_enable = MXL_RSSI_ENABLE,
44 .rssi_ena = MXL_RSSI_ENABLE, 40 .cap_select = MXL_CAP_SEL_ENABLE,
45 .addr = 0xC6 >> 1, 41 .div_out = MXL_DIV_OUT_4,
42 .clock_out = MXL_CLOCK_OUT_DISABLE,
43 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
44 .top = MXL5005S_TOP_25P2,
45 .mod_mode = MXL_DIGITAL_MODE,
46 .if_mode = MXL_ZERO_IF,
47 .AgcMasterByte = 0x00,
46}; 48};
47 49
48static struct s5h1409_config hauppauge_hvr1600_config = { 50static struct s5h1409_config hauppauge_hvr1600_config = {
@@ -55,7 +57,6 @@ static struct s5h1409_config hauppauge_hvr1600_config = {
55 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK 57 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK
56 58
57}; 59};
58#endif
59 60
60static int dvb_register(struct cx18_stream *stream); 61static int dvb_register(struct cx18_stream *stream);
61 62
@@ -252,21 +253,18 @@ static int dvb_register(struct cx18_stream *stream)
252 int ret = 0; 253 int ret = 0;
253 254
254 switch (cx->card->type) { 255 switch (cx->card->type) {
255/* Wait until the MXL500X driver is merged */
256#ifdef HAVE_MXL500X
257 case CX18_CARD_HVR_1600_ESMT: 256 case CX18_CARD_HVR_1600_ESMT:
258 case CX18_CARD_HVR_1600_SAMSUNG: 257 case CX18_CARD_HVR_1600_SAMSUNG:
259 dvb->fe = dvb_attach(s5h1409_attach, 258 dvb->fe = dvb_attach(s5h1409_attach,
260 &hauppauge_hvr1600_config, 259 &hauppauge_hvr1600_config,
261 &cx->i2c_adap[0]); 260 &cx->i2c_adap[0]);
262 if (dvb->fe != NULL) { 261 if (dvb->fe != NULL) {
263 dvb_attach(mxl500x_attach, dvb->fe, 262 dvb_attach(mxl5005s_attach, dvb->fe,
264 &hauppauge_hvr1600_tuner, 263 &cx->i2c_adap[0],
265 &cx->i2c_adap[0]); 264 &hauppauge_hvr1600_tuner);
266 ret = 0; 265 ret = 0;
267 } 266 }
268 break; 267 break;
269#endif
270 default: 268 default:
271 /* No Digital Tv Support */ 269 /* No Digital Tv Support */
272 break; 270 break;
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c
index 69303065a294..0b3141db174b 100644
--- a/drivers/media/video/cx18/cx18-fileops.c
+++ b/drivers/media/video/cx18/cx18-fileops.c
@@ -39,7 +39,7 @@
39 associated VBI streams are also automatically claimed. 39 associated VBI streams are also automatically claimed.
40 Possible error returns: -EBUSY if someone else has claimed 40 Possible error returns: -EBUSY if someone else has claimed
41 the stream or 0 on success. */ 41 the stream or 0 on success. */
42int cx18_claim_stream(struct cx18_open_id *id, int type) 42static int cx18_claim_stream(struct cx18_open_id *id, int type)
43{ 43{
44 struct cx18 *cx = id->cx; 44 struct cx18 *cx = id->cx;
45 struct cx18_stream *s = &cx->streams[type]; 45 struct cx18_stream *s = &cx->streams[type];
@@ -87,7 +87,7 @@ int cx18_claim_stream(struct cx18_open_id *id, int type)
87 87
88/* This function releases a previously claimed stream. It will take into 88/* This function releases a previously claimed stream. It will take into
89 account associated VBI streams. */ 89 account associated VBI streams. */
90void cx18_release_stream(struct cx18_stream *s) 90static void cx18_release_stream(struct cx18_stream *s)
91{ 91{
92 struct cx18 *cx = s->cx; 92 struct cx18 *cx = s->cx;
93 struct cx18_stream *s_vbi; 93 struct cx18_stream *s_vbi;
@@ -662,6 +662,8 @@ int cx18_v4l2_open(struct inode *inode, struct file *filp)
662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) { 662 for (x = 0; cx == NULL && x < cx18_cards_active; x++) {
663 /* find out which stream this open was on */ 663 /* find out which stream this open was on */
664 for (y = 0; y < CX18_MAX_STREAMS; y++) { 664 for (y = 0; y < CX18_MAX_STREAMS; y++) {
665 if (cx18_cards[x] == NULL)
666 continue;
665 s = &cx18_cards[x]->streams[y]; 667 s = &cx18_cards[x]->streams[y];
666 if (s->v4l2dev && s->v4l2dev->minor == minor) { 668 if (s->v4l2dev && s->v4l2dev->minor == minor) {
667 cx = cx18_cards[x]; 669 cx = cx18_cards[x];
diff --git a/drivers/media/video/cx18/cx18-fileops.h b/drivers/media/video/cx18/cx18-fileops.h
index 16cdafbd24c5..46da0282fc7d 100644
--- a/drivers/media/video/cx18/cx18-fileops.h
+++ b/drivers/media/video/cx18/cx18-fileops.h
@@ -34,12 +34,3 @@ void cx18_stop_capture(struct cx18_open_id *id, int gop_end);
34void cx18_mute(struct cx18 *cx); 34void cx18_mute(struct cx18 *cx);
35void cx18_unmute(struct cx18 *cx); 35void cx18_unmute(struct cx18 *cx);
36 36
37/* Utilities */
38
39/* Try to claim a stream for the filehandle. Return 0 on success,
40 -EBUSY if stream already claimed. Once a stream is claimed, it
41 remains claimed until the associated filehandle is closed. */
42int cx18_claim_stream(struct cx18_open_id *id, int type);
43
44/* Release a previously claimed stream. */
45void cx18_release_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-gpio.c b/drivers/media/video/cx18/cx18-gpio.c
index 19253e6b8673..bb8bc86086d0 100644
--- a/drivers/media/video/cx18/cx18-gpio.c
+++ b/drivers/media/video/cx18/cx18-gpio.c
@@ -35,6 +35,9 @@
35#define CX18_REG_GPIO_OUT2 0xc78104 35#define CX18_REG_GPIO_OUT2 0xc78104
36#define CX18_REG_GPIO_DIR2 0xc7810c 36#define CX18_REG_GPIO_DIR2 0xc7810c
37 37
38static u32 gpio_dir;
39static u32 gpio_val;
40
38/* 41/*
39 * HVR-1600 GPIO pins, courtesy of Hauppauge: 42 * HVR-1600 GPIO pins, courtesy of Hauppauge:
40 * 43 *
@@ -44,31 +47,53 @@
44 * gpio13: cs5345 reset pin 47 * gpio13: cs5345 reset pin
45*/ 48*/
46 49
50static void gpio_write(struct cx18 *cx)
51{
52 write_reg((gpio_dir & 0xffff) << 16, CX18_REG_GPIO_DIR1);
53 write_reg(((gpio_dir & 0xffff) << 16) | (gpio_val & 0xffff),
54 CX18_REG_GPIO_OUT1);
55 write_reg(gpio_dir & 0xffff0000, CX18_REG_GPIO_DIR2);
56 write_reg((gpio_dir & 0xffff0000) | ((gpio_val & 0xffff0000) >> 16),
57 CX18_REG_GPIO_OUT2);
58}
59
47void cx18_gpio_init(struct cx18 *cx) 60void cx18_gpio_init(struct cx18 *cx)
48{ 61{
49 if (cx->card->gpio_init.direction == 0) 62 gpio_dir = cx->card->gpio_init.direction;
63 gpio_val = cx->card->gpio_init.initial_value;
64
65 if (gpio_dir == 0)
50 return; 66 return;
51 67
52 CX18_DEBUG_INFO("GPIO initial dir: %08x out: %08x\n", 68 gpio_dir |= 1 << cx->card->xceive_pin;
53 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_OUT1)); 69 gpio_val |= 1 << cx->card->xceive_pin;
54 70
55 /* init output data then direction */ 71 CX18_DEBUG_INFO("GPIO initial dir: %08x/%08x out: %08x/%08x\n",
56 write_reg(cx->card->gpio_init.direction << 16, CX18_REG_GPIO_DIR1); 72 read_reg(CX18_REG_GPIO_DIR1), read_reg(CX18_REG_GPIO_DIR2),
57 write_reg(0, CX18_REG_GPIO_DIR2); 73 read_reg(CX18_REG_GPIO_OUT1), read_reg(CX18_REG_GPIO_OUT2));
58 write_reg((cx->card->gpio_init.direction << 16) | 74
59 cx->card->gpio_init.initial_value, CX18_REG_GPIO_OUT1); 75 gpio_write(cx);
60 write_reg(0, CX18_REG_GPIO_OUT2);
61} 76}
62 77
63/* Xceive tuner reset function */ 78/* Xceive tuner reset function */
64int cx18_reset_tuner_gpio(void *dev, int cmd, int value) 79int cx18_reset_tuner_gpio(void *dev, int cmd, int value)
65{ 80{
66 struct i2c_algo_bit_data *algo = dev; 81 struct i2c_algo_bit_data *algo = dev;
67 struct cx18 *cx = algo->data; 82 struct cx18_i2c_algo_callback_data *cb_data = algo->data;
68/* int curdir, curout;*/ 83 struct cx18 *cx = cb_data->cx;
69 84
70 if (cmd != XC2028_TUNER_RESET) 85 if (cmd != XC2028_TUNER_RESET)
71 return 0; 86 return 0;
72 CX18_DEBUG_INFO("Resetting tuner\n"); 87 CX18_DEBUG_INFO("Resetting tuner\n");
88
89 gpio_dir |= 1 << cx->card->xceive_pin;
90 gpio_val &= ~(1 << cx->card->xceive_pin);
91
92 gpio_write(cx);
93 schedule_timeout_interruptible(msecs_to_jiffies(1));
94
95 gpio_val |= 1 << cx->card->xceive_pin;
96 gpio_write(cx);
97 schedule_timeout_interruptible(msecs_to_jiffies(1));
73 return 0; 98 return 0;
74} 99}
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c
index 18c88d1e4833..4f08a4058d1a 100644
--- a/drivers/media/video/cx18/cx18-i2c.c
+++ b/drivers/media/video/cx18/cx18-i2c.c
@@ -25,6 +25,7 @@
25#include "cx18-cards.h" 25#include "cx18-cards.h"
26#include "cx18-gpio.h" 26#include "cx18-gpio.h"
27#include "cx18-av-core.h" 27#include "cx18-av-core.h"
28#include "cx18-i2c.h"
28 29
29#include <media/ir-kbd-i2c.h> 30#include <media/ir-kbd-i2c.h>
30 31
diff --git a/drivers/media/video/cx18/cx18-queue.c b/drivers/media/video/cx18/cx18-queue.c
index 65af1bb507ca..6990b77c6200 100644
--- a/drivers/media/video/cx18/cx18-queue.c
+++ b/drivers/media/video/cx18/cx18-queue.c
@@ -26,17 +26,6 @@
26#include "cx18-queue.h" 26#include "cx18-queue.h"
27#include "cx18-scb.h" 27#include "cx18-scb.h"
28 28
29int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
30 const char __user *src, int copybytes)
31{
32 if (s->buf_size - buf->bytesused < copybytes)
33 copybytes = s->buf_size - buf->bytesused;
34 if (copy_from_user(buf->buf + buf->bytesused, src, copybytes))
35 return -EFAULT;
36 buf->bytesused += copybytes;
37 return copybytes;
38}
39
40void cx18_buf_swap(struct cx18_buffer *buf) 29void cx18_buf_swap(struct cx18_buffer *buf)
41{ 30{
42 int i; 31 int i;
@@ -159,8 +148,9 @@ static void cx18_queue_move_buf(struct cx18_stream *s, struct cx18_queue *from,
159 -ENOMEM is returned if the buffers could not be obtained, 0 if all 148 -ENOMEM is returned if the buffers could not be obtained, 0 if all
160 buffers where obtained from the 'from' list and if non-zero then 149 buffers where obtained from the 'from' list and if non-zero then
161 the number of stolen buffers is returned. */ 150 the number of stolen buffers is returned. */
162int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from, 151static int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
163 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes) 152 struct cx18_queue *steal, struct cx18_queue *to,
153 int needed_bytes)
164{ 154{
165 unsigned long flags; 155 unsigned long flags;
166 int rc = 0; 156 int rc = 0;
@@ -239,12 +229,12 @@ int cx18_stream_alloc(struct cx18_stream *s)
239 229
240 /* allocate stream buffers. Initially all buffers are in q_free. */ 230 /* allocate stream buffers. Initially all buffers are in q_free. */
241 for (i = 0; i < s->buffers; i++) { 231 for (i = 0; i < s->buffers; i++) {
242 struct cx18_buffer *buf = 232 struct cx18_buffer *buf = kzalloc(sizeof(struct cx18_buffer),
243 kzalloc(sizeof(struct cx18_buffer), GFP_KERNEL); 233 GFP_KERNEL|__GFP_NOWARN);
244 234
245 if (buf == NULL) 235 if (buf == NULL)
246 break; 236 break;
247 buf->buf = kmalloc(s->buf_size, GFP_KERNEL); 237 buf->buf = kmalloc(s->buf_size, GFP_KERNEL|__GFP_NOWARN);
248 if (buf->buf == NULL) { 238 if (buf->buf == NULL) {
249 kfree(buf); 239 kfree(buf);
250 break; 240 break;
diff --git a/drivers/media/video/cx18/cx18-queue.h b/drivers/media/video/cx18/cx18-queue.h
index f86c8a6fa6e7..91423b9863a4 100644
--- a/drivers/media/video/cx18/cx18-queue.h
+++ b/drivers/media/video/cx18/cx18-queue.h
@@ -39,8 +39,6 @@ static inline void cx18_buf_sync_for_device(struct cx18_stream *s,
39 s->buf_size, s->dma); 39 s->buf_size, s->dma);
40} 40}
41 41
42int cx18_buf_copy_from_user(struct cx18_stream *s, struct cx18_buffer *buf,
43 const char __user *src, int copybytes);
44void cx18_buf_swap(struct cx18_buffer *buf); 42void cx18_buf_swap(struct cx18_buffer *buf);
45 43
46/* cx18_queue utility functions */ 44/* cx18_queue utility functions */
@@ -48,8 +46,6 @@ void cx18_queue_init(struct cx18_queue *q);
48void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf, 46void cx18_enqueue(struct cx18_stream *s, struct cx18_buffer *buf,
49 struct cx18_queue *q); 47 struct cx18_queue *q);
50struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q); 48struct cx18_buffer *cx18_dequeue(struct cx18_stream *s, struct cx18_queue *q);
51int cx18_queue_move(struct cx18_stream *s, struct cx18_queue *from,
52 struct cx18_queue *steal, struct cx18_queue *to, int needed_bytes);
53struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id, 49struct cx18_buffer *cx18_queue_find_buf(struct cx18_stream *s, u32 id,
54 u32 bytesused); 50 u32 bytesused);
55void cx18_flush_queues(struct cx18_stream *s); 51void cx18_flush_queues(struct cx18_stream *s);
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c
index afb141b2027a..4ca9d847f1b1 100644
--- a/drivers/media/video/cx18/cx18-streams.c
+++ b/drivers/media/video/cx18/cx18-streams.c
@@ -218,7 +218,7 @@ int cx18_streams_setup(struct cx18 *cx)
218 return 0; 218 return 0;
219 219
220 /* One or more streams could not be initialized. Clean 'em all up. */ 220 /* One or more streams could not be initialized. Clean 'em all up. */
221 cx18_streams_cleanup(cx); 221 cx18_streams_cleanup(cx, 0);
222 return -ENOMEM; 222 return -ENOMEM;
223} 223}
224 224
@@ -296,12 +296,12 @@ int cx18_streams_register(struct cx18 *cx)
296 return 0; 296 return 0;
297 297
298 /* One or more streams could not be initialized. Clean 'em all up. */ 298 /* One or more streams could not be initialized. Clean 'em all up. */
299 cx18_streams_cleanup(cx); 299 cx18_streams_cleanup(cx, 1);
300 return -ENOMEM; 300 return -ENOMEM;
301} 301}
302 302
303/* Unregister v4l2 devices */ 303/* Unregister v4l2 devices */
304void cx18_streams_cleanup(struct cx18 *cx) 304void cx18_streams_cleanup(struct cx18 *cx, int unregister)
305{ 305{
306 struct video_device *vdev; 306 struct video_device *vdev;
307 int type; 307 int type;
@@ -319,8 +319,11 @@ void cx18_streams_cleanup(struct cx18 *cx)
319 319
320 cx18_stream_free(&cx->streams[type]); 320 cx18_stream_free(&cx->streams[type]);
321 321
322 /* Unregister device */ 322 /* Unregister or release device */
323 video_unregister_device(vdev); 323 if (unregister)
324 video_unregister_device(vdev);
325 else
326 video_device_release(vdev);
324 } 327 }
325} 328}
326 329
diff --git a/drivers/media/video/cx18/cx18-streams.h b/drivers/media/video/cx18/cx18-streams.h
index 8c7ba7d2fa79..f327e947b24f 100644
--- a/drivers/media/video/cx18/cx18-streams.h
+++ b/drivers/media/video/cx18/cx18-streams.h
@@ -24,7 +24,7 @@
24u32 cx18_find_handle(struct cx18 *cx); 24u32 cx18_find_handle(struct cx18 *cx);
25int cx18_streams_setup(struct cx18 *cx); 25int cx18_streams_setup(struct cx18 *cx);
26int cx18_streams_register(struct cx18 *cx); 26int cx18_streams_register(struct cx18 *cx);
27void cx18_streams_cleanup(struct cx18 *cx); 27void cx18_streams_cleanup(struct cx18 *cx, int unregister);
28 28
29/* Capture related */ 29/* Capture related */
30int cx18_start_v4l2_encode_stream(struct cx18_stream *s); 30int cx18_start_v4l2_encode_stream(struct cx18_stream *s);
diff --git a/drivers/media/video/cx23885/Kconfig b/drivers/media/video/cx23885/Kconfig
index cadf936c3673..7bf14c9a15c7 100644
--- a/drivers/media/video/cx23885/Kconfig
+++ b/drivers/media/video/cx23885/Kconfig
@@ -1,18 +1,20 @@
1config VIDEO_CX23885 1config VIDEO_CX23885
2 tristate "Conexant cx23885 (2388x successor) support" 2 tristate "Conexant cx23885 (2388x successor) support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C && INPUT
4 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 5 select I2C_ALGOBIT
5 select FW_LOADER 6 select FW_LOADER
6 select VIDEO_BTCX 7 select VIDEO_BTCX
7 select MEDIA_TUNER 8 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 9 select VIDEO_TVEEPROM
9 select VIDEO_IR 10 select VIDEO_IR
10 select VIDEOBUF_DVB 11 select VIDEOBUF_DVB
11 select VIDEO_CX25840 12 select VIDEO_CX25840
13 select VIDEO_CX2341X
14 select DVB_DIB7000P if !DVB_FE_CUSTOMISE
12 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE 15 select MEDIA_TUNER_MT2131 if !DVB_FE_CUSTOMISE
13 select DVB_S5H1409 if !DVB_FE_CUSTOMISE 16 select DVB_S5H1409 if !DVB_FE_CUSTOMISE
14 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 17 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
15 select DVB_PLL if !DVB_FE_CUSTOMISE
16 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE 18 select MEDIA_TUNER_XC2028 if !DVB_FE_CUSTOMIZE
17 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE 19 select MEDIA_TUNER_TDA8290 if !DVB_FE_CUSTOMIZE
18 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE 20 select MEDIA_TUNER_TDA18271 if !DVB_FE_CUSTOMIZE
diff --git a/drivers/media/video/cx23885/cx23885-cards.c b/drivers/media/video/cx23885/cx23885-cards.c
index 6ebf58724a01..20e05f230546 100644
--- a/drivers/media/video/cx23885/cx23885-cards.c
+++ b/drivers/media/video/cx23885/cx23885-cards.c
@@ -200,6 +200,10 @@ struct cx23885_subid cx23885_subids[] = {
200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200, 200 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
201 }, { 201 }, {
202 .subvendor = 0x0070, 202 .subvendor = 0x0070,
203 .subdevice = 0x71d3,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1200,
205 }, {
206 .subvendor = 0x0070,
203 .subdevice = 0x8101, 207 .subdevice = 0x8101,
204 .card = CX23885_BOARD_HAUPPAUGE_HVR1700, 208 .card = CX23885_BOARD_HAUPPAUGE_HVR1700,
205 }, { 209 }, {
@@ -245,6 +249,33 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
245 /* Make sure we support the board model */ 249 /* Make sure we support the board model */
246 switch (tv.model) 250 switch (tv.model)
247 { 251 {
252 case 71009:
253 /* WinTV-HVR1200 (PCIe, Retail, full height)
254 * DVB-T and basic analog */
255 case 71359:
256 /* WinTV-HVR1200 (PCIe, OEM, half height)
257 * DVB-T and basic analog */
258 case 71439:
259 /* WinTV-HVR1200 (PCIe, OEM, half height)
260 * DVB-T and basic analog */
261 case 71449:
262 /* WinTV-HVR1200 (PCIe, OEM, full height)
263 * DVB-T and basic analog */
264 case 71939:
265 /* WinTV-HVR1200 (PCIe, OEM, half height)
266 * DVB-T and basic analog */
267 case 71949:
268 /* WinTV-HVR1200 (PCIe, OEM, full height)
269 * DVB-T and basic analog */
270 case 71959:
271 /* WinTV-HVR1200 (PCIe, OEM, full height)
272 * DVB-T and basic analog */
273 case 71979:
274 /* WinTV-HVR1200 (PCIe, OEM, half height)
275 * DVB-T and basic analog */
276 case 71999:
277 /* WinTV-HVR1200 (PCIe, OEM, full height)
278 * DVB-T and basic analog */
248 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */ 279 case 76601: /* WinTV-HVR1800lp (PCIe, Retail, No IR, Dual channel ATSC and MPEG2 HW Encoder */
249 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */ 280 case 77001: /* WinTV-HVR1500 (Express Card, OEM, No IR, ATSC and Basic analog */
250 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */ 281 case 77011: /* WinTV-HVR1500 (Express Card, Retail, No IR, ATSC and Basic analog */
@@ -263,8 +294,11 @@ static void hauppauge_eeprom(struct cx23885_dev *dev, u8 *eeprom_data)
263 case 80019: 294 case 80019:
264 /* WinTV-HVR1400 (Express Card, Retail, IR, 295 /* WinTV-HVR1400 (Express Card, Retail, IR,
265 * DVB-T and Basic analog */ 296 * DVB-T and Basic analog */
297 case 81509:
298 /* WinTV-HVR1700 (PCIe, OEM, No IR, half height)
299 * DVB-T and MPEG2 HW Encoder */
266 case 81519: 300 case 81519:
267 /* WinTV-HVR1700 (PCIe, Retail, No IR, half height, 301 /* WinTV-HVR1700 (PCIe, OEM, No IR, full height)
268 * DVB-T and MPEG2 HW Encoder */ 302 * DVB-T and MPEG2 HW Encoder */
269 break; 303 break;
270 default: 304 default:
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c
index f05649727b60..022aa391937a 100644
--- a/drivers/media/video/cx23885/cx23885-dvb.c
+++ b/drivers/media/video/cx23885/cx23885-dvb.c
@@ -37,7 +37,6 @@
37#include "lgdt330x.h" 37#include "lgdt330x.h"
38#include "xc5000.h" 38#include "xc5000.h"
39#include "tda10048.h" 39#include "tda10048.h"
40#include "dvb-pll.h"
41#include "tuner-xc2028.h" 40#include "tuner-xc2028.h"
42#include "tuner-simple.h" 41#include "tuner-simple.h"
43#include "dib7000p.h" 42#include "dib7000p.h"
@@ -385,12 +384,10 @@ static int dvb_register(struct cx23885_tsport *port)
385 port->dvb.frontend = dvb_attach(s5h1409_attach, 384 port->dvb.frontend = dvb_attach(s5h1409_attach,
386 &hauppauge_hvr1500q_config, 385 &hauppauge_hvr1500q_config,
387 &dev->i2c_bus[0].i2c_adap); 386 &dev->i2c_bus[0].i2c_adap);
388 if (port->dvb.frontend != NULL) { 387 if (port->dvb.frontend != NULL)
389 hauppauge_hvr1500q_tunerconfig.priv = i2c_bus;
390 dvb_attach(xc5000_attach, port->dvb.frontend, 388 dvb_attach(xc5000_attach, port->dvb.frontend,
391 &i2c_bus->i2c_adap, 389 &i2c_bus->i2c_adap,
392 &hauppauge_hvr1500q_tunerconfig); 390 &hauppauge_hvr1500q_tunerconfig, i2c_bus);
393 }
394 break; 391 break;
395 case CX23885_BOARD_HAUPPAUGE_HVR1500: 392 case CX23885_BOARD_HAUPPAUGE_HVR1500:
396 i2c_bus = &dev->i2c_bus[1]; 393 i2c_bus = &dev->i2c_bus[1];
diff --git a/drivers/media/video/cx25840/Kconfig b/drivers/media/video/cx25840/Kconfig
index 7cf29a03ed63..448f4cd0ce34 100644
--- a/drivers/media/video/cx25840/Kconfig
+++ b/drivers/media/video/cx25840/Kconfig
@@ -1,6 +1,7 @@
1config VIDEO_CX25840 1config VIDEO_CX25840
2 tristate "Conexant CX2584x audio/video decoders" 2 tristate "Conexant CX2584x audio/video decoders"
3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L2 && I2C && EXPERIMENTAL
4 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 5 select FW_LOADER
5 ---help--- 6 ---help---
6 Support for the Conexant CX2584x audio/video decoders. 7 Support for the Conexant CX2584x audio/video decoders.
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index b0d7d6a7a4cc..10e20d8196dc 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -2,10 +2,9 @@ config VIDEO_CX88
2 tristate "Conexant 2388x (bt878 successor) support" 2 tristate "Conexant 2388x (bt878 successor) support"
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select I2C_ALGOBIT 4 select I2C_ALGOBIT
5 select FW_LOADER
6 select VIDEO_BTCX 5 select VIDEO_BTCX
7 select VIDEOBUF_DMA_SG 6 select VIDEOBUF_DMA_SG
8 select MEDIA_TUNER 7 select VIDEO_TUNER
9 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
10 select VIDEO_IR 9 select VIDEO_IR
11 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO 10 select VIDEO_WM8775 if VIDEO_HELPER_CHIPS_AUTO
@@ -34,8 +33,9 @@ config VIDEO_CX88_ALSA
34 33
35config VIDEO_CX88_BLACKBIRD 34config VIDEO_CX88_BLACKBIRD
36 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)" 35 tristate "Blackbird MPEG encoder support (cx2388x + cx23416)"
37 depends on VIDEO_CX88 36 depends on VIDEO_CX88 && HOTPLUG
38 select VIDEO_CX2341X 37 select VIDEO_CX2341X
38 select FW_LOADER
39 ---help--- 39 ---help---
40 This adds support for MPEG encoder cards based on the 40 This adds support for MPEG encoder cards based on the
41 Blackbird reference design, using the Conexant 2388x 41 Blackbird reference design, using the Conexant 2388x
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 1c7fe6862a60..d96173ff1dba 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -509,9 +509,6 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
509 if (!fe) { 509 if (!fe) {
510 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 510 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
511 dev->core->name); 511 dev->core->name);
512 dvb_frontend_detach(dev->dvb.frontend);
513 dvb_unregister_frontend(dev->dvb.frontend);
514 dev->dvb.frontend = NULL;
515 return -EINVAL; 512 return -EINVAL;
516 } 513 }
517 514
@@ -523,20 +520,23 @@ static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
523 520
524static int dvb_register(struct cx8802_dev *dev) 521static int dvb_register(struct cx8802_dev *dev)
525{ 522{
523 struct cx88_core *core = dev->core;
524
526 /* init struct videobuf_dvb */ 525 /* init struct videobuf_dvb */
527 dev->dvb.name = dev->core->name; 526 dev->dvb.name = core->name;
528 dev->ts_gen_cntrl = 0x0c; 527 dev->ts_gen_cntrl = 0x0c;
529 528
530 /* init frontend */ 529 /* init frontend */
531 switch (dev->core->boardnr) { 530 switch (core->boardnr) {
532 case CX88_BOARD_HAUPPAUGE_DVB_T1: 531 case CX88_BOARD_HAUPPAUGE_DVB_T1:
533 dev->dvb.frontend = dvb_attach(cx22702_attach, 532 dev->dvb.frontend = dvb_attach(cx22702_attach,
534 &connexant_refboard_config, 533 &connexant_refboard_config,
535 &dev->core->i2c_adap); 534 &core->i2c_adap);
536 if (dev->dvb.frontend != NULL) { 535 if (dev->dvb.frontend != NULL) {
537 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 536 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
538 &dev->core->i2c_adap, 537 0x61, &core->i2c_adap,
539 DVB_PLL_THOMSON_DTT759X); 538 DVB_PLL_THOMSON_DTT759X))
539 goto frontend_detach;
540 } 540 }
541 break; 541 break;
542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1: 542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
@@ -545,11 +545,12 @@ static int dvb_register(struct cx8802_dev *dev)
545 case CX88_BOARD_WINFAST_DTV1000: 545 case CX88_BOARD_WINFAST_DTV1000:
546 dev->dvb.frontend = dvb_attach(cx22702_attach, 546 dev->dvb.frontend = dvb_attach(cx22702_attach,
547 &connexant_refboard_config, 547 &connexant_refboard_config,
548 &dev->core->i2c_adap); 548 &core->i2c_adap);
549 if (dev->dvb.frontend != NULL) { 549 if (dev->dvb.frontend != NULL) {
550 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 550 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
551 &dev->core->i2c_adap, 551 0x60, &core->i2c_adap,
552 DVB_PLL_THOMSON_DTT7579); 552 DVB_PLL_THOMSON_DTT7579))
553 goto frontend_detach;
553 } 554 }
554 break; 555 break;
555 case CX88_BOARD_WINFAST_DTV2000H: 556 case CX88_BOARD_WINFAST_DTV2000H:
@@ -559,29 +560,32 @@ static int dvb_register(struct cx8802_dev *dev)
559 case CX88_BOARD_HAUPPAUGE_HVR3000: 560 case CX88_BOARD_HAUPPAUGE_HVR3000:
560 dev->dvb.frontend = dvb_attach(cx22702_attach, 561 dev->dvb.frontend = dvb_attach(cx22702_attach,
561 &hauppauge_hvr_config, 562 &hauppauge_hvr_config,
562 &dev->core->i2c_adap); 563 &core->i2c_adap);
563 if (dev->dvb.frontend != NULL) { 564 if (dev->dvb.frontend != NULL) {
564 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 565 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
565 &dev->core->i2c_adap, 0x61, 566 &core->i2c_adap, 0x61,
566 TUNER_PHILIPS_FMD1216ME_MK3); 567 TUNER_PHILIPS_FMD1216ME_MK3))
568 goto frontend_detach;
567 } 569 }
568 break; 570 break;
569 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 571 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
570 dev->dvb.frontend = dvb_attach(mt352_attach, 572 dev->dvb.frontend = dvb_attach(mt352_attach,
571 &dvico_fusionhdtv, 573 &dvico_fusionhdtv,
572 &dev->core->i2c_adap); 574 &core->i2c_adap);
573 if (dev->dvb.frontend != NULL) { 575 if (dev->dvb.frontend != NULL) {
574 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 576 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
575 NULL, DVB_PLL_THOMSON_DTT7579); 577 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
578 goto frontend_detach;
576 break; 579 break;
577 } 580 }
578 /* ZL10353 replaces MT352 on later cards */ 581 /* ZL10353 replaces MT352 on later cards */
579 dev->dvb.frontend = dvb_attach(zl10353_attach, 582 dev->dvb.frontend = dvb_attach(zl10353_attach,
580 &dvico_fusionhdtv_plus_v1_1, 583 &dvico_fusionhdtv_plus_v1_1,
581 &dev->core->i2c_adap); 584 &core->i2c_adap);
582 if (dev->dvb.frontend != NULL) { 585 if (dev->dvb.frontend != NULL) {
583 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 586 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
584 NULL, DVB_PLL_THOMSON_DTT7579); 587 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
588 goto frontend_detach;
585 } 589 }
586 break; 590 break;
587 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL: 591 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
@@ -589,28 +593,31 @@ static int dvb_register(struct cx8802_dev *dev)
589 * compatible, with a slightly different MT352 AGC gain. */ 593 * compatible, with a slightly different MT352 AGC gain. */
590 dev->dvb.frontend = dvb_attach(mt352_attach, 594 dev->dvb.frontend = dvb_attach(mt352_attach,
591 &dvico_fusionhdtv_dual, 595 &dvico_fusionhdtv_dual,
592 &dev->core->i2c_adap); 596 &core->i2c_adap);
593 if (dev->dvb.frontend != NULL) { 597 if (dev->dvb.frontend != NULL) {
594 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 598 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
595 NULL, DVB_PLL_THOMSON_DTT7579); 599 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
600 goto frontend_detach;
596 break; 601 break;
597 } 602 }
598 /* ZL10353 replaces MT352 on later cards */ 603 /* ZL10353 replaces MT352 on later cards */
599 dev->dvb.frontend = dvb_attach(zl10353_attach, 604 dev->dvb.frontend = dvb_attach(zl10353_attach,
600 &dvico_fusionhdtv_plus_v1_1, 605 &dvico_fusionhdtv_plus_v1_1,
601 &dev->core->i2c_adap); 606 &core->i2c_adap);
602 if (dev->dvb.frontend != NULL) { 607 if (dev->dvb.frontend != NULL) {
603 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 608 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
604 NULL, DVB_PLL_THOMSON_DTT7579); 609 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
610 goto frontend_detach;
605 } 611 }
606 break; 612 break;
607 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 613 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
608 dev->dvb.frontend = dvb_attach(mt352_attach, 614 dev->dvb.frontend = dvb_attach(mt352_attach,
609 &dvico_fusionhdtv, 615 &dvico_fusionhdtv,
610 &dev->core->i2c_adap); 616 &core->i2c_adap);
611 if (dev->dvb.frontend != NULL) { 617 if (dev->dvb.frontend != NULL) {
612 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 618 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
613 NULL, DVB_PLL_LG_Z201); 619 0x61, NULL, DVB_PLL_LG_Z201))
620 goto frontend_detach;
614 } 621 }
615 break; 622 break;
616 case CX88_BOARD_KWORLD_DVB_T: 623 case CX88_BOARD_KWORLD_DVB_T:
@@ -618,10 +625,11 @@ static int dvb_register(struct cx8802_dev *dev)
618 case CX88_BOARD_ADSTECH_DVB_T_PCI: 625 case CX88_BOARD_ADSTECH_DVB_T_PCI:
619 dev->dvb.frontend = dvb_attach(mt352_attach, 626 dev->dvb.frontend = dvb_attach(mt352_attach,
620 &dntv_live_dvbt_config, 627 &dntv_live_dvbt_config,
621 &dev->core->i2c_adap); 628 &core->i2c_adap);
622 if (dev->dvb.frontend != NULL) { 629 if (dev->dvb.frontend != NULL) {
623 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 630 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
624 NULL, DVB_PLL_UNKNOWN_1); 631 0x61, NULL, DVB_PLL_UNKNOWN_1))
632 goto frontend_detach;
625 } 633 }
626 break; 634 break;
627 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO: 635 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
@@ -630,32 +638,35 @@ static int dvb_register(struct cx8802_dev *dev)
630 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config, 638 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
631 &dev->vp3054->adap); 639 &dev->vp3054->adap);
632 if (dev->dvb.frontend != NULL) { 640 if (dev->dvb.frontend != NULL) {
633 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 641 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
634 &dev->core->i2c_adap, 0x61, 642 &core->i2c_adap, 0x61,
635 TUNER_PHILIPS_FMD1216ME_MK3); 643 TUNER_PHILIPS_FMD1216ME_MK3))
644 goto frontend_detach;
636 } 645 }
637#else 646#else
638 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name); 647 printk(KERN_ERR "%s/2: built without vp3054 support\n",
648 core->name);
639#endif 649#endif
640 break; 650 break;
641 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID: 651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
642 dev->dvb.frontend = dvb_attach(zl10353_attach, 652 dev->dvb.frontend = dvb_attach(zl10353_attach,
643 &dvico_fusionhdtv_hybrid, 653 &dvico_fusionhdtv_hybrid,
644 &dev->core->i2c_adap); 654 &core->i2c_adap);
645 if (dev->dvb.frontend != NULL) { 655 if (dev->dvb.frontend != NULL) {
646 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 656 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
647 &dev->core->i2c_adap, 0x61, 657 &core->i2c_adap, 0x61,
648 TUNER_THOMSON_FE6600); 658 TUNER_THOMSON_FE6600))
659 goto frontend_detach;
649 } 660 }
650 break; 661 break;
651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: 662 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
652 dev->dvb.frontend = dvb_attach(zl10353_attach, 663 dev->dvb.frontend = dvb_attach(zl10353_attach,
653 &dvico_fusionhdtv_xc3028, 664 &dvico_fusionhdtv_xc3028,
654 &dev->core->i2c_adap); 665 &core->i2c_adap);
655 if (dev->dvb.frontend == NULL) 666 if (dev->dvb.frontend == NULL)
656 dev->dvb.frontend = dvb_attach(mt352_attach, 667 dev->dvb.frontend = dvb_attach(mt352_attach,
657 &dvico_fusionhdtv_mt352_xc3028, 668 &dvico_fusionhdtv_mt352_xc3028,
658 &dev->core->i2c_adap); 669 &core->i2c_adap);
659 /* 670 /*
660 * On this board, the demod provides the I2C bus pullup. 671 * On this board, the demod provides the I2C bus pullup.
661 * We must not permit gate_ctrl to be performed, or 672 * We must not permit gate_ctrl to be performed, or
@@ -668,19 +679,18 @@ static int dvb_register(struct cx8802_dev *dev)
668 break; 679 break;
669 case CX88_BOARD_PCHDTV_HD3000: 680 case CX88_BOARD_PCHDTV_HD3000:
670 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000, 681 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
671 &dev->core->i2c_adap); 682 &core->i2c_adap);
672 if (dev->dvb.frontend != NULL) { 683 if (dev->dvb.frontend != NULL) {
673 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 684 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
674 &dev->core->i2c_adap, 0x61, 685 &core->i2c_adap, 0x61,
675 TUNER_THOMSON_DTT761X); 686 TUNER_THOMSON_DTT761X))
687 goto frontend_detach;
676 } 688 }
677 break; 689 break;
678 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q: 690 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
679 dev->ts_gen_cntrl = 0x08; 691 dev->ts_gen_cntrl = 0x08;
680 {
681 /* Do a hardware reset of chip before using it. */
682 struct cx88_core *core = dev->core;
683 692
693 /* Do a hardware reset of chip before using it. */
684 cx_clear(MO_GP0_IO, 1); 694 cx_clear(MO_GP0_IO, 1);
685 mdelay(100); 695 mdelay(100);
686 cx_set(MO_GP0_IO, 1); 696 cx_set(MO_GP0_IO, 1);
@@ -690,139 +700,137 @@ static int dvb_register(struct cx8802_dev *dev)
690 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set; 700 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
691 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 701 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
692 &fusionhdtv_3_gold, 702 &fusionhdtv_3_gold,
693 &dev->core->i2c_adap); 703 &core->i2c_adap);
694 if (dev->dvb.frontend != NULL) { 704 if (dev->dvb.frontend != NULL) {
695 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 705 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
696 &dev->core->i2c_adap, 0x61, 706 &core->i2c_adap, 0x61,
697 TUNER_MICROTUNE_4042FI5); 707 TUNER_MICROTUNE_4042FI5))
698 } 708 goto frontend_detach;
699 } 709 }
700 break; 710 break;
701 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T: 711 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
702 dev->ts_gen_cntrl = 0x08; 712 dev->ts_gen_cntrl = 0x08;
703 {
704 /* Do a hardware reset of chip before using it. */
705 struct cx88_core *core = dev->core;
706 713
714 /* Do a hardware reset of chip before using it. */
707 cx_clear(MO_GP0_IO, 1); 715 cx_clear(MO_GP0_IO, 1);
708 mdelay(100); 716 mdelay(100);
709 cx_set(MO_GP0_IO, 9); 717 cx_set(MO_GP0_IO, 9);
710 mdelay(200); 718 mdelay(200);
711 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 719 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
712 &fusionhdtv_3_gold, 720 &fusionhdtv_3_gold,
713 &dev->core->i2c_adap); 721 &core->i2c_adap);
714 if (dev->dvb.frontend != NULL) { 722 if (dev->dvb.frontend != NULL) {
715 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 723 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
716 &dev->core->i2c_adap, 0x61, 724 &core->i2c_adap, 0x61,
717 TUNER_THOMSON_DTT761X); 725 TUNER_THOMSON_DTT761X))
718 } 726 goto frontend_detach;
719 } 727 }
720 break; 728 break;
721 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD: 729 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
722 dev->ts_gen_cntrl = 0x08; 730 dev->ts_gen_cntrl = 0x08;
723 {
724 /* Do a hardware reset of chip before using it. */
725 struct cx88_core *core = dev->core;
726 731
732 /* Do a hardware reset of chip before using it. */
727 cx_clear(MO_GP0_IO, 1); 733 cx_clear(MO_GP0_IO, 1);
728 mdelay(100); 734 mdelay(100);
729 cx_set(MO_GP0_IO, 1); 735 cx_set(MO_GP0_IO, 1);
730 mdelay(200); 736 mdelay(200);
731 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 737 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
732 &fusionhdtv_5_gold, 738 &fusionhdtv_5_gold,
733 &dev->core->i2c_adap); 739 &core->i2c_adap);
734 if (dev->dvb.frontend != NULL) { 740 if (dev->dvb.frontend != NULL) {
735 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 741 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
736 &dev->core->i2c_adap, 0x61, 742 &core->i2c_adap, 0x61,
737 TUNER_LG_TDVS_H06XF); 743 TUNER_LG_TDVS_H06XF))
738 dvb_attach(tda9887_attach, dev->dvb.frontend, 744 goto frontend_detach;
739 &dev->core->i2c_adap, 0x43); 745 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
740 } 746 &core->i2c_adap, 0x43))
747 goto frontend_detach;
741 } 748 }
742 break; 749 break;
743 case CX88_BOARD_PCHDTV_HD5500: 750 case CX88_BOARD_PCHDTV_HD5500:
744 dev->ts_gen_cntrl = 0x08; 751 dev->ts_gen_cntrl = 0x08;
745 {
746 /* Do a hardware reset of chip before using it. */
747 struct cx88_core *core = dev->core;
748 752
753 /* Do a hardware reset of chip before using it. */
749 cx_clear(MO_GP0_IO, 1); 754 cx_clear(MO_GP0_IO, 1);
750 mdelay(100); 755 mdelay(100);
751 cx_set(MO_GP0_IO, 1); 756 cx_set(MO_GP0_IO, 1);
752 mdelay(200); 757 mdelay(200);
753 dev->dvb.frontend = dvb_attach(lgdt330x_attach, 758 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
754 &pchdtv_hd5500, 759 &pchdtv_hd5500,
755 &dev->core->i2c_adap); 760 &core->i2c_adap);
756 if (dev->dvb.frontend != NULL) { 761 if (dev->dvb.frontend != NULL) {
757 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 762 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
758 &dev->core->i2c_adap, 0x61, 763 &core->i2c_adap, 0x61,
759 TUNER_LG_TDVS_H06XF); 764 TUNER_LG_TDVS_H06XF))
760 dvb_attach(tda9887_attach, dev->dvb.frontend, 765 goto frontend_detach;
761 &dev->core->i2c_adap, 0x43); 766 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
762 } 767 &core->i2c_adap, 0x43))
768 goto frontend_detach;
763 } 769 }
764 break; 770 break;
765 case CX88_BOARD_ATI_HDTVWONDER: 771 case CX88_BOARD_ATI_HDTVWONDER:
766 dev->dvb.frontend = dvb_attach(nxt200x_attach, 772 dev->dvb.frontend = dvb_attach(nxt200x_attach,
767 &ati_hdtvwonder, 773 &ati_hdtvwonder,
768 &dev->core->i2c_adap); 774 &core->i2c_adap);
769 if (dev->dvb.frontend != NULL) { 775 if (dev->dvb.frontend != NULL) {
770 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 776 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
771 &dev->core->i2c_adap, 0x61, 777 &core->i2c_adap, 0x61,
772 TUNER_PHILIPS_TUV1236D); 778 TUNER_PHILIPS_TUV1236D))
779 goto frontend_detach;
773 } 780 }
774 break; 781 break;
775 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1: 782 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
776 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1: 783 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
777 dev->dvb.frontend = dvb_attach(cx24123_attach, 784 dev->dvb.frontend = dvb_attach(cx24123_attach,
778 &hauppauge_novas_config, 785 &hauppauge_novas_config,
779 &dev->core->i2c_adap); 786 &core->i2c_adap);
780 if (dev->dvb.frontend) { 787 if (dev->dvb.frontend) {
781 dvb_attach(isl6421_attach, dev->dvb.frontend, 788 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
782 &dev->core->i2c_adap, 0x08, 0x00, 0x00); 789 &core->i2c_adap, 0x08, 0x00, 0x00))
790 goto frontend_detach;
783 } 791 }
784 break; 792 break;
785 case CX88_BOARD_KWORLD_DVBS_100: 793 case CX88_BOARD_KWORLD_DVBS_100:
786 dev->dvb.frontend = dvb_attach(cx24123_attach, 794 dev->dvb.frontend = dvb_attach(cx24123_attach,
787 &kworld_dvbs_100_config, 795 &kworld_dvbs_100_config,
788 &dev->core->i2c_adap); 796 &core->i2c_adap);
789 if (dev->dvb.frontend) { 797 if (dev->dvb.frontend) {
790 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 798 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
791 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage; 799 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
792 } 800 }
793 break; 801 break;
794 case CX88_BOARD_GENIATECH_DVBS: 802 case CX88_BOARD_GENIATECH_DVBS:
795 dev->dvb.frontend = dvb_attach(cx24123_attach, 803 dev->dvb.frontend = dvb_attach(cx24123_attach,
796 &geniatech_dvbs_config, 804 &geniatech_dvbs_config,
797 &dev->core->i2c_adap); 805 &core->i2c_adap);
798 if (dev->dvb.frontend) { 806 if (dev->dvb.frontend) {
799 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage; 807 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
800 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage; 808 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
801 } 809 }
802 break; 810 break;
803 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 811 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
804 dev->dvb.frontend = dvb_attach(s5h1409_attach, 812 dev->dvb.frontend = dvb_attach(s5h1409_attach,
805 &pinnacle_pctv_hd_800i_config, 813 &pinnacle_pctv_hd_800i_config,
806 &dev->core->i2c_adap); 814 &core->i2c_adap);
807 if (dev->dvb.frontend != NULL) { 815 if (dev->dvb.frontend != NULL) {
808 /* tuner_config.video_dev must point to 816 /* tuner_config.video_dev must point to
809 * i2c_adap.algo_data 817 * i2c_adap.algo_data
810 */ 818 */
811 pinnacle_pctv_hd_800i_tuner_config.priv = 819 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
812 dev->core->i2c_adap.algo_data; 820 &core->i2c_adap,
813 dvb_attach(xc5000_attach, dev->dvb.frontend, 821 &pinnacle_pctv_hd_800i_tuner_config,
814 &dev->core->i2c_adap, 822 core->i2c_adap.algo_data))
815 &pinnacle_pctv_hd_800i_tuner_config); 823 goto frontend_detach;
816 } 824 }
817 break; 825 break;
818 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 826 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
819 dev->dvb.frontend = dvb_attach(s5h1409_attach, 827 dev->dvb.frontend = dvb_attach(s5h1409_attach,
820 &dvico_hdtv5_pci_nano_config, 828 &dvico_hdtv5_pci_nano_config,
821 &dev->core->i2c_adap); 829 &core->i2c_adap);
822 if (dev->dvb.frontend != NULL) { 830 if (dev->dvb.frontend != NULL) {
823 struct dvb_frontend *fe; 831 struct dvb_frontend *fe;
824 struct xc2028_config cfg = { 832 struct xc2028_config cfg = {
825 .i2c_adap = &dev->core->i2c_adap, 833 .i2c_adap = &core->i2c_adap,
826 .i2c_addr = 0x61, 834 .i2c_addr = 0x61,
827 .callback = cx88_pci_nano_callback, 835 .callback = cx88_pci_nano_callback,
828 }; 836 };
@@ -841,50 +849,50 @@ static int dvb_register(struct cx8802_dev *dev)
841 case CX88_BOARD_PINNACLE_HYBRID_PCTV: 849 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
842 dev->dvb.frontend = dvb_attach(zl10353_attach, 850 dev->dvb.frontend = dvb_attach(zl10353_attach,
843 &cx88_geniatech_x8000_mt, 851 &cx88_geniatech_x8000_mt,
844 &dev->core->i2c_adap); 852 &core->i2c_adap);
845 if (attach_xc3028(0x61, dev) < 0) 853 if (attach_xc3028(0x61, dev) < 0)
846 return -EINVAL; 854 goto frontend_detach;
847 break; 855 break;
848 case CX88_BOARD_GENIATECH_X8000_MT: 856 case CX88_BOARD_GENIATECH_X8000_MT:
849 dev->ts_gen_cntrl = 0x00; 857 dev->ts_gen_cntrl = 0x00;
850 858
851 dev->dvb.frontend = dvb_attach(zl10353_attach, 859 dev->dvb.frontend = dvb_attach(zl10353_attach,
852 &cx88_geniatech_x8000_mt, 860 &cx88_geniatech_x8000_mt,
853 &dev->core->i2c_adap); 861 &core->i2c_adap);
854 if (attach_xc3028(0x61, dev) < 0) 862 if (attach_xc3028(0x61, dev) < 0)
855 return -EINVAL; 863 goto frontend_detach;
856 break; 864 break;
857 case CX88_BOARD_KWORLD_ATSC_120: 865 case CX88_BOARD_KWORLD_ATSC_120:
858 dev->dvb.frontend = dvb_attach(s5h1409_attach, 866 dev->dvb.frontend = dvb_attach(s5h1409_attach,
859 &kworld_atsc_120_config, 867 &kworld_atsc_120_config,
860 &dev->core->i2c_adap); 868 &core->i2c_adap);
861 if (attach_xc3028(0x61, dev) < 0) 869 if (attach_xc3028(0x61, dev) < 0)
862 return -EINVAL; 870 goto frontend_detach;
863 break; 871 break;
864 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD: 872 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
865 dev->dvb.frontend = dvb_attach(s5h1411_attach, 873 dev->dvb.frontend = dvb_attach(s5h1411_attach,
866 &dvico_fusionhdtv7_config, 874 &dvico_fusionhdtv7_config,
867 &dev->core->i2c_adap); 875 &core->i2c_adap);
868 if (dev->dvb.frontend != NULL) { 876 if (dev->dvb.frontend != NULL) {
869 /* tuner_config.video_dev must point to 877 /* tuner_config.video_dev must point to
870 * i2c_adap.algo_data 878 * i2c_adap.algo_data
871 */ 879 */
872 dvico_fusionhdtv7_tuner_config.priv = 880 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
873 dev->core->i2c_adap.algo_data; 881 &core->i2c_adap,
874 dvb_attach(xc5000_attach, dev->dvb.frontend, 882 &dvico_fusionhdtv7_tuner_config,
875 &dev->core->i2c_adap, 883 core->i2c_adap.algo_data))
876 &dvico_fusionhdtv7_tuner_config); 884 goto frontend_detach;
877 } 885 }
878 break; 886 break;
879 default: 887 default:
880 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n", 888 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
881 dev->core->name); 889 core->name);
882 break; 890 break;
883 } 891 }
884 if (NULL == dev->dvb.frontend) { 892 if (NULL == dev->dvb.frontend) {
885 printk(KERN_ERR 893 printk(KERN_ERR
886 "%s/2: frontend initialization failed\n", 894 "%s/2: frontend initialization failed\n",
887 dev->core->name); 895 core->name);
888 return -EINVAL; 896 return -EINVAL;
889 } 897 }
890 898
@@ -892,11 +900,18 @@ static int dvb_register(struct cx8802_dev *dev)
892 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl; 900 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
893 901
894 /* Put the analog decoder in standby to keep it quiet */ 902 /* Put the analog decoder in standby to keep it quiet */
895 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); 903 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
896 904
897 /* register everything */ 905 /* register everything */
898 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, 906 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
899 &dev->pci->dev, adapter_nr); 907 &dev->pci->dev, adapter_nr);
908
909frontend_detach:
910 if (dev->dvb.frontend) {
911 dvb_frontend_detach(dev->dvb.frontend);
912 dev->dvb.frontend = NULL;
913 }
914 return -EINVAL;
900} 915}
901 916
902/* ----------------------------------------------------------- */ 917/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/Kconfig b/drivers/media/video/em28xx/Kconfig
index c7c2896bbd8b..16a5af30e9d1 100644
--- a/drivers/media/video/em28xx/Kconfig
+++ b/drivers/media/video/em28xx/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_EM28XX 1config VIDEO_EM28XX
2 tristate "Empia EM28xx USB video capture support" 2 tristate "Empia EM28xx USB video capture support"
3 depends on VIDEO_DEV && I2C && INPUT 3 depends on VIDEO_DEV && I2C && INPUT
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_TVEEPROM 5 select VIDEO_TVEEPROM
6 select VIDEO_IR 6 select VIDEO_IR
7 select VIDEOBUF_VMALLOC 7 select VIDEOBUF_VMALLOC
@@ -35,7 +35,6 @@ config VIDEO_EM28XX_DVB
35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE 35 select DVB_LGDT330X if !DVB_FE_CUSTOMISE
36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE 36 select DVB_ZL10353 if !DVB_FE_CUSTOMISE
37 select VIDEOBUF_DVB 37 select VIDEOBUF_DVB
38 select FW_LOADER
39 ---help--- 38 ---help---
40 This adds support for DVB cards based on the 39 This adds support for DVB cards based on the
41 Empiatech em28xx chips. 40 Empiatech em28xx chips.
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 50ccf3771204..3e4f3c7e92e7 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -420,7 +420,13 @@ struct usb_device_id em28xx_id_table [] = {
420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 420 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
421 { USB_DEVICE(0x2040, 0x6502), 421 { USB_DEVICE(0x2040, 0x6502),
422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 }, 422 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
423 { USB_DEVICE(0x2040, 0x6513), 423 { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x2040, 0x6517), /* HP HVR-950 */
426 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
427 { USB_DEVICE(0x2040, 0x651b), /* RP HVR-950 */
428 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
429 { USB_DEVICE(0x2040, 0x651f), /* HCW HVR-850 */
424 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 }, 430 .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_950 },
425 { USB_DEVICE(0x0ccd, 0x0042), 431 { USB_DEVICE(0x0ccd, 0x0042),
426 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS }, 432 .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index 7df81575b7f2..8cf4983f0039 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -251,7 +251,6 @@ static int attach_xc3028(u8 addr, struct em28xx *dev)
251 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 251 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
252 dev->name); 252 dev->name);
253 dvb_frontend_detach(dev->dvb->frontend); 253 dvb_frontend_detach(dev->dvb->frontend);
254 dvb_unregister_frontend(dev->dvb->frontend);
255 dev->dvb->frontend = NULL; 254 dev->dvb->frontend = NULL;
256 return -EINVAL; 255 return -EINVAL;
257 } 256 }
diff --git a/drivers/media/video/ivtv/Kconfig b/drivers/media/video/ivtv/Kconfig
index eec115bf9517..5d7ee8fcdd50 100644
--- a/drivers/media/video/ivtv/Kconfig
+++ b/drivers/media/video/ivtv/Kconfig
@@ -1,10 +1,12 @@
1config VIDEO_IVTV 1config VIDEO_IVTV
2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support" 2 tristate "Conexant cx23416/cx23415 MPEG encoder/decoder support"
3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL 3 depends on VIDEO_V4L1 && VIDEO_V4L2 && PCI && I2C && EXPERIMENTAL
4 depends on INPUT # due to VIDEO_IR
5 depends on HOTPLUG # due to FW_LOADER
4 select I2C_ALGOBIT 6 select I2C_ALGOBIT
5 select FW_LOADER 7 select FW_LOADER
6 select VIDEO_IR 8 select VIDEO_IR
7 select MEDIA_TUNER 9 select VIDEO_TUNER
8 select VIDEO_TVEEPROM 10 select VIDEO_TVEEPROM
9 select VIDEO_CX2341X 11 select VIDEO_CX2341X
10 select VIDEO_CX25840 12 select VIDEO_CX25840
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c
index 8c02fa661591..c7e449f6397b 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -181,12 +181,12 @@ static int ivtv_setup_vbi_fmt(struct ivtv *itv, enum v4l2_mpeg_stream_vbi_fmt fm
181 return 0; 181 return 0;
182 } 182 }
183 /* Need sliced data for mpeg insertion */ 183 /* Need sliced data for mpeg insertion */
184 if (get_service_set(itv->vbi.sliced_in) == 0) { 184 if (ivtv_get_service_set(itv->vbi.sliced_in) == 0) {
185 if (itv->is_60hz) 185 if (itv->is_60hz)
186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525; 186 itv->vbi.sliced_in->service_set = V4L2_SLICED_CAPTION_525;
187 else 187 else
188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625; 188 itv->vbi.sliced_in->service_set = V4L2_SLICED_WSS_625;
189 expand_service_set(itv->vbi.sliced_in, itv->is_50hz); 189 ivtv_expand_service_set(itv->vbi.sliced_in, itv->is_50hz);
190 } 190 }
191 return 0; 191 return 0;
192} 192}
diff --git a/drivers/media/video/ivtv/ivtv-driver.c b/drivers/media/video/ivtv/ivtv-driver.c
index ed020f722b05..797e636771da 100644
--- a/drivers/media/video/ivtv/ivtv-driver.c
+++ b/drivers/media/video/ivtv/ivtv-driver.c
@@ -853,6 +853,7 @@ static int ivtv_setup_pci(struct ivtv *itv, struct pci_dev *dev,
853 return 0; 853 return 0;
854} 854}
855 855
856#ifdef MODULE
856static u32 ivtv_request_module(struct ivtv *itv, u32 hw, 857static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
857 const char *name, u32 id) 858 const char *name, u32 id)
858{ 859{
@@ -865,12 +866,14 @@ static u32 ivtv_request_module(struct ivtv *itv, u32 hw,
865 IVTV_DEBUG_INFO("Loaded module %s\n", name); 866 IVTV_DEBUG_INFO("Loaded module %s\n", name);
866 return hw; 867 return hw;
867} 868}
869#endif
868 870
869static void ivtv_load_and_init_modules(struct ivtv *itv) 871static void ivtv_load_and_init_modules(struct ivtv *itv)
870{ 872{
871 u32 hw = itv->card->hw_all; 873 u32 hw = itv->card->hw_all;
872 unsigned i; 874 unsigned i;
873 875
876#ifdef MODULE
874 /* load modules */ 877 /* load modules */
875#ifndef CONFIG_MEDIA_TUNER 878#ifndef CONFIG_MEDIA_TUNER
876 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER); 879 hw = ivtv_request_module(itv, hw, "tuner", IVTV_HW_TUNER);
@@ -911,6 +914,7 @@ static void ivtv_load_and_init_modules(struct ivtv *itv)
911#ifndef CONFIG_VIDEO_M52790 914#ifndef CONFIG_VIDEO_M52790
912 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790); 915 hw = ivtv_request_module(itv, hw, "m52790", IVTV_HW_M52790);
913#endif 916#endif
917#endif
914 918
915 /* check which i2c devices are actually found */ 919 /* check which i2c devices are actually found */
916 for (i = 0; i < 32; i++) { 920 for (i = 0; i < 32; i++) {
@@ -1228,7 +1232,7 @@ static int __devinit ivtv_probe(struct pci_dev *dev,
1228 return 0; 1232 return 0;
1229 1233
1230free_streams: 1234free_streams:
1231 ivtv_streams_cleanup(itv); 1235 ivtv_streams_cleanup(itv, 1);
1232free_irq: 1236free_irq:
1233 free_irq(itv->dev->irq, (void *)itv); 1237 free_irq(itv->dev->irq, (void *)itv);
1234free_i2c: 1238free_i2c:
@@ -1373,7 +1377,7 @@ static void ivtv_remove(struct pci_dev *pci_dev)
1373 flush_workqueue(itv->irq_work_queues); 1377 flush_workqueue(itv->irq_work_queues);
1374 destroy_workqueue(itv->irq_work_queues); 1378 destroy_workqueue(itv->irq_work_queues);
1375 1379
1376 ivtv_streams_cleanup(itv); 1380 ivtv_streams_cleanup(itv, 1);
1377 ivtv_udma_free(itv); 1381 ivtv_udma_free(itv);
1378 1382
1379 exit_ivtv_i2c(itv); 1383 exit_ivtv_i2c(itv);
diff --git a/drivers/media/video/ivtv/ivtv-fileops.c b/drivers/media/video/ivtv/ivtv-fileops.c
index 2b74b0ab1477..f2fa434b677b 100644
--- a/drivers/media/video/ivtv/ivtv-fileops.c
+++ b/drivers/media/video/ivtv/ivtv-fileops.c
@@ -987,6 +987,8 @@ int ivtv_v4l2_open(struct inode *inode, struct file *filp)
987 /* Find which card this open was on */ 987 /* Find which card this open was on */
988 spin_lock(&ivtv_cards_lock); 988 spin_lock(&ivtv_cards_lock);
989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) { 989 for (x = 0; itv == NULL && x < ivtv_cards_active; x++) {
990 if (ivtv_cards[x] == NULL)
991 continue;
990 /* find out which stream this open was on */ 992 /* find out which stream this open was on */
991 for (y = 0; y < IVTV_MAX_STREAMS; y++) { 993 for (y = 0; y < IVTV_MAX_STREAMS; y++) {
992 s = &ivtv_cards[x]->streams[y]; 994 s = &ivtv_cards[x]->streams[y];
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.c b/drivers/media/video/ivtv/ivtv-ioctl.c
index d508b5d0538c..26cc0f6699fd 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.c
+++ b/drivers/media/video/ivtv/ivtv-ioctl.c
@@ -38,7 +38,7 @@
38#include <linux/dvb/audio.h> 38#include <linux/dvb/audio.h>
39#include <linux/i2c-id.h> 39#include <linux/i2c-id.h>
40 40
41u16 service2vbi(int type) 41u16 ivtv_service2vbi(int type)
42{ 42{
43 switch (type) { 43 switch (type) {
44 case V4L2_SLICED_TELETEXT_B: 44 case V4L2_SLICED_TELETEXT_B:
@@ -88,7 +88,7 @@ static u16 select_service_from_set(int field, int line, u16 set, int is_pal)
88 return 0; 88 return 0;
89} 89}
90 90
91void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal) 91void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
92{ 92{
93 u16 set = fmt->service_set; 93 u16 set = fmt->service_set;
94 int f, l; 94 int f, l;
@@ -115,7 +115,7 @@ static int check_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal)
115 return set != 0; 115 return set != 0;
116} 116}
117 117
118u16 get_service_set(struct v4l2_sliced_vbi_format *fmt) 118u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt)
119{ 119{
120 int f, l; 120 int f, l;
121 u16 set = 0; 121 u16 set = 0;
@@ -466,7 +466,7 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625; 466 vbifmt->service_lines[0][23] = V4L2_SLICED_WSS_625;
467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS; 467 vbifmt->service_lines[0][16] = V4L2_SLICED_VPS;
468 } 468 }
469 vbifmt->service_set = get_service_set(vbifmt); 469 vbifmt->service_set = ivtv_get_service_set(vbifmt);
470 break; 470 break;
471 } 471 }
472 472
@@ -481,12 +481,12 @@ static int ivtv_get_fmt(struct ivtv *itv, int streamtype, struct v4l2_format *fm
481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) { 481 if (streamtype == IVTV_DEC_STREAM_TYPE_VBI) {
482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 : 482 vbifmt->service_set = itv->is_50hz ? V4L2_SLICED_VBI_625 :
483 V4L2_SLICED_VBI_525; 483 V4L2_SLICED_VBI_525;
484 expand_service_set(vbifmt, itv->is_50hz); 484 ivtv_expand_service_set(vbifmt, itv->is_50hz);
485 break; 485 break;
486 } 486 }
487 487
488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt); 488 itv->video_dec_func(itv, VIDIOC_G_FMT, fmt);
489 vbifmt->service_set = get_service_set(vbifmt); 489 vbifmt->service_set = ivtv_get_service_set(vbifmt);
490 break; 490 break;
491 } 491 }
492 case V4L2_BUF_TYPE_VBI_OUTPUT: 492 case V4L2_BUF_TYPE_VBI_OUTPUT:
@@ -640,9 +640,9 @@ static int ivtv_try_or_set_fmt(struct ivtv *itv, int streamtype,
640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved)); 640 memset(vbifmt->reserved, 0, sizeof(vbifmt->reserved));
641 641
642 if (vbifmt->service_set) 642 if (vbifmt->service_set)
643 expand_service_set(vbifmt, itv->is_50hz); 643 ivtv_expand_service_set(vbifmt, itv->is_50hz);
644 set = check_service_set(vbifmt, itv->is_50hz); 644 set = check_service_set(vbifmt, itv->is_50hz);
645 vbifmt->service_set = get_service_set(vbifmt); 645 vbifmt->service_set = ivtv_get_service_set(vbifmt);
646 646
647 if (!set_fmt) 647 if (!set_fmt)
648 return 0; 648 return 0;
diff --git a/drivers/media/video/ivtv/ivtv-ioctl.h b/drivers/media/video/ivtv/ivtv-ioctl.h
index a03351b6853d..4e67f0ed1fc0 100644
--- a/drivers/media/video/ivtv/ivtv-ioctl.h
+++ b/drivers/media/video/ivtv/ivtv-ioctl.h
@@ -21,9 +21,9 @@
21#ifndef IVTV_IOCTL_H 21#ifndef IVTV_IOCTL_H
22#define IVTV_IOCTL_H 22#define IVTV_IOCTL_H
23 23
24u16 service2vbi(int type); 24u16 ivtv_service2vbi(int type);
25void expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal); 25void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
26u16 get_service_set(struct v4l2_sliced_vbi_format *fmt); 26u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 27int ivtv_v4l2_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
28 unsigned long arg); 28 unsigned long arg);
29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg); 29int ivtv_v4l2_ioctls(struct ivtv *itv, struct file *filp, unsigned int cmd, void *arg);
diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index 3e1deec67a5e..fc8b1eaa333b 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -203,14 +203,14 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
203 s->dma != PCI_DMA_NONE ? "DMA " : "", 203 s->dma != PCI_DMA_NONE ? "DMA " : "",
204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024); 204 s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
205 205
206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL); 206 s->sg_pending = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
207 if (s->sg_pending == NULL) { 207 if (s->sg_pending == NULL) {
208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name); 208 IVTV_ERR("Could not allocate sg_pending for %s stream\n", s->name);
209 return -ENOMEM; 209 return -ENOMEM;
210 } 210 }
211 s->sg_pending_size = 0; 211 s->sg_pending_size = 0;
212 212
213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL); 213 s->sg_processing = kzalloc(SGsize, GFP_KERNEL|__GFP_NOWARN);
214 if (s->sg_processing == NULL) { 214 if (s->sg_processing == NULL) {
215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name); 215 IVTV_ERR("Could not allocate sg_processing for %s stream\n", s->name);
216 kfree(s->sg_pending); 216 kfree(s->sg_pending);
@@ -219,7 +219,8 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
219 } 219 }
220 s->sg_processing_size = 0; 220 s->sg_processing_size = 0;
221 221
222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element), GFP_KERNEL); 222 s->sg_dma = kzalloc(sizeof(struct ivtv_sg_element),
223 GFP_KERNEL|__GFP_NOWARN);
223 if (s->sg_dma == NULL) { 224 if (s->sg_dma == NULL) {
224 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name); 225 IVTV_ERR("Could not allocate sg_dma for %s stream\n", s->name);
225 kfree(s->sg_pending); 226 kfree(s->sg_pending);
@@ -235,11 +236,12 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
235 236
236 /* allocate stream buffers. Initially all buffers are in q_free. */ 237 /* allocate stream buffers. Initially all buffers are in q_free. */
237 for (i = 0; i < s->buffers; i++) { 238 for (i = 0; i < s->buffers; i++) {
238 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer), GFP_KERNEL); 239 struct ivtv_buffer *buf = kzalloc(sizeof(struct ivtv_buffer),
240 GFP_KERNEL|__GFP_NOWARN);
239 241
240 if (buf == NULL) 242 if (buf == NULL)
241 break; 243 break;
242 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL); 244 buf->buf = kmalloc(s->buf_size + 256, GFP_KERNEL|__GFP_NOWARN);
243 if (buf->buf == NULL) { 245 if (buf->buf == NULL) {
244 kfree(buf); 246 kfree(buf);
245 break; 247 break;
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c
index 4ab8d36831ba..c47c2b945147 100644
--- a/drivers/media/video/ivtv/ivtv-streams.c
+++ b/drivers/media/video/ivtv/ivtv-streams.c
@@ -244,7 +244,7 @@ int ivtv_streams_setup(struct ivtv *itv)
244 return 0; 244 return 0;
245 245
246 /* One or more streams could not be initialized. Clean 'em all up. */ 246 /* One or more streams could not be initialized. Clean 'em all up. */
247 ivtv_streams_cleanup(itv); 247 ivtv_streams_cleanup(itv, 0);
248 return -ENOMEM; 248 return -ENOMEM;
249} 249}
250 250
@@ -304,12 +304,12 @@ int ivtv_streams_register(struct ivtv *itv)
304 return 0; 304 return 0;
305 305
306 /* One or more streams could not be initialized. Clean 'em all up. */ 306 /* One or more streams could not be initialized. Clean 'em all up. */
307 ivtv_streams_cleanup(itv); 307 ivtv_streams_cleanup(itv, 1);
308 return -ENOMEM; 308 return -ENOMEM;
309} 309}
310 310
311/* Unregister v4l2 devices */ 311/* Unregister v4l2 devices */
312void ivtv_streams_cleanup(struct ivtv *itv) 312void ivtv_streams_cleanup(struct ivtv *itv, int unregister)
313{ 313{
314 int type; 314 int type;
315 315
@@ -322,8 +322,11 @@ void ivtv_streams_cleanup(struct ivtv *itv)
322 continue; 322 continue;
323 323
324 ivtv_stream_free(&itv->streams[type]); 324 ivtv_stream_free(&itv->streams[type]);
325 /* Unregister device */ 325 /* Unregister or release device */
326 video_unregister_device(vdev); 326 if (unregister)
327 video_unregister_device(vdev);
328 else
329 video_device_release(vdev);
327 } 330 }
328} 331}
329 332
diff --git a/drivers/media/video/ivtv/ivtv-streams.h b/drivers/media/video/ivtv/ivtv-streams.h
index 3d76a415fbd8..a653a5136417 100644
--- a/drivers/media/video/ivtv/ivtv-streams.h
+++ b/drivers/media/video/ivtv/ivtv-streams.h
@@ -23,7 +23,7 @@
23 23
24int ivtv_streams_setup(struct ivtv *itv); 24int ivtv_streams_setup(struct ivtv *itv);
25int ivtv_streams_register(struct ivtv *itv); 25int ivtv_streams_register(struct ivtv *itv);
26void ivtv_streams_cleanup(struct ivtv *itv); 26void ivtv_streams_cleanup(struct ivtv *itv, int unregister);
27 27
28/* Capture related */ 28/* Capture related */
29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s); 29int ivtv_start_v4l2_encode_stream(struct ivtv_stream *s);
diff --git a/drivers/media/video/ivtv/ivtv-vbi.c b/drivers/media/video/ivtv/ivtv-vbi.c
index c151bcf5519a..71798f0da27f 100644
--- a/drivers/media/video/ivtv/ivtv-vbi.c
+++ b/drivers/media/video/ivtv/ivtv-vbi.c
@@ -169,7 +169,8 @@ static void copy_vbi_data(struct ivtv *itv, int lines, u32 pts_stamp)
169 linemask[0] |= (1 << l); 169 linemask[0] |= (1 << l);
170 else 170 else
171 linemask[1] |= (1 << (l - 32)); 171 linemask[1] |= (1 << (l - 32));
172 dst[sd + 12 + line * 43] = service2vbi(itv->vbi.sliced_data[i].id); 172 dst[sd + 12 + line * 43] =
173 ivtv_service2vbi(itv->vbi.sliced_data[i].id);
173 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42); 174 memcpy(dst + sd + 12 + line * 43 + 1, itv->vbi.sliced_data[i].data, 42);
174 line++; 175 line++;
175 } 176 }
diff --git a/drivers/media/video/ivtv/ivtv-yuv.c b/drivers/media/video/ivtv/ivtv-yuv.c
index 62f70bd5e3cb..a9417f6e4087 100644
--- a/drivers/media/video/ivtv/ivtv-yuv.c
+++ b/drivers/media/video/ivtv/ivtv-yuv.c
@@ -908,7 +908,7 @@ static void ivtv_yuv_init(struct ivtv *itv)
908 } 908 }
909 909
910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */ 910 /* We need a buffer for blanking when Y plane is offset - non-fatal if we can't get one */
911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL); 911 yi->blanking_ptr = kzalloc(720 * 16, GFP_KERNEL|__GFP_NOWARN);
912 if (yi->blanking_ptr) { 912 if (yi->blanking_ptr) {
913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE); 913 yi->blanking_dmaptr = pci_map_single(itv->dev, yi->blanking_ptr, 720*16, PCI_DMA_TODEVICE);
914 } else { 914 } else {
diff --git a/drivers/media/video/ivtv/ivtvfb.c b/drivers/media/video/ivtv/ivtvfb.c
index df789f683e63..73be154f7f05 100644
--- a/drivers/media/video/ivtv/ivtvfb.c
+++ b/drivers/media/video/ivtv/ivtvfb.c
@@ -948,7 +948,8 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
948 } 948 }
949 949
950 /* Allocate the pseudo palette */ 950 /* Allocate the pseudo palette */
951 oi->ivtvfb_info.pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); 951 oi->ivtvfb_info.pseudo_palette =
952 kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN);
952 953
953 if (!oi->ivtvfb_info.pseudo_palette) { 954 if (!oi->ivtvfb_info.pseudo_palette) {
954 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n"); 955 IVTVFB_ERR("abort, unable to alloc pseudo pallete\n");
@@ -1056,7 +1057,8 @@ static int ivtvfb_init_card(struct ivtv *itv)
1056 return -EBUSY; 1057 return -EBUSY;
1057 } 1058 }
1058 1059
1059 itv->osd_info = kzalloc(sizeof(struct osd_info), GFP_ATOMIC); 1060 itv->osd_info = kzalloc(sizeof(struct osd_info),
1061 GFP_ATOMIC|__GFP_NOWARN);
1060 if (itv->osd_info == NULL) { 1062 if (itv->osd_info == NULL) {
1061 IVTVFB_ERR("Failed to allocate memory for osd_info\n"); 1063 IVTVFB_ERR("Failed to allocate memory for osd_info\n");
1062 return -ENOMEM; 1064 return -ENOMEM;
diff --git a/drivers/media/video/mt9m001.c b/drivers/media/video/mt9m001.c
index 179e47049a45..ee43499544c1 100644
--- a/drivers/media/video/mt9m001.c
+++ b/drivers/media/video/mt9m001.c
@@ -12,15 +12,12 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/log2.h> 14#include <linux/log2.h>
15#include <linux/gpio.h>
15 16
16#include <media/v4l2-common.h> 17#include <media/v4l2-common.h>
17#include <media/v4l2-chip-ident.h> 18#include <media/v4l2-chip-ident.h>
18#include <media/soc_camera.h> 19#include <media/soc_camera.h>
19 20
20#ifdef CONFIG_MT9M001_PCA9536_SWITCH
21#include <asm/gpio.h>
22#endif
23
24/* mt9m001 i2c address 0x5d 21/* mt9m001 i2c address 0x5d
25 * The platform has to define i2c_board_info 22 * The platform has to define i2c_board_info
26 * and call i2c_register_board_info() */ 23 * and call i2c_register_board_info() */
diff --git a/drivers/media/video/mt9v022.c b/drivers/media/video/mt9v022.c
index d1391ac55096..1658fe590392 100644
--- a/drivers/media/video/mt9v022.c
+++ b/drivers/media/video/mt9v022.c
@@ -13,15 +13,12 @@
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/delay.h> 14#include <linux/delay.h>
15#include <linux/log2.h> 15#include <linux/log2.h>
16#include <linux/gpio.h>
16 17
17#include <media/v4l2-common.h> 18#include <media/v4l2-common.h>
18#include <media/v4l2-chip-ident.h> 19#include <media/v4l2-chip-ident.h>
19#include <media/soc_camera.h> 20#include <media/soc_camera.h>
20 21
21#ifdef CONFIG_MT9M001_PCA9536_SWITCH
22#include <asm/gpio.h>
23#endif
24
25/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c 22/* mt9v022 i2c address 0x48, 0x4c, 0x58, 0x5c
26 * The platform has to define i2c_board_info 23 * The platform has to define i2c_board_info
27 * and call i2c_register_board_info() */ 24 * and call i2c_register_board_info() */
@@ -91,7 +88,7 @@ static const struct soc_camera_data_format mt9v022_monochrome_formats[] = {
91struct mt9v022 { 88struct mt9v022 {
92 struct i2c_client *client; 89 struct i2c_client *client;
93 struct soc_camera_device icd; 90 struct soc_camera_device icd;
94 int model; /* V4L2_IDENT_MT9M001* codes from v4l2-chip-ident.h */ 91 int model; /* V4L2_IDENT_MT9V022* codes from v4l2-chip-ident.h */
95 int switch_gpio; 92 int switch_gpio;
96 u16 chip_control; 93 u16 chip_control;
97 unsigned char datawidth; 94 unsigned char datawidth;
diff --git a/drivers/media/video/pvrusb2/Kconfig b/drivers/media/video/pvrusb2/Kconfig
index 9620c67fae77..4482b2c72ced 100644
--- a/drivers/media/video/pvrusb2/Kconfig
+++ b/drivers/media/video/pvrusb2/Kconfig
@@ -1,8 +1,10 @@
1config VIDEO_PVRUSB2 1config VIDEO_PVRUSB2
2 tristate "Hauppauge WinTV-PVR USB2 support" 2 tristate "Hauppauge WinTV-PVR USB2 support"
3 depends on VIDEO_V4L2 && I2C 3 depends on VIDEO_V4L2 && I2C
4 depends on VIDEO_MEDIA # Avoids pvrusb = Y / DVB = M
5 depends on HOTPLUG # due to FW_LOADER
4 select FW_LOADER 6 select FW_LOADER
5 select MEDIA_TUNER 7 select VIDEO_TUNER
6 select VIDEO_TVEEPROM 8 select VIDEO_TVEEPROM
7 select VIDEO_CX2341X 9 select VIDEO_CX2341X
8 select VIDEO_SAA711X 10 select VIDEO_SAA711X
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 40e4c3bd2cb9..83f076abce35 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -3,7 +3,7 @@ config VIDEO_SAA7134
3 depends on VIDEO_DEV && PCI && I2C && INPUT 3 depends on VIDEO_DEV && PCI && I2C && INPUT
4 select VIDEOBUF_DMA_SG 4 select VIDEOBUF_DMA_SG
5 select VIDEO_IR 5 select VIDEO_IR
6 select MEDIA_TUNER 6 select VIDEO_TUNER
7 select VIDEO_TVEEPROM 7 select VIDEO_TVEEPROM
8 select CRC32 8 select CRC32
9 ---help--- 9 ---help---
@@ -27,6 +27,7 @@ config VIDEO_SAA7134_ALSA
27config VIDEO_SAA7134_DVB 27config VIDEO_SAA7134_DVB
28 tristate "DVB/ATSC Support for saa7134 based TV cards" 28 tristate "DVB/ATSC Support for saa7134 based TV cards"
29 depends on VIDEO_SAA7134 && DVB_CORE 29 depends on VIDEO_SAA7134 && DVB_CORE
30 depends on HOTPLUG # due to FW_LOADER
30 select VIDEOBUF_DVB 31 select VIDEOBUF_DVB
31 select FW_LOADER 32 select FW_LOADER
32 select DVB_PLL if !DVB_FE_CUSTOMISE 33 select DVB_PLL if !DVB_FE_CUSTOMISE
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index eec127864fe3..2c19cd0113c8 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -864,7 +864,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
864 struct saa7134_dev *dev; 864 struct saa7134_dev *dev;
865 struct saa7134_mpeg_ops *mops; 865 struct saa7134_mpeg_ops *mops;
866 int err; 866 int err;
867 int mask;
868 867
869 if (saa7134_devcount == SAA7134_MAXBOARDS) 868 if (saa7134_devcount == SAA7134_MAXBOARDS)
870 return -ENOMEM; 869 return -ENOMEM;
@@ -1065,11 +1064,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1065 if (TUNER_ABSENT != dev->tuner_type) 1064 if (TUNER_ABSENT != dev->tuner_type)
1066 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL); 1065 saa7134_i2c_call_clients(dev, TUNER_SET_STANDBY, NULL);
1067 1066
1068 if (card(dev).gpiomask != 0) {
1069 mask = card(dev).gpiomask;
1070 saa_andorl(SAA7134_GPIO_GPMODE0 >> 2, mask, mask);
1071 saa_andorl(SAA7134_GPIO_GPSTATUS0 >> 2, mask, 0);
1072 }
1073 return 0; 1067 return 0;
1074 1068
1075 fail4: 1069 fail4:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 2d16be2259db..469f93aac008 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -538,19 +538,23 @@ static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
538 return 0; 538 return 0;
539} 539}
540 540
541static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *cdec_conf, 541static int configure_tda827x_fe(struct saa7134_dev *dev,
542 struct tda827x_config *tuner_conf) 542 struct tda1004x_config *cdec_conf,
543 struct tda827x_config *tuner_conf)
543{ 544{
544 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap); 545 dev->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
545 if (dev->dvb.frontend) { 546 if (dev->dvb.frontend) {
546 if (cdec_conf->i2c_gate) 547 if (cdec_conf->i2c_gate)
547 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl; 548 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
548 if (dvb_attach(tda827x_attach, dev->dvb.frontend, cdec_conf->tuner_address, 549 if (dvb_attach(tda827x_attach, dev->dvb.frontend,
549 &dev->i2c_adap, tuner_conf) == NULL) { 550 cdec_conf->tuner_address,
550 wprintk("no tda827x tuner found at addr: %02x\n", 551 &dev->i2c_adap, tuner_conf))
552 return 0;
553
554 wprintk("no tda827x tuner found at addr: %02x\n",
551 cdec_conf->tuner_address); 555 cdec_conf->tuner_address);
552 }
553 } 556 }
557 return -EINVAL;
554} 558}
555 559
556/* ------------------------------------------------------------------ */ 560/* ------------------------------------------------------------------ */
@@ -997,7 +1001,9 @@ static int dvb_init(struct saa7134_dev *dev)
997 break; 1001 break;
998 case SAA7134_BOARD_FLYDVBTDUO: 1002 case SAA7134_BOARD_FLYDVBTDUO:
999 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS: 1003 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
1000 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1004 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1005 &tda827x_cfg_0) < 0)
1006 goto dettach_frontend;
1001 break; 1007 break;
1002 case SAA7134_BOARD_PHILIPS_EUROPA: 1008 case SAA7134_BOARD_PHILIPS_EUROPA:
1003 case SAA7134_BOARD_VIDEOMATE_DVBT_300: 1009 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
@@ -1022,36 +1028,52 @@ static int dvb_init(struct saa7134_dev *dev)
1022 } 1028 }
1023 break; 1029 break;
1024 case SAA7134_BOARD_KWORLD_DVBT_210: 1030 case SAA7134_BOARD_KWORLD_DVBT_210:
1025 configure_tda827x_fe(dev, &kworld_dvb_t_210_config, &tda827x_cfg_2); 1031 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1032 &tda827x_cfg_2) < 0)
1033 goto dettach_frontend;
1026 break; 1034 break;
1027 case SAA7134_BOARD_PHILIPS_TIGER: 1035 case SAA7134_BOARD_PHILIPS_TIGER:
1028 configure_tda827x_fe(dev, &philips_tiger_config, &tda827x_cfg_0); 1036 if (configure_tda827x_fe(dev, &philips_tiger_config,
1037 &tda827x_cfg_0) < 0)
1038 goto dettach_frontend;
1029 break; 1039 break;
1030 case SAA7134_BOARD_PINNACLE_PCTV_310i: 1040 case SAA7134_BOARD_PINNACLE_PCTV_310i:
1031 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, &tda827x_cfg_1); 1041 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1042 &tda827x_cfg_1) < 0)
1043 goto dettach_frontend;
1032 break; 1044 break;
1033 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 1045 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
1034 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, &tda827x_cfg_1); 1046 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1047 &tda827x_cfg_1) < 0)
1048 goto dettach_frontend;
1035 break; 1049 break;
1036 case SAA7134_BOARD_ASUSTeK_P7131_DUAL: 1050 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
1037 configure_tda827x_fe(dev, &asus_p7131_dual_config, &tda827x_cfg_0); 1051 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1052 &tda827x_cfg_0) < 0)
1053 goto dettach_frontend;
1038 break; 1054 break;
1039 case SAA7134_BOARD_FLYDVBT_LR301: 1055 case SAA7134_BOARD_FLYDVBT_LR301:
1040 configure_tda827x_fe(dev, &tda827x_lifeview_config, &tda827x_cfg_0); 1056 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1057 &tda827x_cfg_0) < 0)
1058 goto dettach_frontend;
1041 break; 1059 break;
1042 case SAA7134_BOARD_FLYDVB_TRIO: 1060 case SAA7134_BOARD_FLYDVB_TRIO:
1043 if(! use_frontend) { /* terrestrial */ 1061 if (!use_frontend) { /* terrestrial */
1044 configure_tda827x_fe(dev, &lifeview_trio_config, &tda827x_cfg_0); 1062 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1063 &tda827x_cfg_0) < 0)
1064 goto dettach_frontend;
1045 } else { /* satellite */ 1065 } else { /* satellite */
1046 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap); 1066 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1047 if (dev->dvb.frontend) { 1067 if (dev->dvb.frontend) {
1048 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63, 1068 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1049 &dev->i2c_adap, 0) == NULL) { 1069 &dev->i2c_adap, 0) == NULL) {
1050 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__); 1070 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
1071 goto dettach_frontend;
1051 } 1072 }
1052 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap, 1073 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1053 0x08, 0, 0) == NULL) { 1074 0x08, 0, 0) == NULL) {
1054 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__); 1075 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
1076 goto dettach_frontend;
1055 } 1077 }
1056 } 1078 }
1057 } 1079 }
@@ -1067,15 +1089,20 @@ static int dvb_init(struct saa7134_dev *dev)
1067 &ads_duo_cfg) == NULL) { 1089 &ads_duo_cfg) == NULL) {
1068 wprintk("no tda827x tuner found at addr: %02x\n", 1090 wprintk("no tda827x tuner found at addr: %02x\n",
1069 ads_tech_duo_config.tuner_address); 1091 ads_tech_duo_config.tuner_address);
1092 goto dettach_frontend;
1070 } 1093 }
1071 } 1094 }
1072 break; 1095 break;
1073 case SAA7134_BOARD_TEVION_DVBT_220RF: 1096 case SAA7134_BOARD_TEVION_DVBT_220RF:
1074 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, &tda827x_cfg_0); 1097 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1098 &tda827x_cfg_0) < 0)
1099 goto dettach_frontend;
1075 break; 1100 break;
1076 case SAA7134_BOARD_MEDION_MD8800_QUADRO: 1101 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1077 if (!use_frontend) { /* terrestrial */ 1102 if (!use_frontend) { /* terrestrial */
1078 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1103 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1104 &tda827x_cfg_0) < 0)
1105 goto dettach_frontend;
1079 } else { /* satellite */ 1106 } else { /* satellite */
1080 dev->dvb.frontend = dvb_attach(tda10086_attach, 1107 dev->dvb.frontend = dvb_attach(tda10086_attach,
1081 &flydvbs, &dev->i2c_adap); 1108 &flydvbs, &dev->i2c_adap);
@@ -1086,16 +1113,20 @@ static int dvb_init(struct saa7134_dev *dev)
1086 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1}; 1113 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1087 1114
1088 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 1115 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1089 0x60, &dev->i2c_adap, 0) == NULL) 1116 0x60, &dev->i2c_adap, 0) == NULL) {
1090 wprintk("%s: Medion Quadro, no tda826x " 1117 wprintk("%s: Medion Quadro, no tda826x "
1091 "found !\n", __func__); 1118 "found !\n", __func__);
1119 goto dettach_frontend;
1120 }
1092 if (dev_id != 0x08) { 1121 if (dev_id != 0x08) {
1093 /* we need to open the i2c gate (we know it exists) */ 1122 /* we need to open the i2c gate (we know it exists) */
1094 fe->ops.i2c_gate_ctrl(fe, 1); 1123 fe->ops.i2c_gate_ctrl(fe, 1);
1095 if (dvb_attach(isl6405_attach, fe, 1124 if (dvb_attach(isl6405_attach, fe,
1096 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1125 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1097 wprintk("%s: Medion Quadro, no ISL6405 " 1126 wprintk("%s: Medion Quadro, no ISL6405 "
1098 "found !\n", __func__); 1127 "found !\n", __func__);
1128 goto dettach_frontend;
1129 }
1099 if (dev_id == 0x07) { 1130 if (dev_id == 0x07) {
1100 /* fire up the 2nd section of the LNB supply since 1131 /* fire up the 2nd section of the LNB supply since
1101 we can't do this from the other section */ 1132 we can't do this from the other section */
@@ -1117,19 +1148,17 @@ static int dvb_init(struct saa7134_dev *dev)
1117 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180: 1148 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
1118 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, 1149 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1119 &dev->i2c_adap); 1150 &dev->i2c_adap);
1120 if (dev->dvb.frontend) { 1151 if (dev->dvb.frontend)
1121 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, 1152 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1122 NULL, DVB_PLL_TDHU2); 1153 NULL, DVB_PLL_TDHU2);
1123 }
1124 break; 1154 break;
1125 case SAA7134_BOARD_KWORLD_ATSC110: 1155 case SAA7134_BOARD_KWORLD_ATSC110:
1126 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, 1156 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1127 &dev->i2c_adap); 1157 &dev->i2c_adap);
1128 if (dev->dvb.frontend) { 1158 if (dev->dvb.frontend)
1129 dvb_attach(simple_tuner_attach, dev->dvb.frontend, 1159 dvb_attach(simple_tuner_attach, dev->dvb.frontend,
1130 &dev->i2c_adap, 0x61, 1160 &dev->i2c_adap, 0x61,
1131 TUNER_PHILIPS_TUV1236D); 1161 TUNER_PHILIPS_TUV1236D);
1132 }
1133 break; 1162 break;
1134 case SAA7134_BOARD_FLYDVBS_LR300: 1163 case SAA7134_BOARD_FLYDVBS_LR300:
1135 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1164 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
@@ -1138,10 +1167,12 @@ static int dvb_init(struct saa7134_dev *dev)
1138 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1167 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1139 &dev->i2c_adap, 0) == NULL) { 1168 &dev->i2c_adap, 0) == NULL) {
1140 wprintk("%s: No tda826x found!\n", __func__); 1169 wprintk("%s: No tda826x found!\n", __func__);
1170 goto dettach_frontend;
1141 } 1171 }
1142 if (dvb_attach(isl6421_attach, dev->dvb.frontend, 1172 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1143 &dev->i2c_adap, 0x08, 0, 0) == NULL) { 1173 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1144 wprintk("%s: No ISL6421 found!\n", __func__); 1174 wprintk("%s: No ISL6421 found!\n", __func__);
1175 goto dettach_frontend;
1145 } 1176 }
1146 } 1177 }
1147 break; 1178 break;
@@ -1168,43 +1199,65 @@ static int dvb_init(struct saa7134_dev *dev)
1168 } 1199 }
1169 break; 1200 break;
1170 case SAA7134_BOARD_CINERGY_HT_PCMCIA: 1201 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
1171 configure_tda827x_fe(dev, &cinergy_ht_config, &tda827x_cfg_0); 1202 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1203 &tda827x_cfg_0) < 0)
1204 goto dettach_frontend;
1172 break; 1205 break;
1173 case SAA7134_BOARD_CINERGY_HT_PCI: 1206 case SAA7134_BOARD_CINERGY_HT_PCI:
1174 configure_tda827x_fe(dev, &cinergy_ht_pci_config, &tda827x_cfg_0); 1207 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1208 &tda827x_cfg_0) < 0)
1209 goto dettach_frontend;
1175 break; 1210 break;
1176 case SAA7134_BOARD_PHILIPS_TIGER_S: 1211 case SAA7134_BOARD_PHILIPS_TIGER_S:
1177 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1212 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1213 &tda827x_cfg_2) < 0)
1214 goto dettach_frontend;
1178 break; 1215 break;
1179 case SAA7134_BOARD_ASUS_P7131_4871: 1216 case SAA7134_BOARD_ASUS_P7131_4871:
1180 configure_tda827x_fe(dev, &asus_p7131_4871_config, &tda827x_cfg_2); 1217 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1218 &tda827x_cfg_2) < 0)
1219 goto dettach_frontend;
1181 break; 1220 break;
1182 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA: 1221 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1183 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config, &tda827x_cfg_2); 1222 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1223 &tda827x_cfg_2) < 0)
1224 goto dettach_frontend;
1184 break; 1225 break;
1185 case SAA7134_BOARD_AVERMEDIA_SUPER_007: 1226 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1186 configure_tda827x_fe(dev, &avermedia_super_007_config, &tda827x_cfg_0); 1227 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1228 &tda827x_cfg_0) < 0)
1229 goto dettach_frontend;
1187 break; 1230 break;
1188 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056: 1231 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1189 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config, &tda827x_cfg_2_sw42); 1232 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1233 &tda827x_cfg_2_sw42) < 0)
1234 goto dettach_frontend;
1190 break; 1235 break;
1191 case SAA7134_BOARD_PHILIPS_SNAKE: 1236 case SAA7134_BOARD_PHILIPS_SNAKE:
1192 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, 1237 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1193 &dev->i2c_adap); 1238 &dev->i2c_adap);
1194 if (dev->dvb.frontend) { 1239 if (dev->dvb.frontend) {
1195 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60, 1240 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1196 &dev->i2c_adap, 0) == NULL) 1241 &dev->i2c_adap, 0) == NULL) {
1197 wprintk("%s: No tda826x found!\n", __func__); 1242 wprintk("%s: No tda826x found!\n", __func__);
1243 goto dettach_frontend;
1244 }
1198 if (dvb_attach(lnbp21_attach, dev->dvb.frontend, 1245 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1199 &dev->i2c_adap, 0, 0) == NULL) 1246 &dev->i2c_adap, 0, 0) == NULL) {
1200 wprintk("%s: No lnbp21 found!\n", __func__); 1247 wprintk("%s: No lnbp21 found!\n", __func__);
1248 goto dettach_frontend;
1249 }
1201 } 1250 }
1202 break; 1251 break;
1203 case SAA7134_BOARD_CREATIX_CTX953: 1252 case SAA7134_BOARD_CREATIX_CTX953:
1204 configure_tda827x_fe(dev, &md8800_dvbt_config, &tda827x_cfg_0); 1253 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1254 &tda827x_cfg_0) < 0)
1255 goto dettach_frontend;
1205 break; 1256 break;
1206 case SAA7134_BOARD_MSI_TVANYWHERE_AD11: 1257 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1207 configure_tda827x_fe(dev, &philips_tiger_s_config, &tda827x_cfg_2); 1258 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1259 &tda827x_cfg_2) < 0)
1260 goto dettach_frontend;
1208 break; 1261 break;
1209 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506: 1262 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1210 dev->dvb.frontend = dvb_attach(mt352_attach, 1263 dev->dvb.frontend = dvb_attach(mt352_attach,
@@ -1218,16 +1271,20 @@ static int dvb_init(struct saa7134_dev *dev)
1218 if (dev->dvb.frontend) { 1271 if (dev->dvb.frontend) {
1219 struct dvb_frontend *fe; 1272 struct dvb_frontend *fe;
1220 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60, 1273 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1221 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) 1274 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
1222 wprintk("%s: MD7134 DVB-S, no SD1878 " 1275 wprintk("%s: MD7134 DVB-S, no SD1878 "
1223 "found !\n", __func__); 1276 "found !\n", __func__);
1277 goto dettach_frontend;
1278 }
1224 /* we need to open the i2c gate (we know it exists) */ 1279 /* we need to open the i2c gate (we know it exists) */
1225 fe = dev->dvb.frontend; 1280 fe = dev->dvb.frontend;
1226 fe->ops.i2c_gate_ctrl(fe, 1); 1281 fe->ops.i2c_gate_ctrl(fe, 1);
1227 if (dvb_attach(isl6405_attach, fe, 1282 if (dvb_attach(isl6405_attach, fe,
1228 &dev->i2c_adap, 0x08, 0, 0) == NULL) 1283 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
1229 wprintk("%s: MD7134 DVB-S, no ISL6405 " 1284 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1230 "found !\n", __func__); 1285 "found !\n", __func__);
1286 goto dettach_frontend;
1287 }
1231 fe->ops.i2c_gate_ctrl(fe, 0); 1288 fe->ops.i2c_gate_ctrl(fe, 0);
1232 dev->original_set_voltage = fe->ops.set_voltage; 1289 dev->original_set_voltage = fe->ops.set_voltage;
1233 fe->ops.set_voltage = md8800_set_voltage; 1290 fe->ops.set_voltage = md8800_set_voltage;
@@ -1254,10 +1311,7 @@ static int dvb_init(struct saa7134_dev *dev)
1254 if (!fe) { 1311 if (!fe) {
1255 printk(KERN_ERR "%s/2: xc3028 attach failed\n", 1312 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1256 dev->name); 1313 dev->name);
1257 dvb_frontend_detach(dev->dvb.frontend); 1314 goto dettach_frontend;
1258 dvb_unregister_frontend(dev->dvb.frontend);
1259 dev->dvb.frontend = NULL;
1260 return -1;
1261 } 1315 }
1262 } 1316 }
1263 1317
@@ -1282,6 +1336,12 @@ static int dvb_init(struct saa7134_dev *dev)
1282 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend); 1336 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
1283 } 1337 }
1284 return ret; 1338 return ret;
1339
1340dettach_frontend:
1341 dvb_frontend_detach(dev->dvb.frontend);
1342 dev->dvb.frontend = NULL;
1343
1344 return -1;
1285} 1345}
1286 1346
1287static int dvb_fini(struct saa7134_dev *dev) 1347static int dvb_fini(struct saa7134_dev *dev)
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index a0baf2d0ba7f..48e1a01718ec 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1634,7 +1634,7 @@ static int saa7134_s_fmt_overlay(struct file *file, void *priv,
1634 struct saa7134_fh *fh = priv; 1634 struct saa7134_fh *fh = priv;
1635 struct saa7134_dev *dev = fh->dev; 1635 struct saa7134_dev *dev = fh->dev;
1636 int err; 1636 int err;
1637 unsigned int flags; 1637 unsigned long flags;
1638 1638
1639 if (saa7134_no_overlay > 0) { 1639 if (saa7134_no_overlay > 0) {
1640 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n"); 1640 printk(KERN_ERR "V4L2_BUF_TYPE_VIDEO_OVERLAY: no_overlay\n");
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 9276ed997388..b12c60cf5a09 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -30,6 +30,7 @@
30#include <linux/kref.h> 30#include <linux/kref.h>
31 31
32#include <linux/usb.h> 32#include <linux/usb.h>
33#include <linux/mm.h>
33#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
34#include <linux/videodev2.h> 35#include <linux/videodev2.h>
35#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
@@ -245,6 +246,8 @@ static int stk_initialise(struct stk_camera *dev)
245 return -1; 246 return -1;
246} 247}
247 248
249#ifdef CONFIG_VIDEO_V4L1_COMPAT
250
248/* sysfs functions */ 251/* sysfs functions */
249/*FIXME cleanup this */ 252/*FIXME cleanup this */
250 253
@@ -350,6 +353,10 @@ static void stk_remove_sysfs_files(struct video_device *vdev)
350 video_device_remove_file(vdev, &dev_attr_vflip); 353 video_device_remove_file(vdev, &dev_attr_vflip);
351} 354}
352 355
356#else
357#define stk_create_sysfs_files(a)
358#define stk_remove_sysfs_files(a)
359#endif
353 360
354/* *********************************************** */ 361/* *********************************************** */
355/* 362/*
diff --git a/drivers/media/video/tcm825x.c b/drivers/media/video/tcm825x.c
index e57a64605778..8f0100f67a91 100644
--- a/drivers/media/video/tcm825x.c
+++ b/drivers/media/video/tcm825x.c
@@ -885,12 +885,19 @@ static int __exit tcm825x_remove(struct i2c_client *client)
885 return 0; 885 return 0;
886} 886}
887 887
888static const struct i2c_device_id tcm825x_id[] = {
889 { "tcm825x", 0 },
890 { }
891};
892MODULE_DEVICE_TABLE(i2c, tcm825x_id);
893
888static struct i2c_driver tcm825x_i2c_driver = { 894static struct i2c_driver tcm825x_i2c_driver = {
889 .driver = { 895 .driver = {
890 .name = TCM825X_NAME, 896 .name = TCM825X_NAME,
891 }, 897 },
892 .probe = tcm825x_probe, 898 .probe = tcm825x_probe,
893 .remove = __exit_p(tcm825x_remove), 899 .remove = __exit_p(tcm825x_remove),
900 .id_table = tcm825x_id,
894}; 901};
895 902
896static struct tcm825x_sensor tcm825x = { 903static struct tcm825x_sensor tcm825x = {
diff --git a/drivers/media/video/tlv320aic23b.c b/drivers/media/video/tlv320aic23b.c
index f1db54202dea..28ab9f9d760a 100644
--- a/drivers/media/video/tlv320aic23b.c
+++ b/drivers/media/video/tlv320aic23b.c
@@ -168,6 +168,11 @@ static int tlv320aic23b_remove(struct i2c_client *client)
168 168
169/* ----------------------------------------------------------------------- */ 169/* ----------------------------------------------------------------------- */
170 170
171static const struct i2c_device_id tlv320aic23b_id[] = {
172 { "tlv320aic23b", 0 },
173 { }
174};
175MODULE_DEVICE_TABLE(i2c, tlv320aic23b_id);
171 176
172static struct v4l2_i2c_driver_data v4l2_i2c_data = { 177static struct v4l2_i2c_driver_data v4l2_i2c_data = {
173 .name = "tlv320aic23b", 178 .name = "tlv320aic23b",
@@ -175,4 +180,5 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
175 .command = tlv320aic23b_command, 180 .command = tlv320aic23b_command,
176 .probe = tlv320aic23b_probe, 181 .probe = tlv320aic23b_probe,
177 .remove = tlv320aic23b_remove, 182 .remove = tlv320aic23b_remove,
183 .id_table = tlv320aic23b_id,
178}; 184};
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 6bf104ea051d..5a75788b92ae 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -40,11 +40,11 @@
40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \ 40 typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
41 if (__a) { \ 41 if (__a) { \
42 __r = (int) __a(ARGS); \ 42 __r = (int) __a(ARGS); \
43 symbol_put(FUNCTION); \
43 } else { \ 44 } else { \
44 printk(KERN_ERR "TUNER: Unable to find " \ 45 printk(KERN_ERR "TUNER: Unable to find " \
45 "symbol "#FUNCTION"()\n"); \ 46 "symbol "#FUNCTION"()\n"); \
46 } \ 47 } \
47 symbol_put(FUNCTION); \
48 __r; \ 48 __r; \
49}) 49})
50 50
@@ -340,16 +340,6 @@ static void tuner_i2c_address_check(struct tuner *t)
340 tuner_warn("====================== WARNING! ======================\n"); 340 tuner_warn("====================== WARNING! ======================\n");
341} 341}
342 342
343static void attach_tda829x(struct tuner *t)
344{
345 struct tda829x_config cfg = {
346 .lna_cfg = t->config,
347 .tuner_callback = t->tuner_callback,
348 };
349 dvb_attach(tda829x_attach,
350 &t->fe, t->i2c->adapter, t->i2c->addr, &cfg);
351}
352
353static struct xc5000_config xc5000_cfg; 343static struct xc5000_config xc5000_cfg;
354 344
355static void set_type(struct i2c_client *c, unsigned int type, 345static void set_type(struct i2c_client *c, unsigned int type,
@@ -385,12 +375,19 @@ static void set_type(struct i2c_client *c, unsigned int type,
385 375
386 switch (t->type) { 376 switch (t->type) {
387 case TUNER_MT2032: 377 case TUNER_MT2032:
388 dvb_attach(microtune_attach, 378 if (!dvb_attach(microtune_attach,
389 &t->fe, t->i2c->adapter, t->i2c->addr); 379 &t->fe, t->i2c->adapter, t->i2c->addr))
380 goto attach_failed;
390 break; 381 break;
391 case TUNER_PHILIPS_TDA8290: 382 case TUNER_PHILIPS_TDA8290:
392 { 383 {
393 attach_tda829x(t); 384 struct tda829x_config cfg = {
385 .lna_cfg = t->config,
386 .tuner_callback = t->tuner_callback,
387 };
388 if (!dvb_attach(tda829x_attach, &t->fe, t->i2c->adapter,
389 t->i2c->addr, &cfg))
390 goto attach_failed;
394 break; 391 break;
395 } 392 }
396 case TUNER_TEA5767: 393 case TUNER_TEA5767:
@@ -441,8 +438,9 @@ static void set_type(struct i2c_client *c, unsigned int type,
441 break; 438 break;
442 } 439 }
443 case TUNER_TDA9887: 440 case TUNER_TDA9887:
444 dvb_attach(tda9887_attach, 441 if (!dvb_attach(tda9887_attach,
445 &t->fe, t->i2c->adapter, t->i2c->addr); 442 &t->fe, t->i2c->adapter, t->i2c->addr))
443 goto attach_failed;
446 break; 444 break;
447 case TUNER_XC5000: 445 case TUNER_XC5000:
448 { 446 {
@@ -450,10 +448,10 @@ static void set_type(struct i2c_client *c, unsigned int type,
450 448
451 xc5000_cfg.i2c_address = t->i2c->addr; 449 xc5000_cfg.i2c_address = t->i2c->addr;
452 xc5000_cfg.if_khz = 5380; 450 xc5000_cfg.if_khz = 5380;
453 xc5000_cfg.priv = c->adapter->algo_data;
454 xc5000_cfg.tuner_callback = t->tuner_callback; 451 xc5000_cfg.tuner_callback = t->tuner_callback;
455 if (!dvb_attach(xc5000_attach, 452 if (!dvb_attach(xc5000_attach,
456 &t->fe, t->i2c->adapter, &xc5000_cfg)) 453 &t->fe, t->i2c->adapter, &xc5000_cfg,
454 c->adapter->algo_data))
457 goto attach_failed; 455 goto attach_failed;
458 456
459 xc_tuner_ops = &t->fe.ops.tuner_ops; 457 xc_tuner_ops = &t->fe.ops.tuner_ops;
@@ -1167,7 +1165,7 @@ static int tuner_probe(struct i2c_client *client,
1167 /* If chip is not tda8290, don't register. 1165 /* If chip is not tda8290, don't register.
1168 since it can be tda9887*/ 1166 since it can be tda9887*/
1169 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter, 1167 if (tuner_symbol_probe(tda829x_probe, t->i2c->adapter,
1170 t->i2c->addr) == 0) { 1168 t->i2c->addr) >= 0) {
1171 tuner_dbg("tda829x detected\n"); 1169 tuner_dbg("tda829x detected\n");
1172 } else { 1170 } else {
1173 /* Default is being tda9887 */ 1171 /* Default is being tda9887 */
@@ -1181,7 +1179,7 @@ static int tuner_probe(struct i2c_client *client,
1181 case 0x60: 1179 case 0x60:
1182 if (tuner_symbol_probe(tea5767_autodetection, 1180 if (tuner_symbol_probe(tea5767_autodetection,
1183 t->i2c->adapter, t->i2c->addr) 1181 t->i2c->adapter, t->i2c->addr)
1184 != EINVAL) { 1182 >= 0) {
1185 t->type = TUNER_TEA5767; 1183 t->type = TUNER_TEA5767;
1186 t->mode_mask = T_RADIO; 1184 t->mode_mask = T_RADIO;
1187 t->mode = T_STANDBY; 1185 t->mode = T_STANDBY;
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 6f9945b04e1f..c77914d99d15 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -1505,7 +1505,8 @@ static int chip_probe(struct i2c_client *client, const struct i2c_device_id *id)
1505 } 1505 }
1506 1506
1507 /* fill required data structures */ 1507 /* fill required data structures */
1508 strcpy(client->name, desc->name); 1508 if (!id)
1509 strlcpy(client->name, desc->name, I2C_NAME_SIZE);
1509 chip->type = desc-chiplist; 1510 chip->type = desc-chiplist;
1510 chip->shadow.count = desc->registers+1; 1511 chip->shadow.count = desc->registers+1;
1511 chip->prevmode = -1; 1512 chip->prevmode = -1;
@@ -1830,6 +1831,15 @@ static int chip_legacy_probe(struct i2c_adapter *adap)
1830 return 0; 1831 return 0;
1831} 1832}
1832 1833
1834/* This driver supports many devices and the idea is to let the driver
1835 detect which device is present. So rather than listing all supported
1836 devices here, we pretend to support a single, fake device type. */
1837static const struct i2c_device_id chip_id[] = {
1838 { "tvaudio", 0 },
1839 { }
1840};
1841MODULE_DEVICE_TABLE(i2c, chip_id);
1842
1833static struct v4l2_i2c_driver_data v4l2_i2c_data = { 1843static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1834 .name = "tvaudio", 1844 .name = "tvaudio",
1835 .driverid = I2C_DRIVERID_TVAUDIO, 1845 .driverid = I2C_DRIVERID_TVAUDIO,
@@ -1837,6 +1847,7 @@ static struct v4l2_i2c_driver_data v4l2_i2c_data = {
1837 .probe = chip_probe, 1847 .probe = chip_probe,
1838 .remove = chip_remove, 1848 .remove = chip_remove,
1839 .legacy_probe = chip_legacy_probe, 1849 .legacy_probe = chip_legacy_probe,
1850 .id_table = chip_id,
1840}; 1851};
1841 1852
1842/* 1853/*
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 3cf8a8e801e5..9da0e1807ffb 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -319,10 +319,12 @@ audioIC[] =
319 {AUDIO_CHIP_INTERNAL, "CX25843"}, 319 {AUDIO_CHIP_INTERNAL, "CX25843"},
320 {AUDIO_CHIP_INTERNAL, "CX23418"}, 320 {AUDIO_CHIP_INTERNAL, "CX23418"},
321 {AUDIO_CHIP_INTERNAL, "CX23885"}, 321 {AUDIO_CHIP_INTERNAL, "CX23885"},
322 /* 40-42 */ 322 /* 40-44 */
323 {AUDIO_CHIP_INTERNAL, "CX23888"}, 323 {AUDIO_CHIP_INTERNAL, "CX23888"},
324 {AUDIO_CHIP_INTERNAL, "SAA7131"}, 324 {AUDIO_CHIP_INTERNAL, "SAA7131"},
325 {AUDIO_CHIP_INTERNAL, "CX23887"}, 325 {AUDIO_CHIP_INTERNAL, "CX23887"},
326 {AUDIO_CHIP_INTERNAL, "SAA7164"},
327 {AUDIO_CHIP_INTERNAL, "AU8522"},
326}; 328};
327 329
328/* This list is supplied by Hauppauge. Thanks! */ 330/* This list is supplied by Hauppauge. Thanks! */
@@ -341,8 +343,10 @@ static const char *decoderIC[] = {
341 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842", 343 "CX882", "TVP5150A", "CX25840", "CX25841", "CX25842",
342 /* 30-34 */ 344 /* 30-34 */
343 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888", 345 "CX25843", "CX23418", "NEC61153", "CX23885", "CX23888",
344 /* 35-37 */ 346 /* 35-39 */
345 "SAA7131", "CX25837", "CX23887" 347 "SAA7131", "CX25837", "CX23887", "CX23885A", "CX23887A",
348 /* 40-42 */
349 "SAA7164", "CX23885B", "AU8522"
346}; 350};
347 351
348static int hasRadioTuner(int tunerType) 352static int hasRadioTuner(int tunerType)
diff --git a/drivers/media/video/usbvision/Kconfig b/drivers/media/video/usbvision/Kconfig
index 74e1d3075a20..fc24ef05b3f3 100644
--- a/drivers/media/video/usbvision/Kconfig
+++ b/drivers/media/video/usbvision/Kconfig
@@ -1,7 +1,7 @@
1config VIDEO_USBVISION 1config VIDEO_USBVISION
2 tristate "USB video devices based on Nogatech NT1003/1004/1005" 2 tristate "USB video devices based on Nogatech NT1003/1004/1005"
3 depends on I2C && VIDEO_V4L2 3 depends on I2C && VIDEO_V4L2
4 select MEDIA_TUNER 4 select VIDEO_TUNER
5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO 5 select VIDEO_SAA711X if VIDEO_HELPER_CHIPS_AUTO
6 ---help--- 6 ---help---
7 There are more than 50 different USB video devices based on 7 There are more than 50 different USB video devices based on
diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 30a1af857c7a..fa394104339c 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -47,6 +47,7 @@
47 * to test the HW NMI watchdog 47 * to test the HW NMI watchdog
48 * F## = Break at do_fork for ## iterations 48 * F## = Break at do_fork for ## iterations
49 * S## = Break at sys_open for ## iterations 49 * S## = Break at sys_open for ## iterations
50 * I## = Run the single step test ## iterations
50 * 51 *
51 * NOTE: that the do_fork and sys_open tests are mutually exclusive. 52 * NOTE: that the do_fork and sys_open tests are mutually exclusive.
52 * 53 *
@@ -375,7 +376,7 @@ static void emul_sstep_get(char *arg)
375 break; 376 break;
376 case 1: 377 case 1:
377 /* set breakpoint */ 378 /* set breakpoint */
378 break_helper("Z0", 0, sstep_addr); 379 break_helper("Z0", NULL, sstep_addr);
379 break; 380 break;
380 case 2: 381 case 2:
381 /* Continue */ 382 /* Continue */
@@ -383,7 +384,7 @@ static void emul_sstep_get(char *arg)
383 break; 384 break;
384 case 3: 385 case 3:
385 /* Clear breakpoint */ 386 /* Clear breakpoint */
386 break_helper("z0", 0, sstep_addr); 387 break_helper("z0", NULL, sstep_addr);
387 break; 388 break;
388 default: 389 default:
389 eprintk("kgdbts: ERROR failed sstep get emulation\n"); 390 eprintk("kgdbts: ERROR failed sstep get emulation\n");
@@ -465,11 +466,11 @@ static struct test_struct sw_breakpoint_test[] = {
465 { "?", "S0*" }, /* Clear break points */ 466 { "?", "S0*" }, /* Clear break points */
466 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ 467 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */
467 { "c", "T0*", }, /* Continue */ 468 { "c", "T0*", }, /* Continue */
468 { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, 469 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc },
469 { "write", "OK", write_regs }, 470 { "write", "OK", write_regs },
470 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ 471 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */
471 { "D", "OK" }, /* Detach */ 472 { "D", "OK" }, /* Detach */
472 { "D", "OK", 0, got_break }, /* If the test worked we made it here */ 473 { "D", "OK", NULL, got_break }, /* On success we made it here */
473 { "", "" }, 474 { "", "" },
474}; 475};
475 476
@@ -499,14 +500,14 @@ static struct test_struct singlestep_break_test[] = {
499 { "?", "S0*" }, /* Clear break points */ 500 { "?", "S0*" }, /* Clear break points */
500 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ 501 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */
501 { "c", "T0*", }, /* Continue */ 502 { "c", "T0*", }, /* Continue */
502 { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, 503 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc },
503 { "write", "OK", write_regs }, /* Write registers */ 504 { "write", "OK", write_regs }, /* Write registers */
504 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */ 505 { "kgdbts_break_test", "OK", sw_rem_break }, /*remove breakpoint */
505 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 506 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
506 { "g", "kgdbts_break_test", 0, check_single_step }, 507 { "g", "kgdbts_break_test", NULL, check_single_step },
507 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */ 508 { "kgdbts_break_test", "OK", sw_break, }, /* set sw breakpoint */
508 { "c", "T0*", }, /* Continue */ 509 { "c", "T0*", }, /* Continue */
509 { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, 510 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc },
510 { "write", "OK", write_regs }, /* Write registers */ 511 { "write", "OK", write_regs }, /* Write registers */
511 { "D", "OK" }, /* Remove all breakpoints and continues */ 512 { "D", "OK" }, /* Remove all breakpoints and continues */
512 { "", "" }, 513 { "", "" },
@@ -520,14 +521,14 @@ static struct test_struct do_fork_test[] = {
520 { "?", "S0*" }, /* Clear break points */ 521 { "?", "S0*" }, /* Clear break points */
521 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ 522 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */
522 { "c", "T0*", }, /* Continue */ 523 { "c", "T0*", }, /* Continue */
523 { "g", "do_fork", 0, check_and_rewind_pc }, /* check location */ 524 { "g", "do_fork", NULL, check_and_rewind_pc }, /* check location */
524 { "write", "OK", write_regs }, /* Write registers */ 525 { "write", "OK", write_regs }, /* Write registers */
525 { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */ 526 { "do_fork", "OK", sw_rem_break }, /*remove breakpoint */
526 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 527 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
527 { "g", "do_fork", 0, check_single_step }, 528 { "g", "do_fork", NULL, check_single_step },
528 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */ 529 { "do_fork", "OK", sw_break, }, /* set sw breakpoint */
529 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ 530 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */
530 { "D", "OK", 0, final_ack_set }, /* detach and unregister I/O */ 531 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */
531 { "", "" }, 532 { "", "" },
532}; 533};
533 534
@@ -538,14 +539,14 @@ static struct test_struct sys_open_test[] = {
538 { "?", "S0*" }, /* Clear break points */ 539 { "?", "S0*" }, /* Clear break points */
539 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ 540 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */
540 { "c", "T0*", }, /* Continue */ 541 { "c", "T0*", }, /* Continue */
541 { "g", "sys_open", 0, check_and_rewind_pc }, /* check location */ 542 { "g", "sys_open", NULL, check_and_rewind_pc }, /* check location */
542 { "write", "OK", write_regs }, /* Write registers */ 543 { "write", "OK", write_regs }, /* Write registers */
543 { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */ 544 { "sys_open", "OK", sw_rem_break }, /*remove breakpoint */
544 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */ 545 { "s", "T0*", emul_sstep_get, emul_sstep_put }, /* Single step */
545 { "g", "sys_open", 0, check_single_step }, 546 { "g", "sys_open", NULL, check_single_step },
546 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */ 547 { "sys_open", "OK", sw_break, }, /* set sw breakpoint */
547 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */ 548 { "7", "T0*", skip_back_repeat_test }, /* Loop based on repeat_test */
548 { "D", "OK", 0, final_ack_set }, /* detach and unregister I/O */ 549 { "D", "OK", NULL, final_ack_set }, /* detach and unregister I/O */
549 { "", "" }, 550 { "", "" },
550}; 551};
551 552
@@ -556,11 +557,11 @@ static struct test_struct hw_breakpoint_test[] = {
556 { "?", "S0*" }, /* Clear break points */ 557 { "?", "S0*" }, /* Clear break points */
557 { "kgdbts_break_test", "OK", hw_break, }, /* set hw breakpoint */ 558 { "kgdbts_break_test", "OK", hw_break, }, /* set hw breakpoint */
558 { "c", "T0*", }, /* Continue */ 559 { "c", "T0*", }, /* Continue */
559 { "g", "kgdbts_break_test", 0, check_and_rewind_pc }, 560 { "g", "kgdbts_break_test", NULL, check_and_rewind_pc },
560 { "write", "OK", write_regs }, 561 { "write", "OK", write_regs },
561 { "kgdbts_break_test", "OK", hw_rem_break }, /*remove breakpoint */ 562 { "kgdbts_break_test", "OK", hw_rem_break }, /*remove breakpoint */
562 { "D", "OK" }, /* Detach */ 563 { "D", "OK" }, /* Detach */
563 { "D", "OK", 0, got_break }, /* If the test worked we made it here */ 564 { "D", "OK", NULL, got_break }, /* On success we made it here */
564 { "", "" }, 565 { "", "" },
565}; 566};
566 567
@@ -570,12 +571,12 @@ static struct test_struct hw_breakpoint_test[] = {
570static struct test_struct hw_write_break_test[] = { 571static struct test_struct hw_write_break_test[] = {
571 { "?", "S0*" }, /* Clear break points */ 572 { "?", "S0*" }, /* Clear break points */
572 { "hw_break_val", "OK", hw_write_break, }, /* set hw breakpoint */ 573 { "hw_break_val", "OK", hw_write_break, }, /* set hw breakpoint */
573 { "c", "T0*", 0, got_break }, /* Continue */ 574 { "c", "T0*", NULL, got_break }, /* Continue */
574 { "g", "silent", 0, check_and_rewind_pc }, 575 { "g", "silent", NULL, check_and_rewind_pc },
575 { "write", "OK", write_regs }, 576 { "write", "OK", write_regs },
576 { "hw_break_val", "OK", hw_rem_write_break }, /*remove breakpoint */ 577 { "hw_break_val", "OK", hw_rem_write_break }, /*remove breakpoint */
577 { "D", "OK" }, /* Detach */ 578 { "D", "OK" }, /* Detach */
578 { "D", "OK", 0, got_break }, /* If the test worked we made it here */ 579 { "D", "OK", NULL, got_break }, /* On success we made it here */
579 { "", "" }, 580 { "", "" },
580}; 581};
581 582
@@ -585,12 +586,12 @@ static struct test_struct hw_write_break_test[] = {
585static struct test_struct hw_access_break_test[] = { 586static struct test_struct hw_access_break_test[] = {
586 { "?", "S0*" }, /* Clear break points */ 587 { "?", "S0*" }, /* Clear break points */
587 { "hw_break_val", "OK", hw_access_break, }, /* set hw breakpoint */ 588 { "hw_break_val", "OK", hw_access_break, }, /* set hw breakpoint */
588 { "c", "T0*", 0, got_break }, /* Continue */ 589 { "c", "T0*", NULL, got_break }, /* Continue */
589 { "g", "silent", 0, check_and_rewind_pc }, 590 { "g", "silent", NULL, check_and_rewind_pc },
590 { "write", "OK", write_regs }, 591 { "write", "OK", write_regs },
591 { "hw_break_val", "OK", hw_rem_access_break }, /*remove breakpoint */ 592 { "hw_break_val", "OK", hw_rem_access_break }, /*remove breakpoint */
592 { "D", "OK" }, /* Detach */ 593 { "D", "OK" }, /* Detach */
593 { "D", "OK", 0, got_break }, /* If the test worked we made it here */ 594 { "D", "OK", NULL, got_break }, /* On success we made it here */
594 { "", "" }, 595 { "", "" },
595}; 596};
596 597
@@ -599,9 +600,9 @@ static struct test_struct hw_access_break_test[] = {
599 */ 600 */
600static struct test_struct nmi_sleep_test[] = { 601static struct test_struct nmi_sleep_test[] = {
601 { "?", "S0*" }, /* Clear break points */ 602 { "?", "S0*" }, /* Clear break points */
602 { "c", "T0*", 0, got_break }, /* Continue */ 603 { "c", "T0*", NULL, got_break }, /* Continue */
603 { "D", "OK" }, /* Detach */ 604 { "D", "OK" }, /* Detach */
604 { "D", "OK", 0, got_break }, /* If the test worked we made it here */ 605 { "D", "OK", NULL, got_break }, /* On success we made it here */
605 { "", "" }, 606 { "", "" },
606}; 607};
607 608
@@ -874,18 +875,23 @@ static void kgdbts_run_tests(void)
874{ 875{
875 char *ptr; 876 char *ptr;
876 int fork_test = 0; 877 int fork_test = 0;
877 int sys_open_test = 0; 878 int do_sys_open_test = 0;
879 int sstep_test = 1000;
878 int nmi_sleep = 0; 880 int nmi_sleep = 0;
881 int i;
879 882
880 ptr = strstr(config, "F"); 883 ptr = strstr(config, "F");
881 if (ptr) 884 if (ptr)
882 fork_test = simple_strtol(ptr+1, NULL, 10); 885 fork_test = simple_strtol(ptr + 1, NULL, 10);
883 ptr = strstr(config, "S"); 886 ptr = strstr(config, "S");
884 if (ptr) 887 if (ptr)
885 sys_open_test = simple_strtol(ptr+1, NULL, 10); 888 do_sys_open_test = simple_strtol(ptr + 1, NULL, 10);
886 ptr = strstr(config, "N"); 889 ptr = strstr(config, "N");
887 if (ptr) 890 if (ptr)
888 nmi_sleep = simple_strtol(ptr+1, NULL, 10); 891 nmi_sleep = simple_strtol(ptr+1, NULL, 10);
892 ptr = strstr(config, "I");
893 if (ptr)
894 sstep_test = simple_strtol(ptr+1, NULL, 10);
889 895
890 /* required internal KGDB tests */ 896 /* required internal KGDB tests */
891 v1printk("kgdbts:RUN plant and detach test\n"); 897 v1printk("kgdbts:RUN plant and detach test\n");
@@ -894,8 +900,13 @@ static void kgdbts_run_tests(void)
894 run_breakpoint_test(0); 900 run_breakpoint_test(0);
895 v1printk("kgdbts:RUN bad memory access test\n"); 901 v1printk("kgdbts:RUN bad memory access test\n");
896 run_bad_read_test(); 902 run_bad_read_test();
897 v1printk("kgdbts:RUN singlestep breakpoint test\n"); 903 v1printk("kgdbts:RUN singlestep test %i iterations\n", sstep_test);
898 run_singlestep_break_test(); 904 for (i = 0; i < sstep_test; i++) {
905 run_singlestep_break_test();
906 if (i % 100 == 0)
907 v1printk("kgdbts:RUN singlestep [%i/%i]\n",
908 i, sstep_test);
909 }
899 910
900 /* ===Optional tests=== */ 911 /* ===Optional tests=== */
901 912
@@ -922,7 +933,7 @@ static void kgdbts_run_tests(void)
922 repeat_test = fork_test; 933 repeat_test = fork_test;
923 printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n", 934 printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n",
924 repeat_test); 935 repeat_test);
925 kthread_run(kgdbts_unreg_thread, 0, "kgdbts_unreg"); 936 kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
926 run_do_fork_test(); 937 run_do_fork_test();
927 return; 938 return;
928 } 939 }
@@ -931,11 +942,11 @@ static void kgdbts_run_tests(void)
931 * executed because a kernel thread will be spawned at the very 942 * executed because a kernel thread will be spawned at the very
932 * end to unregister the debug hooks. 943 * end to unregister the debug hooks.
933 */ 944 */
934 if (sys_open_test) { 945 if (do_sys_open_test) {
935 repeat_test = sys_open_test; 946 repeat_test = do_sys_open_test;
936 printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n", 947 printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n",
937 repeat_test); 948 repeat_test);
938 kthread_run(kgdbts_unreg_thread, 0, "kgdbts_unreg"); 949 kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
939 run_sys_open_test(); 950 run_sys_open_test();
940 return; 951 return;
941 } 952 }
diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
index 5515234be86a..03a87a307e32 100644
--- a/drivers/misc/sgi-xp/xp.h
+++ b/drivers/misc/sgi-xp/xp.h
@@ -157,215 +157,136 @@ struct xpc_msg {
157/* 157/*
158 * Define the return values and values passed to user's callout functions. 158 * Define the return values and values passed to user's callout functions.
159 * (It is important to add new value codes at the end just preceding 159 * (It is important to add new value codes at the end just preceding
160 * xpcUnknownReason, which must have the highest numerical value.) 160 * xpUnknownReason, which must have the highest numerical value.)
161 */ 161 */
162enum xpc_retval { 162enum xp_retval {
163 xpcSuccess = 0, 163 xpSuccess = 0,
164 164
165 xpcNotConnected, /* 1: channel is not connected */ 165 xpNotConnected, /* 1: channel is not connected */
166 xpcConnected, /* 2: channel connected (opened) */ 166 xpConnected, /* 2: channel connected (opened) */
167 xpcRETIRED1, /* 3: (formerly xpcDisconnected) */ 167 xpRETIRED1, /* 3: (formerly xpDisconnected) */
168 168
169 xpcMsgReceived, /* 4: message received */ 169 xpMsgReceived, /* 4: message received */
170 xpcMsgDelivered, /* 5: message delivered and acknowledged */ 170 xpMsgDelivered, /* 5: message delivered and acknowledged */
171 171
172 xpcRETIRED2, /* 6: (formerly xpcTransferFailed) */ 172 xpRETIRED2, /* 6: (formerly xpTransferFailed) */
173 173
174 xpcNoWait, /* 7: operation would require wait */ 174 xpNoWait, /* 7: operation would require wait */
175 xpcRetry, /* 8: retry operation */ 175 xpRetry, /* 8: retry operation */
176 xpcTimeout, /* 9: timeout in xpc_allocate_msg_wait() */ 176 xpTimeout, /* 9: timeout in xpc_allocate_msg_wait() */
177 xpcInterrupted, /* 10: interrupted wait */ 177 xpInterrupted, /* 10: interrupted wait */
178 178
179 xpcUnequalMsgSizes, /* 11: message size disparity between sides */ 179 xpUnequalMsgSizes, /* 11: message size disparity between sides */
180 xpcInvalidAddress, /* 12: invalid address */ 180 xpInvalidAddress, /* 12: invalid address */
181 181
182 xpcNoMemory, /* 13: no memory available for XPC structures */ 182 xpNoMemory, /* 13: no memory available for XPC structures */
183 xpcLackOfResources, /* 14: insufficient resources for operation */ 183 xpLackOfResources, /* 14: insufficient resources for operation */
184 xpcUnregistered, /* 15: channel is not registered */ 184 xpUnregistered, /* 15: channel is not registered */
185 xpcAlreadyRegistered, /* 16: channel is already registered */ 185 xpAlreadyRegistered, /* 16: channel is already registered */
186 186
187 xpcPartitionDown, /* 17: remote partition is down */ 187 xpPartitionDown, /* 17: remote partition is down */
188 xpcNotLoaded, /* 18: XPC module is not loaded */ 188 xpNotLoaded, /* 18: XPC module is not loaded */
189 xpcUnloading, /* 19: this side is unloading XPC module */ 189 xpUnloading, /* 19: this side is unloading XPC module */
190 190
191 xpcBadMagic, /* 20: XPC MAGIC string not found */ 191 xpBadMagic, /* 20: XPC MAGIC string not found */
192 192
193 xpcReactivating, /* 21: remote partition was reactivated */ 193 xpReactivating, /* 21: remote partition was reactivated */
194 194
195 xpcUnregistering, /* 22: this side is unregistering channel */ 195 xpUnregistering, /* 22: this side is unregistering channel */
196 xpcOtherUnregistering, /* 23: other side is unregistering channel */ 196 xpOtherUnregistering, /* 23: other side is unregistering channel */
197 197
198 xpcCloneKThread, /* 24: cloning kernel thread */ 198 xpCloneKThread, /* 24: cloning kernel thread */
199 xpcCloneKThreadFailed, /* 25: cloning kernel thread failed */ 199 xpCloneKThreadFailed, /* 25: cloning kernel thread failed */
200 200
201 xpcNoHeartbeat, /* 26: remote partition has no heartbeat */ 201 xpNoHeartbeat, /* 26: remote partition has no heartbeat */
202 202
203 xpcPioReadError, /* 27: PIO read error */ 203 xpPioReadError, /* 27: PIO read error */
204 xpcPhysAddrRegFailed, /* 28: registration of phys addr range failed */ 204 xpPhysAddrRegFailed, /* 28: registration of phys addr range failed */
205 205
206 xpcBteDirectoryError, /* 29: maps to BTEFAIL_DIR */ 206 xpRETIRED3, /* 29: (formerly xpBteDirectoryError) */
207 xpcBtePoisonError, /* 30: maps to BTEFAIL_POISON */ 207 xpRETIRED4, /* 30: (formerly xpBtePoisonError) */
208 xpcBteWriteError, /* 31: maps to BTEFAIL_WERR */ 208 xpRETIRED5, /* 31: (formerly xpBteWriteError) */
209 xpcBteAccessError, /* 32: maps to BTEFAIL_ACCESS */ 209 xpRETIRED6, /* 32: (formerly xpBteAccessError) */
210 xpcBtePWriteError, /* 33: maps to BTEFAIL_PWERR */ 210 xpRETIRED7, /* 33: (formerly xpBtePWriteError) */
211 xpcBtePReadError, /* 34: maps to BTEFAIL_PRERR */ 211 xpRETIRED8, /* 34: (formerly xpBtePReadError) */
212 xpcBteTimeOutError, /* 35: maps to BTEFAIL_TOUT */ 212 xpRETIRED9, /* 35: (formerly xpBteTimeOutError) */
213 xpcBteXtalkError, /* 36: maps to BTEFAIL_XTERR */ 213 xpRETIRED10, /* 36: (formerly xpBteXtalkError) */
214 xpcBteNotAvailable, /* 37: maps to BTEFAIL_NOTAVAIL */ 214 xpRETIRED11, /* 37: (formerly xpBteNotAvailable) */
215 xpcBteUnmappedError, /* 38: unmapped BTEFAIL_ error */ 215 xpRETIRED12, /* 38: (formerly xpBteUnmappedError) */
216 216
217 xpcBadVersion, /* 39: bad version number */ 217 xpBadVersion, /* 39: bad version number */
218 xpcVarsNotSet, /* 40: the XPC variables are not set up */ 218 xpVarsNotSet, /* 40: the XPC variables are not set up */
219 xpcNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */ 219 xpNoRsvdPageAddr, /* 41: unable to get rsvd page's phys addr */
220 xpcInvalidPartid, /* 42: invalid partition ID */ 220 xpInvalidPartid, /* 42: invalid partition ID */
221 xpcLocalPartid, /* 43: local partition ID */ 221 xpLocalPartid, /* 43: local partition ID */
222 222
223 xpcOtherGoingDown, /* 44: other side going down, reason unknown */ 223 xpOtherGoingDown, /* 44: other side going down, reason unknown */
224 xpcSystemGoingDown, /* 45: system is going down, reason unknown */ 224 xpSystemGoingDown, /* 45: system is going down, reason unknown */
225 xpcSystemHalt, /* 46: system is being halted */ 225 xpSystemHalt, /* 46: system is being halted */
226 xpcSystemReboot, /* 47: system is being rebooted */ 226 xpSystemReboot, /* 47: system is being rebooted */
227 xpcSystemPoweroff, /* 48: system is being powered off */ 227 xpSystemPoweroff, /* 48: system is being powered off */
228 228
229 xpcDisconnecting, /* 49: channel disconnecting (closing) */ 229 xpDisconnecting, /* 49: channel disconnecting (closing) */
230 230
231 xpcOpenCloseError, /* 50: channel open/close protocol error */ 231 xpOpenCloseError, /* 50: channel open/close protocol error */
232 232
233 xpcDisconnected, /* 51: channel disconnected (closed) */ 233 xpDisconnected, /* 51: channel disconnected (closed) */
234 234
235 xpcBteSh2Start, /* 52: BTE CRB timeout */ 235 xpBteCopyError, /* 52: bte_copy() returned error */
236 236
237 /* 53: 0x1 BTE Error Response Short */ 237 xpUnknownReason /* 53: unknown reason - must be last in enum */
238 xpcBteSh2RspShort = xpcBteSh2Start + BTEFAIL_SH2_RESP_SHORT,
239
240 /* 54: 0x2 BTE Error Response Long */
241 xpcBteSh2RspLong = xpcBteSh2Start + BTEFAIL_SH2_RESP_LONG,
242
243 /* 56: 0x4 BTE Error Response DSB */
244 xpcBteSh2RspDSB = xpcBteSh2Start + BTEFAIL_SH2_RESP_DSP,
245
246 /* 60: 0x8 BTE Error Response Access */
247 xpcBteSh2RspAccess = xpcBteSh2Start + BTEFAIL_SH2_RESP_ACCESS,
248
249 /* 68: 0x10 BTE Error CRB timeout */
250 xpcBteSh2CRBTO = xpcBteSh2Start + BTEFAIL_SH2_CRB_TO,
251
252 /* 84: 0x20 BTE Error NACK limit */
253 xpcBteSh2NACKLimit = xpcBteSh2Start + BTEFAIL_SH2_NACK_LIMIT,
254
255 /* 115: BTE end */
256 xpcBteSh2End = xpcBteSh2Start + BTEFAIL_SH2_ALL,
257
258 xpcUnknownReason /* 116: unknown reason - must be last in enum */
259}; 238};
260 239
261/* 240/*
262 * Define the callout function types used by XPC to update the user on 241 * Define the callout function type used by XPC to update the user on
263 * connection activity and state changes (via the user function registered by 242 * connection activity and state changes via the user function registered
264 * xpc_connect()) and to notify them of messages received and delivered (via 243 * by xpc_connect().
265 * the user function registered by xpc_send_notify()).
266 *
267 * The two function types are xpc_channel_func and xpc_notify_func and
268 * both share the following arguments, with the exception of "data", which
269 * only xpc_channel_func has.
270 * 244 *
271 * Arguments: 245 * Arguments:
272 * 246 *
273 * reason - reason code. (See following table.) 247 * reason - reason code.
274 * partid - partition ID associated with condition. 248 * partid - partition ID associated with condition.
275 * ch_number - channel # associated with condition. 249 * ch_number - channel # associated with condition.
276 * data - pointer to optional data. (See following table.) 250 * data - pointer to optional data.
277 * key - pointer to optional user-defined value provided as the "key" 251 * key - pointer to optional user-defined value provided as the "key"
278 * argument to xpc_connect() or xpc_send_notify(). 252 * argument to xpc_connect().
279 * 253 *
280 * In the following table the "Optional Data" column applies to callouts made 254 * A reason code of xpConnected indicates that a connection has been
281 * to functions registered by xpc_connect(). A "NA" in that column indicates 255 * established to the specified partition on the specified channel. The data
282 * that this reason code can be passed to functions registered by 256 * argument indicates the max number of entries allowed in the message queue.
283 * xpc_send_notify() (i.e. they don't have data arguments).
284 * 257 *
285 * Also, the first three reason codes in the following table indicate 258 * A reason code of xpMsgReceived indicates that a XPC message arrived from
286 * success, whereas the others indicate failure. When a failure reason code 259 * the specified partition on the specified channel. The data argument
287 * is received, one can assume that the channel is not connected. 260 * specifies the address of the message's payload. The user must call
261 * xpc_received() when finished with the payload.
288 * 262 *
289 * 263 * All other reason codes indicate failure. The data argmument is NULL.
290 * Reason Code | Cause | Optional Data 264 * When a failure reason code is received, one can assume that the channel
291 * =====================+================================+===================== 265 * is not connected.
292 * xpcConnected | connection has been established| max #of entries
293 * | to the specified partition on | allowed in message
294 * | the specified channel | queue
295 * ---------------------+--------------------------------+---------------------
296 * xpcMsgReceived | an XPC message arrived from | address of payload
297 * | the specified partition on the |
298 * | specified channel | [the user must call
299 * | | xpc_received() when
300 * | | finished with the
301 * | | payload]
302 * ---------------------+--------------------------------+---------------------
303 * xpcMsgDelivered | notification that the message | NA
304 * | was delivered to the intended |
305 * | recipient and that they have |
306 * | acknowledged its receipt by |
307 * | calling xpc_received() |
308 * =====================+================================+=====================
309 * xpcUnequalMsgSizes | can't connect to the specified | NULL
310 * | partition on the specified |
311 * | channel because of mismatched |
312 * | message sizes |
313 * ---------------------+--------------------------------+---------------------
314 * xpcNoMemory | insufficient memory avaiable | NULL
315 * | to allocate message queue |
316 * ---------------------+--------------------------------+---------------------
317 * xpcLackOfResources | lack of resources to create | NULL
318 * | the necessary kthreads to |
319 * | support the channel |
320 * ---------------------+--------------------------------+---------------------
321 * xpcUnregistering | this side's user has | NULL or NA
322 * | unregistered by calling |
323 * | xpc_disconnect() |
324 * ---------------------+--------------------------------+---------------------
325 * xpcOtherUnregistering| the other side's user has | NULL or NA
326 * | unregistered by calling |
327 * | xpc_disconnect() |
328 * ---------------------+--------------------------------+---------------------
329 * xpcNoHeartbeat | the other side's XPC is no | NULL or NA
330 * | longer heartbeating |
331 * | |
332 * ---------------------+--------------------------------+---------------------
333 * xpcUnloading | this side's XPC module is | NULL or NA
334 * | being unloaded |
335 * | |
336 * ---------------------+--------------------------------+---------------------
337 * xpcOtherUnloading | the other side's XPC module is | NULL or NA
338 * | is being unloaded |
339 * | |
340 * ---------------------+--------------------------------+---------------------
341 * xpcPioReadError | xp_nofault_PIOR() returned an | NULL or NA
342 * | error while sending an IPI |
343 * | |
344 * ---------------------+--------------------------------+---------------------
345 * xpcInvalidAddress | the address either received or | NULL or NA
346 * | sent by the specified partition|
347 * | is invalid |
348 * ---------------------+--------------------------------+---------------------
349 * xpcBteNotAvailable | attempt to pull data from the | NULL or NA
350 * xpcBtePoisonError | specified partition over the |
351 * xpcBteWriteError | specified channel via a |
352 * xpcBteAccessError | bte_copy() failed |
353 * xpcBteTimeOutError | |
354 * xpcBteXtalkError | |
355 * xpcBteDirectoryError | |
356 * xpcBteGenericError | |
357 * xpcBteUnmappedError | |
358 * ---------------------+--------------------------------+---------------------
359 * xpcUnknownReason | the specified channel to the | NULL or NA
360 * | specified partition was |
361 * | unavailable for unknown reasons|
362 * =====================+================================+=====================
363 */ 266 */
364 267typedef void (*xpc_channel_func) (enum xp_retval reason, short partid,
365typedef void (*xpc_channel_func) (enum xpc_retval reason, partid_t partid,
366 int ch_number, void *data, void *key); 268 int ch_number, void *data, void *key);
367 269
368typedef void (*xpc_notify_func) (enum xpc_retval reason, partid_t partid, 270/*
271 * Define the callout function type used by XPC to notify the user of
272 * messages received and delivered via the user function registered by
273 * xpc_send_notify().
274 *
275 * Arguments:
276 *
277 * reason - reason code.
278 * partid - partition ID associated with condition.
279 * ch_number - channel # associated with condition.
280 * key - pointer to optional user-defined value provided as the "key"
281 * argument to xpc_send_notify().
282 *
283 * A reason code of xpMsgDelivered indicates that the message was delivered
284 * to the intended recipient and that they have acknowledged its receipt by
285 * calling xpc_received().
286 *
287 * All other reason codes indicate failure.
288 */
289typedef void (*xpc_notify_func) (enum xp_retval reason, short partid,
369 int ch_number, void *key); 290 int ch_number, void *key);
370 291
371/* 292/*
@@ -401,57 +322,57 @@ struct xpc_registration {
401struct xpc_interface { 322struct xpc_interface {
402 void (*connect) (int); 323 void (*connect) (int);
403 void (*disconnect) (int); 324 void (*disconnect) (int);
404 enum xpc_retval (*allocate) (partid_t, int, u32, void **); 325 enum xp_retval (*allocate) (short, int, u32, void **);
405 enum xpc_retval (*send) (partid_t, int, void *); 326 enum xp_retval (*send) (short, int, void *);
406 enum xpc_retval (*send_notify) (partid_t, int, void *, 327 enum xp_retval (*send_notify) (short, int, void *,
407 xpc_notify_func, void *); 328 xpc_notify_func, void *);
408 void (*received) (partid_t, int, void *); 329 void (*received) (short, int, void *);
409 enum xpc_retval (*partid_to_nasids) (partid_t, void *); 330 enum xp_retval (*partid_to_nasids) (short, void *);
410}; 331};
411 332
412extern struct xpc_interface xpc_interface; 333extern struct xpc_interface xpc_interface;
413 334
414extern void xpc_set_interface(void (*)(int), 335extern void xpc_set_interface(void (*)(int),
415 void (*)(int), 336 void (*)(int),
416 enum xpc_retval (*)(partid_t, int, u32, void **), 337 enum xp_retval (*)(short, int, u32, void **),
417 enum xpc_retval (*)(partid_t, int, void *), 338 enum xp_retval (*)(short, int, void *),
418 enum xpc_retval (*)(partid_t, int, void *, 339 enum xp_retval (*)(short, int, void *,
419 xpc_notify_func, void *), 340 xpc_notify_func, void *),
420 void (*)(partid_t, int, void *), 341 void (*)(short, int, void *),
421 enum xpc_retval (*)(partid_t, void *)); 342 enum xp_retval (*)(short, void *));
422extern void xpc_clear_interface(void); 343extern void xpc_clear_interface(void);
423 344
424extern enum xpc_retval xpc_connect(int, xpc_channel_func, void *, u16, 345extern enum xp_retval xpc_connect(int, xpc_channel_func, void *, u16,
425 u16, u32, u32); 346 u16, u32, u32);
426extern void xpc_disconnect(int); 347extern void xpc_disconnect(int);
427 348
428static inline enum xpc_retval 349static inline enum xp_retval
429xpc_allocate(partid_t partid, int ch_number, u32 flags, void **payload) 350xpc_allocate(short partid, int ch_number, u32 flags, void **payload)
430{ 351{
431 return xpc_interface.allocate(partid, ch_number, flags, payload); 352 return xpc_interface.allocate(partid, ch_number, flags, payload);
432} 353}
433 354
434static inline enum xpc_retval 355static inline enum xp_retval
435xpc_send(partid_t partid, int ch_number, void *payload) 356xpc_send(short partid, int ch_number, void *payload)
436{ 357{
437 return xpc_interface.send(partid, ch_number, payload); 358 return xpc_interface.send(partid, ch_number, payload);
438} 359}
439 360
440static inline enum xpc_retval 361static inline enum xp_retval
441xpc_send_notify(partid_t partid, int ch_number, void *payload, 362xpc_send_notify(short partid, int ch_number, void *payload,
442 xpc_notify_func func, void *key) 363 xpc_notify_func func, void *key)
443{ 364{
444 return xpc_interface.send_notify(partid, ch_number, payload, func, key); 365 return xpc_interface.send_notify(partid, ch_number, payload, func, key);
445} 366}
446 367
447static inline void 368static inline void
448xpc_received(partid_t partid, int ch_number, void *payload) 369xpc_received(short partid, int ch_number, void *payload)
449{ 370{
450 return xpc_interface.received(partid, ch_number, payload); 371 return xpc_interface.received(partid, ch_number, payload);
451} 372}
452 373
453static inline enum xpc_retval 374static inline enum xp_retval
454xpc_partid_to_nasids(partid_t partid, void *nasids) 375xpc_partid_to_nasids(short partid, void *nasids)
455{ 376{
456 return xpc_interface.partid_to_nasids(partid, nasids); 377 return xpc_interface.partid_to_nasids(partid, nasids);
457} 378}
diff --git a/drivers/misc/sgi-xp/xp_main.c b/drivers/misc/sgi-xp/xp_main.c
index 1fbf99bae963..196480b691a1 100644
--- a/drivers/misc/sgi-xp/xp_main.c
+++ b/drivers/misc/sgi-xp/xp_main.c
@@ -42,21 +42,21 @@ EXPORT_SYMBOL_GPL(xpc_registrations);
42/* 42/*
43 * Initialize the XPC interface to indicate that XPC isn't loaded. 43 * Initialize the XPC interface to indicate that XPC isn't loaded.
44 */ 44 */
45static enum xpc_retval 45static enum xp_retval
46xpc_notloaded(void) 46xpc_notloaded(void)
47{ 47{
48 return xpcNotLoaded; 48 return xpNotLoaded;
49} 49}
50 50
51struct xpc_interface xpc_interface = { 51struct xpc_interface xpc_interface = {
52 (void (*)(int))xpc_notloaded, 52 (void (*)(int))xpc_notloaded,
53 (void (*)(int))xpc_notloaded, 53 (void (*)(int))xpc_notloaded,
54 (enum xpc_retval(*)(partid_t, int, u32, void **))xpc_notloaded, 54 (enum xp_retval(*)(short, int, u32, void **))xpc_notloaded,
55 (enum xpc_retval(*)(partid_t, int, void *))xpc_notloaded, 55 (enum xp_retval(*)(short, int, void *))xpc_notloaded,
56 (enum xpc_retval(*)(partid_t, int, void *, xpc_notify_func, void *)) 56 (enum xp_retval(*)(short, int, void *, xpc_notify_func, void *))
57 xpc_notloaded, 57 xpc_notloaded,
58 (void (*)(partid_t, int, void *))xpc_notloaded, 58 (void (*)(short, int, void *))xpc_notloaded,
59 (enum xpc_retval(*)(partid_t, void *))xpc_notloaded 59 (enum xp_retval(*)(short, void *))xpc_notloaded
60}; 60};
61EXPORT_SYMBOL_GPL(xpc_interface); 61EXPORT_SYMBOL_GPL(xpc_interface);
62 62
@@ -66,12 +66,12 @@ EXPORT_SYMBOL_GPL(xpc_interface);
66void 66void
67xpc_set_interface(void (*connect) (int), 67xpc_set_interface(void (*connect) (int),
68 void (*disconnect) (int), 68 void (*disconnect) (int),
69 enum xpc_retval (*allocate) (partid_t, int, u32, void **), 69 enum xp_retval (*allocate) (short, int, u32, void **),
70 enum xpc_retval (*send) (partid_t, int, void *), 70 enum xp_retval (*send) (short, int, void *),
71 enum xpc_retval (*send_notify) (partid_t, int, void *, 71 enum xp_retval (*send_notify) (short, int, void *,
72 xpc_notify_func, void *), 72 xpc_notify_func, void *),
73 void (*received) (partid_t, int, void *), 73 void (*received) (short, int, void *),
74 enum xpc_retval (*partid_to_nasids) (partid_t, void *)) 74 enum xp_retval (*partid_to_nasids) (short, void *))
75{ 75{
76 xpc_interface.connect = connect; 76 xpc_interface.connect = connect;
77 xpc_interface.disconnect = disconnect; 77 xpc_interface.disconnect = disconnect;
@@ -91,16 +91,16 @@ xpc_clear_interface(void)
91{ 91{
92 xpc_interface.connect = (void (*)(int))xpc_notloaded; 92 xpc_interface.connect = (void (*)(int))xpc_notloaded;
93 xpc_interface.disconnect = (void (*)(int))xpc_notloaded; 93 xpc_interface.disconnect = (void (*)(int))xpc_notloaded;
94 xpc_interface.allocate = (enum xpc_retval(*)(partid_t, int, u32, 94 xpc_interface.allocate = (enum xp_retval(*)(short, int, u32,
95 void **))xpc_notloaded; 95 void **))xpc_notloaded;
96 xpc_interface.send = (enum xpc_retval(*)(partid_t, int, void *)) 96 xpc_interface.send = (enum xp_retval(*)(short, int, void *))
97 xpc_notloaded; 97 xpc_notloaded;
98 xpc_interface.send_notify = (enum xpc_retval(*)(partid_t, int, void *, 98 xpc_interface.send_notify = (enum xp_retval(*)(short, int, void *,
99 xpc_notify_func, 99 xpc_notify_func,
100 void *))xpc_notloaded; 100 void *))xpc_notloaded;
101 xpc_interface.received = (void (*)(partid_t, int, void *)) 101 xpc_interface.received = (void (*)(short, int, void *))
102 xpc_notloaded; 102 xpc_notloaded;
103 xpc_interface.partid_to_nasids = (enum xpc_retval(*)(partid_t, void *)) 103 xpc_interface.partid_to_nasids = (enum xp_retval(*)(short, void *))
104 xpc_notloaded; 104 xpc_notloaded;
105} 105}
106EXPORT_SYMBOL_GPL(xpc_clear_interface); 106EXPORT_SYMBOL_GPL(xpc_clear_interface);
@@ -123,13 +123,13 @@ EXPORT_SYMBOL_GPL(xpc_clear_interface);
123 * nentries - max #of XPC message entries a message queue can contain. 123 * nentries - max #of XPC message entries a message queue can contain.
124 * The actual number, which is determined when a connection 124 * The actual number, which is determined when a connection
125 * is established and may be less then requested, will be 125 * is established and may be less then requested, will be
126 * passed to the user via the xpcConnected callout. 126 * passed to the user via the xpConnected callout.
127 * assigned_limit - max number of kthreads allowed to be processing 127 * assigned_limit - max number of kthreads allowed to be processing
128 * messages (per connection) at any given instant. 128 * messages (per connection) at any given instant.
129 * idle_limit - max number of kthreads allowed to be idle at any given 129 * idle_limit - max number of kthreads allowed to be idle at any given
130 * instant. 130 * instant.
131 */ 131 */
132enum xpc_retval 132enum xp_retval
133xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size, 133xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
134 u16 nentries, u32 assigned_limit, u32 idle_limit) 134 u16 nentries, u32 assigned_limit, u32 idle_limit)
135{ 135{
@@ -143,12 +143,12 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
143 registration = &xpc_registrations[ch_number]; 143 registration = &xpc_registrations[ch_number];
144 144
145 if (mutex_lock_interruptible(&registration->mutex) != 0) 145 if (mutex_lock_interruptible(&registration->mutex) != 0)
146 return xpcInterrupted; 146 return xpInterrupted;
147 147
148 /* if XPC_CHANNEL_REGISTERED(ch_number) */ 148 /* if XPC_CHANNEL_REGISTERED(ch_number) */
149 if (registration->func != NULL) { 149 if (registration->func != NULL) {
150 mutex_unlock(&registration->mutex); 150 mutex_unlock(&registration->mutex);
151 return xpcAlreadyRegistered; 151 return xpAlreadyRegistered;
152 } 152 }
153 153
154 /* register the channel for connection */ 154 /* register the channel for connection */
@@ -163,7 +163,7 @@ xpc_connect(int ch_number, xpc_channel_func func, void *key, u16 payload_size,
163 163
164 xpc_interface.connect(ch_number); 164 xpc_interface.connect(ch_number);
165 165
166 return xpcSuccess; 166 return xpSuccess;
167} 167}
168EXPORT_SYMBOL_GPL(xpc_connect); 168EXPORT_SYMBOL_GPL(xpc_connect);
169 169
diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
index 9eb6d4a3269c..11ac267ed68f 100644
--- a/drivers/misc/sgi-xp/xpc.h
+++ b/drivers/misc/sgi-xp/xpc.h
@@ -172,13 +172,13 @@ struct xpc_vars {
172 (_version >= _XPC_VERSION(3, 1)) 172 (_version >= _XPC_VERSION(3, 1))
173 173
174static inline int 174static inline int
175xpc_hb_allowed(partid_t partid, struct xpc_vars *vars) 175xpc_hb_allowed(short partid, struct xpc_vars *vars)
176{ 176{
177 return ((vars->heartbeating_to_mask & (1UL << partid)) != 0); 177 return ((vars->heartbeating_to_mask & (1UL << partid)) != 0);
178} 178}
179 179
180static inline void 180static inline void
181xpc_allow_hb(partid_t partid, struct xpc_vars *vars) 181xpc_allow_hb(short partid, struct xpc_vars *vars)
182{ 182{
183 u64 old_mask, new_mask; 183 u64 old_mask, new_mask;
184 184
@@ -190,7 +190,7 @@ xpc_allow_hb(partid_t partid, struct xpc_vars *vars)
190} 190}
191 191
192static inline void 192static inline void
193xpc_disallow_hb(partid_t partid, struct xpc_vars *vars) 193xpc_disallow_hb(short partid, struct xpc_vars *vars)
194{ 194{
195 u64 old_mask, new_mask; 195 u64 old_mask, new_mask;
196 196
@@ -408,11 +408,11 @@ struct xpc_notify {
408 * messages. 408 * messages.
409 */ 409 */
410struct xpc_channel { 410struct xpc_channel {
411 partid_t partid; /* ID of remote partition connected */ 411 short partid; /* ID of remote partition connected */
412 spinlock_t lock; /* lock for updating this structure */ 412 spinlock_t lock; /* lock for updating this structure */
413 u32 flags; /* general flags */ 413 u32 flags; /* general flags */
414 414
415 enum xpc_retval reason; /* reason why channel is disconnect'g */ 415 enum xp_retval reason; /* reason why channel is disconnect'g */
416 int reason_line; /* line# disconnect initiated from */ 416 int reason_line; /* line# disconnect initiated from */
417 417
418 u16 number; /* channel # */ 418 u16 number; /* channel # */
@@ -522,7 +522,7 @@ struct xpc_partition {
522 spinlock_t act_lock; /* protect updating of act_state */ 522 spinlock_t act_lock; /* protect updating of act_state */
523 u8 act_state; /* from XPC HB viewpoint */ 523 u8 act_state; /* from XPC HB viewpoint */
524 u8 remote_vars_version; /* version# of partition's vars */ 524 u8 remote_vars_version; /* version# of partition's vars */
525 enum xpc_retval reason; /* reason partition is deactivating */ 525 enum xp_retval reason; /* reason partition is deactivating */
526 int reason_line; /* line# deactivation initiated from */ 526 int reason_line; /* line# deactivation initiated from */
527 int reactivate_nasid; /* nasid in partition to reactivate */ 527 int reactivate_nasid; /* nasid in partition to reactivate */
528 528
@@ -615,7 +615,7 @@ struct xpc_partition {
615/* interval in seconds to print 'waiting disengagement' messages */ 615/* interval in seconds to print 'waiting disengagement' messages */
616#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10 616#define XPC_DISENGAGE_PRINTMSG_INTERVAL 10
617 617
618#define XPC_PARTID(_p) ((partid_t) ((_p) - &xpc_partitions[0])) 618#define XPC_PARTID(_p) ((short)((_p) - &xpc_partitions[0]))
619 619
620/* found in xp_main.c */ 620/* found in xp_main.c */
621extern struct xpc_registration xpc_registrations[]; 621extern struct xpc_registration xpc_registrations[];
@@ -646,31 +646,31 @@ extern void xpc_allow_IPI_ops(void);
646extern void xpc_restrict_IPI_ops(void); 646extern void xpc_restrict_IPI_ops(void);
647extern int xpc_identify_act_IRQ_sender(void); 647extern int xpc_identify_act_IRQ_sender(void);
648extern int xpc_partition_disengaged(struct xpc_partition *); 648extern int xpc_partition_disengaged(struct xpc_partition *);
649extern enum xpc_retval xpc_mark_partition_active(struct xpc_partition *); 649extern enum xp_retval xpc_mark_partition_active(struct xpc_partition *);
650extern void xpc_mark_partition_inactive(struct xpc_partition *); 650extern void xpc_mark_partition_inactive(struct xpc_partition *);
651extern void xpc_discovery(void); 651extern void xpc_discovery(void);
652extern void xpc_check_remote_hb(void); 652extern void xpc_check_remote_hb(void);
653extern void xpc_deactivate_partition(const int, struct xpc_partition *, 653extern void xpc_deactivate_partition(const int, struct xpc_partition *,
654 enum xpc_retval); 654 enum xp_retval);
655extern enum xpc_retval xpc_initiate_partid_to_nasids(partid_t, void *); 655extern enum xp_retval xpc_initiate_partid_to_nasids(short, void *);
656 656
657/* found in xpc_channel.c */ 657/* found in xpc_channel.c */
658extern void xpc_initiate_connect(int); 658extern void xpc_initiate_connect(int);
659extern void xpc_initiate_disconnect(int); 659extern void xpc_initiate_disconnect(int);
660extern enum xpc_retval xpc_initiate_allocate(partid_t, int, u32, void **); 660extern enum xp_retval xpc_initiate_allocate(short, int, u32, void **);
661extern enum xpc_retval xpc_initiate_send(partid_t, int, void *); 661extern enum xp_retval xpc_initiate_send(short, int, void *);
662extern enum xpc_retval xpc_initiate_send_notify(partid_t, int, void *, 662extern enum xp_retval xpc_initiate_send_notify(short, int, void *,
663 xpc_notify_func, void *); 663 xpc_notify_func, void *);
664extern void xpc_initiate_received(partid_t, int, void *); 664extern void xpc_initiate_received(short, int, void *);
665extern enum xpc_retval xpc_setup_infrastructure(struct xpc_partition *); 665extern enum xp_retval xpc_setup_infrastructure(struct xpc_partition *);
666extern enum xpc_retval xpc_pull_remote_vars_part(struct xpc_partition *); 666extern enum xp_retval xpc_pull_remote_vars_part(struct xpc_partition *);
667extern void xpc_process_channel_activity(struct xpc_partition *); 667extern void xpc_process_channel_activity(struct xpc_partition *);
668extern void xpc_connected_callout(struct xpc_channel *); 668extern void xpc_connected_callout(struct xpc_channel *);
669extern void xpc_deliver_msg(struct xpc_channel *); 669extern void xpc_deliver_msg(struct xpc_channel *);
670extern void xpc_disconnect_channel(const int, struct xpc_channel *, 670extern void xpc_disconnect_channel(const int, struct xpc_channel *,
671 enum xpc_retval, unsigned long *); 671 enum xp_retval, unsigned long *);
672extern void xpc_disconnect_callout(struct xpc_channel *, enum xpc_retval); 672extern void xpc_disconnect_callout(struct xpc_channel *, enum xp_retval);
673extern void xpc_partition_going_down(struct xpc_partition *, enum xpc_retval); 673extern void xpc_partition_going_down(struct xpc_partition *, enum xp_retval);
674extern void xpc_teardown_infrastructure(struct xpc_partition *); 674extern void xpc_teardown_infrastructure(struct xpc_partition *);
675 675
676static inline void 676static inline void
@@ -901,7 +901,7 @@ xpc_IPI_receive(AMO_t *amo)
901 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR); 901 return FETCHOP_LOAD_OP(TO_AMO((u64)&amo->variable), FETCHOP_CLEAR);
902} 902}
903 903
904static inline enum xpc_retval 904static inline enum xp_retval
905xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector) 905xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
906{ 906{
907 int ret = 0; 907 int ret = 0;
@@ -923,7 +923,7 @@ xpc_IPI_send(AMO_t *amo, u64 flag, int nasid, int phys_cpuid, int vector)
923 923
924 local_irq_restore(irq_flags); 924 local_irq_restore(irq_flags);
925 925
926 return ((ret == 0) ? xpcSuccess : xpcPioReadError); 926 return ((ret == 0) ? xpSuccess : xpPioReadError);
927} 927}
928 928
929/* 929/*
@@ -992,7 +992,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
992 unsigned long *irq_flags) 992 unsigned long *irq_flags)
993{ 993{
994 struct xpc_partition *part = &xpc_partitions[ch->partid]; 994 struct xpc_partition *part = &xpc_partitions[ch->partid];
995 enum xpc_retval ret; 995 enum xp_retval ret;
996 996
997 if (likely(part->act_state != XPC_P_DEACTIVATING)) { 997 if (likely(part->act_state != XPC_P_DEACTIVATING)) {
998 ret = xpc_IPI_send(part->remote_IPI_amo_va, 998 ret = xpc_IPI_send(part->remote_IPI_amo_va,
@@ -1001,7 +1001,7 @@ xpc_notify_IRQ_send(struct xpc_channel *ch, u8 ipi_flag, char *ipi_flag_string,
1001 part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY); 1001 part->remote_IPI_phys_cpuid, SGI_XPC_NOTIFY);
1002 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n", 1002 dev_dbg(xpc_chan, "%s sent to partid=%d, channel=%d, ret=%d\n",
1003 ipi_flag_string, ch->partid, ch->number, ret); 1003 ipi_flag_string, ch->partid, ch->number, ret);
1004 if (unlikely(ret != xpcSuccess)) { 1004 if (unlikely(ret != xpSuccess)) {
1005 if (irq_flags != NULL) 1005 if (irq_flags != NULL)
1006 spin_unlock_irqrestore(&ch->lock, *irq_flags); 1006 spin_unlock_irqrestore(&ch->lock, *irq_flags);
1007 XPC_DEACTIVATE_PARTITION(part, ret); 1007 XPC_DEACTIVATE_PARTITION(part, ret);
@@ -1123,41 +1123,10 @@ xpc_IPI_init(int index)
1123 return amo; 1123 return amo;
1124} 1124}
1125 1125
1126static inline enum xpc_retval 1126static inline enum xp_retval
1127xpc_map_bte_errors(bte_result_t error) 1127xpc_map_bte_errors(bte_result_t error)
1128{ 1128{
1129 if (error == BTE_SUCCESS) 1129 return ((error == BTE_SUCCESS) ? xpSuccess : xpBteCopyError);
1130 return xpcSuccess;
1131
1132 if (is_shub2()) {
1133 if (BTE_VALID_SH2_ERROR(error))
1134 return xpcBteSh2Start + error;
1135 return xpcBteUnmappedError;
1136 }
1137 switch (error) {
1138 case BTE_SUCCESS:
1139 return xpcSuccess;
1140 case BTEFAIL_DIR:
1141 return xpcBteDirectoryError;
1142 case BTEFAIL_POISON:
1143 return xpcBtePoisonError;
1144 case BTEFAIL_WERR:
1145 return xpcBteWriteError;
1146 case BTEFAIL_ACCESS:
1147 return xpcBteAccessError;
1148 case BTEFAIL_PWERR:
1149 return xpcBtePWriteError;
1150 case BTEFAIL_PRERR:
1151 return xpcBtePReadError;
1152 case BTEFAIL_TOUT:
1153 return xpcBteTimeOutError;
1154 case BTEFAIL_XTERR:
1155 return xpcBteXtalkError;
1156 case BTEFAIL_NOTAVAIL:
1157 return xpcBteNotAvailable;
1158 default:
1159 return xpcBteUnmappedError;
1160 }
1161} 1130}
1162 1131
1163/* 1132/*
diff --git a/drivers/misc/sgi-xp/xpc_channel.c b/drivers/misc/sgi-xp/xpc_channel.c
index bfcb9ea968e9..9c90c2d55c08 100644
--- a/drivers/misc/sgi-xp/xpc_channel.c
+++ b/drivers/misc/sgi-xp/xpc_channel.c
@@ -53,7 +53,7 @@ xpc_kzalloc_cacheline_aligned(size_t size, gfp_t flags, void **base)
53 * Set up the initial values for the XPartition Communication channels. 53 * Set up the initial values for the XPartition Communication channels.
54 */ 54 */
55static void 55static void
56xpc_initialize_channels(struct xpc_partition *part, partid_t partid) 56xpc_initialize_channels(struct xpc_partition *part, short partid)
57{ 57{
58 int ch_number; 58 int ch_number;
59 struct xpc_channel *ch; 59 struct xpc_channel *ch;
@@ -90,12 +90,12 @@ xpc_initialize_channels(struct xpc_partition *part, partid_t partid)
90 * Setup the infrastructure necessary to support XPartition Communication 90 * Setup the infrastructure necessary to support XPartition Communication
91 * between the specified remote partition and the local one. 91 * between the specified remote partition and the local one.
92 */ 92 */
93enum xpc_retval 93enum xp_retval
94xpc_setup_infrastructure(struct xpc_partition *part) 94xpc_setup_infrastructure(struct xpc_partition *part)
95{ 95{
96 int ret, cpuid; 96 int ret, cpuid;
97 struct timer_list *timer; 97 struct timer_list *timer;
98 partid_t partid = XPC_PARTID(part); 98 short partid = XPC_PARTID(part);
99 99
100 /* 100 /*
101 * Zero out MOST of the entry for this partition. Only the fields 101 * Zero out MOST of the entry for this partition. Only the fields
@@ -114,7 +114,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
114 GFP_KERNEL); 114 GFP_KERNEL);
115 if (part->channels == NULL) { 115 if (part->channels == NULL) {
116 dev_err(xpc_chan, "can't get memory for channels\n"); 116 dev_err(xpc_chan, "can't get memory for channels\n");
117 return xpcNoMemory; 117 return xpNoMemory;
118 } 118 }
119 119
120 part->nchannels = XPC_NCHANNELS; 120 part->nchannels = XPC_NCHANNELS;
@@ -129,7 +129,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
129 part->channels = NULL; 129 part->channels = NULL;
130 dev_err(xpc_chan, "can't get memory for local get/put " 130 dev_err(xpc_chan, "can't get memory for local get/put "
131 "values\n"); 131 "values\n");
132 return xpcNoMemory; 132 return xpNoMemory;
133 } 133 }
134 134
135 part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE, 135 part->remote_GPs = xpc_kzalloc_cacheline_aligned(XPC_GP_SIZE,
@@ -143,7 +143,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
143 part->local_GPs = NULL; 143 part->local_GPs = NULL;
144 kfree(part->channels); 144 kfree(part->channels);
145 part->channels = NULL; 145 part->channels = NULL;
146 return xpcNoMemory; 146 return xpNoMemory;
147 } 147 }
148 148
149 /* allocate all the required open and close args */ 149 /* allocate all the required open and close args */
@@ -159,7 +159,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
159 part->local_GPs = NULL; 159 part->local_GPs = NULL;
160 kfree(part->channels); 160 kfree(part->channels);
161 part->channels = NULL; 161 part->channels = NULL;
162 return xpcNoMemory; 162 return xpNoMemory;
163 } 163 }
164 164
165 part->remote_openclose_args = 165 part->remote_openclose_args =
@@ -175,7 +175,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
175 part->local_GPs = NULL; 175 part->local_GPs = NULL;
176 kfree(part->channels); 176 kfree(part->channels);
177 part->channels = NULL; 177 part->channels = NULL;
178 return xpcNoMemory; 178 return xpNoMemory;
179 } 179 }
180 180
181 xpc_initialize_channels(part, partid); 181 xpc_initialize_channels(part, partid);
@@ -209,7 +209,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
209 part->local_GPs = NULL; 209 part->local_GPs = NULL;
210 kfree(part->channels); 210 kfree(part->channels);
211 part->channels = NULL; 211 part->channels = NULL;
212 return xpcLackOfResources; 212 return xpLackOfResources;
213 } 213 }
214 214
215 /* Setup a timer to check for dropped IPIs */ 215 /* Setup a timer to check for dropped IPIs */
@@ -243,7 +243,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
243 xpc_vars_part[partid].nchannels = part->nchannels; 243 xpc_vars_part[partid].nchannels = part->nchannels;
244 xpc_vars_part[partid].magic = XPC_VP_MAGIC1; 244 xpc_vars_part[partid].magic = XPC_VP_MAGIC1;
245 245
246 return xpcSuccess; 246 return xpSuccess;
247} 247}
248 248
249/* 249/*
@@ -254,7 +254,7 @@ xpc_setup_infrastructure(struct xpc_partition *part)
254 * dst must be a cacheline aligned virtual address on this partition. 254 * dst must be a cacheline aligned virtual address on this partition.
255 * cnt must be an cacheline sized 255 * cnt must be an cacheline sized
256 */ 256 */
257static enum xpc_retval 257static enum xp_retval
258xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst, 258xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
259 const void *src, size_t cnt) 259 const void *src, size_t cnt)
260{ 260{
@@ -270,7 +270,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
270 bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt, 270 bte_ret = xp_bte_copy((u64)src, (u64)dst, (u64)cnt,
271 (BTE_NORMAL | BTE_WACQUIRE), NULL); 271 (BTE_NORMAL | BTE_WACQUIRE), NULL);
272 if (bte_ret == BTE_SUCCESS) 272 if (bte_ret == BTE_SUCCESS)
273 return xpcSuccess; 273 return xpSuccess;
274 274
275 dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n", 275 dev_dbg(xpc_chan, "xp_bte_copy() from partition %d failed, ret=%d\n",
276 XPC_PARTID(part), bte_ret); 276 XPC_PARTID(part), bte_ret);
@@ -282,7 +282,7 @@ xpc_pull_remote_cachelines(struct xpc_partition *part, void *dst,
282 * Pull the remote per partition specific variables from the specified 282 * Pull the remote per partition specific variables from the specified
283 * partition. 283 * partition.
284 */ 284 */
285enum xpc_retval 285enum xp_retval
286xpc_pull_remote_vars_part(struct xpc_partition *part) 286xpc_pull_remote_vars_part(struct xpc_partition *part)
287{ 287{
288 u8 buffer[L1_CACHE_BYTES * 2]; 288 u8 buffer[L1_CACHE_BYTES * 2];
@@ -290,8 +290,8 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
290 (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer); 290 (struct xpc_vars_part *)L1_CACHE_ALIGN((u64)buffer);
291 struct xpc_vars_part *pulled_entry; 291 struct xpc_vars_part *pulled_entry;
292 u64 remote_entry_cacheline_pa, remote_entry_pa; 292 u64 remote_entry_cacheline_pa, remote_entry_pa;
293 partid_t partid = XPC_PARTID(part); 293 short partid = XPC_PARTID(part);
294 enum xpc_retval ret; 294 enum xp_retval ret;
295 295
296 /* pull the cacheline that contains the variables we're interested in */ 296 /* pull the cacheline that contains the variables we're interested in */
297 297
@@ -311,7 +311,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
311 ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline, 311 ret = xpc_pull_remote_cachelines(part, pulled_entry_cacheline,
312 (void *)remote_entry_cacheline_pa, 312 (void *)remote_entry_cacheline_pa,
313 L1_CACHE_BYTES); 313 L1_CACHE_BYTES);
314 if (ret != xpcSuccess) { 314 if (ret != xpSuccess) {
315 dev_dbg(xpc_chan, "failed to pull XPC vars_part from " 315 dev_dbg(xpc_chan, "failed to pull XPC vars_part from "
316 "partition %d, ret=%d\n", partid, ret); 316 "partition %d, ret=%d\n", partid, ret);
317 return ret; 317 return ret;
@@ -326,11 +326,11 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
326 dev_dbg(xpc_chan, "partition %d's XPC vars_part for " 326 dev_dbg(xpc_chan, "partition %d's XPC vars_part for "
327 "partition %d has bad magic value (=0x%lx)\n", 327 "partition %d has bad magic value (=0x%lx)\n",
328 partid, sn_partition_id, pulled_entry->magic); 328 partid, sn_partition_id, pulled_entry->magic);
329 return xpcBadMagic; 329 return xpBadMagic;
330 } 330 }
331 331
332 /* they've not been initialized yet */ 332 /* they've not been initialized yet */
333 return xpcRetry; 333 return xpRetry;
334 } 334 }
335 335
336 if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) { 336 if (xpc_vars_part[partid].magic == XPC_VP_MAGIC1) {
@@ -344,7 +344,7 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
344 dev_err(xpc_chan, "partition %d's XPC vars_part for " 344 dev_err(xpc_chan, "partition %d's XPC vars_part for "
345 "partition %d are not valid\n", partid, 345 "partition %d are not valid\n", partid,
346 sn_partition_id); 346 sn_partition_id);
347 return xpcInvalidAddress; 347 return xpInvalidAddress;
348 } 348 }
349 349
350 /* the variables we imported look to be valid */ 350 /* the variables we imported look to be valid */
@@ -366,9 +366,9 @@ xpc_pull_remote_vars_part(struct xpc_partition *part)
366 } 366 }
367 367
368 if (pulled_entry->magic == XPC_VP_MAGIC1) 368 if (pulled_entry->magic == XPC_VP_MAGIC1)
369 return xpcRetry; 369 return xpRetry;
370 370
371 return xpcSuccess; 371 return xpSuccess;
372} 372}
373 373
374/* 374/*
@@ -379,7 +379,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
379{ 379{
380 unsigned long irq_flags; 380 unsigned long irq_flags;
381 u64 IPI_amo; 381 u64 IPI_amo;
382 enum xpc_retval ret; 382 enum xp_retval ret;
383 383
384 /* 384 /*
385 * See if there are any IPI flags to be handled. 385 * See if there are any IPI flags to be handled.
@@ -398,7 +398,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
398 (void *)part-> 398 (void *)part->
399 remote_openclose_args_pa, 399 remote_openclose_args_pa,
400 XPC_OPENCLOSE_ARGS_SIZE); 400 XPC_OPENCLOSE_ARGS_SIZE);
401 if (ret != xpcSuccess) { 401 if (ret != xpSuccess) {
402 XPC_DEACTIVATE_PARTITION(part, ret); 402 XPC_DEACTIVATE_PARTITION(part, ret);
403 403
404 dev_dbg(xpc_chan, "failed to pull openclose args from " 404 dev_dbg(xpc_chan, "failed to pull openclose args from "
@@ -414,7 +414,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
414 ret = xpc_pull_remote_cachelines(part, part->remote_GPs, 414 ret = xpc_pull_remote_cachelines(part, part->remote_GPs,
415 (void *)part->remote_GPs_pa, 415 (void *)part->remote_GPs_pa,
416 XPC_GP_SIZE); 416 XPC_GP_SIZE);
417 if (ret != xpcSuccess) { 417 if (ret != xpSuccess) {
418 XPC_DEACTIVATE_PARTITION(part, ret); 418 XPC_DEACTIVATE_PARTITION(part, ret);
419 419
420 dev_dbg(xpc_chan, "failed to pull GPs from partition " 420 dev_dbg(xpc_chan, "failed to pull GPs from partition "
@@ -431,7 +431,7 @@ xpc_get_IPI_flags(struct xpc_partition *part)
431/* 431/*
432 * Allocate the local message queue and the notify queue. 432 * Allocate the local message queue and the notify queue.
433 */ 433 */
434static enum xpc_retval 434static enum xp_retval
435xpc_allocate_local_msgqueue(struct xpc_channel *ch) 435xpc_allocate_local_msgqueue(struct xpc_channel *ch)
436{ 436{
437 unsigned long irq_flags; 437 unsigned long irq_flags;
@@ -464,18 +464,18 @@ xpc_allocate_local_msgqueue(struct xpc_channel *ch)
464 ch->local_nentries = nentries; 464 ch->local_nentries = nentries;
465 } 465 }
466 spin_unlock_irqrestore(&ch->lock, irq_flags); 466 spin_unlock_irqrestore(&ch->lock, irq_flags);
467 return xpcSuccess; 467 return xpSuccess;
468 } 468 }
469 469
470 dev_dbg(xpc_chan, "can't get memory for local message queue and notify " 470 dev_dbg(xpc_chan, "can't get memory for local message queue and notify "
471 "queue, partid=%d, channel=%d\n", ch->partid, ch->number); 471 "queue, partid=%d, channel=%d\n", ch->partid, ch->number);
472 return xpcNoMemory; 472 return xpNoMemory;
473} 473}
474 474
475/* 475/*
476 * Allocate the cached remote message queue. 476 * Allocate the cached remote message queue.
477 */ 477 */
478static enum xpc_retval 478static enum xp_retval
479xpc_allocate_remote_msgqueue(struct xpc_channel *ch) 479xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
480{ 480{
481 unsigned long irq_flags; 481 unsigned long irq_flags;
@@ -502,12 +502,12 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
502 ch->remote_nentries = nentries; 502 ch->remote_nentries = nentries;
503 } 503 }
504 spin_unlock_irqrestore(&ch->lock, irq_flags); 504 spin_unlock_irqrestore(&ch->lock, irq_flags);
505 return xpcSuccess; 505 return xpSuccess;
506 } 506 }
507 507
508 dev_dbg(xpc_chan, "can't get memory for cached remote message queue, " 508 dev_dbg(xpc_chan, "can't get memory for cached remote message queue, "
509 "partid=%d, channel=%d\n", ch->partid, ch->number); 509 "partid=%d, channel=%d\n", ch->partid, ch->number);
510 return xpcNoMemory; 510 return xpNoMemory;
511} 511}
512 512
513/* 513/*
@@ -515,20 +515,20 @@ xpc_allocate_remote_msgqueue(struct xpc_channel *ch)
515 * 515 *
516 * Note: Assumes all of the channel sizes are filled in. 516 * Note: Assumes all of the channel sizes are filled in.
517 */ 517 */
518static enum xpc_retval 518static enum xp_retval
519xpc_allocate_msgqueues(struct xpc_channel *ch) 519xpc_allocate_msgqueues(struct xpc_channel *ch)
520{ 520{
521 unsigned long irq_flags; 521 unsigned long irq_flags;
522 enum xpc_retval ret; 522 enum xp_retval ret;
523 523
524 DBUG_ON(ch->flags & XPC_C_SETUP); 524 DBUG_ON(ch->flags & XPC_C_SETUP);
525 525
526 ret = xpc_allocate_local_msgqueue(ch); 526 ret = xpc_allocate_local_msgqueue(ch);
527 if (ret != xpcSuccess) 527 if (ret != xpSuccess)
528 return ret; 528 return ret;
529 529
530 ret = xpc_allocate_remote_msgqueue(ch); 530 ret = xpc_allocate_remote_msgqueue(ch);
531 if (ret != xpcSuccess) { 531 if (ret != xpSuccess) {
532 kfree(ch->local_msgqueue_base); 532 kfree(ch->local_msgqueue_base);
533 ch->local_msgqueue = NULL; 533 ch->local_msgqueue = NULL;
534 kfree(ch->notify_queue); 534 kfree(ch->notify_queue);
@@ -540,7 +540,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch)
540 ch->flags |= XPC_C_SETUP; 540 ch->flags |= XPC_C_SETUP;
541 spin_unlock_irqrestore(&ch->lock, irq_flags); 541 spin_unlock_irqrestore(&ch->lock, irq_flags);
542 542
543 return xpcSuccess; 543 return xpSuccess;
544} 544}
545 545
546/* 546/*
@@ -552,7 +552,7 @@ xpc_allocate_msgqueues(struct xpc_channel *ch)
552static void 552static void
553xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags) 553xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
554{ 554{
555 enum xpc_retval ret; 555 enum xp_retval ret;
556 556
557 DBUG_ON(!spin_is_locked(&ch->lock)); 557 DBUG_ON(!spin_is_locked(&ch->lock));
558 558
@@ -568,7 +568,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
568 ret = xpc_allocate_msgqueues(ch); 568 ret = xpc_allocate_msgqueues(ch);
569 spin_lock_irqsave(&ch->lock, *irq_flags); 569 spin_lock_irqsave(&ch->lock, *irq_flags);
570 570
571 if (ret != xpcSuccess) 571 if (ret != xpSuccess)
572 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags); 572 XPC_DISCONNECT_CHANNEL(ch, ret, irq_flags);
573 573
574 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING)) 574 if (ch->flags & (XPC_C_CONNECTED | XPC_C_DISCONNECTING))
@@ -603,7 +603,7 @@ xpc_process_connect(struct xpc_channel *ch, unsigned long *irq_flags)
603 * Notify those who wanted to be notified upon delivery of their message. 603 * Notify those who wanted to be notified upon delivery of their message.
604 */ 604 */
605static void 605static void
606xpc_notify_senders(struct xpc_channel *ch, enum xpc_retval reason, s64 put) 606xpc_notify_senders(struct xpc_channel *ch, enum xp_retval reason, s64 put)
607{ 607{
608 struct xpc_notify *notify; 608 struct xpc_notify *notify;
609 u8 notify_type; 609 u8 notify_type;
@@ -748,7 +748,7 @@ xpc_process_disconnect(struct xpc_channel *ch, unsigned long *irq_flags)
748 748
749 if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) { 749 if (ch->flags & XPC_C_DISCONNECTINGCALLOUT_MADE) {
750 spin_unlock_irqrestore(&ch->lock, *irq_flags); 750 spin_unlock_irqrestore(&ch->lock, *irq_flags);
751 xpc_disconnect_callout(ch, xpcDisconnected); 751 xpc_disconnect_callout(ch, xpDisconnected);
752 spin_lock_irqsave(&ch->lock, *irq_flags); 752 spin_lock_irqsave(&ch->lock, *irq_flags);
753 } 753 }
754 754
@@ -791,7 +791,7 @@ xpc_process_openclose_IPI(struct xpc_partition *part, int ch_number,
791 struct xpc_openclose_args *args = 791 struct xpc_openclose_args *args =
792 &part->remote_openclose_args[ch_number]; 792 &part->remote_openclose_args[ch_number];
793 struct xpc_channel *ch = &part->channels[ch_number]; 793 struct xpc_channel *ch = &part->channels[ch_number];
794 enum xpc_retval reason; 794 enum xp_retval reason;
795 795
796 spin_lock_irqsave(&ch->lock, irq_flags); 796 spin_lock_irqsave(&ch->lock, irq_flags);
797 797
@@ -871,10 +871,10 @@ again:
871 871
872 if (!(ch->flags & XPC_C_DISCONNECTING)) { 872 if (!(ch->flags & XPC_C_DISCONNECTING)) {
873 reason = args->reason; 873 reason = args->reason;
874 if (reason <= xpcSuccess || reason > xpcUnknownReason) 874 if (reason <= xpSuccess || reason > xpUnknownReason)
875 reason = xpcUnknownReason; 875 reason = xpUnknownReason;
876 else if (reason == xpcUnregistering) 876 else if (reason == xpUnregistering)
877 reason = xpcOtherUnregistering; 877 reason = xpOtherUnregistering;
878 878
879 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags); 879 XPC_DISCONNECT_CHANNEL(ch, reason, &irq_flags);
880 880
@@ -961,7 +961,7 @@ again:
961 961
962 if (ch->flags & XPC_C_OPENREQUEST) { 962 if (ch->flags & XPC_C_OPENREQUEST) {
963 if (args->msg_size != ch->msg_size) { 963 if (args->msg_size != ch->msg_size) {
964 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, 964 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
965 &irq_flags); 965 &irq_flags);
966 spin_unlock_irqrestore(&ch->lock, irq_flags); 966 spin_unlock_irqrestore(&ch->lock, irq_flags);
967 return; 967 return;
@@ -991,7 +991,7 @@ again:
991 return; 991 return;
992 } 992 }
993 if (!(ch->flags & XPC_C_OPENREQUEST)) { 993 if (!(ch->flags & XPC_C_OPENREQUEST)) {
994 XPC_DISCONNECT_CHANNEL(ch, xpcOpenCloseError, 994 XPC_DISCONNECT_CHANNEL(ch, xpOpenCloseError,
995 &irq_flags); 995 &irq_flags);
996 spin_unlock_irqrestore(&ch->lock, irq_flags); 996 spin_unlock_irqrestore(&ch->lock, irq_flags);
997 return; 997 return;
@@ -1042,18 +1042,18 @@ again:
1042/* 1042/*
1043 * Attempt to establish a channel connection to a remote partition. 1043 * Attempt to establish a channel connection to a remote partition.
1044 */ 1044 */
1045static enum xpc_retval 1045static enum xp_retval
1046xpc_connect_channel(struct xpc_channel *ch) 1046xpc_connect_channel(struct xpc_channel *ch)
1047{ 1047{
1048 unsigned long irq_flags; 1048 unsigned long irq_flags;
1049 struct xpc_registration *registration = &xpc_registrations[ch->number]; 1049 struct xpc_registration *registration = &xpc_registrations[ch->number];
1050 1050
1051 if (mutex_trylock(&registration->mutex) == 0) 1051 if (mutex_trylock(&registration->mutex) == 0)
1052 return xpcRetry; 1052 return xpRetry;
1053 1053
1054 if (!XPC_CHANNEL_REGISTERED(ch->number)) { 1054 if (!XPC_CHANNEL_REGISTERED(ch->number)) {
1055 mutex_unlock(&registration->mutex); 1055 mutex_unlock(&registration->mutex);
1056 return xpcUnregistered; 1056 return xpUnregistered;
1057 } 1057 }
1058 1058
1059 spin_lock_irqsave(&ch->lock, irq_flags); 1059 spin_lock_irqsave(&ch->lock, irq_flags);
@@ -1095,10 +1095,10 @@ xpc_connect_channel(struct xpc_channel *ch)
1095 * the channel lock as needed. 1095 * the channel lock as needed.
1096 */ 1096 */
1097 mutex_unlock(&registration->mutex); 1097 mutex_unlock(&registration->mutex);
1098 XPC_DISCONNECT_CHANNEL(ch, xpcUnequalMsgSizes, 1098 XPC_DISCONNECT_CHANNEL(ch, xpUnequalMsgSizes,
1099 &irq_flags); 1099 &irq_flags);
1100 spin_unlock_irqrestore(&ch->lock, irq_flags); 1100 spin_unlock_irqrestore(&ch->lock, irq_flags);
1101 return xpcUnequalMsgSizes; 1101 return xpUnequalMsgSizes;
1102 } 1102 }
1103 } else { 1103 } else {
1104 ch->msg_size = registration->msg_size; 1104 ch->msg_size = registration->msg_size;
@@ -1120,7 +1120,7 @@ xpc_connect_channel(struct xpc_channel *ch)
1120 1120
1121 spin_unlock_irqrestore(&ch->lock, irq_flags); 1121 spin_unlock_irqrestore(&ch->lock, irq_flags);
1122 1122
1123 return xpcSuccess; 1123 return xpSuccess;
1124} 1124}
1125 1125
1126/* 1126/*
@@ -1203,7 +1203,7 @@ xpc_process_msg_IPI(struct xpc_partition *part, int ch_number)
1203 * Notify senders that messages sent have been 1203 * Notify senders that messages sent have been
1204 * received and delivered by the other side. 1204 * received and delivered by the other side.
1205 */ 1205 */
1206 xpc_notify_senders(ch, xpcMsgDelivered, 1206 xpc_notify_senders(ch, xpMsgDelivered,
1207 ch->remote_GP.get); 1207 ch->remote_GP.get);
1208 } 1208 }
1209 1209
@@ -1335,7 +1335,7 @@ xpc_process_channel_activity(struct xpc_partition *part)
1335 * at the same time. 1335 * at the same time.
1336 */ 1336 */
1337void 1337void
1338xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason) 1338xpc_partition_going_down(struct xpc_partition *part, enum xp_retval reason)
1339{ 1339{
1340 unsigned long irq_flags; 1340 unsigned long irq_flags;
1341 int ch_number; 1341 int ch_number;
@@ -1375,7 +1375,7 @@ xpc_partition_going_down(struct xpc_partition *part, enum xpc_retval reason)
1375void 1375void
1376xpc_teardown_infrastructure(struct xpc_partition *part) 1376xpc_teardown_infrastructure(struct xpc_partition *part)
1377{ 1377{
1378 partid_t partid = XPC_PARTID(part); 1378 short partid = XPC_PARTID(part);
1379 1379
1380 /* 1380 /*
1381 * We start off by making this partition inaccessible to local 1381 * We start off by making this partition inaccessible to local
@@ -1428,7 +1428,7 @@ xpc_teardown_infrastructure(struct xpc_partition *part)
1428void 1428void
1429xpc_initiate_connect(int ch_number) 1429xpc_initiate_connect(int ch_number)
1430{ 1430{
1431 partid_t partid; 1431 short partid;
1432 struct xpc_partition *part; 1432 struct xpc_partition *part;
1433 struct xpc_channel *ch; 1433 struct xpc_channel *ch;
1434 1434
@@ -1456,13 +1456,13 @@ xpc_connected_callout(struct xpc_channel *ch)
1456 /* let the registerer know that a connection has been established */ 1456 /* let the registerer know that a connection has been established */
1457 1457
1458 if (ch->func != NULL) { 1458 if (ch->func != NULL) {
1459 dev_dbg(xpc_chan, "ch->func() called, reason=xpcConnected, " 1459 dev_dbg(xpc_chan, "ch->func() called, reason=xpConnected, "
1460 "partid=%d, channel=%d\n", ch->partid, ch->number); 1460 "partid=%d, channel=%d\n", ch->partid, ch->number);
1461 1461
1462 ch->func(xpcConnected, ch->partid, ch->number, 1462 ch->func(xpConnected, ch->partid, ch->number,
1463 (void *)(u64)ch->local_nentries, ch->key); 1463 (void *)(u64)ch->local_nentries, ch->key);
1464 1464
1465 dev_dbg(xpc_chan, "ch->func() returned, reason=xpcConnected, " 1465 dev_dbg(xpc_chan, "ch->func() returned, reason=xpConnected, "
1466 "partid=%d, channel=%d\n", ch->partid, ch->number); 1466 "partid=%d, channel=%d\n", ch->partid, ch->number);
1467 } 1467 }
1468} 1468}
@@ -1484,7 +1484,7 @@ void
1484xpc_initiate_disconnect(int ch_number) 1484xpc_initiate_disconnect(int ch_number)
1485{ 1485{
1486 unsigned long irq_flags; 1486 unsigned long irq_flags;
1487 partid_t partid; 1487 short partid;
1488 struct xpc_partition *part; 1488 struct xpc_partition *part;
1489 struct xpc_channel *ch; 1489 struct xpc_channel *ch;
1490 1490
@@ -1503,7 +1503,7 @@ xpc_initiate_disconnect(int ch_number)
1503 if (!(ch->flags & XPC_C_DISCONNECTED)) { 1503 if (!(ch->flags & XPC_C_DISCONNECTED)) {
1504 ch->flags |= XPC_C_WDISCONNECT; 1504 ch->flags |= XPC_C_WDISCONNECT;
1505 1505
1506 XPC_DISCONNECT_CHANNEL(ch, xpcUnregistering, 1506 XPC_DISCONNECT_CHANNEL(ch, xpUnregistering,
1507 &irq_flags); 1507 &irq_flags);
1508 } 1508 }
1509 1509
@@ -1528,7 +1528,7 @@ xpc_initiate_disconnect(int ch_number)
1528 */ 1528 */
1529void 1529void
1530xpc_disconnect_channel(const int line, struct xpc_channel *ch, 1530xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1531 enum xpc_retval reason, unsigned long *irq_flags) 1531 enum xp_retval reason, unsigned long *irq_flags)
1532{ 1532{
1533 u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED); 1533 u32 channel_was_connected = (ch->flags & XPC_C_CONNECTED);
1534 1534
@@ -1563,7 +1563,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1563 1563
1564 } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) && 1564 } else if ((ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) &&
1565 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) { 1565 !(ch->flags & XPC_C_DISCONNECTINGCALLOUT)) {
1566 /* start a kthread that will do the xpcDisconnecting callout */ 1566 /* start a kthread that will do the xpDisconnecting callout */
1567 xpc_create_kthreads(ch, 1, 1); 1567 xpc_create_kthreads(ch, 1, 1);
1568 } 1568 }
1569 1569
@@ -1575,7 +1575,7 @@ xpc_disconnect_channel(const int line, struct xpc_channel *ch,
1575} 1575}
1576 1576
1577void 1577void
1578xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason) 1578xpc_disconnect_callout(struct xpc_channel *ch, enum xp_retval reason)
1579{ 1579{
1580 /* 1580 /*
1581 * Let the channel's registerer know that the channel is being 1581 * Let the channel's registerer know that the channel is being
@@ -1598,13 +1598,13 @@ xpc_disconnect_callout(struct xpc_channel *ch, enum xpc_retval reason)
1598 * Wait for a message entry to become available for the specified channel, 1598 * Wait for a message entry to become available for the specified channel,
1599 * but don't wait any longer than 1 jiffy. 1599 * but don't wait any longer than 1 jiffy.
1600 */ 1600 */
1601static enum xpc_retval 1601static enum xp_retval
1602xpc_allocate_msg_wait(struct xpc_channel *ch) 1602xpc_allocate_msg_wait(struct xpc_channel *ch)
1603{ 1603{
1604 enum xpc_retval ret; 1604 enum xp_retval ret;
1605 1605
1606 if (ch->flags & XPC_C_DISCONNECTING) { 1606 if (ch->flags & XPC_C_DISCONNECTING) {
1607 DBUG_ON(ch->reason == xpcInterrupted); 1607 DBUG_ON(ch->reason == xpInterrupted);
1608 return ch->reason; 1608 return ch->reason;
1609 } 1609 }
1610 1610
@@ -1614,11 +1614,11 @@ xpc_allocate_msg_wait(struct xpc_channel *ch)
1614 1614
1615 if (ch->flags & XPC_C_DISCONNECTING) { 1615 if (ch->flags & XPC_C_DISCONNECTING) {
1616 ret = ch->reason; 1616 ret = ch->reason;
1617 DBUG_ON(ch->reason == xpcInterrupted); 1617 DBUG_ON(ch->reason == xpInterrupted);
1618 } else if (ret == 0) { 1618 } else if (ret == 0) {
1619 ret = xpcTimeout; 1619 ret = xpTimeout;
1620 } else { 1620 } else {
1621 ret = xpcInterrupted; 1621 ret = xpInterrupted;
1622 } 1622 }
1623 1623
1624 return ret; 1624 return ret;
@@ -1628,12 +1628,12 @@ xpc_allocate_msg_wait(struct xpc_channel *ch)
1628 * Allocate an entry for a message from the message queue associated with the 1628 * Allocate an entry for a message from the message queue associated with the
1629 * specified channel. 1629 * specified channel.
1630 */ 1630 */
1631static enum xpc_retval 1631static enum xp_retval
1632xpc_allocate_msg(struct xpc_channel *ch, u32 flags, 1632xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1633 struct xpc_msg **address_of_msg) 1633 struct xpc_msg **address_of_msg)
1634{ 1634{
1635 struct xpc_msg *msg; 1635 struct xpc_msg *msg;
1636 enum xpc_retval ret; 1636 enum xp_retval ret;
1637 s64 put; 1637 s64 put;
1638 1638
1639 /* this reference will be dropped in xpc_send_msg() */ 1639 /* this reference will be dropped in xpc_send_msg() */
@@ -1645,7 +1645,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1645 } 1645 }
1646 if (!(ch->flags & XPC_C_CONNECTED)) { 1646 if (!(ch->flags & XPC_C_CONNECTED)) {
1647 xpc_msgqueue_deref(ch); 1647 xpc_msgqueue_deref(ch);
1648 return xpcNotConnected; 1648 return xpNotConnected;
1649 } 1649 }
1650 1650
1651 /* 1651 /*
@@ -1653,7 +1653,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1653 * If none are available, we'll make sure that we grab the latest 1653 * If none are available, we'll make sure that we grab the latest
1654 * GP values. 1654 * GP values.
1655 */ 1655 */
1656 ret = xpcTimeout; 1656 ret = xpTimeout;
1657 1657
1658 while (1) { 1658 while (1) {
1659 1659
@@ -1683,16 +1683,16 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1683 * that will cause the IPI handler to fetch the latest 1683 * that will cause the IPI handler to fetch the latest
1684 * GP values as if an IPI was sent by the other side. 1684 * GP values as if an IPI was sent by the other side.
1685 */ 1685 */
1686 if (ret == xpcTimeout) 1686 if (ret == xpTimeout)
1687 xpc_IPI_send_local_msgrequest(ch); 1687 xpc_IPI_send_local_msgrequest(ch);
1688 1688
1689 if (flags & XPC_NOWAIT) { 1689 if (flags & XPC_NOWAIT) {
1690 xpc_msgqueue_deref(ch); 1690 xpc_msgqueue_deref(ch);
1691 return xpcNoWait; 1691 return xpNoWait;
1692 } 1692 }
1693 1693
1694 ret = xpc_allocate_msg_wait(ch); 1694 ret = xpc_allocate_msg_wait(ch);
1695 if (ret != xpcInterrupted && ret != xpcTimeout) { 1695 if (ret != xpInterrupted && ret != xpTimeout) {
1696 xpc_msgqueue_deref(ch); 1696 xpc_msgqueue_deref(ch);
1697 return ret; 1697 return ret;
1698 } 1698 }
@@ -1711,7 +1711,7 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1711 1711
1712 *address_of_msg = msg; 1712 *address_of_msg = msg;
1713 1713
1714 return xpcSuccess; 1714 return xpSuccess;
1715} 1715}
1716 1716
1717/* 1717/*
@@ -1727,11 +1727,11 @@ xpc_allocate_msg(struct xpc_channel *ch, u32 flags,
1727 * payload - address of the allocated payload area pointer (filled in on 1727 * payload - address of the allocated payload area pointer (filled in on
1728 * return) in which the user-defined message is constructed. 1728 * return) in which the user-defined message is constructed.
1729 */ 1729 */
1730enum xpc_retval 1730enum xp_retval
1731xpc_initiate_allocate(partid_t partid, int ch_number, u32 flags, void **payload) 1731xpc_initiate_allocate(short partid, int ch_number, u32 flags, void **payload)
1732{ 1732{
1733 struct xpc_partition *part = &xpc_partitions[partid]; 1733 struct xpc_partition *part = &xpc_partitions[partid];
1734 enum xpc_retval ret = xpcUnknownReason; 1734 enum xp_retval ret = xpUnknownReason;
1735 struct xpc_msg *msg = NULL; 1735 struct xpc_msg *msg = NULL;
1736 1736
1737 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); 1737 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
@@ -1814,11 +1814,11 @@ xpc_send_msgs(struct xpc_channel *ch, s64 initial_put)
1814 * local message queue's Put value and sends an IPI to the partition the 1814 * local message queue's Put value and sends an IPI to the partition the
1815 * message is being sent to. 1815 * message is being sent to.
1816 */ 1816 */
1817static enum xpc_retval 1817static enum xp_retval
1818xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type, 1818xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1819 xpc_notify_func func, void *key) 1819 xpc_notify_func func, void *key)
1820{ 1820{
1821 enum xpc_retval ret = xpcSuccess; 1821 enum xp_retval ret = xpSuccess;
1822 struct xpc_notify *notify = notify; 1822 struct xpc_notify *notify = notify;
1823 s64 put, msg_number = msg->number; 1823 s64 put, msg_number = msg->number;
1824 1824
@@ -1908,12 +1908,12 @@ xpc_send_msg(struct xpc_channel *ch, struct xpc_msg *msg, u8 notify_type,
1908 * payload - pointer to the payload area allocated via 1908 * payload - pointer to the payload area allocated via
1909 * xpc_initiate_allocate(). 1909 * xpc_initiate_allocate().
1910 */ 1910 */
1911enum xpc_retval 1911enum xp_retval
1912xpc_initiate_send(partid_t partid, int ch_number, void *payload) 1912xpc_initiate_send(short partid, int ch_number, void *payload)
1913{ 1913{
1914 struct xpc_partition *part = &xpc_partitions[partid]; 1914 struct xpc_partition *part = &xpc_partitions[partid];
1915 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1915 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
1916 enum xpc_retval ret; 1916 enum xp_retval ret;
1917 1917
1918 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1918 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg,
1919 partid, ch_number); 1919 partid, ch_number);
@@ -1957,13 +1957,13 @@ xpc_initiate_send(partid_t partid, int ch_number, void *payload)
1957 * receipt. THIS FUNCTION MUST BE NON-BLOCKING. 1957 * receipt. THIS FUNCTION MUST BE NON-BLOCKING.
1958 * key - user-defined key to be passed to the function when it's called. 1958 * key - user-defined key to be passed to the function when it's called.
1959 */ 1959 */
1960enum xpc_retval 1960enum xp_retval
1961xpc_initiate_send_notify(partid_t partid, int ch_number, void *payload, 1961xpc_initiate_send_notify(short partid, int ch_number, void *payload,
1962 xpc_notify_func func, void *key) 1962 xpc_notify_func func, void *key)
1963{ 1963{
1964 struct xpc_partition *part = &xpc_partitions[partid]; 1964 struct xpc_partition *part = &xpc_partitions[partid];
1965 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload); 1965 struct xpc_msg *msg = XPC_MSG_ADDRESS(payload);
1966 enum xpc_retval ret; 1966 enum xp_retval ret;
1967 1967
1968 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg, 1968 dev_dbg(xpc_chan, "msg=0x%p, partid=%d, channel=%d\n", (void *)msg,
1969 partid, ch_number); 1969 partid, ch_number);
@@ -1985,7 +1985,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get)
1985 struct xpc_msg *remote_msg, *msg; 1985 struct xpc_msg *remote_msg, *msg;
1986 u32 msg_index, nmsgs; 1986 u32 msg_index, nmsgs;
1987 u64 msg_offset; 1987 u64 msg_offset;
1988 enum xpc_retval ret; 1988 enum xp_retval ret;
1989 1989
1990 if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) { 1990 if (mutex_lock_interruptible(&ch->msg_to_pull_mutex) != 0) {
1991 /* we were interrupted by a signal */ 1991 /* we were interrupted by a signal */
@@ -2012,7 +2012,7 @@ xpc_pull_remote_msg(struct xpc_channel *ch, s64 get)
2012 2012
2013 ret = xpc_pull_remote_cachelines(part, msg, remote_msg, 2013 ret = xpc_pull_remote_cachelines(part, msg, remote_msg,
2014 nmsgs * ch->msg_size); 2014 nmsgs * ch->msg_size);
2015 if (ret != xpcSuccess) { 2015 if (ret != xpSuccess) {
2016 2016
2017 dev_dbg(xpc_chan, "failed to pull %d msgs starting with" 2017 dev_dbg(xpc_chan, "failed to pull %d msgs starting with"
2018 " msg %ld from partition %d, channel=%d, " 2018 " msg %ld from partition %d, channel=%d, "
@@ -2112,7 +2112,7 @@ xpc_deliver_msg(struct xpc_channel *ch)
2112 ch->number); 2112 ch->number);
2113 2113
2114 /* deliver the message to its intended recipient */ 2114 /* deliver the message to its intended recipient */
2115 ch->func(xpcMsgReceived, ch->partid, ch->number, 2115 ch->func(xpMsgReceived, ch->partid, ch->number,
2116 &msg->payload, ch->key); 2116 &msg->payload, ch->key);
2117 2117
2118 dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, " 2118 dev_dbg(xpc_chan, "ch->func() returned, msg=0x%p, "
@@ -2203,7 +2203,7 @@ xpc_acknowledge_msgs(struct xpc_channel *ch, s64 initial_get, u8 msg_flags)
2203 * xpc_initiate_allocate(). 2203 * xpc_initiate_allocate().
2204 */ 2204 */
2205void 2205void
2206xpc_initiate_received(partid_t partid, int ch_number, void *payload) 2206xpc_initiate_received(short partid, int ch_number, void *payload)
2207{ 2207{
2208 struct xpc_partition *part = &xpc_partitions[partid]; 2208 struct xpc_partition *part = &xpc_partitions[partid];
2209 struct xpc_channel *ch; 2209 struct xpc_channel *ch;
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
index f673ba90eb0e..08256ed0d9a6 100644
--- a/drivers/misc/sgi-xp/xpc_main.c
+++ b/drivers/misc/sgi-xp/xpc_main.c
@@ -315,13 +315,13 @@ xpc_initiate_discovery(void *ignore)
315 * the XPC per partition variables from the remote partition and waiting for 315 * the XPC per partition variables from the remote partition and waiting for
316 * the remote partition to pull ours. 316 * the remote partition to pull ours.
317 */ 317 */
318static enum xpc_retval 318static enum xp_retval
319xpc_make_first_contact(struct xpc_partition *part) 319xpc_make_first_contact(struct xpc_partition *part)
320{ 320{
321 enum xpc_retval ret; 321 enum xp_retval ret;
322 322
323 while ((ret = xpc_pull_remote_vars_part(part)) != xpcSuccess) { 323 while ((ret = xpc_pull_remote_vars_part(part)) != xpSuccess) {
324 if (ret != xpcRetry) { 324 if (ret != xpRetry) {
325 XPC_DEACTIVATE_PARTITION(part, ret); 325 XPC_DEACTIVATE_PARTITION(part, ret);
326 return ret; 326 return ret;
327 } 327 }
@@ -406,7 +406,7 @@ xpc_partition_up(struct xpc_partition *part)
406 406
407 dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part)); 407 dev_dbg(xpc_chan, "activating partition %d\n", XPC_PARTID(part));
408 408
409 if (xpc_setup_infrastructure(part) != xpcSuccess) 409 if (xpc_setup_infrastructure(part) != xpSuccess)
410 return; 410 return;
411 411
412 /* 412 /*
@@ -418,7 +418,7 @@ xpc_partition_up(struct xpc_partition *part)
418 418
419 (void)xpc_part_ref(part); /* this will always succeed */ 419 (void)xpc_part_ref(part); /* this will always succeed */
420 420
421 if (xpc_make_first_contact(part) == xpcSuccess) 421 if (xpc_make_first_contact(part) == xpSuccess)
422 xpc_channel_mgr(part); 422 xpc_channel_mgr(part);
423 423
424 xpc_part_deref(part); 424 xpc_part_deref(part);
@@ -429,7 +429,7 @@ xpc_partition_up(struct xpc_partition *part)
429static int 429static int
430xpc_activating(void *__partid) 430xpc_activating(void *__partid)
431{ 431{
432 partid_t partid = (u64)__partid; 432 short partid = (u64)__partid;
433 struct xpc_partition *part = &xpc_partitions[partid]; 433 struct xpc_partition *part = &xpc_partitions[partid];
434 unsigned long irq_flags; 434 unsigned long irq_flags;
435 435
@@ -470,7 +470,7 @@ xpc_activating(void *__partid)
470 470
471 spin_lock_irqsave(&part->act_lock, irq_flags); 471 spin_lock_irqsave(&part->act_lock, irq_flags);
472 part->act_state = XPC_P_INACTIVE; 472 part->act_state = XPC_P_INACTIVE;
473 XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__); 473 XPC_SET_REASON(part, xpPhysAddrRegFailed, __LINE__);
474 spin_unlock_irqrestore(&part->act_lock, irq_flags); 474 spin_unlock_irqrestore(&part->act_lock, irq_flags);
475 part->remote_rp_pa = 0; 475 part->remote_rp_pa = 0;
476 return 0; 476 return 0;
@@ -488,7 +488,7 @@ xpc_activating(void *__partid)
488 xpc_disallow_hb(partid, xpc_vars); 488 xpc_disallow_hb(partid, xpc_vars);
489 xpc_mark_partition_inactive(part); 489 xpc_mark_partition_inactive(part);
490 490
491 if (part->reason == xpcReactivating) { 491 if (part->reason == xpReactivating) {
492 /* interrupting ourselves results in activating partition */ 492 /* interrupting ourselves results in activating partition */
493 xpc_IPI_send_reactivate(part); 493 xpc_IPI_send_reactivate(part);
494 } 494 }
@@ -499,7 +499,7 @@ xpc_activating(void *__partid)
499void 499void
500xpc_activate_partition(struct xpc_partition *part) 500xpc_activate_partition(struct xpc_partition *part)
501{ 501{
502 partid_t partid = XPC_PARTID(part); 502 short partid = XPC_PARTID(part);
503 unsigned long irq_flags; 503 unsigned long irq_flags;
504 struct task_struct *kthread; 504 struct task_struct *kthread;
505 505
@@ -508,7 +508,7 @@ xpc_activate_partition(struct xpc_partition *part)
508 DBUG_ON(part->act_state != XPC_P_INACTIVE); 508 DBUG_ON(part->act_state != XPC_P_INACTIVE);
509 509
510 part->act_state = XPC_P_ACTIVATION_REQ; 510 part->act_state = XPC_P_ACTIVATION_REQ;
511 XPC_SET_REASON(part, xpcCloneKThread, __LINE__); 511 XPC_SET_REASON(part, xpCloneKThread, __LINE__);
512 512
513 spin_unlock_irqrestore(&part->act_lock, irq_flags); 513 spin_unlock_irqrestore(&part->act_lock, irq_flags);
514 514
@@ -517,7 +517,7 @@ xpc_activate_partition(struct xpc_partition *part)
517 if (IS_ERR(kthread)) { 517 if (IS_ERR(kthread)) {
518 spin_lock_irqsave(&part->act_lock, irq_flags); 518 spin_lock_irqsave(&part->act_lock, irq_flags);
519 part->act_state = XPC_P_INACTIVE; 519 part->act_state = XPC_P_INACTIVE;
520 XPC_SET_REASON(part, xpcCloneKThreadFailed, __LINE__); 520 XPC_SET_REASON(part, xpCloneKThreadFailed, __LINE__);
521 spin_unlock_irqrestore(&part->act_lock, irq_flags); 521 spin_unlock_irqrestore(&part->act_lock, irq_flags);
522 } 522 }
523} 523}
@@ -541,7 +541,7 @@ xpc_activate_partition(struct xpc_partition *part)
541irqreturn_t 541irqreturn_t
542xpc_notify_IRQ_handler(int irq, void *dev_id) 542xpc_notify_IRQ_handler(int irq, void *dev_id)
543{ 543{
544 partid_t partid = (partid_t) (u64)dev_id; 544 short partid = (short)(u64)dev_id;
545 struct xpc_partition *part = &xpc_partitions[partid]; 545 struct xpc_partition *part = &xpc_partitions[partid];
546 546
547 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS); 547 DBUG_ON(partid <= 0 || partid >= XP_MAX_PARTITIONS);
@@ -643,7 +643,7 @@ xpc_kthread_waitmsgs(struct xpc_partition *part, struct xpc_channel *ch)
643static int 643static int
644xpc_kthread_start(void *args) 644xpc_kthread_start(void *args)
645{ 645{
646 partid_t partid = XPC_UNPACK_ARG1(args); 646 short partid = XPC_UNPACK_ARG1(args);
647 u16 ch_number = XPC_UNPACK_ARG2(args); 647 u16 ch_number = XPC_UNPACK_ARG2(args);
648 struct xpc_partition *part = &xpc_partitions[partid]; 648 struct xpc_partition *part = &xpc_partitions[partid];
649 struct xpc_channel *ch; 649 struct xpc_channel *ch;
@@ -696,7 +696,7 @@ xpc_kthread_start(void *args)
696 ch->flags |= XPC_C_DISCONNECTINGCALLOUT; 696 ch->flags |= XPC_C_DISCONNECTINGCALLOUT;
697 spin_unlock_irqrestore(&ch->lock, irq_flags); 697 spin_unlock_irqrestore(&ch->lock, irq_flags);
698 698
699 xpc_disconnect_callout(ch, xpcDisconnecting); 699 xpc_disconnect_callout(ch, xpDisconnecting);
700 700
701 spin_lock_irqsave(&ch->lock, irq_flags); 701 spin_lock_irqsave(&ch->lock, irq_flags);
702 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE; 702 ch->flags |= XPC_C_DISCONNECTINGCALLOUT_MADE;
@@ -776,7 +776,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
776 * then we'll deadlock if all other kthreads assigned 776 * then we'll deadlock if all other kthreads assigned
777 * to this channel are blocked in the channel's 777 * to this channel are blocked in the channel's
778 * registerer, because the only thing that will unblock 778 * registerer, because the only thing that will unblock
779 * them is the xpcDisconnecting callout that this 779 * them is the xpDisconnecting callout that this
780 * failed kthread_run() would have made. 780 * failed kthread_run() would have made.
781 */ 781 */
782 782
@@ -796,7 +796,7 @@ xpc_create_kthreads(struct xpc_channel *ch, int needed,
796 * to function. 796 * to function.
797 */ 797 */
798 spin_lock_irqsave(&ch->lock, irq_flags); 798 spin_lock_irqsave(&ch->lock, irq_flags);
799 XPC_DISCONNECT_CHANNEL(ch, xpcLackOfResources, 799 XPC_DISCONNECT_CHANNEL(ch, xpLackOfResources,
800 &irq_flags); 800 &irq_flags);
801 spin_unlock_irqrestore(&ch->lock, irq_flags); 801 spin_unlock_irqrestore(&ch->lock, irq_flags);
802 } 802 }
@@ -809,7 +809,7 @@ void
809xpc_disconnect_wait(int ch_number) 809xpc_disconnect_wait(int ch_number)
810{ 810{
811 unsigned long irq_flags; 811 unsigned long irq_flags;
812 partid_t partid; 812 short partid;
813 struct xpc_partition *part; 813 struct xpc_partition *part;
814 struct xpc_channel *ch; 814 struct xpc_channel *ch;
815 int wakeup_channel_mgr; 815 int wakeup_channel_mgr;
@@ -857,9 +857,9 @@ xpc_disconnect_wait(int ch_number)
857} 857}
858 858
859static void 859static void
860xpc_do_exit(enum xpc_retval reason) 860xpc_do_exit(enum xp_retval reason)
861{ 861{
862 partid_t partid; 862 short partid;
863 int active_part_count, printed_waiting_msg = 0; 863 int active_part_count, printed_waiting_msg = 0;
864 struct xpc_partition *part; 864 struct xpc_partition *part;
865 unsigned long printmsg_time, disengage_request_timeout = 0; 865 unsigned long printmsg_time, disengage_request_timeout = 0;
@@ -955,7 +955,7 @@ xpc_do_exit(enum xpc_retval reason)
955 del_timer_sync(&xpc_hb_timer); 955 del_timer_sync(&xpc_hb_timer);
956 DBUG_ON(xpc_vars->heartbeating_to_mask != 0); 956 DBUG_ON(xpc_vars->heartbeating_to_mask != 0);
957 957
958 if (reason == xpcUnloading) { 958 if (reason == xpUnloading) {
959 /* take ourselves off of the reboot_notifier_list */ 959 /* take ourselves off of the reboot_notifier_list */
960 (void)unregister_reboot_notifier(&xpc_reboot_notifier); 960 (void)unregister_reboot_notifier(&xpc_reboot_notifier);
961 961
@@ -981,20 +981,20 @@ xpc_do_exit(enum xpc_retval reason)
981static int 981static int
982xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused) 982xpc_system_reboot(struct notifier_block *nb, unsigned long event, void *unused)
983{ 983{
984 enum xpc_retval reason; 984 enum xp_retval reason;
985 985
986 switch (event) { 986 switch (event) {
987 case SYS_RESTART: 987 case SYS_RESTART:
988 reason = xpcSystemReboot; 988 reason = xpSystemReboot;
989 break; 989 break;
990 case SYS_HALT: 990 case SYS_HALT:
991 reason = xpcSystemHalt; 991 reason = xpSystemHalt;
992 break; 992 break;
993 case SYS_POWER_OFF: 993 case SYS_POWER_OFF:
994 reason = xpcSystemPoweroff; 994 reason = xpSystemPoweroff;
995 break; 995 break;
996 default: 996 default:
997 reason = xpcSystemGoingDown; 997 reason = xpSystemGoingDown;
998 } 998 }
999 999
1000 xpc_do_exit(reason); 1000 xpc_do_exit(reason);
@@ -1008,7 +1008,7 @@ static void
1008xpc_die_disengage(void) 1008xpc_die_disengage(void)
1009{ 1009{
1010 struct xpc_partition *part; 1010 struct xpc_partition *part;
1011 partid_t partid; 1011 short partid;
1012 unsigned long engaged; 1012 unsigned long engaged;
1013 long time, printmsg_time, disengage_request_timeout; 1013 long time, printmsg_time, disengage_request_timeout;
1014 1014
@@ -1124,7 +1124,7 @@ int __init
1124xpc_init(void) 1124xpc_init(void)
1125{ 1125{
1126 int ret; 1126 int ret;
1127 partid_t partid; 1127 short partid;
1128 struct xpc_partition *part; 1128 struct xpc_partition *part;
1129 struct task_struct *kthread; 1129 struct task_struct *kthread;
1130 size_t buf_size; 1130 size_t buf_size;
@@ -1279,7 +1279,7 @@ xpc_init(void)
1279 /* mark this new thread as a non-starter */ 1279 /* mark this new thread as a non-starter */
1280 complete(&xpc_discovery_exited); 1280 complete(&xpc_discovery_exited);
1281 1281
1282 xpc_do_exit(xpcUnloading); 1282 xpc_do_exit(xpUnloading);
1283 return -EBUSY; 1283 return -EBUSY;
1284 } 1284 }
1285 1285
@@ -1297,7 +1297,7 @@ module_init(xpc_init);
1297void __exit 1297void __exit
1298xpc_exit(void) 1298xpc_exit(void)
1299{ 1299{
1300 xpc_do_exit(xpcUnloading); 1300 xpc_do_exit(xpUnloading);
1301} 1301}
1302 1302
1303module_exit(xpc_exit); 1303module_exit(xpc_exit);
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
index acd3fd4285d7..7dd4b5812c42 100644
--- a/drivers/misc/sgi-xp/xpc_partition.c
+++ b/drivers/misc/sgi-xp/xpc_partition.c
@@ -403,7 +403,7 @@ xpc_check_remote_hb(void)
403{ 403{
404 struct xpc_vars *remote_vars; 404 struct xpc_vars *remote_vars;
405 struct xpc_partition *part; 405 struct xpc_partition *part;
406 partid_t partid; 406 short partid;
407 bte_result_t bres; 407 bte_result_t bres;
408 408
409 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; 409 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
@@ -444,7 +444,7 @@ xpc_check_remote_hb(void)
444 (remote_vars->heartbeat_offline == 0)) || 444 (remote_vars->heartbeat_offline == 0)) ||
445 !xpc_hb_allowed(sn_partition_id, remote_vars)) { 445 !xpc_hb_allowed(sn_partition_id, remote_vars)) {
446 446
447 XPC_DEACTIVATE_PARTITION(part, xpcNoHeartbeat); 447 XPC_DEACTIVATE_PARTITION(part, xpNoHeartbeat);
448 continue; 448 continue;
449 } 449 }
450 450
@@ -459,7 +459,7 @@ xpc_check_remote_hb(void)
459 * is large enough to contain a copy of their reserved page header and 459 * is large enough to contain a copy of their reserved page header and
460 * part_nasids mask. 460 * part_nasids mask.
461 */ 461 */
462static enum xpc_retval 462static enum xp_retval
463xpc_get_remote_rp(int nasid, u64 *discovered_nasids, 463xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
464 struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa) 464 struct xpc_rsvd_page *remote_rp, u64 *remote_rp_pa)
465{ 465{
@@ -469,7 +469,7 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
469 469
470 *remote_rp_pa = xpc_get_rsvd_page_pa(nasid); 470 *remote_rp_pa = xpc_get_rsvd_page_pa(nasid);
471 if (*remote_rp_pa == 0) 471 if (*remote_rp_pa == 0)
472 return xpcNoRsvdPageAddr; 472 return xpNoRsvdPageAddr;
473 473
474 /* pull over the reserved page header and part_nasids mask */ 474 /* pull over the reserved page header and part_nasids mask */
475 bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp, 475 bres = xp_bte_copy(*remote_rp_pa, (u64)remote_rp,
@@ -489,18 +489,18 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
489 489
490 if (remote_rp->partid < 1 || 490 if (remote_rp->partid < 1 ||
491 remote_rp->partid > (XP_MAX_PARTITIONS - 1)) { 491 remote_rp->partid > (XP_MAX_PARTITIONS - 1)) {
492 return xpcInvalidPartid; 492 return xpInvalidPartid;
493 } 493 }
494 494
495 if (remote_rp->partid == sn_partition_id) 495 if (remote_rp->partid == sn_partition_id)
496 return xpcLocalPartid; 496 return xpLocalPartid;
497 497
498 if (XPC_VERSION_MAJOR(remote_rp->version) != 498 if (XPC_VERSION_MAJOR(remote_rp->version) !=
499 XPC_VERSION_MAJOR(XPC_RP_VERSION)) { 499 XPC_VERSION_MAJOR(XPC_RP_VERSION)) {
500 return xpcBadVersion; 500 return xpBadVersion;
501 } 501 }
502 502
503 return xpcSuccess; 503 return xpSuccess;
504} 504}
505 505
506/* 506/*
@@ -509,13 +509,13 @@ xpc_get_remote_rp(int nasid, u64 *discovered_nasids,
509 * remote_vars points to a buffer that is cacheline aligned for BTE copies and 509 * remote_vars points to a buffer that is cacheline aligned for BTE copies and
510 * assumed to be of size XPC_RP_VARS_SIZE. 510 * assumed to be of size XPC_RP_VARS_SIZE.
511 */ 511 */
512static enum xpc_retval 512static enum xp_retval
513xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars) 513xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
514{ 514{
515 int bres; 515 int bres;
516 516
517 if (remote_vars_pa == 0) 517 if (remote_vars_pa == 0)
518 return xpcVarsNotSet; 518 return xpVarsNotSet;
519 519
520 /* pull over the cross partition variables */ 520 /* pull over the cross partition variables */
521 bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE, 521 bres = xp_bte_copy(remote_vars_pa, (u64)remote_vars, XPC_RP_VARS_SIZE,
@@ -525,10 +525,10 @@ xpc_get_remote_vars(u64 remote_vars_pa, struct xpc_vars *remote_vars)
525 525
526 if (XPC_VERSION_MAJOR(remote_vars->version) != 526 if (XPC_VERSION_MAJOR(remote_vars->version) !=
527 XPC_VERSION_MAJOR(XPC_V_VERSION)) { 527 XPC_VERSION_MAJOR(XPC_V_VERSION)) {
528 return xpcBadVersion; 528 return xpBadVersion;
529 } 529 }
530 530
531 return xpcSuccess; 531 return xpSuccess;
532} 532}
533 533
534/* 534/*
@@ -604,16 +604,16 @@ xpc_identify_act_IRQ_req(int nasid)
604 int reactivate = 0; 604 int reactivate = 0;
605 int stamp_diff; 605 int stamp_diff;
606 struct timespec remote_rp_stamp = { 0, 0 }; 606 struct timespec remote_rp_stamp = { 0, 0 };
607 partid_t partid; 607 short partid;
608 struct xpc_partition *part; 608 struct xpc_partition *part;
609 enum xpc_retval ret; 609 enum xp_retval ret;
610 610
611 /* pull over the reserved page structure */ 611 /* pull over the reserved page structure */
612 612
613 remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer; 613 remote_rp = (struct xpc_rsvd_page *)xpc_remote_copy_buffer;
614 614
615 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa); 615 ret = xpc_get_remote_rp(nasid, NULL, remote_rp, &remote_rp_pa);
616 if (ret != xpcSuccess) { 616 if (ret != xpSuccess) {
617 dev_warn(xpc_part, "unable to get reserved page from nasid %d, " 617 dev_warn(xpc_part, "unable to get reserved page from nasid %d, "
618 "which sent interrupt, reason=%d\n", nasid, ret); 618 "which sent interrupt, reason=%d\n", nasid, ret);
619 return; 619 return;
@@ -632,7 +632,7 @@ xpc_identify_act_IRQ_req(int nasid)
632 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer; 632 remote_vars = (struct xpc_vars *)xpc_remote_copy_buffer;
633 633
634 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); 634 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
635 if (ret != xpcSuccess) { 635 if (ret != xpSuccess) {
636 636
637 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, " 637 dev_warn(xpc_part, "unable to get XPC variables from nasid %d, "
638 "which sent interrupt, reason=%d\n", nasid, ret); 638 "which sent interrupt, reason=%d\n", nasid, ret);
@@ -699,7 +699,7 @@ xpc_identify_act_IRQ_req(int nasid)
699 &remote_rp_stamp, remote_rp_pa, 699 &remote_rp_stamp, remote_rp_pa,
700 remote_vars_pa, remote_vars); 700 remote_vars_pa, remote_vars);
701 part->reactivate_nasid = nasid; 701 part->reactivate_nasid = nasid;
702 XPC_DEACTIVATE_PARTITION(part, xpcReactivating); 702 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
703 return; 703 return;
704 } 704 }
705 705
@@ -754,11 +754,11 @@ xpc_identify_act_IRQ_req(int nasid)
754 754
755 if (reactivate) { 755 if (reactivate) {
756 part->reactivate_nasid = nasid; 756 part->reactivate_nasid = nasid;
757 XPC_DEACTIVATE_PARTITION(part, xpcReactivating); 757 XPC_DEACTIVATE_PARTITION(part, xpReactivating);
758 758
759 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) && 759 } else if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version) &&
760 xpc_partition_disengage_requested(1UL << partid)) { 760 xpc_partition_disengage_requested(1UL << partid)) {
761 XPC_DEACTIVATE_PARTITION(part, xpcOtherGoingDown); 761 XPC_DEACTIVATE_PARTITION(part, xpOtherGoingDown);
762 } 762 }
763} 763}
764 764
@@ -825,7 +825,7 @@ xpc_identify_act_IRQ_sender(void)
825int 825int
826xpc_partition_disengaged(struct xpc_partition *part) 826xpc_partition_disengaged(struct xpc_partition *part)
827{ 827{
828 partid_t partid = XPC_PARTID(part); 828 short partid = XPC_PARTID(part);
829 int disengaged; 829 int disengaged;
830 830
831 disengaged = (xpc_partition_engaged(1UL << partid) == 0); 831 disengaged = (xpc_partition_engaged(1UL << partid) == 0);
@@ -870,20 +870,20 @@ xpc_partition_disengaged(struct xpc_partition *part)
870/* 870/*
871 * Mark specified partition as active. 871 * Mark specified partition as active.
872 */ 872 */
873enum xpc_retval 873enum xp_retval
874xpc_mark_partition_active(struct xpc_partition *part) 874xpc_mark_partition_active(struct xpc_partition *part)
875{ 875{
876 unsigned long irq_flags; 876 unsigned long irq_flags;
877 enum xpc_retval ret; 877 enum xp_retval ret;
878 878
879 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); 879 dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part));
880 880
881 spin_lock_irqsave(&part->act_lock, irq_flags); 881 spin_lock_irqsave(&part->act_lock, irq_flags);
882 if (part->act_state == XPC_P_ACTIVATING) { 882 if (part->act_state == XPC_P_ACTIVATING) {
883 part->act_state = XPC_P_ACTIVE; 883 part->act_state = XPC_P_ACTIVE;
884 ret = xpcSuccess; 884 ret = xpSuccess;
885 } else { 885 } else {
886 DBUG_ON(part->reason == xpcSuccess); 886 DBUG_ON(part->reason == xpSuccess);
887 ret = part->reason; 887 ret = part->reason;
888 } 888 }
889 spin_unlock_irqrestore(&part->act_lock, irq_flags); 889 spin_unlock_irqrestore(&part->act_lock, irq_flags);
@@ -896,7 +896,7 @@ xpc_mark_partition_active(struct xpc_partition *part)
896 */ 896 */
897void 897void
898xpc_deactivate_partition(const int line, struct xpc_partition *part, 898xpc_deactivate_partition(const int line, struct xpc_partition *part,
899 enum xpc_retval reason) 899 enum xp_retval reason)
900{ 900{
901 unsigned long irq_flags; 901 unsigned long irq_flags;
902 902
@@ -905,15 +905,15 @@ xpc_deactivate_partition(const int line, struct xpc_partition *part,
905 if (part->act_state == XPC_P_INACTIVE) { 905 if (part->act_state == XPC_P_INACTIVE) {
906 XPC_SET_REASON(part, reason, line); 906 XPC_SET_REASON(part, reason, line);
907 spin_unlock_irqrestore(&part->act_lock, irq_flags); 907 spin_unlock_irqrestore(&part->act_lock, irq_flags);
908 if (reason == xpcReactivating) { 908 if (reason == xpReactivating) {
909 /* we interrupt ourselves to reactivate partition */ 909 /* we interrupt ourselves to reactivate partition */
910 xpc_IPI_send_reactivate(part); 910 xpc_IPI_send_reactivate(part);
911 } 911 }
912 return; 912 return;
913 } 913 }
914 if (part->act_state == XPC_P_DEACTIVATING) { 914 if (part->act_state == XPC_P_DEACTIVATING) {
915 if ((part->reason == xpcUnloading && reason != xpcUnloading) || 915 if ((part->reason == xpUnloading && reason != xpUnloading) ||
916 reason == xpcReactivating) { 916 reason == xpReactivating) {
917 XPC_SET_REASON(part, reason, line); 917 XPC_SET_REASON(part, reason, line);
918 } 918 }
919 spin_unlock_irqrestore(&part->act_lock, irq_flags); 919 spin_unlock_irqrestore(&part->act_lock, irq_flags);
@@ -982,10 +982,10 @@ xpc_discovery(void)
982 int max_regions; 982 int max_regions;
983 int nasid; 983 int nasid;
984 struct xpc_rsvd_page *rp; 984 struct xpc_rsvd_page *rp;
985 partid_t partid; 985 short partid;
986 struct xpc_partition *part; 986 struct xpc_partition *part;
987 u64 *discovered_nasids; 987 u64 *discovered_nasids;
988 enum xpc_retval ret; 988 enum xp_retval ret;
989 989
990 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + 990 remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE +
991 xp_nasid_mask_bytes, 991 xp_nasid_mask_bytes,
@@ -1063,12 +1063,12 @@ xpc_discovery(void)
1063 1063
1064 ret = xpc_get_remote_rp(nasid, discovered_nasids, 1064 ret = xpc_get_remote_rp(nasid, discovered_nasids,
1065 remote_rp, &remote_rp_pa); 1065 remote_rp, &remote_rp_pa);
1066 if (ret != xpcSuccess) { 1066 if (ret != xpSuccess) {
1067 dev_dbg(xpc_part, "unable to get reserved page " 1067 dev_dbg(xpc_part, "unable to get reserved page "
1068 "from nasid %d, reason=%d\n", nasid, 1068 "from nasid %d, reason=%d\n", nasid,
1069 ret); 1069 ret);
1070 1070
1071 if (ret == xpcLocalPartid) 1071 if (ret == xpLocalPartid)
1072 break; 1072 break;
1073 1073
1074 continue; 1074 continue;
@@ -1082,7 +1082,7 @@ xpc_discovery(void)
1082 /* pull over the cross partition variables */ 1082 /* pull over the cross partition variables */
1083 1083
1084 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); 1084 ret = xpc_get_remote_vars(remote_vars_pa, remote_vars);
1085 if (ret != xpcSuccess) { 1085 if (ret != xpSuccess) {
1086 dev_dbg(xpc_part, "unable to get XPC variables " 1086 dev_dbg(xpc_part, "unable to get XPC variables "
1087 "from nasid %d, reason=%d\n", nasid, 1087 "from nasid %d, reason=%d\n", nasid,
1088 ret); 1088 ret);
@@ -1116,7 +1116,7 @@ xpc_discovery(void)
1116 "register xp_addr region 0x%016lx\n", 1116 "register xp_addr region 0x%016lx\n",
1117 partid, remote_vars->amos_page_pa); 1117 partid, remote_vars->amos_page_pa);
1118 1118
1119 XPC_SET_REASON(part, xpcPhysAddrRegFailed, 1119 XPC_SET_REASON(part, xpPhysAddrRegFailed,
1120 __LINE__); 1120 __LINE__);
1121 break; 1121 break;
1122 } 1122 }
@@ -1151,8 +1151,8 @@ xpc_discovery(void)
1151 * Given a partid, get the nasids owned by that partition from the 1151 * Given a partid, get the nasids owned by that partition from the
1152 * remote partition's reserved page. 1152 * remote partition's reserved page.
1153 */ 1153 */
1154enum xpc_retval 1154enum xp_retval
1155xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask) 1155xpc_initiate_partid_to_nasids(short partid, void *nasid_mask)
1156{ 1156{
1157 struct xpc_partition *part; 1157 struct xpc_partition *part;
1158 u64 part_nasid_pa; 1158 u64 part_nasid_pa;
@@ -1160,7 +1160,7 @@ xpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask)
1160 1160
1161 part = &xpc_partitions[partid]; 1161 part = &xpc_partitions[partid];
1162 if (part->remote_rp_pa == 0) 1162 if (part->remote_rp_pa == 0)
1163 return xpcPartitionDown; 1163 return xpPartitionDown;
1164 1164
1165 memset(nasid_mask, 0, XP_NASID_MASK_BYTES); 1165 memset(nasid_mask, 0, XP_NASID_MASK_BYTES);
1166 1166
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c
index a9543c65814d..822dc8e8d7f0 100644
--- a/drivers/misc/sgi-xp/xpnet.c
+++ b/drivers/misc/sgi-xp/xpnet.c
@@ -166,7 +166,7 @@ struct device *xpnet = &xpnet_dbg_subname;
166 * Packet was recevied by XPC and forwarded to us. 166 * Packet was recevied by XPC and forwarded to us.
167 */ 167 */
168static void 168static void
169xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg) 169xpnet_receive(short partid, int channel, struct xpnet_message *msg)
170{ 170{
171 struct sk_buff *skb; 171 struct sk_buff *skb;
172 bte_result_t bret; 172 bte_result_t bret;
@@ -282,7 +282,7 @@ xpnet_receive(partid_t partid, int channel, struct xpnet_message *msg)
282 * state or message reception on a connection. 282 * state or message reception on a connection.
283 */ 283 */
284static void 284static void
285xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel, 285xpnet_connection_activity(enum xp_retval reason, short partid, int channel,
286 void *data, void *key) 286 void *data, void *key)
287{ 287{
288 long bp; 288 long bp;
@@ -291,13 +291,13 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
291 DBUG_ON(channel != XPC_NET_CHANNEL); 291 DBUG_ON(channel != XPC_NET_CHANNEL);
292 292
293 switch (reason) { 293 switch (reason) {
294 case xpcMsgReceived: /* message received */ 294 case xpMsgReceived: /* message received */
295 DBUG_ON(data == NULL); 295 DBUG_ON(data == NULL);
296 296
297 xpnet_receive(partid, channel, (struct xpnet_message *)data); 297 xpnet_receive(partid, channel, (struct xpnet_message *)data);
298 break; 298 break;
299 299
300 case xpcConnected: /* connection completed to a partition */ 300 case xpConnected: /* connection completed to a partition */
301 spin_lock_bh(&xpnet_broadcast_lock); 301 spin_lock_bh(&xpnet_broadcast_lock);
302 xpnet_broadcast_partitions |= 1UL << (partid - 1); 302 xpnet_broadcast_partitions |= 1UL << (partid - 1);
303 bp = xpnet_broadcast_partitions; 303 bp = xpnet_broadcast_partitions;
@@ -330,7 +330,7 @@ xpnet_connection_activity(enum xpc_retval reason, partid_t partid, int channel,
330static int 330static int
331xpnet_dev_open(struct net_device *dev) 331xpnet_dev_open(struct net_device *dev)
332{ 332{
333 enum xpc_retval ret; 333 enum xp_retval ret;
334 334
335 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, " 335 dev_dbg(xpnet, "calling xpc_connect(%d, 0x%p, NULL, %ld, %ld, %ld, "
336 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity, 336 "%ld)\n", XPC_NET_CHANNEL, xpnet_connection_activity,
@@ -340,7 +340,7 @@ xpnet_dev_open(struct net_device *dev)
340 ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL, 340 ret = xpc_connect(XPC_NET_CHANNEL, xpnet_connection_activity, NULL,
341 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES, 341 XPNET_MSG_SIZE, XPNET_MSG_NENTRIES,
342 XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS); 342 XPNET_MAX_KTHREADS, XPNET_MAX_IDLE_KTHREADS);
343 if (ret != xpcSuccess) { 343 if (ret != xpSuccess) {
344 dev_err(xpnet, "ifconfig up of %s failed on XPC connect, " 344 dev_err(xpnet, "ifconfig up of %s failed on XPC connect, "
345 "ret=%d\n", dev->name, ret); 345 "ret=%d\n", dev->name, ret);
346 346
@@ -407,7 +407,7 @@ xpnet_dev_get_stats(struct net_device *dev)
407 * release the skb and then release our pending message structure. 407 * release the skb and then release our pending message structure.
408 */ 408 */
409static void 409static void
410xpnet_send_completed(enum xpc_retval reason, partid_t partid, int channel, 410xpnet_send_completed(enum xp_retval reason, short partid, int channel,
411 void *__qm) 411 void *__qm)
412{ 412{
413 struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm; 413 struct xpnet_pending_msg *queued_msg = (struct xpnet_pending_msg *)__qm;
@@ -439,12 +439,12 @@ static int
439xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) 439xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
440{ 440{
441 struct xpnet_pending_msg *queued_msg; 441 struct xpnet_pending_msg *queued_msg;
442 enum xpc_retval ret; 442 enum xp_retval ret;
443 struct xpnet_message *msg; 443 struct xpnet_message *msg;
444 u64 start_addr, end_addr; 444 u64 start_addr, end_addr;
445 long dp; 445 long dp;
446 u8 second_mac_octet; 446 u8 second_mac_octet;
447 partid_t dest_partid; 447 short dest_partid;
448 struct xpnet_dev_private *priv; 448 struct xpnet_dev_private *priv;
449 u16 embedded_bytes; 449 u16 embedded_bytes;
450 450
@@ -528,7 +528,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
528 528
529 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL, 529 ret = xpc_allocate(dest_partid, XPC_NET_CHANNEL,
530 XPC_NOWAIT, (void **)&msg); 530 XPC_NOWAIT, (void **)&msg);
531 if (unlikely(ret != xpcSuccess)) 531 if (unlikely(ret != xpSuccess))
532 continue; 532 continue;
533 533
534 msg->embedded_bytes = embedded_bytes; 534 msg->embedded_bytes = embedded_bytes;
@@ -557,7 +557,7 @@ xpnet_dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
557 557
558 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg, 558 ret = xpc_send_notify(dest_partid, XPC_NET_CHANNEL, msg,
559 xpnet_send_completed, queued_msg); 559 xpnet_send_completed, queued_msg);
560 if (unlikely(ret != xpcSuccess)) { 560 if (unlikely(ret != xpSuccess)) {
561 atomic_dec(&queued_msg->use_count); 561 atomic_dec(&queued_msg->use_count);
562 continue; 562 continue;
563 } 563 }
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 626ac083f4e0..da5fecad74d9 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -425,7 +425,7 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
425 host->cclk = host->mclk; 425 host->cclk = host->mclk;
426 } else { 426 } else {
427 clk = host->mclk / (2 * ios->clock) - 1; 427 clk = host->mclk / (2 * ios->clock) - 1;
428 if (clk > 256) 428 if (clk >= 256)
429 clk = 255; 429 clk = 255;
430 host->cclk = host->mclk / (2 * (clk + 1)); 430 host->cclk = host->mclk / (2 * (clk + 1));
431 } 431 }
@@ -512,6 +512,18 @@ static int mmci_probe(struct amba_device *dev, void *id)
512 512
513 host->plat = plat; 513 host->plat = plat;
514 host->mclk = clk_get_rate(host->clk); 514 host->mclk = clk_get_rate(host->clk);
515 /*
516 * According to the spec, mclk is max 100 MHz,
517 * so we try to adjust the clock down to this,
518 * (if possible).
519 */
520 if (host->mclk > 100000000) {
521 ret = clk_set_rate(host->clk, 100000000);
522 if (ret < 0)
523 goto clk_disable;
524 host->mclk = clk_get_rate(host->clk);
525 DBG(host, "eventual mclk rate: %u Hz\n", host->mclk);
526 }
515 host->mmc = mmc; 527 host->mmc = mmc;
516 host->base = ioremap(dev->res.start, SZ_4K); 528 host->base = ioremap(dev->res.start, SZ_4K);
517 if (!host->base) { 529 if (!host->base) {
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 7fb02e177a3d..299118de8933 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -187,7 +187,7 @@ struct sdhci_host {
187 struct mmc_request *mrq; /* Current request */ 187 struct mmc_request *mrq; /* Current request */
188 struct mmc_command *cmd; /* Current command */ 188 struct mmc_command *cmd; /* Current command */
189 struct mmc_data *data; /* Current data request */ 189 struct mmc_data *data; /* Current data request */
190 int data_early:1; /* Data finished before cmd */ 190 unsigned int data_early:1; /* Data finished before cmd */
191 191
192 struct scatterlist *cur_sg; /* We're working on this */ 192 struct scatterlist *cur_sg; /* We're working on this */
193 int num_sg; /* Entries left */ 193 int num_sg; /* Entries left */
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 1bd69aa9e22a..17bc87a43ff4 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -374,7 +374,7 @@ config MTD_REDWOOD
374 374
375config MTD_SOLUTIONENGINE 375config MTD_SOLUTIONENGINE
376 tristate "CFI Flash device mapped on Hitachi SolutionEngine" 376 tristate "CFI Flash device mapped on Hitachi SolutionEngine"
377 depends on SUPERH && MTD_CFI && MTD_REDBOOT_PARTS 377 depends on SUPERH && SOLUTION_ENGINE && MTD_CFI && MTD_REDBOOT_PARTS
378 help 378 help
379 This enables access to the flash chips on the Hitachi SolutionEngine and 379 This enables access to the flash chips on the Hitachi SolutionEngine and
380 similar boards. Say 'Y' if you are building a kernel for such a board. 380 similar boards. Say 'Y' if you are building a kernel for such a board.
@@ -480,13 +480,6 @@ config MTD_H720X
480 This enables access to the flash chips on the Hynix evaluation boards. 480 This enables access to the flash chips on the Hynix evaluation boards.
481 If you have such a board, say 'Y'. 481 If you have such a board, say 'Y'.
482 482
483config MTD_MPC1211
484 tristate "CFI Flash device mapped on Interface MPC-1211"
485 depends on SH_MPC1211 && MTD_CFI
486 help
487 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02).
488 If you have such a board, say 'Y'.
489
490config MTD_OMAP_NOR 483config MTD_OMAP_NOR
491 tristate "TI OMAP board mappings" 484 tristate "TI OMAP board mappings"
492 depends on MTD_CFI && ARCH_OMAP 485 depends on MTD_CFI && ARCH_OMAP
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index a9cbe80f99a0..957fb5f70f5e 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -58,7 +58,6 @@ obj-$(CONFIG_MTD_WALNUT) += walnut.o
58obj-$(CONFIG_MTD_H720X) += h720x-flash.o 58obj-$(CONFIG_MTD_H720X) += h720x-flash.o
59obj-$(CONFIG_MTD_SBC8240) += sbc8240.o 59obj-$(CONFIG_MTD_SBC8240) += sbc8240.o
60obj-$(CONFIG_MTD_NOR_TOTO) += omap-toto-flash.o 60obj-$(CONFIG_MTD_NOR_TOTO) += omap-toto-flash.o
61obj-$(CONFIG_MTD_MPC1211) += mpc1211.o
62obj-$(CONFIG_MTD_IXP4XX) += ixp4xx.o 61obj-$(CONFIG_MTD_IXP4XX) += ixp4xx.o
63obj-$(CONFIG_MTD_IXP2000) += ixp2000.o 62obj-$(CONFIG_MTD_IXP2000) += ixp2000.o
64obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o 63obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o
diff --git a/drivers/mtd/maps/mpc1211.c b/drivers/mtd/maps/mpc1211.c
deleted file mode 100644
index 45a00fac88ac..000000000000
--- a/drivers/mtd/maps/mpc1211.c
+++ /dev/null
@@ -1,80 +0,0 @@
1/*
2 * Flash on MPC-1211
3 *
4 * $Id: mpc1211.c,v 1.4 2004/09/16 23:27:13 gleixner Exp $
5 *
6 * (C) 2002 Interface, Saito.K & Jeanne
7 *
8 * GPL'd
9 */
10
11#include <linux/module.h>
12#include <linux/types.h>
13#include <linux/kernel.h>
14#include <asm/io.h>
15#include <linux/mtd/mtd.h>
16#include <linux/mtd/map.h>
17#include <linux/mtd/partitions.h>
18
19static struct mtd_info *flash_mtd;
20static struct mtd_partition *parsed_parts;
21
22struct map_info mpc1211_flash_map = {
23 .name = "MPC-1211 FLASH",
24 .size = 0x80000,
25 .bankwidth = 1,
26};
27
28static struct mtd_partition mpc1211_partitions[] = {
29 {
30 .name = "IPL & ETH-BOOT",
31 .offset = 0x00000000,
32 .size = 0x10000,
33 },
34 {
35 .name = "Flash FS",
36 .offset = 0x00010000,
37 .size = MTDPART_SIZ_FULL,
38 }
39};
40
41static int __init init_mpc1211_maps(void)
42{
43 int nr_parts;
44
45 mpc1211_flash_map.phys = 0;
46 mpc1211_flash_map.virt = (void __iomem *)P2SEGADDR(0);
47
48 simple_map_init(&mpc1211_flash_map);
49
50 printk(KERN_NOTICE "Probing for flash chips at 0x00000000:\n");
51 flash_mtd = do_map_probe("jedec_probe", &mpc1211_flash_map);
52 if (!flash_mtd) {
53 printk(KERN_NOTICE "Flash chips not detected at either possible location.\n");
54 return -ENXIO;
55 }
56 printk(KERN_NOTICE "MPC-1211: Flash at 0x%08lx\n", mpc1211_flash_map.virt & 0x1fffffff);
57 flash_mtd->module = THIS_MODULE;
58
59 parsed_parts = mpc1211_partitions;
60 nr_parts = ARRAY_SIZE(mpc1211_partitions);
61
62 add_mtd_partitions(flash_mtd, parsed_parts, nr_parts);
63 return 0;
64}
65
66static void __exit cleanup_mpc1211_maps(void)
67{
68 if (parsed_parts)
69 del_mtd_partitions(flash_mtd);
70 else
71 del_mtd_device(flash_mtd);
72 map_destroy(flash_mtd);
73}
74
75module_init(init_mpc1211_maps);
76module_exit(cleanup_mpc1211_maps);
77
78MODULE_LICENSE("GPL");
79MODULE_AUTHOR("Saito.K & Jeanne <ksaito@interface.co.jp>");
80MODULE_DESCRIPTION("MTD map driver for MPC-1211 boards. Interface");
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 6f8e7d4cf74d..2edda8cc7f99 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -319,7 +319,7 @@ static struct vortex_chip_info {
319 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)", 319 {"3c920B-EMB-WNM (ATI Radeon 9100 IGP)",
320 PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, }, 320 PCI_USES_MASTER, IS_TORNADO|HAS_MII|HAS_HWCKSM, 128, },
321 {"3c980 Cyclone", 321 {"3c980 Cyclone",
322 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM, 128, }, 322 PCI_USES_MASTER, IS_CYCLONE|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
323 323
324 {"3c980C Python-T", 324 {"3c980C Python-T",
325 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, }, 325 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM, 128, },
@@ -600,7 +600,6 @@ struct vortex_private {
600 struct sk_buff* tx_skbuff[TX_RING_SIZE]; 600 struct sk_buff* tx_skbuff[TX_RING_SIZE];
601 unsigned int cur_rx, cur_tx; /* The next free ring entry */ 601 unsigned int cur_rx, cur_tx; /* The next free ring entry */
602 unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */ 602 unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */
603 struct net_device_stats stats; /* Generic stats */
604 struct vortex_extra_stats xstats; /* NIC-specific extra stats */ 603 struct vortex_extra_stats xstats; /* NIC-specific extra stats */
605 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */ 604 struct sk_buff *tx_skb; /* Packet being eaten by bus master ctrl. */
606 dma_addr_t tx_skb_dma; /* Allocated DMA address for bus master ctrl DMA. */ 605 dma_addr_t tx_skb_dma; /* Allocated DMA address for bus master ctrl DMA. */
@@ -1875,7 +1874,7 @@ static void vortex_tx_timeout(struct net_device *dev)
1875 1874
1876 issue_and_wait(dev, TxReset); 1875 issue_and_wait(dev, TxReset);
1877 1876
1878 vp->stats.tx_errors++; 1877 dev->stats.tx_errors++;
1879 if (vp->full_bus_master_tx) { 1878 if (vp->full_bus_master_tx) {
1880 printk(KERN_DEBUG "%s: Resetting the Tx ring pointer.\n", dev->name); 1879 printk(KERN_DEBUG "%s: Resetting the Tx ring pointer.\n", dev->name);
1881 if (vp->cur_tx - vp->dirty_tx > 0 && ioread32(ioaddr + DownListPtr) == 0) 1880 if (vp->cur_tx - vp->dirty_tx > 0 && ioread32(ioaddr + DownListPtr) == 0)
@@ -1887,7 +1886,7 @@ static void vortex_tx_timeout(struct net_device *dev)
1887 iowrite8(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold); 1886 iowrite8(PKT_BUF_SZ>>8, ioaddr + TxFreeThreshold);
1888 iowrite16(DownUnstall, ioaddr + EL3_CMD); 1887 iowrite16(DownUnstall, ioaddr + EL3_CMD);
1889 } else { 1888 } else {
1890 vp->stats.tx_dropped++; 1889 dev->stats.tx_dropped++;
1891 netif_wake_queue(dev); 1890 netif_wake_queue(dev);
1892 } 1891 }
1893 1892
@@ -1928,8 +1927,8 @@ vortex_error(struct net_device *dev, int status)
1928 } 1927 }
1929 dump_tx_ring(dev); 1928 dump_tx_ring(dev);
1930 } 1929 }
1931 if (tx_status & 0x14) vp->stats.tx_fifo_errors++; 1930 if (tx_status & 0x14) dev->stats.tx_fifo_errors++;
1932 if (tx_status & 0x38) vp->stats.tx_aborted_errors++; 1931 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
1933 if (tx_status & 0x08) vp->xstats.tx_max_collisions++; 1932 if (tx_status & 0x08) vp->xstats.tx_max_collisions++;
1934 iowrite8(0, ioaddr + TxStatus); 1933 iowrite8(0, ioaddr + TxStatus);
1935 if (tx_status & 0x30) { /* txJabber or txUnderrun */ 1934 if (tx_status & 0x30) { /* txJabber or txUnderrun */
@@ -2051,8 +2050,8 @@ vortex_start_xmit(struct sk_buff *skb, struct net_device *dev)
2051 if (vortex_debug > 2) 2050 if (vortex_debug > 2)
2052 printk(KERN_DEBUG "%s: Tx error, status %2.2x.\n", 2051 printk(KERN_DEBUG "%s: Tx error, status %2.2x.\n",
2053 dev->name, tx_status); 2052 dev->name, tx_status);
2054 if (tx_status & 0x04) vp->stats.tx_fifo_errors++; 2053 if (tx_status & 0x04) dev->stats.tx_fifo_errors++;
2055 if (tx_status & 0x38) vp->stats.tx_aborted_errors++; 2054 if (tx_status & 0x38) dev->stats.tx_aborted_errors++;
2056 if (tx_status & 0x30) { 2055 if (tx_status & 0x30) {
2057 issue_and_wait(dev, TxReset); 2056 issue_and_wait(dev, TxReset);
2058 } 2057 }
@@ -2350,7 +2349,7 @@ boomerang_interrupt(int irq, void *dev_id)
2350 } else { 2349 } else {
2351 printk(KERN_DEBUG "boomerang_interrupt: no skb!\n"); 2350 printk(KERN_DEBUG "boomerang_interrupt: no skb!\n");
2352 } 2351 }
2353 /* vp->stats.tx_packets++; Counted below. */ 2352 /* dev->stats.tx_packets++; Counted below. */
2354 dirty_tx++; 2353 dirty_tx++;
2355 } 2354 }
2356 vp->dirty_tx = dirty_tx; 2355 vp->dirty_tx = dirty_tx;
@@ -2409,12 +2408,12 @@ static int vortex_rx(struct net_device *dev)
2409 unsigned char rx_error = ioread8(ioaddr + RxErrors); 2408 unsigned char rx_error = ioread8(ioaddr + RxErrors);
2410 if (vortex_debug > 2) 2409 if (vortex_debug > 2)
2411 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error); 2410 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error);
2412 vp->stats.rx_errors++; 2411 dev->stats.rx_errors++;
2413 if (rx_error & 0x01) vp->stats.rx_over_errors++; 2412 if (rx_error & 0x01) dev->stats.rx_over_errors++;
2414 if (rx_error & 0x02) vp->stats.rx_length_errors++; 2413 if (rx_error & 0x02) dev->stats.rx_length_errors++;
2415 if (rx_error & 0x04) vp->stats.rx_frame_errors++; 2414 if (rx_error & 0x04) dev->stats.rx_frame_errors++;
2416 if (rx_error & 0x08) vp->stats.rx_crc_errors++; 2415 if (rx_error & 0x08) dev->stats.rx_crc_errors++;
2417 if (rx_error & 0x10) vp->stats.rx_length_errors++; 2416 if (rx_error & 0x10) dev->stats.rx_length_errors++;
2418 } else { 2417 } else {
2419 /* The packet length: up to 4.5K!. */ 2418 /* The packet length: up to 4.5K!. */
2420 int pkt_len = rx_status & 0x1fff; 2419 int pkt_len = rx_status & 0x1fff;
@@ -2446,7 +2445,7 @@ static int vortex_rx(struct net_device *dev)
2446 skb->protocol = eth_type_trans(skb, dev); 2445 skb->protocol = eth_type_trans(skb, dev);
2447 netif_rx(skb); 2446 netif_rx(skb);
2448 dev->last_rx = jiffies; 2447 dev->last_rx = jiffies;
2449 vp->stats.rx_packets++; 2448 dev->stats.rx_packets++;
2450 /* Wait a limited time to go to next packet. */ 2449 /* Wait a limited time to go to next packet. */
2451 for (i = 200; i >= 0; i--) 2450 for (i = 200; i >= 0; i--)
2452 if ( ! (ioread16(ioaddr + EL3_STATUS) & CmdInProgress)) 2451 if ( ! (ioread16(ioaddr + EL3_STATUS) & CmdInProgress))
@@ -2455,7 +2454,7 @@ static int vortex_rx(struct net_device *dev)
2455 } else if (vortex_debug > 0) 2454 } else if (vortex_debug > 0)
2456 printk(KERN_NOTICE "%s: No memory to allocate a sk_buff of " 2455 printk(KERN_NOTICE "%s: No memory to allocate a sk_buff of "
2457 "size %d.\n", dev->name, pkt_len); 2456 "size %d.\n", dev->name, pkt_len);
2458 vp->stats.rx_dropped++; 2457 dev->stats.rx_dropped++;
2459 } 2458 }
2460 issue_and_wait(dev, RxDiscard); 2459 issue_and_wait(dev, RxDiscard);
2461 } 2460 }
@@ -2482,12 +2481,12 @@ boomerang_rx(struct net_device *dev)
2482 unsigned char rx_error = rx_status >> 16; 2481 unsigned char rx_error = rx_status >> 16;
2483 if (vortex_debug > 2) 2482 if (vortex_debug > 2)
2484 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error); 2483 printk(KERN_DEBUG " Rx error: status %2.2x.\n", rx_error);
2485 vp->stats.rx_errors++; 2484 dev->stats.rx_errors++;
2486 if (rx_error & 0x01) vp->stats.rx_over_errors++; 2485 if (rx_error & 0x01) dev->stats.rx_over_errors++;
2487 if (rx_error & 0x02) vp->stats.rx_length_errors++; 2486 if (rx_error & 0x02) dev->stats.rx_length_errors++;
2488 if (rx_error & 0x04) vp->stats.rx_frame_errors++; 2487 if (rx_error & 0x04) dev->stats.rx_frame_errors++;
2489 if (rx_error & 0x08) vp->stats.rx_crc_errors++; 2488 if (rx_error & 0x08) dev->stats.rx_crc_errors++;
2490 if (rx_error & 0x10) vp->stats.rx_length_errors++; 2489 if (rx_error & 0x10) dev->stats.rx_length_errors++;
2491 } else { 2490 } else {
2492 /* The packet length: up to 4.5K!. */ 2491 /* The packet length: up to 4.5K!. */
2493 int pkt_len = rx_status & 0x1fff; 2492 int pkt_len = rx_status & 0x1fff;
@@ -2529,7 +2528,7 @@ boomerang_rx(struct net_device *dev)
2529 } 2528 }
2530 netif_rx(skb); 2529 netif_rx(skb);
2531 dev->last_rx = jiffies; 2530 dev->last_rx = jiffies;
2532 vp->stats.rx_packets++; 2531 dev->stats.rx_packets++;
2533 } 2532 }
2534 entry = (++vp->cur_rx) % RX_RING_SIZE; 2533 entry = (++vp->cur_rx) % RX_RING_SIZE;
2535 } 2534 }
@@ -2591,7 +2590,7 @@ vortex_down(struct net_device *dev, int final_down)
2591 del_timer_sync(&vp->rx_oom_timer); 2590 del_timer_sync(&vp->rx_oom_timer);
2592 del_timer_sync(&vp->timer); 2591 del_timer_sync(&vp->timer);
2593 2592
2594 /* Turn off statistics ASAP. We update vp->stats below. */ 2593 /* Turn off statistics ASAP. We update dev->stats below. */
2595 iowrite16(StatsDisable, ioaddr + EL3_CMD); 2594 iowrite16(StatsDisable, ioaddr + EL3_CMD);
2596 2595
2597 /* Disable the receiver and transmitter. */ 2596 /* Disable the receiver and transmitter. */
@@ -2728,7 +2727,7 @@ static struct net_device_stats *vortex_get_stats(struct net_device *dev)
2728 update_stats(ioaddr, dev); 2727 update_stats(ioaddr, dev);
2729 spin_unlock_irqrestore (&vp->lock, flags); 2728 spin_unlock_irqrestore (&vp->lock, flags);
2730 } 2729 }
2731 return &vp->stats; 2730 return &dev->stats;
2732} 2731}
2733 2732
2734/* Update statistics. 2733/* Update statistics.
@@ -2748,18 +2747,18 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2748 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */ 2747 /* Unlike the 3c5x9 we need not turn off stats updates while reading. */
2749 /* Switch to the stats window, and read everything. */ 2748 /* Switch to the stats window, and read everything. */
2750 EL3WINDOW(6); 2749 EL3WINDOW(6);
2751 vp->stats.tx_carrier_errors += ioread8(ioaddr + 0); 2750 dev->stats.tx_carrier_errors += ioread8(ioaddr + 0);
2752 vp->stats.tx_heartbeat_errors += ioread8(ioaddr + 1); 2751 dev->stats.tx_heartbeat_errors += ioread8(ioaddr + 1);
2753 vp->stats.tx_window_errors += ioread8(ioaddr + 4); 2752 dev->stats.tx_window_errors += ioread8(ioaddr + 4);
2754 vp->stats.rx_fifo_errors += ioread8(ioaddr + 5); 2753 dev->stats.rx_fifo_errors += ioread8(ioaddr + 5);
2755 vp->stats.tx_packets += ioread8(ioaddr + 6); 2754 dev->stats.tx_packets += ioread8(ioaddr + 6);
2756 vp->stats.tx_packets += (ioread8(ioaddr + 9)&0x30) << 4; 2755 dev->stats.tx_packets += (ioread8(ioaddr + 9)&0x30) << 4;
2757 /* Rx packets */ ioread8(ioaddr + 7); /* Must read to clear */ 2756 /* Rx packets */ ioread8(ioaddr + 7); /* Must read to clear */
2758 /* Don't bother with register 9, an extension of registers 6&7. 2757 /* Don't bother with register 9, an extension of registers 6&7.
2759 If we do use the 6&7 values the atomic update assumption above 2758 If we do use the 6&7 values the atomic update assumption above
2760 is invalid. */ 2759 is invalid. */
2761 vp->stats.rx_bytes += ioread16(ioaddr + 10); 2760 dev->stats.rx_bytes += ioread16(ioaddr + 10);
2762 vp->stats.tx_bytes += ioread16(ioaddr + 12); 2761 dev->stats.tx_bytes += ioread16(ioaddr + 12);
2763 /* Extra stats for get_ethtool_stats() */ 2762 /* Extra stats for get_ethtool_stats() */
2764 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2); 2763 vp->xstats.tx_multiple_collisions += ioread8(ioaddr + 2);
2765 vp->xstats.tx_single_collisions += ioread8(ioaddr + 3); 2764 vp->xstats.tx_single_collisions += ioread8(ioaddr + 3);
@@ -2767,14 +2766,14 @@ static void update_stats(void __iomem *ioaddr, struct net_device *dev)
2767 EL3WINDOW(4); 2766 EL3WINDOW(4);
2768 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12); 2767 vp->xstats.rx_bad_ssd += ioread8(ioaddr + 12);
2769 2768
2770 vp->stats.collisions = vp->xstats.tx_multiple_collisions 2769 dev->stats.collisions = vp->xstats.tx_multiple_collisions
2771 + vp->xstats.tx_single_collisions 2770 + vp->xstats.tx_single_collisions
2772 + vp->xstats.tx_max_collisions; 2771 + vp->xstats.tx_max_collisions;
2773 2772
2774 { 2773 {
2775 u8 up = ioread8(ioaddr + 13); 2774 u8 up = ioread8(ioaddr + 13);
2776 vp->stats.rx_bytes += (up & 0x0f) << 16; 2775 dev->stats.rx_bytes += (up & 0x0f) << 16;
2777 vp->stats.tx_bytes += (up & 0xf0) << 12; 2776 dev->stats.tx_bytes += (up & 0xf0) << 12;
2778 } 2777 }
2779 2778
2780 EL3WINDOW(old_window >> 13); 2779 EL3WINDOW(old_window >> 13);
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index af46341827f2..9f6cc8a56073 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1273,20 +1273,6 @@ config PCNET32
1273 To compile this driver as a module, choose M here. The module 1273 To compile this driver as a module, choose M here. The module
1274 will be called pcnet32. 1274 will be called pcnet32.
1275 1275
1276config PCNET32_NAPI
1277 bool "Use RX polling (NAPI)"
1278 depends on PCNET32
1279 help
1280 NAPI is a new driver API designed to reduce CPU and interrupt load
1281 when the driver is receiving lots of packets from the card. It is
1282 still somewhat experimental and thus not yet enabled by default.
1283
1284 If your estimated Rx load is 10kpps or more, or if the card will be
1285 deployed on potentially unfriendly networks (e.g. in a firewall),
1286 then say Y here.
1287
1288 If in doubt, say N.
1289
1290config AMD8111_ETH 1276config AMD8111_ETH
1291 tristate "AMD 8111 (new PCI lance) support" 1277 tristate "AMD 8111 (new PCI lance) support"
1292 depends on NET_PCI && PCI 1278 depends on NET_PCI && PCI
@@ -2440,7 +2426,7 @@ config CHELSIO_T3
2440 2426
2441config EHEA 2427config EHEA
2442 tristate "eHEA Ethernet support" 2428 tristate "eHEA Ethernet support"
2443 depends on IBMEBUS && INET && SPARSEMEM 2429 depends on IBMEBUS && INET && SPARSEMEM && MEMORY_HOTPLUG
2444 select INET_LRO 2430 select INET_LRO
2445 ---help--- 2431 ---help---
2446 This driver supports the IBM pSeries eHEA ethernet adapter. 2432 This driver supports the IBM pSeries eHEA ethernet adapter.
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c
index 82e9a5bd0dd2..a0b4c8516073 100644
--- a/drivers/net/appletalk/cops.c
+++ b/drivers/net/appletalk/cops.c
@@ -499,19 +499,13 @@ static void cops_reset(struct net_device *dev, int sleep)
499 { 499 {
500 outb(0, ioaddr+DAYNA_RESET); /* Assert the reset port */ 500 outb(0, ioaddr+DAYNA_RESET); /* Assert the reset port */
501 inb(ioaddr+DAYNA_RESET); /* Clear the reset */ 501 inb(ioaddr+DAYNA_RESET); /* Clear the reset */
502 if(sleep) 502 if (sleep)
503 { 503 msleep(333);
504 long snap=jiffies; 504 else
505 505 mdelay(333);
506 /* Let card finish initializing, about 1/3 second */
507 while (time_before(jiffies, snap + HZ/3))
508 schedule();
509 }
510 else
511 mdelay(333);
512 } 506 }
507
513 netif_wake_queue(dev); 508 netif_wake_queue(dev);
514 return;
515} 509}
516 510
517static void cops_load (struct net_device *dev) 511static void cops_load (struct net_device *dev)
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 0afe522b8f7b..9c2394d49428 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 4 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
5 * 5 *
6 * Derived from Intel e1000 driver 6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
@@ -36,7 +36,6 @@
36 * A very incomplete list of things that need to be dealt with: 36 * A very incomplete list of things that need to be dealt with:
37 * 37 *
38 * TODO: 38 * TODO:
39 * Wake on LAN.
40 * Add more ethtool functions. 39 * Add more ethtool functions.
41 * Fix abstruse irq enable/disable condition described here: 40 * Fix abstruse irq enable/disable condition described here:
42 * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 41 * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2
@@ -638,21 +637,18 @@ static s32 atl1_phy_leave_power_saving(struct atl1_hw *hw)
638} 637}
639 638
640/* 639/*
641 *TODO: do something or get rid of this 640 * Force the PHY into power saving mode using vendor magic.
642 */ 641 */
643#ifdef CONFIG_PM 642#ifdef CONFIG_PM
644static s32 atl1_phy_enter_power_saving(struct atl1_hw *hw) 643static void atl1_phy_enter_power_saving(struct atl1_hw *hw)
645{ 644{
646/* s32 ret_val; 645 atl1_write_phy_reg(hw, MII_DBG_ADDR, 0);
647 * u16 phy_data; 646 atl1_write_phy_reg(hw, MII_DBG_DATA, 0x124E);
648 */ 647 atl1_write_phy_reg(hw, MII_DBG_ADDR, 2);
648 atl1_write_phy_reg(hw, MII_DBG_DATA, 0x3000);
649 atl1_write_phy_reg(hw, MII_DBG_ADDR, 3);
650 atl1_write_phy_reg(hw, MII_DBG_DATA, 0);
649 651
650/*
651 ret_val = atl1_write_phy_reg(hw, ...);
652 ret_val = atl1_write_phy_reg(hw, ...);
653 ....
654*/
655 return 0;
656} 652}
657#endif 653#endif
658 654
@@ -2784,64 +2780,93 @@ static int atl1_suspend(struct pci_dev *pdev, pm_message_t state)
2784 struct atl1_hw *hw = &adapter->hw; 2780 struct atl1_hw *hw = &adapter->hw;
2785 u32 ctrl = 0; 2781 u32 ctrl = 0;
2786 u32 wufc = adapter->wol; 2782 u32 wufc = adapter->wol;
2783 u32 val;
2784 int retval;
2785 u16 speed;
2786 u16 duplex;
2787 2787
2788 netif_device_detach(netdev); 2788 netif_device_detach(netdev);
2789 if (netif_running(netdev)) 2789 if (netif_running(netdev))
2790 atl1_down(adapter); 2790 atl1_down(adapter);
2791 2791
2792 retval = pci_save_state(pdev);
2793 if (retval)
2794 return retval;
2795
2792 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); 2796 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2793 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); 2797 atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl);
2794 if (ctrl & BMSR_LSTATUS) 2798 val = ctrl & BMSR_LSTATUS;
2799 if (val)
2795 wufc &= ~ATLX_WUFC_LNKC; 2800 wufc &= ~ATLX_WUFC_LNKC;
2796 2801
2797 /* reduce speed to 10/100M */ 2802 if (val && wufc) {
2798 if (wufc) { 2803 val = atl1_get_speed_and_duplex(hw, &speed, &duplex);
2799 atl1_phy_enter_power_saving(hw); 2804 if (val) {
2800 /* if resume, let driver to re- setup link */ 2805 if (netif_msg_ifdown(adapter))
2801 hw->phy_configured = false; 2806 dev_printk(KERN_DEBUG, &pdev->dev,
2802 atl1_set_mac_addr(hw); 2807 "error getting speed/duplex\n");
2803 atlx_set_multi(netdev); 2808 goto disable_wol;
2809 }
2804 2810
2805 ctrl = 0; 2811 ctrl = 0;
2806 /* turn on magic packet wol */
2807 if (wufc & ATLX_WUFC_MAG)
2808 ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN;
2809 2812
2810 /* turn on Link change WOL */ 2813 /* enable magic packet WOL */
2811 if (wufc & ATLX_WUFC_LNKC) 2814 if (wufc & ATLX_WUFC_MAG)
2812 ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); 2815 ctrl |= (WOL_MAGIC_EN | WOL_MAGIC_PME_EN);
2813 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); 2816 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
2814 2817 ioread32(hw->hw_addr + REG_WOL_CTRL);
2815 /* turn on all-multi mode if wake on multicast is enabled */ 2818
2816 ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL); 2819 /* configure the mac */
2817 ctrl &= ~MAC_CTRL_DBG; 2820 ctrl = MAC_CTRL_RX_EN;
2818 ctrl &= ~MAC_CTRL_PROMIS_EN; 2821 ctrl |= ((u32)((speed == SPEED_1000) ? MAC_CTRL_SPEED_1000 :
2819 if (wufc & ATLX_WUFC_MC) 2822 MAC_CTRL_SPEED_10_100) << MAC_CTRL_SPEED_SHIFT);
2820 ctrl |= MAC_CTRL_MC_ALL_EN; 2823 if (duplex == FULL_DUPLEX)
2821 else 2824 ctrl |= MAC_CTRL_DUPLX;
2822 ctrl &= ~MAC_CTRL_MC_ALL_EN; 2825 ctrl |= (((u32)adapter->hw.preamble_len &
2823 2826 MAC_CTRL_PRMLEN_MASK) << MAC_CTRL_PRMLEN_SHIFT);
2824 /* turn on broadcast mode if wake on-BC is enabled */ 2827 if (adapter->vlgrp)
2825 if (wufc & ATLX_WUFC_BC) 2828 ctrl |= MAC_CTRL_RMV_VLAN;
2829 if (wufc & ATLX_WUFC_MAG)
2826 ctrl |= MAC_CTRL_BC_EN; 2830 ctrl |= MAC_CTRL_BC_EN;
2827 else
2828 ctrl &= ~MAC_CTRL_BC_EN;
2829
2830 /* enable RX */
2831 ctrl |= MAC_CTRL_RX_EN;
2832 iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); 2831 iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL);
2833 pci_enable_wake(pdev, PCI_D3hot, 1); 2832 ioread32(hw->hw_addr + REG_MAC_CTRL);
2834 pci_enable_wake(pdev, PCI_D3cold, 1); 2833
2835 } else { 2834 /* poke the PHY */
2836 iowrite32(0, hw->hw_addr + REG_WOL_CTRL); 2835 ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2837 pci_enable_wake(pdev, PCI_D3hot, 0); 2836 ctrl |= PCIE_PHYMISC_FORCE_RCV_DET;
2838 pci_enable_wake(pdev, PCI_D3cold, 0); 2837 iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2838 ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2839
2840 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2841 goto exit;
2839 } 2842 }
2840 2843
2841 pci_save_state(pdev); 2844 if (!val && wufc) {
2845 ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN);
2846 iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL);
2847 ioread32(hw->hw_addr + REG_WOL_CTRL);
2848 iowrite32(0, hw->hw_addr + REG_MAC_CTRL);
2849 ioread32(hw->hw_addr + REG_MAC_CTRL);
2850 hw->phy_configured = false;
2851 pci_enable_wake(pdev, pci_choose_state(pdev, state), 1);
2852 goto exit;
2853 }
2854
2855disable_wol:
2856 iowrite32(0, hw->hw_addr + REG_WOL_CTRL);
2857 ioread32(hw->hw_addr + REG_WOL_CTRL);
2858 ctrl = ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2859 ctrl |= PCIE_PHYMISC_FORCE_RCV_DET;
2860 iowrite32(ctrl, hw->hw_addr + REG_PCIE_PHYMISC);
2861 ioread32(hw->hw_addr + REG_PCIE_PHYMISC);
2862 atl1_phy_enter_power_saving(hw);
2863 hw->phy_configured = false;
2864 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
2865exit:
2866 if (netif_running(netdev))
2867 pci_disable_msi(adapter->pdev);
2842 pci_disable_device(pdev); 2868 pci_disable_device(pdev);
2843 2869 pci_set_power_state(pdev, pci_choose_state(pdev, state));
2844 pci_set_power_state(pdev, PCI_D3hot);
2845 2870
2846 return 0; 2871 return 0;
2847} 2872}
@@ -2855,20 +2880,26 @@ static int atl1_resume(struct pci_dev *pdev)
2855 pci_set_power_state(pdev, PCI_D0); 2880 pci_set_power_state(pdev, PCI_D0);
2856 pci_restore_state(pdev); 2881 pci_restore_state(pdev);
2857 2882
2858 /* FIXME: check and handle */
2859 err = pci_enable_device(pdev); 2883 err = pci_enable_device(pdev);
2884 if (err) {
2885 if (netif_msg_ifup(adapter))
2886 dev_printk(KERN_DEBUG, &pdev->dev,
2887 "error enabling pci device\n");
2888 return err;
2889 }
2890
2891 pci_set_master(pdev);
2892 iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL);
2860 pci_enable_wake(pdev, PCI_D3hot, 0); 2893 pci_enable_wake(pdev, PCI_D3hot, 0);
2861 pci_enable_wake(pdev, PCI_D3cold, 0); 2894 pci_enable_wake(pdev, PCI_D3cold, 0);
2862 2895
2863 iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); 2896 atl1_reset_hw(&adapter->hw);
2864 atl1_reset(adapter); 2897 adapter->cmb.cmb->int_stats = 0;
2865 2898
2866 if (netif_running(netdev)) 2899 if (netif_running(netdev))
2867 atl1_up(adapter); 2900 atl1_up(adapter);
2868 netif_device_attach(netdev); 2901 netif_device_attach(netdev);
2869 2902
2870 atl1_via_workaround(adapter);
2871
2872 return 0; 2903 return 0;
2873} 2904}
2874#else 2905#else
@@ -2876,6 +2907,13 @@ static int atl1_resume(struct pci_dev *pdev)
2876#define atl1_resume NULL 2907#define atl1_resume NULL
2877#endif 2908#endif
2878 2909
2910static void atl1_shutdown(struct pci_dev *pdev)
2911{
2912#ifdef CONFIG_PM
2913 atl1_suspend(pdev, PMSG_SUSPEND);
2914#endif
2915}
2916
2879#ifdef CONFIG_NET_POLL_CONTROLLER 2917#ifdef CONFIG_NET_POLL_CONTROLLER
2880static void atl1_poll_controller(struct net_device *netdev) 2918static void atl1_poll_controller(struct net_device *netdev)
2881{ 2919{
@@ -3122,7 +3160,8 @@ static struct pci_driver atl1_driver = {
3122 .probe = atl1_probe, 3160 .probe = atl1_probe,
3123 .remove = __devexit_p(atl1_remove), 3161 .remove = __devexit_p(atl1_remove),
3124 .suspend = atl1_suspend, 3162 .suspend = atl1_suspend,
3125 .resume = atl1_resume 3163 .resume = atl1_resume,
3164 .shutdown = atl1_shutdown
3126}; 3165};
3127 3166
3128/* 3167/*
diff --git a/drivers/net/atlx/atl1.h b/drivers/net/atlx/atl1.h
index 51893d66eae1..a5015b14a429 100644
--- a/drivers/net/atlx/atl1.h
+++ b/drivers/net/atlx/atl1.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 2 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 3 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
4 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 4 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
5 * 5 *
6 * Derived from Intel e1000 driver 6 * Derived from Intel e1000 driver
7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved. 7 * Copyright(c) 1999 - 2005 Intel Corporation. All rights reserved.
diff --git a/drivers/net/atlx/atlx.c b/drivers/net/atlx/atlx.c
index f06b854e2501..b3e7fcf0f6e7 100644
--- a/drivers/net/atlx/atlx.c
+++ b/drivers/net/atlx/atlx.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
5 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 5 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
6 * Copyright(c) 2007 Atheros Corporation. All rights reserved. 6 * Copyright(c) 2007 Atheros Corporation. All rights reserved.
7 * 7 *
8 * Derived from Intel e1000 driver 8 * Derived from Intel e1000 driver
diff --git a/drivers/net/atlx/atlx.h b/drivers/net/atlx/atlx.h
index 3be7c09734d4..297a03da6b7f 100644
--- a/drivers/net/atlx/atlx.h
+++ b/drivers/net/atlx/atlx.h
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved. 3 * Copyright(c) 2005 - 2006 Attansic Corporation. All rights reserved.
4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com> 4 * Copyright(c) 2006 - 2007 Chris Snook <csnook@redhat.com>
5 * Copyright(c) 2006 Jay Cliburn <jcliburn@gmail.com> 5 * Copyright(c) 2006 - 2008 Jay Cliburn <jcliburn@gmail.com>
6 * Copyright(c) 2007 Atheros Corporation. All rights reserved. 6 * Copyright(c) 2007 Atheros Corporation. All rights reserved.
7 * 7 *
8 * Derived from Intel e1000 driver 8 * Derived from Intel e1000 driver
@@ -29,7 +29,7 @@
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/types.h> 30#include <linux/types.h>
31 31
32#define ATLX_DRIVER_VERSION "2.1.1" 32#define ATLX_DRIVER_VERSION "2.1.3"
33MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \ 33MODULE_AUTHOR("Xiong Huang <xiong.huang@atheros.com>, \
34 Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>"); 34 Chris Snook <csnook@redhat.com>, Jay Cliburn <jcliburn@gmail.com>");
35MODULE_LICENSE("GPL"); 35MODULE_LICENSE("GPL");
@@ -460,6 +460,9 @@ MODULE_VERSION(ATLX_DRIVER_VERSION);
460#define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */ 460#define MII_ATLX_PSSR_100MBS 0x4000 /* 01=100Mbs */
461#define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */ 461#define MII_ATLX_PSSR_1000MBS 0x8000 /* 10=1000Mbs */
462 462
463#define MII_DBG_ADDR 0x1D
464#define MII_DBG_DATA 0x1E
465
463/* PCI Command Register Bit Definitions */ 466/* PCI Command Register Bit Definitions */
464#define PCI_REG_COMMAND 0x04 /* PCI Command Register */ 467#define PCI_REG_COMMAND 0x04 /* PCI Command Register */
465#define CMD_IO_SPACE 0x0001 468#define CMD_IO_SPACE 0x0001
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6425603bc379..50a40e433154 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1425,13 +1425,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1425 res = netdev_set_master(slave_dev, bond_dev); 1425 res = netdev_set_master(slave_dev, bond_dev);
1426 if (res) { 1426 if (res) {
1427 dprintk("Error %d calling netdev_set_master\n", res); 1427 dprintk("Error %d calling netdev_set_master\n", res);
1428 goto err_close; 1428 goto err_restore_mac;
1429 } 1429 }
1430 /* open the slave since the application closed it */ 1430 /* open the slave since the application closed it */
1431 res = dev_open(slave_dev); 1431 res = dev_open(slave_dev);
1432 if (res) { 1432 if (res) {
1433 dprintk("Openning slave %s failed\n", slave_dev->name); 1433 dprintk("Openning slave %s failed\n", slave_dev->name);
1434 goto err_restore_mac; 1434 goto err_unset_master;
1435 } 1435 }
1436 1436
1437 new_slave->dev = slave_dev; 1437 new_slave->dev = slave_dev;
@@ -1444,7 +1444,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1444 */ 1444 */
1445 res = bond_alb_init_slave(bond, new_slave); 1445 res = bond_alb_init_slave(bond, new_slave);
1446 if (res) { 1446 if (res) {
1447 goto err_unset_master; 1447 goto err_close;
1448 } 1448 }
1449 } 1449 }
1450 1450
@@ -1619,7 +1619,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1619 1619
1620 res = bond_create_slave_symlinks(bond_dev, slave_dev); 1620 res = bond_create_slave_symlinks(bond_dev, slave_dev);
1621 if (res) 1621 if (res)
1622 goto err_unset_master; 1622 goto err_close;
1623 1623
1624 printk(KERN_INFO DRV_NAME 1624 printk(KERN_INFO DRV_NAME
1625 ": %s: enslaving %s as a%s interface with a%s link.\n", 1625 ": %s: enslaving %s as a%s interface with a%s link.\n",
@@ -1631,12 +1631,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1631 return 0; 1631 return 0;
1632 1632
1633/* Undo stages on error */ 1633/* Undo stages on error */
1634err_unset_master:
1635 netdev_set_master(slave_dev, NULL);
1636
1637err_close: 1634err_close:
1638 dev_close(slave_dev); 1635 dev_close(slave_dev);
1639 1636
1637err_unset_master:
1638 netdev_set_master(slave_dev, NULL);
1639
1640err_restore_mac: 1640err_restore_mac:
1641 if (!bond->params.fail_over_mac) { 1641 if (!bond->params.fail_over_mac) {
1642 memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN); 1642 memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
@@ -4936,7 +4936,9 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4936 if (res < 0) { 4936 if (res < 0) {
4937 rtnl_lock(); 4937 rtnl_lock();
4938 down_write(&bonding_rwsem); 4938 down_write(&bonding_rwsem);
4939 goto out_bond; 4939 bond_deinit(bond_dev);
4940 unregister_netdevice(bond_dev);
4941 goto out_rtnl;
4940 } 4942 }
4941 4943
4942 return 0; 4944 return 0;
@@ -4990,9 +4992,10 @@ err:
4990 destroy_workqueue(bond->wq); 4992 destroy_workqueue(bond->wq);
4991 } 4993 }
4992 4994
4995 bond_destroy_sysfs();
4996
4993 rtnl_lock(); 4997 rtnl_lock();
4994 bond_free_all(); 4998 bond_free_all();
4995 bond_destroy_sysfs();
4996 rtnl_unlock(); 4999 rtnl_unlock();
4997out: 5000out:
4998 return res; 5001 return res;
@@ -5004,9 +5007,10 @@ static void __exit bonding_exit(void)
5004 unregister_netdevice_notifier(&bond_netdev_notifier); 5007 unregister_netdevice_notifier(&bond_netdev_notifier);
5005 unregister_inetaddr_notifier(&bond_inetaddr_notifier); 5008 unregister_inetaddr_notifier(&bond_inetaddr_notifier);
5006 5009
5010 bond_destroy_sysfs();
5011
5007 rtnl_lock(); 5012 rtnl_lock();
5008 bond_free_all(); 5013 bond_free_all();
5009 bond_destroy_sysfs();
5010 rtnl_unlock(); 5014 rtnl_unlock();
5011} 5015}
5012 5016
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 979c2d05ff9c..08f3d396bcd6 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -146,29 +146,29 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
146 ": Unable remove bond %s due to open references.\n", 146 ": Unable remove bond %s due to open references.\n",
147 ifname); 147 ifname);
148 res = -EPERM; 148 res = -EPERM;
149 goto out; 149 goto out_unlock;
150 } 150 }
151 printk(KERN_INFO DRV_NAME 151 printk(KERN_INFO DRV_NAME
152 ": %s is being deleted...\n", 152 ": %s is being deleted...\n",
153 bond->dev->name); 153 bond->dev->name);
154 bond_destroy(bond); 154 bond_destroy(bond);
155 up_write(&bonding_rwsem); 155 goto out_unlock;
156 rtnl_unlock();
157 goto out;
158 } 156 }
159 157
160 printk(KERN_ERR DRV_NAME 158 printk(KERN_ERR DRV_NAME
161 ": unable to delete non-existent bond %s\n", ifname); 159 ": unable to delete non-existent bond %s\n", ifname);
162 res = -ENODEV; 160 res = -ENODEV;
163 up_write(&bonding_rwsem); 161 goto out_unlock;
164 rtnl_unlock();
165 goto out;
166 } 162 }
167 163
168err_no_cmd: 164err_no_cmd:
169 printk(KERN_ERR DRV_NAME 165 printk(KERN_ERR DRV_NAME
170 ": no command found in bonding_masters. Use +ifname or -ifname.\n"); 166 ": no command found in bonding_masters. Use +ifname or -ifname.\n");
171 res = -EPERM; 167 return -EPERM;
168
169out_unlock:
170 up_write(&bonding_rwsem);
171 rtnl_unlock();
172 172
173 /* Always return either count or an error. If you return 0, you'll 173 /* Always return either count or an error. If you return 0, you'll
174 * get called forever, which is bad. 174 * get called forever, which is bad.
@@ -1437,8 +1437,16 @@ int bond_create_sysfs(void)
1437 * configure multiple bonding devices. 1437 * configure multiple bonding devices.
1438 */ 1438 */
1439 if (ret == -EEXIST) { 1439 if (ret == -EEXIST) {
1440 netdev_class = NULL; 1440 /* Is someone being kinky and naming a device bonding_master? */
1441 return 0; 1441 if (__dev_get_by_name(&init_net,
1442 class_attr_bonding_masters.attr.name))
1443 printk(KERN_ERR
1444 "network device named %s already exists in sysfs",
1445 class_attr_bonding_masters.attr.name);
1446 else {
1447 netdev_class = NULL;
1448 return 0;
1449 }
1442 } 1450 }
1443 1451
1444 return ret; 1452 return ret;
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h
index 4fdb13f8447b..acebe431d068 100644
--- a/drivers/net/cxgb3/adapter.h
+++ b/drivers/net/cxgb3/adapter.h
@@ -71,6 +71,7 @@ enum { /* adapter flags */
71 USING_MSIX = (1 << 2), 71 USING_MSIX = (1 << 2),
72 QUEUES_BOUND = (1 << 3), 72 QUEUES_BOUND = (1 << 3),
73 TP_PARITY_INIT = (1 << 4), 73 TP_PARITY_INIT = (1 << 4),
74 NAPI_INIT = (1 << 5),
74}; 75};
75 76
76struct fl_pg_chunk { 77struct fl_pg_chunk {
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h
index 91ee7277b813..579bee42a5cb 100644
--- a/drivers/net/cxgb3/common.h
+++ b/drivers/net/cxgb3/common.h
@@ -698,6 +698,7 @@ void mac_prep(struct cmac *mac, struct adapter *adapter, int index);
698void early_hw_init(struct adapter *adapter, const struct adapter_info *ai); 698void early_hw_init(struct adapter *adapter, const struct adapter_info *ai);
699int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai, 699int t3_prep_adapter(struct adapter *adapter, const struct adapter_info *ai,
700 int reset); 700 int reset);
701int t3_replay_prep_adapter(struct adapter *adapter);
701void t3_led_ready(struct adapter *adapter); 702void t3_led_ready(struct adapter *adapter);
702void t3_fatal_err(struct adapter *adapter); 703void t3_fatal_err(struct adapter *adapter);
703void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on); 704void t3_set_vlan_accel(struct adapter *adapter, unsigned int ports, int on);
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index 05e5f59e87fa..3a3127216791 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -421,6 +421,13 @@ static void init_napi(struct adapter *adap)
421 netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll, 421 netif_napi_add(qs->netdev, &qs->napi, qs->napi.poll,
422 64); 422 64);
423 } 423 }
424
425 /*
426 * netif_napi_add() can be called only once per napi_struct because it
427 * adds each new napi_struct to a list. Be careful not to call it a
428 * second time, e.g., during EEH recovery, by making a note of it.
429 */
430 adap->flags |= NAPI_INIT;
424} 431}
425 432
426/* 433/*
@@ -896,7 +903,8 @@ static int cxgb_up(struct adapter *adap)
896 goto out; 903 goto out;
897 904
898 setup_rss(adap); 905 setup_rss(adap);
899 init_napi(adap); 906 if (!(adap->flags & NAPI_INIT))
907 init_napi(adap);
900 adap->flags |= FULL_INIT_DONE; 908 adap->flags |= FULL_INIT_DONE;
901 } 909 }
902 910
@@ -999,7 +1007,7 @@ static int offload_open(struct net_device *dev)
999 return 0; 1007 return 0;
1000 1008
1001 if (!adap_up && (err = cxgb_up(adapter)) < 0) 1009 if (!adap_up && (err = cxgb_up(adapter)) < 0)
1002 return err; 1010 goto out;
1003 1011
1004 t3_tp_set_offload_mode(adapter, 1); 1012 t3_tp_set_offload_mode(adapter, 1);
1005 tdev->lldev = adapter->port[0]; 1013 tdev->lldev = adapter->port[0];
@@ -1061,10 +1069,8 @@ static int cxgb_open(struct net_device *dev)
1061 int other_ports = adapter->open_device_map & PORT_MASK; 1069 int other_ports = adapter->open_device_map & PORT_MASK;
1062 int err; 1070 int err;
1063 1071
1064 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0) { 1072 if (!adapter->open_device_map && (err = cxgb_up(adapter)) < 0)
1065 quiesce_rx(adapter);
1066 return err; 1073 return err;
1067 }
1068 1074
1069 set_bit(pi->port_id, &adapter->open_device_map); 1075 set_bit(pi->port_id, &adapter->open_device_map);
1070 if (is_offload(adapter) && !ofld_disable) { 1076 if (is_offload(adapter) && !ofld_disable) {
@@ -1894,11 +1900,11 @@ static int cxgb_extension_ioctl(struct net_device *dev, void __user *useraddr)
1894 u8 *fw_data; 1900 u8 *fw_data;
1895 struct ch_mem_range t; 1901 struct ch_mem_range t;
1896 1902
1897 if (!capable(CAP_NET_ADMIN)) 1903 if (!capable(CAP_SYS_RAWIO))
1898 return -EPERM; 1904 return -EPERM;
1899 if (copy_from_user(&t, useraddr, sizeof(t))) 1905 if (copy_from_user(&t, useraddr, sizeof(t)))
1900 return -EFAULT; 1906 return -EFAULT;
1901 1907 /* Check t.len sanity ? */
1902 fw_data = kmalloc(t.len, GFP_KERNEL); 1908 fw_data = kmalloc(t.len, GFP_KERNEL);
1903 if (!fw_data) 1909 if (!fw_data)
1904 return -ENOMEM; 1910 return -ENOMEM;
@@ -2424,14 +2430,11 @@ static pci_ers_result_t t3_io_error_detected(struct pci_dev *pdev,
2424 test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map)) 2430 test_bit(OFFLOAD_DEVMAP_BIT, &adapter->open_device_map))
2425 offload_close(&adapter->tdev); 2431 offload_close(&adapter->tdev);
2426 2432
2427 /* Free sge resources */
2428 t3_free_sge_resources(adapter);
2429
2430 adapter->flags &= ~FULL_INIT_DONE; 2433 adapter->flags &= ~FULL_INIT_DONE;
2431 2434
2432 pci_disable_device(pdev); 2435 pci_disable_device(pdev);
2433 2436
2434 /* Request a slot slot reset. */ 2437 /* Request a slot reset. */
2435 return PCI_ERS_RESULT_NEED_RESET; 2438 return PCI_ERS_RESULT_NEED_RESET;
2436} 2439}
2437 2440
@@ -2448,13 +2451,20 @@ static pci_ers_result_t t3_io_slot_reset(struct pci_dev *pdev)
2448 if (pci_enable_device(pdev)) { 2451 if (pci_enable_device(pdev)) {
2449 dev_err(&pdev->dev, 2452 dev_err(&pdev->dev,
2450 "Cannot re-enable PCI device after reset.\n"); 2453 "Cannot re-enable PCI device after reset.\n");
2451 return PCI_ERS_RESULT_DISCONNECT; 2454 goto err;
2452 } 2455 }
2453 pci_set_master(pdev); 2456 pci_set_master(pdev);
2457 pci_restore_state(pdev);
2454 2458
2455 t3_prep_adapter(adapter, adapter->params.info, 1); 2459 /* Free sge resources */
2460 t3_free_sge_resources(adapter);
2461
2462 if (t3_replay_prep_adapter(adapter))
2463 goto err;
2456 2464
2457 return PCI_ERS_RESULT_RECOVERED; 2465 return PCI_ERS_RESULT_RECOVERED;
2466err:
2467 return PCI_ERS_RESULT_DISCONNECT;
2458} 2468}
2459 2469
2460/** 2470/**
@@ -2483,13 +2493,6 @@ static void t3_io_resume(struct pci_dev *pdev)
2483 netif_device_attach(netdev); 2493 netif_device_attach(netdev);
2484 } 2494 }
2485 } 2495 }
2486
2487 if (is_offload(adapter)) {
2488 __set_bit(OFFLOAD_DEVMAP_BIT, &adapter->registered_device_map);
2489 if (offload_open(adapter->port[0]))
2490 printk(KERN_WARNING
2491 "Could not bring back offload capabilities\n");
2492 }
2493} 2496}
2494 2497
2495static struct pci_error_handlers t3_err_handler = { 2498static struct pci_error_handlers t3_err_handler = {
@@ -2608,6 +2611,7 @@ static int __devinit init_one(struct pci_dev *pdev,
2608 } 2611 }
2609 2612
2610 pci_set_master(pdev); 2613 pci_set_master(pdev);
2614 pci_save_state(pdev);
2611 2615
2612 mmio_start = pci_resource_start(pdev, 0); 2616 mmio_start = pci_resource_start(pdev, 0);
2613 mmio_len = pci_resource_len(pdev, 0); 2617 mmio_len = pci_resource_len(pdev, 0);
diff --git a/drivers/net/cxgb3/regs.h b/drivers/net/cxgb3/regs.h
index 02dbbb300929..567178879345 100644
--- a/drivers/net/cxgb3/regs.h
+++ b/drivers/net/cxgb3/regs.h
@@ -444,6 +444,14 @@
444 444
445#define A_PCIE_CFG 0x88 445#define A_PCIE_CFG 0x88
446 446
447#define S_ENABLELINKDWNDRST 21
448#define V_ENABLELINKDWNDRST(x) ((x) << S_ENABLELINKDWNDRST)
449#define F_ENABLELINKDWNDRST V_ENABLELINKDWNDRST(1U)
450
451#define S_ENABLELINKDOWNRST 20
452#define V_ENABLELINKDOWNRST(x) ((x) << S_ENABLELINKDOWNRST)
453#define F_ENABLELINKDOWNRST V_ENABLELINKDOWNRST(1U)
454
447#define S_PCIE_CLIDECEN 16 455#define S_PCIE_CLIDECEN 16
448#define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN) 456#define V_PCIE_CLIDECEN(x) ((x) << S_PCIE_CLIDECEN)
449#define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U) 457#define F_PCIE_CLIDECEN V_PCIE_CLIDECEN(1U)
diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c
index 98a6bbd11d4c..796eb305cdc3 100644
--- a/drivers/net/cxgb3/sge.c
+++ b/drivers/net/cxgb3/sge.c
@@ -539,6 +539,31 @@ static void *alloc_ring(struct pci_dev *pdev, size_t nelem, size_t elem_size,
539} 539}
540 540
541/** 541/**
542 * t3_reset_qset - reset a sge qset
543 * @q: the queue set
544 *
545 * Reset the qset structure.
546 * the NAPI structure is preserved in the event of
547 * the qset's reincarnation, for example during EEH recovery.
548 */
549static void t3_reset_qset(struct sge_qset *q)
550{
551 if (q->adap &&
552 !(q->adap->flags & NAPI_INIT)) {
553 memset(q, 0, sizeof(*q));
554 return;
555 }
556
557 q->adap = NULL;
558 memset(&q->rspq, 0, sizeof(q->rspq));
559 memset(q->fl, 0, sizeof(struct sge_fl) * SGE_RXQ_PER_SET);
560 memset(q->txq, 0, sizeof(struct sge_txq) * SGE_TXQ_PER_SET);
561 q->txq_stopped = 0;
562 memset(&q->tx_reclaim_timer, 0, sizeof(q->tx_reclaim_timer));
563}
564
565
566/**
542 * free_qset - free the resources of an SGE queue set 567 * free_qset - free the resources of an SGE queue set
543 * @adapter: the adapter owning the queue set 568 * @adapter: the adapter owning the queue set
544 * @q: the queue set 569 * @q: the queue set
@@ -594,7 +619,7 @@ static void t3_free_qset(struct adapter *adapter, struct sge_qset *q)
594 q->rspq.desc, q->rspq.phys_addr); 619 q->rspq.desc, q->rspq.phys_addr);
595 } 620 }
596 621
597 memset(q, 0, sizeof(*q)); 622 t3_reset_qset(q);
598} 623}
599 624
600/** 625/**
@@ -1365,7 +1390,7 @@ static void restart_ctrlq(unsigned long data)
1365 */ 1390 */
1366int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb) 1391int t3_mgmt_tx(struct adapter *adap, struct sk_buff *skb)
1367{ 1392{
1368 int ret; 1393 int ret;
1369 local_bh_disable(); 1394 local_bh_disable();
1370 ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb); 1395 ret = ctrl_xmit(adap, &adap->sge.qs[0].txq[TXQ_CTRL], skb);
1371 local_bh_enable(); 1396 local_bh_enable();
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c
index a99496a431c4..d405a932c73a 100644
--- a/drivers/net/cxgb3/t3_hw.c
+++ b/drivers/net/cxgb3/t3_hw.c
@@ -3264,6 +3264,7 @@ static void config_pcie(struct adapter *adap)
3264 3264
3265 t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff); 3265 t3_write_reg(adap, A_PCIE_PEX_ERR, 0xffffffff);
3266 t3_set_reg_field(adap, A_PCIE_CFG, 0, 3266 t3_set_reg_field(adap, A_PCIE_CFG, 0,
3267 F_ENABLELINKDWNDRST | F_ENABLELINKDOWNRST |
3267 F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN); 3268 F_PCIE_DMASTOPEN | F_PCIE_CLIDECEN);
3268} 3269}
3269 3270
@@ -3655,3 +3656,30 @@ void t3_led_ready(struct adapter *adapter)
3655 t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL, 3656 t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL,
3656 F_GPIO0_OUT_VAL); 3657 F_GPIO0_OUT_VAL);
3657} 3658}
3659
3660int t3_replay_prep_adapter(struct adapter *adapter)
3661{
3662 const struct adapter_info *ai = adapter->params.info;
3663 unsigned int i, j = 0;
3664 int ret;
3665
3666 early_hw_init(adapter, ai);
3667 ret = init_parity(adapter);
3668 if (ret)
3669 return ret;
3670
3671 for_each_port(adapter, i) {
3672 struct port_info *p = adap2pinfo(adapter, i);
3673 while (!adapter->params.vpd.port_type[j])
3674 ++j;
3675
3676 p->port_type->phy_prep(&p->phy, adapter, ai->phy_base_addr + j,
3677 ai->mdio_ops);
3678
3679 p->phy.ops->power_down(&p->phy, 1);
3680 ++j;
3681 }
3682
3683return 0;
3684}
3685
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 12b4626102e1..32a9a922f153 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -117,6 +117,9 @@ typedef struct board_info {
117 117
118 struct mutex addr_lock; /* phy and eeprom access lock */ 118 struct mutex addr_lock; /* phy and eeprom access lock */
119 119
120 struct delayed_work phy_poll;
121 struct net_device *ndev;
122
120 spinlock_t lock; 123 spinlock_t lock;
121 124
122 struct mii_if_info mii; 125 struct mii_if_info mii;
@@ -297,6 +300,10 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
297 } 300 }
298} 301}
299 302
303static void dm9000_schedule_poll(board_info_t *db)
304{
305 schedule_delayed_work(&db->phy_poll, HZ * 2);
306}
300 307
301/* Our watchdog timed out. Called by the networking layer */ 308/* Our watchdog timed out. Called by the networking layer */
302static void dm9000_timeout(struct net_device *dev) 309static void dm9000_timeout(struct net_device *dev)
@@ -465,6 +472,17 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
465 .set_eeprom = dm9000_set_eeprom, 472 .set_eeprom = dm9000_set_eeprom,
466}; 473};
467 474
475static void
476dm9000_poll_work(struct work_struct *w)
477{
478 struct delayed_work *dw = container_of(w, struct delayed_work, work);
479 board_info_t *db = container_of(dw, board_info_t, phy_poll);
480
481 mii_check_media(&db->mii, netif_msg_link(db), 0);
482
483 if (netif_running(db->ndev))
484 dm9000_schedule_poll(db);
485}
468 486
469/* dm9000_release_board 487/* dm9000_release_board
470 * 488 *
@@ -503,7 +521,7 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
503/* 521/*
504 * Search DM9000 board, allocate space and register it 522 * Search DM9000 board, allocate space and register it
505 */ 523 */
506static int 524static int __devinit
507dm9000_probe(struct platform_device *pdev) 525dm9000_probe(struct platform_device *pdev)
508{ 526{
509 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 527 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
@@ -525,17 +543,21 @@ dm9000_probe(struct platform_device *pdev)
525 543
526 SET_NETDEV_DEV(ndev, &pdev->dev); 544 SET_NETDEV_DEV(ndev, &pdev->dev);
527 545
528 dev_dbg(&pdev->dev, "dm9000_probe()"); 546 dev_dbg(&pdev->dev, "dm9000_probe()\n");
529 547
530 /* setup board info structure */ 548 /* setup board info structure */
531 db = (struct board_info *) ndev->priv; 549 db = (struct board_info *) ndev->priv;
532 memset(db, 0, sizeof (*db)); 550 memset(db, 0, sizeof (*db));
533 551
534 db->dev = &pdev->dev; 552 db->dev = &pdev->dev;
553 db->ndev = ndev;
535 554
536 spin_lock_init(&db->lock); 555 spin_lock_init(&db->lock);
537 mutex_init(&db->addr_lock); 556 mutex_init(&db->addr_lock);
538 557
558 INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
559
560
539 if (pdev->num_resources < 2) { 561 if (pdev->num_resources < 2) {
540 ret = -ENODEV; 562 ret = -ENODEV;
541 goto out; 563 goto out;
@@ -761,6 +783,8 @@ dm9000_open(struct net_device *dev)
761 783
762 mii_check_media(&db->mii, netif_msg_link(db), 1); 784 mii_check_media(&db->mii, netif_msg_link(db), 1);
763 netif_start_queue(dev); 785 netif_start_queue(dev);
786
787 dm9000_schedule_poll(db);
764 788
765 return 0; 789 return 0;
766} 790}
@@ -879,6 +903,8 @@ dm9000_stop(struct net_device *ndev)
879 if (netif_msg_ifdown(db)) 903 if (netif_msg_ifdown(db))
880 dev_dbg(db->dev, "shutting down %s\n", ndev->name); 904 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
881 905
906 cancel_delayed_work(&db->phy_poll);
907
882 netif_stop_queue(ndev); 908 netif_stop_queue(ndev);
883 netif_carrier_off(ndev); 909 netif_carrier_off(ndev);
884 910
@@ -1288,6 +1314,8 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1288 spin_unlock_irqrestore(&db->lock,flags); 1314 spin_unlock_irqrestore(&db->lock,flags);
1289 1315
1290 mutex_unlock(&db->addr_lock); 1316 mutex_unlock(&db->addr_lock);
1317
1318 dm9000_dbg(db, 5, "phy_read[%02x] -> %04x\n", reg, ret);
1291 return ret; 1319 return ret;
1292} 1320}
1293 1321
@@ -1301,6 +1329,7 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1301 unsigned long flags; 1329 unsigned long flags;
1302 unsigned long reg_save; 1330 unsigned long reg_save;
1303 1331
1332 dm9000_dbg(db, 5, "phy_write[%02x] = %04x\n", reg, value);
1304 mutex_lock(&db->addr_lock); 1333 mutex_lock(&db->addr_lock);
1305 1334
1306 spin_lock_irqsave(&db->lock,flags); 1335 spin_lock_irqsave(&db->lock,flags);
@@ -1372,7 +1401,7 @@ dm9000_drv_resume(struct platform_device *dev)
1372 return 0; 1401 return 0;
1373} 1402}
1374 1403
1375static int 1404static int __devexit
1376dm9000_drv_remove(struct platform_device *pdev) 1405dm9000_drv_remove(struct platform_device *pdev)
1377{ 1406{
1378 struct net_device *ndev = platform_get_drvdata(pdev); 1407 struct net_device *ndev = platform_get_drvdata(pdev);
@@ -1393,7 +1422,7 @@ static struct platform_driver dm9000_driver = {
1393 .owner = THIS_MODULE, 1422 .owner = THIS_MODULE,
1394 }, 1423 },
1395 .probe = dm9000_probe, 1424 .probe = dm9000_probe,
1396 .remove = dm9000_drv_remove, 1425 .remove = __devexit_p(dm9000_drv_remove),
1397 .suspend = dm9000_drv_suspend, 1426 .suspend = dm9000_drv_suspend,
1398 .resume = dm9000_drv_resume, 1427 .resume = dm9000_drv_resume,
1399}; 1428};
diff --git a/drivers/net/e1000e/defines.h b/drivers/net/e1000e/defines.h
index 2a53875cddbf..f823b8ba5785 100644
--- a/drivers/net/e1000e/defines.h
+++ b/drivers/net/e1000e/defines.h
@@ -648,6 +648,8 @@
648#define IFE_E_PHY_ID 0x02A80330 648#define IFE_E_PHY_ID 0x02A80330
649#define IFE_PLUS_E_PHY_ID 0x02A80320 649#define IFE_PLUS_E_PHY_ID 0x02A80320
650#define IFE_C_E_PHY_ID 0x02A80310 650#define IFE_C_E_PHY_ID 0x02A80310
651#define BME1000_E_PHY_ID 0x01410CB0
652#define BME1000_E_PHY_ID_R2 0x01410CB1
651 653
652/* M88E1000 Specific Registers */ 654/* M88E1000 Specific Registers */
653#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */ 655#define M88E1000_PHY_SPEC_CTRL 0x10 /* PHY Specific Control Register */
@@ -701,6 +703,14 @@
701#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK 0x0E00 703#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_MASK 0x0E00
702#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X 0x0800 704#define M88EC018_EPSCR_DOWNSHIFT_COUNTER_5X 0x0800
703 705
706/* BME1000 PHY Specific Control Register */
707#define BME1000_PSCR_ENABLE_DOWNSHIFT 0x0800 /* 1 = enable downshift */
708
709
710#define PHY_PAGE_SHIFT 5
711#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
712 ((reg) & MAX_PHY_REG_ADDRESS))
713
704/* 714/*
705 * Bits... 715 * Bits...
706 * 15-5: page 716 * 15-5: page
diff --git a/drivers/net/e1000e/e1000.h b/drivers/net/e1000e/e1000.h
index 38bfd0d261fe..d3bc6f8101fa 100644
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -127,7 +127,7 @@ struct e1000_buffer {
127 /* arrays of page information for packet split */ 127 /* arrays of page information for packet split */
128 struct e1000_ps_page *ps_pages; 128 struct e1000_ps_page *ps_pages;
129 }; 129 };
130 130 struct page *page;
131}; 131};
132 132
133struct e1000_ring { 133struct e1000_ring {
@@ -304,6 +304,7 @@ struct e1000_info {
304#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5) 304#define FLAG_HAS_CTRLEXT_ON_LOAD (1 << 5)
305#define FLAG_HAS_SWSM_ON_LOAD (1 << 6) 305#define FLAG_HAS_SWSM_ON_LOAD (1 << 6)
306#define FLAG_HAS_JUMBO_FRAMES (1 << 7) 306#define FLAG_HAS_JUMBO_FRAMES (1 << 7)
307#define FLAG_IS_ICH (1 << 9)
307#define FLAG_HAS_SMART_POWER_DOWN (1 << 11) 308#define FLAG_HAS_SMART_POWER_DOWN (1 << 11)
308#define FLAG_IS_QUAD_PORT_A (1 << 12) 309#define FLAG_IS_QUAD_PORT_A (1 << 12)
309#define FLAG_IS_QUAD_PORT (1 << 13) 310#define FLAG_IS_QUAD_PORT (1 << 13)
@@ -386,6 +387,7 @@ extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw,
386 bool state); 387 bool state);
387extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); 388extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw);
388extern void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); 389extern void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw);
390extern void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw);
389 391
390extern s32 e1000e_check_for_copper_link(struct e1000_hw *hw); 392extern s32 e1000e_check_for_copper_link(struct e1000_hw *hw);
391extern s32 e1000e_check_for_fiber_link(struct e1000_hw *hw); 393extern s32 e1000e_check_for_fiber_link(struct e1000_hw *hw);
@@ -443,6 +445,9 @@ extern s32 e1000e_get_phy_info_m88(struct e1000_hw *hw);
443extern s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); 445extern s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data);
444extern s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); 446extern s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data);
445extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id); 447extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id);
448extern s32 e1000e_determine_phy_address(struct e1000_hw *hw);
449extern s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data);
450extern s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data);
446extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); 451extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl);
447extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); 452extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data);
448extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); 453extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data);
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c
index ce045acce63e..a14561f40db0 100644
--- a/drivers/net/e1000e/ethtool.c
+++ b/drivers/net/e1000e/ethtool.c
@@ -494,8 +494,12 @@ static int e1000_get_eeprom(struct net_device *netdev,
494 for (i = 0; i < last_word - first_word + 1; i++) { 494 for (i = 0; i < last_word - first_word + 1; i++) {
495 ret_val = e1000_read_nvm(hw, first_word + i, 1, 495 ret_val = e1000_read_nvm(hw, first_word + i, 1,
496 &eeprom_buff[i]); 496 &eeprom_buff[i]);
497 if (ret_val) 497 if (ret_val) {
498 /* a read error occurred, throw away the
499 * result */
500 memset(eeprom_buff, 0xff, sizeof(eeprom_buff));
498 break; 501 break;
502 }
499 } 503 }
500 } 504 }
501 505
@@ -803,8 +807,7 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
803 /* restore previous status */ 807 /* restore previous status */
804 ew32(STATUS, before); 808 ew32(STATUS, before);
805 809
806 if ((mac->type != e1000_ich8lan) && 810 if (!(adapter->flags & FLAG_IS_ICH)) {
807 (mac->type != e1000_ich9lan)) {
808 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF); 811 REG_PATTERN_TEST(E1000_FCAL, 0xFFFFFFFF, 0xFFFFFFFF);
809 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF); 812 REG_PATTERN_TEST(E1000_FCAH, 0x0000FFFF, 0xFFFFFFFF);
810 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF); 813 REG_PATTERN_TEST(E1000_FCT, 0x0000FFFF, 0xFFFFFFFF);
@@ -824,15 +827,13 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)
824 827
825 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000); 828 REG_SET_AND_CHECK(E1000_RCTL, 0xFFFFFFFF, 0x00000000);
826 829
827 before = (((mac->type == e1000_ich8lan) || 830 before = ((adapter->flags & FLAG_IS_ICH) ? 0x06C3B33E : 0x06DFB3FE);
828 (mac->type == e1000_ich9lan)) ? 0x06C3B33E : 0x06DFB3FE);
829 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB); 831 REG_SET_AND_CHECK(E1000_RCTL, before, 0x003FFFFB);
830 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000); 832 REG_SET_AND_CHECK(E1000_TCTL, 0xFFFFFFFF, 0x00000000);
831 833
832 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF); 834 REG_SET_AND_CHECK(E1000_RCTL, before, 0xFFFFFFFF);
833 REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 835 REG_PATTERN_TEST(E1000_RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
834 if ((mac->type != e1000_ich8lan) && 836 if (!(adapter->flags & FLAG_IS_ICH))
835 (mac->type != e1000_ich9lan))
836 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF); 837 REG_PATTERN_TEST(E1000_TXCW, 0xC000FFFF, 0x0000FFFF);
837 REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF); 838 REG_PATTERN_TEST(E1000_TDBAL, 0xFFFFFFF0, 0xFFFFFFFF);
838 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF); 839 REG_PATTERN_TEST(E1000_TIDV, 0x0000FFFF, 0x0000FFFF);
@@ -911,9 +912,7 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)
911 912
912 /* Test each interrupt */ 913 /* Test each interrupt */
913 for (i = 0; i < 10; i++) { 914 for (i = 0; i < 10; i++) {
914 915 if ((adapter->flags & FLAG_IS_ICH) && (i == 8))
915 if (((adapter->hw.mac.type == e1000_ich8lan) ||
916 (adapter->hw.mac.type == e1000_ich9lan)) && i == 8)
917 continue; 916 continue;
918 917
919 /* Interrupt to test */ 918 /* Interrupt to test */
@@ -1184,6 +1183,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1184 struct e1000_hw *hw = &adapter->hw; 1183 struct e1000_hw *hw = &adapter->hw;
1185 u32 ctrl_reg = 0; 1184 u32 ctrl_reg = 0;
1186 u32 stat_reg = 0; 1185 u32 stat_reg = 0;
1186 u16 phy_reg = 0;
1187 1187
1188 hw->mac.autoneg = 0; 1188 hw->mac.autoneg = 0;
1189 1189
@@ -1211,6 +1211,28 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1211 E1000_CTRL_SPD_100 |/* Force Speed to 100 */ 1211 E1000_CTRL_SPD_100 |/* Force Speed to 100 */
1212 E1000_CTRL_FD); /* Force Duplex to FULL */ 1212 E1000_CTRL_FD); /* Force Duplex to FULL */
1213 break; 1213 break;
1214 case e1000_phy_bm:
1215 /* Set Default MAC Interface speed to 1GB */
1216 e1e_rphy(hw, PHY_REG(2, 21), &phy_reg);
1217 phy_reg &= ~0x0007;
1218 phy_reg |= 0x006;
1219 e1e_wphy(hw, PHY_REG(2, 21), phy_reg);
1220 /* Assert SW reset for above settings to take effect */
1221 e1000e_commit_phy(hw);
1222 mdelay(1);
1223 /* Force Full Duplex */
1224 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1225 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x000C);
1226 /* Set Link Up (in force link) */
1227 e1e_rphy(hw, PHY_REG(776, 16), &phy_reg);
1228 e1e_wphy(hw, PHY_REG(776, 16), phy_reg | 0x0040);
1229 /* Force Link */
1230 e1e_rphy(hw, PHY_REG(769, 16), &phy_reg);
1231 e1e_wphy(hw, PHY_REG(769, 16), phy_reg | 0x0040);
1232 /* Set Early Link Enable */
1233 e1e_rphy(hw, PHY_REG(769, 20), &phy_reg);
1234 e1e_wphy(hw, PHY_REG(769, 20), phy_reg | 0x0400);
1235 /* fall through */
1214 default: 1236 default:
1215 /* force 1000, set loopback */ 1237 /* force 1000, set loopback */
1216 e1e_wphy(hw, PHY_CONTROL, 0x4140); 1238 e1e_wphy(hw, PHY_CONTROL, 0x4140);
@@ -1224,8 +1246,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)
1224 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ 1246 E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */
1225 E1000_CTRL_FD); /* Force Duplex to FULL */ 1247 E1000_CTRL_FD); /* Force Duplex to FULL */
1226 1248
1227 if ((adapter->hw.mac.type == e1000_ich8lan) || 1249 if (adapter->flags & FLAG_IS_ICH)
1228 (adapter->hw.mac.type == e1000_ich9lan))
1229 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */ 1250 ctrl_reg |= E1000_CTRL_SLU; /* Set Link Up */
1230 } 1251 }
1231 1252
diff --git a/drivers/net/e1000e/hw.h b/drivers/net/e1000e/hw.h
index a930e6d9cf02..74f263acb172 100644
--- a/drivers/net/e1000e/hw.h
+++ b/drivers/net/e1000e/hw.h
@@ -216,6 +216,21 @@ enum e1e_registers {
216#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */ 216#define IGP01E1000_PHY_LINK_HEALTH 0x13 /* PHY Link Health */
217#define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */ 217#define IGP02E1000_PHY_POWER_MGMT 0x19 /* Power Management */
218#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */ 218#define IGP01E1000_PHY_PAGE_SELECT 0x1F /* Page Select */
219#define BM_PHY_PAGE_SELECT 22 /* Page Select for BM */
220#define IGP_PAGE_SHIFT 5
221#define PHY_REG_MASK 0x1F
222
223#define BM_WUC_PAGE 800
224#define BM_WUC_ADDRESS_OPCODE 0x11
225#define BM_WUC_DATA_OPCODE 0x12
226#define BM_WUC_ENABLE_PAGE 769
227#define BM_WUC_ENABLE_REG 17
228#define BM_WUC_ENABLE_BIT (1 << 2)
229#define BM_WUC_HOST_WU_BIT (1 << 4)
230
231#define BM_WUC PHY_REG(BM_WUC_PAGE, 1)
232#define BM_WUFC PHY_REG(BM_WUC_PAGE, 2)
233#define BM_WUS PHY_REG(BM_WUC_PAGE, 3)
219 234
220#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4 235#define IGP01E1000_PHY_PCS_INIT_REG 0x00B4
221#define IGP01E1000_PHY_POLARITY_MASK 0x0078 236#define IGP01E1000_PHY_POLARITY_MASK 0x0078
@@ -331,10 +346,16 @@ enum e1e_registers {
331#define E1000_DEV_ID_ICH8_IFE_G 0x10C5 346#define E1000_DEV_ID_ICH8_IFE_G 0x10C5
332#define E1000_DEV_ID_ICH8_IGP_M 0x104D 347#define E1000_DEV_ID_ICH8_IGP_M 0x104D
333#define E1000_DEV_ID_ICH9_IGP_AMT 0x10BD 348#define E1000_DEV_ID_ICH9_IGP_AMT 0x10BD
349#define E1000_DEV_ID_ICH9_IGP_M_AMT 0x10F5
350#define E1000_DEV_ID_ICH9_IGP_M 0x10BF
351#define E1000_DEV_ID_ICH9_IGP_M_V 0x10CB
334#define E1000_DEV_ID_ICH9_IGP_C 0x294C 352#define E1000_DEV_ID_ICH9_IGP_C 0x294C
335#define E1000_DEV_ID_ICH9_IFE 0x10C0 353#define E1000_DEV_ID_ICH9_IFE 0x10C0
336#define E1000_DEV_ID_ICH9_IFE_GT 0x10C3 354#define E1000_DEV_ID_ICH9_IFE_GT 0x10C3
337#define E1000_DEV_ID_ICH9_IFE_G 0x10C2 355#define E1000_DEV_ID_ICH9_IFE_G 0x10C2
356#define E1000_DEV_ID_ICH10_R_BM_LM 0x10CC
357#define E1000_DEV_ID_ICH10_R_BM_LF 0x10CD
358#define E1000_DEV_ID_ICH10_R_BM_V 0x10CE
338 359
339#define E1000_FUNC_1 1 360#define E1000_FUNC_1 1
340 361
@@ -378,6 +399,7 @@ enum e1000_phy_type {
378 e1000_phy_gg82563, 399 e1000_phy_gg82563,
379 e1000_phy_igp_3, 400 e1000_phy_igp_3,
380 e1000_phy_ife, 401 e1000_phy_ife,
402 e1000_phy_bm,
381}; 403};
382 404
383enum e1000_bus_width { 405enum e1000_bus_width {
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 768485dbb2c6..9e38452a738c 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -38,6 +38,12 @@
38 * 82566DM Gigabit Network Connection 38 * 82566DM Gigabit Network Connection
39 * 82566MC Gigabit Network Connection 39 * 82566MC Gigabit Network Connection
40 * 82566MM Gigabit Network Connection 40 * 82566MM Gigabit Network Connection
41 * 82567LM Gigabit Network Connection
42 * 82567LF Gigabit Network Connection
43 * 82567LM-2 Gigabit Network Connection
44 * 82567LF-2 Gigabit Network Connection
45 * 82567V-2 Gigabit Network Connection
46 * 82562GT-3 10/100 Network Connection
41 */ 47 */
42 48
43#include <linux/netdevice.h> 49#include <linux/netdevice.h>
@@ -198,6 +204,19 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
198 phy->addr = 1; 204 phy->addr = 1;
199 phy->reset_delay_us = 100; 205 phy->reset_delay_us = 100;
200 206
207 /*
208 * We may need to do this twice - once for IGP and if that fails,
209 * we'll set BM func pointers and try again
210 */
211 ret_val = e1000e_determine_phy_address(hw);
212 if (ret_val) {
213 hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm;
214 hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm;
215 ret_val = e1000e_determine_phy_address(hw);
216 if (ret_val)
217 return ret_val;
218 }
219
201 phy->id = 0; 220 phy->id = 0;
202 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) && 221 while ((e1000_phy_unknown == e1000e_get_phy_type_from_id(phy->id)) &&
203 (i++ < 100)) { 222 (i++ < 100)) {
@@ -219,6 +238,13 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
219 phy->type = e1000_phy_ife; 238 phy->type = e1000_phy_ife;
220 phy->autoneg_mask = E1000_ALL_NOT_GIG; 239 phy->autoneg_mask = E1000_ALL_NOT_GIG;
221 break; 240 break;
241 case BME1000_E_PHY_ID:
242 phy->type = e1000_phy_bm;
243 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
244 hw->phy.ops.read_phy_reg = e1000e_read_phy_reg_bm;
245 hw->phy.ops.write_phy_reg = e1000e_write_phy_reg_bm;
246 hw->phy.ops.commit_phy = e1000e_phy_sw_reset;
247 break;
222 default: 248 default:
223 return -E1000_ERR_PHY; 249 return -E1000_ERR_PHY;
224 break; 250 break;
@@ -664,6 +690,7 @@ static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw)
664 return e1000_get_phy_info_ife_ich8lan(hw); 690 return e1000_get_phy_info_ife_ich8lan(hw);
665 break; 691 break;
666 case e1000_phy_igp_3: 692 case e1000_phy_igp_3:
693 case e1000_phy_bm:
667 return e1000e_get_phy_info_igp(hw); 694 return e1000e_get_phy_info_igp(hw);
668 break; 695 break;
669 default: 696 default:
@@ -728,7 +755,7 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)
728 s32 ret_val = 0; 755 s32 ret_val = 0;
729 u16 data; 756 u16 data;
730 757
731 if (phy->type != e1000_phy_igp_3) 758 if (phy->type == e1000_phy_ife)
732 return ret_val; 759 return ret_val;
733 760
734 phy_ctrl = er32(PHY_CTRL); 761 phy_ctrl = er32(PHY_CTRL);
@@ -1918,8 +1945,35 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
1918 ret_val = e1000e_copper_link_setup_igp(hw); 1945 ret_val = e1000e_copper_link_setup_igp(hw);
1919 if (ret_val) 1946 if (ret_val)
1920 return ret_val; 1947 return ret_val;
1948 } else if (hw->phy.type == e1000_phy_bm) {
1949 ret_val = e1000e_copper_link_setup_m88(hw);
1950 if (ret_val)
1951 return ret_val;
1921 } 1952 }
1922 1953
1954 if (hw->phy.type == e1000_phy_ife) {
1955 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data);
1956 if (ret_val)
1957 return ret_val;
1958
1959 reg_data &= ~IFE_PMC_AUTO_MDIX;
1960
1961 switch (hw->phy.mdix) {
1962 case 1:
1963 reg_data &= ~IFE_PMC_FORCE_MDIX;
1964 break;
1965 case 2:
1966 reg_data |= IFE_PMC_FORCE_MDIX;
1967 break;
1968 case 0:
1969 default:
1970 reg_data |= IFE_PMC_AUTO_MDIX;
1971 break;
1972 }
1973 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data);
1974 if (ret_val)
1975 return ret_val;
1976 }
1923 return e1000e_setup_copper_link(hw); 1977 return e1000e_setup_copper_link(hw);
1924} 1978}
1925 1979
@@ -2127,6 +2181,31 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
2127} 2181}
2128 2182
2129/** 2183/**
2184 * e1000e_disable_gig_wol_ich8lan - disable gig during WoL
2185 * @hw: pointer to the HW structure
2186 *
2187 * During S0 to Sx transition, it is possible the link remains at gig
2188 * instead of negotiating to a lower speed. Before going to Sx, set
2189 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
2190 * to a lower speed.
2191 *
2192 * Should only be called for ICH9 devices.
2193 **/
2194void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
2195{
2196 u32 phy_ctrl;
2197
2198 if (hw->mac.type == e1000_ich9lan) {
2199 phy_ctrl = er32(PHY_CTRL);
2200 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU |
2201 E1000_PHY_CTRL_GBE_DISABLE;
2202 ew32(PHY_CTRL, phy_ctrl);
2203 }
2204
2205 return;
2206}
2207
2208/**
2130 * e1000_cleanup_led_ich8lan - Restore the default LED operation 2209 * e1000_cleanup_led_ich8lan - Restore the default LED operation
2131 * @hw: pointer to the HW structure 2210 * @hw: pointer to the HW structure
2132 * 2211 *
@@ -2247,6 +2326,7 @@ static struct e1000_nvm_operations ich8_nvm_ops = {
2247struct e1000_info e1000_ich8_info = { 2326struct e1000_info e1000_ich8_info = {
2248 .mac = e1000_ich8lan, 2327 .mac = e1000_ich8lan,
2249 .flags = FLAG_HAS_WOL 2328 .flags = FLAG_HAS_WOL
2329 | FLAG_IS_ICH
2250 | FLAG_RX_CSUM_ENABLED 2330 | FLAG_RX_CSUM_ENABLED
2251 | FLAG_HAS_CTRLEXT_ON_LOAD 2331 | FLAG_HAS_CTRLEXT_ON_LOAD
2252 | FLAG_HAS_AMT 2332 | FLAG_HAS_AMT
@@ -2262,6 +2342,7 @@ struct e1000_info e1000_ich8_info = {
2262struct e1000_info e1000_ich9_info = { 2342struct e1000_info e1000_ich9_info = {
2263 .mac = e1000_ich9lan, 2343 .mac = e1000_ich9lan,
2264 .flags = FLAG_HAS_JUMBO_FRAMES 2344 .flags = FLAG_HAS_JUMBO_FRAMES
2345 | FLAG_IS_ICH
2265 | FLAG_HAS_WOL 2346 | FLAG_HAS_WOL
2266 | FLAG_RX_CSUM_ENABLED 2347 | FLAG_RX_CSUM_ENABLED
2267 | FLAG_HAS_CTRLEXT_ON_LOAD 2348 | FLAG_HAS_CTRLEXT_ON_LOAD
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 8991ab8911e2..8cbb40f3a506 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -43,10 +43,11 @@
43#include <linux/if_vlan.h> 43#include <linux/if_vlan.h>
44#include <linux/cpu.h> 44#include <linux/cpu.h>
45#include <linux/smp.h> 45#include <linux/smp.h>
46#include <linux/pm_qos_params.h>
46 47
47#include "e1000.h" 48#include "e1000.h"
48 49
49#define DRV_VERSION "0.2.1" 50#define DRV_VERSION "0.3.3.3-k2"
50char e1000e_driver_name[] = "e1000e"; 51char e1000e_driver_name[] = "e1000e";
51const char e1000e_driver_version[] = DRV_VERSION; 52const char e1000e_driver_version[] = DRV_VERSION;
52 53
@@ -341,6 +342,89 @@ no_buffers:
341} 342}
342 343
343/** 344/**
345 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
346 * @adapter: address of board private structure
347 * @rx_ring: pointer to receive ring structure
348 * @cleaned_count: number of buffers to allocate this pass
349 **/
350
351static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter,
352 int cleaned_count)
353{
354 struct net_device *netdev = adapter->netdev;
355 struct pci_dev *pdev = adapter->pdev;
356 struct e1000_rx_desc *rx_desc;
357 struct e1000_ring *rx_ring = adapter->rx_ring;
358 struct e1000_buffer *buffer_info;
359 struct sk_buff *skb;
360 unsigned int i;
361 unsigned int bufsz = 256 -
362 16 /* for skb_reserve */ -
363 NET_IP_ALIGN;
364
365 i = rx_ring->next_to_use;
366 buffer_info = &rx_ring->buffer_info[i];
367
368 while (cleaned_count--) {
369 skb = buffer_info->skb;
370 if (skb) {
371 skb_trim(skb, 0);
372 goto check_page;
373 }
374
375 skb = netdev_alloc_skb(netdev, bufsz);
376 if (unlikely(!skb)) {
377 /* Better luck next round */
378 adapter->alloc_rx_buff_failed++;
379 break;
380 }
381
382 /* Make buffer alignment 2 beyond a 16 byte boundary
383 * this will result in a 16 byte aligned IP header after
384 * the 14 byte MAC header is removed
385 */
386 skb_reserve(skb, NET_IP_ALIGN);
387
388 buffer_info->skb = skb;
389check_page:
390 /* allocate a new page if necessary */
391 if (!buffer_info->page) {
392 buffer_info->page = alloc_page(GFP_ATOMIC);
393 if (unlikely(!buffer_info->page)) {
394 adapter->alloc_rx_buff_failed++;
395 break;
396 }
397 }
398
399 if (!buffer_info->dma)
400 buffer_info->dma = pci_map_page(pdev,
401 buffer_info->page, 0,
402 PAGE_SIZE,
403 PCI_DMA_FROMDEVICE);
404
405 rx_desc = E1000_RX_DESC(*rx_ring, i);
406 rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma);
407
408 if (unlikely(++i == rx_ring->count))
409 i = 0;
410 buffer_info = &rx_ring->buffer_info[i];
411 }
412
413 if (likely(rx_ring->next_to_use != i)) {
414 rx_ring->next_to_use = i;
415 if (unlikely(i-- == 0))
416 i = (rx_ring->count - 1);
417
418 /* Force memory writes to complete before letting h/w
419 * know there are new descriptors to fetch. (Only
420 * applicable for weak-ordered memory model archs,
421 * such as IA-64). */
422 wmb();
423 writel(i, adapter->hw.hw_addr + rx_ring->tail);
424 }
425}
426
427/**
344 * e1000_clean_rx_irq - Send received data up the network stack; legacy 428 * e1000_clean_rx_irq - Send received data up the network stack; legacy
345 * @adapter: board private structure 429 * @adapter: board private structure
346 * 430 *
@@ -783,6 +867,186 @@ next_desc:
783} 867}
784 868
785/** 869/**
870 * e1000_consume_page - helper function
871 **/
872static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
873 u16 length)
874{
875 bi->page = NULL;
876 skb->len += length;
877 skb->data_len += length;
878 skb->truesize += length;
879}
880
881/**
882 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
883 * @adapter: board private structure
884 *
885 * the return value indicates whether actual cleaning was done, there
886 * is no guarantee that everything was cleaned
887 **/
888
889static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,
890 int *work_done, int work_to_do)
891{
892 struct net_device *netdev = adapter->netdev;
893 struct pci_dev *pdev = adapter->pdev;
894 struct e1000_ring *rx_ring = adapter->rx_ring;
895 struct e1000_rx_desc *rx_desc, *next_rxd;
896 struct e1000_buffer *buffer_info, *next_buffer;
897 u32 length;
898 unsigned int i;
899 int cleaned_count = 0;
900 bool cleaned = false;
901 unsigned int total_rx_bytes=0, total_rx_packets=0;
902
903 i = rx_ring->next_to_clean;
904 rx_desc = E1000_RX_DESC(*rx_ring, i);
905 buffer_info = &rx_ring->buffer_info[i];
906
907 while (rx_desc->status & E1000_RXD_STAT_DD) {
908 struct sk_buff *skb;
909 u8 status;
910
911 if (*work_done >= work_to_do)
912 break;
913 (*work_done)++;
914
915 status = rx_desc->status;
916 skb = buffer_info->skb;
917 buffer_info->skb = NULL;
918
919 ++i;
920 if (i == rx_ring->count)
921 i = 0;
922 next_rxd = E1000_RX_DESC(*rx_ring, i);
923 prefetch(next_rxd);
924
925 next_buffer = &rx_ring->buffer_info[i];
926
927 cleaned = true;
928 cleaned_count++;
929 pci_unmap_page(pdev, buffer_info->dma, PAGE_SIZE,
930 PCI_DMA_FROMDEVICE);
931 buffer_info->dma = 0;
932
933 length = le16_to_cpu(rx_desc->length);
934
935 /* errors is only valid for DD + EOP descriptors */
936 if (unlikely((status & E1000_RXD_STAT_EOP) &&
937 (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) {
938 /* recycle both page and skb */
939 buffer_info->skb = skb;
940 /* an error means any chain goes out the window
941 * too */
942 if (rx_ring->rx_skb_top)
943 dev_kfree_skb(rx_ring->rx_skb_top);
944 rx_ring->rx_skb_top = NULL;
945 goto next_desc;
946 }
947
948#define rxtop rx_ring->rx_skb_top
949 if (!(status & E1000_RXD_STAT_EOP)) {
950 /* this descriptor is only the beginning (or middle) */
951 if (!rxtop) {
952 /* this is the beginning of a chain */
953 rxtop = skb;
954 skb_fill_page_desc(rxtop, 0, buffer_info->page,
955 0, length);
956 } else {
957 /* this is the middle of a chain */
958 skb_fill_page_desc(rxtop,
959 skb_shinfo(rxtop)->nr_frags,
960 buffer_info->page, 0, length);
961 /* re-use the skb, only consumed the page */
962 buffer_info->skb = skb;
963 }
964 e1000_consume_page(buffer_info, rxtop, length);
965 goto next_desc;
966 } else {
967 if (rxtop) {
968 /* end of the chain */
969 skb_fill_page_desc(rxtop,
970 skb_shinfo(rxtop)->nr_frags,
971 buffer_info->page, 0, length);
972 /* re-use the current skb, we only consumed the
973 * page */
974 buffer_info->skb = skb;
975 skb = rxtop;
976 rxtop = NULL;
977 e1000_consume_page(buffer_info, skb, length);
978 } else {
979 /* no chain, got EOP, this buf is the packet
980 * copybreak to save the put_page/alloc_page */
981 if (length <= copybreak &&
982 skb_tailroom(skb) >= length) {
983 u8 *vaddr;
984 vaddr = kmap_atomic(buffer_info->page,
985 KM_SKB_DATA_SOFTIRQ);
986 memcpy(skb_tail_pointer(skb), vaddr,
987 length);
988 kunmap_atomic(vaddr,
989 KM_SKB_DATA_SOFTIRQ);
990 /* re-use the page, so don't erase
991 * buffer_info->page */
992 skb_put(skb, length);
993 } else {
994 skb_fill_page_desc(skb, 0,
995 buffer_info->page, 0,
996 length);
997 e1000_consume_page(buffer_info, skb,
998 length);
999 }
1000 }
1001 }
1002
1003 /* Receive Checksum Offload XXX recompute due to CRC strip? */
1004 e1000_rx_checksum(adapter,
1005 (u32)(status) |
1006 ((u32)(rx_desc->errors) << 24),
1007 le16_to_cpu(rx_desc->csum), skb);
1008
1009 /* probably a little skewed due to removing CRC */
1010 total_rx_bytes += skb->len;
1011 total_rx_packets++;
1012
1013 /* eth type trans needs skb->data to point to something */
1014 if (!pskb_may_pull(skb, ETH_HLEN)) {
1015 ndev_err(netdev, "pskb_may_pull failed.\n");
1016 dev_kfree_skb(skb);
1017 goto next_desc;
1018 }
1019
1020 e1000_receive_skb(adapter, netdev, skb, status,
1021 rx_desc->special);
1022
1023next_desc:
1024 rx_desc->status = 0;
1025
1026 /* return some buffers to hardware, one at a time is too slow */
1027 if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) {
1028 adapter->alloc_rx_buf(adapter, cleaned_count);
1029 cleaned_count = 0;
1030 }
1031
1032 /* use prefetched values */
1033 rx_desc = next_rxd;
1034 buffer_info = next_buffer;
1035 }
1036 rx_ring->next_to_clean = i;
1037
1038 cleaned_count = e1000_desc_unused(rx_ring);
1039 if (cleaned_count)
1040 adapter->alloc_rx_buf(adapter, cleaned_count);
1041
1042 adapter->total_rx_bytes += total_rx_bytes;
1043 adapter->total_rx_packets += total_rx_packets;
1044 adapter->net_stats.rx_bytes += total_rx_bytes;
1045 adapter->net_stats.rx_packets += total_rx_packets;
1046 return cleaned;
1047}
1048
1049/**
786 * e1000_clean_rx_ring - Free Rx Buffers per Queue 1050 * e1000_clean_rx_ring - Free Rx Buffers per Queue
787 * @adapter: board private structure 1051 * @adapter: board private structure
788 **/ 1052 **/
@@ -802,6 +1066,10 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
802 pci_unmap_single(pdev, buffer_info->dma, 1066 pci_unmap_single(pdev, buffer_info->dma,
803 adapter->rx_buffer_len, 1067 adapter->rx_buffer_len,
804 PCI_DMA_FROMDEVICE); 1068 PCI_DMA_FROMDEVICE);
1069 else if (adapter->clean_rx == e1000_clean_jumbo_rx_irq)
1070 pci_unmap_page(pdev, buffer_info->dma,
1071 PAGE_SIZE,
1072 PCI_DMA_FROMDEVICE);
805 else if (adapter->clean_rx == e1000_clean_rx_irq_ps) 1073 else if (adapter->clean_rx == e1000_clean_rx_irq_ps)
806 pci_unmap_single(pdev, buffer_info->dma, 1074 pci_unmap_single(pdev, buffer_info->dma,
807 adapter->rx_ps_bsize0, 1075 adapter->rx_ps_bsize0,
@@ -809,6 +1077,11 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter)
809 buffer_info->dma = 0; 1077 buffer_info->dma = 0;
810 } 1078 }
811 1079
1080 if (buffer_info->page) {
1081 put_page(buffer_info->page);
1082 buffer_info->page = NULL;
1083 }
1084
812 if (buffer_info->skb) { 1085 if (buffer_info->skb) {
813 dev_kfree_skb(buffer_info->skb); 1086 dev_kfree_skb(buffer_info->skb);
814 buffer_info->skb = NULL; 1087 buffer_info->skb = NULL;
@@ -1755,10 +2028,12 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
1755 * a lot of memory, since we allocate 3 pages at all times 2028 * a lot of memory, since we allocate 3 pages at all times
1756 * per packet. 2029 * per packet.
1757 */ 2030 */
1758 adapter->rx_ps_pages = 0;
1759 pages = PAGE_USE_COUNT(adapter->netdev->mtu); 2031 pages = PAGE_USE_COUNT(adapter->netdev->mtu);
1760 if ((pages <= 3) && (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE)) 2032 if (!(adapter->flags & FLAG_IS_ICH) && (pages <= 3) &&
2033 (PAGE_SIZE <= 16384) && (rctl & E1000_RCTL_LPE))
1761 adapter->rx_ps_pages = pages; 2034 adapter->rx_ps_pages = pages;
2035 else
2036 adapter->rx_ps_pages = 0;
1762 2037
1763 if (adapter->rx_ps_pages) { 2038 if (adapter->rx_ps_pages) {
1764 /* Configure extra packet-split registers */ 2039 /* Configure extra packet-split registers */
@@ -1819,9 +2094,12 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
1819 sizeof(union e1000_rx_desc_packet_split); 2094 sizeof(union e1000_rx_desc_packet_split);
1820 adapter->clean_rx = e1000_clean_rx_irq_ps; 2095 adapter->clean_rx = e1000_clean_rx_irq_ps;
1821 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps; 2096 adapter->alloc_rx_buf = e1000_alloc_rx_buffers_ps;
2097 } else if (adapter->netdev->mtu > ETH_FRAME_LEN + ETH_FCS_LEN) {
2098 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
2099 adapter->clean_rx = e1000_clean_jumbo_rx_irq;
2100 adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers;
1822 } else { 2101 } else {
1823 rdlen = rx_ring->count * 2102 rdlen = rx_ring->count * sizeof(struct e1000_rx_desc);
1824 sizeof(struct e1000_rx_desc);
1825 adapter->clean_rx = e1000_clean_rx_irq; 2103 adapter->clean_rx = e1000_clean_rx_irq;
1826 adapter->alloc_rx_buf = e1000_alloc_rx_buffers; 2104 adapter->alloc_rx_buf = e1000_alloc_rx_buffers;
1827 } 2105 }
@@ -1885,8 +2163,21 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)
1885 * units), e.g. using jumbo frames when setting to E1000_ERT_2048 2163 * units), e.g. using jumbo frames when setting to E1000_ERT_2048
1886 */ 2164 */
1887 if ((adapter->flags & FLAG_HAS_ERT) && 2165 if ((adapter->flags & FLAG_HAS_ERT) &&
1888 (adapter->netdev->mtu > ETH_DATA_LEN)) 2166 (adapter->netdev->mtu > ETH_DATA_LEN)) {
1889 ew32(ERT, E1000_ERT_2048); 2167 u32 rxdctl = er32(RXDCTL(0));
2168 ew32(RXDCTL(0), rxdctl | 0x3);
2169 ew32(ERT, E1000_ERT_2048 | (1 << 13));
2170 /*
2171 * With jumbo frames and early-receive enabled, excessive
2172 * C4->C2 latencies result in dropped transactions.
2173 */
2174 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2175 e1000e_driver_name, 55);
2176 } else {
2177 pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY,
2178 e1000e_driver_name,
2179 PM_QOS_DEFAULT_VALUE);
2180 }
1890 2181
1891 /* Enable Receives */ 2182 /* Enable Receives */
1892 ew32(RCTL, rctl); 2183 ew32(RCTL, rctl);
@@ -2155,6 +2446,14 @@ void e1000e_reset(struct e1000_adapter *adapter)
2155 2446
2156 /* Allow time for pending master requests to run */ 2447 /* Allow time for pending master requests to run */
2157 mac->ops.reset_hw(hw); 2448 mac->ops.reset_hw(hw);
2449
2450 /*
2451 * For parts with AMT enabled, let the firmware know
2452 * that the network interface is in control
2453 */
2454 if ((adapter->flags & FLAG_HAS_AMT) && e1000e_check_mng_mode(hw))
2455 e1000_get_hw_control(adapter);
2456
2158 ew32(WUC, 0); 2457 ew32(WUC, 0);
2159 2458
2160 if (mac->ops.init_hw(hw)) 2459 if (mac->ops.init_hw(hw))
@@ -3469,6 +3768,8 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)
3469 * means we reserve 2 more, this pushes us to allocate from the next 3768 * means we reserve 2 more, this pushes us to allocate from the next
3470 * larger slab size. 3769 * larger slab size.
3471 * i.e. RXBUFFER_2048 --> size-4096 slab 3770 * i.e. RXBUFFER_2048 --> size-4096 slab
3771 * However with the new *_jumbo_rx* routines, jumbo receives will use
3772 * fragmented skbs
3472 */ 3773 */
3473 3774
3474 if (max_frame <= 256) 3775 if (max_frame <= 256)
@@ -3626,6 +3927,9 @@ static int e1000_suspend(struct pci_dev *pdev, pm_message_t state)
3626 ew32(CTRL_EXT, ctrl_ext); 3927 ew32(CTRL_EXT, ctrl_ext);
3627 } 3928 }
3628 3929
3930 if (adapter->flags & FLAG_IS_ICH)
3931 e1000e_disable_gig_wol_ich8lan(&adapter->hw);
3932
3629 /* Allow time for pending master requests to run */ 3933 /* Allow time for pending master requests to run */
3630 e1000e_disable_pcie_master(&adapter->hw); 3934 e1000e_disable_pcie_master(&adapter->hw);
3631 3935
@@ -4292,6 +4596,13 @@ static struct pci_device_id e1000_pci_tbl[] = {
4292 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan }, 4596 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IFE_GT), board_ich9lan },
4293 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan }, 4597 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_AMT), board_ich9lan },
4294 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan }, 4598 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_C), board_ich9lan },
4599 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M), board_ich9lan },
4600 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_AMT), board_ich9lan },
4601 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH9_IGP_M_V), board_ich9lan },
4602
4603 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LM), board_ich9lan },
4604 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_LF), board_ich9lan },
4605 { PCI_VDEVICE(INTEL, E1000_DEV_ID_ICH10_R_BM_V), board_ich9lan },
4295 4606
4296 { } /* terminate list */ 4607 { } /* terminate list */
4297}; 4608};
@@ -4326,7 +4637,9 @@ static int __init e1000_init_module(void)
4326 printk(KERN_INFO "%s: Copyright (c) 1999-2008 Intel Corporation.\n", 4637 printk(KERN_INFO "%s: Copyright (c) 1999-2008 Intel Corporation.\n",
4327 e1000e_driver_name); 4638 e1000e_driver_name);
4328 ret = pci_register_driver(&e1000_driver); 4639 ret = pci_register_driver(&e1000_driver);
4329 4640 pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name,
4641 PM_QOS_DEFAULT_VALUE);
4642
4330 return ret; 4643 return ret;
4331} 4644}
4332module_init(e1000_init_module); 4645module_init(e1000_init_module);
@@ -4340,6 +4653,7 @@ module_init(e1000_init_module);
4340static void __exit e1000_exit_module(void) 4653static void __exit e1000_exit_module(void)
4341{ 4654{
4342 pci_unregister_driver(&e1000_driver); 4655 pci_unregister_driver(&e1000_driver);
4656 pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, e1000e_driver_name);
4343} 4657}
4344module_exit(e1000_exit_module); 4658module_exit(e1000_exit_module);
4345 4659
diff --git a/drivers/net/e1000e/phy.c b/drivers/net/e1000e/phy.c
index e102332a6bee..b133dcf0e950 100644
--- a/drivers/net/e1000e/phy.c
+++ b/drivers/net/e1000e/phy.c
@@ -34,6 +34,9 @@ static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw);
34static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw); 34static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw);
35static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active); 35static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);
36static s32 e1000_wait_autoneg(struct e1000_hw *hw); 36static s32 e1000_wait_autoneg(struct e1000_hw *hw);
37static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg);
38static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
39 u16 *data, bool read);
37 40
38/* Cable length tables */ 41/* Cable length tables */
39static const u16 e1000_m88_cable_length_table[] = 42static const u16 e1000_m88_cable_length_table[] =
@@ -465,6 +468,10 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)
465 if (phy->disable_polarity_correction == 1) 468 if (phy->disable_polarity_correction == 1)
466 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL; 469 phy_data |= M88E1000_PSCR_POLARITY_REVERSAL;
467 470
471 /* Enable downshift on BM (disabled by default) */
472 if (phy->type == e1000_phy_bm)
473 phy_data |= BME1000_PSCR_ENABLE_DOWNSHIFT;
474
468 ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data); 475 ret_val = e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, phy_data);
469 if (ret_val) 476 if (ret_val)
470 return ret_val; 477 return ret_val;
@@ -1776,6 +1783,10 @@ enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id)
1776 case IFE_C_E_PHY_ID: 1783 case IFE_C_E_PHY_ID:
1777 phy_type = e1000_phy_ife; 1784 phy_type = e1000_phy_ife;
1778 break; 1785 break;
1786 case BME1000_E_PHY_ID:
1787 case BME1000_E_PHY_ID_R2:
1788 phy_type = e1000_phy_bm;
1789 break;
1779 default: 1790 default:
1780 phy_type = e1000_phy_unknown; 1791 phy_type = e1000_phy_unknown;
1781 break; 1792 break;
@@ -1784,6 +1795,273 @@ enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id)
1784} 1795}
1785 1796
1786/** 1797/**
1798 * e1000e_determine_phy_address - Determines PHY address.
1799 * @hw: pointer to the HW structure
1800 *
1801 * This uses a trial and error method to loop through possible PHY
1802 * addresses. It tests each by reading the PHY ID registers and
1803 * checking for a match.
1804 **/
1805s32 e1000e_determine_phy_address(struct e1000_hw *hw)
1806{
1807 s32 ret_val = -E1000_ERR_PHY_TYPE;
1808 u32 phy_addr= 0;
1809 u32 i = 0;
1810 enum e1000_phy_type phy_type = e1000_phy_unknown;
1811
1812 do {
1813 for (phy_addr = 0; phy_addr < 4; phy_addr++) {
1814 hw->phy.addr = phy_addr;
1815 e1000e_get_phy_id(hw);
1816 phy_type = e1000e_get_phy_type_from_id(hw->phy.id);
1817
1818 /*
1819 * If phy_type is valid, break - we found our
1820 * PHY address
1821 */
1822 if (phy_type != e1000_phy_unknown) {
1823 ret_val = 0;
1824 break;
1825 }
1826 }
1827 i++;
1828 } while ((ret_val != 0) && (i < 100));
1829
1830 return ret_val;
1831}
1832
1833/**
1834 * e1000_get_phy_addr_for_bm_page - Retrieve PHY page address
1835 * @page: page to access
1836 *
1837 * Returns the phy address for the page requested.
1838 **/
1839static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg)
1840{
1841 u32 phy_addr = 2;
1842
1843 if ((page >= 768) || (page == 0 && reg == 25) || (reg == 31))
1844 phy_addr = 1;
1845
1846 return phy_addr;
1847}
1848
1849/**
1850 * e1000e_write_phy_reg_bm - Write BM PHY register
1851 * @hw: pointer to the HW structure
1852 * @offset: register offset to write to
1853 * @data: data to write at register offset
1854 *
1855 * Acquires semaphore, if necessary, then writes the data to PHY register
1856 * at the offset. Release any acquired semaphores before exiting.
1857 **/
1858s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data)
1859{
1860 s32 ret_val;
1861 u32 page_select = 0;
1862 u32 page = offset >> IGP_PAGE_SHIFT;
1863 u32 page_shift = 0;
1864
1865 /* Page 800 works differently than the rest so it has its own func */
1866 if (page == BM_WUC_PAGE) {
1867 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, &data,
1868 false);
1869 goto out;
1870 }
1871
1872 ret_val = hw->phy.ops.acquire_phy(hw);
1873 if (ret_val)
1874 goto out;
1875
1876 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
1877
1878 if (offset > MAX_PHY_MULTI_PAGE_REG) {
1879 /*
1880 * Page select is register 31 for phy address 1 and 22 for
1881 * phy address 2 and 3. Page select is shifted only for
1882 * phy address 1.
1883 */
1884 if (hw->phy.addr == 1) {
1885 page_shift = IGP_PAGE_SHIFT;
1886 page_select = IGP01E1000_PHY_PAGE_SELECT;
1887 } else {
1888 page_shift = 0;
1889 page_select = BM_PHY_PAGE_SELECT;
1890 }
1891
1892 /* Page is shifted left, PHY expects (page x 32) */
1893 ret_val = e1000e_write_phy_reg_mdic(hw, page_select,
1894 (page << page_shift));
1895 if (ret_val) {
1896 hw->phy.ops.release_phy(hw);
1897 goto out;
1898 }
1899 }
1900
1901 ret_val = e1000e_write_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
1902 data);
1903
1904 hw->phy.ops.release_phy(hw);
1905
1906out:
1907 return ret_val;
1908}
1909
1910/**
1911 * e1000e_read_phy_reg_bm - Read BM PHY register
1912 * @hw: pointer to the HW structure
1913 * @offset: register offset to be read
1914 * @data: pointer to the read data
1915 *
1916 * Acquires semaphore, if necessary, then reads the PHY register at offset
1917 * and storing the retrieved information in data. Release any acquired
1918 * semaphores before exiting.
1919 **/
1920s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data)
1921{
1922 s32 ret_val;
1923 u32 page_select = 0;
1924 u32 page = offset >> IGP_PAGE_SHIFT;
1925 u32 page_shift = 0;
1926
1927 /* Page 800 works differently than the rest so it has its own func */
1928 if (page == BM_WUC_PAGE) {
1929 ret_val = e1000_access_phy_wakeup_reg_bm(hw, offset, data,
1930 true);
1931 goto out;
1932 }
1933
1934 ret_val = hw->phy.ops.acquire_phy(hw);
1935 if (ret_val)
1936 goto out;
1937
1938 hw->phy.addr = e1000_get_phy_addr_for_bm_page(page, offset);
1939
1940 if (offset > MAX_PHY_MULTI_PAGE_REG) {
1941 /*
1942 * Page select is register 31 for phy address 1 and 22 for
1943 * phy address 2 and 3. Page select is shifted only for
1944 * phy address 1.
1945 */
1946 if (hw->phy.addr == 1) {
1947 page_shift = IGP_PAGE_SHIFT;
1948 page_select = IGP01E1000_PHY_PAGE_SELECT;
1949 } else {
1950 page_shift = 0;
1951 page_select = BM_PHY_PAGE_SELECT;
1952 }
1953
1954 /* Page is shifted left, PHY expects (page x 32) */
1955 ret_val = e1000e_write_phy_reg_mdic(hw, page_select,
1956 (page << page_shift));
1957 if (ret_val) {
1958 hw->phy.ops.release_phy(hw);
1959 goto out;
1960 }
1961 }
1962
1963 ret_val = e1000e_read_phy_reg_mdic(hw, MAX_PHY_REG_ADDRESS & offset,
1964 data);
1965 hw->phy.ops.release_phy(hw);
1966
1967out:
1968 return ret_val;
1969}
1970
1971/**
1972 * e1000_access_phy_wakeup_reg_bm - Read BM PHY wakeup register
1973 * @hw: pointer to the HW structure
1974 * @offset: register offset to be read or written
1975 * @data: pointer to the data to read or write
1976 * @read: determines if operation is read or write
1977 *
1978 * Acquires semaphore, if necessary, then reads the PHY register at offset
1979 * and storing the retrieved information in data. Release any acquired
1980 * semaphores before exiting. Note that procedure to read the wakeup
1981 * registers are different. It works as such:
1982 * 1) Set page 769, register 17, bit 2 = 1
1983 * 2) Set page to 800 for host (801 if we were manageability)
1984 * 3) Write the address using the address opcode (0x11)
1985 * 4) Read or write the data using the data opcode (0x12)
1986 * 5) Restore 769_17.2 to its original value
1987 **/
1988static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,
1989 u16 *data, bool read)
1990{
1991 s32 ret_val;
1992 u16 reg = ((u16)offset) & PHY_REG_MASK;
1993 u16 phy_reg = 0;
1994 u8 phy_acquired = 1;
1995
1996
1997 ret_val = hw->phy.ops.acquire_phy(hw);
1998 if (ret_val) {
1999 phy_acquired = 0;
2000 goto out;
2001 }
2002
2003 /* All operations in this function are phy address 1 */
2004 hw->phy.addr = 1;
2005
2006 /* Set page 769 */
2007 e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2008 (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
2009
2010 ret_val = e1000e_read_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, &phy_reg);
2011 if (ret_val)
2012 goto out;
2013
2014 /* First clear bit 4 to avoid a power state change */
2015 phy_reg &= ~(BM_WUC_HOST_WU_BIT);
2016 ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
2017 if (ret_val)
2018 goto out;
2019
2020 /* Write bit 2 = 1, and clear bit 4 to 769_17 */
2021 ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG,
2022 phy_reg | BM_WUC_ENABLE_BIT);
2023 if (ret_val)
2024 goto out;
2025
2026 /* Select page 800 */
2027 ret_val = e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2028 (BM_WUC_PAGE << IGP_PAGE_SHIFT));
2029
2030 /* Write the page 800 offset value using opcode 0x11 */
2031 ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ADDRESS_OPCODE, reg);
2032 if (ret_val)
2033 goto out;
2034
2035 if (read) {
2036 /* Read the page 800 value using opcode 0x12 */
2037 ret_val = e1000e_read_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE,
2038 data);
2039 } else {
2040 /* Read the page 800 value using opcode 0x12 */
2041 ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_DATA_OPCODE,
2042 *data);
2043 }
2044
2045 if (ret_val)
2046 goto out;
2047
2048 /*
2049 * Restore 769_17.2 to its original value
2050 * Set page 769
2051 */
2052 e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT,
2053 (BM_WUC_ENABLE_PAGE << IGP_PAGE_SHIFT));
2054
2055 /* Clear 769_17.2 */
2056 ret_val = e1000e_write_phy_reg_mdic(hw, BM_WUC_ENABLE_REG, phy_reg);
2057
2058out:
2059 if (phy_acquired == 1)
2060 hw->phy.ops.release_phy(hw);
2061 return ret_val;
2062}
2063
2064/**
1787 * e1000e_commit_phy - Soft PHY reset 2065 * e1000e_commit_phy - Soft PHY reset
1788 * @hw: pointer to the HW structure 2066 * @hw: pointer to the HW structure
1789 * 2067 *
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 2eb82aba4a8b..795c594a4b7c 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -202,7 +202,7 @@ static unsigned short start_code[] = {
202 0x0000,Cmd_MCast, 202 0x0000,Cmd_MCast,
203 0x0076, /* link to next command */ 203 0x0076, /* link to next command */
204#define CONF_NR_MULTICAST 0x44 204#define CONF_NR_MULTICAST 0x44
205 0x0000, /* number of multicast addresses */ 205 0x0000, /* number of bytes in multicast address(es) */
206#define CONF_MULTICAST 0x46 206#define CONF_MULTICAST 0x46
207 0x0000, 0x0000, 0x0000, /* some addresses */ 207 0x0000, 0x0000, 0x0000, /* some addresses */
208 0x0000, 0x0000, 0x0000, 208 0x0000, 0x0000, 0x0000,
@@ -1569,7 +1569,7 @@ static void eexp_hw_init586(struct net_device *dev)
1569 1569
1570static void eexp_setup_filter(struct net_device *dev) 1570static void eexp_setup_filter(struct net_device *dev)
1571{ 1571{
1572 struct dev_mc_list *dmi = dev->mc_list; 1572 struct dev_mc_list *dmi;
1573 unsigned short ioaddr = dev->base_addr; 1573 unsigned short ioaddr = dev->base_addr;
1574 int count = dev->mc_count; 1574 int count = dev->mc_count;
1575 int i; 1575 int i;
@@ -1580,9 +1580,9 @@ static void eexp_setup_filter(struct net_device *dev)
1580 } 1580 }
1581 1581
1582 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR); 1582 outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
1583 outw(count, ioaddr+SHADOW(CONF_NR_MULTICAST)); 1583 outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST));
1584 for (i = 0; i < count; i++) { 1584 for (i = 0, dmi = dev->mc_list; i < count; i++, dmi = dmi->next) {
1585 unsigned short *data = (unsigned short *)dmi->dmi_addr; 1585 unsigned short *data;
1586 if (!dmi) { 1586 if (!dmi) {
1587 printk(KERN_INFO "%s: too few multicast addresses\n", dev->name); 1587 printk(KERN_INFO "%s: too few multicast addresses\n", dev->name);
1588 break; 1588 break;
@@ -1591,6 +1591,7 @@ static void eexp_setup_filter(struct net_device *dev)
1591 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name); 1591 printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
1592 continue; 1592 continue;
1593 } 1593 }
1594 data = (unsigned short *)dmi->dmi_addr;
1594 outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR); 1595 outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR);
1595 outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i))); 1596 outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i)));
1596 outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR); 1597 outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR);
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index f5dacceab95b..fe872fbd671e 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0090" 43#define DRV_VERSION "EHEA_0091"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
@@ -118,6 +118,13 @@
118#define EHEA_MR_ACC_CTRL 0x00800000 118#define EHEA_MR_ACC_CTRL 0x00800000
119 119
120#define EHEA_BUSMAP_START 0x8000000000000000ULL 120#define EHEA_BUSMAP_START 0x8000000000000000ULL
121#define EHEA_INVAL_ADDR 0xFFFFFFFFFFFFFFFFULL
122#define EHEA_DIR_INDEX_SHIFT 13 /* 8k Entries in 64k block */
123#define EHEA_TOP_INDEX_SHIFT (EHEA_DIR_INDEX_SHIFT * 2)
124#define EHEA_MAP_ENTRIES (1 << EHEA_DIR_INDEX_SHIFT)
125#define EHEA_MAP_SIZE (0x10000) /* currently fixed map size */
126#define EHEA_INDEX_MASK (EHEA_MAP_ENTRIES - 1)
127
121 128
122#define EHEA_WATCH_DOG_TIMEOUT 10*HZ 129#define EHEA_WATCH_DOG_TIMEOUT 10*HZ
123 130
@@ -192,10 +199,20 @@ struct h_epas {
192 set to 0 if unused */ 199 set to 0 if unused */
193}; 200};
194 201
195struct ehea_busmap { 202/*
196 unsigned int entries; /* total number of entries */ 203 * Memory map data structures
197 unsigned int valid_sections; /* number of valid sections */ 204 */
198 u64 *vaddr; 205struct ehea_dir_bmap
206{
207 u64 ent[EHEA_MAP_ENTRIES];
208};
209struct ehea_top_bmap
210{
211 struct ehea_dir_bmap *dir[EHEA_MAP_ENTRIES];
212};
213struct ehea_bmap
214{
215 struct ehea_top_bmap *top[EHEA_MAP_ENTRIES];
199}; 216};
200 217
201struct ehea_qp; 218struct ehea_qp;
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index f9bc21c74b59..d1b6d4e7495d 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -35,6 +35,7 @@
35#include <linux/if_ether.h> 35#include <linux/if_ether.h>
36#include <linux/notifier.h> 36#include <linux/notifier.h>
37#include <linux/reboot.h> 37#include <linux/reboot.h>
38#include <linux/memory.h>
38#include <asm/kexec.h> 39#include <asm/kexec.h>
39#include <linux/mutex.h> 40#include <linux/mutex.h>
40 41
@@ -3503,6 +3504,24 @@ void ehea_crash_handler(void)
3503 0, H_DEREG_BCMC); 3504 0, H_DEREG_BCMC);
3504} 3505}
3505 3506
3507static int ehea_mem_notifier(struct notifier_block *nb,
3508 unsigned long action, void *data)
3509{
3510 switch (action) {
3511 case MEM_OFFLINE:
3512 ehea_info("memory has been removed");
3513 ehea_rereg_mrs(NULL);
3514 break;
3515 default:
3516 break;
3517 }
3518 return NOTIFY_OK;
3519}
3520
3521static struct notifier_block ehea_mem_nb = {
3522 .notifier_call = ehea_mem_notifier,
3523};
3524
3506static int ehea_reboot_notifier(struct notifier_block *nb, 3525static int ehea_reboot_notifier(struct notifier_block *nb,
3507 unsigned long action, void *unused) 3526 unsigned long action, void *unused)
3508{ 3527{
@@ -3581,6 +3600,10 @@ int __init ehea_module_init(void)
3581 if (ret) 3600 if (ret)
3582 ehea_info("failed registering reboot notifier"); 3601 ehea_info("failed registering reboot notifier");
3583 3602
3603 ret = register_memory_notifier(&ehea_mem_nb);
3604 if (ret)
3605 ehea_info("failed registering memory remove notifier");
3606
3584 ret = crash_shutdown_register(&ehea_crash_handler); 3607 ret = crash_shutdown_register(&ehea_crash_handler);
3585 if (ret) 3608 if (ret)
3586 ehea_info("failed registering crash handler"); 3609 ehea_info("failed registering crash handler");
@@ -3604,6 +3627,7 @@ int __init ehea_module_init(void)
3604out3: 3627out3:
3605 ibmebus_unregister_driver(&ehea_driver); 3628 ibmebus_unregister_driver(&ehea_driver);
3606out2: 3629out2:
3630 unregister_memory_notifier(&ehea_mem_nb);
3607 unregister_reboot_notifier(&ehea_reboot_nb); 3631 unregister_reboot_notifier(&ehea_reboot_nb);
3608 crash_shutdown_unregister(&ehea_crash_handler); 3632 crash_shutdown_unregister(&ehea_crash_handler);
3609out: 3633out:
@@ -3621,6 +3645,7 @@ static void __exit ehea_module_exit(void)
3621 ret = crash_shutdown_unregister(&ehea_crash_handler); 3645 ret = crash_shutdown_unregister(&ehea_crash_handler);
3622 if (ret) 3646 if (ret)
3623 ehea_info("failed unregistering crash handler"); 3647 ehea_info("failed unregistering crash handler");
3648 unregister_memory_notifier(&ehea_mem_nb);
3624 kfree(ehea_fw_handles.arr); 3649 kfree(ehea_fw_handles.arr);
3625 kfree(ehea_bcmc_regs.arr); 3650 kfree(ehea_bcmc_regs.arr);
3626 ehea_destroy_busmap(); 3651 ehea_destroy_busmap();
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c
index d522e905f460..140f05baafd8 100644
--- a/drivers/net/ehea/ehea_qmr.c
+++ b/drivers/net/ehea/ehea_qmr.c
@@ -31,8 +31,8 @@
31#include "ehea_phyp.h" 31#include "ehea_phyp.h"
32#include "ehea_qmr.h" 32#include "ehea_qmr.h"
33 33
34struct ehea_bmap *ehea_bmap = NULL;
34 35
35struct ehea_busmap ehea_bmap = { 0, 0, NULL };
36 36
37 37
38static void *hw_qpageit_get_inc(struct hw_queue *queue) 38static void *hw_qpageit_get_inc(struct hw_queue *queue)
@@ -559,125 +559,253 @@ int ehea_destroy_qp(struct ehea_qp *qp)
559 return 0; 559 return 0;
560} 560}
561 561
562int ehea_create_busmap(void) 562static inline int ehea_calc_index(unsigned long i, unsigned long s)
563{ 563{
564 u64 vaddr = EHEA_BUSMAP_START; 564 return (i >> s) & EHEA_INDEX_MASK;
565 unsigned long high_section_index = 0; 565}
566 int i;
567 566
568 /* 567static inline int ehea_init_top_bmap(struct ehea_top_bmap *ehea_top_bmap,
569 * Sections are not in ascending order -> Loop over all sections and 568 int dir)
570 * find the highest PFN to compute the required map size. 569{
571 */ 570 if(!ehea_top_bmap->dir[dir]) {
572 ehea_bmap.valid_sections = 0; 571 ehea_top_bmap->dir[dir] =
572 kzalloc(sizeof(struct ehea_dir_bmap), GFP_KERNEL);
573 if (!ehea_top_bmap->dir[dir])
574 return -ENOMEM;
575 }
576 return 0;
577}
573 578
574 for (i = 0; i < NR_MEM_SECTIONS; i++) 579static inline int ehea_init_bmap(struct ehea_bmap *ehea_bmap, int top, int dir)
575 if (valid_section_nr(i)) 580{
576 high_section_index = i; 581 if(!ehea_bmap->top[top]) {
582 ehea_bmap->top[top] =
583 kzalloc(sizeof(struct ehea_top_bmap), GFP_KERNEL);
584 if (!ehea_bmap->top[top])
585 return -ENOMEM;
586 }
587 return ehea_init_top_bmap(ehea_bmap->top[top], dir);
588}
577 589
578 ehea_bmap.entries = high_section_index + 1; 590static int ehea_create_busmap_callback(unsigned long pfn,
579 ehea_bmap.vaddr = vmalloc(ehea_bmap.entries * sizeof(*ehea_bmap.vaddr)); 591 unsigned long nr_pages, void *arg)
592{
593 unsigned long i, mr_len, start_section, end_section;
594 start_section = (pfn * PAGE_SIZE) / EHEA_SECTSIZE;
595 end_section = start_section + ((nr_pages * PAGE_SIZE) / EHEA_SECTSIZE);
596 mr_len = *(unsigned long *)arg;
580 597
581 if (!ehea_bmap.vaddr) 598 ehea_bmap = kzalloc(sizeof(struct ehea_bmap), GFP_KERNEL);
599 if (!ehea_bmap)
582 return -ENOMEM; 600 return -ENOMEM;
583 601
584 for (i = 0 ; i < ehea_bmap.entries; i++) { 602 for (i = start_section; i < end_section; i++) {
585 unsigned long pfn = section_nr_to_pfn(i); 603 int ret;
604 int top, dir, idx;
605 u64 vaddr;
606
607 top = ehea_calc_index(i, EHEA_TOP_INDEX_SHIFT);
608 dir = ehea_calc_index(i, EHEA_DIR_INDEX_SHIFT);
609
610 ret = ehea_init_bmap(ehea_bmap, top, dir);
611 if(ret)
612 return ret;
586 613
587 if (pfn_valid(pfn)) { 614 idx = i & EHEA_INDEX_MASK;
588 ehea_bmap.vaddr[i] = vaddr; 615 vaddr = EHEA_BUSMAP_START + mr_len + i * EHEA_SECTSIZE;
589 vaddr += EHEA_SECTSIZE; 616
590 ehea_bmap.valid_sections++; 617 ehea_bmap->top[top]->dir[dir]->ent[idx] = vaddr;
591 } else
592 ehea_bmap.vaddr[i] = 0;
593 } 618 }
594 619
620 mr_len += nr_pages * PAGE_SIZE;
621 *(unsigned long *)arg = mr_len;
622
595 return 0; 623 return 0;
596} 624}
597 625
626static unsigned long ehea_mr_len;
627
628static DEFINE_MUTEX(ehea_busmap_mutex);
629
630int ehea_create_busmap(void)
631{
632 int ret;
633 mutex_lock(&ehea_busmap_mutex);
634 ehea_mr_len = 0;
635 ret = walk_memory_resource(0, 1ULL << MAX_PHYSMEM_BITS, &ehea_mr_len,
636 ehea_create_busmap_callback);
637 mutex_unlock(&ehea_busmap_mutex);
638 return ret;
639}
640
598void ehea_destroy_busmap(void) 641void ehea_destroy_busmap(void)
599{ 642{
600 vfree(ehea_bmap.vaddr); 643 int top, dir;
644 mutex_lock(&ehea_busmap_mutex);
645 if (!ehea_bmap)
646 goto out_destroy;
647
648 for (top = 0; top < EHEA_MAP_ENTRIES; top++) {
649 if (!ehea_bmap->top[top])
650 continue;
651
652 for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) {
653 if (!ehea_bmap->top[top]->dir[dir])
654 continue;
655
656 kfree(ehea_bmap->top[top]->dir[dir]);
657 }
658
659 kfree(ehea_bmap->top[top]);
660 }
661
662 kfree(ehea_bmap);
663 ehea_bmap = NULL;
664out_destroy:
665 mutex_unlock(&ehea_busmap_mutex);
601} 666}
602 667
603u64 ehea_map_vaddr(void *caddr) 668u64 ehea_map_vaddr(void *caddr)
604{ 669{
605 u64 mapped_addr; 670 int top, dir, idx;
606 unsigned long index = __pa(caddr) >> SECTION_SIZE_BITS; 671 unsigned long index, offset;
607 672
608 if (likely(index < ehea_bmap.entries)) { 673 if (!ehea_bmap)
609 mapped_addr = ehea_bmap.vaddr[index]; 674 return EHEA_INVAL_ADDR;
610 if (likely(mapped_addr)) 675
611 mapped_addr |= (((unsigned long)caddr) 676 index = virt_to_abs(caddr) >> SECTION_SIZE_BITS;
612 & (EHEA_SECTSIZE - 1)); 677 top = (index >> EHEA_TOP_INDEX_SHIFT) & EHEA_INDEX_MASK;
613 else 678 if (!ehea_bmap->top[top])
614 mapped_addr = -1; 679 return EHEA_INVAL_ADDR;
615 } else 680
616 mapped_addr = -1; 681 dir = (index >> EHEA_DIR_INDEX_SHIFT) & EHEA_INDEX_MASK;
617 682 if (!ehea_bmap->top[top]->dir[dir])
618 if (unlikely(mapped_addr == -1)) 683 return EHEA_INVAL_ADDR;
619 if (!test_and_set_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) 684
620 schedule_work(&ehea_rereg_mr_task); 685 idx = index & EHEA_INDEX_MASK;
621 686 if (!ehea_bmap->top[top]->dir[dir]->ent[idx])
622 return mapped_addr; 687 return EHEA_INVAL_ADDR;
688
689 offset = (unsigned long)caddr & (EHEA_SECTSIZE - 1);
690 return ehea_bmap->top[top]->dir[dir]->ent[idx] | offset;
691}
692
693static inline void *ehea_calc_sectbase(int top, int dir, int idx)
694{
695 unsigned long ret = idx;
696 ret |= dir << EHEA_DIR_INDEX_SHIFT;
697 ret |= top << EHEA_TOP_INDEX_SHIFT;
698 return abs_to_virt(ret << SECTION_SIZE_BITS);
699}
700
701static u64 ehea_reg_mr_section(int top, int dir, int idx, u64 *pt,
702 struct ehea_adapter *adapter,
703 struct ehea_mr *mr)
704{
705 void *pg;
706 u64 j, m, hret;
707 unsigned long k = 0;
708 u64 pt_abs = virt_to_abs(pt);
709
710 void *sectbase = ehea_calc_sectbase(top, dir, idx);
711
712 for (j = 0; j < (EHEA_PAGES_PER_SECTION / EHEA_MAX_RPAGE); j++) {
713
714 for (m = 0; m < EHEA_MAX_RPAGE; m++) {
715 pg = sectbase + ((k++) * EHEA_PAGESIZE);
716 pt[m] = virt_to_abs(pg);
717 }
718 hret = ehea_h_register_rpage_mr(adapter->handle, mr->handle, 0,
719 0, pt_abs, EHEA_MAX_RPAGE);
720
721 if ((hret != H_SUCCESS)
722 && (hret != H_PAGE_REGISTERED)) {
723 ehea_h_free_resource(adapter->handle, mr->handle,
724 FORCE_FREE);
725 ehea_error("register_rpage_mr failed");
726 return hret;
727 }
728 }
729 return hret;
730}
731
732static u64 ehea_reg_mr_sections(int top, int dir, u64 *pt,
733 struct ehea_adapter *adapter,
734 struct ehea_mr *mr)
735{
736 u64 hret = H_SUCCESS;
737 int idx;
738
739 for (idx = 0; idx < EHEA_MAP_ENTRIES; idx++) {
740 if (!ehea_bmap->top[top]->dir[dir]->ent[idx])
741 continue;
742
743 hret = ehea_reg_mr_section(top, dir, idx, pt, adapter, mr);
744 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
745 return hret;
746 }
747 return hret;
748}
749
750static u64 ehea_reg_mr_dir_sections(int top, u64 *pt,
751 struct ehea_adapter *adapter,
752 struct ehea_mr *mr)
753{
754 u64 hret = H_SUCCESS;
755 int dir;
756
757 for (dir = 0; dir < EHEA_MAP_ENTRIES; dir++) {
758 if (!ehea_bmap->top[top]->dir[dir])
759 continue;
760
761 hret = ehea_reg_mr_sections(top, dir, pt, adapter, mr);
762 if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED))
763 return hret;
764 }
765 return hret;
623} 766}
624 767
625int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) 768int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr)
626{ 769{
627 int ret; 770 int ret;
628 u64 *pt; 771 u64 *pt;
629 void *pg; 772 u64 hret;
630 u64 hret, pt_abs, i, j, m, mr_len;
631 u32 acc_ctrl = EHEA_MR_ACC_CTRL; 773 u32 acc_ctrl = EHEA_MR_ACC_CTRL;
632 774
633 mr_len = ehea_bmap.valid_sections * EHEA_SECTSIZE; 775 unsigned long top;
634 776
635 pt = kzalloc(PAGE_SIZE, GFP_KERNEL); 777 pt = kzalloc(PAGE_SIZE, GFP_KERNEL);
636 if (!pt) { 778 if (!pt) {
637 ehea_error("no mem"); 779 ehea_error("no mem");
638 ret = -ENOMEM; 780 ret = -ENOMEM;
639 goto out; 781 goto out;
640 } 782 }
641 pt_abs = virt_to_abs(pt);
642 783
643 hret = ehea_h_alloc_resource_mr(adapter->handle, 784 hret = ehea_h_alloc_resource_mr(adapter->handle, EHEA_BUSMAP_START,
644 EHEA_BUSMAP_START, mr_len, 785 ehea_mr_len, acc_ctrl, adapter->pd,
645 acc_ctrl, adapter->pd,
646 &mr->handle, &mr->lkey); 786 &mr->handle, &mr->lkey);
787
647 if (hret != H_SUCCESS) { 788 if (hret != H_SUCCESS) {
648 ehea_error("alloc_resource_mr failed"); 789 ehea_error("alloc_resource_mr failed");
649 ret = -EIO; 790 ret = -EIO;
650 goto out; 791 goto out;
651 } 792 }
652 793
653 for (i = 0 ; i < ehea_bmap.entries; i++) 794 if (!ehea_bmap) {
654 if (ehea_bmap.vaddr[i]) { 795 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE);
655 void *sectbase = __va(i << SECTION_SIZE_BITS); 796 ehea_error("no busmap available");
656 unsigned long k = 0; 797 ret = -EIO;
657 798 goto out;
658 for (j = 0; j < (EHEA_PAGES_PER_SECTION / 799 }
659 EHEA_MAX_RPAGE); j++) { 800
660 801 for (top = 0; top < EHEA_MAP_ENTRIES; top++) {
661 for (m = 0; m < EHEA_MAX_RPAGE; m++) { 802 if (!ehea_bmap->top[top])
662 pg = sectbase + ((k++) * EHEA_PAGESIZE); 803 continue;
663 pt[m] = virt_to_abs(pg); 804
664 } 805 hret = ehea_reg_mr_dir_sections(top, pt, adapter, mr);
665 806 if((hret != H_PAGE_REGISTERED) && (hret != H_SUCCESS))
666 hret = ehea_h_register_rpage_mr(adapter->handle, 807 break;
667 mr->handle, 808 }
668 0, 0, pt_abs,
669 EHEA_MAX_RPAGE);
670 if ((hret != H_SUCCESS)
671 && (hret != H_PAGE_REGISTERED)) {
672 ehea_h_free_resource(adapter->handle,
673 mr->handle,
674 FORCE_FREE);
675 ehea_error("register_rpage_mr failed");
676 ret = -EIO;
677 goto out;
678 }
679 }
680 }
681 809
682 if (hret != H_SUCCESS) { 810 if (hret != H_SUCCESS) {
683 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); 811 ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE);
diff --git a/drivers/net/fs_enet/mii-fec.c b/drivers/net/fs_enet/mii-fec.c
index ba75efc9f5b5..f0014cfbb275 100644
--- a/drivers/net/fs_enet/mii-fec.c
+++ b/drivers/net/fs_enet/mii-fec.c
@@ -194,7 +194,7 @@ static int __devinit fs_enet_mdio_probe(struct of_device *ofdev,
194 194
195 ret = of_address_to_resource(ofdev->node, 0, &res); 195 ret = of_address_to_resource(ofdev->node, 0, &res);
196 if (ret) 196 if (ret)
197 return ret; 197 goto out_res;
198 198
199 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start); 199 snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);
200 200
@@ -236,6 +236,7 @@ out_free_irqs:
236 kfree(new_bus->irq); 236 kfree(new_bus->irq);
237out_unmap_regs: 237out_unmap_regs:
238 iounmap(fec->fecp); 238 iounmap(fec->fecp);
239out_res:
239out_fec: 240out_fec:
240 kfree(fec); 241 kfree(fec);
241out_mii: 242out_mii:
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 642dc633b444..393a0f175302 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -138,6 +138,7 @@ static int gfar_poll(struct napi_struct *napi, int budget);
138static void gfar_netpoll(struct net_device *dev); 138static void gfar_netpoll(struct net_device *dev);
139#endif 139#endif
140int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit); 140int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit);
141static int gfar_clean_tx_ring(struct net_device *dev);
141static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length); 142static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int length);
142static void gfar_vlan_rx_register(struct net_device *netdev, 143static void gfar_vlan_rx_register(struct net_device *netdev,
143 struct vlan_group *grp); 144 struct vlan_group *grp);
@@ -634,6 +635,8 @@ static void free_skb_resources(struct gfar_private *priv)
634 dev_kfree_skb_any(priv->tx_skbuff[i]); 635 dev_kfree_skb_any(priv->tx_skbuff[i]);
635 priv->tx_skbuff[i] = NULL; 636 priv->tx_skbuff[i] = NULL;
636 } 637 }
638
639 txbdp++;
637 } 640 }
638 641
639 kfree(priv->tx_skbuff); 642 kfree(priv->tx_skbuff);
@@ -1141,7 +1144,7 @@ static int gfar_close(struct net_device *dev)
1141} 1144}
1142 1145
1143/* Changes the mac address if the controller is not running. */ 1146/* Changes the mac address if the controller is not running. */
1144int gfar_set_mac_address(struct net_device *dev) 1147static int gfar_set_mac_address(struct net_device *dev)
1145{ 1148{
1146 gfar_set_mac_for_addr(dev, 0, dev->dev_addr); 1149 gfar_set_mac_for_addr(dev, 0, dev->dev_addr);
1147 1150
@@ -1260,7 +1263,7 @@ static void gfar_timeout(struct net_device *dev)
1260} 1263}
1261 1264
1262/* Interrupt Handler for Transmit complete */ 1265/* Interrupt Handler for Transmit complete */
1263int gfar_clean_tx_ring(struct net_device *dev) 1266static int gfar_clean_tx_ring(struct net_device *dev)
1264{ 1267{
1265 struct txbd8 *bdp; 1268 struct txbd8 *bdp;
1266 struct gfar_private *priv = netdev_priv(dev); 1269 struct gfar_private *priv = netdev_priv(dev);
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index fd487be3993e..27f37c81e52c 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -782,5 +782,8 @@ extern void gfar_halt(struct net_device *dev);
782extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, 782extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
783 int enable, u32 regnum, u32 read); 783 int enable, u32 regnum, u32 read);
784void gfar_init_sysfs(struct net_device *dev); 784void gfar_init_sysfs(struct net_device *dev);
785int gfar_local_mdio_write(struct gfar_mii __iomem *regs, int mii_id,
786 int regnum, u16 value);
787int gfar_local_mdio_read(struct gfar_mii __iomem *regs, int mii_id, int regnum);
785 788
786#endif /* __GIANFAR_H */ 789#endif /* __GIANFAR_H */
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
index 230878b94190..5116f68e01b9 100644
--- a/drivers/net/gianfar_sysfs.c
+++ b/drivers/net/gianfar_sysfs.c
@@ -103,10 +103,10 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
103 103
104 spin_lock_irqsave(&priv->rxlock, flags); 104 spin_lock_irqsave(&priv->rxlock, flags);
105 if (length > priv->rx_buffer_size) 105 if (length > priv->rx_buffer_size)
106 return count; 106 goto out;
107 107
108 if (length == priv->rx_stash_size) 108 if (length == priv->rx_stash_size)
109 return count; 109 goto out;
110 110
111 priv->rx_stash_size = length; 111 priv->rx_stash_size = length;
112 112
@@ -125,6 +125,7 @@ static ssize_t gfar_set_rx_stash_size(struct device *dev,
125 125
126 gfar_write(&priv->regs->attr, temp); 126 gfar_write(&priv->regs->attr, temp);
127 127
128out:
128 spin_unlock_irqrestore(&priv->rxlock, flags); 129 spin_unlock_irqrestore(&priv->rxlock, flags);
129 130
130 return count; 131 return count;
@@ -154,10 +155,10 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
154 155
155 spin_lock_irqsave(&priv->rxlock, flags); 156 spin_lock_irqsave(&priv->rxlock, flags);
156 if (index > priv->rx_stash_size) 157 if (index > priv->rx_stash_size)
157 return count; 158 goto out;
158 159
159 if (index == priv->rx_stash_index) 160 if (index == priv->rx_stash_index)
160 return count; 161 goto out;
161 162
162 priv->rx_stash_index = index; 163 priv->rx_stash_index = index;
163 164
@@ -166,6 +167,7 @@ static ssize_t gfar_set_rx_stash_index(struct device *dev,
166 temp |= ATTRELI_EI(index); 167 temp |= ATTRELI_EI(index);
167 gfar_write(&priv->regs->attreli, flags); 168 gfar_write(&priv->regs->attreli, flags);
168 169
170out:
169 spin_unlock_irqrestore(&priv->rxlock, flags); 171 spin_unlock_irqrestore(&priv->rxlock, flags);
170 172
171 return count; 173 return count;
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index a873d2b315ca..a7714da7c283 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -100,7 +100,9 @@ static int nsc_ircc_probe_39x(nsc_chip_t *chip, chipio_t *info);
100static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info); 100static int nsc_ircc_init_108(nsc_chip_t *chip, chipio_t *info);
101static int nsc_ircc_init_338(nsc_chip_t *chip, chipio_t *info); 101static int nsc_ircc_init_338(nsc_chip_t *chip, chipio_t *info);
102static int nsc_ircc_init_39x(nsc_chip_t *chip, chipio_t *info); 102static int nsc_ircc_init_39x(nsc_chip_t *chip, chipio_t *info);
103#ifdef CONFIG_PNP
103static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id); 104static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id);
105#endif
104 106
105/* These are the known NSC chips */ 107/* These are the known NSC chips */
106static nsc_chip_t chips[] = { 108static nsc_chip_t chips[] = {
@@ -156,9 +158,11 @@ static const struct pnp_device_id nsc_ircc_pnp_table[] = {
156MODULE_DEVICE_TABLE(pnp, nsc_ircc_pnp_table); 158MODULE_DEVICE_TABLE(pnp, nsc_ircc_pnp_table);
157 159
158static struct pnp_driver nsc_ircc_pnp_driver = { 160static struct pnp_driver nsc_ircc_pnp_driver = {
161#ifdef CONFIG_PNP
159 .name = "nsc-ircc", 162 .name = "nsc-ircc",
160 .id_table = nsc_ircc_pnp_table, 163 .id_table = nsc_ircc_pnp_table,
161 .probe = nsc_ircc_pnp_probe, 164 .probe = nsc_ircc_pnp_probe,
165#endif
162}; 166};
163 167
164/* Some prototypes */ 168/* Some prototypes */
@@ -916,6 +920,7 @@ static int nsc_ircc_probe_39x(nsc_chip_t *chip, chipio_t *info)
916 return 0; 920 return 0;
917} 921}
918 922
923#ifdef CONFIG_PNP
919/* PNP probing */ 924/* PNP probing */
920static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id) 925static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id)
921{ 926{
@@ -952,6 +957,7 @@ static int nsc_ircc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *i
952 957
953 return 0; 958 return 0;
954} 959}
960#endif
955 961
956/* 962/*
957 * Function nsc_ircc_setup (info) 963 * Function nsc_ircc_setup (info)
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index 1f26da761e9f..cfe0194fef71 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -376,6 +376,7 @@ MODULE_DEVICE_TABLE(pnp, smsc_ircc_pnp_table);
376 376
377static int pnp_driver_registered; 377static int pnp_driver_registered;
378 378
379#ifdef CONFIG_PNP
379static int __init smsc_ircc_pnp_probe(struct pnp_dev *dev, 380static int __init smsc_ircc_pnp_probe(struct pnp_dev *dev,
380 const struct pnp_device_id *dev_id) 381 const struct pnp_device_id *dev_id)
381{ 382{
@@ -402,7 +403,9 @@ static struct pnp_driver smsc_ircc_pnp_driver = {
402 .id_table = smsc_ircc_pnp_table, 403 .id_table = smsc_ircc_pnp_table,
403 .probe = smsc_ircc_pnp_probe, 404 .probe = smsc_ircc_pnp_probe,
404}; 405};
405 406#else /* CONFIG_PNP */
407static struct pnp_driver smsc_ircc_pnp_driver;
408#endif
406 409
407/******************************************************************************* 410/*******************************************************************************
408 * 411 *
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 2056cfc624dc..c36a03ae9bfb 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -450,7 +450,7 @@ static void macvlan_dellink(struct net_device *dev)
450 unregister_netdevice(dev); 450 unregister_netdevice(dev);
451 451
452 if (list_empty(&port->vlans)) 452 if (list_empty(&port->vlans))
453 macvlan_port_destroy(dev); 453 macvlan_port_destroy(port->dev);
454} 454}
455 455
456static struct rtnl_link_ops macvlan_link_ops __read_mostly = { 456static struct rtnl_link_ops macvlan_link_ops __read_mostly = {
diff --git a/drivers/net/mlx4/mr.c b/drivers/net/mlx4/mr.c
index cb46446b2691..03a9abcce524 100644
--- a/drivers/net/mlx4/mr.c
+++ b/drivers/net/mlx4/mr.c
@@ -551,7 +551,7 @@ int mlx4_fmr_alloc(struct mlx4_dev *dev, u32 pd, u32 access, int max_pages,
551 u64 mtt_seg; 551 u64 mtt_seg;
552 int err = -ENOMEM; 552 int err = -ENOMEM;
553 553
554 if (page_shift < 12 || page_shift >= 32) 554 if (page_shift < (ffs(dev->caps.page_size_cap) - 1) || page_shift >= 32)
555 return -EINVAL; 555 return -EINVAL;
556 556
557 /* All MTTs must fit in the same page */ 557 /* All MTTs must fit in the same page */
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 381b36e5f64c..b7915cdcc6a5 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -91,6 +91,11 @@
91 */ 91 */
92#define PHY_ADDR_REG 0x0000 92#define PHY_ADDR_REG 0x0000
93#define SMI_REG 0x0004 93#define SMI_REG 0x0004
94#define WINDOW_BASE(i) (0x0200 + ((i) << 3))
95#define WINDOW_SIZE(i) (0x0204 + ((i) << 3))
96#define WINDOW_REMAP_HIGH(i) (0x0280 + ((i) << 2))
97#define WINDOW_BAR_ENABLE 0x0290
98#define WINDOW_PROTECT(i) (0x0294 + ((i) << 4))
94 99
95/* 100/*
96 * Per-port registers. 101 * Per-port registers.
@@ -507,9 +512,23 @@ struct mv643xx_mib_counters {
507 u32 late_collision; 512 u32 late_collision;
508}; 513};
509 514
515struct mv643xx_shared_private {
516 void __iomem *eth_base;
517
518 /* used to protect SMI_REG, which is shared across ports */
519 spinlock_t phy_lock;
520
521 u32 win_protect;
522
523 unsigned int t_clk;
524};
525
510struct mv643xx_private { 526struct mv643xx_private {
527 struct mv643xx_shared_private *shared;
511 int port_num; /* User Ethernet port number */ 528 int port_num; /* User Ethernet port number */
512 529
530 struct mv643xx_shared_private *shared_smi;
531
513 u32 rx_sram_addr; /* Base address of rx sram area */ 532 u32 rx_sram_addr; /* Base address of rx sram area */
514 u32 rx_sram_size; /* Size of rx sram area */ 533 u32 rx_sram_size; /* Size of rx sram area */
515 u32 tx_sram_addr; /* Base address of tx sram area */ 534 u32 tx_sram_addr; /* Base address of tx sram area */
@@ -614,19 +633,14 @@ static const struct ethtool_ops mv643xx_ethtool_ops;
614static char mv643xx_driver_name[] = "mv643xx_eth"; 633static char mv643xx_driver_name[] = "mv643xx_eth";
615static char mv643xx_driver_version[] = "1.0"; 634static char mv643xx_driver_version[] = "1.0";
616 635
617static void __iomem *mv643xx_eth_base;
618
619/* used to protect SMI_REG, which is shared across ports */
620static DEFINE_SPINLOCK(mv643xx_eth_phy_lock);
621
622static inline u32 rdl(struct mv643xx_private *mp, int offset) 636static inline u32 rdl(struct mv643xx_private *mp, int offset)
623{ 637{
624 return readl(mv643xx_eth_base + offset); 638 return readl(mp->shared->eth_base + offset);
625} 639}
626 640
627static inline void wrl(struct mv643xx_private *mp, int offset, u32 data) 641static inline void wrl(struct mv643xx_private *mp, int offset, u32 data)
628{ 642{
629 writel(data, mv643xx_eth_base + offset); 643 writel(data, mp->shared->eth_base + offset);
630} 644}
631 645
632/* 646/*
@@ -1119,7 +1133,6 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
1119 * 1133 *
1120 * INPUT: 1134 * INPUT:
1121 * struct mv643xx_private *mp Ethernet port 1135 * struct mv643xx_private *mp Ethernet port
1122 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
1123 * unsigned int delay Delay in usec 1136 * unsigned int delay Delay in usec
1124 * 1137 *
1125 * OUTPUT: 1138 * OUTPUT:
@@ -1130,10 +1143,10 @@ static irqreturn_t mv643xx_eth_int_handler(int irq, void *dev_id)
1130 * 1143 *
1131 */ 1144 */
1132static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp, 1145static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
1133 unsigned int t_clk, unsigned int delay) 1146 unsigned int delay)
1134{ 1147{
1135 unsigned int port_num = mp->port_num; 1148 unsigned int port_num = mp->port_num;
1136 unsigned int coal = ((t_clk / 1000000) * delay) / 64; 1149 unsigned int coal = ((mp->shared->t_clk / 1000000) * delay) / 64;
1137 1150
1138 /* Set RX Coalescing mechanism */ 1151 /* Set RX Coalescing mechanism */
1139 wrl(mp, SDMA_CONFIG_REG(port_num), 1152 wrl(mp, SDMA_CONFIG_REG(port_num),
@@ -1158,7 +1171,6 @@ static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
1158 * 1171 *
1159 * INPUT: 1172 * INPUT:
1160 * struct mv643xx_private *mp Ethernet port 1173 * struct mv643xx_private *mp Ethernet port
1161 * unsigned int t_clk t_clk of the MV-643xx chip in HZ units
1162 * unsigned int delay Delay in uSeconds 1174 * unsigned int delay Delay in uSeconds
1163 * 1175 *
1164 * OUTPUT: 1176 * OUTPUT:
@@ -1169,9 +1181,9 @@ static unsigned int eth_port_set_rx_coal(struct mv643xx_private *mp,
1169 * 1181 *
1170 */ 1182 */
1171static unsigned int eth_port_set_tx_coal(struct mv643xx_private *mp, 1183static unsigned int eth_port_set_tx_coal(struct mv643xx_private *mp,
1172 unsigned int t_clk, unsigned int delay) 1184 unsigned int delay)
1173{ 1185{
1174 unsigned int coal = ((t_clk / 1000000) * delay) / 64; 1186 unsigned int coal = ((mp->shared->t_clk / 1000000) * delay) / 64;
1175 1187
1176 /* Set TX Coalescing mechanism */ 1188 /* Set TX Coalescing mechanism */
1177 wrl(mp, TX_FIFO_URGENT_THRESHOLD_REG(mp->port_num), coal << 4); 1189 wrl(mp, TX_FIFO_URGENT_THRESHOLD_REG(mp->port_num), coal << 4);
@@ -1413,11 +1425,11 @@ static int mv643xx_eth_open(struct net_device *dev)
1413 1425
1414#ifdef MV643XX_COAL 1426#ifdef MV643XX_COAL
1415 mp->rx_int_coal = 1427 mp->rx_int_coal =
1416 eth_port_set_rx_coal(mp, 133000000, MV643XX_RX_COAL); 1428 eth_port_set_rx_coal(mp, MV643XX_RX_COAL);
1417#endif 1429#endif
1418 1430
1419 mp->tx_int_coal = 1431 mp->tx_int_coal =
1420 eth_port_set_tx_coal(mp, 133000000, MV643XX_TX_COAL); 1432 eth_port_set_tx_coal(mp, MV643XX_TX_COAL);
1421 1433
1422 /* Unmask phy and link status changes interrupts */ 1434 /* Unmask phy and link status changes interrupts */
1423 wrl(mp, INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT); 1435 wrl(mp, INTERRUPT_EXTEND_MASK_REG(port_num), ETH_INT_UNMASK_ALL_EXT);
@@ -1827,6 +1839,11 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1827 return -ENODEV; 1839 return -ENODEV;
1828 } 1840 }
1829 1841
1842 if (pd->shared == NULL) {
1843 printk(KERN_ERR "No mv643xx_eth_platform_data->shared\n");
1844 return -ENODEV;
1845 }
1846
1830 dev = alloc_etherdev(sizeof(struct mv643xx_private)); 1847 dev = alloc_etherdev(sizeof(struct mv643xx_private));
1831 if (!dev) 1848 if (!dev)
1832 return -ENOMEM; 1849 return -ENOMEM;
@@ -1877,8 +1894,16 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1877 1894
1878 spin_lock_init(&mp->lock); 1895 spin_lock_init(&mp->lock);
1879 1896
1897 mp->shared = platform_get_drvdata(pd->shared);
1880 port_num = mp->port_num = pd->port_number; 1898 port_num = mp->port_num = pd->port_number;
1881 1899
1900 if (mp->shared->win_protect)
1901 wrl(mp, WINDOW_PROTECT(port_num), mp->shared->win_protect);
1902
1903 mp->shared_smi = mp->shared;
1904 if (pd->shared_smi != NULL)
1905 mp->shared_smi = platform_get_drvdata(pd->shared_smi);
1906
1882 /* set default config values */ 1907 /* set default config values */
1883 eth_port_uc_addr_get(mp, dev->dev_addr); 1908 eth_port_uc_addr_get(mp, dev->dev_addr);
1884 mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE; 1909 mp->rx_ring_size = PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
@@ -1983,30 +2008,91 @@ static int mv643xx_eth_remove(struct platform_device *pdev)
1983 return 0; 2008 return 0;
1984} 2009}
1985 2010
2011static void mv643xx_eth_conf_mbus_windows(struct mv643xx_shared_private *msp,
2012 struct mbus_dram_target_info *dram)
2013{
2014 void __iomem *base = msp->eth_base;
2015 u32 win_enable;
2016 u32 win_protect;
2017 int i;
2018
2019 for (i = 0; i < 6; i++) {
2020 writel(0, base + WINDOW_BASE(i));
2021 writel(0, base + WINDOW_SIZE(i));
2022 if (i < 4)
2023 writel(0, base + WINDOW_REMAP_HIGH(i));
2024 }
2025
2026 win_enable = 0x3f;
2027 win_protect = 0;
2028
2029 for (i = 0; i < dram->num_cs; i++) {
2030 struct mbus_dram_window *cs = dram->cs + i;
2031
2032 writel((cs->base & 0xffff0000) |
2033 (cs->mbus_attr << 8) |
2034 dram->mbus_dram_target_id, base + WINDOW_BASE(i));
2035 writel((cs->size - 1) & 0xffff0000, base + WINDOW_SIZE(i));
2036
2037 win_enable &= ~(1 << i);
2038 win_protect |= 3 << (2 * i);
2039 }
2040
2041 writel(win_enable, base + WINDOW_BAR_ENABLE);
2042 msp->win_protect = win_protect;
2043}
2044
1986static int mv643xx_eth_shared_probe(struct platform_device *pdev) 2045static int mv643xx_eth_shared_probe(struct platform_device *pdev)
1987{ 2046{
1988 static int mv643xx_version_printed = 0; 2047 static int mv643xx_version_printed = 0;
2048 struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
2049 struct mv643xx_shared_private *msp;
1989 struct resource *res; 2050 struct resource *res;
2051 int ret;
1990 2052
1991 if (!mv643xx_version_printed++) 2053 if (!mv643xx_version_printed++)
1992 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n"); 2054 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n");
1993 2055
2056 ret = -EINVAL;
1994 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2057 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1995 if (res == NULL) 2058 if (res == NULL)
1996 return -ENODEV; 2059 goto out;
1997 2060
1998 mv643xx_eth_base = ioremap(res->start, res->end - res->start + 1); 2061 ret = -ENOMEM;
1999 if (mv643xx_eth_base == NULL) 2062 msp = kmalloc(sizeof(*msp), GFP_KERNEL);
2000 return -ENOMEM; 2063 if (msp == NULL)
2064 goto out;
2065 memset(msp, 0, sizeof(*msp));
2066
2067 msp->eth_base = ioremap(res->start, res->end - res->start + 1);
2068 if (msp->eth_base == NULL)
2069 goto out_free;
2070
2071 spin_lock_init(&msp->phy_lock);
2072 msp->t_clk = (pd != NULL && pd->t_clk != 0) ? pd->t_clk : 133000000;
2073
2074 platform_set_drvdata(pdev, msp);
2075
2076 /*
2077 * (Re-)program MBUS remapping windows if we are asked to.
2078 */
2079 if (pd != NULL && pd->dram != NULL)
2080 mv643xx_eth_conf_mbus_windows(msp, pd->dram);
2001 2081
2002 return 0; 2082 return 0;
2003 2083
2084out_free:
2085 kfree(msp);
2086out:
2087 return ret;
2004} 2088}
2005 2089
2006static int mv643xx_eth_shared_remove(struct platform_device *pdev) 2090static int mv643xx_eth_shared_remove(struct platform_device *pdev)
2007{ 2091{
2008 iounmap(mv643xx_eth_base); 2092 struct mv643xx_shared_private *msp = platform_get_drvdata(pdev);
2009 mv643xx_eth_base = NULL; 2093
2094 iounmap(msp->eth_base);
2095 kfree(msp);
2010 2096
2011 return 0; 2097 return 0;
2012} 2098}
@@ -2906,15 +2992,16 @@ static void eth_port_reset(struct mv643xx_private *mp)
2906static void eth_port_read_smi_reg(struct mv643xx_private *mp, 2992static void eth_port_read_smi_reg(struct mv643xx_private *mp,
2907 unsigned int phy_reg, unsigned int *value) 2993 unsigned int phy_reg, unsigned int *value)
2908{ 2994{
2995 void __iomem *smi_reg = mp->shared_smi->eth_base + SMI_REG;
2909 int phy_addr = ethernet_phy_get(mp); 2996 int phy_addr = ethernet_phy_get(mp);
2910 unsigned long flags; 2997 unsigned long flags;
2911 int i; 2998 int i;
2912 2999
2913 /* the SMI register is a shared resource */ 3000 /* the SMI register is a shared resource */
2914 spin_lock_irqsave(&mv643xx_eth_phy_lock, flags); 3001 spin_lock_irqsave(&mp->shared_smi->phy_lock, flags);
2915 3002
2916 /* wait for the SMI register to become available */ 3003 /* wait for the SMI register to become available */
2917 for (i = 0; rdl(mp, SMI_REG) & ETH_SMI_BUSY; i++) { 3004 for (i = 0; readl(smi_reg) & ETH_SMI_BUSY; i++) {
2918 if (i == PHY_WAIT_ITERATIONS) { 3005 if (i == PHY_WAIT_ITERATIONS) {
2919 printk("%s: PHY busy timeout\n", mp->dev->name); 3006 printk("%s: PHY busy timeout\n", mp->dev->name);
2920 goto out; 3007 goto out;
@@ -2922,11 +3009,11 @@ static void eth_port_read_smi_reg(struct mv643xx_private *mp,
2922 udelay(PHY_WAIT_MICRO_SECONDS); 3009 udelay(PHY_WAIT_MICRO_SECONDS);
2923 } 3010 }
2924 3011
2925 wrl(mp, SMI_REG, 3012 writel((phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ,
2926 (phy_addr << 16) | (phy_reg << 21) | ETH_SMI_OPCODE_READ); 3013 smi_reg);
2927 3014
2928 /* now wait for the data to be valid */ 3015 /* now wait for the data to be valid */
2929 for (i = 0; !(rdl(mp, SMI_REG) & ETH_SMI_READ_VALID); i++) { 3016 for (i = 0; !(readl(smi_reg) & ETH_SMI_READ_VALID); i++) {
2930 if (i == PHY_WAIT_ITERATIONS) { 3017 if (i == PHY_WAIT_ITERATIONS) {
2931 printk("%s: PHY read timeout\n", mp->dev->name); 3018 printk("%s: PHY read timeout\n", mp->dev->name);
2932 goto out; 3019 goto out;
@@ -2934,9 +3021,9 @@ static void eth_port_read_smi_reg(struct mv643xx_private *mp,
2934 udelay(PHY_WAIT_MICRO_SECONDS); 3021 udelay(PHY_WAIT_MICRO_SECONDS);
2935 } 3022 }
2936 3023
2937 *value = rdl(mp, SMI_REG) & 0xffff; 3024 *value = readl(smi_reg) & 0xffff;
2938out: 3025out:
2939 spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags); 3026 spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags);
2940} 3027}
2941 3028
2942/* 3029/*
@@ -2962,17 +3049,16 @@ out:
2962static void eth_port_write_smi_reg(struct mv643xx_private *mp, 3049static void eth_port_write_smi_reg(struct mv643xx_private *mp,
2963 unsigned int phy_reg, unsigned int value) 3050 unsigned int phy_reg, unsigned int value)
2964{ 3051{
2965 int phy_addr; 3052 void __iomem *smi_reg = mp->shared_smi->eth_base + SMI_REG;
2966 int i; 3053 int phy_addr = ethernet_phy_get(mp);
2967 unsigned long flags; 3054 unsigned long flags;
2968 3055 int i;
2969 phy_addr = ethernet_phy_get(mp);
2970 3056
2971 /* the SMI register is a shared resource */ 3057 /* the SMI register is a shared resource */
2972 spin_lock_irqsave(&mv643xx_eth_phy_lock, flags); 3058 spin_lock_irqsave(&mp->shared_smi->phy_lock, flags);
2973 3059
2974 /* wait for the SMI register to become available */ 3060 /* wait for the SMI register to become available */
2975 for (i = 0; rdl(mp, SMI_REG) & ETH_SMI_BUSY; i++) { 3061 for (i = 0; readl(smi_reg) & ETH_SMI_BUSY; i++) {
2976 if (i == PHY_WAIT_ITERATIONS) { 3062 if (i == PHY_WAIT_ITERATIONS) {
2977 printk("%s: PHY busy timeout\n", mp->dev->name); 3063 printk("%s: PHY busy timeout\n", mp->dev->name);
2978 goto out; 3064 goto out;
@@ -2980,10 +3066,10 @@ static void eth_port_write_smi_reg(struct mv643xx_private *mp,
2980 udelay(PHY_WAIT_MICRO_SECONDS); 3066 udelay(PHY_WAIT_MICRO_SECONDS);
2981 } 3067 }
2982 3068
2983 wrl(mp, SMI_REG, (phy_addr << 16) | (phy_reg << 21) | 3069 writel((phy_addr << 16) | (phy_reg << 21) |
2984 ETH_SMI_OPCODE_WRITE | (value & 0xffff)); 3070 ETH_SMI_OPCODE_WRITE | (value & 0xffff), smi_reg);
2985out: 3071out:
2986 spin_unlock_irqrestore(&mv643xx_eth_phy_lock, flags); 3072 spin_unlock_irqrestore(&mp->shared_smi->phy_lock, flags);
2987} 3073}
2988 3074
2989/* 3075/*
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index ef63c8d2bd7e..c91b12ea26ad 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -144,11 +144,13 @@ struct myri10ge_tx_buf {
144 char *req_bytes; 144 char *req_bytes;
145 struct myri10ge_tx_buffer_state *info; 145 struct myri10ge_tx_buffer_state *info;
146 int mask; /* number of transmit slots -1 */ 146 int mask; /* number of transmit slots -1 */
147 int boundary; /* boundary transmits cannot cross */
148 int req ____cacheline_aligned; /* transmit slots submitted */ 147 int req ____cacheline_aligned; /* transmit slots submitted */
149 int pkt_start; /* packets started */ 148 int pkt_start; /* packets started */
149 int stop_queue;
150 int linearized;
150 int done ____cacheline_aligned; /* transmit slots completed */ 151 int done ____cacheline_aligned; /* transmit slots completed */
151 int pkt_done; /* packets completed */ 152 int pkt_done; /* packets completed */
153 int wake_queue;
152}; 154};
153 155
154struct myri10ge_rx_done { 156struct myri10ge_rx_done {
@@ -160,29 +162,50 @@ struct myri10ge_rx_done {
160 struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS]; 162 struct net_lro_desc lro_desc[MYRI10GE_MAX_LRO_DESCRIPTORS];
161}; 163};
162 164
163struct myri10ge_priv { 165struct myri10ge_slice_netstats {
164 int running; /* running? */ 166 unsigned long rx_packets;
165 int csum_flag; /* rx_csums? */ 167 unsigned long tx_packets;
168 unsigned long rx_bytes;
169 unsigned long tx_bytes;
170 unsigned long rx_dropped;
171 unsigned long tx_dropped;
172};
173
174struct myri10ge_slice_state {
166 struct myri10ge_tx_buf tx; /* transmit ring */ 175 struct myri10ge_tx_buf tx; /* transmit ring */
167 struct myri10ge_rx_buf rx_small; 176 struct myri10ge_rx_buf rx_small;
168 struct myri10ge_rx_buf rx_big; 177 struct myri10ge_rx_buf rx_big;
169 struct myri10ge_rx_done rx_done; 178 struct myri10ge_rx_done rx_done;
179 struct net_device *dev;
180 struct napi_struct napi;
181 struct myri10ge_priv *mgp;
182 struct myri10ge_slice_netstats stats;
183 __be32 __iomem *irq_claim;
184 struct mcp_irq_data *fw_stats;
185 dma_addr_t fw_stats_bus;
186 int watchdog_tx_done;
187 int watchdog_tx_req;
188};
189
190struct myri10ge_priv {
191 struct myri10ge_slice_state ss;
192 int tx_boundary; /* boundary transmits cannot cross */
193 int running; /* running? */
194 int csum_flag; /* rx_csums? */
170 int small_bytes; 195 int small_bytes;
171 int big_bytes; 196 int big_bytes;
197 int max_intr_slots;
172 struct net_device *dev; 198 struct net_device *dev;
173 struct napi_struct napi;
174 struct net_device_stats stats; 199 struct net_device_stats stats;
200 spinlock_t stats_lock;
175 u8 __iomem *sram; 201 u8 __iomem *sram;
176 int sram_size; 202 int sram_size;
177 unsigned long board_span; 203 unsigned long board_span;
178 unsigned long iomem_base; 204 unsigned long iomem_base;
179 __be32 __iomem *irq_claim;
180 __be32 __iomem *irq_deassert; 205 __be32 __iomem *irq_deassert;
181 char *mac_addr_string; 206 char *mac_addr_string;
182 struct mcp_cmd_response *cmd; 207 struct mcp_cmd_response *cmd;
183 dma_addr_t cmd_bus; 208 dma_addr_t cmd_bus;
184 struct mcp_irq_data *fw_stats;
185 dma_addr_t fw_stats_bus;
186 struct pci_dev *pdev; 209 struct pci_dev *pdev;
187 int msi_enabled; 210 int msi_enabled;
188 u32 link_state; 211 u32 link_state;
@@ -191,20 +214,16 @@ struct myri10ge_priv {
191 __be32 __iomem *intr_coal_delay_ptr; 214 __be32 __iomem *intr_coal_delay_ptr;
192 int mtrr; 215 int mtrr;
193 int wc_enabled; 216 int wc_enabled;
194 int wake_queue;
195 int stop_queue;
196 int down_cnt; 217 int down_cnt;
197 wait_queue_head_t down_wq; 218 wait_queue_head_t down_wq;
198 struct work_struct watchdog_work; 219 struct work_struct watchdog_work;
199 struct timer_list watchdog_timer; 220 struct timer_list watchdog_timer;
200 int watchdog_tx_done;
201 int watchdog_tx_req;
202 int watchdog_pause;
203 int watchdog_resets; 221 int watchdog_resets;
204 int tx_linearized; 222 int watchdog_pause;
205 int pause; 223 int pause;
206 char *fw_name; 224 char *fw_name;
207 char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE]; 225 char eeprom_strings[MYRI10GE_EEPROM_STRINGS_SIZE];
226 char *product_code_string;
208 char fw_version[128]; 227 char fw_version[128];
209 int fw_ver_major; 228 int fw_ver_major;
210 int fw_ver_minor; 229 int fw_ver_minor;
@@ -228,58 +247,54 @@ static char *myri10ge_fw_aligned = "myri10ge_eth_z8e.dat";
228 247
229static char *myri10ge_fw_name = NULL; 248static char *myri10ge_fw_name = NULL;
230module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR); 249module_param(myri10ge_fw_name, charp, S_IRUGO | S_IWUSR);
231MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name\n"); 250MODULE_PARM_DESC(myri10ge_fw_name, "Firmware image name");
232 251
233static int myri10ge_ecrc_enable = 1; 252static int myri10ge_ecrc_enable = 1;
234module_param(myri10ge_ecrc_enable, int, S_IRUGO); 253module_param(myri10ge_ecrc_enable, int, S_IRUGO);
235MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E\n"); 254MODULE_PARM_DESC(myri10ge_ecrc_enable, "Enable Extended CRC on PCI-E");
236
237static int myri10ge_max_intr_slots = 1024;
238module_param(myri10ge_max_intr_slots, int, S_IRUGO);
239MODULE_PARM_DESC(myri10ge_max_intr_slots, "Interrupt queue slots\n");
240 255
241static int myri10ge_small_bytes = -1; /* -1 == auto */ 256static int myri10ge_small_bytes = -1; /* -1 == auto */
242module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR); 257module_param(myri10ge_small_bytes, int, S_IRUGO | S_IWUSR);
243MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets\n"); 258MODULE_PARM_DESC(myri10ge_small_bytes, "Threshold of small packets");
244 259
245static int myri10ge_msi = 1; /* enable msi by default */ 260static int myri10ge_msi = 1; /* enable msi by default */
246module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR); 261module_param(myri10ge_msi, int, S_IRUGO | S_IWUSR);
247MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts\n"); 262MODULE_PARM_DESC(myri10ge_msi, "Enable Message Signalled Interrupts");
248 263
249static int myri10ge_intr_coal_delay = 75; 264static int myri10ge_intr_coal_delay = 75;
250module_param(myri10ge_intr_coal_delay, int, S_IRUGO); 265module_param(myri10ge_intr_coal_delay, int, S_IRUGO);
251MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay\n"); 266MODULE_PARM_DESC(myri10ge_intr_coal_delay, "Interrupt coalescing delay");
252 267
253static int myri10ge_flow_control = 1; 268static int myri10ge_flow_control = 1;
254module_param(myri10ge_flow_control, int, S_IRUGO); 269module_param(myri10ge_flow_control, int, S_IRUGO);
255MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter\n"); 270MODULE_PARM_DESC(myri10ge_flow_control, "Pause parameter");
256 271
257static int myri10ge_deassert_wait = 1; 272static int myri10ge_deassert_wait = 1;
258module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR); 273module_param(myri10ge_deassert_wait, int, S_IRUGO | S_IWUSR);
259MODULE_PARM_DESC(myri10ge_deassert_wait, 274MODULE_PARM_DESC(myri10ge_deassert_wait,
260 "Wait when deasserting legacy interrupts\n"); 275 "Wait when deasserting legacy interrupts");
261 276
262static int myri10ge_force_firmware = 0; 277static int myri10ge_force_firmware = 0;
263module_param(myri10ge_force_firmware, int, S_IRUGO); 278module_param(myri10ge_force_firmware, int, S_IRUGO);
264MODULE_PARM_DESC(myri10ge_force_firmware, 279MODULE_PARM_DESC(myri10ge_force_firmware,
265 "Force firmware to assume aligned completions\n"); 280 "Force firmware to assume aligned completions");
266 281
267static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN; 282static int myri10ge_initial_mtu = MYRI10GE_MAX_ETHER_MTU - ETH_HLEN;
268module_param(myri10ge_initial_mtu, int, S_IRUGO); 283module_param(myri10ge_initial_mtu, int, S_IRUGO);
269MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU\n"); 284MODULE_PARM_DESC(myri10ge_initial_mtu, "Initial MTU");
270 285
271static int myri10ge_napi_weight = 64; 286static int myri10ge_napi_weight = 64;
272module_param(myri10ge_napi_weight, int, S_IRUGO); 287module_param(myri10ge_napi_weight, int, S_IRUGO);
273MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight\n"); 288MODULE_PARM_DESC(myri10ge_napi_weight, "Set NAPI weight");
274 289
275static int myri10ge_watchdog_timeout = 1; 290static int myri10ge_watchdog_timeout = 1;
276module_param(myri10ge_watchdog_timeout, int, S_IRUGO); 291module_param(myri10ge_watchdog_timeout, int, S_IRUGO);
277MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout\n"); 292MODULE_PARM_DESC(myri10ge_watchdog_timeout, "Set watchdog timeout");
278 293
279static int myri10ge_max_irq_loops = 1048576; 294static int myri10ge_max_irq_loops = 1048576;
280module_param(myri10ge_max_irq_loops, int, S_IRUGO); 295module_param(myri10ge_max_irq_loops, int, S_IRUGO);
281MODULE_PARM_DESC(myri10ge_max_irq_loops, 296MODULE_PARM_DESC(myri10ge_max_irq_loops,
282 "Set stuck legacy IRQ detection threshold\n"); 297 "Set stuck legacy IRQ detection threshold");
283 298
284#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK 299#define MYRI10GE_MSG_DEFAULT NETIF_MSG_LINK
285 300
@@ -289,21 +304,22 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)");
289 304
290static int myri10ge_lro = 1; 305static int myri10ge_lro = 1;
291module_param(myri10ge_lro, int, S_IRUGO); 306module_param(myri10ge_lro, int, S_IRUGO);
292MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload\n"); 307MODULE_PARM_DESC(myri10ge_lro, "Enable large receive offload");
293 308
294static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS; 309static int myri10ge_lro_max_pkts = MYRI10GE_LRO_MAX_PKTS;
295module_param(myri10ge_lro_max_pkts, int, S_IRUGO); 310module_param(myri10ge_lro_max_pkts, int, S_IRUGO);
296MODULE_PARM_DESC(myri10ge_lro, "Number of LRO packets to be aggregated\n"); 311MODULE_PARM_DESC(myri10ge_lro_max_pkts,
312 "Number of LRO packets to be aggregated");
297 313
298static int myri10ge_fill_thresh = 256; 314static int myri10ge_fill_thresh = 256;
299module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR); 315module_param(myri10ge_fill_thresh, int, S_IRUGO | S_IWUSR);
300MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed\n"); 316MODULE_PARM_DESC(myri10ge_fill_thresh, "Number of empty rx slots allowed");
301 317
302static int myri10ge_reset_recover = 1; 318static int myri10ge_reset_recover = 1;
303 319
304static int myri10ge_wcfifo = 0; 320static int myri10ge_wcfifo = 0;
305module_param(myri10ge_wcfifo, int, S_IRUGO); 321module_param(myri10ge_wcfifo, int, S_IRUGO);
306MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled\n"); 322MODULE_PARM_DESC(myri10ge_wcfifo, "Enable WC Fifo when WC is enabled");
307 323
308#define MYRI10GE_FW_OFFSET 1024*1024 324#define MYRI10GE_FW_OFFSET 1024*1024
309#define MYRI10GE_HIGHPART_TO_U32(X) \ 325#define MYRI10GE_HIGHPART_TO_U32(X) \
@@ -359,8 +375,10 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd,
359 for (sleep_total = 0; 375 for (sleep_total = 0;
360 sleep_total < 1000 376 sleep_total < 1000
361 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); 377 && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT);
362 sleep_total += 10) 378 sleep_total += 10) {
363 udelay(10); 379 udelay(10);
380 mb();
381 }
364 } else { 382 } else {
365 /* use msleep for most command */ 383 /* use msleep for most command */
366 for (sleep_total = 0; 384 for (sleep_total = 0;
@@ -420,6 +438,10 @@ static int myri10ge_read_mac_addr(struct myri10ge_priv *mgp)
420 ptr += 1; 438 ptr += 1;
421 } 439 }
422 } 440 }
441 if (memcmp(ptr, "PC=", 3) == 0) {
442 ptr += 3;
443 mgp->product_code_string = ptr;
444 }
423 if (memcmp((const void *)ptr, "SN=", 3) == 0) { 445 if (memcmp((const void *)ptr, "SN=", 3) == 0) {
424 ptr += 3; 446 ptr += 3;
425 mgp->serial_number = simple_strtoul(ptr, &ptr, 10); 447 mgp->serial_number = simple_strtoul(ptr, &ptr, 10);
@@ -442,7 +464,7 @@ abort:
442static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) 464static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable)
443{ 465{
444 char __iomem *submit; 466 char __iomem *submit;
445 __be32 buf[16]; 467 __be32 buf[16] __attribute__ ((__aligned__(8)));
446 u32 dma_low, dma_high; 468 u32 dma_low, dma_high;
447 int i; 469 int i;
448 470
@@ -609,13 +631,38 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp)
609 return status; 631 return status;
610} 632}
611 633
634int myri10ge_get_firmware_capabilities(struct myri10ge_priv *mgp)
635{
636 struct myri10ge_cmd cmd;
637 int status;
638
639 /* probe for IPv6 TSO support */
640 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
641 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
642 &cmd, 0);
643 if (status == 0) {
644 mgp->max_tso6 = cmd.data0;
645 mgp->features |= NETIF_F_TSO6;
646 }
647
648 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
649 if (status != 0) {
650 dev_err(&mgp->pdev->dev,
651 "failed MXGEFW_CMD_GET_RX_RING_SIZE\n");
652 return -ENXIO;
653 }
654
655 mgp->max_intr_slots = 2 * (cmd.data0 / sizeof(struct mcp_dma_addr));
656
657 return 0;
658}
659
612static int myri10ge_load_firmware(struct myri10ge_priv *mgp) 660static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
613{ 661{
614 char __iomem *submit; 662 char __iomem *submit;
615 __be32 buf[16]; 663 __be32 buf[16] __attribute__ ((__aligned__(8)));
616 u32 dma_low, dma_high, size; 664 u32 dma_low, dma_high, size;
617 int status, i; 665 int status, i;
618 struct myri10ge_cmd cmd;
619 666
620 size = 0; 667 size = 0;
621 status = myri10ge_load_hotplug_firmware(mgp, &size); 668 status = myri10ge_load_hotplug_firmware(mgp, &size);
@@ -635,7 +682,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
635 } 682 }
636 dev_info(&mgp->pdev->dev, 683 dev_info(&mgp->pdev->dev,
637 "Successfully adopted running firmware\n"); 684 "Successfully adopted running firmware\n");
638 if (mgp->tx.boundary == 4096) { 685 if (mgp->tx_boundary == 4096) {
639 dev_warn(&mgp->pdev->dev, 686 dev_warn(&mgp->pdev->dev,
640 "Using firmware currently running on NIC" 687 "Using firmware currently running on NIC"
641 ". For optimal\n"); 688 ". For optimal\n");
@@ -646,7 +693,9 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
646 } 693 }
647 694
648 mgp->fw_name = "adopted"; 695 mgp->fw_name = "adopted";
649 mgp->tx.boundary = 2048; 696 mgp->tx_boundary = 2048;
697 myri10ge_dummy_rdma(mgp, 1);
698 status = myri10ge_get_firmware_capabilities(mgp);
650 return status; 699 return status;
651 } 700 }
652 701
@@ -681,26 +730,18 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp)
681 msleep(1); 730 msleep(1);
682 mb(); 731 mb();
683 i = 0; 732 i = 0;
684 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 20) { 733 while (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA && i < 9) {
685 msleep(1); 734 msleep(1 << i);
686 i++; 735 i++;
687 } 736 }
688 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) { 737 if (mgp->cmd->data != MYRI10GE_NO_CONFIRM_DATA) {
689 dev_err(&mgp->pdev->dev, "handoff failed\n"); 738 dev_err(&mgp->pdev->dev, "handoff failed\n");
690 return -ENXIO; 739 return -ENXIO;
691 } 740 }
692 dev_info(&mgp->pdev->dev, "handoff confirmed\n");
693 myri10ge_dummy_rdma(mgp, 1); 741 myri10ge_dummy_rdma(mgp, 1);
742 status = myri10ge_get_firmware_capabilities(mgp);
694 743
695 /* probe for IPv6 TSO support */ 744 return status;
696 mgp->features = NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_TSO;
697 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
698 &cmd, 0);
699 if (status == 0) {
700 mgp->max_tso6 = cmd.data0;
701 mgp->features |= NETIF_F_TSO6;
702 }
703 return 0;
704} 745}
705 746
706static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr) 747static int myri10ge_update_mac_address(struct myri10ge_priv *mgp, u8 * addr)
@@ -772,7 +813,7 @@ static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type)
772 * transfers took to complete. 813 * transfers took to complete.
773 */ 814 */
774 815
775 len = mgp->tx.boundary; 816 len = mgp->tx_boundary;
776 817
777 cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus); 818 cmd.data0 = MYRI10GE_LOWPART_TO_U32(dmatest_bus);
778 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus); 819 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(dmatest_bus);
@@ -834,17 +875,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
834 875
835 /* Now exchange information about interrupts */ 876 /* Now exchange information about interrupts */
836 877
837 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 878 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
838 memset(mgp->rx_done.entry, 0, bytes); 879 memset(mgp->ss.rx_done.entry, 0, bytes);
839 cmd.data0 = (u32) bytes; 880 cmd.data0 = (u32) bytes;
840 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0); 881 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_SIZE, &cmd, 0);
841 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->rx_done.bus); 882 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.rx_done.bus);
842 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->rx_done.bus); 883 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.rx_done.bus);
843 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0); 884 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_INTRQ_DMA, &cmd, 0);
844 885
845 status |= 886 status |=
846 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); 887 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0);
847 mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0); 888 mgp->ss.irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0);
848 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, 889 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET,
849 &cmd, 0); 890 &cmd, 0);
850 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); 891 mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0);
@@ -858,17 +899,17 @@ static int myri10ge_reset(struct myri10ge_priv *mgp)
858 } 899 }
859 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); 900 put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr);
860 901
861 memset(mgp->rx_done.entry, 0, bytes); 902 memset(mgp->ss.rx_done.entry, 0, bytes);
862 903
863 /* reset mcp/driver shared state back to 0 */ 904 /* reset mcp/driver shared state back to 0 */
864 mgp->tx.req = 0; 905 mgp->ss.tx.req = 0;
865 mgp->tx.done = 0; 906 mgp->ss.tx.done = 0;
866 mgp->tx.pkt_start = 0; 907 mgp->ss.tx.pkt_start = 0;
867 mgp->tx.pkt_done = 0; 908 mgp->ss.tx.pkt_done = 0;
868 mgp->rx_big.cnt = 0; 909 mgp->ss.rx_big.cnt = 0;
869 mgp->rx_small.cnt = 0; 910 mgp->ss.rx_small.cnt = 0;
870 mgp->rx_done.idx = 0; 911 mgp->ss.rx_done.idx = 0;
871 mgp->rx_done.cnt = 0; 912 mgp->ss.rx_done.cnt = 0;
872 mgp->link_changes = 0; 913 mgp->link_changes = 0;
873 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr); 914 status = myri10ge_update_mac_address(mgp, mgp->dev->dev_addr);
874 myri10ge_change_pause(mgp, mgp->pause); 915 myri10ge_change_pause(mgp, mgp->pause);
@@ -1020,9 +1061,10 @@ myri10ge_unmap_rx_page(struct pci_dev *pdev,
1020 * page into an skb */ 1061 * page into an skb */
1021 1062
1022static inline int 1063static inline int
1023myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, 1064myri10ge_rx_done(struct myri10ge_slice_state *ss, struct myri10ge_rx_buf *rx,
1024 int bytes, int len, __wsum csum) 1065 int bytes, int len, __wsum csum)
1025{ 1066{
1067 struct myri10ge_priv *mgp = ss->mgp;
1026 struct sk_buff *skb; 1068 struct sk_buff *skb;
1027 struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME]; 1069 struct skb_frag_struct rx_frags[MYRI10GE_MAX_FRAGS_PER_FRAME];
1028 int i, idx, hlen, remainder; 1070 int i, idx, hlen, remainder;
@@ -1052,11 +1094,10 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1052 rx_frags[0].page_offset += MXGEFW_PAD; 1094 rx_frags[0].page_offset += MXGEFW_PAD;
1053 rx_frags[0].size -= MXGEFW_PAD; 1095 rx_frags[0].size -= MXGEFW_PAD;
1054 len -= MXGEFW_PAD; 1096 len -= MXGEFW_PAD;
1055 lro_receive_frags(&mgp->rx_done.lro_mgr, rx_frags, 1097 lro_receive_frags(&ss->rx_done.lro_mgr, rx_frags,
1056 len, len, 1098 len, len,
1057 /* opaque, will come back in get_frag_header */ 1099 /* opaque, will come back in get_frag_header */
1058 (void *)(__force unsigned long)csum, 1100 (void *)(__force unsigned long)csum, csum);
1059 csum);
1060 return 1; 1101 return 1;
1061 } 1102 }
1062 1103
@@ -1096,10 +1137,11 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1096 return 1; 1137 return 1;
1097} 1138}
1098 1139
1099static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) 1140static inline void
1141myri10ge_tx_done(struct myri10ge_slice_state *ss, int mcp_index)
1100{ 1142{
1101 struct pci_dev *pdev = mgp->pdev; 1143 struct pci_dev *pdev = ss->mgp->pdev;
1102 struct myri10ge_tx_buf *tx = &mgp->tx; 1144 struct myri10ge_tx_buf *tx = &ss->tx;
1103 struct sk_buff *skb; 1145 struct sk_buff *skb;
1104 int idx, len; 1146 int idx, len;
1105 1147
@@ -1117,8 +1159,8 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
1117 len = pci_unmap_len(&tx->info[idx], len); 1159 len = pci_unmap_len(&tx->info[idx], len);
1118 pci_unmap_len_set(&tx->info[idx], len, 0); 1160 pci_unmap_len_set(&tx->info[idx], len, 0);
1119 if (skb) { 1161 if (skb) {
1120 mgp->stats.tx_bytes += skb->len; 1162 ss->stats.tx_bytes += skb->len;
1121 mgp->stats.tx_packets++; 1163 ss->stats.tx_packets++;
1122 dev_kfree_skb_irq(skb); 1164 dev_kfree_skb_irq(skb);
1123 if (len) 1165 if (len)
1124 pci_unmap_single(pdev, 1166 pci_unmap_single(pdev,
@@ -1134,16 +1176,18 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index)
1134 } 1176 }
1135 } 1177 }
1136 /* start the queue if we've stopped it */ 1178 /* start the queue if we've stopped it */
1137 if (netif_queue_stopped(mgp->dev) 1179 if (netif_queue_stopped(ss->dev)
1138 && tx->req - tx->done < (tx->mask >> 1)) { 1180 && tx->req - tx->done < (tx->mask >> 1)) {
1139 mgp->wake_queue++; 1181 tx->wake_queue++;
1140 netif_wake_queue(mgp->dev); 1182 netif_wake_queue(ss->dev);
1141 } 1183 }
1142} 1184}
1143 1185
1144static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget) 1186static inline int
1187myri10ge_clean_rx_done(struct myri10ge_slice_state *ss, int budget)
1145{ 1188{
1146 struct myri10ge_rx_done *rx_done = &mgp->rx_done; 1189 struct myri10ge_rx_done *rx_done = &ss->rx_done;
1190 struct myri10ge_priv *mgp = ss->mgp;
1147 unsigned long rx_bytes = 0; 1191 unsigned long rx_bytes = 0;
1148 unsigned long rx_packets = 0; 1192 unsigned long rx_packets = 0;
1149 unsigned long rx_ok; 1193 unsigned long rx_ok;
@@ -1159,40 +1203,40 @@ static inline int myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int budget)
1159 rx_done->entry[idx].length = 0; 1203 rx_done->entry[idx].length = 0;
1160 checksum = csum_unfold(rx_done->entry[idx].checksum); 1204 checksum = csum_unfold(rx_done->entry[idx].checksum);
1161 if (length <= mgp->small_bytes) 1205 if (length <= mgp->small_bytes)
1162 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, 1206 rx_ok = myri10ge_rx_done(ss, &ss->rx_small,
1163 mgp->small_bytes, 1207 mgp->small_bytes,
1164 length, checksum); 1208 length, checksum);
1165 else 1209 else
1166 rx_ok = myri10ge_rx_done(mgp, &mgp->rx_big, 1210 rx_ok = myri10ge_rx_done(ss, &ss->rx_big,
1167 mgp->big_bytes, 1211 mgp->big_bytes,
1168 length, checksum); 1212 length, checksum);
1169 rx_packets += rx_ok; 1213 rx_packets += rx_ok;
1170 rx_bytes += rx_ok * (unsigned long)length; 1214 rx_bytes += rx_ok * (unsigned long)length;
1171 cnt++; 1215 cnt++;
1172 idx = cnt & (myri10ge_max_intr_slots - 1); 1216 idx = cnt & (mgp->max_intr_slots - 1);
1173 work_done++; 1217 work_done++;
1174 } 1218 }
1175 rx_done->idx = idx; 1219 rx_done->idx = idx;
1176 rx_done->cnt = cnt; 1220 rx_done->cnt = cnt;
1177 mgp->stats.rx_packets += rx_packets; 1221 ss->stats.rx_packets += rx_packets;
1178 mgp->stats.rx_bytes += rx_bytes; 1222 ss->stats.rx_bytes += rx_bytes;
1179 1223
1180 if (myri10ge_lro) 1224 if (myri10ge_lro)
1181 lro_flush_all(&rx_done->lro_mgr); 1225 lro_flush_all(&rx_done->lro_mgr);
1182 1226
1183 /* restock receive rings if needed */ 1227 /* restock receive rings if needed */
1184 if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt < myri10ge_fill_thresh) 1228 if (ss->rx_small.fill_cnt - ss->rx_small.cnt < myri10ge_fill_thresh)
1185 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 1229 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
1186 mgp->small_bytes + MXGEFW_PAD, 0); 1230 mgp->small_bytes + MXGEFW_PAD, 0);
1187 if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt < myri10ge_fill_thresh) 1231 if (ss->rx_big.fill_cnt - ss->rx_big.cnt < myri10ge_fill_thresh)
1188 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); 1232 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
1189 1233
1190 return work_done; 1234 return work_done;
1191} 1235}
1192 1236
1193static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp) 1237static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1194{ 1238{
1195 struct mcp_irq_data *stats = mgp->fw_stats; 1239 struct mcp_irq_data *stats = mgp->ss.fw_stats;
1196 1240
1197 if (unlikely(stats->stats_updated)) { 1241 if (unlikely(stats->stats_updated)) {
1198 unsigned link_up = ntohl(stats->link_up); 1242 unsigned link_up = ntohl(stats->link_up);
@@ -1219,9 +1263,9 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1219 } 1263 }
1220 } 1264 }
1221 if (mgp->rdma_tags_available != 1265 if (mgp->rdma_tags_available !=
1222 ntohl(mgp->fw_stats->rdma_tags_available)) { 1266 ntohl(stats->rdma_tags_available)) {
1223 mgp->rdma_tags_available = 1267 mgp->rdma_tags_available =
1224 ntohl(mgp->fw_stats->rdma_tags_available); 1268 ntohl(stats->rdma_tags_available);
1225 printk(KERN_WARNING "myri10ge: %s: RDMA timed out! " 1269 printk(KERN_WARNING "myri10ge: %s: RDMA timed out! "
1226 "%d tags left\n", mgp->dev->name, 1270 "%d tags left\n", mgp->dev->name,
1227 mgp->rdma_tags_available); 1271 mgp->rdma_tags_available);
@@ -1234,26 +1278,27 @@ static inline void myri10ge_check_statblock(struct myri10ge_priv *mgp)
1234 1278
1235static int myri10ge_poll(struct napi_struct *napi, int budget) 1279static int myri10ge_poll(struct napi_struct *napi, int budget)
1236{ 1280{
1237 struct myri10ge_priv *mgp = 1281 struct myri10ge_slice_state *ss =
1238 container_of(napi, struct myri10ge_priv, napi); 1282 container_of(napi, struct myri10ge_slice_state, napi);
1239 struct net_device *netdev = mgp->dev; 1283 struct net_device *netdev = ss->mgp->dev;
1240 int work_done; 1284 int work_done;
1241 1285
1242 /* process as many rx events as NAPI will allow */ 1286 /* process as many rx events as NAPI will allow */
1243 work_done = myri10ge_clean_rx_done(mgp, budget); 1287 work_done = myri10ge_clean_rx_done(ss, budget);
1244 1288
1245 if (work_done < budget) { 1289 if (work_done < budget) {
1246 netif_rx_complete(netdev, napi); 1290 netif_rx_complete(netdev, napi);
1247 put_be32(htonl(3), mgp->irq_claim); 1291 put_be32(htonl(3), ss->irq_claim);
1248 } 1292 }
1249 return work_done; 1293 return work_done;
1250} 1294}
1251 1295
1252static irqreturn_t myri10ge_intr(int irq, void *arg) 1296static irqreturn_t myri10ge_intr(int irq, void *arg)
1253{ 1297{
1254 struct myri10ge_priv *mgp = arg; 1298 struct myri10ge_slice_state *ss = arg;
1255 struct mcp_irq_data *stats = mgp->fw_stats; 1299 struct myri10ge_priv *mgp = ss->mgp;
1256 struct myri10ge_tx_buf *tx = &mgp->tx; 1300 struct mcp_irq_data *stats = ss->fw_stats;
1301 struct myri10ge_tx_buf *tx = &ss->tx;
1257 u32 send_done_count; 1302 u32 send_done_count;
1258 int i; 1303 int i;
1259 1304
@@ -1264,7 +1309,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1264 /* low bit indicates receives are present, so schedule 1309 /* low bit indicates receives are present, so schedule
1265 * napi poll handler */ 1310 * napi poll handler */
1266 if (stats->valid & 1) 1311 if (stats->valid & 1)
1267 netif_rx_schedule(mgp->dev, &mgp->napi); 1312 netif_rx_schedule(ss->dev, &ss->napi);
1268 1313
1269 if (!mgp->msi_enabled) { 1314 if (!mgp->msi_enabled) {
1270 put_be32(0, mgp->irq_deassert); 1315 put_be32(0, mgp->irq_deassert);
@@ -1281,7 +1326,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1281 /* check for transmit completes and receives */ 1326 /* check for transmit completes and receives */
1282 send_done_count = ntohl(stats->send_done_count); 1327 send_done_count = ntohl(stats->send_done_count);
1283 if (send_done_count != tx->pkt_done) 1328 if (send_done_count != tx->pkt_done)
1284 myri10ge_tx_done(mgp, (int)send_done_count); 1329 myri10ge_tx_done(ss, (int)send_done_count);
1285 if (unlikely(i > myri10ge_max_irq_loops)) { 1330 if (unlikely(i > myri10ge_max_irq_loops)) {
1286 printk(KERN_WARNING "myri10ge: %s: irq stuck?\n", 1331 printk(KERN_WARNING "myri10ge: %s: irq stuck?\n",
1287 mgp->dev->name); 1332 mgp->dev->name);
@@ -1296,16 +1341,46 @@ static irqreturn_t myri10ge_intr(int irq, void *arg)
1296 1341
1297 myri10ge_check_statblock(mgp); 1342 myri10ge_check_statblock(mgp);
1298 1343
1299 put_be32(htonl(3), mgp->irq_claim + 1); 1344 put_be32(htonl(3), ss->irq_claim + 1);
1300 return (IRQ_HANDLED); 1345 return (IRQ_HANDLED);
1301} 1346}
1302 1347
1303static int 1348static int
1304myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) 1349myri10ge_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd)
1305{ 1350{
1351 struct myri10ge_priv *mgp = netdev_priv(netdev);
1352 char *ptr;
1353 int i;
1354
1306 cmd->autoneg = AUTONEG_DISABLE; 1355 cmd->autoneg = AUTONEG_DISABLE;
1307 cmd->speed = SPEED_10000; 1356 cmd->speed = SPEED_10000;
1308 cmd->duplex = DUPLEX_FULL; 1357 cmd->duplex = DUPLEX_FULL;
1358
1359 /*
1360 * parse the product code to deterimine the interface type
1361 * (CX4, XFP, Quad Ribbon Fiber) by looking at the character
1362 * after the 3rd dash in the driver's cached copy of the
1363 * EEPROM's product code string.
1364 */
1365 ptr = mgp->product_code_string;
1366 if (ptr == NULL) {
1367 printk(KERN_ERR "myri10ge: %s: Missing product code\n",
1368 netdev->name);
1369 return 0;
1370 }
1371 for (i = 0; i < 3; i++, ptr++) {
1372 ptr = strchr(ptr, '-');
1373 if (ptr == NULL) {
1374 printk(KERN_ERR "myri10ge: %s: Invalid product "
1375 "code %s\n", netdev->name,
1376 mgp->product_code_string);
1377 return 0;
1378 }
1379 }
1380 if (*ptr == 'R' || *ptr == 'Q') {
1381 /* We've found either an XFP or quad ribbon fiber */
1382 cmd->port = PORT_FIBRE;
1383 }
1309 return 0; 1384 return 0;
1310} 1385}
1311 1386
@@ -1324,6 +1399,7 @@ static int
1324myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal) 1399myri10ge_get_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal)
1325{ 1400{
1326 struct myri10ge_priv *mgp = netdev_priv(netdev); 1401 struct myri10ge_priv *mgp = netdev_priv(netdev);
1402
1327 coal->rx_coalesce_usecs = mgp->intr_coal_delay; 1403 coal->rx_coalesce_usecs = mgp->intr_coal_delay;
1328 return 0; 1404 return 0;
1329} 1405}
@@ -1370,10 +1446,10 @@ myri10ge_get_ringparam(struct net_device *netdev,
1370{ 1446{
1371 struct myri10ge_priv *mgp = netdev_priv(netdev); 1447 struct myri10ge_priv *mgp = netdev_priv(netdev);
1372 1448
1373 ring->rx_mini_max_pending = mgp->rx_small.mask + 1; 1449 ring->rx_mini_max_pending = mgp->ss.rx_small.mask + 1;
1374 ring->rx_max_pending = mgp->rx_big.mask + 1; 1450 ring->rx_max_pending = mgp->ss.rx_big.mask + 1;
1375 ring->rx_jumbo_max_pending = 0; 1451 ring->rx_jumbo_max_pending = 0;
1376 ring->tx_max_pending = mgp->rx_small.mask + 1; 1452 ring->tx_max_pending = mgp->ss.rx_small.mask + 1;
1377 ring->rx_mini_pending = ring->rx_mini_max_pending; 1453 ring->rx_mini_pending = ring->rx_mini_max_pending;
1378 ring->rx_pending = ring->rx_max_pending; 1454 ring->rx_pending = ring->rx_max_pending;
1379 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending; 1455 ring->rx_jumbo_pending = ring->rx_jumbo_max_pending;
@@ -1383,6 +1459,7 @@ myri10ge_get_ringparam(struct net_device *netdev,
1383static u32 myri10ge_get_rx_csum(struct net_device *netdev) 1459static u32 myri10ge_get_rx_csum(struct net_device *netdev)
1384{ 1460{
1385 struct myri10ge_priv *mgp = netdev_priv(netdev); 1461 struct myri10ge_priv *mgp = netdev_priv(netdev);
1462
1386 if (mgp->csum_flag) 1463 if (mgp->csum_flag)
1387 return 1; 1464 return 1;
1388 else 1465 else
@@ -1392,6 +1469,7 @@ static u32 myri10ge_get_rx_csum(struct net_device *netdev)
1392static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled) 1469static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
1393{ 1470{
1394 struct myri10ge_priv *mgp = netdev_priv(netdev); 1471 struct myri10ge_priv *mgp = netdev_priv(netdev);
1472
1395 if (csum_enabled) 1473 if (csum_enabled)
1396 mgp->csum_flag = MXGEFW_FLAGS_CKSUM; 1474 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
1397 else 1475 else
@@ -1411,7 +1489,7 @@ static int myri10ge_set_tso(struct net_device *netdev, u32 tso_enabled)
1411 return 0; 1489 return 0;
1412} 1490}
1413 1491
1414static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = { 1492static const char myri10ge_gstrings_main_stats[][ETH_GSTRING_LEN] = {
1415 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors", 1493 "rx_packets", "tx_packets", "rx_bytes", "tx_bytes", "rx_errors",
1416 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions", 1494 "tx_errors", "rx_dropped", "tx_dropped", "multicast", "collisions",
1417 "rx_length_errors", "rx_over_errors", "rx_crc_errors", 1495 "rx_length_errors", "rx_over_errors", "rx_crc_errors",
@@ -1421,28 +1499,39 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = {
1421 /* device-specific stats */ 1499 /* device-specific stats */
1422 "tx_boundary", "WC", "irq", "MSI", 1500 "tx_boundary", "WC", "irq", "MSI",
1423 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs", 1501 "read_dma_bw_MBs", "write_dma_bw_MBs", "read_write_dma_bw_MBs",
1424 "serial_number", "tx_pkt_start", "tx_pkt_done", 1502 "serial_number", "watchdog_resets",
1425 "tx_req", "tx_done", "rx_small_cnt", "rx_big_cnt",
1426 "wake_queue", "stop_queue", "watchdog_resets", "tx_linearized",
1427 "link_changes", "link_up", "dropped_link_overflow", 1503 "link_changes", "link_up", "dropped_link_overflow",
1428 "dropped_link_error_or_filtered", 1504 "dropped_link_error_or_filtered",
1429 "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32", 1505 "dropped_pause", "dropped_bad_phy", "dropped_bad_crc32",
1430 "dropped_unicast_filtered", "dropped_multicast_filtered", 1506 "dropped_unicast_filtered", "dropped_multicast_filtered",
1431 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer", 1507 "dropped_runt", "dropped_overrun", "dropped_no_small_buffer",
1432 "dropped_no_big_buffer", "LRO aggregated", "LRO flushed", 1508 "dropped_no_big_buffer"
1509};
1510
1511static const char myri10ge_gstrings_slice_stats[][ETH_GSTRING_LEN] = {
1512 "----------- slice ---------",
1513 "tx_pkt_start", "tx_pkt_done", "tx_req", "tx_done",
1514 "rx_small_cnt", "rx_big_cnt",
1515 "wake_queue", "stop_queue", "tx_linearized", "LRO aggregated",
1516 "LRO flushed",
1433 "LRO avg aggr", "LRO no_desc" 1517 "LRO avg aggr", "LRO no_desc"
1434}; 1518};
1435 1519
1436#define MYRI10GE_NET_STATS_LEN 21 1520#define MYRI10GE_NET_STATS_LEN 21
1437#define MYRI10GE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_stats) 1521#define MYRI10GE_MAIN_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_main_stats)
1522#define MYRI10GE_SLICE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_slice_stats)
1438 1523
1439static void 1524static void
1440myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) 1525myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data)
1441{ 1526{
1442 switch (stringset) { 1527 switch (stringset) {
1443 case ETH_SS_STATS: 1528 case ETH_SS_STATS:
1444 memcpy(data, *myri10ge_gstrings_stats, 1529 memcpy(data, *myri10ge_gstrings_main_stats,
1445 sizeof(myri10ge_gstrings_stats)); 1530 sizeof(myri10ge_gstrings_main_stats));
1531 data += sizeof(myri10ge_gstrings_main_stats);
1532 memcpy(data, *myri10ge_gstrings_slice_stats,
1533 sizeof(myri10ge_gstrings_slice_stats));
1534 data += sizeof(myri10ge_gstrings_slice_stats);
1446 break; 1535 break;
1447 } 1536 }
1448} 1537}
@@ -1451,7 +1540,7 @@ static int myri10ge_get_sset_count(struct net_device *netdev, int sset)
1451{ 1540{
1452 switch (sset) { 1541 switch (sset) {
1453 case ETH_SS_STATS: 1542 case ETH_SS_STATS:
1454 return MYRI10GE_STATS_LEN; 1543 return MYRI10GE_MAIN_STATS_LEN + MYRI10GE_SLICE_STATS_LEN;
1455 default: 1544 default:
1456 return -EOPNOTSUPP; 1545 return -EOPNOTSUPP;
1457 } 1546 }
@@ -1462,12 +1551,13 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
1462 struct ethtool_stats *stats, u64 * data) 1551 struct ethtool_stats *stats, u64 * data)
1463{ 1552{
1464 struct myri10ge_priv *mgp = netdev_priv(netdev); 1553 struct myri10ge_priv *mgp = netdev_priv(netdev);
1554 struct myri10ge_slice_state *ss;
1465 int i; 1555 int i;
1466 1556
1467 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++) 1557 for (i = 0; i < MYRI10GE_NET_STATS_LEN; i++)
1468 data[i] = ((unsigned long *)&mgp->stats)[i]; 1558 data[i] = ((unsigned long *)&mgp->stats)[i];
1469 1559
1470 data[i++] = (unsigned int)mgp->tx.boundary; 1560 data[i++] = (unsigned int)mgp->tx_boundary;
1471 data[i++] = (unsigned int)mgp->wc_enabled; 1561 data[i++] = (unsigned int)mgp->wc_enabled;
1472 data[i++] = (unsigned int)mgp->pdev->irq; 1562 data[i++] = (unsigned int)mgp->pdev->irq;
1473 data[i++] = (unsigned int)mgp->msi_enabled; 1563 data[i++] = (unsigned int)mgp->msi_enabled;
@@ -1475,40 +1565,44 @@ myri10ge_get_ethtool_stats(struct net_device *netdev,
1475 data[i++] = (unsigned int)mgp->write_dma; 1565 data[i++] = (unsigned int)mgp->write_dma;
1476 data[i++] = (unsigned int)mgp->read_write_dma; 1566 data[i++] = (unsigned int)mgp->read_write_dma;
1477 data[i++] = (unsigned int)mgp->serial_number; 1567 data[i++] = (unsigned int)mgp->serial_number;
1478 data[i++] = (unsigned int)mgp->tx.pkt_start;
1479 data[i++] = (unsigned int)mgp->tx.pkt_done;
1480 data[i++] = (unsigned int)mgp->tx.req;
1481 data[i++] = (unsigned int)mgp->tx.done;
1482 data[i++] = (unsigned int)mgp->rx_small.cnt;
1483 data[i++] = (unsigned int)mgp->rx_big.cnt;
1484 data[i++] = (unsigned int)mgp->wake_queue;
1485 data[i++] = (unsigned int)mgp->stop_queue;
1486 data[i++] = (unsigned int)mgp->watchdog_resets; 1568 data[i++] = (unsigned int)mgp->watchdog_resets;
1487 data[i++] = (unsigned int)mgp->tx_linearized;
1488 data[i++] = (unsigned int)mgp->link_changes; 1569 data[i++] = (unsigned int)mgp->link_changes;
1489 data[i++] = (unsigned int)ntohl(mgp->fw_stats->link_up); 1570
1490 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_link_overflow); 1571 /* firmware stats are useful only in the first slice */
1491 data[i++] = 1572 ss = &mgp->ss;
1492 (unsigned int)ntohl(mgp->fw_stats->dropped_link_error_or_filtered); 1573 data[i++] = (unsigned int)ntohl(ss->fw_stats->link_up);
1493 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_pause); 1574 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_link_overflow);
1494 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_phy);
1495 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_bad_crc32);
1496 data[i++] = 1575 data[i++] =
1497 (unsigned int)ntohl(mgp->fw_stats->dropped_unicast_filtered); 1576 (unsigned int)ntohl(ss->fw_stats->dropped_link_error_or_filtered);
1577 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_pause);
1578 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_phy);
1579 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_bad_crc32);
1580 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_unicast_filtered);
1498 data[i++] = 1581 data[i++] =
1499 (unsigned int)ntohl(mgp->fw_stats->dropped_multicast_filtered); 1582 (unsigned int)ntohl(ss->fw_stats->dropped_multicast_filtered);
1500 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_runt); 1583 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_runt);
1501 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_overrun); 1584 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_overrun);
1502 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_small_buffer); 1585 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_small_buffer);
1503 data[i++] = (unsigned int)ntohl(mgp->fw_stats->dropped_no_big_buffer); 1586 data[i++] = (unsigned int)ntohl(ss->fw_stats->dropped_no_big_buffer);
1504 data[i++] = mgp->rx_done.lro_mgr.stats.aggregated; 1587
1505 data[i++] = mgp->rx_done.lro_mgr.stats.flushed; 1588 data[i++] = 0;
1506 if (mgp->rx_done.lro_mgr.stats.flushed) 1589 data[i++] = (unsigned int)ss->tx.pkt_start;
1507 data[i++] = mgp->rx_done.lro_mgr.stats.aggregated / 1590 data[i++] = (unsigned int)ss->tx.pkt_done;
1508 mgp->rx_done.lro_mgr.stats.flushed; 1591 data[i++] = (unsigned int)ss->tx.req;
1592 data[i++] = (unsigned int)ss->tx.done;
1593 data[i++] = (unsigned int)ss->rx_small.cnt;
1594 data[i++] = (unsigned int)ss->rx_big.cnt;
1595 data[i++] = (unsigned int)ss->tx.wake_queue;
1596 data[i++] = (unsigned int)ss->tx.stop_queue;
1597 data[i++] = (unsigned int)ss->tx.linearized;
1598 data[i++] = ss->rx_done.lro_mgr.stats.aggregated;
1599 data[i++] = ss->rx_done.lro_mgr.stats.flushed;
1600 if (ss->rx_done.lro_mgr.stats.flushed)
1601 data[i++] = ss->rx_done.lro_mgr.stats.aggregated /
1602 ss->rx_done.lro_mgr.stats.flushed;
1509 else 1603 else
1510 data[i++] = 0; 1604 data[i++] = 0;
1511 data[i++] = mgp->rx_done.lro_mgr.stats.no_desc; 1605 data[i++] = ss->rx_done.lro_mgr.stats.no_desc;
1512} 1606}
1513 1607
1514static void myri10ge_set_msglevel(struct net_device *netdev, u32 value) 1608static void myri10ge_set_msglevel(struct net_device *netdev, u32 value)
@@ -1544,19 +1638,17 @@ static const struct ethtool_ops myri10ge_ethtool_ops = {
1544 .get_msglevel = myri10ge_get_msglevel 1638 .get_msglevel = myri10ge_get_msglevel
1545}; 1639};
1546 1640
1547static int myri10ge_allocate_rings(struct net_device *dev) 1641static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss)
1548{ 1642{
1549 struct myri10ge_priv *mgp; 1643 struct myri10ge_priv *mgp = ss->mgp;
1550 struct myri10ge_cmd cmd; 1644 struct myri10ge_cmd cmd;
1645 struct net_device *dev = mgp->dev;
1551 int tx_ring_size, rx_ring_size; 1646 int tx_ring_size, rx_ring_size;
1552 int tx_ring_entries, rx_ring_entries; 1647 int tx_ring_entries, rx_ring_entries;
1553 int i, status; 1648 int i, status;
1554 size_t bytes; 1649 size_t bytes;
1555 1650
1556 mgp = netdev_priv(dev);
1557
1558 /* get ring sizes */ 1651 /* get ring sizes */
1559
1560 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0); 1652 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_RING_SIZE, &cmd, 0);
1561 tx_ring_size = cmd.data0; 1653 tx_ring_size = cmd.data0;
1562 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0); 1654 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_RX_RING_SIZE, &cmd, 0);
@@ -1566,144 +1658,142 @@ static int myri10ge_allocate_rings(struct net_device *dev)
1566 1658
1567 tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send); 1659 tx_ring_entries = tx_ring_size / sizeof(struct mcp_kreq_ether_send);
1568 rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr); 1660 rx_ring_entries = rx_ring_size / sizeof(struct mcp_dma_addr);
1569 mgp->tx.mask = tx_ring_entries - 1; 1661 ss->tx.mask = tx_ring_entries - 1;
1570 mgp->rx_small.mask = mgp->rx_big.mask = rx_ring_entries - 1; 1662 ss->rx_small.mask = ss->rx_big.mask = rx_ring_entries - 1;
1571 1663
1572 status = -ENOMEM; 1664 status = -ENOMEM;
1573 1665
1574 /* allocate the host shadow rings */ 1666 /* allocate the host shadow rings */
1575 1667
1576 bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4) 1668 bytes = 8 + (MYRI10GE_MAX_SEND_DESC_TSO + 4)
1577 * sizeof(*mgp->tx.req_list); 1669 * sizeof(*ss->tx.req_list);
1578 mgp->tx.req_bytes = kzalloc(bytes, GFP_KERNEL); 1670 ss->tx.req_bytes = kzalloc(bytes, GFP_KERNEL);
1579 if (mgp->tx.req_bytes == NULL) 1671 if (ss->tx.req_bytes == NULL)
1580 goto abort_with_nothing; 1672 goto abort_with_nothing;
1581 1673
1582 /* ensure req_list entries are aligned to 8 bytes */ 1674 /* ensure req_list entries are aligned to 8 bytes */
1583 mgp->tx.req_list = (struct mcp_kreq_ether_send *) 1675 ss->tx.req_list = (struct mcp_kreq_ether_send *)
1584 ALIGN((unsigned long)mgp->tx.req_bytes, 8); 1676 ALIGN((unsigned long)ss->tx.req_bytes, 8);
1585 1677
1586 bytes = rx_ring_entries * sizeof(*mgp->rx_small.shadow); 1678 bytes = rx_ring_entries * sizeof(*ss->rx_small.shadow);
1587 mgp->rx_small.shadow = kzalloc(bytes, GFP_KERNEL); 1679 ss->rx_small.shadow = kzalloc(bytes, GFP_KERNEL);
1588 if (mgp->rx_small.shadow == NULL) 1680 if (ss->rx_small.shadow == NULL)
1589 goto abort_with_tx_req_bytes; 1681 goto abort_with_tx_req_bytes;
1590 1682
1591 bytes = rx_ring_entries * sizeof(*mgp->rx_big.shadow); 1683 bytes = rx_ring_entries * sizeof(*ss->rx_big.shadow);
1592 mgp->rx_big.shadow = kzalloc(bytes, GFP_KERNEL); 1684 ss->rx_big.shadow = kzalloc(bytes, GFP_KERNEL);
1593 if (mgp->rx_big.shadow == NULL) 1685 if (ss->rx_big.shadow == NULL)
1594 goto abort_with_rx_small_shadow; 1686 goto abort_with_rx_small_shadow;
1595 1687
1596 /* allocate the host info rings */ 1688 /* allocate the host info rings */
1597 1689
1598 bytes = tx_ring_entries * sizeof(*mgp->tx.info); 1690 bytes = tx_ring_entries * sizeof(*ss->tx.info);
1599 mgp->tx.info = kzalloc(bytes, GFP_KERNEL); 1691 ss->tx.info = kzalloc(bytes, GFP_KERNEL);
1600 if (mgp->tx.info == NULL) 1692 if (ss->tx.info == NULL)
1601 goto abort_with_rx_big_shadow; 1693 goto abort_with_rx_big_shadow;
1602 1694
1603 bytes = rx_ring_entries * sizeof(*mgp->rx_small.info); 1695 bytes = rx_ring_entries * sizeof(*ss->rx_small.info);
1604 mgp->rx_small.info = kzalloc(bytes, GFP_KERNEL); 1696 ss->rx_small.info = kzalloc(bytes, GFP_KERNEL);
1605 if (mgp->rx_small.info == NULL) 1697 if (ss->rx_small.info == NULL)
1606 goto abort_with_tx_info; 1698 goto abort_with_tx_info;
1607 1699
1608 bytes = rx_ring_entries * sizeof(*mgp->rx_big.info); 1700 bytes = rx_ring_entries * sizeof(*ss->rx_big.info);
1609 mgp->rx_big.info = kzalloc(bytes, GFP_KERNEL); 1701 ss->rx_big.info = kzalloc(bytes, GFP_KERNEL);
1610 if (mgp->rx_big.info == NULL) 1702 if (ss->rx_big.info == NULL)
1611 goto abort_with_rx_small_info; 1703 goto abort_with_rx_small_info;
1612 1704
1613 /* Fill the receive rings */ 1705 /* Fill the receive rings */
1614 mgp->rx_big.cnt = 0; 1706 ss->rx_big.cnt = 0;
1615 mgp->rx_small.cnt = 0; 1707 ss->rx_small.cnt = 0;
1616 mgp->rx_big.fill_cnt = 0; 1708 ss->rx_big.fill_cnt = 0;
1617 mgp->rx_small.fill_cnt = 0; 1709 ss->rx_small.fill_cnt = 0;
1618 mgp->rx_small.page_offset = MYRI10GE_ALLOC_SIZE; 1710 ss->rx_small.page_offset = MYRI10GE_ALLOC_SIZE;
1619 mgp->rx_big.page_offset = MYRI10GE_ALLOC_SIZE; 1711 ss->rx_big.page_offset = MYRI10GE_ALLOC_SIZE;
1620 mgp->rx_small.watchdog_needed = 0; 1712 ss->rx_small.watchdog_needed = 0;
1621 mgp->rx_big.watchdog_needed = 0; 1713 ss->rx_big.watchdog_needed = 0;
1622 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 1714 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
1623 mgp->small_bytes + MXGEFW_PAD, 0); 1715 mgp->small_bytes + MXGEFW_PAD, 0);
1624 1716
1625 if (mgp->rx_small.fill_cnt < mgp->rx_small.mask + 1) { 1717 if (ss->rx_small.fill_cnt < ss->rx_small.mask + 1) {
1626 printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n", 1718 printk(KERN_ERR "myri10ge: %s: alloced only %d small bufs\n",
1627 dev->name, mgp->rx_small.fill_cnt); 1719 dev->name, ss->rx_small.fill_cnt);
1628 goto abort_with_rx_small_ring; 1720 goto abort_with_rx_small_ring;
1629 } 1721 }
1630 1722
1631 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 0); 1723 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 0);
1632 if (mgp->rx_big.fill_cnt < mgp->rx_big.mask + 1) { 1724 if (ss->rx_big.fill_cnt < ss->rx_big.mask + 1) {
1633 printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n", 1725 printk(KERN_ERR "myri10ge: %s: alloced only %d big bufs\n",
1634 dev->name, mgp->rx_big.fill_cnt); 1726 dev->name, ss->rx_big.fill_cnt);
1635 goto abort_with_rx_big_ring; 1727 goto abort_with_rx_big_ring;
1636 } 1728 }
1637 1729
1638 return 0; 1730 return 0;
1639 1731
1640abort_with_rx_big_ring: 1732abort_with_rx_big_ring:
1641 for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { 1733 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
1642 int idx = i & mgp->rx_big.mask; 1734 int idx = i & ss->rx_big.mask;
1643 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx], 1735 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
1644 mgp->big_bytes); 1736 mgp->big_bytes);
1645 put_page(mgp->rx_big.info[idx].page); 1737 put_page(ss->rx_big.info[idx].page);
1646 } 1738 }
1647 1739
1648abort_with_rx_small_ring: 1740abort_with_rx_small_ring:
1649 for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { 1741 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
1650 int idx = i & mgp->rx_small.mask; 1742 int idx = i & ss->rx_small.mask;
1651 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], 1743 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
1652 mgp->small_bytes + MXGEFW_PAD); 1744 mgp->small_bytes + MXGEFW_PAD);
1653 put_page(mgp->rx_small.info[idx].page); 1745 put_page(ss->rx_small.info[idx].page);
1654 } 1746 }
1655 1747
1656 kfree(mgp->rx_big.info); 1748 kfree(ss->rx_big.info);
1657 1749
1658abort_with_rx_small_info: 1750abort_with_rx_small_info:
1659 kfree(mgp->rx_small.info); 1751 kfree(ss->rx_small.info);
1660 1752
1661abort_with_tx_info: 1753abort_with_tx_info:
1662 kfree(mgp->tx.info); 1754 kfree(ss->tx.info);
1663 1755
1664abort_with_rx_big_shadow: 1756abort_with_rx_big_shadow:
1665 kfree(mgp->rx_big.shadow); 1757 kfree(ss->rx_big.shadow);
1666 1758
1667abort_with_rx_small_shadow: 1759abort_with_rx_small_shadow:
1668 kfree(mgp->rx_small.shadow); 1760 kfree(ss->rx_small.shadow);
1669 1761
1670abort_with_tx_req_bytes: 1762abort_with_tx_req_bytes:
1671 kfree(mgp->tx.req_bytes); 1763 kfree(ss->tx.req_bytes);
1672 mgp->tx.req_bytes = NULL; 1764 ss->tx.req_bytes = NULL;
1673 mgp->tx.req_list = NULL; 1765 ss->tx.req_list = NULL;
1674 1766
1675abort_with_nothing: 1767abort_with_nothing:
1676 return status; 1768 return status;
1677} 1769}
1678 1770
1679static void myri10ge_free_rings(struct net_device *dev) 1771static void myri10ge_free_rings(struct myri10ge_slice_state *ss)
1680{ 1772{
1681 struct myri10ge_priv *mgp; 1773 struct myri10ge_priv *mgp = ss->mgp;
1682 struct sk_buff *skb; 1774 struct sk_buff *skb;
1683 struct myri10ge_tx_buf *tx; 1775 struct myri10ge_tx_buf *tx;
1684 int i, len, idx; 1776 int i, len, idx;
1685 1777
1686 mgp = netdev_priv(dev); 1778 for (i = ss->rx_big.cnt; i < ss->rx_big.fill_cnt; i++) {
1687 1779 idx = i & ss->rx_big.mask;
1688 for (i = mgp->rx_big.cnt; i < mgp->rx_big.fill_cnt; i++) { 1780 if (i == ss->rx_big.fill_cnt - 1)
1689 idx = i & mgp->rx_big.mask; 1781 ss->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE;
1690 if (i == mgp->rx_big.fill_cnt - 1) 1782 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_big.info[idx],
1691 mgp->rx_big.info[idx].page_offset = MYRI10GE_ALLOC_SIZE;
1692 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_big.info[idx],
1693 mgp->big_bytes); 1783 mgp->big_bytes);
1694 put_page(mgp->rx_big.info[idx].page); 1784 put_page(ss->rx_big.info[idx].page);
1695 } 1785 }
1696 1786
1697 for (i = mgp->rx_small.cnt; i < mgp->rx_small.fill_cnt; i++) { 1787 for (i = ss->rx_small.cnt; i < ss->rx_small.fill_cnt; i++) {
1698 idx = i & mgp->rx_small.mask; 1788 idx = i & ss->rx_small.mask;
1699 if (i == mgp->rx_small.fill_cnt - 1) 1789 if (i == ss->rx_small.fill_cnt - 1)
1700 mgp->rx_small.info[idx].page_offset = 1790 ss->rx_small.info[idx].page_offset =
1701 MYRI10GE_ALLOC_SIZE; 1791 MYRI10GE_ALLOC_SIZE;
1702 myri10ge_unmap_rx_page(mgp->pdev, &mgp->rx_small.info[idx], 1792 myri10ge_unmap_rx_page(mgp->pdev, &ss->rx_small.info[idx],
1703 mgp->small_bytes + MXGEFW_PAD); 1793 mgp->small_bytes + MXGEFW_PAD);
1704 put_page(mgp->rx_small.info[idx].page); 1794 put_page(ss->rx_small.info[idx].page);
1705 } 1795 }
1706 tx = &mgp->tx; 1796 tx = &ss->tx;
1707 while (tx->done != tx->req) { 1797 while (tx->done != tx->req) {
1708 idx = tx->done & tx->mask; 1798 idx = tx->done & tx->mask;
1709 skb = tx->info[idx].skb; 1799 skb = tx->info[idx].skb;
@@ -1714,7 +1804,7 @@ static void myri10ge_free_rings(struct net_device *dev)
1714 len = pci_unmap_len(&tx->info[idx], len); 1804 len = pci_unmap_len(&tx->info[idx], len);
1715 pci_unmap_len_set(&tx->info[idx], len, 0); 1805 pci_unmap_len_set(&tx->info[idx], len, 0);
1716 if (skb) { 1806 if (skb) {
1717 mgp->stats.tx_dropped++; 1807 ss->stats.tx_dropped++;
1718 dev_kfree_skb_any(skb); 1808 dev_kfree_skb_any(skb);
1719 if (len) 1809 if (len)
1720 pci_unmap_single(mgp->pdev, 1810 pci_unmap_single(mgp->pdev,
@@ -1729,19 +1819,19 @@ static void myri10ge_free_rings(struct net_device *dev)
1729 PCI_DMA_TODEVICE); 1819 PCI_DMA_TODEVICE);
1730 } 1820 }
1731 } 1821 }
1732 kfree(mgp->rx_big.info); 1822 kfree(ss->rx_big.info);
1733 1823
1734 kfree(mgp->rx_small.info); 1824 kfree(ss->rx_small.info);
1735 1825
1736 kfree(mgp->tx.info); 1826 kfree(ss->tx.info);
1737 1827
1738 kfree(mgp->rx_big.shadow); 1828 kfree(ss->rx_big.shadow);
1739 1829
1740 kfree(mgp->rx_small.shadow); 1830 kfree(ss->rx_small.shadow);
1741 1831
1742 kfree(mgp->tx.req_bytes); 1832 kfree(ss->tx.req_bytes);
1743 mgp->tx.req_bytes = NULL; 1833 ss->tx.req_bytes = NULL;
1744 mgp->tx.req_list = NULL; 1834 ss->tx.req_list = NULL;
1745} 1835}
1746 1836
1747static int myri10ge_request_irq(struct myri10ge_priv *mgp) 1837static int myri10ge_request_irq(struct myri10ge_priv *mgp)
@@ -1840,13 +1930,11 @@ myri10ge_get_frag_header(struct skb_frag_struct *frag, void **mac_hdr,
1840 1930
1841static int myri10ge_open(struct net_device *dev) 1931static int myri10ge_open(struct net_device *dev)
1842{ 1932{
1843 struct myri10ge_priv *mgp; 1933 struct myri10ge_priv *mgp = netdev_priv(dev);
1844 struct myri10ge_cmd cmd; 1934 struct myri10ge_cmd cmd;
1845 struct net_lro_mgr *lro_mgr; 1935 struct net_lro_mgr *lro_mgr;
1846 int status, big_pow2; 1936 int status, big_pow2;
1847 1937
1848 mgp = netdev_priv(dev);
1849
1850 if (mgp->running != MYRI10GE_ETH_STOPPED) 1938 if (mgp->running != MYRI10GE_ETH_STOPPED)
1851 return -EBUSY; 1939 return -EBUSY;
1852 1940
@@ -1883,16 +1971,16 @@ static int myri10ge_open(struct net_device *dev)
1883 /* get the lanai pointers to the send and receive rings */ 1971 /* get the lanai pointers to the send and receive rings */
1884 1972
1885 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0); 1973 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SEND_OFFSET, &cmd, 0);
1886 mgp->tx.lanai = 1974 mgp->ss.tx.lanai =
1887 (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0); 1975 (struct mcp_kreq_ether_send __iomem *)(mgp->sram + cmd.data0);
1888 1976
1889 status |= 1977 status |=
1890 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0); 1978 myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_SMALL_RX_OFFSET, &cmd, 0);
1891 mgp->rx_small.lanai = 1979 mgp->ss.rx_small.lanai =
1892 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); 1980 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1893 1981
1894 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0); 1982 status |= myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_BIG_RX_OFFSET, &cmd, 0);
1895 mgp->rx_big.lanai = 1983 mgp->ss.rx_big.lanai =
1896 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0); 1984 (struct mcp_kreq_ether_recv __iomem *)(mgp->sram + cmd.data0);
1897 1985
1898 if (status != 0) { 1986 if (status != 0) {
@@ -1904,15 +1992,15 @@ static int myri10ge_open(struct net_device *dev)
1904 } 1992 }
1905 1993
1906 if (myri10ge_wcfifo && mgp->wc_enabled) { 1994 if (myri10ge_wcfifo && mgp->wc_enabled) {
1907 mgp->tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4; 1995 mgp->ss.tx.wc_fifo = (u8 __iomem *) mgp->sram + MXGEFW_ETH_SEND_4;
1908 mgp->rx_small.wc_fifo = 1996 mgp->ss.rx_small.wc_fifo =
1909 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL; 1997 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_SMALL;
1910 mgp->rx_big.wc_fifo = 1998 mgp->ss.rx_big.wc_fifo =
1911 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG; 1999 (u8 __iomem *) mgp->sram + MXGEFW_ETH_RECV_BIG;
1912 } else { 2000 } else {
1913 mgp->tx.wc_fifo = NULL; 2001 mgp->ss.tx.wc_fifo = NULL;
1914 mgp->rx_small.wc_fifo = NULL; 2002 mgp->ss.rx_small.wc_fifo = NULL;
1915 mgp->rx_big.wc_fifo = NULL; 2003 mgp->ss.rx_big.wc_fifo = NULL;
1916 } 2004 }
1917 2005
1918 /* Firmware needs the big buff size as a power of 2. Lie and 2006 /* Firmware needs the big buff size as a power of 2. Lie and
@@ -1929,7 +2017,7 @@ static int myri10ge_open(struct net_device *dev)
1929 mgp->big_bytes = big_pow2; 2017 mgp->big_bytes = big_pow2;
1930 } 2018 }
1931 2019
1932 status = myri10ge_allocate_rings(dev); 2020 status = myri10ge_allocate_rings(&mgp->ss);
1933 if (status != 0) 2021 if (status != 0)
1934 goto abort_with_irq; 2022 goto abort_with_irq;
1935 2023
@@ -1948,12 +2036,12 @@ static int myri10ge_open(struct net_device *dev)
1948 goto abort_with_rings; 2036 goto abort_with_rings;
1949 } 2037 }
1950 2038
1951 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->fw_stats_bus); 2039 cmd.data0 = MYRI10GE_LOWPART_TO_U32(mgp->ss.fw_stats_bus);
1952 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->fw_stats_bus); 2040 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(mgp->ss.fw_stats_bus);
1953 cmd.data2 = sizeof(struct mcp_irq_data); 2041 cmd.data2 = sizeof(struct mcp_irq_data);
1954 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0); 2042 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_SET_STATS_DMA_V2, &cmd, 0);
1955 if (status == -ENOSYS) { 2043 if (status == -ENOSYS) {
1956 dma_addr_t bus = mgp->fw_stats_bus; 2044 dma_addr_t bus = mgp->ss.fw_stats_bus;
1957 bus += offsetof(struct mcp_irq_data, send_done_count); 2045 bus += offsetof(struct mcp_irq_data, send_done_count);
1958 cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus); 2046 cmd.data0 = MYRI10GE_LOWPART_TO_U32(bus);
1959 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus); 2047 cmd.data1 = MYRI10GE_HIGHPART_TO_U32(bus);
@@ -1974,20 +2062,20 @@ static int myri10ge_open(struct net_device *dev)
1974 mgp->link_state = ~0U; 2062 mgp->link_state = ~0U;
1975 mgp->rdma_tags_available = 15; 2063 mgp->rdma_tags_available = 15;
1976 2064
1977 lro_mgr = &mgp->rx_done.lro_mgr; 2065 lro_mgr = &mgp->ss.rx_done.lro_mgr;
1978 lro_mgr->dev = dev; 2066 lro_mgr->dev = dev;
1979 lro_mgr->features = LRO_F_NAPI; 2067 lro_mgr->features = LRO_F_NAPI;
1980 lro_mgr->ip_summed = CHECKSUM_COMPLETE; 2068 lro_mgr->ip_summed = CHECKSUM_COMPLETE;
1981 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY; 2069 lro_mgr->ip_summed_aggr = CHECKSUM_UNNECESSARY;
1982 lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS; 2070 lro_mgr->max_desc = MYRI10GE_MAX_LRO_DESCRIPTORS;
1983 lro_mgr->lro_arr = mgp->rx_done.lro_desc; 2071 lro_mgr->lro_arr = mgp->ss.rx_done.lro_desc;
1984 lro_mgr->get_frag_header = myri10ge_get_frag_header; 2072 lro_mgr->get_frag_header = myri10ge_get_frag_header;
1985 lro_mgr->max_aggr = myri10ge_lro_max_pkts; 2073 lro_mgr->max_aggr = myri10ge_lro_max_pkts;
1986 lro_mgr->frag_align_pad = 2; 2074 lro_mgr->frag_align_pad = 2;
1987 if (lro_mgr->max_aggr > MAX_SKB_FRAGS) 2075 if (lro_mgr->max_aggr > MAX_SKB_FRAGS)
1988 lro_mgr->max_aggr = MAX_SKB_FRAGS; 2076 lro_mgr->max_aggr = MAX_SKB_FRAGS;
1989 2077
1990 napi_enable(&mgp->napi); /* must happen prior to any irq */ 2078 napi_enable(&mgp->ss.napi); /* must happen prior to any irq */
1991 2079
1992 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0); 2080 status = myri10ge_send_cmd(mgp, MXGEFW_CMD_ETHERNET_UP, &cmd, 0);
1993 if (status) { 2081 if (status) {
@@ -1996,8 +2084,8 @@ static int myri10ge_open(struct net_device *dev)
1996 goto abort_with_rings; 2084 goto abort_with_rings;
1997 } 2085 }
1998 2086
1999 mgp->wake_queue = 0; 2087 mgp->ss.tx.wake_queue = 0;
2000 mgp->stop_queue = 0; 2088 mgp->ss.tx.stop_queue = 0;
2001 mgp->running = MYRI10GE_ETH_RUNNING; 2089 mgp->running = MYRI10GE_ETH_RUNNING;
2002 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ; 2090 mgp->watchdog_timer.expires = jiffies + myri10ge_watchdog_timeout * HZ;
2003 add_timer(&mgp->watchdog_timer); 2091 add_timer(&mgp->watchdog_timer);
@@ -2005,7 +2093,7 @@ static int myri10ge_open(struct net_device *dev)
2005 return 0; 2093 return 0;
2006 2094
2007abort_with_rings: 2095abort_with_rings:
2008 myri10ge_free_rings(dev); 2096 myri10ge_free_rings(&mgp->ss);
2009 2097
2010abort_with_irq: 2098abort_with_irq:
2011 myri10ge_free_irq(mgp); 2099 myri10ge_free_irq(mgp);
@@ -2017,21 +2105,19 @@ abort_with_nothing:
2017 2105
2018static int myri10ge_close(struct net_device *dev) 2106static int myri10ge_close(struct net_device *dev)
2019{ 2107{
2020 struct myri10ge_priv *mgp; 2108 struct myri10ge_priv *mgp = netdev_priv(dev);
2021 struct myri10ge_cmd cmd; 2109 struct myri10ge_cmd cmd;
2022 int status, old_down_cnt; 2110 int status, old_down_cnt;
2023 2111
2024 mgp = netdev_priv(dev);
2025
2026 if (mgp->running != MYRI10GE_ETH_RUNNING) 2112 if (mgp->running != MYRI10GE_ETH_RUNNING)
2027 return 0; 2113 return 0;
2028 2114
2029 if (mgp->tx.req_bytes == NULL) 2115 if (mgp->ss.tx.req_bytes == NULL)
2030 return 0; 2116 return 0;
2031 2117
2032 del_timer_sync(&mgp->watchdog_timer); 2118 del_timer_sync(&mgp->watchdog_timer);
2033 mgp->running = MYRI10GE_ETH_STOPPING; 2119 mgp->running = MYRI10GE_ETH_STOPPING;
2034 napi_disable(&mgp->napi); 2120 napi_disable(&mgp->ss.napi);
2035 netif_carrier_off(dev); 2121 netif_carrier_off(dev);
2036 netif_stop_queue(dev); 2122 netif_stop_queue(dev);
2037 old_down_cnt = mgp->down_cnt; 2123 old_down_cnt = mgp->down_cnt;
@@ -2047,7 +2133,7 @@ static int myri10ge_close(struct net_device *dev)
2047 2133
2048 netif_tx_disable(dev); 2134 netif_tx_disable(dev);
2049 myri10ge_free_irq(mgp); 2135 myri10ge_free_irq(mgp);
2050 myri10ge_free_rings(dev); 2136 myri10ge_free_rings(&mgp->ss);
2051 2137
2052 mgp->running = MYRI10GE_ETH_STOPPED; 2138 mgp->running = MYRI10GE_ETH_STOPPED;
2053 return 0; 2139 return 0;
@@ -2143,7 +2229,7 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
2143 2229
2144/* 2230/*
2145 * Transmit a packet. We need to split the packet so that a single 2231 * Transmit a packet. We need to split the packet so that a single
2146 * segment does not cross myri10ge->tx.boundary, so this makes segment 2232 * segment does not cross myri10ge->tx_boundary, so this makes segment
2147 * counting tricky. So rather than try to count segments up front, we 2233 * counting tricky. So rather than try to count segments up front, we
2148 * just give up if there are too few segments to hold a reasonably 2234 * just give up if there are too few segments to hold a reasonably
2149 * fragmented packet currently available. If we run 2235 * fragmented packet currently available. If we run
@@ -2154,8 +2240,9 @@ myri10ge_submit_req_wc(struct myri10ge_tx_buf *tx,
2154static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) 2240static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
2155{ 2241{
2156 struct myri10ge_priv *mgp = netdev_priv(dev); 2242 struct myri10ge_priv *mgp = netdev_priv(dev);
2243 struct myri10ge_slice_state *ss;
2157 struct mcp_kreq_ether_send *req; 2244 struct mcp_kreq_ether_send *req;
2158 struct myri10ge_tx_buf *tx = &mgp->tx; 2245 struct myri10ge_tx_buf *tx;
2159 struct skb_frag_struct *frag; 2246 struct skb_frag_struct *frag;
2160 dma_addr_t bus; 2247 dma_addr_t bus;
2161 u32 low; 2248 u32 low;
@@ -2166,6 +2253,9 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev)
2166 int cum_len, seglen, boundary, rdma_count; 2253 int cum_len, seglen, boundary, rdma_count;
2167 u8 flags, odd_flag; 2254 u8 flags, odd_flag;
2168 2255
2256 /* always transmit through slot 0 */
2257 ss = &mgp->ss;
2258 tx = &ss->tx;
2169again: 2259again:
2170 req = tx->req_list; 2260 req = tx->req_list;
2171 avail = tx->mask - 1 - (tx->req - tx->done); 2261 avail = tx->mask - 1 - (tx->req - tx->done);
@@ -2180,7 +2270,7 @@ again:
2180 2270
2181 if ((unlikely(avail < max_segments))) { 2271 if ((unlikely(avail < max_segments))) {
2182 /* we are out of transmit resources */ 2272 /* we are out of transmit resources */
2183 mgp->stop_queue++; 2273 tx->stop_queue++;
2184 netif_stop_queue(dev); 2274 netif_stop_queue(dev);
2185 return 1; 2275 return 1;
2186 } 2276 }
@@ -2242,7 +2332,7 @@ again:
2242 if (skb_padto(skb, ETH_ZLEN)) { 2332 if (skb_padto(skb, ETH_ZLEN)) {
2243 /* The packet is gone, so we must 2333 /* The packet is gone, so we must
2244 * return 0 */ 2334 * return 0 */
2245 mgp->stats.tx_dropped += 1; 2335 ss->stats.tx_dropped += 1;
2246 return 0; 2336 return 0;
2247 } 2337 }
2248 /* adjust the len to account for the zero pad 2338 /* adjust the len to account for the zero pad
@@ -2284,7 +2374,7 @@ again:
2284 2374
2285 while (1) { 2375 while (1) {
2286 /* Break the SKB or Fragment up into pieces which 2376 /* Break the SKB or Fragment up into pieces which
2287 * do not cross mgp->tx.boundary */ 2377 * do not cross mgp->tx_boundary */
2288 low = MYRI10GE_LOWPART_TO_U32(bus); 2378 low = MYRI10GE_LOWPART_TO_U32(bus);
2289 high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus)); 2379 high_swapped = htonl(MYRI10GE_HIGHPART_TO_U32(bus));
2290 while (len) { 2380 while (len) {
@@ -2294,7 +2384,8 @@ again:
2294 if (unlikely(count == max_segments)) 2384 if (unlikely(count == max_segments))
2295 goto abort_linearize; 2385 goto abort_linearize;
2296 2386
2297 boundary = (low + tx->boundary) & ~(tx->boundary - 1); 2387 boundary =
2388 (low + mgp->tx_boundary) & ~(mgp->tx_boundary - 1);
2298 seglen = boundary - low; 2389 seglen = boundary - low;
2299 if (seglen > len) 2390 if (seglen > len)
2300 seglen = len; 2391 seglen = len;
@@ -2378,7 +2469,7 @@ again:
2378 myri10ge_submit_req_wc(tx, tx->req_list, count); 2469 myri10ge_submit_req_wc(tx, tx->req_list, count);
2379 tx->pkt_start++; 2470 tx->pkt_start++;
2380 if ((avail - count) < MXGEFW_MAX_SEND_DESC) { 2471 if ((avail - count) < MXGEFW_MAX_SEND_DESC) {
2381 mgp->stop_queue++; 2472 tx->stop_queue++;
2382 netif_stop_queue(dev); 2473 netif_stop_queue(dev);
2383 } 2474 }
2384 dev->trans_start = jiffies; 2475 dev->trans_start = jiffies;
@@ -2420,12 +2511,12 @@ abort_linearize:
2420 if (skb_linearize(skb)) 2511 if (skb_linearize(skb))
2421 goto drop; 2512 goto drop;
2422 2513
2423 mgp->tx_linearized++; 2514 tx->linearized++;
2424 goto again; 2515 goto again;
2425 2516
2426drop: 2517drop:
2427 dev_kfree_skb_any(skb); 2518 dev_kfree_skb_any(skb);
2428 mgp->stats.tx_dropped += 1; 2519 ss->stats.tx_dropped += 1;
2429 return 0; 2520 return 0;
2430 2521
2431} 2522}
@@ -2433,7 +2524,7 @@ drop:
2433static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) 2524static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev)
2434{ 2525{
2435 struct sk_buff *segs, *curr; 2526 struct sk_buff *segs, *curr;
2436 struct myri10ge_priv *mgp = dev->priv; 2527 struct myri10ge_priv *mgp = netdev_priv(dev);
2437 int status; 2528 int status;
2438 2529
2439 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6); 2530 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO6);
@@ -2473,14 +2564,13 @@ static struct net_device_stats *myri10ge_get_stats(struct net_device *dev)
2473 2564
2474static void myri10ge_set_multicast_list(struct net_device *dev) 2565static void myri10ge_set_multicast_list(struct net_device *dev)
2475{ 2566{
2567 struct myri10ge_priv *mgp = netdev_priv(dev);
2476 struct myri10ge_cmd cmd; 2568 struct myri10ge_cmd cmd;
2477 struct myri10ge_priv *mgp;
2478 struct dev_mc_list *mc_list; 2569 struct dev_mc_list *mc_list;
2479 __be32 data[2] = { 0, 0 }; 2570 __be32 data[2] = { 0, 0 };
2480 int err; 2571 int err;
2481 DECLARE_MAC_BUF(mac); 2572 DECLARE_MAC_BUF(mac);
2482 2573
2483 mgp = netdev_priv(dev);
2484 /* can be called from atomic contexts, 2574 /* can be called from atomic contexts,
2485 * pass 1 to force atomicity in myri10ge_send_cmd() */ 2575 * pass 1 to force atomicity in myri10ge_send_cmd() */
2486 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1); 2576 myri10ge_change_promisc(mgp, dev->flags & IFF_PROMISC, 1);
@@ -2616,13 +2706,14 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2616 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4; 2706 ext_type = (val & PCI_EXP_FLAGS_TYPE) >> 4;
2617 if (ext_type != PCI_EXP_TYPE_ROOT_PORT) { 2707 if (ext_type != PCI_EXP_TYPE_ROOT_PORT) {
2618 if (myri10ge_ecrc_enable > 1) { 2708 if (myri10ge_ecrc_enable > 1) {
2619 struct pci_dev *old_bridge = bridge; 2709 struct pci_dev *prev_bridge, *old_bridge = bridge;
2620 2710
2621 /* Walk the hierarchy up to the root port 2711 /* Walk the hierarchy up to the root port
2622 * where ECRC has to be enabled */ 2712 * where ECRC has to be enabled */
2623 do { 2713 do {
2714 prev_bridge = bridge;
2624 bridge = bridge->bus->self; 2715 bridge = bridge->bus->self;
2625 if (!bridge) { 2716 if (!bridge || prev_bridge == bridge) {
2626 dev_err(dev, 2717 dev_err(dev,
2627 "Failed to find root port" 2718 "Failed to find root port"
2628 " to force ECRC\n"); 2719 " to force ECRC\n");
@@ -2681,9 +2772,9 @@ static void myri10ge_enable_ecrc(struct myri10ge_priv *mgp)
2681 * already been enabled, then it must use a firmware image which works 2772 * already been enabled, then it must use a firmware image which works
2682 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it 2773 * around unaligned completion packets (myri10ge_ethp_z8e.dat), and it
2683 * should also ensure that it never gives the device a Read-DMA which is 2774 * should also ensure that it never gives the device a Read-DMA which is
2684 * larger than 2KB by setting the tx.boundary to 2KB. If ECRC is 2775 * larger than 2KB by setting the tx_boundary to 2KB. If ECRC is
2685 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat) 2776 * enabled, then the driver should use the aligned (myri10ge_eth_z8e.dat)
2686 * firmware image, and set tx.boundary to 4KB. 2777 * firmware image, and set tx_boundary to 4KB.
2687 */ 2778 */
2688 2779
2689static void myri10ge_firmware_probe(struct myri10ge_priv *mgp) 2780static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
@@ -2692,7 +2783,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2692 struct device *dev = &pdev->dev; 2783 struct device *dev = &pdev->dev;
2693 int status; 2784 int status;
2694 2785
2695 mgp->tx.boundary = 4096; 2786 mgp->tx_boundary = 4096;
2696 /* 2787 /*
2697 * Verify the max read request size was set to 4KB 2788 * Verify the max read request size was set to 4KB
2698 * before trying the test with 4KB. 2789 * before trying the test with 4KB.
@@ -2704,7 +2795,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2704 } 2795 }
2705 if (status != 4096) { 2796 if (status != 4096) {
2706 dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status); 2797 dev_warn(dev, "Max Read Request size != 4096 (%d)\n", status);
2707 mgp->tx.boundary = 2048; 2798 mgp->tx_boundary = 2048;
2708 } 2799 }
2709 /* 2800 /*
2710 * load the optimized firmware (which assumes aligned PCIe 2801 * load the optimized firmware (which assumes aligned PCIe
@@ -2737,7 +2828,7 @@ static void myri10ge_firmware_probe(struct myri10ge_priv *mgp)
2737 "Please install up to date fw\n"); 2828 "Please install up to date fw\n");
2738abort: 2829abort:
2739 /* fall back to using the unaligned firmware */ 2830 /* fall back to using the unaligned firmware */
2740 mgp->tx.boundary = 2048; 2831 mgp->tx_boundary = 2048;
2741 mgp->fw_name = myri10ge_fw_unaligned; 2832 mgp->fw_name = myri10ge_fw_unaligned;
2742 2833
2743} 2834}
@@ -2758,7 +2849,7 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2758 if (link_width < 8) { 2849 if (link_width < 8) {
2759 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n", 2850 dev_info(&mgp->pdev->dev, "PCIE x%d Link\n",
2760 link_width); 2851 link_width);
2761 mgp->tx.boundary = 4096; 2852 mgp->tx_boundary = 4096;
2762 mgp->fw_name = myri10ge_fw_aligned; 2853 mgp->fw_name = myri10ge_fw_aligned;
2763 } else { 2854 } else {
2764 myri10ge_firmware_probe(mgp); 2855 myri10ge_firmware_probe(mgp);
@@ -2767,12 +2858,12 @@ static void myri10ge_select_firmware(struct myri10ge_priv *mgp)
2767 if (myri10ge_force_firmware == 1) { 2858 if (myri10ge_force_firmware == 1) {
2768 dev_info(&mgp->pdev->dev, 2859 dev_info(&mgp->pdev->dev,
2769 "Assuming aligned completions (forced)\n"); 2860 "Assuming aligned completions (forced)\n");
2770 mgp->tx.boundary = 4096; 2861 mgp->tx_boundary = 4096;
2771 mgp->fw_name = myri10ge_fw_aligned; 2862 mgp->fw_name = myri10ge_fw_aligned;
2772 } else { 2863 } else {
2773 dev_info(&mgp->pdev->dev, 2864 dev_info(&mgp->pdev->dev,
2774 "Assuming unaligned completions (forced)\n"); 2865 "Assuming unaligned completions (forced)\n");
2775 mgp->tx.boundary = 2048; 2866 mgp->tx_boundary = 2048;
2776 mgp->fw_name = myri10ge_fw_unaligned; 2867 mgp->fw_name = myri10ge_fw_unaligned;
2777 } 2868 }
2778 } 2869 }
@@ -2889,6 +2980,7 @@ static void myri10ge_watchdog(struct work_struct *work)
2889{ 2980{
2890 struct myri10ge_priv *mgp = 2981 struct myri10ge_priv *mgp =
2891 container_of(work, struct myri10ge_priv, watchdog_work); 2982 container_of(work, struct myri10ge_priv, watchdog_work);
2983 struct myri10ge_tx_buf *tx;
2892 u32 reboot; 2984 u32 reboot;
2893 int status; 2985 int status;
2894 u16 cmd, vendor; 2986 u16 cmd, vendor;
@@ -2938,15 +3030,16 @@ static void myri10ge_watchdog(struct work_struct *work)
2938 3030
2939 printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n", 3031 printk(KERN_ERR "myri10ge: %s: device timeout, resetting\n",
2940 mgp->dev->name); 3032 mgp->dev->name);
3033 tx = &mgp->ss.tx;
2941 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", 3034 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2942 mgp->dev->name, mgp->tx.req, mgp->tx.done, 3035 mgp->dev->name, tx->req, tx->done,
2943 mgp->tx.pkt_start, mgp->tx.pkt_done, 3036 tx->pkt_start, tx->pkt_done,
2944 (int)ntohl(mgp->fw_stats->send_done_count)); 3037 (int)ntohl(mgp->ss.fw_stats->send_done_count));
2945 msleep(2000); 3038 msleep(2000);
2946 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n", 3039 printk(KERN_INFO "myri10ge: %s: %d %d %d %d %d\n",
2947 mgp->dev->name, mgp->tx.req, mgp->tx.done, 3040 mgp->dev->name, tx->req, tx->done,
2948 mgp->tx.pkt_start, mgp->tx.pkt_done, 3041 tx->pkt_start, tx->pkt_done,
2949 (int)ntohl(mgp->fw_stats->send_done_count)); 3042 (int)ntohl(mgp->ss.fw_stats->send_done_count));
2950 } 3043 }
2951 rtnl_lock(); 3044 rtnl_lock();
2952 myri10ge_close(mgp->dev); 3045 myri10ge_close(mgp->dev);
@@ -2969,28 +3062,31 @@ static void myri10ge_watchdog(struct work_struct *work)
2969static void myri10ge_watchdog_timer(unsigned long arg) 3062static void myri10ge_watchdog_timer(unsigned long arg)
2970{ 3063{
2971 struct myri10ge_priv *mgp; 3064 struct myri10ge_priv *mgp;
3065 struct myri10ge_slice_state *ss;
2972 u32 rx_pause_cnt; 3066 u32 rx_pause_cnt;
2973 3067
2974 mgp = (struct myri10ge_priv *)arg; 3068 mgp = (struct myri10ge_priv *)arg;
2975 3069
2976 if (mgp->rx_small.watchdog_needed) { 3070 rx_pause_cnt = ntohl(mgp->ss.fw_stats->dropped_pause);
2977 myri10ge_alloc_rx_pages(mgp, &mgp->rx_small, 3071
3072 ss = &mgp->ss;
3073 if (ss->rx_small.watchdog_needed) {
3074 myri10ge_alloc_rx_pages(mgp, &ss->rx_small,
2978 mgp->small_bytes + MXGEFW_PAD, 1); 3075 mgp->small_bytes + MXGEFW_PAD, 1);
2979 if (mgp->rx_small.fill_cnt - mgp->rx_small.cnt >= 3076 if (ss->rx_small.fill_cnt - ss->rx_small.cnt >=
2980 myri10ge_fill_thresh) 3077 myri10ge_fill_thresh)
2981 mgp->rx_small.watchdog_needed = 0; 3078 ss->rx_small.watchdog_needed = 0;
2982 } 3079 }
2983 if (mgp->rx_big.watchdog_needed) { 3080 if (ss->rx_big.watchdog_needed) {
2984 myri10ge_alloc_rx_pages(mgp, &mgp->rx_big, mgp->big_bytes, 1); 3081 myri10ge_alloc_rx_pages(mgp, &ss->rx_big, mgp->big_bytes, 1);
2985 if (mgp->rx_big.fill_cnt - mgp->rx_big.cnt >= 3082 if (ss->rx_big.fill_cnt - ss->rx_big.cnt >=
2986 myri10ge_fill_thresh) 3083 myri10ge_fill_thresh)
2987 mgp->rx_big.watchdog_needed = 0; 3084 ss->rx_big.watchdog_needed = 0;
2988 } 3085 }
2989 rx_pause_cnt = ntohl(mgp->fw_stats->dropped_pause);
2990 3086
2991 if (mgp->tx.req != mgp->tx.done && 3087 if (ss->tx.req != ss->tx.done &&
2992 mgp->tx.done == mgp->watchdog_tx_done && 3088 ss->tx.done == ss->watchdog_tx_done &&
2993 mgp->watchdog_tx_req != mgp->watchdog_tx_done) { 3089 ss->watchdog_tx_req != ss->watchdog_tx_done) {
2994 /* nic seems like it might be stuck.. */ 3090 /* nic seems like it might be stuck.. */
2995 if (rx_pause_cnt != mgp->watchdog_pause) { 3091 if (rx_pause_cnt != mgp->watchdog_pause) {
2996 if (net_ratelimit()) 3092 if (net_ratelimit())
@@ -3005,8 +3101,8 @@ static void myri10ge_watchdog_timer(unsigned long arg)
3005 /* rearm timer */ 3101 /* rearm timer */
3006 mod_timer(&mgp->watchdog_timer, 3102 mod_timer(&mgp->watchdog_timer,
3007 jiffies + myri10ge_watchdog_timeout * HZ); 3103 jiffies + myri10ge_watchdog_timeout * HZ);
3008 mgp->watchdog_tx_done = mgp->tx.done; 3104 ss->watchdog_tx_done = ss->tx.done;
3009 mgp->watchdog_tx_req = mgp->tx.req; 3105 ss->watchdog_tx_req = ss->tx.req;
3010 mgp->watchdog_pause = rx_pause_cnt; 3106 mgp->watchdog_pause = rx_pause_cnt;
3011} 3107}
3012 3108
@@ -3030,7 +3126,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3030 3126
3031 mgp = netdev_priv(netdev); 3127 mgp = netdev_priv(netdev);
3032 mgp->dev = netdev; 3128 mgp->dev = netdev;
3033 netif_napi_add(netdev, &mgp->napi, myri10ge_poll, myri10ge_napi_weight); 3129 netif_napi_add(netdev, &mgp->ss.napi, myri10ge_poll, myri10ge_napi_weight);
3034 mgp->pdev = pdev; 3130 mgp->pdev = pdev;
3035 mgp->csum_flag = MXGEFW_FLAGS_CKSUM; 3131 mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
3036 mgp->pause = myri10ge_flow_control; 3132 mgp->pause = myri10ge_flow_control;
@@ -3076,9 +3172,9 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3076 if (mgp->cmd == NULL) 3172 if (mgp->cmd == NULL)
3077 goto abort_with_netdev; 3173 goto abort_with_netdev;
3078 3174
3079 mgp->fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3175 mgp->ss.fw_stats = dma_alloc_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3080 &mgp->fw_stats_bus, GFP_KERNEL); 3176 &mgp->ss.fw_stats_bus, GFP_KERNEL);
3081 if (mgp->fw_stats == NULL) 3177 if (mgp->ss.fw_stats == NULL)
3082 goto abort_with_cmd; 3178 goto abort_with_cmd;
3083 3179
3084 mgp->board_span = pci_resource_len(pdev, 0); 3180 mgp->board_span = pci_resource_len(pdev, 0);
@@ -3118,12 +3214,12 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3118 netdev->dev_addr[i] = mgp->mac_addr[i]; 3214 netdev->dev_addr[i] = mgp->mac_addr[i];
3119 3215
3120 /* allocate rx done ring */ 3216 /* allocate rx done ring */
3121 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3217 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3122 mgp->rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes, 3218 mgp->ss.rx_done.entry = dma_alloc_coherent(&pdev->dev, bytes,
3123 &mgp->rx_done.bus, GFP_KERNEL); 3219 &mgp->ss.rx_done.bus, GFP_KERNEL);
3124 if (mgp->rx_done.entry == NULL) 3220 if (mgp->ss.rx_done.entry == NULL)
3125 goto abort_with_ioremap; 3221 goto abort_with_ioremap;
3126 memset(mgp->rx_done.entry, 0, bytes); 3222 memset(mgp->ss.rx_done.entry, 0, bytes);
3127 3223
3128 myri10ge_select_firmware(mgp); 3224 myri10ge_select_firmware(mgp);
3129 3225
@@ -3183,7 +3279,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3183 } 3279 }
3184 dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n", 3280 dev_info(dev, "%s IRQ %d, tx bndry %d, fw %s, WC %s\n",
3185 (mgp->msi_enabled ? "MSI" : "xPIC"), 3281 (mgp->msi_enabled ? "MSI" : "xPIC"),
3186 netdev->irq, mgp->tx.boundary, mgp->fw_name, 3282 netdev->irq, mgp->tx_boundary, mgp->fw_name,
3187 (mgp->wc_enabled ? "Enabled" : "Disabled")); 3283 (mgp->wc_enabled ? "Enabled" : "Disabled"));
3188 3284
3189 return 0; 3285 return 0;
@@ -3195,9 +3291,9 @@ abort_with_firmware:
3195 myri10ge_dummy_rdma(mgp, 0); 3291 myri10ge_dummy_rdma(mgp, 0);
3196 3292
3197abort_with_rx_done: 3293abort_with_rx_done:
3198 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3294 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3199 dma_free_coherent(&pdev->dev, bytes, 3295 dma_free_coherent(&pdev->dev, bytes,
3200 mgp->rx_done.entry, mgp->rx_done.bus); 3296 mgp->ss.rx_done.entry, mgp->ss.rx_done.bus);
3201 3297
3202abort_with_ioremap: 3298abort_with_ioremap:
3203 iounmap(mgp->sram); 3299 iounmap(mgp->sram);
@@ -3207,8 +3303,8 @@ abort_with_wc:
3207 if (mgp->mtrr >= 0) 3303 if (mgp->mtrr >= 0)
3208 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); 3304 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
3209#endif 3305#endif
3210 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3306 dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3211 mgp->fw_stats, mgp->fw_stats_bus); 3307 mgp->ss.fw_stats, mgp->ss.fw_stats_bus);
3212 3308
3213abort_with_cmd: 3309abort_with_cmd:
3214 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), 3310 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
@@ -3246,9 +3342,9 @@ static void myri10ge_remove(struct pci_dev *pdev)
3246 /* avoid a memory leak */ 3342 /* avoid a memory leak */
3247 pci_restore_state(pdev); 3343 pci_restore_state(pdev);
3248 3344
3249 bytes = myri10ge_max_intr_slots * sizeof(*mgp->rx_done.entry); 3345 bytes = mgp->max_intr_slots * sizeof(*mgp->ss.rx_done.entry);
3250 dma_free_coherent(&pdev->dev, bytes, 3346 dma_free_coherent(&pdev->dev, bytes,
3251 mgp->rx_done.entry, mgp->rx_done.bus); 3347 mgp->ss.rx_done.entry, mgp->ss.rx_done.bus);
3252 3348
3253 iounmap(mgp->sram); 3349 iounmap(mgp->sram);
3254 3350
@@ -3256,8 +3352,8 @@ static void myri10ge_remove(struct pci_dev *pdev)
3256 if (mgp->mtrr >= 0) 3352 if (mgp->mtrr >= 0)
3257 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span); 3353 mtrr_del(mgp->mtrr, mgp->iomem_base, mgp->board_span);
3258#endif 3354#endif
3259 dma_free_coherent(&pdev->dev, sizeof(*mgp->fw_stats), 3355 dma_free_coherent(&pdev->dev, sizeof(*mgp->ss.fw_stats),
3260 mgp->fw_stats, mgp->fw_stats_bus); 3356 mgp->ss.fw_stats, mgp->ss.fw_stats_bus);
3261 3357
3262 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd), 3358 dma_free_coherent(&pdev->dev, sizeof(*mgp->cmd),
3263 mgp->cmd, mgp->cmd_bus); 3359 mgp->cmd, mgp->cmd_bus);
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h
index 58e57178c563..fdbeeee07372 100644
--- a/drivers/net/myri10ge/myri10ge_mcp.h
+++ b/drivers/net/myri10ge/myri10ge_mcp.h
@@ -10,7 +10,7 @@ struct mcp_dma_addr {
10 __be32 low; 10 __be32 low;
11}; 11};
12 12
13/* 4 Bytes. 8 Bytes for NDIS drivers. */ 13/* 4 Bytes */
14struct mcp_slot { 14struct mcp_slot {
15 __sum16 checksum; 15 __sum16 checksum;
16 __be16 length; 16 __be16 length;
@@ -144,6 +144,7 @@ enum myri10ge_mcp_cmd_type {
144 * a power of 2 number of entries. */ 144 * a power of 2 number of entries. */
145 145
146 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */ 146 MXGEFW_CMD_SET_INTRQ_SIZE, /* in bytes */
147#define MXGEFW_CMD_SET_INTRQ_SIZE_FLAG_NO_STRICT_SIZE_CHECK (1 << 31)
147 148
148 /* command to bring ethernet interface up. Above parameters 149 /* command to bring ethernet interface up. Above parameters
149 * (plus mtu & mac address) must have been exchanged prior 150 * (plus mtu & mac address) must have been exchanged prior
@@ -221,10 +222,14 @@ enum myri10ge_mcp_cmd_type {
221 MXGEFW_CMD_GET_MAX_RSS_QUEUES, 222 MXGEFW_CMD_GET_MAX_RSS_QUEUES,
222 MXGEFW_CMD_ENABLE_RSS_QUEUES, 223 MXGEFW_CMD_ENABLE_RSS_QUEUES,
223 /* data0 = number of slices n (0, 1, ..., n-1) to enable 224 /* data0 = number of slices n (0, 1, ..., n-1) to enable
224 * data1 = interrupt mode. 0=share one INTx/MSI, 1=use one MSI-X per queue. 225 * data1 = interrupt mode.
226 * 0=share one INTx/MSI, 1=use one MSI-X per queue.
225 * If all queues share one interrupt, the driver must have set 227 * If all queues share one interrupt, the driver must have set
226 * RSS_SHARED_INTERRUPT_DMA before enabling queues. 228 * RSS_SHARED_INTERRUPT_DMA before enabling queues.
227 */ 229 */
230#define MXGEFW_SLICE_INTR_MODE_SHARED 0
231#define MXGEFW_SLICE_INTR_MODE_ONE_PER_SLICE 1
232
228 MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET, 233 MXGEFW_CMD_GET_RSS_SHARED_INTERRUPT_MASK_OFFSET,
229 MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA, 234 MXGEFW_CMD_SET_RSS_SHARED_INTERRUPT_DMA,
230 /* data0, data1 = bus address lsw, msw */ 235 /* data0, data1 = bus address lsw, msw */
@@ -241,10 +246,14 @@ enum myri10ge_mcp_cmd_type {
241 * 0: disable rss. nic does not distribute receive packets. 246 * 0: disable rss. nic does not distribute receive packets.
242 * 1: enable rss. nic distributes receive packets among queues. 247 * 1: enable rss. nic distributes receive packets among queues.
243 * data1 = hash type 248 * data1 = hash type
244 * 1: IPV4 249 * 1: IPV4 (required by RSS)
245 * 2: TCP_IPV4 250 * 2: TCP_IPV4 (required by RSS)
246 * 3: IPV4 | TCP_IPV4 251 * 3: IPV4 | TCP_IPV4 (required by RSS)
252 * 4: source port
247 */ 253 */
254#define MXGEFW_RSS_HASH_TYPE_IPV4 0x1
255#define MXGEFW_RSS_HASH_TYPE_TCP_IPV4 0x2
256#define MXGEFW_RSS_HASH_TYPE_SRC_PORT 0x4
248 257
249 MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE, 258 MXGEFW_CMD_GET_MAX_TSO6_HDR_SIZE,
250 /* Return data = the max. size of the entire headers of a IPv6 TSO packet. 259 /* Return data = the max. size of the entire headers of a IPv6 TSO packet.
@@ -260,6 +269,8 @@ enum myri10ge_mcp_cmd_type {
260 * 0: Linux/FreeBSD style (NIC default) 269 * 0: Linux/FreeBSD style (NIC default)
261 * 1: NDIS/NetBSD style 270 * 1: NDIS/NetBSD style
262 */ 271 */
272#define MXGEFW_TSO_MODE_LINUX 0
273#define MXGEFW_TSO_MODE_NDIS 1
263 274
264 MXGEFW_CMD_MDIO_READ, 275 MXGEFW_CMD_MDIO_READ,
265 /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */ 276 /* data0 = dev_addr (PMA/PMD or PCS ...), data1 = register/addr */
@@ -286,6 +297,38 @@ enum myri10ge_mcp_cmd_type {
286 /* Return data = NIC memory offset of mcp_vpump_public_global */ 297 /* Return data = NIC memory offset of mcp_vpump_public_global */
287 MXGEFW_CMD_RESET_VPUMP, 298 MXGEFW_CMD_RESET_VPUMP,
288 /* Resets the VPUMP state */ 299 /* Resets the VPUMP state */
300
301 MXGEFW_CMD_SET_RSS_MCP_SLOT_TYPE,
302 /* data0 = mcp_slot type to use.
303 * 0 = the default 4B mcp_slot
304 * 1 = 8B mcp_slot_8
305 */
306#define MXGEFW_RSS_MCP_SLOT_TYPE_MIN 0
307#define MXGEFW_RSS_MCP_SLOT_TYPE_WITH_HASH 1
308
309 MXGEFW_CMD_SET_THROTTLE_FACTOR,
310 /* set the throttle factor for ethp_z8e
311 * data0 = throttle_factor
312 * throttle_factor = 256 * pcie-raw-speed / tx_speed
313 * tx_speed = 256 * pcie-raw-speed / throttle_factor
314 *
315 * For PCI-E x8: pcie-raw-speed == 16Gb/s
316 * For PCI-E x4: pcie-raw-speed == 8Gb/s
317 *
318 * ex1: throttle_factor == 0x1a0 (416), tx_speed == 1.23GB/s == 9.846 Gb/s
319 * ex2: throttle_factor == 0x200 (512), tx_speed == 1.0GB/s == 8 Gb/s
320 *
321 * with tx_boundary == 2048, max-throttle-factor == 8191 => min-speed == 500Mb/s
322 * with tx_boundary == 4096, max-throttle-factor == 4095 => min-speed == 1Gb/s
323 */
324
325 MXGEFW_CMD_VPUMP_UP,
326 /* Allocates VPump Connection, Send Request and Zero copy buffer address tables */
327 MXGEFW_CMD_GET_VPUMP_CLK,
328 /* Get the lanai clock */
329
330 MXGEFW_CMD_GET_DCA_OFFSET,
331 /* offset of dca control for WDMAs */
289}; 332};
290 333
291enum myri10ge_mcp_cmd_status { 334enum myri10ge_mcp_cmd_status {
@@ -302,7 +345,8 @@ enum myri10ge_mcp_cmd_status {
302 MXGEFW_CMD_ERROR_UNALIGNED, 345 MXGEFW_CMD_ERROR_UNALIGNED,
303 MXGEFW_CMD_ERROR_NO_MDIO, 346 MXGEFW_CMD_ERROR_NO_MDIO,
304 MXGEFW_CMD_ERROR_XFP_FAILURE, 347 MXGEFW_CMD_ERROR_XFP_FAILURE,
305 MXGEFW_CMD_ERROR_XFP_ABSENT 348 MXGEFW_CMD_ERROR_XFP_ABSENT,
349 MXGEFW_CMD_ERROR_BAD_PCIE_LINK
306}; 350};
307 351
308#define MXGEFW_OLD_IRQ_DATA_LEN 40 352#define MXGEFW_OLD_IRQ_DATA_LEN 40
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
index 16a810dd6d51..07d65c2cbb24 100644
--- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
+++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h
@@ -1,30 +1,6 @@
1#ifndef __MYRI10GE_MCP_GEN_HEADER_H__ 1#ifndef __MYRI10GE_MCP_GEN_HEADER_H__
2#define __MYRI10GE_MCP_GEN_HEADER_H__ 2#define __MYRI10GE_MCP_GEN_HEADER_H__
3 3
4/* this file define a standard header used as a first entry point to
5 * exchange information between firmware/driver and driver. The
6 * header structure can be anywhere in the mcp. It will usually be in
7 * the .data section, because some fields needs to be initialized at
8 * compile time.
9 * The 32bit word at offset MX_HEADER_PTR_OFFSET in the mcp must
10 * contains the location of the header.
11 *
12 * Typically a MCP will start with the following:
13 * .text
14 * .space 52 ! to help catch MEMORY_INT errors
15 * bt start ! jump to real code
16 * nop
17 * .long _gen_mcp_header
18 *
19 * The source will have a definition like:
20 *
21 * mcp_gen_header_t gen_mcp_header = {
22 * .header_length = sizeof(mcp_gen_header_t),
23 * .mcp_type = MCP_TYPE_XXX,
24 * .version = "something $Id: mcp_gen_header.h,v 1.2 2006/05/13 10:04:35 bgoglin Exp $",
25 * .mcp_globals = (unsigned)&Globals
26 * };
27 */
28 4
29#define MCP_HEADER_PTR_OFFSET 0x3c 5#define MCP_HEADER_PTR_OFFSET 0x3c
30 6
@@ -32,13 +8,14 @@
32#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */ 8#define MCP_TYPE_PCIE 0x70636965 /* "PCIE" pcie-only MCP */
33#define MCP_TYPE_ETH 0x45544820 /* "ETH " */ 9#define MCP_TYPE_ETH 0x45544820 /* "ETH " */
34#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */ 10#define MCP_TYPE_MCP0 0x4d435030 /* "MCP0" */
11#define MCP_TYPE_DFLT 0x20202020 /* " " */
35 12
36struct mcp_gen_header { 13struct mcp_gen_header {
37 /* the first 4 fields are filled at compile time */ 14 /* the first 4 fields are filled at compile time */
38 unsigned header_length; 15 unsigned header_length;
39 __be32 mcp_type; 16 __be32 mcp_type;
40 char version[128]; 17 char version[128];
41 unsigned mcp_globals; /* pointer to mcp-type specific structure */ 18 unsigned mcp_private; /* pointer to mcp-type specific structure */
42 19
43 /* filled by the MCP at run-time */ 20 /* filled by the MCP at run-time */
44 unsigned sram_size; 21 unsigned sram_size;
@@ -53,6 +30,18 @@ struct mcp_gen_header {
53 * 30 *
54 * Never remove any field. Keep everything naturally align. 31 * Never remove any field. Keep everything naturally align.
55 */ 32 */
33
34 /* Specifies if the running mcp is mcp0, 1, or 2. */
35 unsigned char mcp_index;
36 unsigned char disable_rabbit;
37 unsigned char unaligned_tlp;
38 unsigned char pad1;
39 unsigned counters_addr;
40 unsigned copy_block_info; /* for small mcps loaded with "lload -d" */
41 unsigned short handoff_id_major; /* must be equal */
42 unsigned short handoff_id_caps; /* bitfield: new mcp must have superset */
43 unsigned msix_table_addr; /* start address of msix table in firmware */
44 /* 8 */
56}; 45};
57 46
58#endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */ 47#endif /* __MYRI10GE_MCP_GEN_HEADER_H__ */
diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 4009c4ce96b4..918f802fe089 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -1,6 +1,6 @@
1/* niu.c: Neptune ethernet driver. 1/* niu.c: Neptune ethernet driver.
2 * 2 *
3 * Copyright (C) 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 2007, 2008 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/module.h> 6#include <linux/module.h>
@@ -33,8 +33,8 @@
33 33
34#define DRV_MODULE_NAME "niu" 34#define DRV_MODULE_NAME "niu"
35#define PFX DRV_MODULE_NAME ": " 35#define PFX DRV_MODULE_NAME ": "
36#define DRV_MODULE_VERSION "0.8" 36#define DRV_MODULE_VERSION "0.9"
37#define DRV_MODULE_RELDATE "April 24, 2008" 37#define DRV_MODULE_RELDATE "May 4, 2008"
38 38
39static char version[] __devinitdata = 39static char version[] __devinitdata =
40 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n"; 40 DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
@@ -865,7 +865,6 @@ static int link_status_1g_serdes(struct niu *np, int *link_up_p)
865 return 0; 865 return 0;
866} 866}
867 867
868
869static int link_status_10g_serdes(struct niu *np, int *link_up_p) 868static int link_status_10g_serdes(struct niu *np, int *link_up_p)
870{ 869{
871 unsigned long flags; 870 unsigned long flags;
@@ -900,7 +899,6 @@ static int link_status_10g_serdes(struct niu *np, int *link_up_p)
900 return 0; 899 return 0;
901} 900}
902 901
903
904static int link_status_1g_rgmii(struct niu *np, int *link_up_p) 902static int link_status_1g_rgmii(struct niu *np, int *link_up_p)
905{ 903{
906 struct niu_link_config *lp = &np->link_config; 904 struct niu_link_config *lp = &np->link_config;
@@ -957,7 +955,6 @@ out:
957 return err; 955 return err;
958} 956}
959 957
960
961static int bcm8704_reset(struct niu *np) 958static int bcm8704_reset(struct niu *np)
962{ 959{
963 int err, limit; 960 int err, limit;
@@ -1357,8 +1354,6 @@ static int mii_reset(struct niu *np)
1357 return 0; 1354 return 0;
1358} 1355}
1359 1356
1360
1361
1362static int xcvr_init_1g_rgmii(struct niu *np) 1357static int xcvr_init_1g_rgmii(struct niu *np)
1363{ 1358{
1364 int err; 1359 int err;
@@ -1419,7 +1414,6 @@ static int xcvr_init_1g_rgmii(struct niu *np)
1419 return 0; 1414 return 0;
1420} 1415}
1421 1416
1422
1423static int mii_init_common(struct niu *np) 1417static int mii_init_common(struct niu *np)
1424{ 1418{
1425 struct niu_link_config *lp = &np->link_config; 1419 struct niu_link_config *lp = &np->link_config;
@@ -7008,31 +7002,20 @@ static int __devinit niu_phy_type_prop_decode(struct niu *np,
7008 return 0; 7002 return 0;
7009} 7003}
7010 7004
7011/* niu board models have a trailing dash version incremented
7012 * with HW rev change. Need to ingnore the dash version while
7013 * checking for match
7014 *
7015 * for example, for the 10G card the current vpd.board_model
7016 * is 501-5283-04, of which -04 is the dash version and have
7017 * to be ignored
7018 */
7019static int niu_board_model_match(struct niu *np, const char *model)
7020{
7021 return !strncmp(np->vpd.board_model, model, strlen(model));
7022}
7023
7024static int niu_pci_vpd_get_nports(struct niu *np) 7005static int niu_pci_vpd_get_nports(struct niu *np)
7025{ 7006{
7026 int ports = 0; 7007 int ports = 0;
7027 7008
7028 if ((niu_board_model_match(np, NIU_QGC_LP_BM_STR)) || 7009 if ((!strcmp(np->vpd.model, NIU_QGC_LP_MDL_STR)) ||
7029 (niu_board_model_match(np, NIU_QGC_PEM_BM_STR)) || 7010 (!strcmp(np->vpd.model, NIU_QGC_PEM_MDL_STR)) ||
7030 (niu_board_model_match(np, NIU_ALONSO_BM_STR))) { 7011 (!strcmp(np->vpd.model, NIU_MARAMBA_MDL_STR)) ||
7012 (!strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) ||
7013 (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR))) {
7031 ports = 4; 7014 ports = 4;
7032 } else if ((niu_board_model_match(np, NIU_2XGF_LP_BM_STR)) || 7015 } else if ((!strcmp(np->vpd.model, NIU_2XGF_LP_MDL_STR)) ||
7033 (niu_board_model_match(np, NIU_2XGF_PEM_BM_STR)) || 7016 (!strcmp(np->vpd.model, NIU_2XGF_PEM_MDL_STR)) ||
7034 (niu_board_model_match(np, NIU_FOXXY_BM_STR)) || 7017 (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) ||
7035 (niu_board_model_match(np, NIU_2XGF_MRVL_BM_STR))) { 7018 (!strcmp(np->vpd.model, NIU_2XGF_MRVL_MDL_STR))) {
7036 ports = 2; 7019 ports = 2;
7037 } 7020 }
7038 7021
@@ -7053,8 +7036,8 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7053 return; 7036 return;
7054 } 7037 }
7055 7038
7056 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7039 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7057 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7040 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7058 np->flags |= NIU_FLAGS_10G; 7041 np->flags |= NIU_FLAGS_10G;
7059 np->flags &= ~NIU_FLAGS_FIBER; 7042 np->flags &= ~NIU_FLAGS_FIBER;
7060 np->flags |= NIU_FLAGS_XCVR_SERDES; 7043 np->flags |= NIU_FLAGS_XCVR_SERDES;
@@ -7065,7 +7048,7 @@ static void __devinit niu_pci_vpd_validate(struct niu *np)
7065 } 7048 }
7066 if (np->flags & NIU_FLAGS_10G) 7049 if (np->flags & NIU_FLAGS_10G)
7067 np->mac_xcvr = MAC_XCVR_XPCS; 7050 np->mac_xcvr = MAC_XCVR_XPCS;
7068 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7051 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7069 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | 7052 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER |
7070 NIU_FLAGS_HOTPLUG_PHY); 7053 NIU_FLAGS_HOTPLUG_PHY);
7071 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) { 7054 } else if (niu_phy_type_prop_decode(np, np->vpd.phy_type)) {
@@ -7264,8 +7247,11 @@ static int __devinit niu_get_and_validate_port(struct niu *np)
7264 parent->num_ports = nr64(ESPC_NUM_PORTS_MACS) & 7247 parent->num_ports = nr64(ESPC_NUM_PORTS_MACS) &
7265 ESPC_NUM_PORTS_MACS_VAL; 7248 ESPC_NUM_PORTS_MACS_VAL;
7266 7249
7250 /* All of the current probing methods fail on
7251 * Maramba on-board parts.
7252 */
7267 if (!parent->num_ports) 7253 if (!parent->num_ports)
7268 return -ENODEV; 7254 parent->num_ports = 4;
7269 } 7255 }
7270 } 7256 }
7271 } 7257 }
@@ -7538,8 +7524,8 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7538 u32 val; 7524 u32 val;
7539 int err; 7525 int err;
7540 7526
7541 if (!strcmp(np->vpd.model, "SUNW,CP3220") || 7527 if (!strcmp(np->vpd.model, NIU_ALONSO_MDL_STR) ||
7542 !strcmp(np->vpd.model, "SUNW,CP3260")) { 7528 !strcmp(np->vpd.model, NIU_KIMI_MDL_STR)) {
7543 num_10g = 0; 7529 num_10g = 0;
7544 num_1g = 2; 7530 num_1g = 2;
7545 parent->plat_type = PLAT_TYPE_ATCA_CP3220; 7531 parent->plat_type = PLAT_TYPE_ATCA_CP3220;
@@ -7548,7 +7534,7 @@ static int __devinit walk_phys(struct niu *np, struct niu_parent *parent)
7548 phy_encode(PORT_TYPE_1G, 1) | 7534 phy_encode(PORT_TYPE_1G, 1) |
7549 phy_encode(PORT_TYPE_1G, 2) | 7535 phy_encode(PORT_TYPE_1G, 2) |
7550 phy_encode(PORT_TYPE_1G, 3)); 7536 phy_encode(PORT_TYPE_1G, 3));
7551 } else if (niu_board_model_match(np, NIU_FOXXY_BM_STR)) { 7537 } else if (!strcmp(np->vpd.model, NIU_FOXXY_MDL_STR)) {
7552 num_10g = 2; 7538 num_10g = 2;
7553 num_1g = 0; 7539 num_1g = 0;
7554 parent->num_ports = 2; 7540 parent->num_ports = 2;
@@ -7943,6 +7929,7 @@ static int __devinit niu_get_of_props(struct niu *np)
7943 struct device_node *dp; 7929 struct device_node *dp;
7944 const char *phy_type; 7930 const char *phy_type;
7945 const u8 *mac_addr; 7931 const u8 *mac_addr;
7932 const char *model;
7946 int prop_len; 7933 int prop_len;
7947 7934
7948 if (np->parent->plat_type == PLAT_TYPE_NIU) 7935 if (np->parent->plat_type == PLAT_TYPE_NIU)
@@ -7997,6 +7984,11 @@ static int __devinit niu_get_of_props(struct niu *np)
7997 7984
7998 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len); 7985 memcpy(dev->dev_addr, dev->perm_addr, dev->addr_len);
7999 7986
7987 model = of_get_property(dp, "model", &prop_len);
7988
7989 if (model)
7990 strcpy(np->vpd.model, model);
7991
8000 return 0; 7992 return 0;
8001#else 7993#else
8002 return -EINVAL; 7994 return -EINVAL;
diff --git a/drivers/net/niu.h b/drivers/net/niu.h
index 101a3f1a8ec8..c6fa883daa22 100644
--- a/drivers/net/niu.h
+++ b/drivers/net/niu.h
@@ -2946,6 +2946,15 @@ struct rx_ring_info {
2946#define NIU_ALONSO_BM_STR "373-0202" 2946#define NIU_ALONSO_BM_STR "373-0202"
2947#define NIU_FOXXY_BM_STR "501-7961" 2947#define NIU_FOXXY_BM_STR "501-7961"
2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82" 2948#define NIU_2XGF_MRVL_BM_STR "SK-6E82"
2949#define NIU_QGC_LP_MDL_STR "SUNW,pcie-qgc"
2950#define NIU_2XGF_LP_MDL_STR "SUNW,pcie-2xgf"
2951#define NIU_QGC_PEM_MDL_STR "SUNW,pcie-qgc-pem"
2952#define NIU_2XGF_PEM_MDL_STR "SUNW,pcie-2xgf-pem"
2953#define NIU_ALONSO_MDL_STR "SUNW,CP3220"
2954#define NIU_KIMI_MDL_STR "SUNW,CP3260"
2955#define NIU_MARAMBA_MDL_STR "SUNW,pcie-neptune"
2956#define NIU_FOXXY_MDL_STR "SUNW,pcie-rfem"
2957#define NIU_2XGF_MRVL_MDL_STR "SysKonnect,pcie-2xgf"
2949 2958
2950#define NIU_VPD_MIN_MAJOR 3 2959#define NIU_VPD_MIN_MAJOR 3
2951#define NIU_VPD_MIN_MINOR 4 2960#define NIU_VPD_MIN_MINOR 4
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index d0d5585114b0..81fd85214b98 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -22,12 +22,8 @@
22 *************************************************************************/ 22 *************************************************************************/
23 23
24#define DRV_NAME "pcnet32" 24#define DRV_NAME "pcnet32"
25#ifdef CONFIG_PCNET32_NAPI 25#define DRV_VERSION "1.35"
26#define DRV_VERSION "1.34-NAPI" 26#define DRV_RELDATE "21.Apr.2008"
27#else
28#define DRV_VERSION "1.34"
29#endif
30#define DRV_RELDATE "14.Aug.2007"
31#define PFX DRV_NAME ": " 27#define PFX DRV_NAME ": "
32 28
33static const char *const version = 29static const char *const version =
@@ -445,30 +441,24 @@ static struct pcnet32_access pcnet32_dwio = {
445 441
446static void pcnet32_netif_stop(struct net_device *dev) 442static void pcnet32_netif_stop(struct net_device *dev)
447{ 443{
448#ifdef CONFIG_PCNET32_NAPI
449 struct pcnet32_private *lp = netdev_priv(dev); 444 struct pcnet32_private *lp = netdev_priv(dev);
450#endif 445
451 dev->trans_start = jiffies; 446 dev->trans_start = jiffies;
452#ifdef CONFIG_PCNET32_NAPI
453 napi_disable(&lp->napi); 447 napi_disable(&lp->napi);
454#endif
455 netif_tx_disable(dev); 448 netif_tx_disable(dev);
456} 449}
457 450
458static void pcnet32_netif_start(struct net_device *dev) 451static void pcnet32_netif_start(struct net_device *dev)
459{ 452{
460#ifdef CONFIG_PCNET32_NAPI
461 struct pcnet32_private *lp = netdev_priv(dev); 453 struct pcnet32_private *lp = netdev_priv(dev);
462 ulong ioaddr = dev->base_addr; 454 ulong ioaddr = dev->base_addr;
463 u16 val; 455 u16 val;
464#endif 456
465 netif_wake_queue(dev); 457 netif_wake_queue(dev);
466#ifdef CONFIG_PCNET32_NAPI
467 val = lp->a.read_csr(ioaddr, CSR3); 458 val = lp->a.read_csr(ioaddr, CSR3);
468 val &= 0x00ff; 459 val &= 0x00ff;
469 lp->a.write_csr(ioaddr, CSR3, val); 460 lp->a.write_csr(ioaddr, CSR3, val);
470 napi_enable(&lp->napi); 461 napi_enable(&lp->napi);
471#endif
472} 462}
473 463
474/* 464/*
@@ -911,11 +901,7 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
911 rc = 1; /* default to fail */ 901 rc = 1; /* default to fail */
912 902
913 if (netif_running(dev)) 903 if (netif_running(dev))
914#ifdef CONFIG_PCNET32_NAPI
915 pcnet32_netif_stop(dev); 904 pcnet32_netif_stop(dev);
916#else
917 pcnet32_close(dev);
918#endif
919 905
920 spin_lock_irqsave(&lp->lock, flags); 906 spin_lock_irqsave(&lp->lock, flags);
921 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */ 907 lp->a.write_csr(ioaddr, CSR0, CSR0_STOP); /* stop the chip */
@@ -1046,7 +1032,6 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
1046 x = a->read_bcr(ioaddr, 32); /* reset internal loopback */ 1032 x = a->read_bcr(ioaddr, 32); /* reset internal loopback */
1047 a->write_bcr(ioaddr, 32, (x & ~0x0002)); 1033 a->write_bcr(ioaddr, 32, (x & ~0x0002));
1048 1034
1049#ifdef CONFIG_PCNET32_NAPI
1050 if (netif_running(dev)) { 1035 if (netif_running(dev)) {
1051 pcnet32_netif_start(dev); 1036 pcnet32_netif_start(dev);
1052 pcnet32_restart(dev, CSR0_NORMAL); 1037 pcnet32_restart(dev, CSR0_NORMAL);
@@ -1055,16 +1040,6 @@ static int pcnet32_loopback_test(struct net_device *dev, uint64_t * data1)
1055 lp->a.write_bcr(ioaddr, 20, 4); /* return to 16bit mode */ 1040 lp->a.write_bcr(ioaddr, 20, 4); /* return to 16bit mode */
1056 } 1041 }
1057 spin_unlock_irqrestore(&lp->lock, flags); 1042 spin_unlock_irqrestore(&lp->lock, flags);
1058#else
1059 if (netif_running(dev)) {
1060 spin_unlock_irqrestore(&lp->lock, flags);
1061 pcnet32_open(dev);
1062 } else {
1063 pcnet32_purge_rx_ring(dev);
1064 lp->a.write_bcr(ioaddr, 20, 4); /* return to 16bit mode */
1065 spin_unlock_irqrestore(&lp->lock, flags);
1066 }
1067#endif
1068 1043
1069 return (rc); 1044 return (rc);
1070} /* end pcnet32_loopback_test */ 1045} /* end pcnet32_loopback_test */
@@ -1270,11 +1245,7 @@ static void pcnet32_rx_entry(struct net_device *dev,
1270 } 1245 }
1271 dev->stats.rx_bytes += skb->len; 1246 dev->stats.rx_bytes += skb->len;
1272 skb->protocol = eth_type_trans(skb, dev); 1247 skb->protocol = eth_type_trans(skb, dev);
1273#ifdef CONFIG_PCNET32_NAPI
1274 netif_receive_skb(skb); 1248 netif_receive_skb(skb);
1275#else
1276 netif_rx(skb);
1277#endif
1278 dev->last_rx = jiffies; 1249 dev->last_rx = jiffies;
1279 dev->stats.rx_packets++; 1250 dev->stats.rx_packets++;
1280 return; 1251 return;
@@ -1403,7 +1374,6 @@ static int pcnet32_tx(struct net_device *dev)
1403 return must_restart; 1374 return must_restart;
1404} 1375}
1405 1376
1406#ifdef CONFIG_PCNET32_NAPI
1407static int pcnet32_poll(struct napi_struct *napi, int budget) 1377static int pcnet32_poll(struct napi_struct *napi, int budget)
1408{ 1378{
1409 struct pcnet32_private *lp = container_of(napi, struct pcnet32_private, napi); 1379 struct pcnet32_private *lp = container_of(napi, struct pcnet32_private, napi);
@@ -1442,7 +1412,6 @@ static int pcnet32_poll(struct napi_struct *napi, int budget)
1442 } 1412 }
1443 return work_done; 1413 return work_done;
1444} 1414}
1445#endif
1446 1415
1447#define PCNET32_REGS_PER_PHY 32 1416#define PCNET32_REGS_PER_PHY 32
1448#define PCNET32_MAX_PHYS 32 1417#define PCNET32_MAX_PHYS 32
@@ -1864,9 +1833,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1864 /* napi.weight is used in both the napi and non-napi cases */ 1833 /* napi.weight is used in both the napi and non-napi cases */
1865 lp->napi.weight = lp->rx_ring_size / 2; 1834 lp->napi.weight = lp->rx_ring_size / 2;
1866 1835
1867#ifdef CONFIG_PCNET32_NAPI
1868 netif_napi_add(dev, &lp->napi, pcnet32_poll, lp->rx_ring_size / 2); 1836 netif_napi_add(dev, &lp->napi, pcnet32_poll, lp->rx_ring_size / 2);
1869#endif
1870 1837
1871 if (fdx && !(lp->options & PCNET32_PORT_ASEL) && 1838 if (fdx && !(lp->options & PCNET32_PORT_ASEL) &&
1872 ((cards_found >= MAX_UNITS) || full_duplex[cards_found])) 1839 ((cards_found >= MAX_UNITS) || full_duplex[cards_found]))
@@ -2297,9 +2264,7 @@ static int pcnet32_open(struct net_device *dev)
2297 goto err_free_ring; 2264 goto err_free_ring;
2298 } 2265 }
2299 2266
2300#ifdef CONFIG_PCNET32_NAPI
2301 napi_enable(&lp->napi); 2267 napi_enable(&lp->napi);
2302#endif
2303 2268
2304 /* Re-initialize the PCNET32, and start it when done. */ 2269 /* Re-initialize the PCNET32, and start it when done. */
2305 lp->a.write_csr(ioaddr, 1, (lp->init_dma_addr & 0xffff)); 2270 lp->a.write_csr(ioaddr, 1, (lp->init_dma_addr & 0xffff));
@@ -2623,7 +2588,6 @@ pcnet32_interrupt(int irq, void *dev_id)
2623 dev->name, csr0); 2588 dev->name, csr0);
2624 /* unlike for the lance, there is no restart needed */ 2589 /* unlike for the lance, there is no restart needed */
2625 } 2590 }
2626#ifdef CONFIG_PCNET32_NAPI
2627 if (netif_rx_schedule_prep(dev, &lp->napi)) { 2591 if (netif_rx_schedule_prep(dev, &lp->napi)) {
2628 u16 val; 2592 u16 val;
2629 /* set interrupt masks */ 2593 /* set interrupt masks */
@@ -2634,24 +2598,9 @@ pcnet32_interrupt(int irq, void *dev_id)
2634 __netif_rx_schedule(dev, &lp->napi); 2598 __netif_rx_schedule(dev, &lp->napi);
2635 break; 2599 break;
2636 } 2600 }
2637#else
2638 pcnet32_rx(dev, lp->napi.weight);
2639 if (pcnet32_tx(dev)) {
2640 /* reset the chip to clear the error condition, then restart */
2641 lp->a.reset(ioaddr);
2642 lp->a.write_csr(ioaddr, CSR4, 0x0915); /* auto tx pad */
2643 pcnet32_restart(dev, CSR0_START);
2644 netif_wake_queue(dev);
2645 }
2646#endif
2647 csr0 = lp->a.read_csr(ioaddr, CSR0); 2601 csr0 = lp->a.read_csr(ioaddr, CSR0);
2648 } 2602 }
2649 2603
2650#ifndef CONFIG_PCNET32_NAPI
2651 /* Set interrupt enable. */
2652 lp->a.write_csr(ioaddr, CSR0, CSR0_INTEN);
2653#endif
2654
2655 if (netif_msg_intr(lp)) 2604 if (netif_msg_intr(lp))
2656 printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n", 2605 printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n",
2657 dev->name, lp->a.read_csr(ioaddr, CSR0)); 2606 dev->name, lp->a.read_csr(ioaddr, CSR0));
@@ -2670,9 +2619,7 @@ static int pcnet32_close(struct net_device *dev)
2670 del_timer_sync(&lp->watchdog_timer); 2619 del_timer_sync(&lp->watchdog_timer);
2671 2620
2672 netif_stop_queue(dev); 2621 netif_stop_queue(dev);
2673#ifdef CONFIG_PCNET32_NAPI
2674 napi_disable(&lp->napi); 2622 napi_disable(&lp->napi);
2675#endif
2676 2623
2677 spin_lock_irqsave(&lp->lock, flags); 2624 spin_lock_irqsave(&lp->lock, flags);
2678 2625
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 3c18bb594957..45cc2914d347 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -547,7 +547,7 @@ static void phy_force_reduction(struct phy_device *phydev)
547 * Must not be called from interrupt context, or while the 547 * Must not be called from interrupt context, or while the
548 * phydev->lock is held. 548 * phydev->lock is held.
549 */ 549 */
550void phy_error(struct phy_device *phydev) 550static void phy_error(struct phy_device *phydev)
551{ 551{
552 mutex_lock(&phydev->lock); 552 mutex_lock(&phydev->lock);
553 phydev->state = PHY_HALTED; 553 phydev->state = PHY_HALTED;
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index d3207c0da895..1f4ca2b54a73 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -2458,6 +2458,7 @@ ppp_create_interface(int unit, int *retp)
2458 2458
2459out3: 2459out3:
2460 atomic_dec(&ppp_unit_count); 2460 atomic_dec(&ppp_unit_count);
2461 unregister_netdev(dev);
2461out2: 2462out2:
2462 mutex_unlock(&all_ppp_mutex); 2463 mutex_unlock(&all_ppp_mutex);
2463 free_netdev(dev); 2464 free_netdev(dev);
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 244d7830c92a..79359919335b 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -1621,9 +1621,16 @@ out_no_ppp:
1621end: 1621end:
1622 release_sock(sk); 1622 release_sock(sk);
1623 1623
1624 if (error != 0) 1624 if (error != 0) {
1625 PRINTK(session ? session->debug : -1, PPPOL2TP_MSG_CONTROL, KERN_WARNING, 1625 if (session)
1626 "%s: connect failed: %d\n", session->name, error); 1626 PRINTK(session->debug,
1627 PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1628 "%s: connect failed: %d\n",
1629 session->name, error);
1630 else
1631 PRINTK(-1, PPPOL2TP_MSG_CONTROL, KERN_WARNING,
1632 "connect failed: %d\n", error);
1633 }
1627 1634
1628 return error; 1635 return error;
1629} 1636}
diff --git a/drivers/net/ps3_gelic_wireless.c b/drivers/net/ps3_gelic_wireless.c
index 0d32123085e9..1dae1f2ed813 100644
--- a/drivers/net/ps3_gelic_wireless.c
+++ b/drivers/net/ps3_gelic_wireless.c
@@ -2474,6 +2474,8 @@ static void gelic_wl_free(struct gelic_wl_info *wl)
2474 2474
2475 pr_debug("%s: <-\n", __func__); 2475 pr_debug("%s: <-\n", __func__);
2476 2476
2477 free_page((unsigned long)wl->buf);
2478
2477 pr_debug("%s: destroy queues\n", __func__); 2479 pr_debug("%s: destroy queues\n", __func__);
2478 destroy_workqueue(wl->eurus_cmd_queue); 2480 destroy_workqueue(wl->eurus_cmd_queue);
2479 destroy_workqueue(wl->event_queue); 2481 destroy_workqueue(wl->event_queue);
diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 0f023447eafd..1d2daeec7ac1 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -1,5 +1,5 @@
1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \ 1sfc-y += efx.o falcon.o tx.o rx.o falcon_xmac.o \
2 i2c-direct.o ethtool.o xfp_phy.o mdio_10g.o \ 2 i2c-direct.o selftest.o ethtool.o xfp_phy.o \
3 tenxpress.o boards.o sfe4001.o 3 mdio_10g.o tenxpress.o boards.o sfe4001.o
4 4
5obj-$(CONFIG_SFC) += sfc.o 5obj-$(CONFIG_SFC) += sfc.o
diff --git a/drivers/net/sfc/boards.h b/drivers/net/sfc/boards.h
index f56341d428e1..695764dc2e64 100644
--- a/drivers/net/sfc/boards.h
+++ b/drivers/net/sfc/boards.h
@@ -22,5 +22,7 @@ enum efx_board_type {
22extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info); 22extern int efx_set_board_info(struct efx_nic *efx, u16 revision_info);
23extern int sfe4001_poweron(struct efx_nic *efx); 23extern int sfe4001_poweron(struct efx_nic *efx);
24extern void sfe4001_poweroff(struct efx_nic *efx); 24extern void sfe4001_poweroff(struct efx_nic *efx);
25/* Are we putting the PHY into flash config mode */
26extern unsigned int sfe4001_phy_flash_cfg;
25 27
26#endif 28#endif
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 59edcf793c19..418f2e53a95b 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1873,6 +1873,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type,
1873 tx_queue->queue = i; 1873 tx_queue->queue = i;
1874 tx_queue->buffer = NULL; 1874 tx_queue->buffer = NULL;
1875 tx_queue->channel = &efx->channel[0]; /* for safety */ 1875 tx_queue->channel = &efx->channel[0]; /* for safety */
1876 tx_queue->tso_headers_free = NULL;
1876 } 1877 }
1877 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) { 1878 for (i = 0; i < EFX_MAX_RX_QUEUES; i++) {
1878 rx_queue = &efx->rx_queue[i]; 1879 rx_queue = &efx->rx_queue[i];
@@ -2071,7 +2072,8 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev,
2071 net_dev = alloc_etherdev(sizeof(*efx)); 2072 net_dev = alloc_etherdev(sizeof(*efx));
2072 if (!net_dev) 2073 if (!net_dev)
2073 return -ENOMEM; 2074 return -ENOMEM;
2074 net_dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA; 2075 net_dev->features |= (NETIF_F_IP_CSUM | NETIF_F_SG |
2076 NETIF_F_HIGHDMA | NETIF_F_TSO);
2075 if (lro) 2077 if (lro)
2076 net_dev->features |= NETIF_F_LRO; 2078 net_dev->features |= NETIF_F_LRO;
2077 efx = net_dev->priv; 2079 efx = net_dev->priv;
diff --git a/drivers/net/sfc/enum.h b/drivers/net/sfc/enum.h
index 43663a4619da..c53290d08e2b 100644
--- a/drivers/net/sfc/enum.h
+++ b/drivers/net/sfc/enum.h
@@ -10,6 +10,55 @@
10#ifndef EFX_ENUM_H 10#ifndef EFX_ENUM_H
11#define EFX_ENUM_H 11#define EFX_ENUM_H
12 12
13/**
14 * enum efx_loopback_mode - loopback modes
15 * @LOOPBACK_NONE: no loopback
16 * @LOOPBACK_XGMII: loopback within MAC at XGMII level
17 * @LOOPBACK_XGXS: loopback within MAC at XGXS level
18 * @LOOPBACK_XAUI: loopback within MAC at XAUI level
19 * @LOOPBACK_PHYXS: loopback within PHY at PHYXS level
20 * @LOOPBACK_PCS: loopback within PHY at PCS level
21 * @LOOPBACK_PMAPMD: loopback within PHY at PMAPMD level
22 * @LOOPBACK_NETWORK: reflecting loopback (even further than furthest!)
23 */
24/* Please keep in order and up-to-date w.r.t the following two #defines */
25enum efx_loopback_mode {
26 LOOPBACK_NONE = 0,
27 LOOPBACK_MAC = 1,
28 LOOPBACK_XGMII = 2,
29 LOOPBACK_XGXS = 3,
30 LOOPBACK_XAUI = 4,
31 LOOPBACK_PHY = 5,
32 LOOPBACK_PHYXS = 6,
33 LOOPBACK_PCS = 7,
34 LOOPBACK_PMAPMD = 8,
35 LOOPBACK_NETWORK = 9,
36 LOOPBACK_MAX
37};
38
39#define LOOPBACK_TEST_MAX LOOPBACK_PMAPMD
40
41extern const char *efx_loopback_mode_names[];
42#define LOOPBACK_MODE_NAME(mode) \
43 STRING_TABLE_LOOKUP(mode, efx_loopback_mode)
44#define LOOPBACK_MODE(efx) \
45 LOOPBACK_MODE_NAME(efx->loopback_mode)
46
47/* These loopbacks occur within the controller */
48#define LOOPBACKS_10G_INTERNAL ((1 << LOOPBACK_XGMII)| \
49 (1 << LOOPBACK_XGXS) | \
50 (1 << LOOPBACK_XAUI))
51
52#define LOOPBACK_MASK(_efx) \
53 (1 << (_efx)->loopback_mode)
54
55#define LOOPBACK_INTERNAL(_efx) \
56 ((LOOPBACKS_10G_INTERNAL & LOOPBACK_MASK(_efx)) ? 1 : 0)
57
58#define LOOPBACK_OUT_OF(_from, _to, _mask) \
59 (((LOOPBACK_MASK(_from) & (_mask)) && \
60 ((LOOPBACK_MASK(_to) & (_mask)) == 0)) ? 1 : 0)
61
13/*****************************************************************************/ 62/*****************************************************************************/
14 63
15/** 64/**
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index ad541badbd98..e2c75d101610 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -12,12 +12,26 @@
12#include <linux/ethtool.h> 12#include <linux/ethtool.h>
13#include <linux/rtnetlink.h> 13#include <linux/rtnetlink.h>
14#include "net_driver.h" 14#include "net_driver.h"
15#include "selftest.h"
15#include "efx.h" 16#include "efx.h"
16#include "ethtool.h" 17#include "ethtool.h"
17#include "falcon.h" 18#include "falcon.h"
18#include "gmii.h" 19#include "gmii.h"
19#include "mac.h" 20#include "mac.h"
20 21
22const char *efx_loopback_mode_names[] = {
23 [LOOPBACK_NONE] = "NONE",
24 [LOOPBACK_MAC] = "MAC",
25 [LOOPBACK_XGMII] = "XGMII",
26 [LOOPBACK_XGXS] = "XGXS",
27 [LOOPBACK_XAUI] = "XAUI",
28 [LOOPBACK_PHY] = "PHY",
29 [LOOPBACK_PHYXS] = "PHY(XS)",
30 [LOOPBACK_PCS] = "PHY(PCS)",
31 [LOOPBACK_PMAPMD] = "PHY(PMAPMD)",
32 [LOOPBACK_NETWORK] = "NETWORK",
33};
34
21static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable); 35static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable);
22 36
23struct ethtool_string { 37struct ethtool_string {
@@ -217,23 +231,179 @@ static void efx_ethtool_get_drvinfo(struct net_device *net_dev,
217 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info)); 231 strlcpy(info->bus_info, pci_name(efx->pci_dev), sizeof(info->bus_info));
218} 232}
219 233
234/**
235 * efx_fill_test - fill in an individual self-test entry
236 * @test_index: Index of the test
237 * @strings: Ethtool strings, or %NULL
238 * @data: Ethtool test results, or %NULL
239 * @test: Pointer to test result (used only if data != %NULL)
240 * @unit_format: Unit name format (e.g. "channel\%d")
241 * @unit_id: Unit id (e.g. 0 for "channel0")
242 * @test_format: Test name format (e.g. "loopback.\%s.tx.sent")
243 * @test_id: Test id (e.g. "PHY" for "loopback.PHY.tx_sent")
244 *
245 * Fill in an individual self-test entry.
246 */
247static void efx_fill_test(unsigned int test_index,
248 struct ethtool_string *strings, u64 *data,
249 int *test, const char *unit_format, int unit_id,
250 const char *test_format, const char *test_id)
251{
252 struct ethtool_string unit_str, test_str;
253
254 /* Fill data value, if applicable */
255 if (data)
256 data[test_index] = *test;
257
258 /* Fill string, if applicable */
259 if (strings) {
260 snprintf(unit_str.name, sizeof(unit_str.name),
261 unit_format, unit_id);
262 snprintf(test_str.name, sizeof(test_str.name),
263 test_format, test_id);
264 snprintf(strings[test_index].name,
265 sizeof(strings[test_index].name),
266 "%-9s%-17s", unit_str.name, test_str.name);
267 }
268}
269
270#define EFX_PORT_NAME "port%d", 0
271#define EFX_CHANNEL_NAME(_channel) "channel%d", _channel->channel
272#define EFX_TX_QUEUE_NAME(_tx_queue) "txq%d", _tx_queue->queue
273#define EFX_RX_QUEUE_NAME(_rx_queue) "rxq%d", _rx_queue->queue
274#define EFX_LOOPBACK_NAME(_mode, _counter) \
275 "loopback.%s." _counter, LOOPBACK_MODE_NAME(mode)
276
277/**
278 * efx_fill_loopback_test - fill in a block of loopback self-test entries
279 * @efx: Efx NIC
280 * @lb_tests: Efx loopback self-test results structure
281 * @mode: Loopback test mode
282 * @test_index: Starting index of the test
283 * @strings: Ethtool strings, or %NULL
284 * @data: Ethtool test results, or %NULL
285 */
286static int efx_fill_loopback_test(struct efx_nic *efx,
287 struct efx_loopback_self_tests *lb_tests,
288 enum efx_loopback_mode mode,
289 unsigned int test_index,
290 struct ethtool_string *strings, u64 *data)
291{
292 struct efx_tx_queue *tx_queue;
293
294 efx_for_each_tx_queue(tx_queue, efx) {
295 efx_fill_test(test_index++, strings, data,
296 &lb_tests->tx_sent[tx_queue->queue],
297 EFX_TX_QUEUE_NAME(tx_queue),
298 EFX_LOOPBACK_NAME(mode, "tx_sent"));
299 efx_fill_test(test_index++, strings, data,
300 &lb_tests->tx_done[tx_queue->queue],
301 EFX_TX_QUEUE_NAME(tx_queue),
302 EFX_LOOPBACK_NAME(mode, "tx_done"));
303 }
304 efx_fill_test(test_index++, strings, data,
305 &lb_tests->rx_good,
306 EFX_PORT_NAME,
307 EFX_LOOPBACK_NAME(mode, "rx_good"));
308 efx_fill_test(test_index++, strings, data,
309 &lb_tests->rx_bad,
310 EFX_PORT_NAME,
311 EFX_LOOPBACK_NAME(mode, "rx_bad"));
312
313 return test_index;
314}
315
316/**
317 * efx_ethtool_fill_self_tests - get self-test details
318 * @efx: Efx NIC
319 * @tests: Efx self-test results structure, or %NULL
320 * @strings: Ethtool strings, or %NULL
321 * @data: Ethtool test results, or %NULL
322 */
323static int efx_ethtool_fill_self_tests(struct efx_nic *efx,
324 struct efx_self_tests *tests,
325 struct ethtool_string *strings,
326 u64 *data)
327{
328 struct efx_channel *channel;
329 unsigned int n = 0;
330 enum efx_loopback_mode mode;
331
332 /* Interrupt */
333 efx_fill_test(n++, strings, data, &tests->interrupt,
334 "core", 0, "interrupt", NULL);
335
336 /* Event queues */
337 efx_for_each_channel(channel, efx) {
338 efx_fill_test(n++, strings, data,
339 &tests->eventq_dma[channel->channel],
340 EFX_CHANNEL_NAME(channel),
341 "eventq.dma", NULL);
342 efx_fill_test(n++, strings, data,
343 &tests->eventq_int[channel->channel],
344 EFX_CHANNEL_NAME(channel),
345 "eventq.int", NULL);
346 efx_fill_test(n++, strings, data,
347 &tests->eventq_poll[channel->channel],
348 EFX_CHANNEL_NAME(channel),
349 "eventq.poll", NULL);
350 }
351
352 /* PHY presence */
353 efx_fill_test(n++, strings, data, &tests->phy_ok,
354 EFX_PORT_NAME, "phy_ok", NULL);
355
356 /* Loopback tests */
357 efx_fill_test(n++, strings, data, &tests->loopback_speed,
358 EFX_PORT_NAME, "loopback.speed", NULL);
359 efx_fill_test(n++, strings, data, &tests->loopback_full_duplex,
360 EFX_PORT_NAME, "loopback.full_duplex", NULL);
361 for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) {
362 if (!(efx->loopback_modes & (1 << mode)))
363 continue;
364 n = efx_fill_loopback_test(efx,
365 &tests->loopback[mode], mode, n,
366 strings, data);
367 }
368
369 return n;
370}
371
220static int efx_ethtool_get_stats_count(struct net_device *net_dev) 372static int efx_ethtool_get_stats_count(struct net_device *net_dev)
221{ 373{
222 return EFX_ETHTOOL_NUM_STATS; 374 return EFX_ETHTOOL_NUM_STATS;
223} 375}
224 376
377static int efx_ethtool_self_test_count(struct net_device *net_dev)
378{
379 struct efx_nic *efx = net_dev->priv;
380
381 return efx_ethtool_fill_self_tests(efx, NULL, NULL, NULL);
382}
383
225static void efx_ethtool_get_strings(struct net_device *net_dev, 384static void efx_ethtool_get_strings(struct net_device *net_dev,
226 u32 string_set, u8 *strings) 385 u32 string_set, u8 *strings)
227{ 386{
387 struct efx_nic *efx = net_dev->priv;
228 struct ethtool_string *ethtool_strings = 388 struct ethtool_string *ethtool_strings =
229 (struct ethtool_string *)strings; 389 (struct ethtool_string *)strings;
230 int i; 390 int i;
231 391
232 if (string_set == ETH_SS_STATS) 392 switch (string_set) {
393 case ETH_SS_STATS:
233 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) 394 for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++)
234 strncpy(ethtool_strings[i].name, 395 strncpy(ethtool_strings[i].name,
235 efx_ethtool_stats[i].name, 396 efx_ethtool_stats[i].name,
236 sizeof(ethtool_strings[i].name)); 397 sizeof(ethtool_strings[i].name));
398 break;
399 case ETH_SS_TEST:
400 efx_ethtool_fill_self_tests(efx, NULL,
401 ethtool_strings, NULL);
402 break;
403 default:
404 /* No other string sets */
405 break;
406 }
237} 407}
238 408
239static void efx_ethtool_get_stats(struct net_device *net_dev, 409static void efx_ethtool_get_stats(struct net_device *net_dev,
@@ -272,6 +442,22 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
272 } 442 }
273} 443}
274 444
445static int efx_ethtool_set_tso(struct net_device *net_dev, u32 enable)
446{
447 int rc;
448
449 /* Our TSO requires TX checksumming, so force TX checksumming
450 * on when TSO is enabled.
451 */
452 if (enable) {
453 rc = efx_ethtool_set_tx_csum(net_dev, 1);
454 if (rc)
455 return rc;
456 }
457
458 return ethtool_op_set_tso(net_dev, enable);
459}
460
275static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable) 461static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
276{ 462{
277 struct efx_nic *efx = net_dev->priv; 463 struct efx_nic *efx = net_dev->priv;
@@ -283,6 +469,15 @@ static int efx_ethtool_set_tx_csum(struct net_device *net_dev, u32 enable)
283 469
284 efx_flush_queues(efx); 470 efx_flush_queues(efx);
285 471
472 /* Our TSO requires TX checksumming, so disable TSO when
473 * checksumming is disabled
474 */
475 if (!enable) {
476 rc = efx_ethtool_set_tso(net_dev, 0);
477 if (rc)
478 return rc;
479 }
480
286 return 0; 481 return 0;
287} 482}
288 483
@@ -305,6 +500,64 @@ static u32 efx_ethtool_get_rx_csum(struct net_device *net_dev)
305 return efx->rx_checksum_enabled; 500 return efx->rx_checksum_enabled;
306} 501}
307 502
503static void efx_ethtool_self_test(struct net_device *net_dev,
504 struct ethtool_test *test, u64 *data)
505{
506 struct efx_nic *efx = net_dev->priv;
507 struct efx_self_tests efx_tests;
508 int offline, already_up;
509 int rc;
510
511 ASSERT_RTNL();
512 if (efx->state != STATE_RUNNING) {
513 rc = -EIO;
514 goto fail1;
515 }
516
517 /* We need rx buffers and interrupts. */
518 already_up = (efx->net_dev->flags & IFF_UP);
519 if (!already_up) {
520 rc = dev_open(efx->net_dev);
521 if (rc) {
522 EFX_ERR(efx, "failed opening device.\n");
523 goto fail2;
524 }
525 }
526
527 memset(&efx_tests, 0, sizeof(efx_tests));
528 offline = (test->flags & ETH_TEST_FL_OFFLINE);
529
530 /* Perform online self tests first */
531 rc = efx_online_test(efx, &efx_tests);
532 if (rc)
533 goto out;
534
535 /* Perform offline tests only if online tests passed */
536 if (offline) {
537 /* Stop the kernel from sending packets during the test. */
538 efx_stop_queue(efx);
539 rc = efx_flush_queues(efx);
540 if (!rc)
541 rc = efx_offline_test(efx, &efx_tests,
542 efx->loopback_modes);
543 efx_wake_queue(efx);
544 }
545
546 out:
547 if (!already_up)
548 dev_close(efx->net_dev);
549
550 EFX_LOG(efx, "%s all %sline self-tests\n",
551 rc == 0 ? "passed" : "failed", offline ? "off" : "on");
552
553 fail2:
554 fail1:
555 /* Fill ethtool results structures */
556 efx_ethtool_fill_self_tests(efx, &efx_tests, NULL, data);
557 if (rc)
558 test->flags |= ETH_TEST_FL_FAILED;
559}
560
308/* Restart autonegotiation */ 561/* Restart autonegotiation */
309static int efx_ethtool_nway_reset(struct net_device *net_dev) 562static int efx_ethtool_nway_reset(struct net_device *net_dev)
310{ 563{
@@ -451,8 +704,12 @@ struct ethtool_ops efx_ethtool_ops = {
451 .set_tx_csum = efx_ethtool_set_tx_csum, 704 .set_tx_csum = efx_ethtool_set_tx_csum,
452 .get_sg = ethtool_op_get_sg, 705 .get_sg = ethtool_op_get_sg,
453 .set_sg = ethtool_op_set_sg, 706 .set_sg = ethtool_op_set_sg,
707 .get_tso = ethtool_op_get_tso,
708 .set_tso = efx_ethtool_set_tso,
454 .get_flags = ethtool_op_get_flags, 709 .get_flags = ethtool_op_get_flags,
455 .set_flags = ethtool_op_set_flags, 710 .set_flags = ethtool_op_set_flags,
711 .self_test_count = efx_ethtool_self_test_count,
712 .self_test = efx_ethtool_self_test,
456 .get_strings = efx_ethtool_get_strings, 713 .get_strings = efx_ethtool_get_strings,
457 .phys_id = efx_ethtool_phys_id, 714 .phys_id = efx_ethtool_phys_id,
458 .get_stats_count = efx_ethtool_get_stats_count, 715 .get_stats_count = efx_ethtool_get_stats_count,
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c
index 46db549ce580..b57cc68058c0 100644
--- a/drivers/net/sfc/falcon.c
+++ b/drivers/net/sfc/falcon.c
@@ -1129,6 +1129,7 @@ static void falcon_handle_driver_event(struct efx_channel *channel,
1129 case RX_RECOVERY_EV_DECODE: 1129 case RX_RECOVERY_EV_DECODE:
1130 EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. " 1130 EFX_ERR(efx, "channel %d seen DRIVER RX_RESET event. "
1131 "Resetting.\n", channel->channel); 1131 "Resetting.\n", channel->channel);
1132 atomic_inc(&efx->rx_reset);
1132 efx_schedule_reset(efx, 1133 efx_schedule_reset(efx,
1133 EFX_WORKAROUND_6555(efx) ? 1134 EFX_WORKAROUND_6555(efx) ?
1134 RESET_TYPE_RX_RECOVERY : 1135 RESET_TYPE_RX_RECOVERY :
@@ -1731,7 +1732,8 @@ void falcon_drain_tx_fifo(struct efx_nic *efx)
1731 efx_oword_t temp; 1732 efx_oword_t temp;
1732 int count; 1733 int count;
1733 1734
1734 if (FALCON_REV(efx) < FALCON_REV_B0) 1735 if ((FALCON_REV(efx) < FALCON_REV_B0) ||
1736 (efx->loopback_mode != LOOPBACK_NONE))
1735 return; 1737 return;
1736 1738
1737 falcon_read(efx, &temp, MAC0_CTRL_REG_KER); 1739 falcon_read(efx, &temp, MAC0_CTRL_REG_KER);
@@ -2091,6 +2093,8 @@ static int falcon_probe_phy(struct efx_nic *efx)
2091 efx->phy_type); 2093 efx->phy_type);
2092 return -1; 2094 return -1;
2093 } 2095 }
2096
2097 efx->loopback_modes = LOOPBACKS_10G_INTERNAL | efx->phy_op->loopbacks;
2094 return 0; 2098 return 0;
2095} 2099}
2096 2100
@@ -2468,14 +2472,12 @@ int falcon_probe_nic(struct efx_nic *efx)
2468 fail5: 2472 fail5:
2469 falcon_free_buffer(efx, &efx->irq_status); 2473 falcon_free_buffer(efx, &efx->irq_status);
2470 fail4: 2474 fail4:
2471 /* fall-thru */
2472 fail3: 2475 fail3:
2473 if (nic_data->pci_dev2) { 2476 if (nic_data->pci_dev2) {
2474 pci_dev_put(nic_data->pci_dev2); 2477 pci_dev_put(nic_data->pci_dev2);
2475 nic_data->pci_dev2 = NULL; 2478 nic_data->pci_dev2 = NULL;
2476 } 2479 }
2477 fail2: 2480 fail2:
2478 /* fall-thru */
2479 fail1: 2481 fail1:
2480 kfree(efx->nic_data); 2482 kfree(efx->nic_data);
2481 return rc; 2483 return rc;
diff --git a/drivers/net/sfc/falcon_hwdefs.h b/drivers/net/sfc/falcon_hwdefs.h
index 0485a63eaff6..06e2d68fc3d1 100644
--- a/drivers/net/sfc/falcon_hwdefs.h
+++ b/drivers/net/sfc/falcon_hwdefs.h
@@ -636,6 +636,14 @@
636#define XX_HIDRVA_WIDTH 1 636#define XX_HIDRVA_WIDTH 1
637#define XX_LODRVA_LBN 8 637#define XX_LODRVA_LBN 8
638#define XX_LODRVA_WIDTH 1 638#define XX_LODRVA_WIDTH 1
639#define XX_LPBKD_LBN 3
640#define XX_LPBKD_WIDTH 1
641#define XX_LPBKC_LBN 2
642#define XX_LPBKC_WIDTH 1
643#define XX_LPBKB_LBN 1
644#define XX_LPBKB_WIDTH 1
645#define XX_LPBKA_LBN 0
646#define XX_LPBKA_WIDTH 1
639 647
640#define XX_TXDRV_CTL_REG_MAC 0x12 648#define XX_TXDRV_CTL_REG_MAC 0x12
641#define XX_DEQD_LBN 28 649#define XX_DEQD_LBN 28
@@ -656,8 +664,14 @@
656#define XX_DTXA_WIDTH 4 664#define XX_DTXA_WIDTH 4
657 665
658/* XAUI XGXS core status register */ 666/* XAUI XGXS core status register */
659#define XX_FORCE_SIG_DECODE_FORCED 0xff
660#define XX_CORE_STAT_REG_MAC 0x16 667#define XX_CORE_STAT_REG_MAC 0x16
668#define XX_FORCE_SIG_LBN 24
669#define XX_FORCE_SIG_WIDTH 8
670#define XX_FORCE_SIG_DECODE_FORCED 0xff
671#define XX_XGXS_LB_EN_LBN 23
672#define XX_XGXS_LB_EN_WIDTH 1
673#define XX_XGMII_LB_EN_LBN 22
674#define XX_XGMII_LB_EN_WIDTH 1
661#define XX_ALIGN_DONE_LBN 20 675#define XX_ALIGN_DONE_LBN 20
662#define XX_ALIGN_DONE_WIDTH 1 676#define XX_ALIGN_DONE_WIDTH 1
663#define XX_SYNC_STAT_LBN 16 677#define XX_SYNC_STAT_LBN 16
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c
index aa7521b24a5d..a74b7931a3c4 100644
--- a/drivers/net/sfc/falcon_xmac.c
+++ b/drivers/net/sfc/falcon_xmac.c
@@ -32,7 +32,7 @@
32 (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE)) 32 (FALCON_XMAC_REGBANK + ((mac_reg) * FALCON_XMAC_REG_SIZE))
33 33
34void falcon_xmac_writel(struct efx_nic *efx, 34void falcon_xmac_writel(struct efx_nic *efx,
35 efx_dword_t *value, unsigned int mac_reg) 35 efx_dword_t *value, unsigned int mac_reg)
36{ 36{
37 efx_oword_t temp; 37 efx_oword_t temp;
38 38
@@ -69,6 +69,10 @@ static int falcon_reset_xmac(struct efx_nic *efx)
69 udelay(10); 69 udelay(10);
70 } 70 }
71 71
72 /* This often fails when DSP is disabled, ignore it */
73 if (sfe4001_phy_flash_cfg != 0)
74 return 0;
75
72 EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); 76 EFX_ERR(efx, "timed out waiting for XMAC core reset\n");
73 return -ETIMEDOUT; 77 return -ETIMEDOUT;
74} 78}
@@ -223,7 +227,7 @@ static int falcon_xgmii_status(struct efx_nic *efx)
223 /* The ISR latches, so clear it and re-read */ 227 /* The ISR latches, so clear it and re-read */
224 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0); 228 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
225 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0); 229 falcon_xmac_readl(efx, &reg, XM_MGT_INT_REG_MAC_B0);
226 230
227 if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || 231 if (EFX_DWORD_FIELD(reg, XM_LCLFLT) ||
228 EFX_DWORD_FIELD(reg, XM_RMTFLT)) { 232 EFX_DWORD_FIELD(reg, XM_RMTFLT)) {
229 EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); 233 EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg));
@@ -237,7 +241,7 @@ static void falcon_mask_status_intr(struct efx_nic *efx, int enable)
237{ 241{
238 efx_dword_t reg; 242 efx_dword_t reg;
239 243
240 if (FALCON_REV(efx) < FALCON_REV_B0) 244 if ((FALCON_REV(efx) < FALCON_REV_B0) || LOOPBACK_INTERNAL(efx))
241 return; 245 return;
242 246
243 /* Flush the ISR */ 247 /* Flush the ISR */
@@ -284,6 +288,9 @@ int falcon_xaui_link_ok(struct efx_nic *efx)
284 efx_dword_t reg; 288 efx_dword_t reg;
285 int align_done, sync_status, link_ok = 0; 289 int align_done, sync_status, link_ok = 0;
286 290
291 if (LOOPBACK_INTERNAL(efx))
292 return 1;
293
287 /* Read link status */ 294 /* Read link status */
288 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC); 295 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
289 296
@@ -374,6 +381,61 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx)
374 falcon_xmac_writel(efx, &reg, XM_ADR_HI_REG_MAC); 381 falcon_xmac_writel(efx, &reg, XM_ADR_HI_REG_MAC);
375} 382}
376 383
384static void falcon_reconfigure_xgxs_core(struct efx_nic *efx)
385{
386 efx_dword_t reg;
387 int xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS) ? 1 : 0;
388 int xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI) ? 1 : 0;
389 int xgmii_loopback =
390 (efx->loopback_mode == LOOPBACK_XGMII) ? 1 : 0;
391
392 /* XGXS block is flaky and will need to be reset if moving
393 * into our out of XGMII, XGXS or XAUI loopbacks. */
394 if (EFX_WORKAROUND_5147(efx)) {
395 int old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback;
396 int reset_xgxs;
397
398 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
399 old_xgxs_loopback = EFX_DWORD_FIELD(reg, XX_XGXS_LB_EN);
400 old_xgmii_loopback = EFX_DWORD_FIELD(reg, XX_XGMII_LB_EN);
401
402 falcon_xmac_readl(efx, &reg, XX_SD_CTL_REG_MAC);
403 old_xaui_loopback = EFX_DWORD_FIELD(reg, XX_LPBKA);
404
405 /* The PHY driver may have turned XAUI off */
406 reset_xgxs = ((xgxs_loopback != old_xgxs_loopback) ||
407 (xaui_loopback != old_xaui_loopback) ||
408 (xgmii_loopback != old_xgmii_loopback));
409 if (reset_xgxs) {
410 falcon_xmac_readl(efx, &reg, XX_PWR_RST_REG_MAC);
411 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 1);
412 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 1);
413 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
414 udelay(1);
415 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSTX_EN, 0);
416 EFX_SET_DWORD_FIELD(reg, XX_RSTXGXSRX_EN, 0);
417 falcon_xmac_writel(efx, &reg, XX_PWR_RST_REG_MAC);
418 udelay(1);
419 }
420 }
421
422 falcon_xmac_readl(efx, &reg, XX_CORE_STAT_REG_MAC);
423 EFX_SET_DWORD_FIELD(reg, XX_FORCE_SIG,
424 (xgxs_loopback || xaui_loopback) ?
425 XX_FORCE_SIG_DECODE_FORCED : 0);
426 EFX_SET_DWORD_FIELD(reg, XX_XGXS_LB_EN, xgxs_loopback);
427 EFX_SET_DWORD_FIELD(reg, XX_XGMII_LB_EN, xgmii_loopback);
428 falcon_xmac_writel(efx, &reg, XX_CORE_STAT_REG_MAC);
429
430 falcon_xmac_readl(efx, &reg, XX_SD_CTL_REG_MAC);
431 EFX_SET_DWORD_FIELD(reg, XX_LPBKD, xaui_loopback);
432 EFX_SET_DWORD_FIELD(reg, XX_LPBKC, xaui_loopback);
433 EFX_SET_DWORD_FIELD(reg, XX_LPBKB, xaui_loopback);
434 EFX_SET_DWORD_FIELD(reg, XX_LPBKA, xaui_loopback);
435 falcon_xmac_writel(efx, &reg, XX_SD_CTL_REG_MAC);
436}
437
438
377/* Try and bring the Falcon side of the Falcon-Phy XAUI link fails 439/* Try and bring the Falcon side of the Falcon-Phy XAUI link fails
378 * to come back up. Bash it until it comes back up */ 440 * to come back up. Bash it until it comes back up */
379static int falcon_check_xaui_link_up(struct efx_nic *efx) 441static int falcon_check_xaui_link_up(struct efx_nic *efx)
@@ -382,7 +444,8 @@ static int falcon_check_xaui_link_up(struct efx_nic *efx)
382 tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; 444 tries = EFX_WORKAROUND_5147(efx) ? 5 : 1;
383 max_tries = tries; 445 max_tries = tries;
384 446
385 if (efx->phy_type == PHY_TYPE_NONE) 447 if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
448 (efx->phy_type == PHY_TYPE_NONE))
386 return 0; 449 return 0;
387 450
388 while (tries) { 451 while (tries) {
@@ -408,8 +471,13 @@ void falcon_reconfigure_xmac(struct efx_nic *efx)
408 falcon_mask_status_intr(efx, 0); 471 falcon_mask_status_intr(efx, 0);
409 472
410 falcon_deconfigure_mac_wrapper(efx); 473 falcon_deconfigure_mac_wrapper(efx);
474
475 efx->tx_disabled = LOOPBACK_INTERNAL(efx);
411 efx->phy_op->reconfigure(efx); 476 efx->phy_op->reconfigure(efx);
477
478 falcon_reconfigure_xgxs_core(efx);
412 falcon_reconfigure_xmac_core(efx); 479 falcon_reconfigure_xmac_core(efx);
480
413 falcon_reconfigure_mac_wrapper(efx); 481 falcon_reconfigure_mac_wrapper(efx);
414 482
415 /* Ensure XAUI link is up */ 483 /* Ensure XAUI link is up */
@@ -491,13 +559,15 @@ void falcon_update_stats_xmac(struct efx_nic *efx)
491 (mac_stats->rx_bytes - mac_stats->rx_good_bytes); 559 (mac_stats->rx_bytes - mac_stats->rx_good_bytes);
492} 560}
493 561
494#define EFX_XAUI_RETRAIN_MAX 8
495
496int falcon_check_xmac(struct efx_nic *efx) 562int falcon_check_xmac(struct efx_nic *efx)
497{ 563{
498 unsigned xaui_link_ok; 564 unsigned xaui_link_ok;
499 int rc; 565 int rc;
500 566
567 if ((efx->loopback_mode == LOOPBACK_NETWORK) ||
568 (efx->phy_type == PHY_TYPE_NONE))
569 return 0;
570
501 falcon_mask_status_intr(efx, 0); 571 falcon_mask_status_intr(efx, 0);
502 xaui_link_ok = falcon_xaui_link_ok(efx); 572 xaui_link_ok = falcon_xaui_link_ok(efx);
503 573
diff --git a/drivers/net/sfc/mdio_10g.c b/drivers/net/sfc/mdio_10g.c
index dc06bb0aa575..c4f540e93b79 100644
--- a/drivers/net/sfc/mdio_10g.c
+++ b/drivers/net/sfc/mdio_10g.c
@@ -44,6 +44,9 @@ static int mdio_clause45_check_mmd(struct efx_nic *efx, int mmd,
44 int status; 44 int status;
45 int phy_id = efx->mii.phy_id; 45 int phy_id = efx->mii.phy_id;
46 46
47 if (LOOPBACK_INTERNAL(efx))
48 return 0;
49
47 /* Read MMD STATUS2 to check it is responding. */ 50 /* Read MMD STATUS2 to check it is responding. */
48 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2); 51 status = mdio_clause45_read(efx, phy_id, mmd, MDIO_MMDREG_STAT2);
49 if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) & 52 if (((status >> MDIO_MMDREG_STAT2_PRESENT_LBN) &
@@ -164,6 +167,22 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
164 int mmd = 0; 167 int mmd = 0;
165 int good; 168 int good;
166 169
170 /* If the port is in loopback, then we should only consider a subset
171 * of mmd's */
172 if (LOOPBACK_INTERNAL(efx))
173 return 1;
174 else if (efx->loopback_mode == LOOPBACK_NETWORK)
175 return 0;
176 else if (efx->loopback_mode == LOOPBACK_PHYXS)
177 mmd_mask &= ~(MDIO_MMDREG_DEVS0_PHYXS |
178 MDIO_MMDREG_DEVS0_PCS |
179 MDIO_MMDREG_DEVS0_PMAPMD);
180 else if (efx->loopback_mode == LOOPBACK_PCS)
181 mmd_mask &= ~(MDIO_MMDREG_DEVS0_PCS |
182 MDIO_MMDREG_DEVS0_PMAPMD);
183 else if (efx->loopback_mode == LOOPBACK_PMAPMD)
184 mmd_mask &= ~MDIO_MMDREG_DEVS0_PMAPMD;
185
167 while (mmd_mask) { 186 while (mmd_mask) {
168 if (mmd_mask & 1) { 187 if (mmd_mask & 1) {
169 /* Double reads because link state is latched, and a 188 /* Double reads because link state is latched, and a
@@ -182,6 +201,65 @@ int mdio_clause45_links_ok(struct efx_nic *efx, unsigned int mmd_mask)
182 return ok; 201 return ok;
183} 202}
184 203
204void mdio_clause45_transmit_disable(struct efx_nic *efx)
205{
206 int phy_id = efx->mii.phy_id;
207 int ctrl1, ctrl2;
208
209 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
210 MDIO_MMDREG_TXDIS);
211 if (efx->tx_disabled)
212 ctrl2 |= (1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN);
213 else
214 ctrl1 &= ~(1 << MDIO_MMDREG_TXDIS_GLOBAL_LBN);
215 if (ctrl1 != ctrl2)
216 mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
217 MDIO_MMDREG_TXDIS, ctrl2);
218}
219
220void mdio_clause45_phy_reconfigure(struct efx_nic *efx)
221{
222 int phy_id = efx->mii.phy_id;
223 int ctrl1, ctrl2;
224
225 /* Handle (with debouncing) PMA/PMD loopback */
226 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PMAPMD,
227 MDIO_MMDREG_CTRL1);
228
229 if (efx->loopback_mode == LOOPBACK_PMAPMD)
230 ctrl2 |= (1 << MDIO_PMAPMD_CTRL1_LBACK_LBN);
231 else
232 ctrl2 &= ~(1 << MDIO_PMAPMD_CTRL1_LBACK_LBN);
233
234 if (ctrl1 != ctrl2)
235 mdio_clause45_write(efx, phy_id, MDIO_MMD_PMAPMD,
236 MDIO_MMDREG_CTRL1, ctrl2);
237
238 /* Handle (with debouncing) PCS loopback */
239 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS,
240 MDIO_MMDREG_CTRL1);
241 if (efx->loopback_mode == LOOPBACK_PCS)
242 ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
243 else
244 ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
245
246 if (ctrl1 != ctrl2)
247 mdio_clause45_write(efx, phy_id, MDIO_MMD_PCS,
248 MDIO_MMDREG_CTRL1, ctrl2);
249
250 /* Handle (with debouncing) PHYXS network loopback */
251 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS,
252 MDIO_MMDREG_CTRL1);
253 if (efx->loopback_mode == LOOPBACK_NETWORK)
254 ctrl2 |= (1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
255 else
256 ctrl2 &= ~(1 << MDIO_MMDREG_CTRL1_LBACK_LBN);
257
258 if (ctrl1 != ctrl2)
259 mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS,
260 MDIO_MMDREG_CTRL1, ctrl2);
261}
262
185/** 263/**
186 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO. 264 * mdio_clause45_get_settings - Read (some of) the PHY settings over MDIO.
187 * @efx: Efx NIC 265 * @efx: Efx NIC
diff --git a/drivers/net/sfc/mdio_10g.h b/drivers/net/sfc/mdio_10g.h
index 2214b6d820a7..cb99f3f4491c 100644
--- a/drivers/net/sfc/mdio_10g.h
+++ b/drivers/net/sfc/mdio_10g.h
@@ -44,11 +44,16 @@
44#define MDIO_MMDREG_DEVS1 (6) 44#define MDIO_MMDREG_DEVS1 (6)
45#define MDIO_MMDREG_CTRL2 (7) 45#define MDIO_MMDREG_CTRL2 (7)
46#define MDIO_MMDREG_STAT2 (8) 46#define MDIO_MMDREG_STAT2 (8)
47#define MDIO_MMDREG_TXDIS (9)
47 48
48/* Bits in MMDREG_CTRL1 */ 49/* Bits in MMDREG_CTRL1 */
49/* Reset */ 50/* Reset */
50#define MDIO_MMDREG_CTRL1_RESET_LBN (15) 51#define MDIO_MMDREG_CTRL1_RESET_LBN (15)
51#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1) 52#define MDIO_MMDREG_CTRL1_RESET_WIDTH (1)
53/* Loopback */
54/* Loopback bit for WIS, PCS, PHYSX and DTEXS */
55#define MDIO_MMDREG_CTRL1_LBACK_LBN (14)
56#define MDIO_MMDREG_CTRL1_LBACK_WIDTH (1)
52 57
53/* Bits in MMDREG_STAT1 */ 58/* Bits in MMDREG_STAT1 */
54#define MDIO_MMDREG_STAT1_FAULT_LBN (7) 59#define MDIO_MMDREG_STAT1_FAULT_LBN (7)
@@ -56,6 +61,9 @@
56/* Link state */ 61/* Link state */
57#define MDIO_MMDREG_STAT1_LINK_LBN (2) 62#define MDIO_MMDREG_STAT1_LINK_LBN (2)
58#define MDIO_MMDREG_STAT1_LINK_WIDTH (1) 63#define MDIO_MMDREG_STAT1_LINK_WIDTH (1)
64/* Low power ability */
65#define MDIO_MMDREG_STAT1_LPABLE_LBN (1)
66#define MDIO_MMDREG_STAT1_LPABLE_WIDTH (1)
59 67
60/* Bits in ID reg */ 68/* Bits in ID reg */
61#define MDIO_ID_REV(_id32) (_id32 & 0xf) 69#define MDIO_ID_REV(_id32) (_id32 & 0xf)
@@ -76,6 +84,14 @@
76#define MDIO_MMDREG_STAT2_PRESENT_LBN (14) 84#define MDIO_MMDREG_STAT2_PRESENT_LBN (14)
77#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2) 85#define MDIO_MMDREG_STAT2_PRESENT_WIDTH (2)
78 86
87/* Bits in MMDREG_TXDIS */
88#define MDIO_MMDREG_TXDIS_GLOBAL_LBN (0)
89#define MDIO_MMDREG_TXDIS_GLOBAL_WIDTH (1)
90
91/* MMD-specific bits, ordered by MMD, then register */
92#define MDIO_PMAPMD_CTRL1_LBACK_LBN (0)
93#define MDIO_PMAPMD_CTRL1_LBACK_WIDTH (1)
94
79/* PMA type (4 bits) */ 95/* PMA type (4 bits) */
80#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0) 96#define MDIO_PMAPMD_CTRL2_10G_CX4 (0x0)
81#define MDIO_PMAPMD_CTRL2_10G_EW (0x1) 97#define MDIO_PMAPMD_CTRL2_10G_EW (0x1)
@@ -95,7 +111,7 @@
95#define MDIO_PMAPMD_CTRL2_10_BT (0xf) 111#define MDIO_PMAPMD_CTRL2_10_BT (0xf)
96#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf) 112#define MDIO_PMAPMD_CTRL2_TYPE_MASK (0xf)
97 113
98/* /\* PHY XGXS lane state *\/ */ 114/* PHY XGXS lane state */
99#define MDIO_PHYXS_LANE_STATE (0x18) 115#define MDIO_PHYXS_LANE_STATE (0x18)
100#define MDIO_PHYXS_LANE_ALIGNED_LBN (12) 116#define MDIO_PHYXS_LANE_ALIGNED_LBN (12)
101 117
@@ -217,6 +233,12 @@ int mdio_clause45_check_mmds(struct efx_nic *efx,
217extern int mdio_clause45_links_ok(struct efx_nic *efx, 233extern int mdio_clause45_links_ok(struct efx_nic *efx,
218 unsigned int mmd_mask); 234 unsigned int mmd_mask);
219 235
236/* Generic transmit disable support though PMAPMD */
237extern void mdio_clause45_transmit_disable(struct efx_nic *efx);
238
239/* Generic part of reconfigure: set/clear loopback bits */
240extern void mdio_clause45_phy_reconfigure(struct efx_nic *efx);
241
220/* Read (some of) the PHY settings over MDIO */ 242/* Read (some of) the PHY settings over MDIO */
221extern void mdio_clause45_get_settings(struct efx_nic *efx, 243extern void mdio_clause45_get_settings(struct efx_nic *efx,
222 struct ethtool_cmd *ecmd); 244 struct ethtool_cmd *ecmd);
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index c505482c2520..59f261b4171f 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -134,6 +134,8 @@ struct efx_special_buffer {
134 * Set only on the final fragment of a packet; %NULL for all other 134 * Set only on the final fragment of a packet; %NULL for all other
135 * fragments. When this fragment completes, then we can free this 135 * fragments. When this fragment completes, then we can free this
136 * skb. 136 * skb.
137 * @tsoh: The associated TSO header structure, or %NULL if this
138 * buffer is not a TSO header.
137 * @dma_addr: DMA address of the fragment. 139 * @dma_addr: DMA address of the fragment.
138 * @len: Length of this fragment. 140 * @len: Length of this fragment.
139 * This field is zero when the queue slot is empty. 141 * This field is zero when the queue slot is empty.
@@ -144,6 +146,7 @@ struct efx_special_buffer {
144 */ 146 */
145struct efx_tx_buffer { 147struct efx_tx_buffer {
146 const struct sk_buff *skb; 148 const struct sk_buff *skb;
149 struct efx_tso_header *tsoh;
147 dma_addr_t dma_addr; 150 dma_addr_t dma_addr;
148 unsigned short len; 151 unsigned short len;
149 unsigned char continuation; 152 unsigned char continuation;
@@ -187,6 +190,13 @@ struct efx_tx_buffer {
187 * variable indicates that the queue is full. This is to 190 * variable indicates that the queue is full. This is to
188 * avoid cache-line ping-pong between the xmit path and the 191 * avoid cache-line ping-pong between the xmit path and the
189 * completion path. 192 * completion path.
193 * @tso_headers_free: A list of TSO headers allocated for this TX queue
194 * that are not in use, and so available for new TSO sends. The list
195 * is protected by the TX queue lock.
196 * @tso_bursts: Number of times TSO xmit invoked by kernel
197 * @tso_long_headers: Number of packets with headers too long for standard
198 * blocks
199 * @tso_packets: Number of packets via the TSO xmit path
190 */ 200 */
191struct efx_tx_queue { 201struct efx_tx_queue {
192 /* Members which don't change on the fast path */ 202 /* Members which don't change on the fast path */
@@ -206,6 +216,10 @@ struct efx_tx_queue {
206 unsigned int insert_count ____cacheline_aligned_in_smp; 216 unsigned int insert_count ____cacheline_aligned_in_smp;
207 unsigned int write_count; 217 unsigned int write_count;
208 unsigned int old_read_count; 218 unsigned int old_read_count;
219 struct efx_tso_header *tso_headers_free;
220 unsigned int tso_bursts;
221 unsigned int tso_long_headers;
222 unsigned int tso_packets;
209}; 223};
210 224
211/** 225/**
@@ -434,6 +448,9 @@ struct efx_board {
434 struct efx_blinker blinker; 448 struct efx_blinker blinker;
435}; 449};
436 450
451#define STRING_TABLE_LOOKUP(val, member) \
452 member ## _names[val]
453
437enum efx_int_mode { 454enum efx_int_mode {
438 /* Be careful if altering to correct macro below */ 455 /* Be careful if altering to correct macro below */
439 EFX_INT_MODE_MSIX = 0, 456 EFX_INT_MODE_MSIX = 0,
@@ -506,6 +523,7 @@ enum efx_fc_type {
506 * @check_hw: Check hardware 523 * @check_hw: Check hardware
507 * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset) 524 * @reset_xaui: Reset XAUI side of PHY for (software sequenced reset)
508 * @mmds: MMD presence mask 525 * @mmds: MMD presence mask
526 * @loopbacks: Supported loopback modes mask
509 */ 527 */
510struct efx_phy_operations { 528struct efx_phy_operations {
511 int (*init) (struct efx_nic *efx); 529 int (*init) (struct efx_nic *efx);
@@ -515,6 +533,7 @@ struct efx_phy_operations {
515 int (*check_hw) (struct efx_nic *efx); 533 int (*check_hw) (struct efx_nic *efx);
516 void (*reset_xaui) (struct efx_nic *efx); 534 void (*reset_xaui) (struct efx_nic *efx);
517 int mmds; 535 int mmds;
536 unsigned loopbacks;
518}; 537};
519 538
520/* 539/*
@@ -653,7 +672,6 @@ union efx_multicast_hash {
653 * @phy_op: PHY interface 672 * @phy_op: PHY interface
654 * @phy_data: PHY private data (including PHY-specific stats) 673 * @phy_data: PHY private data (including PHY-specific stats)
655 * @mii: PHY interface 674 * @mii: PHY interface
656 * @phy_powered: PHY power state
657 * @tx_disabled: PHY transmitter turned off 675 * @tx_disabled: PHY transmitter turned off
658 * @link_up: Link status 676 * @link_up: Link status
659 * @link_options: Link options (MII/GMII format) 677 * @link_options: Link options (MII/GMII format)
@@ -662,6 +680,9 @@ union efx_multicast_hash {
662 * @multicast_hash: Multicast hash table 680 * @multicast_hash: Multicast hash table
663 * @flow_control: Flow control flags - separate RX/TX so can't use link_options 681 * @flow_control: Flow control flags - separate RX/TX so can't use link_options
664 * @reconfigure_work: work item for dealing with PHY events 682 * @reconfigure_work: work item for dealing with PHY events
683 * @loopback_mode: Loopback status
684 * @loopback_modes: Supported loopback mode bitmask
685 * @loopback_selftest: Offline self-test private state
665 * 686 *
666 * The @priv field of the corresponding &struct net_device points to 687 * The @priv field of the corresponding &struct net_device points to
667 * this. 688 * this.
@@ -721,6 +742,7 @@ struct efx_nic {
721 struct efx_phy_operations *phy_op; 742 struct efx_phy_operations *phy_op;
722 void *phy_data; 743 void *phy_data;
723 struct mii_if_info mii; 744 struct mii_if_info mii;
745 unsigned tx_disabled;
724 746
725 int link_up; 747 int link_up;
726 unsigned int link_options; 748 unsigned int link_options;
@@ -732,6 +754,10 @@ struct efx_nic {
732 struct work_struct reconfigure_work; 754 struct work_struct reconfigure_work;
733 755
734 atomic_t rx_reset; 756 atomic_t rx_reset;
757 enum efx_loopback_mode loopback_mode;
758 unsigned int loopback_modes;
759
760 void *loopback_selftest;
735}; 761};
736 762
737/** 763/**
diff --git a/drivers/net/sfc/rx.c b/drivers/net/sfc/rx.c
index 551299b462ae..670622373ddf 100644
--- a/drivers/net/sfc/rx.c
+++ b/drivers/net/sfc/rx.c
@@ -19,6 +19,7 @@
19#include "rx.h" 19#include "rx.h"
20#include "efx.h" 20#include "efx.h"
21#include "falcon.h" 21#include "falcon.h"
22#include "selftest.h"
22#include "workarounds.h" 23#include "workarounds.h"
23 24
24/* Number of RX descriptors pushed at once. */ 25/* Number of RX descriptors pushed at once. */
@@ -683,6 +684,15 @@ void __efx_rx_packet(struct efx_channel *channel,
683 struct sk_buff *skb; 684 struct sk_buff *skb;
684 int lro = efx->net_dev->features & NETIF_F_LRO; 685 int lro = efx->net_dev->features & NETIF_F_LRO;
685 686
687 /* If we're in loopback test, then pass the packet directly to the
688 * loopback layer, and free the rx_buf here
689 */
690 if (unlikely(efx->loopback_selftest)) {
691 efx_loopback_rx_packet(efx, rx_buf->data, rx_buf->len);
692 efx_free_rx_buffer(efx, rx_buf);
693 goto done;
694 }
695
686 if (rx_buf->skb) { 696 if (rx_buf->skb) {
687 prefetch(skb_shinfo(rx_buf->skb)); 697 prefetch(skb_shinfo(rx_buf->skb));
688 698
@@ -736,7 +746,6 @@ void __efx_rx_packet(struct efx_channel *channel,
736 /* Update allocation strategy method */ 746 /* Update allocation strategy method */
737 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB; 747 channel->rx_alloc_level += RX_ALLOC_FACTOR_SKB;
738 748
739 /* fall-thru */
740done: 749done:
741 efx->net_dev->last_rx = jiffies; 750 efx->net_dev->last_rx = jiffies;
742} 751}
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c
new file mode 100644
index 000000000000..cbda15946e8f
--- /dev/null
+++ b/drivers/net/sfc/selftest.c
@@ -0,0 +1,717 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#include <linux/netdevice.h>
12#include <linux/module.h>
13#include <linux/delay.h>
14#include <linux/kernel_stat.h>
15#include <linux/pci.h>
16#include <linux/ethtool.h>
17#include <linux/ip.h>
18#include <linux/in.h>
19#include <linux/udp.h>
20#include <linux/rtnetlink.h>
21#include <asm/io.h>
22#include "net_driver.h"
23#include "ethtool.h"
24#include "efx.h"
25#include "falcon.h"
26#include "selftest.h"
27#include "boards.h"
28#include "workarounds.h"
29#include "mac.h"
30
31/*
32 * Loopback test packet structure
33 *
34 * The self-test should stress every RSS vector, and unfortunately
35 * Falcon only performs RSS on TCP/UDP packets.
36 */
37struct efx_loopback_payload {
38 struct ethhdr header;
39 struct iphdr ip;
40 struct udphdr udp;
41 __be16 iteration;
42 const char msg[64];
43} __attribute__ ((packed));
44
45/* Loopback test source MAC address */
46static const unsigned char payload_source[ETH_ALEN] = {
47 0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
48};
49
50static const char *payload_msg =
51 "Hello world! This is an Efx loopback test in progress!";
52
53/**
54 * efx_selftest_state - persistent state during a selftest
55 * @flush: Drop all packets in efx_loopback_rx_packet
56 * @packet_count: Number of packets being used in this test
57 * @skbs: An array of skbs transmitted
58 * @rx_good: RX good packet count
59 * @rx_bad: RX bad packet count
60 * @payload: Payload used in tests
61 */
62struct efx_selftest_state {
63 int flush;
64 int packet_count;
65 struct sk_buff **skbs;
66 atomic_t rx_good;
67 atomic_t rx_bad;
68 struct efx_loopback_payload payload;
69};
70
71/**************************************************************************
72 *
73 * Configurable values
74 *
75 **************************************************************************/
76
77/* Level of loopback testing
78 *
79 * The maximum packet burst length is 16**(n-1), i.e.
80 *
81 * - Level 0 : no packets
82 * - Level 1 : 1 packet
83 * - Level 2 : 17 packets (1 * 1 packet, 1 * 16 packets)
84 * - Level 3 : 273 packets (1 * 1 packet, 1 * 16 packet, 1 * 256 packets)
85 *
86 */
87static unsigned int loopback_test_level = 3;
88
89/**************************************************************************
90 *
91 * Interrupt and event queue testing
92 *
93 **************************************************************************/
94
95/* Test generation and receipt of interrupts */
96static int efx_test_interrupts(struct efx_nic *efx,
97 struct efx_self_tests *tests)
98{
99 struct efx_channel *channel;
100
101 EFX_LOG(efx, "testing interrupts\n");
102 tests->interrupt = -1;
103
104 /* Reset interrupt flag */
105 efx->last_irq_cpu = -1;
106 smp_wmb();
107
108 /* ACK each interrupting event queue. Receiving an interrupt due to
109 * traffic before a test event is raised is considered a pass */
110 efx_for_each_channel_with_interrupt(channel, efx) {
111 if (channel->work_pending)
112 efx_process_channel_now(channel);
113 if (efx->last_irq_cpu >= 0)
114 goto success;
115 }
116
117 falcon_generate_interrupt(efx);
118
119 /* Wait for arrival of test interrupt. */
120 EFX_LOG(efx, "waiting for test interrupt\n");
121 schedule_timeout_uninterruptible(HZ / 10);
122 if (efx->last_irq_cpu >= 0)
123 goto success;
124
125 EFX_ERR(efx, "timed out waiting for interrupt\n");
126 return -ETIMEDOUT;
127
128 success:
129 EFX_LOG(efx, "test interrupt (mode %d) seen on CPU%d\n",
130 efx->interrupt_mode, efx->last_irq_cpu);
131 tests->interrupt = 1;
132 return 0;
133}
134
135/* Test generation and receipt of non-interrupting events */
136static int efx_test_eventq(struct efx_channel *channel,
137 struct efx_self_tests *tests)
138{
139 unsigned int magic;
140
141 /* Channel specific code, limited to 20 bits */
142 magic = (0x00010150 + channel->channel);
143 EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n",
144 channel->channel, magic);
145
146 tests->eventq_dma[channel->channel] = -1;
147 tests->eventq_int[channel->channel] = 1; /* fake pass */
148 tests->eventq_poll[channel->channel] = 1; /* fake pass */
149
150 /* Reset flag and zero magic word */
151 channel->efx->last_irq_cpu = -1;
152 channel->eventq_magic = 0;
153 smp_wmb();
154
155 falcon_generate_test_event(channel, magic);
156 udelay(1);
157
158 efx_process_channel_now(channel);
159 if (channel->eventq_magic != magic) {
160 EFX_ERR(channel->efx, "channel %d failed to see test event\n",
161 channel->channel);
162 return -ETIMEDOUT;
163 } else {
164 tests->eventq_dma[channel->channel] = 1;
165 }
166
167 return 0;
168}
169
170/* Test generation and receipt of interrupting events */
171static int efx_test_eventq_irq(struct efx_channel *channel,
172 struct efx_self_tests *tests)
173{
174 unsigned int magic, count;
175
176 /* Channel specific code, limited to 20 bits */
177 magic = (0x00010150 + channel->channel);
178 EFX_LOG(channel->efx, "channel %d testing event queue with code %x\n",
179 channel->channel, magic);
180
181 tests->eventq_dma[channel->channel] = -1;
182 tests->eventq_int[channel->channel] = -1;
183 tests->eventq_poll[channel->channel] = -1;
184
185 /* Reset flag and zero magic word */
186 channel->efx->last_irq_cpu = -1;
187 channel->eventq_magic = 0;
188 smp_wmb();
189
190 falcon_generate_test_event(channel, magic);
191
192 /* Wait for arrival of interrupt */
193 count = 0;
194 do {
195 schedule_timeout_uninterruptible(HZ / 100);
196
197 if (channel->work_pending)
198 efx_process_channel_now(channel);
199
200 if (channel->eventq_magic == magic)
201 goto eventq_ok;
202 } while (++count < 2);
203
204 EFX_ERR(channel->efx, "channel %d timed out waiting for event queue\n",
205 channel->channel);
206
207 /* See if interrupt arrived */
208 if (channel->efx->last_irq_cpu >= 0) {
209 EFX_ERR(channel->efx, "channel %d saw interrupt on CPU%d "
210 "during event queue test\n", channel->channel,
211 raw_smp_processor_id());
212 tests->eventq_int[channel->channel] = 1;
213 }
214
215 /* Check to see if event was received even if interrupt wasn't */
216 efx_process_channel_now(channel);
217 if (channel->eventq_magic == magic) {
218 EFX_ERR(channel->efx, "channel %d event was generated, but "
219 "failed to trigger an interrupt\n", channel->channel);
220 tests->eventq_dma[channel->channel] = 1;
221 }
222
223 return -ETIMEDOUT;
224 eventq_ok:
225 EFX_LOG(channel->efx, "channel %d event queue passed\n",
226 channel->channel);
227 tests->eventq_dma[channel->channel] = 1;
228 tests->eventq_int[channel->channel] = 1;
229 tests->eventq_poll[channel->channel] = 1;
230 return 0;
231}
232
233/**************************************************************************
234 *
235 * PHY testing
236 *
237 **************************************************************************/
238
239/* Check PHY presence by reading the PHY ID registers */
240static int efx_test_phy(struct efx_nic *efx,
241 struct efx_self_tests *tests)
242{
243 u16 physid1, physid2;
244 struct mii_if_info *mii = &efx->mii;
245 struct net_device *net_dev = efx->net_dev;
246
247 if (efx->phy_type == PHY_TYPE_NONE)
248 return 0;
249
250 EFX_LOG(efx, "testing PHY presence\n");
251 tests->phy_ok = -1;
252
253 physid1 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID1);
254 physid2 = mii->mdio_read(net_dev, mii->phy_id, MII_PHYSID2);
255
256 if ((physid1 != 0x0000) && (physid1 != 0xffff) &&
257 (physid2 != 0x0000) && (physid2 != 0xffff)) {
258 EFX_LOG(efx, "found MII PHY %d ID 0x%x:%x\n",
259 mii->phy_id, physid1, physid2);
260 tests->phy_ok = 1;
261 return 0;
262 }
263
264 EFX_ERR(efx, "no MII PHY present with ID %d\n", mii->phy_id);
265 return -ENODEV;
266}
267
268/**************************************************************************
269 *
270 * Loopback testing
271 * NB Only one loopback test can be executing concurrently.
272 *
273 **************************************************************************/
274
275/* Loopback test RX callback
276 * This is called for each received packet during loopback testing.
277 */
278void efx_loopback_rx_packet(struct efx_nic *efx,
279 const char *buf_ptr, int pkt_len)
280{
281 struct efx_selftest_state *state = efx->loopback_selftest;
282 struct efx_loopback_payload *received;
283 struct efx_loopback_payload *payload;
284
285 BUG_ON(!buf_ptr);
286
287 /* If we are just flushing, then drop the packet */
288 if ((state == NULL) || state->flush)
289 return;
290
291 payload = &state->payload;
292
293 received = (struct efx_loopback_payload *)(char *) buf_ptr;
294 received->ip.saddr = payload->ip.saddr;
295 received->ip.check = payload->ip.check;
296
297 /* Check that header exists */
298 if (pkt_len < sizeof(received->header)) {
299 EFX_ERR(efx, "saw runt RX packet (length %d) in %s loopback "
300 "test\n", pkt_len, LOOPBACK_MODE(efx));
301 goto err;
302 }
303
304 /* Check that the ethernet header exists */
305 if (memcmp(&received->header, &payload->header, ETH_HLEN) != 0) {
306 EFX_ERR(efx, "saw non-loopback RX packet in %s loopback test\n",
307 LOOPBACK_MODE(efx));
308 goto err;
309 }
310
311 /* Check packet length */
312 if (pkt_len != sizeof(*payload)) {
313 EFX_ERR(efx, "saw incorrect RX packet length %d (wanted %d) in "
314 "%s loopback test\n", pkt_len, (int)sizeof(*payload),
315 LOOPBACK_MODE(efx));
316 goto err;
317 }
318
319 /* Check that IP header matches */
320 if (memcmp(&received->ip, &payload->ip, sizeof(payload->ip)) != 0) {
321 EFX_ERR(efx, "saw corrupted IP header in %s loopback test\n",
322 LOOPBACK_MODE(efx));
323 goto err;
324 }
325
326 /* Check that msg and padding matches */
327 if (memcmp(&received->msg, &payload->msg, sizeof(received->msg)) != 0) {
328 EFX_ERR(efx, "saw corrupted RX packet in %s loopback test\n",
329 LOOPBACK_MODE(efx));
330 goto err;
331 }
332
333 /* Check that iteration matches */
334 if (received->iteration != payload->iteration) {
335 EFX_ERR(efx, "saw RX packet from iteration %d (wanted %d) in "
336 "%s loopback test\n", ntohs(received->iteration),
337 ntohs(payload->iteration), LOOPBACK_MODE(efx));
338 goto err;
339 }
340
341 /* Increase correct RX count */
342 EFX_TRACE(efx, "got loopback RX in %s loopback test\n",
343 LOOPBACK_MODE(efx));
344
345 atomic_inc(&state->rx_good);
346 return;
347
348 err:
349#ifdef EFX_ENABLE_DEBUG
350 if (atomic_read(&state->rx_bad) == 0) {
351 EFX_ERR(efx, "received packet:\n");
352 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
353 buf_ptr, pkt_len, 0);
354 EFX_ERR(efx, "expected packet:\n");
355 print_hex_dump(KERN_ERR, "", DUMP_PREFIX_OFFSET, 0x10, 1,
356 &state->payload, sizeof(state->payload), 0);
357 }
358#endif
359 atomic_inc(&state->rx_bad);
360}
361
362/* Initialise an efx_selftest_state for a new iteration */
363static void efx_iterate_state(struct efx_nic *efx)
364{
365 struct efx_selftest_state *state = efx->loopback_selftest;
366 struct net_device *net_dev = efx->net_dev;
367 struct efx_loopback_payload *payload = &state->payload;
368
369 /* Initialise the layerII header */
370 memcpy(&payload->header.h_dest, net_dev->dev_addr, ETH_ALEN);
371 memcpy(&payload->header.h_source, &payload_source, ETH_ALEN);
372 payload->header.h_proto = htons(ETH_P_IP);
373
374 /* saddr set later and used as incrementing count */
375 payload->ip.daddr = htonl(INADDR_LOOPBACK);
376 payload->ip.ihl = 5;
377 payload->ip.check = htons(0xdead);
378 payload->ip.tot_len = htons(sizeof(*payload) - sizeof(struct ethhdr));
379 payload->ip.version = IPVERSION;
380 payload->ip.protocol = IPPROTO_UDP;
381
382 /* Initialise udp header */
383 payload->udp.source = 0;
384 payload->udp.len = htons(sizeof(*payload) - sizeof(struct ethhdr) -
385 sizeof(struct iphdr));
386 payload->udp.check = 0; /* checksum ignored */
387
388 /* Fill out payload */
389 payload->iteration = htons(ntohs(payload->iteration) + 1);
390 memcpy(&payload->msg, payload_msg, sizeof(payload_msg));
391
392 /* Fill out remaining state members */
393 atomic_set(&state->rx_good, 0);
394 atomic_set(&state->rx_bad, 0);
395 smp_wmb();
396}
397
398static int efx_tx_loopback(struct efx_tx_queue *tx_queue)
399{
400 struct efx_nic *efx = tx_queue->efx;
401 struct efx_selftest_state *state = efx->loopback_selftest;
402 struct efx_loopback_payload *payload;
403 struct sk_buff *skb;
404 int i, rc;
405
406 /* Transmit N copies of buffer */
407 for (i = 0; i < state->packet_count; i++) {
408 /* Allocate an skb, holding an extra reference for
409 * transmit completion counting */
410 skb = alloc_skb(sizeof(state->payload), GFP_KERNEL);
411 if (!skb)
412 return -ENOMEM;
413 state->skbs[i] = skb;
414 skb_get(skb);
415
416 /* Copy the payload in, incrementing the source address to
417 * exercise the rss vectors */
418 payload = ((struct efx_loopback_payload *)
419 skb_put(skb, sizeof(state->payload)));
420 memcpy(payload, &state->payload, sizeof(state->payload));
421 payload->ip.saddr = htonl(INADDR_LOOPBACK | (i << 2));
422
423 /* Ensure everything we've written is visible to the
424 * interrupt handler. */
425 smp_wmb();
426
427 if (NET_DEV_REGISTERED(efx))
428 netif_tx_lock_bh(efx->net_dev);
429 rc = efx_xmit(efx, tx_queue, skb);
430 if (NET_DEV_REGISTERED(efx))
431 netif_tx_unlock_bh(efx->net_dev);
432
433 if (rc != NETDEV_TX_OK) {
434 EFX_ERR(efx, "TX queue %d could not transmit packet %d "
435 "of %d in %s loopback test\n", tx_queue->queue,
436 i + 1, state->packet_count, LOOPBACK_MODE(efx));
437
438 /* Defer cleaning up the other skbs for the caller */
439 kfree_skb(skb);
440 return -EPIPE;
441 }
442 }
443
444 return 0;
445}
446
447static int efx_rx_loopback(struct efx_tx_queue *tx_queue,
448 struct efx_loopback_self_tests *lb_tests)
449{
450 struct efx_nic *efx = tx_queue->efx;
451 struct efx_selftest_state *state = efx->loopback_selftest;
452 struct sk_buff *skb;
453 int tx_done = 0, rx_good, rx_bad;
454 int i, rc = 0;
455
456 if (NET_DEV_REGISTERED(efx))
457 netif_tx_lock_bh(efx->net_dev);
458
459 /* Count the number of tx completions, and decrement the refcnt. Any
460 * skbs not already completed will be free'd when the queue is flushed */
461 for (i=0; i < state->packet_count; i++) {
462 skb = state->skbs[i];
463 if (skb && !skb_shared(skb))
464 ++tx_done;
465 dev_kfree_skb_any(skb);
466 }
467
468 if (NET_DEV_REGISTERED(efx))
469 netif_tx_unlock_bh(efx->net_dev);
470
471 /* Check TX completion and received packet counts */
472 rx_good = atomic_read(&state->rx_good);
473 rx_bad = atomic_read(&state->rx_bad);
474 if (tx_done != state->packet_count) {
475 /* Don't free the skbs; they will be picked up on TX
476 * overflow or channel teardown.
477 */
478 EFX_ERR(efx, "TX queue %d saw only %d out of an expected %d "
479 "TX completion events in %s loopback test\n",
480 tx_queue->queue, tx_done, state->packet_count,
481 LOOPBACK_MODE(efx));
482 rc = -ETIMEDOUT;
483 /* Allow to fall through so we see the RX errors as well */
484 }
485
486 /* We may always be up to a flush away from our desired packet total */
487 if (rx_good != state->packet_count) {
488 EFX_LOG(efx, "TX queue %d saw only %d out of an expected %d "
489 "received packets in %s loopback test\n",
490 tx_queue->queue, rx_good, state->packet_count,
491 LOOPBACK_MODE(efx));
492 rc = -ETIMEDOUT;
493 /* Fall through */
494 }
495
496 /* Update loopback test structure */
497 lb_tests->tx_sent[tx_queue->queue] += state->packet_count;
498 lb_tests->tx_done[tx_queue->queue] += tx_done;
499 lb_tests->rx_good += rx_good;
500 lb_tests->rx_bad += rx_bad;
501
502 return rc;
503}
504
505static int
506efx_test_loopback(struct efx_tx_queue *tx_queue,
507 struct efx_loopback_self_tests *lb_tests)
508{
509 struct efx_nic *efx = tx_queue->efx;
510 struct efx_selftest_state *state = efx->loopback_selftest;
511 struct efx_channel *channel;
512 int i, rc = 0;
513
514 for (i = 0; i < loopback_test_level; i++) {
515 /* Determine how many packets to send */
516 state->packet_count = (efx->type->txd_ring_mask + 1) / 3;
517 state->packet_count = min(1 << (i << 2), state->packet_count);
518 state->skbs = kzalloc(sizeof(state->skbs[0]) *
519 state->packet_count, GFP_KERNEL);
520 state->flush = 0;
521
522 EFX_LOG(efx, "TX queue %d testing %s loopback with %d "
523 "packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
524 state->packet_count);
525
526 efx_iterate_state(efx);
527 rc = efx_tx_loopback(tx_queue);
528
529 /* NAPI polling is not enabled, so process channels synchronously */
530 schedule_timeout_uninterruptible(HZ / 50);
531 efx_for_each_channel_with_interrupt(channel, efx) {
532 if (channel->work_pending)
533 efx_process_channel_now(channel);
534 }
535
536 rc |= efx_rx_loopback(tx_queue, lb_tests);
537 kfree(state->skbs);
538
539 if (rc) {
540 /* Wait a while to ensure there are no packets
541 * floating around after a failure. */
542 schedule_timeout_uninterruptible(HZ / 10);
543 return rc;
544 }
545 }
546
547 EFX_LOG(efx, "TX queue %d passed %s loopback test with a burst length "
548 "of %d packets\n", tx_queue->queue, LOOPBACK_MODE(efx),
549 state->packet_count);
550
551 return rc;
552}
553
554static int efx_test_loopbacks(struct efx_nic *efx,
555 struct efx_self_tests *tests,
556 unsigned int loopback_modes)
557{
558 struct efx_selftest_state *state = efx->loopback_selftest;
559 struct ethtool_cmd ecmd, ecmd_loopback;
560 struct efx_tx_queue *tx_queue;
561 enum efx_loopback_mode old_mode, mode;
562 int count, rc = 0, link_up;
563
564 rc = efx_ethtool_get_settings(efx->net_dev, &ecmd);
565 if (rc) {
566 EFX_ERR(efx, "could not get GMII settings\n");
567 return rc;
568 }
569 old_mode = efx->loopback_mode;
570
571 /* Disable autonegotiation for the purposes of loopback */
572 memcpy(&ecmd_loopback, &ecmd, sizeof(ecmd_loopback));
573 if (ecmd_loopback.autoneg == AUTONEG_ENABLE) {
574 ecmd_loopback.autoneg = AUTONEG_DISABLE;
575 ecmd_loopback.duplex = DUPLEX_FULL;
576 ecmd_loopback.speed = SPEED_10000;
577 }
578
579 rc = efx_ethtool_set_settings(efx->net_dev, &ecmd_loopback);
580 if (rc) {
581 EFX_ERR(efx, "could not disable autonegotiation\n");
582 goto out;
583 }
584 tests->loopback_speed = ecmd_loopback.speed;
585 tests->loopback_full_duplex = ecmd_loopback.duplex;
586
587 /* Test all supported loopback modes */
588 for (mode = LOOPBACK_NONE; mode < LOOPBACK_TEST_MAX; mode++) {
589 if (!(loopback_modes & (1 << mode)))
590 continue;
591
592 /* Move the port into the specified loopback mode. */
593 state->flush = 1;
594 efx->loopback_mode = mode;
595 efx_reconfigure_port(efx);
596
597 /* Wait for the PHY to signal the link is up */
598 count = 0;
599 do {
600 struct efx_channel *channel = &efx->channel[0];
601
602 falcon_check_xmac(efx);
603 schedule_timeout_uninterruptible(HZ / 10);
604 if (channel->work_pending)
605 efx_process_channel_now(channel);
606 /* Wait for PHY events to be processed */
607 flush_workqueue(efx->workqueue);
608 rmb();
609
610 /* efx->link_up can be 1 even if the XAUI link is down,
611 * (bug5762). Usually, it's not worth bothering with the
612 * difference, but for selftests, we need that extra
613 * guarantee that the link is really, really, up.
614 */
615 link_up = efx->link_up;
616 if (!falcon_xaui_link_ok(efx))
617 link_up = 0;
618
619 } while ((++count < 20) && !link_up);
620
621 /* The link should now be up. If it isn't, there is no point
622 * in attempting a loopback test */
623 if (!link_up) {
624 EFX_ERR(efx, "loopback %s never came up\n",
625 LOOPBACK_MODE(efx));
626 rc = -EIO;
627 goto out;
628 }
629
630 EFX_LOG(efx, "link came up in %s loopback in %d iterations\n",
631 LOOPBACK_MODE(efx), count);
632
633 /* Test every TX queue */
634 efx_for_each_tx_queue(tx_queue, efx) {
635 rc |= efx_test_loopback(tx_queue,
636 &tests->loopback[mode]);
637 if (rc)
638 goto out;
639 }
640 }
641
642 out:
643 /* Take out of loopback and restore PHY settings */
644 state->flush = 1;
645 efx->loopback_mode = old_mode;
646 efx_ethtool_set_settings(efx->net_dev, &ecmd);
647
648 return rc;
649}
650
651/**************************************************************************
652 *
653 * Entry points
654 *
655 *************************************************************************/
656
657/* Online (i.e. non-disruptive) testing
658 * This checks interrupt generation, event delivery and PHY presence. */
659int efx_online_test(struct efx_nic *efx, struct efx_self_tests *tests)
660{
661 struct efx_channel *channel;
662 int rc = 0;
663
664 EFX_LOG(efx, "performing online self-tests\n");
665
666 rc |= efx_test_interrupts(efx, tests);
667 efx_for_each_channel(channel, efx) {
668 if (channel->has_interrupt)
669 rc |= efx_test_eventq_irq(channel, tests);
670 else
671 rc |= efx_test_eventq(channel, tests);
672 }
673 rc |= efx_test_phy(efx, tests);
674
675 if (rc)
676 EFX_ERR(efx, "failed online self-tests\n");
677
678 return rc;
679}
680
681/* Offline (i.e. disruptive) testing
682 * This checks MAC and PHY loopback on the specified port. */
683int efx_offline_test(struct efx_nic *efx,
684 struct efx_self_tests *tests, unsigned int loopback_modes)
685{
686 struct efx_selftest_state *state;
687 int rc = 0;
688
689 EFX_LOG(efx, "performing offline self-tests\n");
690
691 /* Create a selftest_state structure to hold state for the test */
692 state = kzalloc(sizeof(*state), GFP_KERNEL);
693 if (state == NULL) {
694 rc = -ENOMEM;
695 goto out;
696 }
697
698 /* Set the port loopback_selftest member. From this point on
699 * all received packets will be dropped. Mark the state as
700 * "flushing" so all inflight packets are dropped */
701 BUG_ON(efx->loopback_selftest);
702 state->flush = 1;
703 efx->loopback_selftest = (void *)state;
704
705 rc = efx_test_loopbacks(efx, tests, loopback_modes);
706
707 efx->loopback_selftest = NULL;
708 wmb();
709 kfree(state);
710
711 out:
712 if (rc)
713 EFX_ERR(efx, "failed offline self-tests\n");
714
715 return rc;
716}
717
diff --git a/drivers/net/sfc/selftest.h b/drivers/net/sfc/selftest.h
new file mode 100644
index 000000000000..f6999c2b622d
--- /dev/null
+++ b/drivers/net/sfc/selftest.h
@@ -0,0 +1,50 @@
1/****************************************************************************
2 * Driver for Solarflare Solarstorm network controllers and boards
3 * Copyright 2005-2006 Fen Systems Ltd.
4 * Copyright 2006-2008 Solarflare Communications Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation, incorporated herein by reference.
9 */
10
11#ifndef EFX_SELFTEST_H
12#define EFX_SELFTEST_H
13
14#include "net_driver.h"
15
16/*
17 * Self tests
18 */
19
20struct efx_loopback_self_tests {
21 int tx_sent[EFX_MAX_TX_QUEUES];
22 int tx_done[EFX_MAX_TX_QUEUES];
23 int rx_good;
24 int rx_bad;
25};
26
27/* Efx self test results
28 * For fields which are not counters, 1 indicates success and -1
29 * indicates failure.
30 */
31struct efx_self_tests {
32 int interrupt;
33 int eventq_dma[EFX_MAX_CHANNELS];
34 int eventq_int[EFX_MAX_CHANNELS];
35 int eventq_poll[EFX_MAX_CHANNELS];
36 int phy_ok;
37 int loopback_speed;
38 int loopback_full_duplex;
39 struct efx_loopback_self_tests loopback[LOOPBACK_TEST_MAX];
40};
41
42extern void efx_loopback_rx_packet(struct efx_nic *efx,
43 const char *buf_ptr, int pkt_len);
44extern int efx_online_test(struct efx_nic *efx,
45 struct efx_self_tests *tests);
46extern int efx_offline_test(struct efx_nic *efx,
47 struct efx_self_tests *tests,
48 unsigned int loopback_modes);
49
50#endif /* EFX_SELFTEST_H */
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 11fa9fb8f48b..725d1a539c49 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -130,6 +130,15 @@ void sfe4001_poweroff(struct efx_nic *efx)
130 (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1); 130 (void) efx_i2c_read(i2c, MAX6647, RSL, &in, 1);
131} 131}
132 132
133/* The P0_EN_3V3X line on SFE4001 boards (from A2 onward) is connected
134 * to the FLASH_CFG_1 input on the DSP. We must keep it high at power-
135 * up to allow writing the flash (done through MDIO from userland).
136 */
137unsigned int sfe4001_phy_flash_cfg;
138module_param_named(phy_flash_cfg, sfe4001_phy_flash_cfg, uint, 0444);
139MODULE_PARM_DESC(phy_flash_cfg,
140 "Force PHY to enter flash configuration mode");
141
133/* This board uses an I2C expander to provider power to the PHY, which needs to 142/* This board uses an I2C expander to provider power to the PHY, which needs to
134 * be turned on before the PHY can be used. 143 * be turned on before the PHY can be used.
135 * Context: Process context, rtnl lock held 144 * Context: Process context, rtnl lock held
@@ -203,6 +212,8 @@ int sfe4001_poweron(struct efx_nic *efx)
203 out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) | 212 out = 0xff & ~((1 << P0_EN_1V2_LBN) | (1 << P0_EN_2V5_LBN) |
204 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) | 213 (1 << P0_EN_3V3X_LBN) | (1 << P0_EN_5V_LBN) |
205 (1 << P0_X_TRST_LBN)); 214 (1 << P0_X_TRST_LBN));
215 if (sfe4001_phy_flash_cfg)
216 out |= 1 << P0_EN_3V3X_LBN;
206 217
207 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1); 218 rc = efx_i2c_write(i2c, PCA9539, P0_OUT, &out, 1);
208 if (rc) 219 if (rc)
@@ -226,6 +237,9 @@ int sfe4001_poweron(struct efx_nic *efx)
226 if (in & (1 << P1_AFE_PWD_LBN)) 237 if (in & (1 << P1_AFE_PWD_LBN))
227 goto done; 238 goto done;
228 239
240 /* DSP doesn't look powered in flash config mode */
241 if (sfe4001_phy_flash_cfg)
242 goto done;
229 } while (++count < 20); 243 } while (++count < 20);
230 244
231 EFX_INFO(efx, "timed out waiting for power\n"); 245 EFX_INFO(efx, "timed out waiting for power\n");
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index a2e9f79e47b1..b1cd6deec01f 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -24,6 +24,11 @@
24 MDIO_MMDREG_DEVS0_PCS | \ 24 MDIO_MMDREG_DEVS0_PCS | \
25 MDIO_MMDREG_DEVS0_PHYXS) 25 MDIO_MMDREG_DEVS0_PHYXS)
26 26
27#define TENXPRESS_LOOPBACKS ((1 << LOOPBACK_PHYXS) | \
28 (1 << LOOPBACK_PCS) | \
29 (1 << LOOPBACK_PMAPMD) | \
30 (1 << LOOPBACK_NETWORK))
31
27/* We complain if we fail to see the link partner as 10G capable this many 32/* We complain if we fail to see the link partner as 10G capable this many
28 * times in a row (must be > 1 as sampling the autoneg. registers is racy) 33 * times in a row (must be > 1 as sampling the autoneg. registers is racy)
29 */ 34 */
@@ -72,6 +77,10 @@
72#define PMA_PMD_BIST_RXD_LBN (1) 77#define PMA_PMD_BIST_RXD_LBN (1)
73#define PMA_PMD_BIST_AFE_LBN (0) 78#define PMA_PMD_BIST_AFE_LBN (0)
74 79
80/* Special Software reset register */
81#define PMA_PMD_EXT_CTRL_REG 49152
82#define PMA_PMD_EXT_SSR_LBN 15
83
75#define BIST_MAX_DELAY (1000) 84#define BIST_MAX_DELAY (1000)
76#define BIST_POLL_DELAY (10) 85#define BIST_POLL_DELAY (10)
77 86
@@ -86,6 +95,11 @@
86#define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */ 95#define PCS_TEST_SELECT_REG 0xd807 /* PRM 10.5.8 */
87#define CLK312_EN_LBN 3 96#define CLK312_EN_LBN 3
88 97
98/* PHYXS registers */
99#define PHYXS_TEST1 (49162)
100#define LOOPBACK_NEAR_LBN (8)
101#define LOOPBACK_NEAR_WIDTH (1)
102
89/* Boot status register */ 103/* Boot status register */
90#define PCS_BOOT_STATUS_REG (0xd000) 104#define PCS_BOOT_STATUS_REG (0xd000)
91#define PCS_BOOT_FATAL_ERR_LBN (0) 105#define PCS_BOOT_FATAL_ERR_LBN (0)
@@ -106,7 +120,9 @@ MODULE_PARM_DESC(crc_error_reset_threshold,
106 120
107struct tenxpress_phy_data { 121struct tenxpress_phy_data {
108 enum tenxpress_state state; 122 enum tenxpress_state state;
123 enum efx_loopback_mode loopback_mode;
109 atomic_t bad_crc_count; 124 atomic_t bad_crc_count;
125 int tx_disabled;
110 int bad_lp_tries; 126 int bad_lp_tries;
111}; 127};
112 128
@@ -199,10 +215,12 @@ static int tenxpress_phy_init(struct efx_nic *efx)
199 215
200 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL); 216 tenxpress_set_state(efx, TENXPRESS_STATUS_NORMAL);
201 217
202 rc = mdio_clause45_wait_reset_mmds(efx, 218 if (!sfe4001_phy_flash_cfg) {
203 TENXPRESS_REQUIRED_DEVS); 219 rc = mdio_clause45_wait_reset_mmds(efx,
204 if (rc < 0) 220 TENXPRESS_REQUIRED_DEVS);
205 goto fail; 221 if (rc < 0)
222 goto fail;
223 }
206 224
207 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0); 225 rc = mdio_clause45_check_mmds(efx, TENXPRESS_REQUIRED_DEVS, 0);
208 if (rc < 0) 226 if (rc < 0)
@@ -225,6 +243,35 @@ static int tenxpress_phy_init(struct efx_nic *efx)
225 return rc; 243 return rc;
226} 244}
227 245
246static int tenxpress_special_reset(struct efx_nic *efx)
247{
248 int rc, reg;
249
250 EFX_TRACE(efx, "%s\n", __func__);
251
252 /* Initiate reset */
253 reg = mdio_clause45_read(efx, efx->mii.phy_id,
254 MDIO_MMD_PMAPMD, PMA_PMD_EXT_CTRL_REG);
255 reg |= (1 << PMA_PMD_EXT_SSR_LBN);
256 mdio_clause45_write(efx, efx->mii.phy_id, MDIO_MMD_PMAPMD,
257 PMA_PMD_EXT_CTRL_REG, reg);
258
259 msleep(200);
260
261 /* Wait for the blocks to come out of reset */
262 rc = mdio_clause45_wait_reset_mmds(efx,
263 TENXPRESS_REQUIRED_DEVS);
264 if (rc < 0)
265 return rc;
266
267 /* Try and reconfigure the device */
268 rc = tenxpress_init(efx);
269 if (rc < 0)
270 return rc;
271
272 return 0;
273}
274
228static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp) 275static void tenxpress_set_bad_lp(struct efx_nic *efx, int bad_lp)
229{ 276{
230 struct tenxpress_phy_data *pd = efx->phy_data; 277 struct tenxpress_phy_data *pd = efx->phy_data;
@@ -299,11 +346,46 @@ static int tenxpress_link_ok(struct efx_nic *efx, int check_lp)
299 return ok; 346 return ok;
300} 347}
301 348
349static void tenxpress_phyxs_loopback(struct efx_nic *efx)
350{
351 int phy_id = efx->mii.phy_id;
352 int ctrl1, ctrl2;
353
354 ctrl1 = ctrl2 = mdio_clause45_read(efx, phy_id, MDIO_MMD_PHYXS,
355 PHYXS_TEST1);
356 if (efx->loopback_mode == LOOPBACK_PHYXS)
357 ctrl2 |= (1 << LOOPBACK_NEAR_LBN);
358 else
359 ctrl2 &= ~(1 << LOOPBACK_NEAR_LBN);
360 if (ctrl1 != ctrl2)
361 mdio_clause45_write(efx, phy_id, MDIO_MMD_PHYXS,
362 PHYXS_TEST1, ctrl2);
363}
364
302static void tenxpress_phy_reconfigure(struct efx_nic *efx) 365static void tenxpress_phy_reconfigure(struct efx_nic *efx)
303{ 366{
367 struct tenxpress_phy_data *phy_data = efx->phy_data;
368 int loop_change = LOOPBACK_OUT_OF(phy_data, efx,
369 TENXPRESS_LOOPBACKS);
370
304 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL)) 371 if (!tenxpress_state_is(efx, TENXPRESS_STATUS_NORMAL))
305 return; 372 return;
306 373
374 /* When coming out of transmit disable, coming out of low power
375 * mode, or moving out of any PHY internal loopback mode,
376 * perform a special software reset */
377 if ((phy_data->tx_disabled && !efx->tx_disabled) ||
378 loop_change) {
379 (void) tenxpress_special_reset(efx);
380 falcon_reset_xaui(efx);
381 }
382
383 mdio_clause45_transmit_disable(efx);
384 mdio_clause45_phy_reconfigure(efx);
385 tenxpress_phyxs_loopback(efx);
386
387 phy_data->tx_disabled = efx->tx_disabled;
388 phy_data->loopback_mode = efx->loopback_mode;
307 efx->link_up = tenxpress_link_ok(efx, 0); 389 efx->link_up = tenxpress_link_ok(efx, 0);
308 efx->link_options = GM_LPA_10000FULL; 390 efx->link_options = GM_LPA_10000FULL;
309} 391}
@@ -431,4 +513,5 @@ struct efx_phy_operations falcon_tenxpress_phy_ops = {
431 .clear_interrupt = tenxpress_phy_clear_interrupt, 513 .clear_interrupt = tenxpress_phy_clear_interrupt,
432 .reset_xaui = tenxpress_reset_xaui, 514 .reset_xaui = tenxpress_reset_xaui,
433 .mmds = TENXPRESS_REQUIRED_DEVS, 515 .mmds = TENXPRESS_REQUIRED_DEVS,
516 .loopbacks = TENXPRESS_LOOPBACKS,
434}; 517};
diff --git a/drivers/net/sfc/tx.c b/drivers/net/sfc/tx.c
index fbb866b2185e..9b436f5b4888 100644
--- a/drivers/net/sfc/tx.c
+++ b/drivers/net/sfc/tx.c
@@ -82,6 +82,46 @@ static inline void efx_dequeue_buffer(struct efx_tx_queue *tx_queue,
82 } 82 }
83} 83}
84 84
85/**
86 * struct efx_tso_header - a DMA mapped buffer for packet headers
87 * @next: Linked list of free ones.
88 * The list is protected by the TX queue lock.
89 * @dma_unmap_len: Length to unmap for an oversize buffer, or 0.
90 * @dma_addr: The DMA address of the header below.
91 *
92 * This controls the memory used for a TSO header. Use TSOH_DATA()
93 * to find the packet header data. Use TSOH_SIZE() to calculate the
94 * total size required for a given packet header length. TSO headers
95 * in the free list are exactly %TSOH_STD_SIZE bytes in size.
96 */
97struct efx_tso_header {
98 union {
99 struct efx_tso_header *next;
100 size_t unmap_len;
101 };
102 dma_addr_t dma_addr;
103};
104
105static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
106 const struct sk_buff *skb);
107static void efx_fini_tso(struct efx_tx_queue *tx_queue);
108static void efx_tsoh_heap_free(struct efx_tx_queue *tx_queue,
109 struct efx_tso_header *tsoh);
110
111static inline void efx_tsoh_free(struct efx_tx_queue *tx_queue,
112 struct efx_tx_buffer *buffer)
113{
114 if (buffer->tsoh) {
115 if (likely(!buffer->tsoh->unmap_len)) {
116 buffer->tsoh->next = tx_queue->tso_headers_free;
117 tx_queue->tso_headers_free = buffer->tsoh;
118 } else {
119 efx_tsoh_heap_free(tx_queue, buffer->tsoh);
120 }
121 buffer->tsoh = NULL;
122 }
123}
124
85 125
86/* 126/*
87 * Add a socket buffer to a TX queue 127 * Add a socket buffer to a TX queue
@@ -114,6 +154,9 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
114 154
115 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count); 155 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count);
116 156
157 if (skb_shinfo((struct sk_buff *)skb)->gso_size)
158 return efx_enqueue_skb_tso(tx_queue, skb);
159
117 /* Get size of the initial fragment */ 160 /* Get size of the initial fragment */
118 len = skb_headlen(skb); 161 len = skb_headlen(skb);
119 162
@@ -166,6 +209,8 @@ static inline int efx_enqueue_skb(struct efx_tx_queue *tx_queue,
166 insert_ptr = (tx_queue->insert_count & 209 insert_ptr = (tx_queue->insert_count &
167 efx->type->txd_ring_mask); 210 efx->type->txd_ring_mask);
168 buffer = &tx_queue->buffer[insert_ptr]; 211 buffer = &tx_queue->buffer[insert_ptr];
212 efx_tsoh_free(tx_queue, buffer);
213 EFX_BUG_ON_PARANOID(buffer->tsoh);
169 EFX_BUG_ON_PARANOID(buffer->skb); 214 EFX_BUG_ON_PARANOID(buffer->skb);
170 EFX_BUG_ON_PARANOID(buffer->len); 215 EFX_BUG_ON_PARANOID(buffer->len);
171 EFX_BUG_ON_PARANOID(buffer->continuation != 1); 216 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
@@ -432,6 +477,9 @@ void efx_fini_tx_queue(struct efx_tx_queue *tx_queue)
432 477
433 efx_release_tx_buffers(tx_queue); 478 efx_release_tx_buffers(tx_queue);
434 479
480 /* Free up TSO header cache */
481 efx_fini_tso(tx_queue);
482
435 /* Release queue's stop on port, if any */ 483 /* Release queue's stop on port, if any */
436 if (tx_queue->stopped) { 484 if (tx_queue->stopped) {
437 tx_queue->stopped = 0; 485 tx_queue->stopped = 0;
@@ -450,3 +498,619 @@ void efx_remove_tx_queue(struct efx_tx_queue *tx_queue)
450} 498}
451 499
452 500
501/* Efx TCP segmentation acceleration.
502 *
503 * Why? Because by doing it here in the driver we can go significantly
504 * faster than the GSO.
505 *
506 * Requires TX checksum offload support.
507 */
508
509/* Number of bytes inserted at the start of a TSO header buffer,
510 * similar to NET_IP_ALIGN.
511 */
512#if defined(__i386__) || defined(__x86_64__)
513#define TSOH_OFFSET 0
514#else
515#define TSOH_OFFSET NET_IP_ALIGN
516#endif
517
518#define TSOH_BUFFER(tsoh) ((u8 *)(tsoh + 1) + TSOH_OFFSET)
519
520/* Total size of struct efx_tso_header, buffer and padding */
521#define TSOH_SIZE(hdr_len) \
522 (sizeof(struct efx_tso_header) + TSOH_OFFSET + hdr_len)
523
524/* Size of blocks on free list. Larger blocks must be allocated from
525 * the heap.
526 */
527#define TSOH_STD_SIZE 128
528
529#define PTR_DIFF(p1, p2) ((u8 *)(p1) - (u8 *)(p2))
530#define ETH_HDR_LEN(skb) (skb_network_header(skb) - (skb)->data)
531#define SKB_TCP_OFF(skb) PTR_DIFF(tcp_hdr(skb), (skb)->data)
532#define SKB_IPV4_OFF(skb) PTR_DIFF(ip_hdr(skb), (skb)->data)
533
534/**
535 * struct tso_state - TSO state for an SKB
536 * @remaining_len: Bytes of data we've yet to segment
537 * @seqnum: Current sequence number
538 * @packet_space: Remaining space in current packet
539 * @ifc: Input fragment cursor.
540 * Where we are in the current fragment of the incoming SKB. These
541 * values get updated in place when we split a fragment over
542 * multiple packets.
543 * @p: Parameters.
544 * These values are set once at the start of the TSO send and do
545 * not get changed as the routine progresses.
546 *
547 * The state used during segmentation. It is put into this data structure
548 * just to make it easy to pass into inline functions.
549 */
550struct tso_state {
551 unsigned remaining_len;
552 unsigned seqnum;
553 unsigned packet_space;
554
555 struct {
556 /* DMA address of current position */
557 dma_addr_t dma_addr;
558 /* Remaining length */
559 unsigned int len;
560 /* DMA address and length of the whole fragment */
561 unsigned int unmap_len;
562 dma_addr_t unmap_addr;
563 struct page *page;
564 unsigned page_off;
565 } ifc;
566
567 struct {
568 /* The number of bytes of header */
569 unsigned int header_length;
570
571 /* The number of bytes to put in each outgoing segment. */
572 int full_packet_size;
573
574 /* Current IPv4 ID, host endian. */
575 unsigned ipv4_id;
576 } p;
577};
578
579
580/*
581 * Verify that our various assumptions about sk_buffs and the conditions
582 * under which TSO will be attempted hold true.
583 */
584static inline void efx_tso_check_safe(const struct sk_buff *skb)
585{
586 EFX_BUG_ON_PARANOID(skb->protocol != htons(ETH_P_IP));
587 EFX_BUG_ON_PARANOID(((struct ethhdr *)skb->data)->h_proto !=
588 skb->protocol);
589 EFX_BUG_ON_PARANOID(ip_hdr(skb)->protocol != IPPROTO_TCP);
590 EFX_BUG_ON_PARANOID((PTR_DIFF(tcp_hdr(skb), skb->data)
591 + (tcp_hdr(skb)->doff << 2u)) >
592 skb_headlen(skb));
593}
594
595
596/*
597 * Allocate a page worth of efx_tso_header structures, and string them
598 * into the tx_queue->tso_headers_free linked list. Return 0 or -ENOMEM.
599 */
600static int efx_tsoh_block_alloc(struct efx_tx_queue *tx_queue)
601{
602
603 struct pci_dev *pci_dev = tx_queue->efx->pci_dev;
604 struct efx_tso_header *tsoh;
605 dma_addr_t dma_addr;
606 u8 *base_kva, *kva;
607
608 base_kva = pci_alloc_consistent(pci_dev, PAGE_SIZE, &dma_addr);
609 if (base_kva == NULL) {
610 EFX_ERR(tx_queue->efx, "Unable to allocate page for TSO"
611 " headers\n");
612 return -ENOMEM;
613 }
614
615 /* pci_alloc_consistent() allocates pages. */
616 EFX_BUG_ON_PARANOID(dma_addr & (PAGE_SIZE - 1u));
617
618 for (kva = base_kva; kva < base_kva + PAGE_SIZE; kva += TSOH_STD_SIZE) {
619 tsoh = (struct efx_tso_header *)kva;
620 tsoh->dma_addr = dma_addr + (TSOH_BUFFER(tsoh) - base_kva);
621 tsoh->next = tx_queue->tso_headers_free;
622 tx_queue->tso_headers_free = tsoh;
623 }
624
625 return 0;
626}
627
628
629/* Free up a TSO header, and all others in the same page. */
630static void efx_tsoh_block_free(struct efx_tx_queue *tx_queue,
631 struct efx_tso_header *tsoh,
632 struct pci_dev *pci_dev)
633{
634 struct efx_tso_header **p;
635 unsigned long base_kva;
636 dma_addr_t base_dma;
637
638 base_kva = (unsigned long)tsoh & PAGE_MASK;
639 base_dma = tsoh->dma_addr & PAGE_MASK;
640
641 p = &tx_queue->tso_headers_free;
642 while (*p != NULL)
643 if (((unsigned long)*p & PAGE_MASK) == base_kva)
644 *p = (*p)->next;
645 else
646 p = &(*p)->next;
647
648 pci_free_consistent(pci_dev, PAGE_SIZE, (void *)base_kva, base_dma);
649}
650
651static struct efx_tso_header *
652efx_tsoh_heap_alloc(struct efx_tx_queue *tx_queue, size_t header_len)
653{
654 struct efx_tso_header *tsoh;
655
656 tsoh = kmalloc(TSOH_SIZE(header_len), GFP_ATOMIC | GFP_DMA);
657 if (unlikely(!tsoh))
658 return NULL;
659
660 tsoh->dma_addr = pci_map_single(tx_queue->efx->pci_dev,
661 TSOH_BUFFER(tsoh), header_len,
662 PCI_DMA_TODEVICE);
663 if (unlikely(pci_dma_mapping_error(tsoh->dma_addr))) {
664 kfree(tsoh);
665 return NULL;
666 }
667
668 tsoh->unmap_len = header_len;
669 return tsoh;
670}
671
672static void
673efx_tsoh_heap_free(struct efx_tx_queue *tx_queue, struct efx_tso_header *tsoh)
674{
675 pci_unmap_single(tx_queue->efx->pci_dev,
676 tsoh->dma_addr, tsoh->unmap_len,
677 PCI_DMA_TODEVICE);
678 kfree(tsoh);
679}
680
681/**
682 * efx_tx_queue_insert - push descriptors onto the TX queue
683 * @tx_queue: Efx TX queue
684 * @dma_addr: DMA address of fragment
685 * @len: Length of fragment
686 * @skb: Only non-null for end of last segment
687 * @end_of_packet: True if last fragment in a packet
688 * @unmap_addr: DMA address of fragment for unmapping
689 * @unmap_len: Only set this in last segment of a fragment
690 *
691 * Push descriptors onto the TX queue. Return 0 on success or 1 if
692 * @tx_queue full.
693 */
694static int efx_tx_queue_insert(struct efx_tx_queue *tx_queue,
695 dma_addr_t dma_addr, unsigned len,
696 const struct sk_buff *skb, int end_of_packet,
697 dma_addr_t unmap_addr, unsigned unmap_len)
698{
699 struct efx_tx_buffer *buffer;
700 struct efx_nic *efx = tx_queue->efx;
701 unsigned dma_len, fill_level, insert_ptr, misalign;
702 int q_space;
703
704 EFX_BUG_ON_PARANOID(len <= 0);
705
706 fill_level = tx_queue->insert_count - tx_queue->old_read_count;
707 /* -1 as there is no way to represent all descriptors used */
708 q_space = efx->type->txd_ring_mask - 1 - fill_level;
709
710 while (1) {
711 if (unlikely(q_space-- <= 0)) {
712 /* It might be that completions have happened
713 * since the xmit path last checked. Update
714 * the xmit path's copy of read_count.
715 */
716 ++tx_queue->stopped;
717 /* This memory barrier protects the change of
718 * stopped from the access of read_count. */
719 smp_mb();
720 tx_queue->old_read_count =
721 *(volatile unsigned *)&tx_queue->read_count;
722 fill_level = (tx_queue->insert_count
723 - tx_queue->old_read_count);
724 q_space = efx->type->txd_ring_mask - 1 - fill_level;
725 if (unlikely(q_space-- <= 0))
726 return 1;
727 smp_mb();
728 --tx_queue->stopped;
729 }
730
731 insert_ptr = tx_queue->insert_count & efx->type->txd_ring_mask;
732 buffer = &tx_queue->buffer[insert_ptr];
733 ++tx_queue->insert_count;
734
735 EFX_BUG_ON_PARANOID(tx_queue->insert_count -
736 tx_queue->read_count >
737 efx->type->txd_ring_mask);
738
739 efx_tsoh_free(tx_queue, buffer);
740 EFX_BUG_ON_PARANOID(buffer->len);
741 EFX_BUG_ON_PARANOID(buffer->unmap_len);
742 EFX_BUG_ON_PARANOID(buffer->skb);
743 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
744 EFX_BUG_ON_PARANOID(buffer->tsoh);
745
746 buffer->dma_addr = dma_addr;
747
748 /* Ensure we do not cross a boundary unsupported by H/W */
749 dma_len = (~dma_addr & efx->type->tx_dma_mask) + 1;
750
751 misalign = (unsigned)dma_addr & efx->type->bug5391_mask;
752 if (misalign && dma_len + misalign > 512)
753 dma_len = 512 - misalign;
754
755 /* If there is enough space to send then do so */
756 if (dma_len >= len)
757 break;
758
759 buffer->len = dma_len; /* Don't set the other members */
760 dma_addr += dma_len;
761 len -= dma_len;
762 }
763
764 EFX_BUG_ON_PARANOID(!len);
765 buffer->len = len;
766 buffer->skb = skb;
767 buffer->continuation = !end_of_packet;
768 buffer->unmap_addr = unmap_addr;
769 buffer->unmap_len = unmap_len;
770 return 0;
771}
772
773
774/*
775 * Put a TSO header into the TX queue.
776 *
777 * This is special-cased because we know that it is small enough to fit in
778 * a single fragment, and we know it doesn't cross a page boundary. It
779 * also allows us to not worry about end-of-packet etc.
780 */
781static inline void efx_tso_put_header(struct efx_tx_queue *tx_queue,
782 struct efx_tso_header *tsoh, unsigned len)
783{
784 struct efx_tx_buffer *buffer;
785
786 buffer = &tx_queue->buffer[tx_queue->insert_count &
787 tx_queue->efx->type->txd_ring_mask];
788 efx_tsoh_free(tx_queue, buffer);
789 EFX_BUG_ON_PARANOID(buffer->len);
790 EFX_BUG_ON_PARANOID(buffer->unmap_len);
791 EFX_BUG_ON_PARANOID(buffer->skb);
792 EFX_BUG_ON_PARANOID(buffer->continuation != 1);
793 EFX_BUG_ON_PARANOID(buffer->tsoh);
794 buffer->len = len;
795 buffer->dma_addr = tsoh->dma_addr;
796 buffer->tsoh = tsoh;
797
798 ++tx_queue->insert_count;
799}
800
801
802/* Remove descriptors put into a tx_queue. */
803static void efx_enqueue_unwind(struct efx_tx_queue *tx_queue)
804{
805 struct efx_tx_buffer *buffer;
806
807 /* Work backwards until we hit the original insert pointer value */
808 while (tx_queue->insert_count != tx_queue->write_count) {
809 --tx_queue->insert_count;
810 buffer = &tx_queue->buffer[tx_queue->insert_count &
811 tx_queue->efx->type->txd_ring_mask];
812 efx_tsoh_free(tx_queue, buffer);
813 EFX_BUG_ON_PARANOID(buffer->skb);
814 buffer->len = 0;
815 buffer->continuation = 1;
816 if (buffer->unmap_len) {
817 pci_unmap_page(tx_queue->efx->pci_dev,
818 buffer->unmap_addr,
819 buffer->unmap_len, PCI_DMA_TODEVICE);
820 buffer->unmap_len = 0;
821 }
822 }
823}
824
825
826/* Parse the SKB header and initialise state. */
827static inline void tso_start(struct tso_state *st, const struct sk_buff *skb)
828{
829 /* All ethernet/IP/TCP headers combined size is TCP header size
830 * plus offset of TCP header relative to start of packet.
831 */
832 st->p.header_length = ((tcp_hdr(skb)->doff << 2u)
833 + PTR_DIFF(tcp_hdr(skb), skb->data));
834 st->p.full_packet_size = (st->p.header_length
835 + skb_shinfo(skb)->gso_size);
836
837 st->p.ipv4_id = ntohs(ip_hdr(skb)->id);
838 st->seqnum = ntohl(tcp_hdr(skb)->seq);
839
840 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->urg);
841 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->syn);
842 EFX_BUG_ON_PARANOID(tcp_hdr(skb)->rst);
843
844 st->packet_space = st->p.full_packet_size;
845 st->remaining_len = skb->len - st->p.header_length;
846}
847
848
849/**
850 * tso_get_fragment - record fragment details and map for DMA
851 * @st: TSO state
852 * @efx: Efx NIC
853 * @data: Pointer to fragment data
854 * @len: Length of fragment
855 *
856 * Record fragment details and map for DMA. Return 0 on success, or
857 * -%ENOMEM if DMA mapping fails.
858 */
859static inline int tso_get_fragment(struct tso_state *st, struct efx_nic *efx,
860 int len, struct page *page, int page_off)
861{
862
863 st->ifc.unmap_addr = pci_map_page(efx->pci_dev, page, page_off,
864 len, PCI_DMA_TODEVICE);
865 if (likely(!pci_dma_mapping_error(st->ifc.unmap_addr))) {
866 st->ifc.unmap_len = len;
867 st->ifc.len = len;
868 st->ifc.dma_addr = st->ifc.unmap_addr;
869 st->ifc.page = page;
870 st->ifc.page_off = page_off;
871 return 0;
872 }
873 return -ENOMEM;
874}
875
876
877/**
878 * tso_fill_packet_with_fragment - form descriptors for the current fragment
879 * @tx_queue: Efx TX queue
880 * @skb: Socket buffer
881 * @st: TSO state
882 *
883 * Form descriptors for the current fragment, until we reach the end
884 * of fragment or end-of-packet. Return 0 on success, 1 if not enough
885 * space in @tx_queue.
886 */
887static inline int tso_fill_packet_with_fragment(struct efx_tx_queue *tx_queue,
888 const struct sk_buff *skb,
889 struct tso_state *st)
890{
891
892 int n, end_of_packet, rc;
893
894 if (st->ifc.len == 0)
895 return 0;
896 if (st->packet_space == 0)
897 return 0;
898
899 EFX_BUG_ON_PARANOID(st->ifc.len <= 0);
900 EFX_BUG_ON_PARANOID(st->packet_space <= 0);
901
902 n = min(st->ifc.len, st->packet_space);
903
904 st->packet_space -= n;
905 st->remaining_len -= n;
906 st->ifc.len -= n;
907 st->ifc.page_off += n;
908 end_of_packet = st->remaining_len == 0 || st->packet_space == 0;
909
910 rc = efx_tx_queue_insert(tx_queue, st->ifc.dma_addr, n,
911 st->remaining_len ? NULL : skb,
912 end_of_packet, st->ifc.unmap_addr,
913 st->ifc.len ? 0 : st->ifc.unmap_len);
914
915 st->ifc.dma_addr += n;
916
917 return rc;
918}
919
920
921/**
922 * tso_start_new_packet - generate a new header and prepare for the new packet
923 * @tx_queue: Efx TX queue
924 * @skb: Socket buffer
925 * @st: TSO state
926 *
927 * Generate a new header and prepare for the new packet. Return 0 on
928 * success, or -1 if failed to alloc header.
929 */
930static inline int tso_start_new_packet(struct efx_tx_queue *tx_queue,
931 const struct sk_buff *skb,
932 struct tso_state *st)
933{
934 struct efx_tso_header *tsoh;
935 struct iphdr *tsoh_iph;
936 struct tcphdr *tsoh_th;
937 unsigned ip_length;
938 u8 *header;
939
940 /* Allocate a DMA-mapped header buffer. */
941 if (likely(TSOH_SIZE(st->p.header_length) <= TSOH_STD_SIZE)) {
942 if (tx_queue->tso_headers_free == NULL)
943 if (efx_tsoh_block_alloc(tx_queue))
944 return -1;
945 EFX_BUG_ON_PARANOID(!tx_queue->tso_headers_free);
946 tsoh = tx_queue->tso_headers_free;
947 tx_queue->tso_headers_free = tsoh->next;
948 tsoh->unmap_len = 0;
949 } else {
950 tx_queue->tso_long_headers++;
951 tsoh = efx_tsoh_heap_alloc(tx_queue, st->p.header_length);
952 if (unlikely(!tsoh))
953 return -1;
954 }
955
956 header = TSOH_BUFFER(tsoh);
957 tsoh_th = (struct tcphdr *)(header + SKB_TCP_OFF(skb));
958 tsoh_iph = (struct iphdr *)(header + SKB_IPV4_OFF(skb));
959
960 /* Copy and update the headers. */
961 memcpy(header, skb->data, st->p.header_length);
962
963 tsoh_th->seq = htonl(st->seqnum);
964 st->seqnum += skb_shinfo(skb)->gso_size;
965 if (st->remaining_len > skb_shinfo(skb)->gso_size) {
966 /* This packet will not finish the TSO burst. */
967 ip_length = st->p.full_packet_size - ETH_HDR_LEN(skb);
968 tsoh_th->fin = 0;
969 tsoh_th->psh = 0;
970 } else {
971 /* This packet will be the last in the TSO burst. */
972 ip_length = (st->p.header_length - ETH_HDR_LEN(skb)
973 + st->remaining_len);
974 tsoh_th->fin = tcp_hdr(skb)->fin;
975 tsoh_th->psh = tcp_hdr(skb)->psh;
976 }
977 tsoh_iph->tot_len = htons(ip_length);
978
979 /* Linux leaves suitable gaps in the IP ID space for us to fill. */
980 tsoh_iph->id = htons(st->p.ipv4_id);
981 st->p.ipv4_id++;
982
983 st->packet_space = skb_shinfo(skb)->gso_size;
984 ++tx_queue->tso_packets;
985
986 /* Form a descriptor for this header. */
987 efx_tso_put_header(tx_queue, tsoh, st->p.header_length);
988
989 return 0;
990}
991
992
993/**
994 * efx_enqueue_skb_tso - segment and transmit a TSO socket buffer
995 * @tx_queue: Efx TX queue
996 * @skb: Socket buffer
997 *
998 * Context: You must hold netif_tx_lock() to call this function.
999 *
1000 * Add socket buffer @skb to @tx_queue, doing TSO or return != 0 if
1001 * @skb was not enqueued. In all cases @skb is consumed. Return
1002 * %NETDEV_TX_OK or %NETDEV_TX_BUSY.
1003 */
1004static int efx_enqueue_skb_tso(struct efx_tx_queue *tx_queue,
1005 const struct sk_buff *skb)
1006{
1007 int frag_i, rc, rc2 = NETDEV_TX_OK;
1008 struct tso_state state;
1009 skb_frag_t *f;
1010
1011 /* Verify TSO is safe - these checks should never fail. */
1012 efx_tso_check_safe(skb);
1013
1014 EFX_BUG_ON_PARANOID(tx_queue->write_count != tx_queue->insert_count);
1015
1016 tso_start(&state, skb);
1017
1018 /* Assume that skb header area contains exactly the headers, and
1019 * all payload is in the frag list.
1020 */
1021 if (skb_headlen(skb) == state.p.header_length) {
1022 /* Grab the first payload fragment. */
1023 EFX_BUG_ON_PARANOID(skb_shinfo(skb)->nr_frags < 1);
1024 frag_i = 0;
1025 f = &skb_shinfo(skb)->frags[frag_i];
1026 rc = tso_get_fragment(&state, tx_queue->efx,
1027 f->size, f->page, f->page_offset);
1028 if (rc)
1029 goto mem_err;
1030 } else {
1031 /* It may look like this code fragment assumes that the
1032 * skb->data portion does not cross a page boundary, but
1033 * that is not the case. It is guaranteed to be direct
1034 * mapped memory, and therefore is physically contiguous,
1035 * and so DMA will work fine. kmap_atomic() on this region
1036 * will just return the direct mapping, so that will work
1037 * too.
1038 */
1039 int page_off = (unsigned long)skb->data & (PAGE_SIZE - 1);
1040 int hl = state.p.header_length;
1041 rc = tso_get_fragment(&state, tx_queue->efx,
1042 skb_headlen(skb) - hl,
1043 virt_to_page(skb->data), page_off + hl);
1044 if (rc)
1045 goto mem_err;
1046 frag_i = -1;
1047 }
1048
1049 if (tso_start_new_packet(tx_queue, skb, &state) < 0)
1050 goto mem_err;
1051
1052 while (1) {
1053 rc = tso_fill_packet_with_fragment(tx_queue, skb, &state);
1054 if (unlikely(rc))
1055 goto stop;
1056
1057 /* Move onto the next fragment? */
1058 if (state.ifc.len == 0) {
1059 if (++frag_i >= skb_shinfo(skb)->nr_frags)
1060 /* End of payload reached. */
1061 break;
1062 f = &skb_shinfo(skb)->frags[frag_i];
1063 rc = tso_get_fragment(&state, tx_queue->efx,
1064 f->size, f->page, f->page_offset);
1065 if (rc)
1066 goto mem_err;
1067 }
1068
1069 /* Start at new packet? */
1070 if (state.packet_space == 0 &&
1071 tso_start_new_packet(tx_queue, skb, &state) < 0)
1072 goto mem_err;
1073 }
1074
1075 /* Pass off to hardware */
1076 falcon_push_buffers(tx_queue);
1077
1078 tx_queue->tso_bursts++;
1079 return NETDEV_TX_OK;
1080
1081 mem_err:
1082 EFX_ERR(tx_queue->efx, "Out of memory for TSO headers, or PCI mapping"
1083 " error\n");
1084 dev_kfree_skb_any((struct sk_buff *)skb);
1085 goto unwind;
1086
1087 stop:
1088 rc2 = NETDEV_TX_BUSY;
1089
1090 /* Stop the queue if it wasn't stopped before. */
1091 if (tx_queue->stopped == 1)
1092 efx_stop_queue(tx_queue->efx);
1093
1094 unwind:
1095 efx_enqueue_unwind(tx_queue);
1096 return rc2;
1097}
1098
1099
1100/*
1101 * Free up all TSO datastructures associated with tx_queue. This
1102 * routine should be called only once the tx_queue is both empty and
1103 * will no longer be used.
1104 */
1105static void efx_fini_tso(struct efx_tx_queue *tx_queue)
1106{
1107 unsigned i;
1108
1109 if (tx_queue->buffer)
1110 for (i = 0; i <= tx_queue->efx->type->txd_ring_mask; ++i)
1111 efx_tsoh_free(tx_queue, &tx_queue->buffer[i]);
1112
1113 while (tx_queue->tso_headers_free != NULL)
1114 efx_tsoh_block_free(tx_queue, tx_queue->tso_headers_free,
1115 tx_queue->efx->pci_dev);
1116}
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
index 66dd5bf1eaa9..3b9f9ddbc372 100644
--- a/drivers/net/sfc/xfp_phy.c
+++ b/drivers/net/sfc/xfp_phy.c
@@ -24,6 +24,10 @@
24 MDIO_MMDREG_DEVS0_PMAPMD | \ 24 MDIO_MMDREG_DEVS0_PMAPMD | \
25 MDIO_MMDREG_DEVS0_PHYXS) 25 MDIO_MMDREG_DEVS0_PHYXS)
26 26
27#define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \
28 (1 << LOOPBACK_PMAPMD) | \
29 (1 << LOOPBACK_NETWORK))
30
27/****************************************************************************/ 31/****************************************************************************/
28/* Quake-specific MDIO registers */ 32/* Quake-specific MDIO registers */
29#define MDIO_QUAKE_LED0_REG (0xD006) 33#define MDIO_QUAKE_LED0_REG (0xD006)
@@ -35,6 +39,10 @@ void xfp_set_led(struct efx_nic *p, int led, int mode)
35 mode); 39 mode);
36} 40}
37 41
42struct xfp_phy_data {
43 int tx_disabled;
44};
45
38#define XFP_MAX_RESET_TIME 500 46#define XFP_MAX_RESET_TIME 500
39#define XFP_RESET_WAIT 10 47#define XFP_RESET_WAIT 10
40 48
@@ -72,18 +80,31 @@ static int xfp_reset_phy(struct efx_nic *efx)
72 80
73static int xfp_phy_init(struct efx_nic *efx) 81static int xfp_phy_init(struct efx_nic *efx)
74{ 82{
83 struct xfp_phy_data *phy_data;
75 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS); 84 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS);
76 int rc; 85 int rc;
77 86
87 phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL);
88 efx->phy_data = (void *) phy_data;
89
78 EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision" 90 EFX_INFO(efx, "XFP: PHY ID reg %x (OUI %x model %x revision"
79 " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid), 91 " %x)\n", devid, MDIO_ID_OUI(devid), MDIO_ID_MODEL(devid),
80 MDIO_ID_REV(devid)); 92 MDIO_ID_REV(devid));
81 93
94 phy_data->tx_disabled = efx->tx_disabled;
95
82 rc = xfp_reset_phy(efx); 96 rc = xfp_reset_phy(efx);
83 97
84 EFX_INFO(efx, "XFP: PHY init %s.\n", 98 EFX_INFO(efx, "XFP: PHY init %s.\n",
85 rc ? "failed" : "successful"); 99 rc ? "failed" : "successful");
100 if (rc < 0)
101 goto fail;
86 102
103 return 0;
104
105 fail:
106 kfree(efx->phy_data);
107 efx->phy_data = NULL;
87 return rc; 108 return rc;
88} 109}
89 110
@@ -110,6 +131,16 @@ static int xfp_phy_check_hw(struct efx_nic *efx)
110 131
111static void xfp_phy_reconfigure(struct efx_nic *efx) 132static void xfp_phy_reconfigure(struct efx_nic *efx)
112{ 133{
134 struct xfp_phy_data *phy_data = efx->phy_data;
135
136 /* Reset the PHY when moving from tx off to tx on */
137 if (phy_data->tx_disabled && !efx->tx_disabled)
138 xfp_reset_phy(efx);
139
140 mdio_clause45_transmit_disable(efx);
141 mdio_clause45_phy_reconfigure(efx);
142
143 phy_data->tx_disabled = efx->tx_disabled;
113 efx->link_up = xfp_link_ok(efx); 144 efx->link_up = xfp_link_ok(efx);
114 efx->link_options = GM_LPA_10000FULL; 145 efx->link_options = GM_LPA_10000FULL;
115} 146}
@@ -119,6 +150,10 @@ static void xfp_phy_fini(struct efx_nic *efx)
119{ 150{
120 /* Clobber the LED if it was blinking */ 151 /* Clobber the LED if it was blinking */
121 efx->board_info.blink(efx, 0); 152 efx->board_info.blink(efx, 0);
153
154 /* Free the context block */
155 kfree(efx->phy_data);
156 efx->phy_data = NULL;
122} 157}
123 158
124struct efx_phy_operations falcon_xfp_phy_ops = { 159struct efx_phy_operations falcon_xfp_phy_ops = {
@@ -129,4 +164,5 @@ struct efx_phy_operations falcon_xfp_phy_ops = {
129 .clear_interrupt = xfp_phy_clear_interrupt, 164 .clear_interrupt = xfp_phy_clear_interrupt,
130 .reset_xaui = efx_port_dummy_op_void, 165 .reset_xaui = efx_port_dummy_op_void,
131 .mmds = XFP_REQUIRED_DEVS, 166 .mmds = XFP_REQUIRED_DEVS,
167 .loopbacks = XFP_LOOPBACKS,
132}; 168};
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 7bb3ba9bcbd8..c0a5eea20007 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1966,13 +1966,13 @@ struct sky2_status_le {
1966struct tx_ring_info { 1966struct tx_ring_info {
1967 struct sk_buff *skb; 1967 struct sk_buff *skb;
1968 DECLARE_PCI_UNMAP_ADDR(mapaddr); 1968 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1969 DECLARE_PCI_UNMAP_ADDR(maplen); 1969 DECLARE_PCI_UNMAP_LEN(maplen);
1970}; 1970};
1971 1971
1972struct rx_ring_info { 1972struct rx_ring_info {
1973 struct sk_buff *skb; 1973 struct sk_buff *skb;
1974 dma_addr_t data_addr; 1974 dma_addr_t data_addr;
1975 DECLARE_PCI_UNMAP_ADDR(data_size); 1975 DECLARE_PCI_UNMAP_LEN(data_size);
1976 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT]; 1976 dma_addr_t frag_addr[ETH_JUMBO_MTU >> PAGE_SHIFT];
1977}; 1977};
1978 1978
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index a59c1f224aa8..2511ca7a12aa 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -434,10 +434,6 @@ static int uli526x_open(struct net_device *dev)
434 434
435 ULI526X_DBUG(0, "uli526x_open", 0); 435 ULI526X_DBUG(0, "uli526x_open", 0);
436 436
437 ret = request_irq(dev->irq, &uli526x_interrupt, IRQF_SHARED, dev->name, dev);
438 if (ret)
439 return ret;
440
441 /* system variable init */ 437 /* system variable init */
442 db->cr6_data = CR6_DEFAULT | uli526x_cr6_user_set; 438 db->cr6_data = CR6_DEFAULT | uli526x_cr6_user_set;
443 db->tx_packet_cnt = 0; 439 db->tx_packet_cnt = 0;
@@ -456,6 +452,10 @@ static int uli526x_open(struct net_device *dev)
456 /* Initialize ULI526X board */ 452 /* Initialize ULI526X board */
457 uli526x_init(dev); 453 uli526x_init(dev);
458 454
455 ret = request_irq(dev->irq, &uli526x_interrupt, IRQF_SHARED, dev->name, dev);
456 if (ret)
457 return ret;
458
459 /* Active System Interface */ 459 /* Active System Interface */
460 netif_wake_queue(dev); 460 netif_wake_queue(dev);
461 461
@@ -1368,6 +1368,12 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
1368 * This setup frame initialize ULI526X address filter mode 1368 * This setup frame initialize ULI526X address filter mode
1369 */ 1369 */
1370 1370
1371#ifdef __BIG_ENDIAN
1372#define FLT_SHIFT 16
1373#else
1374#define FLT_SHIFT 0
1375#endif
1376
1371static void send_filter_frame(struct net_device *dev, int mc_cnt) 1377static void send_filter_frame(struct net_device *dev, int mc_cnt)
1372{ 1378{
1373 struct uli526x_board_info *db = netdev_priv(dev); 1379 struct uli526x_board_info *db = netdev_priv(dev);
@@ -1384,27 +1390,27 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt)
1384 1390
1385 /* Node address */ 1391 /* Node address */
1386 addrptr = (u16 *) dev->dev_addr; 1392 addrptr = (u16 *) dev->dev_addr;
1387 *suptr++ = addrptr[0]; 1393 *suptr++ = addrptr[0] << FLT_SHIFT;
1388 *suptr++ = addrptr[1]; 1394 *suptr++ = addrptr[1] << FLT_SHIFT;
1389 *suptr++ = addrptr[2]; 1395 *suptr++ = addrptr[2] << FLT_SHIFT;
1390 1396
1391 /* broadcast address */ 1397 /* broadcast address */
1392 *suptr++ = 0xffff; 1398 *suptr++ = 0xffff << FLT_SHIFT;
1393 *suptr++ = 0xffff; 1399 *suptr++ = 0xffff << FLT_SHIFT;
1394 *suptr++ = 0xffff; 1400 *suptr++ = 0xffff << FLT_SHIFT;
1395 1401
1396 /* fit the multicast address */ 1402 /* fit the multicast address */
1397 for (mcptr = dev->mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1403 for (mcptr = dev->mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
1398 addrptr = (u16 *) mcptr->dmi_addr; 1404 addrptr = (u16 *) mcptr->dmi_addr;
1399 *suptr++ = addrptr[0]; 1405 *suptr++ = addrptr[0] << FLT_SHIFT;
1400 *suptr++ = addrptr[1]; 1406 *suptr++ = addrptr[1] << FLT_SHIFT;
1401 *suptr++ = addrptr[2]; 1407 *suptr++ = addrptr[2] << FLT_SHIFT;
1402 } 1408 }
1403 1409
1404 for (; i<14; i++) { 1410 for (; i<14; i++) {
1405 *suptr++ = 0xffff; 1411 *suptr++ = 0xffff << FLT_SHIFT;
1406 *suptr++ = 0xffff; 1412 *suptr++ = 0xffff << FLT_SHIFT;
1407 *suptr++ = 0xffff; 1413 *suptr++ = 0xffff << FLT_SHIFT;
1408 } 1414 }
1409 1415
1410 /* prepare the setup frame */ 1416 /* prepare the setup frame */
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 281ce3d39532..ca0bdac07a78 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -62,7 +62,6 @@
62#endif /* UGETH_VERBOSE_DEBUG */ 62#endif /* UGETH_VERBOSE_DEBUG */
63#define UGETH_MSG_DEFAULT (NETIF_MSG_IFUP << 1 ) - 1 63#define UGETH_MSG_DEFAULT (NETIF_MSG_IFUP << 1 ) - 1
64 64
65void uec_set_ethtool_ops(struct net_device *netdev);
66 65
67static DEFINE_SPINLOCK(ugeth_lock); 66static DEFINE_SPINLOCK(ugeth_lock);
68 67
@@ -216,7 +215,8 @@ static struct list_head *dequeue(struct list_head *lh)
216 } 215 }
217} 216}
218 217
219static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, u8 *bd) 218static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth,
219 u8 __iomem *bd)
220{ 220{
221 struct sk_buff *skb = NULL; 221 struct sk_buff *skb = NULL;
222 222
@@ -236,21 +236,22 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, u8 *bd)
236 236
237 skb->dev = ugeth->dev; 237 skb->dev = ugeth->dev;
238 238
239 out_be32(&((struct qe_bd *)bd)->buf, 239 out_be32(&((struct qe_bd __iomem *)bd)->buf,
240 dma_map_single(NULL, 240 dma_map_single(NULL,
241 skb->data, 241 skb->data,
242 ugeth->ug_info->uf_info.max_rx_buf_length + 242 ugeth->ug_info->uf_info.max_rx_buf_length +
243 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 243 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
244 DMA_FROM_DEVICE)); 244 DMA_FROM_DEVICE));
245 245
246 out_be32((u32 *)bd, (R_E | R_I | (in_be32((u32 *)bd) & R_W))); 246 out_be32((u32 __iomem *)bd,
247 (R_E | R_I | (in_be32((u32 __iomem*)bd) & R_W)));
247 248
248 return skb; 249 return skb;
249} 250}
250 251
251static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ) 252static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
252{ 253{
253 u8 *bd; 254 u8 __iomem *bd;
254 u32 bd_status; 255 u32 bd_status;
255 struct sk_buff *skb; 256 struct sk_buff *skb;
256 int i; 257 int i;
@@ -259,7 +260,7 @@ static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
259 i = 0; 260 i = 0;
260 261
261 do { 262 do {
262 bd_status = in_be32((u32*)bd); 263 bd_status = in_be32((u32 __iomem *)bd);
263 skb = get_new_skb(ugeth, bd); 264 skb = get_new_skb(ugeth, bd);
264 265
265 if (!skb) /* If can not allocate data buffer, 266 if (!skb) /* If can not allocate data buffer,
@@ -277,7 +278,7 @@ static int rx_bd_buffer_set(struct ucc_geth_private *ugeth, u8 rxQ)
277} 278}
278 279
279static int fill_init_enet_entries(struct ucc_geth_private *ugeth, 280static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
280 volatile u32 *p_start, 281 u32 *p_start,
281 u8 num_entries, 282 u8 num_entries,
282 u32 thread_size, 283 u32 thread_size,
283 u32 thread_alignment, 284 u32 thread_alignment,
@@ -316,7 +317,7 @@ static int fill_init_enet_entries(struct ucc_geth_private *ugeth,
316} 317}
317 318
318static int return_init_enet_entries(struct ucc_geth_private *ugeth, 319static int return_init_enet_entries(struct ucc_geth_private *ugeth,
319 volatile u32 *p_start, 320 u32 *p_start,
320 u8 num_entries, 321 u8 num_entries,
321 enum qe_risc_allocation risc, 322 enum qe_risc_allocation risc,
322 int skip_page_for_first_entry) 323 int skip_page_for_first_entry)
@@ -326,21 +327,22 @@ static int return_init_enet_entries(struct ucc_geth_private *ugeth,
326 int snum; 327 int snum;
327 328
328 for (i = 0; i < num_entries; i++) { 329 for (i = 0; i < num_entries; i++) {
330 u32 val = *p_start;
331
329 /* Check that this entry was actually valid -- 332 /* Check that this entry was actually valid --
330 needed in case failed in allocations */ 333 needed in case failed in allocations */
331 if ((*p_start & ENET_INIT_PARAM_RISC_MASK) == risc) { 334 if ((val & ENET_INIT_PARAM_RISC_MASK) == risc) {
332 snum = 335 snum =
333 (u32) (*p_start & ENET_INIT_PARAM_SNUM_MASK) >> 336 (u32) (val & ENET_INIT_PARAM_SNUM_MASK) >>
334 ENET_INIT_PARAM_SNUM_SHIFT; 337 ENET_INIT_PARAM_SNUM_SHIFT;
335 qe_put_snum((u8) snum); 338 qe_put_snum((u8) snum);
336 if (!((i == 0) && skip_page_for_first_entry)) { 339 if (!((i == 0) && skip_page_for_first_entry)) {
337 /* First entry of Rx does not have page */ 340 /* First entry of Rx does not have page */
338 init_enet_offset = 341 init_enet_offset =
339 (in_be32(p_start) & 342 (val & ENET_INIT_PARAM_PTR_MASK);
340 ENET_INIT_PARAM_PTR_MASK);
341 qe_muram_free(init_enet_offset); 343 qe_muram_free(init_enet_offset);
342 } 344 }
343 *(p_start++) = 0; /* Just for cosmetics */ 345 *p_start++ = 0;
344 } 346 }
345 } 347 }
346 348
@@ -349,7 +351,7 @@ static int return_init_enet_entries(struct ucc_geth_private *ugeth,
349 351
350#ifdef DEBUG 352#ifdef DEBUG
351static int dump_init_enet_entries(struct ucc_geth_private *ugeth, 353static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
352 volatile u32 *p_start, 354 u32 __iomem *p_start,
353 u8 num_entries, 355 u8 num_entries,
354 u32 thread_size, 356 u32 thread_size,
355 enum qe_risc_allocation risc, 357 enum qe_risc_allocation risc,
@@ -360,11 +362,13 @@ static int dump_init_enet_entries(struct ucc_geth_private *ugeth,
360 int snum; 362 int snum;
361 363
362 for (i = 0; i < num_entries; i++) { 364 for (i = 0; i < num_entries; i++) {
365 u32 val = in_be32(p_start);
366
363 /* Check that this entry was actually valid -- 367 /* Check that this entry was actually valid --
364 needed in case failed in allocations */ 368 needed in case failed in allocations */
365 if ((*p_start & ENET_INIT_PARAM_RISC_MASK) == risc) { 369 if ((val & ENET_INIT_PARAM_RISC_MASK) == risc) {
366 snum = 370 snum =
367 (u32) (*p_start & ENET_INIT_PARAM_SNUM_MASK) >> 371 (u32) (val & ENET_INIT_PARAM_SNUM_MASK) >>
368 ENET_INIT_PARAM_SNUM_SHIFT; 372 ENET_INIT_PARAM_SNUM_SHIFT;
369 qe_put_snum((u8) snum); 373 qe_put_snum((u8) snum);
370 if (!((i == 0) && skip_page_for_first_entry)) { 374 if (!((i == 0) && skip_page_for_first_entry)) {
@@ -440,7 +444,7 @@ static int hw_add_addr_in_paddr(struct ucc_geth_private *ugeth,
440 444
441static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num) 445static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
442{ 446{
443 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; 447 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
444 448
445 if (!(paddr_num < NUM_OF_PADDRS)) { 449 if (!(paddr_num < NUM_OF_PADDRS)) {
446 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__); 450 ugeth_warn("%s: Illagel paddr_num.", __FUNCTION__);
@@ -448,7 +452,7 @@ static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
448 } 452 }
449 453
450 p_82xx_addr_filt = 454 p_82xx_addr_filt =
451 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram-> 455 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->p_rx_glbl_pram->
452 addressfiltering; 456 addressfiltering;
453 457
454 /* Writing address ff.ff.ff.ff.ff.ff disables address 458 /* Writing address ff.ff.ff.ff.ff.ff disables address
@@ -463,11 +467,11 @@ static int hw_clear_addr_in_paddr(struct ucc_geth_private *ugeth, u8 paddr_num)
463static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth, 467static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth,
464 u8 *p_enet_addr) 468 u8 *p_enet_addr)
465{ 469{
466 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; 470 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
467 u32 cecr_subblock; 471 u32 cecr_subblock;
468 472
469 p_82xx_addr_filt = 473 p_82xx_addr_filt =
470 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram-> 474 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->p_rx_glbl_pram->
471 addressfiltering; 475 addressfiltering;
472 476
473 cecr_subblock = 477 cecr_subblock =
@@ -487,7 +491,7 @@ static void hw_add_addr_in_hash(struct ucc_geth_private *ugeth,
487static void magic_packet_detection_enable(struct ucc_geth_private *ugeth) 491static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
488{ 492{
489 struct ucc_fast_private *uccf; 493 struct ucc_fast_private *uccf;
490 struct ucc_geth *ug_regs; 494 struct ucc_geth __iomem *ug_regs;
491 u32 maccfg2, uccm; 495 u32 maccfg2, uccm;
492 496
493 uccf = ugeth->uccf; 497 uccf = ugeth->uccf;
@@ -507,7 +511,7 @@ static void magic_packet_detection_enable(struct ucc_geth_private *ugeth)
507static void magic_packet_detection_disable(struct ucc_geth_private *ugeth) 511static void magic_packet_detection_disable(struct ucc_geth_private *ugeth)
508{ 512{
509 struct ucc_fast_private *uccf; 513 struct ucc_fast_private *uccf;
510 struct ucc_geth *ug_regs; 514 struct ucc_geth __iomem *ug_regs;
511 u32 maccfg2, uccm; 515 u32 maccfg2, uccm;
512 516
513 uccf = ugeth->uccf; 517 uccf = ugeth->uccf;
@@ -538,13 +542,13 @@ static void get_statistics(struct ucc_geth_private *ugeth,
538 rx_firmware_statistics, 542 rx_firmware_statistics,
539 struct ucc_geth_hardware_statistics *hardware_statistics) 543 struct ucc_geth_hardware_statistics *hardware_statistics)
540{ 544{
541 struct ucc_fast *uf_regs; 545 struct ucc_fast __iomem *uf_regs;
542 struct ucc_geth *ug_regs; 546 struct ucc_geth __iomem *ug_regs;
543 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram; 547 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram;
544 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram; 548 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram;
545 549
546 ug_regs = ugeth->ug_regs; 550 ug_regs = ugeth->ug_regs;
547 uf_regs = (struct ucc_fast *) ug_regs; 551 uf_regs = (struct ucc_fast __iomem *) ug_regs;
548 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram; 552 p_tx_fw_statistics_pram = ugeth->p_tx_fw_statistics_pram;
549 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram; 553 p_rx_fw_statistics_pram = ugeth->p_rx_fw_statistics_pram;
550 554
@@ -1132,9 +1136,9 @@ static void dump_regs(struct ucc_geth_private *ugeth)
1132} 1136}
1133#endif /* DEBUG */ 1137#endif /* DEBUG */
1134 1138
1135static void init_default_reg_vals(volatile u32 *upsmr_register, 1139static void init_default_reg_vals(u32 __iomem *upsmr_register,
1136 volatile u32 *maccfg1_register, 1140 u32 __iomem *maccfg1_register,
1137 volatile u32 *maccfg2_register) 1141 u32 __iomem *maccfg2_register)
1138{ 1142{
1139 out_be32(upsmr_register, UCC_GETH_UPSMR_INIT); 1143 out_be32(upsmr_register, UCC_GETH_UPSMR_INIT);
1140 out_be32(maccfg1_register, UCC_GETH_MACCFG1_INIT); 1144 out_be32(maccfg1_register, UCC_GETH_MACCFG1_INIT);
@@ -1148,7 +1152,7 @@ static int init_half_duplex_params(int alt_beb,
1148 u8 alt_beb_truncation, 1152 u8 alt_beb_truncation,
1149 u8 max_retransmissions, 1153 u8 max_retransmissions,
1150 u8 collision_window, 1154 u8 collision_window,
1151 volatile u32 *hafdup_register) 1155 u32 __iomem *hafdup_register)
1152{ 1156{
1153 u32 value = 0; 1157 u32 value = 0;
1154 1158
@@ -1180,7 +1184,7 @@ static int init_inter_frame_gap_params(u8 non_btb_cs_ipg,
1180 u8 non_btb_ipg, 1184 u8 non_btb_ipg,
1181 u8 min_ifg, 1185 u8 min_ifg,
1182 u8 btb_ipg, 1186 u8 btb_ipg,
1183 volatile u32 *ipgifg_register) 1187 u32 __iomem *ipgifg_register)
1184{ 1188{
1185 u32 value = 0; 1189 u32 value = 0;
1186 1190
@@ -1215,9 +1219,9 @@ int init_flow_control_params(u32 automatic_flow_control_mode,
1215 int tx_flow_control_enable, 1219 int tx_flow_control_enable,
1216 u16 pause_period, 1220 u16 pause_period,
1217 u16 extension_field, 1221 u16 extension_field,
1218 volatile u32 *upsmr_register, 1222 u32 __iomem *upsmr_register,
1219 volatile u32 *uempr_register, 1223 u32 __iomem *uempr_register,
1220 volatile u32 *maccfg1_register) 1224 u32 __iomem *maccfg1_register)
1221{ 1225{
1222 u32 value = 0; 1226 u32 value = 0;
1223 1227
@@ -1243,8 +1247,8 @@ int init_flow_control_params(u32 automatic_flow_control_mode,
1243 1247
1244static int init_hw_statistics_gathering_mode(int enable_hardware_statistics, 1248static int init_hw_statistics_gathering_mode(int enable_hardware_statistics,
1245 int auto_zero_hardware_statistics, 1249 int auto_zero_hardware_statistics,
1246 volatile u32 *upsmr_register, 1250 u32 __iomem *upsmr_register,
1247 volatile u16 *uescr_register) 1251 u16 __iomem *uescr_register)
1248{ 1252{
1249 u32 upsmr_value = 0; 1253 u32 upsmr_value = 0;
1250 u16 uescr_value = 0; 1254 u16 uescr_value = 0;
@@ -1270,12 +1274,12 @@ static int init_hw_statistics_gathering_mode(int enable_hardware_statistics,
1270static int init_firmware_statistics_gathering_mode(int 1274static int init_firmware_statistics_gathering_mode(int
1271 enable_tx_firmware_statistics, 1275 enable_tx_firmware_statistics,
1272 int enable_rx_firmware_statistics, 1276 int enable_rx_firmware_statistics,
1273 volatile u32 *tx_rmon_base_ptr, 1277 u32 __iomem *tx_rmon_base_ptr,
1274 u32 tx_firmware_statistics_structure_address, 1278 u32 tx_firmware_statistics_structure_address,
1275 volatile u32 *rx_rmon_base_ptr, 1279 u32 __iomem *rx_rmon_base_ptr,
1276 u32 rx_firmware_statistics_structure_address, 1280 u32 rx_firmware_statistics_structure_address,
1277 volatile u16 *temoder_register, 1281 u16 __iomem *temoder_register,
1278 volatile u32 *remoder_register) 1282 u32 __iomem *remoder_register)
1279{ 1283{
1280 /* Note: this function does not check if */ 1284 /* Note: this function does not check if */
1281 /* the parameters it receives are NULL */ 1285 /* the parameters it receives are NULL */
@@ -1307,8 +1311,8 @@ static int init_mac_station_addr_regs(u8 address_byte_0,
1307 u8 address_byte_3, 1311 u8 address_byte_3,
1308 u8 address_byte_4, 1312 u8 address_byte_4,
1309 u8 address_byte_5, 1313 u8 address_byte_5,
1310 volatile u32 *macstnaddr1_register, 1314 u32 __iomem *macstnaddr1_register,
1311 volatile u32 *macstnaddr2_register) 1315 u32 __iomem *macstnaddr2_register)
1312{ 1316{
1313 u32 value = 0; 1317 u32 value = 0;
1314 1318
@@ -1344,7 +1348,7 @@ static int init_mac_station_addr_regs(u8 address_byte_0,
1344} 1348}
1345 1349
1346static int init_check_frame_length_mode(int length_check, 1350static int init_check_frame_length_mode(int length_check,
1347 volatile u32 *maccfg2_register) 1351 u32 __iomem *maccfg2_register)
1348{ 1352{
1349 u32 value = 0; 1353 u32 value = 0;
1350 1354
@@ -1360,7 +1364,7 @@ static int init_check_frame_length_mode(int length_check,
1360} 1364}
1361 1365
1362static int init_preamble_length(u8 preamble_length, 1366static int init_preamble_length(u8 preamble_length,
1363 volatile u32 *maccfg2_register) 1367 u32 __iomem *maccfg2_register)
1364{ 1368{
1365 u32 value = 0; 1369 u32 value = 0;
1366 1370
@@ -1376,7 +1380,7 @@ static int init_preamble_length(u8 preamble_length,
1376 1380
1377static int init_rx_parameters(int reject_broadcast, 1381static int init_rx_parameters(int reject_broadcast,
1378 int receive_short_frames, 1382 int receive_short_frames,
1379 int promiscuous, volatile u32 *upsmr_register) 1383 int promiscuous, u32 __iomem *upsmr_register)
1380{ 1384{
1381 u32 value = 0; 1385 u32 value = 0;
1382 1386
@@ -1403,7 +1407,7 @@ static int init_rx_parameters(int reject_broadcast,
1403} 1407}
1404 1408
1405static int init_max_rx_buff_len(u16 max_rx_buf_len, 1409static int init_max_rx_buff_len(u16 max_rx_buf_len,
1406 volatile u16 *mrblr_register) 1410 u16 __iomem *mrblr_register)
1407{ 1411{
1408 /* max_rx_buf_len value must be a multiple of 128 */ 1412 /* max_rx_buf_len value must be a multiple of 128 */
1409 if ((max_rx_buf_len == 0) 1413 if ((max_rx_buf_len == 0)
@@ -1415,8 +1419,8 @@ static int init_max_rx_buff_len(u16 max_rx_buf_len,
1415} 1419}
1416 1420
1417static int init_min_frame_len(u16 min_frame_length, 1421static int init_min_frame_len(u16 min_frame_length,
1418 volatile u16 *minflr_register, 1422 u16 __iomem *minflr_register,
1419 volatile u16 *mrblr_register) 1423 u16 __iomem *mrblr_register)
1420{ 1424{
1421 u16 mrblr_value = 0; 1425 u16 mrblr_value = 0;
1422 1426
@@ -1431,8 +1435,8 @@ static int init_min_frame_len(u16 min_frame_length,
1431static int adjust_enet_interface(struct ucc_geth_private *ugeth) 1435static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1432{ 1436{
1433 struct ucc_geth_info *ug_info; 1437 struct ucc_geth_info *ug_info;
1434 struct ucc_geth *ug_regs; 1438 struct ucc_geth __iomem *ug_regs;
1435 struct ucc_fast *uf_regs; 1439 struct ucc_fast __iomem *uf_regs;
1436 int ret_val; 1440 int ret_val;
1437 u32 upsmr, maccfg2, tbiBaseAddress; 1441 u32 upsmr, maccfg2, tbiBaseAddress;
1438 u16 value; 1442 u16 value;
@@ -1517,8 +1521,8 @@ static int adjust_enet_interface(struct ucc_geth_private *ugeth)
1517static void adjust_link(struct net_device *dev) 1521static void adjust_link(struct net_device *dev)
1518{ 1522{
1519 struct ucc_geth_private *ugeth = netdev_priv(dev); 1523 struct ucc_geth_private *ugeth = netdev_priv(dev);
1520 struct ucc_geth *ug_regs; 1524 struct ucc_geth __iomem *ug_regs;
1521 struct ucc_fast *uf_regs; 1525 struct ucc_fast __iomem *uf_regs;
1522 struct phy_device *phydev = ugeth->phydev; 1526 struct phy_device *phydev = ugeth->phydev;
1523 unsigned long flags; 1527 unsigned long flags;
1524 int new_state = 0; 1528 int new_state = 0;
@@ -1678,9 +1682,9 @@ static int ugeth_graceful_stop_rx(struct ucc_geth_private * ugeth)
1678 uccf = ugeth->uccf; 1682 uccf = ugeth->uccf;
1679 1683
1680 /* Clear acknowledge bit */ 1684 /* Clear acknowledge bit */
1681 temp = ugeth->p_rx_glbl_pram->rxgstpack; 1685 temp = in_8(&ugeth->p_rx_glbl_pram->rxgstpack);
1682 temp &= ~GRACEFUL_STOP_ACKNOWLEDGE_RX; 1686 temp &= ~GRACEFUL_STOP_ACKNOWLEDGE_RX;
1683 ugeth->p_rx_glbl_pram->rxgstpack = temp; 1687 out_8(&ugeth->p_rx_glbl_pram->rxgstpack, temp);
1684 1688
1685 /* Keep issuing command and checking acknowledge bit until 1689 /* Keep issuing command and checking acknowledge bit until
1686 it is asserted, according to spec */ 1690 it is asserted, according to spec */
@@ -1692,7 +1696,7 @@ static int ugeth_graceful_stop_rx(struct ucc_geth_private * ugeth)
1692 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock, 1696 qe_issue_cmd(QE_GRACEFUL_STOP_RX, cecr_subblock,
1693 QE_CR_PROTOCOL_ETHERNET, 0); 1697 QE_CR_PROTOCOL_ETHERNET, 0);
1694 1698
1695 temp = ugeth->p_rx_glbl_pram->rxgstpack; 1699 temp = in_8(&ugeth->p_rx_glbl_pram->rxgstpack);
1696 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX)); 1700 } while (!(temp & GRACEFUL_STOP_ACKNOWLEDGE_RX));
1697 1701
1698 uccf->stopped_rx = 1; 1702 uccf->stopped_rx = 1;
@@ -1991,19 +1995,20 @@ static int ugeth_82xx_filtering_clear_all_addr_in_hash(struct ucc_geth_private *
1991 enum enet_addr_type 1995 enum enet_addr_type
1992 enet_addr_type) 1996 enet_addr_type)
1993{ 1997{
1994 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; 1998 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
1995 struct ucc_fast_private *uccf; 1999 struct ucc_fast_private *uccf;
1996 enum comm_dir comm_dir; 2000 enum comm_dir comm_dir;
1997 struct list_head *p_lh; 2001 struct list_head *p_lh;
1998 u16 i, num; 2002 u16 i, num;
1999 u32 *addr_h, *addr_l; 2003 u32 __iomem *addr_h;
2004 u32 __iomem *addr_l;
2000 u8 *p_counter; 2005 u8 *p_counter;
2001 2006
2002 uccf = ugeth->uccf; 2007 uccf = ugeth->uccf;
2003 2008
2004 p_82xx_addr_filt = 2009 p_82xx_addr_filt =
2005 (struct ucc_geth_82xx_address_filtering_pram *) ugeth->p_rx_glbl_pram-> 2010 (struct ucc_geth_82xx_address_filtering_pram __iomem *)
2006 addressfiltering; 2011 ugeth->p_rx_glbl_pram->addressfiltering;
2007 2012
2008 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) { 2013 if (enet_addr_type == ENET_ADDR_TYPE_GROUP) {
2009 addr_h = &(p_82xx_addr_filt->gaddr_h); 2014 addr_h = &(p_82xx_addr_filt->gaddr_h);
@@ -2079,7 +2084,7 @@ static int ugeth_82xx_filtering_clear_addr_in_paddr(struct ucc_geth_private *uge
2079static void ucc_geth_memclean(struct ucc_geth_private *ugeth) 2084static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2080{ 2085{
2081 u16 i, j; 2086 u16 i, j;
2082 u8 *bd; 2087 u8 __iomem *bd;
2083 2088
2084 if (!ugeth) 2089 if (!ugeth)
2085 return; 2090 return;
@@ -2154,8 +2159,8 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2154 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) { 2159 for (j = 0; j < ugeth->ug_info->bdRingLenTx[i]; j++) {
2155 if (ugeth->tx_skbuff[i][j]) { 2160 if (ugeth->tx_skbuff[i][j]) {
2156 dma_unmap_single(NULL, 2161 dma_unmap_single(NULL,
2157 ((struct qe_bd *)bd)->buf, 2162 in_be32(&((struct qe_bd __iomem *)bd)->buf),
2158 (in_be32((u32 *)bd) & 2163 (in_be32((u32 __iomem *)bd) &
2159 BD_LENGTH_MASK), 2164 BD_LENGTH_MASK),
2160 DMA_TO_DEVICE); 2165 DMA_TO_DEVICE);
2161 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]); 2166 dev_kfree_skb_any(ugeth->tx_skbuff[i][j]);
@@ -2182,7 +2187,7 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth)
2182 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) { 2187 for (j = 0; j < ugeth->ug_info->bdRingLenRx[i]; j++) {
2183 if (ugeth->rx_skbuff[i][j]) { 2188 if (ugeth->rx_skbuff[i][j]) {
2184 dma_unmap_single(NULL, 2189 dma_unmap_single(NULL,
2185 ((struct qe_bd *)bd)->buf, 2190 in_be32(&((struct qe_bd __iomem *)bd)->buf),
2186 ugeth->ug_info-> 2191 ugeth->ug_info->
2187 uf_info.max_rx_buf_length + 2192 uf_info.max_rx_buf_length +
2188 UCC_GETH_RX_DATA_BUF_ALIGNMENT, 2193 UCC_GETH_RX_DATA_BUF_ALIGNMENT,
@@ -2218,8 +2223,8 @@ static void ucc_geth_set_multi(struct net_device *dev)
2218{ 2223{
2219 struct ucc_geth_private *ugeth; 2224 struct ucc_geth_private *ugeth;
2220 struct dev_mc_list *dmi; 2225 struct dev_mc_list *dmi;
2221 struct ucc_fast *uf_regs; 2226 struct ucc_fast __iomem *uf_regs;
2222 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; 2227 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
2223 int i; 2228 int i;
2224 2229
2225 ugeth = netdev_priv(dev); 2230 ugeth = netdev_priv(dev);
@@ -2228,14 +2233,14 @@ static void ucc_geth_set_multi(struct net_device *dev)
2228 2233
2229 if (dev->flags & IFF_PROMISC) { 2234 if (dev->flags & IFF_PROMISC) {
2230 2235
2231 uf_regs->upsmr |= UPSMR_PRO; 2236 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr) | UPSMR_PRO);
2232 2237
2233 } else { 2238 } else {
2234 2239
2235 uf_regs->upsmr &= ~UPSMR_PRO; 2240 out_be32(&uf_regs->upsmr, in_be32(&uf_regs->upsmr)&~UPSMR_PRO);
2236 2241
2237 p_82xx_addr_filt = 2242 p_82xx_addr_filt =
2238 (struct ucc_geth_82xx_address_filtering_pram *) ugeth-> 2243 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->
2239 p_rx_glbl_pram->addressfiltering; 2244 p_rx_glbl_pram->addressfiltering;
2240 2245
2241 if (dev->flags & IFF_ALLMULTI) { 2246 if (dev->flags & IFF_ALLMULTI) {
@@ -2270,7 +2275,7 @@ static void ucc_geth_set_multi(struct net_device *dev)
2270 2275
2271static void ucc_geth_stop(struct ucc_geth_private *ugeth) 2276static void ucc_geth_stop(struct ucc_geth_private *ugeth)
2272{ 2277{
2273 struct ucc_geth *ug_regs = ugeth->ug_regs; 2278 struct ucc_geth __iomem *ug_regs = ugeth->ug_regs;
2274 struct phy_device *phydev = ugeth->phydev; 2279 struct phy_device *phydev = ugeth->phydev;
2275 u32 tempval; 2280 u32 tempval;
2276 2281
@@ -2419,20 +2424,20 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth)
2419 return -ENOMEM; 2424 return -ENOMEM;
2420 } 2425 }
2421 2426
2422 ugeth->ug_regs = (struct ucc_geth *) ioremap(uf_info->regs, sizeof(struct ucc_geth)); 2427 ugeth->ug_regs = (struct ucc_geth __iomem *) ioremap(uf_info->regs, sizeof(struct ucc_geth));
2423 2428
2424 return 0; 2429 return 0;
2425} 2430}
2426 2431
2427static int ucc_geth_startup(struct ucc_geth_private *ugeth) 2432static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2428{ 2433{
2429 struct ucc_geth_82xx_address_filtering_pram *p_82xx_addr_filt; 2434 struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
2430 struct ucc_geth_init_pram *p_init_enet_pram; 2435 struct ucc_geth_init_pram __iomem *p_init_enet_pram;
2431 struct ucc_fast_private *uccf; 2436 struct ucc_fast_private *uccf;
2432 struct ucc_geth_info *ug_info; 2437 struct ucc_geth_info *ug_info;
2433 struct ucc_fast_info *uf_info; 2438 struct ucc_fast_info *uf_info;
2434 struct ucc_fast *uf_regs; 2439 struct ucc_fast __iomem *uf_regs;
2435 struct ucc_geth *ug_regs; 2440 struct ucc_geth __iomem *ug_regs;
2436 int ret_val = -EINVAL; 2441 int ret_val = -EINVAL;
2437 u32 remoder = UCC_GETH_REMODER_INIT; 2442 u32 remoder = UCC_GETH_REMODER_INIT;
2438 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1; 2443 u32 init_enet_pram_offset, cecr_subblock, command, maccfg1;
@@ -2440,7 +2445,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2440 u16 temoder = UCC_GETH_TEMODER_INIT; 2445 u16 temoder = UCC_GETH_TEMODER_INIT;
2441 u16 test; 2446 u16 test;
2442 u8 function_code = 0; 2447 u8 function_code = 0;
2443 u8 *bd, *endOfRing; 2448 u8 __iomem *bd;
2449 u8 __iomem *endOfRing;
2444 u8 numThreadsRxNumerical, numThreadsTxNumerical; 2450 u8 numThreadsRxNumerical, numThreadsTxNumerical;
2445 2451
2446 ugeth_vdbg("%s: IN", __FUNCTION__); 2452 ugeth_vdbg("%s: IN", __FUNCTION__);
@@ -2602,11 +2608,11 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2602 if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4) 2608 if (UCC_GETH_TX_BD_RING_ALIGNMENT > 4)
2603 align = UCC_GETH_TX_BD_RING_ALIGNMENT; 2609 align = UCC_GETH_TX_BD_RING_ALIGNMENT;
2604 ugeth->tx_bd_ring_offset[j] = 2610 ugeth->tx_bd_ring_offset[j] =
2605 kmalloc((u32) (length + align), GFP_KERNEL); 2611 (u32) kmalloc((u32) (length + align), GFP_KERNEL);
2606 2612
2607 if (ugeth->tx_bd_ring_offset[j] != 0) 2613 if (ugeth->tx_bd_ring_offset[j] != 0)
2608 ugeth->p_tx_bd_ring[j] = 2614 ugeth->p_tx_bd_ring[j] =
2609 (void*)((ugeth->tx_bd_ring_offset[j] + 2615 (u8 __iomem *)((ugeth->tx_bd_ring_offset[j] +
2610 align) & ~(align - 1)); 2616 align) & ~(align - 1));
2611 } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { 2617 } else if (uf_info->bd_mem_part == MEM_PART_MURAM) {
2612 ugeth->tx_bd_ring_offset[j] = 2618 ugeth->tx_bd_ring_offset[j] =
@@ -2614,7 +2620,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2614 UCC_GETH_TX_BD_RING_ALIGNMENT); 2620 UCC_GETH_TX_BD_RING_ALIGNMENT);
2615 if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j])) 2621 if (!IS_ERR_VALUE(ugeth->tx_bd_ring_offset[j]))
2616 ugeth->p_tx_bd_ring[j] = 2622 ugeth->p_tx_bd_ring[j] =
2617 (u8 *) qe_muram_addr(ugeth-> 2623 (u8 __iomem *) qe_muram_addr(ugeth->
2618 tx_bd_ring_offset[j]); 2624 tx_bd_ring_offset[j]);
2619 } 2625 }
2620 if (!ugeth->p_tx_bd_ring[j]) { 2626 if (!ugeth->p_tx_bd_ring[j]) {
@@ -2626,8 +2632,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2626 return -ENOMEM; 2632 return -ENOMEM;
2627 } 2633 }
2628 /* Zero unused end of bd ring, according to spec */ 2634 /* Zero unused end of bd ring, according to spec */
2629 memset(ugeth->p_tx_bd_ring[j] + 2635 memset_io((void __iomem *)(ugeth->p_tx_bd_ring[j] +
2630 ug_info->bdRingLenTx[j] * sizeof(struct qe_bd), 0, 2636 ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)), 0,
2631 length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd)); 2637 length - ug_info->bdRingLenTx[j] * sizeof(struct qe_bd));
2632 } 2638 }
2633 2639
@@ -2639,10 +2645,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2639 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4) 2645 if (UCC_GETH_RX_BD_RING_ALIGNMENT > 4)
2640 align = UCC_GETH_RX_BD_RING_ALIGNMENT; 2646 align = UCC_GETH_RX_BD_RING_ALIGNMENT;
2641 ugeth->rx_bd_ring_offset[j] = 2647 ugeth->rx_bd_ring_offset[j] =
2642 kmalloc((u32) (length + align), GFP_KERNEL); 2648 (u32) kmalloc((u32) (length + align), GFP_KERNEL);
2643 if (ugeth->rx_bd_ring_offset[j] != 0) 2649 if (ugeth->rx_bd_ring_offset[j] != 0)
2644 ugeth->p_rx_bd_ring[j] = 2650 ugeth->p_rx_bd_ring[j] =
2645 (void*)((ugeth->rx_bd_ring_offset[j] + 2651 (u8 __iomem *)((ugeth->rx_bd_ring_offset[j] +
2646 align) & ~(align - 1)); 2652 align) & ~(align - 1));
2647 } else if (uf_info->bd_mem_part == MEM_PART_MURAM) { 2653 } else if (uf_info->bd_mem_part == MEM_PART_MURAM) {
2648 ugeth->rx_bd_ring_offset[j] = 2654 ugeth->rx_bd_ring_offset[j] =
@@ -2650,7 +2656,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2650 UCC_GETH_RX_BD_RING_ALIGNMENT); 2656 UCC_GETH_RX_BD_RING_ALIGNMENT);
2651 if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j])) 2657 if (!IS_ERR_VALUE(ugeth->rx_bd_ring_offset[j]))
2652 ugeth->p_rx_bd_ring[j] = 2658 ugeth->p_rx_bd_ring[j] =
2653 (u8 *) qe_muram_addr(ugeth-> 2659 (u8 __iomem *) qe_muram_addr(ugeth->
2654 rx_bd_ring_offset[j]); 2660 rx_bd_ring_offset[j]);
2655 } 2661 }
2656 if (!ugeth->p_rx_bd_ring[j]) { 2662 if (!ugeth->p_rx_bd_ring[j]) {
@@ -2685,14 +2691,14 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2685 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j]; 2691 bd = ugeth->confBd[j] = ugeth->txBd[j] = ugeth->p_tx_bd_ring[j];
2686 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) { 2692 for (i = 0; i < ug_info->bdRingLenTx[j]; i++) {
2687 /* clear bd buffer */ 2693 /* clear bd buffer */
2688 out_be32(&((struct qe_bd *)bd)->buf, 0); 2694 out_be32(&((struct qe_bd __iomem *)bd)->buf, 0);
2689 /* set bd status and length */ 2695 /* set bd status and length */
2690 out_be32((u32 *)bd, 0); 2696 out_be32((u32 __iomem *)bd, 0);
2691 bd += sizeof(struct qe_bd); 2697 bd += sizeof(struct qe_bd);
2692 } 2698 }
2693 bd -= sizeof(struct qe_bd); 2699 bd -= sizeof(struct qe_bd);
2694 /* set bd status and length */ 2700 /* set bd status and length */
2695 out_be32((u32 *)bd, T_W); /* for last BD set Wrap bit */ 2701 out_be32((u32 __iomem *)bd, T_W); /* for last BD set Wrap bit */
2696 } 2702 }
2697 2703
2698 /* Init Rx bds */ 2704 /* Init Rx bds */
@@ -2717,14 +2723,14 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2717 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j]; 2723 bd = ugeth->rxBd[j] = ugeth->p_rx_bd_ring[j];
2718 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) { 2724 for (i = 0; i < ug_info->bdRingLenRx[j]; i++) {
2719 /* set bd status and length */ 2725 /* set bd status and length */
2720 out_be32((u32 *)bd, R_I); 2726 out_be32((u32 __iomem *)bd, R_I);
2721 /* clear bd buffer */ 2727 /* clear bd buffer */
2722 out_be32(&((struct qe_bd *)bd)->buf, 0); 2728 out_be32(&((struct qe_bd __iomem *)bd)->buf, 0);
2723 bd += sizeof(struct qe_bd); 2729 bd += sizeof(struct qe_bd);
2724 } 2730 }
2725 bd -= sizeof(struct qe_bd); 2731 bd -= sizeof(struct qe_bd);
2726 /* set bd status and length */ 2732 /* set bd status and length */
2727 out_be32((u32 *)bd, R_W); /* for last BD set Wrap bit */ 2733 out_be32((u32 __iomem *)bd, R_W); /* for last BD set Wrap bit */
2728 } 2734 }
2729 2735
2730 /* 2736 /*
@@ -2744,10 +2750,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2744 return -ENOMEM; 2750 return -ENOMEM;
2745 } 2751 }
2746 ugeth->p_tx_glbl_pram = 2752 ugeth->p_tx_glbl_pram =
2747 (struct ucc_geth_tx_global_pram *) qe_muram_addr(ugeth-> 2753 (struct ucc_geth_tx_global_pram __iomem *) qe_muram_addr(ugeth->
2748 tx_glbl_pram_offset); 2754 tx_glbl_pram_offset);
2749 /* Zero out p_tx_glbl_pram */ 2755 /* Zero out p_tx_glbl_pram */
2750 memset(ugeth->p_tx_glbl_pram, 0, sizeof(struct ucc_geth_tx_global_pram)); 2756 memset_io((void __iomem *)ugeth->p_tx_glbl_pram, 0, sizeof(struct ucc_geth_tx_global_pram));
2751 2757
2752 /* Fill global PRAM */ 2758 /* Fill global PRAM */
2753 2759
@@ -2768,7 +2774,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2768 } 2774 }
2769 2775
2770 ugeth->p_thread_data_tx = 2776 ugeth->p_thread_data_tx =
2771 (struct ucc_geth_thread_data_tx *) qe_muram_addr(ugeth-> 2777 (struct ucc_geth_thread_data_tx __iomem *) qe_muram_addr(ugeth->
2772 thread_dat_tx_offset); 2778 thread_dat_tx_offset);
2773 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset); 2779 out_be32(&ugeth->p_tx_glbl_pram->tqptr, ugeth->thread_dat_tx_offset);
2774 2780
@@ -2779,7 +2785,8 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2779 2785
2780 /* iphoffset */ 2786 /* iphoffset */
2781 for (i = 0; i < TX_IP_OFFSET_ENTRY_MAX; i++) 2787 for (i = 0; i < TX_IP_OFFSET_ENTRY_MAX; i++)
2782 ugeth->p_tx_glbl_pram->iphoffset[i] = ug_info->iphoffset[i]; 2788 out_8(&ugeth->p_tx_glbl_pram->iphoffset[i],
2789 ug_info->iphoffset[i]);
2783 2790
2784 /* SQPTR */ 2791 /* SQPTR */
2785 /* Size varies with number of Tx queues */ 2792 /* Size varies with number of Tx queues */
@@ -2797,7 +2804,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2797 } 2804 }
2798 2805
2799 ugeth->p_send_q_mem_reg = 2806 ugeth->p_send_q_mem_reg =
2800 (struct ucc_geth_send_queue_mem_region *) qe_muram_addr(ugeth-> 2807 (struct ucc_geth_send_queue_mem_region __iomem *) qe_muram_addr(ugeth->
2801 send_q_mem_reg_offset); 2808 send_q_mem_reg_offset);
2802 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset); 2809 out_be32(&ugeth->p_tx_glbl_pram->sqptr, ugeth->send_q_mem_reg_offset);
2803 2810
@@ -2841,25 +2848,26 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2841 } 2848 }
2842 2849
2843 ugeth->p_scheduler = 2850 ugeth->p_scheduler =
2844 (struct ucc_geth_scheduler *) qe_muram_addr(ugeth-> 2851 (struct ucc_geth_scheduler __iomem *) qe_muram_addr(ugeth->
2845 scheduler_offset); 2852 scheduler_offset);
2846 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer, 2853 out_be32(&ugeth->p_tx_glbl_pram->schedulerbasepointer,
2847 ugeth->scheduler_offset); 2854 ugeth->scheduler_offset);
2848 /* Zero out p_scheduler */ 2855 /* Zero out p_scheduler */
2849 memset(ugeth->p_scheduler, 0, sizeof(struct ucc_geth_scheduler)); 2856 memset_io((void __iomem *)ugeth->p_scheduler, 0, sizeof(struct ucc_geth_scheduler));
2850 2857
2851 /* Set values in scheduler */ 2858 /* Set values in scheduler */
2852 out_be32(&ugeth->p_scheduler->mblinterval, 2859 out_be32(&ugeth->p_scheduler->mblinterval,
2853 ug_info->mblinterval); 2860 ug_info->mblinterval);
2854 out_be16(&ugeth->p_scheduler->nortsrbytetime, 2861 out_be16(&ugeth->p_scheduler->nortsrbytetime,
2855 ug_info->nortsrbytetime); 2862 ug_info->nortsrbytetime);
2856 ugeth->p_scheduler->fracsiz = ug_info->fracsiz; 2863 out_8(&ugeth->p_scheduler->fracsiz, ug_info->fracsiz);
2857 ugeth->p_scheduler->strictpriorityq = ug_info->strictpriorityq; 2864 out_8(&ugeth->p_scheduler->strictpriorityq,
2858 ugeth->p_scheduler->txasap = ug_info->txasap; 2865 ug_info->strictpriorityq);
2859 ugeth->p_scheduler->extrabw = ug_info->extrabw; 2866 out_8(&ugeth->p_scheduler->txasap, ug_info->txasap);
2867 out_8(&ugeth->p_scheduler->extrabw, ug_info->extrabw);
2860 for (i = 0; i < NUM_TX_QUEUES; i++) 2868 for (i = 0; i < NUM_TX_QUEUES; i++)
2861 ugeth->p_scheduler->weightfactor[i] = 2869 out_8(&ugeth->p_scheduler->weightfactor[i],
2862 ug_info->weightfactor[i]; 2870 ug_info->weightfactor[i]);
2863 2871
2864 /* Set pointers to cpucount registers in scheduler */ 2872 /* Set pointers to cpucount registers in scheduler */
2865 ugeth->p_cpucount[0] = &(ugeth->p_scheduler->cpucount0); 2873 ugeth->p_cpucount[0] = &(ugeth->p_scheduler->cpucount0);
@@ -2890,10 +2898,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2890 return -ENOMEM; 2898 return -ENOMEM;
2891 } 2899 }
2892 ugeth->p_tx_fw_statistics_pram = 2900 ugeth->p_tx_fw_statistics_pram =
2893 (struct ucc_geth_tx_firmware_statistics_pram *) 2901 (struct ucc_geth_tx_firmware_statistics_pram __iomem *)
2894 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset); 2902 qe_muram_addr(ugeth->tx_fw_statistics_pram_offset);
2895 /* Zero out p_tx_fw_statistics_pram */ 2903 /* Zero out p_tx_fw_statistics_pram */
2896 memset(ugeth->p_tx_fw_statistics_pram, 2904 memset_io((void __iomem *)ugeth->p_tx_fw_statistics_pram,
2897 0, sizeof(struct ucc_geth_tx_firmware_statistics_pram)); 2905 0, sizeof(struct ucc_geth_tx_firmware_statistics_pram));
2898 } 2906 }
2899 2907
@@ -2930,10 +2938,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2930 return -ENOMEM; 2938 return -ENOMEM;
2931 } 2939 }
2932 ugeth->p_rx_glbl_pram = 2940 ugeth->p_rx_glbl_pram =
2933 (struct ucc_geth_rx_global_pram *) qe_muram_addr(ugeth-> 2941 (struct ucc_geth_rx_global_pram __iomem *) qe_muram_addr(ugeth->
2934 rx_glbl_pram_offset); 2942 rx_glbl_pram_offset);
2935 /* Zero out p_rx_glbl_pram */ 2943 /* Zero out p_rx_glbl_pram */
2936 memset(ugeth->p_rx_glbl_pram, 0, sizeof(struct ucc_geth_rx_global_pram)); 2944 memset_io((void __iomem *)ugeth->p_rx_glbl_pram, 0, sizeof(struct ucc_geth_rx_global_pram));
2937 2945
2938 /* Fill global PRAM */ 2946 /* Fill global PRAM */
2939 2947
@@ -2953,7 +2961,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2953 } 2961 }
2954 2962
2955 ugeth->p_thread_data_rx = 2963 ugeth->p_thread_data_rx =
2956 (struct ucc_geth_thread_data_rx *) qe_muram_addr(ugeth-> 2964 (struct ucc_geth_thread_data_rx __iomem *) qe_muram_addr(ugeth->
2957 thread_dat_rx_offset); 2965 thread_dat_rx_offset);
2958 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset); 2966 out_be32(&ugeth->p_rx_glbl_pram->rqptr, ugeth->thread_dat_rx_offset);
2959 2967
@@ -2976,10 +2984,10 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
2976 return -ENOMEM; 2984 return -ENOMEM;
2977 } 2985 }
2978 ugeth->p_rx_fw_statistics_pram = 2986 ugeth->p_rx_fw_statistics_pram =
2979 (struct ucc_geth_rx_firmware_statistics_pram *) 2987 (struct ucc_geth_rx_firmware_statistics_pram __iomem *)
2980 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset); 2988 qe_muram_addr(ugeth->rx_fw_statistics_pram_offset);
2981 /* Zero out p_rx_fw_statistics_pram */ 2989 /* Zero out p_rx_fw_statistics_pram */
2982 memset(ugeth->p_rx_fw_statistics_pram, 0, 2990 memset_io((void __iomem *)ugeth->p_rx_fw_statistics_pram, 0,
2983 sizeof(struct ucc_geth_rx_firmware_statistics_pram)); 2991 sizeof(struct ucc_geth_rx_firmware_statistics_pram));
2984 } 2992 }
2985 2993
@@ -3000,7 +3008,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3000 } 3008 }
3001 3009
3002 ugeth->p_rx_irq_coalescing_tbl = 3010 ugeth->p_rx_irq_coalescing_tbl =
3003 (struct ucc_geth_rx_interrupt_coalescing_table *) 3011 (struct ucc_geth_rx_interrupt_coalescing_table __iomem *)
3004 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset); 3012 qe_muram_addr(ugeth->rx_irq_coalescing_tbl_offset);
3005 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr, 3013 out_be32(&ugeth->p_rx_glbl_pram->intcoalescingptr,
3006 ugeth->rx_irq_coalescing_tbl_offset); 3014 ugeth->rx_irq_coalescing_tbl_offset);
@@ -3069,11 +3077,11 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3069 } 3077 }
3070 3078
3071 ugeth->p_rx_bd_qs_tbl = 3079 ugeth->p_rx_bd_qs_tbl =
3072 (struct ucc_geth_rx_bd_queues_entry *) qe_muram_addr(ugeth-> 3080 (struct ucc_geth_rx_bd_queues_entry __iomem *) qe_muram_addr(ugeth->
3073 rx_bd_qs_tbl_offset); 3081 rx_bd_qs_tbl_offset);
3074 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset); 3082 out_be32(&ugeth->p_rx_glbl_pram->rbdqptr, ugeth->rx_bd_qs_tbl_offset);
3075 /* Zero out p_rx_bd_qs_tbl */ 3083 /* Zero out p_rx_bd_qs_tbl */
3076 memset(ugeth->p_rx_bd_qs_tbl, 3084 memset_io((void __iomem *)ugeth->p_rx_bd_qs_tbl,
3077 0, 3085 0,
3078 ug_info->numQueuesRx * (sizeof(struct ucc_geth_rx_bd_queues_entry) + 3086 ug_info->numQueuesRx * (sizeof(struct ucc_geth_rx_bd_queues_entry) +
3079 sizeof(struct ucc_geth_rx_prefetched_bds))); 3087 sizeof(struct ucc_geth_rx_prefetched_bds)));
@@ -3133,7 +3141,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3133 &ugeth->p_rx_glbl_pram->remoder); 3141 &ugeth->p_rx_glbl_pram->remoder);
3134 3142
3135 /* function code register */ 3143 /* function code register */
3136 ugeth->p_rx_glbl_pram->rstate = function_code; 3144 out_8(&ugeth->p_rx_glbl_pram->rstate, function_code);
3137 3145
3138 /* initialize extended filtering */ 3146 /* initialize extended filtering */
3139 if (ug_info->rxExtendedFiltering) { 3147 if (ug_info->rxExtendedFiltering) {
@@ -3160,7 +3168,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3160 } 3168 }
3161 3169
3162 ugeth->p_exf_glbl_param = 3170 ugeth->p_exf_glbl_param =
3163 (struct ucc_geth_exf_global_pram *) qe_muram_addr(ugeth-> 3171 (struct ucc_geth_exf_global_pram __iomem *) qe_muram_addr(ugeth->
3164 exf_glbl_param_offset); 3172 exf_glbl_param_offset);
3165 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam, 3173 out_be32(&ugeth->p_rx_glbl_pram->exfGlobalParam,
3166 ugeth->exf_glbl_param_offset); 3174 ugeth->exf_glbl_param_offset);
@@ -3175,7 +3183,7 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3175 ugeth_82xx_filtering_clear_addr_in_paddr(ugeth, (u8) j); 3183 ugeth_82xx_filtering_clear_addr_in_paddr(ugeth, (u8) j);
3176 3184
3177 p_82xx_addr_filt = 3185 p_82xx_addr_filt =
3178 (struct ucc_geth_82xx_address_filtering_pram *) ugeth-> 3186 (struct ucc_geth_82xx_address_filtering_pram __iomem *) ugeth->
3179 p_rx_glbl_pram->addressfiltering; 3187 p_rx_glbl_pram->addressfiltering;
3180 3188
3181 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth, 3189 ugeth_82xx_filtering_clear_all_addr_in_hash(ugeth,
@@ -3307,17 +3315,21 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth)
3307 return -ENOMEM; 3315 return -ENOMEM;
3308 } 3316 }
3309 p_init_enet_pram = 3317 p_init_enet_pram =
3310 (struct ucc_geth_init_pram *) qe_muram_addr(init_enet_pram_offset); 3318 (struct ucc_geth_init_pram __iomem *) qe_muram_addr(init_enet_pram_offset);
3311 3319
3312 /* Copy shadow InitEnet command parameter structure into PRAM */ 3320 /* Copy shadow InitEnet command parameter structure into PRAM */
3313 p_init_enet_pram->resinit1 = ugeth->p_init_enet_param_shadow->resinit1; 3321 out_8(&p_init_enet_pram->resinit1,
3314 p_init_enet_pram->resinit2 = ugeth->p_init_enet_param_shadow->resinit2; 3322 ugeth->p_init_enet_param_shadow->resinit1);
3315 p_init_enet_pram->resinit3 = ugeth->p_init_enet_param_shadow->resinit3; 3323 out_8(&p_init_enet_pram->resinit2,
3316 p_init_enet_pram->resinit4 = ugeth->p_init_enet_param_shadow->resinit4; 3324 ugeth->p_init_enet_param_shadow->resinit2);
3325 out_8(&p_init_enet_pram->resinit3,
3326 ugeth->p_init_enet_param_shadow->resinit3);
3327 out_8(&p_init_enet_pram->resinit4,
3328 ugeth->p_init_enet_param_shadow->resinit4);
3317 out_be16(&p_init_enet_pram->resinit5, 3329 out_be16(&p_init_enet_pram->resinit5,
3318 ugeth->p_init_enet_param_shadow->resinit5); 3330 ugeth->p_init_enet_param_shadow->resinit5);
3319 p_init_enet_pram->largestexternallookupkeysize = 3331 out_8(&p_init_enet_pram->largestexternallookupkeysize,
3320 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize; 3332 ugeth->p_init_enet_param_shadow->largestexternallookupkeysize);
3321 out_be32(&p_init_enet_pram->rgftgfrxglobal, 3333 out_be32(&p_init_enet_pram->rgftgfrxglobal,
3322 ugeth->p_init_enet_param_shadow->rgftgfrxglobal); 3334 ugeth->p_init_enet_param_shadow->rgftgfrxglobal);
3323 for (i = 0; i < ENET_INIT_PARAM_MAX_ENTRIES_RX; i++) 3335 for (i = 0; i < ENET_INIT_PARAM_MAX_ENTRIES_RX; i++)
@@ -3371,7 +3383,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3371#ifdef CONFIG_UGETH_TX_ON_DEMAND 3383#ifdef CONFIG_UGETH_TX_ON_DEMAND
3372 struct ucc_fast_private *uccf; 3384 struct ucc_fast_private *uccf;
3373#endif 3385#endif
3374 u8 *bd; /* BD pointer */ 3386 u8 __iomem *bd; /* BD pointer */
3375 u32 bd_status; 3387 u32 bd_status;
3376 u8 txQ = 0; 3388 u8 txQ = 0;
3377 3389
@@ -3383,7 +3395,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3383 3395
3384 /* Start from the next BD that should be filled */ 3396 /* Start from the next BD that should be filled */
3385 bd = ugeth->txBd[txQ]; 3397 bd = ugeth->txBd[txQ];
3386 bd_status = in_be32((u32 *)bd); 3398 bd_status = in_be32((u32 __iomem *)bd);
3387 /* Save the skb pointer so we can free it later */ 3399 /* Save the skb pointer so we can free it later */
3388 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb; 3400 ugeth->tx_skbuff[txQ][ugeth->skb_curtx[txQ]] = skb;
3389 3401
@@ -3393,7 +3405,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3393 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]); 3405 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]);
3394 3406
3395 /* set up the buffer descriptor */ 3407 /* set up the buffer descriptor */
3396 out_be32(&((struct qe_bd *)bd)->buf, 3408 out_be32(&((struct qe_bd __iomem *)bd)->buf,
3397 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE)); 3409 dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE));
3398 3410
3399 /* printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); */ 3411 /* printk(KERN_DEBUG"skb->data is 0x%x\n",skb->data); */
@@ -3401,7 +3413,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3401 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len; 3413 bd_status = (bd_status & T_W) | T_R | T_I | T_L | skb->len;
3402 3414
3403 /* set bd status and length */ 3415 /* set bd status and length */
3404 out_be32((u32 *)bd, bd_status); 3416 out_be32((u32 __iomem *)bd, bd_status);
3405 3417
3406 dev->trans_start = jiffies; 3418 dev->trans_start = jiffies;
3407 3419
@@ -3441,7 +3453,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3441static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit) 3453static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit)
3442{ 3454{
3443 struct sk_buff *skb; 3455 struct sk_buff *skb;
3444 u8 *bd; 3456 u8 __iomem *bd;
3445 u16 length, howmany = 0; 3457 u16 length, howmany = 0;
3446 u32 bd_status; 3458 u32 bd_status;
3447 u8 *bdBuffer; 3459 u8 *bdBuffer;
@@ -3454,11 +3466,11 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3454 /* collect received buffers */ 3466 /* collect received buffers */
3455 bd = ugeth->rxBd[rxQ]; 3467 bd = ugeth->rxBd[rxQ];
3456 3468
3457 bd_status = in_be32((u32 *)bd); 3469 bd_status = in_be32((u32 __iomem *)bd);
3458 3470
3459 /* while there are received buffers and BD is full (~R_E) */ 3471 /* while there are received buffers and BD is full (~R_E) */
3460 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) { 3472 while (!((bd_status & (R_E)) || (--rx_work_limit < 0))) {
3461 bdBuffer = (u8 *) in_be32(&((struct qe_bd *)bd)->buf); 3473 bdBuffer = (u8 *) in_be32(&((struct qe_bd __iomem *)bd)->buf);
3462 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4); 3474 length = (u16) ((bd_status & BD_LENGTH_MASK) - 4);
3463 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]]; 3475 skb = ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]];
3464 3476
@@ -3516,7 +3528,7 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit
3516 else 3528 else
3517 bd += sizeof(struct qe_bd); 3529 bd += sizeof(struct qe_bd);
3518 3530
3519 bd_status = in_be32((u32 *)bd); 3531 bd_status = in_be32((u32 __iomem *)bd);
3520 } 3532 }
3521 3533
3522 ugeth->rxBd[rxQ] = bd; 3534 ugeth->rxBd[rxQ] = bd;
@@ -3527,11 +3539,11 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3527{ 3539{
3528 /* Start from the next BD that should be filled */ 3540 /* Start from the next BD that should be filled */
3529 struct ucc_geth_private *ugeth = netdev_priv(dev); 3541 struct ucc_geth_private *ugeth = netdev_priv(dev);
3530 u8 *bd; /* BD pointer */ 3542 u8 __iomem *bd; /* BD pointer */
3531 u32 bd_status; 3543 u32 bd_status;
3532 3544
3533 bd = ugeth->confBd[txQ]; 3545 bd = ugeth->confBd[txQ];
3534 bd_status = in_be32((u32 *)bd); 3546 bd_status = in_be32((u32 __iomem *)bd);
3535 3547
3536 /* Normal processing. */ 3548 /* Normal processing. */
3537 while ((bd_status & T_R) == 0) { 3549 while ((bd_status & T_R) == 0) {
@@ -3561,7 +3573,7 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
3561 bd += sizeof(struct qe_bd); 3573 bd += sizeof(struct qe_bd);
3562 else 3574 else
3563 bd = ugeth->p_tx_bd_ring[txQ]; 3575 bd = ugeth->p_tx_bd_ring[txQ];
3564 bd_status = in_be32((u32 *)bd); 3576 bd_status = in_be32((u32 __iomem *)bd);
3565 } 3577 }
3566 ugeth->confBd[txQ] = bd; 3578 ugeth->confBd[txQ] = bd;
3567 return 0; 3579 return 0;
@@ -3910,7 +3922,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
3910 return -EINVAL; 3922 return -EINVAL;
3911 } 3923 }
3912 } else { 3924 } else {
3913 prop = of_get_property(np, "rx-clock", NULL); 3925 prop = of_get_property(np, "tx-clock", NULL);
3914 if (!prop) { 3926 if (!prop) {
3915 printk(KERN_ERR 3927 printk(KERN_ERR
3916 "ucc_geth: mising tx-clock-name property\n"); 3928 "ucc_geth: mising tx-clock-name property\n");
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
index 9f8b7580a3a4..abc0e2242634 100644
--- a/drivers/net/ucc_geth.h
+++ b/drivers/net/ucc_geth.h
@@ -700,8 +700,8 @@ struct ucc_geth_82xx_address_filtering_pram {
700 u32 iaddr_l; /* individual address filter, low */ 700 u32 iaddr_l; /* individual address filter, low */
701 u32 gaddr_h; /* group address filter, high */ 701 u32 gaddr_h; /* group address filter, high */
702 u32 gaddr_l; /* group address filter, low */ 702 u32 gaddr_l; /* group address filter, low */
703 struct ucc_geth_82xx_enet_address taddr; 703 struct ucc_geth_82xx_enet_address __iomem taddr;
704 struct ucc_geth_82xx_enet_address paddr[NUM_OF_PADDRS]; 704 struct ucc_geth_82xx_enet_address __iomem paddr[NUM_OF_PADDRS];
705 u8 res0[0x40 - 0x38]; 705 u8 res0[0x40 - 0x38];
706} __attribute__ ((packed)); 706} __attribute__ ((packed));
707 707
@@ -1186,40 +1186,40 @@ struct ucc_geth_private {
1186 struct ucc_fast_private *uccf; 1186 struct ucc_fast_private *uccf;
1187 struct net_device *dev; 1187 struct net_device *dev;
1188 struct napi_struct napi; 1188 struct napi_struct napi;
1189 struct ucc_geth *ug_regs; 1189 struct ucc_geth __iomem *ug_regs;
1190 struct ucc_geth_init_pram *p_init_enet_param_shadow; 1190 struct ucc_geth_init_pram *p_init_enet_param_shadow;
1191 struct ucc_geth_exf_global_pram *p_exf_glbl_param; 1191 struct ucc_geth_exf_global_pram __iomem *p_exf_glbl_param;
1192 u32 exf_glbl_param_offset; 1192 u32 exf_glbl_param_offset;
1193 struct ucc_geth_rx_global_pram *p_rx_glbl_pram; 1193 struct ucc_geth_rx_global_pram __iomem *p_rx_glbl_pram;
1194 u32 rx_glbl_pram_offset; 1194 u32 rx_glbl_pram_offset;
1195 struct ucc_geth_tx_global_pram *p_tx_glbl_pram; 1195 struct ucc_geth_tx_global_pram __iomem *p_tx_glbl_pram;
1196 u32 tx_glbl_pram_offset; 1196 u32 tx_glbl_pram_offset;
1197 struct ucc_geth_send_queue_mem_region *p_send_q_mem_reg; 1197 struct ucc_geth_send_queue_mem_region __iomem *p_send_q_mem_reg;
1198 u32 send_q_mem_reg_offset; 1198 u32 send_q_mem_reg_offset;
1199 struct ucc_geth_thread_data_tx *p_thread_data_tx; 1199 struct ucc_geth_thread_data_tx __iomem *p_thread_data_tx;
1200 u32 thread_dat_tx_offset; 1200 u32 thread_dat_tx_offset;
1201 struct ucc_geth_thread_data_rx *p_thread_data_rx; 1201 struct ucc_geth_thread_data_rx __iomem *p_thread_data_rx;
1202 u32 thread_dat_rx_offset; 1202 u32 thread_dat_rx_offset;
1203 struct ucc_geth_scheduler *p_scheduler; 1203 struct ucc_geth_scheduler __iomem *p_scheduler;
1204 u32 scheduler_offset; 1204 u32 scheduler_offset;
1205 struct ucc_geth_tx_firmware_statistics_pram *p_tx_fw_statistics_pram; 1205 struct ucc_geth_tx_firmware_statistics_pram __iomem *p_tx_fw_statistics_pram;
1206 u32 tx_fw_statistics_pram_offset; 1206 u32 tx_fw_statistics_pram_offset;
1207 struct ucc_geth_rx_firmware_statistics_pram *p_rx_fw_statistics_pram; 1207 struct ucc_geth_rx_firmware_statistics_pram __iomem *p_rx_fw_statistics_pram;
1208 u32 rx_fw_statistics_pram_offset; 1208 u32 rx_fw_statistics_pram_offset;
1209 struct ucc_geth_rx_interrupt_coalescing_table *p_rx_irq_coalescing_tbl; 1209 struct ucc_geth_rx_interrupt_coalescing_table __iomem *p_rx_irq_coalescing_tbl;
1210 u32 rx_irq_coalescing_tbl_offset; 1210 u32 rx_irq_coalescing_tbl_offset;
1211 struct ucc_geth_rx_bd_queues_entry *p_rx_bd_qs_tbl; 1211 struct ucc_geth_rx_bd_queues_entry __iomem *p_rx_bd_qs_tbl;
1212 u32 rx_bd_qs_tbl_offset; 1212 u32 rx_bd_qs_tbl_offset;
1213 u8 *p_tx_bd_ring[NUM_TX_QUEUES]; 1213 u8 __iomem *p_tx_bd_ring[NUM_TX_QUEUES];
1214 u32 tx_bd_ring_offset[NUM_TX_QUEUES]; 1214 u32 tx_bd_ring_offset[NUM_TX_QUEUES];
1215 u8 *p_rx_bd_ring[NUM_RX_QUEUES]; 1215 u8 __iomem *p_rx_bd_ring[NUM_RX_QUEUES];
1216 u32 rx_bd_ring_offset[NUM_RX_QUEUES]; 1216 u32 rx_bd_ring_offset[NUM_RX_QUEUES];
1217 u8 *confBd[NUM_TX_QUEUES]; 1217 u8 __iomem *confBd[NUM_TX_QUEUES];
1218 u8 *txBd[NUM_TX_QUEUES]; 1218 u8 __iomem *txBd[NUM_TX_QUEUES];
1219 u8 *rxBd[NUM_RX_QUEUES]; 1219 u8 __iomem *rxBd[NUM_RX_QUEUES];
1220 int badFrame[NUM_RX_QUEUES]; 1220 int badFrame[NUM_RX_QUEUES];
1221 u16 cpucount[NUM_TX_QUEUES]; 1221 u16 cpucount[NUM_TX_QUEUES];
1222 volatile u16 *p_cpucount[NUM_TX_QUEUES]; 1222 u16 __iomem *p_cpucount[NUM_TX_QUEUES];
1223 int indAddrRegUsed[NUM_OF_PADDRS]; 1223 int indAddrRegUsed[NUM_OF_PADDRS];
1224 u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */ 1224 u8 paddr[NUM_OF_PADDRS][ENET_NUM_OCTETS_PER_ADDRESS]; /* ethernet address */
1225 u8 numGroupAddrInHash; 1225 u8 numGroupAddrInHash;
@@ -1251,4 +1251,12 @@ struct ucc_geth_private {
1251 int oldlink; 1251 int oldlink;
1252}; 1252};
1253 1253
1254void uec_set_ethtool_ops(struct net_device *netdev);
1255int init_flow_control_params(u32 automatic_flow_control_mode,
1256 int rx_flow_control_enable, int tx_flow_control_enable,
1257 u16 pause_period, u16 extension_field,
1258 u32 __iomem *upsmr_register, u32 __iomem *uempr_register,
1259 u32 __iomem *maccfg1_register);
1260
1261
1254#endif /* __UCC_GETH_H__ */ 1262#endif /* __UCC_GETH_H__ */
diff --git a/drivers/net/ucc_geth_ethtool.c b/drivers/net/ucc_geth_ethtool.c
index 33200038a14d..5f176f2b1c17 100644
--- a/drivers/net/ucc_geth_ethtool.c
+++ b/drivers/net/ucc_geth_ethtool.c
@@ -108,12 +108,6 @@ static char rx_fw_stat_gstrings[][ETH_GSTRING_LEN] = {
108#define UEC_TX_FW_STATS_LEN ARRAY_SIZE(tx_fw_stat_gstrings) 108#define UEC_TX_FW_STATS_LEN ARRAY_SIZE(tx_fw_stat_gstrings)
109#define UEC_RX_FW_STATS_LEN ARRAY_SIZE(rx_fw_stat_gstrings) 109#define UEC_RX_FW_STATS_LEN ARRAY_SIZE(rx_fw_stat_gstrings)
110 110
111extern int init_flow_control_params(u32 automatic_flow_control_mode,
112 int rx_flow_control_enable,
113 int tx_flow_control_enable, u16 pause_period,
114 u16 extension_field, volatile u32 *upsmr_register,
115 volatile u32 *uempr_register, volatile u32 *maccfg1_register);
116
117static int 111static int
118uec_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) 112uec_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
119{ 113{
diff --git a/drivers/net/ucc_geth_mii.c b/drivers/net/ucc_geth_mii.c
index 2af490781005..940474736922 100644
--- a/drivers/net/ucc_geth_mii.c
+++ b/drivers/net/ucc_geth_mii.c
@@ -104,7 +104,7 @@ int uec_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
104} 104}
105 105
106/* Reset the MIIM registers, and wait for the bus to free */ 106/* Reset the MIIM registers, and wait for the bus to free */
107int uec_mdio_reset(struct mii_bus *bus) 107static int uec_mdio_reset(struct mii_bus *bus)
108{ 108{
109 struct ucc_mii_mng __iomem *regs = (void __iomem *)bus->priv; 109 struct ucc_mii_mng __iomem *regs = (void __iomem *)bus->priv;
110 unsigned int timeout = PHY_INIT_TIMEOUT; 110 unsigned int timeout = PHY_INIT_TIMEOUT;
@@ -240,7 +240,7 @@ reg_map_fail:
240 return err; 240 return err;
241} 241}
242 242
243int uec_mdio_remove(struct of_device *ofdev) 243static int uec_mdio_remove(struct of_device *ofdev)
244{ 244{
245 struct device *device = &ofdev->dev; 245 struct device *device = &ofdev->dev;
246 struct mii_bus *bus = dev_get_drvdata(device); 246 struct mii_bus *bus = dev_get_drvdata(device);
diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index 6f245cfb6624..dc6f097062df 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -1381,6 +1381,10 @@ static const struct usb_device_id products [] = {
1381 USB_DEVICE (0x0411, 0x003d), 1381 USB_DEVICE (0x0411, 0x003d),
1382 .driver_info = (unsigned long) &ax8817x_info, 1382 .driver_info = (unsigned long) &ax8817x_info,
1383}, { 1383}, {
1384 // Buffalo LUA-U2-GT 10/100/1000
1385 USB_DEVICE (0x0411, 0x006e),
1386 .driver_info = (unsigned long) &ax88178_info,
1387}, {
1384 // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" 1388 // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter"
1385 USB_DEVICE (0x6189, 0x182d), 1389 USB_DEVICE (0x6189, 0x182d),
1386 .driver_info = (unsigned long) &ax8817x_info, 1390 .driver_info = (unsigned long) &ax8817x_info,
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 8005dd16fb4e..d5140aed7b79 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -150,11 +150,9 @@ config HDLC_FR
150 150
151config HDLC_PPP 151config HDLC_PPP
152 tristate "Synchronous Point-to-Point Protocol (PPP) support" 152 tristate "Synchronous Point-to-Point Protocol (PPP) support"
153 depends on HDLC && BROKEN 153 depends on HDLC
154 help 154 help
155 Generic HDLC driver supporting PPP over WAN connections. 155 Generic HDLC driver supporting PPP over WAN connections.
156 This module is currently broken and will cause a kernel panic
157 when a device configured in PPP mode is activated.
158 156
159 It will be replaced by new PPP implementation in Linux 2.6.26. 157 It will be replaced by new PPP implementation in Linux 2.6.26.
160 158
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
index 45ddfc9763cc..b0fce1387eaf 100644
--- a/drivers/net/wan/cosa.c
+++ b/drivers/net/wan/cosa.c
@@ -629,7 +629,7 @@ static void sppp_channel_init(struct channel_data *chan)
629 d->base_addr = chan->cosa->datareg; 629 d->base_addr = chan->cosa->datareg;
630 d->irq = chan->cosa->irq; 630 d->irq = chan->cosa->irq;
631 d->dma = chan->cosa->dma; 631 d->dma = chan->cosa->dma;
632 d->priv = chan; 632 d->ml_priv = chan;
633 sppp_attach(&chan->pppdev); 633 sppp_attach(&chan->pppdev);
634 if (register_netdev(d)) { 634 if (register_netdev(d)) {
635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name); 635 printk(KERN_WARNING "%s: register_netdev failed.\n", d->name);
@@ -650,7 +650,7 @@ static void sppp_channel_delete(struct channel_data *chan)
650 650
651static int cosa_sppp_open(struct net_device *d) 651static int cosa_sppp_open(struct net_device *d)
652{ 652{
653 struct channel_data *chan = d->priv; 653 struct channel_data *chan = d->ml_priv;
654 int err; 654 int err;
655 unsigned long flags; 655 unsigned long flags;
656 656
@@ -690,7 +690,7 @@ static int cosa_sppp_open(struct net_device *d)
690 690
691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev) 691static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
692{ 692{
693 struct channel_data *chan = dev->priv; 693 struct channel_data *chan = dev->ml_priv;
694 694
695 netif_stop_queue(dev); 695 netif_stop_queue(dev);
696 696
@@ -701,7 +701,7 @@ static int cosa_sppp_tx(struct sk_buff *skb, struct net_device *dev)
701 701
702static void cosa_sppp_timeout(struct net_device *dev) 702static void cosa_sppp_timeout(struct net_device *dev)
703{ 703{
704 struct channel_data *chan = dev->priv; 704 struct channel_data *chan = dev->ml_priv;
705 705
706 if (test_bit(RXBIT, &chan->cosa->rxtx)) { 706 if (test_bit(RXBIT, &chan->cosa->rxtx)) {
707 chan->stats.rx_errors++; 707 chan->stats.rx_errors++;
@@ -720,7 +720,7 @@ static void cosa_sppp_timeout(struct net_device *dev)
720 720
721static int cosa_sppp_close(struct net_device *d) 721static int cosa_sppp_close(struct net_device *d)
722{ 722{
723 struct channel_data *chan = d->priv; 723 struct channel_data *chan = d->ml_priv;
724 unsigned long flags; 724 unsigned long flags;
725 725
726 netif_stop_queue(d); 726 netif_stop_queue(d);
@@ -800,7 +800,7 @@ static int sppp_tx_done(struct channel_data *chan, int size)
800 800
801static struct net_device_stats *cosa_net_stats(struct net_device *dev) 801static struct net_device_stats *cosa_net_stats(struct net_device *dev)
802{ 802{
803 struct channel_data *chan = dev->priv; 803 struct channel_data *chan = dev->ml_priv;
804 return &chan->stats; 804 return &chan->stats;
805} 805}
806 806
@@ -1217,7 +1217,7 @@ static int cosa_sppp_ioctl(struct net_device *dev, struct ifreq *ifr,
1217 int cmd) 1217 int cmd)
1218{ 1218{
1219 int rv; 1219 int rv;
1220 struct channel_data *chan = dev->priv; 1220 struct channel_data *chan = dev->ml_priv;
1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data); 1221 rv = cosa_ioctl_common(chan->cosa, chan, cmd, (unsigned long)ifr->ifr_data);
1222 if (rv == -ENOIOCTLCMD) { 1222 if (rv == -ENOIOCTLCMD) {
1223 return sppp_do_ioctl(dev, ifr, cmd); 1223 return sppp_do_ioctl(dev, ifr, cmd);
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index 10396d9686f4..00308337928e 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -45,7 +45,7 @@ static int ppp_open(struct net_device *dev)
45 int (*old_ioctl)(struct net_device *, struct ifreq *, int); 45 int (*old_ioctl)(struct net_device *, struct ifreq *, int);
46 int result; 46 int result;
47 47
48 dev->priv = &state(hdlc)->syncppp_ptr; 48 dev->ml_priv = &state(hdlc)->syncppp_ptr;
49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev; 49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev;
50 state(hdlc)->pppdev.dev = dev; 50 state(hdlc)->pppdev.dev = dev;
51 51
diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c
index 83dbc924fcb5..f3065d3473fd 100644
--- a/drivers/net/wan/hostess_sv11.c
+++ b/drivers/net/wan/hostess_sv11.c
@@ -75,7 +75,7 @@ static void hostess_input(struct z8530_channel *c, struct sk_buff *skb)
75 75
76static int hostess_open(struct net_device *d) 76static int hostess_open(struct net_device *d)
77{ 77{
78 struct sv11_device *sv11=d->priv; 78 struct sv11_device *sv11=d->ml_priv;
79 int err = -1; 79 int err = -1;
80 80
81 /* 81 /*
@@ -128,7 +128,7 @@ static int hostess_open(struct net_device *d)
128 128
129static int hostess_close(struct net_device *d) 129static int hostess_close(struct net_device *d)
130{ 130{
131 struct sv11_device *sv11=d->priv; 131 struct sv11_device *sv11=d->ml_priv;
132 /* 132 /*
133 * Discard new frames 133 * Discard new frames
134 */ 134 */
@@ -159,14 +159,14 @@ static int hostess_close(struct net_device *d)
159 159
160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd) 160static int hostess_ioctl(struct net_device *d, struct ifreq *ifr, int cmd)
161{ 161{
162 /* struct sv11_device *sv11=d->priv; 162 /* struct sv11_device *sv11=d->ml_priv;
163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */ 163 z8530_ioctl(d,&sv11->sync.chanA,ifr,cmd) */
164 return sppp_do_ioctl(d, ifr,cmd); 164 return sppp_do_ioctl(d, ifr,cmd);
165} 165}
166 166
167static struct net_device_stats *hostess_get_stats(struct net_device *d) 167static struct net_device_stats *hostess_get_stats(struct net_device *d)
168{ 168{
169 struct sv11_device *sv11=d->priv; 169 struct sv11_device *sv11=d->ml_priv;
170 if(sv11) 170 if(sv11)
171 return z8530_get_stats(&sv11->sync.chanA); 171 return z8530_get_stats(&sv11->sync.chanA);
172 else 172 else
@@ -179,7 +179,7 @@ static struct net_device_stats *hostess_get_stats(struct net_device *d)
179 179
180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d) 180static int hostess_queue_xmit(struct sk_buff *skb, struct net_device *d)
181{ 181{
182 struct sv11_device *sv11=d->priv; 182 struct sv11_device *sv11=d->ml_priv;
183 return z8530_queue_xmit(&sv11->sync.chanA, skb); 183 return z8530_queue_xmit(&sv11->sync.chanA, skb);
184} 184}
185 185
@@ -325,6 +325,7 @@ static struct sv11_device *sv11_init(int iobase, int irq)
325 /* 325 /*
326 * Initialise the PPP components 326 * Initialise the PPP components
327 */ 327 */
328 d->ml_priv = sv;
328 sppp_attach(&sv->netdev); 329 sppp_attach(&sv->netdev);
329 330
330 /* 331 /*
@@ -333,7 +334,6 @@ static struct sv11_device *sv11_init(int iobase, int irq)
333 334
334 d->base_addr = iobase; 335 d->base_addr = iobase;
335 d->irq = irq; 336 d->irq = irq;
336 d->priv = sv;
337 337
338 if(register_netdev(d)) 338 if(register_netdev(d))
339 { 339 {
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index b5860b97a93e..24fd613466b7 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -459,6 +459,7 @@ static void __exit lapbeth_cleanup_driver(void)
459 list_for_each_safe(entry, tmp, &lapbeth_devices) { 459 list_for_each_safe(entry, tmp, &lapbeth_devices) {
460 lapbeth = list_entry(entry, struct lapbethdev, node); 460 lapbeth = list_entry(entry, struct lapbethdev, node);
461 461
462 dev_put(lapbeth->ethdev);
462 unregister_netdevice(lapbeth->axdev); 463 unregister_netdevice(lapbeth->axdev);
463 } 464 }
464 rtnl_unlock(); 465 rtnl_unlock();
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 6635ecef36e5..62133cee446a 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -891,6 +891,7 @@ static int __devinit lmc_init_one(struct pci_dev *pdev,
891 891
892 /* Initialize the sppp layer */ 892 /* Initialize the sppp layer */
893 /* An ioctl can cause a subsequent detach for raw frame interface */ 893 /* An ioctl can cause a subsequent detach for raw frame interface */
894 dev->ml_priv = sc;
894 sc->if_type = LMC_PPP; 895 sc->if_type = LMC_PPP;
895 sc->check = 0xBEAFCAFE; 896 sc->check = 0xBEAFCAFE;
896 dev->base_addr = pci_resource_start(pdev, 0); 897 dev->base_addr = pci_resource_start(pdev, 0);
diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c
index 11276bf3149f..44a89df1b8bf 100644
--- a/drivers/net/wan/sealevel.c
+++ b/drivers/net/wan/sealevel.c
@@ -241,6 +241,7 @@ static inline struct slvl_device *slvl_alloc(int iobase, int irq)
241 return NULL; 241 return NULL;
242 242
243 sv = d->priv; 243 sv = d->priv;
244 d->ml_priv = sv;
244 sv->if_ptr = &sv->pppdev; 245 sv->if_ptr = &sv->pppdev;
245 sv->pppdev.dev = d; 246 sv->pppdev.dev = d;
246 d->base_addr = iobase; 247 d->base_addr = iobase;
diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig
index cc0006900b30..995dd537083f 100644
--- a/drivers/net/wireless/iwlwifi/Kconfig
+++ b/drivers/net/wireless/iwlwifi/Kconfig
@@ -1,6 +1,5 @@
1config IWLWIFI 1config IWLWIFI
2 bool 2 tristate
3 default n
4 3
5config IWLCORE 4config IWLCORE
6 tristate "Intel Wireless Wifi Core" 5 tristate "Intel Wireless Wifi Core"
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 8464397f7816..9df48b33f0ca 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -666,7 +666,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
666 rx_status.flag = 0; 666 rx_status.flag = 0;
667 rx_status.mactime = le64_to_cpu(rx_end->timestamp); 667 rx_status.mactime = le64_to_cpu(rx_end->timestamp);
668 rx_status.freq = 668 rx_status.freq =
669 ieee80211_frequency_to_channel(le16_to_cpu(rx_hdr->channel)); 669 ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel));
670 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 670 rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
671 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 671 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
672 672
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
index 67356d9a0c59..24dee00b0e85 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c
@@ -168,8 +168,8 @@ struct iwl4965_lq_sta {
168 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; 168 struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file;
169#endif 169#endif
170 u32 dbg_fixed_rate; 170 u32 dbg_fixed_rate;
171 struct iwl_priv *drv;
172#endif 171#endif
172 struct iwl_priv *drv;
173}; 173};
174 174
175static void rs_rate_scale_perform(struct iwl_priv *priv, 175static void rs_rate_scale_perform(struct iwl_priv *priv,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index 9546582e983f..5d675e39bab8 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -3128,7 +3128,7 @@ static void iwl4965_rx_reply_rx(struct iwl_priv *priv,
3128 3128
3129 rx_status.mactime = le64_to_cpu(rx_start->timestamp); 3129 rx_status.mactime = le64_to_cpu(rx_start->timestamp);
3130 rx_status.freq = 3130 rx_status.freq =
3131 ieee80211_frequency_to_channel(le16_to_cpu(rx_start->channel)); 3131 ieee80211_channel_to_frequency(le16_to_cpu(rx_start->channel));
3132 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? 3132 rx_status.band = (rx_start->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ?
3133 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; 3133 IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ;
3134 rx_status.rate_idx = 3134 rx_status.rate_idx =
diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c
index 04c2638d75ad..9196825ed1b5 100644
--- a/drivers/net/wireless/prism54/islpci_dev.c
+++ b/drivers/net/wireless/prism54/islpci_dev.c
@@ -388,8 +388,15 @@ islpci_open(struct net_device *ndev)
388 388
389 netif_start_queue(ndev); 389 netif_start_queue(ndev);
390 390
391 /* Turn off carrier unless we know we have associated */ 391 /* Turn off carrier if in STA or Ad-hoc mode. It will be turned on
392 netif_carrier_off(ndev); 392 * once the firmware receives a trap of being associated
393 * (GEN_OID_LINKSTATE). In other modes (AP or WDS or monitor) we
394 * should just leave the carrier on as its expected the firmware
395 * won't send us a trigger. */
396 if (priv->iw_mode == IW_MODE_INFRA || priv->iw_mode == IW_MODE_ADHOC)
397 netif_carrier_off(ndev);
398 else
399 netif_carrier_on(ndev);
393 400
394 return 0; 401 return 0;
395} 402}
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 9929b15e28ba..61510c519351 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -1028,8 +1028,10 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1028 * Initialize the device. 1028 * Initialize the device.
1029 */ 1029 */
1030 status = rt2x00dev->ops->lib->initialize(rt2x00dev); 1030 status = rt2x00dev->ops->lib->initialize(rt2x00dev);
1031 if (status) 1031 if (status) {
1032 goto exit; 1032 rt2x00queue_uninitialize(rt2x00dev);
1033 return status;
1034 }
1033 1035
1034 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags); 1036 __set_bit(DEVICE_INITIALIZED, &rt2x00dev->flags);
1035 1037
@@ -1039,11 +1041,6 @@ static int rt2x00lib_initialize(struct rt2x00_dev *rt2x00dev)
1039 rt2x00rfkill_register(rt2x00dev); 1041 rt2x00rfkill_register(rt2x00dev);
1040 1042
1041 return 0; 1043 return 0;
1042
1043exit:
1044 rt2x00lib_uninitialize(rt2x00dev);
1045
1046 return status;
1047} 1044}
1048 1045
1049int rt2x00lib_start(struct rt2x00_dev *rt2x00dev) 1046int rt2x00lib_start(struct rt2x00_dev *rt2x00dev)
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c
index 9e5d94e44c5c..c17078eac197 100644
--- a/drivers/net/wireless/rt2x00/rt2x00pci.c
+++ b/drivers/net/wireless/rt2x00/rt2x00pci.c
@@ -314,13 +314,14 @@ int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev)
314 if (status) { 314 if (status) {
315 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n", 315 ERROR(rt2x00dev, "IRQ %d allocation failed (error %d).\n",
316 pci_dev->irq, status); 316 pci_dev->irq, status);
317 return status; 317 goto exit;
318 } 318 }
319 319
320 return 0; 320 return 0;
321 321
322exit: 322exit:
323 rt2x00pci_uninitialize(rt2x00dev); 323 queue_for_each(rt2x00dev, queue)
324 rt2x00pci_free_queue_dma(rt2x00dev, queue);
324 325
325 return status; 326 return status;
326} 327}
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 98af4d26583d..b64f2f5d0d53 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -2362,6 +2362,7 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2362{ 2362{
2363 struct rt2x00_dev *rt2x00dev = hw->priv; 2363 struct rt2x00_dev *rt2x00dev = hw->priv;
2364 struct rt2x00_intf *intf = vif_to_intf(control->vif); 2364 struct rt2x00_intf *intf = vif_to_intf(control->vif);
2365 struct queue_entry_priv_pci_tx *priv_tx;
2365 struct skb_frame_desc *skbdesc; 2366 struct skb_frame_desc *skbdesc;
2366 unsigned int beacon_base; 2367 unsigned int beacon_base;
2367 u32 reg; 2368 u32 reg;
@@ -2369,21 +2370,8 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2369 if (unlikely(!intf->beacon)) 2370 if (unlikely(!intf->beacon))
2370 return -ENOBUFS; 2371 return -ENOBUFS;
2371 2372
2372 /* 2373 priv_tx = intf->beacon->priv_data;
2373 * We need to append the descriptor in front of the 2374 memset(priv_tx->desc, 0, intf->beacon->queue->desc_size);
2374 * beacon frame.
2375 */
2376 if (skb_headroom(skb) < intf->beacon->queue->desc_size) {
2377 if (pskb_expand_head(skb, intf->beacon->queue->desc_size,
2378 0, GFP_ATOMIC))
2379 return -ENOMEM;
2380 }
2381
2382 /*
2383 * Add the descriptor in front of the skb.
2384 */
2385 skb_push(skb, intf->beacon->queue->desc_size);
2386 memset(skb->data, 0, intf->beacon->queue->desc_size);
2387 2375
2388 /* 2376 /*
2389 * Fill in skb descriptor 2377 * Fill in skb descriptor
@@ -2391,9 +2379,9 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2391 skbdesc = get_skb_frame_desc(skb); 2379 skbdesc = get_skb_frame_desc(skb);
2392 memset(skbdesc, 0, sizeof(*skbdesc)); 2380 memset(skbdesc, 0, sizeof(*skbdesc));
2393 skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED; 2381 skbdesc->flags |= FRAME_DESC_DRIVER_GENERATED;
2394 skbdesc->data = skb->data + intf->beacon->queue->desc_size; 2382 skbdesc->data = skb->data;
2395 skbdesc->data_len = skb->len - intf->beacon->queue->desc_size; 2383 skbdesc->data_len = skb->len;
2396 skbdesc->desc = skb->data; 2384 skbdesc->desc = priv_tx->desc;
2397 skbdesc->desc_len = intf->beacon->queue->desc_size; 2385 skbdesc->desc_len = intf->beacon->queue->desc_size;
2398 skbdesc->entry = intf->beacon; 2386 skbdesc->entry = intf->beacon;
2399 2387
@@ -2414,7 +2402,10 @@ static int rt61pci_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb,
2414 rt2x00lib_write_tx_desc(rt2x00dev, skb, control); 2402 rt2x00lib_write_tx_desc(rt2x00dev, skb, control);
2415 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx); 2403 beacon_base = HW_BEACON_OFFSET(intf->beacon->entry_idx);
2416 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base, 2404 rt2x00pci_register_multiwrite(rt2x00dev, beacon_base,
2417 skb->data, skb->len); 2405 skbdesc->desc, skbdesc->desc_len);
2406 rt2x00pci_register_multiwrite(rt2x00dev,
2407 beacon_base + skbdesc->desc_len,
2408 skbdesc->data, skbdesc->data_len);
2418 rt61pci_kick_tx_queue(rt2x00dev, QID_BEACON); 2409 rt61pci_kick_tx_queue(rt2x00dev, QID_BEACON);
2419 2410
2420 return 0; 2411 return 0;
@@ -2479,7 +2470,7 @@ static const struct data_queue_desc rt61pci_queue_tx = {
2479 2470
2480static const struct data_queue_desc rt61pci_queue_bcn = { 2471static const struct data_queue_desc rt61pci_queue_bcn = {
2481 .entry_num = 4 * BEACON_ENTRIES, 2472 .entry_num = 4 * BEACON_ENTRIES,
2482 .data_size = MGMT_FRAME_SIZE, 2473 .data_size = 0, /* No DMA required for beacons */
2483 .desc_size = TXINFO_SIZE, 2474 .desc_size = TXINFO_SIZE,
2484 .priv_size = sizeof(struct queue_entry_priv_pci_tx), 2475 .priv_size = sizeof(struct queue_entry_priv_pci_tx),
2485}; 2476};
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c
index 5dd23c93497d..883af891ebfb 100644
--- a/drivers/net/wireless/strip.c
+++ b/drivers/net/wireless/strip.c
@@ -2611,7 +2611,7 @@ static int strip_open(struct tty_struct *tty)
2611 * We need a write method. 2611 * We need a write method.
2612 */ 2612 */
2613 2613
2614 if (tty->ops->write == NULL) 2614 if (tty->ops->write == NULL || tty->ops->set_termios == NULL)
2615 return -EOPNOTSUPP; 2615 return -EOPNOTSUPP;
2616 2616
2617 /* 2617 /*
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index 03384a43186b..49ae97003952 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -908,9 +908,9 @@ static void wv_psa_show(psa_t * p)
908 p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5], 908 p->psa_call_code[3], p->psa_call_code[4], p->psa_call_code[5],
909 p->psa_call_code[6], p->psa_call_code[7]); 909 p->psa_call_code[6], p->psa_call_code[7]);
910#ifdef DEBUG_SHOW_UNUSED 910#ifdef DEBUG_SHOW_UNUSED
911 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", 911 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n",
912 p->psa_reserved[0], 912 p->psa_reserved[0],
913 p->psa_reserved[1], p->psa_reserved[2], p->psa_reserved[3]); 913 p->psa_reserved[1]);
914#endif /* DEBUG_SHOW_UNUSED */ 914#endif /* DEBUG_SHOW_UNUSED */
915 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); 915 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
916 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); 916 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index baf74015751c..b584c0ecc62d 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -1074,11 +1074,9 @@ wv_psa_show(psa_t * p)
1074 p->psa_call_code[6], 1074 p->psa_call_code[6],
1075 p->psa_call_code[7]); 1075 p->psa_call_code[7]);
1076#ifdef DEBUG_SHOW_UNUSED 1076#ifdef DEBUG_SHOW_UNUSED
1077 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X:%02X:%02X\n", 1077 printk(KERN_DEBUG "psa_reserved[]: %02X:%02X\n",
1078 p->psa_reserved[0], 1078 p->psa_reserved[0],
1079 p->psa_reserved[1], 1079 p->psa_reserved[1]);
1080 p->psa_reserved[2],
1081 p->psa_reserved[3]);
1082#endif /* DEBUG_SHOW_UNUSED */ 1080#endif /* DEBUG_SHOW_UNUSED */
1083 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status); 1081 printk(KERN_DEBUG "psa_conf_status: %d, ", p->psa_conf_status);
1084 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]); 1082 printk("psa_crc: 0x%02x%02x, ", p->psa_crc[0], p->psa_crc[1]);
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 5316074f39f0..12e24f04dddf 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -889,9 +889,13 @@ static void tx_urb_complete(struct urb *urb)
889 } 889 }
890free_urb: 890free_urb:
891 skb = (struct sk_buff *)urb->context; 891 skb = (struct sk_buff *)urb->context;
892 zd_mac_tx_to_dev(skb, urb->status); 892 /*
893 * grab 'usb' pointer before handing off the skb (since
894 * it might be freed by zd_mac_tx_to_dev or mac80211)
895 */
893 cb = (struct zd_tx_skb_control_block *)skb->cb; 896 cb = (struct zd_tx_skb_control_block *)skb->cb;
894 usb = &zd_hw_mac(cb->hw)->chip.usb; 897 usb = &zd_hw_mac(cb->hw)->chip.usb;
898 zd_mac_tx_to_dev(skb, urb->status);
895 free_tx_urb(usb, urb); 899 free_tx_urb(usb, urb);
896 tx_dec_submitted_urbs(usb); 900 tx_dec_submitted_urbs(usb);
897 return; 901 return;
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index efcbf4b4579f..2450b3a393ff 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -27,7 +27,7 @@
27#include "buffer_sync.h" 27#include "buffer_sync.h"
28#include "oprof.h" 28#include "oprof.h"
29 29
30DEFINE_PER_CPU_SHARED_ALIGNED(struct oprofile_cpu_buffer, cpu_buffer); 30DEFINE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
31 31
32static void wq_sync_buffer(struct work_struct *work); 32static void wq_sync_buffer(struct work_struct *work);
33 33
diff --git a/drivers/oprofile/cpu_buffer.h b/drivers/oprofile/cpu_buffer.h
index 13588174311d..c3e366b52261 100644
--- a/drivers/oprofile/cpu_buffer.h
+++ b/drivers/oprofile/cpu_buffer.h
@@ -46,7 +46,7 @@ struct oprofile_cpu_buffer {
46 unsigned long sample_invalid_eip; 46 unsigned long sample_invalid_eip;
47 int cpu; 47 int cpu;
48 struct delayed_work work; 48 struct delayed_work work;
49} ____cacheline_aligned; 49};
50 50
51DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer); 51DECLARE_PER_CPU(struct oprofile_cpu_buffer, cpu_buffer);
52 52
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 1fd8bb765702..66c0fd21894b 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -49,7 +49,7 @@
49 49
50#define DEFAULT_DOMAIN_ADDRESS_WIDTH 48 50#define DEFAULT_DOMAIN_ADDRESS_WIDTH 48
51 51
52#define DMAR_OPERATION_TIMEOUT (HZ*60) /* 1m */ 52#define DMAR_OPERATION_TIMEOUT ((cycles_t) tsc_khz*10*1000) /* 10sec */
53 53
54#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1) 54#define DOMAIN_MAX_ADDR(gaw) ((((u64)1) << gaw) - 1)
55 55
@@ -490,12 +490,12 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
490 490
491#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \ 491#define IOMMU_WAIT_OP(iommu, offset, op, cond, sts) \
492{\ 492{\
493 unsigned long start_time = jiffies;\ 493 cycles_t start_time = get_cycles();\
494 while (1) {\ 494 while (1) {\
495 sts = op (iommu->reg + offset);\ 495 sts = op (iommu->reg + offset);\
496 if (cond)\ 496 if (cond)\
497 break;\ 497 break;\
498 if (time_after(jiffies, start_time + DMAR_OPERATION_TIMEOUT))\ 498 if (DMAR_OPERATION_TIMEOUT < (get_cycles() - start_time))\
499 panic("DMAR hardware is malfunctioning\n");\ 499 panic("DMAR hardware is malfunctioning\n");\
500 cpu_relax();\ 500 cpu_relax();\
501 }\ 501 }\
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 72f7476930c8..9d6fc8e6285d 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -19,8 +19,31 @@
19#include <linux/pci-acpi.h> 19#include <linux/pci-acpi.h>
20#include "pci.h" 20#include "pci.h"
21 21
22static u32 ctrlset_buf[3] = {0, 0, 0}; 22struct acpi_osc_data {
23static u32 global_ctrlsets = 0; 23 acpi_handle handle;
24 u32 ctrlset_buf[3];
25 u32 global_ctrlsets;
26 struct list_head sibiling;
27};
28static LIST_HEAD(acpi_osc_data_list);
29
30static struct acpi_osc_data *acpi_get_osc_data(acpi_handle handle)
31{
32 struct acpi_osc_data *data;
33
34 list_for_each_entry(data, &acpi_osc_data_list, sibiling) {
35 if (data->handle == handle)
36 return data;
37 }
38 data = kzalloc(sizeof(*data), GFP_KERNEL);
39 if (!data)
40 return NULL;
41 INIT_LIST_HEAD(&data->sibiling);
42 data->handle = handle;
43 list_add_tail(&data->sibiling, &acpi_osc_data_list);
44 return data;
45}
46
24static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66}; 47static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
25 48
26static acpi_status 49static acpi_status
@@ -37,8 +60,27 @@ acpi_query_osc (
37 union acpi_object *out_obj; 60 union acpi_object *out_obj;
38 u32 osc_dw0; 61 u32 osc_dw0;
39 acpi_status *ret_status = (acpi_status *)retval; 62 acpi_status *ret_status = (acpi_status *)retval;
63 struct acpi_osc_data *osc_data;
64 u32 flags = (unsigned long)context, temp;
65 acpi_handle tmp;
66
67 status = acpi_get_handle(handle, "_OSC", &tmp);
68 if (ACPI_FAILURE(status))
69 return status;
70
71 osc_data = acpi_get_osc_data(handle);
72 if (!osc_data) {
73 printk(KERN_ERR "acpi osc data array is full\n");
74 return AE_ERROR;
75 }
76
77 osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS);
78
79 /* do _OSC query for all possible controls */
80 temp = osc_data->ctrlset_buf[OSC_CONTROL_TYPE];
81 osc_data->ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
82 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
40 83
41
42 /* Setting up input parameters */ 84 /* Setting up input parameters */
43 input.count = 4; 85 input.count = 4;
44 input.pointer = in_params; 86 input.pointer = in_params;
@@ -51,13 +93,11 @@ acpi_query_osc (
51 in_params[2].integer.value = 3; 93 in_params[2].integer.value = 3;
52 in_params[3].type = ACPI_TYPE_BUFFER; 94 in_params[3].type = ACPI_TYPE_BUFFER;
53 in_params[3].buffer.length = 12; 95 in_params[3].buffer.length = 12;
54 in_params[3].buffer.pointer = (u8 *)context; 96 in_params[3].buffer.pointer = (u8 *)osc_data->ctrlset_buf;
55 97
56 status = acpi_evaluate_object(handle, "_OSC", &input, &output); 98 status = acpi_evaluate_object(handle, "_OSC", &input, &output);
57 if (ACPI_FAILURE (status)) { 99 if (ACPI_FAILURE(status))
58 *ret_status = status; 100 goto out_nofree;
59 return status;
60 }
61 out_obj = output.pointer; 101 out_obj = output.pointer;
62 102
63 if (out_obj->type != ACPI_TYPE_BUFFER) { 103 if (out_obj->type != ACPI_TYPE_BUFFER) {
@@ -76,7 +116,8 @@ acpi_query_osc (
76 printk(KERN_DEBUG "_OSC invalid revision\n"); 116 printk(KERN_DEBUG "_OSC invalid revision\n");
77 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) { 117 if (osc_dw0 & OSC_CAPABILITIES_MASK_ERROR) {
78 /* Update Global Control Set */ 118 /* Update Global Control Set */
79 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer+8)); 119 osc_data->global_ctrlsets =
120 *((u32 *)(out_obj->buffer.pointer + 8));
80 status = AE_OK; 121 status = AE_OK;
81 goto query_osc_out; 122 goto query_osc_out;
82 } 123 }
@@ -85,12 +126,21 @@ acpi_query_osc (
85 } 126 }
86 127
87 /* Update Global Control Set */ 128 /* Update Global Control Set */
88 global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8)); 129 osc_data->global_ctrlsets = *((u32 *)(out_obj->buffer.pointer + 8));
89 status = AE_OK; 130 status = AE_OK;
90 131
91query_osc_out: 132query_osc_out:
92 kfree(output.pointer); 133 kfree(output.pointer);
134out_nofree:
93 *ret_status = status; 135 *ret_status = status;
136
137 osc_data->ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
138 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] = temp;
139 if (ACPI_FAILURE(status)) {
140 /* no osc support at all */
141 osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
142 }
143
94 return status; 144 return status;
95} 145}
96 146
@@ -165,28 +215,15 @@ run_osc_out:
165 **/ 215 **/
166acpi_status __pci_osc_support_set(u32 flags, const char *hid) 216acpi_status __pci_osc_support_set(u32 flags, const char *hid)
167{ 217{
168 u32 temp; 218 acpi_status retval = AE_NOT_FOUND;
169 acpi_status retval;
170 219
171 if (!(flags & OSC_SUPPORT_MASKS)) { 220 if (!(flags & OSC_SUPPORT_MASKS)) {
172 return AE_TYPE; 221 return AE_TYPE;
173 } 222 }
174 ctrlset_buf[OSC_SUPPORT_TYPE] |= (flags & OSC_SUPPORT_MASKS);
175
176 /* do _OSC query for all possible controls */
177 temp = ctrlset_buf[OSC_CONTROL_TYPE];
178 ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
179 ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
180 acpi_get_devices(hid, 223 acpi_get_devices(hid,
181 acpi_query_osc, 224 acpi_query_osc,
182 ctrlset_buf, 225 (void *)(unsigned long)flags,
183 (void **) &retval ); 226 (void **) &retval );
184 ctrlset_buf[OSC_QUERY_TYPE] = !OSC_QUERY_ENABLE;
185 ctrlset_buf[OSC_CONTROL_TYPE] = temp;
186 if (ACPI_FAILURE(retval)) {
187 /* no osc support at all */
188 ctrlset_buf[OSC_SUPPORT_TYPE] = 0;
189 }
190 return AE_OK; 227 return AE_OK;
191} 228}
192 229
@@ -201,19 +238,31 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
201{ 238{
202 acpi_status status; 239 acpi_status status;
203 u32 ctrlset; 240 u32 ctrlset;
241 acpi_handle tmp;
242 struct acpi_osc_data *osc_data;
243
244 status = acpi_get_handle(handle, "_OSC", &tmp);
245 if (ACPI_FAILURE(status))
246 return status;
247
248 osc_data = acpi_get_osc_data(handle);
249 if (!osc_data) {
250 printk(KERN_ERR "acpi osc data array is full\n");
251 return AE_ERROR;
252 }
204 253
205 ctrlset = (flags & OSC_CONTROL_MASKS); 254 ctrlset = (flags & OSC_CONTROL_MASKS);
206 if (!ctrlset) { 255 if (!ctrlset) {
207 return AE_TYPE; 256 return AE_TYPE;
208 } 257 }
209 if (ctrlset_buf[OSC_SUPPORT_TYPE] && 258 if (osc_data->ctrlset_buf[OSC_SUPPORT_TYPE] &&
210 ((global_ctrlsets & ctrlset) != ctrlset)) { 259 ((osc_data->global_ctrlsets & ctrlset) != ctrlset)) {
211 return AE_SUPPORT; 260 return AE_SUPPORT;
212 } 261 }
213 ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; 262 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset;
214 status = acpi_run_osc(handle, ctrlset_buf); 263 status = acpi_run_osc(handle, osc_data->ctrlset_buf);
215 if (ACPI_FAILURE (status)) { 264 if (ACPI_FAILURE (status)) {
216 ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; 265 osc_data->ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset;
217 } 266 }
218 267
219 return status; 268 return status;
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 4a55bf380957..3706ce7972dd 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -842,13 +842,25 @@ static void set_pcie_port_type(struct pci_dev *pdev)
842 * reading the dword at 0x100 which must either be 0 or a valid extended 842 * reading the dword at 0x100 which must either be 0 or a valid extended
843 * capability header. 843 * capability header.
844 */ 844 */
845int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix) 845int pci_cfg_space_size_ext(struct pci_dev *dev)
846{ 846{
847 int pos;
848 u32 status; 847 u32 status;
849 848
850 if (!check_exp_pcix) 849 if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
851 goto skip; 850 goto fail;
851 if (status == 0xffffffff)
852 goto fail;
853
854 return PCI_CFG_SPACE_EXP_SIZE;
855
856 fail:
857 return PCI_CFG_SPACE_SIZE;
858}
859
860int pci_cfg_space_size(struct pci_dev *dev)
861{
862 int pos;
863 u32 status;
852 864
853 pos = pci_find_capability(dev, PCI_CAP_ID_EXP); 865 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
854 if (!pos) { 866 if (!pos) {
@@ -861,23 +873,12 @@ int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix)
861 goto fail; 873 goto fail;
862 } 874 }
863 875
864 skip: 876 return pci_cfg_space_size_ext(dev);
865 if (pci_read_config_dword(dev, 256, &status) != PCIBIOS_SUCCESSFUL)
866 goto fail;
867 if (status == 0xffffffff)
868 goto fail;
869
870 return PCI_CFG_SPACE_EXP_SIZE;
871 877
872 fail: 878 fail:
873 return PCI_CFG_SPACE_SIZE; 879 return PCI_CFG_SPACE_SIZE;
874} 880}
875 881
876int pci_cfg_space_size(struct pci_dev *dev)
877{
878 return pci_cfg_space_size_ext(dev, 1);
879}
880
881static void pci_release_bus_bridge_dev(struct device *dev) 882static void pci_release_bus_bridge_dev(struct device *dev)
882{ 883{
883 kfree(dev); 884 kfree(dev);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index afd914ebe215..f2d9c770f51a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1826,6 +1826,7 @@ static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
1826 } 1826 }
1827} 1827}
1828DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk); 1828DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, nv_msi_ht_cap_quirk);
1829DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL, PCI_ANY_ID, nv_msi_ht_cap_quirk);
1829 1830
1830static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev) 1831static void __devinit quirk_msi_intx_disable_bug(struct pci_dev *dev)
1831{ 1832{
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 4fe7c58f57e9..886dac823ed6 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -19,6 +19,7 @@ void pnp_remove_card(struct pnp_card *card);
19int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev); 19int pnp_add_card_device(struct pnp_card *card, struct pnp_dev *dev);
20void pnp_remove_card_device(struct pnp_dev *dev); 20void pnp_remove_card_device(struct pnp_dev *dev);
21 21
22struct pnp_option *pnp_build_option(int priority);
22struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev); 23struct pnp_option *pnp_register_independent_option(struct pnp_dev *dev);
23struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev, 24struct pnp_option *pnp_register_dependent_option(struct pnp_dev *dev,
24 int priority); 25 int priority);
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index 5d9301de1778..5695a79f3a52 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -424,7 +424,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
424 start = simple_strtoul(buf, &buf, 0); 424 start = simple_strtoul(buf, &buf, 0);
425 pnp_res = pnp_add_irq_resource(dev, start, 0); 425 pnp_res = pnp_add_irq_resource(dev, start, 0);
426 if (pnp_res) 426 if (pnp_res)
427 nirq++; 427 pnp_res->index = nirq++;
428 continue; 428 continue;
429 } 429 }
430 if (!strnicmp(buf, "dma", 3)) { 430 if (!strnicmp(buf, "dma", 3)) {
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
index d049a2279fea..ffdb12a59c40 100644
--- a/drivers/pnp/quirks.c
+++ b/drivers/pnp/quirks.c
@@ -111,6 +111,113 @@ static void quirk_sb16audio_resources(struct pnp_dev *dev)
111 dev_info(&dev->dev, "SB audio device quirk - increased port range\n"); 111 dev_info(&dev->dev, "SB audio device quirk - increased port range\n");
112} 112}
113 113
114static struct pnp_option *quirk_isapnp_mpu_options(struct pnp_dev *dev)
115{
116 struct pnp_option *head = NULL;
117 struct pnp_option *prev = NULL;
118 struct pnp_option *res;
119
120 /*
121 * Build a functional IRQ-less variant of each MPU option.
122 */
123
124 for (res = dev->dependent; res; res = res->next) {
125 struct pnp_option *curr;
126 struct pnp_port *port;
127 struct pnp_port *copy;
128
129 port = res->port;
130 if (!port || !res->irq)
131 continue;
132
133 copy = pnp_alloc(sizeof *copy);
134 if (!copy)
135 break;
136
137 copy->min = port->min;
138 copy->max = port->max;
139 copy->align = port->align;
140 copy->size = port->size;
141 copy->flags = port->flags;
142
143 curr = pnp_build_option(PNP_RES_PRIORITY_FUNCTIONAL);
144 if (!curr) {
145 kfree(copy);
146 break;
147 }
148 curr->port = copy;
149
150 if (prev)
151 prev->next = curr;
152 else
153 head = curr;
154 prev = curr;
155 }
156 if (head)
157 dev_info(&dev->dev, "adding IRQ-less MPU options\n");
158
159 return head;
160}
161
162static void quirk_ad1815_mpu_resources(struct pnp_dev *dev)
163{
164 struct pnp_option *res;
165 struct pnp_irq *irq;
166
167 /*
168 * Distribute the independent IRQ over the dependent options
169 */
170
171 res = dev->independent;
172 if (!res)
173 return;
174
175 irq = res->irq;
176 if (!irq || irq->next)
177 return;
178
179 res = dev->dependent;
180 if (!res)
181 return;
182
183 while (1) {
184 struct pnp_irq *copy;
185
186 copy = pnp_alloc(sizeof *copy);
187 if (!copy)
188 break;
189
190 memcpy(copy->map, irq->map, sizeof copy->map);
191 copy->flags = irq->flags;
192
193 copy->next = res->irq; /* Yes, this is NULL */
194 res->irq = copy;
195
196 if (!res->next)
197 break;
198 res = res->next;
199 }
200 kfree(irq);
201
202 res->next = quirk_isapnp_mpu_options(dev);
203
204 res = dev->independent;
205 res->irq = NULL;
206}
207
208static void quirk_isapnp_mpu_resources(struct pnp_dev *dev)
209{
210 struct pnp_option *res;
211
212 res = dev->dependent;
213 if (!res)
214 return;
215
216 while (res->next)
217 res = res->next;
218
219 res->next = quirk_isapnp_mpu_options(dev);
220}
114 221
115#include <linux/pci.h> 222#include <linux/pci.h>
116 223
@@ -205,6 +312,11 @@ static struct pnp_fixup pnp_fixups[] = {
205 {"CTL0043", quirk_sb16audio_resources}, 312 {"CTL0043", quirk_sb16audio_resources},
206 {"CTL0044", quirk_sb16audio_resources}, 313 {"CTL0044", quirk_sb16audio_resources},
207 {"CTL0045", quirk_sb16audio_resources}, 314 {"CTL0045", quirk_sb16audio_resources},
315 /* Add IRQ-less MPU options */
316 {"ADS7151", quirk_ad1815_mpu_resources},
317 {"ADS7181", quirk_isapnp_mpu_resources},
318 {"AZT0002", quirk_isapnp_mpu_resources},
319 /* PnP resources that might overlap PCI BARs */
208 {"PNP0c01", quirk_system_pci_resources}, 320 {"PNP0c01", quirk_system_pci_resources},
209 {"PNP0c02", quirk_system_pci_resources}, 321 {"PNP0c02", quirk_system_pci_resources},
210 {""} 322 {""}
@@ -212,20 +324,16 @@ static struct pnp_fixup pnp_fixups[] = {
212 324
213void pnp_fixup_device(struct pnp_dev *dev) 325void pnp_fixup_device(struct pnp_dev *dev)
214{ 326{
215 int i = 0; 327 struct pnp_fixup *f;
216 void (*quirk)(struct pnp_dev *);
217
218 while (*pnp_fixups[i].id) {
219 if (compare_pnp_id(dev->id, pnp_fixups[i].id)) {
220 quirk = pnp_fixups[i].quirk_function;
221 328
329 for (f = pnp_fixups; *f->id; f++) {
330 if (!compare_pnp_id(dev->id, f->id))
331 continue;
222#ifdef DEBUG 332#ifdef DEBUG
223 dev_dbg(&dev->dev, "calling "); 333 dev_dbg(&dev->dev, "%s: calling ", f->id);
224 print_fn_descriptor_symbol("%s()\n", 334 print_fn_descriptor_symbol("%s\n",
225 (unsigned long) *quirk); 335 (unsigned long) f->quirk_function);
226#endif 336#endif
227 (*quirk)(dev); 337 f->quirk_function(dev);
228 }
229 i++;
230 } 338 }
231} 339}
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 2041620d5682..390b50096e30 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -28,7 +28,7 @@ static int pnp_reserve_mem[16] = {[0 ... 15] = -1 }; /* reserve (don't use) some
28 * option registration 28 * option registration
29 */ 29 */
30 30
31static struct pnp_option *pnp_build_option(int priority) 31struct pnp_option *pnp_build_option(int priority)
32{ 32{
33 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option)); 33 struct pnp_option *option = pnp_alloc(sizeof(struct pnp_option));
34 34
diff --git a/drivers/pnp/support.c b/drivers/pnp/support.c
index 3eba85ed729c..95b076c18c07 100644
--- a/drivers/pnp/support.c
+++ b/drivers/pnp/support.c
@@ -45,10 +45,10 @@ void pnp_eisa_id_to_string(u32 id, char *str)
45 str[0] = 'A' + ((id >> 26) & 0x3f) - 1; 45 str[0] = 'A' + ((id >> 26) & 0x3f) - 1;
46 str[1] = 'A' + ((id >> 21) & 0x1f) - 1; 46 str[1] = 'A' + ((id >> 21) & 0x1f) - 1;
47 str[2] = 'A' + ((id >> 16) & 0x1f) - 1; 47 str[2] = 'A' + ((id >> 16) & 0x1f) - 1;
48 str[3] = hex_asc((id >> 12) & 0xf); 48 str[3] = hex_asc_hi(id >> 8);
49 str[4] = hex_asc((id >> 8) & 0xf); 49 str[4] = hex_asc_lo(id >> 8);
50 str[5] = hex_asc((id >> 4) & 0xf); 50 str[5] = hex_asc_hi(id);
51 str[6] = hex_asc((id >> 0) & 0xf); 51 str[6] = hex_asc_lo(id);
52 str[7] = '\0'; 52 str[7] = '\0';
53} 53}
54 54
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c
index a83a40b3ebaa..0f0d27d1c4ca 100644
--- a/drivers/rtc/rtc-ds1511.c
+++ b/drivers/rtc/rtc-ds1511.c
@@ -184,7 +184,7 @@ ds1511_wdog_disable(void)
184static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) 184static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
185{ 185{
186 u8 mon, day, dow, hrs, min, sec, yrs, cen; 186 u8 mon, day, dow, hrs, min, sec, yrs, cen;
187 unsigned int flags; 187 unsigned long flags;
188 188
189 /* 189 /*
190 * won't have to change this for a while 190 * won't have to change this for a while
@@ -247,7 +247,7 @@ static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm)
247static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm) 247static int ds1511_rtc_read_time(struct device *dev, struct rtc_time *rtc_tm)
248{ 248{
249 unsigned int century; 249 unsigned int century;
250 unsigned int flags; 250 unsigned long flags;
251 251
252 spin_lock_irqsave(&ds1511_lock, flags); 252 spin_lock_irqsave(&ds1511_lock, flags);
253 rtc_disable_update(); 253 rtc_disable_update();
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c
index ba795a4db1e9..9f996ec881ce 100644
--- a/drivers/rtc/rtc-lib.c
+++ b/drivers/rtc/rtc-lib.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(rtc_year_days);
51 */ 51 */
52void rtc_time_to_tm(unsigned long time, struct rtc_time *tm) 52void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
53{ 53{
54 register int days, month, year; 54 unsigned int days, month, year;
55 55
56 days = time / 86400; 56 days = time / 86400;
57 time -= days * 86400; 57 time -= days * 86400;
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 316bfaa80872..a3e0880b38fb 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/kernel.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
20#include <linux/i2c.h> 21#include <linux/i2c.h>
@@ -803,6 +804,7 @@ static int m41t80_probe(struct i2c_client *client,
803 804
804#ifdef CONFIG_RTC_DRV_M41T80_WDT 805#ifdef CONFIG_RTC_DRV_M41T80_WDT
805 if (clientdata->features & M41T80_FEATURE_HT) { 806 if (clientdata->features & M41T80_FEATURE_HT) {
807 save_client = client;
806 rc = misc_register(&wdt_dev); 808 rc = misc_register(&wdt_dev);
807 if (rc) 809 if (rc)
808 goto exit; 810 goto exit;
@@ -811,7 +813,6 @@ static int m41t80_probe(struct i2c_client *client,
811 misc_deregister(&wdt_dev); 813 misc_deregister(&wdt_dev);
812 goto exit; 814 goto exit;
813 } 815 }
814 save_client = client;
815 } 816 }
816#endif 817#endif
817 return 0; 818 return 0;
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c
index 29f47bacfc77..a6fa1f2f2ca6 100644
--- a/drivers/rtc/rtc-s35390a.c
+++ b/drivers/rtc/rtc-s35390a.c
@@ -227,7 +227,7 @@ static int s35390a_probe(struct i2c_client *client,
227 /* This chip uses multiple addresses, use dummy devices for them */ 227 /* This chip uses multiple addresses, use dummy devices for them */
228 for (i = 1; i < 8; ++i) { 228 for (i = 1; i < 8; ++i) {
229 s35390a->client[i] = i2c_new_dummy(client->adapter, 229 s35390a->client[i] = i2c_new_dummy(client->adapter,
230 client->addr + i, "rtc-s35390a"); 230 client->addr + i);
231 if (!s35390a->client[i]) { 231 if (!s35390a->client[i]) {
232 dev_err(&client->dev, "Address %02x unavailable\n", 232 dev_err(&client->dev, "Address %02x unavailable\n",
233 client->addr + i); 233 client->addr + i);
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
index 110699bb4787..1f88e9e914ec 100644
--- a/drivers/rtc/rtc-sh.c
+++ b/drivers/rtc/rtc-sh.c
@@ -616,7 +616,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
616 goto err_badres; 616 goto err_badres;
617 } 617 }
618 618
619 rtc->regbase = (void __iomem *)rtc->res->start; 619 rtc->regbase = ioremap_nocache(rtc->res->start, rtc->regsize);
620 if (unlikely(!rtc->regbase)) { 620 if (unlikely(!rtc->regbase)) {
621 ret = -EINVAL; 621 ret = -EINVAL;
622 goto err_badmap; 622 goto err_badmap;
@@ -626,7 +626,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
626 &sh_rtc_ops, THIS_MODULE); 626 &sh_rtc_ops, THIS_MODULE);
627 if (IS_ERR(rtc->rtc_dev)) { 627 if (IS_ERR(rtc->rtc_dev)) {
628 ret = PTR_ERR(rtc->rtc_dev); 628 ret = PTR_ERR(rtc->rtc_dev);
629 goto err_badmap; 629 goto err_unmap;
630 } 630 }
631 631
632 rtc->capabilities = RTC_DEF_CAPABILITIES; 632 rtc->capabilities = RTC_DEF_CAPABILITIES;
@@ -653,7 +653,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
653 dev_err(&pdev->dev, 653 dev_err(&pdev->dev,
654 "request period IRQ failed with %d, IRQ %d\n", ret, 654 "request period IRQ failed with %d, IRQ %d\n", ret,
655 rtc->periodic_irq); 655 rtc->periodic_irq);
656 goto err_badmap; 656 goto err_unmap;
657 } 657 }
658 658
659 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED, 659 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, IRQF_DISABLED,
@@ -663,7 +663,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
663 "request carry IRQ failed with %d, IRQ %d\n", ret, 663 "request carry IRQ failed with %d, IRQ %d\n", ret,
664 rtc->carry_irq); 664 rtc->carry_irq);
665 free_irq(rtc->periodic_irq, rtc); 665 free_irq(rtc->periodic_irq, rtc);
666 goto err_badmap; 666 goto err_unmap;
667 } 667 }
668 668
669 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED, 669 ret = request_irq(rtc->alarm_irq, sh_rtc_alarm, IRQF_DISABLED,
@@ -674,7 +674,7 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
674 rtc->alarm_irq); 674 rtc->alarm_irq);
675 free_irq(rtc->carry_irq, rtc); 675 free_irq(rtc->carry_irq, rtc);
676 free_irq(rtc->periodic_irq, rtc); 676 free_irq(rtc->periodic_irq, rtc);
677 goto err_badmap; 677 goto err_unmap;
678 } 678 }
679 679
680 tmp = readb(rtc->regbase + RCR1); 680 tmp = readb(rtc->regbase + RCR1);
@@ -684,6 +684,8 @@ static int __devinit sh_rtc_probe(struct platform_device *pdev)
684 684
685 return 0; 685 return 0;
686 686
687err_unmap:
688 iounmap(rtc->regbase);
687err_badmap: 689err_badmap:
688 release_resource(rtc->res); 690 release_resource(rtc->res);
689err_badres: 691err_badres:
@@ -708,6 +710,8 @@ static int __devexit sh_rtc_remove(struct platform_device *pdev)
708 710
709 release_resource(rtc->res); 711 release_resource(rtc->res);
710 712
713 iounmap(rtc->regbase);
714
711 platform_set_drvdata(pdev, NULL); 715 platform_set_drvdata(pdev, NULL);
712 716
713 kfree(rtc); 717 kfree(rtc);
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index c1f2adefad41..5043150019ac 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -965,8 +965,7 @@ tty3270_write_room(struct tty_struct *tty)
965 * Insert character into the screen at the current position with the 965 * Insert character into the screen at the current position with the
966 * current color and highlight. This function does NOT do cursor movement. 966 * current color and highlight. This function does NOT do cursor movement.
967 */ 967 */
968static int 968static void tty3270_put_character(struct tty3270 *tp, char ch)
969tty3270_put_character(struct tty3270 *tp, char ch)
970{ 969{
971 struct tty3270_line *line; 970 struct tty3270_line *line;
972 struct tty3270_cell *cell; 971 struct tty3270_cell *cell;
@@ -986,7 +985,6 @@ tty3270_put_character(struct tty3270 *tp, char ch)
986 cell->character = tp->view.ascebc[(unsigned int) ch]; 985 cell->character = tp->view.ascebc[(unsigned int) ch];
987 cell->highlight = tp->highlight; 986 cell->highlight = tp->highlight;
988 cell->f_color = tp->f_color; 987 cell->f_color = tp->f_color;
989 return 1;
990} 988}
991 989
992/* 990/*
@@ -1612,16 +1610,15 @@ tty3270_write(struct tty_struct * tty,
1612/* 1610/*
1613 * Put single characters to the ttys character buffer 1611 * Put single characters to the ttys character buffer
1614 */ 1612 */
1615static void 1613static int tty3270_put_char(struct tty_struct *tty, unsigned char ch)
1616tty3270_put_char(struct tty_struct *tty, unsigned char ch)
1617{ 1614{
1618 struct tty3270 *tp; 1615 struct tty3270 *tp;
1619 1616
1620 tp = tty->driver_data; 1617 tp = tty->driver_data;
1621 if (!tp) 1618 if (!tp || tp->char_count >= TTY3270_CHAR_BUF_SIZE)
1622 return; 1619 return 0;
1623 if (tp->char_count < TTY3270_CHAR_BUF_SIZE) 1620 tp->char_buf[tp->char_count++] = ch;
1624 tp->char_buf[tp->char_count++] = ch; 1621 return 1;
1625} 1622}
1626 1623
1627/* 1624/*
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index 40ef948fcb3a..9c21b8f43f9b 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -19,6 +19,7 @@
19 19
20#include <asm/cio.h> 20#include <asm/cio.h>
21#include <asm/uaccess.h> 21#include <asm/uaccess.h>
22#include <asm/cio.h>
22 23
23#include "blacklist.h" 24#include "blacklist.h"
24#include "cio.h" 25#include "cio.h"
@@ -43,164 +44,169 @@ typedef enum {add, free} range_action;
43 * Function: blacklist_range 44 * Function: blacklist_range
44 * (Un-)blacklist the devices from-to 45 * (Un-)blacklist the devices from-to
45 */ 46 */
46static void 47static int blacklist_range(range_action action, unsigned int from_ssid,
47blacklist_range (range_action action, unsigned int from, unsigned int to, 48 unsigned int to_ssid, unsigned int from,
48 unsigned int ssid) 49 unsigned int to, int msgtrigger)
49{ 50{
50 if (!to) 51 if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) {
51 to = from; 52 if (msgtrigger)
52 53 printk(KERN_WARNING "cio: Invalid cio_ignore range "
53 if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID) { 54 "0.%x.%04x-0.%x.%04x\n", from_ssid, from,
54 printk (KERN_WARNING "cio: Invalid blacklist range " 55 to_ssid, to);
55 "0.%x.%04x to 0.%x.%04x, skipping\n", 56 return 1;
56 ssid, from, ssid, to);
57 return;
58 } 57 }
59 for (; from <= to; from++) { 58
59 while ((from_ssid < to_ssid) || ((from_ssid == to_ssid) &&
60 (from <= to))) {
60 if (action == add) 61 if (action == add)
61 set_bit (from, bl_dev[ssid]); 62 set_bit(from, bl_dev[from_ssid]);
62 else 63 else
63 clear_bit (from, bl_dev[ssid]); 64 clear_bit(from, bl_dev[from_ssid]);
65 from++;
66 if (from > __MAX_SUBCHANNEL) {
67 from_ssid++;
68 from = 0;
69 }
64 } 70 }
71
72 return 0;
65} 73}
66 74
67/* 75static int pure_hex(char **cp, unsigned int *val, int min_digit,
68 * Function: blacklist_busid 76 int max_digit, int max_val)
69 * Get devno/busid from given string.
70 * Shamelessly grabbed from dasd_devmap.c.
71 */
72static int
73blacklist_busid(char **str, int *id0, int *ssid, int *devno)
74{ 77{
75 int val, old_style; 78 int diff;
76 char *sav; 79 unsigned int value;
77 80
78 sav = *str; 81 diff = 0;
82 *val = 0;
79 83
80 /* check for leading '0x' */ 84 while (isxdigit(**cp) && (diff <= max_digit)) {
81 old_style = 0; 85
82 if ((*str)[0] == '0' && (*str)[1] == 'x') { 86 if (isdigit(**cp))
83 *str += 2; 87 value = **cp - '0';
84 old_style = 1; 88 else
85 } 89 value = tolower(**cp) - 'a' + 10;
86 if (!isxdigit((*str)[0])) /* We require at least one hex digit */ 90 *val = *val * 16 + value;
87 goto confused; 91 (*cp)++;
88 val = simple_strtoul(*str, str, 16); 92 diff++;
89 if (old_style || (*str)[0] != '.') {
90 *id0 = *ssid = 0;
91 if (val < 0 || val > 0xffff)
92 goto confused;
93 *devno = val;
94 if ((*str)[0] != ',' && (*str)[0] != '-' &&
95 (*str)[0] != '\n' && (*str)[0] != '\0')
96 goto confused;
97 return 0;
98 } 93 }
99 /* New style x.y.z busid */ 94
100 if (val < 0 || val > 0xff) 95 if ((diff < min_digit) || (diff > max_digit) || (*val > max_val))
101 goto confused; 96 return 1;
102 *id0 = val; 97
103 (*str)++;
104 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
105 goto confused;
106 val = simple_strtoul(*str, str, 16);
107 if (val < 0 || val > 0xff || (*str)++[0] != '.')
108 goto confused;
109 *ssid = val;
110 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
111 goto confused;
112 val = simple_strtoul(*str, str, 16);
113 if (val < 0 || val > 0xffff)
114 goto confused;
115 *devno = val;
116 if ((*str)[0] != ',' && (*str)[0] != '-' &&
117 (*str)[0] != '\n' && (*str)[0] != '\0')
118 goto confused;
119 return 0; 98 return 0;
120confused:
121 strsep(str, ",\n");
122 printk(KERN_WARNING "cio: Invalid cio_ignore parameter '%s'\n", sav);
123 return 1;
124} 99}
125 100
126static int 101static int parse_busid(char *str, int *cssid, int *ssid, int *devno,
127blacklist_parse_parameters (char *str, range_action action) 102 int msgtrigger)
128{ 103{
129 int from, to, from_id0, to_id0, from_ssid, to_ssid; 104 char *str_work;
130 105 int val, rc, ret;
131 while (*str != 0 && *str != '\n') { 106
132 range_action ra = action; 107 rc = 1;
133 while(*str == ',') 108
134 str++; 109 if (*str == '\0')
135 if (*str == '!') { 110 goto out;
136 ra = !action; 111
137 ++str; 112 /* old style */
113 str_work = str;
114 val = simple_strtoul(str, &str_work, 16);
115
116 if (*str_work == '\0') {
117 if (val <= __MAX_SUBCHANNEL) {
118 *devno = val;
119 *ssid = 0;
120 *cssid = 0;
121 rc = 0;
138 } 122 }
123 goto out;
124 }
139 125
140 /* 126 /* new style */
141 * Since we have to parse the proc commands and the 127 str_work = str;
142 * kernel arguments we have to check four cases 128 ret = pure_hex(&str_work, cssid, 1, 2, __MAX_CSSID);
143 */ 129 if (ret || (str_work[0] != '.'))
144 if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 || 130 goto out;
145 strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) { 131 str_work++;
146 int j; 132 ret = pure_hex(&str_work, ssid, 1, 1, __MAX_SSID);
147 133 if (ret || (str_work[0] != '.'))
148 str += 3; 134 goto out;
149 for (j=0; j <= __MAX_SSID; j++) 135 str_work++;
150 blacklist_range(ra, 0, __MAX_SUBCHANNEL, j); 136 ret = pure_hex(&str_work, devno, 4, 4, __MAX_SUBCHANNEL);
151 } else { 137 if (ret || (str_work[0] != '\0'))
152 int rc; 138 goto out;
139
140 rc = 0;
141out:
142 if (rc && msgtrigger)
143 printk(KERN_WARNING "cio: Invalid cio_ignore device '%s'\n",
144 str);
145
146 return rc;
147}
153 148
154 rc = blacklist_busid(&str, &from_id0, 149static int blacklist_parse_parameters(char *str, range_action action,
155 &from_ssid, &from); 150 int msgtrigger)
156 if (rc) 151{
157 continue; 152 int from_cssid, to_cssid, from_ssid, to_ssid, from, to;
158 to = from; 153 int rc, totalrc;
159 to_id0 = from_id0; 154 char *parm;
160 to_ssid = from_ssid; 155 range_action ra;
161 if (*str == '-') { 156
162 str++; 157 totalrc = 0;
163 rc = blacklist_busid(&str, &to_id0, 158
164 &to_ssid, &to); 159 while ((parm = strsep(&str, ","))) {
165 if (rc) 160 rc = 0;
166 continue; 161 ra = action;
167 } 162 if (*parm == '!') {
168 if (*str == '-') { 163 if (ra == add)
169 printk(KERN_WARNING "cio: invalid cio_ignore " 164 ra = free;
170 "parameter '%s'\n", 165 else
171 strsep(&str, ",\n")); 166 ra = add;
172 continue; 167 parm++;
173 } 168 }
174 if ((from_id0 != to_id0) || 169 if (strcmp(parm, "all") == 0) {
175 (from_ssid != to_ssid)) { 170 from_cssid = 0;
176 printk(KERN_WARNING "cio: invalid cio_ignore " 171 from_ssid = 0;
177 "range %x.%x.%04x-%x.%x.%04x\n", 172 from = 0;
178 from_id0, from_ssid, from, 173 to_cssid = __MAX_CSSID;
179 to_id0, to_ssid, to); 174 to_ssid = __MAX_SSID;
180 continue; 175 to = __MAX_SUBCHANNEL;
176 } else {
177 rc = parse_busid(strsep(&parm, "-"), &from_cssid,
178 &from_ssid, &from, msgtrigger);
179 if (!rc) {
180 if (parm != NULL)
181 rc = parse_busid(parm, &to_cssid,
182 &to_ssid, &to,
183 msgtrigger);
184 else {
185 to_cssid = from_cssid;
186 to_ssid = from_ssid;
187 to = from;
188 }
181 } 189 }
182 blacklist_range (ra, from, to, to_ssid);
183 } 190 }
191 if (!rc) {
192 rc = blacklist_range(ra, from_ssid, to_ssid, from, to,
193 msgtrigger);
194 if (rc)
195 totalrc = 1;
196 } else
197 totalrc = 1;
184 } 198 }
185 return 1; 199
200 return totalrc;
186} 201}
187 202
188/* Parsing the commandline for blacklist parameters, e.g. to blacklist
189 * bus ids 0.0.1234, 0.0.1235 and 0.0.1236, you could use any of:
190 * - cio_ignore=1234-1236
191 * - cio_ignore=0x1234-0x1235,1236
192 * - cio_ignore=0x1234,1235-1236
193 * - cio_ignore=1236 cio_ignore=1234-0x1236
194 * - cio_ignore=1234 cio_ignore=1236 cio_ignore=0x1235
195 * - cio_ignore=0.0.1234-0.0.1236
196 * - cio_ignore=0.0.1234,0x1235,1236
197 * - ...
198 */
199static int __init 203static int __init
200blacklist_setup (char *str) 204blacklist_setup (char *str)
201{ 205{
202 CIO_MSG_EVENT(6, "Reading blacklist parameters\n"); 206 CIO_MSG_EVENT(6, "Reading blacklist parameters\n");
203 return blacklist_parse_parameters (str, add); 207 if (blacklist_parse_parameters(str, add, 1))
208 return 0;
209 return 1;
204} 210}
205 211
206__setup ("cio_ignore=", blacklist_setup); 212__setup ("cio_ignore=", blacklist_setup);
@@ -224,27 +230,23 @@ is_blacklisted (int ssid, int devno)
224 * Function: blacklist_parse_proc_parameters 230 * Function: blacklist_parse_proc_parameters
225 * parse the stuff which is piped to /proc/cio_ignore 231 * parse the stuff which is piped to /proc/cio_ignore
226 */ 232 */
227static void 233static int blacklist_parse_proc_parameters(char *buf)
228blacklist_parse_proc_parameters (char *buf)
229{ 234{
230 if (strncmp (buf, "free ", 5) == 0) { 235 int rc;
231 blacklist_parse_parameters (buf + 5, free); 236 char *parm;
232 } else if (strncmp (buf, "add ", 4) == 0) { 237
233 /* 238 parm = strsep(&buf, " ");
234 * We don't need to check for known devices since 239
235 * css_probe_device will handle this correctly. 240 if (strcmp("free", parm) == 0)
236 */ 241 rc = blacklist_parse_parameters(buf, free, 0);
237 blacklist_parse_parameters (buf + 4, add); 242 else if (strcmp("add", parm) == 0)
238 } else { 243 rc = blacklist_parse_parameters(buf, add, 0);
239 printk (KERN_WARNING "cio: cio_ignore: Parse error; \n" 244 else
240 KERN_WARNING "try using 'free all|<devno-range>," 245 return 1;
241 "<devno-range>,...'\n"
242 KERN_WARNING "or 'add <devno-range>,"
243 "<devno-range>,...'\n");
244 return;
245 }
246 246
247 css_schedule_reprobe(); 247 css_schedule_reprobe();
248
249 return rc;
248} 250}
249 251
250/* Iterator struct for all devices. */ 252/* Iterator struct for all devices. */
@@ -328,6 +330,8 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
328 size_t user_len, loff_t *offset) 330 size_t user_len, loff_t *offset)
329{ 331{
330 char *buf; 332 char *buf;
333 size_t i;
334 ssize_t rc, ret;
331 335
332 if (*offset) 336 if (*offset)
333 return -EINVAL; 337 return -EINVAL;
@@ -336,16 +340,27 @@ cio_ignore_write(struct file *file, const char __user *user_buf,
336 buf = vmalloc (user_len + 1); /* maybe better use the stack? */ 340 buf = vmalloc (user_len + 1); /* maybe better use the stack? */
337 if (buf == NULL) 341 if (buf == NULL)
338 return -ENOMEM; 342 return -ENOMEM;
343 memset(buf, 0, user_len + 1);
344
339 if (strncpy_from_user (buf, user_buf, user_len) < 0) { 345 if (strncpy_from_user (buf, user_buf, user_len) < 0) {
340 vfree (buf); 346 rc = -EFAULT;
341 return -EFAULT; 347 goto out_free;
342 } 348 }
343 buf[user_len] = '\0';
344 349
345 blacklist_parse_proc_parameters (buf); 350 i = user_len - 1;
351 while ((i >= 0) && (isspace(buf[i]) || (buf[i] == 0))) {
352 buf[i] = '\0';
353 i--;
354 }
355 ret = blacklist_parse_proc_parameters(buf);
356 if (ret)
357 rc = -EINVAL;
358 else
359 rc = user_len;
346 360
361out_free:
347 vfree (buf); 362 vfree (buf);
348 return user_len; 363 return rc;
349} 364}
350 365
351static const struct seq_operations cio_ignore_proc_seq_ops = { 366static const struct seq_operations cio_ignore_proc_seq_ops = {
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 08a578161306..82c6a2d45128 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -39,23 +39,6 @@ debug_info_t *cio_debug_msg_id;
39debug_info_t *cio_debug_trace_id; 39debug_info_t *cio_debug_trace_id;
40debug_info_t *cio_debug_crw_id; 40debug_info_t *cio_debug_crw_id;
41 41
42int cio_show_msg;
43
44static int __init
45cio_setup (char *parm)
46{
47 if (!strcmp (parm, "yes"))
48 cio_show_msg = 1;
49 else if (!strcmp (parm, "no"))
50 cio_show_msg = 0;
51 else
52 printk(KERN_ERR "cio: cio_setup: "
53 "invalid cio_msg parameter '%s'", parm);
54 return 1;
55}
56
57__setup ("cio_msg=", cio_setup);
58
59/* 42/*
60 * Function: cio_debug_init 43 * Function: cio_debug_init
61 * Initializes three debug logs for common I/O: 44 * Initializes three debug logs for common I/O:
@@ -166,7 +149,7 @@ cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
166 149
167 stsch (sch->schid, &sch->schib); 150 stsch (sch->schid, &sch->schib);
168 151
169 CIO_MSG_EVENT(0, "cio_start: 'not oper' status for " 152 CIO_MSG_EVENT(2, "cio_start: 'not oper' status for "
170 "subchannel 0.%x.%04x!\n", sch->schid.ssid, 153 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
171 sch->schid.sch_no); 154 sch->schid.sch_no);
172 sprintf(dbf_text, "no%s", sch->dev.bus_id); 155 sprintf(dbf_text, "no%s", sch->dev.bus_id);
@@ -567,10 +550,9 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
567 * ... just being curious we check for non I/O subchannels 550 * ... just being curious we check for non I/O subchannels
568 */ 551 */
569 if (sch->st != 0) { 552 if (sch->st != 0) {
570 CIO_DEBUG(KERN_INFO, 0, 553 CIO_MSG_EVENT(4, "Subchannel 0.%x.%04x reports "
571 "Subchannel 0.%x.%04x reports " 554 "non-I/O subchannel type %04X\n",
572 "non-I/O subchannel type %04X\n", 555 sch->schid.ssid, sch->schid.sch_no, sch->st);
573 sch->schid.ssid, sch->schid.sch_no, sch->st);
574 /* We stop here for non-io subchannels. */ 556 /* We stop here for non-io subchannels. */
575 err = sch->st; 557 err = sch->st;
576 goto out; 558 goto out;
@@ -588,7 +570,7 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
588 * This device must not be known to Linux. So we simply 570 * This device must not be known to Linux. So we simply
589 * say that there is no device and return ENODEV. 571 * say that there is no device and return ENODEV.
590 */ 572 */
591 CIO_MSG_EVENT(4, "Blacklisted device detected " 573 CIO_MSG_EVENT(6, "Blacklisted device detected "
592 "at devno %04X, subchannel set %x\n", 574 "at devno %04X, subchannel set %x\n",
593 sch->schib.pmcw.dev, sch->schid.ssid); 575 sch->schib.pmcw.dev, sch->schid.ssid);
594 err = -ENODEV; 576 err = -ENODEV;
@@ -601,12 +583,11 @@ cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
601 sch->lpm = sch->schib.pmcw.pam & sch->opm; 583 sch->lpm = sch->schib.pmcw.pam & sch->opm;
602 sch->isc = 3; 584 sch->isc = 3;
603 585
604 CIO_DEBUG(KERN_INFO, 0, 586 CIO_MSG_EVENT(6, "Detected device %04x on subchannel 0.%x.%04X "
605 "Detected device %04x on subchannel 0.%x.%04X" 587 "- PIM = %02X, PAM = %02X, POM = %02X\n",
606 " - PIM = %02X, PAM = %02X, POM = %02X\n", 588 sch->schib.pmcw.dev, sch->schid.ssid,
607 sch->schib.pmcw.dev, sch->schid.ssid, 589 sch->schid.sch_no, sch->schib.pmcw.pim,
608 sch->schid.sch_no, sch->schib.pmcw.pim, 590 sch->schib.pmcw.pam, sch->schib.pmcw.pom);
609 sch->schib.pmcw.pam, sch->schib.pmcw.pom);
610 591
611 /* 592 /*
612 * We now have to initially ... 593 * We now have to initially ...
diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
index 3c75412904dc..6e933aebe013 100644
--- a/drivers/s390/cio/cio.h
+++ b/drivers/s390/cio/cio.h
@@ -118,6 +118,4 @@ extern void *cio_get_console_priv(void);
118#define cio_get_console_priv() NULL 118#define cio_get_console_priv() NULL
119#endif 119#endif
120 120
121extern int cio_show_msg;
122
123#endif 121#endif
diff --git a/drivers/s390/cio/cio_debug.h b/drivers/s390/cio/cio_debug.h
index d7429ef6c666..e64e8278c42e 100644
--- a/drivers/s390/cio/cio_debug.h
+++ b/drivers/s390/cio/cio_debug.h
@@ -31,10 +31,4 @@ static inline void CIO_HEX_EVENT(int level, void *data, int length)
31 } 31 }
32} 32}
33 33
34#define CIO_DEBUG(printk_level, event_level, msg...) do { \
35 if (cio_show_msg) \
36 printk(printk_level "cio: " msg); \
37 CIO_MSG_EVENT(event_level, msg); \
38 } while (0)
39
40#endif 34#endif
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 595e327d2f76..a76956512b2d 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -570,7 +570,7 @@ static void reprobe_all(struct work_struct *unused)
570{ 570{
571 int ret; 571 int ret;
572 572
573 CIO_MSG_EVENT(2, "reprobe start\n"); 573 CIO_MSG_EVENT(4, "reprobe start\n");
574 574
575 need_reprobe = 0; 575 need_reprobe = 0;
576 /* Make sure initial subchannel scan is done. */ 576 /* Make sure initial subchannel scan is done. */
@@ -578,7 +578,7 @@ static void reprobe_all(struct work_struct *unused)
578 atomic_read(&ccw_device_init_count) == 0); 578 atomic_read(&ccw_device_init_count) == 0);
579 ret = for_each_subchannel_staged(NULL, reprobe_subchannel, NULL); 579 ret = for_each_subchannel_staged(NULL, reprobe_subchannel, NULL);
580 580
581 CIO_MSG_EVENT(2, "reprobe done (rc=%d, need_reprobe=%d)\n", ret, 581 CIO_MSG_EVENT(4, "reprobe done (rc=%d, need_reprobe=%d)\n", ret,
582 need_reprobe); 582 need_reprobe);
583} 583}
584 584
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index abfd601d237a..e22813db74a2 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -341,7 +341,7 @@ ccw_device_remove_disconnected(struct ccw_device *cdev)
341 rc = device_schedule_callback(&cdev->dev, 341 rc = device_schedule_callback(&cdev->dev,
342 ccw_device_remove_orphan_cb); 342 ccw_device_remove_orphan_cb);
343 if (rc) 343 if (rc)
344 CIO_MSG_EVENT(2, "Couldn't unregister orphan " 344 CIO_MSG_EVENT(0, "Couldn't unregister orphan "
345 "0.%x.%04x\n", 345 "0.%x.%04x\n",
346 cdev->private->dev_id.ssid, 346 cdev->private->dev_id.ssid,
347 cdev->private->dev_id.devno); 347 cdev->private->dev_id.devno);
@@ -351,7 +351,7 @@ ccw_device_remove_disconnected(struct ccw_device *cdev)
351 rc = device_schedule_callback(cdev->dev.parent, 351 rc = device_schedule_callback(cdev->dev.parent,
352 ccw_device_remove_sch_cb); 352 ccw_device_remove_sch_cb);
353 if (rc) 353 if (rc)
354 CIO_MSG_EVENT(2, "Couldn't unregister disconnected device " 354 CIO_MSG_EVENT(0, "Couldn't unregister disconnected device "
355 "0.%x.%04x\n", 355 "0.%x.%04x\n",
356 cdev->private->dev_id.ssid, 356 cdev->private->dev_id.ssid,
357 cdev->private->dev_id.devno); 357 cdev->private->dev_id.devno);
@@ -397,7 +397,7 @@ int ccw_device_set_offline(struct ccw_device *cdev)
397 if (ret == 0) 397 if (ret == 0)
398 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 398 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
399 else { 399 else {
400 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, " 400 CIO_MSG_EVENT(0, "ccw_device_offline returned %d, "
401 "device 0.%x.%04x\n", 401 "device 0.%x.%04x\n",
402 ret, cdev->private->dev_id.ssid, 402 ret, cdev->private->dev_id.ssid,
403 cdev->private->dev_id.devno); 403 cdev->private->dev_id.devno);
@@ -433,7 +433,7 @@ int ccw_device_set_online(struct ccw_device *cdev)
433 if (ret == 0) 433 if (ret == 0)
434 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 434 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
435 else { 435 else {
436 CIO_MSG_EVENT(2, "ccw_device_online returned %d, " 436 CIO_MSG_EVENT(0, "ccw_device_online returned %d, "
437 "device 0.%x.%04x\n", 437 "device 0.%x.%04x\n",
438 ret, cdev->private->dev_id.ssid, 438 ret, cdev->private->dev_id.ssid,
439 cdev->private->dev_id.devno); 439 cdev->private->dev_id.devno);
@@ -451,7 +451,7 @@ int ccw_device_set_online(struct ccw_device *cdev)
451 if (ret == 0) 451 if (ret == 0)
452 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev)); 452 wait_event(cdev->private->wait_q, dev_fsm_final_state(cdev));
453 else 453 else
454 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, " 454 CIO_MSG_EVENT(0, "ccw_device_offline returned %d, "
455 "device 0.%x.%04x\n", 455 "device 0.%x.%04x\n",
456 ret, cdev->private->dev_id.ssid, 456 ret, cdev->private->dev_id.ssid,
457 cdev->private->dev_id.devno); 457 cdev->private->dev_id.devno);
@@ -803,7 +803,7 @@ static void sch_attach_disconnected_device(struct subchannel *sch,
803 other_sch = to_subchannel(get_device(cdev->dev.parent)); 803 other_sch = to_subchannel(get_device(cdev->dev.parent));
804 ret = device_move(&cdev->dev, &sch->dev); 804 ret = device_move(&cdev->dev, &sch->dev);
805 if (ret) { 805 if (ret) {
806 CIO_MSG_EVENT(2, "Moving disconnected device 0.%x.%04x failed " 806 CIO_MSG_EVENT(0, "Moving disconnected device 0.%x.%04x failed "
807 "(ret=%d)!\n", cdev->private->dev_id.ssid, 807 "(ret=%d)!\n", cdev->private->dev_id.ssid,
808 cdev->private->dev_id.devno, ret); 808 cdev->private->dev_id.devno, ret);
809 put_device(&other_sch->dev); 809 put_device(&other_sch->dev);
@@ -933,7 +933,7 @@ io_subchannel_register(struct work_struct *work)
933 ret = device_reprobe(&cdev->dev); 933 ret = device_reprobe(&cdev->dev);
934 if (ret) 934 if (ret)
935 /* We can't do much here. */ 935 /* We can't do much here. */
936 CIO_MSG_EVENT(2, "device_reprobe() returned" 936 CIO_MSG_EVENT(0, "device_reprobe() returned"
937 " %d for 0.%x.%04x\n", ret, 937 " %d for 0.%x.%04x\n", ret,
938 cdev->private->dev_id.ssid, 938 cdev->private->dev_id.ssid,
939 cdev->private->dev_id.devno); 939 cdev->private->dev_id.devno);
@@ -1086,7 +1086,7 @@ static void ccw_device_move_to_sch(struct work_struct *work)
1086 rc = device_move(&cdev->dev, &sch->dev); 1086 rc = device_move(&cdev->dev, &sch->dev);
1087 mutex_unlock(&sch->reg_mutex); 1087 mutex_unlock(&sch->reg_mutex);
1088 if (rc) { 1088 if (rc) {
1089 CIO_MSG_EVENT(2, "Moving device 0.%x.%04x to subchannel " 1089 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to subchannel "
1090 "0.%x.%04x failed (ret=%d)!\n", 1090 "0.%x.%04x failed (ret=%d)!\n",
1091 cdev->private->dev_id.ssid, 1091 cdev->private->dev_id.ssid,
1092 cdev->private->dev_id.devno, sch->schid.ssid, 1092 cdev->private->dev_id.devno, sch->schid.ssid,
@@ -1446,8 +1446,7 @@ ccw_device_remove (struct device *dev)
1446 wait_event(cdev->private->wait_q, 1446 wait_event(cdev->private->wait_q,
1447 dev_fsm_final_state(cdev)); 1447 dev_fsm_final_state(cdev));
1448 else 1448 else
1449 //FIXME: we can't fail! 1449 CIO_MSG_EVENT(0, "ccw_device_offline returned %d, "
1450 CIO_MSG_EVENT(2, "ccw_device_offline returned %d, "
1451 "device 0.%x.%04x\n", 1450 "device 0.%x.%04x\n",
1452 ret, cdev->private->dev_id.ssid, 1451 ret, cdev->private->dev_id.ssid,
1453 cdev->private->dev_id.devno); 1452 cdev->private->dev_id.devno);
@@ -1524,7 +1523,7 @@ static int recovery_check(struct device *dev, void *data)
1524 spin_lock_irq(cdev->ccwlock); 1523 spin_lock_irq(cdev->ccwlock);
1525 switch (cdev->private->state) { 1524 switch (cdev->private->state) {
1526 case DEV_STATE_DISCONNECTED: 1525 case DEV_STATE_DISCONNECTED:
1527 CIO_MSG_EVENT(3, "recovery: trigger 0.%x.%04x\n", 1526 CIO_MSG_EVENT(4, "recovery: trigger 0.%x.%04x\n",
1528 cdev->private->dev_id.ssid, 1527 cdev->private->dev_id.ssid,
1529 cdev->private->dev_id.devno); 1528 cdev->private->dev_id.devno);
1530 dev_fsm_event(cdev, DEV_EVENT_VERIFY); 1529 dev_fsm_event(cdev, DEV_EVENT_VERIFY);
@@ -1554,7 +1553,7 @@ static void recovery_work_func(struct work_struct *unused)
1554 } 1553 }
1555 spin_unlock_irq(&recovery_lock); 1554 spin_unlock_irq(&recovery_lock);
1556 } else 1555 } else
1557 CIO_MSG_EVENT(2, "recovery: end\n"); 1556 CIO_MSG_EVENT(4, "recovery: end\n");
1558} 1557}
1559 1558
1560static DECLARE_WORK(recovery_work, recovery_work_func); 1559static DECLARE_WORK(recovery_work, recovery_work_func);
@@ -1572,7 +1571,7 @@ void ccw_device_schedule_recovery(void)
1572{ 1571{
1573 unsigned long flags; 1572 unsigned long flags;
1574 1573
1575 CIO_MSG_EVENT(2, "recovery: schedule\n"); 1574 CIO_MSG_EVENT(4, "recovery: schedule\n");
1576 spin_lock_irqsave(&recovery_lock, flags); 1575 spin_lock_irqsave(&recovery_lock, flags);
1577 if (!timer_pending(&recovery_timer) || (recovery_phase != 0)) { 1576 if (!timer_pending(&recovery_timer) || (recovery_phase != 0)) {
1578 recovery_phase = 0; 1577 recovery_phase = 0;
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index 99403b0a97a7..e268d5a77c12 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -322,10 +322,10 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
322 same_dev = 0; /* Keep the compiler quiet... */ 322 same_dev = 0; /* Keep the compiler quiet... */
323 switch (state) { 323 switch (state) {
324 case DEV_STATE_NOT_OPER: 324 case DEV_STATE_NOT_OPER:
325 CIO_DEBUG(KERN_WARNING, 2, 325 CIO_MSG_EVENT(2, "SenseID : unknown device %04x on "
326 "SenseID : unknown device %04x on subchannel " 326 "subchannel 0.%x.%04x\n",
327 "0.%x.%04x\n", cdev->private->dev_id.devno, 327 cdev->private->dev_id.devno,
328 sch->schid.ssid, sch->schid.sch_no); 328 sch->schid.ssid, sch->schid.sch_no);
329 break; 329 break;
330 case DEV_STATE_OFFLINE: 330 case DEV_STATE_OFFLINE:
331 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) { 331 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
@@ -348,20 +348,19 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
348 return; 348 return;
349 } 349 }
350 /* Issue device info message. */ 350 /* Issue device info message. */
351 CIO_DEBUG(KERN_INFO, 2, 351 CIO_MSG_EVENT(4, "SenseID : device 0.%x.%04x reports: "
352 "SenseID : device 0.%x.%04x reports: " 352 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
353 "CU Type/Mod = %04X/%02X, Dev Type/Mod = " 353 "%04X/%02X\n",
354 "%04X/%02X\n", 354 cdev->private->dev_id.ssid,
355 cdev->private->dev_id.ssid, 355 cdev->private->dev_id.devno,
356 cdev->private->dev_id.devno, 356 cdev->id.cu_type, cdev->id.cu_model,
357 cdev->id.cu_type, cdev->id.cu_model, 357 cdev->id.dev_type, cdev->id.dev_model);
358 cdev->id.dev_type, cdev->id.dev_model);
359 break; 358 break;
360 case DEV_STATE_BOXED: 359 case DEV_STATE_BOXED:
361 CIO_DEBUG(KERN_WARNING, 2, 360 CIO_MSG_EVENT(0, "SenseID : boxed device %04x on "
362 "SenseID : boxed device %04x on subchannel " 361 " subchannel 0.%x.%04x\n",
363 "0.%x.%04x\n", cdev->private->dev_id.devno, 362 cdev->private->dev_id.devno,
364 sch->schid.ssid, sch->schid.sch_no); 363 sch->schid.ssid, sch->schid.sch_no);
365 break; 364 break;
366 } 365 }
367 cdev->private->state = state; 366 cdev->private->state = state;
@@ -443,9 +442,8 @@ ccw_device_done(struct ccw_device *cdev, int state)
443 442
444 443
445 if (state == DEV_STATE_BOXED) 444 if (state == DEV_STATE_BOXED)
446 CIO_DEBUG(KERN_WARNING, 2, 445 CIO_MSG_EVENT(0, "Boxed device %04x on subchannel %04x\n",
447 "Boxed device %04x on subchannel %04x\n", 446 cdev->private->dev_id.devno, sch->schid.sch_no);
448 cdev->private->dev_id.devno, sch->schid.sch_no);
449 447
450 if (cdev->private->flags.donotify) { 448 if (cdev->private->flags.donotify) {
451 cdev->private->flags.donotify = 0; 449 cdev->private->flags.donotify = 0;
@@ -900,7 +898,7 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
900 /* Basic sense hasn't started. Try again. */ 898 /* Basic sense hasn't started. Try again. */
901 ccw_device_do_sense(cdev, irb); 899 ccw_device_do_sense(cdev, irb);
902 else { 900 else {
903 CIO_MSG_EVENT(2, "Huh? 0.%x.%04x: unsolicited " 901 CIO_MSG_EVENT(0, "0.%x.%04x: unsolicited "
904 "interrupt during w4sense...\n", 902 "interrupt during w4sense...\n",
905 cdev->private->dev_id.ssid, 903 cdev->private->dev_id.ssid,
906 cdev->private->dev_id.devno); 904 cdev->private->dev_id.devno);
@@ -1169,8 +1167,10 @@ ccw_device_nop(struct ccw_device *cdev, enum dev_event dev_event)
1169static void 1167static void
1170ccw_device_bug(struct ccw_device *cdev, enum dev_event dev_event) 1168ccw_device_bug(struct ccw_device *cdev, enum dev_event dev_event)
1171{ 1169{
1172 CIO_MSG_EVENT(0, "dev_jumptable[%i][%i] == NULL\n", 1170 CIO_MSG_EVENT(0, "Internal state [%i][%i] not handled for device "
1173 cdev->private->state, dev_event); 1171 "0.%x.%04x\n", cdev->private->state, dev_event,
1172 cdev->private->dev_id.ssid,
1173 cdev->private->dev_id.devno);
1174 BUG(); 1174 BUG();
1175} 1175}
1176 1176
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index dc4d87f77f6c..cba7020517ed 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -214,7 +214,7 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
214 * sense id information. So, for intervention required, 214 * sense id information. So, for intervention required,
215 * we use the "whack it until it talks" strategy... 215 * we use the "whack it until it talks" strategy...
216 */ 216 */
217 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel " 217 CIO_MSG_EVENT(0, "SenseID : device %04x on Subchannel "
218 "0.%x.%04x reports cmd reject\n", 218 "0.%x.%04x reports cmd reject\n",
219 cdev->private->dev_id.devno, sch->schid.ssid, 219 cdev->private->dev_id.devno, sch->schid.ssid,
220 sch->schid.sch_no); 220 sch->schid.sch_no);
@@ -239,7 +239,7 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
239 239
240 lpm = to_io_private(sch)->orb.lpm; 240 lpm = to_io_private(sch)->orb.lpm;
241 if ((lpm & sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0) 241 if ((lpm & sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0)
242 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x " 242 CIO_MSG_EVENT(4, "SenseID : path %02X for device %04x "
243 "on subchannel 0.%x.%04x is " 243 "on subchannel 0.%x.%04x is "
244 "'not operational'\n", lpm, 244 "'not operational'\n", lpm,
245 cdev->private->dev_id.devno, 245 cdev->private->dev_id.devno,
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index c52449a1f9fc..ba559053402e 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -79,7 +79,7 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev)
79 /* ret is 0, -EBUSY, -EACCES or -ENODEV */ 79 /* ret is 0, -EBUSY, -EACCES or -ENODEV */
80 if (ret != -EACCES) 80 if (ret != -EACCES)
81 return ret; 81 return ret;
82 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " 82 CIO_MSG_EVENT(3, "SNID - Device %04x on Subchannel "
83 "0.%x.%04x, lpm %02X, became 'not " 83 "0.%x.%04x, lpm %02X, became 'not "
84 "operational'\n", 84 "operational'\n",
85 cdev->private->dev_id.devno, 85 cdev->private->dev_id.devno,
@@ -159,7 +159,7 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
159 u8 lpm; 159 u8 lpm;
160 160
161 lpm = to_io_private(sch)->orb.lpm; 161 lpm = to_io_private(sch)->orb.lpm;
162 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x," 162 CIO_MSG_EVENT(3, "SNID - Device %04x on Subchannel 0.%x.%04x,"
163 " lpm %02X, became 'not operational'\n", 163 " lpm %02X, became 'not operational'\n",
164 cdev->private->dev_id.devno, sch->schid.ssid, 164 cdev->private->dev_id.devno, sch->schid.ssid,
165 sch->schid.sch_no, lpm); 165 sch->schid.sch_no, lpm);
@@ -275,7 +275,7 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
275 return ret; 275 return ret;
276 } 276 }
277 /* PGID command failed on this path. */ 277 /* PGID command failed on this path. */
278 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " 278 CIO_MSG_EVENT(3, "SPID - Device %04x on Subchannel "
279 "0.%x.%04x, lpm %02X, became 'not operational'\n", 279 "0.%x.%04x, lpm %02X, became 'not operational'\n",
280 cdev->private->dev_id.devno, sch->schid.ssid, 280 cdev->private->dev_id.devno, sch->schid.ssid,
281 sch->schid.sch_no, cdev->private->imask); 281 sch->schid.sch_no, cdev->private->imask);
@@ -317,7 +317,7 @@ static int __ccw_device_do_nop(struct ccw_device *cdev)
317 return ret; 317 return ret;
318 } 318 }
319 /* nop command failed on this path. */ 319 /* nop command failed on this path. */
320 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel " 320 CIO_MSG_EVENT(3, "NOP - Device %04x on Subchannel "
321 "0.%x.%04x, lpm %02X, became 'not operational'\n", 321 "0.%x.%04x, lpm %02X, became 'not operational'\n",
322 cdev->private->dev_id.devno, sch->schid.ssid, 322 cdev->private->dev_id.devno, sch->schid.ssid,
323 sch->schid.sch_no, cdev->private->imask); 323 sch->schid.sch_no, cdev->private->imask);
@@ -362,7 +362,7 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
362 return -EAGAIN; 362 return -EAGAIN;
363 } 363 }
364 if (irb->scsw.cc == 3) { 364 if (irb->scsw.cc == 3) {
365 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x," 365 CIO_MSG_EVENT(3, "SPID - Device %04x on Subchannel 0.%x.%04x,"
366 " lpm %02X, became 'not operational'\n", 366 " lpm %02X, became 'not operational'\n",
367 cdev->private->dev_id.devno, sch->schid.ssid, 367 cdev->private->dev_id.devno, sch->schid.ssid,
368 sch->schid.sch_no, cdev->private->imask); 368 sch->schid.sch_no, cdev->private->imask);
@@ -391,7 +391,7 @@ static int __ccw_device_check_nop(struct ccw_device *cdev)
391 return -ETIME; 391 return -ETIME;
392 } 392 }
393 if (irb->scsw.cc == 3) { 393 if (irb->scsw.cc == 3) {
394 CIO_MSG_EVENT(2, "NOP - Device %04x on Subchannel 0.%x.%04x," 394 CIO_MSG_EVENT(3, "NOP - Device %04x on Subchannel 0.%x.%04x,"
395 " lpm %02X, became 'not operational'\n", 395 " lpm %02X, became 'not operational'\n",
396 cdev->private->dev_id.devno, sch->schid.ssid, 396 cdev->private->dev_id.devno, sch->schid.ssid,
397 sch->schid.sch_no, cdev->private->imask); 397 sch->schid.sch_no, cdev->private->imask);
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c
index 4d4b54277c43..5080f343ad74 100644
--- a/drivers/s390/s390mach.c
+++ b/drivers/s390/s390mach.c
@@ -48,10 +48,11 @@ s390_collect_crw_info(void *param)
48 int ccode; 48 int ccode;
49 struct semaphore *sem; 49 struct semaphore *sem;
50 unsigned int chain; 50 unsigned int chain;
51 int ignore;
51 52
52 sem = (struct semaphore *)param; 53 sem = (struct semaphore *)param;
53repeat: 54repeat:
54 down_interruptible(sem); 55 ignore = down_interruptible(sem);
55 chain = 0; 56 chain = 0;
56 while (1) { 57 while (1) {
57 if (unlikely(chain > 1)) { 58 if (unlikely(chain > 1)) {
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c
index 4fab0c23814c..b87037ec9805 100644
--- a/drivers/sbus/char/bpp.c
+++ b/drivers/sbus/char/bpp.c
@@ -41,7 +41,7 @@
41#define BPP_DELAY 100 41#define BPP_DELAY 100
42 42
43static const unsigned BPP_MAJOR = LP_MAJOR; 43static const unsigned BPP_MAJOR = LP_MAJOR;
44static const char* dev_name = "bpp"; 44static const char *bpp_dev_name = "bpp";
45 45
46/* When switching from compatibility to a mode where I can read, try 46/* When switching from compatibility to a mode where I can read, try
47 the following mode first. */ 47 the following mode first. */
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 46d7e400c8be..81ccbd7f9e34 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -1679,6 +1679,7 @@ config MAC_SCSI
1679config SCSI_MAC_ESP 1679config SCSI_MAC_ESP
1680 tristate "Macintosh NCR53c9[46] SCSI" 1680 tristate "Macintosh NCR53c9[46] SCSI"
1681 depends on MAC && SCSI 1681 depends on MAC && SCSI
1682 select SCSI_SPI_ATTRS
1682 help 1683 help
1683 This is the NCR 53c9x SCSI controller found on most of the 68040 1684 This is the NCR 53c9x SCSI controller found on most of the 68040
1684 based Macintoshes. 1685 based Macintoshes.
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index f5215fd4b73d..1dca1775f4b1 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -3830,7 +3830,7 @@ static int __init aha152x_init(void)
3830 iounmap(p); 3830 iounmap(p);
3831 } 3831 }
3832 if (!ok && setup_count == 0) 3832 if (!ok && setup_count == 0)
3833 return 0; 3833 return -ENODEV;
3834 3834
3835 printk(KERN_INFO "aha152x: BIOS test: passed, "); 3835 printk(KERN_INFO "aha152x: BIOS test: passed, ");
3836#else 3836#else
@@ -3909,14 +3909,14 @@ static int __init aha152x_init(void)
3909#endif 3909#endif
3910 } 3910 }
3911 3911
3912 return 1; 3912 return 0;
3913} 3913}
3914 3914
3915static void __exit aha152x_exit(void) 3915static void __exit aha152x_exit(void)
3916{ 3916{
3917 struct aha152x_hostdata *hd; 3917 struct aha152x_hostdata *hd, *tmp;
3918 3918
3919 list_for_each_entry(hd, &aha152x_host_list, host_list) { 3919 list_for_each_entry_safe(hd, tmp, &aha152x_host_list, host_list) {
3920 struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata); 3920 struct Scsi_Host *shost = container_of((void *)hd, struct Scsi_Host, hostdata);
3921 3921
3922 aha152x_release(shost); 3922 aha152x_release(shost);
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 0fb5bf4c43ac..8508816f303d 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -1967,45 +1967,6 @@ cleanup:
1967 return rcode; 1967 return rcode;
1968} 1968}
1969 1969
1970
1971/*
1972 * This routine returns information about the system. This does not effect
1973 * any logic and if the info is wrong - it doesn't matter.
1974 */
1975
1976/* Get all the info we can not get from kernel services */
1977static int adpt_system_info(void __user *buffer)
1978{
1979 sysInfo_S si;
1980
1981 memset(&si, 0, sizeof(si));
1982
1983 si.osType = OS_LINUX;
1984 si.osMajorVersion = 0;
1985 si.osMinorVersion = 0;
1986 si.osRevision = 0;
1987 si.busType = SI_PCI_BUS;
1988 si.processorFamily = DPTI_sig.dsProcessorFamily;
1989
1990#if defined __i386__
1991 adpt_i386_info(&si);
1992#elif defined (__ia64__)
1993 adpt_ia64_info(&si);
1994#elif defined(__sparc__)
1995 adpt_sparc_info(&si);
1996#elif defined (__alpha__)
1997 adpt_alpha_info(&si);
1998#else
1999 si.processorType = 0xff ;
2000#endif
2001 if(copy_to_user(buffer, &si, sizeof(si))){
2002 printk(KERN_WARNING"dpti: Could not copy buffer TO user\n");
2003 return -EFAULT;
2004 }
2005
2006 return 0;
2007}
2008
2009#if defined __ia64__ 1970#if defined __ia64__
2010static void adpt_ia64_info(sysInfo_S* si) 1971static void adpt_ia64_info(sysInfo_S* si)
2011{ 1972{
@@ -2016,7 +1977,6 @@ static void adpt_ia64_info(sysInfo_S* si)
2016} 1977}
2017#endif 1978#endif
2018 1979
2019
2020#if defined __sparc__ 1980#if defined __sparc__
2021static void adpt_sparc_info(sysInfo_S* si) 1981static void adpt_sparc_info(sysInfo_S* si)
2022{ 1982{
@@ -2026,7 +1986,6 @@ static void adpt_sparc_info(sysInfo_S* si)
2026 si->processorType = PROC_ULTRASPARC; 1986 si->processorType = PROC_ULTRASPARC;
2027} 1987}
2028#endif 1988#endif
2029
2030#if defined __alpha__ 1989#if defined __alpha__
2031static void adpt_alpha_info(sysInfo_S* si) 1990static void adpt_alpha_info(sysInfo_S* si)
2032{ 1991{
@@ -2038,7 +1997,6 @@ static void adpt_alpha_info(sysInfo_S* si)
2038#endif 1997#endif
2039 1998
2040#if defined __i386__ 1999#if defined __i386__
2041
2042static void adpt_i386_info(sysInfo_S* si) 2000static void adpt_i386_info(sysInfo_S* si)
2043{ 2001{
2044 // This is all the info we need for now 2002 // This is all the info we need for now
@@ -2059,9 +2017,45 @@ static void adpt_i386_info(sysInfo_S* si)
2059 break; 2017 break;
2060 } 2018 }
2061} 2019}
2020#endif
2021
2022/*
2023 * This routine returns information about the system. This does not effect
2024 * any logic and if the info is wrong - it doesn't matter.
2025 */
2062 2026
2027/* Get all the info we can not get from kernel services */
2028static int adpt_system_info(void __user *buffer)
2029{
2030 sysInfo_S si;
2031
2032 memset(&si, 0, sizeof(si));
2033
2034 si.osType = OS_LINUX;
2035 si.osMajorVersion = 0;
2036 si.osMinorVersion = 0;
2037 si.osRevision = 0;
2038 si.busType = SI_PCI_BUS;
2039 si.processorFamily = DPTI_sig.dsProcessorFamily;
2040
2041#if defined __i386__
2042 adpt_i386_info(&si);
2043#elif defined (__ia64__)
2044 adpt_ia64_info(&si);
2045#elif defined(__sparc__)
2046 adpt_sparc_info(&si);
2047#elif defined (__alpha__)
2048 adpt_alpha_info(&si);
2049#else
2050 si.processorType = 0xff ;
2063#endif 2051#endif
2052 if (copy_to_user(buffer, &si, sizeof(si))){
2053 printk(KERN_WARNING"dpti: Could not copy buffer TO user\n");
2054 return -EFAULT;
2055 }
2064 2056
2057 return 0;
2058}
2065 2059
2066static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, 2060static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd,
2067 ulong arg) 2061 ulong arg)
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 924cd5a51676..337746d46043 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -316,19 +316,6 @@ static int adpt_close(struct inode *inode, struct file *file);
316static void adpt_delay(int millisec); 316static void adpt_delay(int millisec);
317#endif 317#endif
318 318
319#if defined __ia64__
320static void adpt_ia64_info(sysInfo_S* si);
321#endif
322#if defined __sparc__
323static void adpt_sparc_info(sysInfo_S* si);
324#endif
325#if defined __alpha__
326static void adpt_sparc_info(sysInfo_S* si);
327#endif
328#if defined __i386__
329static void adpt_i386_info(sysInfo_S* si);
330#endif
331
332#define PRINT_BUFFER_SIZE 512 319#define PRINT_BUFFER_SIZE 512
333 320
334#define HBA_FLAGS_DBG_FLAGS_MASK 0xffff0000 // Mask for debug flags 321#define HBA_FLAGS_DBG_FLAGS_MASK 0xffff0000 // Mask for debug flags
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 8e2e964af668..46771d4c81bd 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -550,7 +550,6 @@ static int __init gdth_search_isa(ulong32 bios_adr)
550#endif /* CONFIG_ISA */ 550#endif /* CONFIG_ISA */
551 551
552#ifdef CONFIG_PCI 552#ifdef CONFIG_PCI
553static bool gdth_pci_registered;
554 553
555static bool gdth_search_vortex(ushort device) 554static bool gdth_search_vortex(ushort device)
556{ 555{
@@ -3724,6 +3723,8 @@ static void gdth_log_event(gdth_evt_data *dvr, char *buffer)
3724} 3723}
3725 3724
3726#ifdef GDTH_STATISTICS 3725#ifdef GDTH_STATISTICS
3726static unchar gdth_timer_running;
3727
3727static void gdth_timeout(ulong data) 3728static void gdth_timeout(ulong data)
3728{ 3729{
3729 ulong32 i; 3730 ulong32 i;
@@ -3731,7 +3732,10 @@ static void gdth_timeout(ulong data)
3731 gdth_ha_str *ha; 3732 gdth_ha_str *ha;
3732 ulong flags; 3733 ulong flags;
3733 3734
3734 BUG_ON(list_empty(&gdth_instances)); 3735 if(unlikely(list_empty(&gdth_instances))) {
3736 gdth_timer_running = 0;
3737 return;
3738 }
3735 3739
3736 ha = list_first_entry(&gdth_instances, gdth_ha_str, list); 3740 ha = list_first_entry(&gdth_instances, gdth_ha_str, list);
3737 spin_lock_irqsave(&ha->smp_lock, flags); 3741 spin_lock_irqsave(&ha->smp_lock, flags);
@@ -3751,6 +3755,22 @@ static void gdth_timeout(ulong data)
3751 add_timer(&gdth_timer); 3755 add_timer(&gdth_timer);
3752 spin_unlock_irqrestore(&ha->smp_lock, flags); 3756 spin_unlock_irqrestore(&ha->smp_lock, flags);
3753} 3757}
3758
3759static void gdth_timer_init(void)
3760{
3761 if (gdth_timer_running)
3762 return;
3763 gdth_timer_running = 1;
3764 TRACE2(("gdth_detect(): Initializing timer !\n"));
3765 gdth_timer.expires = jiffies + HZ;
3766 gdth_timer.data = 0L;
3767 gdth_timer.function = gdth_timeout;
3768 add_timer(&gdth_timer);
3769}
3770#else
3771static inline void gdth_timer_init(void)
3772{
3773}
3754#endif 3774#endif
3755 3775
3756static void __init internal_setup(char *str,int *ints) 3776static void __init internal_setup(char *str,int *ints)
@@ -4735,6 +4755,7 @@ static int __init gdth_isa_probe_one(ulong32 isa_bios)
4735 if (error) 4755 if (error)
4736 goto out_free_coal_stat; 4756 goto out_free_coal_stat;
4737 list_add_tail(&ha->list, &gdth_instances); 4757 list_add_tail(&ha->list, &gdth_instances);
4758 gdth_timer_init();
4738 4759
4739 scsi_scan_host(shp); 4760 scsi_scan_host(shp);
4740 4761
@@ -4865,6 +4886,7 @@ static int __init gdth_eisa_probe_one(ushort eisa_slot)
4865 if (error) 4886 if (error)
4866 goto out_free_coal_stat; 4887 goto out_free_coal_stat;
4867 list_add_tail(&ha->list, &gdth_instances); 4888 list_add_tail(&ha->list, &gdth_instances);
4889 gdth_timer_init();
4868 4890
4869 scsi_scan_host(shp); 4891 scsi_scan_host(shp);
4870 4892
@@ -5011,6 +5033,7 @@ static int gdth_pci_probe_one(gdth_pci_str *pcistr,
5011 list_add_tail(&ha->list, &gdth_instances); 5033 list_add_tail(&ha->list, &gdth_instances);
5012 5034
5013 pci_set_drvdata(ha->pdev, ha); 5035 pci_set_drvdata(ha->pdev, ha);
5036 gdth_timer_init();
5014 5037
5015 scsi_scan_host(shp); 5038 scsi_scan_host(shp);
5016 5039
@@ -5110,6 +5133,7 @@ static int __init gdth_init(void)
5110 /* initializations */ 5133 /* initializations */
5111 gdth_polling = TRUE; 5134 gdth_polling = TRUE;
5112 gdth_clear_events(); 5135 gdth_clear_events();
5136 init_timer(&gdth_timer);
5113 5137
5114 /* As default we do not probe for EISA or ISA controllers */ 5138 /* As default we do not probe for EISA or ISA controllers */
5115 if (probe_eisa_isa) { 5139 if (probe_eisa_isa) {
@@ -5132,23 +5156,17 @@ static int __init gdth_init(void)
5132 5156
5133#ifdef CONFIG_PCI 5157#ifdef CONFIG_PCI
5134 /* scanning for PCI controllers */ 5158 /* scanning for PCI controllers */
5135 if (pci_register_driver(&gdth_pci_driver) == 0) 5159 if (pci_register_driver(&gdth_pci_driver)) {
5136 gdth_pci_registered = true; 5160 gdth_ha_str *ha;
5161
5162 list_for_each_entry(ha, &gdth_instances, list)
5163 gdth_remove_one(ha);
5164 return -ENODEV;
5165 }
5137#endif /* CONFIG_PCI */ 5166#endif /* CONFIG_PCI */
5138 5167
5139 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count)); 5168 TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
5140 5169
5141 if (list_empty(&gdth_instances))
5142 return -ENODEV;
5143
5144#ifdef GDTH_STATISTICS
5145 TRACE2(("gdth_detect(): Initializing timer !\n"));
5146 init_timer(&gdth_timer);
5147 gdth_timer.expires = jiffies + HZ;
5148 gdth_timer.data = 0L;
5149 gdth_timer.function = gdth_timeout;
5150 add_timer(&gdth_timer);
5151#endif
5152 major = register_chrdev(0,"gdth", &gdth_fops); 5170 major = register_chrdev(0,"gdth", &gdth_fops);
5153 register_reboot_notifier(&gdth_notifier); 5171 register_reboot_notifier(&gdth_notifier);
5154 gdth_polling = FALSE; 5172 gdth_polling = FALSE;
@@ -5167,8 +5185,7 @@ static void __exit gdth_exit(void)
5167#endif 5185#endif
5168 5186
5169#ifdef CONFIG_PCI 5187#ifdef CONFIG_PCI
5170 if (gdth_pci_registered) 5188 pci_unregister_driver(&gdth_pci_driver);
5171 pci_unregister_driver(&gdth_pci_driver);
5172#endif 5189#endif
5173 5190
5174 list_for_each_entry(ha, &gdth_instances, list) 5191 list_for_each_entry(ha, &gdth_instances, list)
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 010c1b9b178c..b43bf1d60dac 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -730,7 +730,9 @@ static int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
730 if (iscsi_recv_pdu(conn->cls_conn, hdr, data, 730 if (iscsi_recv_pdu(conn->cls_conn, hdr, data,
731 datalen)) 731 datalen))
732 rc = ISCSI_ERR_CONN_FAILED; 732 rc = ISCSI_ERR_CONN_FAILED;
733 } 733 } else
734 mod_timer(&conn->transport_timer,
735 jiffies + conn->recv_timeout);
734 iscsi_free_mgmt_task(conn, mtask); 736 iscsi_free_mgmt_task(conn, mtask);
735 break; 737 break;
736 default: 738 default:
@@ -1453,19 +1455,20 @@ static void iscsi_check_transport_timeouts(unsigned long data)
1453{ 1455{
1454 struct iscsi_conn *conn = (struct iscsi_conn *)data; 1456 struct iscsi_conn *conn = (struct iscsi_conn *)data;
1455 struct iscsi_session *session = conn->session; 1457 struct iscsi_session *session = conn->session;
1456 unsigned long timeout, next_timeout = 0, last_recv; 1458 unsigned long recv_timeout, next_timeout = 0, last_recv;
1457 1459
1458 spin_lock(&session->lock); 1460 spin_lock(&session->lock);
1459 if (session->state != ISCSI_STATE_LOGGED_IN) 1461 if (session->state != ISCSI_STATE_LOGGED_IN)
1460 goto done; 1462 goto done;
1461 1463
1462 timeout = conn->recv_timeout; 1464 recv_timeout = conn->recv_timeout;
1463 if (!timeout) 1465 if (!recv_timeout)
1464 goto done; 1466 goto done;
1465 1467
1466 timeout *= HZ; 1468 recv_timeout *= HZ;
1467 last_recv = conn->last_recv; 1469 last_recv = conn->last_recv;
1468 if (time_before_eq(last_recv + timeout + (conn->ping_timeout * HZ), 1470 if (conn->ping_mtask &&
1471 time_before_eq(conn->last_ping + (conn->ping_timeout * HZ),
1469 jiffies)) { 1472 jiffies)) {
1470 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs " 1473 iscsi_conn_printk(KERN_ERR, conn, "ping timeout of %d secs "
1471 "expired, last rx %lu, last ping %lu, " 1474 "expired, last rx %lu, last ping %lu, "
@@ -1476,15 +1479,13 @@ static void iscsi_check_transport_timeouts(unsigned long data)
1476 return; 1479 return;
1477 } 1480 }
1478 1481
1479 if (time_before_eq(last_recv + timeout, jiffies)) { 1482 if (time_before_eq(last_recv + recv_timeout, jiffies)) {
1480 if (time_before_eq(conn->last_ping, last_recv)) { 1483 /* send a ping to try to provoke some traffic */
1481 /* send a ping to try to provoke some traffic */ 1484 debug_scsi("Sending nopout as ping on conn %p\n", conn);
1482 debug_scsi("Sending nopout as ping on conn %p\n", conn); 1485 iscsi_send_nopout(conn, NULL);
1483 iscsi_send_nopout(conn, NULL); 1486 next_timeout = conn->last_ping + (conn->ping_timeout * HZ);
1484 }
1485 next_timeout = last_recv + timeout + (conn->ping_timeout * HZ);
1486 } else 1487 } else
1487 next_timeout = last_recv + timeout; 1488 next_timeout = last_recv + recv_timeout;
1488 1489
1489 debug_scsi("Setting next tmo %lu\n", next_timeout); 1490 debug_scsi("Setting next tmo %lu\n", next_timeout);
1490 mod_timer(&conn->transport_timer, next_timeout); 1491 mod_timer(&conn->transport_timer, next_timeout);
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index fa060932d2b4..51e2f299dbbb 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -2007,7 +2007,7 @@ qla1280_set_defaults(struct scsi_qla_host *ha)
2007 nv->bus[bus].config_2.req_ack_active_negation = 1; 2007 nv->bus[bus].config_2.req_ack_active_negation = 1;
2008 nv->bus[bus].config_2.data_line_active_negation = 1; 2008 nv->bus[bus].config_2.data_line_active_negation = 1;
2009 nv->bus[bus].selection_timeout = 250; 2009 nv->bus[bus].selection_timeout = 250;
2010 nv->bus[bus].max_queue_depth = 256; 2010 nv->bus[bus].max_queue_depth = 32;
2011 2011
2012 if (IS_ISP1040(ha)) { 2012 if (IS_ISP1040(ha)) {
2013 nv->bus[bus].bus_reset_delay = 3; 2013 nv->bus[bus].bus_reset_delay = 3;
@@ -2051,7 +2051,7 @@ qla1280_config_target(struct scsi_qla_host *ha, int bus, int target)
2051 status = qla1280_mailbox_command(ha, 0x0f, mb); 2051 status = qla1280_mailbox_command(ha, 0x0f, mb);
2052 2052
2053 /* Save Tag queuing enable flag. */ 2053 /* Save Tag queuing enable flag. */
2054 flag = (BIT_0 << target) & mb[0]; 2054 flag = (BIT_0 << target);
2055 if (nv->bus[bus].target[target].parameter.tag_queuing) 2055 if (nv->bus[bus].target[target].parameter.tag_queuing)
2056 ha->bus_settings[bus].qtag_enables |= flag; 2056 ha->bus_settings[bus].qtag_enables |= flag;
2057 2057
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 36acbcca2d48..62e6eb136a3c 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -976,11 +976,15 @@ config SERIAL_68328_RTS_CTS
976 depends on SERIAL_68328 976 depends on SERIAL_68328
977 977
978config SERIAL_COLDFIRE 978config SERIAL_COLDFIRE
979 bool "ColdFire serial support" 979 bool "ColdFire serial support (DEPRECATED)"
980 depends on COLDFIRE 980 depends on COLDFIRE
981 help 981 help
982 This driver supports the built-in serial ports of the Motorola ColdFire 982 This driver supports the built-in serial ports of the Motorola ColdFire
983 family of CPUs. 983 family of CPUs.
984 This driver is deprecated because it supports only the old interface
985 for serial drivers and features like magic keys are not working.
986 Please switch to the new style driver because this driver will be
987 removed soon.
984 988
985config SERIAL_MCF 989config SERIAL_MCF
986 bool "Coldfire serial support (new style driver)" 990 bool "Coldfire serial support (new style driver)"
diff --git a/drivers/serial/bfin_5xx.c b/drivers/serial/bfin_5xx.c
index 8a2f6a1baa74..d6b4ead693b7 100644
--- a/drivers/serial/bfin_5xx.c
+++ b/drivers/serial/bfin_5xx.c
@@ -65,9 +65,6 @@ static void bfin_serial_stop_tx(struct uart_port *port)
65{ 65{
66 struct bfin_serial_port *uart = (struct bfin_serial_port *)port; 66 struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
67 struct circ_buf *xmit = &uart->port.info->xmit; 67 struct circ_buf *xmit = &uart->port.info->xmit;
68#if !defined(CONFIG_BF54x) && !defined(CONFIG_SERIAL_BFIN_DMA)
69 unsigned short ier;
70#endif
71 68
72 while (!(UART_GET_LSR(uart) & TEMT)) 69 while (!(UART_GET_LSR(uart) & TEMT))
73 cpu_relax(); 70 cpu_relax();
@@ -82,12 +79,8 @@ static void bfin_serial_stop_tx(struct uart_port *port)
82#ifdef CONFIG_BF54x 79#ifdef CONFIG_BF54x
83 /* Clear TFI bit */ 80 /* Clear TFI bit */
84 UART_PUT_LSR(uart, TFI); 81 UART_PUT_LSR(uart, TFI);
85 UART_CLEAR_IER(uart, ETBEI);
86#else
87 ier = UART_GET_IER(uart);
88 ier &= ~ETBEI;
89 UART_PUT_IER(uart, ier);
90#endif 82#endif
83 UART_CLEAR_IER(uart, ETBEI);
91#endif 84#endif
92} 85}
93 86
@@ -102,14 +95,7 @@ static void bfin_serial_start_tx(struct uart_port *port)
102 if (uart->tx_done) 95 if (uart->tx_done)
103 bfin_serial_dma_tx_chars(uart); 96 bfin_serial_dma_tx_chars(uart);
104#else 97#else
105#ifdef CONFIG_BF54x
106 UART_SET_IER(uart, ETBEI); 98 UART_SET_IER(uart, ETBEI);
107#else
108 unsigned short ier;
109 ier = UART_GET_IER(uart);
110 ier |= ETBEI;
111 UART_PUT_IER(uart, ier);
112#endif
113 bfin_serial_tx_chars(uart); 99 bfin_serial_tx_chars(uart);
114#endif 100#endif
115} 101}
@@ -120,21 +106,10 @@ static void bfin_serial_start_tx(struct uart_port *port)
120static void bfin_serial_stop_rx(struct uart_port *port) 106static void bfin_serial_stop_rx(struct uart_port *port)
121{ 107{
122 struct bfin_serial_port *uart = (struct bfin_serial_port *)port; 108 struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
123#ifdef CONFIG_KGDB_UART 109#ifdef CONFIG_KGDB_UART
124 if (uart->port.line != CONFIG_KGDB_UART_PORT) { 110 if (uart->port.line != CONFIG_KGDB_UART_PORT)
125#endif 111#endif
126#ifdef CONFIG_BF54x
127 UART_CLEAR_IER(uart, ERBFI); 112 UART_CLEAR_IER(uart, ERBFI);
128#else
129 unsigned short ier;
130
131 ier = UART_GET_IER(uart);
132 ier &= ~ERBFI;
133 UART_PUT_IER(uart, ier);
134#endif
135#ifdef CONFIG_KGDB_UART
136 }
137#endif
138} 113}
139 114
140/* 115/*
@@ -161,10 +136,7 @@ void kgdb_put_debug_char(int chr)
161 SSYNC(); 136 SSYNC();
162 } 137 }
163 138
164#ifndef CONFIG_BF54x 139 UART_CLEAR_DLAB(uart);
165 UART_PUT_LCR(uart, UART_GET_LCR(uart)&(~DLAB));
166 SSYNC();
167#endif
168 UART_PUT_CHAR(uart, (unsigned char)chr); 140 UART_PUT_CHAR(uart, (unsigned char)chr);
169 SSYNC(); 141 SSYNC();
170} 142}
@@ -183,10 +155,7 @@ int kgdb_get_debug_char(void)
183 while(!(UART_GET_LSR(uart) & DR)) { 155 while(!(UART_GET_LSR(uart) & DR)) {
184 SSYNC(); 156 SSYNC();
185 } 157 }
186#ifndef CONFIG_BF54x 158 UART_CLEAR_DLAB(uart);
187 UART_PUT_LCR(uart, UART_GET_LCR(uart)&(~DLAB));
188 SSYNC();
189#endif
190 chr = UART_GET_CHAR(uart); 159 chr = UART_GET_CHAR(uart);
191 SSYNC(); 160 SSYNC();
192 161
@@ -208,9 +177,6 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
208 struct tty_struct *tty = uart->port.info->tty; 177 struct tty_struct *tty = uart->port.info->tty;
209 unsigned int status, ch, flg; 178 unsigned int status, ch, flg;
210 static struct timeval anomaly_start = { .tv_sec = 0 }; 179 static struct timeval anomaly_start = { .tv_sec = 0 };
211#ifdef CONFIG_KGDB_UART
212 struct pt_regs *regs = get_irq_regs();
213#endif
214 180
215 status = UART_GET_LSR(uart); 181 status = UART_GET_LSR(uart);
216 UART_CLEAR_LSR(uart); 182 UART_CLEAR_LSR(uart);
@@ -220,6 +186,7 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
220 186
221#ifdef CONFIG_KGDB_UART 187#ifdef CONFIG_KGDB_UART
222 if (uart->port.line == CONFIG_KGDB_UART_PORT) { 188 if (uart->port.line == CONFIG_KGDB_UART_PORT) {
189 struct pt_regs *regs = get_irq_regs();
223 if (uart->port.cons->index == CONFIG_KGDB_UART_PORT && ch == 0x1) { /* Ctrl + A */ 190 if (uart->port.cons->index == CONFIG_KGDB_UART_PORT && ch == 0x1) { /* Ctrl + A */
224 kgdb_breakkey_pressed(regs); 191 kgdb_breakkey_pressed(regs);
225 return; 192 return;
@@ -391,7 +358,6 @@ static void bfin_serial_do_work(struct work_struct *work)
391static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart) 358static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
392{ 359{
393 struct circ_buf *xmit = &uart->port.info->xmit; 360 struct circ_buf *xmit = &uart->port.info->xmit;
394 unsigned short ier;
395 361
396 uart->tx_done = 0; 362 uart->tx_done = 0;
397 363
@@ -429,13 +395,7 @@ static void bfin_serial_dma_tx_chars(struct bfin_serial_port *uart)
429 set_dma_x_modify(uart->tx_dma_channel, 1); 395 set_dma_x_modify(uart->tx_dma_channel, 1);
430 enable_dma(uart->tx_dma_channel); 396 enable_dma(uart->tx_dma_channel);
431 397
432#ifdef CONFIG_BF54x
433 UART_SET_IER(uart, ETBEI); 398 UART_SET_IER(uart, ETBEI);
434#else
435 ier = UART_GET_IER(uart);
436 ier |= ETBEI;
437 UART_PUT_IER(uart, ier);
438#endif
439} 399}
440 400
441static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart) 401static void bfin_serial_dma_rx_chars(struct bfin_serial_port *uart)
@@ -513,19 +473,12 @@ static irqreturn_t bfin_serial_dma_tx_int(int irq, void *dev_id)
513{ 473{
514 struct bfin_serial_port *uart = dev_id; 474 struct bfin_serial_port *uart = dev_id;
515 struct circ_buf *xmit = &uart->port.info->xmit; 475 struct circ_buf *xmit = &uart->port.info->xmit;
516 unsigned short ier;
517 476
518 spin_lock(&uart->port.lock); 477 spin_lock(&uart->port.lock);
519 if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) { 478 if (!(get_dma_curr_irqstat(uart->tx_dma_channel)&DMA_RUN)) {
520 disable_dma(uart->tx_dma_channel); 479 disable_dma(uart->tx_dma_channel);
521 clear_dma_irqstat(uart->tx_dma_channel); 480 clear_dma_irqstat(uart->tx_dma_channel);
522#ifdef CONFIG_BF54x
523 UART_CLEAR_IER(uart, ETBEI); 481 UART_CLEAR_IER(uart, ETBEI);
524#else
525 ier = UART_GET_IER(uart);
526 ier &= ~ETBEI;
527 UART_PUT_IER(uart, ier);
528#endif
529 xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1); 482 xmit->tail = (xmit->tail + uart->tx_count) & (UART_XMIT_SIZE - 1);
530 uart->port.icount.tx += uart->tx_count; 483 uart->port.icount.tx += uart->tx_count;
531 484
@@ -701,7 +654,6 @@ static int bfin_serial_startup(struct uart_port *port)
701# endif 654# endif
702 } 655 }
703 656
704
705 if (request_irq 657 if (request_irq
706 (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED, 658 (uart->port.irq+1, bfin_serial_tx_int, IRQF_DISABLED,
707 "BFIN_UART_TX", uart)) { 659 "BFIN_UART_TX", uart)) {
@@ -710,11 +662,7 @@ static int bfin_serial_startup(struct uart_port *port)
710 return -EBUSY; 662 return -EBUSY;
711 } 663 }
712#endif 664#endif
713#ifdef CONFIG_BF54x
714 UART_SET_IER(uart, ERBFI); 665 UART_SET_IER(uart, ERBFI);
715#else
716 UART_PUT_IER(uart, UART_GET_IER(uart) | ERBFI);
717#endif
718 return 0; 666 return 0;
719} 667}
720 668
@@ -810,26 +758,15 @@ bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
810 UART_PUT_IER(uart, 0); 758 UART_PUT_IER(uart, 0);
811#endif 759#endif
812 760
813#ifndef CONFIG_BF54x
814 /* Set DLAB in LCR to Access DLL and DLH */ 761 /* Set DLAB in LCR to Access DLL and DLH */
815 val = UART_GET_LCR(uart); 762 UART_SET_DLAB(uart);
816 val |= DLAB;
817 UART_PUT_LCR(uart, val);
818 SSYNC();
819#endif
820 763
821 UART_PUT_DLL(uart, quot & 0xFF); 764 UART_PUT_DLL(uart, quot & 0xFF);
822 SSYNC();
823 UART_PUT_DLH(uart, (quot >> 8) & 0xFF); 765 UART_PUT_DLH(uart, (quot >> 8) & 0xFF);
824 SSYNC(); 766 SSYNC();
825 767
826#ifndef CONFIG_BF54x
827 /* Clear DLAB in LCR to Access THR RBR IER */ 768 /* Clear DLAB in LCR to Access THR RBR IER */
828 val = UART_GET_LCR(uart); 769 UART_CLEAR_DLAB(uart);
829 val &= ~DLAB;
830 UART_PUT_LCR(uart, val);
831 SSYNC();
832#endif
833 770
834 UART_PUT_LCR(uart, lcr); 771 UART_PUT_LCR(uart, lcr);
835 772
@@ -992,8 +929,7 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
992 status = UART_GET_IER(uart) & (ERBFI | ETBEI); 929 status = UART_GET_IER(uart) & (ERBFI | ETBEI);
993 if (status == (ERBFI | ETBEI)) { 930 if (status == (ERBFI | ETBEI)) {
994 /* ok, the port was enabled */ 931 /* ok, the port was enabled */
995 unsigned short lcr, val; 932 u16 lcr, dlh, dll;
996 unsigned short dlh, dll;
997 933
998 lcr = UART_GET_LCR(uart); 934 lcr = UART_GET_LCR(uart);
999 935
@@ -1010,22 +946,14 @@ bfin_serial_console_get_options(struct bfin_serial_port *uart, int *baud,
1010 case 2: *bits = 7; break; 946 case 2: *bits = 7; break;
1011 case 3: *bits = 8; break; 947 case 3: *bits = 8; break;
1012 } 948 }
1013#ifndef CONFIG_BF54x
1014 /* Set DLAB in LCR to Access DLL and DLH */ 949 /* Set DLAB in LCR to Access DLL and DLH */
1015 val = UART_GET_LCR(uart); 950 UART_SET_DLAB(uart);
1016 val |= DLAB;
1017 UART_PUT_LCR(uart, val);
1018#endif
1019 951
1020 dll = UART_GET_DLL(uart); 952 dll = UART_GET_DLL(uart);
1021 dlh = UART_GET_DLH(uart); 953 dlh = UART_GET_DLH(uart);
1022 954
1023#ifndef CONFIG_BF54x
1024 /* Clear DLAB in LCR to Access THR RBR IER */ 955 /* Clear DLAB in LCR to Access THR RBR IER */
1025 val = UART_GET_LCR(uart); 956 UART_CLEAR_DLAB(uart);
1026 val &= ~DLAB;
1027 UART_PUT_LCR(uart, val);
1028#endif
1029 957
1030 *baud = get_sclk() / (16*(dll | dlh << 8)); 958 *baud = get_sclk() / (16*(dll | dlh << 8));
1031 } 959 }
@@ -1290,11 +1218,7 @@ static int __init bfin_serial_init(void)
1290 request_irq(uart->port.irq, bfin_serial_rx_int, 1218 request_irq(uart->port.irq, bfin_serial_rx_int,
1291 IRQF_DISABLED, "BFIN_UART_RX", uart); 1219 IRQF_DISABLED, "BFIN_UART_RX", uart);
1292 pr_info("Request irq for kgdb uart port\n"); 1220 pr_info("Request irq for kgdb uart port\n");
1293#ifdef CONFIG_BF54x
1294 UART_SET_IER(uart, ERBFI); 1221 UART_SET_IER(uart, ERBFI);
1295#else
1296 UART_PUT_IER(uart, UART_GET_IER(uart) | ERBFI);
1297#endif
1298 SSYNC(); 1222 SSYNC();
1299 t.c_cflag = CS8|B57600; 1223 t.c_cflag = CS8|B57600;
1300 t.c_iflag = 0; 1224 t.c_iflag = 0;
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index f9fa237aa949..3e0366eab412 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -3808,7 +3808,7 @@ rs_close(struct tty_struct *tty, struct file * filp)
3808 3808
3809 shutdown(info); 3809 shutdown(info);
3810 rs_flush_buffer(tty); 3810 rs_flush_buffer(tty);
3811 tty_ldisc_flush_buffer(tty); 3811 tty_ldisc_flush(tty);
3812 tty->closing = 0; 3812 tty->closing = 0;
3813 info->event = 0; 3813 info->event = 0;
3814 info->tty = 0; 3814 info->tty = 0;
diff --git a/drivers/serial/mcfserial.c b/drivers/serial/mcfserial.c
index 43af40d59b8a..56007cc8a9b3 100644
--- a/drivers/serial/mcfserial.c
+++ b/drivers/serial/mcfserial.c
@@ -1,3 +1,4 @@
1#warning This driver is deprecated. Check Kconfig for details.
1/* 2/*
2 * mcfserial.c -- serial driver for ColdFire internal UARTS. 3 * mcfserial.c -- serial driver for ColdFire internal UARTS.
3 * 4 *
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 1e2b9d826f69..eab032733790 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -556,7 +556,7 @@ static int uart_chars_in_buffer(struct tty_struct *tty)
556static void uart_flush_buffer(struct tty_struct *tty) 556static void uart_flush_buffer(struct tty_struct *tty)
557{ 557{
558 struct uart_state *state = tty->driver_data; 558 struct uart_state *state = tty->driver_data;
559 struct uart_port *port = state->port; 559 struct uart_port *port;
560 unsigned long flags; 560 unsigned long flags;
561 561
562 /* 562 /*
@@ -568,6 +568,7 @@ static void uart_flush_buffer(struct tty_struct *tty)
568 return; 568 return;
569 } 569 }
570 570
571 port = state->port;
571 pr_debug("uart_flush_buffer(%d) called\n", tty->index); 572 pr_debug("uart_flush_buffer(%d) called\n", tty->index);
572 573
573 spin_lock_irqsave(&port->lock, flags); 574 spin_lock_irqsave(&port->lock, flags);
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 969106187718..8fdafc27fce8 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -42,14 +42,12 @@
42#include <linux/console.h> 42#include <linux/console.h>
43#include <linux/platform_device.h> 43#include <linux/platform_device.h>
44#include <linux/serial_sci.h> 44#include <linux/serial_sci.h>
45
46#ifdef CONFIG_CPU_FREQ
47#include <linux/notifier.h> 45#include <linux/notifier.h>
48#include <linux/cpufreq.h> 46#include <linux/cpufreq.h>
49#endif 47#include <linux/clk.h>
50
51#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
52#include <linux/ctype.h> 48#include <linux/ctype.h>
49
50#ifdef CONFIG_SUPERH
53#include <asm/clock.h> 51#include <asm/clock.h>
54#include <asm/sh_bios.h> 52#include <asm/sh_bios.h>
55#include <asm/kgdb.h> 53#include <asm/kgdb.h>
@@ -80,7 +78,7 @@ struct sci_port {
80 struct timer_list break_timer; 78 struct timer_list break_timer;
81 int break_flag; 79 int break_flag;
82 80
83#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 81#ifdef CONFIG_SUPERH
84 /* Port clock */ 82 /* Port clock */
85 struct clk *clk; 83 struct clk *clk;
86#endif 84#endif
@@ -365,21 +363,19 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
365static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 363static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
366{ 364{
367 unsigned int fcr_val = 0; 365 unsigned int fcr_val = 0;
366 unsigned short data;
368 367
369 if (cflag & CRTSCTS) { 368 if (port->mapbase == 0xffe00000) {
370 fcr_val |= SCFCR_MCE; 369 data = ctrl_inw(PSCR);
371 370 data &= ~0x03cf;
372 ctrl_outw(0x0000, PORT_PSCR); 371 if (cflag & CRTSCTS)
373 } else { 372 fcr_val |= SCFCR_MCE;
374 unsigned short data; 373 else
375 374 data |= 0x0340;
376 data = ctrl_inw(PORT_PSCR);
377 data &= 0x033f;
378 data |= 0x0400;
379 ctrl_outw(data, PORT_PSCR);
380 375
381 ctrl_outw(ctrl_inw(SCSPTR0) & 0x17, SCSPTR0); 376 ctrl_outw(data, PSCR);
382 } 377 }
378 /* SCIF1 and SCIF2 should be setup by board code */
383 379
384 sci_out(port, SCFCR, fcr_val); 380 sci_out(port, SCFCR, fcr_val);
385} 381}
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index fa8700a968fc..eb84833233fd 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -76,12 +76,13 @@
76# define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */ 76# define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */
77# define SCIF_ONLY 77# define SCIF_ONLY
78#elif defined(CONFIG_CPU_SUBTYPE_SH7722) 78#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
79# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ 79# define PADR 0xA4050120
80# define SCSPTR0 SCPDR0 80# define PSDR 0xA405013e
81# define PWDR 0xA4050166
82# define PSCR 0xA405011E
81# define SCIF_ORER 0x0001 /* overrun error bit */ 83# define SCIF_ORER 0x0001 /* overrun error bit */
82# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 84# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
83# define SCIF_ONLY 85# define SCIF_ONLY
84# define PORT_PSCR 0xA405011E
85#elif defined(CONFIG_CPU_SUBTYPE_SH7366) 86#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
86# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */ 87# define SCPDR0 0xA405013E /* 16 bit SCIF0 PSDR */
87# define SCSPTR0 SCPDR0 88# define SCSPTR0 SCPDR0
@@ -320,7 +321,7 @@
320 unsigned int addr = port->mapbase + (offset); \ 321 unsigned int addr = port->mapbase + (offset); \
321 if ((size) == 8) { \ 322 if ((size) == 8) { \
322 ctrl_outb(value, addr); \ 323 ctrl_outb(value, addr); \
323 } else { \ 324 } else if ((size) == 16) { \
324 ctrl_outw(value, addr); \ 325 ctrl_outw(value, addr); \
325 } 326 }
326 327
@@ -451,7 +452,11 @@ SCIF_FNS(SCSPTR, 0, 0, 0x24, 16)
451SCIF_FNS(SCLSR, 0, 0, 0x28, 16) 452SCIF_FNS(SCLSR, 0, 0, 0x28, 16)
452#else 453#else
453SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16) 454SCIF_FNS(SCFDR, 0x0e, 16, 0x1C, 16)
455#if defined(CONFIG_CPU_SUBTYPE_SH7722)
456SCIF_FNS(SCSPTR, 0, 0, 0, 0)
457#else
454SCIF_FNS(SCSPTR, 0, 0, 0x20, 16) 458SCIF_FNS(SCSPTR, 0, 0, 0x20, 16)
459#endif
455SCIF_FNS(SCLSR, 0, 0, 0x24, 16) 460SCIF_FNS(SCLSR, 0, 0, 0x24, 16)
456#endif 461#endif
457#endif 462#endif
@@ -593,13 +598,25 @@ static inline int sci_rxd_in(struct uart_port *port)
593 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */ 598 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
594 return 1; 599 return 1;
595} 600}
596#elif defined(CONFIG_CPU_SUBTYPE_SH7722) || defined(CONFIG_CPU_SUBTYPE_SH7366) 601#elif defined(CONFIG_CPU_SUBTYPE_SH7366)
597static inline int sci_rxd_in(struct uart_port *port) 602static inline int sci_rxd_in(struct uart_port *port)
598{ 603{
599 if (port->mapbase == 0xffe00000) 604 if (port->mapbase == 0xffe00000)
600 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */ 605 return ctrl_inb(SCPDR0) & 0x0001 ? 1 : 0; /* SCIF0 */
601 return 1; 606 return 1;
602} 607}
608#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
609static inline int sci_rxd_in(struct uart_port *port)
610{
611 if (port->mapbase == 0xffe00000)
612 return ctrl_inb(PSDR) & 0x02 ? 1 : 0; /* SCIF0 */
613 if (port->mapbase == 0xffe10000)
614 return ctrl_inb(PADR) & 0x40 ? 1 : 0; /* SCIF1 */
615 if (port->mapbase == 0xffe20000)
616 return ctrl_inb(PWDR) & 0x04 ? 1 : 0; /* SCIF2 */
617
618 return 1;
619}
603#elif defined(CONFIG_CPU_SUBTYPE_SH7723) 620#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
604static inline int sci_rxd_in(struct uart_port *port) 621static inline int sci_rxd_in(struct uart_port *port)
605{ 622{
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index fae9e8f3d092..66ec5d8808de 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -126,7 +126,6 @@ config SPI_MPC52xx_PSC
126config SPI_MPC83xx 126config SPI_MPC83xx
127 tristate "Freescale MPC83xx/QUICC Engine SPI controller" 127 tristate "Freescale MPC83xx/QUICC Engine SPI controller"
128 depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL 128 depends on SPI_MASTER && (PPC_83xx || QUICC_ENGINE) && EXPERIMENTAL
129 select SPI_BITBANG
130 help 129 help
131 This enables using the Freescale MPC83xx and QUICC Engine SPI 130 This enables using the Freescale MPC83xx and QUICC Engine SPI
132 controllers in master mode. 131 controllers in master mode.
diff --git a/drivers/spi/mpc52xx_psc_spi.c b/drivers/spi/mpc52xx_psc_spi.c
index 90729469d481..681d62325d3d 100644
--- a/drivers/spi/mpc52xx_psc_spi.c
+++ b/drivers/spi/mpc52xx_psc_spi.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * MPC52xx SPC in SPI mode driver. 2 * MPC52xx PSC in SPI mode driver.
3 * 3 *
4 * Maintainer: Dragos Carp 4 * Maintainer: Dragos Carp
5 * 5 *
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index 654bb58be630..0c452c46ab07 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -1567,7 +1567,7 @@ static int pxa2xx_spi_resume(struct platform_device *pdev)
1567 int status = 0; 1567 int status = 0;
1568 1568
1569 /* Enable the SSP clock */ 1569 /* Enable the SSP clock */
1570 clk_disable(ssp->clk); 1570 clk_enable(ssp->clk);
1571 1571
1572 /* Start the queue running */ 1572 /* Start the queue running */
1573 status = start_queue(drv_data); 1573 status = start_queue(drv_data);
diff --git a/drivers/spi/spi_mpc83xx.c b/drivers/spi/spi_mpc83xx.c
index 189f706b9e4b..6832da6f7109 100644
--- a/drivers/spi/spi_mpc83xx.c
+++ b/drivers/spi/spi_mpc83xx.c
@@ -49,6 +49,7 @@ struct mpc83xx_spi_reg {
49#define SPMODE_LEN(x) ((x) << 20) 49#define SPMODE_LEN(x) ((x) << 20)
50#define SPMODE_PM(x) ((x) << 16) 50#define SPMODE_PM(x) ((x) << 16)
51#define SPMODE_OP (1 << 14) 51#define SPMODE_OP (1 << 14)
52#define SPMODE_CG(x) ((x) << 7)
52 53
53/* 54/*
54 * Default for SPI Mode: 55 * Default for SPI Mode:
@@ -67,10 +68,6 @@ struct mpc83xx_spi_reg {
67 68
68/* SPI Controller driver's private data. */ 69/* SPI Controller driver's private data. */
69struct mpc83xx_spi { 70struct mpc83xx_spi {
70 /* bitbang has to be first */
71 struct spi_bitbang bitbang;
72 struct completion done;
73
74 struct mpc83xx_spi_reg __iomem *base; 71 struct mpc83xx_spi_reg __iomem *base;
75 72
76 /* rx & tx bufs from the spi_transfer */ 73 /* rx & tx bufs from the spi_transfer */
@@ -82,7 +79,7 @@ struct mpc83xx_spi {
82 u32(*get_tx) (struct mpc83xx_spi *); 79 u32(*get_tx) (struct mpc83xx_spi *);
83 80
84 unsigned int count; 81 unsigned int count;
85 u32 irq; 82 int irq;
86 83
87 unsigned nsecs; /* (clock cycle time)/2 */ 84 unsigned nsecs; /* (clock cycle time)/2 */
88 85
@@ -94,6 +91,25 @@ struct mpc83xx_spi {
94 91
95 void (*activate_cs) (u8 cs, u8 polarity); 92 void (*activate_cs) (u8 cs, u8 polarity);
96 void (*deactivate_cs) (u8 cs, u8 polarity); 93 void (*deactivate_cs) (u8 cs, u8 polarity);
94
95 u8 busy;
96
97 struct workqueue_struct *workqueue;
98 struct work_struct work;
99
100 struct list_head queue;
101 spinlock_t lock;
102
103 struct completion done;
104};
105
106struct spi_mpc83xx_cs {
107 /* functions to deal with different sized buffers */
108 void (*get_rx) (u32 rx_data, struct mpc83xx_spi *);
109 u32 (*get_tx) (struct mpc83xx_spi *);
110 u32 rx_shift; /* RX data reg shift when in qe mode */
111 u32 tx_shift; /* TX data reg shift when in qe mode */
112 u32 hw_mode; /* Holds HW mode register settings */
97}; 113};
98 114
99static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val) 115static inline void mpc83xx_spi_write_reg(__be32 __iomem * reg, u32 val)
@@ -137,6 +153,7 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
137{ 153{
138 struct mpc83xx_spi *mpc83xx_spi; 154 struct mpc83xx_spi *mpc83xx_spi;
139 u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0; 155 u8 pol = spi->mode & SPI_CS_HIGH ? 1 : 0;
156 struct spi_mpc83xx_cs *cs = spi->controller_state;
140 157
141 mpc83xx_spi = spi_master_get_devdata(spi->master); 158 mpc83xx_spi = spi_master_get_devdata(spi->master);
142 159
@@ -147,50 +164,26 @@ static void mpc83xx_spi_chipselect(struct spi_device *spi, int value)
147 164
148 if (value == BITBANG_CS_ACTIVE) { 165 if (value == BITBANG_CS_ACTIVE) {
149 u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode); 166 u32 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
150 u32 len = spi->bits_per_word;
151 u8 pm;
152 167
153 if (len == 32) 168 mpc83xx_spi->rx_shift = cs->rx_shift;
154 len = 0; 169 mpc83xx_spi->tx_shift = cs->tx_shift;
155 else 170 mpc83xx_spi->get_rx = cs->get_rx;
156 len = len - 1; 171 mpc83xx_spi->get_tx = cs->get_tx;
157 172
158 /* mask out bits we are going to set */ 173 if (cs->hw_mode != regval) {
159 regval &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH 174 unsigned long flags;
160 | SPMODE_LEN(0xF) | SPMODE_DIV16 175 void *tmp_ptr = &mpc83xx_spi->base->mode;
161 | SPMODE_PM(0xF) | SPMODE_REV | SPMODE_LOOP); 176
162 177 regval = cs->hw_mode;
163 if (spi->mode & SPI_CPHA) 178 /* Turn off IRQs locally to minimize time that
164 regval |= SPMODE_CP_BEGIN_EDGECLK; 179 * SPI is disabled
165 if (spi->mode & SPI_CPOL) 180 */
166 regval |= SPMODE_CI_INACTIVEHIGH; 181 local_irq_save(flags);
167 if (!(spi->mode & SPI_LSB_FIRST)) 182 /* Turn off SPI unit prior changing mode */
168 regval |= SPMODE_REV; 183 mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE);
169 if (spi->mode & SPI_LOOP) 184 mpc83xx_spi_write_reg(tmp_ptr, regval);
170 regval |= SPMODE_LOOP; 185 local_irq_restore(flags);
171
172 regval |= SPMODE_LEN(len);
173
174 if ((mpc83xx_spi->spibrg / spi->max_speed_hz) >= 64) {
175 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 64) - 1;
176 if (pm > 0x0f) {
177 dev_err(&spi->dev, "Requested speed is too "
178 "low: %d Hz. Will use %d Hz instead.\n",
179 spi->max_speed_hz,
180 mpc83xx_spi->spibrg / 1024);
181 pm = 0x0f;
182 }
183 regval |= SPMODE_PM(pm) | SPMODE_DIV16;
184 } else {
185 pm = mpc83xx_spi->spibrg / (spi->max_speed_hz * 4);
186 if (pm)
187 pm--;
188 regval |= SPMODE_PM(pm);
189 } 186 }
190
191 /* Turn off SPI unit prior changing mode */
192 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0);
193 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
194 if (mpc83xx_spi->activate_cs) 187 if (mpc83xx_spi->activate_cs)
195 mpc83xx_spi->activate_cs(spi->chip_select, pol); 188 mpc83xx_spi->activate_cs(spi->chip_select, pol);
196 } 189 }
@@ -201,8 +194,9 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
201{ 194{
202 struct mpc83xx_spi *mpc83xx_spi; 195 struct mpc83xx_spi *mpc83xx_spi;
203 u32 regval; 196 u32 regval;
204 u8 bits_per_word; 197 u8 bits_per_word, pm;
205 u32 hz; 198 u32 hz;
199 struct spi_mpc83xx_cs *cs = spi->controller_state;
206 200
207 mpc83xx_spi = spi_master_get_devdata(spi->master); 201 mpc83xx_spi = spi_master_get_devdata(spi->master);
208 202
@@ -223,61 +217,191 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
223 || ((bits_per_word > 16) && (bits_per_word != 32))) 217 || ((bits_per_word > 16) && (bits_per_word != 32)))
224 return -EINVAL; 218 return -EINVAL;
225 219
226 mpc83xx_spi->rx_shift = 0; 220 if (!hz)
227 mpc83xx_spi->tx_shift = 0; 221 hz = spi->max_speed_hz;
222
223 cs->rx_shift = 0;
224 cs->tx_shift = 0;
228 if (bits_per_word <= 8) { 225 if (bits_per_word <= 8) {
229 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u8; 226 cs->get_rx = mpc83xx_spi_rx_buf_u8;
230 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u8; 227 cs->get_tx = mpc83xx_spi_tx_buf_u8;
231 if (mpc83xx_spi->qe_mode) { 228 if (mpc83xx_spi->qe_mode) {
232 mpc83xx_spi->rx_shift = 16; 229 cs->rx_shift = 16;
233 mpc83xx_spi->tx_shift = 24; 230 cs->tx_shift = 24;
234 } 231 }
235 } else if (bits_per_word <= 16) { 232 } else if (bits_per_word <= 16) {
236 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u16; 233 cs->get_rx = mpc83xx_spi_rx_buf_u16;
237 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u16; 234 cs->get_tx = mpc83xx_spi_tx_buf_u16;
238 if (mpc83xx_spi->qe_mode) { 235 if (mpc83xx_spi->qe_mode) {
239 mpc83xx_spi->rx_shift = 16; 236 cs->rx_shift = 16;
240 mpc83xx_spi->tx_shift = 16; 237 cs->tx_shift = 16;
241 } 238 }
242 } else if (bits_per_word <= 32) { 239 } else if (bits_per_word <= 32) {
243 mpc83xx_spi->get_rx = mpc83xx_spi_rx_buf_u32; 240 cs->get_rx = mpc83xx_spi_rx_buf_u32;
244 mpc83xx_spi->get_tx = mpc83xx_spi_tx_buf_u32; 241 cs->get_tx = mpc83xx_spi_tx_buf_u32;
245 } else 242 } else
246 return -EINVAL; 243 return -EINVAL;
247 244
248 if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) { 245 if (mpc83xx_spi->qe_mode && spi->mode & SPI_LSB_FIRST) {
249 mpc83xx_spi->tx_shift = 0; 246 cs->tx_shift = 0;
250 if (bits_per_word <= 8) 247 if (bits_per_word <= 8)
251 mpc83xx_spi->rx_shift = 8; 248 cs->rx_shift = 8;
252 else 249 else
253 mpc83xx_spi->rx_shift = 0; 250 cs->rx_shift = 0;
254 } 251 }
255 252
256 /* nsecs = (clock period)/2 */ 253 mpc83xx_spi->rx_shift = cs->rx_shift;
257 if (!hz) 254 mpc83xx_spi->tx_shift = cs->tx_shift;
258 hz = spi->max_speed_hz; 255 mpc83xx_spi->get_rx = cs->get_rx;
259 mpc83xx_spi->nsecs = (1000000000 / 2) / hz; 256 mpc83xx_spi->get_tx = cs->get_tx;
260 if (mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000)
261 return -EINVAL;
262 257
263 if (bits_per_word == 32) 258 if (bits_per_word == 32)
264 bits_per_word = 0; 259 bits_per_word = 0;
265 else 260 else
266 bits_per_word = bits_per_word - 1; 261 bits_per_word = bits_per_word - 1;
267 262
268 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
269
270 /* mask out bits we are going to set */ 263 /* mask out bits we are going to set */
271 regval &= ~(SPMODE_LEN(0xF) | SPMODE_REV); 264 cs->hw_mode &= ~(SPMODE_LEN(0xF) | SPMODE_DIV16
272 regval |= SPMODE_LEN(bits_per_word); 265 | SPMODE_PM(0xF));
273 if (!(spi->mode & SPI_LSB_FIRST)) 266
274 regval |= SPMODE_REV; 267 cs->hw_mode |= SPMODE_LEN(bits_per_word);
268
269 if ((mpc83xx_spi->spibrg / hz) >= 64) {
270 pm = mpc83xx_spi->spibrg / (hz * 64) - 1;
271 if (pm > 0x0f) {
272 dev_err(&spi->dev, "Requested speed is too "
273 "low: %d Hz. Will use %d Hz instead.\n",
274 hz, mpc83xx_spi->spibrg / 1024);
275 pm = 0x0f;
276 }
277 cs->hw_mode |= SPMODE_PM(pm) | SPMODE_DIV16;
278 } else {
279 pm = mpc83xx_spi->spibrg / (hz * 4);
280 if (pm)
281 pm--;
282 cs->hw_mode |= SPMODE_PM(pm);
283 }
284 regval = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
285 if (cs->hw_mode != regval) {
286 unsigned long flags;
287 void *tmp_ptr = &mpc83xx_spi->base->mode;
288
289 regval = cs->hw_mode;
290 /* Turn off IRQs locally to minimize time
291 * that SPI is disabled
292 */
293 local_irq_save(flags);
294 /* Turn off SPI unit prior changing mode */
295 mpc83xx_spi_write_reg(tmp_ptr, regval & ~SPMODE_ENABLE);
296 mpc83xx_spi_write_reg(tmp_ptr, regval);
297 local_irq_restore(flags);
298 }
299 return 0;
300}
275 301
276 /* Turn off SPI unit prior changing mode */ 302static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
277 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, 0); 303{
278 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 304 struct mpc83xx_spi *mpc83xx_spi;
305 u32 word, len, bits_per_word;
279 306
280 return 0; 307 mpc83xx_spi = spi_master_get_devdata(spi->master);
308
309 mpc83xx_spi->tx = t->tx_buf;
310 mpc83xx_spi->rx = t->rx_buf;
311 bits_per_word = spi->bits_per_word;
312 if (t->bits_per_word)
313 bits_per_word = t->bits_per_word;
314 len = t->len;
315 if (bits_per_word > 8)
316 len /= 2;
317 if (bits_per_word > 16)
318 len /= 2;
319 mpc83xx_spi->count = len;
320 INIT_COMPLETION(mpc83xx_spi->done);
321
322 /* enable rx ints */
323 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE);
324
325 /* transmit word */
326 word = mpc83xx_spi->get_tx(mpc83xx_spi);
327 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word);
328
329 wait_for_completion(&mpc83xx_spi->done);
330
331 /* disable rx ints */
332 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
333
334 return mpc83xx_spi->count;
335}
336
337static void mpc83xx_spi_work(struct work_struct *work)
338{
339 struct mpc83xx_spi *mpc83xx_spi =
340 container_of(work, struct mpc83xx_spi, work);
341
342 spin_lock_irq(&mpc83xx_spi->lock);
343 mpc83xx_spi->busy = 1;
344 while (!list_empty(&mpc83xx_spi->queue)) {
345 struct spi_message *m;
346 struct spi_device *spi;
347 struct spi_transfer *t = NULL;
348 unsigned cs_change;
349 int status, nsecs = 50;
350
351 m = container_of(mpc83xx_spi->queue.next,
352 struct spi_message, queue);
353 list_del_init(&m->queue);
354 spin_unlock_irq(&mpc83xx_spi->lock);
355
356 spi = m->spi;
357 cs_change = 1;
358 status = 0;
359 list_for_each_entry(t, &m->transfers, transfer_list) {
360 if (t->bits_per_word || t->speed_hz) {
361 /* Don't allow changes if CS is active */
362 status = -EINVAL;
363
364 if (cs_change)
365 status = mpc83xx_spi_setup_transfer(spi, t);
366 if (status < 0)
367 break;
368 }
369
370 if (cs_change)
371 mpc83xx_spi_chipselect(spi, BITBANG_CS_ACTIVE);
372 cs_change = t->cs_change;
373 if (t->len)
374 status = mpc83xx_spi_bufs(spi, t);
375 if (status) {
376 status = -EMSGSIZE;
377 break;
378 }
379 m->actual_length += t->len;
380
381 if (t->delay_usecs)
382 udelay(t->delay_usecs);
383
384 if (cs_change) {
385 ndelay(nsecs);
386 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
387 ndelay(nsecs);
388 }
389 }
390
391 m->status = status;
392 m->complete(m->context);
393
394 if (status || !cs_change) {
395 ndelay(nsecs);
396 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
397 }
398
399 mpc83xx_spi_setup_transfer(spi, NULL);
400
401 spin_lock_irq(&mpc83xx_spi->lock);
402 }
403 mpc83xx_spi->busy = 0;
404 spin_unlock_irq(&mpc83xx_spi->lock);
281} 405}
282 406
283/* the spi->mode bits understood by this driver: */ 407/* the spi->mode bits understood by this driver: */
@@ -286,9 +410,10 @@ int mpc83xx_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
286 410
287static int mpc83xx_spi_setup(struct spi_device *spi) 411static int mpc83xx_spi_setup(struct spi_device *spi)
288{ 412{
289 struct spi_bitbang *bitbang;
290 struct mpc83xx_spi *mpc83xx_spi; 413 struct mpc83xx_spi *mpc83xx_spi;
291 int retval; 414 int retval;
415 u32 hw_mode;
416 struct spi_mpc83xx_cs *cs = spi->controller_state;
292 417
293 if (spi->mode & ~MODEBITS) { 418 if (spi->mode & ~MODEBITS) {
294 dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n", 419 dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
@@ -299,63 +424,56 @@ static int mpc83xx_spi_setup(struct spi_device *spi)
299 if (!spi->max_speed_hz) 424 if (!spi->max_speed_hz)
300 return -EINVAL; 425 return -EINVAL;
301 426
302 bitbang = spi_master_get_devdata(spi->master); 427 if (!cs) {
428 cs = kzalloc(sizeof *cs, GFP_KERNEL);
429 if (!cs)
430 return -ENOMEM;
431 spi->controller_state = cs;
432 }
303 mpc83xx_spi = spi_master_get_devdata(spi->master); 433 mpc83xx_spi = spi_master_get_devdata(spi->master);
304 434
305 if (!spi->bits_per_word) 435 if (!spi->bits_per_word)
306 spi->bits_per_word = 8; 436 spi->bits_per_word = 8;
307 437
438 hw_mode = cs->hw_mode; /* Save orginal settings */
439 cs->hw_mode = mpc83xx_spi_read_reg(&mpc83xx_spi->base->mode);
440 /* mask out bits we are going to set */
441 cs->hw_mode &= ~(SPMODE_CP_BEGIN_EDGECLK | SPMODE_CI_INACTIVEHIGH
442 | SPMODE_REV | SPMODE_LOOP);
443
444 if (spi->mode & SPI_CPHA)
445 cs->hw_mode |= SPMODE_CP_BEGIN_EDGECLK;
446 if (spi->mode & SPI_CPOL)
447 cs->hw_mode |= SPMODE_CI_INACTIVEHIGH;
448 if (!(spi->mode & SPI_LSB_FIRST))
449 cs->hw_mode |= SPMODE_REV;
450 if (spi->mode & SPI_LOOP)
451 cs->hw_mode |= SPMODE_LOOP;
452
308 retval = mpc83xx_spi_setup_transfer(spi, NULL); 453 retval = mpc83xx_spi_setup_transfer(spi, NULL);
309 if (retval < 0) 454 if (retval < 0) {
455 cs->hw_mode = hw_mode; /* Restore settings */
310 return retval; 456 return retval;
457 }
311 458
312 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec\n", 459 dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u Hz\n",
313 __func__, spi->mode & (SPI_CPOL | SPI_CPHA), 460 __func__, spi->mode & (SPI_CPOL | SPI_CPHA),
314 spi->bits_per_word, 2 * mpc83xx_spi->nsecs); 461 spi->bits_per_word, spi->max_speed_hz);
315 462#if 0 /* Don't think this is needed */
316 /* NOTE we _need_ to call chipselect() early, ideally with adapter 463 /* NOTE we _need_ to call chipselect() early, ideally with adapter
317 * setup, unless the hardware defaults cooperate to avoid confusion 464 * setup, unless the hardware defaults cooperate to avoid confusion
318 * between normal (active low) and inverted chipselects. 465 * between normal (active low) and inverted chipselects.
319 */ 466 */
320 467
321 /* deselect chip (low or high) */ 468 /* deselect chip (low or high) */
322 spin_lock(&bitbang->lock); 469 spin_lock(&mpc83xx_spi->lock);
323 if (!bitbang->busy) { 470 if (!mpc83xx_spi->busy)
324 bitbang->chipselect(spi, BITBANG_CS_INACTIVE); 471 mpc83xx_spi_chipselect(spi, BITBANG_CS_INACTIVE);
325 ndelay(mpc83xx_spi->nsecs); 472 spin_unlock(&mpc83xx_spi->lock);
326 } 473#endif
327 spin_unlock(&bitbang->lock);
328
329 return 0; 474 return 0;
330} 475}
331 476
332static int mpc83xx_spi_bufs(struct spi_device *spi, struct spi_transfer *t)
333{
334 struct mpc83xx_spi *mpc83xx_spi;
335 u32 word;
336
337 mpc83xx_spi = spi_master_get_devdata(spi->master);
338
339 mpc83xx_spi->tx = t->tx_buf;
340 mpc83xx_spi->rx = t->rx_buf;
341 mpc83xx_spi->count = t->len;
342 INIT_COMPLETION(mpc83xx_spi->done);
343
344 /* enable rx ints */
345 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, SPIM_NE);
346
347 /* transmit word */
348 word = mpc83xx_spi->get_tx(mpc83xx_spi);
349 mpc83xx_spi_write_reg(&mpc83xx_spi->base->transmit, word);
350
351 wait_for_completion(&mpc83xx_spi->done);
352
353 /* disable rx ints */
354 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mask, 0);
355
356 return t->len - mpc83xx_spi->count;
357}
358
359irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data) 477irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data)
360{ 478{
361 struct mpc83xx_spi *mpc83xx_spi = context_data; 479 struct mpc83xx_spi *mpc83xx_spi = context_data;
@@ -395,6 +513,28 @@ irqreturn_t mpc83xx_spi_irq(s32 irq, void *context_data)
395 513
396 return ret; 514 return ret;
397} 515}
516static int mpc83xx_spi_transfer(struct spi_device *spi,
517 struct spi_message *m)
518{
519 struct mpc83xx_spi *mpc83xx_spi = spi_master_get_devdata(spi->master);
520 unsigned long flags;
521
522 m->actual_length = 0;
523 m->status = -EINPROGRESS;
524
525 spin_lock_irqsave(&mpc83xx_spi->lock, flags);
526 list_add_tail(&m->queue, &mpc83xx_spi->queue);
527 queue_work(mpc83xx_spi->workqueue, &mpc83xx_spi->work);
528 spin_unlock_irqrestore(&mpc83xx_spi->lock, flags);
529
530 return 0;
531}
532
533
534static void mpc83xx_spi_cleanup(struct spi_device *spi)
535{
536 kfree(spi->controller_state);
537}
398 538
399static int __init mpc83xx_spi_probe(struct platform_device *dev) 539static int __init mpc83xx_spi_probe(struct platform_device *dev)
400{ 540{
@@ -426,11 +566,11 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
426 ret = -ENODEV; 566 ret = -ENODEV;
427 goto free_master; 567 goto free_master;
428 } 568 }
569 master->setup = mpc83xx_spi_setup;
570 master->transfer = mpc83xx_spi_transfer;
571 master->cleanup = mpc83xx_spi_cleanup;
572
429 mpc83xx_spi = spi_master_get_devdata(master); 573 mpc83xx_spi = spi_master_get_devdata(master);
430 mpc83xx_spi->bitbang.master = spi_master_get(master);
431 mpc83xx_spi->bitbang.chipselect = mpc83xx_spi_chipselect;
432 mpc83xx_spi->bitbang.setup_transfer = mpc83xx_spi_setup_transfer;
433 mpc83xx_spi->bitbang.txrx_bufs = mpc83xx_spi_bufs;
434 mpc83xx_spi->activate_cs = pdata->activate_cs; 574 mpc83xx_spi->activate_cs = pdata->activate_cs;
435 mpc83xx_spi->deactivate_cs = pdata->deactivate_cs; 575 mpc83xx_spi->deactivate_cs = pdata->deactivate_cs;
436 mpc83xx_spi->qe_mode = pdata->qe_mode; 576 mpc83xx_spi->qe_mode = pdata->qe_mode;
@@ -445,7 +585,6 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
445 mpc83xx_spi->tx_shift = 24; 585 mpc83xx_spi->tx_shift = 24;
446 } 586 }
447 587
448 mpc83xx_spi->bitbang.master->setup = mpc83xx_spi_setup;
449 init_completion(&mpc83xx_spi->done); 588 init_completion(&mpc83xx_spi->done);
450 589
451 mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1); 590 mpc83xx_spi->base = ioremap(r->start, r->end - r->start + 1);
@@ -483,11 +622,21 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
483 regval |= SPMODE_OP; 622 regval |= SPMODE_OP;
484 623
485 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval); 624 mpc83xx_spi_write_reg(&mpc83xx_spi->base->mode, regval);
625 spin_lock_init(&mpc83xx_spi->lock);
626 init_completion(&mpc83xx_spi->done);
627 INIT_WORK(&mpc83xx_spi->work, mpc83xx_spi_work);
628 INIT_LIST_HEAD(&mpc83xx_spi->queue);
486 629
487 ret = spi_bitbang_start(&mpc83xx_spi->bitbang); 630 mpc83xx_spi->workqueue = create_singlethread_workqueue(
488 631 master->dev.parent->bus_id);
489 if (ret != 0) 632 if (mpc83xx_spi->workqueue == NULL) {
633 ret = -EBUSY;
490 goto free_irq; 634 goto free_irq;
635 }
636
637 ret = spi_register_master(master);
638 if (ret < 0)
639 goto unreg_master;
491 640
492 printk(KERN_INFO 641 printk(KERN_INFO
493 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", 642 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n",
@@ -495,6 +644,8 @@ static int __init mpc83xx_spi_probe(struct platform_device *dev)
495 644
496 return ret; 645 return ret;
497 646
647unreg_master:
648 destroy_workqueue(mpc83xx_spi->workqueue);
498free_irq: 649free_irq:
499 free_irq(mpc83xx_spi->irq, mpc83xx_spi); 650 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
500unmap_io: 651unmap_io:
@@ -515,10 +666,12 @@ static int __exit mpc83xx_spi_remove(struct platform_device *dev)
515 master = platform_get_drvdata(dev); 666 master = platform_get_drvdata(dev);
516 mpc83xx_spi = spi_master_get_devdata(master); 667 mpc83xx_spi = spi_master_get_devdata(master);
517 668
518 spi_bitbang_stop(&mpc83xx_spi->bitbang); 669 flush_workqueue(mpc83xx_spi->workqueue);
670 destroy_workqueue(mpc83xx_spi->workqueue);
671 spi_unregister_master(master);
672
519 free_irq(mpc83xx_spi->irq, mpc83xx_spi); 673 free_irq(mpc83xx_spi->irq, mpc83xx_spi);
520 iounmap(mpc83xx_spi->base); 674 iounmap(mpc83xx_spi->base);
521 spi_master_put(mpc83xx_spi->bitbang.master);
522 675
523 return 0; 676 return 0;
524} 677}
diff --git a/drivers/usb/c67x00/c67x00-ll-hpi.c b/drivers/usb/c67x00/c67x00-ll-hpi.c
index f3430b372f09..5100fbbf6cb0 100644
--- a/drivers/usb/c67x00/c67x00-ll-hpi.c
+++ b/drivers/usb/c67x00/c67x00-ll-hpi.c
@@ -23,6 +23,7 @@
23 23
24#include <asm/byteorder.h> 24#include <asm/byteorder.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/jiffies.h>
26#include <linux/usb/c67x00.h> 27#include <linux/usb/c67x00.h>
27#include "c67x00.h" 28#include "c67x00.h"
28 29
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index cefe7f2c6f75..63c34043b4d9 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1248,6 +1248,9 @@ static struct usb_device_id acm_ids[] = {
1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */ 1248 { USB_DEVICE(0x22b8, 0x7000), /* Motorola Q Phone */
1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */ 1249 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1250 }, 1250 },
1251 { USB_DEVICE(0x0803, 0x3095), /* Zoom Telephonics Model 3095F USB MODEM */
1252 .driver_info = NO_UNION_NORMAL, /* has no union descriptor */
1253 },
1251 1254
1252 /* control interfaces with various AT-command sets */ 1255 /* control interfaces with various AT-command sets */
1253 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, 1256 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 99e5a68a3f12..fae55a31e26d 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -156,6 +156,10 @@ static struct attribute *ep_dev_attrs[] = {
156static struct attribute_group ep_dev_attr_grp = { 156static struct attribute_group ep_dev_attr_grp = {
157 .attrs = ep_dev_attrs, 157 .attrs = ep_dev_attrs,
158}; 158};
159static struct attribute_group *ep_dev_groups[] = {
160 &ep_dev_attr_grp,
161 NULL
162};
159 163
160static int usb_endpoint_major_init(void) 164static int usb_endpoint_major_init(void)
161{ 165{
@@ -298,6 +302,7 @@ int usb_create_ep_files(struct device *parent,
298 302
299 ep_dev->desc = &endpoint->desc; 303 ep_dev->desc = &endpoint->desc;
300 ep_dev->udev = udev; 304 ep_dev->udev = udev;
305 ep_dev->dev.groups = ep_dev_groups;
301 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); 306 ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor);
302 ep_dev->dev.class = ep_class->class; 307 ep_dev->dev.class = ep_class->class;
303 ep_dev->dev.parent = parent; 308 ep_dev->dev.parent = parent;
@@ -309,9 +314,6 @@ int usb_create_ep_files(struct device *parent,
309 retval = device_register(&ep_dev->dev); 314 retval = device_register(&ep_dev->dev);
310 if (retval) 315 if (retval)
311 goto error_chrdev; 316 goto error_chrdev;
312 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
313 if (retval)
314 goto error_group;
315 317
316 /* create the symlink to the old-style "ep_XX" directory */ 318 /* create the symlink to the old-style "ep_XX" directory */
317 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 319 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
@@ -322,8 +324,6 @@ int usb_create_ep_files(struct device *parent,
322 return retval; 324 return retval;
323 325
324error_link: 326error_link:
325 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
326error_group:
327 device_unregister(&ep_dev->dev); 327 device_unregister(&ep_dev->dev);
328 destroy_endpoint_class(); 328 destroy_endpoint_class();
329 return retval; 329 return retval;
@@ -348,7 +348,6 @@ void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
348 348
349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 349 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name); 350 sysfs_remove_link(&ep_dev->dev.parent->kobj, name);
351 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
352 device_unregister(&ep_dev->dev); 351 device_unregister(&ep_dev->dev);
353 endpoint->ep_dev = NULL; 352 endpoint->ep_dev = NULL;
354 destroy_endpoint_class(); 353 destroy_endpoint_class();
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 3e69266e1f4d..fe47d145255a 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1607,6 +1607,7 @@ free_interfaces:
1607 intf->dev.driver = NULL; 1607 intf->dev.driver = NULL;
1608 intf->dev.bus = &usb_bus_type; 1608 intf->dev.bus = &usb_bus_type;
1609 intf->dev.type = &usb_if_device_type; 1609 intf->dev.type = &usb_if_device_type;
1610 intf->dev.groups = usb_interface_groups;
1610 intf->dev.dma_mask = dev->dev.dma_mask; 1611 intf->dev.dma_mask = dev->dev.dma_mask;
1611 device_initialize(&intf->dev); 1612 device_initialize(&intf->dev);
1612 mark_quiesced(intf); 1613 mark_quiesced(intf);
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 5b20a60de8ba..c783cb111847 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -538,6 +538,46 @@ static struct attribute_group dev_attr_grp = {
538 .attrs = dev_attrs, 538 .attrs = dev_attrs,
539}; 539};
540 540
541/* When modifying this list, be sure to modify dev_string_attrs_are_visible()
542 * accordingly.
543 */
544static struct attribute *dev_string_attrs[] = {
545 &dev_attr_manufacturer.attr,
546 &dev_attr_product.attr,
547 &dev_attr_serial.attr,
548 NULL
549};
550
551static mode_t dev_string_attrs_are_visible(struct kobject *kobj,
552 struct attribute *a, int n)
553{
554 struct usb_device *udev = to_usb_device(
555 container_of(kobj, struct device, kobj));
556
557 if (a == &dev_attr_manufacturer.attr) {
558 if (udev->manufacturer == NULL)
559 return 0;
560 } else if (a == &dev_attr_product.attr) {
561 if (udev->product == NULL)
562 return 0;
563 } else if (a == &dev_attr_serial.attr) {
564 if (udev->serial == NULL)
565 return 0;
566 }
567 return a->mode;
568}
569
570static struct attribute_group dev_string_attr_grp = {
571 .attrs = dev_string_attrs,
572 .is_visible = dev_string_attrs_are_visible,
573};
574
575struct attribute_group *usb_device_groups[] = {
576 &dev_attr_grp,
577 &dev_string_attr_grp,
578 NULL
579};
580
541/* Binary descriptors */ 581/* Binary descriptors */
542 582
543static ssize_t 583static ssize_t
@@ -591,10 +631,9 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
591 struct device *dev = &udev->dev; 631 struct device *dev = &udev->dev;
592 int retval; 632 int retval;
593 633
594 retval = sysfs_create_group(&dev->kobj, &dev_attr_grp); 634 /* Unforunately these attributes cannot be created before
595 if (retval) 635 * the uevent is broadcast.
596 return retval; 636 */
597
598 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors); 637 retval = device_create_bin_file(dev, &dev_bin_attr_descriptors);
599 if (retval) 638 if (retval)
600 goto error; 639 goto error;
@@ -607,21 +646,6 @@ int usb_create_sysfs_dev_files(struct usb_device *udev)
607 if (retval) 646 if (retval)
608 goto error; 647 goto error;
609 648
610 if (udev->manufacturer) {
611 retval = device_create_file(dev, &dev_attr_manufacturer);
612 if (retval)
613 goto error;
614 }
615 if (udev->product) {
616 retval = device_create_file(dev, &dev_attr_product);
617 if (retval)
618 goto error;
619 }
620 if (udev->serial) {
621 retval = device_create_file(dev, &dev_attr_serial);
622 if (retval)
623 goto error;
624 }
625 retval = usb_create_ep_files(dev, &udev->ep0, udev); 649 retval = usb_create_ep_files(dev, &udev->ep0, udev);
626 if (retval) 650 if (retval)
627 goto error; 651 goto error;
@@ -636,13 +660,9 @@ void usb_remove_sysfs_dev_files(struct usb_device *udev)
636 struct device *dev = &udev->dev; 660 struct device *dev = &udev->dev;
637 661
638 usb_remove_ep_files(&udev->ep0); 662 usb_remove_ep_files(&udev->ep0);
639 device_remove_file(dev, &dev_attr_manufacturer);
640 device_remove_file(dev, &dev_attr_product);
641 device_remove_file(dev, &dev_attr_serial);
642 remove_power_attributes(dev); 663 remove_power_attributes(dev);
643 remove_persist_attributes(dev); 664 remove_persist_attributes(dev);
644 device_remove_bin_file(dev, &dev_bin_attr_descriptors); 665 device_remove_bin_file(dev, &dev_bin_attr_descriptors);
645 sysfs_remove_group(&dev->kobj, &dev_attr_grp);
646} 666}
647 667
648/* Interface Accociation Descriptor fields */ 668/* Interface Accociation Descriptor fields */
@@ -688,17 +708,15 @@ static ssize_t show_interface_string(struct device *dev,
688 struct device_attribute *attr, char *buf) 708 struct device_attribute *attr, char *buf)
689{ 709{
690 struct usb_interface *intf; 710 struct usb_interface *intf;
691 struct usb_device *udev; 711 char *string;
692 int len;
693 712
694 intf = to_usb_interface(dev); 713 intf = to_usb_interface(dev);
695 udev = interface_to_usbdev(intf); 714 string = intf->cur_altsetting->string;
696 len = snprintf(buf, 256, "%s", intf->cur_altsetting->string); 715 barrier(); /* The altsetting might change! */
697 if (len < 0) 716
717 if (!string)
698 return 0; 718 return 0;
699 buf[len] = '\n'; 719 return sprintf(buf, "%s\n", string);
700 buf[len+1] = 0;
701 return len+1;
702} 720}
703static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL); 721static DEVICE_ATTR(interface, S_IRUGO, show_interface_string, NULL);
704 722
@@ -727,18 +745,6 @@ static ssize_t show_modalias(struct device *dev,
727} 745}
728static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL); 746static DEVICE_ATTR(modalias, S_IRUGO, show_modalias, NULL);
729 747
730static struct attribute *intf_assoc_attrs[] = {
731 &dev_attr_iad_bFirstInterface.attr,
732 &dev_attr_iad_bInterfaceCount.attr,
733 &dev_attr_iad_bFunctionClass.attr,
734 &dev_attr_iad_bFunctionSubClass.attr,
735 &dev_attr_iad_bFunctionProtocol.attr,
736 NULL,
737};
738static struct attribute_group intf_assoc_attr_grp = {
739 .attrs = intf_assoc_attrs,
740};
741
742static struct attribute *intf_attrs[] = { 748static struct attribute *intf_attrs[] = {
743 &dev_attr_bInterfaceNumber.attr, 749 &dev_attr_bInterfaceNumber.attr,
744 &dev_attr_bAlternateSetting.attr, 750 &dev_attr_bAlternateSetting.attr,
@@ -753,6 +759,37 @@ static struct attribute_group intf_attr_grp = {
753 .attrs = intf_attrs, 759 .attrs = intf_attrs,
754}; 760};
755 761
762static struct attribute *intf_assoc_attrs[] = {
763 &dev_attr_iad_bFirstInterface.attr,
764 &dev_attr_iad_bInterfaceCount.attr,
765 &dev_attr_iad_bFunctionClass.attr,
766 &dev_attr_iad_bFunctionSubClass.attr,
767 &dev_attr_iad_bFunctionProtocol.attr,
768 NULL,
769};
770
771static mode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
772 struct attribute *a, int n)
773{
774 struct usb_interface *intf = to_usb_interface(
775 container_of(kobj, struct device, kobj));
776
777 if (intf->intf_assoc == NULL)
778 return 0;
779 return a->mode;
780}
781
782static struct attribute_group intf_assoc_attr_grp = {
783 .attrs = intf_assoc_attrs,
784 .is_visible = intf_assoc_attrs_are_visible,
785};
786
787struct attribute_group *usb_interface_groups[] = {
788 &intf_attr_grp,
789 &intf_assoc_attr_grp,
790 NULL
791};
792
756static inline void usb_create_intf_ep_files(struct usb_interface *intf, 793static inline void usb_create_intf_ep_files(struct usb_interface *intf,
757 struct usb_device *udev) 794 struct usb_device *udev)
758{ 795{
@@ -777,23 +814,21 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
777 814
778int usb_create_sysfs_intf_files(struct usb_interface *intf) 815int usb_create_sysfs_intf_files(struct usb_interface *intf)
779{ 816{
780 struct device *dev = &intf->dev;
781 struct usb_device *udev = interface_to_usbdev(intf); 817 struct usb_device *udev = interface_to_usbdev(intf);
782 struct usb_host_interface *alt = intf->cur_altsetting; 818 struct usb_host_interface *alt = intf->cur_altsetting;
783 int retval; 819 int retval;
784 820
785 if (intf->sysfs_files_created) 821 if (intf->sysfs_files_created)
786 return 0; 822 return 0;
787 retval = sysfs_create_group(&dev->kobj, &intf_attr_grp);
788 if (retval)
789 return retval;
790 823
824 /* The interface string may be present in some altsettings
825 * and missing in others. Hence its attribute cannot be created
826 * before the uevent is broadcast.
827 */
791 if (alt->string == NULL) 828 if (alt->string == NULL)
792 alt->string = usb_cache_string(udev, alt->desc.iInterface); 829 alt->string = usb_cache_string(udev, alt->desc.iInterface);
793 if (alt->string) 830 if (alt->string)
794 retval = device_create_file(dev, &dev_attr_interface); 831 retval = device_create_file(&intf->dev, &dev_attr_interface);
795 if (intf->intf_assoc)
796 retval = sysfs_create_group(&dev->kobj, &intf_assoc_attr_grp);
797 usb_create_intf_ep_files(intf, udev); 832 usb_create_intf_ep_files(intf, udev);
798 intf->sysfs_files_created = 1; 833 intf->sysfs_files_created = 1;
799 return 0; 834 return 0;
@@ -807,7 +842,5 @@ void usb_remove_sysfs_intf_files(struct usb_interface *intf)
807 return; 842 return;
808 usb_remove_intf_ep_files(intf); 843 usb_remove_intf_ep_files(intf);
809 device_remove_file(dev, &dev_attr_interface); 844 device_remove_file(dev, &dev_attr_interface);
810 sysfs_remove_group(&dev->kobj, &intf_attr_grp);
811 sysfs_remove_group(&intf->dev.kobj, &intf_assoc_attr_grp);
812 intf->sysfs_files_created = 0; 845 intf->sysfs_files_created = 0;
813} 846}
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 1f0db51190cc..325774375837 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -291,6 +291,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
291 device_initialize(&dev->dev); 291 device_initialize(&dev->dev);
292 dev->dev.bus = &usb_bus_type; 292 dev->dev.bus = &usb_bus_type;
293 dev->dev.type = &usb_device_type; 293 dev->dev.type = &usb_device_type;
294 dev->dev.groups = usb_device_groups;
294 dev->dev.dma_mask = bus->controller->dma_mask; 295 dev->dev.dma_mask = bus->controller->dma_mask;
295 set_dev_node(&dev->dev, dev_to_node(bus->controller)); 296 set_dev_node(&dev->dev, dev_to_node(bus->controller));
296 dev->state = USB_STATE_ATTACHED; 297 dev->state = USB_STATE_ATTACHED;
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 1bf8ccb9c58d..1a8bc21c335e 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -130,6 +130,10 @@ static inline int is_active(const struct usb_interface *f)
130/* for labeling diagnostics */ 130/* for labeling diagnostics */
131extern const char *usbcore_name; 131extern const char *usbcore_name;
132 132
133/* sysfs stuff */
134extern struct attribute_group *usb_device_groups[];
135extern struct attribute_group *usb_interface_groups[];
136
133/* usbfs stuff */ 137/* usbfs stuff */
134extern struct mutex usbfs_mutex; 138extern struct mutex usbfs_mutex;
135extern struct usb_driver usbfs_driver; 139extern struct usb_driver usbfs_driver;
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index ce337cb5d137..f261d2a9a5f0 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3251,7 +3251,7 @@ static int udc_pci_probe(
3251 /* pci setup */ 3251 /* pci setup */
3252 if (pci_enable_device(pdev) < 0) { 3252 if (pci_enable_device(pdev) < 0) {
3253 kfree(dev); 3253 kfree(dev);
3254 dev = 0; 3254 dev = NULL;
3255 retval = -ENODEV; 3255 retval = -ENODEV;
3256 goto finished; 3256 goto finished;
3257 } 3257 }
@@ -3264,7 +3264,7 @@ static int udc_pci_probe(
3264 if (!request_mem_region(resource, len, name)) { 3264 if (!request_mem_region(resource, len, name)) {
3265 dev_dbg(&pdev->dev, "pci device used already\n"); 3265 dev_dbg(&pdev->dev, "pci device used already\n");
3266 kfree(dev); 3266 kfree(dev);
3267 dev = 0; 3267 dev = NULL;
3268 retval = -EBUSY; 3268 retval = -EBUSY;
3269 goto finished; 3269 goto finished;
3270 } 3270 }
@@ -3274,7 +3274,7 @@ static int udc_pci_probe(
3274 if (dev->virt_addr == NULL) { 3274 if (dev->virt_addr == NULL) {
3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n"); 3275 dev_dbg(&pdev->dev, "start address cannot be mapped\n");
3276 kfree(dev); 3276 kfree(dev);
3277 dev = 0; 3277 dev = NULL;
3278 retval = -EFAULT; 3278 retval = -EFAULT;
3279 goto finished; 3279 goto finished;
3280 } 3280 }
@@ -3282,7 +3282,7 @@ static int udc_pci_probe(
3282 if (!pdev->irq) { 3282 if (!pdev->irq) {
3283 dev_err(&dev->pdev->dev, "irq not set\n"); 3283 dev_err(&dev->pdev->dev, "irq not set\n");
3284 kfree(dev); 3284 kfree(dev);
3285 dev = 0; 3285 dev = NULL;
3286 retval = -ENODEV; 3286 retval = -ENODEV;
3287 goto finished; 3287 goto finished;
3288 } 3288 }
@@ -3290,7 +3290,7 @@ static int udc_pci_probe(
3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { 3290 if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); 3291 dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
3292 kfree(dev); 3292 kfree(dev);
3293 dev = 0; 3293 dev = NULL;
3294 retval = -EBUSY; 3294 retval = -EBUSY;
3295 goto finished; 3295 goto finished;
3296 } 3296 }
diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
index e756023362c2..07e5a0b5dcda 100644
--- a/drivers/usb/gadget/atmel_usba_udc.c
+++ b/drivers/usb/gadget/atmel_usba_udc.c
@@ -649,7 +649,13 @@ static int usba_ep_disable(struct usb_ep *_ep)
649 649
650 if (!ep->desc) { 650 if (!ep->desc) {
651 spin_unlock_irqrestore(&udc->lock, flags); 651 spin_unlock_irqrestore(&udc->lock, flags);
652 DBG(DBG_ERR, "ep_disable: %s not enabled\n", ep->ep.name); 652 /* REVISIT because this driver disables endpoints in
653 * reset_all_endpoints() before calling disconnect(),
654 * most gadget drivers would trigger this non-error ...
655 */
656 if (udc->gadget.speed != USB_SPEED_UNKNOWN)
657 DBG(DBG_ERR, "ep_disable: %s not enabled\n",
658 ep->ep.name);
653 return -EINVAL; 659 return -EINVAL;
654 } 660 }
655 ep->desc = NULL; 661 ep->desc = NULL;
@@ -1032,8 +1038,6 @@ static struct usba_udc the_udc = {
1032 .release = nop_release, 1038 .release = nop_release,
1033 }, 1039 },
1034 }, 1040 },
1035
1036 .lock = SPIN_LOCK_UNLOCKED,
1037}; 1041};
1038 1042
1039/* 1043/*
@@ -1052,6 +1056,12 @@ static void reset_all_endpoints(struct usba_udc *udc)
1052 request_complete(ep, req, -ECONNRESET); 1056 request_complete(ep, req, -ECONNRESET);
1053 } 1057 }
1054 1058
1059 /* NOTE: normally, the next call to the gadget driver is in
1060 * charge of disabling endpoints... usually disconnect().
1061 * The exception would be entering a high speed test mode.
1062 *
1063 * FIXME remove this code ... and retest thoroughly.
1064 */
1055 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) { 1065 list_for_each_entry(ep, &udc->gadget.ep_list, ep.ep_list) {
1056 if (ep->desc) { 1066 if (ep->desc) {
1057 spin_unlock(&udc->lock); 1067 spin_unlock(&udc->lock);
@@ -1219,7 +1229,7 @@ static inline bool feature_is_ep_halt(struct usb_ctrlrequest *crq)
1219static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep, 1229static int handle_ep0_setup(struct usba_udc *udc, struct usba_ep *ep,
1220 struct usb_ctrlrequest *crq) 1230 struct usb_ctrlrequest *crq)
1221{ 1231{
1222 int retval = 0;; 1232 int retval = 0;
1223 1233
1224 switch (crq->bRequest) { 1234 switch (crq->bRequest) {
1225 case USB_REQ_GET_STATUS: { 1235 case USB_REQ_GET_STATUS: {
@@ -1693,6 +1703,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1693 usba_writel(udc, INT_CLR, USBA_END_OF_RESET); 1703 usba_writel(udc, INT_CLR, USBA_END_OF_RESET);
1694 reset_all_endpoints(udc); 1704 reset_all_endpoints(udc);
1695 1705
1706 if (udc->gadget.speed != USB_SPEED_UNKNOWN
1707 && udc->driver->disconnect) {
1708 udc->gadget.speed = USB_SPEED_UNKNOWN;
1709 spin_unlock(&udc->lock);
1710 udc->driver->disconnect(&udc->gadget);
1711 spin_lock(&udc->lock);
1712 }
1713
1696 if (status & USBA_HIGH_SPEED) { 1714 if (status & USBA_HIGH_SPEED) {
1697 DBG(DBG_BUS, "High-speed bus reset detected\n"); 1715 DBG(DBG_BUS, "High-speed bus reset detected\n");
1698 udc->gadget.speed = USB_SPEED_HIGH; 1716 udc->gadget.speed = USB_SPEED_HIGH;
@@ -1716,9 +1734,13 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
1716 | USBA_DET_SUSPEND 1734 | USBA_DET_SUSPEND
1717 | USBA_END_OF_RESUME)); 1735 | USBA_END_OF_RESUME));
1718 1736
1737 /*
1738 * Unclear why we hit this irregularly, e.g. in usbtest,
1739 * but it's clearly harmless...
1740 */
1719 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED)) 1741 if (!(usba_ep_readl(ep0, CFG) & USBA_EPT_MAPPED))
1720 dev_warn(&udc->pdev->dev, 1742 dev_dbg(&udc->pdev->dev,
1721 "WARNING: EP0 configuration is invalid!\n"); 1743 "ODD: EP0 configuration is invalid!\n");
1722 } 1744 }
1723 1745
1724 spin_unlock(&udc->lock); 1746 spin_unlock(&udc->lock);
@@ -1751,9 +1773,11 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
1751 reset_all_endpoints(udc); 1773 reset_all_endpoints(udc);
1752 toggle_bias(0); 1774 toggle_bias(0);
1753 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1775 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1754 spin_unlock(&udc->lock); 1776 if (udc->driver->disconnect) {
1755 udc->driver->disconnect(&udc->gadget); 1777 spin_unlock(&udc->lock);
1756 spin_lock(&udc->lock); 1778 udc->driver->disconnect(&udc->gadget);
1779 spin_lock(&udc->lock);
1780 }
1757 } 1781 }
1758 udc->vbus_prev = vbus; 1782 udc->vbus_prev = vbus;
1759 } 1783 }
@@ -1825,7 +1849,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1825 1849
1826 if (!udc->pdev) 1850 if (!udc->pdev)
1827 return -ENODEV; 1851 return -ENODEV;
1828 if (driver != udc->driver) 1852 if (driver != udc->driver || !driver->unbind)
1829 return -EINVAL; 1853 return -EINVAL;
1830 1854
1831 if (udc->vbus_pin != -1) 1855 if (udc->vbus_pin != -1)
@@ -1840,6 +1864,9 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
1840 toggle_bias(0); 1864 toggle_bias(0);
1841 usba_writel(udc, CTRL, USBA_DISABLE_MASK); 1865 usba_writel(udc, CTRL, USBA_DISABLE_MASK);
1842 1866
1867 if (udc->driver->disconnect)
1868 udc->driver->disconnect(&udc->gadget);
1869
1843 driver->unbind(&udc->gadget); 1870 driver->unbind(&udc->gadget);
1844 udc->gadget.dev.driver = NULL; 1871 udc->gadget.dev.driver = NULL;
1845 udc->driver = NULL; 1872 udc->driver = NULL;
@@ -1879,6 +1906,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
1879 goto err_get_hclk; 1906 goto err_get_hclk;
1880 } 1907 }
1881 1908
1909 spin_lock_init(&udc->lock);
1882 udc->pdev = pdev; 1910 udc->pdev = pdev;
1883 udc->pclk = pclk; 1911 udc->pclk = pclk;
1884 udc->hclk = hclk; 1912 udc->hclk = hclk;
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 75eba202f737..499b7a23f351 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -1546,7 +1546,6 @@ static __init void udc_init_data(struct pxa_udc *dev)
1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list); 1546 INIT_LIST_HEAD(&dev->gadget.ep0->ep_list);
1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0]; 1547 dev->udc_usb_ep[0].pxa_ep = &dev->pxa_ep[0];
1548 ep0_idle(dev); 1548 ep0_idle(dev);
1549 strcpy(dev->dev->bus_id, "");
1550 1549
1551 /* PXA endpoints init */ 1550 /* PXA endpoints init */
1552 for (i = 0; i < NR_PXA_ENDPOINTS; i++) { 1551 for (i = 0; i < NR_PXA_ENDPOINTS; i++) {
@@ -1746,13 +1745,10 @@ static void handle_ep0_ctrl_req(struct pxa_udc *udc,
1746 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i); 1745 ep_err(ep, "wrong to have extra bytes for setup : 0x%08x\n", i);
1747 } 1746 }
1748 1747
1749 le16_to_cpus(&u.r.wValue);
1750 le16_to_cpus(&u.r.wIndex);
1751 le16_to_cpus(&u.r.wLength);
1752
1753 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n", 1748 ep_dbg(ep, "SETUP %02x.%02x v%04x i%04x l%04x\n",
1754 u.r.bRequestType, u.r.bRequest, 1749 u.r.bRequestType, u.r.bRequest,
1755 u.r.wValue, u.r.wIndex, u.r.wLength); 1750 le16_to_cpu(u.r.wValue), le16_to_cpu(u.r.wIndex),
1751 le16_to_cpu(u.r.wLength));
1756 if (unlikely(have_extrabytes)) 1752 if (unlikely(have_extrabytes))
1757 goto stall; 1753 goto stall;
1758 1754
@@ -2296,7 +2292,8 @@ static void pxa_udc_shutdown(struct platform_device *_dev)
2296{ 2292{
2297 struct pxa_udc *udc = platform_get_drvdata(_dev); 2293 struct pxa_udc *udc = platform_get_drvdata(_dev);
2298 2294
2299 udc_disable(udc); 2295 if (udc_readl(udc, UDCCR) & UDCCR_UDE)
2296 udc_disable(udc);
2300} 2297}
2301 2298
2302#ifdef CONFIG_PM 2299#ifdef CONFIG_PM
@@ -2361,9 +2358,8 @@ static int pxa_udc_resume(struct platform_device *_dev)
2361 * Upon exit from sleep mode and before clearing OTGPH, 2358 * Upon exit from sleep mode and before clearing OTGPH,
2362 * Software must configure the USB OTG pad, UDC, and UHC 2359 * Software must configure the USB OTG pad, UDC, and UHC
2363 * to the state they were in before entering sleep mode. 2360 * to the state they were in before entering sleep mode.
2364 *
2365 * Should be : PSSR |= PSSR_OTGPH;
2366 */ 2361 */
2362 PSSR |= PSSR_OTGPH;
2367 2363
2368 return 0; 2364 return 0;
2369} 2365}
@@ -2387,6 +2383,9 @@ static struct platform_driver udc_driver = {
2387 2383
2388static int __init udc_init(void) 2384static int __init udc_init(void)
2389{ 2385{
2386 if (!cpu_is_pxa27x())
2387 return -ENODEV;
2388
2390 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2389 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
2391 return platform_driver_probe(&udc_driver, pxa_udc_probe); 2390 return platform_driver_probe(&udc_driver, pxa_udc_probe);
2392} 2391}
diff --git a/drivers/usb/gadget/pxa27x_udc.h b/drivers/usb/gadget/pxa27x_udc.h
index 1d1b7936ee11..97453db924ff 100644
--- a/drivers/usb/gadget/pxa27x_udc.h
+++ b/drivers/usb/gadget/pxa27x_udc.h
@@ -484,4 +484,12 @@ static inline struct pxa_udc *to_gadget_udc(struct usb_gadget *gadget)
484#define ep_warn(ep, fmt, arg...) \ 484#define ep_warn(ep, fmt, arg...) \
485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg) 485 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg)
486 486
487/*
488 * Cannot include pxa-regs.h, as register names are similar.
489 * So PSSR is redefined here. This should be removed once UDC registers will
490 * be gone from pxa-regs.h.
491 */
492#define PSSR __REG(0x40F00004) /* Power Manager Sleep Status */
493#define PSSR_OTGPH (1 << 6) /* OTG Peripheral Hold */
494
487#endif /* __LINUX_USB_GADGET_PXA27X_H */ 495#endif /* __LINUX_USB_GADGET_PXA27X_H */
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 54cdd6f94034..fa019fa73334 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -14,7 +14,6 @@
14 * This software is distributed under the terms of the GNU General 14 * This software is distributed under the terms of the GNU General
15 * Public License ("GPL") as published by the Free Software Foundation, 15 * Public License ("GPL") as published by the Free Software Foundation,
16 * either version 2 of that License or (at your option) any later version. 16 * either version 2 of that License or (at your option) any later version.
17 *
18 */ 17 */
19 18
20#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -33,7 +32,7 @@
33/* Defines */ 32/* Defines */
34 33
35#define GS_VERSION_STR "v2.2" 34#define GS_VERSION_STR "v2.2"
36#define GS_VERSION_NUM 0x0202 35#define GS_VERSION_NUM 0x2200
37 36
38#define GS_LONG_NAME "Gadget Serial" 37#define GS_LONG_NAME "Gadget Serial"
39#define GS_SHORT_NAME "g_serial" 38#define GS_SHORT_NAME "g_serial"
@@ -41,7 +40,11 @@
41#define GS_MAJOR 127 40#define GS_MAJOR 127
42#define GS_MINOR_START 0 41#define GS_MINOR_START 0
43 42
44#define GS_NUM_PORTS 16 43/* REVISIT only one port is supported for now;
44 * see gs_{send,recv}_packet() ... no multiplexing,
45 * and no support for multiple ACM devices.
46 */
47#define GS_NUM_PORTS 1
45 48
46#define GS_NUM_CONFIGS 1 49#define GS_NUM_CONFIGS 1
47#define GS_NO_CONFIG_ID 0 50#define GS_NO_CONFIG_ID 0
@@ -65,6 +68,9 @@
65 68
66#define GS_DEFAULT_USE_ACM 0 69#define GS_DEFAULT_USE_ACM 0
67 70
71/* 9600-8-N-1 ... matches init_termios.c_cflag and defaults
72 * expected by "usbser.sys" on MS-Windows.
73 */
68#define GS_DEFAULT_DTE_RATE 9600 74#define GS_DEFAULT_DTE_RATE 9600
69#define GS_DEFAULT_DATA_BITS 8 75#define GS_DEFAULT_DATA_BITS 8
70#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY 76#define GS_DEFAULT_PARITY USB_CDC_NO_PARITY
@@ -107,10 +113,6 @@ static int debug = 1;
107#define GS_NOTIFY_MAXPACKET 8 113#define GS_NOTIFY_MAXPACKET 8
108 114
109 115
110/* Structures */
111
112struct gs_dev;
113
114/* circular buffer */ 116/* circular buffer */
115struct gs_buf { 117struct gs_buf {
116 unsigned int buf_size; 118 unsigned int buf_size;
@@ -119,12 +121,6 @@ struct gs_buf {
119 char *buf_put; 121 char *buf_put;
120}; 122};
121 123
122/* list of requests */
123struct gs_req_entry {
124 struct list_head re_entry;
125 struct usb_request *re_req;
126};
127
128/* the port structure holds info for each port, one for each minor number */ 124/* the port structure holds info for each port, one for each minor number */
129struct gs_port { 125struct gs_port {
130 struct gs_dev *port_dev; /* pointer to device struct */ 126 struct gs_dev *port_dev; /* pointer to device struct */
@@ -164,26 +160,7 @@ struct gs_dev {
164 160
165/* Functions */ 161/* Functions */
166 162
167/* module */ 163/* tty driver internals */
168static int __init gs_module_init(void);
169static void __exit gs_module_exit(void);
170
171/* tty driver */
172static int gs_open(struct tty_struct *tty, struct file *file);
173static void gs_close(struct tty_struct *tty, struct file *file);
174static int gs_write(struct tty_struct *tty,
175 const unsigned char *buf, int count);
176static int gs_put_char(struct tty_struct *tty, unsigned char ch);
177static void gs_flush_chars(struct tty_struct *tty);
178static int gs_write_room(struct tty_struct *tty);
179static int gs_chars_in_buffer(struct tty_struct *tty);
180static void gs_throttle(struct tty_struct * tty);
181static void gs_unthrottle(struct tty_struct * tty);
182static void gs_break(struct tty_struct *tty, int break_state);
183static int gs_ioctl(struct tty_struct *tty, struct file *file,
184 unsigned int cmd, unsigned long arg);
185static void gs_set_termios(struct tty_struct *tty, struct ktermios *old);
186
187static int gs_send(struct gs_dev *dev); 164static int gs_send(struct gs_dev *dev);
188static int gs_send_packet(struct gs_dev *dev, char *packet, 165static int gs_send_packet(struct gs_dev *dev, char *packet,
189 unsigned int size); 166 unsigned int size);
@@ -192,19 +169,7 @@ static int gs_recv_packet(struct gs_dev *dev, char *packet,
192static void gs_read_complete(struct usb_ep *ep, struct usb_request *req); 169static void gs_read_complete(struct usb_ep *ep, struct usb_request *req);
193static void gs_write_complete(struct usb_ep *ep, struct usb_request *req); 170static void gs_write_complete(struct usb_ep *ep, struct usb_request *req);
194 171
195/* gadget driver */ 172/* gadget driver internals */
196static int gs_bind(struct usb_gadget *gadget);
197static void gs_unbind(struct usb_gadget *gadget);
198static int gs_setup(struct usb_gadget *gadget,
199 const struct usb_ctrlrequest *ctrl);
200static int gs_setup_standard(struct usb_gadget *gadget,
201 const struct usb_ctrlrequest *ctrl);
202static int gs_setup_class(struct usb_gadget *gadget,
203 const struct usb_ctrlrequest *ctrl);
204static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req);
205static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
206 struct usb_request *req);
207static void gs_disconnect(struct usb_gadget *gadget);
208static int gs_set_config(struct gs_dev *dev, unsigned config); 173static int gs_set_config(struct gs_dev *dev, unsigned config);
209static void gs_reset_config(struct gs_dev *dev); 174static void gs_reset_config(struct gs_dev *dev);
210static int gs_build_config_buf(u8 *buf, struct usb_gadget *g, 175static int gs_build_config_buf(u8 *buf, struct usb_gadget *g,
@@ -214,10 +179,6 @@ static struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned int len,
214 gfp_t kmalloc_flags); 179 gfp_t kmalloc_flags);
215static void gs_free_req(struct usb_ep *ep, struct usb_request *req); 180static void gs_free_req(struct usb_ep *ep, struct usb_request *req);
216 181
217static struct gs_req_entry *gs_alloc_req_entry(struct usb_ep *ep, unsigned len,
218 gfp_t kmalloc_flags);
219static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req);
220
221static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags); 182static int gs_alloc_ports(struct gs_dev *dev, gfp_t kmalloc_flags);
222static void gs_free_ports(struct gs_dev *dev); 183static void gs_free_ports(struct gs_dev *dev);
223 184
@@ -232,62 +193,15 @@ static unsigned int gs_buf_put(struct gs_buf *gb, const char *buf,
232static unsigned int gs_buf_get(struct gs_buf *gb, char *buf, 193static unsigned int gs_buf_get(struct gs_buf *gb, char *buf,
233 unsigned int count); 194 unsigned int count);
234 195
235/* external functions */
236extern int net2280_set_fifo_mode(struct usb_gadget *gadget, int mode);
237
238 196
239/* Globals */ 197/* Globals */
240 198
241static struct gs_dev *gs_device; 199static struct gs_dev *gs_device;
242 200
243static const char *EP_IN_NAME;
244static const char *EP_OUT_NAME;
245static const char *EP_NOTIFY_NAME;
246
247static struct mutex gs_open_close_lock[GS_NUM_PORTS]; 201static struct mutex gs_open_close_lock[GS_NUM_PORTS];
248 202
249static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
250static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
251
252static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
253
254static unsigned int use_acm = GS_DEFAULT_USE_ACM;
255
256
257/* tty driver struct */
258static const struct tty_operations gs_tty_ops = {
259 .open = gs_open,
260 .close = gs_close,
261 .write = gs_write,
262 .put_char = gs_put_char,
263 .flush_chars = gs_flush_chars,
264 .write_room = gs_write_room,
265 .ioctl = gs_ioctl,
266 .set_termios = gs_set_termios,
267 .throttle = gs_throttle,
268 .unthrottle = gs_unthrottle,
269 .break_ctl = gs_break,
270 .chars_in_buffer = gs_chars_in_buffer,
271};
272static struct tty_driver *gs_tty_driver;
273
274/* gadget driver struct */
275static struct usb_gadget_driver gs_gadget_driver = {
276#ifdef CONFIG_USB_GADGET_DUALSPEED
277 .speed = USB_SPEED_HIGH,
278#else
279 .speed = USB_SPEED_FULL,
280#endif /* CONFIG_USB_GADGET_DUALSPEED */
281 .function = GS_LONG_NAME,
282 .bind = gs_bind,
283 .unbind = gs_unbind,
284 .setup = gs_setup,
285 .disconnect = gs_disconnect,
286 .driver = {
287 .name = GS_SHORT_NAME,
288 },
289};
290 203
204/*-------------------------------------------------------------------------*/
291 205
292/* USB descriptors */ 206/* USB descriptors */
293 207
@@ -304,7 +218,6 @@ static char manufacturer[50];
304static struct usb_string gs_strings[] = { 218static struct usb_string gs_strings[] = {
305 { GS_MANUFACTURER_STR_ID, manufacturer }, 219 { GS_MANUFACTURER_STR_ID, manufacturer },
306 { GS_PRODUCT_STR_ID, GS_LONG_NAME }, 220 { GS_PRODUCT_STR_ID, GS_LONG_NAME },
307 { GS_SERIAL_STR_ID, "0" },
308 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" }, 221 { GS_BULK_CONFIG_STR_ID, "Gadget Serial Bulk" },
309 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" }, 222 { GS_ACM_CONFIG_STR_ID, "Gadget Serial CDC ACM" },
310 { GS_CONTROL_STR_ID, "Gadget Serial Control" }, 223 { GS_CONTROL_STR_ID, "Gadget Serial Control" },
@@ -327,7 +240,6 @@ static struct usb_device_descriptor gs_device_desc = {
327 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID), 240 .idProduct = __constant_cpu_to_le16(GS_PRODUCT_ID),
328 .iManufacturer = GS_MANUFACTURER_STR_ID, 241 .iManufacturer = GS_MANUFACTURER_STR_ID,
329 .iProduct = GS_PRODUCT_STR_ID, 242 .iProduct = GS_PRODUCT_STR_ID,
330 .iSerialNumber = GS_SERIAL_STR_ID,
331 .bNumConfigurations = GS_NUM_CONFIGS, 243 .bNumConfigurations = GS_NUM_CONFIGS,
332}; 244};
333 245
@@ -364,7 +276,7 @@ static const struct usb_interface_descriptor gs_bulk_interface_desc = {
364 .bDescriptorType = USB_DT_INTERFACE, 276 .bDescriptorType = USB_DT_INTERFACE,
365 .bInterfaceNumber = GS_BULK_INTERFACE_ID, 277 .bInterfaceNumber = GS_BULK_INTERFACE_ID,
366 .bNumEndpoints = 2, 278 .bNumEndpoints = 2,
367 .bInterfaceClass = USB_CLASS_CDC_DATA, 279 .bInterfaceClass = USB_CLASS_VENDOR_SPEC,
368 .bInterfaceSubClass = 0, 280 .bInterfaceSubClass = 0,
369 .bInterfaceProtocol = 0, 281 .bInterfaceProtocol = 0,
370 .iInterface = GS_DATA_STR_ID, 282 .iInterface = GS_DATA_STR_ID,
@@ -521,6 +433,8 @@ static const struct usb_descriptor_header *gs_acm_highspeed_function[] = {
521}; 433};
522 434
523 435
436/*-------------------------------------------------------------------------*/
437
524/* Module */ 438/* Module */
525MODULE_DESCRIPTION(GS_LONG_NAME); 439MODULE_DESCRIPTION(GS_LONG_NAME);
526MODULE_AUTHOR("Al Borchers"); 440MODULE_AUTHOR("Al Borchers");
@@ -531,84 +445,23 @@ module_param(debug, int, S_IRUGO|S_IWUSR);
531MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on"); 445MODULE_PARM_DESC(debug, "Enable debugging, 0=off, 1=on");
532#endif 446#endif
533 447
448static unsigned int read_q_size = GS_DEFAULT_READ_Q_SIZE;
534module_param(read_q_size, uint, S_IRUGO); 449module_param(read_q_size, uint, S_IRUGO);
535MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32"); 450MODULE_PARM_DESC(read_q_size, "Read request queue size, default=32");
536 451
452static unsigned int write_q_size = GS_DEFAULT_WRITE_Q_SIZE;
537module_param(write_q_size, uint, S_IRUGO); 453module_param(write_q_size, uint, S_IRUGO);
538MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32"); 454MODULE_PARM_DESC(write_q_size, "Write request queue size, default=32");
539 455
456static unsigned int write_buf_size = GS_DEFAULT_WRITE_BUF_SIZE;
540module_param(write_buf_size, uint, S_IRUGO); 457module_param(write_buf_size, uint, S_IRUGO);
541MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192"); 458MODULE_PARM_DESC(write_buf_size, "Write buffer size, default=8192");
542 459
460static unsigned int use_acm = GS_DEFAULT_USE_ACM;
543module_param(use_acm, uint, S_IRUGO); 461module_param(use_acm, uint, S_IRUGO);
544MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no"); 462MODULE_PARM_DESC(use_acm, "Use CDC ACM, 0=no, 1=yes, default=no");
545 463
546module_init(gs_module_init); 464/*-------------------------------------------------------------------------*/
547module_exit(gs_module_exit);
548
549/*
550* gs_module_init
551*
552* Register as a USB gadget driver and a tty driver.
553*/
554static int __init gs_module_init(void)
555{
556 int i;
557 int retval;
558
559 retval = usb_gadget_register_driver(&gs_gadget_driver);
560 if (retval) {
561 pr_err("gs_module_init: cannot register gadget driver, "
562 "ret=%d\n", retval);
563 return retval;
564 }
565
566 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
567 if (!gs_tty_driver)
568 return -ENOMEM;
569 gs_tty_driver->owner = THIS_MODULE;
570 gs_tty_driver->driver_name = GS_SHORT_NAME;
571 gs_tty_driver->name = "ttygs";
572 gs_tty_driver->major = GS_MAJOR;
573 gs_tty_driver->minor_start = GS_MINOR_START;
574 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
575 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
576 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
577 gs_tty_driver->init_termios = tty_std_termios;
578 gs_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
579 tty_set_operations(gs_tty_driver, &gs_tty_ops);
580
581 for (i=0; i < GS_NUM_PORTS; i++)
582 mutex_init(&gs_open_close_lock[i]);
583
584 retval = tty_register_driver(gs_tty_driver);
585 if (retval) {
586 usb_gadget_unregister_driver(&gs_gadget_driver);
587 put_tty_driver(gs_tty_driver);
588 pr_err("gs_module_init: cannot register tty driver, "
589 "ret=%d\n", retval);
590 return retval;
591 }
592
593 pr_info("gs_module_init: %s %s loaded\n",
594 GS_LONG_NAME, GS_VERSION_STR);
595 return 0;
596}
597
598/*
599* gs_module_exit
600*
601* Unregister as a tty driver and a USB gadget driver.
602*/
603static void __exit gs_module_exit(void)
604{
605 tty_unregister_driver(gs_tty_driver);
606 put_tty_driver(gs_tty_driver);
607 usb_gadget_unregister_driver(&gs_gadget_driver);
608
609 pr_info("gs_module_exit: %s %s unloaded\n",
610 GS_LONG_NAME, GS_VERSION_STR);
611}
612 465
613/* TTY Driver */ 466/* TTY Driver */
614 467
@@ -753,15 +606,15 @@ exit_unlock_dev:
753 * gs_close 606 * gs_close
754 */ 607 */
755 608
756#define GS_WRITE_FINISHED_EVENT_SAFELY(p) \ 609static int gs_write_finished_event_safely(struct gs_port *p)
757({ \ 610{
758 int cond; \ 611 int cond;
759 \ 612
760 spin_lock_irq(&(p)->port_lock); \ 613 spin_lock_irq(&(p)->port_lock);
761 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf); \ 614 cond = !(p)->port_dev || !gs_buf_data_avail((p)->port_write_buf);
762 spin_unlock_irq(&(p)->port_lock); \ 615 spin_unlock_irq(&(p)->port_lock);
763 cond; \ 616 return cond;
764}) 617}
765 618
766static void gs_close(struct tty_struct *tty, struct file *file) 619static void gs_close(struct tty_struct *tty, struct file *file)
767{ 620{
@@ -807,7 +660,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
807 if (gs_buf_data_avail(port->port_write_buf) > 0) { 660 if (gs_buf_data_avail(port->port_write_buf) > 0) {
808 spin_unlock_irq(&port->port_lock); 661 spin_unlock_irq(&port->port_lock);
809 wait_event_interruptible_timeout(port->port_write_wait, 662 wait_event_interruptible_timeout(port->port_write_wait,
810 GS_WRITE_FINISHED_EVENT_SAFELY(port), 663 gs_write_finished_event_safely(port),
811 GS_CLOSE_TIMEOUT * HZ); 664 GS_CLOSE_TIMEOUT * HZ);
812 spin_lock_irq(&port->port_lock); 665 spin_lock_irq(&port->port_lock);
813 } 666 }
@@ -1065,6 +918,23 @@ static void gs_set_termios(struct tty_struct *tty, struct ktermios *old)
1065{ 918{
1066} 919}
1067 920
921static const struct tty_operations gs_tty_ops = {
922 .open = gs_open,
923 .close = gs_close,
924 .write = gs_write,
925 .put_char = gs_put_char,
926 .flush_chars = gs_flush_chars,
927 .write_room = gs_write_room,
928 .ioctl = gs_ioctl,
929 .set_termios = gs_set_termios,
930 .throttle = gs_throttle,
931 .unthrottle = gs_unthrottle,
932 .break_ctl = gs_break,
933 .chars_in_buffer = gs_chars_in_buffer,
934};
935
936/*-------------------------------------------------------------------------*/
937
1068/* 938/*
1069* gs_send 939* gs_send
1070* 940*
@@ -1080,7 +950,6 @@ static int gs_send(struct gs_dev *dev)
1080 unsigned long flags; 950 unsigned long flags;
1081 struct usb_ep *ep; 951 struct usb_ep *ep;
1082 struct usb_request *req; 952 struct usb_request *req;
1083 struct gs_req_entry *req_entry;
1084 953
1085 if (dev == NULL) { 954 if (dev == NULL) {
1086 pr_err("gs_send: NULL device pointer\n"); 955 pr_err("gs_send: NULL device pointer\n");
@@ -1093,10 +962,8 @@ static int gs_send(struct gs_dev *dev)
1093 962
1094 while(!list_empty(&dev->dev_req_list)) { 963 while(!list_empty(&dev->dev_req_list)) {
1095 964
1096 req_entry = list_entry(dev->dev_req_list.next, 965 req = list_entry(dev->dev_req_list.next,
1097 struct gs_req_entry, re_entry); 966 struct usb_request, list);
1098
1099 req = req_entry->re_req;
1100 967
1101 len = gs_send_packet(dev, req->buf, ep->maxpacket); 968 len = gs_send_packet(dev, req->buf, ep->maxpacket);
1102 969
@@ -1106,7 +973,7 @@ static int gs_send(struct gs_dev *dev)
1106 *((unsigned char *)req->buf), 973 *((unsigned char *)req->buf),
1107 *((unsigned char *)req->buf+1), 974 *((unsigned char *)req->buf+1),
1108 *((unsigned char *)req->buf+2)); 975 *((unsigned char *)req->buf+2));
1109 list_del(&req_entry->re_entry); 976 list_del(&req->list);
1110 req->length = len; 977 req->length = len;
1111 spin_unlock_irqrestore(&dev->dev_lock, flags); 978 spin_unlock_irqrestore(&dev->dev_lock, flags);
1112 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 979 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) {
@@ -1289,7 +1156,6 @@ requeue:
1289static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) 1156static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1290{ 1157{
1291 struct gs_dev *dev = ep->driver_data; 1158 struct gs_dev *dev = ep->driver_data;
1292 struct gs_req_entry *gs_req = req->context;
1293 1159
1294 if (dev == NULL) { 1160 if (dev == NULL) {
1295 pr_err("gs_write_complete: NULL device pointer\n"); 1161 pr_err("gs_write_complete: NULL device pointer\n");
@@ -1300,13 +1166,8 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req)
1300 case 0: 1166 case 0:
1301 /* normal completion */ 1167 /* normal completion */
1302requeue: 1168requeue:
1303 if (gs_req == NULL) {
1304 pr_err("gs_write_complete: NULL request pointer\n");
1305 return;
1306 }
1307
1308 spin_lock(&dev->dev_lock); 1169 spin_lock(&dev->dev_lock);
1309 list_add(&gs_req->re_entry, &dev->dev_req_list); 1170 list_add(&req->list, &dev->dev_req_list);
1310 spin_unlock(&dev->dev_lock); 1171 spin_unlock(&dev->dev_lock);
1311 1172
1312 gs_send(dev); 1173 gs_send(dev);
@@ -1328,9 +1189,39 @@ requeue:
1328 } 1189 }
1329} 1190}
1330 1191
1192/*-------------------------------------------------------------------------*/
1193
1331/* Gadget Driver */ 1194/* Gadget Driver */
1332 1195
1333/* 1196/*
1197 * gs_unbind
1198 *
1199 * Called on module unload. Frees the control request and device
1200 * structure.
1201 */
1202static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1203{
1204 struct gs_dev *dev = get_gadget_data(gadget);
1205
1206 gs_device = NULL;
1207
1208 /* read/write requests already freed, only control request remains */
1209 if (dev != NULL) {
1210 if (dev->dev_ctrl_req != NULL) {
1211 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1212 dev->dev_ctrl_req = NULL;
1213 }
1214 gs_reset_config(dev);
1215 gs_free_ports(dev);
1216 kfree(dev);
1217 set_gadget_data(gadget, NULL);
1218 }
1219
1220 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1221 GS_VERSION_STR);
1222}
1223
1224/*
1334 * gs_bind 1225 * gs_bind
1335 * 1226 *
1336 * Called on module load. Allocates and initializes the device 1227 * Called on module load. Allocates and initializes the device
@@ -1362,19 +1253,23 @@ static int __init gs_bind(struct usb_gadget *gadget)
1362 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099); 1253 __constant_cpu_to_le16(GS_VERSION_NUM|0x0099);
1363 } 1254 }
1364 1255
1256 dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL);
1257 if (dev == NULL)
1258 return -ENOMEM;
1259
1365 usb_ep_autoconfig_reset(gadget); 1260 usb_ep_autoconfig_reset(gadget);
1366 1261
1367 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc); 1262 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_in_desc);
1368 if (!ep) 1263 if (!ep)
1369 goto autoconf_fail; 1264 goto autoconf_fail;
1370 EP_IN_NAME = ep->name; 1265 dev->dev_in_ep = ep;
1371 ep->driver_data = ep; /* claim the endpoint */ 1266 ep->driver_data = dev; /* claim the endpoint */
1372 1267
1373 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc); 1268 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_out_desc);
1374 if (!ep) 1269 if (!ep)
1375 goto autoconf_fail; 1270 goto autoconf_fail;
1376 EP_OUT_NAME = ep->name; 1271 dev->dev_out_ep = ep;
1377 ep->driver_data = ep; /* claim the endpoint */ 1272 ep->driver_data = dev; /* claim the endpoint */
1378 1273
1379 if (use_acm) { 1274 if (use_acm) {
1380 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc); 1275 ep = usb_ep_autoconfig(gadget, &gs_fullspeed_notify_desc);
@@ -1384,8 +1279,8 @@ static int __init gs_bind(struct usb_gadget *gadget)
1384 } 1279 }
1385 gs_device_desc.idProduct = __constant_cpu_to_le16( 1280 gs_device_desc.idProduct = __constant_cpu_to_le16(
1386 GS_CDC_PRODUCT_ID), 1281 GS_CDC_PRODUCT_ID),
1387 EP_NOTIFY_NAME = ep->name; 1282 dev->dev_notify_ep = ep;
1388 ep->driver_data = ep; /* claim the endpoint */ 1283 ep->driver_data = dev; /* claim the endpoint */
1389 } 1284 }
1390 1285
1391 gs_device_desc.bDeviceClass = use_acm 1286 gs_device_desc.bDeviceClass = use_acm
@@ -1415,9 +1310,7 @@ static int __init gs_bind(struct usb_gadget *gadget)
1415 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP; 1310 gs_acm_config_desc.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
1416 } 1311 }
1417 1312
1418 gs_device = dev = kzalloc(sizeof(struct gs_dev), GFP_KERNEL); 1313 gs_device = dev;
1419 if (dev == NULL)
1420 return -ENOMEM;
1421 1314
1422 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s", 1315 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s",
1423 init_utsname()->sysname, init_utsname()->release, 1316 init_utsname()->sysname, init_utsname()->release,
@@ -1441,8 +1334,6 @@ static int __init gs_bind(struct usb_gadget *gadget)
1441 gs_unbind(gadget); 1334 gs_unbind(gadget);
1442 return -ENOMEM; 1335 return -ENOMEM;
1443 } 1336 }
1444 dev->dev_ctrl_req->complete = gs_setup_complete;
1445
1446 gadget->ep0->driver_data = dev; 1337 gadget->ep0->driver_data = dev;
1447 1338
1448 pr_info("gs_bind: %s %s bound\n", 1339 pr_info("gs_bind: %s %s bound\n",
@@ -1451,99 +1342,11 @@ static int __init gs_bind(struct usb_gadget *gadget)
1451 return 0; 1342 return 0;
1452 1343
1453autoconf_fail: 1344autoconf_fail:
1345 kfree(dev);
1454 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name); 1346 pr_err("gs_bind: cannot autoconfigure on %s\n", gadget->name);
1455 return -ENODEV; 1347 return -ENODEV;
1456} 1348}
1457 1349
1458/*
1459 * gs_unbind
1460 *
1461 * Called on module unload. Frees the control request and device
1462 * structure.
1463 */
1464static void /* __init_or_exit */ gs_unbind(struct usb_gadget *gadget)
1465{
1466 struct gs_dev *dev = get_gadget_data(gadget);
1467
1468 gs_device = NULL;
1469
1470 /* read/write requests already freed, only control request remains */
1471 if (dev != NULL) {
1472 if (dev->dev_ctrl_req != NULL) {
1473 gs_free_req(gadget->ep0, dev->dev_ctrl_req);
1474 dev->dev_ctrl_req = NULL;
1475 }
1476 gs_free_ports(dev);
1477 if (dev->dev_notify_ep)
1478 usb_ep_disable(dev->dev_notify_ep);
1479 if (dev->dev_in_ep)
1480 usb_ep_disable(dev->dev_in_ep);
1481 if (dev->dev_out_ep)
1482 usb_ep_disable(dev->dev_out_ep);
1483 kfree(dev);
1484 set_gadget_data(gadget, NULL);
1485 }
1486
1487 pr_info("gs_unbind: %s %s unbound\n", GS_LONG_NAME,
1488 GS_VERSION_STR);
1489}
1490
1491/*
1492 * gs_setup
1493 *
1494 * Implements all the control endpoint functionality that's not
1495 * handled in hardware or the hardware driver.
1496 *
1497 * Returns the size of the data sent to the host, or a negative
1498 * error number.
1499 */
1500static int gs_setup(struct usb_gadget *gadget,
1501 const struct usb_ctrlrequest *ctrl)
1502{
1503 int ret = -EOPNOTSUPP;
1504 struct gs_dev *dev = get_gadget_data(gadget);
1505 struct usb_request *req = dev->dev_ctrl_req;
1506 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1507 u16 wValue = le16_to_cpu(ctrl->wValue);
1508 u16 wLength = le16_to_cpu(ctrl->wLength);
1509
1510 req->complete = gs_setup_complete;
1511
1512 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1513 case USB_TYPE_STANDARD:
1514 ret = gs_setup_standard(gadget,ctrl);
1515 break;
1516
1517 case USB_TYPE_CLASS:
1518 ret = gs_setup_class(gadget,ctrl);
1519 break;
1520
1521 default:
1522 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1523 "value=%04x, index=%04x, length=%d\n",
1524 ctrl->bRequestType, ctrl->bRequest,
1525 wValue, wIndex, wLength);
1526 break;
1527 }
1528
1529 /* respond with data transfer before status phase? */
1530 if (ret >= 0) {
1531 req->length = ret;
1532 req->zero = ret < wLength
1533 && (ret % gadget->ep0->maxpacket) == 0;
1534 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1535 if (ret < 0) {
1536 pr_err("gs_setup: cannot queue response, ret=%d\n",
1537 ret);
1538 req->status = 0;
1539 gs_setup_complete(gadget->ep0, req);
1540 }
1541 }
1542
1543 /* device either stalls (ret < 0) or reports success */
1544 return ret;
1545}
1546
1547static int gs_setup_standard(struct usb_gadget *gadget, 1350static int gs_setup_standard(struct usb_gadget *gadget,
1548 const struct usb_ctrlrequest *ctrl) 1351 const struct usb_ctrlrequest *ctrl)
1549{ 1352{
@@ -1673,6 +1476,42 @@ set_interface_done:
1673 return ret; 1476 return ret;
1674} 1477}
1675 1478
1479static void gs_setup_complete_set_line_coding(struct usb_ep *ep,
1480 struct usb_request *req)
1481{
1482 struct gs_dev *dev = ep->driver_data;
1483 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */
1484
1485 switch (req->status) {
1486 case 0:
1487 /* normal completion */
1488 if (req->actual != sizeof(port->port_line_coding))
1489 usb_ep_set_halt(ep);
1490 else if (port) {
1491 struct usb_cdc_line_coding *value = req->buf;
1492
1493 /* REVISIT: we currently just remember this data.
1494 * If we change that, (a) validate it first, then
1495 * (b) update whatever hardware needs updating.
1496 */
1497 spin_lock(&port->port_lock);
1498 port->port_line_coding = *value;
1499 spin_unlock(&port->port_lock);
1500 }
1501 break;
1502
1503 case -ESHUTDOWN:
1504 /* disconnect */
1505 gs_free_req(ep, req);
1506 break;
1507
1508 default:
1509 /* unexpected */
1510 break;
1511 }
1512 return;
1513}
1514
1676static int gs_setup_class(struct usb_gadget *gadget, 1515static int gs_setup_class(struct usb_gadget *gadget,
1677 const struct usb_ctrlrequest *ctrl) 1516 const struct usb_ctrlrequest *ctrl)
1678{ 1517{
@@ -1734,52 +1573,72 @@ static int gs_setup_class(struct usb_gadget *gadget,
1734 return ret; 1573 return ret;
1735} 1574}
1736 1575
1737static void gs_setup_complete_set_line_coding(struct usb_ep *ep, 1576/*
1738 struct usb_request *req) 1577 * gs_setup_complete
1578 */
1579static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req)
1739{ 1580{
1740 struct gs_dev *dev = ep->driver_data; 1581 if (req->status || req->actual != req->length) {
1741 struct gs_port *port = dev->dev_port[0]; /* ACM only has one port */ 1582 pr_err("gs_setup_complete: status error, status=%d, "
1583 "actual=%d, length=%d\n",
1584 req->status, req->actual, req->length);
1585 }
1586}
1742 1587
1743 switch (req->status) { 1588/*
1744 case 0: 1589 * gs_setup
1745 /* normal completion */ 1590 *
1746 if (req->actual != sizeof(port->port_line_coding)) 1591 * Implements all the control endpoint functionality that's not
1747 usb_ep_set_halt(ep); 1592 * handled in hardware or the hardware driver.
1748 else if (port) { 1593 *
1749 struct usb_cdc_line_coding *value = req->buf; 1594 * Returns the size of the data sent to the host, or a negative
1595 * error number.
1596 */
1597static int gs_setup(struct usb_gadget *gadget,
1598 const struct usb_ctrlrequest *ctrl)
1599{
1600 int ret = -EOPNOTSUPP;
1601 struct gs_dev *dev = get_gadget_data(gadget);
1602 struct usb_request *req = dev->dev_ctrl_req;
1603 u16 wIndex = le16_to_cpu(ctrl->wIndex);
1604 u16 wValue = le16_to_cpu(ctrl->wValue);
1605 u16 wLength = le16_to_cpu(ctrl->wLength);
1750 1606
1751 /* REVISIT: we currently just remember this data. 1607 req->complete = gs_setup_complete;
1752 * If we change that, (a) validate it first, then 1608
1753 * (b) update whatever hardware needs updating. 1609 switch (ctrl->bRequestType & USB_TYPE_MASK) {
1754 */ 1610 case USB_TYPE_STANDARD:
1755 spin_lock(&port->port_lock); 1611 ret = gs_setup_standard(gadget, ctrl);
1756 port->port_line_coding = *value;
1757 spin_unlock(&port->port_lock);
1758 }
1759 break; 1612 break;
1760 1613
1761 case -ESHUTDOWN: 1614 case USB_TYPE_CLASS:
1762 /* disconnect */ 1615 ret = gs_setup_class(gadget, ctrl);
1763 gs_free_req(ep, req);
1764 break; 1616 break;
1765 1617
1766 default: 1618 default:
1767 /* unexpected */ 1619 pr_err("gs_setup: unknown request, type=%02x, request=%02x, "
1620 "value=%04x, index=%04x, length=%d\n",
1621 ctrl->bRequestType, ctrl->bRequest,
1622 wValue, wIndex, wLength);
1768 break; 1623 break;
1769 } 1624 }
1770 return;
1771}
1772 1625
1773/* 1626 /* respond with data transfer before status phase? */
1774 * gs_setup_complete 1627 if (ret >= 0) {
1775 */ 1628 req->length = ret;
1776static void gs_setup_complete(struct usb_ep *ep, struct usb_request *req) 1629 req->zero = ret < wLength
1777{ 1630 && (ret % gadget->ep0->maxpacket) == 0;
1778 if (req->status || req->actual != req->length) { 1631 ret = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
1779 pr_err("gs_setup_complete: status error, status=%d, " 1632 if (ret < 0) {
1780 "actual=%d, length=%d\n", 1633 pr_err("gs_setup: cannot queue response, ret=%d\n",
1781 req->status, req->actual, req->length); 1634 ret);
1635 req->status = 0;
1636 gs_setup_complete(gadget->ep0, req);
1637 }
1782 } 1638 }
1639
1640 /* device either stalls (ret < 0) or reports success */
1641 return ret;
1783} 1642}
1784 1643
1785/* 1644/*
@@ -1811,6 +1670,23 @@ static void gs_disconnect(struct usb_gadget *gadget)
1811 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME); 1670 pr_info("gs_disconnect: %s disconnected\n", GS_LONG_NAME);
1812} 1671}
1813 1672
1673static struct usb_gadget_driver gs_gadget_driver = {
1674#ifdef CONFIG_USB_GADGET_DUALSPEED
1675 .speed = USB_SPEED_HIGH,
1676#else
1677 .speed = USB_SPEED_FULL,
1678#endif /* CONFIG_USB_GADGET_DUALSPEED */
1679 .function = GS_LONG_NAME,
1680 .bind = gs_bind,
1681 .unbind = gs_unbind,
1682 .setup = gs_setup,
1683 .disconnect = gs_disconnect,
1684 .driver = {
1685 .name = GS_SHORT_NAME,
1686 .owner = THIS_MODULE,
1687 },
1688};
1689
1814/* 1690/*
1815 * gs_set_config 1691 * gs_set_config
1816 * 1692 *
@@ -1826,9 +1702,8 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1826 int ret = 0; 1702 int ret = 0;
1827 struct usb_gadget *gadget = dev->dev_gadget; 1703 struct usb_gadget *gadget = dev->dev_gadget;
1828 struct usb_ep *ep; 1704 struct usb_ep *ep;
1829 struct usb_endpoint_descriptor *ep_desc; 1705 struct usb_endpoint_descriptor *out, *in, *notify;
1830 struct usb_request *req; 1706 struct usb_request *req;
1831 struct gs_req_entry *req_entry;
1832 1707
1833 if (dev == NULL) { 1708 if (dev == NULL) {
1834 pr_err("gs_set_config: NULL device pointer\n"); 1709 pr_err("gs_set_config: NULL device pointer\n");
@@ -1846,86 +1721,62 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1846 case GS_BULK_CONFIG_ID: 1721 case GS_BULK_CONFIG_ID:
1847 if (use_acm) 1722 if (use_acm)
1848 return -EINVAL; 1723 return -EINVAL;
1849 /* device specific optimizations */
1850 if (gadget_is_net2280(gadget))
1851 net2280_set_fifo_mode(gadget, 1);
1852 break; 1724 break;
1853 case GS_ACM_CONFIG_ID: 1725 case GS_ACM_CONFIG_ID:
1854 if (!use_acm) 1726 if (!use_acm)
1855 return -EINVAL; 1727 return -EINVAL;
1856 /* device specific optimizations */
1857 if (gadget_is_net2280(gadget))
1858 net2280_set_fifo_mode(gadget, 1);
1859 break; 1728 break;
1860 default: 1729 default:
1861 return -EINVAL; 1730 return -EINVAL;
1862 } 1731 }
1863 1732
1864 dev->dev_config = config; 1733 in = choose_ep_desc(gadget,
1865 1734 &gs_highspeed_in_desc,
1866 gadget_for_each_ep(ep, gadget) { 1735 &gs_fullspeed_in_desc);
1867 1736 out = choose_ep_desc(gadget,
1868 if (EP_NOTIFY_NAME 1737 &gs_highspeed_out_desc,
1869 && strcmp(ep->name, EP_NOTIFY_NAME) == 0) { 1738 &gs_fullspeed_out_desc);
1870 ep_desc = choose_ep_desc(gadget, 1739 notify = dev->dev_notify_ep
1740 ? choose_ep_desc(gadget,
1871 &gs_highspeed_notify_desc, 1741 &gs_highspeed_notify_desc,
1872 &gs_fullspeed_notify_desc); 1742 &gs_fullspeed_notify_desc)
1873 ret = usb_ep_enable(ep,ep_desc); 1743 : NULL;
1874 if (ret == 0) {
1875 ep->driver_data = dev;
1876 dev->dev_notify_ep = ep;
1877 dev->dev_notify_ep_desc = ep_desc;
1878 } else {
1879 pr_err("gs_set_config: cannot enable NOTIFY "
1880 "endpoint %s, ret=%d\n",
1881 ep->name, ret);
1882 goto exit_reset_config;
1883 }
1884 }
1885
1886 else if (strcmp(ep->name, EP_IN_NAME) == 0) {
1887 ep_desc = choose_ep_desc(gadget,
1888 &gs_highspeed_in_desc,
1889 &gs_fullspeed_in_desc);
1890 ret = usb_ep_enable(ep,ep_desc);
1891 if (ret == 0) {
1892 ep->driver_data = dev;
1893 dev->dev_in_ep = ep;
1894 dev->dev_in_ep_desc = ep_desc;
1895 } else {
1896 pr_err("gs_set_config: cannot enable IN "
1897 "endpoint %s, ret=%d\n",
1898 ep->name, ret);
1899 goto exit_reset_config;
1900 }
1901 }
1902 1744
1903 else if (strcmp(ep->name, EP_OUT_NAME) == 0) { 1745 ret = usb_ep_enable(dev->dev_in_ep, in);
1904 ep_desc = choose_ep_desc(gadget, 1746 if (ret == 0) {
1905 &gs_highspeed_out_desc, 1747 dev->dev_in_ep_desc = in;
1906 &gs_fullspeed_out_desc); 1748 } else {
1907 ret = usb_ep_enable(ep,ep_desc); 1749 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1908 if (ret == 0) { 1750 __func__, "IN", dev->dev_in_ep->name, ret);
1909 ep->driver_data = dev; 1751 return ret;
1910 dev->dev_out_ep = ep; 1752 }
1911 dev->dev_out_ep_desc = ep_desc;
1912 } else {
1913 pr_err("gs_set_config: cannot enable OUT "
1914 "endpoint %s, ret=%d\n",
1915 ep->name, ret);
1916 goto exit_reset_config;
1917 }
1918 }
1919 1753
1754 ret = usb_ep_enable(dev->dev_out_ep, out);
1755 if (ret == 0) {
1756 dev->dev_out_ep_desc = out;
1757 } else {
1758 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1759 __func__, "OUT", dev->dev_out_ep->name, ret);
1760fail0:
1761 usb_ep_disable(dev->dev_in_ep);
1762 return ret;
1920 } 1763 }
1921 1764
1922 if (dev->dev_in_ep == NULL || dev->dev_out_ep == NULL 1765 if (notify) {
1923 || (config != GS_BULK_CONFIG_ID && dev->dev_notify_ep == NULL)) { 1766 ret = usb_ep_enable(dev->dev_notify_ep, notify);
1924 pr_err("gs_set_config: cannot find endpoints\n"); 1767 if (ret == 0) {
1925 ret = -ENODEV; 1768 dev->dev_notify_ep_desc = notify;
1926 goto exit_reset_config; 1769 } else {
1770 pr_debug("%s: cannot enable %s %s, ret=%d\n",
1771 __func__, "NOTIFY",
1772 dev->dev_notify_ep->name, ret);
1773 usb_ep_disable(dev->dev_out_ep);
1774 goto fail0;
1775 }
1927 } 1776 }
1928 1777
1778 dev->dev_config = config;
1779
1929 /* allocate and queue read requests */ 1780 /* allocate and queue read requests */
1930 ep = dev->dev_out_ep; 1781 ep = dev->dev_out_ep;
1931 for (i=0; i<read_q_size && ret == 0; i++) { 1782 for (i=0; i<read_q_size && ret == 0; i++) {
@@ -1946,9 +1797,10 @@ static int gs_set_config(struct gs_dev *dev, unsigned config)
1946 /* allocate write requests, and put on free list */ 1797 /* allocate write requests, and put on free list */
1947 ep = dev->dev_in_ep; 1798 ep = dev->dev_in_ep;
1948 for (i=0; i<write_q_size; i++) { 1799 for (i=0; i<write_q_size; i++) {
1949 if ((req_entry=gs_alloc_req_entry(ep, ep->maxpacket, GFP_ATOMIC))) { 1800 req = gs_alloc_req(ep, ep->maxpacket, GFP_ATOMIC);
1950 req_entry->re_req->complete = gs_write_complete; 1801 if (req) {
1951 list_add(&req_entry->re_entry, &dev->dev_req_list); 1802 req->complete = gs_write_complete;
1803 list_add(&req->list, &dev->dev_req_list);
1952 } else { 1804 } else {
1953 pr_err("gs_set_config: cannot allocate " 1805 pr_err("gs_set_config: cannot allocate "
1954 "write requests\n"); 1806 "write requests\n");
@@ -1986,7 +1838,7 @@ exit_reset_config:
1986 */ 1838 */
1987static void gs_reset_config(struct gs_dev *dev) 1839static void gs_reset_config(struct gs_dev *dev)
1988{ 1840{
1989 struct gs_req_entry *req_entry; 1841 struct usb_request *req;
1990 1842
1991 if (dev == NULL) { 1843 if (dev == NULL) {
1992 pr_err("gs_reset_config: NULL device pointer\n"); 1844 pr_err("gs_reset_config: NULL device pointer\n");
@@ -2000,26 +1852,18 @@ static void gs_reset_config(struct gs_dev *dev)
2000 1852
2001 /* free write requests on the free list */ 1853 /* free write requests on the free list */
2002 while(!list_empty(&dev->dev_req_list)) { 1854 while(!list_empty(&dev->dev_req_list)) {
2003 req_entry = list_entry(dev->dev_req_list.next, 1855 req = list_entry(dev->dev_req_list.next,
2004 struct gs_req_entry, re_entry); 1856 struct usb_request, list);
2005 list_del(&req_entry->re_entry); 1857 list_del(&req->list);
2006 gs_free_req_entry(dev->dev_in_ep, req_entry); 1858 gs_free_req(dev->dev_in_ep, req);
2007 } 1859 }
2008 1860
2009 /* disable endpoints, forcing completion of pending i/o; */ 1861 /* disable endpoints, forcing completion of pending i/o; */
2010 /* completion handlers free their requests in this case */ 1862 /* completion handlers free their requests in this case */
2011 if (dev->dev_notify_ep) { 1863 if (dev->dev_notify_ep)
2012 usb_ep_disable(dev->dev_notify_ep); 1864 usb_ep_disable(dev->dev_notify_ep);
2013 dev->dev_notify_ep = NULL; 1865 usb_ep_disable(dev->dev_in_ep);
2014 } 1866 usb_ep_disable(dev->dev_out_ep);
2015 if (dev->dev_in_ep) {
2016 usb_ep_disable(dev->dev_in_ep);
2017 dev->dev_in_ep = NULL;
2018 }
2019 if (dev->dev_out_ep) {
2020 usb_ep_disable(dev->dev_out_ep);
2021 dev->dev_out_ep = NULL;
2022 }
2023} 1867}
2024 1868
2025/* 1869/*
@@ -2113,46 +1957,6 @@ static void gs_free_req(struct usb_ep *ep, struct usb_request *req)
2113} 1957}
2114 1958
2115/* 1959/*
2116 * gs_alloc_req_entry
2117 *
2118 * Allocates a request and its buffer, using the given
2119 * endpoint, buffer len, and kmalloc flags.
2120 */
2121static struct gs_req_entry *
2122gs_alloc_req_entry(struct usb_ep *ep, unsigned len, gfp_t kmalloc_flags)
2123{
2124 struct gs_req_entry *req;
2125
2126 req = kmalloc(sizeof(struct gs_req_entry), kmalloc_flags);
2127 if (req == NULL)
2128 return NULL;
2129
2130 req->re_req = gs_alloc_req(ep, len, kmalloc_flags);
2131 if (req->re_req == NULL) {
2132 kfree(req);
2133 return NULL;
2134 }
2135
2136 req->re_req->context = req;
2137
2138 return req;
2139}
2140
2141/*
2142 * gs_free_req_entry
2143 *
2144 * Frees a request and its buffer.
2145 */
2146static void gs_free_req_entry(struct usb_ep *ep, struct gs_req_entry *req)
2147{
2148 if (ep != NULL && req != NULL) {
2149 if (req->re_req != NULL)
2150 gs_free_req(ep, req->re_req);
2151 kfree(req);
2152 }
2153}
2154
2155/*
2156 * gs_alloc_ports 1960 * gs_alloc_ports
2157 * 1961 *
2158 * Allocate all ports and set the gs_dev struct to point to them. 1962 * Allocate all ports and set the gs_dev struct to point to them.
@@ -2233,6 +2037,8 @@ static void gs_free_ports(struct gs_dev *dev)
2233 } 2037 }
2234} 2038}
2235 2039
2040/*-------------------------------------------------------------------------*/
2041
2236/* Circular Buffer */ 2042/* Circular Buffer */
2237 2043
2238/* 2044/*
@@ -2393,3 +2199,77 @@ gs_buf_get(struct gs_buf *gb, char *buf, unsigned int count)
2393 2199
2394 return count; 2200 return count;
2395} 2201}
2202
2203/*-------------------------------------------------------------------------*/
2204
2205static struct tty_driver *gs_tty_driver;
2206
2207/*
2208 * gs_module_init
2209 *
2210 * Register as a USB gadget driver and a tty driver.
2211 */
2212static int __init gs_module_init(void)
2213{
2214 int i;
2215 int retval;
2216
2217 retval = usb_gadget_register_driver(&gs_gadget_driver);
2218 if (retval) {
2219 pr_err("gs_module_init: cannot register gadget driver, "
2220 "ret=%d\n", retval);
2221 return retval;
2222 }
2223
2224 gs_tty_driver = alloc_tty_driver(GS_NUM_PORTS);
2225 if (!gs_tty_driver)
2226 return -ENOMEM;
2227 gs_tty_driver->owner = THIS_MODULE;
2228 gs_tty_driver->driver_name = GS_SHORT_NAME;
2229 gs_tty_driver->name = "ttygs";
2230 gs_tty_driver->major = GS_MAJOR;
2231 gs_tty_driver->minor_start = GS_MINOR_START;
2232 gs_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
2233 gs_tty_driver->subtype = SERIAL_TYPE_NORMAL;
2234 gs_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
2235 gs_tty_driver->init_termios = tty_std_termios;
2236 /* must match GS_DEFAULT_DTE_RATE and friends */
2237 gs_tty_driver->init_termios.c_cflag =
2238 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2239 gs_tty_driver->init_termios.c_ispeed = GS_DEFAULT_DTE_RATE;
2240 gs_tty_driver->init_termios.c_ospeed = GS_DEFAULT_DTE_RATE;
2241 tty_set_operations(gs_tty_driver, &gs_tty_ops);
2242
2243 for (i = 0; i < GS_NUM_PORTS; i++)
2244 mutex_init(&gs_open_close_lock[i]);
2245
2246 retval = tty_register_driver(gs_tty_driver);
2247 if (retval) {
2248 usb_gadget_unregister_driver(&gs_gadget_driver);
2249 put_tty_driver(gs_tty_driver);
2250 pr_err("gs_module_init: cannot register tty driver, "
2251 "ret=%d\n", retval);
2252 return retval;
2253 }
2254
2255 pr_info("gs_module_init: %s %s loaded\n",
2256 GS_LONG_NAME, GS_VERSION_STR);
2257 return 0;
2258}
2259module_init(gs_module_init);
2260
2261/*
2262 * gs_module_exit
2263 *
2264 * Unregister as a tty driver and a USB gadget driver.
2265 */
2266static void __exit gs_module_exit(void)
2267{
2268 tty_unregister_driver(gs_tty_driver);
2269 put_tty_driver(gs_tty_driver);
2270 usb_gadget_unregister_driver(&gs_gadget_driver);
2271
2272 pr_info("gs_module_exit: %s %s unloaded\n",
2273 GS_LONG_NAME, GS_VERSION_STR);
2274}
2275module_exit(gs_module_exit);
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 33b467a8352d..1ef6df395e0c 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -129,7 +129,7 @@ config USB_ISP1760_PCI
129 129
130config USB_ISP1760_OF 130config USB_ISP1760_OF
131 bool "Support for the OF platform bus" 131 bool "Support for the OF platform bus"
132 depends on USB_ISP1760_HCD && OF 132 depends on USB_ISP1760_HCD && PPC_OF
133 ---help--- 133 ---help---
134 Enables support for the device present on the PowerPC 134 Enables support for the device present on the PowerPC
135 OpenFirmware platform bus. 135 OpenFirmware platform bus.
diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c
index 4ba96c1e060c..c9cec8738261 100644
--- a/drivers/usb/host/isp1760-hcd.c
+++ b/drivers/usb/host/isp1760-hcd.c
@@ -988,7 +988,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
988 * This did not trigger for a long time now. 988 * This did not trigger for a long time now.
989 */ 989 */
990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: " 990 printk(KERN_ERR "Reloading ptd %p/%p... qh %p readed: "
991 "%d of %d done: %08x cur: %08x\n", qtd, 991 "%d of %zu done: %08x cur: %08x\n", qtd,
992 urb, qh, PTD_XFERRED_LENGTH(dw3), 992 urb, qh, PTD_XFERRED_LENGTH(dw3),
993 qtd->length, done_map, 993 qtd->length, done_map,
994 (1 << queue_entry)); 994 (1 << queue_entry));
@@ -1088,7 +1088,7 @@ static void do_atl_int(struct usb_hcd *usb_hcd)
1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) { 1088 } else if (usb_pipebulk(urb->pipe) && (length < qtd->length)) {
1089 /* short BULK received */ 1089 /* short BULK received */
1090 1090
1091 printk(KERN_ERR "short bulk, %d instead %d\n", length, 1091 printk(KERN_ERR "short bulk, %d instead %zu\n", length,
1092 qtd->length); 1092 qtd->length);
1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) { 1093 if (urb->transfer_flags & URB_SHORT_NOT_OK) {
1094 urb->status = -EREMOTEIO; 1094 urb->status = -EREMOTEIO;
diff --git a/drivers/usb/host/isp1760-if.c b/drivers/usb/host/isp1760-if.c
index 73fb2a38f1e4..440bf94f0d4c 100644
--- a/drivers/usb/host/isp1760-if.c
+++ b/drivers/usb/host/isp1760-if.c
@@ -256,7 +256,7 @@ static struct pci_driver isp1761_pci_driver = {
256 256
257static int __init isp1760_init(void) 257static int __init isp1760_init(void)
258{ 258{
259 int ret; 259 int ret = -ENODEV;
260 260
261 init_kmem_once(); 261 init_kmem_once();
262 262
diff --git a/drivers/usb/host/ohci-sm501.c b/drivers/usb/host/ohci-sm501.c
index 77204f001b9a..e899a77dfb83 100644
--- a/drivers/usb/host/ohci-sm501.c
+++ b/drivers/usb/host/ohci-sm501.c
@@ -90,7 +90,7 @@ static int ohci_hcd_sm501_drv_probe(struct platform_device *pdev)
90 struct device *dev = &pdev->dev; 90 struct device *dev = &pdev->dev;
91 struct resource *res, *mem; 91 struct resource *res, *mem;
92 int retval, irq; 92 int retval, irq;
93 struct usb_hcd *hcd = 0; 93 struct usb_hcd *hcd = NULL;
94 94
95 irq = retval = platform_get_irq(pdev, 0); 95 irq = retval = platform_get_irq(pdev, 0);
96 if (retval < 0) 96 if (retval < 0)
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7aafd53fbcab..189a9db03509 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -63,9 +63,6 @@
63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 63#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004
64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 64#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006
65 65
66#define USB_VENDOR_ID_MICROCHIP 0x04d8
67#define USB_DEVICE_ID_PICDEM 0x000c
68
69#ifdef CONFIG_USB_DYNAMIC_MINORS 66#ifdef CONFIG_USB_DYNAMIC_MINORS
70#define USB_LD_MINOR_BASE 0 67#define USB_LD_MINOR_BASE 0
71#else 68#else
@@ -92,7 +89,6 @@ static struct usb_device_id ld_usb_table [] = {
92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, 89 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) },
93 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, 90 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
94 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, 91 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
95 { USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICDEM) },
96 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, 92 { USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
97 { } /* Terminating entry */ 93 { } /* Terminating entry */
98}; 94};
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 742be3c35947..054dedd28127 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -856,6 +856,11 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
856 struct urb *u; 856 struct urb *u;
857 struct usb_ctrlrequest req; 857 struct usb_ctrlrequest req;
858 struct subcase *reqp; 858 struct subcase *reqp;
859
860 /* sign of this variable means:
861 * -: tested code must return this (negative) error code
862 * +: tested code may return this (negative too) error code
863 */
859 int expected = 0; 864 int expected = 0;
860 865
861 /* requests here are mostly expected to succeed on any 866 /* requests here are mostly expected to succeed on any
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 2cffec85ee7e..9ba64ccc1359 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -447,6 +447,15 @@ config USB_SERIAL_MOS7840
447 To compile this driver as a module, choose M here: the 447 To compile this driver as a module, choose M here: the
448 module will be called mos7840. If unsure, choose N. 448 module will be called mos7840. If unsure, choose N.
449 449
450config USB_SERIAL_MOTOROLA
451 tristate "USB Motorola Phone modem driver"
452 ---help---
453 Say Y here if you want to use a Motorola phone with a USB
454 connector as a modem link.
455
456 To compile this driver as a module, choose M here: the
457 module will be called moto_modem. If unsure, choose N.
458
450config USB_SERIAL_NAVMAN 459config USB_SERIAL_NAVMAN
451 tristate "USB Navman GPS device" 460 tristate "USB Navman GPS device"
452 help 461 help
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 756859510d8c..17a762ab6769 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 39obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o 40obj-$(CONFIG_USB_SERIAL_MOS7720) += mos7720.o
41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o 41obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
42obj-$(CONFIG_USB_SERIAL_MOTOROLA) += moto_modem.o
42obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 43obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
43obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 44obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
44obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 45obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index dc0ea08ed231..f5b57b196c5a 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -73,6 +73,7 @@ static struct usb_device_id id_table [] = {
73 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */ 73 { USB_DEVICE(0x10C4, 0x814A) }, /* West Mountain Radio RIGblaster P&P */
74 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */ 74 { USB_DEVICE(0x10C4, 0x814B) }, /* West Mountain Radio RIGtalk */
75 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */ 75 { USB_DEVICE(0x10C4, 0x815E) }, /* Helicomm IP-Link 1220-DVM */
76 { USB_DEVICE(0x10C4, 0x81A6) }, /* ThinkOptics WavIt */
76 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */ 77 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */
77 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */ 78 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
78 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */ 79 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 8a217648b250..a01e987c7d32 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -643,7 +643,7 @@ static void read_buf_callback(struct urb *urb)
643static int iuu_bulk_write(struct usb_serial_port *port) 643static int iuu_bulk_write(struct usb_serial_port *port)
644{ 644{
645 struct iuu_private *priv = usb_get_serial_port_data(port); 645 struct iuu_private *priv = usb_get_serial_port_data(port);
646 unsigned int flags; 646 unsigned long flags;
647 int result; 647 int result;
648 int i; 648 int i;
649 char *buf_ptr = port->write_urb->transfer_buffer; 649 char *buf_ptr = port->write_urb->transfer_buffer;
@@ -694,7 +694,7 @@ static void iuu_uart_read_callback(struct urb *urb)
694{ 694{
695 struct usb_serial_port *port = urb->context; 695 struct usb_serial_port *port = urb->context;
696 struct iuu_private *priv = usb_get_serial_port_data(port); 696 struct iuu_private *priv = usb_get_serial_port_data(port);
697 unsigned int flags; 697 unsigned long flags;
698 int status; 698 int status;
699 int error = 0; 699 int error = 0;
700 int len = 0; 700 int len = 0;
@@ -759,7 +759,7 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
759 int count) 759 int count)
760{ 760{
761 struct iuu_private *priv = usb_get_serial_port_data(port); 761 struct iuu_private *priv = usb_get_serial_port_data(port);
762 unsigned int flags; 762 unsigned long flags;
763 dbg("%s - enter", __func__); 763 dbg("%s - enter", __func__);
764 764
765 if (count > 256) 765 if (count > 256)
diff --git a/drivers/usb/serial/moto_modem.c b/drivers/usb/serial/moto_modem.c
new file mode 100644
index 000000000000..2e8e05462ef7
--- /dev/null
+++ b/drivers/usb/serial/moto_modem.c
@@ -0,0 +1,70 @@
1/*
2 * Motorola USB Phone driver
3 *
4 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
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 version 2 as
8 * published by the Free Software Foundation.
9 *
10 * {sigh}
11 * Mororola should be using the CDC ACM USB spec, but instead
12 * they try to just "do their own thing"... This driver should handle a
13 * few phones in which a basic "dumb serial connection" is needed to be
14 * able to get a connection through to them.
15 */
16
17#include <linux/kernel.h>
18#include <linux/init.h>
19#include <linux/tty.h>
20#include <linux/module.h>
21#include <linux/usb.h>
22#include <linux/usb/serial.h>
23
24static struct usb_device_id id_table [] = {
25 { USB_DEVICE(0x05c6, 0x3197) }, /* unknown Motorola phone */
26 { USB_DEVICE(0x0c44, 0x0022) }, /* unknown Mororola phone */
27 { USB_DEVICE(0x22b8, 0x2a64) }, /* Motorola KRZR K1m */
28 { },
29};
30MODULE_DEVICE_TABLE(usb, id_table);
31
32static struct usb_driver moto_driver = {
33 .name = "moto-modem",
34 .probe = usb_serial_probe,
35 .disconnect = usb_serial_disconnect,
36 .id_table = id_table,
37 .no_dynamic_id = 1,
38};
39
40static struct usb_serial_driver moto_device = {
41 .driver = {
42 .owner = THIS_MODULE,
43 .name = "moto-modem",
44 },
45 .id_table = id_table,
46 .num_ports = 1,
47};
48
49static int __init moto_init(void)
50{
51 int retval;
52
53 retval = usb_serial_register(&moto_device);
54 if (retval)
55 return retval;
56 retval = usb_register(&moto_driver);
57 if (retval)
58 usb_serial_deregister(&moto_device);
59 return retval;
60}
61
62static void __exit moto_exit(void)
63{
64 usb_deregister(&moto_driver);
65 usb_serial_deregister(&moto_device);
66}
67
68module_init(moto_init);
69module_exit(moto_exit);
70MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index e4be2d442b1e..e7e016e60333 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -154,8 +154,6 @@ static int option_send_setup(struct usb_serial_port *port);
154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100 154#define NOVATELWIRELESS_PRODUCT_MC727 0x4100
155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400 155#define NOVATELWIRELESS_PRODUCT_MC950D 0x4400
156 156
157#define NOVATELWIRELESS_PRODUCT_U727 0x5010
158
159/* FUTURE NOVATEL PRODUCTS */ 157/* FUTURE NOVATEL PRODUCTS */
160#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000 158#define NOVATELWIRELESS_PRODUCT_EVDO_1 0x6000
161#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000 159#define NOVATELWIRELESS_PRODUCT_HSPA_1 0x7000
@@ -184,6 +182,9 @@ static int option_send_setup(struct usb_serial_port *port);
184#define AXESSTEL_VENDOR_ID 0x1726 182#define AXESSTEL_VENDOR_ID 0x1726
185#define AXESSTEL_PRODUCT_MV110H 0x1000 183#define AXESSTEL_PRODUCT_MV110H 0x1000
186 184
185#define ONDA_VENDOR_ID 0x19d2
186#define ONDA_PRODUCT_ET502HS 0x0002
187
187#define BANDRICH_VENDOR_ID 0x1A8D 188#define BANDRICH_VENDOR_ID 0x1A8D
188#define BANDRICH_PRODUCT_C100_1 0x1002 189#define BANDRICH_PRODUCT_C100_1 0x1002
189#define BANDRICH_PRODUCT_C100_2 0x1003 190#define BANDRICH_PRODUCT_C100_2 0x1003
@@ -269,7 +270,6 @@ static struct usb_device_id option_ids[] = {
269 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */ 270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EU870D) }, /* Novatel EU850D/EU860D/EU870D */
270 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */ 271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC950D) }, /* Novatel MC930D/MC950D */
271 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */ 272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC727) }, /* Novatel MC727/U727/USB727 */
272 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_U727) }, /* Novatel U727 */
273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */ 273 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EVDO_1) }, /* Novatel EVDO product */
274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */ 274 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_HSPA_1) }, /* Novatel HSPA product */
275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */ 275 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_EMBEDDED_1) }, /* Novatel Embedded product */
@@ -293,14 +293,17 @@ static struct usb_device_id option_ids[] = {
293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */ 293 { USB_DEVICE(DELL_VENDOR_ID, 0x8133) }, /* Dell Wireless 5720 == Novatel EV620 CDMA/EV-DO */
294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */ 294 { USB_DEVICE(DELL_VENDOR_ID, 0x8136) }, /* Dell Wireless HSDPA 5520 == Novatel Expedite EU860D */
295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */ 295 { USB_DEVICE(DELL_VENDOR_ID, 0x8137) }, /* Dell Wireless HSDPA 5520 */
296 { USB_DEVICE(DELL_VENDOR_ID, 0x8138) }, /* Dell Wireless 5520 Voda I Mobile Broadband (3G HSDPA) Minicard */
296 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, 297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) },
297 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 298 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
298 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) }, 299 { USB_DEVICE(AXESSTEL_VENDOR_ID, AXESSTEL_PRODUCT_MV110H) },
300 { USB_DEVICE(ONDA_VENDOR_ID, ONDA_PRODUCT_ET502HS) },
299 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) }, 301 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_1) },
300 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) }, 302 { USB_DEVICE(BANDRICH_VENDOR_ID, BANDRICH_PRODUCT_C100_2) },
301 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) }, 303 { USB_DEVICE(KYOCERA_VENDOR_ID, KYOCERA_PRODUCT_KPC680) },
302 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */ 304 { USB_DEVICE(QUALCOMM_VENDOR_ID, 0x6613)}, /* Onda H600/ZTE MF330 */
303 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */ 305 { USB_DEVICE(MAXON_VENDOR_ID, 0x6280) }, /* BP3-USB & BP3-EXT HSDPA */
306 { USB_DEVICE(0x19d2, 0x0001) }, /* Telstra NextG CDMA */
304 { } /* Terminating entry */ 307 { } /* Terminating entry */
305}; 308};
306MODULE_DEVICE_TABLE(usb, option_ids); 309MODULE_DEVICE_TABLE(usb, option_ids);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index a0ed889230aa..1b09578cbb10 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -401,6 +401,14 @@ UNUSUAL_DEV( 0x04a5, 0x3010, 0x0100, 0x0100,
401 US_SC_DEVICE, US_PR_DEVICE, NULL, 401 US_SC_DEVICE, US_PR_DEVICE, NULL,
402 US_FL_IGNORE_RESIDUE ), 402 US_FL_IGNORE_RESIDUE ),
403 403
404#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
405UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
406 "Cypress",
407 "Cypress AT2LP",
408 US_SC_CYP_ATACB, US_PR_BULK, NULL,
409 0),
410#endif
411
404/* Reported by Simon Levitt <simon@whattf.com> 412/* Reported by Simon Levitt <simon@whattf.com>
405 * This entry needs Sub and Proto fields */ 413 * This entry needs Sub and Proto fields */
406UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100, 414UNUSUAL_DEV( 0x04b8, 0x0601, 0x0100, 0x0100,
@@ -539,17 +547,6 @@ UNUSUAL_DEV( 0x04e6, 0x0101, 0x0200, 0x0200,
539 "CD-RW Device", 547 "CD-RW Device",
540 US_SC_8020, US_PR_CB, NULL, 0), 548 US_SC_8020, US_PR_CB, NULL, 0),
541 549
542/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
543 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
544 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
545 */
546
547UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
548 "Kobian Mercury",
549 "Binocam DCB-132",
550 US_SC_DEVICE, US_PR_DEVICE, NULL,
551 US_FL_BULK32),
552
553#ifdef CONFIG_USB_STORAGE_USBAT 550#ifdef CONFIG_USB_STORAGE_USBAT
554UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999, 551UNUSUAL_DEV( 0x04e6, 0x1010, 0x0000, 0x9999,
555 "Shuttle/SCM", 552 "Shuttle/SCM",
@@ -565,6 +562,16 @@ UNUSUAL_DEV( 0x04e8, 0x507c, 0x0220, 0x0220,
565 US_SC_DEVICE, US_PR_DEVICE, NULL, 562 US_SC_DEVICE, US_PR_DEVICE, NULL,
566 US_FL_MAX_SECTORS_64), 563 US_FL_MAX_SECTORS_64),
567 564
565/* Entry and supporting patch by Theodore Kilgore <kilgota@auburn.edu>.
566 * Device uses standards-violating 32-byte Bulk Command Block Wrappers and
567 * reports itself as "Proprietary SCSI Bulk." Cf. device entry 0x084d:0x0011.
568 */
569UNUSUAL_DEV( 0x04fc, 0x80c2, 0x0100, 0x0100,
570 "Kobian Mercury",
571 "Binocam DCB-132",
572 US_SC_DEVICE, US_PR_DEVICE, NULL,
573 US_FL_BULK32),
574
568/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */ 575/* Reported by Bob Sass <rls@vectordb.com> -- only rev 1.33 tested */
569UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, 576UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133,
570 "Belkin", 577 "Belkin",
@@ -1304,6 +1311,16 @@ UNUSUAL_DEV( 0x0ace, 0x20ff, 0x0101, 0x0101,
1304 US_SC_DEVICE, US_PR_DEVICE, NULL, 1311 US_SC_DEVICE, US_PR_DEVICE, NULL,
1305 US_FL_IGNORE_DEVICE ), 1312 US_FL_IGNORE_DEVICE ),
1306 1313
1314/* Reported by F. Aben <f.aben@option.com>
1315 * This device (wrongly) has a vendor-specific device descriptor.
1316 * The entry is needed so usb-storage can bind to it's mass-storage
1317 * interface as an interface driver */
1318UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1319 "Option",
1320 "GI 0401 SD-Card",
1321 US_SC_DEVICE, US_PR_DEVICE, NULL,
1322 0 ),
1323
1307#ifdef CONFIG_USB_STORAGE_ISD200 1324#ifdef CONFIG_USB_STORAGE_ISD200
1308UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110, 1325UNUSUAL_DEV( 0x0bf6, 0xa001, 0x0100, 0x0110,
1309 "ATI", 1326 "ATI",
@@ -1361,13 +1378,6 @@ UNUSUAL_DEV( 0x0d96, 0x410a, 0x0001, 0xffff,
1361 US_SC_DEVICE, US_PR_DEVICE, NULL, 1378 US_SC_DEVICE, US_PR_DEVICE, NULL,
1362 US_FL_FIX_INQUIRY), 1379 US_FL_FIX_INQUIRY),
1363 1380
1364/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1365UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1366 "INTOVA",
1367 "Pixtreme",
1368 US_SC_DEVICE, US_PR_DEVICE, NULL,
1369 US_FL_FIX_CAPACITY ),
1370
1371/* 1381/*
1372 * Entry for Jenoptik JD 5200z3 1382 * Entry for Jenoptik JD 5200z3
1373 * 1383 *
@@ -1684,6 +1694,16 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201,
1684 US_SC_DEVICE, US_PR_DEVICE, NULL, 1694 US_SC_DEVICE, US_PR_DEVICE, NULL,
1685 US_FL_IGNORE_RESIDUE ), 1695 US_FL_IGNORE_RESIDUE ),
1686 1696
1697/* Reported by Mauro Andreolini <andreoli@weblab.ing.unimo.it>
1698 * This entry is needed to bypass the ZeroCD mechanism
1699 * and to properly load as a modem device.
1700 */
1701UNUSUAL_DEV( 0x19d2, 0x2000, 0x0000, 0x0000,
1702 "Onda ET502HS",
1703 "USB MMC Storage",
1704 US_SC_DEVICE, US_PR_DEVICE, NULL,
1705 US_FL_IGNORE_DEVICE),
1706
1687/* patch submitted by Davide Perini <perini.davide@dpsoftware.org> 1707/* patch submitted by Davide Perini <perini.davide@dpsoftware.org>
1688 * and Renato Perini <rperini@email.it> 1708 * and Renato Perini <rperini@email.it>
1689 */ 1709 */
@@ -1721,6 +1741,13 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1721 US_SC_DEVICE, US_PR_DEVICE, NULL, 1741 US_SC_DEVICE, US_PR_DEVICE, NULL,
1722 US_FL_GO_SLOW ), 1742 US_FL_GO_SLOW ),
1723 1743
1744/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1745UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1746 "INTOVA",
1747 "Pixtreme",
1748 US_SC_DEVICE, US_PR_DEVICE, NULL,
1749 US_FL_FIX_CAPACITY ),
1750
1724/* 1751/*
1725 * David Härdeman <david@2gen.com> 1752 * David Härdeman <david@2gen.com>
1726 * The key makes the SCSI stack print confusing (but harmless) messages 1753 * The key makes the SCSI stack print confusing (but harmless) messages
@@ -1745,14 +1772,6 @@ UNUSUAL_DEV( 0xed06, 0x4500, 0x0001, 0x0001,
1745 US_SC_DEVICE, US_PR_DEVICE, NULL, 1772 US_SC_DEVICE, US_PR_DEVICE, NULL,
1746 US_FL_CAPACITY_HEURISTICS), 1773 US_FL_CAPACITY_HEURISTICS),
1747 1774
1748#ifdef CONFIG_USB_STORAGE_CYPRESS_ATACB
1749UNUSUAL_DEV( 0x04b4, 0x6830, 0x0000, 0x9999,
1750 "Cypress",
1751 "Cypress AT2LP",
1752 US_SC_CYP_ATACB, US_PR_BULK, NULL,
1753 0),
1754#endif
1755
1756/* Control/Bulk transport for all SubClass values */ 1775/* Control/Bulk transport for all SubClass values */
1757USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR), 1776USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1758USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR), 1777USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index bb1dadaa4a23..2cdaf1ff8315 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -171,7 +171,6 @@ config FB_SYS_FOPS
171config FB_DEFERRED_IO 171config FB_DEFERRED_IO
172 bool 172 bool
173 depends on FB 173 depends on FB
174 default y
175 174
176config FB_METRONOME 175config FB_METRONOME
177 tristate 176 tristate
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index 8ffdf3578768..b004036d4087 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -441,14 +441,15 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
441 441
442 value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock)); 442 value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
443 443
444 value = (value / 2) - 1; 444 if (value < 2) {
445 dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n", value);
446
447 if (value <= 0) {
448 dev_notice(info->device, "Bypassing pixel clock divider\n"); 445 dev_notice(info->device, "Bypassing pixel clock divider\n");
449 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); 446 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
450 } else { 447 } else {
451 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); 448 value = (value / 2) - 1;
449 dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n",
450 value);
451 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1,
452 value << ATMEL_LCDC_CLKVAL_OFFSET);
452 info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1))); 453 info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1)));
453 dev_dbg(info->device, " updated pixclk: %lu KHz\n", 454 dev_dbg(info->device, " updated pixclk: %lu KHz\n",
454 PICOS2KHZ(info->var.pixclock)); 455 PICOS2KHZ(info->var.pixclock));
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index 275d9dab0c61..e721644bad74 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -17,11 +17,9 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/of_device.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/oplib.h>
23#include <asm/prom.h>
24#include <asm/of_device.h>
25#include <asm/fbio.h> 23#include <asm/fbio.h>
26 24
27#include "sbuslib.h" 25#include "sbuslib.h"
@@ -299,7 +297,7 @@ static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *
299 par->physbase = op->resource[0].start; 297 par->physbase = op->resource[0].start;
300 par->which_io = op->resource[0].flags & IORESOURCE_BITS; 298 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
301 299
302 sbusfb_fill_var(&info->var, dp->node, 1); 300 sbusfb_fill_var(&info->var, dp, 1);
303 linebytes = of_getintprop_default(dp, "linebytes", 301 linebytes = of_getintprop_default(dp, "linebytes",
304 info->var.xres); 302 info->var.xres);
305 303
@@ -329,7 +327,7 @@ static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *
329 if (!info->screen_base) 327 if (!info->screen_base)
330 goto out_unmap_regs; 328 goto out_unmap_regs;
331 329
332 bw2_blank(0, info); 330 bw2_blank(FB_BLANK_UNBLANK, info);
333 331
334 bw2_init_fix(info, linebytes); 332 bw2_init_fix(info, linebytes);
335 333
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index 0db0fecba93b..b17e74671779 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -17,10 +17,9 @@
17#include <linux/fb.h> 17#include <linux/fb.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20#include <linux/of_device.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/prom.h>
23#include <asm/of_device.h>
24#include <asm/fbio.h> 23#include <asm/fbio.h>
25 24
26#include "sbuslib.h" 25#include "sbuslib.h"
@@ -482,7 +481,7 @@ static int __devinit cg14_probe(struct of_device *op, const struct of_device_id
482 481
483 spin_lock_init(&par->lock); 482 spin_lock_init(&par->lock);
484 483
485 sbusfb_fill_var(&info->var, dp->node, 8); 484 sbusfb_fill_var(&info->var, dp, 8);
486 info->var.red.length = 8; 485 info->var.red.length = 8;
487 info->var.green.length = 8; 486 info->var.green.length = 8;
488 info->var.blue.length = 8; 487 info->var.blue.length = 8;
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index 010ea53978f8..3aa7b6cb0268 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -17,11 +17,9 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/of_device.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/oplib.h>
23#include <asm/prom.h>
24#include <asm/of_device.h>
25#include <asm/fbio.h> 23#include <asm/fbio.h>
26 24
27#include "sbuslib.h" 25#include "sbuslib.h"
@@ -373,7 +371,7 @@ static int __devinit cg3_probe(struct of_device *op,
373 par->physbase = op->resource[0].start; 371 par->physbase = op->resource[0].start;
374 par->which_io = op->resource[0].flags & IORESOURCE_BITS; 372 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
375 373
376 sbusfb_fill_var(&info->var, dp->node, 8); 374 sbusfb_fill_var(&info->var, dp, 8);
377 info->var.red.length = 8; 375 info->var.red.length = 8;
378 info->var.green.length = 8; 376 info->var.green.length = 8;
379 info->var.blue.length = 8; 377 info->var.blue.length = 8;
@@ -398,7 +396,7 @@ static int __devinit cg3_probe(struct of_device *op,
398 if (!info->screen_base) 396 if (!info->screen_base)
399 goto out_unmap_regs; 397 goto out_unmap_regs;
400 398
401 cg3_blank(0, info); 399 cg3_blank(FB_BLANK_UNBLANK, info);
402 400
403 if (!of_find_property(dp, "width", NULL)) { 401 if (!of_find_property(dp, "width", NULL)) {
404 err = cg3_do_default_mode(par); 402 err = cg3_do_default_mode(par);
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index fc90db6da65a..2f64bb3bd254 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -17,9 +17,9 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/of_device.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/of_device.h>
23#include <asm/fbio.h> 23#include <asm/fbio.h>
24 24
25#include "sbuslib.h" 25#include "sbuslib.h"
@@ -728,7 +728,7 @@ static int __devinit cg6_probe(struct of_device *op,
728 par->physbase = op->resource[0].start; 728 par->physbase = op->resource[0].start;
729 par->which_io = op->resource[0].flags & IORESOURCE_BITS; 729 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
730 730
731 sbusfb_fill_var(&info->var, dp->node, 8); 731 sbusfb_fill_var(&info->var, dp, 8);
732 info->var.red.length = 8; 732 info->var.red.length = 8;
733 info->var.green.length = 8; 733 info->var.green.length = 8;
734 info->var.blue.length = 8; 734 info->var.blue.length = 8;
@@ -767,7 +767,7 @@ static int __devinit cg6_probe(struct of_device *op,
767 767
768 cg6_bt_init(par); 768 cg6_bt_init(par);
769 cg6_chip_init(info); 769 cg6_chip_init(info);
770 cg6_blank(0, info); 770 cg6_blank(FB_BLANK_UNBLANK, info);
771 771
772 if (fb_alloc_cmap(&info->cmap, 256, 0)) 772 if (fb_alloc_cmap(&info->cmap, 256, 0))
773 goto out_unmap_regs; 773 goto out_unmap_regs;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index ad31983b43eb..5fa8b76673cb 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1853,6 +1853,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1853 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]]; 1853 struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];
1854 struct display *p = &fb_display[vc->vc_num]; 1854 struct display *p = &fb_display[vc->vc_num];
1855 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK; 1855 int scroll_partial = info->flags & FBINFO_PARTIAL_PAN_OK;
1856 unsigned short saved_ec;
1857 int ret;
1856 1858
1857 if (fbcon_is_inactive(vc, info)) 1859 if (fbcon_is_inactive(vc, info))
1858 return -EINVAL; 1860 return -EINVAL;
@@ -1865,6 +1867,11 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1865 * whole screen (prevents flicker). 1867 * whole screen (prevents flicker).
1866 */ 1868 */
1867 1869
1870 saved_ec = vc->vc_video_erase_char;
1871 vc->vc_video_erase_char = vc->vc_scrl_erase_char;
1872
1873 ret = 0;
1874
1868 switch (dir) { 1875 switch (dir) {
1869 case SM_UP: 1876 case SM_UP:
1870 if (count > vc->vc_rows) /* Maximum realistic size */ 1877 if (count > vc->vc_rows) /* Maximum realistic size */
@@ -1883,7 +1890,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1883 (b - count)), 1890 (b - count)),
1884 vc->vc_scrl_erase_char, 1891 vc->vc_scrl_erase_char,
1885 vc->vc_size_row * count); 1892 vc->vc_size_row * count);
1886 return 1; 1893 ret = 1;
1887 break; 1894 break;
1888 1895
1889 case SCROLL_WRAP_MOVE: 1896 case SCROLL_WRAP_MOVE:
@@ -1955,7 +1962,8 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1955 (b - count)), 1962 (b - count)),
1956 vc->vc_scrl_erase_char, 1963 vc->vc_scrl_erase_char,
1957 vc->vc_size_row * count); 1964 vc->vc_size_row * count);
1958 return 1; 1965 ret = 1;
1966 break;
1959 } 1967 }
1960 break; 1968 break;
1961 1969
@@ -1974,7 +1982,7 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
1974 t), 1982 t),
1975 vc->vc_scrl_erase_char, 1983 vc->vc_scrl_erase_char,
1976 vc->vc_size_row * count); 1984 vc->vc_size_row * count);
1977 return 1; 1985 ret = 1;
1978 break; 1986 break;
1979 1987
1980 case SCROLL_WRAP_MOVE: 1988 case SCROLL_WRAP_MOVE:
@@ -2044,10 +2052,13 @@ static int fbcon_scroll(struct vc_data *vc, int t, int b, int dir,
2044 t), 2052 t),
2045 vc->vc_scrl_erase_char, 2053 vc->vc_scrl_erase_char,
2046 vc->vc_size_row * count); 2054 vc->vc_size_row * count);
2047 return 1; 2055 ret = 1;
2056 break;
2048 } 2057 }
2058 break;
2049 } 2059 }
2050 return 0; 2060 vc->vc_video_erase_char = saved_ec;
2061 return ret;
2051} 2062}
2052 2063
2053 2064
@@ -2507,6 +2518,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2507 c = vc->vc_video_erase_char; 2518 c = vc->vc_video_erase_char;
2508 vc->vc_video_erase_char = 2519 vc->vc_video_erase_char =
2509 ((c & 0xfe00) >> 1) | (c & 0xff); 2520 ((c & 0xfe00) >> 1) | (c & 0xff);
2521 c = vc->vc_def_color;
2522 vc->vc_scrl_erase_char =
2523 ((c & 0xFE00) >> 1) | (c & 0xFF);
2510 vc->vc_attr >>= 1; 2524 vc->vc_attr >>= 1;
2511 } 2525 }
2512 } else if (!vc->vc_hi_font_mask && cnt == 512) { 2526 } else if (!vc->vc_hi_font_mask && cnt == 512) {
@@ -2537,9 +2551,14 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h,
2537 if (vc->vc_can_do_color) { 2551 if (vc->vc_can_do_color) {
2538 vc->vc_video_erase_char = 2552 vc->vc_video_erase_char =
2539 ((c & 0xff00) << 1) | (c & 0xff); 2553 ((c & 0xff00) << 1) | (c & 0xff);
2554 c = vc->vc_def_color;
2555 vc->vc_scrl_erase_char =
2556 ((c & 0xFF00) << 1) | (c & 0xFF);
2540 vc->vc_attr <<= 1; 2557 vc->vc_attr <<= 1;
2541 } else 2558 } else {
2542 vc->vc_video_erase_char = c & ~0x100; 2559 vc->vc_video_erase_char = c & ~0x100;
2560 vc->vc_scrl_erase_char = c & ~0x100;
2561 }
2543 } 2562 }
2544 2563
2545 } 2564 }
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 93dca3e2aa50..7992b13ee68f 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -16,11 +16,10 @@
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/timer.h> 18#include <linux/timer.h>
19#include <linux/of_device.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/upa.h> 22#include <asm/upa.h>
22#include <asm/prom.h>
23#include <asm/of_device.h>
24#include <asm/fbio.h> 23#include <asm/fbio.h>
25 24
26#include "sbuslib.h" 25#include "sbuslib.h"
@@ -941,7 +940,7 @@ static int __devinit ffb_probe(struct of_device *op,
941 info->screen_base = (char *) par->physbase + FFB_DFB24_POFF; 940 info->screen_base = (char *) par->physbase + FFB_DFB24_POFF;
942 info->pseudo_palette = par->pseudo_palette; 941 info->pseudo_palette = par->pseudo_palette;
943 942
944 sbusfb_fill_var(&info->var, dp->node, 32); 943 sbusfb_fill_var(&info->var, dp, 32);
945 par->fbsize = PAGE_ALIGN(info->var.xres * info->var.yres * 4); 944 par->fbsize = PAGE_ALIGN(info->var.xres * info->var.yres * 4);
946 ffb_fixup_var_rgb(&info->var); 945 ffb_fixup_var_rgb(&info->var);
947 946
@@ -987,7 +986,7 @@ static int __devinit ffb_probe(struct of_device *op,
987 * chosen console, it will have video outputs off in 986 * chosen console, it will have video outputs off in
988 * the DAC. 987 * the DAC.
989 */ 988 */
990 ffb_blank(0, info); 989 ffb_blank(FB_BLANK_UNBLANK, info);
991 990
992 if (fb_alloc_cmap(&info->cmap, 256, 0)) 991 if (fb_alloc_cmap(&info->cmap, 256, 0))
993 goto out_unmap_dac; 992 goto out_unmap_dac;
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index cd9d4cc26954..aaef9165ec9b 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -63,54 +63,32 @@ static const struct {
63 { 0x00014284, 19688 }, 63 { 0x00014284, 19688 },
64 { 0x00011104, 20400 }, 64 { 0x00011104, 20400 },
65 { 0x00016363, 23625 }, 65 { 0x00016363, 23625 },
66 { 0x00015303, 24380 },
67 { 0x000031AC, 24923 }, 66 { 0x000031AC, 24923 },
68 { 0x0000215D, 25175 }, 67 { 0x0000215D, 25175 },
69 { 0x00001087, 27000 }, 68 { 0x00001087, 27000 },
70 { 0x0000216C, 28322 }, 69 { 0x0000216C, 28322 },
71 { 0x0000218D, 28560 }, 70 { 0x0000218D, 28560 },
72 { 0x00010041, 29913 },
73 { 0x000010C9, 31200 }, 71 { 0x000010C9, 31200 },
74 { 0x00003147, 31500 }, 72 { 0x00003147, 31500 },
75 { 0x000141A1, 32400 },
76 { 0x000010A7, 33032 }, 73 { 0x000010A7, 33032 },
77 { 0x00012182, 33375 },
78 { 0x000141B1, 33750 },
79 { 0x00002159, 35112 }, 74 { 0x00002159, 35112 },
80 { 0x00004249, 35500 }, 75 { 0x00004249, 35500 },
81 { 0x00000057, 36000 }, 76 { 0x00000057, 36000 },
82 { 0x000141E1, 37125 },
83 { 0x0000219A, 37889 }, 77 { 0x0000219A, 37889 },
84 { 0x00002158, 39168 }, 78 { 0x00002158, 39168 },
85 { 0x00000045, 40000 }, 79 { 0x00000045, 40000 },
86 { 0x000131A1, 40500 },
87 { 0x00010061, 42301 },
88 { 0x00000089, 43163 }, 80 { 0x00000089, 43163 },
89 { 0x00012151, 43875 },
90 { 0x000010E7, 44900 }, 81 { 0x000010E7, 44900 },
91 { 0x00002136, 45720 }, 82 { 0x00002136, 45720 },
92 { 0x000152E1, 47250 },
93 { 0x00010071, 48000 },
94 { 0x00003207, 49500 }, 83 { 0x00003207, 49500 },
95 { 0x00002187, 50000 }, 84 { 0x00002187, 50000 },
96 { 0x00014291, 50625 },
97 { 0x00011101, 51188 },
98 { 0x00017481, 54563 },
99 { 0x00004286, 56250 }, 85 { 0x00004286, 56250 },
100 { 0x00014170, 57375 },
101 { 0x00016210, 58500 },
102 { 0x000010E5, 60065 }, 86 { 0x000010E5, 60065 },
103 { 0x00013140, 62796 },
104 { 0x00004214, 65000 }, 87 { 0x00004214, 65000 },
105 { 0x00016250, 65250 },
106 { 0x00001105, 68179 }, 88 { 0x00001105, 68179 },
107 { 0x000141C0, 69600 },
108 { 0x00015220, 70160 },
109 { 0x00010050, 72000 },
110 { 0x000031E4, 74250 }, 89 { 0x000031E4, 74250 },
111 { 0x00003183, 75000 }, 90 { 0x00003183, 75000 },
112 { 0x00004284, 78750 }, 91 { 0x00004284, 78750 },
113 { 0x00012130, 80052 },
114 { 0x00001104, 81600 }, 92 { 0x00001104, 81600 },
115 { 0x00006363, 94500 }, 93 { 0x00006363, 94500 },
116 { 0x00005303, 97520 }, 94 { 0x00005303, 97520 },
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index f3160fc29795..8bc46e930340 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -16,10 +16,9 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/fb.h> 17#include <linux/fb.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/of_device.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/prom.h>
22#include <asm/of_device.h>
23#include <asm/fbio.h> 22#include <asm/fbio.h>
24 23
25#include "sbuslib.h" 24#include "sbuslib.h"
@@ -562,7 +561,7 @@ static int __devinit leo_probe(struct of_device *op, const struct of_device_id *
562 par->physbase = op->resource[0].start; 561 par->physbase = op->resource[0].start;
563 par->which_io = op->resource[0].flags & IORESOURCE_BITS; 562 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
564 563
565 sbusfb_fill_var(&info->var, dp->node, 32); 564 sbusfb_fill_var(&info->var, dp, 32);
566 leo_fixup_var_rgb(&info->var); 565 leo_fixup_var_rgb(&info->var);
567 566
568 linebytes = of_getintprop_default(dp, "linebytes", 567 linebytes = of_getintprop_default(dp, "linebytes",
@@ -601,7 +600,7 @@ static int __devinit leo_probe(struct of_device *op, const struct of_device_id *
601 leo_init_wids(info); 600 leo_init_wids(info);
602 leo_init_hw(info); 601 leo_init_hw(info);
603 602
604 leo_blank(0, info); 603 leo_blank(FB_BLANK_UNBLANK, info);
605 604
606 if (fb_alloc_cmap(&info->cmap, 256, 0)) 605 if (fb_alloc_cmap(&info->cmap, 256, 0))
607 goto out_unmap_regs; 606 goto out_unmap_regs;
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 9de1c114f809..39ac49e0682c 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -27,6 +27,16 @@ config LOGO_LINUX_CLUT224
27 bool "Standard 224-color Linux logo" 27 bool "Standard 224-color Linux logo"
28 default y 28 default y
29 29
30config LOGO_BLACKFIN_VGA16
31 bool "16-colour Blackfin Processor Linux logo"
32 depends on BLACKFIN
33 default y
34
35config LOGO_BLACKFIN_CLUT224
36 bool "224-colour Blackfin Processor Linux logo"
37 depends on BLACKFIN
38 default y
39
30config LOGO_DEC_CLUT224 40config LOGO_DEC_CLUT224
31 bool "224-color Digital Equipment Corporation Linux logo" 41 bool "224-color Digital Equipment Corporation Linux logo"
32 depends on MACH_DECSTATION || ALPHA 42 depends on MACH_DECSTATION || ALPHA
diff --git a/drivers/video/logo/Makefile b/drivers/video/logo/Makefile
index a5fc4edf84e6..b91251d1fe41 100644
--- a/drivers/video/logo/Makefile
+++ b/drivers/video/logo/Makefile
@@ -4,6 +4,8 @@ obj-$(CONFIG_LOGO) += logo.o
4obj-$(CONFIG_LOGO_LINUX_MONO) += logo_linux_mono.o 4obj-$(CONFIG_LOGO_LINUX_MONO) += logo_linux_mono.o
5obj-$(CONFIG_LOGO_LINUX_VGA16) += logo_linux_vga16.o 5obj-$(CONFIG_LOGO_LINUX_VGA16) += logo_linux_vga16.o
6obj-$(CONFIG_LOGO_LINUX_CLUT224) += logo_linux_clut224.o 6obj-$(CONFIG_LOGO_LINUX_CLUT224) += logo_linux_clut224.o
7obj-$(CONFIG_LOGO_BLACKFIN_CLUT224) += logo_blackfin_clut224.o
8obj-$(CONFIG_LOGO_BLACKFIN_VGA16) += logo_blackfin_vga16.o
7obj-$(CONFIG_LOGO_DEC_CLUT224) += logo_dec_clut224.o 9obj-$(CONFIG_LOGO_DEC_CLUT224) += logo_dec_clut224.o
8obj-$(CONFIG_LOGO_MAC_CLUT224) += logo_mac_clut224.o 10obj-$(CONFIG_LOGO_MAC_CLUT224) += logo_mac_clut224.o
9obj-$(CONFIG_LOGO_PARISC_CLUT224) += logo_parisc_clut224.o 11obj-$(CONFIG_LOGO_PARISC_CLUT224) += logo_parisc_clut224.o
diff --git a/drivers/video/logo/logo.c b/drivers/video/logo/logo.c
index fc72684aae5a..2e85a2b52d05 100644
--- a/drivers/video/logo/logo.c
+++ b/drivers/video/logo/logo.c
@@ -24,6 +24,8 @@
24extern const struct linux_logo logo_linux_mono; 24extern const struct linux_logo logo_linux_mono;
25extern const struct linux_logo logo_linux_vga16; 25extern const struct linux_logo logo_linux_vga16;
26extern const struct linux_logo logo_linux_clut224; 26extern const struct linux_logo logo_linux_clut224;
27extern const struct linux_logo logo_blackfin_vga16;
28extern const struct linux_logo logo_blackfin_clut224;
27extern const struct linux_logo logo_dec_clut224; 29extern const struct linux_logo logo_dec_clut224;
28extern const struct linux_logo logo_mac_clut224; 30extern const struct linux_logo logo_mac_clut224;
29extern const struct linux_logo logo_parisc_clut224; 31extern const struct linux_logo logo_parisc_clut224;
@@ -65,6 +67,10 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
65 /* Generic Linux logo */ 67 /* Generic Linux logo */
66 logo = &logo_linux_vga16; 68 logo = &logo_linux_vga16;
67#endif 69#endif
70#ifdef CONFIG_LOGO_BLACKFIN_VGA16
71 /* Blackfin processor logo */
72 logo = &logo_blackfin_vga16;
73#endif
68#ifdef CONFIG_LOGO_SUPERH_VGA16 74#ifdef CONFIG_LOGO_SUPERH_VGA16
69 /* SuperH Linux logo */ 75 /* SuperH Linux logo */
70 logo = &logo_superh_vga16; 76 logo = &logo_superh_vga16;
@@ -76,6 +82,10 @@ const struct linux_logo * __init_refok fb_find_logo(int depth)
76 /* Generic Linux logo */ 82 /* Generic Linux logo */
77 logo = &logo_linux_clut224; 83 logo = &logo_linux_clut224;
78#endif 84#endif
85#ifdef CONFIG_LOGO_BLACKFIN_CLUT224
86 /* Blackfin Linux logo */
87 logo = &logo_blackfin_clut224;
88#endif
79#ifdef CONFIG_LOGO_DEC_CLUT224 89#ifdef CONFIG_LOGO_DEC_CLUT224
80 /* DEC Linux logo on MIPS/MIPS64 or ALPHA */ 90 /* DEC Linux logo on MIPS/MIPS64 or ALPHA */
81 logo = &logo_dec_clut224; 91 logo = &logo_dec_clut224;
diff --git a/drivers/video/logo/logo_blackfin_clut224.ppm b/drivers/video/logo/logo_blackfin_clut224.ppm
new file mode 100644
index 000000000000..dc9a50a14477
--- /dev/null
+++ b/drivers/video/logo/logo_blackfin_clut224.ppm
@@ -0,0 +1,1127 @@
1P3
2# This was generated by the GIMP & Netpbm tools
3# gimp linux_bf.svg (create 80x80 save as linux_bf.ppm)
4# pnmquant 224 linux_bf.ppm | pnmnoraw > logo_blackfin_clut224.ppm
5#
680 80
7255
80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
141 1 1 3 3 3 4 6 6 6 6 6 4 6 6 3 3 3
150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 2 2 2 10 10 10 26 26 27
2844 44 45 66 66 66 78 81 81 78 81 81 75 75 76 60 60 60
2939 39 39 20 20 20 6 6 6 1 1 1 0 0 0 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
350 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 2 2 2 14 14 14 47 47 47 84 84 84 75 75 76
4247 47 47 12 12 12 0 0 0 0 0 0 0 0 0 20 20 20
4353 54 54 81 81 82 74 74 74 31 31 31 6 6 6 0 0 0
440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
490 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
554 4 4 34 34 35 84 84 84 60 60 60 4 4 4 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
570 0 0 0 0 0 17 18 18 75 75 76 66 66 66 17 18 18
581 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630 0 0 0 0 0
640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3
6942 42 43 84 84 84 8 8 8 0 0 0 0 0 0 0 0 0
700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
710 3 3 36 40 40 10 16 16 0 0 0 31 31 31 84 84 84
7229 29 30 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 0 0 0 0 0
780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 0 0 0 0 0 0 0 0 0 0 0 1 1 1 26 27 27
8384 84 84 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8515 19 19 114 115 115 110 114 114 44 46 46 0 0 0 12 12 12
8690 87 86 24 24 24 1 1 1 0 0 0 0 0 0 0 0 0
870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
910 0 0 0 0 0
920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
960 0 0 0 0 0 0 0 0 0 0 0 8 8 8 75 75 76
9714 14 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9930 40 40 133 133 133 129 130 130 78 85 85 23 31 30 0 0 0
10019 19 19 78 81 81 13 13 13 0 0 0 0 0 0 0 0 0
1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1050 0 0 0 0 0
1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 0 0 0 0 0 0 0 0 0 0 0 26 27 27 81 81 82
1110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11336 40 40 89 90 91 55 63 63 23 31 30 4 6 6 0 0 0
1140 0 0 60 60 60 47 47 47 2 2 2 0 0 0 0 0 0
1150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1190 0 0 0 0 0
1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1240 0 0 0 0 0 0 0 0 2 2 2 53 54 54 34 34 35
1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1274 10 10 7 9 9 0 0 0 0 0 0 0 0 0 0 0 0
1280 0 0 1 1 1 84 84 84 13 13 13 0 0 0 0 0 0
1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1330 0 0 0 0 0
1340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1380 0 0 0 0 0 0 0 0 4 6 6 78 81 81 2 2 2
1390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1420 0 0 0 0 0 65 64 64 36 36 36 0 0 0 0 0 0
1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1470 0 0 0 0 0
1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1520 0 0 0 0 0 0 0 0 10 11 11 81 81 82 0 0 0
1530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1560 0 0 0 0 0 12 12 12 67 70 70 4 4 4 0 0 0
1570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1610 0 0 0 0 0
1620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1660 0 0 0 0 0 0 0 0 16 16 16 81 81 82 0 0 0
1670 0 0 0 0 0 4 10 10 44 50 50 18 21 21 0 0 0
1680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1690 1 1 78 85 85 120 121 122 7 9 9 0 0 0 0 0 0
1700 0 0 0 0 0 0 0 0 82 82 81 12 12 12 0 0 0
1710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1750 0 0 0 0 0
1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1800 0 0 0 0 0 0 0 0 19 19 19 81 81 82 0 0 0
1810 0 0 2 2 2 8 8 8 55 63 63 108 110 110 52 58 58
1820 0 0 0 0 0 0 0 0 0 0 0 42 42 43 129 130 130
183140 142 143 114 115 115 110 114 114 129 130 130 0 0 0 0 0 0
1840 0 0 0 0 0 0 0 0 75 75 76 24 24 24 0 0 0
1850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1890 0 0 0 0 0
1900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1940 0 0 0 0 0 0 0 0 19 19 19 74 74 74 0 0 0
1954 6 6 167 168 167 196 196 197 196 196 197 61 65 66 78 85 85
1960 0 0 0 0 0 0 0 0 118 118 118 202 202 203 219 219 219
197219 219 219 214 214 215 187 187 188 78 85 85 29 33 34 0 0 0
1980 0 0 0 0 0 0 0 0 60 60 60 39 39 39 0 0 0
1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2030 0 0 0 0 0
2040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2080 0 0 0 0 0 0 0 0 19 19 19 72 71 71 0 0 0
209185 185 184 244 245 245 250 251 252 251 251 252 247 248 249 36 36 36
2100 0 0 0 0 0 13 13 13 243 243 241 252 252 252 253 253 253
211253 253 253 252 252 252 247 247 246 193 193 194 0 0 0 0 0 0
2120 0 0 0 0 0 0 0 0 42 42 43 50 51 51 1 1 1
2130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2170 0 0 0 0 0
2180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2220 0 0 0 0 0 0 0 0 19 19 19 78 81 81 0 0 0
223247 247 246 193 193 194 95 97 97 193 193 194 255 255 255 237 237 238
2240 0 0 0 0 0 202 202 203 255 255 255 247 247 246 108 107 107
22582 85 86 167 168 167 255 255 255 248 248 249 0 0 0 0 0 0
2260 0 0 0 0 0 0 0 0 34 34 35 56 56 56 2 2 2
2270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2310 0 0 0 0 0
2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2360 0 0 0 0 0 0 0 0 19 19 19 78 81 81 0 0 0
237250 250 251 50 51 51 153 154 155 150 151 151 244 245 245 244 245 245
23844 50 50 84 89 89 153 154 155 255 255 255 140 142 143 0 0 0
239149 149 150 156 155 156 237 237 238 254 254 254 67 70 70 0 0 0
2400 0 0 0 0 0 0 0 0 39 39 39 47 47 47 1 1 1
2410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2450 0 0 0 0 0
2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2500 0 0 0 0 0 0 0 0 19 19 19 81 81 82 0 0 0
251248 248 249 34 34 35 72 71 71 165 165 165 202 202 203 244 245 245
25210 16 16 82 85 86 89 90 91 255 255 255 95 97 97 0 0 0
2530 0 0 53 54 54 177 177 174 255 255 255 127 127 126 0 0 0
2540 0 0 0 0 0 0 0 0 39 39 39 36 36 36 0 0 0
2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2590 0 0 0 0 0
2600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2640 0 0 0 0 0 0 0 0 14 14 14 78 81 81 0 0 0
265243 243 243 89 90 91 0 0 0 36 40 40 201 147 55 241 205 27
266241 205 27 241 205 27 241 205 27 238 192 33 108 110 110 0 0 0
2670 0 0 0 0 0 191 190 190 254 254 254 34 34 35 0 0 0
2680 0 0 0 0 0 0 0 0 42 42 43 42 42 43 0 0 0
2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2730 0 0 0 0 0
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2780 0 0 0 0 0 0 0 0 10 10 10 75 75 76 0 0 0
279202 202 203 218 217 217 21 19 17 230 165 41 199 129 48 213 157 40
280244 212 23 243 206 27 180 121 62 243 206 27 244 209 25 226 179 40
28115 10 7 103 103 103 254 254 254 251 251 252 0 0 0 0 0 0
2820 0 0 0 0 0 0 0 0 17 18 18 58 58 58 2 2 2
2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2870 0 0 0 0 0
2880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2920 0 0 0 0 0 0 0 0 9 9 9 84 84 84 0 0 0
2930 0 0 226 226 219 213 157 40 244 209 25 245 211 23 245 211 23
294245 214 38 245 214 38 245 211 23 245 211 23 245 211 23 244 212 23
295244 212 23 241 205 27 226 179 40 196 196 197 0 0 0 0 0 0
2960 0 0 0 0 0 0 0 0 0 0 0 74 74 74 4 6 6
2970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3010 0 0 0 0 0
3020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3060 0 0 0 0 0 0 0 0 7 7 7 84 84 84 0 0 0
30754 42 32 213 157 40 243 206 27 245 211 23 245 211 23 245 211 23
308245 215 41 245 214 35 245 211 23 245 211 23 245 214 35 245 215 41
309245 214 35 245 211 23 245 211 23 238 204 29 0 0 0 0 0 0
3100 0 0 0 0 0 0 0 0 0 0 0 81 81 82 12 12 12
3110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3150 0 0 0 0 0
3160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3200 0 0 0 0 0 0 0 0 4 6 6 74 74 74 0 0 0
321201 147 55 241 205 27 245 211 23 245 211 23 245 211 23 245 213 29
322245 214 38 245 211 23 245 211 23 245 214 35 245 215 41 245 215 41
323245 213 29 142 83 36 142 83 36 244 209 25 1 1 1 0 0 0
3240 0 0 0 0 0 0 0 0 0 0 0 74 74 74 25 25 26
3250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3290 0 0 0 0 0
3300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3340 0 0 0 0 0 0 0 0 4 4 4 72 71 71 6 6 6
335213 157 40 244 209 25 245 211 23 245 211 23 245 211 23 245 213 29
336244 212 23 245 211 23 245 214 35 245 215 41 245 215 41 245 213 29
337142 83 36 142 83 36 238 192 33 241 205 27 0 0 0 0 0 0
3380 0 0 0 0 0 0 0 0 0 0 0 44 44 44 49 50 50
3392 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3430 0 0 0 0 0
3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3480 0 0 0 0 0 0 0 0 3 3 3 65 64 64 17 18 18
349199 129 48 199 129 48 245 211 23 245 211 23 245 211 23 245 211 23
350245 211 23 244 212 23 245 214 38 245 214 38 142 83 36 142 83 36
351142 83 36 245 211 23 244 210 23 230 165 41 0 0 0 0 0 0
35278 81 81 114 115 115 73 79 79 0 0 0 3 3 3 81 81 82
3539 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3570 0 0 0 0 0
3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3620 0 0 0 0 0 0 0 0 1 1 1 49 50 50 29 29 30
36390 87 86 199 129 48 173 101 51 173 101 51 245 211 23 245 211 23
364245 211 23 230 165 41 142 83 36 142 83 36 142 83 36 245 211 23
365244 210 23 241 205 27 230 165 41 175 173 165 3 3 3 0 0 0
36644 46 46 118 118 118 118 118 118 108 110 110 0 0 0 75 75 76
36728 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3710 0 0 0 0 0
3720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3760 0 0 0 0 0 0 0 0 1 1 1 52 53 53 26 26 27
377118 118 118 175 173 165 199 129 48 173 101 51 173 101 51 173 101 51
378173 101 51 142 83 36 173 101 51 245 211 23 244 209 25 238 204 29
379213 157 40 214 196 166 227 227 227 214 214 215 120 121 122 0 0 0
3800 0 0 108 110 110 118 118 118 118 118 118 0 0 0 23 23 23
38166 66 66 4 6 6 0 0 0 0 0 0 0 0 0 0 0 0
3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3850 0 0 0 0 0
3860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3900 0 0 0 0 0 0 0 0 7 7 7 75 75 76 4 4 4
391127 127 126 205 205 205 181 181 181 199 129 48 226 179 40 244 209 25
392244 209 25 244 209 25 243 206 27 238 192 33 213 157 40 187 166 103
393234 234 234 248 248 249 251 252 252 248 248 249 214 214 215 0 0 0
3940 0 0 0 0 0 103 103 103 100 103 103 0 0 0 0 0 0
39578 81 81 24 24 24 0 0 0 0 0 0 0 0 0 0 0 0
3960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3990 0 0 0 0 0
4000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4040 0 0 0 0 0 0 0 0 26 27 27 82 82 81 0 0 0
405146 146 147 234 234 234 222 221 221 178 178 179 180 121 62 213 157 40
406213 157 40 213 157 40 201 147 55 180 121 62 219 219 219 243 243 241
407253 253 253 255 255 255 255 255 255 255 255 255 250 250 251 120 121 122
4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
40920 20 20 72 71 71 8 8 8 0 0 0 0 0 0 0 0 0
4100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4130 0 0 0 0 0
4140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4180 0 0 0 0 0 10 10 10 75 75 76 22 22 22 0 0 0
419205 205 205 253 253 253 247 248 249 212 211 212 178 178 179 161 161 162
420165 165 165 181 181 181 205 205 205 227 227 227 244 245 245 254 254 254
421255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 239 239 240
4220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4230 0 0 67 70 70 39 39 39 2 2 2 0 0 0 0 0 0
4240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4270 0 0 0 0 0
4280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4320 0 0 4 4 4 50 51 51 60 60 60 0 0 0 16 16 16
433249 250 251 255 255 255 255 255 255 240 240 240 209 210 210 193 193 194
434200 200 197 212 211 212 231 231 231 246 247 248 255 255 255 255 255 255
435255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 253 253 253
436153 154 155 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4370 0 0 3 3 3 84 84 84 20 20 20 0 0 0 0 0 0
4380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4410 0 0 0 0 0
4420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4462 2 2 33 33 34 81 81 82 0 0 0 0 0 0 231 231 231
447255 255 255 255 255 255 255 255 255 253 253 253 234 234 234 222 221 221
448227 227 227 237 237 238 250 250 251 255 255 255 255 255 255 255 255 255
449255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
450240 240 240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4510 0 0 0 0 0 26 27 27 72 71 71 8 8 8 0 0 0
4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4550 0 0 0 0 0
4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
46021 21 22 84 84 84 7 7 7 0 0 0 150 151 151 252 252 252
461255 255 255 255 255 255 255 255 255 255 255 255 252 252 252 244 245 245
462246 247 248 253 253 253 255 255 255 255 255 255 255 255 255 255 255 255
463255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
464251 251 252 9 9 9 0 0 0 0 0 0 0 0 0 0 0 0
4650 0 0 0 0 0 0 0 0 65 64 64 47 47 47 3 3 3
4660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4690 0 0 0 0 0
4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12 12 12
47475 75 76 26 26 27 0 0 0 1 1 1 239 239 240 255 255 255
475255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
476255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
477255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
478255 255 255 202 202 203 0 0 0 0 0 0 0 0 0 0 0 0
4790 0 0 0 0 0 0 0 0 0 0 0 84 84 84 28 28 29
4801 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4830 0 0 0 0 0
4840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4870 0 0 0 0 0 0 0 0 0 0 0 4 4 4 55 55 55
48860 60 60 0 0 0 0 0 0 95 97 97 248 248 249 255 255 255
489255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
490255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
491255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
492255 255 255 244 245 245 0 0 0 0 0 0 0 0 0 0 0 0
4930 0 0 0 0 0 0 0 0 0 0 0 14 14 14 82 82 81
49415 15 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4970 0 0 0 0 0
4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5010 0 0 0 0 0 0 0 0 1 1 1 29 29 30 84 84 84
5020 0 0 0 0 0 0 0 0 156 155 156 247 247 246 255 255 255
503255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
504255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
505255 255 255 255 255 255 247 247 246 240 240 240 232 232 233 232 232 233
506243 243 243 253 253 253 53 54 54 0 0 0 0 0 0 0 0 0
5070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 44 44
50860 60 60 6 6 6 0 0 0 0 0 0 0 0 0 0 0 0
5090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5110 0 0 0 0 0
5120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5150 0 0 0 0 0 0 0 0 10 10 10 81 81 82 14 14 14
5160 0 0 0 0 0 6 6 6 150 151 151 214 214 215 250 251 252
517255 255 255 255 255 255 255 255 255 246 247 248 218 217 217 214 214 215
518218 217 217 244 245 245 255 255 255 255 255 255 255 255 255 250 248 249
519232 232 233 214 214 215 196 196 197 182 183 184 181 181 181 181 181 181
520187 187 188 240 240 240 232 232 233 0 0 0 0 0 0 0 0 0
5210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52278 81 81 34 34 35 1 1 1 0 0 0 0 0 0 0 0 0
5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5250 0 0 0 0 0
5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5290 0 0 0 0 0 1 1 1 39 39 39 74 74 74 0 0 0
5300 0 0 0 0 0 60 60 60 161 161 162 200 200 197 229 229 230
531251 251 252 255 255 255 255 255 255 255 255 255 243 243 241 214 214 215
532248 248 249 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
533239 239 240 214 214 215 193 193 194 182 183 184 178 178 179 176 177 177
534176 177 177 182 183 184 248 248 249 14 14 14 0 0 0 61 65 66
53510 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
53610 10 10 84 84 84 13 13 13 0 0 0 0 0 0 0 0 0
5370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5390 0 0 0 0 0
5400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5430 0 0 0 0 0 10 11 11 82 82 81 7 7 7 0 0 0
5440 0 0 0 0 0 165 165 165 229 229 230 249 250 251 254 254 254
545255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
546255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
547255 255 255 255 255 255 253 253 253 240 240 240 227 227 227 205 205 205
548181 181 181 176 177 177 191 190 190 227 227 227 0 0 0 44 50 50
54984 89 89 61 65 66 0 0 0 0 0 0 0 0 0 0 0 0
5500 0 0 58 58 58 49 50 50 3 3 3 0 0 0 0 0 0
5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5530 0 0 0 0 0
5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5570 0 0 1 1 1 36 36 36 66 66 66 0 0 0 29 33 34
5580 3 3 26 27 27 234 234 234 254 254 254 255 255 255 255 255 255
559255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
560254 254 254 253 253 254 252 253 253 253 253 254 253 254 254 253 254 254
561254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 251 251 252
562227 227 227 187 187 188 176 177 177 222 221 221 13 13 13 0 0 0
56312 15 14 73 79 79 36 40 40 0 0 0 0 0 0 0 0 0
5640 0 0 1 1 1 90 87 86 17 18 18 0 0 0 0 0 0
5650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5670 0 0 0 0 0
5680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5710 0 0 7 7 7 78 81 81 12 12 12 23 31 30 52 58 58
5720 0 0 209 210 210 253 253 253 255 255 255 255 255 255 255 255 255
573255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
574251 251 252 150 151 151 103 103 103 129 130 130 196 196 197 250 250 251
575252 252 253 254 254 254 255 255 255 255 255 255 255 255 255 255 255 255
576255 255 255 240 240 240 193 193 194 196 196 197 229 229 230 0 0 0
5770 0 0 4 10 10 30 40 40 0 3 3 0 0 0 0 0 0
5780 0 0 0 0 0 47 47 47 53 54 54 3 3 3 0 0 0
5790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5810 0 0 0 0 0
5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5850 0 0 23 23 23 81 81 82 0 0 0 52 58 58 36 40 40
58642 42 43 250 250 251 255 255 255 255 255 255 255 255 255 255 255 255
587255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
588227 227 227 7 7 7 7 7 7 7 7 7 7 7 7 44 44 45
589156 155 156 249 250 251 253 253 253 254 254 254 255 255 255 255 255 255
590255 255 255 255 255 255 247 247 246 222 221 221 239 239 240 0 0 0
59130 40 40 44 50 50 23 31 30 29 33 34 0 0 0 0 0 0
5920 0 0 0 0 0 0 0 0 90 87 86 16 16 16 0 0 0
5930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5950 0 0 0 0 0
5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5992 2 2 50 51 51 42 42 43 29 33 34 52 58 58 0 0 0
600232 232 233 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
601255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
602250 251 252 44 44 44 7 7 7 7 7 7 7 7 7 7 7 7
6037 7 7 56 56 56 209 210 210 252 252 253 254 254 254 255 255 255
604255 255 255 255 255 255 255 255 255 254 253 253 249 250 251 146 146 147
60536 40 40 44 50 50 36 40 40 67 70 70 61 65 66 0 0 0
6060 0 0 0 0 0 0 0 0 55 55 55 44 44 45 1 1 1
6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6090 0 0 0 0 0
6100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
61310 10 10 81 81 82 1 1 1 52 58 58 44 50 50 52 53 53
614251 251 252 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
615255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 254 254 254
616253 253 253 187 187 188 8 8 8 7 7 7 7 7 7 7 7 7
6177 7 7 7 7 7 19 19 19 178 178 179 252 252 253 254 254 254
618255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 237 237 238
61910 16 16 30 40 40 0 3 3 23 31 30 84 89 89 0 0 0
6200 0 0 0 0 0 0 0 0 3 3 3 81 81 82 9 9 9
6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6230 0 0 0 0 0
6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
62729 29 30 72 71 71 10 16 16 52 58 58 0 0 0 222 221 221
628255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
629255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
630254 254 254 251 251 252 95 97 97 7 7 7 7 7 7 7 7 7
6317 7 7 7 7 7 7 7 7 10 10 10 161 161 162 251 252 252
632254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 248 248 249
6330 0 0 0 0 0 0 0 0 0 0 0 84 89 89 0 3 3
6340 0 0 0 0 0 0 0 0 0 0 0 74 74 74 26 27 27
6350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6370 0 0 0 0 0
6380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4
64165 64 64 20 20 20 20 25 25 30 40 40 0 0 0 247 247 246
642255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
643255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
644255 255 255 253 253 254 222 221 221 9 9 9 7 7 7 7 7 7
6457 7 7 7 7 7 7 7 7 7 7 7 8 8 8 149 149 150
646252 252 253 254 254 254 255 255 255 255 255 255 255 255 255 252 252 252
6470 0 0 0 0 0 0 0 0 0 0 0 73 79 79 12 15 14
6480 0 0 0 0 0 0 0 0 0 0 0 36 36 36 58 58 58
6493 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6510 0 0 0 0 0
6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20 20 20
65574 74 74 0 0 0 4 10 10 4 10 10 36 36 36 252 252 252
656255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
657255 255 255 255 255 255 255 255 255 227 227 227 253 253 253 255 255 255
658255 255 255 254 254 254 250 251 252 65 64 64 7 7 7 7 7 7
6597 7 7 7 7 7 7 7 7 7 7 7 7 7 7 8 8 8
660146 146 147 251 252 252 254 254 254 255 255 255 255 255 255 253 254 254
6610 0 0 0 0 0 0 0 0 0 0 0 52 58 58 10 16 16
6620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 82 82 81
6639 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6650 0 0 0 0 0
6660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6680 0 0 0 0 0 0 0 0 0 0 0 4 6 6 65 64 64
66925 25 25 0 3 3 30 40 40 0 0 0 187 187 188 254 254 254
670255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
671255 255 255 255 255 255 255 255 255 193 193 194 253 252 252 255 255 255
672255 255 255 255 255 255 252 253 253 129 130 130 7 7 7 7 7 7
6737 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
6748 8 8 149 149 150 252 252 253 254 254 254 255 255 255 254 254 254
67552 53 53 0 0 0 0 0 0 0 0 0 20 25 25 2 5 4
6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81 81 82
67720 20 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6790 0 0 0 0 0
6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6820 0 0 0 0 0 0 0 0 0 0 0 26 26 27 81 81 82
6830 0 0 18 21 21 73 79 79 0 0 0 237 237 238 255 255 255
684255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
685255 255 255 255 255 255 255 255 255 182 183 184 255 255 255 255 255 255
686255 255 255 255 255 255 253 253 253 176 177 177 7 7 7 7 7 7
6877 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
6887 7 7 8 8 8 153 154 155 251 252 252 254 254 254 255 255 255
689150 151 151 0 0 0 0 0 0 0 0 0 20 25 25 0 0 0
6900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 65 64 64
69133 33 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6930 0 0 0 0 0
6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6960 0 0 0 0 0 0 0 0 6 6 6 67 70 70 20 20 20
6970 0 0 23 31 30 82 85 86 0 0 0 247 247 246 255 255 255
698255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
699255 255 255 255 255 255 255 255 255 182 183 184 255 255 255 255 255 255
700255 255 255 255 255 255 253 254 254 214 214 215 7 7 7 7 7 7
7017 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7027 7 7 7 7 7 8 8 8 156 155 156 252 252 253 254 254 254
703167 168 167 0 0 0 0 0 0 0 0 0 67 70 70 0 0 0
7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 47 47 47
70544 44 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7070 0 0 0 0 0
7080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7100 0 0 0 0 0 0 0 0 21 21 22 75 75 76 0 0 0
7110 0 0 29 33 34 84 89 89 0 0 0 248 248 249 255 255 255
712255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
713255 255 255 255 255 255 248 248 249 181 181 181 255 255 255 255 255 255
714255 255 255 255 255 255 254 254 254 240 240 240 7 7 7 7 7 7
7157 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7167 7 7 7 7 7 7 7 7 8 8 8 161 161 162 251 252 252
717185 185 184 4 4 4 0 0 0 10 11 11 100 103 103 0 0 0
7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 36 36
71955 55 55 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7210 0 0 0 0 0
7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7240 0 0 0 0 0 0 0 0 33 33 34 50 51 51 0 0 0
7250 0 0 9 11 11 82 85 86 10 16 16 248 248 249 255 255 255
726255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
727255 255 255 255 255 255 245 244 245 179 180 181 255 255 255 255 255 255
728255 255 255 255 255 255 254 254 254 251 252 252 20 20 20 7 7 7
7297 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
7307 7 7 7 7 7 7 7 7 7 7 7 10 10 10 161 161 162
731205 205 205 17 18 18 0 0 0 95 97 97 78 81 81 0 0 0
7320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36 36 36
73353 54 54 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
7340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7350 0 0 0 0 0
7360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7380 0 0 0 0 0 0 0 0 31 31 31 58 58 58 0 0 0
7390 0 0 0 0 0 67 70 70 78 81 81 248 248 249 255 255 255
740255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
741255 255 255 255 255 255 234 234 234 179 180 181 255 255 255 255 255 255
742255 255 255 255 255 255 254 254 254 251 252 252 23 23 23 7 7 7
7437 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
74410 11 11 84 84 84 161 161 162 209 210 210 229 229 230 237 237 238
745202 202 203 26 26 27 9 11 11 44 50 50 0 0 0 4 6 6
7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 52 53 53
74739 39 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7490 0 0 0 0 0
7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7520 0 0 0 0 0 0 0 0 23 23 23 78 81 81 213 157 40
753243 206 27 243 206 27 54 42 32 73 79 79 222 221 221 255 255 255
754255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
755255 255 255 255 255 255 238 238 236 178 178 179 255 255 255 255 255 255
756255 255 255 255 255 255 254 254 254 251 252 253 36 36 36 7 7 7
7577 7 7 7 7 7 7 7 7 7 7 7 7 7 7 84 84 84
758222 221 221 251 252 252 252 253 253 253 253 253 253 254 254 252 252 253
759146 146 147 140 142 143 156 155 156 110 114 114 26 27 27 82 85 86
76084 89 89 95 97 97 36 40 40 0 0 0 0 0 0 74 74 74
76123 23 23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7630 0 0 0 0 0
7640 0 0 0 0 0 0 0 0 0 0 0 2 2 2 14 14 14
76524 24 24 26 26 27 26 26 27 26 26 27 25 25 26 21 21 22
7667 7 7 0 0 0 1 1 1 34 34 35 238 192 33 244 210 23
767244 212 23 244 212 23 244 210 23 88 79 47 200 200 197 254 254 254
768255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
769255 255 255 255 255 255 244 245 245 179 180 181 255 255 255 255 255 255
770255 255 255 255 255 255 254 254 254 252 252 253 36 36 36 7 7 7
7717 7 7 7 7 7 7 7 7 8 8 8 149 149 150 251 251 252
772252 252 253 253 253 253 253 253 253 250 248 249 239 223 156 239 223 156
773120 121 122 182 183 184 176 177 177 120 121 122 33 33 34 3 3 3
7740 0 0 67 70 70 146 146 147 20 25 25 1 1 1 82 82 81
7759 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7770 0 0 0 0 0
7780 0 0 0 0 0 0 0 0 0 0 0 19 19 19 89 90 91
779146 146 147 150 151 151 150 151 151 150 151 151 150 151 151 129 130 130
78058 58 58 6 6 6 14 14 14 201 147 55 245 211 23 245 213 29
781245 214 35 245 215 41 245 213 29 244 210 23 142 83 36 232 232 233
782254 254 254 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
783255 255 255 255 255 255 255 255 255 185 185 184 255 255 255 255 255 255
784255 255 255 255 255 255 254 254 254 251 252 252 50 51 51 7 7 7
7857 7 7 7 7 7 7 7 7 146 146 147 251 252 252 252 253 253
786251 252 253 239 239 240 171 168 154 129 130 130 137 136 134 175 173 165
787221 218 200 65 64 64 22 22 22 186 186 187 114 115 115 26 26 27
7882 2 2 0 0 0 61 65 66 31 33 27 238 192 33 108 96 91
7899 9 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7910 0 0 0 0 0
7920 0 0 0 0 0 0 0 0 2 2 2 52 53 53 178 178 179
79321 21 22 7 7 7 7 7 7 7 7 7 7 7 7 118 118 118
794137 136 134 36 36 36 65 64 64 243 206 27 244 212 23 245 215 41
795245 215 41 245 215 41 245 215 41 244 209 25 244 209 25 1 1 1
796219 219 219 253 253 253 255 255 255 255 255 255 255 255 255 255 255 255
797255 255 255 255 255 255 255 255 255 214 214 215 255 255 255 255 255 255
798255 255 255 255 255 255 254 254 254 252 252 253 50 51 51 7 7 7
7997 7 7 7 7 7 84 84 84 250 251 252 252 253 253 251 251 252
800167 168 167 22 22 22 7 7 7 7 7 7 7 7 7 7 7 7
8017 7 7 7 7 7 7 7 7 34 34 35 187 187 188 103 103 103
80229 29 30 3 3 3 7 9 9 238 204 29 245 215 41 245 214 35
80328 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8050 0 0 0 0 0
8060 0 0 0 0 0 0 0 0 7 7 7 90 87 86 178 178 179
8077 7 7 7 7 7 7 7 7 7 7 7 7 7 7 16 16 16
808193 193 194 133 133 133 187 166 103 245 218 76 245 218 76 245 216 51
809245 216 51 245 218 76 246 224 96 245 218 76 245 218 76 245 218 76
81025 25 25 186 186 187 252 252 252 254 254 254 254 254 254 253 254 254
811254 254 254 254 254 254 254 254 254 246 247 248 254 254 254 253 254 254
812254 254 254 254 254 254 253 254 254 251 252 252 36 36 36 7 7 7
8137 7 7 20 20 20 229 229 230 253 253 253 252 253 253 178 178 179
81410 10 10 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8157 7 7 7 7 7 7 7 7 7 7 7 42 42 43 196 196 197
816118 118 118 33 33 34 238 204 29 245 215 41 245 215 41 245 215 41
81749 50 50 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
8180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8190 0 0 0 0 0
8200 0 0 0 0 0 0 0 0 17 18 18 120 121 122 137 136 134
8217 7 7 7 7 7 34 34 35 20 20 20 7 7 7 7 7 7
822202 202 203 209 206 202 193 187 162 193 187 162 248 234 156 245 218 76
823245 218 76 248 234 156 193 187 162 193 187 162 193 187 162 214 196 166
824240 219 129 95 97 97 196 196 197 186 186 187 187 187 188 196 196 197
825252 252 253 251 252 253 212 211 212 187 187 188 196 196 197 251 252 252
826218 217 217 187 187 188 191 190 190 250 251 252 24 24 24 7 7 7
8277 7 7 110 114 114 252 252 253 253 254 254 250 251 252 89 90 91
82889 90 91 129 130 130 127 127 126 44 44 44 7 7 7 7 7 7
8297 7 7 7 7 7 7 7 7 7 7 7 7 7 7 49 50 50
830202 202 203 214 196 166 245 216 51 245 214 38 245 214 35 245 214 38
83158 58 58 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0
8320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8330 0 0 0 0 0
8340 0 0 0 0 0 0 0 0 31 31 31 156 155 156 82 82 81
8357 7 7 10 10 10 237 237 238 66 66 66 7 7 7 25 25 25
836247 248 249 81 81 82 7 7 7 31 31 31 247 237 174 245 218 76
837246 226 108 200 200 197 7 7 7 7 7 7 7 7 7 137 136 134
838247 237 174 193 193 194 72 71 71 7 7 7 7 7 7 8 8 8
839196 196 197 250 251 252 67 70 70 7 7 7 84 84 84 244 245 245
84047 47 47 7 7 7 118 118 118 249 250 251 12 12 12 7 7 7
8419 9 9 218 217 217 253 253 253 254 254 254 252 253 253 251 251 252
842249 250 251 237 237 238 95 97 97 9 9 9 15 15 15 95 97 97
84347 47 47 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
84466 66 66 240 230 197 246 226 108 245 214 38 245 211 23 244 212 23
84565 64 64 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0
8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8470 0 0 0 0 0
8480 0 0 0 0 0 2 2 2 52 53 53 185 185 184 25 25 25
8497 7 7 60 60 60 240 240 240 14 14 14 7 7 7 84 84 84
850247 248 249 23 23 23 7 7 7 94 91 88 248 234 156 245 218 76
851248 234 156 127 127 126 7 7 7 7 7 7 7 7 7 167 168 167
852251 248 240 65 64 64 7 7 7 7 7 7 7 7 7 7 7 7
85384 84 84 243 243 243 15 15 15 7 7 7 140 142 143 146 146 147
8547 7 7 33 33 34 237 237 238 243 243 243 21 21 22 120 121 122
855218 217 217 252 252 253 254 254 254 253 253 254 252 253 253 251 252 252
856247 248 249 72 71 71 7 7 7 58 58 58 222 221 221 248 248 249
85775 75 76 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8587 7 7 82 82 81 246 239 193 246 226 108 245 216 51 245 214 38
859238 192 33 21 21 22 1 1 1 0 0 0 0 0 0 0 0 0
8600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8610 0 0 0 0 0
8620 0 0 0 0 0 8 8 8 90 87 86 182 183 184 7 7 7
8637 7 7 120 121 122 187 187 188 7 7 7 7 7 7 146 146 147
864205 205 205 7 7 7 7 7 7 153 153 148 240 219 129 246 224 96
865246 239 193 39 39 39 60 60 60 108 110 110 7 7 7 202 202 203
866227 227 227 7 7 7 7 7 7 205 205 205 89 90 91 7 7 7
867120 121 122 193 193 194 7 7 7 7 7 7 186 186 187 25 25 25
8687 7 7 167 168 167 251 251 252 243 243 243 214 214 215 250 251 252
869251 252 253 254 254 254 253 253 253 219 219 219 140 140 139 140 140 139
870118 118 118 7 7 7 52 53 53 237 237 238 247 247 246 176 177 177
8718 8 8 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
8727 7 7 7 7 7 95 97 97 246 239 193 246 226 108 245 216 51
873245 214 38 201 147 55 31 31 31 103 103 103 103 103 103 72 71 71
8740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8750 0 0 0 0 0
8760 0 0 0 0 0 17 18 18 127 127 126 140 140 139 7 7 7
8777 7 7 17 18 18 17 18 18 7 7 7 95 97 97 244 245 245
878146 146 147 7 7 7 7 7 7 200 200 197 246 226 108 240 219 129
879194 194 184 7 7 7 140 140 139 89 90 91 7 7 7 232 232 233
880165 165 165 7 7 7 31 31 31 249 250 251 39 39 39 7 7 7
881176 177 177 133 133 133 7 7 7 22 22 22 108 110 110 7 7 7
88272 71 71 251 252 252 252 253 253 250 251 252 247 248 249 205 205 205
883251 252 253 254 254 254 252 252 253 84 84 84 7 7 7 7 7 7
8847 7 7 7 7 7 140 142 143 247 248 249 140 140 139 14 14 14
8857 7 7 7 7 7 7 7 7 7 7 7 7 7 7 16 16 16
88614 14 14 7 7 7 7 7 7 114 115 115 246 239 193 246 224 96
887245 216 51 245 216 51 243 235 220 176 177 177 185 185 184 229 229 230
88847 47 47 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8890 0 0 0 0 0
8900 0 0 0 0 0 31 31 31 156 155 156 90 87 86 7 7 7
8917 7 7 7 7 7 7 7 7 31 31 31 243 243 241 247 247 246
89284 84 84 7 7 7 26 27 27 246 239 193 246 226 108 248 234 156
893108 110 110 7 7 7 212 211 212 44 44 44 22 22 22 249 250 251
894108 107 107 7 7 7 89 90 91 238 238 236 114 115 115 118 118 118
895231 231 231 75 75 76 7 7 7 34 34 35 10 11 11 12 12 12
896214 214 215 253 253 253 253 253 253 200 200 197 31 31 31 103 103 103
897252 252 253 252 253 253 218 217 217 9 9 9 7 7 7 7 7 7
8987 7 7 7 7 7 25 25 25 39 39 39 7 7 7 7 7 7
8997 7 7 7 7 7 7 7 7 7 7 7 103 103 103 234 234 234
900181 181 181 7 7 7 7 7 7 7 7 7 133 133 133 247 237 174
901246 224 96 246 226 108 185 185 184 177 177 174 153 154 155 181 181 181
902140 140 139 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9030 0 0 0 0 0
9040 0 0 1 1 1 49 50 50 186 186 187 28 28 28 7 7 7
90512 12 12 22 22 22 7 7 7 7 7 7 108 107 107 247 247 246
90625 25 25 7 7 7 90 87 86 247 237 174 246 226 108 246 239 193
90728 28 28 44 44 44 237 237 238 9 9 9 53 54 54 249 250 251
90849 50 50 7 7 7 153 153 148 249 241 199 214 196 166 185 185 184
909229 229 230 19 19 19 7 7 7 7 7 7 7 7 7 103 103 103
910251 252 253 254 254 254 253 253 253 150 151 151 7 7 7 187 187 188
911252 252 253 251 251 252 103 103 103 7 7 7 7 7 7 7 7 7
9127 7 7 23 23 23 17 18 18 7 7 7 7 7 7 7 7 7
9137 7 7 7 7 7 12 12 12 153 153 148 246 239 193 249 241 199
914161 161 162 9 9 9 84 84 84 108 110 110 25 25 25 153 153 148
915247 237 174 246 224 96 218 217 217 165 165 165 182 183 184 193 193 194
916114 115 115 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9170 0 0 0 0 0
9180 0 0 4 4 4 74 74 74 181 181 181 7 7 7 7 7 7
919110 114 114 200 200 197 7 7 7 7 7 7 60 60 60 209 210 210
9207 7 7 7 7 7 146 146 147 248 234 156 248 234 156 177 177 174
9217 7 7 118 118 118 193 193 194 7 7 7 84 84 84 232 232 233
9228 8 8 7 7 7 209 210 210 221 218 200 193 187 162 219 219 219
923200 200 197 7 7 7 7 7 7 7 7 7 7 7 7 95 97 97
924251 252 252 254 254 254 252 253 253 118 118 118 29 29 30 247 248 249
925252 252 253 227 227 227 16 16 16 7 7 7 7 7 7 7 7 7
926100 103 103 218 217 217 219 218 214 7 7 7 7 7 7 7 7 7
9277 7 7 21 21 22 185 185 184 246 239 193 248 234 156 240 230 197
92860 60 60 194 194 184 246 239 193 249 241 199 137 136 134 10 10 10
929171 168 154 248 234 156 248 234 156 226 226 219 209 210 210 249 241 199
93028 28 28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9310 0 0 0 0 0
9320 0 0 13 13 13 108 110 110 146 146 147 7 7 7 7 7 7
933167 168 167 140 140 139 7 7 7 7 7 7 120 121 122 146 146 147
9347 7 7 7 7 7 194 194 184 240 219 129 247 237 174 95 97 97
9357 7 7 95 97 97 90 87 86 7 7 7 118 118 118 176 177 177
9367 7 7 28 28 28 248 248 249 44 44 45 7 7 7 167 168 167
937140 140 139 7 7 7 36 36 36 74 74 74 7 7 7 65 64 64
938251 252 253 254 254 254 251 252 252 81 81 82 108 110 110 251 252 252
939251 251 252 127 127 126 7 7 7 7 7 7 8 8 8 140 140 139
940181 181 181 140 140 139 221 218 200 7 7 7 7 7 7 7 7 7
94134 34 35 209 210 210 231 231 231 246 239 193 247 237 174 194 194 184
942227 227 227 249 241 199 240 219 129 248 234 156 153 153 148 7 7 7
94313 13 13 185 185 184 248 234 156 245 218 76 245 216 51 245 214 38
94431 31 31 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9450 0 0 0 0 0
9460 0 0 31 31 31 153 154 155 89 90 91 7 7 7 8 8 8
947232 232 233 82 82 81 7 7 7 7 7 7 179 180 181 89 90 91
9487 7 7 24 24 24 243 235 220 248 234 156 240 230 197 20 20 20
9497 7 7 7 7 7 7 7 7 7 7 7 149 149 150 118 118 118
9507 7 7 90 87 86 229 229 230 7 7 7 7 7 7 229 229 230
95182 82 81 7 7 7 95 97 97 100 103 103 7 7 7 34 34 35
952251 252 252 253 253 254 251 251 252 47 47 47 193 193 194 251 252 252
953239 239 240 23 23 23 7 7 7 13 13 13 165 165 165 234 234 234
954149 149 150 146 114 101 200 200 197 7 7 7 7 7 7 52 53 53
955227 227 227 167 168 167 16 16 16 214 196 166 248 234 156 243 235 220
956219 219 219 156 155 156 247 237 174 246 239 193 75 75 76 7 7 7
95760 60 60 227 227 227 243 235 220 240 219 129 245 218 76 245 213 29
95816 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9590 0 0 0 0 0
9601 1 1 49 50 50 185 185 184 33 33 34 7 7 7 10 11 11
96156 56 56 16 16 16 7 7 7 10 10 10 237 237 238 26 27 27
9627 7 7 55 55 55 185 185 184 221 218 200 167 168 167 7 7 7
96320 20 20 39 39 39 10 11 11 7 7 7 181 181 181 58 58 58
9647 7 7 103 103 103 133 133 133 7 7 7 44 44 44 247 248 249
96524 24 24 7 7 7 156 155 156 129 130 130 7 7 7 9 9 9
966244 245 245 252 253 253 237 237 238 34 34 35 248 248 249 251 251 252
967161 161 162 7 7 7 24 24 24 187 187 188 212 211 212 67 70 70
968187 187 188 173 170 143 209 206 202 10 10 10 95 97 97 237 237 238
969129 130 130 8 8 8 89 90 91 246 239 193 247 237 174 177 177 174
97017 18 18 137 136 134 249 241 199 219 218 214 10 10 10 95 97 97
971243 243 243 150 151 151 31 31 31 221 218 200 240 219 129 53 54 54
9723 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9730 0 0 0 0 0
9744 4 4 72 71 71 182 183 184 7 7 7 7 7 7 7 7 7
9757 7 7 7 7 7 12 12 12 161 161 162 209 210 210 7 7 7
9767 7 7 7 7 7 7 7 7 187 187 188 82 82 81 7 7 7
977146 146 147 247 248 249 17 18 18 7 7 7 212 211 212 47 47 47
9787 7 7 7 7 7 7 7 7 8 8 8 146 146 147 205 205 205
9797 7 7 7 7 7 214 214 215 156 155 156 7 7 7 7 7 7
980218 217 217 251 252 252 186 186 187 110 114 114 249 250 251 248 248 249
98175 75 76 34 34 35 205 205 205 129 130 130 16 16 16 7 7 7
982156 155 156 214 196 166 240 230 197 243 243 241 227 227 227 74 74 74
9837 7 7 29 29 30 226 226 219 249 241 199 175 173 165 14 14 14
9849 9 9 221 218 200 246 239 193 153 153 148 146 146 147 246 247 248
985110 114 114 7 7 7 7 7 7 42 42 43 193 193 194 95 97 97
98619 19 19 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0
9870 0 0 0 0 0
9886 6 6 84 84 84 140 142 143 7 7 7 7 7 7 7 7 7
9897 7 7 20 20 20 177 177 174 249 241 199 149 149 150 7 7 7
9907 7 7 7 7 7 10 11 11 226 226 219 13 13 13 8 8 8
991219 218 214 219 218 214 7 7 7 8 8 8 238 238 236 200 200 197
99213 13 13 7 7 7 13 13 13 161 161 162 243 235 220 146 146 147
9937 7 7 29 29 30 232 232 233 176 177 177 7 7 7 7 7 7
994182 183 184 237 237 238 129 130 130 167 168 167 176 177 177 202 202 203
99510 11 11 95 97 97 44 44 45 7 7 7 7 7 7 7 7 7
99675 75 76 226 226 219 243 235 220 156 155 156 24 24 24 7 7 7
9977 7 7 176 177 177 247 247 246 200 200 197 17 18 18 7 7 7
99849 50 50 246 239 193 248 234 156 251 248 240 239 239 240 84 84 84
9997 7 7 7 7 7 7 7 7 7 7 7 60 60 60 187 187 188
100084 84 84 14 14 14 0 0 0 0 0 0 0 0 0 0 0 0
10010 0 0 0 0 0
10024 4 4 53 54 54 137 136 134 156 155 156 161 161 162 161 161 162
1003167 168 167 239 223 156 240 219 129 246 226 108 239 223 156 239 223 156
1004239 223 156 239 223 156 214 196 166 239 223 156 193 187 162 193 187 162
1005248 234 156 239 223 156 193 187 162 193 187 162 248 234 156 248 234 156
1006214 196 166 193 187 162 214 196 166 248 234 156 240 219 129 214 196 166
1007193 187 162 193 187 162 171 168 154 146 146 147 137 136 134 137 136 134
1008161 161 162 209 210 210 65 64 64 202 202 203 179 180 181 140 140 139
10097 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10107 7 7 60 60 60 39 39 39 7 7 7 7 7 7 7 7 7
101166 66 66 249 250 251 202 202 203 16 16 16 7 7 7 7 7 7
101223 23 23 243 235 220 246 239 193 226 226 219 52 53 53 7 7 7
10137 7 7 7 7 7 7 7 7 7 7 7 7 7 7 75 75 76
1014176 177 177 66 66 66 9 9 9 0 0 0 0 0 0 0 0 0
10150 0 0 0 0 0
10160 0 0 10 10 10 28 28 29 34 34 35 36 36 36 36 36 36
101744 44 45 146 114 101 241 207 50 241 207 50 241 207 50 241 211 63
1018241 211 63 241 211 63 241 211 63 241 211 63 241 211 63 245 216 51
1019245 216 51 245 216 51 241 211 63 241 211 63 245 216 51 241 211 63
1020245 218 76 245 218 76 245 216 51 245 215 41 245 214 38 241 207 50
1021241 211 63 201 147 55 88 79 47 29 29 30 34 34 35 42 42 43
1022103 103 103 191 190 190 75 75 76 196 196 197 200 200 197 65 64 64
10237 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10247 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
102590 87 86 146 146 147 19 19 19 7 7 7 7 7 7 7 7 7
10267 7 7 90 87 86 140 140 139 31 31 31 7 7 7 7 7 7
10277 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
1028103 103 103 161 161 162 53 54 54 7 7 7 0 0 0 0 0 0
10290 0 0 0 0 0
10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10310 0 0 12 12 12 50 51 51 146 114 101 180 121 62 199 129 48
1032201 147 55 213 157 40 213 157 40 230 165 41 226 179 40 226 179 40
1033238 192 33 241 205 27 244 209 25 244 210 23 244 212 23 245 211 23
1034245 211 23 245 211 23 245 211 23 244 209 25 238 204 29 226 179 40
1035213 157 40 199 129 48 54 42 32 0 0 0 4 6 6 44 44 45
1036150 151 151 129 130 130 137 136 134 205 205 205 202 202 203 8 8 8
10377 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10387 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10397 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10407 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10417 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10427 7 7 129 130 130 146 146 147 47 47 47 4 4 4 0 0 0
10430 0 0 0 0 0
10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10450 0 0 0 0 0 2 2 2 12 12 12 28 28 29 49 50 50
104674 74 74 108 96 91 180 121 62 180 121 62 199 129 48 201 147 55
1047213 157 40 230 165 41 226 179 40 238 192 33 241 205 27 241 205 27
1048243 206 27 243 206 27 241 205 27 238 204 29 226 179 40 213 157 40
1049199 129 48 199 129 48 21 19 17 65 64 64 103 103 103 167 168 167
1050202 202 203 24 24 24 193 193 194 229 229 230 140 140 139 7 7 7
10517 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10527 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10537 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10547 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10557 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10567 7 7 8 8 8 156 155 156 133 133 133 36 36 36 3 3 3
10570 0 0 0 0 0
10580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1
10604 4 4 10 11 11 21 21 22 39 39 39 60 60 60 108 96 91
1061180 121 62 199 129 48 199 129 48 213 157 40 230 165 41 226 179 40
1062226 179 40 226 179 40 226 179 40 226 179 40 213 157 40 199 129 48
1063180 121 62 99 91 79 72 71 71 56 56 56 129 130 130 167 168 167
106421 21 22 17 18 18 231 231 231 229 229 230 52 53 53 7 7 7
10657 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10677 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10687 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10697 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10707 7 7 7 7 7 13 13 13 176 177 177 120 121 122 33 33 34
10712 2 2 0 0 0
10720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10740 0 0 0 0 0 0 0 0 0 0 0 2 2 2 8 8 8
107521 21 22 47 47 47 99 91 79 180 121 62 199 129 48 199 129 48
1076201 147 55 213 157 40 213 157 40 201 147 55 199 129 48 180 121 62
107799 91 79 26 26 27 9 9 9 60 60 60 186 186 187 31 31 31
10787 7 7 60 60 60 243 243 243 209 210 210 7 7 7 7 7 7
10797 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10807 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10817 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10827 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10837 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
10847 7 7 7 7 7 7 7 7 26 27 27 193 193 194 108 110 110
108522 22 22 0 0 0
10860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10890 0 0 1 1 1 8 8 8 24 24 24 58 58 58 108 96 91
1090180 121 62 180 121 62 180 121 62 180 121 62 180 121 62 72 71 71
109115 15 15 0 0 0 4 6 6 75 75 76 156 155 156 24 24 24
109224 24 24 108 107 107 232 232 233 137 136 134 24 24 24 24 24 24
109324 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109424 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109524 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109624 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109724 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24
109824 24 24 24 24 24 24 24 24 24 24 24 58 58 58 176 177 177
109960 60 60 3 3 3
11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11030 0 0 0 0 0 0 0 0 0 0 0 2 2 2 12 12 12
110426 27 27 44 44 44 55 55 55 50 51 51 29 29 30 8 8 8
11050 0 0 0 0 0 3 3 3 47 47 47 127 127 126 150 151 151
1106150 151 151 140 142 143 129 130 130 140 142 143 150 151 151 150 151 151
1107150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1108150 151 151 150 151 151 153 154 155 161 161 162 165 165 165 167 168 167
1109177 177 174 167 168 167 161 161 162 156 155 156 150 151 151 150 151 151
1110150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1111150 151 151 150 151 151 150 151 151 150 151 151 150 151 151 150 151 151
1112150 151 151 150 151 151 150 151 151 150 151 151 149 149 150 127 127 126
111344 44 45 2 2 2
11140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11180 0 0 0 0 0 2 2 2 1 1 1 0 0 0 0 0 0
11190 0 0 0 0 0 0 0 0 7 7 7 21 21 22 25 25 26
112025 25 26 24 24 24 20 20 20 23 23 24 25 25 26 26 26 27
112126 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112226 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 27 27
112328 28 29 26 27 27 26 26 27 26 26 27 26 26 27 26 26 27
112426 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112526 26 27 26 26 27 26 26 27 26 26 27 26 26 27 26 26 27
112626 26 27 26 26 27 26 26 27 26 26 27 25 25 26 21 21 22
11277 7 7 0 0 0
diff --git a/drivers/video/logo/logo_blackfin_vga16.ppm b/drivers/video/logo/logo_blackfin_vga16.ppm
new file mode 100644
index 000000000000..1352b02a9d93
--- /dev/null
+++ b/drivers/video/logo/logo_blackfin_vga16.ppm
@@ -0,0 +1,1127 @@
1P3
2# This was generated by the GIMP & Netpbm tools
3# gimp linux_bf.svg (create 80x80 save as linux_bf.ppm)
4# ppmquant -mapfile clut_vga16.ppm linux_bf.ppm | pnmnoraw > logo_blackfin_vga16.ppm
5#
680 80
7255
80 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
90 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
210 0 0 0 0 0
220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2885 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85 85
290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
350 0 0 0 0 0
360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
410 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
4285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4385 85 85 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
490 0 0 0 0 0
500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
550 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
570 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
630 0 0 0 0 0
640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
690 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
770 0 0 0 0 0
780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
850 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
8685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
910 0 0 0 0 0
920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
990 0 0 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
1000 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
1010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1050 0 0 0 0 0
1060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1130 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1140 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1190 0 0 0 0 0
1200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1280 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1330 0 0 0 0 0
1340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1420 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
1430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1470 0 0 0 0 0
1480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1520 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1560 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1610 0 0 0 0 0
1620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1660 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1670 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1690 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
1700 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1750 0 0 0 0 0
1760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1800 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1810 0 0 0 0 0 0 0 0 85 85 85 85 85 85 85 85 85
1820 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
183170 170 170 85 85 85 85 85 85 170 170 170 0 0 0 0 0 0
1840 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1890 0 0 0 0 0
1900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1940 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
1950 0 0 170 170 170 170 170 170 170 170 170 85 85 85 85 85 85
1960 0 0 0 0 0 0 0 0 85 85 85 170 170 170 255 255 255
197255 255 255 255 255 255 170 170 170 85 85 85 0 0 0 0 0 0
1980 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
1990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2030 0 0 0 0 0
2040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2080 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
209170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
2100 0 0 0 0 0 0 0 0 255 255 255 255 255 255 255 255 255
211255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
2120 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2170 0 0 0 0 0
2180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2220 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
223255 255 255 170 170 170 85 85 85 170 170 170 255 255 255 255 255 255
2240 0 0 0 0 0 170 170 170 255 255 255 255 255 255 85 85 85
22585 85 85 170 170 170 255 255 255 255 255 255 0 0 0 0 0 0
2260 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2310 0 0 0 0 0
2320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2360 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
237255 255 255 85 85 85 170 170 170 170 170 170 255 255 255 255 255 255
23885 85 85 85 85 85 170 170 170 255 255 255 170 170 170 0 0 0
239170 170 170 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
2400 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2450 0 0 0 0 0
2460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2500 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
251255 255 255 0 0 0 85 85 85 170 170 170 170 170 170 255 255 255
2520 0 0 85 85 85 85 85 85 255 255 255 85 85 85 0 0 0
2530 0 0 85 85 85 170 170 170 255 255 255 85 85 85 0 0 0
2540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2590 0 0 0 0 0
2600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2640 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
265255 255 255 85 85 85 0 0 0 0 0 0 255 85 85 255 255 85
266255 255 85 255 255 85 255 255 85 255 255 85 85 85 85 0 0 0
2670 0 0 0 0 0 170 170 170 255 255 255 0 0 0 0 0 0
2680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2730 0 0 0 0 0
2740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2780 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
279170 170 170 255 255 255 0 0 0 255 85 85 170 85 0 170 85 0
280255 255 85 255 255 85 170 85 0 255 255 85 255 255 85 255 255 85
2810 0 0 85 85 85 255 255 255 255 255 255 0 0 0 0 0 0
2820 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2870 0 0 0 0 0
2880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2930 0 0 255 255 255 255 85 85 255 255 85 255 255 85 255 255 85
294255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
295255 255 85 255 255 85 255 255 85 170 170 170 0 0 0 0 0 0
2960 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
2970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3010 0 0 0 0 0
3020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3050 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3060 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3070 0 0 255 85 85 255 255 85 255 255 85 255 255 85 255 255 85
308255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
309255 255 85 255 255 85 255 255 85 255 255 85 0 0 0 0 0 0
3100 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3150 0 0 0 0 0
3160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
321170 85 0 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
322255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
323255 255 85 170 85 0 85 85 85 255 255 85 0 0 0 0 0 0
3240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
3250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3290 0 0 0 0 0
3300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3330 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
335255 85 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
336255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
337170 85 0 85 85 85 255 255 85 255 255 85 0 0 0 0 0 0
3380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
3390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3430 0 0 0 0 0
3440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3480 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
349170 85 0 170 85 0 255 255 85 255 255 85 255 255 85 255 255 85
350255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 170 85 0
351170 85 0 255 255 85 255 255 85 255 85 85 0 0 0 0 0 0
35285 85 85 85 85 85 85 85 85 0 0 0 0 0 0 85 85 85
3530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3570 0 0 0 0 0
3580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3620 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
36385 85 85 170 85 0 170 85 0 170 85 0 255 255 85 255 255 85
364255 255 85 255 85 85 170 85 0 170 85 0 170 85 0 255 255 85
365255 255 85 255 255 85 255 85 85 170 170 170 0 0 0 0 0 0
36685 85 85 85 85 85 85 85 85 85 85 85 0 0 0 85 85 85
3670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3710 0 0 0 0 0
3720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3760 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
37785 85 85 170 170 170 170 85 0 170 85 0 170 85 0 170 85 0
378170 85 0 170 85 0 170 85 0 255 255 85 255 255 85 255 255 85
379255 85 85 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
3800 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
38185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3850 0 0 0 0 0
3860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3900 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
391170 170 170 170 170 170 170 170 170 170 85 0 255 255 85 255 255 85
392255 255 85 255 255 85 255 255 85 255 255 85 255 85 85 170 170 170
393255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
3940 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
39585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
3990 0 0 0 0 0
4000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4040 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
405170 170 170 255 255 255 255 255 255 170 170 170 170 85 0 255 85 85
406255 85 85 255 85 85 255 85 85 255 85 85 255 255 255 255 255 255
407255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 85 85
4080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4090 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
4100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4130 0 0 0 0 0
4140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4180 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
419170 170 170 255 255 255 255 255 255 170 170 170 170 170 170 170 170 170
420170 170 170 170 170 170 170 170 170 255 255 255 255 255 255 255 255 255
421255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
4220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4230 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
4240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4270 0 0 0 0 0
4280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4310 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4320 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
433255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
434170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
435255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
436170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4370 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
4380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4410 0 0 0 0 0
4420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4460 0 0 0 0 0 85 85 85 0 0 0 0 0 0 255 255 255
447255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
448255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
449255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
450255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4510 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
4520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4550 0 0 0 0 0
4560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4600 0 0 85 85 85 0 0 0 0 0 0 170 170 170 255 255 255
461255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
462255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
463255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
464255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4650 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
4660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4690 0 0 0 0 0
4700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47485 85 85 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
475255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
476255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
477255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
478255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
4790 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
4800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4830 0 0 0 0 0
4840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
48885 85 85 0 0 0 0 0 0 85 85 85 255 255 255 255 255 255
489255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
490255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
491255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
492255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
4930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
4940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4970 0 0 0 0 0
4980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
4990 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
5020 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
503255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
504255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
505255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
506255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
5070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
50885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5110 0 0 0 0 0
5120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5150 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
5160 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
517255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
518255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
519255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
520170 170 170 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
5210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52285 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5250 0 0 0 0 0
5260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5280 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5290 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
5300 0 0 0 0 0 85 85 85 170 170 170 170 170 170 255 255 255
531255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
532255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
533255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
534170 170 170 170 170 170 255 255 255 0 0 0 0 0 0 85 85 85
5350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5360 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5390 0 0 0 0 0
5400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5420 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5430 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5440 0 0 0 0 0 170 170 170 255 255 255 255 255 255 255 255 255
545255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
546255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
547255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
548170 170 170 170 170 170 170 170 170 255 255 255 0 0 0 85 85 85
54985 85 85 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5500 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
5510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5530 0 0 0 0 0
5540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5560 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5570 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5580 0 0 0 0 0 255 255 255 255 255 255 255 255 255 255 255 255
559255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
560255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
561255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
562255 255 255 170 170 170 170 170 170 255 255 255 0 0 0 0 0 0
5630 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5640 0 0 0 0 0 85 85 85 0 0 0 0 0 0 0 0 0
5650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5670 0 0 0 0 0
5680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5700 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5710 0 0 0 0 0 85 85 85 0 0 0 0 0 0 85 85 85
5720 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
573255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
574255 255 255 170 170 170 85 85 85 170 170 170 170 170 170 255 255 255
575255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
576255 255 255 255 255 255 170 170 170 170 170 170 255 255 255 0 0 0
5770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5780 0 0 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
5790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5810 0 0 0 0 0
5820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5840 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5850 0 0 0 0 0 85 85 85 0 0 0 85 85 85 0 0 0
5860 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
587255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
588255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
589170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
590255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 0 0 0
5910 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
5920 0 0 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
5930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5950 0 0 0 0 0
5960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5990 0 0 85 85 85 0 0 0 0 0 0 85 85 85 0 0 0
600255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
601255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
602255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
6030 0 0 85 85 85 170 170 170 255 255 255 255 255 255 255 255 255
604255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
6050 0 0 85 85 85 0 0 0 85 85 85 85 85 85 0 0 0
6060 0 0 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
6070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6090 0 0 0 0 0
6100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6110 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6130 0 0 85 85 85 0 0 0 85 85 85 85 85 85 85 85 85
614255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
615255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
616255 255 255 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
6170 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
618255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6190 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6230 0 0 0 0 0
6240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6270 0 0 85 85 85 0 0 0 85 85 85 0 0 0 255 255 255
628255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
629255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
630255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
6310 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
632255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6330 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6340 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6350 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6370 0 0 0 0 0
6380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
64185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
642255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
643255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
644255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
6450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
646255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6470 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6490 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6510 0 0 0 0 0
6520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
65585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 255 255 255
656255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
657255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
658255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 0 0 0
6590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
660170 170 170 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
6610 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6630 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6650 0 0 0 0 0
6660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6690 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
670255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
671255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
672255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
6730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6740 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
67585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6770 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6790 0 0 0 0 0
6800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6830 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
684255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
685255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
686255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
6870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6880 0 0 0 0 0 170 170 170 255 255 255 255 255 255 255 255 255
689170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
6910 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6920 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6930 0 0 0 0 0
6940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
6960 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
6970 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
698255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
699255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
700255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7020 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
703170 170 170 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
70585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7070 0 0 0 0 0
7080 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7100 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7110 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
712255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
713255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
714255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7160 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
717170 170 170 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
71985 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7210 0 0 0 0 0
7220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7240 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7250 0 0 0 0 0 85 85 85 0 0 0 255 255 255 255 255 255
726255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
727255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
728255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
731170 170 170 0 0 0 0 0 0 85 85 85 85 85 85 0 0 0
7320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
73385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7340 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7350 0 0 0 0 0
7360 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7380 0 0 0 0 0 0 0 0 0 0 0 85 85 85 0 0 0
7390 0 0 0 0 0 85 85 85 85 85 85 255 255 255 255 255 255
740255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
741255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
742255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7430 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7440 0 0 85 85 85 170 170 170 170 170 170 255 255 255 255 255 255
745170 170 170 0 0 0 0 0 0 85 85 85 0 0 0 0 0 0
7460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
7470 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7480 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7490 0 0 0 0 0
7500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7520 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 85 0
753255 255 85 255 255 85 0 0 0 85 85 85 255 255 255 255 255 255
754255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
755255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
756255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7570 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
758255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
759170 170 170 170 170 170 170 170 170 85 85 85 0 0 0 85 85 85
76085 85 85 85 85 85 0 0 0 0 0 0 0 0 0 85 85 85
7610 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7630 0 0 0 0 0
7640 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7660 0 0 0 0 0 0 0 0 0 0 0 255 255 85 255 255 85
767255 255 85 255 255 85 255 255 85 85 85 85 170 170 170 255 255 255
768255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
769255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
770255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
7710 0 0 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
772255 255 255 255 255 255 255 255 255 255 255 255 255 255 85 170 170 170
77385 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
7740 0 0 85 85 85 170 170 170 0 0 0 0 0 0 85 85 85
7750 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7760 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7770 0 0 0 0 0
7780 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
779170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
78085 85 85 0 0 0 0 0 0 170 85 0 255 255 85 255 255 85
781255 255 85 255 255 85 255 255 85 255 255 85 170 85 0 255 255 255
782255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
783255 255 255 255 255 255 255 255 255 170 170 170 255 255 255 255 255 255
784255 255 255 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
7850 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
786255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
787255 255 255 85 85 85 0 0 0 170 170 170 85 85 85 0 0 0
7880 0 0 0 0 0 85 85 85 0 0 0 255 255 85 85 85 85
7890 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7900 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
7910 0 0 0 0 0
7920 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
7930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
794170 170 170 0 0 0 85 85 85 255 255 85 255 255 85 255 255 85
795255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 0 0 0
796255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
797255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
798255 255 255 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
7990 0 0 0 0 0 85 85 85 255 255 255 255 255 255 255 255 255
800170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8010 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
8020 0 0 0 0 0 0 0 0 255 255 85 255 255 85 255 255 85
8030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8050 0 0 0 0 0
8060 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
8070 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
808170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
809255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
8100 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
811255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
812255 255 255 255 255 255 255 255 255 255 255 255 0 0 0 0 0 0
8130 0 0 0 0 0 255 255 255 255 255 255 255 255 255 170 170 170
8140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 170 170 170
81685 85 85 0 0 0 255 255 85 255 255 85 255 255 85 255 255 85
81785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8190 0 0 0 0 0
8200 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
8210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
822170 170 170 170 170 170 170 170 170 170 170 170 255 255 85 255 255 85
823255 255 85 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
824255 255 85 85 85 85 170 170 170 170 170 170 170 170 170 170 170 170
825255 255 255 255 255 255 170 170 170 170 170 170 170 170 170 255 255 255
826255 255 255 170 170 170 170 170 170 255 255 255 0 0 0 0 0 0
8270 0 0 85 85 85 255 255 255 255 255 255 255 255 255 85 85 85
82885 85 85 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
8290 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
830170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
83185 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8320 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8330 0 0 0 0 0
8340 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
8350 0 0 0 0 0 255 255 255 85 85 85 0 0 0 0 0 0
836255 255 255 85 85 85 0 0 0 0 0 0 255 255 255 255 255 85
837255 255 85 170 170 170 0 0 0 0 0 0 0 0 0 170 170 170
838255 255 255 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
839170 170 170 255 255 255 85 85 85 0 0 0 85 85 85 255 255 255
84085 85 85 0 0 0 85 85 85 255 255 255 0 0 0 0 0 0
8410 0 0 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
842255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 85 85 85
84385 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
84485 85 85 255 255 255 255 255 85 255 255 85 255 255 85 255 255 85
84585 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8460 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8470 0 0 0 0 0
8480 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8490 0 0 85 85 85 255 255 255 0 0 0 0 0 0 85 85 85
850255 255 255 0 0 0 0 0 0 85 85 85 255 255 85 255 255 85
851255 255 85 85 85 85 0 0 0 0 0 0 0 0 0 170 170 170
852255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
85385 85 85 255 255 255 0 0 0 0 0 0 170 170 170 170 170 170
8540 0 0 0 0 0 255 255 255 255 255 255 0 0 0 85 85 85
855255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255
856255 255 255 85 85 85 0 0 0 85 85 85 255 255 255 255 255 255
85785 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8580 0 0 85 85 85 255 255 255 255 255 85 255 255 85 255 255 85
859255 255 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8600 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8610 0 0 0 0 0
8620 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8630 0 0 85 85 85 170 170 170 0 0 0 0 0 0 170 170 170
864170 170 170 0 0 0 0 0 0 170 170 170 255 255 85 255 255 85
865255 255 255 0 0 0 85 85 85 85 85 85 0 0 0 170 170 170
866255 255 255 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
86785 85 85 170 170 170 0 0 0 0 0 0 170 170 170 0 0 0
8680 0 0 170 170 170 255 255 255 255 255 255 255 255 255 255 255 255
869255 255 255 255 255 255 255 255 255 255 255 255 170 170 170 170 170 170
87085 85 85 0 0 0 85 85 85 255 255 255 255 255 255 170 170 170
8710 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8720 0 0 0 0 0 85 85 85 255 255 255 255 255 85 255 255 85
873255 255 85 170 85 0 0 0 0 85 85 85 85 85 85 85 85 85
8740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8750 0 0 0 0 0
8760 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
8770 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
878170 170 170 0 0 0 0 0 0 170 170 170 255 255 85 255 255 85
879170 170 170 0 0 0 170 170 170 85 85 85 0 0 0 255 255 255
880170 170 170 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0
881170 170 170 170 170 170 0 0 0 0 0 0 85 85 85 0 0 0
88285 85 85 255 255 255 255 255 255 255 255 255 255 255 255 170 170 170
883255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 0 0 0
8840 0 0 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
8850 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8860 0 0 0 0 0 0 0 0 85 85 85 255 255 255 255 255 85
887255 255 85 255 255 85 255 255 255 170 170 170 170 170 170 255 255 255
88885 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8890 0 0 0 0 0
8900 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
8910 0 0 0 0 0 0 0 0 0 0 0 255 255 255 255 255 255
89285 85 85 0 0 0 0 0 0 255 255 255 255 255 85 255 255 85
89385 85 85 0 0 0 255 255 255 85 85 85 0 0 0 255 255 255
89485 85 85 0 0 0 85 85 85 255 255 255 85 85 85 85 85 85
895255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
896255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 85 85 85
897255 255 255 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
8980 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
8990 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
900170 170 170 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
901255 255 85 255 255 85 170 170 170 170 170 170 170 170 170 170 170 170
902170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9030 0 0 0 0 0
9040 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
9050 0 0 0 0 0 0 0 0 0 0 0 85 85 85 255 255 255
9060 0 0 0 0 0 85 85 85 255 255 85 255 255 85 255 255 255
9070 0 0 85 85 85 255 255 255 0 0 0 85 85 85 255 255 255
90885 85 85 0 0 0 170 170 170 255 255 255 170 170 170 170 170 170
909255 255 255 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
910255 255 255 255 255 255 255 255 255 170 170 170 0 0 0 170 170 170
911255 255 255 255 255 255 85 85 85 0 0 0 0 0 0 0 0 0
9120 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9130 0 0 0 0 0 0 0 0 170 170 170 255 255 255 255 255 255
914170 170 170 0 0 0 85 85 85 85 85 85 0 0 0 170 170 170
915255 255 85 255 255 85 255 255 255 170 170 170 170 170 170 170 170 170
91685 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9170 0 0 0 0 0
9180 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
91985 85 85 170 170 170 0 0 0 0 0 0 85 85 85 170 170 170
9200 0 0 0 0 0 170 170 170 255 255 85 255 255 85 170 170 170
9210 0 0 85 85 85 170 170 170 0 0 0 85 85 85 255 255 255
9220 0 0 0 0 0 170 170 170 170 170 170 170 170 170 255 255 255
923170 170 170 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
924255 255 255 255 255 255 255 255 255 85 85 85 0 0 0 255 255 255
925255 255 255 255 255 255 0 0 0 0 0 0 0 0 0 0 0 0
92685 85 85 255 255 255 255 255 255 0 0 0 0 0 0 0 0 0
9270 0 0 0 0 0 170 170 170 255 255 255 255 255 85 255 255 255
92885 85 85 170 170 170 255 255 255 255 255 255 170 170 170 0 0 0
929170 170 170 255 255 85 255 255 85 255 255 255 170 170 170 255 255 255
9300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9310 0 0 0 0 0
9320 0 0 0 0 0 85 85 85 170 170 170 0 0 0 0 0 0
933170 170 170 170 170 170 0 0 0 0 0 0 85 85 85 170 170 170
9340 0 0 0 0 0 170 170 170 255 255 85 255 255 255 85 85 85
9350 0 0 85 85 85 85 85 85 0 0 0 85 85 85 170 170 170
9360 0 0 0 0 0 255 255 255 85 85 85 0 0 0 170 170 170
937170 170 170 0 0 0 0 0 0 85 85 85 0 0 0 85 85 85
938255 255 255 255 255 255 255 255 255 85 85 85 85 85 85 255 255 255
939255 255 255 85 85 85 0 0 0 0 0 0 0 0 0 170 170 170
940170 170 170 170 170 170 255 255 255 0 0 0 0 0 0 0 0 0
9410 0 0 170 170 170 255 255 255 255 255 255 255 255 85 170 170 170
942255 255 255 255 255 255 255 255 85 255 255 85 170 170 170 0 0 0
9430 0 0 170 170 170 255 255 85 255 255 85 255 255 85 255 255 85
9440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9450 0 0 0 0 0
9460 0 0 0 0 0 170 170 170 85 85 85 0 0 0 0 0 0
947255 255 255 85 85 85 0 0 0 0 0 0 170 170 170 85 85 85
9480 0 0 0 0 0 255 255 255 255 255 85 255 255 255 0 0 0
9490 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9500 0 0 85 85 85 255 255 255 0 0 0 0 0 0 255 255 255
95185 85 85 0 0 0 85 85 85 85 85 85 0 0 0 0 0 0
952255 255 255 255 255 255 255 255 255 85 85 85 170 170 170 255 255 255
953255 255 255 0 0 0 0 0 0 0 0 0 170 170 170 255 255 255
954170 170 170 85 85 85 170 170 170 0 0 0 0 0 0 85 85 85
955255 255 255 170 170 170 0 0 0 170 170 170 255 255 85 255 255 255
956255 255 255 170 170 170 255 255 255 255 255 255 85 85 85 0 0 0
95785 85 85 255 255 255 255 255 255 255 255 85 255 255 85 255 255 85
9580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9590 0 0 0 0 0
9600 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
96185 85 85 0 0 0 0 0 0 0 0 0 255 255 255 0 0 0
9620 0 0 85 85 85 170 170 170 255 255 255 170 170 170 0 0 0
9630 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9640 0 0 85 85 85 170 170 170 0 0 0 85 85 85 255 255 255
9650 0 0 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
966255 255 255 255 255 255 255 255 255 0 0 0 255 255 255 255 255 255
967170 170 170 0 0 0 0 0 0 170 170 170 255 255 255 85 85 85
968170 170 170 170 170 170 170 170 170 0 0 0 85 85 85 255 255 255
969170 170 170 0 0 0 85 85 85 255 255 255 255 255 85 170 170 170
9700 0 0 170 170 170 255 255 255 255 255 255 0 0 0 85 85 85
971255 255 255 170 170 170 0 0 0 170 170 170 255 255 85 85 85 85
9720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9730 0 0 0 0 0
9740 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
9750 0 0 0 0 0 0 0 0 170 170 170 170 170 170 0 0 0
9760 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
977170 170 170 255 255 255 0 0 0 0 0 0 170 170 170 85 85 85
9780 0 0 0 0 0 0 0 0 0 0 0 170 170 170 170 170 170
9790 0 0 0 0 0 255 255 255 170 170 170 0 0 0 0 0 0
980255 255 255 255 255 255 170 170 170 85 85 85 255 255 255 255 255 255
98185 85 85 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
982170 170 170 170 170 170 255 255 255 255 255 255 255 255 255 85 85 85
9830 0 0 0 0 0 255 255 255 255 255 255 170 170 170 0 0 0
9840 0 0 170 170 170 255 255 255 170 170 170 170 170 170 255 255 255
98585 85 85 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
9860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
9870 0 0 0 0 0
9880 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
9890 0 0 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
9900 0 0 0 0 0 0 0 0 255 255 255 0 0 0 0 0 0
991255 255 255 255 255 255 0 0 0 0 0 0 255 255 255 170 170 170
9920 0 0 0 0 0 0 0 0 170 170 170 255 255 255 170 170 170
9930 0 0 0 0 0 255 255 255 170 170 170 0 0 0 0 0 0
994170 170 170 255 255 255 170 170 170 170 170 170 170 170 170 170 170 170
9950 0 0 85 85 85 85 85 85 0 0 0 0 0 0 0 0 0
99685 85 85 255 255 255 255 255 255 170 170 170 0 0 0 0 0 0
9970 0 0 170 170 170 255 255 255 170 170 170 0 0 0 0 0 0
99885 85 85 255 255 255 255 255 85 255 255 255 255 255 255 85 85 85
9990 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
100085 85 85 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10010 0 0 0 0 0
10020 0 0 85 85 85 170 170 170 170 170 170 170 170 170 170 170 170
1003170 170 170 170 170 170 255 255 85 255 255 85 255 255 85 170 170 170
1004170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1005255 255 85 170 170 170 170 170 170 170 170 170 255 255 85 255 255 85
1006170 170 170 170 170 170 170 170 170 255 255 85 255 255 85 170 170 170
1007170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1008170 170 170 170 170 170 85 85 85 170 170 170 170 170 170 170 170 170
10090 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10100 0 0 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
101185 85 85 255 255 255 170 170 170 0 0 0 0 0 0 0 0 0
10120 0 0 255 255 255 255 255 255 255 255 255 85 85 85 0 0 0
10130 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
1014170 170 170 85 85 85 0 0 0 0 0 0 0 0 0 0 0 0
10150 0 0 0 0 0
10160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
101785 85 85 85 85 85 255 255 85 255 255 85 255 255 85 255 255 85
1018255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1019255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1020255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1021255 255 85 255 85 85 85 85 85 0 0 0 0 0 0 0 0 0
102285 85 85 170 170 170 85 85 85 170 170 170 170 170 170 85 85 85
10230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102585 85 85 170 170 170 0 0 0 0 0 0 0 0 0 0 0 0
10260 0 0 85 85 85 170 170 170 0 0 0 0 0 0 0 0 0
10270 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
102885 85 85 170 170 170 85 85 85 0 0 0 0 0 0 0 0 0
10290 0 0 0 0 0
10300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10310 0 0 0 0 0 85 85 85 85 85 85 170 85 0 170 85 0
1032170 85 0 255 85 85 255 85 85 255 85 85 255 255 85 255 255 85
1033255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1034255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 255 85
1035255 85 85 170 85 0 85 85 85 0 0 0 0 0 0 85 85 85
1036170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 0 0 0
10370 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10380 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10390 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10400 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10410 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10420 0 0 170 170 170 170 170 170 85 85 85 0 0 0 0 0 0
10430 0 0 0 0 0
10440 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10450 0 0 0 0 0 0 0 0 0 0 0 0 0 0 85 85 85
104685 85 85 85 85 85 170 85 0 170 85 0 170 85 0 170 85 0
1047255 85 85 255 85 85 255 255 85 255 255 85 255 255 85 255 255 85
1048255 255 85 255 255 85 255 255 85 255 255 85 255 255 85 255 85 85
1049170 85 0 170 85 0 0 0 0 85 85 85 85 85 85 170 170 170
1050170 170 170 0 0 0 170 170 170 255 255 255 170 170 170 0 0 0
10510 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10520 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10540 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10550 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10560 0 0 0 0 0 170 170 170 170 170 170 0 0 0 0 0 0
10570 0 0 0 0 0
10580 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10590 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10600 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1061170 85 0 170 85 0 170 85 0 255 85 85 255 85 85 255 255 85
1062255 255 85 255 255 85 255 255 85 255 255 85 255 85 85 170 85 0
1063170 85 0 85 85 85 85 85 85 85 85 85 170 170 170 170 170 170
10640 0 0 0 0 0 255 255 255 255 255 255 85 85 85 0 0 0
10650 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10660 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10670 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10680 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10690 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10700 0 0 0 0 0 0 0 0 170 170 170 85 85 85 0 0 0
10710 0 0 0 0 0
10720 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10730 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10740 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10750 0 0 85 85 85 85 85 85 170 85 0 170 85 0 170 85 0
1076170 85 0 255 85 85 255 85 85 255 85 85 170 85 0 170 85 0
107785 85 85 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
10780 0 0 85 85 85 255 255 255 170 170 170 0 0 0 0 0 0
10790 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10810 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10820 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10830 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10840 0 0 0 0 0 0 0 0 0 0 0 170 170 170 85 85 85
10850 0 0 0 0 0
10860 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10870 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10880 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10890 0 0 0 0 0 0 0 0 0 0 0 85 85 85 85 85 85
1090170 85 0 170 85 0 170 85 0 170 85 0 170 85 0 85 85 85
10910 0 0 0 0 0 0 0 0 85 85 85 170 170 170 0 0 0
10920 0 0 85 85 85 255 255 255 170 170 170 0 0 0 0 0 0
10930 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10940 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10950 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10960 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10970 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
10980 0 0 0 0 0 0 0 0 0 0 0 85 85 85 170 170 170
109985 85 85 0 0 0
11000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11010 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11020 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11030 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11040 0 0 85 85 85 85 85 85 85 85 85 0 0 0 0 0 0
11050 0 0 0 0 0 0 0 0 85 85 85 85 85 85 170 170 170
1106170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1107170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1108170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1109170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1110170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1111170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 170
1112170 170 170 170 170 170 170 170 170 170 170 170 170 170 170 85 85 85
111385 85 85 0 0 0
11140 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11150 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11160 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11170 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11180 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11190 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11200 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11210 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11220 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11230 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11240 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11260 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
11270 0 0 0 0 0
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index c95874fe9076..9e903454ffc1 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -15,10 +15,9 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/fb.h> 16#include <linux/fb.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/of_device.h>
18 19
19#include <asm/io.h> 20#include <asm/io.h>
20#include <asm/prom.h>
21#include <asm/of_device.h>
22#include <asm/fbio.h> 21#include <asm/fbio.h>
23 22
24#include "sbuslib.h" 23#include "sbuslib.h"
@@ -275,7 +274,7 @@ static int __devinit p9100_probe(struct of_device *op, const struct of_device_id
275 par->physbase = op->resource[2].start; 274 par->physbase = op->resource[2].start;
276 par->which_io = op->resource[2].flags & IORESOURCE_BITS; 275 par->which_io = op->resource[2].flags & IORESOURCE_BITS;
277 276
278 sbusfb_fill_var(&info->var, dp->node, 8); 277 sbusfb_fill_var(&info->var, dp, 8);
279 info->var.red.length = 8; 278 info->var.red.length = 8;
280 info->var.green.length = 8; 279 info->var.green.length = 8;
281 info->var.blue.length = 8; 280 info->var.blue.length = 8;
@@ -295,7 +294,7 @@ static int __devinit p9100_probe(struct of_device *op, const struct of_device_id
295 if (!info->screen_base) 294 if (!info->screen_base)
296 goto out_unmap_regs; 295 goto out_unmap_regs;
297 296
298 p9100_blank(0, info); 297 p9100_blank(FB_BLANK_UNBLANK, info);
299 298
300 if (fb_alloc_cmap(&info->cmap, 256, 0)) 299 if (fb_alloc_cmap(&info->cmap, 256, 0))
301 goto out_unmap_screen; 300 goto out_unmap_screen;
diff --git a/drivers/video/pnx4008/pnxrgbfb.c b/drivers/video/pnx4008/pnxrgbfb.c
index 685761a0732c..4db6b48a8715 100644
--- a/drivers/video/pnx4008/pnxrgbfb.c
+++ b/drivers/video/pnx4008/pnxrgbfb.c
@@ -100,7 +100,6 @@ static int rgbfb_remove(struct platform_device *pdev)
100 fb_dealloc_cmap(&info->cmap); 100 fb_dealloc_cmap(&info->cmap);
101 framebuffer_release(info); 101 framebuffer_release(info);
102 platform_set_drvdata(pdev, NULL); 102 platform_set_drvdata(pdev, NULL);
103 kfree(info);
104 } 103 }
105 104
106 pnx4008_free_dum_channel(channel_owned, pdev->id); 105 pnx4008_free_dum_channel(channel_owned, pdev->id);
@@ -168,23 +167,21 @@ static int __devinit rgbfb_probe(struct platform_device *pdev)
168 167
169 ret = fb_alloc_cmap(&info->cmap, 256, 0); 168 ret = fb_alloc_cmap(&info->cmap, 256, 0);
170 if (ret < 0) 169 if (ret < 0)
171 goto err2; 170 goto err1;
172 171
173 ret = register_framebuffer(info); 172 ret = register_framebuffer(info);
174 if (ret < 0) 173 if (ret < 0)
175 goto err3; 174 goto err2;
176 platform_set_drvdata(pdev, info); 175 platform_set_drvdata(pdev, info);
177 176
178 return 0; 177 return 0;
179 178
180err3:
181 fb_dealloc_cmap(&info->cmap);
182err2: 179err2:
183 framebuffer_release(info); 180 fb_dealloc_cmap(&info->cmap);
184err1: 181err1:
185 pnx4008_free_dum_channel(channel_owned, pdev->id); 182 pnx4008_free_dum_channel(channel_owned, pdev->id);
186err0: 183err0:
187 kfree(info); 184 framebuffer_release(info);
188err: 185err:
189 return ret; 186 return ret;
190} 187}
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 3ab6e3d973a1..48aea39c35a5 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -1301,8 +1301,8 @@ static void pxafb_decode_mode_info(struct pxafb_info *fbi,
1301 } 1301 }
1302} 1302}
1303 1303
1304static int pxafb_decode_mach_info(struct pxafb_info *fbi, 1304static void pxafb_decode_mach_info(struct pxafb_info *fbi,
1305 struct pxafb_mach_info *inf) 1305 struct pxafb_mach_info *inf)
1306{ 1306{
1307 unsigned int lcd_conn = inf->lcd_conn; 1307 unsigned int lcd_conn = inf->lcd_conn;
1308 1308
@@ -1333,7 +1333,7 @@ static int pxafb_decode_mach_info(struct pxafb_info *fbi,
1333 fbi->lccr0 = inf->lccr0; 1333 fbi->lccr0 = inf->lccr0;
1334 fbi->lccr3 = inf->lccr3; 1334 fbi->lccr3 = inf->lccr3;
1335 fbi->lccr4 = inf->lccr4; 1335 fbi->lccr4 = inf->lccr4;
1336 return -EINVAL; 1336 goto decode_mode;
1337 } 1337 }
1338 1338
1339 if (lcd_conn == LCD_MONO_STN_8BPP) 1339 if (lcd_conn == LCD_MONO_STN_8BPP)
@@ -1343,8 +1343,8 @@ static int pxafb_decode_mach_info(struct pxafb_info *fbi,
1343 fbi->lccr3 |= (lcd_conn & LCD_BIAS_ACTIVE_LOW) ? LCCR3_OEP : 0; 1343 fbi->lccr3 |= (lcd_conn & LCD_BIAS_ACTIVE_LOW) ? LCCR3_OEP : 0;
1344 fbi->lccr3 |= (lcd_conn & LCD_PCLK_EDGE_FALL) ? LCCR3_PCP : 0; 1344 fbi->lccr3 |= (lcd_conn & LCD_PCLK_EDGE_FALL) ? LCCR3_PCP : 0;
1345 1345
1346decode_mode:
1346 pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes); 1347 pxafb_decode_mode_info(fbi, inf->modes, inf->num_modes);
1347 return 0;
1348} 1348}
1349 1349
1350static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev) 1350static struct pxafb_info * __init pxafb_init_fbinfo(struct device *dev)
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 4deaac05b938..37d764ad56b0 100644
--- a/drivers/video/sbuslib.c
+++ b/drivers/video/sbuslib.c
@@ -10,18 +10,19 @@
10#include <linux/fb.h> 10#include <linux/fb.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/uaccess.h> 12#include <linux/uaccess.h>
13#include <linux/of_device.h>
13 14
14#include <asm/oplib.h>
15#include <asm/fbio.h> 15#include <asm/fbio.h>
16 16
17#include "sbuslib.h" 17#include "sbuslib.h"
18 18
19void sbusfb_fill_var(struct fb_var_screeninfo *var, int prom_node, int bpp) 19void sbusfb_fill_var(struct fb_var_screeninfo *var, struct device_node *dp,
20 int bpp)
20{ 21{
21 memset(var, 0, sizeof(*var)); 22 memset(var, 0, sizeof(*var));
22 23
23 var->xres = prom_getintdefault(prom_node, "width", 1152); 24 var->xres = of_getintprop_default(dp, "width", 1152);
24 var->yres = prom_getintdefault(prom_node, "height", 900); 25 var->yres = of_getintprop_default(dp, "height", 900);
25 var->xres_virtual = var->xres; 26 var->xres_virtual = var->xres;
26 var->yres_virtual = var->yres; 27 var->yres_virtual = var->yres;
27 var->bits_per_pixel = bpp; 28 var->bits_per_pixel = bpp;
diff --git a/drivers/video/sbuslib.h b/drivers/video/sbuslib.h
index 492828c3fe8f..7ba3250236bd 100644
--- a/drivers/video/sbuslib.h
+++ b/drivers/video/sbuslib.h
@@ -11,7 +11,8 @@ struct sbus_mmap_map {
11#define SBUS_MMAP_FBSIZE(n) (-n) 11#define SBUS_MMAP_FBSIZE(n) (-n)
12#define SBUS_MMAP_EMPTY 0x80000000 12#define SBUS_MMAP_EMPTY 0x80000000
13 13
14extern void sbusfb_fill_var(struct fb_var_screeninfo *var, int prom_node, int bpp); 14extern void sbusfb_fill_var(struct fb_var_screeninfo *var,
15 struct device_node *dp, int bpp);
15struct vm_area_struct; 16struct vm_area_struct;
16extern int sbusfb_mmap_helper(struct sbus_mmap_map *map, 17extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
17 unsigned long physbase, unsigned long fbsize, 18 unsigned long physbase, unsigned long fbsize,
@@ -21,6 +22,6 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
21 struct fb_info *info, 22 struct fb_info *info,
22 int type, int fb_depth, unsigned long fb_size); 23 int type, int fb_depth, unsigned long fb_size);
23int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd, 24int sbusfb_compat_ioctl(struct fb_info *info, unsigned int cmd,
24 unsigned long arg); 25 unsigned long arg);
25 26
26#endif /* _SBUSLIB_H */ 27#endif /* _SBUSLIB_H */
diff --git a/drivers/video/sunxvr2500.c b/drivers/video/sunxvr2500.c
index c3869a96ab58..b1dde09e7015 100644
--- a/drivers/video/sunxvr2500.c
+++ b/drivers/video/sunxvr2500.c
@@ -9,10 +9,9 @@
9#include <linux/fb.h> 9#include <linux/fb.h>
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/of_device.h>
12 13
13#include <asm/io.h> 14#include <asm/io.h>
14#include <asm/prom.h>
15#include <asm/of_device.h>
16 15
17struct s3d_info { 16struct s3d_info {
18 struct fb_info *info; 17 struct fb_info *info;
diff --git a/drivers/video/sunxvr500.c b/drivers/video/sunxvr500.c
index 71bf3f1f00bc..c2ba51b7ea18 100644
--- a/drivers/video/sunxvr500.c
+++ b/drivers/video/sunxvr500.c
@@ -9,10 +9,9 @@
9#include <linux/fb.h> 9#include <linux/fb.h>
10#include <linux/pci.h> 10#include <linux/pci.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/of_device.h>
12 13
13#include <asm/io.h> 14#include <asm/io.h>
14#include <asm/prom.h>
15#include <asm/of_device.h>
16 15
17/* XXX This device has a 'dev-comm' property which aparently is 16/* XXX This device has a 'dev-comm' property which aparently is
18 * XXX a pointer into the openfirmware's address space which is 17 * XXX a pointer into the openfirmware's address space which is
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index a71774305772..2a03f78bbb0d 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -17,10 +17,9 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/fb.h> 18#include <linux/fb.h>
19#include <linux/mm.h> 19#include <linux/mm.h>
20#include <linux/of_device.h>
20 21
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/prom.h>
23#include <asm/of_device.h>
24#include <asm/fbio.h> 23#include <asm/fbio.h>
25 24
26#include "sbuslib.h" 25#include "sbuslib.h"
@@ -84,7 +83,7 @@ struct tcx_tec {
84 83
85struct tcx_thc { 84struct tcx_thc {
86 u32 thc_rev; 85 u32 thc_rev;
87 u32 thc_pad0[511]; 86 u32 thc_pad0[511];
88 u32 thc_hs; /* hsync timing */ 87 u32 thc_hs; /* hsync timing */
89 u32 thc_hsdvs; 88 u32 thc_hsdvs;
90 u32 thc_hd; 89 u32 thc_hd;
@@ -126,10 +125,10 @@ struct tcx_par {
126}; 125};
127 126
128/* Reset control plane so that WID is 8-bit plane. */ 127/* Reset control plane so that WID is 8-bit plane. */
129static void __tcx_set_control_plane (struct tcx_par *par) 128static void __tcx_set_control_plane(struct tcx_par *par)
130{ 129{
131 u32 __iomem *p, *pend; 130 u32 __iomem *p, *pend;
132 131
133 if (par->lowdepth) 132 if (par->lowdepth)
134 return; 133 return;
135 134
@@ -143,8 +142,8 @@ static void __tcx_set_control_plane (struct tcx_par *par)
143 sbus_writel(tmp, p); 142 sbus_writel(tmp, p);
144 } 143 }
145} 144}
146 145
147static void tcx_reset (struct fb_info *info) 146static void tcx_reset(struct fb_info *info)
148{ 147{
149 struct tcx_par *par = (struct tcx_par *) info->par; 148 struct tcx_par *par = (struct tcx_par *) info->par;
150 unsigned long flags; 149 unsigned long flags;
@@ -365,7 +364,8 @@ static void tcx_unmap_regs(struct of_device *op, struct fb_info *info,
365 info->screen_base, par->fbsize); 364 info->screen_base, par->fbsize);
366} 365}
367 366
368static int __devinit tcx_init_one(struct of_device *op) 367static int __devinit tcx_probe(struct of_device *op,
368 const struct of_device_id *match)
369{ 369{
370 struct device_node *dp = op->node; 370 struct device_node *dp = op->node;
371 struct fb_info *info; 371 struct fb_info *info;
@@ -384,7 +384,7 @@ static int __devinit tcx_init_one(struct of_device *op)
384 par->lowdepth = 384 par->lowdepth =
385 (of_find_property(dp, "tcx-8-bit", NULL) != NULL); 385 (of_find_property(dp, "tcx-8-bit", NULL) != NULL);
386 386
387 sbusfb_fill_var(&info->var, dp->node, 8); 387 sbusfb_fill_var(&info->var, dp, 8);
388 info->var.red.length = 8; 388 info->var.red.length = 8;
389 info->var.green.length = 8; 389 info->var.green.length = 8;
390 info->var.blue.length = 8; 390 info->var.blue.length = 8;
@@ -488,13 +488,6 @@ out_err:
488 return err; 488 return err;
489} 489}
490 490
491static int __devinit tcx_probe(struct of_device *dev, const struct of_device_id *match)
492{
493 struct of_device *op = to_of_device(&dev->dev);
494
495 return tcx_init_one(op);
496}
497
498static int __devexit tcx_remove(struct of_device *op) 491static int __devexit tcx_remove(struct of_device *op)
499{ 492{
500 struct fb_info *info = dev_get_drvdata(&op->dev); 493 struct fb_info *info = dev_get_drvdata(&op->dev);
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index bd54cd0de39a..beefab2992c0 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -27,7 +27,6 @@
27#define VERSION "0.7.8-NEWAPI" 27#define VERSION "0.7.8-NEWAPI"
28 28
29struct tridentfb_par { 29struct tridentfb_par {
30 int vclk; /* in MHz */
31 void __iomem *io_virt; /* iospace virtual memory address */ 30 void __iomem *io_virt; /* iospace virtual memory address */
32}; 31};
33 32
@@ -669,27 +668,26 @@ static void set_screen_start(int base)
669 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17)); 668 (read3X4(CRTHiOrd) & 0xF8) | ((base & 0xE0000) >> 17));
670} 669}
671 670
672/* Use 20.12 fixed-point for NTSC value and frequency calculation */
673#define calc_freq(n, m, k) ( ((unsigned long)0xE517 * (n + 8) / ((m + 2) * (1 << k))) >> 12 )
674
675/* Set dotclock frequency */ 671/* Set dotclock frequency */
676static void set_vclk(int freq) 672static void set_vclk(unsigned long freq)
677{ 673{
678 int m, n, k; 674 int m, n, k;
679 int f, fi, d, di; 675 unsigned long f, fi, d, di;
680 unsigned char lo = 0, hi = 0; 676 unsigned char lo = 0, hi = 0;
681 677
682 d = 20; 678 d = 20000;
683 for (k = 2; k >= 0; k--) 679 for (k = 2; k >= 0; k--)
684 for (m = 0; m < 63; m++) 680 for (m = 0; m < 63; m++)
685 for (n = 0; n < 128; n++) { 681 for (n = 0; n < 128; n++) {
686 fi = calc_freq(n, m, k); 682 fi = ((14318l * (n + 8)) / (m + 2)) >> k;
687 if ((di = abs(fi - freq)) < d) { 683 if ((di = abs(fi - freq)) < d) {
688 d = di; 684 d = di;
689 f = fi; 685 f = fi;
690 lo = n; 686 lo = n;
691 hi = (k << 6) | m; 687 hi = (k << 6) | m;
692 } 688 }
689 if (fi > freq)
690 break;
693 } 691 }
694 if (chip3D) { 692 if (chip3D) {
695 write3C4(ClockHigh, hi); 693 write3C4(ClockHigh, hi);
@@ -888,6 +886,8 @@ static int tridentfb_set_par(struct fb_info *info)
888 struct fb_var_screeninfo *var = &info->var; 886 struct fb_var_screeninfo *var = &info->var;
889 int bpp = var->bits_per_pixel; 887 int bpp = var->bits_per_pixel;
890 unsigned char tmp; 888 unsigned char tmp;
889 unsigned long vclk;
890
891 debug("enter\n"); 891 debug("enter\n");
892 hdispend = var->xres / 8 - 1; 892 hdispend = var->xres / 8 - 1;
893 hsyncstart = (var->xres + var->right_margin) / 8; 893 hsyncstart = (var->xres + var->right_margin) / 8;
@@ -905,7 +905,6 @@ static int tridentfb_set_par(struct fb_info *info)
905 vblankstart = var->yres; 905 vblankstart = var->yres;
906 vblankend = vtotal + 2; 906 vblankend = vtotal + 2;
907 907
908 enable_mmio();
909 crtc_unlock(); 908 crtc_unlock();
910 write3CE(CyberControl, 8); 909 write3CE(CyberControl, 8);
911 910
@@ -1015,11 +1014,11 @@ static int tridentfb_set_par(struct fb_info *info)
1015 write3X4(Performance, 0x92); 1014 write3X4(Performance, 0x92);
1016 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */ 1015 write3X4(PCIReg, 0x07); /* MMIO & PCI read and write burst enable */
1017 1016
1018 /* convert from picoseconds to MHz */ 1017 /* convert from picoseconds to kHz */
1019 par->vclk = 1000000 / info->var.pixclock; 1018 vclk = PICOS2KHZ(info->var.pixclock);
1020 if (bpp == 32) 1019 if (bpp == 32)
1021 par->vclk *= 2; 1020 vclk *= 2;
1022 set_vclk(par->vclk); 1021 set_vclk(vclk);
1023 1022
1024 write3C4(0, 3); 1023 write3C4(0, 3);
1025 write3C4(1, 1); /* set char clock 8 dots wide */ 1024 write3C4(1, 1); /* set char clock 8 dots wide */
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 26e07df783b9..c3bbd6af996d 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -22,6 +22,21 @@
22 22
23#include <linux/list.h> 23#include <linux/list.h>
24 24
25/**
26 * struct v9fs_dentry - 9p private data stored in dentry d_fsdata
27 * @lock: protects the fidlist
28 * @fidlist: list of FIDs currently associated with this dentry
29 *
30 * This structure defines the 9p private data associated with
31 * a particular dentry. In particular, this private data is used
32 * to lookup which 9P FID handle should be used for a particular VFS
33 * operation. FID handles are associated with dentries instead of
34 * inodes in order to more closely map functionality to the Plan 9
35 * expected behavior for FID reclaimation and tracking.
36 *
37 * See Also: Mapping FIDs to Linux VFS model in
38 * Design and Implementation of the Linux 9P File System documentation
39 */
25struct v9fs_dentry { 40struct v9fs_dentry {
26 spinlock_t lock; /* protect fidlist */ 41 spinlock_t lock; /* protect fidlist */
27 struct list_head fidlist; 42 struct list_head fidlist;
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 9b0f0222e8bb..047c791427aa 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -71,19 +71,19 @@ static match_table_t tokens = {
71 71
72/** 72/**
73 * v9fs_parse_options - parse mount options into session structure 73 * v9fs_parse_options - parse mount options into session structure
74 * @options: options string passed from mount
75 * @v9ses: existing v9fs session information 74 * @v9ses: existing v9fs session information
76 * 75 *
76 * Return 0 upon success, -ERRNO upon failure.
77 */ 77 */
78 78
79static void v9fs_parse_options(struct v9fs_session_info *v9ses) 79static int v9fs_parse_options(struct v9fs_session_info *v9ses)
80{ 80{
81 char *options; 81 char *options;
82 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
83 char *p; 83 char *p;
84 int option = 0; 84 int option = 0;
85 char *s, *e; 85 char *s, *e;
86 int ret; 86 int ret = 0;
87 87
88 /* setup defaults */ 88 /* setup defaults */
89 v9ses->afid = ~0; 89 v9ses->afid = ~0;
@@ -91,19 +91,26 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
91 v9ses->cache = 0; 91 v9ses->cache = 0;
92 92
93 if (!v9ses->options) 93 if (!v9ses->options)
94 return; 94 return 0;
95 95
96 options = kstrdup(v9ses->options, GFP_KERNEL); 96 options = kstrdup(v9ses->options, GFP_KERNEL);
97 if (!options) {
98 P9_DPRINTK(P9_DEBUG_ERROR,
99 "failed to allocate copy of option string\n");
100 return -ENOMEM;
101 }
102
97 while ((p = strsep(&options, ",")) != NULL) { 103 while ((p = strsep(&options, ",")) != NULL) {
98 int token; 104 int token;
99 if (!*p) 105 if (!*p)
100 continue; 106 continue;
101 token = match_token(p, tokens, args); 107 token = match_token(p, tokens, args);
102 if (token < Opt_uname) { 108 if (token < Opt_uname) {
103 ret = match_int(&args[0], &option); 109 int r = match_int(&args[0], &option);
104 if (ret < 0) { 110 if (r < 0) {
105 P9_DPRINTK(P9_DEBUG_ERROR, 111 P9_DPRINTK(P9_DEBUG_ERROR,
106 "integer field, but no integer?\n"); 112 "integer field, but no integer?\n");
113 ret = r;
107 continue; 114 continue;
108 } 115 }
109 } 116 }
@@ -125,10 +132,10 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
125 v9ses->afid = option; 132 v9ses->afid = option;
126 break; 133 break;
127 case Opt_uname: 134 case Opt_uname:
128 match_strcpy(v9ses->uname, &args[0]); 135 match_strlcpy(v9ses->uname, &args[0], PATH_MAX);
129 break; 136 break;
130 case Opt_remotename: 137 case Opt_remotename:
131 match_strcpy(v9ses->aname, &args[0]); 138 match_strlcpy(v9ses->aname, &args[0], PATH_MAX);
132 break; 139 break;
133 case Opt_nodevmap: 140 case Opt_nodevmap:
134 v9ses->nodev = 1; 141 v9ses->nodev = 1;
@@ -139,6 +146,13 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
139 146
140 case Opt_access: 147 case Opt_access:
141 s = match_strdup(&args[0]); 148 s = match_strdup(&args[0]);
149 if (!s) {
150 P9_DPRINTK(P9_DEBUG_ERROR,
151 "failed to allocate copy"
152 " of option argument\n");
153 ret = -ENOMEM;
154 break;
155 }
142 v9ses->flags &= ~V9FS_ACCESS_MASK; 156 v9ses->flags &= ~V9FS_ACCESS_MASK;
143 if (strcmp(s, "user") == 0) 157 if (strcmp(s, "user") == 0)
144 v9ses->flags |= V9FS_ACCESS_USER; 158 v9ses->flags |= V9FS_ACCESS_USER;
@@ -158,6 +172,7 @@ static void v9fs_parse_options(struct v9fs_session_info *v9ses)
158 } 172 }
159 } 173 }
160 kfree(options); 174 kfree(options);
175 return ret;
161} 176}
162 177
163/** 178/**
@@ -173,6 +188,7 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
173{ 188{
174 int retval = -EINVAL; 189 int retval = -EINVAL;
175 struct p9_fid *fid; 190 struct p9_fid *fid;
191 int rc;
176 192
177 v9ses->uname = __getname(); 193 v9ses->uname = __getname();
178 if (!v9ses->uname) 194 if (!v9ses->uname)
@@ -190,8 +206,21 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
190 v9ses->uid = ~0; 206 v9ses->uid = ~0;
191 v9ses->dfltuid = V9FS_DEFUID; 207 v9ses->dfltuid = V9FS_DEFUID;
192 v9ses->dfltgid = V9FS_DEFGID; 208 v9ses->dfltgid = V9FS_DEFGID;
193 v9ses->options = kstrdup(data, GFP_KERNEL); 209 if (data) {
194 v9fs_parse_options(v9ses); 210 v9ses->options = kstrdup(data, GFP_KERNEL);
211 if (!v9ses->options) {
212 P9_DPRINTK(P9_DEBUG_ERROR,
213 "failed to allocate copy of option string\n");
214 retval = -ENOMEM;
215 goto error;
216 }
217 }
218
219 rc = v9fs_parse_options(v9ses);
220 if (rc < 0) {
221 retval = rc;
222 goto error;
223 }
195 224
196 v9ses->clnt = p9_client_create(dev_name, v9ses->options); 225 v9ses->clnt = p9_client_create(dev_name, v9ses->options);
197 226
@@ -233,7 +262,6 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
233 return fid; 262 return fid;
234 263
235error: 264error:
236 v9fs_session_close(v9ses);
237 return ERR_PTR(retval); 265 return ERR_PTR(retval);
238} 266}
239 267
@@ -256,9 +284,12 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
256} 284}
257 285
258/** 286/**
259 * v9fs_session_cancel - mark transport as disconnected 287 * v9fs_session_cancel - terminate a session
260 * and cancel all pending requests. 288 * @v9ses: session to terminate
289 *
290 * mark transport as disconnected and cancel all pending requests.
261 */ 291 */
292
262void v9fs_session_cancel(struct v9fs_session_info *v9ses) { 293void v9fs_session_cancel(struct v9fs_session_info *v9ses) {
263 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses); 294 P9_DPRINTK(P9_DEBUG_ERROR, "cancel session %p\n", v9ses);
264 p9_client_disconnect(v9ses->clnt); 295 p9_client_disconnect(v9ses->clnt);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 7d3a1018db52..a7d567192998 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -21,18 +21,69 @@
21 * 21 *
22 */ 22 */
23 23
24/* 24/**
25 * Session structure provides information for an opened session 25 * enum p9_session_flags - option flags for each 9P session
26 * 26 * @V9FS_EXTENDED: whether or not to use 9P2000.u extensions
27 */ 27 * @V9FS_ACCESS_SINGLE: only the mounting user can access the hierarchy
28 * @V9FS_ACCESS_USER: a new attach will be issued for every user (default)
29 * @V9FS_ACCESS_ANY: use a single attach for all users
30 * @V9FS_ACCESS_MASK: bit mask of different ACCESS options
31 *
32 * Session flags reflect options selected by users at mount time
33 */
34enum p9_session_flags {
35 V9FS_EXTENDED = 0x01,
36 V9FS_ACCESS_SINGLE = 0x02,
37 V9FS_ACCESS_USER = 0x04,
38 V9FS_ACCESS_ANY = 0x06,
39 V9FS_ACCESS_MASK = 0x06,
40};
41
42/* possible values of ->cache */
43/**
44 * enum p9_cache_modes - user specified cache preferences
45 * @CACHE_NONE: do not cache data, dentries, or directory contents (default)
46 * @CACHE_LOOSE: cache data, dentries, and directory contents w/no consistency
47 *
48 * eventually support loose, tight, time, session, default always none
49 */
50
51enum p9_cache_modes {
52 CACHE_NONE,
53 CACHE_LOOSE,
54};
55
56/**
57 * struct v9fs_session_info - per-instance session information
58 * @flags: session options of type &p9_session_flags
59 * @nodev: set to 1 to disable device mapping
60 * @debug: debug level
61 * @afid: authentication handle
62 * @cache: cache mode of type &p9_cache_modes
63 * @options: copy of options string given by user
64 * @uname: string user name to mount hierarchy as
65 * @aname: mount specifier for remote hierarchy
66 * @maxdata: maximum data to be sent/recvd per protocol message
67 * @dfltuid: default numeric userid to mount hierarchy as
68 * @dfltgid: default numeric groupid to mount hierarchy as
69 * @uid: if %V9FS_ACCESS_SINGLE, the numeric uid which mounted the hierarchy
70 * @clnt: reference to 9P network client instantiated for this session
71 * @debugfs_dir: reference to debugfs_dir which can be used for add'l debug
72 *
73 * This structure holds state for each session instance established during
74 * a sys_mount() .
75 *
76 * Bugs: there seems to be a lot of state which could be condensed and/or
77 * removed.
78 */
28 79
29struct v9fs_session_info { 80struct v9fs_session_info {
30 /* options */ 81 /* options */
31 unsigned char flags; /* session flags */ 82 unsigned char flags;
32 unsigned char nodev; /* set to 1 if no disable device mapping */ 83 unsigned char nodev;
33 unsigned short debug; /* debug level */ 84 unsigned short debug;
34 unsigned int afid; /* authentication fid */ 85 unsigned int afid;
35 unsigned int cache; /* cache mode */ 86 unsigned int cache;
36 87
37 char *options; /* copy of mount options */ 88 char *options; /* copy of mount options */
38 char *uname; /* user name to mount as */ 89 char *uname; /* user name to mount as */
@@ -45,22 +96,6 @@ struct v9fs_session_info {
45 struct dentry *debugfs_dir; 96 struct dentry *debugfs_dir;
46}; 97};
47 98
48/* session flags */
49enum {
50 V9FS_EXTENDED = 0x01, /* 9P2000.u */
51 V9FS_ACCESS_MASK = 0x06, /* access mask */
52 V9FS_ACCESS_SINGLE = 0x02, /* only one user can access the files */
53 V9FS_ACCESS_USER = 0x04, /* attache per user */
54 V9FS_ACCESS_ANY = 0x06, /* use the same attach for all users */
55};
56
57/* possible values of ->cache */
58/* eventually support loose, tight, time, session, default always none */
59enum {
60 CACHE_NONE, /* default */
61 CACHE_LOOSE, /* no consistency */
62};
63
64extern struct dentry *v9fs_debugfs_root; 99extern struct dentry *v9fs_debugfs_root;
65 100
66struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *, 101struct p9_fid *v9fs_session_init(struct v9fs_session_info *, const char *,
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 6248f0e727a3..97d3aed57983 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -43,7 +43,7 @@
43/** 43/**
44 * v9fs_vfs_readpage - read an entire page in from 9P 44 * v9fs_vfs_readpage - read an entire page in from 9P
45 * 45 *
46 * @file: file being read 46 * @filp: file being read
47 * @page: structure to page 47 * @page: structure to page
48 * 48 *
49 */ 49 */
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index 0924d4477da3..88e3787c6ea9 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -60,7 +60,7 @@ static inline int dt_type(struct p9_stat *mistat)
60 60
61/** 61/**
62 * v9fs_dir_readdir - read a directory 62 * v9fs_dir_readdir - read a directory
63 * @filep: opened file structure 63 * @filp: opened file structure
64 * @dirent: directory structure ??? 64 * @dirent: directory structure ???
65 * @filldir: function to populate directory structure ??? 65 * @filldir: function to populate directory structure ???
66 * 66 *
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index a616fff8906d..0d55affe37d4 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -90,10 +90,11 @@ int v9fs_file_open(struct inode *inode, struct file *file)
90 90
91/** 91/**
92 * v9fs_file_lock - lock a file (or directory) 92 * v9fs_file_lock - lock a file (or directory)
93 * @inode: inode to be opened 93 * @filp: file to be locked
94 * @file: file being opened 94 * @cmd: lock command
95 * @fl: file lock structure
95 * 96 *
96 * XXX - this looks like a local only lock, we should extend into 9P 97 * Bugs: this looks like a local only lock, we should extend into 9P
97 * by using open exclusive 98 * by using open exclusive
98 */ 99 */
99 100
@@ -118,7 +119,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
118 119
119/** 120/**
120 * v9fs_file_read - read from a file 121 * v9fs_file_read - read from a file
121 * @filep: file pointer to read 122 * @filp: file pointer to read
122 * @data: data buffer to read data into 123 * @data: data buffer to read data into
123 * @count: size of buffer 124 * @count: size of buffer
124 * @offset: offset at which to read data 125 * @offset: offset at which to read data
@@ -142,7 +143,7 @@ v9fs_file_read(struct file *filp, char __user * data, size_t count,
142 143
143/** 144/**
144 * v9fs_file_write - write to a file 145 * v9fs_file_write - write to a file
145 * @filep: file pointer to write 146 * @filp: file pointer to write
146 * @data: data buffer to write data from 147 * @data: data buffer to write data from
147 * @count: size of buffer 148 * @count: size of buffer
148 * @offset: offset at which to write data 149 * @offset: offset at which to write data
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 6a28842052ea..40fa807bd929 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -129,6 +129,12 @@ static int p9mode2unixmode(struct v9fs_session_info *v9ses, int mode)
129 return res; 129 return res;
130} 130}
131 131
132/**
133 * v9fs_uflags2omode- convert posix open flags to plan 9 mode bits
134 * @uflags: flags to convert
135 *
136 */
137
132int v9fs_uflags2omode(int uflags) 138int v9fs_uflags2omode(int uflags)
133{ 139{
134 int ret; 140 int ret;
@@ -312,6 +318,14 @@ error:
312} 318}
313*/ 319*/
314 320
321/**
322 * v9fs_inode_from_fid - populate an inode by issuing a attribute request
323 * @v9ses: session information
324 * @fid: fid to issue attribute request for
325 * @sb: superblock on which to create inode
326 *
327 */
328
315static struct inode * 329static struct inode *
316v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, 330v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
317 struct super_block *sb) 331 struct super_block *sb)
@@ -384,9 +398,12 @@ v9fs_open_created(struct inode *inode, struct file *file)
384 398
385/** 399/**
386 * v9fs_create - Create a file 400 * v9fs_create - Create a file
401 * @v9ses: session information
402 * @dir: directory that dentry is being created in
387 * @dentry: dentry that is being created 403 * @dentry: dentry that is being created
388 * @perm: create permissions 404 * @perm: create permissions
389 * @mode: open mode 405 * @mode: open mode
406 * @extension: 9p2000.u extension string to support devices, etc.
390 * 407 *
391 */ 408 */
392static struct p9_fid * 409static struct p9_fid *
@@ -461,7 +478,7 @@ error:
461 478
462/** 479/**
463 * v9fs_vfs_create - VFS hook to create files 480 * v9fs_vfs_create - VFS hook to create files
464 * @inode: directory inode that is being created 481 * @dir: directory inode that is being created
465 * @dentry: dentry that is being deleted 482 * @dentry: dentry that is being deleted
466 * @mode: create permissions 483 * @mode: create permissions
467 * @nd: path information 484 * @nd: path information
@@ -519,7 +536,7 @@ error:
519 536
520/** 537/**
521 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory 538 * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
522 * @inode: inode that is being unlinked 539 * @dir: inode that is being unlinked
523 * @dentry: dentry that is being unlinked 540 * @dentry: dentry that is being unlinked
524 * @mode: mode for new directory 541 * @mode: mode for new directory
525 * 542 *
@@ -703,9 +720,9 @@ done:
703 720
704/** 721/**
705 * v9fs_vfs_getattr - retrieve file metadata 722 * v9fs_vfs_getattr - retrieve file metadata
706 * @mnt - mount information 723 * @mnt: mount information
707 * @dentry - file to get attributes on 724 * @dentry: file to get attributes on
708 * @stat - metadata structure to populate 725 * @stat: metadata structure to populate
709 * 726 *
710 */ 727 */
711 728
@@ -928,7 +945,7 @@ done:
928/** 945/**
929 * v9fs_vfs_readlink - read a symlink's location 946 * v9fs_vfs_readlink - read a symlink's location
930 * @dentry: dentry for symlink 947 * @dentry: dentry for symlink
931 * @buf: buffer to load symlink location into 948 * @buffer: buffer to load symlink location into
932 * @buflen: length of buffer 949 * @buflen: length of buffer
933 * 950 *
934 */ 951 */
@@ -996,10 +1013,12 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
996 * v9fs_vfs_put_link - release a symlink path 1013 * v9fs_vfs_put_link - release a symlink path
997 * @dentry: dentry for symlink 1014 * @dentry: dentry for symlink
998 * @nd: nameidata 1015 * @nd: nameidata
1016 * @p: unused
999 * 1017 *
1000 */ 1018 */
1001 1019
1002static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p) 1020static void
1021v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
1003{ 1022{
1004 char *s = nd_get_link(nd); 1023 char *s = nd_get_link(nd);
1005 1024
@@ -1008,6 +1027,15 @@ static void v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void
1008 __putname(s); 1027 __putname(s);
1009} 1028}
1010 1029
1030/**
1031 * v9fs_vfs_mkspecial - create a special file
1032 * @dir: inode to create special file in
1033 * @dentry: dentry to create
1034 * @mode: mode to create special file
1035 * @extension: 9p2000.u format extension string representing special file
1036 *
1037 */
1038
1011static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry, 1039static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1012 int mode, const char *extension) 1040 int mode, const char *extension)
1013{ 1041{
@@ -1037,7 +1065,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
1037 * @dentry: dentry for symlink 1065 * @dentry: dentry for symlink
1038 * @symname: symlink data 1066 * @symname: symlink data
1039 * 1067 *
1040 * See 9P2000.u RFC for more information 1068 * See Also: 9P2000.u RFC for more information
1041 * 1069 *
1042 */ 1070 */
1043 1071
@@ -1058,10 +1086,6 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1058 * 1086 *
1059 */ 1087 */
1060 1088
1061/* XXX - lots of code dup'd from symlink and creates,
1062 * figure out a better reuse strategy
1063 */
1064
1065static int 1089static int
1066v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, 1090v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
1067 struct dentry *dentry) 1091 struct dentry *dentry)
@@ -1098,7 +1122,7 @@ clunk_fid:
1098 * @dir: inode destination for new link 1122 * @dir: inode destination for new link
1099 * @dentry: dentry for file 1123 * @dentry: dentry for file
1100 * @mode: mode for creation 1124 * @mode: mode for creation
1101 * @dev_t: device associated with special file 1125 * @rdev: device associated with special file
1102 * 1126 *
1103 */ 1127 */
1104 1128
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index a452ac67fc94..bf59c3960494 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -75,6 +75,7 @@ static int v9fs_set_super(struct super_block *s, void *data)
75 * v9fs_fill_super - populate superblock with info 75 * v9fs_fill_super - populate superblock with info
76 * @sb: superblock 76 * @sb: superblock
77 * @v9ses: session information 77 * @v9ses: session information
78 * @flags: flags propagated from v9fs_get_sb()
78 * 79 *
79 */ 80 */
80 81
@@ -127,29 +128,26 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
127 fid = v9fs_session_init(v9ses, dev_name, data); 128 fid = v9fs_session_init(v9ses, dev_name, data);
128 if (IS_ERR(fid)) { 129 if (IS_ERR(fid)) {
129 retval = PTR_ERR(fid); 130 retval = PTR_ERR(fid);
130 fid = NULL; 131 goto close_session;
131 kfree(v9ses);
132 v9ses = NULL;
133 goto error;
134 } 132 }
135 133
136 st = p9_client_stat(fid); 134 st = p9_client_stat(fid);
137 if (IS_ERR(st)) { 135 if (IS_ERR(st)) {
138 retval = PTR_ERR(st); 136 retval = PTR_ERR(st);
139 goto error; 137 goto clunk_fid;
140 } 138 }
141 139
142 sb = sget(fs_type, NULL, v9fs_set_super, v9ses); 140 sb = sget(fs_type, NULL, v9fs_set_super, v9ses);
143 if (IS_ERR(sb)) { 141 if (IS_ERR(sb)) {
144 retval = PTR_ERR(sb); 142 retval = PTR_ERR(sb);
145 goto error; 143 goto free_stat;
146 } 144 }
147 v9fs_fill_super(sb, v9ses, flags); 145 v9fs_fill_super(sb, v9ses, flags);
148 146
149 inode = v9fs_get_inode(sb, S_IFDIR | mode); 147 inode = v9fs_get_inode(sb, S_IFDIR | mode);
150 if (IS_ERR(inode)) { 148 if (IS_ERR(inode)) {
151 retval = PTR_ERR(inode); 149 retval = PTR_ERR(inode);
152 goto error; 150 goto release_sb;
153 } 151 }
154 152
155 inode->i_uid = uid; 153 inode->i_uid = uid;
@@ -158,7 +156,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
158 root = d_alloc_root(inode); 156 root = d_alloc_root(inode);
159 if (!root) { 157 if (!root) {
160 retval = -ENOMEM; 158 retval = -ENOMEM;
161 goto error; 159 goto release_sb;
162 } 160 }
163 161
164 sb->s_root = root; 162 sb->s_root = root;
@@ -169,21 +167,22 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
169 167
170 return simple_set_mnt(mnt, sb); 168 return simple_set_mnt(mnt, sb);
171 169
172error: 170release_sb:
173 kfree(st);
174 if (fid)
175 p9_client_clunk(fid);
176
177 if (v9ses) {
178 v9fs_session_close(v9ses);
179 kfree(v9ses);
180 }
181
182 if (sb) { 171 if (sb) {
183 up_write(&sb->s_umount); 172 up_write(&sb->s_umount);
184 deactivate_super(sb); 173 deactivate_super(sb);
185 } 174 }
186 175
176free_stat:
177 kfree(st);
178
179clunk_fid:
180 p9_client_clunk(fid);
181
182close_session:
183 v9fs_session_close(v9ses);
184 kfree(v9ses);
185
187 return retval; 186 return retval;
188} 187}
189 188
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index d5bd497ab9cb..223b1917093e 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -48,7 +48,7 @@ struct affs_ext_key {
48 * affs fs inode data in memory 48 * affs fs inode data in memory
49 */ 49 */
50struct affs_inode_info { 50struct affs_inode_info {
51 u32 i_opencnt; 51 atomic_t i_opencnt;
52 struct semaphore i_link_lock; /* Protects internal inode access. */ 52 struct semaphore i_link_lock; /* Protects internal inode access. */
53 struct semaphore i_ext_lock; /* Protects internal inode access. */ 53 struct semaphore i_ext_lock; /* Protects internal inode access. */
54#define i_hash_lock i_ext_lock 54#define i_hash_lock i_ext_lock
@@ -170,8 +170,6 @@ extern int affs_rename(struct inode *old_dir, struct dentry *old_dentry,
170extern unsigned long affs_parent_ino(struct inode *dir); 170extern unsigned long affs_parent_ino(struct inode *dir);
171extern struct inode *affs_new_inode(struct inode *dir); 171extern struct inode *affs_new_inode(struct inode *dir);
172extern int affs_notify_change(struct dentry *dentry, struct iattr *attr); 172extern int affs_notify_change(struct dentry *dentry, struct iattr *attr);
173extern void affs_put_inode(struct inode *inode);
174extern void affs_drop_inode(struct inode *inode);
175extern void affs_delete_inode(struct inode *inode); 173extern void affs_delete_inode(struct inode *inode);
176extern void affs_clear_inode(struct inode *inode); 174extern void affs_clear_inode(struct inode *inode);
177extern struct inode *affs_iget(struct super_block *sb, 175extern struct inode *affs_iget(struct super_block *sb,
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 1a4f092f24ef..6eac7bdeec94 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -48,8 +48,9 @@ affs_file_open(struct inode *inode, struct file *filp)
48{ 48{
49 if (atomic_read(&filp->f_count) != 1) 49 if (atomic_read(&filp->f_count) != 1)
50 return 0; 50 return 0;
51 pr_debug("AFFS: open(%d)\n", AFFS_I(inode)->i_opencnt); 51 pr_debug("AFFS: open(%lu,%d)\n",
52 AFFS_I(inode)->i_opencnt++; 52 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt));
53 atomic_inc(&AFFS_I(inode)->i_opencnt);
53 return 0; 54 return 0;
54} 55}
55 56
@@ -58,10 +59,16 @@ affs_file_release(struct inode *inode, struct file *filp)
58{ 59{
59 if (atomic_read(&filp->f_count) != 0) 60 if (atomic_read(&filp->f_count) != 0)
60 return 0; 61 return 0;
61 pr_debug("AFFS: release(%d)\n", AFFS_I(inode)->i_opencnt); 62 pr_debug("AFFS: release(%lu, %d)\n",
62 AFFS_I(inode)->i_opencnt--; 63 inode->i_ino, atomic_read(&AFFS_I(inode)->i_opencnt));
63 if (!AFFS_I(inode)->i_opencnt) 64
65 if (atomic_dec_and_test(&AFFS_I(inode)->i_opencnt)) {
66 mutex_lock(&inode->i_mutex);
67 if (inode->i_size != AFFS_I(inode)->mmu_private)
68 affs_truncate(inode);
64 affs_free_prealloc(inode); 69 affs_free_prealloc(inode);
70 mutex_unlock(&inode->i_mutex);
71 }
65 72
66 return 0; 73 return 0;
67} 74}
@@ -180,7 +187,7 @@ affs_get_extblock(struct inode *inode, u32 ext)
180 /* inline the simplest case: same extended block as last time */ 187 /* inline the simplest case: same extended block as last time */
181 struct buffer_head *bh = AFFS_I(inode)->i_ext_bh; 188 struct buffer_head *bh = AFFS_I(inode)->i_ext_bh;
182 if (ext == AFFS_I(inode)->i_ext_last) 189 if (ext == AFFS_I(inode)->i_ext_last)
183 atomic_inc(&bh->b_count); 190 get_bh(bh);
184 else 191 else
185 /* we have to do more (not inlined) */ 192 /* we have to do more (not inlined) */
186 bh = affs_get_extblock_slow(inode, ext); 193 bh = affs_get_extblock_slow(inode, ext);
@@ -306,7 +313,7 @@ store_ext:
306 affs_brelse(AFFS_I(inode)->i_ext_bh); 313 affs_brelse(AFFS_I(inode)->i_ext_bh);
307 AFFS_I(inode)->i_ext_last = ext; 314 AFFS_I(inode)->i_ext_last = ext;
308 AFFS_I(inode)->i_ext_bh = bh; 315 AFFS_I(inode)->i_ext_bh = bh;
309 atomic_inc(&bh->b_count); 316 get_bh(bh);
310 317
311 return bh; 318 return bh;
312 319
@@ -324,7 +331,6 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
324 331
325 pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block); 332 pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block);
326 333
327
328 BUG_ON(block > (sector_t)0x7fffffffUL); 334 BUG_ON(block > (sector_t)0x7fffffffUL);
329 335
330 if (block >= AFFS_I(inode)->i_blkcnt) { 336 if (block >= AFFS_I(inode)->i_blkcnt) {
@@ -827,6 +833,8 @@ affs_truncate(struct inode *inode)
827 res = mapping->a_ops->write_begin(NULL, mapping, size, 0, 0, &page, &fsdata); 833 res = mapping->a_ops->write_begin(NULL, mapping, size, 0, 0, &page, &fsdata);
828 if (!res) 834 if (!res)
829 res = mapping->a_ops->write_end(NULL, mapping, size, 0, 0, page, fsdata); 835 res = mapping->a_ops->write_end(NULL, mapping, size, 0, 0, page, fsdata);
836 else
837 inode->i_size = AFFS_I(inode)->mmu_private;
830 mark_inode_dirty(inode); 838 mark_inode_dirty(inode);
831 return; 839 return;
832 } else if (inode->i_size == AFFS_I(inode)->mmu_private) 840 } else if (inode->i_size == AFFS_I(inode)->mmu_private)
@@ -862,6 +870,7 @@ affs_truncate(struct inode *inode)
862 blk++; 870 blk++;
863 } else 871 } else
864 AFFS_HEAD(ext_bh)->first_data = 0; 872 AFFS_HEAD(ext_bh)->first_data = 0;
873 AFFS_HEAD(ext_bh)->block_count = cpu_to_be32(i);
865 size = AFFS_SB(sb)->s_hashsize; 874 size = AFFS_SB(sb)->s_hashsize;
866 if (size > blkcnt - blk + i) 875 if (size > blkcnt - blk + i)
867 size = blkcnt - blk + i; 876 size = blkcnt - blk + i;
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 27fe6cbe43ae..a13b334a3910 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -58,7 +58,7 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
58 AFFS_I(inode)->i_extcnt = 1; 58 AFFS_I(inode)->i_extcnt = 1;
59 AFFS_I(inode)->i_ext_last = ~1; 59 AFFS_I(inode)->i_ext_last = ~1;
60 AFFS_I(inode)->i_protect = prot; 60 AFFS_I(inode)->i_protect = prot;
61 AFFS_I(inode)->i_opencnt = 0; 61 atomic_set(&AFFS_I(inode)->i_opencnt, 0);
62 AFFS_I(inode)->i_blkcnt = 0; 62 AFFS_I(inode)->i_blkcnt = 0;
63 AFFS_I(inode)->i_lc = NULL; 63 AFFS_I(inode)->i_lc = NULL;
64 AFFS_I(inode)->i_lc_size = 0; 64 AFFS_I(inode)->i_lc_size = 0;
@@ -108,8 +108,6 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino)
108 inode->i_mode |= S_IFDIR; 108 inode->i_mode |= S_IFDIR;
109 } else 109 } else
110 inode->i_mode = S_IRUGO | S_IXUGO | S_IWUSR | S_IFDIR; 110 inode->i_mode = S_IRUGO | S_IXUGO | S_IWUSR | S_IFDIR;
111 if (tail->link_chain)
112 inode->i_nlink = 2;
113 /* Maybe it should be controlled by mount parameter? */ 111 /* Maybe it should be controlled by mount parameter? */
114 //inode->i_mode |= S_ISVTX; 112 //inode->i_mode |= S_ISVTX;
115 inode->i_op = &affs_dir_inode_operations; 113 inode->i_op = &affs_dir_inode_operations;
@@ -245,31 +243,12 @@ out:
245} 243}
246 244
247void 245void
248affs_put_inode(struct inode *inode)
249{
250 pr_debug("AFFS: put_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
251 affs_free_prealloc(inode);
252}
253
254void
255affs_drop_inode(struct inode *inode)
256{
257 mutex_lock(&inode->i_mutex);
258 if (inode->i_size != AFFS_I(inode)->mmu_private)
259 affs_truncate(inode);
260 mutex_unlock(&inode->i_mutex);
261
262 generic_drop_inode(inode);
263}
264
265void
266affs_delete_inode(struct inode *inode) 246affs_delete_inode(struct inode *inode)
267{ 247{
268 pr_debug("AFFS: delete_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); 248 pr_debug("AFFS: delete_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
269 truncate_inode_pages(&inode->i_data, 0); 249 truncate_inode_pages(&inode->i_data, 0);
270 inode->i_size = 0; 250 inode->i_size = 0;
271 if (S_ISREG(inode->i_mode)) 251 affs_truncate(inode);
272 affs_truncate(inode);
273 clear_inode(inode); 252 clear_inode(inode);
274 affs_free_block(inode->i_sb, inode->i_ino); 253 affs_free_block(inode->i_sb, inode->i_ino);
275} 254}
@@ -277,9 +256,12 @@ affs_delete_inode(struct inode *inode)
277void 256void
278affs_clear_inode(struct inode *inode) 257affs_clear_inode(struct inode *inode)
279{ 258{
280 unsigned long cache_page = (unsigned long) AFFS_I(inode)->i_lc; 259 unsigned long cache_page;
281 260
282 pr_debug("AFFS: clear_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink); 261 pr_debug("AFFS: clear_inode(ino=%lu, nlink=%u)\n", inode->i_ino, inode->i_nlink);
262
263 affs_free_prealloc(inode);
264 cache_page = (unsigned long)AFFS_I(inode)->i_lc;
283 if (cache_page) { 265 if (cache_page) {
284 pr_debug("AFFS: freeing ext cache\n"); 266 pr_debug("AFFS: freeing ext cache\n");
285 AFFS_I(inode)->i_lc = NULL; 267 AFFS_I(inode)->i_lc = NULL;
@@ -316,7 +298,7 @@ affs_new_inode(struct inode *dir)
316 inode->i_ino = block; 298 inode->i_ino = block;
317 inode->i_nlink = 1; 299 inode->i_nlink = 1;
318 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 300 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
319 AFFS_I(inode)->i_opencnt = 0; 301 atomic_set(&AFFS_I(inode)->i_opencnt, 0);
320 AFFS_I(inode)->i_blkcnt = 0; 302 AFFS_I(inode)->i_blkcnt = 0;
321 AFFS_I(inode)->i_lc = NULL; 303 AFFS_I(inode)->i_lc = NULL;
322 AFFS_I(inode)->i_lc_size = 0; 304 AFFS_I(inode)->i_lc_size = 0;
@@ -369,12 +351,12 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
369 switch (type) { 351 switch (type) {
370 case ST_LINKFILE: 352 case ST_LINKFILE:
371 case ST_LINKDIR: 353 case ST_LINKDIR:
372 inode_bh = bh;
373 retval = -ENOSPC; 354 retval = -ENOSPC;
374 block = affs_alloc_block(dir, dir->i_ino); 355 block = affs_alloc_block(dir, dir->i_ino);
375 if (!block) 356 if (!block)
376 goto err; 357 goto err;
377 retval = -EIO; 358 retval = -EIO;
359 inode_bh = bh;
378 bh = affs_getzeroblk(sb, block); 360 bh = affs_getzeroblk(sb, block);
379 if (!bh) 361 if (!bh)
380 goto err; 362 goto err;
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 2218f1ee71ce..cfcf1b6cf82b 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -234,7 +234,8 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
234int 234int
235affs_unlink(struct inode *dir, struct dentry *dentry) 235affs_unlink(struct inode *dir, struct dentry *dentry)
236{ 236{
237 pr_debug("AFFS: unlink(dir=%d, \"%.*s\")\n", (u32)dir->i_ino, 237 pr_debug("AFFS: unlink(dir=%d, %lu \"%.*s\")\n", (u32)dir->i_ino,
238 dentry->d_inode->i_ino,
238 (int)dentry->d_name.len, dentry->d_name.name); 239 (int)dentry->d_name.len, dentry->d_name.name);
239 240
240 return affs_remove_header(dentry); 241 return affs_remove_header(dentry);
@@ -302,7 +303,8 @@ affs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
302int 303int
303affs_rmdir(struct inode *dir, struct dentry *dentry) 304affs_rmdir(struct inode *dir, struct dentry *dentry)
304{ 305{
305 pr_debug("AFFS: rmdir(dir=%u, \"%.*s\")\n", (u32)dir->i_ino, 306 pr_debug("AFFS: rmdir(dir=%u, %lu \"%.*s\")\n", (u32)dir->i_ino,
307 dentry->d_inode->i_ino,
306 (int)dentry->d_name.len, dentry->d_name.name); 308 (int)dentry->d_name.len, dentry->d_name.name);
307 309
308 return affs_remove_header(dentry); 310 return affs_remove_header(dentry);
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 01d25d532541..d214837d5e42 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -71,12 +71,18 @@ static struct kmem_cache * affs_inode_cachep;
71 71
72static struct inode *affs_alloc_inode(struct super_block *sb) 72static struct inode *affs_alloc_inode(struct super_block *sb)
73{ 73{
74 struct affs_inode_info *ei; 74 struct affs_inode_info *i;
75 ei = (struct affs_inode_info *)kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL); 75
76 if (!ei) 76 i = kmem_cache_alloc(affs_inode_cachep, GFP_KERNEL);
77 if (!i)
77 return NULL; 78 return NULL;
78 ei->vfs_inode.i_version = 1; 79
79 return &ei->vfs_inode; 80 i->vfs_inode.i_version = 1;
81 i->i_lc = NULL;
82 i->i_ext_bh = NULL;
83 i->i_pa_cnt = 0;
84
85 return &i->vfs_inode;
80} 86}
81 87
82static void affs_destroy_inode(struct inode *inode) 88static void affs_destroy_inode(struct inode *inode)
@@ -114,8 +120,6 @@ static const struct super_operations affs_sops = {
114 .alloc_inode = affs_alloc_inode, 120 .alloc_inode = affs_alloc_inode,
115 .destroy_inode = affs_destroy_inode, 121 .destroy_inode = affs_destroy_inode,
116 .write_inode = affs_write_inode, 122 .write_inode = affs_write_inode,
117 .put_inode = affs_put_inode,
118 .drop_inode = affs_drop_inode,
119 .delete_inode = affs_delete_inode, 123 .delete_inode = affs_delete_inode,
120 .clear_inode = affs_clear_inode, 124 .clear_inode = affs_clear_inode,
121 .put_super = affs_put_super, 125 .put_super = affs_put_super,
diff --git a/fs/bio.c b/fs/bio.c
index 799f86deff24..78562574cb52 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -158,7 +158,7 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, int nr_iovecs, struct bio_set *bs)
158 158
159 bio_init(bio); 159 bio_init(bio);
160 if (likely(nr_iovecs)) { 160 if (likely(nr_iovecs)) {
161 unsigned long idx = 0; /* shut up gcc */ 161 unsigned long uninitialized_var(idx);
162 162
163 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs); 163 bvl = bvec_alloc_bs(gfp_mask, nr_iovecs, &idx, bs);
164 if (unlikely(!bvl)) { 164 if (unlikely(!bvl)) {
@@ -963,6 +963,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
963 * @data: pointer to buffer to copy 963 * @data: pointer to buffer to copy
964 * @len: length in bytes 964 * @len: length in bytes
965 * @gfp_mask: allocation flags for bio and page allocation 965 * @gfp_mask: allocation flags for bio and page allocation
966 * @reading: data direction is READ
966 * 967 *
967 * copy the kernel address into a bio suitable for io to a block 968 * copy the kernel address into a bio suitable for io to a block
968 * device. Returns an error pointer in case of error. 969 * device. Returns an error pointer in case of error.
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 05c9da6181c3..8355e918fddf 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,6 @@
1Version 1.53
2------------
3
1Version 1.52 4Version 1.52
2------------ 5------------
3Fix oops on second mount to server when null auth is used. 6Fix oops on second mount to server when null auth is used.
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c
index bcda2c6b6a04..cb52cbbe45ff 100644
--- a/fs/cifs/asn1.c
+++ b/fs/cifs/asn1.c
@@ -460,8 +460,8 @@ decode_negTokenInit(unsigned char *security_blob, int length,
460 unsigned char *sequence_end; 460 unsigned char *sequence_end;
461 unsigned long *oid = NULL; 461 unsigned long *oid = NULL;
462 unsigned int cls, con, tag, oidlen, rc; 462 unsigned int cls, con, tag, oidlen, rc;
463 int use_ntlmssp = FALSE; 463 bool use_ntlmssp = false;
464 int use_kerberos = FALSE; 464 bool use_kerberos = false;
465 465
466 *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/ 466 *secType = NTLM; /* BB eventually make Kerberos or NLTMSSP the default*/
467 467
@@ -561,15 +561,15 @@ decode_negTokenInit(unsigned char *security_blob, int length,
561 if (compare_oid(oid, oidlen, 561 if (compare_oid(oid, oidlen,
562 MSKRB5_OID, 562 MSKRB5_OID,
563 MSKRB5_OID_LEN)) 563 MSKRB5_OID_LEN))
564 use_kerberos = TRUE; 564 use_kerberos = true;
565 else if (compare_oid(oid, oidlen, 565 else if (compare_oid(oid, oidlen,
566 KRB5_OID, 566 KRB5_OID,
567 KRB5_OID_LEN)) 567 KRB5_OID_LEN))
568 use_kerberos = TRUE; 568 use_kerberos = true;
569 else if (compare_oid(oid, oidlen, 569 else if (compare_oid(oid, oidlen,
570 NTLMSSP_OID, 570 NTLMSSP_OID,
571 NTLMSSP_OID_LEN)) 571 NTLMSSP_OID_LEN))
572 use_ntlmssp = TRUE; 572 use_ntlmssp = true;
573 573
574 kfree(oid); 574 kfree(oid);
575 } 575 }
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 95024c066d89..f6fdecf6598c 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -93,15 +93,11 @@ static char *cifs_get_share_name(const char *node_name)
93 /* find sharename end */ 93 /* find sharename end */
94 pSep++; 94 pSep++;
95 pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC)); 95 pSep = memchr(UNC+(pSep-UNC), '\\', len-(pSep-UNC));
96 if (!pSep) { 96 if (pSep) {
97 cERROR(1, ("%s:2 cant find share name in node name: %s", 97 /* trim path up to sharename end
98 __func__, node_name)); 98 * now we have share name in UNC */
99 kfree(UNC); 99 *pSep = 0;
100 return NULL;
101 } 100 }
102 /* trim path up to sharename end
103 * * now we have share name in UNC */
104 *pSep = 0;
105 101
106 return UNC; 102 return UNC;
107} 103}
@@ -188,7 +184,7 @@ static char *compose_mount_options(const char *sb_mountdata,
188 tkn_e = strchr(tkn_e+1, '\\'); 184 tkn_e = strchr(tkn_e+1, '\\');
189 if (tkn_e) { 185 if (tkn_e) {
190 strcat(mountdata, ",prefixpath="); 186 strcat(mountdata, ",prefixpath=");
191 strcat(mountdata, tkn_e); 187 strcat(mountdata, tkn_e+1);
192 } 188 }
193 } 189 }
194 190
@@ -244,7 +240,8 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry)
244 return NULL; 240 return NULL;
245 241
246 if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) { 242 if (cifs_sb->tcon->Flags & SMB_SHARE_IS_IN_DFS) {
247 /* we should use full path name to correct working with DFS */ 243 int i;
244 /* we should use full path name for correct working with DFS */
248 l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) + 245 l_max_len = strnlen(cifs_sb->tcon->treeName, MAX_TREE_SIZE+1) +
249 strnlen(search_path, MAX_PATHCONF) + 1; 246 strnlen(search_path, MAX_PATHCONF) + 1;
250 tmp_path = kmalloc(l_max_len, GFP_KERNEL); 247 tmp_path = kmalloc(l_max_len, GFP_KERNEL);
@@ -253,8 +250,14 @@ static char *build_full_dfs_path_from_dentry(struct dentry *dentry)
253 return NULL; 250 return NULL;
254 } 251 }
255 strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len); 252 strncpy(tmp_path, cifs_sb->tcon->treeName, l_max_len);
256 strcat(tmp_path, search_path);
257 tmp_path[l_max_len-1] = 0; 253 tmp_path[l_max_len-1] = 0;
254 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
255 for (i = 0; i < l_max_len; i++) {
256 if (tmp_path[i] == '\\')
257 tmp_path[i] = '/';
258 }
259 strncat(tmp_path, search_path, l_max_len - strlen(tmp_path));
260
258 full_path = tmp_path; 261 full_path = tmp_path;
259 kfree(search_path); 262 kfree(search_path);
260 } else { 263 } else {
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index e99d4faf5f02..34902cff5400 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -559,7 +559,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
559 const char *path, const __u16 *pfid) 559 const char *path, const __u16 *pfid)
560{ 560{
561 struct cifsFileInfo *open_file = NULL; 561 struct cifsFileInfo *open_file = NULL;
562 int unlock_file = FALSE; 562 bool unlock_file = false;
563 int xid; 563 int xid;
564 int rc = -EIO; 564 int rc = -EIO;
565 __u16 fid; 565 __u16 fid;
@@ -586,10 +586,10 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
586 cifs_sb = CIFS_SB(sb); 586 cifs_sb = CIFS_SB(sb);
587 587
588 if (open_file) { 588 if (open_file) {
589 unlock_file = TRUE; 589 unlock_file = true;
590 fid = open_file->netfid; 590 fid = open_file->netfid;
591 } else if (pfid == NULL) { 591 } else if (pfid == NULL) {
592 int oplock = FALSE; 592 int oplock = 0;
593 /* open file */ 593 /* open file */
594 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, 594 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
595 READ_CONTROL, 0, &fid, &oplock, NULL, 595 READ_CONTROL, 0, &fid, &oplock, NULL,
@@ -604,7 +604,7 @@ static struct cifs_ntsd *get_cifs_acl(u32 *pacllen, struct inode *inode,
604 604
605 rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen); 605 rc = CIFSSMBGetCIFSACL(xid, cifs_sb->tcon, fid, &pntsd, pacllen);
606 cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen)); 606 cFYI(1, ("GetCIFSACL rc = %d ACL len %d", rc, *pacllen));
607 if (unlock_file == TRUE) /* find_readable_file increments ref count */ 607 if (unlock_file == true) /* find_readable_file increments ref count */
608 atomic_dec(&open_file->wrtPending); 608 atomic_dec(&open_file->wrtPending);
609 else if (pfid == NULL) /* if opened above we have to close the handle */ 609 else if (pfid == NULL) /* if opened above we have to close the handle */
610 CIFSSMBClose(xid, cifs_sb->tcon, fid); 610 CIFSSMBClose(xid, cifs_sb->tcon, fid);
@@ -619,7 +619,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
619 struct inode *inode, const char *path) 619 struct inode *inode, const char *path)
620{ 620{
621 struct cifsFileInfo *open_file; 621 struct cifsFileInfo *open_file;
622 int unlock_file = FALSE; 622 bool unlock_file = false;
623 int xid; 623 int xid;
624 int rc = -EIO; 624 int rc = -EIO;
625 __u16 fid; 625 __u16 fid;
@@ -640,10 +640,10 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
640 640
641 open_file = find_readable_file(CIFS_I(inode)); 641 open_file = find_readable_file(CIFS_I(inode));
642 if (open_file) { 642 if (open_file) {
643 unlock_file = TRUE; 643 unlock_file = true;
644 fid = open_file->netfid; 644 fid = open_file->netfid;
645 } else { 645 } else {
646 int oplock = FALSE; 646 int oplock = 0;
647 /* open file */ 647 /* open file */
648 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, 648 rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
649 WRITE_DAC, 0, &fid, &oplock, NULL, 649 WRITE_DAC, 0, &fid, &oplock, NULL,
@@ -658,7 +658,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
658 658
659 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen); 659 rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
660 cFYI(DBG2, ("SetCIFSACL rc = %d", rc)); 660 cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
661 if (unlock_file == TRUE) 661 if (unlock_file)
662 atomic_dec(&open_file->wrtPending); 662 atomic_dec(&open_file->wrtPending);
663 else 663 else
664 CIFSSMBClose(xid, cifs_sb->tcon, fid); 664 CIFSSMBClose(xid, cifs_sb->tcon, fid);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 39c2cbdface7..427a7c695896 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -222,50 +222,50 @@ static int
222cifs_statfs(struct dentry *dentry, struct kstatfs *buf) 222cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
223{ 223{
224 struct super_block *sb = dentry->d_sb; 224 struct super_block *sb = dentry->d_sb;
225 int xid; 225 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
226 struct cifsTconInfo *tcon = cifs_sb->tcon;
226 int rc = -EOPNOTSUPP; 227 int rc = -EOPNOTSUPP;
227 struct cifs_sb_info *cifs_sb; 228 int xid;
228 struct cifsTconInfo *pTcon;
229 229
230 xid = GetXid(); 230 xid = GetXid();
231 231
232 cifs_sb = CIFS_SB(sb);
233 pTcon = cifs_sb->tcon;
234
235 buf->f_type = CIFS_MAGIC_NUMBER; 232 buf->f_type = CIFS_MAGIC_NUMBER;
236 233
237 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */ 234 /*
238 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would 235 * PATH_MAX may be too long - it would presumably be total path,
239 presumably be total path, but note 236 * but note that some servers (includinng Samba 3) have a shorter
240 that some servers (includinng Samba 3) 237 * maximum path.
241 have a shorter maximum path */ 238 *
239 * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO.
240 */
241 buf->f_namelen = PATH_MAX;
242 buf->f_files = 0; /* undefined */ 242 buf->f_files = 0; /* undefined */
243 buf->f_ffree = 0; /* unlimited */ 243 buf->f_ffree = 0; /* unlimited */
244 244
245/* BB we could add a second check for a QFS Unix capability bit */ 245 /*
246/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */ 246 * We could add a second check for a QFS Unix capability bit
247 if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS & 247 */
248 le64_to_cpu(pTcon->fsUnixInfo.Capability))) 248 if ((tcon->ses->capabilities & CAP_UNIX) &&
249 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf); 249 (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
250 250 rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
251 /* Only need to call the old QFSInfo if failed 251
252 on newer one */ 252 /*
253 if (rc) 253 * Only need to call the old QFSInfo if failed on newer one,
254 if (pTcon->ses->capabilities & CAP_NT_SMBS) 254 * e.g. by OS/2.
255 rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ 255 **/
256 256 if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
257 /* Some old Windows servers also do not support level 103, retry with 257 rc = CIFSSMBQFSInfo(xid, tcon, buf);
258 older level one if old server failed the previous call or we 258
259 bypassed it because we detected that this was an older LANMAN sess */ 259 /*
260 * Some old Windows servers also do not support level 103, retry with
261 * older level one if old server failed the previous call or we
262 * bypassed it because we detected that this was an older LANMAN sess
263 */
260 if (rc) 264 if (rc)
261 rc = SMBOldQFSInfo(xid, pTcon, buf); 265 rc = SMBOldQFSInfo(xid, tcon, buf);
262 /* int f_type; 266
263 __fsid_t f_fsid;
264 int f_namelen; */
265 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
266 FreeXid(xid); 267 FreeXid(xid);
267 return 0; /* always return success? what if volume is no 268 return 0;
268 longer available? */
269} 269}
270 270
271static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd) 271static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd)
@@ -306,8 +306,8 @@ cifs_alloc_inode(struct super_block *sb)
306 /* Until the file is open and we have gotten oplock 306 /* Until the file is open and we have gotten oplock
307 info back from the server, can not assume caching of 307 info back from the server, can not assume caching of
308 file data or metadata */ 308 file data or metadata */
309 cifs_inode->clientCanCacheRead = FALSE; 309 cifs_inode->clientCanCacheRead = false;
310 cifs_inode->clientCanCacheAll = FALSE; 310 cifs_inode->clientCanCacheAll = false;
311 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 311 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
312 312
313 /* Can not set i_flags here - they get immediately overwritten 313 /* Can not set i_flags here - they get immediately overwritten
@@ -940,7 +940,7 @@ static int cifs_oplock_thread(void *dummyarg)
940 rc = CIFSSMBLock(0, pTcon, netfid, 940 rc = CIFSSMBLock(0, pTcon, netfid,
941 0 /* len */ , 0 /* offset */, 0, 941 0 /* len */ , 0 /* offset */, 0,
942 0, LOCKING_ANDX_OPLOCK_RELEASE, 942 0, LOCKING_ANDX_OPLOCK_RELEASE,
943 0 /* wait flag */); 943 false /* wait flag */);
944 cFYI(1, ("Oplock release rc = %d", rc)); 944 cFYI(1, ("Oplock release rc = %d", rc));
945 } 945 }
946 } else 946 } else
diff --git a/fs/cifs/cifsfs.h b/fs/cifs/cifsfs.h
index e1dd9f32e1d7..cd1301a09b3b 100644
--- a/fs/cifs/cifsfs.h
+++ b/fs/cifs/cifsfs.h
@@ -24,14 +24,6 @@
24 24
25#define ROOT_I 2 25#define ROOT_I 2
26 26
27#ifndef FALSE
28#define FALSE 0
29#endif
30
31#ifndef TRUE
32#define TRUE 1
33#endif
34
35extern struct file_system_type cifs_fs_type; 27extern struct file_system_type cifs_fs_type;
36extern const struct address_space_operations cifs_addr_ops; 28extern const struct address_space_operations cifs_addr_ops;
37extern const struct address_space_operations cifs_addr_ops_smallbuf; 29extern const struct address_space_operations cifs_addr_ops_smallbuf;
@@ -110,5 +102,5 @@ extern int cifs_ioctl(struct inode *inode, struct file *filep,
110extern const struct export_operations cifs_export_ops; 102extern const struct export_operations cifs_export_ops;
111#endif /* EXPERIMENTAL */ 103#endif /* EXPERIMENTAL */
112 104
113#define CIFS_VERSION "1.52" 105#define CIFS_VERSION "1.53"
114#endif /* _CIFSFS_H */ 106#endif /* _CIFSFS_H */
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 69a2e1942542..b7d9f698e63e 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -57,14 +57,6 @@
57 57
58#include "cifspdu.h" 58#include "cifspdu.h"
59 59
60#ifndef FALSE
61#define FALSE 0
62#endif
63
64#ifndef TRUE
65#define TRUE 1
66#endif
67
68#ifndef XATTR_DOS_ATTRIB 60#ifndef XATTR_DOS_ATTRIB
69#define XATTR_DOS_ATTRIB "user.DOSATTRIB" 61#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
70#endif 62#endif
@@ -147,7 +139,7 @@ struct TCP_Server_Info {
147 enum protocolEnum protocolType; 139 enum protocolEnum protocolType;
148 char versionMajor; 140 char versionMajor;
149 char versionMinor; 141 char versionMinor;
150 unsigned svlocal:1; /* local server or remote */ 142 bool svlocal:1; /* local server or remote */
151 atomic_t socketUseCount; /* number of open cifs sessions on socket */ 143 atomic_t socketUseCount; /* number of open cifs sessions on socket */
152 atomic_t inFlight; /* number of requests on the wire to server */ 144 atomic_t inFlight; /* number of requests on the wire to server */
153#ifdef CONFIG_CIFS_STATS2 145#ifdef CONFIG_CIFS_STATS2
@@ -286,10 +278,10 @@ struct cifsTconInfo {
286 FILE_SYSTEM_DEVICE_INFO fsDevInfo; 278 FILE_SYSTEM_DEVICE_INFO fsDevInfo;
287 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */ 279 FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
288 FILE_SYSTEM_UNIX_INFO fsUnixInfo; 280 FILE_SYSTEM_UNIX_INFO fsUnixInfo;
289 unsigned ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */ 281 bool ipc:1; /* set if connection to IPC$ eg for RPC/PIPES */
290 unsigned retry:1; 282 bool retry:1;
291 unsigned nocase:1; 283 bool nocase:1;
292 unsigned unix_ext:1; /* if off disable Linux extensions to CIFS protocol 284 bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
293 for this mount even if server would support */ 285 for this mount even if server would support */
294 /* BB add field for back pointer to sb struct(s)? */ 286 /* BB add field for back pointer to sb struct(s)? */
295}; 287};
@@ -317,10 +309,10 @@ struct cifs_search_info {
317 char *srch_entries_start; 309 char *srch_entries_start;
318 char *presume_name; 310 char *presume_name;
319 unsigned int resume_name_len; 311 unsigned int resume_name_len;
320 unsigned endOfSearch:1; 312 bool endOfSearch:1;
321 unsigned emptyDir:1; 313 bool emptyDir:1;
322 unsigned unicode:1; 314 bool unicode:1;
323 unsigned smallBuf:1; /* so we know which buf_release function to call */ 315 bool smallBuf:1; /* so we know which buf_release function to call */
324}; 316};
325 317
326struct cifsFileInfo { 318struct cifsFileInfo {
@@ -335,9 +327,9 @@ struct cifsFileInfo {
335 struct inode *pInode; /* needed for oplock break */ 327 struct inode *pInode; /* needed for oplock break */
336 struct mutex lock_mutex; 328 struct mutex lock_mutex;
337 struct list_head llist; /* list of byte range locks we have. */ 329 struct list_head llist; /* list of byte range locks we have. */
338 unsigned closePend:1; /* file is marked to close */ 330 bool closePend:1; /* file is marked to close */
339 unsigned invalidHandle:1; /* file closed via session abend */ 331 bool invalidHandle:1; /* file closed via session abend */
340 unsigned messageMode:1; /* for pipes: message vs byte mode */ 332 bool messageMode:1; /* for pipes: message vs byte mode */
341 atomic_t wrtPending; /* handle in use - defer close */ 333 atomic_t wrtPending; /* handle in use - defer close */
342 struct semaphore fh_sem; /* prevents reopen race after dead ses*/ 334 struct semaphore fh_sem; /* prevents reopen race after dead ses*/
343 char *search_resume_name; /* BB removeme BB */ 335 char *search_resume_name; /* BB removeme BB */
@@ -356,9 +348,9 @@ struct cifsInodeInfo {
356 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */ 348 __u32 cifsAttrs; /* e.g. DOS archive bit, sparse, compressed, system */
357 atomic_t inUse; /* num concurrent users (local openers cifs) of file*/ 349 atomic_t inUse; /* num concurrent users (local openers cifs) of file*/
358 unsigned long time; /* jiffies of last update/check of inode */ 350 unsigned long time; /* jiffies of last update/check of inode */
359 unsigned clientCanCacheRead:1; /* read oplock */ 351 bool clientCanCacheRead:1; /* read oplock */
360 unsigned clientCanCacheAll:1; /* read and writebehind oplock */ 352 bool clientCanCacheAll:1; /* read and writebehind oplock */
361 unsigned oplockPending:1; 353 bool oplockPending:1;
362 struct inode vfs_inode; 354 struct inode vfs_inode;
363}; 355};
364 356
@@ -426,9 +418,9 @@ struct mid_q_entry {
426 struct smb_hdr *resp_buf; /* response buffer */ 418 struct smb_hdr *resp_buf; /* response buffer */
427 int midState; /* wish this were enum but can not pass to wait_event */ 419 int midState; /* wish this were enum but can not pass to wait_event */
428 __u8 command; /* smb command code */ 420 __u8 command; /* smb command code */
429 unsigned largeBuf:1; /* if valid response, is pointer to large buf */ 421 bool largeBuf:1; /* if valid response, is pointer to large buf */
430 unsigned multiRsp:1; /* multiple trans2 responses for one request */ 422 bool multiRsp:1; /* multiple trans2 responses for one request */
431 unsigned multiEnd:1; /* both received */ 423 bool multiEnd:1; /* both received */
432}; 424};
433 425
434struct oplock_q_entry { 426struct oplock_q_entry {
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h
index 9f49c2f3582c..c43bf4b7a556 100644
--- a/fs/cifs/cifspdu.h
+++ b/fs/cifs/cifspdu.h
@@ -340,6 +340,7 @@
340#define OPEN_NO_RECALL 0x00400000 340#define OPEN_NO_RECALL 0x00400000
341#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */ 341#define OPEN_FREE_SPACE_QUERY 0x00800000 /* should be zero */
342#define CREATE_OPTIONS_MASK 0x007FFFFF 342#define CREATE_OPTIONS_MASK 0x007FFFFF
343#define CREATE_OPTION_READONLY 0x10000000
343#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */ 344#define CREATE_OPTION_SPECIAL 0x20000000 /* system. NB not sent over wire */
344 345
345/* ImpersonationLevel flags */ 346/* ImpersonationLevel flags */
@@ -2050,7 +2051,7 @@ typedef struct {
2050 to 0xFFFF00 */ 2051 to 0xFFFF00 */
2051#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080 2052#define CIFS_UNIX_LARGE_WRITE_CAP 0x00000080
2052#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */ 2053#define CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP 0x00000100 /* can do SPNEGO crypt */
2053#define CIFS_UNIX_TRANPSORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */ 2054#define CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP 0x00000200 /* must do */
2054#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and 2055#define CIFS_UNIX_PROXY_CAP 0x00000400 /* Proxy cap: 0xACE ioctl and
2055 QFS PROXY call */ 2056 QFS PROXY call */
2056#ifdef CONFIG_CIFS_POSIX 2057#ifdef CONFIG_CIFS_POSIX
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 50f9fdae19b3..d481f6c5a2be 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -59,8 +59,9 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
59 struct smb_hdr *out_buf, 59 struct smb_hdr *out_buf,
60 int *bytes_returned); 60 int *bytes_returned);
61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length); 61extern int checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length);
62extern int is_valid_oplock_break(struct smb_hdr *smb, struct TCP_Server_Info *); 62extern bool is_valid_oplock_break(struct smb_hdr *smb,
63extern int is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); 63 struct TCP_Server_Info *);
64extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
64extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *); 65extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *);
65#ifdef CONFIG_CIFS_EXPERIMENTAL 66#ifdef CONFIG_CIFS_EXPERIMENTAL
66extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *); 67extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *);
@@ -69,7 +70,7 @@ extern unsigned int smbCalcSize(struct smb_hdr *ptr);
69extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr); 70extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr);
70extern int decode_negTokenInit(unsigned char *security_blob, int length, 71extern int decode_negTokenInit(unsigned char *security_blob, int length,
71 enum securityEnum *secType); 72 enum securityEnum *secType);
72extern int cifs_inet_pton(int, char *source, void *dst); 73extern int cifs_inet_pton(const int, const char *source, void *dst);
73extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr); 74extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr);
74extern void header_assemble(struct smb_hdr *, char /* command */ , 75extern void header_assemble(struct smb_hdr *, char /* command */ ,
75 const struct cifsTconInfo *, int /* length of 76 const struct cifsTconInfo *, int /* length of
@@ -187,12 +188,12 @@ extern int CIFSSMBSetAttrLegacy(int xid, struct cifsTconInfo *tcon,
187#endif /* possibly unneeded function */ 188#endif /* possibly unneeded function */
188extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, 189extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
189 const char *fileName, __u64 size, 190 const char *fileName, __u64 size,
190 int setAllocationSizeFlag, 191 bool setAllocationSizeFlag,
191 const struct nls_table *nls_codepage, 192 const struct nls_table *nls_codepage,
192 int remap_special_chars); 193 int remap_special_chars);
193extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, 194extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
194 __u64 size, __u16 fileHandle, __u32 opener_pid, 195 __u64 size, __u16 fileHandle, __u32 opener_pid,
195 int AllocSizeFlag); 196 bool AllocSizeFlag);
196extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon, 197extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
197 char *full_path, __u64 mode, __u64 uid, 198 char *full_path, __u64 mode, __u64 uid,
198 __u64 gid, dev_t dev, 199 __u64 gid, dev_t dev,
@@ -291,11 +292,11 @@ extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
291 const __u16 netfid, const __u64 len, 292 const __u16 netfid, const __u64 len,
292 const __u64 offset, const __u32 numUnlock, 293 const __u64 offset, const __u32 numUnlock,
293 const __u32 numLock, const __u8 lockType, 294 const __u32 numLock, const __u8 lockType,
294 const int waitFlag); 295 const bool waitFlag);
295extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 296extern int CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
296 const __u16 smb_file_id, const int get_flag, 297 const __u16 smb_file_id, const int get_flag,
297 const __u64 len, struct file_lock *, 298 const __u64 len, struct file_lock *,
298 const __u16 lock_type, const int waitFlag); 299 const __u16 lock_type, const bool waitFlag);
299extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon); 300extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
300extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses); 301extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses);
301 302
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index 4728fa982a4e..95fbba4ea7d4 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -95,7 +95,7 @@ static void mark_open_files_invalid(struct cifsTconInfo *pTcon)
95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) { 95 list_for_each_safe(tmp, tmp1, &pTcon->openFileList) {
96 open_file = list_entry(tmp, struct cifsFileInfo, tlist); 96 open_file = list_entry(tmp, struct cifsFileInfo, tlist);
97 if (open_file) 97 if (open_file)
98 open_file->invalidHandle = TRUE; 98 open_file->invalidHandle = true;
99 } 99 }
100 write_unlock(&GlobalSMBSeslock); 100 write_unlock(&GlobalSMBSeslock);
101 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted 101 /* BB Add call to invalidate_inodes(sb) for all superblocks mounted
@@ -141,7 +141,7 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
141 if (tcon->ses->server->tcpStatus == 141 if (tcon->ses->server->tcpStatus ==
142 CifsNeedReconnect) { 142 CifsNeedReconnect) {
143 /* on "soft" mounts we wait once */ 143 /* on "soft" mounts we wait once */
144 if ((tcon->retry == FALSE) || 144 if (!tcon->retry ||
145 (tcon->ses->status == CifsExiting)) { 145 (tcon->ses->status == CifsExiting)) {
146 cFYI(1, ("gave up waiting on " 146 cFYI(1, ("gave up waiting on "
147 "reconnect in smb_init")); 147 "reconnect in smb_init"));
@@ -289,7 +289,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
289 if (tcon->ses->server->tcpStatus == 289 if (tcon->ses->server->tcpStatus ==
290 CifsNeedReconnect) { 290 CifsNeedReconnect) {
291 /* on "soft" mounts we wait once */ 291 /* on "soft" mounts we wait once */
292 if ((tcon->retry == FALSE) || 292 if (!tcon->retry ||
293 (tcon->ses->status == CifsExiting)) { 293 (tcon->ses->status == CifsExiting)) {
294 cFYI(1, ("gave up waiting on " 294 cFYI(1, ("gave up waiting on "
295 "reconnect in smb_init")); 295 "reconnect in smb_init"));
@@ -1224,11 +1224,8 @@ OldOpenRetry:
1224 else /* BB FIXME BB */ 1224 else /* BB FIXME BB */
1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/); 1225 pSMB->FileAttributes = cpu_to_le16(0/*ATTR_NORMAL*/);
1226 1226
1227 /* if ((omode & S_IWUGO) == 0) 1227 if (create_options & CREATE_OPTION_READONLY)
1228 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1228 pSMB->FileAttributes |= cpu_to_le16(ATTR_READONLY);
1229 /* Above line causes problems due to vfs splitting create into two
1230 pieces - need to set mode after file created not while it is
1231 being created */
1232 1229
1233 /* BB FIXME BB */ 1230 /* BB FIXME BB */
1234/* pSMB->CreateOptions = cpu_to_le32(create_options & 1231/* pSMB->CreateOptions = cpu_to_le32(create_options &
@@ -1331,17 +1328,16 @@ openRetry:
1331 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM); 1328 pSMB->FileAttributes = cpu_to_le32(ATTR_SYSTEM);
1332 else 1329 else
1333 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL); 1330 pSMB->FileAttributes = cpu_to_le32(ATTR_NORMAL);
1331
1334 /* XP does not handle ATTR_POSIX_SEMANTICS */ 1332 /* XP does not handle ATTR_POSIX_SEMANTICS */
1335 /* but it helps speed up case sensitive checks for other 1333 /* but it helps speed up case sensitive checks for other
1336 servers such as Samba */ 1334 servers such as Samba */
1337 if (tcon->ses->capabilities & CAP_UNIX) 1335 if (tcon->ses->capabilities & CAP_UNIX)
1338 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS); 1336 pSMB->FileAttributes |= cpu_to_le32(ATTR_POSIX_SEMANTICS);
1339 1337
1340 /* if ((omode & S_IWUGO) == 0) 1338 if (create_options & CREATE_OPTION_READONLY)
1341 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);*/ 1339 pSMB->FileAttributes |= cpu_to_le32(ATTR_READONLY);
1342 /* Above line causes problems due to vfs splitting create into two 1340
1343 pieces - need to set mode after file created not while it is
1344 being created */
1345 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL); 1341 pSMB->ShareAccess = cpu_to_le32(FILE_SHARE_ALL);
1346 pSMB->CreateDisposition = cpu_to_le32(openDisposition); 1342 pSMB->CreateDisposition = cpu_to_le32(openDisposition);
1347 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK); 1343 pSMB->CreateOptions = cpu_to_le32(create_options & CREATE_OPTIONS_MASK);
@@ -1686,7 +1682,7 @@ int
1686CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, 1682CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1687 const __u16 smb_file_id, const __u64 len, 1683 const __u16 smb_file_id, const __u64 len,
1688 const __u64 offset, const __u32 numUnlock, 1684 const __u64 offset, const __u32 numUnlock,
1689 const __u32 numLock, const __u8 lockType, const int waitFlag) 1685 const __u32 numLock, const __u8 lockType, const bool waitFlag)
1690{ 1686{
1691 int rc = 0; 1687 int rc = 0;
1692 LOCK_REQ *pSMB = NULL; 1688 LOCK_REQ *pSMB = NULL;
@@ -1695,7 +1691,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1695 int timeout = 0; 1691 int timeout = 0;
1696 __u16 count; 1692 __u16 count;
1697 1693
1698 cFYI(1, ("CIFSSMBLock timeout %d numLock %d", waitFlag, numLock)); 1694 cFYI(1, ("CIFSSMBLock timeout %d numLock %d", (int)waitFlag, numLock));
1699 rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB); 1695 rc = small_smb_init(SMB_COM_LOCKING_ANDX, 8, tcon, (void **) &pSMB);
1700 1696
1701 if (rc) 1697 if (rc)
@@ -1706,7 +1702,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
1706 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) { 1702 if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
1707 timeout = CIFS_ASYNC_OP; /* no response expected */ 1703 timeout = CIFS_ASYNC_OP; /* no response expected */
1708 pSMB->Timeout = 0; 1704 pSMB->Timeout = 0;
1709 } else if (waitFlag == TRUE) { 1705 } else if (waitFlag) {
1710 timeout = CIFS_BLOCKING_OP; /* blocking operation, no timeout */ 1706 timeout = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
1711 pSMB->Timeout = cpu_to_le32(-1);/* blocking - do not time out */ 1707 pSMB->Timeout = cpu_to_le32(-1);/* blocking - do not time out */
1712 } else { 1708 } else {
@@ -1756,7 +1752,7 @@ int
1756CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, 1752CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
1757 const __u16 smb_file_id, const int get_flag, const __u64 len, 1753 const __u16 smb_file_id, const int get_flag, const __u64 len,
1758 struct file_lock *pLockData, const __u16 lock_type, 1754 struct file_lock *pLockData, const __u16 lock_type,
1759 const int waitFlag) 1755 const bool waitFlag)
1760{ 1756{
1761 struct smb_com_transaction2_sfi_req *pSMB = NULL; 1757 struct smb_com_transaction2_sfi_req *pSMB = NULL;
1762 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL; 1758 struct smb_com_transaction2_sfi_rsp *pSMBr = NULL;
@@ -3581,9 +3577,9 @@ findFirstRetry:
3581 rc = validate_t2((struct smb_t2_rsp *)pSMBr); 3577 rc = validate_t2((struct smb_t2_rsp *)pSMBr);
3582 if (rc == 0) { 3578 if (rc == 0) {
3583 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3579 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3584 psrch_inf->unicode = TRUE; 3580 psrch_inf->unicode = true;
3585 else 3581 else
3586 psrch_inf->unicode = FALSE; 3582 psrch_inf->unicode = false;
3587 3583
3588 psrch_inf->ntwrk_buf_start = (char *)pSMBr; 3584 psrch_inf->ntwrk_buf_start = (char *)pSMBr;
3589 psrch_inf->smallBuf = 0; 3585 psrch_inf->smallBuf = 0;
@@ -3594,9 +3590,9 @@ findFirstRetry:
3594 le16_to_cpu(pSMBr->t2.ParameterOffset)); 3590 le16_to_cpu(pSMBr->t2.ParameterOffset));
3595 3591
3596 if (parms->EndofSearch) 3592 if (parms->EndofSearch)
3597 psrch_inf->endOfSearch = TRUE; 3593 psrch_inf->endOfSearch = true;
3598 else 3594 else
3599 psrch_inf->endOfSearch = FALSE; 3595 psrch_inf->endOfSearch = false;
3600 3596
3601 psrch_inf->entries_in_buffer = 3597 psrch_inf->entries_in_buffer =
3602 le16_to_cpu(parms->SearchCount); 3598 le16_to_cpu(parms->SearchCount);
@@ -3624,7 +3620,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3624 3620
3625 cFYI(1, ("In FindNext")); 3621 cFYI(1, ("In FindNext"));
3626 3622
3627 if (psrch_inf->endOfSearch == TRUE) 3623 if (psrch_inf->endOfSearch)
3628 return -ENOENT; 3624 return -ENOENT;
3629 3625
3630 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, 3626 rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB,
@@ -3682,7 +3678,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3682 cifs_stats_inc(&tcon->num_fnext); 3678 cifs_stats_inc(&tcon->num_fnext);
3683 if (rc) { 3679 if (rc) {
3684 if (rc == -EBADF) { 3680 if (rc == -EBADF) {
3685 psrch_inf->endOfSearch = TRUE; 3681 psrch_inf->endOfSearch = true;
3686 rc = 0; /* search probably was closed at end of search*/ 3682 rc = 0; /* search probably was closed at end of search*/
3687 } else 3683 } else
3688 cFYI(1, ("FindNext returned = %d", rc)); 3684 cFYI(1, ("FindNext returned = %d", rc));
@@ -3692,9 +3688,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3692 if (rc == 0) { 3688 if (rc == 0) {
3693 /* BB fixme add lock for file (srch_info) struct here */ 3689 /* BB fixme add lock for file (srch_info) struct here */
3694 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) 3690 if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE)
3695 psrch_inf->unicode = TRUE; 3691 psrch_inf->unicode = true;
3696 else 3692 else
3697 psrch_inf->unicode = FALSE; 3693 psrch_inf->unicode = false;
3698 response_data = (char *) &pSMBr->hdr.Protocol + 3694 response_data = (char *) &pSMBr->hdr.Protocol +
3699 le16_to_cpu(pSMBr->t2.ParameterOffset); 3695 le16_to_cpu(pSMBr->t2.ParameterOffset);
3700 parms = (T2_FNEXT_RSP_PARMS *)response_data; 3696 parms = (T2_FNEXT_RSP_PARMS *)response_data;
@@ -3709,9 +3705,9 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
3709 psrch_inf->ntwrk_buf_start = (char *)pSMB; 3705 psrch_inf->ntwrk_buf_start = (char *)pSMB;
3710 psrch_inf->smallBuf = 0; 3706 psrch_inf->smallBuf = 0;
3711 if (parms->EndofSearch) 3707 if (parms->EndofSearch)
3712 psrch_inf->endOfSearch = TRUE; 3708 psrch_inf->endOfSearch = true;
3713 else 3709 else
3714 psrch_inf->endOfSearch = FALSE; 3710 psrch_inf->endOfSearch = false;
3715 psrch_inf->entries_in_buffer = 3711 psrch_inf->entries_in_buffer =
3716 le16_to_cpu(parms->SearchCount); 3712 le16_to_cpu(parms->SearchCount);
3717 psrch_inf->index_of_last_entry += 3713 psrch_inf->index_of_last_entry +=
@@ -4586,7 +4582,7 @@ QFSPosixRetry:
4586 4582
4587int 4583int
4588CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName, 4584CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon, const char *fileName,
4589 __u64 size, int SetAllocation, 4585 __u64 size, bool SetAllocation,
4590 const struct nls_table *nls_codepage, int remap) 4586 const struct nls_table *nls_codepage, int remap)
4591{ 4587{
4592 struct smb_com_transaction2_spi_req *pSMB = NULL; 4588 struct smb_com_transaction2_spi_req *pSMB = NULL;
@@ -4675,7 +4671,7 @@ SetEOFRetry:
4675 4671
4676int 4672int
4677CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, 4673CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size,
4678 __u16 fid, __u32 pid_of_opener, int SetAllocation) 4674 __u16 fid, __u32 pid_of_opener, bool SetAllocation)
4679{ 4675{
4680 struct smb_com_transaction2_sfi_req *pSMB = NULL; 4676 struct smb_com_transaction2_sfi_req *pSMB = NULL;
4681 char *data_offset; 4677 char *data_offset;
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index e17106730168..f428bf3bf1a9 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -49,8 +49,6 @@
49#define CIFS_PORT 445 49#define CIFS_PORT 445
50#define RFC1001_PORT 139 50#define RFC1001_PORT 139
51 51
52static DECLARE_COMPLETION(cifsd_complete);
53
54extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8, 52extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
55 unsigned char *p24); 53 unsigned char *p24);
56 54
@@ -71,23 +69,23 @@ struct smb_vol {
71 mode_t file_mode; 69 mode_t file_mode;
72 mode_t dir_mode; 70 mode_t dir_mode;
73 unsigned secFlg; 71 unsigned secFlg;
74 unsigned rw:1; 72 bool rw:1;
75 unsigned retry:1; 73 bool retry:1;
76 unsigned intr:1; 74 bool intr:1;
77 unsigned setuids:1; 75 bool setuids:1;
78 unsigned override_uid:1; 76 bool override_uid:1;
79 unsigned override_gid:1; 77 bool override_gid:1;
80 unsigned noperm:1; 78 bool noperm:1;
81 unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ 79 bool no_psx_acl:1; /* set if posix acl support should be disabled */
82 unsigned cifs_acl:1; 80 bool cifs_acl:1;
83 unsigned no_xattr:1; /* set if xattr (EA) support should be disabled*/ 81 bool no_xattr:1; /* set if xattr (EA) support should be disabled*/
84 unsigned server_ino:1; /* use inode numbers from server ie UniqueId */ 82 bool server_ino:1; /* use inode numbers from server ie UniqueId */
85 unsigned direct_io:1; 83 bool direct_io:1;
86 unsigned remap:1; /* set to remap seven reserved chars in filenames */ 84 bool remap:1; /* set to remap seven reserved chars in filenames */
87 unsigned posix_paths:1; /* unset to not ask for posix pathnames. */ 85 bool posix_paths:1; /* unset to not ask for posix pathnames. */
88 unsigned no_linux_ext:1; 86 bool no_linux_ext:1;
89 unsigned sfu_emul:1; 87 bool sfu_emul:1;
90 unsigned nullauth:1; /* attempt to authenticate with null user */ 88 bool nullauth:1; /* attempt to authenticate with null user */
91 unsigned nocase; /* request case insensitive filenames */ 89 unsigned nocase; /* request case insensitive filenames */
92 unsigned nobrl; /* disable sending byte range locks to srv */ 90 unsigned nobrl; /* disable sending byte range locks to srv */
93 unsigned int rsize; 91 unsigned int rsize;
@@ -345,18 +343,16 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
345 struct task_struct *task_to_wake = NULL; 343 struct task_struct *task_to_wake = NULL;
346 struct mid_q_entry *mid_entry; 344 struct mid_q_entry *mid_entry;
347 char temp; 345 char temp;
348 int isLargeBuf = FALSE; 346 bool isLargeBuf = false;
349 int isMultiRsp; 347 bool isMultiRsp;
350 int reconnect; 348 int reconnect;
351 349
352 current->flags |= PF_MEMALLOC; 350 current->flags |= PF_MEMALLOC;
353 server->tsk = current; /* save process info to wake at shutdown */
354 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current))); 351 cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
355 write_lock(&GlobalSMBSeslock); 352 write_lock(&GlobalSMBSeslock);
356 atomic_inc(&tcpSesAllocCount); 353 atomic_inc(&tcpSesAllocCount);
357 length = tcpSesAllocCount.counter; 354 length = tcpSesAllocCount.counter;
358 write_unlock(&GlobalSMBSeslock); 355 write_unlock(&GlobalSMBSeslock);
359 complete(&cifsd_complete);
360 if (length > 1) 356 if (length > 1)
361 mempool_resize(cifs_req_poolp, length + cifs_min_rcv, 357 mempool_resize(cifs_req_poolp, length + cifs_min_rcv,
362 GFP_KERNEL); 358 GFP_KERNEL);
@@ -390,8 +386,8 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
390 } else /* if existing small buf clear beginning */ 386 } else /* if existing small buf clear beginning */
391 memset(smallbuf, 0, sizeof(struct smb_hdr)); 387 memset(smallbuf, 0, sizeof(struct smb_hdr));
392 388
393 isLargeBuf = FALSE; 389 isLargeBuf = false;
394 isMultiRsp = FALSE; 390 isMultiRsp = false;
395 smb_buffer = smallbuf; 391 smb_buffer = smallbuf;
396 iov.iov_base = smb_buffer; 392 iov.iov_base = smb_buffer;
397 iov.iov_len = 4; 393 iov.iov_len = 4;
@@ -517,7 +513,7 @@ incomplete_rcv:
517 reconnect = 0; 513 reconnect = 0;
518 514
519 if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) { 515 if (pdu_length > MAX_CIFS_SMALL_BUFFER_SIZE - 4) {
520 isLargeBuf = TRUE; 516 isLargeBuf = true;
521 memcpy(bigbuf, smallbuf, 4); 517 memcpy(bigbuf, smallbuf, 4);
522 smb_buffer = bigbuf; 518 smb_buffer = bigbuf;
523 } 519 }
@@ -582,16 +578,18 @@ incomplete_rcv:
582 (mid_entry->command == smb_buffer->Command)) { 578 (mid_entry->command == smb_buffer->Command)) {
583 if (check2ndT2(smb_buffer,server->maxBuf) > 0) { 579 if (check2ndT2(smb_buffer,server->maxBuf) > 0) {
584 /* We have a multipart transact2 resp */ 580 /* We have a multipart transact2 resp */
585 isMultiRsp = TRUE; 581 isMultiRsp = true;
586 if (mid_entry->resp_buf) { 582 if (mid_entry->resp_buf) {
587 /* merge response - fix up 1st*/ 583 /* merge response - fix up 1st*/
588 if (coalesce_t2(smb_buffer, 584 if (coalesce_t2(smb_buffer,
589 mid_entry->resp_buf)) { 585 mid_entry->resp_buf)) {
590 mid_entry->multiRsp = 1; 586 mid_entry->multiRsp =
587 true;
591 break; 588 break;
592 } else { 589 } else {
593 /* all parts received */ 590 /* all parts received */
594 mid_entry->multiEnd = 1; 591 mid_entry->multiEnd =
592 true;
595 goto multi_t2_fnd; 593 goto multi_t2_fnd;
596 } 594 }
597 } else { 595 } else {
@@ -603,17 +601,15 @@ incomplete_rcv:
603 /* Have first buffer */ 601 /* Have first buffer */
604 mid_entry->resp_buf = 602 mid_entry->resp_buf =
605 smb_buffer; 603 smb_buffer;
606 mid_entry->largeBuf = 1; 604 mid_entry->largeBuf =
605 true;
607 bigbuf = NULL; 606 bigbuf = NULL;
608 } 607 }
609 } 608 }
610 break; 609 break;
611 } 610 }
612 mid_entry->resp_buf = smb_buffer; 611 mid_entry->resp_buf = smb_buffer;
613 if (isLargeBuf) 612 mid_entry->largeBuf = isLargeBuf;
614 mid_entry->largeBuf = 1;
615 else
616 mid_entry->largeBuf = 0;
617multi_t2_fnd: 613multi_t2_fnd:
618 task_to_wake = mid_entry->tsk; 614 task_to_wake = mid_entry->tsk;
619 mid_entry->midState = MID_RESPONSE_RECEIVED; 615 mid_entry->midState = MID_RESPONSE_RECEIVED;
@@ -638,8 +634,8 @@ multi_t2_fnd:
638 smallbuf = NULL; 634 smallbuf = NULL;
639 } 635 }
640 wake_up_process(task_to_wake); 636 wake_up_process(task_to_wake);
641 } else if ((is_valid_oplock_break(smb_buffer, server) == FALSE) 637 } else if (!is_valid_oplock_break(smb_buffer, server) &&
642 && (isMultiRsp == FALSE)) { 638 !isMultiRsp) {
643 cERROR(1, ("No task to wake, unknown frame received! " 639 cERROR(1, ("No task to wake, unknown frame received! "
644 "NumMids %d", midCount.counter)); 640 "NumMids %d", midCount.counter));
645 cifs_dump_mem("Received Data is: ", (char *)smb_buffer, 641 cifs_dump_mem("Received Data is: ", (char *)smb_buffer,
@@ -654,10 +650,20 @@ multi_t2_fnd:
654 650
655 spin_lock(&GlobalMid_Lock); 651 spin_lock(&GlobalMid_Lock);
656 server->tcpStatus = CifsExiting; 652 server->tcpStatus = CifsExiting;
657 server->tsk = NULL; 653 spin_unlock(&GlobalMid_Lock);
654
655 /* don't exit until kthread_stop is called */
656 set_current_state(TASK_UNINTERRUPTIBLE);
657 while (!kthread_should_stop()) {
658 schedule();
659 set_current_state(TASK_UNINTERRUPTIBLE);
660 }
661 set_current_state(TASK_RUNNING);
662
658 /* check if we have blocked requests that need to free */ 663 /* check if we have blocked requests that need to free */
659 /* Note that cifs_max_pending is normally 50, but 664 /* Note that cifs_max_pending is normally 50, but
660 can be set at module install time to as little as two */ 665 can be set at module install time to as little as two */
666 spin_lock(&GlobalMid_Lock);
661 if (atomic_read(&server->inFlight) >= cifs_max_pending) 667 if (atomic_read(&server->inFlight) >= cifs_max_pending)
662 atomic_set(&server->inFlight, cifs_max_pending - 1); 668 atomic_set(&server->inFlight, cifs_max_pending - 1);
663 /* We do not want to set the max_pending too low or we 669 /* We do not want to set the max_pending too low or we
@@ -825,7 +831,7 @@ cifs_parse_mount_options(char *options, const char *devname,
825 vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); 831 vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP);
826 832
827 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */ 833 /* vol->retry default is 0 (i.e. "soft" limited retry not hard retry) */
828 vol->rw = TRUE; 834 vol->rw = true;
829 /* default is always to request posix paths. */ 835 /* default is always to request posix paths. */
830 vol->posix_paths = 1; 836 vol->posix_paths = 1;
831 837
@@ -1181,7 +1187,7 @@ cifs_parse_mount_options(char *options, const char *devname,
1181 } else if (strnicmp(data, "guest", 5) == 0) { 1187 } else if (strnicmp(data, "guest", 5) == 0) {
1182 /* ignore */ 1188 /* ignore */
1183 } else if (strnicmp(data, "rw", 2) == 0) { 1189 } else if (strnicmp(data, "rw", 2) == 0) {
1184 vol->rw = TRUE; 1190 vol->rw = true;
1185 } else if ((strnicmp(data, "suid", 4) == 0) || 1191 } else if ((strnicmp(data, "suid", 4) == 0) ||
1186 (strnicmp(data, "nosuid", 6) == 0) || 1192 (strnicmp(data, "nosuid", 6) == 0) ||
1187 (strnicmp(data, "exec", 4) == 0) || 1193 (strnicmp(data, "exec", 4) == 0) ||
@@ -1197,7 +1203,7 @@ cifs_parse_mount_options(char *options, const char *devname,
1197 is ok to just ignore them */ 1203 is ok to just ignore them */
1198 continue; 1204 continue;
1199 } else if (strnicmp(data, "ro", 2) == 0) { 1205 } else if (strnicmp(data, "ro", 2) == 0) {
1200 vol->rw = FALSE; 1206 vol->rw = false;
1201 } else if (strnicmp(data, "hard", 4) == 0) { 1207 } else if (strnicmp(data, "hard", 4) == 0) {
1202 vol->retry = 1; 1208 vol->retry = 1;
1203 } else if (strnicmp(data, "soft", 4) == 0) { 1209 } else if (strnicmp(data, "soft", 4) == 0) {
@@ -1305,6 +1311,9 @@ cifs_parse_mount_options(char *options, const char *devname,
1305 "begin with // or \\\\ \n"); 1311 "begin with // or \\\\ \n");
1306 return 1; 1312 return 1;
1307 } 1313 }
1314 value = strpbrk(vol->UNC+2, "/\\");
1315 if (value)
1316 *value = '\\';
1308 } else { 1317 } else {
1309 printk(KERN_WARNING "CIFS: UNC name too long\n"); 1318 printk(KERN_WARNING "CIFS: UNC name too long\n");
1310 return 1; 1319 return 1;
@@ -1318,42 +1327,43 @@ cifs_parse_mount_options(char *options, const char *devname,
1318 1327
1319static struct cifsSesInfo * 1328static struct cifsSesInfo *
1320cifs_find_tcp_session(struct in_addr *target_ip_addr, 1329cifs_find_tcp_session(struct in_addr *target_ip_addr,
1321 struct in6_addr *target_ip6_addr, 1330 struct in6_addr *target_ip6_addr,
1322 char *userName, struct TCP_Server_Info **psrvTcp) 1331 char *userName, struct TCP_Server_Info **psrvTcp)
1323{ 1332{
1324 struct list_head *tmp; 1333 struct list_head *tmp;
1325 struct cifsSesInfo *ses; 1334 struct cifsSesInfo *ses;
1335
1326 *psrvTcp = NULL; 1336 *psrvTcp = NULL;
1327 read_lock(&GlobalSMBSeslock);
1328 1337
1338 read_lock(&GlobalSMBSeslock);
1329 list_for_each(tmp, &GlobalSMBSessionList) { 1339 list_for_each(tmp, &GlobalSMBSessionList) {
1330 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList); 1340 ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
1331 if (ses->server) { 1341 if (!ses->server)
1332 if ((target_ip_addr && 1342 continue;
1333 (ses->server->addr.sockAddr.sin_addr.s_addr 1343
1334 == target_ip_addr->s_addr)) || (target_ip6_addr 1344 if (target_ip_addr &&
1335 && memcmp(&ses->server->addr.sockAddr6.sin6_addr, 1345 ses->server->addr.sockAddr.sin_addr.s_addr != target_ip_addr->s_addr)
1336 target_ip6_addr, sizeof(*target_ip6_addr)))) { 1346 continue;
1337 /* BB lock server and tcp session and increment 1347 else if (target_ip6_addr &&
1338 use count here?? */ 1348 memcmp(&ses->server->addr.sockAddr6.sin6_addr,
1339 1349 target_ip6_addr, sizeof(*target_ip6_addr)))
1340 /* found a match on the TCP session */ 1350 continue;
1341 *psrvTcp = ses->server; 1351 /* BB lock server and tcp session; increment use count here?? */
1342 1352
1343 /* BB check if reconnection needed */ 1353 /* found a match on the TCP session */
1344 if (strncmp 1354 *psrvTcp = ses->server;
1345 (ses->userName, userName, 1355
1346 MAX_USERNAME_SIZE) == 0){ 1356 /* BB check if reconnection needed */
1347 read_unlock(&GlobalSMBSeslock); 1357 if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
1348 /* Found exact match on both TCP and 1358 read_unlock(&GlobalSMBSeslock);
1349 SMB sessions */ 1359 /* Found exact match on both TCP and
1350 return ses; 1360 SMB sessions */
1351 } 1361 return ses;
1352 }
1353 } 1362 }
1354 /* else tcp and smb sessions need reconnection */ 1363 /* else tcp and smb sessions need reconnection */
1355 } 1364 }
1356 read_unlock(&GlobalSMBSeslock); 1365 read_unlock(&GlobalSMBSeslock);
1366
1357 return NULL; 1367 return NULL;
1358} 1368}
1359 1369
@@ -1362,45 +1372,43 @@ find_unc(__be32 new_target_ip_addr, char *uncName, char *userName)
1362{ 1372{
1363 struct list_head *tmp; 1373 struct list_head *tmp;
1364 struct cifsTconInfo *tcon; 1374 struct cifsTconInfo *tcon;
1375 __be32 old_ip;
1365 1376
1366 read_lock(&GlobalSMBSeslock); 1377 read_lock(&GlobalSMBSeslock);
1378
1367 list_for_each(tmp, &GlobalTreeConnectionList) { 1379 list_for_each(tmp, &GlobalTreeConnectionList) {
1368 cFYI(1, ("Next tcon")); 1380 cFYI(1, ("Next tcon"));
1369 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); 1381 tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList);
1370 if (tcon->ses) { 1382 if (!tcon->ses || !tcon->ses->server)
1371 if (tcon->ses->server) { 1383 continue;
1372 cFYI(1, 1384
1373 ("old ip addr: %x == new ip %x ?", 1385 old_ip = tcon->ses->server->addr.sockAddr.sin_addr.s_addr;
1374 tcon->ses->server->addr.sockAddr.sin_addr. 1386 cFYI(1, ("old ip addr: %x == new ip %x ?",
1375 s_addr, new_target_ip_addr)); 1387 old_ip, new_target_ip_addr));
1376 if (tcon->ses->server->addr.sockAddr.sin_addr. 1388
1377 s_addr == new_target_ip_addr) { 1389 if (old_ip != new_target_ip_addr)
1378 /* BB lock tcon, server and tcp session and increment use count here? */ 1390 continue;
1379 /* found a match on the TCP session */ 1391
1380 /* BB check if reconnection needed */ 1392 /* BB lock tcon, server, tcp session and increment use count? */
1381 cFYI(1, 1393 /* found a match on the TCP session */
1382 ("IP match, old UNC: %s new: %s", 1394 /* BB check if reconnection needed */
1383 tcon->treeName, uncName)); 1395 cFYI(1, ("IP match, old UNC: %s new: %s",
1384 if (strncmp 1396 tcon->treeName, uncName));
1385 (tcon->treeName, uncName, 1397
1386 MAX_TREE_SIZE) == 0) { 1398 if (strncmp(tcon->treeName, uncName, MAX_TREE_SIZE))
1387 cFYI(1, 1399 continue;
1388 ("and old usr: %s new: %s", 1400
1389 tcon->treeName, uncName)); 1401 cFYI(1, ("and old usr: %s new: %s",
1390 if (strncmp 1402 tcon->treeName, uncName));
1391 (tcon->ses->userName, 1403
1392 userName, 1404 if (strncmp(tcon->ses->userName, userName, MAX_USERNAME_SIZE))
1393 MAX_USERNAME_SIZE) == 0) { 1405 continue;
1394 read_unlock(&GlobalSMBSeslock); 1406
1395 /* matched smb session 1407 /* matched smb session (user name) */
1396 (user name */ 1408 read_unlock(&GlobalSMBSeslock);
1397 return tcon; 1409 return tcon;
1398 }
1399 }
1400 }
1401 }
1402 }
1403 } 1410 }
1411
1404 read_unlock(&GlobalSMBSeslock); 1412 read_unlock(&GlobalSMBSeslock);
1405 return NULL; 1413 return NULL;
1406} 1414}
@@ -1982,7 +1990,6 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
1982 kfree(srvTcp->hostname); 1990 kfree(srvTcp->hostname);
1983 goto out; 1991 goto out;
1984 } 1992 }
1985 wait_for_completion(&cifsd_complete);
1986 rc = 0; 1993 rc = 0;
1987 memcpy(srvTcp->workstation_RFC1001_name, 1994 memcpy(srvTcp->workstation_RFC1001_name,
1988 volume_info.source_rfc1001_name, 16); 1995 volume_info.source_rfc1001_name, 16);
@@ -2189,15 +2196,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2189 srvTcp->tcpStatus = CifsExiting; 2196 srvTcp->tcpStatus = CifsExiting;
2190 spin_unlock(&GlobalMid_Lock); 2197 spin_unlock(&GlobalMid_Lock);
2191 if (srvTcp->tsk) { 2198 if (srvTcp->tsk) {
2192 struct task_struct *tsk;
2193 /* If we could verify that kthread_stop would 2199 /* If we could verify that kthread_stop would
2194 always wake up processes blocked in 2200 always wake up processes blocked in
2195 tcp in recv_mesg then we could remove the 2201 tcp in recv_mesg then we could remove the
2196 send_sig call */ 2202 send_sig call */
2197 force_sig(SIGKILL, srvTcp->tsk); 2203 force_sig(SIGKILL, srvTcp->tsk);
2198 tsk = srvTcp->tsk; 2204 kthread_stop(srvTcp->tsk);
2199 if (tsk)
2200 kthread_stop(tsk);
2201 } 2205 }
2202 } 2206 }
2203 /* If find_unc succeeded then rc == 0 so we can not end */ 2207 /* If find_unc succeeded then rc == 0 so we can not end */
@@ -2213,23 +2217,17 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
2213 if ((temp_rc == -ESHUTDOWN) && 2217 if ((temp_rc == -ESHUTDOWN) &&
2214 (pSesInfo->server) && 2218 (pSesInfo->server) &&
2215 (pSesInfo->server->tsk)) { 2219 (pSesInfo->server->tsk)) {
2216 struct task_struct *tsk;
2217 force_sig(SIGKILL, 2220 force_sig(SIGKILL,
2218 pSesInfo->server->tsk); 2221 pSesInfo->server->tsk);
2219 tsk = pSesInfo->server->tsk; 2222 kthread_stop(pSesInfo->server->tsk);
2220 if (tsk)
2221 kthread_stop(tsk);
2222 } 2223 }
2223 } else { 2224 } else {
2224 cFYI(1, ("No session or bad tcon")); 2225 cFYI(1, ("No session or bad tcon"));
2225 if ((pSesInfo->server) && 2226 if ((pSesInfo->server) &&
2226 (pSesInfo->server->tsk)) { 2227 (pSesInfo->server->tsk)) {
2227 struct task_struct *tsk;
2228 force_sig(SIGKILL, 2228 force_sig(SIGKILL,
2229 pSesInfo->server->tsk); 2229 pSesInfo->server->tsk);
2230 tsk = pSesInfo->server->tsk; 2230 kthread_stop(pSesInfo->server->tsk);
2231 if (tsk)
2232 kthread_stop(tsk);
2233 } 2231 }
2234 } 2232 }
2235 sesInfoFree(pSesInfo); 2233 sesInfoFree(pSesInfo);
@@ -2602,7 +2600,7 @@ sesssetup_nomem: /* do not return an error on nomem for the info strings,
2602 2600
2603static int 2601static int
2604CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, 2602CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2605 struct cifsSesInfo *ses, int *pNTLMv2_flag, 2603 struct cifsSesInfo *ses, bool *pNTLMv2_flag,
2606 const struct nls_table *nls_codepage) 2604 const struct nls_table *nls_codepage)
2607{ 2605{
2608 struct smb_hdr *smb_buffer; 2606 struct smb_hdr *smb_buffer;
@@ -2625,7 +2623,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2625 if (ses == NULL) 2623 if (ses == NULL)
2626 return -EINVAL; 2624 return -EINVAL;
2627 domain = ses->domainName; 2625 domain = ses->domainName;
2628 *pNTLMv2_flag = FALSE; 2626 *pNTLMv2_flag = false;
2629 smb_buffer = cifs_buf_get(); 2627 smb_buffer = cifs_buf_get();
2630 if (smb_buffer == NULL) { 2628 if (smb_buffer == NULL) {
2631 return -ENOMEM; 2629 return -ENOMEM;
@@ -2778,7 +2776,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2778 CIFS_CRYPTO_KEY_SIZE); 2776 CIFS_CRYPTO_KEY_SIZE);
2779 if (SecurityBlob2->NegotiateFlags & 2777 if (SecurityBlob2->NegotiateFlags &
2780 cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2)) 2778 cpu_to_le32(NTLMSSP_NEGOTIATE_NTLMV2))
2781 *pNTLMv2_flag = TRUE; 2779 *pNTLMv2_flag = true;
2782 2780
2783 if ((SecurityBlob2->NegotiateFlags & 2781 if ((SecurityBlob2->NegotiateFlags &
2784 cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN)) 2782 cpu_to_le32(NTLMSSP_NEGOTIATE_ALWAYS_SIGN))
@@ -2939,7 +2937,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
2939} 2937}
2940static int 2938static int
2941CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, 2939CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
2942 char *ntlm_session_key, int ntlmv2_flag, 2940 char *ntlm_session_key, bool ntlmv2_flag,
2943 const struct nls_table *nls_codepage) 2941 const struct nls_table *nls_codepage)
2944{ 2942{
2945 struct smb_hdr *smb_buffer; 2943 struct smb_hdr *smb_buffer;
@@ -3556,8 +3554,6 @@ cifs_umount(struct super_block *sb, struct cifs_sb_info *cifs_sb)
3556 cifs_sb->prepath = NULL; 3554 cifs_sb->prepath = NULL;
3557 kfree(tmp); 3555 kfree(tmp);
3558 if (ses) 3556 if (ses)
3559 schedule_timeout_interruptible(msecs_to_jiffies(500));
3560 if (ses)
3561 sesInfoFree(ses); 3557 sesInfoFree(ses);
3562 3558
3563 FreeXid(xid); 3559 FreeXid(xid);
@@ -3569,7 +3565,7 @@ int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo,
3569{ 3565{
3570 int rc = 0; 3566 int rc = 0;
3571 char ntlm_session_key[CIFS_SESS_KEY_SIZE]; 3567 char ntlm_session_key[CIFS_SESS_KEY_SIZE];
3572 int ntlmv2_flag = FALSE; 3568 bool ntlmv2_flag = false;
3573 int first_time = 0; 3569 int first_time = 0;
3574 3570
3575 /* what if server changes its buffer size after dropping the session? */ 3571 /* what if server changes its buffer size after dropping the session? */
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 0f5c62ba4038..e4e0078a0526 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -119,6 +119,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
119{ 119{
120 int rc = -ENOENT; 120 int rc = -ENOENT;
121 int xid; 121 int xid;
122 int create_options = CREATE_NOT_DIR;
122 int oplock = 0; 123 int oplock = 0;
123 int desiredAccess = GENERIC_READ | GENERIC_WRITE; 124 int desiredAccess = GENERIC_READ | GENERIC_WRITE;
124 __u16 fileHandle; 125 __u16 fileHandle;
@@ -130,7 +131,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
130 struct cifsFileInfo *pCifsFile = NULL; 131 struct cifsFileInfo *pCifsFile = NULL;
131 struct cifsInodeInfo *pCifsInode; 132 struct cifsInodeInfo *pCifsInode;
132 int disposition = FILE_OVERWRITE_IF; 133 int disposition = FILE_OVERWRITE_IF;
133 int write_only = FALSE; 134 bool write_only = false;
134 135
135 xid = GetXid(); 136 xid = GetXid();
136 137
@@ -152,7 +153,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
152 if (oflags & FMODE_WRITE) { 153 if (oflags & FMODE_WRITE) {
153 desiredAccess |= GENERIC_WRITE; 154 desiredAccess |= GENERIC_WRITE;
154 if (!(oflags & FMODE_READ)) 155 if (!(oflags & FMODE_READ))
155 write_only = TRUE; 156 write_only = true;
156 } 157 }
157 158
158 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) 159 if ((oflags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
@@ -176,9 +177,19 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
176 FreeXid(xid); 177 FreeXid(xid);
177 return -ENOMEM; 178 return -ENOMEM;
178 } 179 }
180
181 mode &= ~current->fs->umask;
182
183 /*
184 * if we're not using unix extensions, see if we need to set
185 * ATTR_READONLY on the create call
186 */
187 if (!pTcon->unix_ext && (mode & S_IWUGO) == 0)
188 create_options |= CREATE_OPTION_READONLY;
189
179 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS) 190 if (cifs_sb->tcon->ses->capabilities & CAP_NT_SMBS)
180 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition, 191 rc = CIFSSMBOpen(xid, pTcon, full_path, disposition,
181 desiredAccess, CREATE_NOT_DIR, 192 desiredAccess, create_options,
182 &fileHandle, &oplock, buf, cifs_sb->local_nls, 193 &fileHandle, &oplock, buf, cifs_sb->local_nls,
183 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 194 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
184 else 195 else
@@ -187,7 +198,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
187 if (rc == -EIO) { 198 if (rc == -EIO) {
188 /* old server, retry the open legacy style */ 199 /* old server, retry the open legacy style */
189 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition, 200 rc = SMBLegacyOpen(xid, pTcon, full_path, disposition,
190 desiredAccess, CREATE_NOT_DIR, 201 desiredAccess, create_options,
191 &fileHandle, &oplock, buf, cifs_sb->local_nls, 202 &fileHandle, &oplock, buf, cifs_sb->local_nls,
192 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 203 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
193 } 204 }
@@ -197,7 +208,6 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
197 /* If Open reported that we actually created a file 208 /* If Open reported that we actually created a file
198 then we now have to set the mode if possible */ 209 then we now have to set the mode if possible */
199 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) { 210 if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
200 mode &= ~current->fs->umask;
201 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 211 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
202 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, 212 CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
203 (__u64)current->fsuid, 213 (__u64)current->fsuid,
@@ -254,7 +264,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
254 d_instantiate(direntry, newinode); 264 d_instantiate(direntry, newinode);
255 } 265 }
256 if ((nd == NULL /* nfsd case - nfs srv does not set nd */) || 266 if ((nd == NULL /* nfsd case - nfs srv does not set nd */) ||
257 ((nd->flags & LOOKUP_OPEN) == FALSE)) { 267 (!(nd->flags & LOOKUP_OPEN))) {
258 /* mknod case - do not leave file open */ 268 /* mknod case - do not leave file open */
259 CIFSSMBClose(xid, pTcon, fileHandle); 269 CIFSSMBClose(xid, pTcon, fileHandle);
260 } else if (newinode) { 270 } else if (newinode) {
@@ -266,8 +276,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
266 pCifsFile->netfid = fileHandle; 276 pCifsFile->netfid = fileHandle;
267 pCifsFile->pid = current->tgid; 277 pCifsFile->pid = current->tgid;
268 pCifsFile->pInode = newinode; 278 pCifsFile->pInode = newinode;
269 pCifsFile->invalidHandle = FALSE; 279 pCifsFile->invalidHandle = false;
270 pCifsFile->closePend = FALSE; 280 pCifsFile->closePend = false;
271 init_MUTEX(&pCifsFile->fh_sem); 281 init_MUTEX(&pCifsFile->fh_sem);
272 mutex_init(&pCifsFile->lock_mutex); 282 mutex_init(&pCifsFile->lock_mutex);
273 INIT_LIST_HEAD(&pCifsFile->llist); 283 INIT_LIST_HEAD(&pCifsFile->llist);
@@ -280,7 +290,7 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
280 pCifsInode = CIFS_I(newinode); 290 pCifsInode = CIFS_I(newinode);
281 if (pCifsInode) { 291 if (pCifsInode) {
282 /* if readable file instance put first in list*/ 292 /* if readable file instance put first in list*/
283 if (write_only == TRUE) { 293 if (write_only) {
284 list_add_tail(&pCifsFile->flist, 294 list_add_tail(&pCifsFile->flist,
285 &pCifsInode->openFileList); 295 &pCifsInode->openFileList);
286 } else { 296 } else {
@@ -288,12 +298,12 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
288 &pCifsInode->openFileList); 298 &pCifsInode->openFileList);
289 } 299 }
290 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 300 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
291 pCifsInode->clientCanCacheAll = TRUE; 301 pCifsInode->clientCanCacheAll = true;
292 pCifsInode->clientCanCacheRead = TRUE; 302 pCifsInode->clientCanCacheRead = true;
293 cFYI(1, ("Exclusive Oplock inode %p", 303 cFYI(1, ("Exclusive Oplock inode %p",
294 newinode)); 304 newinode));
295 } else if ((oplock & 0xF) == OPLOCK_READ) 305 } else if ((oplock & 0xF) == OPLOCK_READ)
296 pCifsInode->clientCanCacheRead = TRUE; 306 pCifsInode->clientCanCacheRead = true;
297 } 307 }
298 write_unlock(&GlobalSMBSeslock); 308 write_unlock(&GlobalSMBSeslock);
299 } 309 }
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 7cc86c418182..939e256f8497 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -55,6 +55,32 @@ struct key_type key_type_dns_resolver = {
55 .match = user_match, 55 .match = user_match,
56}; 56};
57 57
58/* Checks if supplied name is IP address
59 * returns:
60 * 1 - name is IP
61 * 0 - name is not IP
62 */
63static int is_ip(const char *name)
64{
65 int rc;
66 struct sockaddr_in sin_server;
67 struct sockaddr_in6 sin_server6;
68
69 rc = cifs_inet_pton(AF_INET, name,
70 &sin_server.sin_addr.s_addr);
71
72 if (rc <= 0) {
73 /* not ipv4 address, try ipv6 */
74 rc = cifs_inet_pton(AF_INET6, name,
75 &sin_server6.sin6_addr.in6_u);
76 if (rc > 0)
77 return 1;
78 } else {
79 return 1;
80 }
81 /* we failed translating address */
82 return 0;
83}
58 84
59/* Resolves server name to ip address. 85/* Resolves server name to ip address.
60 * input: 86 * input:
@@ -67,8 +93,9 @@ int
67dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) 93dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
68{ 94{
69 int rc = -EAGAIN; 95 int rc = -EAGAIN;
70 struct key *rkey; 96 struct key *rkey = ERR_PTR(-EAGAIN);
71 char *name; 97 char *name;
98 char *data = NULL;
72 int len; 99 int len;
73 100
74 if (!ip_addr || !unc) 101 if (!ip_addr || !unc)
@@ -97,26 +124,41 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
97 memcpy(name, unc+2, len); 124 memcpy(name, unc+2, len);
98 name[len] = 0; 125 name[len] = 0;
99 126
127 if (is_ip(name)) {
128 cFYI(1, ("%s: it is IP, skipping dns upcall: %s",
129 __func__, name));
130 data = name;
131 goto skip_upcall;
132 }
133
100 rkey = request_key(&key_type_dns_resolver, name, ""); 134 rkey = request_key(&key_type_dns_resolver, name, "");
101 if (!IS_ERR(rkey)) { 135 if (!IS_ERR(rkey)) {
102 len = strlen(rkey->payload.data); 136 data = rkey->payload.data;
103 *ip_addr = kmalloc(len+1, GFP_KERNEL); 137 cFYI(1, ("%s: resolved: %s to %s", __func__,
104 if (*ip_addr) {
105 memcpy(*ip_addr, rkey->payload.data, len);
106 (*ip_addr)[len] = '\0';
107 cFYI(1, ("%s: resolved: %s to %s", __func__,
108 rkey->description, 138 rkey->description,
109 *ip_addr 139 *ip_addr
110 )); 140 ));
141 } else {
142 cERROR(1, ("%s: unable to resolve: %s", __func__, name));
143 goto out;
144 }
145
146skip_upcall:
147 if (data) {
148 len = strlen(data);
149 *ip_addr = kmalloc(len+1, GFP_KERNEL);
150 if (*ip_addr) {
151 memcpy(*ip_addr, data, len);
152 (*ip_addr)[len] = '\0';
111 rc = 0; 153 rc = 0;
112 } else { 154 } else {
113 rc = -ENOMEM; 155 rc = -ENOMEM;
114 } 156 }
115 key_put(rkey); 157 if (!IS_ERR(rkey))
116 } else { 158 key_put(rkey);
117 cERROR(1, ("%s: unable to resolve: %s", __func__, name));
118 } 159 }
119 160
161out:
120 kfree(name); 162 kfree(name);
121 return rc; 163 return rc;
122} 164}
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index 7d1d5aa4c430..5a57581eb4b2 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -68,7 +68,7 @@ int cifs_dir_notify(struct file *file, unsigned long arg)
68{ 68{
69 int xid; 69 int xid;
70 int rc = -EINVAL; 70 int rc = -EINVAL;
71 int oplock = FALSE; 71 int oplock = 0;
72 struct cifs_sb_info *cifs_sb; 72 struct cifs_sb_info *cifs_sb;
73 struct cifsTconInfo *pTcon; 73 struct cifsTconInfo *pTcon;
74 char *full_path = NULL; 74 char *full_path = NULL;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 40b690073fc1..31a0a33b9d95 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -51,8 +51,8 @@ static inline struct cifsFileInfo *cifs_init_private(
51 INIT_LIST_HEAD(&private_data->llist); 51 INIT_LIST_HEAD(&private_data->llist);
52 private_data->pfile = file; /* needed for writepage */ 52 private_data->pfile = file; /* needed for writepage */
53 private_data->pInode = inode; 53 private_data->pInode = inode;
54 private_data->invalidHandle = FALSE; 54 private_data->invalidHandle = false;
55 private_data->closePend = FALSE; 55 private_data->closePend = false;
56 /* we have to track num writers to the inode, since writepages 56 /* we have to track num writers to the inode, since writepages
57 does not tell us which handle the write is for so there can 57 does not tell us which handle the write is for so there can
58 be a close (overlapping with write) of the filehandle that 58 be a close (overlapping with write) of the filehandle that
@@ -148,12 +148,12 @@ client_can_cache:
148 full_path, buf, inode->i_sb, xid, NULL); 148 full_path, buf, inode->i_sb, xid, NULL);
149 149
150 if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) { 150 if ((*oplock & 0xF) == OPLOCK_EXCLUSIVE) {
151 pCifsInode->clientCanCacheAll = TRUE; 151 pCifsInode->clientCanCacheAll = true;
152 pCifsInode->clientCanCacheRead = TRUE; 152 pCifsInode->clientCanCacheRead = true;
153 cFYI(1, ("Exclusive Oplock granted on inode %p", 153 cFYI(1, ("Exclusive Oplock granted on inode %p",
154 file->f_path.dentry->d_inode)); 154 file->f_path.dentry->d_inode));
155 } else if ((*oplock & 0xF) == OPLOCK_READ) 155 } else if ((*oplock & 0xF) == OPLOCK_READ)
156 pCifsInode->clientCanCacheRead = TRUE; 156 pCifsInode->clientCanCacheRead = true;
157 157
158 return rc; 158 return rc;
159} 159}
@@ -247,7 +247,7 @@ int cifs_open(struct inode *inode, struct file *file)
247 if (oplockEnabled) 247 if (oplockEnabled)
248 oplock = REQ_OPLOCK; 248 oplock = REQ_OPLOCK;
249 else 249 else
250 oplock = FALSE; 250 oplock = 0;
251 251
252 /* BB pass O_SYNC flag through on file attributes .. BB */ 252 /* BB pass O_SYNC flag through on file attributes .. BB */
253 253
@@ -339,7 +339,7 @@ static int cifs_relock_file(struct cifsFileInfo *cifsFile)
339 return rc; 339 return rc;
340} 340}
341 341
342static int cifs_reopen_file(struct file *file, int can_flush) 342static int cifs_reopen_file(struct file *file, bool can_flush)
343{ 343{
344 int rc = -EACCES; 344 int rc = -EACCES;
345 int xid, oplock; 345 int xid, oplock;
@@ -360,7 +360,7 @@ static int cifs_reopen_file(struct file *file, int can_flush)
360 360
361 xid = GetXid(); 361 xid = GetXid();
362 down(&pCifsFile->fh_sem); 362 down(&pCifsFile->fh_sem);
363 if (pCifsFile->invalidHandle == FALSE) { 363 if (!pCifsFile->invalidHandle) {
364 up(&pCifsFile->fh_sem); 364 up(&pCifsFile->fh_sem);
365 FreeXid(xid); 365 FreeXid(xid);
366 return 0; 366 return 0;
@@ -404,7 +404,7 @@ reopen_error_exit:
404 if (oplockEnabled) 404 if (oplockEnabled)
405 oplock = REQ_OPLOCK; 405 oplock = REQ_OPLOCK;
406 else 406 else
407 oplock = FALSE; 407 oplock = 0;
408 408
409 /* Can not refresh inode by passing in file_info buf to be returned 409 /* Can not refresh inode by passing in file_info buf to be returned
410 by SMBOpen and then calling get_inode_info with returned buf 410 by SMBOpen and then calling get_inode_info with returned buf
@@ -422,7 +422,7 @@ reopen_error_exit:
422 cFYI(1, ("oplock: %d", oplock)); 422 cFYI(1, ("oplock: %d", oplock));
423 } else { 423 } else {
424 pCifsFile->netfid = netfid; 424 pCifsFile->netfid = netfid;
425 pCifsFile->invalidHandle = FALSE; 425 pCifsFile->invalidHandle = false;
426 up(&pCifsFile->fh_sem); 426 up(&pCifsFile->fh_sem);
427 pCifsInode = CIFS_I(inode); 427 pCifsInode = CIFS_I(inode);
428 if (pCifsInode) { 428 if (pCifsInode) {
@@ -432,8 +432,8 @@ reopen_error_exit:
432 CIFS_I(inode)->write_behind_rc = rc; 432 CIFS_I(inode)->write_behind_rc = rc;
433 /* temporarily disable caching while we 433 /* temporarily disable caching while we
434 go to server to get inode info */ 434 go to server to get inode info */
435 pCifsInode->clientCanCacheAll = FALSE; 435 pCifsInode->clientCanCacheAll = false;
436 pCifsInode->clientCanCacheRead = FALSE; 436 pCifsInode->clientCanCacheRead = false;
437 if (pTcon->unix_ext) 437 if (pTcon->unix_ext)
438 rc = cifs_get_inode_info_unix(&inode, 438 rc = cifs_get_inode_info_unix(&inode,
439 full_path, inode->i_sb, xid); 439 full_path, inode->i_sb, xid);
@@ -448,16 +448,16 @@ reopen_error_exit:
448 we can not go to the server to get the new inod 448 we can not go to the server to get the new inod
449 info */ 449 info */
450 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) { 450 if ((oplock & 0xF) == OPLOCK_EXCLUSIVE) {
451 pCifsInode->clientCanCacheAll = TRUE; 451 pCifsInode->clientCanCacheAll = true;
452 pCifsInode->clientCanCacheRead = TRUE; 452 pCifsInode->clientCanCacheRead = true;
453 cFYI(1, ("Exclusive Oplock granted on inode %p", 453 cFYI(1, ("Exclusive Oplock granted on inode %p",
454 file->f_path.dentry->d_inode)); 454 file->f_path.dentry->d_inode));
455 } else if ((oplock & 0xF) == OPLOCK_READ) { 455 } else if ((oplock & 0xF) == OPLOCK_READ) {
456 pCifsInode->clientCanCacheRead = TRUE; 456 pCifsInode->clientCanCacheRead = true;
457 pCifsInode->clientCanCacheAll = FALSE; 457 pCifsInode->clientCanCacheAll = false;
458 } else { 458 } else {
459 pCifsInode->clientCanCacheRead = FALSE; 459 pCifsInode->clientCanCacheRead = false;
460 pCifsInode->clientCanCacheAll = FALSE; 460 pCifsInode->clientCanCacheAll = false;
461 } 461 }
462 cifs_relock_file(pCifsFile); 462 cifs_relock_file(pCifsFile);
463 } 463 }
@@ -484,7 +484,7 @@ int cifs_close(struct inode *inode, struct file *file)
484 if (pSMBFile) { 484 if (pSMBFile) {
485 struct cifsLockInfo *li, *tmp; 485 struct cifsLockInfo *li, *tmp;
486 486
487 pSMBFile->closePend = TRUE; 487 pSMBFile->closePend = true;
488 if (pTcon) { 488 if (pTcon) {
489 /* no sense reconnecting to close a file that is 489 /* no sense reconnecting to close a file that is
490 already closed */ 490 already closed */
@@ -553,8 +553,8 @@ int cifs_close(struct inode *inode, struct file *file)
553 cFYI(1, ("closing last open instance for inode %p", inode)); 553 cFYI(1, ("closing last open instance for inode %p", inode));
554 /* if the file is not open we do not know if we can cache info 554 /* if the file is not open we do not know if we can cache info
555 on this inode, much less write behind and read ahead */ 555 on this inode, much less write behind and read ahead */
556 CIFS_I(inode)->clientCanCacheRead = FALSE; 556 CIFS_I(inode)->clientCanCacheRead = false;
557 CIFS_I(inode)->clientCanCacheAll = FALSE; 557 CIFS_I(inode)->clientCanCacheAll = false;
558 } 558 }
559 read_unlock(&GlobalSMBSeslock); 559 read_unlock(&GlobalSMBSeslock);
560 if ((rc == 0) && CIFS_I(inode)->write_behind_rc) 560 if ((rc == 0) && CIFS_I(inode)->write_behind_rc)
@@ -583,9 +583,9 @@ int cifs_closedir(struct inode *inode, struct file *file)
583 pTcon = cifs_sb->tcon; 583 pTcon = cifs_sb->tcon;
584 584
585 cFYI(1, ("Freeing private data in close dir")); 585 cFYI(1, ("Freeing private data in close dir"));
586 if ((pCFileStruct->srch_inf.endOfSearch == FALSE) && 586 if (!pCFileStruct->srch_inf.endOfSearch &&
587 (pCFileStruct->invalidHandle == FALSE)) { 587 !pCFileStruct->invalidHandle) {
588 pCFileStruct->invalidHandle = TRUE; 588 pCFileStruct->invalidHandle = true;
589 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid); 589 rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
590 cFYI(1, ("Closing uncompleted readdir with rc %d", 590 cFYI(1, ("Closing uncompleted readdir with rc %d",
591 rc)); 591 rc));
@@ -637,12 +637,12 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
637 __u32 numLock = 0; 637 __u32 numLock = 0;
638 __u32 numUnlock = 0; 638 __u32 numUnlock = 0;
639 __u64 length; 639 __u64 length;
640 int wait_flag = FALSE; 640 bool wait_flag = false;
641 struct cifs_sb_info *cifs_sb; 641 struct cifs_sb_info *cifs_sb;
642 struct cifsTconInfo *pTcon; 642 struct cifsTconInfo *pTcon;
643 __u16 netfid; 643 __u16 netfid;
644 __u8 lockType = LOCKING_ANDX_LARGE_FILES; 644 __u8 lockType = LOCKING_ANDX_LARGE_FILES;
645 int posix_locking; 645 bool posix_locking;
646 646
647 length = 1 + pfLock->fl_end - pfLock->fl_start; 647 length = 1 + pfLock->fl_end - pfLock->fl_start;
648 rc = -EACCES; 648 rc = -EACCES;
@@ -659,7 +659,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
659 cFYI(1, ("Flock")); 659 cFYI(1, ("Flock"));
660 if (pfLock->fl_flags & FL_SLEEP) { 660 if (pfLock->fl_flags & FL_SLEEP) {
661 cFYI(1, ("Blocking lock")); 661 cFYI(1, ("Blocking lock"));
662 wait_flag = TRUE; 662 wait_flag = true;
663 } 663 }
664 if (pfLock->fl_flags & FL_ACCESS) 664 if (pfLock->fl_flags & FL_ACCESS)
665 cFYI(1, ("Process suspended by mandatory locking - " 665 cFYI(1, ("Process suspended by mandatory locking - "
@@ -794,7 +794,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *pfLock)
794 stored_rc = CIFSSMBLock(xid, pTcon, 794 stored_rc = CIFSSMBLock(xid, pTcon,
795 netfid, 795 netfid,
796 li->length, li->offset, 796 li->length, li->offset,
797 1, 0, li->type, FALSE); 797 1, 0, li->type, false);
798 if (stored_rc) 798 if (stored_rc)
799 rc = stored_rc; 799 rc = stored_rc;
800 800
@@ -866,7 +866,7 @@ ssize_t cifs_user_write(struct file *file, const char __user *write_data,
866 filemap_fdatawait from here so tell 866 filemap_fdatawait from here so tell
867 reopen_file not to flush data to server 867 reopen_file not to flush data to server
868 now */ 868 now */
869 rc = cifs_reopen_file(file, FALSE); 869 rc = cifs_reopen_file(file, false);
870 if (rc != 0) 870 if (rc != 0)
871 break; 871 break;
872 } 872 }
@@ -966,7 +966,7 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
966 filemap_fdatawait from here so tell 966 filemap_fdatawait from here so tell
967 reopen_file not to flush data to 967 reopen_file not to flush data to
968 server now */ 968 server now */
969 rc = cifs_reopen_file(file, FALSE); 969 rc = cifs_reopen_file(file, false);
970 if (rc != 0) 970 if (rc != 0)
971 break; 971 break;
972 } 972 }
@@ -1093,7 +1093,7 @@ refind_writable:
1093 1093
1094 read_unlock(&GlobalSMBSeslock); 1094 read_unlock(&GlobalSMBSeslock);
1095 /* Had to unlock since following call can block */ 1095 /* Had to unlock since following call can block */
1096 rc = cifs_reopen_file(open_file->pfile, FALSE); 1096 rc = cifs_reopen_file(open_file->pfile, false);
1097 if (!rc) { 1097 if (!rc) {
1098 if (!open_file->closePend) 1098 if (!open_file->closePend)
1099 return open_file; 1099 return open_file;
@@ -1608,7 +1608,7 @@ ssize_t cifs_user_read(struct file *file, char __user *read_data,
1608 int buf_type = CIFS_NO_BUFFER; 1608 int buf_type = CIFS_NO_BUFFER;
1609 if ((open_file->invalidHandle) && 1609 if ((open_file->invalidHandle) &&
1610 (!open_file->closePend)) { 1610 (!open_file->closePend)) {
1611 rc = cifs_reopen_file(file, TRUE); 1611 rc = cifs_reopen_file(file, true);
1612 if (rc != 0) 1612 if (rc != 0)
1613 break; 1613 break;
1614 } 1614 }
@@ -1693,7 +1693,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
1693 while (rc == -EAGAIN) { 1693 while (rc == -EAGAIN) {
1694 if ((open_file->invalidHandle) && 1694 if ((open_file->invalidHandle) &&
1695 (!open_file->closePend)) { 1695 (!open_file->closePend)) {
1696 rc = cifs_reopen_file(file, TRUE); 1696 rc = cifs_reopen_file(file, true);
1697 if (rc != 0) 1697 if (rc != 0)
1698 break; 1698 break;
1699 } 1699 }
@@ -1850,7 +1850,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
1850 while (rc == -EAGAIN) { 1850 while (rc == -EAGAIN) {
1851 if ((open_file->invalidHandle) && 1851 if ((open_file->invalidHandle) &&
1852 (!open_file->closePend)) { 1852 (!open_file->closePend)) {
1853 rc = cifs_reopen_file(file, TRUE); 1853 rc = cifs_reopen_file(file, true);
1854 if (rc != 0) 1854 if (rc != 0)
1855 break; 1855 break;
1856 } 1856 }
@@ -2009,10 +2009,10 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)
2009 refreshing the inode only on increases in the file size 2009 refreshing the inode only on increases in the file size
2010 but this is tricky to do without racing with writebehind 2010 but this is tricky to do without racing with writebehind
2011 page caching in the current Linux kernel design */ 2011 page caching in the current Linux kernel design */
2012int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file) 2012bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
2013{ 2013{
2014 if (!cifsInode) 2014 if (!cifsInode)
2015 return 1; 2015 return true;
2016 2016
2017 if (is_inode_writable(cifsInode)) { 2017 if (is_inode_writable(cifsInode)) {
2018 /* This inode is open for write at least once */ 2018 /* This inode is open for write at least once */
@@ -2022,15 +2022,15 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
2022 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 2022 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
2023 /* since no page cache to corrupt on directio 2023 /* since no page cache to corrupt on directio
2024 we can change size safely */ 2024 we can change size safely */
2025 return 1; 2025 return true;
2026 } 2026 }
2027 2027
2028 if (i_size_read(&cifsInode->vfs_inode) < end_of_file) 2028 if (i_size_read(&cifsInode->vfs_inode) < end_of_file)
2029 return 1; 2029 return true;
2030 2030
2031 return 0; 2031 return false;
2032 } else 2032 } else
2033 return 1; 2033 return true;
2034} 2034}
2035 2035
2036static int cifs_prepare_write(struct file *file, struct page *page, 2036static int cifs_prepare_write(struct file *file, struct page *page,
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index e1031b9e2c55..fcbdbb6ad7bf 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -281,7 +281,7 @@ static int decode_sfu_inode(struct inode *inode, __u64 size,
281 struct cifs_sb_info *cifs_sb, int xid) 281 struct cifs_sb_info *cifs_sb, int xid)
282{ 282{
283 int rc; 283 int rc;
284 int oplock = FALSE; 284 int oplock = 0;
285 __u16 netfid; 285 __u16 netfid;
286 struct cifsTconInfo *pTcon = cifs_sb->tcon; 286 struct cifsTconInfo *pTcon = cifs_sb->tcon;
287 char buf[24]; 287 char buf[24];
@@ -389,7 +389,7 @@ int cifs_get_inode_info(struct inode **pinode,
389 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 389 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
390 const unsigned char *full_path = NULL; 390 const unsigned char *full_path = NULL;
391 char *buf = NULL; 391 char *buf = NULL;
392 int adjustTZ = FALSE; 392 bool adjustTZ = false;
393 bool is_dfs_referral = false; 393 bool is_dfs_referral = false;
394 394
395 pTcon = cifs_sb->tcon; 395 pTcon = cifs_sb->tcon;
@@ -425,7 +425,7 @@ try_again_CIFSSMBQPathInfo:
425 pfindData, cifs_sb->local_nls, 425 pfindData, cifs_sb->local_nls,
426 cifs_sb->mnt_cifs_flags & 426 cifs_sb->mnt_cifs_flags &
427 CIFS_MOUNT_MAP_SPECIAL_CHR); 427 CIFS_MOUNT_MAP_SPECIAL_CHR);
428 adjustTZ = TRUE; 428 adjustTZ = true;
429 } 429 }
430 } 430 }
431 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */ 431 /* dump_mem("\nQPathInfo return data",&findData, sizeof(findData)); */
@@ -703,7 +703,7 @@ psx_del_no_retry:
703 } else if (rc == -ENOENT) { 703 } else if (rc == -ENOENT) {
704 d_drop(direntry); 704 d_drop(direntry);
705 } else if (rc == -ETXTBSY) { 705 } else if (rc == -ETXTBSY) {
706 int oplock = FALSE; 706 int oplock = 0;
707 __u16 netfid; 707 __u16 netfid;
708 708
709 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE, 709 rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, DELETE,
@@ -736,7 +736,7 @@ psx_del_no_retry:
736 rc = -EOPNOTSUPP; 736 rc = -EOPNOTSUPP;
737 737
738 if (rc == -EOPNOTSUPP) { 738 if (rc == -EOPNOTSUPP) {
739 int oplock = FALSE; 739 int oplock = 0;
740 __u16 netfid; 740 __u16 netfid;
741 /* rc = CIFSSMBSetAttrLegacy(xid, pTcon, 741 /* rc = CIFSSMBSetAttrLegacy(xid, pTcon,
742 full_path, 742 full_path,
@@ -774,7 +774,7 @@ psx_del_no_retry:
774 if (direntry->d_inode) 774 if (direntry->d_inode)
775 drop_nlink(direntry->d_inode); 775 drop_nlink(direntry->d_inode);
776 } else if (rc == -ETXTBSY) { 776 } else if (rc == -ETXTBSY) {
777 int oplock = FALSE; 777 int oplock = 0;
778 __u16 netfid; 778 __u16 netfid;
779 779
780 rc = CIFSSMBOpen(xid, pTcon, full_path, 780 rc = CIFSSMBOpen(xid, pTcon, full_path,
@@ -974,8 +974,8 @@ mkdir_get_info:
974 * failed to get it from the server or was set bogus */ 974 * failed to get it from the server or was set bogus */
975 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2)) 975 if ((direntry->d_inode) && (direntry->d_inode->i_nlink < 2))
976 direntry->d_inode->i_nlink = 2; 976 direntry->d_inode->i_nlink = 2;
977 mode &= ~current->fs->umask;
977 if (pTcon->unix_ext) { 978 if (pTcon->unix_ext) {
978 mode &= ~current->fs->umask;
979 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 979 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
980 CIFSSMBUnixSetPerms(xid, pTcon, full_path, 980 CIFSSMBUnixSetPerms(xid, pTcon, full_path,
981 mode, 981 mode,
@@ -994,9 +994,16 @@ mkdir_get_info:
994 CIFS_MOUNT_MAP_SPECIAL_CHR); 994 CIFS_MOUNT_MAP_SPECIAL_CHR);
995 } 995 }
996 } else { 996 } else {
997 /* BB to be implemented via Windows secrty descriptors 997 if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
998 eg CIFSSMBWinSetPerms(xid, pTcon, full_path, mode, 998 (mode & S_IWUGO) == 0) {
999 -1, -1, local_nls); */ 999 FILE_BASIC_INFO pInfo;
1000 memset(&pInfo, 0, sizeof(pInfo));
1001 pInfo.Attributes = cpu_to_le32(ATTR_READONLY);
1002 CIFSSMBSetTimes(xid, pTcon, full_path,
1003 &pInfo, cifs_sb->local_nls,
1004 cifs_sb->mnt_cifs_flags &
1005 CIFS_MOUNT_MAP_SPECIAL_CHR);
1006 }
1000 if (direntry->d_inode) { 1007 if (direntry->d_inode) {
1001 direntry->d_inode->i_mode = mode; 1008 direntry->d_inode->i_mode = mode;
1002 direntry->d_inode->i_mode |= S_IFDIR; 1009 direntry->d_inode->i_mode |= S_IFDIR;
@@ -1149,7 +1156,7 @@ int cifs_rename(struct inode *source_inode, struct dentry *source_direntry,
1149 cFYI(1, ("rename rc %d", rc)); 1156 cFYI(1, ("rename rc %d", rc));
1150 1157
1151 if ((rc == -EIO) || (rc == -EEXIST)) { 1158 if ((rc == -EIO) || (rc == -EEXIST)) {
1152 int oplock = FALSE; 1159 int oplock = 0;
1153 __u16 netfid; 1160 __u16 netfid;
1154 1161
1155 /* BB FIXME Is Generic Read correct for rename? */ 1162 /* BB FIXME Is Generic Read correct for rename? */
@@ -1186,7 +1193,7 @@ int cifs_revalidate(struct dentry *direntry)
1186 struct cifsInodeInfo *cifsInode; 1193 struct cifsInodeInfo *cifsInode;
1187 loff_t local_size; 1194 loff_t local_size;
1188 struct timespec local_mtime; 1195 struct timespec local_mtime;
1189 int invalidate_inode = FALSE; 1196 bool invalidate_inode = false;
1190 1197
1191 if (direntry->d_inode == NULL) 1198 if (direntry->d_inode == NULL)
1192 return -ENOENT; 1199 return -ENOENT;
@@ -1268,7 +1275,7 @@ int cifs_revalidate(struct dentry *direntry)
1268 only ones who could have modified the file and the 1275 only ones who could have modified the file and the
1269 server copy is staler than ours */ 1276 server copy is staler than ours */
1270 } else { 1277 } else {
1271 invalidate_inode = TRUE; 1278 invalidate_inode = true;
1272 } 1279 }
1273 } 1280 }
1274 1281
@@ -1402,24 +1409,25 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1402 int rc = -EACCES; 1409 int rc = -EACCES;
1403 struct cifsFileInfo *open_file = NULL; 1410 struct cifsFileInfo *open_file = NULL;
1404 FILE_BASIC_INFO time_buf; 1411 FILE_BASIC_INFO time_buf;
1405 int set_time = FALSE; 1412 bool set_time = false;
1406 int set_dosattr = FALSE; 1413 bool set_dosattr = false;
1407 __u64 mode = 0xFFFFFFFFFFFFFFFFULL; 1414 __u64 mode = 0xFFFFFFFFFFFFFFFFULL;
1408 __u64 uid = 0xFFFFFFFFFFFFFFFFULL; 1415 __u64 uid = 0xFFFFFFFFFFFFFFFFULL;
1409 __u64 gid = 0xFFFFFFFFFFFFFFFFULL; 1416 __u64 gid = 0xFFFFFFFFFFFFFFFFULL;
1410 struct cifsInodeInfo *cifsInode; 1417 struct cifsInodeInfo *cifsInode;
1418 struct inode *inode = direntry->d_inode;
1411 1419
1412 xid = GetXid(); 1420 xid = GetXid();
1413 1421
1414 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x", 1422 cFYI(1, ("setattr on file %s attrs->iavalid 0x%x",
1415 direntry->d_name.name, attrs->ia_valid)); 1423 direntry->d_name.name, attrs->ia_valid));
1416 1424
1417 cifs_sb = CIFS_SB(direntry->d_inode->i_sb); 1425 cifs_sb = CIFS_SB(inode->i_sb);
1418 pTcon = cifs_sb->tcon; 1426 pTcon = cifs_sb->tcon;
1419 1427
1420 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) { 1428 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) == 0) {
1421 /* check if we have permission to change attrs */ 1429 /* check if we have permission to change attrs */
1422 rc = inode_change_ok(direntry->d_inode, attrs); 1430 rc = inode_change_ok(inode, attrs);
1423 if (rc < 0) { 1431 if (rc < 0) {
1424 FreeXid(xid); 1432 FreeXid(xid);
1425 return rc; 1433 return rc;
@@ -1432,7 +1440,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1432 FreeXid(xid); 1440 FreeXid(xid);
1433 return -ENOMEM; 1441 return -ENOMEM;
1434 } 1442 }
1435 cifsInode = CIFS_I(direntry->d_inode); 1443 cifsInode = CIFS_I(inode);
1436 1444
1437 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) { 1445 if ((attrs->ia_valid & ATTR_MTIME) || (attrs->ia_valid & ATTR_SIZE)) {
1438 /* 1446 /*
@@ -1443,9 +1451,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1443 will be truncated anyway? Also, should we error out here if 1451 will be truncated anyway? Also, should we error out here if
1444 the flush returns error? 1452 the flush returns error?
1445 */ 1453 */
1446 rc = filemap_write_and_wait(direntry->d_inode->i_mapping); 1454 rc = filemap_write_and_wait(inode->i_mapping);
1447 if (rc != 0) { 1455 if (rc != 0) {
1448 CIFS_I(direntry->d_inode)->write_behind_rc = rc; 1456 cifsInode->write_behind_rc = rc;
1449 rc = 0; 1457 rc = 0;
1450 } 1458 }
1451 } 1459 }
@@ -1464,7 +1472,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1464 __u16 nfid = open_file->netfid; 1472 __u16 nfid = open_file->netfid;
1465 __u32 npid = open_file->pid; 1473 __u32 npid = open_file->pid;
1466 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size, 1474 rc = CIFSSMBSetFileSize(xid, pTcon, attrs->ia_size,
1467 nfid, npid, FALSE); 1475 nfid, npid, false);
1468 atomic_dec(&open_file->wrtPending); 1476 atomic_dec(&open_file->wrtPending);
1469 cFYI(1, ("SetFSize for attrs rc = %d", rc)); 1477 cFYI(1, ("SetFSize for attrs rc = %d", rc));
1470 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1478 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
@@ -1484,14 +1492,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1484 it was found or because there was an error setting 1492 it was found or because there was an error setting
1485 it by handle */ 1493 it by handle */
1486 rc = CIFSSMBSetEOF(xid, pTcon, full_path, 1494 rc = CIFSSMBSetEOF(xid, pTcon, full_path,
1487 attrs->ia_size, FALSE, 1495 attrs->ia_size, false,
1488 cifs_sb->local_nls, 1496 cifs_sb->local_nls,
1489 cifs_sb->mnt_cifs_flags & 1497 cifs_sb->mnt_cifs_flags &
1490 CIFS_MOUNT_MAP_SPECIAL_CHR); 1498 CIFS_MOUNT_MAP_SPECIAL_CHR);
1491 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc)); 1499 cFYI(1, ("SetEOF by path (setattrs) rc = %d", rc));
1492 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) { 1500 if ((rc == -EINVAL) || (rc == -EOPNOTSUPP)) {
1493 __u16 netfid; 1501 __u16 netfid;
1494 int oplock = FALSE; 1502 int oplock = 0;
1495 1503
1496 rc = SMBLegacyOpen(xid, pTcon, full_path, 1504 rc = SMBLegacyOpen(xid, pTcon, full_path,
1497 FILE_OPEN, 1505 FILE_OPEN,
@@ -1516,14 +1524,13 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1516 1524
1517 /* Server is ok setting allocation size implicitly - no need 1525 /* Server is ok setting allocation size implicitly - no need
1518 to call: 1526 to call:
1519 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, TRUE, 1527 CIFSSMBSetEOF(xid, pTcon, full_path, attrs->ia_size, true,
1520 cifs_sb->local_nls); 1528 cifs_sb->local_nls);
1521 */ 1529 */
1522 1530
1523 if (rc == 0) { 1531 if (rc == 0) {
1524 rc = cifs_vmtruncate(direntry->d_inode, attrs->ia_size); 1532 rc = cifs_vmtruncate(inode, attrs->ia_size);
1525 cifs_truncate_page(direntry->d_inode->i_mapping, 1533 cifs_truncate_page(inode->i_mapping, inode->i_size);
1526 direntry->d_inode->i_size);
1527 } else 1534 } else
1528 goto cifs_setattr_exit; 1535 goto cifs_setattr_exit;
1529 } 1536 }
@@ -1557,14 +1564,14 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1557 rc = 0; 1564 rc = 0;
1558#ifdef CONFIG_CIFS_EXPERIMENTAL 1565#ifdef CONFIG_CIFS_EXPERIMENTAL
1559 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 1566 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
1560 rc = mode_to_acl(direntry->d_inode, full_path, mode); 1567 rc = mode_to_acl(inode, full_path, mode);
1561 else if ((mode & S_IWUGO) == 0) { 1568 else if ((mode & S_IWUGO) == 0) {
1562#else 1569#else
1563 if ((mode & S_IWUGO) == 0) { 1570 if ((mode & S_IWUGO) == 0) {
1564#endif 1571#endif
1565 /* not writeable */ 1572 /* not writeable */
1566 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) { 1573 if ((cifsInode->cifsAttrs & ATTR_READONLY) == 0) {
1567 set_dosattr = TRUE; 1574 set_dosattr = true;
1568 time_buf.Attributes = 1575 time_buf.Attributes =
1569 cpu_to_le32(cifsInode->cifsAttrs | 1576 cpu_to_le32(cifsInode->cifsAttrs |
1570 ATTR_READONLY); 1577 ATTR_READONLY);
@@ -1574,28 +1581,24 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1574 not be able to write to it - so if any write 1581 not be able to write to it - so if any write
1575 bit is enabled for user or group or other we 1582 bit is enabled for user or group or other we
1576 need to at least try to remove r/o dos attr */ 1583 need to at least try to remove r/o dos attr */
1577 set_dosattr = TRUE; 1584 set_dosattr = true;
1578 time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs & 1585 time_buf.Attributes = cpu_to_le32(cifsInode->cifsAttrs &
1579 (~ATTR_READONLY)); 1586 (~ATTR_READONLY));
1580 /* Windows ignores set to zero */ 1587 /* Windows ignores set to zero */
1581 if (time_buf.Attributes == 0) 1588 if (time_buf.Attributes == 0)
1582 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL); 1589 time_buf.Attributes |= cpu_to_le32(ATTR_NORMAL);
1583 } 1590 }
1584#ifdef CONFIG_CIFS_EXPERIMENTAL
1585 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
1586 mode_to_acl(direntry->d_inode, full_path, mode);
1587#endif
1588 } 1591 }
1589 1592
1590 if (attrs->ia_valid & ATTR_ATIME) { 1593 if (attrs->ia_valid & ATTR_ATIME) {
1591 set_time = TRUE; 1594 set_time = true;
1592 time_buf.LastAccessTime = 1595 time_buf.LastAccessTime =
1593 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime)); 1596 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));
1594 } else 1597 } else
1595 time_buf.LastAccessTime = 0; 1598 time_buf.LastAccessTime = 0;
1596 1599
1597 if (attrs->ia_valid & ATTR_MTIME) { 1600 if (attrs->ia_valid & ATTR_MTIME) {
1598 set_time = TRUE; 1601 set_time = true;
1599 time_buf.LastWriteTime = 1602 time_buf.LastWriteTime =
1600 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime)); 1603 cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));
1601 } else 1604 } else
@@ -1606,7 +1609,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1606 server times */ 1609 server times */
1607 1610
1608 if (set_time && (attrs->ia_valid & ATTR_CTIME)) { 1611 if (set_time && (attrs->ia_valid & ATTR_CTIME)) {
1609 set_time = TRUE; 1612 set_time = true;
1610 /* Although Samba throws this field away 1613 /* Although Samba throws this field away
1611 it may be useful to Windows - but we do 1614 it may be useful to Windows - but we do
1612 not want to set ctime unless some other 1615 not want to set ctime unless some other
@@ -1630,7 +1633,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1630 rc = -EOPNOTSUPP; 1633 rc = -EOPNOTSUPP;
1631 1634
1632 if (rc == -EOPNOTSUPP) { 1635 if (rc == -EOPNOTSUPP) {
1633 int oplock = FALSE; 1636 int oplock = 0;
1634 __u16 netfid; 1637 __u16 netfid;
1635 1638
1636 cFYI(1, ("calling SetFileInfo since SetPathInfo for " 1639 cFYI(1, ("calling SetFileInfo since SetPathInfo for "
@@ -1669,7 +1672,7 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
1669 /* do not need local check to inode_check_ok since the server does 1672 /* do not need local check to inode_check_ok since the server does
1670 that */ 1673 that */
1671 if (!rc) 1674 if (!rc)
1672 rc = inode_setattr(direntry->d_inode, attrs); 1675 rc = inode_setattr(inode, attrs);
1673cifs_setattr_exit: 1676cifs_setattr_exit:
1674 kfree(full_path); 1677 kfree(full_path);
1675 FreeXid(xid); 1678 FreeXid(xid);
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index d4e7ec93285f..1c2c3ce5020b 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -230,7 +230,7 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
230 struct inode *inode = direntry->d_inode; 230 struct inode *inode = direntry->d_inode;
231 int rc = -EACCES; 231 int rc = -EACCES;
232 int xid; 232 int xid;
233 int oplock = FALSE; 233 int oplock = 0;
234 struct cifs_sb_info *cifs_sb; 234 struct cifs_sb_info *cifs_sb;
235 struct cifsTconInfo *pTcon; 235 struct cifsTconInfo *pTcon;
236 char *full_path = NULL; 236 char *full_path = NULL;
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index 2a42d9fedbb2..1d69b8014e0b 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -496,7 +496,8 @@ checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length)
496 } 496 }
497 return 0; 497 return 0;
498} 498}
499int 499
500bool
500is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv) 501is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
501{ 502{
502 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf; 503 struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
@@ -522,17 +523,17 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
522 pnotify->Action)); /* BB removeme BB */ 523 pnotify->Action)); /* BB removeme BB */
523 /* cifs_dump_mem("Rcvd notify Data: ",buf, 524 /* cifs_dump_mem("Rcvd notify Data: ",buf,
524 sizeof(struct smb_hdr)+60); */ 525 sizeof(struct smb_hdr)+60); */
525 return TRUE; 526 return true;
526 } 527 }
527 if (pSMBr->hdr.Status.CifsError) { 528 if (pSMBr->hdr.Status.CifsError) {
528 cFYI(1, ("notify err 0x%d", 529 cFYI(1, ("notify err 0x%d",
529 pSMBr->hdr.Status.CifsError)); 530 pSMBr->hdr.Status.CifsError));
530 return TRUE; 531 return true;
531 } 532 }
532 return FALSE; 533 return false;
533 } 534 }
534 if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX) 535 if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
535 return FALSE; 536 return false;
536 if (pSMB->hdr.Flags & SMBFLG_RESPONSE) { 537 if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
537 /* no sense logging error on invalid handle on oplock 538 /* no sense logging error on invalid handle on oplock
538 break - harmless race between close request and oplock 539 break - harmless race between close request and oplock
@@ -541,21 +542,21 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
541 if ((NT_STATUS_INVALID_HANDLE) == 542 if ((NT_STATUS_INVALID_HANDLE) ==
542 le32_to_cpu(pSMB->hdr.Status.CifsError)) { 543 le32_to_cpu(pSMB->hdr.Status.CifsError)) {
543 cFYI(1, ("invalid handle on oplock break")); 544 cFYI(1, ("invalid handle on oplock break"));
544 return TRUE; 545 return true;
545 } else if (ERRbadfid == 546 } else if (ERRbadfid ==
546 le16_to_cpu(pSMB->hdr.Status.DosError.Error)) { 547 le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
547 return TRUE; 548 return true;
548 } else { 549 } else {
549 return FALSE; /* on valid oplock brk we get "request" */ 550 return false; /* on valid oplock brk we get "request" */
550 } 551 }
551 } 552 }
552 if (pSMB->hdr.WordCount != 8) 553 if (pSMB->hdr.WordCount != 8)
553 return FALSE; 554 return false;
554 555
555 cFYI(1, ("oplock type 0x%d level 0x%d", 556 cFYI(1, ("oplock type 0x%d level 0x%d",
556 pSMB->LockType, pSMB->OplockLevel)); 557 pSMB->LockType, pSMB->OplockLevel));
557 if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)) 558 if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
558 return FALSE; 559 return false;
559 560
560 /* look up tcon based on tid & uid */ 561 /* look up tcon based on tid & uid */
561 read_lock(&GlobalSMBSeslock); 562 read_lock(&GlobalSMBSeslock);
@@ -573,11 +574,11 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
573 ("file id match, oplock break")); 574 ("file id match, oplock break"));
574 pCifsInode = 575 pCifsInode =
575 CIFS_I(netfile->pInode); 576 CIFS_I(netfile->pInode);
576 pCifsInode->clientCanCacheAll = FALSE; 577 pCifsInode->clientCanCacheAll = false;
577 if (pSMB->OplockLevel == 0) 578 if (pSMB->OplockLevel == 0)
578 pCifsInode->clientCanCacheRead 579 pCifsInode->clientCanCacheRead
579 = FALSE; 580 = false;
580 pCifsInode->oplockPending = TRUE; 581 pCifsInode->oplockPending = true;
581 AllocOplockQEntry(netfile->pInode, 582 AllocOplockQEntry(netfile->pInode,
582 netfile->netfid, 583 netfile->netfid,
583 tcon); 584 tcon);
@@ -585,17 +586,17 @@ is_valid_oplock_break(struct smb_hdr *buf, struct TCP_Server_Info *srv)
585 ("about to wake up oplock thread")); 586 ("about to wake up oplock thread"));
586 if (oplockThread) 587 if (oplockThread)
587 wake_up_process(oplockThread); 588 wake_up_process(oplockThread);
588 return TRUE; 589 return true;
589 } 590 }
590 } 591 }
591 read_unlock(&GlobalSMBSeslock); 592 read_unlock(&GlobalSMBSeslock);
592 cFYI(1, ("No matching file for oplock break")); 593 cFYI(1, ("No matching file for oplock break"));
593 return TRUE; 594 return true;
594 } 595 }
595 } 596 }
596 read_unlock(&GlobalSMBSeslock); 597 read_unlock(&GlobalSMBSeslock);
597 cFYI(1, ("Can not process oplock break for non-existent connection")); 598 cFYI(1, ("Can not process oplock break for non-existent connection"));
598 return TRUE; 599 return true;
599} 600}
600 601
601void 602void
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index 3b5a5ce882b6..00f4cff400b3 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -132,47 +132,17 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
132 {0, 0} 132 {0, 0}
133}; 133};
134 134
135
136/* if the mount helper is missing we need to reverse the 1st slash
137 from '/' to backslash in order to format the UNC properly for
138 ip address parsing and for tree connect (unless the user
139 remembered to put the UNC name in properly). Fortunately we do
140 not have to call this twice (we check for IPv4 addresses
141 first, so it is already converted by the time we
142 try IPv6 addresses */
143static int canonicalize_unc(char *cp)
144{
145 int i;
146
147 for (i = 0; i <= 46 /* INET6_ADDRSTRLEN */ ; i++) {
148 if (cp[i] == 0)
149 break;
150 if (cp[i] == '\\')
151 break;
152 if (cp[i] == '/') {
153 cFYI(DBG2, ("change slash to \\ in malformed UNC"));
154 cp[i] = '\\';
155 return 1;
156 }
157 }
158 return 0;
159}
160
161/* Convert string containing dotted ip address to binary form */ 135/* Convert string containing dotted ip address to binary form */
162/* returns 0 if invalid address */ 136/* returns 0 if invalid address */
163 137
164int 138int
165cifs_inet_pton(int address_family, char *cp, void *dst) 139cifs_inet_pton(const int address_family, const char *cp, void *dst)
166{ 140{
167 int ret = 0; 141 int ret = 0;
168 142
169 /* calculate length by finding first slash or NULL */ 143 /* calculate length by finding first slash or NULL */
170 if (address_family == AF_INET) { 144 if (address_family == AF_INET) {
171 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL); 145 ret = in4_pton(cp, -1 /* len */, dst, '\\', NULL);
172 if (ret == 0) {
173 if (canonicalize_unc(cp))
174 ret = in4_pton(cp, -1, dst, '\\', NULL);
175 }
176 } else if (address_family == AF_INET6) { 146 } else if (address_family == AF_INET6) {
177 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL); 147 ret = in6_pton(cp, -1 /* len */, dst , '\\', NULL);
178 } 148 }
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 32b445edc882..34ec32100c72 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -447,8 +447,8 @@ static int initiate_cifs_search(const int xid, struct file *file)
447 if (file->private_data == NULL) 447 if (file->private_data == NULL)
448 return -ENOMEM; 448 return -ENOMEM;
449 cifsFile = file->private_data; 449 cifsFile = file->private_data;
450 cifsFile->invalidHandle = TRUE; 450 cifsFile->invalidHandle = true;
451 cifsFile->srch_inf.endOfSearch = FALSE; 451 cifsFile->srch_inf.endOfSearch = false;
452 452
453 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 453 cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
454 if (cifs_sb == NULL) 454 if (cifs_sb == NULL)
@@ -485,7 +485,7 @@ ffirst_retry:
485 cifs_sb->mnt_cifs_flags & 485 cifs_sb->mnt_cifs_flags &
486 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); 486 CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
487 if (rc == 0) 487 if (rc == 0)
488 cifsFile->invalidHandle = FALSE; 488 cifsFile->invalidHandle = false;
489 if ((rc == -EOPNOTSUPP) && 489 if ((rc == -EOPNOTSUPP) &&
490 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 490 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
491 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 491 cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
@@ -670,7 +670,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
670 (index_to_find < first_entry_in_buffer)) { 670 (index_to_find < first_entry_in_buffer)) {
671 /* close and restart search */ 671 /* close and restart search */
672 cFYI(1, ("search backing up - close and restart search")); 672 cFYI(1, ("search backing up - close and restart search"));
673 cifsFile->invalidHandle = TRUE; 673 cifsFile->invalidHandle = true;
674 CIFSFindClose(xid, pTcon, cifsFile->netfid); 674 CIFSFindClose(xid, pTcon, cifsFile->netfid);
675 kfree(cifsFile->search_resume_name); 675 kfree(cifsFile->search_resume_name);
676 cifsFile->search_resume_name = NULL; 676 cifsFile->search_resume_name = NULL;
@@ -692,7 +692,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
692 } 692 }
693 693
694 while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) && 694 while ((index_to_find >= cifsFile->srch_inf.index_of_last_entry) &&
695 (rc == 0) && (cifsFile->srch_inf.endOfSearch == FALSE)) { 695 (rc == 0) && !cifsFile->srch_inf.endOfSearch) {
696 cFYI(1, ("calling findnext2")); 696 cFYI(1, ("calling findnext2"));
697 rc = CIFSFindNext(xid, pTcon, cifsFile->netfid, 697 rc = CIFSFindNext(xid, pTcon, cifsFile->netfid,
698 &cifsFile->srch_inf); 698 &cifsFile->srch_inf);
@@ -1038,7 +1038,7 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
1038 break; 1038 break;
1039 } 1039 }
1040 } /* else { 1040 } /* else {
1041 cifsFile->invalidHandle = TRUE; 1041 cifsFile->invalidHandle = true;
1042 CIFSFindClose(xid, pTcon, cifsFile->netfid); 1042 CIFSFindClose(xid, pTcon, cifsFile->netfid);
1043 } 1043 }
1044 kfree(cifsFile->search_resume_name); 1044 kfree(cifsFile->search_resume_name);
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c
index 58bbfd992cc0..ff3232fa1015 100644
--- a/fs/cifs/smbencrypt.c
+++ b/fs/cifs/smbencrypt.c
@@ -35,11 +35,11 @@
35#include "cifs_debug.h" 35#include "cifs_debug.h"
36#include "cifsencrypt.h" 36#include "cifsencrypt.h"
37 37
38#ifndef FALSE 38#ifndef false
39#define FALSE 0 39#define false 0
40#endif 40#endif
41#ifndef TRUE 41#ifndef true
42#define TRUE 1 42#define true 1
43#endif 43#endif
44 44
45/* following came from the other byteorder.h to avoid include conflicts */ 45/* following came from the other byteorder.h to avoid include conflicts */
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 8cd6a445b017..e9527eedc639 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -264,7 +264,7 @@ ssize_t cifs_getxattr(struct dentry *direntry, const char *ea_name,
264#ifdef CONFIG_CIFS_EXPERIMENTAL 264#ifdef CONFIG_CIFS_EXPERIMENTAL
265 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 265 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
266 __u16 fid; 266 __u16 fid;
267 int oplock = FALSE; 267 int oplock = 0;
268 struct cifs_ntsd *pacl = NULL; 268 struct cifs_ntsd *pacl = NULL;
269 __u32 buflen = 0; 269 __u32 buflen = 0;
270 if (experimEnabled) 270 if (experimEnabled)
diff --git a/fs/dquot.c b/fs/dquot.c
index dfba1623cccb..5ac77da19959 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1491,6 +1491,16 @@ int vfs_quota_off(struct super_block *sb, int type, int remount)
1491 1491
1492 /* We need to serialize quota_off() for device */ 1492 /* We need to serialize quota_off() for device */
1493 mutex_lock(&dqopt->dqonoff_mutex); 1493 mutex_lock(&dqopt->dqonoff_mutex);
1494
1495 /*
1496 * Skip everything if there's nothing to do. We have to do this because
1497 * sometimes we are called when fill_super() failed and calling
1498 * sync_fs() in such cases does no good.
1499 */
1500 if (!sb_any_quota_enabled(sb) && !sb_any_quota_suspended(sb)) {
1501 mutex_unlock(&dqopt->dqonoff_mutex);
1502 return 0;
1503 }
1494 for (cnt = 0; cnt < MAXQUOTAS; cnt++) { 1504 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1495 toputinode[cnt] = NULL; 1505 toputinode[cnt] = NULL;
1496 if (type != -1 && cnt != type) 1506 if (type != -1 && cnt != type)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 0a1397335a8e..c92cc1c00aae 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -37,17 +37,11 @@ static struct dentry *lock_parent(struct dentry *dentry)
37{ 37{
38 struct dentry *dir; 38 struct dentry *dir;
39 39
40 dir = dget(dentry->d_parent); 40 dir = dget_parent(dentry);
41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT); 41 mutex_lock_nested(&(dir->d_inode->i_mutex), I_MUTEX_PARENT);
42 return dir; 42 return dir;
43} 43}
44 44
45static void unlock_parent(struct dentry *dentry)
46{
47 mutex_unlock(&(dentry->d_parent->d_inode->i_mutex));
48 dput(dentry->d_parent);
49}
50
51static void unlock_dir(struct dentry *dir) 45static void unlock_dir(struct dentry *dir)
52{ 46{
53 mutex_unlock(&dir->d_inode->i_mutex); 47 mutex_unlock(&dir->d_inode->i_mutex);
@@ -426,8 +420,9 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
426 int rc = 0; 420 int rc = 0;
427 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 421 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
428 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir); 422 struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
423 struct dentry *lower_dir_dentry;
429 424
430 lock_parent(lower_dentry); 425 lower_dir_dentry = lock_parent(lower_dentry);
431 rc = vfs_unlink(lower_dir_inode, lower_dentry); 426 rc = vfs_unlink(lower_dir_inode, lower_dentry);
432 if (rc) { 427 if (rc) {
433 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc); 428 printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
@@ -439,7 +434,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
439 dentry->d_inode->i_ctime = dir->i_ctime; 434 dentry->d_inode->i_ctime = dir->i_ctime;
440 d_drop(dentry); 435 d_drop(dentry);
441out_unlock: 436out_unlock:
442 unlock_parent(lower_dentry); 437 unlock_dir(lower_dir_dentry);
443 return rc; 438 return rc;
444} 439}
445 440
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
index 788995efd1d3..6560da1a58ce 100644
--- a/fs/ecryptfs/miscdev.c
+++ b/fs/ecryptfs/miscdev.c
@@ -257,12 +257,14 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count,
257 mutex_lock(&daemon->mux); 257 mutex_lock(&daemon->mux);
258 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { 258 if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) {
259 rc = 0; 259 rc = 0;
260 mutex_unlock(&ecryptfs_daemon_hash_mux);
260 printk(KERN_WARNING "%s: Attempt to read from zombified " 261 printk(KERN_WARNING "%s: Attempt to read from zombified "
261 "daemon\n", __func__); 262 "daemon\n", __func__);
262 goto out_unlock_daemon; 263 goto out_unlock_daemon;
263 } 264 }
264 if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { 265 if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) {
265 rc = 0; 266 rc = 0;
267 mutex_unlock(&ecryptfs_daemon_hash_mux);
266 goto out_unlock_daemon; 268 goto out_unlock_daemon;
267 } 269 }
268 /* This daemon will not go away so long as this flag is set */ 270 /* This daemon will not go away so long as this flag is set */
diff --git a/fs/exec.c b/fs/exec.c
index aeaa9791d8be..1f8a24aa1f8b 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -736,7 +736,7 @@ static int exec_mmap(struct mm_struct *mm)
736 tsk->active_mm = mm; 736 tsk->active_mm = mm;
737 activate_mm(active_mm, mm); 737 activate_mm(active_mm, mm);
738 task_unlock(tsk); 738 task_unlock(tsk);
739 mm_update_next_owner(mm); 739 mm_update_next_owner(old_mm);
740 arch_pick_mmap_layout(mm); 740 arch_pick_mmap_layout(mm);
741 if (old_mm) { 741 if (old_mm) {
742 up_read(&old_mm->mmap_sem); 742 up_read(&old_mm->mmap_sem);
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index d4a4f0e9ff69..175414ac2210 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -1000,6 +1000,11 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
1000 i.value = NULL; 1000 i.value = NULL;
1001 error = ext3_xattr_block_set(handle, inode, &i, &bs); 1001 error = ext3_xattr_block_set(handle, inode, &i, &bs);
1002 } else if (error == -ENOSPC) { 1002 } else if (error == -ENOSPC) {
1003 if (EXT3_I(inode)->i_file_acl && !bs.s.base) {
1004 error = ext3_xattr_block_find(inode, &i, &bs);
1005 if (error)
1006 goto cleanup;
1007 }
1003 error = ext3_xattr_block_set(handle, inode, &i, &bs); 1008 error = ext3_xattr_block_set(handle, inode, &i, &bs);
1004 if (error) 1009 if (error)
1005 goto cleanup; 1010 goto cleanup;
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index fbec2ef93797..b128bdc0f55c 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2639,8 +2639,7 @@ static int ext4_mb_init_per_dev_proc(struct super_block *sb)
2639 struct proc_dir_entry *proc; 2639 struct proc_dir_entry *proc;
2640 char devname[64]; 2640 char devname[64];
2641 2641
2642 snprintf(devname, sizeof(devname) - 1, "%s", 2642 bdevname(sb->s_bdev, devname);
2643 bdevname(sb->s_bdev, devname));
2644 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4); 2643 sbi->s_mb_proc = proc_mkdir(devname, proc_root_ext4);
2645 2644
2646 MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats); 2645 MB_PROC_HANDLER(EXT4_MB_STATS_NAME, stats);
@@ -2674,8 +2673,7 @@ static int ext4_mb_destroy_per_dev_proc(struct super_block *sb)
2674 if (sbi->s_mb_proc == NULL) 2673 if (sbi->s_mb_proc == NULL)
2675 return -EINVAL; 2674 return -EINVAL;
2676 2675
2677 snprintf(devname, sizeof(devname) - 1, "%s", 2676 bdevname(sb->s_bdev, devname);
2678 bdevname(sb->s_bdev, devname));
2679 remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc); 2677 remove_proc_entry(EXT4_MB_GROUP_PREALLOC, sbi->s_mb_proc);
2680 remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc); 2678 remove_proc_entry(EXT4_MB_STREAM_REQ, sbi->s_mb_proc);
2681 remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc); 2679 remove_proc_entry(EXT4_MB_ORDER2_REQ, sbi->s_mb_proc);
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 3fbc2c6c3d0e..ff08633f398e 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1009,6 +1009,11 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,
1009 i.value = NULL; 1009 i.value = NULL;
1010 error = ext4_xattr_block_set(handle, inode, &i, &bs); 1010 error = ext4_xattr_block_set(handle, inode, &i, &bs);
1011 } else if (error == -ENOSPC) { 1011 } else if (error == -ENOSPC) {
1012 if (EXT4_I(inode)->i_file_acl && !bs.s.base) {
1013 error = ext4_xattr_block_find(inode, &i, &bs);
1014 if (error)
1015 goto cleanup;
1016 }
1012 error = ext4_xattr_block_set(handle, inode, &i, &bs); 1017 error = ext4_xattr_block_set(handle, inode, &i, &bs);
1013 if (error) 1018 if (error)
1014 goto cleanup; 1019 goto cleanup;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f28cf8b46f80..8092f0d9fd1f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -804,6 +804,8 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req,
804 if (offset == PAGE_CACHE_SIZE) 804 if (offset == PAGE_CACHE_SIZE)
805 offset = 0; 805 offset = 0;
806 806
807 if (!fc->big_writes)
808 break;
807 } while (iov_iter_count(ii) && count < fc->max_write && 809 } while (iov_iter_count(ii) && count < fc->max_write &&
808 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0); 810 req->num_pages < FUSE_MAX_PAGES_PER_REQ && offset == 0);
809 811
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index dadffa21a206..bae948657c4f 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -404,6 +404,9 @@ struct fuse_conn {
404 /** Is bmap not implemented by fs? */ 404 /** Is bmap not implemented by fs? */
405 unsigned no_bmap : 1; 405 unsigned no_bmap : 1;
406 406
407 /** Do multi-page cached writes */
408 unsigned big_writes : 1;
409
407 /** The number of requests waiting for completion */ 410 /** The number of requests waiting for completion */
408 atomic_t num_waiting; 411 atomic_t num_waiting;
409 412
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 79b615873838..fb77e0962132 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -576,6 +576,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req)
576 fc->no_lock = 1; 576 fc->no_lock = 1;
577 if (arg->flags & FUSE_ATOMIC_O_TRUNC) 577 if (arg->flags & FUSE_ATOMIC_O_TRUNC)
578 fc->atomic_o_trunc = 1; 578 fc->atomic_o_trunc = 1;
579 if (arg->flags & FUSE_BIG_WRITES)
580 fc->big_writes = 1;
579 } else { 581 } else {
580 ra_pages = fc->max_read / PAGE_CACHE_SIZE; 582 ra_pages = fc->max_read / PAGE_CACHE_SIZE;
581 fc->no_lock = 1; 583 fc->no_lock = 1;
@@ -599,7 +601,8 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)
599 arg->major = FUSE_KERNEL_VERSION; 601 arg->major = FUSE_KERNEL_VERSION;
600 arg->minor = FUSE_KERNEL_MINOR_VERSION; 602 arg->minor = FUSE_KERNEL_MINOR_VERSION;
601 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE; 603 arg->max_readahead = fc->bdi.ra_pages * PAGE_CACHE_SIZE;
602 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC; 604 arg->flags |= FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_ATOMIC_O_TRUNC |
605 FUSE_BIG_WRITES;
603 req->in.h.opcode = FUSE_INIT; 606 req->in.h.opcode = FUSE_INIT;
604 req->in.numargs = 1; 607 req->in.numargs = 1;
605 req->in.args[0].size = sizeof(*arg); 608 req->in.args[0].size = sizeof(*arg);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index d53b2af91c25..67e1c8b467c4 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -65,6 +65,8 @@ static int hfsplus_releasepage(struct page *page, gfp_t mask)
65 BUG(); 65 BUG();
66 return 0; 66 return 0;
67 } 67 }
68 if (!tree)
69 return 0;
68 if (tree->node_size >= PAGE_CACHE_SIZE) { 70 if (tree->node_size >= PAGE_CACHE_SIZE) {
69 nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT); 71 nidx = page->index >> (tree->node_size_shift - PAGE_CACHE_SHIFT);
70 spin_lock(&tree->hash_lock); 72 spin_lock(&tree->hash_lock);
diff --git a/fs/hppfs/Makefile b/fs/hppfs/Makefile
index 6890433f7595..8a1f50344368 100644
--- a/fs/hppfs/Makefile
+++ b/fs/hppfs/Makefile
@@ -1,9 +1,9 @@
1# 1#
2# Copyright (C) 2002, 2003 Jeff Dike (jdike@karaya.com) 2# Copyright (C) 2002 - 2008 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6hppfs-objs := hppfs_kern.o 6hppfs-objs := hppfs.o
7 7
8obj-y = 8obj-y =
9obj-$(CONFIG_HPPFS) += hppfs.o 9obj-$(CONFIG_HPPFS) += $(hppfs-objs)
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs.c
index 8601d8ef3b55..65077aa90f0a 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs.c
@@ -33,7 +33,7 @@ struct hppfs_private {
33}; 33};
34 34
35struct hppfs_inode_info { 35struct hppfs_inode_info {
36 struct dentry *proc_dentry; 36 struct dentry *proc_dentry;
37 struct inode vfs_inode; 37 struct inode vfs_inode;
38}; 38};
39 39
@@ -52,7 +52,7 @@ static int is_pid(struct dentry *dentry)
52 int i; 52 int i;
53 53
54 sb = dentry->d_sb; 54 sb = dentry->d_sb;
55 if ((sb->s_op != &hppfs_sbops) || (dentry->d_parent != sb->s_root)) 55 if (dentry->d_parent != sb->s_root)
56 return 0; 56 return 0;
57 57
58 for (i = 0; i < dentry->d_name.len; i++) { 58 for (i = 0; i < dentry->d_name.len; i++) {
@@ -136,7 +136,7 @@ static int file_removed(struct dentry *dentry, const char *file)
136} 136}
137 137
138static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry, 138static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
139 struct nameidata *nd) 139 struct nameidata *nd)
140{ 140{
141 struct dentry *proc_dentry, *new, *parent; 141 struct dentry *proc_dentry, *new, *parent;
142 struct inode *inode; 142 struct inode *inode;
@@ -254,6 +254,8 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
254 int err; 254 int err;
255 255
256 if (hppfs->contents != NULL) { 256 if (hppfs->contents != NULL) {
257 int rem;
258
257 if (*ppos >= hppfs->len) 259 if (*ppos >= hppfs->len)
258 return 0; 260 return 0;
259 261
@@ -267,8 +269,10 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
267 269
268 if (off + count > hppfs->len) 270 if (off + count > hppfs->len)
269 count = hppfs->len - off; 271 count = hppfs->len - off;
270 copy_to_user(buf, &data->contents[off], count); 272 rem = copy_to_user(buf, &data->contents[off], count);
271 *ppos += count; 273 *ppos += count - rem;
274 if (rem > 0)
275 return -EFAULT;
272 } else if (hppfs->host_fd != -1) { 276 } else if (hppfs->host_fd != -1) {
273 err = os_seek_file(hppfs->host_fd, *ppos); 277 err = os_seek_file(hppfs->host_fd, *ppos);
274 if (err) { 278 if (err) {
@@ -285,21 +289,15 @@ static ssize_t hppfs_read(struct file *file, char __user *buf, size_t count,
285 return count; 289 return count;
286} 290}
287 291
288static ssize_t hppfs_write(struct file *file, const char __user *buf, size_t len, 292static ssize_t hppfs_write(struct file *file, const char __user *buf,
289 loff_t *ppos) 293 size_t len, loff_t *ppos)
290{ 294{
291 struct hppfs_private *data = file->private_data; 295 struct hppfs_private *data = file->private_data;
292 struct file *proc_file = data->proc_file; 296 struct file *proc_file = data->proc_file;
293 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *); 297 ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *);
294 int err;
295 298
296 write = proc_file->f_path.dentry->d_inode->i_fop->write; 299 write = proc_file->f_path.dentry->d_inode->i_fop->write;
297 300 return (*write)(proc_file, buf, len, ppos);
298 proc_file->f_pos = file->f_pos;
299 err = (*write)(proc_file, buf, len, &proc_file->f_pos);
300 file->f_pos = proc_file->f_pos;
301
302 return err;
303} 301}
304 302
305static int open_host_sock(char *host_file, int *filter_out) 303static int open_host_sock(char *host_file, int *filter_out)
@@ -357,7 +355,7 @@ static struct hppfs_data *hppfs_get_data(int fd, int filter,
357 355
358 if (filter) { 356 if (filter) {
359 while ((n = read_proc(proc_file, data->contents, 357 while ((n = read_proc(proc_file, data->contents,
360 sizeof(data->contents), NULL, 0)) > 0) 358 sizeof(data->contents), NULL, 0)) > 0)
361 os_write_file(fd, data->contents, n); 359 os_write_file(fd, data->contents, n);
362 err = os_shutdown_socket(fd, 0, 1); 360 err = os_shutdown_socket(fd, 0, 1);
363 if (err) { 361 if (err) {
@@ -429,8 +427,8 @@ static int file_mode(int fmode)
429static int hppfs_open(struct inode *inode, struct file *file) 427static int hppfs_open(struct inode *inode, struct file *file)
430{ 428{
431 struct hppfs_private *data; 429 struct hppfs_private *data;
432 struct dentry *proc_dentry;
433 struct vfsmount *proc_mnt; 430 struct vfsmount *proc_mnt;
431 struct dentry *proc_dentry;
434 char *host_file; 432 char *host_file;
435 int err, fd, type, filter; 433 int err, fd, type, filter;
436 434
@@ -492,8 +490,8 @@ static int hppfs_open(struct inode *inode, struct file *file)
492static int hppfs_dir_open(struct inode *inode, struct file *file) 490static int hppfs_dir_open(struct inode *inode, struct file *file)
493{ 491{
494 struct hppfs_private *data; 492 struct hppfs_private *data;
495 struct dentry *proc_dentry;
496 struct vfsmount *proc_mnt; 493 struct vfsmount *proc_mnt;
494 struct dentry *proc_dentry;
497 int err; 495 int err;
498 496
499 err = -ENOMEM; 497 err = -ENOMEM;
@@ -620,6 +618,9 @@ static struct inode *hppfs_alloc_inode(struct super_block *sb)
620 618
621void hppfs_delete_inode(struct inode *ino) 619void hppfs_delete_inode(struct inode *ino)
622{ 620{
621 dput(HPPFS_I(ino)->proc_dentry);
622 mntput(ino->i_sb->s_fs_info);
623
623 clear_inode(ino); 624 clear_inode(ino);
624} 625}
625 626
@@ -628,69 +629,46 @@ static void hppfs_destroy_inode(struct inode *inode)
628 kfree(HPPFS_I(inode)); 629 kfree(HPPFS_I(inode));
629} 630}
630 631
631static void hppfs_put_super(struct super_block *sb)
632{
633 mntput(sb->s_fs_info);
634}
635
636static const struct super_operations hppfs_sbops = { 632static const struct super_operations hppfs_sbops = {
637 .alloc_inode = hppfs_alloc_inode, 633 .alloc_inode = hppfs_alloc_inode,
638 .destroy_inode = hppfs_destroy_inode, 634 .destroy_inode = hppfs_destroy_inode,
639 .delete_inode = hppfs_delete_inode, 635 .delete_inode = hppfs_delete_inode,
640 .statfs = hppfs_statfs, 636 .statfs = hppfs_statfs,
641 .put_super = hppfs_put_super,
642}; 637};
643 638
644static int hppfs_readlink(struct dentry *dentry, char __user *buffer, 639static int hppfs_readlink(struct dentry *dentry, char __user *buffer,
645 int buflen) 640 int buflen)
646{ 641{
647 struct file *proc_file;
648 struct dentry *proc_dentry; 642 struct dentry *proc_dentry;
649 struct vfsmount *proc_mnt;
650 int ret;
651 643
652 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 644 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
653 proc_mnt = dentry->d_sb->s_fs_info; 645 return proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer,
654 646 buflen);
655 proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY);
656 if (IS_ERR(proc_file))
657 return PTR_ERR(proc_file);
658
659 ret = proc_dentry->d_inode->i_op->readlink(proc_dentry, buffer, buflen);
660
661 fput(proc_file);
662
663 return ret;
664} 647}
665 648
666static void* hppfs_follow_link(struct dentry *dentry, struct nameidata *nd) 649static void *hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
667{ 650{
668 struct file *proc_file;
669 struct dentry *proc_dentry; 651 struct dentry *proc_dentry;
670 struct vfsmount *proc_mnt;
671 void *ret;
672 652
673 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry; 653 proc_dentry = HPPFS_I(dentry->d_inode)->proc_dentry;
674 proc_mnt = dentry->d_sb->s_fs_info;
675
676 proc_file = dentry_open(dget(proc_dentry), mntget(proc_mnt), O_RDONLY);
677 if (IS_ERR(proc_file))
678 return proc_file;
679
680 ret = proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
681 654
682 fput(proc_file); 655 return proc_dentry->d_inode->i_op->follow_link(proc_dentry, nd);
656}
683 657
684 return ret; 658int hppfs_permission(struct inode *inode, int mask, struct nameidata *nd)
659{
660 return generic_permission(inode, mask, NULL);
685} 661}
686 662
687static const struct inode_operations hppfs_dir_iops = { 663static const struct inode_operations hppfs_dir_iops = {
688 .lookup = hppfs_lookup, 664 .lookup = hppfs_lookup,
665 .permission = hppfs_permission,
689}; 666};
690 667
691static const struct inode_operations hppfs_link_iops = { 668static const struct inode_operations hppfs_link_iops = {
692 .readlink = hppfs_readlink, 669 .readlink = hppfs_readlink,
693 .follow_link = hppfs_follow_link, 670 .follow_link = hppfs_follow_link,
671 .permission = hppfs_permission,
694}; 672};
695 673
696static struct inode *get_inode(struct super_block *sb, struct dentry *dentry) 674static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
@@ -712,7 +690,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
712 inode->i_fop = &hppfs_file_fops; 690 inode->i_fop = &hppfs_file_fops;
713 } 691 }
714 692
715 HPPFS_I(inode)->proc_dentry = dentry; 693 HPPFS_I(inode)->proc_dentry = dget(dentry);
716 694
717 inode->i_uid = proc_ino->i_uid; 695 inode->i_uid = proc_ino->i_uid;
718 inode->i_gid = proc_ino->i_gid; 696 inode->i_gid = proc_ino->i_gid;
@@ -725,7 +703,7 @@ static struct inode *get_inode(struct super_block *sb, struct dentry *dentry)
725 inode->i_size = proc_ino->i_size; 703 inode->i_size = proc_ino->i_size;
726 inode->i_blocks = proc_ino->i_blocks; 704 inode->i_blocks = proc_ino->i_blocks;
727 705
728 return 0; 706 return inode;
729} 707}
730 708
731static int hppfs_fill_super(struct super_block *sb, void *d, int silent) 709static int hppfs_fill_super(struct super_block *sb, void *d, int silent)
diff --git a/fs/inode.c b/fs/inode.c
index bf6478130424..c36d9480335c 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1149,13 +1149,8 @@ static inline void iput_final(struct inode *inode)
1149void iput(struct inode *inode) 1149void iput(struct inode *inode)
1150{ 1150{
1151 if (inode) { 1151 if (inode) {
1152 const struct super_operations *op = inode->i_sb->s_op;
1153
1154 BUG_ON(inode->i_state == I_CLEAR); 1152 BUG_ON(inode->i_state == I_CLEAR);
1155 1153
1156 if (op && op->put_inode)
1157 op->put_inode(inode);
1158
1159 if (atomic_dec_and_lock(&inode->i_count, &inode_lock)) 1154 if (atomic_dec_and_lock(&inode->i_count, &inode_lock))
1160 iput_final(inode); 1155 iput_final(inode);
1161 } 1156 }
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index cd931ef1f000..5a8ca61498ca 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -470,7 +470,9 @@ void journal_commit_transaction(journal_t *journal)
470 * transaction! Now comes the tricky part: we need to write out 470 * transaction! Now comes the tricky part: we need to write out
471 * metadata. Loop over the transaction's entire buffer list: 471 * metadata. Loop over the transaction's entire buffer list:
472 */ 472 */
473 spin_lock(&journal->j_state_lock);
473 commit_transaction->t_state = T_COMMIT; 474 commit_transaction->t_state = T_COMMIT;
475 spin_unlock(&journal->j_state_lock);
474 476
475 J_ASSERT(commit_transaction->t_nr_buffers <= 477 J_ASSERT(commit_transaction->t_nr_buffers <=
476 commit_transaction->t_outstanding_credits); 478 commit_transaction->t_outstanding_credits);
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 53632e3e8457..2e24567c4a79 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -901,7 +901,7 @@ static void jbd2_stats_proc_init(journal_t *journal)
901{ 901{
902 char name[BDEVNAME_SIZE]; 902 char name[BDEVNAME_SIZE];
903 903
904 snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); 904 bdevname(journal->j_dev, name);
905 journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats); 905 journal->j_proc_entry = proc_mkdir(name, proc_jbd2_stats);
906 if (journal->j_proc_entry) { 906 if (journal->j_proc_entry) {
907 proc_create_data("history", S_IRUGO, journal->j_proc_entry, 907 proc_create_data("history", S_IRUGO, journal->j_proc_entry,
@@ -915,7 +915,7 @@ static void jbd2_stats_proc_exit(journal_t *journal)
915{ 915{
916 char name[BDEVNAME_SIZE]; 916 char name[BDEVNAME_SIZE];
917 917
918 snprintf(name, sizeof(name) - 1, "%s", bdevname(journal->j_dev, name)); 918 bdevname(journal->j_dev, name);
919 remove_proc_entry("info", journal->j_proc_entry); 919 remove_proc_entry("info", journal->j_proc_entry);
920 remove_proc_entry("history", journal->j_proc_entry); 920 remove_proc_entry("history", journal->j_proc_entry);
921 remove_proc_entry(name, proc_jbd2_stats); 921 remove_proc_entry(name, proc_jbd2_stats);
diff --git a/fs/locks.c b/fs/locks.c
index 663c069b59b3..11dbf08651b7 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -773,7 +773,7 @@ static int flock_lock_file(struct file *filp, struct file_lock *request)
773 * give it the opportunity to lock the file. 773 * give it the opportunity to lock the file.
774 */ 774 */
775 if (found) 775 if (found)
776 cond_resched(); 776 cond_resched_bkl();
777 777
778find_conflict: 778find_conflict:
779 for_each_lock(inode, before) { 779 for_each_lock(inode, before) {
@@ -1753,6 +1753,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
1753 struct file_lock *file_lock = locks_alloc_lock(); 1753 struct file_lock *file_lock = locks_alloc_lock();
1754 struct flock flock; 1754 struct flock flock;
1755 struct inode *inode; 1755 struct inode *inode;
1756 struct file *f;
1756 int error; 1757 int error;
1757 1758
1758 if (file_lock == NULL) 1759 if (file_lock == NULL)
@@ -1825,7 +1826,15 @@ again:
1825 * Attempt to detect a close/fcntl race and recover by 1826 * Attempt to detect a close/fcntl race and recover by
1826 * releasing the lock that was just acquired. 1827 * releasing the lock that was just acquired.
1827 */ 1828 */
1828 if (!error && fcheck(fd) != filp && flock.l_type != F_UNLCK) { 1829 /*
1830 * we need that spin_lock here - it prevents reordering between
1831 * update of inode->i_flock and check for it done in close().
1832 * rcu_read_lock() wouldn't do.
1833 */
1834 spin_lock(&current->files->file_lock);
1835 f = fcheck(fd);
1836 spin_unlock(&current->files->file_lock);
1837 if (!error && f != filp && flock.l_type != F_UNLCK) {
1829 flock.l_type = F_UNLCK; 1838 flock.l_type = F_UNLCK;
1830 goto again; 1839 goto again;
1831 } 1840 }
@@ -1881,6 +1890,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
1881 struct file_lock *file_lock = locks_alloc_lock(); 1890 struct file_lock *file_lock = locks_alloc_lock();
1882 struct flock64 flock; 1891 struct flock64 flock;
1883 struct inode *inode; 1892 struct inode *inode;
1893 struct file *f;
1884 int error; 1894 int error;
1885 1895
1886 if (file_lock == NULL) 1896 if (file_lock == NULL)
@@ -1953,7 +1963,10 @@ again:
1953 * Attempt to detect a close/fcntl race and recover by 1963 * Attempt to detect a close/fcntl race and recover by
1954 * releasing the lock that was just acquired. 1964 * releasing the lock that was just acquired.
1955 */ 1965 */
1956 if (!error && fcheck(fd) != filp && flock.l_type != F_UNLCK) { 1966 spin_lock(&current->files->file_lock);
1967 f = fcheck(fd);
1968 spin_unlock(&current->files->file_lock);
1969 if (!error && f != filp && flock.l_type != F_UNLCK) {
1957 flock.l_type = F_UNLCK; 1970 flock.l_type = F_UNLCK;
1958 goto again; 1971 goto again;
1959 } 1972 }
diff --git a/fs/pipe.c b/fs/pipe.c
index 3499f9ff6316..ec228bc9f882 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -17,6 +17,7 @@
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/pagemap.h> 18#include <linux/pagemap.h>
19#include <linux/audit.h> 19#include <linux/audit.h>
20#include <linux/syscalls.h>
20 21
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
22#include <asm/ioctls.h> 23#include <asm/ioctls.h>
@@ -1086,8 +1087,11 @@ asmlinkage long __weak sys_pipe(int __user *fildes)
1086 1087
1087 error = do_pipe(fd); 1088 error = do_pipe(fd);
1088 if (!error) { 1089 if (!error) {
1089 if (copy_to_user(fildes, fd, sizeof(fd))) 1090 if (copy_to_user(fildes, fd, sizeof(fd))) {
1091 sys_close(fd[0]);
1092 sys_close(fd[1]);
1090 error = -EFAULT; 1093 error = -EFAULT;
1094 }
1091 } 1095 }
1092 return error; 1096 return error;
1093} 1097}
diff --git a/fs/proc/array.c b/fs/proc/array.c
index dca997a93bff..9e3b8c33c24b 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -298,6 +298,7 @@ static inline void task_cap(struct seq_file *m, struct task_struct *p)
298 render_cap_t(m, "CapInh:\t", &p->cap_inheritable); 298 render_cap_t(m, "CapInh:\t", &p->cap_inheritable);
299 render_cap_t(m, "CapPrm:\t", &p->cap_permitted); 299 render_cap_t(m, "CapPrm:\t", &p->cap_permitted);
300 render_cap_t(m, "CapEff:\t", &p->cap_effective); 300 render_cap_t(m, "CapEff:\t", &p->cap_effective);
301 render_cap_t(m, "CapBnd:\t", &p->cap_bset);
301} 302}
302 303
303static inline void task_context_switch_counts(struct seq_file *m, 304static inline void task_context_switch_counts(struct seq_file *m,
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index e2b8e769f510..88717c0f941b 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -5,11 +5,9 @@
5#include <linux/highmem.h> 5#include <linux/highmem.h>
6#include <linux/ptrace.h> 6#include <linux/ptrace.h>
7#include <linux/pagemap.h> 7#include <linux/pagemap.h>
8#include <linux/ptrace.h>
9#include <linux/mempolicy.h> 8#include <linux/mempolicy.h>
10#include <linux/swap.h> 9#include <linux/swap.h>
11#include <linux/swapops.h> 10#include <linux/swapops.h>
12#include <linux/seq_file.h>
13 11
14#include <asm/elf.h> 12#include <asm/elf.h>
15#include <asm/uaccess.h> 13#include <asm/uaccess.h>
diff --git a/fs/splice.c b/fs/splice.c
index 633f58ebfb72..78150038b584 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -811,24 +811,19 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
811{ 811{
812 struct address_space *mapping = out->f_mapping; 812 struct address_space *mapping = out->f_mapping;
813 struct inode *inode = mapping->host; 813 struct inode *inode = mapping->host;
814 int killsuid, killpriv; 814 struct splice_desc sd = {
815 .total_len = len,
816 .flags = flags,
817 .pos = *ppos,
818 .u.file = out,
819 };
815 ssize_t ret; 820 ssize_t ret;
816 int err = 0;
817
818 killpriv = security_inode_need_killpriv(out->f_path.dentry);
819 killsuid = should_remove_suid(out->f_path.dentry);
820 if (unlikely(killsuid || killpriv)) {
821 mutex_lock(&inode->i_mutex);
822 if (killpriv)
823 err = security_inode_killpriv(out->f_path.dentry);
824 if (!err && killsuid)
825 err = __remove_suid(out->f_path.dentry, killsuid);
826 mutex_unlock(&inode->i_mutex);
827 if (err)
828 return err;
829 }
830 821
831 ret = splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_file); 822 inode_double_lock(inode, pipe->inode);
823 ret = remove_suid(out->f_path.dentry);
824 if (likely(!ret))
825 ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
826 inode_double_unlock(inode, pipe->inode);
832 if (ret > 0) { 827 if (ret > 0) {
833 unsigned long nr_pages; 828 unsigned long nr_pages;
834 829
@@ -840,6 +835,8 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
840 * sync it. 835 * sync it.
841 */ 836 */
842 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) { 837 if (unlikely((out->f_flags & O_SYNC) || IS_SYNC(inode))) {
838 int err;
839
843 mutex_lock(&inode->i_mutex); 840 mutex_lock(&inode->i_mutex);
844 err = generic_osync_inode(inode, mapping, 841 err = generic_osync_inode(inode, mapping,
845 OSYNC_METADATA|OSYNC_DATA); 842 OSYNC_METADATA|OSYNC_DATA);
@@ -1075,7 +1072,7 @@ long do_splice_direct(struct file *in, loff_t *ppos, struct file *out,
1075 1072
1076 ret = splice_direct_to_actor(in, &sd, direct_splice_actor); 1073 ret = splice_direct_to_actor(in, &sd, direct_splice_actor);
1077 if (ret > 0) 1074 if (ret > 0)
1078 *ppos = sd.pos; 1075 *ppos += ret;
1079 1076
1080 return ret; 1077 return ret;
1081} 1078}
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index a1c3a1fab7f0..8c0e4b92574f 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -419,12 +419,8 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
419 */ 419 */
420int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) 420int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
421{ 421{
422 if (sysfs_find_dirent(acxt->parent_sd, sd->s_name)) { 422 if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
423 printk(KERN_WARNING "sysfs: duplicate filename '%s' "
424 "can not be created\n", sd->s_name);
425 WARN_ON(1);
426 return -EEXIST; 423 return -EEXIST;
427 }
428 424
429 sd->s_parent = sysfs_get(acxt->parent_sd); 425 sd->s_parent = sysfs_get(acxt->parent_sd);
430 426
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 2b34c8ca6c83..d3231947db19 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -32,6 +32,7 @@
32#include <linux/buffer_head.h> 32#include <linux/buffer_head.h>
33#include <linux/sched.h> 33#include <linux/sched.h>
34#include <linux/crc-itu-t.h> 34#include <linux/crc-itu-t.h>
35#include <linux/exportfs.h>
35 36
36static inline int udf_match(int len1, const char *name1, int len2, 37static inline int udf_match(int len1, const char *name1, int len2,
37 const char *name2) 38 const char *name2)
@@ -158,6 +159,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
158 sector_t offset; 159 sector_t offset;
159 struct extent_position epos = {}; 160 struct extent_position epos = {};
160 struct udf_inode_info *dinfo = UDF_I(dir); 161 struct udf_inode_info *dinfo = UDF_I(dir);
162 int isdotdot = dentry->d_name.len == 2 &&
163 dentry->d_name.name[0] == '.' && dentry->d_name.name[1] == '.';
161 164
162 size = udf_ext0_offset(dir) + dir->i_size; 165 size = udf_ext0_offset(dir) + dir->i_size;
163 f_pos = udf_ext0_offset(dir); 166 f_pos = udf_ext0_offset(dir);
@@ -225,6 +228,12 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
225 continue; 228 continue;
226 } 229 }
227 230
231 if ((cfi->fileCharacteristics & FID_FILE_CHAR_PARENT) &&
232 isdotdot) {
233 brelse(epos.bh);
234 return fi;
235 }
236
228 if (!lfi) 237 if (!lfi)
229 continue; 238 continue;
230 239
@@ -286,9 +295,8 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
286 } 295 }
287 } 296 }
288 unlock_kernel(); 297 unlock_kernel();
289 d_add(dentry, inode);
290 298
291 return NULL; 299 return d_splice_alias(inode, dentry);
292} 300}
293 301
294static struct fileIdentDesc *udf_add_entry(struct inode *dir, 302static struct fileIdentDesc *udf_add_entry(struct inode *dir,
@@ -307,7 +315,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
307 uint16_t liu; 315 uint16_t liu;
308 int block; 316 int block;
309 kernel_lb_addr eloc; 317 kernel_lb_addr eloc;
310 uint32_t elen; 318 uint32_t elen = 0;
311 sector_t offset; 319 sector_t offset;
312 struct extent_position epos = {}; 320 struct extent_position epos = {};
313 struct udf_inode_info *dinfo; 321 struct udf_inode_info *dinfo;
@@ -398,7 +406,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
398 } 406 }
399 407
400add: 408add:
401 if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { 409 /* Is there any extent whose size we need to round up? */
410 if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && elen) {
402 elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); 411 elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1);
403 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) 412 if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
404 epos.offset -= sizeof(short_ad); 413 epos.offset -= sizeof(short_ad);
@@ -1232,6 +1241,134 @@ end_rename:
1232 return retval; 1241 return retval;
1233} 1242}
1234 1243
1244static struct dentry *udf_get_parent(struct dentry *child)
1245{
1246 struct dentry *parent;
1247 struct inode *inode = NULL;
1248 struct dentry dotdot;
1249 struct fileIdentDesc cfi;
1250 struct udf_fileident_bh fibh;
1251
1252 dotdot.d_name.name = "..";
1253 dotdot.d_name.len = 2;
1254
1255 lock_kernel();
1256 if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi))
1257 goto out_unlock;
1258
1259 if (fibh.sbh != fibh.ebh)
1260 brelse(fibh.ebh);
1261 brelse(fibh.sbh);
1262
1263 inode = udf_iget(child->d_inode->i_sb,
1264 lelb_to_cpu(cfi.icb.extLocation));
1265 if (!inode)
1266 goto out_unlock;
1267 unlock_kernel();
1268
1269 parent = d_alloc_anon(inode);
1270 if (!parent) {
1271 iput(inode);
1272 parent = ERR_PTR(-ENOMEM);
1273 }
1274
1275 return parent;
1276out_unlock:
1277 unlock_kernel();
1278 return ERR_PTR(-EACCES);
1279}
1280
1281
1282static struct dentry *udf_nfs_get_inode(struct super_block *sb, u32 block,
1283 u16 partref, __u32 generation)
1284{
1285 struct inode *inode;
1286 struct dentry *result;
1287 kernel_lb_addr loc;
1288
1289 if (block == 0)
1290 return ERR_PTR(-ESTALE);
1291
1292 loc.logicalBlockNum = block;
1293 loc.partitionReferenceNum = partref;
1294 inode = udf_iget(sb, loc);
1295
1296 if (inode == NULL)
1297 return ERR_PTR(-ENOMEM);
1298
1299 if (generation && inode->i_generation != generation) {
1300 iput(inode);
1301 return ERR_PTR(-ESTALE);
1302 }
1303 result = d_alloc_anon(inode);
1304 if (!result) {
1305 iput(inode);
1306 return ERR_PTR(-ENOMEM);
1307 }
1308 return result;
1309}
1310
1311static struct dentry *udf_fh_to_dentry(struct super_block *sb,
1312 struct fid *fid, int fh_len, int fh_type)
1313{
1314 if ((fh_len != 3 && fh_len != 5) ||
1315 (fh_type != FILEID_UDF_WITH_PARENT &&
1316 fh_type != FILEID_UDF_WITHOUT_PARENT))
1317 return NULL;
1318
1319 return udf_nfs_get_inode(sb, fid->udf.block, fid->udf.partref,
1320 fid->udf.generation);
1321}
1322
1323static struct dentry *udf_fh_to_parent(struct super_block *sb,
1324 struct fid *fid, int fh_len, int fh_type)
1325{
1326 if (fh_len != 5 || fh_type != FILEID_UDF_WITH_PARENT)
1327 return NULL;
1328
1329 return udf_nfs_get_inode(sb, fid->udf.parent_block,
1330 fid->udf.parent_partref,
1331 fid->udf.parent_generation);
1332}
1333static int udf_encode_fh(struct dentry *de, __u32 *fh, int *lenp,
1334 int connectable)
1335{
1336 int len = *lenp;
1337 struct inode *inode = de->d_inode;
1338 kernel_lb_addr location = UDF_I(inode)->i_location;
1339 struct fid *fid = (struct fid *)fh;
1340 int type = FILEID_UDF_WITHOUT_PARENT;
1341
1342 if (len < 3 || (connectable && len < 5))
1343 return 255;
1344
1345 *lenp = 3;
1346 fid->udf.block = location.logicalBlockNum;
1347 fid->udf.partref = location.partitionReferenceNum;
1348 fid->udf.generation = inode->i_generation;
1349
1350 if (connectable && !S_ISDIR(inode->i_mode)) {
1351 spin_lock(&de->d_lock);
1352 inode = de->d_parent->d_inode;
1353 location = UDF_I(inode)->i_location;
1354 fid->udf.parent_block = location.logicalBlockNum;
1355 fid->udf.parent_partref = location.partitionReferenceNum;
1356 fid->udf.parent_generation = inode->i_generation;
1357 spin_unlock(&de->d_lock);
1358 *lenp = 5;
1359 type = FILEID_UDF_WITH_PARENT;
1360 }
1361
1362 return type;
1363}
1364
1365const struct export_operations udf_export_ops = {
1366 .encode_fh = udf_encode_fh,
1367 .fh_to_dentry = udf_fh_to_dentry,
1368 .fh_to_parent = udf_fh_to_parent,
1369 .get_parent = udf_get_parent,
1370};
1371
1235const struct inode_operations udf_dir_inode_operations = { 1372const struct inode_operations udf_dir_inode_operations = {
1236 .lookup = udf_lookup, 1373 .lookup = udf_lookup,
1237 .create = udf_create, 1374 .create = udf_create,
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index 63610f026ae1..96dfd207c3d6 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -27,8 +27,8 @@
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/buffer_head.h> 28#include <linux/buffer_head.h>
29 29
30inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, 30uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
31 uint16_t partition, uint32_t offset) 31 uint16_t partition, uint32_t offset)
32{ 32{
33 struct udf_sb_info *sbi = UDF_SB(sb); 33 struct udf_sb_info *sbi = UDF_SB(sb);
34 struct udf_part_map *map; 34 struct udf_part_map *map;
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 9fb18a340fc1..7a5f69be6ac2 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1933,6 +1933,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1933 1933
1934 /* Fill in the rest of the superblock */ 1934 /* Fill in the rest of the superblock */
1935 sb->s_op = &udf_sb_ops; 1935 sb->s_op = &udf_sb_ops;
1936 sb->s_export_op = &udf_export_ops;
1936 sb->dq_op = NULL; 1937 sb->dq_op = NULL;
1937 sb->s_dirt = 0; 1938 sb->s_dirt = 0;
1938 sb->s_magic = UDF_SUPER_MAGIC; 1939 sb->s_magic = UDF_SUPER_MAGIC;
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index f3f45d029277..8fa9c2d70911 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -73,6 +73,7 @@ struct task_struct;
73struct buffer_head; 73struct buffer_head;
74struct super_block; 74struct super_block;
75 75
76extern const struct export_operations udf_export_ops;
76extern const struct inode_operations udf_dir_inode_operations; 77extern const struct inode_operations udf_dir_inode_operations;
77extern const struct file_operations udf_dir_operations; 78extern const struct file_operations udf_dir_operations;
78extern const struct inode_operations udf_file_inode_operations; 79extern const struct inode_operations udf_file_inode_operations;
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 244a1aaa940e..11c035168ea6 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -107,7 +107,6 @@ extern struct inode * ufs_new_inode (struct inode *, int);
107 107
108/* inode.c */ 108/* inode.c */
109extern struct inode *ufs_iget(struct super_block *, unsigned long); 109extern struct inode *ufs_iget(struct super_block *, unsigned long);
110extern void ufs_put_inode (struct inode *);
111extern int ufs_write_inode (struct inode *, int); 110extern int ufs_write_inode (struct inode *, int);
112extern int ufs_sync_inode (struct inode *); 111extern int ufs_sync_inode (struct inode *);
113extern void ufs_delete_inode (struct inode *); 112extern void ufs_delete_inode (struct inode *);
diff --git a/include/asm-alpha/barrier.h b/include/asm-alpha/barrier.h
index 384dc08d6f53..ac78eba909bc 100644
--- a/include/asm-alpha/barrier.h
+++ b/include/asm-alpha/barrier.h
@@ -24,7 +24,7 @@ __asm__ __volatile__("mb": : :"memory")
24#define smp_mb() barrier() 24#define smp_mb() barrier()
25#define smp_rmb() barrier() 25#define smp_rmb() barrier()
26#define smp_wmb() barrier() 26#define smp_wmb() barrier()
27#define smp_read_barrier_depends() barrier() 27#define smp_read_barrier_depends() do { } while (0)
28#endif 28#endif
29 29
30#define set_mb(var, value) \ 30#define set_mb(var, value) \
diff --git a/include/asm-alpha/param.h b/include/asm-alpha/param.h
index 0982f1d39499..e691ecfedb2c 100644
--- a/include/asm-alpha/param.h
+++ b/include/asm-alpha/param.h
@@ -5,8 +5,12 @@
5 hardware ignores reprogramming. We also need userland buy-in to the 5 hardware ignores reprogramming. We also need userland buy-in to the
6 change in HZ, since this is visible in the wait4 resources etc. */ 6 change in HZ, since this is visible in the wait4 resources etc. */
7 7
8#ifdef __KERNEL__
8#define HZ CONFIG_HZ 9#define HZ CONFIG_HZ
9#define USER_HZ HZ 10#define USER_HZ HZ
11#else
12#define HZ 1024
13#endif
10 14
11#define EXEC_PAGESIZE 8192 15#define EXEC_PAGESIZE 8192
12 16
diff --git a/include/asm-alpha/pgtable.h b/include/asm-alpha/pgtable.h
index 05ce5fba43e3..3f0c59f6d8aa 100644
--- a/include/asm-alpha/pgtable.h
+++ b/include/asm-alpha/pgtable.h
@@ -287,17 +287,34 @@ extern inline pte_t pte_mkspecial(pte_t pte) { return pte; }
287#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) 287#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
288#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address)) 288#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
289 289
290/*
291 * The smp_read_barrier_depends() in the following functions are required to
292 * order the load of *dir (the pointer in the top level page table) with any
293 * subsequent load of the returned pmd_t *ret (ret is data dependent on *dir).
294 *
295 * If this ordering is not enforced, the CPU might load an older value of
296 * *ret, which may be uninitialized data. See mm/memory.c:__pte_alloc for
297 * more details.
298 *
299 * Note that we never change the mm->pgd pointer after the task is running, so
300 * pgd_offset does not require such a barrier.
301 */
302
290/* Find an entry in the second-level page table.. */ 303/* Find an entry in the second-level page table.. */
291extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address) 304extern inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
292{ 305{
293 return (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1)); 306 pmd_t *ret = (pmd_t *) pgd_page_vaddr(*dir) + ((address >> PMD_SHIFT) & (PTRS_PER_PAGE - 1));
307 smp_read_barrier_depends(); /* see above */
308 return ret;
294} 309}
295 310
296/* Find an entry in the third-level page table.. */ 311/* Find an entry in the third-level page table.. */
297extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address) 312extern inline pte_t * pte_offset_kernel(pmd_t * dir, unsigned long address)
298{ 313{
299 return (pte_t *) pmd_page_vaddr(*dir) 314 pte_t *ret = (pte_t *) pmd_page_vaddr(*dir)
300 + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1)); 315 + ((address >> PAGE_SHIFT) & (PTRS_PER_PAGE - 1));
316 smp_read_barrier_depends(); /* see above */
317 return ret;
301} 318}
302 319
303#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr)) 320#define pte_offset_map(dir,addr) pte_offset_kernel((dir),(addr))
diff --git a/include/asm-arm/arch-pxa/pm.h b/include/asm-arm/arch-pxa/pm.h
index 9d9f4b54b2ce..261e5bc958db 100644
--- a/include/asm-arm/arch-pxa/pm.h
+++ b/include/asm-arm/arch-pxa/pm.h
@@ -10,7 +10,7 @@
10#include <linux/suspend.h> 10#include <linux/suspend.h>
11 11
12struct pxa_cpu_pm_fns { 12struct pxa_cpu_pm_fns {
13 int save_size; 13 int save_count;
14 void (*save)(unsigned long *); 14 void (*save)(unsigned long *);
15 void (*restore)(unsigned long *); 15 void (*restore)(unsigned long *);
16 int (*valid)(suspend_state_t state); 16 int (*valid)(suspend_state_t state);
diff --git a/include/asm-arm/arch-pxa/system.h b/include/asm-arm/arch-pxa/system.h
index a758a719180f..9aa6c2e939e8 100644
--- a/include/asm-arm/arch-pxa/system.h
+++ b/include/asm-arm/arch-pxa/system.h
@@ -22,7 +22,8 @@ static inline void arch_idle(void)
22 22
23static inline void arch_reset(char mode) 23static inline void arch_reset(char mode)
24{ 24{
25 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR; 25 if (cpu_is_pxa2xx())
26 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
26 27
27 if (mode == 's') { 28 if (mode == 's') {
28 /* Jump into ROM at address 0 */ 29 /* Jump into ROM at address 0 */
diff --git a/include/asm-blackfin/dpmc.h b/include/asm-blackfin/dpmc.h
index 686cf83a5269..7f34cd384f12 100644
--- a/include/asm-blackfin/dpmc.h
+++ b/include/asm-blackfin/dpmc.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * include/asm-blackfin/dpmc.h - Miscellaneous IOCTL commands for Dynamic Power 2 * include/asm-blackfin/dpmc.h - Miscellaneous IOCTL commands for Dynamic Power
3 * Management Controller Driver. 3 * Management Controller Driver.
4 * Copyright (C) 2004 Analog Device Inc. 4 * Copyright (C) 2004-2008 Analog Device Inc.
5 * 5 *
6 */ 6 */
7#ifndef _BLACKFIN_DPMC_H_ 7#ifndef _BLACKFIN_DPMC_H_
@@ -65,6 +65,14 @@ void disable_wdog_timer(void);
65extern unsigned long get_cclk(void); 65extern unsigned long get_cclk(void);
66extern unsigned long get_sclk(void); 66extern unsigned long get_sclk(void);
67 67
68struct bfin_dpmc_platform_data {
69 const unsigned int *tuple_tab;
70 unsigned short tabsize;
71 unsigned short vr_settling_time; /* in us */
72};
73
74#define VRPAIR(vlev, freq) (((vlev) << 16) | ((freq) >> 16))
75
68#endif /* __KERNEL__ */ 76#endif /* __KERNEL__ */
69 77
70#endif /*_BLACKFIN_DPMC_H_*/ 78#endif /*_BLACKFIN_DPMC_H_*/
diff --git a/include/asm-blackfin/entry.h b/include/asm-blackfin/entry.h
index 562c6d3a3232..c4f721e0d00d 100644
--- a/include/asm-blackfin/entry.h
+++ b/include/asm-blackfin/entry.h
@@ -17,6 +17,11 @@
17#define PF_DTRACE_OFF 1 17#define PF_DTRACE_OFF 1
18#define PF_DTRACE_BIT 5 18#define PF_DTRACE_BIT 5
19 19
20/*
21 * NOTE! The single-stepping code assumes that all interrupt handlers
22 * start by saving SYSCFG on the stack with their first instruction.
23 */
24
20/* This one is used for exceptions, emulation, and NMI. It doesn't push 25/* This one is used for exceptions, emulation, and NMI. It doesn't push
21 RETI and doesn't do cli. */ 26 RETI and doesn't do cli. */
22#define SAVE_ALL_SYS save_context_no_interrupts 27#define SAVE_ALL_SYS save_context_no_interrupts
diff --git a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
index f0ab2736a680..26e3c8076b4e 100644
--- a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
@@ -44,10 +44,15 @@
44#define UART_PUT_CHAR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_THR), v) 44#define UART_PUT_CHAR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_THR), v)
45#define UART_PUT_DLL(uart, v) bfin_write16(((uart)->port.membase + OFFSET_DLL), v) 45#define UART_PUT_DLL(uart, v) bfin_write16(((uart)->port.membase + OFFSET_DLL), v)
46#define UART_PUT_IER(uart, v) bfin_write16(((uart)->port.membase + OFFSET_IER), v) 46#define UART_PUT_IER(uart, v) bfin_write16(((uart)->port.membase + OFFSET_IER), v)
47#define UART_SET_IER(uart, v) UART_PUT_IER(uart, UART_GET_IER(uart) | (v))
48#define UART_CLEAR_IER(uart, v) UART_PUT_IER(uart, UART_GET_IER(uart) & ~(v))
47#define UART_PUT_DLH(uart, v) bfin_write16(((uart)->port.membase + OFFSET_DLH), v) 49#define UART_PUT_DLH(uart, v) bfin_write16(((uart)->port.membase + OFFSET_DLH), v)
48#define UART_PUT_LCR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_LCR), v) 50#define UART_PUT_LCR(uart, v) bfin_write16(((uart)->port.membase + OFFSET_LCR), v)
49#define UART_PUT_GCTL(uart, v) bfin_write16(((uart)->port.membase + OFFSET_GCTL), v) 51#define UART_PUT_GCTL(uart, v) bfin_write16(((uart)->port.membase + OFFSET_GCTL), v)
50 52
53#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
54#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
55
51#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) 56#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
52# define CONFIG_SERIAL_BFIN_CTSRTS 57# define CONFIG_SERIAL_BFIN_CTSRTS
53 58
diff --git a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
index fbe88dee3e2d..d016603b6615 100644
--- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
@@ -44,10 +44,15 @@
44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v) 45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v) 46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v)
47#define UART_SET_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) | (v))
48#define UART_CLEAR_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) & ~(v))
47#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v) 49#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
48#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v) 50#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
49#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v) 51#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
50 52
53#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
54#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
55
51#ifdef CONFIG_BFIN_UART0_CTSRTS 56#ifdef CONFIG_BFIN_UART0_CTSRTS
52# define CONFIG_SERIAL_BFIN_CTSRTS 57# define CONFIG_SERIAL_BFIN_CTSRTS
53# ifndef CONFIG_UART0_CTS_PIN 58# ifndef CONFIG_UART0_CTS_PIN
diff --git a/include/asm-blackfin/mach-bf533/defBF532.h b/include/asm-blackfin/mach-bf533/defBF532.h
index 17e1548cec08..0ab4dd7494cf 100644
--- a/include/asm-blackfin/mach-bf533/defBF532.h
+++ b/include/asm-blackfin/mach-bf533/defBF532.h
@@ -468,6 +468,8 @@
468#define VLEV_110 0x00B0 /* VLEV = 1.10 V (-5% - +10% Accuracy) */ 468#define VLEV_110 0x00B0 /* VLEV = 1.10 V (-5% - +10% Accuracy) */
469#define VLEV_115 0x00C0 /* VLEV = 1.15 V (-5% - +10% Accuracy) */ 469#define VLEV_115 0x00C0 /* VLEV = 1.15 V (-5% - +10% Accuracy) */
470#define VLEV_120 0x00D0 /* VLEV = 1.20 V (-5% - +10% Accuracy) */ 470#define VLEV_120 0x00D0 /* VLEV = 1.20 V (-5% - +10% Accuracy) */
471#define VLEV_125 0x00E0 /* VLEV = 1.25 V (-5% - +10% Accuracy) */
472#define VLEV_130 0x00F0 /* VLEV = 1.30 V (-5% - +10% Accuracy) */
471 473
472#define WAKE 0x0100 /* Enable RTC/Reset Wakeup From Hibernate */ 474#define WAKE 0x0100 /* Enable RTC/Reset Wakeup From Hibernate */
473#define SCKELOW 0x8000 /* Do Not Drive SCKE High During Reset After Hibernate */ 475#define SCKELOW 0x8000 /* Do Not Drive SCKE High During Reset After Hibernate */
diff --git a/include/asm-blackfin/mach-bf533/irq.h b/include/asm-blackfin/mach-bf533/irq.h
index 832e6f6122da..5aa38e5da6b7 100644
--- a/include/asm-blackfin/mach-bf533/irq.h
+++ b/include/asm-blackfin/mach-bf533/irq.h
@@ -66,12 +66,13 @@ Core Emulation **
66 DMA8/9 Interrupt IVG13 28 66 DMA8/9 Interrupt IVG13 28
67 DMA10/11 Interrupt IVG13 29 67 DMA10/11 Interrupt IVG13 29
68 Watchdog Timer IVG13 30 68 Watchdog Timer IVG13 30
69 Software Interrupt 1 IVG14 31 69
70 Software Interrupt 2 -- 70 Softirq IVG14 31
71 System Call --
71 (lowest priority) IVG15 32 * 72 (lowest priority) IVG15 32 *
72 */ 73 */
73#define SYS_IRQS 32 74#define SYS_IRQS 31
74#define NR_PERI_INTS 24 75#define NR_PERI_INTS 24
75 76
76/* The ABSTRACT IRQ definitions */ 77/* The ABSTRACT IRQ definitions */
77/** the first seven of the following are fixed, the rest you change if you need to **/ 78/** the first seven of the following are fixed, the rest you change if you need to **/
@@ -96,7 +97,7 @@ Core Emulation **
96#define IRQ_SPORT0_TX 17 /*DMA2 Interrupt (SPORT0 TX) */ 97#define IRQ_SPORT0_TX 17 /*DMA2 Interrupt (SPORT0 TX) */
97#define IRQ_SPORT1_RX 18 /*DMA3 Interrupt (SPORT1 RX) */ 98#define IRQ_SPORT1_RX 18 /*DMA3 Interrupt (SPORT1 RX) */
98#define IRQ_SPORT1_TX 19 /*DMA4 Interrupt (SPORT1 TX) */ 99#define IRQ_SPORT1_TX 19 /*DMA4 Interrupt (SPORT1 TX) */
99#define IRQ_SPI 20 /*DMA5 Interrupt (SPI) */ 100#define IRQ_SPI 20 /*DMA5 Interrupt (SPI) */
100#define IRQ_UART_RX 21 /*DMA6 Interrupt (UART RX) */ 101#define IRQ_UART_RX 21 /*DMA6 Interrupt (UART RX) */
101#define IRQ_UART_TX 22 /*DMA7 Interrupt (UART TX) */ 102#define IRQ_UART_TX 22 /*DMA7 Interrupt (UART TX) */
102#define IRQ_TMR0 23 /*Timer 0 */ 103#define IRQ_TMR0 23 /*Timer 0 */
@@ -108,9 +109,6 @@ Core Emulation **
108#define IRQ_MEM_DMA1 29 /*DMA10/11 Interrupt (Memory DMA Stream 1) */ 109#define IRQ_MEM_DMA1 29 /*DMA10/11 Interrupt (Memory DMA Stream 1) */
109#define IRQ_WATCH 30 /*Watch Dog Timer */ 110#define IRQ_WATCH 30 /*Watch Dog Timer */
110 111
111#define IRQ_SW_INT1 31 /*Software Int 1 */
112#define IRQ_SW_INT2 32 /*Software Int 2 (reserved for SYSCALL) */
113
114#define IRQ_PF0 33 112#define IRQ_PF0 33
115#define IRQ_PF1 34 113#define IRQ_PF1 34
116#define IRQ_PF2 35 114#define IRQ_PF2 35
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
index fd100a415b98..f79d1a0e9129 100644
--- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
@@ -44,10 +44,15 @@
44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v) 45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v) 46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v)
47#define UART_SET_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) | (v))
48#define UART_CLEAR_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) & ~(v))
47#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v) 49#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
48#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v) 50#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
49#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v) 51#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
50 52
53#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
54#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
55
51#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) 56#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
52# define CONFIG_SERIAL_BFIN_CTSRTS 57# define CONFIG_SERIAL_BFIN_CTSRTS
53 58
diff --git a/include/asm-blackfin/mach-bf537/irq.h b/include/asm-blackfin/mach-bf537/irq.h
index be6f2ff77f31..2e68a8a1e730 100644
--- a/include/asm-blackfin/mach-bf537/irq.h
+++ b/include/asm-blackfin/mach-bf537/irq.h
@@ -34,24 +34,23 @@
34 34
35/* 35/*
36 * Interrupt source definitions 36 * Interrupt source definitions
37 Event Source Core Event Name 37 * Event Source Core Event Name
38Core Emulation ** 38 * Core Emulation **
39 Events (highest priority) EMU 0 39 * Events (highest priority) EMU 0
40 Reset RST 1 40 * Reset RST 1
41 NMI NMI 2 41 * NMI NMI 2
42 Exception EVX 3 42 * Exception EVX 3
43 Reserved -- 4 43 * Reserved -- 4
44 Hardware Error IVHW 5 44 * Hardware Error IVHW 5
45 Core Timer IVTMR 6 * 45 * Core Timer IVTMR 6
46 46 * .....
47..... 47 *
48 48 * Softirq IVG14
49 Software Interrupt 1 IVG14 31 49 * System Call --
50 Software Interrupt 2 -- 50 * (lowest priority) IVG15
51 (lowest priority) IVG15 32 *
52 */ 51 */
53 52
54#define SYS_IRQS 41 53#define SYS_IRQS 39
55#define NR_PERI_INTS 32 54#define NR_PERI_INTS 32
56 55
57/* The ABSTRACT IRQ definitions */ 56/* The ABSTRACT IRQ definitions */
@@ -95,10 +94,8 @@ Core Emulation **
95#define IRQ_PORTG_INTB 35 /* PF Port G (PF15:0) Interrupt B */ 94#define IRQ_PORTG_INTB 35 /* PF Port G (PF15:0) Interrupt B */
96#define IRQ_MEM_DMA0 36 /*(Memory DMA Stream 0) */ 95#define IRQ_MEM_DMA0 36 /*(Memory DMA Stream 0) */
97#define IRQ_MEM_DMA1 37 /*(Memory DMA Stream 1) */ 96#define IRQ_MEM_DMA1 37 /*(Memory DMA Stream 1) */
98#define IRQ_PROG_INTB 38 /* PF Ports F (PF15:0) Interrupt B */ 97#define IRQ_PROG_INTB 38 /* PF Ports F (PF15:0) Interrupt B */
99#define IRQ_WATCH 38 /*Watch Dog Timer */ 98#define IRQ_WATCH 38 /*Watch Dog Timer */
100#define IRQ_SW_INT1 40 /*Software Int 1 */
101#define IRQ_SW_INT2 41 /*Software Int 2 (reserved for SYSCALL) */
102 99
103#define IRQ_PPI_ERROR 42 /*PPI Error Interrupt */ 100#define IRQ_PPI_ERROR 42 /*PPI Error Interrupt */
104#define IRQ_CAN_ERROR 43 /*CAN Error Interrupt */ 101#define IRQ_CAN_ERROR 43 /*CAN Error Interrupt */
diff --git a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
index 6547027cd3e6..5eb46a77d919 100644
--- a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
@@ -54,6 +54,9 @@
54#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v) 54#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
55#define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v) 55#define UART_PUT_MCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_MCR),v)
56 56
57#define UART_SET_DLAB(uart) /* MMRs not muxed on BF54x */
58#define UART_CLEAR_DLAB(uart) /* MMRs not muxed on BF54x */
59
57#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS) 60#if defined(CONFIG_BFIN_UART0_CTSRTS) || defined(CONFIG_BFIN_UART1_CTSRTS)
58# define CONFIG_SERIAL_BFIN_CTSRTS 61# define CONFIG_SERIAL_BFIN_CTSRTS
59 62
diff --git a/include/asm-blackfin/mach-bf548/defBF54x_base.h b/include/asm-blackfin/mach-bf548/defBF54x_base.h
index 08f90c21fe8a..e022e896cb18 100644
--- a/include/asm-blackfin/mach-bf548/defBF54x_base.h
+++ b/include/asm-blackfin/mach-bf548/defBF54x_base.h
@@ -2329,6 +2329,26 @@
2329#define KPADWE 0x1000 /* Keypad Wake-Up Enable */ 2329#define KPADWE 0x1000 /* Keypad Wake-Up Enable */
2330#define ROTWE 0x2000 /* Rotary Wake-Up Enable */ 2330#define ROTWE 0x2000 /* Rotary Wake-Up Enable */
2331 2331
2332#define FREQ_333 0x0001 /* Switching Frequency Is 333 kHz */
2333#define FREQ_667 0x0002 /* Switching Frequency Is 667 kHz */
2334#define FREQ_1000 0x0003 /* Switching Frequency Is 1 MHz */
2335
2336#define GAIN_5 0x0000 /* GAIN = 5*/
2337#define GAIN_10 0x0004 /* GAIN = 1*/
2338#define GAIN_20 0x0008 /* GAIN = 2*/
2339#define GAIN_50 0x000C /* GAIN = 5*/
2340
2341#define VLEV_085 0x0060 /* VLEV = 0.85 V (-5% - +10% Accuracy) */
2342#define VLEV_090 0x0070 /* VLEV = 0.90 V (-5% - +10% Accuracy) */
2343#define VLEV_095 0x0080 /* VLEV = 0.95 V (-5% - +10% Accuracy) */
2344#define VLEV_100 0x0090 /* VLEV = 1.00 V (-5% - +10% Accuracy) */
2345#define VLEV_105 0x00A0 /* VLEV = 1.05 V (-5% - +10% Accuracy) */
2346#define VLEV_110 0x00B0 /* VLEV = 1.10 V (-5% - +10% Accuracy) */
2347#define VLEV_115 0x00C0 /* VLEV = 1.15 V (-5% - +10% Accuracy) */
2348#define VLEV_120 0x00D0 /* VLEV = 1.20 V (-5% - +10% Accuracy) */
2349#define VLEV_125 0x00E0 /* VLEV = 1.25 V (-5% - +10% Accuracy) */
2350#define VLEV_130 0x00F0 /* VLEV = 1.30 V (-5% - +10% Accuracy) */
2351
2332/* Bit masks for NFC_CTL */ 2352/* Bit masks for NFC_CTL */
2333 2353
2334#define WR_DLY 0xf /* Write Strobe Delay */ 2354#define WR_DLY 0xf /* Write Strobe Delay */
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
index 8a4e66d1db37..7a9628769296 100644
--- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
@@ -44,10 +44,15 @@
44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v) 44#define UART_PUT_CHAR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_THR),v)
45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v) 45#define UART_PUT_DLL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLL),v)
46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v) 46#define UART_PUT_IER(uart,v) bfin_write16(((uart)->port.membase + OFFSET_IER),v)
47#define UART_SET_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) | (v))
48#define UART_CLEAR_IER(uart,v) UART_PUT_IER(uart, UART_GET_IER(uart) & ~(v))
47#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v) 49#define UART_PUT_DLH(uart,v) bfin_write16(((uart)->port.membase + OFFSET_DLH),v)
48#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v) 50#define UART_PUT_LCR(uart,v) bfin_write16(((uart)->port.membase + OFFSET_LCR),v)
49#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v) 51#define UART_PUT_GCTL(uart,v) bfin_write16(((uart)->port.membase + OFFSET_GCTL),v)
50 52
53#define UART_SET_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) | DLAB); SSYNC(); } while (0)
54#define UART_CLEAR_DLAB(uart) do { UART_PUT_LCR(uart, UART_GET_LCR(uart) & ~DLAB); SSYNC(); } while (0)
55
51#ifdef CONFIG_BFIN_UART0_CTSRTS 56#ifdef CONFIG_BFIN_UART0_CTSRTS
52# define CONFIG_SERIAL_BFIN_CTSRTS 57# define CONFIG_SERIAL_BFIN_CTSRTS
53# ifndef CONFIG_UART0_CTS_PIN 58# ifndef CONFIG_UART0_CTS_PIN
diff --git a/include/asm-blackfin/mach-bf561/defBF561.h b/include/asm-blackfin/mach-bf561/defBF561.h
index 366c9b9a0cb7..1ab50e906fe7 100644
--- a/include/asm-blackfin/mach-bf561/defBF561.h
+++ b/include/asm-blackfin/mach-bf561/defBF561.h
@@ -868,6 +868,34 @@
868#define CHIPID_FAMILY 0x0FFFF000 868#define CHIPID_FAMILY 0x0FFFF000
869#define CHIPID_MANUFACTURE 0x00000FFE 869#define CHIPID_MANUFACTURE 0x00000FFE
870 870
871/* VR_CTL Masks */
872#define FREQ 0x0003 /* Switching Oscillator Frequency For Regulator */
873#define HIBERNATE 0x0000 /* Powerdown/Bypass On-Board Regulation */
874#define FREQ_333 0x0001 /* Switching Frequency Is 333 kHz */
875#define FREQ_667 0x0002 /* Switching Frequency Is 667 kHz */
876#define FREQ_1000 0x0003 /* Switching Frequency Is 1 MHz */
877
878#define GAIN 0x000C /* Voltage Level Gain */
879#define GAIN_5 0x0000 /* GAIN = 5*/
880#define GAIN_10 0x0004 /* GAIN = 1*/
881#define GAIN_20 0x0008 /* GAIN = 2*/
882#define GAIN_50 0x000C /* GAIN = 5*/
883
884#define VLEV 0x00F0 /* Internal Voltage Level */
885#define VLEV_085 0x0060 /* VLEV = 0.85 V (-5% - +10% Accuracy) */
886#define VLEV_090 0x0070 /* VLEV = 0.90 V (-5% - +10% Accuracy) */
887#define VLEV_095 0x0080 /* VLEV = 0.95 V (-5% - +10% Accuracy) */
888#define VLEV_100 0x0090 /* VLEV = 1.00 V (-5% - +10% Accuracy) */
889#define VLEV_105 0x00A0 /* VLEV = 1.05 V (-5% - +10% Accuracy) */
890#define VLEV_110 0x00B0 /* VLEV = 1.10 V (-5% - +10% Accuracy) */
891#define VLEV_115 0x00C0 /* VLEV = 1.15 V (-5% - +10% Accuracy) */
892#define VLEV_120 0x00D0 /* VLEV = 1.20 V (-5% - +10% Accuracy) */
893#define VLEV_125 0x00E0 /* VLEV = 1.25 V (-5% - +10% Accuracy) */
894#define VLEV_130 0x00F0 /* VLEV = 1.30 V (-5% - +10% Accuracy) */
895
896#define WAKE 0x0100 /* Enable RTC/Reset Wakeup From Hibernate */
897#define SCKELOW 0x8000 /* Do Not Drive SCKE High During Reset After Hibernate */
898
871/* PLL_DIV Masks */ 899/* PLL_DIV Masks */
872#define SCLK_DIV(x) (x) /* SCLK = VCO / x */ 900#define SCLK_DIV(x) (x) /* SCLK = VCO / x */
873 901
diff --git a/include/asm-blackfin/mach-bf561/irq.h b/include/asm-blackfin/mach-bf561/irq.h
index 83f0383957d2..6698389c5564 100644
--- a/include/asm-blackfin/mach-bf561/irq.h
+++ b/include/asm-blackfin/mach-bf561/irq.h
@@ -118,12 +118,13 @@
118 Supplemental interrupt 0 IVG7 69 118 Supplemental interrupt 0 IVG7 69
119 supplemental interrupt 1 IVG7 70 119 supplemental interrupt 1 IVG7 70
120 120
121 Software Interrupt 1 IVG14 71 121 Softirq IVG14
122 Software Interrupt 2 IVG15 72 * 122 System Call --
123 (lowest priority) 123 (lowest priority) IVG15
124
124 **********************************************************************/ 125 **********************************************************************/
125 126
126#define SYS_IRQS 72 127#define SYS_IRQS 71
127#define NR_PERI_INTS 64 128#define NR_PERI_INTS 64
128 129
129/* 130/*
@@ -237,9 +238,7 @@
237#define IRQ_RESERVED_2 (IVG_BASE + 61) /* Reserved interrupt */ 238#define IRQ_RESERVED_2 (IVG_BASE + 61) /* Reserved interrupt */
238#define IRQ_SUPPLE_0 (IVG_BASE + 62) /* Supplemental interrupt 0 */ 239#define IRQ_SUPPLE_0 (IVG_BASE + 62) /* Supplemental interrupt 0 */
239#define IRQ_SUPPLE_1 (IVG_BASE + 63) /* supplemental interrupt 1 */ 240#define IRQ_SUPPLE_1 (IVG_BASE + 63) /* supplemental interrupt 1 */
240#define IRQ_SW_INT1 71 /* Software Interrupt 1 */ 241
241#define IRQ_SW_INT2 72 /* Software Interrupt 2 */
242 /* reserved for SYSCALL */
243#define IRQ_PF0 73 242#define IRQ_PF0 73
244#define IRQ_PF1 74 243#define IRQ_PF1 74
245#define IRQ_PF2 75 244#define IRQ_PF2 75
diff --git a/include/asm-blackfin/mach-common/context.S b/include/asm-blackfin/mach-common/context.S
index fd0ebe1862b8..c0e630edfb9a 100644
--- a/include/asm-blackfin/mach-common/context.S
+++ b/include/asm-blackfin/mach-common/context.S
@@ -28,6 +28,11 @@
28 */ 28 */
29 29
30/* 30/*
31 * NOTE! The single-stepping code assumes that all interrupt handlers
32 * start by saving SYSCFG on the stack with their first instruction.
33 */
34
35/*
31 * Code to save processor context. 36 * Code to save processor context.
32 * We even save the register which are preserved by a function call 37 * We even save the register which are preserved by a function call
33 * - r4, r5, r6, r7, p3, p4, p5 38 * - r4, r5, r6, r7, p3, p4, p5
diff --git a/include/asm-blackfin/time.h b/include/asm-blackfin/time.h
index 6e5859b6ea32..ddc43ce38533 100644
--- a/include/asm-blackfin/time.h
+++ b/include/asm-blackfin/time.h
@@ -24,6 +24,8 @@
24 24
25#ifndef CONFIG_CPU_FREQ 25#ifndef CONFIG_CPU_FREQ
26#define TIME_SCALE 1 26#define TIME_SCALE 1
27#define __bfin_cycles_off (0)
28#define __bfin_cycles_mod (0)
27#else 29#else
28/* 30/*
29 * Blackfin CPU frequency scaling supports max Core Clock 1, 1/2 and 1/4 . 31 * Blackfin CPU frequency scaling supports max Core Clock 1, 1/2 and 1/4 .
@@ -31,6 +33,8 @@
31 * adjust the Core Timer Presale Register. This way we don't lose time. 33 * adjust the Core Timer Presale Register. This way we don't lose time.
32 */ 34 */
33#define TIME_SCALE 4 35#define TIME_SCALE 4
36extern unsigned long long __bfin_cycles_off;
37extern unsigned int __bfin_cycles_mod;
34#endif 38#endif
35 39
36#endif 40#endif
diff --git a/include/asm-frv/system.h b/include/asm-frv/system.h
index cb307f8a6b48..d3a12a9079f7 100644
--- a/include/asm-frv/system.h
+++ b/include/asm-frv/system.h
@@ -179,7 +179,7 @@ do { \
179#define mb() asm volatile ("membar" : : :"memory") 179#define mb() asm volatile ("membar" : : :"memory")
180#define rmb() asm volatile ("membar" : : :"memory") 180#define rmb() asm volatile ("membar" : : :"memory")
181#define wmb() asm volatile ("membar" : : :"memory") 181#define wmb() asm volatile ("membar" : : :"memory")
182#define read_barrier_depends() barrier() 182#define read_barrier_depends() do { } while (0)
183 183
184#ifdef CONFIG_SMP 184#ifdef CONFIG_SMP
185#define smp_mb() mb() 185#define smp_mb() mb()
diff --git a/include/asm-h8300/param.h b/include/asm-h8300/param.h
index 04f64f100379..1c72fb8080ff 100644
--- a/include/asm-h8300/param.h
+++ b/include/asm-h8300/param.h
@@ -1,14 +1,12 @@
1#ifndef _H8300_PARAM_H 1#ifndef _H8300_PARAM_H
2#define _H8300_PARAM_H 2#define _H8300_PARAM_H
3 3
4
5#ifndef HZ
6#define HZ CONFIG_HZ
7#endif
8
9#ifdef __KERNEL__ 4#ifdef __KERNEL__
5#define HZ CONFIG_HZ
10#define USER_HZ HZ 6#define USER_HZ HZ
11#define CLOCKS_PER_SEC (USER_HZ) 7#define CLOCKS_PER_SEC (USER_HZ)
8#else
9#define HZ 100
12#endif 10#endif
13 11
14#define EXEC_PAGESIZE 4096 12#define EXEC_PAGESIZE 4096
diff --git a/include/asm-m68k/machw.h b/include/asm-m68k/machw.h
index d2e0e25d5c90..35624998291c 100644
--- a/include/asm-m68k/machw.h
+++ b/include/asm-m68k/machw.h
@@ -66,36 +66,6 @@ struct MAC_SCC
66# define mac_scc ((*(volatile struct SCC*)MAC_SCC_BAS)) 66# define mac_scc ((*(volatile struct SCC*)MAC_SCC_BAS))
67#endif 67#endif
68 68
69/* hardware stuff */
70
71#define MACHW_DECLARE(name) unsigned name : 1
72#define MACHW_SET(name) (mac_hw_present.name = 1)
73#define MACHW_PRESENT(name) (mac_hw_present.name)
74
75struct mac_hw_present {
76 /* video hardware */
77 /* sound hardware */
78 /* disk storage interfaces */
79 MACHW_DECLARE(MAC_SCSI_80); /* Directly mapped NCR5380 */
80 MACHW_DECLARE(MAC_SCSI_96); /* 53c9[46] */
81 MACHW_DECLARE(MAC_SCSI_96_2); /* 2nd 53c9[46] Q900 and Q950 */
82 MACHW_DECLARE(IDE); /* IDE Interface */
83 /* other I/O hardware */
84 MACHW_DECLARE(SCC); /* Serial Communications Contr. */
85 /* DMA */
86 MACHW_DECLARE(SCSI_DMA); /* DMA for the NCR5380 */
87 /* real time clocks */
88 MACHW_DECLARE(RTC_CLK); /* clock chip */
89 /* supporting hardware */
90 MACHW_DECLARE(VIA1); /* Versatile Interface Ad. 1 */
91 MACHW_DECLARE(VIA2); /* Versatile Interface Ad. 2 */
92 MACHW_DECLARE(RBV); /* Versatile Interface Ad. 2+ */
93 /* NUBUS */
94 MACHW_DECLARE(NUBUS); /* NUBUS */
95};
96
97extern struct mac_hw_present mac_hw_present;
98
99#endif /* __ASSEMBLY__ */ 69#endif /* __ASSEMBLY__ */
100 70
101#endif /* linux/machw.h */ 71#endif /* linux/machw.h */
diff --git a/include/asm-mips/bitops.h b/include/asm-mips/bitops.h
index c2bd126c3b4e..642724734eba 100644
--- a/include/asm-mips/bitops.h
+++ b/include/asm-mips/bitops.h
@@ -558,11 +558,13 @@ static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *
558 __clear_bit(nr, addr); 558 __clear_bit(nr, addr);
559} 559}
560 560
561#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
562
561/* 563/*
562 * Return the bit position (0..63) of the most significant 1 bit in a word 564 * Return the bit position (0..63) of the most significant 1 bit in a word
563 * Returns -1 if no 1 bit exists 565 * Returns -1 if no 1 bit exists
564 */ 566 */
565static inline int __ilog2(unsigned long x) 567static inline unsigned long __fls(unsigned long x)
566{ 568{
567 int lz; 569 int lz;
568 570
@@ -591,13 +593,6 @@ static inline int __ilog2(unsigned long x)
591 return 63 - lz; 593 return 63 - lz;
592} 594}
593 595
594static inline unsigned long __fls(unsigned long x)
595{
596 return __ilog2(x);
597}
598
599#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
600
601/* 596/*
602 * __ffs - find first bit in word. 597 * __ffs - find first bit in word.
603 * @word: The word to search 598 * @word: The word to search
@@ -607,7 +602,7 @@ static inline unsigned long __fls(unsigned long x)
607 */ 602 */
608static inline unsigned long __ffs(unsigned long word) 603static inline unsigned long __ffs(unsigned long word)
609{ 604{
610 return __ilog2(word & -word); 605 return __fls(word & -word);
611} 606}
612 607
613/* 608/*
@@ -654,6 +649,7 @@ static inline int ffs(int word)
654#else 649#else
655 650
656#include <asm-generic/bitops/__ffs.h> 651#include <asm-generic/bitops/__ffs.h>
652#include <asm-generic/bitops/__fls.h>
657#include <asm-generic/bitops/ffs.h> 653#include <asm-generic/bitops/ffs.h>
658#include <asm-generic/bitops/fls.h> 654#include <asm-generic/bitops/fls.h>
659#include <asm-generic/bitops/fls64.h> 655#include <asm-generic/bitops/fls64.h>
diff --git a/include/asm-mips/compiler.h b/include/asm-mips/compiler.h
index aa6b876bbd78..71f5c5cfc58a 100644
--- a/include/asm-mips/compiler.h
+++ b/include/asm-mips/compiler.h
@@ -9,10 +9,10 @@
9#define _ASM_COMPILER_H 9#define _ASM_COMPILER_H
10 10
11#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 11#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
12#define GCC_IMM_ASM "n" 12#define GCC_IMM_ASM() "n"
13#define GCC_REG_ACCUM "$0" 13#define GCC_REG_ACCUM "$0"
14#else 14#else
15#define GCC_IMM_ASM "rn" 15#define GCC_IMM_ASM() "rn"
16#define GCC_REG_ACCUM "accum" 16#define GCC_REG_ACCUM "accum"
17#endif 17#endif
18 18
diff --git a/include/asm-mips/mach-au1x00/au1000.h b/include/asm-mips/mach-au1x00/au1000.h
index a05555165d05..363a14ee0ae5 100644
--- a/include/asm-mips/mach-au1x00/au1000.h
+++ b/include/asm-mips/mach-au1x00/au1000.h
@@ -40,8 +40,8 @@
40#include <linux/delay.h> 40#include <linux/delay.h>
41#include <linux/types.h> 41#include <linux/types.h>
42 42
43#include <asm/io.h> 43#include <linux/io.h>
44#include <asm/irq.h> 44#include <linux/irq.h>
45 45
46/* cpu pipeline flush */ 46/* cpu pipeline flush */
47void static inline au_sync(void) 47void static inline au_sync(void)
@@ -63,32 +63,32 @@ void static inline au_sync_delay(int ms)
63 63
64void static inline au_writeb(u8 val, unsigned long reg) 64void static inline au_writeb(u8 val, unsigned long reg)
65{ 65{
66 *(volatile u8 *)(reg) = val; 66 *(volatile u8 *)reg = val;
67} 67}
68 68
69void static inline au_writew(u16 val, unsigned long reg) 69void static inline au_writew(u16 val, unsigned long reg)
70{ 70{
71 *(volatile u16 *)(reg) = val; 71 *(volatile u16 *)reg = val;
72} 72}
73 73
74void static inline au_writel(u32 val, unsigned long reg) 74void static inline au_writel(u32 val, unsigned long reg)
75{ 75{
76 *(volatile u32 *)(reg) = val; 76 *(volatile u32 *)reg = val;
77} 77}
78 78
79static inline u8 au_readb(unsigned long reg) 79static inline u8 au_readb(unsigned long reg)
80{ 80{
81 return (*(volatile u8 *)reg); 81 return *(volatile u8 *)reg;
82} 82}
83 83
84static inline u16 au_readw(unsigned long reg) 84static inline u16 au_readw(unsigned long reg)
85{ 85{
86 return (*(volatile u16 *)reg); 86 return *(volatile u16 *)reg;
87} 87}
88 88
89static inline u32 au_readl(unsigned long reg) 89static inline u32 au_readl(unsigned long reg)
90{ 90{
91 return (*(volatile u32 *)reg); 91 return *(volatile u32 *)reg;
92} 92}
93 93
94 94
@@ -117,76 +117,77 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
117#endif /* !defined (_LANGUAGE_ASSEMBLY) */ 117#endif /* !defined (_LANGUAGE_ASSEMBLY) */
118 118
119/* 119/*
120 * SDRAM Register Offsets 120 * SDRAM register offsets
121 */ 121 */
122#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1100) 122#if defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1500) || \
123#define MEM_SDMODE0 (0x0000) 123 defined(CONFIG_SOC_AU1100)
124#define MEM_SDMODE1 (0x0004) 124#define MEM_SDMODE0 0x0000
125#define MEM_SDMODE2 (0x0008) 125#define MEM_SDMODE1 0x0004
126#define MEM_SDADDR0 (0x000C) 126#define MEM_SDMODE2 0x0008
127#define MEM_SDADDR1 (0x0010) 127#define MEM_SDADDR0 0x000C
128#define MEM_SDADDR2 (0x0014) 128#define MEM_SDADDR1 0x0010
129#define MEM_SDREFCFG (0x0018) 129#define MEM_SDADDR2 0x0014
130#define MEM_SDPRECMD (0x001C) 130#define MEM_SDREFCFG 0x0018
131#define MEM_SDAUTOREF (0x0020) 131#define MEM_SDPRECMD 0x001C
132#define MEM_SDWRMD0 (0x0024) 132#define MEM_SDAUTOREF 0x0020
133#define MEM_SDWRMD1 (0x0028) 133#define MEM_SDWRMD0 0x0024
134#define MEM_SDWRMD2 (0x002C) 134#define MEM_SDWRMD1 0x0028
135#define MEM_SDSLEEP (0x0030) 135#define MEM_SDWRMD2 0x002C
136#define MEM_SDSMCKE (0x0034) 136#define MEM_SDSLEEP 0x0030
137#define MEM_SDSMCKE 0x0034
137 138
138/* 139/*
139 * MEM_SDMODE register content definitions 140 * MEM_SDMODE register content definitions
140 */ 141 */
141#define MEM_SDMODE_F (1<<22) 142#define MEM_SDMODE_F (1 << 22)
142#define MEM_SDMODE_SR (1<<21) 143#define MEM_SDMODE_SR (1 << 21)
143#define MEM_SDMODE_BS (1<<20) 144#define MEM_SDMODE_BS (1 << 20)
144#define MEM_SDMODE_RS (3<<18) 145#define MEM_SDMODE_RS (3 << 18)
145#define MEM_SDMODE_CS (7<<15) 146#define MEM_SDMODE_CS (7 << 15)
146#define MEM_SDMODE_TRAS (15<<11) 147#define MEM_SDMODE_TRAS (15 << 11)
147#define MEM_SDMODE_TMRD (3<<9) 148#define MEM_SDMODE_TMRD (3 << 9)
148#define MEM_SDMODE_TWR (3<<7) 149#define MEM_SDMODE_TWR (3 << 7)
149#define MEM_SDMODE_TRP (3<<5) 150#define MEM_SDMODE_TRP (3 << 5)
150#define MEM_SDMODE_TRCD (3<<3) 151#define MEM_SDMODE_TRCD (3 << 3)
151#define MEM_SDMODE_TCL (7<<0) 152#define MEM_SDMODE_TCL (7 << 0)
152 153
153#define MEM_SDMODE_BS_2Bank (0<<20) 154#define MEM_SDMODE_BS_2Bank (0 << 20)
154#define MEM_SDMODE_BS_4Bank (1<<20) 155#define MEM_SDMODE_BS_4Bank (1 << 20)
155#define MEM_SDMODE_RS_11Row (0<<18) 156#define MEM_SDMODE_RS_11Row (0 << 18)
156#define MEM_SDMODE_RS_12Row (1<<18) 157#define MEM_SDMODE_RS_12Row (1 << 18)
157#define MEM_SDMODE_RS_13Row (2<<18) 158#define MEM_SDMODE_RS_13Row (2 << 18)
158#define MEM_SDMODE_RS_N(N) ((N)<<18) 159#define MEM_SDMODE_RS_N(N) ((N) << 18)
159#define MEM_SDMODE_CS_7Col (0<<15) 160#define MEM_SDMODE_CS_7Col (0 << 15)
160#define MEM_SDMODE_CS_8Col (1<<15) 161#define MEM_SDMODE_CS_8Col (1 << 15)
161#define MEM_SDMODE_CS_9Col (2<<15) 162#define MEM_SDMODE_CS_9Col (2 << 15)
162#define MEM_SDMODE_CS_10Col (3<<15) 163#define MEM_SDMODE_CS_10Col (3 << 15)
163#define MEM_SDMODE_CS_11Col (4<<15) 164#define MEM_SDMODE_CS_11Col (4 << 15)
164#define MEM_SDMODE_CS_N(N) ((N)<<15) 165#define MEM_SDMODE_CS_N(N) ((N) << 15)
165#define MEM_SDMODE_TRAS_N(N) ((N)<<11) 166#define MEM_SDMODE_TRAS_N(N) ((N) << 11)
166#define MEM_SDMODE_TMRD_N(N) ((N)<<9) 167#define MEM_SDMODE_TMRD_N(N) ((N) << 9)
167#define MEM_SDMODE_TWR_N(N) ((N)<<7) 168#define MEM_SDMODE_TWR_N(N) ((N) << 7)
168#define MEM_SDMODE_TRP_N(N) ((N)<<5) 169#define MEM_SDMODE_TRP_N(N) ((N) << 5)
169#define MEM_SDMODE_TRCD_N(N) ((N)<<3) 170#define MEM_SDMODE_TRCD_N(N) ((N) << 3)
170#define MEM_SDMODE_TCL_N(N) ((N)<<0) 171#define MEM_SDMODE_TCL_N(N) ((N) << 0)
171 172
172/* 173/*
173 * MEM_SDADDR register contents definitions 174 * MEM_SDADDR register contents definitions
174 */ 175 */
175#define MEM_SDADDR_E (1<<20) 176#define MEM_SDADDR_E (1 << 20)
176#define MEM_SDADDR_CSBA (0x03FF<<10) 177#define MEM_SDADDR_CSBA (0x03FF << 10)
177#define MEM_SDADDR_CSMASK (0x03FF<<0) 178#define MEM_SDADDR_CSMASK (0x03FF << 0)
178#define MEM_SDADDR_CSBA_N(N) ((N)&(0x03FF<<22)>>12) 179#define MEM_SDADDR_CSBA_N(N) ((N) & (0x03FF << 22) >> 12)
179#define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF<<22)>>22) 180#define MEM_SDADDR_CSMASK_N(N) ((N)&(0x03FF << 22) >> 22)
180 181
181/* 182/*
182 * MEM_SDREFCFG register content definitions 183 * MEM_SDREFCFG register content definitions
183 */ 184 */
184#define MEM_SDREFCFG_TRC (15<<28) 185#define MEM_SDREFCFG_TRC (15 << 28)
185#define MEM_SDREFCFG_TRPM (3<<26) 186#define MEM_SDREFCFG_TRPM (3 << 26)
186#define MEM_SDREFCFG_E (1<<25) 187#define MEM_SDREFCFG_E (1 << 25)
187#define MEM_SDREFCFG_RE (0x1ffffff<<0) 188#define MEM_SDREFCFG_RE (0x1ffffff << 0)
188#define MEM_SDREFCFG_TRC_N(N) ((N)<<MEM_SDREFCFG_TRC) 189#define MEM_SDREFCFG_TRC_N(N) ((N) << MEM_SDREFCFG_TRC)
189#define MEM_SDREFCFG_TRPM_N(N) ((N)<<MEM_SDREFCFG_TRPM) 190#define MEM_SDREFCFG_TRPM_N(N) ((N) << MEM_SDREFCFG_TRPM)
190#define MEM_SDREFCFG_REF_N(N) (N) 191#define MEM_SDREFCFG_REF_N(N) (N)
191#endif 192#endif
192 193
@@ -199,25 +200,25 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
199/***********************************************************************/ 200/***********************************************************************/
200 201
201#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) 202#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
202#define MEM_SDMODE0 (0x0800) 203#define MEM_SDMODE0 0x0800
203#define MEM_SDMODE1 (0x0808) 204#define MEM_SDMODE1 0x0808
204#define MEM_SDMODE2 (0x0810) 205#define MEM_SDMODE2 0x0810
205#define MEM_SDADDR0 (0x0820) 206#define MEM_SDADDR0 0x0820
206#define MEM_SDADDR1 (0x0828) 207#define MEM_SDADDR1 0x0828
207#define MEM_SDADDR2 (0x0830) 208#define MEM_SDADDR2 0x0830
208#define MEM_SDCONFIGA (0x0840) 209#define MEM_SDCONFIGA 0x0840
209#define MEM_SDCONFIGB (0x0848) 210#define MEM_SDCONFIGB 0x0848
210#define MEM_SDSTAT (0x0850) 211#define MEM_SDSTAT 0x0850
211#define MEM_SDERRADDR (0x0858) 212#define MEM_SDERRADDR 0x0858
212#define MEM_SDSTRIDE0 (0x0860) 213#define MEM_SDSTRIDE0 0x0860
213#define MEM_SDSTRIDE1 (0x0868) 214#define MEM_SDSTRIDE1 0x0868
214#define MEM_SDSTRIDE2 (0x0870) 215#define MEM_SDSTRIDE2 0x0870
215#define MEM_SDWRMD0 (0x0880) 216#define MEM_SDWRMD0 0x0880
216#define MEM_SDWRMD1 (0x0888) 217#define MEM_SDWRMD1 0x0888
217#define MEM_SDWRMD2 (0x0890) 218#define MEM_SDWRMD2 0x0890
218#define MEM_SDPRECMD (0x08C0) 219#define MEM_SDPRECMD 0x08C0
219#define MEM_SDAUTOREF (0x08C8) 220#define MEM_SDAUTOREF 0x08C8
220#define MEM_SDSREF (0x08D0) 221#define MEM_SDSREF 0x08D0
221#define MEM_SDSLEEP MEM_SDSREF 222#define MEM_SDSLEEP MEM_SDSREF
222 223
223#endif 224#endif
@@ -256,9 +257,9 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
256#define SSI0_PHYS_ADDR 0x11600000 257#define SSI0_PHYS_ADDR 0x11600000
257#define SSI1_PHYS_ADDR 0x11680000 258#define SSI1_PHYS_ADDR 0x11680000
258#define SYS_PHYS_ADDR 0x11900000 259#define SYS_PHYS_ADDR 0x11900000
259#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 260#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
260#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 261#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
261#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 262#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
262#endif 263#endif
263 264
264/********************************************************************/ 265/********************************************************************/
@@ -290,13 +291,13 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
290#define UART3_PHYS_ADDR 0x11400000 291#define UART3_PHYS_ADDR 0x11400000
291#define GPIO2_PHYS_ADDR 0x11700000 292#define GPIO2_PHYS_ADDR 0x11700000
292#define SYS_PHYS_ADDR 0x11900000 293#define SYS_PHYS_ADDR 0x11900000
293#define PCI_MEM_PHYS_ADDR 0x400000000ULL 294#define PCI_MEM_PHYS_ADDR 0x400000000ULL
294#define PCI_IO_PHYS_ADDR 0x500000000ULL 295#define PCI_IO_PHYS_ADDR 0x500000000ULL
295#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL 296#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL
296#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL 297#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL
297#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 298#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
298#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 299#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
299#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 300#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
300#endif 301#endif
301 302
302/********************************************************************/ 303/********************************************************************/
@@ -333,9 +334,9 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
333#define GPIO2_PHYS_ADDR 0x11700000 334#define GPIO2_PHYS_ADDR 0x11700000
334#define SYS_PHYS_ADDR 0x11900000 335#define SYS_PHYS_ADDR 0x11900000
335#define LCD_PHYS_ADDR 0x15000000 336#define LCD_PHYS_ADDR 0x15000000
336#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 337#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
337#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 338#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
338#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 339#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
339#endif 340#endif
340 341
341/***********************************************************************/ 342/***********************************************************************/
@@ -360,17 +361,17 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
360#define SYS_PHYS_ADDR 0x11900000 361#define SYS_PHYS_ADDR 0x11900000
361#define DDMA_PHYS_ADDR 0x14002000 362#define DDMA_PHYS_ADDR 0x14002000
362#define PE_PHYS_ADDR 0x14008000 363#define PE_PHYS_ADDR 0x14008000
363#define PSC0_PHYS_ADDR 0x11A00000 364#define PSC0_PHYS_ADDR 0x11A00000
364#define PSC1_PHYS_ADDR 0x11B00000 365#define PSC1_PHYS_ADDR 0x11B00000
365#define PSC2_PHYS_ADDR 0x10A00000 366#define PSC2_PHYS_ADDR 0x10A00000
366#define PSC3_PHYS_ADDR 0x10B00000 367#define PSC3_PHYS_ADDR 0x10B00000
367#define PCI_MEM_PHYS_ADDR 0x400000000ULL 368#define PCI_MEM_PHYS_ADDR 0x400000000ULL
368#define PCI_IO_PHYS_ADDR 0x500000000ULL 369#define PCI_IO_PHYS_ADDR 0x500000000ULL
369#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL 370#define PCI_CONFIG0_PHYS_ADDR 0x600000000ULL
370#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL 371#define PCI_CONFIG1_PHYS_ADDR 0x680000000ULL
371#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 372#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
372#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 373#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
373#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 374#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
374#endif 375#endif
375 376
376/***********************************************************************/ 377/***********************************************************************/
@@ -397,122 +398,121 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
397#define SWCNT_PHYS_ADDR 0x1110010C 398#define SWCNT_PHYS_ADDR 0x1110010C
398#define MAEFE_PHYS_ADDR 0x14012000 399#define MAEFE_PHYS_ADDR 0x14012000
399#define MAEBE_PHYS_ADDR 0x14010000 400#define MAEBE_PHYS_ADDR 0x14010000
400#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL 401#define PCMCIA_IO_PHYS_ADDR 0xF00000000ULL
401#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL 402#define PCMCIA_ATTR_PHYS_ADDR 0xF40000000ULL
402#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL 403#define PCMCIA_MEM_PHYS_ADDR 0xF80000000ULL
403#endif 404#endif
404 405
405
406/* Static Bus Controller */ 406/* Static Bus Controller */
407#define MEM_STCFG0 0xB4001000 407#define MEM_STCFG0 0xB4001000
408#define MEM_STTIME0 0xB4001004 408#define MEM_STTIME0 0xB4001004
409#define MEM_STADDR0 0xB4001008 409#define MEM_STADDR0 0xB4001008
410 410
411#define MEM_STCFG1 0xB4001010 411#define MEM_STCFG1 0xB4001010
412#define MEM_STTIME1 0xB4001014 412#define MEM_STTIME1 0xB4001014
413#define MEM_STADDR1 0xB4001018 413#define MEM_STADDR1 0xB4001018
414 414
415#define MEM_STCFG2 0xB4001020 415#define MEM_STCFG2 0xB4001020
416#define MEM_STTIME2 0xB4001024 416#define MEM_STTIME2 0xB4001024
417#define MEM_STADDR2 0xB4001028 417#define MEM_STADDR2 0xB4001028
418 418
419#define MEM_STCFG3 0xB4001030 419#define MEM_STCFG3 0xB4001030
420#define MEM_STTIME3 0xB4001034 420#define MEM_STTIME3 0xB4001034
421#define MEM_STADDR3 0xB4001038 421#define MEM_STADDR3 0xB4001038
422 422
423#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200) 423#if defined(CONFIG_SOC_AU1550) || defined(CONFIG_SOC_AU1200)
424#define MEM_STNDCTL 0xB4001100 424#define MEM_STNDCTL 0xB4001100
425#define MEM_STSTAT 0xB4001104 425#define MEM_STSTAT 0xB4001104
426 426
427#define MEM_STNAND_CMD (0x0) 427#define MEM_STNAND_CMD 0x0
428#define MEM_STNAND_ADDR (0x4) 428#define MEM_STNAND_ADDR 0x4
429#define MEM_STNAND_DATA (0x20) 429#define MEM_STNAND_DATA 0x20
430#endif 430#endif
431 431
432/* Interrupt Controller 0 */ 432/* Interrupt Controller 0 */
433#define IC0_CFG0RD 0xB0400040 433#define IC0_CFG0RD 0xB0400040
434#define IC0_CFG0SET 0xB0400040 434#define IC0_CFG0SET 0xB0400040
435#define IC0_CFG0CLR 0xB0400044 435#define IC0_CFG0CLR 0xB0400044
436 436
437#define IC0_CFG1RD 0xB0400048 437#define IC0_CFG1RD 0xB0400048
438#define IC0_CFG1SET 0xB0400048 438#define IC0_CFG1SET 0xB0400048
439#define IC0_CFG1CLR 0xB040004C 439#define IC0_CFG1CLR 0xB040004C
440 440
441#define IC0_CFG2RD 0xB0400050 441#define IC0_CFG2RD 0xB0400050
442#define IC0_CFG2SET 0xB0400050 442#define IC0_CFG2SET 0xB0400050
443#define IC0_CFG2CLR 0xB0400054 443#define IC0_CFG2CLR 0xB0400054
444 444
445#define IC0_REQ0INT 0xB0400054 445#define IC0_REQ0INT 0xB0400054
446#define IC0_SRCRD 0xB0400058 446#define IC0_SRCRD 0xB0400058
447#define IC0_SRCSET 0xB0400058 447#define IC0_SRCSET 0xB0400058
448#define IC0_SRCCLR 0xB040005C 448#define IC0_SRCCLR 0xB040005C
449#define IC0_REQ1INT 0xB040005C 449#define IC0_REQ1INT 0xB040005C
450 450
451#define IC0_ASSIGNRD 0xB0400060 451#define IC0_ASSIGNRD 0xB0400060
452#define IC0_ASSIGNSET 0xB0400060 452#define IC0_ASSIGNSET 0xB0400060
453#define IC0_ASSIGNCLR 0xB0400064 453#define IC0_ASSIGNCLR 0xB0400064
454 454
455#define IC0_WAKERD 0xB0400068 455#define IC0_WAKERD 0xB0400068
456#define IC0_WAKESET 0xB0400068 456#define IC0_WAKESET 0xB0400068
457#define IC0_WAKECLR 0xB040006C 457#define IC0_WAKECLR 0xB040006C
458 458
459#define IC0_MASKRD 0xB0400070 459#define IC0_MASKRD 0xB0400070
460#define IC0_MASKSET 0xB0400070 460#define IC0_MASKSET 0xB0400070
461#define IC0_MASKCLR 0xB0400074 461#define IC0_MASKCLR 0xB0400074
462 462
463#define IC0_RISINGRD 0xB0400078 463#define IC0_RISINGRD 0xB0400078
464#define IC0_RISINGCLR 0xB0400078 464#define IC0_RISINGCLR 0xB0400078
465#define IC0_FALLINGRD 0xB040007C 465#define IC0_FALLINGRD 0xB040007C
466#define IC0_FALLINGCLR 0xB040007C 466#define IC0_FALLINGCLR 0xB040007C
467 467
468#define IC0_TESTBIT 0xB0400080 468#define IC0_TESTBIT 0xB0400080
469 469
470/* Interrupt Controller 1 */ 470/* Interrupt Controller 1 */
471#define IC1_CFG0RD 0xB1800040 471#define IC1_CFG0RD 0xB1800040
472#define IC1_CFG0SET 0xB1800040 472#define IC1_CFG0SET 0xB1800040
473#define IC1_CFG0CLR 0xB1800044 473#define IC1_CFG0CLR 0xB1800044
474 474
475#define IC1_CFG1RD 0xB1800048 475#define IC1_CFG1RD 0xB1800048
476#define IC1_CFG1SET 0xB1800048 476#define IC1_CFG1SET 0xB1800048
477#define IC1_CFG1CLR 0xB180004C 477#define IC1_CFG1CLR 0xB180004C
478 478
479#define IC1_CFG2RD 0xB1800050 479#define IC1_CFG2RD 0xB1800050
480#define IC1_CFG2SET 0xB1800050 480#define IC1_CFG2SET 0xB1800050
481#define IC1_CFG2CLR 0xB1800054 481#define IC1_CFG2CLR 0xB1800054
482 482
483#define IC1_REQ0INT 0xB1800054 483#define IC1_REQ0INT 0xB1800054
484#define IC1_SRCRD 0xB1800058 484#define IC1_SRCRD 0xB1800058
485#define IC1_SRCSET 0xB1800058 485#define IC1_SRCSET 0xB1800058
486#define IC1_SRCCLR 0xB180005C 486#define IC1_SRCCLR 0xB180005C
487#define IC1_REQ1INT 0xB180005C 487#define IC1_REQ1INT 0xB180005C
488 488
489#define IC1_ASSIGNRD 0xB1800060 489#define IC1_ASSIGNRD 0xB1800060
490#define IC1_ASSIGNSET 0xB1800060 490#define IC1_ASSIGNSET 0xB1800060
491#define IC1_ASSIGNCLR 0xB1800064 491#define IC1_ASSIGNCLR 0xB1800064
492 492
493#define IC1_WAKERD 0xB1800068 493#define IC1_WAKERD 0xB1800068
494#define IC1_WAKESET 0xB1800068 494#define IC1_WAKESET 0xB1800068
495#define IC1_WAKECLR 0xB180006C 495#define IC1_WAKECLR 0xB180006C
496 496
497#define IC1_MASKRD 0xB1800070 497#define IC1_MASKRD 0xB1800070
498#define IC1_MASKSET 0xB1800070 498#define IC1_MASKSET 0xB1800070
499#define IC1_MASKCLR 0xB1800074 499#define IC1_MASKCLR 0xB1800074
500 500
501#define IC1_RISINGRD 0xB1800078 501#define IC1_RISINGRD 0xB1800078
502#define IC1_RISINGCLR 0xB1800078 502#define IC1_RISINGCLR 0xB1800078
503#define IC1_FALLINGRD 0xB180007C 503#define IC1_FALLINGRD 0xB180007C
504#define IC1_FALLINGCLR 0xB180007C 504#define IC1_FALLINGCLR 0xB180007C
505 505
506#define IC1_TESTBIT 0xB1800080 506#define IC1_TESTBIT 0xB1800080
507 507
508/* Interrupt Configuration Modes */ 508/* Interrupt Configuration Modes */
509#define INTC_INT_DISABLED 0 509#define INTC_INT_DISABLED 0x0
510#define INTC_INT_RISE_EDGE 0x1 510#define INTC_INT_RISE_EDGE 0x1
511#define INTC_INT_FALL_EDGE 0x2 511#define INTC_INT_FALL_EDGE 0x2
512#define INTC_INT_RISE_AND_FALL_EDGE 0x3 512#define INTC_INT_RISE_AND_FALL_EDGE 0x3
513#define INTC_INT_HIGH_LEVEL 0x5 513#define INTC_INT_HIGH_LEVEL 0x5
514#define INTC_INT_LOW_LEVEL 0x6 514#define INTC_INT_LOW_LEVEL 0x6
515#define INTC_INT_HIGH_AND_LOW_LEVEL 0x7 515#define INTC_INT_HIGH_AND_LOW_LEVEL 0x7
516 516
517/* Interrupt Numbers */ 517/* Interrupt Numbers */
518/* Au1000 */ 518/* Au1000 */
@@ -579,18 +579,18 @@ enum soc_au1000_ints {
579 AU1000_GPIO_31, 579 AU1000_GPIO_31,
580}; 580};
581 581
582#define UART0_ADDR 0xB1100000 582#define UART0_ADDR 0xB1100000
583#define UART1_ADDR 0xB1200000 583#define UART1_ADDR 0xB1200000
584#define UART2_ADDR 0xB1300000 584#define UART2_ADDR 0xB1300000
585#define UART3_ADDR 0xB1400000 585#define UART3_ADDR 0xB1400000
586 586
587#define USB_OHCI_BASE 0x10100000 // phys addr for ioremap 587#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
588#define USB_HOST_CONFIG 0xB017fffc 588#define USB_HOST_CONFIG 0xB017FFFC
589 589
590#define AU1000_ETH0_BASE 0xB0500000 590#define AU1000_ETH0_BASE 0xB0500000
591#define AU1000_ETH1_BASE 0xB0510000 591#define AU1000_ETH1_BASE 0xB0510000
592#define AU1000_MAC0_ENABLE 0xB0520000 592#define AU1000_MAC0_ENABLE 0xB0520000
593#define AU1000_MAC1_ENABLE 0xB0520004 593#define AU1000_MAC1_ENABLE 0xB0520004
594#define NUM_ETH_INTERFACES 2 594#define NUM_ETH_INTERFACES 2
595#endif /* CONFIG_SOC_AU1000 */ 595#endif /* CONFIG_SOC_AU1000 */
596 596
@@ -662,16 +662,16 @@ enum soc_au1500_ints {
662#define INTC AU1000_PCI_INTC 662#define INTC AU1000_PCI_INTC
663#define INTD AU1000_PCI_INTD 663#define INTD AU1000_PCI_INTD
664 664
665#define UART0_ADDR 0xB1100000 665#define UART0_ADDR 0xB1100000
666#define UART3_ADDR 0xB1400000 666#define UART3_ADDR 0xB1400000
667 667
668#define USB_OHCI_BASE 0x10100000 // phys addr for ioremap 668#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
669#define USB_HOST_CONFIG 0xB017fffc 669#define USB_HOST_CONFIG 0xB017fffc
670 670
671#define AU1500_ETH0_BASE 0xB1500000 671#define AU1500_ETH0_BASE 0xB1500000
672#define AU1500_ETH1_BASE 0xB1510000 672#define AU1500_ETH1_BASE 0xB1510000
673#define AU1500_MAC0_ENABLE 0xB1520000 673#define AU1500_MAC0_ENABLE 0xB1520000
674#define AU1500_MAC1_ENABLE 0xB1520004 674#define AU1500_MAC1_ENABLE 0xB1520004
675#define NUM_ETH_INTERFACES 2 675#define NUM_ETH_INTERFACES 2
676#endif /* CONFIG_SOC_AU1500 */ 676#endif /* CONFIG_SOC_AU1500 */
677 677
@@ -739,15 +739,15 @@ enum soc_au1100_ints {
739 AU1000_GPIO_31, 739 AU1000_GPIO_31,
740}; 740};
741 741
742#define UART0_ADDR 0xB1100000 742#define UART0_ADDR 0xB1100000
743#define UART1_ADDR 0xB1200000 743#define UART1_ADDR 0xB1200000
744#define UART3_ADDR 0xB1400000 744#define UART3_ADDR 0xB1400000
745 745
746#define USB_OHCI_BASE 0x10100000 // phys addr for ioremap 746#define USB_OHCI_BASE 0x10100000 /* phys addr for ioremap */
747#define USB_HOST_CONFIG 0xB017fffc 747#define USB_HOST_CONFIG 0xB017FFFC
748 748
749#define AU1100_ETH0_BASE 0xB0500000 749#define AU1100_ETH0_BASE 0xB0500000
750#define AU1100_MAC0_ENABLE 0xB0520000 750#define AU1100_MAC0_ENABLE 0xB0520000
751#define NUM_ETH_INTERFACES 1 751#define NUM_ETH_INTERFACES 1
752#endif /* CONFIG_SOC_AU1100 */ 752#endif /* CONFIG_SOC_AU1100 */
753 753
@@ -826,18 +826,18 @@ enum soc_au1550_ints {
826#define INTC AU1550_PCI_INTC 826#define INTC AU1550_PCI_INTC
827#define INTD AU1550_PCI_INTD 827#define INTD AU1550_PCI_INTD
828 828
829#define UART0_ADDR 0xB1100000 829#define UART0_ADDR 0xB1100000
830#define UART1_ADDR 0xB1200000 830#define UART1_ADDR 0xB1200000
831#define UART3_ADDR 0xB1400000 831#define UART3_ADDR 0xB1400000
832 832
833#define USB_OHCI_BASE 0x14020000 // phys addr for ioremap 833#define USB_OHCI_BASE 0x14020000 /* phys addr for ioremap */
834#define USB_OHCI_LEN 0x00060000 834#define USB_OHCI_LEN 0x00060000
835#define USB_HOST_CONFIG 0xB4027ffc 835#define USB_HOST_CONFIG 0xB4027ffc
836 836
837#define AU1550_ETH0_BASE 0xB0500000 837#define AU1550_ETH0_BASE 0xB0500000
838#define AU1550_ETH1_BASE 0xB0510000 838#define AU1550_ETH1_BASE 0xB0510000
839#define AU1550_MAC0_ENABLE 0xB0520000 839#define AU1550_MAC0_ENABLE 0xB0520000
840#define AU1550_MAC1_ENABLE 0xB0520004 840#define AU1550_MAC1_ENABLE 0xB0520004
841#define NUM_ETH_INTERFACES 2 841#define NUM_ETH_INTERFACES 2
842#endif /* CONFIG_SOC_AU1550 */ 842#endif /* CONFIG_SOC_AU1550 */
843 843
@@ -911,32 +911,32 @@ enum soc_au1200_ints {
911 AU1000_GPIO_31, 911 AU1000_GPIO_31,
912}; 912};
913 913
914#define UART0_ADDR 0xB1100000 914#define UART0_ADDR 0xB1100000
915#define UART1_ADDR 0xB1200000 915#define UART1_ADDR 0xB1200000
916 916
917#define USB_UOC_BASE 0x14020020 917#define USB_UOC_BASE 0x14020020
918#define USB_UOC_LEN 0x20 918#define USB_UOC_LEN 0x20
919#define USB_OHCI_BASE 0x14020100 919#define USB_OHCI_BASE 0x14020100
920#define USB_OHCI_LEN 0x100 920#define USB_OHCI_LEN 0x100
921#define USB_EHCI_BASE 0x14020200 921#define USB_EHCI_BASE 0x14020200
922#define USB_EHCI_LEN 0x100 922#define USB_EHCI_LEN 0x100
923#define USB_UDC_BASE 0x14022000 923#define USB_UDC_BASE 0x14022000
924#define USB_UDC_LEN 0x2000 924#define USB_UDC_LEN 0x2000
925#define USB_MSR_BASE 0xB4020000 925#define USB_MSR_BASE 0xB4020000
926#define USB_MSR_MCFG 4 926#define USB_MSR_MCFG 4
927#define USBMSRMCFG_OMEMEN 0 927#define USBMSRMCFG_OMEMEN 0
928#define USBMSRMCFG_OBMEN 1 928#define USBMSRMCFG_OBMEN 1
929#define USBMSRMCFG_EMEMEN 2 929#define USBMSRMCFG_EMEMEN 2
930#define USBMSRMCFG_EBMEN 3 930#define USBMSRMCFG_EBMEN 3
931#define USBMSRMCFG_DMEMEN 4 931#define USBMSRMCFG_DMEMEN 4
932#define USBMSRMCFG_DBMEN 5 932#define USBMSRMCFG_DBMEN 5
933#define USBMSRMCFG_GMEMEN 6 933#define USBMSRMCFG_GMEMEN 6
934#define USBMSRMCFG_OHCCLKEN 16 934#define USBMSRMCFG_OHCCLKEN 16
935#define USBMSRMCFG_EHCCLKEN 17 935#define USBMSRMCFG_EHCCLKEN 17
936#define USBMSRMCFG_UDCCLKEN 18 936#define USBMSRMCFG_UDCCLKEN 18
937#define USBMSRMCFG_PHYPLLEN 19 937#define USBMSRMCFG_PHYPLLEN 19
938#define USBMSRMCFG_RDCOMB 30 938#define USBMSRMCFG_RDCOMB 30
939#define USBMSRMCFG_PFEN 31 939#define USBMSRMCFG_PFEN 31
940 940
941#endif /* CONFIG_SOC_AU1200 */ 941#endif /* CONFIG_SOC_AU1200 */
942 942
@@ -949,259 +949,258 @@ enum soc_au1200_ints {
949#define INTX 0xFF /* not valid */ 949#define INTX 0xFF /* not valid */
950 950
951/* Programmable Counters 0 and 1 */ 951/* Programmable Counters 0 and 1 */
952#define SYS_BASE 0xB1900000 952#define SYS_BASE 0xB1900000
953#define SYS_COUNTER_CNTRL (SYS_BASE + 0x14) 953#define SYS_COUNTER_CNTRL (SYS_BASE + 0x14)
954# define SYS_CNTRL_E1S (1<<23) 954# define SYS_CNTRL_E1S (1 << 23)
955# define SYS_CNTRL_T1S (1<<20) 955# define SYS_CNTRL_T1S (1 << 20)
956# define SYS_CNTRL_M21 (1<<19) 956# define SYS_CNTRL_M21 (1 << 19)
957# define SYS_CNTRL_M11 (1<<18) 957# define SYS_CNTRL_M11 (1 << 18)
958# define SYS_CNTRL_M01 (1<<17) 958# define SYS_CNTRL_M01 (1 << 17)
959# define SYS_CNTRL_C1S (1<<16) 959# define SYS_CNTRL_C1S (1 << 16)
960# define SYS_CNTRL_BP (1<<14) 960# define SYS_CNTRL_BP (1 << 14)
961# define SYS_CNTRL_EN1 (1<<13) 961# define SYS_CNTRL_EN1 (1 << 13)
962# define SYS_CNTRL_BT1 (1<<12) 962# define SYS_CNTRL_BT1 (1 << 12)
963# define SYS_CNTRL_EN0 (1<<11) 963# define SYS_CNTRL_EN0 (1 << 11)
964# define SYS_CNTRL_BT0 (1<<10) 964# define SYS_CNTRL_BT0 (1 << 10)
965# define SYS_CNTRL_E0 (1<<8) 965# define SYS_CNTRL_E0 (1 << 8)
966# define SYS_CNTRL_E0S (1<<7) 966# define SYS_CNTRL_E0S (1 << 7)
967# define SYS_CNTRL_32S (1<<5) 967# define SYS_CNTRL_32S (1 << 5)
968# define SYS_CNTRL_T0S (1<<4) 968# define SYS_CNTRL_T0S (1 << 4)
969# define SYS_CNTRL_M20 (1<<3) 969# define SYS_CNTRL_M20 (1 << 3)
970# define SYS_CNTRL_M10 (1<<2) 970# define SYS_CNTRL_M10 (1 << 2)
971# define SYS_CNTRL_M00 (1<<1) 971# define SYS_CNTRL_M00 (1 << 1)
972# define SYS_CNTRL_C0S (1<<0) 972# define SYS_CNTRL_C0S (1 << 0)
973 973
974/* Programmable Counter 0 Registers */ 974/* Programmable Counter 0 Registers */
975#define SYS_TOYTRIM (SYS_BASE + 0) 975#define SYS_TOYTRIM (SYS_BASE + 0)
976#define SYS_TOYWRITE (SYS_BASE + 4) 976#define SYS_TOYWRITE (SYS_BASE + 4)
977#define SYS_TOYMATCH0 (SYS_BASE + 8) 977#define SYS_TOYMATCH0 (SYS_BASE + 8)
978#define SYS_TOYMATCH1 (SYS_BASE + 0xC) 978#define SYS_TOYMATCH1 (SYS_BASE + 0xC)
979#define SYS_TOYMATCH2 (SYS_BASE + 0x10) 979#define SYS_TOYMATCH2 (SYS_BASE + 0x10)
980#define SYS_TOYREAD (SYS_BASE + 0x40) 980#define SYS_TOYREAD (SYS_BASE + 0x40)
981 981
982/* Programmable Counter 1 Registers */ 982/* Programmable Counter 1 Registers */
983#define SYS_RTCTRIM (SYS_BASE + 0x44) 983#define SYS_RTCTRIM (SYS_BASE + 0x44)
984#define SYS_RTCWRITE (SYS_BASE + 0x48) 984#define SYS_RTCWRITE (SYS_BASE + 0x48)
985#define SYS_RTCMATCH0 (SYS_BASE + 0x4C) 985#define SYS_RTCMATCH0 (SYS_BASE + 0x4C)
986#define SYS_RTCMATCH1 (SYS_BASE + 0x50) 986#define SYS_RTCMATCH1 (SYS_BASE + 0x50)
987#define SYS_RTCMATCH2 (SYS_BASE + 0x54) 987#define SYS_RTCMATCH2 (SYS_BASE + 0x54)
988#define SYS_RTCREAD (SYS_BASE + 0x58) 988#define SYS_RTCREAD (SYS_BASE + 0x58)
989 989
990/* I2S Controller */ 990/* I2S Controller */
991#define I2S_DATA 0xB1000000 991#define I2S_DATA 0xB1000000
992# define I2S_DATA_MASK (0xffffff) 992# define I2S_DATA_MASK 0xffffff
993#define I2S_CONFIG 0xB1000004 993#define I2S_CONFIG 0xB1000004
994# define I2S_CONFIG_XU (1<<25) 994# define I2S_CONFIG_XU (1 << 25)
995# define I2S_CONFIG_XO (1<<24) 995# define I2S_CONFIG_XO (1 << 24)
996# define I2S_CONFIG_RU (1<<23) 996# define I2S_CONFIG_RU (1 << 23)
997# define I2S_CONFIG_RO (1<<22) 997# define I2S_CONFIG_RO (1 << 22)
998# define I2S_CONFIG_TR (1<<21) 998# define I2S_CONFIG_TR (1 << 21)
999# define I2S_CONFIG_TE (1<<20) 999# define I2S_CONFIG_TE (1 << 20)
1000# define I2S_CONFIG_TF (1<<19) 1000# define I2S_CONFIG_TF (1 << 19)
1001# define I2S_CONFIG_RR (1<<18) 1001# define I2S_CONFIG_RR (1 << 18)
1002# define I2S_CONFIG_RE (1<<17) 1002# define I2S_CONFIG_RE (1 << 17)
1003# define I2S_CONFIG_RF (1<<16) 1003# define I2S_CONFIG_RF (1 << 16)
1004# define I2S_CONFIG_PD (1<<11) 1004# define I2S_CONFIG_PD (1 << 11)
1005# define I2S_CONFIG_LB (1<<10) 1005# define I2S_CONFIG_LB (1 << 10)
1006# define I2S_CONFIG_IC (1<<9) 1006# define I2S_CONFIG_IC (1 << 9)
1007# define I2S_CONFIG_FM_BIT 7 1007# define I2S_CONFIG_FM_BIT 7
1008# define I2S_CONFIG_FM_MASK (0x3 << I2S_CONFIG_FM_BIT) 1008# define I2S_CONFIG_FM_MASK (0x3 << I2S_CONFIG_FM_BIT)
1009# define I2S_CONFIG_FM_I2S (0x0 << I2S_CONFIG_FM_BIT) 1009# define I2S_CONFIG_FM_I2S (0x0 << I2S_CONFIG_FM_BIT)
1010# define I2S_CONFIG_FM_LJ (0x1 << I2S_CONFIG_FM_BIT) 1010# define I2S_CONFIG_FM_LJ (0x1 << I2S_CONFIG_FM_BIT)
1011# define I2S_CONFIG_FM_RJ (0x2 << I2S_CONFIG_FM_BIT) 1011# define I2S_CONFIG_FM_RJ (0x2 << I2S_CONFIG_FM_BIT)
1012# define I2S_CONFIG_TN (1<<6) 1012# define I2S_CONFIG_TN (1 << 6)
1013# define I2S_CONFIG_RN (1<<5) 1013# define I2S_CONFIG_RN (1 << 5)
1014# define I2S_CONFIG_SZ_BIT 0 1014# define I2S_CONFIG_SZ_BIT 0
1015# define I2S_CONFIG_SZ_MASK (0x1F << I2S_CONFIG_SZ_BIT) 1015# define I2S_CONFIG_SZ_MASK (0x1F << I2S_CONFIG_SZ_BIT)
1016 1016
1017#define I2S_CONTROL 0xB1000008 1017#define I2S_CONTROL 0xB1000008
1018# define I2S_CONTROL_D (1<<1) 1018# define I2S_CONTROL_D (1 << 1)
1019# define I2S_CONTROL_CE (1<<0) 1019# define I2S_CONTROL_CE (1 << 0)
1020 1020
1021/* USB Host Controller */ 1021/* USB Host Controller */
1022#ifndef USB_OHCI_LEN 1022#ifndef USB_OHCI_LEN
1023#define USB_OHCI_LEN 0x00100000 1023#define USB_OHCI_LEN 0x00100000
1024#endif 1024#endif
1025 1025
1026#ifndef CONFIG_SOC_AU1200 1026#ifndef CONFIG_SOC_AU1200
1027 1027
1028/* USB Device Controller */ 1028/* USB Device Controller */
1029#define USBD_EP0RD 0xB0200000 1029#define USBD_EP0RD 0xB0200000
1030#define USBD_EP0WR 0xB0200004 1030#define USBD_EP0WR 0xB0200004
1031#define USBD_EP2WR 0xB0200008 1031#define USBD_EP2WR 0xB0200008
1032#define USBD_EP3WR 0xB020000C 1032#define USBD_EP3WR 0xB020000C
1033#define USBD_EP4RD 0xB0200010 1033#define USBD_EP4RD 0xB0200010
1034#define USBD_EP5RD 0xB0200014 1034#define USBD_EP5RD 0xB0200014
1035#define USBD_INTEN 0xB0200018 1035#define USBD_INTEN 0xB0200018
1036#define USBD_INTSTAT 0xB020001C 1036#define USBD_INTSTAT 0xB020001C
1037# define USBDEV_INT_SOF (1<<12) 1037# define USBDEV_INT_SOF (1 << 12)
1038# define USBDEV_INT_HF_BIT 6 1038# define USBDEV_INT_HF_BIT 6
1039# define USBDEV_INT_HF_MASK (0x3f << USBDEV_INT_HF_BIT) 1039# define USBDEV_INT_HF_MASK 0x3f << USBDEV_INT_HF_BIT)
1040# define USBDEV_INT_CMPLT_BIT 0 1040# define USBDEV_INT_CMPLT_BIT 0
1041# define USBDEV_INT_CMPLT_MASK (0x3f << USBDEV_INT_CMPLT_BIT) 1041# define USBDEV_INT_CMPLT_MASK (0x3f << USBDEV_INT_CMPLT_BIT)
1042#define USBD_CONFIG 0xB0200020 1042#define USBD_CONFIG 0xB0200020
1043#define USBD_EP0CS 0xB0200024 1043#define USBD_EP0CS 0xB0200024
1044#define USBD_EP2CS 0xB0200028 1044#define USBD_EP2CS 0xB0200028
1045#define USBD_EP3CS 0xB020002C 1045#define USBD_EP3CS 0xB020002C
1046#define USBD_EP4CS 0xB0200030 1046#define USBD_EP4CS 0xB0200030
1047#define USBD_EP5CS 0xB0200034 1047#define USBD_EP5CS 0xB0200034
1048# define USBDEV_CS_SU (1<<14) 1048# define USBDEV_CS_SU (1 << 14)
1049# define USBDEV_CS_NAK (1<<13) 1049# define USBDEV_CS_NAK (1 << 13)
1050# define USBDEV_CS_ACK (1<<12) 1050# define USBDEV_CS_ACK (1 << 12)
1051# define USBDEV_CS_BUSY (1<<11) 1051# define USBDEV_CS_BUSY (1 << 11)
1052# define USBDEV_CS_TSIZE_BIT 1 1052# define USBDEV_CS_TSIZE_BIT 1
1053# define USBDEV_CS_TSIZE_MASK (0x3ff << USBDEV_CS_TSIZE_BIT) 1053# define USBDEV_CS_TSIZE_MASK (0x3ff << USBDEV_CS_TSIZE_BIT)
1054# define USBDEV_CS_STALL (1<<0) 1054# define USBDEV_CS_STALL (1 << 0)
1055#define USBD_EP0RDSTAT 0xB0200040 1055#define USBD_EP0RDSTAT 0xB0200040
1056#define USBD_EP0WRSTAT 0xB0200044 1056#define USBD_EP0WRSTAT 0xB0200044
1057#define USBD_EP2WRSTAT 0xB0200048 1057#define USBD_EP2WRSTAT 0xB0200048
1058#define USBD_EP3WRSTAT 0xB020004C 1058#define USBD_EP3WRSTAT 0xB020004C
1059#define USBD_EP4RDSTAT 0xB0200050 1059#define USBD_EP4RDSTAT 0xB0200050
1060#define USBD_EP5RDSTAT 0xB0200054 1060#define USBD_EP5RDSTAT 0xB0200054
1061# define USBDEV_FSTAT_FLUSH (1<<6) 1061# define USBDEV_FSTAT_FLUSH (1 << 6)
1062# define USBDEV_FSTAT_UF (1<<5) 1062# define USBDEV_FSTAT_UF (1 << 5)
1063# define USBDEV_FSTAT_OF (1<<4) 1063# define USBDEV_FSTAT_OF (1 << 4)
1064# define USBDEV_FSTAT_FCNT_BIT 0 1064# define USBDEV_FSTAT_FCNT_BIT 0
1065# define USBDEV_FSTAT_FCNT_MASK (0x0f << USBDEV_FSTAT_FCNT_BIT) 1065# define USBDEV_FSTAT_FCNT_MASK (0x0f << USBDEV_FSTAT_FCNT_BIT)
1066#define USBD_ENABLE 0xB0200058 1066#define USBD_ENABLE 0xB0200058
1067# define USBDEV_ENABLE (1<<1) 1067# define USBDEV_ENABLE (1 << 1)
1068# define USBDEV_CE (1<<0) 1068# define USBDEV_CE (1 << 0)
1069 1069
1070#endif /* !CONFIG_SOC_AU1200 */ 1070#endif /* !CONFIG_SOC_AU1200 */
1071 1071
1072/* Ethernet Controllers */ 1072/* Ethernet Controllers */
1073 1073
1074/* 4 byte offsets from AU1000_ETH_BASE */ 1074/* 4 byte offsets from AU1000_ETH_BASE */
1075#define MAC_CONTROL 0x0 1075#define MAC_CONTROL 0x0
1076# define MAC_RX_ENABLE (1<<2) 1076# define MAC_RX_ENABLE (1 << 2)
1077# define MAC_TX_ENABLE (1<<3) 1077# define MAC_TX_ENABLE (1 << 3)
1078# define MAC_DEF_CHECK (1<<5) 1078# define MAC_DEF_CHECK (1 << 5)
1079# define MAC_SET_BL(X) (((X)&0x3)<<6) 1079# define MAC_SET_BL(X) (((X) & 0x3) << 6)
1080# define MAC_AUTO_PAD (1<<8) 1080# define MAC_AUTO_PAD (1 << 8)
1081# define MAC_DISABLE_RETRY (1<<10) 1081# define MAC_DISABLE_RETRY (1 << 10)
1082# define MAC_DISABLE_BCAST (1<<11) 1082# define MAC_DISABLE_BCAST (1 << 11)
1083# define MAC_LATE_COL (1<<12) 1083# define MAC_LATE_COL (1 << 12)
1084# define MAC_HASH_MODE (1<<13) 1084# define MAC_HASH_MODE (1 << 13)
1085# define MAC_HASH_ONLY (1<<15) 1085# define MAC_HASH_ONLY (1 << 15)
1086# define MAC_PASS_ALL (1<<16) 1086# define MAC_PASS_ALL (1 << 16)
1087# define MAC_INVERSE_FILTER (1<<17) 1087# define MAC_INVERSE_FILTER (1 << 17)
1088# define MAC_PROMISCUOUS (1<<18) 1088# define MAC_PROMISCUOUS (1 << 18)
1089# define MAC_PASS_ALL_MULTI (1<<19) 1089# define MAC_PASS_ALL_MULTI (1 << 19)
1090# define MAC_FULL_DUPLEX (1<<20) 1090# define MAC_FULL_DUPLEX (1 << 20)
1091# define MAC_NORMAL_MODE 0 1091# define MAC_NORMAL_MODE 0
1092# define MAC_INT_LOOPBACK (1<<21) 1092# define MAC_INT_LOOPBACK (1 << 21)
1093# define MAC_EXT_LOOPBACK (1<<22) 1093# define MAC_EXT_LOOPBACK (1 << 22)
1094# define MAC_DISABLE_RX_OWN (1<<23) 1094# define MAC_DISABLE_RX_OWN (1 << 23)
1095# define MAC_BIG_ENDIAN (1<<30) 1095# define MAC_BIG_ENDIAN (1 << 30)
1096# define MAC_RX_ALL (1<<31) 1096# define MAC_RX_ALL (1 << 31)
1097#define MAC_ADDRESS_HIGH 0x4 1097#define MAC_ADDRESS_HIGH 0x4
1098#define MAC_ADDRESS_LOW 0x8 1098#define MAC_ADDRESS_LOW 0x8
1099#define MAC_MCAST_HIGH 0xC 1099#define MAC_MCAST_HIGH 0xC
1100#define MAC_MCAST_LOW 0x10 1100#define MAC_MCAST_LOW 0x10
1101#define MAC_MII_CNTRL 0x14 1101#define MAC_MII_CNTRL 0x14
1102# define MAC_MII_BUSY (1<<0) 1102# define MAC_MII_BUSY (1 << 0)
1103# define MAC_MII_READ 0 1103# define MAC_MII_READ 0
1104# define MAC_MII_WRITE (1<<1) 1104# define MAC_MII_WRITE (1 << 1)
1105# define MAC_SET_MII_SELECT_REG(X) (((X)&0x1f)<<6) 1105# define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6)
1106# define MAC_SET_MII_SELECT_PHY(X) (((X)&0x1f)<<11) 1106# define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11)
1107#define MAC_MII_DATA 0x18 1107#define MAC_MII_DATA 0x18
1108#define MAC_FLOW_CNTRL 0x1C 1108#define MAC_FLOW_CNTRL 0x1C
1109# define MAC_FLOW_CNTRL_BUSY (1<<0) 1109# define MAC_FLOW_CNTRL_BUSY (1 << 0)
1110# define MAC_FLOW_CNTRL_ENABLE (1<<1) 1110# define MAC_FLOW_CNTRL_ENABLE (1 << 1)
1111# define MAC_PASS_CONTROL (1<<2) 1111# define MAC_PASS_CONTROL (1 << 2)
1112# define MAC_SET_PAUSE(X) (((X)&0xffff)<<16) 1112# define MAC_SET_PAUSE(X) (((X) & 0xffff) << 16)
1113#define MAC_VLAN1_TAG 0x20 1113#define MAC_VLAN1_TAG 0x20
1114#define MAC_VLAN2_TAG 0x24 1114#define MAC_VLAN2_TAG 0x24
1115 1115
1116/* Ethernet Controller Enable */ 1116/* Ethernet Controller Enable */
1117 1117
1118# define MAC_EN_CLOCK_ENABLE (1<<0) 1118# define MAC_EN_CLOCK_ENABLE (1 << 0)
1119# define MAC_EN_RESET0 (1<<1) 1119# define MAC_EN_RESET0 (1 << 1)
1120# define MAC_EN_TOSS (0<<2) 1120# define MAC_EN_TOSS (0 << 2)
1121# define MAC_EN_CACHEABLE (1<<3) 1121# define MAC_EN_CACHEABLE (1 << 3)
1122# define MAC_EN_RESET1 (1<<4) 1122# define MAC_EN_RESET1 (1 << 4)
1123# define MAC_EN_RESET2 (1<<5) 1123# define MAC_EN_RESET2 (1 << 5)
1124# define MAC_DMA_RESET (1<<6) 1124# define MAC_DMA_RESET (1 << 6)
1125 1125
1126/* Ethernet Controller DMA Channels */ 1126/* Ethernet Controller DMA Channels */
1127 1127
1128#define MAC0_TX_DMA_ADDR 0xB4004000 1128#define MAC0_TX_DMA_ADDR 0xB4004000
1129#define MAC1_TX_DMA_ADDR 0xB4004200 1129#define MAC1_TX_DMA_ADDR 0xB4004200
1130/* offsets from MAC_TX_RING_ADDR address */ 1130/* offsets from MAC_TX_RING_ADDR address */
1131#define MAC_TX_BUFF0_STATUS 0x0 1131#define MAC_TX_BUFF0_STATUS 0x0
1132# define TX_FRAME_ABORTED (1<<0) 1132# define TX_FRAME_ABORTED (1 << 0)
1133# define TX_JAB_TIMEOUT (1<<1) 1133# define TX_JAB_TIMEOUT (1 << 1)
1134# define TX_NO_CARRIER (1<<2) 1134# define TX_NO_CARRIER (1 << 2)
1135# define TX_LOSS_CARRIER (1<<3) 1135# define TX_LOSS_CARRIER (1 << 3)
1136# define TX_EXC_DEF (1<<4) 1136# define TX_EXC_DEF (1 << 4)
1137# define TX_LATE_COLL_ABORT (1<<5) 1137# define TX_LATE_COLL_ABORT (1 << 5)
1138# define TX_EXC_COLL (1<<6) 1138# define TX_EXC_COLL (1 << 6)
1139# define TX_UNDERRUN (1<<7) 1139# define TX_UNDERRUN (1 << 7)
1140# define TX_DEFERRED (1<<8) 1140# define TX_DEFERRED (1 << 8)
1141# define TX_LATE_COLL (1<<9) 1141# define TX_LATE_COLL (1 << 9)
1142# define TX_COLL_CNT_MASK (0xF<<10) 1142# define TX_COLL_CNT_MASK (0xF << 10)
1143# define TX_PKT_RETRY (1<<31) 1143# define TX_PKT_RETRY (1 << 31)
1144#define MAC_TX_BUFF0_ADDR 0x4 1144#define MAC_TX_BUFF0_ADDR 0x4
1145# define TX_DMA_ENABLE (1<<0) 1145# define TX_DMA_ENABLE (1 << 0)
1146# define TX_T_DONE (1<<1) 1146# define TX_T_DONE (1 << 1)
1147# define TX_GET_DMA_BUFFER(X) (((X)>>2)&0x3) 1147# define TX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
1148#define MAC_TX_BUFF0_LEN 0x8 1148#define MAC_TX_BUFF0_LEN 0x8
1149#define MAC_TX_BUFF1_STATUS 0x10 1149#define MAC_TX_BUFF1_STATUS 0x10
1150#define MAC_TX_BUFF1_ADDR 0x14 1150#define MAC_TX_BUFF1_ADDR 0x14
1151#define MAC_TX_BUFF1_LEN 0x18 1151#define MAC_TX_BUFF1_LEN 0x18
1152#define MAC_TX_BUFF2_STATUS 0x20 1152#define MAC_TX_BUFF2_STATUS 0x20
1153#define MAC_TX_BUFF2_ADDR 0x24 1153#define MAC_TX_BUFF2_ADDR 0x24
1154#define MAC_TX_BUFF2_LEN 0x28 1154#define MAC_TX_BUFF2_LEN 0x28
1155#define MAC_TX_BUFF3_STATUS 0x30 1155#define MAC_TX_BUFF3_STATUS 0x30
1156#define MAC_TX_BUFF3_ADDR 0x34 1156#define MAC_TX_BUFF3_ADDR 0x34
1157#define MAC_TX_BUFF3_LEN 0x38 1157#define MAC_TX_BUFF3_LEN 0x38
1158 1158
1159#define MAC0_RX_DMA_ADDR 0xB4004100 1159#define MAC0_RX_DMA_ADDR 0xB4004100
1160#define MAC1_RX_DMA_ADDR 0xB4004300 1160#define MAC1_RX_DMA_ADDR 0xB4004300
1161/* offsets from MAC_RX_RING_ADDR */ 1161/* offsets from MAC_RX_RING_ADDR */
1162#define MAC_RX_BUFF0_STATUS 0x0 1162#define MAC_RX_BUFF0_STATUS 0x0
1163# define RX_FRAME_LEN_MASK 0x3fff 1163# define RX_FRAME_LEN_MASK 0x3fff
1164# define RX_WDOG_TIMER (1<<14) 1164# define RX_WDOG_TIMER (1 << 14)
1165# define RX_RUNT (1<<15) 1165# define RX_RUNT (1 << 15)
1166# define RX_OVERLEN (1<<16) 1166# define RX_OVERLEN (1 << 16)
1167# define RX_COLL (1<<17) 1167# define RX_COLL (1 << 17)
1168# define RX_ETHER (1<<18) 1168# define RX_ETHER (1 << 18)
1169# define RX_MII_ERROR (1<<19) 1169# define RX_MII_ERROR (1 << 19)
1170# define RX_DRIBBLING (1<<20) 1170# define RX_DRIBBLING (1 << 20)
1171# define RX_CRC_ERROR (1<<21) 1171# define RX_CRC_ERROR (1 << 21)
1172# define RX_VLAN1 (1<<22) 1172# define RX_VLAN1 (1 << 22)
1173# define RX_VLAN2 (1<<23) 1173# define RX_VLAN2 (1 << 23)
1174# define RX_LEN_ERROR (1<<24) 1174# define RX_LEN_ERROR (1 << 24)
1175# define RX_CNTRL_FRAME (1<<25) 1175# define RX_CNTRL_FRAME (1 << 25)
1176# define RX_U_CNTRL_FRAME (1<<26) 1176# define RX_U_CNTRL_FRAME (1 << 26)
1177# define RX_MCAST_FRAME (1<<27) 1177# define RX_MCAST_FRAME (1 << 27)
1178# define RX_BCAST_FRAME (1<<28) 1178# define RX_BCAST_FRAME (1 << 28)
1179# define RX_FILTER_FAIL (1<<29) 1179# define RX_FILTER_FAIL (1 << 29)
1180# define RX_PACKET_FILTER (1<<30) 1180# define RX_PACKET_FILTER (1 << 30)
1181# define RX_MISSED_FRAME (1<<31) 1181# define RX_MISSED_FRAME (1 << 31)
1182 1182
1183# define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \ 1183# define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \
1184 RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \ 1184 RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \
1185 RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME) 1185 RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME)
1186#define MAC_RX_BUFF0_ADDR 0x4 1186#define MAC_RX_BUFF0_ADDR 0x4
1187# define RX_DMA_ENABLE (1<<0) 1187# define RX_DMA_ENABLE (1 << 0)
1188# define RX_T_DONE (1<<1) 1188# define RX_T_DONE (1 << 1)
1189# define RX_GET_DMA_BUFFER(X) (((X)>>2)&0x3) 1189# define RX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
1190# define RX_SET_BUFF_ADDR(X) ((X)&0xffffffc0) 1190# define RX_SET_BUFF_ADDR(X) ((X) & 0xffffffc0)
1191#define MAC_RX_BUFF1_STATUS 0x10 1191#define MAC_RX_BUFF1_STATUS 0x10
1192#define MAC_RX_BUFF1_ADDR 0x14 1192#define MAC_RX_BUFF1_ADDR 0x14
1193#define MAC_RX_BUFF2_STATUS 0x20 1193#define MAC_RX_BUFF2_STATUS 0x20
1194#define MAC_RX_BUFF2_ADDR 0x24 1194#define MAC_RX_BUFF2_ADDR 0x24
1195#define MAC_RX_BUFF3_STATUS 0x30 1195#define MAC_RX_BUFF3_STATUS 0x30
1196#define MAC_RX_BUFF3_ADDR 0x34 1196#define MAC_RX_BUFF3_ADDR 0x34
1197
1198 1197
1199/* UARTS 0-3 */ 1198/* UARTS 0-3 */
1200#define UART_BASE UART0_ADDR 1199#define UART_BASE UART0_ADDR
1201#ifdef CONFIG_SOC_AU1200 1200#ifdef CONFIG_SOC_AU1200
1202#define UART_DEBUG_BASE UART1_ADDR 1201#define UART_DEBUG_BASE UART1_ADDR
1203#else 1202#else
1204#define UART_DEBUG_BASE UART3_ADDR 1203#define UART_DEBUG_BASE UART3_ADDR
1205#endif 1204#endif
1206 1205
1207#define UART_RX 0 /* Receive buffer */ 1206#define UART_RX 0 /* Receive buffer */
@@ -1294,341 +1293,337 @@ enum soc_au1200_ints {
1294#define UART_MSR_DCTS 0x01 /* Delta CTS */ 1293#define UART_MSR_DCTS 0x01 /* Delta CTS */
1295#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */ 1294#define UART_MSR_ANY_DELTA 0x0F /* Any of the delta bits! */
1296 1295
1297
1298
1299/* SSIO */ 1296/* SSIO */
1300#define SSI0_STATUS 0xB1600000 1297#define SSI0_STATUS 0xB1600000
1301# define SSI_STATUS_BF (1<<4) 1298# define SSI_STATUS_BF (1 << 4)
1302# define SSI_STATUS_OF (1<<3) 1299# define SSI_STATUS_OF (1 << 3)
1303# define SSI_STATUS_UF (1<<2) 1300# define SSI_STATUS_UF (1 << 2)
1304# define SSI_STATUS_D (1<<1) 1301# define SSI_STATUS_D (1 << 1)
1305# define SSI_STATUS_B (1<<0) 1302# define SSI_STATUS_B (1 << 0)
1306#define SSI0_INT 0xB1600004 1303#define SSI0_INT 0xB1600004
1307# define SSI_INT_OI (1<<3) 1304# define SSI_INT_OI (1 << 3)
1308# define SSI_INT_UI (1<<2) 1305# define SSI_INT_UI (1 << 2)
1309# define SSI_INT_DI (1<<1) 1306# define SSI_INT_DI (1 << 1)
1310#define SSI0_INT_ENABLE 0xB1600008 1307#define SSI0_INT_ENABLE 0xB1600008
1311# define SSI_INTE_OIE (1<<3) 1308# define SSI_INTE_OIE (1 << 3)
1312# define SSI_INTE_UIE (1<<2) 1309# define SSI_INTE_UIE (1 << 2)
1313# define SSI_INTE_DIE (1<<1) 1310# define SSI_INTE_DIE (1 << 1)
1314#define SSI0_CONFIG 0xB1600020 1311#define SSI0_CONFIG 0xB1600020
1315# define SSI_CONFIG_AO (1<<24) 1312# define SSI_CONFIG_AO (1 << 24)
1316# define SSI_CONFIG_DO (1<<23) 1313# define SSI_CONFIG_DO (1 << 23)
1317# define SSI_CONFIG_ALEN_BIT 20 1314# define SSI_CONFIG_ALEN_BIT 20
1318# define SSI_CONFIG_ALEN_MASK (0x7<<20) 1315# define SSI_CONFIG_ALEN_MASK (0x7 << 20)
1319# define SSI_CONFIG_DLEN_BIT 16 1316# define SSI_CONFIG_DLEN_BIT 16
1320# define SSI_CONFIG_DLEN_MASK (0x7<<16) 1317# define SSI_CONFIG_DLEN_MASK (0x7 << 16)
1321# define SSI_CONFIG_DD (1<<11) 1318# define SSI_CONFIG_DD (1 << 11)
1322# define SSI_CONFIG_AD (1<<10) 1319# define SSI_CONFIG_AD (1 << 10)
1323# define SSI_CONFIG_BM_BIT 8 1320# define SSI_CONFIG_BM_BIT 8
1324# define SSI_CONFIG_BM_MASK (0x3<<8) 1321# define SSI_CONFIG_BM_MASK (0x3 << 8)
1325# define SSI_CONFIG_CE (1<<7) 1322# define SSI_CONFIG_CE (1 << 7)
1326# define SSI_CONFIG_DP (1<<6) 1323# define SSI_CONFIG_DP (1 << 6)
1327# define SSI_CONFIG_DL (1<<5) 1324# define SSI_CONFIG_DL (1 << 5)
1328# define SSI_CONFIG_EP (1<<4) 1325# define SSI_CONFIG_EP (1 << 4)
1329#define SSI0_ADATA 0xB1600024 1326#define SSI0_ADATA 0xB1600024
1330# define SSI_AD_D (1<<24) 1327# define SSI_AD_D (1 << 24)
1331# define SSI_AD_ADDR_BIT 16 1328# define SSI_AD_ADDR_BIT 16
1332# define SSI_AD_ADDR_MASK (0xff<<16) 1329# define SSI_AD_ADDR_MASK (0xff << 16)
1333# define SSI_AD_DATA_BIT 0 1330# define SSI_AD_DATA_BIT 0
1334# define SSI_AD_DATA_MASK (0xfff<<0) 1331# define SSI_AD_DATA_MASK (0xfff << 0)
1335#define SSI0_CLKDIV 0xB1600028 1332#define SSI0_CLKDIV 0xB1600028
1336#define SSI0_CONTROL 0xB1600100 1333#define SSI0_CONTROL 0xB1600100
1337# define SSI_CONTROL_CD (1<<1) 1334# define SSI_CONTROL_CD (1 << 1)
1338# define SSI_CONTROL_E (1<<0) 1335# define SSI_CONTROL_E (1 << 0)
1339 1336
1340/* SSI1 */ 1337/* SSI1 */
1341#define SSI1_STATUS 0xB1680000 1338#define SSI1_STATUS 0xB1680000
1342#define SSI1_INT 0xB1680004 1339#define SSI1_INT 0xB1680004
1343#define SSI1_INT_ENABLE 0xB1680008 1340#define SSI1_INT_ENABLE 0xB1680008
1344#define SSI1_CONFIG 0xB1680020 1341#define SSI1_CONFIG 0xB1680020
1345#define SSI1_ADATA 0xB1680024 1342#define SSI1_ADATA 0xB1680024
1346#define SSI1_CLKDIV 0xB1680028 1343#define SSI1_CLKDIV 0xB1680028
1347#define SSI1_ENABLE 0xB1680100 1344#define SSI1_ENABLE 0xB1680100
1348 1345
1349/* 1346/*
1350 * Register content definitions 1347 * Register content definitions
1351 */ 1348 */
1352#define SSI_STATUS_BF (1<<4) 1349#define SSI_STATUS_BF (1 << 4)
1353#define SSI_STATUS_OF (1<<3) 1350#define SSI_STATUS_OF (1 << 3)
1354#define SSI_STATUS_UF (1<<2) 1351#define SSI_STATUS_UF (1 << 2)
1355#define SSI_STATUS_D (1<<1) 1352#define SSI_STATUS_D (1 << 1)
1356#define SSI_STATUS_B (1<<0) 1353#define SSI_STATUS_B (1 << 0)
1357 1354
1358/* SSI_INT */ 1355/* SSI_INT */
1359#define SSI_INT_OI (1<<3) 1356#define SSI_INT_OI (1 << 3)
1360#define SSI_INT_UI (1<<2) 1357#define SSI_INT_UI (1 << 2)
1361#define SSI_INT_DI (1<<1) 1358#define SSI_INT_DI (1 << 1)
1362 1359
1363/* SSI_INTEN */ 1360/* SSI_INTEN */
1364#define SSI_INTEN_OIE (1<<3) 1361#define SSI_INTEN_OIE (1 << 3)
1365#define SSI_INTEN_UIE (1<<2) 1362#define SSI_INTEN_UIE (1 << 2)
1366#define SSI_INTEN_DIE (1<<1) 1363#define SSI_INTEN_DIE (1 << 1)
1367 1364
1368#define SSI_CONFIG_AO (1<<24) 1365#define SSI_CONFIG_AO (1 << 24)
1369#define SSI_CONFIG_DO (1<<23) 1366#define SSI_CONFIG_DO (1 << 23)
1370#define SSI_CONFIG_ALEN (7<<20) 1367#define SSI_CONFIG_ALEN (7 << 20)
1371#define SSI_CONFIG_DLEN (15<<16) 1368#define SSI_CONFIG_DLEN (15 << 16)
1372#define SSI_CONFIG_DD (1<<11) 1369#define SSI_CONFIG_DD (1 << 11)
1373#define SSI_CONFIG_AD (1<<10) 1370#define SSI_CONFIG_AD (1 << 10)
1374#define SSI_CONFIG_BM (3<<8) 1371#define SSI_CONFIG_BM (3 << 8)
1375#define SSI_CONFIG_CE (1<<7) 1372#define SSI_CONFIG_CE (1 << 7)
1376#define SSI_CONFIG_DP (1<<6) 1373#define SSI_CONFIG_DP (1 << 6)
1377#define SSI_CONFIG_DL (1<<5) 1374#define SSI_CONFIG_DL (1 << 5)
1378#define SSI_CONFIG_EP (1<<4) 1375#define SSI_CONFIG_EP (1 << 4)
1379#define SSI_CONFIG_ALEN_N(N) ((N-1)<<20) 1376#define SSI_CONFIG_ALEN_N(N) ((N-1) << 20)
1380#define SSI_CONFIG_DLEN_N(N) ((N-1)<<16) 1377#define SSI_CONFIG_DLEN_N(N) ((N-1) << 16)
1381#define SSI_CONFIG_BM_HI (0<<8) 1378#define SSI_CONFIG_BM_HI (0 << 8)
1382#define SSI_CONFIG_BM_LO (1<<8) 1379#define SSI_CONFIG_BM_LO (1 << 8)
1383#define SSI_CONFIG_BM_CY (2<<8) 1380#define SSI_CONFIG_BM_CY (2 << 8)
1384 1381
1385#define SSI_ADATA_D (1<<24) 1382#define SSI_ADATA_D (1 << 24)
1386#define SSI_ADATA_ADDR (0xFF<<16) 1383#define SSI_ADATA_ADDR (0xFF << 16)
1387#define SSI_ADATA_DATA (0x0FFF) 1384#define SSI_ADATA_DATA 0x0FFF
1388#define SSI_ADATA_ADDR_N(N) (N<<16) 1385#define SSI_ADATA_ADDR_N(N) (N << 16)
1389 1386
1390#define SSI_ENABLE_CD (1<<1) 1387#define SSI_ENABLE_CD (1 << 1)
1391#define SSI_ENABLE_E (1<<0) 1388#define SSI_ENABLE_E (1 << 0)
1392
1393 1389
1394/* IrDA Controller */ 1390/* IrDA Controller */
1395#define IRDA_BASE 0xB0300000 1391#define IRDA_BASE 0xB0300000
1396#define IR_RING_PTR_STATUS (IRDA_BASE+0x00) 1392#define IR_RING_PTR_STATUS (IRDA_BASE + 0x00)
1397#define IR_RING_BASE_ADDR_H (IRDA_BASE+0x04) 1393#define IR_RING_BASE_ADDR_H (IRDA_BASE + 0x04)
1398#define IR_RING_BASE_ADDR_L (IRDA_BASE+0x08) 1394#define IR_RING_BASE_ADDR_L (IRDA_BASE + 0x08)
1399#define IR_RING_SIZE (IRDA_BASE+0x0C) 1395#define IR_RING_SIZE (IRDA_BASE + 0x0C)
1400#define IR_RING_PROMPT (IRDA_BASE+0x10) 1396#define IR_RING_PROMPT (IRDA_BASE + 0x10)
1401#define IR_RING_ADDR_CMPR (IRDA_BASE+0x14) 1397#define IR_RING_ADDR_CMPR (IRDA_BASE + 0x14)
1402#define IR_INT_CLEAR (IRDA_BASE+0x18) 1398#define IR_INT_CLEAR (IRDA_BASE + 0x18)
1403#define IR_CONFIG_1 (IRDA_BASE+0x20) 1399#define IR_CONFIG_1 (IRDA_BASE + 0x20)
1404# define IR_RX_INVERT_LED (1<<0) 1400# define IR_RX_INVERT_LED (1 << 0)
1405# define IR_TX_INVERT_LED (1<<1) 1401# define IR_TX_INVERT_LED (1 << 1)
1406# define IR_ST (1<<2) 1402# define IR_ST (1 << 2)
1407# define IR_SF (1<<3) 1403# define IR_SF (1 << 3)
1408# define IR_SIR (1<<4) 1404# define IR_SIR (1 << 4)
1409# define IR_MIR (1<<5) 1405# define IR_MIR (1 << 5)
1410# define IR_FIR (1<<6) 1406# define IR_FIR (1 << 6)
1411# define IR_16CRC (1<<7) 1407# define IR_16CRC (1 << 7)
1412# define IR_TD (1<<8) 1408# define IR_TD (1 << 8)
1413# define IR_RX_ALL (1<<9) 1409# define IR_RX_ALL (1 << 9)
1414# define IR_DMA_ENABLE (1<<10) 1410# define IR_DMA_ENABLE (1 << 10)
1415# define IR_RX_ENABLE (1<<11) 1411# define IR_RX_ENABLE (1 << 11)
1416# define IR_TX_ENABLE (1<<12) 1412# define IR_TX_ENABLE (1 << 12)
1417# define IR_LOOPBACK (1<<14) 1413# define IR_LOOPBACK (1 << 14)
1418# define IR_SIR_MODE (IR_SIR | IR_DMA_ENABLE | \ 1414# define IR_SIR_MODE (IR_SIR | IR_DMA_ENABLE | \
1419 IR_RX_ALL | IR_RX_ENABLE | IR_SF | IR_16CRC) 1415 IR_RX_ALL | IR_RX_ENABLE | IR_SF | IR_16CRC)
1420#define IR_SIR_FLAGS (IRDA_BASE+0x24) 1416#define IR_SIR_FLAGS (IRDA_BASE + 0x24)
1421#define IR_ENABLE (IRDA_BASE+0x28) 1417#define IR_ENABLE (IRDA_BASE + 0x28)
1422# define IR_RX_STATUS (1<<9) 1418# define IR_RX_STATUS (1 << 9)
1423# define IR_TX_STATUS (1<<10) 1419# define IR_TX_STATUS (1 << 10)
1424#define IR_READ_PHY_CONFIG (IRDA_BASE+0x2C) 1420#define IR_READ_PHY_CONFIG (IRDA_BASE + 0x2C)
1425#define IR_WRITE_PHY_CONFIG (IRDA_BASE+0x30) 1421#define IR_WRITE_PHY_CONFIG (IRDA_BASE + 0x30)
1426#define IR_MAX_PKT_LEN (IRDA_BASE+0x34) 1422#define IR_MAX_PKT_LEN (IRDA_BASE + 0x34)
1427#define IR_RX_BYTE_CNT (IRDA_BASE+0x38) 1423#define IR_RX_BYTE_CNT (IRDA_BASE + 0x38)
1428#define IR_CONFIG_2 (IRDA_BASE+0x3C) 1424#define IR_CONFIG_2 (IRDA_BASE + 0x3C)
1429# define IR_MODE_INV (1<<0) 1425# define IR_MODE_INV (1 << 0)
1430# define IR_ONE_PIN (1<<1) 1426# define IR_ONE_PIN (1 << 1)
1431#define IR_INTERFACE_CONFIG (IRDA_BASE+0x40) 1427#define IR_INTERFACE_CONFIG (IRDA_BASE + 0x40)
1432 1428
1433/* GPIO */ 1429/* GPIO */
1434#define SYS_PINFUNC 0xB190002C 1430#define SYS_PINFUNC 0xB190002C
1435# define SYS_PF_USB (1<<15) /* 2nd USB device/host */ 1431# define SYS_PF_USB (1 << 15) /* 2nd USB device/host */
1436# define SYS_PF_U3 (1<<14) /* GPIO23/U3TXD */ 1432# define SYS_PF_U3 (1 << 14) /* GPIO23/U3TXD */
1437# define SYS_PF_U2 (1<<13) /* GPIO22/U2TXD */ 1433# define SYS_PF_U2 (1 << 13) /* GPIO22/U2TXD */
1438# define SYS_PF_U1 (1<<12) /* GPIO21/U1TXD */ 1434# define SYS_PF_U1 (1 << 12) /* GPIO21/U1TXD */
1439# define SYS_PF_SRC (1<<11) /* GPIO6/SROMCKE */ 1435# define SYS_PF_SRC (1 << 11) /* GPIO6/SROMCKE */
1440# define SYS_PF_CK5 (1<<10) /* GPIO3/CLK5 */ 1436# define SYS_PF_CK5 (1 << 10) /* GPIO3/CLK5 */
1441# define SYS_PF_CK4 (1<<9) /* GPIO2/CLK4 */ 1437# define SYS_PF_CK4 (1 << 9) /* GPIO2/CLK4 */
1442# define SYS_PF_IRF (1<<8) /* GPIO15/IRFIRSEL */ 1438# define SYS_PF_IRF (1 << 8) /* GPIO15/IRFIRSEL */
1443# define SYS_PF_UR3 (1<<7) /* GPIO[14:9]/UART3 */ 1439# define SYS_PF_UR3 (1 << 7) /* GPIO[14:9]/UART3 */
1444# define SYS_PF_I2D (1<<6) /* GPIO8/I2SDI */ 1440# define SYS_PF_I2D (1 << 6) /* GPIO8/I2SDI */
1445# define SYS_PF_I2S (1<<5) /* I2S/GPIO[29:31] */ 1441# define SYS_PF_I2S (1 << 5) /* I2S/GPIO[29:31] */
1446# define SYS_PF_NI2 (1<<4) /* NI2/GPIO[24:28] */ 1442# define SYS_PF_NI2 (1 << 4) /* NI2/GPIO[24:28] */
1447# define SYS_PF_U0 (1<<3) /* U0TXD/GPIO20 */ 1443# define SYS_PF_U0 (1 << 3) /* U0TXD/GPIO20 */
1448# define SYS_PF_RD (1<<2) /* IRTXD/GPIO19 */ 1444# define SYS_PF_RD (1 << 2) /* IRTXD/GPIO19 */
1449# define SYS_PF_A97 (1<<1) /* AC97/SSL1 */ 1445# define SYS_PF_A97 (1 << 1) /* AC97/SSL1 */
1450# define SYS_PF_S0 (1<<0) /* SSI_0/GPIO[16:18] */ 1446# define SYS_PF_S0 (1 << 0) /* SSI_0/GPIO[16:18] */
1451 1447
1452/* Au1100 Only */ 1448/* Au1100 only */
1453# define SYS_PF_PC (1<<18) /* PCMCIA/GPIO[207:204] */ 1449# define SYS_PF_PC (1 << 18) /* PCMCIA/GPIO[207:204] */
1454# define SYS_PF_LCD (1<<17) /* extern lcd/GPIO[203:200] */ 1450# define SYS_PF_LCD (1 << 17) /* extern lcd/GPIO[203:200] */
1455# define SYS_PF_CS (1<<16) /* EXTCLK0/32khz to gpio2 */ 1451# define SYS_PF_CS (1 << 16) /* EXTCLK0/32KHz to gpio2 */
1456# define SYS_PF_EX0 (1<<9) /* gpio2/clock */ 1452# define SYS_PF_EX0 (1 << 9) /* GPIO2/clock */
1457 1453
1458/* Au1550 Only. Redefines lots of pins */ 1454/* Au1550 only. Redefines lots of pins */
1459# define SYS_PF_PSC2_MASK (7 << 17) 1455# define SYS_PF_PSC2_MASK (7 << 17)
1460# define SYS_PF_PSC2_AC97 (0) 1456# define SYS_PF_PSC2_AC97 0
1461# define SYS_PF_PSC2_SPI (0) 1457# define SYS_PF_PSC2_SPI 0
1462# define SYS_PF_PSC2_I2S (1 << 17) 1458# define SYS_PF_PSC2_I2S (1 << 17)
1463# define SYS_PF_PSC2_SMBUS (3 << 17) 1459# define SYS_PF_PSC2_SMBUS (3 << 17)
1464# define SYS_PF_PSC2_GPIO (7 << 17) 1460# define SYS_PF_PSC2_GPIO (7 << 17)
1465# define SYS_PF_PSC3_MASK (7 << 20) 1461# define SYS_PF_PSC3_MASK (7 << 20)
1466# define SYS_PF_PSC3_AC97 (0) 1462# define SYS_PF_PSC3_AC97 0
1467# define SYS_PF_PSC3_SPI (0) 1463# define SYS_PF_PSC3_SPI 0
1468# define SYS_PF_PSC3_I2S (1 << 20) 1464# define SYS_PF_PSC3_I2S (1 << 20)
1469# define SYS_PF_PSC3_SMBUS (3 << 20) 1465# define SYS_PF_PSC3_SMBUS (3 << 20)
1470# define SYS_PF_PSC3_GPIO (7 << 20) 1466# define SYS_PF_PSC3_GPIO (7 << 20)
1471# define SYS_PF_PSC1_S1 (1 << 1) 1467# define SYS_PF_PSC1_S1 (1 << 1)
1472# define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2)) 1468# define SYS_PF_MUST_BE_SET ((1 << 5) | (1 << 2))
1473 1469
1474/* Au1200 Only */ 1470/* Au1200 only */
1475#ifdef CONFIG_SOC_AU1200 1471#ifdef CONFIG_SOC_AU1200
1476#define SYS_PINFUNC_DMA (1<<31) 1472#define SYS_PINFUNC_DMA (1 << 31)
1477#define SYS_PINFUNC_S0A (1<<30) 1473#define SYS_PINFUNC_S0A (1 << 30)
1478#define SYS_PINFUNC_S1A (1<<29) 1474#define SYS_PINFUNC_S1A (1 << 29)
1479#define SYS_PINFUNC_LP0 (1<<28) 1475#define SYS_PINFUNC_LP0 (1 << 28)
1480#define SYS_PINFUNC_LP1 (1<<27) 1476#define SYS_PINFUNC_LP1 (1 << 27)
1481#define SYS_PINFUNC_LD16 (1<<26) 1477#define SYS_PINFUNC_LD16 (1 << 26)
1482#define SYS_PINFUNC_LD8 (1<<25) 1478#define SYS_PINFUNC_LD8 (1 << 25)
1483#define SYS_PINFUNC_LD1 (1<<24) 1479#define SYS_PINFUNC_LD1 (1 << 24)
1484#define SYS_PINFUNC_LD0 (1<<23) 1480#define SYS_PINFUNC_LD0 (1 << 23)
1485#define SYS_PINFUNC_P1A (3<<21) 1481#define SYS_PINFUNC_P1A (3 << 21)
1486#define SYS_PINFUNC_P1B (1<<20) 1482#define SYS_PINFUNC_P1B (1 << 20)
1487#define SYS_PINFUNC_FS3 (1<<19) 1483#define SYS_PINFUNC_FS3 (1 << 19)
1488#define SYS_PINFUNC_P0A (3<<17) 1484#define SYS_PINFUNC_P0A (3 << 17)
1489#define SYS_PINFUNC_CS (1<<16) 1485#define SYS_PINFUNC_CS (1 << 16)
1490#define SYS_PINFUNC_CIM (1<<15) 1486#define SYS_PINFUNC_CIM (1 << 15)
1491#define SYS_PINFUNC_P1C (1<<14) 1487#define SYS_PINFUNC_P1C (1 << 14)
1492#define SYS_PINFUNC_U1T (1<<12) 1488#define SYS_PINFUNC_U1T (1 << 12)
1493#define SYS_PINFUNC_U1R (1<<11) 1489#define SYS_PINFUNC_U1R (1 << 11)
1494#define SYS_PINFUNC_EX1 (1<<10) 1490#define SYS_PINFUNC_EX1 (1 << 10)
1495#define SYS_PINFUNC_EX0 (1<<9) 1491#define SYS_PINFUNC_EX0 (1 << 9)
1496#define SYS_PINFUNC_U0R (1<<8) 1492#define SYS_PINFUNC_U0R (1 << 8)
1497#define SYS_PINFUNC_MC (1<<7) 1493#define SYS_PINFUNC_MC (1 << 7)
1498#define SYS_PINFUNC_S0B (1<<6) 1494#define SYS_PINFUNC_S0B (1 << 6)
1499#define SYS_PINFUNC_S0C (1<<5) 1495#define SYS_PINFUNC_S0C (1 << 5)
1500#define SYS_PINFUNC_P0B (1<<4) 1496#define SYS_PINFUNC_P0B (1 << 4)
1501#define SYS_PINFUNC_U0T (1<<3) 1497#define SYS_PINFUNC_U0T (1 << 3)
1502#define SYS_PINFUNC_S1B (1<<2) 1498#define SYS_PINFUNC_S1B (1 << 2)
1503#endif 1499#endif
1504 1500
1505#define SYS_TRIOUTRD 0xB1900100 1501#define SYS_TRIOUTRD 0xB1900100
1506#define SYS_TRIOUTCLR 0xB1900100 1502#define SYS_TRIOUTCLR 0xB1900100
1507#define SYS_OUTPUTRD 0xB1900108 1503#define SYS_OUTPUTRD 0xB1900108
1508#define SYS_OUTPUTSET 0xB1900108 1504#define SYS_OUTPUTSET 0xB1900108
1509#define SYS_OUTPUTCLR 0xB190010C 1505#define SYS_OUTPUTCLR 0xB190010C
1510#define SYS_PINSTATERD 0xB1900110 1506#define SYS_PINSTATERD 0xB1900110
1511#define SYS_PININPUTEN 0xB1900110 1507#define SYS_PININPUTEN 0xB1900110
1512 1508
1513/* GPIO2, Au1500, Au1550 only */ 1509/* GPIO2, Au1500, Au1550 only */
1514#define GPIO2_BASE 0xB1700000 1510#define GPIO2_BASE 0xB1700000
1515#define GPIO2_DIR (GPIO2_BASE + 0) 1511#define GPIO2_DIR (GPIO2_BASE + 0)
1516#define GPIO2_OUTPUT (GPIO2_BASE + 8) 1512#define GPIO2_OUTPUT (GPIO2_BASE + 8)
1517#define GPIO2_PINSTATE (GPIO2_BASE + 0xC) 1513#define GPIO2_PINSTATE (GPIO2_BASE + 0xC)
1518#define GPIO2_INTENABLE (GPIO2_BASE + 0x10) 1514#define GPIO2_INTENABLE (GPIO2_BASE + 0x10)
1519#define GPIO2_ENABLE (GPIO2_BASE + 0x14) 1515#define GPIO2_ENABLE (GPIO2_BASE + 0x14)
1520 1516
1521/* Power Management */ 1517/* Power Management */
1522#define SYS_SCRATCH0 0xB1900018 1518#define SYS_SCRATCH0 0xB1900018
1523#define SYS_SCRATCH1 0xB190001C 1519#define SYS_SCRATCH1 0xB190001C
1524#define SYS_WAKEMSK 0xB1900034 1520#define SYS_WAKEMSK 0xB1900034
1525#define SYS_ENDIAN 0xB1900038 1521#define SYS_ENDIAN 0xB1900038
1526#define SYS_POWERCTRL 0xB190003C 1522#define SYS_POWERCTRL 0xB190003C
1527#define SYS_WAKESRC 0xB190005C 1523#define SYS_WAKESRC 0xB190005C
1528#define SYS_SLPPWR 0xB1900078 1524#define SYS_SLPPWR 0xB1900078
1529#define SYS_SLEEP 0xB190007C 1525#define SYS_SLEEP 0xB190007C
1530 1526
1531/* Clock Controller */ 1527/* Clock Controller */
1532#define SYS_FREQCTRL0 0xB1900020 1528#define SYS_FREQCTRL0 0xB1900020
1533# define SYS_FC_FRDIV2_BIT 22 1529# define SYS_FC_FRDIV2_BIT 22
1534# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT) 1530# define SYS_FC_FRDIV2_MASK (0xff << SYS_FC_FRDIV2_BIT)
1535# define SYS_FC_FE2 (1<<21) 1531# define SYS_FC_FE2 (1 << 21)
1536# define SYS_FC_FS2 (1<<20) 1532# define SYS_FC_FS2 (1 << 20)
1537# define SYS_FC_FRDIV1_BIT 12 1533# define SYS_FC_FRDIV1_BIT 12
1538# define SYS_FC_FRDIV1_MASK (0xff << SYS_FC_FRDIV1_BIT) 1534# define SYS_FC_FRDIV1_MASK (0xff << SYS_FC_FRDIV1_BIT)
1539# define SYS_FC_FE1 (1<<11) 1535# define SYS_FC_FE1 (1 << 11)
1540# define SYS_FC_FS1 (1<<10) 1536# define SYS_FC_FS1 (1 << 10)
1541# define SYS_FC_FRDIV0_BIT 2 1537# define SYS_FC_FRDIV0_BIT 2
1542# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT) 1538# define SYS_FC_FRDIV0_MASK (0xff << SYS_FC_FRDIV0_BIT)
1543# define SYS_FC_FE0 (1<<1) 1539# define SYS_FC_FE0 (1 << 1)
1544# define SYS_FC_FS0 (1<<0) 1540# define SYS_FC_FS0 (1 << 0)
1545#define SYS_FREQCTRL1 0xB1900024 1541#define SYS_FREQCTRL1 0xB1900024
1546# define SYS_FC_FRDIV5_BIT 22 1542# define SYS_FC_FRDIV5_BIT 22
1547# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT) 1543# define SYS_FC_FRDIV5_MASK (0xff << SYS_FC_FRDIV5_BIT)
1548# define SYS_FC_FE5 (1<<21) 1544# define SYS_FC_FE5 (1 << 21)
1549# define SYS_FC_FS5 (1<<20) 1545# define SYS_FC_FS5 (1 << 20)
1550# define SYS_FC_FRDIV4_BIT 12 1546# define SYS_FC_FRDIV4_BIT 12
1551# define SYS_FC_FRDIV4_MASK (0xff << SYS_FC_FRDIV4_BIT) 1547# define SYS_FC_FRDIV4_MASK (0xff << SYS_FC_FRDIV4_BIT)
1552# define SYS_FC_FE4 (1<<11) 1548# define SYS_FC_FE4 (1 << 11)
1553# define SYS_FC_FS4 (1<<10) 1549# define SYS_FC_FS4 (1 << 10)
1554# define SYS_FC_FRDIV3_BIT 2 1550# define SYS_FC_FRDIV3_BIT 2
1555# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT) 1551# define SYS_FC_FRDIV3_MASK (0xff << SYS_FC_FRDIV3_BIT)
1556# define SYS_FC_FE3 (1<<1) 1552# define SYS_FC_FE3 (1 << 1)
1557# define SYS_FC_FS3 (1<<0) 1553# define SYS_FC_FS3 (1 << 0)
1558#define SYS_CLKSRC 0xB1900028 1554#define SYS_CLKSRC 0xB1900028
1559# define SYS_CS_ME1_BIT 27 1555# define SYS_CS_ME1_BIT 27
1560# define SYS_CS_ME1_MASK (0x7<<SYS_CS_ME1_BIT) 1556# define SYS_CS_ME1_MASK (0x7 << SYS_CS_ME1_BIT)
1561# define SYS_CS_DE1 (1<<26) 1557# define SYS_CS_DE1 (1 << 26)
1562# define SYS_CS_CE1 (1<<25) 1558# define SYS_CS_CE1 (1 << 25)
1563# define SYS_CS_ME0_BIT 22 1559# define SYS_CS_ME0_BIT 22
1564# define SYS_CS_ME0_MASK (0x7<<SYS_CS_ME0_BIT) 1560# define SYS_CS_ME0_MASK (0x7 << SYS_CS_ME0_BIT)
1565# define SYS_CS_DE0 (1<<21) 1561# define SYS_CS_DE0 (1 << 21)
1566# define SYS_CS_CE0 (1<<20) 1562# define SYS_CS_CE0 (1 << 20)
1567# define SYS_CS_MI2_BIT 17 1563# define SYS_CS_MI2_BIT 17
1568# define SYS_CS_MI2_MASK (0x7<<SYS_CS_MI2_BIT) 1564# define SYS_CS_MI2_MASK (0x7 << SYS_CS_MI2_BIT)
1569# define SYS_CS_DI2 (1<<16) 1565# define SYS_CS_DI2 (1 << 16)
1570# define SYS_CS_CI2 (1<<15) 1566# define SYS_CS_CI2 (1 << 15)
1571#ifdef CONFIG_SOC_AU1100 1567#ifdef CONFIG_SOC_AU1100
1572# define SYS_CS_ML_BIT 7 1568# define SYS_CS_ML_BIT 7
1573# define SYS_CS_ML_MASK (0x7<<SYS_CS_ML_BIT) 1569# define SYS_CS_ML_MASK (0x7 << SYS_CS_ML_BIT)
1574# define SYS_CS_DL (1<<6) 1570# define SYS_CS_DL (1 << 6)
1575# define SYS_CS_CL (1<<5) 1571# define SYS_CS_CL (1 << 5)
1576#else 1572#else
1577# define SYS_CS_MUH_BIT 12 1573# define SYS_CS_MUH_BIT 12
1578# define SYS_CS_MUH_MASK (0x7<<SYS_CS_MUH_BIT) 1574# define SYS_CS_MUH_MASK (0x7 << SYS_CS_MUH_BIT)
1579# define SYS_CS_DUH (1<<11) 1575# define SYS_CS_DUH (1 << 11)
1580# define SYS_CS_CUH (1<<10) 1576# define SYS_CS_CUH (1 << 10)
1581# define SYS_CS_MUD_BIT 7 1577# define SYS_CS_MUD_BIT 7
1582# define SYS_CS_MUD_MASK (0x7<<SYS_CS_MUD_BIT) 1578# define SYS_CS_MUD_MASK (0x7 << SYS_CS_MUD_BIT)
1583# define SYS_CS_DUD (1<<6) 1579# define SYS_CS_DUD (1 << 6)
1584# define SYS_CS_CUD (1<<5) 1580# define SYS_CS_CUD (1 << 5)
1585#endif 1581#endif
1586# define SYS_CS_MIR_BIT 2 1582# define SYS_CS_MIR_BIT 2
1587# define SYS_CS_MIR_MASK (0x7<<SYS_CS_MIR_BIT) 1583# define SYS_CS_MIR_MASK (0x7 << SYS_CS_MIR_BIT)
1588# define SYS_CS_DIR (1<<1) 1584# define SYS_CS_DIR (1 << 1)
1589# define SYS_CS_CIR (1<<0) 1585# define SYS_CS_CIR (1 << 0)
1590 1586
1591# define SYS_CS_MUX_AUX 0x1 1587# define SYS_CS_MUX_AUX 0x1
1592# define SYS_CS_MUX_FQ0 0x2 1588# define SYS_CS_MUX_FQ0 0x2
1593# define SYS_CS_MUX_FQ1 0x3 1589# define SYS_CS_MUX_FQ1 0x3
1594# define SYS_CS_MUX_FQ2 0x4 1590# define SYS_CS_MUX_FQ2 0x4
1595# define SYS_CS_MUX_FQ3 0x5 1591# define SYS_CS_MUX_FQ3 0x5
1596# define SYS_CS_MUX_FQ4 0x6 1592# define SYS_CS_MUX_FQ4 0x6
1597# define SYS_CS_MUX_FQ5 0x7 1593# define SYS_CS_MUX_FQ5 0x7
1598#define SYS_CPUPLL 0xB1900060 1594#define SYS_CPUPLL 0xB1900060
1599#define SYS_AUXPLL 0xB1900064 1595#define SYS_AUXPLL 0xB1900064
1600 1596
1601/* AC97 Controller */ 1597/* AC97 Controller */
1602#define AC97C_CONFIG 0xB0000000 1598#define AC97C_CONFIG 0xB0000000
1603# define AC97C_RECV_SLOTS_BIT 13 1599# define AC97C_RECV_SLOTS_BIT 13
1604# define AC97C_RECV_SLOTS_MASK (0x3ff << AC97C_RECV_SLOTS_BIT) 1600# define AC97C_RECV_SLOTS_MASK (0x3ff << AC97C_RECV_SLOTS_BIT)
1605# define AC97C_XMIT_SLOTS_BIT 3 1601# define AC97C_XMIT_SLOTS_BIT 3
1606# define AC97C_XMIT_SLOTS_MASK (0x3ff << AC97C_XMIT_SLOTS_BIT) 1602# define AC97C_XMIT_SLOTS_MASK (0x3ff << AC97C_XMIT_SLOTS_BIT)
1607# define AC97C_SG (1<<2) 1603# define AC97C_SG (1 << 2)
1608# define AC97C_SYNC (1<<1) 1604# define AC97C_SYNC (1 << 1)
1609# define AC97C_RESET (1<<0) 1605# define AC97C_RESET (1 << 0)
1610#define AC97C_STATUS 0xB0000004 1606#define AC97C_STATUS 0xB0000004
1611# define AC97C_XU (1<<11) 1607# define AC97C_XU (1 << 11)
1612# define AC97C_XO (1<<10) 1608# define AC97C_XO (1 << 10)
1613# define AC97C_RU (1<<9) 1609# define AC97C_RU (1 << 9)
1614# define AC97C_RO (1<<8) 1610# define AC97C_RO (1 << 8)
1615# define AC97C_READY (1<<7) 1611# define AC97C_READY (1 << 7)
1616# define AC97C_CP (1<<6) 1612# define AC97C_CP (1 << 6)
1617# define AC97C_TR (1<<5) 1613# define AC97C_TR (1 << 5)
1618# define AC97C_TE (1<<4) 1614# define AC97C_TE (1 << 4)
1619# define AC97C_TF (1<<3) 1615# define AC97C_TF (1 << 3)
1620# define AC97C_RR (1<<2) 1616# define AC97C_RR (1 << 2)
1621# define AC97C_RE (1<<1) 1617# define AC97C_RE (1 << 1)
1622# define AC97C_RF (1<<0) 1618# define AC97C_RF (1 << 0)
1623#define AC97C_DATA 0xB0000008 1619#define AC97C_DATA 0xB0000008
1624#define AC97C_CMD 0xB000000C 1620#define AC97C_CMD 0xB000000C
1625# define AC97C_WD_BIT 16 1621# define AC97C_WD_BIT 16
1626# define AC97C_READ (1<<7) 1622# define AC97C_READ (1 << 7)
1627# define AC97C_INDEX_MASK 0x7f 1623# define AC97C_INDEX_MASK 0x7f
1628#define AC97C_CNTRL 0xB0000010 1624#define AC97C_CNTRL 0xB0000010
1629# define AC97C_RS (1<<1) 1625# define AC97C_RS (1 << 1)
1630# define AC97C_CE (1<<0) 1626# define AC97C_CE (1 << 0)
1631
1632 1627
1633/* Secure Digital (SD) Controller */ 1628/* Secure Digital (SD) Controller */
1634#define SD0_XMIT_FIFO 0xB0600000 1629#define SD0_XMIT_FIFO 0xB0600000
@@ -1638,73 +1633,74 @@ enum soc_au1200_ints {
1638 1633
1639#if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550) 1634#if defined(CONFIG_SOC_AU1500) || defined(CONFIG_SOC_AU1550)
1640/* Au1500 PCI Controller */ 1635/* Au1500 PCI Controller */
1641#define Au1500_CFG_BASE 0xB4005000 // virtual, kseg0 addr 1636#define Au1500_CFG_BASE 0xB4005000 /* virtual, KSEG1 addr */
1642#define Au1500_PCI_CMEM (Au1500_CFG_BASE + 0) 1637#define Au1500_PCI_CMEM (Au1500_CFG_BASE + 0)
1643#define Au1500_PCI_CFG (Au1500_CFG_BASE + 4) 1638#define Au1500_PCI_CFG (Au1500_CFG_BASE + 4)
1644# define PCI_ERROR ((1<<22) | (1<<23) | (1<<24) | (1<<25) | (1<<26) | (1<<27)) 1639# define PCI_ERROR ((1 << 22) | (1 << 23) | (1 << 24) | \
1645#define Au1500_PCI_B2BMASK_CCH (Au1500_CFG_BASE + 8) 1640 (1 << 25) | (1 << 26) | (1 << 27))
1646#define Au1500_PCI_B2B0_VID (Au1500_CFG_BASE + 0xC) 1641#define Au1500_PCI_B2BMASK_CCH (Au1500_CFG_BASE + 8)
1647#define Au1500_PCI_B2B1_ID (Au1500_CFG_BASE + 0x10) 1642#define Au1500_PCI_B2B0_VID (Au1500_CFG_BASE + 0xC)
1648#define Au1500_PCI_MWMASK_DEV (Au1500_CFG_BASE + 0x14) 1643#define Au1500_PCI_B2B1_ID (Au1500_CFG_BASE + 0x10)
1644#define Au1500_PCI_MWMASK_DEV (Au1500_CFG_BASE + 0x14)
1649#define Au1500_PCI_MWBASE_REV_CCL (Au1500_CFG_BASE + 0x18) 1645#define Au1500_PCI_MWBASE_REV_CCL (Au1500_CFG_BASE + 0x18)
1650#define Au1500_PCI_ERR_ADDR (Au1500_CFG_BASE + 0x1C) 1646#define Au1500_PCI_ERR_ADDR (Au1500_CFG_BASE + 0x1C)
1651#define Au1500_PCI_SPEC_INTACK (Au1500_CFG_BASE + 0x20) 1647#define Au1500_PCI_SPEC_INTACK (Au1500_CFG_BASE + 0x20)
1652#define Au1500_PCI_ID (Au1500_CFG_BASE + 0x100) 1648#define Au1500_PCI_ID (Au1500_CFG_BASE + 0x100)
1653#define Au1500_PCI_STATCMD (Au1500_CFG_BASE + 0x104) 1649#define Au1500_PCI_STATCMD (Au1500_CFG_BASE + 0x104)
1654#define Au1500_PCI_CLASSREV (Au1500_CFG_BASE + 0x108) 1650#define Au1500_PCI_CLASSREV (Au1500_CFG_BASE + 0x108)
1655#define Au1500_PCI_HDRTYPE (Au1500_CFG_BASE + 0x10C) 1651#define Au1500_PCI_HDRTYPE (Au1500_CFG_BASE + 0x10C)
1656#define Au1500_PCI_MBAR (Au1500_CFG_BASE + 0x110) 1652#define Au1500_PCI_MBAR (Au1500_CFG_BASE + 0x110)
1657 1653
1658#define Au1500_PCI_HDR 0xB4005100 // virtual, kseg0 addr 1654#define Au1500_PCI_HDR 0xB4005100 /* virtual, KSEG1 addr */
1659 1655
1660/* All of our structures, like pci resource, have 32 bit members. 1656/*
1657 * All of our structures, like PCI resource, have 32-bit members.
1661 * Drivers are expected to do an ioremap on the PCI MEM resource, but it's 1658 * Drivers are expected to do an ioremap on the PCI MEM resource, but it's
1662 * hard to store 0x4 0000 0000 in a 32 bit type. We require a small patch 1659 * hard to store 0x4 0000 0000 in a 32-bit type. We require a small patch
1663 * to __ioremap to check for addresses between (u32)Au1500_PCI_MEM_START and 1660 * to __ioremap to check for addresses between (u32)Au1500_PCI_MEM_START and
1664 * (u32)Au1500_PCI_MEM_END and change those to the full 36 bit PCI MEM 1661 * (u32)Au1500_PCI_MEM_END and change those to the full 36-bit PCI MEM
1665 * addresses. For PCI IO, it's simpler because we get to do the ioremap 1662 * addresses. For PCI I/O, it's simpler because we get to do the ioremap
1666 * ourselves and then adjust the device's resources. 1663 * ourselves and then adjust the device's resources.
1667 */ 1664 */
1668#define Au1500_EXT_CFG 0x600000000ULL 1665#define Au1500_EXT_CFG 0x600000000ULL
1669#define Au1500_EXT_CFG_TYPE1 0x680000000ULL 1666#define Au1500_EXT_CFG_TYPE1 0x680000000ULL
1670#define Au1500_PCI_IO_START 0x500000000ULL 1667#define Au1500_PCI_IO_START 0x500000000ULL
1671#define Au1500_PCI_IO_END 0x5000FFFFFULL 1668#define Au1500_PCI_IO_END 0x5000FFFFFULL
1672#define Au1500_PCI_MEM_START 0x440000000ULL 1669#define Au1500_PCI_MEM_START 0x440000000ULL
1673#define Au1500_PCI_MEM_END 0x44FFFFFFFULL 1670#define Au1500_PCI_MEM_END 0x44FFFFFFFULL
1674 1671
1675#define PCI_IO_START 0x00001000 1672#define PCI_IO_START 0x00001000
1676#define PCI_IO_END 0x000FFFFF 1673#define PCI_IO_END 0x000FFFFF
1677#define PCI_MEM_START 0x40000000 1674#define PCI_MEM_START 0x40000000
1678#define PCI_MEM_END 0x4FFFFFFF 1675#define PCI_MEM_END 0x4FFFFFFF
1679 1676
1680#define PCI_FIRST_DEVFN (0<<3) 1677#define PCI_FIRST_DEVFN (0 << 3)
1681#define PCI_LAST_DEVFN (19<<3) 1678#define PCI_LAST_DEVFN (19 << 3)
1682 1679
1683#define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */ 1680#define IOPORT_RESOURCE_START 0x00001000 /* skip legacy probing */
1684#define IOPORT_RESOURCE_END 0xffffffff 1681#define IOPORT_RESOURCE_END 0xffffffff
1685#define IOMEM_RESOURCE_START 0x10000000 1682#define IOMEM_RESOURCE_START 0x10000000
1686#define IOMEM_RESOURCE_END 0xffffffff 1683#define IOMEM_RESOURCE_END 0xffffffff
1687 1684
1688#else /* Au1000 and Au1100 and Au1200 */ 1685#else /* Au1000 and Au1100 and Au1200 */
1689 1686
1690/* don't allow any legacy ports probing */ 1687/* Don't allow any legacy ports probing */
1691#define IOPORT_RESOURCE_START 0x10000000 1688#define IOPORT_RESOURCE_START 0x10000000
1692#define IOPORT_RESOURCE_END 0xffffffff 1689#define IOPORT_RESOURCE_END 0xffffffff
1693#define IOMEM_RESOURCE_START 0x10000000 1690#define IOMEM_RESOURCE_START 0x10000000
1694#define IOMEM_RESOURCE_END 0xffffffff 1691#define IOMEM_RESOURCE_END 0xffffffff
1695 1692
1696#define PCI_IO_START 0 1693#define PCI_IO_START 0
1697#define PCI_IO_END 0 1694#define PCI_IO_END 0
1698#define PCI_MEM_START 0 1695#define PCI_MEM_START 0
1699#define PCI_MEM_END 0 1696#define PCI_MEM_END 0
1700#define PCI_FIRST_DEVFN 0 1697#define PCI_FIRST_DEVFN 0
1701#define PCI_LAST_DEVFN 0 1698#define PCI_LAST_DEVFN 0
1702 1699
1703#endif 1700#endif
1704 1701
1705#ifndef _LANGUAGE_ASSEMBLY 1702#ifndef _LANGUAGE_ASSEMBLY
1706typedef volatile struct 1703typedef volatile struct {
1707{
1708 /* 0x0000 */ u32 toytrim; 1704 /* 0x0000 */ u32 toytrim;
1709 /* 0x0004 */ u32 toywrite; 1705 /* 0x0004 */ u32 toywrite;
1710 /* 0x0008 */ u32 toymatch0; 1706 /* 0x0008 */ u32 toymatch0;
@@ -1746,13 +1742,14 @@ typedef volatile struct
1746 /* 0x010C */ u32 outputclr; 1742 /* 0x010C */ u32 outputclr;
1747 /* 0x0110 */ u32 pinstaterd; 1743 /* 0x0110 */ u32 pinstaterd;
1748#define pininputen pinstaterd 1744#define pininputen pinstaterd
1749
1750} AU1X00_SYS; 1745} AU1X00_SYS;
1751 1746
1752static AU1X00_SYS* const sys = (AU1X00_SYS *)SYS_BASE; 1747static AU1X00_SYS * const sys = (AU1X00_SYS *)SYS_BASE;
1753 1748
1754#endif 1749#endif
1755/* Processor information base on prid. 1750
1751/*
1752 * Processor information based on PRID.
1756 * Copied from PowerPC. 1753 * Copied from PowerPC.
1757 */ 1754 */
1758#ifndef _LANGUAGE_ASSEMBLY 1755#ifndef _LANGUAGE_ASSEMBLY
@@ -1767,9 +1764,8 @@ struct cpu_spec {
1767 unsigned char cpu_pll_wo; /* sys_cpupll reg. write-only */ 1764 unsigned char cpu_pll_wo; /* sys_cpupll reg. write-only */
1768}; 1765};
1769 1766
1770extern struct cpu_spec cpu_specs[]; 1767extern struct cpu_spec cpu_specs[];
1771extern struct cpu_spec *cur_cpu_spec[]; 1768extern struct cpu_spec *cur_cpu_spec[];
1772#endif 1769#endif
1773 1770
1774#endif 1771#endif
1775
diff --git a/include/asm-mips/mach-au1x00/au1000_dma.h b/include/asm-mips/mach-au1x00/au1000_dma.h
index 9f29520e8fb0..c333b4e1cd44 100644
--- a/include/asm-mips/mach-au1x00/au1000_dma.h
+++ b/include/asm-mips/mach-au1x00/au1000_dma.h
@@ -1,11 +1,10 @@
1/* 1/*
2 * BRIEF MODULE DESCRIPTION 2 * BRIEF MODULE DESCRIPTION
3 * Defines for using and allocating dma channels on the Alchemy 3 * Defines for using and allocating DMA channels on the Alchemy
4 * Au1000 mips processor. 4 * Au1x00 MIPS processors.
5 * 5 *
6 * Copyright 2000 MontaVista Software Inc. 6 * Copyright 2000, 2008 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc. 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * stevel@mvista.com or source@mvista.com
9 * 8 *
10 * This program is free software; you can redistribute it and/or modify it 9 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
@@ -31,7 +30,7 @@
31#ifndef __ASM_AU1000_DMA_H 30#ifndef __ASM_AU1000_DMA_H
32#define __ASM_AU1000_DMA_H 31#define __ASM_AU1000_DMA_H
33 32
34#include <asm/io.h> /* need byte IO */ 33#include <linux/io.h> /* need byte IO */
35#include <linux/spinlock.h> /* And spinlocks */ 34#include <linux/spinlock.h> /* And spinlocks */
36#include <linux/delay.h> 35#include <linux/delay.h>
37#include <asm/system.h> 36#include <asm/system.h>
@@ -50,36 +49,36 @@
50#define DMA_DAH_MASK (0x0f << 20) 49#define DMA_DAH_MASK (0x0f << 20)
51#define DMA_DID_BIT 16 50#define DMA_DID_BIT 16
52#define DMA_DID_MASK (0x0f << DMA_DID_BIT) 51#define DMA_DID_MASK (0x0f << DMA_DID_BIT)
53#define DMA_DS (1<<15) 52#define DMA_DS (1 << 15)
54#define DMA_BE (1<<13) 53#define DMA_BE (1 << 13)
55#define DMA_DR (1<<12) 54#define DMA_DR (1 << 12)
56#define DMA_TS8 (1<<11) 55#define DMA_TS8 (1 << 11)
57#define DMA_DW_BIT 9 56#define DMA_DW_BIT 9
58#define DMA_DW_MASK (0x03 << DMA_DW_BIT) 57#define DMA_DW_MASK (0x03 << DMA_DW_BIT)
59#define DMA_DW8 (0 << DMA_DW_BIT) 58#define DMA_DW8 (0 << DMA_DW_BIT)
60#define DMA_DW16 (1 << DMA_DW_BIT) 59#define DMA_DW16 (1 << DMA_DW_BIT)
61#define DMA_DW32 (2 << DMA_DW_BIT) 60#define DMA_DW32 (2 << DMA_DW_BIT)
62#define DMA_NC (1<<8) 61#define DMA_NC (1 << 8)
63#define DMA_IE (1<<7) 62#define DMA_IE (1 << 7)
64#define DMA_HALT (1<<6) 63#define DMA_HALT (1 << 6)
65#define DMA_GO (1<<5) 64#define DMA_GO (1 << 5)
66#define DMA_AB (1<<4) 65#define DMA_AB (1 << 4)
67#define DMA_D1 (1<<3) 66#define DMA_D1 (1 << 3)
68#define DMA_BE1 (1<<2) 67#define DMA_BE1 (1 << 2)
69#define DMA_D0 (1<<1) 68#define DMA_D0 (1 << 1)
70#define DMA_BE0 (1<<0) 69#define DMA_BE0 (1 << 0)
71 70
72#define DMA_PERIPHERAL_ADDR 0x00000008 71#define DMA_PERIPHERAL_ADDR 0x00000008
73#define DMA_BUFFER0_START 0x0000000C 72#define DMA_BUFFER0_START 0x0000000C
74#define DMA_BUFFER1_START 0x00000014 73#define DMA_BUFFER1_START 0x00000014
75#define DMA_BUFFER0_COUNT 0x00000010 74#define DMA_BUFFER0_COUNT 0x00000010
76#define DMA_BUFFER1_COUNT 0x00000018 75#define DMA_BUFFER1_COUNT 0x00000018
77#define DMA_BAH_BIT 16 76#define DMA_BAH_BIT 16
78#define DMA_BAH_MASK (0x0f << DMA_BAH_BIT) 77#define DMA_BAH_MASK (0x0f << DMA_BAH_BIT)
79#define DMA_COUNT_BIT 0 78#define DMA_COUNT_BIT 0
80#define DMA_COUNT_MASK (0xffff << DMA_COUNT_BIT) 79#define DMA_COUNT_MASK (0xffff << DMA_COUNT_BIT)
81 80
82/* DMA Device ID's follow */ 81/* DMA Device IDs follow */
83enum { 82enum {
84 DMA_ID_UART0_TX = 0, 83 DMA_ID_UART0_TX = 0,
85 DMA_ID_UART0_RX, 84 DMA_ID_UART0_RX,
@@ -110,7 +109,8 @@ enum {
110}; 109};
111 110
112struct dma_chan { 111struct dma_chan {
113 int dev_id; // this channel is allocated if >=0, free otherwise 112 int dev_id; /* this channel is allocated if >= 0, */
113 /* free otherwise */
114 unsigned int io; 114 unsigned int io;
115 const char *dev_str; 115 const char *dev_str;
116 int irq; 116 int irq;
@@ -132,23 +132,23 @@ extern int au1000_dma_read_proc(char *buf, char **start, off_t fpos,
132extern void dump_au1000_dma_channel(unsigned int dmanr); 132extern void dump_au1000_dma_channel(unsigned int dmanr);
133extern spinlock_t au1000_dma_spin_lock; 133extern spinlock_t au1000_dma_spin_lock;
134 134
135 135static inline struct dma_chan *get_dma_chan(unsigned int dmanr)
136static __inline__ struct dma_chan *get_dma_chan(unsigned int dmanr)
137{ 136{
138 if (dmanr >= NUM_AU1000_DMA_CHANNELS 137 if (dmanr >= NUM_AU1000_DMA_CHANNELS ||
139 || au1000_dma_table[dmanr].dev_id < 0) 138 au1000_dma_table[dmanr].dev_id < 0)
140 return NULL; 139 return NULL;
141 return &au1000_dma_table[dmanr]; 140 return &au1000_dma_table[dmanr];
142} 141}
143 142
144static __inline__ unsigned long claim_dma_lock(void) 143static inline unsigned long claim_dma_lock(void)
145{ 144{
146 unsigned long flags; 145 unsigned long flags;
146
147 spin_lock_irqsave(&au1000_dma_spin_lock, flags); 147 spin_lock_irqsave(&au1000_dma_spin_lock, flags);
148 return flags; 148 return flags;
149} 149}
150 150
151static __inline__ void release_dma_lock(unsigned long flags) 151static inline void release_dma_lock(unsigned long flags)
152{ 152{
153 spin_unlock_irqrestore(&au1000_dma_spin_lock, flags); 153 spin_unlock_irqrestore(&au1000_dma_spin_lock, flags);
154} 154}
@@ -156,48 +156,53 @@ static __inline__ void release_dma_lock(unsigned long flags)
156/* 156/*
157 * Set the DMA buffer enable bits in the mode register. 157 * Set the DMA buffer enable bits in the mode register.
158 */ 158 */
159static __inline__ void enable_dma_buffer0(unsigned int dmanr) 159static inline void enable_dma_buffer0(unsigned int dmanr)
160{ 160{
161 struct dma_chan *chan = get_dma_chan(dmanr); 161 struct dma_chan *chan = get_dma_chan(dmanr);
162
162 if (!chan) 163 if (!chan)
163 return; 164 return;
164 au_writel(DMA_BE0, chan->io + DMA_MODE_SET); 165 au_writel(DMA_BE0, chan->io + DMA_MODE_SET);
165} 166}
166static __inline__ void enable_dma_buffer1(unsigned int dmanr) 167
168static inline void enable_dma_buffer1(unsigned int dmanr)
167{ 169{
168 struct dma_chan *chan = get_dma_chan(dmanr); 170 struct dma_chan *chan = get_dma_chan(dmanr);
171
169 if (!chan) 172 if (!chan)
170 return; 173 return;
171 au_writel(DMA_BE1, chan->io + DMA_MODE_SET); 174 au_writel(DMA_BE1, chan->io + DMA_MODE_SET);
172} 175}
173static __inline__ void enable_dma_buffers(unsigned int dmanr) 176static inline void enable_dma_buffers(unsigned int dmanr)
174{ 177{
175 struct dma_chan *chan = get_dma_chan(dmanr); 178 struct dma_chan *chan = get_dma_chan(dmanr);
179
176 if (!chan) 180 if (!chan)
177 return; 181 return;
178 au_writel(DMA_BE0 | DMA_BE1, chan->io + DMA_MODE_SET); 182 au_writel(DMA_BE0 | DMA_BE1, chan->io + DMA_MODE_SET);
179} 183}
180 184
181static __inline__ void start_dma(unsigned int dmanr) 185static inline void start_dma(unsigned int dmanr)
182{ 186{
183 struct dma_chan *chan = get_dma_chan(dmanr); 187 struct dma_chan *chan = get_dma_chan(dmanr);
188
184 if (!chan) 189 if (!chan)
185 return; 190 return;
186
187 au_writel(DMA_GO, chan->io + DMA_MODE_SET); 191 au_writel(DMA_GO, chan->io + DMA_MODE_SET);
188} 192}
189 193
190#define DMA_HALT_POLL 0x5000 194#define DMA_HALT_POLL 0x5000
191 195
192static __inline__ void halt_dma(unsigned int dmanr) 196static inline void halt_dma(unsigned int dmanr)
193{ 197{
194 struct dma_chan *chan = get_dma_chan(dmanr); 198 struct dma_chan *chan = get_dma_chan(dmanr);
195 int i; 199 int i;
200
196 if (!chan) 201 if (!chan)
197 return; 202 return;
198
199 au_writel(DMA_GO, chan->io + DMA_MODE_CLEAR); 203 au_writel(DMA_GO, chan->io + DMA_MODE_CLEAR);
200 // poll the halt bit 204
205 /* Poll the halt bit */
201 for (i = 0; i < DMA_HALT_POLL; i++) 206 for (i = 0; i < DMA_HALT_POLL; i++)
202 if (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) 207 if (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT)
203 break; 208 break;
@@ -205,55 +210,57 @@ static __inline__ void halt_dma(unsigned int dmanr)
205 printk(KERN_INFO "halt_dma: HALT poll expired!\n"); 210 printk(KERN_INFO "halt_dma: HALT poll expired!\n");
206} 211}
207 212
208 213static inline void disable_dma(unsigned int dmanr)
209static __inline__ void disable_dma(unsigned int dmanr)
210{ 214{
211 struct dma_chan *chan = get_dma_chan(dmanr); 215 struct dma_chan *chan = get_dma_chan(dmanr);
216
212 if (!chan) 217 if (!chan)
213 return; 218 return;
214 219
215 halt_dma(dmanr); 220 halt_dma(dmanr);
216 221
217 // now we can disable the buffers 222 /* Now we can disable the buffers */
218 au_writel(~DMA_GO, chan->io + DMA_MODE_CLEAR); 223 au_writel(~DMA_GO, chan->io + DMA_MODE_CLEAR);
219} 224}
220 225
221static __inline__ int dma_halted(unsigned int dmanr) 226static inline int dma_halted(unsigned int dmanr)
222{ 227{
223 struct dma_chan *chan = get_dma_chan(dmanr); 228 struct dma_chan *chan = get_dma_chan(dmanr);
229
224 if (!chan) 230 if (!chan)
225 return 1; 231 return 1;
226 return (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) ? 1 : 0; 232 return (au_readl(chan->io + DMA_MODE_READ) & DMA_HALT) ? 1 : 0;
227} 233}
228 234
229/* initialize a DMA channel */ 235/* Initialize a DMA channel. */
230static __inline__ void init_dma(unsigned int dmanr) 236static inline void init_dma(unsigned int dmanr)
231{ 237{
232 struct dma_chan *chan = get_dma_chan(dmanr); 238 struct dma_chan *chan = get_dma_chan(dmanr);
233 u32 mode; 239 u32 mode;
240
234 if (!chan) 241 if (!chan)
235 return; 242 return;
236 243
237 disable_dma(dmanr); 244 disable_dma(dmanr);
238 245
239 // set device FIFO address 246 /* Set device FIFO address */
240 au_writel(CPHYSADDR(chan->fifo_addr), 247 au_writel(CPHYSADDR(chan->fifo_addr), chan->io + DMA_PERIPHERAL_ADDR);
241 chan->io + DMA_PERIPHERAL_ADDR);
242 248
243 mode = chan->mode | (chan->dev_id << DMA_DID_BIT); 249 mode = chan->mode | (chan->dev_id << DMA_DID_BIT);
244 if (chan->irq) 250 if (chan->irq)
245 mode |= DMA_IE; 251 mode |= DMA_IE;
246 252
247 au_writel(~mode, chan->io + DMA_MODE_CLEAR); 253 au_writel(~mode, chan->io + DMA_MODE_CLEAR);
248 au_writel(mode, chan->io + DMA_MODE_SET); 254 au_writel(mode, chan->io + DMA_MODE_SET);
249} 255}
250 256
251/* 257/*
252 * set mode for a specific DMA channel 258 * Set mode for a specific DMA channel
253 */ 259 */
254static __inline__ void set_dma_mode(unsigned int dmanr, unsigned int mode) 260static inline void set_dma_mode(unsigned int dmanr, unsigned int mode)
255{ 261{
256 struct dma_chan *chan = get_dma_chan(dmanr); 262 struct dma_chan *chan = get_dma_chan(dmanr);
263
257 if (!chan) 264 if (!chan)
258 return; 265 return;
259 /* 266 /*
@@ -266,36 +273,37 @@ static __inline__ void set_dma_mode(unsigned int dmanr, unsigned int mode)
266 chan->mode |= mode; 273 chan->mode |= mode;
267} 274}
268 275
269static __inline__ unsigned int get_dma_mode(unsigned int dmanr) 276static inline unsigned int get_dma_mode(unsigned int dmanr)
270{ 277{
271 struct dma_chan *chan = get_dma_chan(dmanr); 278 struct dma_chan *chan = get_dma_chan(dmanr);
279
272 if (!chan) 280 if (!chan)
273 return 0; 281 return 0;
274 return chan->mode; 282 return chan->mode;
275} 283}
276 284
277static __inline__ int get_dma_active_buffer(unsigned int dmanr) 285static inline int get_dma_active_buffer(unsigned int dmanr)
278{ 286{
279 struct dma_chan *chan = get_dma_chan(dmanr); 287 struct dma_chan *chan = get_dma_chan(dmanr);
288
280 if (!chan) 289 if (!chan)
281 return -1; 290 return -1;
282 return (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 1 : 0; 291 return (au_readl(chan->io + DMA_MODE_READ) & DMA_AB) ? 1 : 0;
283} 292}
284 293
285
286/* 294/*
287 * set the device FIFO address for a specific DMA channel - only 295 * Set the device FIFO address for a specific DMA channel - only
288 * applicable to GPO4 and GPO5. All the other devices have fixed 296 * applicable to GPO4 and GPO5. All the other devices have fixed
289 * FIFO addresses. 297 * FIFO addresses.
290 */ 298 */
291static __inline__ void set_dma_fifo_addr(unsigned int dmanr, 299static inline void set_dma_fifo_addr(unsigned int dmanr, unsigned int a)
292 unsigned int a)
293{ 300{
294 struct dma_chan *chan = get_dma_chan(dmanr); 301 struct dma_chan *chan = get_dma_chan(dmanr);
302
295 if (!chan) 303 if (!chan)
296 return; 304 return;
297 305
298 if (chan->mode & DMA_DS) /* second bank of device ids */ 306 if (chan->mode & DMA_DS) /* second bank of device IDs */
299 return; 307 return;
300 308
301 if (chan->dev_id != DMA_ID_GP04 && chan->dev_id != DMA_ID_GP05) 309 if (chan->dev_id != DMA_ID_GP04 && chan->dev_id != DMA_ID_GP05)
@@ -307,16 +315,19 @@ static __inline__ void set_dma_fifo_addr(unsigned int dmanr,
307/* 315/*
308 * Clear the DMA buffer done bits in the mode register. 316 * Clear the DMA buffer done bits in the mode register.
309 */ 317 */
310static __inline__ void clear_dma_done0(unsigned int dmanr) 318static inline void clear_dma_done0(unsigned int dmanr)
311{ 319{
312 struct dma_chan *chan = get_dma_chan(dmanr); 320 struct dma_chan *chan = get_dma_chan(dmanr);
321
313 if (!chan) 322 if (!chan)
314 return; 323 return;
315 au_writel(DMA_D0, chan->io + DMA_MODE_CLEAR); 324 au_writel(DMA_D0, chan->io + DMA_MODE_CLEAR);
316} 325}
317static __inline__ void clear_dma_done1(unsigned int dmanr) 326
327static inline void clear_dma_done1(unsigned int dmanr)
318{ 328{
319 struct dma_chan *chan = get_dma_chan(dmanr); 329 struct dma_chan *chan = get_dma_chan(dmanr);
330
320 if (!chan) 331 if (!chan)
321 return; 332 return;
322 au_writel(DMA_D1, chan->io + DMA_MODE_CLEAR); 333 au_writel(DMA_D1, chan->io + DMA_MODE_CLEAR);
@@ -325,16 +336,17 @@ static __inline__ void clear_dma_done1(unsigned int dmanr)
325/* 336/*
326 * This does nothing - not applicable to Au1000 DMA. 337 * This does nothing - not applicable to Au1000 DMA.
327 */ 338 */
328static __inline__ void set_dma_page(unsigned int dmanr, char pagenr) 339static inline void set_dma_page(unsigned int dmanr, char pagenr)
329{ 340{
330} 341}
331 342
332/* 343/*
333 * Set Buffer 0 transfer address for specific DMA channel. 344 * Set Buffer 0 transfer address for specific DMA channel.
334 */ 345 */
335static __inline__ void set_dma_addr0(unsigned int dmanr, unsigned int a) 346static inline void set_dma_addr0(unsigned int dmanr, unsigned int a)
336{ 347{
337 struct dma_chan *chan = get_dma_chan(dmanr); 348 struct dma_chan *chan = get_dma_chan(dmanr);
349
338 if (!chan) 350 if (!chan)
339 return; 351 return;
340 au_writel(a, chan->io + DMA_BUFFER0_START); 352 au_writel(a, chan->io + DMA_BUFFER0_START);
@@ -343,9 +355,10 @@ static __inline__ void set_dma_addr0(unsigned int dmanr, unsigned int a)
343/* 355/*
344 * Set Buffer 1 transfer address for specific DMA channel. 356 * Set Buffer 1 transfer address for specific DMA channel.
345 */ 357 */
346static __inline__ void set_dma_addr1(unsigned int dmanr, unsigned int a) 358static inline void set_dma_addr1(unsigned int dmanr, unsigned int a)
347{ 359{
348 struct dma_chan *chan = get_dma_chan(dmanr); 360 struct dma_chan *chan = get_dma_chan(dmanr);
361
349 if (!chan) 362 if (!chan)
350 return; 363 return;
351 au_writel(a, chan->io + DMA_BUFFER1_START); 364 au_writel(a, chan->io + DMA_BUFFER1_START);
@@ -355,10 +368,10 @@ static __inline__ void set_dma_addr1(unsigned int dmanr, unsigned int a)
355/* 368/*
356 * Set Buffer 0 transfer size (max 64k) for a specific DMA channel. 369 * Set Buffer 0 transfer size (max 64k) for a specific DMA channel.
357 */ 370 */
358static __inline__ void set_dma_count0(unsigned int dmanr, 371static inline void set_dma_count0(unsigned int dmanr, unsigned int count)
359 unsigned int count)
360{ 372{
361 struct dma_chan *chan = get_dma_chan(dmanr); 373 struct dma_chan *chan = get_dma_chan(dmanr);
374
362 if (!chan) 375 if (!chan)
363 return; 376 return;
364 count &= DMA_COUNT_MASK; 377 count &= DMA_COUNT_MASK;
@@ -368,10 +381,10 @@ static __inline__ void set_dma_count0(unsigned int dmanr,
368/* 381/*
369 * Set Buffer 1 transfer size (max 64k) for a specific DMA channel. 382 * Set Buffer 1 transfer size (max 64k) for a specific DMA channel.
370 */ 383 */
371static __inline__ void set_dma_count1(unsigned int dmanr, 384static inline void set_dma_count1(unsigned int dmanr, unsigned int count)
372 unsigned int count)
373{ 385{
374 struct dma_chan *chan = get_dma_chan(dmanr); 386 struct dma_chan *chan = get_dma_chan(dmanr);
387
375 if (!chan) 388 if (!chan)
376 return; 389 return;
377 count &= DMA_COUNT_MASK; 390 count &= DMA_COUNT_MASK;
@@ -381,10 +394,10 @@ static __inline__ void set_dma_count1(unsigned int dmanr,
381/* 394/*
382 * Set both buffer transfer sizes (max 64k) for a specific DMA channel. 395 * Set both buffer transfer sizes (max 64k) for a specific DMA channel.
383 */ 396 */
384static __inline__ void set_dma_count(unsigned int dmanr, 397static inline void set_dma_count(unsigned int dmanr, unsigned int count)
385 unsigned int count)
386{ 398{
387 struct dma_chan *chan = get_dma_chan(dmanr); 399 struct dma_chan *chan = get_dma_chan(dmanr);
400
388 if (!chan) 401 if (!chan)
389 return; 402 return;
390 count &= DMA_COUNT_MASK; 403 count &= DMA_COUNT_MASK;
@@ -396,35 +409,36 @@ static __inline__ void set_dma_count(unsigned int dmanr,
396 * Returns which buffer has its done bit set in the mode register. 409 * Returns which buffer has its done bit set in the mode register.
397 * Returns -1 if neither or both done bits set. 410 * Returns -1 if neither or both done bits set.
398 */ 411 */
399static __inline__ unsigned int get_dma_buffer_done(unsigned int dmanr) 412static inline unsigned int get_dma_buffer_done(unsigned int dmanr)
400{ 413{
401 struct dma_chan *chan = get_dma_chan(dmanr); 414 struct dma_chan *chan = get_dma_chan(dmanr);
415
402 if (!chan) 416 if (!chan)
403 return 0; 417 return 0;
404 418 return au_readl(chan->io + DMA_MODE_READ) & (DMA_D0 | DMA_D1);
405 return au_readl(chan->io + DMA_MODE_READ) & (DMA_D0 | DMA_D1);
406} 419}
407 420
408 421
409/* 422/*
410 * Returns the DMA channel's Buffer Done IRQ number. 423 * Returns the DMA channel's Buffer Done IRQ number.
411 */ 424 */
412static __inline__ int get_dma_done_irq(unsigned int dmanr) 425static inline int get_dma_done_irq(unsigned int dmanr)
413{ 426{
414 struct dma_chan *chan = get_dma_chan(dmanr); 427 struct dma_chan *chan = get_dma_chan(dmanr);
428
415 if (!chan) 429 if (!chan)
416 return -1; 430 return -1;
417
418 return chan->irq; 431 return chan->irq;
419} 432}
420 433
421/* 434/*
422 * Get DMA residue count. Returns the number of _bytes_ left to transfer. 435 * Get DMA residue count. Returns the number of _bytes_ left to transfer.
423 */ 436 */
424static __inline__ int get_dma_residue(unsigned int dmanr) 437static inline int get_dma_residue(unsigned int dmanr)
425{ 438{
426 int curBufCntReg, count; 439 int curBufCntReg, count;
427 struct dma_chan *chan = get_dma_chan(dmanr); 440 struct dma_chan *chan = get_dma_chan(dmanr);
441
428 if (!chan) 442 if (!chan)
429 return 0; 443 return 0;
430 444
@@ -442,4 +456,3 @@ static __inline__ int get_dma_residue(unsigned int dmanr)
442} 456}
443 457
444#endif /* __ASM_AU1000_DMA_H */ 458#endif /* __ASM_AU1000_DMA_H */
445
diff --git a/include/asm-mips/mach-au1x00/au1000_gpio.h b/include/asm-mips/mach-au1x00/au1000_gpio.h
index 298f92012e8e..d8c96fda5549 100644
--- a/include/asm-mips/mach-au1x00/au1000_gpio.h
+++ b/include/asm-mips/mach-au1x00/au1000_gpio.h
@@ -2,12 +2,12 @@
2 * FILE NAME au1000_gpio.h 2 * FILE NAME au1000_gpio.h
3 * 3 *
4 * BRIEF MODULE DESCRIPTION 4 * BRIEF MODULE DESCRIPTION
5 * API to Alchemy Au1000 GPIO device. 5 * API to Alchemy Au1xx0 GPIO device.
6 * 6 *
7 * Author: MontaVista Software, Inc. <source@mvista.com> 7 * Author: MontaVista Software, Inc. <source@mvista.com>
8 * Steve Longerbeam <stevel@mvista.com> 8 * Steve Longerbeam
9 * 9 *
10 * Copyright 2001 MontaVista Software Inc. 10 * Copyright 2001, 2008 MontaVista Software Inc.
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify it 12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the 13 * under the terms of the GNU General Public License as published by the
@@ -37,12 +37,12 @@
37 37
38#define AU1000GPIO_IOC_MAGIC 'A' 38#define AU1000GPIO_IOC_MAGIC 'A'
39 39
40#define AU1000GPIO_IN _IOR (AU1000GPIO_IOC_MAGIC, 0, int) 40#define AU1000GPIO_IN _IOR(AU1000GPIO_IOC_MAGIC, 0, int)
41#define AU1000GPIO_SET _IOW (AU1000GPIO_IOC_MAGIC, 1, int) 41#define AU1000GPIO_SET _IOW(AU1000GPIO_IOC_MAGIC, 1, int)
42#define AU1000GPIO_CLEAR _IOW (AU1000GPIO_IOC_MAGIC, 2, int) 42#define AU1000GPIO_CLEAR _IOW(AU1000GPIO_IOC_MAGIC, 2, int)
43#define AU1000GPIO_OUT _IOW (AU1000GPIO_IOC_MAGIC, 3, int) 43#define AU1000GPIO_OUT _IOW(AU1000GPIO_IOC_MAGIC, 3, int)
44#define AU1000GPIO_TRISTATE _IOW (AU1000GPIO_IOC_MAGIC, 4, int) 44#define AU1000GPIO_TRISTATE _IOW(AU1000GPIO_IOC_MAGIC, 4, int)
45#define AU1000GPIO_AVAIL_MASK _IOR (AU1000GPIO_IOC_MAGIC, 5, int) 45#define AU1000GPIO_AVAIL_MASK _IOR(AU1000GPIO_IOC_MAGIC, 5, int)
46 46
47#ifdef __KERNEL__ 47#ifdef __KERNEL__
48extern u32 get_au1000_avail_gpio_mask(void); 48extern u32 get_au1000_avail_gpio_mask(void);
diff --git a/include/asm-mips/mach-au1x00/au1550_spi.h b/include/asm-mips/mach-au1x00/au1550_spi.h
index c2f0466523ec..40e6c489833a 100644
--- a/include/asm-mips/mach-au1x00/au1550_spi.h
+++ b/include/asm-mips/mach-au1x00/au1550_spi.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * au1550_spi.h - au1550 psc spi controller driver - platform data struct 2 * au1550_spi.h - Au1550 PSC SPI controller driver - platform data structure
3 */ 3 */
4 4
5#ifndef _AU1550_SPI_H_ 5#ifndef _AU1550_SPI_H_
diff --git a/include/asm-mips/mach-au1x00/au1xxx.h b/include/asm-mips/mach-au1x00/au1xxx.h
index 947135941033..1b3655090ed3 100644
--- a/include/asm-mips/mach-au1x00/au1xxx.h
+++ b/include/asm-mips/mach-au1x00/au1xxx.h
@@ -23,10 +23,10 @@
23#ifndef _AU1XXX_H_ 23#ifndef _AU1XXX_H_
24#define _AU1XXX_H_ 24#define _AU1XXX_H_
25 25
26
27#include <asm/mach-au1x00/au1000.h> 26#include <asm/mach-au1x00/au1000.h>
28 27
29#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550) 28#if defined(CONFIG_MIPS_DB1000) || defined(CONFIG_MIPS_DB1100) || \
29 defined(CONFIG_MIPS_DB1500) || defined(CONFIG_MIPS_DB1550)
30#include <asm/mach-db1x00/db1x00.h> 30#include <asm/mach-db1x00/db1x00.h>
31 31
32#elif defined(CONFIG_MIPS_PB1550) 32#elif defined(CONFIG_MIPS_PB1550)
diff --git a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
index 93d507cea518..ad17d7ce516a 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_dbdma.h
@@ -28,17 +28,18 @@
28 * 675 Mass Ave, Cambridge, MA 02139, USA. 28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */ 29 */
30 30
31/* Specifics for the Au1xxx Descriptor-Based DMA Controllers, first 31/*
32 * seen in the AU1550 part. 32 * Specifics for the Au1xxx Descriptor-Based DMA Controller,
33 * first seen in the AU1550 part.
33 */ 34 */
34#ifndef _AU1000_DBDMA_H_ 35#ifndef _AU1000_DBDMA_H_
35#define _AU1000_DBDMA_H_ 36#define _AU1000_DBDMA_H_
36 37
37
38#ifndef _LANGUAGE_ASSEMBLY 38#ifndef _LANGUAGE_ASSEMBLY
39 39
40/* The DMA base addresses. 40/*
41 * The Channels are every 256 bytes (0x0100) from the channel 0 base. 41 * The DMA base addresses.
42 * The channels are every 256 bytes (0x0100) from the channel 0 base.
42 * Interrupt status/enable is bits 15:0 for channels 15 to zero. 43 * Interrupt status/enable is bits 15:0 for channels 15 to zero.
43 */ 44 */
44#define DDMA_GLOBAL_BASE 0xb4003000 45#define DDMA_GLOBAL_BASE 0xb4003000
@@ -51,16 +52,14 @@ typedef volatile struct dbdma_global {
51 u32 ddma_inten; 52 u32 ddma_inten;
52} dbdma_global_t; 53} dbdma_global_t;
53 54
54/* General Configuration. 55/* General Configuration. */
55*/
56#define DDMA_CONFIG_AF (1 << 2) 56#define DDMA_CONFIG_AF (1 << 2)
57#define DDMA_CONFIG_AH (1 << 1) 57#define DDMA_CONFIG_AH (1 << 1)
58#define DDMA_CONFIG_AL (1 << 0) 58#define DDMA_CONFIG_AL (1 << 0)
59 59
60#define DDMA_THROTTLE_EN (1 << 31) 60#define DDMA_THROTTLE_EN (1 << 31)
61 61
62/* The structure of a DMA Channel. 62/* The structure of a DMA Channel. */
63*/
64typedef volatile struct au1xxx_dma_channel { 63typedef volatile struct au1xxx_dma_channel {
65 u32 ddma_cfg; /* See below */ 64 u32 ddma_cfg; /* See below */
66 u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */ 65 u32 ddma_desptr; /* 32-byte aligned pointer to descriptor */
@@ -69,8 +68,7 @@ typedef volatile struct au1xxx_dma_channel {
69 u32 ddma_irq; /* If bit 0 set, interrupt pending */ 68 u32 ddma_irq; /* If bit 0 set, interrupt pending */
70 u32 ddma_stat; /* See below */ 69 u32 ddma_stat; /* See below */
71 u32 ddma_bytecnt; /* Byte count, valid only when chan idle */ 70 u32 ddma_bytecnt; /* Byte count, valid only when chan idle */
72 /* Remainder, up to the 256 byte boundary, is reserved. 71 /* Remainder, up to the 256 byte boundary, is reserved. */
73 */
74} au1x_dma_chan_t; 72} au1x_dma_chan_t;
75 73
76#define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */ 74#define DDMA_CFG_SED (1 << 9) /* source DMA level/edge detect */
@@ -84,7 +82,8 @@ typedef volatile struct au1xxx_dma_channel {
84#define DDMA_CFG_DBE (1 << 1) /* Destination big endian */ 82#define DDMA_CFG_DBE (1 << 1) /* Destination big endian */
85#define DDMA_CFG_EN (1 << 0) /* Channel enable */ 83#define DDMA_CFG_EN (1 << 0) /* Channel enable */
86 84
87/* Always set when descriptor processing done, regardless of 85/*
86 * Always set when descriptor processing done, regardless of
88 * interrupt enable state. Reflected in global intstat, don't 87 * interrupt enable state. Reflected in global intstat, don't
89 * clear this until global intstat is read/used. 88 * clear this until global intstat is read/used.
90 */ 89 */
@@ -94,7 +93,8 @@ typedef volatile struct au1xxx_dma_channel {
94#define DDMA_STAT_V (1 << 1) /* Descriptor valid */ 93#define DDMA_STAT_V (1 << 1) /* Descriptor valid */
95#define DDMA_STAT_H (1 << 0) /* Channel Halted */ 94#define DDMA_STAT_H (1 << 0) /* Channel Halted */
96 95
97/* "Standard" DDMA Descriptor. 96/*
97 * "Standard" DDMA Descriptor.
98 * Must be 32-byte aligned. 98 * Must be 32-byte aligned.
99 */ 99 */
100typedef volatile struct au1xxx_ddma_desc { 100typedef volatile struct au1xxx_ddma_desc {
@@ -106,8 +106,9 @@ typedef volatile struct au1xxx_ddma_desc {
106 u32 dscr_dest1; /* See below */ 106 u32 dscr_dest1; /* See below */
107 u32 dscr_stat; /* completion status */ 107 u32 dscr_stat; /* completion status */
108 u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */ 108 u32 dscr_nxtptr; /* Next descriptor pointer (mostly) */
109 /* First 32bytes are HW specific!!! 109 /*
110 Lets have some SW data following.. make sure its 32bytes 110 * First 32 bytes are HW specific!!!
111 * Lets have some SW data following -- make sure it's 32 bytes.
111 */ 112 */
112 u32 sw_status; 113 u32 sw_status;
113 u32 sw_context; 114 u32 sw_context;
@@ -130,10 +131,9 @@ typedef volatile struct au1xxx_ddma_desc {
130#define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */ 131#define DSCR_CMD0_CV (0x1 << 2) /* Clear Valid when done */
131#define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */ 132#define DSCR_CMD0_ST_MASK (0x3 << 0) /* Status instruction */
132 133
133#define SW_STATUS_INUSE (1<<0) 134#define SW_STATUS_INUSE (1 << 0)
134 135
135/* Command 0 device IDs. 136/* Command 0 device IDs. */
136*/
137#ifdef CONFIG_SOC_AU1550 137#ifdef CONFIG_SOC_AU1550
138#define DSCR_CMD0_UART0_TX 0 138#define DSCR_CMD0_UART0_TX 0
139#define DSCR_CMD0_UART0_RX 1 139#define DSCR_CMD0_UART0_RX 1
@@ -198,16 +198,15 @@ typedef volatile struct au1xxx_ddma_desc {
198#define DSCR_CMD0_THROTTLE 30 198#define DSCR_CMD0_THROTTLE 30
199#define DSCR_CMD0_ALWAYS 31 199#define DSCR_CMD0_ALWAYS 31
200#define DSCR_NDEV_IDS 32 200#define DSCR_NDEV_IDS 32
201/* THis macro is used to find/create custom device types */ 201/* This macro is used to find/create custom device types */
202#define DSCR_DEV2CUSTOM_ID(x, d) (((((x)&0xFFFF)<<8)|0x32000000)|((d)&0xFF)) 202#define DSCR_DEV2CUSTOM_ID(x, d) (((((x) & 0xFFFF) << 8) | 0x32000000) | \
203#define DSCR_CUSTOM2DEV_ID(x) ((x)&0xFF) 203 ((d) & 0xFF))
204 204#define DSCR_CUSTOM2DEV_ID(x) ((x) & 0xFF)
205 205
206#define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25) 206#define DSCR_CMD0_SID(x) (((x) & 0x1f) << 25)
207#define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20) 207#define DSCR_CMD0_DID(x) (((x) & 0x1f) << 20)
208 208
209/* Source/Destination transfer width. 209/* Source/Destination transfer width. */
210*/
211#define DSCR_CMD0_BYTE 0 210#define DSCR_CMD0_BYTE 0
212#define DSCR_CMD0_HALFWORD 1 211#define DSCR_CMD0_HALFWORD 1
213#define DSCR_CMD0_WORD 2 212#define DSCR_CMD0_WORD 2
@@ -215,16 +214,14 @@ typedef volatile struct au1xxx_ddma_desc {
215#define DSCR_CMD0_SW(x) (((x) & 0x3) << 18) 214#define DSCR_CMD0_SW(x) (((x) & 0x3) << 18)
216#define DSCR_CMD0_DW(x) (((x) & 0x3) << 16) 215#define DSCR_CMD0_DW(x) (((x) & 0x3) << 16)
217 216
218/* DDMA Descriptor Type. 217/* DDMA Descriptor Type. */
219*/
220#define DSCR_CMD0_STANDARD 0 218#define DSCR_CMD0_STANDARD 0
221#define DSCR_CMD0_LITERAL 1 219#define DSCR_CMD0_LITERAL 1
222#define DSCR_CMD0_CMP_BRANCH 2 220#define DSCR_CMD0_CMP_BRANCH 2
223 221
224#define DSCR_CMD0_DT(x) (((x) & 0x3) << 13) 222#define DSCR_CMD0_DT(x) (((x) & 0x3) << 13)
225 223
226/* Status Instruction. 224/* Status Instruction. */
227*/
228#define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */ 225#define DSCR_CMD0_ST_NOCHANGE 0 /* Don't change */
229#define DSCR_CMD0_ST_CURRENT 1 /* Write current status */ 226#define DSCR_CMD0_ST_CURRENT 1 /* Write current status */
230#define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */ 227#define DSCR_CMD0_ST_CMD0 2 /* Write cmd0 with V cleared */
@@ -232,23 +229,20 @@ typedef volatile struct au1xxx_ddma_desc {
232 229
233#define DSCR_CMD0_ST(x) (((x) & 0x3) << 0) 230#define DSCR_CMD0_ST(x) (((x) & 0x3) << 0)
234 231
235/* Descriptor Command 1 232/* Descriptor Command 1. */
236*/
237#define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */ 233#define DSCR_CMD1_SUPTR_MASK (0xf << 28) /* upper 4 bits of src addr */
238#define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */ 234#define DSCR_CMD1_DUPTR_MASK (0xf << 24) /* upper 4 bits of dest addr */
239#define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */ 235#define DSCR_CMD1_FL_MASK (0x3 << 22) /* Flag bits */
240#define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */ 236#define DSCR_CMD1_BC_MASK (0x3fffff) /* Byte count */
241 237
242/* Flag description. 238/* Flag description. */
243*/
244#define DSCR_CMD1_FL_MEM_STRIDE0 0 239#define DSCR_CMD1_FL_MEM_STRIDE0 0
245#define DSCR_CMD1_FL_MEM_STRIDE1 1 240#define DSCR_CMD1_FL_MEM_STRIDE1 1
246#define DSCR_CMD1_FL_MEM_STRIDE2 2 241#define DSCR_CMD1_FL_MEM_STRIDE2 2
247 242
248#define DSCR_CMD1_FL(x) (((x) & 0x3) << 22) 243#define DSCR_CMD1_FL(x) (((x) & 0x3) << 22)
249 244
250/* Source1, 1-dimensional stride. 245/* Source1, 1-dimensional stride. */
251*/
252#define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */ 246#define DSCR_SRC1_STS_MASK (3 << 30) /* Src xfer size */
253#define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */ 247#define DSCR_SRC1_SAM_MASK (3 << 28) /* Src xfer movement */
254#define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */ 248#define DSCR_SRC1_SB_MASK (0x3fff << 14) /* Block size */
@@ -256,8 +250,7 @@ typedef volatile struct au1xxx_ddma_desc {
256#define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */ 250#define DSCR_SRC1_SS_MASK (0x3fff << 0) /* Stride */
257#define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0) 251#define DSCR_SRC1_SS(x) (((x) & 0x3fff) << 0)
258 252
259/* Dest1, 1-dimensional stride. 253/* Dest1, 1-dimensional stride. */
260*/
261#define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */ 254#define DSCR_DEST1_DTS_MASK (3 << 30) /* Dest xfer size */
262#define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */ 255#define DSCR_DEST1_DAM_MASK (3 << 28) /* Dest xfer movement */
263#define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */ 256#define DSCR_DEST1_DB_MASK (0x3fff << 14) /* Block size */
@@ -279,29 +272,27 @@ typedef volatile struct au1xxx_ddma_desc {
279#define DSCR_SRC1_SAM(x) (((x) & 3) << 28) 272#define DSCR_SRC1_SAM(x) (((x) & 3) << 28)
280#define DSCR_DEST1_DAM(x) (((x) & 3) << 28) 273#define DSCR_DEST1_DAM(x) (((x) & 3) << 28)
281 274
282/* The next descriptor pointer. 275/* The next descriptor pointer. */
283*/
284#define DSCR_NXTPTR_MASK (0x07ffffff) 276#define DSCR_NXTPTR_MASK (0x07ffffff)
285#define DSCR_NXTPTR(x) ((x) >> 5) 277#define DSCR_NXTPTR(x) ((x) >> 5)
286#define DSCR_GET_NXTPTR(x) ((x) << 5) 278#define DSCR_GET_NXTPTR(x) ((x) << 5)
287#define DSCR_NXTPTR_MS (1 << 27) 279#define DSCR_NXTPTR_MS (1 << 27)
288 280
289/* The number of DBDMA channels. 281/* The number of DBDMA channels. */
290*/
291#define NUM_DBDMA_CHANS 16 282#define NUM_DBDMA_CHANS 16
292 283
293/* 284/*
294 * Ddma API definitions 285 * DDMA API definitions
295 * FIXME: may not fit to this header file 286 * FIXME: may not fit to this header file
296 */ 287 */
297typedef struct dbdma_device_table { 288typedef struct dbdma_device_table {
298 u32 dev_id; 289 u32 dev_id;
299 u32 dev_flags; 290 u32 dev_flags;
300 u32 dev_tsize; 291 u32 dev_tsize;
301 u32 dev_devwidth; 292 u32 dev_devwidth;
302 u32 dev_physaddr; /* If FIFO */ 293 u32 dev_physaddr; /* If FIFO */
303 u32 dev_intlevel; 294 u32 dev_intlevel;
304 u32 dev_intpolarity; 295 u32 dev_intpolarity;
305} dbdev_tab_t; 296} dbdev_tab_t;
306 297
307 298
@@ -316,44 +307,41 @@ typedef struct dbdma_chan_config {
316 au1x_ddma_desc_t *chan_desc_base; 307 au1x_ddma_desc_t *chan_desc_base;
317 au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr; 308 au1x_ddma_desc_t *get_ptr, *put_ptr, *cur_ptr;
318 void *chan_callparam; 309 void *chan_callparam;
319 void (*chan_callback)(int, void *); 310 void (*chan_callback)(int, void *);
320} chan_tab_t; 311} chan_tab_t;
321 312
322#define DEV_FLAGS_INUSE (1 << 0) 313#define DEV_FLAGS_INUSE (1 << 0)
323#define DEV_FLAGS_ANYUSE (1 << 1) 314#define DEV_FLAGS_ANYUSE (1 << 1)
324#define DEV_FLAGS_OUT (1 << 2) 315#define DEV_FLAGS_OUT (1 << 2)
325#define DEV_FLAGS_IN (1 << 3) 316#define DEV_FLAGS_IN (1 << 3)
326#define DEV_FLAGS_BURSTABLE (1 << 4) 317#define DEV_FLAGS_BURSTABLE (1 << 4)
327#define DEV_FLAGS_SYNC (1 << 5) 318#define DEV_FLAGS_SYNC (1 << 5)
328/* end Ddma API definitions */ 319/* end DDMA API definitions */
329 320
330/* External functions for drivers to use. 321/*
331*/ 322 * External functions for drivers to use.
332/* Use this to allocate a dbdma channel. The device ids are one of the 323 * Use this to allocate a DBDMA channel. The device IDs are one of
333 * DSCR_CMD0 devices IDs, which is usually redefined to a more 324 * the DSCR_CMD0 devices IDs, which is usually redefined to a more
334 * meaningful name. The 'callback' is called during dma completion 325 * meaningful name. The 'callback' is called during DMA completion
335 * interrupt. 326 * interrupt.
336 */ 327 */
337extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid, 328extern u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
338 void (*callback)(int, void *), void *callparam); 329 void (*callback)(int, void *),
330 void *callparam);
339 331
340#define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS 332#define DBDMA_MEM_CHAN DSCR_CMD0_ALWAYS
341 333
342/* Set the device width of a in/out fifo. 334/* Set the device width of an in/out FIFO. */
343*/
344u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits); 335u32 au1xxx_dbdma_set_devwidth(u32 chanid, int bits);
345 336
346/* Allocate a ring of descriptors for dbdma. 337/* Allocate a ring of descriptors for DBDMA. */
347*/
348u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries); 338u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries);
349 339
350/* Put buffers on source/destination descriptors. 340/* Put buffers on source/destination descriptors. */
351*/
352u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags); 341u32 _au1xxx_dbdma_put_source(u32 chanid, void *buf, int nbytes, u32 flags);
353u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags); 342u32 _au1xxx_dbdma_put_dest(u32 chanid, void *buf, int nbytes, u32 flags);
354 343
355/* Get a buffer from the destination descriptor. 344/* Get a buffer from the destination descriptor. */
356*/
357u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes); 345u32 au1xxx_dbdma_get_dest(u32 chanid, void **buf, int *nbytes);
358 346
359void au1xxx_dbdma_stop(u32 chanid); 347void au1xxx_dbdma_stop(u32 chanid);
@@ -364,29 +352,34 @@ u32 au1xxx_get_dma_residue(u32 chanid);
364void au1xxx_dbdma_chan_free(u32 chanid); 352void au1xxx_dbdma_chan_free(u32 chanid);
365void au1xxx_dbdma_dump(u32 chanid); 353void au1xxx_dbdma_dump(u32 chanid);
366 354
367u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr ); 355u32 au1xxx_dbdma_put_dscr(u32 chanid, au1x_ddma_desc_t *dscr);
368 356
369u32 au1xxx_ddma_add_device( dbdev_tab_t *dev ); 357u32 au1xxx_ddma_add_device(dbdev_tab_t *dev);
370void * au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp); 358void *au1xxx_ddma_get_nextptr_virt(au1x_ddma_desc_t *dp);
371 359
372/* 360/*
373 Some compatibilty macros -- 361 * Some compatibilty macros -- needed to make changes to API
374 Needed to make changes to API without breaking existing drivers 362 * without breaking existing drivers.
375*/ 363 */
376#define au1xxx_dbdma_put_source(chanid, buf, nbytes)_au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE) 364#define au1xxx_dbdma_put_source(chanid, buf, nbytes) \
377#define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags) 365 _au1xxx_dbdma_put_source(chanid, buf, nbytes, DDMA_FLAGS_IE)
378#define put_source_flags(chanid, buf, nbytes, flags) au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) 366#define au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags) \
379 367 _au1xxx_dbdma_put_source(chanid, buf, nbytes, flags)
380 368#define put_source_flags(chanid, buf, nbytes, flags) \
381#define au1xxx_dbdma_put_dest(chanid, buf, nbytes) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE) 369 au1xxx_dbdma_put_source_flags(chanid, buf, nbytes, flags)
382#define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags) 370
383#define put_dest_flags(chanid, buf, nbytes, flags) au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) 371#define au1xxx_dbdma_put_dest(chanid, buf, nbytes) \
372 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, DDMA_FLAGS_IE)
373#define au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags) \
374 _au1xxx_dbdma_put_dest(chanid, buf, nbytes, flags)
375#define put_dest_flags(chanid, buf, nbytes, flags) \
376 au1xxx_dbdma_put_dest_flags(chanid, buf, nbytes, flags)
384 377
385/* 378/*
386 * Flags for the put_source/put_dest functions. 379 * Flags for the put_source/put_dest functions.
387 */ 380 */
388#define DDMA_FLAGS_IE (1<<0) 381#define DDMA_FLAGS_IE (1 << 0)
389#define DDMA_FLAGS_NOIE (1<<1) 382#define DDMA_FLAGS_NOIE (1 << 1)
390 383
391#endif /* _LANGUAGE_ASSEMBLY */ 384#endif /* _LANGUAGE_ASSEMBLY */
392#endif /* _AU1000_DBDMA_H_ */ 385#endif /* _AU1000_DBDMA_H_ */
diff --git a/include/asm-mips/mach-au1x00/au1xxx_ide.h b/include/asm-mips/mach-au1x00/au1xxx_ide.h
index b493a5e46c63..60638b8969ba 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_ide.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h
@@ -31,167 +31,164 @@
31 */ 31 */
32 32
33#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 33#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
34 #define DMA_WAIT_TIMEOUT 100 34#define DMA_WAIT_TIMEOUT 100
35 #define NUM_DESCRIPTORS PRD_ENTRIES 35#define NUM_DESCRIPTORS PRD_ENTRIES
36#else /* CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA */ 36#else /* CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA */
37 #define NUM_DESCRIPTORS 2 37#define NUM_DESCRIPTORS 2
38#endif 38#endif
39 39
40#ifndef AU1XXX_ATA_RQSIZE 40#ifndef AU1XXX_ATA_RQSIZE
41 #define AU1XXX_ATA_RQSIZE 128 41#define AU1XXX_ATA_RQSIZE 128
42#endif 42#endif
43 43
44/* Disable Burstable-Support for DBDMA */ 44/* Disable Burstable-Support for DBDMA */
45#ifndef CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 45#ifndef CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON
46 #define CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 0 46#define CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 0
47#endif 47#endif
48 48
49#ifdef CONFIG_PM 49#ifdef CONFIG_PM
50/* 50/*
51* This will enable the device to be powered up when write() or read() 51 * This will enable the device to be powered up when write() or read()
52* is called. If this is not defined, the driver will return -EBUSY. 52 * is called. If this is not defined, the driver will return -EBUSY.
53*/ 53 */
54#define WAKE_ON_ACCESS 1 54#define WAKE_ON_ACCESS 1
55 55
56typedef struct 56typedef struct {
57{ 57 spinlock_t lock; /* Used to block on state transitions */
58 spinlock_t lock; /* Used to block on state transitions */ 58 au1xxx_power_dev_t *dev; /* Power Managers device structure */
59 au1xxx_power_dev_t *dev; /* Power Managers device structure */ 59 unsigned stopped; /* Used to signal device is stopped */
60 unsigned stopped; /* USed to signaling device is stopped */
61} pm_state; 60} pm_state;
62#endif 61#endif
63 62
64 63typedef struct {
65typedef struct 64 u32 tx_dev_id, rx_dev_id, target_dev_id;
66{ 65 u32 tx_chan, rx_chan;
67 u32 tx_dev_id, rx_dev_id, target_dev_id; 66 void *tx_desc_head, *rx_desc_head;
68 u32 tx_chan, rx_chan; 67 ide_hwif_t *hwif;
69 void *tx_desc_head, *rx_desc_head;
70 ide_hwif_t *hwif;
71#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 68#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
72 ide_drive_t *drive; 69 ide_drive_t *drive;
73 struct dbdma_cmd *dma_table_cpu; 70 struct dbdma_cmd *dma_table_cpu;
74 dma_addr_t dma_table_dma; 71 dma_addr_t dma_table_dma;
75#endif 72#endif
76 int irq; 73 int irq;
77 u32 regbase; 74 u32 regbase;
78#ifdef CONFIG_PM 75#ifdef CONFIG_PM
79 pm_state pm; 76 pm_state pm;
80#endif 77#endif
81} _auide_hwif; 78} _auide_hwif;
82 79
83/******************************************************************************* 80/******************************************************************************/
84* PIO Mode timing calculation : * 81/* PIO Mode timing calculation : */
85* * 82/* */
86* Static Bus Spec ATA Spec * 83/* Static Bus Spec ATA Spec */
87* Tcsoe = t1 * 84/* Tcsoe = t1 */
88* Toecs = t9 * 85/* Toecs = t9 */
89* Twcs = t9 * 86/* Twcs = t9 */
90* Tcsh = t2i | t2 * 87/* Tcsh = t2i | t2 */
91* Tcsoff = t2i | t2 * 88/* Tcsoff = t2i | t2 */
92* Twp = t2 * 89/* Twp = t2 */
93* Tcsw = t1 * 90/* Tcsw = t1 */
94* Tpm = 0 * 91/* Tpm = 0 */
95* Ta = t1+t2 * 92/* Ta = t1+t2 */
96*******************************************************************************/ 93/******************************************************************************/
97 94
98#define TCSOE_MASK (0x07<<29) 95#define TCSOE_MASK (0x07 << 29)
99#define TOECS_MASK (0x07<<26) 96#define TOECS_MASK (0x07 << 26)
100#define TWCS_MASK (0x07<<28) 97#define TWCS_MASK (0x07 << 28)
101#define TCSH_MASK (0x0F<<24) 98#define TCSH_MASK (0x0F << 24)
102#define TCSOFF_MASK (0x07<<20) 99#define TCSOFF_MASK (0x07 << 20)
103#define TWP_MASK (0x3F<<14) 100#define TWP_MASK (0x3F << 14)
104#define TCSW_MASK (0x0F<<10) 101#define TCSW_MASK (0x0F << 10)
105#define TPM_MASK (0x0F<<6) 102#define TPM_MASK (0x0F << 6)
106#define TA_MASK (0x3F<<0) 103#define TA_MASK (0x3F << 0)
107#define TS_MASK (1<<8) 104#define TS_MASK (1 << 8)
108 105
109/* Timing parameters PIO mode 0 */ 106/* Timing parameters PIO mode 0 */
110#define SBC_IDE_PIO0_TCSOE (0x04<<29) 107#define SBC_IDE_PIO0_TCSOE (0x04 << 29)
111#define SBC_IDE_PIO0_TOECS (0x01<<26) 108#define SBC_IDE_PIO0_TOECS (0x01 << 26)
112#define SBC_IDE_PIO0_TWCS (0x02<<28) 109#define SBC_IDE_PIO0_TWCS (0x02 << 28)
113#define SBC_IDE_PIO0_TCSH (0x08<<24) 110#define SBC_IDE_PIO0_TCSH (0x08 << 24)
114#define SBC_IDE_PIO0_TCSOFF (0x07<<20) 111#define SBC_IDE_PIO0_TCSOFF (0x07 << 20)
115#define SBC_IDE_PIO0_TWP (0x10<<14) 112#define SBC_IDE_PIO0_TWP (0x10 << 14)
116#define SBC_IDE_PIO0_TCSW (0x04<<10) 113#define SBC_IDE_PIO0_TCSW (0x04 << 10)
117#define SBC_IDE_PIO0_TPM (0x0<<6) 114#define SBC_IDE_PIO0_TPM (0x00 << 6)
118#define SBC_IDE_PIO0_TA (0x15<<0) 115#define SBC_IDE_PIO0_TA (0x15 << 0)
119/* Timing parameters PIO mode 1 */ 116/* Timing parameters PIO mode 1 */
120#define SBC_IDE_PIO1_TCSOE (0x03<<29) 117#define SBC_IDE_PIO1_TCSOE (0x03 << 29)
121#define SBC_IDE_PIO1_TOECS (0x01<<26) 118#define SBC_IDE_PIO1_TOECS (0x01 << 26)
122#define SBC_IDE_PIO1_TWCS (0x01<<28) 119#define SBC_IDE_PIO1_TWCS (0x01 << 28)
123#define SBC_IDE_PIO1_TCSH (0x06<<24) 120#define SBC_IDE_PIO1_TCSH (0x06 << 24)
124#define SBC_IDE_PIO1_TCSOFF (0x06<<20) 121#define SBC_IDE_PIO1_TCSOFF (0x06 << 20)
125#define SBC_IDE_PIO1_TWP (0x08<<14) 122#define SBC_IDE_PIO1_TWP (0x08 << 14)
126#define SBC_IDE_PIO1_TCSW (0x03<<10) 123#define SBC_IDE_PIO1_TCSW (0x03 << 10)
127#define SBC_IDE_PIO1_TPM (0x00<<6) 124#define SBC_IDE_PIO1_TPM (0x00 << 6)
128#define SBC_IDE_PIO1_TA (0x0B<<0) 125#define SBC_IDE_PIO1_TA (0x0B << 0)
129/* Timing parameters PIO mode 2 */ 126/* Timing parameters PIO mode 2 */
130#define SBC_IDE_PIO2_TCSOE (0x05<<29) 127#define SBC_IDE_PIO2_TCSOE (0x05 << 29)
131#define SBC_IDE_PIO2_TOECS (0x01<<26) 128#define SBC_IDE_PIO2_TOECS (0x01 << 26)
132#define SBC_IDE_PIO2_TWCS (0x01<<28) 129#define SBC_IDE_PIO2_TWCS (0x01 << 28)
133#define SBC_IDE_PIO2_TCSH (0x07<<24) 130#define SBC_IDE_PIO2_TCSH (0x07 << 24)
134#define SBC_IDE_PIO2_TCSOFF (0x07<<20) 131#define SBC_IDE_PIO2_TCSOFF (0x07 << 20)
135#define SBC_IDE_PIO2_TWP (0x1F<<14) 132#define SBC_IDE_PIO2_TWP (0x1F << 14)
136#define SBC_IDE_PIO2_TCSW (0x05<<10) 133#define SBC_IDE_PIO2_TCSW (0x05 << 10)
137#define SBC_IDE_PIO2_TPM (0x00<<6) 134#define SBC_IDE_PIO2_TPM (0x00 << 6)
138#define SBC_IDE_PIO2_TA (0x22<<0) 135#define SBC_IDE_PIO2_TA (0x22 << 0)
139/* Timing parameters PIO mode 3 */ 136/* Timing parameters PIO mode 3 */
140#define SBC_IDE_PIO3_TCSOE (0x05<<29) 137#define SBC_IDE_PIO3_TCSOE (0x05 << 29)
141#define SBC_IDE_PIO3_TOECS (0x01<<26) 138#define SBC_IDE_PIO3_TOECS (0x01 << 26)
142#define SBC_IDE_PIO3_TWCS (0x01<<28) 139#define SBC_IDE_PIO3_TWCS (0x01 << 28)
143#define SBC_IDE_PIO3_TCSH (0x0D<<24) 140#define SBC_IDE_PIO3_TCSH (0x0D << 24)
144#define SBC_IDE_PIO3_TCSOFF (0x0D<<20) 141#define SBC_IDE_PIO3_TCSOFF (0x0D << 20)
145#define SBC_IDE_PIO3_TWP (0x15<<14) 142#define SBC_IDE_PIO3_TWP (0x15 << 14)
146#define SBC_IDE_PIO3_TCSW (0x05<<10) 143#define SBC_IDE_PIO3_TCSW (0x05 << 10)
147#define SBC_IDE_PIO3_TPM (0x00<<6) 144#define SBC_IDE_PIO3_TPM (0x00 << 6)
148#define SBC_IDE_PIO3_TA (0x1A<<0) 145#define SBC_IDE_PIO3_TA (0x1A << 0)
149/* Timing parameters PIO mode 4 */ 146/* Timing parameters PIO mode 4 */
150#define SBC_IDE_PIO4_TCSOE (0x04<<29) 147#define SBC_IDE_PIO4_TCSOE (0x04 << 29)
151#define SBC_IDE_PIO4_TOECS (0x01<<26) 148#define SBC_IDE_PIO4_TOECS (0x01 << 26)
152#define SBC_IDE_PIO4_TWCS (0x01<<28) 149#define SBC_IDE_PIO4_TWCS (0x01 << 28)
153#define SBC_IDE_PIO4_TCSH (0x04<<24) 150#define SBC_IDE_PIO4_TCSH (0x04 << 24)
154#define SBC_IDE_PIO4_TCSOFF (0x04<<20) 151#define SBC_IDE_PIO4_TCSOFF (0x04 << 20)
155#define SBC_IDE_PIO4_TWP (0x0D<<14) 152#define SBC_IDE_PIO4_TWP (0x0D << 14)
156#define SBC_IDE_PIO4_TCSW (0x03<<10) 153#define SBC_IDE_PIO4_TCSW (0x03 << 10)
157#define SBC_IDE_PIO4_TPM (0x00<<6) 154#define SBC_IDE_PIO4_TPM (0x00 << 6)
158#define SBC_IDE_PIO4_TA (0x12<<0) 155#define SBC_IDE_PIO4_TA (0x12 << 0)
159/* Timing parameters MDMA mode 0 */ 156/* Timing parameters MDMA mode 0 */
160#define SBC_IDE_MDMA0_TCSOE (0x03<<29) 157#define SBC_IDE_MDMA0_TCSOE (0x03 << 29)
161#define SBC_IDE_MDMA0_TOECS (0x01<<26) 158#define SBC_IDE_MDMA0_TOECS (0x01 << 26)
162#define SBC_IDE_MDMA0_TWCS (0x01<<28) 159#define SBC_IDE_MDMA0_TWCS (0x01 << 28)
163#define SBC_IDE_MDMA0_TCSH (0x07<<24) 160#define SBC_IDE_MDMA0_TCSH (0x07 << 24)
164#define SBC_IDE_MDMA0_TCSOFF (0x07<<20) 161#define SBC_IDE_MDMA0_TCSOFF (0x07 << 20)
165#define SBC_IDE_MDMA0_TWP (0x0C<<14) 162#define SBC_IDE_MDMA0_TWP (0x0C << 14)
166#define SBC_IDE_MDMA0_TCSW (0x03<<10) 163#define SBC_IDE_MDMA0_TCSW (0x03 << 10)
167#define SBC_IDE_MDMA0_TPM (0x00<<6) 164#define SBC_IDE_MDMA0_TPM (0x00 << 6)
168#define SBC_IDE_MDMA0_TA (0x0F<<0) 165#define SBC_IDE_MDMA0_TA (0x0F << 0)
169/* Timing parameters MDMA mode 1 */ 166/* Timing parameters MDMA mode 1 */
170#define SBC_IDE_MDMA1_TCSOE (0x05<<29) 167#define SBC_IDE_MDMA1_TCSOE (0x05 << 29)
171#define SBC_IDE_MDMA1_TOECS (0x01<<26) 168#define SBC_IDE_MDMA1_TOECS (0x01 << 26)
172#define SBC_IDE_MDMA1_TWCS (0x01<<28) 169#define SBC_IDE_MDMA1_TWCS (0x01 << 28)
173#define SBC_IDE_MDMA1_TCSH (0x05<<24) 170#define SBC_IDE_MDMA1_TCSH (0x05 << 24)
174#define SBC_IDE_MDMA1_TCSOFF (0x05<<20) 171#define SBC_IDE_MDMA1_TCSOFF (0x05 << 20)
175#define SBC_IDE_MDMA1_TWP (0x0F<<14) 172#define SBC_IDE_MDMA1_TWP (0x0F << 14)
176#define SBC_IDE_MDMA1_TCSW (0x05<<10) 173#define SBC_IDE_MDMA1_TCSW (0x05 << 10)
177#define SBC_IDE_MDMA1_TPM (0x00<<6) 174#define SBC_IDE_MDMA1_TPM (0x00 << 6)
178#define SBC_IDE_MDMA1_TA (0x15<<0) 175#define SBC_IDE_MDMA1_TA (0x15 << 0)
179/* Timing parameters MDMA mode 2 */ 176/* Timing parameters MDMA mode 2 */
180#define SBC_IDE_MDMA2_TCSOE (0x04<<29) 177#define SBC_IDE_MDMA2_TCSOE (0x04 << 29)
181#define SBC_IDE_MDMA2_TOECS (0x01<<26) 178#define SBC_IDE_MDMA2_TOECS (0x01 << 26)
182#define SBC_IDE_MDMA2_TWCS (0x01<<28) 179#define SBC_IDE_MDMA2_TWCS (0x01 << 28)
183#define SBC_IDE_MDMA2_TCSH (0x04<<24) 180#define SBC_IDE_MDMA2_TCSH (0x04 << 24)
184#define SBC_IDE_MDMA2_TCSOFF (0x04<<20) 181#define SBC_IDE_MDMA2_TCSOFF (0x04 << 20)
185#define SBC_IDE_MDMA2_TWP (0x0D<<14) 182#define SBC_IDE_MDMA2_TWP (0x0D << 14)
186#define SBC_IDE_MDMA2_TCSW (0x04<<10) 183#define SBC_IDE_MDMA2_TCSW (0x04 << 10)
187#define SBC_IDE_MDMA2_TPM (0x00<<6) 184#define SBC_IDE_MDMA2_TPM (0x00 << 6)
188#define SBC_IDE_MDMA2_TA (0x12<<0) 185#define SBC_IDE_MDMA2_TA (0x12 << 0)
189 186
190#define SBC_IDE_TIMING(mode) \ 187#define SBC_IDE_TIMING(mode) \
191 SBC_IDE_##mode##_TWCS | \ 188 (SBC_IDE_##mode##_TWCS | \
192 SBC_IDE_##mode##_TCSH | \ 189 SBC_IDE_##mode##_TCSH | \
193 SBC_IDE_##mode##_TCSOFF | \ 190 SBC_IDE_##mode##_TCSOFF | \
194 SBC_IDE_##mode##_TWP | \ 191 SBC_IDE_##mode##_TWP | \
195 SBC_IDE_##mode##_TCSW | \ 192 SBC_IDE_##mode##_TCSW | \
196 SBC_IDE_##mode##_TPM | \ 193 SBC_IDE_##mode##_TPM | \
197 SBC_IDE_##mode##_TA 194 SBC_IDE_##mode##_TA)
diff --git a/include/asm-mips/mach-au1x00/au1xxx_psc.h b/include/asm-mips/mach-au1x00/au1xxx_psc.h
index 1bd4e27caf6b..dae4eca2417e 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_psc.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_psc.h
@@ -33,7 +33,6 @@
33#ifndef _AU1000_PSC_H_ 33#ifndef _AU1000_PSC_H_
34#define _AU1000_PSC_H_ 34#define _AU1000_PSC_H_
35 35
36
37/* The PSC base addresses. */ 36/* The PSC base addresses. */
38#ifdef CONFIG_SOC_AU1550 37#ifdef CONFIG_SOC_AU1550
39#define PSC0_BASE_ADDR 0xb1a00000 38#define PSC0_BASE_ADDR 0xb1a00000
@@ -47,8 +46,8 @@
47#define PSC1_BASE_ADDR 0xb1b00000 46#define PSC1_BASE_ADDR 0xb1b00000
48#endif 47#endif
49 48
50/* The PSC select and control registers are common to 49/*
51 * all protocols. 50 * The PSC select and control registers are common to all protocols.
52 */ 51 */
53#define PSC_SEL_OFFSET 0x00000000 52#define PSC_SEL_OFFSET 0x00000000
54#define PSC_CTRL_OFFSET 0x00000004 53#define PSC_CTRL_OFFSET 0x00000004
@@ -59,18 +58,17 @@
59#define PSC_SEL_CLK_SERCLK (2 << 4) 58#define PSC_SEL_CLK_SERCLK (2 << 4)
60 59
61#define PSC_SEL_PS_MASK 0x00000007 60#define PSC_SEL_PS_MASK 0x00000007
62#define PSC_SEL_PS_DISABLED (0) 61#define PSC_SEL_PS_DISABLED 0
63#define PSC_SEL_PS_SPIMODE (2) 62#define PSC_SEL_PS_SPIMODE 2
64#define PSC_SEL_PS_I2SMODE (3) 63#define PSC_SEL_PS_I2SMODE 3
65#define PSC_SEL_PS_AC97MODE (4) 64#define PSC_SEL_PS_AC97MODE 4
66#define PSC_SEL_PS_SMBUSMODE (5) 65#define PSC_SEL_PS_SMBUSMODE 5
67 66
68#define PSC_CTRL_DISABLE (0) 67#define PSC_CTRL_DISABLE 0
69#define PSC_CTRL_SUSPEND (2) 68#define PSC_CTRL_SUSPEND 2
70#define PSC_CTRL_ENABLE (3) 69#define PSC_CTRL_ENABLE 3
71 70
72/* AC97 Registers. 71/* AC97 Registers. */
73*/
74#define PSC_AC97CFG_OFFSET 0x00000008 72#define PSC_AC97CFG_OFFSET 0x00000008
75#define PSC_AC97MSK_OFFSET 0x0000000c 73#define PSC_AC97MSK_OFFSET 0x0000000c
76#define PSC_AC97PCR_OFFSET 0x00000010 74#define PSC_AC97PCR_OFFSET 0x00000010
@@ -95,8 +93,7 @@
95#define PSC_AC97GPO (AC97_PSC_BASE + PSC_AC97GPO_OFFSET) 93#define PSC_AC97GPO (AC97_PSC_BASE + PSC_AC97GPO_OFFSET)
96#define PSC_AC97GPI (AC97_PSC_BASE + PSC_AC97GPI_OFFSET) 94#define PSC_AC97GPI (AC97_PSC_BASE + PSC_AC97GPI_OFFSET)
97 95
98/* AC97 Config Register. 96/* AC97 Config Register. */
99*/
100#define PSC_AC97CFG_RT_MASK (3 << 30) 97#define PSC_AC97CFG_RT_MASK (3 << 30)
101#define PSC_AC97CFG_RT_FIFO1 (0 << 30) 98#define PSC_AC97CFG_RT_FIFO1 (0 << 30)
102#define PSC_AC97CFG_RT_FIFO2 (1 << 30) 99#define PSC_AC97CFG_RT_FIFO2 (1 << 30)
@@ -118,20 +115,19 @@
118#define PSC_AC97CFG_RXSLOT_MASK (0x3ff << 1) 115#define PSC_AC97CFG_RXSLOT_MASK (0x3ff << 1)
119#define PSC_AC97CFG_GE_ENABLE (1) 116#define PSC_AC97CFG_GE_ENABLE (1)
120 117
121/* Enable slots 3-12. 118/* Enable slots 3-12. */
122*/
123#define PSC_AC97CFG_TXSLOT_ENA(x) (1 << (((x) - 3) + 11)) 119#define PSC_AC97CFG_TXSLOT_ENA(x) (1 << (((x) - 3) + 11))
124#define PSC_AC97CFG_RXSLOT_ENA(x) (1 << (((x) - 3) + 1)) 120#define PSC_AC97CFG_RXSLOT_ENA(x) (1 << (((x) - 3) + 1))
125 121
126/* The word length equation is ((x) * 2) + 2, so choose 'x' appropriately. 122/*
123 * The word length equation is ((x) * 2) + 2, so choose 'x' appropriately.
127 * The only sensible numbers are 7, 9, or possibly 11. Nah, just do the 124 * The only sensible numbers are 7, 9, or possibly 11. Nah, just do the
128 * arithmetic in the macro. 125 * arithmetic in the macro.
129 */ 126 */
130#define PSC_AC97CFG_SET_LEN(x) (((((x)-2)/2) & 0xf) << 21) 127#define PSC_AC97CFG_SET_LEN(x) (((((x) - 2) / 2) & 0xf) << 21)
131#define PSC_AC97CFG_GET_LEN(x) (((((x) >> 21) & 0xf) * 2) + 2) 128#define PSC_AC97CFG_GET_LEN(x) (((((x) >> 21) & 0xf) * 2) + 2)
132 129
133/* AC97 Mask Register. 130/* AC97 Mask Register. */
134*/
135#define PSC_AC97MSK_GR (1 << 25) 131#define PSC_AC97MSK_GR (1 << 25)
136#define PSC_AC97MSK_CD (1 << 24) 132#define PSC_AC97MSK_CD (1 << 24)
137#define PSC_AC97MSK_RR (1 << 13) 133#define PSC_AC97MSK_RR (1 << 13)
@@ -148,8 +144,7 @@
148 PSC_AC97MSK_TO | PSC_AC97MSK_TU | \ 144 PSC_AC97MSK_TO | PSC_AC97MSK_TU | \
149 PSC_AC97MSK_RD | PSC_AC97MSK_TD) 145 PSC_AC97MSK_RD | PSC_AC97MSK_TD)
150 146
151/* AC97 Protocol Control Register. 147/* AC97 Protocol Control Register. */
152*/
153#define PSC_AC97PCR_RC (1 << 6) 148#define PSC_AC97PCR_RC (1 << 6)
154#define PSC_AC97PCR_RP (1 << 5) 149#define PSC_AC97PCR_RP (1 << 5)
155#define PSC_AC97PCR_RS (1 << 4) 150#define PSC_AC97PCR_RS (1 << 4)
@@ -157,8 +152,7 @@
157#define PSC_AC97PCR_TP (1 << 1) 152#define PSC_AC97PCR_TP (1 << 1)
158#define PSC_AC97PCR_TS (1 << 0) 153#define PSC_AC97PCR_TS (1 << 0)
159 154
160/* AC97 Status register (read only). 155/* AC97 Status register (read only). */
161*/
162#define PSC_AC97STAT_CB (1 << 26) 156#define PSC_AC97STAT_CB (1 << 26)
163#define PSC_AC97STAT_CP (1 << 25) 157#define PSC_AC97STAT_CP (1 << 25)
164#define PSC_AC97STAT_CR (1 << 24) 158#define PSC_AC97STAT_CR (1 << 24)
@@ -174,8 +168,7 @@
174#define PSC_AC97STAT_DR (1 << 1) 168#define PSC_AC97STAT_DR (1 << 1)
175#define PSC_AC97STAT_SR (1 << 0) 169#define PSC_AC97STAT_SR (1 << 0)
176 170
177/* AC97 Event Register. 171/* AC97 Event Register. */
178*/
179#define PSC_AC97EVNT_GR (1 << 25) 172#define PSC_AC97EVNT_GR (1 << 25)
180#define PSC_AC97EVNT_CD (1 << 24) 173#define PSC_AC97EVNT_CD (1 << 24)
181#define PSC_AC97EVNT_RR (1 << 13) 174#define PSC_AC97EVNT_RR (1 << 13)
@@ -187,22 +180,18 @@
187#define PSC_AC97EVNT_RD (1 << 5) 180#define PSC_AC97EVNT_RD (1 << 5)
188#define PSC_AC97EVNT_TD (1 << 4) 181#define PSC_AC97EVNT_TD (1 << 4)
189 182
190/* CODEC Command Register. 183/* CODEC Command Register. */
191*/
192#define PSC_AC97CDC_RD (1 << 25) 184#define PSC_AC97CDC_RD (1 << 25)
193#define PSC_AC97CDC_ID_MASK (3 << 23) 185#define PSC_AC97CDC_ID_MASK (3 << 23)
194#define PSC_AC97CDC_INDX_MASK (0x7f << 16) 186#define PSC_AC97CDC_INDX_MASK (0x7f << 16)
195#define PSC_AC97CDC_ID(x) (((x) & 0x3) << 23) 187#define PSC_AC97CDC_ID(x) (((x) & 0x03) << 23)
196#define PSC_AC97CDC_INDX(x) (((x) & 0x7f) << 16) 188#define PSC_AC97CDC_INDX(x) (((x) & 0x7f) << 16)
197 189
198/* AC97 Reset Control Register. 190/* AC97 Reset Control Register. */
199*/
200#define PSC_AC97RST_RST (1 << 1) 191#define PSC_AC97RST_RST (1 << 1)
201#define PSC_AC97RST_SNC (1 << 0) 192#define PSC_AC97RST_SNC (1 << 0)
202 193
203 194/* PSC in I2S Mode. */
204/* PSC in I2S Mode.
205*/
206typedef struct psc_i2s { 195typedef struct psc_i2s {
207 u32 psc_sel; 196 u32 psc_sel;
208 u32 psc_ctrl; 197 u32 psc_ctrl;
@@ -215,8 +204,7 @@ typedef struct psc_i2s {
215 u32 psc_i2sudf; 204 u32 psc_i2sudf;
216} psc_i2s_t; 205} psc_i2s_t;
217 206
218/* I2S Config Register. 207/* I2S Config Register. */
219*/
220#define PSC_I2SCFG_RT_MASK (3 << 30) 208#define PSC_I2SCFG_RT_MASK (3 << 30)
221#define PSC_I2SCFG_RT_FIFO1 (0 << 30) 209#define PSC_I2SCFG_RT_FIFO1 (0 << 30)
222#define PSC_I2SCFG_RT_FIFO2 (1 << 30) 210#define PSC_I2SCFG_RT_FIFO2 (1 << 30)
@@ -247,8 +235,7 @@ typedef struct psc_i2s {
247#define PSC_I2SCFG_MLJ (1 << 10) 235#define PSC_I2SCFG_MLJ (1 << 10)
248#define PSC_I2SCFG_XM (1 << 9) 236#define PSC_I2SCFG_XM (1 << 9)
249 237
250/* The word length equation is simply LEN+1. 238/* The word length equation is simply LEN+1. */
251 */
252#define PSC_I2SCFG_SET_LEN(x) ((((x) - 1) & 0x1f) << 4) 239#define PSC_I2SCFG_SET_LEN(x) ((((x) - 1) & 0x1f) << 4)
253#define PSC_I2SCFG_GET_LEN(x) ((((x) >> 4) & 0x1f) + 1) 240#define PSC_I2SCFG_GET_LEN(x) ((((x) >> 4) & 0x1f) + 1)
254 241
@@ -256,8 +243,7 @@ typedef struct psc_i2s {
256#define PSC_I2SCFG_MLF (1 << 1) 243#define PSC_I2SCFG_MLF (1 << 1)
257#define PSC_I2SCFG_MS (1 << 0) 244#define PSC_I2SCFG_MS (1 << 0)
258 245
259/* I2S Mask Register. 246/* I2S Mask Register. */
260*/
261#define PSC_I2SMSK_RR (1 << 13) 247#define PSC_I2SMSK_RR (1 << 13)
262#define PSC_I2SMSK_RO (1 << 12) 248#define PSC_I2SMSK_RO (1 << 12)
263#define PSC_I2SMSK_RU (1 << 11) 249#define PSC_I2SMSK_RU (1 << 11)
@@ -271,8 +257,7 @@ typedef struct psc_i2s {
271 PSC_I2SMSK_TO | PSC_I2SMSK_TU | \ 257 PSC_I2SMSK_TO | PSC_I2SMSK_TU | \
272 PSC_I2SMSK_RD | PSC_I2SMSK_TD) 258 PSC_I2SMSK_RD | PSC_I2SMSK_TD)
273 259
274/* I2S Protocol Control Register. 260/* I2S Protocol Control Register. */
275*/
276#define PSC_I2SPCR_RC (1 << 6) 261#define PSC_I2SPCR_RC (1 << 6)
277#define PSC_I2SPCR_RP (1 << 5) 262#define PSC_I2SPCR_RP (1 << 5)
278#define PSC_I2SPCR_RS (1 << 4) 263#define PSC_I2SPCR_RS (1 << 4)
@@ -280,8 +265,7 @@ typedef struct psc_i2s {
280#define PSC_I2SPCR_TP (1 << 1) 265#define PSC_I2SPCR_TP (1 << 1)
281#define PSC_I2SPCR_TS (1 << 0) 266#define PSC_I2SPCR_TS (1 << 0)
282 267
283/* I2S Status register (read only). 268/* I2S Status register (read only). */
284*/
285#define PSC_I2SSTAT_RF (1 << 13) 269#define PSC_I2SSTAT_RF (1 << 13)
286#define PSC_I2SSTAT_RE (1 << 12) 270#define PSC_I2SSTAT_RE (1 << 12)
287#define PSC_I2SSTAT_RR (1 << 11) 271#define PSC_I2SSTAT_RR (1 << 11)
@@ -294,8 +278,7 @@ typedef struct psc_i2s {
294#define PSC_I2SSTAT_DR (1 << 1) 278#define PSC_I2SSTAT_DR (1 << 1)
295#define PSC_I2SSTAT_SR (1 << 0) 279#define PSC_I2SSTAT_SR (1 << 0)
296 280
297/* I2S Event Register. 281/* I2S Event Register. */
298*/
299#define PSC_I2SEVNT_RR (1 << 13) 282#define PSC_I2SEVNT_RR (1 << 13)
300#define PSC_I2SEVNT_RO (1 << 12) 283#define PSC_I2SEVNT_RO (1 << 12)
301#define PSC_I2SEVNT_RU (1 << 11) 284#define PSC_I2SEVNT_RU (1 << 11)
@@ -305,8 +288,7 @@ typedef struct psc_i2s {
305#define PSC_I2SEVNT_RD (1 << 5) 288#define PSC_I2SEVNT_RD (1 << 5)
306#define PSC_I2SEVNT_TD (1 << 4) 289#define PSC_I2SEVNT_TD (1 << 4)
307 290
308/* PSC in SPI Mode. 291/* PSC in SPI Mode. */
309*/
310typedef struct psc_spi { 292typedef struct psc_spi {
311 u32 psc_sel; 293 u32 psc_sel;
312 u32 psc_ctrl; 294 u32 psc_ctrl;
@@ -318,8 +300,7 @@ typedef struct psc_spi {
318 u32 psc_spitxrx; 300 u32 psc_spitxrx;
319} psc_spi_t; 301} psc_spi_t;
320 302
321/* SPI Config Register. 303/* SPI Config Register. */
322*/
323#define PSC_SPICFG_RT_MASK (3 << 30) 304#define PSC_SPICFG_RT_MASK (3 << 30)
324#define PSC_SPICFG_RT_FIFO1 (0 << 30) 305#define PSC_SPICFG_RT_FIFO1 (0 << 30)
325#define PSC_SPICFG_RT_FIFO2 (1 << 30) 306#define PSC_SPICFG_RT_FIFO2 (1 << 30)
@@ -355,8 +336,7 @@ typedef struct psc_spi {
355#define PSC_SPICFG_MLF (1 << 1) 336#define PSC_SPICFG_MLF (1 << 1)
356#define PSC_SPICFG_MO (1 << 0) 337#define PSC_SPICFG_MO (1 << 0)
357 338
358/* SPI Mask Register. 339/* SPI Mask Register. */
359*/
360#define PSC_SPIMSK_MM (1 << 16) 340#define PSC_SPIMSK_MM (1 << 16)
361#define PSC_SPIMSK_RR (1 << 13) 341#define PSC_SPIMSK_RR (1 << 13)
362#define PSC_SPIMSK_RO (1 << 12) 342#define PSC_SPIMSK_RO (1 << 12)
@@ -371,16 +351,14 @@ typedef struct psc_spi {
371 PSC_SPIMSK_TU | PSC_SPIMSK_SD | \ 351 PSC_SPIMSK_TU | PSC_SPIMSK_SD | \
372 PSC_SPIMSK_MD) 352 PSC_SPIMSK_MD)
373 353
374/* SPI Protocol Control Register. 354/* SPI Protocol Control Register. */
375*/
376#define PSC_SPIPCR_RC (1 << 6) 355#define PSC_SPIPCR_RC (1 << 6)
377#define PSC_SPIPCR_SP (1 << 5) 356#define PSC_SPIPCR_SP (1 << 5)
378#define PSC_SPIPCR_SS (1 << 4) 357#define PSC_SPIPCR_SS (1 << 4)
379#define PSC_SPIPCR_TC (1 << 2) 358#define PSC_SPIPCR_TC (1 << 2)
380#define PSC_SPIPCR_MS (1 << 0) 359#define PSC_SPIPCR_MS (1 << 0)
381 360
382/* SPI Status register (read only). 361/* SPI Status register (read only). */
383*/
384#define PSC_SPISTAT_RF (1 << 13) 362#define PSC_SPISTAT_RF (1 << 13)
385#define PSC_SPISTAT_RE (1 << 12) 363#define PSC_SPISTAT_RE (1 << 12)
386#define PSC_SPISTAT_RR (1 << 11) 364#define PSC_SPISTAT_RR (1 << 11)
@@ -393,8 +371,7 @@ typedef struct psc_spi {
393#define PSC_SPISTAT_DR (1 << 1) 371#define PSC_SPISTAT_DR (1 << 1)
394#define PSC_SPISTAT_SR (1 << 0) 372#define PSC_SPISTAT_SR (1 << 0)
395 373
396/* SPI Event Register. 374/* SPI Event Register. */
397*/
398#define PSC_SPIEVNT_MM (1 << 16) 375#define PSC_SPIEVNT_MM (1 << 16)
399#define PSC_SPIEVNT_RR (1 << 13) 376#define PSC_SPIEVNT_RR (1 << 13)
400#define PSC_SPIEVNT_RO (1 << 12) 377#define PSC_SPIEVNT_RO (1 << 12)
@@ -405,13 +382,11 @@ typedef struct psc_spi {
405#define PSC_SPIEVNT_SD (1 << 5) 382#define PSC_SPIEVNT_SD (1 << 5)
406#define PSC_SPIEVNT_MD (1 << 4) 383#define PSC_SPIEVNT_MD (1 << 4)
407 384
408/* Transmit register control. 385/* Transmit register control. */
409*/
410#define PSC_SPITXRX_LC (1 << 29) 386#define PSC_SPITXRX_LC (1 << 29)
411#define PSC_SPITXRX_SR (1 << 28) 387#define PSC_SPITXRX_SR (1 << 28)
412 388
413/* PSC in SMBus (I2C) Mode. 389/* PSC in SMBus (I2C) Mode. */
414*/
415typedef struct psc_smb { 390typedef struct psc_smb {
416 u32 psc_sel; 391 u32 psc_sel;
417 u32 psc_ctrl; 392 u32 psc_ctrl;
@@ -424,8 +399,7 @@ typedef struct psc_smb {
424 u32 psc_smbtmr; 399 u32 psc_smbtmr;
425} psc_smb_t; 400} psc_smb_t;
426 401
427/* SMBus Config Register. 402/* SMBus Config Register. */
428*/
429#define PSC_SMBCFG_RT_MASK (3 << 30) 403#define PSC_SMBCFG_RT_MASK (3 << 30)
430#define PSC_SMBCFG_RT_FIFO1 (0 << 30) 404#define PSC_SMBCFG_RT_FIFO1 (0 << 30)
431#define PSC_SMBCFG_RT_FIFO2 (1 << 30) 405#define PSC_SMBCFG_RT_FIFO2 (1 << 30)
@@ -452,8 +426,7 @@ typedef struct psc_smb {
452 426
453#define PSC_SMBCFG_SET_SLV(x) (((x) & 0x7f) << 1) 427#define PSC_SMBCFG_SET_SLV(x) (((x) & 0x7f) << 1)
454 428
455/* SMBus Mask Register. 429/* SMBus Mask Register. */
456*/
457#define PSC_SMBMSK_DN (1 << 30) 430#define PSC_SMBMSK_DN (1 << 30)
458#define PSC_SMBMSK_AN (1 << 29) 431#define PSC_SMBMSK_AN (1 << 29)
459#define PSC_SMBMSK_AL (1 << 28) 432#define PSC_SMBMSK_AL (1 << 28)
@@ -471,13 +444,11 @@ typedef struct psc_smb {
471 PSC_SMBMSK_TU | PSC_SMBMSK_SD | \ 444 PSC_SMBMSK_TU | PSC_SMBMSK_SD | \
472 PSC_SMBMSK_MD) 445 PSC_SMBMSK_MD)
473 446
474/* SMBus Protocol Control Register. 447/* SMBus Protocol Control Register. */
475*/
476#define PSC_SMBPCR_DC (1 << 2) 448#define PSC_SMBPCR_DC (1 << 2)
477#define PSC_SMBPCR_MS (1 << 0) 449#define PSC_SMBPCR_MS (1 << 0)
478 450
479/* SMBus Status register (read only). 451/* SMBus Status register (read only). */
480*/
481#define PSC_SMBSTAT_BB (1 << 28) 452#define PSC_SMBSTAT_BB (1 << 28)
482#define PSC_SMBSTAT_RF (1 << 13) 453#define PSC_SMBSTAT_RF (1 << 13)
483#define PSC_SMBSTAT_RE (1 << 12) 454#define PSC_SMBSTAT_RE (1 << 12)
@@ -491,8 +462,7 @@ typedef struct psc_smb {
491#define PSC_SMBSTAT_DR (1 << 1) 462#define PSC_SMBSTAT_DR (1 << 1)
492#define PSC_SMBSTAT_SR (1 << 0) 463#define PSC_SMBSTAT_SR (1 << 0)
493 464
494/* SMBus Event Register. 465/* SMBus Event Register. */
495*/
496#define PSC_SMBEVNT_DN (1 << 30) 466#define PSC_SMBEVNT_DN (1 << 30)
497#define PSC_SMBEVNT_AN (1 << 29) 467#define PSC_SMBEVNT_AN (1 << 29)
498#define PSC_SMBEVNT_AL (1 << 28) 468#define PSC_SMBEVNT_AL (1 << 28)
@@ -510,15 +480,13 @@ typedef struct psc_smb {
510 PSC_SMBEVNT_TU | PSC_SMBEVNT_SD | \ 480 PSC_SMBEVNT_TU | PSC_SMBEVNT_SD | \
511 PSC_SMBEVNT_MD) 481 PSC_SMBEVNT_MD)
512 482
513/* Transmit register control. 483/* Transmit register control. */
514*/
515#define PSC_SMBTXRX_RSR (1 << 28) 484#define PSC_SMBTXRX_RSR (1 << 28)
516#define PSC_SMBTXRX_STP (1 << 29) 485#define PSC_SMBTXRX_STP (1 << 29)
517#define PSC_SMBTXRX_DATAMASK (0xff) 486#define PSC_SMBTXRX_DATAMASK 0xff
518 487
519/* SMBus protocol timers register. 488/* SMBus protocol timers register. */
520*/ 489#define PSC_SMBTMR_SET_TH(x) (((x) & 0x03) << 30)
521#define PSC_SMBTMR_SET_TH(x) (((x) & 0x3) << 30)
522#define PSC_SMBTMR_SET_PS(x) (((x) & 0x1f) << 25) 490#define PSC_SMBTMR_SET_PS(x) (((x) & 0x1f) << 25)
523#define PSC_SMBTMR_SET_PU(x) (((x) & 0x1f) << 20) 491#define PSC_SMBTMR_SET_PU(x) (((x) & 0x1f) << 20)
524#define PSC_SMBTMR_SET_SH(x) (((x) & 0x1f) << 15) 492#define PSC_SMBTMR_SET_SH(x) (((x) & 0x1f) << 15)
@@ -526,5 +494,4 @@ typedef struct psc_smb {
526#define PSC_SMBTMR_SET_CL(x) (((x) & 0x1f) << 5) 494#define PSC_SMBTMR_SET_CL(x) (((x) & 0x1f) << 5)
527#define PSC_SMBTMR_SET_CH(x) (((x) & 0x1f) << 0) 495#define PSC_SMBTMR_SET_CH(x) (((x) & 0x1f) << 0)
528 496
529
530#endif /* _AU1000_PSC_H_ */ 497#endif /* _AU1000_PSC_H_ */
diff --git a/include/asm-mips/mach-db1x00/db1200.h b/include/asm-mips/mach-db1x00/db1200.h
index eedd048a7261..27f26102b1bb 100644
--- a/include/asm-mips/mach-db1x00/db1200.h
+++ b/include/asm-mips/mach-db1x00/db1200.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * AMD Alchemy DB1200 Referrence Board 2 * AMD Alchemy DBAu1200 Reference Board
3 * Board Registers defines. 3 * Board register defines.
4 * 4 *
5 * ######################################################################## 5 * ########################################################################
6 * 6 *
@@ -27,26 +27,25 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h> 28#include <asm/mach-au1x00/au1xxx_psc.h>
29 29
30// This is defined in au1000.h with bogus value 30#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
31#undef AU1X00_EXTERNAL_INT 31#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
32#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX
33#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
32 34
33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX 35/*
34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX 36 * SPI and SMB are muxed on the DBAu1200 board.
35#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX 37 * Refer to board documentation.
36#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
37
38/* SPI and SMB are muxed on the Pb1200 board.
39 Refer to board documentation.
40 */ 38 */
41#define SPI_PSC_BASE PSC0_BASE_ADDR 39#define SPI_PSC_BASE PSC0_BASE_ADDR
42#define SMBUS_PSC_BASE PSC0_BASE_ADDR 40#define SMBUS_PSC_BASE PSC0_BASE_ADDR
43/* AC97 and I2S are muxed on the Pb1200 board. 41/*
44 Refer to board documentation. 42 * AC'97 and I2S are muxed on the DBAu1200 board.
43 * Refer to board documentation.
45 */ 44 */
46#define AC97_PSC_BASE PSC1_BASE_ADDR 45#define AC97_PSC_BASE PSC1_BASE_ADDR
47#define I2S_PSC_BASE PSC1_BASE_ADDR 46#define I2S_PSC_BASE PSC1_BASE_ADDR
48 47
49#define BCSR_KSEG1_ADDR 0xB9800000 48#define BCSR_KSEG1_ADDR 0xB9800000
50 49
51typedef volatile struct 50typedef volatile struct
52{ 51{
@@ -102,9 +101,9 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
102#define BCSR_STATUS_SWAPBOOT 0x0040 101#define BCSR_STATUS_SWAPBOOT 0x0040
103#define BCSR_STATUS_FLASHBUSY 0x0100 102#define BCSR_STATUS_FLASHBUSY 0x0100
104#define BCSR_STATUS_IDECBLID 0x0200 103#define BCSR_STATUS_IDECBLID 0x0200
105#define BCSR_STATUS_SD0WP 0x0400 104#define BCSR_STATUS_SD0WP 0x0400
106#define BCSR_STATUS_U0RXD 0x1000 105#define BCSR_STATUS_U0RXD 0x1000
107#define BCSR_STATUS_U1RXD 0x2000 106#define BCSR_STATUS_U1RXD 0x2000
108 107
109#define BCSR_SWITCHES_OCTAL 0x00FF 108#define BCSR_SWITCHES_OCTAL 0x00FF
110#define BCSR_SWITCHES_DIP_1 0x0080 109#define BCSR_SWITCHES_DIP_1 0x0080
@@ -122,8 +121,8 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
122#define BCSR_RESETS_DC 0x0004 121#define BCSR_RESETS_DC 0x0004
123#define BCSR_RESETS_IDE 0x0008 122#define BCSR_RESETS_IDE 0x0008
124#define BCSR_RESETS_TV 0x0010 123#define BCSR_RESETS_TV 0x0010
125/* not resets but in the same register */ 124/* Not resets but in the same register */
126#define BCSR_RESETS_PWMR1mUX 0x0800 125#define BCSR_RESETS_PWMR1MUX 0x0800
127#define BCSR_RESETS_PCS0MUX 0x1000 126#define BCSR_RESETS_PCS0MUX 0x1000
128#define BCSR_RESETS_PCS1MUX 0x2000 127#define BCSR_RESETS_PCS1MUX 0x2000
129#define BCSR_RESETS_SPISEL 0x4000 128#define BCSR_RESETS_SPISEL 0x4000
@@ -160,7 +159,7 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
160#define BCSR_INT_PC0STSCHG 0x0008 159#define BCSR_INT_PC0STSCHG 0x0008
161#define BCSR_INT_PC1 0x0010 160#define BCSR_INT_PC1 0x0010
162#define BCSR_INT_PC1STSCHG 0x0020 161#define BCSR_INT_PC1STSCHG 0x0020
163#define BCSR_INT_DC 0x0040 162#define BCSR_INT_DC 0x0040
164#define BCSR_INT_FLASHBUSY 0x0080 163#define BCSR_INT_FLASHBUSY 0x0080
165#define BCSR_INT_PC0INSERT 0x0100 164#define BCSR_INT_PC0INSERT 0x0100
166#define BCSR_INT_PC0EJECT 0x0200 165#define BCSR_INT_PC0EJECT 0x0200
@@ -179,10 +178,10 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
179#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1 178#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
180#define IDE_RQSIZE 128 179#define IDE_RQSIZE 128
181 180
182#define NAND_PHYS_ADDR 0x20000000 181#define NAND_PHYS_ADDR 0x20000000
183 182
184/* 183/*
185 * External Interrupts for Pb1200 as of 8/6/2004. 184 * External Interrupts for DBAu1200 as of 8/6/2004.
186 * Bit positions in the CPLD registers can be calculated by taking 185 * Bit positions in the CPLD registers can be calculated by taking
187 * the interrupt define and subtracting the DB1200_INT_BEGIN value. 186 * the interrupt define and subtracting the DB1200_INT_BEGIN value.
188 * 187 *
@@ -211,23 +210,21 @@ enum external_pb1200_ints {
211}; 210};
212 211
213 212
214/* For drivers/pcmcia/au1000_db1x00.c */ 213/*
215 214 * DBAu1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
216/* PCMCIA Db1x00 specific defines */ 215 */
217 216#define PCMCIA_MAX_SOCK 1
218#define PCMCIA_MAX_SOCK 1 217#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
219#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1)
220 218
221/* VPP/VCC */ 219/* VPP/VCC */
222#define SET_VCC_VPP(VCC, VPP, SLOT)\ 220#define SET_VCC_VPP(VCC, VPP, SLOT) \
223 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) 221 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
224 222
225#define BOARD_PC0_INT DB1200_PC0_INT 223#define BOARD_PC0_INT DB1200_PC0_INT
226#define BOARD_PC1_INT DB1200_PC1_INT 224#define BOARD_PC1_INT DB1200_PC1_INT
227#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1<<(8+(2*SOCKET))) 225#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
228 226
229/* Nand chip select */ 227/* NAND chip select */
230#define NAND_CS 1 228#define NAND_CS 1
231 229
232#endif /* __ASM_DB1200_H */ 230#endif /* __ASM_DB1200_H */
233
diff --git a/include/asm-mips/mach-db1x00/db1x00.h b/include/asm-mips/mach-db1x00/db1x00.h
index e7a88ba35833..612ae90dbcb8 100644
--- a/include/asm-mips/mach-db1x00/db1x00.h
+++ b/include/asm-mips/mach-db1x00/db1x00.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * AMD Alchemy DB1x00 Reference Boards 2 * AMD Alchemy DBAu1x00 Reference Boards
3 * 3 *
4 * Copyright 2001 MontaVista Software Inc. 4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. 5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 * ppopov@mvista.com or source@mvista.com
7 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org) 6 * Copyright (C) 2005 Ralf Baechle (ralf@linux-mips.org)
8 * 7 *
9 * ######################################################################## 8 * ########################################################################
@@ -32,26 +31,26 @@
32 31
33#ifdef CONFIG_MIPS_DB1550 32#ifdef CONFIG_MIPS_DB1550
34 33
35#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX 34#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
36#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX 35#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
37#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX 36#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX
38#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX 37#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX
39 38
40#define SPI_PSC_BASE PSC0_BASE_ADDR 39#define SPI_PSC_BASE PSC0_BASE_ADDR
41#define AC97_PSC_BASE PSC1_BASE_ADDR 40#define AC97_PSC_BASE PSC1_BASE_ADDR
42#define SMBUS_PSC_BASE PSC2_BASE_ADDR 41#define SMBUS_PSC_BASE PSC2_BASE_ADDR
43#define I2S_PSC_BASE PSC3_BASE_ADDR 42#define I2S_PSC_BASE PSC3_BASE_ADDR
44 43
45#define BCSR_KSEG1_ADDR 0xAF000000 44#define BCSR_KSEG1_ADDR 0xAF000000
46#define NAND_PHYS_ADDR 0x20000000 45#define NAND_PHYS_ADDR 0x20000000
47 46
48#else 47#else
49#define BCSR_KSEG1_ADDR 0xAE000000 48#define BCSR_KSEG1_ADDR 0xAE000000
50#endif 49#endif
51 50
52/* 51/*
53 * Overlay data structure of the Db1x00 board registers. 52 * Overlay data structure of the DBAu1x00 board registers.
54 * Registers located at physical 0E0000xx, KSEG1 0xAE0000xx 53 * Registers are located at physical 0E0000xx, KSEG1 0xAE0000xx.
55 */ 54 */
56typedef volatile struct 55typedef volatile struct
57{ 56{
@@ -138,18 +137,19 @@ typedef volatile struct
138 137
139#define BCSR_SWRESET_RESET 0x0080 138#define BCSR_SWRESET_RESET 0x0080
140 139
141/* PCMCIA Db1x00 specific defines */ 140/* PCMCIA DBAu1x00 specific defines */
142#define PCMCIA_MAX_SOCK 1 141#define PCMCIA_MAX_SOCK 1
143#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) 142#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
144 143
145/* VPP/VCC */ 144/* VPP/VCC */
146#define SET_VCC_VPP(VCC, VPP, SLOT)\ 145#define SET_VCC_VPP(VCC, VPP, SLOT)\
147 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) 146 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
148 147
149/* SD controller macros */
150/* 148/*
151 * Detect card. 149 * SD controller macros
152 */ 150 */
151
152/* Detect card. */
153#define mmc_card_inserted(_n_, _res_) \ 153#define mmc_card_inserted(_n_, _res_) \
154 do { \ 154 do { \
155 BCSR * const bcsr = (BCSR *)0xAE000000; \ 155 BCSR * const bcsr = (BCSR *)0xAE000000; \
@@ -176,10 +176,10 @@ typedef volatile struct
176 unsigned long mmc_pwr, mmc_wp, board_specific; \ 176 unsigned long mmc_pwr, mmc_wp, board_specific; \
177 if ((_n_)) { \ 177 if ((_n_)) { \
178 mmc_pwr = BCSR_BOARD_SD1_PWR; \ 178 mmc_pwr = BCSR_BOARD_SD1_PWR; \
179 mmc_wp = BCSR_BOARD_SD1_WP; \ 179 mmc_wp = BCSR_BOARD_SD1_WP; \
180 } else { \ 180 } else { \
181 mmc_pwr = BCSR_BOARD_SD0_PWR; \ 181 mmc_pwr = BCSR_BOARD_SD0_PWR; \
182 mmc_wp = BCSR_BOARD_SD0_WP; \ 182 mmc_wp = BCSR_BOARD_SD0_WP; \
183 } \ 183 } \
184 board_specific = au_readl((unsigned long)(&bcsr->specific)); \ 184 board_specific = au_readl((unsigned long)(&bcsr->specific)); \
185 if (!(board_specific & mmc_wp)) {/* low means card present */ \ 185 if (!(board_specific & mmc_wp)) {/* low means card present */ \
@@ -190,17 +190,19 @@ typedef volatile struct
190 } while (0) 190 } while (0)
191 191
192 192
193/* NAND defines */ 193/*
194/* Timing values as described in databook, * ns value stripped of 194 * NAND defines
195 *
196 * Timing values as described in databook, * ns value stripped of the
195 * lower 2 bits. 197 * lower 2 bits.
196 * These defines are here rather than an SOC1550 generic file because 198 * These defines are here rather than an Au1550 generic file because
197 * the parts chosen on another board may be different and may require 199 * the parts chosen on another board may be different and may require
198 * different timings. 200 * different timings.
199 */ 201 */
200#define NAND_T_H (18 >> 2) 202#define NAND_T_H (18 >> 2)
201#define NAND_T_PUL (30 >> 2) 203#define NAND_T_PUL (30 >> 2)
202#define NAND_T_SU (30 >> 2) 204#define NAND_T_SU (30 >> 2)
203#define NAND_T_WH (30 >> 2) 205#define NAND_T_WH (30 >> 2)
204 206
205/* Bitfield shift amounts */ 207/* Bitfield shift amounts */
206#define NAND_T_H_SHIFT 0 208#define NAND_T_H_SHIFT 0
@@ -208,16 +210,15 @@ typedef volatile struct
208#define NAND_T_SU_SHIFT 8 210#define NAND_T_SU_SHIFT 8
209#define NAND_T_WH_SHIFT 12 211#define NAND_T_WH_SHIFT 12
210 212
211#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ 213#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
212 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ 214 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
213 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ 215 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
214 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) 216 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
215#define NAND_CS 1 217#define NAND_CS 1
216 218
217/* should be done by yamon */ 219/* Should be done by YAMON */
218#define NAND_STCFG 0x00400005 /* 8-bit NAND */ 220#define NAND_STCFG 0x00400005 /* 8-bit NAND */
219#define NAND_STTIME 0x00007774 /* valid for 396MHz SD=2 only */ 221#define NAND_STTIME 0x00007774 /* valid for 396 MHz SD=2 only */
220#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */ 222#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */
221 223
222#endif /* __ASM_DB1X00_H */ 224#endif /* __ASM_DB1X00_H */
223
diff --git a/include/asm-mips/mach-pb1x00/pb1000.h b/include/asm-mips/mach-pb1x00/pb1000.h
index b52e0e7ee3fb..6d1ff9060e44 100644
--- a/include/asm-mips/mach-pb1x00/pb1000.h
+++ b/include/asm-mips/mach-pb1x00/pb1000.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * Alchemy Semi PB1000 Referrence Board 2 * Alchemy Semi Pb1000 Referrence Board
3 * 3 *
4 * Copyright 2001 MontaVista Software Inc. 4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. 5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 * ppopov@mvista.com or source@mvista.com
7 * 6 *
8 * ######################################################################## 7 * ########################################################################
9 * 8 *
@@ -28,145 +27,61 @@
28#define __ASM_PB1000_H 27#define __ASM_PB1000_H
29 28
30/* PCMCIA PB1000 specific defines */ 29/* PCMCIA PB1000 specific defines */
31#define PCMCIA_MAX_SOCK 1 30#define PCMCIA_MAX_SOCK 1
32#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) 31#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
33 32
34#define PB1000_PCR 0xBE000000 33#define PB1000_PCR 0xBE000000
35# define PCR_SLOT_0_VPP0 (1<<0) 34# define PCR_SLOT_0_VPP0 (1 << 0)
36# define PCR_SLOT_0_VPP1 (1<<1) 35# define PCR_SLOT_0_VPP1 (1 << 1)
37# define PCR_SLOT_0_VCC0 (1<<2) 36# define PCR_SLOT_0_VCC0 (1 << 2)
38# define PCR_SLOT_0_VCC1 (1<<3) 37# define PCR_SLOT_0_VCC1 (1 << 3)
39# define PCR_SLOT_0_RST (1<<4) 38# define PCR_SLOT_0_RST (1 << 4)
40 39# define PCR_SLOT_1_VPP0 (1 << 8)
41# define PCR_SLOT_1_VPP0 (1<<8) 40# define PCR_SLOT_1_VPP1 (1 << 9)
42# define PCR_SLOT_1_VPP1 (1<<9) 41# define PCR_SLOT_1_VCC0 (1 << 10)
43# define PCR_SLOT_1_VCC0 (1<<10) 42# define PCR_SLOT_1_VCC1 (1 << 11)
44# define PCR_SLOT_1_VCC1 (1<<11) 43# define PCR_SLOT_1_RST (1 << 12)
45# define PCR_SLOT_1_RST (1<<12) 44
46 45#define PB1000_MDR 0xBE000004
47#define PB1000_MDR 0xBE000004 46# define MDR_PI (1 << 5) /* PCMCIA int latch */
48# define MDR_PI (1<<5) /* pcmcia int latch */ 47# define MDR_EPI (1 << 14) /* enable PCMCIA int */
49# define MDR_EPI (1<<14) /* enable pcmcia int */ 48# define MDR_CPI (1 << 15) /* clear PCMCIA int */
50# define MDR_CPI (1<<15) /* clear pcmcia int */ 49
51 50#define PB1000_ACR1 0xBE000008
52#define PB1000_ACR1 0xBE000008 51# define ACR1_SLOT_0_CD1 (1 << 0) /* card detect 1 */
53# define ACR1_SLOT_0_CD1 (1<<0) /* card detect 1 */ 52# define ACR1_SLOT_0_CD2 (1 << 1) /* card detect 2 */
54# define ACR1_SLOT_0_CD2 (1<<1) /* card detect 2 */ 53# define ACR1_SLOT_0_READY (1 << 2) /* ready */
55# define ACR1_SLOT_0_READY (1<<2) /* ready */ 54# define ACR1_SLOT_0_STATUS (1 << 3) /* status change */
56# define ACR1_SLOT_0_STATUS (1<<3) /* status change */ 55# define ACR1_SLOT_0_VS1 (1 << 4) /* voltage sense 1 */
57# define ACR1_SLOT_0_VS1 (1<<4) /* voltage sense 1 */ 56# define ACR1_SLOT_0_VS2 (1 << 5) /* voltage sense 2 */
58# define ACR1_SLOT_0_VS2 (1<<5) /* voltage sense 2 */ 57# define ACR1_SLOT_0_INPACK (1 << 6) /* inpack pin status */
59# define ACR1_SLOT_0_INPACK (1<<6) /* inpack pin status */ 58# define ACR1_SLOT_1_CD1 (1 << 8) /* card detect 1 */
60# define ACR1_SLOT_1_CD1 (1<<8) /* card detect 1 */ 59# define ACR1_SLOT_1_CD2 (1 << 9) /* card detect 2 */
61# define ACR1_SLOT_1_CD2 (1<<9) /* card detect 2 */ 60# define ACR1_SLOT_1_READY (1 << 10) /* ready */
62# define ACR1_SLOT_1_READY (1<<10) /* ready */ 61# define ACR1_SLOT_1_STATUS (1 << 11) /* status change */
63# define ACR1_SLOT_1_STATUS (1<<11) /* status change */ 62# define ACR1_SLOT_1_VS1 (1 << 12) /* voltage sense 1 */
64# define ACR1_SLOT_1_VS1 (1<<12) /* voltage sense 1 */ 63# define ACR1_SLOT_1_VS2 (1 << 13) /* voltage sense 2 */
65# define ACR1_SLOT_1_VS2 (1<<13) /* voltage sense 2 */ 64# define ACR1_SLOT_1_INPACK (1 << 14) /* inpack pin status */
66# define ACR1_SLOT_1_INPACK (1<<14) /* inpack pin status */ 65
67 66#define CPLD_AUX0 0xBE00000C
68#define CPLD_AUX0 0xBE00000C 67#define CPLD_AUX1 0xBE000010
69#define CPLD_AUX1 0xBE000010 68#define CPLD_AUX2 0xBE000014
70#define CPLD_AUX2 0xBE000014
71 69
72/* Voltage levels */ 70/* Voltage levels */
73 71
74/* VPPEN1 - VPPEN0 */ 72/* VPPEN1 - VPPEN0 */
75#define VPP_GND ((0<<1) | (0<<0)) 73#define VPP_GND ((0 << 1) | (0 << 0))
76#define VPP_5V ((1<<1) | (0<<0)) 74#define VPP_5V ((1 << 1) | (0 << 0))
77#define VPP_3V ((0<<1) | (1<<0)) 75#define VPP_3V ((0 << 1) | (1 << 0))
78#define VPP_12V ((0<<1) | (1<<0)) 76#define VPP_12V ((0 << 1) | (1 << 0))
79#define VPP_HIZ ((1<<1) | (1<<0)) 77#define VPP_HIZ ((1 << 1) | (1 << 0))
80 78
81/* VCCEN1 - VCCEN0 */ 79/* VCCEN1 - VCCEN0 */
82#define VCC_3V ((0<<1) | (1<<0)) 80#define VCC_3V ((0 << 1) | (1 << 0))
83#define VCC_5V ((1<<1) | (0<<0)) 81#define VCC_5V ((1 << 1) | (0 << 0))
84#define VCC_HIZ ((0<<1) | (0<<0)) 82#define VCC_HIZ ((0 << 1) | (0 << 0))
85 83
86/* VPP/VCC */ 84/* VPP/VCC */
87#define SET_VCC_VPP(VCC, VPP, SLOT)\ 85#define SET_VCC_VPP(VCC, VPP, SLOT) \
88 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) 86 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
89
90
91/* PCI PB1000 specific defines */
92/* The reason these defines are here instead of au1000.h is because
93 * the Au1000 does not have a PCI bus controller so the PCI implementation
94 * on the some of the older Pb1000 boards was very board specific.
95 */
96#define PCI_CONFIG_BASE 0xBA020000 /* the only external slot */
97
98#define SDRAM_DEVID 0xBA010000
99#define SDRAM_CMD 0xBA010004
100#define SDRAM_CLASS 0xBA010008
101#define SDRAM_MISC 0xBA01000C
102#define SDRAM_MBAR 0xBA010010
103
104#define PCI_IO_DATA_PORT 0xBA800000
105
106#define PCI_IO_ADDR 0xBE00001C
107#define PCI_INT_ACK 0xBBC00000
108#define PCI_IO_READ 0xBBC00020
109#define PCI_IO_WRITE 0xBBC00030
110
111#define PCI_BRIDGE_CONFIG 0xBE000018
112
113#define PCI_IO_START 0x10000000
114#define PCI_IO_END 0x1000ffff
115#define PCI_MEM_START 0x18000000
116#define PCI_MEM_END 0x18ffffff
117
118#define PCI_FIRST_DEVFN 0
119#define PCI_LAST_DEVFN 1
120
121static inline u8 au_pci_io_readb(u32 addr)
122{
123 writel(addr, PCI_IO_ADDR);
124 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffcfff) | (1<<12), PCI_BRIDGE_CONFIG);
125 return (readl(PCI_IO_DATA_PORT) & 0xff);
126}
127
128static inline u16 au_pci_io_readw(u32 addr)
129{
130 writel(addr, PCI_IO_ADDR);
131 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffcfff) | (1<<13), PCI_BRIDGE_CONFIG);
132 return (readl(PCI_IO_DATA_PORT) & 0xffff);
133}
134
135static inline u32 au_pci_io_readl(u32 addr)
136{
137 writel(addr, PCI_IO_ADDR);
138 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffcfff), PCI_BRIDGE_CONFIG);
139 return readl(PCI_IO_DATA_PORT);
140}
141
142static inline void au_pci_io_writeb(u8 val, u32 addr)
143{
144 writel(addr, PCI_IO_ADDR);
145 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffcfff) | (1<<12), PCI_BRIDGE_CONFIG);
146 writel(val, PCI_IO_DATA_PORT);
147}
148
149static inline void au_pci_io_writew(u16 val, u32 addr)
150{
151 writel(addr, PCI_IO_ADDR);
152 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffcfff) | (1<<13), PCI_BRIDGE_CONFIG);
153 writel(val, PCI_IO_DATA_PORT);
154}
155
156static inline void au_pci_io_writel(u32 val, u32 addr)
157{
158 writel(addr, PCI_IO_ADDR);
159 writel(readl(PCI_BRIDGE_CONFIG) & 0xffffcfff, PCI_BRIDGE_CONFIG);
160 writel(val, PCI_IO_DATA_PORT);
161}
162
163static inline void set_sdram_extbyte(void)
164{
165 writel(readl(PCI_BRIDGE_CONFIG) & 0xffffff00, PCI_BRIDGE_CONFIG);
166}
167
168static inline void set_slot_extbyte(void)
169{
170 writel((readl(PCI_BRIDGE_CONFIG) & 0xffffbf00) | 0x18, PCI_BRIDGE_CONFIG);
171}
172#endif /* __ASM_PB1000_H */ 87#endif /* __ASM_PB1000_H */
diff --git a/include/asm-mips/mach-pb1x00/pb1100.h b/include/asm-mips/mach-pb1x00/pb1100.h
index 63aa3926b297..b1a60f1cbd02 100644
--- a/include/asm-mips/mach-pb1x00/pb1100.h
+++ b/include/asm-mips/mach-pb1x00/pb1100.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * Alchemy Semi PB1100 Referrence Board 2 * Alchemy Semi Pb1100 Referrence Board
3 * 3 *
4 * Copyright 2001 MontaVista Software Inc. 4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. 5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 * ppopov@mvista.com or source@mvista.com
7 * 6 *
8 * ######################################################################## 7 * ########################################################################
9 * 8 *
@@ -27,59 +26,60 @@
27#ifndef __ASM_PB1100_H 26#ifndef __ASM_PB1100_H
28#define __ASM_PB1100_H 27#define __ASM_PB1100_H
29 28
30#define PB1100_IDENT 0xAE000000 29#define PB1100_IDENT 0xAE000000
31#define BOARD_STATUS_REG 0xAE000004 30#define BOARD_STATUS_REG 0xAE000004
32# define PB1100_ROM_SEL (1<<15) 31# define PB1100_ROM_SEL (1 << 15)
33# define PB1100_ROM_SIZ (1<<14) 32# define PB1100_ROM_SIZ (1 << 14)
34# define PB1100_SWAP_BOOT (1<<13) 33# define PB1100_SWAP_BOOT (1 << 13)
35# define PB1100_FLASH_WP (1<<12) 34# define PB1100_FLASH_WP (1 << 12)
36# define PB1100_ROM_H_STS (1<<11) 35# define PB1100_ROM_H_STS (1 << 11)
37# define PB1100_ROM_L_STS (1<<10) 36# define PB1100_ROM_L_STS (1 << 10)
38# define PB1100_FLASH_H_STS (1<<9) 37# define PB1100_FLASH_H_STS (1 << 9)
39# define PB1100_FLASH_L_STS (1<<8) 38# define PB1100_FLASH_L_STS (1 << 8)
40# define PB1100_SRAM_SIZ (1<<7) 39# define PB1100_SRAM_SIZ (1 << 7)
41# define PB1100_TSC_BUSY (1<<6) 40# define PB1100_TSC_BUSY (1 << 6)
42# define PB1100_PCMCIA_VS_MASK (3<<4) 41# define PB1100_PCMCIA_VS_MASK (3 << 4)
43# define PB1100_RS232_CD (1<<3) 42# define PB1100_RS232_CD (1 << 3)
44# define PB1100_RS232_CTS (1<<2) 43# define PB1100_RS232_CTS (1 << 2)
45# define PB1100_RS232_DSR (1<<1) 44# define PB1100_RS232_DSR (1 << 1)
46# define PB1100_RS232_RI (1<<0) 45# define PB1100_RS232_RI (1 << 0)
47 46
48#define PB1100_IRDA_RS232 0xAE00000C 47#define PB1100_IRDA_RS232 0xAE00000C
49# define PB1100_IRDA_FULL (0<<14) /* full power */ 48# define PB1100_IRDA_FULL (0 << 14) /* full power */
50# define PB1100_IRDA_SHUTDOWN (1<<14) 49# define PB1100_IRDA_SHUTDOWN (1 << 14)
51# define PB1100_IRDA_TT (2<<14) /* 2/3 power */ 50# define PB1100_IRDA_TT (2 << 14) /* 2/3 power */
52# define PB1100_IRDA_OT (3<<14) /* 1/3 power */ 51# define PB1100_IRDA_OT (3 << 14) /* 1/3 power */
53# define PB1100_IRDA_FIR (1<<13) 52# define PB1100_IRDA_FIR (1 << 13)
54 53
55#define PCMCIA_BOARD_REG 0xAE000010 54#define PCMCIA_BOARD_REG 0xAE000010
56# define PB1100_SD_WP1_RO (1<<15) /* read only */ 55# define PB1100_SD_WP1_RO (1 << 15) /* read only */
57# define PB1100_SD_WP0_RO (1<<14) /* read only */ 56# define PB1100_SD_WP0_RO (1 << 14) /* read only */
58# define PB1100_SD_PWR1 (1<<11) /* applies power to SD1 */ 57# define PB1100_SD_PWR1 (1 << 11) /* applies power to SD1 */
59# define PB1100_SD_PWR0 (1<<10) /* applies power to SD0 */ 58# define PB1100_SD_PWR0 (1 << 10) /* applies power to SD0 */
60# define PB1100_SEL_SD_CONN1 (1<<9) 59# define PB1100_SEL_SD_CONN1 (1 << 9)
61# define PB1100_SEL_SD_CONN0 (1<<8) 60# define PB1100_SEL_SD_CONN0 (1 << 8)
62# define PC_DEASSERT_RST (1<<7) 61# define PC_DEASSERT_RST (1 << 7)
63# define PC_DRV_EN (1<<4) 62# define PC_DRV_EN (1 << 4)
64 63
65#define PB1100_G_CONTROL 0xAE000014 /* graphics control */ 64#define PB1100_G_CONTROL 0xAE000014 /* graphics control */
66 65
67#define PB1100_RST_VDDI 0xAE00001C 66#define PB1100_RST_VDDI 0xAE00001C
68# define PB1100_SOFT_RESET (1<<15) /* clear to reset the board */ 67# define PB1100_SOFT_RESET (1 << 15) /* clear to reset the board */
69# define PB1100_VDDI_MASK (0x1F) 68# define PB1100_VDDI_MASK 0x1F
70 69
71#define PB1100_LEDS 0xAE000018 70#define PB1100_LEDS 0xAE000018
72 71
73/* 11:8 is 4 discreet LEDs. Clearing a bit illuminates the LED. 72/*
74 * 7:0 is the LED Display's decimal points. 73 * 11:8 is 4 discreet LEDs. Clearing a bit illuminates the LED.
74 * 7:0 is the LED Display's decimal points.
75 */ 75 */
76#define PB1100_HEX_LED 0xAE000018 76#define PB1100_HEX_LED 0xAE000018
77 77
78/* PCMCIA PB1100 specific defines */ 78/* PCMCIA Pb1100 specific defines */
79#define PCMCIA_MAX_SOCK 0 79#define PCMCIA_MAX_SOCK 0
80#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) 80#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
81 81
82/* VPP/VCC */ 82/* VPP/VCC */
83#define SET_VCC_VPP(VCC, VPP) (((VCC)<<2) | ((VPP)<<0)) 83#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
84 84
85#endif /* __ASM_PB1100_H */ 85#endif /* __ASM_PB1100_H */
diff --git a/include/asm-mips/mach-pb1x00/pb1200.h b/include/asm-mips/mach-pb1x00/pb1200.h
index e2c6bcac3b42..c8618df88cb5 100644
--- a/include/asm-mips/mach-pb1x00/pb1200.h
+++ b/include/asm-mips/mach-pb1x00/pb1200.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * AMD Alchemy PB1200 Referrence Board 2 * AMD Alchemy Pb1200 Referrence Board
3 * Board Registers defines. 3 * Board Registers defines.
4 * 4 *
5 * ######################################################################## 5 * ########################################################################
@@ -27,21 +27,20 @@
27#include <linux/types.h> 27#include <linux/types.h>
28#include <asm/mach-au1x00/au1xxx_psc.h> 28#include <asm/mach-au1x00/au1xxx_psc.h>
29 29
30// This is defined in au1000.h with bogus value 30#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
31#undef AU1X00_EXTERNAL_INT 31#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
32#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX
33#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
32 34
33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX 35/*
34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX 36 * SPI and SMB are muxed on the Pb1200 board.
35#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC1_TX 37 * Refer to board documentation.
36#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC1_RX
37
38/* SPI and SMB are muxed on the Pb1200 board.
39 Refer to board documentation.
40 */ 38 */
41#define SPI_PSC_BASE PSC0_BASE_ADDR 39#define SPI_PSC_BASE PSC0_BASE_ADDR
42#define SMBUS_PSC_BASE PSC0_BASE_ADDR 40#define SMBUS_PSC_BASE PSC0_BASE_ADDR
43/* AC97 and I2S are muxed on the Pb1200 board. 41/*
44 Refer to board documentation. 42 * AC97 and I2S are muxed on the Pb1200 board.
43 * Refer to board documentation.
45 */ 44 */
46#define AC97_PSC_BASE PSC1_BASE_ADDR 45#define AC97_PSC_BASE PSC1_BASE_ADDR
47#define I2S_PSC_BASE PSC1_BASE_ADDR 46#define I2S_PSC_BASE PSC1_BASE_ADDR
@@ -102,10 +101,10 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
102#define BCSR_STATUS_SWAPBOOT 0x0040 101#define BCSR_STATUS_SWAPBOOT 0x0040
103#define BCSR_STATUS_FLASHBUSY 0x0100 102#define BCSR_STATUS_FLASHBUSY 0x0100
104#define BCSR_STATUS_IDECBLID 0x0200 103#define BCSR_STATUS_IDECBLID 0x0200
105#define BCSR_STATUS_SD0WP 0x0400 104#define BCSR_STATUS_SD0WP 0x0400
106#define BCSR_STATUS_SD1WP 0x0800 105#define BCSR_STATUS_SD1WP 0x0800
107#define BCSR_STATUS_U0RXD 0x1000 106#define BCSR_STATUS_U0RXD 0x1000
108#define BCSR_STATUS_U1RXD 0x2000 107#define BCSR_STATUS_U1RXD 0x2000
109 108
110#define BCSR_SWITCHES_OCTAL 0x00FF 109#define BCSR_SWITCHES_OCTAL 0x00FF
111#define BCSR_SWITCHES_DIP_1 0x0080 110#define BCSR_SWITCHES_DIP_1 0x0080
@@ -123,11 +122,11 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
123#define BCSR_RESETS_DC 0x0004 122#define BCSR_RESETS_DC 0x0004
124#define BCSR_RESETS_IDE 0x0008 123#define BCSR_RESETS_IDE 0x0008
125/* not resets but in the same register */ 124/* not resets but in the same register */
126#define BCSR_RESETS_WSCFSM 0x0800 125#define BCSR_RESETS_WSCFSM 0x0800
127#define BCSR_RESETS_PCS0MUX 0x1000 126#define BCSR_RESETS_PCS0MUX 0x1000
128#define BCSR_RESETS_PCS1MUX 0x2000 127#define BCSR_RESETS_PCS1MUX 0x2000
129#define BCSR_RESETS_SPISEL 0x4000 128#define BCSR_RESETS_SPISEL 0x4000
130#define BCSR_RESETS_SD1MUX 0x8000 129#define BCSR_RESETS_SD1MUX 0x8000
131 130
132#define BCSR_PCMCIA_PC0VPP 0x0003 131#define BCSR_PCMCIA_PC0VPP 0x0003
133#define BCSR_PCMCIA_PC0VCC 0x000C 132#define BCSR_PCMCIA_PC0VCC 0x000C
@@ -163,7 +162,7 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
163#define BCSR_INT_PC0STSCHG 0x0008 162#define BCSR_INT_PC0STSCHG 0x0008
164#define BCSR_INT_PC1 0x0010 163#define BCSR_INT_PC1 0x0010
165#define BCSR_INT_PC1STSCHG 0x0020 164#define BCSR_INT_PC1STSCHG 0x0020
166#define BCSR_INT_DC 0x0040 165#define BCSR_INT_DC 0x0040
167#define BCSR_INT_FLASHBUSY 0x0080 166#define BCSR_INT_FLASHBUSY 0x0080
168#define BCSR_INT_PC0INSERT 0x0100 167#define BCSR_INT_PC0INSERT 0x0100
169#define BCSR_INT_PC0EJECT 0x0200 168#define BCSR_INT_PC0EJECT 0x0200
@@ -174,14 +173,6 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
174#define BCSR_INT_SD1INSERT 0x4000 173#define BCSR_INT_SD1INSERT 0x4000
175#define BCSR_INT_SD1EJECT 0x8000 174#define BCSR_INT_SD1EJECT 0x8000
176 175
177/* PCMCIA Db1x00 specific defines */
178#define PCMCIA_MAX_SOCK 1
179#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1)
180
181/* VPP/VCC */
182#define SET_VCC_VPP(VCC, VPP, SLOT)\
183 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8))
184
185#define SMC91C111_PHYS_ADDR 0x0D000300 176#define SMC91C111_PHYS_ADDR 0x0D000300
186#define SMC91C111_INT PB1200_ETH_INT 177#define SMC91C111_INT PB1200_ETH_INT
187 178
@@ -192,18 +183,19 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
192#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1 183#define IDE_DDMA_REQ DSCR_CMD0_DMA_REQ1
193#define IDE_RQSIZE 128 184#define IDE_RQSIZE 128
194 185
195#define NAND_PHYS_ADDR 0x1C000000 186#define NAND_PHYS_ADDR 0x1C000000
196 187
197/* Timing values as described in databook, * ns value stripped of 188/*
189 * Timing values as described in databook, * ns value stripped of
198 * lower 2 bits. 190 * lower 2 bits.
199 * These defines are here rather than an SOC1200 generic file because 191 * These defines are here rather than an Au1200 generic file because
200 * the parts chosen on another board may be different and may require 192 * the parts chosen on another board may be different and may require
201 * different timings. 193 * different timings.
202 */ 194 */
203#define NAND_T_H (18 >> 2) 195#define NAND_T_H (18 >> 2)
204#define NAND_T_PUL (30 >> 2) 196#define NAND_T_PUL (30 >> 2)
205#define NAND_T_SU (30 >> 2) 197#define NAND_T_SU (30 >> 2)
206#define NAND_T_WH (30 >> 2) 198#define NAND_T_WH (30 >> 2)
207 199
208/* Bitfield shift amounts */ 200/* Bitfield shift amounts */
209#define NAND_T_H_SHIFT 0 201#define NAND_T_H_SHIFT 0
@@ -211,11 +203,10 @@ static BCSR * const bcsr = (BCSR *)BCSR_KSEG1_ADDR;
211#define NAND_T_SU_SHIFT 8 203#define NAND_T_SU_SHIFT 8
212#define NAND_T_WH_SHIFT 12 204#define NAND_T_WH_SHIFT 12
213 205
214#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ 206#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
215 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ 207 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
216 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ 208 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
217 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) 209 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
218
219 210
220/* 211/*
221 * External Interrupts for Pb1200 as of 8/6/2004. 212 * External Interrupts for Pb1200 as of 8/6/2004.
@@ -248,13 +239,21 @@ enum external_pb1200_ints {
248 PB1200_INT_END = PB1200_INT_BEGIN + 15 239 PB1200_INT_END = PB1200_INT_BEGIN + 15
249}; 240};
250 241
251/* For drivers/pcmcia/au1000_db1x00.c */ 242/*
252#define BOARD_PC0_INT PB1200_PC0_INT 243 * Pb1200 specific PCMCIA defines for drivers/pcmcia/au1000_db1x00.c
253#define BOARD_PC1_INT PB1200_PC1_INT 244 */
254#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1<<(8+(2*SOCKET))) 245#define PCMCIA_MAX_SOCK 1
246#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
255 247
256/* Nand chip select */ 248/* VPP/VCC */
249#define SET_VCC_VPP(VCC, VPP, SLOT) \
250 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
251
252#define BOARD_PC0_INT PB1200_PC0_INT
253#define BOARD_PC1_INT PB1200_PC1_INT
254#define BOARD_CARD_INSERTED(SOCKET) bcsr->sig_status & (1 << (8 + (2 * SOCKET)))
255
256/* NAND chip select */
257#define NAND_CS 1 257#define NAND_CS 1
258 258
259#endif /* __ASM_PB1200_H */ 259#endif /* __ASM_PB1200_H */
260
diff --git a/include/asm-mips/mach-pb1x00/pb1500.h b/include/asm-mips/mach-pb1x00/pb1500.h
index ff6d40c87a25..da51a2eb7b82 100644
--- a/include/asm-mips/mach-pb1x00/pb1500.h
+++ b/include/asm-mips/mach-pb1x00/pb1500.h
@@ -1,9 +1,8 @@
1/* 1/*
2 * Alchemy Semi PB1500 Referrence Board 2 * Alchemy Semi Pb1500 Referrence Board
3 * 3 *
4 * Copyright 2001 MontaVista Software Inc. 4 * Copyright 2001, 2008 MontaVista Software Inc.
5 * Author: MontaVista Software, Inc. 5 * Author: MontaVista Software, Inc. <source@mvista.com>
6 * ppopov@mvista.com or source@mvista.com
7 * 6 *
8 * ######################################################################## 7 * ########################################################################
9 * 8 *
@@ -27,25 +26,24 @@
27#ifndef __ASM_PB1500_H 26#ifndef __ASM_PB1500_H
28#define __ASM_PB1500_H 27#define __ASM_PB1500_H
29 28
29#define IDENT_BOARD_REG 0xAE000000
30#define BOARD_STATUS_REG 0xAE000004
31#define PCI_BOARD_REG 0xAE000010
32#define PCMCIA_BOARD_REG 0xAE000010
33# define PC_DEASSERT_RST 0x80
34# define PC_DRV_EN 0x10
35#define PB1500_G_CONTROL 0xAE000014
36#define PB1500_RST_VDDI 0xAE00001C
37#define PB1500_LEDS 0xAE000018
30 38
31#define IDENT_BOARD_REG 0xAE000000 39#define PB1500_HEX_LED 0xAF000004
32#define BOARD_STATUS_REG 0xAE000004 40#define PB1500_HEX_LED_BLANK 0xAF000008
33#define PCI_BOARD_REG 0xAE000010
34#define PCMCIA_BOARD_REG 0xAE000010
35 #define PC_DEASSERT_RST 0x80
36 #define PC_DRV_EN 0x10
37#define PB1500_G_CONTROL 0xAE000014
38#define PB1500_RST_VDDI 0xAE00001C
39#define PB1500_LEDS 0xAE000018
40 41
41#define PB1500_HEX_LED 0xAF000004 42/* PCMCIA Pb1500 specific defines */
42#define PB1500_HEX_LED_BLANK 0xAF000008 43#define PCMCIA_MAX_SOCK 0
43 44#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
44/* PCMCIA PB1500 specific defines */
45#define PCMCIA_MAX_SOCK 0
46#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1)
47 45
48/* VPP/VCC */ 46/* VPP/VCC */
49#define SET_VCC_VPP(VCC, VPP) (((VCC)<<2) | ((VPP)<<0)) 47#define SET_VCC_VPP(VCC, VPP) (((VCC) << 2) | ((VPP) << 0))
50 48
51#endif /* __ASM_PB1500_H */ 49#endif /* __ASM_PB1500_H */
diff --git a/include/asm-mips/mach-pb1x00/pb1550.h b/include/asm-mips/mach-pb1x00/pb1550.h
index c2ab0e2df4ae..6704a11497db 100644
--- a/include/asm-mips/mach-pb1x00/pb1550.h
+++ b/include/asm-mips/mach-pb1x00/pb1550.h
@@ -30,15 +30,15 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <asm/mach-au1x00/au1xxx_psc.h> 31#include <asm/mach-au1x00/au1xxx_psc.h>
32 32
33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX 33#define DBDMA_AC97_TX_CHAN DSCR_CMD0_PSC1_TX
34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX 34#define DBDMA_AC97_RX_CHAN DSCR_CMD0_PSC1_RX
35#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX 35#define DBDMA_I2S_TX_CHAN DSCR_CMD0_PSC3_TX
36#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX 36#define DBDMA_I2S_RX_CHAN DSCR_CMD0_PSC3_RX
37 37
38#define SPI_PSC_BASE PSC0_BASE_ADDR 38#define SPI_PSC_BASE PSC0_BASE_ADDR
39#define AC97_PSC_BASE PSC1_BASE_ADDR 39#define AC97_PSC_BASE PSC1_BASE_ADDR
40#define SMBUS_PSC_BASE PSC2_BASE_ADDR 40#define SMBUS_PSC_BASE PSC2_BASE_ADDR
41#define I2S_PSC_BASE PSC3_BASE_ADDR 41#define I2S_PSC_BASE PSC3_BASE_ADDR
42 42
43#define BCSR_PHYS_ADDR 0xAF000000 43#define BCSR_PHYS_ADDR 0xAF000000
44 44
@@ -129,12 +129,12 @@ static BCSR * const bcsr = (BCSR *)BCSR_PHYS_ADDR;
129#define BCSR_SYSTEM_POWEROFF 0x4000 129#define BCSR_SYSTEM_POWEROFF 0x4000
130#define BCSR_SYSTEM_RESET 0x8000 130#define BCSR_SYSTEM_RESET 0x8000
131 131
132#define PCMCIA_MAX_SOCK 1 132#define PCMCIA_MAX_SOCK 1
133#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK+1) 133#define PCMCIA_NUM_SOCKS (PCMCIA_MAX_SOCK + 1)
134 134
135/* VPP/VCC */ 135/* VPP/VCC */
136#define SET_VCC_VPP(VCC, VPP, SLOT)\ 136#define SET_VCC_VPP(VCC, VPP, SLOT) \
137 ((((VCC)<<2) | ((VPP)<<0)) << ((SLOT)*8)) 137 ((((VCC) << 2) | ((VPP) << 0)) << ((SLOT) * 8))
138 138
139#if defined(CONFIG_MTD_PB1550_BOOT) && defined(CONFIG_MTD_PB1550_USER) 139#if defined(CONFIG_MTD_PB1550_BOOT) && defined(CONFIG_MTD_PB1550_USER)
140#define PB1550_BOTH_BANKS 140#define PB1550_BOTH_BANKS
@@ -144,16 +144,17 @@ static BCSR * const bcsr = (BCSR *)BCSR_PHYS_ADDR;
144#define PB1550_USER_ONLY 144#define PB1550_USER_ONLY
145#endif 145#endif
146 146
147/* Timing values as described in databook, * ns value stripped of 147/*
148 * Timing values as described in databook, * ns value stripped of
148 * lower 2 bits. 149 * lower 2 bits.
149 * These defines are here rather than an SOC1550 generic file because 150 * These defines are here rather than an SOC1550 generic file because
150 * the parts chosen on another board may be different and may require 151 * the parts chosen on another board may be different and may require
151 * different timings. 152 * different timings.
152 */ 153 */
153#define NAND_T_H (18 >> 2) 154#define NAND_T_H (18 >> 2)
154#define NAND_T_PUL (30 >> 2) 155#define NAND_T_PUL (30 >> 2)
155#define NAND_T_SU (30 >> 2) 156#define NAND_T_SU (30 >> 2)
156#define NAND_T_WH (30 >> 2) 157#define NAND_T_WH (30 >> 2)
157 158
158/* Bitfield shift amounts */ 159/* Bitfield shift amounts */
159#define NAND_T_H_SHIFT 0 160#define NAND_T_H_SHIFT 0
@@ -161,16 +162,16 @@ static BCSR * const bcsr = (BCSR *)BCSR_PHYS_ADDR;
161#define NAND_T_SU_SHIFT 8 162#define NAND_T_SU_SHIFT 8
162#define NAND_T_WH_SHIFT 12 163#define NAND_T_WH_SHIFT 12
163 164
164#define NAND_TIMING ((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \ 165#define NAND_TIMING (((NAND_T_H & 0xF) << NAND_T_H_SHIFT) | \
165 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \ 166 ((NAND_T_PUL & 0xF) << NAND_T_PUL_SHIFT) | \
166 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \ 167 ((NAND_T_SU & 0xF) << NAND_T_SU_SHIFT) | \
167 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT) 168 ((NAND_T_WH & 0xF) << NAND_T_WH_SHIFT))
168 169
169#define NAND_CS 1 170#define NAND_CS 1
170 171
171/* should be done by yamon */ 172/* Should be done by YAMON */
172#define NAND_STCFG 0x00400005 /* 8-bit NAND */ 173#define NAND_STCFG 0x00400005 /* 8-bit NAND */
173#define NAND_STTIME 0x00007774 /* valid for 396MHz SD=2 only */ 174#define NAND_STTIME 0x00007774 /* valid for 396 MHz SD=2 only */
174#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */ 175#define NAND_STADDR 0x12000FFF /* physical address 0x20000000 */
175 176
176#endif /* __ASM_PB1550_H */ 177#endif /* __ASM_PB1550_H */
diff --git a/include/asm-mips/rtlx.h b/include/asm-mips/rtlx.h
index 65778c890a62..20b666022dcb 100644
--- a/include/asm-mips/rtlx.h
+++ b/include/asm-mips/rtlx.h
@@ -29,13 +29,13 @@ extern unsigned int rtlx_read_poll(int index, int can_sleep);
29extern unsigned int rtlx_write_poll(int index); 29extern unsigned int rtlx_write_poll(int index);
30 30
31enum rtlx_state { 31enum rtlx_state {
32 RTLX_STATE_UNUSED, 32 RTLX_STATE_UNUSED = 0,
33 RTLX_STATE_INITIALISED, 33 RTLX_STATE_INITIALISED,
34 RTLX_STATE_REMOTE_READY, 34 RTLX_STATE_REMOTE_READY,
35 RTLX_STATE_OPENED 35 RTLX_STATE_OPENED
36}; 36};
37 37
38#define RTLX_BUFFER_SIZE 1024 38#define RTLX_BUFFER_SIZE 2048
39 39
40/* each channel supports read and write. 40/* each channel supports read and write.
41 linux (vpe0) reads lx_buffer and writes rt_buffer 41 linux (vpe0) reads lx_buffer and writes rt_buffer
diff --git a/include/asm-mn10300/processor.h b/include/asm-mn10300/processor.h
index f1b081f53468..73239271873d 100644
--- a/include/asm-mn10300/processor.h
+++ b/include/asm-mn10300/processor.h
@@ -58,7 +58,7 @@ extern struct mn10300_cpuinfo boot_cpu_data;
58extern void identify_cpu(struct mn10300_cpuinfo *); 58extern void identify_cpu(struct mn10300_cpuinfo *);
59extern void print_cpu_info(struct mn10300_cpuinfo *); 59extern void print_cpu_info(struct mn10300_cpuinfo *);
60extern void dodgy_tsc(void); 60extern void dodgy_tsc(void);
61#define cpu_relax() do {} while (0) 61#define cpu_relax() barrier()
62 62
63/* 63/*
64 * User space process size: 1.75GB (default). 64 * User space process size: 1.75GB (default).
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index afae0697e8ce..e0062d73db1c 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -2,7 +2,7 @@
2#define _ASM_POWERPC_IO_H 2#define _ASM_POWERPC_IO_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5/* 5/*
6 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
@@ -18,6 +18,9 @@ extern int check_legacy_ioport(unsigned long base_port);
18#define _PNPWRP 0xa79 18#define _PNPWRP 0xa79
19#define PNPBIOS_BASE 0xf000 19#define PNPBIOS_BASE 0xf000
20 20
21#include <linux/device.h>
22#include <linux/io.h>
23
21#include <linux/compiler.h> 24#include <linux/compiler.h>
22#include <asm/page.h> 25#include <asm/page.h>
23#include <asm/byteorder.h> 26#include <asm/byteorder.h>
@@ -744,6 +747,9 @@ static inline void * bus_to_virt(unsigned long address)
744 747
745#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) 748#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
746 749
750void __iomem *devm_ioremap_prot(struct device *dev, resource_size_t offset,
751 size_t size, unsigned long flags);
752
747#endif /* __KERNEL__ */ 753#endif /* __KERNEL__ */
748 754
749#endif /* _ASM_POWERPC_IO_H */ 755#endif /* _ASM_POWERPC_IO_H */
diff --git a/include/asm-powerpc/pgtable-ppc32.h b/include/asm-powerpc/pgtable-ppc32.h
index 7c97b5a08d08..c08e714d0c42 100644
--- a/include/asm-powerpc/pgtable-ppc32.h
+++ b/include/asm-powerpc/pgtable-ppc32.h
@@ -209,6 +209,13 @@ extern int icache_44x_need_flush;
209 * 0 1 2 3 4 ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 209 * 0 1 2 3 4 ... 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
210 * - - - - - - U0 U1 U2 U3 W I M G E - UX UW UR SX SW SR 210 * - - - - - - U0 U1 U2 U3 W I M G E - UX UW UR SX SW SR
211 * 211 *
212 * Newer 440 cores (440x6 as used on AMCC 460EX/460GT) have additional
213 * TLB2 storage attibute fields. Those are:
214 *
215 * TLB2:
216 * 0...10 11 12 13 14 15 16...31
217 * no change WL1 IL1I IL1D IL2I IL2D no change
218 *
212 * There are some constrains and options, to decide mapping software bits 219 * There are some constrains and options, to decide mapping software bits
213 * into TLB entry. 220 * into TLB entry.
214 * 221 *
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index e3c845b0f764..6abead6e681a 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -100,6 +100,7 @@
100 100
101/* Flag indicating progress during context switch. */ 101/* Flag indicating progress during context switch. */
102#define SPU_CONTEXT_SWITCH_PENDING 0UL 102#define SPU_CONTEXT_SWITCH_PENDING 0UL
103#define SPU_CONTEXT_FAULT_PENDING 1UL
103 104
104struct spu_context; 105struct spu_context;
105struct spu_runqueue; 106struct spu_runqueue;
@@ -128,9 +129,11 @@ struct spu {
128 unsigned int irqs[3]; 129 unsigned int irqs[3];
129 u32 node; 130 u32 node;
130 u64 flags; 131 u64 flags;
131 u64 dar;
132 u64 dsisr;
133 u64 class_0_pending; 132 u64 class_0_pending;
133 u64 class_0_dar;
134 u64 class_0_dsisr;
135 u64 class_1_dar;
136 u64 class_1_dsisr;
134 size_t ls_size; 137 size_t ls_size;
135 unsigned int slb_replace; 138 unsigned int slb_replace;
136 struct mm_struct *mm; 139 struct mm_struct *mm;
@@ -143,7 +146,7 @@ struct spu {
143 146
144 void (* wbox_callback)(struct spu *spu); 147 void (* wbox_callback)(struct spu *spu);
145 void (* ibox_callback)(struct spu *spu); 148 void (* ibox_callback)(struct spu *spu);
146 void (* stop_callback)(struct spu *spu); 149 void (* stop_callback)(struct spu *spu, int irq);
147 void (* mfc_callback)(struct spu *spu); 150 void (* mfc_callback)(struct spu *spu);
148 151
149 char irq_c0[8]; 152 char irq_c0[8];
diff --git a/include/asm-powerpc/spu_csa.h b/include/asm-powerpc/spu_csa.h
index 0ab6bff86078..129ec148d451 100644
--- a/include/asm-powerpc/spu_csa.h
+++ b/include/asm-powerpc/spu_csa.h
@@ -254,7 +254,8 @@ struct spu_state {
254 u64 spu_chnldata_RW[32]; 254 u64 spu_chnldata_RW[32];
255 u32 spu_mailbox_data[4]; 255 u32 spu_mailbox_data[4];
256 u32 pu_mailbox_data[1]; 256 u32 pu_mailbox_data[1];
257 u64 dar, dsisr, class_0_pending; 257 u64 class_0_dar, class_0_dsisr, class_0_pending;
258 u64 class_1_dar, class_1_dsisr;
258 unsigned long suspend_time; 259 unsigned long suspend_time;
259 spinlock_t register_lock; 260 spinlock_t register_lock;
260}; 261};
diff --git a/include/asm-ppc/system.h b/include/asm-ppc/system.h
index 0593cb889d45..70ebd333c55b 100644
--- a/include/asm-ppc/system.h
+++ b/include/asm-ppc/system.h
@@ -178,7 +178,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
178 178
179} 179}
180 180
181extern inline void * xchg_ptr(void * m, void * val) 181static inline void * xchg_ptr(void * m, void * val)
182{ 182{
183 return (void *) xchg_u32(m, (unsigned long) val); 183 return (void *) xchg_u32(m, (unsigned long) val);
184} 184}
diff --git a/include/asm-s390/kvm_host.h b/include/asm-s390/kvm_host.h
index f8204a4f2e02..18cbd8a39796 100644
--- a/include/asm-s390/kvm_host.h
+++ b/include/asm-s390/kvm_host.h
@@ -104,6 +104,7 @@ struct sie_block {
104 104
105struct kvm_vcpu_stat { 105struct kvm_vcpu_stat {
106 u32 exit_userspace; 106 u32 exit_userspace;
107 u32 exit_null;
107 u32 exit_external_request; 108 u32 exit_external_request;
108 u32 exit_external_interrupt; 109 u32 exit_external_interrupt;
109 u32 exit_stop_request; 110 u32 exit_stop_request;
diff --git a/include/asm-s390/page.h b/include/asm-s390/page.h
index f0f4579eac13..12fd9c4f0f15 100644
--- a/include/asm-s390/page.h
+++ b/include/asm-s390/page.h
@@ -125,6 +125,17 @@ page_get_storage_key(unsigned long addr)
125 return skey; 125 return skey;
126} 126}
127 127
128#ifdef CONFIG_PAGE_STATES
129
130struct page;
131void arch_free_page(struct page *page, int order);
132void arch_alloc_page(struct page *page, int order);
133
134#define HAVE_ARCH_FREE_PAGE
135#define HAVE_ARCH_ALLOC_PAGE
136
137#endif
138
128#endif /* !__ASSEMBLY__ */ 139#endif /* !__ASSEMBLY__ */
129 140
130/* to align the pointer to the (next) page boundary */ 141/* to align the pointer to the (next) page boundary */
diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h
index 441d7c260857..d7d4e2eb3e6f 100644
--- a/include/asm-s390/ptrace.h
+++ b/include/asm-s390/ptrace.h
@@ -471,6 +471,8 @@ struct task_struct;
471extern void user_enable_single_step(struct task_struct *); 471extern void user_enable_single_step(struct task_struct *);
472extern void user_disable_single_step(struct task_struct *); 472extern void user_disable_single_step(struct task_struct *);
473 473
474#define __ARCH_WANT_COMPAT_SYS_PTRACE
475
474#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) 476#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
475#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN) 477#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
476#define regs_return_value(regs)((regs)->gprs[2]) 478#define regs_return_value(regs)((regs)->gprs[2])
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index c819ae25a842..e0d4500d5f95 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -116,6 +116,12 @@ extern void pfault_fini(void);
116#define pfault_fini() do { } while (0) 116#define pfault_fini() do { } while (0)
117#endif /* CONFIG_PFAULT */ 117#endif /* CONFIG_PFAULT */
118 118
119#ifdef CONFIG_PAGE_STATES
120extern void cmma_init(void);
121#else
122static inline void cmma_init(void) { }
123#endif
124
119#define finish_arch_switch(prev) do { \ 125#define finish_arch_switch(prev) do { \
120 set_fs(current->thread.mm_segment); \ 126 set_fs(current->thread.mm_segment); \
121 account_vtime(prev); \ 127 account_vtime(prev); \
diff --git a/include/asm-s390/types.h b/include/asm-s390/types.h
index 78dda038dd47..0e959e20e9a3 100644
--- a/include/asm-s390/types.h
+++ b/include/asm-s390/types.h
@@ -10,9 +10,9 @@
10#define _S390_TYPES_H 10#define _S390_TYPES_H
11 11
12#ifndef __s390x__ 12#ifndef __s390x__
13# include <asm-generic/int-l64.h>
14#else
15# include <asm-generic/int-ll64.h> 13# include <asm-generic/int-ll64.h>
14#else
15# include <asm-generic/int-l64.h>
16#endif 16#endif
17 17
18#ifndef __ASSEMBLY__ 18#ifndef __ASSEMBLY__
diff --git a/include/asm-sh/cpu-sh3/dma.h b/include/asm-sh/cpu-sh3/dma.h
index 092ff9d872c3..6813c3220a1d 100644
--- a/include/asm-sh/cpu-sh3/dma.h
+++ b/include/asm-sh/cpu-sh3/dma.h
@@ -3,19 +3,19 @@
3 3
4 4
5#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \ 5#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
6 defined(CONFIG_CPU_SUBTYPE_SH7721) || \ 6 defined(CONFIG_CPU_SUBTYPE_SH7721)
7 defined(CONFIG_CPU_SUBTYPE_SH7709)
8#define SH_DMAC_BASE 0xa4010020 7#define SH_DMAC_BASE 0xa4010020
8#else
9#define SH_DMAC_BASE 0xa4000020
10#endif
9 11
12#if defined(CONFIG_CPU_SUBTYPE_SH7720) || defined(CONFIG_CPU_SUBTYPE_SH7709)
10#define DMTE0_IRQ 48 13#define DMTE0_IRQ 48
11#define DMTE1_IRQ 49 14#define DMTE1_IRQ 49
12#define DMTE2_IRQ 50 15#define DMTE2_IRQ 50
13#define DMTE3_IRQ 51 16#define DMTE3_IRQ 51
14#define DMTE4_IRQ 76 17#define DMTE4_IRQ 76
15#define DMTE5_IRQ 77 18#define DMTE5_IRQ 77
16
17#else
18#define SH_DMAC_BASE 0xa4000020
19#endif 19#endif
20 20
21/* Definitions for the SuperH DMAC */ 21/* Definitions for the SuperH DMAC */
diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h
index c958fdaa0095..7438d1e21bc9 100644
--- a/include/asm-sh/hw_irq.h
+++ b/include/asm-sh/hw_irq.h
@@ -79,6 +79,10 @@ struct intc_desc {
79 struct intc_sense_reg *sense_regs; 79 struct intc_sense_reg *sense_regs;
80 unsigned int nr_sense_regs; 80 unsigned int nr_sense_regs;
81 char *name; 81 char *name;
82#ifdef CONFIG_CPU_SH3
83 struct intc_mask_reg *ack_regs;
84 unsigned int nr_ack_regs;
85#endif
82}; 86};
83 87
84#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) 88#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
@@ -91,10 +95,25 @@ struct intc_desc symbol __initdata = { \
91 chipname, \ 95 chipname, \
92} 96}
93 97
98#ifdef CONFIG_CPU_SH3
99#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
100 mask_regs, prio_regs, sense_regs, ack_regs) \
101struct intc_desc symbol __initdata = { \
102 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
103 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
104 _INTC_ARRAY(sense_regs), \
105 chipname, \
106 _INTC_ARRAY(ack_regs), \
107}
108#endif
109
94void __init register_intc_controller(struct intc_desc *desc); 110void __init register_intc_controller(struct intc_desc *desc);
95int intc_set_priority(unsigned int irq, unsigned int prio); 111int intc_set_priority(unsigned int irq, unsigned int prio);
96 112
97void __init plat_irq_setup(void); 113void __init plat_irq_setup(void);
114#ifdef CONFIG_CPU_SH3
115void __init plat_irq_setup_sh3(void);
116#endif
98 117
99enum { IRQ_MODE_IRQ, IRQ_MODE_IRQ7654, IRQ_MODE_IRQ3210, 118enum { IRQ_MODE_IRQ, IRQ_MODE_IRQ7654, IRQ_MODE_IRQ3210,
100 IRQ_MODE_IRL7654_MASK, IRQ_MODE_IRL3210_MASK, 119 IRQ_MODE_IRL7654_MASK, IRQ_MODE_IRL3210_MASK,
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index 356e50d06745..a4fbf0c84fb1 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -268,11 +268,6 @@ unsigned long long peek_real_address_q(unsigned long long addr);
268unsigned long long poke_real_address_q(unsigned long long addr, 268unsigned long long poke_real_address_q(unsigned long long addr,
269 unsigned long long val); 269 unsigned long long val);
270 270
271/* arch/sh/mm/ioremap_64.c */
272unsigned long onchip_remap(unsigned long addr, unsigned long size,
273 const char *name);
274extern void onchip_unmap(unsigned long vaddr);
275
276#if !defined(CONFIG_MMU) 271#if !defined(CONFIG_MMU)
277#define virt_to_phys(address) ((unsigned long)(address)) 272#define virt_to_phys(address) ((unsigned long)(address))
278#define phys_to_virt(address) ((void *)(address)) 273#define phys_to_virt(address) ((void *)(address))
@@ -302,9 +297,16 @@ extern void onchip_unmap(unsigned long vaddr);
302void __iomem *__ioremap(unsigned long offset, unsigned long size, 297void __iomem *__ioremap(unsigned long offset, unsigned long size,
303 unsigned long flags); 298 unsigned long flags);
304void __iounmap(void __iomem *addr); 299void __iounmap(void __iomem *addr);
300
301/* arch/sh/mm/ioremap_64.c */
302unsigned long onchip_remap(unsigned long addr, unsigned long size,
303 const char *name);
304extern void onchip_unmap(unsigned long vaddr);
305#else 305#else
306#define __ioremap(offset, size, flags) ((void __iomem *)(offset)) 306#define __ioremap(offset, size, flags) ((void __iomem *)(offset))
307#define __iounmap(addr) do { } while (0) 307#define __iounmap(addr) do { } while (0)
308#define onchip_remap(addr, size, name) (addr)
309#define onchip_unmap(addr) do { } while (0)
308#endif /* CONFIG_MMU */ 310#endif /* CONFIG_MMU */
309 311
310static inline void __iomem * 312static inline void __iomem *
diff --git a/include/asm-sh/keyboard.h b/include/asm-sh/keyboard.h
deleted file mode 100644
index 31dcc4fa5f28..000000000000
--- a/include/asm-sh/keyboard.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __ASM_SH_KEYBOARD_H
2#define __ASM_SH_KEYBOARD_H
3/*
4 * $Id: keyboard.h,v 1.1.1.1 2001/10/15 20:45:09 mrbrown Exp $
5 */
6
7#include <linux/kd.h>
8#include <asm/machvec.h>
9
10#ifdef CONFIG_SH_MPC1211
11#include <asm/mpc1211/keyboard-mpc1211.h>
12#endif
13#endif
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index fe58d00b250c..87e812f68bb0 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -27,6 +27,7 @@
27/* ASID is 8-bit value, so it can't be 0x100 */ 27/* ASID is 8-bit value, so it can't be 0x100 */
28#define MMU_NO_ASID 0x100 28#define MMU_NO_ASID 0x100
29 29
30#ifdef CONFIG_MMU
30#define asid_cache(cpu) (cpu_data[cpu].asid_cache) 31#define asid_cache(cpu) (cpu_data[cpu].asid_cache)
31#define cpu_context(cpu, mm) ((mm)->context.id[cpu]) 32#define cpu_context(cpu, mm) ((mm)->context.id[cpu])
32 33
@@ -38,7 +39,6 @@
38 */ 39 */
39#define MMU_VPN_MASK 0xfffff000 40#define MMU_VPN_MASK 0xfffff000
40 41
41#ifdef CONFIG_MMU
42#if defined(CONFIG_SUPERH32) 42#if defined(CONFIG_SUPERH32)
43#include "mmu_context_32.h" 43#include "mmu_context_32.h"
44#else 44#else
@@ -129,6 +129,8 @@ static inline void switch_mm(struct mm_struct *prev,
129#define destroy_context(mm) do { } while (0) 129#define destroy_context(mm) do { } while (0)
130#define set_asid(asid) do { } while (0) 130#define set_asid(asid) do { } while (0)
131#define get_asid() (0) 131#define get_asid() (0)
132#define cpu_asid(cpu, mm) ({ (void)cpu; 0; })
133#define switch_and_save_asid(asid) (0)
132#define set_TTB(pgd) do { } while (0) 134#define set_TTB(pgd) do { } while (0)
133#define get_TTB() (0) 135#define get_TTB() (0)
134#define activate_context(mm,cpu) do { } while (0) 136#define activate_context(mm,cpu) do { } while (0)
diff --git a/include/asm-sh/mmzone.h b/include/asm-sh/mmzone.h
index 7969f381dff2..2969253c4042 100644
--- a/include/asm-sh/mmzone.h
+++ b/include/asm-sh/mmzone.h
@@ -41,6 +41,8 @@ void __init plat_mem_setup(void);
41 41
42/* arch/sh/kernel/setup.c */ 42/* arch/sh/kernel/setup.c */
43void __init setup_bootmem_allocator(unsigned long start_pfn); 43void __init setup_bootmem_allocator(unsigned long start_pfn);
44void __init __add_active_range(unsigned int nid, unsigned long start_pfn,
45 unsigned long end_pfn);
44 46
45#endif /* __KERNEL__ */ 47#endif /* __KERNEL__ */
46#endif /* __ASM_SH_MMZONE_H */ 48#endif /* __ASM_SH_MMZONE_H */
diff --git a/include/asm-sh/mpc1211/dma.h b/include/asm-sh/mpc1211/dma.h
deleted file mode 100644
index e506d1aaa0d0..000000000000
--- a/include/asm-sh/mpc1211/dma.h
+++ /dev/null
@@ -1,303 +0,0 @@
1/* $Id: dma.h,v 1.7 1992/12/14 00:29:34 root Exp root $
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 */
7
8#ifndef _ASM_MPC1211_DMA_H
9#define _ASM_MPC1211_DMA_H
10
11#include <linux/spinlock.h> /* And spinlocks */
12#include <asm/io.h> /* need byte IO */
13#include <linux/delay.h>
14
15
16#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
17#define dma_outb outb_p
18#else
19#define dma_outb outb
20#endif
21
22#define dma_inb inb
23
24/*
25 * NOTES about DMA transfers:
26 *
27 * controller 1: channels 0-3, byte operations, ports 00-1F
28 * controller 2: channels 4-7, word operations, ports C0-DF
29 *
30 * - ALL registers are 8 bits only, regardless of transfer size
31 * - channel 4 is not used - cascades 1 into 2.
32 * - channels 0-3 are byte - addresses/counts are for physical bytes
33 * - channels 5-7 are word - addresses/counts are for physical words
34 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
35 * - transfer count loaded to registers is 1 less than actual count
36 * - controller 2 offsets are all even (2x offsets for controller 1)
37 * - page registers for 5-7 don't use data bit 0, represent 128K pages
38 * - page registers for 0-3 use bit 0, represent 64K pages
39 *
40 * DMA transfers are limited to the lower 16MB of _physical_ memory.
41 * Note that addresses loaded into registers must be _physical_ addresses,
42 * not logical addresses (which may differ if paging is active).
43 *
44 * Address mapping for channels 0-3:
45 *
46 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
47 * | ... | | ... | | ... |
48 * | ... | | ... | | ... |
49 * | ... | | ... | | ... |
50 * P7 ... P0 A7 ... A0 A7 ... A0
51 * | Page | Addr MSB | Addr LSB | (DMA registers)
52 *
53 * Address mapping for channels 5-7:
54 *
55 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
56 * | ... | \ \ ... \ \ \ ... \ \
57 * | ... | \ \ ... \ \ \ ... \ (not used)
58 * | ... | \ \ ... \ \ \ ... \
59 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
60 * | Page | Addr MSB | Addr LSB | (DMA registers)
61 *
62 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
63 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
64 * the hardware level, so odd-byte transfers aren't possible).
65 *
66 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
67 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
68 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
69 *
70 */
71
72#define MAX_DMA_CHANNELS 8
73
74/* The maximum address that we can perform a DMA transfer to on this platform */
75#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x10000000)
76
77/* 8237 DMA controllers */
78#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
79#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
80
81/* DMA controller registers */
82#define DMA1_CMD_REG 0x08 /* command register (w) */
83#define DMA1_STAT_REG 0x08 /* status register (r) */
84#define DMA1_REQ_REG 0x09 /* request register (w) */
85#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
86#define DMA1_MODE_REG 0x0B /* mode register (w) */
87#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
88#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
89#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
90#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
91#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
92
93#define DMA2_CMD_REG 0xD0 /* command register (w) */
94#define DMA2_STAT_REG 0xD0 /* status register (r) */
95#define DMA2_REQ_REG 0xD2 /* request register (w) */
96#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
97#define DMA2_MODE_REG 0xD6 /* mode register (w) */
98#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
99#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
100#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
101#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
102#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
103
104#define DMA_ADDR_0 0x00 /* DMA address registers */
105#define DMA_ADDR_1 0x02
106#define DMA_ADDR_2 0x04
107#define DMA_ADDR_3 0x06
108#define DMA_ADDR_4 0xC0
109#define DMA_ADDR_5 0xC4
110#define DMA_ADDR_6 0xC8
111#define DMA_ADDR_7 0xCC
112
113#define DMA_CNT_0 0x01 /* DMA count registers */
114#define DMA_CNT_1 0x03
115#define DMA_CNT_2 0x05
116#define DMA_CNT_3 0x07
117#define DMA_CNT_4 0xC2
118#define DMA_CNT_5 0xC6
119#define DMA_CNT_6 0xCA
120#define DMA_CNT_7 0xCE
121
122#define DMA_PAGE_0 0x87 /* DMA page registers */
123#define DMA_PAGE_1 0x83
124#define DMA_PAGE_2 0x81
125#define DMA_PAGE_3 0x82
126#define DMA_PAGE_5 0x8B
127#define DMA_PAGE_6 0x89
128#define DMA_PAGE_7 0x8A
129
130#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
131#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
132#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
133
134#define DMA_AUTOINIT 0x10
135
136
137extern spinlock_t dma_spin_lock;
138
139static __inline__ unsigned long claim_dma_lock(void)
140{
141 unsigned long flags;
142 spin_lock_irqsave(&dma_spin_lock, flags);
143 return flags;
144}
145
146static __inline__ void release_dma_lock(unsigned long flags)
147{
148 spin_unlock_irqrestore(&dma_spin_lock, flags);
149}
150
151/* enable/disable a specific DMA channel */
152static __inline__ void enable_dma(unsigned int dmanr)
153{
154 if (dmanr<=3)
155 dma_outb(dmanr, DMA1_MASK_REG);
156 else
157 dma_outb(dmanr & 3, DMA2_MASK_REG);
158}
159
160static __inline__ void disable_dma(unsigned int dmanr)
161{
162 if (dmanr<=3)
163 dma_outb(dmanr | 4, DMA1_MASK_REG);
164 else
165 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
166}
167
168/* Clear the 'DMA Pointer Flip Flop'.
169 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
170 * Use this once to initialize the FF to a known state.
171 * After that, keep track of it. :-)
172 * --- In order to do that, the DMA routines below should ---
173 * --- only be used while holding the DMA lock ! ---
174 */
175static __inline__ void clear_dma_ff(unsigned int dmanr)
176{
177 if (dmanr<=3)
178 dma_outb(0, DMA1_CLEAR_FF_REG);
179 else
180 dma_outb(0, DMA2_CLEAR_FF_REG);
181}
182
183/* set mode (above) for a specific DMA channel */
184static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
185{
186 if (dmanr<=3)
187 dma_outb(mode | dmanr, DMA1_MODE_REG);
188 else
189 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
190}
191
192/* Set only the page register bits of the transfer address.
193 * This is used for successive transfers when we know the contents of
194 * the lower 16 bits of the DMA current address register, but a 64k boundary
195 * may have been crossed.
196 */
197static __inline__ void set_dma_page(unsigned int dmanr, unsigned int pagenr)
198{
199 switch(dmanr) {
200 case 0:
201 dma_outb( pagenr & 0xff, DMA_PAGE_0);
202 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_0 + 0x400);
203 break;
204 case 1:
205 dma_outb( pagenr & 0xff, DMA_PAGE_1);
206 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_1 + 0x400);
207 break;
208 case 2:
209 dma_outb( pagenr & 0xff, DMA_PAGE_2);
210 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_2 + 0x400);
211 break;
212 case 3:
213 dma_outb( pagenr & 0xff, DMA_PAGE_3);
214 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_3 + 0x400);
215 break;
216 case 5:
217 dma_outb( pagenr & 0xfe, DMA_PAGE_5);
218 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_5 + 0x400);
219 break;
220 case 6:
221 dma_outb( pagenr & 0xfe, DMA_PAGE_6);
222 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_6 + 0x400);
223 break;
224 case 7:
225 dma_outb( pagenr & 0xfe, DMA_PAGE_7);
226 dma_outb((pagenr >> 8) & 0xff, DMA_PAGE_7 + 0x400);
227 break;
228 }
229}
230
231
232/* Set transfer address & page bits for specific DMA channel.
233 * Assumes dma flipflop is clear.
234 */
235static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
236{
237 set_dma_page(dmanr, a>>16);
238 if (dmanr <= 3) {
239 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
240 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
241 } else {
242 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
243 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
244 }
245}
246
247
248/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
249 * a specific DMA channel.
250 * You must ensure the parameters are valid.
251 * NOTE: from a manual: "the number of transfers is one more
252 * than the initial word count"! This is taken into account.
253 * Assumes dma flip-flop is clear.
254 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
255 */
256static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
257{
258 count--;
259 if (dmanr <= 3) {
260 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
261 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
262 } else {
263 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
264 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
265 }
266}
267
268
269/* Get DMA residue count. After a DMA transfer, this
270 * should return zero. Reading this while a DMA transfer is
271 * still in progress will return unpredictable results.
272 * If called before the channel has been used, it may return 1.
273 * Otherwise, it returns the number of _bytes_ left to transfer.
274 *
275 * Assumes DMA flip-flop is clear.
276 */
277static __inline__ int get_dma_residue(unsigned int dmanr)
278{
279 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
280 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
281
282 /* using short to get 16-bit wrap around */
283 unsigned short count;
284
285 count = 1 + dma_inb(io_port);
286 count += dma_inb(io_port) << 8;
287 return (dmanr<=3)? count : (count<<1);
288}
289
290
291/* These are in kernel/dma.c: */
292extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
293extern void free_dma(unsigned int dmanr); /* release it again */
294
295/* From PCI */
296
297#ifdef CONFIG_PCI
298extern int isa_dma_bridge_buggy;
299#else
300#define isa_dma_bridge_buggy (0)
301#endif
302
303#endif /* _ASM_MPC1211_DMA_H */
diff --git a/include/asm-sh/mpc1211/io.h b/include/asm-sh/mpc1211/io.h
deleted file mode 100644
index 6298370bec2d..000000000000
--- a/include/asm-sh/mpc1211/io.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * include/asm-sh/mpc1211/io.h
3 *
4 * Copyright 2001 Saito.K & Jeanne
5 *
6 * IO functions for an Interface MPC-1211
7 */
8
9#ifndef _ASM_SH_IO_MPC1211_H
10#define _ASM_SH_IO_MPC1211_H
11
12#include <linux/time.h>
13
14extern int mpc1211_irq_demux(int irq);
15
16extern void init_mpc1211_IRQ(void);
17extern void heartbeat_mpc1211(void);
18
19extern void mpc1211_rtc_gettimeofday(struct timeval *tv);
20extern int mpc1211_rtc_settimeofday(const struct timeval *tv);
21
22#endif /* _ASM_SH_IO_MPC1211_H */
diff --git a/include/asm-sh/mpc1211/keyboard.h b/include/asm-sh/mpc1211/keyboard.h
deleted file mode 100644
index 9020feee7b4c..000000000000
--- a/include/asm-sh/mpc1211/keyboard.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/*
2 * MPC1211 specific keybord definitions
3 * Taken from the old asm-i386/keybord.h for PC/AT-style definitions
4 * created 3 Nov 1996 by Geert Uytterhoeven.
5 */
6
7#ifdef __KERNEL__
8
9#include <linux/kernel.h>
10#include <linux/ioport.h>
11#include <linux/kd.h>
12#include <linux/pm.h>
13#include <asm/io.h>
14
15#define KEYBOARD_IRQ 1
16#define DISABLE_KBD_DURING_INTERRUPTS 0
17
18extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
19extern int pckbd_getkeycode(unsigned int scancode);
20extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
21 char raw_mode);
22extern char pckbd_unexpected_up(unsigned char keycode);
23extern void pckbd_leds(unsigned char leds);
24extern void pckbd_init_hw(void);
25extern int pckbd_pm_resume(struct pm_dev *, pm_request_t, void *);
26extern pm_callback pm_kbd_request_override;
27
28#define kbd_setkeycode pckbd_setkeycode
29#define kbd_getkeycode pckbd_getkeycode
30#define kbd_translate pckbd_translate
31#define kbd_unexpected_up pckbd_unexpected_up
32#define kbd_leds pckbd_leds
33#define kbd_init_hw pckbd_init_hw
34
35/* resource allocation */
36#define kbd_request_region()
37#define kbd_request_irq(handler) request_irq(KEYBOARD_IRQ, handler, 0, \
38 "keyboard", NULL)
39
40/* How to access the keyboard macros on this platform. */
41#define kbd_read_input() inb(KBD_DATA_REG)
42#define kbd_read_status() inb(KBD_STATUS_REG)
43#define kbd_write_output(val) outb(val, KBD_DATA_REG)
44#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
45
46/* Some stoneage hardware needs delays after some operations. */
47#define kbd_pause() do { } while(0)
48
49/*
50 * Machine specific bits for the PS/2 driver
51 */
52
53#define AUX_IRQ 12
54
55#define aux_request_irq(hand, dev_id) \
56 request_irq(AUX_IRQ, hand, IRQF_SHARED, "PS2 Mouse", dev_id)
57
58#define aux_free_irq(dev_id) free_irq(AUX_IRQ, dev_id)
59
60#endif /* __KERNEL__ */
diff --git a/include/asm-sh/mpc1211/m1543c.h b/include/asm-sh/mpc1211/m1543c.h
deleted file mode 100644
index c95d13236c3b..000000000000
--- a/include/asm-sh/mpc1211/m1543c.h
+++ /dev/null
@@ -1,200 +0,0 @@
1#ifndef __ASM_SH_M1543C_H
2#define __ASM_SH_M1543C_H
3
4/*
5 * linux/include/asm-sh/m1543c.h
6 * Copyright (C) 2001 Nobuhiro Sakawa
7 * M1543C:PCI-ISA Bus Bridge with Super IO Chip support
8 *
9 * from
10 *
11 * linux/include/asm-sh/smc37c93x.h
12 *
13 * Copyright (C) 2000 Kazumoto Kojima
14 *
15 * SMSC 37C93x Super IO Chip support
16 */
17
18/* Default base I/O address */
19#define FDC_PRIMARY_BASE 0x3f0
20#define IDE1_PRIMARY_BASE 0x1f0
21#define IDE1_SECONDARY_BASE 0x170
22#define PARPORT_PRIMARY_BASE 0x378
23#define COM1_PRIMARY_BASE 0x2f8
24#define COM2_PRIMARY_BASE 0x3f8
25#define COM3_PRIMARY_BASE 0x3e8
26#define RTC_PRIMARY_BASE 0x070
27#define KBC_PRIMARY_BASE 0x060
28#define AUXIO_PRIMARY_BASE 0x000 /* XXX */
29#define I8259_M_CR 0x20
30#define I8259_M_MR 0x21
31#define I8259_S_CR 0xa0
32#define I8259_S_MR 0xa1
33
34/* Logical device number */
35#define LDN_FDC 0
36#define LDN_IDE1 1
37#define LDN_IDE2 2
38#define LDN_PARPORT 3
39#define LDN_COM1 4
40#define LDN_COM2 5
41#define LDN_COM3 11
42#define LDN_RTC 6
43#define LDN_KBC 7
44
45/* Configuration port and key */
46#define CONFIG_PORT 0x3f0
47#define INDEX_PORT CONFIG_PORT
48#define DATA_PORT 0x3f1
49#define CONFIG_ENTER1 0x51
50#define CONFIG_ENTER2 0x23
51#define CONFIG_EXIT 0xbb
52
53/* Configuration index */
54#define CURRENT_LDN_INDEX 0x07
55#define POWER_CONTROL_INDEX 0x22
56#define ACTIVATE_INDEX 0x30
57#define IO_BASE_HI_INDEX 0x60
58#define IO_BASE_LO_INDEX 0x61
59#define IRQ_SELECT_INDEX 0x70
60#define PS2_IRQ_INDEX 0x72
61#define DMA_SELECT_INDEX 0x74
62
63/* UART stuff. Only for debugging. */
64/* UART Register */
65
66#define UART_RBR 0x0 /* Receiver Buffer Register (Read Only) */
67#define UART_THR 0x0 /* Transmitter Holding Register (Write Only) */
68#define UART_IER 0x2 /* Interrupt Enable Register */
69#define UART_IIR 0x4 /* Interrupt Ident Register (Read Only) */
70#define UART_FCR 0x4 /* FIFO Control Register (Write Only) */
71#define UART_LCR 0x6 /* Line Control Register */
72#define UART_MCR 0x8 /* MODEM Control Register */
73#define UART_LSR 0xa /* Line Status Register */
74#define UART_MSR 0xc /* MODEM Status Register */
75#define UART_SCR 0xe /* Scratch Register */
76#define UART_DLL 0x0 /* Divisor Latch (LS) */
77#define UART_DLM 0x2 /* Divisor Latch (MS) */
78
79#ifndef __ASSEMBLY__
80typedef struct uart_reg {
81 volatile __u16 rbr;
82 volatile __u16 ier;
83 volatile __u16 iir;
84 volatile __u16 lcr;
85 volatile __u16 mcr;
86 volatile __u16 lsr;
87 volatile __u16 msr;
88 volatile __u16 scr;
89} uart_reg;
90#endif /* ! __ASSEMBLY__ */
91
92/* Alias for Write Only Register */
93
94#define thr rbr
95#define tcr iir
96
97/* Alias for Divisor Latch Register */
98
99#define dll rbr
100#define dlm ier
101#define fcr iir
102
103/* Interrupt Enable Register */
104
105#define IER_ERDAI 0x0100 /* Enable Received Data Available Interrupt */
106#define IER_ETHREI 0x0200 /* Enable Transmitter Holding Register Empty Interrupt */
107#define IER_ELSI 0x0400 /* Enable Receiver Line Status Interrupt */
108#define IER_EMSI 0x0800 /* Enable MODEM Status Interrupt */
109
110/* Interrupt Ident Register */
111
112#define IIR_IP 0x0100 /* "0" if Interrupt Pending */
113#define IIR_IIB0 0x0200 /* Interrupt ID Bit 0 */
114#define IIR_IIB1 0x0400 /* Interrupt ID Bit 1 */
115#define IIR_IIB2 0x0800 /* Interrupt ID Bit 2 */
116#define IIR_FIFO 0xc000 /* FIFOs enabled */
117
118/* FIFO Control Register */
119
120#define FCR_FEN 0x0100 /* FIFO enable */
121#define FCR_RFRES 0x0200 /* Receiver FIFO reset */
122#define FCR_TFRES 0x0400 /* Transmitter FIFO reset */
123#define FCR_DMA 0x0800 /* DMA mode select */
124#define FCR_RTL 0x4000 /* Receiver triger (LSB) */
125#define FCR_RTM 0x8000 /* Receiver triger (MSB) */
126
127/* Line Control Register */
128
129#define LCR_WLS0 0x0100 /* Word Length Select Bit 0 */
130#define LCR_WLS1 0x0200 /* Word Length Select Bit 1 */
131#define LCR_STB 0x0400 /* Number of Stop Bits */
132#define LCR_PEN 0x0800 /* Parity Enable */
133#define LCR_EPS 0x1000 /* Even Parity Select */
134#define LCR_SP 0x2000 /* Stick Parity */
135#define LCR_SB 0x4000 /* Set Break */
136#define LCR_DLAB 0x8000 /* Divisor Latch Access Bit */
137
138/* MODEM Control Register */
139
140#define MCR_DTR 0x0100 /* Data Terminal Ready */
141#define MCR_RTS 0x0200 /* Request to Send */
142#define MCR_OUT1 0x0400 /* Out 1 */
143#define MCR_IRQEN 0x0800 /* IRQ Enable */
144#define MCR_LOOP 0x1000 /* Loop */
145
146/* Line Status Register */
147
148#define LSR_DR 0x0100 /* Data Ready */
149#define LSR_OE 0x0200 /* Overrun Error */
150#define LSR_PE 0x0400 /* Parity Error */
151#define LSR_FE 0x0800 /* Framing Error */
152#define LSR_BI 0x1000 /* Break Interrupt */
153#define LSR_THRE 0x2000 /* Transmitter Holding Register Empty */
154#define LSR_TEMT 0x4000 /* Transmitter Empty */
155#define LSR_FIFOE 0x8000 /* Receiver FIFO error */
156
157/* MODEM Status Register */
158
159#define MSR_DCTS 0x0100 /* Delta Clear to Send */
160#define MSR_DDSR 0x0200 /* Delta Data Set Ready */
161#define MSR_TERI 0x0400 /* Trailing Edge Ring Indicator */
162#define MSR_DDCD 0x0800 /* Delta Data Carrier Detect */
163#define MSR_CTS 0x1000 /* Clear to Send */
164#define MSR_DSR 0x2000 /* Data Set Ready */
165#define MSR_RI 0x4000 /* Ring Indicator */
166#define MSR_DCD 0x8000 /* Data Carrier Detect */
167
168/* Baud Rate Divisor */
169
170#define UART_CLK (1843200) /* 1.8432 MHz */
171#define UART_BAUD(x) (UART_CLK / (16 * (x)))
172
173/* RTC register definition */
174#define RTC_SECONDS 0
175#define RTC_SECONDS_ALARM 1
176#define RTC_MINUTES 2
177#define RTC_MINUTES_ALARM 3
178#define RTC_HOURS 4
179#define RTC_HOURS_ALARM 5
180#define RTC_DAY_OF_WEEK 6
181#define RTC_DAY_OF_MONTH 7
182#define RTC_MONTH 8
183#define RTC_YEAR 9
184#define RTC_FREQ_SELECT 10
185# define RTC_UIP 0x80
186# define RTC_DIV_CTL 0x70
187/* This RTC can work under 32.768KHz clock only. */
188# define RTC_OSC_ENABLE 0x20
189# define RTC_OSC_DISABLE 0x00
190#define RTC_CONTROL 11
191# define RTC_SET 0x80
192# define RTC_PIE 0x40
193# define RTC_AIE 0x20
194# define RTC_UIE 0x10
195# define RTC_SQWE 0x08
196# define RTC_DM_BINARY 0x04
197# define RTC_24H 0x02
198# define RTC_DST_EN 0x01
199
200#endif /* __ASM_SH_M1543C_H */
diff --git a/include/asm-sh/mpc1211/mc146818rtc.h b/include/asm-sh/mpc1211/mc146818rtc.h
deleted file mode 100644
index e245f2a3cd78..000000000000
--- a/include/asm-sh/mpc1211/mc146818rtc.h
+++ /dev/null
@@ -1,6 +0,0 @@
1/*
2 * MPC1211 uses PC/AT style RTC definitions.
3 */
4#include <asm-x86/mc146818rtc_32.h>
5
6
diff --git a/include/asm-sh/mpc1211/mpc1211.h b/include/asm-sh/mpc1211/mpc1211.h
deleted file mode 100644
index fa456c3e4e01..000000000000
--- a/include/asm-sh/mpc1211/mpc1211.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef __ASM_SH_MPC1211_H
2#define __ASM_SH_MPC1211_H
3
4/*
5 * linux/include/asm-sh/mpc1211.h
6 *
7 * Copyright (C) 2001 Saito.K & Jeanne
8 *
9 * Interface MPC-1211 support
10 */
11
12#define PA_PCI_IO (0xa4000000) /* PCI I/O space */
13#define PA_PCI_MEM (0xb0000000) /* PCI MEM space */
14
15#define PCIPAR (0xa4000cf8) /* PCI Config address */
16#define PCIPDR (0xa4000cfc) /* PCI Config data */
17
18#endif /* __ASM_SH_MPC1211_H */
diff --git a/include/asm-sh/mpc1211/pci.h b/include/asm-sh/mpc1211/pci.h
deleted file mode 100644
index d9162c5ed76a..000000000000
--- a/include/asm-sh/mpc1211/pci.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Low-Level PCI Support for MPC-1211
3 *
4 * (c) 2002 Saito.K & Jeanne
5 *
6 */
7
8#ifndef _PCI_MPC1211_H_
9#define _PCI_MPC1211_H_
10
11#include <linux/pci.h>
12
13/* set debug level 4=verbose...1=terse */
14//#define DEBUG_PCI 3
15#undef DEBUG_PCI
16
17#ifdef DEBUG_PCI
18#define PCIDBG(n, x...) { if(DEBUG_PCI>=n) printk(x); }
19#else
20#define PCIDBG(n, x...)
21#endif
22
23/* startup values */
24#define PCI_PROBE_BIOS 1
25#define PCI_PROBE_CONF1 2
26#define PCI_PROBE_CONF2 4
27#define PCI_NO_CHECKS 0x400
28#define PCI_ASSIGN_ROMS 0x1000
29#define PCI_BIOS_IRQ_SCAN 0x2000
30
31/* MPC-1211 Specific Values */
32#define PCIPAR (0xa4000cf8) /* PCI Config address */
33#define PCIPDR (0xa4000cfc) /* PCI Config data */
34
35#define PA_PCI_IO (0xa4000000) /* PCI I/O space */
36#define PA_PCI_MEM (0xb0000000) /* PCI MEM space */
37
38#endif /* _PCI_MPC1211_H_ */
diff --git a/include/asm-sh/r7780rp.h b/include/asm-sh/r7780rp.h
index a33838f23a6d..306f7359f7d4 100644
--- a/include/asm-sh/r7780rp.h
+++ b/include/asm-sh/r7780rp.h
@@ -193,8 +193,6 @@
193#define IRQ_SCIF0 (HL_FPGA_IRQ_BASE + 15) 193#define IRQ_SCIF0 (HL_FPGA_IRQ_BASE + 15)
194#define IRQ_SCIF1 (HL_FPGA_IRQ_BASE + 16) 194#define IRQ_SCIF1 (HL_FPGA_IRQ_BASE + 16)
195 195
196unsigned char *highlander_init_irq_r7780mp(void); 196unsigned char *highlander_plat_irq_setup(void);
197unsigned char *highlander_init_irq_r7780rp(void);
198unsigned char *highlander_init_irq_r7785rp(void);
199 197
200#endif /* __ASM_SH_RENESAS_R7780RP */ 198#endif /* __ASM_SH_RENESAS_R7780RP */
diff --git a/include/asm-sh/tlb_64.h b/include/asm-sh/tlb_64.h
index 0308e05fc57b..0a96f3af69e3 100644
--- a/include/asm-sh/tlb_64.h
+++ b/include/asm-sh/tlb_64.h
@@ -56,6 +56,7 @@ static inline void __flush_tlb_slot(unsigned long long slot)
56 __asm__ __volatile__ ("putcfg %0, 0, r63\n" : : "r" (slot)); 56 __asm__ __volatile__ ("putcfg %0, 0, r63\n" : : "r" (slot));
57} 57}
58 58
59#ifdef CONFIG_MMU
59/* arch/sh64/mm/tlb.c */ 60/* arch/sh64/mm/tlb.c */
60int sh64_tlb_init(void); 61int sh64_tlb_init(void);
61unsigned long long sh64_next_free_dtlb_entry(void); 62unsigned long long sh64_next_free_dtlb_entry(void);
@@ -64,6 +65,13 @@ int sh64_put_wired_dtlb_entry(unsigned long long entry);
64void sh64_setup_tlb_slot(unsigned long long config_addr, unsigned long eaddr, 65void sh64_setup_tlb_slot(unsigned long long config_addr, unsigned long eaddr,
65 unsigned long asid, unsigned long paddr); 66 unsigned long asid, unsigned long paddr);
66void sh64_teardown_tlb_slot(unsigned long long config_addr); 67void sh64_teardown_tlb_slot(unsigned long long config_addr);
67 68#else
69#define sh64_tlb_init() do { } while (0)
70#define sh64_next_free_dtlb_entry() (0)
71#define sh64_get_wired_dtlb_entry() (0)
72#define sh64_put_wired_dtlb_entry(entry) do { } while (0)
73#define sh64_setup_tlb_slot(conf, virt, asid, phys) do { } while (0)
74#define sh64_teardown_tlb_slot(addr) do { } while (0)
75#endif /* CONFIG_MMU */
68#endif /* __ASSEMBLY__ */ 76#endif /* __ASSEMBLY__ */
69#endif /* __ASM_SH_TLB_64_H */ 77#endif /* __ASM_SH_TLB_64_H */
diff --git a/include/asm-sh/topology.h b/include/asm-sh/topology.h
index 34cdb28e8f44..95f0085e098a 100644
--- a/include/asm-sh/topology.h
+++ b/include/asm-sh/topology.h
@@ -29,6 +29,17 @@
29 .nr_balance_failed = 0, \ 29 .nr_balance_failed = 0, \
30} 30}
31 31
32#define cpu_to_node(cpu) ((void)(cpu),0)
33#define parent_node(node) ((void)(node),0)
34
35#define node_to_cpumask(node) ((void)node, cpu_online_map)
36#define node_to_first_cpu(node) ((void)(node),0)
37
38#define pcibus_to_node(bus) ((void)(bus), -1)
39#define pcibus_to_cpumask(bus) (pcibus_to_node(bus) == -1 ? \
40 CPU_MASK_ALL : \
41 node_to_cpumask(pcibus_to_node(bus)) \
42 )
32#endif 43#endif
33 44
34#include <asm-generic/topology.h> 45#include <asm-generic/topology.h>
diff --git a/include/asm-sh/uaccess_64.h b/include/asm-sh/uaccess_64.h
index f956b7b316c7..a9b68d094844 100644
--- a/include/asm-sh/uaccess_64.h
+++ b/include/asm-sh/uaccess_64.h
@@ -274,7 +274,9 @@ struct exception_table_entry
274 unsigned long insn, fixup; 274 unsigned long insn, fixup;
275}; 275};
276 276
277#ifdef CONFIG_MMU
277#define ARCH_HAS_SEARCH_EXTABLE 278#define ARCH_HAS_SEARCH_EXTABLE
279#endif
278 280
279/* Returns 0 if exception not found and fixup.unit otherwise. */ 281/* Returns 0 if exception not found and fixup.unit otherwise. */
280extern unsigned long search_exception_table(unsigned long addr); 282extern unsigned long search_exception_table(unsigned long addr);
diff --git a/include/asm-sparc/mman.h b/include/asm-sparc/mman.h
index e18be984c01d..3d16b40bb8ef 100644
--- a/include/asm-sparc/mman.h
+++ b/include/asm-sparc/mman.h
@@ -24,9 +24,8 @@
24 24
25#ifdef __KERNEL__ 25#ifdef __KERNEL__
26#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
27#define arch_mmap_check sparc_mmap_check 27#define arch_mmap_check(addr,len,flags) sparc_mmap_check(addr,len)
28int sparc_mmap_check(unsigned long addr, unsigned long len, 28int sparc_mmap_check(unsigned long addr, unsigned long len);
29 unsigned long flags);
30#endif 29#endif
31#endif 30#endif
32 31
diff --git a/include/asm-sparc/psr.h b/include/asm-sparc/psr.h
index 19c978051118..213970477a24 100644
--- a/include/asm-sparc/psr.h
+++ b/include/asm-sparc/psr.h
@@ -25,6 +25,7 @@
25#define PSR_PIL 0x00000f00 /* processor interrupt level */ 25#define PSR_PIL 0x00000f00 /* processor interrupt level */
26#define PSR_EF 0x00001000 /* enable floating point */ 26#define PSR_EF 0x00001000 /* enable floating point */
27#define PSR_EC 0x00002000 /* enable co-processor */ 27#define PSR_EC 0x00002000 /* enable co-processor */
28#define PSR_SYSCALL 0x00004000 /* inside of a syscall */
28#define PSR_LE 0x00008000 /* SuperSparcII little-endian */ 29#define PSR_LE 0x00008000 /* SuperSparcII little-endian */
29#define PSR_ICC 0x00f00000 /* integer condition codes */ 30#define PSR_ICC 0x00f00000 /* integer condition codes */
30#define PSR_C 0x00100000 /* carry bit */ 31#define PSR_C 0x00100000 /* carry bit */
diff --git a/include/asm-sparc/ptrace.h b/include/asm-sparc/ptrace.h
index 8201a7b29d49..0afb867d6c1b 100644
--- a/include/asm-sparc/ptrace.h
+++ b/include/asm-sparc/ptrace.h
@@ -10,6 +10,8 @@
10 10
11#ifndef __ASSEMBLY__ 11#ifndef __ASSEMBLY__
12 12
13#include <linux/types.h>
14
13struct pt_regs { 15struct pt_regs {
14 unsigned long psr; 16 unsigned long psr;
15 unsigned long pc; 17 unsigned long pc;
@@ -39,6 +41,16 @@ struct pt_regs {
39#define UREG_FP UREG_I6 41#define UREG_FP UREG_I6
40#define UREG_RETPC UREG_I7 42#define UREG_RETPC UREG_I7
41 43
44static inline bool pt_regs_is_syscall(struct pt_regs *regs)
45{
46 return (regs->psr & PSR_SYSCALL);
47}
48
49static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
50{
51 return (regs->psr &= ~PSR_SYSCALL);
52}
53
42/* A register window */ 54/* A register window */
43struct reg_window { 55struct reg_window {
44 unsigned long locals[8]; 56 unsigned long locals[8];
@@ -149,6 +161,7 @@ extern void show_regs(struct pt_regs *);
149#define SF_XXARG 0x5c 161#define SF_XXARG 0x5c
150 162
151/* Stuff for the ptrace system call */ 163/* Stuff for the ptrace system call */
164#define PTRACE_SPARC_DETACH 11
152#define PTRACE_GETREGS 12 165#define PTRACE_GETREGS 12
153#define PTRACE_SETREGS 13 166#define PTRACE_SETREGS 13
154#define PTRACE_GETFPREGS 14 167#define PTRACE_GETFPREGS 14
diff --git a/include/asm-sparc/signal.h b/include/asm-sparc/signal.h
index d03a21c97abb..94071c75701f 100644
--- a/include/asm-sparc/signal.h
+++ b/include/asm-sparc/signal.h
@@ -199,13 +199,7 @@ typedef struct sigaltstack {
199 size_t ss_size; 199 size_t ss_size;
200} stack_t; 200} stack_t;
201 201
202struct sparc_deliver_cookie { 202#define ptrace_signal_deliver(regs, cookie) do { } while (0)
203 int restart_syscall;
204 unsigned long orig_i0;
205};
206
207struct pt_regs;
208extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie);
209 203
210#endif /* !(__KERNEL__) */ 204#endif /* !(__KERNEL__) */
211 205
diff --git a/include/asm-sparc64/mman.h b/include/asm-sparc64/mman.h
index e584563b56eb..625be4d61baf 100644
--- a/include/asm-sparc64/mman.h
+++ b/include/asm-sparc64/mman.h
@@ -24,9 +24,8 @@
24 24
25#ifdef __KERNEL__ 25#ifdef __KERNEL__
26#ifndef __ASSEMBLY__ 26#ifndef __ASSEMBLY__
27#define arch_mmap_check sparc64_mmap_check 27#define arch_mmap_check(addr,len,flags) sparc64_mmap_check(addr,len)
28int sparc64_mmap_check(unsigned long addr, unsigned long len, 28int sparc64_mmap_check(unsigned long addr, unsigned long len);
29 unsigned long flags);
30#endif 29#endif
31#endif 30#endif
32 31
diff --git a/include/asm-sparc64/psrcompat.h b/include/asm-sparc64/psrcompat.h
index 5590ce6bd076..3614ca04753f 100644
--- a/include/asm-sparc64/psrcompat.h
+++ b/include/asm-sparc64/psrcompat.h
@@ -12,6 +12,7 @@
12#define PSR_PIL 0x00000f00 /* processor interrupt level */ 12#define PSR_PIL 0x00000f00 /* processor interrupt level */
13#define PSR_EF 0x00001000 /* enable floating point */ 13#define PSR_EF 0x00001000 /* enable floating point */
14#define PSR_EC 0x00002000 /* enable co-processor */ 14#define PSR_EC 0x00002000 /* enable co-processor */
15#define PSR_SYSCALL 0x00004000 /* inside of a syscall */
15#define PSR_LE 0x00008000 /* SuperSparcII little-endian */ 16#define PSR_LE 0x00008000 /* SuperSparcII little-endian */
16#define PSR_ICC 0x00f00000 /* integer condition codes */ 17#define PSR_ICC 0x00f00000 /* integer condition codes */
17#define PSR_C 0x00100000 /* carry bit */ 18#define PSR_C 0x00100000 /* carry bit */
@@ -30,6 +31,7 @@ static inline unsigned int tstate_to_psr(unsigned long tstate)
30 PSR_S | 31 PSR_S |
31 ((tstate & TSTATE_ICC) >> 12) | 32 ((tstate & TSTATE_ICC) >> 12) |
32 ((tstate & TSTATE_XCC) >> 20) | 33 ((tstate & TSTATE_XCC) >> 20) |
34 ((tstate & TSTATE_SYSCALL) ? PSR_SYSCALL : 0) |
33 PSR_V8PLUS); 35 PSR_V8PLUS);
34} 36}
35 37
diff --git a/include/asm-sparc64/pstate.h b/include/asm-sparc64/pstate.h
index f3c45484c636..949aebaf991d 100644
--- a/include/asm-sparc64/pstate.h
+++ b/include/asm-sparc64/pstate.h
@@ -62,6 +62,7 @@
62#define TSTATE_PRIV _AC(0x0000000000000400,UL) /* Privilege. */ 62#define TSTATE_PRIV _AC(0x0000000000000400,UL) /* Privilege. */
63#define TSTATE_IE _AC(0x0000000000000200,UL) /* Interrupt Enable. */ 63#define TSTATE_IE _AC(0x0000000000000200,UL) /* Interrupt Enable. */
64#define TSTATE_AG _AC(0x0000000000000100,UL) /* Alternate Globals.*/ 64#define TSTATE_AG _AC(0x0000000000000100,UL) /* Alternate Globals.*/
65#define TSTATE_SYSCALL _AC(0x0000000000000020,UL) /* in syscall trap */
65#define TSTATE_CWP _AC(0x000000000000001f,UL) /* Curr Win-Pointer. */ 66#define TSTATE_CWP _AC(0x000000000000001f,UL) /* Curr Win-Pointer. */
66 67
67/* Floating-Point Registers State Register. 68/* Floating-Point Registers State Register.
diff --git a/include/asm-sparc64/ptrace.h b/include/asm-sparc64/ptrace.h
index 714b81956f32..90972a5ada59 100644
--- a/include/asm-sparc64/ptrace.h
+++ b/include/asm-sparc64/ptrace.h
@@ -42,16 +42,14 @@ static inline int pt_regs_trap_type(struct pt_regs *regs)
42 return regs->magic & 0x1ff; 42 return regs->magic & 0x1ff;
43} 43}
44 44
45static inline int pt_regs_clear_trap_type(struct pt_regs *regs) 45static inline bool pt_regs_is_syscall(struct pt_regs *regs)
46{ 46{
47 return regs->magic &= ~0x1ff; 47 return (regs->tstate & TSTATE_SYSCALL);
48} 48}
49 49
50static inline bool pt_regs_is_syscall(struct pt_regs *regs) 50static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
51{ 51{
52 int tt = pt_regs_trap_type(regs); 52 return (regs->tstate &= ~TSTATE_SYSCALL);
53
54 return (tt == 0x110 || tt == 0x111 || tt == 0x16d);
55} 53}
56 54
57struct pt_regs32 { 55struct pt_regs32 {
@@ -298,6 +296,7 @@ extern void __show_regs(struct pt_regs *);
298#define SF_XXARG 0x5c 296#define SF_XXARG 0x5c
299 297
300/* Stuff for the ptrace system call */ 298/* Stuff for the ptrace system call */
299#define PTRACE_SPARC_DETACH 11
301#define PTRACE_GETREGS 12 300#define PTRACE_GETREGS 12
302#define PTRACE_SETREGS 13 301#define PTRACE_SETREGS 13
303#define PTRACE_GETFPREGS 14 302#define PTRACE_GETFPREGS 14
diff --git a/include/asm-sparc64/signal.h b/include/asm-sparc64/signal.h
index fa6f467389db..c49f32d38707 100644
--- a/include/asm-sparc64/signal.h
+++ b/include/asm-sparc64/signal.h
@@ -186,13 +186,7 @@ struct k_sigaction {
186 void __user *ka_restorer; 186 void __user *ka_restorer;
187}; 187};
188 188
189struct signal_deliver_cookie { 189#define ptrace_signal_deliver(regs, cookie) do { } while (0)
190 int restart_syscall;
191 unsigned long orig_i0;
192};
193
194struct pt_regs;
195extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie);
196 190
197#endif /* !(__KERNEL__) */ 191#endif /* !(__KERNEL__) */
198 192
diff --git a/include/asm-sparc64/thread_info.h b/include/asm-sparc64/thread_info.h
index 71e42d1a80d9..e5873e385306 100644
--- a/include/asm-sparc64/thread_info.h
+++ b/include/asm-sparc64/thread_info.h
@@ -38,7 +38,7 @@ struct thread_info {
38 struct task_struct *task; 38 struct task_struct *task;
39 unsigned long flags; 39 unsigned long flags;
40 __u8 fpsaved[7]; 40 __u8 fpsaved[7];
41 __u8 pad; 41 __u8 status;
42 unsigned long ksp; 42 unsigned long ksp;
43 43
44 /* D$ line 2 */ 44 /* D$ line 2 */
@@ -217,7 +217,7 @@ register struct thread_info *current_thread_info_reg asm("g6");
217 * nop 217 * nop
218 */ 218 */
219#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 219#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
220#define TIF_RESTORE_SIGMASK 1 /* restore signal mask in do_signal() */ 220/* flags bit 1 is available */
221#define TIF_SIGPENDING 2 /* signal pending */ 221#define TIF_SIGPENDING 2 /* signal pending */
222#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 222#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
223#define TIF_PERFCTR 4 /* performance counters active */ 223#define TIF_PERFCTR 4 /* performance counters active */
@@ -244,14 +244,34 @@ register struct thread_info *current_thread_info_reg asm("g6");
244#define _TIF_32BIT (1<<TIF_32BIT) 244#define _TIF_32BIT (1<<TIF_32BIT)
245#define _TIF_SECCOMP (1<<TIF_SECCOMP) 245#define _TIF_SECCOMP (1<<TIF_SECCOMP)
246#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 246#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
247#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
248#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 247#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
249#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 248#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
250 249
251#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \ 250#define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
252 (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK | \ 251 (_TIF_SIGPENDING | \
253 _TIF_NEED_RESCHED | _TIF_PERFCTR)) 252 _TIF_NEED_RESCHED | _TIF_PERFCTR))
254 253
254/*
255 * Thread-synchronous status.
256 *
257 * This is different from the flags in that nobody else
258 * ever touches our thread-synchronous status, so we don't
259 * have to worry about atomic accesses.
260 *
261 * Note that there are only 8 bits available.
262 */
263#define TS_RESTORE_SIGMASK 0x0001 /* restore signal mask in do_signal() */
264
265#ifndef __ASSEMBLY__
266#define HAVE_SET_RESTORE_SIGMASK 1
267static inline void set_restore_sigmask(void)
268{
269 struct thread_info *ti = current_thread_info();
270 ti->status |= TS_RESTORE_SIGMASK;
271 set_bit(TIF_SIGPENDING, &ti->flags);
272}
273#endif /* !__ASSEMBLY__ */
274
255#endif /* __KERNEL__ */ 275#endif /* __KERNEL__ */
256 276
257#endif /* _ASM_THREAD_INFO_H */ 277#endif /* _ASM_THREAD_INFO_H */
diff --git a/include/asm-sparc64/ttable.h b/include/asm-sparc64/ttable.h
index 1b55538b944f..52d67d394107 100644
--- a/include/asm-sparc64/ttable.h
+++ b/include/asm-sparc64/ttable.h
@@ -91,13 +91,14 @@
91 nop; 91 nop;
92 92
93#define SYSCALL_TRAP(routine, systbl) \ 93#define SYSCALL_TRAP(routine, systbl) \
94 rdpr %pil, %g2; \
95 mov TSTATE_SYSCALL, %g3; \
94 sethi %hi(109f), %g7; \ 96 sethi %hi(109f), %g7; \
95 ba,pt %xcc, etrap; \ 97 ba,pt %xcc, etrap_syscall; \
96109: or %g7, %lo(109b), %g7; \ 98109: or %g7, %lo(109b), %g7; \
97 sethi %hi(systbl), %l7; \ 99 sethi %hi(systbl), %l7; \
98 ba,pt %xcc, routine; \ 100 ba,pt %xcc, routine; \
99 or %l7, %lo(systbl), %l7; \ 101 or %l7, %lo(systbl), %l7;
100 nop; nop;
101 102
102#define TRAP_UTRAP(handler,lvl) \ 103#define TRAP_UTRAP(handler,lvl) \
103 mov handler, %g3; \ 104 mov handler, %g3; \
diff --git a/include/asm-um/irq.h b/include/asm-um/irq.h
index de389a477cdd..4a2037f8204b 100644
--- a/include/asm-um/irq.h
+++ b/include/asm-um/irq.h
@@ -15,8 +15,9 @@
15#define SIGIO_WRITE_IRQ 11 15#define SIGIO_WRITE_IRQ 11
16#define TELNETD_IRQ 12 16#define TELNETD_IRQ 12
17#define XTERM_IRQ 13 17#define XTERM_IRQ 13
18#define RANDOM_IRQ 14
18 19
19#define LAST_IRQ XTERM_IRQ 20#define LAST_IRQ RANDOM_IRQ
20#define NR_IRQS (LAST_IRQ + 1) 21#define NR_IRQS (LAST_IRQ + 1)
21 22
22#endif 23#endif
diff --git a/include/asm-um/keyboard.h b/include/asm-um/keyboard.h
deleted file mode 100644
index ee2e2303d0e4..000000000000
--- a/include/asm-um/keyboard.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __UM_KEYBOARD_H
2#define __UM_KEYBOARD_H
3
4#include "asm/arch/keyboard.h"
5
6#endif
diff --git a/include/asm-um/page.h b/include/asm-um/page.h
index 381f96b1c825..916e1a61999f 100644
--- a/include/asm-um/page.h
+++ b/include/asm-um/page.h
@@ -7,16 +7,20 @@
7#ifndef __UM_PAGE_H 7#ifndef __UM_PAGE_H
8#define __UM_PAGE_H 8#define __UM_PAGE_H
9 9
10struct page; 10#include <linux/const.h>
11
12#include <linux/types.h>
13#include <asm/vm-flags.h>
14 11
15/* PAGE_SHIFT determines the page size */ 12/* PAGE_SHIFT determines the page size */
16#define PAGE_SHIFT 12 13#define PAGE_SHIFT 12
17#define PAGE_SIZE (1UL << PAGE_SHIFT) 14#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
18#define PAGE_MASK (~(PAGE_SIZE-1)) 15#define PAGE_MASK (~(PAGE_SIZE-1))
19 16
17#ifndef __ASSEMBLY__
18
19struct page;
20
21#include <linux/types.h>
22#include <asm/vm-flags.h>
23
20/* 24/*
21 * These are used to make use of C type-checking.. 25 * These are used to make use of C type-checking..
22 */ 26 */
@@ -120,4 +124,5 @@ extern struct page *arch_validate(struct page *page, gfp_t mask, int order);
120#include <asm-generic/memory_model.h> 124#include <asm-generic/memory_model.h>
121#include <asm-generic/page.h> 125#include <asm-generic/page.h>
122 126
123#endif 127#endif /* __ASSEMBLY__ */
128#endif /* __UM_PAGE_H */
diff --git a/include/asm-um/param.h b/include/asm-um/param.h
index 4cd4a226f8c1..e44f4e60d16d 100644
--- a/include/asm-um/param.h
+++ b/include/asm-um/param.h
@@ -13,6 +13,8 @@
13#define HZ CONFIG_HZ 13#define HZ CONFIG_HZ
14#define USER_HZ 100 /* .. some user interfaces are in "ticks" */ 14#define USER_HZ 100 /* .. some user interfaces are in "ticks" */
15#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ 15#define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */
16#else
17#define HZ 100
16#endif 18#endif
17 19
18#endif 20#endif
diff --git a/include/asm-v850/param.h b/include/asm-v850/param.h
index 281832690290..4391f5fe0204 100644
--- a/include/asm-v850/param.h
+++ b/include/asm-v850/param.h
@@ -26,6 +26,8 @@
26# define HZ CONFIG_HZ 26# define HZ CONFIG_HZ
27# define USER_HZ 100 27# define USER_HZ 100
28# define CLOCKS_PER_SEC USER_HZ 28# define CLOCKS_PER_SEC USER_HZ
29#else
30# define HZ 100
29#endif 31#endif
30 32
31#endif /* __V850_PARAM_H__ */ 33#endif /* __V850_PARAM_H__ */
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h
index b81a4d4d3337..ee4b3ead6a43 100644
--- a/include/asm-x86/bitops.h
+++ b/include/asm-x86/bitops.h
@@ -23,13 +23,10 @@
23#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1) 23#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
24/* Technically wrong, but this avoids compilation errors on some gcc 24/* Technically wrong, but this avoids compilation errors on some gcc
25 versions. */ 25 versions. */
26#define ADDR "=m" (*(volatile long *)addr) 26#define ADDR "=m" (*(volatile long *) addr)
27#define BIT_ADDR "=m" (((volatile int *)addr)[nr >> 5])
28#else 27#else
29#define ADDR "+m" (*(volatile long *) addr) 28#define ADDR "+m" (*(volatile long *) addr)
30#define BIT_ADDR "+m" (((volatile int *)addr)[nr >> 5])
31#endif 29#endif
32#define BASE_ADDR "m" (*(volatile int *)addr)
33 30
34/** 31/**
35 * set_bit - Atomically set a bit in memory 32 * set_bit - Atomically set a bit in memory
@@ -77,7 +74,7 @@ static inline void __set_bit(int nr, volatile void *addr)
77 */ 74 */
78static inline void clear_bit(int nr, volatile void *addr) 75static inline void clear_bit(int nr, volatile void *addr)
79{ 76{
80 asm volatile(LOCK_PREFIX "btr %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR); 77 asm volatile(LOCK_PREFIX "btr %1,%0" : ADDR : "Ir" (nr));
81} 78}
82 79
83/* 80/*
@@ -96,7 +93,7 @@ static inline void clear_bit_unlock(unsigned nr, volatile void *addr)
96 93
97static inline void __clear_bit(int nr, volatile void *addr) 94static inline void __clear_bit(int nr, volatile void *addr)
98{ 95{
99 asm volatile("btr %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR); 96 asm volatile("btr %1,%0" : ADDR : "Ir" (nr));
100} 97}
101 98
102/* 99/*
@@ -131,7 +128,7 @@ static inline void __clear_bit_unlock(unsigned nr, volatile void *addr)
131 */ 128 */
132static inline void __change_bit(int nr, volatile void *addr) 129static inline void __change_bit(int nr, volatile void *addr)
133{ 130{
134 asm volatile("btc %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR); 131 asm volatile("btc %1,%0" : ADDR : "Ir" (nr));
135} 132}
136 133
137/** 134/**
@@ -145,7 +142,7 @@ static inline void __change_bit(int nr, volatile void *addr)
145 */ 142 */
146static inline void change_bit(int nr, volatile void *addr) 143static inline void change_bit(int nr, volatile void *addr)
147{ 144{
148 asm volatile(LOCK_PREFIX "btc %1,%2" : BIT_ADDR : "Ir" (nr), BASE_ADDR); 145 asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr));
149} 146}
150 147
151/** 148/**
@@ -191,9 +188,10 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)
191{ 188{
192 int oldbit; 189 int oldbit;
193 190
194 asm volatile("bts %2,%3\n\t" 191 asm("bts %2,%1\n\t"
195 "sbb %0,%0" 192 "sbb %0,%0"
196 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR); 193 : "=r" (oldbit), ADDR
194 : "Ir" (nr));
197 return oldbit; 195 return oldbit;
198} 196}
199 197
@@ -229,9 +227,10 @@ static inline int __test_and_clear_bit(int nr, volatile void *addr)
229{ 227{
230 int oldbit; 228 int oldbit;
231 229
232 asm volatile("btr %2,%3\n\t" 230 asm volatile("btr %2,%1\n\t"
233 "sbb %0,%0" 231 "sbb %0,%0"
234 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR); 232 : "=r" (oldbit), ADDR
233 : "Ir" (nr));
235 return oldbit; 234 return oldbit;
236} 235}
237 236
@@ -240,9 +239,10 @@ static inline int __test_and_change_bit(int nr, volatile void *addr)
240{ 239{
241 int oldbit; 240 int oldbit;
242 241
243 asm volatile("btc %2,%3\n\t" 242 asm volatile("btc %2,%1\n\t"
244 "sbb %0,%0" 243 "sbb %0,%0"
245 : "=r" (oldbit), BIT_ADDR : "Ir" (nr), BASE_ADDR); 244 : "=r" (oldbit), ADDR
245 : "Ir" (nr) : "memory");
246 246
247 return oldbit; 247 return oldbit;
248} 248}
@@ -276,11 +276,10 @@ static inline int variable_test_bit(int nr, volatile const void *addr)
276{ 276{
277 int oldbit; 277 int oldbit;
278 278
279 asm volatile("bt %2,%3\n\t" 279 asm volatile("bt %2,%1\n\t"
280 "sbb %0,%0" 280 "sbb %0,%0"
281 : "=r" (oldbit) 281 : "=r" (oldbit)
282 : "m" (((volatile const int *)addr)[nr >> 5]), 282 : "m" (*(unsigned long *)addr), "Ir" (nr));
283 "Ir" (nr), BASE_ADDR);
284 283
285 return oldbit; 284 return oldbit;
286} 285}
@@ -397,8 +396,6 @@ static inline int fls(int x)
397} 396}
398#endif /* __KERNEL__ */ 397#endif /* __KERNEL__ */
399 398
400#undef BASE_ADDR
401#undef BIT_ADDR
402#undef ADDR 399#undef ADDR
403 400
404static inline void set_bit_string(unsigned long *bitmap, 401static inline void set_bit_string(unsigned long *bitmap,
diff --git a/include/asm-x86/geode.h b/include/asm-x86/geode.h
index 7154dc4de951..6e6458853a36 100644
--- a/include/asm-x86/geode.h
+++ b/include/asm-x86/geode.h
@@ -185,16 +185,14 @@ static inline int is_geode(void)
185 return (is_geode_gx() || is_geode_lx()); 185 return (is_geode_gx() || is_geode_lx());
186} 186}
187 187
188/* 188#ifdef CONFIG_MGEODE_LX
189 * The VSA has virtual registers that we can query for a signature. 189extern int geode_has_vsa2(void);
190 */ 190#else
191static inline int geode_has_vsa2(void) 191static inline int geode_has_vsa2(void)
192{ 192{
193 outw(VSA_VR_UNLOCK, VSA_VRC_INDEX); 193 return 0;
194 outw(VSA_VR_SIGNATURE, VSA_VRC_INDEX);
195
196 return (inw(VSA_VRC_DATA) == VSA_SIG);
197} 194}
195#endif
198 196
199/* MFGPTs */ 197/* MFGPTs */
200 198
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index da2adb45f6e3..6b722d315936 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -175,7 +175,15 @@ static inline int save_i387(struct _fpstate __user *buf)
175 */ 175 */
176static inline int restore_i387(struct _fpstate __user *buf) 176static inline int restore_i387(struct _fpstate __user *buf)
177{ 177{
178 set_used_math(); 178 struct task_struct *tsk = current;
179 int err;
180
181 if (!used_math()) {
182 err = init_fpu(tsk);
183 if (err)
184 return err;
185 }
186
179 if (!(task_thread_info(current)->status & TS_USEDFPU)) { 187 if (!(task_thread_info(current)->status & TS_USEDFPU)) {
180 clts(); 188 clts();
181 task_thread_info(current)->status |= TS_USEDFPU; 189 task_thread_info(current)->status |= TS_USEDFPU;
diff --git a/include/asm-x86/pat.h b/include/asm-x86/pat.h
index 8b822b5a1786..88f60cc6a227 100644
--- a/include/asm-x86/pat.h
+++ b/include/asm-x86/pat.h
@@ -4,7 +4,13 @@
4 4
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7#ifdef CONFIG_X86_PAT
7extern int pat_wc_enabled; 8extern int pat_wc_enabled;
9extern void validate_pat_support(struct cpuinfo_x86 *c);
10#else
11static const int pat_wc_enabled = 0;
12static inline void validate_pat_support(struct cpuinfo_x86 *c) { }
13#endif
8 14
9extern void pat_init(void); 15extern void pat_init(void);
10 16
@@ -12,5 +18,7 @@ extern int reserve_memtype(u64 start, u64 end,
12 unsigned long req_type, unsigned long *ret_type); 18 unsigned long req_type, unsigned long *ret_type);
13extern int free_memtype(u64 start, u64 end); 19extern int free_memtype(u64 start, u64 end);
14 20
21extern void pat_disable(char *reason);
22
15#endif 23#endif
16 24
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 801b31f71452..55c3a0e3a8ce 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -57,7 +57,8 @@
57#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \ 57#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | \
58 _PAGE_DIRTY) 58 _PAGE_DIRTY)
59 59
60#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 60#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_PCD | _PAGE_PWT | \
61 _PAGE_ACCESSED | _PAGE_DIRTY)
61 62
62#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT) 63#define _PAGE_CACHE_MASK (_PAGE_PCD | _PAGE_PWT)
63#define _PAGE_CACHE_WB (0) 64#define _PAGE_CACHE_WB (0)
@@ -288,12 +289,21 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
288 * Chop off the NX bit (if present), and add the NX portion of 289 * Chop off the NX bit (if present), and add the NX portion of
289 * the newprot (if present): 290 * the newprot (if present):
290 */ 291 */
291 val &= _PAGE_CHG_MASK & ~_PAGE_NX; 292 val &= _PAGE_CHG_MASK;
292 val |= pgprot_val(newprot) & __supported_pte_mask; 293 val |= pgprot_val(newprot) & (~_PAGE_CHG_MASK) & __supported_pte_mask;
293 294
294 return __pte(val); 295 return __pte(val);
295} 296}
296 297
298/* mprotect needs to preserve PAT bits when updating vm_page_prot */
299#define pgprot_modify pgprot_modify
300static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
301{
302 pgprotval_t preservebits = pgprot_val(oldprot) & _PAGE_CHG_MASK;
303 pgprotval_t addbits = pgprot_val(newprot);
304 return __pgprot(preservebits | addbits);
305}
306
297#define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX)) 307#define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX))
298 308
299#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask) 309#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index 577ab79c4c27..d7f0403bbecb 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -88,14 +88,7 @@ extern unsigned long pg0[];
88/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */ 88/* To avoid harmful races, pmd_none(x) should check only the lower when PAE */
89#define pmd_none(x) (!(unsigned long)pmd_val((x))) 89#define pmd_none(x) (!(unsigned long)pmd_val((x)))
90#define pmd_present(x) (pmd_val((x)) & _PAGE_PRESENT) 90#define pmd_present(x) (pmd_val((x)) & _PAGE_PRESENT)
91 91#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
92extern int pmd_bad(pmd_t pmd);
93
94#define pmd_bad_v1(x) \
95 (_KERNPG_TABLE != (pmd_val((x)) & ~(PAGE_MASK | _PAGE_USER)))
96#define pmd_bad_v2(x) \
97 (_KERNPG_TABLE != (pmd_val((x)) & ~(PAGE_MASK | _PAGE_USER | \
98 _PAGE_PSE | _PAGE_NX)))
99 92
100#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 93#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
101 94
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index a3bbf8766c1d..efe83dcbd412 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -158,14 +158,12 @@ static inline unsigned long pgd_bad(pgd_t pgd)
158 158
159static inline unsigned long pud_bad(pud_t pud) 159static inline unsigned long pud_bad(pud_t pud)
160{ 160{
161 return pud_val(pud) & 161 return pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
162 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
163} 162}
164 163
165static inline unsigned long pmd_bad(pmd_t pmd) 164static inline unsigned long pmd_bad(pmd_t pmd)
166{ 165{
167 return pmd_val(pmd) & 166 return pmd_val(pmd) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER);
168 ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER | _PAGE_PSE | _PAGE_NX);
169} 167}
170 168
171#define pte_none(x) (!pte_val((x))) 169#define pte_none(x) (!pte_val((x)))
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h
index bc6376f1bc5a..21e89bf92f1c 100644
--- a/include/asm-x86/spinlock.h
+++ b/include/asm-x86/spinlock.h
@@ -20,18 +20,8 @@
20 */ 20 */
21 21
22#ifdef CONFIG_X86_32 22#ifdef CONFIG_X86_32
23typedef char _slock_t;
24# define LOCK_INS_DEC "decb"
25# define LOCK_INS_XCH "xchgb"
26# define LOCK_INS_MOV "movb"
27# define LOCK_INS_CMP "cmpb"
28# define LOCK_PTR_REG "a" 23# define LOCK_PTR_REG "a"
29#else 24#else
30typedef int _slock_t;
31# define LOCK_INS_DEC "decl"
32# define LOCK_INS_XCH "xchgl"
33# define LOCK_INS_MOV "movl"
34# define LOCK_INS_CMP "cmpl"
35# define LOCK_PTR_REG "D" 25# define LOCK_PTR_REG "D"
36#endif 26#endif
37 27
@@ -66,14 +56,14 @@ typedef int _slock_t;
66#if (NR_CPUS < 256) 56#if (NR_CPUS < 256)
67static inline int __raw_spin_is_locked(raw_spinlock_t *lock) 57static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
68{ 58{
69 int tmp = *(volatile signed int *)(&(lock)->slock); 59 int tmp = ACCESS_ONCE(lock->slock);
70 60
71 return (((tmp >> 8) & 0xff) != (tmp & 0xff)); 61 return (((tmp >> 8) & 0xff) != (tmp & 0xff));
72} 62}
73 63
74static inline int __raw_spin_is_contended(raw_spinlock_t *lock) 64static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
75{ 65{
76 int tmp = *(volatile signed int *)(&(lock)->slock); 66 int tmp = ACCESS_ONCE(lock->slock);
77 67
78 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1; 68 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
79} 69}
@@ -130,14 +120,14 @@ static __always_inline void __raw_spin_unlock(raw_spinlock_t *lock)
130#else 120#else
131static inline int __raw_spin_is_locked(raw_spinlock_t *lock) 121static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
132{ 122{
133 int tmp = *(volatile signed int *)(&(lock)->slock); 123 int tmp = ACCESS_ONCE(lock->slock);
134 124
135 return (((tmp >> 16) & 0xffff) != (tmp & 0xffff)); 125 return (((tmp >> 16) & 0xffff) != (tmp & 0xffff));
136} 126}
137 127
138static inline int __raw_spin_is_contended(raw_spinlock_t *lock) 128static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
139{ 129{
140 int tmp = *(volatile signed int *)(&(lock)->slock); 130 int tmp = ACCESS_ONCE(lock->slock);
141 131
142 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1; 132 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
143} 133}
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index 4f35a0fb4f22..dcf3f8131d6b 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -25,6 +25,16 @@
25#ifndef _ASM_X86_TOPOLOGY_H 25#ifndef _ASM_X86_TOPOLOGY_H
26#define _ASM_X86_TOPOLOGY_H 26#define _ASM_X86_TOPOLOGY_H
27 27
28#ifdef CONFIG_X86_32
29# ifdef CONFIG_X86_HT
30# define ENABLE_TOPO_DEFINES
31# endif
32#else
33# ifdef CONFIG_SMP
34# define ENABLE_TOPO_DEFINES
35# endif
36#endif
37
28#ifdef CONFIG_NUMA 38#ifdef CONFIG_NUMA
29#include <linux/cpumask.h> 39#include <linux/cpumask.h>
30#include <asm/mpspec.h> 40#include <asm/mpspec.h>
@@ -130,10 +140,6 @@ extern unsigned long node_end_pfn[];
130extern unsigned long node_remap_size[]; 140extern unsigned long node_remap_size[];
131#define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid]) 141#define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid])
132 142
133# ifdef CONFIG_X86_HT
134# define ENABLE_TOPO_DEFINES
135# endif
136
137# define SD_CACHE_NICE_TRIES 1 143# define SD_CACHE_NICE_TRIES 1
138# define SD_IDLE_IDX 1 144# define SD_IDLE_IDX 1
139# define SD_NEWIDLE_IDX 2 145# define SD_NEWIDLE_IDX 2
@@ -141,10 +147,6 @@ extern unsigned long node_remap_size[];
141 147
142#else 148#else
143 149
144# ifdef CONFIG_SMP
145# define ENABLE_TOPO_DEFINES
146# endif
147
148# define SD_CACHE_NICE_TRIES 2 150# define SD_CACHE_NICE_TRIES 2
149# define SD_IDLE_IDX 2 151# define SD_IDLE_IDX 2
150# define SD_NEWIDLE_IDX 2 152# define SD_NEWIDLE_IDX 2
diff --git a/include/asm-xtensa/param.h b/include/asm-xtensa/param.h
index 82ad34d92d35..ba03d5aeab6b 100644
--- a/include/asm-xtensa/param.h
+++ b/include/asm-xtensa/param.h
@@ -15,6 +15,8 @@
15# define HZ CONFIG_HZ /* internal timer frequency */ 15# define HZ CONFIG_HZ /* internal timer frequency */
16# define USER_HZ 100 /* for user interfaces in "ticks" */ 16# define USER_HZ 100 /* for user interfaces in "ticks" */
17# define CLOCKS_PER_SEC (USER_HZ) /* frequnzy at which times() counts */ 17# define CLOCKS_PER_SEC (USER_HZ) /* frequnzy at which times() counts */
18#else
19# define HZ 100
18#endif 20#endif
19 21
20#define EXEC_PAGESIZE 4096 22#define EXEC_PAGESIZE 4096
diff --git a/include/linux/atm.h b/include/linux/atm.h
index 60136684e0af..c791ddd96939 100644
--- a/include/linux/atm.h
+++ b/include/linux/atm.h
@@ -16,14 +16,11 @@
16 * documentation. Do not change them. 16 * documentation. Do not change them.
17 */ 17 */
18 18
19#ifdef __KERNEL__
20#include <linux/socket.h>
21#include <linux/types.h>
22#endif
23#include <linux/compiler.h> 19#include <linux/compiler.h>
24#include <linux/atmapi.h> 20#include <linux/atmapi.h>
25#include <linux/atmsap.h> 21#include <linux/atmsap.h>
26#include <linux/atmioc.h> 22#include <linux/atmioc.h>
23#include <linux/types.h>
27 24
28 25
29/* general ATM constants */ 26/* general ATM constants */
@@ -212,7 +209,7 @@ struct sockaddr_atmsvc {
212 char pub[ATM_E164_LEN+1]; /* public address (E.164) */ 209 char pub[ATM_E164_LEN+1]; /* public address (E.164) */
213 /* unused addresses must be bzero'ed */ 210 /* unused addresses must be bzero'ed */
214 char lij_type; /* role in LIJ call; one of ATM_LIJ* */ 211 char lij_type; /* role in LIJ call; one of ATM_LIJ* */
215 uint32_t lij_id; /* LIJ call identifier */ 212 __u32 lij_id; /* LIJ call identifier */
216 } sas_addr __ATM_API_ALIGN; /* SVC address */ 213 } sas_addr __ATM_API_ALIGN; /* SVC address */
217}; 214};
218 215
diff --git a/include/linux/atm_tcp.h b/include/linux/atm_tcp.h
index 18787f9b2f19..375638f8554b 100644
--- a/include/linux/atm_tcp.h
+++ b/include/linux/atm_tcp.h
@@ -8,11 +8,9 @@
8#define LINUX_ATM_TCP_H 8#define LINUX_ATM_TCP_H
9 9
10#include <linux/atmapi.h> 10#include <linux/atmapi.h>
11 11#include <linux/atm.h>
12#ifdef __KERNEL__
13#include <linux/types.h>
14#endif
15#include <linux/atmioc.h> 12#include <linux/atmioc.h>
13#include <linux/types.h>
16 14
17 15
18/* 16/*
@@ -20,9 +18,9 @@
20 */ 18 */
21 19
22struct atmtcp_hdr { 20struct atmtcp_hdr {
23 uint16_t vpi; 21 __u16 vpi;
24 uint16_t vci; 22 __u16 vci;
25 uint32_t length; /* ... of data part */ 23 __u32 length; /* ... of data part */
26}; 24};
27 25
28/* 26/*
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 43b406def35f..1abfe664c444 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -110,7 +110,6 @@ extern int __bitmap_weight(const unsigned long *bitmap, int bits);
110 110
111extern int bitmap_scnprintf(char *buf, unsigned int len, 111extern int bitmap_scnprintf(char *buf, unsigned int len,
112 const unsigned long *src, int nbits); 112 const unsigned long *src, int nbits);
113extern int bitmap_scnprintf_len(unsigned int len);
114extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user, 113extern int __bitmap_parse(const char *buf, unsigned int buflen, int is_user,
115 unsigned long *dst, int nbits); 114 unsigned long *dst, int nbits);
116extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen, 115extern int bitmap_parse_user(const char __user *ubuf, unsigned int ulen,
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index dcae0c8d97e6..c8bd2daf95ec 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -182,4 +182,16 @@ extern void __chk_io_ptr(const volatile void __iomem *);
182# define __section(S) __attribute__ ((__section__(#S))) 182# define __section(S) __attribute__ ((__section__(#S)))
183#endif 183#endif
184 184
185/*
186 * Prevent the compiler from merging or refetching accesses. The compiler
187 * is also forbidden from reordering successive instances of ACCESS_ONCE(),
188 * but only when the compiler is aware of some particular ordering. One way
189 * to make the compiler aware of ordering is to put the two invocations of
190 * ACCESS_ONCE() in different C statements.
191 *
192 * This macro does absolutely -nothing- to prevent the CPU from reordering,
193 * merging, or refetching absolutely anything at any time.
194 */
195#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
196
185#endif /* __LINUX_COMPILER_H */ 197#endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 9650806fe2ea..5df3db58fcc6 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -289,13 +289,6 @@ static inline int __cpumask_scnprintf(char *buf, int len,
289 return bitmap_scnprintf(buf, len, srcp->bits, nbits); 289 return bitmap_scnprintf(buf, len, srcp->bits, nbits);
290} 290}
291 291
292#define cpumask_scnprintf_len(len) \
293 __cpumask_scnprintf_len((len))
294static inline int __cpumask_scnprintf_len(int len)
295{
296 return bitmap_scnprintf_len(len);
297}
298
299#define cpumask_parse_user(ubuf, ulen, dst) \ 292#define cpumask_parse_user(ubuf, ulen, dst) \
300 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS) 293 __cpumask_parse_user((ubuf), (ulen), &(dst), NR_CPUS)
301static inline int __cpumask_parse_user(const char __user *buf, int len, 294static inline int __cpumask_parse_user(const char __user *buf, int len,
diff --git a/include/linux/device.h b/include/linux/device.h
index 8c23e3dfe3ac..15e9fa3ad3af 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -183,7 +183,6 @@ struct class {
183 struct module *owner; 183 struct module *owner;
184 184
185 struct kset subsys; 185 struct kset subsys;
186 struct list_head children;
187 struct list_head devices; 186 struct list_head devices;
188 struct list_head interfaces; 187 struct list_head interfaces;
189 struct kset class_dirs; 188 struct kset class_dirs;
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index de8387b7ceb6..f5abd1306638 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -33,6 +33,19 @@ enum fid_type {
33 * 32 bit parent directory inode number. 33 * 32 bit parent directory inode number.
34 */ 34 */
35 FILEID_INO32_GEN_PARENT = 2, 35 FILEID_INO32_GEN_PARENT = 2,
36
37 /*
38 * 32 bit block number, 16 bit partition reference,
39 * 16 bit unused, 32 bit generation number.
40 */
41 FILEID_UDF_WITHOUT_PARENT = 0x51,
42
43 /*
44 * 32 bit block number, 16 bit partition reference,
45 * 16 bit unused, 32 bit generation number,
46 * 32 bit parent block number, 32 bit parent generation number
47 */
48 FILEID_UDF_WITH_PARENT = 0x52,
36}; 49};
37 50
38struct fid { 51struct fid {
@@ -43,6 +56,14 @@ struct fid {
43 u32 parent_ino; 56 u32 parent_ino;
44 u32 parent_gen; 57 u32 parent_gen;
45 } i32; 58 } i32;
59 struct {
60 u32 block;
61 u16 partref;
62 u16 parent_partref;
63 u32 generation;
64 u32 parent_block;
65 u32 parent_generation;
66 } udf;
46 __u32 raw[0]; 67 __u32 raw[0];
47 }; 68 };
48}; 69};
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a1ba005d08e7..f413085f748e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1289,17 +1289,12 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
1289extern ssize_t vfs_writev(struct file *, const struct iovec __user *, 1289extern ssize_t vfs_writev(struct file *, const struct iovec __user *,
1290 unsigned long, loff_t *); 1290 unsigned long, loff_t *);
1291 1291
1292/*
1293 * NOTE: write_inode, delete_inode, clear_inode, put_inode can be called
1294 * without the big kernel lock held in all filesystems.
1295 */
1296struct super_operations { 1292struct super_operations {
1297 struct inode *(*alloc_inode)(struct super_block *sb); 1293 struct inode *(*alloc_inode)(struct super_block *sb);
1298 void (*destroy_inode)(struct inode *); 1294 void (*destroy_inode)(struct inode *);
1299 1295
1300 void (*dirty_inode) (struct inode *); 1296 void (*dirty_inode) (struct inode *);
1301 int (*write_inode) (struct inode *, int); 1297 int (*write_inode) (struct inode *, int);
1302 void (*put_inode) (struct inode *);
1303 void (*drop_inode) (struct inode *); 1298 void (*drop_inode) (struct inode *);
1304 void (*delete_inode) (struct inode *); 1299 void (*delete_inode) (struct inode *);
1305 void (*put_super) (struct super_block *); 1300 void (*put_super) (struct super_block *);
@@ -1821,7 +1816,6 @@ extern void iget_failed(struct inode *);
1821extern void clear_inode(struct inode *); 1816extern void clear_inode(struct inode *);
1822extern void destroy_inode(struct inode *); 1817extern void destroy_inode(struct inode *);
1823extern struct inode *new_inode(struct super_block *); 1818extern struct inode *new_inode(struct super_block *);
1824extern int __remove_suid(struct dentry *, int);
1825extern int should_remove_suid(struct dentry *); 1819extern int should_remove_suid(struct dentry *);
1826extern int remove_suid(struct dentry *); 1820extern int remove_suid(struct dentry *);
1827 1821
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index 5c86f1196c3a..d48282197696 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -109,6 +109,7 @@ struct fuse_file_lock {
109#define FUSE_POSIX_LOCKS (1 << 1) 109#define FUSE_POSIX_LOCKS (1 << 1)
110#define FUSE_FILE_OPS (1 << 2) 110#define FUSE_FILE_OPS (1 << 2)
111#define FUSE_ATOMIC_O_TRUNC (1 << 3) 111#define FUSE_ATOMIC_O_TRUNC (1 << 3)
112#define FUSE_BIG_WRITES (1 << 5)
112 113
113/** 114/**
114 * Release flags 115 * Release flags
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index ecd2bf63fc84..ae7aec3cabee 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -178,17 +178,17 @@ static inline struct hd_struct *get_part(struct gendisk *gendiskp,
178 178
179static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) { 179static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
180 int i; 180 int i;
181
181 for_each_possible_cpu(i) 182 for_each_possible_cpu(i)
182 memset(per_cpu_ptr(gendiskp->dkstats, i), value, 183 memset(per_cpu_ptr(gendiskp->dkstats, i), value,
183 sizeof (struct disk_stats)); 184 sizeof(struct disk_stats));
184} 185}
185 186
186#define __part_stat_add(part, field, addnd) \ 187#define __part_stat_add(part, field, addnd) \
187 (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd) 188 (per_cpu_ptr(part->dkstats, smp_processor_id())->field += addnd)
188 189
189#define __all_stat_add(gendiskp, field, addnd, sector) \ 190#define __all_stat_add(gendiskp, part, field, addnd, sector) \
190({ \ 191({ \
191 struct hd_struct *part = get_part(gendiskp, sector); \
192 if (part) \ 192 if (part) \
193 __part_stat_add(part, field, addnd); \ 193 __part_stat_add(part, field, addnd); \
194 __disk_stat_add(gendiskp, field, addnd); \ 194 __disk_stat_add(gendiskp, field, addnd); \
@@ -203,11 +203,13 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
203 res; \ 203 res; \
204}) 204})
205 205
206static inline void part_stat_set_all(struct hd_struct *part, int value) { 206static inline void part_stat_set_all(struct hd_struct *part, int value)
207{
207 int i; 208 int i;
209
208 for_each_possible_cpu(i) 210 for_each_possible_cpu(i)
209 memset(per_cpu_ptr(part->dkstats, i), value, 211 memset(per_cpu_ptr(part->dkstats, i), value,
210 sizeof(struct disk_stats)); 212 sizeof(struct disk_stats));
211} 213}
212 214
213#else /* !CONFIG_SMP */ 215#else /* !CONFIG_SMP */
@@ -223,9 +225,8 @@ static inline void disk_stat_set_all(struct gendisk *gendiskp, int value)
223#define __part_stat_add(part, field, addnd) \ 225#define __part_stat_add(part, field, addnd) \
224 (part->dkstats.field += addnd) 226 (part->dkstats.field += addnd)
225 227
226#define __all_stat_add(gendiskp, field, addnd, sector) \ 228#define __all_stat_add(gendiskp, part, field, addnd, sector) \
227({ \ 229({ \
228 struct hd_struct *part = get_part(gendiskp, sector); \
229 if (part) \ 230 if (part) \
230 part->dkstats.field += addnd; \ 231 part->dkstats.field += addnd; \
231 __disk_stat_add(gendiskp, field, addnd); \ 232 __disk_stat_add(gendiskp, field, addnd); \
@@ -276,10 +277,10 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
276#define part_stat_sub(gendiskp, field, subnd) \ 277#define part_stat_sub(gendiskp, field, subnd) \
277 part_stat_add(gendiskp, field, -subnd) 278 part_stat_add(gendiskp, field, -subnd)
278 279
279#define all_stat_add(gendiskp, field, addnd, sector) \ 280#define all_stat_add(gendiskp, part, field, addnd, sector) \
280 do { \ 281 do { \
281 preempt_disable(); \ 282 preempt_disable(); \
282 __all_stat_add(gendiskp, field, addnd, sector); \ 283 __all_stat_add(gendiskp, part, field, addnd, sector); \
283 preempt_enable(); \ 284 preempt_enable(); \
284 } while (0) 285 } while (0)
285 286
@@ -288,15 +289,15 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
288#define all_stat_dec(gendiskp, field, sector) \ 289#define all_stat_dec(gendiskp, field, sector) \
289 all_stat_add(gendiskp, field, -1, sector) 290 all_stat_add(gendiskp, field, -1, sector)
290 291
291#define __all_stat_inc(gendiskp, field, sector) \ 292#define __all_stat_inc(gendiskp, part, field, sector) \
292 __all_stat_add(gendiskp, field, 1, sector) 293 __all_stat_add(gendiskp, part, field, 1, sector)
293#define all_stat_inc(gendiskp, field, sector) \ 294#define all_stat_inc(gendiskp, part, field, sector) \
294 all_stat_add(gendiskp, field, 1, sector) 295 all_stat_add(gendiskp, part, field, 1, sector)
295 296
296#define __all_stat_sub(gendiskp, field, subnd, sector) \ 297#define __all_stat_sub(gendiskp, part, field, subnd, sector) \
297 __all_stat_add(gendiskp, field, -subnd, sector) 298 __all_stat_add(gendiskp, part, field, -subnd, sector)
298#define all_stat_sub(gendiskp, field, subnd, sector) \ 299#define all_stat_sub(gendiskp, part, field, subnd, sector) \
299 all_stat_add(gendiskp, field, -subnd, sector) 300 all_stat_add(gendiskp, part, field, -subnd, sector)
300 301
301/* Inlines to alloc and free disk stats in struct gendisk */ 302/* Inlines to alloc and free disk stats in struct gendisk */
302#ifdef CONFIG_SMP 303#ifdef CONFIG_SMP
@@ -524,7 +525,7 @@ struct unixware_disklabel {
524#define ADDPART_FLAG_RAID 1 525#define ADDPART_FLAG_RAID 1
525#define ADDPART_FLAG_WHOLEDISK 2 526#define ADDPART_FLAG_WHOLEDISK 2
526 527
527extern dev_t blk_lookup_devt(const char *name); 528extern dev_t blk_lookup_devt(const char *name, int part);
528extern char *disk_name (struct gendisk *hd, int part, char *buf); 529extern char *disk_name (struct gendisk *hd, int part, char *buf);
529 530
530extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 531extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
@@ -552,7 +553,7 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
552 553
553static inline void printk_all_partitions(void) { } 554static inline void printk_all_partitions(void) { }
554 555
555static inline dev_t blk_lookup_devt(const char *name) 556static inline dev_t blk_lookup_devt(const char *name, int part)
556{ 557{
557 dev_t devt = MKDEV(0, 0); 558 dev_t devt = MKDEV(0, 0);
558 return devt; 559 return devt;
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 897f723bd222..181006cc94a0 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -72,6 +72,14 @@
72#define in_softirq() (softirq_count()) 72#define in_softirq() (softirq_count())
73#define in_interrupt() (irq_count()) 73#define in_interrupt() (irq_count())
74 74
75#if defined(CONFIG_PREEMPT)
76# define PREEMPT_INATOMIC_BASE kernel_locked()
77# define PREEMPT_CHECK_OFFSET 1
78#else
79# define PREEMPT_INATOMIC_BASE 0
80# define PREEMPT_CHECK_OFFSET 0
81#endif
82
75/* 83/*
76 * Are we running in atomic context? WARNING: this macro cannot 84 * Are we running in atomic context? WARNING: this macro cannot
77 * always detect atomic context; in particular, it cannot know about 85 * always detect atomic context; in particular, it cannot know about
@@ -79,17 +87,11 @@
79 * used in the general case to determine whether sleeping is possible. 87 * used in the general case to determine whether sleeping is possible.
80 * Do not use in_atomic() in driver code. 88 * Do not use in_atomic() in driver code.
81 */ 89 */
82#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0) 90#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_INATOMIC_BASE)
83
84#ifdef CONFIG_PREEMPT
85# define PREEMPT_CHECK_OFFSET 1
86#else
87# define PREEMPT_CHECK_OFFSET 0
88#endif
89 91
90/* 92/*
91 * Check whether we were atomic before we did preempt_disable(): 93 * Check whether we were atomic before we did preempt_disable():
92 * (used by the scheduler) 94 * (used by the scheduler, *after* releasing the kernel lock)
93 */ 95 */
94#define in_atomic_preempt_off() \ 96#define in_atomic_preempt_off() \
95 ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET) 97 ((preempt_count() & ~PREEMPT_ACTIVE) != PREEMPT_CHECK_OFFSET)
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index cb63da5c2139..6716ec808c5e 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -262,7 +262,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
262 * client handles for the extra addresses. 262 * client handles for the extra addresses.
263 */ 263 */
264extern struct i2c_client * 264extern struct i2c_client *
265i2c_new_dummy(struct i2c_adapter *adap, u16 address, const char *type); 265i2c_new_dummy(struct i2c_adapter *adap, u16 address);
266 266
267extern void i2c_unregister_device(struct i2c_client *); 267extern void i2c_unregister_device(struct i2c_client *);
268 268
diff --git a/include/linux/ide.h b/include/linux/ide.h
index b0135b0c3a04..f8f195c20da2 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -965,7 +965,6 @@ typedef struct ide_task_s {
965void ide_tf_dump(const char *, struct ide_taskfile *); 965void ide_tf_dump(const char *, struct ide_taskfile *);
966 966
967extern void SELECT_DRIVE(ide_drive_t *); 967extern void SELECT_DRIVE(ide_drive_t *);
968extern void SELECT_MASK(ide_drive_t *, int);
969 968
970extern int drive_is_ready(ide_drive_t *); 969extern int drive_is_ready(ide_drive_t *);
971 970
@@ -1058,8 +1057,8 @@ enum {
1058 IDE_HFLAG_NO_SET_MODE = (1 << 9), 1057 IDE_HFLAG_NO_SET_MODE = (1 << 9),
1059 /* trust BIOS for programming chipset/device for DMA */ 1058 /* trust BIOS for programming chipset/device for DMA */
1060 IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10), 1059 IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10),
1061 /* host uses VDMA (tied with IDE_HFLAG_CS5520 for now) */ 1060 /* host is CS5510/CS5520 */
1062 IDE_HFLAG_VDMA = (1 << 11), 1061 IDE_HFLAG_CS5520 = (1 << 11),
1063 /* ATAPI DMA is unsupported */ 1062 /* ATAPI DMA is unsupported */
1064 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), 1063 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12),
1065 /* set if host is a "non-bootable" controller */ 1064 /* set if host is a "non-bootable" controller */
@@ -1070,8 +1069,6 @@ enum {
1070 IDE_HFLAG_NO_AUTODMA = (1 << 15), 1069 IDE_HFLAG_NO_AUTODMA = (1 << 15),
1071 /* host uses MMIO */ 1070 /* host uses MMIO */
1072 IDE_HFLAG_MMIO = (1 << 16), 1071 IDE_HFLAG_MMIO = (1 << 16),
1073 /* host is CS5510/CS5520 */
1074 IDE_HFLAG_CS5520 = IDE_HFLAG_VDMA,
1075 /* no LBA48 */ 1072 /* no LBA48 */
1076 IDE_HFLAG_NO_LBA48 = (1 << 17), 1073 IDE_HFLAG_NO_LBA48 = (1 << 17),
1077 /* no LBA48 DMA */ 1074 /* no LBA48 DMA */
@@ -1101,6 +1098,8 @@ enum {
1101 IDE_HFLAG_NO_IO_32BIT = (1 << 30), 1098 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1102 /* never unmask IRQs */ 1099 /* never unmask IRQs */
1103 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31), 1100 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1101 /* host uses VDMA (disabled for now) */
1102 IDE_HFLAG_VDMA = 0,
1104}; 1103};
1105 1104
1106#ifdef CONFIG_BLK_DEV_OFFBOARD 1105#ifdef CONFIG_BLK_DEV_OFFBOARD
diff --git a/include/linux/io.h b/include/linux/io.h
index 3a03a3604cce..6c7f0ba0d5fa 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -65,5 +65,6 @@ void __iomem *devm_ioremap_nocache(struct device *dev, resource_size_t offset,
65void devm_iounmap(struct device *dev, void __iomem *addr); 65void devm_iounmap(struct device *dev, void __iomem *addr);
66int check_signature(const volatile void __iomem *io_addr, 66int check_signature(const volatile void __iomem *io_addr,
67 const unsigned char *signature, int length); 67 const unsigned char *signature, int length);
68void devm_ioremap_release(struct device *dev, void *res);
68 69
69#endif /* _LINUX_IO_H */ 70#endif /* _LINUX_IO_H */
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index 2a3bb1bb7433..f98a656b17e5 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -68,6 +68,20 @@ static inline int task_nice_ioprio(struct task_struct *task)
68} 68}
69 69
70/* 70/*
71 * This is for the case where the task hasn't asked for a specific IO class.
72 * Check for idle and rt task process, and return appropriate IO class.
73 */
74static inline int task_nice_ioclass(struct task_struct *task)
75{
76 if (task->policy == SCHED_IDLE)
77 return IOPRIO_CLASS_IDLE;
78 else if (task->policy == SCHED_FIFO || task->policy == SCHED_RR)
79 return IOPRIO_CLASS_RT;
80 else
81 return IOPRIO_CLASS_BE;
82}
83
84/*
71 * For inheritance, return the highest of the two given priorities 85 * For inheritance, return the highest of the two given priorities
72 */ 86 */
73extern int ioprio_best(unsigned short aprio, unsigned short bprio); 87extern int ioprio_best(unsigned short aprio, unsigned short bprio);
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 4d46e299afb5..792bf0aa779b 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -276,7 +276,17 @@ extern void print_hex_dump(const char *level, const char *prefix_str,
276 const void *buf, size_t len, bool ascii); 276 const void *buf, size_t len, bool ascii);
277extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type, 277extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
278 const void *buf, size_t len); 278 const void *buf, size_t len);
279#define hex_asc(x) "0123456789abcdef"[x] 279
280extern const char hex_asc[];
281#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
282#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
283
284static inline char *pack_hex_byte(char *buf, u8 byte)
285{
286 *buf++ = hex_asc_hi(byte);
287 *buf++ = hex_asc_lo(byte);
288 return buf;
289}
280 290
281#define pr_emerg(fmt, arg...) \ 291#define pr_emerg(fmt, arg...) \
282 printk(KERN_EMERG fmt, ##arg) 292 printk(KERN_EMERG fmt, ##arg)
diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
index 9757b1a6d9dc..6adcc297e354 100644
--- a/include/linux/kgdb.h
+++ b/include/linux/kgdb.h
@@ -261,10 +261,12 @@ struct kgdb_io {
261 261
262extern struct kgdb_arch arch_kgdb_ops; 262extern struct kgdb_arch arch_kgdb_ops;
263 263
264extern unsigned long __weak kgdb_arch_pc(int exception, struct pt_regs *regs);
265
264extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops); 266extern int kgdb_register_io_module(struct kgdb_io *local_kgdb_io_ops);
265extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops); 267extern void kgdb_unregister_io_module(struct kgdb_io *local_kgdb_io_ops);
266 268
267extern int kgdb_hex2long(char **ptr, long *long_val); 269extern int kgdb_hex2long(char **ptr, unsigned long *long_val);
268extern int kgdb_mem2hex(char *mem, char *buf, int count); 270extern int kgdb_mem2hex(char *mem, char *buf, int count);
269extern int kgdb_hex2mem(char *buf, char *mem, int count); 271extern int kgdb_hex2mem(char *buf, char *mem, int count);
270 272
diff --git a/include/linux/libata.h b/include/linux/libata.h
index d1dfe872ee30..0f17643e0a6e 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1039,6 +1039,7 @@ extern void ata_eh_thaw_port(struct ata_port *ap);
1039 1039
1040extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); 1040extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
1041extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); 1041extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
1042extern void ata_eh_analyze_ncq_error(struct ata_link *link);
1042 1043
1043extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset, 1044extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1044 ata_reset_fn_t softreset, ata_reset_fn_t hardreset, 1045 ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
@@ -1381,6 +1382,18 @@ static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
1381 return *(struct ata_port **)&host->hostdata[0]; 1382 return *(struct ata_port **)&host->hostdata[0];
1382} 1383}
1383 1384
1385static inline int ata_check_ready(u8 status)
1386{
1387 if (!(status & ATA_BUSY))
1388 return 1;
1389
1390 /* 0xff indicates either no device or device not ready */
1391 if (status == 0xff)
1392 return -ENODEV;
1393
1394 return 0;
1395}
1396
1384 1397
1385/************************************************************************** 1398/**************************************************************************
1386 * PMP - drivers/ata/libata-pmp.c 1399 * PMP - drivers/ata/libata-pmp.c
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index eb7c16cc9559..02a27ae78539 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -226,8 +226,17 @@ struct mm_struct {
226 rwlock_t ioctx_list_lock; /* aio lock */ 226 rwlock_t ioctx_list_lock; /* aio lock */
227 struct kioctx *ioctx_list; 227 struct kioctx *ioctx_list;
228#ifdef CONFIG_MM_OWNER 228#ifdef CONFIG_MM_OWNER
229 struct task_struct *owner; /* The thread group leader that */ 229 /*
230 /* owns the mm_struct. */ 230 * "owner" points to a task that is regarded as the canonical
231 * user/owner of this mm. All of the following must be true in
232 * order for it to be changed:
233 *
234 * current == mm->owner
235 * current->mm != mm
236 * new_owner->mm == mm
237 * new_owner->alloc_lock is held
238 */
239 struct task_struct *owner;
231#endif 240#endif
232 241
233#ifdef CONFIG_PROC_FS 242#ifdef CONFIG_PROC_FS
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index 30e11aa3c1c9..a15cdd4a8e58 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -1,19 +1,31 @@
1/* 1/*
2 * MV-643XX ethernet platform device data definition file. 2 * MV-643XX ethernet platform device data definition file.
3 */ 3 */
4
4#ifndef __LINUX_MV643XX_ETH_H 5#ifndef __LINUX_MV643XX_ETH_H
5#define __LINUX_MV643XX_ETH_H 6#define __LINUX_MV643XX_ETH_H
6 7
7#define MV643XX_ETH_SHARED_NAME "mv643xx_eth_shared" 8#include <linux/mbus.h>
8#define MV643XX_ETH_NAME "mv643xx_eth" 9
10#define MV643XX_ETH_SHARED_NAME "mv643xx_eth"
11#define MV643XX_ETH_NAME "mv643xx_eth_port"
9#define MV643XX_ETH_SHARED_REGS 0x2000 12#define MV643XX_ETH_SHARED_REGS 0x2000
10#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000 13#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000
11#define MV643XX_ETH_BAR_4 0x2220 14#define MV643XX_ETH_BAR_4 0x2220
12#define MV643XX_ETH_SIZE_REG_4 0x2224 15#define MV643XX_ETH_SIZE_REG_4 0x2224
13#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290 16#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290
14 17
18struct mv643xx_eth_shared_platform_data {
19 struct mbus_dram_target_info *dram;
20 unsigned int t_clk;
21};
22
15struct mv643xx_eth_platform_data { 23struct mv643xx_eth_platform_data {
24 struct platform_device *shared;
16 int port_number; 25 int port_number;
26
27 struct platform_device *shared_smi;
28
17 u16 force_phy_addr; /* force override if phy_addr == 0 */ 29 u16 force_phy_addr; /* force override if phy_addr == 0 */
18 u16 phy_addr; 30 u16 phy_addr;
19 31
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7c1d4466583b..b11e6e19e96c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -93,14 +93,16 @@ struct wireless_dev;
93 * used. 93 * used.
94 */ 94 */
95 95
96#if !defined(CONFIG_AX25) && !defined(CONFIG_AX25_MODULE) && !defined(CONFIG_TR) 96#if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
97#define LL_MAX_HEADER 32 97# if defined(CONFIG_MAC80211_MESH)
98# define LL_MAX_HEADER 128
99# else
100# define LL_MAX_HEADER 96
101# endif
102#elif defined(CONFIG_TR)
103# define LL_MAX_HEADER 48
98#else 104#else
99#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 105# define LL_MAX_HEADER 32
100#define LL_MAX_HEADER 96
101#else
102#define LL_MAX_HEADER 48
103#endif
104#endif 106#endif
105 107
106#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \ 108#if !defined(CONFIG_NET_IPIP) && !defined(CONFIG_NET_IPIP_MODULE) && \
@@ -244,11 +246,16 @@ struct hh_cache
244 * 246 *
245 * We could use other alignment values, but we must maintain the 247 * We could use other alignment values, but we must maintain the
246 * relationship HH alignment <= LL alignment. 248 * relationship HH alignment <= LL alignment.
249 *
250 * LL_ALLOCATED_SPACE also takes into account the tailroom the device
251 * may need.
247 */ 252 */
248#define LL_RESERVED_SPACE(dev) \ 253#define LL_RESERVED_SPACE(dev) \
249 (((dev)->hard_header_len&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) 254 ((((dev)->hard_header_len+(dev)->needed_headroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
250#define LL_RESERVED_SPACE_EXTRA(dev,extra) \ 255#define LL_RESERVED_SPACE_EXTRA(dev,extra) \
251 ((((dev)->hard_header_len+extra)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD) 256 ((((dev)->hard_header_len+(dev)->needed_headroom+(extra))&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
257#define LL_ALLOCATED_SPACE(dev) \
258 ((((dev)->hard_header_len+(dev)->needed_headroom+(dev)->needed_tailroom)&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
252 259
253struct header_ops { 260struct header_ops {
254 int (*create) (struct sk_buff *skb, struct net_device *dev, 261 int (*create) (struct sk_buff *skb, struct net_device *dev,
@@ -567,6 +574,13 @@ struct net_device
567 unsigned short type; /* interface hardware type */ 574 unsigned short type; /* interface hardware type */
568 unsigned short hard_header_len; /* hardware hdr length */ 575 unsigned short hard_header_len; /* hardware hdr length */
569 576
577 /* extra head- and tailroom the hardware may need, but not in all cases
578 * can this be guaranteed, especially tailroom. Some cases also use
579 * LL_MAX_HEADER instead to allocate the skb.
580 */
581 unsigned short needed_headroom;
582 unsigned short needed_tailroom;
583
570 struct net_device *master; /* Pointer to master device of a group, 584 struct net_device *master; /* Pointer to master device of a group,
571 * which this device is member of. 585 * which this device is member of.
572 */ 586 */
@@ -715,6 +729,9 @@ struct net_device
715 struct net *nd_net; 729 struct net *nd_net;
716#endif 730#endif
717 731
732 /* mid-layer private */
733 void *ml_priv;
734
718 /* bridge stuff */ 735 /* bridge stuff */
719 struct net_bridge_port *br_port; 736 struct net_bridge_port *br_port;
720 /* macvlan */ 737 /* macvlan */
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index 5da04e586a3f..23aa2ec6b7b7 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -7,6 +7,7 @@
7 7
8struct nf_ct_sip_master { 8struct nf_ct_sip_master {
9 unsigned int register_cseq; 9 unsigned int register_cseq;
10 unsigned int invite_cseq;
10}; 11};
11 12
12enum sip_expectation_classes { 13enum sip_expectation_classes {
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
index 2e5a96732042..bd2a870ec296 100644
--- a/include/linux/of_i2c.h
+++ b/include/linux/of_i2c.h
@@ -14,11 +14,7 @@
14 14
15#include <linux/i2c.h> 15#include <linux/i2c.h>
16 16
17#ifdef CONFIG_OF_I2C
18
19void of_register_i2c_devices(struct i2c_adapter *adap, 17void of_register_i2c_devices(struct i2c_adapter *adap,
20 struct device_node *adap_node); 18 struct device_node *adap_node);
21 19
22#endif /* CONFIG_OF_I2C */
23
24#endif /* __LINUX_OF_I2C_H */ 20#endif /* __LINUX_OF_I2C_H */
diff --git a/include/linux/parser.h b/include/linux/parser.h
index 26b2bdfcaf06..7dcd05075756 100644
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -29,5 +29,5 @@ int match_token(char *, match_table_t table, substring_t args[]);
29int match_int(substring_t *, int *result); 29int match_int(substring_t *, int *result);
30int match_octal(substring_t *, int *result); 30int match_octal(substring_t *, int *result);
31int match_hex(substring_t *, int *result); 31int match_hex(substring_t *, int *result);
32void match_strcpy(char *, const substring_t *); 32size_t match_strlcpy(char *, const substring_t *, size_t);
33char *match_strdup(const substring_t *); 33char *match_strdup(const substring_t *);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 96acd0dae241..509159bcd4e7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -44,6 +44,7 @@
44#include <linux/mod_devicetable.h> 44#include <linux/mod_devicetable.h>
45 45
46#include <linux/types.h> 46#include <linux/types.h>
47#include <linux/init.h>
47#include <linux/ioport.h> 48#include <linux/ioport.h>
48#include <linux/list.h> 49#include <linux/list.h>
49#include <linux/compiler.h> 50#include <linux/compiler.h>
@@ -474,7 +475,7 @@ extern struct pci_bus *pci_find_bus(int domain, int busnr);
474void pci_bus_add_devices(struct pci_bus *bus); 475void pci_bus_add_devices(struct pci_bus *bus);
475struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, 476struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
476 struct pci_ops *ops, void *sysdata); 477 struct pci_ops *ops, void *sysdata);
477static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, 478static inline struct pci_bus * __devinit pci_scan_bus(int bus, struct pci_ops *ops,
478 void *sysdata) 479 void *sysdata)
479{ 480{
480 struct pci_bus *root_bus; 481 struct pci_bus *root_bus;
@@ -666,7 +667,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
666 667
667void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 668void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
668 void *userdata); 669 void *userdata);
669int pci_cfg_space_size_ext(struct pci_dev *dev, unsigned check_exp_pcix); 670int pci_cfg_space_size_ext(struct pci_dev *dev);
670int pci_cfg_space_size(struct pci_dev *dev); 671int pci_cfg_space_size(struct pci_dev *dev);
671unsigned char pci_bus_max_busnr(struct pci_bus *bus); 672unsigned char pci_bus_max_busnr(struct pci_bus *bus);
672 673
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index d746a2abb322..4cdd393e71e1 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -13,8 +13,14 @@
13 __attribute__((__section__(".data.percpu"))) \ 13 __attribute__((__section__(".data.percpu"))) \
14 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name 14 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
15 15
16#ifdef MODULE
17#define SHARED_ALIGNED_SECTION ".data.percpu"
18#else
19#define SHARED_ALIGNED_SECTION ".data.percpu.shared_aligned"
20#endif
21
16#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ 22#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
17 __attribute__((__section__(".data.percpu.shared_aligned"))) \ 23 __attribute__((__section__(SHARED_ALIGNED_SECTION))) \
18 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \ 24 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \
19 ____cacheline_aligned_in_smp 25 ____cacheline_aligned_in_smp
20#else 26#else
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 02df20f085fe..7224c4099a28 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -412,6 +412,8 @@ int mdiobus_register(struct mii_bus *bus);
412void mdiobus_unregister(struct mii_bus *bus); 412void mdiobus_unregister(struct mii_bus *bus);
413void phy_sanitize_settings(struct phy_device *phydev); 413void phy_sanitize_settings(struct phy_device *phydev);
414int phy_stop_interrupts(struct phy_device *phydev); 414int phy_stop_interrupts(struct phy_device *phydev);
415int phy_enable_interrupts(struct phy_device *phydev);
416int phy_disable_interrupts(struct phy_device *phydev);
415 417
416static inline int phy_read_status(struct phy_device *phydev) { 418static inline int phy_read_status(struct phy_device *phydev) {
417 return phydev->drv->read_status(phydev); 419 return phydev->drv->read_status(phydev);
@@ -447,5 +449,8 @@ int phy_register_fixup_for_uid(u32 phy_uid, u32 phy_uid_mask,
447 int (*run)(struct phy_device *)); 449 int (*run)(struct phy_device *));
448int phy_scan_fixups(struct phy_device *phydev); 450int phy_scan_fixups(struct phy_device *phydev);
449 451
452int __init mdio_bus_init(void);
453void mdio_bus_exit(void);
454
450extern struct bus_type mdio_bus_type; 455extern struct bus_type mdio_bus_type;
451#endif /* __PHY_H */ 456#endif /* __PHY_H */
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index 8082d6587a0f..d42dbec06083 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -131,18 +131,6 @@ struct rcu_head {
131 */ 131 */
132#define rcu_read_unlock_bh() __rcu_read_unlock_bh() 132#define rcu_read_unlock_bh() __rcu_read_unlock_bh()
133 133
134/*
135 * Prevent the compiler from merging or refetching accesses. The compiler
136 * is also forbidden from reordering successive instances of ACCESS_ONCE(),
137 * but only when the compiler is aware of some particular ordering. One way
138 * to make the compiler aware of ordering is to put the two invocations of
139 * ACCESS_ONCE() in different C statements.
140 *
141 * This macro does absolutely -nothing- to prevent the CPU from reordering,
142 * merging, or refetching absolutely anything at any time.
143 */
144#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
145
146/** 134/**
147 * rcu_dereference - fetch an RCU-protected pointer in an 135 * rcu_dereference - fetch an RCU-protected pointer in an
148 * RCU read-side critical section. This pointer may later 136 * RCU read-side critical section. This pointer may later
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 03c238088aee..5395a6176f4b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -158,6 +158,8 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
158} 158}
159#endif 159#endif
160 160
161extern unsigned long long time_sync_thresh;
162
161/* 163/*
162 * Task state bitmask. NOTE! These bits are also 164 * Task state bitmask. NOTE! These bits are also
163 * encoded in fs/proc/array.c: get_task_state(). 165 * encoded in fs/proc/array.c: get_task_state().
@@ -1551,6 +1553,35 @@ static inline int set_cpus_allowed(struct task_struct *p, cpumask_t new_mask)
1551 1553
1552extern unsigned long long sched_clock(void); 1554extern unsigned long long sched_clock(void);
1553 1555
1556#ifndef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
1557static inline void sched_clock_init(void)
1558{
1559}
1560
1561static inline u64 sched_clock_cpu(int cpu)
1562{
1563 return sched_clock();
1564}
1565
1566static inline void sched_clock_tick(void)
1567{
1568}
1569
1570static inline void sched_clock_idle_sleep_event(void)
1571{
1572}
1573
1574static inline void sched_clock_idle_wakeup_event(u64 delta_ns)
1575{
1576}
1577#else
1578extern void sched_clock_init(void);
1579extern u64 sched_clock_cpu(int cpu);
1580extern void sched_clock_tick(void);
1581extern void sched_clock_idle_sleep_event(void);
1582extern void sched_clock_idle_wakeup_event(u64 delta_ns);
1583#endif
1584
1554/* 1585/*
1555 * For kernel-internal use: high-speed (but slightly incorrect) per-cpu 1586 * For kernel-internal use: high-speed (but slightly incorrect) per-cpu
1556 * clock constructed from sched_clock(): 1587 * clock constructed from sched_clock():
@@ -1977,6 +2008,11 @@ static inline void clear_tsk_need_resched(struct task_struct *tsk)
1977 clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED); 2008 clear_tsk_thread_flag(tsk,TIF_NEED_RESCHED);
1978} 2009}
1979 2010
2011static inline int test_tsk_need_resched(struct task_struct *tsk)
2012{
2013 return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED));
2014}
2015
1980static inline int signal_pending(struct task_struct *p) 2016static inline int signal_pending(struct task_struct *p)
1981{ 2017{
1982 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); 2018 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
@@ -2001,13 +2037,13 @@ static inline int need_resched(void)
2001 * cond_resched_lock() will drop the spinlock before scheduling, 2037 * cond_resched_lock() will drop the spinlock before scheduling,
2002 * cond_resched_softirq() will enable bhs before scheduling. 2038 * cond_resched_softirq() will enable bhs before scheduling.
2003 */ 2039 */
2004#ifdef CONFIG_PREEMPT 2040extern int _cond_resched(void);
2041#ifdef CONFIG_PREEMPT_BKL
2005static inline int cond_resched(void) 2042static inline int cond_resched(void)
2006{ 2043{
2007 return 0; 2044 return 0;
2008} 2045}
2009#else 2046#else
2010extern int _cond_resched(void);
2011static inline int cond_resched(void) 2047static inline int cond_resched(void)
2012{ 2048{
2013 return _cond_resched(); 2049 return _cond_resched();
@@ -2015,6 +2051,10 @@ static inline int cond_resched(void)
2015#endif 2051#endif
2016extern int cond_resched_lock(spinlock_t * lock); 2052extern int cond_resched_lock(spinlock_t * lock);
2017extern int cond_resched_softirq(void); 2053extern int cond_resched_softirq(void);
2054static inline int cond_resched_bkl(void)
2055{
2056 return _cond_resched();
2057}
2018 2058
2019/* 2059/*
2020 * Does a critical section need to be broken due to another 2060 * Does a critical section need to be broken due to another
diff --git a/include/linux/usb/association.h b/include/linux/usb/association.h
new file mode 100644
index 000000000000..07c5e3cf5898
--- /dev/null
+++ b/include/linux/usb/association.h
@@ -0,0 +1,150 @@
1/*
2 * Wireless USB - Cable Based Association
3 *
4 * Copyright (C) 2006 Intel Corporation
5 * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version
9 * 2 as published by the Free Software Foundation.
10 *
11 */
12#ifndef __LINUX_USB_ASSOCIATION_H
13#define __LINUX_USB_ASSOCIATION_H
14
15
16/*
17 * Association attributes
18 *
19 * Association Models Supplement to WUSB 1.0 T[3-1]
20 *
21 * Each field in the structures has it's ID, it's length and then the
22 * value. This is the actual definition of the field's ID and its
23 * length.
24 */
25struct wusb_am_attr {
26 __u8 id;
27 __u8 len;
28};
29
30/* Different fields defined by the spec */
31#define WUSB_AR_AssociationTypeId { .id = 0x0000, .len = 2 }
32#define WUSB_AR_AssociationSubTypeId { .id = 0x0001, .len = 2 }
33#define WUSB_AR_Length { .id = 0x0002, .len = 4 }
34#define WUSB_AR_AssociationStatus { .id = 0x0004, .len = 4 }
35#define WUSB_AR_LangID { .id = 0x0008, .len = 2 }
36#define WUSB_AR_DeviceFriendlyName { .id = 0x000b, .len = 64 } /* max */
37#define WUSB_AR_HostFriendlyName { .id = 0x000c, .len = 64 } /* max */
38#define WUSB_AR_CHID { .id = 0x1000, .len = 16 }
39#define WUSB_AR_CDID { .id = 0x1001, .len = 16 }
40#define WUSB_AR_ConnectionContext { .id = 0x1002, .len = 48 }
41#define WUSB_AR_BandGroups { .id = 0x1004, .len = 2 }
42
43/* CBAF Control Requests (AMS1.0[T4-1] */
44enum {
45 CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01,
46 CBAF_REQ_GET_ASSOCIATION_REQUEST,
47 CBAF_REQ_SET_ASSOCIATION_RESPONSE
48};
49
50/*
51 * CBAF USB-interface defitions
52 *
53 * No altsettings, one optional interrupt endpoint.
54 */
55enum {
56 CBAF_IFACECLASS = 0xef,
57 CBAF_IFACESUBCLASS = 0x03,
58 CBAF_IFACEPROTOCOL = 0x01,
59};
60
61/* Association Information (AMS1.0[T4-3]) */
62struct wusb_cbaf_assoc_info {
63 __le16 Length;
64 __u8 NumAssociationRequests;
65 __le16 Flags;
66 __u8 AssociationRequestsArray[];
67} __attribute__((packed));
68
69/* Association Request (AMS1.0[T4-4]) */
70struct wusb_cbaf_assoc_request {
71 __u8 AssociationDataIndex;
72 __u8 Reserved;
73 __le16 AssociationTypeId;
74 __le16 AssociationSubTypeId;
75 __le32 AssociationTypeInfoSize;
76} __attribute__((packed));
77
78enum {
79 AR_TYPE_WUSB = 0x0001,
80 AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000,
81 AR_TYPE_WUSB_ASSOCIATE = 0x0001,
82};
83
84/* Association Attribute header (AMS1.0[3.8]) */
85struct wusb_cbaf_attr_hdr {
86 __le16 id;
87 __le16 len;
88} __attribute__((packed));
89
90/* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */
91struct wusb_cbaf_host_info {
92 struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
93 __le16 AssociationTypeId;
94 struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
95 __le16 AssociationSubTypeId;
96 struct wusb_cbaf_attr_hdr CHID_hdr;
97 struct wusb_ckhdid CHID;
98 struct wusb_cbaf_attr_hdr LangID_hdr;
99 __le16 LangID;
100 struct wusb_cbaf_attr_hdr HostFriendlyName_hdr;
101 __u8 HostFriendlyName[];
102} __attribute__((packed));
103
104/* Device Info (AMS1.0[T4-8])
105 *
106 * I still don't get this tag'n'header stuff for each goddamn
107 * field...
108 */
109struct wusb_cbaf_device_info {
110 struct wusb_cbaf_attr_hdr Length_hdr;
111 __le32 Length;
112 struct wusb_cbaf_attr_hdr CDID_hdr;
113 struct wusb_ckhdid CDID;
114 struct wusb_cbaf_attr_hdr BandGroups_hdr;
115 __le16 BandGroups;
116 struct wusb_cbaf_attr_hdr LangID_hdr;
117 __le16 LangID;
118 struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr;
119 __u8 DeviceFriendlyName[];
120} __attribute__((packed));
121
122/* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */
123struct wusb_cbaf_cc_data {
124 struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
125 __le16 AssociationTypeId;
126 struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
127 __le16 AssociationSubTypeId;
128 struct wusb_cbaf_attr_hdr Length_hdr;
129 __le32 Length;
130 struct wusb_cbaf_attr_hdr ConnectionContext_hdr;
131 struct wusb_ckhdid CHID;
132 struct wusb_ckhdid CDID;
133 struct wusb_ckhdid CK;
134 struct wusb_cbaf_attr_hdr BandGroups_hdr;
135 __le16 BandGroups;
136} __attribute__((packed));
137
138/* CC_DATA - Failure case (AMS1.0[T4-10]) */
139struct wusb_cbaf_cc_data_fail {
140 struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
141 __le16 AssociationTypeId;
142 struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
143 __le16 AssociationSubTypeId;
144 struct wusb_cbaf_attr_hdr Length_hdr;
145 __le16 Length;
146 struct wusb_cbaf_attr_hdr AssociationStatus_hdr;
147 __u32 AssociationStatus;
148} __attribute__((packed));
149
150#endif /* __LINUX_USB_ASSOCIATION_H */
diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
index 4d0909e53595..79b9837d9ca0 100644
--- a/include/linux/vermagic.h
+++ b/include/linux/vermagic.h
@@ -17,6 +17,11 @@
17#else 17#else
18#define MODULE_VERMAGIC_MODULE_UNLOAD "" 18#define MODULE_VERMAGIC_MODULE_UNLOAD ""
19#endif 19#endif
20#ifdef CONFIG_MODVERSIONS
21#define MODULE_VERMAGIC_MODVERSIONS "modversions "
22#else
23#define MODULE_VERMAGIC_MODVERSIONS ""
24#endif
20#ifndef MODULE_ARCH_VERMAGIC 25#ifndef MODULE_ARCH_VERMAGIC
21#define MODULE_ARCH_VERMAGIC "" 26#define MODULE_ARCH_VERMAGIC ""
22#endif 27#endif
@@ -24,5 +29,6 @@
24#define VERMAGIC_STRING \ 29#define VERMAGIC_STRING \
25 UTS_RELEASE " " \ 30 UTS_RELEASE " " \
26 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \ 31 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
27 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_ARCH_VERMAGIC 32 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
33 MODULE_ARCH_VERMAGIC
28 34
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h
index 347b6f8beb23..878562278b67 100644
--- a/include/media/v4l2-i2c-drv-legacy.h
+++ b/include/media/v4l2-i2c-drv-legacy.h
@@ -31,6 +31,7 @@ struct v4l2_i2c_driver_data {
31 int (*resume)(struct i2c_client *client); 31 int (*resume)(struct i2c_client *client);
32 int (*legacy_probe)(struct i2c_adapter *adapter); 32 int (*legacy_probe)(struct i2c_adapter *adapter);
33 int legacy_class; 33 int legacy_class;
34 const struct i2c_device_id *id_table;
34}; 35};
35 36
36static struct v4l2_i2c_driver_data v4l2_i2c_data; 37static struct v4l2_i2c_driver_data v4l2_i2c_data;
@@ -124,6 +125,7 @@ static int __init v4l2_i2c_drv_init(void)
124 v4l2_i2c_driver.command = v4l2_i2c_data.command; 125 v4l2_i2c_driver.command = v4l2_i2c_data.command;
125 v4l2_i2c_driver.probe = v4l2_i2c_data.probe; 126 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
126 v4l2_i2c_driver.remove = v4l2_i2c_data.remove; 127 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
128 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
127 err = i2c_add_driver(&v4l2_i2c_driver); 129 err = i2c_add_driver(&v4l2_i2c_driver);
128 if (err) 130 if (err)
129 i2c_del_driver(&v4l2_i2c_driver_legacy); 131 i2c_del_driver(&v4l2_i2c_driver_legacy);
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
index 7b6f06be7950..40ecef29801d 100644
--- a/include/media/v4l2-i2c-drv.h
+++ b/include/media/v4l2-i2c-drv.h
@@ -36,6 +36,7 @@ struct v4l2_i2c_driver_data {
36 int (*resume)(struct i2c_client *client); 36 int (*resume)(struct i2c_client *client);
37 int (*legacy_probe)(struct i2c_adapter *adapter); 37 int (*legacy_probe)(struct i2c_adapter *adapter);
38 int legacy_class; 38 int legacy_class;
39 const struct i2c_device_id *id_table;
39}; 40};
40 41
41static struct v4l2_i2c_driver_data v4l2_i2c_data; 42static struct v4l2_i2c_driver_data v4l2_i2c_data;
@@ -53,6 +54,7 @@ static int __init v4l2_i2c_drv_init(void)
53 v4l2_i2c_driver.remove = v4l2_i2c_data.remove; 54 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
54 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend; 55 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend;
55 v4l2_i2c_driver.resume = v4l2_i2c_data.resume; 56 v4l2_i2c_driver.resume = v4l2_i2c_data.resume;
57 v4l2_i2c_driver.id_table = v4l2_i2c_data.id_table;
56 return i2c_add_driver(&v4l2_i2c_driver); 58 return i2c_add_driver(&v4l2_i2c_driver);
57} 59}
58 60
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h
index 585eb4496990..b3d3e27c6299 100644
--- a/include/net/9p/9p.h
+++ b/include/net/9p/9p.h
@@ -29,14 +29,31 @@
29 29
30#ifdef CONFIG_NET_9P_DEBUG 30#ifdef CONFIG_NET_9P_DEBUG
31 31
32#define P9_DEBUG_ERROR (1<<0) 32/**
33#define P9_DEBUG_9P (1<<2) 33 * enum p9_debug_flags - bits for mount time debug parameter
34#define P9_DEBUG_VFS (1<<3) 34 * @P9_DEBUG_ERROR: more verbose error messages including original error string
35#define P9_DEBUG_CONV (1<<4) 35 * @P9_DEBUG_9P: 9P protocol tracing
36#define P9_DEBUG_MUX (1<<5) 36 * @P9_DEBUG_VFS: VFS API tracing
37#define P9_DEBUG_TRANS (1<<6) 37 * @P9_DEBUG_CONV: protocol conversion tracing
38#define P9_DEBUG_SLABS (1<<7) 38 * @P9_DEBUG_MUX: trace management of concurrent transactions
39#define P9_DEBUG_FCALL (1<<8) 39 * @P9_DEBUG_TRANS: transport tracing
40 * @P9_DEBUG_SLABS: memory management tracing
41 * @P9_DEBUG_FCALL: verbose dump of protocol messages
42 *
43 * These flags are passed at mount time to turn on various levels of
44 * verbosity and tracing which will be output to the system logs.
45 */
46
47enum p9_debug_flags {
48 P9_DEBUG_ERROR = (1<<0),
49 P9_DEBUG_9P = (1<<2),
50 P9_DEBUG_VFS = (1<<3),
51 P9_DEBUG_CONV = (1<<4),
52 P9_DEBUG_MUX = (1<<5),
53 P9_DEBUG_TRANS = (1<<6),
54 P9_DEBUG_SLABS = (1<<7),
55 P9_DEBUG_FCALL = (1<<8),
56};
40 57
41extern unsigned int p9_debug_level; 58extern unsigned int p9_debug_level;
42 59
@@ -62,9 +79,47 @@ do { \
62 format , __FUNCTION__, task_pid_nr(current), ## arg); \ 79 format , __FUNCTION__, task_pid_nr(current), ## arg); \
63} while (0) 80} while (0)
64 81
82/**
83 * enum p9_msg_t - 9P message types
84 * @P9_TVERSION: version handshake request
85 * @P9_RVERSION: version handshake response
86 * @P9_TAUTH: request to establish authentication channel
87 * @P9_RAUTH: response with authentication information
88 * @P9_TATTACH: establish user access to file service
89 * @P9_RATTACH: response with top level handle to file hierarchy
90 * @P9_TERROR: not used
91 * @P9_RERROR: response for any failed request
92 * @P9_TFLUSH: request to abort a previous request
93 * @P9_RFLUSH: response when previous request has been cancelled
94 * @P9_TWALK: descend a directory hierarchy
95 * @P9_RWALK: response with new handle for position within hierarchy
96 * @P9_TOPEN: prepare a handle for I/O on an existing file
97 * @P9_ROPEN: response with file access information
98 * @P9_TCREATE: prepare a handle for I/O on a new file
99 * @P9_RCREATE: response with file access information
100 * @P9_TREAD: request to transfer data from a file or directory
101 * @P9_RREAD: response with data requested
102 * @P9_TWRITE: reuqest to transfer data to a file
103 * @P9_RWRITE: response with out much data was transfered to file
104 * @P9_TCLUNK: forget about a handle to an entity within the file system
105 * @P9_RCLUNK: response when server has forgotten about the handle
106 * @P9_TREMOVE: request to remove an entity from the hierarchy
107 * @P9_RREMOVE: response when server has removed the entity
108 * @P9_TSTAT: request file entity attributes
109 * @P9_RSTAT: response with file entity attributes
110 * @P9_TWSTAT: request to update file entity attributes
111 * @P9_RWSTAT: response when file entity attributes are updated
112 *
113 * There are 14 basic operations in 9P2000, paired as
114 * requests and responses. The one special case is ERROR
115 * as there is no @P9_TERROR request for clients to transmit to
116 * the server, but the server may respond to any other request
117 * with an @P9_RERROR.
118 *
119 * See Also: http://plan9.bell-labs.com/sys/man/5/INDEX.html
120 */
65 121
66/* Message Types */ 122enum p9_msg_t {
67enum {
68 P9_TVERSION = 100, 123 P9_TVERSION = 100,
69 P9_RVERSION, 124 P9_RVERSION,
70 P9_TAUTH = 102, 125 P9_TAUTH = 102,
@@ -95,30 +150,71 @@ enum {
95 P9_RWSTAT, 150 P9_RWSTAT,
96}; 151};
97 152
98/* open modes */ 153/**
99enum { 154 * enum p9_open_mode_t - 9P open modes
155 * @P9_OREAD: open file for reading only
156 * @P9_OWRITE: open file for writing only
157 * @P9_ORDWR: open file for reading or writing
158 * @P9_OEXEC: open file for execution
159 * @P9_OTRUNC: truncate file to zero-length before opening it
160 * @P9_OREXEC: close the file when an exec(2) system call is made
161 * @P9_ORCLOSE: remove the file when the file is closed
162 * @P9_OAPPEND: open the file and seek to the end
163 * @P9_OEXCL: only create a file, do not open it
164 *
165 * 9P open modes differ slightly from Posix standard modes.
166 * In particular, there are extra modes which specify different
167 * semantic behaviors than may be available on standard Posix
168 * systems. For example, @P9_OREXEC and @P9_ORCLOSE are modes that
169 * most likely will not be issued from the Linux VFS client, but may
170 * be supported by servers.
171 *
172 * See Also: http://plan9.bell-labs.com/magic/man2html/2/open
173 */
174
175enum p9_open_mode_t {
100 P9_OREAD = 0x00, 176 P9_OREAD = 0x00,
101 P9_OWRITE = 0x01, 177 P9_OWRITE = 0x01,
102 P9_ORDWR = 0x02, 178 P9_ORDWR = 0x02,
103 P9_OEXEC = 0x03, 179 P9_OEXEC = 0x03,
104 P9_OEXCL = 0x04,
105 P9_OTRUNC = 0x10, 180 P9_OTRUNC = 0x10,
106 P9_OREXEC = 0x20, 181 P9_OREXEC = 0x20,
107 P9_ORCLOSE = 0x40, 182 P9_ORCLOSE = 0x40,
108 P9_OAPPEND = 0x80, 183 P9_OAPPEND = 0x80,
109}; 184 P9_OEXCL = 0x1000,
110 185};
111/* permissions */ 186
112enum { 187/**
188 * enum p9_perm_t - 9P permissions
189 * @P9_DMDIR: mode bite for directories
190 * @P9_DMAPPEND: mode bit for is append-only
191 * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed)
192 * @P9_DMMOUNT: mode bite for mount points
193 * @P9_DMAUTH: mode bit for authentication file
194 * @P9_DMTMP: mode bit for non-backed-up files
195 * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u)
196 * @P9_DMLINK: mode bit for hard-link (9P2000.u)
197 * @P9_DMDEVICE: mode bit for device files (9P2000.u)
198 * @P9_DMNAMEDPIPE: mode bit for named pipe (9P2000.u)
199 * @P9_DMSOCKET: mode bit for socket (9P2000.u)
200 * @P9_DMSETUID: mode bit for setuid (9P2000.u)
201 * @P9_DMSETGID: mode bit for setgid (9P2000.u)
202 * @P9_DMSETVTX: mode bit for sticky bit (9P2000.u)
203 *
204 * 9P permissions differ slightly from Posix standard modes.
205 *
206 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
207 */
208enum p9_perm_t {
113 P9_DMDIR = 0x80000000, 209 P9_DMDIR = 0x80000000,
114 P9_DMAPPEND = 0x40000000, 210 P9_DMAPPEND = 0x40000000,
115 P9_DMEXCL = 0x20000000, 211 P9_DMEXCL = 0x20000000,
116 P9_DMMOUNT = 0x10000000, 212 P9_DMMOUNT = 0x10000000,
117 P9_DMAUTH = 0x08000000, 213 P9_DMAUTH = 0x08000000,
118 P9_DMTMP = 0x04000000, 214 P9_DMTMP = 0x04000000,
215/* 9P2000.u extensions */
119 P9_DMSYMLINK = 0x02000000, 216 P9_DMSYMLINK = 0x02000000,
120 P9_DMLINK = 0x01000000, 217 P9_DMLINK = 0x01000000,
121 /* 9P2000.u extensions */
122 P9_DMDEVICE = 0x00800000, 218 P9_DMDEVICE = 0x00800000,
123 P9_DMNAMEDPIPE = 0x00200000, 219 P9_DMNAMEDPIPE = 0x00200000,
124 P9_DMSOCKET = 0x00100000, 220 P9_DMSOCKET = 0x00100000,
@@ -127,8 +223,26 @@ enum {
127 P9_DMSETVTX = 0x00010000, 223 P9_DMSETVTX = 0x00010000,
128}; 224};
129 225
130/* qid.types */ 226/**
131enum { 227 * enum p9_qid_t - QID types
228 * @P9_QTDIR: directory
229 * @P9_QTAPPEND: append-only
230 * @P9_QTEXCL: excluse use (only one open handle allowed)
231 * @P9_QTMOUNT: mount points
232 * @P9_QTAUTH: authentication file
233 * @P9_QTTMP: non-backed-up files
234 * @P9_QTSYMLINK: symbolic links (9P2000.u)
235 * @P9_QTLINK: hard-link (9P2000.u)
236 * @P9_QTFILE: normal files
237 *
238 * QID types are a subset of permissions - they are primarily
239 * used to differentiate semantics for a file system entity via
240 * a jump-table. Their value is also the most signifigant 16 bits
241 * of the permission_t
242 *
243 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
244 */
245enum p9_qid_t {
132 P9_QTDIR = 0x80, 246 P9_QTDIR = 0x80,
133 P9_QTAPPEND = 0x40, 247 P9_QTAPPEND = 0x40,
134 P9_QTEXCL = 0x20, 248 P9_QTEXCL = 0x20,
@@ -140,6 +254,7 @@ enum {
140 P9_QTFILE = 0x00, 254 P9_QTFILE = 0x00,
141}; 255};
142 256
257/* 9P Magic Numbers */
143#define P9_NOTAG (u16)(~0) 258#define P9_NOTAG (u16)(~0)
144#define P9_NOFID (u32)(~0) 259#define P9_NOFID (u32)(~0)
145#define P9_MAXWELEM 16 260#define P9_MAXWELEM 16
@@ -147,19 +262,69 @@ enum {
147/* ample room for Twrite/Rread header */ 262/* ample room for Twrite/Rread header */
148#define P9_IOHDRSZ 24 263#define P9_IOHDRSZ 24
149 264
265/**
266 * struct p9_str - length prefixed string type
267 * @len: length of the string
268 * @str: the string
269 *
270 * The protocol uses length prefixed strings for all
271 * string data, so we replicate that for our internal
272 * string members.
273 */
274
150struct p9_str { 275struct p9_str {
151 u16 len; 276 u16 len;
152 char *str; 277 char *str;
153}; 278};
154 279
155/* qids are the unique ID for a file (like an inode */ 280/**
281 * struct p9_qid - file system entity information
282 * @type: 8-bit type &p9_qid_t
283 * @version: 16-bit monotonically incrementing version number
284 * @path: 64-bit per-server-unique ID for a file system element
285 *
286 * qids are identifiers used by 9P servers to track file system
287 * entities. The type is used to differentiate semantics for operations
288 * on the entity (ie. read means something different on a directory than
289 * on a file). The path provides a server unique index for an entity
290 * (roughly analogous to an inode number), while the version is updated
291 * every time a file is modified and can be used to maintain cache
292 * coherency between clients and serves.
293 * Servers will often differentiate purely synthetic entities by setting
294 * their version to 0, signaling that they should never be cached and
295 * should be accessed synchronously.
296 *
297 * See Also://plan9.bell-labs.com/magic/man2html/2/stat
298 */
299
156struct p9_qid { 300struct p9_qid {
157 u8 type; 301 u8 type;
158 u32 version; 302 u32 version;
159 u64 path; 303 u64 path;
160}; 304};
161 305
162/* Plan 9 file metadata (stat) structure */ 306/**
307 * struct p9_stat - file system metadata information
308 * @size: length prefix for this stat structure instance
309 * @type: the type of the server (equivilent to a major number)
310 * @dev: the sub-type of the server (equivilent to a minor number)
311 * @qid: unique id from the server of type &p9_qid
312 * @mode: Plan 9 format permissions of type &p9_perm_t
313 * @atime: Last access/read time
314 * @mtime: Last modify/write time
315 * @length: file length
316 * @name: last element of path (aka filename) in type &p9_str
317 * @uid: owner name in type &p9_str
318 * @gid: group owner in type &p9_str
319 * @muid: last modifier in type &p9_str
320 * @extension: area used to encode extended UNIX support in type &p9_str
321 * @n_uid: numeric user id of owner (part of 9p2000.u extension)
322 * @n_gid: numeric group id (part of 9p2000.u extension)
323 * @n_muid: numeric user id of laster modifier (part of 9p2000.u extension)
324 *
325 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
326 */
327
163struct p9_stat { 328struct p9_stat {
164 u16 size; 329 u16 size;
165 u16 type; 330 u16 type;
@@ -179,10 +344,14 @@ struct p9_stat {
179 u32 n_muid; /* 9p2000.u extensions */ 344 u32 n_muid; /* 9p2000.u extensions */
180}; 345};
181 346
182/* file metadata (stat) structure used to create Twstat message 347/*
183 The is similar to p9_stat, but the strings don't point to 348 * file metadata (stat) structure used to create Twstat message
184 the same memory block and should be freed separately 349 * The is identical to &p9_stat, but the strings don't point to
185*/ 350 * the same memory block and should be freed separately
351 *
352 * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat
353 */
354
186struct p9_wstat { 355struct p9_wstat {
187 u16 size; 356 u16 size;
188 u16 type; 357 u16 type;
@@ -335,10 +504,20 @@ struct p9_twstat {
335struct p9_rwstat { 504struct p9_rwstat {
336}; 505};
337 506
338/* 507/**
339 * fcall is the primary packet structure 508 * struct p9_fcall - primary packet structure
340 * 509 * @size: prefixed length of the structure
341 */ 510 * @id: protocol operating identifier of type &p9_msg_t
511 * @tag: transaction id of the request
512 * @sdata: payload
513 * @params: per-operation parameters
514 *
515 * &p9_fcall represents the structure for all 9P RPC
516 * transactions. Requests are packaged into fcalls, and reponses
517 * must be extracted from them.
518 *
519 * See Also: http://plan9.bell-labs.com/magic/man2html/2/fcall
520 */
342 521
343struct p9_fcall { 522struct p9_fcall {
344 u32 size; 523 u32 size;
@@ -416,4 +595,5 @@ int p9_idpool_check(int id, struct p9_idpool *p);
416 595
417int p9_error_init(void); 596int p9_error_init(void);
418int p9_errstr2errno(char *, int); 597int p9_errstr2errno(char *, int);
598int p9_trans_fd_init(void);
419#endif /* NET_9P_H */ 599#endif /* NET_9P_H */
diff --git a/include/net/9p/client.h b/include/net/9p/client.h
index e52f93d9ac5f..c936dd14de41 100644
--- a/include/net/9p/client.h
+++ b/include/net/9p/client.h
@@ -26,6 +26,23 @@
26#ifndef NET_9P_CLIENT_H 26#ifndef NET_9P_CLIENT_H
27#define NET_9P_CLIENT_H 27#define NET_9P_CLIENT_H
28 28
29/**
30 * struct p9_client - per client instance state
31 * @lock: protect @fidlist
32 * @msize: maximum data size negotiated by protocol
33 * @dotu: extension flags negotiated by protocol
34 * @trans_mod: module API instantiated with this client
35 * @trans: tranport instance state and API
36 * @conn: connection state information used by trans_fd
37 * @fidpool: fid handle accounting for session
38 * @fidlist: List of active fid handles
39 *
40 * The client structure is used to keep track of various per-client
41 * state that has been instantiated.
42 *
43 * Bugs: duplicated data and potentially unnecessary elements.
44 */
45
29struct p9_client { 46struct p9_client {
30 spinlock_t lock; /* protect client structure */ 47 spinlock_t lock; /* protect client structure */
31 int msize; 48 int msize;
@@ -38,6 +55,24 @@ struct p9_client {
38 struct list_head fidlist; 55 struct list_head fidlist;
39}; 56};
40 57
58/**
59 * struct p9_fid - file system entity handle
60 * @clnt: back pointer to instantiating &p9_client
61 * @fid: numeric identifier for this handle
62 * @mode: current mode of this fid (enum?)
63 * @qid: the &p9_qid server identifier this handle points to
64 * @iounit: the server reported maximum transaction size for this file
65 * @uid: the numeric uid of the local user who owns this handle
66 * @aux: transport specific information (unused?)
67 * @rdir_fpos: tracks offset of file position when reading directory contents
68 * @rdir_pos: (unused?)
69 * @rdir_fcall: holds response of last directory read request
70 * @flist: per-client-instance fid tracking
71 * @dlist: per-dentry fid tracking
72 *
73 * TODO: This needs lots of explanation.
74 */
75
41struct p9_fid { 76struct p9_fid {
42 struct p9_client *clnt; 77 struct p9_client *clnt;
43 u32 fid; 78 u32 fid;
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
index d2209ae9d18b..0db3a4038dc0 100644
--- a/include/net/9p/transport.h
+++ b/include/net/9p/transport.h
@@ -26,12 +26,40 @@
26#ifndef NET_9P_TRANSPORT_H 26#ifndef NET_9P_TRANSPORT_H
27#define NET_9P_TRANSPORT_H 27#define NET_9P_TRANSPORT_H
28 28
29/**
30 * enum p9_trans_status - different states of underlying transports
31 * @Connected: transport is connected and healthy
32 * @Disconnected: transport has been disconnected
33 * @Hung: transport is connected by wedged
34 *
35 * This enumeration details the various states a transport
36 * instatiation can be in.
37 */
38
29enum p9_trans_status { 39enum p9_trans_status {
30 Connected, 40 Connected,
31 Disconnected, 41 Disconnected,
32 Hung, 42 Hung,
33}; 43};
34 44
45/**
46 * struct p9_trans - per-transport state and API
47 * @status: transport &p9_trans_status
48 * @msize: negotiated maximum packet size (duplicate from client)
49 * @extended: negotiated protocol extensions (duplicate from client)
50 * @priv: transport private data
51 * @close: member function to disconnect and close the transport
52 * @rpc: member function to issue a request to the transport
53 *
54 * This is the basic API for a transport instance. It is used as
55 * a handle by the client to issue requests. This interface is currently
56 * in flux during reorganization.
57 *
58 * Bugs: there is lots of duplicated data here and its not clear that
59 * the member functions need to be per-instance versus per transport
60 * module.
61 */
62
35struct p9_trans { 63struct p9_trans {
36 enum p9_trans_status status; 64 enum p9_trans_status status;
37 int msize; 65 int msize;
@@ -42,6 +70,21 @@ struct p9_trans {
42 struct p9_fcall **rc); 70 struct p9_fcall **rc);
43}; 71};
44 72
73/**
74 * struct p9_trans_module - transport module interface
75 * @list: used to maintain a list of currently available transports
76 * @name: the human-readable name of the transport
77 * @maxsize: transport provided maximum packet size
78 * @def: set if this transport should be considered the default
79 * @create: member function to create a new connection on this transport
80 *
81 * This is the basic API for a transport module which is registered by the
82 * transport module with the 9P core network module and used by the client
83 * to instantiate a new connection on a transport.
84 *
85 * Bugs: the transport module list isn't protected.
86 */
87
45struct p9_trans_module { 88struct p9_trans_module {
46 struct list_head list; 89 struct list_head list;
47 char *name; /* name of transport */ 90 char *name; /* name of transport */
@@ -53,5 +96,4 @@ struct p9_trans_module {
53void v9fs_register_trans(struct p9_trans_module *m); 96void v9fs_register_trans(struct p9_trans_module *m);
54struct p9_trans_module *v9fs_match_trans(const substring_t *name); 97struct p9_trans_module *v9fs_match_trans(const substring_t *name);
55struct p9_trans_module *v9fs_default_trans(void); 98struct p9_trans_module *v9fs_default_trans(void);
56
57#endif /* NET_9P_TRANSPORT_H */ 99#endif /* NET_9P_TRANSPORT_H */
diff --git a/include/net/ip.h b/include/net/ip.h
index 6d7bcd5e62d4..3b40bc2234be 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -210,7 +210,7 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
210{ 210{
211 return (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO || 211 return (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO ||
212 (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT && 212 (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT &&
213 !(dst_metric(dst, RTAX_LOCK)&(1<<RTAX_MTU)))); 213 !(dst_metric_locked(dst, RTAX_MTU))));
214} 214}
215 215
216extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); 216extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h
index e4efad1f9eff..0ce93398720d 100644
--- a/include/net/irda/discovery.h
+++ b/include/net/irda/discovery.h
@@ -57,9 +57,6 @@ typedef union {
57 __u8 byte[2]; 57 __u8 byte[2];
58} __u16_host_order; 58} __u16_host_order;
59 59
60/* Same purpose, different application */
61#define u16ho(array) (* ((__u16 *) array))
62
63/* Types of discovery */ 60/* Types of discovery */
64typedef enum { 61typedef enum {
65 DISCOVERY_LOG, /* What's in our discovery log */ 62 DISCOVERY_LOG, /* What's in our discovery log */
diff --git a/include/net/syncppp.h b/include/net/syncppp.h
index 877efa434700..e43f4070d892 100644
--- a/include/net/syncppp.h
+++ b/include/net/syncppp.h
@@ -59,7 +59,7 @@ struct ppp_device
59 59
60static inline struct sppp *sppp_of(struct net_device *dev) 60static inline struct sppp *sppp_of(struct net_device *dev)
61{ 61{
62 struct ppp_device **ppp = dev->priv; 62 struct ppp_device **ppp = dev->ml_priv;
63 BUG_ON((*ppp)->dev != dev); 63 BUG_ON((*ppp)->dev != dev);
64 return &(*ppp)->sppp; 64 return &(*ppp)->sppp;
65} 65}
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index d1350bcccb03..2933d7474a79 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -648,14 +648,46 @@ extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
648extern void xfrm_audit_state_icvfail(struct xfrm_state *x, 648extern void xfrm_audit_state_icvfail(struct xfrm_state *x,
649 struct sk_buff *skb, u8 proto); 649 struct sk_buff *skb, u8 proto);
650#else 650#else
651#define xfrm_audit_policy_add(x, r, a, se, s) do { ; } while (0) 651
652#define xfrm_audit_policy_delete(x, r, a, se, s) do { ; } while (0) 652static inline void xfrm_audit_policy_add(struct xfrm_policy *xp, int result,
653#define xfrm_audit_state_add(x, r, a, se, s) do { ; } while (0) 653 u32 auid, u32 ses, u32 secid)
654#define xfrm_audit_state_delete(x, r, a, se, s) do { ; } while (0) 654{
655#define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0) 655}
656#define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0) 656
657#define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0) 657static inline void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result,
658#define xfrm_audit_state_icvfail(x, s, p) do { ; } while (0) 658 u32 auid, u32 ses, u32 secid)
659{
660}
661
662static inline void xfrm_audit_state_add(struct xfrm_state *x, int result,
663 u32 auid, u32 ses, u32 secid)
664{
665}
666
667static inline void xfrm_audit_state_delete(struct xfrm_state *x, int result,
668 u32 auid, u32 ses, u32 secid)
669{
670}
671
672static inline void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
673 struct sk_buff *skb)
674{
675}
676
677static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb,
678 u16 family)
679{
680}
681
682static inline void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
683 __be32 net_spi, __be32 net_seq)
684{
685}
686
687static inline void xfrm_audit_state_icvfail(struct xfrm_state *x,
688 struct sk_buff *skb, u8 proto)
689{
690}
659#endif /* CONFIG_AUDITSYSCALL */ 691#endif /* CONFIG_AUDITSYSCALL */
660 692
661static inline void xfrm_pol_hold(struct xfrm_policy *policy) 693static inline void xfrm_pol_hold(struct xfrm_policy *policy)
diff --git a/include/sound/soc.h b/include/sound/soc.h
index e6ea6f750941..d3c8c033dff8 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -238,7 +238,7 @@ int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
238 struct snd_ctl_elem_info *uinfo); 238 struct snd_ctl_elem_info *uinfo);
239int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol, 239int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
240 struct snd_ctl_elem_info *uinfo); 240 struct snd_ctl_elem_info *uinfo);
241#define snd_soc_info_bool_ext snd_ctl_boolean_mono 241#define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
242int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, 242int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
243 struct snd_ctl_elem_value *ucontrol); 243 struct snd_ctl_elem_value *ucontrol);
244int snd_soc_put_volsw(struct snd_kcontrol *kcontrol, 244int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
diff --git a/init/Kconfig b/init/Kconfig
index f0e62e5ce0dc..6135d07f31ec 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -316,9 +316,16 @@ config CPUSETS
316 316
317 Say N if unsure. 317 Say N if unsure.
318 318
319#
320# Architectures with an unreliable sched_clock() should select this:
321#
322config HAVE_UNSTABLE_SCHED_CLOCK
323 bool
324
319config GROUP_SCHED 325config GROUP_SCHED
320 bool "Group CPU scheduler" 326 bool "Group CPU scheduler"
321 default y 327 depends on EXPERIMENTAL
328 default n
322 help 329 help
323 This feature lets CPU scheduler recognize task groups and control CPU 330 This feature lets CPU scheduler recognize task groups and control CPU
324 bandwidth allocation to such task groups. 331 bandwidth allocation to such task groups.
@@ -326,7 +333,7 @@ config GROUP_SCHED
326config FAIR_GROUP_SCHED 333config FAIR_GROUP_SCHED
327 bool "Group scheduling for SCHED_OTHER" 334 bool "Group scheduling for SCHED_OTHER"
328 depends on GROUP_SCHED 335 depends on GROUP_SCHED
329 default y 336 default GROUP_SCHED
330 337
331config RT_GROUP_SCHED 338config RT_GROUP_SCHED
332 bool "Group scheduling for SCHED_RR/FIFO" 339 bool "Group scheduling for SCHED_RR/FIFO"
@@ -627,6 +634,14 @@ config ELF_CORE
627 help 634 help
628 Enable support for generating core dumps. Disabling saves about 4k. 635 Enable support for generating core dumps. Disabling saves about 4k.
629 636
637config PCSPKR_PLATFORM
638 bool "Enable PC-Speaker support" if EMBEDDED
639 depends on ALPHA || X86 || MIPS || PPC_PREP || PPC_CHRP || PPC_PSERIES
640 default y
641 help
642 This option allows to disable the internal PC-Speaker
643 support, saving some memory.
644
630config COMPAT_BRK 645config COMPAT_BRK
631 bool "Disable heap randomization" 646 bool "Disable heap randomization"
632 default y 647 default y
@@ -830,9 +845,9 @@ config MODULE_FORCE_LOAD
830 depends on MODULES 845 depends on MODULES
831 default n 846 default n
832 help 847 help
833 This option allows loading of modules even if that would set the 848 Allow loading of modules without version information (ie. modprobe
834 'F' (forced) taint, due to lack of version info. Which is 849 --force). Forced module loading sets the 'F' (forced) taint flag and
835 usually a really bad idea. 850 is usually a really bad idea.
836 851
837config MODULE_UNLOAD 852config MODULE_UNLOAD
838 bool "Module unloading" 853 bool "Module unloading"
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 3885e70e7759..660c1e50c91b 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -76,6 +76,7 @@ dev_t name_to_dev_t(char *name)
76 char s[32]; 76 char s[32];
77 char *p; 77 char *p;
78 dev_t res = 0; 78 dev_t res = 0;
79 int part;
79 80
80 if (strncmp(name, "/dev/", 5) != 0) { 81 if (strncmp(name, "/dev/", 5) != 0) {
81 unsigned maj, min; 82 unsigned maj, min;
@@ -106,7 +107,31 @@ dev_t name_to_dev_t(char *name)
106 for (p = s; *p; p++) 107 for (p = s; *p; p++)
107 if (*p == '/') 108 if (*p == '/')
108 *p = '!'; 109 *p = '!';
109 res = blk_lookup_devt(s); 110 res = blk_lookup_devt(s, 0);
111 if (res)
112 goto done;
113
114 /*
115 * try non-existant, but valid partition, which may only exist
116 * after revalidating the disk, like partitioned md devices
117 */
118 while (p > s && isdigit(p[-1]))
119 p--;
120 if (p == s || !*p || *p == '0')
121 goto fail;
122
123 /* try disk name without <part number> */
124 part = simple_strtoul(p, NULL, 10);
125 *p = '\0';
126 res = blk_lookup_devt(s, part);
127 if (res)
128 goto done;
129
130 /* try disk name without p<part number> */
131 if (p < s + 2 || !isdigit(p[-2]) || p[-1] != 'p')
132 goto fail;
133 p[-1] = '\0';
134 res = blk_lookup_devt(s, part);
110 if (res) 135 if (res)
111 goto done; 136 goto done;
112 137
diff --git a/init/main.c b/init/main.c
index a87d4ca5c36c..f406fefa626c 100644
--- a/init/main.c
+++ b/init/main.c
@@ -602,6 +602,7 @@ asmlinkage void __init start_kernel(void)
602 softirq_init(); 602 softirq_init();
603 timekeeping_init(); 603 timekeeping_init();
604 time_init(); 604 time_init();
605 sched_clock_init();
605 profile_init(); 606 profile_init();
606 if (!irqs_disabled()) 607 if (!irqs_disabled())
607 printk("start_kernel(): bug: interrupts were enabled early\n"); 608 printk("start_kernel(): bug: interrupts were enabled early\n");
@@ -701,7 +702,6 @@ static void __init do_initcalls(void)
701 702
702 for (call = __initcall_start; call < __initcall_end; call++) { 703 for (call = __initcall_start; call < __initcall_end; call++) {
703 ktime_t t0, t1, delta; 704 ktime_t t0, t1, delta;
704 char *msg = NULL;
705 char msgbuf[40]; 705 char msgbuf[40];
706 int result; 706 int result;
707 707
@@ -723,22 +723,23 @@ static void __init do_initcalls(void)
723 (unsigned long long) delta.tv64 >> 20); 723 (unsigned long long) delta.tv64 >> 20);
724 } 724 }
725 725
726 if (result && result != -ENODEV && initcall_debug) { 726 msgbuf[0] = 0;
727 sprintf(msgbuf, "error code %d", result); 727
728 msg = msgbuf; 728 if (result && result != -ENODEV && initcall_debug)
729 } 729 sprintf(msgbuf, "error code %d ", result);
730
730 if (preempt_count() != count) { 731 if (preempt_count() != count) {
731 msg = "preemption imbalance"; 732 strncat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
732 preempt_count() = count; 733 preempt_count() = count;
733 } 734 }
734 if (irqs_disabled()) { 735 if (irqs_disabled()) {
735 msg = "disabled interrupts"; 736 strncat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
736 local_irq_enable(); 737 local_irq_enable();
737 } 738 }
738 if (msg) { 739 if (msgbuf[0]) {
739 print_fn_descriptor_symbol(KERN_WARNING "initcall %s()", 740 print_fn_descriptor_symbol(KERN_WARNING "initcall %s()",
740 (unsigned long) *call); 741 (unsigned long) *call);
741 printk(" returned with %s\n", msg); 742 printk(" returned with %s\n", msgbuf);
742 } 743 }
743 } 744 }
744 745
diff --git a/kernel/Makefile b/kernel/Makefile
index 188c43223f52..1c9938addb9d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \
9 rcupdate.o extable.o params.o posix-timers.o \ 9 rcupdate.o extable.o params.o posix-timers.o \
10 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ 10 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \
11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ 11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \
12 notifier.o ksysfs.o pm_qos_params.o 12 notifier.o ksysfs.o pm_qos_params.o sched_clock.o
13 13
14obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o 14obj-$(CONFIG_SYSCTL_SYSCALL_CHECK) += sysctl_check.o
15obj-$(CONFIG_STACKTRACE) += stacktrace.o 15obj-$(CONFIG_STACKTRACE) += stacktrace.o
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 8da627d33804..86ea9e34e326 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -1031,11 +1031,9 @@ int current_cpuset_is_being_rebound(void)
1031 return task_cs(current) == cpuset_being_rebound; 1031 return task_cs(current) == cpuset_being_rebound;
1032} 1032}
1033 1033
1034static int update_relax_domain_level(struct cpuset *cs, char *buf) 1034static int update_relax_domain_level(struct cpuset *cs, s64 val)
1035{ 1035{
1036 int val = simple_strtol(buf, NULL, 10); 1036 if ((int)val < 0)
1037
1038 if (val < 0)
1039 val = -1; 1037 val = -1;
1040 1038
1041 if (val != cs->relax_domain_level) { 1039 if (val != cs->relax_domain_level) {
@@ -1280,9 +1278,6 @@ static ssize_t cpuset_common_file_write(struct cgroup *cont,
1280 case FILE_MEMLIST: 1278 case FILE_MEMLIST:
1281 retval = update_nodemask(cs, buffer); 1279 retval = update_nodemask(cs, buffer);
1282 break; 1280 break;
1283 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
1284 retval = update_relax_domain_level(cs, buffer);
1285 break;
1286 default: 1281 default:
1287 retval = -EINVAL; 1282 retval = -EINVAL;
1288 goto out2; 1283 goto out2;
@@ -1348,6 +1343,30 @@ static int cpuset_write_u64(struct cgroup *cgrp, struct cftype *cft, u64 val)
1348 return retval; 1343 return retval;
1349} 1344}
1350 1345
1346static int cpuset_write_s64(struct cgroup *cgrp, struct cftype *cft, s64 val)
1347{
1348 int retval = 0;
1349 struct cpuset *cs = cgroup_cs(cgrp);
1350 cpuset_filetype_t type = cft->private;
1351
1352 cgroup_lock();
1353
1354 if (cgroup_is_removed(cgrp)) {
1355 cgroup_unlock();
1356 return -ENODEV;
1357 }
1358 switch (type) {
1359 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
1360 retval = update_relax_domain_level(cs, val);
1361 break;
1362 default:
1363 retval = -EINVAL;
1364 break;
1365 }
1366 cgroup_unlock();
1367 return retval;
1368}
1369
1351/* 1370/*
1352 * These ascii lists should be read in a single call, by using a user 1371 * These ascii lists should be read in a single call, by using a user
1353 * buffer large enough to hold the entire map. If read in smaller 1372 * buffer large enough to hold the entire map. If read in smaller
@@ -1406,9 +1425,6 @@ static ssize_t cpuset_common_file_read(struct cgroup *cont,
1406 case FILE_MEMLIST: 1425 case FILE_MEMLIST:
1407 s += cpuset_sprintf_memlist(s, cs); 1426 s += cpuset_sprintf_memlist(s, cs);
1408 break; 1427 break;
1409 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
1410 s += sprintf(s, "%d", cs->relax_domain_level);
1411 break;
1412 default: 1428 default:
1413 retval = -EINVAL; 1429 retval = -EINVAL;
1414 goto out; 1430 goto out;
@@ -1449,6 +1465,18 @@ static u64 cpuset_read_u64(struct cgroup *cont, struct cftype *cft)
1449 } 1465 }
1450} 1466}
1451 1467
1468static s64 cpuset_read_s64(struct cgroup *cont, struct cftype *cft)
1469{
1470 struct cpuset *cs = cgroup_cs(cont);
1471 cpuset_filetype_t type = cft->private;
1472 switch (type) {
1473 case FILE_SCHED_RELAX_DOMAIN_LEVEL:
1474 return cs->relax_domain_level;
1475 default:
1476 BUG();
1477 }
1478}
1479
1452 1480
1453/* 1481/*
1454 * for the common functions, 'private' gives the type of file 1482 * for the common functions, 'private' gives the type of file
@@ -1499,8 +1527,8 @@ static struct cftype files[] = {
1499 1527
1500 { 1528 {
1501 .name = "sched_relax_domain_level", 1529 .name = "sched_relax_domain_level",
1502 .read_u64 = cpuset_read_u64, 1530 .read_s64 = cpuset_read_s64,
1503 .write_u64 = cpuset_write_u64, 1531 .write_s64 = cpuset_write_s64,
1504 .private = FILE_SCHED_RELAX_DOMAIN_LEVEL, 1532 .private = FILE_SCHED_RELAX_DOMAIN_LEVEL,
1505 }, 1533 },
1506 1534
diff --git a/kernel/futex.c b/kernel/futex.c
index 98092c9817f4..449def8074fe 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -104,10 +104,6 @@ struct futex_q {
104 /* Key which the futex is hashed on: */ 104 /* Key which the futex is hashed on: */
105 union futex_key key; 105 union futex_key key;
106 106
107 /* For fd, sigio sent using these: */
108 int fd;
109 struct file *filp;
110
111 /* Optional priority inheritance state: */ 107 /* Optional priority inheritance state: */
112 struct futex_pi_state *pi_state; 108 struct futex_pi_state *pi_state;
113 struct task_struct *task; 109 struct task_struct *task;
@@ -126,9 +122,6 @@ struct futex_hash_bucket {
126 122
127static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS]; 123static struct futex_hash_bucket futex_queues[1<<FUTEX_HASHBITS];
128 124
129/* Futex-fs vfsmount entry: */
130static struct vfsmount *futex_mnt;
131
132/* 125/*
133 * Take mm->mmap_sem, when futex is shared 126 * Take mm->mmap_sem, when futex is shared
134 */ 127 */
@@ -610,8 +603,6 @@ lookup_pi_state(u32 uval, struct futex_hash_bucket *hb,
610static void wake_futex(struct futex_q *q) 603static void wake_futex(struct futex_q *q)
611{ 604{
612 plist_del(&q->list, &q->list.plist); 605 plist_del(&q->list, &q->list.plist);
613 if (q->filp)
614 send_sigio(&q->filp->f_owner, q->fd, POLL_IN);
615 /* 606 /*
616 * The lock in wake_up_all() is a crucial memory barrier after the 607 * The lock in wake_up_all() is a crucial memory barrier after the
617 * plist_del() and also before assigning to q->lock_ptr. 608 * plist_del() and also before assigning to q->lock_ptr.
@@ -988,14 +979,10 @@ out:
988} 979}
989 980
990/* The key must be already stored in q->key. */ 981/* The key must be already stored in q->key. */
991static inline struct futex_hash_bucket * 982static inline struct futex_hash_bucket *queue_lock(struct futex_q *q)
992queue_lock(struct futex_q *q, int fd, struct file *filp)
993{ 983{
994 struct futex_hash_bucket *hb; 984 struct futex_hash_bucket *hb;
995 985
996 q->fd = fd;
997 q->filp = filp;
998
999 init_waitqueue_head(&q->waiters); 986 init_waitqueue_head(&q->waiters);
1000 987
1001 get_futex_key_refs(&q->key); 988 get_futex_key_refs(&q->key);
@@ -1006,7 +993,7 @@ queue_lock(struct futex_q *q, int fd, struct file *filp)
1006 return hb; 993 return hb;
1007} 994}
1008 995
1009static inline void __queue_me(struct futex_q *q, struct futex_hash_bucket *hb) 996static inline void queue_me(struct futex_q *q, struct futex_hash_bucket *hb)
1010{ 997{
1011 int prio; 998 int prio;
1012 999
@@ -1041,15 +1028,6 @@ queue_unlock(struct futex_q *q, struct futex_hash_bucket *hb)
1041 * exactly once. They are called with the hashed spinlock held. 1028 * exactly once. They are called with the hashed spinlock held.
1042 */ 1029 */
1043 1030
1044/* The key must be already stored in q->key. */
1045static void queue_me(struct futex_q *q, int fd, struct file *filp)
1046{
1047 struct futex_hash_bucket *hb;
1048
1049 hb = queue_lock(q, fd, filp);
1050 __queue_me(q, hb);
1051}
1052
1053/* Return 1 if we were still queued (ie. 0 means we were woken) */ 1031/* Return 1 if we were still queued (ie. 0 means we were woken) */
1054static int unqueue_me(struct futex_q *q) 1032static int unqueue_me(struct futex_q *q)
1055{ 1033{
@@ -1194,7 +1172,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1194 if (unlikely(ret != 0)) 1172 if (unlikely(ret != 0))
1195 goto out_release_sem; 1173 goto out_release_sem;
1196 1174
1197 hb = queue_lock(&q, -1, NULL); 1175 hb = queue_lock(&q);
1198 1176
1199 /* 1177 /*
1200 * Access the page AFTER the futex is queued. 1178 * Access the page AFTER the futex is queued.
@@ -1238,7 +1216,7 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
1238 goto out_unlock_release_sem; 1216 goto out_unlock_release_sem;
1239 1217
1240 /* Only actually queue if *uaddr contained val. */ 1218 /* Only actually queue if *uaddr contained val. */
1241 __queue_me(&q, hb); 1219 queue_me(&q, hb);
1242 1220
1243 /* 1221 /*
1244 * Now the futex is queued and we have checked the data, we 1222 * Now the futex is queued and we have checked the data, we
@@ -1386,7 +1364,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1386 goto out_release_sem; 1364 goto out_release_sem;
1387 1365
1388 retry_unlocked: 1366 retry_unlocked:
1389 hb = queue_lock(&q, -1, NULL); 1367 hb = queue_lock(&q);
1390 1368
1391 retry_locked: 1369 retry_locked:
1392 ret = lock_taken = 0; 1370 ret = lock_taken = 0;
@@ -1499,7 +1477,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
1499 /* 1477 /*
1500 * Only actually queue now that the atomic ops are done: 1478 * Only actually queue now that the atomic ops are done:
1501 */ 1479 */
1502 __queue_me(&q, hb); 1480 queue_me(&q, hb);
1503 1481
1504 /* 1482 /*
1505 * Now the futex is queued and we have checked the data, we 1483 * Now the futex is queued and we have checked the data, we
@@ -1746,121 +1724,6 @@ pi_faulted:
1746 return ret; 1724 return ret;
1747} 1725}
1748 1726
1749static int futex_close(struct inode *inode, struct file *filp)
1750{
1751 struct futex_q *q = filp->private_data;
1752
1753 unqueue_me(q);
1754 kfree(q);
1755
1756 return 0;
1757}
1758
1759/* This is one-shot: once it's gone off you need a new fd */
1760static unsigned int futex_poll(struct file *filp,
1761 struct poll_table_struct *wait)
1762{
1763 struct futex_q *q = filp->private_data;
1764 int ret = 0;
1765
1766 poll_wait(filp, &q->waiters, wait);
1767
1768 /*
1769 * plist_node_empty() is safe here without any lock.
1770 * q->lock_ptr != 0 is not safe, because of ordering against wakeup.
1771 */
1772 if (plist_node_empty(&q->list))
1773 ret = POLLIN | POLLRDNORM;
1774
1775 return ret;
1776}
1777
1778static const struct file_operations futex_fops = {
1779 .release = futex_close,
1780 .poll = futex_poll,
1781};
1782
1783/*
1784 * Signal allows caller to avoid the race which would occur if they
1785 * set the sigio stuff up afterwards.
1786 */
1787static int futex_fd(u32 __user *uaddr, int signal)
1788{
1789 struct futex_q *q;
1790 struct file *filp;
1791 int ret, err;
1792 struct rw_semaphore *fshared;
1793 static unsigned long printk_interval;
1794
1795 if (printk_timed_ratelimit(&printk_interval, 60 * 60 * 1000)) {
1796 printk(KERN_WARNING "Process `%s' used FUTEX_FD, which "
1797 "will be removed from the kernel in June 2007\n",
1798 current->comm);
1799 }
1800
1801 ret = -EINVAL;
1802 if (!valid_signal(signal))
1803 goto out;
1804
1805 ret = get_unused_fd();
1806 if (ret < 0)
1807 goto out;
1808 filp = get_empty_filp();
1809 if (!filp) {
1810 put_unused_fd(ret);
1811 ret = -ENFILE;
1812 goto out;
1813 }
1814 filp->f_op = &futex_fops;
1815 filp->f_path.mnt = mntget(futex_mnt);
1816 filp->f_path.dentry = dget(futex_mnt->mnt_root);
1817 filp->f_mapping = filp->f_path.dentry->d_inode->i_mapping;
1818
1819 if (signal) {
1820 err = __f_setown(filp, task_pid(current), PIDTYPE_PID, 1);
1821 if (err < 0) {
1822 goto error;
1823 }
1824 filp->f_owner.signum = signal;
1825 }
1826
1827 q = kmalloc(sizeof(*q), GFP_KERNEL);
1828 if (!q) {
1829 err = -ENOMEM;
1830 goto error;
1831 }
1832 q->pi_state = NULL;
1833
1834 fshared = &current->mm->mmap_sem;
1835 down_read(fshared);
1836 err = get_futex_key(uaddr, fshared, &q->key);
1837
1838 if (unlikely(err != 0)) {
1839 up_read(fshared);
1840 kfree(q);
1841 goto error;
1842 }
1843
1844 /*
1845 * queue_me() must be called before releasing mmap_sem, because
1846 * key->shared.inode needs to be referenced while holding it.
1847 */
1848 filp->private_data = q;
1849
1850 queue_me(q, ret, filp);
1851 up_read(fshared);
1852
1853 /* Now we map fd to filp, so userspace can access it */
1854 fd_install(ret, filp);
1855out:
1856 return ret;
1857error:
1858 put_unused_fd(ret);
1859 put_filp(filp);
1860 ret = err;
1861 goto out;
1862}
1863
1864/* 1727/*
1865 * Support for robust futexes: the kernel cleans up held futexes at 1728 * Support for robust futexes: the kernel cleans up held futexes at
1866 * thread exit time. 1729 * thread exit time.
@@ -2092,10 +1955,6 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
2092 case FUTEX_WAKE_BITSET: 1955 case FUTEX_WAKE_BITSET:
2093 ret = futex_wake(uaddr, fshared, val, val3); 1956 ret = futex_wake(uaddr, fshared, val, val3);
2094 break; 1957 break;
2095 case FUTEX_FD:
2096 /* non-zero val means F_SETOWN(getpid()) & F_SETSIG(val) */
2097 ret = futex_fd(uaddr, val);
2098 break;
2099 case FUTEX_REQUEUE: 1958 case FUTEX_REQUEUE:
2100 ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, NULL); 1959 ret = futex_requeue(uaddr, fshared, uaddr2, val, val2, NULL);
2101 break; 1960 break;
@@ -2156,19 +2015,6 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,
2156 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); 2015 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
2157} 2016}
2158 2017
2159static int futexfs_get_sb(struct file_system_type *fs_type,
2160 int flags, const char *dev_name, void *data,
2161 struct vfsmount *mnt)
2162{
2163 return get_sb_pseudo(fs_type, "futex", NULL, FUTEXFS_SUPER_MAGIC, mnt);
2164}
2165
2166static struct file_system_type futex_fs_type = {
2167 .name = "futexfs",
2168 .get_sb = futexfs_get_sb,
2169 .kill_sb = kill_anon_super,
2170};
2171
2172static int __init futex_init(void) 2018static int __init futex_init(void)
2173{ 2019{
2174 u32 curval; 2020 u32 curval;
@@ -2193,16 +2039,6 @@ static int __init futex_init(void)
2193 spin_lock_init(&futex_queues[i].lock); 2039 spin_lock_init(&futex_queues[i].lock);
2194 } 2040 }
2195 2041
2196 i = register_filesystem(&futex_fs_type);
2197 if (i)
2198 return i;
2199
2200 futex_mnt = kern_mount(&futex_fs_type);
2201 if (IS_ERR(futex_mnt)) {
2202 unregister_filesystem(&futex_fs_type);
2203 return PTR_ERR(futex_mnt);
2204 }
2205
2206 return 0; 2042 return 0;
2207} 2043}
2208__initcall(futex_init); 2044__initcall(futex_init);
diff --git a/kernel/kgdb.c b/kernel/kgdb.c
index 1bd0ec1c80b2..14787de568b3 100644
--- a/kernel/kgdb.c
+++ b/kernel/kgdb.c
@@ -61,7 +61,7 @@ struct kgdb_state {
61 int err_code; 61 int err_code;
62 int cpu; 62 int cpu;
63 int pass_exception; 63 int pass_exception;
64 long threadid; 64 unsigned long threadid;
65 long kgdb_usethreadid; 65 long kgdb_usethreadid;
66 struct pt_regs *linux_regs; 66 struct pt_regs *linux_regs;
67}; 67};
@@ -146,7 +146,7 @@ atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
146 * the other CPUs might interfere with your debugging context, so 146 * the other CPUs might interfere with your debugging context, so
147 * use this with care: 147 * use this with care:
148 */ 148 */
149int kgdb_do_roundup = 1; 149static int kgdb_do_roundup = 1;
150 150
151static int __init opt_nokgdbroundup(char *str) 151static int __init opt_nokgdbroundup(char *str)
152{ 152{
@@ -346,14 +346,6 @@ static void put_packet(char *buffer)
346 } 346 }
347} 347}
348 348
349static char *pack_hex_byte(char *pkt, u8 byte)
350{
351 *pkt++ = hexchars[byte >> 4];
352 *pkt++ = hexchars[byte & 0xf];
353
354 return pkt;
355}
356
357/* 349/*
358 * Convert the memory pointed to by mem into hex, placing result in buf. 350 * Convert the memory pointed to by mem into hex, placing result in buf.
359 * Return a pointer to the last char put in buf (null). May return an error. 351 * Return a pointer to the last char put in buf (null). May return an error.
@@ -438,7 +430,7 @@ int kgdb_hex2mem(char *buf, char *mem, int count)
438 * While we find nice hex chars, build a long_val. 430 * While we find nice hex chars, build a long_val.
439 * Return number of chars processed. 431 * Return number of chars processed.
440 */ 432 */
441int kgdb_hex2long(char **ptr, long *long_val) 433int kgdb_hex2long(char **ptr, unsigned long *long_val)
442{ 434{
443 int hex_val; 435 int hex_val;
444 int num = 0; 436 int num = 0;
@@ -709,7 +701,7 @@ int kgdb_isremovedbreak(unsigned long addr)
709 return 0; 701 return 0;
710} 702}
711 703
712int remove_all_break(void) 704static int remove_all_break(void)
713{ 705{
714 unsigned long addr; 706 unsigned long addr;
715 int error; 707 int error;
diff --git a/kernel/module.c b/kernel/module.c
index 8e4528c9909f..f5e9491ef7ac 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -917,6 +917,10 @@ static int check_version(Elf_Shdr *sechdrs,
917 if (!crc) 917 if (!crc)
918 return 1; 918 return 1;
919 919
920 /* No versions at all? modprobe --force does this. */
921 if (versindex == 0)
922 return try_to_force_load(mod, symname) == 0;
923
920 versions = (void *) sechdrs[versindex].sh_addr; 924 versions = (void *) sechdrs[versindex].sh_addr;
921 num_versions = sechdrs[versindex].sh_size 925 num_versions = sechdrs[versindex].sh_size
922 / sizeof(struct modversion_info); 926 / sizeof(struct modversion_info);
@@ -932,8 +936,9 @@ static int check_version(Elf_Shdr *sechdrs,
932 goto bad_version; 936 goto bad_version;
933 } 937 }
934 938
935 if (!try_to_force_load(mod, symname)) 939 printk(KERN_WARNING "%s: no symbol version for %s\n",
936 return 1; 940 mod->name, symname);
941 return 0;
937 942
938bad_version: 943bad_version:
939 printk("%s: disagrees about version of symbol %s\n", 944 printk("%s: disagrees about version of symbol %s\n",
@@ -952,11 +957,14 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
952 return check_version(sechdrs, versindex, "struct_module", mod, crc); 957 return check_version(sechdrs, versindex, "struct_module", mod, crc);
953} 958}
954 959
955/* First part is kernel version, which we ignore. */ 960/* First part is kernel version, which we ignore if module has crcs. */
956static inline int same_magic(const char *amagic, const char *bmagic) 961static inline int same_magic(const char *amagic, const char *bmagic,
962 bool has_crcs)
957{ 963{
958 amagic += strcspn(amagic, " "); 964 if (has_crcs) {
959 bmagic += strcspn(bmagic, " "); 965 amagic += strcspn(amagic, " ");
966 bmagic += strcspn(bmagic, " ");
967 }
960 return strcmp(amagic, bmagic) == 0; 968 return strcmp(amagic, bmagic) == 0;
961} 969}
962#else 970#else
@@ -976,7 +984,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
976 return 1; 984 return 1;
977} 985}
978 986
979static inline int same_magic(const char *amagic, const char *bmagic) 987static inline int same_magic(const char *amagic, const char *bmagic,
988 bool has_crcs)
980{ 989{
981 return strcmp(amagic, bmagic) == 0; 990 return strcmp(amagic, bmagic) == 0;
982} 991}
@@ -1869,7 +1878,7 @@ static struct module *load_module(void __user *umod,
1869 err = try_to_force_load(mod, "magic"); 1878 err = try_to_force_load(mod, "magic");
1870 if (err) 1879 if (err)
1871 goto free_hdr; 1880 goto free_hdr;
1872 } else if (!same_magic(modmagic, vermagic)) { 1881 } else if (!same_magic(modmagic, vermagic, versindex)) {
1873 printk(KERN_ERR "%s: version magic '%s' should be '%s'\n", 1882 printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
1874 mod->name, modmagic, vermagic); 1883 mod->name, modmagic, vermagic);
1875 err = -ENOEXEC; 1884 err = -ENOEXEC;
diff --git a/kernel/relay.c b/kernel/relay.c
index 7de644cdec43..bc24dcdc570f 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -1191,7 +1191,7 @@ static ssize_t relay_file_splice_read(struct file *in,
1191 ret = 0; 1191 ret = 0;
1192 spliced = 0; 1192 spliced = 0;
1193 1193
1194 while (len && !spliced) { 1194 while (len) {
1195 ret = subbuf_splice_actor(in, ppos, pipe, len, flags, &nonpad_ret); 1195 ret = subbuf_splice_actor(in, ppos, pipe, len, flags, &nonpad_ret);
1196 if (ret < 0) 1196 if (ret < 0)
1197 break; 1197 break;
diff --git a/kernel/sched.c b/kernel/sched.c
index 34bcc5bc120e..cfa222a91539 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -75,16 +75,6 @@
75#include <asm/irq_regs.h> 75#include <asm/irq_regs.h>
76 76
77/* 77/*
78 * Scheduler clock - returns current time in nanosec units.
79 * This is default implementation.
80 * Architectures and sub-architectures can override this.
81 */
82unsigned long long __attribute__((weak)) sched_clock(void)
83{
84 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ);
85}
86
87/*
88 * Convert user-nice values [ -20 ... 0 ... 19 ] 78 * Convert user-nice values [ -20 ... 0 ... 19 ]
89 * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ], 79 * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
90 * and back. 80 * and back.
@@ -242,6 +232,12 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)
242} 232}
243#endif 233#endif
244 234
235/*
236 * sched_domains_mutex serializes calls to arch_init_sched_domains,
237 * detach_destroy_domains and partition_sched_domains.
238 */
239static DEFINE_MUTEX(sched_domains_mutex);
240
245#ifdef CONFIG_GROUP_SCHED 241#ifdef CONFIG_GROUP_SCHED
246 242
247#include <linux/cgroup.h> 243#include <linux/cgroup.h>
@@ -308,9 +304,6 @@ static DEFINE_PER_CPU(struct rt_rq, init_rt_rq) ____cacheline_aligned_in_smp;
308 */ 304 */
309static DEFINE_SPINLOCK(task_group_lock); 305static DEFINE_SPINLOCK(task_group_lock);
310 306
311/* doms_cur_mutex serializes access to doms_cur[] array */
312static DEFINE_MUTEX(doms_cur_mutex);
313
314#ifdef CONFIG_FAIR_GROUP_SCHED 307#ifdef CONFIG_FAIR_GROUP_SCHED
315#ifdef CONFIG_USER_SCHED 308#ifdef CONFIG_USER_SCHED
316# define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD) 309# define INIT_TASK_GROUP_LOAD (2*NICE_0_LOAD)
@@ -318,7 +311,13 @@ static DEFINE_MUTEX(doms_cur_mutex);
318# define INIT_TASK_GROUP_LOAD NICE_0_LOAD 311# define INIT_TASK_GROUP_LOAD NICE_0_LOAD
319#endif 312#endif
320 313
314/*
315 * A weight of 0, 1 or ULONG_MAX can cause arithmetics problems.
316 * (The default weight is 1024 - so there's no practical
317 * limitation from this.)
318 */
321#define MIN_SHARES 2 319#define MIN_SHARES 2
320#define MAX_SHARES (ULONG_MAX - 1)
322 321
323static int init_task_group_load = INIT_TASK_GROUP_LOAD; 322static int init_task_group_load = INIT_TASK_GROUP_LOAD;
324#endif 323#endif
@@ -358,21 +357,9 @@ static inline void set_task_rq(struct task_struct *p, unsigned int cpu)
358#endif 357#endif
359} 358}
360 359
361static inline void lock_doms_cur(void)
362{
363 mutex_lock(&doms_cur_mutex);
364}
365
366static inline void unlock_doms_cur(void)
367{
368 mutex_unlock(&doms_cur_mutex);
369}
370
371#else 360#else
372 361
373static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { } 362static inline void set_task_rq(struct task_struct *p, unsigned int cpu) { }
374static inline void lock_doms_cur(void) { }
375static inline void unlock_doms_cur(void) { }
376 363
377#endif /* CONFIG_GROUP_SCHED */ 364#endif /* CONFIG_GROUP_SCHED */
378 365
@@ -560,13 +547,7 @@ struct rq {
560 unsigned long next_balance; 547 unsigned long next_balance;
561 struct mm_struct *prev_mm; 548 struct mm_struct *prev_mm;
562 549
563 u64 clock, prev_clock_raw; 550 u64 clock;
564 s64 clock_max_delta;
565
566 unsigned int clock_warps, clock_overflows, clock_underflows;
567 u64 idle_clock;
568 unsigned int clock_deep_idle_events;
569 u64 tick_timestamp;
570 551
571 atomic_t nr_iowait; 552 atomic_t nr_iowait;
572 553
@@ -631,82 +612,6 @@ static inline int cpu_of(struct rq *rq)
631#endif 612#endif
632} 613}
633 614
634#ifdef CONFIG_NO_HZ
635static inline bool nohz_on(int cpu)
636{
637 return tick_get_tick_sched(cpu)->nohz_mode != NOHZ_MODE_INACTIVE;
638}
639
640static inline u64 max_skipped_ticks(struct rq *rq)
641{
642 return nohz_on(cpu_of(rq)) ? jiffies - rq->last_tick_seen + 2 : 1;
643}
644
645static inline void update_last_tick_seen(struct rq *rq)
646{
647 rq->last_tick_seen = jiffies;
648}
649#else
650static inline u64 max_skipped_ticks(struct rq *rq)
651{
652 return 1;
653}
654
655static inline void update_last_tick_seen(struct rq *rq)
656{
657}
658#endif
659
660/*
661 * Update the per-runqueue clock, as finegrained as the platform can give
662 * us, but without assuming monotonicity, etc.:
663 */
664static void __update_rq_clock(struct rq *rq)
665{
666 u64 prev_raw = rq->prev_clock_raw;
667 u64 now = sched_clock();
668 s64 delta = now - prev_raw;
669 u64 clock = rq->clock;
670
671#ifdef CONFIG_SCHED_DEBUG
672 WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());
673#endif
674 /*
675 * Protect against sched_clock() occasionally going backwards:
676 */
677 if (unlikely(delta < 0)) {
678 clock++;
679 rq->clock_warps++;
680 } else {
681 /*
682 * Catch too large forward jumps too:
683 */
684 u64 max_jump = max_skipped_ticks(rq) * TICK_NSEC;
685 u64 max_time = rq->tick_timestamp + max_jump;
686
687 if (unlikely(clock + delta > max_time)) {
688 if (clock < max_time)
689 clock = max_time;
690 else
691 clock++;
692 rq->clock_overflows++;
693 } else {
694 if (unlikely(delta > rq->clock_max_delta))
695 rq->clock_max_delta = delta;
696 clock += delta;
697 }
698 }
699
700 rq->prev_clock_raw = now;
701 rq->clock = clock;
702}
703
704static void update_rq_clock(struct rq *rq)
705{
706 if (likely(smp_processor_id() == cpu_of(rq)))
707 __update_rq_clock(rq);
708}
709
710/* 615/*
711 * The domain tree (rq->sd) is protected by RCU's quiescent state transition. 616 * The domain tree (rq->sd) is protected by RCU's quiescent state transition.
712 * See detach_destroy_domains: synchronize_sched for details. 617 * See detach_destroy_domains: synchronize_sched for details.
@@ -722,6 +627,11 @@ static void update_rq_clock(struct rq *rq)
722#define task_rq(p) cpu_rq(task_cpu(p)) 627#define task_rq(p) cpu_rq(task_cpu(p))
723#define cpu_curr(cpu) (cpu_rq(cpu)->curr) 628#define cpu_curr(cpu) (cpu_rq(cpu)->curr)
724 629
630static inline void update_rq_clock(struct rq *rq)
631{
632 rq->clock = sched_clock_cpu(cpu_of(rq));
633}
634
725/* 635/*
726 * Tunables that become constants when CONFIG_SCHED_DEBUG is off: 636 * Tunables that become constants when CONFIG_SCHED_DEBUG is off:
727 */ 637 */
@@ -757,14 +667,14 @@ const_debug unsigned int sysctl_sched_features =
757#define SCHED_FEAT(name, enabled) \ 667#define SCHED_FEAT(name, enabled) \
758 #name , 668 #name ,
759 669
760__read_mostly char *sched_feat_names[] = { 670static __read_mostly char *sched_feat_names[] = {
761#include "sched_features.h" 671#include "sched_features.h"
762 NULL 672 NULL
763}; 673};
764 674
765#undef SCHED_FEAT 675#undef SCHED_FEAT
766 676
767int sched_feat_open(struct inode *inode, struct file *filp) 677static int sched_feat_open(struct inode *inode, struct file *filp)
768{ 678{
769 filp->private_data = inode->i_private; 679 filp->private_data = inode->i_private;
770 return 0; 680 return 0;
@@ -899,7 +809,7 @@ static inline u64 global_rt_runtime(void)
899 return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC; 809 return (u64)sysctl_sched_rt_runtime * NSEC_PER_USEC;
900} 810}
901 811
902static const unsigned long long time_sync_thresh = 100000; 812unsigned long long time_sync_thresh = 100000;
903 813
904static DEFINE_PER_CPU(unsigned long long, time_offset); 814static DEFINE_PER_CPU(unsigned long long, time_offset);
905static DEFINE_PER_CPU(unsigned long long, prev_cpu_time); 815static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);
@@ -913,11 +823,14 @@ static DEFINE_PER_CPU(unsigned long long, prev_cpu_time);
913static DEFINE_SPINLOCK(time_sync_lock); 823static DEFINE_SPINLOCK(time_sync_lock);
914static unsigned long long prev_global_time; 824static unsigned long long prev_global_time;
915 825
916static unsigned long long __sync_cpu_clock(cycles_t time, int cpu) 826static unsigned long long __sync_cpu_clock(unsigned long long time, int cpu)
917{ 827{
918 unsigned long flags; 828 /*
919 829 * We want this inlined, to not get tracer function calls
920 spin_lock_irqsave(&time_sync_lock, flags); 830 * in this critical section:
831 */
832 spin_acquire(&time_sync_lock.dep_map, 0, 0, _THIS_IP_);
833 __raw_spin_lock(&time_sync_lock.raw_lock);
921 834
922 if (time < prev_global_time) { 835 if (time < prev_global_time) {
923 per_cpu(time_offset, cpu) += prev_global_time - time; 836 per_cpu(time_offset, cpu) += prev_global_time - time;
@@ -926,7 +839,8 @@ static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)
926 prev_global_time = time; 839 prev_global_time = time;
927 } 840 }
928 841
929 spin_unlock_irqrestore(&time_sync_lock, flags); 842 __raw_spin_unlock(&time_sync_lock.raw_lock);
843 spin_release(&time_sync_lock.dep_map, 1, _THIS_IP_);
930 844
931 return time; 845 return time;
932} 846}
@@ -934,8 +848,6 @@ static unsigned long long __sync_cpu_clock(cycles_t time, int cpu)
934static unsigned long long __cpu_clock(int cpu) 848static unsigned long long __cpu_clock(int cpu)
935{ 849{
936 unsigned long long now; 850 unsigned long long now;
937 unsigned long flags;
938 struct rq *rq;
939 851
940 /* 852 /*
941 * Only call sched_clock() if the scheduler has already been 853 * Only call sched_clock() if the scheduler has already been
@@ -944,11 +856,7 @@ static unsigned long long __cpu_clock(int cpu)
944 if (unlikely(!scheduler_running)) 856 if (unlikely(!scheduler_running))
945 return 0; 857 return 0;
946 858
947 local_irq_save(flags); 859 now = sched_clock_cpu(cpu);
948 rq = cpu_rq(cpu);
949 update_rq_clock(rq);
950 now = rq->clock;
951 local_irq_restore(flags);
952 860
953 return now; 861 return now;
954} 862}
@@ -960,13 +868,18 @@ static unsigned long long __cpu_clock(int cpu)
960unsigned long long cpu_clock(int cpu) 868unsigned long long cpu_clock(int cpu)
961{ 869{
962 unsigned long long prev_cpu_time, time, delta_time; 870 unsigned long long prev_cpu_time, time, delta_time;
871 unsigned long flags;
963 872
873 local_irq_save(flags);
964 prev_cpu_time = per_cpu(prev_cpu_time, cpu); 874 prev_cpu_time = per_cpu(prev_cpu_time, cpu);
965 time = __cpu_clock(cpu) + per_cpu(time_offset, cpu); 875 time = __cpu_clock(cpu) + per_cpu(time_offset, cpu);
966 delta_time = time-prev_cpu_time; 876 delta_time = time-prev_cpu_time;
967 877
968 if (unlikely(delta_time > time_sync_thresh)) 878 if (unlikely(delta_time > time_sync_thresh)) {
969 time = __sync_cpu_clock(time, cpu); 879 time = __sync_cpu_clock(time, cpu);
880 per_cpu(prev_cpu_time, cpu) = time;
881 }
882 local_irq_restore(flags);
970 883
971 return time; 884 return time;
972} 885}
@@ -1117,43 +1030,6 @@ static struct rq *this_rq_lock(void)
1117 return rq; 1030 return rq;
1118} 1031}
1119 1032
1120/*
1121 * We are going deep-idle (irqs are disabled):
1122 */
1123void sched_clock_idle_sleep_event(void)
1124{
1125 struct rq *rq = cpu_rq(smp_processor_id());
1126
1127 spin_lock(&rq->lock);
1128 __update_rq_clock(rq);
1129 spin_unlock(&rq->lock);
1130 rq->clock_deep_idle_events++;
1131}
1132EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event);
1133
1134/*
1135 * We just idled delta nanoseconds (called with irqs disabled):
1136 */
1137void sched_clock_idle_wakeup_event(u64 delta_ns)
1138{
1139 struct rq *rq = cpu_rq(smp_processor_id());
1140 u64 now = sched_clock();
1141
1142 rq->idle_clock += delta_ns;
1143 /*
1144 * Override the previous timestamp and ignore all
1145 * sched_clock() deltas that occured while we idled,
1146 * and use the PM-provided delta_ns to advance the
1147 * rq clock:
1148 */
1149 spin_lock(&rq->lock);
1150 rq->prev_clock_raw = now;
1151 rq->clock += delta_ns;
1152 spin_unlock(&rq->lock);
1153 touch_softlockup_watchdog();
1154}
1155EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
1156
1157static void __resched_task(struct task_struct *p, int tif_bit); 1033static void __resched_task(struct task_struct *p, int tif_bit);
1158 1034
1159static inline void resched_task(struct task_struct *p) 1035static inline void resched_task(struct task_struct *p)
@@ -1189,6 +1065,7 @@ static inline void resched_rq(struct rq *rq)
1189enum { 1065enum {
1190 HRTICK_SET, /* re-programm hrtick_timer */ 1066 HRTICK_SET, /* re-programm hrtick_timer */
1191 HRTICK_RESET, /* not a new slice */ 1067 HRTICK_RESET, /* not a new slice */
1068 HRTICK_BLOCK, /* stop hrtick operations */
1192}; 1069};
1193 1070
1194/* 1071/*
@@ -1200,6 +1077,8 @@ static inline int hrtick_enabled(struct rq *rq)
1200{ 1077{
1201 if (!sched_feat(HRTICK)) 1078 if (!sched_feat(HRTICK))
1202 return 0; 1079 return 0;
1080 if (unlikely(test_bit(HRTICK_BLOCK, &rq->hrtick_flags)))
1081 return 0;
1203 return hrtimer_is_hres_active(&rq->hrtick_timer); 1082 return hrtimer_is_hres_active(&rq->hrtick_timer);
1204} 1083}
1205 1084
@@ -1275,14 +1154,70 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer)
1275 WARN_ON_ONCE(cpu_of(rq) != smp_processor_id()); 1154 WARN_ON_ONCE(cpu_of(rq) != smp_processor_id());
1276 1155
1277 spin_lock(&rq->lock); 1156 spin_lock(&rq->lock);
1278 __update_rq_clock(rq); 1157 update_rq_clock(rq);
1279 rq->curr->sched_class->task_tick(rq, rq->curr, 1); 1158 rq->curr->sched_class->task_tick(rq, rq->curr, 1);
1280 spin_unlock(&rq->lock); 1159 spin_unlock(&rq->lock);
1281 1160
1282 return HRTIMER_NORESTART; 1161 return HRTIMER_NORESTART;
1283} 1162}
1284 1163
1285static inline void init_rq_hrtick(struct rq *rq) 1164static void hotplug_hrtick_disable(int cpu)
1165{
1166 struct rq *rq = cpu_rq(cpu);
1167 unsigned long flags;
1168
1169 spin_lock_irqsave(&rq->lock, flags);
1170 rq->hrtick_flags = 0;
1171 __set_bit(HRTICK_BLOCK, &rq->hrtick_flags);
1172 spin_unlock_irqrestore(&rq->lock, flags);
1173
1174 hrtick_clear(rq);
1175}
1176
1177static void hotplug_hrtick_enable(int cpu)
1178{
1179 struct rq *rq = cpu_rq(cpu);
1180 unsigned long flags;
1181
1182 spin_lock_irqsave(&rq->lock, flags);
1183 __clear_bit(HRTICK_BLOCK, &rq->hrtick_flags);
1184 spin_unlock_irqrestore(&rq->lock, flags);
1185}
1186
1187static int
1188hotplug_hrtick(struct notifier_block *nfb, unsigned long action, void *hcpu)
1189{
1190 int cpu = (int)(long)hcpu;
1191
1192 switch (action) {
1193 case CPU_UP_CANCELED:
1194 case CPU_UP_CANCELED_FROZEN:
1195 case CPU_DOWN_PREPARE:
1196 case CPU_DOWN_PREPARE_FROZEN:
1197 case CPU_DEAD:
1198 case CPU_DEAD_FROZEN:
1199 hotplug_hrtick_disable(cpu);
1200 return NOTIFY_OK;
1201
1202 case CPU_UP_PREPARE:
1203 case CPU_UP_PREPARE_FROZEN:
1204 case CPU_DOWN_FAILED:
1205 case CPU_DOWN_FAILED_FROZEN:
1206 case CPU_ONLINE:
1207 case CPU_ONLINE_FROZEN:
1208 hotplug_hrtick_enable(cpu);
1209 return NOTIFY_OK;
1210 }
1211
1212 return NOTIFY_DONE;
1213}
1214
1215static void init_hrtick(void)
1216{
1217 hotcpu_notifier(hotplug_hrtick, 0);
1218}
1219
1220static void init_rq_hrtick(struct rq *rq)
1286{ 1221{
1287 rq->hrtick_flags = 0; 1222 rq->hrtick_flags = 0;
1288 hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 1223 hrtimer_init(&rq->hrtick_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
@@ -1319,6 +1254,10 @@ static inline void init_rq_hrtick(struct rq *rq)
1319void hrtick_resched(void) 1254void hrtick_resched(void)
1320{ 1255{
1321} 1256}
1257
1258static inline void init_hrtick(void)
1259{
1260}
1322#endif 1261#endif
1323 1262
1324/* 1263/*
@@ -1438,8 +1377,8 @@ calc_delta_mine(unsigned long delta_exec, unsigned long weight,
1438{ 1377{
1439 u64 tmp; 1378 u64 tmp;
1440 1379
1441 if (unlikely(!lw->inv_weight)) 1380 if (!lw->inv_weight)
1442 lw->inv_weight = (WMULT_CONST-lw->weight/2) / (lw->weight+1); 1381 lw->inv_weight = 1 + (WMULT_CONST-lw->weight/2)/(lw->weight+1);
1443 1382
1444 tmp = (u64)delta_exec * weight; 1383 tmp = (u64)delta_exec * weight;
1445 /* 1384 /*
@@ -1748,6 +1687,8 @@ __update_group_shares_cpu(struct task_group *tg, struct sched_domain *sd,
1748 1687
1749 if (shares < MIN_SHARES) 1688 if (shares < MIN_SHARES)
1750 shares = MIN_SHARES; 1689 shares = MIN_SHARES;
1690 else if (shares > MAX_SHARES)
1691 shares = MAX_SHARES;
1751 1692
1752 __set_se_shares(tg->se[tcpu], shares); 1693 __set_se_shares(tg->se[tcpu], shares);
1753} 1694}
@@ -4339,8 +4280,10 @@ void account_system_time(struct task_struct *p, int hardirq_offset,
4339 struct rq *rq = this_rq(); 4280 struct rq *rq = this_rq();
4340 cputime64_t tmp; 4281 cputime64_t tmp;
4341 4282
4342 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) 4283 if ((p->flags & PF_VCPU) && (irq_count() - hardirq_offset == 0)) {
4343 return account_guest_time(p, cputime); 4284 account_guest_time(p, cputime);
4285 return;
4286 }
4344 4287
4345 p->stime = cputime_add(p->stime, cputime); 4288 p->stime = cputime_add(p->stime, cputime);
4346 4289
@@ -4404,19 +4347,11 @@ void scheduler_tick(void)
4404 int cpu = smp_processor_id(); 4347 int cpu = smp_processor_id();
4405 struct rq *rq = cpu_rq(cpu); 4348 struct rq *rq = cpu_rq(cpu);
4406 struct task_struct *curr = rq->curr; 4349 struct task_struct *curr = rq->curr;
4407 u64 next_tick = rq->tick_timestamp + TICK_NSEC; 4350
4351 sched_clock_tick();
4408 4352
4409 spin_lock(&rq->lock); 4353 spin_lock(&rq->lock);
4410 __update_rq_clock(rq); 4354 update_rq_clock(rq);
4411 /*
4412 * Let rq->clock advance by at least TICK_NSEC:
4413 */
4414 if (unlikely(rq->clock < next_tick)) {
4415 rq->clock = next_tick;
4416 rq->clock_underflows++;
4417 }
4418 rq->tick_timestamp = rq->clock;
4419 update_last_tick_seen(rq);
4420 update_cpu_load(rq); 4355 update_cpu_load(rq);
4421 curr->sched_class->task_tick(rq, curr, 0); 4356 curr->sched_class->task_tick(rq, curr, 0);
4422 spin_unlock(&rq->lock); 4357 spin_unlock(&rq->lock);
@@ -4570,7 +4505,7 @@ need_resched_nonpreemptible:
4570 * Do the rq-clock update outside the rq lock: 4505 * Do the rq-clock update outside the rq lock:
4571 */ 4506 */
4572 local_irq_disable(); 4507 local_irq_disable();
4573 __update_rq_clock(rq); 4508 update_rq_clock(rq);
4574 spin_lock(&rq->lock); 4509 spin_lock(&rq->lock);
4575 clear_tsk_need_resched(prev); 4510 clear_tsk_need_resched(prev);
4576 4511
@@ -4595,9 +4530,9 @@ need_resched_nonpreemptible:
4595 prev->sched_class->put_prev_task(rq, prev); 4530 prev->sched_class->put_prev_task(rq, prev);
4596 next = pick_next_task(rq, prev); 4531 next = pick_next_task(rq, prev);
4597 4532
4598 sched_info_switch(prev, next);
4599
4600 if (likely(prev != next)) { 4533 if (likely(prev != next)) {
4534 sched_info_switch(prev, next);
4535
4601 rq->nr_switches++; 4536 rq->nr_switches++;
4602 rq->curr = next; 4537 rq->curr = next;
4603 ++*switch_count; 4538 ++*switch_count;
@@ -4632,8 +4567,6 @@ EXPORT_SYMBOL(schedule);
4632asmlinkage void __sched preempt_schedule(void) 4567asmlinkage void __sched preempt_schedule(void)
4633{ 4568{
4634 struct thread_info *ti = current_thread_info(); 4569 struct thread_info *ti = current_thread_info();
4635 struct task_struct *task = current;
4636 int saved_lock_depth;
4637 4570
4638 /* 4571 /*
4639 * If there is a non-zero preempt_count or interrupts are disabled, 4572 * If there is a non-zero preempt_count or interrupts are disabled,
@@ -4644,16 +4577,7 @@ asmlinkage void __sched preempt_schedule(void)
4644 4577
4645 do { 4578 do {
4646 add_preempt_count(PREEMPT_ACTIVE); 4579 add_preempt_count(PREEMPT_ACTIVE);
4647
4648 /*
4649 * We keep the big kernel semaphore locked, but we
4650 * clear ->lock_depth so that schedule() doesnt
4651 * auto-release the semaphore:
4652 */
4653 saved_lock_depth = task->lock_depth;
4654 task->lock_depth = -1;
4655 schedule(); 4580 schedule();
4656 task->lock_depth = saved_lock_depth;
4657 sub_preempt_count(PREEMPT_ACTIVE); 4581 sub_preempt_count(PREEMPT_ACTIVE);
4658 4582
4659 /* 4583 /*
@@ -4674,26 +4598,15 @@ EXPORT_SYMBOL(preempt_schedule);
4674asmlinkage void __sched preempt_schedule_irq(void) 4598asmlinkage void __sched preempt_schedule_irq(void)
4675{ 4599{
4676 struct thread_info *ti = current_thread_info(); 4600 struct thread_info *ti = current_thread_info();
4677 struct task_struct *task = current;
4678 int saved_lock_depth;
4679 4601
4680 /* Catch callers which need to be fixed */ 4602 /* Catch callers which need to be fixed */
4681 BUG_ON(ti->preempt_count || !irqs_disabled()); 4603 BUG_ON(ti->preempt_count || !irqs_disabled());
4682 4604
4683 do { 4605 do {
4684 add_preempt_count(PREEMPT_ACTIVE); 4606 add_preempt_count(PREEMPT_ACTIVE);
4685
4686 /*
4687 * We keep the big kernel semaphore locked, but we
4688 * clear ->lock_depth so that schedule() doesnt
4689 * auto-release the semaphore:
4690 */
4691 saved_lock_depth = task->lock_depth;
4692 task->lock_depth = -1;
4693 local_irq_enable(); 4607 local_irq_enable();
4694 schedule(); 4608 schedule();
4695 local_irq_disable(); 4609 local_irq_disable();
4696 task->lock_depth = saved_lock_depth;
4697 sub_preempt_count(PREEMPT_ACTIVE); 4610 sub_preempt_count(PREEMPT_ACTIVE);
4698 4611
4699 /* 4612 /*
@@ -5612,7 +5525,6 @@ static void __cond_resched(void)
5612 } while (need_resched()); 5525 } while (need_resched());
5613} 5526}
5614 5527
5615#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PREEMPT_VOLUNTARY)
5616int __sched _cond_resched(void) 5528int __sched _cond_resched(void)
5617{ 5529{
5618 if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) && 5530 if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) &&
@@ -5623,7 +5535,6 @@ int __sched _cond_resched(void)
5623 return 0; 5535 return 0;
5624} 5536}
5625EXPORT_SYMBOL(_cond_resched); 5537EXPORT_SYMBOL(_cond_resched);
5626#endif
5627 5538
5628/* 5539/*
5629 * cond_resched_lock() - if a reschedule is pending, drop the given lock, 5540 * cond_resched_lock() - if a reschedule is pending, drop the given lock,
@@ -5918,8 +5829,11 @@ void __cpuinit init_idle(struct task_struct *idle, int cpu)
5918 spin_unlock_irqrestore(&rq->lock, flags); 5829 spin_unlock_irqrestore(&rq->lock, flags);
5919 5830
5920 /* Set the preempt count _outside_ the spinlocks! */ 5831 /* Set the preempt count _outside_ the spinlocks! */
5832#if defined(CONFIG_PREEMPT)
5833 task_thread_info(idle)->preempt_count = (idle->lock_depth >= 0);
5834#else
5921 task_thread_info(idle)->preempt_count = 0; 5835 task_thread_info(idle)->preempt_count = 0;
5922 5836#endif
5923 /* 5837 /*
5924 * The idle tasks have their own, simple scheduling class: 5838 * The idle tasks have their own, simple scheduling class:
5925 */ 5839 */
@@ -7755,7 +7669,7 @@ void partition_sched_domains(int ndoms_new, cpumask_t *doms_new,
7755{ 7669{
7756 int i, j; 7670 int i, j;
7757 7671
7758 lock_doms_cur(); 7672 mutex_lock(&sched_domains_mutex);
7759 7673
7760 /* always unregister in case we don't destroy any domains */ 7674 /* always unregister in case we don't destroy any domains */
7761 unregister_sched_domain_sysctl(); 7675 unregister_sched_domain_sysctl();
@@ -7804,7 +7718,7 @@ match2:
7804 7718
7805 register_sched_domain_sysctl(); 7719 register_sched_domain_sysctl();
7806 7720
7807 unlock_doms_cur(); 7721 mutex_unlock(&sched_domains_mutex);
7808} 7722}
7809 7723
7810#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 7724#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -7813,8 +7727,10 @@ int arch_reinit_sched_domains(void)
7813 int err; 7727 int err;
7814 7728
7815 get_online_cpus(); 7729 get_online_cpus();
7730 mutex_lock(&sched_domains_mutex);
7816 detach_destroy_domains(&cpu_online_map); 7731 detach_destroy_domains(&cpu_online_map);
7817 err = arch_init_sched_domains(&cpu_online_map); 7732 err = arch_init_sched_domains(&cpu_online_map);
7733 mutex_unlock(&sched_domains_mutex);
7818 put_online_cpus(); 7734 put_online_cpus();
7819 7735
7820 return err; 7736 return err;
@@ -7932,13 +7848,16 @@ void __init sched_init_smp(void)
7932 BUG_ON(sched_group_nodes_bycpu == NULL); 7848 BUG_ON(sched_group_nodes_bycpu == NULL);
7933#endif 7849#endif
7934 get_online_cpus(); 7850 get_online_cpus();
7851 mutex_lock(&sched_domains_mutex);
7935 arch_init_sched_domains(&cpu_online_map); 7852 arch_init_sched_domains(&cpu_online_map);
7936 cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map); 7853 cpus_andnot(non_isolated_cpus, cpu_possible_map, cpu_isolated_map);
7937 if (cpus_empty(non_isolated_cpus)) 7854 if (cpus_empty(non_isolated_cpus))
7938 cpu_set(smp_processor_id(), non_isolated_cpus); 7855 cpu_set(smp_processor_id(), non_isolated_cpus);
7856 mutex_unlock(&sched_domains_mutex);
7939 put_online_cpus(); 7857 put_online_cpus();
7940 /* XXX: Theoretical race here - CPU may be hotplugged now */ 7858 /* XXX: Theoretical race here - CPU may be hotplugged now */
7941 hotcpu_notifier(update_sched_domains, 0); 7859 hotcpu_notifier(update_sched_domains, 0);
7860 init_hrtick();
7942 7861
7943 /* Move init over to a non-isolated CPU */ 7862 /* Move init over to a non-isolated CPU */
7944 if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0) 7863 if (set_cpus_allowed_ptr(current, &non_isolated_cpus) < 0)
@@ -8025,7 +7944,7 @@ static void init_tg_cfs_entry(struct task_group *tg, struct cfs_rq *cfs_rq,
8025 7944
8026 se->my_q = cfs_rq; 7945 se->my_q = cfs_rq;
8027 se->load.weight = tg->shares; 7946 se->load.weight = tg->shares;
8028 se->load.inv_weight = div64_u64(1ULL<<32, se->load.weight); 7947 se->load.inv_weight = 0;
8029 se->parent = parent; 7948 se->parent = parent;
8030} 7949}
8031#endif 7950#endif
@@ -8149,8 +8068,6 @@ void __init sched_init(void)
8149 spin_lock_init(&rq->lock); 8068 spin_lock_init(&rq->lock);
8150 lockdep_set_class(&rq->lock, &rq->rq_lock_key); 8069 lockdep_set_class(&rq->lock, &rq->rq_lock_key);
8151 rq->nr_running = 0; 8070 rq->nr_running = 0;
8152 rq->clock = 1;
8153 update_last_tick_seen(rq);
8154 init_cfs_rq(&rq->cfs, rq); 8071 init_cfs_rq(&rq->cfs, rq);
8155 init_rt_rq(&rq->rt, rq); 8072 init_rt_rq(&rq->rt, rq);
8156#ifdef CONFIG_FAIR_GROUP_SCHED 8073#ifdef CONFIG_FAIR_GROUP_SCHED
@@ -8294,6 +8211,7 @@ EXPORT_SYMBOL(__might_sleep);
8294static void normalize_task(struct rq *rq, struct task_struct *p) 8211static void normalize_task(struct rq *rq, struct task_struct *p)
8295{ 8212{
8296 int on_rq; 8213 int on_rq;
8214
8297 update_rq_clock(rq); 8215 update_rq_clock(rq);
8298 on_rq = p->se.on_rq; 8216 on_rq = p->se.on_rq;
8299 if (on_rq) 8217 if (on_rq)
@@ -8325,7 +8243,6 @@ void normalize_rt_tasks(void)
8325 p->se.sleep_start = 0; 8243 p->se.sleep_start = 0;
8326 p->se.block_start = 0; 8244 p->se.block_start = 0;
8327#endif 8245#endif
8328 task_rq(p)->clock = 0;
8329 8246
8330 if (!rt_task(p)) { 8247 if (!rt_task(p)) {
8331 /* 8248 /*
@@ -8692,7 +8609,7 @@ static void __set_se_shares(struct sched_entity *se, unsigned long shares)
8692 dequeue_entity(cfs_rq, se, 0); 8609 dequeue_entity(cfs_rq, se, 0);
8693 8610
8694 se->load.weight = shares; 8611 se->load.weight = shares;
8695 se->load.inv_weight = div64_u64((1ULL<<32), shares); 8612 se->load.inv_weight = 0;
8696 8613
8697 if (on_rq) 8614 if (on_rq)
8698 enqueue_entity(cfs_rq, se, 0); 8615 enqueue_entity(cfs_rq, se, 0);
@@ -8722,13 +8639,10 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
8722 if (!tg->se[0]) 8639 if (!tg->se[0])
8723 return -EINVAL; 8640 return -EINVAL;
8724 8641
8725 /*
8726 * A weight of 0 or 1 can cause arithmetics problems.
8727 * (The default weight is 1024 - so there's no practical
8728 * limitation from this.)
8729 */
8730 if (shares < MIN_SHARES) 8642 if (shares < MIN_SHARES)
8731 shares = MIN_SHARES; 8643 shares = MIN_SHARES;
8644 else if (shares > MAX_SHARES)
8645 shares = MAX_SHARES;
8732 8646
8733 mutex_lock(&shares_mutex); 8647 mutex_lock(&shares_mutex);
8734 if (tg->shares == shares) 8648 if (tg->shares == shares)
@@ -8753,7 +8667,7 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
8753 * force a rebalance 8667 * force a rebalance
8754 */ 8668 */
8755 cfs_rq_set_shares(tg->cfs_rq[i], 0); 8669 cfs_rq_set_shares(tg->cfs_rq[i], 0);
8756 set_se_shares(tg->se[i], shares/nr_cpu_ids); 8670 set_se_shares(tg->se[i], shares);
8757 } 8671 }
8758 8672
8759 /* 8673 /*
@@ -9072,7 +8986,7 @@ static u64 cpu_shares_read_u64(struct cgroup *cgrp, struct cftype *cft)
9072#endif 8986#endif
9073 8987
9074#ifdef CONFIG_RT_GROUP_SCHED 8988#ifdef CONFIG_RT_GROUP_SCHED
9075static ssize_t cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft, 8989static int cpu_rt_runtime_write(struct cgroup *cgrp, struct cftype *cft,
9076 s64 val) 8990 s64 val)
9077{ 8991{
9078 return sched_group_set_rt_runtime(cgroup_tg(cgrp), val); 8992 return sched_group_set_rt_runtime(cgroup_tg(cgrp), val);
diff --git a/kernel/sched_clock.c b/kernel/sched_clock.c
new file mode 100644
index 000000000000..9c597e37f7de
--- /dev/null
+++ b/kernel/sched_clock.c
@@ -0,0 +1,236 @@
1/*
2 * sched_clock for unstable cpu clocks
3 *
4 * Copyright (C) 2008 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
5 *
6 * Based on code by:
7 * Ingo Molnar <mingo@redhat.com>
8 * Guillaume Chazarain <guichaz@gmail.com>
9 *
10 * Create a semi stable clock from a mixture of other events, including:
11 * - gtod
12 * - jiffies
13 * - sched_clock()
14 * - explicit idle events
15 *
16 * We use gtod as base and the unstable clock deltas. The deltas are filtered,
17 * making it monotonic and keeping it within an expected window. This window
18 * is set up using jiffies.
19 *
20 * Furthermore, explicit sleep and wakeup hooks allow us to account for time
21 * that is otherwise invisible (TSC gets stopped).
22 *
23 * The clock: sched_clock_cpu() is monotonic per cpu, and should be somewhat
24 * consistent between cpus (never more than 1 jiffies difference).
25 */
26#include <linux/sched.h>
27#include <linux/percpu.h>
28#include <linux/spinlock.h>
29#include <linux/ktime.h>
30#include <linux/module.h>
31
32
33#ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
34
35struct sched_clock_data {
36 /*
37 * Raw spinlock - this is a special case: this might be called
38 * from within instrumentation code so we dont want to do any
39 * instrumentation ourselves.
40 */
41 raw_spinlock_t lock;
42
43 unsigned long prev_jiffies;
44 u64 prev_raw;
45 u64 tick_raw;
46 u64 tick_gtod;
47 u64 clock;
48};
49
50static DEFINE_PER_CPU_SHARED_ALIGNED(struct sched_clock_data, sched_clock_data);
51
52static inline struct sched_clock_data *this_scd(void)
53{
54 return &__get_cpu_var(sched_clock_data);
55}
56
57static inline struct sched_clock_data *cpu_sdc(int cpu)
58{
59 return &per_cpu(sched_clock_data, cpu);
60}
61
62void sched_clock_init(void)
63{
64 u64 ktime_now = ktime_to_ns(ktime_get());
65 u64 now = 0;
66 int cpu;
67
68 for_each_possible_cpu(cpu) {
69 struct sched_clock_data *scd = cpu_sdc(cpu);
70
71 scd->lock = (raw_spinlock_t)__RAW_SPIN_LOCK_UNLOCKED;
72 scd->prev_jiffies = jiffies;
73 scd->prev_raw = now;
74 scd->tick_raw = now;
75 scd->tick_gtod = ktime_now;
76 scd->clock = ktime_now;
77 }
78}
79
80/*
81 * update the percpu scd from the raw @now value
82 *
83 * - filter out backward motion
84 * - use jiffies to generate a min,max window to clip the raw values
85 */
86static void __update_sched_clock(struct sched_clock_data *scd, u64 now)
87{
88 unsigned long now_jiffies = jiffies;
89 long delta_jiffies = now_jiffies - scd->prev_jiffies;
90 u64 clock = scd->clock;
91 u64 min_clock, max_clock;
92 s64 delta = now - scd->prev_raw;
93
94 WARN_ON_ONCE(!irqs_disabled());
95 min_clock = scd->tick_gtod + delta_jiffies * TICK_NSEC;
96
97 if (unlikely(delta < 0)) {
98 clock++;
99 goto out;
100 }
101
102 max_clock = min_clock + TICK_NSEC;
103
104 if (unlikely(clock + delta > max_clock)) {
105 if (clock < max_clock)
106 clock = max_clock;
107 else
108 clock++;
109 } else {
110 clock += delta;
111 }
112
113 out:
114 if (unlikely(clock < min_clock))
115 clock = min_clock;
116
117 scd->prev_raw = now;
118 scd->prev_jiffies = now_jiffies;
119 scd->clock = clock;
120}
121
122static void lock_double_clock(struct sched_clock_data *data1,
123 struct sched_clock_data *data2)
124{
125 if (data1 < data2) {
126 __raw_spin_lock(&data1->lock);
127 __raw_spin_lock(&data2->lock);
128 } else {
129 __raw_spin_lock(&data2->lock);
130 __raw_spin_lock(&data1->lock);
131 }
132}
133
134u64 sched_clock_cpu(int cpu)
135{
136 struct sched_clock_data *scd = cpu_sdc(cpu);
137 u64 now, clock;
138
139 WARN_ON_ONCE(!irqs_disabled());
140 now = sched_clock();
141
142 if (cpu != raw_smp_processor_id()) {
143 /*
144 * in order to update a remote cpu's clock based on our
145 * unstable raw time rebase it against:
146 * tick_raw (offset between raw counters)
147 * tick_gotd (tick offset between cpus)
148 */
149 struct sched_clock_data *my_scd = this_scd();
150
151 lock_double_clock(scd, my_scd);
152
153 now -= my_scd->tick_raw;
154 now += scd->tick_raw;
155
156 now -= my_scd->tick_gtod;
157 now += scd->tick_gtod;
158
159 __raw_spin_unlock(&my_scd->lock);
160 } else {
161 __raw_spin_lock(&scd->lock);
162 }
163
164 __update_sched_clock(scd, now);
165 clock = scd->clock;
166
167 __raw_spin_unlock(&scd->lock);
168
169 return clock;
170}
171
172void sched_clock_tick(void)
173{
174 struct sched_clock_data *scd = this_scd();
175 u64 now, now_gtod;
176
177 WARN_ON_ONCE(!irqs_disabled());
178
179 now = sched_clock();
180 now_gtod = ktime_to_ns(ktime_get());
181
182 __raw_spin_lock(&scd->lock);
183 __update_sched_clock(scd, now);
184 /*
185 * update tick_gtod after __update_sched_clock() because that will
186 * already observe 1 new jiffy; adding a new tick_gtod to that would
187 * increase the clock 2 jiffies.
188 */
189 scd->tick_raw = now;
190 scd->tick_gtod = now_gtod;
191 __raw_spin_unlock(&scd->lock);
192}
193
194/*
195 * We are going deep-idle (irqs are disabled):
196 */
197void sched_clock_idle_sleep_event(void)
198{
199 sched_clock_cpu(smp_processor_id());
200}
201EXPORT_SYMBOL_GPL(sched_clock_idle_sleep_event);
202
203/*
204 * We just idled delta nanoseconds (called with irqs disabled):
205 */
206void sched_clock_idle_wakeup_event(u64 delta_ns)
207{
208 struct sched_clock_data *scd = this_scd();
209 u64 now = sched_clock();
210
211 /*
212 * Override the previous timestamp and ignore all
213 * sched_clock() deltas that occured while we idled,
214 * and use the PM-provided delta_ns to advance the
215 * rq clock:
216 */
217 __raw_spin_lock(&scd->lock);
218 scd->prev_raw = now;
219 scd->clock += delta_ns;
220 __raw_spin_unlock(&scd->lock);
221
222 touch_softlockup_watchdog();
223}
224EXPORT_SYMBOL_GPL(sched_clock_idle_wakeup_event);
225
226#endif
227
228/*
229 * Scheduler clock - returns current time in nanosec units.
230 * This is default implementation.
231 * Architectures and sub-architectures can override this.
232 */
233unsigned long long __attribute__((weak)) sched_clock(void)
234{
235 return (unsigned long long)jiffies * (NSEC_PER_SEC / HZ);
236}
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 6b4a12558e88..5f06118fbc31 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -204,13 +204,6 @@ static void print_cpu(struct seq_file *m, int cpu)
204 PN(next_balance); 204 PN(next_balance);
205 P(curr->pid); 205 P(curr->pid);
206 PN(clock); 206 PN(clock);
207 PN(idle_clock);
208 PN(prev_clock_raw);
209 P(clock_warps);
210 P(clock_overflows);
211 P(clock_underflows);
212 P(clock_deep_idle_events);
213 PN(clock_max_delta);
214 P(cpu_load[0]); 207 P(cpu_load[0]);
215 P(cpu_load[1]); 208 P(cpu_load[1]);
216 P(cpu_load[2]); 209 P(cpu_load[2]);
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 89fa32b4edf2..e24ecd39c4b8 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -662,10 +662,15 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial)
662 if (!initial) { 662 if (!initial) {
663 /* sleeps upto a single latency don't count. */ 663 /* sleeps upto a single latency don't count. */
664 if (sched_feat(NEW_FAIR_SLEEPERS)) { 664 if (sched_feat(NEW_FAIR_SLEEPERS)) {
665 unsigned long thresh = sysctl_sched_latency;
666
667 /*
668 * convert the sleeper threshold into virtual time
669 */
665 if (sched_feat(NORMALIZED_SLEEPER)) 670 if (sched_feat(NORMALIZED_SLEEPER))
666 vruntime -= calc_delta_weight(sysctl_sched_latency, se); 671 thresh = calc_delta_fair(thresh, se);
667 else 672
668 vruntime -= sysctl_sched_latency; 673 vruntime -= thresh;
669 } 674 }
670 675
671 /* ensure we never gain time by being placed backwards. */ 676 /* ensure we never gain time by being placed backwards. */
@@ -682,6 +687,7 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup)
682 * Update run-time statistics of the 'current'. 687 * Update run-time statistics of the 'current'.
683 */ 688 */
684 update_curr(cfs_rq); 689 update_curr(cfs_rq);
690 account_entity_enqueue(cfs_rq, se);
685 691
686 if (wakeup) { 692 if (wakeup) {
687 place_entity(cfs_rq, se, 0); 693 place_entity(cfs_rq, se, 0);
@@ -692,7 +698,6 @@ enqueue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int wakeup)
692 check_spread(cfs_rq, se); 698 check_spread(cfs_rq, se);
693 if (se != cfs_rq->curr) 699 if (se != cfs_rq->curr)
694 __enqueue_entity(cfs_rq, se); 700 __enqueue_entity(cfs_rq, se);
695 account_entity_enqueue(cfs_rq, se);
696} 701}
697 702
698static void update_avg(u64 *avg, u64 sample) 703static void update_avg(u64 *avg, u64 sample)
@@ -841,8 +846,10 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
841 * queued ticks are scheduled to match the slice, so don't bother 846 * queued ticks are scheduled to match the slice, so don't bother
842 * validating it and just reschedule. 847 * validating it and just reschedule.
843 */ 848 */
844 if (queued) 849 if (queued) {
845 return resched_task(rq_of(cfs_rq)->curr); 850 resched_task(rq_of(cfs_rq)->curr);
851 return;
852 }
846 /* 853 /*
847 * don't let the period tick interfere with the hrtick preemption 854 * don't let the period tick interfere with the hrtick preemption
848 */ 855 */
@@ -957,7 +964,7 @@ static void yield_task_fair(struct rq *rq)
957 return; 964 return;
958 965
959 if (likely(!sysctl_sched_compat_yield) && curr->policy != SCHED_BATCH) { 966 if (likely(!sysctl_sched_compat_yield) && curr->policy != SCHED_BATCH) {
960 __update_rq_clock(rq); 967 update_rq_clock(rq);
961 /* 968 /*
962 * Update run-time statistics of the 'current'. 969 * Update run-time statistics of the 'current'.
963 */ 970 */
@@ -1007,7 +1014,7 @@ static int wake_idle(int cpu, struct task_struct *p)
1007 * sibling runqueue info. This will avoid the checks and cache miss 1014 * sibling runqueue info. This will avoid the checks and cache miss
1008 * penalities associated with that. 1015 * penalities associated with that.
1009 */ 1016 */
1010 if (idle_cpu(cpu) || cpu_rq(cpu)->nr_running > 1) 1017 if (idle_cpu(cpu) || cpu_rq(cpu)->cfs.nr_running > 1)
1011 return cpu; 1018 return cpu;
1012 1019
1013 for_each_domain(cpu, sd) { 1020 for_each_domain(cpu, sd) {
@@ -1611,30 +1618,6 @@ static const struct sched_class fair_sched_class = {
1611}; 1618};
1612 1619
1613#ifdef CONFIG_SCHED_DEBUG 1620#ifdef CONFIG_SCHED_DEBUG
1614static void
1615print_cfs_rq_tasks(struct seq_file *m, struct cfs_rq *cfs_rq, int depth)
1616{
1617 struct sched_entity *se;
1618
1619 if (!cfs_rq)
1620 return;
1621
1622 list_for_each_entry_rcu(se, &cfs_rq->tasks, group_node) {
1623 int i;
1624
1625 for (i = depth; i; i--)
1626 seq_puts(m, " ");
1627
1628 seq_printf(m, "%lu %s %lu\n",
1629 se->load.weight,
1630 entity_is_task(se) ? "T" : "G",
1631 calc_delta_weight(SCHED_LOAD_SCALE, se)
1632 );
1633 if (!entity_is_task(se))
1634 print_cfs_rq_tasks(m, group_cfs_rq(se), depth + 1);
1635 }
1636}
1637
1638static void print_cfs_stats(struct seq_file *m, int cpu) 1621static void print_cfs_stats(struct seq_file *m, int cpu)
1639{ 1622{
1640 struct cfs_rq *cfs_rq; 1623 struct cfs_rq *cfs_rq;
@@ -1642,9 +1625,6 @@ static void print_cfs_stats(struct seq_file *m, int cpu)
1642 rcu_read_lock(); 1625 rcu_read_lock();
1643 for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq) 1626 for_each_leaf_cfs_rq(cpu_rq(cpu), cfs_rq)
1644 print_cfs_rq(m, cpu, cfs_rq); 1627 print_cfs_rq(m, cpu, cfs_rq);
1645
1646 seq_printf(m, "\nWeight tree:\n");
1647 print_cfs_rq_tasks(m, &cpu_rq(cpu)->cfs, 1);
1648 rcu_read_unlock(); 1628 rcu_read_unlock();
1649} 1629}
1650#endif 1630#endif
diff --git a/kernel/sched_idletask.c b/kernel/sched_idletask.c
index 2bcafa375633..3a4f92dbbe66 100644
--- a/kernel/sched_idletask.c
+++ b/kernel/sched_idletask.c
@@ -99,7 +99,7 @@ static void prio_changed_idle(struct rq *rq, struct task_struct *p,
99/* 99/*
100 * Simple, special scheduling class for the per-CPU idle tasks: 100 * Simple, special scheduling class for the per-CPU idle tasks:
101 */ 101 */
102const struct sched_class idle_sched_class = { 102static const struct sched_class idle_sched_class = {
103 /* .next is NULL */ 103 /* .next is NULL */
104 /* no enqueue/yield_task for idle tasks */ 104 /* no enqueue/yield_task for idle tasks */
105 105
diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index c2730a5a4f05..060e87b0cb1c 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1098,11 +1098,14 @@ static void post_schedule_rt(struct rq *rq)
1098 } 1098 }
1099} 1099}
1100 1100
1101 1101/*
1102 * If we are not running and we are not going to reschedule soon, we should
1103 * try to push tasks away now
1104 */
1102static void task_wake_up_rt(struct rq *rq, struct task_struct *p) 1105static void task_wake_up_rt(struct rq *rq, struct task_struct *p)
1103{ 1106{
1104 if (!task_running(rq, p) && 1107 if (!task_running(rq, p) &&
1105 (p->prio >= rq->rt.highest_prio) && 1108 !test_tsk_need_resched(rq->curr) &&
1106 rq->rt.overloaded) 1109 rq->rt.overloaded)
1107 push_rt_tasks(rq); 1110 push_rt_tasks(rq);
1108} 1111}
@@ -1309,7 +1312,7 @@ static void set_curr_task_rt(struct rq *rq)
1309 p->se.exec_start = rq->clock; 1312 p->se.exec_start = rq->clock;
1310} 1313}
1311 1314
1312const struct sched_class rt_sched_class = { 1315static const struct sched_class rt_sched_class = {
1313 .next = &fair_sched_class, 1316 .next = &fair_sched_class,
1314 .enqueue_task = enqueue_task_rt, 1317 .enqueue_task = enqueue_task_rt,
1315 .dequeue_task = dequeue_task_rt, 1318 .dequeue_task = dequeue_task_rt,
diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
index f2e01ac5ab09..a5d4b1dac2a5 100644
--- a/lib/Kconfig.kgdb
+++ b/lib/Kconfig.kgdb
@@ -1,4 +1,10 @@
1 1
2config HAVE_ARCH_KGDB_SHADOW_INFO
3 bool
4
5config HAVE_ARCH_KGDB
6 bool
7
2menuconfig KGDB 8menuconfig KGDB
3 bool "KGDB: kernel debugging with remote gdb" 9 bool "KGDB: kernel debugging with remote gdb"
4 select FRAME_POINTER 10 select FRAME_POINTER
@@ -10,15 +16,10 @@ menuconfig KGDB
10 at http://kgdb.sourceforge.net as well as in DocBook form 16 at http://kgdb.sourceforge.net as well as in DocBook form
11 in Documentation/DocBook/. If unsure, say N. 17 in Documentation/DocBook/. If unsure, say N.
12 18
13config HAVE_ARCH_KGDB_SHADOW_INFO 19if KGDB
14 bool
15
16config HAVE_ARCH_KGDB
17 bool
18 20
19config KGDB_SERIAL_CONSOLE 21config KGDB_SERIAL_CONSOLE
20 tristate "KGDB: use kgdb over the serial console" 22 tristate "KGDB: use kgdb over the serial console"
21 depends on KGDB
22 select CONSOLE_POLL 23 select CONSOLE_POLL
23 select MAGIC_SYSRQ 24 select MAGIC_SYSRQ
24 default y 25 default y
@@ -28,7 +29,6 @@ config KGDB_SERIAL_CONSOLE
28 29
29config KGDB_TESTS 30config KGDB_TESTS
30 bool "KGDB: internal test suite" 31 bool "KGDB: internal test suite"
31 depends on KGDB
32 default n 32 default n
33 help 33 help
34 This is a kgdb I/O module specifically designed to test 34 This is a kgdb I/O module specifically designed to test
@@ -56,3 +56,5 @@ config KGDB_TESTS_BOOT_STRING
56 boot. See the drivers/misc/kgdbts.c for detailed 56 boot. See the drivers/misc/kgdbts.c for detailed
57 information about other strings you could use beyond the 57 information about other strings you could use beyond the
58 default of V1F100. 58 default of V1F100.
59
60endif # KGDB
diff --git a/lib/bitmap.c b/lib/bitmap.c
index c4cb48f77f0c..482df94ea21e 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -316,22 +316,6 @@ int bitmap_scnprintf(char *buf, unsigned int buflen,
316EXPORT_SYMBOL(bitmap_scnprintf); 316EXPORT_SYMBOL(bitmap_scnprintf);
317 317
318/** 318/**
319 * bitmap_scnprintf_len - return buffer length needed to convert
320 * bitmap to an ASCII hex string.
321 * @len: number of bits to be converted
322 */
323int bitmap_scnprintf_len(unsigned int len)
324{
325 /* we need 9 chars per word for 32 bit words (8 hexdigits + sep/null) */
326 int bitslen = ALIGN(len, CHUNKSZ);
327 int wordlen = CHUNKSZ / 4;
328 int buflen = (bitslen / wordlen) * (wordlen + 1) * sizeof(char);
329
330 return buflen;
331}
332EXPORT_SYMBOL(bitmap_scnprintf_len);
333
334/**
335 * __bitmap_parse - convert an ASCII hex string into a bitmap. 319 * __bitmap_parse - convert an ASCII hex string into a bitmap.
336 * @buf: pointer to buffer containing string. 320 * @buf: pointer to buffer containing string.
337 * @buflen: buffer size in bytes. If string is smaller than this 321 * @buflen: buffer size in bytes. If string is smaller than this
diff --git a/lib/devres.c b/lib/devres.c
index 26c87c49d776..72c8909006da 100644
--- a/lib/devres.c
+++ b/lib/devres.c
@@ -2,7 +2,7 @@
2#include <linux/io.h> 2#include <linux/io.h>
3#include <linux/module.h> 3#include <linux/module.h>
4 4
5static void devm_ioremap_release(struct device *dev, void *res) 5void devm_ioremap_release(struct device *dev, void *res)
6{ 6{
7 iounmap(*(void __iomem **)res); 7 iounmap(*(void __iomem **)res);
8} 8}
diff --git a/lib/hexdump.c b/lib/hexdump.c
index 343546550dc9..f07c0db81d26 100644
--- a/lib/hexdump.c
+++ b/lib/hexdump.c
@@ -12,6 +12,9 @@
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/module.h> 13#include <linux/module.h>
14 14
15const char hex_asc[] = "0123456789abcdef";
16EXPORT_SYMBOL(hex_asc);
17
15/** 18/**
16 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory 19 * hex_dump_to_buffer - convert a blob of data to "hex ASCII" in memory
17 * @buf: data blob to dump 20 * @buf: data blob to dump
@@ -93,8 +96,8 @@ void hex_dump_to_buffer(const void *buf, size_t len, int rowsize,
93 for (j = 0; (j < rowsize) && (j < len) && (lx + 4) < linebuflen; 96 for (j = 0; (j < rowsize) && (j < len) && (lx + 4) < linebuflen;
94 j++) { 97 j++) {
95 ch = ptr[j]; 98 ch = ptr[j];
96 linebuf[lx++] = hex_asc(ch >> 4); 99 linebuf[lx++] = hex_asc_hi(ch);
97 linebuf[lx++] = hex_asc(ch & 0x0f); 100 linebuf[lx++] = hex_asc_lo(ch);
98 linebuf[lx++] = ' '; 101 linebuf[lx++] = ' ';
99 } 102 }
100 ascii_column = 3 * rowsize + 2; 103 ascii_column = 3 * rowsize + 2;
diff --git a/lib/kernel_lock.c b/lib/kernel_lock.c
index cd3e82530b03..01a3c22c1b5a 100644
--- a/lib/kernel_lock.c
+++ b/lib/kernel_lock.c
@@ -11,79 +11,121 @@
11#include <linux/semaphore.h> 11#include <linux/semaphore.h>
12 12
13/* 13/*
14 * The 'big kernel semaphore' 14 * The 'big kernel lock'
15 * 15 *
16 * This mutex is taken and released recursively by lock_kernel() 16 * This spinlock is taken and released recursively by lock_kernel()
17 * and unlock_kernel(). It is transparently dropped and reacquired 17 * and unlock_kernel(). It is transparently dropped and reacquired
18 * over schedule(). It is used to protect legacy code that hasn't 18 * over schedule(). It is used to protect legacy code that hasn't
19 * been migrated to a proper locking design yet. 19 * been migrated to a proper locking design yet.
20 * 20 *
21 * Note: code locked by this semaphore will only be serialized against
22 * other code using the same locking facility. The code guarantees that
23 * the task remains on the same CPU.
24 *
25 * Don't use in new code. 21 * Don't use in new code.
26 */ 22 */
27static DECLARE_MUTEX(kernel_sem); 23static __cacheline_aligned_in_smp DEFINE_SPINLOCK(kernel_flag);
24
28 25
29/* 26/*
30 * Re-acquire the kernel semaphore. 27 * Acquire/release the underlying lock from the scheduler.
31 * 28 *
32 * This function is called with preemption off. 29 * This is called with preemption disabled, and should
30 * return an error value if it cannot get the lock and
31 * TIF_NEED_RESCHED gets set.
33 * 32 *
34 * We are executing in schedule() so the code must be extremely careful 33 * If it successfully gets the lock, it should increment
35 * about recursion, both due to the down() and due to the enabling of 34 * the preemption count like any spinlock does.
36 * preemption. schedule() will re-check the preemption flag after 35 *
37 * reacquiring the semaphore. 36 * (This works on UP too - _raw_spin_trylock will never
37 * return false in that case)
38 */ 38 */
39int __lockfunc __reacquire_kernel_lock(void) 39int __lockfunc __reacquire_kernel_lock(void)
40{ 40{
41 struct task_struct *task = current; 41 while (!_raw_spin_trylock(&kernel_flag)) {
42 int saved_lock_depth = task->lock_depth; 42 if (test_thread_flag(TIF_NEED_RESCHED))
43 43 return -EAGAIN;
44 BUG_ON(saved_lock_depth < 0); 44 cpu_relax();
45 45 }
46 task->lock_depth = -1;
47 preempt_enable_no_resched();
48
49 down(&kernel_sem);
50
51 preempt_disable(); 46 preempt_disable();
52 task->lock_depth = saved_lock_depth;
53
54 return 0; 47 return 0;
55} 48}
56 49
57void __lockfunc __release_kernel_lock(void) 50void __lockfunc __release_kernel_lock(void)
58{ 51{
59 up(&kernel_sem); 52 _raw_spin_unlock(&kernel_flag);
53 preempt_enable_no_resched();
60} 54}
61 55
62/* 56/*
63 * Getting the big kernel semaphore. 57 * These are the BKL spinlocks - we try to be polite about preemption.
58 * If SMP is not on (ie UP preemption), this all goes away because the
59 * _raw_spin_trylock() will always succeed.
64 */ 60 */
65void __lockfunc lock_kernel(void) 61#ifdef CONFIG_PREEMPT
62static inline void __lock_kernel(void)
66{ 63{
67 struct task_struct *task = current; 64 preempt_disable();
68 int depth = task->lock_depth + 1; 65 if (unlikely(!_raw_spin_trylock(&kernel_flag))) {
66 /*
67 * If preemption was disabled even before this
68 * was called, there's nothing we can be polite
69 * about - just spin.
70 */
71 if (preempt_count() > 1) {
72 _raw_spin_lock(&kernel_flag);
73 return;
74 }
69 75
70 if (likely(!depth))
71 /* 76 /*
72 * No recursion worries - we set up lock_depth _after_ 77 * Otherwise, let's wait for the kernel lock
78 * with preemption enabled..
73 */ 79 */
74 down(&kernel_sem); 80 do {
81 preempt_enable();
82 while (spin_is_locked(&kernel_flag))
83 cpu_relax();
84 preempt_disable();
85 } while (!_raw_spin_trylock(&kernel_flag));
86 }
87}
75 88
76 task->lock_depth = depth; 89#else
90
91/*
92 * Non-preemption case - just get the spinlock
93 */
94static inline void __lock_kernel(void)
95{
96 _raw_spin_lock(&kernel_flag);
77} 97}
98#endif
78 99
79void __lockfunc unlock_kernel(void) 100static inline void __unlock_kernel(void)
80{ 101{
81 struct task_struct *task = current; 102 /*
103 * the BKL is not covered by lockdep, so we open-code the
104 * unlocking sequence (and thus avoid the dep-chain ops):
105 */
106 _raw_spin_unlock(&kernel_flag);
107 preempt_enable();
108}
82 109
83 BUG_ON(task->lock_depth < 0); 110/*
111 * Getting the big kernel lock.
112 *
113 * This cannot happen asynchronously, so we only need to
114 * worry about other CPU's.
115 */
116void __lockfunc lock_kernel(void)
117{
118 int depth = current->lock_depth+1;
119 if (likely(!depth))
120 __lock_kernel();
121 current->lock_depth = depth;
122}
84 123
85 if (likely(--task->lock_depth < 0)) 124void __lockfunc unlock_kernel(void)
86 up(&kernel_sem); 125{
126 BUG_ON(current->lock_depth < 0);
127 if (likely(--current->lock_depth < 0))
128 __unlock_kernel();
87} 129}
88 130
89EXPORT_SYMBOL(lock_kernel); 131EXPORT_SYMBOL(lock_kernel);
diff --git a/lib/lmb.c b/lib/lmb.c
index 83287d3869a3..867f7b5a8231 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -19,31 +19,42 @@
19 19
20struct lmb lmb; 20struct lmb lmb;
21 21
22static int lmb_debug;
23
24static int __init early_lmb(char *p)
25{
26 if (p && strstr(p, "debug"))
27 lmb_debug = 1;
28 return 0;
29}
30early_param("lmb", early_lmb);
31
22void lmb_dump_all(void) 32void lmb_dump_all(void)
23{ 33{
24#ifdef DEBUG
25 unsigned long i; 34 unsigned long i;
26 35
27 pr_debug("lmb_dump_all:\n"); 36 if (!lmb_debug)
28 pr_debug(" memory.cnt = 0x%lx\n", lmb.memory.cnt); 37 return;
29 pr_debug(" memory.size = 0x%llx\n", 38
39 pr_info("lmb_dump_all:\n");
40 pr_info(" memory.cnt = 0x%lx\n", lmb.memory.cnt);
41 pr_info(" memory.size = 0x%llx\n",
30 (unsigned long long)lmb.memory.size); 42 (unsigned long long)lmb.memory.size);
31 for (i=0; i < lmb.memory.cnt ;i++) { 43 for (i=0; i < lmb.memory.cnt ;i++) {
32 pr_debug(" memory.region[0x%x].base = 0x%llx\n", 44 pr_info(" memory.region[0x%lx].base = 0x%llx\n",
33 i, (unsigned long long)lmb.memory.region[i].base); 45 i, (unsigned long long)lmb.memory.region[i].base);
34 pr_debug(" .size = 0x%llx\n", 46 pr_info(" .size = 0x%llx\n",
35 (unsigned long long)lmb.memory.region[i].size); 47 (unsigned long long)lmb.memory.region[i].size);
36 } 48 }
37 49
38 pr_debug(" reserved.cnt = 0x%lx\n", lmb.reserved.cnt); 50 pr_info(" reserved.cnt = 0x%lx\n", lmb.reserved.cnt);
39 pr_debug(" reserved.size = 0x%lx\n", lmb.reserved.size); 51 pr_info(" reserved.size = 0x%lx\n", lmb.reserved.size);
40 for (i=0; i < lmb.reserved.cnt ;i++) { 52 for (i=0; i < lmb.reserved.cnt ;i++) {
41 pr_debug(" reserved.region[0x%x].base = 0x%llx\n", 53 pr_info(" reserved.region[0x%lx].base = 0x%llx\n",
42 i, (unsigned long long)lmb.reserved.region[i].base); 54 i, (unsigned long long)lmb.reserved.region[i].base);
43 pr_debug(" .size = 0x%llx\n", 55 pr_info(" .size = 0x%llx\n",
44 (unsigned long long)lmb.reserved.region[i].size); 56 (unsigned long long)lmb.reserved.region[i].size);
45 } 57 }
46#endif /* DEBUG */
47} 58}
48 59
49static unsigned long lmb_addrs_overlap(u64 base1, u64 size1, u64 base2, 60static unsigned long lmb_addrs_overlap(u64 base1, u64 size1, u64 base2,
@@ -286,8 +297,7 @@ static u64 __init lmb_alloc_nid_unreserved(u64 start, u64 end,
286 j = lmb_overlaps_region(&lmb.reserved, base, size); 297 j = lmb_overlaps_region(&lmb.reserved, base, size);
287 if (j < 0) { 298 if (j < 0) {
288 /* this area isn't reserved, take it */ 299 /* this area isn't reserved, take it */
289 if (lmb_add_region(&lmb.reserved, base, 300 if (lmb_add_region(&lmb.reserved, base, size) < 0)
290 lmb_align_up(size, align)) < 0)
291 base = ~(u64)0; 301 base = ~(u64)0;
292 return base; 302 return base;
293 } 303 }
@@ -333,6 +343,10 @@ u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
333 struct lmb_region *mem = &lmb.memory; 343 struct lmb_region *mem = &lmb.memory;
334 int i; 344 int i;
335 345
346 BUG_ON(0 == size);
347
348 size = lmb_align_up(size, align);
349
336 for (i = 0; i < mem->cnt; i++) { 350 for (i = 0; i < mem->cnt; i++) {
337 u64 ret = lmb_alloc_nid_region(&mem->region[i], 351 u64 ret = lmb_alloc_nid_region(&mem->region[i],
338 nid_range, 352 nid_range,
@@ -370,6 +384,8 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
370 384
371 BUG_ON(0 == size); 385 BUG_ON(0 == size);
372 386
387 size = lmb_align_up(size, align);
388
373 /* On some platforms, make sure we allocate lowmem */ 389 /* On some platforms, make sure we allocate lowmem */
374 /* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */ 390 /* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */
375 if (max_addr == LMB_ALLOC_ANYWHERE) 391 if (max_addr == LMB_ALLOC_ANYWHERE)
@@ -393,8 +409,7 @@ u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
393 j = lmb_overlaps_region(&lmb.reserved, base, size); 409 j = lmb_overlaps_region(&lmb.reserved, base, size);
394 if (j < 0) { 410 if (j < 0) {
395 /* this area isn't reserved, take it */ 411 /* this area isn't reserved, take it */
396 if (lmb_add_region(&lmb.reserved, base, 412 if (lmb_add_region(&lmb.reserved, base, size) < 0)
397 lmb_align_up(size, align)) < 0)
398 return 0; 413 return 0;
399 return base; 414 return base;
400 } 415 }
diff --git a/lib/parser.c b/lib/parser.c
index 703c8c13b346..4f0cbc03e0e8 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -182,18 +182,25 @@ int match_hex(substring_t *s, int *result)
182} 182}
183 183
184/** 184/**
185 * match_strcpy: - copies the characters from a substring_t to a string 185 * match_strlcpy: - Copy the characters from a substring_t to a sized buffer
186 * @to: string to copy characters to. 186 * @dest: where to copy to
187 * @s: &substring_t to copy 187 * @src: &substring_t to copy
188 * @size: size of destination buffer
188 * 189 *
189 * Description: Copies the set of characters represented by the given 190 * Description: Copy the characters in &substring_t @src to the
190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is 191 * c-style string @dest. Copy no more than @size - 1 characters, plus
191 * large enough to hold the characters of @s. 192 * the terminating NUL. Return length of @src.
192 */ 193 */
193void match_strcpy(char *to, const substring_t *s) 194size_t match_strlcpy(char *dest, const substring_t *src, size_t size)
194{ 195{
195 memcpy(to, s->from, s->to - s->from); 196 size_t ret = src->to - src->from;
196 to[s->to - s->from] = '\0'; 197
198 if (size) {
199 size_t len = ret >= size ? size - 1 : ret;
200 memcpy(dest, src->from, len);
201 dest[len] = '\0';
202 }
203 return ret;
197} 204}
198 205
199/** 206/**
@@ -206,9 +213,10 @@ void match_strcpy(char *to, const substring_t *s)
206 */ 213 */
207char *match_strdup(const substring_t *s) 214char *match_strdup(const substring_t *s)
208{ 215{
209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); 216 size_t sz = s->to - s->from + 1;
217 char *p = kmalloc(sz, GFP_KERNEL);
210 if (p) 218 if (p)
211 match_strcpy(p, s); 219 match_strlcpy(p, s, sz);
212 return p; 220 return p;
213} 221}
214 222
@@ -216,5 +224,5 @@ EXPORT_SYMBOL(match_token);
216EXPORT_SYMBOL(match_int); 224EXPORT_SYMBOL(match_int);
217EXPORT_SYMBOL(match_octal); 225EXPORT_SYMBOL(match_octal);
218EXPORT_SYMBOL(match_hex); 226EXPORT_SYMBOL(match_hex);
219EXPORT_SYMBOL(match_strcpy); 227EXPORT_SYMBOL(match_strlcpy);
220EXPORT_SYMBOL(match_strdup); 228EXPORT_SYMBOL(match_strdup);
diff --git a/mm/filemap.c b/mm/filemap.c
index 239d36163bbe..1e6a7d34874f 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1461,6 +1461,11 @@ page_not_uptodate:
1461 */ 1461 */
1462 ClearPageError(page); 1462 ClearPageError(page);
1463 error = mapping->a_ops->readpage(file, page); 1463 error = mapping->a_ops->readpage(file, page);
1464 if (!error) {
1465 wait_on_page_locked(page);
1466 if (!PageUptodate(page))
1467 error = -EIO;
1468 }
1464 page_cache_release(page); 1469 page_cache_release(page);
1465 1470
1466 if (!error || error == AOP_TRUNCATED_PAGE) 1471 if (!error || error == AOP_TRUNCATED_PAGE)
@@ -1655,7 +1660,7 @@ int should_remove_suid(struct dentry *dentry)
1655} 1660}
1656EXPORT_SYMBOL(should_remove_suid); 1661EXPORT_SYMBOL(should_remove_suid);
1657 1662
1658int __remove_suid(struct dentry *dentry, int kill) 1663static int __remove_suid(struct dentry *dentry, int kill)
1659{ 1664{
1660 struct iattr newattrs; 1665 struct iattr newattrs;
1661 1666
diff --git a/mm/memory.c b/mm/memory.c
index bbab1e37055e..fb5608a120ed 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -311,6 +311,21 @@ int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address)
311 if (!new) 311 if (!new)
312 return -ENOMEM; 312 return -ENOMEM;
313 313
314 /*
315 * Ensure all pte setup (eg. pte page lock and page clearing) are
316 * visible before the pte is made visible to other CPUs by being
317 * put into page tables.
318 *
319 * The other side of the story is the pointer chasing in the page
320 * table walking code (when walking the page table without locking;
321 * ie. most of the time). Fortunately, these data accesses consist
322 * of a chain of data-dependent loads, meaning most CPUs (alpha
323 * being the notable exception) will already guarantee loads are
324 * seen in-order. See the alpha page table accessors for the
325 * smp_read_barrier_depends() barriers in page table walking code.
326 */
327 smp_wmb(); /* Could be smp_wmb__xxx(before|after)_spin_lock */
328
314 spin_lock(&mm->page_table_lock); 329 spin_lock(&mm->page_table_lock);
315 if (!pmd_present(*pmd)) { /* Has another populated it ? */ 330 if (!pmd_present(*pmd)) { /* Has another populated it ? */
316 mm->nr_ptes++; 331 mm->nr_ptes++;
@@ -329,6 +344,8 @@ int __pte_alloc_kernel(pmd_t *pmd, unsigned long address)
329 if (!new) 344 if (!new)
330 return -ENOMEM; 345 return -ENOMEM;
331 346
347 smp_wmb(); /* See comment in __pte_alloc */
348
332 spin_lock(&init_mm.page_table_lock); 349 spin_lock(&init_mm.page_table_lock);
333 if (!pmd_present(*pmd)) { /* Has another populated it ? */ 350 if (!pmd_present(*pmd)) { /* Has another populated it ? */
334 pmd_populate_kernel(&init_mm, pmd, new); 351 pmd_populate_kernel(&init_mm, pmd, new);
@@ -969,7 +986,7 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
969 goto no_page_table; 986 goto no_page_table;
970 987
971 pmd = pmd_offset(pud, address); 988 pmd = pmd_offset(pud, address);
972 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) 989 if (pmd_none(*pmd))
973 goto no_page_table; 990 goto no_page_table;
974 991
975 if (pmd_huge(*pmd)) { 992 if (pmd_huge(*pmd)) {
@@ -978,6 +995,9 @@ struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
978 goto out; 995 goto out;
979 } 996 }
980 997
998 if (unlikely(pmd_bad(*pmd)))
999 goto no_page_table;
1000
981 ptep = pte_offset_map_lock(mm, pmd, address, &ptl); 1001 ptep = pte_offset_map_lock(mm, pmd, address, &ptl);
982 if (!ptep) 1002 if (!ptep)
983 goto out; 1003 goto out;
@@ -2616,6 +2636,8 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
2616 if (!new) 2636 if (!new)
2617 return -ENOMEM; 2637 return -ENOMEM;
2618 2638
2639 smp_wmb(); /* See comment in __pte_alloc */
2640
2619 spin_lock(&mm->page_table_lock); 2641 spin_lock(&mm->page_table_lock);
2620 if (pgd_present(*pgd)) /* Another has populated it */ 2642 if (pgd_present(*pgd)) /* Another has populated it */
2621 pud_free(mm, new); 2643 pud_free(mm, new);
@@ -2637,6 +2659,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
2637 if (!new) 2659 if (!new)
2638 return -ENOMEM; 2660 return -ENOMEM;
2639 2661
2662 smp_wmb(); /* See comment in __pte_alloc */
2663
2640 spin_lock(&mm->page_table_lock); 2664 spin_lock(&mm->page_table_lock);
2641#ifndef __ARCH_HAS_4LEVEL_HACK 2665#ifndef __ARCH_HAS_4LEVEL_HACK
2642 if (pud_present(*pud)) /* Another has populated it */ 2666 if (pud_present(*pud)) /* Another has populated it */
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index b17dca7249f8..833f854eabe5 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -159,21 +159,58 @@ void register_page_bootmem_info_node(struct pglist_data *pgdat)
159} 159}
160#endif /* !CONFIG_SPARSEMEM_VMEMMAP */ 160#endif /* !CONFIG_SPARSEMEM_VMEMMAP */
161 161
162static void grow_zone_span(struct zone *zone, unsigned long start_pfn,
163 unsigned long end_pfn)
164{
165 unsigned long old_zone_end_pfn;
166
167 zone_span_writelock(zone);
168
169 old_zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages;
170 if (start_pfn < zone->zone_start_pfn)
171 zone->zone_start_pfn = start_pfn;
172
173 zone->spanned_pages = max(old_zone_end_pfn, end_pfn) -
174 zone->zone_start_pfn;
175
176 zone_span_writeunlock(zone);
177}
178
179static void grow_pgdat_span(struct pglist_data *pgdat, unsigned long start_pfn,
180 unsigned long end_pfn)
181{
182 unsigned long old_pgdat_end_pfn =
183 pgdat->node_start_pfn + pgdat->node_spanned_pages;
184
185 if (start_pfn < pgdat->node_start_pfn)
186 pgdat->node_start_pfn = start_pfn;
187
188 pgdat->node_spanned_pages = max(old_pgdat_end_pfn, end_pfn) -
189 pgdat->node_start_pfn;
190}
191
162static int __add_zone(struct zone *zone, unsigned long phys_start_pfn) 192static int __add_zone(struct zone *zone, unsigned long phys_start_pfn)
163{ 193{
164 struct pglist_data *pgdat = zone->zone_pgdat; 194 struct pglist_data *pgdat = zone->zone_pgdat;
165 int nr_pages = PAGES_PER_SECTION; 195 int nr_pages = PAGES_PER_SECTION;
166 int nid = pgdat->node_id; 196 int nid = pgdat->node_id;
167 int zone_type; 197 int zone_type;
198 unsigned long flags;
168 199
169 zone_type = zone - pgdat->node_zones; 200 zone_type = zone - pgdat->node_zones;
170 if (!zone->wait_table) { 201 if (!zone->wait_table) {
171 int ret = 0; 202 int ret;
203
172 ret = init_currently_empty_zone(zone, phys_start_pfn, 204 ret = init_currently_empty_zone(zone, phys_start_pfn,
173 nr_pages, MEMMAP_HOTPLUG); 205 nr_pages, MEMMAP_HOTPLUG);
174 if (ret < 0) 206 if (ret)
175 return ret; 207 return ret;
176 } 208 }
209 pgdat_resize_lock(zone->zone_pgdat, &flags);
210 grow_zone_span(zone, phys_start_pfn, phys_start_pfn + nr_pages);
211 grow_pgdat_span(zone->zone_pgdat, phys_start_pfn,
212 phys_start_pfn + nr_pages);
213 pgdat_resize_unlock(zone->zone_pgdat, &flags);
177 memmap_init_zone(nr_pages, nid, zone_type, 214 memmap_init_zone(nr_pages, nid, zone_type,
178 phys_start_pfn, MEMMAP_HOTPLUG); 215 phys_start_pfn, MEMMAP_HOTPLUG);
179 return 0; 216 return 0;
@@ -299,36 +336,6 @@ int __remove_pages(struct zone *zone, unsigned long phys_start_pfn,
299} 336}
300EXPORT_SYMBOL_GPL(__remove_pages); 337EXPORT_SYMBOL_GPL(__remove_pages);
301 338
302static void grow_zone_span(struct zone *zone,
303 unsigned long start_pfn, unsigned long end_pfn)
304{
305 unsigned long old_zone_end_pfn;
306
307 zone_span_writelock(zone);
308
309 old_zone_end_pfn = zone->zone_start_pfn + zone->spanned_pages;
310 if (start_pfn < zone->zone_start_pfn)
311 zone->zone_start_pfn = start_pfn;
312
313 zone->spanned_pages = max(old_zone_end_pfn, end_pfn) -
314 zone->zone_start_pfn;
315
316 zone_span_writeunlock(zone);
317}
318
319static void grow_pgdat_span(struct pglist_data *pgdat,
320 unsigned long start_pfn, unsigned long end_pfn)
321{
322 unsigned long old_pgdat_end_pfn =
323 pgdat->node_start_pfn + pgdat->node_spanned_pages;
324
325 if (start_pfn < pgdat->node_start_pfn)
326 pgdat->node_start_pfn = start_pfn;
327
328 pgdat->node_spanned_pages = max(old_pgdat_end_pfn, end_pfn) -
329 pgdat->node_start_pfn;
330}
331
332void online_page(struct page *page) 339void online_page(struct page *page)
333{ 340{
334 totalram_pages++; 341 totalram_pages++;
@@ -367,7 +374,6 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages,
367 374
368int online_pages(unsigned long pfn, unsigned long nr_pages) 375int online_pages(unsigned long pfn, unsigned long nr_pages)
369{ 376{
370 unsigned long flags;
371 unsigned long onlined_pages = 0; 377 unsigned long onlined_pages = 0;
372 struct zone *zone; 378 struct zone *zone;
373 int need_zonelists_rebuild = 0; 379 int need_zonelists_rebuild = 0;
@@ -395,11 +401,6 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
395 * memory_block->state_mutex. 401 * memory_block->state_mutex.
396 */ 402 */
397 zone = page_zone(pfn_to_page(pfn)); 403 zone = page_zone(pfn_to_page(pfn));
398 pgdat_resize_lock(zone->zone_pgdat, &flags);
399 grow_zone_span(zone, pfn, pfn + nr_pages);
400 grow_pgdat_span(zone->zone_pgdat, pfn, pfn + nr_pages);
401 pgdat_resize_unlock(zone->zone_pgdat, &flags);
402
403 /* 404 /*
404 * If this zone is not populated, then it is not in zonelist. 405 * If this zone is not populated, then it is not in zonelist.
405 * This means the page allocator ignores this zone. 406 * This means the page allocator ignores this zone.
@@ -408,8 +409,15 @@ int online_pages(unsigned long pfn, unsigned long nr_pages)
408 if (!populated_zone(zone)) 409 if (!populated_zone(zone))
409 need_zonelists_rebuild = 1; 410 need_zonelists_rebuild = 1;
410 411
411 walk_memory_resource(pfn, nr_pages, &onlined_pages, 412 ret = walk_memory_resource(pfn, nr_pages, &onlined_pages,
412 online_pages_range); 413 online_pages_range);
414 if (ret) {
415 printk(KERN_DEBUG "online_pages %lx at %lx failed\n",
416 nr_pages, pfn);
417 memory_notify(MEM_CANCEL_ONLINE, &arg);
418 return ret;
419 }
420
413 zone->present_pages += onlined_pages; 421 zone->present_pages += onlined_pages;
414 zone->zone_pgdat->node_present_pages += onlined_pages; 422 zone->zone_pgdat->node_present_pages += onlined_pages;
415 423
diff --git a/mm/mprotect.c b/mm/mprotect.c
index 4de546899dc1..a5bf31c27375 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -26,6 +26,13 @@
26#include <asm/cacheflush.h> 26#include <asm/cacheflush.h>
27#include <asm/tlbflush.h> 27#include <asm/tlbflush.h>
28 28
29#ifndef pgprot_modify
30static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
31{
32 return newprot;
33}
34#endif
35
29static void change_pte_range(struct mm_struct *mm, pmd_t *pmd, 36static void change_pte_range(struct mm_struct *mm, pmd_t *pmd,
30 unsigned long addr, unsigned long end, pgprot_t newprot, 37 unsigned long addr, unsigned long end, pgprot_t newprot,
31 int dirty_accountable) 38 int dirty_accountable)
@@ -192,7 +199,9 @@ success:
192 * held in write mode. 199 * held in write mode.
193 */ 200 */
194 vma->vm_flags = newflags; 201 vma->vm_flags = newflags;
195 vma->vm_page_prot = vm_get_page_prot(newflags); 202 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
203 vm_get_page_prot(newflags));
204
196 if (vma_wants_writenotify(vma)) { 205 if (vma_wants_writenotify(vma)) {
197 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED); 206 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
198 dirty_accountable = 1; 207 dirty_accountable = 1;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bdd5c432c426..63835579323a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2862,8 +2862,6 @@ __meminit int init_currently_empty_zone(struct zone *zone,
2862 2862
2863 zone->zone_start_pfn = zone_start_pfn; 2863 zone->zone_start_pfn = zone_start_pfn;
2864 2864
2865 memmap_init(size, pgdat->node_id, zone_idx(zone), zone_start_pfn);
2866
2867 zone_init_free_lists(zone); 2865 zone_init_free_lists(zone);
2868 2866
2869 return 0; 2867 return 0;
@@ -3433,6 +3431,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
3433 ret = init_currently_empty_zone(zone, zone_start_pfn, 3431 ret = init_currently_empty_zone(zone, zone_start_pfn,
3434 size, MEMMAP_EARLY); 3432 size, MEMMAP_EARLY);
3435 BUG_ON(ret); 3433 BUG_ON(ret);
3434 memmap_init(size, nid, j, zone_start_pfn);
3436 zone_start_pfn += size; 3435 zone_start_pfn += size;
3437 } 3436 }
3438} 3437}
diff --git a/mm/pdflush.c b/mm/pdflush.c
index 1c96cfc9e040..9d834aa4b979 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -207,7 +207,6 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0)
207 207
208 spin_lock_irqsave(&pdflush_lock, flags); 208 spin_lock_irqsave(&pdflush_lock, flags);
209 if (list_empty(&pdflush_list)) { 209 if (list_empty(&pdflush_list)) {
210 spin_unlock_irqrestore(&pdflush_lock, flags);
211 ret = -1; 210 ret = -1;
212 } else { 211 } else {
213 struct pdflush_work *pdf; 212 struct pdflush_work *pdf;
@@ -219,8 +218,9 @@ int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0)
219 pdf->fn = fn; 218 pdf->fn = fn;
220 pdf->arg0 = arg0; 219 pdf->arg0 = arg0;
221 wake_up_process(pdf->who); 220 wake_up_process(pdf->who);
222 spin_unlock_irqrestore(&pdflush_lock, flags);
223 } 221 }
222 spin_unlock_irqrestore(&pdflush_lock, flags);
223
224 return ret; 224 return ret;
225} 225}
226 226
diff --git a/mm/slub.c b/mm/slub.c
index d379b782fc83..a505a828ef41 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3762,7 +3762,7 @@ static int any_slab_objects(struct kmem_cache *s)
3762 if (!n) 3762 if (!n)
3763 continue; 3763 continue;
3764 3764
3765 if (atomic_read(&n->total_objects)) 3765 if (atomic_long_read(&n->total_objects))
3766 return 1; 3766 return 1;
3767 } 3767 }
3768 return 0; 3768 return 0;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 1a32130b958c..db9eabb2c5b3 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -41,7 +41,9 @@ static void sum_vm_events(unsigned long *ret, cpumask_t *cpumask)
41*/ 41*/
42void all_vm_events(unsigned long *ret) 42void all_vm_events(unsigned long *ret)
43{ 43{
44 get_online_cpus();
44 sum_vm_events(ret, &cpu_online_map); 45 sum_vm_events(ret, &cpu_online_map);
46 put_online_cpus();
45} 47}
46EXPORT_SYMBOL_GPL(all_vm_events); 48EXPORT_SYMBOL_GPL(all_vm_events);
47 49
diff --git a/net/9p/Kconfig b/net/9p/Kconfig
index bafc50c9e6ff..ff34c5acc130 100644
--- a/net/9p/Kconfig
+++ b/net/9p/Kconfig
@@ -13,16 +13,6 @@ menuconfig NET_9P
13 13
14 If unsure, say N. 14 If unsure, say N.
15 15
16config NET_9P_FD
17 depends on NET_9P
18 default y if NET_9P
19 tristate "9P File Descriptor Transports (Experimental)"
20 help
21 This builds support for file descriptor transports for 9p
22 which includes support for TCP/IP, named pipes, or passed
23 file descriptors. TCP/IP is the default transport for 9p,
24 so if you are going to use 9p, you'll likely want this.
25
26config NET_9P_VIRTIO 16config NET_9P_VIRTIO
27 depends on NET_9P && EXPERIMENTAL && VIRTIO 17 depends on NET_9P && EXPERIMENTAL && VIRTIO
28 tristate "9P Virtio Transport (Experimental)" 18 tristate "9P Virtio Transport (Experimental)"
diff --git a/net/9p/Makefile b/net/9p/Makefile
index 8a1051101898..519219480db1 100644
--- a/net/9p/Makefile
+++ b/net/9p/Makefile
@@ -1,5 +1,4 @@
1obj-$(CONFIG_NET_9P) := 9pnet.o 1obj-$(CONFIG_NET_9P) := 9pnet.o
2obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o
3obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o 2obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o
4 3
59pnet-objs := \ 49pnet-objs := \
@@ -9,8 +8,6 @@ obj-$(CONFIG_NET_9P_VIRTIO) += 9pnet_virtio.o
9 error.o \ 8 error.o \
10 fcprint.o \ 9 fcprint.o \
11 util.o \ 10 util.o \
12
139pnet_fd-objs := \
14 trans_fd.o \ 11 trans_fd.o \
15 12
169pnet_virtio-objs := \ 139pnet_virtio-objs := \
diff --git a/net/9p/client.c b/net/9p/client.c
index 84e087e24146..2ffe40cf2f01 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -64,21 +64,30 @@ static match_table_t tokens = {
64 * @options: options string passed from mount 64 * @options: options string passed from mount
65 * @v9ses: existing v9fs session information 65 * @v9ses: existing v9fs session information
66 * 66 *
67 * Return 0 upon success, -ERRNO upon failure
67 */ 68 */
68 69
69static void parse_opts(char *options, struct p9_client *clnt) 70static int parse_opts(char *opts, struct p9_client *clnt)
70{ 71{
72 char *options;
71 char *p; 73 char *p;
72 substring_t args[MAX_OPT_ARGS]; 74 substring_t args[MAX_OPT_ARGS];
73 int option; 75 int option;
74 int ret; 76 int ret = 0;
75 77
76 clnt->trans_mod = v9fs_default_trans(); 78 clnt->trans_mod = v9fs_default_trans();
77 clnt->dotu = 1; 79 clnt->dotu = 1;
78 clnt->msize = 8192; 80 clnt->msize = 8192;
79 81
80 if (!options) 82 if (!opts)
81 return; 83 return 0;
84
85 options = kstrdup(opts, GFP_KERNEL);
86 if (!options) {
87 P9_DPRINTK(P9_DEBUG_ERROR,
88 "failed to allocate copy of option string\n");
89 return -ENOMEM;
90 }
82 91
83 while ((p = strsep(&options, ",")) != NULL) { 92 while ((p = strsep(&options, ",")) != NULL) {
84 int token; 93 int token;
@@ -86,10 +95,11 @@ static void parse_opts(char *options, struct p9_client *clnt)
86 continue; 95 continue;
87 token = match_token(p, tokens, args); 96 token = match_token(p, tokens, args);
88 if (token < Opt_trans) { 97 if (token < Opt_trans) {
89 ret = match_int(&args[0], &option); 98 int r = match_int(&args[0], &option);
90 if (ret < 0) { 99 if (r < 0) {
91 P9_DPRINTK(P9_DEBUG_ERROR, 100 P9_DPRINTK(P9_DEBUG_ERROR,
92 "integer field, but no integer?\n"); 101 "integer field, but no integer?\n");
102 ret = r;
93 continue; 103 continue;
94 } 104 }
95 } 105 }
@@ -107,6 +117,8 @@ static void parse_opts(char *options, struct p9_client *clnt)
107 continue; 117 continue;
108 } 118 }
109 } 119 }
120 kfree(options);
121 return ret;
110} 122}
111 123
112 124
@@ -138,16 +150,20 @@ struct p9_client *p9_client_create(const char *dev_name, char *options)
138 if (!clnt) 150 if (!clnt)
139 return ERR_PTR(-ENOMEM); 151 return ERR_PTR(-ENOMEM);
140 152
153 clnt->trans = NULL;
141 spin_lock_init(&clnt->lock); 154 spin_lock_init(&clnt->lock);
142 INIT_LIST_HEAD(&clnt->fidlist); 155 INIT_LIST_HEAD(&clnt->fidlist);
143 clnt->fidpool = p9_idpool_create(); 156 clnt->fidpool = p9_idpool_create();
144 if (!clnt->fidpool) { 157 if (IS_ERR(clnt->fidpool)) {
145 err = PTR_ERR(clnt->fidpool); 158 err = PTR_ERR(clnt->fidpool);
146 clnt->fidpool = NULL; 159 clnt->fidpool = NULL;
147 goto error; 160 goto error;
148 } 161 }
149 162
150 parse_opts(options, clnt); 163 err = parse_opts(options, clnt);
164 if (err < 0)
165 goto error;
166
151 if (clnt->trans_mod == NULL) { 167 if (clnt->trans_mod == NULL) {
152 err = -EPROTONOSUPPORT; 168 err = -EPROTONOSUPPORT;
153 P9_DPRINTK(P9_DEBUG_ERROR, 169 P9_DPRINTK(P9_DEBUG_ERROR,
diff --git a/net/9p/conv.c b/net/9p/conv.c
index 3fe35d532c87..44547201f5bc 100644
--- a/net/9p/conv.c
+++ b/net/9p/conv.c
@@ -197,7 +197,7 @@ static void buf_get_qid(struct cbuf *bufp, struct p9_qid *qid)
197 197
198/** 198/**
199 * p9_size_wstat - calculate the size of a variable length stat struct 199 * p9_size_wstat - calculate the size of a variable length stat struct
200 * @stat: metadata (stat) structure 200 * @wstat: metadata (stat) structure
201 * @dotu: non-zero if 9P2000.u 201 * @dotu: non-zero if 9P2000.u
202 * 202 *
203 */ 203 */
@@ -511,6 +511,12 @@ p9_create_common(struct cbuf *bufp, u32 size, u8 id)
511 return fc; 511 return fc;
512} 512}
513 513
514/**
515 * p9_set_tag - set the tag field of an &p9_fcall structure
516 * @fc: fcall structure to set tag within
517 * @tag: tag id to set
518 */
519
514void p9_set_tag(struct p9_fcall *fc, u16 tag) 520void p9_set_tag(struct p9_fcall *fc, u16 tag)
515{ 521{
516 fc->tag = tag; 522 fc->tag = tag;
@@ -518,6 +524,12 @@ void p9_set_tag(struct p9_fcall *fc, u16 tag)
518} 524}
519EXPORT_SYMBOL(p9_set_tag); 525EXPORT_SYMBOL(p9_set_tag);
520 526
527/**
528 * p9_create_tversion - allocates and creates a T_VERSION request
529 * @msize: requested maximum data size
530 * @version: version string to negotiate
531 *
532 */
521struct p9_fcall *p9_create_tversion(u32 msize, char *version) 533struct p9_fcall *p9_create_tversion(u32 msize, char *version)
522{ 534{
523 int size; 535 int size;
@@ -542,6 +554,16 @@ error:
542} 554}
543EXPORT_SYMBOL(p9_create_tversion); 555EXPORT_SYMBOL(p9_create_tversion);
544 556
557/**
558 * p9_create_tauth - allocates and creates a T_AUTH request
559 * @afid: handle to use for authentication protocol
560 * @uname: user name attempting to authenticate
561 * @aname: mount specifier for remote server
562 * @n_uname: numeric id for user attempting to authneticate
563 * @dotu: 9P2000.u extension flag
564 *
565 */
566
545struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname, 567struct p9_fcall *p9_create_tauth(u32 afid, char *uname, char *aname,
546 u32 n_uname, int dotu) 568 u32 n_uname, int dotu)
547{ 569{
@@ -580,6 +602,18 @@ error:
580} 602}
581EXPORT_SYMBOL(p9_create_tauth); 603EXPORT_SYMBOL(p9_create_tauth);
582 604
605/**
606 * p9_create_tattach - allocates and creates a T_ATTACH request
607 * @fid: handle to use for the new mount point
608 * @afid: handle to use for authentication protocol
609 * @uname: user name attempting to attach
610 * @aname: mount specifier for remote server
611 * @n_uname: numeric id for user attempting to attach
612 * @n_uname: numeric id for user attempting to attach
613 * @dotu: 9P2000.u extension flag
614 *
615 */
616
583struct p9_fcall * 617struct p9_fcall *
584p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname, 618p9_create_tattach(u32 fid, u32 afid, char *uname, char *aname,
585 u32 n_uname, int dotu) 619 u32 n_uname, int dotu)
@@ -616,6 +650,12 @@ error:
616} 650}
617EXPORT_SYMBOL(p9_create_tattach); 651EXPORT_SYMBOL(p9_create_tattach);
618 652
653/**
654 * p9_create_tflush - allocates and creates a T_FLUSH request
655 * @oldtag: tag id for the transaction we are attempting to cancel
656 *
657 */
658
619struct p9_fcall *p9_create_tflush(u16 oldtag) 659struct p9_fcall *p9_create_tflush(u16 oldtag)
620{ 660{
621 int size; 661 int size;
@@ -639,6 +679,15 @@ error:
639} 679}
640EXPORT_SYMBOL(p9_create_tflush); 680EXPORT_SYMBOL(p9_create_tflush);
641 681
682/**
683 * p9_create_twalk - allocates and creates a T_FLUSH request
684 * @fid: handle we are traversing from
685 * @newfid: a new handle for this transaction
686 * @nwname: number of path elements to traverse
687 * @wnames: array of path elements
688 *
689 */
690
642struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname, 691struct p9_fcall *p9_create_twalk(u32 fid, u32 newfid, u16 nwname,
643 char **wnames) 692 char **wnames)
644{ 693{
@@ -677,6 +726,13 @@ error:
677} 726}
678EXPORT_SYMBOL(p9_create_twalk); 727EXPORT_SYMBOL(p9_create_twalk);
679 728
729/**
730 * p9_create_topen - allocates and creates a T_OPEN request
731 * @fid: handle we are trying to open
732 * @mode: what mode we are trying to open the file in
733 *
734 */
735
680struct p9_fcall *p9_create_topen(u32 fid, u8 mode) 736struct p9_fcall *p9_create_topen(u32 fid, u8 mode)
681{ 737{
682 int size; 738 int size;
@@ -701,6 +757,19 @@ error:
701} 757}
702EXPORT_SYMBOL(p9_create_topen); 758EXPORT_SYMBOL(p9_create_topen);
703 759
760/**
761 * p9_create_tcreate - allocates and creates a T_CREATE request
762 * @fid: handle of directory we are trying to create in
763 * @name: name of the file we are trying to create
764 * @perm: permissions for the file we are trying to create
765 * @mode: what mode we are trying to open the file in
766 * @extension: 9p2000.u extension string (for special files)
767 * @dotu: 9p2000.u enabled flag
768 *
769 * Note: Plan 9 create semantics include opening the resulting file
770 * which is why mode is included.
771 */
772
704struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode, 773struct p9_fcall *p9_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
705 char *extension, int dotu) 774 char *extension, int dotu)
706{ 775{
@@ -736,6 +805,13 @@ error:
736} 805}
737EXPORT_SYMBOL(p9_create_tcreate); 806EXPORT_SYMBOL(p9_create_tcreate);
738 807
808/**
809 * p9_create_tread - allocates and creates a T_READ request
810 * @fid: handle of the file we are trying to read
811 * @offset: offset to start reading from
812 * @count: how many bytes to read
813 */
814
739struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count) 815struct p9_fcall *p9_create_tread(u32 fid, u64 offset, u32 count)
740{ 816{
741 int size; 817 int size;
@@ -761,6 +837,17 @@ error:
761} 837}
762EXPORT_SYMBOL(p9_create_tread); 838EXPORT_SYMBOL(p9_create_tread);
763 839
840/**
841 * p9_create_twrite - allocates and creates a T_WRITE request from the kernel
842 * @fid: handle of the file we are trying to write
843 * @offset: offset to start writing at
844 * @count: how many bytes to write
845 * @data: data to write
846 *
847 * This function will create a requst with data buffers from the kernel
848 * such as the page cache.
849 */
850
764struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count, 851struct p9_fcall *p9_create_twrite(u32 fid, u64 offset, u32 count,
765 const char *data) 852 const char *data)
766{ 853{
@@ -794,6 +881,16 @@ error:
794} 881}
795EXPORT_SYMBOL(p9_create_twrite); 882EXPORT_SYMBOL(p9_create_twrite);
796 883
884/**
885 * p9_create_twrite_u - allocates and creates a T_WRITE request from userspace
886 * @fid: handle of the file we are trying to write
887 * @offset: offset to start writing at
888 * @count: how many bytes to write
889 * @data: data to write
890 *
891 * This function will create a request with data buffers from userspace
892 */
893
797struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count, 894struct p9_fcall *p9_create_twrite_u(u32 fid, u64 offset, u32 count,
798 const char __user *data) 895 const char __user *data)
799{ 896{
@@ -827,6 +924,14 @@ error:
827} 924}
828EXPORT_SYMBOL(p9_create_twrite_u); 925EXPORT_SYMBOL(p9_create_twrite_u);
829 926
927/**
928 * p9_create_tclunk - allocate a request to forget about a file handle
929 * @fid: handle of the file we closing or forgetting about
930 *
931 * clunk is used both to close open files and to discard transient handles
932 * which may be created during meta-data operations and hierarchy traversal.
933 */
934
830struct p9_fcall *p9_create_tclunk(u32 fid) 935struct p9_fcall *p9_create_tclunk(u32 fid)
831{ 936{
832 int size; 937 int size;
@@ -850,6 +955,12 @@ error:
850} 955}
851EXPORT_SYMBOL(p9_create_tclunk); 956EXPORT_SYMBOL(p9_create_tclunk);
852 957
958/**
959 * p9_create_tremove - allocate and create a request to remove a file
960 * @fid: handle of the file or directory we are removing
961 *
962 */
963
853struct p9_fcall *p9_create_tremove(u32 fid) 964struct p9_fcall *p9_create_tremove(u32 fid)
854{ 965{
855 int size; 966 int size;
@@ -873,6 +984,12 @@ error:
873} 984}
874EXPORT_SYMBOL(p9_create_tremove); 985EXPORT_SYMBOL(p9_create_tremove);
875 986
987/**
988 * p9_create_tstat - allocate and populate a request for attributes
989 * @fid: handle of the file or directory we are trying to get the attributes of
990 *
991 */
992
876struct p9_fcall *p9_create_tstat(u32 fid) 993struct p9_fcall *p9_create_tstat(u32 fid)
877{ 994{
878 int size; 995 int size;
@@ -896,6 +1013,14 @@ error:
896} 1013}
897EXPORT_SYMBOL(p9_create_tstat); 1014EXPORT_SYMBOL(p9_create_tstat);
898 1015
1016/**
1017 * p9_create_tstat - allocate and populate a request to change attributes
1018 * @fid: handle of the file or directory we are trying to change
1019 * @wstat: &p9_stat structure with attributes we wish to set
1020 * @dotu: 9p2000.u enabled flag
1021 *
1022 */
1023
899struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat, 1024struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat,
900 int dotu) 1025 int dotu)
901{ 1026{
@@ -922,3 +1047,4 @@ error:
922 return fc; 1047 return fc;
923} 1048}
924EXPORT_SYMBOL(p9_create_twstat); 1049EXPORT_SYMBOL(p9_create_twstat);
1050
diff --git a/net/9p/error.c b/net/9p/error.c
index 64104b9cb422..fdebe4314062 100644
--- a/net/9p/error.c
+++ b/net/9p/error.c
@@ -33,6 +33,13 @@
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <net/9p/9p.h> 34#include <net/9p/9p.h>
35 35
36/**
37 * struct errormap - map string errors from Plan 9 to Linux numeric ids
38 * @name: string sent over 9P
39 * @val: numeric id most closely representing @name
40 * @namelen: length of string
41 * @list: hash-table list for string lookup
42 */
36struct errormap { 43struct errormap {
37 char *name; 44 char *name;
38 int val; 45 int val;
@@ -177,8 +184,7 @@ static struct errormap errmap[] = {
177}; 184};
178 185
179/** 186/**
180 * p9_error_init - preload 187 * p9_error_init - preload mappings into hash list
181 * @errstr: error string
182 * 188 *
183 */ 189 */
184 190
@@ -206,6 +212,7 @@ EXPORT_SYMBOL(p9_error_init);
206/** 212/**
207 * errstr2errno - convert error string to error number 213 * errstr2errno - convert error string to error number
208 * @errstr: error string 214 * @errstr: error string
215 * @len: length of error string
209 * 216 *
210 */ 217 */
211 218
@@ -230,8 +237,8 @@ int p9_errstr2errno(char *errstr, int len)
230 if (errno == 0) { 237 if (errno == 0) {
231 /* TODO: if error isn't found, add it dynamically */ 238 /* TODO: if error isn't found, add it dynamically */
232 errstr[len] = 0; 239 errstr[len] = 0;
233 printk(KERN_ERR "%s: errstr :%s: not found\n", __func__, 240 printk(KERN_ERR "%s: server reported unknown error %s\n",
234 errstr); 241 __func__, errstr);
235 errno = 1; 242 errno = 1;
236 } 243 }
237 244
diff --git a/net/9p/fcprint.c b/net/9p/fcprint.c
index 40244fbd9b0d..53dd8e28dd8a 100644
--- a/net/9p/fcprint.c
+++ b/net/9p/fcprint.c
@@ -142,6 +142,14 @@ p9_printdata(char *buf, int buflen, u8 *data, int datalen)
142 return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16); 142 return p9_dumpdata(buf, buflen, data, datalen < 16?datalen:16);
143} 143}
144 144
145/**
146 * p9_printfcall - decode and print a protocol structure into a buffer
147 * @buf: buffer to deposit decoded structure into
148 * @buflen: available space in buffer
149 * @fc: protocol rpc structure of type &p9_fcall
150 * @extended: whether or not session is operating with extended protocol
151 */
152
145int 153int
146p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended) 154p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int extended)
147{ 155{
diff --git a/net/9p/mod.c b/net/9p/mod.c
index c285aab2af04..bdee1fb7cc62 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -39,9 +39,6 @@ module_param_named(debug, p9_debug_level, uint, 0);
39MODULE_PARM_DESC(debug, "9P debugging level"); 39MODULE_PARM_DESC(debug, "9P debugging level");
40#endif 40#endif
41 41
42extern int p9_mux_global_init(void);
43extern void p9_mux_global_exit(void);
44
45/* 42/*
46 * Dynamic Transport Registration Routines 43 * Dynamic Transport Registration Routines
47 * 44 *
@@ -52,7 +49,7 @@ static struct p9_trans_module *v9fs_default_transport;
52 49
53/** 50/**
54 * v9fs_register_trans - register a new transport with 9p 51 * v9fs_register_trans - register a new transport with 9p
55 * @m - structure describing the transport module and entry points 52 * @m: structure describing the transport module and entry points
56 * 53 *
57 */ 54 */
58void v9fs_register_trans(struct p9_trans_module *m) 55void v9fs_register_trans(struct p9_trans_module *m)
@@ -65,7 +62,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
65 62
66/** 63/**
67 * v9fs_match_trans - match transport versus registered transports 64 * v9fs_match_trans - match transport versus registered transports
68 * @arg: string identifying transport 65 * @name: string identifying transport
69 * 66 *
70 */ 67 */
71struct p9_trans_module *v9fs_match_trans(const substring_t *name) 68struct p9_trans_module *v9fs_match_trans(const substring_t *name)
@@ -110,6 +107,7 @@ static int __init init_p9(void)
110 107
111 p9_error_init(); 108 p9_error_init();
112 printk(KERN_INFO "Installing 9P2000 support\n"); 109 printk(KERN_INFO "Installing 9P2000 support\n");
110 p9_trans_fd_init();
113 111
114 return ret; 112 return ret;
115} 113}
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index f624dff76852..4507f744f44e 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -47,12 +47,29 @@
47#define SCHED_TIMEOUT 10 47#define SCHED_TIMEOUT 10
48#define MAXPOLLWADDR 2 48#define MAXPOLLWADDR 2
49 49
50/**
51 * struct p9_fd_opts - per-transport options
52 * @rfd: file descriptor for reading (trans=fd)
53 * @wfd: file descriptor for writing (trans=fd)
54 * @port: port to connect to (trans=tcp)
55 *
56 */
57
50struct p9_fd_opts { 58struct p9_fd_opts {
51 int rfd; 59 int rfd;
52 int wfd; 60 int wfd;
53 u16 port; 61 u16 port;
54}; 62};
55 63
64
65/**
66 * struct p9_trans_fd - transport state
67 * @rd: reference to file to read from
68 * @wr: reference of file to write to
69 * @conn: connection state reference
70 *
71 */
72
56struct p9_trans_fd { 73struct p9_trans_fd {
57 struct file *rd; 74 struct file *rd;
58 struct file *wr; 75 struct file *wr;
@@ -90,10 +107,24 @@ enum {
90}; 107};
91 108
92struct p9_req; 109struct p9_req;
93
94typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a); 110typedef void (*p9_conn_req_callback)(struct p9_req *req, void *a);
111
112/**
113 * struct p9_req - fd mux encoding of an rpc transaction
114 * @lock: protects req_list
115 * @tag: numeric tag for rpc transaction
116 * @tcall: request &p9_fcall structure
117 * @rcall: response &p9_fcall structure
118 * @err: error state
119 * @cb: callback for when response is received
120 * @cba: argument to pass to callback
121 * @flush: flag to indicate RPC has been flushed
122 * @req_list: list link for higher level objects to chain requests
123 *
124 */
125
95struct p9_req { 126struct p9_req {
96 spinlock_t lock; /* protect request structure */ 127 spinlock_t lock;
97 int tag; 128 int tag;
98 struct p9_fcall *tcall; 129 struct p9_fcall *tcall;
99 struct p9_fcall *rcall; 130 struct p9_fcall *rcall;
@@ -104,7 +135,39 @@ struct p9_req {
104 struct list_head req_list; 135 struct list_head req_list;
105}; 136};
106 137
107struct p9_mux_poll_task; 138struct p9_mux_poll_task {
139 struct task_struct *task;
140 struct list_head mux_list;
141 int muxnum;
142};
143
144/**
145 * struct p9_conn - fd mux connection state information
146 * @lock: protects mux_list (?)
147 * @mux_list: list link for mux to manage multiple connections (?)
148 * @poll_task: task polling on this connection
149 * @msize: maximum size for connection (dup)
150 * @extended: 9p2000.u flag (dup)
151 * @trans: reference to transport instance for this connection
152 * @tagpool: id accounting for transactions
153 * @err: error state
154 * @equeue: event wait_q (?)
155 * @req_list: accounting for requests which have been sent
156 * @unsent_req_list: accounting for requests that haven't been sent
157 * @rcall: current response &p9_fcall structure
158 * @rpos: read position in current frame
159 * @rbuf: current read buffer
160 * @wpos: write position for current frame
161 * @wsize: amount of data to write for current frame
162 * @wbuf: current write buffer
163 * @poll_wait: array of wait_q's for various worker threads
164 * @poll_waddr: ????
165 * @pt: poll state
166 * @rq: current read work
167 * @wq: current write work
168 * @wsched: ????
169 *
170 */
108 171
109struct p9_conn { 172struct p9_conn {
110 spinlock_t lock; /* protect lock structure */ 173 spinlock_t lock; /* protect lock structure */
@@ -132,11 +195,16 @@ struct p9_conn {
132 unsigned long wsched; 195 unsigned long wsched;
133}; 196};
134 197
135struct p9_mux_poll_task { 198/**
136 struct task_struct *task; 199 * struct p9_mux_rpc - fd mux rpc accounting structure
137 struct list_head mux_list; 200 * @m: connection this request was issued on
138 int muxnum; 201 * @err: error state
139}; 202 * @tcall: request &p9_fcall
203 * @rcall: response &p9_fcall
204 * @wqueue: wait queue that client is blocked on for this rpc
205 *
206 * Bug: isn't this information duplicated elsewhere like &p9_req
207 */
140 208
141struct p9_mux_rpc { 209struct p9_mux_rpc {
142 struct p9_conn *m; 210 struct p9_conn *m;
@@ -207,10 +275,12 @@ static void p9_mux_put_tag(struct p9_conn *m, u16 tag)
207 275
208/** 276/**
209 * p9_mux_calc_poll_procs - calculates the number of polling procs 277 * p9_mux_calc_poll_procs - calculates the number of polling procs
210 * based on the number of mounted v9fs filesystems. 278 * @muxnum: number of mounts
211 * 279 *
280 * Calculation is based on the number of mounted v9fs filesystems.
212 * The current implementation returns sqrt of the number of mounts. 281 * The current implementation returns sqrt of the number of mounts.
213 */ 282 */
283
214static int p9_mux_calc_poll_procs(int muxnum) 284static int p9_mux_calc_poll_procs(int muxnum)
215{ 285{
216 int n; 286 int n;
@@ -331,12 +401,11 @@ static void p9_mux_poll_stop(struct p9_conn *m)
331 401
332/** 402/**
333 * p9_conn_create - allocate and initialize the per-session mux data 403 * p9_conn_create - allocate and initialize the per-session mux data
334 * Creates the polling task if this is the first session. 404 * @trans: transport structure
335 * 405 *
336 * @trans - transport structure 406 * Note: Creates the polling task if this is the first session.
337 * @msize - maximum message size
338 * @extended - extended flag
339 */ 407 */
408
340static struct p9_conn *p9_conn_create(struct p9_trans *trans) 409static struct p9_conn *p9_conn_create(struct p9_trans *trans)
341{ 410{
342 int i, n; 411 int i, n;
@@ -406,7 +475,10 @@ static struct p9_conn *p9_conn_create(struct p9_trans *trans)
406 475
407/** 476/**
408 * p9_mux_destroy - cancels all pending requests and frees mux resources 477 * p9_mux_destroy - cancels all pending requests and frees mux resources
478 * @m: mux to destroy
479 *
409 */ 480 */
481
410static void p9_conn_destroy(struct p9_conn *m) 482static void p9_conn_destroy(struct p9_conn *m)
411{ 483{
412 P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m, 484 P9_DPRINTK(P9_DEBUG_MUX, "mux %p prev %p next %p\n", m,
@@ -429,9 +501,14 @@ static void p9_conn_destroy(struct p9_conn *m)
429} 501}
430 502
431/** 503/**
432 * p9_pollwait - called by files poll operation to add v9fs-poll task 504 * p9_pollwait - add poll task to the wait queue
433 * to files wait queue 505 * @filp: file pointer being polled
506 * @wait_address: wait_q to block on
507 * @p: poll state
508 *
509 * called by files poll operation to add v9fs-poll task to files wait queue
434 */ 510 */
511
435static void 512static void
436p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p) 513p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
437{ 514{
@@ -462,7 +539,10 @@ p9_pollwait(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
462 539
463/** 540/**
464 * p9_poll_mux - polls a mux and schedules read or write works if necessary 541 * p9_poll_mux - polls a mux and schedules read or write works if necessary
542 * @m: connection to poll
543 *
465 */ 544 */
545
466static void p9_poll_mux(struct p9_conn *m) 546static void p9_poll_mux(struct p9_conn *m)
467{ 547{
468 int n; 548 int n;
@@ -499,9 +579,14 @@ static void p9_poll_mux(struct p9_conn *m)
499} 579}
500 580
501/** 581/**
502 * p9_poll_proc - polls all v9fs transports for new events and queues 582 * p9_poll_proc - poll worker thread
503 * the appropriate work to the work queue 583 * @a: thread state and arguments
584 *
585 * polls all v9fs transports for new events and queues the appropriate
586 * work to the work queue
587 *
504 */ 588 */
589
505static int p9_poll_proc(void *a) 590static int p9_poll_proc(void *a)
506{ 591{
507 struct p9_conn *m, *mtmp; 592 struct p9_conn *m, *mtmp;
@@ -527,7 +612,10 @@ static int p9_poll_proc(void *a)
527 612
528/** 613/**
529 * p9_write_work - called when a transport can send some data 614 * p9_write_work - called when a transport can send some data
615 * @work: container for work to be done
616 *
530 */ 617 */
618
531static void p9_write_work(struct work_struct *work) 619static void p9_write_work(struct work_struct *work)
532{ 620{
533 int n, err; 621 int n, err;
@@ -638,7 +726,10 @@ static void process_request(struct p9_conn *m, struct p9_req *req)
638 726
639/** 727/**
640 * p9_read_work - called when there is some data to be read from a transport 728 * p9_read_work - called when there is some data to be read from a transport
729 * @work: container of work to be done
730 *
641 */ 731 */
732
642static void p9_read_work(struct work_struct *work) 733static void p9_read_work(struct work_struct *work)
643{ 734{
644 int n, err; 735 int n, err;
@@ -793,7 +884,9 @@ error:
793 * @tc: request to be sent 884 * @tc: request to be sent
794 * @cb: callback function to call when response is received 885 * @cb: callback function to call when response is received
795 * @cba: parameter to pass to the callback function 886 * @cba: parameter to pass to the callback function
887 *
796 */ 888 */
889
797static struct p9_req *p9_send_request(struct p9_conn *m, 890static struct p9_req *p9_send_request(struct p9_conn *m,
798 struct p9_fcall *tc, 891 struct p9_fcall *tc,
799 p9_conn_req_callback cb, void *cba) 892 p9_conn_req_callback cb, void *cba)
@@ -961,10 +1054,12 @@ p9_conn_rpc_cb(struct p9_req *req, void *a)
961/** 1054/**
962 * p9_fd_rpc- sends 9P request and waits until a response is available. 1055 * p9_fd_rpc- sends 9P request and waits until a response is available.
963 * The function can be interrupted. 1056 * The function can be interrupted.
964 * @m: mux data 1057 * @t: transport data
965 * @tc: request to be sent 1058 * @tc: request to be sent
966 * @rc: pointer where a pointer to the response is stored 1059 * @rc: pointer where a pointer to the response is stored
1060 *
967 */ 1061 */
1062
968int 1063int
969p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) 1064p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
970{ 1065{
@@ -1041,8 +1136,10 @@ p9_fd_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
1041 * @m: mux data 1136 * @m: mux data
1042 * @tc: request to be sent 1137 * @tc: request to be sent
1043 * @cb: callback function to be called when response arrives 1138 * @cb: callback function to be called when response arrives
1044 * @cba: value to pass to the callback function 1139 * @a: value to pass to the callback function
1140 *
1045 */ 1141 */
1142
1046int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc, 1143int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc,
1047 p9_conn_req_callback cb, void *a) 1144 p9_conn_req_callback cb, void *a)
1048{ 1145{
@@ -1065,7 +1162,9 @@ int p9_conn_rpcnb(struct p9_conn *m, struct p9_fcall *tc,
1065 * p9_conn_cancel - cancel all pending requests with error 1162 * p9_conn_cancel - cancel all pending requests with error
1066 * @m: mux data 1163 * @m: mux data
1067 * @err: error code 1164 * @err: error code
1165 *
1068 */ 1166 */
1167
1069void p9_conn_cancel(struct p9_conn *m, int err) 1168void p9_conn_cancel(struct p9_conn *m, int err)
1070{ 1169{
1071 struct p9_req *req, *rtmp; 1170 struct p9_req *req, *rtmp;
@@ -1097,35 +1196,46 @@ void p9_conn_cancel(struct p9_conn *m, int err)
1097} 1196}
1098 1197
1099/** 1198/**
1100 * v9fs_parse_options - parse mount options into session structure 1199 * parse_options - parse mount options into session structure
1101 * @options: options string passed from mount 1200 * @options: options string passed from mount
1102 * @v9ses: existing v9fs session information 1201 * @opts: transport-specific structure to parse options into
1103 * 1202 *
1203 * Returns 0 upon success, -ERRNO upon failure
1104 */ 1204 */
1105 1205
1106static void parse_opts(char *options, struct p9_fd_opts *opts) 1206static int parse_opts(char *params, struct p9_fd_opts *opts)
1107{ 1207{
1108 char *p; 1208 char *p;
1109 substring_t args[MAX_OPT_ARGS]; 1209 substring_t args[MAX_OPT_ARGS];
1110 int option; 1210 int option;
1211 char *options;
1111 int ret; 1212 int ret;
1112 1213
1113 opts->port = P9_PORT; 1214 opts->port = P9_PORT;
1114 opts->rfd = ~0; 1215 opts->rfd = ~0;
1115 opts->wfd = ~0; 1216 opts->wfd = ~0;
1116 1217
1117 if (!options) 1218 if (!params)
1118 return; 1219 return 0;
1220
1221 options = kstrdup(params, GFP_KERNEL);
1222 if (!options) {
1223 P9_DPRINTK(P9_DEBUG_ERROR,
1224 "failed to allocate copy of option string\n");
1225 return -ENOMEM;
1226 }
1119 1227
1120 while ((p = strsep(&options, ",")) != NULL) { 1228 while ((p = strsep(&options, ",")) != NULL) {
1121 int token; 1229 int token;
1230 int r;
1122 if (!*p) 1231 if (!*p)
1123 continue; 1232 continue;
1124 token = match_token(p, tokens, args); 1233 token = match_token(p, tokens, args);
1125 ret = match_int(&args[0], &option); 1234 r = match_int(&args[0], &option);
1126 if (ret < 0) { 1235 if (r < 0) {
1127 P9_DPRINTK(P9_DEBUG_ERROR, 1236 P9_DPRINTK(P9_DEBUG_ERROR,
1128 "integer field, but no integer?\n"); 1237 "integer field, but no integer?\n");
1238 ret = r;
1129 continue; 1239 continue;
1130 } 1240 }
1131 switch (token) { 1241 switch (token) {
@@ -1142,6 +1252,8 @@ static void parse_opts(char *options, struct p9_fd_opts *opts)
1142 continue; 1252 continue;
1143 } 1253 }
1144 } 1254 }
1255 kfree(options);
1256 return 0;
1145} 1257}
1146 1258
1147static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd) 1259static int p9_fd_open(struct p9_trans *trans, int rfd, int wfd)
@@ -1193,11 +1305,12 @@ static int p9_socket_open(struct p9_trans *trans, struct socket *csocket)
1193 1305
1194/** 1306/**
1195 * p9_fd_read- read from a fd 1307 * p9_fd_read- read from a fd
1196 * @v9ses: session information 1308 * @trans: transport instance state
1197 * @v: buffer to receive data into 1309 * @v: buffer to receive data into
1198 * @len: size of receive buffer 1310 * @len: size of receive buffer
1199 * 1311 *
1200 */ 1312 */
1313
1201static int p9_fd_read(struct p9_trans *trans, void *v, int len) 1314static int p9_fd_read(struct p9_trans *trans, void *v, int len)
1202{ 1315{
1203 int ret; 1316 int ret;
@@ -1220,11 +1333,12 @@ static int p9_fd_read(struct p9_trans *trans, void *v, int len)
1220 1333
1221/** 1334/**
1222 * p9_fd_write - write to a socket 1335 * p9_fd_write - write to a socket
1223 * @v9ses: session information 1336 * @trans: transport instance state
1224 * @v: buffer to send data from 1337 * @v: buffer to send data from
1225 * @len: size of send buffer 1338 * @len: size of send buffer
1226 * 1339 *
1227 */ 1340 */
1341
1228static int p9_fd_write(struct p9_trans *trans, void *v, int len) 1342static int p9_fd_write(struct p9_trans *trans, void *v, int len)
1229{ 1343{
1230 int ret; 1344 int ret;
@@ -1296,6 +1410,7 @@ end:
1296 * @trans: private socket structure 1410 * @trans: private socket structure
1297 * 1411 *
1298 */ 1412 */
1413
1299static void p9_fd_close(struct p9_trans *trans) 1414static void p9_fd_close(struct p9_trans *trans)
1300{ 1415{
1301 struct p9_trans_fd *ts; 1416 struct p9_trans_fd *ts;
@@ -1318,6 +1433,23 @@ static void p9_fd_close(struct p9_trans *trans)
1318 kfree(ts); 1433 kfree(ts);
1319} 1434}
1320 1435
1436/*
1437 * stolen from NFS - maybe should be made a generic function?
1438 */
1439static inline int valid_ipaddr4(const char *buf)
1440{
1441 int rc, count, in[4];
1442
1443 rc = sscanf(buf, "%d.%d.%d.%d", &in[0], &in[1], &in[2], &in[3]);
1444 if (rc != 4)
1445 return -EINVAL;
1446 for (count = 0; count < 4; count++) {
1447 if (in[count] > 255)
1448 return -EINVAL;
1449 }
1450 return 0;
1451}
1452
1321static struct p9_trans * 1453static struct p9_trans *
1322p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu) 1454p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu)
1323{ 1455{
@@ -1328,7 +1460,12 @@ p9_trans_create_tcp(const char *addr, char *args, int msize, unsigned char dotu)
1328 struct p9_fd_opts opts; 1460 struct p9_fd_opts opts;
1329 struct p9_trans_fd *p; 1461 struct p9_trans_fd *p;
1330 1462
1331 parse_opts(args, &opts); 1463 err = parse_opts(args, &opts);
1464 if (err < 0)
1465 return ERR_PTR(err);
1466
1467 if (valid_ipaddr4(addr) < 0)
1468 return ERR_PTR(-EINVAL);
1332 1469
1333 csocket = NULL; 1470 csocket = NULL;
1334 trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL); 1471 trans = kmalloc(sizeof(struct p9_trans), GFP_KERNEL);
@@ -1508,7 +1645,7 @@ static struct p9_trans_module p9_fd_trans = {
1508 .create = p9_trans_create_fd, 1645 .create = p9_trans_create_fd,
1509}; 1646};
1510 1647
1511static int __init p9_trans_fd_init(void) 1648int p9_trans_fd_init(void)
1512{ 1649{
1513 int ret = p9_mux_global_init(); 1650 int ret = p9_mux_global_init();
1514 if (ret) { 1651 if (ret) {
@@ -1522,9 +1659,4 @@ static int __init p9_trans_fd_init(void)
1522 1659
1523 return 0; 1660 return 0;
1524} 1661}
1525 1662EXPORT_SYMBOL(p9_trans_fd_init);
1526module_init(p9_trans_fd_init);
1527
1528MODULE_AUTHOR("Latchesar Ionkov <lucho@ionkov.net>");
1529MODULE_AUTHOR("Eric Van Hensbergen <ericvh@gmail.com>");
1530MODULE_LICENSE("GPL");
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index de7a9f532edc..42adc052b149 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -49,29 +49,75 @@
49#define VIRTQUEUE_NUM 128 49#define VIRTQUEUE_NUM 128
50 50
51/* a single mutex to manage channel initialization and attachment */ 51/* a single mutex to manage channel initialization and attachment */
52static DECLARE_MUTEX(virtio_9p_lock); 52static DEFINE_MUTEX(virtio_9p_lock);
53/* global which tracks highest initialized channel */ 53/* global which tracks highest initialized channel */
54static int chan_index; 54static int chan_index;
55 55
56#define P9_INIT_MAXTAG 16 56#define P9_INIT_MAXTAG 16
57 57
58#define REQ_STATUS_IDLE 0 58
59#define REQ_STATUS_SENT 1 59/**
60#define REQ_STATUS_RCVD 2 60 * enum p9_req_status_t - virtio request status
61#define REQ_STATUS_FLSH 3 61 * @REQ_STATUS_IDLE: request slot unused
62 * @REQ_STATUS_SENT: request sent to server
63 * @REQ_STATUS_RCVD: response received from server
64 * @REQ_STATUS_FLSH: request has been flushed
65 *
66 * The @REQ_STATUS_IDLE state is used to mark a request slot as unused
67 * but use is actually tracked by the idpool structure which handles tag
68 * id allocation.
69 *
70 */
71
72enum p9_req_status_t {
73 REQ_STATUS_IDLE,
74 REQ_STATUS_SENT,
75 REQ_STATUS_RCVD,
76 REQ_STATUS_FLSH,
77};
78
79/**
80 * struct p9_req_t - virtio request slots
81 * @status: status of this request slot
82 * @wq: wait_queue for the client to block on for this request
83 *
84 * The virtio transport uses an array to track outstanding requests
85 * instead of a list. While this may incurr overhead during initial
86 * allocation or expansion, it makes request lookup much easier as the
87 * tag id is a index into an array. (We use tag+1 so that we can accomodate
88 * the -1 tag for the T_VERSION request).
89 * This also has the nice effect of only having to allocate wait_queues
90 * once, instead of constantly allocating and freeing them. Its possible
91 * other resources could benefit from this scheme as well.
92 *
93 */
62 94
63struct p9_req_t { 95struct p9_req_t {
64 int status; 96 int status;
65 wait_queue_head_t *wq; 97 wait_queue_head_t *wq;
66}; 98};
67 99
68/* We keep all per-channel information in a structure. 100/**
101 * struct virtio_chan - per-instance transport information
102 * @initialized: whether the channel is initialized
103 * @inuse: whether the channel is in use
104 * @lock: protects multiple elements within this structure
105 * @vdev: virtio dev associated with this channel
106 * @vq: virtio queue associated with this channel
107 * @tagpool: accounting for tag ids (and request slots)
108 * @reqs: array of request slots
109 * @max_tag: current number of request_slots allocated
110 * @sg: scatter gather list which is used to pack a request (protected?)
111 *
112 * We keep all per-channel information in a structure.
69 * This structure is allocated within the devices dev->mem space. 113 * This structure is allocated within the devices dev->mem space.
70 * A pointer to the structure will get put in the transport private. 114 * A pointer to the structure will get put in the transport private.
115 *
71 */ 116 */
117
72static struct virtio_chan { 118static struct virtio_chan {
73 bool initialized; /* channel is initialized */ 119 bool initialized;
74 bool inuse; /* channel is in use */ 120 bool inuse;
75 121
76 spinlock_t lock; 122 spinlock_t lock;
77 123
@@ -86,7 +132,19 @@ static struct virtio_chan {
86 struct scatterlist sg[VIRTQUEUE_NUM]; 132 struct scatterlist sg[VIRTQUEUE_NUM];
87} channels[MAX_9P_CHAN]; 133} channels[MAX_9P_CHAN];
88 134
89/* Lookup requests by tag */ 135/**
136 * p9_lookup_tag - Lookup requests by tag
137 * @c: virtio channel to lookup tag within
138 * @tag: numeric id for transaction
139 *
140 * this is a simple array lookup, but will grow the
141 * request_slots as necessary to accomodate transaction
142 * ids which did not previously have a slot.
143 *
144 * Bugs: there is currently no upper limit on request slots set
145 * here, but that should be constrained by the id accounting.
146 */
147
90static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag) 148static struct p9_req_t *p9_lookup_tag(struct virtio_chan *c, u16 tag)
91{ 149{
92 /* This looks up the original request by tag so we know which 150 /* This looks up the original request by tag so we know which
@@ -130,11 +188,20 @@ static unsigned int rest_of_page(void *data)
130 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE); 188 return PAGE_SIZE - ((unsigned long)data % PAGE_SIZE);
131} 189}
132 190
191/**
192 * p9_virtio_close - reclaim resources of a channel
193 * @trans: transport state
194 *
195 * This reclaims a channel by freeing its resources and
196 * reseting its inuse flag.
197 *
198 */
199
133static void p9_virtio_close(struct p9_trans *trans) 200static void p9_virtio_close(struct p9_trans *trans)
134{ 201{
135 struct virtio_chan *chan = trans->priv; 202 struct virtio_chan *chan = trans->priv;
136 int count; 203 int count;
137 unsigned int flags; 204 unsigned long flags;
138 205
139 spin_lock_irqsave(&chan->lock, flags); 206 spin_lock_irqsave(&chan->lock, flags);
140 p9_idpool_destroy(chan->tagpool); 207 p9_idpool_destroy(chan->tagpool);
@@ -144,13 +211,26 @@ static void p9_virtio_close(struct p9_trans *trans)
144 chan->max_tag = 0; 211 chan->max_tag = 0;
145 spin_unlock_irqrestore(&chan->lock, flags); 212 spin_unlock_irqrestore(&chan->lock, flags);
146 213
147 down(&virtio_9p_lock); 214 mutex_lock(&virtio_9p_lock);
148 chan->inuse = false; 215 chan->inuse = false;
149 up(&virtio_9p_lock); 216 mutex_unlock(&virtio_9p_lock);
150 217
151 kfree(trans); 218 kfree(trans);
152} 219}
153 220
221/**
222 * req_done - callback which signals activity from the server
223 * @vq: virtio queue activity was received on
224 *
225 * This notifies us that the server has triggered some activity
226 * on the virtio channel - most likely a response to request we
227 * sent. Figure out which requests now have responses and wake up
228 * those threads.
229 *
230 * Bugs: could do with some additional sanity checking, but appears to work.
231 *
232 */
233
154static void req_done(struct virtqueue *vq) 234static void req_done(struct virtqueue *vq)
155{ 235{
156 struct virtio_chan *chan = vq->vdev->priv; 236 struct virtio_chan *chan = vq->vdev->priv;
@@ -169,6 +249,20 @@ static void req_done(struct virtqueue *vq)
169 spin_unlock_irqrestore(&chan->lock, flags); 249 spin_unlock_irqrestore(&chan->lock, flags);
170} 250}
171 251
252/**
253 * pack_sg_list - pack a scatter gather list from a linear buffer
254 * @sg: scatter/gather list to pack into
255 * @start: which segment of the sg_list to start at
256 * @limit: maximum segment to pack data to
257 * @data: data to pack into scatter/gather list
258 * @count: amount of data to pack into the scatter/gather list
259 *
260 * sg_lists have multiple segments of various sizes. This will pack
261 * arbitrary data into an existing scatter gather list, segmenting the
262 * data as necessary within constraints.
263 *
264 */
265
172static int 266static int
173pack_sg_list(struct scatterlist *sg, int start, int limit, char *data, 267pack_sg_list(struct scatterlist *sg, int start, int limit, char *data,
174 int count) 268 int count)
@@ -189,6 +283,14 @@ pack_sg_list(struct scatterlist *sg, int start, int limit, char *data,
189 return index-start; 283 return index-start;
190} 284}
191 285
286/**
287 * p9_virtio_rpc - issue a request and wait for a response
288 * @t: transport state
289 * @tc: &p9_fcall request to transmit
290 * @rc: &p9_fcall to put reponse into
291 *
292 */
293
192static int 294static int
193p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc) 295p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
194{ 296{
@@ -263,16 +365,26 @@ p9_virtio_rpc(struct p9_trans *t, struct p9_fcall *tc, struct p9_fcall **rc)
263 return 0; 365 return 0;
264} 366}
265 367
368/**
369 * p9_virtio_probe - probe for existence of 9P virtio channels
370 * @vdev: virtio device to probe
371 *
372 * This probes for existing virtio channels. At present only
373 * a single channel is in use, so in the future more work may need
374 * to be done here.
375 *
376 */
377
266static int p9_virtio_probe(struct virtio_device *vdev) 378static int p9_virtio_probe(struct virtio_device *vdev)
267{ 379{
268 int err; 380 int err;
269 struct virtio_chan *chan; 381 struct virtio_chan *chan;
270 int index; 382 int index;
271 383
272 down(&virtio_9p_lock); 384 mutex_lock(&virtio_9p_lock);
273 index = chan_index++; 385 index = chan_index++;
274 chan = &channels[index]; 386 chan = &channels[index];
275 up(&virtio_9p_lock); 387 mutex_unlock(&virtio_9p_lock);
276 388
277 if (chan_index > MAX_9P_CHAN) { 389 if (chan_index > MAX_9P_CHAN) {
278 printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n"); 390 printk(KERN_ERR "9p: virtio: Maximum channels exceeded\n");
@@ -301,17 +413,34 @@ static int p9_virtio_probe(struct virtio_device *vdev)
301out_free_vq: 413out_free_vq:
302 vdev->config->del_vq(chan->vq); 414 vdev->config->del_vq(chan->vq);
303fail: 415fail:
304 down(&virtio_9p_lock); 416 mutex_lock(&virtio_9p_lock);
305 chan_index--; 417 chan_index--;
306 up(&virtio_9p_lock); 418 mutex_unlock(&virtio_9p_lock);
307 return err; 419 return err;
308} 420}
309 421
310/* This sets up a transport channel for 9p communication. Right now 422
423/**
424 * p9_virtio_create - allocate a new virtio channel
425 * @devname: string identifying the channel to connect to (unused)
426 * @args: args passed from sys_mount() for per-transport options (unused)
427 * @msize: requested maximum packet size
428 * @extended: 9p2000.u enabled flag
429 *
430 * This sets up a transport channel for 9p communication. Right now
311 * we only match the first available channel, but eventually we couldlook up 431 * we only match the first available channel, but eventually we couldlook up
312 * alternate channels by matching devname versus a virtio_config entry. 432 * alternate channels by matching devname versus a virtio_config entry.
313 * We use a simple reference count mechanism to ensure that only a single 433 * We use a simple reference count mechanism to ensure that only a single
314 * mount has a channel open at a time. */ 434 * mount has a channel open at a time.
435 *
436 * Bugs: doesn't allow identification of a specific channel
437 * to allocate, channels are allocated sequentially. This was
438 * a pragmatic decision to get things rolling, but ideally some
439 * way of identifying the channel to attach to would be nice
440 * if we are going to support multiple channels.
441 *
442 */
443
315static struct p9_trans * 444static struct p9_trans *
316p9_virtio_create(const char *devname, char *args, int msize, 445p9_virtio_create(const char *devname, char *args, int msize,
317 unsigned char extended) 446 unsigned char extended)
@@ -320,7 +449,7 @@ p9_virtio_create(const char *devname, char *args, int msize,
320 struct virtio_chan *chan = channels; 449 struct virtio_chan *chan = channels;
321 int index = 0; 450 int index = 0;
322 451
323 down(&virtio_9p_lock); 452 mutex_lock(&virtio_9p_lock);
324 while (index < MAX_9P_CHAN) { 453 while (index < MAX_9P_CHAN) {
325 if (chan->initialized && !chan->inuse) { 454 if (chan->initialized && !chan->inuse) {
326 chan->inuse = true; 455 chan->inuse = true;
@@ -330,7 +459,7 @@ p9_virtio_create(const char *devname, char *args, int msize,
330 chan = &channels[index]; 459 chan = &channels[index];
331 } 460 }
332 } 461 }
333 up(&virtio_9p_lock); 462 mutex_unlock(&virtio_9p_lock);
334 463
335 if (index >= MAX_9P_CHAN) { 464 if (index >= MAX_9P_CHAN) {
336 printk(KERN_ERR "9p: no channels available\n"); 465 printk(KERN_ERR "9p: no channels available\n");
@@ -360,6 +489,12 @@ p9_virtio_create(const char *devname, char *args, int msize,
360 return trans; 489 return trans;
361} 490}
362 491
492/**
493 * p9_virtio_remove - clean up resources associated with a virtio device
494 * @vdev: virtio device to remove
495 *
496 */
497
363static void p9_virtio_remove(struct virtio_device *vdev) 498static void p9_virtio_remove(struct virtio_device *vdev)
364{ 499{
365 struct virtio_chan *chan = vdev->priv; 500 struct virtio_chan *chan = vdev->priv;
diff --git a/net/9p/util.c b/net/9p/util.c
index ef7215565d88..958fc58cd1ff 100644
--- a/net/9p/util.c
+++ b/net/9p/util.c
@@ -32,11 +32,23 @@
32#include <linux/idr.h> 32#include <linux/idr.h>
33#include <net/9p/9p.h> 33#include <net/9p/9p.h>
34 34
35/**
36 * struct p9_idpool - per-connection accounting for tag idpool
37 * @lock: protects the pool
38 * @pool: idr to allocate tag id from
39 *
40 */
41
35struct p9_idpool { 42struct p9_idpool {
36 spinlock_t lock; 43 spinlock_t lock;
37 struct idr pool; 44 struct idr pool;
38}; 45};
39 46
47/**
48 * p9_idpool_create - create a new per-connection id pool
49 *
50 */
51
40struct p9_idpool *p9_idpool_create(void) 52struct p9_idpool *p9_idpool_create(void)
41{ 53{
42 struct p9_idpool *p; 54 struct p9_idpool *p;
@@ -52,6 +64,11 @@ struct p9_idpool *p9_idpool_create(void)
52} 64}
53EXPORT_SYMBOL(p9_idpool_create); 65EXPORT_SYMBOL(p9_idpool_create);
54 66
67/**
68 * p9_idpool_destroy - create a new per-connection id pool
69 * @p: idpool to destory
70 */
71
55void p9_idpool_destroy(struct p9_idpool *p) 72void p9_idpool_destroy(struct p9_idpool *p)
56{ 73{
57 idr_destroy(&p->pool); 74 idr_destroy(&p->pool);
@@ -61,9 +78,9 @@ EXPORT_SYMBOL(p9_idpool_destroy);
61 78
62/** 79/**
63 * p9_idpool_get - allocate numeric id from pool 80 * p9_idpool_get - allocate numeric id from pool
64 * @p - pool to allocate from 81 * @p: pool to allocate from
65 * 82 *
66 * XXX - This seems to be an awful generic function, should it be in idr.c with 83 * Bugs: This seems to be an awful generic function, should it be in idr.c with
67 * the lock included in struct idr? 84 * the lock included in struct idr?
68 */ 85 */
69 86
@@ -71,7 +88,7 @@ int p9_idpool_get(struct p9_idpool *p)
71{ 88{
72 int i = 0; 89 int i = 0;
73 int error; 90 int error;
74 unsigned int flags; 91 unsigned long flags;
75 92
76retry: 93retry:
77 if (idr_pre_get(&p->pool, GFP_KERNEL) == 0) 94 if (idr_pre_get(&p->pool, GFP_KERNEL) == 0)
@@ -94,15 +111,16 @@ EXPORT_SYMBOL(p9_idpool_get);
94 111
95/** 112/**
96 * p9_idpool_put - release numeric id from pool 113 * p9_idpool_put - release numeric id from pool
97 * @p - pool to allocate from 114 * @id: numeric id which is being released
115 * @p: pool to release id into
98 * 116 *
99 * XXX - This seems to be an awful generic function, should it be in idr.c with 117 * Bugs: This seems to be an awful generic function, should it be in idr.c with
100 * the lock included in struct idr? 118 * the lock included in struct idr?
101 */ 119 */
102 120
103void p9_idpool_put(int id, struct p9_idpool *p) 121void p9_idpool_put(int id, struct p9_idpool *p)
104{ 122{
105 unsigned int flags; 123 unsigned long flags;
106 spin_lock_irqsave(&p->lock, flags); 124 spin_lock_irqsave(&p->lock, flags);
107 idr_remove(&p->pool, id); 125 idr_remove(&p->pool, id);
108 spin_unlock_irqrestore(&p->lock, flags); 126 spin_unlock_irqrestore(&p->lock, flags);
@@ -111,11 +129,13 @@ EXPORT_SYMBOL(p9_idpool_put);
111 129
112/** 130/**
113 * p9_idpool_check - check if the specified id is available 131 * p9_idpool_check - check if the specified id is available
114 * @id - id to check 132 * @id: id to check
115 * @p - pool 133 * @p: pool to check
116 */ 134 */
135
117int p9_idpool_check(int id, struct p9_idpool *p) 136int p9_idpool_check(int id, struct p9_idpool *p)
118{ 137{
119 return idr_find(&p->pool, id) != NULL; 138 return idr_find(&p->pool, id) != NULL;
120} 139}
121EXPORT_SYMBOL(p9_idpool_check); 140EXPORT_SYMBOL(p9_idpool_check);
141
diff --git a/net/atm/br2684.c b/net/atm/br2684.c
index 1b228065e745..9d52ebfc1962 100644
--- a/net/atm/br2684.c
+++ b/net/atm/br2684.c
@@ -346,9 +346,9 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb)
346 /* skb==NULL means VCC is being destroyed */ 346 /* skb==NULL means VCC is being destroyed */
347 br2684_close_vcc(brvcc); 347 br2684_close_vcc(brvcc);
348 if (list_empty(&brdev->brvccs)) { 348 if (list_empty(&brdev->brvccs)) {
349 read_lock(&devs_lock); 349 write_lock_irq(&devs_lock);
350 list_del(&brdev->br2684_devs); 350 list_del(&brdev->br2684_devs);
351 read_unlock(&devs_lock); 351 write_unlock_irq(&devs_lock);
352 unregister_netdev(net_dev); 352 unregister_netdev(net_dev);
353 free_netdev(net_dev); 353 free_netdev(net_dev);
354 } 354 }
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 77a981a1ee52..c2397f503b0f 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -273,15 +273,13 @@ int br_add_bridge(const char *name)
273 rtnl_lock(); 273 rtnl_lock();
274 if (strchr(dev->name, '%')) { 274 if (strchr(dev->name, '%')) {
275 ret = dev_alloc_name(dev, dev->name); 275 ret = dev_alloc_name(dev, dev->name);
276 if (ret < 0) { 276 if (ret < 0)
277 free_netdev(dev); 277 goto out_free;
278 goto out;
279 }
280 } 278 }
281 279
282 ret = register_netdevice(dev); 280 ret = register_netdevice(dev);
283 if (ret) 281 if (ret)
284 goto out; 282 goto out_free;
285 283
286 ret = br_sysfs_addbr(dev); 284 ret = br_sysfs_addbr(dev);
287 if (ret) 285 if (ret)
@@ -289,6 +287,10 @@ int br_add_bridge(const char *name)
289 out: 287 out:
290 rtnl_unlock(); 288 rtnl_unlock();
291 return ret; 289 return ret;
290
291out_free:
292 free_netdev(dev);
293 goto out;
292} 294}
293 295
294int br_del_bridge(const char *name) 296int br_del_bridge(const char *name)
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 2759b76f731c..7e8ca2836452 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -208,6 +208,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol)
208 */ 208 */
209int can_send(struct sk_buff *skb, int loop) 209int can_send(struct sk_buff *skb, int loop)
210{ 210{
211 struct sk_buff *newskb = NULL;
211 int err; 212 int err;
212 213
213 if (skb->dev->type != ARPHRD_CAN) { 214 if (skb->dev->type != ARPHRD_CAN) {
@@ -244,8 +245,7 @@ int can_send(struct sk_buff *skb, int loop)
244 * If the interface is not capable to do loopback 245 * If the interface is not capable to do loopback
245 * itself, we do it here. 246 * itself, we do it here.
246 */ 247 */
247 struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); 248 newskb = skb_clone(skb, GFP_ATOMIC);
248
249 if (!newskb) { 249 if (!newskb) {
250 kfree_skb(skb); 250 kfree_skb(skb);
251 return -ENOMEM; 251 return -ENOMEM;
@@ -254,7 +254,6 @@ int can_send(struct sk_buff *skb, int loop)
254 newskb->sk = skb->sk; 254 newskb->sk = skb->sk;
255 newskb->ip_summed = CHECKSUM_UNNECESSARY; 255 newskb->ip_summed = CHECKSUM_UNNECESSARY;
256 newskb->pkt_type = PACKET_BROADCAST; 256 newskb->pkt_type = PACKET_BROADCAST;
257 netif_rx(newskb);
258 } 257 }
259 } else { 258 } else {
260 /* indication for the CAN driver: no loopback required */ 259 /* indication for the CAN driver: no loopback required */
@@ -266,11 +265,20 @@ int can_send(struct sk_buff *skb, int loop)
266 if (err > 0) 265 if (err > 0)
267 err = net_xmit_errno(err); 266 err = net_xmit_errno(err);
268 267
268 if (err) {
269 if (newskb)
270 kfree_skb(newskb);
271 return err;
272 }
273
274 if (newskb)
275 netif_rx(newskb);
276
269 /* update statistics */ 277 /* update statistics */
270 can_stats.tx_frames++; 278 can_stats.tx_frames++;
271 can_stats.tx_frames_delta++; 279 can_stats.tx_frames_delta++;
272 280
273 return err; 281 return 0;
274} 282}
275EXPORT_SYMBOL(can_send); 283EXPORT_SYMBOL(can_send);
276 284
diff --git a/net/core/dev.c b/net/core/dev.c
index d334446a8eaf..ce88c0d3e354 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -903,7 +903,11 @@ int dev_change_name(struct net_device *dev, char *newname)
903 strlcpy(dev->name, newname, IFNAMSIZ); 903 strlcpy(dev->name, newname, IFNAMSIZ);
904 904
905rollback: 905rollback:
906 device_rename(&dev->dev, dev->name); 906 err = device_rename(&dev->dev, dev->name);
907 if (err) {
908 memcpy(dev->name, oldname, IFNAMSIZ);
909 return err;
910 }
907 911
908 write_lock_bh(&dev_base_lock); 912 write_lock_bh(&dev_base_lock);
909 hlist_del(&dev->name_hlist); 913 hlist_del(&dev->name_hlist);
@@ -994,6 +998,8 @@ int dev_open(struct net_device *dev)
994{ 998{
995 int ret = 0; 999 int ret = 0;
996 1000
1001 ASSERT_RTNL();
1002
997 /* 1003 /*
998 * Is it already up? 1004 * Is it already up?
999 */ 1005 */
@@ -1060,6 +1066,8 @@ int dev_open(struct net_device *dev)
1060 */ 1066 */
1061int dev_close(struct net_device *dev) 1067int dev_close(struct net_device *dev)
1062{ 1068{
1069 ASSERT_RTNL();
1070
1063 might_sleep(); 1071 might_sleep();
1064 1072
1065 if (!(dev->flags & IFF_UP)) 1073 if (!(dev->flags & IFF_UP))
@@ -4480,17 +4488,19 @@ static void __net_exit default_device_exit(struct net *net)
4480 rtnl_lock(); 4488 rtnl_lock();
4481 for_each_netdev_safe(net, dev, next) { 4489 for_each_netdev_safe(net, dev, next) {
4482 int err; 4490 int err;
4491 char fb_name[IFNAMSIZ];
4483 4492
4484 /* Ignore unmoveable devices (i.e. loopback) */ 4493 /* Ignore unmoveable devices (i.e. loopback) */
4485 if (dev->features & NETIF_F_NETNS_LOCAL) 4494 if (dev->features & NETIF_F_NETNS_LOCAL)
4486 continue; 4495 continue;
4487 4496
4488 /* Push remaing network devices to init_net */ 4497 /* Push remaing network devices to init_net */
4489 err = dev_change_net_namespace(dev, &init_net, "dev%d"); 4498 snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
4499 err = dev_change_net_namespace(dev, &init_net, fb_name);
4490 if (err) { 4500 if (err) {
4491 printk(KERN_WARNING "%s: failed to move %s to init_net: %d\n", 4501 printk(KERN_EMERG "%s: failed to move %s to init_net: %d\n",
4492 __func__, dev->name, err); 4502 __func__, dev->name, err);
4493 unregister_netdevice(dev); 4503 BUG();
4494 } 4504 }
4495 } 4505 }
4496 rtnl_unlock(); 4506 rtnl_unlock();
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index b04d643fc3c7..8fb134da0346 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -419,7 +419,7 @@ static void arp_reply(struct sk_buff *skb)
419 return; 419 return;
420 420
421 size = arp_hdr_len(skb->dev); 421 size = arp_hdr_len(skb->dev);
422 send_skb = find_skb(np, size + LL_RESERVED_SPACE(np->dev), 422 send_skb = find_skb(np, size + LL_ALLOCATED_SPACE(np->dev),
423 LL_RESERVED_SPACE(np->dev)); 423 LL_RESERVED_SPACE(np->dev));
424 424
425 if (!send_skb) 425 if (!send_skb)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4fe605fa6f8a..5c459f2b7985 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -200,7 +200,9 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
200 goto nodata; 200 goto nodata;
201 201
202 /* 202 /*
203 * See comment in sk_buff definition, just before the 'tail' member 203 * Only clear those fields we need to clear, not those that we will
204 * actually initialise below. Hence, don't put any more fields after
205 * the tail pointer in struct sk_buff!
204 */ 206 */
205 memset(skb, 0, offsetof(struct sk_buff, tail)); 207 memset(skb, 0, offsetof(struct sk_buff, tail));
206 skb->truesize = size + sizeof(struct sk_buff); 208 skb->truesize = size + sizeof(struct sk_buff);
diff --git a/net/core/sock.c b/net/core/sock.c
index fa76f04fa9c6..88094cb09c06 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -270,7 +270,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
270 int err = 0; 270 int err = 0;
271 int skb_len; 271 int skb_len;
272 272
273 /* Cast skb->rcvbuf to unsigned... It's pointless, but reduces 273 /* Cast sk->rcvbuf to unsigned... It's pointless, but reduces
274 number of warnings when compiling with -W --ANK 274 number of warnings when compiling with -W --ANK
275 */ 275 */
276 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >= 276 if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
diff --git a/net/dccp/feat.c b/net/dccp/feat.c
index 4a4f6ce4498d..933a0ecf8d46 100644
--- a/net/dccp/feat.c
+++ b/net/dccp/feat.c
@@ -32,7 +32,7 @@ int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature,
32 32
33 if (len > 3) { 33 if (len > 3) {
34 DCCP_WARN("invalid length %d\n", len); 34 DCCP_WARN("invalid length %d\n", len);
35 return 1; 35 return -EINVAL;
36 } 36 }
37 /* XXX add further sanity checks */ 37 /* XXX add further sanity checks */
38 38
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 2f665a516476..f50e88bf2661 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -235,14 +235,14 @@ static void dn_dst_update_pmtu(struct dst_entry *dst, u32 mtu)
235 else 235 else
236 min_mtu -= 21; 236 min_mtu -= 21;
237 237
238 if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= min_mtu) { 238 if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= min_mtu) {
239 if (!(dst_metric_locked(dst, RTAX_MTU))) { 239 if (!(dst_metric_locked(dst, RTAX_MTU))) {
240 dst->metrics[RTAX_MTU-1] = mtu; 240 dst->metrics[RTAX_MTU-1] = mtu;
241 dst_set_expires(dst, dn_rt_mtu_expires); 241 dst_set_expires(dst, dn_rt_mtu_expires);
242 } 242 }
243 if (!(dst_metric_locked(dst, RTAX_ADVMSS))) { 243 if (!(dst_metric_locked(dst, RTAX_ADVMSS))) {
244 u32 mss = mtu - DN_MAX_NSP_DATA_HEADER; 244 u32 mss = mtu - DN_MAX_NSP_DATA_HEADER;
245 if (dst->metrics[RTAX_ADVMSS-1] > mss) 245 if (dst_metric(dst, RTAX_ADVMSS) > mss)
246 dst->metrics[RTAX_ADVMSS-1] = mss; 246 dst->metrics[RTAX_ADVMSS-1] = mss;
247 } 247 }
248 } 248 }
@@ -805,12 +805,12 @@ static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res)
805 rt->u.dst.neighbour = n; 805 rt->u.dst.neighbour = n;
806 } 806 }
807 807
808 if (rt->u.dst.metrics[RTAX_MTU-1] == 0 || 808 if (dst_metric(&rt->u.dst, RTAX_MTU) == 0 ||
809 rt->u.dst.metrics[RTAX_MTU-1] > rt->u.dst.dev->mtu) 809 dst_metric(&rt->u.dst, RTAX_MTU) > rt->u.dst.dev->mtu)
810 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; 810 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
811 mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst)); 811 mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->u.dst));
812 if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0 || 812 if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0 ||
813 rt->u.dst.metrics[RTAX_ADVMSS-1] > mss) 813 dst_metric(&rt->u.dst, RTAX_ADVMSS) > mss)
814 rt->u.dst.metrics[RTAX_ADVMSS-1] = mss; 814 rt->u.dst.metrics[RTAX_ADVMSS-1] = mss;
815 return 0; 815 return 0;
816} 816}
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index 68d154480043..7c9bb13b1539 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -340,7 +340,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock,
340 340
341 dev_hold(dev); 341 dev_hold(dev);
342 342
343 skb = sock_alloc_send_skb(sk, len+LL_RESERVED_SPACE(dev), 343 skb = sock_alloc_send_skb(sk, len+LL_ALLOCATED_SPACE(dev),
344 msg->msg_flags & MSG_DONTWAIT, &err); 344 msg->msg_flags & MSG_DONTWAIT, &err);
345 if (skb==NULL) 345 if (skb==NULL)
346 goto out_unlock; 346 goto out_unlock;
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index 68b72a7a1806..418862f1bf22 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -570,7 +570,7 @@ struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
570 * Allocate a buffer 570 * Allocate a buffer
571 */ 571 */
572 572
573 skb = alloc_skb(arp_hdr_len(dev) + LL_RESERVED_SPACE(dev), GFP_ATOMIC); 573 skb = alloc_skb(arp_hdr_len(dev) + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC);
574 if (skb == NULL) 574 if (skb == NULL)
575 return NULL; 575 return NULL;
576 576
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 05afb576d935..2c0e4572cc90 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -338,7 +338,7 @@ static int cipso_v4_cache_check(const unsigned char *key,
338 return -ENOENT; 338 return -ENOENT;
339 339
340 hash = cipso_v4_map_cache_hash(key, key_len); 340 hash = cipso_v4_map_cache_hash(key, key_len);
341 bkt = hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); 341 bkt = hash & (CIPSO_V4_CACHE_BUCKETS - 1);
342 spin_lock_bh(&cipso_v4_cache[bkt].lock); 342 spin_lock_bh(&cipso_v4_cache[bkt].lock);
343 list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) { 343 list_for_each_entry(entry, &cipso_v4_cache[bkt].list, list) {
344 if (entry->hash == hash && 344 if (entry->hash == hash &&
@@ -417,7 +417,7 @@ int cipso_v4_cache_add(const struct sk_buff *skb,
417 atomic_inc(&secattr->cache->refcount); 417 atomic_inc(&secattr->cache->refcount);
418 entry->lsm_data = secattr->cache; 418 entry->lsm_data = secattr->cache;
419 419
420 bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETBITS - 1); 420 bkt = entry->hash & (CIPSO_V4_CACHE_BUCKETS - 1);
421 spin_lock_bh(&cipso_v4_cache[bkt].lock); 421 spin_lock_bh(&cipso_v4_cache[bkt].lock);
422 if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) { 422 if (cipso_v4_cache[bkt].size < cipso_v4_cache_bucketsize) {
423 list_add(&entry->list, &cipso_v4_cache[bkt].list); 423 list_add(&entry->list, &cipso_v4_cache[bkt].list);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 6250f4239b61..2769dc4a4c84 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -292,7 +292,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size)
292 struct iphdr *pip; 292 struct iphdr *pip;
293 struct igmpv3_report *pig; 293 struct igmpv3_report *pig;
294 294
295 skb = alloc_skb(size + LL_RESERVED_SPACE(dev), GFP_ATOMIC); 295 skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC);
296 if (skb == NULL) 296 if (skb == NULL)
297 return NULL; 297 return NULL;
298 298
@@ -653,7 +653,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc,
653 return -1; 653 return -1;
654 } 654 }
655 655
656 skb=alloc_skb(IGMP_SIZE+LL_RESERVED_SPACE(dev), GFP_ATOMIC); 656 skb=alloc_skb(IGMP_SIZE+LL_ALLOCATED_SPACE(dev), GFP_ATOMIC);
657 if (skb == NULL) { 657 if (skb == NULL) {
658 ip_rt_put(rt); 658 ip_rt_put(rt);
659 return -1; 659 return -1;
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 7b4bad6d572f..ff77a4a7f9ec 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -397,7 +397,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
397 iph = ip_hdr(skb); 397 iph = ip_hdr(skb);
398 398
399 /* 399 /*
400 * RFC1122: 3.1.2.2 MUST silently discard any IP frame that fails the checksum. 400 * RFC1122: 3.2.1.2 MUST silently discard any IP frame that fails the checksum.
401 * 401 *
402 * Is the datagram acceptable? 402 * Is the datagram acceptable?
403 * 403 *
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 89dee4346f60..ed45037ce9be 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -710,14 +710,14 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d
710 struct net_device *dev = d->dev; 710 struct net_device *dev = d->dev;
711 struct sk_buff *skb; 711 struct sk_buff *skb;
712 struct bootp_pkt *b; 712 struct bootp_pkt *b;
713 int hh_len = LL_RESERVED_SPACE(dev);
714 struct iphdr *h; 713 struct iphdr *h;
715 714
716 /* Allocate packet */ 715 /* Allocate packet */
717 skb = alloc_skb(sizeof(struct bootp_pkt) + hh_len + 15, GFP_KERNEL); 716 skb = alloc_skb(sizeof(struct bootp_pkt) + LL_ALLOCATED_SPACE(dev) + 15,
717 GFP_KERNEL);
718 if (!skb) 718 if (!skb)
719 return; 719 return;
720 skb_reserve(skb, hh_len); 720 skb_reserve(skb, LL_RESERVED_SPACE(dev));
721 b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt)); 721 b = (struct bootp_pkt *) skb_put(skb, sizeof(struct bootp_pkt));
722 memset(b, 0, sizeof(struct bootp_pkt)); 722 memset(b, 0, sizeof(struct bootp_pkt));
723 723
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 11d7f753a820..fead049daf43 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -322,7 +322,6 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
322 unsigned int flags) 322 unsigned int flags)
323{ 323{
324 struct inet_sock *inet = inet_sk(sk); 324 struct inet_sock *inet = inet_sk(sk);
325 int hh_len;
326 struct iphdr *iph; 325 struct iphdr *iph;
327 struct sk_buff *skb; 326 struct sk_buff *skb;
328 unsigned int iphlen; 327 unsigned int iphlen;
@@ -336,13 +335,12 @@ static int raw_send_hdrinc(struct sock *sk, void *from, size_t length,
336 if (flags&MSG_PROBE) 335 if (flags&MSG_PROBE)
337 goto out; 336 goto out;
338 337
339 hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); 338 skb = sock_alloc_send_skb(sk,
340 339 length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15,
341 skb = sock_alloc_send_skb(sk, length+hh_len+15, 340 flags & MSG_DONTWAIT, &err);
342 flags&MSG_DONTWAIT, &err);
343 if (skb == NULL) 341 if (skb == NULL)
344 goto error; 342 goto error;
345 skb_reserve(skb, hh_len); 343 skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev));
346 344
347 skb->priority = sk->sk_priority; 345 skb->priority = sk->sk_priority;
348 skb->mark = sk->sk_mark; 346 skb->mark = sk->sk_mark;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 5e3685c5c407..92f90ae46f4a 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1468,14 +1468,14 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1468 1468
1469 /* BSD 4.2 compatibility hack :-( */ 1469 /* BSD 4.2 compatibility hack :-( */
1470 if (mtu == 0 && 1470 if (mtu == 0 &&
1471 old_mtu >= rth->u.dst.metrics[RTAX_MTU-1] && 1471 old_mtu >= dst_metric(&rth->u.dst, RTAX_MTU) &&
1472 old_mtu >= 68 + (iph->ihl << 2)) 1472 old_mtu >= 68 + (iph->ihl << 2))
1473 old_mtu -= iph->ihl << 2; 1473 old_mtu -= iph->ihl << 2;
1474 1474
1475 mtu = guess_mtu(old_mtu); 1475 mtu = guess_mtu(old_mtu);
1476 } 1476 }
1477 if (mtu <= rth->u.dst.metrics[RTAX_MTU-1]) { 1477 if (mtu <= dst_metric(&rth->u.dst, RTAX_MTU)) {
1478 if (mtu < rth->u.dst.metrics[RTAX_MTU-1]) { 1478 if (mtu < dst_metric(&rth->u.dst, RTAX_MTU)) {
1479 dst_confirm(&rth->u.dst); 1479 dst_confirm(&rth->u.dst);
1480 if (mtu < ip_rt_min_pmtu) { 1480 if (mtu < ip_rt_min_pmtu) {
1481 mtu = ip_rt_min_pmtu; 1481 mtu = ip_rt_min_pmtu;
@@ -1497,7 +1497,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph,
1497 1497
1498static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) 1498static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
1499{ 1499{
1500 if (dst->metrics[RTAX_MTU-1] > mtu && mtu >= 68 && 1500 if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= 68 &&
1501 !(dst_metric_locked(dst, RTAX_MTU))) { 1501 !(dst_metric_locked(dst, RTAX_MTU))) {
1502 if (mtu < ip_rt_min_pmtu) { 1502 if (mtu < ip_rt_min_pmtu) {
1503 mtu = ip_rt_min_pmtu; 1503 mtu = ip_rt_min_pmtu;
@@ -1613,7 +1613,7 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
1613 sizeof(rt->u.dst.metrics)); 1613 sizeof(rt->u.dst.metrics));
1614 if (fi->fib_mtu == 0) { 1614 if (fi->fib_mtu == 0) {
1615 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu; 1615 rt->u.dst.metrics[RTAX_MTU-1] = rt->u.dst.dev->mtu;
1616 if (rt->u.dst.metrics[RTAX_LOCK-1] & (1 << RTAX_MTU) && 1616 if (dst_metric_locked(&rt->u.dst, RTAX_MTU) &&
1617 rt->rt_gateway != rt->rt_dst && 1617 rt->rt_gateway != rt->rt_dst &&
1618 rt->u.dst.dev->mtu > 576) 1618 rt->u.dst.dev->mtu > 576)
1619 rt->u.dst.metrics[RTAX_MTU-1] = 576; 1619 rt->u.dst.metrics[RTAX_MTU-1] = 576;
@@ -1624,14 +1624,14 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag)
1624 } else 1624 } else
1625 rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu; 1625 rt->u.dst.metrics[RTAX_MTU-1]= rt->u.dst.dev->mtu;
1626 1626
1627 if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) 1627 if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0)
1628 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; 1628 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl;
1629 if (rt->u.dst.metrics[RTAX_MTU-1] > IP_MAX_MTU) 1629 if (dst_metric(&rt->u.dst, RTAX_MTU) > IP_MAX_MTU)
1630 rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; 1630 rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU;
1631 if (rt->u.dst.metrics[RTAX_ADVMSS-1] == 0) 1631 if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0)
1632 rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, 1632 rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40,
1633 ip_rt_min_advmss); 1633 ip_rt_min_advmss);
1634 if (rt->u.dst.metrics[RTAX_ADVMSS-1] > 65535 - 40) 1634 if (dst_metric(&rt->u.dst, RTAX_ADVMSS) > 65535 - 40)
1635 rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40; 1635 rt->u.dst.metrics[RTAX_ADVMSS-1] = 65535 - 40;
1636 1636
1637#ifdef CONFIG_NET_CLS_ROUTE 1637#ifdef CONFIG_NET_CLS_ROUTE
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index eda4f4a233f3..b54d9d37b636 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -66,6 +66,7 @@
66#include <linux/mm.h> 66#include <linux/mm.h>
67#include <linux/module.h> 67#include <linux/module.h>
68#include <linux/sysctl.h> 68#include <linux/sysctl.h>
69#include <net/dst.h>
69#include <net/tcp.h> 70#include <net/tcp.h>
70#include <net/inet_common.h> 71#include <net/inet_common.h>
71#include <linux/ipsec.h> 72#include <linux/ipsec.h>
@@ -113,8 +114,6 @@ int sysctl_tcp_abc __read_mostly;
113#define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED) 114#define FLAG_FORWARD_PROGRESS (FLAG_ACKED|FLAG_DATA_SACKED)
114#define FLAG_ANY_PROGRESS (FLAG_FORWARD_PROGRESS|FLAG_SND_UNA_ADVANCED) 115#define FLAG_ANY_PROGRESS (FLAG_FORWARD_PROGRESS|FLAG_SND_UNA_ADVANCED)
115 116
116#define IsSackFrto() (sysctl_tcp_frto == 0x2)
117
118#define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) 117#define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH)
119#define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) 118#define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
120 119
@@ -605,7 +604,7 @@ static u32 tcp_rto_min(struct sock *sk)
605 u32 rto_min = TCP_RTO_MIN; 604 u32 rto_min = TCP_RTO_MIN;
606 605
607 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) 606 if (dst && dst_metric_locked(dst, RTAX_RTO_MIN))
608 rto_min = dst->metrics[RTAX_RTO_MIN - 1]; 607 rto_min = dst_metric(dst, RTAX_RTO_MIN);
609 return rto_min; 608 return rto_min;
610} 609}
611 610
@@ -769,7 +768,7 @@ void tcp_update_metrics(struct sock *sk)
769 dst->metrics[RTAX_RTTVAR - 1] = m; 768 dst->metrics[RTAX_RTTVAR - 1] = m;
770 else 769 else
771 dst->metrics[RTAX_RTTVAR-1] -= 770 dst->metrics[RTAX_RTTVAR-1] -=
772 (dst->metrics[RTAX_RTTVAR-1] - m)>>2; 771 (dst_metric(dst, RTAX_RTTVAR) - m)>>2;
773 } 772 }
774 773
775 if (tp->snd_ssthresh >= 0xFFFF) { 774 if (tp->snd_ssthresh >= 0xFFFF) {
@@ -788,21 +787,21 @@ void tcp_update_metrics(struct sock *sk)
788 dst->metrics[RTAX_SSTHRESH-1] = 787 dst->metrics[RTAX_SSTHRESH-1] =
789 max(tp->snd_cwnd >> 1, tp->snd_ssthresh); 788 max(tp->snd_cwnd >> 1, tp->snd_ssthresh);
790 if (!dst_metric_locked(dst, RTAX_CWND)) 789 if (!dst_metric_locked(dst, RTAX_CWND))
791 dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_cwnd) >> 1; 790 dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_cwnd) >> 1;
792 } else { 791 } else {
793 /* Else slow start did not finish, cwnd is non-sense, 792 /* Else slow start did not finish, cwnd is non-sense,
794 ssthresh may be also invalid. 793 ssthresh may be also invalid.
795 */ 794 */
796 if (!dst_metric_locked(dst, RTAX_CWND)) 795 if (!dst_metric_locked(dst, RTAX_CWND))
797 dst->metrics[RTAX_CWND-1] = (dst->metrics[RTAX_CWND-1] + tp->snd_ssthresh) >> 1; 796 dst->metrics[RTAX_CWND-1] = (dst_metric(dst, RTAX_CWND) + tp->snd_ssthresh) >> 1;
798 if (dst->metrics[RTAX_SSTHRESH-1] && 797 if (dst_metric(dst, RTAX_SSTHRESH) &&
799 !dst_metric_locked(dst, RTAX_SSTHRESH) && 798 !dst_metric_locked(dst, RTAX_SSTHRESH) &&
800 tp->snd_ssthresh > dst->metrics[RTAX_SSTHRESH-1]) 799 tp->snd_ssthresh > dst_metric(dst, RTAX_SSTHRESH))
801 dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh; 800 dst->metrics[RTAX_SSTHRESH-1] = tp->snd_ssthresh;
802 } 801 }
803 802
804 if (!dst_metric_locked(dst, RTAX_REORDERING)) { 803 if (!dst_metric_locked(dst, RTAX_REORDERING)) {
805 if (dst->metrics[RTAX_REORDERING-1] < tp->reordering && 804 if (dst_metric(dst, RTAX_REORDERING) < tp->reordering &&
806 tp->reordering != sysctl_tcp_reordering) 805 tp->reordering != sysctl_tcp_reordering)
807 dst->metrics[RTAX_REORDERING-1] = tp->reordering; 806 dst->metrics[RTAX_REORDERING-1] = tp->reordering;
808 } 807 }
@@ -1685,6 +1684,11 @@ static inline void tcp_reset_reno_sack(struct tcp_sock *tp)
1685 tp->sacked_out = 0; 1684 tp->sacked_out = 0;
1686} 1685}
1687 1686
1687static int tcp_is_sackfrto(const struct tcp_sock *tp)
1688{
1689 return (sysctl_tcp_frto == 0x2) && !tcp_is_reno(tp);
1690}
1691
1688/* F-RTO can only be used if TCP has never retransmitted anything other than 1692/* F-RTO can only be used if TCP has never retransmitted anything other than
1689 * head (SACK enhanced variant from Appendix B of RFC4138 is more robust here) 1693 * head (SACK enhanced variant from Appendix B of RFC4138 is more robust here)
1690 */ 1694 */
@@ -1701,7 +1705,7 @@ int tcp_use_frto(struct sock *sk)
1701 if (icsk->icsk_mtup.probe_size) 1705 if (icsk->icsk_mtup.probe_size)
1702 return 0; 1706 return 0;
1703 1707
1704 if (IsSackFrto()) 1708 if (tcp_is_sackfrto(tp))
1705 return 1; 1709 return 1;
1706 1710
1707 /* Avoid expensive walking of rexmit queue if possible */ 1711 /* Avoid expensive walking of rexmit queue if possible */
@@ -1791,7 +1795,7 @@ void tcp_enter_frto(struct sock *sk)
1791 /* Earlier loss recovery underway (see RFC4138; Appendix B). 1795 /* Earlier loss recovery underway (see RFC4138; Appendix B).
1792 * The last condition is necessary at least in tp->frto_counter case. 1796 * The last condition is necessary at least in tp->frto_counter case.
1793 */ 1797 */
1794 if (IsSackFrto() && (tp->frto_counter || 1798 if (tcp_is_sackfrto(tp) && (tp->frto_counter ||
1795 ((1 << icsk->icsk_ca_state) & (TCPF_CA_Recovery|TCPF_CA_Loss))) && 1799 ((1 << icsk->icsk_ca_state) & (TCPF_CA_Recovery|TCPF_CA_Loss))) &&
1796 after(tp->high_seq, tp->snd_una)) { 1800 after(tp->high_seq, tp->snd_una)) {
1797 tp->frto_highmark = tp->high_seq; 1801 tp->frto_highmark = tp->high_seq;
@@ -1838,9 +1842,16 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
1838 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; 1842 TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
1839 } 1843 }
1840 1844
1841 /* Don't lost mark skbs that were fwd transmitted after RTO */ 1845 /* Marking forward transmissions that were made after RTO lost
1842 if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED) && 1846 * can cause unnecessary retransmissions in some scenarios,
1843 !after(TCP_SKB_CB(skb)->end_seq, tp->frto_highmark)) { 1847 * SACK blocks will mitigate that in some but not in all cases.
1848 * We used to not mark them but it was causing break-ups with
1849 * receivers that do only in-order receival.
1850 *
1851 * TODO: we could detect presence of such receiver and select
1852 * different behavior per flow.
1853 */
1854 if (!(TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)) {
1844 TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; 1855 TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
1845 tp->lost_out += tcp_skb_pcount(skb); 1856 tp->lost_out += tcp_skb_pcount(skb);
1846 } 1857 }
@@ -1856,7 +1867,7 @@ static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
1856 tp->reordering = min_t(unsigned int, tp->reordering, 1867 tp->reordering = min_t(unsigned int, tp->reordering,
1857 sysctl_tcp_reordering); 1868 sysctl_tcp_reordering);
1858 tcp_set_ca_state(sk, TCP_CA_Loss); 1869 tcp_set_ca_state(sk, TCP_CA_Loss);
1859 tp->high_seq = tp->frto_highmark; 1870 tp->high_seq = tp->snd_nxt;
1860 TCP_ECN_queue_cwr(tp); 1871 TCP_ECN_queue_cwr(tp);
1861 1872
1862 tcp_clear_retrans_hints_partial(tp); 1873 tcp_clear_retrans_hints_partial(tp);
@@ -2478,7 +2489,7 @@ static void tcp_try_to_open(struct sock *sk, int flag)
2478 2489
2479 tcp_verify_left_out(tp); 2490 tcp_verify_left_out(tp);
2480 2491
2481 if (tp->retrans_out == 0) 2492 if (!tp->frto_counter && tp->retrans_out == 0)
2482 tp->retrans_stamp = 0; 2493 tp->retrans_stamp = 0;
2483 2494
2484 if (flag & FLAG_ECE) 2495 if (flag & FLAG_ECE)
@@ -3123,7 +3134,7 @@ static int tcp_process_frto(struct sock *sk, int flag)
3123 return 1; 3134 return 1;
3124 } 3135 }
3125 3136
3126 if (!IsSackFrto() || tcp_is_reno(tp)) { 3137 if (!tcp_is_sackfrto(tp)) {
3127 /* RFC4138 shortcoming in step 2; should also have case c): 3138 /* RFC4138 shortcoming in step 2; should also have case c):
3128 * ACK isn't duplicate nor advances window, e.g., opposite dir 3139 * ACK isn't duplicate nor advances window, e.g., opposite dir
3129 * data, winupdate 3140 * data, winupdate
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 0af2e055f883..48cdce9c696c 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -780,7 +780,7 @@ slow_path:
780 * Allocate buffer. 780 * Allocate buffer.
781 */ 781 */
782 782
783 if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_RESERVED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) { 783 if ((frag = alloc_skb(len+hlen+sizeof(struct frag_hdr)+LL_ALLOCATED_SPACE(rt->u.dst.dev), GFP_ATOMIC)) == NULL) {
784 NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n"); 784 NETDEBUG(KERN_INFO "IPv6: frag: no memory for new fragment!\n");
785 IP6_INC_STATS(ip6_dst_idev(skb->dst), 785 IP6_INC_STATS(ip6_dst_idev(skb->dst),
786 IPSTATS_MIB_FRAGFAILS); 786 IPSTATS_MIB_FRAGFAILS);
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
index 54f91efdae58..fd632dd7f98d 100644
--- a/net/ipv6/mcast.c
+++ b/net/ipv6/mcast.c
@@ -1411,7 +1411,7 @@ static struct sk_buff *mld_newpack(struct net_device *dev, int size)
1411 IPV6_TLV_PADN, 0 }; 1411 IPV6_TLV_PADN, 0 };
1412 1412
1413 /* we assume size > sizeof(ra) here */ 1413 /* we assume size > sizeof(ra) here */
1414 skb = sock_alloc_send_skb(sk, size + LL_RESERVED_SPACE(dev), 1, &err); 1414 skb = sock_alloc_send_skb(sk, size + LL_ALLOCATED_SPACE(dev), 1, &err);
1415 1415
1416 if (!skb) 1416 if (!skb)
1417 return NULL; 1417 return NULL;
@@ -1790,7 +1790,7 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
1790 payload_len = len + sizeof(ra); 1790 payload_len = len + sizeof(ra);
1791 full_len = sizeof(struct ipv6hdr) + payload_len; 1791 full_len = sizeof(struct ipv6hdr) + payload_len;
1792 1792
1793 skb = sock_alloc_send_skb(sk, LL_RESERVED_SPACE(dev) + full_len, 1, &err); 1793 skb = sock_alloc_send_skb(sk, LL_ALLOCATED_SPACE(dev) + full_len, 1, &err);
1794 1794
1795 if (skb == NULL) { 1795 if (skb == NULL) {
1796 rcu_read_lock(); 1796 rcu_read_lock();
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 2c74885f8355..a55fc05b8125 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -479,7 +479,7 @@ static void __ndisc_send(struct net_device *dev,
479 479
480 skb = sock_alloc_send_skb(sk, 480 skb = sock_alloc_send_skb(sk,
481 (MAX_HEADER + sizeof(struct ipv6hdr) + 481 (MAX_HEADER + sizeof(struct ipv6hdr) +
482 len + LL_RESERVED_SPACE(dev)), 482 len + LL_ALLOCATED_SPACE(dev)),
483 1, &err); 483 1, &err);
484 if (!skb) { 484 if (!skb) {
485 ND_PRINTK0(KERN_ERR 485 ND_PRINTK0(KERN_ERR
@@ -1521,7 +1521,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh,
1521 1521
1522 buff = sock_alloc_send_skb(sk, 1522 buff = sock_alloc_send_skb(sk,
1523 (MAX_HEADER + sizeof(struct ipv6hdr) + 1523 (MAX_HEADER + sizeof(struct ipv6hdr) +
1524 len + LL_RESERVED_SPACE(dev)), 1524 len + LL_ALLOCATED_SPACE(dev)),
1525 1, &err); 1525 1, &err);
1526 if (buff == NULL) { 1526 if (buff == NULL) {
1527 ND_PRINTK0(KERN_ERR 1527 ND_PRINTK0(KERN_ERR
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index 396f0ea11090..232e0dc45bf5 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -609,7 +609,6 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
609 struct ipv6_pinfo *np = inet6_sk(sk); 609 struct ipv6_pinfo *np = inet6_sk(sk);
610 struct ipv6hdr *iph; 610 struct ipv6hdr *iph;
611 struct sk_buff *skb; 611 struct sk_buff *skb;
612 unsigned int hh_len;
613 int err; 612 int err;
614 613
615 if (length > rt->u.dst.dev->mtu) { 614 if (length > rt->u.dst.dev->mtu) {
@@ -619,13 +618,12 @@ static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
619 if (flags&MSG_PROBE) 618 if (flags&MSG_PROBE)
620 goto out; 619 goto out;
621 620
622 hh_len = LL_RESERVED_SPACE(rt->u.dst.dev); 621 skb = sock_alloc_send_skb(sk,
623 622 length + LL_ALLOCATED_SPACE(rt->u.dst.dev) + 15,
624 skb = sock_alloc_send_skb(sk, length+hh_len+15, 623 flags & MSG_DONTWAIT, &err);
625 flags&MSG_DONTWAIT, &err);
626 if (skb == NULL) 624 if (skb == NULL)
627 goto error; 625 goto error;
628 skb_reserve(skb, hh_len); 626 skb_reserve(skb, LL_RESERVED_SPACE(rt->u.dst.dev));
629 627
630 skb->priority = sk->sk_priority; 628 skb->priority = sk->sk_priority;
631 skb->mark = sk->sk_mark; 629 skb->mark = sk->sk_mark;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index a493ad9b8914..12bba0880345 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1243,11 +1243,11 @@ install_route:
1243 } 1243 }
1244 } 1244 }
1245 1245
1246 if (rt->u.dst.metrics[RTAX_HOPLIMIT-1] == 0) 1246 if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0)
1247 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; 1247 rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1;
1248 if (!rt->u.dst.metrics[RTAX_MTU-1]) 1248 if (!dst_metric(&rt->u.dst, RTAX_MTU))
1249 rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); 1249 rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev);
1250 if (!rt->u.dst.metrics[RTAX_ADVMSS-1]) 1250 if (!dst_metric(&rt->u.dst, RTAX_ADVMSS))
1251 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); 1251 rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst));
1252 rt->u.dst.dev = dev; 1252 rt->u.dst.dev = dev;
1253 rt->rt6i_idev = idev; 1253 rt->rt6i_idev = idev;
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 4b2f1033994e..5a6fab95569f 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -596,9 +596,9 @@ static int ipip6_rcv(struct sk_buff *skb)
596 } 596 }
597 597
598 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0); 598 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
599 kfree_skb(skb);
600 read_unlock(&ipip6_lock); 599 read_unlock(&ipip6_lock);
601out: 600out:
601 kfree_skb(skb);
602 return 0; 602 return 0;
603} 603}
604 604
diff --git a/net/irda/discovery.c b/net/irda/discovery.c
index bfacef8b76f4..a6f99b5a1499 100644
--- a/net/irda/discovery.c
+++ b/net/irda/discovery.c
@@ -40,6 +40,8 @@
40 40
41#include <net/irda/discovery.h> 41#include <net/irda/discovery.h>
42 42
43#include <asm/unaligned.h>
44
43/* 45/*
44 * Function irlmp_add_discovery (cachelog, discovery) 46 * Function irlmp_add_discovery (cachelog, discovery)
45 * 47 *
@@ -87,7 +89,7 @@ void irlmp_add_discovery(hashbin_t *cachelog, discovery_t *new)
87 */ 89 */
88 hashbin_remove_this(cachelog, (irda_queue_t *) node); 90 hashbin_remove_this(cachelog, (irda_queue_t *) node);
89 /* Check if hints bits are unchanged */ 91 /* Check if hints bits are unchanged */
90 if(u16ho(node->data.hints) == u16ho(new->data.hints)) 92 if (get_unaligned((__u16 *)node->data.hints) == get_unaligned((__u16 *)new->data.hints))
91 /* Set time of first discovery for this node */ 93 /* Set time of first discovery for this node */
92 new->firststamp = node->firststamp; 94 new->firststamp = node->firststamp;
93 kfree(node); 95 kfree(node);
@@ -281,9 +283,9 @@ struct irda_device_info *irlmp_copy_discoveries(hashbin_t *log, int *pn,
281 /* Mask out the ones we don't want : 283 /* Mask out the ones we don't want :
282 * We want to match the discovery mask, and to get only 284 * We want to match the discovery mask, and to get only
283 * the most recent one (unless we want old ones) */ 285 * the most recent one (unless we want old ones) */
284 if ((u16ho(discovery->data.hints) & mask) && 286 if ((get_unaligned((__u16 *)discovery->data.hints) & mask) &&
285 ((old_entries) || 287 ((old_entries) ||
286 ((jiffies - discovery->firststamp) < j_timeout)) ) { 288 ((jiffies - discovery->firststamp) < j_timeout))) {
287 /* Create buffer as needed. 289 /* Create buffer as needed.
288 * As this function get called a lot and most time 290 * As this function get called a lot and most time
289 * we don't have anything to put in the log (we are 291 * we don't have anything to put in the log (we are
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index 1f81f8e7c61d..7bf5b913828b 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -1062,7 +1062,8 @@ void irlmp_discovery_expiry(discinfo_t *expiries, int number)
1062 for(i = 0; i < number; i++) { 1062 for(i = 0; i < number; i++) {
1063 /* Check if we should notify client */ 1063 /* Check if we should notify client */
1064 if ((client->expir_callback) && 1064 if ((client->expir_callback) &&
1065 (client->hint_mask.word & u16ho(expiries[i].hints) 1065 (client->hint_mask.word &
1066 get_unaligned((__u16 *)expiries[i].hints)
1066 & 0x7f7f) ) 1067 & 0x7f7f) )
1067 client->expir_callback(&(expiries[i]), 1068 client->expir_callback(&(expiries[i]),
1068 EXPIRY_TIMEOUT, 1069 EXPIRY_TIMEOUT,
@@ -1086,7 +1087,7 @@ discovery_t *irlmp_get_discovery_response(void)
1086 1087
1087 IRDA_ASSERT(irlmp != NULL, return NULL;); 1088 IRDA_ASSERT(irlmp != NULL, return NULL;);
1088 1089
1089 u16ho(irlmp->discovery_rsp.data.hints) = irlmp->hints.word; 1090 put_unaligned(irlmp->hints.word, (__u16 *)irlmp->discovery_rsp.data.hints);
1090 1091
1091 /* 1092 /*
1092 * Set character set for device name (we use ASCII), and 1093 * Set character set for device name (we use ASCII), and
diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c
index 75497e55927d..cf9a4b531a98 100644
--- a/net/irda/irnet/irnet_irda.c
+++ b/net/irda/irnet/irnet_irda.c
@@ -10,6 +10,7 @@
10 10
11#include "irnet_irda.h" /* Private header */ 11#include "irnet_irda.h" /* Private header */
12#include <linux/seq_file.h> 12#include <linux/seq_file.h>
13#include <asm/unaligned.h>
13 14
14/* 15/*
15 * PPP disconnect work: we need to make sure we're in 16 * PPP disconnect work: we need to make sure we're in
@@ -1673,7 +1674,7 @@ irnet_discovery_indication(discinfo_t * discovery,
1673 /* Notify the control channel */ 1674 /* Notify the control channel */
1674 irnet_post_event(NULL, IRNET_DISCOVER, 1675 irnet_post_event(NULL, IRNET_DISCOVER,
1675 discovery->saddr, discovery->daddr, discovery->info, 1676 discovery->saddr, discovery->daddr, discovery->info,
1676 u16ho(discovery->hints)); 1677 get_unaligned((__u16 *)discovery->hints));
1677 1678
1678 DEXIT(IRDA_OCB_TRACE, "\n"); 1679 DEXIT(IRDA_OCB_TRACE, "\n");
1679} 1680}
@@ -1704,7 +1705,7 @@ irnet_expiry_indication(discinfo_t * expiry,
1704 /* Notify the control channel */ 1705 /* Notify the control channel */
1705 irnet_post_event(NULL, IRNET_EXPIRE, 1706 irnet_post_event(NULL, IRNET_EXPIRE,
1706 expiry->saddr, expiry->daddr, expiry->info, 1707 expiry->saddr, expiry->daddr, expiry->info,
1707 u16ho(expiry->hints)); 1708 get_unaligned((__u16 *)expiry->hints));
1708 1709
1709 DEXIT(IRDA_OCB_TRACE, "\n"); 1710 DEXIT(IRDA_OCB_TRACE, "\n");
1710} 1711}
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 879e7210458a..19efc3a6a932 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -255,14 +255,23 @@ void ieee80211_debugfs_key_remove(struct ieee80211_key *key)
255void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) 255void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata)
256{ 256{
257 char buf[50]; 257 char buf[50];
258 struct ieee80211_key *key;
258 259
259 if (!sdata->debugfsdir) 260 if (!sdata->debugfsdir)
260 return; 261 return;
261 262
262 sprintf(buf, "../keys/%d", sdata->default_key->debugfs.cnt); 263 /* this is running under the key lock */
263 sdata->debugfs.default_key = 264
264 debugfs_create_symlink("default_key", sdata->debugfsdir, buf); 265 key = sdata->default_key;
266 if (key) {
267 sprintf(buf, "../keys/%d", key->debugfs.cnt);
268 sdata->debugfs.default_key =
269 debugfs_create_symlink("default_key",
270 sdata->debugfsdir, buf);
271 } else
272 ieee80211_debugfs_key_remove_default(sdata);
265} 273}
274
266void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) 275void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata)
267{ 276{
268 if (!sdata) 277 if (!sdata)
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index f41c7e0de622..4a8062f8b1cc 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -53,6 +53,15 @@ int ieee80211_if_add(struct net_device *dev, const char *name,
53 if (!ndev) 53 if (!ndev)
54 return -ENOMEM; 54 return -ENOMEM;
55 55
56 ndev->needed_headroom = local->tx_headroom +
57 4*6 /* four MAC addresses */
58 + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
59 + 6 /* mesh */
60 + 8 /* rfc1042/bridge tunnel */
61 - ETH_HLEN /* ethernet hard_header_len */
62 + IEEE80211_ENCRYPT_HEADROOM;
63 ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
64
56 ret = dev_alloc_name(ndev, ndev->name); 65 ret = dev_alloc_name(ndev, ndev->name);
57 if (ret < 0) 66 if (ret < 0)
58 goto fail; 67 goto fail;
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 55e76117da9e..eb347eca30b5 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1771,6 +1771,7 @@ fail_wep:
1771fail_rate: 1771fail_rate:
1772 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); 1772 ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
1773 unregister_netdevice(local->mdev); 1773 unregister_netdevice(local->mdev);
1774 local->mdev = NULL;
1774fail_dev: 1775fail_dev:
1775 rtnl_unlock(); 1776 rtnl_unlock();
1776 sta_info_stop(local); 1777 sta_info_stop(local);
@@ -1778,8 +1779,10 @@ fail_sta_info:
1778 debugfs_hw_del(local); 1779 debugfs_hw_del(local);
1779 destroy_workqueue(local->hw.workqueue); 1780 destroy_workqueue(local->hw.workqueue);
1780fail_workqueue: 1781fail_workqueue:
1781 ieee80211_if_free(local->mdev); 1782 if (local->mdev != NULL) {
1782 local->mdev = NULL; 1783 ieee80211_if_free(local->mdev);
1784 local->mdev = NULL;
1785 }
1783fail_mdev_alloc: 1786fail_mdev_alloc:
1784 wiphy_unregister(local->hw.wiphy); 1787 wiphy_unregister(local->hw.wiphy);
1785 return result; 1788 return result;
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index f76bc26ae4d2..697ef67f96b6 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -397,7 +397,7 @@ int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
397 put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum); 397 put_unaligned(cpu_to_le32(sdata->u.sta.mesh_seqnum), &meshhdr->seqnum);
398 sdata->u.sta.mesh_seqnum++; 398 sdata->u.sta.mesh_seqnum++;
399 399
400 return 5; 400 return 6;
401} 401}
402 402
403void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata) 403void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata)
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
index 3df809222d1c..af0cd1e3e213 100644
--- a/net/mac80211/mesh_hwmp.c
+++ b/net/mac80211/mesh_hwmp.c
@@ -120,7 +120,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
120 *pos++ = WLAN_EID_PREP; 120 *pos++ = WLAN_EID_PREP;
121 break; 121 break;
122 default: 122 default:
123 kfree(skb); 123 kfree_skb(skb);
124 return -ENOTSUPP; 124 return -ENOTSUPP;
125 break; 125 break;
126 } 126 }
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index 5845dc21ce85..99c2d360888e 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -158,19 +158,25 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
158 if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0) 158 if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0)
159 return -ENOSPC; 159 return -ENOSPC;
160 160
161 read_lock(&pathtbl_resize_lock);
162
163 new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL); 161 new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL);
164 if (!new_mpath) { 162 if (!new_mpath) {
165 atomic_dec(&sdata->u.sta.mpaths); 163 atomic_dec(&sdata->u.sta.mpaths);
166 err = -ENOMEM; 164 err = -ENOMEM;
167 goto endadd2; 165 goto endadd2;
168 } 166 }
167 new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
168 if (!new_node) {
169 kfree(new_mpath);
170 atomic_dec(&sdata->u.sta.mpaths);
171 err = -ENOMEM;
172 goto endadd2;
173 }
174
175 read_lock(&pathtbl_resize_lock);
169 memcpy(new_mpath->dst, dst, ETH_ALEN); 176 memcpy(new_mpath->dst, dst, ETH_ALEN);
170 new_mpath->dev = dev; 177 new_mpath->dev = dev;
171 new_mpath->flags = 0; 178 new_mpath->flags = 0;
172 skb_queue_head_init(&new_mpath->frame_queue); 179 skb_queue_head_init(&new_mpath->frame_queue);
173 new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
174 new_node->mpath = new_mpath; 180 new_node->mpath = new_mpath;
175 new_mpath->timer.data = (unsigned long) new_mpath; 181 new_mpath->timer.data = (unsigned long) new_mpath;
176 new_mpath->timer.function = mesh_path_timer; 182 new_mpath->timer.function = mesh_path_timer;
@@ -202,7 +208,6 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
202 208
203endadd: 209endadd:
204 spin_unlock(&mesh_paths->hashwlock[hash_idx]); 210 spin_unlock(&mesh_paths->hashwlock[hash_idx]);
205endadd2:
206 read_unlock(&pathtbl_resize_lock); 211 read_unlock(&pathtbl_resize_lock);
207 if (!err && grow) { 212 if (!err && grow) {
208 struct mesh_table *oldtbl, *newtbl; 213 struct mesh_table *oldtbl, *newtbl;
@@ -215,10 +220,12 @@ endadd2:
215 return -ENOMEM; 220 return -ENOMEM;
216 } 221 }
217 rcu_assign_pointer(mesh_paths, newtbl); 222 rcu_assign_pointer(mesh_paths, newtbl);
223 write_unlock(&pathtbl_resize_lock);
224
218 synchronize_rcu(); 225 synchronize_rcu();
219 mesh_table_free(oldtbl, false); 226 mesh_table_free(oldtbl, false);
220 write_unlock(&pathtbl_resize_lock);
221 } 227 }
228endadd2:
222 return err; 229 return err;
223} 230}
224 231
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 55b85ae5bc11..5d7719f44bea 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -651,6 +651,26 @@ static void ieee80211_authenticate(struct net_device *dev,
651 mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 651 mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
652} 652}
653 653
654static int ieee80211_compatible_rates(struct ieee80211_sta_bss *bss,
655 struct ieee80211_supported_band *sband,
656 u64 *rates)
657{
658 int i, j, count;
659 *rates = 0;
660 count = 0;
661 for (i = 0; i < bss->supp_rates_len; i++) {
662 int rate = (bss->supp_rates[i] & 0x7F) * 5;
663
664 for (j = 0; j < sband->n_bitrates; j++)
665 if (sband->bitrates[j].bitrate == rate) {
666 *rates |= BIT(j);
667 count++;
668 break;
669 }
670 }
671
672 return count;
673}
654 674
655static void ieee80211_send_assoc(struct net_device *dev, 675static void ieee80211_send_assoc(struct net_device *dev,
656 struct ieee80211_if_sta *ifsta) 676 struct ieee80211_if_sta *ifsta)
@@ -659,11 +679,12 @@ static void ieee80211_send_assoc(struct net_device *dev,
659 struct sk_buff *skb; 679 struct sk_buff *skb;
660 struct ieee80211_mgmt *mgmt; 680 struct ieee80211_mgmt *mgmt;
661 u8 *pos, *ies; 681 u8 *pos, *ies;
662 int i, len; 682 int i, len, count, rates_len, supp_rates_len;
663 u16 capab; 683 u16 capab;
664 struct ieee80211_sta_bss *bss; 684 struct ieee80211_sta_bss *bss;
665 int wmm = 0; 685 int wmm = 0;
666 struct ieee80211_supported_band *sband; 686 struct ieee80211_supported_band *sband;
687 u64 rates = 0;
667 688
668 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 689 skb = dev_alloc_skb(local->hw.extra_tx_headroom +
669 sizeof(*mgmt) + 200 + ifsta->extra_ie_len + 690 sizeof(*mgmt) + 200 + ifsta->extra_ie_len +
@@ -725,24 +746,39 @@ static void ieee80211_send_assoc(struct net_device *dev,
725 *pos++ = ifsta->ssid_len; 746 *pos++ = ifsta->ssid_len;
726 memcpy(pos, ifsta->ssid, ifsta->ssid_len); 747 memcpy(pos, ifsta->ssid, ifsta->ssid_len);
727 748
749 /* all supported rates should be added here but some APs
750 * (e.g. D-Link DAP 1353 in b-only mode) don't like that
751 * Therefore only add rates the AP supports */
752 rates_len = ieee80211_compatible_rates(bss, sband, &rates);
753 supp_rates_len = rates_len;
754 if (supp_rates_len > 8)
755 supp_rates_len = 8;
756
728 len = sband->n_bitrates; 757 len = sband->n_bitrates;
729 if (len > 8) 758 pos = skb_put(skb, supp_rates_len + 2);
730 len = 8;
731 pos = skb_put(skb, len + 2);
732 *pos++ = WLAN_EID_SUPP_RATES; 759 *pos++ = WLAN_EID_SUPP_RATES;
733 *pos++ = len; 760 *pos++ = supp_rates_len;
734 for (i = 0; i < len; i++) {
735 int rate = sband->bitrates[i].bitrate;
736 *pos++ = (u8) (rate / 5);
737 }
738 761
739 if (sband->n_bitrates > len) { 762 count = 0;
740 pos = skb_put(skb, sband->n_bitrates - len + 2); 763 for (i = 0; i < sband->n_bitrates; i++) {
741 *pos++ = WLAN_EID_EXT_SUPP_RATES; 764 if (BIT(i) & rates) {
742 *pos++ = sband->n_bitrates - len;
743 for (i = len; i < sband->n_bitrates; i++) {
744 int rate = sband->bitrates[i].bitrate; 765 int rate = sband->bitrates[i].bitrate;
745 *pos++ = (u8) (rate / 5); 766 *pos++ = (u8) (rate / 5);
767 if (++count == 8)
768 break;
769 }
770 }
771
772 if (count == 8) {
773 pos = skb_put(skb, rates_len - count + 2);
774 *pos++ = WLAN_EID_EXT_SUPP_RATES;
775 *pos++ = rates_len - count;
776
777 for (i++; i < sband->n_bitrates; i++) {
778 if (BIT(i) & rates) {
779 int rate = sband->bitrates[i].bitrate;
780 *pos++ = (u8) (rate / 5);
781 }
746 } 782 }
747 } 783 }
748 784
diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
index ae75d4178739..ff5c380f3c13 100644
--- a/net/mac80211/rc80211_pid_debugfs.c
+++ b/net/mac80211/rc80211_pid_debugfs.c
@@ -85,7 +85,7 @@ static int rate_control_pid_events_open(struct inode *inode, struct file *file)
85 struct rc_pid_sta_info *sinfo = inode->i_private; 85 struct rc_pid_sta_info *sinfo = inode->i_private;
86 struct rc_pid_event_buffer *events = &sinfo->events; 86 struct rc_pid_event_buffer *events = &sinfo->events;
87 struct rc_pid_events_file_info *file_info; 87 struct rc_pid_events_file_info *file_info;
88 unsigned int status; 88 unsigned long status;
89 89
90 /* Allocate a state struct */ 90 /* Allocate a state struct */
91 file_info = kmalloc(sizeof(*file_info), GFP_KERNEL); 91 file_info = kmalloc(sizeof(*file_info), GFP_KERNEL);
@@ -135,7 +135,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
135 char pb[RC_PID_PRINT_BUF_SIZE]; 135 char pb[RC_PID_PRINT_BUF_SIZE];
136 int ret; 136 int ret;
137 int p; 137 int p;
138 unsigned int status; 138 unsigned long status;
139 139
140 /* Check if there is something to read. */ 140 /* Check if there is something to read. */
141 if (events->next_entry == file_info->next_entry) { 141 if (events->next_entry == file_info->next_entry) {
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index e8b89c89e875..9b5a3cbec265 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -1300,11 +1300,11 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
1300 if (is_multicast_ether_addr(skb->data)) { 1300 if (is_multicast_ether_addr(skb->data)) {
1301 if (*mesh_ttl > 0) { 1301 if (*mesh_ttl > 0) {
1302 xmit_skb = skb_copy(skb, GFP_ATOMIC); 1302 xmit_skb = skb_copy(skb, GFP_ATOMIC);
1303 if (!xmit_skb && net_ratelimit()) 1303 if (xmit_skb)
1304 xmit_skb->pkt_type = PACKET_OTHERHOST;
1305 else if (net_ratelimit())
1304 printk(KERN_DEBUG "%s: failed to clone " 1306 printk(KERN_DEBUG "%s: failed to clone "
1305 "multicast frame\n", dev->name); 1307 "multicast frame\n", dev->name);
1306 else
1307 xmit_skb->pkt_type = PACKET_OTHERHOST;
1308 } else 1308 } else
1309 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, 1309 IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta,
1310 dropped_frames_ttl); 1310 dropped_frames_ttl);
@@ -1390,7 +1390,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
1390 padding = ((4 - subframe_len) & 0x3); 1390 padding = ((4 - subframe_len) & 0x3);
1391 /* the last MSDU has no padding */ 1391 /* the last MSDU has no padding */
1392 if (subframe_len > remaining) { 1392 if (subframe_len > remaining) {
1393 printk(KERN_DEBUG "%s: wrong buffer size", dev->name); 1393 printk(KERN_DEBUG "%s: wrong buffer size\n", dev->name);
1394 return RX_DROP_UNUSABLE; 1394 return RX_DROP_UNUSABLE;
1395 } 1395 }
1396 1396
@@ -1413,7 +1413,7 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
1413 eth = (struct ethhdr *) skb_pull(skb, ntohs(len) + 1413 eth = (struct ethhdr *) skb_pull(skb, ntohs(len) +
1414 padding); 1414 padding);
1415 if (!eth) { 1415 if (!eth) {
1416 printk(KERN_DEBUG "%s: wrong buffer size ", 1416 printk(KERN_DEBUG "%s: wrong buffer size\n",
1417 dev->name); 1417 dev->name);
1418 dev_kfree_skb(frame); 1418 dev_kfree_skb(frame);
1419 return RX_DROP_UNUSABLE; 1419 return RX_DROP_UNUSABLE;
@@ -1947,7 +1947,7 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
1947 if (!skb_new) { 1947 if (!skb_new) {
1948 if (net_ratelimit()) 1948 if (net_ratelimit())
1949 printk(KERN_DEBUG "%s: failed to copy " 1949 printk(KERN_DEBUG "%s: failed to copy "
1950 "multicast frame for %s", 1950 "multicast frame for %s\n",
1951 wiphy_name(local->hw.wiphy), 1951 wiphy_name(local->hw.wiphy),
1952 prev->dev->name); 1952 prev->dev->name);
1953 continue; 1953 continue;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index f35eaea98e73..1d7dd54aacef 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1562,13 +1562,13 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb,
1562 * be cloned. This could happen, e.g., with Linux bridge code passing 1562 * be cloned. This could happen, e.g., with Linux bridge code passing
1563 * us broadcast frames. */ 1563 * us broadcast frames. */
1564 1564
1565 if (head_need > 0 || skb_cloned(skb)) { 1565 if (head_need > 0 || skb_header_cloned(skb)) {
1566#if 0 1566#if 0
1567 printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes " 1567 printk(KERN_DEBUG "%s: need to reallocate buffer for %d bytes "
1568 "of headroom\n", dev->name, head_need); 1568 "of headroom\n", dev->name, head_need);
1569#endif 1569#endif
1570 1570
1571 if (skb_cloned(skb)) 1571 if (skb_header_cloned(skb))
1572 I802_DEBUG_INC(local->tx_expand_skb_head_cloned); 1572 I802_DEBUG_INC(local->tx_expand_skb_head_cloned);
1573 else 1573 else
1574 I802_DEBUG_INC(local->tx_expand_skb_head); 1574 I802_DEBUG_INC(local->tx_expand_skb_head);
@@ -1898,6 +1898,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1898 control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE; 1898 control->flags |= IEEE80211_TXCTL_SHORT_PREAMBLE;
1899 control->antenna_sel_tx = local->hw.conf.antenna_sel_tx; 1899 control->antenna_sel_tx = local->hw.conf.antenna_sel_tx;
1900 control->flags |= IEEE80211_TXCTL_NO_ACK; 1900 control->flags |= IEEE80211_TXCTL_NO_ACK;
1901 control->flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
1901 control->retry_limit = 1; 1902 control->retry_limit = 1;
1902 control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT; 1903 control->flags |= IEEE80211_TXCTL_CLEAR_PS_FILT;
1903 } 1904 }
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index cc9f715c7bfc..24a465c4df09 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -153,15 +153,15 @@ int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
153 /* 7.1.3.5a.2 */ 153 /* 7.1.3.5a.2 */
154 switch (ae) { 154 switch (ae) {
155 case 0: 155 case 0:
156 return 5; 156 return 6;
157 case 1: 157 case 1:
158 return 11; 158 return 12;
159 case 2: 159 case 2:
160 return 17; 160 return 18;
161 case 3: 161 case 3:
162 return 23; 162 return 24;
163 default: 163 default:
164 return 5; 164 return 6;
165 } 165 }
166} 166}
167 167
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c
index 8ffff27fe000..c87baf4ce979 100644
--- a/net/mac80211/wme.c
+++ b/net/mac80211/wme.c
@@ -379,7 +379,8 @@ static int wme_qdiscop_init(struct Qdisc *qd, struct nlattr *opt)
379 qd->handle); 379 qd->handle);
380 if (!q->queues[i]) { 380 if (!q->queues[i]) {
381 q->queues[i] = &noop_qdisc; 381 q->queues[i] = &noop_qdisc;
382 printk(KERN_ERR "%s child qdisc %i creation failed", dev->name, i); 382 printk(KERN_ERR "%s child qdisc %i creation failed\n",
383 dev->name, i);
383 } 384 }
384 } 385 }
385 386
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index c1fc0f1a641c..aa8d80c35e28 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -90,6 +90,7 @@ config NF_CT_PROTO_DCCP
90 tristate 'DCCP protocol connection tracking support (EXPERIMENTAL)' 90 tristate 'DCCP protocol connection tracking support (EXPERIMENTAL)'
91 depends on EXPERIMENTAL && NF_CONNTRACK 91 depends on EXPERIMENTAL && NF_CONNTRACK
92 depends on NETFILTER_ADVANCED 92 depends on NETFILTER_ADVANCED
93 default IP_DCCP
93 help 94 help
94 With this option enabled, the layer 3 independent connection 95 With this option enabled, the layer 3 independent connection
95 tracking code will be able to do state tracking on DCCP connections. 96 tracking code will be able to do state tracking on DCCP connections.
@@ -104,6 +105,7 @@ config NF_CT_PROTO_SCTP
104 tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)' 105 tristate 'SCTP protocol connection tracking support (EXPERIMENTAL)'
105 depends on EXPERIMENTAL && NF_CONNTRACK 106 depends on EXPERIMENTAL && NF_CONNTRACK
106 depends on NETFILTER_ADVANCED 107 depends on NETFILTER_ADVANCED
108 default IP_SCTP
107 help 109 help
108 With this option enabled, the layer 3 independent connection 110 With this option enabled, the layer 3 independent connection
109 tracking code will be able to do state tracking on SCTP connections. 111 tracking code will be able to do state tracking on SCTP connections.
@@ -532,6 +534,7 @@ config NETFILTER_XT_MATCH_DCCP
532 tristate '"dccp" protocol match support' 534 tristate '"dccp" protocol match support'
533 depends on NETFILTER_XTABLES 535 depends on NETFILTER_XTABLES
534 depends on NETFILTER_ADVANCED 536 depends on NETFILTER_ADVANCED
537 default IP_DCCP
535 help 538 help
536 With this option enabled, you will be able to use the iptables 539 With this option enabled, you will be able to use the iptables
537 `dccp' match in order to match on DCCP source/destination ports 540 `dccp' match in order to match on DCCP source/destination ports
@@ -725,6 +728,7 @@ config NETFILTER_XT_MATCH_SCTP
725 tristate '"sctp" protocol match support (EXPERIMENTAL)' 728 tristate '"sctp" protocol match support (EXPERIMENTAL)'
726 depends on NETFILTER_XTABLES && EXPERIMENTAL 729 depends on NETFILTER_XTABLES && EXPERIMENTAL
727 depends on NETFILTER_ADVANCED 730 depends on NETFILTER_ADVANCED
731 default IP_SCTP
728 help 732 help
729 With this option enabled, you will be able to use the 733 With this option enabled, you will be able to use the
730 `sctp' match in order to match on SCTP source/destination ports 734 `sctp' match in order to match on SCTP source/destination ports
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 16774ecd1c4e..0edefcfc5949 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -472,6 +472,9 @@ static int ctnetlink_conntrack_event(struct notifier_block *this,
472 goto nla_put_failure; 472 goto nla_put_failure;
473 nla_nest_end(skb, nest_parms); 473 nla_nest_end(skb, nest_parms);
474 474
475 if (ctnetlink_dump_id(skb, ct) < 0)
476 goto nla_put_failure;
477
475 if (events & IPCT_DESTROY) { 478 if (events & IPCT_DESTROY) {
476 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 || 479 if (ctnetlink_dump_counters(skb, ct, IP_CT_DIR_ORIGINAL) < 0 ||
477 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0) 480 ctnetlink_dump_counters(skb, ct, IP_CT_DIR_REPLY) < 0)
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 9f4900069561..2f9bbc058b48 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -870,6 +870,7 @@ static int process_sdp(struct sk_buff *skb,
870{ 870{
871 enum ip_conntrack_info ctinfo; 871 enum ip_conntrack_info ctinfo;
872 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 872 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
873 struct nf_conn_help *help = nfct_help(ct);
873 unsigned int matchoff, matchlen; 874 unsigned int matchoff, matchlen;
874 unsigned int mediaoff, medialen; 875 unsigned int mediaoff, medialen;
875 unsigned int sdpoff; 876 unsigned int sdpoff;
@@ -959,6 +960,9 @@ static int process_sdp(struct sk_buff *skb,
959 if (nf_nat_sdp_session && ct->status & IPS_NAT_MASK) 960 if (nf_nat_sdp_session && ct->status & IPS_NAT_MASK)
960 ret = nf_nat_sdp_session(skb, dptr, sdpoff, datalen, &rtp_addr); 961 ret = nf_nat_sdp_session(skb, dptr, sdpoff, datalen, &rtp_addr);
961 962
963 if (ret == NF_ACCEPT && i > 0)
964 help->help.ct_sip_info.invite_cseq = cseq;
965
962 return ret; 966 return ret;
963} 967}
964static int process_invite_response(struct sk_buff *skb, 968static int process_invite_response(struct sk_buff *skb,
@@ -967,14 +971,14 @@ static int process_invite_response(struct sk_buff *skb,
967{ 971{
968 enum ip_conntrack_info ctinfo; 972 enum ip_conntrack_info ctinfo;
969 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 973 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
974 struct nf_conn_help *help = nfct_help(ct);
970 975
971 if ((code >= 100 && code <= 199) || 976 if ((code >= 100 && code <= 199) ||
972 (code >= 200 && code <= 299)) 977 (code >= 200 && code <= 299))
973 return process_sdp(skb, dptr, datalen, cseq); 978 return process_sdp(skb, dptr, datalen, cseq);
974 else { 979 else if (help->help.ct_sip_info.invite_cseq == cseq)
975 flush_expectations(ct, true); 980 flush_expectations(ct, true);
976 return NF_ACCEPT; 981 return NF_ACCEPT;
977 }
978} 982}
979 983
980static int process_update_response(struct sk_buff *skb, 984static int process_update_response(struct sk_buff *skb,
@@ -983,14 +987,14 @@ static int process_update_response(struct sk_buff *skb,
983{ 987{
984 enum ip_conntrack_info ctinfo; 988 enum ip_conntrack_info ctinfo;
985 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 989 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
990 struct nf_conn_help *help = nfct_help(ct);
986 991
987 if ((code >= 100 && code <= 199) || 992 if ((code >= 100 && code <= 199) ||
988 (code >= 200 && code <= 299)) 993 (code >= 200 && code <= 299))
989 return process_sdp(skb, dptr, datalen, cseq); 994 return process_sdp(skb, dptr, datalen, cseq);
990 else { 995 else if (help->help.ct_sip_info.invite_cseq == cseq)
991 flush_expectations(ct, true); 996 flush_expectations(ct, true);
992 return NF_ACCEPT; 997 return NF_ACCEPT;
993 }
994} 998}
995 999
996static int process_prack_response(struct sk_buff *skb, 1000static int process_prack_response(struct sk_buff *skb,
@@ -999,14 +1003,14 @@ static int process_prack_response(struct sk_buff *skb,
999{ 1003{
1000 enum ip_conntrack_info ctinfo; 1004 enum ip_conntrack_info ctinfo;
1001 struct nf_conn *ct = nf_ct_get(skb, &ctinfo); 1005 struct nf_conn *ct = nf_ct_get(skb, &ctinfo);
1006 struct nf_conn_help *help = nfct_help(ct);
1002 1007
1003 if ((code >= 100 && code <= 199) || 1008 if ((code >= 100 && code <= 199) ||
1004 (code >= 200 && code <= 299)) 1009 (code >= 200 && code <= 299))
1005 return process_sdp(skb, dptr, datalen, cseq); 1010 return process_sdp(skb, dptr, datalen, cseq);
1006 else { 1011 else if (help->help.ct_sip_info.invite_cseq == cseq)
1007 flush_expectations(ct, true); 1012 flush_expectations(ct, true);
1008 return NF_ACCEPT; 1013 return NF_ACCEPT;
1009 }
1010} 1014}
1011 1015
1012static int process_bye_request(struct sk_buff *skb, 1016static int process_bye_request(struct sk_buff *skb,
diff --git a/net/netfilter/xt_iprange.c b/net/netfilter/xt_iprange.c
index 500528d60cd7..c63e9333c755 100644
--- a/net/netfilter/xt_iprange.c
+++ b/net/netfilter/xt_iprange.c
@@ -179,3 +179,5 @@ module_exit(iprange_mt_exit);
179MODULE_LICENSE("GPL"); 179MODULE_LICENSE("GPL");
180MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>"); 180MODULE_AUTHOR("Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>, Jan Engelhardt <jengelh@computergmbh.de>");
181MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching"); 181MODULE_DESCRIPTION("Xtables: arbitrary IPv4 range matching");
182MODULE_ALIAS("ipt_iprange");
183MODULE_ALIAS("ip6t_iprange");
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 25070240d4ae..2cee87da4441 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -743,7 +743,7 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock,
743 if (len > dev->mtu+reserve) 743 if (len > dev->mtu+reserve)
744 goto out_unlock; 744 goto out_unlock;
745 745
746 skb = sock_alloc_send_skb(sk, len + LL_RESERVED_SPACE(dev), 746 skb = sock_alloc_send_skb(sk, len + LL_ALLOCATED_SPACE(dev),
747 msg->msg_flags & MSG_DONTWAIT, &err); 747 msg->msg_flags & MSG_DONTWAIT, &err);
748 if (skb==NULL) 748 if (skb==NULL)
749 goto out_unlock; 749 goto out_unlock;
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c
index 64b2d136c78e..1d421d059caf 100644
--- a/net/sched/act_simple.c
+++ b/net/sched/act_simple.c
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
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 * Authors: Jamal Hadi Salim (2005) 9 * Authors: Jamal Hadi Salim (2005-8)
10 * 10 *
11 */ 11 */
12 12
@@ -34,6 +34,7 @@ static struct tcf_hashinfo simp_hash_info = {
34 .lock = &simp_lock, 34 .lock = &simp_lock,
35}; 35};
36 36
37#define SIMP_MAX_DATA 32
37static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res) 38static int tcf_simp(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res)
38{ 39{
39 struct tcf_defact *d = a->priv; 40 struct tcf_defact *d = a->priv;
@@ -69,23 +70,28 @@ static int tcf_simp_release(struct tcf_defact *d, int bind)
69 return ret; 70 return ret;
70} 71}
71 72
72static int alloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) 73static int alloc_defdata(struct tcf_defact *d, char *defdata)
73{ 74{
74 d->tcfd_defdata = kmemdup(defdata, datalen, GFP_KERNEL); 75 d->tcfd_defdata = kstrndup(defdata, SIMP_MAX_DATA, GFP_KERNEL);
75 if (unlikely(!d->tcfd_defdata)) 76 if (unlikely(!d->tcfd_defdata))
76 return -ENOMEM; 77 return -ENOMEM;
77 d->tcfd_datalen = datalen; 78
78 return 0; 79 return 0;
79} 80}
80 81
81static int realloc_defdata(struct tcf_defact *d, u32 datalen, void *defdata) 82static void reset_policy(struct tcf_defact *d, char *defdata,
83 struct tc_defact *p)
82{ 84{
83 kfree(d->tcfd_defdata); 85 spin_lock_bh(&d->tcf_lock);
84 return alloc_defdata(d, datalen, defdata); 86 d->tcf_action = p->action;
87 memset(d->tcfd_defdata, 0, SIMP_MAX_DATA);
88 strlcpy(d->tcfd_defdata, defdata, SIMP_MAX_DATA);
89 spin_unlock_bh(&d->tcf_lock);
85} 90}
86 91
87static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { 92static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = {
88 [TCA_DEF_PARMS] = { .len = sizeof(struct tc_defact) }, 93 [TCA_DEF_PARMS] = { .len = sizeof(struct tc_defact) },
94 [TCA_DEF_DATA] = { .type = NLA_STRING, .len = SIMP_MAX_DATA },
89}; 95};
90 96
91static int tcf_simp_init(struct nlattr *nla, struct nlattr *est, 97static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
@@ -95,28 +101,24 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
95 struct tc_defact *parm; 101 struct tc_defact *parm;
96 struct tcf_defact *d; 102 struct tcf_defact *d;
97 struct tcf_common *pc; 103 struct tcf_common *pc;
98 void *defdata; 104 char *defdata;
99 u32 datalen = 0;
100 int ret = 0, err; 105 int ret = 0, err;
101 106
102 if (nla == NULL) 107 if (nla == NULL)
103 return -EINVAL; 108 return -EINVAL;
104 109
105 err = nla_parse_nested(tb, TCA_DEF_MAX, nla, NULL); 110 err = nla_parse_nested(tb, TCA_DEF_MAX, nla, simple_policy);
106 if (err < 0) 111 if (err < 0)
107 return err; 112 return err;
108 113
109 if (tb[TCA_DEF_PARMS] == NULL) 114 if (tb[TCA_DEF_PARMS] == NULL)
110 return -EINVAL; 115 return -EINVAL;
111 116
112 parm = nla_data(tb[TCA_DEF_PARMS]); 117 if (tb[TCA_DEF_DATA] == NULL)
113 defdata = nla_data(tb[TCA_DEF_DATA]);
114 if (defdata == NULL)
115 return -EINVAL; 118 return -EINVAL;
116 119
117 datalen = nla_len(tb[TCA_DEF_DATA]); 120 parm = nla_data(tb[TCA_DEF_PARMS]);
118 if (datalen == 0) 121 defdata = nla_data(tb[TCA_DEF_DATA]);
119 return -EINVAL;
120 122
121 pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info); 123 pc = tcf_hash_check(parm->index, a, bind, &simp_hash_info);
122 if (!pc) { 124 if (!pc) {
@@ -126,11 +128,12 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
126 return -ENOMEM; 128 return -ENOMEM;
127 129
128 d = to_defact(pc); 130 d = to_defact(pc);
129 ret = alloc_defdata(d, datalen, defdata); 131 ret = alloc_defdata(d, defdata);
130 if (ret < 0) { 132 if (ret < 0) {
131 kfree(pc); 133 kfree(pc);
132 return ret; 134 return ret;
133 } 135 }
136 d->tcf_action = parm->action;
134 ret = ACT_P_CREATED; 137 ret = ACT_P_CREATED;
135 } else { 138 } else {
136 d = to_defact(pc); 139 d = to_defact(pc);
@@ -138,13 +141,9 @@ static int tcf_simp_init(struct nlattr *nla, struct nlattr *est,
138 tcf_simp_release(d, bind); 141 tcf_simp_release(d, bind);
139 return -EEXIST; 142 return -EEXIST;
140 } 143 }
141 realloc_defdata(d, datalen, defdata); 144 reset_policy(d, defdata, parm);
142 } 145 }
143 146
144 spin_lock_bh(&d->tcf_lock);
145 d->tcf_action = parm->action;
146 spin_unlock_bh(&d->tcf_lock);
147
148 if (ret == ACT_P_CREATED) 147 if (ret == ACT_P_CREATED)
149 tcf_hash_insert(pc, &simp_hash_info); 148 tcf_hash_insert(pc, &simp_hash_info);
150 return ret; 149 return ret;
@@ -172,7 +171,7 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
172 opt.bindcnt = d->tcf_bindcnt - bind; 171 opt.bindcnt = d->tcf_bindcnt - bind;
173 opt.action = d->tcf_action; 172 opt.action = d->tcf_action;
174 NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt); 173 NLA_PUT(skb, TCA_DEF_PARMS, sizeof(opt), &opt);
175 NLA_PUT(skb, TCA_DEF_DATA, d->tcfd_datalen, d->tcfd_defdata); 174 NLA_PUT_STRING(skb, TCA_DEF_DATA, d->tcfd_defdata);
176 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install); 175 t.install = jiffies_to_clock_t(jiffies - d->tcf_tm.install);
177 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse); 176 t.lastuse = jiffies_to_clock_t(jiffies - d->tcf_tm.lastuse);
178 t.expires = jiffies_to_clock_t(d->tcf_tm.expires); 177 t.expires = jiffies_to_clock_t(d->tcf_tm.expires);
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 66148cc4759e..5bc1ed490180 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1197,12 +1197,16 @@ static inline int htb_parent_last_child(struct htb_class *cl)
1197 return 1; 1197 return 1;
1198} 1198}
1199 1199
1200static void htb_parent_to_leaf(struct htb_class *cl, struct Qdisc *new_q) 1200static void htb_parent_to_leaf(struct htb_sched *q, struct htb_class *cl,
1201 struct Qdisc *new_q)
1201{ 1202{
1202 struct htb_class *parent = cl->parent; 1203 struct htb_class *parent = cl->parent;
1203 1204
1204 BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity); 1205 BUG_TRAP(!cl->level && cl->un.leaf.q && !cl->prio_activity);
1205 1206
1207 if (parent->cmode != HTB_CAN_SEND)
1208 htb_safe_rb_erase(&parent->pq_node, q->wait_pq + parent->level);
1209
1206 parent->level = 0; 1210 parent->level = 0;
1207 memset(&parent->un.inner, 0, sizeof(parent->un.inner)); 1211 memset(&parent->un.inner, 0, sizeof(parent->un.inner));
1208 INIT_LIST_HEAD(&parent->un.leaf.drop_list); 1212 INIT_LIST_HEAD(&parent->un.leaf.drop_list);
@@ -1300,7 +1304,7 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg)
1300 htb_deactivate(q, cl); 1304 htb_deactivate(q, cl);
1301 1305
1302 if (last_child) 1306 if (last_child)
1303 htb_parent_to_leaf(cl, new_q); 1307 htb_parent_to_leaf(q, cl, new_q);
1304 1308
1305 if (--cl->refcnt == 0) 1309 if (--cl->refcnt == 0)
1306 htb_destroy_class(sch, cl); 1310 htb_destroy_class(sch, cl);
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 81b606424e12..bbc7107c86cf 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -2418,7 +2418,8 @@ static int sctp_process_param(struct sctp_association *asoc,
2418 break; 2418 break;
2419 2419
2420 case SCTP_PARAM_IPV6_ADDRESS: 2420 case SCTP_PARAM_IPV6_ADDRESS:
2421 asoc->peer.ipv6_address = 1; 2421 if (PF_INET6 == asoc->base.sk->sk_family)
2422 asoc->peer.ipv6_address = 1;
2422 break; 2423 break;
2423 2424
2424 case SCTP_PARAM_HOST_NAME_ADDRESS: 2425 case SCTP_PARAM_HOST_NAME_ADDRESS:
@@ -2829,6 +2830,19 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
2829 addr_param = (union sctp_addr_param *) 2830 addr_param = (union sctp_addr_param *)
2830 ((void *)asconf_param + sizeof(sctp_addip_param_t)); 2831 ((void *)asconf_param + sizeof(sctp_addip_param_t));
2831 2832
2833 switch (addr_param->v4.param_hdr.type) {
2834 case SCTP_PARAM_IPV6_ADDRESS:
2835 if (!asoc->peer.ipv6_address)
2836 return SCTP_ERROR_INV_PARAM;
2837 break;
2838 case SCTP_PARAM_IPV4_ADDRESS:
2839 if (!asoc->peer.ipv4_address)
2840 return SCTP_ERROR_INV_PARAM;
2841 break;
2842 default:
2843 return SCTP_ERROR_INV_PARAM;
2844 }
2845
2832 af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type)); 2846 af = sctp_get_af_specific(param_type2af(addr_param->v4.param_hdr.type));
2833 if (unlikely(!af)) 2847 if (unlikely(!af))
2834 return SCTP_ERROR_INV_PARAM; 2848 return SCTP_ERROR_INV_PARAM;
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index d74c2d269539..01c7e311b904 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -18,7 +18,6 @@
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/sched.h>
22 21
23#include <linux/sunrpc/types.h> 22#include <linux/sunrpc/types.h>
24#include <linux/sunrpc/xdr.h> 23#include <linux/sunrpc/xdr.h>
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 0d783bcc6f9a..bd78d1705c0f 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -303,15 +303,14 @@ static inline void k_term_timer(struct timer_list *timer)
303/* 303/*
304 * TIPC message buffer code 304 * TIPC message buffer code
305 * 305 *
306 * TIPC message buffer headroom reserves space for a link-level header 306 * TIPC message buffer headroom reserves space for the worst-case
307 * (in case the message is sent off-node), 307 * link-level device header (in case the message is sent off-node).
308 * while ensuring TIPC header is word aligned for quicker access
309 * 308 *
310 * The largest header currently supported is 18 bytes, which is used when 309 * Note: Headroom should be a multiple of 4 to ensure the TIPC header fields
311 * the standard 14 byte Ethernet header has 4 added bytes for VLAN info 310 * are word aligned for quicker access
312 */ 311 */
313 312
314#define BUF_HEADROOM 20u 313#define BUF_HEADROOM LL_MAX_HEADER
315 314
316struct tipc_skb_cb { 315struct tipc_skb_cb {
317 void *handle; 316 void *handle;
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c
index 09cd9c0c2d80..3f964db908a7 100644
--- a/net/xfrm/xfrm_output.c
+++ b/net/xfrm/xfrm_output.c
@@ -25,11 +25,11 @@ static int xfrm_state_check_space(struct xfrm_state *x, struct sk_buff *skb)
25 struct dst_entry *dst = skb->dst; 25 struct dst_entry *dst = skb->dst;
26 int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev) 26 int nhead = dst->header_len + LL_RESERVED_SPACE(dst->dev)
27 - skb_headroom(skb); 27 - skb_headroom(skb);
28 int ntail = dst->dev->needed_tailroom - skb_tailroom(skb);
28 29
29 if (nhead > 0) 30 if (nhead > 0 || ntail > 0)
30 return pskb_expand_head(skb, nhead, 0, GFP_ATOMIC); 31 return pskb_expand_head(skb, nhead, ntail, GFP_ATOMIC);
31 32
32 /* Check tail too... */
33 return 0; 33 return 0;
34} 34}
35 35
diff --git a/sound/drivers/Kconfig b/sound/drivers/Kconfig
index a78a8d045175..379bcb074463 100644
--- a/sound/drivers/Kconfig
+++ b/sound/drivers/Kconfig
@@ -5,8 +5,8 @@ menu "Generic devices"
5 5
6 6
7config SND_PCSP 7config SND_PCSP
8 tristate "Internal PC speaker support" 8 tristate "PC-Speaker support"
9 depends on X86_PC && HIGH_RES_TIMERS 9 depends on PCSPKR_PLATFORM && X86_PC && HIGH_RES_TIMERS
10 depends on INPUT 10 depends on INPUT
11 depends on SND 11 depends on SND
12 select SND_PCM 12 select SND_PCM
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 59203511e77d..54a1f9036c66 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -194,6 +194,7 @@ static void pcsp_stop_beep(struct snd_pcsp *chip)
194 spin_unlock_irq(&chip->substream_lock); 194 spin_unlock_irq(&chip->substream_lock);
195} 195}
196 196
197#ifdef CONFIG_PM
197static int pcsp_suspend(struct platform_device *dev, pm_message_t state) 198static int pcsp_suspend(struct platform_device *dev, pm_message_t state)
198{ 199{
199 struct snd_pcsp *chip = platform_get_drvdata(dev); 200 struct snd_pcsp *chip = platform_get_drvdata(dev);
@@ -201,6 +202,9 @@ static int pcsp_suspend(struct platform_device *dev, pm_message_t state)
201 snd_pcm_suspend_all(chip->pcm); 202 snd_pcm_suspend_all(chip->pcm);
202 return 0; 203 return 0;
203} 204}
205#else
206#define pcsp_suspend NULL
207#endif /* CONFIG_PM */
204 208
205static void pcsp_shutdown(struct platform_device *dev) 209static void pcsp_shutdown(struct platform_device *dev)
206{ 210{
diff --git a/sound/oss/kahlua.c b/sound/oss/kahlua.c
index dfe670f12e67..eb9bc365530d 100644
--- a/sound/oss/kahlua.c
+++ b/sound/oss/kahlua.c
@@ -67,7 +67,7 @@ static int __devinit probe_one(struct pci_dev *pdev, const struct pci_device_id
67 return 1; 67 return 1;
68 68
69 mem = ioremap(base, 128); 69 mem = ioremap(base, 128);
70 if(mem == 0UL) 70 if (!mem)
71 return 1; 71 return 1;
72 map = readw(mem + 0x18); /* Read the SMI enables */ 72 map = readw(mem + 0x18); /* Read the SMI enables */
73 iounmap(mem); 73 iounmap(mem);
diff --git a/sound/pci/Kconfig b/sound/pci/Kconfig
index 581debf37dcb..7e4742109572 100644
--- a/sound/pci/Kconfig
+++ b/sound/pci/Kconfig
@@ -515,19 +515,16 @@ config SND_FM801
515config SND_FM801_TEA575X_BOOL 515config SND_FM801_TEA575X_BOOL
516 bool "ForteMedia FM801 + TEA5757 tuner" 516 bool "ForteMedia FM801 + TEA5757 tuner"
517 depends on SND_FM801 517 depends on SND_FM801
518 depends on VIDEO_V4L1=y || VIDEO_V4L1=SND_FM801
518 help 519 help
519 Say Y here to include support for soundcards based on the ForteMedia 520 Say Y here to include support for soundcards based on the ForteMedia
520 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media 521 FM801 chip with a TEA5757 tuner connected to GPIO1-3 pins (Media
521 Forte SF256-PCS-02) into the snd-fm801 driver. 522 Forte SF256-PCS-02) into the snd-fm801 driver.
522 523
523 This will enable support for the old V4L1 API.
524
525config SND_FM801_TEA575X 524config SND_FM801_TEA575X
526 tristate 525 tristate
527 depends on SND_FM801_TEA575X_BOOL 526 depends on SND_FM801_TEA575X_BOOL
528 default SND_FM801 527 default SND_FM801
529 select VIDEO_V4L1
530 select VIDEO_DEV
531 528
532config SND_HDA_INTEL 529config SND_HDA_INTEL
533 tristate "Intel HD Audio" 530 tristate "Intel HD Audio"
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 39198e505b12..2da89810ca10 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -3446,6 +3446,7 @@ static const struct snd_kcontrol_new snd_ac97_controls_vt1617a[] = {
3446int patch_vt1617a(struct snd_ac97 * ac97) 3446int patch_vt1617a(struct snd_ac97 * ac97)
3447{ 3447{
3448 int err = 0; 3448 int err = 0;
3449 int val;
3449 3450
3450 /* we choose to not fail out at this point, but we tell the 3451 /* we choose to not fail out at this point, but we tell the
3451 caller when we return */ 3452 caller when we return */
@@ -3456,7 +3457,13 @@ int patch_vt1617a(struct snd_ac97 * ac97)
3456 /* bring analog power consumption to normal by turning off the 3457 /* bring analog power consumption to normal by turning off the
3457 * headphone amplifier, like WinXP driver for EPIA SP 3458 * headphone amplifier, like WinXP driver for EPIA SP
3458 */ 3459 */
3459 snd_ac97_write_cache(ac97, 0x5c, 0x20); 3460 /* We need to check the bit before writing it.
3461 * On some (many?) hardwares, setting bit actually clears it!
3462 */
3463 val = snd_ac97_read(ac97, 0x5c);
3464 if (!(val & 0x20))
3465 snd_ac97_write_cache(ac97, 0x5c, 0x20);
3466
3460 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */ 3467 ac97->ext_id |= AC97_EI_SPDIF; /* force the detection of spdif */
3461 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000; 3468 ac97->rates[AC97_RATES_SPDIF] = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000;
3462 ac97->build_ops = &patch_vt1616_ops; 3469 ac97->build_ops = &patch_vt1616_ops;
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index d9783a4263e0..6d4df45e81e0 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -11902,7 +11902,10 @@ static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
11902 hda_nid_t nid, 11902 hda_nid_t nid,
11903 int pin_type, int dac_idx) 11903 int pin_type, int dac_idx)
11904{ 11904{
11905 alc_set_pin_output(codec, nid, pin_type); 11905 snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
11906 pin_type);
11907 snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
11908 AMP_OUT_UNMUTE);
11906} 11909}
11907 11910
11908static void alc861_auto_init_multi_out(struct hda_codec *codec) 11911static void alc861_auto_init_multi_out(struct hda_codec *codec)
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index b3a15d616873..393f7fd2b1be 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -4289,6 +4289,8 @@ struct hda_codec_preset snd_hda_preset_sigmatel[] = {
4289 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x }, 4289 { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
4290 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x }, 4290 { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
4291 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x }, 4291 { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
4292 { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
4293 { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
4292 /* The following does not take into account .id=0x83847661 when subsys = 4294 /* The following does not take into account .id=0x83847661 when subsys =
4293 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are 4295 * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
4294 * currently not fully supported. 4296 * currently not fully supported.
diff --git a/sound/soc/at91/at91-pcm.c b/sound/soc/at91/at91-pcm.c
index 67c88e322fb1..ccac6bd2889c 100644
--- a/sound/soc/at91/at91-pcm.c
+++ b/sound/soc/at91/at91-pcm.c
@@ -103,7 +103,8 @@ static void at91_pcm_dma_irq(u32 ssc_sr,
103 if (prtd->period_ptr >= prtd->dma_buffer_end) { 103 if (prtd->period_ptr >= prtd->dma_buffer_end) {
104 prtd->period_ptr = prtd->dma_buffer; 104 prtd->period_ptr = prtd->dma_buffer;
105 } 105 }
106 at91_ssc_write(params->ssc_base + params->pdc->xnpr, prtd->period_ptr); 106 at91_ssc_write(params->ssc_base + params->pdc->xnpr,
107 prtd->period_ptr);
107 at91_ssc_write(params->ssc_base + params->pdc->xncr, 108 at91_ssc_write(params->ssc_base + params->pdc->xncr,
108 prtd->period_size / params->pdc_xfer_size); 109 prtd->period_size / params->pdc_xfer_size);
109 } 110 }
@@ -191,10 +192,12 @@ static int at91_pcm_trigger(struct snd_pcm_substream *substream,
191 at91_ssc_write(params->ssc_base + AT91_SSC_IER, 192 at91_ssc_write(params->ssc_base + AT91_SSC_IER,
192 params->mask->ssc_endx | params->mask->ssc_endbuf); 193 params->mask->ssc_endx | params->mask->ssc_endbuf);
193 194
194 at91_ssc_write(params->ssc_base + ATMEL_PDC_PTCR, params->mask->pdc_enable); 195 at91_ssc_write(params->ssc_base + ATMEL_PDC_PTCR,
196 params->mask->pdc_enable);
195 197
196 DBG("sr=%lx imr=%lx\n", at91_ssc_read(params->ssc_base + AT91_SSC_SR), 198 DBG("sr=%lx imr=%lx\n",
197 at91_ssc_read(params->ssc_base + AT91_SSC_IER)); 199 at91_ssc_read(params->ssc_base + AT91_SSC_SR),
200 at91_ssc_read(params->ssc_base + AT91_SSC_IMR));
198 break; 201 break;
199 202
200 case SNDRV_PCM_TRIGGER_STOP: 203 case SNDRV_PCM_TRIGGER_STOP:
diff --git a/sound/soc/at91/at91-ssc.c b/sound/soc/at91/at91-ssc.c
index f642d2dd4ec3..bc35d00a38f8 100644
--- a/sound/soc/at91/at91-ssc.c
+++ b/sound/soc/at91/at91-ssc.c
@@ -590,7 +590,7 @@ static int at91_ssc_hw_params(struct snd_pcm_substream *substream,
590 printk(KERN_WARNING "at91-ssc: request_irq failure\n"); 590 printk(KERN_WARNING "at91-ssc: request_irq failure\n");
591 591
592 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid); 592 DBG("Stopping pid %d clock\n", ssc_p->ssc.pid);
593 at91_sys_write(AT91_PMC_PCER, 1<<ssc_p->ssc.pid); 593 at91_sys_write(AT91_PMC_PCDR, 1<<ssc_p->ssc.pid);
594 return ret; 594 return ret;
595 } 595 }
596 596
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 630684f4a0bc..09b1661b8a3a 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -539,8 +539,8 @@ static const char *intercon[][3] = {
539 {"HPRCOM", NULL, "Right HP Com"}, 539 {"HPRCOM", NULL, "Right HP Com"},
540 540
541 /* Mono Output */ 541 /* Mono Output */
542 {"MONOLOUT", NULL, "Mono Out"}, 542 {"MONO_LOUT", NULL, "Mono Out"},
543 {"MONOLOUT", NULL, "Mono Out"}, 543 {"MONO_LOUT", NULL, "Mono Out"},
544 544
545 /* Left Input */ 545 /* Left Input */
546 {"Left Line1L Mux", "single-ended", "LINE1L"}, 546 {"Left Line1L Mux", "single-ended", "LINE1L"},
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index b2a11b0d2e4c..f588545698f3 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -416,7 +416,7 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd)
416 * to put data into its FIFO. Without it, ALSA starts 416 * to put data into its FIFO. Without it, ALSA starts
417 * to complain about overruns. 417 * to complain about overruns.
418 */ 418 */
419 msleep(1); 419 mdelay(1);
420 } 420 }
421 break; 421 break;
422 422
diff --git a/sound/soc/omap/n810.c b/sound/soc/omap/n810.c
index 83b1eb4e40f3..6533563a6011 100644
--- a/sound/soc/omap/n810.c
+++ b/sound/soc/omap/n810.c
@@ -188,8 +188,8 @@ static const char *audio_map[][3] = {
188static const char *spk_function[] = {"Off", "On"}; 188static const char *spk_function[] = {"Off", "On"};
189static const char *jack_function[] = {"Off", "Headphone"}; 189static const char *jack_function[] = {"Off", "Headphone"};
190static const struct soc_enum n810_enum[] = { 190static const struct soc_enum n810_enum[] = {
191 SOC_ENUM_SINGLE_EXT(2, spk_function), 191 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(spk_function), spk_function),
192 SOC_ENUM_SINGLE_EXT(3, jack_function), 192 SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(jack_function), jack_function),
193}; 193};
194 194
195static const struct snd_kcontrol_new aic33_n810_controls[] = { 195static const struct snd_kcontrol_new aic33_n810_controls[] = {
diff --git a/sound/soc/s3c24xx/s3c24xx-i2s.c b/sound/soc/s3c24xx/s3c24xx-i2s.c
index 4ebcd6a8bf28..1ed6afd45459 100644
--- a/sound/soc/s3c24xx/s3c24xx-i2s.c
+++ b/sound/soc/s3c24xx/s3c24xx-i2s.c
@@ -224,6 +224,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai,
224 iismod |= S3C2410_IISMOD_SLAVE; 224 iismod |= S3C2410_IISMOD_SLAVE;
225 break; 225 break;
226 case SND_SOC_DAIFMT_CBS_CFS: 226 case SND_SOC_DAIFMT_CBS_CFS:
227 iismod &= ~S3C2410_IISMOD_SLAVE;
227 break; 228 break;
228 default: 229 default:
229 return -EINVAL; 230 return -EINVAL;
@@ -234,6 +235,7 @@ static int s3c24xx_i2s_set_fmt(struct snd_soc_cpu_dai *cpu_dai,
234 iismod |= S3C2410_IISMOD_MSB; 235 iismod |= S3C2410_IISMOD_MSB;
235 break; 236 break;
236 case SND_SOC_DAIFMT_I2S: 237 case SND_SOC_DAIFMT_I2S:
238 iismod &= ~S3C2410_IISMOD_MSB;
237 break; 239 break;
238 default: 240 default:
239 return -EINVAL; 241 return -EINVAL;
diff --git a/sound/soc/s3c24xx/s3c24xx-pcm.c b/sound/soc/s3c24xx/s3c24xx-pcm.c
index 6c70a81c730c..7806ae614617 100644
--- a/sound/soc/s3c24xx/s3c24xx-pcm.c
+++ b/sound/soc/s3c24xx/s3c24xx-pcm.c
@@ -171,7 +171,7 @@ static int s3c24xx_pcm_hw_params(struct snd_pcm_substream *substream,
171 ret = s3c2410_dma_request(prtd->params->channel, 171 ret = s3c2410_dma_request(prtd->params->channel,
172 prtd->params->client, NULL); 172 prtd->params->client, NULL);
173 173
174 if (ret) { 174 if (ret < 0) {
175 DBG(KERN_ERR "failed to get dma channel\n"); 175 DBG(KERN_ERR "failed to get dma channel\n");
176 return ret; 176 return ret;
177 } 177 }
diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c
index 478369bb38c3..b343818dbb96 100644
--- a/sound/synth/emux/emux_synth.c
+++ b/sound/synth/emux/emux_synth.c
@@ -341,8 +341,12 @@ snd_emux_control(void *p, int type, struct snd_midi_channel *chan)
341 case MIDI_CTL_SOFT_PEDAL: 341 case MIDI_CTL_SOFT_PEDAL:
342#ifdef SNDRV_EMUX_USE_RAW_EFFECT 342#ifdef SNDRV_EMUX_USE_RAW_EFFECT
343 /* FIXME: this is an emulation */ 343 /* FIXME: this is an emulation */
344 snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160, 344 if (chan->control[type] >= 64)
345 snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, -160,
345 EMUX_FX_FLAG_ADD); 346 EMUX_FX_FLAG_ADD);
347 else
348 snd_emux_send_effect(port, chan, EMUX_FX_CUTOFF, 0,
349 EMUX_FX_FLAG_OFF);
346#endif 350#endif
347 break; 351 break;
348 352