aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-27 18:16:47 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-27 18:16:47 -0400
commit3b9f6cb8a1ec791be79c6c7595fea922f12d1e64 (patch)
tree2393a448add846e6c2ed12f68106c3018b72c6a9
parentc38778c3a9aeadcd1ee319cfc8ea5a9cbf8cdafa (diff)
parenta77c64c1a641950626181b4857abb701d8f38ccc (diff)
Merge branch 'master' into upstream
-rw-r--r--Documentation/ABI/removed/devfs (renamed from Documentation/ABI/obsolete/devfs)5
-rw-r--r--Documentation/ABI/testing/sysfs-power88
-rw-r--r--Documentation/DocBook/usb.tmpl123
-rw-r--r--Documentation/HOWTO3
-rw-r--r--Documentation/devices.txt3
-rw-r--r--Documentation/feature-removal-schedule.txt56
-rw-r--r--Documentation/filesystems/proc.txt14
-rw-r--r--Documentation/i2c/busses/i2c-viapro7
-rw-r--r--Documentation/i2c/i2c-stub15
-rw-r--r--Documentation/kbuild/makefiles.txt5
-rw-r--r--Documentation/kernel-parameters.txt11
-rw-r--r--Documentation/networking/bonding.txt59
-rw-r--r--Documentation/nommu-mmap.txt46
-rw-r--r--Documentation/pcieaer-howto.txt253
-rw-r--r--Documentation/power/devices.txt725
-rw-r--r--Documentation/sh/new-machine.txt128
-rw-r--r--Documentation/sh/register-banks.txt33
-rw-r--r--Documentation/usb/error-codes.txt11
-rw-r--r--Documentation/usb/usb-serial.txt5
-rw-r--r--Documentation/x86_64/boot-options.txt7
-rw-r--r--Documentation/x86_64/kernel-stacks99
-rw-r--r--MAINTAINERS1
-rw-r--r--Makefile6
-rw-r--r--arch/arm/mach-pxa/corgi.c15
-rw-r--r--arch/arm/plat-omap/usb.c2
-rw-r--r--arch/avr32/mm/tlb.c6
-rw-r--r--arch/i386/Kconfig31
-rw-r--r--arch/i386/Makefile8
-rw-r--r--arch/i386/boot/edd.S97
-rw-r--r--arch/i386/boot/setup.S4
-rw-r--r--arch/i386/defconfig1063
-rw-r--r--arch/i386/kernel/Makefile3
-rw-r--r--arch/i386/kernel/acpi/Makefile2
-rw-r--r--arch/i386/kernel/acpi/boot.c181
-rw-r--r--arch/i386/kernel/acpi/earlyquirk.c6
-rw-r--r--arch/i386/kernel/apic.c31
-rw-r--r--arch/i386/kernel/cpu/amd.c7
-rw-r--r--arch/i386/kernel/cpu/centaur.c24
-rw-r--r--arch/i386/kernel/cpu/common.c8
-rw-r--r--arch/i386/kernel/cpu/cpu.h2
-rw-r--r--arch/i386/kernel/cpu/cyrix.c42
-rw-r--r--arch/i386/kernel/cpu/intel.c3
-rw-r--r--arch/i386/kernel/cpu/mcheck/Makefile2
-rw-r--r--arch/i386/kernel/cpu/mcheck/p4.c26
-rw-r--r--arch/i386/kernel/cpu/mcheck/therm_throt.c180
-rw-r--r--arch/i386/kernel/cpu/nexgen.c9
-rw-r--r--arch/i386/kernel/cpu/proc.c4
-rw-r--r--arch/i386/kernel/cpu/rise.c4
-rw-r--r--arch/i386/kernel/cpu/transmeta.c7
-rw-r--r--arch/i386/kernel/cpu/umc.c7
-rw-r--r--arch/i386/kernel/crash.c22
-rw-r--r--arch/i386/kernel/entry.S110
-rw-r--r--arch/i386/kernel/head.S67
-rw-r--r--arch/i386/kernel/i8259.c6
-rw-r--r--arch/i386/kernel/io_apic.c125
-rw-r--r--arch/i386/kernel/machine_kexec.c140
-rw-r--r--arch/i386/kernel/mca.c8
-rw-r--r--arch/i386/kernel/microcode.c774
-rw-r--r--arch/i386/kernel/mpparse.c70
-rw-r--r--arch/i386/kernel/nmi.c940
-rw-r--r--arch/i386/kernel/process.c14
-rw-r--r--arch/i386/kernel/ptrace.c10
-rw-r--r--arch/i386/kernel/relocate_kernel.S162
-rw-r--r--arch/i386/kernel/semaphore.c134
-rw-r--r--arch/i386/kernel/setup.c393
-rw-r--r--arch/i386/kernel/smpboot.c19
-rw-r--r--arch/i386/kernel/srat.c97
-rw-r--r--arch/i386/kernel/stacktrace.c98
-rw-r--r--arch/i386/kernel/syscall_table.S1
-rw-r--r--arch/i386/kernel/time.c23
-rw-r--r--arch/i386/kernel/topology.c21
-rw-r--r--arch/i386/kernel/traps.c231
-rw-r--r--arch/i386/kernel/tsc.c2
-rw-r--r--arch/i386/lib/Makefile2
-rw-r--r--arch/i386/lib/semaphore.S217
-rw-r--r--arch/i386/mach-generic/bigsmp.c1
-rw-r--r--arch/i386/mach-generic/es7000.c1
-rw-r--r--arch/i386/mach-generic/probe.c60
-rw-r--r--arch/i386/mach-generic/summit.c1
-rw-r--r--arch/i386/mm/discontig.c74
-rw-r--r--arch/i386/mm/extable.c2
-rw-r--r--arch/i386/mm/fault.c25
-rw-r--r--arch/i386/mm/highmem.c2
-rw-r--r--arch/i386/mm/init.c38
-rw-r--r--arch/i386/oprofile/nmi_int.c88
-rw-r--r--arch/i386/oprofile/nmi_timer_int.c35
-rw-r--r--arch/i386/oprofile/op_model_athlon.c54
-rw-r--r--arch/i386/oprofile/op_model_p4.c152
-rw-r--r--arch/i386/oprofile/op_model_ppro.c65
-rw-r--r--arch/i386/oprofile/op_x86_model.h1
-rw-r--r--arch/i386/pci/Makefile2
-rw-r--r--arch/i386/pci/common.c4
-rw-r--r--arch/i386/pci/direct.c25
-rw-r--r--arch/i386/pci/early.c52
-rw-r--r--arch/i386/pci/init.c9
-rw-r--r--arch/i386/pci/mmconfig.c41
-rw-r--r--arch/i386/pci/pci.h7
-rw-r--r--arch/ia64/Kconfig11
-rw-r--r--arch/ia64/ia32/sys_ia32.c2
-rw-r--r--arch/ia64/kernel/Makefile5
-rw-r--r--arch/ia64/kernel/entry.S4
-rw-r--r--arch/ia64/kernel/esi.c205
-rw-r--r--arch/ia64/kernel/esi_stub.S96
-rw-r--r--arch/ia64/kernel/ia64_ksyms.c4
-rw-r--r--arch/ia64/kernel/kprobes.c61
-rw-r--r--arch/ia64/kernel/mca.c234
-rw-r--r--arch/ia64/kernel/mca_asm.S9
-rw-r--r--arch/ia64/kernel/mca_drv.c54
-rw-r--r--arch/ia64/kernel/mca_drv.h4
-rw-r--r--arch/ia64/kernel/perfmon.c113
-rw-r--r--arch/ia64/kernel/salinfo.c4
-rw-r--r--arch/ia64/kernel/setup.c41
-rw-r--r--arch/ia64/kernel/smpboot.c24
-rw-r--r--arch/ia64/kernel/topology.c2
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S8
-rw-r--r--arch/ia64/mm/contig.c84
-rw-r--r--arch/ia64/mm/discontig.c72
-rw-r--r--arch/ia64/mm/init.c12
-rw-r--r--arch/ia64/pci/pci.c3
-rw-r--r--arch/ia64/sn/kernel/bte.c3
-rw-r--r--arch/mips/Kconfig46
-rw-r--r--arch/mips/Makefile8
-rw-r--r--arch/mips/au1000/db1x00/Makefile1
-rw-r--r--arch/mips/au1000/db1x00/mirage_ts.c260
-rw-r--r--arch/mips/basler/excite/excite_device.c16
-rw-r--r--arch/mips/configs/atlas_defconfig3
-rw-r--r--arch/mips/configs/bigsur_defconfig1
-rw-r--r--arch/mips/configs/capcella_defconfig1
-rw-r--r--arch/mips/configs/cobalt_defconfig3
-rw-r--r--arch/mips/configs/db1000_defconfig1
-rw-r--r--arch/mips/configs/db1100_defconfig1
-rw-r--r--arch/mips/configs/db1200_defconfig1
-rw-r--r--arch/mips/configs/db1500_defconfig1
-rw-r--r--arch/mips/configs/db1550_defconfig1
-rw-r--r--arch/mips/configs/ddb5477_defconfig1
-rw-r--r--arch/mips/configs/decstation_defconfig1
-rw-r--r--arch/mips/configs/e55_defconfig11
-rw-r--r--arch/mips/configs/emma2rh_defconfig1
-rw-r--r--arch/mips/configs/ev64120_defconfig1
-rw-r--r--arch/mips/configs/excite_defconfig1
-rw-r--r--arch/mips/configs/ip22_defconfig3
-rw-r--r--arch/mips/configs/ip27_defconfig3
-rw-r--r--arch/mips/configs/ip32_defconfig1
-rw-r--r--arch/mips/configs/it8172_defconfig1
-rw-r--r--arch/mips/configs/ivr_defconfig1
-rw-r--r--arch/mips/configs/jaguar-atx_defconfig3
-rw-r--r--arch/mips/configs/jmr3927_defconfig1
-rw-r--r--arch/mips/configs/lasat200_defconfig3
-rw-r--r--arch/mips/configs/malta_defconfig3
-rw-r--r--arch/mips/configs/mipssim_defconfig1
-rw-r--r--arch/mips/configs/mpc30x_defconfig13
-rw-r--r--arch/mips/configs/ocelot_3_defconfig1
-rw-r--r--arch/mips/configs/ocelot_c_defconfig3
-rw-r--r--arch/mips/configs/ocelot_defconfig3
-rw-r--r--arch/mips/configs/ocelot_g_defconfig3
-rw-r--r--arch/mips/configs/pb1100_defconfig1
-rw-r--r--arch/mips/configs/pb1500_defconfig1
-rw-r--r--arch/mips/configs/pb1550_defconfig1
-rw-r--r--arch/mips/configs/pnx8550-jbs_defconfig1
-rw-r--r--arch/mips/configs/pnx8550-v2pci_defconfig1
-rw-r--r--arch/mips/configs/qemu_defconfig3
-rw-r--r--arch/mips/configs/rbhma4500_defconfig1
-rw-r--r--arch/mips/configs/rm200_defconfig3
-rw-r--r--arch/mips/configs/sb1250-swarm_defconfig1
-rw-r--r--arch/mips/configs/sead_defconfig1
-rw-r--r--arch/mips/configs/tb0226_defconfig1
-rw-r--r--arch/mips/configs/tb0229_defconfig1
-rw-r--r--arch/mips/configs/tb0287_defconfig1
-rw-r--r--arch/mips/configs/workpad_defconfig11
-rw-r--r--arch/mips/configs/wrppmc_defconfig1
-rw-r--r--arch/mips/configs/yosemite_defconfig1
-rw-r--r--arch/mips/defconfig5
-rw-r--r--arch/mips/galileo-boards/ev96100/Makefile9
-rw-r--r--arch/mips/galileo-boards/ev96100/init.c173
-rw-r--r--arch/mips/galileo-boards/ev96100/irq.c77
-rw-r--r--arch/mips/galileo-boards/ev96100/puts.c138
-rw-r--r--arch/mips/galileo-boards/ev96100/reset.c70
-rw-r--r--arch/mips/galileo-boards/ev96100/setup.c159
-rw-r--r--arch/mips/galileo-boards/ev96100/time.c88
-rw-r--r--arch/mips/kernel/cpu-probe.c62
-rw-r--r--arch/mips/kernel/irixsig.c63
-rw-r--r--arch/mips/kernel/linux32.c10
-rw-r--r--arch/mips/kernel/process.c257
-rw-r--r--arch/mips/kernel/scall32-o32.S2
-rw-r--r--arch/mips/kernel/scall64-64.S2
-rw-r--r--arch/mips/kernel/scall64-n32.S6
-rw-r--r--arch/mips/kernel/scall64-o32.S4
-rw-r--r--arch/mips/kernel/setup.c439
-rw-r--r--arch/mips/kernel/signal.c8
-rw-r--r--arch/mips/kernel/signal32.c7
-rw-r--r--arch/mips/kernel/smp-mt.c2
-rw-r--r--arch/mips/kernel/smtc-asm.S2
-rw-r--r--arch/mips/kernel/syscall.c4
-rw-r--r--arch/mips/kernel/traps.c146
-rw-r--r--arch/mips/kernel/vpe.c6
-rw-r--r--arch/mips/mips-boards/atlas/atlas_int.c105
-rw-r--r--arch/mips/mips-boards/atlas/atlas_setup.c2
-rw-r--r--arch/mips/mips-boards/generic/time.c64
-rw-r--r--arch/mips/mm/c-r3k.c2
-rw-r--r--arch/mips/mm/c-r4k.c28
-rw-r--r--arch/mips/mm/c-sb1.c58
-rw-r--r--arch/mips/mm/c-tx39.c4
-rw-r--r--arch/mips/mm/cache.c18
-rw-r--r--arch/mips/mm/fault.c2
-rw-r--r--arch/mips/mm/tlb-r4k.c21
-rw-r--r--arch/mips/pci/Makefile4
-rw-r--r--arch/mips/pci/fixup-atlas.c20
-rw-r--r--arch/mips/pci/fixup-ev96100.c48
-rw-r--r--arch/mips/pci/ops-au1000.c2
-rw-r--r--arch/mips/pci/ops-gt96100.c169
-rw-r--r--arch/mips/pci/pci-ev96100.c63
-rw-r--r--arch/mips/pci/pci-ip27.c2
-rw-r--r--arch/mips/sibyte/bcm1480/irq.c19
-rw-r--r--arch/mips/sibyte/sb1250/irq.c17
-rw-r--r--arch/powerpc/Kconfig7
-rw-r--r--arch/powerpc/kernel/sys_ppc32.c2
-rw-r--r--arch/powerpc/mm/mem.c51
-rw-r--r--arch/powerpc/mm/numa.c159
-rw-r--r--arch/powerpc/platforms/cell/spufs/inode.c3
-rw-r--r--arch/powerpc/platforms/pseries/hvCall_inst.c2
-rw-r--r--arch/powerpc/sysdev/mpic.c2
-rw-r--r--arch/ppc/Kconfig3
-rw-r--r--arch/ppc/mm/init.c23
-rw-r--r--arch/s390/hypfs/inode.c7
-rw-r--r--arch/s390/kernel/compat_linux.c2
-rw-r--r--arch/s390/kernel/debug.c2
-rw-r--r--arch/s390/kernel/stacktrace.c17
-rw-r--r--arch/sh/Kconfig173
-rw-r--r--arch/sh/Kconfig.debug36
-rw-r--r--arch/sh/Makefile40
-rw-r--r--arch/sh/boards/adx/Makefile6
-rw-r--r--arch/sh/boards/adx/irq.c31
-rw-r--r--arch/sh/boards/adx/setup.c56
-rw-r--r--arch/sh/boards/bigsur/irq.c47
-rw-r--r--arch/sh/boards/bigsur/setup.c47
-rw-r--r--arch/sh/boards/cat68701/Makefile6
-rw-r--r--arch/sh/boards/cat68701/irq.c28
-rw-r--r--arch/sh/boards/cat68701/setup.c85
-rw-r--r--arch/sh/boards/cqreek/Makefile6
-rw-r--r--arch/sh/boards/cqreek/irq.c128
-rw-r--r--arch/sh/boards/cqreek/setup.c100
-rw-r--r--arch/sh/boards/dmida/Makefile7
-rw-r--r--arch/sh/boards/dmida/mach.c59
-rw-r--r--arch/sh/boards/dreamcast/irq.c15
-rw-r--r--arch/sh/boards/dreamcast/rtc.c22
-rw-r--r--arch/sh/boards/dreamcast/setup.c40
-rw-r--r--arch/sh/boards/ec3104/setup.c49
-rw-r--r--arch/sh/boards/harp/Makefile8
-rw-r--r--arch/sh/boards/harp/irq.c147
-rw-r--r--arch/sh/boards/harp/led.c51
-rw-r--r--arch/sh/boards/harp/mach.c62
-rw-r--r--arch/sh/boards/harp/pcidma.c42
-rw-r--r--arch/sh/boards/harp/setup.c90
-rw-r--r--arch/sh/boards/hp6xx/Makefile5
-rw-r--r--arch/sh/boards/hp6xx/hp6xx_apm.c123
-rw-r--r--arch/sh/boards/hp6xx/pm.c88
-rw-r--r--arch/sh/boards/hp6xx/pm_wakeup.S58
-rw-r--r--arch/sh/boards/hp6xx/setup.c62
-rw-r--r--arch/sh/boards/landisk/Makefile5
-rw-r--r--arch/sh/boards/landisk/io.c250
-rw-r--r--arch/sh/boards/landisk/irq.c99
-rw-r--r--arch/sh/boards/landisk/landisk_pwb.c348
-rw-r--r--arch/sh/boards/landisk/rtc.c93
-rw-r--r--arch/sh/boards/landisk/setup.c177
-rw-r--r--arch/sh/boards/mpc1211/rtc.c4
-rw-r--r--arch/sh/boards/mpc1211/setup.c71
-rw-r--r--arch/sh/boards/overdrive/Makefile8
-rw-r--r--arch/sh/boards/overdrive/fpga.c133
-rw-r--r--arch/sh/boards/overdrive/galileo.c587
-rw-r--r--arch/sh/boards/overdrive/io.c172
-rw-r--r--arch/sh/boards/overdrive/irq.c191
-rw-r--r--arch/sh/boards/overdrive/led.c58
-rw-r--r--arch/sh/boards/overdrive/mach.c62
-rw-r--r--arch/sh/boards/overdrive/pcidma.c46
-rw-r--r--arch/sh/boards/overdrive/setup.c36
-rw-r--r--arch/sh/boards/renesas/edosk7705/Makefile4
-rw-r--r--arch/sh/boards/renesas/edosk7705/setup.c29
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/Kconfig12
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/Makefile6
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/io.c252
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/irq.c6
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/led.c26
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/mach.c54
-rw-r--r--arch/sh/boards/renesas/hs7751rvoip/setup.c94
-rw-r--r--arch/sh/boards/renesas/r7780rp/Kconfig14
-rw-r--r--arch/sh/boards/renesas/r7780rp/Makefile6
-rw-r--r--arch/sh/boards/renesas/r7780rp/io.c301
-rw-r--r--arch/sh/boards/renesas/r7780rp/irq.c117
-rw-r--r--arch/sh/boards/renesas/r7780rp/led.c45
-rw-r--r--arch/sh/boards/renesas/r7780rp/setup.c163
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/Kconfig12
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/Makefile8
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/io.c191
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/irq.c6
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/led.c11
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/mach.c69
-rw-r--r--arch/sh/boards/renesas/rts7751r2d/setup.c139
-rw-r--r--arch/sh/boards/renesas/sh7710voipgw/Makefile1
-rw-r--r--arch/sh/boards/renesas/sh7710voipgw/setup.c109
-rw-r--r--arch/sh/boards/renesas/systemh/io.c163
-rw-r--r--arch/sh/boards/renesas/systemh/irq.c10
-rw-r--r--arch/sh/boards/renesas/systemh/setup.c30
-rw-r--r--arch/sh/boards/saturn/setup.c14
-rw-r--r--arch/sh/boards/se/7300/io.c8
-rw-r--r--arch/sh/boards/se/7300/irq.c2
-rw-r--r--arch/sh/boards/se/7300/led.c18
-rw-r--r--arch/sh/boards/se/7300/setup.c20
-rw-r--r--arch/sh/boards/se/73180/io.c6
-rw-r--r--arch/sh/boards/se/73180/irq.c9
-rw-r--r--arch/sh/boards/se/73180/led.c15
-rw-r--r--arch/sh/boards/se/73180/setup.c22
-rw-r--r--arch/sh/boards/se/7343/Makefile7
-rw-r--r--arch/sh/boards/se/7343/io.c275
-rw-r--r--arch/sh/boards/se/7343/irq.c193
-rw-r--r--arch/sh/boards/se/7343/led.c46
-rw-r--r--arch/sh/boards/se/7343/setup.c84
-rw-r--r--arch/sh/boards/se/770x/Makefile4
-rw-r--r--arch/sh/boards/se/770x/io.c61
-rw-r--r--arch/sh/boards/se/770x/irq.c2
-rw-r--r--arch/sh/boards/se/770x/led.c17
-rw-r--r--arch/sh/boards/se/770x/mach.c67
-rw-r--r--arch/sh/boards/se/770x/setup.c65
-rw-r--r--arch/sh/boards/se/7751/Makefile4
-rw-r--r--arch/sh/boards/se/7751/io.c171
-rw-r--r--arch/sh/boards/se/7751/irq.c2
-rw-r--r--arch/sh/boards/se/7751/led.c18
-rw-r--r--arch/sh/boards/se/7751/mach.c54
-rw-r--r--arch/sh/boards/se/7751/setup.c109
-rw-r--r--arch/sh/boards/sh03/rtc.c9
-rw-r--r--arch/sh/boards/sh03/setup.c49
-rw-r--r--arch/sh/boards/sh2000/Makefile6
-rw-r--r--arch/sh/boards/sh2000/setup.c70
-rw-r--r--arch/sh/boards/shmin/Makefile5
-rw-r--r--arch/sh/boards/shmin/setup.c41
-rw-r--r--arch/sh/boards/snapgear/io.c145
-rw-r--r--arch/sh/boards/snapgear/rtc.c34
-rw-r--r--arch/sh/boards/snapgear/setup.c115
-rw-r--r--arch/sh/boards/superh/microdev/irq.c39
-rw-r--r--arch/sh/boards/superh/microdev/setup.c113
-rw-r--r--arch/sh/boards/titan/Makefile5
-rw-r--r--arch/sh/boards/titan/io.c126
-rw-r--r--arch/sh/boards/titan/setup.c48
-rw-r--r--arch/sh/boards/unknown/setup.c13
-rw-r--r--arch/sh/boot/compressed/Makefile11
-rw-r--r--arch/sh/cchips/Kconfig6
-rw-r--r--arch/sh/cchips/hd6446x/hd64461/io.c20
-rw-r--r--arch/sh/cchips/hd6446x/hd64461/setup.c10
-rw-r--r--arch/sh/cchips/hd6446x/hd64465/setup.c6
-rw-r--r--arch/sh/cchips/voyagergx/irq.c23
-rw-r--r--arch/sh/cchips/voyagergx/setup.c2
-rw-r--r--arch/sh/configs/landisk_defconfig1373
-rw-r--r--arch/sh/configs/r7780rp_defconfig1099
-rw-r--r--arch/sh/configs/se73180_defconfig1
-rw-r--r--arch/sh/configs/se7343_defconfig997
-rw-r--r--arch/sh/configs/sh7710voipgw_defconfig913
-rw-r--r--arch/sh/configs/shmin_defconfig (renamed from arch/mips/configs/ev96100_defconfig)639
-rw-r--r--arch/sh/configs/titan_defconfig1367
-rw-r--r--arch/sh/drivers/dma/Kconfig3
-rw-r--r--arch/sh/drivers/dma/dma-g2.c54
-rw-r--r--arch/sh/drivers/dma/dma-pvr2.c5
-rw-r--r--arch/sh/drivers/dma/dma-sh.c19
-rw-r--r--arch/sh/drivers/pci/Makefile6
-rw-r--r--arch/sh/drivers/pci/fixups-dreamcast.c38
-rw-r--r--arch/sh/drivers/pci/fixups-r7780rp.c45
-rw-r--r--arch/sh/drivers/pci/fixups-rts7751r2d.c24
-rw-r--r--arch/sh/drivers/pci/fixups-sh03.c38
-rw-r--r--arch/sh/drivers/pci/ops-bigsur.c18
-rw-r--r--arch/sh/drivers/pci/ops-landisk.c68
-rw-r--r--arch/sh/drivers/pci/ops-r7780rp.c75
-rw-r--r--arch/sh/drivers/pci/ops-rts7751r2d.c13
-rw-r--r--arch/sh/drivers/pci/ops-sh4.c164
-rw-r--r--arch/sh/drivers/pci/ops-snapgear.c21
-rw-r--r--arch/sh/drivers/pci/ops-titan.c83
-rw-r--r--arch/sh/drivers/pci/pci-auto.c48
-rw-r--r--arch/sh/drivers/pci/pci-sh4.h180
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.c326
-rw-r--r--arch/sh/drivers/pci/pci-sh7751.h174
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.c139
-rw-r--r--arch/sh/drivers/pci/pci-sh7780.h94
-rw-r--r--arch/sh/drivers/pci/pci-st40.c19
-rw-r--r--arch/sh/drivers/pci/pci.c105
-rw-r--r--arch/sh/kernel/Makefile5
-rw-r--r--arch/sh/kernel/apm.c539
-rw-r--r--arch/sh/kernel/cf-enabler.c12
-rw-r--r--arch/sh/kernel/cpu/Makefile1
-rw-r--r--arch/sh/kernel/cpu/clock.c19
-rw-r--r--arch/sh/kernel/cpu/init.c21
-rw-r--r--arch/sh/kernel/cpu/irq/Makefile5
-rw-r--r--arch/sh/kernel/cpu/irq/intc2.c6
-rw-r--r--arch/sh/kernel/cpu/irq/ipr.c14
-rw-r--r--arch/sh/kernel/cpu/irq/maskreg.c (renamed from arch/sh/boards/adx/irq_maskreg.c)61
-rw-r--r--arch/sh/kernel/cpu/irq/pint.c8
-rw-r--r--arch/sh/kernel/cpu/rtc.c128
-rw-r--r--arch/sh/kernel/cpu/sh3/Makefile13
-rw-r--r--arch/sh/kernel/cpu/sh3/clock-sh7706.c84
-rw-r--r--arch/sh/kernel/cpu/sh3/ex.S54
-rw-r--r--arch/sh/kernel/cpu/sh3/probe.c6
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7300.c43
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7705.c48
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7708.c43
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7709.c53
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7710.c43
-rw-r--r--arch/sh/kernel/cpu/sh4/Makefile10
-rw-r--r--arch/sh/kernel/cpu/sh4/ex.S176
-rw-r--r--arch/sh/kernel/cpu/sh4/probe.c138
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh4-202.c43
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh73180.c43
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7343.c43
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c48
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7760.c53
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7770.c53
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7780.c79
-rw-r--r--arch/sh/kernel/cpu/sh4/sq.c543
-rw-r--r--arch/sh/kernel/early_printk.c106
-rw-r--r--arch/sh/kernel/entry.S333
-rw-r--r--arch/sh/kernel/head.S43
-rw-r--r--arch/sh/kernel/io.c67
-rw-r--r--arch/sh/kernel/irq.c168
-rw-r--r--arch/sh/kernel/kgdb_stub.c33
-rw-r--r--arch/sh/kernel/machine_kexec.c6
-rw-r--r--arch/sh/kernel/pm.c88
-rw-r--r--arch/sh/kernel/process.c28
-rw-r--r--arch/sh/kernel/ptrace.c1
-rw-r--r--arch/sh/kernel/semaphore.c2
-rw-r--r--arch/sh/kernel/setup.c117
-rw-r--r--arch/sh/kernel/sh_ksyms.c32
-rw-r--r--arch/sh/kernel/signal.c158
-rw-r--r--arch/sh/kernel/sys_sh.c56
-rw-r--r--arch/sh/kernel/syscalls.S353
-rw-r--r--arch/sh/kernel/time.c68
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c24
-rw-r--r--arch/sh/kernel/traps.c184
-rw-r--r--arch/sh/kernel/vmlinux.lds.S17
-rw-r--r--arch/sh/kernel/vsyscall/Makefile36
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-note.S25
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-sigreturn.S39
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-syscall.S10
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall-trapa.S42
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.c150
-rw-r--r--arch/sh/kernel/vsyscall/vsyscall.lds.S74
-rw-r--r--arch/sh/lib/checksum.S3
-rw-r--r--arch/sh/lib/memcpy-sh4.S4
-rw-r--r--arch/sh/lib/memset.S1
-rw-r--r--arch/sh/math-emu/Makefile1
-rw-r--r--arch/sh/math-emu/math.c624
-rw-r--r--arch/sh/math-emu/sfp-util.h72
-rw-r--r--arch/sh/mm/Kconfig78
-rw-r--r--arch/sh/mm/Makefile16
-rw-r--r--arch/sh/mm/cache-debugfs.c147
-rw-r--r--arch/sh/mm/cache-sh4.c685
-rw-r--r--arch/sh/mm/cache-sh7705.c19
-rw-r--r--arch/sh/mm/clear_page.S99
-rw-r--r--arch/sh/mm/consistent.c2
-rw-r--r--arch/sh/mm/fault.c207
-rw-r--r--arch/sh/mm/hugetlbpage.c52
-rw-r--r--arch/sh/mm/init.c32
-rw-r--r--arch/sh/mm/ioremap.c17
-rw-r--r--arch/sh/mm/pg-nommu.c17
-rw-r--r--arch/sh/mm/pg-sh4.c24
-rw-r--r--arch/sh/mm/pmb.c400
-rw-r--r--arch/sh/mm/tlb-flush.c134
-rw-r--r--arch/sh/mm/tlb-sh4.c8
-rw-r--r--arch/sh/oprofile/Makefile4
-rw-r--r--arch/sh/tools/mach-types10
-rw-r--r--arch/sparc64/defconfig38
-rw-r--r--arch/sparc64/kernel/sys_sparc32.c2
-rw-r--r--arch/sparc64/mm/init.c3
-rw-r--r--arch/um/Makefile-x86_647
-rw-r--r--arch/um/drivers/chan_kern.c16
-rw-r--r--arch/um/drivers/daemon.h2
-rw-r--r--arch/um/drivers/daemon_kern.c2
-rw-r--r--arch/um/drivers/daemon_user.c2
-rw-r--r--arch/um/drivers/fd.c4
-rw-r--r--arch/um/drivers/hostaudio_kern.c4
-rw-r--r--arch/um/drivers/line.c6
-rw-r--r--arch/um/drivers/mcast.h2
-rw-r--r--arch/um/drivers/mcast_kern.c2
-rw-r--r--arch/um/drivers/mcast_user.c2
-rw-r--r--arch/um/drivers/mmapper_kern.c4
-rw-r--r--arch/um/drivers/net_kern.c25
-rw-r--r--arch/um/drivers/null.c4
-rw-r--r--arch/um/drivers/pcap_kern.c2
-rw-r--r--arch/um/drivers/pcap_user.c2
-rw-r--r--arch/um/drivers/port_user.c4
-rw-r--r--arch/um/drivers/pty.c6
-rw-r--r--arch/um/drivers/random.c2
-rw-r--r--arch/um/drivers/slip.h2
-rw-r--r--arch/um/drivers/slip_kern.c2
-rw-r--r--arch/um/drivers/slip_user.c2
-rw-r--r--arch/um/drivers/slirp.h2
-rw-r--r--arch/um/drivers/slirp_kern.c2
-rw-r--r--arch/um/drivers/slirp_user.c2
-rw-r--r--arch/um/drivers/ssl.c4
-rw-r--r--arch/um/drivers/stdio_console.c2
-rw-r--r--arch/um/drivers/tty.c4
-rw-r--r--arch/um/drivers/xterm.c4
-rw-r--r--arch/um/include/chan_kern.h6
-rw-r--r--arch/um/include/chan_user.h6
-rw-r--r--arch/um/include/kern_util.h2
-rw-r--r--arch/um/include/line.h4
-rw-r--r--arch/um/include/net_kern.h4
-rw-r--r--arch/um/include/os.h13
-rw-r--r--arch/um/include/skas/skas.h3
-rw-r--r--arch/um/include/sysdep-i386/archsetjmp.h3
-rw-r--r--arch/um/include/sysdep-x86_64/archsetjmp.h3
-rw-r--r--arch/um/include/sysdep-x86_64/ptrace.h43
-rw-r--r--arch/um/include/sysdep-x86_64/sc.h2
-rw-r--r--arch/um/kernel/Makefile2
-rw-r--r--arch/um/kernel/gmon_syms.c13
-rw-r--r--arch/um/kernel/ksyms.c3
-rw-r--r--arch/um/kernel/mem.c3
-rw-r--r--arch/um/kernel/process.c (renamed from arch/um/kernel/process_kern.c)33
-rw-r--r--arch/um/kernel/skas/Makefile3
-rw-r--r--arch/um/kernel/skas/exec.c30
-rw-r--r--arch/um/kernel/skas/exec_kern.c41
-rw-r--r--arch/um/kernel/skas/process.c217
-rw-r--r--arch/um/kernel/skas/process_kern.c533
-rw-r--r--arch/um/kernel/time.c2
-rw-r--r--arch/um/kernel/trap.c17
-rw-r--r--arch/um/kernel/um_arch.c2
-rw-r--r--arch/um/os-Linux/Makefile8
-rw-r--r--arch/um/os-Linux/drivers/etap.h2
-rw-r--r--arch/um/os-Linux/drivers/ethertap_kern.c2
-rw-r--r--arch/um/os-Linux/drivers/ethertap_user.c2
-rw-r--r--arch/um/os-Linux/drivers/tuntap.h2
-rw-r--r--arch/um/os-Linux/drivers/tuntap_kern.c2
-rw-r--r--arch/um/os-Linux/drivers/tuntap_user.c2
-rw-r--r--arch/um/os-Linux/skas/process.c68
-rw-r--r--arch/um/sys-i386/Makefile2
-rw-r--r--arch/x86_64/Kconfig49
-rw-r--r--arch/x86_64/Makefile10
-rw-r--r--arch/x86_64/boot/compressed/Makefile3
-rw-r--r--arch/x86_64/boot/setup.S4
-rw-r--r--arch/x86_64/defconfig109
-rw-r--r--arch/x86_64/ia32/ia32_aout.c8
-rw-r--r--arch/x86_64/ia32/ia32_signal.c53
-rw-r--r--arch/x86_64/ia32/ia32entry.S9
-rw-r--r--arch/x86_64/ia32/ptrace32.c10
-rw-r--r--arch/x86_64/ia32/sys_ia32.c54
-rw-r--r--arch/x86_64/kernel/Makefile9
-rw-r--r--arch/x86_64/kernel/aperture.c25
-rw-r--r--arch/x86_64/kernel/apic.c229
-rw-r--r--arch/x86_64/kernel/crash.c26
-rw-r--r--arch/x86_64/kernel/e820.c243
-rw-r--r--arch/x86_64/kernel/early-quirks.c122
-rw-r--r--arch/x86_64/kernel/early_printk.c20
-rw-r--r--arch/x86_64/kernel/entry.S63
-rw-r--r--arch/x86_64/kernel/genapic_cluster.c1
-rw-r--r--arch/x86_64/kernel/genapic_flat.c5
-rw-r--r--arch/x86_64/kernel/head.S15
-rw-r--r--arch/x86_64/kernel/head64.c44
-rw-r--r--arch/x86_64/kernel/i8259.c15
-rw-r--r--arch/x86_64/kernel/io_apic.c482
-rw-r--r--arch/x86_64/kernel/ioport.c1
-rw-r--r--arch/x86_64/kernel/irq.c12
-rw-r--r--arch/x86_64/kernel/machine_kexec.c99
-rw-r--r--arch/x86_64/kernel/mce.c29
-rw-r--r--arch/x86_64/kernel/mce_intel.c30
-rw-r--r--arch/x86_64/kernel/mpparse.c238
-rw-r--r--arch/x86_64/kernel/nmi.c840
-rw-r--r--arch/x86_64/kernel/pci-calgary.c142
-rw-r--r--arch/x86_64/kernel/pci-dma.c7
-rw-r--r--arch/x86_64/kernel/pci-gart.c3
-rw-r--r--arch/x86_64/kernel/pci-nommu.c1
-rw-r--r--arch/x86_64/kernel/process.c110
-rw-r--r--arch/x86_64/kernel/ptrace.c29
-rw-r--r--arch/x86_64/kernel/relocate_kernel.S171
-rw-r--r--arch/x86_64/kernel/setup.c248
-rw-r--r--arch/x86_64/kernel/setup64.c45
-rw-r--r--arch/x86_64/kernel/signal.c87
-rw-r--r--arch/x86_64/kernel/smp.c23
-rw-r--r--arch/x86_64/kernel/smpboot.c14
-rw-r--r--arch/x86_64/kernel/stacktrace.c220
-rw-r--r--arch/x86_64/kernel/tce.c12
-rw-r--r--arch/x86_64/kernel/time.c94
-rw-r--r--arch/x86_64/kernel/trampoline.S2
-rw-r--r--arch/x86_64/kernel/traps.c204
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S25
-rw-r--r--arch/x86_64/kernel/vsmp.c3
-rw-r--r--arch/x86_64/kernel/vsyscall.c98
-rw-r--r--arch/x86_64/kernel/x8664_ksyms.c1
-rw-r--r--arch/x86_64/lib/Makefile2
-rw-r--r--arch/x86_64/lib/clear_page.S47
-rw-r--r--arch/x86_64/lib/copy_page.S53
-rw-r--r--arch/x86_64/lib/copy_user.S153
-rw-r--r--arch/x86_64/lib/csum-copy.S26
-rw-r--r--arch/x86_64/lib/getuser.S32
-rw-r--r--arch/x86_64/lib/iomap_copy.S10
-rw-r--r--arch/x86_64/lib/memcpy.S69
-rw-r--r--arch/x86_64/lib/memset.S79
-rw-r--r--arch/x86_64/lib/putuser.S32
-rw-r--r--arch/x86_64/lib/rwlock.S38
-rw-r--r--arch/x86_64/lib/thunk.S43
-rw-r--r--arch/x86_64/mm/fault.c22
-rw-r--r--arch/x86_64/mm/init.c127
-rw-r--r--arch/x86_64/mm/k8topology.c6
-rw-r--r--arch/x86_64/mm/numa.c32
-rw-r--r--arch/x86_64/mm/pageattr.c24
-rw-r--r--arch/x86_64/mm/srat.c19
-rw-r--r--arch/x86_64/pci/Makefile3
-rw-r--r--arch/x86_64/pci/mmconfig.c44
-rw-r--r--block/blktrace.c2
-rw-r--r--drivers/acorn/char/i2c.c1
-rw-r--r--drivers/acpi/i2c_ec.c2
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/base/base.h2
-rw-r--r--drivers/base/bus.c133
-rw-r--r--drivers/base/class.c34
-rw-r--r--drivers/base/core.c230
-rw-r--r--drivers/base/dd.c147
-rw-r--r--drivers/base/driver.c16
-rw-r--r--drivers/base/firmware_class.c2
-rw-r--r--drivers/base/platform.c30
-rw-r--r--drivers/base/power/resume.c37
-rw-r--r--drivers/base/power/suspend.c92
-rw-r--r--drivers/base/power/sysfs.c35
-rw-r--r--drivers/block/loop.c7
-rw-r--r--drivers/block/ub.c38
-rw-r--r--drivers/char/Kconfig10
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/hpet.c4
-rw-r--r--drivers/char/mem.c39
-rw-r--r--drivers/char/mspec.c421
-rw-r--r--drivers/char/watchdog/Kconfig8
-rw-r--r--drivers/char/watchdog/shwdt.c110
-rw-r--r--drivers/eisa/eisa-bus.c23
-rw-r--r--drivers/hwmon/it87.c1
-rw-r--r--drivers/hwmon/lm78.c1
-rw-r--r--drivers/hwmon/pc87360.c1
-rw-r--r--drivers/hwmon/sis5595.c1
-rw-r--r--drivers/hwmon/smsc47b397.c1
-rw-r--r--drivers/hwmon/smsc47m1.c1
-rw-r--r--drivers/hwmon/via686a.c1
-rw-r--r--drivers/hwmon/vt8231.c1
-rw-r--r--drivers/hwmon/w83627ehf.c1
-rw-r--r--drivers/hwmon/w83627hf.c1
-rw-r--r--drivers/hwmon/w83781d.c1
-rw-r--r--drivers/i2c/Kconfig2
-rw-r--r--drivers/i2c/algos/Kconfig6
-rw-r--r--drivers/i2c/algos/Makefile1
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c23
-rw-r--r--drivers/i2c/algos/i2c-algo-pca.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-pcf.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-sgi.c2
-rw-r--r--drivers/i2c/algos/i2c-algo-sibyte.c215
-rw-r--r--drivers/i2c/busses/Kconfig34
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c2
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c2
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c2
-rw-r--r--drivers/i2c/busses/i2c-amd756.c2
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c2
-rw-r--r--drivers/i2c/busses/i2c-au1550.c21
-rw-r--r--drivers/i2c/busses/i2c-elektor.c1
-rw-r--r--drivers/i2c/busses/i2c-hydra.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-i810.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c2
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c2
-rw-r--r--drivers/i2c/busses/i2c-isa.c42
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c1
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c1
-rw-r--r--drivers/i2c/busses/i2c-mpc.c2
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c2
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c2
-rw-r--r--drivers/i2c/busses/i2c-ocores.c2
-rw-r--r--drivers/i2c/busses/i2c-omap.c676
-rw-r--r--drivers/i2c/busses/i2c-parport-light.c1
-rw-r--r--drivers/i2c/busses/i2c-parport.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c2
-rw-r--r--drivers/i2c/busses/i2c-powermac.c2
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c1
-rw-r--r--drivers/i2c/busses/i2c-pxa.c2
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c2
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sibyte.c160
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c2
-rw-r--r--drivers/i2c/busses/i2c-sis630.c2
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c2
-rw-r--r--drivers/i2c/busses/i2c-stub.c21
-rw-r--r--drivers/i2c/busses/i2c-via.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c10
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c2
-rw-r--r--drivers/i2c/busses/scx200_i2c.c12
-rw-r--r--drivers/i2c/chips/eeprom.c8
-rw-r--r--drivers/i2c/chips/isp1301_omap.c2
-rw-r--r--drivers/i2c/chips/max6875.c25
-rw-r--r--drivers/i2c/chips/pca9539.c11
-rw-r--r--drivers/i2c/chips/pcf8574.c22
-rw-r--r--drivers/i2c/chips/pcf8591.c58
-rw-r--r--drivers/i2c/chips/tps65010.c2
-rw-r--r--drivers/i2c/i2c-core.c72
-rw-r--r--drivers/i2c/i2c-dev.c109
-rw-r--r--drivers/ide/ide.c6
-rw-r--r--drivers/ide/ppc/pmac.c14
-rw-r--r--drivers/ieee1394/pcilynx.c1
-rw-r--r--drivers/infiniband/core/mad.c5
-rw-r--r--drivers/infiniband/hw/ipath/ipath_fs.c13
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba6110.c5
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c4
-rw-r--r--drivers/input/touchscreen/hp680_ts_input.c14
-rw-r--r--drivers/isdn/capi/capifs.c2
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c2
-rw-r--r--drivers/isdn/hisax/hfc_usb.h6
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-urb.c1
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c2
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c1
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c1
-rw-r--r--drivers/media/video/cx88/cx88-vp3054-i2c.c1
-rw-r--r--drivers/media/video/ov511.c7
-rw-r--r--drivers/media/video/pwc/pwc-if.c2
-rw-r--r--drivers/media/video/w9968cf.c7
-rw-r--r--drivers/media/video/zoran_card.c1
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c17
-rw-r--r--drivers/net/3c509.c1
-rw-r--r--drivers/net/3c59x.c1
-rw-r--r--drivers/net/acenic.c4
-rw-r--r--drivers/net/bonding/bond_3ad.c70
-rw-r--r--drivers/net/bonding/bond_main.c228
-rw-r--r--drivers/net/bonding/bond_sysfs.c56
-rw-r--r--drivers/net/bonding/bonding.h34
-rw-r--r--drivers/net/e1000/e1000_hw.h4
-rw-r--r--drivers/net/forcedeth.c8
-rw-r--r--drivers/net/gt64240eth.h402
-rw-r--r--drivers/net/irda/irda-usb.c18
-rw-r--r--drivers/net/irda/vlsi_ir.h2
-rw-r--r--drivers/net/ne3210.c1
-rw-r--r--drivers/net/phy/phy_device.c2
-rw-r--r--drivers/net/s2io.c10
-rw-r--r--drivers/net/skge.c357
-rw-r--r--drivers/net/skge.h37
-rw-r--r--drivers/net/smc91x.h18
-rw-r--r--drivers/net/stnic.c2
-rw-r--r--drivers/net/tokenring/lanstreamer.c59
-rw-r--r--drivers/net/tokenring/lanstreamer.h12
-rw-r--r--drivers/net/tulip/de4x5.c1
-rw-r--r--drivers/net/typhoon.c4
-rw-r--r--drivers/net/wan/Kconfig12
-rw-r--r--drivers/net/wan/Makefile19
-rw-r--r--drivers/net/wan/hdlc.c (renamed from drivers/net/wan/hdlc_generic.c)169
-rw-r--r--drivers/net/wan/hdlc_cisco.c198
-rw-r--r--drivers/net/wan/hdlc_fr.c389
-rw-r--r--drivers/net/wan/hdlc_ppp.c77
-rw-r--r--drivers/net/wan/hdlc_raw.c50
-rw-r--r--drivers/net/wan/hdlc_raw_eth.c49
-rw-r--r--drivers/net/wan/hdlc_x25.c54
-rw-r--r--drivers/net/wan/pc300.h1
-rw-r--r--drivers/net/wan/pc300_drv.c30
-rw-r--r--drivers/net/wireless/airo.c19
-rw-r--r--drivers/net/wireless/atmel.c18
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx.h1
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_main.c10
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_phy.c15
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_wx.c2
-rw-r--r--drivers/net/wireless/bcm43xx/bcm43xx_xmit.c5
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c10
-rw-r--r--drivers/net/wireless/ipw2100.c14
-rw-r--r--drivers/net/wireless/ipw2200.c16
-rw-r--r--drivers/net/wireless/orinoco.c10
-rw-r--r--drivers/net/wireless/prism54/isl_ioctl.c16
-rw-r--r--drivers/net/wireless/ray_cs.c2
-rw-r--r--drivers/net/wireless/wl3501_cs.c6
-rw-r--r--drivers/net/wireless/zd1201.c6
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.c137
-rw-r--r--drivers/net/wireless/zd1211rw/zd_chip.h23
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c50
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h5
-rw-r--r--drivers/net/wireless/zd1211rw/zd_netdev.c2
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c10
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.h2
-rw-r--r--drivers/oprofile/oprofilefs.c11
-rw-r--r--drivers/pci/Kconfig25
-rw-r--r--drivers/pci/bus.c22
-rw-r--r--drivers/pci/hotplug/acpiphp.h5
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c127
-rw-r--r--drivers/pci/hotplug/acpiphp_ibm.c4
-rw-r--r--drivers/pci/hotplug/cpqphp_sysfs.c2
-rw-r--r--drivers/pci/hotplug/fakephp.c18
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h4
-rw-r--r--drivers/pci/hotplug/pci_hotplug_core.c157
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c12
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c9
-rw-r--r--drivers/pci/hotplug/shpchp.h2
-rw-r--r--drivers/pci/hotplug/shpchp_core.c6
-rw-r--r--drivers/pci/hotplug/shpchp_sysfs.c4
-rw-r--r--drivers/pci/msi.c64
-rw-r--r--drivers/pci/pci-driver.c47
-rw-r--r--drivers/pci/pci-sysfs.c153
-rw-r--r--drivers/pci/pci.c59
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/pcie/Kconfig1
-rw-r--r--drivers/pci/pcie/Makefile3
-rw-r--r--drivers/pci/pcie/aer/Kconfig12
-rw-r--r--drivers/pci/pcie/aer/Makefile8
-rw-r--r--drivers/pci/pcie/aer/aerdrv.c346
-rw-r--r--drivers/pci/pcie/aer/aerdrv.h125
-rw-r--r--drivers/pci/pcie/aer/aerdrv_acpi.c68
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c758
-rw-r--r--drivers/pci/pcie/aer/aerdrv_errprint.c248
-rw-r--r--drivers/pci/pcie/portdrv.h2
-rw-r--r--drivers/pci/pcie/portdrv_bus.c1
-rw-r--r--drivers/pci/pcie/portdrv_core.c11
-rw-r--r--drivers/pci/pcie/portdrv_pci.c211
-rw-r--r--drivers/pci/probe.c16
-rw-r--r--drivers/pci/quirks.c104
-rw-r--r--drivers/pci/remove.c37
-rw-r--r--drivers/pci/setup-bus.c13
-rw-r--r--drivers/rtc/Kconfig10
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-sh.c467
-rw-r--r--drivers/scsi/aha1740.c1
-rw-r--r--drivers/scsi/aic7xxx/aic7770_osm.c3
-rw-r--r--drivers/scsi/mesh.c15
-rw-r--r--drivers/scsi/sim710.c1
-rw-r--r--drivers/serial/Kconfig9
-rw-r--r--drivers/serial/sh-sci.c1146
-rw-r--r--drivers/serial/sh-sci.h90
-rw-r--r--drivers/usb/Kconfig1
-rw-r--r--drivers/usb/Makefile12
-rw-r--r--drivers/usb/atm/ueagle-atm.c74
-rw-r--r--drivers/usb/class/usblp.c15
-rw-r--r--drivers/usb/core/Makefile2
-rw-r--r--drivers/usb/core/buffer.c4
-rw-r--r--drivers/usb/core/config.c4
-rw-r--r--drivers/usb/core/devices.c6
-rw-r--r--drivers/usb/core/devio.c68
-rw-r--r--drivers/usb/core/driver.c1011
-rw-r--r--drivers/usb/core/endpoint.c30
-rw-r--r--drivers/usb/core/file.c2
-rw-r--r--drivers/usb/core/generic.c208
-rw-r--r--drivers/usb/core/hcd-pci.c18
-rw-r--r--drivers/usb/core/hcd.c244
-rw-r--r--drivers/usb/core/hcd.h60
-rw-r--r--drivers/usb/core/hub.c555
-rw-r--r--drivers/usb/core/hub.h3
-rw-r--r--drivers/usb/core/inode.c13
-rw-r--r--drivers/usb/core/message.c148
-rw-r--r--drivers/usb/core/notify.c3
-rw-r--r--drivers/usb/core/sysfs.c60
-rw-r--r--drivers/usb/core/urb.c15
-rw-r--r--drivers/usb/core/usb.c533
-rw-r--r--drivers/usb/core/usb.h76
-rw-r--r--drivers/usb/gadget/Kconfig16
-rw-r--r--drivers/usb/gadget/Makefile2
-rw-r--r--drivers/usb/gadget/at91_udc.c2
-rw-r--r--drivers/usb/gadget/dummy_hcd.c8
-rw-r--r--drivers/usb/gadget/ether.c9
-rw-r--r--drivers/usb/gadget/gmidi.c1337
-rw-r--r--drivers/usb/gadget/inode.c67
-rw-r--r--drivers/usb/gadget/net2280.c156
-rw-r--r--drivers/usb/gadget/omap_udc.c4
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c70
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.h24
-rw-r--r--drivers/usb/gadget/serial.c3
-rw-r--r--drivers/usb/host/Kconfig29
-rw-r--r--drivers/usb/host/Makefile1
-rw-r--r--drivers/usb/host/ehci-au1xxx.c2
-rw-r--r--drivers/usb/host/ehci-dbg.c31
-rw-r--r--drivers/usb/host/ehci-fsl.c2
-rw-r--r--drivers/usb/host/ehci-hcd.c95
-rw-r--r--drivers/usb/host/ehci-hub.c14
-rw-r--r--drivers/usb/host/ehci-mem.c14
-rw-r--r--drivers/usb/host/ehci-pci.c10
-rw-r--r--drivers/usb/host/ehci-q.c26
-rw-r--r--drivers/usb/host/ehci-sched.c26
-rw-r--r--drivers/usb/host/ehci.h59
-rw-r--r--drivers/usb/host/isp116x-hcd.c4
-rw-r--r--drivers/usb/host/isp116x.h2
-rw-r--r--drivers/usb/host/ohci-at91.c7
-rw-r--r--drivers/usb/host/ohci-au1xxx.c7
-rw-r--r--drivers/usb/host/ohci-dbg.c18
-rw-r--r--drivers/usb/host/ohci-ep93xx.c3
-rw-r--r--drivers/usb/host/ohci-hcd.c64
-rw-r--r--drivers/usb/host/ohci-hub.c70
-rw-r--r--drivers/usb/host/ohci-lh7a404.c7
-rw-r--r--drivers/usb/host/ohci-mem.c1
-rw-r--r--drivers/usb/host/ohci-omap.c120
-rw-r--r--drivers/usb/host/ohci-pci.c13
-rw-r--r--drivers/usb/host/ohci-pnx4008.c476
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c3
-rw-r--r--drivers/usb/host/ohci-pxa27x.c3
-rw-r--r--drivers/usb/host/ohci-s3c2410.c5
-rw-r--r--drivers/usb/host/ohci-sa1111.c5
-rw-r--r--drivers/usb/host/ohci.h4
-rw-r--r--drivers/usb/host/sl811-hcd.c13
-rw-r--r--drivers/usb/host/u132-hcd.c3295
-rw-r--r--drivers/usb/host/uhci-debug.c6
-rw-r--r--drivers/usb/host/uhci-hcd.c12
-rw-r--r--drivers/usb/host/uhci-hub.c12
-rw-r--r--drivers/usb/image/mdc800.c4
-rw-r--r--drivers/usb/input/Kconfig30
-rw-r--r--drivers/usb/input/Makefile2
-rw-r--r--drivers/usb/input/acecad.c5
-rw-r--r--drivers/usb/input/appletouch.c5
-rw-r--r--drivers/usb/input/ati_remote.c8
-rw-r--r--drivers/usb/input/hid-core.c24
-rw-r--r--drivers/usb/input/hiddev.c2
-rw-r--r--drivers/usb/input/itmtouch.c2
-rw-r--r--drivers/usb/input/keyspan_remote.c3
-rw-r--r--drivers/usb/input/mtouchusb.c2
-rw-r--r--drivers/usb/input/powermate.c4
-rw-r--r--drivers/usb/input/touchkitusb.c2
-rw-r--r--drivers/usb/input/trancevibrator.c159
-rw-r--r--drivers/usb/input/usbmouse.c2
-rw-r--r--drivers/usb/input/usbtouchscreen.c285
-rw-r--r--drivers/usb/input/wacom.c1003
-rw-r--r--drivers/usb/input/wacom.h132
-rw-r--r--drivers/usb/input/wacom_sys.c315
-rw-r--r--drivers/usb/input/wacom_wac.c646
-rw-r--r--drivers/usb/input/wacom_wac.h48
-rw-r--r--drivers/usb/input/yealink.c2
-rw-r--r--drivers/usb/misc/Kconfig61
-rw-r--r--drivers/usb/misc/Makefile5
-rw-r--r--drivers/usb/misc/adutux.c900
-rw-r--r--drivers/usb/misc/auerswald.c6
-rw-r--r--drivers/usb/misc/cypress_cy7c63.c19
-rw-r--r--drivers/usb/misc/cytherm.c35
-rw-r--r--drivers/usb/misc/ftdi-elan.c2809
-rw-r--r--drivers/usb/misc/idmouse.c2
-rw-r--r--drivers/usb/misc/ldusb.c10
-rw-r--r--drivers/usb/misc/legousbtower.c2
-rw-r--r--drivers/usb/misc/phidget.c43
-rw-r--r--drivers/usb/misc/phidget.h12
-rw-r--r--drivers/usb/misc/phidgetkit.c316
-rw-r--r--drivers/usb/misc/phidgetmotorcontrol.c466
-rw-r--r--drivers/usb/misc/phidgetservo.c117
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c2
-rw-r--r--drivers/usb/misc/usb_u132.h97
-rw-r--r--drivers/usb/misc/usblcd.c10
-rw-r--r--drivers/usb/misc/usbled.c20
-rw-r--r--drivers/usb/mon/mon_main.c7
-rw-r--r--drivers/usb/mon/mon_stat.c4
-rw-r--r--drivers/usb/mon/mon_text.c19
-rw-r--r--drivers/usb/mon/usb_mon.h5
-rw-r--r--drivers/usb/net/asix.c1001
-rw-r--r--drivers/usb/net/net1080.c15
-rw-r--r--drivers/usb/net/pegasus.c2
-rw-r--r--drivers/usb/net/rtl8150.c2
-rw-r--r--drivers/usb/net/usbnet.c44
-rw-r--r--drivers/usb/net/usbnet.h1
-rw-r--r--drivers/usb/serial/Kconfig25
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/aircable.c625
-rw-r--r--drivers/usb/serial/airprime.c261
-rw-r--r--drivers/usb/serial/ark3116.c233
-rw-r--r--drivers/usb/serial/cypress_m8.c129
-rw-r--r--drivers/usb/serial/ftdi_sio.c30
-rw-r--r--drivers/usb/serial/garmin_gps.c219
-rw-r--r--drivers/usb/serial/ipaq.c38
-rw-r--r--drivers/usb/serial/mos7840.c2962
-rw-r--r--drivers/usb/serial/pl2303.c827
-rw-r--r--drivers/usb/serial/pl2303.h4
-rw-r--r--drivers/usb/serial/usb-serial.c28
-rw-r--r--drivers/usb/storage/Kconfig12
-rw-r--r--drivers/usb/storage/Makefile1
-rw-r--r--drivers/usb/storage/initializers.c73
-rw-r--r--drivers/usb/storage/initializers.h1
-rw-r--r--drivers/usb/storage/karma.c155
-rw-r--r--drivers/usb/storage/karma.h7
-rw-r--r--drivers/usb/storage/libusual.c10
-rw-r--r--drivers/usb/storage/onetouch.c8
-rw-r--r--drivers/usb/storage/scsiglue.c15
-rw-r--r--drivers/usb/storage/transport.c5
-rw-r--r--drivers/usb/storage/unusual_devs.h18
-rw-r--r--drivers/usb/storage/usb.c11
-rw-r--r--drivers/usb/usb-skeleton.c101
-rw-r--r--drivers/video/aty/radeon_pm.c15
-rw-r--r--drivers/video/backlight/hp680_bl.c4
-rw-r--r--drivers/video/console/Kconfig2
-rw-r--r--drivers/video/hitfb.c229
-rw-r--r--drivers/video/i810/i810-i2c.c1
-rw-r--r--drivers/video/i810/i810_main.c12
-rw-r--r--drivers/video/matrox/i2c-matroxfb.c12
-rw-r--r--drivers/video/nvidia/nvidia.c13
-rw-r--r--drivers/video/pvr2fb.c22
-rw-r--r--drivers/video/savage/savagefb-i2c.c1
-rw-r--r--drivers/video/savage/savagefb_driver.c14
-rw-r--r--fs/9p/vfs_inode.c4
-rw-r--r--fs/Kconfig19
-rw-r--r--fs/adfs/inode.c1
-rw-r--r--fs/adfs/super.c6
-rw-r--r--fs/affs/super.c6
-rw-r--r--fs/afs/inode.c1
-rw-r--r--fs/afs/vlocation.c3
-rw-r--r--fs/afs/volume.c3
-rw-r--r--fs/autofs/inode.c6
-rw-r--r--fs/autofs/symlink.c2
-rw-r--r--fs/autofs4/inode.c1
-rw-r--r--fs/autofs4/root.c38
-rw-r--r--fs/befs/linuxvfs.c5
-rw-r--r--fs/bfs/dir.c2
-rw-r--r--fs/bfs/inode.c10
-rw-r--r--fs/binfmt_elf.c3
-rw-r--r--fs/binfmt_misc.c9
-rw-r--r--fs/char_dev.c20
-rw-r--r--fs/cifs/cifsfs.c21
-rw-r--r--fs/cifs/readdir.c5
-rw-r--r--fs/coda/coda_linux.c2
-rw-r--r--fs/coda/dir.c2
-rw-r--r--fs/coda/inode.c3
-rw-r--r--fs/compat.c5
-rw-r--r--fs/configfs/file.c3
-rw-r--r--fs/configfs/inode.c4
-rw-r--r--fs/cramfs/inode.c4
-rw-r--r--fs/debugfs/file.c60
-rw-r--r--fs/debugfs/inode.c20
-rw-r--r--fs/devpts/inode.c6
-rw-r--r--fs/efs/super.c6
-rw-r--r--fs/eventpoll.c1
-rw-r--r--fs/exec.c53
-rw-r--r--fs/ext2/acl.c4
-rw-r--r--fs/ext2/ialloc.c1
-rw-r--r--fs/ext2/inode.c1
-rw-r--r--fs/ext2/super.c38
-rw-r--r--fs/ext2/xattr.c3
-rw-r--r--fs/ext3/acl.c6
-rw-r--r--fs/ext3/balloc.c350
-rw-r--r--fs/ext3/bitmap.c2
-rw-r--r--fs/ext3/dir.c19
-rw-r--r--fs/ext3/file.c2
-rw-r--r--fs/ext3/fsync.c6
-rw-r--r--fs/ext3/hash.c8
-rw-r--r--fs/ext3/ialloc.c55
-rw-r--r--fs/ext3/inode.c77
-rw-r--r--fs/ext3/namei.c50
-rw-r--r--fs/ext3/resize.c42
-rw-r--r--fs/ext3/super.c110
-rw-r--r--fs/ext3/xattr.c16
-rw-r--r--fs/fat/cache.c3
-rw-r--r--fs/fat/inode.c38
-rw-r--r--fs/file.c6
-rw-r--r--fs/file_table.c2
-rw-r--r--fs/freevxfs/vxfs.h2
-rw-r--r--fs/freevxfs/vxfs_inode.c5
-rw-r--r--fs/fuse/control.c6
-rw-r--r--fs/fuse/inode.c1
-rw-r--r--fs/hfs/bnode.c3
-rw-r--r--fs/hfs/btree.c3
-rw-r--r--fs/hfs/inode.c2
-rw-r--r--fs/hfs/super.c6
-rw-r--r--fs/hfsplus/bnode.c3
-rw-r--r--fs/hfsplus/btree.c3
-rw-r--r--fs/hfsplus/inode.c2
-rw-r--r--fs/hfsplus/super.c3
-rw-r--r--fs/hostfs/hostfs_kern.c1
-rw-r--r--fs/hpfs/buffer.c2
-rw-r--r--fs/hpfs/inode.c1
-rw-r--r--fs/hpfs/super.c6
-rw-r--r--fs/hppfs/hppfs_kern.c1
-rw-r--r--fs/hugetlbfs/inode.c1
-rw-r--r--fs/inode.c6
-rw-r--r--fs/isofs/inode.c10
-rw-r--r--fs/jbd/checkpoint.c33
-rw-r--r--fs/jbd/journal.c74
-rw-r--r--fs/jbd/recovery.c56
-rw-r--r--fs/jbd/revoke.c70
-rw-r--r--fs/jbd/transaction.c134
-rw-r--r--fs/jffs/inode-v23.c44
-rw-r--r--fs/jffs/intrep.c11
-rw-r--r--fs/jffs/jffs_fm.c6
-rw-r--r--fs/jffs2/fs.c2
-rw-r--r--fs/jffs2/super.c3
-rw-r--r--fs/jfs/jfs_extent.c2
-rw-r--r--fs/jfs/jfs_imap.c1
-rw-r--r--fs/jfs/jfs_inode.c1
-rw-r--r--fs/jfs/jfs_metapage.c2
-rw-r--r--fs/jfs/jfs_txnmgr.c4
-rw-r--r--fs/libfs.c4
-rw-r--r--fs/lockd/clntlock.c2
-rw-r--r--fs/lockd/clntproc.c2
-rw-r--r--fs/lockd/host.c4
-rw-r--r--fs/lockd/svcsubs.c3
-rw-r--r--fs/minix/bitmap.c2
-rw-r--r--fs/minix/inode.c13
-rw-r--r--fs/namei.c50
-rw-r--r--fs/namespace.c10
-rw-r--r--fs/ncpfs/inode.c7
-rw-r--r--fs/ncpfs/symlink.c4
-rw-r--r--fs/nfs/delegation.c7
-rw-r--r--fs/nfs/direct.c3
-rw-r--r--fs/nfs/inode.c9
-rw-r--r--fs/nfs/namespace.c12
-rw-r--r--fs/nfs/nfs3proc.c2
-rw-r--r--fs/nfs/pagelist.c3
-rw-r--r--fs/nfs/proc.c2
-rw-r--r--fs/nfs/read.c3
-rw-r--r--fs/nfs/write.c3
-rw-r--r--fs/nfsd/nfs4idmap.c3
-rw-r--r--fs/nfsd/nfs4state.c8
-rw-r--r--fs/ntfs/dir.c5
-rw-r--r--fs/ntfs/inode.c6
-rw-r--r--fs/ntfs/mft.c9
-rw-r--r--fs/ntfs/super.c28
-rw-r--r--fs/ntfs/unistr.c4
-rw-r--r--fs/ocfs2/dlm/dlmfs.c6
-rw-r--r--fs/ocfs2/dlmglue.c2
-rw-r--r--fs/ocfs2/inode.c4
-rw-r--r--fs/partitions/efi.c9
-rw-r--r--fs/pipe.c1
-rw-r--r--fs/proc/internal.h1
-rw-r--r--fs/proc/kcore.c6
-rw-r--r--fs/proc/nommu.c20
-rw-r--r--fs/proc/task_mmu.c5
-rw-r--r--fs/proc/task_nommu.c74
-rw-r--r--fs/qnx4/inode.c8
-rw-r--r--fs/ramfs/inode.c1
-rw-r--r--fs/reiserfs/inode.c4
-rw-r--r--fs/reiserfs/super.c25
-rw-r--r--fs/romfs/inode.c3
-rw-r--r--fs/smbfs/inode.c5
-rw-r--r--fs/smbfs/proc.c1
-rw-r--r--fs/smbfs/request.c3
-rw-r--r--fs/stat.c3
-rw-r--r--fs/sysfs/bin.c13
-rw-r--r--fs/sysfs/dir.c2
-rw-r--r--fs/sysfs/inode.c12
-rw-r--r--fs/sysfs/symlink.c14
-rw-r--r--fs/sysfs/sysfs.h2
-rw-r--r--fs/sysv/ialloc.c2
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/sysv/super.c6
-rw-r--r--fs/udf/ialloc.c7
-rw-r--r--fs/udf/inode.c2
-rw-r--r--fs/udf/super.c3
-rw-r--r--fs/ufs/ialloc.c1
-rw-r--r--fs/ufs/inode.c1
-rw-r--r--fs/ufs/super.c6
-rw-r--r--fs/xfs/linux-2.6/kmem.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c4
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c1
-rw-r--r--include/asm-arm/arch-pxa/udc.h8
-rw-r--r--include/asm-arm/unistd.h3
-rw-r--r--include/asm-arm26/unistd.h3
-rw-r--r--include/asm-frv/unistd.h3
-rw-r--r--include/asm-generic/vmlinux.lds.h6
-rw-r--r--include/asm-h8300/unistd.h6
-rw-r--r--include/asm-i386/acpi.h14
-rw-r--r--include/asm-i386/alternative-asm.i14
-rw-r--r--include/asm-i386/apic.h16
-rw-r--r--include/asm-i386/desc.h121
-rw-r--r--include/asm-i386/dwarf2.h11
-rw-r--r--include/asm-i386/e820.h2
-rw-r--r--include/asm-i386/frame.i24
-rw-r--r--include/asm-i386/genapic.h69
-rw-r--r--include/asm-i386/intel_arch_perfmon.h14
-rw-r--r--include/asm-i386/io_apic.h11
-rw-r--r--include/asm-i386/kexec.h27
-rw-r--r--include/asm-i386/mach-es7000/mach_apic.h4
-rw-r--r--include/asm-i386/mach-summit/mach_apic.h11
-rw-r--r--include/asm-i386/mutex.h16
-rw-r--r--include/asm-i386/nmi.h37
-rw-r--r--include/asm-i386/pgtable.h2
-rw-r--r--include/asm-i386/ptrace.h9
-rw-r--r--include/asm-i386/rwlock.h48
-rw-r--r--include/asm-i386/rwsem.h62
-rw-r--r--include/asm-i386/segment.h17
-rw-r--r--include/asm-i386/semaphore.h53
-rw-r--r--include/asm-i386/smp.h20
-rw-r--r--include/asm-i386/spinlock.h134
-rw-r--r--include/asm-i386/stacktrace.h1
-rw-r--r--include/asm-i386/therm_throt.h9
-rw-r--r--include/asm-i386/tlbflush.h4
-rw-r--r--include/asm-i386/tsc.h1
-rw-r--r--include/asm-i386/unistd.h8
-rw-r--r--include/asm-i386/unwind.h8
-rw-r--r--include/asm-ia64/esi.h30
-rw-r--r--include/asm-ia64/futex.h122
-rw-r--r--include/asm-ia64/kprobes.h9
-rw-r--r--include/asm-ia64/mca_asm.h2
-rw-r--r--include/asm-ia64/meminit.h1
-rw-r--r--include/asm-ia64/module.h3
-rw-r--r--include/asm-ia64/numa.h2
-rw-r--r--include/asm-ia64/pal.h16
-rw-r--r--include/asm-ia64/processor.h13
-rw-r--r--include/asm-ia64/smp.h1
-rw-r--r--include/asm-ia64/unistd.h3
-rw-r--r--include/asm-m32r/spinlock.h9
-rw-r--r--include/asm-m32r/system.h4
-rw-r--r--include/asm-m32r/unistd.h5
-rw-r--r--include/asm-m68k/unistd.h5
-rw-r--r--include/asm-m68knommu/unistd.h5
-rw-r--r--include/asm-mips/Kbuild2
-rw-r--r--include/asm-mips/bootinfo.h3
-rw-r--r--include/asm-mips/cacheflush.h12
-rw-r--r--include/asm-mips/fcntl.h2
-rw-r--r--include/asm-mips/galileo-boards/gt96100.h427
-rw-r--r--include/asm-mips/hazards.h360
-rw-r--r--include/asm-mips/irq.h4
-rw-r--r--include/asm-mips/mach-atlas/mc146818rtc.h4
-rw-r--r--include/asm-mips/mach-ev96100/mach-gt64120.h46
-rw-r--r--include/asm-mips/mach-excite/excite.h2
-rw-r--r--include/asm-mips/mach-excite/excite_fpga.h (renamed from arch/mips/basler/excite/excite_fpga.h)0
-rw-r--r--include/asm-mips/mach-qemu/cpu-feature-overrides.h2
-rw-r--r--include/asm-mips/mips-boards/atlasint.h124
-rw-r--r--include/asm-mips/mmu_context.h8
-rw-r--r--include/asm-mips/page.h11
-rw-r--r--include/asm-mips/pgtable-64.h6
-rw-r--r--include/asm-mips/ptrace.h3
-rw-r--r--include/asm-mips/serial.h4
-rw-r--r--include/asm-mips/sibyte/sb1250_defs.h6
-rw-r--r--include/asm-mips/sibyte/sb1250_scd.h2
-rw-r--r--include/asm-mips/signal.h11
-rw-r--r--include/asm-mips/spinlock.h47
-rw-r--r--include/asm-mips/timex.h4
-rw-r--r--include/asm-mips/unistd.h24
-rw-r--r--include/asm-mips/user.h4
-rw-r--r--include/asm-s390/unistd.h4
-rw-r--r--include/asm-sh/addrspace.h8
-rw-r--r--include/asm-sh/adx/io.h86
-rw-r--r--include/asm-sh/apm.h46
-rw-r--r--include/asm-sh/atomic.h106
-rw-r--r--include/asm-sh/auxvec.h14
-rw-r--r--include/asm-sh/bitops.h16
-rw-r--r--include/asm-sh/bugs.h4
-rw-r--r--include/asm-sh/cache.h30
-rw-r--r--include/asm-sh/cacheflush.h3
-rw-r--r--include/asm-sh/cat68701/io.h22
-rw-r--r--include/asm-sh/checksum.h2
-rw-r--r--include/asm-sh/cpu-features.h24
-rw-r--r--include/asm-sh/cpu-sh2/shmparam.h16
-rw-r--r--include/asm-sh/cpu-sh3/cache.h4
-rw-r--r--include/asm-sh/cpu-sh3/cacheflush.h52
-rw-r--r--include/asm-sh/cpu-sh3/freq.h4
-rw-r--r--include/asm-sh/cpu-sh3/mmu_context.h8
-rw-r--r--include/asm-sh/cpu-sh3/shmparam.h16
-rw-r--r--include/asm-sh/cpu-sh3/timer.h8
-rw-r--r--include/asm-sh/cpu-sh3/ubc.h15
-rw-r--r--include/asm-sh/cpu-sh4/addrspace.h3
-rw-r--r--include/asm-sh/cpu-sh4/cache.h2
-rw-r--r--include/asm-sh/cpu-sh4/cacheflush.h36
-rw-r--r--include/asm-sh/cpu-sh4/dma-sh7780.h39
-rw-r--r--include/asm-sh/cpu-sh4/dma.h11
-rw-r--r--include/asm-sh/cpu-sh4/shmparam.h19
-rw-r--r--include/asm-sh/cpu-sh4/sq.h23
-rw-r--r--include/asm-sh/cqreek/cqreek.h27
-rw-r--r--include/asm-sh/dma-mapping.h42
-rw-r--r--include/asm-sh/dma.h1
-rw-r--r--include/asm-sh/dmida/io.h10
-rw-r--r--include/asm-sh/elf.h30
-rw-r--r--include/asm-sh/fixmap.h2
-rw-r--r--include/asm-sh/flat.h2
-rw-r--r--include/asm-sh/harp/harp.h43
-rw-r--r--include/asm-sh/harp/io.h10
-rw-r--r--include/asm-sh/hd64461.h (renamed from include/asm-sh/hd64461/hd64461.h)56
-rw-r--r--include/asm-sh/hd64461/io.h43
-rw-r--r--include/asm-sh/hp6xx/hp6xx.h53
-rw-r--r--include/asm-sh/hp6xx/io.h2
-rw-r--r--include/asm-sh/hs7751rvoip/hs7751rvoip.h11
-rw-r--r--include/asm-sh/io.h16
-rw-r--r--include/asm-sh/irq-sh73180.h2
-rw-r--r--include/asm-sh/irq-sh7343.h317
-rw-r--r--include/asm-sh/irq-sh7780.h5
-rw-r--r--include/asm-sh/irq.h137
-rw-r--r--include/asm-sh/kexec.h9
-rw-r--r--include/asm-sh/kgdb.h15
-rw-r--r--include/asm-sh/landisk/gio.h45
-rw-r--r--include/asm-sh/landisk/ide.h14
-rw-r--r--include/asm-sh/landisk/iodata_landisk.h79
-rw-r--r--include/asm-sh/machvec.h7
-rw-r--r--include/asm-sh/mc146818rtc.h169
-rw-r--r--include/asm-sh/mmu.h77
-rw-r--r--include/asm-sh/mmu_context.h15
-rw-r--r--include/asm-sh/overdrive/fpga.h15
-rw-r--r--include/asm-sh/overdrive/gt64111.h109
-rw-r--r--include/asm-sh/overdrive/io.h39
-rw-r--r--include/asm-sh/overdrive/overdrive.h88
-rw-r--r--include/asm-sh/page.h33
-rw-r--r--include/asm-sh/pci.h44
-rw-r--r--include/asm-sh/pgalloc.h37
-rw-r--r--include/asm-sh/pgtable.h154
-rw-r--r--include/asm-sh/pm.h17
-rw-r--r--include/asm-sh/processor.h52
-rw-r--r--include/asm-sh/r7780rp/ide.h8
-rw-r--r--include/asm-sh/r7780rp/r7780rp.h177
-rw-r--r--include/asm-sh/rtc.h25
-rw-r--r--include/asm-sh/rts7751r2d/rts7751r2d.h2
-rw-r--r--include/asm-sh/scatterlist.h9
-rw-r--r--include/asm-sh/sci.h34
-rw-r--r--include/asm-sh/se.h (renamed from include/asm-sh/se/se.h)3
-rw-r--r--include/asm-sh/se/io.h35
-rw-r--r--include/asm-sh/se7300.h (renamed from include/asm-sh/se7300/se7300.h)3
-rw-r--r--include/asm-sh/se7300/io.h29
-rw-r--r--include/asm-sh/se73180.h (renamed from include/asm-sh/se73180/se73180.h)3
-rw-r--r--include/asm-sh/se73180/io.h32
-rw-r--r--include/asm-sh/se7343.h82
-rw-r--r--include/asm-sh/se7751.h (renamed from include/asm-sh/se7751/se7751.h)3
-rw-r--r--include/asm-sh/se7751/io.h42
-rw-r--r--include/asm-sh/setup.h2
-rw-r--r--include/asm-sh/sfp-machine.h86
-rw-r--r--include/asm-sh/sh03/io.h10
-rw-r--r--include/asm-sh/sh2000/sh2000.h8
-rw-r--r--include/asm-sh/shmin/shmin.h9
-rw-r--r--include/asm-sh/shmparam.h20
-rw-r--r--include/asm-sh/smc37c93x.h (renamed from include/asm-sh/se/smc37c93x.h)0
-rw-r--r--include/asm-sh/smp.h5
-rw-r--r--include/asm-sh/snapgear.h (renamed from include/asm-sh/snapgear/io.h)31
-rw-r--r--include/asm-sh/system.h199
-rw-r--r--include/asm-sh/systemh/io.h43
-rw-r--r--include/asm-sh/systemh7751.h (renamed from include/asm-sh/systemh/7751systemh.h)3
-rw-r--r--include/asm-sh/thread_info.h43
-rw-r--r--include/asm-sh/timer.h2
-rw-r--r--include/asm-sh/titan.h43
-rw-r--r--include/asm-sh/uaccess.h79
-rw-r--r--include/asm-sh/unistd.h51
-rw-r--r--include/asm-sh/voyagergx.h (renamed from include/asm-sh/rts7751r2d/voyagergx_reg.h)2
-rw-r--r--include/asm-sh/watchdog.h3
-rw-r--r--include/asm-sh64/unistd.h6
-rw-r--r--include/asm-um/alternative-asm.i6
-rw-r--r--include/asm-um/frame.i6
-rw-r--r--include/asm-um/processor-generic.h6
-rw-r--r--include/asm-um/ptrace-x86_64.h3
-rw-r--r--include/asm-v850/unistd.h5
-rw-r--r--include/asm-x86_64/acpi.h2
-rw-r--r--include/asm-x86_64/alternative-asm.i14
-rw-r--r--include/asm-x86_64/apic.h9
-rw-r--r--include/asm-x86_64/bitops.h2
-rw-r--r--include/asm-x86_64/calgary.h7
-rw-r--r--include/asm-x86_64/dwarf2.h8
-rw-r--r--include/asm-x86_64/e820.h14
-rw-r--r--include/asm-x86_64/fixmap.h4
-rw-r--r--include/asm-x86_64/genapic.h1
-rw-r--r--include/asm-x86_64/i387.h9
-rw-r--r--include/asm-x86_64/intel_arch_perfmon.h14
-rw-r--r--include/asm-x86_64/io_apic.h6
-rw-r--r--include/asm-x86_64/irq.h2
-rw-r--r--include/asm-x86_64/kexec.h29
-rw-r--r--include/asm-x86_64/linkage.h2
-rw-r--r--include/asm-x86_64/mach_apic.h1
-rw-r--r--include/asm-x86_64/mce.h2
-rw-r--r--include/asm-x86_64/mmx.h14
-rw-r--r--include/asm-x86_64/mpspec.h11
-rw-r--r--include/asm-x86_64/msr.h11
-rw-r--r--include/asm-x86_64/mutex.h20
-rw-r--r--include/asm-x86_64/nmi.h38
-rw-r--r--include/asm-x86_64/pci-direct.h42
-rw-r--r--include/asm-x86_64/pda.h109
-rw-r--r--include/asm-x86_64/percpu.h10
-rw-r--r--include/asm-x86_64/pgtable.h8
-rw-r--r--include/asm-x86_64/proto.h17
-rw-r--r--include/asm-x86_64/rwlock.h64
-rw-r--r--include/asm-x86_64/segment.h5
-rw-r--r--include/asm-x86_64/semaphore.h40
-rw-r--r--include/asm-x86_64/signal.h4
-rw-r--r--include/asm-x86_64/smp.h29
-rw-r--r--include/asm-x86_64/spinlock.h80
-rw-r--r--include/asm-x86_64/stacktrace.h18
-rw-r--r--include/asm-x86_64/system.h5
-rw-r--r--include/asm-x86_64/tce.h1
-rw-r--r--include/asm-x86_64/therm_throt.h1
-rw-r--r--include/asm-x86_64/thread_info.h9
-rw-r--r--include/asm-x86_64/tlbflush.h70
-rw-r--r--include/asm-x86_64/uaccess.h68
-rw-r--r--include/asm-x86_64/unistd.h10
-rw-r--r--include/asm-x86_64/unwind.h9
-rw-r--r--include/asm-x86_64/vsyscall.h9
-rw-r--r--include/linux/aer.h24
-rw-r--r--include/linux/cdev.h2
-rw-r--r--include/linux/compiler.h5
-rw-r--r--include/linux/device.h99
-rw-r--r--include/linux/edd.h1
-rw-r--r--include/linux/eisa.h8
-rw-r--r--include/linux/err.h4
-rw-r--r--include/linux/ext3_fs.h4
-rw-r--r--include/linux/ext3_fs_i.h2
-rw-r--r--include/linux/ext3_jbd.h10
-rw-r--r--include/linux/fs.h14
-rw-r--r--include/linux/getcpu.h16
-rw-r--r--include/linux/gfp.h5
-rw-r--r--include/linux/hdlc.h201
-rw-r--r--include/linux/hdlc/ioctl.h33
-rw-r--r--include/linux/i2c-algo-bit.h1
-rw-r--r--include/linux/i2c-algo-pcf.h1
-rw-r--r--include/linux/i2c-algo-sibyte.h33
-rw-r--r--include/linux/i2c.h14
-rw-r--r--include/linux/if.h2
-rw-r--r--include/linux/init.h1
-rw-r--r--include/linux/jbd.h70
-rw-r--r--include/linux/jiffies.h15
-rw-r--r--include/linux/kernel.h8
-rw-r--r--include/linux/kobject.h16
-rw-r--r--include/linux/linkage.h6
-rw-r--r--include/linux/mm.h127
-rw-r--r--include/linux/mm_types.h67
-rw-r--r--include/linux/mmzone.h17
-rw-r--r--include/linux/mod_devicetable.h12
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/linux/nfs_fs.h4
-rw-r--r--include/linux/nfsd/nfsfh.h10
-rw-r--r--include/linux/pci.h41
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/pci_regs.h2
-rw-r--r--include/linux/pcieport_if.h6
-rw-r--r--include/linux/pid.h2
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pm.h63
-rw-r--r--include/linux/proc_fs.h2
-rw-r--r--include/linux/sched.h14
-rw-r--r--include/linux/slab.h4
-rw-r--r--include/linux/smb.h1
-rw-r--r--include/linux/stacktrace.h7
-rw-r--r--include/linux/syscalls.h2
-rw-r--r--include/linux/sysctl.h2
-rw-r--r--include/linux/sysfs.h28
-rw-r--r--include/linux/uaccess.h22
-rw-r--r--include/linux/usb.h156
-rw-r--r--include/linux/usb/audio.h53
-rw-r--r--include/linux/usb/midi.h112
-rw-r--r--include/linux/usb/otg.h (renamed from include/linux/usb_otg.h)4
-rw-r--r--include/linux/usb_usual.h3
-rw-r--r--include/linux/vermagic.h4
-rw-r--r--include/linux/vmalloc.h1
-rw-r--r--include/linux/wireless.h24
-rw-r--r--include/media/v4l2-dev.h2
-rw-r--r--init/Kconfig31
-rw-r--r--init/do_mounts.c5
-rw-r--r--init/main.c34
-rw-r--r--ipc/mqueue.c6
-rw-r--r--kernel/cpuset.c1
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/lockdep.c9
-rw-r--r--kernel/panic.c13
-rw-r--r--kernel/pid.c12
-rw-r--r--kernel/power/Kconfig11
-rw-r--r--kernel/power/disk.c4
-rw-r--r--kernel/power/swsusp.c9
-rw-r--r--kernel/power/user.c2
-rw-r--r--kernel/ptrace.c54
-rw-r--r--kernel/relay.c2
-rw-r--r--kernel/resource.c32
-rw-r--r--kernel/signal.c5
-rw-r--r--kernel/spinlock.c5
-rw-r--r--kernel/sys.c31
-rw-r--r--kernel/sysctl.c136
-rw-r--r--kernel/unwind.c35
-rw-r--r--lib/Kconfig.debug13
-rw-r--r--lib/hweight.c10
-rw-r--r--lib/klist.c26
-rw-r--r--lib/kobject.c9
-rw-r--r--mm/memory.c117
-rw-r--r--mm/mempolicy.c4
-rw-r--r--mm/nommu.c245
-rw-r--r--mm/page_alloc.c749
-rw-r--r--mm/shmem.c4
-rw-r--r--mm/slab.c126
-rw-r--r--mm/slob.c3
-rw-r--r--mm/truncate.c25
-rw-r--r--mm/vmalloc.c30
-rw-r--r--mm/vmscan.c30
-rw-r--r--mm/vmstat.c3
-rw-r--r--net/core/net-sysfs.c5
-rw-r--r--net/core/wireless.c67
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c8
-rw-r--r--net/sunrpc/rpc_pipe.c4
-rw-r--r--net/sunrpc/sched.c8
-rw-r--r--scripts/Kbuild.include7
-rw-r--r--scripts/gcc-x86_64-has-stack-protector.sh6
-rw-r--r--scripts/mod/file2alias.c12
-rw-r--r--security/inode.c9
-rw-r--r--security/selinux/selinuxfs.c1
-rw-r--r--sound/oss/sh_dac_audio.c60
-rw-r--r--sound/usb/usbmidi.c6
1466 files changed, 61664 insertions, 27190 deletions
diff --git a/Documentation/ABI/obsolete/devfs b/Documentation/ABI/removed/devfs
index b8b87399bc8f..8195c4e0d0a1 100644
--- a/Documentation/ABI/obsolete/devfs
+++ b/Documentation/ABI/removed/devfs
@@ -1,13 +1,12 @@
1What: devfs 1What: devfs
2Date: July 2005 2Date: July 2005 (scheduled), finally removed in kernel v2.6.18
3Contact: Greg Kroah-Hartman <gregkh@suse.de> 3Contact: Greg Kroah-Hartman <gregkh@suse.de>
4Description: 4Description:
5 devfs has been unmaintained for a number of years, has unfixable 5 devfs has been unmaintained for a number of years, has unfixable
6 races, contains a naming policy within the kernel that is 6 races, contains a naming policy within the kernel that is
7 against the LSB, and can be replaced by using udev. 7 against the LSB, and can be replaced by using udev.
8 The files fs/devfs/*, include/linux/devfs_fs*.h will be removed, 8 The files fs/devfs/*, include/linux/devfs_fs*.h were removed,
9 along with the the assorted devfs function calls throughout the 9 along with the the assorted devfs function calls throughout the
10 kernel tree. 10 kernel tree.
11 11
12Users: 12Users:
13
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
new file mode 100644
index 000000000000..d882f8093871
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-power
@@ -0,0 +1,88 @@
1What: /sys/power/
2Date: August 2006
3Contact: Rafael J. Wysocki <rjw@sisk.pl>
4Description:
5 The /sys/power directory will contain files that will
6 provide a unified interface to the power management
7 subsystem.
8
9What: /sys/power/state
10Date: August 2006
11Contact: Rafael J. Wysocki <rjw@sisk.pl>
12Description:
13 The /sys/power/state file controls the system power state.
14 Reading from this file returns what states are supported,
15 which is hard-coded to 'standby' (Power-On Suspend), 'mem'
16 (Suspend-to-RAM), and 'disk' (Suspend-to-Disk).
17
18 Writing to this file one of these strings causes the system to
19 transition into that state. Please see the file
20 Documentation/power/states.txt for a description of each of
21 these states.
22
23What: /sys/power/disk
24Date: August 2006
25Contact: Rafael J. Wysocki <rjw@sisk.pl>
26Description:
27 The /sys/power/disk file controls the operating mode of the
28 suspend-to-disk mechanism. Reading from this file returns
29 the name of the method by which the system will be put to
30 sleep on the next suspend. There are four methods supported:
31 'firmware' - means that the memory image will be saved to disk
32 by some firmware, in which case we also assume that the
33 firmware will handle the system suspend.
34 'platform' - the memory image will be saved by the kernel and
35 the system will be put to sleep by the platform driver (e.g.
36 ACPI or other PM registers).
37 'shutdown' - the memory image will be saved by the kernel and
38 the system will be powered off.
39 'reboot' - the memory image will be saved by the kernel and
40 the system will be rebooted.
41
42 The suspend-to-disk method may be chosen by writing to this
43 file one of the accepted strings:
44
45 'firmware'
46 'platform'
47 'shutdown'
48 'reboot'
49
50 It will only change to 'firmware' or 'platform' if the system
51 supports that.
52
53What: /sys/power/image_size
54Date: August 2006
55Contact: Rafael J. Wysocki <rjw@sisk.pl>
56Description:
57 The /sys/power/image_size file controls the size of the image
58 created by the suspend-to-disk mechanism. It can be written a
59 string representing a non-negative integer that will be used
60 as an upper limit of the image size, in bytes. The kernel's
61 suspend-to-disk code will do its best to ensure the image size
62 will not exceed this number. However, if it turns out to be
63 impossible, the kernel will try to suspend anyway using the
64 smallest image possible. In particular, if "0" is written to
65 this file, the suspend image will be as small as possible.
66
67 Reading from this file will display the current image size
68 limit, which is set to 500 MB by default.
69
70What: /sys/power/pm_trace
71Date: August 2006
72Contact: Rafael J. Wysocki <rjw@sisk.pl>
73Description:
74 The /sys/power/pm_trace file controls the code which saves the
75 last PM event point in the RTC across reboots, so that you can
76 debug a machine that just hangs during suspend (or more
77 commonly, during resume). Namely, the RTC is only used to save
78 the last PM event point if this file contains '1'. Initially
79 it contains '0' which may be changed to '1' by writing a
80 string representing a nonzero integer into it.
81
82 To use this debugging feature you should attempt to suspend
83 the machine, then reboot it and run
84
85 dmesg -s 1000000 | grep 'hash matches'
86
87 CAUTION: Using it will cause your machine's real-time (CMOS)
88 clock to be set to a random invalid time after a resume.
diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl
index 320af25de3a2..3608472d7b74 100644
--- a/Documentation/DocBook/usb.tmpl
+++ b/Documentation/DocBook/usb.tmpl
@@ -43,59 +43,52 @@
43 43
44 <para>A Universal Serial Bus (USB) is used to connect a host, 44 <para>A Universal Serial Bus (USB) is used to connect a host,
45 such as a PC or workstation, to a number of peripheral 45 such as a PC or workstation, to a number of peripheral
46 devices. USB uses a tree structure, with the host at the 46 devices. USB uses a tree structure, with the host as the
47 root (the system's master), hubs as interior nodes, and 47 root (the system's master), hubs as interior nodes, and
48 peripheral devices as leaves (and slaves). 48 peripherals as leaves (and slaves).
49 Modern PCs support several such trees of USB devices, usually 49 Modern PCs support several such trees of USB devices, usually
50 one USB 2.0 tree (480 Mbit/sec each) with 50 one USB 2.0 tree (480 Mbit/sec each) with
51 a few USB 1.1 trees (12 Mbit/sec each) that are used when you 51 a few USB 1.1 trees (12 Mbit/sec each) that are used when you
52 connect a USB 1.1 device directly to the machine's "root hub". 52 connect a USB 1.1 device directly to the machine's "root hub".
53 </para> 53 </para>
54 54
55 <para>That master/slave asymmetry was designed in part for 55 <para>That master/slave asymmetry was designed-in for a number of
56 ease of use. It is not physically possible to assemble 56 reasons, one being ease of use. It is not physically possible to
57 (legal) USB cables incorrectly: all upstream "to-the-host" 57 assemble (legal) USB cables incorrectly: all upstream "to the host"
58 connectors are the rectangular type, matching the sockets on 58 connectors are the rectangular type (matching the sockets on
59 root hubs, and the downstream type are the squarish type 59 root hubs), and all downstream connectors are the squarish type
60 (or they are built in to the peripheral). 60 (or they are built into the peripheral).
61 Software doesn't need to deal with distributed autoconfiguration 61 Also, the host software doesn't need to deal with distributed
62 since the pre-designated master node manages all that. 62 auto-configuration since the pre-designated master node manages all that.
63 At the electrical level, bus protocol overhead is reduced by 63 And finally, at the electrical level, bus protocol overhead is reduced by
64 eliminating arbitration and moving scheduling into host software. 64 eliminating arbitration and moving scheduling into the host software.
65 </para> 65 </para>
66 66
67 <para>USB 1.0 was announced in January 1996, and was revised 67 <para>USB 1.0 was announced in January 1996 and was revised
68 as USB 1.1 (with improvements in hub specification and 68 as USB 1.1 (with improvements in hub specification and
69 support for interrupt-out transfers) in September 1998. 69 support for interrupt-out transfers) in September 1998.
70 USB 2.0 was released in April 2000, including high speed 70 USB 2.0 was released in April 2000, adding high-speed
71 transfers and transaction translating hubs (used for USB 1.1 71 transfers and transaction-translating hubs (used for USB 1.1
72 and 1.0 backward compatibility). 72 and 1.0 backward compatibility).
73 </para> 73 </para>
74 74
75 <para>USB support was added to Linux early in the 2.2 kernel series 75 <para>Kernel developers added USB support to Linux early in the 2.2 kernel
76 shortly before the 2.3 development forked off. Updates 76 series, shortly before 2.3 development forked. Updates from 2.3 were
77 from 2.3 were regularly folded back into 2.2 releases, bringing 77 regularly folded back into 2.2 releases, which improved reliability and
78 new features such as <filename>/sbin/hotplug</filename> support, 78 brought <filename>/sbin/hotplug</filename> support as well more drivers.
79 more drivers, and more robustness. 79 Such improvements were continued in the 2.5 kernel series, where they added
80 The 2.5 kernel series continued such improvements, and also 80 USB 2.0 support, improved performance, and made the host controller drivers
81 worked on USB 2.0 support, 81 (HCDs) more consistent. They also simplified the API (to make bugs less
82 higher performance, 82 likely) and added internal "kerneldoc" documentation.
83 better consistency between host controller drivers,
84 API simplification (to make bugs less likely),
85 and providing internal "kerneldoc" documentation.
86 </para> 83 </para>
87 84
88 <para>Linux can run inside USB devices as well as on 85 <para>Linux can run inside USB devices as well as on
89 the hosts that control the devices. 86 the hosts that control the devices.
90 Because the Linux 2.x USB support evolved to support mass market 87 But USB device drivers running inside those peripherals
91 platforms such as Apple Macintosh or PC-compatible systems,
92 it didn't address design concerns for those types of USB systems.
93 So it can't be used inside mass-market PDAs, or other peripherals.
94 USB device drivers running inside those Linux peripherals
95 don't do the same things as the ones running inside hosts, 88 don't do the same things as the ones running inside hosts,
96 and so they've been given a different name: 89 so they've been given a different name:
97 they're called <emphasis>gadget drivers</emphasis>. 90 <emphasis>gadget drivers</emphasis>.
98 This document does not present gadget drivers. 91 This document does not cover gadget drivers.
99 </para> 92 </para>
100 93
101 </chapter> 94 </chapter>
@@ -103,17 +96,14 @@
103<chapter id="host"> 96<chapter id="host">
104 <title>USB Host-Side API Model</title> 97 <title>USB Host-Side API Model</title>
105 98
106 <para>Within the kernel, 99 <para>Host-side drivers for USB devices talk to the "usbcore" APIs.
107 host-side drivers for USB devices talk to the "usbcore" APIs. 100 There are two. One is intended for
108 There are two types of public "usbcore" APIs, targetted at two different 101 <emphasis>general-purpose</emphasis> drivers (exposed through
109 layers of USB driver. Those are 102 driver frameworks), and the other is for drivers that are
110 <emphasis>general purpose</emphasis> drivers, exposed through 103 <emphasis>part of the core</emphasis>.
111 driver frameworks such as block, character, or network devices; 104 Such core drivers include the <emphasis>hub</emphasis> driver
112 and drivers that are <emphasis>part of the core</emphasis>, 105 (which manages trees of USB devices) and several different kinds
113 which are involved in managing a USB bus. 106 of <emphasis>host controller drivers</emphasis>,
114 Such core drivers include the <emphasis>hub</emphasis> driver,
115 which manages trees of USB devices, and several different kinds
116 of <emphasis>host controller driver (HCD)</emphasis>,
117 which control individual busses. 107 which control individual busses.
118 </para> 108 </para>
119 109
@@ -122,21 +112,21 @@
122 112
123 <itemizedlist> 113 <itemizedlist>
124 114
125 <listitem><para>USB supports four kinds of data transfer 115 <listitem><para>USB supports four kinds of data transfers
126 (control, bulk, interrupt, and isochronous). Two transfer 116 (control, bulk, interrupt, and isochronous). Two of them (control
127 types use bandwidth as it's available (control and bulk), 117 and bulk) use bandwidth as it's available,
128 while the other two types of transfer (interrupt and isochronous) 118 while the other two (interrupt and isochronous)
129 are scheduled to provide guaranteed bandwidth. 119 are scheduled to provide guaranteed bandwidth.
130 </para></listitem> 120 </para></listitem>
131 121
132 <listitem><para>The device description model includes one or more 122 <listitem><para>The device description model includes one or more
133 "configurations" per device, only one of which is active at a time. 123 "configurations" per device, only one of which is active at a time.
134 Devices that are capable of high speed operation must also support 124 Devices that are capable of high-speed operation must also support
135 full speed configurations, along with a way to ask about the 125 full-speed configurations, along with a way to ask about the
136 "other speed" configurations that might be used. 126 "other speed" configurations which might be used.
137 </para></listitem> 127 </para></listitem>
138 128
139 <listitem><para>Configurations have one or more "interface", each 129 <listitem><para>Configurations have one or more "interfaces", each
140 of which may have "alternate settings". Interfaces may be 130 of which may have "alternate settings". Interfaces may be
141 standardized by USB "Class" specifications, or may be specific to 131 standardized by USB "Class" specifications, or may be specific to
142 a vendor or device.</para> 132 a vendor or device.</para>
@@ -162,7 +152,7 @@
162 </para></listitem> 152 </para></listitem>
163 153
164 <listitem><para>The Linux USB API supports synchronous calls for 154 <listitem><para>The Linux USB API supports synchronous calls for
165 control and bulk messaging. 155 control and bulk messages.
166 It also supports asynchnous calls for all kinds of data transfer, 156 It also supports asynchnous calls for all kinds of data transfer,
167 using request structures called "URBs" (USB Request Blocks). 157 using request structures called "URBs" (USB Request Blocks).
168 </para></listitem> 158 </para></listitem>
@@ -463,14 +453,25 @@
463 file in your Linux kernel sources. 453 file in your Linux kernel sources.
464 </para> 454 </para>
465 455
466 <para>Otherwise the main use for this file from programs 456 <para>This file, in combination with the poll() system call, can
467 is to poll() it to get notifications of usb devices 457 also be used to detect when devices are added or removed:
468 as they're plugged or unplugged. 458<programlisting>int fd;
469 To see what changed, you'd need to read the file and 459struct pollfd pfd;
470 compare "before" and "after" contents, scan the filesystem, 460
471 or see its hotplug event. 461fd = open("/proc/bus/usb/devices", O_RDONLY);
462pfd = { fd, POLLIN, 0 };
463for (;;) {
464 /* The first time through, this call will return immediately. */
465 poll(&amp;pfd, 1, -1);
466
467 /* To see what's changed, compare the file's previous and current
468 contents or scan the filesystem. (Scanning is more precise.) */
469}</programlisting>
470 Note that this behavior is intended to be used for informational
471 and debug purposes. It would be more appropriate to use programs
472 such as udev or HAL to initialize a device or start a user-mode
473 helper program, for instance.
472 </para> 474 </para>
473
474 </sect1> 475 </sect1>
475 476
476 <sect1> 477 <sect1>
diff --git a/Documentation/HOWTO b/Documentation/HOWTO
index 915ae8c986c6..1d6560413cc5 100644
--- a/Documentation/HOWTO
+++ b/Documentation/HOWTO
@@ -358,7 +358,8 @@ Here is a list of some of the different kernel trees available:
358 quilt trees: 358 quilt trees:
359 - USB, PCI, Driver Core, and I2C, Greg Kroah-Hartman <gregkh@suse.de> 359 - USB, PCI, Driver Core, and I2C, Greg Kroah-Hartman <gregkh@suse.de>
360 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 360 kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
361 361 - x86-64, partly i386, Andi Kleen <ak@suse.de>
362 ftp.firstfloor.org:/pub/ak/x86_64/quilt/
362 363
363Bug Reporting 364Bug Reporting
364------------- 365-------------
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index 66c725f530f3..addc67b1d770 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2543,6 +2543,9 @@ Your cooperation is appreciated.
2543 64 = /dev/usb/rio500 Diamond Rio 500 2543 64 = /dev/usb/rio500 Diamond Rio 500
2544 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de) 2544 65 = /dev/usb/usblcd USBLCD Interface (info@usblcd.de)
2545 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD) 2545 66 = /dev/usb/cpad0 Synaptics cPad (mouse/LCD)
2546 67 = /dev/usb/adutux0 1st Ontrak ADU device
2547 ...
2548 76 = /dev/usb/adutux10 10th Ontrak ADU device
2546 96 = /dev/usb/hiddev0 1st USB HID device 2549 96 = /dev/usb/hiddev0 1st USB HID device
2547 ... 2550 ...
2548 111 = /dev/usb/hiddev15 16th USB HID device 2551 111 = /dev/usb/hiddev15 16th USB HID device
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 552507fe9a7e..436697cb9388 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -6,6 +6,21 @@ be removed from this file.
6 6
7--------------------------- 7---------------------------
8 8
9What: /sys/devices/.../power/state
10 dev->power.power_state
11 dpm_runtime_{suspend,resume)()
12When: July 2007
13Why: Broken design for runtime control over driver power states, confusing
14 driver-internal runtime power management with: mechanisms to support
15 system-wide sleep state transitions; event codes that distinguish
16 different phases of swsusp "sleep" transitions; and userspace policy
17 inputs. This framework was never widely used, and most attempts to
18 use it were broken. Drivers should instead be exposing domain-specific
19 interfaces either to kernel or to userspace.
20Who: Pavel Machek <pavel@suse.cz>
21
22---------------------------
23
9What: RAW driver (CONFIG_RAW_DRIVER) 24What: RAW driver (CONFIG_RAW_DRIVER)
10When: December 2005 25When: December 2005
11Why: declared obsolete since kernel 2.6.3 26Why: declared obsolete since kernel 2.6.3
@@ -55,6 +70,18 @@ Who: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
55 70
56--------------------------- 71---------------------------
57 72
73What: sys_sysctl
74When: January 2007
75Why: The same information is available through /proc/sys and that is the
76 interface user space prefers to use. And there do not appear to be
77 any existing user in user space of sys_sysctl. The additional
78 maintenance overhead of keeping a set of binary names gets
79 in the way of doing a good job of maintaining this interface.
80
81Who: Eric Biederman <ebiederm@xmission.com>
82
83---------------------------
84
58What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl]) 85What: PCMCIA control ioctl (needed for pcmcia-cs [cardmgr, cardctl])
59When: November 2005 86When: November 2005
60Files: drivers/pcmcia/: pcmcia_ioctl.c 87Files: drivers/pcmcia/: pcmcia_ioctl.c
@@ -202,14 +229,6 @@ Who: Nick Piggin <npiggin@suse.de>
202 229
203--------------------------- 230---------------------------
204 231
205What: Support for the MIPS EV96100 evaluation board
206When: September 2006
207Why: Does no longer build since at least November 15, 2003, apparently
208 no userbase left.
209Who: Ralf Baechle <ralf@linux-mips.org>
210
211---------------------------
212
213What: Support for the Momentum / PMC-Sierra Jaguar ATX evaluation board 232What: Support for the Momentum / PMC-Sierra Jaguar ATX evaluation board
214When: September 2006 233When: September 2006
215Why: Does no longer build since quite some time, and was never popular, 234Why: Does no longer build since quite some time, and was never popular,
@@ -294,3 +313,24 @@ Why: The frame diverter is included in most distribution kernels, but is
294 It is not clear if anyone is still using it. 313 It is not clear if anyone is still using it.
295Who: Stephen Hemminger <shemminger@osdl.org> 314Who: Stephen Hemminger <shemminger@osdl.org>
296 315
316---------------------------
317
318
319What: PHYSDEVPATH, PHYSDEVBUS, PHYSDEVDRIVER in the uevent environment
320When: Oktober 2008
321Why: The stacking of class devices makes these values misleading and
322 inconsistent.
323 Class devices should not carry any of these properties, and bus
324 devices have SUBSYTEM and DRIVER as a replacement.
325Who: Kay Sievers <kay.sievers@suse.de>
326
327---------------------------
328
329What: i2c-isa
330When: December 2006
331Why: i2c-isa is a non-sense and doesn't fit in the device driver
332 model. Drivers relying on it are better implemented as platform
333 drivers.
334Who: Jean Delvare <khali@linux-fr.org>
335
336---------------------------
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 99902ae6804e..7db71d6fba82 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1124,11 +1124,15 @@ debugging information is displayed on console.
1124NMI switch that most IA32 servers have fires unknown NMI up, for example. 1124NMI switch that most IA32 servers have fires unknown NMI up, for example.
1125If a system hangs up, try pressing the NMI switch. 1125If a system hangs up, try pressing the NMI switch.
1126 1126
1127[NOTE] 1127nmi_watchdog
1128 This function and oprofile share a NMI callback. Therefore this function 1128------------
1129 cannot be enabled when oprofile is activated. 1129
1130 And NMI watchdog will be disabled when the value in this file is set to 1130Enables/Disables the NMI watchdog on x86 systems. When the value is non-zero
1131 non-zero. 1131the NMI watchdog is enabled and will continuously test all online cpus to
1132determine whether or not they are still functioning properly.
1133
1134Because the NMI watchdog shares registers with oprofile, by disabling the NMI
1135watchdog, oprofile may have more registers to utilize.
1132 1136
1133 1137
11342.4 /proc/sys/vm - The virtual memory subsystem 11382.4 /proc/sys/vm - The virtual memory subsystem
diff --git a/Documentation/i2c/busses/i2c-viapro b/Documentation/i2c/busses/i2c-viapro
index 16775663b9f5..25680346e0ac 100644
--- a/Documentation/i2c/busses/i2c-viapro
+++ b/Documentation/i2c/busses/i2c-viapro
@@ -7,9 +7,12 @@ Supported adapters:
7 * VIA Technologies, Inc. VT82C686A/B 7 * VIA Technologies, Inc. VT82C686A/B
8 Datasheet: Sometimes available at the VIA website 8 Datasheet: Sometimes available at the VIA website
9 9
10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A, VT8235, VT8237R 10 * VIA Technologies, Inc. VT8231, VT8233, VT8233A
11 Datasheet: available on request from VIA 11 Datasheet: available on request from VIA
12 12
13 * VIA Technologies, Inc. VT8235, VT8237R, VT8237A, VT8251
14 Datasheet: available on request and under NDA from VIA
15
13Authors: 16Authors:
14 Kyösti Mälkki <kmalkki@cc.hut.fi>, 17 Kyösti Mälkki <kmalkki@cc.hut.fi>,
15 Mark D. Studebaker <mdsxyz123@yahoo.com>, 18 Mark D. Studebaker <mdsxyz123@yahoo.com>,
@@ -39,6 +42,8 @@ Your lspci -n listing must show one of these :
39 device 1106:8235 (VT8231 function 4) 42 device 1106:8235 (VT8231 function 4)
40 device 1106:3177 (VT8235) 43 device 1106:3177 (VT8235)
41 device 1106:3227 (VT8237R) 44 device 1106:3227 (VT8237R)
45 device 1106:3337 (VT8237A)
46 device 1106:3287 (VT8251)
42 47
43If none of these show up, you should look in the BIOS for settings like 48If none of these show up, you should look in the BIOS for settings like
44enable ACPI / SMBus or even USB. 49enable ACPI / SMBus or even USB.
diff --git a/Documentation/i2c/i2c-stub b/Documentation/i2c/i2c-stub
index d6dcb138abf5..9cc081e69764 100644
--- a/Documentation/i2c/i2c-stub
+++ b/Documentation/i2c/i2c-stub
@@ -6,9 +6,12 @@ This module is a very simple fake I2C/SMBus driver. It implements four
6types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and 6types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, and
7(r/w) word data. 7(r/w) word data.
8 8
9You need to provide a chip address as a module parameter when loading
10this driver, which will then only react to SMBus commands to this address.
11
9No hardware is needed nor associated with this module. It will accept write 12No hardware is needed nor associated with this module. It will accept write
10quick commands to all addresses; it will respond to the other commands (also 13quick commands to one address; it will respond to the other commands (also
11to all addresses) by reading from or writing to an array in memory. It will 14to one address) by reading from or writing to an array in memory. It will
12also spam the kernel logs for every command it handles. 15also spam the kernel logs for every command it handles.
13 16
14A pointer register with auto-increment is implemented for all byte 17A pointer register with auto-increment is implemented for all byte
@@ -21,6 +24,11 @@ The typical use-case is like this:
21 3. load the target sensors chip driver module 24 3. load the target sensors chip driver module
22 4. observe its behavior in the kernel log 25 4. observe its behavior in the kernel log
23 26
27PARAMETERS:
28
29int chip_addr:
30 The SMBus address to emulate a chip at.
31
24CAVEATS: 32CAVEATS:
25 33
26There are independent arrays for byte/data and word/data commands. Depending 34There are independent arrays for byte/data and word/data commands. Depending
@@ -33,6 +41,9 @@ If the hardware for your driver has banked registers (e.g. Winbond sensors
33chips) this module will not work well - although it could be extended to 41chips) this module will not work well - although it could be extended to
34support that pretty easily. 42support that pretty easily.
35 43
44Only one chip address is supported - although this module could be
45extended to support more.
46
36If you spam it hard enough, printk can be lossy. This module really wants 47If you spam it hard enough, printk can be lossy. This module really wants
37something like relayfs. 48something like relayfs.
38 49
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index b7d6abb501a6..e2cbd59cf2d0 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -421,6 +421,11 @@ more details, with real examples.
421 The second argument is optional, and if supplied will be used 421 The second argument is optional, and if supplied will be used
422 if first argument is not supported. 422 if first argument is not supported.
423 423
424 as-instr
425 as-instr checks if the assembler reports a specific instruction
426 and then outputs either option1 or option2
427 C escapes are supported in the test instruction
428
424 cc-option 429 cc-option
425 cc-option is used to check if $(CC) supports a given option, and not 430 cc-option is used to check if $(CC) supports a given option, and not
426 supported to use an optional second option. 431 supported to use an optional second option.
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 766abdab94e7..54983246930d 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -573,8 +573,6 @@ running once the system is up.
573 gscd= [HW,CD] 573 gscd= [HW,CD]
574 Format: <io> 574 Format: <io>
575 575
576 gt96100eth= [NET] MIPS GT96100 Advanced Communication Controller
577
578 gus= [HW,OSS] 576 gus= [HW,OSS]
579 Format: <io>,<irq>,<dma>,<dma16> 577 Format: <io>,<irq>,<dma>,<dma16>
580 578
@@ -1240,7 +1238,11 @@ running once the system is up.
1240 bootloader. This is currently used on 1238 bootloader. This is currently used on
1241 IXP2000 systems where the bus has to be 1239 IXP2000 systems where the bus has to be
1242 configured a certain way for adjunct CPUs. 1240 configured a certain way for adjunct CPUs.
1243 1241 noearly [X86] Don't do any early type 1 scanning.
1242 This might help on some broken boards which
1243 machine check when some devices' config space
1244 is read. But various workarounds are disabled
1245 and some IOMMU drivers will not work.
1244 pcmv= [HW,PCMCIA] BadgePAD 4 1246 pcmv= [HW,PCMCIA] BadgePAD 4
1245 1247
1246 pd. [PARIDE] 1248 pd. [PARIDE]
@@ -1368,6 +1370,9 @@ running once the system is up.
1368 Reserves a hole at the top of the kernel virtual 1370 Reserves a hole at the top of the kernel virtual
1369 address space. 1371 address space.
1370 1372
1373 reset_devices [KNL] Force drivers to reset the underlying device
1374 during initialization.
1375
1371 resume= [SWSUSP] 1376 resume= [SWSUSP]
1372 Specify the partition device for software suspend 1377 Specify the partition device for software suspend
1373 1378
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
index afac780445cd..dc942eaf490f 100644
--- a/Documentation/networking/bonding.txt
+++ b/Documentation/networking/bonding.txt
@@ -192,6 +192,17 @@ or, for backwards compatibility, the option value. E.g.,
192arp_interval 192arp_interval
193 193
194 Specifies the ARP link monitoring frequency in milliseconds. 194 Specifies the ARP link monitoring frequency in milliseconds.
195
196 The ARP monitor works by periodically checking the slave
197 devices to determine whether they have sent or received
198 traffic recently (the precise criteria depends upon the
199 bonding mode, and the state of the slave). Regular traffic is
200 generated via ARP probes issued for the addresses specified by
201 the arp_ip_target option.
202
203 This behavior can be modified by the arp_validate option,
204 below.
205
195 If ARP monitoring is used in an etherchannel compatible mode 206 If ARP monitoring is used in an etherchannel compatible mode
196 (modes 0 and 2), the switch should be configured in a mode 207 (modes 0 and 2), the switch should be configured in a mode
197 that evenly distributes packets across all links. If the 208 that evenly distributes packets across all links. If the
@@ -213,6 +224,54 @@ arp_ip_target
213 maximum number of targets that can be specified is 16. The 224 maximum number of targets that can be specified is 16. The
214 default value is no IP addresses. 225 default value is no IP addresses.
215 226
227arp_validate
228
229 Specifies whether or not ARP probes and replies should be
230 validated in the active-backup mode. This causes the ARP
231 monitor to examine the incoming ARP requests and replies, and
232 only consider a slave to be up if it is receiving the
233 appropriate ARP traffic.
234
235 Possible values are:
236
237 none or 0
238
239 No validation is performed. This is the default.
240
241 active or 1
242
243 Validation is performed only for the active slave.
244
245 backup or 2
246
247 Validation is performed only for backup slaves.
248
249 all or 3
250
251 Validation is performed for all slaves.
252
253 For the active slave, the validation checks ARP replies to
254 confirm that they were generated by an arp_ip_target. Since
255 backup slaves do not typically receive these replies, the
256 validation performed for backup slaves is on the ARP request
257 sent out via the active slave. It is possible that some
258 switch or network configurations may result in situations
259 wherein the backup slaves do not receive the ARP requests; in
260 such a situation, validation of backup slaves must be
261 disabled.
262
263 This option is useful in network configurations in which
264 multiple bonding hosts are concurrently issuing ARPs to one or
265 more targets beyond a common switch. Should the link between
266 the switch and target fail (but not the switch itself), the
267 probe traffic generated by the multiple bonding instances will
268 fool the standard ARP monitor into considering the links as
269 still up. Use of the arp_validate option can resolve this, as
270 the ARP monitor will only consider ARP requests and replies
271 associated with its own instance of bonding.
272
273 This option was added in bonding version 3.1.0.
274
216downdelay 275downdelay
217 276
218 Specifies the time, in milliseconds, to wait before disabling 277 Specifies the time, in milliseconds, to wait before disabling
diff --git a/Documentation/nommu-mmap.txt b/Documentation/nommu-mmap.txt
index b88ebe4d808c..7714f57caad5 100644
--- a/Documentation/nommu-mmap.txt
+++ b/Documentation/nommu-mmap.txt
@@ -116,6 +116,9 @@ FURTHER NOTES ON NO-MMU MMAP
116 (*) A list of all the mappings on the system is visible through /proc/maps in 116 (*) A list of all the mappings on the system is visible through /proc/maps in
117 no-MMU mode. 117 no-MMU mode.
118 118
119 (*) A list of all the mappings in use by a process is visible through
120 /proc/<pid>/maps in no-MMU mode.
121
119 (*) Supplying MAP_FIXED or a requesting a particular mapping address will 122 (*) Supplying MAP_FIXED or a requesting a particular mapping address will
120 result in an error. 123 result in an error.
121 124
@@ -125,6 +128,49 @@ FURTHER NOTES ON NO-MMU MMAP
125 error will result if they don't. This is most likely to be encountered 128 error will result if they don't. This is most likely to be encountered
126 with character device files, pipes, fifos and sockets. 129 with character device files, pipes, fifos and sockets.
127 130
131
132==========================
133INTERPROCESS SHARED MEMORY
134==========================
135
136Both SYSV IPC SHM shared memory and POSIX shared memory is supported in NOMMU
137mode. The former through the usual mechanism, the latter through files created
138on ramfs or tmpfs mounts.
139
140
141=======
142FUTEXES
143=======
144
145Futexes are supported in NOMMU mode if the arch supports them. An error will
146be given if an address passed to the futex system call lies outside the
147mappings made by a process or if the mapping in which the address lies does not
148support futexes (such as an I/O chardev mapping).
149
150
151=============
152NO-MMU MREMAP
153=============
154
155The mremap() function is partially supported. It may change the size of a
156mapping, and may move it[*] if MREMAP_MAYMOVE is specified and if the new size
157of the mapping exceeds the size of the slab object currently occupied by the
158memory to which the mapping refers, or if a smaller slab object could be used.
159
160MREMAP_FIXED is not supported, though it is ignored if there's no change of
161address and the object does not need to be moved.
162
163Shared mappings may not be moved. Shareable mappings may not be moved either,
164even if they are not currently shared.
165
166The mremap() function must be given an exact match for base address and size of
167a previously mapped object. It may not be used to create holes in existing
168mappings, move parts of existing mappings or resize parts of mappings. It must
169act on a complete mapping.
170
171[*] Not currently supported.
172
173
128============================================ 174============================================
129PROVIDING SHAREABLE CHARACTER DEVICE SUPPORT 175PROVIDING SHAREABLE CHARACTER DEVICE SUPPORT
130============================================ 176============================================
diff --git a/Documentation/pcieaer-howto.txt b/Documentation/pcieaer-howto.txt
new file mode 100644
index 000000000000..16c251230c82
--- /dev/null
+++ b/Documentation/pcieaer-howto.txt
@@ -0,0 +1,253 @@
1 The PCI Express Advanced Error Reporting Driver Guide HOWTO
2 T. Long Nguyen <tom.l.nguyen@intel.com>
3 Yanmin Zhang <yanmin.zhang@intel.com>
4 07/29/2006
5
6
71. Overview
8
91.1 About this guide
10
11This guide describes the basics of the PCI Express Advanced Error
12Reporting (AER) driver and provides information on how to use it, as
13well as how to enable the drivers of endpoint devices to conform with
14PCI Express AER driver.
15
161.2 Copyright © Intel Corporation 2006.
17
181.3 What is the PCI Express AER Driver?
19
20PCI Express error signaling can occur on the PCI Express link itself
21or on behalf of transactions initiated on the link. PCI Express
22defines two error reporting paradigms: the baseline capability and
23the Advanced Error Reporting capability. The baseline capability is
24required of all PCI Express components providing a minimum defined
25set of error reporting requirements. Advanced Error Reporting
26capability is implemented with a PCI Express advanced error reporting
27extended capability structure providing more robust error reporting.
28
29The PCI Express AER driver provides the infrastructure to support PCI
30Express Advanced Error Reporting capability. The PCI Express AER
31driver provides three basic functions:
32
33- Gathers the comprehensive error information if errors occurred.
34- Reports error to the users.
35- Performs error recovery actions.
36
37AER driver only attaches root ports which support PCI-Express AER
38capability.
39
40
412. User Guide
42
432.1 Include the PCI Express AER Root Driver into the Linux Kernel
44
45The PCI Express AER Root driver is a Root Port service driver attached
46to the PCI Express Port Bus driver. If a user wants to use it, the driver
47has to be compiled. Option CONFIG_PCIEAER supports this capability. It
48depends on CONFIG_PCIEPORTBUS, so pls. set CONFIG_PCIEPORTBUS=y and
49CONFIG_PCIEAER = y.
50
512.2 Load PCI Express AER Root Driver
52There is a case where a system has AER support in BIOS. Enabling the AER
53Root driver and having AER support in BIOS may result unpredictable
54behavior. To avoid this conflict, a successful load of the AER Root driver
55requires ACPI _OSC support in the BIOS to allow the AER Root driver to
56request for native control of AER. See the PCI FW 3.0 Specification for
57details regarding OSC usage. Currently, lots of firmwares don't provide
58_OSC support while they use PCI Express. To support such firmwares,
59forceload, a parameter of type bool, could enable AER to continue to
60be initiated although firmwares have no _OSC support. To enable the
61walkaround, pls. add aerdriver.forceload=y to kernel boot parameter line
62when booting kernel. Note that forceload=n by default.
63
642.3 AER error output
65When a PCI-E AER error is captured, an error message will be outputed to
66console. If it's a correctable error, it is outputed as a warning.
67Otherwise, it is printed as an error. So users could choose different
68log level to filter out correctable error messages.
69
70Below shows an example.
71+------ PCI-Express Device Error -----+
72Error Severity : Uncorrected (Fatal)
73PCIE Bus Error type : Transaction Layer
74Unsupported Request : First
75Requester ID : 0500
76VendorID=8086h, DeviceID=0329h, Bus=05h, Device=00h, Function=00h
77TLB Header:
7804000001 00200a03 05010000 00050100
79
80In the example, 'Requester ID' means the ID of the device who sends
81the error message to root port. Pls. refer to pci express specs for
82other fields.
83
84
853. Developer Guide
86
87To enable AER aware support requires a software driver to configure
88the AER capability structure within its device and to provide callbacks.
89
90To support AER better, developers need understand how AER does work
91firstly.
92
93PCI Express errors are classified into two types: correctable errors
94and uncorrectable errors. This classification is based on the impacts
95of those errors, which may result in degraded performance or function
96failure.
97
98Correctable errors pose no impacts on the functionality of the
99interface. The PCI Express protocol can recover without any software
100intervention or any loss of data. These errors are detected and
101corrected by hardware. Unlike correctable errors, uncorrectable
102errors impact functionality of the interface. Uncorrectable errors
103can cause a particular transaction or a particular PCI Express link
104to be unreliable. Depending on those error conditions, uncorrectable
105errors are further classified into non-fatal errors and fatal errors.
106Non-fatal errors cause the particular transaction to be unreliable,
107but the PCI Express link itself is fully functional. Fatal errors, on
108the other hand, cause the link to be unreliable.
109
110When AER is enabled, a PCI Express device will automatically send an
111error message to the PCIE root port above it when the device captures
112an error. The Root Port, upon receiving an error reporting message,
113internally processes and logs the error message in its PCI Express
114capability structure. Error information being logged includes storing
115the error reporting agent's requestor ID into the Error Source
116Identification Registers and setting the error bits of the Root Error
117Status Register accordingly. If AER error reporting is enabled in Root
118Error Command Register, the Root Port generates an interrupt if an
119error is detected.
120
121Note that the errors as described above are related to the PCI Express
122hierarchy and links. These errors do not include any device specific
123errors because device specific errors will still get sent directly to
124the device driver.
125
1263.1 Configure the AER capability structure
127
128AER aware drivers of PCI Express component need change the device
129control registers to enable AER. They also could change AER registers,
130including mask and severity registers. Helper function
131pci_enable_pcie_error_reporting could be used to enable AER. See
132section 3.3.
133
1343.2. Provide callbacks
135
1363.2.1 callback reset_link to reset pci express link
137
138This callback is used to reset the pci express physical link when a
139fatal error happens. The root port aer service driver provides a
140default reset_link function, but different upstream ports might
141have different specifications to reset pci express link, so all
142upstream ports should provide their own reset_link functions.
143
144In struct pcie_port_service_driver, a new pointer, reset_link, is
145added.
146
147pci_ers_result_t (*reset_link) (struct pci_dev *dev);
148
149Section 3.2.2.2 provides more detailed info on when to call
150reset_link.
151
1523.2.2 PCI error-recovery callbacks
153
154The PCI Express AER Root driver uses error callbacks to coordinate
155with downstream device drivers associated with a hierarchy in question
156when performing error recovery actions.
157
158Data struct pci_driver has a pointer, err_handler, to point to
159pci_error_handlers who consists of a couple of callback function
160pointers. AER driver follows the rules defined in
161pci-error-recovery.txt except pci express specific parts (e.g.
162reset_link). Pls. refer to pci-error-recovery.txt for detailed
163definitions of the callbacks.
164
165Below sections specify when to call the error callback functions.
166
1673.2.2.1 Correctable errors
168
169Correctable errors pose no impacts on the functionality of
170the interface. The PCI Express protocol can recover without any
171software intervention or any loss of data. These errors do not
172require any recovery actions. The AER driver clears the device's
173correctable error status register accordingly and logs these errors.
174
1753.2.2.2 Non-correctable (non-fatal and fatal) errors
176
177If an error message indicates a non-fatal error, performing link reset
178at upstream is not required. The AER driver calls error_detected(dev,
179pci_channel_io_normal) to all drivers associated within a hierarchy in
180question. for example,
181EndPoint<==>DownstreamPort B<==>UpstreamPort A<==>RootPort.
182If Upstream port A captures an AER error, the hierarchy consists of
183Downstream port B and EndPoint.
184
185A driver may return PCI_ERS_RESULT_CAN_RECOVER,
186PCI_ERS_RESULT_DISCONNECT, or PCI_ERS_RESULT_NEED_RESET, depending on
187whether it can recover or the AER driver calls mmio_enabled as next.
188
189If an error message indicates a fatal error, kernel will broadcast
190error_detected(dev, pci_channel_io_frozen) to all drivers within
191a hierarchy in question. Then, performing link reset at upstream is
192necessary. As different kinds of devices might use different approaches
193to reset link, AER port service driver is required to provide the
194function to reset link. Firstly, kernel looks for if the upstream
195component has an aer driver. If it has, kernel uses the reset_link
196callback of the aer driver. If the upstream component has no aer driver
197and the port is downstream port, we will use the aer driver of the
198root port who reports the AER error. As for upstream ports,
199they should provide their own aer service drivers with reset_link
200function. If error_detected returns PCI_ERS_RESULT_CAN_RECOVER and
201reset_link returns PCI_ERS_RESULT_RECOVERED, the error handling goes
202to mmio_enabled.
203
2043.3 helper functions
205
2063.3.1 int pci_find_aer_capability(struct pci_dev *dev);
207pci_find_aer_capability locates the PCI Express AER capability
208in the device configuration space. If the device doesn't support
209PCI-Express AER, the function returns 0.
210
2113.3.2 int pci_enable_pcie_error_reporting(struct pci_dev *dev);
212pci_enable_pcie_error_reporting enables the device to send error
213messages to root port when an error is detected. Note that devices
214don't enable the error reporting by default, so device drivers need
215call this function to enable it.
216
2173.3.3 int pci_disable_pcie_error_reporting(struct pci_dev *dev);
218pci_disable_pcie_error_reporting disables the device to send error
219messages to root port when an error is detected.
220
2213.3.4 int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
222pci_cleanup_aer_uncorrect_error_status cleanups the uncorrectable
223error status register.
224
2253.4 Frequent Asked Questions
226
227Q: What happens if a PCI Express device driver does not provide an
228error recovery handler (pci_driver->err_handler is equal to NULL)?
229
230A: The devices attached with the driver won't be recovered. If the
231error is fatal, kernel will print out warning messages. Please refer
232to section 3 for more information.
233
234Q: What happens if an upstream port service driver does not provide
235callback reset_link?
236
237A: Fatal error recovery will fail if the errors are reported by the
238upstream ports who are attached by the service driver.
239
240Q: How does this infrastructure deal with driver that is not PCI
241Express aware?
242
243A: This infrastructure calls the error callback functions of the
244driver when an error happens. But if the driver is not aware of
245PCI Express, the device might not report its own errors to root
246port.
247
248Q: What modifications will that driver need to make it compatible
249with the PCI Express AER Root driver?
250
251A: It could call the helper functions to enable AER in devices and
252cleanup uncorrectable status register. Pls. refer to section 3.3.
253
diff --git a/Documentation/power/devices.txt b/Documentation/power/devices.txt
index fba1e05c47c7..d0e79d5820a5 100644
--- a/Documentation/power/devices.txt
+++ b/Documentation/power/devices.txt
@@ -1,208 +1,553 @@
1Most of the code in Linux is device drivers, so most of the Linux power
2management code is also driver-specific. Most drivers will do very little;
3others, especially for platforms with small batteries (like cell phones),
4will do a lot.
5
6This writeup gives an overview of how drivers interact with system-wide
7power management goals, emphasizing the models and interfaces that are
8shared by everything that hooks up to the driver model core. Read it as
9background for the domain-specific work you'd do with any specific driver.
10
11
12Two Models for Device Power Management
13======================================
14Drivers will use one or both of these models to put devices into low-power
15states:
16
17 System Sleep model:
18 Drivers can enter low power states as part of entering system-wide
19 low-power states like "suspend-to-ram", or (mostly for systems with
20 disks) "hibernate" (suspend-to-disk).
21
22 This is something that device, bus, and class drivers collaborate on
23 by implementing various role-specific suspend and resume methods to
24 cleanly power down hardware and software subsystems, then reactivate
25 them without loss of data.
26
27 Some drivers can manage hardware wakeup events, which make the system
28 leave that low-power state. This feature may be disabled using the
29 relevant /sys/devices/.../power/wakeup file; enabling it may cost some
30 power usage, but let the whole system enter low power states more often.
31
32 Runtime Power Management model:
33 Drivers may also enter low power states while the system is running,
34 independently of other power management activity. Upstream drivers
35 will normally not know (or care) if the device is in some low power
36 state when issuing requests; the driver will auto-resume anything
37 that's needed when it gets a request.
38
39 This doesn't have, or need much infrastructure; it's just something you
40 should do when writing your drivers. For example, clk_disable() unused
41 clocks as part of minimizing power drain for currently-unused hardware.
42 Of course, sometimes clusters of drivers will collaborate with each
43 other, which could involve task-specific power management.
44
45There's not a lot to be said about those low power states except that they
46are very system-specific, and often device-specific. Also, that if enough
47drivers put themselves into low power states (at "runtime"), the effect may be
48the same as entering some system-wide low-power state (system sleep) ... and
49that synergies exist, so that several drivers using runtime pm might put the
50system into a state where even deeper power saving options are available.
51
52Most suspended devices will have quiesced all I/O: no more DMA or irqs, no
53more data read or written, and requests from upstream drivers are no longer
54accepted. A given bus or platform may have different requirements though.
55
56Examples of hardware wakeup events include an alarm from a real time clock,
57network wake-on-LAN packets, keyboard or mouse activity, and media insertion
58or removal (for PCMCIA, MMC/SD, USB, and so on).
59
60
61Interfaces for Entering System Sleep States
62===========================================
63Most of the programming interfaces a device driver needs to know about
64relate to that first model: entering a system-wide low power state,
65rather than just minimizing power consumption by one device.
66
67
68Bus Driver Methods
69------------------
70The core methods to suspend and resume devices reside in struct bus_type.
71These are mostly of interest to people writing infrastructure for busses
72like PCI or USB, or because they define the primitives that device drivers
73may need to apply in domain-specific ways to their devices:
1 74
2Device Power Management 75struct bus_type {
76 ...
77 int (*suspend)(struct device *dev, pm_message_t state);
78 int (*suspend_late)(struct device *dev, pm_message_t state);
3 79
80 int (*resume_early)(struct device *dev);
81 int (*resume)(struct device *dev);
82};
4 83
5Device power management encompasses two areas - the ability to save 84Bus drivers implement those methods as appropriate for the hardware and
6state and transition a device to a low-power state when the system is 85the drivers using it; PCI works differently from USB, and so on. Not many
7entering a low-power state; and the ability to transition a device to 86people write bus drivers; most driver code is a "device driver" that
8a low-power state while the system is running (and independently of 87builds on top of bus-specific framework code.
9any other power management activity). 88
89For more information on these driver calls, see the description later;
90they are called in phases for every device, respecting the parent-child
91sequencing in the driver model tree. Note that as this is being written,
92only the suspend() and resume() are widely available; not many bus drivers
93leverage all of those phases, or pass them down to lower driver levels.
94
95
96/sys/devices/.../power/wakeup files
97-----------------------------------
98All devices in the driver model have two flags to control handling of
99wakeup events, which are hardware signals that can force the device and/or
100system out of a low power state. These are initialized by bus or device
101driver code using device_init_wakeup(dev,can_wakeup).
102
103The "can_wakeup" flag just records whether the device (and its driver) can
104physically support wakeup events. When that flag is clear, the sysfs
105"wakeup" file is empty, and device_may_wakeup() returns false.
106
107For devices that can issue wakeup events, a separate flag controls whether
108that device should try to use its wakeup mechanism. The initial value of
109device_may_wakeup() will be true, so that the device's "wakeup" file holds
110the value "enabled". Userspace can change that to "disabled" so that
111device_may_wakeup() returns false; or change it back to "enabled" (so that
112it returns true again).
113
114
115EXAMPLE: PCI Device Driver Methods
116-----------------------------------
117PCI framework software calls these methods when the PCI device driver bound
118to a device device has provided them:
119
120struct pci_driver {
121 ...
122 int (*suspend)(struct pci_device *pdev, pm_message_t state);
123 int (*suspend_late)(struct pci_device *pdev, pm_message_t state);
124
125 int (*resume_early)(struct pci_device *pdev);
126 int (*resume)(struct pci_device *pdev);
127};
10 128
129Drivers will implement those methods, and call PCI-specific procedures
130like pci_set_power_state(), pci_enable_wake(), pci_save_state(), and
131pci_restore_state() to manage PCI-specific mechanisms. (PCI config space
132could be saved during driver probe, if it weren't for the fact that some
133systems rely on userspace tweaking using setpci.) Devices are suspended
134before their bridges enter low power states, and likewise bridges resume
135before their devices.
136
137
138Upper Layers of Driver Stacks
139-----------------------------
140Device drivers generally have at least two interfaces, and the methods
141sketched above are the ones which apply to the lower level (nearer PCI, USB,
142or other bus hardware). The network and block layers are examples of upper
143level interfaces, as is a character device talking to userspace.
144
145Power management requests normally need to flow through those upper levels,
146which often use domain-oriented requests like "blank that screen". In
147some cases those upper levels will have power management intelligence that
148relates to end-user activity, or other devices that work in cooperation.
149
150When those interfaces are structured using class interfaces, there is a
151standard way to have the upper layer stop issuing requests to a given
152class device (and restart later):
153
154struct class {
155 ...
156 int (*suspend)(struct device *dev, pm_message_t state);
157 int (*resume)(struct device *dev);
158};
11 159
12Methods 160Those calls are issued in specific phases of the process by which the
161system enters a low power "suspend" state, or resumes from it.
162
163
164Calling Drivers to Enter System Sleep States
165============================================
166When the system enters a low power state, each device's driver is asked
167to suspend the device by putting it into state compatible with the target
168system state. That's usually some version of "off", but the details are
169system-specific. Also, wakeup-enabled devices will usually stay partly
170functional in order to wake the system.
171
172When the system leaves that low power state, the device's driver is asked
173to resume it. The suspend and resume operations always go together, and
174both are multi-phase operations.
175
176For simple drivers, suspend might quiesce the device using the class code
177and then turn its hardware as "off" as possible with late_suspend. The
178matching resume calls would then completely reinitialize the hardware
179before reactivating its class I/O queues.
180
181More power-aware drivers drivers will use more than one device low power
182state, either at runtime or during system sleep states, and might trigger
183system wakeup events.
184
185
186Call Sequence Guarantees
187------------------------
188To ensure that bridges and similar links needed to talk to a device are
189available when the device is suspended or resumed, the device tree is
190walked in a bottom-up order to suspend devices. A top-down order is
191used to resume those devices.
192
193The ordering of the device tree is defined by the order in which devices
194get registered: a child can never be registered, probed or resumed before
195its parent; and can't be removed or suspended after that parent.
196
197The policy is that the device tree should match hardware bus topology.
198(Or at least the control bus, for devices which use multiple busses.)
199
200
201Suspending Devices
202------------------
203Suspending a given device is done in several phases. Suspending the
204system always includes every phase, executing calls for every device
205before the next phase begins. Not all busses or classes support all
206these callbacks; and not all drivers use all the callbacks.
207
208The phases are seen by driver notifications issued in this order:
209
210 1 class.suspend(dev, message) is called after tasks are frozen, for
211 devices associated with a class that has such a method. This
212 method may sleep.
213
214 Since I/O activity usually comes from such higher layers, this is
215 a good place to quiesce all drivers of a given type (and keep such
216 code out of those drivers).
217
218 2 bus.suspend(dev, message) is called next. This method may sleep,
219 and is often morphed into a device driver call with bus-specific
220 parameters and/or rules.
221
222 This call should handle parts of device suspend logic that require
223 sleeping. It probably does work to quiesce the device which hasn't
224 been abstracted into class.suspend() or bus.suspend_late().
225
226 3 bus.suspend_late(dev, message) is called with IRQs disabled, and
227 with only one CPU active. Until the bus.resume_early() phase
228 completes (see later), IRQs are not enabled again. This method
229 won't be exposed by all busses; for message based busses like USB,
230 I2C, or SPI, device interactions normally require IRQs. This bus
231 call may be morphed into a driver call with bus-specific parameters.
232
233 This call might save low level hardware state that might otherwise
234 be lost in the upcoming low power state, and actually put the
235 device into a low power state ... so that in some cases the device
236 may stay partly usable until this late. This "late" call may also
237 help when coping with hardware that behaves badly.
238
239The pm_message_t parameter is currently used to refine those semantics
240(described later).
241
242At the end of those phases, drivers should normally have stopped all I/O
243transactions (DMA, IRQs), saved enough state that they can re-initialize
244or restore previous state (as needed by the hardware), and placed the
245device into a low-power state. On many platforms they will also use
246clk_disable() to gate off one or more clock sources; sometimes they will
247also switch off power supplies, or reduce voltages. Drivers which have
248runtime PM support may already have performed some or all of the steps
249needed to prepare for the upcoming system sleep state.
250
251When any driver sees that its device_can_wakeup(dev), it should make sure
252to use the relevant hardware signals to trigger a system wakeup event.
253For example, enable_irq_wake() might identify GPIO signals hooked up to
254a switch or other external hardware, and pci_enable_wake() does something
255similar for PCI's PME# signal.
256
257If a driver (or bus, or class) fails it suspend method, the system won't
258enter the desired low power state; it will resume all the devices it's
259suspended so far.
260
261Note that drivers may need to perform different actions based on the target
262system lowpower/sleep state. At this writing, there are only platform
263specific APIs through which drivers could determine those target states.
264
265
266Device Low Power (suspend) States
267---------------------------------
268Device low-power states aren't very standard. One device might only handle
269"on" and "off, while another might support a dozen different versions of
270"on" (how many engines are active?), plus a state that gets back to "on"
271faster than from a full "off".
272
273Some busses define rules about what different suspend states mean. PCI
274gives one example: after the suspend sequence completes, a non-legacy
275PCI device may not perform DMA or issue IRQs, and any wakeup events it
276issues would be issued through the PME# bus signal. Plus, there are
277several PCI-standard device states, some of which are optional.
278
279In contrast, integrated system-on-chip processors often use irqs as the
280wakeup event sources (so drivers would call enable_irq_wake) and might
281be able to treat DMA completion as a wakeup event (sometimes DMA can stay
282active too, it'd only be the CPU and some peripherals that sleep).
283
284Some details here may be platform-specific. Systems may have devices that
285can be fully active in certain sleep states, such as an LCD display that's
286refreshed using DMA while most of the system is sleeping lightly ... and
287its frame buffer might even be updated by a DSP or other non-Linux CPU while
288the Linux control processor stays idle.
289
290Moreover, the specific actions taken may depend on the target system state.
291One target system state might allow a given device to be very operational;
292another might require a hard shut down with re-initialization on resume.
293And two different target systems might use the same device in different
294ways; the aforementioned LCD might be active in one product's "standby",
295but a different product using the same SOC might work differently.
296
297
298Meaning of pm_message_t.event
299-----------------------------
300Parameters to suspend calls include the device affected and a message of
301type pm_message_t, which has one field: the event. If driver does not
302recognize the event code, suspend calls may abort the request and return
303a negative errno. However, most drivers will be fine if they implement
304PM_EVENT_SUSPEND semantics for all messages.
305
306The event codes are used to refine the goal of suspending the device, and
307mostly matter when creating or resuming system memory image snapshots, as
308used with suspend-to-disk:
309
310 PM_EVENT_SUSPEND -- quiesce the driver and put hardware into a low-power
311 state. When used with system sleep states like "suspend-to-RAM" or
312 "standby", the upcoming resume() call will often be able to rely on
313 state kept in hardware, or issue system wakeup events. When used
314 instead with suspend-to-disk, few devices support this capability;
315 most are completely powered off.
316
317 PM_EVENT_FREEZE -- quiesce the driver, but don't necessarily change into
318 any low power mode. A system snapshot is about to be taken, often
319 followed by a call to the driver's resume() method. Neither wakeup
320 events nor DMA are allowed.
321
322 PM_EVENT_PRETHAW -- quiesce the driver, knowing that the upcoming resume()
323 will restore a suspend-to-disk snapshot from a different kernel image.
324 Drivers that are smart enough to look at their hardware state during
325 resume() processing need that state to be correct ... a PRETHAW could
326 be used to invalidate that state (by resetting the device), like a
327 shutdown() invocation would before a kexec() or system halt. Other
328 drivers might handle this the same way as PM_EVENT_FREEZE. Neither
329 wakeup events nor DMA are allowed.
330
331To enter "standby" (ACPI S1) or "Suspend to RAM" (STR, ACPI S3) states, or
332the similarly named APM states, only PM_EVENT_SUSPEND is used; for "Suspend
333to Disk" (STD, hibernate, ACPI S4), all of those event codes are used.
334
335There's also PM_EVENT_ON, a value which never appears as a suspend event
336but is sometimes used to record the "not suspended" device state.
337
338
339Resuming Devices
340----------------
341Resuming is done in multiple phases, much like suspending, with all
342devices processing each phase's calls before the next phase begins.
343
344The phases are seen by driver notifications issued in this order:
345
346 1 bus.resume_early(dev) is called with IRQs disabled, and with
347 only one CPU active. As with bus.suspend_late(), this method
348 won't be supported on busses that require IRQs in order to
349 interact with devices.
350
351 This reverses the effects of bus.suspend_late().
352
353 2 bus.resume(dev) is called next. This may be morphed into a device
354 driver call with bus-specific parameters; implementations may sleep.
355
356 This reverses the effects of bus.suspend().
357
358 3 class.resume(dev) is called for devices associated with a class
359 that has such a method. Implementations may sleep.
360
361 This reverses the effects of class.suspend(), and would usually
362 reactivate the device's I/O queue.
363
364At the end of those phases, drivers should normally be as functional as
365they were before suspending: I/O can be performed using DMA and IRQs, and
366the relevant clocks are gated on. The device need not be "fully on"; it
367might be in a runtime lowpower/suspend state that acts as if it were.
368
369However, the details here may again be platform-specific. For example,
370some systems support multiple "run" states, and the mode in effect at
371the end of resume() might not be the one which preceded suspension.
372That means availability of certain clocks or power supplies changed,
373which could easily affect how a driver works.
374
375
376Drivers need to be able to handle hardware which has been reset since the
377suspend methods were called, for example by complete reinitialization.
378This may be the hardest part, and the one most protected by NDA'd documents
379and chip errata. It's simplest if the hardware state hasn't changed since
380the suspend() was called, but that can't always be guaranteed.
381
382Drivers must also be prepared to notice that the device has been removed
383while the system was powered off, whenever that's physically possible.
384PCMCIA, MMC, USB, Firewire, SCSI, and even IDE are common examples of busses
385where common Linux platforms will see such removal. Details of how drivers
386will notice and handle such removals are currently bus-specific, and often
387involve a separate thread.
13 388
14The methods to suspend and resume devices reside in struct bus_type:
15 389
16struct bus_type { 390Note that the bus-specific runtime PM wakeup mechanism can exist, and might
17 ... 391be defined to share some of the same driver code as for system wakeup. For
18 int (*suspend)(struct device * dev, pm_message_t state); 392example, a bus-specific device driver's resume() method might be used there,
19 int (*resume)(struct device * dev); 393so it wouldn't only be called from bus.resume() during system-wide wakeup.
20}; 394See bus-specific information about how runtime wakeup events are handled.
21 395
22Each bus driver is responsible implementing these methods, translating
23the call into a bus-specific request and forwarding the call to the
24bus-specific drivers. For example, PCI drivers implement suspend() and
25resume() methods in struct pci_driver. The PCI core is simply
26responsible for translating the pointers to PCI-specific ones and
27calling the low-level driver.
28
29This is done to a) ease transition to the new power management methods
30and leverage the existing PM code in various bus drivers; b) allow
31buses to implement generic and default PM routines for devices, and c)
32make the flow of execution obvious to the reader.
33
34
35System Power Management
36
37When the system enters a low-power state, the device tree is walked in
38a depth-first fashion to transition each device into a low-power
39state. The ordering of the device tree is guaranteed by the order in
40which devices get registered - children are never registered before
41their ancestors, and devices are placed at the back of the list when
42registered. By walking the list in reverse order, we are guaranteed to
43suspend devices in the proper order.
44
45Devices are suspended once with interrupts enabled. Drivers are
46expected to stop I/O transactions, save device state, and place the
47device into a low-power state. Drivers may sleep, allocate memory,
48etc. at will.
49
50Some devices are broken and will inevitably have problems powering
51down or disabling themselves with interrupts enabled. For these
52special cases, they may return -EAGAIN. This will put the device on a
53list to be taken care of later. When interrupts are disabled, before
54we enter the low-power state, their drivers are called again to put
55their device to sleep.
56
57On resume, the devices that returned -EAGAIN will be called to power
58themselves back on with interrupts disabled. Once interrupts have been
59re-enabled, the rest of the drivers will be called to resume their
60devices. On resume, a driver is responsible for powering back on each
61device, restoring state, and re-enabling I/O transactions for that
62device.
63 396
397System Devices
398--------------
64System devices follow a slightly different API, which can be found in 399System devices follow a slightly different API, which can be found in
65 400
66 include/linux/sysdev.h 401 include/linux/sysdev.h
67 drivers/base/sys.c 402 drivers/base/sys.c
68 403
69System devices will only be suspended with interrupts disabled, and 404System devices will only be suspended with interrupts disabled, and after
70after all other devices have been suspended. On resume, they will be 405all other devices have been suspended. On resume, they will be resumed
71resumed before any other devices, and also with interrupts disabled. 406before any other devices, and also with interrupts disabled.
72 407
408That is, IRQs are disabled, the suspend_late() phase begins, then the
409sysdev_driver.suspend() phase, and the system enters a sleep state. Then
410the sysdev_driver.resume() phase begins, followed by the resume_early()
411phase, after which IRQs are enabled.
73 412
74Runtime Power Management 413Code to actually enter and exit the system-wide low power state sometimes
75 414involves hardware details that are only known to the boot firmware, and
76Many devices are able to dynamically power down while the system is 415may leave a CPU running software (from SRAM or flash memory) that monitors
77still running. This feature is useful for devices that are not being 416the system and manages its wakeup sequence.
78used, and can offer significant power savings on a running system.
79
80In each device's directory, there is a 'power' directory, which
81contains at least a 'state' file. Reading from this file displays what
82power state the device is currently in. Writing to this file initiates
83a transition to the specified power state, which must be a decimal in
84the range 1-3, inclusive; or 0 for 'On'.
85 417
86The PM core will call the ->suspend() method in the bus_type object
87that the device belongs to if the specified state is not 0, or
88->resume() if it is.
89 418
90Nothing will happen if the specified state is the same state the 419Runtime Power Management
91device is currently in. 420========================
92 421Many devices are able to dynamically power down while the system is still
93If the device is already in a low-power state, and the specified state 422running. This feature is useful for devices that are not being used, and
94is another, but different, low-power state, the ->resume() method will 423can offer significant power savings on a running system. These devices
95first be called to power the device back on, then ->suspend() will be 424often support a range of runtime power states, which might use names such
96called again with the new state. 425as "off", "sleep", "idle", "active", and so on. Those states will in some
97 426cases (like PCI) be partially constrained by a bus the device uses, and will
98The driver is responsible for saving the working state of the device 427usually include hardware states that are also used in system sleep states.
99and putting it into the low-power state specified. If this was 428
100successful, it returns 0, and the device's power_state field is 429However, note that if a driver puts a device into a runtime low power state
101updated. 430and the system then goes into a system-wide sleep state, it normally ought
102 431to resume into that runtime low power state rather than "full on". Such
103The driver must take care to know whether or not it is able to 432distinctions would be part of the driver-internal state machine for that
104properly resume the device, including all step of reinitialization 433hardware; the whole point of runtime power management is to be sure that
105necessary. (This is the hardest part, and the one most protected by 434drivers are decoupled in that way from the state machine governing phases
106NDA'd documents). 435of the system-wide power/sleep state transitions.
107 436
108The driver must also take care not to suspend a device that is 437
109currently in use. It is their responsibility to provide their own 438Power Saving Techniques
110exclusion mechanisms. 439-----------------------
111 440Normally runtime power management is handled by the drivers without specific
112The runtime power transition happens with interrupts enabled. If a 441userspace or kernel intervention, by device-aware use of techniques like:
113device cannot support being powered down with interrupts, it may 442
114return -EAGAIN (as it would during a system power management 443 Using information provided by other system layers
115transition), but it will _not_ be called again, and the transaction 444 - stay deeply "off" except between open() and close()
116will fail. 445 - if transceiver/PHY indicates "nobody connected", stay "off"
117 446 - application protocols may include power commands or hints
118There is currently no way to know what states a device or driver 447
119supports a priori. This will change in the future. 448 Using fewer CPU cycles
120 449 - using DMA instead of PIO
121pm_message_t meaning 450 - removing timers, or making them lower frequency
122 451 - shortening "hot" code paths
123pm_message_t has two fields. event ("major"), and flags. If driver 452 - eliminating cache misses
124does not know event code, it aborts the request, returning error. Some 453 - (sometimes) offloading work to device firmware
125drivers may need to deal with special cases based on the actual type 454
126of suspend operation being done at the system level. This is why 455 Reducing other resource costs
127there are flags. 456 - gating off unused clocks in software (or hardware)
128 457 - switching off unused power supplies
129Event codes are: 458 - eliminating (or delaying/merging) IRQs
130 459 - tuning DMA to use word and/or burst modes
131ON -- no need to do anything except special cases like broken 460
132HW. 461 Using device-specific low power states
133 462 - using lower voltages
134# NOTIFICATION -- pretty much same as ON? 463 - avoiding needless DMA transfers
135 464
136FREEZE -- stop DMA and interrupts, and be prepared to reinit HW from 465Read your hardware documentation carefully to see the opportunities that
137scratch. That probably means stop accepting upstream requests, the 466may be available. If you can, measure the actual power usage and check
138actual policy of what to do with them being specific to a given 467it against the budget established for your project.
139driver. It's acceptable for a network driver to just drop packets 468
140while a block driver is expected to block the queue so no request is 469
141lost. (Use IDE as an example on how to do that). FREEZE requires no 470Examples: USB hosts, system timer, system CPU
142power state change, and it's expected for drivers to be able to 471----------------------------------------------
143quickly transition back to operating state. 472USB host controllers make interesting, if complex, examples. In many cases
144 473these have no work to do: no USB devices are connected, or all of them are
145SUSPEND -- like FREEZE, but also put hardware into low-power state. If 474in the USB "suspend" state. Linux host controller drivers can then disable
146there's need to distinguish several levels of sleep, additional flag 475periodic DMA transfers that would otherwise be a constant power drain on the
147is probably best way to do that. 476memory subsystem, and enter a suspend state. In power-aware controllers,
148 477entering that suspend state may disable the clock used with USB signaling,
149Transitions are only from a resumed state to a suspended state, never 478saving a certain amount of power.
150between 2 suspended states. (ON -> FREEZE or ON -> SUSPEND can happen, 479
151FREEZE -> SUSPEND or SUSPEND -> FREEZE can not). 480The controller will be woken from that state (with an IRQ) by changes to the
152 481signal state on the data lines of a given port, for example by an existing
153All events are: 482peripheral requesting "remote wakeup" or by plugging a new peripheral. The
154 483same wakeup mechanism usually works from "standby" sleep states, and on some
155[NOTE NOTE NOTE: If you are driver author, you should not care; you 484systems also from "suspend to RAM" (or even "suspend to disk") states.
156should only look at event, and ignore flags.] 485(Except that ACPI may be involved instead of normal IRQs, on some hardware.)
157 486
158#Prepare for suspend -- userland is still running but we are going to 487System devices like timers and CPUs may have special roles in the platform
159#enter suspend state. This gives drivers chance to load firmware from 488power management scheme. For example, system timers using a "dynamic tick"
160#disk and store it in memory, or do other activities taht require 489approach don't just save CPU cycles (by eliminating needless timer IRQs),
161#operating userland, ability to kmalloc GFP_KERNEL, etc... All of these 490but they may also open the door to using lower power CPU "idle" states that
162#are forbiden once the suspend dance is started.. event = ON, flags = 491cost more than a jiffie to enter and exit. On x86 systems these are states
163#PREPARE_TO_SUSPEND 492like "C3"; note that periodic DMA transfers from a USB host controller will
164 493also prevent entry to a C3 state, much like a periodic timer IRQ.
165Apm standby -- prepare for APM event. Quiesce devices to make life 494
166easier for APM BIOS. event = FREEZE, flags = APM_STANDBY 495That kind of runtime mechanism interaction is common. "System On Chip" (SOC)
167 496processors often have low power idle modes that can't be entered unless
168Apm suspend -- same as APM_STANDBY, but it we should probably avoid 497certain medium-speed clocks (often 12 or 48 MHz) are gated off. When the
169spinning down disks. event = FREEZE, flags = APM_SUSPEND 498drivers gate those clocks effectively, then the system idle task may be able
170 499to use the lower power idle modes and thereby increase battery life.
171System halt, reboot -- quiesce devices to make life easier for BIOS. event 500
172= FREEZE, flags = SYSTEM_HALT or SYSTEM_REBOOT 501If the CPU can have a "cpufreq" driver, there also may be opportunities
173 502to shift to lower voltage settings and reduce the power cost of executing
174System shutdown -- at least disks need to be spun down, or data may be 503a given number of instructions. (Without voltage adjustment, it's rare
175lost. Quiesce devices, just to make life easier for BIOS. event = 504for cpufreq to save much power; the cost-per-instruction must go down.)
176FREEZE, flags = SYSTEM_SHUTDOWN 505
177 506
178Kexec -- turn off DMAs and put hardware into some state where new 507/sys/devices/.../power/state files
179kernel can take over. event = FREEZE, flags = KEXEC 508==================================
180 509For now you can also test some of this functionality using sysfs.
181Powerdown at end of swsusp -- very similar to SYSTEM_SHUTDOWN, except wake 510
182may need to be enabled on some devices. This actually has at least 3 511 DEPRECATED: USE "power/state" ONLY FOR DRIVER TESTING, AND
183subtypes, system can reboot, enter S4 and enter S5 at the end of 512 AVOID USING dev->power.power_state IN DRIVERS.
184swsusp. event = FREEZE, flags = SWSUSP and one of SYSTEM_REBOOT, 513
185SYSTEM_SHUTDOWN, SYSTEM_S4 514 THESE WILL BE REMOVED. IF THE "power/state" FILE GETS REPLACED,
186 515 IT WILL BECOME SOMETHING COUPLED TO THE BUS OR DRIVER.
187Suspend to ram -- put devices into low power state. event = SUSPEND, 516
188flags = SUSPEND_TO_RAM 517In each device's directory, there is a 'power' directory, which contains
189 518at least a 'state' file. The value of this field is effectively boolean,
190Freeze for swsusp snapshot -- stop DMA and interrupts. No need to put 519PM_EVENT_ON or PM_EVENT_SUSPEND.
191devices into low power mode, but you must be able to reinitialize 520
192device from scratch in resume method. This has two flavors, its done 521 * Reading from this file displays a value corresponding to
193once on suspending kernel, once on resuming kernel. event = FREEZE, 522 the power.power_state.event field. All nonzero values are
194flags = DURING_SUSPEND or DURING_RESUME 523 displayed as "2", corresponding to a low power state; zero
195 524 is displayed as "0", corresponding to normal operation.
196Device detach requested from /sys -- deinitialize device; proably same as 525
197SYSTEM_SHUTDOWN, I do not understand this one too much. probably event 526 * Writing to this file initiates a transition using the
198= FREEZE, flags = DEV_DETACH. 527 specified event code number; only '0', '2', and '3' are
199 528 accepted (without a newline); '2' and '3' are both
200#These are not really events sent: 529 mapped to PM_EVENT_SUSPEND.
201# 530
202#System fully on -- device is working normally; this is probably never 531On writes, the PM core relies on that recorded event code and the device/bus
203#passed to suspend() method... event = ON, flags = 0 532capabilities to determine whether it uses a partial suspend() or resume()
204# 533sequence to change things so that the recorded event corresponds to the
205#Ready after resume -- userland is now running, again. Time to free any 534numeric parameter.
206#memory you ate during prepare to suspend... event = ON, flags = 535
207#READY_AFTER_RESUME 536 - If the bus requires the irqs-disabled suspend_late()/resume_early()
208# 537 phases, writes fail because those operations are not supported here.
538
539 - If the recorded value is the expected value, nothing is done.
540
541 - If the recorded value is nonzero, the device is partially resumed,
542 using the bus.resume() and/or class.resume() methods.
543
544 - If the target value is nonzero, the device is partially suspended,
545 using the class.suspend() and/or bus.suspend() methods and the
546 PM_EVENT_SUSPEND message.
547
548Drivers have no way to tell whether their suspend() and resume() calls
549have come through the sysfs power/state file or as part of entering a
550system sleep state, except that when accessed through sysfs the normal
551parent/child sequencing rules are ignored. Drivers (such as bus, bridge,
552or hub drivers) which expose child devices may need to enforce those rules
553on their own.
diff --git a/Documentation/sh/new-machine.txt b/Documentation/sh/new-machine.txt
index eb2dd2e6993b..73988e0d112b 100644
--- a/Documentation/sh/new-machine.txt
+++ b/Documentation/sh/new-machine.txt
@@ -41,11 +41,6 @@ Board-specific code:
41 | 41 |
42 .. more boards here ... 42 .. more boards here ...
43 43
44It should also be noted that each board is required to have some certain
45headers. At the time of this writing, io.h is the only thing that needs
46to be provided for each board, and can generally just reference generic
47functions (with the exception of isa_port2addr).
48
49Next, for companion chips: 44Next, for companion chips:
50. 45.
51`-- arch 46`-- arch
@@ -104,12 +99,13 @@ and then populate that with sub-directories for each member of the family.
104Both the Solution Engine and the hp6xx boards are an example of this. 99Both the Solution Engine and the hp6xx boards are an example of this.
105 100
106After you have setup your new arch/sh/boards/ directory, remember that you 101After you have setup your new arch/sh/boards/ directory, remember that you
107also must add a directory in include/asm-sh for headers localized to this 102should also add a directory in include/asm-sh for headers localized to this
108board. In order to interoperate seamlessly with the build system, it's best 103board (if there are going to be more than one). In order to interoperate
109to have this directory the same as the arch/sh/boards/ directory name, 104seamlessly with the build system, it's best to have this directory the same
110though if your board is again part of a family, the build system has ways 105as the arch/sh/boards/ directory name, though if your board is again part of
111of dealing with this, and you can feel free to name the directory after 106a family, the build system has ways of dealing with this (via incdir-y
112the family member itself. 107overloading), and you can feel free to name the directory after the family
108member itself.
113 109
114There are a few things that each board is required to have, both in the 110There are a few things that each board is required to have, both in the
115arch/sh/boards and the include/asm-sh/ heirarchy. In order to better 111arch/sh/boards and the include/asm-sh/ heirarchy. In order to better
@@ -122,6 +118,7 @@ might look something like:
122 * arch/sh/boards/vapor/setup.c - Setup code for imaginary board 118 * arch/sh/boards/vapor/setup.c - Setup code for imaginary board
123 */ 119 */
124#include <linux/init.h> 120#include <linux/init.h>
121#include <asm/rtc.h> /* for board_time_init() */
125 122
126const char *get_system_type(void) 123const char *get_system_type(void)
127{ 124{
@@ -152,79 +149,57 @@ int __init platform_setup(void)
152} 149}
153 150
154Our new imaginary board will also have to tie into the machvec in order for it 151Our new imaginary board will also have to tie into the machvec in order for it
155to be of any use. Currently the machvec is slowly on its way out, but is still 152to be of any use.
156required for the time being. As such, let us take a look at what needs to be
157done for the machvec assignment.
158 153
159machvec functions fall into a number of categories: 154machvec functions fall into a number of categories:
160 155
161 - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc). 156 - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc).
162 - I/O remapping functions (ioremap etc) 157 - I/O mapping functions (ioport_map, ioport_unmap, etc).
163 - some initialisation functions 158 - a 'heartbeat' function.
164 - a 'heartbeat' function 159 - PCI and IRQ initialization routines.
165 - some miscellaneous flags 160 - Consistent allocators (for boards that need special allocators,
166 161 particularly for allocating out of some board-specific SRAM for DMA
167The tree can be built in two ways: 162 handles).
168 - as a fully generic build. All drivers are linked in, and all functions 163
169 go through the machvec 164There are machvec functions added and removed over time, so always be sure to
170 - as a machine specific build. In this case only the required drivers 165consult include/asm-sh/machvec.h for the current state of the machvec.
171 will be linked in, and some macros may be redefined to not go through 166
172 the machvec where performance is important (in particular IO functions). 167The kernel will automatically wrap in generic routines for undefined function
173 168pointers in the machvec at boot time, as machvec functions are referenced
174There are three ways in which IO can be performed: 169unconditionally throughout most of the tree. Some boards have incredibly
175 - none at all. This is really only useful for the 'unknown' machine type, 170sparse machvecs (such as the dreamcast and sh03), whereas others must define
176 which us designed to run on a machine about which we know nothing, and 171virtually everything (rts7751r2d).
177 so all all IO instructions do nothing. 172
178 - fully custom. In this case all IO functions go to a machine specific 173Adding a new machine is relatively trivial (using vapor as an example):
179 set of functions which can do what they like 174
180 - a generic set of functions. These will cope with most situations, 175If the board-specific definitions are quite minimalistic, as is the case for
181 and rely on a single function, mv_port2addr, which is called through the 176the vast majority of boards, simply having a single board-specific header is
182 machine vector, and converts an IO address into a memory address, which 177sufficient.
183 can be read from/written to directly. 178
184 179 - add a new file include/asm-sh/vapor.h which contains prototypes for
185Thus adding a new machine involves the following steps (I will assume I am
186adding a machine called vapor):
187
188 - add a new file include/asm-sh/vapor/io.h which contains prototypes for
189 any machine specific IO functions prefixed with the machine name, for 180 any machine specific IO functions prefixed with the machine name, for
190 example vapor_inb. These will be needed when filling out the machine 181 example vapor_inb. These will be needed when filling out the machine
191 vector. 182 vector.
192 183
193 This is the minimum that is required, however there are ample 184 Note that these prototypes are generated automatically by setting
194 opportunities to optimise this. In particular, by making the prototypes 185 __IO_PREFIX to something sensible. A typical example would be:
195 inline function definitions, it is possible to inline the function when 186
196 building machine specific versions. Note that the machine vector 187 #define __IO_PREFIX vapor
197 functions will still be needed, so that a module built for a generic 188 #include <asm/io_generic.h>
198 setup can be loaded. 189
199 190 somewhere in the board-specific header. Any boards being ported that still
200 - add a new file arch/sh/boards/vapor/mach.c. This contains the definition 191 have a legacy io.h should remove it entirely and switch to the new model.
201 of the machine vector. When building the machine specific version, this 192
202 will be the real machine vector (via an alias), while in the generic 193 - Add machine vector definitions to the board's setup.c. At a bare minimum,
203 version is used to initialise the machine vector, and then freed, by 194 this must be defined as something like:
204 making it initdata. This should be defined as: 195
205 196 struct sh_machine_vector mv_vapor __initmv = {
206 struct sh_machine_vector mv_vapor __initmv = { 197 .mv_name = "vapor",
207 .mv_name = "vapor", 198 };
208 } 199 ALIAS_MV(vapor)
209 ALIAS_MV(vapor) 200
210 201 - finally add a file arch/sh/boards/vapor/io.c, which contains definitions of
211 - finally add a file arch/sh/boards/vapor/io.c, which contains 202 the machine specific io functions (if there are enough to warrant it).
212 definitions of the machine specific io functions.
213
214A note about initialisation functions. Three initialisation functions are
215provided in the machine vector:
216 - mv_arch_init - called very early on from setup_arch
217 - mv_init_irq - called from init_IRQ, after the generic SH interrupt
218 initialisation
219 - mv_init_pci - currently not used
220
221Any other remaining functions which need to be called at start up can be
222added to the list using the __initcalls macro (or module_init if the code
223can be built as a module). Many generic drivers probe to see if the device
224they are targeting is present, however this may not always be appropriate,
225so a flag can be added to the machine vector which will be set on those
226machines which have the hardware in question, reducing the probe to a
227single conditional.
228 203
2293. Hooking into the Build System 2043. Hooking into the Build System
230================================ 205================================
@@ -303,4 +278,3 @@ which will in turn copy the defconfig for this board, run it through
303oldconfig (prompting you for any new options since the time of creation), 278oldconfig (prompting you for any new options since the time of creation),
304and start you on your way to having a functional kernel for your new 279and start you on your way to having a functional kernel for your new
305board. 280board.
306
diff --git a/Documentation/sh/register-banks.txt b/Documentation/sh/register-banks.txt
new file mode 100644
index 000000000000..a6719f2f6594
--- /dev/null
+++ b/Documentation/sh/register-banks.txt
@@ -0,0 +1,33 @@
1 Notes on register bank usage in the kernel
2 ==========================================
3
4Introduction
5------------
6
7The SH-3 and SH-4 CPU families traditionally include a single partial register
8bank (selected by SR.RB, only r0 ... r7 are banked), whereas other families
9may have more full-featured banking or simply no such capabilities at all.
10
11SR.RB banking
12-------------
13
14In the case of this type of banking, banked registers are mapped directly to
15r0 ... r7 if SR.RB is set to the bank we are interested in, otherwise ldc/stc
16can still be used to reference the banked registers (as r0_bank ... r7_bank)
17when in the context of another bank. The developer must keep the SR.RB value
18in mind when writing code that utilizes these banked registers, for obvious
19reasons. Userspace is also not able to poke at the bank1 values, so these can
20be used rather effectively as scratch registers by the kernel.
21
22Presently the kernel uses several of these registers.
23
24 - r0_bank, r1_bank (referenced as k0 and k1, used for scratch
25 registers when doing exception handling).
26 - r2_bank (used to track the EXPEVT/INTEVT code)
27 - Used by do_IRQ() and friends for doing irq mapping based off
28 of the interrupt exception vector jump table offset
29 - r6_bank (global interrupt mask)
30 - The SR.IMASK interrupt handler makes use of this to set the
31 interrupt priority level (used by local_irq_enable())
32 - r7_bank (current)
33
diff --git a/Documentation/usb/error-codes.txt b/Documentation/usb/error-codes.txt
index 867f4c38f356..39c68f8c4e6c 100644
--- a/Documentation/usb/error-codes.txt
+++ b/Documentation/usb/error-codes.txt
@@ -98,13 +98,13 @@ one or more packets could finish before an error stops further endpoint I/O.
98 error, a failure to respond (often caused by 98 error, a failure to respond (often caused by
99 device disconnect), or some other fault. 99 device disconnect), or some other fault.
100 100
101-ETIMEDOUT (**) No response packet received within the prescribed 101-ETIME (**) No response packet received within the prescribed
102 bus turn-around time. This error may instead be 102 bus turn-around time. This error may instead be
103 reported as -EPROTO or -EILSEQ. 103 reported as -EPROTO or -EILSEQ.
104 104
105 Note that the synchronous USB message functions 105-ETIMEDOUT Synchronous USB message functions use this code
106 also use this code to indicate timeout expired 106 to indicate timeout expired before the transfer
107 before the transfer completed. 107 completed, and no other error was reported by HC.
108 108
109-EPIPE (**) Endpoint stalled. For non-control endpoints, 109-EPIPE (**) Endpoint stalled. For non-control endpoints,
110 reset this status with usb_clear_halt(). 110 reset this status with usb_clear_halt().
@@ -163,6 +163,3 @@ usb_get_*/usb_set_*():
163usb_control_msg(): 163usb_control_msg():
164usb_bulk_msg(): 164usb_bulk_msg():
165-ETIMEDOUT Timeout expired before the transfer completed. 165-ETIMEDOUT Timeout expired before the transfer completed.
166 In the future this code may change to -ETIME,
167 whose definition is a closer match to this sort
168 of error.
diff --git a/Documentation/usb/usb-serial.txt b/Documentation/usb/usb-serial.txt
index 02b0f7beb6d1..a2dee6e6190d 100644
--- a/Documentation/usb/usb-serial.txt
+++ b/Documentation/usb/usb-serial.txt
@@ -433,6 +433,11 @@ Options supported:
433 See http://www.uuhaus.de/linux/palmconnect.html for up-to-date 433 See http://www.uuhaus.de/linux/palmconnect.html for up-to-date
434 information on this driver. 434 information on this driver.
435 435
436AIRcable USB Dongle Bluetooth driver
437 If there is the cdc_acm driver loaded in the system, you will find that the
438 cdc_acm claims the device before AIRcable can. This is simply corrected
439 by unloading both modules and then loading the aircable module before
440 cdc_acm module
436 441
437Generic Serial driver 442Generic Serial driver
438 443
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 6da24e7a56cb..4303e0c12476 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -245,6 +245,13 @@ Debugging
245 newfallback: use new unwinder but fall back to old if it gets 245 newfallback: use new unwinder but fall back to old if it gets
246 stuck (default) 246 stuck (default)
247 247
248 call_trace=[old|both|newfallback|new]
249 old: use old inexact backtracer
250 new: use new exact dwarf2 unwinder
251 both: print entries from both
252 newfallback: use new unwinder but fall back to old if it gets
253 stuck (default)
254
248Misc 255Misc
249 256
250 noreplacement Don't replace instructions with more appropriate ones 257 noreplacement Don't replace instructions with more appropriate ones
diff --git a/Documentation/x86_64/kernel-stacks b/Documentation/x86_64/kernel-stacks
new file mode 100644
index 000000000000..bddfddd466ab
--- /dev/null
+++ b/Documentation/x86_64/kernel-stacks
@@ -0,0 +1,99 @@
1Most of the text from Keith Owens, hacked by AK
2
3x86_64 page size (PAGE_SIZE) is 4K.
4
5Like all other architectures, x86_64 has a kernel stack for every
6active thread. These thread stacks are THREAD_SIZE (2*PAGE_SIZE) big.
7These stacks contain useful data as long as a thread is alive or a
8zombie. While the thread is in user space the kernel stack is empty
9except for the thread_info structure at the bottom.
10
11In addition to the per thread stacks, there are specialized stacks
12associated with each cpu. These stacks are only used while the kernel
13is in control on that cpu, when a cpu returns to user space the
14specialized stacks contain no useful data. The main cpu stacks is
15
16* Interrupt stack. IRQSTACKSIZE
17
18 Used for external hardware interrupts. If this is the first external
19 hardware interrupt (i.e. not a nested hardware interrupt) then the
20 kernel switches from the current task to the interrupt stack. Like
21 the split thread and interrupt stacks on i386 (with CONFIG_4KSTACKS),
22 this gives more room for kernel interrupt processing without having
23 to increase the size of every per thread stack.
24
25 The interrupt stack is also used when processing a softirq.
26
27Switching to the kernel interrupt stack is done by software based on a
28per CPU interrupt nest counter. This is needed because x86-64 "IST"
29hardware stacks cannot nest without races.
30
31x86_64 also has a feature which is not available on i386, the ability
32to automatically switch to a new stack for designated events such as
33double fault or NMI, which makes it easier to handle these unusual
34events on x86_64. This feature is called the Interrupt Stack Table
35(IST). There can be up to 7 IST entries per cpu. The IST code is an
36index into the Task State Segment (TSS), the IST entries in the TSS
37point to dedicated stacks, each stack can be a different size.
38
39An IST is selected by an non-zero value in the IST field of an
40interrupt-gate descriptor. When an interrupt occurs and the hardware
41loads such a descriptor, the hardware automatically sets the new stack
42pointer based on the IST value, then invokes the interrupt handler. If
43software wants to allow nested IST interrupts then the handler must
44adjust the IST values on entry to and exit from the interrupt handler.
45(this is occasionally done, e.g. for debug exceptions)
46
47Events with different IST codes (i.e. with different stacks) can be
48nested. For example, a debug interrupt can safely be interrupted by an
49NMI. arch/x86_64/kernel/entry.S::paranoidentry adjusts the stack
50pointers on entry to and exit from all IST events, in theory allowing
51IST events with the same code to be nested. However in most cases, the
52stack size allocated to an IST assumes no nesting for the same code.
53If that assumption is ever broken then the stacks will become corrupt.
54
55The currently assigned IST stacks are :-
56
57* STACKFAULT_STACK. EXCEPTION_STKSZ (PAGE_SIZE).
58
59 Used for interrupt 12 - Stack Fault Exception (#SS).
60
61 This allows to recover from invalid stack segments. Rarely
62 happens.
63
64* DOUBLEFAULT_STACK. EXCEPTION_STKSZ (PAGE_SIZE).
65
66 Used for interrupt 8 - Double Fault Exception (#DF).
67
68 Invoked when handling a exception causes another exception. Happens
69 when the kernel is very confused (e.g. kernel stack pointer corrupt)
70 Using a separate stack allows to recover from it well enough in many
71 cases to still output an oops.
72
73* NMI_STACK. EXCEPTION_STKSZ (PAGE_SIZE).
74
75 Used for non-maskable interrupts (NMI).
76
77 NMI can be delivered at any time, including when the kernel is in the
78 middle of switching stacks. Using IST for NMI events avoids making
79 assumptions about the previous state of the kernel stack.
80
81* DEBUG_STACK. DEBUG_STKSZ
82
83 Used for hardware debug interrupts (interrupt 1) and for software
84 debug interrupts (INT3).
85
86 When debugging a kernel, debug interrupts (both hardware and
87 software) can occur at any time. Using IST for these interrupts
88 avoids making assumptions about the previous state of the kernel
89 stack.
90
91* MCE_STACK. EXCEPTION_STKSZ (PAGE_SIZE).
92
93 Used for interrupt 18 - Machine Check Exception (#MC).
94
95 MCE can be delivered at any time, including when the kernel is in the
96 middle of switching stacks. Using IST for MCE events avoids making
97 assumptions about the previous state of the kernel stack.
98
99For more details see the Intel IA32 or AMD AMD64 architecture manuals.
diff --git a/MAINTAINERS b/MAINTAINERS
index 767a43434ae8..63673e6513b7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2679,7 +2679,6 @@ M: josejx@gentoo.org
2679P: Daniel Drake 2679P: Daniel Drake
2680M: dsd@gentoo.org 2680M: dsd@gentoo.org
2681W: http://softmac.sipsolutions.net/ 2681W: http://softmac.sipsolutions.net/
2682L: softmac-dev@sipsolutions.net
2683L: netdev@vger.kernel.org 2682L: netdev@vger.kernel.org
2684S: Maintained 2683S: Maintained
2685 2684
diff --git a/Makefile b/Makefile
index 80dac0245d66..4c6c5e32ef96 100644
--- a/Makefile
+++ b/Makefile
@@ -1385,9 +1385,13 @@ endif #ifeq ($(config-targets),1)
1385endif #ifeq ($(mixed-targets),1) 1385endif #ifeq ($(mixed-targets),1)
1386 1386
1387PHONY += checkstack kernelrelease kernelversion 1387PHONY += checkstack kernelrelease kernelversion
1388
1389# Use $(SUBARCH) here instead of $(ARCH) so that this works for UML.
1390# In the UML case, $(SUBARCH) is the name of the underlying
1391# architecture, while for all other arches, it is the same as $(ARCH).
1388checkstack: 1392checkstack:
1389 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1393 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1390 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1394 $(PERL) $(src)/scripts/checkstack.pl $(SUBARCH)
1391 1395
1392kernelrelease: 1396kernelrelease:
1393 $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \ 1397 $(if $(wildcard include/config/kernel.release), $(Q)echo $(KERNELRELEASE), \
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index cce26576999e..337c01c4ac37 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -284,21 +284,9 @@ static struct pxaficp_platform_data corgi_ficp_platform_data = {
284/* 284/*
285 * USB Device Controller 285 * USB Device Controller
286 */ 286 */
287static void corgi_udc_command(int cmd)
288{
289 switch(cmd) {
290 case PXA2XX_UDC_CMD_CONNECT:
291 GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
292 break;
293 case PXA2XX_UDC_CMD_DISCONNECT:
294 GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
295 break;
296 }
297}
298
299static struct pxa2xx_udc_mach_info udc_info __initdata = { 287static struct pxa2xx_udc_mach_info udc_info __initdata = {
300 /* no connect GPIO; corgi can't tell connection status */ 288 /* no connect GPIO; corgi can't tell connection status */
301 .udc_command = corgi_udc_command, 289 .gpio_pullup = CORGI_GPIO_USB_PULLUP,
302}; 290};
303 291
304 292
@@ -350,7 +338,6 @@ static void __init corgi_init(void)
350 corgi_ssp_set_machinfo(&corgi_ssp_machinfo); 338 corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
351 339
352 pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT); 340 pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT);
353 pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
354 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN); 341 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
355 342
356 pxa_set_udc_info(&udc_info); 343 pxa_set_udc_info(&udc_info);
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 9b815327b6a5..7e8096809be2 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -26,7 +26,7 @@
26#include <linux/errno.h> 26#include <linux/errno.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/platform_device.h> 28#include <linux/platform_device.h>
29#include <linux/usb_otg.h> 29#include <linux/usb/otg.h>
30 30
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
diff --git a/arch/avr32/mm/tlb.c b/arch/avr32/mm/tlb.c
index 5d0523bbe298..7b073052203d 100644
--- a/arch/avr32/mm/tlb.c
+++ b/arch/avr32/mm/tlb.c
@@ -15,7 +15,8 @@
15 15
16void show_dtlb_entry(unsigned int index) 16void show_dtlb_entry(unsigned int index)
17{ 17{
18 unsigned int tlbehi, tlbehi_save, tlbelo, mmucr, mmucr_save, flags; 18 unsigned int tlbehi, tlbehi_save, tlbelo, mmucr, mmucr_save;
19 unsigned long flags;
19 20
20 local_irq_save(flags); 21 local_irq_save(flags);
21 mmucr_save = sysreg_read(MMUCR); 22 mmucr_save = sysreg_read(MMUCR);
@@ -305,7 +306,8 @@ static void tlb_stop(struct seq_file *tlb, void *v)
305 306
306static int tlb_show(struct seq_file *tlb, void *v) 307static int tlb_show(struct seq_file *tlb, void *v)
307{ 308{
308 unsigned int tlbehi, tlbehi_save, tlbelo, mmucr, mmucr_save, flags; 309 unsigned int tlbehi, tlbehi_save, tlbelo, mmucr, mmucr_save;
310 unsigned long flags;
309 unsigned long *index = v; 311 unsigned long *index = v;
310 312
311 if (*index == 0) 313 if (*index == 0)
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 6189b0c28d6f..3fd2f256f2be 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -166,7 +166,6 @@ config X86_VISWS
166 166
167config X86_GENERICARCH 167config X86_GENERICARCH
168 bool "Generic architecture (Summit, bigsmp, ES7000, default)" 168 bool "Generic architecture (Summit, bigsmp, ES7000, default)"
169 depends on SMP
170 help 169 help
171 This option compiles in the Summit, bigsmp, ES7000, default subarchitectures. 170 This option compiles in the Summit, bigsmp, ES7000, default subarchitectures.
172 It is intended for a generic binary kernel. 171 It is intended for a generic binary kernel.
@@ -263,7 +262,7 @@ source "kernel/Kconfig.preempt"
263 262
264config X86_UP_APIC 263config X86_UP_APIC
265 bool "Local APIC support on uniprocessors" 264 bool "Local APIC support on uniprocessors"
266 depends on !SMP && !(X86_VISWS || X86_VOYAGER) 265 depends on !SMP && !(X86_VISWS || X86_VOYAGER || X86_GENERICARCH)
267 help 266 help
268 A local APIC (Advanced Programmable Interrupt Controller) is an 267 A local APIC (Advanced Programmable Interrupt Controller) is an
269 integrated interrupt controller in the CPU. If you have a single-CPU 268 integrated interrupt controller in the CPU. If you have a single-CPU
@@ -288,12 +287,12 @@ config X86_UP_IOAPIC
288 287
289config X86_LOCAL_APIC 288config X86_LOCAL_APIC
290 bool 289 bool
291 depends on X86_UP_APIC || ((X86_VISWS || SMP) && !X86_VOYAGER) 290 depends on X86_UP_APIC || ((X86_VISWS || SMP) && !X86_VOYAGER) || X86_GENERICARCH
292 default y 291 default y
293 292
294config X86_IO_APIC 293config X86_IO_APIC
295 bool 294 bool
296 depends on X86_UP_IOAPIC || (SMP && !(X86_VISWS || X86_VOYAGER)) 295 depends on X86_UP_IOAPIC || (SMP && !(X86_VISWS || X86_VOYAGER)) || X86_GENERICARCH
297 default y 296 default y
298 297
299config X86_VISWS_APIC 298config X86_VISWS_APIC
@@ -402,6 +401,7 @@ config X86_REBOOTFIXUPS
402 401
403config MICROCODE 402config MICROCODE
404 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support" 403 tristate "/dev/cpu/microcode - Intel IA32 CPU microcode support"
404 select FW_LOADER
405 ---help--- 405 ---help---
406 If you say Y here and also to "/dev file system support" in the 406 If you say Y here and also to "/dev file system support" in the
407 'File systems' section, you will be able to update the microcode on 407 'File systems' section, you will be able to update the microcode on
@@ -417,6 +417,11 @@ config MICROCODE
417 To compile this driver as a module, choose M here: the 417 To compile this driver as a module, choose M here: the
418 module will be called microcode. 418 module will be called microcode.
419 419
420config MICROCODE_OLD_INTERFACE
421 bool
422 depends on MICROCODE
423 default y
424
420config X86_MSR 425config X86_MSR
421 tristate "/dev/cpu/*/msr - Model-specific register support" 426 tristate "/dev/cpu/*/msr - Model-specific register support"
422 help 427 help
@@ -599,12 +604,10 @@ config ARCH_SELECT_MEMORY_MODEL
599 def_bool y 604 def_bool y
600 depends on ARCH_SPARSEMEM_ENABLE 605 depends on ARCH_SPARSEMEM_ENABLE
601 606
602source "mm/Kconfig" 607config ARCH_POPULATES_NODE_MAP
608 def_bool y
603 609
604config HAVE_ARCH_EARLY_PFN_TO_NID 610source "mm/Kconfig"
605 bool
606 default y
607 depends on NUMA
608 611
609config HIGHPTE 612config HIGHPTE
610 bool "Allocate 3rd-level pagetables from highmem" 613 bool "Allocate 3rd-level pagetables from highmem"
@@ -741,8 +744,7 @@ config SECCOMP
741source kernel/Kconfig.hz 744source kernel/Kconfig.hz
742 745
743config KEXEC 746config KEXEC
744 bool "kexec system call (EXPERIMENTAL)" 747 bool "kexec system call"
745 depends on EXPERIMENTAL
746 help 748 help
747 kexec is a system call that implements the ability to shutdown your 749 kexec is a system call that implements the ability to shutdown your
748 current kernel, and to start another kernel. It is like a reboot 750 current kernel, and to start another kernel. It is like a reboot
@@ -763,6 +765,13 @@ config CRASH_DUMP
763 depends on HIGHMEM 765 depends on HIGHMEM
764 help 766 help
765 Generate crash dump after being started by kexec. 767 Generate crash dump after being started by kexec.
768 This should be normally only set in special crash dump kernels
769 which are loaded in the main kernel with kexec-tools into
770 a specially reserved region and then later executed after
771 a crash by kdump/kexec. The crash dump kernel must be compiled
772 to a memory address not used by the main kernel or BIOS using
773 PHYSICAL_START.
774 For more details see Documentation/kdump/kdump.txt
766 775
767config PHYSICAL_START 776config PHYSICAL_START
768 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 777 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 3e4adb1e2244..7cc0b189b82b 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -46,6 +46,14 @@ cflags-y += -ffreestanding
46# a lot more stack due to the lack of sharing of stacklots: 46# a lot more stack due to the lack of sharing of stacklots:
47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;) 47CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
48 48
49# do binutils support CFI?
50cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
51AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
52
53# is .cfi_signal_frame supported too?
54cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
55AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
56
49CFLAGS += $(cflags-y) 57CFLAGS += $(cflags-y)
50 58
51# Default subarch .c files 59# Default subarch .c files
diff --git a/arch/i386/boot/edd.S b/arch/i386/boot/edd.S
index 4b84ea216f2b..34321368011a 100644
--- a/arch/i386/boot/edd.S
+++ b/arch/i386/boot/edd.S
@@ -15,42 +15,95 @@
15#include <asm/setup.h> 15#include <asm/setup.h>
16 16
17#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) 17#if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
18
19# It is assumed that %ds == INITSEG here
20
18 movb $0, (EDD_MBR_SIG_NR_BUF) 21 movb $0, (EDD_MBR_SIG_NR_BUF)
19 movb $0, (EDDNR) 22 movb $0, (EDDNR)
20 23
21# Check the command line for two options: 24# Check the command line for options:
22# edd=of disables EDD completely (edd=off) 25# edd=of disables EDD completely (edd=off)
23# edd=sk skips the MBR test (edd=skipmbr) 26# edd=sk skips the MBR test (edd=skipmbr)
27# edd=on re-enables EDD (edd=on)
28
24 pushl %esi 29 pushl %esi
25 cmpl $0, %cs:cmd_line_ptr 30 movw $edd_mbr_sig_start, %di # Default to edd=on
26 jz done_cl 31
27 movl %cs:(cmd_line_ptr), %esi 32 movl %cs:(cmd_line_ptr), %esi
28# ds:esi has the pointer to the command line now 33 andl %esi, %esi
29 movl $(COMMAND_LINE_SIZE-7), %ecx 34 jz old_cl # Old boot protocol?
30# loop through kernel command line one byte at a time 35
31cl_loop: 36# Convert to a real-mode pointer in fs:si
32 cmpl $EDD_CL_EQUALS, (%si) 37 movl %esi, %eax
38 shrl $4, %eax
39 movw %ax, %fs
40 andw $0xf, %si
41 jmp have_cl_pointer
42
43# Old-style boot protocol?
44old_cl:
45 push %ds # aka INITSEG
46 pop %fs
47
48 cmpw $0xa33f, (0x20)
49 jne done_cl # No command line at all?
50 movw (0x22), %si # Pointer relative to INITSEG
51
52# fs:si has the pointer to the command line now
53have_cl_pointer:
54
55# Loop through kernel command line one byte at a time. Just in
56# case the loader is buggy and failed to null-terminate the command line
57# terminate if we get close enough to the end of the segment that we
58# cannot fit "edd=XX"...
59cl_atspace:
60 cmpw $-5, %si # Watch for segment wraparound
61 jae done_cl
62 movl %fs:(%si), %eax
63 andb %al, %al # End of line?
64 jz done_cl
65 cmpl $EDD_CL_EQUALS, %eax
33 jz found_edd_equals 66 jz found_edd_equals
34 incl %esi 67 cmpb $0x20, %al # <= space consider whitespace
35 loop cl_loop 68 ja cl_skipword
36 jmp done_cl 69 incw %si
70 jmp cl_atspace
71
72cl_skipword:
73 cmpw $-5, %si # Watch for segment wraparound
74 jae done_cl
75 movb %fs:(%si), %al # End of string?
76 andb %al, %al
77 jz done_cl
78 cmpb $0x20, %al
79 jbe cl_atspace
80 incw %si
81 jmp cl_skipword
82
37found_edd_equals: 83found_edd_equals:
38# only looking at first two characters after equals 84# only looking at first two characters after equals
39 addl $4, %esi 85# late overrides early on the command line, so keep going after finding something
40 cmpw $EDD_CL_OFF, (%si) # edd=of 86 movw %fs:4(%si), %ax
41 jz do_edd_off 87 cmpw $EDD_CL_OFF, %ax # edd=of
42 cmpw $EDD_CL_SKIP, (%si) # edd=sk 88 je do_edd_off
43 jz do_edd_skipmbr 89 cmpw $EDD_CL_SKIP, %ax # edd=sk
44 jmp done_cl 90 je do_edd_skipmbr
91 cmpw $EDD_CL_ON, %ax # edd=on
92 je do_edd_on
93 jmp cl_skipword
45do_edd_skipmbr: 94do_edd_skipmbr:
46 popl %esi 95 movw $edd_start, %di
47 jmp edd_start 96 jmp cl_skipword
48do_edd_off: 97do_edd_off:
49 popl %esi 98 movw $edd_done, %di
50 jmp edd_done 99 jmp cl_skipword
100do_edd_on:
101 movw $edd_mbr_sig_start, %di
102 jmp cl_skipword
103
51done_cl: 104done_cl:
52 popl %esi 105 popl %esi
53 106 jmpw *%di
54 107
55# Read the first sector of each BIOS disk device and store the 4-byte signature 108# Read the first sector of each BIOS disk device and store the 4-byte signature
56edd_mbr_sig_start: 109edd_mbr_sig_start:
diff --git a/arch/i386/boot/setup.S b/arch/i386/boot/setup.S
index d2b684cd620a..3aec4538a113 100644
--- a/arch/i386/boot/setup.S
+++ b/arch/i386/boot/setup.S
@@ -494,12 +494,12 @@ no_voyager:
494 movw %cs, %ax # aka SETUPSEG 494 movw %cs, %ax # aka SETUPSEG
495 subw $DELTA_INITSEG, %ax # aka INITSEG 495 subw $DELTA_INITSEG, %ax # aka INITSEG
496 movw %ax, %ds 496 movw %ax, %ds
497 movw $0, (0x1ff) # default is no pointing device 497 movb $0, (0x1ff) # default is no pointing device
498 int $0x11 # int 0x11: equipment list 498 int $0x11 # int 0x11: equipment list
499 testb $0x04, %al # check if mouse installed 499 testb $0x04, %al # check if mouse installed
500 jz no_psmouse 500 jz no_psmouse
501 501
502 movw $0xAA, (0x1ff) # device present 502 movb $0xAA, (0x1ff) # device present
503no_psmouse: 503no_psmouse:
504 504
505#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) 505#if defined(CONFIG_X86_SPEEDSTEP_SMI) || defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE)
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 89ebb7a316ab..1a29bfa26d0c 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/defconfig
@@ -1,41 +1,51 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-git5
4# Tue Sep 26 09:30:47 2006
3# 5#
4CONFIG_X86_32=y 6CONFIG_X86_32=y
7CONFIG_GENERIC_TIME=y
8CONFIG_LOCKDEP_SUPPORT=y
9CONFIG_STACKTRACE_SUPPORT=y
5CONFIG_SEMAPHORE_SLEEPERS=y 10CONFIG_SEMAPHORE_SLEEPERS=y
6CONFIG_X86=y 11CONFIG_X86=y
7CONFIG_MMU=y 12CONFIG_MMU=y
8CONFIG_GENERIC_ISA_DMA=y 13CONFIG_GENERIC_ISA_DMA=y
9CONFIG_GENERIC_IOMAP=y 14CONFIG_GENERIC_IOMAP=y
15CONFIG_GENERIC_HWEIGHT=y
10CONFIG_ARCH_MAY_HAVE_PC_FDC=y 16CONFIG_ARCH_MAY_HAVE_PC_FDC=y
11CONFIG_DMI=y 17CONFIG_DMI=y
18CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
12 19
13# 20#
14# Code maturity level options 21# Code maturity level options
15# 22#
16CONFIG_EXPERIMENTAL=y 23CONFIG_EXPERIMENTAL=y
17CONFIG_BROKEN_ON_SMP=y 24CONFIG_LOCK_KERNEL=y
18CONFIG_INIT_ENV_ARG_LIMIT=32 25CONFIG_INIT_ENV_ARG_LIMIT=32
19 26
20# 27#
21# General setup 28# General setup
22# 29#
23CONFIG_LOCALVERSION="" 30CONFIG_LOCALVERSION=""
24# CONFIG_LOCALVERSION_AUTO is not set 31CONFIG_LOCALVERSION_AUTO=y
25CONFIG_SWAP=y 32CONFIG_SWAP=y
26CONFIG_SYSVIPC=y 33CONFIG_SYSVIPC=y
27# CONFIG_POSIX_MQUEUE is not set 34CONFIG_POSIX_MQUEUE=y
28# CONFIG_BSD_PROCESS_ACCT is not set 35# CONFIG_BSD_PROCESS_ACCT is not set
29CONFIG_SYSCTL=y 36# CONFIG_TASKSTATS is not set
30# CONFIG_AUDIT is not set 37# CONFIG_AUDIT is not set
31CONFIG_IKCONFIG=y 38CONFIG_IKCONFIG=y
32CONFIG_IKCONFIG_PROC=y 39CONFIG_IKCONFIG_PROC=y
40# CONFIG_CPUSETS is not set
41# CONFIG_RELAY is not set
33CONFIG_INITRAMFS_SOURCE="" 42CONFIG_INITRAMFS_SOURCE=""
34CONFIG_UID16=y
35CONFIG_VM86=y
36CONFIG_CC_OPTIMIZE_FOR_SIZE=y 43CONFIG_CC_OPTIMIZE_FOR_SIZE=y
37# CONFIG_EMBEDDED is not set 44# CONFIG_EMBEDDED is not set
45CONFIG_UID16=y
46CONFIG_SYSCTL=y
38CONFIG_KALLSYMS=y 47CONFIG_KALLSYMS=y
48CONFIG_KALLSYMS_ALL=y
39# CONFIG_KALLSYMS_EXTRA_PASS is not set 49# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_HOTPLUG=y 50CONFIG_HOTPLUG=y
41CONFIG_PRINTK=y 51CONFIG_PRINTK=y
@@ -45,11 +55,9 @@ CONFIG_BASE_FULL=y
45CONFIG_FUTEX=y 55CONFIG_FUTEX=y
46CONFIG_EPOLL=y 56CONFIG_EPOLL=y
47CONFIG_SHMEM=y 57CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52CONFIG_SLAB=y 58CONFIG_SLAB=y
59CONFIG_VM_EVENT_COUNTERS=y
60CONFIG_RT_MUTEXES=y
53# CONFIG_TINY_SHMEM is not set 61# CONFIG_TINY_SHMEM is not set
54CONFIG_BASE_SMALL=0 62CONFIG_BASE_SMALL=0
55# CONFIG_SLOB is not set 63# CONFIG_SLOB is not set
@@ -60,41 +68,45 @@ CONFIG_BASE_SMALL=0
60CONFIG_MODULES=y 68CONFIG_MODULES=y
61CONFIG_MODULE_UNLOAD=y 69CONFIG_MODULE_UNLOAD=y
62CONFIG_MODULE_FORCE_UNLOAD=y 70CONFIG_MODULE_FORCE_UNLOAD=y
63CONFIG_OBSOLETE_MODPARM=y
64# CONFIG_MODVERSIONS is not set 71# CONFIG_MODVERSIONS is not set
65# CONFIG_MODULE_SRCVERSION_ALL is not set 72# CONFIG_MODULE_SRCVERSION_ALL is not set
66# CONFIG_KMOD is not set 73# CONFIG_KMOD is not set
74CONFIG_STOP_MACHINE=y
67 75
68# 76#
69# Block layer 77# Block layer
70# 78#
71# CONFIG_LBD is not set 79CONFIG_LBD=y
80# CONFIG_BLK_DEV_IO_TRACE is not set
81# CONFIG_LSF is not set
72 82
73# 83#
74# IO Schedulers 84# IO Schedulers
75# 85#
76CONFIG_IOSCHED_NOOP=y 86CONFIG_IOSCHED_NOOP=y
77# CONFIG_IOSCHED_AS is not set 87CONFIG_IOSCHED_AS=y
78# CONFIG_IOSCHED_DEADLINE is not set 88CONFIG_IOSCHED_DEADLINE=y
79CONFIG_IOSCHED_CFQ=y 89CONFIG_IOSCHED_CFQ=y
80# CONFIG_DEFAULT_AS is not set 90CONFIG_DEFAULT_AS=y
81# CONFIG_DEFAULT_DEADLINE is not set 91# CONFIG_DEFAULT_DEADLINE is not set
82CONFIG_DEFAULT_CFQ=y 92# CONFIG_DEFAULT_CFQ is not set
83# CONFIG_DEFAULT_NOOP is not set 93# CONFIG_DEFAULT_NOOP is not set
84CONFIG_DEFAULT_IOSCHED="cfq" 94CONFIG_DEFAULT_IOSCHED="anticipatory"
85 95
86# 96#
87# Processor type and features 97# Processor type and features
88# 98#
89CONFIG_X86_PC=y 99CONFIG_SMP=y
100# CONFIG_X86_PC is not set
90# CONFIG_X86_ELAN is not set 101# CONFIG_X86_ELAN is not set
91# CONFIG_X86_VOYAGER is not set 102# CONFIG_X86_VOYAGER is not set
92# CONFIG_X86_NUMAQ is not set 103# CONFIG_X86_NUMAQ is not set
93# CONFIG_X86_SUMMIT is not set 104# CONFIG_X86_SUMMIT is not set
94# CONFIG_X86_BIGSMP is not set 105# CONFIG_X86_BIGSMP is not set
95# CONFIG_X86_VISWS is not set 106# CONFIG_X86_VISWS is not set
96# CONFIG_X86_GENERICARCH is not set 107CONFIG_X86_GENERICARCH=y
97# CONFIG_X86_ES7000 is not set 108# CONFIG_X86_ES7000 is not set
109CONFIG_X86_CYCLONE_TIMER=y
98# CONFIG_M386 is not set 110# CONFIG_M386 is not set
99# CONFIG_M486 is not set 111# CONFIG_M486 is not set
100# CONFIG_M586 is not set 112# CONFIG_M586 is not set
@@ -102,11 +114,11 @@ CONFIG_X86_PC=y
102# CONFIG_M586MMX is not set 114# CONFIG_M586MMX is not set
103# CONFIG_M686 is not set 115# CONFIG_M686 is not set
104# CONFIG_MPENTIUMII is not set 116# CONFIG_MPENTIUMII is not set
105# CONFIG_MPENTIUMIII is not set 117CONFIG_MPENTIUMIII=y
106# CONFIG_MPENTIUMM is not set 118# CONFIG_MPENTIUMM is not set
107# CONFIG_MPENTIUM4 is not set 119# CONFIG_MPENTIUM4 is not set
108# CONFIG_MK6 is not set 120# CONFIG_MK6 is not set
109CONFIG_MK7=y 121# CONFIG_MK7 is not set
110# CONFIG_MK8 is not set 122# CONFIG_MK8 is not set
111# CONFIG_MCRUSOE is not set 123# CONFIG_MCRUSOE is not set
112# CONFIG_MEFFICEON is not set 124# CONFIG_MEFFICEON is not set
@@ -117,10 +129,10 @@ CONFIG_MK7=y
117# CONFIG_MGEODE_LX is not set 129# CONFIG_MGEODE_LX is not set
118# CONFIG_MCYRIXIII is not set 130# CONFIG_MCYRIXIII is not set
119# CONFIG_MVIAC3_2 is not set 131# CONFIG_MVIAC3_2 is not set
120# CONFIG_X86_GENERIC is not set 132CONFIG_X86_GENERIC=y
121CONFIG_X86_CMPXCHG=y 133CONFIG_X86_CMPXCHG=y
122CONFIG_X86_XADD=y 134CONFIG_X86_XADD=y
123CONFIG_X86_L1_CACHE_SHIFT=6 135CONFIG_X86_L1_CACHE_SHIFT=7
124CONFIG_RWSEM_XCHGADD_ALGORITHM=y 136CONFIG_RWSEM_XCHGADD_ALGORITHM=y
125CONFIG_GENERIC_CALIBRATE_DELAY=y 137CONFIG_GENERIC_CALIBRATE_DELAY=y
126CONFIG_X86_WP_WORKS_OK=y 138CONFIG_X86_WP_WORKS_OK=y
@@ -131,26 +143,28 @@ CONFIG_X86_CMPXCHG64=y
131CONFIG_X86_GOOD_APIC=y 143CONFIG_X86_GOOD_APIC=y
132CONFIG_X86_INTEL_USERCOPY=y 144CONFIG_X86_INTEL_USERCOPY=y
133CONFIG_X86_USE_PPRO_CHECKSUM=y 145CONFIG_X86_USE_PPRO_CHECKSUM=y
134CONFIG_X86_USE_3DNOW=y
135CONFIG_X86_TSC=y 146CONFIG_X86_TSC=y
136# CONFIG_HPET_TIMER is not set 147CONFIG_HPET_TIMER=y
137# CONFIG_SMP is not set 148CONFIG_HPET_EMULATE_RTC=y
138CONFIG_PREEMPT_NONE=y 149CONFIG_NR_CPUS=32
139# CONFIG_PREEMPT_VOLUNTARY is not set 150CONFIG_SCHED_SMT=y
151CONFIG_SCHED_MC=y
152# CONFIG_PREEMPT_NONE is not set
153CONFIG_PREEMPT_VOLUNTARY=y
140# CONFIG_PREEMPT is not set 154# CONFIG_PREEMPT is not set
141CONFIG_X86_UP_APIC=y 155CONFIG_PREEMPT_BKL=y
142CONFIG_X86_UP_IOAPIC=y
143CONFIG_X86_LOCAL_APIC=y 156CONFIG_X86_LOCAL_APIC=y
144CONFIG_X86_IO_APIC=y 157CONFIG_X86_IO_APIC=y
145CONFIG_X86_MCE=y 158CONFIG_X86_MCE=y
146CONFIG_X86_MCE_NONFATAL=y 159CONFIG_X86_MCE_NONFATAL=y
147# CONFIG_X86_MCE_P4THERMAL is not set 160CONFIG_X86_MCE_P4THERMAL=y
161CONFIG_VM86=y
148# CONFIG_TOSHIBA is not set 162# CONFIG_TOSHIBA is not set
149# CONFIG_I8K is not set 163# CONFIG_I8K is not set
150# CONFIG_X86_REBOOTFIXUPS is not set 164# CONFIG_X86_REBOOTFIXUPS is not set
151# CONFIG_MICROCODE is not set 165CONFIG_MICROCODE=y
152# CONFIG_X86_MSR is not set 166CONFIG_X86_MSR=y
153# CONFIG_X86_CPUID is not set 167CONFIG_X86_CPUID=y
154 168
155# 169#
156# Firmware Drivers 170# Firmware Drivers
@@ -158,68 +172,67 @@ CONFIG_X86_MCE_NONFATAL=y
158# CONFIG_EDD is not set 172# CONFIG_EDD is not set
159# CONFIG_DELL_RBU is not set 173# CONFIG_DELL_RBU is not set
160# CONFIG_DCDBAS is not set 174# CONFIG_DCDBAS is not set
161CONFIG_NOHIGHMEM=y 175# CONFIG_NOHIGHMEM is not set
162# CONFIG_HIGHMEM4G is not set 176CONFIG_HIGHMEM4G=y
163# CONFIG_HIGHMEM64G is not set 177# CONFIG_HIGHMEM64G is not set
164CONFIG_VMSPLIT_3G=y
165# CONFIG_VMSPLIT_3G_OPT is not set
166# CONFIG_VMSPLIT_2G is not set
167# CONFIG_VMSPLIT_1G is not set
168CONFIG_PAGE_OFFSET=0xC0000000 178CONFIG_PAGE_OFFSET=0xC0000000
169CONFIG_ARCH_FLATMEM_ENABLE=y 179CONFIG_HIGHMEM=y
170CONFIG_ARCH_SPARSEMEM_ENABLE=y
171CONFIG_ARCH_SELECT_MEMORY_MODEL=y
172CONFIG_SELECT_MEMORY_MODEL=y 180CONFIG_SELECT_MEMORY_MODEL=y
173CONFIG_FLATMEM_MANUAL=y 181CONFIG_FLATMEM_MANUAL=y
174# CONFIG_DISCONTIGMEM_MANUAL is not set 182# CONFIG_DISCONTIGMEM_MANUAL is not set
175# CONFIG_SPARSEMEM_MANUAL is not set 183# CONFIG_SPARSEMEM_MANUAL is not set
176CONFIG_FLATMEM=y 184CONFIG_FLATMEM=y
177CONFIG_FLAT_NODE_MEM_MAP=y 185CONFIG_FLAT_NODE_MEM_MAP=y
178CONFIG_SPARSEMEM_STATIC=y 186# CONFIG_SPARSEMEM_STATIC is not set
179CONFIG_SPLIT_PTLOCK_CPUS=4 187CONFIG_SPLIT_PTLOCK_CPUS=4
188CONFIG_RESOURCES_64BIT=y
189# CONFIG_HIGHPTE is not set
180# CONFIG_MATH_EMULATION is not set 190# CONFIG_MATH_EMULATION is not set
181CONFIG_MTRR=y 191CONFIG_MTRR=y
182# CONFIG_EFI is not set 192# CONFIG_EFI is not set
193# CONFIG_IRQBALANCE is not set
183CONFIG_REGPARM=y 194CONFIG_REGPARM=y
184# CONFIG_SECCOMP is not set 195CONFIG_SECCOMP=y
185CONFIG_HZ_100=y 196# CONFIG_HZ_100 is not set
186# CONFIG_HZ_250 is not set 197CONFIG_HZ_250=y
187# CONFIG_HZ_1000 is not set 198# CONFIG_HZ_1000 is not set
188CONFIG_HZ=100 199CONFIG_HZ=250
189# CONFIG_KEXEC is not set 200# CONFIG_KEXEC is not set
201# CONFIG_CRASH_DUMP is not set
190CONFIG_PHYSICAL_START=0x100000 202CONFIG_PHYSICAL_START=0x100000
191CONFIG_DOUBLEFAULT=y 203# CONFIG_HOTPLUG_CPU is not set
204CONFIG_COMPAT_VDSO=y
205CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
192 206
193# 207#
194# Power management options (ACPI, APM) 208# Power management options (ACPI, APM)
195# 209#
196CONFIG_PM=y 210CONFIG_PM=y
197# CONFIG_PM_LEGACY is not set 211CONFIG_PM_LEGACY=y
198# CONFIG_PM_DEBUG is not set 212# CONFIG_PM_DEBUG is not set
199CONFIG_SOFTWARE_SUSPEND=y
200CONFIG_PM_STD_PARTITION=""
201 213
202# 214#
203# ACPI (Advanced Configuration and Power Interface) Support 215# ACPI (Advanced Configuration and Power Interface) Support
204# 216#
205CONFIG_ACPI=y 217CONFIG_ACPI=y
206# CONFIG_ACPI_SLEEP is not set 218CONFIG_ACPI_AC=y
207# CONFIG_ACPI_AC is not set 219CONFIG_ACPI_BATTERY=y
208# CONFIG_ACPI_BATTERY is not set 220CONFIG_ACPI_BUTTON=y
209# CONFIG_ACPI_BUTTON is not set
210# CONFIG_ACPI_VIDEO is not set 221# CONFIG_ACPI_VIDEO is not set
211# CONFIG_ACPI_HOTKEY is not set 222# CONFIG_ACPI_HOTKEY is not set
212# CONFIG_ACPI_FAN is not set 223CONFIG_ACPI_FAN=y
213# CONFIG_ACPI_PROCESSOR is not set 224# CONFIG_ACPI_DOCK is not set
225CONFIG_ACPI_PROCESSOR=y
226CONFIG_ACPI_THERMAL=y
214# CONFIG_ACPI_ASUS is not set 227# CONFIG_ACPI_ASUS is not set
215# CONFIG_ACPI_IBM is not set 228# CONFIG_ACPI_IBM is not set
216# CONFIG_ACPI_TOSHIBA is not set 229# CONFIG_ACPI_TOSHIBA is not set
217CONFIG_ACPI_BLACKLIST_YEAR=0 230CONFIG_ACPI_BLACKLIST_YEAR=2001
218# CONFIG_ACPI_DEBUG is not set 231CONFIG_ACPI_DEBUG=y
219CONFIG_ACPI_EC=y 232CONFIG_ACPI_EC=y
220CONFIG_ACPI_POWER=y 233CONFIG_ACPI_POWER=y
221CONFIG_ACPI_SYSTEM=y 234CONFIG_ACPI_SYSTEM=y
222# CONFIG_X86_PM_TIMER is not set 235CONFIG_X86_PM_TIMER=y
223# CONFIG_ACPI_CONTAINER is not set 236# CONFIG_ACPI_CONTAINER is not set
224 237
225# 238#
@@ -230,7 +243,41 @@ CONFIG_ACPI_SYSTEM=y
230# 243#
231# CPU Frequency scaling 244# CPU Frequency scaling
232# 245#
233# CONFIG_CPU_FREQ is not set 246CONFIG_CPU_FREQ=y
247CONFIG_CPU_FREQ_TABLE=y
248CONFIG_CPU_FREQ_DEBUG=y
249CONFIG_CPU_FREQ_STAT=y
250# CONFIG_CPU_FREQ_STAT_DETAILS is not set
251CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE=y
252# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
253CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
254# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
255CONFIG_CPU_FREQ_GOV_USERSPACE=y
256CONFIG_CPU_FREQ_GOV_ONDEMAND=y
257# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set
258
259#
260# CPUFreq processor drivers
261#
262CONFIG_X86_ACPI_CPUFREQ=y
263# CONFIG_X86_POWERNOW_K6 is not set
264# CONFIG_X86_POWERNOW_K7 is not set
265CONFIG_X86_POWERNOW_K8=y
266CONFIG_X86_POWERNOW_K8_ACPI=y
267# CONFIG_X86_GX_SUSPMOD is not set
268# CONFIG_X86_SPEEDSTEP_CENTRINO is not set
269# CONFIG_X86_SPEEDSTEP_ICH is not set
270# CONFIG_X86_SPEEDSTEP_SMI is not set
271# CONFIG_X86_P4_CLOCKMOD is not set
272# CONFIG_X86_CPUFREQ_NFORCE2 is not set
273# CONFIG_X86_LONGRUN is not set
274# CONFIG_X86_LONGHAUL is not set
275
276#
277# shared options
278#
279CONFIG_X86_ACPI_CPUFREQ_PROC_INTF=y
280# CONFIG_X86_SPEEDSTEP_LIB is not set
234 281
235# 282#
236# Bus options (PCI, PCMCIA, EISA, MCA, ISA) 283# Bus options (PCI, PCMCIA, EISA, MCA, ISA)
@@ -244,12 +291,13 @@ CONFIG_PCI_BIOS=y
244CONFIG_PCI_DIRECT=y 291CONFIG_PCI_DIRECT=y
245CONFIG_PCI_MMCONFIG=y 292CONFIG_PCI_MMCONFIG=y
246# CONFIG_PCIEPORTBUS is not set 293# CONFIG_PCIEPORTBUS is not set
247# CONFIG_PCI_MSI is not set 294CONFIG_PCI_MSI=y
248# CONFIG_PCI_LEGACY_PROC is not set 295# CONFIG_PCI_DEBUG is not set
249CONFIG_ISA_DMA_API=y 296CONFIG_ISA_DMA_API=y
250# CONFIG_ISA is not set 297# CONFIG_ISA is not set
251# CONFIG_MCA is not set 298# CONFIG_MCA is not set
252# CONFIG_SCx200 is not set 299# CONFIG_SCx200 is not set
300CONFIG_K8_NB=y
253 301
254# 302#
255# PCCARD (PCMCIA/CardBus) support 303# PCCARD (PCMCIA/CardBus) support
@@ -278,93 +326,54 @@ CONFIG_NET=y
278# 326#
279# CONFIG_NETDEBUG is not set 327# CONFIG_NETDEBUG is not set
280CONFIG_PACKET=y 328CONFIG_PACKET=y
281CONFIG_PACKET_MMAP=y 329# CONFIG_PACKET_MMAP is not set
282CONFIG_UNIX=y 330CONFIG_UNIX=y
331CONFIG_XFRM=y
332# CONFIG_XFRM_USER is not set
333# CONFIG_XFRM_SUB_POLICY is not set
283# CONFIG_NET_KEY is not set 334# CONFIG_NET_KEY is not set
284CONFIG_INET=y 335CONFIG_INET=y
285# CONFIG_IP_MULTICAST is not set 336CONFIG_IP_MULTICAST=y
286# CONFIG_IP_ADVANCED_ROUTER is not set 337# CONFIG_IP_ADVANCED_ROUTER is not set
287CONFIG_IP_FIB_HASH=y 338CONFIG_IP_FIB_HASH=y
288# CONFIG_IP_PNP is not set 339CONFIG_IP_PNP=y
340CONFIG_IP_PNP_DHCP=y
341# CONFIG_IP_PNP_BOOTP is not set
342# CONFIG_IP_PNP_RARP is not set
289# CONFIG_NET_IPIP is not set 343# CONFIG_NET_IPIP is not set
290# CONFIG_NET_IPGRE is not set 344# CONFIG_NET_IPGRE is not set
345# CONFIG_IP_MROUTE is not set
291# CONFIG_ARPD is not set 346# CONFIG_ARPD is not set
292# CONFIG_SYN_COOKIES is not set 347# CONFIG_SYN_COOKIES is not set
293# CONFIG_INET_AH is not set 348# CONFIG_INET_AH is not set
294# CONFIG_INET_ESP is not set 349# CONFIG_INET_ESP is not set
295# CONFIG_INET_IPCOMP is not set 350# CONFIG_INET_IPCOMP is not set
351# CONFIG_INET_XFRM_TUNNEL is not set
296# CONFIG_INET_TUNNEL is not set 352# CONFIG_INET_TUNNEL is not set
297# CONFIG_INET_DIAG is not set 353CONFIG_INET_XFRM_MODE_TRANSPORT=y
354CONFIG_INET_XFRM_MODE_TUNNEL=y
355CONFIG_INET_DIAG=y
356CONFIG_INET_TCP_DIAG=y
298# CONFIG_TCP_CONG_ADVANCED is not set 357# CONFIG_TCP_CONG_ADVANCED is not set
299CONFIG_TCP_CONG_BIC=y 358CONFIG_TCP_CONG_CUBIC=y
300 359CONFIG_DEFAULT_TCP_CONG="cubic"
301# 360CONFIG_IPV6=y
302# IP: Virtual Server Configuration 361# CONFIG_IPV6_PRIVACY is not set
303# 362# CONFIG_IPV6_ROUTER_PREF is not set
304# CONFIG_IP_VS is not set 363# CONFIG_INET6_AH is not set
305# CONFIG_IPV6 is not set 364# CONFIG_INET6_ESP is not set
306CONFIG_NETFILTER=y 365# CONFIG_INET6_IPCOMP is not set
307# CONFIG_NETFILTER_DEBUG is not set 366# CONFIG_IPV6_MIP6 is not set
308 367# CONFIG_INET6_XFRM_TUNNEL is not set
309# 368# CONFIG_INET6_TUNNEL is not set
310# Core Netfilter Configuration 369CONFIG_INET6_XFRM_MODE_TRANSPORT=y
311# 370CONFIG_INET6_XFRM_MODE_TUNNEL=y
312# CONFIG_NETFILTER_NETLINK is not set 371# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
313CONFIG_NETFILTER_XTABLES=y 372# CONFIG_IPV6_TUNNEL is not set
314# CONFIG_NETFILTER_XT_TARGET_CLASSIFY is not set 373# CONFIG_IPV6_SUBTREES is not set
315# CONFIG_NETFILTER_XT_TARGET_MARK is not set 374# CONFIG_IPV6_MULTIPLE_TABLES is not set
316# CONFIG_NETFILTER_XT_TARGET_NFQUEUE is not set 375# CONFIG_NETWORK_SECMARK is not set
317# CONFIG_NETFILTER_XT_MATCH_COMMENT is not set 376# CONFIG_NETFILTER is not set
318# CONFIG_NETFILTER_XT_MATCH_CONNTRACK is not set
319# CONFIG_NETFILTER_XT_MATCH_DCCP is not set
320# CONFIG_NETFILTER_XT_MATCH_HELPER is not set
321# CONFIG_NETFILTER_XT_MATCH_LENGTH is not set
322CONFIG_NETFILTER_XT_MATCH_LIMIT=y
323CONFIG_NETFILTER_XT_MATCH_MAC=y
324# CONFIG_NETFILTER_XT_MATCH_MARK is not set
325# CONFIG_NETFILTER_XT_MATCH_PKTTYPE is not set
326# CONFIG_NETFILTER_XT_MATCH_REALM is not set
327# CONFIG_NETFILTER_XT_MATCH_SCTP is not set
328CONFIG_NETFILTER_XT_MATCH_STATE=y
329# CONFIG_NETFILTER_XT_MATCH_STRING is not set
330# CONFIG_NETFILTER_XT_MATCH_TCPMSS is not set
331
332#
333# IP: Netfilter Configuration
334#
335CONFIG_IP_NF_CONNTRACK=y
336# CONFIG_IP_NF_CT_ACCT is not set
337# CONFIG_IP_NF_CONNTRACK_MARK is not set
338# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
339# CONFIG_IP_NF_CT_PROTO_SCTP is not set
340CONFIG_IP_NF_FTP=y
341# CONFIG_IP_NF_IRC is not set
342# CONFIG_IP_NF_NETBIOS_NS is not set
343# CONFIG_IP_NF_TFTP is not set
344# CONFIG_IP_NF_AMANDA is not set
345# CONFIG_IP_NF_PPTP is not set
346# CONFIG_IP_NF_QUEUE is not set
347CONFIG_IP_NF_IPTABLES=y
348# CONFIG_IP_NF_MATCH_IPRANGE is not set
349# CONFIG_IP_NF_MATCH_MULTIPORT is not set
350# CONFIG_IP_NF_MATCH_TOS is not set
351# CONFIG_IP_NF_MATCH_RECENT is not set
352# CONFIG_IP_NF_MATCH_ECN is not set
353# CONFIG_IP_NF_MATCH_DSCP is not set
354# CONFIG_IP_NF_MATCH_AH_ESP is not set
355# CONFIG_IP_NF_MATCH_TTL is not set
356# CONFIG_IP_NF_MATCH_OWNER is not set
357# CONFIG_IP_NF_MATCH_ADDRTYPE is not set
358# CONFIG_IP_NF_MATCH_HASHLIMIT is not set
359CONFIG_IP_NF_FILTER=y
360# CONFIG_IP_NF_TARGET_REJECT is not set
361CONFIG_IP_NF_TARGET_LOG=y
362# CONFIG_IP_NF_TARGET_ULOG is not set
363# CONFIG_IP_NF_TARGET_TCPMSS is not set
364# CONFIG_IP_NF_NAT is not set
365# CONFIG_IP_NF_MANGLE is not set
366# CONFIG_IP_NF_RAW is not set
367# CONFIG_IP_NF_ARPTABLES is not set
368 377
369# 378#
370# DCCP Configuration (EXPERIMENTAL) 379# DCCP Configuration (EXPERIMENTAL)
@@ -389,7 +398,6 @@ CONFIG_IP_NF_TARGET_LOG=y
389# CONFIG_ATALK is not set 398# CONFIG_ATALK is not set
390# CONFIG_X25 is not set 399# CONFIG_X25 is not set
391# CONFIG_LAPB is not set 400# CONFIG_LAPB is not set
392# CONFIG_NET_DIVERT is not set
393# CONFIG_ECONET is not set 401# CONFIG_ECONET is not set
394# CONFIG_WAN_ROUTER is not set 402# CONFIG_WAN_ROUTER is not set
395 403
@@ -402,6 +410,7 @@ CONFIG_IP_NF_TARGET_LOG=y
402# Network testing 410# Network testing
403# 411#
404# CONFIG_NET_PKTGEN is not set 412# CONFIG_NET_PKTGEN is not set
413# CONFIG_NET_TCPPROBE is not set
405# CONFIG_HAMRADIO is not set 414# CONFIG_HAMRADIO is not set
406# CONFIG_IRDA is not set 415# CONFIG_IRDA is not set
407# CONFIG_BT is not set 416# CONFIG_BT is not set
@@ -416,7 +425,9 @@ CONFIG_IP_NF_TARGET_LOG=y
416# 425#
417CONFIG_STANDALONE=y 426CONFIG_STANDALONE=y
418CONFIG_PREVENT_FIRMWARE_BUILD=y 427CONFIG_PREVENT_FIRMWARE_BUILD=y
419# CONFIG_FW_LOADER is not set 428CONFIG_FW_LOADER=y
429# CONFIG_DEBUG_DRIVER is not set
430# CONFIG_SYS_HYPERVISOR is not set
420 431
421# 432#
422# Connector - unified userspace <-> kernelspace linker 433# Connector - unified userspace <-> kernelspace linker
@@ -431,13 +442,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
431# 442#
432# Parallel port support 443# Parallel port support
433# 444#
434CONFIG_PARPORT=y 445# CONFIG_PARPORT is not set
435CONFIG_PARPORT_PC=y
436# CONFIG_PARPORT_SERIAL is not set
437# CONFIG_PARPORT_PC_FIFO is not set
438# CONFIG_PARPORT_PC_SUPERIO is not set
439# CONFIG_PARPORT_GSC is not set
440CONFIG_PARPORT_1284=y
441 446
442# 447#
443# Plug and Play support 448# Plug and Play support
@@ -447,8 +452,7 @@ CONFIG_PARPORT_1284=y
447# 452#
448# Block devices 453# Block devices
449# 454#
450# CONFIG_BLK_DEV_FD is not set 455CONFIG_BLK_DEV_FD=y
451# CONFIG_PARIDE is not set
452# CONFIG_BLK_CPQ_DA is not set 456# CONFIG_BLK_CPQ_DA is not set
453# CONFIG_BLK_CPQ_CISS_DA is not set 457# CONFIG_BLK_CPQ_CISS_DA is not set
454# CONFIG_BLK_DEV_DAC960 is not set 458# CONFIG_BLK_DEV_DAC960 is not set
@@ -459,8 +463,11 @@ CONFIG_BLK_DEV_LOOP=y
459# CONFIG_BLK_DEV_NBD is not set 463# CONFIG_BLK_DEV_NBD is not set
460# CONFIG_BLK_DEV_SX8 is not set 464# CONFIG_BLK_DEV_SX8 is not set
461# CONFIG_BLK_DEV_UB is not set 465# CONFIG_BLK_DEV_UB is not set
462# CONFIG_BLK_DEV_RAM is not set 466CONFIG_BLK_DEV_RAM=y
463CONFIG_BLK_DEV_RAM_COUNT=16 467CONFIG_BLK_DEV_RAM_COUNT=16
468CONFIG_BLK_DEV_RAM_SIZE=4096
469CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
470CONFIG_BLK_DEV_INITRD=y
464# CONFIG_CDROM_PKTCDVD is not set 471# CONFIG_CDROM_PKTCDVD is not set
465# CONFIG_ATA_OVER_ETH is not set 472# CONFIG_ATA_OVER_ETH is not set
466 473
@@ -476,7 +483,7 @@ CONFIG_BLK_DEV_IDE=y
476# CONFIG_BLK_DEV_IDE_SATA is not set 483# CONFIG_BLK_DEV_IDE_SATA is not set
477# CONFIG_BLK_DEV_HD_IDE is not set 484# CONFIG_BLK_DEV_HD_IDE is not set
478CONFIG_BLK_DEV_IDEDISK=y 485CONFIG_BLK_DEV_IDEDISK=y
479# CONFIG_IDEDISK_MULTI_MODE is not set 486CONFIG_IDEDISK_MULTI_MODE=y
480CONFIG_BLK_DEV_IDECD=y 487CONFIG_BLK_DEV_IDECD=y
481# CONFIG_BLK_DEV_IDETAPE is not set 488# CONFIG_BLK_DEV_IDETAPE is not set
482# CONFIG_BLK_DEV_IDEFLOPPY is not set 489# CONFIG_BLK_DEV_IDEFLOPPY is not set
@@ -486,10 +493,10 @@ CONFIG_BLK_DEV_IDECD=y
486# 493#
487# IDE chipset support/bugfixes 494# IDE chipset support/bugfixes
488# 495#
489# CONFIG_IDE_GENERIC is not set 496CONFIG_IDE_GENERIC=y
490# CONFIG_BLK_DEV_CMD640 is not set 497# CONFIG_BLK_DEV_CMD640 is not set
491CONFIG_BLK_DEV_IDEPCI=y 498CONFIG_BLK_DEV_IDEPCI=y
492CONFIG_IDEPCI_SHARE_IRQ=y 499# CONFIG_IDEPCI_SHARE_IRQ is not set
493# CONFIG_BLK_DEV_OFFBOARD is not set 500# CONFIG_BLK_DEV_OFFBOARD is not set
494# CONFIG_BLK_DEV_GENERIC is not set 501# CONFIG_BLK_DEV_GENERIC is not set
495# CONFIG_BLK_DEV_OPTI621 is not set 502# CONFIG_BLK_DEV_OPTI621 is not set
@@ -500,7 +507,7 @@ CONFIG_IDEDMA_PCI_AUTO=y
500# CONFIG_IDEDMA_ONLYDISK is not set 507# CONFIG_IDEDMA_ONLYDISK is not set
501# CONFIG_BLK_DEV_AEC62XX is not set 508# CONFIG_BLK_DEV_AEC62XX is not set
502# CONFIG_BLK_DEV_ALI15X3 is not set 509# CONFIG_BLK_DEV_ALI15X3 is not set
503# CONFIG_BLK_DEV_AMD74XX is not set 510CONFIG_BLK_DEV_AMD74XX=y
504# CONFIG_BLK_DEV_ATIIXP is not set 511# CONFIG_BLK_DEV_ATIIXP is not set
505# CONFIG_BLK_DEV_CMD64X is not set 512# CONFIG_BLK_DEV_CMD64X is not set
506# CONFIG_BLK_DEV_TRIFLEX is not set 513# CONFIG_BLK_DEV_TRIFLEX is not set
@@ -511,7 +518,7 @@ CONFIG_IDEDMA_PCI_AUTO=y
511# CONFIG_BLK_DEV_HPT34X is not set 518# CONFIG_BLK_DEV_HPT34X is not set
512# CONFIG_BLK_DEV_HPT366 is not set 519# CONFIG_BLK_DEV_HPT366 is not set
513# CONFIG_BLK_DEV_SC1200 is not set 520# CONFIG_BLK_DEV_SC1200 is not set
514# CONFIG_BLK_DEV_PIIX is not set 521CONFIG_BLK_DEV_PIIX=y
515# CONFIG_BLK_DEV_IT821X is not set 522# CONFIG_BLK_DEV_IT821X is not set
516# CONFIG_BLK_DEV_NS87415 is not set 523# CONFIG_BLK_DEV_NS87415 is not set
517# CONFIG_BLK_DEV_PDC202XX_OLD is not set 524# CONFIG_BLK_DEV_PDC202XX_OLD is not set
@@ -521,7 +528,7 @@ CONFIG_IDEDMA_PCI_AUTO=y
521# CONFIG_BLK_DEV_SIS5513 is not set 528# CONFIG_BLK_DEV_SIS5513 is not set
522# CONFIG_BLK_DEV_SLC90E66 is not set 529# CONFIG_BLK_DEV_SLC90E66 is not set
523# CONFIG_BLK_DEV_TRM290 is not set 530# CONFIG_BLK_DEV_TRM290 is not set
524CONFIG_BLK_DEV_VIA82CXXX=y 531# CONFIG_BLK_DEV_VIA82CXXX is not set
525# CONFIG_IDE_ARM is not set 532# CONFIG_IDE_ARM is not set
526CONFIG_BLK_DEV_IDEDMA=y 533CONFIG_BLK_DEV_IDEDMA=y
527# CONFIG_IDEDMA_IVB is not set 534# CONFIG_IDEDMA_IVB is not set
@@ -533,6 +540,7 @@ CONFIG_IDEDMA_AUTO=y
533# 540#
534# CONFIG_RAID_ATTRS is not set 541# CONFIG_RAID_ATTRS is not set
535CONFIG_SCSI=y 542CONFIG_SCSI=y
543CONFIG_SCSI_NETLINK=y
536# CONFIG_SCSI_PROC_FS is not set 544# CONFIG_SCSI_PROC_FS is not set
537 545
538# 546#
@@ -541,8 +549,9 @@ CONFIG_SCSI=y
541CONFIG_BLK_DEV_SD=y 549CONFIG_BLK_DEV_SD=y
542# CONFIG_CHR_DEV_ST is not set 550# CONFIG_CHR_DEV_ST is not set
543# CONFIG_CHR_DEV_OSST is not set 551# CONFIG_CHR_DEV_OSST is not set
544# CONFIG_BLK_DEV_SR is not set 552CONFIG_BLK_DEV_SR=y
545# CONFIG_CHR_DEV_SG is not set 553# CONFIG_BLK_DEV_SR_VENDOR is not set
554CONFIG_CHR_DEV_SG=y
546# CONFIG_CHR_DEV_SCH is not set 555# CONFIG_CHR_DEV_SCH is not set
547 556
548# 557#
@@ -553,29 +562,44 @@ CONFIG_BLK_DEV_SD=y
553# CONFIG_SCSI_LOGGING is not set 562# CONFIG_SCSI_LOGGING is not set
554 563
555# 564#
556# SCSI Transport Attributes 565# SCSI Transports
557# 566#
558# CONFIG_SCSI_SPI_ATTRS is not set 567CONFIG_SCSI_SPI_ATTRS=y
559# CONFIG_SCSI_FC_ATTRS is not set 568CONFIG_SCSI_FC_ATTRS=y
560# CONFIG_SCSI_ISCSI_ATTRS is not set 569# CONFIG_SCSI_ISCSI_ATTRS is not set
561# CONFIG_SCSI_SAS_ATTRS is not set 570# CONFIG_SCSI_SAS_ATTRS is not set
571# CONFIG_SCSI_SAS_LIBSAS is not set
562 572
563# 573#
564# SCSI low-level drivers 574# SCSI low-level drivers
565# 575#
566# CONFIG_ISCSI_TCP is not set 576# CONFIG_ISCSI_TCP is not set
567# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 577CONFIG_BLK_DEV_3W_XXXX_RAID=y
568# CONFIG_SCSI_3W_9XXX is not set 578# CONFIG_SCSI_3W_9XXX is not set
569# CONFIG_SCSI_ACARD is not set 579# CONFIG_SCSI_ACARD is not set
570# CONFIG_SCSI_AACRAID is not set 580# CONFIG_SCSI_AACRAID is not set
571# CONFIG_SCSI_AIC7XXX is not set 581CONFIG_SCSI_AIC7XXX=y
582CONFIG_AIC7XXX_CMDS_PER_DEVICE=32
583CONFIG_AIC7XXX_RESET_DELAY_MS=5000
584CONFIG_AIC7XXX_DEBUG_ENABLE=y
585CONFIG_AIC7XXX_DEBUG_MASK=0
586CONFIG_AIC7XXX_REG_PRETTY_PRINT=y
572# CONFIG_SCSI_AIC7XXX_OLD is not set 587# CONFIG_SCSI_AIC7XXX_OLD is not set
573# CONFIG_SCSI_AIC79XX is not set 588CONFIG_SCSI_AIC79XX=y
589CONFIG_AIC79XX_CMDS_PER_DEVICE=32
590CONFIG_AIC79XX_RESET_DELAY_MS=4000
591# CONFIG_AIC79XX_ENABLE_RD_STRM is not set
592# CONFIG_AIC79XX_DEBUG_ENABLE is not set
593CONFIG_AIC79XX_DEBUG_MASK=0
594# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
595# CONFIG_SCSI_AIC94XX is not set
574# CONFIG_SCSI_DPT_I2O is not set 596# CONFIG_SCSI_DPT_I2O is not set
597# CONFIG_SCSI_ADVANSYS is not set
598# CONFIG_SCSI_ARCMSR is not set
575# CONFIG_MEGARAID_NEWGEN is not set 599# CONFIG_MEGARAID_NEWGEN is not set
576# CONFIG_MEGARAID_LEGACY is not set 600# CONFIG_MEGARAID_LEGACY is not set
577# CONFIG_MEGARAID_SAS is not set 601# CONFIG_MEGARAID_SAS is not set
578# CONFIG_SCSI_SATA is not set 602# CONFIG_SCSI_HPTIOP is not set
579# CONFIG_SCSI_BUSLOGIC is not set 603# CONFIG_SCSI_BUSLOGIC is not set
580# CONFIG_SCSI_DMX3191D is not set 604# CONFIG_SCSI_DMX3191D is not set
581# CONFIG_SCSI_EATA is not set 605# CONFIG_SCSI_EATA is not set
@@ -584,11 +608,9 @@ CONFIG_BLK_DEV_SD=y
584# CONFIG_SCSI_IPS is not set 608# CONFIG_SCSI_IPS is not set
585# CONFIG_SCSI_INITIO is not set 609# CONFIG_SCSI_INITIO is not set
586# CONFIG_SCSI_INIA100 is not set 610# CONFIG_SCSI_INIA100 is not set
587# CONFIG_SCSI_PPA is not set 611# CONFIG_SCSI_STEX is not set
588# CONFIG_SCSI_IMM is not set
589# CONFIG_SCSI_SYM53C8XX_2 is not set 612# CONFIG_SCSI_SYM53C8XX_2 is not set
590# CONFIG_SCSI_IPR is not set 613# CONFIG_SCSI_IPR is not set
591# CONFIG_SCSI_QLOGIC_FC is not set
592# CONFIG_SCSI_QLOGIC_1280 is not set 614# CONFIG_SCSI_QLOGIC_1280 is not set
593# CONFIG_SCSI_QLA_FC is not set 615# CONFIG_SCSI_QLA_FC is not set
594# CONFIG_SCSI_LPFC is not set 616# CONFIG_SCSI_LPFC is not set
@@ -598,22 +620,114 @@ CONFIG_BLK_DEV_SD=y
598# CONFIG_SCSI_DEBUG is not set 620# CONFIG_SCSI_DEBUG is not set
599 621
600# 622#
623# Serial ATA (prod) and Parallel ATA (experimental) drivers
624#
625CONFIG_ATA=y
626CONFIG_SATA_AHCI=y
627CONFIG_SATA_SVW=y
628CONFIG_ATA_PIIX=y
629# CONFIG_SATA_MV is not set
630CONFIG_SATA_NV=y
631# CONFIG_PDC_ADMA is not set
632# CONFIG_SATA_QSTOR is not set
633# CONFIG_SATA_PROMISE is not set
634# CONFIG_SATA_SX4 is not set
635CONFIG_SATA_SIL=y
636# CONFIG_SATA_SIL24 is not set
637# CONFIG_SATA_SIS is not set
638# CONFIG_SATA_ULI is not set
639CONFIG_SATA_VIA=y
640# CONFIG_SATA_VITESSE is not set
641CONFIG_SATA_INTEL_COMBINED=y
642# CONFIG_PATA_ALI is not set
643# CONFIG_PATA_AMD is not set
644# CONFIG_PATA_ARTOP is not set
645# CONFIG_PATA_ATIIXP is not set
646# CONFIG_PATA_CMD64X is not set
647# CONFIG_PATA_CS5520 is not set
648# CONFIG_PATA_CS5530 is not set
649# CONFIG_PATA_CS5535 is not set
650# CONFIG_PATA_CYPRESS is not set
651# CONFIG_PATA_EFAR is not set
652# CONFIG_ATA_GENERIC is not set
653# CONFIG_PATA_HPT366 is not set
654# CONFIG_PATA_HPT37X is not set
655# CONFIG_PATA_HPT3X2N is not set
656# CONFIG_PATA_HPT3X3 is not set
657# CONFIG_PATA_IT821X is not set
658# CONFIG_PATA_JMICRON is not set
659# CONFIG_PATA_LEGACY is not set
660# CONFIG_PATA_TRIFLEX is not set
661# CONFIG_PATA_MPIIX is not set
662# CONFIG_PATA_OLDPIIX is not set
663# CONFIG_PATA_NETCELL is not set
664# CONFIG_PATA_NS87410 is not set
665# CONFIG_PATA_OPTI is not set
666# CONFIG_PATA_OPTIDMA is not set
667# CONFIG_PATA_PDC_OLD is not set
668# CONFIG_PATA_QDI is not set
669# CONFIG_PATA_RADISYS is not set
670# CONFIG_PATA_RZ1000 is not set
671# CONFIG_PATA_SC1200 is not set
672# CONFIG_PATA_SERVERWORKS is not set
673# CONFIG_PATA_PDC2027X is not set
674# CONFIG_PATA_SIL680 is not set
675# CONFIG_PATA_SIS is not set
676# CONFIG_PATA_VIA is not set
677# CONFIG_PATA_WINBOND is not set
678
679#
601# Multi-device support (RAID and LVM) 680# Multi-device support (RAID and LVM)
602# 681#
603# CONFIG_MD is not set 682CONFIG_MD=y
683# CONFIG_BLK_DEV_MD is not set
684CONFIG_BLK_DEV_DM=y
685# CONFIG_DM_CRYPT is not set
686# CONFIG_DM_SNAPSHOT is not set
687# CONFIG_DM_MIRROR is not set
688# CONFIG_DM_ZERO is not set
689# CONFIG_DM_MULTIPATH is not set
604 690
605# 691#
606# Fusion MPT device support 692# Fusion MPT device support
607# 693#
608# CONFIG_FUSION is not set 694CONFIG_FUSION=y
609# CONFIG_FUSION_SPI is not set 695CONFIG_FUSION_SPI=y
610# CONFIG_FUSION_FC is not set 696# CONFIG_FUSION_FC is not set
611# CONFIG_FUSION_SAS is not set 697# CONFIG_FUSION_SAS is not set
698CONFIG_FUSION_MAX_SGE=128
699# CONFIG_FUSION_CTL is not set
612 700
613# 701#
614# IEEE 1394 (FireWire) support 702# IEEE 1394 (FireWire) support
615# 703#
616# CONFIG_IEEE1394 is not set 704CONFIG_IEEE1394=y
705
706#
707# Subsystem Options
708#
709# CONFIG_IEEE1394_VERBOSEDEBUG is not set
710# CONFIG_IEEE1394_OUI_DB is not set
711# CONFIG_IEEE1394_EXTRA_CONFIG_ROMS is not set
712# CONFIG_IEEE1394_EXPORT_FULL_API is not set
713
714#
715# Device Drivers
716#
717
718#
719# Texas Instruments PCILynx requires I2C
720#
721CONFIG_IEEE1394_OHCI1394=y
722
723#
724# Protocol Drivers
725#
726# CONFIG_IEEE1394_VIDEO1394 is not set
727# CONFIG_IEEE1394_SBP2 is not set
728# CONFIG_IEEE1394_ETH1394 is not set
729# CONFIG_IEEE1394_DV1394 is not set
730CONFIG_IEEE1394_RAWIO=y
617 731
618# 732#
619# I2O device support 733# I2O device support
@@ -652,46 +766,63 @@ CONFIG_MII=y
652# 766#
653# Tulip family network device support 767# Tulip family network device support
654# 768#
655# CONFIG_NET_TULIP is not set 769CONFIG_NET_TULIP=y
770# CONFIG_DE2104X is not set
771CONFIG_TULIP=y
772# CONFIG_TULIP_MWI is not set
773# CONFIG_TULIP_MMIO is not set
774# CONFIG_TULIP_NAPI is not set
775# CONFIG_DE4X5 is not set
776# CONFIG_WINBOND_840 is not set
777# CONFIG_DM9102 is not set
778# CONFIG_ULI526X is not set
656# CONFIG_HP100 is not set 779# CONFIG_HP100 is not set
657CONFIG_NET_PCI=y 780CONFIG_NET_PCI=y
658# CONFIG_PCNET32 is not set 781# CONFIG_PCNET32 is not set
659# CONFIG_AMD8111_ETH is not set 782# CONFIG_AMD8111_ETH is not set
660# CONFIG_ADAPTEC_STARFIRE is not set 783# CONFIG_ADAPTEC_STARFIRE is not set
661# CONFIG_B44 is not set 784CONFIG_B44=y
662# CONFIG_FORCEDETH is not set 785CONFIG_FORCEDETH=y
786# CONFIG_FORCEDETH_NAPI is not set
663# CONFIG_DGRS is not set 787# CONFIG_DGRS is not set
664# CONFIG_EEPRO100 is not set 788# CONFIG_EEPRO100 is not set
665CONFIG_E100=y 789CONFIG_E100=y
666# CONFIG_FEALNX is not set 790# CONFIG_FEALNX is not set
667# CONFIG_NATSEMI is not set 791# CONFIG_NATSEMI is not set
668# CONFIG_NE2K_PCI is not set 792# CONFIG_NE2K_PCI is not set
669# CONFIG_8139CP is not set 793CONFIG_8139CP=y
670# CONFIG_8139TOO is not set 794CONFIG_8139TOO=y
795# CONFIG_8139TOO_PIO is not set
796# CONFIG_8139TOO_TUNE_TWISTER is not set
797# CONFIG_8139TOO_8129 is not set
798# CONFIG_8139_OLD_RX_RESET is not set
671# CONFIG_SIS900 is not set 799# CONFIG_SIS900 is not set
672# CONFIG_EPIC100 is not set 800# CONFIG_EPIC100 is not set
673# CONFIG_SUNDANCE is not set 801# CONFIG_SUNDANCE is not set
674# CONFIG_TLAN is not set 802# CONFIG_TLAN is not set
675# CONFIG_VIA_RHINE is not set 803# CONFIG_VIA_RHINE is not set
676# CONFIG_NET_POCKET is not set
677 804
678# 805#
679# Ethernet (1000 Mbit) 806# Ethernet (1000 Mbit)
680# 807#
681# CONFIG_ACENIC is not set 808# CONFIG_ACENIC is not set
682# CONFIG_DL2K is not set 809# CONFIG_DL2K is not set
683# CONFIG_E1000 is not set 810CONFIG_E1000=y
811# CONFIG_E1000_NAPI is not set
812# CONFIG_E1000_DISABLE_PACKET_SPLIT is not set
684# CONFIG_NS83820 is not set 813# CONFIG_NS83820 is not set
685# CONFIG_HAMACHI is not set 814# CONFIG_HAMACHI is not set
686# CONFIG_YELLOWFIN is not set 815# CONFIG_YELLOWFIN is not set
687# CONFIG_R8169 is not set 816CONFIG_R8169=y
817# CONFIG_R8169_NAPI is not set
688# CONFIG_SIS190 is not set 818# CONFIG_SIS190 is not set
689# CONFIG_SKGE is not set 819# CONFIG_SKGE is not set
690# CONFIG_SKY2 is not set 820CONFIG_SKY2=y
691# CONFIG_SK98LIN is not set 821# CONFIG_SK98LIN is not set
692# CONFIG_VIA_VELOCITY is not set 822# CONFIG_VIA_VELOCITY is not set
693# CONFIG_TIGON3 is not set 823CONFIG_TIGON3=y
694# CONFIG_BNX2 is not set 824CONFIG_BNX2=y
825# CONFIG_QLA3XXX is not set
695 826
696# 827#
697# Ethernet (10000 Mbit) 828# Ethernet (10000 Mbit)
@@ -699,6 +830,7 @@ CONFIG_E100=y
699# CONFIG_CHELSIO_T1 is not set 830# CONFIG_CHELSIO_T1 is not set
700# CONFIG_IXGB is not set 831# CONFIG_IXGB is not set
701# CONFIG_S2IO is not set 832# CONFIG_S2IO is not set
833# CONFIG_MYRI10GE is not set
702 834
703# 835#
704# Token Ring devices 836# Token Ring devices
@@ -716,14 +848,15 @@ CONFIG_E100=y
716# CONFIG_WAN is not set 848# CONFIG_WAN is not set
717# CONFIG_FDDI is not set 849# CONFIG_FDDI is not set
718# CONFIG_HIPPI is not set 850# CONFIG_HIPPI is not set
719# CONFIG_PLIP is not set
720# CONFIG_PPP is not set 851# CONFIG_PPP is not set
721# CONFIG_SLIP is not set 852# CONFIG_SLIP is not set
722# CONFIG_NET_FC is not set 853# CONFIG_NET_FC is not set
723# CONFIG_SHAPER is not set 854# CONFIG_SHAPER is not set
724# CONFIG_NETCONSOLE is not set 855CONFIG_NETCONSOLE=y
725# CONFIG_NETPOLL is not set 856CONFIG_NETPOLL=y
726# CONFIG_NET_POLL_CONTROLLER is not set 857# CONFIG_NETPOLL_RX is not set
858# CONFIG_NETPOLL_TRAP is not set
859CONFIG_NET_POLL_CONTROLLER=y
727 860
728# 861#
729# ISDN subsystem 862# ISDN subsystem
@@ -745,8 +878,8 @@ CONFIG_INPUT=y
745# 878#
746CONFIG_INPUT_MOUSEDEV=y 879CONFIG_INPUT_MOUSEDEV=y
747CONFIG_INPUT_MOUSEDEV_PSAUX=y 880CONFIG_INPUT_MOUSEDEV_PSAUX=y
748CONFIG_INPUT_MOUSEDEV_SCREEN_X=1280 881CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
749CONFIG_INPUT_MOUSEDEV_SCREEN_Y=1024 882CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
750# CONFIG_INPUT_JOYDEV is not set 883# CONFIG_INPUT_JOYDEV is not set
751# CONFIG_INPUT_TSDEV is not set 884# CONFIG_INPUT_TSDEV is not set
752CONFIG_INPUT_EVDEV=y 885CONFIG_INPUT_EVDEV=y
@@ -776,7 +909,6 @@ CONFIG_SERIO=y
776CONFIG_SERIO_I8042=y 909CONFIG_SERIO_I8042=y
777# CONFIG_SERIO_SERPORT is not set 910# CONFIG_SERIO_SERPORT is not set
778# CONFIG_SERIO_CT82C710 is not set 911# CONFIG_SERIO_CT82C710 is not set
779# CONFIG_SERIO_PARKBD is not set
780# CONFIG_SERIO_PCIPS2 is not set 912# CONFIG_SERIO_PCIPS2 is not set
781CONFIG_SERIO_LIBPS2=y 913CONFIG_SERIO_LIBPS2=y
782# CONFIG_SERIO_RAW is not set 914# CONFIG_SERIO_RAW is not set
@@ -788,14 +920,15 @@ CONFIG_SERIO_LIBPS2=y
788CONFIG_VT=y 920CONFIG_VT=y
789CONFIG_VT_CONSOLE=y 921CONFIG_VT_CONSOLE=y
790CONFIG_HW_CONSOLE=y 922CONFIG_HW_CONSOLE=y
923# CONFIG_VT_HW_CONSOLE_BINDING is not set
791# CONFIG_SERIAL_NONSTANDARD is not set 924# CONFIG_SERIAL_NONSTANDARD is not set
792 925
793# 926#
794# Serial drivers 927# Serial drivers
795# 928#
796CONFIG_SERIAL_8250=y 929CONFIG_SERIAL_8250=y
797# CONFIG_SERIAL_8250_CONSOLE is not set 930CONFIG_SERIAL_8250_CONSOLE=y
798# CONFIG_SERIAL_8250_ACPI is not set 931CONFIG_SERIAL_8250_PCI=y
799CONFIG_SERIAL_8250_NR_UARTS=4 932CONFIG_SERIAL_8250_NR_UARTS=4
800CONFIG_SERIAL_8250_RUNTIME_UARTS=4 933CONFIG_SERIAL_8250_RUNTIME_UARTS=4
801# CONFIG_SERIAL_8250_EXTENDED is not set 934# CONFIG_SERIAL_8250_EXTENDED is not set
@@ -804,14 +937,11 @@ CONFIG_SERIAL_8250_RUNTIME_UARTS=4
804# Non-8250 serial port support 937# Non-8250 serial port support
805# 938#
806CONFIG_SERIAL_CORE=y 939CONFIG_SERIAL_CORE=y
940CONFIG_SERIAL_CORE_CONSOLE=y
807# CONFIG_SERIAL_JSM is not set 941# CONFIG_SERIAL_JSM is not set
808CONFIG_UNIX98_PTYS=y 942CONFIG_UNIX98_PTYS=y
809CONFIG_LEGACY_PTYS=y 943CONFIG_LEGACY_PTYS=y
810CONFIG_LEGACY_PTY_COUNT=256 944CONFIG_LEGACY_PTY_COUNT=256
811CONFIG_PRINTER=y
812# CONFIG_LP_CONSOLE is not set
813# CONFIG_PPDEV is not set
814# CONFIG_TIPAR is not set
815 945
816# 946#
817# IPMI 947# IPMI
@@ -822,8 +952,12 @@ CONFIG_PRINTER=y
822# Watchdog Cards 952# Watchdog Cards
823# 953#
824# CONFIG_WATCHDOG is not set 954# CONFIG_WATCHDOG is not set
825# CONFIG_HW_RANDOM is not set 955CONFIG_HW_RANDOM=y
826CONFIG_NVRAM=y 956CONFIG_HW_RANDOM_INTEL=y
957CONFIG_HW_RANDOM_AMD=y
958CONFIG_HW_RANDOM_GEODE=y
959CONFIG_HW_RANDOM_VIA=y
960# CONFIG_NVRAM is not set
827CONFIG_RTC=y 961CONFIG_RTC=y
828# CONFIG_DTLK is not set 962# CONFIG_DTLK is not set
829# CONFIG_R3964 is not set 963# CONFIG_R3964 is not set
@@ -833,31 +967,28 @@ CONFIG_RTC=y
833# 967#
834# Ftape, the floppy tape device driver 968# Ftape, the floppy tape device driver
835# 969#
836# CONFIG_FTAPE is not set
837CONFIG_AGP=y 970CONFIG_AGP=y
838# CONFIG_AGP_ALI is not set 971# CONFIG_AGP_ALI is not set
839# CONFIG_AGP_ATI is not set 972# CONFIG_AGP_ATI is not set
840# CONFIG_AGP_AMD is not set 973# CONFIG_AGP_AMD is not set
841# CONFIG_AGP_AMD64 is not set 974CONFIG_AGP_AMD64=y
842# CONFIG_AGP_INTEL is not set 975CONFIG_AGP_INTEL=y
843# CONFIG_AGP_NVIDIA is not set 976# CONFIG_AGP_NVIDIA is not set
844# CONFIG_AGP_SIS is not set 977# CONFIG_AGP_SIS is not set
845# CONFIG_AGP_SWORKS is not set 978# CONFIG_AGP_SWORKS is not set
846CONFIG_AGP_VIA=y 979# CONFIG_AGP_VIA is not set
847# CONFIG_AGP_EFFICEON is not set 980# CONFIG_AGP_EFFICEON is not set
848CONFIG_DRM=y 981# CONFIG_DRM is not set
849# CONFIG_DRM_TDFX is not set
850# CONFIG_DRM_R128 is not set
851CONFIG_DRM_RADEON=y
852# CONFIG_DRM_MGA is not set
853# CONFIG_DRM_SIS is not set
854# CONFIG_DRM_VIA is not set
855# CONFIG_DRM_SAVAGE is not set
856# CONFIG_MWAVE is not set 982# CONFIG_MWAVE is not set
983# CONFIG_PC8736x_GPIO is not set
984# CONFIG_NSC_GPIO is not set
857# CONFIG_CS5535_GPIO is not set 985# CONFIG_CS5535_GPIO is not set
858# CONFIG_RAW_DRIVER is not set 986CONFIG_RAW_DRIVER=y
859# CONFIG_HPET is not set 987CONFIG_MAX_RAW_DEVS=256
860# CONFIG_HANGCHECK_TIMER is not set 988CONFIG_HPET=y
989# CONFIG_HPET_RTC_IRQ is not set
990CONFIG_HPET_MMAP=y
991CONFIG_HANGCHECK_TIMER=y
861 992
862# 993#
863# TPM devices 994# TPM devices
@@ -868,59 +999,7 @@ CONFIG_DRM_RADEON=y
868# 999#
869# I2C support 1000# I2C support
870# 1001#
871CONFIG_I2C=y 1002# CONFIG_I2C is not set
872CONFIG_I2C_CHARDEV=y
873
874#
875# I2C Algorithms
876#
877CONFIG_I2C_ALGOBIT=y
878# CONFIG_I2C_ALGOPCF is not set
879# CONFIG_I2C_ALGOPCA is not set
880
881#
882# I2C Hardware Bus support
883#
884# CONFIG_I2C_ALI1535 is not set
885# CONFIG_I2C_ALI1563 is not set
886# CONFIG_I2C_ALI15X3 is not set
887# CONFIG_I2C_AMD756 is not set
888# CONFIG_I2C_AMD8111 is not set
889# CONFIG_I2C_I801 is not set
890# CONFIG_I2C_I810 is not set
891# CONFIG_I2C_PIIX4 is not set
892CONFIG_I2C_ISA=y
893# CONFIG_I2C_NFORCE2 is not set
894# CONFIG_I2C_PARPORT is not set
895# CONFIG_I2C_PARPORT_LIGHT is not set
896# CONFIG_I2C_PROSAVAGE is not set
897# CONFIG_I2C_SAVAGE4 is not set
898# CONFIG_SCx200_ACB is not set
899# CONFIG_I2C_SIS5595 is not set
900# CONFIG_I2C_SIS630 is not set
901# CONFIG_I2C_SIS96X is not set
902# CONFIG_I2C_STUB is not set
903# CONFIG_I2C_VIA is not set
904CONFIG_I2C_VIAPRO=y
905# CONFIG_I2C_VOODOO3 is not set
906# CONFIG_I2C_PCA_ISA is not set
907
908#
909# Miscellaneous I2C Chip support
910#
911# CONFIG_SENSORS_DS1337 is not set
912# CONFIG_SENSORS_DS1374 is not set
913# CONFIG_SENSORS_EEPROM is not set
914# CONFIG_SENSORS_PCF8574 is not set
915# CONFIG_SENSORS_PCA9539 is not set
916# CONFIG_SENSORS_PCF8591 is not set
917# CONFIG_SENSORS_RTC8564 is not set
918# CONFIG_SENSORS_MAX6875 is not set
919# CONFIG_RTC_X1205_I2C is not set
920# CONFIG_I2C_DEBUG_CORE is not set
921# CONFIG_I2C_DEBUG_ALGO is not set
922# CONFIG_I2C_DEBUG_BUS is not set
923# CONFIG_I2C_DEBUG_CHIP is not set
924 1003
925# 1004#
926# SPI support 1005# SPI support
@@ -931,51 +1010,12 @@ CONFIG_I2C_VIAPRO=y
931# 1010#
932# Dallas's 1-wire bus 1011# Dallas's 1-wire bus
933# 1012#
934# CONFIG_W1 is not set
935 1013
936# 1014#
937# Hardware Monitoring support 1015# Hardware Monitoring support
938# 1016#
939CONFIG_HWMON=y 1017# CONFIG_HWMON is not set
940CONFIG_HWMON_VID=y 1018# CONFIG_HWMON_VID is not set
941# CONFIG_SENSORS_ADM1021 is not set
942# CONFIG_SENSORS_ADM1025 is not set
943# CONFIG_SENSORS_ADM1026 is not set
944# CONFIG_SENSORS_ADM1031 is not set
945# CONFIG_SENSORS_ADM9240 is not set
946# CONFIG_SENSORS_ASB100 is not set
947# CONFIG_SENSORS_ATXP1 is not set
948# CONFIG_SENSORS_DS1621 is not set
949# CONFIG_SENSORS_F71805F is not set
950# CONFIG_SENSORS_FSCHER is not set
951# CONFIG_SENSORS_FSCPOS is not set
952# CONFIG_SENSORS_GL518SM is not set
953# CONFIG_SENSORS_GL520SM is not set
954CONFIG_SENSORS_IT87=y
955# CONFIG_SENSORS_LM63 is not set
956# CONFIG_SENSORS_LM75 is not set
957# CONFIG_SENSORS_LM77 is not set
958# CONFIG_SENSORS_LM78 is not set
959# CONFIG_SENSORS_LM80 is not set
960# CONFIG_SENSORS_LM83 is not set
961# CONFIG_SENSORS_LM85 is not set
962# CONFIG_SENSORS_LM87 is not set
963# CONFIG_SENSORS_LM90 is not set
964# CONFIG_SENSORS_LM92 is not set
965# CONFIG_SENSORS_MAX1619 is not set
966# CONFIG_SENSORS_PC87360 is not set
967# CONFIG_SENSORS_SIS5595 is not set
968# CONFIG_SENSORS_SMSC47M1 is not set
969# CONFIG_SENSORS_SMSC47B397 is not set
970# CONFIG_SENSORS_VIA686A is not set
971# CONFIG_SENSORS_VT8231 is not set
972# CONFIG_SENSORS_W83781D is not set
973# CONFIG_SENSORS_W83792D is not set
974# CONFIG_SENSORS_W83L785TS is not set
975# CONFIG_SENSORS_W83627HF is not set
976# CONFIG_SENSORS_W83627EHF is not set
977# CONFIG_SENSORS_HDAPS is not set
978# CONFIG_HWMON_DEBUG_CHIP is not set
979 1019
980# 1020#
981# Misc devices 1021# Misc devices
@@ -983,117 +1023,31 @@ CONFIG_SENSORS_IT87=y
983# CONFIG_IBM_ASM is not set 1023# CONFIG_IBM_ASM is not set
984 1024
985# 1025#
986# Multimedia Capabilities Port drivers
987#
988
989#
990# Multimedia devices 1026# Multimedia devices
991# 1027#
992CONFIG_VIDEO_DEV=y 1028# CONFIG_VIDEO_DEV is not set
993 1029CONFIG_VIDEO_V4L2=y
994#
995# Video For Linux
996#
997
998#
999# Video Adapters
1000#
1001# CONFIG_VIDEO_ADV_DEBUG is not set
1002# CONFIG_VIDEO_BT848 is not set
1003# CONFIG_VIDEO_BWQCAM is not set
1004# CONFIG_VIDEO_CQCAM is not set
1005# CONFIG_VIDEO_W9966 is not set
1006# CONFIG_VIDEO_CPIA is not set
1007# CONFIG_VIDEO_SAA5246A is not set
1008# CONFIG_VIDEO_SAA5249 is not set
1009# CONFIG_TUNER_3036 is not set
1010# CONFIG_VIDEO_STRADIS is not set
1011# CONFIG_VIDEO_ZORAN is not set
1012CONFIG_VIDEO_SAA7134=y
1013# CONFIG_VIDEO_SAA7134_ALSA is not set
1014# CONFIG_VIDEO_MXB is not set
1015# CONFIG_VIDEO_DPC is not set
1016# CONFIG_VIDEO_HEXIUM_ORION is not set
1017# CONFIG_VIDEO_HEXIUM_GEMINI is not set
1018# CONFIG_VIDEO_CX88 is not set
1019# CONFIG_VIDEO_EM28XX is not set
1020# CONFIG_VIDEO_OVCAMCHIP is not set
1021# CONFIG_VIDEO_AUDIO_DECODER is not set
1022# CONFIG_VIDEO_DECODER is not set
1023
1024#
1025# Radio Adapters
1026#
1027# CONFIG_RADIO_GEMTEK_PCI is not set
1028# CONFIG_RADIO_MAXIRADIO is not set
1029# CONFIG_RADIO_MAESTRO is not set
1030 1030
1031# 1031#
1032# Digital Video Broadcasting Devices 1032# Digital Video Broadcasting Devices
1033# 1033#
1034# CONFIG_DVB is not set 1034# CONFIG_DVB is not set
1035CONFIG_VIDEO_TUNER=y 1035# CONFIG_USB_DABUSB is not set
1036CONFIG_VIDEO_BUF=y
1037CONFIG_VIDEO_IR=y
1038 1036
1039# 1037#
1040# Graphics support 1038# Graphics support
1041# 1039#
1042CONFIG_FB=y 1040CONFIG_FIRMWARE_EDID=y
1043CONFIG_FB_CFB_FILLRECT=y 1041# CONFIG_FB is not set
1044CONFIG_FB_CFB_COPYAREA=y
1045CONFIG_FB_CFB_IMAGEBLIT=y
1046# CONFIG_FB_MACMODES is not set
1047CONFIG_FB_MODE_HELPERS=y
1048# CONFIG_FB_TILEBLITTING is not set
1049# CONFIG_FB_CIRRUS is not set
1050# CONFIG_FB_PM2 is not set
1051# CONFIG_FB_CYBER2000 is not set
1052# CONFIG_FB_ARC is not set
1053# CONFIG_FB_ASILIANT is not set
1054# CONFIG_FB_IMSTT is not set
1055# CONFIG_FB_VGA16 is not set
1056# CONFIG_FB_VESA is not set
1057CONFIG_VIDEO_SELECT=y
1058# CONFIG_FB_HGA is not set
1059# CONFIG_FB_S1D13XXX is not set
1060# CONFIG_FB_NVIDIA is not set
1061# CONFIG_FB_RIVA is not set
1062# CONFIG_FB_I810 is not set
1063# CONFIG_FB_INTEL is not set
1064# CONFIG_FB_MATROX is not set
1065# CONFIG_FB_RADEON_OLD is not set
1066CONFIG_FB_RADEON=y
1067CONFIG_FB_RADEON_I2C=y
1068# CONFIG_FB_RADEON_DEBUG is not set
1069# CONFIG_FB_ATY128 is not set
1070# CONFIG_FB_ATY is not set
1071# CONFIG_FB_SAVAGE is not set
1072# CONFIG_FB_SIS is not set
1073# CONFIG_FB_NEOMAGIC is not set
1074# CONFIG_FB_KYRO is not set
1075# CONFIG_FB_3DFX is not set
1076# CONFIG_FB_VOODOO1 is not set
1077# CONFIG_FB_CYBLA is not set
1078# CONFIG_FB_TRIDENT is not set
1079# CONFIG_FB_GEODE is not set
1080# CONFIG_FB_VIRTUAL is not set
1081 1042
1082# 1043#
1083# Console display driver support 1044# Console display driver support
1084# 1045#
1085CONFIG_VGA_CONSOLE=y 1046CONFIG_VGA_CONSOLE=y
1047CONFIG_VGACON_SOFT_SCROLLBACK=y
1048CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=128
1049CONFIG_VIDEO_SELECT=y
1086CONFIG_DUMMY_CONSOLE=y 1050CONFIG_DUMMY_CONSOLE=y
1087CONFIG_FRAMEBUFFER_CONSOLE=y
1088# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
1089# CONFIG_FONTS is not set
1090CONFIG_FONT_8x8=y
1091CONFIG_FONT_8x16=y
1092
1093#
1094# Logo configuration
1095#
1096# CONFIG_LOGO is not set
1097# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 1051# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
1098 1052
1099# 1053#
@@ -1104,97 +1058,30 @@ CONFIG_SOUND=y
1104# 1058#
1105# Advanced Linux Sound Architecture 1059# Advanced Linux Sound Architecture
1106# 1060#
1107CONFIG_SND=y 1061# CONFIG_SND is not set
1108CONFIG_SND_TIMER=y
1109CONFIG_SND_PCM=y
1110CONFIG_SND_RAWMIDI=y
1111CONFIG_SND_SEQUENCER=y
1112# CONFIG_SND_SEQ_DUMMY is not set
1113# CONFIG_SND_MIXER_OSS is not set
1114# CONFIG_SND_PCM_OSS is not set
1115# CONFIG_SND_SEQUENCER_OSS is not set
1116CONFIG_SND_RTCTIMER=y
1117CONFIG_SND_SEQ_RTCTIMER_DEFAULT=y
1118# CONFIG_SND_DYNAMIC_MINORS is not set
1119# CONFIG_SND_SUPPORT_OLD_API is not set
1120# CONFIG_SND_VERBOSE_PRINTK is not set
1121# CONFIG_SND_DEBUG is not set
1122
1123#
1124# Generic devices
1125#
1126CONFIG_SND_MPU401_UART=y
1127CONFIG_SND_AC97_CODEC=y
1128CONFIG_SND_AC97_BUS=y
1129# CONFIG_SND_DUMMY is not set
1130# CONFIG_SND_VIRMIDI is not set
1131# CONFIG_SND_MTPAV is not set
1132# CONFIG_SND_SERIAL_U16550 is not set
1133# CONFIG_SND_MPU401 is not set
1134
1135#
1136# PCI devices
1137#
1138# CONFIG_SND_AD1889 is not set
1139# CONFIG_SND_ALS4000 is not set
1140# CONFIG_SND_ALI5451 is not set
1141# CONFIG_SND_ATIIXP is not set
1142# CONFIG_SND_ATIIXP_MODEM is not set
1143# CONFIG_SND_AU8810 is not set
1144# CONFIG_SND_AU8820 is not set
1145# CONFIG_SND_AU8830 is not set
1146# CONFIG_SND_AZT3328 is not set
1147# CONFIG_SND_BT87X is not set
1148# CONFIG_SND_CA0106 is not set
1149# CONFIG_SND_CMIPCI is not set
1150# CONFIG_SND_CS4281 is not set
1151# CONFIG_SND_CS46XX is not set
1152# CONFIG_SND_CS5535AUDIO is not set
1153# CONFIG_SND_EMU10K1 is not set
1154# CONFIG_SND_EMU10K1X is not set
1155# CONFIG_SND_ENS1370 is not set
1156# CONFIG_SND_ENS1371 is not set
1157# CONFIG_SND_ES1938 is not set
1158# CONFIG_SND_ES1968 is not set
1159# CONFIG_SND_FM801 is not set
1160# CONFIG_SND_HDA_INTEL is not set
1161# CONFIG_SND_HDSP is not set
1162# CONFIG_SND_HDSPM is not set
1163# CONFIG_SND_ICE1712 is not set
1164# CONFIG_SND_ICE1724 is not set
1165# CONFIG_SND_INTEL8X0 is not set
1166# CONFIG_SND_INTEL8X0M is not set
1167# CONFIG_SND_KORG1212 is not set
1168# CONFIG_SND_MAESTRO3 is not set
1169# CONFIG_SND_MIXART is not set
1170# CONFIG_SND_NM256 is not set
1171# CONFIG_SND_PCXHR is not set
1172# CONFIG_SND_RME32 is not set
1173# CONFIG_SND_RME96 is not set
1174# CONFIG_SND_RME9652 is not set
1175# CONFIG_SND_SONICVIBES is not set
1176# CONFIG_SND_TRIDENT is not set
1177CONFIG_SND_VIA82XX=y
1178# CONFIG_SND_VIA82XX_MODEM is not set
1179# CONFIG_SND_VX222 is not set
1180# CONFIG_SND_YMFPCI is not set
1181
1182#
1183# USB devices
1184#
1185# CONFIG_SND_USB_AUDIO is not set
1186# CONFIG_SND_USB_USX2Y is not set
1187 1062
1188# 1063#
1189# Open Sound System 1064# Open Sound System
1190# 1065#
1191# CONFIG_SOUND_PRIME is not set 1066CONFIG_SOUND_PRIME=y
1067CONFIG_OSS_OBSOLETE_DRIVER=y
1068# CONFIG_SOUND_BT878 is not set
1069# CONFIG_SOUND_EMU10K1 is not set
1070# CONFIG_SOUND_FUSION is not set
1071# CONFIG_SOUND_ES1371 is not set
1072CONFIG_SOUND_ICH=y
1073# CONFIG_SOUND_TRIDENT is not set
1074# CONFIG_SOUND_MSNDCLAS is not set
1075# CONFIG_SOUND_MSNDPIN is not set
1076# CONFIG_SOUND_VIA82CXXX is not set
1077# CONFIG_SOUND_OSS is not set
1192 1078
1193# 1079#
1194# USB support 1080# USB support
1195# 1081#
1196CONFIG_USB_ARCH_HAS_HCD=y 1082CONFIG_USB_ARCH_HAS_HCD=y
1197CONFIG_USB_ARCH_HAS_OHCI=y 1083CONFIG_USB_ARCH_HAS_OHCI=y
1084CONFIG_USB_ARCH_HAS_EHCI=y
1198CONFIG_USB=y 1085CONFIG_USB=y
1199# CONFIG_USB_DEBUG is not set 1086# CONFIG_USB_DEBUG is not set
1200 1087
@@ -1213,17 +1100,19 @@ CONFIG_USB_DEVICEFS=y
1213CONFIG_USB_EHCI_HCD=y 1100CONFIG_USB_EHCI_HCD=y
1214# CONFIG_USB_EHCI_SPLIT_ISO is not set 1101# CONFIG_USB_EHCI_SPLIT_ISO is not set
1215# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1102# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1103# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1216# CONFIG_USB_ISP116X_HCD is not set 1104# CONFIG_USB_ISP116X_HCD is not set
1217# CONFIG_USB_OHCI_HCD is not set 1105CONFIG_USB_OHCI_HCD=y
1106# CONFIG_USB_OHCI_BIG_ENDIAN is not set
1107CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1218CONFIG_USB_UHCI_HCD=y 1108CONFIG_USB_UHCI_HCD=y
1219# CONFIG_USB_SL811_HCD is not set 1109# CONFIG_USB_SL811_HCD is not set
1220 1110
1221# 1111#
1222# USB Device Class drivers 1112# USB Device Class drivers
1223# 1113#
1224# CONFIG_OBSOLETE_OSS_USB_DRIVER is not set
1225# CONFIG_USB_ACM is not set 1114# CONFIG_USB_ACM is not set
1226# CONFIG_USB_PRINTER is not set 1115CONFIG_USB_PRINTER=y
1227 1116
1228# 1117#
1229# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' 1118# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
@@ -1248,21 +1137,17 @@ CONFIG_USB_STORAGE=y
1248# 1137#
1249# USB Input Devices 1138# USB Input Devices
1250# 1139#
1251# CONFIG_USB_HID is not set 1140CONFIG_USB_HID=y
1252 1141CONFIG_USB_HIDINPUT=y
1253# 1142# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1254# USB HID Boot Protocol drivers 1143# CONFIG_HID_FF is not set
1255# 1144# CONFIG_USB_HIDDEV is not set
1256# CONFIG_USB_KBD is not set
1257# CONFIG_USB_MOUSE is not set
1258# CONFIG_USB_AIPTEK is not set 1145# CONFIG_USB_AIPTEK is not set
1259# CONFIG_USB_WACOM is not set 1146# CONFIG_USB_WACOM is not set
1260# CONFIG_USB_ACECAD is not set 1147# CONFIG_USB_ACECAD is not set
1261# CONFIG_USB_KBTAB is not set 1148# CONFIG_USB_KBTAB is not set
1262# CONFIG_USB_POWERMATE is not set 1149# CONFIG_USB_POWERMATE is not set
1263# CONFIG_USB_MTOUCH is not set 1150# CONFIG_USB_TOUCHSCREEN is not set
1264# CONFIG_USB_ITMTOUCH is not set
1265# CONFIG_USB_EGALAX is not set
1266# CONFIG_USB_YEALINK is not set 1151# CONFIG_USB_YEALINK is not set
1267# CONFIG_USB_XPAD is not set 1152# CONFIG_USB_XPAD is not set
1268# CONFIG_USB_ATI_REMOTE is not set 1153# CONFIG_USB_ATI_REMOTE is not set
@@ -1277,21 +1162,6 @@ CONFIG_USB_STORAGE=y
1277# CONFIG_USB_MICROTEK is not set 1162# CONFIG_USB_MICROTEK is not set
1278 1163
1279# 1164#
1280# USB Multimedia devices
1281#
1282# CONFIG_USB_DABUSB is not set
1283# CONFIG_USB_VICAM is not set
1284# CONFIG_USB_DSBR is not set
1285# CONFIG_USB_ET61X251 is not set
1286# CONFIG_USB_IBMCAM is not set
1287# CONFIG_USB_KONICAWC is not set
1288# CONFIG_USB_OV511 is not set
1289# CONFIG_USB_SE401 is not set
1290# CONFIG_USB_SN9C102 is not set
1291# CONFIG_USB_STV680 is not set
1292# CONFIG_USB_PWC is not set
1293
1294#
1295# USB Network Adapters 1165# USB Network Adapters
1296# 1166#
1297# CONFIG_USB_CATC is not set 1167# CONFIG_USB_CATC is not set
@@ -1299,12 +1169,11 @@ CONFIG_USB_STORAGE=y
1299# CONFIG_USB_PEGASUS is not set 1169# CONFIG_USB_PEGASUS is not set
1300# CONFIG_USB_RTL8150 is not set 1170# CONFIG_USB_RTL8150 is not set
1301# CONFIG_USB_USBNET is not set 1171# CONFIG_USB_USBNET is not set
1302# CONFIG_USB_MON is not set 1172CONFIG_USB_MON=y
1303 1173
1304# 1174#
1305# USB port drivers 1175# USB port drivers
1306# 1176#
1307# CONFIG_USB_USS720 is not set
1308 1177
1309# 1178#
1310# USB Serial Converter support 1179# USB Serial Converter support
@@ -1321,10 +1190,12 @@ CONFIG_USB_STORAGE=y
1321# CONFIG_USB_LEGOTOWER is not set 1190# CONFIG_USB_LEGOTOWER is not set
1322# CONFIG_USB_LCD is not set 1191# CONFIG_USB_LCD is not set
1323# CONFIG_USB_LED is not set 1192# CONFIG_USB_LED is not set
1193# CONFIG_USB_CYPRESS_CY7C63 is not set
1324# CONFIG_USB_CYTHERM is not set 1194# CONFIG_USB_CYTHERM is not set
1325# CONFIG_USB_PHIDGETKIT is not set 1195# CONFIG_USB_PHIDGETKIT is not set
1326# CONFIG_USB_PHIDGETSERVO is not set 1196# CONFIG_USB_PHIDGETSERVO is not set
1327# CONFIG_USB_IDMOUSE is not set 1197# CONFIG_USB_IDMOUSE is not set
1198# CONFIG_USB_APPLEDISPLAY is not set
1328# CONFIG_USB_SISUSBVGA is not set 1199# CONFIG_USB_SISUSBVGA is not set
1329# CONFIG_USB_LD is not set 1200# CONFIG_USB_LD is not set
1330# CONFIG_USB_TEST is not set 1201# CONFIG_USB_TEST is not set
@@ -1344,56 +1215,96 @@ CONFIG_USB_STORAGE=y
1344# CONFIG_MMC is not set 1215# CONFIG_MMC is not set
1345 1216
1346# 1217#
1218# LED devices
1219#
1220# CONFIG_NEW_LEDS is not set
1221
1222#
1223# LED drivers
1224#
1225
1226#
1227# LED Triggers
1228#
1229
1230#
1347# InfiniBand support 1231# InfiniBand support
1348# 1232#
1349# CONFIG_INFINIBAND is not set 1233# CONFIG_INFINIBAND is not set
1350 1234
1351# 1235#
1352# SN Devices 1236# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1237#
1238# CONFIG_EDAC is not set
1239
1240#
1241# Real Time Clock
1353# 1242#
1243# CONFIG_RTC_CLASS is not set
1354 1244
1355# 1245#
1356# EDAC - error detection and reporting (RAS) 1246# DMA Engine support
1247#
1248# CONFIG_DMA_ENGINE is not set
1249
1250#
1251# DMA Clients
1252#
1253
1254#
1255# DMA Devices
1357# 1256#
1358# CONFIG_EDAC is not set
1359 1257
1360# 1258#
1361# File systems 1259# File systems
1362# 1260#
1363CONFIG_EXT2_FS=y 1261CONFIG_EXT2_FS=y
1364# CONFIG_EXT2_FS_XATTR is not set 1262CONFIG_EXT2_FS_XATTR=y
1263CONFIG_EXT2_FS_POSIX_ACL=y
1264# CONFIG_EXT2_FS_SECURITY is not set
1365# CONFIG_EXT2_FS_XIP is not set 1265# CONFIG_EXT2_FS_XIP is not set
1366# CONFIG_EXT3_FS is not set 1266CONFIG_EXT3_FS=y
1367# CONFIG_REISERFS_FS is not set 1267CONFIG_EXT3_FS_XATTR=y
1268CONFIG_EXT3_FS_POSIX_ACL=y
1269# CONFIG_EXT3_FS_SECURITY is not set
1270CONFIG_JBD=y
1271# CONFIG_JBD_DEBUG is not set
1272CONFIG_FS_MBCACHE=y
1273CONFIG_REISERFS_FS=y
1274# CONFIG_REISERFS_CHECK is not set
1275# CONFIG_REISERFS_PROC_INFO is not set
1276CONFIG_REISERFS_FS_XATTR=y
1277CONFIG_REISERFS_FS_POSIX_ACL=y
1278# CONFIG_REISERFS_FS_SECURITY is not set
1368# CONFIG_JFS_FS is not set 1279# CONFIG_JFS_FS is not set
1369# CONFIG_FS_POSIX_ACL is not set 1280CONFIG_FS_POSIX_ACL=y
1370# CONFIG_XFS_FS is not set 1281# CONFIG_XFS_FS is not set
1371# CONFIG_OCFS2_FS is not set 1282# CONFIG_OCFS2_FS is not set
1372# CONFIG_MINIX_FS is not set 1283# CONFIG_MINIX_FS is not set
1373# CONFIG_ROMFS_FS is not set 1284# CONFIG_ROMFS_FS is not set
1374# CONFIG_INOTIFY is not set 1285CONFIG_INOTIFY=y
1286CONFIG_INOTIFY_USER=y
1375# CONFIG_QUOTA is not set 1287# CONFIG_QUOTA is not set
1376CONFIG_DNOTIFY=y 1288CONFIG_DNOTIFY=y
1377# CONFIG_AUTOFS_FS is not set 1289# CONFIG_AUTOFS_FS is not set
1378# CONFIG_AUTOFS4_FS is not set 1290CONFIG_AUTOFS4_FS=y
1379# CONFIG_FUSE_FS is not set 1291# CONFIG_FUSE_FS is not set
1380 1292
1381# 1293#
1382# CD-ROM/DVD Filesystems 1294# CD-ROM/DVD Filesystems
1383# 1295#
1384CONFIG_ISO9660_FS=y 1296CONFIG_ISO9660_FS=y
1385CONFIG_JOLIET=y 1297# CONFIG_JOLIET is not set
1386CONFIG_ZISOFS=y 1298# CONFIG_ZISOFS is not set
1387CONFIG_ZISOFS_FS=y
1388# CONFIG_UDF_FS is not set 1299# CONFIG_UDF_FS is not set
1389 1300
1390# 1301#
1391# DOS/FAT/NT Filesystems 1302# DOS/FAT/NT Filesystems
1392# 1303#
1393CONFIG_FAT_FS=y 1304CONFIG_FAT_FS=y
1394# CONFIG_MSDOS_FS is not set 1305CONFIG_MSDOS_FS=y
1395CONFIG_VFAT_FS=y 1306CONFIG_VFAT_FS=y
1396CONFIG_FAT_DEFAULT_CODEPAGE=850 1307CONFIG_FAT_DEFAULT_CODEPAGE=437
1397CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1" 1308CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1398# CONFIG_NTFS_FS is not set 1309# CONFIG_NTFS_FS is not set
1399 1310
@@ -1404,10 +1315,9 @@ CONFIG_PROC_FS=y
1404CONFIG_PROC_KCORE=y 1315CONFIG_PROC_KCORE=y
1405CONFIG_SYSFS=y 1316CONFIG_SYSFS=y
1406CONFIG_TMPFS=y 1317CONFIG_TMPFS=y
1407# CONFIG_HUGETLBFS is not set 1318CONFIG_HUGETLBFS=y
1408# CONFIG_HUGETLB_PAGE is not set 1319CONFIG_HUGETLB_PAGE=y
1409CONFIG_RAMFS=y 1320CONFIG_RAMFS=y
1410# CONFIG_RELAYFS_FS is not set
1411# CONFIG_CONFIGFS_FS is not set 1321# CONFIG_CONFIGFS_FS is not set
1412 1322
1413# 1323#
@@ -1430,13 +1340,26 @@ CONFIG_RAMFS=y
1430# 1340#
1431# Network File Systems 1341# Network File Systems
1432# 1342#
1433# CONFIG_NFS_FS is not set 1343CONFIG_NFS_FS=y
1434# CONFIG_NFSD is not set 1344CONFIG_NFS_V3=y
1345# CONFIG_NFS_V3_ACL is not set
1346# CONFIG_NFS_V4 is not set
1347# CONFIG_NFS_DIRECTIO is not set
1348CONFIG_NFSD=y
1349CONFIG_NFSD_V3=y
1350# CONFIG_NFSD_V3_ACL is not set
1351# CONFIG_NFSD_V4 is not set
1352CONFIG_NFSD_TCP=y
1353CONFIG_ROOT_NFS=y
1354CONFIG_LOCKD=y
1355CONFIG_LOCKD_V4=y
1356CONFIG_EXPORTFS=y
1357CONFIG_NFS_COMMON=y
1358CONFIG_SUNRPC=y
1359# CONFIG_RPCSEC_GSS_KRB5 is not set
1360# CONFIG_RPCSEC_GSS_SPKM3 is not set
1435# CONFIG_SMB_FS is not set 1361# CONFIG_SMB_FS is not set
1436CONFIG_CIFS=y 1362# CONFIG_CIFS is not set
1437# CONFIG_CIFS_STATS is not set
1438# CONFIG_CIFS_XATTR is not set
1439# CONFIG_CIFS_EXPERIMENTAL is not set
1440# CONFIG_NCP_FS is not set 1363# CONFIG_NCP_FS is not set
1441# CONFIG_CODA_FS is not set 1364# CONFIG_CODA_FS is not set
1442# CONFIG_AFS_FS is not set 1365# CONFIG_AFS_FS is not set
@@ -1445,33 +1368,18 @@ CONFIG_CIFS=y
1445# 1368#
1446# Partition Types 1369# Partition Types
1447# 1370#
1448CONFIG_PARTITION_ADVANCED=y 1371# CONFIG_PARTITION_ADVANCED is not set
1449# CONFIG_ACORN_PARTITION is not set
1450# CONFIG_OSF_PARTITION is not set
1451# CONFIG_AMIGA_PARTITION is not set
1452# CONFIG_ATARI_PARTITION is not set
1453# CONFIG_MAC_PARTITION is not set
1454CONFIG_MSDOS_PARTITION=y 1372CONFIG_MSDOS_PARTITION=y
1455# CONFIG_BSD_DISKLABEL is not set
1456# CONFIG_MINIX_SUBPARTITION is not set
1457# CONFIG_SOLARIS_X86_PARTITION is not set
1458# CONFIG_UNIXWARE_DISKLABEL is not set
1459# CONFIG_LDM_PARTITION is not set
1460# CONFIG_SGI_PARTITION is not set
1461# CONFIG_ULTRIX_PARTITION is not set
1462# CONFIG_SUN_PARTITION is not set
1463# CONFIG_KARMA_PARTITION is not set
1464# CONFIG_EFI_PARTITION is not set
1465 1373
1466# 1374#
1467# Native Language Support 1375# Native Language Support
1468# 1376#
1469CONFIG_NLS=y 1377CONFIG_NLS=y
1470CONFIG_NLS_DEFAULT="iso8859-15" 1378CONFIG_NLS_DEFAULT="iso8859-1"
1471# CONFIG_NLS_CODEPAGE_437 is not set 1379CONFIG_NLS_CODEPAGE_437=y
1472# CONFIG_NLS_CODEPAGE_737 is not set 1380# CONFIG_NLS_CODEPAGE_737 is not set
1473# CONFIG_NLS_CODEPAGE_775 is not set 1381# CONFIG_NLS_CODEPAGE_775 is not set
1474CONFIG_NLS_CODEPAGE_850=y 1382# CONFIG_NLS_CODEPAGE_850 is not set
1475# CONFIG_NLS_CODEPAGE_852 is not set 1383# CONFIG_NLS_CODEPAGE_852 is not set
1476# CONFIG_NLS_CODEPAGE_855 is not set 1384# CONFIG_NLS_CODEPAGE_855 is not set
1477# CONFIG_NLS_CODEPAGE_857 is not set 1385# CONFIG_NLS_CODEPAGE_857 is not set
@@ -1491,7 +1399,7 @@ CONFIG_NLS_CODEPAGE_850=y
1491# CONFIG_NLS_ISO8859_8 is not set 1399# CONFIG_NLS_ISO8859_8 is not set
1492# CONFIG_NLS_CODEPAGE_1250 is not set 1400# CONFIG_NLS_CODEPAGE_1250 is not set
1493# CONFIG_NLS_CODEPAGE_1251 is not set 1401# CONFIG_NLS_CODEPAGE_1251 is not set
1494# CONFIG_NLS_ASCII is not set 1402CONFIG_NLS_ASCII=y
1495CONFIG_NLS_ISO8859_1=y 1403CONFIG_NLS_ISO8859_1=y
1496# CONFIG_NLS_ISO8859_2 is not set 1404# CONFIG_NLS_ISO8859_2 is not set
1497# CONFIG_NLS_ISO8859_3 is not set 1405# CONFIG_NLS_ISO8859_3 is not set
@@ -1510,20 +1418,50 @@ CONFIG_NLS_UTF8=y
1510# 1418#
1511# Instrumentation Support 1419# Instrumentation Support
1512# 1420#
1513# CONFIG_PROFILING is not set 1421CONFIG_PROFILING=y
1514# CONFIG_KPROBES is not set 1422CONFIG_OPROFILE=y
1423CONFIG_KPROBES=y
1515 1424
1516# 1425#
1517# Kernel hacking 1426# Kernel hacking
1518# 1427#
1428CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1519# CONFIG_PRINTK_TIME is not set 1429# CONFIG_PRINTK_TIME is not set
1520CONFIG_MAGIC_SYSRQ=y 1430CONFIG_MAGIC_SYSRQ=y
1521# CONFIG_DEBUG_KERNEL is not set 1431CONFIG_UNUSED_SYMBOLS=y
1522CONFIG_LOG_BUF_SHIFT=14 1432CONFIG_DEBUG_KERNEL=y
1433CONFIG_LOG_BUF_SHIFT=18
1434CONFIG_DETECT_SOFTLOCKUP=y
1435# CONFIG_SCHEDSTATS is not set
1436# CONFIG_DEBUG_SLAB is not set
1437# CONFIG_DEBUG_RT_MUTEXES is not set
1438# CONFIG_RT_MUTEX_TESTER is not set
1439# CONFIG_DEBUG_SPINLOCK is not set
1440# CONFIG_DEBUG_MUTEXES is not set
1441# CONFIG_DEBUG_RWSEMS is not set
1442# CONFIG_DEBUG_LOCK_ALLOC is not set
1443# CONFIG_PROVE_LOCKING is not set
1444# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1445# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1446# CONFIG_DEBUG_KOBJECT is not set
1447# CONFIG_DEBUG_HIGHMEM is not set
1523CONFIG_DEBUG_BUGVERBOSE=y 1448CONFIG_DEBUG_BUGVERBOSE=y
1449# CONFIG_DEBUG_INFO is not set
1450# CONFIG_DEBUG_FS is not set
1451# CONFIG_DEBUG_VM is not set
1452# CONFIG_FRAME_POINTER is not set
1453CONFIG_UNWIND_INFO=y
1454CONFIG_STACK_UNWIND=y
1455# CONFIG_FORCED_INLINING is not set
1456# CONFIG_RCU_TORTURE_TEST is not set
1524CONFIG_EARLY_PRINTK=y 1457CONFIG_EARLY_PRINTK=y
1458CONFIG_DEBUG_STACKOVERFLOW=y
1459# CONFIG_DEBUG_STACK_USAGE is not set
1460# CONFIG_DEBUG_RODATA is not set
1461# CONFIG_4KSTACKS is not set
1525CONFIG_X86_FIND_SMP_CONFIG=y 1462CONFIG_X86_FIND_SMP_CONFIG=y
1526CONFIG_X86_MPPARSE=y 1463CONFIG_X86_MPPARSE=y
1464CONFIG_DOUBLEFAULT=y
1527 1465
1528# 1466#
1529# Security options 1467# Security options
@@ -1537,10 +1475,6 @@ CONFIG_X86_MPPARSE=y
1537# CONFIG_CRYPTO is not set 1475# CONFIG_CRYPTO is not set
1538 1476
1539# 1477#
1540# Hardware crypto devices
1541#
1542
1543#
1544# Library routines 1478# Library routines
1545# 1479#
1546# CONFIG_CRC_CCITT is not set 1480# CONFIG_CRC_CCITT is not set
@@ -1548,7 +1482,12 @@ CONFIG_X86_MPPARSE=y
1548CONFIG_CRC32=y 1482CONFIG_CRC32=y
1549# CONFIG_LIBCRC32C is not set 1483# CONFIG_LIBCRC32C is not set
1550CONFIG_ZLIB_INFLATE=y 1484CONFIG_ZLIB_INFLATE=y
1485CONFIG_PLIST=y
1551CONFIG_GENERIC_HARDIRQS=y 1486CONFIG_GENERIC_HARDIRQS=y
1552CONFIG_GENERIC_IRQ_PROBE=y 1487CONFIG_GENERIC_IRQ_PROBE=y
1488CONFIG_GENERIC_PENDING_IRQ=y
1489CONFIG_X86_SMP=y
1490CONFIG_X86_HT=y
1553CONFIG_X86_BIOS_REBOOT=y 1491CONFIG_X86_BIOS_REBOOT=y
1492CONFIG_X86_TRAMPOLINE=y
1554CONFIG_KTIME_SCALAR=y 1493CONFIG_KTIME_SCALAR=y
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 5427a842e841..1a884b6e6e5c 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -4,7 +4,7 @@
4 4
5extra-y := head.o init_task.o vmlinux.lds 5extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o entry.o traps.o irq.o \
8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \ 8 ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
9 pci-dma.o i386_ksyms.o i387.o bootflag.o \ 9 pci-dma.o i386_ksyms.o i387.o bootflag.o \
10 quirks.o i8237.o topology.o alternative.o i8253.o tsc.o 10 quirks.o i8237.o topology.o alternative.o i8253.o tsc.o
@@ -81,4 +81,5 @@ $(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
81 $(call if_changed,syscall) 81 $(call if_changed,syscall)
82 82
83k8-y += ../../x86_64/kernel/k8.o 83k8-y += ../../x86_64/kernel/k8.o
84stacktrace-y += ../../x86_64/kernel/stacktrace.o
84 85
diff --git a/arch/i386/kernel/acpi/Makefile b/arch/i386/kernel/acpi/Makefile
index 7e9ac99354f4..7f7be01f44e6 100644
--- a/arch/i386/kernel/acpi/Makefile
+++ b/arch/i386/kernel/acpi/Makefile
@@ -1,5 +1,7 @@
1obj-$(CONFIG_ACPI) += boot.o 1obj-$(CONFIG_ACPI) += boot.o
2ifneq ($(CONFIG_PCI),)
2obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o 3obj-$(CONFIG_X86_IO_APIC) += earlyquirk.o
4endif
3obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o 5obj-$(CONFIG_ACPI_SLEEP) += sleep.o wakeup.o
4 6
5ifneq ($(CONFIG_ACPI_PROCESSOR),) 7ifneq ($(CONFIG_ACPI_PROCESSOR),)
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index ee003bc0e8b1..1aaea6ab8c46 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -26,9 +26,12 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/acpi.h> 27#include <linux/acpi.h>
28#include <linux/efi.h> 28#include <linux/efi.h>
29#include <linux/cpumask.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/dmi.h> 31#include <linux/dmi.h>
31#include <linux/irq.h> 32#include <linux/irq.h>
33#include <linux/bootmem.h>
34#include <linux/ioport.h>
32 35
33#include <asm/pgtable.h> 36#include <asm/pgtable.h>
34#include <asm/io_apic.h> 37#include <asm/io_apic.h>
@@ -36,11 +39,17 @@
36#include <asm/io.h> 39#include <asm/io.h>
37#include <asm/mpspec.h> 40#include <asm/mpspec.h>
38 41
39#ifdef CONFIG_X86_64 42static int __initdata acpi_force = 0;
40 43
41extern void __init clustered_apic_check(void); 44#ifdef CONFIG_ACPI
45int acpi_disabled = 0;
46#else
47int acpi_disabled = 1;
48#endif
49EXPORT_SYMBOL(acpi_disabled);
50
51#ifdef CONFIG_X86_64
42 52
43extern int gsi_irq_sharing(int gsi);
44#include <asm/proto.h> 53#include <asm/proto.h>
45 54
46static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; } 55static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id) { return 0; }
@@ -506,16 +515,76 @@ EXPORT_SYMBOL(acpi_register_gsi);
506#ifdef CONFIG_ACPI_HOTPLUG_CPU 515#ifdef CONFIG_ACPI_HOTPLUG_CPU
507int acpi_map_lsapic(acpi_handle handle, int *pcpu) 516int acpi_map_lsapic(acpi_handle handle, int *pcpu)
508{ 517{
509 /* TBD */ 518 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
510 return -EINVAL; 519 union acpi_object *obj;
520 struct acpi_table_lapic *lapic;
521 cpumask_t tmp_map, new_map;
522 u8 physid;
523 int cpu;
524
525 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
526 return -EINVAL;
527
528 if (!buffer.length || !buffer.pointer)
529 return -EINVAL;
530
531 obj = buffer.pointer;
532 if (obj->type != ACPI_TYPE_BUFFER ||
533 obj->buffer.length < sizeof(*lapic)) {
534 kfree(buffer.pointer);
535 return -EINVAL;
536 }
537
538 lapic = (struct acpi_table_lapic *)obj->buffer.pointer;
539
540 if ((lapic->header.type != ACPI_MADT_LAPIC) ||
541 (!lapic->flags.enabled)) {
542 kfree(buffer.pointer);
543 return -EINVAL;
544 }
545
546 physid = lapic->id;
547
548 kfree(buffer.pointer);
549 buffer.length = ACPI_ALLOCATE_BUFFER;
550 buffer.pointer = NULL;
551
552 tmp_map = cpu_present_map;
553 mp_register_lapic(physid, lapic->flags.enabled);
554
555 /*
556 * If mp_register_lapic successfully generates a new logical cpu
557 * number, then the following will get us exactly what was mapped
558 */
559 cpus_andnot(new_map, cpu_present_map, tmp_map);
560 if (cpus_empty(new_map)) {
561 printk ("Unable to map lapic to logical cpu number\n");
562 return -EINVAL;
563 }
564
565 cpu = first_cpu(new_map);
566
567 *pcpu = cpu;
568 return 0;
511} 569}
512 570
513EXPORT_SYMBOL(acpi_map_lsapic); 571EXPORT_SYMBOL(acpi_map_lsapic);
514 572
515int acpi_unmap_lsapic(int cpu) 573int acpi_unmap_lsapic(int cpu)
516{ 574{
517 /* TBD */ 575 int i;
518 return -EINVAL; 576
577 for_each_possible_cpu(i) {
578 if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) {
579 x86_acpiid_to_apicid[i] = -1;
580 break;
581 }
582 }
583 x86_cpu_to_apicid[cpu] = -1;
584 cpu_clear(cpu, cpu_present_map);
585 num_processors--;
586
587 return (0);
519} 588}
520 589
521EXPORT_SYMBOL(acpi_unmap_lsapic); 590EXPORT_SYMBOL(acpi_unmap_lsapic);
@@ -579,6 +648,8 @@ static int __init acpi_parse_sbf(unsigned long phys_addr, unsigned long size)
579static int __init acpi_parse_hpet(unsigned long phys, unsigned long size) 648static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
580{ 649{
581 struct acpi_table_hpet *hpet_tbl; 650 struct acpi_table_hpet *hpet_tbl;
651 struct resource *hpet_res;
652 resource_size_t res_start;
582 653
583 if (!phys || !size) 654 if (!phys || !size)
584 return -EINVAL; 655 return -EINVAL;
@@ -594,12 +665,26 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
594 "memory.\n"); 665 "memory.\n");
595 return -1; 666 return -1;
596 } 667 }
668
669#define HPET_RESOURCE_NAME_SIZE 9
670 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
671 if (hpet_res) {
672 memset(hpet_res, 0, sizeof(*hpet_res));
673 hpet_res->name = (void *)&hpet_res[1];
674 hpet_res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
675 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE,
676 "HPET %u", hpet_tbl->number);
677 hpet_res->end = (1 * 1024) - 1;
678 }
679
597#ifdef CONFIG_X86_64 680#ifdef CONFIG_X86_64
598 vxtime.hpet_address = hpet_tbl->addr.addrl | 681 vxtime.hpet_address = hpet_tbl->addr.addrl |
599 ((long)hpet_tbl->addr.addrh << 32); 682 ((long)hpet_tbl->addr.addrh << 32);
600 683
601 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 684 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
602 hpet_tbl->id, vxtime.hpet_address); 685 hpet_tbl->id, vxtime.hpet_address);
686
687 res_start = vxtime.hpet_address;
603#else /* X86 */ 688#else /* X86 */
604 { 689 {
605 extern unsigned long hpet_address; 690 extern unsigned long hpet_address;
@@ -607,9 +692,17 @@ static int __init acpi_parse_hpet(unsigned long phys, unsigned long size)
607 hpet_address = hpet_tbl->addr.addrl; 692 hpet_address = hpet_tbl->addr.addrl;
608 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 693 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
609 hpet_tbl->id, hpet_address); 694 hpet_tbl->id, hpet_address);
695
696 res_start = hpet_address;
610 } 697 }
611#endif /* X86 */ 698#endif /* X86 */
612 699
700 if (hpet_res) {
701 hpet_res->start = res_start;
702 hpet_res->end += res_start;
703 insert_resource(&iomem_resource, hpet_res);
704 }
705
613 return 0; 706 return 0;
614} 707}
615#else 708#else
@@ -860,8 +953,6 @@ static void __init acpi_process_madt(void)
860 return; 953 return;
861} 954}
862 955
863extern int acpi_force;
864
865#ifdef __i386__ 956#ifdef __i386__
866 957
867static int __init disable_acpi_irq(struct dmi_system_id *d) 958static int __init disable_acpi_irq(struct dmi_system_id *d)
@@ -1163,3 +1254,75 @@ int __init acpi_boot_init(void)
1163 1254
1164 return 0; 1255 return 0;
1165} 1256}
1257
1258static int __init parse_acpi(char *arg)
1259{
1260 if (!arg)
1261 return -EINVAL;
1262
1263 /* "acpi=off" disables both ACPI table parsing and interpreter */
1264 if (strcmp(arg, "off") == 0) {
1265 disable_acpi();
1266 }
1267 /* acpi=force to over-ride black-list */
1268 else if (strcmp(arg, "force") == 0) {
1269 acpi_force = 1;
1270 acpi_ht = 1;
1271 acpi_disabled = 0;
1272 }
1273 /* acpi=strict disables out-of-spec workarounds */
1274 else if (strcmp(arg, "strict") == 0) {
1275 acpi_strict = 1;
1276 }
1277 /* Limit ACPI just to boot-time to enable HT */
1278 else if (strcmp(arg, "ht") == 0) {
1279 if (!acpi_force)
1280 disable_acpi();
1281 acpi_ht = 1;
1282 }
1283 /* "acpi=noirq" disables ACPI interrupt routing */
1284 else if (strcmp(arg, "noirq") == 0) {
1285 acpi_noirq_set();
1286 } else {
1287 /* Core will printk when we return error. */
1288 return -EINVAL;
1289 }
1290 return 0;
1291}
1292early_param("acpi", parse_acpi);
1293
1294/* FIXME: Using pci= for an ACPI parameter is a travesty. */
1295static int __init parse_pci(char *arg)
1296{
1297 if (arg && strcmp(arg, "noacpi") == 0)
1298 acpi_disable_pci();
1299 return 0;
1300}
1301early_param("pci", parse_pci);
1302
1303#ifdef CONFIG_X86_IO_APIC
1304static int __init parse_acpi_skip_timer_override(char *arg)
1305{
1306 acpi_skip_timer_override = 1;
1307 return 0;
1308}
1309early_param("acpi_skip_timer_override", parse_acpi_skip_timer_override);
1310#endif /* CONFIG_X86_IO_APIC */
1311
1312static int __init setup_acpi_sci(char *s)
1313{
1314 if (!s)
1315 return -EINVAL;
1316 if (!strcmp(s, "edge"))
1317 acpi_sci_flags.trigger = 1;
1318 else if (!strcmp(s, "level"))
1319 acpi_sci_flags.trigger = 3;
1320 else if (!strcmp(s, "high"))
1321 acpi_sci_flags.polarity = 1;
1322 else if (!strcmp(s, "low"))
1323 acpi_sci_flags.polarity = 3;
1324 else
1325 return -EINVAL;
1326 return 0;
1327}
1328early_param("acpi_sci", setup_acpi_sci);
diff --git a/arch/i386/kernel/acpi/earlyquirk.c b/arch/i386/kernel/acpi/earlyquirk.c
index 1649a175a206..fe799b11ac0a 100644
--- a/arch/i386/kernel/acpi/earlyquirk.c
+++ b/arch/i386/kernel/acpi/earlyquirk.c
@@ -48,7 +48,11 @@ void __init check_acpi_pci(void)
48 int num, slot, func; 48 int num, slot, func;
49 49
50 /* Assume the machine supports type 1. If not it will 50 /* Assume the machine supports type 1. If not it will
51 always read ffffffff and should not have any side effect. */ 51 always read ffffffff and should not have any side effect.
52 Actually a few buggy systems can machine check. Allow the user
53 to disable it by command line option at least -AK */
54 if (!early_pci_allowed())
55 return;
52 56
53 /* Poor man's PCI discovery */ 57 /* Poor man's PCI discovery */
54 for (num = 0; num < 32; num++) { 58 for (num = 0; num < 32; num++) {
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 8c844d07862f..90faae5c5d30 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -52,7 +52,18 @@ static cpumask_t timer_bcast_ipi;
52/* 52/*
53 * Knob to control our willingness to enable the local APIC. 53 * Knob to control our willingness to enable the local APIC.
54 */ 54 */
55int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */ 55static int enable_local_apic __initdata = 0; /* -1=force-disable, +1=force-enable */
56
57static inline void lapic_disable(void)
58{
59 enable_local_apic = -1;
60 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
61}
62
63static inline void lapic_enable(void)
64{
65 enable_local_apic = 1;
66}
56 67
57/* 68/*
58 * Debug level 69 * Debug level
@@ -586,8 +597,7 @@ void __devinit setup_local_APIC(void)
586 printk("No ESR for 82489DX.\n"); 597 printk("No ESR for 82489DX.\n");
587 } 598 }
588 599
589 if (nmi_watchdog == NMI_LOCAL_APIC) 600 setup_apic_nmi_watchdog(NULL);
590 setup_apic_nmi_watchdog();
591 apic_pm_activate(); 601 apic_pm_activate();
592} 602}
593 603
@@ -1373,3 +1383,18 @@ int __init APIC_init_uniprocessor (void)
1373 1383
1374 return 0; 1384 return 0;
1375} 1385}
1386
1387static int __init parse_lapic(char *arg)
1388{
1389 lapic_enable();
1390 return 0;
1391}
1392early_param("lapic", parse_lapic);
1393
1394static int __init parse_nolapic(char *arg)
1395{
1396 lapic_disable();
1397 return 0;
1398}
1399early_param("nolapic", parse_nolapic);
1400
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index e6a2d6b80cda..e4758095d87a 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -22,7 +22,7 @@
22extern void vide(void); 22extern void vide(void);
23__asm__(".align 4\nvide: ret"); 23__asm__(".align 4\nvide: ret");
24 24
25static void __init init_amd(struct cpuinfo_x86 *c) 25static void __cpuinit init_amd(struct cpuinfo_x86 *c)
26{ 26{
27 u32 l, h; 27 u32 l, h;
28 int mbytes = num_physpages >> (20-PAGE_SHIFT); 28 int mbytes = num_physpages >> (20-PAGE_SHIFT);
@@ -246,7 +246,7 @@ static void __init init_amd(struct cpuinfo_x86 *c)
246 num_cache_leaves = 3; 246 num_cache_leaves = 3;
247} 247}
248 248
249static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size) 249static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
250{ 250{
251 /* AMD errata T13 (order #21922) */ 251 /* AMD errata T13 (order #21922) */
252 if ((c->x86 == 6)) { 252 if ((c->x86 == 6)) {
@@ -259,7 +259,7 @@ static unsigned int amd_size_cache(struct cpuinfo_x86 * c, unsigned int size)
259 return size; 259 return size;
260} 260}
261 261
262static struct cpu_dev amd_cpu_dev __initdata = { 262static struct cpu_dev amd_cpu_dev __cpuinitdata = {
263 .c_vendor = "AMD", 263 .c_vendor = "AMD",
264 .c_ident = { "AuthenticAMD" }, 264 .c_ident = { "AuthenticAMD" },
265 .c_models = { 265 .c_models = {
@@ -275,7 +275,6 @@ static struct cpu_dev amd_cpu_dev __initdata = {
275 }, 275 },
276 }, 276 },
277 .c_init = init_amd, 277 .c_init = init_amd,
278 .c_identify = generic_identify,
279 .c_size_cache = amd_size_cache, 278 .c_size_cache = amd_size_cache,
280}; 279};
281 280
diff --git a/arch/i386/kernel/cpu/centaur.c b/arch/i386/kernel/cpu/centaur.c
index bd75629dd262..8c25047975c0 100644
--- a/arch/i386/kernel/cpu/centaur.c
+++ b/arch/i386/kernel/cpu/centaur.c
@@ -9,7 +9,7 @@
9 9
10#ifdef CONFIG_X86_OOSTORE 10#ifdef CONFIG_X86_OOSTORE
11 11
12static u32 __init power2(u32 x) 12static u32 __cpuinit power2(u32 x)
13{ 13{
14 u32 s=1; 14 u32 s=1;
15 while(s<=x) 15 while(s<=x)
@@ -22,7 +22,7 @@ static u32 __init power2(u32 x)
22 * Set up an actual MCR 22 * Set up an actual MCR
23 */ 23 */
24 24
25static void __init centaur_mcr_insert(int reg, u32 base, u32 size, int key) 25static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key)
26{ 26{
27 u32 lo, hi; 27 u32 lo, hi;
28 28
@@ -40,7 +40,7 @@ static void __init centaur_mcr_insert(int reg, u32 base, u32 size, int key)
40 * Shortcut: We know you can't put 4Gig of RAM on a winchip 40 * Shortcut: We know you can't put 4Gig of RAM on a winchip
41 */ 41 */
42 42
43static u32 __init ramtop(void) /* 16388 */ 43static u32 __cpuinit ramtop(void) /* 16388 */
44{ 44{
45 int i; 45 int i;
46 u32 top = 0; 46 u32 top = 0;
@@ -91,7 +91,7 @@ static u32 __init ramtop(void) /* 16388 */
91 * Compute a set of MCR's to give maximum coverage 91 * Compute a set of MCR's to give maximum coverage
92 */ 92 */
93 93
94static int __init centaur_mcr_compute(int nr, int key) 94static int __cpuinit centaur_mcr_compute(int nr, int key)
95{ 95{
96 u32 mem = ramtop(); 96 u32 mem = ramtop();
97 u32 root = power2(mem); 97 u32 root = power2(mem);
@@ -166,7 +166,7 @@ static int __init centaur_mcr_compute(int nr, int key)
166 return ct; 166 return ct;
167} 167}
168 168
169static void __init centaur_create_optimal_mcr(void) 169static void __cpuinit centaur_create_optimal_mcr(void)
170{ 170{
171 int i; 171 int i;
172 /* 172 /*
@@ -189,7 +189,7 @@ static void __init centaur_create_optimal_mcr(void)
189 wrmsr(MSR_IDT_MCR0+i, 0, 0); 189 wrmsr(MSR_IDT_MCR0+i, 0, 0);
190} 190}
191 191
192static void __init winchip2_create_optimal_mcr(void) 192static void __cpuinit winchip2_create_optimal_mcr(void)
193{ 193{
194 u32 lo, hi; 194 u32 lo, hi;
195 int i; 195 int i;
@@ -227,7 +227,7 @@ static void __init winchip2_create_optimal_mcr(void)
227 * Handle the MCR key on the Winchip 2. 227 * Handle the MCR key on the Winchip 2.
228 */ 228 */
229 229
230static void __init winchip2_unprotect_mcr(void) 230static void __cpuinit winchip2_unprotect_mcr(void)
231{ 231{
232 u32 lo, hi; 232 u32 lo, hi;
233 u32 key; 233 u32 key;
@@ -239,7 +239,7 @@ static void __init winchip2_unprotect_mcr(void)
239 wrmsr(MSR_IDT_MCR_CTRL, lo, hi); 239 wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
240} 240}
241 241
242static void __init winchip2_protect_mcr(void) 242static void __cpuinit winchip2_protect_mcr(void)
243{ 243{
244 u32 lo, hi; 244 u32 lo, hi;
245 245
@@ -257,7 +257,7 @@ static void __init winchip2_protect_mcr(void)
257#define RNG_ENABLED (1 << 3) 257#define RNG_ENABLED (1 << 3)
258#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */ 258#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */
259 259
260static void __init init_c3(struct cpuinfo_x86 *c) 260static void __cpuinit init_c3(struct cpuinfo_x86 *c)
261{ 261{
262 u32 lo, hi; 262 u32 lo, hi;
263 263
@@ -303,7 +303,7 @@ static void __init init_c3(struct cpuinfo_x86 *c)
303 display_cacheinfo(c); 303 display_cacheinfo(c);
304} 304}
305 305
306static void __init init_centaur(struct cpuinfo_x86 *c) 306static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
307{ 307{
308 enum { 308 enum {
309 ECX8=1<<1, 309 ECX8=1<<1,
@@ -442,7 +442,7 @@ static void __init init_centaur(struct cpuinfo_x86 *c)
442 } 442 }
443} 443}
444 444
445static unsigned int centaur_size_cache(struct cpuinfo_x86 * c, unsigned int size) 445static unsigned int __cpuinit centaur_size_cache(struct cpuinfo_x86 * c, unsigned int size)
446{ 446{
447 /* VIA C3 CPUs (670-68F) need further shifting. */ 447 /* VIA C3 CPUs (670-68F) need further shifting. */
448 if ((c->x86 == 6) && ((c->x86_model == 7) || (c->x86_model == 8))) 448 if ((c->x86 == 6) && ((c->x86_model == 7) || (c->x86_model == 8)))
@@ -457,7 +457,7 @@ static unsigned int centaur_size_cache(struct cpuinfo_x86 * c, unsigned int size
457 return size; 457 return size;
458} 458}
459 459
460static struct cpu_dev centaur_cpu_dev __initdata = { 460static struct cpu_dev centaur_cpu_dev __cpuinitdata = {
461 .c_vendor = "Centaur", 461 .c_vendor = "Centaur",
462 .c_ident = { "CentaurHauls" }, 462 .c_ident = { "CentaurHauls" },
463 .c_init = init_centaur, 463 .c_init = init_centaur,
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 70c87de582c7..2799baaadf45 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -36,7 +36,7 @@ struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
36 36
37extern int disable_pse; 37extern int disable_pse;
38 38
39static void default_init(struct cpuinfo_x86 * c) 39static void __cpuinit default_init(struct cpuinfo_x86 * c)
40{ 40{
41 /* Not much we can do here... */ 41 /* Not much we can do here... */
42 /* Check if at least it has cpuid */ 42 /* Check if at least it has cpuid */
@@ -49,7 +49,7 @@ static void default_init(struct cpuinfo_x86 * c)
49 } 49 }
50} 50}
51 51
52static struct cpu_dev default_cpu = { 52static struct cpu_dev __cpuinitdata default_cpu = {
53 .c_init = default_init, 53 .c_init = default_init,
54 .c_vendor = "Unknown", 54 .c_vendor = "Unknown",
55}; 55};
@@ -265,7 +265,7 @@ static void __init early_cpu_detect(void)
265 } 265 }
266} 266}
267 267
268void __cpuinit generic_identify(struct cpuinfo_x86 * c) 268static void __cpuinit generic_identify(struct cpuinfo_x86 * c)
269{ 269{
270 u32 tfms, xlvl; 270 u32 tfms, xlvl;
271 int ebx; 271 int ebx;
@@ -675,7 +675,7 @@ old_gdt:
675#endif 675#endif
676 676
677 /* Clear %fs and %gs. */ 677 /* Clear %fs and %gs. */
678 asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs"); 678 asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0));
679 679
680 /* Clear all 6 debug registers: */ 680 /* Clear all 6 debug registers: */
681 set_debugreg(0, 0); 681 set_debugreg(0, 0);
diff --git a/arch/i386/kernel/cpu/cpu.h b/arch/i386/kernel/cpu/cpu.h
index 5a1d4f163e84..2f6432cef6ff 100644
--- a/arch/i386/kernel/cpu/cpu.h
+++ b/arch/i386/kernel/cpu/cpu.h
@@ -24,7 +24,5 @@ extern struct cpu_dev * cpu_devs [X86_VENDOR_NUM];
24extern int get_model_name(struct cpuinfo_x86 *c); 24extern int get_model_name(struct cpuinfo_x86 *c);
25extern void display_cacheinfo(struct cpuinfo_x86 *c); 25extern void display_cacheinfo(struct cpuinfo_x86 *c);
26 26
27extern void generic_identify(struct cpuinfo_x86 * c);
28
29extern void early_intel_workaround(struct cpuinfo_x86 *c); 27extern void early_intel_workaround(struct cpuinfo_x86 *c);
30 28
diff --git a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c
index f03b7f94c304..c0c3b59de32c 100644
--- a/arch/i386/kernel/cpu/cyrix.c
+++ b/arch/i386/kernel/cpu/cyrix.c
@@ -12,7 +12,7 @@
12/* 12/*
13 * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU 13 * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU
14 */ 14 */
15static void __init do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) 15static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
16{ 16{
17 unsigned char ccr2, ccr3; 17 unsigned char ccr2, ccr3;
18 unsigned long flags; 18 unsigned long flags;
@@ -52,25 +52,25 @@ static void __init do_cyrix_devid(unsigned char *dir0, unsigned char *dir1)
52 * Actually since bugs.h doesn't even reference this perhaps someone should 52 * Actually since bugs.h doesn't even reference this perhaps someone should
53 * fix the documentation ??? 53 * fix the documentation ???
54 */ 54 */
55static unsigned char Cx86_dir0_msb __initdata = 0; 55static unsigned char Cx86_dir0_msb __cpuinitdata = 0;
56 56
57static char Cx86_model[][9] __initdata = { 57static char Cx86_model[][9] __cpuinitdata = {
58 "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ", 58 "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ",
59 "M II ", "Unknown" 59 "M II ", "Unknown"
60}; 60};
61static char Cx486_name[][5] __initdata = { 61static char Cx486_name[][5] __cpuinitdata = {
62 "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx", 62 "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx",
63 "SRx2", "DRx2" 63 "SRx2", "DRx2"
64}; 64};
65static char Cx486S_name[][4] __initdata = { 65static char Cx486S_name[][4] __cpuinitdata = {
66 "S", "S2", "Se", "S2e" 66 "S", "S2", "Se", "S2e"
67}; 67};
68static char Cx486D_name[][4] __initdata = { 68static char Cx486D_name[][4] __cpuinitdata = {
69 "DX", "DX2", "?", "?", "?", "DX4" 69 "DX", "DX2", "?", "?", "?", "DX4"
70}; 70};
71static char Cx86_cb[] __initdata = "?.5x Core/Bus Clock"; 71static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock";
72static char cyrix_model_mult1[] __initdata = "12??43"; 72static char cyrix_model_mult1[] __cpuinitdata = "12??43";
73static char cyrix_model_mult2[] __initdata = "12233445"; 73static char cyrix_model_mult2[] __cpuinitdata = "12233445";
74 74
75/* 75/*
76 * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old 76 * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old
@@ -82,7 +82,7 @@ static char cyrix_model_mult2[] __initdata = "12233445";
82 82
83extern void calibrate_delay(void) __init; 83extern void calibrate_delay(void) __init;
84 84
85static void __init check_cx686_slop(struct cpuinfo_x86 *c) 85static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c)
86{ 86{
87 unsigned long flags; 87 unsigned long flags;
88 88
@@ -107,7 +107,7 @@ static void __init check_cx686_slop(struct cpuinfo_x86 *c)
107} 107}
108 108
109 109
110static void __init set_cx86_reorder(void) 110static void __cpuinit set_cx86_reorder(void)
111{ 111{
112 u8 ccr3; 112 u8 ccr3;
113 113
@@ -122,7 +122,7 @@ static void __init set_cx86_reorder(void)
122 setCx86(CX86_CCR3, ccr3); 122 setCx86(CX86_CCR3, ccr3);
123} 123}
124 124
125static void __init set_cx86_memwb(void) 125static void __cpuinit set_cx86_memwb(void)
126{ 126{
127 u32 cr0; 127 u32 cr0;
128 128
@@ -137,7 +137,7 @@ static void __init set_cx86_memwb(void)
137 setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14 ); 137 setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14 );
138} 138}
139 139
140static void __init set_cx86_inc(void) 140static void __cpuinit set_cx86_inc(void)
141{ 141{
142 unsigned char ccr3; 142 unsigned char ccr3;
143 143
@@ -158,7 +158,7 @@ static void __init set_cx86_inc(void)
158 * Configure later MediaGX and/or Geode processor. 158 * Configure later MediaGX and/or Geode processor.
159 */ 159 */
160 160
161static void __init geode_configure(void) 161static void __cpuinit geode_configure(void)
162{ 162{
163 unsigned long flags; 163 unsigned long flags;
164 u8 ccr3, ccr4; 164 u8 ccr3, ccr4;
@@ -184,14 +184,14 @@ static void __init geode_configure(void)
184 184
185 185
186#ifdef CONFIG_PCI 186#ifdef CONFIG_PCI
187static struct pci_device_id __initdata cyrix_55x0[] = { 187static struct pci_device_id __cpuinitdata cyrix_55x0[] = {
188 { PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510) }, 188 { PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5510) },
189 { PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520) }, 189 { PCI_DEVICE(PCI_VENDOR_ID_CYRIX, PCI_DEVICE_ID_CYRIX_5520) },
190 { }, 190 { },
191}; 191};
192#endif 192#endif
193 193
194static void __init init_cyrix(struct cpuinfo_x86 *c) 194static void __cpuinit init_cyrix(struct cpuinfo_x86 *c)
195{ 195{
196 unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0; 196 unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0;
197 char *buf = c->x86_model_id; 197 char *buf = c->x86_model_id;
@@ -346,7 +346,7 @@ static void __init init_cyrix(struct cpuinfo_x86 *c)
346/* 346/*
347 * Handle National Semiconductor branded processors 347 * Handle National Semiconductor branded processors
348 */ 348 */
349static void __init init_nsc(struct cpuinfo_x86 *c) 349static void __cpuinit init_nsc(struct cpuinfo_x86 *c)
350{ 350{
351 /* There may be GX1 processors in the wild that are branded 351 /* There may be GX1 processors in the wild that are branded
352 * NSC and not Cyrix. 352 * NSC and not Cyrix.
@@ -394,7 +394,7 @@ static inline int test_cyrix_52div(void)
394 return (unsigned char) (test >> 8) == 0x02; 394 return (unsigned char) (test >> 8) == 0x02;
395} 395}
396 396
397static void cyrix_identify(struct cpuinfo_x86 * c) 397static void __cpuinit cyrix_identify(struct cpuinfo_x86 * c)
398{ 398{
399 /* Detect Cyrix with disabled CPUID */ 399 /* Detect Cyrix with disabled CPUID */
400 if ( c->x86 == 4 && test_cyrix_52div() ) { 400 if ( c->x86 == 4 && test_cyrix_52div() ) {
@@ -427,10 +427,9 @@ static void cyrix_identify(struct cpuinfo_x86 * c)
427 local_irq_restore(flags); 427 local_irq_restore(flags);
428 } 428 }
429 } 429 }
430 generic_identify(c);
431} 430}
432 431
433static struct cpu_dev cyrix_cpu_dev __initdata = { 432static struct cpu_dev cyrix_cpu_dev __cpuinitdata = {
434 .c_vendor = "Cyrix", 433 .c_vendor = "Cyrix",
435 .c_ident = { "CyrixInstead" }, 434 .c_ident = { "CyrixInstead" },
436 .c_init = init_cyrix, 435 .c_init = init_cyrix,
@@ -453,11 +452,10 @@ static int __init cyrix_exit_cpu(void)
453 452
454late_initcall(cyrix_exit_cpu); 453late_initcall(cyrix_exit_cpu);
455 454
456static struct cpu_dev nsc_cpu_dev __initdata = { 455static struct cpu_dev nsc_cpu_dev __cpuinitdata = {
457 .c_vendor = "NSC", 456 .c_vendor = "NSC",
458 .c_ident = { "Geode by NSC" }, 457 .c_ident = { "Geode by NSC" },
459 .c_init = init_nsc, 458 .c_init = init_nsc,
460 .c_identify = generic_identify,
461}; 459};
462 460
463int __init nsc_init_cpu(void) 461int __init nsc_init_cpu(void)
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 5a2e270924b1..94a95aa5227e 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -198,7 +198,7 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
198} 198}
199 199
200 200
201static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size) 201static unsigned int __cpuinit intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
202{ 202{
203 /* Intel PIII Tualatin. This comes in two flavours. 203 /* Intel PIII Tualatin. This comes in two flavours.
204 * One has 256kb of cache, the other 512. We have no way 204 * One has 256kb of cache, the other 512. We have no way
@@ -263,7 +263,6 @@ static struct cpu_dev intel_cpu_dev __cpuinitdata = {
263 }, 263 },
264 }, 264 },
265 .c_init = init_intel, 265 .c_init = init_intel,
266 .c_identify = generic_identify,
267 .c_size_cache = intel_size_cache, 266 .c_size_cache = intel_size_cache,
268}; 267};
269 268
diff --git a/arch/i386/kernel/cpu/mcheck/Makefile b/arch/i386/kernel/cpu/mcheck/Makefile
index 30808f3d6715..f1ebe1c1c17a 100644
--- a/arch/i386/kernel/cpu/mcheck/Makefile
+++ b/arch/i386/kernel/cpu/mcheck/Makefile
@@ -1,2 +1,2 @@
1obj-y = mce.o k7.o p4.o p5.o p6.o winchip.o 1obj-y = mce.o k7.o p4.o p5.o p6.o winchip.o therm_throt.o
2obj-$(CONFIG_X86_MCE_NONFATAL) += non-fatal.o 2obj-$(CONFIG_X86_MCE_NONFATAL) += non-fatal.o
diff --git a/arch/i386/kernel/cpu/mcheck/p4.c b/arch/i386/kernel/cpu/mcheck/p4.c
index b95f1b3d53aa..504434a46011 100644
--- a/arch/i386/kernel/cpu/mcheck/p4.c
+++ b/arch/i386/kernel/cpu/mcheck/p4.c
@@ -13,6 +13,8 @@
13#include <asm/msr.h> 13#include <asm/msr.h>
14#include <asm/apic.h> 14#include <asm/apic.h>
15 15
16#include <asm/therm_throt.h>
17
16#include "mce.h" 18#include "mce.h"
17 19
18/* as supported by the P4/Xeon family */ 20/* as supported by the P4/Xeon family */
@@ -44,25 +46,12 @@ static void unexpected_thermal_interrupt(struct pt_regs *regs)
44/* P4/Xeon Thermal transition interrupt handler */ 46/* P4/Xeon Thermal transition interrupt handler */
45static void intel_thermal_interrupt(struct pt_regs *regs) 47static void intel_thermal_interrupt(struct pt_regs *regs)
46{ 48{
47 u32 l, h; 49 __u64 msr_val;
48 unsigned int cpu = smp_processor_id();
49 static unsigned long next[NR_CPUS];
50 50
51 ack_APIC_irq(); 51 ack_APIC_irq();
52 52
53 if (time_after(next[cpu], jiffies)) 53 rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
54 return; 54 therm_throt_process(msr_val & 0x1);
55
56 next[cpu] = jiffies + HZ*5;
57 rdmsr(MSR_IA32_THERM_STATUS, l, h);
58 if (l & 0x1) {
59 printk(KERN_EMERG "CPU%d: Temperature above threshold\n", cpu);
60 printk(KERN_EMERG "CPU%d: Running in modulated clock mode\n",
61 cpu);
62 add_taint(TAINT_MACHINE_CHECK);
63 } else {
64 printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
65 }
66} 55}
67 56
68/* Thermal interrupt handler for this CPU setup */ 57/* Thermal interrupt handler for this CPU setup */
@@ -122,10 +111,13 @@ static void intel_init_thermal(struct cpuinfo_x86 *c)
122 111
123 rdmsr (MSR_IA32_MISC_ENABLE, l, h); 112 rdmsr (MSR_IA32_MISC_ENABLE, l, h);
124 wrmsr (MSR_IA32_MISC_ENABLE, l | (1<<3), h); 113 wrmsr (MSR_IA32_MISC_ENABLE, l | (1<<3), h);
125 114
126 l = apic_read (APIC_LVTTHMR); 115 l = apic_read (APIC_LVTTHMR);
127 apic_write_around (APIC_LVTTHMR, l & ~APIC_LVT_MASKED); 116 apic_write_around (APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
128 printk (KERN_INFO "CPU%d: Thermal monitoring enabled\n", cpu); 117 printk (KERN_INFO "CPU%d: Thermal monitoring enabled\n", cpu);
118
119 /* enable thermal throttle processing */
120 atomic_set(&therm_throt_en, 1);
129 return; 121 return;
130} 122}
131#endif /* CONFIG_X86_MCE_P4THERMAL */ 123#endif /* CONFIG_X86_MCE_P4THERMAL */
diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c
new file mode 100644
index 000000000000..4f43047de406
--- /dev/null
+++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c
@@ -0,0 +1,180 @@
1/*
2 * linux/arch/i386/kerne/cpu/mcheck/therm_throt.c
3 *
4 * Thermal throttle event support code (such as syslog messaging and rate
5 * limiting) that was factored out from x86_64 (mce_intel.c) and i386 (p4.c).
6 * This allows consistent reporting of CPU thermal throttle events.
7 *
8 * Maintains a counter in /sys that keeps track of the number of thermal
9 * events, such that the user knows how bad the thermal problem might be
10 * (since the logging to syslog and mcelog is rate limited).
11 *
12 * Author: Dmitriy Zavin (dmitriyz@google.com)
13 *
14 * Credits: Adapted from Zwane Mwaikambo's original code in mce_intel.c.
15 * Inspired by Ross Biro's and Al Borchers' counter code.
16 */
17
18#include <linux/percpu.h>
19#include <linux/sysdev.h>
20#include <linux/cpu.h>
21#include <asm/cpu.h>
22#include <linux/notifier.h>
23#include <asm/therm_throt.h>
24
25/* How long to wait between reporting thermal events */
26#define CHECK_INTERVAL (300 * HZ)
27
28static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
29static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
30atomic_t therm_throt_en = ATOMIC_INIT(0);
31
32#ifdef CONFIG_SYSFS
33#define define_therm_throt_sysdev_one_ro(_name) \
34 static SYSDEV_ATTR(_name, 0444, therm_throt_sysdev_show_##_name, NULL)
35
36#define define_therm_throt_sysdev_show_func(name) \
37static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \
38 char *buf) \
39{ \
40 unsigned int cpu = dev->id; \
41 ssize_t ret; \
42 \
43 preempt_disable(); /* CPU hotplug */ \
44 if (cpu_online(cpu)) \
45 ret = sprintf(buf, "%lu\n", \
46 per_cpu(thermal_throttle_##name, cpu)); \
47 else \
48 ret = 0; \
49 preempt_enable(); \
50 \
51 return ret; \
52}
53
54define_therm_throt_sysdev_show_func(count);
55define_therm_throt_sysdev_one_ro(count);
56
57static struct attribute *thermal_throttle_attrs[] = {
58 &attr_count.attr,
59 NULL
60};
61
62static struct attribute_group thermal_throttle_attr_group = {
63 .attrs = thermal_throttle_attrs,
64 .name = "thermal_throttle"
65};
66#endif /* CONFIG_SYSFS */
67
68/***
69 * therm_throt_process - Process thermal throttling event from interrupt
70 * @curr: Whether the condition is current or not (boolean), since the
71 * thermal interrupt normally gets called both when the thermal
72 * event begins and once the event has ended.
73 *
74 * This function is called by the thermal interrupt after the
75 * IRQ has been acknowledged.
76 *
77 * It will take care of rate limiting and printing messages to the syslog.
78 *
79 * Returns: 0 : Event should NOT be further logged, i.e. still in
80 * "timeout" from previous log message.
81 * 1 : Event should be logged further, and a message has been
82 * printed to the syslog.
83 */
84int therm_throt_process(int curr)
85{
86 unsigned int cpu = smp_processor_id();
87 __u64 tmp_jiffs = get_jiffies_64();
88
89 if (curr)
90 __get_cpu_var(thermal_throttle_count)++;
91
92 if (time_before64(tmp_jiffs, __get_cpu_var(next_check)))
93 return 0;
94
95 __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
96
97 /* if we just entered the thermal event */
98 if (curr) {
99 printk(KERN_CRIT "CPU%d: Temperature above threshold, "
100 "cpu clock throttled (total events = %lu)\n", cpu,
101 __get_cpu_var(thermal_throttle_count));
102
103 add_taint(TAINT_MACHINE_CHECK);
104 } else {
105 printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);
106 }
107
108 return 1;
109}
110
111#ifdef CONFIG_SYSFS
112/* Add/Remove thermal_throttle interface for CPU device */
113static __cpuinit int thermal_throttle_add_dev(struct sys_device * sys_dev)
114{
115 sysfs_create_group(&sys_dev->kobj, &thermal_throttle_attr_group);
116 return 0;
117}
118
119#ifdef CONFIG_HOTPLUG_CPU
120static __cpuinit int thermal_throttle_remove_dev(struct sys_device * sys_dev)
121{
122 sysfs_remove_group(&sys_dev->kobj, &thermal_throttle_attr_group);
123 return 0;
124}
125
126/* Mutex protecting device creation against CPU hotplug */
127static DEFINE_MUTEX(therm_cpu_lock);
128
129/* Get notified when a cpu comes on/off. Be hotplug friendly. */
130static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block *nfb,
131 unsigned long action,
132 void *hcpu)
133{
134 unsigned int cpu = (unsigned long)hcpu;
135 struct sys_device *sys_dev;
136
137 sys_dev = get_cpu_sysdev(cpu);
138 mutex_lock(&therm_cpu_lock);
139 switch (action) {
140 case CPU_ONLINE:
141 thermal_throttle_add_dev(sys_dev);
142 break;
143 case CPU_DEAD:
144 thermal_throttle_remove_dev(sys_dev);
145 break;
146 }
147 mutex_unlock(&therm_cpu_lock);
148 return NOTIFY_OK;
149}
150
151static struct notifier_block thermal_throttle_cpu_notifier =
152{
153 .notifier_call = thermal_throttle_cpu_callback,
154};
155#endif /* CONFIG_HOTPLUG_CPU */
156
157static __init int thermal_throttle_init_device(void)
158{
159 unsigned int cpu = 0;
160
161 if (!atomic_read(&therm_throt_en))
162 return 0;
163
164 register_hotcpu_notifier(&thermal_throttle_cpu_notifier);
165
166#ifdef CONFIG_HOTPLUG_CPU
167 mutex_lock(&therm_cpu_lock);
168#endif
169 /* connect live CPUs to sysfs */
170 for_each_online_cpu(cpu)
171 thermal_throttle_add_dev(get_cpu_sysdev(cpu));
172#ifdef CONFIG_HOTPLUG_CPU
173 mutex_unlock(&therm_cpu_lock);
174#endif
175
176 return 0;
177}
178
179device_initcall(thermal_throttle_init_device);
180#endif /* CONFIG_SYSFS */
diff --git a/arch/i386/kernel/cpu/nexgen.c b/arch/i386/kernel/cpu/nexgen.c
index ad87fa58058d..8bf23cc80c63 100644
--- a/arch/i386/kernel/cpu/nexgen.c
+++ b/arch/i386/kernel/cpu/nexgen.c
@@ -10,7 +10,7 @@
10 * to have CPUID. (Thanks to Herbert Oppmann) 10 * to have CPUID. (Thanks to Herbert Oppmann)
11 */ 11 */
12 12
13static int __init deep_magic_nexgen_probe(void) 13static int __cpuinit deep_magic_nexgen_probe(void)
14{ 14{
15 int ret; 15 int ret;
16 16
@@ -27,21 +27,20 @@ static int __init deep_magic_nexgen_probe(void)
27 return ret; 27 return ret;
28} 28}
29 29
30static void __init init_nexgen(struct cpuinfo_x86 * c) 30static void __cpuinit init_nexgen(struct cpuinfo_x86 * c)
31{ 31{
32 c->x86_cache_size = 256; /* A few had 1 MB... */ 32 c->x86_cache_size = 256; /* A few had 1 MB... */
33} 33}
34 34
35static void __init nexgen_identify(struct cpuinfo_x86 * c) 35static void __cpuinit nexgen_identify(struct cpuinfo_x86 * c)
36{ 36{
37 /* Detect NexGen with old hypercode */ 37 /* Detect NexGen with old hypercode */
38 if ( deep_magic_nexgen_probe() ) { 38 if ( deep_magic_nexgen_probe() ) {
39 strcpy(c->x86_vendor_id, "NexGenDriven"); 39 strcpy(c->x86_vendor_id, "NexGenDriven");
40 } 40 }
41 generic_identify(c);
42} 41}
43 42
44static struct cpu_dev nexgen_cpu_dev __initdata = { 43static struct cpu_dev nexgen_cpu_dev __cpuinitdata = {
45 .c_vendor = "Nexgen", 44 .c_vendor = "Nexgen",
46 .c_ident = { "NexGenDriven" }, 45 .c_ident = { "NexGenDriven" },
47 .c_models = { 46 .c_models = {
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index f54a15268ed7..76aac088a323 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -46,8 +46,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
46 46
47 /* Intel-defined (#2) */ 47 /* Intel-defined (#2) */
48 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", 48 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
49 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 49 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
50 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 50 NULL, NULL, "dca", NULL, NULL, NULL, NULL, NULL,
51 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 51 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
52 52
53 /* VIA/Cyrix/Centaur-defined */ 53 /* VIA/Cyrix/Centaur-defined */
diff --git a/arch/i386/kernel/cpu/rise.c b/arch/i386/kernel/cpu/rise.c
index d08d5a2811c8..9317f7414989 100644
--- a/arch/i386/kernel/cpu/rise.c
+++ b/arch/i386/kernel/cpu/rise.c
@@ -5,7 +5,7 @@
5 5
6#include "cpu.h" 6#include "cpu.h"
7 7
8static void __init init_rise(struct cpuinfo_x86 *c) 8static void __cpuinit init_rise(struct cpuinfo_x86 *c)
9{ 9{
10 printk("CPU: Rise iDragon"); 10 printk("CPU: Rise iDragon");
11 if (c->x86_model > 2) 11 if (c->x86_model > 2)
@@ -28,7 +28,7 @@ static void __init init_rise(struct cpuinfo_x86 *c)
28 set_bit(X86_FEATURE_CX8, c->x86_capability); 28 set_bit(X86_FEATURE_CX8, c->x86_capability);
29} 29}
30 30
31static struct cpu_dev rise_cpu_dev __initdata = { 31static struct cpu_dev rise_cpu_dev __cpuinitdata = {
32 .c_vendor = "Rise", 32 .c_vendor = "Rise",
33 .c_ident = { "RiseRiseRise" }, 33 .c_ident = { "RiseRiseRise" },
34 .c_models = { 34 .c_models = {
diff --git a/arch/i386/kernel/cpu/transmeta.c b/arch/i386/kernel/cpu/transmeta.c
index 7214c9b577ab..4056fb7d2cdf 100644
--- a/arch/i386/kernel/cpu/transmeta.c
+++ b/arch/i386/kernel/cpu/transmeta.c
@@ -5,7 +5,7 @@
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include "cpu.h" 6#include "cpu.h"
7 7
8static void __init init_transmeta(struct cpuinfo_x86 *c) 8static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
9{ 9{
10 unsigned int cap_mask, uk, max, dummy; 10 unsigned int cap_mask, uk, max, dummy;
11 unsigned int cms_rev1, cms_rev2; 11 unsigned int cms_rev1, cms_rev2;
@@ -85,10 +85,9 @@ static void __init init_transmeta(struct cpuinfo_x86 *c)
85#endif 85#endif
86} 86}
87 87
88static void __init transmeta_identify(struct cpuinfo_x86 * c) 88static void __cpuinit transmeta_identify(struct cpuinfo_x86 * c)
89{ 89{
90 u32 xlvl; 90 u32 xlvl;
91 generic_identify(c);
92 91
93 /* Transmeta-defined flags: level 0x80860001 */ 92 /* Transmeta-defined flags: level 0x80860001 */
94 xlvl = cpuid_eax(0x80860000); 93 xlvl = cpuid_eax(0x80860000);
@@ -98,7 +97,7 @@ static void __init transmeta_identify(struct cpuinfo_x86 * c)
98 } 97 }
99} 98}
100 99
101static struct cpu_dev transmeta_cpu_dev __initdata = { 100static struct cpu_dev transmeta_cpu_dev __cpuinitdata = {
102 .c_vendor = "Transmeta", 101 .c_vendor = "Transmeta",
103 .c_ident = { "GenuineTMx86", "TransmetaCPU" }, 102 .c_ident = { "GenuineTMx86", "TransmetaCPU" },
104 .c_init = init_transmeta, 103 .c_init = init_transmeta,
diff --git a/arch/i386/kernel/cpu/umc.c b/arch/i386/kernel/cpu/umc.c
index 2cd988f6dc55..1bf3f87e9c5b 100644
--- a/arch/i386/kernel/cpu/umc.c
+++ b/arch/i386/kernel/cpu/umc.c
@@ -5,12 +5,8 @@
5 5
6/* UMC chips appear to be only either 386 or 486, so no special init takes place. 6/* UMC chips appear to be only either 386 or 486, so no special init takes place.
7 */ 7 */
8static void __init init_umc(struct cpuinfo_x86 * c)
9{
10
11}
12 8
13static struct cpu_dev umc_cpu_dev __initdata = { 9static struct cpu_dev umc_cpu_dev __cpuinitdata = {
14 .c_vendor = "UMC", 10 .c_vendor = "UMC",
15 .c_ident = { "UMC UMC UMC" }, 11 .c_ident = { "UMC UMC UMC" },
16 .c_models = { 12 .c_models = {
@@ -21,7 +17,6 @@ static struct cpu_dev umc_cpu_dev __initdata = {
21 } 17 }
22 }, 18 },
23 }, 19 },
24 .c_init = init_umc,
25}; 20};
26 21
27int __init umc_init_cpu(void) 22int __init umc_init_cpu(void)
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index 5b96f038367f..67d297dc1003 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -22,6 +22,8 @@
22#include <asm/nmi.h> 22#include <asm/nmi.h>
23#include <asm/hw_irq.h> 23#include <asm/hw_irq.h>
24#include <asm/apic.h> 24#include <asm/apic.h>
25#include <asm/kdebug.h>
26
25#include <mach_ipi.h> 27#include <mach_ipi.h>
26 28
27 29
@@ -93,16 +95,25 @@ static void crash_save_self(struct pt_regs *regs)
93#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) 95#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
94static atomic_t waiting_for_crash_ipi; 96static atomic_t waiting_for_crash_ipi;
95 97
96static int crash_nmi_callback(struct pt_regs *regs, int cpu) 98static int crash_nmi_callback(struct notifier_block *self,
99 unsigned long val, void *data)
97{ 100{
101 struct pt_regs *regs;
98 struct pt_regs fixed_regs; 102 struct pt_regs fixed_regs;
103 int cpu;
104
105 if (val != DIE_NMI_IPI)
106 return NOTIFY_OK;
107
108 regs = ((struct die_args *)data)->regs;
109 cpu = raw_smp_processor_id();
99 110
100 /* Don't do anything if this handler is invoked on crashing cpu. 111 /* Don't do anything if this handler is invoked on crashing cpu.
101 * Otherwise, system will completely hang. Crashing cpu can get 112 * Otherwise, system will completely hang. Crashing cpu can get
102 * an NMI if system was initially booted with nmi_watchdog parameter. 113 * an NMI if system was initially booted with nmi_watchdog parameter.
103 */ 114 */
104 if (cpu == crashing_cpu) 115 if (cpu == crashing_cpu)
105 return 1; 116 return NOTIFY_STOP;
106 local_irq_disable(); 117 local_irq_disable();
107 118
108 if (!user_mode_vm(regs)) { 119 if (!user_mode_vm(regs)) {
@@ -125,13 +136,18 @@ static void smp_send_nmi_allbutself(void)
125 send_IPI_allbutself(NMI_VECTOR); 136 send_IPI_allbutself(NMI_VECTOR);
126} 137}
127 138
139static struct notifier_block crash_nmi_nb = {
140 .notifier_call = crash_nmi_callback,
141};
142
128static void nmi_shootdown_cpus(void) 143static void nmi_shootdown_cpus(void)
129{ 144{
130 unsigned long msecs; 145 unsigned long msecs;
131 146
132 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); 147 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
133 /* Would it be better to replace the trap vector here? */ 148 /* Would it be better to replace the trap vector here? */
134 set_nmi_callback(crash_nmi_callback); 149 if (register_die_notifier(&crash_nmi_nb))
150 return; /* return what? */
135 /* Ensure the new callback function is set before sending 151 /* Ensure the new callback function is set before sending
136 * out the NMI 152 * out the NMI
137 */ 153 */
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 87f9f60b803b..5a63d6fdb70e 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -76,8 +76,15 @@ DF_MASK = 0x00000400
76NT_MASK = 0x00004000 76NT_MASK = 0x00004000
77VM_MASK = 0x00020000 77VM_MASK = 0x00020000
78 78
79/* These are replaces for paravirtualization */
80#define DISABLE_INTERRUPTS cli
81#define ENABLE_INTERRUPTS sti
82#define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
83#define INTERRUPT_RETURN iret
84#define GET_CR0_INTO_EAX movl %cr0, %eax
85
79#ifdef CONFIG_PREEMPT 86#ifdef CONFIG_PREEMPT
80#define preempt_stop cli; TRACE_IRQS_OFF 87#define preempt_stop DISABLE_INTERRUPTS; TRACE_IRQS_OFF
81#else 88#else
82#define preempt_stop 89#define preempt_stop
83#define resume_kernel restore_nocheck 90#define resume_kernel restore_nocheck
@@ -176,18 +183,21 @@ VM_MASK = 0x00020000
176 183
177#define RING0_INT_FRAME \ 184#define RING0_INT_FRAME \
178 CFI_STARTPROC simple;\ 185 CFI_STARTPROC simple;\
186 CFI_SIGNAL_FRAME;\
179 CFI_DEF_CFA esp, 3*4;\ 187 CFI_DEF_CFA esp, 3*4;\
180 /*CFI_OFFSET cs, -2*4;*/\ 188 /*CFI_OFFSET cs, -2*4;*/\
181 CFI_OFFSET eip, -3*4 189 CFI_OFFSET eip, -3*4
182 190
183#define RING0_EC_FRAME \ 191#define RING0_EC_FRAME \
184 CFI_STARTPROC simple;\ 192 CFI_STARTPROC simple;\
193 CFI_SIGNAL_FRAME;\
185 CFI_DEF_CFA esp, 4*4;\ 194 CFI_DEF_CFA esp, 4*4;\
186 /*CFI_OFFSET cs, -2*4;*/\ 195 /*CFI_OFFSET cs, -2*4;*/\
187 CFI_OFFSET eip, -3*4 196 CFI_OFFSET eip, -3*4
188 197
189#define RING0_PTREGS_FRAME \ 198#define RING0_PTREGS_FRAME \
190 CFI_STARTPROC simple;\ 199 CFI_STARTPROC simple;\
200 CFI_SIGNAL_FRAME;\
191 CFI_DEF_CFA esp, OLDESP-EBX;\ 201 CFI_DEF_CFA esp, OLDESP-EBX;\
192 /*CFI_OFFSET cs, CS-OLDESP;*/\ 202 /*CFI_OFFSET cs, CS-OLDESP;*/\
193 CFI_OFFSET eip, EIP-OLDESP;\ 203 CFI_OFFSET eip, EIP-OLDESP;\
@@ -233,10 +243,11 @@ ret_from_intr:
233check_userspace: 243check_userspace:
234 movl EFLAGS(%esp), %eax # mix EFLAGS and CS 244 movl EFLAGS(%esp), %eax # mix EFLAGS and CS
235 movb CS(%esp), %al 245 movb CS(%esp), %al
236 testl $(VM_MASK | 3), %eax 246 andl $(VM_MASK | SEGMENT_RPL_MASK), %eax
237 jz resume_kernel 247 cmpl $USER_RPL, %eax
248 jb resume_kernel # not returning to v8086 or userspace
238ENTRY(resume_userspace) 249ENTRY(resume_userspace)
239 cli # make sure we don't miss an interrupt 250 DISABLE_INTERRUPTS # make sure we don't miss an interrupt
240 # setting need_resched or sigpending 251 # setting need_resched or sigpending
241 # between sampling and the iret 252 # between sampling and the iret
242 movl TI_flags(%ebp), %ecx 253 movl TI_flags(%ebp), %ecx
@@ -247,7 +258,7 @@ ENTRY(resume_userspace)
247 258
248#ifdef CONFIG_PREEMPT 259#ifdef CONFIG_PREEMPT
249ENTRY(resume_kernel) 260ENTRY(resume_kernel)
250 cli 261 DISABLE_INTERRUPTS
251 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ? 262 cmpl $0,TI_preempt_count(%ebp) # non-zero preempt_count ?
252 jnz restore_nocheck 263 jnz restore_nocheck
253need_resched: 264need_resched:
@@ -267,6 +278,7 @@ need_resched:
267 # sysenter call handler stub 278 # sysenter call handler stub
268ENTRY(sysenter_entry) 279ENTRY(sysenter_entry)
269 CFI_STARTPROC simple 280 CFI_STARTPROC simple
281 CFI_SIGNAL_FRAME
270 CFI_DEF_CFA esp, 0 282 CFI_DEF_CFA esp, 0
271 CFI_REGISTER esp, ebp 283 CFI_REGISTER esp, ebp
272 movl TSS_sysenter_esp0(%esp),%esp 284 movl TSS_sysenter_esp0(%esp),%esp
@@ -275,7 +287,7 @@ sysenter_past_esp:
275 * No need to follow this irqs on/off section: the syscall 287 * No need to follow this irqs on/off section: the syscall
276 * disabled irqs and here we enable it straight after entry: 288 * disabled irqs and here we enable it straight after entry:
277 */ 289 */
278 sti 290 ENABLE_INTERRUPTS
279 pushl $(__USER_DS) 291 pushl $(__USER_DS)
280 CFI_ADJUST_CFA_OFFSET 4 292 CFI_ADJUST_CFA_OFFSET 4
281 /*CFI_REL_OFFSET ss, 0*/ 293 /*CFI_REL_OFFSET ss, 0*/
@@ -320,7 +332,7 @@ sysenter_past_esp:
320 jae syscall_badsys 332 jae syscall_badsys
321 call *sys_call_table(,%eax,4) 333 call *sys_call_table(,%eax,4)
322 movl %eax,EAX(%esp) 334 movl %eax,EAX(%esp)
323 cli 335 DISABLE_INTERRUPTS
324 TRACE_IRQS_OFF 336 TRACE_IRQS_OFF
325 movl TI_flags(%ebp), %ecx 337 movl TI_flags(%ebp), %ecx
326 testw $_TIF_ALLWORK_MASK, %cx 338 testw $_TIF_ALLWORK_MASK, %cx
@@ -330,8 +342,7 @@ sysenter_past_esp:
330 movl OLDESP(%esp), %ecx 342 movl OLDESP(%esp), %ecx
331 xorl %ebp,%ebp 343 xorl %ebp,%ebp
332 TRACE_IRQS_ON 344 TRACE_IRQS_ON
333 sti 345 ENABLE_INTERRUPTS_SYSEXIT
334 sysexit
335 CFI_ENDPROC 346 CFI_ENDPROC
336 347
337 348
@@ -356,7 +367,7 @@ syscall_call:
356 call *sys_call_table(,%eax,4) 367 call *sys_call_table(,%eax,4)
357 movl %eax,EAX(%esp) # store the return value 368 movl %eax,EAX(%esp) # store the return value
358syscall_exit: 369syscall_exit:
359 cli # make sure we don't miss an interrupt 370 DISABLE_INTERRUPTS # make sure we don't miss an interrupt
360 # setting need_resched or sigpending 371 # setting need_resched or sigpending
361 # between sampling and the iret 372 # between sampling and the iret
362 TRACE_IRQS_OFF 373 TRACE_IRQS_OFF
@@ -371,8 +382,8 @@ restore_all:
371 # See comments in process.c:copy_thread() for details. 382 # See comments in process.c:copy_thread() for details.
372 movb OLDSS(%esp), %ah 383 movb OLDSS(%esp), %ah
373 movb CS(%esp), %al 384 movb CS(%esp), %al
374 andl $(VM_MASK | (4 << 8) | 3), %eax 385 andl $(VM_MASK | (SEGMENT_TI_MASK << 8) | SEGMENT_RPL_MASK), %eax
375 cmpl $((4 << 8) | 3), %eax 386 cmpl $((SEGMENT_LDT << 8) | USER_RPL), %eax
376 CFI_REMEMBER_STATE 387 CFI_REMEMBER_STATE
377 je ldt_ss # returning to user-space with LDT SS 388 je ldt_ss # returning to user-space with LDT SS
378restore_nocheck: 389restore_nocheck:
@@ -381,11 +392,11 @@ restore_nocheck_notrace:
381 RESTORE_REGS 392 RESTORE_REGS
382 addl $4, %esp 393 addl $4, %esp
383 CFI_ADJUST_CFA_OFFSET -4 394 CFI_ADJUST_CFA_OFFSET -4
3841: iret 3951: INTERRUPT_RETURN
385.section .fixup,"ax" 396.section .fixup,"ax"
386iret_exc: 397iret_exc:
387 TRACE_IRQS_ON 398 TRACE_IRQS_ON
388 sti 399 ENABLE_INTERRUPTS
389 pushl $0 # no error code 400 pushl $0 # no error code
390 pushl $do_iret_error 401 pushl $do_iret_error
391 jmp error_code 402 jmp error_code
@@ -409,7 +420,7 @@ ldt_ss:
409 * dosemu and wine happy. */ 420 * dosemu and wine happy. */
410 subl $8, %esp # reserve space for switch16 pointer 421 subl $8, %esp # reserve space for switch16 pointer
411 CFI_ADJUST_CFA_OFFSET 8 422 CFI_ADJUST_CFA_OFFSET 8
412 cli 423 DISABLE_INTERRUPTS
413 TRACE_IRQS_OFF 424 TRACE_IRQS_OFF
414 movl %esp, %eax 425 movl %esp, %eax
415 /* Set up the 16bit stack frame with switch32 pointer on top, 426 /* Set up the 16bit stack frame with switch32 pointer on top,
@@ -419,7 +430,7 @@ ldt_ss:
419 TRACE_IRQS_IRET 430 TRACE_IRQS_IRET
420 RESTORE_REGS 431 RESTORE_REGS
421 lss 20+4(%esp), %esp # switch to 16bit stack 432 lss 20+4(%esp), %esp # switch to 16bit stack
4221: iret 4331: INTERRUPT_RETURN
423.section __ex_table,"a" 434.section __ex_table,"a"
424 .align 4 435 .align 4
425 .long 1b,iret_exc 436 .long 1b,iret_exc
@@ -434,7 +445,7 @@ work_pending:
434 jz work_notifysig 445 jz work_notifysig
435work_resched: 446work_resched:
436 call schedule 447 call schedule
437 cli # make sure we don't miss an interrupt 448 DISABLE_INTERRUPTS # make sure we don't miss an interrupt
438 # setting need_resched or sigpending 449 # setting need_resched or sigpending
439 # between sampling and the iret 450 # between sampling and the iret
440 TRACE_IRQS_OFF 451 TRACE_IRQS_OFF
@@ -490,7 +501,7 @@ syscall_exit_work:
490 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl 501 testb $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP), %cl
491 jz work_pending 502 jz work_pending
492 TRACE_IRQS_ON 503 TRACE_IRQS_ON
493 sti # could let do_syscall_trace() call 504 ENABLE_INTERRUPTS # could let do_syscall_trace() call
494 # schedule() instead 505 # schedule() instead
495 movl %esp, %eax 506 movl %esp, %eax
496 movl $1, %edx 507 movl $1, %edx
@@ -591,11 +602,9 @@ ENTRY(name) \
591/* The include is where all of the SMP etc. interrupts come from */ 602/* The include is where all of the SMP etc. interrupts come from */
592#include "entry_arch.h" 603#include "entry_arch.h"
593 604
594ENTRY(divide_error) 605KPROBE_ENTRY(page_fault)
595 RING0_INT_FRAME 606 RING0_EC_FRAME
596 pushl $0 # no error code 607 pushl $do_page_fault
597 CFI_ADJUST_CFA_OFFSET 4
598 pushl $do_divide_error
599 CFI_ADJUST_CFA_OFFSET 4 608 CFI_ADJUST_CFA_OFFSET 4
600 ALIGN 609 ALIGN
601error_code: 610error_code:
@@ -645,6 +654,7 @@ error_code:
645 call *%edi 654 call *%edi
646 jmp ret_from_exception 655 jmp ret_from_exception
647 CFI_ENDPROC 656 CFI_ENDPROC
657KPROBE_END(page_fault)
648 658
649ENTRY(coprocessor_error) 659ENTRY(coprocessor_error)
650 RING0_INT_FRAME 660 RING0_INT_FRAME
@@ -669,7 +679,7 @@ ENTRY(device_not_available)
669 pushl $-1 # mark this as an int 679 pushl $-1 # mark this as an int
670 CFI_ADJUST_CFA_OFFSET 4 680 CFI_ADJUST_CFA_OFFSET 4
671 SAVE_ALL 681 SAVE_ALL
672 movl %cr0, %eax 682 GET_CR0_INTO_EAX
673 testl $0x4, %eax # EM (math emulation bit) 683 testl $0x4, %eax # EM (math emulation bit)
674 jne device_not_available_emulate 684 jne device_not_available_emulate
675 preempt_stop 685 preempt_stop
@@ -702,9 +712,15 @@ device_not_available_emulate:
702 jne ok; \ 712 jne ok; \
703label: \ 713label: \
704 movl TSS_sysenter_esp0+offset(%esp),%esp; \ 714 movl TSS_sysenter_esp0+offset(%esp),%esp; \
715 CFI_DEF_CFA esp, 0; \
716 CFI_UNDEFINED eip; \
705 pushfl; \ 717 pushfl; \
718 CFI_ADJUST_CFA_OFFSET 4; \
706 pushl $__KERNEL_CS; \ 719 pushl $__KERNEL_CS; \
707 pushl $sysenter_past_esp 720 CFI_ADJUST_CFA_OFFSET 4; \
721 pushl $sysenter_past_esp; \
722 CFI_ADJUST_CFA_OFFSET 4; \
723 CFI_REL_OFFSET eip, 0
708 724
709KPROBE_ENTRY(debug) 725KPROBE_ENTRY(debug)
710 RING0_INT_FRAME 726 RING0_INT_FRAME
@@ -720,7 +736,8 @@ debug_stack_correct:
720 call do_debug 736 call do_debug
721 jmp ret_from_exception 737 jmp ret_from_exception
722 CFI_ENDPROC 738 CFI_ENDPROC
723 .previous .text 739KPROBE_END(debug)
740
724/* 741/*
725 * NMI is doubly nasty. It can happen _while_ we're handling 742 * NMI is doubly nasty. It can happen _while_ we're handling
726 * a debug fault, and the debug fault hasn't yet been able to 743 * a debug fault, and the debug fault hasn't yet been able to
@@ -729,7 +746,7 @@ debug_stack_correct:
729 * check whether we got an NMI on the debug path where the debug 746 * check whether we got an NMI on the debug path where the debug
730 * fault happened on the sysenter path. 747 * fault happened on the sysenter path.
731 */ 748 */
732ENTRY(nmi) 749KPROBE_ENTRY(nmi)
733 RING0_INT_FRAME 750 RING0_INT_FRAME
734 pushl %eax 751 pushl %eax
735 CFI_ADJUST_CFA_OFFSET 4 752 CFI_ADJUST_CFA_OFFSET 4
@@ -754,6 +771,7 @@ ENTRY(nmi)
754 cmpl $sysenter_entry,12(%esp) 771 cmpl $sysenter_entry,12(%esp)
755 je nmi_debug_stack_check 772 je nmi_debug_stack_check
756nmi_stack_correct: 773nmi_stack_correct:
774 /* We have a RING0_INT_FRAME here */
757 pushl %eax 775 pushl %eax
758 CFI_ADJUST_CFA_OFFSET 4 776 CFI_ADJUST_CFA_OFFSET 4
759 SAVE_ALL 777 SAVE_ALL
@@ -764,9 +782,12 @@ nmi_stack_correct:
764 CFI_ENDPROC 782 CFI_ENDPROC
765 783
766nmi_stack_fixup: 784nmi_stack_fixup:
785 RING0_INT_FRAME
767 FIX_STACK(12,nmi_stack_correct, 1) 786 FIX_STACK(12,nmi_stack_correct, 1)
768 jmp nmi_stack_correct 787 jmp nmi_stack_correct
788
769nmi_debug_stack_check: 789nmi_debug_stack_check:
790 /* We have a RING0_INT_FRAME here */
770 cmpw $__KERNEL_CS,16(%esp) 791 cmpw $__KERNEL_CS,16(%esp)
771 jne nmi_stack_correct 792 jne nmi_stack_correct
772 cmpl $debug,(%esp) 793 cmpl $debug,(%esp)
@@ -777,8 +798,10 @@ nmi_debug_stack_check:
777 jmp nmi_stack_correct 798 jmp nmi_stack_correct
778 799
779nmi_16bit_stack: 800nmi_16bit_stack:
780 RING0_INT_FRAME 801 /* We have a RING0_INT_FRAME here.
781 /* create the pointer to lss back */ 802 *
803 * create the pointer to lss back
804 */
782 pushl %ss 805 pushl %ss
783 CFI_ADJUST_CFA_OFFSET 4 806 CFI_ADJUST_CFA_OFFSET 4
784 pushl %esp 807 pushl %esp
@@ -799,12 +822,13 @@ nmi_16bit_stack:
799 call do_nmi 822 call do_nmi
800 RESTORE_REGS 823 RESTORE_REGS
801 lss 12+4(%esp), %esp # back to 16bit stack 824 lss 12+4(%esp), %esp # back to 16bit stack
8021: iret 8251: INTERRUPT_RETURN
803 CFI_ENDPROC 826 CFI_ENDPROC
804.section __ex_table,"a" 827.section __ex_table,"a"
805 .align 4 828 .align 4
806 .long 1b,iret_exc 829 .long 1b,iret_exc
807.previous 830.previous
831KPROBE_END(nmi)
808 832
809KPROBE_ENTRY(int3) 833KPROBE_ENTRY(int3)
810 RING0_INT_FRAME 834 RING0_INT_FRAME
@@ -816,7 +840,7 @@ KPROBE_ENTRY(int3)
816 call do_int3 840 call do_int3
817 jmp ret_from_exception 841 jmp ret_from_exception
818 CFI_ENDPROC 842 CFI_ENDPROC
819 .previous .text 843KPROBE_END(int3)
820 844
821ENTRY(overflow) 845ENTRY(overflow)
822 RING0_INT_FRAME 846 RING0_INT_FRAME
@@ -881,7 +905,7 @@ KPROBE_ENTRY(general_protection)
881 CFI_ADJUST_CFA_OFFSET 4 905 CFI_ADJUST_CFA_OFFSET 4
882 jmp error_code 906 jmp error_code
883 CFI_ENDPROC 907 CFI_ENDPROC
884 .previous .text 908KPROBE_END(general_protection)
885 909
886ENTRY(alignment_check) 910ENTRY(alignment_check)
887 RING0_EC_FRAME 911 RING0_EC_FRAME
@@ -890,13 +914,14 @@ ENTRY(alignment_check)
890 jmp error_code 914 jmp error_code
891 CFI_ENDPROC 915 CFI_ENDPROC
892 916
893KPROBE_ENTRY(page_fault) 917ENTRY(divide_error)
894 RING0_EC_FRAME 918 RING0_INT_FRAME
895 pushl $do_page_fault 919 pushl $0 # no error code
920 CFI_ADJUST_CFA_OFFSET 4
921 pushl $do_divide_error
896 CFI_ADJUST_CFA_OFFSET 4 922 CFI_ADJUST_CFA_OFFSET 4
897 jmp error_code 923 jmp error_code
898 CFI_ENDPROC 924 CFI_ENDPROC
899 .previous .text
900 925
901#ifdef CONFIG_X86_MCE 926#ifdef CONFIG_X86_MCE
902ENTRY(machine_check) 927ENTRY(machine_check)
@@ -949,6 +974,19 @@ ENTRY(arch_unwind_init_running)
949ENDPROC(arch_unwind_init_running) 974ENDPROC(arch_unwind_init_running)
950#endif 975#endif
951 976
977ENTRY(kernel_thread_helper)
978 pushl $0 # fake return address for unwinder
979 CFI_STARTPROC
980 movl %edx,%eax
981 push %edx
982 CFI_ADJUST_CFA_OFFSET 4
983 call *%ebx
984 push %eax
985 CFI_ADJUST_CFA_OFFSET 4
986 call do_exit
987 CFI_ENDPROC
988ENDPROC(kernel_thread_helper)
989
952.section .rodata,"a" 990.section .rodata,"a"
953#include "syscall_table.S" 991#include "syscall_table.S"
954 992
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index a6b8bd89aa27..be9d883c62ce 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -371,8 +371,65 @@ rp_sidt:
371 addl $8,%edi 371 addl $8,%edi
372 dec %ecx 372 dec %ecx
373 jne rp_sidt 373 jne rp_sidt
374
375.macro set_early_handler handler,trapno
376 lea \handler,%edx
377 movl $(__KERNEL_CS << 16),%eax
378 movw %dx,%ax
379 movw $0x8E00,%dx /* interrupt gate - dpl=0, present */
380 lea idt_table,%edi
381 movl %eax,8*\trapno(%edi)
382 movl %edx,8*\trapno+4(%edi)
383.endm
384
385 set_early_handler handler=early_divide_err,trapno=0
386 set_early_handler handler=early_illegal_opcode,trapno=6
387 set_early_handler handler=early_protection_fault,trapno=13
388 set_early_handler handler=early_page_fault,trapno=14
389
374 ret 390 ret
375 391
392early_divide_err:
393 xor %edx,%edx
394 pushl $0 /* fake errcode */
395 jmp early_fault
396
397early_illegal_opcode:
398 movl $6,%edx
399 pushl $0 /* fake errcode */
400 jmp early_fault
401
402early_protection_fault:
403 movl $13,%edx
404 jmp early_fault
405
406early_page_fault:
407 movl $14,%edx
408 jmp early_fault
409
410early_fault:
411 cld
412#ifdef CONFIG_PRINTK
413 movl $(__KERNEL_DS),%eax
414 movl %eax,%ds
415 movl %eax,%es
416 cmpl $2,early_recursion_flag
417 je hlt_loop
418 incl early_recursion_flag
419 movl %cr2,%eax
420 pushl %eax
421 pushl %edx /* trapno */
422 pushl $fault_msg
423#ifdef CONFIG_EARLY_PRINTK
424 call early_printk
425#else
426 call printk
427#endif
428#endif
429hlt_loop:
430 hlt
431 jmp hlt_loop
432
376/* This is the default interrupt "handler" :-) */ 433/* This is the default interrupt "handler" :-) */
377 ALIGN 434 ALIGN
378ignore_int: 435ignore_int:
@@ -386,6 +443,9 @@ ignore_int:
386 movl $(__KERNEL_DS),%eax 443 movl $(__KERNEL_DS),%eax
387 movl %eax,%ds 444 movl %eax,%ds
388 movl %eax,%es 445 movl %eax,%es
446 cmpl $2,early_recursion_flag
447 je hlt_loop
448 incl early_recursion_flag
389 pushl 16(%esp) 449 pushl 16(%esp)
390 pushl 24(%esp) 450 pushl 24(%esp)
391 pushl 32(%esp) 451 pushl 32(%esp)
@@ -431,9 +491,16 @@ ENTRY(stack_start)
431 491
432ready: .byte 0 492ready: .byte 0
433 493
494early_recursion_flag:
495 .long 0
496
434int_msg: 497int_msg:
435 .asciz "Unknown interrupt or fault at EIP %p %p %p\n" 498 .asciz "Unknown interrupt or fault at EIP %p %p %p\n"
436 499
500fault_msg:
501 .ascii "Int %d: CR2 %p err %p EIP %p CS %p flags %p\n"
502 .asciz "Stack: %p %p %p %p %p %p %p %p\n"
503
437/* 504/*
438 * The IDT and GDT 'descriptors' are a strange 48-bit object 505 * The IDT and GDT 'descriptors' are a strange 48-bit object
439 * only used by the lidt and lgdt instructions. They are not 506 * only used by the lidt and lgdt instructions. They are not
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index d4756d154f47..ea5f4e7958d8 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -45,6 +45,8 @@ static void end_8259A_irq (unsigned int irq)
45 45
46#define shutdown_8259A_irq disable_8259A_irq 46#define shutdown_8259A_irq disable_8259A_irq
47 47
48static int i8259A_auto_eoi;
49
48static void mask_and_ack_8259A(unsigned int); 50static void mask_and_ack_8259A(unsigned int);
49 51
50unsigned int startup_8259A_irq(unsigned int irq) 52unsigned int startup_8259A_irq(unsigned int irq)
@@ -253,7 +255,7 @@ static void save_ELCR(char *trigger)
253 255
254static int i8259A_resume(struct sys_device *dev) 256static int i8259A_resume(struct sys_device *dev)
255{ 257{
256 init_8259A(0); 258 init_8259A(i8259A_auto_eoi);
257 restore_ELCR(irq_trigger); 259 restore_ELCR(irq_trigger);
258 return 0; 260 return 0;
259} 261}
@@ -301,6 +303,8 @@ void init_8259A(int auto_eoi)
301{ 303{
302 unsigned long flags; 304 unsigned long flags;
303 305
306 i8259A_auto_eoi = auto_eoi;
307
304 spin_lock_irqsave(&i8259A_lock, flags); 308 spin_lock_irqsave(&i8259A_lock, flags);
305 309
306 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */ 310 outb(0xff, PIC_MASTER_IMR); /* mask all of 8259A-1 */
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 4fb32c551fe0..fd0df75cfbda 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -40,6 +40,7 @@
40#include <asm/nmi.h> 40#include <asm/nmi.h>
41 41
42#include <mach_apic.h> 42#include <mach_apic.h>
43#include <mach_apicdef.h>
43 44
44#include "io_ports.h" 45#include "io_ports.h"
45 46
@@ -65,7 +66,7 @@ int sis_apic_bug = -1;
65 */ 66 */
66int nr_ioapic_registers[MAX_IO_APICS]; 67int nr_ioapic_registers[MAX_IO_APICS];
67 68
68int disable_timer_pin_1 __initdata; 69static int disable_timer_pin_1 __initdata;
69 70
70/* 71/*
71 * Rough estimation of how many shared IRQs there are, can 72 * Rough estimation of how many shared IRQs there are, can
@@ -93,6 +94,34 @@ int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1};
93#define vector_to_irq(vector) (vector) 94#define vector_to_irq(vector) (vector)
94#endif 95#endif
95 96
97
98union entry_union {
99 struct { u32 w1, w2; };
100 struct IO_APIC_route_entry entry;
101};
102
103static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
104{
105 union entry_union eu;
106 unsigned long flags;
107 spin_lock_irqsave(&ioapic_lock, flags);
108 eu.w1 = io_apic_read(apic, 0x10 + 2 * pin);
109 eu.w2 = io_apic_read(apic, 0x11 + 2 * pin);
110 spin_unlock_irqrestore(&ioapic_lock, flags);
111 return eu.entry;
112}
113
114static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
115{
116 unsigned long flags;
117 union entry_union eu;
118 eu.entry = e;
119 spin_lock_irqsave(&ioapic_lock, flags);
120 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
121 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
122 spin_unlock_irqrestore(&ioapic_lock, flags);
123}
124
96/* 125/*
97 * The common case is 1:1 IRQ<->pin mappings. Sometimes there are 126 * The common case is 1:1 IRQ<->pin mappings. Sometimes there are
98 * shared ISA-space IRQs, so we have to support them. We are super 127 * shared ISA-space IRQs, so we have to support them. We are super
@@ -200,13 +229,9 @@ static void unmask_IO_APIC_irq (unsigned int irq)
200static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) 229static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
201{ 230{
202 struct IO_APIC_route_entry entry; 231 struct IO_APIC_route_entry entry;
203 unsigned long flags;
204 232
205 /* Check delivery_mode to be sure we're not clearing an SMI pin */ 233 /* Check delivery_mode to be sure we're not clearing an SMI pin */
206 spin_lock_irqsave(&ioapic_lock, flags); 234 entry = ioapic_read_entry(apic, pin);
207 *(((int*)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
208 *(((int*)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
209 spin_unlock_irqrestore(&ioapic_lock, flags);
210 if (entry.delivery_mode == dest_SMI) 235 if (entry.delivery_mode == dest_SMI)
211 return; 236 return;
212 237
@@ -215,10 +240,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
215 */ 240 */
216 memset(&entry, 0, sizeof(entry)); 241 memset(&entry, 0, sizeof(entry));
217 entry.mask = 1; 242 entry.mask = 1;
218 spin_lock_irqsave(&ioapic_lock, flags); 243 ioapic_write_entry(apic, pin, entry);
219 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry) + 0));
220 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry) + 1));
221 spin_unlock_irqrestore(&ioapic_lock, flags);
222} 244}
223 245
224static void clear_IO_APIC (void) 246static void clear_IO_APIC (void)
@@ -1283,9 +1305,8 @@ static void __init setup_IO_APIC_irqs(void)
1283 if (!apic && (irq < 16)) 1305 if (!apic && (irq < 16))
1284 disable_8259A_irq(irq); 1306 disable_8259A_irq(irq);
1285 } 1307 }
1308 ioapic_write_entry(apic, pin, entry);
1286 spin_lock_irqsave(&ioapic_lock, flags); 1309 spin_lock_irqsave(&ioapic_lock, flags);
1287 io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
1288 io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
1289 set_native_irq_info(irq, TARGET_CPUS); 1310 set_native_irq_info(irq, TARGET_CPUS);
1290 spin_unlock_irqrestore(&ioapic_lock, flags); 1311 spin_unlock_irqrestore(&ioapic_lock, flags);
1291 } 1312 }
@@ -1301,7 +1322,6 @@ static void __init setup_IO_APIC_irqs(void)
1301static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector) 1322static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector)
1302{ 1323{
1303 struct IO_APIC_route_entry entry; 1324 struct IO_APIC_route_entry entry;
1304 unsigned long flags;
1305 1325
1306 memset(&entry,0,sizeof(entry)); 1326 memset(&entry,0,sizeof(entry));
1307 1327
@@ -1331,10 +1351,7 @@ static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, in
1331 /* 1351 /*
1332 * Add it to the IO-APIC irq-routing table: 1352 * Add it to the IO-APIC irq-routing table:
1333 */ 1353 */
1334 spin_lock_irqsave(&ioapic_lock, flags); 1354 ioapic_write_entry(apic, pin, entry);
1335 io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
1336 io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
1337 spin_unlock_irqrestore(&ioapic_lock, flags);
1338 1355
1339 enable_8259A_irq(0); 1356 enable_8259A_irq(0);
1340} 1357}
@@ -1444,10 +1461,7 @@ void __init print_IO_APIC(void)
1444 for (i = 0; i <= reg_01.bits.entries; i++) { 1461 for (i = 0; i <= reg_01.bits.entries; i++) {
1445 struct IO_APIC_route_entry entry; 1462 struct IO_APIC_route_entry entry;
1446 1463
1447 spin_lock_irqsave(&ioapic_lock, flags); 1464 entry = ioapic_read_entry(apic, i);
1448 *(((int *)&entry)+0) = io_apic_read(apic, 0x10+i*2);
1449 *(((int *)&entry)+1) = io_apic_read(apic, 0x11+i*2);
1450 spin_unlock_irqrestore(&ioapic_lock, flags);
1451 1465
1452 printk(KERN_DEBUG " %02x %03X %02X ", 1466 printk(KERN_DEBUG " %02x %03X %02X ",
1453 i, 1467 i,
@@ -1666,10 +1680,7 @@ static void __init enable_IO_APIC(void)
1666 /* See if any of the pins is in ExtINT mode */ 1680 /* See if any of the pins is in ExtINT mode */
1667 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { 1681 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
1668 struct IO_APIC_route_entry entry; 1682 struct IO_APIC_route_entry entry;
1669 spin_lock_irqsave(&ioapic_lock, flags); 1683 entry = ioapic_read_entry(apic, pin);
1670 *(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
1671 *(((int *)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
1672 spin_unlock_irqrestore(&ioapic_lock, flags);
1673 1684
1674 1685
1675 /* If the interrupt line is enabled and in ExtInt mode 1686 /* If the interrupt line is enabled and in ExtInt mode
@@ -1726,7 +1737,6 @@ void disable_IO_APIC(void)
1726 */ 1737 */
1727 if (ioapic_i8259.pin != -1) { 1738 if (ioapic_i8259.pin != -1) {
1728 struct IO_APIC_route_entry entry; 1739 struct IO_APIC_route_entry entry;
1729 unsigned long flags;
1730 1740
1731 memset(&entry, 0, sizeof(entry)); 1741 memset(&entry, 0, sizeof(entry));
1732 entry.mask = 0; /* Enabled */ 1742 entry.mask = 0; /* Enabled */
@@ -1743,12 +1753,7 @@ void disable_IO_APIC(void)
1743 /* 1753 /*
1744 * Add it to the IO-APIC irq-routing table: 1754 * Add it to the IO-APIC irq-routing table:
1745 */ 1755 */
1746 spin_lock_irqsave(&ioapic_lock, flags); 1756 ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry);
1747 io_apic_write(ioapic_i8259.apic, 0x11+2*ioapic_i8259.pin,
1748 *(((int *)&entry)+1));
1749 io_apic_write(ioapic_i8259.apic, 0x10+2*ioapic_i8259.pin,
1750 *(((int *)&entry)+0));
1751 spin_unlock_irqrestore(&ioapic_lock, flags);
1752 } 1757 }
1753 disconnect_bsp_APIC(ioapic_i8259.pin != -1); 1758 disconnect_bsp_APIC(ioapic_i8259.pin != -1);
1754} 1759}
@@ -2213,17 +2218,13 @@ static inline void unlock_ExtINT_logic(void)
2213 int apic, pin, i; 2218 int apic, pin, i;
2214 struct IO_APIC_route_entry entry0, entry1; 2219 struct IO_APIC_route_entry entry0, entry1;
2215 unsigned char save_control, save_freq_select; 2220 unsigned char save_control, save_freq_select;
2216 unsigned long flags;
2217 2221
2218 pin = find_isa_irq_pin(8, mp_INT); 2222 pin = find_isa_irq_pin(8, mp_INT);
2219 apic = find_isa_irq_apic(8, mp_INT); 2223 apic = find_isa_irq_apic(8, mp_INT);
2220 if (pin == -1) 2224 if (pin == -1)
2221 return; 2225 return;
2222 2226
2223 spin_lock_irqsave(&ioapic_lock, flags); 2227 entry0 = ioapic_read_entry(apic, pin);
2224 *(((int *)&entry0) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
2225 *(((int *)&entry0) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
2226 spin_unlock_irqrestore(&ioapic_lock, flags);
2227 clear_IO_APIC_pin(apic, pin); 2228 clear_IO_APIC_pin(apic, pin);
2228 2229
2229 memset(&entry1, 0, sizeof(entry1)); 2230 memset(&entry1, 0, sizeof(entry1));
@@ -2236,10 +2237,7 @@ static inline void unlock_ExtINT_logic(void)
2236 entry1.trigger = 0; 2237 entry1.trigger = 0;
2237 entry1.vector = 0; 2238 entry1.vector = 0;
2238 2239
2239 spin_lock_irqsave(&ioapic_lock, flags); 2240 ioapic_write_entry(apic, pin, entry1);
2240 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
2241 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
2242 spin_unlock_irqrestore(&ioapic_lock, flags);
2243 2241
2244 save_control = CMOS_READ(RTC_CONTROL); 2242 save_control = CMOS_READ(RTC_CONTROL);
2245 save_freq_select = CMOS_READ(RTC_FREQ_SELECT); 2243 save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
@@ -2258,10 +2256,7 @@ static inline void unlock_ExtINT_logic(void)
2258 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); 2256 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
2259 clear_IO_APIC_pin(apic, pin); 2257 clear_IO_APIC_pin(apic, pin);
2260 2258
2261 spin_lock_irqsave(&ioapic_lock, flags); 2259 ioapic_write_entry(apic, pin, entry0);
2262 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
2263 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
2264 spin_unlock_irqrestore(&ioapic_lock, flags);
2265} 2260}
2266 2261
2267int timer_uses_ioapic_pin_0; 2262int timer_uses_ioapic_pin_0;
@@ -2461,17 +2456,12 @@ static int ioapic_suspend(struct sys_device *dev, pm_message_t state)
2461{ 2456{
2462 struct IO_APIC_route_entry *entry; 2457 struct IO_APIC_route_entry *entry;
2463 struct sysfs_ioapic_data *data; 2458 struct sysfs_ioapic_data *data;
2464 unsigned long flags;
2465 int i; 2459 int i;
2466 2460
2467 data = container_of(dev, struct sysfs_ioapic_data, dev); 2461 data = container_of(dev, struct sysfs_ioapic_data, dev);
2468 entry = data->entry; 2462 entry = data->entry;
2469 spin_lock_irqsave(&ioapic_lock, flags); 2463 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++)
2470 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) { 2464 entry[i] = ioapic_read_entry(dev->id, i);
2471 *(((int *)entry) + 1) = io_apic_read(dev->id, 0x11 + 2 * i);
2472 *(((int *)entry) + 0) = io_apic_read(dev->id, 0x10 + 2 * i);
2473 }
2474 spin_unlock_irqrestore(&ioapic_lock, flags);
2475 2465
2476 return 0; 2466 return 0;
2477} 2467}
@@ -2493,11 +2483,9 @@ static int ioapic_resume(struct sys_device *dev)
2493 reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid; 2483 reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid;
2494 io_apic_write(dev->id, 0, reg_00.raw); 2484 io_apic_write(dev->id, 0, reg_00.raw);
2495 } 2485 }
2496 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) {
2497 io_apic_write(dev->id, 0x11+2*i, *(((int *)entry)+1));
2498 io_apic_write(dev->id, 0x10+2*i, *(((int *)entry)+0));
2499 }
2500 spin_unlock_irqrestore(&ioapic_lock, flags); 2486 spin_unlock_irqrestore(&ioapic_lock, flags);
2487 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++)
2488 ioapic_write_entry(dev->id, i, entry[i]);
2501 2489
2502 return 0; 2490 return 0;
2503} 2491}
@@ -2694,9 +2682,8 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2694 if (!ioapic && (irq < 16)) 2682 if (!ioapic && (irq < 16))
2695 disable_8259A_irq(irq); 2683 disable_8259A_irq(irq);
2696 2684
2685 ioapic_write_entry(ioapic, pin, entry);
2697 spin_lock_irqsave(&ioapic_lock, flags); 2686 spin_lock_irqsave(&ioapic_lock, flags);
2698 io_apic_write(ioapic, 0x11+2*pin, *(((int *)&entry)+1));
2699 io_apic_write(ioapic, 0x10+2*pin, *(((int *)&entry)+0));
2700 set_native_irq_info(use_pci_vector() ? entry.vector : irq, TARGET_CPUS); 2687 set_native_irq_info(use_pci_vector() ? entry.vector : irq, TARGET_CPUS);
2701 spin_unlock_irqrestore(&ioapic_lock, flags); 2688 spin_unlock_irqrestore(&ioapic_lock, flags);
2702 2689
@@ -2704,3 +2691,25 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int a
2704} 2691}
2705 2692
2706#endif /* CONFIG_ACPI */ 2693#endif /* CONFIG_ACPI */
2694
2695static int __init parse_disable_timer_pin_1(char *arg)
2696{
2697 disable_timer_pin_1 = 1;
2698 return 0;
2699}
2700early_param("disable_timer_pin_1", parse_disable_timer_pin_1);
2701
2702static int __init parse_enable_timer_pin_1(char *arg)
2703{
2704 disable_timer_pin_1 = -1;
2705 return 0;
2706}
2707early_param("enable_timer_pin_1", parse_enable_timer_pin_1);
2708
2709static int __init parse_noapic(char *arg)
2710{
2711 /* disable IO-APIC */
2712 disable_ioapic_setup();
2713 return 0;
2714}
2715early_param("noapic", parse_noapic);
diff --git a/arch/i386/kernel/machine_kexec.c b/arch/i386/kernel/machine_kexec.c
index 6b1ae6ba76f0..91966bafb3dc 100644
--- a/arch/i386/kernel/machine_kexec.c
+++ b/arch/i386/kernel/machine_kexec.c
@@ -9,6 +9,7 @@
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/kexec.h> 10#include <linux/kexec.h>
11#include <linux/delay.h> 11#include <linux/delay.h>
12#include <linux/init.h>
12#include <asm/pgtable.h> 13#include <asm/pgtable.h>
13#include <asm/pgalloc.h> 14#include <asm/pgalloc.h>
14#include <asm/tlbflush.h> 15#include <asm/tlbflush.h>
@@ -20,70 +21,13 @@
20#include <asm/system.h> 21#include <asm/system.h>
21 22
22#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE))) 23#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
23 24static u32 kexec_pgd[1024] PAGE_ALIGNED;
24#define L0_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 25#ifdef CONFIG_X86_PAE
25#define L1_ATTR (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 26static u32 kexec_pmd0[1024] PAGE_ALIGNED;
26#define L2_ATTR (_PAGE_PRESENT) 27static u32 kexec_pmd1[1024] PAGE_ALIGNED;
27
28#define LEVEL0_SIZE (1UL << 12UL)
29
30#ifndef CONFIG_X86_PAE
31#define LEVEL1_SIZE (1UL << 22UL)
32static u32 pgtable_level1[1024] PAGE_ALIGNED;
33
34static void identity_map_page(unsigned long address)
35{
36 unsigned long level1_index, level2_index;
37 u32 *pgtable_level2;
38
39 /* Find the current page table */
40 pgtable_level2 = __va(read_cr3());
41
42 /* Find the indexes of the physical address to identity map */
43 level1_index = (address % LEVEL1_SIZE)/LEVEL0_SIZE;
44 level2_index = address / LEVEL1_SIZE;
45
46 /* Identity map the page table entry */
47 pgtable_level1[level1_index] = address | L0_ATTR;
48 pgtable_level2[level2_index] = __pa(pgtable_level1) | L1_ATTR;
49
50 /* Flush the tlb so the new mapping takes effect.
51 * Global tlb entries are not flushed but that is not an issue.
52 */
53 load_cr3(pgtable_level2);
54}
55
56#else
57#define LEVEL1_SIZE (1UL << 21UL)
58#define LEVEL2_SIZE (1UL << 30UL)
59static u64 pgtable_level1[512] PAGE_ALIGNED;
60static u64 pgtable_level2[512] PAGE_ALIGNED;
61
62static void identity_map_page(unsigned long address)
63{
64 unsigned long level1_index, level2_index, level3_index;
65 u64 *pgtable_level3;
66
67 /* Find the current page table */
68 pgtable_level3 = __va(read_cr3());
69
70 /* Find the indexes of the physical address to identity map */
71 level1_index = (address % LEVEL1_SIZE)/LEVEL0_SIZE;
72 level2_index = (address % LEVEL2_SIZE)/LEVEL1_SIZE;
73 level3_index = address / LEVEL2_SIZE;
74
75 /* Identity map the page table entry */
76 pgtable_level1[level1_index] = address | L0_ATTR;
77 pgtable_level2[level2_index] = __pa(pgtable_level1) | L1_ATTR;
78 set_64bit(&pgtable_level3[level3_index],
79 __pa(pgtable_level2) | L2_ATTR);
80
81 /* Flush the tlb so the new mapping takes effect.
82 * Global tlb entries are not flushed but that is not an issue.
83 */
84 load_cr3(pgtable_level3);
85}
86#endif 28#endif
29static u32 kexec_pte0[1024] PAGE_ALIGNED;
30static u32 kexec_pte1[1024] PAGE_ALIGNED;
87 31
88static void set_idt(void *newidt, __u16 limit) 32static void set_idt(void *newidt, __u16 limit)
89{ 33{
@@ -127,16 +71,6 @@ static void load_segments(void)
127#undef __STR 71#undef __STR
128} 72}
129 73
130typedef asmlinkage NORET_TYPE void (*relocate_new_kernel_t)(
131 unsigned long indirection_page,
132 unsigned long reboot_code_buffer,
133 unsigned long start_address,
134 unsigned int has_pae) ATTRIB_NORET;
135
136extern const unsigned char relocate_new_kernel[];
137extern void relocate_new_kernel_end(void);
138extern const unsigned int relocate_new_kernel_size;
139
140/* 74/*
141 * A architecture hook called to validate the 75 * A architecture hook called to validate the
142 * proposed image and prepare the control pages 76 * proposed image and prepare the control pages
@@ -169,25 +103,29 @@ void machine_kexec_cleanup(struct kimage *image)
169 */ 103 */
170NORET_TYPE void machine_kexec(struct kimage *image) 104NORET_TYPE void machine_kexec(struct kimage *image)
171{ 105{
172 unsigned long page_list; 106 unsigned long page_list[PAGES_NR];
173 unsigned long reboot_code_buffer; 107 void *control_page;
174
175 relocate_new_kernel_t rnk;
176 108
177 /* Interrupts aren't acceptable while we reboot */ 109 /* Interrupts aren't acceptable while we reboot */
178 local_irq_disable(); 110 local_irq_disable();
179 111
180 /* Compute some offsets */ 112 control_page = page_address(image->control_code_page);
181 reboot_code_buffer = page_to_pfn(image->control_code_page) 113 memcpy(control_page, relocate_kernel, PAGE_SIZE);
182 << PAGE_SHIFT; 114
183 page_list = image->head; 115 page_list[PA_CONTROL_PAGE] = __pa(control_page);
184 116 page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
185 /* Set up an identity mapping for the reboot_code_buffer */ 117 page_list[PA_PGD] = __pa(kexec_pgd);
186 identity_map_page(reboot_code_buffer); 118 page_list[VA_PGD] = (unsigned long)kexec_pgd;
187 119#ifdef CONFIG_X86_PAE
188 /* copy it out */ 120 page_list[PA_PMD_0] = __pa(kexec_pmd0);
189 memcpy((void *)reboot_code_buffer, relocate_new_kernel, 121 page_list[VA_PMD_0] = (unsigned long)kexec_pmd0;
190 relocate_new_kernel_size); 122 page_list[PA_PMD_1] = __pa(kexec_pmd1);
123 page_list[VA_PMD_1] = (unsigned long)kexec_pmd1;
124#endif
125 page_list[PA_PTE_0] = __pa(kexec_pte0);
126 page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
127 page_list[PA_PTE_1] = __pa(kexec_pte1);
128 page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
191 129
192 /* The segment registers are funny things, they have both a 130 /* The segment registers are funny things, they have both a
193 * visible and an invisible part. Whenever the visible part is 131 * visible and an invisible part. Whenever the visible part is
@@ -206,6 +144,28 @@ NORET_TYPE void machine_kexec(struct kimage *image)
206 set_idt(phys_to_virt(0),0); 144 set_idt(phys_to_virt(0),0);
207 145
208 /* now call it */ 146 /* now call it */
209 rnk = (relocate_new_kernel_t) reboot_code_buffer; 147 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
210 (*rnk)(page_list, reboot_code_buffer, image->start, cpu_has_pae); 148 image->start, cpu_has_pae);
149}
150
151/* crashkernel=size@addr specifies the location to reserve for
152 * a crash kernel. By reserving this memory we guarantee
153 * that linux never sets it up as a DMA target.
154 * Useful for holding code to do something appropriate
155 * after a kernel panic.
156 */
157static int __init parse_crashkernel(char *arg)
158{
159 unsigned long size, base;
160 size = memparse(arg, &arg);
161 if (*arg == '@') {
162 base = memparse(arg+1, &arg);
163 /* FIXME: Do I want a sanity check
164 * to validate the memory range?
165 */
166 crashk_res.start = base;
167 crashk_res.end = base + size - 1;
168 }
169 return 0;
211} 170}
171early_param("crashkernel", parse_crashkernel);
diff --git a/arch/i386/kernel/mca.c b/arch/i386/kernel/mca.c
index cd5456f14af4..eb57a851789d 100644
--- a/arch/i386/kernel/mca.c
+++ b/arch/i386/kernel/mca.c
@@ -42,6 +42,7 @@
42#include <linux/errno.h> 42#include <linux/errno.h>
43#include <linux/kernel.h> 43#include <linux/kernel.h>
44#include <linux/mca.h> 44#include <linux/mca.h>
45#include <linux/kprobes.h>
45#include <asm/system.h> 46#include <asm/system.h>
46#include <asm/io.h> 47#include <asm/io.h>
47#include <linux/proc_fs.h> 48#include <linux/proc_fs.h>
@@ -414,7 +415,8 @@ subsys_initcall(mca_init);
414 415
415/*--------------------------------------------------------------------*/ 416/*--------------------------------------------------------------------*/
416 417
417static void mca_handle_nmi_device(struct mca_device *mca_dev, int check_flag) 418static __kprobes void
419mca_handle_nmi_device(struct mca_device *mca_dev, int check_flag)
418{ 420{
419 int slot = mca_dev->slot; 421 int slot = mca_dev->slot;
420 422
@@ -444,7 +446,7 @@ static void mca_handle_nmi_device(struct mca_device *mca_dev, int check_flag)
444 446
445/*--------------------------------------------------------------------*/ 447/*--------------------------------------------------------------------*/
446 448
447static int mca_handle_nmi_callback(struct device *dev, void *data) 449static int __kprobes mca_handle_nmi_callback(struct device *dev, void *data)
448{ 450{
449 struct mca_device *mca_dev = to_mca_device(dev); 451 struct mca_device *mca_dev = to_mca_device(dev);
450 unsigned char pos5; 452 unsigned char pos5;
@@ -462,7 +464,7 @@ static int mca_handle_nmi_callback(struct device *dev, void *data)
462 return 0; 464 return 0;
463} 465}
464 466
465void mca_handle_nmi(void) 467void __kprobes mca_handle_nmi(void)
466{ 468{
467 /* First try - scan the various adapters and see if a specific 469 /* First try - scan the various adapters and see if a specific
468 * adapter was responsible for the error. 470 * adapter was responsible for the error.
diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c
index 40b44cc0d14b..9b9479768d5e 100644
--- a/arch/i386/kernel/microcode.c
+++ b/arch/i386/kernel/microcode.c
@@ -2,6 +2,7 @@
2 * Intel CPU Microcode Update Driver for Linux 2 * Intel CPU Microcode Update Driver for Linux
3 * 3 *
4 * Copyright (C) 2000-2004 Tigran Aivazian 4 * Copyright (C) 2000-2004 Tigran Aivazian
5 * 2006 Shaohua Li <shaohua.li@intel.com>
5 * 6 *
6 * This driver allows to upgrade microcode on Intel processors 7 * This driver allows to upgrade microcode on Intel processors
7 * belonging to IA-32 family - PentiumPro, Pentium II, 8 * belonging to IA-32 family - PentiumPro, Pentium II,
@@ -82,6 +83,9 @@
82#include <linux/spinlock.h> 83#include <linux/spinlock.h>
83#include <linux/mm.h> 84#include <linux/mm.h>
84#include <linux/mutex.h> 85#include <linux/mutex.h>
86#include <linux/cpu.h>
87#include <linux/firmware.h>
88#include <linux/platform_device.h>
85 89
86#include <asm/msr.h> 90#include <asm/msr.h>
87#include <asm/uaccess.h> 91#include <asm/uaccess.h>
@@ -91,9 +95,6 @@ MODULE_DESCRIPTION("Intel CPU (IA-32) Microcode Update Driver");
91MODULE_AUTHOR("Tigran Aivazian <tigran@veritas.com>"); 95MODULE_AUTHOR("Tigran Aivazian <tigran@veritas.com>");
92MODULE_LICENSE("GPL"); 96MODULE_LICENSE("GPL");
93 97
94static int verbose;
95module_param(verbose, int, 0644);
96
97#define MICROCODE_VERSION "1.14a" 98#define MICROCODE_VERSION "1.14a"
98 99
99#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */ 100#define DEFAULT_UCODE_DATASIZE (2000) /* 2000 bytes */
@@ -120,55 +121,40 @@ static DEFINE_SPINLOCK(microcode_update_lock);
120/* no concurrent ->write()s are allowed on /dev/cpu/microcode */ 121/* no concurrent ->write()s are allowed on /dev/cpu/microcode */
121static DEFINE_MUTEX(microcode_mutex); 122static DEFINE_MUTEX(microcode_mutex);
122 123
123static void __user *user_buffer; /* user area microcode data buffer */
124static unsigned int user_buffer_size; /* it's size */
125
126typedef enum mc_error_code {
127 MC_SUCCESS = 0,
128 MC_IGNORED = 1,
129 MC_NOTFOUND = 2,
130 MC_MARKED = 3,
131 MC_ALLOCATED = 4,
132} mc_error_code_t;
133
134static struct ucode_cpu_info { 124static struct ucode_cpu_info {
125 int valid;
135 unsigned int sig; 126 unsigned int sig;
136 unsigned int pf, orig_pf; 127 unsigned int pf;
137 unsigned int rev; 128 unsigned int rev;
138 unsigned int cksum;
139 mc_error_code_t err;
140 microcode_t *mc; 129 microcode_t *mc;
141} ucode_cpu_info[NR_CPUS]; 130} ucode_cpu_info[NR_CPUS];
142
143static int microcode_open (struct inode *unused1, struct file *unused2)
144{
145 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
146}
147 131
148static void collect_cpu_info (void *unused) 132static void collect_cpu_info(int cpu_num)
149{ 133{
150 int cpu_num = smp_processor_id();
151 struct cpuinfo_x86 *c = cpu_data + cpu_num; 134 struct cpuinfo_x86 *c = cpu_data + cpu_num;
152 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 135 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
153 unsigned int val[2]; 136 unsigned int val[2];
154 137
155 uci->sig = uci->pf = uci->rev = uci->cksum = 0; 138 /* We should bind the task to the CPU */
156 uci->err = MC_NOTFOUND; 139 BUG_ON(raw_smp_processor_id() != cpu_num);
140 uci->pf = uci->rev = 0;
157 uci->mc = NULL; 141 uci->mc = NULL;
142 uci->valid = 1;
158 143
159 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 || 144 if (c->x86_vendor != X86_VENDOR_INTEL || c->x86 < 6 ||
160 cpu_has(c, X86_FEATURE_IA64)) { 145 cpu_has(c, X86_FEATURE_IA64)) {
161 printk(KERN_ERR "microcode: CPU%d not a capable Intel processor\n", cpu_num); 146 printk(KERN_ERR "microcode: CPU%d not a capable Intel "
147 "processor\n", cpu_num);
148 uci->valid = 0;
162 return; 149 return;
163 } else { 150 }
164 uci->sig = cpuid_eax(0x00000001);
165 151
166 if ((c->x86_model >= 5) || (c->x86 > 6)) { 152 uci->sig = cpuid_eax(0x00000001);
167 /* get processor flags from MSR 0x17 */ 153
168 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); 154 if ((c->x86_model >= 5) || (c->x86 > 6)) {
169 uci->pf = 1 << ((val[1] >> 18) & 7); 155 /* get processor flags from MSR 0x17 */
170 } 156 rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
171 uci->orig_pf = uci->pf; 157 uci->pf = 1 << ((val[1] >> 18) & 7);
172 } 158 }
173 159
174 wrmsr(MSR_IA32_UCODE_REV, 0, 0); 160 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
@@ -180,218 +166,159 @@ static void collect_cpu_info (void *unused)
180 uci->sig, uci->pf, uci->rev); 166 uci->sig, uci->pf, uci->rev);
181} 167}
182 168
183static inline void mark_microcode_update (int cpu_num, microcode_header_t *mc_header, int sig, int pf, int cksum) 169static inline int microcode_update_match(int cpu_num,
170 microcode_header_t *mc_header, int sig, int pf)
184{ 171{
185 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 172 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
186 173
187 pr_debug("Microcode Found.\n"); 174 if (!sigmatch(sig, uci->sig, pf, uci->pf)
188 pr_debug(" Header Revision 0x%x\n", mc_header->hdrver); 175 || mc_header->rev <= uci->rev)
189 pr_debug(" Loader Revision 0x%x\n", mc_header->ldrver); 176 return 0;
190 pr_debug(" Revision 0x%x \n", mc_header->rev); 177 return 1;
191 pr_debug(" Date %x/%x/%x\n",
192 ((mc_header->date >> 24 ) & 0xff),
193 ((mc_header->date >> 16 ) & 0xff),
194 (mc_header->date & 0xFFFF));
195 pr_debug(" Signature 0x%x\n", sig);
196 pr_debug(" Type 0x%x Family 0x%x Model 0x%x Stepping 0x%x\n",
197 ((sig >> 12) & 0x3),
198 ((sig >> 8) & 0xf),
199 ((sig >> 4) & 0xf),
200 ((sig & 0xf)));
201 pr_debug(" Processor Flags 0x%x\n", pf);
202 pr_debug(" Checksum 0x%x\n", cksum);
203
204 if (mc_header->rev < uci->rev) {
205 if (uci->err == MC_NOTFOUND) {
206 uci->err = MC_IGNORED;
207 uci->cksum = mc_header->rev;
208 } else if (uci->err == MC_IGNORED && uci->cksum < mc_header->rev)
209 uci->cksum = mc_header->rev;
210 } else if (mc_header->rev == uci->rev) {
211 if (uci->err < MC_MARKED) {
212 /* notify the caller of success on this cpu */
213 uci->err = MC_SUCCESS;
214 }
215 } else if (uci->err != MC_ALLOCATED || mc_header->rev > uci->mc->hdr.rev) {
216 pr_debug("microcode: CPU%d found a matching microcode update with "
217 " revision 0x%x (current=0x%x)\n", cpu_num, mc_header->rev, uci->rev);
218 uci->cksum = cksum;
219 uci->pf = pf; /* keep the original mc pf for cksum calculation */
220 uci->err = MC_MARKED; /* found the match */
221 for_each_online_cpu(cpu_num) {
222 if (ucode_cpu_info + cpu_num != uci
223 && ucode_cpu_info[cpu_num].mc == uci->mc) {
224 uci->mc = NULL;
225 break;
226 }
227 }
228 if (uci->mc != NULL) {
229 vfree(uci->mc);
230 uci->mc = NULL;
231 }
232 }
233 return;
234} 178}
235 179
236static int find_matching_ucodes (void) 180static int microcode_sanity_check(void *mc)
237{ 181{
238 int cursor = 0; 182 microcode_header_t *mc_header = mc;
239 int error = 0; 183 struct extended_sigtable *ext_header = NULL;
240 184 struct extended_signature *ext_sig;
241 while (cursor + MC_HEADER_SIZE < user_buffer_size) { 185 unsigned long total_size, data_size, ext_table_size;
242 microcode_header_t mc_header; 186 int sum, orig_sum, ext_sigcount = 0, i;
243 void *newmc = NULL; 187
244 int i, sum, cpu_num, allocated_flag, total_size, data_size, ext_table_size; 188 total_size = get_totalsize(mc_header);
189 data_size = get_datasize(mc_header);
190 if (data_size + MC_HEADER_SIZE > total_size) {
191 printk(KERN_ERR "microcode: error! "
192 "Bad data size in microcode data file\n");
193 return -EINVAL;
194 }
245 195
246 if (copy_from_user(&mc_header, user_buffer + cursor, MC_HEADER_SIZE)) { 196 if (mc_header->ldrver != 1 || mc_header->hdrver != 1) {
247 printk(KERN_ERR "microcode: error! Can not read user data\n"); 197 printk(KERN_ERR "microcode: error! "
248 error = -EFAULT; 198 "Unknown microcode update format\n");
249 goto out; 199 return -EINVAL;
200 }
201 ext_table_size = total_size - (MC_HEADER_SIZE + data_size);
202 if (ext_table_size) {
203 if ((ext_table_size < EXT_HEADER_SIZE)
204 || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) {
205 printk(KERN_ERR "microcode: error! "
206 "Small exttable size in microcode data file\n");
207 return -EINVAL;
250 } 208 }
251 209 ext_header = mc + MC_HEADER_SIZE + data_size;
252 total_size = get_totalsize(&mc_header); 210 if (ext_table_size != exttable_size(ext_header)) {
253 if ((cursor + total_size > user_buffer_size) || (total_size < DEFAULT_UCODE_TOTALSIZE)) { 211 printk(KERN_ERR "microcode: error! "
254 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); 212 "Bad exttable size in microcode data file\n");
255 error = -EINVAL; 213 return -EFAULT;
256 goto out;
257 } 214 }
215 ext_sigcount = ext_header->count;
216 }
258 217
259 data_size = get_datasize(&mc_header); 218 /* check extended table checksum */
260 if ((data_size + MC_HEADER_SIZE > total_size) || (data_size < DEFAULT_UCODE_DATASIZE)) { 219 if (ext_table_size) {
261 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); 220 int ext_table_sum = 0;
262 error = -EINVAL; 221 int *ext_tablep = (int *)ext_header;
263 goto out; 222
223 i = ext_table_size / DWSIZE;
224 while (i--)
225 ext_table_sum += ext_tablep[i];
226 if (ext_table_sum) {
227 printk(KERN_WARNING "microcode: aborting, "
228 "bad extended signature table checksum\n");
229 return -EINVAL;
264 } 230 }
231 }
265 232
266 if (mc_header.ldrver != 1 || mc_header.hdrver != 1) { 233 /* calculate the checksum */
267 printk(KERN_ERR "microcode: error! Unknown microcode update format\n"); 234 orig_sum = 0;
268 error = -EINVAL; 235 i = (MC_HEADER_SIZE + data_size) / DWSIZE;
269 goto out; 236 while (i--)
237 orig_sum += ((int *)mc)[i];
238 if (orig_sum) {
239 printk(KERN_ERR "microcode: aborting, bad checksum\n");
240 return -EINVAL;
241 }
242 if (!ext_table_size)
243 return 0;
244 /* check extended signature checksum */
245 for (i = 0; i < ext_sigcount; i++) {
246 ext_sig = (struct extended_signature *)((void *)ext_header
247 + EXT_HEADER_SIZE + EXT_SIGNATURE_SIZE * i);
248 sum = orig_sum
249 - (mc_header->sig + mc_header->pf + mc_header->cksum)
250 + (ext_sig->sig + ext_sig->pf + ext_sig->cksum);
251 if (sum) {
252 printk(KERN_ERR "microcode: aborting, bad checksum\n");
253 return -EINVAL;
270 } 254 }
255 }
256 return 0;
257}
271 258
272 for_each_online_cpu(cpu_num) { 259/*
273 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 260 * return 0 - no update found
274 261 * return 1 - found update
275 if (sigmatch(mc_header.sig, uci->sig, mc_header.pf, uci->orig_pf)) 262 * return < 0 - error
276 mark_microcode_update(cpu_num, &mc_header, mc_header.sig, mc_header.pf, mc_header.cksum); 263 */
277 } 264static int get_maching_microcode(void *mc, int cpu)
265{
266 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
267 microcode_header_t *mc_header = mc;
268 struct extended_sigtable *ext_header;
269 unsigned long total_size = get_totalsize(mc_header);
270 int ext_sigcount, i;
271 struct extended_signature *ext_sig;
272 void *new_mc;
273
274 if (microcode_update_match(cpu, mc_header,
275 mc_header->sig, mc_header->pf))
276 goto find;
277
278 if (total_size <= get_datasize(mc_header) + MC_HEADER_SIZE)
279 return 0;
280
281 ext_header = (struct extended_sigtable *)(mc +
282 get_datasize(mc_header) + MC_HEADER_SIZE);
283 ext_sigcount = ext_header->count;
284 ext_sig = (struct extended_signature *)((void *)ext_header
285 + EXT_HEADER_SIZE);
286 for (i = 0; i < ext_sigcount; i++) {
287 if (microcode_update_match(cpu, mc_header,
288 ext_sig->sig, ext_sig->pf))
289 goto find;
290 ext_sig++;
291 }
292 return 0;
293find:
294 pr_debug("microcode: CPU %d found a matching microcode update with"
295 " version 0x%x (current=0x%x)\n", cpu, mc_header->rev,uci->rev);
296 new_mc = vmalloc(total_size);
297 if (!new_mc) {
298 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
299 return -ENOMEM;
300 }
278 301
279 ext_table_size = total_size - (MC_HEADER_SIZE + data_size); 302 /* free previous update file */
280 if (ext_table_size) { 303 vfree(uci->mc);
281 struct extended_sigtable ext_header;
282 struct extended_signature ext_sig;
283 int ext_sigcount;
284 304
285 if ((ext_table_size < EXT_HEADER_SIZE) 305 memcpy(new_mc, mc, total_size);
286 || ((ext_table_size - EXT_HEADER_SIZE) % EXT_SIGNATURE_SIZE)) { 306 uci->mc = new_mc;
287 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n"); 307 return 1;
288 error = -EINVAL;
289 goto out;
290 }
291 if (copy_from_user(&ext_header, user_buffer + cursor
292 + MC_HEADER_SIZE + data_size, EXT_HEADER_SIZE)) {
293 printk(KERN_ERR "microcode: error! Can not read user data\n");
294 error = -EFAULT;
295 goto out;
296 }
297 if (ext_table_size != exttable_size(&ext_header)) {
298 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
299 error = -EFAULT;
300 goto out;
301 }
302
303 ext_sigcount = ext_header.count;
304
305 for (i = 0; i < ext_sigcount; i++) {
306 if (copy_from_user(&ext_sig, user_buffer + cursor + MC_HEADER_SIZE + data_size + EXT_HEADER_SIZE
307 + EXT_SIGNATURE_SIZE * i, EXT_SIGNATURE_SIZE)) {
308 printk(KERN_ERR "microcode: error! Can not read user data\n");
309 error = -EFAULT;
310 goto out;
311 }
312 for_each_online_cpu(cpu_num) {
313 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
314
315 if (sigmatch(ext_sig.sig, uci->sig, ext_sig.pf, uci->orig_pf)) {
316 mark_microcode_update(cpu_num, &mc_header, ext_sig.sig, ext_sig.pf, ext_sig.cksum);
317 }
318 }
319 }
320 }
321 /* now check if any cpu has matched */
322 allocated_flag = 0;
323 sum = 0;
324 for_each_online_cpu(cpu_num) {
325 if (ucode_cpu_info[cpu_num].err == MC_MARKED) {
326 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
327 if (!allocated_flag) {
328 allocated_flag = 1;
329 newmc = vmalloc(total_size);
330 if (!newmc) {
331 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
332 error = -ENOMEM;
333 goto out;
334 }
335 if (copy_from_user(newmc + MC_HEADER_SIZE,
336 user_buffer + cursor + MC_HEADER_SIZE,
337 total_size - MC_HEADER_SIZE)) {
338 printk(KERN_ERR "microcode: error! Can not read user data\n");
339 vfree(newmc);
340 error = -EFAULT;
341 goto out;
342 }
343 memcpy(newmc, &mc_header, MC_HEADER_SIZE);
344 /* check extended table checksum */
345 if (ext_table_size) {
346 int ext_table_sum = 0;
347 int * ext_tablep = (((void *) newmc) + MC_HEADER_SIZE + data_size);
348 i = ext_table_size / DWSIZE;
349 while (i--) ext_table_sum += ext_tablep[i];
350 if (ext_table_sum) {
351 printk(KERN_WARNING "microcode: aborting, bad extended signature table checksum\n");
352 vfree(newmc);
353 error = -EINVAL;
354 goto out;
355 }
356 }
357
358 /* calculate the checksum */
359 i = (MC_HEADER_SIZE + data_size) / DWSIZE;
360 while (i--) sum += ((int *)newmc)[i];
361 sum -= (mc_header.sig + mc_header.pf + mc_header.cksum);
362 }
363 ucode_cpu_info[cpu_num].mc = newmc;
364 ucode_cpu_info[cpu_num].err = MC_ALLOCATED; /* mc updated */
365 if (sum + uci->sig + uci->pf + uci->cksum != 0) {
366 printk(KERN_ERR "microcode: CPU%d aborting, bad checksum\n", cpu_num);
367 error = -EINVAL;
368 goto out;
369 }
370 }
371 }
372 cursor += total_size; /* goto the next update patch */
373 } /* end of while */
374out:
375 return error;
376} 308}
377 309
378static void do_update_one (void * unused) 310static void apply_microcode(int cpu)
379{ 311{
380 unsigned long flags; 312 unsigned long flags;
381 unsigned int val[2]; 313 unsigned int val[2];
382 int cpu_num = smp_processor_id(); 314 int cpu_num = raw_smp_processor_id();
383 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 315 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
384 316
385 if (uci->mc == NULL) { 317 /* We should bind the task to the CPU */
386 if (verbose) { 318 BUG_ON(cpu_num != cpu);
387 if (uci->err == MC_SUCCESS) 319
388 printk(KERN_INFO "microcode: CPU%d already at revision 0x%x\n", 320 if (uci->mc == NULL)
389 cpu_num, uci->rev);
390 else
391 printk(KERN_INFO "microcode: No new microcode data for CPU%d\n", cpu_num);
392 }
393 return; 321 return;
394 }
395 322
396 /* serialize access to the physical write to MSR 0x79 */ 323 /* serialize access to the physical write to MSR 0x79 */
397 spin_lock_irqsave(&microcode_update_lock, flags); 324 spin_lock_irqsave(&microcode_update_lock, flags);
@@ -408,68 +335,107 @@ static void do_update_one (void * unused)
408 /* get the current revision from MSR 0x8B */ 335 /* get the current revision from MSR 0x8B */
409 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); 336 rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
410 337
411 /* notify the caller of success on this cpu */
412 uci->err = MC_SUCCESS;
413 spin_unlock_irqrestore(&microcode_update_lock, flags); 338 spin_unlock_irqrestore(&microcode_update_lock, flags);
414 printk(KERN_INFO "microcode: CPU%d updated from revision " 339 if (val[1] != uci->mc->hdr.rev) {
340 printk(KERN_ERR "microcode: CPU%d updated from revision "
341 "0x%x to 0x%x failed\n", cpu_num, uci->rev, val[1]);
342 return;
343 }
344 pr_debug("microcode: CPU%d updated from revision "
415 "0x%x to 0x%x, date = %08x \n", 345 "0x%x to 0x%x, date = %08x \n",
416 cpu_num, uci->rev, val[1], uci->mc->hdr.date); 346 cpu_num, uci->rev, val[1], uci->mc->hdr.date);
417 return; 347 uci->rev = val[1];
418} 348}
419 349
420static int do_microcode_update (void) 350#ifdef CONFIG_MICROCODE_OLD_INTERFACE
421{ 351static void __user *user_buffer; /* user area microcode data buffer */
422 int i, error; 352static unsigned int user_buffer_size; /* it's size */
423 353
424 if (on_each_cpu(collect_cpu_info, NULL, 1, 1) != 0) { 354static long get_next_ucode(void **mc, long offset)
425 printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); 355{
426 error = -EIO; 356 microcode_header_t mc_header;
427 goto out; 357 unsigned long total_size;
358
359 /* No more data */
360 if (offset >= user_buffer_size)
361 return 0;
362 if (copy_from_user(&mc_header, user_buffer + offset, MC_HEADER_SIZE)) {
363 printk(KERN_ERR "microcode: error! Can not read user data\n");
364 return -EFAULT;
428 } 365 }
429 366 total_size = get_totalsize(&mc_header);
430 if ((error = find_matching_ucodes())) { 367 if (offset + total_size > user_buffer_size) {
431 printk(KERN_ERR "microcode: Error in the microcode data\n"); 368 printk(KERN_ERR "microcode: error! Bad total size in microcode "
432 goto out_free; 369 "data file\n");
370 return -EINVAL;
433 } 371 }
434 372 *mc = vmalloc(total_size);
435 if (on_each_cpu(do_update_one, NULL, 1, 1) != 0) { 373 if (!*mc)
436 printk(KERN_ERR "microcode: Error! Could not run on all processors\n"); 374 return -ENOMEM;
437 error = -EIO; 375 if (copy_from_user(*mc, user_buffer + offset, total_size)) {
376 printk(KERN_ERR "microcode: error! Can not read user data\n");
377 vfree(*mc);
378 return -EFAULT;
438 } 379 }
380 return offset + total_size;
381}
382
383static int do_microcode_update (void)
384{
385 long cursor = 0;
386 int error = 0;
387 void *new_mc;
388 int cpu;
389 cpumask_t old;
390
391 old = current->cpus_allowed;
439 392
440out_free: 393 while ((cursor = get_next_ucode(&new_mc, cursor)) > 0) {
441 for_each_online_cpu(i) { 394 error = microcode_sanity_check(new_mc);
442 if (ucode_cpu_info[i].mc) { 395 if (error)
443 int j; 396 goto out;
444 void *tmp = ucode_cpu_info[i].mc; 397 /*
445 vfree(tmp); 398 * It's possible the data file has multiple matching ucode,
446 for_each_online_cpu(j) { 399 * lets keep searching till the latest version
447 if (ucode_cpu_info[j].mc == tmp) 400 */
448 ucode_cpu_info[j].mc = NULL; 401 for_each_online_cpu(cpu) {
449 } 402 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
403
404 if (!uci->valid)
405 continue;
406 set_cpus_allowed(current, cpumask_of_cpu(cpu));
407 error = get_maching_microcode(new_mc, cpu);
408 if (error < 0)
409 goto out;
410 if (error == 1)
411 apply_microcode(cpu);
450 } 412 }
451 if (ucode_cpu_info[i].err == MC_IGNORED && verbose) 413 vfree(new_mc);
452 printk(KERN_WARNING "microcode: CPU%d not 'upgrading' to earlier revision"
453 " 0x%x (current=0x%x)\n", i, ucode_cpu_info[i].cksum, ucode_cpu_info[i].rev);
454 } 414 }
455out: 415out:
416 if (cursor > 0)
417 vfree(new_mc);
418 if (cursor < 0)
419 error = cursor;
420 set_cpus_allowed(current, old);
456 return error; 421 return error;
457} 422}
458 423
424static int microcode_open (struct inode *unused1, struct file *unused2)
425{
426 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
427}
428
459static ssize_t microcode_write (struct file *file, const char __user *buf, size_t len, loff_t *ppos) 429static ssize_t microcode_write (struct file *file, const char __user *buf, size_t len, loff_t *ppos)
460{ 430{
461 ssize_t ret; 431 ssize_t ret;
462 432
463 if (len < DEFAULT_UCODE_TOTALSIZE) {
464 printk(KERN_ERR "microcode: not enough data\n");
465 return -EINVAL;
466 }
467
468 if ((len >> PAGE_SHIFT) > num_physpages) { 433 if ((len >> PAGE_SHIFT) > num_physpages) {
469 printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages); 434 printk(KERN_ERR "microcode: too much data (max %ld pages)\n", num_physpages);
470 return -EINVAL; 435 return -EINVAL;
471 } 436 }
472 437
438 lock_cpu_hotplug();
473 mutex_lock(&microcode_mutex); 439 mutex_lock(&microcode_mutex);
474 440
475 user_buffer = (void __user *) buf; 441 user_buffer = (void __user *) buf;
@@ -480,6 +446,7 @@ static ssize_t microcode_write (struct file *file, const char __user *buf, size_
480 ret = (ssize_t)len; 446 ret = (ssize_t)len;
481 447
482 mutex_unlock(&microcode_mutex); 448 mutex_unlock(&microcode_mutex);
449 unlock_cpu_hotplug();
483 450
484 return ret; 451 return ret;
485} 452}
@@ -496,7 +463,7 @@ static struct miscdevice microcode_dev = {
496 .fops = &microcode_fops, 463 .fops = &microcode_fops,
497}; 464};
498 465
499static int __init microcode_init (void) 466static int __init microcode_dev_init (void)
500{ 467{
501 int error; 468 int error;
502 469
@@ -508,6 +475,280 @@ static int __init microcode_init (void)
508 return error; 475 return error;
509 } 476 }
510 477
478 return 0;
479}
480
481static void __exit microcode_dev_exit (void)
482{
483 misc_deregister(&microcode_dev);
484}
485
486MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
487#else
488#define microcode_dev_init() 0
489#define microcode_dev_exit() do { } while(0)
490#endif
491
492static long get_next_ucode_from_buffer(void **mc, void *buf,
493 unsigned long size, long offset)
494{
495 microcode_header_t *mc_header;
496 unsigned long total_size;
497
498 /* No more data */
499 if (offset >= size)
500 return 0;
501 mc_header = (microcode_header_t *)(buf + offset);
502 total_size = get_totalsize(mc_header);
503
504 if (offset + total_size > size) {
505 printk(KERN_ERR "microcode: error! Bad data in microcode data file\n");
506 return -EINVAL;
507 }
508
509 *mc = vmalloc(total_size);
510 if (!*mc) {
511 printk(KERN_ERR "microcode: error! Can not allocate memory\n");
512 return -ENOMEM;
513 }
514 memcpy(*mc, buf + offset, total_size);
515 return offset + total_size;
516}
517
518/* fake device for request_firmware */
519static struct platform_device *microcode_pdev;
520
521static int cpu_request_microcode(int cpu)
522{
523 char name[30];
524 struct cpuinfo_x86 *c = cpu_data + cpu;
525 const struct firmware *firmware;
526 void *buf;
527 unsigned long size;
528 long offset = 0;
529 int error;
530 void *mc;
531
532 /* We should bind the task to the CPU */
533 BUG_ON(cpu != raw_smp_processor_id());
534 sprintf(name,"intel-ucode/%02x-%02x-%02x",
535 c->x86, c->x86_model, c->x86_mask);
536 error = request_firmware(&firmware, name, &microcode_pdev->dev);
537 if (error) {
538 pr_debug("ucode data file %s load failed\n", name);
539 return error;
540 }
541 buf = (void *)firmware->data;
542 size = firmware->size;
543 while ((offset = get_next_ucode_from_buffer(&mc, buf, size, offset))
544 > 0) {
545 error = microcode_sanity_check(mc);
546 if (error)
547 break;
548 error = get_maching_microcode(mc, cpu);
549 if (error < 0)
550 break;
551 /*
552 * It's possible the data file has multiple matching ucode,
553 * lets keep searching till the latest version
554 */
555 if (error == 1) {
556 apply_microcode(cpu);
557 error = 0;
558 }
559 vfree(mc);
560 }
561 if (offset > 0)
562 vfree(mc);
563 if (offset < 0)
564 error = offset;
565 release_firmware(firmware);
566
567 return error;
568}
569
570static void microcode_init_cpu(int cpu)
571{
572 cpumask_t old;
573 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
574
575 old = current->cpus_allowed;
576
577 set_cpus_allowed(current, cpumask_of_cpu(cpu));
578 mutex_lock(&microcode_mutex);
579 collect_cpu_info(cpu);
580 if (uci->valid)
581 cpu_request_microcode(cpu);
582 mutex_unlock(&microcode_mutex);
583 set_cpus_allowed(current, old);
584}
585
586static void microcode_fini_cpu(int cpu)
587{
588 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
589
590 mutex_lock(&microcode_mutex);
591 uci->valid = 0;
592 vfree(uci->mc);
593 uci->mc = NULL;
594 mutex_unlock(&microcode_mutex);
595}
596
597static ssize_t reload_store(struct sys_device *dev, const char *buf, size_t sz)
598{
599 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
600 char *end;
601 unsigned long val = simple_strtoul(buf, &end, 0);
602 int err = 0;
603 int cpu = dev->id;
604
605 if (end == buf)
606 return -EINVAL;
607 if (val == 1) {
608 cpumask_t old;
609
610 old = current->cpus_allowed;
611
612 lock_cpu_hotplug();
613 set_cpus_allowed(current, cpumask_of_cpu(cpu));
614
615 mutex_lock(&microcode_mutex);
616 if (uci->valid)
617 err = cpu_request_microcode(cpu);
618 mutex_unlock(&microcode_mutex);
619 unlock_cpu_hotplug();
620 set_cpus_allowed(current, old);
621 }
622 if (err)
623 return err;
624 return sz;
625}
626
627static ssize_t version_show(struct sys_device *dev, char *buf)
628{
629 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
630
631 return sprintf(buf, "0x%x\n", uci->rev);
632}
633
634static ssize_t pf_show(struct sys_device *dev, char *buf)
635{
636 struct ucode_cpu_info *uci = ucode_cpu_info + dev->id;
637
638 return sprintf(buf, "0x%x\n", uci->pf);
639}
640
641static SYSDEV_ATTR(reload, 0200, NULL, reload_store);
642static SYSDEV_ATTR(version, 0400, version_show, NULL);
643static SYSDEV_ATTR(processor_flags, 0400, pf_show, NULL);
644
645static struct attribute *mc_default_attrs[] = {
646 &attr_reload.attr,
647 &attr_version.attr,
648 &attr_processor_flags.attr,
649 NULL
650};
651
652static struct attribute_group mc_attr_group = {
653 .attrs = mc_default_attrs,
654 .name = "microcode",
655};
656
657static int mc_sysdev_add(struct sys_device *sys_dev)
658{
659 int cpu = sys_dev->id;
660 struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
661
662 if (!cpu_online(cpu))
663 return 0;
664 pr_debug("Microcode:CPU %d added\n", cpu);
665 memset(uci, 0, sizeof(*uci));
666 sysfs_create_group(&sys_dev->kobj, &mc_attr_group);
667
668 microcode_init_cpu(cpu);
669 return 0;
670}
671
672static int mc_sysdev_remove(struct sys_device *sys_dev)
673{
674 int cpu = sys_dev->id;
675
676 if (!cpu_online(cpu))
677 return 0;
678 pr_debug("Microcode:CPU %d removed\n", cpu);
679 microcode_fini_cpu(cpu);
680 sysfs_remove_group(&sys_dev->kobj, &mc_attr_group);
681 return 0;
682}
683
684static int mc_sysdev_resume(struct sys_device *dev)
685{
686 int cpu = dev->id;
687
688 if (!cpu_online(cpu))
689 return 0;
690 pr_debug("Microcode:CPU %d resumed\n", cpu);
691 /* only CPU 0 will apply ucode here */
692 apply_microcode(0);
693 return 0;
694}
695
696static struct sysdev_driver mc_sysdev_driver = {
697 .add = mc_sysdev_add,
698 .remove = mc_sysdev_remove,
699 .resume = mc_sysdev_resume,
700};
701
702#ifdef CONFIG_HOTPLUG_CPU
703static __cpuinit int
704mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
705{
706 unsigned int cpu = (unsigned long)hcpu;
707 struct sys_device *sys_dev;
708
709 sys_dev = get_cpu_sysdev(cpu);
710 switch (action) {
711 case CPU_ONLINE:
712 case CPU_DOWN_FAILED:
713 mc_sysdev_add(sys_dev);
714 break;
715 case CPU_DOWN_PREPARE:
716 mc_sysdev_remove(sys_dev);
717 break;
718 }
719 return NOTIFY_OK;
720}
721
722static struct notifier_block mc_cpu_notifier = {
723 .notifier_call = mc_cpu_callback,
724};
725#endif
726
727static int __init microcode_init (void)
728{
729 int error;
730
731 error = microcode_dev_init();
732 if (error)
733 return error;
734 microcode_pdev = platform_device_register_simple("microcode", -1,
735 NULL, 0);
736 if (IS_ERR(microcode_pdev)) {
737 microcode_dev_exit();
738 return PTR_ERR(microcode_pdev);
739 }
740
741 lock_cpu_hotplug();
742 error = sysdev_driver_register(&cpu_sysdev_class, &mc_sysdev_driver);
743 unlock_cpu_hotplug();
744 if (error) {
745 microcode_dev_exit();
746 platform_device_unregister(microcode_pdev);
747 return error;
748 }
749
750 register_hotcpu_notifier(&mc_cpu_notifier);
751
511 printk(KERN_INFO 752 printk(KERN_INFO
512 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@veritas.com>\n"); 753 "IA-32 Microcode Update Driver: v" MICROCODE_VERSION " <tigran@veritas.com>\n");
513 return 0; 754 return 0;
@@ -515,9 +756,16 @@ static int __init microcode_init (void)
515 756
516static void __exit microcode_exit (void) 757static void __exit microcode_exit (void)
517{ 758{
518 misc_deregister(&microcode_dev); 759 microcode_dev_exit();
760
761 unregister_hotcpu_notifier(&mc_cpu_notifier);
762
763 lock_cpu_hotplug();
764 sysdev_driver_unregister(&cpu_sysdev_class, &mc_sysdev_driver);
765 unlock_cpu_hotplug();
766
767 platform_device_unregister(microcode_pdev);
519} 768}
520 769
521module_init(microcode_init) 770module_init(microcode_init)
522module_exit(microcode_exit) 771module_exit(microcode_exit)
523MODULE_ALIAS_MISCDEV(MICROCODE_MINOR);
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index a70b5fa0ef06..442aaf8c77eb 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -30,6 +30,7 @@
30#include <asm/io_apic.h> 30#include <asm/io_apic.h>
31 31
32#include <mach_apic.h> 32#include <mach_apic.h>
33#include <mach_apicdef.h>
33#include <mach_mpparse.h> 34#include <mach_mpparse.h>
34#include <bios_ebda.h> 35#include <bios_ebda.h>
35 36
@@ -68,7 +69,7 @@ unsigned int def_to_bigsmp = 0;
68/* Processor that is doing the boot up */ 69/* Processor that is doing the boot up */
69unsigned int boot_cpu_physical_apicid = -1U; 70unsigned int boot_cpu_physical_apicid = -1U;
70/* Internal processor count */ 71/* Internal processor count */
71static unsigned int __devinitdata num_processors; 72unsigned int __cpuinitdata num_processors;
72 73
73/* Bitmask of physically existing CPUs */ 74/* Bitmask of physically existing CPUs */
74physid_mask_t phys_cpu_present_map; 75physid_mask_t phys_cpu_present_map;
@@ -228,12 +229,14 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
228 229
229 mpc_oem_bus_info(m, str, translation_table[mpc_record]); 230 mpc_oem_bus_info(m, str, translation_table[mpc_record]);
230 231
232#if MAX_MP_BUSSES < 256
231 if (m->mpc_busid >= MAX_MP_BUSSES) { 233 if (m->mpc_busid >= MAX_MP_BUSSES) {
232 printk(KERN_WARNING "MP table busid value (%d) for bustype %s " 234 printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
233 " is too large, max. supported is %d\n", 235 " is too large, max. supported is %d\n",
234 m->mpc_busid, str, MAX_MP_BUSSES - 1); 236 m->mpc_busid, str, MAX_MP_BUSSES - 1);
235 return; 237 return;
236 } 238 }
239#endif
237 240
238 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) { 241 if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
239 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA; 242 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
@@ -293,19 +296,6 @@ static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
293 m->mpc_irqtype, m->mpc_irqflag & 3, 296 m->mpc_irqtype, m->mpc_irqflag & 3,
294 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid, 297 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
295 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint); 298 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
296 /*
297 * Well it seems all SMP boards in existence
298 * use ExtINT/LVT1 == LINT0 and
299 * NMI/LVT2 == LINT1 - the following check
300 * will show us if this assumptions is false.
301 * Until then we do not have to add baggage.
302 */
303 if ((m->mpc_irqtype == mp_ExtINT) &&
304 (m->mpc_destapiclint != 0))
305 BUG();
306 if ((m->mpc_irqtype == mp_NMI) &&
307 (m->mpc_destapiclint != 1))
308 BUG();
309} 299}
310 300
311#ifdef CONFIG_X86_NUMAQ 301#ifdef CONFIG_X86_NUMAQ
@@ -822,8 +812,7 @@ int es7000_plat;
822 812
823#ifdef CONFIG_ACPI 813#ifdef CONFIG_ACPI
824 814
825void __init mp_register_lapic_address ( 815void __init mp_register_lapic_address(u64 address)
826 u64 address)
827{ 816{
828 mp_lapic_addr = (unsigned long) address; 817 mp_lapic_addr = (unsigned long) address;
829 818
@@ -835,13 +824,10 @@ void __init mp_register_lapic_address (
835 Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid); 824 Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
836} 825}
837 826
838 827void __devinit mp_register_lapic (u8 id, u8 enabled)
839void __devinit mp_register_lapic (
840 u8 id,
841 u8 enabled)
842{ 828{
843 struct mpc_config_processor processor; 829 struct mpc_config_processor processor;
844 int boot_cpu = 0; 830 int boot_cpu = 0;
845 831
846 if (MAX_APICS - id <= 0) { 832 if (MAX_APICS - id <= 0) {
847 printk(KERN_WARNING "Processor #%d invalid (max %d)\n", 833 printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
@@ -878,11 +864,9 @@ static struct mp_ioapic_routing {
878 u32 pin_programmed[4]; 864 u32 pin_programmed[4];
879} mp_ioapic_routing[MAX_IO_APICS]; 865} mp_ioapic_routing[MAX_IO_APICS];
880 866
881 867static int mp_find_ioapic (int gsi)
882static int mp_find_ioapic (
883 int gsi)
884{ 868{
885 int i = 0; 869 int i = 0;
886 870
887 /* Find the IOAPIC that manages this GSI. */ 871 /* Find the IOAPIC that manages this GSI. */
888 for (i = 0; i < nr_ioapics; i++) { 872 for (i = 0; i < nr_ioapics; i++) {
@@ -895,15 +879,11 @@ static int mp_find_ioapic (
895 879
896 return -1; 880 return -1;
897} 881}
898
899 882
900void __init mp_register_ioapic ( 883void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
901 u8 id,
902 u32 address,
903 u32 gsi_base)
904{ 884{
905 int idx = 0; 885 int idx = 0;
906 int tmpid; 886 int tmpid;
907 887
908 if (nr_ioapics >= MAX_IO_APICS) { 888 if (nr_ioapics >= MAX_IO_APICS) {
909 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " 889 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
@@ -949,16 +929,10 @@ void __init mp_register_ioapic (
949 mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr, 929 mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr,
950 mp_ioapic_routing[idx].gsi_base, 930 mp_ioapic_routing[idx].gsi_base,
951 mp_ioapic_routing[idx].gsi_end); 931 mp_ioapic_routing[idx].gsi_end);
952
953 return;
954} 932}
955 933
956 934void __init
957void __init mp_override_legacy_irq ( 935mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
958 u8 bus_irq,
959 u8 polarity,
960 u8 trigger,
961 u32 gsi)
962{ 936{
963 struct mpc_config_intsrc intsrc; 937 struct mpc_config_intsrc intsrc;
964 int ioapic = -1; 938 int ioapic = -1;
@@ -996,15 +970,13 @@ void __init mp_override_legacy_irq (
996 mp_irqs[mp_irq_entries] = intsrc; 970 mp_irqs[mp_irq_entries] = intsrc;
997 if (++mp_irq_entries == MAX_IRQ_SOURCES) 971 if (++mp_irq_entries == MAX_IRQ_SOURCES)
998 panic("Max # of irq sources exceeded!\n"); 972 panic("Max # of irq sources exceeded!\n");
999
1000 return;
1001} 973}
1002 974
1003void __init mp_config_acpi_legacy_irqs (void) 975void __init mp_config_acpi_legacy_irqs (void)
1004{ 976{
1005 struct mpc_config_intsrc intsrc; 977 struct mpc_config_intsrc intsrc;
1006 int i = 0; 978 int i = 0;
1007 int ioapic = -1; 979 int ioapic = -1;
1008 980
1009 /* 981 /*
1010 * Fabricate the legacy ISA bus (bus #31). 982 * Fabricate the legacy ISA bus (bus #31).
@@ -1073,12 +1045,12 @@ void __init mp_config_acpi_legacy_irqs (void)
1073 1045
1074#define MAX_GSI_NUM 4096 1046#define MAX_GSI_NUM 4096
1075 1047
1076int mp_register_gsi (u32 gsi, int triggering, int polarity) 1048int mp_register_gsi(u32 gsi, int triggering, int polarity)
1077{ 1049{
1078 int ioapic = -1; 1050 int ioapic = -1;
1079 int ioapic_pin = 0; 1051 int ioapic_pin = 0;
1080 int idx, bit = 0; 1052 int idx, bit = 0;
1081 static int pci_irq = 16; 1053 static int pci_irq = 16;
1082 /* 1054 /*
1083 * Mapping between Global System Interrups, which 1055 * Mapping between Global System Interrups, which
1084 * represent all possible interrupts, and IRQs 1056 * represent all possible interrupts, and IRQs
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index acb351478e42..dbda706fdd14 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -21,83 +21,174 @@
21#include <linux/sysdev.h> 21#include <linux/sysdev.h>
22#include <linux/sysctl.h> 22#include <linux/sysctl.h>
23#include <linux/percpu.h> 23#include <linux/percpu.h>
24#include <linux/dmi.h>
25#include <linux/kprobes.h>
24 26
25#include <asm/smp.h> 27#include <asm/smp.h>
26#include <asm/nmi.h> 28#include <asm/nmi.h>
29#include <asm/kdebug.h>
27#include <asm/intel_arch_perfmon.h> 30#include <asm/intel_arch_perfmon.h>
28 31
29#include "mach_traps.h" 32#include "mach_traps.h"
30 33
31unsigned int nmi_watchdog = NMI_NONE; 34/* perfctr_nmi_owner tracks the ownership of the perfctr registers:
32extern int unknown_nmi_panic; 35 * evtsel_nmi_owner tracks the ownership of the event selection
33static unsigned int nmi_hz = HZ; 36 * - different performance counters/ event selection may be reserved for
34static unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */ 37 * different subsystems this reservation system just tries to coordinate
35static unsigned int nmi_p4_cccr_val; 38 * things a little
36extern void show_registers(struct pt_regs *regs); 39 */
40static DEFINE_PER_CPU(unsigned long, perfctr_nmi_owner);
41static DEFINE_PER_CPU(unsigned long, evntsel_nmi_owner[3]);
37 42
38/* 43/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
39 * lapic_nmi_owner tracks the ownership of the lapic NMI hardware: 44 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
40 * - it may be reserved by some other driver, or not
41 * - when not reserved by some other driver, it may be used for
42 * the NMI watchdog, or not
43 *
44 * This is maintained separately from nmi_active because the NMI
45 * watchdog may also be driven from the I/O APIC timer.
46 */ 45 */
47static DEFINE_SPINLOCK(lapic_nmi_owner_lock); 46#define NMI_MAX_COUNTER_BITS 66
48static unsigned int lapic_nmi_owner;
49#define LAPIC_NMI_WATCHDOG (1<<0)
50#define LAPIC_NMI_RESERVED (1<<1)
51 47
52/* nmi_active: 48/* nmi_active:
53 * +1: the lapic NMI watchdog is active, but can be disabled 49 * >0: the lapic NMI watchdog is active, but can be disabled
54 * 0: the lapic NMI watchdog has not been set up, and cannot 50 * <0: the lapic NMI watchdog has not been set up, and cannot
55 * be enabled 51 * be enabled
56 * -1: the lapic NMI watchdog is disabled, but can be enabled 52 * 0: the lapic NMI watchdog is disabled, but can be enabled
57 */ 53 */
58int nmi_active; 54atomic_t nmi_active = ATOMIC_INIT(0); /* oprofile uses this */
59 55
60#define K7_EVNTSEL_ENABLE (1 << 22) 56unsigned int nmi_watchdog = NMI_DEFAULT;
61#define K7_EVNTSEL_INT (1 << 20) 57static unsigned int nmi_hz = HZ;
62#define K7_EVNTSEL_OS (1 << 17)
63#define K7_EVNTSEL_USR (1 << 16)
64#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76
65#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING
66 58
67#define P6_EVNTSEL0_ENABLE (1 << 22) 59struct nmi_watchdog_ctlblk {
68#define P6_EVNTSEL_INT (1 << 20) 60 int enabled;
69#define P6_EVNTSEL_OS (1 << 17) 61 u64 check_bit;
70#define P6_EVNTSEL_USR (1 << 16) 62 unsigned int cccr_msr;
71#define P6_EVENT_CPU_CLOCKS_NOT_HALTED 0x79 63 unsigned int perfctr_msr; /* the MSR to reset in NMI handler */
72#define P6_NMI_EVENT P6_EVENT_CPU_CLOCKS_NOT_HALTED 64 unsigned int evntsel_msr; /* the MSR to select the events to handle */
65};
66static DEFINE_PER_CPU(struct nmi_watchdog_ctlblk, nmi_watchdog_ctlblk);
73 67
74#define MSR_P4_MISC_ENABLE 0x1A0 68/* local prototypes */
75#define MSR_P4_MISC_ENABLE_PERF_AVAIL (1<<7) 69static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu);
76#define MSR_P4_MISC_ENABLE_PEBS_UNAVAIL (1<<12)
77#define MSR_P4_PERFCTR0 0x300
78#define MSR_P4_CCCR0 0x360
79#define P4_ESCR_EVENT_SELECT(N) ((N)<<25)
80#define P4_ESCR_OS (1<<3)
81#define P4_ESCR_USR (1<<2)
82#define P4_CCCR_OVF_PMI0 (1<<26)
83#define P4_CCCR_OVF_PMI1 (1<<27)
84#define P4_CCCR_THRESHOLD(N) ((N)<<20)
85#define P4_CCCR_COMPLEMENT (1<<19)
86#define P4_CCCR_COMPARE (1<<18)
87#define P4_CCCR_REQUIRED (3<<16)
88#define P4_CCCR_ESCR_SELECT(N) ((N)<<13)
89#define P4_CCCR_ENABLE (1<<12)
90/* Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter
91 CRU_ESCR0 (with any non-null event selector) through a complemented
92 max threshold. [IA32-Vol3, Section 14.9.9] */
93#define MSR_P4_IQ_COUNTER0 0x30C
94#define P4_NMI_CRU_ESCR0 (P4_ESCR_EVENT_SELECT(0x3F)|P4_ESCR_OS|P4_ESCR_USR)
95#define P4_NMI_IQ_CCCR0 \
96 (P4_CCCR_OVF_PMI0|P4_CCCR_THRESHOLD(15)|P4_CCCR_COMPLEMENT| \
97 P4_CCCR_COMPARE|P4_CCCR_REQUIRED|P4_CCCR_ESCR_SELECT(4)|P4_CCCR_ENABLE)
98 70
99#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 71extern void show_registers(struct pt_regs *regs);
100#define ARCH_PERFMON_NMI_EVENT_UMASK ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK 72extern int unknown_nmi_panic;
73
74/* converts an msr to an appropriate reservation bit */
75static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr)
76{
77 /* returns the bit offset of the performance counter register */
78 switch (boot_cpu_data.x86_vendor) {
79 case X86_VENDOR_AMD:
80 return (msr - MSR_K7_PERFCTR0);
81 case X86_VENDOR_INTEL:
82 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
83 return (msr - MSR_ARCH_PERFMON_PERFCTR0);
84
85 switch (boot_cpu_data.x86) {
86 case 6:
87 return (msr - MSR_P6_PERFCTR0);
88 case 15:
89 return (msr - MSR_P4_BPU_PERFCTR0);
90 }
91 }
92 return 0;
93}
94
95/* converts an msr to an appropriate reservation bit */
96static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
97{
98 /* returns the bit offset of the event selection register */
99 switch (boot_cpu_data.x86_vendor) {
100 case X86_VENDOR_AMD:
101 return (msr - MSR_K7_EVNTSEL0);
102 case X86_VENDOR_INTEL:
103 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
104 return (msr - MSR_ARCH_PERFMON_EVENTSEL0);
105
106 switch (boot_cpu_data.x86) {
107 case 6:
108 return (msr - MSR_P6_EVNTSEL0);
109 case 15:
110 return (msr - MSR_P4_BSU_ESCR0);
111 }
112 }
113 return 0;
114}
115
116/* checks for a bit availability (hack for oprofile) */
117int avail_to_resrv_perfctr_nmi_bit(unsigned int counter)
118{
119 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
120
121 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
122}
123
124/* checks the an msr for availability */
125int avail_to_resrv_perfctr_nmi(unsigned int msr)
126{
127 unsigned int counter;
128
129 counter = nmi_perfctr_msr_to_bit(msr);
130 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
131
132 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
133}
134
135int reserve_perfctr_nmi(unsigned int msr)
136{
137 unsigned int counter;
138
139 counter = nmi_perfctr_msr_to_bit(msr);
140 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
141
142 if (!test_and_set_bit(counter, &__get_cpu_var(perfctr_nmi_owner)))
143 return 1;
144 return 0;
145}
146
147void release_perfctr_nmi(unsigned int msr)
148{
149 unsigned int counter;
150
151 counter = nmi_perfctr_msr_to_bit(msr);
152 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
153
154 clear_bit(counter, &__get_cpu_var(perfctr_nmi_owner));
155}
156
157int reserve_evntsel_nmi(unsigned int msr)
158{
159 unsigned int counter;
160
161 counter = nmi_evntsel_msr_to_bit(msr);
162 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
163
164 if (!test_and_set_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0]))
165 return 1;
166 return 0;
167}
168
169void release_evntsel_nmi(unsigned int msr)
170{
171 unsigned int counter;
172
173 counter = nmi_evntsel_msr_to_bit(msr);
174 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
175
176 clear_bit(counter, &__get_cpu_var(evntsel_nmi_owner)[0]);
177}
178
179static __cpuinit inline int nmi_known_cpu(void)
180{
181 switch (boot_cpu_data.x86_vendor) {
182 case X86_VENDOR_AMD:
183 return ((boot_cpu_data.x86 == 15) || (boot_cpu_data.x86 == 6));
184 case X86_VENDOR_INTEL:
185 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
186 return 1;
187 else
188 return ((boot_cpu_data.x86 == 15) || (boot_cpu_data.x86 == 6));
189 }
190 return 0;
191}
101 192
102#ifdef CONFIG_SMP 193#ifdef CONFIG_SMP
103/* The performance counters used by NMI_LOCAL_APIC don't trigger when 194/* The performance counters used by NMI_LOCAL_APIC don't trigger when
@@ -125,7 +216,18 @@ static int __init check_nmi_watchdog(void)
125 unsigned int *prev_nmi_count; 216 unsigned int *prev_nmi_count;
126 int cpu; 217 int cpu;
127 218
128 if (nmi_watchdog == NMI_NONE) 219 /* Enable NMI watchdog for newer systems.
220 Actually it should be safe for most systems before 2004 too except
221 for some IBM systems that corrupt registers when NMI happens
222 during SMM. Unfortunately we don't have more exact information
223 on these and use this coarse check. */
224 if (nmi_watchdog == NMI_DEFAULT && dmi_get_year(DMI_BIOS_DATE) >= 2004)
225 nmi_watchdog = NMI_LOCAL_APIC;
226
227 if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
228 return 0;
229
230 if (!atomic_read(&nmi_active))
129 return 0; 231 return 0;
130 232
131 prev_nmi_count = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL); 233 prev_nmi_count = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
@@ -149,25 +251,45 @@ static int __init check_nmi_watchdog(void)
149 if (!cpu_isset(cpu, cpu_callin_map)) 251 if (!cpu_isset(cpu, cpu_callin_map))
150 continue; 252 continue;
151#endif 253#endif
254 if (!per_cpu(nmi_watchdog_ctlblk, cpu).enabled)
255 continue;
152 if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) { 256 if (nmi_count(cpu) - prev_nmi_count[cpu] <= 5) {
153 endflag = 1;
154 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n", 257 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
155 cpu, 258 cpu,
156 prev_nmi_count[cpu], 259 prev_nmi_count[cpu],
157 nmi_count(cpu)); 260 nmi_count(cpu));
158 nmi_active = 0; 261 per_cpu(nmi_watchdog_ctlblk, cpu).enabled = 0;
159 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG; 262 atomic_dec(&nmi_active);
160 kfree(prev_nmi_count);
161 return -1;
162 } 263 }
163 } 264 }
265 if (!atomic_read(&nmi_active)) {
266 kfree(prev_nmi_count);
267 atomic_set(&nmi_active, -1);
268 return -1;
269 }
164 endflag = 1; 270 endflag = 1;
165 printk("OK.\n"); 271 printk("OK.\n");
166 272
167 /* now that we know it works we can reduce NMI frequency to 273 /* now that we know it works we can reduce NMI frequency to
168 something more reasonable; makes a difference in some configs */ 274 something more reasonable; makes a difference in some configs */
169 if (nmi_watchdog == NMI_LOCAL_APIC) 275 if (nmi_watchdog == NMI_LOCAL_APIC) {
276 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
277
170 nmi_hz = 1; 278 nmi_hz = 1;
279 /*
280 * On Intel CPUs with ARCH_PERFMON only 32 bits in the counter
281 * are writable, with higher bits sign extending from bit 31.
282 * So, we can only program the counter with 31 bit values and
283 * 32nd bit should be 1, for 33.. to be 1.
284 * Find the appropriate nmi_hz
285 */
286 if (wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0 &&
287 ((u64)cpu_khz * 1000) > 0x7fffffffULL) {
288 u64 count = (u64)cpu_khz * 1000;
289 do_div(count, 0x7fffffffUL);
290 nmi_hz = count + 1;
291 }
292 }
171 293
172 kfree(prev_nmi_count); 294 kfree(prev_nmi_count);
173 return 0; 295 return 0;
@@ -181,124 +303,70 @@ static int __init setup_nmi_watchdog(char *str)
181 303
182 get_option(&str, &nmi); 304 get_option(&str, &nmi);
183 305
184 if (nmi >= NMI_INVALID) 306 if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))
185 return 0; 307 return 0;
186 if (nmi == NMI_NONE)
187 nmi_watchdog = nmi;
188 /* 308 /*
189 * If any other x86 CPU has a local APIC, then 309 * If any other x86 CPU has a local APIC, then
190 * please test the NMI stuff there and send me the 310 * please test the NMI stuff there and send me the
191 * missing bits. Right now Intel P6/P4 and AMD K7 only. 311 * missing bits. Right now Intel P6/P4 and AMD K7 only.
192 */ 312 */
193 if ((nmi == NMI_LOCAL_APIC) && 313 if ((nmi == NMI_LOCAL_APIC) && (nmi_known_cpu() == 0))
194 (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && 314 return 0; /* no lapic support */
195 (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15)) 315 nmi_watchdog = nmi;
196 nmi_watchdog = nmi;
197 if ((nmi == NMI_LOCAL_APIC) &&
198 (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
199 (boot_cpu_data.x86 == 6 || boot_cpu_data.x86 == 15))
200 nmi_watchdog = nmi;
201 /*
202 * We can enable the IO-APIC watchdog
203 * unconditionally.
204 */
205 if (nmi == NMI_IO_APIC) {
206 nmi_active = 1;
207 nmi_watchdog = nmi;
208 }
209 return 1; 316 return 1;
210} 317}
211 318
212__setup("nmi_watchdog=", setup_nmi_watchdog); 319__setup("nmi_watchdog=", setup_nmi_watchdog);
213 320
214static void disable_intel_arch_watchdog(void);
215
216static void disable_lapic_nmi_watchdog(void) 321static void disable_lapic_nmi_watchdog(void)
217{ 322{
218 if (nmi_active <= 0) 323 BUG_ON(nmi_watchdog != NMI_LOCAL_APIC);
324
325 if (atomic_read(&nmi_active) <= 0)
219 return; 326 return;
220 switch (boot_cpu_data.x86_vendor) {
221 case X86_VENDOR_AMD:
222 wrmsr(MSR_K7_EVNTSEL0, 0, 0);
223 break;
224 case X86_VENDOR_INTEL:
225 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
226 disable_intel_arch_watchdog();
227 break;
228 }
229 switch (boot_cpu_data.x86) {
230 case 6:
231 if (boot_cpu_data.x86_model > 0xd)
232 break;
233 327
234 wrmsr(MSR_P6_EVNTSEL0, 0, 0); 328 on_each_cpu(stop_apic_nmi_watchdog, NULL, 0, 1);
235 break;
236 case 15:
237 if (boot_cpu_data.x86_model > 0x4)
238 break;
239 329
240 wrmsr(MSR_P4_IQ_CCCR0, 0, 0); 330 BUG_ON(atomic_read(&nmi_active) != 0);
241 wrmsr(MSR_P4_CRU_ESCR0, 0, 0);
242 break;
243 }
244 break;
245 }
246 nmi_active = -1;
247 /* tell do_nmi() and others that we're not active any more */
248 nmi_watchdog = 0;
249} 331}
250 332
251static void enable_lapic_nmi_watchdog(void) 333static void enable_lapic_nmi_watchdog(void)
252{ 334{
253 if (nmi_active < 0) { 335 BUG_ON(nmi_watchdog != NMI_LOCAL_APIC);
254 nmi_watchdog = NMI_LOCAL_APIC;
255 setup_apic_nmi_watchdog();
256 }
257}
258 336
259int reserve_lapic_nmi(void) 337 /* are we already enabled */
260{ 338 if (atomic_read(&nmi_active) != 0)
261 unsigned int old_owner; 339 return;
262
263 spin_lock(&lapic_nmi_owner_lock);
264 old_owner = lapic_nmi_owner;
265 lapic_nmi_owner |= LAPIC_NMI_RESERVED;
266 spin_unlock(&lapic_nmi_owner_lock);
267 if (old_owner & LAPIC_NMI_RESERVED)
268 return -EBUSY;
269 if (old_owner & LAPIC_NMI_WATCHDOG)
270 disable_lapic_nmi_watchdog();
271 return 0;
272}
273 340
274void release_lapic_nmi(void) 341 /* are we lapic aware */
275{ 342 if (nmi_known_cpu() <= 0)
276 unsigned int new_owner; 343 return;
277 344
278 spin_lock(&lapic_nmi_owner_lock); 345 on_each_cpu(setup_apic_nmi_watchdog, NULL, 0, 1);
279 new_owner = lapic_nmi_owner & ~LAPIC_NMI_RESERVED; 346 touch_nmi_watchdog();
280 lapic_nmi_owner = new_owner;
281 spin_unlock(&lapic_nmi_owner_lock);
282 if (new_owner & LAPIC_NMI_WATCHDOG)
283 enable_lapic_nmi_watchdog();
284} 347}
285 348
286void disable_timer_nmi_watchdog(void) 349void disable_timer_nmi_watchdog(void)
287{ 350{
288 if ((nmi_watchdog != NMI_IO_APIC) || (nmi_active <= 0)) 351 BUG_ON(nmi_watchdog != NMI_IO_APIC);
352
353 if (atomic_read(&nmi_active) <= 0)
289 return; 354 return;
290 355
291 unset_nmi_callback(); 356 disable_irq(0);
292 nmi_active = -1; 357 on_each_cpu(stop_apic_nmi_watchdog, NULL, 0, 1);
293 nmi_watchdog = NMI_NONE; 358
359 BUG_ON(atomic_read(&nmi_active) != 0);
294} 360}
295 361
296void enable_timer_nmi_watchdog(void) 362void enable_timer_nmi_watchdog(void)
297{ 363{
298 if (nmi_active < 0) { 364 BUG_ON(nmi_watchdog != NMI_IO_APIC);
299 nmi_watchdog = NMI_IO_APIC; 365
366 if (atomic_read(&nmi_active) == 0) {
300 touch_nmi_watchdog(); 367 touch_nmi_watchdog();
301 nmi_active = 1; 368 on_each_cpu(setup_apic_nmi_watchdog, NULL, 0, 1);
369 enable_irq(0);
302 } 370 }
303} 371}
304 372
@@ -308,15 +376,20 @@ static int nmi_pm_active; /* nmi_active before suspend */
308 376
309static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state) 377static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state)
310{ 378{
311 nmi_pm_active = nmi_active; 379 /* only CPU0 goes here, other CPUs should be offline */
312 disable_lapic_nmi_watchdog(); 380 nmi_pm_active = atomic_read(&nmi_active);
381 stop_apic_nmi_watchdog(NULL);
382 BUG_ON(atomic_read(&nmi_active) != 0);
313 return 0; 383 return 0;
314} 384}
315 385
316static int lapic_nmi_resume(struct sys_device *dev) 386static int lapic_nmi_resume(struct sys_device *dev)
317{ 387{
318 if (nmi_pm_active > 0) 388 /* only CPU0 goes here, other CPUs should be offline */
319 enable_lapic_nmi_watchdog(); 389 if (nmi_pm_active > 0) {
390 setup_apic_nmi_watchdog(NULL);
391 touch_nmi_watchdog();
392 }
320 return 0; 393 return 0;
321} 394}
322 395
@@ -336,7 +409,13 @@ static int __init init_lapic_nmi_sysfs(void)
336{ 409{
337 int error; 410 int error;
338 411
339 if (nmi_active == 0 || nmi_watchdog != NMI_LOCAL_APIC) 412 /* should really be a BUG_ON but b/c this is an
413 * init call, it just doesn't work. -dcz
414 */
415 if (nmi_watchdog != NMI_LOCAL_APIC)
416 return 0;
417
418 if ( atomic_read(&nmi_active) < 0 )
340 return 0; 419 return 0;
341 420
342 error = sysdev_class_register(&nmi_sysclass); 421 error = sysdev_class_register(&nmi_sysclass);
@@ -354,138 +433,269 @@ late_initcall(init_lapic_nmi_sysfs);
354 * Original code written by Keith Owens. 433 * Original code written by Keith Owens.
355 */ 434 */
356 435
357static void clear_msr_range(unsigned int base, unsigned int n) 436static void write_watchdog_counter(unsigned int perfctr_msr, const char *descr)
358{
359 unsigned int i;
360
361 for(i = 0; i < n; ++i)
362 wrmsr(base+i, 0, 0);
363}
364
365static void write_watchdog_counter(const char *descr)
366{ 437{
367 u64 count = (u64)cpu_khz * 1000; 438 u64 count = (u64)cpu_khz * 1000;
368 439
369 do_div(count, nmi_hz); 440 do_div(count, nmi_hz);
370 if(descr) 441 if(descr)
371 Dprintk("setting %s to -0x%08Lx\n", descr, count); 442 Dprintk("setting %s to -0x%08Lx\n", descr, count);
372 wrmsrl(nmi_perfctr_msr, 0 - count); 443 wrmsrl(perfctr_msr, 0 - count);
373} 444}
374 445
375static void setup_k7_watchdog(void) 446/* Note that these events don't tick when the CPU idles. This means
447 the frequency varies with CPU load. */
448
449#define K7_EVNTSEL_ENABLE (1 << 22)
450#define K7_EVNTSEL_INT (1 << 20)
451#define K7_EVNTSEL_OS (1 << 17)
452#define K7_EVNTSEL_USR (1 << 16)
453#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76
454#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING
455
456static int setup_k7_watchdog(void)
376{ 457{
458 unsigned int perfctr_msr, evntsel_msr;
377 unsigned int evntsel; 459 unsigned int evntsel;
460 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
461
462 perfctr_msr = MSR_K7_PERFCTR0;
463 evntsel_msr = MSR_K7_EVNTSEL0;
464 if (!reserve_perfctr_nmi(perfctr_msr))
465 goto fail;
378 466
379 nmi_perfctr_msr = MSR_K7_PERFCTR0; 467 if (!reserve_evntsel_nmi(evntsel_msr))
468 goto fail1;
380 469
381 clear_msr_range(MSR_K7_EVNTSEL0, 4); 470 wrmsrl(perfctr_msr, 0UL);
382 clear_msr_range(MSR_K7_PERFCTR0, 4);
383 471
384 evntsel = K7_EVNTSEL_INT 472 evntsel = K7_EVNTSEL_INT
385 | K7_EVNTSEL_OS 473 | K7_EVNTSEL_OS
386 | K7_EVNTSEL_USR 474 | K7_EVNTSEL_USR
387 | K7_NMI_EVENT; 475 | K7_NMI_EVENT;
388 476
389 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 477 /* setup the timer */
390 write_watchdog_counter("K7_PERFCTR0"); 478 wrmsr(evntsel_msr, evntsel, 0);
479 write_watchdog_counter(perfctr_msr, "K7_PERFCTR0");
391 apic_write(APIC_LVTPC, APIC_DM_NMI); 480 apic_write(APIC_LVTPC, APIC_DM_NMI);
392 evntsel |= K7_EVNTSEL_ENABLE; 481 evntsel |= K7_EVNTSEL_ENABLE;
393 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 482 wrmsr(evntsel_msr, evntsel, 0);
483
484 wd->perfctr_msr = perfctr_msr;
485 wd->evntsel_msr = evntsel_msr;
486 wd->cccr_msr = 0; //unused
487 wd->check_bit = 1ULL<<63;
488 return 1;
489fail1:
490 release_perfctr_nmi(perfctr_msr);
491fail:
492 return 0;
493}
494
495static void stop_k7_watchdog(void)
496{
497 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
498
499 wrmsr(wd->evntsel_msr, 0, 0);
500
501 release_evntsel_nmi(wd->evntsel_msr);
502 release_perfctr_nmi(wd->perfctr_msr);
394} 503}
395 504
396static void setup_p6_watchdog(void) 505#define P6_EVNTSEL0_ENABLE (1 << 22)
506#define P6_EVNTSEL_INT (1 << 20)
507#define P6_EVNTSEL_OS (1 << 17)
508#define P6_EVNTSEL_USR (1 << 16)
509#define P6_EVENT_CPU_CLOCKS_NOT_HALTED 0x79
510#define P6_NMI_EVENT P6_EVENT_CPU_CLOCKS_NOT_HALTED
511
512static int setup_p6_watchdog(void)
397{ 513{
514 unsigned int perfctr_msr, evntsel_msr;
398 unsigned int evntsel; 515 unsigned int evntsel;
516 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
517
518 perfctr_msr = MSR_P6_PERFCTR0;
519 evntsel_msr = MSR_P6_EVNTSEL0;
520 if (!reserve_perfctr_nmi(perfctr_msr))
521 goto fail;
399 522
400 nmi_perfctr_msr = MSR_P6_PERFCTR0; 523 if (!reserve_evntsel_nmi(evntsel_msr))
524 goto fail1;
401 525
402 clear_msr_range(MSR_P6_EVNTSEL0, 2); 526 wrmsrl(perfctr_msr, 0UL);
403 clear_msr_range(MSR_P6_PERFCTR0, 2);
404 527
405 evntsel = P6_EVNTSEL_INT 528 evntsel = P6_EVNTSEL_INT
406 | P6_EVNTSEL_OS 529 | P6_EVNTSEL_OS
407 | P6_EVNTSEL_USR 530 | P6_EVNTSEL_USR
408 | P6_NMI_EVENT; 531 | P6_NMI_EVENT;
409 532
410 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0); 533 /* setup the timer */
411 write_watchdog_counter("P6_PERFCTR0"); 534 wrmsr(evntsel_msr, evntsel, 0);
535 write_watchdog_counter(perfctr_msr, "P6_PERFCTR0");
412 apic_write(APIC_LVTPC, APIC_DM_NMI); 536 apic_write(APIC_LVTPC, APIC_DM_NMI);
413 evntsel |= P6_EVNTSEL0_ENABLE; 537 evntsel |= P6_EVNTSEL0_ENABLE;
414 wrmsr(MSR_P6_EVNTSEL0, evntsel, 0); 538 wrmsr(evntsel_msr, evntsel, 0);
539
540 wd->perfctr_msr = perfctr_msr;
541 wd->evntsel_msr = evntsel_msr;
542 wd->cccr_msr = 0; //unused
543 wd->check_bit = 1ULL<<39;
544 return 1;
545fail1:
546 release_perfctr_nmi(perfctr_msr);
547fail:
548 return 0;
549}
550
551static void stop_p6_watchdog(void)
552{
553 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
554
555 wrmsr(wd->evntsel_msr, 0, 0);
556
557 release_evntsel_nmi(wd->evntsel_msr);
558 release_perfctr_nmi(wd->perfctr_msr);
415} 559}
416 560
561/* Note that these events don't tick when the CPU idles. This means
562 the frequency varies with CPU load. */
563
564#define MSR_P4_MISC_ENABLE_PERF_AVAIL (1<<7)
565#define P4_ESCR_EVENT_SELECT(N) ((N)<<25)
566#define P4_ESCR_OS (1<<3)
567#define P4_ESCR_USR (1<<2)
568#define P4_CCCR_OVF_PMI0 (1<<26)
569#define P4_CCCR_OVF_PMI1 (1<<27)
570#define P4_CCCR_THRESHOLD(N) ((N)<<20)
571#define P4_CCCR_COMPLEMENT (1<<19)
572#define P4_CCCR_COMPARE (1<<18)
573#define P4_CCCR_REQUIRED (3<<16)
574#define P4_CCCR_ESCR_SELECT(N) ((N)<<13)
575#define P4_CCCR_ENABLE (1<<12)
576#define P4_CCCR_OVF (1<<31)
577/* Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter
578 CRU_ESCR0 (with any non-null event selector) through a complemented
579 max threshold. [IA32-Vol3, Section 14.9.9] */
580
417static int setup_p4_watchdog(void) 581static int setup_p4_watchdog(void)
418{ 582{
583 unsigned int perfctr_msr, evntsel_msr, cccr_msr;
584 unsigned int evntsel, cccr_val;
419 unsigned int misc_enable, dummy; 585 unsigned int misc_enable, dummy;
586 unsigned int ht_num;
587 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
420 588
421 rdmsr(MSR_P4_MISC_ENABLE, misc_enable, dummy); 589 rdmsr(MSR_IA32_MISC_ENABLE, misc_enable, dummy);
422 if (!(misc_enable & MSR_P4_MISC_ENABLE_PERF_AVAIL)) 590 if (!(misc_enable & MSR_P4_MISC_ENABLE_PERF_AVAIL))
423 return 0; 591 return 0;
424 592
425 nmi_perfctr_msr = MSR_P4_IQ_COUNTER0;
426 nmi_p4_cccr_val = P4_NMI_IQ_CCCR0;
427#ifdef CONFIG_SMP 593#ifdef CONFIG_SMP
428 if (smp_num_siblings == 2) 594 /* detect which hyperthread we are on */
429 nmi_p4_cccr_val |= P4_CCCR_OVF_PMI1; 595 if (smp_num_siblings == 2) {
596 unsigned int ebx, apicid;
597
598 ebx = cpuid_ebx(1);
599 apicid = (ebx >> 24) & 0xff;
600 ht_num = apicid & 1;
601 } else
430#endif 602#endif
603 ht_num = 0;
431 604
432 if (!(misc_enable & MSR_P4_MISC_ENABLE_PEBS_UNAVAIL)) 605 /* performance counters are shared resources
433 clear_msr_range(0x3F1, 2); 606 * assign each hyperthread its own set
434 /* MSR 0x3F0 seems to have a default value of 0xFC00, but current 607 * (re-use the ESCR0 register, seems safe
435 docs doesn't fully define it, so leave it alone for now. */ 608 * and keeps the cccr_val the same)
436 if (boot_cpu_data.x86_model >= 0x3) { 609 */
437 /* MSR_P4_IQ_ESCR0/1 (0x3ba/0x3bb) removed */ 610 if (!ht_num) {
438 clear_msr_range(0x3A0, 26); 611 /* logical cpu 0 */
439 clear_msr_range(0x3BC, 3); 612 perfctr_msr = MSR_P4_IQ_PERFCTR0;
613 evntsel_msr = MSR_P4_CRU_ESCR0;
614 cccr_msr = MSR_P4_IQ_CCCR0;
615 cccr_val = P4_CCCR_OVF_PMI0 | P4_CCCR_ESCR_SELECT(4);
440 } else { 616 } else {
441 clear_msr_range(0x3A0, 31); 617 /* logical cpu 1 */
618 perfctr_msr = MSR_P4_IQ_PERFCTR1;
619 evntsel_msr = MSR_P4_CRU_ESCR0;
620 cccr_msr = MSR_P4_IQ_CCCR1;
621 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4);
442 } 622 }
443 clear_msr_range(0x3C0, 6); 623
444 clear_msr_range(0x3C8, 6); 624 if (!reserve_perfctr_nmi(perfctr_msr))
445 clear_msr_range(0x3E0, 2); 625 goto fail;
446 clear_msr_range(MSR_P4_CCCR0, 18); 626
447 clear_msr_range(MSR_P4_PERFCTR0, 18); 627 if (!reserve_evntsel_nmi(evntsel_msr))
448 628 goto fail1;
449 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0); 629
450 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0); 630 evntsel = P4_ESCR_EVENT_SELECT(0x3F)
451 write_watchdog_counter("P4_IQ_COUNTER0"); 631 | P4_ESCR_OS
632 | P4_ESCR_USR;
633
634 cccr_val |= P4_CCCR_THRESHOLD(15)
635 | P4_CCCR_COMPLEMENT
636 | P4_CCCR_COMPARE
637 | P4_CCCR_REQUIRED;
638
639 wrmsr(evntsel_msr, evntsel, 0);
640 wrmsr(cccr_msr, cccr_val, 0);
641 write_watchdog_counter(perfctr_msr, "P4_IQ_COUNTER0");
452 apic_write(APIC_LVTPC, APIC_DM_NMI); 642 apic_write(APIC_LVTPC, APIC_DM_NMI);
453 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 643 cccr_val |= P4_CCCR_ENABLE;
644 wrmsr(cccr_msr, cccr_val, 0);
645 wd->perfctr_msr = perfctr_msr;
646 wd->evntsel_msr = evntsel_msr;
647 wd->cccr_msr = cccr_msr;
648 wd->check_bit = 1ULL<<39;
454 return 1; 649 return 1;
650fail1:
651 release_perfctr_nmi(perfctr_msr);
652fail:
653 return 0;
455} 654}
456 655
457static void disable_intel_arch_watchdog(void) 656static void stop_p4_watchdog(void)
458{ 657{
459 unsigned ebx; 658 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
460 659
461 /* 660 wrmsr(wd->cccr_msr, 0, 0);
462 * Check whether the Architectural PerfMon supports 661 wrmsr(wd->evntsel_msr, 0, 0);
463 * Unhalted Core Cycles Event or not. 662
464 * NOTE: Corresponding bit = 0 in ebp indicates event present. 663 release_evntsel_nmi(wd->evntsel_msr);
465 */ 664 release_perfctr_nmi(wd->perfctr_msr);
466 ebx = cpuid_ebx(10);
467 if (!(ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT))
468 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, 0, 0);
469} 665}
470 666
667#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
668#define ARCH_PERFMON_NMI_EVENT_UMASK ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK
669
471static int setup_intel_arch_watchdog(void) 670static int setup_intel_arch_watchdog(void)
472{ 671{
672 unsigned int ebx;
673 union cpuid10_eax eax;
674 unsigned int unused;
675 unsigned int perfctr_msr, evntsel_msr;
473 unsigned int evntsel; 676 unsigned int evntsel;
474 unsigned ebx; 677 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
475 678
476 /* 679 /*
477 * Check whether the Architectural PerfMon supports 680 * Check whether the Architectural PerfMon supports
478 * Unhalted Core Cycles Event or not. 681 * Unhalted Core Cycles Event or not.
479 * NOTE: Corresponding bit = 0 in ebp indicates event present. 682 * NOTE: Corresponding bit = 0 in ebx indicates event present.
480 */ 683 */
481 ebx = cpuid_ebx(10); 684 cpuid(10, &(eax.full), &ebx, &unused, &unused);
482 if ((ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) 685 if ((eax.split.mask_length < (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX+1)) ||
483 return 0; 686 (ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT))
687 goto fail;
688
689 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0;
690 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0;
484 691
485 nmi_perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0; 692 if (!reserve_perfctr_nmi(perfctr_msr))
693 goto fail;
486 694
487 clear_msr_range(MSR_ARCH_PERFMON_EVENTSEL0, 2); 695 if (!reserve_evntsel_nmi(evntsel_msr))
488 clear_msr_range(MSR_ARCH_PERFMON_PERFCTR0, 2); 696 goto fail1;
697
698 wrmsrl(perfctr_msr, 0UL);
489 699
490 evntsel = ARCH_PERFMON_EVENTSEL_INT 700 evntsel = ARCH_PERFMON_EVENTSEL_INT
491 | ARCH_PERFMON_EVENTSEL_OS 701 | ARCH_PERFMON_EVENTSEL_OS
@@ -493,51 +703,145 @@ static int setup_intel_arch_watchdog(void)
493 | ARCH_PERFMON_NMI_EVENT_SEL 703 | ARCH_PERFMON_NMI_EVENT_SEL
494 | ARCH_PERFMON_NMI_EVENT_UMASK; 704 | ARCH_PERFMON_NMI_EVENT_UMASK;
495 705
496 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); 706 /* setup the timer */
497 write_watchdog_counter("INTEL_ARCH_PERFCTR0"); 707 wrmsr(evntsel_msr, evntsel, 0);
708 write_watchdog_counter(perfctr_msr, "INTEL_ARCH_PERFCTR0");
498 apic_write(APIC_LVTPC, APIC_DM_NMI); 709 apic_write(APIC_LVTPC, APIC_DM_NMI);
499 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE; 710 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE;
500 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); 711 wrmsr(evntsel_msr, evntsel, 0);
712
713 wd->perfctr_msr = perfctr_msr;
714 wd->evntsel_msr = evntsel_msr;
715 wd->cccr_msr = 0; //unused
716 wd->check_bit = 1ULL << (eax.split.bit_width - 1);
501 return 1; 717 return 1;
718fail1:
719 release_perfctr_nmi(perfctr_msr);
720fail:
721 return 0;
502} 722}
503 723
504void setup_apic_nmi_watchdog (void) 724static void stop_intel_arch_watchdog(void)
505{ 725{
506 switch (boot_cpu_data.x86_vendor) { 726 unsigned int ebx;
507 case X86_VENDOR_AMD: 727 union cpuid10_eax eax;
508 if (boot_cpu_data.x86 != 6 && boot_cpu_data.x86 != 15) 728 unsigned int unused;
509 return; 729 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
510 setup_k7_watchdog(); 730
511 break; 731 /*
512 case X86_VENDOR_INTEL: 732 * Check whether the Architectural PerfMon supports
513 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { 733 * Unhalted Core Cycles Event or not.
514 if (!setup_intel_arch_watchdog()) 734 * NOTE: Corresponding bit = 0 in ebx indicates event present.
735 */
736 cpuid(10, &(eax.full), &ebx, &unused, &unused);
737 if ((eax.split.mask_length < (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX+1)) ||
738 (ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT))
739 return;
740
741 wrmsr(wd->evntsel_msr, 0, 0);
742 release_evntsel_nmi(wd->evntsel_msr);
743 release_perfctr_nmi(wd->perfctr_msr);
744}
745
746void setup_apic_nmi_watchdog (void *unused)
747{
748 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
749
750 /* only support LOCAL and IO APICs for now */
751 if ((nmi_watchdog != NMI_LOCAL_APIC) &&
752 (nmi_watchdog != NMI_IO_APIC))
753 return;
754
755 if (wd->enabled == 1)
756 return;
757
758 /* cheap hack to support suspend/resume */
759 /* if cpu0 is not active neither should the other cpus */
760 if ((smp_processor_id() != 0) && (atomic_read(&nmi_active) <= 0))
761 return;
762
763 if (nmi_watchdog == NMI_LOCAL_APIC) {
764 switch (boot_cpu_data.x86_vendor) {
765 case X86_VENDOR_AMD:
766 if (boot_cpu_data.x86 != 6 && boot_cpu_data.x86 != 15)
515 return; 767 return;
516 break; 768 if (!setup_k7_watchdog())
517 }
518 switch (boot_cpu_data.x86) {
519 case 6:
520 if (boot_cpu_data.x86_model > 0xd)
521 return; 769 return;
522
523 setup_p6_watchdog();
524 break; 770 break;
525 case 15: 771 case X86_VENDOR_INTEL:
526 if (boot_cpu_data.x86_model > 0x4) 772 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
527 return; 773 if (!setup_intel_arch_watchdog())
774 return;
775 break;
776 }
777 switch (boot_cpu_data.x86) {
778 case 6:
779 if (boot_cpu_data.x86_model > 0xd)
780 return;
781
782 if (!setup_p6_watchdog())
783 return;
784 break;
785 case 15:
786 if (boot_cpu_data.x86_model > 0x4)
787 return;
528 788
529 if (!setup_p4_watchdog()) 789 if (!setup_p4_watchdog())
790 return;
791 break;
792 default:
530 return; 793 return;
794 }
531 break; 795 break;
532 default: 796 default:
533 return; 797 return;
534 } 798 }
535 break; 799 }
536 default: 800 wd->enabled = 1;
801 atomic_inc(&nmi_active);
802}
803
804void stop_apic_nmi_watchdog(void *unused)
805{
806 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
807
808 /* only support LOCAL and IO APICs for now */
809 if ((nmi_watchdog != NMI_LOCAL_APIC) &&
810 (nmi_watchdog != NMI_IO_APIC))
811 return;
812
813 if (wd->enabled == 0)
537 return; 814 return;
815
816 if (nmi_watchdog == NMI_LOCAL_APIC) {
817 switch (boot_cpu_data.x86_vendor) {
818 case X86_VENDOR_AMD:
819 stop_k7_watchdog();
820 break;
821 case X86_VENDOR_INTEL:
822 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
823 stop_intel_arch_watchdog();
824 break;
825 }
826 switch (boot_cpu_data.x86) {
827 case 6:
828 if (boot_cpu_data.x86_model > 0xd)
829 break;
830 stop_p6_watchdog();
831 break;
832 case 15:
833 if (boot_cpu_data.x86_model > 0x4)
834 break;
835 stop_p4_watchdog();
836 break;
837 }
838 break;
839 default:
840 return;
841 }
538 } 842 }
539 lapic_nmi_owner = LAPIC_NMI_WATCHDOG; 843 wd->enabled = 0;
540 nmi_active = 1; 844 atomic_dec(&nmi_active);
541} 845}
542 846
543/* 847/*
@@ -579,7 +883,7 @@ EXPORT_SYMBOL(touch_nmi_watchdog);
579 883
580extern void die_nmi(struct pt_regs *, const char *msg); 884extern void die_nmi(struct pt_regs *, const char *msg);
581 885
582void nmi_watchdog_tick (struct pt_regs * regs) 886__kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
583{ 887{
584 888
585 /* 889 /*
@@ -588,11 +892,23 @@ void nmi_watchdog_tick (struct pt_regs * regs)
588 * smp_processor_id(). 892 * smp_processor_id().
589 */ 893 */
590 unsigned int sum; 894 unsigned int sum;
895 int touched = 0;
591 int cpu = smp_processor_id(); 896 int cpu = smp_processor_id();
897 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
898 u64 dummy;
899 int rc=0;
900
901 /* check for other users first */
902 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
903 == NOTIFY_STOP) {
904 rc = 1;
905 touched = 1;
906 }
592 907
593 sum = per_cpu(irq_stat, cpu).apic_timer_irqs; 908 sum = per_cpu(irq_stat, cpu).apic_timer_irqs;
594 909
595 if (last_irq_sums[cpu] == sum) { 910 /* if the apic timer isn't firing, this cpu isn't doing much */
911 if (!touched && last_irq_sums[cpu] == sum) {
596 /* 912 /*
597 * Ayiee, looks like this CPU is stuck ... 913 * Ayiee, looks like this CPU is stuck ...
598 * wait a few IRQs (5 seconds) before doing the oops ... 914 * wait a few IRQs (5 seconds) before doing the oops ...
@@ -607,27 +923,59 @@ void nmi_watchdog_tick (struct pt_regs * regs)
607 last_irq_sums[cpu] = sum; 923 last_irq_sums[cpu] = sum;
608 alert_counter[cpu] = 0; 924 alert_counter[cpu] = 0;
609 } 925 }
610 if (nmi_perfctr_msr) { 926 /* see if the nmi watchdog went off */
611 if (nmi_perfctr_msr == MSR_P4_IQ_COUNTER0) { 927 if (wd->enabled) {
612 /* 928 if (nmi_watchdog == NMI_LOCAL_APIC) {
613 * P4 quirks: 929 rdmsrl(wd->perfctr_msr, dummy);
614 * - An overflown perfctr will assert its interrupt 930 if (dummy & wd->check_bit){
615 * until the OVF flag in its CCCR is cleared. 931 /* this wasn't a watchdog timer interrupt */
616 * - LVTPC is masked on interrupt and must be 932 goto done;
617 * unmasked by the LVTPC handler. 933 }
934
935 /* only Intel P4 uses the cccr msr */
936 if (wd->cccr_msr != 0) {
937 /*
938 * P4 quirks:
939 * - An overflown perfctr will assert its interrupt
940 * until the OVF flag in its CCCR is cleared.
941 * - LVTPC is masked on interrupt and must be
942 * unmasked by the LVTPC handler.
943 */
944 rdmsrl(wd->cccr_msr, dummy);
945 dummy &= ~P4_CCCR_OVF;
946 wrmsrl(wd->cccr_msr, dummy);
947 apic_write(APIC_LVTPC, APIC_DM_NMI);
948 }
949 else if (wd->perfctr_msr == MSR_P6_PERFCTR0 ||
950 wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) {
951 /* P6 based Pentium M need to re-unmask
952 * the apic vector but it doesn't hurt
953 * other P6 variant.
954 * ArchPerfom/Core Duo also needs this */
955 apic_write(APIC_LVTPC, APIC_DM_NMI);
956 }
957 /* start the cycle over again */
958 write_watchdog_counter(wd->perfctr_msr, NULL);
959 rc = 1;
960 } else if (nmi_watchdog == NMI_IO_APIC) {
961 /* don't know how to accurately check for this.
962 * just assume it was a watchdog timer interrupt
963 * This matches the old behaviour.
618 */ 964 */
619 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 965 rc = 1;
620 apic_write(APIC_LVTPC, APIC_DM_NMI);
621 } 966 }
622 else if (nmi_perfctr_msr == MSR_P6_PERFCTR0 ||
623 nmi_perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) {
624 /* Only P6 based Pentium M need to re-unmask
625 * the apic vector but it doesn't hurt
626 * other P6 variant */
627 apic_write(APIC_LVTPC, APIC_DM_NMI);
628 }
629 write_watchdog_counter(NULL);
630 } 967 }
968done:
969 return rc;
970}
971
972int do_nmi_callback(struct pt_regs * regs, int cpu)
973{
974#ifdef CONFIG_SYSCTL
975 if (unknown_nmi_panic)
976 return unknown_nmi_panic_callback(regs, cpu);
977#endif
978 return 0;
631} 979}
632 980
633#ifdef CONFIG_SYSCTL 981#ifdef CONFIG_SYSCTL
@@ -637,36 +985,46 @@ static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
637 unsigned char reason = get_nmi_reason(); 985 unsigned char reason = get_nmi_reason();
638 char buf[64]; 986 char buf[64];
639 987
640 if (!(reason & 0xc0)) { 988 sprintf(buf, "NMI received for unknown reason %02x\n", reason);
641 sprintf(buf, "NMI received for unknown reason %02x\n", reason); 989 die_nmi(regs, buf);
642 die_nmi(regs, buf);
643 }
644 return 0; 990 return 0;
645} 991}
646 992
647/* 993/*
648 * proc handler for /proc/sys/kernel/unknown_nmi_panic 994 * proc handler for /proc/sys/kernel/nmi
649 */ 995 */
650int proc_unknown_nmi_panic(ctl_table *table, int write, struct file *file, 996int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
651 void __user *buffer, size_t *length, loff_t *ppos) 997 void __user *buffer, size_t *length, loff_t *ppos)
652{ 998{
653 int old_state; 999 int old_state;
654 1000
655 old_state = unknown_nmi_panic; 1001 nmi_watchdog_enabled = (atomic_read(&nmi_active) > 0) ? 1 : 0;
1002 old_state = nmi_watchdog_enabled;
656 proc_dointvec(table, write, file, buffer, length, ppos); 1003 proc_dointvec(table, write, file, buffer, length, ppos);
657 if (!!old_state == !!unknown_nmi_panic) 1004 if (!!old_state == !!nmi_watchdog_enabled)
658 return 0; 1005 return 0;
659 1006
660 if (unknown_nmi_panic) { 1007 if (atomic_read(&nmi_active) < 0) {
661 if (reserve_lapic_nmi() < 0) { 1008 printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
662 unknown_nmi_panic = 0; 1009 return -EIO;
663 return -EBUSY; 1010 }
664 } else { 1011
665 set_nmi_callback(unknown_nmi_panic_callback); 1012 if (nmi_watchdog == NMI_DEFAULT) {
666 } 1013 if (nmi_known_cpu() > 0)
1014 nmi_watchdog = NMI_LOCAL_APIC;
1015 else
1016 nmi_watchdog = NMI_IO_APIC;
1017 }
1018
1019 if (nmi_watchdog == NMI_LOCAL_APIC) {
1020 if (nmi_watchdog_enabled)
1021 enable_lapic_nmi_watchdog();
1022 else
1023 disable_lapic_nmi_watchdog();
667 } else { 1024 } else {
668 release_lapic_nmi(); 1025 printk( KERN_WARNING
669 unset_nmi_callback(); 1026 "NMI watchdog doesn't know what hardware to touch\n");
1027 return -EIO;
670 } 1028 }
671 return 0; 1029 return 0;
672} 1030}
@@ -675,7 +1033,11 @@ int proc_unknown_nmi_panic(ctl_table *table, int write, struct file *file,
675 1033
676EXPORT_SYMBOL(nmi_active); 1034EXPORT_SYMBOL(nmi_active);
677EXPORT_SYMBOL(nmi_watchdog); 1035EXPORT_SYMBOL(nmi_watchdog);
678EXPORT_SYMBOL(reserve_lapic_nmi); 1036EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
679EXPORT_SYMBOL(release_lapic_nmi); 1037EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi_bit);
1038EXPORT_SYMBOL(reserve_perfctr_nmi);
1039EXPORT_SYMBOL(release_perfctr_nmi);
1040EXPORT_SYMBOL(reserve_evntsel_nmi);
1041EXPORT_SYMBOL(release_evntsel_nmi);
680EXPORT_SYMBOL(disable_timer_nmi_watchdog); 1042EXPORT_SYMBOL(disable_timer_nmi_watchdog);
681EXPORT_SYMBOL(enable_timer_nmi_watchdog); 1043EXPORT_SYMBOL(enable_timer_nmi_watchdog);
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 8657c739656a..8c190ca7ae44 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -37,6 +37,7 @@
37#include <linux/kallsyms.h> 37#include <linux/kallsyms.h>
38#include <linux/ptrace.h> 38#include <linux/ptrace.h>
39#include <linux/random.h> 39#include <linux/random.h>
40#include <linux/personality.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -320,15 +321,6 @@ void show_regs(struct pt_regs * regs)
320 * the "args". 321 * the "args".
321 */ 322 */
322extern void kernel_thread_helper(void); 323extern void kernel_thread_helper(void);
323__asm__(".section .text\n"
324 ".align 4\n"
325 "kernel_thread_helper:\n\t"
326 "movl %edx,%eax\n\t"
327 "pushl %edx\n\t"
328 "call *%ebx\n\t"
329 "pushl %eax\n\t"
330 "call do_exit\n"
331 ".previous");
332 324
333/* 325/*
334 * Create a kernel thread 326 * Create a kernel thread
@@ -346,7 +338,7 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
346 regs.xes = __USER_DS; 338 regs.xes = __USER_DS;
347 regs.orig_eax = -1; 339 regs.orig_eax = -1;
348 regs.eip = (unsigned long) kernel_thread_helper; 340 regs.eip = (unsigned long) kernel_thread_helper;
349 regs.xcs = __KERNEL_CS; 341 regs.xcs = __KERNEL_CS | get_kernel_rpl();
350 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2; 342 regs.eflags = X86_EFLAGS_IF | X86_EFLAGS_SF | X86_EFLAGS_PF | 0x2;
351 343
352 /* Ok, create the new process.. */ 344 /* Ok, create the new process.. */
@@ -905,7 +897,7 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *u_info)
905 897
906unsigned long arch_align_stack(unsigned long sp) 898unsigned long arch_align_stack(unsigned long sp)
907{ 899{
908 if (randomize_va_space) 900 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
909 sp -= get_random_int() % 8192; 901 sp -= get_random_int() % 8192;
910 return sp & ~0xf; 902 return sp & ~0xf;
911} 903}
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index d3db03f4085d..775f50e9395b 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -185,17 +185,17 @@ static unsigned long convert_eip_to_linear(struct task_struct *child, struct pt_
185 return addr; 185 return addr;
186} 186}
187 187
188static inline int is_at_popf(struct task_struct *child, struct pt_regs *regs) 188static inline int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
189{ 189{
190 int i, copied; 190 int i, copied;
191 unsigned char opcode[16]; 191 unsigned char opcode[15];
192 unsigned long addr = convert_eip_to_linear(child, regs); 192 unsigned long addr = convert_eip_to_linear(child, regs);
193 193
194 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0); 194 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
195 for (i = 0; i < copied; i++) { 195 for (i = 0; i < copied; i++) {
196 switch (opcode[i]) { 196 switch (opcode[i]) {
197 /* popf */ 197 /* popf and iret */
198 case 0x9d: 198 case 0x9d: case 0xcf:
199 return 1; 199 return 1;
200 /* opcode and address size prefixes */ 200 /* opcode and address size prefixes */
201 case 0x66: case 0x67: 201 case 0x66: case 0x67:
@@ -247,7 +247,7 @@ static void set_singlestep(struct task_struct *child)
247 * don't mark it as being "us" that set it, so that we 247 * don't mark it as being "us" that set it, so that we
248 * won't clear it by hand later. 248 * won't clear it by hand later.
249 */ 249 */
250 if (is_at_popf(child, regs)) 250 if (is_setting_trap_flag(child, regs))
251 return; 251 return;
252 252
253 child->ptrace |= PT_DTRACE; 253 child->ptrace |= PT_DTRACE;
diff --git a/arch/i386/kernel/relocate_kernel.S b/arch/i386/kernel/relocate_kernel.S
index d312616effa1..f151d6fae462 100644
--- a/arch/i386/kernel/relocate_kernel.S
+++ b/arch/i386/kernel/relocate_kernel.S
@@ -7,16 +7,138 @@
7 */ 7 */
8 8
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/page.h>
11#include <asm/kexec.h>
12
13/*
14 * Must be relocatable PIC code callable as a C function
15 */
16
17#define PTR(x) (x << 2)
18#define PAGE_ALIGNED (1 << PAGE_SHIFT)
19#define PAGE_ATTR 0x63 /* _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY */
20#define PAE_PGD_ATTR 0x01 /* _PAGE_PRESENT */
21
22 .text
23 .align PAGE_ALIGNED
24 .globl relocate_kernel
25relocate_kernel:
26 movl 8(%esp), %ebp /* list of pages */
27
28#ifdef CONFIG_X86_PAE
29 /* map the control page at its virtual address */
30
31 movl PTR(VA_PGD)(%ebp), %edi
32 movl PTR(VA_CONTROL_PAGE)(%ebp), %eax
33 andl $0xc0000000, %eax
34 shrl $27, %eax
35 addl %edi, %eax
36
37 movl PTR(PA_PMD_0)(%ebp), %edx
38 orl $PAE_PGD_ATTR, %edx
39 movl %edx, (%eax)
40
41 movl PTR(VA_PMD_0)(%ebp), %edi
42 movl PTR(VA_CONTROL_PAGE)(%ebp), %eax
43 andl $0x3fe00000, %eax
44 shrl $18, %eax
45 addl %edi, %eax
46
47 movl PTR(PA_PTE_0)(%ebp), %edx
48 orl $PAGE_ATTR, %edx
49 movl %edx, (%eax)
50
51 movl PTR(VA_PTE_0)(%ebp), %edi
52 movl PTR(VA_CONTROL_PAGE)(%ebp), %eax
53 andl $0x001ff000, %eax
54 shrl $9, %eax
55 addl %edi, %eax
56
57 movl PTR(PA_CONTROL_PAGE)(%ebp), %edx
58 orl $PAGE_ATTR, %edx
59 movl %edx, (%eax)
60
61 /* identity map the control page at its physical address */
62
63 movl PTR(VA_PGD)(%ebp), %edi
64 movl PTR(PA_CONTROL_PAGE)(%ebp), %eax
65 andl $0xc0000000, %eax
66 shrl $27, %eax
67 addl %edi, %eax
68
69 movl PTR(PA_PMD_1)(%ebp), %edx
70 orl $PAE_PGD_ATTR, %edx
71 movl %edx, (%eax)
72
73 movl PTR(VA_PMD_1)(%ebp), %edi
74 movl PTR(PA_CONTROL_PAGE)(%ebp), %eax
75 andl $0x3fe00000, %eax
76 shrl $18, %eax
77 addl %edi, %eax
78
79 movl PTR(PA_PTE_1)(%ebp), %edx
80 orl $PAGE_ATTR, %edx
81 movl %edx, (%eax)
82
83 movl PTR(VA_PTE_1)(%ebp), %edi
84 movl PTR(PA_CONTROL_PAGE)(%ebp), %eax
85 andl $0x001ff000, %eax
86 shrl $9, %eax
87 addl %edi, %eax
88
89 movl PTR(PA_CONTROL_PAGE)(%ebp), %edx
90 orl $PAGE_ATTR, %edx
91 movl %edx, (%eax)
92#else
93 /* map the control page at its virtual address */
94
95 movl PTR(VA_PGD)(%ebp), %edi
96 movl PTR(VA_CONTROL_PAGE)(%ebp), %eax
97 andl $0xffc00000, %eax
98 shrl $20, %eax
99 addl %edi, %eax
100
101 movl PTR(PA_PTE_0)(%ebp), %edx
102 orl $PAGE_ATTR, %edx
103 movl %edx, (%eax)
104
105 movl PTR(VA_PTE_0)(%ebp), %edi
106 movl PTR(VA_CONTROL_PAGE)(%ebp), %eax
107 andl $0x003ff000, %eax
108 shrl $10, %eax
109 addl %edi, %eax
110
111 movl PTR(PA_CONTROL_PAGE)(%ebp), %edx
112 orl $PAGE_ATTR, %edx
113 movl %edx, (%eax)
114
115 /* identity map the control page at its physical address */
116
117 movl PTR(VA_PGD)(%ebp), %edi
118 movl PTR(PA_CONTROL_PAGE)(%ebp), %eax
119 andl $0xffc00000, %eax
120 shrl $20, %eax
121 addl %edi, %eax
122
123 movl PTR(PA_PTE_1)(%ebp), %edx
124 orl $PAGE_ATTR, %edx
125 movl %edx, (%eax)
126
127 movl PTR(VA_PTE_1)(%ebp), %edi
128 movl PTR(PA_CONTROL_PAGE)(%ebp), %eax
129 andl $0x003ff000, %eax
130 shrl $10, %eax
131 addl %edi, %eax
132
133 movl PTR(PA_CONTROL_PAGE)(%ebp), %edx
134 orl $PAGE_ATTR, %edx
135 movl %edx, (%eax)
136#endif
10 137
11 /*
12 * Must be relocatable PIC code callable as a C function, that once
13 * it starts can not use the previous processes stack.
14 */
15 .globl relocate_new_kernel
16relocate_new_kernel: 138relocate_new_kernel:
17 /* read the arguments and say goodbye to the stack */ 139 /* read the arguments and say goodbye to the stack */
18 movl 4(%esp), %ebx /* page_list */ 140 movl 4(%esp), %ebx /* page_list */
19 movl 8(%esp), %ebp /* reboot_code_buffer */ 141 movl 8(%esp), %ebp /* list of pages */
20 movl 12(%esp), %edx /* start address */ 142 movl 12(%esp), %edx /* start address */
21 movl 16(%esp), %ecx /* cpu_has_pae */ 143 movl 16(%esp), %ecx /* cpu_has_pae */
22 144
@@ -24,11 +146,26 @@ relocate_new_kernel:
24 pushl $0 146 pushl $0
25 popfl 147 popfl
26 148
27 /* set a new stack at the bottom of our page... */ 149 /* get physical address of control page now */
28 lea 4096(%ebp), %esp 150 /* this is impossible after page table switch */
151 movl PTR(PA_CONTROL_PAGE)(%ebp), %edi
29 152
30 /* store the parameters back on the stack */ 153 /* switch to new set of page tables */
31 pushl %edx /* store the start address */ 154 movl PTR(PA_PGD)(%ebp), %eax
155 movl %eax, %cr3
156
157 /* setup a new stack at the end of the physical control page */
158 lea 4096(%edi), %esp
159
160 /* jump to identity mapped page */
161 movl %edi, %eax
162 addl $(identity_mapped - relocate_kernel), %eax
163 pushl %eax
164 ret
165
166identity_mapped:
167 /* store the start address on the stack */
168 pushl %edx
32 169
33 /* Set cr0 to a known state: 170 /* Set cr0 to a known state:
34 * 31 0 == Paging disabled 171 * 31 0 == Paging disabled
@@ -113,8 +250,3 @@ relocate_new_kernel:
113 xorl %edi, %edi 250 xorl %edi, %edi
114 xorl %ebp, %ebp 251 xorl %ebp, %ebp
115 ret 252 ret
116relocate_new_kernel_end:
117
118 .globl relocate_new_kernel_size
119relocate_new_kernel_size:
120 .long relocate_new_kernel_end - relocate_new_kernel
diff --git a/arch/i386/kernel/semaphore.c b/arch/i386/kernel/semaphore.c
deleted file mode 100644
index 98352c374c76..000000000000
--- a/arch/i386/kernel/semaphore.c
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * i386 semaphore implementation.
3 *
4 * (C) Copyright 1999 Linus Torvalds
5 *
6 * Portions Copyright 1999 Red Hat, Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
14 */
15#include <asm/semaphore.h>
16
17/*
18 * The semaphore operations have a special calling sequence that
19 * allow us to do a simpler in-line version of them. These routines
20 * need to convert that sequence back into the C sequence when
21 * there is contention on the semaphore.
22 *
23 * %eax contains the semaphore pointer on entry. Save the C-clobbered
24 * registers (%eax, %edx and %ecx) except %eax whish is either a return
25 * value or just clobbered..
26 */
27asm(
28".section .sched.text\n"
29".align 4\n"
30".globl __down_failed\n"
31"__down_failed:\n\t"
32#if defined(CONFIG_FRAME_POINTER)
33 "pushl %ebp\n\t"
34 "movl %esp,%ebp\n\t"
35#endif
36 "pushl %edx\n\t"
37 "pushl %ecx\n\t"
38 "call __down\n\t"
39 "popl %ecx\n\t"
40 "popl %edx\n\t"
41#if defined(CONFIG_FRAME_POINTER)
42 "movl %ebp,%esp\n\t"
43 "popl %ebp\n\t"
44#endif
45 "ret"
46);
47
48asm(
49".section .sched.text\n"
50".align 4\n"
51".globl __down_failed_interruptible\n"
52"__down_failed_interruptible:\n\t"
53#if defined(CONFIG_FRAME_POINTER)
54 "pushl %ebp\n\t"
55 "movl %esp,%ebp\n\t"
56#endif
57 "pushl %edx\n\t"
58 "pushl %ecx\n\t"
59 "call __down_interruptible\n\t"
60 "popl %ecx\n\t"
61 "popl %edx\n\t"
62#if defined(CONFIG_FRAME_POINTER)
63 "movl %ebp,%esp\n\t"
64 "popl %ebp\n\t"
65#endif
66 "ret"
67);
68
69asm(
70".section .sched.text\n"
71".align 4\n"
72".globl __down_failed_trylock\n"
73"__down_failed_trylock:\n\t"
74#if defined(CONFIG_FRAME_POINTER)
75 "pushl %ebp\n\t"
76 "movl %esp,%ebp\n\t"
77#endif
78 "pushl %edx\n\t"
79 "pushl %ecx\n\t"
80 "call __down_trylock\n\t"
81 "popl %ecx\n\t"
82 "popl %edx\n\t"
83#if defined(CONFIG_FRAME_POINTER)
84 "movl %ebp,%esp\n\t"
85 "popl %ebp\n\t"
86#endif
87 "ret"
88);
89
90asm(
91".section .sched.text\n"
92".align 4\n"
93".globl __up_wakeup\n"
94"__up_wakeup:\n\t"
95 "pushl %edx\n\t"
96 "pushl %ecx\n\t"
97 "call __up\n\t"
98 "popl %ecx\n\t"
99 "popl %edx\n\t"
100 "ret"
101);
102
103/*
104 * rw spinlock fallbacks
105 */
106#if defined(CONFIG_SMP)
107asm(
108".section .sched.text\n"
109".align 4\n"
110".globl __write_lock_failed\n"
111"__write_lock_failed:\n\t"
112 LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
113"1: rep; nop\n\t"
114 "cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
115 "jne 1b\n\t"
116 LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
117 "jnz __write_lock_failed\n\t"
118 "ret"
119);
120
121asm(
122".section .sched.text\n"
123".align 4\n"
124".globl __read_lock_failed\n"
125"__read_lock_failed:\n\t"
126 LOCK_PREFIX "incl (%eax)\n"
127"1: rep; nop\n\t"
128 "cmpl $1,(%eax)\n\t"
129 "js 1b\n\t"
130 LOCK_PREFIX "decl (%eax)\n\t"
131 "js __read_lock_failed\n\t"
132 "ret"
133);
134#endif
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 16d99444cf66..814cdebf7377 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -90,18 +90,6 @@ EXPORT_SYMBOL(boot_cpu_data);
90 90
91unsigned long mmu_cr4_features; 91unsigned long mmu_cr4_features;
92 92
93#ifdef CONFIG_ACPI
94 int acpi_disabled = 0;
95#else
96 int acpi_disabled = 1;
97#endif
98EXPORT_SYMBOL(acpi_disabled);
99
100#ifdef CONFIG_ACPI
101int __initdata acpi_force = 0;
102extern acpi_interrupt_flags acpi_sci_flags;
103#endif
104
105/* for MCA, but anyone else can use it if they want */ 93/* for MCA, but anyone else can use it if they want */
106unsigned int machine_id; 94unsigned int machine_id;
107#ifdef CONFIG_MCA 95#ifdef CONFIG_MCA
@@ -149,7 +137,6 @@ EXPORT_SYMBOL(ist_info);
149struct e820map e820; 137struct e820map e820;
150 138
151extern void early_cpu_init(void); 139extern void early_cpu_init(void);
152extern void generic_apic_probe(char *);
153extern int root_mountflags; 140extern int root_mountflags;
154 141
155unsigned long saved_videomode; 142unsigned long saved_videomode;
@@ -701,238 +688,132 @@ static inline void copy_edd(void)
701} 688}
702#endif 689#endif
703 690
704static void __init parse_cmdline_early (char ** cmdline_p) 691static int __initdata user_defined_memmap = 0;
705{
706 char c = ' ', *to = command_line, *from = saved_command_line;
707 int len = 0;
708 int userdef = 0;
709 692
710 /* Save unparsed command line copy for /proc/cmdline */ 693/*
711 saved_command_line[COMMAND_LINE_SIZE-1] = '\0'; 694 * "mem=nopentium" disables the 4MB page tables.
695 * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM
696 * to <mem>, overriding the bios size.
697 * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from
698 * <start> to <start>+<mem>, overriding the bios size.
699 *
700 * HPA tells me bootloaders need to parse mem=, so no new
701 * option should be mem= [also see Documentation/i386/boot.txt]
702 */
703static int __init parse_mem(char *arg)
704{
705 if (!arg)
706 return -EINVAL;
712 707
713 for (;;) { 708 if (strcmp(arg, "nopentium") == 0) {
714 if (c != ' ') 709 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
715 goto next_char; 710 disable_pse = 1;
716 /* 711 } else {
717 * "mem=nopentium" disables the 4MB page tables. 712 /* If the user specifies memory size, we
718 * "mem=XXX[kKmM]" defines a memory region from HIGH_MEM 713 * limit the BIOS-provided memory map to
719 * to <mem>, overriding the bios size. 714 * that size. exactmap can be used to specify
720 * "memmap=XXX[KkmM]@XXX[KkmM]" defines a memory region from 715 * the exact map. mem=number can be used to
721 * <start> to <start>+<mem>, overriding the bios size. 716 * trim the existing memory map.
722 *
723 * HPA tells me bootloaders need to parse mem=, so no new
724 * option should be mem= [also see Documentation/i386/boot.txt]
725 */ 717 */
726 if (!memcmp(from, "mem=", 4)) { 718 unsigned long long mem_size;
727 if (to != command_line)
728 to--;
729 if (!memcmp(from+4, "nopentium", 9)) {
730 from += 9+4;
731 clear_bit(X86_FEATURE_PSE, boot_cpu_data.x86_capability);
732 disable_pse = 1;
733 } else {
734 /* If the user specifies memory size, we
735 * limit the BIOS-provided memory map to
736 * that size. exactmap can be used to specify
737 * the exact map. mem=number can be used to
738 * trim the existing memory map.
739 */
740 unsigned long long mem_size;
741 719
742 mem_size = memparse(from+4, &from); 720 mem_size = memparse(arg, &arg);
743 limit_regions(mem_size); 721 limit_regions(mem_size);
744 userdef=1; 722 user_defined_memmap = 1;
745 } 723 }
746 } 724 return 0;
747 725}
748 else if (!memcmp(from, "memmap=", 7)) { 726early_param("mem", parse_mem);
749 if (to != command_line)
750 to--;
751 if (!memcmp(from+7, "exactmap", 8)) {
752#ifdef CONFIG_CRASH_DUMP
753 /* If we are doing a crash dump, we
754 * still need to know the real mem
755 * size before original memory map is
756 * reset.
757 */
758 find_max_pfn();
759 saved_max_pfn = max_pfn;
760#endif
761 from += 8+7;
762 e820.nr_map = 0;
763 userdef = 1;
764 } else {
765 /* If the user specifies memory size, we
766 * limit the BIOS-provided memory map to
767 * that size. exactmap can be used to specify
768 * the exact map. mem=number can be used to
769 * trim the existing memory map.
770 */
771 unsigned long long start_at, mem_size;
772
773 mem_size = memparse(from+7, &from);
774 if (*from == '@') {
775 start_at = memparse(from+1, &from);
776 add_memory_region(start_at, mem_size, E820_RAM);
777 } else if (*from == '#') {
778 start_at = memparse(from+1, &from);
779 add_memory_region(start_at, mem_size, E820_ACPI);
780 } else if (*from == '$') {
781 start_at = memparse(from+1, &from);
782 add_memory_region(start_at, mem_size, E820_RESERVED);
783 } else {
784 limit_regions(mem_size);
785 userdef=1;
786 }
787 }
788 }
789
790 else if (!memcmp(from, "noexec=", 7))
791 noexec_setup(from + 7);
792 727
728static int __init parse_memmap(char *arg)
729{
730 if (!arg)
731 return -EINVAL;
793 732
794#ifdef CONFIG_X86_SMP 733 if (strcmp(arg, "exactmap") == 0) {
795 /* 734#ifdef CONFIG_CRASH_DUMP
796 * If the BIOS enumerates physical processors before logical, 735 /* If we are doing a crash dump, we
797 * maxcpus=N at enumeration-time can be used to disable HT. 736 * still need to know the real mem
737 * size before original memory map is
738 * reset.
798 */ 739 */
799 else if (!memcmp(from, "maxcpus=", 8)) { 740 find_max_pfn();
800 extern unsigned int maxcpus; 741 saved_max_pfn = max_pfn;
801
802 maxcpus = simple_strtoul(from + 8, NULL, 0);
803 }
804#endif 742#endif
805 743 e820.nr_map = 0;
806#ifdef CONFIG_ACPI 744 user_defined_memmap = 1;
807 /* "acpi=off" disables both ACPI table parsing and interpreter */ 745 } else {
808 else if (!memcmp(from, "acpi=off", 8)) { 746 /* If the user specifies memory size, we
809 disable_acpi(); 747 * limit the BIOS-provided memory map to
810 } 748 * that size. exactmap can be used to specify
811 749 * the exact map. mem=number can be used to
812 /* acpi=force to over-ride black-list */ 750 * trim the existing memory map.
813 else if (!memcmp(from, "acpi=force", 10)) { 751 */
814 acpi_force = 1; 752 unsigned long long start_at, mem_size;
815 acpi_ht = 1; 753
816 acpi_disabled = 0; 754 mem_size = memparse(arg, &arg);
817 } 755 if (*arg == '@') {
818 756 start_at = memparse(arg+1, &arg);
819 /* acpi=strict disables out-of-spec workarounds */ 757 add_memory_region(start_at, mem_size, E820_RAM);
820 else if (!memcmp(from, "acpi=strict", 11)) { 758 } else if (*arg == '#') {
821 acpi_strict = 1; 759 start_at = memparse(arg+1, &arg);
822 } 760 add_memory_region(start_at, mem_size, E820_ACPI);
823 761 } else if (*arg == '$') {
824 /* Limit ACPI just to boot-time to enable HT */ 762 start_at = memparse(arg+1, &arg);
825 else if (!memcmp(from, "acpi=ht", 7)) { 763 add_memory_region(start_at, mem_size, E820_RESERVED);
826 if (!acpi_force) 764 } else {
827 disable_acpi(); 765 limit_regions(mem_size);
828 acpi_ht = 1; 766 user_defined_memmap = 1;
829 }
830
831 /* "pci=noacpi" disable ACPI IRQ routing and PCI scan */
832 else if (!memcmp(from, "pci=noacpi", 10)) {
833 acpi_disable_pci();
834 }
835 /* "acpi=noirq" disables ACPI interrupt routing */
836 else if (!memcmp(from, "acpi=noirq", 10)) {
837 acpi_noirq_set();
838 } 767 }
768 }
769 return 0;
770}
771early_param("memmap", parse_memmap);
839 772
840 else if (!memcmp(from, "acpi_sci=edge", 13)) 773#ifdef CONFIG_PROC_VMCORE
841 acpi_sci_flags.trigger = 1; 774/* elfcorehdr= specifies the location of elf core header
842 775 * stored by the crashed kernel.
843 else if (!memcmp(from, "acpi_sci=level", 14)) 776 */
844 acpi_sci_flags.trigger = 3; 777static int __init parse_elfcorehdr(char *arg)
845 778{
846 else if (!memcmp(from, "acpi_sci=high", 13)) 779 if (!arg)
847 acpi_sci_flags.polarity = 1; 780 return -EINVAL;
848
849 else if (!memcmp(from, "acpi_sci=low", 12))
850 acpi_sci_flags.polarity = 3;
851
852#ifdef CONFIG_X86_IO_APIC
853 else if (!memcmp(from, "acpi_skip_timer_override", 24))
854 acpi_skip_timer_override = 1;
855
856 if (!memcmp(from, "disable_timer_pin_1", 19))
857 disable_timer_pin_1 = 1;
858 if (!memcmp(from, "enable_timer_pin_1", 18))
859 disable_timer_pin_1 = -1;
860 781
861 /* disable IO-APIC */ 782 elfcorehdr_addr = memparse(arg, &arg);
862 else if (!memcmp(from, "noapic", 6)) 783 return 0;
863 disable_ioapic_setup(); 784}
864#endif /* CONFIG_X86_IO_APIC */ 785early_param("elfcorehdr", parse_elfcorehdr);
865#endif /* CONFIG_ACPI */ 786#endif /* CONFIG_PROC_VMCORE */
866 787
867#ifdef CONFIG_X86_LOCAL_APIC 788/*
868 /* enable local APIC */ 789 * highmem=size forces highmem to be exactly 'size' bytes.
869 else if (!memcmp(from, "lapic", 5)) 790 * This works even on boxes that have no highmem otherwise.
870 lapic_enable(); 791 * This also works to reduce highmem size on bigger boxes.
792 */
793static int __init parse_highmem(char *arg)
794{
795 if (!arg)
796 return -EINVAL;
871 797
872 /* disable local APIC */ 798 highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT;
873 else if (!memcmp(from, "nolapic", 6)) 799 return 0;
874 lapic_disable(); 800}
875#endif /* CONFIG_X86_LOCAL_APIC */ 801early_param("highmem", parse_highmem);
876 802
877#ifdef CONFIG_KEXEC 803/*
878 /* crashkernel=size@addr specifies the location to reserve for 804 * vmalloc=size forces the vmalloc area to be exactly 'size'
879 * a crash kernel. By reserving this memory we guarantee 805 * bytes. This can be used to increase (or decrease) the
880 * that linux never set's it up as a DMA target. 806 * vmalloc area - the default is 128m.
881 * Useful for holding code to do something appropriate 807 */
882 * after a kernel panic. 808static int __init parse_vmalloc(char *arg)
883 */ 809{
884 else if (!memcmp(from, "crashkernel=", 12)) { 810 if (!arg)
885 unsigned long size, base; 811 return -EINVAL;
886 size = memparse(from+12, &from);
887 if (*from == '@') {
888 base = memparse(from+1, &from);
889 /* FIXME: Do I want a sanity check
890 * to validate the memory range?
891 */
892 crashk_res.start = base;
893 crashk_res.end = base + size - 1;
894 }
895 }
896#endif
897#ifdef CONFIG_PROC_VMCORE
898 /* elfcorehdr= specifies the location of elf core header
899 * stored by the crashed kernel.
900 */
901 else if (!memcmp(from, "elfcorehdr=", 11))
902 elfcorehdr_addr = memparse(from+11, &from);
903#endif
904 812
905 /* 813 __VMALLOC_RESERVE = memparse(arg, &arg);
906 * highmem=size forces highmem to be exactly 'size' bytes. 814 return 0;
907 * This works even on boxes that have no highmem otherwise.
908 * This also works to reduce highmem size on bigger boxes.
909 */
910 else if (!memcmp(from, "highmem=", 8))
911 highmem_pages = memparse(from+8, &from) >> PAGE_SHIFT;
912
913 /*
914 * vmalloc=size forces the vmalloc area to be exactly 'size'
915 * bytes. This can be used to increase (or decrease) the
916 * vmalloc area - the default is 128m.
917 */
918 else if (!memcmp(from, "vmalloc=", 8))
919 __VMALLOC_RESERVE = memparse(from+8, &from);
920
921 next_char:
922 c = *(from++);
923 if (!c)
924 break;
925 if (COMMAND_LINE_SIZE <= ++len)
926 break;
927 *(to++) = c;
928 }
929 *to = '\0';
930 *cmdline_p = command_line;
931 if (userdef) {
932 printk(KERN_INFO "user-defined physical RAM map:\n");
933 print_memory_map("user");
934 }
935} 815}
816early_param("vmalloc", parse_vmalloc);
936 817
937/* 818/*
938 * reservetop=size reserves a hole at the top of the kernel address space which 819 * reservetop=size reserves a hole at the top of the kernel address space which
@@ -1189,6 +1070,14 @@ static unsigned long __init setup_memory(void)
1189 } 1070 }
1190 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", 1071 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
1191 pages_to_mb(highend_pfn - highstart_pfn)); 1072 pages_to_mb(highend_pfn - highstart_pfn));
1073 num_physpages = highend_pfn;
1074 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
1075#else
1076 num_physpages = max_low_pfn;
1077 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
1078#endif
1079#ifdef CONFIG_FLATMEM
1080 max_mapnr = num_physpages;
1192#endif 1081#endif
1193 printk(KERN_NOTICE "%ldMB LOWMEM available.\n", 1082 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
1194 pages_to_mb(max_low_pfn)); 1083 pages_to_mb(max_low_pfn));
@@ -1200,22 +1089,20 @@ static unsigned long __init setup_memory(void)
1200 1089
1201void __init zone_sizes_init(void) 1090void __init zone_sizes_init(void)
1202{ 1091{
1203 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
1204 unsigned int max_dma, low;
1205
1206 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
1207 low = max_low_pfn;
1208
1209 if (low < max_dma)
1210 zones_size[ZONE_DMA] = low;
1211 else {
1212 zones_size[ZONE_DMA] = max_dma;
1213 zones_size[ZONE_NORMAL] = low - max_dma;
1214#ifdef CONFIG_HIGHMEM 1092#ifdef CONFIG_HIGHMEM
1215 zones_size[ZONE_HIGHMEM] = highend_pfn - low; 1093 unsigned long max_zone_pfns[MAX_NR_ZONES] = {
1094 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
1095 max_low_pfn,
1096 highend_pfn};
1097 add_active_range(0, 0, highend_pfn);
1098#else
1099 unsigned long max_zone_pfns[MAX_NR_ZONES] = {
1100 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
1101 max_low_pfn};
1102 add_active_range(0, 0, max_low_pfn);
1216#endif 1103#endif
1217 } 1104
1218 free_area_init(zones_size); 1105 free_area_init_nodes(max_zone_pfns);
1219} 1106}
1220#else 1107#else
1221extern unsigned long __init setup_memory(void); 1108extern unsigned long __init setup_memory(void);
@@ -1518,17 +1405,15 @@ void __init setup_arch(char **cmdline_p)
1518 data_resource.start = virt_to_phys(_etext); 1405 data_resource.start = virt_to_phys(_etext);
1519 data_resource.end = virt_to_phys(_edata)-1; 1406 data_resource.end = virt_to_phys(_edata)-1;
1520 1407
1521 parse_cmdline_early(cmdline_p); 1408 parse_early_param();
1522 1409
1523#ifdef CONFIG_EARLY_PRINTK 1410 if (user_defined_memmap) {
1524 { 1411 printk(KERN_INFO "user-defined physical RAM map:\n");
1525 char *s = strstr(*cmdline_p, "earlyprintk="); 1412 print_memory_map("user");
1526 if (s) {
1527 setup_early_printk(strchr(s, '=') + 1);
1528 printk("early console enabled\n");
1529 }
1530 } 1413 }
1531#endif 1414
1415 strlcpy(command_line, saved_command_line, COMMAND_LINE_SIZE);
1416 *cmdline_p = command_line;
1532 1417
1533 max_low_pfn = setup_memory(); 1418 max_low_pfn = setup_memory();
1534 1419
@@ -1557,7 +1442,7 @@ void __init setup_arch(char **cmdline_p)
1557 dmi_scan_machine(); 1442 dmi_scan_machine();
1558 1443
1559#ifdef CONFIG_X86_GENERICARCH 1444#ifdef CONFIG_X86_GENERICARCH
1560 generic_apic_probe(*cmdline_p); 1445 generic_apic_probe();
1561#endif 1446#endif
1562 if (efi_enabled) 1447 if (efi_enabled)
1563 efi_map_memmap(); 1448 efi_map_memmap();
@@ -1569,9 +1454,11 @@ void __init setup_arch(char **cmdline_p)
1569 acpi_boot_table_init(); 1454 acpi_boot_table_init();
1570#endif 1455#endif
1571 1456
1457#ifdef CONFIG_PCI
1572#ifdef CONFIG_X86_IO_APIC 1458#ifdef CONFIG_X86_IO_APIC
1573 check_acpi_pci(); /* Checks more than just ACPI actually */ 1459 check_acpi_pci(); /* Checks more than just ACPI actually */
1574#endif 1460#endif
1461#endif
1575 1462
1576#ifdef CONFIG_ACPI 1463#ifdef CONFIG_ACPI
1577 acpi_boot_init(); 1464 acpi_boot_init();
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index efe07990e7fc..020d873b7d21 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -177,6 +177,9 @@ static void __devinit smp_store_cpu_info(int id)
177 */ 177 */
178 if ((c->x86_vendor == X86_VENDOR_AMD) && (c->x86 == 6)) { 178 if ((c->x86_vendor == X86_VENDOR_AMD) && (c->x86 == 6)) {
179 179
180 if (num_possible_cpus() == 1)
181 goto valid_k7;
182
180 /* Athlon 660/661 is valid. */ 183 /* Athlon 660/661 is valid. */
181 if ((c->x86_model==6) && ((c->x86_mask==0) || (c->x86_mask==1))) 184 if ((c->x86_model==6) && ((c->x86_mask==0) || (c->x86_mask==1)))
182 goto valid_k7; 185 goto valid_k7;
@@ -1376,7 +1379,8 @@ int __cpu_disable(void)
1376 */ 1379 */
1377 if (cpu == 0) 1380 if (cpu == 0)
1378 return -EBUSY; 1381 return -EBUSY;
1379 1382 if (nmi_watchdog == NMI_LOCAL_APIC)
1383 stop_apic_nmi_watchdog(NULL);
1380 clear_local_APIC(); 1384 clear_local_APIC();
1381 /* Allow any queued timer interrupts to get serviced */ 1385 /* Allow any queued timer interrupts to get serviced */
1382 local_irq_enable(); 1386 local_irq_enable();
@@ -1490,3 +1494,16 @@ void __init smp_intr_init(void)
1490 /* IPI for generic function call */ 1494 /* IPI for generic function call */
1491 set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt); 1495 set_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
1492} 1496}
1497
1498/*
1499 * If the BIOS enumerates physical processors before logical,
1500 * maxcpus=N at enumeration-time can be used to disable HT.
1501 */
1502static int __init parse_maxcpus(char *arg)
1503{
1504 extern unsigned int maxcpus;
1505
1506 maxcpus = simple_strtoul(arg, NULL, 0);
1507 return 0;
1508}
1509early_param("maxcpus", parse_maxcpus);
diff --git a/arch/i386/kernel/srat.c b/arch/i386/kernel/srat.c
index 83db411b3aa7..32413122c4c2 100644
--- a/arch/i386/kernel/srat.c
+++ b/arch/i386/kernel/srat.c
@@ -54,8 +54,6 @@ struct node_memory_chunk_s {
54static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS]; 54static struct node_memory_chunk_s node_memory_chunk[MAXCHUNKS];
55 55
56static int num_memory_chunks; /* total number of memory chunks */ 56static int num_memory_chunks; /* total number of memory chunks */
57static int zholes_size_init;
58static unsigned long zholes_size[MAX_NUMNODES * MAX_NR_ZONES];
59 57
60extern void * boot_ioremap(unsigned long, unsigned long); 58extern void * boot_ioremap(unsigned long, unsigned long);
61 59
@@ -135,47 +133,6 @@ static void __init parse_memory_affinity_structure (char *sratp)
135 "enabled and removable" : "enabled" ) ); 133 "enabled and removable" : "enabled" ) );
136} 134}
137 135
138/* Take a chunk of pages from page frame cstart to cend and count the number
139 * of pages in each zone, returned via zones[].
140 */
141static __init void chunk_to_zones(unsigned long cstart, unsigned long cend,
142 unsigned long *zones)
143{
144 unsigned long max_dma;
145 extern unsigned long max_low_pfn;
146
147 int z;
148 unsigned long rend;
149
150 /* FIXME: MAX_DMA_ADDRESS and max_low_pfn are trying to provide
151 * similarly scoped information and should be handled in a consistant
152 * manner.
153 */
154 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
155
156 /* Split the hole into the zones in which it falls. Repeatedly
157 * take the segment in which the remaining hole starts, round it
158 * to the end of that zone.
159 */
160 memset(zones, 0, MAX_NR_ZONES * sizeof(long));
161 while (cstart < cend) {
162 if (cstart < max_dma) {
163 z = ZONE_DMA;
164 rend = (cend < max_dma)? cend : max_dma;
165
166 } else if (cstart < max_low_pfn) {
167 z = ZONE_NORMAL;
168 rend = (cend < max_low_pfn)? cend : max_low_pfn;
169
170 } else {
171 z = ZONE_HIGHMEM;
172 rend = cend;
173 }
174 zones[z] += rend - cstart;
175 cstart = rend;
176 }
177}
178
179/* 136/*
180 * The SRAT table always lists ascending addresses, so can always 137 * The SRAT table always lists ascending addresses, so can always
181 * assume that the first "start" address that you see is the real 138 * assume that the first "start" address that you see is the real
@@ -220,7 +177,6 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp)
220 177
221 memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */ 178 memset(pxm_bitmap, 0, sizeof(pxm_bitmap)); /* init proximity domain bitmap */
222 memset(node_memory_chunk, 0, sizeof(node_memory_chunk)); 179 memset(node_memory_chunk, 0, sizeof(node_memory_chunk));
223 memset(zholes_size, 0, sizeof(zholes_size));
224 180
225 num_memory_chunks = 0; 181 num_memory_chunks = 0;
226 while (p < end) { 182 while (p < end) {
@@ -284,6 +240,7 @@ static int __init acpi20_parse_srat(struct acpi_table_srat *sratp)
284 printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n", 240 printk("chunk %d nid %d start_pfn %08lx end_pfn %08lx\n",
285 j, chunk->nid, chunk->start_pfn, chunk->end_pfn); 241 j, chunk->nid, chunk->start_pfn, chunk->end_pfn);
286 node_read_chunk(chunk->nid, chunk); 242 node_read_chunk(chunk->nid, chunk);
243 add_active_range(chunk->nid, chunk->start_pfn, chunk->end_pfn);
287 } 244 }
288 245
289 for_each_online_node(nid) { 246 for_each_online_node(nid) {
@@ -392,57 +349,7 @@ int __init get_memcfg_from_srat(void)
392 return acpi20_parse_srat((struct acpi_table_srat *)header); 349 return acpi20_parse_srat((struct acpi_table_srat *)header);
393 } 350 }
394out_err: 351out_err:
352 remove_all_active_ranges();
395 printk("failed to get NUMA memory information from SRAT table\n"); 353 printk("failed to get NUMA memory information from SRAT table\n");
396 return 0; 354 return 0;
397} 355}
398
399/* For each node run the memory list to determine whether there are
400 * any memory holes. For each hole determine which ZONE they fall
401 * into.
402 *
403 * NOTE#1: this requires knowledge of the zone boundries and so
404 * _cannot_ be performed before those are calculated in setup_memory.
405 *
406 * NOTE#2: we rely on the fact that the memory chunks are ordered by
407 * start pfn number during setup.
408 */
409static void __init get_zholes_init(void)
410{
411 int nid;
412 int c;
413 int first;
414 unsigned long end = 0;
415
416 for_each_online_node(nid) {
417 first = 1;
418 for (c = 0; c < num_memory_chunks; c++){
419 if (node_memory_chunk[c].nid == nid) {
420 if (first) {
421 end = node_memory_chunk[c].end_pfn;
422 first = 0;
423
424 } else {
425 /* Record any gap between this chunk
426 * and the previous chunk on this node
427 * against the zones it spans.
428 */
429 chunk_to_zones(end,
430 node_memory_chunk[c].start_pfn,
431 &zholes_size[nid * MAX_NR_ZONES]);
432 }
433 }
434 }
435 }
436}
437
438unsigned long * __init get_zholes_size(int nid)
439{
440 if (!zholes_size_init) {
441 zholes_size_init++;
442 get_zholes_init();
443 }
444 if (nid >= MAX_NUMNODES || !node_online(nid))
445 printk("%s: nid = %d is invalid/offline. num_online_nodes = %d",
446 __FUNCTION__, nid, num_online_nodes());
447 return &zholes_size[nid * MAX_NR_ZONES];
448}
diff --git a/arch/i386/kernel/stacktrace.c b/arch/i386/kernel/stacktrace.c
deleted file mode 100644
index e62a037ab399..000000000000
--- a/arch/i386/kernel/stacktrace.c
+++ /dev/null
@@ -1,98 +0,0 @@
1/*
2 * arch/i386/kernel/stacktrace.c
3 *
4 * Stack trace management functions
5 *
6 * Copyright (C) 2006 Red Hat, Inc., Ingo Molnar <mingo@redhat.com>
7 */
8#include <linux/sched.h>
9#include <linux/stacktrace.h>
10
11static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
12{
13 return p > (void *)tinfo &&
14 p < (void *)tinfo + THREAD_SIZE - 3;
15}
16
17/*
18 * Save stack-backtrace addresses into a stack_trace buffer:
19 */
20static inline unsigned long
21save_context_stack(struct stack_trace *trace, unsigned int skip,
22 struct thread_info *tinfo, unsigned long *stack,
23 unsigned long ebp)
24{
25 unsigned long addr;
26
27#ifdef CONFIG_FRAME_POINTER
28 while (valid_stack_ptr(tinfo, (void *)ebp)) {
29 addr = *(unsigned long *)(ebp + 4);
30 if (!skip)
31 trace->entries[trace->nr_entries++] = addr;
32 else
33 skip--;
34 if (trace->nr_entries >= trace->max_entries)
35 break;
36 /*
37 * break out of recursive entries (such as
38 * end_of_stack_stop_unwind_function):
39 */
40 if (ebp == *(unsigned long *)ebp)
41 break;
42
43 ebp = *(unsigned long *)ebp;
44 }
45#else
46 while (valid_stack_ptr(tinfo, stack)) {
47 addr = *stack++;
48 if (__kernel_text_address(addr)) {
49 if (!skip)
50 trace->entries[trace->nr_entries++] = addr;
51 else
52 skip--;
53 if (trace->nr_entries >= trace->max_entries)
54 break;
55 }
56 }
57#endif
58
59 return ebp;
60}
61
62/*
63 * Save stack-backtrace addresses into a stack_trace buffer.
64 * If all_contexts is set, all contexts (hardirq, softirq and process)
65 * are saved. If not set then only the current context is saved.
66 */
67void save_stack_trace(struct stack_trace *trace,
68 struct task_struct *task, int all_contexts,
69 unsigned int skip)
70{
71 unsigned long ebp;
72 unsigned long *stack = &ebp;
73
74 WARN_ON(trace->nr_entries || !trace->max_entries);
75
76 if (!task || task == current) {
77 /* Grab ebp right from our regs: */
78 asm ("movl %%ebp, %0" : "=r" (ebp));
79 } else {
80 /* ebp is the last reg pushed by switch_to(): */
81 ebp = *(unsigned long *) task->thread.esp;
82 }
83
84 while (1) {
85 struct thread_info *context = (struct thread_info *)
86 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
87
88 ebp = save_context_stack(trace, skip, context, stack, ebp);
89 stack = (unsigned long *)context->previous_esp;
90 if (!all_contexts || !stack ||
91 trace->nr_entries >= trace->max_entries)
92 break;
93 trace->entries[trace->nr_entries++] = ULONG_MAX;
94 if (trace->nr_entries >= trace->max_entries)
95 break;
96 }
97}
98
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index dd63d4775398..7e639f78b0b9 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -317,3 +317,4 @@ ENTRY(sys_call_table)
317 .long sys_tee /* 315 */ 317 .long sys_tee /* 315 */
318 .long sys_vmsplice 318 .long sys_vmsplice
319 .long sys_move_pages 319 .long sys_move_pages
320 .long sys_getcpu
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 1302e4ab3c4f..86944acfb647 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -130,18 +130,33 @@ static int set_rtc_mmss(unsigned long nowtime)
130 130
131int timer_ack; 131int timer_ack;
132 132
133#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER)
134unsigned long profile_pc(struct pt_regs *regs) 133unsigned long profile_pc(struct pt_regs *regs)
135{ 134{
136 unsigned long pc = instruction_pointer(regs); 135 unsigned long pc = instruction_pointer(regs);
137 136
138 if (!user_mode_vm(regs) && in_lock_functions(pc)) 137#ifdef CONFIG_SMP
138 if (!user_mode_vm(regs) && in_lock_functions(pc)) {
139#ifdef CONFIG_FRAME_POINTER
139 return *(unsigned long *)(regs->ebp + 4); 140 return *(unsigned long *)(regs->ebp + 4);
140 141#else
142 unsigned long *sp;
143 if ((regs->xcs & 3) == 0)
144 sp = (unsigned long *)&regs->esp;
145 else
146 sp = (unsigned long *)regs->esp;
147 /* Return address is either directly at stack pointer
148 or above a saved eflags. Eflags has bits 22-31 zero,
149 kernel addresses don't. */
150 if (sp[0] >> 22)
151 return sp[0];
152 if (sp[1] >> 22)
153 return sp[1];
154#endif
155 }
156#endif
141 return pc; 157 return pc;
142} 158}
143EXPORT_SYMBOL(profile_pc); 159EXPORT_SYMBOL(profile_pc);
144#endif
145 160
146/* 161/*
147 * This is the same as the above, except we _also_ save the current 162 * This is the same as the above, except we _also_ save the current
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index e2e281d4bcc8..07d6da36a825 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/smp.h> 29#include <linux/smp.h>
30#include <linux/nodemask.h> 30#include <linux/nodemask.h>
31#include <linux/mmzone.h>
31#include <asm/cpu.h> 32#include <asm/cpu.h>
32 33
33static struct i386_cpu cpu_devices[NR_CPUS]; 34static struct i386_cpu cpu_devices[NR_CPUS];
@@ -55,34 +56,18 @@ EXPORT_SYMBOL(arch_register_cpu);
55EXPORT_SYMBOL(arch_unregister_cpu); 56EXPORT_SYMBOL(arch_unregister_cpu);
56#endif /*CONFIG_HOTPLUG_CPU*/ 57#endif /*CONFIG_HOTPLUG_CPU*/
57 58
58
59
60#ifdef CONFIG_NUMA
61#include <linux/mmzone.h>
62
63static int __init topology_init(void) 59static int __init topology_init(void)
64{ 60{
65 int i; 61 int i;
66 62
63#ifdef CONFIG_NUMA
67 for_each_online_node(i) 64 for_each_online_node(i)
68 register_one_node(i); 65 register_one_node(i);
66#endif /* CONFIG_NUMA */
69 67
70 for_each_present_cpu(i) 68 for_each_present_cpu(i)
71 arch_register_cpu(i); 69 arch_register_cpu(i);
72 return 0; 70 return 0;
73} 71}
74 72
75#else /* !CONFIG_NUMA */
76
77static int __init topology_init(void)
78{
79 int i;
80
81 for_each_present_cpu(i)
82 arch_register_cpu(i);
83 return 0;
84}
85
86#endif /* CONFIG_NUMA */
87
88subsys_initcall(topology_init); 73subsys_initcall(topology_init);
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 4fcc6690be99..a13037fe0ee3 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -28,6 +28,7 @@
28#include <linux/kprobes.h> 28#include <linux/kprobes.h>
29#include <linux/kexec.h> 29#include <linux/kexec.h>
30#include <linux/unwind.h> 30#include <linux/unwind.h>
31#include <linux/uaccess.h>
31 32
32#ifdef CONFIG_EISA 33#ifdef CONFIG_EISA
33#include <linux/ioport.h> 34#include <linux/ioport.h>
@@ -40,7 +41,6 @@
40 41
41#include <asm/processor.h> 42#include <asm/processor.h>
42#include <asm/system.h> 43#include <asm/system.h>
43#include <asm/uaccess.h>
44#include <asm/io.h> 44#include <asm/io.h>
45#include <asm/atomic.h> 45#include <asm/atomic.h>
46#include <asm/debugreg.h> 46#include <asm/debugreg.h>
@@ -51,6 +51,7 @@
51#include <asm/smp.h> 51#include <asm/smp.h>
52#include <asm/arch_hooks.h> 52#include <asm/arch_hooks.h>
53#include <asm/kdebug.h> 53#include <asm/kdebug.h>
54#include <asm/stacktrace.h>
54 55
55#include <linux/module.h> 56#include <linux/module.h>
56 57
@@ -118,26 +119,16 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
118 p < (void *)tinfo + THREAD_SIZE - 3; 119 p < (void *)tinfo + THREAD_SIZE - 3;
119} 120}
120 121
121/*
122 * Print one address/symbol entries per line.
123 */
124static inline void print_addr_and_symbol(unsigned long addr, char *log_lvl)
125{
126 printk(" [<%08lx>] ", addr);
127
128 print_symbol("%s\n", addr);
129}
130
131static inline unsigned long print_context_stack(struct thread_info *tinfo, 122static inline unsigned long print_context_stack(struct thread_info *tinfo,
132 unsigned long *stack, unsigned long ebp, 123 unsigned long *stack, unsigned long ebp,
133 char *log_lvl) 124 struct stacktrace_ops *ops, void *data)
134{ 125{
135 unsigned long addr; 126 unsigned long addr;
136 127
137#ifdef CONFIG_FRAME_POINTER 128#ifdef CONFIG_FRAME_POINTER
138 while (valid_stack_ptr(tinfo, (void *)ebp)) { 129 while (valid_stack_ptr(tinfo, (void *)ebp)) {
139 addr = *(unsigned long *)(ebp + 4); 130 addr = *(unsigned long *)(ebp + 4);
140 print_addr_and_symbol(addr, log_lvl); 131 ops->address(data, addr);
141 /* 132 /*
142 * break out of recursive entries (such as 133 * break out of recursive entries (such as
143 * end_of_stack_stop_unwind_function): 134 * end_of_stack_stop_unwind_function):
@@ -150,30 +141,37 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
150 while (valid_stack_ptr(tinfo, stack)) { 141 while (valid_stack_ptr(tinfo, stack)) {
151 addr = *stack++; 142 addr = *stack++;
152 if (__kernel_text_address(addr)) 143 if (__kernel_text_address(addr))
153 print_addr_and_symbol(addr, log_lvl); 144 ops->address(data, addr);
154 } 145 }
155#endif 146#endif
156 return ebp; 147 return ebp;
157} 148}
158 149
150struct ops_and_data {
151 struct stacktrace_ops *ops;
152 void *data;
153};
154
159static asmlinkage int 155static asmlinkage int
160show_trace_unwind(struct unwind_frame_info *info, void *log_lvl) 156dump_trace_unwind(struct unwind_frame_info *info, void *data)
161{ 157{
158 struct ops_and_data *oad = (struct ops_and_data *)data;
162 int n = 0; 159 int n = 0;
163 160
164 while (unwind(info) == 0 && UNW_PC(info)) { 161 while (unwind(info) == 0 && UNW_PC(info)) {
165 n++; 162 n++;
166 print_addr_and_symbol(UNW_PC(info), log_lvl); 163 oad->ops->address(oad->data, UNW_PC(info));
167 if (arch_unw_user_mode(info)) 164 if (arch_unw_user_mode(info))
168 break; 165 break;
169 } 166 }
170 return n; 167 return n;
171} 168}
172 169
173static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs, 170void dump_trace(struct task_struct *task, struct pt_regs *regs,
174 unsigned long *stack, char *log_lvl) 171 unsigned long *stack,
172 struct stacktrace_ops *ops, void *data)
175{ 173{
176 unsigned long ebp; 174 unsigned long ebp = 0;
177 175
178 if (!task) 176 if (!task)
179 task = current; 177 task = current;
@@ -181,54 +179,116 @@ static void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
181 if (call_trace >= 0) { 179 if (call_trace >= 0) {
182 int unw_ret = 0; 180 int unw_ret = 0;
183 struct unwind_frame_info info; 181 struct unwind_frame_info info;
182 struct ops_and_data oad = { .ops = ops, .data = data };
184 183
185 if (regs) { 184 if (regs) {
186 if (unwind_init_frame_info(&info, task, regs) == 0) 185 if (unwind_init_frame_info(&info, task, regs) == 0)
187 unw_ret = show_trace_unwind(&info, log_lvl); 186 unw_ret = dump_trace_unwind(&info, &oad);
188 } else if (task == current) 187 } else if (task == current)
189 unw_ret = unwind_init_running(&info, show_trace_unwind, log_lvl); 188 unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad);
190 else { 189 else {
191 if (unwind_init_blocked(&info, task) == 0) 190 if (unwind_init_blocked(&info, task) == 0)
192 unw_ret = show_trace_unwind(&info, log_lvl); 191 unw_ret = dump_trace_unwind(&info, &oad);
193 } 192 }
194 if (unw_ret > 0) { 193 if (unw_ret > 0) {
195 if (call_trace == 1 && !arch_unw_user_mode(&info)) { 194 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
196 print_symbol("DWARF2 unwinder stuck at %s\n", 195 ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n",
197 UNW_PC(&info)); 196 UNW_PC(&info));
198 if (UNW_SP(&info) >= PAGE_OFFSET) { 197 if (UNW_SP(&info) >= PAGE_OFFSET) {
199 printk("Leftover inexact backtrace:\n"); 198 ops->warning(data, "Leftover inexact backtrace:\n");
200 stack = (void *)UNW_SP(&info); 199 stack = (void *)UNW_SP(&info);
200 if (!stack)
201 return;
202 ebp = UNW_FP(&info);
201 } else 203 } else
202 printk("Full inexact backtrace again:\n"); 204 ops->warning(data, "Full inexact backtrace again:\n");
203 } else if (call_trace >= 1) 205 } else if (call_trace >= 1)
204 return; 206 return;
205 else 207 else
206 printk("Full inexact backtrace again:\n"); 208 ops->warning(data, "Full inexact backtrace again:\n");
207 } else 209 } else
208 printk("Inexact backtrace:\n"); 210 ops->warning(data, "Inexact backtrace:\n");
211 }
212 if (!stack) {
213 unsigned long dummy;
214 stack = &dummy;
215 if (task && task != current)
216 stack = (unsigned long *)task->thread.esp;
209 } 217 }
210 218
211 if (task == current) { 219#ifdef CONFIG_FRAME_POINTER
212 /* Grab ebp right from our regs */ 220 if (!ebp) {
213 asm ("movl %%ebp, %0" : "=r" (ebp) : ); 221 if (task == current) {
214 } else { 222 /* Grab ebp right from our regs */
215 /* ebp is the last reg pushed by switch_to */ 223 asm ("movl %%ebp, %0" : "=r" (ebp) : );
216 ebp = *(unsigned long *) task->thread.esp; 224 } else {
225 /* ebp is the last reg pushed by switch_to */
226 ebp = *(unsigned long *) task->thread.esp;
227 }
217 } 228 }
229#endif
218 230
219 while (1) { 231 while (1) {
220 struct thread_info *context; 232 struct thread_info *context;
221 context = (struct thread_info *) 233 context = (struct thread_info *)
222 ((unsigned long)stack & (~(THREAD_SIZE - 1))); 234 ((unsigned long)stack & (~(THREAD_SIZE - 1)));
223 ebp = print_context_stack(context, stack, ebp, log_lvl); 235 ebp = print_context_stack(context, stack, ebp, ops, data);
236 /* Should be after the line below, but somewhere
237 in early boot context comes out corrupted and we
238 can't reference it -AK */
239 if (ops->stack(data, "IRQ") < 0)
240 break;
224 stack = (unsigned long*)context->previous_esp; 241 stack = (unsigned long*)context->previous_esp;
225 if (!stack) 242 if (!stack)
226 break; 243 break;
227 printk("%s =======================\n", log_lvl);
228 } 244 }
229} 245}
246EXPORT_SYMBOL(dump_trace);
247
248static void
249print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
250{
251 printk(data);
252 print_symbol(msg, symbol);
253 printk("\n");
254}
255
256static void print_trace_warning(void *data, char *msg)
257{
258 printk("%s%s\n", (char *)data, msg);
259}
260
261static int print_trace_stack(void *data, char *name)
262{
263 return 0;
264}
265
266/*
267 * Print one address/symbol entries per line.
268 */
269static void print_trace_address(void *data, unsigned long addr)
270{
271 printk("%s [<%08lx>] ", (char *)data, addr);
272 print_symbol("%s\n", addr);
273}
274
275static struct stacktrace_ops print_trace_ops = {
276 .warning = print_trace_warning,
277 .warning_symbol = print_trace_warning_symbol,
278 .stack = print_trace_stack,
279 .address = print_trace_address,
280};
281
282static void
283show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
284 unsigned long * stack, char *log_lvl)
285{
286 dump_trace(task, regs, stack, &print_trace_ops, log_lvl);
287 printk("%s =======================\n", log_lvl);
288}
230 289
231void show_trace(struct task_struct *task, struct pt_regs *regs, unsigned long * stack) 290void show_trace(struct task_struct *task, struct pt_regs *regs,
291 unsigned long * stack)
232{ 292{
233 show_trace_log_lvl(task, regs, stack, ""); 293 show_trace_log_lvl(task, regs, stack, "");
234} 294}
@@ -291,8 +351,9 @@ void show_registers(struct pt_regs *regs)
291 ss = regs->xss & 0xffff; 351 ss = regs->xss & 0xffff;
292 } 352 }
293 print_modules(); 353 print_modules();
294 printk(KERN_EMERG "CPU: %d\nEIP: %04x:[<%08lx>] %s VLI\n" 354 printk(KERN_EMERG "CPU: %d\n"
295 "EFLAGS: %08lx (%s %.*s) \n", 355 KERN_EMERG "EIP: %04x:[<%08lx>] %s VLI\n"
356 KERN_EMERG "EFLAGS: %08lx (%s %.*s)\n",
296 smp_processor_id(), 0xffff & regs->xcs, regs->eip, 357 smp_processor_id(), 0xffff & regs->xcs, regs->eip,
297 print_tainted(), regs->eflags, system_utsname.release, 358 print_tainted(), regs->eflags, system_utsname.release,
298 (int)strcspn(system_utsname.version, " "), 359 (int)strcspn(system_utsname.version, " "),
@@ -348,7 +409,7 @@ static void handle_BUG(struct pt_regs *regs)
348 409
349 if (eip < PAGE_OFFSET) 410 if (eip < PAGE_OFFSET)
350 return; 411 return;
351 if (__get_user(ud2, (unsigned short __user *)eip)) 412 if (probe_kernel_address((unsigned short __user *)eip, ud2))
352 return; 413 return;
353 if (ud2 != 0x0b0f) 414 if (ud2 != 0x0b0f)
354 return; 415 return;
@@ -361,7 +422,8 @@ static void handle_BUG(struct pt_regs *regs)
361 char *file; 422 char *file;
362 char c; 423 char c;
363 424
364 if (__get_user(line, (unsigned short __user *)(eip + 2))) 425 if (probe_kernel_address((unsigned short __user *)(eip + 2),
426 line))
365 break; 427 break;
366 if (__get_user(file, (char * __user *)(eip + 4)) || 428 if (__get_user(file, (char * __user *)(eip + 4)) ||
367 (unsigned long)file < PAGE_OFFSET || __get_user(c, file)) 429 (unsigned long)file < PAGE_OFFSET || __get_user(c, file))
@@ -634,18 +696,24 @@ gp_in_kernel:
634 } 696 }
635} 697}
636 698
637static void mem_parity_error(unsigned char reason, struct pt_regs * regs) 699static __kprobes void
700mem_parity_error(unsigned char reason, struct pt_regs * regs)
638{ 701{
639 printk(KERN_EMERG "Uhhuh. NMI received. Dazed and confused, but trying " 702 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
640 "to continue\n"); 703 "CPU %d.\n", reason, smp_processor_id());
641 printk(KERN_EMERG "You probably have a hardware problem with your RAM " 704 printk(KERN_EMERG "You probably have a hardware problem with your RAM "
642 "chips\n"); 705 "chips\n");
706 if (panic_on_unrecovered_nmi)
707 panic("NMI: Not continuing");
708
709 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
643 710
644 /* Clear and disable the memory parity error line. */ 711 /* Clear and disable the memory parity error line. */
645 clear_mem_error(reason); 712 clear_mem_error(reason);
646} 713}
647 714
648static void io_check_error(unsigned char reason, struct pt_regs * regs) 715static __kprobes void
716io_check_error(unsigned char reason, struct pt_regs * regs)
649{ 717{
650 unsigned long i; 718 unsigned long i;
651 719
@@ -661,7 +729,8 @@ static void io_check_error(unsigned char reason, struct pt_regs * regs)
661 outb(reason, 0x61); 729 outb(reason, 0x61);
662} 730}
663 731
664static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs) 732static __kprobes void
733unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
665{ 734{
666#ifdef CONFIG_MCA 735#ifdef CONFIG_MCA
667 /* Might actually be able to figure out what the guilty party 736 /* Might actually be able to figure out what the guilty party
@@ -671,15 +740,18 @@ static void unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
671 return; 740 return;
672 } 741 }
673#endif 742#endif
674 printk("Uhhuh. NMI received for unknown reason %02x on CPU %d.\n", 743 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x on "
675 reason, smp_processor_id()); 744 "CPU %d.\n", reason, smp_processor_id());
676 printk("Dazed and confused, but trying to continue\n"); 745 printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
677 printk("Do you have a strange power saving mode enabled?\n"); 746 if (panic_on_unrecovered_nmi)
747 panic("NMI: Not continuing");
748
749 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
678} 750}
679 751
680static DEFINE_SPINLOCK(nmi_print_lock); 752static DEFINE_SPINLOCK(nmi_print_lock);
681 753
682void die_nmi (struct pt_regs *regs, const char *msg) 754void __kprobes die_nmi(struct pt_regs *regs, const char *msg)
683{ 755{
684 if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 2, SIGINT) == 756 if (notify_die(DIE_NMIWATCHDOG, msg, regs, 0, 2, SIGINT) ==
685 NOTIFY_STOP) 757 NOTIFY_STOP)
@@ -711,7 +783,7 @@ void die_nmi (struct pt_regs *regs, const char *msg)
711 do_exit(SIGSEGV); 783 do_exit(SIGSEGV);
712} 784}
713 785
714static void default_do_nmi(struct pt_regs * regs) 786static __kprobes void default_do_nmi(struct pt_regs * regs)
715{ 787{
716 unsigned char reason = 0; 788 unsigned char reason = 0;
717 789
@@ -728,12 +800,12 @@ static void default_do_nmi(struct pt_regs * regs)
728 * Ok, so this is none of the documented NMI sources, 800 * Ok, so this is none of the documented NMI sources,
729 * so it must be the NMI watchdog. 801 * so it must be the NMI watchdog.
730 */ 802 */
731 if (nmi_watchdog) { 803 if (nmi_watchdog_tick(regs, reason))
732 nmi_watchdog_tick(regs);
733 return; 804 return;
734 } 805 if (!do_nmi_callback(regs, smp_processor_id()))
735#endif 806#endif
736 unknown_nmi_error(reason, regs); 807 unknown_nmi_error(reason, regs);
808
737 return; 809 return;
738 } 810 }
739 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP) 811 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
@@ -749,14 +821,7 @@ static void default_do_nmi(struct pt_regs * regs)
749 reassert_nmi(); 821 reassert_nmi();
750} 822}
751 823
752static int dummy_nmi_callback(struct pt_regs * regs, int cpu) 824fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
753{
754 return 0;
755}
756
757static nmi_callback_t nmi_callback = dummy_nmi_callback;
758
759fastcall void do_nmi(struct pt_regs * regs, long error_code)
760{ 825{
761 int cpu; 826 int cpu;
762 827
@@ -766,25 +831,11 @@ fastcall void do_nmi(struct pt_regs * regs, long error_code)
766 831
767 ++nmi_count(cpu); 832 ++nmi_count(cpu);
768 833
769 if (!rcu_dereference(nmi_callback)(regs, cpu)) 834 default_do_nmi(regs);
770 default_do_nmi(regs);
771 835
772 nmi_exit(); 836 nmi_exit();
773} 837}
774 838
775void set_nmi_callback(nmi_callback_t callback)
776{
777 vmalloc_sync_all();
778 rcu_assign_pointer(nmi_callback, callback);
779}
780EXPORT_SYMBOL_GPL(set_nmi_callback);
781
782void unset_nmi_callback(void)
783{
784 nmi_callback = dummy_nmi_callback;
785}
786EXPORT_SYMBOL_GPL(unset_nmi_callback);
787
788#ifdef CONFIG_KPROBES 839#ifdef CONFIG_KPROBES
789fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code) 840fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
790{ 841{
@@ -1124,20 +1175,6 @@ void __init trap_init_f00f_bug(void)
1124} 1175}
1125#endif 1176#endif
1126 1177
1127#define _set_gate(gate_addr,type,dpl,addr,seg) \
1128do { \
1129 int __d0, __d1; \
1130 __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
1131 "movw %4,%%dx\n\t" \
1132 "movl %%eax,%0\n\t" \
1133 "movl %%edx,%1" \
1134 :"=m" (*((long *) (gate_addr))), \
1135 "=m" (*(1+(long *) (gate_addr))), "=&a" (__d0), "=&d" (__d1) \
1136 :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
1137 "3" ((char *) (addr)),"2" ((seg) << 16)); \
1138} while (0)
1139
1140
1141/* 1178/*
1142 * This needs to use 'idt_table' rather than 'idt', and 1179 * This needs to use 'idt_table' rather than 'idt', and
1143 * thus use the _nonmapped_ version of the IDT, as the 1180 * thus use the _nonmapped_ version of the IDT, as the
@@ -1146,7 +1183,7 @@ do { \
1146 */ 1183 */
1147void set_intr_gate(unsigned int n, void *addr) 1184void set_intr_gate(unsigned int n, void *addr)
1148{ 1185{
1149 _set_gate(idt_table+n,14,0,addr,__KERNEL_CS); 1186 _set_gate(n, DESCTYPE_INT, addr, __KERNEL_CS);
1150} 1187}
1151 1188
1152/* 1189/*
@@ -1154,22 +1191,22 @@ void set_intr_gate(unsigned int n, void *addr)
1154 */ 1191 */
1155static inline void set_system_intr_gate(unsigned int n, void *addr) 1192static inline void set_system_intr_gate(unsigned int n, void *addr)
1156{ 1193{
1157 _set_gate(idt_table+n, 14, 3, addr, __KERNEL_CS); 1194 _set_gate(n, DESCTYPE_INT | DESCTYPE_DPL3, addr, __KERNEL_CS);
1158} 1195}
1159 1196
1160static void __init set_trap_gate(unsigned int n, void *addr) 1197static void __init set_trap_gate(unsigned int n, void *addr)
1161{ 1198{
1162 _set_gate(idt_table+n,15,0,addr,__KERNEL_CS); 1199 _set_gate(n, DESCTYPE_TRAP, addr, __KERNEL_CS);
1163} 1200}
1164 1201
1165static void __init set_system_gate(unsigned int n, void *addr) 1202static void __init set_system_gate(unsigned int n, void *addr)
1166{ 1203{
1167 _set_gate(idt_table+n,15,3,addr,__KERNEL_CS); 1204 _set_gate(n, DESCTYPE_TRAP | DESCTYPE_DPL3, addr, __KERNEL_CS);
1168} 1205}
1169 1206
1170static void __init set_task_gate(unsigned int n, unsigned int gdt_entry) 1207static void __init set_task_gate(unsigned int n, unsigned int gdt_entry)
1171{ 1208{
1172 _set_gate(idt_table+n,5,0,0,(gdt_entry<<3)); 1209 _set_gate(n, DESCTYPE_TASK, (void *)0, (gdt_entry<<3));
1173} 1210}
1174 1211
1175 1212
diff --git a/arch/i386/kernel/tsc.c b/arch/i386/kernel/tsc.c
index 7e0d8dab2075..b8fa0a8b2e47 100644
--- a/arch/i386/kernel/tsc.c
+++ b/arch/i386/kernel/tsc.c
@@ -192,7 +192,7 @@ int recalibrate_cpu_khz(void)
192 192
193EXPORT_SYMBOL(recalibrate_cpu_khz); 193EXPORT_SYMBOL(recalibrate_cpu_khz);
194 194
195void tsc_init(void) 195void __init tsc_init(void)
196{ 196{
197 if (!cpu_has_tsc || tsc_disable) 197 if (!cpu_has_tsc || tsc_disable)
198 return; 198 return;
diff --git a/arch/i386/lib/Makefile b/arch/i386/lib/Makefile
index 914933e9ec3d..d86a548b8d54 100644
--- a/arch/i386/lib/Makefile
+++ b/arch/i386/lib/Makefile
@@ -4,6 +4,6 @@
4 4
5 5
6lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \ 6lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \
7 bitops.o 7 bitops.o semaphore.o
8 8
9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o 9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
diff --git a/arch/i386/lib/semaphore.S b/arch/i386/lib/semaphore.S
new file mode 100644
index 000000000000..01f80b5c45d2
--- /dev/null
+++ b/arch/i386/lib/semaphore.S
@@ -0,0 +1,217 @@
1/*
2 * i386 semaphore implementation.
3 *
4 * (C) Copyright 1999 Linus Torvalds
5 *
6 * Portions Copyright 1999 Red Hat, Inc.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 *
13 * rw semaphores implemented November 1999 by Benjamin LaHaise <bcrl@kvack.org>
14 */
15
16#include <linux/config.h>
17#include <linux/linkage.h>
18#include <asm/rwlock.h>
19#include <asm/alternative-asm.i>
20#include <asm/frame.i>
21#include <asm/dwarf2.h>
22
23/*
24 * The semaphore operations have a special calling sequence that
25 * allow us to do a simpler in-line version of them. These routines
26 * need to convert that sequence back into the C sequence when
27 * there is contention on the semaphore.
28 *
29 * %eax contains the semaphore pointer on entry. Save the C-clobbered
30 * registers (%eax, %edx and %ecx) except %eax whish is either a return
31 * value or just clobbered..
32 */
33 .section .sched.text
34ENTRY(__down_failed)
35 CFI_STARTPROC
36 FRAME
37 pushl %edx
38 CFI_ADJUST_CFA_OFFSET 4
39 CFI_REL_OFFSET edx,0
40 pushl %ecx
41 CFI_ADJUST_CFA_OFFSET 4
42 CFI_REL_OFFSET ecx,0
43 call __down
44 popl %ecx
45 CFI_ADJUST_CFA_OFFSET -4
46 CFI_RESTORE ecx
47 popl %edx
48 CFI_ADJUST_CFA_OFFSET -4
49 CFI_RESTORE edx
50 ENDFRAME
51 ret
52 CFI_ENDPROC
53 END(__down_failed)
54
55ENTRY(__down_failed_interruptible)
56 CFI_STARTPROC
57 FRAME
58 pushl %edx
59 CFI_ADJUST_CFA_OFFSET 4
60 CFI_REL_OFFSET edx,0
61 pushl %ecx
62 CFI_ADJUST_CFA_OFFSET 4
63 CFI_REL_OFFSET ecx,0
64 call __down_interruptible
65 popl %ecx
66 CFI_ADJUST_CFA_OFFSET -4
67 CFI_RESTORE ecx
68 popl %edx
69 CFI_ADJUST_CFA_OFFSET -4
70 CFI_RESTORE edx
71 ENDFRAME
72 ret
73 CFI_ENDPROC
74 END(__down_failed_interruptible)
75
76ENTRY(__down_failed_trylock)
77 CFI_STARTPROC
78 FRAME
79 pushl %edx
80 CFI_ADJUST_CFA_OFFSET 4
81 CFI_REL_OFFSET edx,0
82 pushl %ecx
83 CFI_ADJUST_CFA_OFFSET 4
84 CFI_REL_OFFSET ecx,0
85 call __down_trylock
86 popl %ecx
87 CFI_ADJUST_CFA_OFFSET -4
88 CFI_RESTORE ecx
89 popl %edx
90 CFI_ADJUST_CFA_OFFSET -4
91 CFI_RESTORE edx
92 ENDFRAME
93 ret
94 CFI_ENDPROC
95 END(__down_failed_trylock)
96
97ENTRY(__up_wakeup)
98 CFI_STARTPROC
99 FRAME
100 pushl %edx
101 CFI_ADJUST_CFA_OFFSET 4
102 CFI_REL_OFFSET edx,0
103 pushl %ecx
104 CFI_ADJUST_CFA_OFFSET 4
105 CFI_REL_OFFSET ecx,0
106 call __up
107 popl %ecx
108 CFI_ADJUST_CFA_OFFSET -4
109 CFI_RESTORE ecx
110 popl %edx
111 CFI_ADJUST_CFA_OFFSET -4
112 CFI_RESTORE edx
113 ENDFRAME
114 ret
115 CFI_ENDPROC
116 END(__up_wakeup)
117
118/*
119 * rw spinlock fallbacks
120 */
121#ifdef CONFIG_SMP
122ENTRY(__write_lock_failed)
123 CFI_STARTPROC simple
124 FRAME
1252: LOCK_PREFIX
126 addl $ RW_LOCK_BIAS,(%eax)
1271: rep; nop
128 cmpl $ RW_LOCK_BIAS,(%eax)
129 jne 1b
130 LOCK_PREFIX
131 subl $ RW_LOCK_BIAS,(%eax)
132 jnz 2b
133 ENDFRAME
134 ret
135 CFI_ENDPROC
136 END(__write_lock_failed)
137
138ENTRY(__read_lock_failed)
139 CFI_STARTPROC
140 FRAME
1412: LOCK_PREFIX
142 incl (%eax)
1431: rep; nop
144 cmpl $1,(%eax)
145 js 1b
146 LOCK_PREFIX
147 decl (%eax)
148 js 2b
149 ENDFRAME
150 ret
151 CFI_ENDPROC
152 END(__read_lock_failed)
153
154#endif
155
156/* Fix up special calling conventions */
157ENTRY(call_rwsem_down_read_failed)
158 CFI_STARTPROC
159 push %ecx
160 CFI_ADJUST_CFA_OFFSET 4
161 CFI_REL_OFFSET ecx,0
162 push %edx
163 CFI_ADJUST_CFA_OFFSET 4
164 CFI_REL_OFFSET edx,0
165 call rwsem_down_read_failed
166 pop %edx
167 CFI_ADJUST_CFA_OFFSET -4
168 pop %ecx
169 CFI_ADJUST_CFA_OFFSET -4
170 ret
171 CFI_ENDPROC
172 END(call_rwsem_down_read_failed)
173
174ENTRY(call_rwsem_down_write_failed)
175 CFI_STARTPROC
176 push %ecx
177 CFI_ADJUST_CFA_OFFSET 4
178 CFI_REL_OFFSET ecx,0
179 calll rwsem_down_write_failed
180 pop %ecx
181 CFI_ADJUST_CFA_OFFSET -4
182 ret
183 CFI_ENDPROC
184 END(call_rwsem_down_write_failed)
185
186ENTRY(call_rwsem_wake)
187 CFI_STARTPROC
188 decw %dx /* do nothing if still outstanding active readers */
189 jnz 1f
190 push %ecx
191 CFI_ADJUST_CFA_OFFSET 4
192 CFI_REL_OFFSET ecx,0
193 call rwsem_wake
194 pop %ecx
195 CFI_ADJUST_CFA_OFFSET -4
1961: ret
197 CFI_ENDPROC
198 END(call_rwsem_wake)
199
200/* Fix up special calling conventions */
201ENTRY(call_rwsem_downgrade_wake)
202 CFI_STARTPROC
203 push %ecx
204 CFI_ADJUST_CFA_OFFSET 4
205 CFI_REL_OFFSET ecx,0
206 push %edx
207 CFI_ADJUST_CFA_OFFSET 4
208 CFI_REL_OFFSET edx,0
209 call rwsem_downgrade_wake
210 pop %edx
211 CFI_ADJUST_CFA_OFFSET -4
212 pop %ecx
213 CFI_ADJUST_CFA_OFFSET -4
214 ret
215 CFI_ENDPROC
216 END(call_rwsem_downgrade_wake)
217
diff --git a/arch/i386/mach-generic/bigsmp.c b/arch/i386/mach-generic/bigsmp.c
index ef7a6e6fcb9f..33d9f93557ba 100644
--- a/arch/i386/mach-generic/bigsmp.c
+++ b/arch/i386/mach-generic/bigsmp.c
@@ -5,6 +5,7 @@
5#define APIC_DEFINITION 1 5#define APIC_DEFINITION 1
6#include <linux/threads.h> 6#include <linux/threads.h>
7#include <linux/cpumask.h> 7#include <linux/cpumask.h>
8#include <asm/smp.h>
8#include <asm/mpspec.h> 9#include <asm/mpspec.h>
9#include <asm/genapic.h> 10#include <asm/genapic.h>
10#include <asm/fixmap.h> 11#include <asm/fixmap.h>
diff --git a/arch/i386/mach-generic/es7000.c b/arch/i386/mach-generic/es7000.c
index 845cdd0b3593..aa144d82334d 100644
--- a/arch/i386/mach-generic/es7000.c
+++ b/arch/i386/mach-generic/es7000.c
@@ -4,6 +4,7 @@
4#define APIC_DEFINITION 1 4#define APIC_DEFINITION 1
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/cpumask.h> 6#include <linux/cpumask.h>
7#include <asm/smp.h>
7#include <asm/mpspec.h> 8#include <asm/mpspec.h>
8#include <asm/genapic.h> 9#include <asm/genapic.h>
9#include <asm/fixmap.h> 10#include <asm/fixmap.h>
diff --git a/arch/i386/mach-generic/probe.c b/arch/i386/mach-generic/probe.c
index bcd1bcfaa723..94b1fd9cbe3c 100644
--- a/arch/i386/mach-generic/probe.c
+++ b/arch/i386/mach-generic/probe.c
@@ -9,6 +9,7 @@
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/ctype.h> 10#include <linux/ctype.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/errno.h>
12#include <asm/fixmap.h> 13#include <asm/fixmap.h>
13#include <asm/mpspec.h> 14#include <asm/mpspec.h>
14#include <asm/apicdef.h> 15#include <asm/apicdef.h>
@@ -29,7 +30,24 @@ struct genapic *apic_probe[] __initdata = {
29 NULL, 30 NULL,
30}; 31};
31 32
32static int cmdline_apic; 33static int cmdline_apic __initdata;
34static int __init parse_apic(char *arg)
35{
36 int i;
37
38 if (!arg)
39 return -EINVAL;
40
41 for (i = 0; apic_probe[i]; i++) {
42 if (!strcmp(apic_probe[i]->name, arg)) {
43 genapic = apic_probe[i];
44 cmdline_apic = 1;
45 return 0;
46 }
47 }
48 return -ENOENT;
49}
50early_param("apic", parse_apic);
33 51
34void __init generic_bigsmp_probe(void) 52void __init generic_bigsmp_probe(void)
35{ 53{
@@ -48,40 +66,20 @@ void __init generic_bigsmp_probe(void)
48 } 66 }
49} 67}
50 68
51void __init generic_apic_probe(char *command_line) 69void __init generic_apic_probe(void)
52{ 70{
53 char *s; 71 if (!cmdline_apic) {
54 int i; 72 int i;
55 int changed = 0; 73 for (i = 0; apic_probe[i]; i++) {
56 74 if (apic_probe[i]->probe()) {
57 s = strstr(command_line, "apic=");
58 if (s && (s == command_line || isspace(s[-1]))) {
59 char *p = strchr(s, ' '), old;
60 if (!p)
61 p = strchr(s, '\0');
62 old = *p;
63 *p = 0;
64 for (i = 0; !changed && apic_probe[i]; i++) {
65 if (!strcmp(apic_probe[i]->name, s+5)) {
66 changed = 1;
67 genapic = apic_probe[i]; 75 genapic = apic_probe[i];
76 break;
68 } 77 }
69 } 78 }
70 if (!changed) 79 /* Not visible without early console */
71 printk(KERN_ERR "Unknown genapic `%s' specified.\n", s); 80 if (!apic_probe[i])
72 *p = old; 81 panic("Didn't find an APIC driver");
73 cmdline_apic = changed;
74 }
75 for (i = 0; !changed && apic_probe[i]; i++) {
76 if (apic_probe[i]->probe()) {
77 changed = 1;
78 genapic = apic_probe[i];
79 }
80 } 82 }
81 /* Not visible without early console */
82 if (!changed)
83 panic("Didn't find an APIC driver");
84
85 printk(KERN_INFO "Using APIC driver %s\n", genapic->name); 83 printk(KERN_INFO "Using APIC driver %s\n", genapic->name);
86} 84}
87 85
@@ -119,7 +117,9 @@ int __init acpi_madt_oem_check(char *oem_id, char *oem_table_id)
119 return 0; 117 return 0;
120} 118}
121 119
120#ifdef CONFIG_SMP
122int hard_smp_processor_id(void) 121int hard_smp_processor_id(void)
123{ 122{
124 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID)); 123 return genapic->get_apic_id(*(unsigned long *)(APIC_BASE+APIC_ID));
125} 124}
125#endif
diff --git a/arch/i386/mach-generic/summit.c b/arch/i386/mach-generic/summit.c
index b73501ddd653..f7e5d66648dc 100644
--- a/arch/i386/mach-generic/summit.c
+++ b/arch/i386/mach-generic/summit.c
@@ -4,6 +4,7 @@
4#define APIC_DEFINITION 1 4#define APIC_DEFINITION 1
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/cpumask.h> 6#include <linux/cpumask.h>
7#include <asm/smp.h>
7#include <asm/mpspec.h> 8#include <asm/mpspec.h>
8#include <asm/genapic.h> 9#include <asm/genapic.h>
9#include <asm/fixmap.h> 10#include <asm/fixmap.h>
diff --git a/arch/i386/mm/discontig.c b/arch/i386/mm/discontig.c
index fb5d8b747de4..51e3739dd227 100644
--- a/arch/i386/mm/discontig.c
+++ b/arch/i386/mm/discontig.c
@@ -157,21 +157,6 @@ static void __init find_max_pfn_node(int nid)
157 BUG(); 157 BUG();
158} 158}
159 159
160/* Find the owning node for a pfn. */
161int early_pfn_to_nid(unsigned long pfn)
162{
163 int nid;
164
165 for_each_node(nid) {
166 if (node_end_pfn[nid] == 0)
167 break;
168 if (node_start_pfn[nid] <= pfn && node_end_pfn[nid] >= pfn)
169 return nid;
170 }
171
172 return 0;
173}
174
175/* 160/*
176 * Allocate memory for the pg_data_t for this node via a crude pre-bootmem 161 * Allocate memory for the pg_data_t for this node via a crude pre-bootmem
177 * method. For node zero take this from the bottom of memory, for 162 * method. For node zero take this from the bottom of memory, for
@@ -227,6 +212,8 @@ static unsigned long calculate_numa_remap_pages(void)
227 unsigned long pfn; 212 unsigned long pfn;
228 213
229 for_each_online_node(nid) { 214 for_each_online_node(nid) {
215 unsigned old_end_pfn = node_end_pfn[nid];
216
230 /* 217 /*
231 * The acpi/srat node info can show hot-add memroy zones 218 * The acpi/srat node info can show hot-add memroy zones
232 * where memory could be added but not currently present. 219 * where memory could be added but not currently present.
@@ -276,6 +263,7 @@ static unsigned long calculate_numa_remap_pages(void)
276 263
277 node_end_pfn[nid] -= size; 264 node_end_pfn[nid] -= size;
278 node_remap_start_pfn[nid] = node_end_pfn[nid]; 265 node_remap_start_pfn[nid] = node_end_pfn[nid];
266 shrink_active_range(nid, old_end_pfn, node_end_pfn[nid]);
279 } 267 }
280 printk("Reserving total of %ld pages for numa KVA remap\n", 268 printk("Reserving total of %ld pages for numa KVA remap\n",
281 reserve_pages); 269 reserve_pages);
@@ -322,6 +310,11 @@ unsigned long __init setup_memory(void)
322 highstart_pfn = system_max_low_pfn; 310 highstart_pfn = system_max_low_pfn;
323 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", 311 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
324 pages_to_mb(highend_pfn - highstart_pfn)); 312 pages_to_mb(highend_pfn - highstart_pfn));
313 num_physpages = highend_pfn;
314 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
315#else
316 num_physpages = system_max_low_pfn;
317 high_memory = (void *) __va(system_max_low_pfn * PAGE_SIZE - 1) + 1;
325#endif 318#endif
326 printk(KERN_NOTICE "%ldMB LOWMEM available.\n", 319 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
327 pages_to_mb(system_max_low_pfn)); 320 pages_to_mb(system_max_low_pfn));
@@ -364,45 +357,22 @@ void __init numa_kva_reserve(void)
364void __init zone_sizes_init(void) 357void __init zone_sizes_init(void)
365{ 358{
366 int nid; 359 int nid;
367 360 unsigned long max_zone_pfns[MAX_NR_ZONES] = {
368 361 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT,
369 for_each_online_node(nid) { 362 max_low_pfn,
370 unsigned long zones_size[MAX_NR_ZONES] = {0, }; 363 highend_pfn
371 unsigned long *zholes_size; 364 };
372 unsigned int max_dma; 365
373 366 /* If SRAT has not registered memory, register it now */
374 unsigned long low = max_low_pfn; 367 if (find_max_pfn_with_active_regions() == 0) {
375 unsigned long start = node_start_pfn[nid]; 368 for_each_online_node(nid) {
376 unsigned long high = node_end_pfn[nid]; 369 if (node_has_online_mem(nid))
377 370 add_active_range(nid, node_start_pfn[nid],
378 max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; 371 node_end_pfn[nid]);
379
380 if (node_has_online_mem(nid)){
381 if (start > low) {
382#ifdef CONFIG_HIGHMEM
383 BUG_ON(start > high);
384 zones_size[ZONE_HIGHMEM] = high - start;
385#endif
386 } else {
387 if (low < max_dma)
388 zones_size[ZONE_DMA] = low;
389 else {
390 BUG_ON(max_dma > low);
391 BUG_ON(low > high);
392 zones_size[ZONE_DMA] = max_dma;
393 zones_size[ZONE_NORMAL] = low - max_dma;
394#ifdef CONFIG_HIGHMEM
395 zones_size[ZONE_HIGHMEM] = high - low;
396#endif
397 }
398 }
399 } 372 }
400
401 zholes_size = get_zholes_size(nid);
402
403 free_area_init_node(nid, NODE_DATA(nid), zones_size, start,
404 zholes_size);
405 } 373 }
374
375 free_area_init_nodes(max_zone_pfns);
406 return; 376 return;
407} 377}
408 378
diff --git a/arch/i386/mm/extable.c b/arch/i386/mm/extable.c
index de03c5430abc..0ce4f22a2635 100644
--- a/arch/i386/mm/extable.c
+++ b/arch/i386/mm/extable.c
@@ -11,7 +11,7 @@ int fixup_exception(struct pt_regs *regs)
11 const struct exception_table_entry *fixup; 11 const struct exception_table_entry *fixup;
12 12
13#ifdef CONFIG_PNPBIOS 13#ifdef CONFIG_PNPBIOS
14 if (unlikely((regs->xcs & ~15) == (GDT_ENTRY_PNPBIOS_BASE << 3))) 14 if (unlikely(SEGMENT_IS_PNP_CODE(regs->xcs)))
15 { 15 {
16 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp; 16 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
17 extern u32 pnp_bios_is_utter_crap; 17 extern u32 pnp_bios_is_utter_crap;
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index f7279468323a..5e17a3f43b41 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -27,21 +27,24 @@
27#include <asm/uaccess.h> 27#include <asm/uaccess.h>
28#include <asm/desc.h> 28#include <asm/desc.h>
29#include <asm/kdebug.h> 29#include <asm/kdebug.h>
30#include <asm/segment.h>
30 31
31extern void die(const char *,struct pt_regs *,long); 32extern void die(const char *,struct pt_regs *,long);
32 33
33#ifdef CONFIG_KPROBES 34static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
34ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain); 35
35int register_page_fault_notifier(struct notifier_block *nb) 36int register_page_fault_notifier(struct notifier_block *nb)
36{ 37{
37 vmalloc_sync_all(); 38 vmalloc_sync_all();
38 return atomic_notifier_chain_register(&notify_page_fault_chain, nb); 39 return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
39} 40}
41EXPORT_SYMBOL_GPL(register_page_fault_notifier);
40 42
41int unregister_page_fault_notifier(struct notifier_block *nb) 43int unregister_page_fault_notifier(struct notifier_block *nb)
42{ 44{
43 return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb); 45 return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
44} 46}
47EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
45 48
46static inline int notify_page_fault(enum die_val val, const char *str, 49static inline int notify_page_fault(enum die_val val, const char *str,
47 struct pt_regs *regs, long err, int trap, int sig) 50 struct pt_regs *regs, long err, int trap, int sig)
@@ -55,14 +58,6 @@ static inline int notify_page_fault(enum die_val val, const char *str,
55 }; 58 };
56 return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args); 59 return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
57} 60}
58#else
59static inline int notify_page_fault(enum die_val val, const char *str,
60 struct pt_regs *regs, long err, int trap, int sig)
61{
62 return NOTIFY_DONE;
63}
64#endif
65
66 61
67/* 62/*
68 * Unlock any spinlocks which will prevent us from getting the 63 * Unlock any spinlocks which will prevent us from getting the
@@ -119,10 +114,10 @@ static inline unsigned long get_segment_eip(struct pt_regs *regs,
119 } 114 }
120 115
121 /* The standard kernel/user address space limit. */ 116 /* The standard kernel/user address space limit. */
122 *eip_limit = (seg & 3) ? USER_DS.seg : KERNEL_DS.seg; 117 *eip_limit = user_mode(regs) ? USER_DS.seg : KERNEL_DS.seg;
123 118
124 /* By far the most common cases. */ 119 /* By far the most common cases. */
125 if (likely(seg == __USER_CS || seg == __KERNEL_CS)) 120 if (likely(SEGMENT_IS_FLAT_CODE(seg)))
126 return eip; 121 return eip;
127 122
128 /* Check the segment exists, is within the current LDT/GDT size, 123 /* Check the segment exists, is within the current LDT/GDT size,
@@ -436,11 +431,7 @@ good_area:
436 write = 0; 431 write = 0;
437 switch (error_code & 3) { 432 switch (error_code & 3) {
438 default: /* 3: write, present */ 433 default: /* 3: write, present */
439#ifdef TEST_VERIFY_AREA 434 /* fall through */
440 if (regs->cs == KERNEL_CS)
441 printk("WP fault at %08lx\n", regs->eip);
442#endif
443 /* fall through */
444 case 2: /* write, not present */ 435 case 2: /* write, not present */
445 if (!(vma->vm_flags & VM_WRITE)) 436 if (!(vma->vm_flags & VM_WRITE))
446 goto bad_area; 437 goto bad_area;
diff --git a/arch/i386/mm/highmem.c b/arch/i386/mm/highmem.c
index b6eb4dcb8777..ba44000b9069 100644
--- a/arch/i386/mm/highmem.c
+++ b/arch/i386/mm/highmem.c
@@ -54,7 +54,7 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
54 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK; 54 unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
55 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id(); 55 enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
56 56
57 if (vaddr < FIXADDR_START) { // FIXME 57 if (vaddr >= PAGE_OFFSET && vaddr < (unsigned long)high_memory) {
58 dec_preempt_count(); 58 dec_preempt_count();
59 preempt_check_resched(); 59 preempt_check_resched();
60 return; 60 return;
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index efd0bcdac65d..4a5a914b3432 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -435,16 +435,22 @@ u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
435 * on Enable 435 * on Enable
436 * off Disable 436 * off Disable
437 */ 437 */
438void __init noexec_setup(const char *str) 438static int __init noexec_setup(char *str)
439{ 439{
440 if (!strncmp(str, "on",2) && cpu_has_nx) { 440 if (!str || !strcmp(str, "on")) {
441 __supported_pte_mask |= _PAGE_NX; 441 if (cpu_has_nx) {
442 disable_nx = 0; 442 __supported_pte_mask |= _PAGE_NX;
443 } else if (!strncmp(str,"off",3)) { 443 disable_nx = 0;
444 }
445 } else if (!strcmp(str,"off")) {
444 disable_nx = 1; 446 disable_nx = 1;
445 __supported_pte_mask &= ~_PAGE_NX; 447 __supported_pte_mask &= ~_PAGE_NX;
446 } 448 } else
449 return -EINVAL;
450
451 return 0;
447} 452}
453early_param("noexec", noexec_setup);
448 454
449int nx_enabled = 0; 455int nx_enabled = 0;
450#ifdef CONFIG_X86_PAE 456#ifdef CONFIG_X86_PAE
@@ -552,18 +558,6 @@ static void __init test_wp_bit(void)
552 } 558 }
553} 559}
554 560
555static void __init set_max_mapnr_init(void)
556{
557#ifdef CONFIG_HIGHMEM
558 num_physpages = highend_pfn;
559#else
560 num_physpages = max_low_pfn;
561#endif
562#ifdef CONFIG_FLATMEM
563 max_mapnr = num_physpages;
564#endif
565}
566
567static struct kcore_list kcore_mem, kcore_vmalloc; 561static struct kcore_list kcore_mem, kcore_vmalloc;
568 562
569void __init mem_init(void) 563void __init mem_init(void)
@@ -590,14 +584,6 @@ void __init mem_init(void)
590 } 584 }
591#endif 585#endif
592 586
593 set_max_mapnr_init();
594
595#ifdef CONFIG_HIGHMEM
596 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
597#else
598 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
599#endif
600
601 /* this will put all low memory onto the freelists */ 587 /* this will put all low memory onto the freelists */
602 totalram_pages += free_all_bootmem(); 588 totalram_pages += free_all_bootmem();
603 589
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index 5f8dc8a21bd7..3700eef78743 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -17,14 +17,15 @@
17#include <asm/nmi.h> 17#include <asm/nmi.h>
18#include <asm/msr.h> 18#include <asm/msr.h>
19#include <asm/apic.h> 19#include <asm/apic.h>
20#include <asm/kdebug.h>
20 21
21#include "op_counter.h" 22#include "op_counter.h"
22#include "op_x86_model.h" 23#include "op_x86_model.h"
23 24
24static struct op_x86_model_spec const * model; 25static struct op_x86_model_spec const * model;
25static struct op_msrs cpu_msrs[NR_CPUS]; 26static struct op_msrs cpu_msrs[NR_CPUS];
26static unsigned long saved_lvtpc[NR_CPUS]; 27static unsigned long saved_lvtpc[NR_CPUS];
27 28
28static int nmi_start(void); 29static int nmi_start(void);
29static void nmi_stop(void); 30static void nmi_stop(void);
30 31
@@ -82,13 +83,24 @@ static void exit_driverfs(void)
82#define exit_driverfs() do { } while (0) 83#define exit_driverfs() do { } while (0)
83#endif /* CONFIG_PM */ 84#endif /* CONFIG_PM */
84 85
85 86static int profile_exceptions_notify(struct notifier_block *self,
86static int nmi_callback(struct pt_regs * regs, int cpu) 87 unsigned long val, void *data)
87{ 88{
88 return model->check_ctrs(regs, &cpu_msrs[cpu]); 89 struct die_args *args = (struct die_args *)data;
90 int ret = NOTIFY_DONE;
91 int cpu = smp_processor_id();
92
93 switch(val) {
94 case DIE_NMI:
95 if (model->check_ctrs(args->regs, &cpu_msrs[cpu]))
96 ret = NOTIFY_STOP;
97 break;
98 default:
99 break;
100 }
101 return ret;
89} 102}
90 103
91
92static void nmi_cpu_save_registers(struct op_msrs * msrs) 104static void nmi_cpu_save_registers(struct op_msrs * msrs)
93{ 105{
94 unsigned int const nr_ctrs = model->num_counters; 106 unsigned int const nr_ctrs = model->num_counters;
@@ -98,15 +110,19 @@ static void nmi_cpu_save_registers(struct op_msrs * msrs)
98 unsigned int i; 110 unsigned int i;
99 111
100 for (i = 0; i < nr_ctrs; ++i) { 112 for (i = 0; i < nr_ctrs; ++i) {
101 rdmsr(counters[i].addr, 113 if (counters[i].addr){
102 counters[i].saved.low, 114 rdmsr(counters[i].addr,
103 counters[i].saved.high); 115 counters[i].saved.low,
116 counters[i].saved.high);
117 }
104 } 118 }
105 119
106 for (i = 0; i < nr_ctrls; ++i) { 120 for (i = 0; i < nr_ctrls; ++i) {
107 rdmsr(controls[i].addr, 121 if (controls[i].addr){
108 controls[i].saved.low, 122 rdmsr(controls[i].addr,
109 controls[i].saved.high); 123 controls[i].saved.low,
124 controls[i].saved.high);
125 }
110 } 126 }
111} 127}
112 128
@@ -170,27 +186,29 @@ static void nmi_cpu_setup(void * dummy)
170 apic_write(APIC_LVTPC, APIC_DM_NMI); 186 apic_write(APIC_LVTPC, APIC_DM_NMI);
171} 187}
172 188
189static struct notifier_block profile_exceptions_nb = {
190 .notifier_call = profile_exceptions_notify,
191 .next = NULL,
192 .priority = 0
193};
173 194
174static int nmi_setup(void) 195static int nmi_setup(void)
175{ 196{
197 int err=0;
198
176 if (!allocate_msrs()) 199 if (!allocate_msrs())
177 return -ENOMEM; 200 return -ENOMEM;
178 201
179 /* We walk a thin line between law and rape here. 202 if ((err = register_die_notifier(&profile_exceptions_nb))){
180 * We need to be careful to install our NMI handler
181 * without actually triggering any NMIs as this will
182 * break the core code horrifically.
183 */
184 if (reserve_lapic_nmi() < 0) {
185 free_msrs(); 203 free_msrs();
186 return -EBUSY; 204 return err;
187 } 205 }
206
188 /* We need to serialize save and setup for HT because the subset 207 /* We need to serialize save and setup for HT because the subset
189 * of msrs are distinct for save and setup operations 208 * of msrs are distinct for save and setup operations
190 */ 209 */
191 on_each_cpu(nmi_save_registers, NULL, 0, 1); 210 on_each_cpu(nmi_save_registers, NULL, 0, 1);
192 on_each_cpu(nmi_cpu_setup, NULL, 0, 1); 211 on_each_cpu(nmi_cpu_setup, NULL, 0, 1);
193 set_nmi_callback(nmi_callback);
194 nmi_enabled = 1; 212 nmi_enabled = 1;
195 return 0; 213 return 0;
196} 214}
@@ -205,15 +223,19 @@ static void nmi_restore_registers(struct op_msrs * msrs)
205 unsigned int i; 223 unsigned int i;
206 224
207 for (i = 0; i < nr_ctrls; ++i) { 225 for (i = 0; i < nr_ctrls; ++i) {
208 wrmsr(controls[i].addr, 226 if (controls[i].addr){
209 controls[i].saved.low, 227 wrmsr(controls[i].addr,
210 controls[i].saved.high); 228 controls[i].saved.low,
229 controls[i].saved.high);
230 }
211 } 231 }
212 232
213 for (i = 0; i < nr_ctrs; ++i) { 233 for (i = 0; i < nr_ctrs; ++i) {
214 wrmsr(counters[i].addr, 234 if (counters[i].addr){
215 counters[i].saved.low, 235 wrmsr(counters[i].addr,
216 counters[i].saved.high); 236 counters[i].saved.low,
237 counters[i].saved.high);
238 }
217 } 239 }
218} 240}
219 241
@@ -234,6 +256,7 @@ static void nmi_cpu_shutdown(void * dummy)
234 apic_write(APIC_LVTPC, saved_lvtpc[cpu]); 256 apic_write(APIC_LVTPC, saved_lvtpc[cpu]);
235 apic_write(APIC_LVTERR, v); 257 apic_write(APIC_LVTERR, v);
236 nmi_restore_registers(msrs); 258 nmi_restore_registers(msrs);
259 model->shutdown(msrs);
237} 260}
238 261
239 262
@@ -241,8 +264,7 @@ static void nmi_shutdown(void)
241{ 264{
242 nmi_enabled = 0; 265 nmi_enabled = 0;
243 on_each_cpu(nmi_cpu_shutdown, NULL, 0, 1); 266 on_each_cpu(nmi_cpu_shutdown, NULL, 0, 1);
244 unset_nmi_callback(); 267 unregister_die_notifier(&profile_exceptions_nb);
245 release_lapic_nmi();
246 free_msrs(); 268 free_msrs();
247} 269}
248 270
@@ -284,6 +306,14 @@ static int nmi_create_files(struct super_block * sb, struct dentry * root)
284 struct dentry * dir; 306 struct dentry * dir;
285 char buf[4]; 307 char buf[4];
286 308
309 /* quick little hack to _not_ expose a counter if it is not
310 * available for use. This should protect userspace app.
311 * NOTE: assumes 1:1 mapping here (that counters are organized
312 * sequentially in their struct assignment).
313 */
314 if (unlikely(!avail_to_resrv_perfctr_nmi_bit(i)))
315 continue;
316
287 snprintf(buf, sizeof(buf), "%d", i); 317 snprintf(buf, sizeof(buf), "%d", i);
288 dir = oprofilefs_mkdir(sb, root, buf); 318 dir = oprofilefs_mkdir(sb, root, buf);
289 oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled); 319 oprofilefs_create_ulong(sb, dir, "enabled", &counter_config[i].enabled);
diff --git a/arch/i386/oprofile/nmi_timer_int.c b/arch/i386/oprofile/nmi_timer_int.c
index 930a1127bb30..abf0ba52a635 100644
--- a/arch/i386/oprofile/nmi_timer_int.c
+++ b/arch/i386/oprofile/nmi_timer_int.c
@@ -17,34 +17,49 @@
17#include <asm/nmi.h> 17#include <asm/nmi.h>
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/ptrace.h> 19#include <asm/ptrace.h>
20#include <asm/kdebug.h>
20 21
21static int nmi_timer_callback(struct pt_regs * regs, int cpu) 22static int profile_timer_exceptions_notify(struct notifier_block *self,
23 unsigned long val, void *data)
22{ 24{
23 oprofile_add_sample(regs, 0); 25 struct die_args *args = (struct die_args *)data;
24 return 1; 26 int ret = NOTIFY_DONE;
27
28 switch(val) {
29 case DIE_NMI:
30 oprofile_add_sample(args->regs, 0);
31 ret = NOTIFY_STOP;
32 break;
33 default:
34 break;
35 }
36 return ret;
25} 37}
26 38
39static struct notifier_block profile_timer_exceptions_nb = {
40 .notifier_call = profile_timer_exceptions_notify,
41 .next = NULL,
42 .priority = 0
43};
44
27static int timer_start(void) 45static int timer_start(void)
28{ 46{
29 disable_timer_nmi_watchdog(); 47 if (register_die_notifier(&profile_timer_exceptions_nb))
30 set_nmi_callback(nmi_timer_callback); 48 return 1;
31 return 0; 49 return 0;
32} 50}
33 51
34 52
35static void timer_stop(void) 53static void timer_stop(void)
36{ 54{
37 enable_timer_nmi_watchdog(); 55 unregister_die_notifier(&profile_timer_exceptions_nb);
38 unset_nmi_callback();
39 synchronize_sched(); /* Allow already-started NMIs to complete. */ 56 synchronize_sched(); /* Allow already-started NMIs to complete. */
40} 57}
41 58
42 59
43int __init op_nmi_timer_init(struct oprofile_operations * ops) 60int __init op_nmi_timer_init(struct oprofile_operations * ops)
44{ 61{
45 extern int nmi_active; 62 if ((nmi_watchdog != NMI_IO_APIC) || (atomic_read(&nmi_active) <= 0))
46
47 if (nmi_active <= 0)
48 return -ENODEV; 63 return -ENODEV;
49 64
50 ops->start = timer_start; 65 ops->start = timer_start;
diff --git a/arch/i386/oprofile/op_model_athlon.c b/arch/i386/oprofile/op_model_athlon.c
index 693bdea4a52b..3057a19e4641 100644
--- a/arch/i386/oprofile/op_model_athlon.c
+++ b/arch/i386/oprofile/op_model_athlon.c
@@ -21,10 +21,12 @@
21#define NUM_COUNTERS 4 21#define NUM_COUNTERS 4
22#define NUM_CONTROLS 4 22#define NUM_CONTROLS 4
23 23
24#define CTR_IS_RESERVED(msrs,c) (msrs->counters[(c)].addr ? 1 : 0)
24#define CTR_READ(l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0) 25#define CTR_READ(l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0)
25#define CTR_WRITE(l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(unsigned int)(l), -1);} while (0) 26#define CTR_WRITE(l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(unsigned int)(l), -1);} while (0)
26#define CTR_OVERFLOWED(n) (!((n) & (1U<<31))) 27#define CTR_OVERFLOWED(n) (!((n) & (1U<<31)))
27 28
29#define CTRL_IS_RESERVED(msrs,c) (msrs->controls[(c)].addr ? 1 : 0)
28#define CTRL_READ(l,h,msrs,c) do {rdmsr(msrs->controls[(c)].addr, (l), (h));} while (0) 30#define CTRL_READ(l,h,msrs,c) do {rdmsr(msrs->controls[(c)].addr, (l), (h));} while (0)
29#define CTRL_WRITE(l,h,msrs,c) do {wrmsr(msrs->controls[(c)].addr, (l), (h));} while (0) 31#define CTRL_WRITE(l,h,msrs,c) do {wrmsr(msrs->controls[(c)].addr, (l), (h));} while (0)
30#define CTRL_SET_ACTIVE(n) (n |= (1<<22)) 32#define CTRL_SET_ACTIVE(n) (n |= (1<<22))
@@ -40,15 +42,21 @@ static unsigned long reset_value[NUM_COUNTERS];
40 42
41static void athlon_fill_in_addresses(struct op_msrs * const msrs) 43static void athlon_fill_in_addresses(struct op_msrs * const msrs)
42{ 44{
43 msrs->counters[0].addr = MSR_K7_PERFCTR0; 45 int i;
44 msrs->counters[1].addr = MSR_K7_PERFCTR1; 46
45 msrs->counters[2].addr = MSR_K7_PERFCTR2; 47 for (i=0; i < NUM_COUNTERS; i++) {
46 msrs->counters[3].addr = MSR_K7_PERFCTR3; 48 if (reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i))
47 49 msrs->counters[i].addr = MSR_K7_PERFCTR0 + i;
48 msrs->controls[0].addr = MSR_K7_EVNTSEL0; 50 else
49 msrs->controls[1].addr = MSR_K7_EVNTSEL1; 51 msrs->counters[i].addr = 0;
50 msrs->controls[2].addr = MSR_K7_EVNTSEL2; 52 }
51 msrs->controls[3].addr = MSR_K7_EVNTSEL3; 53
54 for (i=0; i < NUM_CONTROLS; i++) {
55 if (reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i))
56 msrs->controls[i].addr = MSR_K7_EVNTSEL0 + i;
57 else
58 msrs->controls[i].addr = 0;
59 }
52} 60}
53 61
54 62
@@ -59,19 +67,23 @@ static void athlon_setup_ctrs(struct op_msrs const * const msrs)
59 67
60 /* clear all counters */ 68 /* clear all counters */
61 for (i = 0 ; i < NUM_CONTROLS; ++i) { 69 for (i = 0 ; i < NUM_CONTROLS; ++i) {
70 if (unlikely(!CTRL_IS_RESERVED(msrs,i)))
71 continue;
62 CTRL_READ(low, high, msrs, i); 72 CTRL_READ(low, high, msrs, i);
63 CTRL_CLEAR(low); 73 CTRL_CLEAR(low);
64 CTRL_WRITE(low, high, msrs, i); 74 CTRL_WRITE(low, high, msrs, i);
65 } 75 }
66 76
67 /* avoid a false detection of ctr overflows in NMI handler */ 77 /* avoid a false detection of ctr overflows in NMI handler */
68 for (i = 0; i < NUM_COUNTERS; ++i) { 78 for (i = 0; i < NUM_COUNTERS; ++i) {
79 if (unlikely(!CTR_IS_RESERVED(msrs,i)))
80 continue;
69 CTR_WRITE(1, msrs, i); 81 CTR_WRITE(1, msrs, i);
70 } 82 }
71 83
72 /* enable active counters */ 84 /* enable active counters */
73 for (i = 0; i < NUM_COUNTERS; ++i) { 85 for (i = 0; i < NUM_COUNTERS; ++i) {
74 if (counter_config[i].enabled) { 86 if ((counter_config[i].enabled) && (CTR_IS_RESERVED(msrs,i))) {
75 reset_value[i] = counter_config[i].count; 87 reset_value[i] = counter_config[i].count;
76 88
77 CTR_WRITE(counter_config[i].count, msrs, i); 89 CTR_WRITE(counter_config[i].count, msrs, i);
@@ -98,6 +110,8 @@ static int athlon_check_ctrs(struct pt_regs * const regs,
98 int i; 110 int i;
99 111
100 for (i = 0 ; i < NUM_COUNTERS; ++i) { 112 for (i = 0 ; i < NUM_COUNTERS; ++i) {
113 if (!reset_value[i])
114 continue;
101 CTR_READ(low, high, msrs, i); 115 CTR_READ(low, high, msrs, i);
102 if (CTR_OVERFLOWED(low)) { 116 if (CTR_OVERFLOWED(low)) {
103 oprofile_add_sample(regs, i); 117 oprofile_add_sample(regs, i);
@@ -132,12 +146,27 @@ static void athlon_stop(struct op_msrs const * const msrs)
132 /* Subtle: stop on all counters to avoid race with 146 /* Subtle: stop on all counters to avoid race with
133 * setting our pm callback */ 147 * setting our pm callback */
134 for (i = 0 ; i < NUM_COUNTERS ; ++i) { 148 for (i = 0 ; i < NUM_COUNTERS ; ++i) {
149 if (!reset_value[i])
150 continue;
135 CTRL_READ(low, high, msrs, i); 151 CTRL_READ(low, high, msrs, i);
136 CTRL_SET_INACTIVE(low); 152 CTRL_SET_INACTIVE(low);
137 CTRL_WRITE(low, high, msrs, i); 153 CTRL_WRITE(low, high, msrs, i);
138 } 154 }
139} 155}
140 156
157static void athlon_shutdown(struct op_msrs const * const msrs)
158{
159 int i;
160
161 for (i = 0 ; i < NUM_COUNTERS ; ++i) {
162 if (CTR_IS_RESERVED(msrs,i))
163 release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
164 }
165 for (i = 0 ; i < NUM_CONTROLS ; ++i) {
166 if (CTRL_IS_RESERVED(msrs,i))
167 release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
168 }
169}
141 170
142struct op_x86_model_spec const op_athlon_spec = { 171struct op_x86_model_spec const op_athlon_spec = {
143 .num_counters = NUM_COUNTERS, 172 .num_counters = NUM_COUNTERS,
@@ -146,5 +175,6 @@ struct op_x86_model_spec const op_athlon_spec = {
146 .setup_ctrs = &athlon_setup_ctrs, 175 .setup_ctrs = &athlon_setup_ctrs,
147 .check_ctrs = &athlon_check_ctrs, 176 .check_ctrs = &athlon_check_ctrs,
148 .start = &athlon_start, 177 .start = &athlon_start,
149 .stop = &athlon_stop 178 .stop = &athlon_stop,
179 .shutdown = &athlon_shutdown
150}; 180};
diff --git a/arch/i386/oprofile/op_model_p4.c b/arch/i386/oprofile/op_model_p4.c
index 7c61d357b82b..47925927b12f 100644
--- a/arch/i386/oprofile/op_model_p4.c
+++ b/arch/i386/oprofile/op_model_p4.c
@@ -32,7 +32,7 @@
32#define NUM_CONTROLS_HT2 (NUM_ESCRS_HT2 + NUM_CCCRS_HT2) 32#define NUM_CONTROLS_HT2 (NUM_ESCRS_HT2 + NUM_CCCRS_HT2)
33 33
34static unsigned int num_counters = NUM_COUNTERS_NON_HT; 34static unsigned int num_counters = NUM_COUNTERS_NON_HT;
35 35static unsigned int num_controls = NUM_CONTROLS_NON_HT;
36 36
37/* this has to be checked dynamically since the 37/* this has to be checked dynamically since the
38 hyper-threadedness of a chip is discovered at 38 hyper-threadedness of a chip is discovered at
@@ -40,8 +40,10 @@ static unsigned int num_counters = NUM_COUNTERS_NON_HT;
40static inline void setup_num_counters(void) 40static inline void setup_num_counters(void)
41{ 41{
42#ifdef CONFIG_SMP 42#ifdef CONFIG_SMP
43 if (smp_num_siblings == 2) 43 if (smp_num_siblings == 2){
44 num_counters = NUM_COUNTERS_HT2; 44 num_counters = NUM_COUNTERS_HT2;
45 num_controls = NUM_CONTROLS_HT2;
46 }
45#endif 47#endif
46} 48}
47 49
@@ -97,15 +99,6 @@ static struct p4_counter_binding p4_counters [NUM_COUNTERS_NON_HT] = {
97 99
98#define NUM_UNUSED_CCCRS NUM_CCCRS_NON_HT - NUM_COUNTERS_NON_HT 100#define NUM_UNUSED_CCCRS NUM_CCCRS_NON_HT - NUM_COUNTERS_NON_HT
99 101
100/* All cccr we don't use. */
101static int p4_unused_cccr[NUM_UNUSED_CCCRS] = {
102 MSR_P4_BPU_CCCR1, MSR_P4_BPU_CCCR3,
103 MSR_P4_MS_CCCR1, MSR_P4_MS_CCCR3,
104 MSR_P4_FLAME_CCCR1, MSR_P4_FLAME_CCCR3,
105 MSR_P4_IQ_CCCR0, MSR_P4_IQ_CCCR1,
106 MSR_P4_IQ_CCCR2, MSR_P4_IQ_CCCR3
107};
108
109/* p4 event codes in libop/op_event.h are indices into this table. */ 102/* p4 event codes in libop/op_event.h are indices into this table. */
110 103
111static struct p4_event_binding p4_events[NUM_EVENTS] = { 104static struct p4_event_binding p4_events[NUM_EVENTS] = {
@@ -372,6 +365,8 @@ static struct p4_event_binding p4_events[NUM_EVENTS] = {
372#define CCCR_OVF_P(cccr) ((cccr) & (1U<<31)) 365#define CCCR_OVF_P(cccr) ((cccr) & (1U<<31))
373#define CCCR_CLEAR_OVF(cccr) ((cccr) &= (~(1U<<31))) 366#define CCCR_CLEAR_OVF(cccr) ((cccr) &= (~(1U<<31)))
374 367
368#define CTRL_IS_RESERVED(msrs,c) (msrs->controls[(c)].addr ? 1 : 0)
369#define CTR_IS_RESERVED(msrs,c) (msrs->counters[(c)].addr ? 1 : 0)
375#define CTR_READ(l,h,i) do {rdmsr(p4_counters[(i)].counter_address, (l), (h));} while (0) 370#define CTR_READ(l,h,i) do {rdmsr(p4_counters[(i)].counter_address, (l), (h));} while (0)
376#define CTR_WRITE(l,i) do {wrmsr(p4_counters[(i)].counter_address, -(u32)(l), -1);} while (0) 371#define CTR_WRITE(l,i) do {wrmsr(p4_counters[(i)].counter_address, -(u32)(l), -1);} while (0)
377#define CTR_OVERFLOW_P(ctr) (!((ctr) & 0x80000000)) 372#define CTR_OVERFLOW_P(ctr) (!((ctr) & 0x80000000))
@@ -401,29 +396,34 @@ static unsigned long reset_value[NUM_COUNTERS_NON_HT];
401static void p4_fill_in_addresses(struct op_msrs * const msrs) 396static void p4_fill_in_addresses(struct op_msrs * const msrs)
402{ 397{
403 unsigned int i; 398 unsigned int i;
404 unsigned int addr, stag; 399 unsigned int addr, cccraddr, stag;
405 400
406 setup_num_counters(); 401 setup_num_counters();
407 stag = get_stagger(); 402 stag = get_stagger();
408 403
409 /* the counter registers we pay attention to */ 404 /* initialize some registers */
410 for (i = 0; i < num_counters; ++i) { 405 for (i = 0; i < num_counters; ++i) {
411 msrs->counters[i].addr = 406 msrs->counters[i].addr = 0;
412 p4_counters[VIRT_CTR(stag, i)].counter_address;
413 } 407 }
414 408 for (i = 0; i < num_controls; ++i) {
415 /* FIXME: bad feeling, we don't save the 10 counters we don't use. */ 409 msrs->controls[i].addr = 0;
416
417 /* 18 CCCR registers */
418 for (i = 0, addr = MSR_P4_BPU_CCCR0 + stag;
419 addr <= MSR_P4_IQ_CCCR5; ++i, addr += addr_increment()) {
420 msrs->controls[i].addr = addr;
421 } 410 }
422 411
412 /* the counter & cccr registers we pay attention to */
413 for (i = 0; i < num_counters; ++i) {
414 addr = p4_counters[VIRT_CTR(stag, i)].counter_address;
415 cccraddr = p4_counters[VIRT_CTR(stag, i)].cccr_address;
416 if (reserve_perfctr_nmi(addr)){
417 msrs->counters[i].addr = addr;
418 msrs->controls[i].addr = cccraddr;
419 }
420 }
421
423 /* 43 ESCR registers in three or four discontiguous group */ 422 /* 43 ESCR registers in three or four discontiguous group */
424 for (addr = MSR_P4_BSU_ESCR0 + stag; 423 for (addr = MSR_P4_BSU_ESCR0 + stag;
425 addr < MSR_P4_IQ_ESCR0; ++i, addr += addr_increment()) { 424 addr < MSR_P4_IQ_ESCR0; ++i, addr += addr_increment()) {
426 msrs->controls[i].addr = addr; 425 if (reserve_evntsel_nmi(addr))
426 msrs->controls[i].addr = addr;
427 } 427 }
428 428
429 /* no IQ_ESCR0/1 on some models, we save a seconde time BSU_ESCR0/1 429 /* no IQ_ESCR0/1 on some models, we save a seconde time BSU_ESCR0/1
@@ -431,47 +431,57 @@ static void p4_fill_in_addresses(struct op_msrs * const msrs)
431 if (boot_cpu_data.x86_model >= 0x3) { 431 if (boot_cpu_data.x86_model >= 0x3) {
432 for (addr = MSR_P4_BSU_ESCR0 + stag; 432 for (addr = MSR_P4_BSU_ESCR0 + stag;
433 addr <= MSR_P4_BSU_ESCR1; ++i, addr += addr_increment()) { 433 addr <= MSR_P4_BSU_ESCR1; ++i, addr += addr_increment()) {
434 msrs->controls[i].addr = addr; 434 if (reserve_evntsel_nmi(addr))
435 msrs->controls[i].addr = addr;
435 } 436 }
436 } else { 437 } else {
437 for (addr = MSR_P4_IQ_ESCR0 + stag; 438 for (addr = MSR_P4_IQ_ESCR0 + stag;
438 addr <= MSR_P4_IQ_ESCR1; ++i, addr += addr_increment()) { 439 addr <= MSR_P4_IQ_ESCR1; ++i, addr += addr_increment()) {
439 msrs->controls[i].addr = addr; 440 if (reserve_evntsel_nmi(addr))
441 msrs->controls[i].addr = addr;
440 } 442 }
441 } 443 }
442 444
443 for (addr = MSR_P4_RAT_ESCR0 + stag; 445 for (addr = MSR_P4_RAT_ESCR0 + stag;
444 addr <= MSR_P4_SSU_ESCR0; ++i, addr += addr_increment()) { 446 addr <= MSR_P4_SSU_ESCR0; ++i, addr += addr_increment()) {
445 msrs->controls[i].addr = addr; 447 if (reserve_evntsel_nmi(addr))
448 msrs->controls[i].addr = addr;
446 } 449 }
447 450
448 for (addr = MSR_P4_MS_ESCR0 + stag; 451 for (addr = MSR_P4_MS_ESCR0 + stag;
449 addr <= MSR_P4_TC_ESCR1; ++i, addr += addr_increment()) { 452 addr <= MSR_P4_TC_ESCR1; ++i, addr += addr_increment()) {
450 msrs->controls[i].addr = addr; 453 if (reserve_evntsel_nmi(addr))
454 msrs->controls[i].addr = addr;
451 } 455 }
452 456
453 for (addr = MSR_P4_IX_ESCR0 + stag; 457 for (addr = MSR_P4_IX_ESCR0 + stag;
454 addr <= MSR_P4_CRU_ESCR3; ++i, addr += addr_increment()) { 458 addr <= MSR_P4_CRU_ESCR3; ++i, addr += addr_increment()) {
455 msrs->controls[i].addr = addr; 459 if (reserve_evntsel_nmi(addr))
460 msrs->controls[i].addr = addr;
456 } 461 }
457 462
458 /* there are 2 remaining non-contiguously located ESCRs */ 463 /* there are 2 remaining non-contiguously located ESCRs */
459 464
460 if (num_counters == NUM_COUNTERS_NON_HT) { 465 if (num_counters == NUM_COUNTERS_NON_HT) {
461 /* standard non-HT CPUs handle both remaining ESCRs*/ 466 /* standard non-HT CPUs handle both remaining ESCRs*/
462 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5; 467 if (reserve_evntsel_nmi(MSR_P4_CRU_ESCR5))
463 msrs->controls[i++].addr = MSR_P4_CRU_ESCR4; 468 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5;
469 if (reserve_evntsel_nmi(MSR_P4_CRU_ESCR4))
470 msrs->controls[i++].addr = MSR_P4_CRU_ESCR4;
464 471
465 } else if (stag == 0) { 472 } else if (stag == 0) {
466 /* HT CPUs give the first remainder to the even thread, as 473 /* HT CPUs give the first remainder to the even thread, as
467 the 32nd control register */ 474 the 32nd control register */
468 msrs->controls[i++].addr = MSR_P4_CRU_ESCR4; 475 if (reserve_evntsel_nmi(MSR_P4_CRU_ESCR4))
476 msrs->controls[i++].addr = MSR_P4_CRU_ESCR4;
469 477
470 } else { 478 } else {
471 /* and two copies of the second to the odd thread, 479 /* and two copies of the second to the odd thread,
472 for the 22st and 23nd control registers */ 480 for the 22st and 23nd control registers */
473 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5; 481 if (reserve_evntsel_nmi(MSR_P4_CRU_ESCR5)) {
474 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5; 482 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5;
483 msrs->controls[i++].addr = MSR_P4_CRU_ESCR5;
484 }
475 } 485 }
476} 486}
477 487
@@ -544,7 +554,6 @@ static void p4_setup_ctrs(struct op_msrs const * const msrs)
544{ 554{
545 unsigned int i; 555 unsigned int i;
546 unsigned int low, high; 556 unsigned int low, high;
547 unsigned int addr;
548 unsigned int stag; 557 unsigned int stag;
549 558
550 stag = get_stagger(); 559 stag = get_stagger();
@@ -557,59 +566,24 @@ static void p4_setup_ctrs(struct op_msrs const * const msrs)
557 566
558 /* clear the cccrs we will use */ 567 /* clear the cccrs we will use */
559 for (i = 0 ; i < num_counters ; i++) { 568 for (i = 0 ; i < num_counters ; i++) {
569 if (unlikely(!CTRL_IS_RESERVED(msrs,i)))
570 continue;
560 rdmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high); 571 rdmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high);
561 CCCR_CLEAR(low); 572 CCCR_CLEAR(low);
562 CCCR_SET_REQUIRED_BITS(low); 573 CCCR_SET_REQUIRED_BITS(low);
563 wrmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high); 574 wrmsr(p4_counters[VIRT_CTR(stag, i)].cccr_address, low, high);
564 } 575 }
565 576
566 /* clear cccrs outside our concern */
567 for (i = stag ; i < NUM_UNUSED_CCCRS ; i += addr_increment()) {
568 rdmsr(p4_unused_cccr[i], low, high);
569 CCCR_CLEAR(low);
570 CCCR_SET_REQUIRED_BITS(low);
571 wrmsr(p4_unused_cccr[i], low, high);
572 }
573
574 /* clear all escrs (including those outside our concern) */ 577 /* clear all escrs (including those outside our concern) */
575 for (addr = MSR_P4_BSU_ESCR0 + stag; 578 for (i = num_counters; i < num_controls; i++) {
576 addr < MSR_P4_IQ_ESCR0; addr += addr_increment()) { 579 if (unlikely(!CTRL_IS_RESERVED(msrs,i)))
577 wrmsr(addr, 0, 0); 580 continue;
578 } 581 wrmsr(msrs->controls[i].addr, 0, 0);
579
580 /* On older models clear also MSR_P4_IQ_ESCR0/1 */
581 if (boot_cpu_data.x86_model < 0x3) {
582 wrmsr(MSR_P4_IQ_ESCR0, 0, 0);
583 wrmsr(MSR_P4_IQ_ESCR1, 0, 0);
584 }
585
586 for (addr = MSR_P4_RAT_ESCR0 + stag;
587 addr <= MSR_P4_SSU_ESCR0; ++i, addr += addr_increment()) {
588 wrmsr(addr, 0, 0);
589 }
590
591 for (addr = MSR_P4_MS_ESCR0 + stag;
592 addr <= MSR_P4_TC_ESCR1; addr += addr_increment()){
593 wrmsr(addr, 0, 0);
594 }
595
596 for (addr = MSR_P4_IX_ESCR0 + stag;
597 addr <= MSR_P4_CRU_ESCR3; addr += addr_increment()){
598 wrmsr(addr, 0, 0);
599 } 582 }
600 583
601 if (num_counters == NUM_COUNTERS_NON_HT) {
602 wrmsr(MSR_P4_CRU_ESCR4, 0, 0);
603 wrmsr(MSR_P4_CRU_ESCR5, 0, 0);
604 } else if (stag == 0) {
605 wrmsr(MSR_P4_CRU_ESCR4, 0, 0);
606 } else {
607 wrmsr(MSR_P4_CRU_ESCR5, 0, 0);
608 }
609
610 /* setup all counters */ 584 /* setup all counters */
611 for (i = 0 ; i < num_counters ; ++i) { 585 for (i = 0 ; i < num_counters ; ++i) {
612 if (counter_config[i].enabled) { 586 if ((counter_config[i].enabled) && (CTRL_IS_RESERVED(msrs,i))) {
613 reset_value[i] = counter_config[i].count; 587 reset_value[i] = counter_config[i].count;
614 pmc_setup_one_p4_counter(i); 588 pmc_setup_one_p4_counter(i);
615 CTR_WRITE(counter_config[i].count, VIRT_CTR(stag, i)); 589 CTR_WRITE(counter_config[i].count, VIRT_CTR(stag, i));
@@ -696,12 +670,32 @@ static void p4_stop(struct op_msrs const * const msrs)
696 stag = get_stagger(); 670 stag = get_stagger();
697 671
698 for (i = 0; i < num_counters; ++i) { 672 for (i = 0; i < num_counters; ++i) {
673 if (!reset_value[i])
674 continue;
699 CCCR_READ(low, high, VIRT_CTR(stag, i)); 675 CCCR_READ(low, high, VIRT_CTR(stag, i));
700 CCCR_SET_DISABLE(low); 676 CCCR_SET_DISABLE(low);
701 CCCR_WRITE(low, high, VIRT_CTR(stag, i)); 677 CCCR_WRITE(low, high, VIRT_CTR(stag, i));
702 } 678 }
703} 679}
704 680
681static void p4_shutdown(struct op_msrs const * const msrs)
682{
683 int i;
684
685 for (i = 0 ; i < num_counters ; ++i) {
686 if (CTR_IS_RESERVED(msrs,i))
687 release_perfctr_nmi(msrs->counters[i].addr);
688 }
689 /* some of the control registers are specially reserved in
690 * conjunction with the counter registers (hence the starting offset).
691 * This saves a few bits.
692 */
693 for (i = num_counters ; i < num_controls ; ++i) {
694 if (CTRL_IS_RESERVED(msrs,i))
695 release_evntsel_nmi(msrs->controls[i].addr);
696 }
697}
698
705 699
706#ifdef CONFIG_SMP 700#ifdef CONFIG_SMP
707struct op_x86_model_spec const op_p4_ht2_spec = { 701struct op_x86_model_spec const op_p4_ht2_spec = {
@@ -711,7 +705,8 @@ struct op_x86_model_spec const op_p4_ht2_spec = {
711 .setup_ctrs = &p4_setup_ctrs, 705 .setup_ctrs = &p4_setup_ctrs,
712 .check_ctrs = &p4_check_ctrs, 706 .check_ctrs = &p4_check_ctrs,
713 .start = &p4_start, 707 .start = &p4_start,
714 .stop = &p4_stop 708 .stop = &p4_stop,
709 .shutdown = &p4_shutdown
715}; 710};
716#endif 711#endif
717 712
@@ -722,5 +717,6 @@ struct op_x86_model_spec const op_p4_spec = {
722 .setup_ctrs = &p4_setup_ctrs, 717 .setup_ctrs = &p4_setup_ctrs,
723 .check_ctrs = &p4_check_ctrs, 718 .check_ctrs = &p4_check_ctrs,
724 .start = &p4_start, 719 .start = &p4_start,
725 .stop = &p4_stop 720 .stop = &p4_stop,
721 .shutdown = &p4_shutdown
726}; 722};
diff --git a/arch/i386/oprofile/op_model_ppro.c b/arch/i386/oprofile/op_model_ppro.c
index 5c3ab4b027ad..f88e05ba8eb3 100644
--- a/arch/i386/oprofile/op_model_ppro.c
+++ b/arch/i386/oprofile/op_model_ppro.c
@@ -22,10 +22,12 @@
22#define NUM_COUNTERS 2 22#define NUM_COUNTERS 2
23#define NUM_CONTROLS 2 23#define NUM_CONTROLS 2
24 24
25#define CTR_IS_RESERVED(msrs,c) (msrs->counters[(c)].addr ? 1 : 0)
25#define CTR_READ(l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0) 26#define CTR_READ(l,h,msrs,c) do {rdmsr(msrs->counters[(c)].addr, (l), (h));} while (0)
26#define CTR_WRITE(l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(u32)(l), -1);} while (0) 27#define CTR_WRITE(l,msrs,c) do {wrmsr(msrs->counters[(c)].addr, -(u32)(l), -1);} while (0)
27#define CTR_OVERFLOWED(n) (!((n) & (1U<<31))) 28#define CTR_OVERFLOWED(n) (!((n) & (1U<<31)))
28 29
30#define CTRL_IS_RESERVED(msrs,c) (msrs->controls[(c)].addr ? 1 : 0)
29#define CTRL_READ(l,h,msrs,c) do {rdmsr((msrs->controls[(c)].addr), (l), (h));} while (0) 31#define CTRL_READ(l,h,msrs,c) do {rdmsr((msrs->controls[(c)].addr), (l), (h));} while (0)
30#define CTRL_WRITE(l,h,msrs,c) do {wrmsr((msrs->controls[(c)].addr), (l), (h));} while (0) 32#define CTRL_WRITE(l,h,msrs,c) do {wrmsr((msrs->controls[(c)].addr), (l), (h));} while (0)
31#define CTRL_SET_ACTIVE(n) (n |= (1<<22)) 33#define CTRL_SET_ACTIVE(n) (n |= (1<<22))
@@ -41,11 +43,21 @@ static unsigned long reset_value[NUM_COUNTERS];
41 43
42static void ppro_fill_in_addresses(struct op_msrs * const msrs) 44static void ppro_fill_in_addresses(struct op_msrs * const msrs)
43{ 45{
44 msrs->counters[0].addr = MSR_P6_PERFCTR0; 46 int i;
45 msrs->counters[1].addr = MSR_P6_PERFCTR1; 47
48 for (i=0; i < NUM_COUNTERS; i++) {
49 if (reserve_perfctr_nmi(MSR_P6_PERFCTR0 + i))
50 msrs->counters[i].addr = MSR_P6_PERFCTR0 + i;
51 else
52 msrs->counters[i].addr = 0;
53 }
46 54
47 msrs->controls[0].addr = MSR_P6_EVNTSEL0; 55 for (i=0; i < NUM_CONTROLS; i++) {
48 msrs->controls[1].addr = MSR_P6_EVNTSEL1; 56 if (reserve_evntsel_nmi(MSR_P6_EVNTSEL0 + i))
57 msrs->controls[i].addr = MSR_P6_EVNTSEL0 + i;
58 else
59 msrs->controls[i].addr = 0;
60 }
49} 61}
50 62
51 63
@@ -56,6 +68,8 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs)
56 68
57 /* clear all counters */ 69 /* clear all counters */
58 for (i = 0 ; i < NUM_CONTROLS; ++i) { 70 for (i = 0 ; i < NUM_CONTROLS; ++i) {
71 if (unlikely(!CTRL_IS_RESERVED(msrs,i)))
72 continue;
59 CTRL_READ(low, high, msrs, i); 73 CTRL_READ(low, high, msrs, i);
60 CTRL_CLEAR(low); 74 CTRL_CLEAR(low);
61 CTRL_WRITE(low, high, msrs, i); 75 CTRL_WRITE(low, high, msrs, i);
@@ -63,12 +77,14 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs)
63 77
64 /* avoid a false detection of ctr overflows in NMI handler */ 78 /* avoid a false detection of ctr overflows in NMI handler */
65 for (i = 0; i < NUM_COUNTERS; ++i) { 79 for (i = 0; i < NUM_COUNTERS; ++i) {
80 if (unlikely(!CTR_IS_RESERVED(msrs,i)))
81 continue;
66 CTR_WRITE(1, msrs, i); 82 CTR_WRITE(1, msrs, i);
67 } 83 }
68 84
69 /* enable active counters */ 85 /* enable active counters */
70 for (i = 0; i < NUM_COUNTERS; ++i) { 86 for (i = 0; i < NUM_COUNTERS; ++i) {
71 if (counter_config[i].enabled) { 87 if ((counter_config[i].enabled) && (CTR_IS_RESERVED(msrs,i))) {
72 reset_value[i] = counter_config[i].count; 88 reset_value[i] = counter_config[i].count;
73 89
74 CTR_WRITE(counter_config[i].count, msrs, i); 90 CTR_WRITE(counter_config[i].count, msrs, i);
@@ -81,6 +97,8 @@ static void ppro_setup_ctrs(struct op_msrs const * const msrs)
81 CTRL_SET_UM(low, counter_config[i].unit_mask); 97 CTRL_SET_UM(low, counter_config[i].unit_mask);
82 CTRL_SET_EVENT(low, counter_config[i].event); 98 CTRL_SET_EVENT(low, counter_config[i].event);
83 CTRL_WRITE(low, high, msrs, i); 99 CTRL_WRITE(low, high, msrs, i);
100 } else {
101 reset_value[i] = 0;
84 } 102 }
85 } 103 }
86} 104}
@@ -93,6 +111,8 @@ static int ppro_check_ctrs(struct pt_regs * const regs,
93 int i; 111 int i;
94 112
95 for (i = 0 ; i < NUM_COUNTERS; ++i) { 113 for (i = 0 ; i < NUM_COUNTERS; ++i) {
114 if (!reset_value[i])
115 continue;
96 CTR_READ(low, high, msrs, i); 116 CTR_READ(low, high, msrs, i);
97 if (CTR_OVERFLOWED(low)) { 117 if (CTR_OVERFLOWED(low)) {
98 oprofile_add_sample(regs, i); 118 oprofile_add_sample(regs, i);
@@ -118,18 +138,38 @@ static int ppro_check_ctrs(struct pt_regs * const regs,
118static void ppro_start(struct op_msrs const * const msrs) 138static void ppro_start(struct op_msrs const * const msrs)
119{ 139{
120 unsigned int low,high; 140 unsigned int low,high;
121 CTRL_READ(low, high, msrs, 0); 141
122 CTRL_SET_ACTIVE(low); 142 if (reset_value[0]) {
123 CTRL_WRITE(low, high, msrs, 0); 143 CTRL_READ(low, high, msrs, 0);
144 CTRL_SET_ACTIVE(low);
145 CTRL_WRITE(low, high, msrs, 0);
146 }
124} 147}
125 148
126 149
127static void ppro_stop(struct op_msrs const * const msrs) 150static void ppro_stop(struct op_msrs const * const msrs)
128{ 151{
129 unsigned int low,high; 152 unsigned int low,high;
130 CTRL_READ(low, high, msrs, 0); 153
131 CTRL_SET_INACTIVE(low); 154 if (reset_value[0]) {
132 CTRL_WRITE(low, high, msrs, 0); 155 CTRL_READ(low, high, msrs, 0);
156 CTRL_SET_INACTIVE(low);
157 CTRL_WRITE(low, high, msrs, 0);
158 }
159}
160
161static void ppro_shutdown(struct op_msrs const * const msrs)
162{
163 int i;
164
165 for (i = 0 ; i < NUM_COUNTERS ; ++i) {
166 if (CTR_IS_RESERVED(msrs,i))
167 release_perfctr_nmi(MSR_P6_PERFCTR0 + i);
168 }
169 for (i = 0 ; i < NUM_CONTROLS ; ++i) {
170 if (CTRL_IS_RESERVED(msrs,i))
171 release_evntsel_nmi(MSR_P6_EVNTSEL0 + i);
172 }
133} 173}
134 174
135 175
@@ -140,5 +180,6 @@ struct op_x86_model_spec const op_ppro_spec = {
140 .setup_ctrs = &ppro_setup_ctrs, 180 .setup_ctrs = &ppro_setup_ctrs,
141 .check_ctrs = &ppro_check_ctrs, 181 .check_ctrs = &ppro_check_ctrs,
142 .start = &ppro_start, 182 .start = &ppro_start,
143 .stop = &ppro_stop 183 .stop = &ppro_stop,
184 .shutdown = &ppro_shutdown
144}; 185};
diff --git a/arch/i386/oprofile/op_x86_model.h b/arch/i386/oprofile/op_x86_model.h
index 123b7e90a9ee..abb1aa95b979 100644
--- a/arch/i386/oprofile/op_x86_model.h
+++ b/arch/i386/oprofile/op_x86_model.h
@@ -40,6 +40,7 @@ struct op_x86_model_spec {
40 struct op_msrs const * const msrs); 40 struct op_msrs const * const msrs);
41 void (*start)(struct op_msrs const * const msrs); 41 void (*start)(struct op_msrs const * const msrs);
42 void (*stop)(struct op_msrs const * const msrs); 42 void (*stop)(struct op_msrs const * const msrs);
43 void (*shutdown)(struct op_msrs const * const msrs);
43}; 44};
44 45
45extern struct op_x86_model_spec const op_ppro_spec; 46extern struct op_x86_model_spec const op_ppro_spec;
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
index 62ad75c57e6a..1594d2f55c8f 100644
--- a/arch/i386/pci/Makefile
+++ b/arch/i386/pci/Makefile
@@ -11,4 +11,4 @@ pci-y += legacy.o irq.o
11pci-$(CONFIG_X86_VISWS) := visws.o fixup.o 11pci-$(CONFIG_X86_VISWS) := visws.o fixup.o
12pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o 12pci-$(CONFIG_X86_NUMAQ) := numa.o irq.o
13 13
14obj-y += $(pci-y) common.o 14obj-y += $(pci-y) common.o early.o
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 0a362e3aeac5..68bce194e688 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -242,6 +242,10 @@ char * __devinit pcibios_setup(char *str)
242 acpi_noirq_set(); 242 acpi_noirq_set();
243 return NULL; 243 return NULL;
244 } 244 }
245 else if (!strcmp(str, "noearly")) {
246 pci_probe |= PCI_PROBE_NOEARLY;
247 return NULL;
248 }
245#ifndef CONFIG_X86_VISWS 249#ifndef CONFIG_X86_VISWS
246 else if (!strcmp(str, "usepirqmask")) { 250 else if (!strcmp(str, "usepirqmask")) {
247 pci_probe |= PCI_USE_PIRQ_MASK; 251 pci_probe |= PCI_USE_PIRQ_MASK;
diff --git a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
index 5d81fb510375..5acf0b4743cf 100644
--- a/arch/i386/pci/direct.c
+++ b/arch/i386/pci/direct.c
@@ -254,7 +254,16 @@ static int __init pci_check_type2(void)
254 return works; 254 return works;
255} 255}
256 256
257void __init pci_direct_init(void) 257void __init pci_direct_init(int type)
258{
259 printk(KERN_INFO "PCI: Using configuration type %d\n", type);
260 if (type == 1)
261 raw_pci_ops = &pci_direct_conf1;
262 else
263 raw_pci_ops = &pci_direct_conf2;
264}
265
266int __init pci_direct_probe(void)
258{ 267{
259 struct resource *region, *region2; 268 struct resource *region, *region2;
260 269
@@ -264,19 +273,16 @@ void __init pci_direct_init(void)
264 if (!region) 273 if (!region)
265 goto type2; 274 goto type2;
266 275
267 if (pci_check_type1()) { 276 if (pci_check_type1())
268 printk(KERN_INFO "PCI: Using configuration type 1\n"); 277 return 1;
269 raw_pci_ops = &pci_direct_conf1;
270 return;
271 }
272 release_resource(region); 278 release_resource(region);
273 279
274 type2: 280 type2:
275 if ((pci_probe & PCI_PROBE_CONF2) == 0) 281 if ((pci_probe & PCI_PROBE_CONF2) == 0)
276 return; 282 return 0;
277 region = request_region(0xCF8, 4, "PCI conf2"); 283 region = request_region(0xCF8, 4, "PCI conf2");
278 if (!region) 284 if (!region)
279 return; 285 return 0;
280 region2 = request_region(0xC000, 0x1000, "PCI conf2"); 286 region2 = request_region(0xC000, 0x1000, "PCI conf2");
281 if (!region2) 287 if (!region2)
282 goto fail2; 288 goto fail2;
@@ -284,10 +290,11 @@ void __init pci_direct_init(void)
284 if (pci_check_type2()) { 290 if (pci_check_type2()) {
285 printk(KERN_INFO "PCI: Using configuration type 2\n"); 291 printk(KERN_INFO "PCI: Using configuration type 2\n");
286 raw_pci_ops = &pci_direct_conf2; 292 raw_pci_ops = &pci_direct_conf2;
287 return; 293 return 2;
288 } 294 }
289 295
290 release_resource(region2); 296 release_resource(region2);
291 fail2: 297 fail2:
292 release_resource(region); 298 release_resource(region);
299 return 0;
293} 300}
diff --git a/arch/i386/pci/early.c b/arch/i386/pci/early.c
new file mode 100644
index 000000000000..713d6c866cae
--- /dev/null
+++ b/arch/i386/pci/early.c
@@ -0,0 +1,52 @@
1#include <linux/kernel.h>
2#include <linux/pci.h>
3#include <asm/pci-direct.h>
4#include <asm/io.h>
5#include "pci.h"
6
7/* Direct PCI access. This is used for PCI accesses in early boot before
8 the PCI subsystem works. */
9
10#define PDprintk(x...)
11
12u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset)
13{
14 u32 v;
15 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
16 v = inl(0xcfc);
17 if (v != 0xffffffff)
18 PDprintk("%x reading 4 from %x: %x\n", slot, offset, v);
19 return v;
20}
21
22u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset)
23{
24 u8 v;
25 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
26 v = inb(0xcfc + (offset&3));
27 PDprintk("%x reading 1 from %x: %x\n", slot, offset, v);
28 return v;
29}
30
31u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset)
32{
33 u16 v;
34 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
35 v = inw(0xcfc + (offset&2));
36 PDprintk("%x reading 2 from %x: %x\n", slot, offset, v);
37 return v;
38}
39
40void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
41 u32 val)
42{
43 PDprintk("%x writing to %x: %x\n", slot, offset, val);
44 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
45 outl(val, 0xcfc);
46}
47
48int early_pci_allowed(void)
49{
50 return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
51 PCI_PROBE_CONF1;
52}
diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c
index 51087a9d9172..d028e1b05c36 100644
--- a/arch/i386/pci/init.c
+++ b/arch/i386/pci/init.c
@@ -6,8 +6,13 @@
6 in the right sequence from here. */ 6 in the right sequence from here. */
7static __init int pci_access_init(void) 7static __init int pci_access_init(void)
8{ 8{
9 int type = 0;
10
11#ifdef CONFIG_PCI_DIRECT
12 type = pci_direct_probe();
13#endif
9#ifdef CONFIG_PCI_MMCONFIG 14#ifdef CONFIG_PCI_MMCONFIG
10 pci_mmcfg_init(); 15 pci_mmcfg_init(type);
11#endif 16#endif
12 if (raw_pci_ops) 17 if (raw_pci_ops)
13 return 0; 18 return 0;
@@ -21,7 +26,7 @@ static __init int pci_access_init(void)
21 * fails. 26 * fails.
22 */ 27 */
23#ifdef CONFIG_PCI_DIRECT 28#ifdef CONFIG_PCI_DIRECT
24 pci_direct_init(); 29 pci_direct_init(type);
25#endif 30#endif
26 return 0; 31 return 0;
27} 32}
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 972180f738d9..05be8db58a8c 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -151,6 +151,38 @@ static struct pci_raw_ops pci_mmcfg = {
151 .write = pci_mmcfg_write, 151 .write = pci_mmcfg_write,
152}; 152};
153 153
154
155static __init void pci_mmcfg_insert_resources(void)
156{
157#define PCI_MMCFG_RESOURCE_NAME_LEN 19
158 int i;
159 struct resource *res;
160 char *names;
161 unsigned num_buses;
162
163 res = kcalloc(PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res),
164 pci_mmcfg_config_num, GFP_KERNEL);
165
166 if (!res) {
167 printk(KERN_ERR "PCI: Unable to allocate MMCONFIG resources\n");
168 return;
169 }
170
171 names = (void *)&res[pci_mmcfg_config_num];
172 for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
173 num_buses = pci_mmcfg_config[i].end_bus_number -
174 pci_mmcfg_config[i].start_bus_number + 1;
175 res->name = names;
176 snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
177 pci_mmcfg_config[i].pci_segment_group_number);
178 res->start = pci_mmcfg_config[i].base_address;
179 res->end = res->start + (num_buses << 20) - 1;
180 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
181 insert_resource(&iomem_resource, res);
182 names += PCI_MMCFG_RESOURCE_NAME_LEN;
183 }
184}
185
154/* K8 systems have some devices (typically in the builtin northbridge) 186/* K8 systems have some devices (typically in the builtin northbridge)
155 that are only accessible using type1 187 that are only accessible using type1
156 Normally this can be expressed in the MCFG by not listing them 188 Normally this can be expressed in the MCFG by not listing them
@@ -187,7 +219,9 @@ static __init void unreachable_devices(void)
187 } 219 }
188} 220}
189 221
190void __init pci_mmcfg_init(void) 222
223
224void __init pci_mmcfg_init(int type)
191{ 225{
192 if ((pci_probe & PCI_PROBE_MMCONF) == 0) 226 if ((pci_probe & PCI_PROBE_MMCONF) == 0)
193 return; 227 return;
@@ -198,7 +232,9 @@ void __init pci_mmcfg_init(void)
198 (pci_mmcfg_config[0].base_address == 0)) 232 (pci_mmcfg_config[0].base_address == 0))
199 return; 233 return;
200 234
201 if (!e820_all_mapped(pci_mmcfg_config[0].base_address, 235 /* Only do this check when type 1 works. If it doesn't work
236 assume we run on a Mac and always use MCFG */
237 if (type == 1 && !e820_all_mapped(pci_mmcfg_config[0].base_address,
202 pci_mmcfg_config[0].base_address + MMCONFIG_APER_MIN, 238 pci_mmcfg_config[0].base_address + MMCONFIG_APER_MIN,
203 E820_RESERVED)) { 239 E820_RESERVED)) {
204 printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %x is not E820-reserved\n", 240 printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %x is not E820-reserved\n",
@@ -212,4 +248,5 @@ void __init pci_mmcfg_init(void)
212 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 248 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
213 249
214 unreachable_devices(); 250 unreachable_devices();
251 pci_mmcfg_insert_resources();
215} 252}
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
index bf4e79335388..1814f74569c6 100644
--- a/arch/i386/pci/pci.h
+++ b/arch/i386/pci/pci.h
@@ -17,6 +17,7 @@
17#define PCI_PROBE_CONF2 0x0004 17#define PCI_PROBE_CONF2 0x0004
18#define PCI_PROBE_MMCONF 0x0008 18#define PCI_PROBE_MMCONF 0x0008
19#define PCI_PROBE_MASK 0x000f 19#define PCI_PROBE_MASK 0x000f
20#define PCI_PROBE_NOEARLY 0x0010
20 21
21#define PCI_NO_SORT 0x0100 22#define PCI_NO_SORT 0x0100
22#define PCI_BIOS_SORT 0x0200 23#define PCI_BIOS_SORT 0x0200
@@ -81,7 +82,9 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus,
81extern int pci_conf1_read(unsigned int seg, unsigned int bus, 82extern int pci_conf1_read(unsigned int seg, unsigned int bus,
82 unsigned int devfn, int reg, int len, u32 *value); 83 unsigned int devfn, int reg, int len, u32 *value);
83 84
84extern void pci_direct_init(void); 85extern int pci_direct_probe(void);
86extern void pci_direct_init(int type);
85extern void pci_pcbios_init(void); 87extern void pci_pcbios_init(void);
86extern void pci_mmcfg_init(void); 88extern void pci_mmcfg_init(int type);
87extern void pcibios_sort(void); 89extern void pcibios_sort(void);
90
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index f521f2f60a78..0b7f701d5cf7 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -356,6 +356,9 @@ config NODES_SHIFT
356 MAX_NUMNODES will be 2^(This value). 356 MAX_NUMNODES will be 2^(This value).
357 If in doubt, use the default. 357 If in doubt, use the default.
358 358
359config ARCH_POPULATES_NODE_MAP
360 def_bool y
361
359# VIRTUAL_MEM_MAP and FLAT_NODE_MEM_MAP are functionally equivalent. 362# VIRTUAL_MEM_MAP and FLAT_NODE_MEM_MAP are functionally equivalent.
360# VIRTUAL_MEM_MAP has been retained for historical reasons. 363# VIRTUAL_MEM_MAP has been retained for historical reasons.
361config VIRTUAL_MEM_MAP 364config VIRTUAL_MEM_MAP
@@ -420,6 +423,14 @@ config IA64_PALINFO
420config SGI_SN 423config SGI_SN
421 def_bool y if (IA64_SGI_SN2 || IA64_GENERIC) 424 def_bool y if (IA64_SGI_SN2 || IA64_GENERIC)
422 425
426config IA64_ESI
427 bool "ESI (Extensible SAL Interface) support"
428 help
429 If you say Y here, support is built into the kernel to
430 make ESI calls. ESI calls are used to support vendor-specific
431 firmware extensions, such as the ability to inject memory-errors
432 for test-purposes. If you're unsure, say N.
433
423source "drivers/sn/Kconfig" 434source "drivers/sn/Kconfig"
424 435
425source "drivers/firmware/Kconfig" 436source "drivers/firmware/Kconfig"
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 6aa3c51619ca..bddbd22706ed 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -1942,7 +1942,7 @@ struct sysctl32 {
1942 unsigned int __unused[4]; 1942 unsigned int __unused[4];
1943}; 1943};
1944 1944
1945#ifdef CONFIG_SYSCTL 1945#ifdef CONFIG_SYSCTL_SYSCALL
1946asmlinkage long 1946asmlinkage long
1947sys32_sysctl (struct sysctl32 __user *args) 1947sys32_sysctl (struct sysctl32 __user *args)
1948{ 1948{
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index ad8215a3c586..31497496eb4b 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -32,6 +32,11 @@ obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o
32obj-$(CONFIG_AUDIT) += audit.o 32obj-$(CONFIG_AUDIT) += audit.o
33mca_recovery-y += mca_drv.o mca_drv_asm.o 33mca_recovery-y += mca_drv.o mca_drv_asm.o
34 34
35obj-$(CONFIG_IA64_ESI) += esi.o
36ifneq ($(CONFIG_IA64_ESI),)
37obj-y += esi_stub.o # must be in kernel proper
38endif
39
35# The gate DSO image is built using a special linker script. 40# The gate DSO image is built using a special linker script.
36targets += gate.so gate-syms.o 41targets += gate.so gate-syms.o
37 42
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index fef06571be99..12701cf32d99 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -1605,8 +1605,8 @@ sys_call_table:
1605 data8 sys_ni_syscall // 1295 reserved for ppoll 1605 data8 sys_ni_syscall // 1295 reserved for ppoll
1606 data8 sys_unshare 1606 data8 sys_unshare
1607 data8 sys_splice 1607 data8 sys_splice
1608 data8 sys_ni_syscall // reserved for set_robust_list 1608 data8 sys_set_robust_list
1609 data8 sys_ni_syscall // reserved for get_robust_list 1609 data8 sys_get_robust_list
1610 data8 sys_sync_file_range // 1300 1610 data8 sys_sync_file_range // 1300
1611 data8 sys_tee 1611 data8 sys_tee
1612 data8 sys_vmsplice 1612 data8 sys_vmsplice
diff --git a/arch/ia64/kernel/esi.c b/arch/ia64/kernel/esi.c
new file mode 100644
index 000000000000..ebf4e988e78c
--- /dev/null
+++ b/arch/ia64/kernel/esi.c
@@ -0,0 +1,205 @@
1/*
2 * Extensible SAL Interface (ESI) support routines.
3 *
4 * Copyright (C) 2006 Hewlett-Packard Co
5 * Alex Williamson <alex.williamson@hp.com>
6 */
7#include <linux/kernel.h>
8#include <linux/init.h>
9#include <linux/module.h>
10#include <linux/string.h>
11
12#include <asm/esi.h>
13#include <asm/sal.h>
14
15MODULE_AUTHOR("Alex Williamson <alex.williamson@hp.com>");
16MODULE_DESCRIPTION("Extensible SAL Interface (ESI) support");
17MODULE_LICENSE("GPL");
18
19#define MODULE_NAME "esi"
20
21#define ESI_TABLE_GUID \
22 EFI_GUID(0x43EA58DC, 0xCF28, 0x4b06, 0xB3, \
23 0x91, 0xB7, 0x50, 0x59, 0x34, 0x2B, 0xD4)
24
25enum esi_systab_entry_type {
26 ESI_DESC_ENTRY_POINT = 0
27};
28
29/*
30 * Entry type: Size:
31 * 0 48
32 */
33#define ESI_DESC_SIZE(type) "\060"[(unsigned) (type)]
34
35typedef struct ia64_esi_desc_entry_point {
36 u8 type;
37 u8 reserved1[15];
38 u64 esi_proc;
39 u64 gp;
40 efi_guid_t guid;
41} ia64_esi_desc_entry_point_t;
42
43struct pdesc {
44 void *addr;
45 void *gp;
46};
47
48static struct ia64_sal_systab *esi_systab;
49
50static int __init esi_init (void)
51{
52 efi_config_table_t *config_tables;
53 struct ia64_sal_systab *systab;
54 unsigned long esi = 0;
55 char *p;
56 int i;
57
58 config_tables = __va(efi.systab->tables);
59
60 for (i = 0; i < (int) efi.systab->nr_tables; ++i) {
61 if (efi_guidcmp(config_tables[i].guid, ESI_TABLE_GUID) == 0) {
62 esi = config_tables[i].table;
63 break;
64 }
65 }
66
67 if (!esi)
68 return -ENODEV;;
69
70 systab = __va(esi);
71
72 if (strncmp(systab->signature, "ESIT", 4) != 0) {
73 printk(KERN_ERR "bad signature in ESI system table!");
74 return -ENODEV;
75 }
76
77 p = (char *) (systab + 1);
78 for (i = 0; i < systab->entry_count; i++) {
79 /*
80 * The first byte of each entry type contains the type
81 * descriptor.
82 */
83 switch (*p) {
84 case ESI_DESC_ENTRY_POINT:
85 break;
86 default:
87 printk(KERN_WARNING "Unkown table type %d found in "
88 "ESI table, ignoring rest of table\n", *p);
89 return -ENODEV;
90 }
91
92 p += ESI_DESC_SIZE(*p);
93 }
94
95 esi_systab = systab;
96 return 0;
97}
98
99
100int ia64_esi_call (efi_guid_t guid, struct ia64_sal_retval *isrvp,
101 enum esi_proc_type proc_type, u64 func,
102 u64 arg1, u64 arg2, u64 arg3, u64 arg4, u64 arg5, u64 arg6,
103 u64 arg7)
104{
105 struct ia64_fpreg fr[6];
106 unsigned long flags = 0;
107 int i;
108 char *p;
109
110 if (!esi_systab)
111 return -1;
112
113 p = (char *) (esi_systab + 1);
114 for (i = 0; i < esi_systab->entry_count; i++) {
115 if (*p == ESI_DESC_ENTRY_POINT) {
116 ia64_esi_desc_entry_point_t *esi = (void *)p;
117 if (!efi_guidcmp(guid, esi->guid)) {
118 ia64_sal_handler esi_proc;
119 struct pdesc pdesc;
120
121 pdesc.addr = __va(esi->esi_proc);
122 pdesc.gp = __va(esi->gp);
123
124 esi_proc = (ia64_sal_handler) &pdesc;
125
126 ia64_save_scratch_fpregs(fr);
127 if (proc_type == ESI_PROC_SERIALIZED)
128 spin_lock_irqsave(&sal_lock, flags);
129 else if (proc_type == ESI_PROC_MP_SAFE)
130 local_irq_save(flags);
131 else
132 preempt_disable();
133 *isrvp = (*esi_proc)(func, arg1, arg2, arg3,
134 arg4, arg5, arg6, arg7);
135 if (proc_type == ESI_PROC_SERIALIZED)
136 spin_unlock_irqrestore(&sal_lock,
137 flags);
138 else if (proc_type == ESI_PROC_MP_SAFE)
139 local_irq_restore(flags);
140 else
141 preempt_enable();
142 ia64_load_scratch_fpregs(fr);
143 return 0;
144 }
145 }
146 p += ESI_DESC_SIZE(*p);
147 }
148 return -1;
149}
150EXPORT_SYMBOL_GPL(ia64_esi_call);
151
152int ia64_esi_call_phys (efi_guid_t guid, struct ia64_sal_retval *isrvp,
153 u64 func, u64 arg1, u64 arg2, u64 arg3, u64 arg4,
154 u64 arg5, u64 arg6, u64 arg7)
155{
156 struct ia64_fpreg fr[6];
157 unsigned long flags;
158 u64 esi_params[8];
159 char *p;
160 int i;
161
162 if (!esi_systab)
163 return -1;
164
165 p = (char *) (esi_systab + 1);
166 for (i = 0; i < esi_systab->entry_count; i++) {
167 if (*p == ESI_DESC_ENTRY_POINT) {
168 ia64_esi_desc_entry_point_t *esi = (void *)p;
169 if (!efi_guidcmp(guid, esi->guid)) {
170 ia64_sal_handler esi_proc;
171 struct pdesc pdesc;
172
173 pdesc.addr = (void *)esi->esi_proc;
174 pdesc.gp = (void *)esi->gp;
175
176 esi_proc = (ia64_sal_handler) &pdesc;
177
178 esi_params[0] = func;
179 esi_params[1] = arg1;
180 esi_params[2] = arg2;
181 esi_params[3] = arg3;
182 esi_params[4] = arg4;
183 esi_params[5] = arg5;
184 esi_params[6] = arg6;
185 esi_params[7] = arg7;
186 ia64_save_scratch_fpregs(fr);
187 spin_lock_irqsave(&sal_lock, flags);
188 *isrvp = esi_call_phys(esi_proc, esi_params);
189 spin_unlock_irqrestore(&sal_lock, flags);
190 ia64_load_scratch_fpregs(fr);
191 return 0;
192 }
193 }
194 p += ESI_DESC_SIZE(*p);
195 }
196 return -1;
197}
198EXPORT_SYMBOL_GPL(ia64_esi_call_phys);
199
200static void __exit esi_exit (void)
201{
202}
203
204module_init(esi_init);
205module_exit(esi_exit); /* makes module removable... */
diff --git a/arch/ia64/kernel/esi_stub.S b/arch/ia64/kernel/esi_stub.S
new file mode 100644
index 000000000000..6b3d6c1f99b6
--- /dev/null
+++ b/arch/ia64/kernel/esi_stub.S
@@ -0,0 +1,96 @@
1/*
2 * ESI call stub.
3 *
4 * Copyright (C) 2005 Hewlett-Packard Co
5 * Alex Williamson <alex.williamson@hp.com>
6 *
7 * Based on EFI call stub by David Mosberger. The stub is virtually
8 * identical to the one for EFI phys-mode calls, except that ESI
9 * calls may have up to 8 arguments, so they get passed to this routine
10 * through memory.
11 *
12 * This stub allows us to make ESI calls in physical mode with interrupts
13 * turned off. ESI calls may not support calling from virtual mode.
14 *
15 * Google for "Extensible SAL specification" for a document describing the
16 * ESI standard.
17 */
18
19/*
20 * PSR settings as per SAL spec (Chapter 8 in the "IA-64 System
21 * Abstraction Layer Specification", revision 2.6e). Note that
22 * psr.dfl and psr.dfh MUST be cleared, despite what this manual says.
23 * Otherwise, SAL dies whenever it's trying to do an IA-32 BIOS call
24 * (the br.ia instruction fails unless psr.dfl and psr.dfh are
25 * cleared). Fortunately, SAL promises not to touch the floating
26 * point regs, so at least we don't have to save f2-f127.
27 */
28#define PSR_BITS_TO_CLEAR \
29 (IA64_PSR_I | IA64_PSR_IT | IA64_PSR_DT | IA64_PSR_RT | \
30 IA64_PSR_DD | IA64_PSR_SS | IA64_PSR_RI | IA64_PSR_ED | \
31 IA64_PSR_DFL | IA64_PSR_DFH)
32
33#define PSR_BITS_TO_SET \
34 (IA64_PSR_BN)
35
36#include <asm/processor.h>
37#include <asm/asmmacro.h>
38
39/*
40 * Inputs:
41 * in0 = address of function descriptor of ESI routine to call
42 * in1 = address of array of ESI parameters
43 *
44 * Outputs:
45 * r8 = result returned by called function
46 */
47GLOBAL_ENTRY(esi_call_phys)
48 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(2)
49 alloc loc1=ar.pfs,2,7,8,0
50 ld8 r2=[in0],8 // load ESI function's entry point
51 mov loc0=rp
52 .body
53 ;;
54 ld8 out0=[in1],8 // ESI params loaded from array
55 ;; // passing all as inputs doesn't work
56 ld8 out1=[in1],8
57 ;;
58 ld8 out2=[in1],8
59 ;;
60 ld8 out3=[in1],8
61 ;;
62 ld8 out4=[in1],8
63 ;;
64 ld8 out5=[in1],8
65 ;;
66 ld8 out6=[in1],8
67 ;;
68 ld8 out7=[in1]
69 mov loc2=gp // save global pointer
70 mov loc4=ar.rsc // save RSE configuration
71 mov ar.rsc=0 // put RSE in enforced lazy, LE mode
72 ;;
73 ld8 gp=[in0] // load ESI function's global pointer
74 movl r16=PSR_BITS_TO_CLEAR
75 mov loc3=psr // save processor status word
76 movl r17=PSR_BITS_TO_SET
77 ;;
78 or loc3=loc3,r17
79 mov b6=r2
80 ;;
81 andcm r16=loc3,r16 // get psr with IT, DT, and RT bits cleared
82 br.call.sptk.many rp=ia64_switch_mode_phys
83.ret0: mov loc5=r19 // old ar.bsp
84 mov loc6=r20 // old sp
85 br.call.sptk.many rp=b6 // call the ESI function
86.ret1: mov ar.rsc=0 // put RSE in enforced lazy, LE mode
87 mov r16=loc3 // save virtual mode psr
88 mov r19=loc5 // save virtual mode bspstore
89 mov r20=loc6 // save virtual mode sp
90 br.call.sptk.many rp=ia64_switch_mode_virt // return to virtual mode
91.ret2: mov ar.rsc=loc4 // restore RSE configuration
92 mov ar.pfs=loc1
93 mov rp=loc0
94 mov gp=loc2
95 br.ret.sptk.many rp
96END(esi_call_phys)
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c
index 3ead20fb6f4b..879c1817bd1c 100644
--- a/arch/ia64/kernel/ia64_ksyms.c
+++ b/arch/ia64/kernel/ia64_ksyms.c
@@ -105,5 +105,9 @@ EXPORT_SYMBOL(ia64_spinlock_contention);
105# endif 105# endif
106#endif 106#endif
107 107
108#if defined(CONFIG_IA64_ESI) || defined(CONFIG_IA64_ESI_MODULE)
109extern void esi_call_phys (void);
110EXPORT_SYMBOL_GPL(esi_call_phys);
111#endif
108extern char ia64_ivt[]; 112extern char ia64_ivt[];
109EXPORT_SYMBOL(ia64_ivt); 113EXPORT_SYMBOL(ia64_ivt);
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c
index 781960f80b6f..169ec3a7156c 100644
--- a/arch/ia64/kernel/kprobes.c
+++ b/arch/ia64/kernel/kprobes.c
@@ -136,10 +136,8 @@ static void __kprobes update_kprobe_inst_flag(uint template, uint slot,
136static int __kprobes unsupported_inst(uint template, uint slot, 136static int __kprobes unsupported_inst(uint template, uint slot,
137 uint major_opcode, 137 uint major_opcode,
138 unsigned long kprobe_inst, 138 unsigned long kprobe_inst,
139 struct kprobe *p) 139 unsigned long addr)
140{ 140{
141 unsigned long addr = (unsigned long)p->addr;
142
143 if (bundle_encoding[template][slot] == I) { 141 if (bundle_encoding[template][slot] == I) {
144 switch (major_opcode) { 142 switch (major_opcode) {
145 case 0x0: //I_UNIT_MISC_OPCODE: 143 case 0x0: //I_UNIT_MISC_OPCODE:
@@ -217,7 +215,7 @@ static void __kprobes prepare_break_inst(uint template, uint slot,
217 struct kprobe *p) 215 struct kprobe *p)
218{ 216{
219 unsigned long break_inst = BREAK_INST; 217 unsigned long break_inst = BREAK_INST;
220 bundle_t *bundle = &p->ainsn.insn.bundle; 218 bundle_t *bundle = &p->opcode.bundle;
221 219
222 /* 220 /*
223 * Copy the original kprobe_inst qualifying predicate(qp) 221 * Copy the original kprobe_inst qualifying predicate(qp)
@@ -423,11 +421,9 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
423 unsigned long *kprobe_addr = (unsigned long *)(addr & ~0xFULL); 421 unsigned long *kprobe_addr = (unsigned long *)(addr & ~0xFULL);
424 unsigned long kprobe_inst=0; 422 unsigned long kprobe_inst=0;
425 unsigned int slot = addr & 0xf, template, major_opcode = 0; 423 unsigned int slot = addr & 0xf, template, major_opcode = 0;
426 bundle_t *bundle = &p->ainsn.insn.bundle; 424 bundle_t *bundle;
427
428 memcpy(&p->opcode.bundle, kprobe_addr, sizeof(bundle_t));
429 memcpy(&p->ainsn.insn.bundle, kprobe_addr, sizeof(bundle_t));
430 425
426 bundle = &((kprobe_opcode_t *)kprobe_addr)->bundle;
431 template = bundle->quad0.template; 427 template = bundle->quad0.template;
432 428
433 if(valid_kprobe_addr(template, slot, addr)) 429 if(valid_kprobe_addr(template, slot, addr))
@@ -440,20 +436,19 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
440 /* Get kprobe_inst and major_opcode from the bundle */ 436 /* Get kprobe_inst and major_opcode from the bundle */
441 get_kprobe_inst(bundle, slot, &kprobe_inst, &major_opcode); 437 get_kprobe_inst(bundle, slot, &kprobe_inst, &major_opcode);
442 438
443 if (unsupported_inst(template, slot, major_opcode, kprobe_inst, p)) 439 if (unsupported_inst(template, slot, major_opcode, kprobe_inst, addr))
444 return -EINVAL; 440 return -EINVAL;
445 441
446 prepare_break_inst(template, slot, major_opcode, kprobe_inst, p);
447 442
448 return 0; 443 p->ainsn.insn = get_insn_slot();
449} 444 if (!p->ainsn.insn)
445 return -ENOMEM;
446 memcpy(&p->opcode, kprobe_addr, sizeof(kprobe_opcode_t));
447 memcpy(p->ainsn.insn, kprobe_addr, sizeof(kprobe_opcode_t));
450 448
451void __kprobes flush_insn_slot(struct kprobe *p) 449 prepare_break_inst(template, slot, major_opcode, kprobe_inst, p);
452{
453 unsigned long arm_addr;
454 450
455 arm_addr = ((unsigned long)&p->opcode.bundle) & ~0xFULL; 451 return 0;
456 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t));
457} 452}
458 453
459void __kprobes arch_arm_kprobe(struct kprobe *p) 454void __kprobes arch_arm_kprobe(struct kprobe *p)
@@ -461,9 +456,10 @@ void __kprobes arch_arm_kprobe(struct kprobe *p)
461 unsigned long addr = (unsigned long)p->addr; 456 unsigned long addr = (unsigned long)p->addr;
462 unsigned long arm_addr = addr & ~0xFULL; 457 unsigned long arm_addr = addr & ~0xFULL;
463 458
464 flush_insn_slot(p); 459 flush_icache_range((unsigned long)p->ainsn.insn,
465 memcpy((char *)arm_addr, &p->ainsn.insn.bundle, sizeof(bundle_t)); 460 (unsigned long)p->ainsn.insn + sizeof(kprobe_opcode_t));
466 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t)); 461 memcpy((char *)arm_addr, &p->opcode, sizeof(kprobe_opcode_t));
462 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t));
467} 463}
468 464
469void __kprobes arch_disarm_kprobe(struct kprobe *p) 465void __kprobes arch_disarm_kprobe(struct kprobe *p)
@@ -471,11 +467,18 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
471 unsigned long addr = (unsigned long)p->addr; 467 unsigned long addr = (unsigned long)p->addr;
472 unsigned long arm_addr = addr & ~0xFULL; 468 unsigned long arm_addr = addr & ~0xFULL;
473 469
474 /* p->opcode contains the original unaltered bundle */ 470 /* p->ainsn.insn contains the original unaltered kprobe_opcode_t */
475 memcpy((char *) arm_addr, (char *) &p->opcode.bundle, sizeof(bundle_t)); 471 memcpy((char *) arm_addr, (char *) p->ainsn.insn,
476 flush_icache_range(arm_addr, arm_addr + sizeof(bundle_t)); 472 sizeof(kprobe_opcode_t));
473 flush_icache_range(arm_addr, arm_addr + sizeof(kprobe_opcode_t));
477} 474}
478 475
476void __kprobes arch_remove_kprobe(struct kprobe *p)
477{
478 mutex_lock(&kprobe_mutex);
479 free_insn_slot(p->ainsn.insn);
480 mutex_unlock(&kprobe_mutex);
481}
479/* 482/*
480 * We are resuming execution after a single step fault, so the pt_regs 483 * We are resuming execution after a single step fault, so the pt_regs
481 * structure reflects the register state after we executed the instruction 484 * structure reflects the register state after we executed the instruction
@@ -486,12 +489,12 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
486 */ 489 */
487static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs) 490static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
488{ 491{
489 unsigned long bundle_addr = ((unsigned long) (&p->opcode.bundle)) & ~0xFULL; 492 unsigned long bundle_addr = (unsigned long) (&p->ainsn.insn->bundle);
490 unsigned long resume_addr = (unsigned long)p->addr & ~0xFULL; 493 unsigned long resume_addr = (unsigned long)p->addr & ~0xFULL;
491 unsigned long template; 494 unsigned long template;
492 int slot = ((unsigned long)p->addr & 0xf); 495 int slot = ((unsigned long)p->addr & 0xf);
493 496
494 template = p->opcode.bundle.quad0.template; 497 template = p->ainsn.insn->bundle.quad0.template;
495 498
496 if (slot == 1 && bundle_encoding[template][1] == L) 499 if (slot == 1 && bundle_encoding[template][1] == L)
497 slot = 2; 500 slot = 2;
@@ -553,7 +556,7 @@ turn_ss_off:
553 556
554static void __kprobes prepare_ss(struct kprobe *p, struct pt_regs *regs) 557static void __kprobes prepare_ss(struct kprobe *p, struct pt_regs *regs)
555{ 558{
556 unsigned long bundle_addr = (unsigned long) &p->opcode.bundle; 559 unsigned long bundle_addr = (unsigned long) &p->ainsn.insn->bundle;
557 unsigned long slot = (unsigned long)p->addr & 0xf; 560 unsigned long slot = (unsigned long)p->addr & 0xf;
558 561
559 /* single step inline if break instruction */ 562 /* single step inline if break instruction */
@@ -768,6 +771,12 @@ static int __kprobes kprobes_fault_handler(struct pt_regs *regs, int trapnr)
768 */ 771 */
769 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr)) 772 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
770 return 1; 773 return 1;
774 /*
775 * In case the user-specified fault handler returned
776 * zero, try to fix up.
777 */
778 if (ia64_done_with_exception(regs))
779 return 1;
771 780
772 /* 781 /*
773 * Let ia64_do_page_fault() fix it. 782 * Let ia64_do_page_fault() fix it.
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
index 2fbe4536fe18..bfbd8986153b 100644
--- a/arch/ia64/kernel/mca.c
+++ b/arch/ia64/kernel/mca.c
@@ -54,6 +54,9 @@
54 * 54 *
55 * 2005-10-07 Keith Owens <kaos@sgi.com> 55 * 2005-10-07 Keith Owens <kaos@sgi.com>
56 * Add notify_die() hooks. 56 * Add notify_die() hooks.
57 *
58 * 2006-09-15 Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
59 * Add printing support for MCA/INIT.
57 */ 60 */
58#include <linux/types.h> 61#include <linux/types.h>
59#include <linux/init.h> 62#include <linux/init.h>
@@ -136,11 +139,175 @@ extern void salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe);
136 139
137static int mca_init __initdata; 140static int mca_init __initdata;
138 141
142/*
143 * limited & delayed printing support for MCA/INIT handler
144 */
145
146#define mprintk(fmt...) ia64_mca_printk(fmt)
147
148#define MLOGBUF_SIZE (512+256*NR_CPUS)
149#define MLOGBUF_MSGMAX 256
150static char mlogbuf[MLOGBUF_SIZE];
151static DEFINE_SPINLOCK(mlogbuf_wlock); /* mca context only */
152static DEFINE_SPINLOCK(mlogbuf_rlock); /* normal context only */
153static unsigned long mlogbuf_start;
154static unsigned long mlogbuf_end;
155static unsigned int mlogbuf_finished = 0;
156static unsigned long mlogbuf_timestamp = 0;
157
158static int loglevel_save = -1;
159#define BREAK_LOGLEVEL(__console_loglevel) \
160 oops_in_progress = 1; \
161 if (loglevel_save < 0) \
162 loglevel_save = __console_loglevel; \
163 __console_loglevel = 15;
164
165#define RESTORE_LOGLEVEL(__console_loglevel) \
166 if (loglevel_save >= 0) { \
167 __console_loglevel = loglevel_save; \
168 loglevel_save = -1; \
169 } \
170 mlogbuf_finished = 0; \
171 oops_in_progress = 0;
172
173/*
174 * Push messages into buffer, print them later if not urgent.
175 */
176void ia64_mca_printk(const char *fmt, ...)
177{
178 va_list args;
179 int printed_len;
180 char temp_buf[MLOGBUF_MSGMAX];
181 char *p;
182
183 va_start(args, fmt);
184 printed_len = vscnprintf(temp_buf, sizeof(temp_buf), fmt, args);
185 va_end(args);
186
187 /* Copy the output into mlogbuf */
188 if (oops_in_progress) {
189 /* mlogbuf was abandoned, use printk directly instead. */
190 printk(temp_buf);
191 } else {
192 spin_lock(&mlogbuf_wlock);
193 for (p = temp_buf; *p; p++) {
194 unsigned long next = (mlogbuf_end + 1) % MLOGBUF_SIZE;
195 if (next != mlogbuf_start) {
196 mlogbuf[mlogbuf_end] = *p;
197 mlogbuf_end = next;
198 } else {
199 /* buffer full */
200 break;
201 }
202 }
203 mlogbuf[mlogbuf_end] = '\0';
204 spin_unlock(&mlogbuf_wlock);
205 }
206}
207EXPORT_SYMBOL(ia64_mca_printk);
208
209/*
210 * Print buffered messages.
211 * NOTE: call this after returning normal context. (ex. from salinfod)
212 */
213void ia64_mlogbuf_dump(void)
214{
215 char temp_buf[MLOGBUF_MSGMAX];
216 char *p;
217 unsigned long index;
218 unsigned long flags;
219 unsigned int printed_len;
220
221 /* Get output from mlogbuf */
222 while (mlogbuf_start != mlogbuf_end) {
223 temp_buf[0] = '\0';
224 p = temp_buf;
225 printed_len = 0;
226
227 spin_lock_irqsave(&mlogbuf_rlock, flags);
228
229 index = mlogbuf_start;
230 while (index != mlogbuf_end) {
231 *p = mlogbuf[index];
232 index = (index + 1) % MLOGBUF_SIZE;
233 if (!*p)
234 break;
235 p++;
236 if (++printed_len >= MLOGBUF_MSGMAX - 1)
237 break;
238 }
239 *p = '\0';
240 if (temp_buf[0])
241 printk(temp_buf);
242 mlogbuf_start = index;
243
244 mlogbuf_timestamp = 0;
245 spin_unlock_irqrestore(&mlogbuf_rlock, flags);
246 }
247}
248EXPORT_SYMBOL(ia64_mlogbuf_dump);
249
250/*
251 * Call this if system is going to down or if immediate flushing messages to
252 * console is required. (ex. recovery was failed, crash dump is going to be
253 * invoked, long-wait rendezvous etc.)
254 * NOTE: this should be called from monarch.
255 */
256static void ia64_mlogbuf_finish(int wait)
257{
258 BREAK_LOGLEVEL(console_loglevel);
259
260 spin_lock_init(&mlogbuf_rlock);
261 ia64_mlogbuf_dump();
262 printk(KERN_EMERG "mlogbuf_finish: printing switched to urgent mode, "
263 "MCA/INIT might be dodgy or fail.\n");
264
265 if (!wait)
266 return;
267
268 /* wait for console */
269 printk("Delaying for 5 seconds...\n");
270 udelay(5*1000000);
271
272 mlogbuf_finished = 1;
273}
274EXPORT_SYMBOL(ia64_mlogbuf_finish);
275
276/*
277 * Print buffered messages from INIT context.
278 */
279static void ia64_mlogbuf_dump_from_init(void)
280{
281 if (mlogbuf_finished)
282 return;
283
284 if (mlogbuf_timestamp && (mlogbuf_timestamp + 30*HZ > jiffies)) {
285 printk(KERN_ERR "INIT: mlogbuf_dump is interrupted by INIT "
286 " and the system seems to be messed up.\n");
287 ia64_mlogbuf_finish(0);
288 return;
289 }
290
291 if (!spin_trylock(&mlogbuf_rlock)) {
292 printk(KERN_ERR "INIT: mlogbuf_dump is interrupted by INIT. "
293 "Generated messages other than stack dump will be "
294 "buffered to mlogbuf and will be printed later.\n");
295 printk(KERN_ERR "INIT: If messages would not printed after "
296 "this INIT, wait 30sec and assert INIT again.\n");
297 if (!mlogbuf_timestamp)
298 mlogbuf_timestamp = jiffies;
299 return;
300 }
301 spin_unlock(&mlogbuf_rlock);
302 ia64_mlogbuf_dump();
303}
139 304
140static void inline 305static void inline
141ia64_mca_spin(const char *func) 306ia64_mca_spin(const char *func)
142{ 307{
143 printk(KERN_EMERG "%s: spinning here, not returning to SAL\n", func); 308 if (monarch_cpu == smp_processor_id())
309 ia64_mlogbuf_finish(0);
310 mprintk(KERN_EMERG "%s: spinning here, not returning to SAL\n", func);
144 while (1) 311 while (1)
145 cpu_relax(); 312 cpu_relax();
146} 313}
@@ -344,9 +511,6 @@ ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs)
344 /* SAL spec states this should run w/ interrupts enabled */ 511 /* SAL spec states this should run w/ interrupts enabled */
345 local_irq_enable(); 512 local_irq_enable();
346 513
347 /* Get the CPE error record and log it */
348 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CPE);
349
350 spin_lock(&cpe_history_lock); 514 spin_lock(&cpe_history_lock);
351 if (!cpe_poll_enabled && cpe_vector >= 0) { 515 if (!cpe_poll_enabled && cpe_vector >= 0) {
352 516
@@ -375,7 +539,7 @@ ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs)
375 mod_timer(&cpe_poll_timer, jiffies + MIN_CPE_POLL_INTERVAL); 539 mod_timer(&cpe_poll_timer, jiffies + MIN_CPE_POLL_INTERVAL);
376 540
377 /* lock already released, get out now */ 541 /* lock already released, get out now */
378 return IRQ_HANDLED; 542 goto out;
379 } else { 543 } else {
380 cpe_history[index++] = now; 544 cpe_history[index++] = now;
381 if (index == CPE_HISTORY_LENGTH) 545 if (index == CPE_HISTORY_LENGTH)
@@ -383,6 +547,10 @@ ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs)
383 } 547 }
384 } 548 }
385 spin_unlock(&cpe_history_lock); 549 spin_unlock(&cpe_history_lock);
550out:
551 /* Get the CPE error record and log it */
552 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CPE);
553
386 return IRQ_HANDLED; 554 return IRQ_HANDLED;
387} 555}
388 556
@@ -988,18 +1156,22 @@ ia64_wait_for_slaves(int monarch, const char *type)
988 } 1156 }
989 if (!missing) 1157 if (!missing)
990 goto all_in; 1158 goto all_in;
991 printk(KERN_INFO "OS %s slave did not rendezvous on cpu", type); 1159 /*
1160 * Maybe slave(s) dead. Print buffered messages immediately.
1161 */
1162 ia64_mlogbuf_finish(0);
1163 mprintk(KERN_INFO "OS %s slave did not rendezvous on cpu", type);
992 for_each_online_cpu(c) { 1164 for_each_online_cpu(c) {
993 if (c == monarch) 1165 if (c == monarch)
994 continue; 1166 continue;
995 if (ia64_mc_info.imi_rendez_checkin[c] == IA64_MCA_RENDEZ_CHECKIN_NOTDONE) 1167 if (ia64_mc_info.imi_rendez_checkin[c] == IA64_MCA_RENDEZ_CHECKIN_NOTDONE)
996 printk(" %d", c); 1168 mprintk(" %d", c);
997 } 1169 }
998 printk("\n"); 1170 mprintk("\n");
999 return; 1171 return;
1000 1172
1001all_in: 1173all_in:
1002 printk(KERN_INFO "All OS %s slaves have reached rendezvous\n", type); 1174 mprintk(KERN_INFO "All OS %s slaves have reached rendezvous\n", type);
1003 return; 1175 return;
1004} 1176}
1005 1177
@@ -1027,10 +1199,8 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
1027 struct ia64_mca_notify_die nd = 1199 struct ia64_mca_notify_die nd =
1028 { .sos = sos, .monarch_cpu = &monarch_cpu }; 1200 { .sos = sos, .monarch_cpu = &monarch_cpu };
1029 1201
1030 oops_in_progress = 1; /* FIXME: make printk NMI/MCA/INIT safe */ 1202 mprintk(KERN_INFO "Entered OS MCA handler. PSP=%lx cpu=%d "
1031 console_loglevel = 15; /* make sure printks make it to console */ 1203 "monarch=%ld\n", sos->proc_state_param, cpu, sos->monarch);
1032 printk(KERN_INFO "Entered OS MCA handler. PSP=%lx cpu=%d monarch=%ld\n",
1033 sos->proc_state_param, cpu, sos->monarch);
1034 1204
1035 previous_current = ia64_mca_modify_original_stack(regs, sw, sos, "MCA"); 1205 previous_current = ia64_mca_modify_original_stack(regs, sw, sos, "MCA");
1036 monarch_cpu = cpu; 1206 monarch_cpu = cpu;
@@ -1066,6 +1236,9 @@ ia64_mca_handler(struct pt_regs *regs, struct switch_stack *sw,
1066 rh->severity = sal_log_severity_corrected; 1236 rh->severity = sal_log_severity_corrected;
1067 ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA); 1237 ia64_sal_clear_state_info(SAL_INFO_TYPE_MCA);
1068 sos->os_status = IA64_MCA_CORRECTED; 1238 sos->os_status = IA64_MCA_CORRECTED;
1239 } else {
1240 /* Dump buffered message to console */
1241 ia64_mlogbuf_finish(1);
1069 } 1242 }
1070 if (notify_die(DIE_MCA_MONARCH_LEAVE, "MCA", regs, (long)&nd, 0, recover) 1243 if (notify_die(DIE_MCA_MONARCH_LEAVE, "MCA", regs, (long)&nd, 0, recover)
1071 == NOTIFY_STOP) 1244 == NOTIFY_STOP)
@@ -1106,9 +1279,6 @@ ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs)
1106 /* SAL spec states this should run w/ interrupts enabled */ 1279 /* SAL spec states this should run w/ interrupts enabled */
1107 local_irq_enable(); 1280 local_irq_enable();
1108 1281
1109 /* Get the CMC error record and log it */
1110 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CMC);
1111
1112 spin_lock(&cmc_history_lock); 1282 spin_lock(&cmc_history_lock);
1113 if (!cmc_polling_enabled) { 1283 if (!cmc_polling_enabled) {
1114 int i, count = 1; /* we know 1 happened now */ 1284 int i, count = 1; /* we know 1 happened now */
@@ -1141,7 +1311,7 @@ ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs)
1141 mod_timer(&cmc_poll_timer, jiffies + CMC_POLL_INTERVAL); 1311 mod_timer(&cmc_poll_timer, jiffies + CMC_POLL_INTERVAL);
1142 1312
1143 /* lock already released, get out now */ 1313 /* lock already released, get out now */
1144 return IRQ_HANDLED; 1314 goto out;
1145 } else { 1315 } else {
1146 cmc_history[index++] = now; 1316 cmc_history[index++] = now;
1147 if (index == CMC_HISTORY_LENGTH) 1317 if (index == CMC_HISTORY_LENGTH)
@@ -1149,6 +1319,10 @@ ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs)
1149 } 1319 }
1150 } 1320 }
1151 spin_unlock(&cmc_history_lock); 1321 spin_unlock(&cmc_history_lock);
1322out:
1323 /* Get the CMC error record and log it */
1324 ia64_mca_log_sal_error_record(SAL_INFO_TYPE_CMC);
1325
1152 return IRQ_HANDLED; 1326 return IRQ_HANDLED;
1153} 1327}
1154 1328
@@ -1305,6 +1479,15 @@ default_monarch_init_process(struct notifier_block *self, unsigned long val, voi
1305 struct task_struct *g, *t; 1479 struct task_struct *g, *t;
1306 if (val != DIE_INIT_MONARCH_PROCESS) 1480 if (val != DIE_INIT_MONARCH_PROCESS)
1307 return NOTIFY_DONE; 1481 return NOTIFY_DONE;
1482
1483 /*
1484 * FIXME: mlogbuf will brim over with INIT stack dumps.
1485 * To enable show_stack from INIT, we use oops_in_progress which should
1486 * be used in real oops. This would cause something wrong after INIT.
1487 */
1488 BREAK_LOGLEVEL(console_loglevel);
1489 ia64_mlogbuf_dump_from_init();
1490
1308 printk(KERN_ERR "Processes interrupted by INIT -"); 1491 printk(KERN_ERR "Processes interrupted by INIT -");
1309 for_each_online_cpu(c) { 1492 for_each_online_cpu(c) {
1310 struct ia64_sal_os_state *s; 1493 struct ia64_sal_os_state *s;
@@ -1326,6 +1509,8 @@ default_monarch_init_process(struct notifier_block *self, unsigned long val, voi
1326 } while_each_thread (g, t); 1509 } while_each_thread (g, t);
1327 read_unlock(&tasklist_lock); 1510 read_unlock(&tasklist_lock);
1328 } 1511 }
1512 /* FIXME: This will not restore zapped printk locks. */
1513 RESTORE_LOGLEVEL(console_loglevel);
1329 return NOTIFY_DONE; 1514 return NOTIFY_DONE;
1330} 1515}
1331 1516
@@ -1357,12 +1542,9 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1357 struct ia64_mca_notify_die nd = 1542 struct ia64_mca_notify_die nd =
1358 { .sos = sos, .monarch_cpu = &monarch_cpu }; 1543 { .sos = sos, .monarch_cpu = &monarch_cpu };
1359 1544
1360 oops_in_progress = 1; /* FIXME: make printk NMI/MCA/INIT safe */
1361 console_loglevel = 15; /* make sure printks make it to console */
1362
1363 (void) notify_die(DIE_INIT_ENTER, "INIT", regs, (long)&nd, 0, 0); 1545 (void) notify_die(DIE_INIT_ENTER, "INIT", regs, (long)&nd, 0, 0);
1364 1546
1365 printk(KERN_INFO "Entered OS INIT handler. PSP=%lx cpu=%d monarch=%ld\n", 1547 mprintk(KERN_INFO "Entered OS INIT handler. PSP=%lx cpu=%d monarch=%ld\n",
1366 sos->proc_state_param, cpu, sos->monarch); 1548 sos->proc_state_param, cpu, sos->monarch);
1367 salinfo_log_wakeup(SAL_INFO_TYPE_INIT, NULL, 0, 0); 1549 salinfo_log_wakeup(SAL_INFO_TYPE_INIT, NULL, 0, 0);
1368 1550
@@ -1375,7 +1557,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1375 * fix their proms and get their customers updated. 1557 * fix their proms and get their customers updated.
1376 */ 1558 */
1377 if (!sos->monarch && atomic_add_return(1, &slaves) == num_online_cpus()) { 1559 if (!sos->monarch && atomic_add_return(1, &slaves) == num_online_cpus()) {
1378 printk(KERN_WARNING "%s: Promoting cpu %d to monarch.\n", 1560 mprintk(KERN_WARNING "%s: Promoting cpu %d to monarch.\n",
1379 __FUNCTION__, cpu); 1561 __FUNCTION__, cpu);
1380 atomic_dec(&slaves); 1562 atomic_dec(&slaves);
1381 sos->monarch = 1; 1563 sos->monarch = 1;
@@ -1387,7 +1569,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1387 * fix their proms and get their customers updated. 1569 * fix their proms and get their customers updated.
1388 */ 1570 */
1389 if (sos->monarch && atomic_add_return(1, &monarchs) > 1) { 1571 if (sos->monarch && atomic_add_return(1, &monarchs) > 1) {
1390 printk(KERN_WARNING "%s: Demoting cpu %d to slave.\n", 1572 mprintk(KERN_WARNING "%s: Demoting cpu %d to slave.\n",
1391 __FUNCTION__, cpu); 1573 __FUNCTION__, cpu);
1392 atomic_dec(&monarchs); 1574 atomic_dec(&monarchs);
1393 sos->monarch = 0; 1575 sos->monarch = 0;
@@ -1408,7 +1590,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1408 if (notify_die(DIE_INIT_SLAVE_LEAVE, "INIT", regs, (long)&nd, 0, 0) 1590 if (notify_die(DIE_INIT_SLAVE_LEAVE, "INIT", regs, (long)&nd, 0, 0)
1409 == NOTIFY_STOP) 1591 == NOTIFY_STOP)
1410 ia64_mca_spin(__FUNCTION__); 1592 ia64_mca_spin(__FUNCTION__);
1411 printk("Slave on cpu %d returning to normal service.\n", cpu); 1593 mprintk("Slave on cpu %d returning to normal service.\n", cpu);
1412 set_curr_task(cpu, previous_current); 1594 set_curr_task(cpu, previous_current);
1413 ia64_mc_info.imi_rendez_checkin[cpu] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE; 1595 ia64_mc_info.imi_rendez_checkin[cpu] = IA64_MCA_RENDEZ_CHECKIN_NOTDONE;
1414 atomic_dec(&slaves); 1596 atomic_dec(&slaves);
@@ -1426,7 +1608,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1426 * same serial line, the user will need some time to switch out of the BMC before 1608 * same serial line, the user will need some time to switch out of the BMC before
1427 * the dump begins. 1609 * the dump begins.
1428 */ 1610 */
1429 printk("Delaying for 5 seconds...\n"); 1611 mprintk("Delaying for 5 seconds...\n");
1430 udelay(5*1000000); 1612 udelay(5*1000000);
1431 ia64_wait_for_slaves(cpu, "INIT"); 1613 ia64_wait_for_slaves(cpu, "INIT");
1432 /* If nobody intercepts DIE_INIT_MONARCH_PROCESS then we drop through 1614 /* If nobody intercepts DIE_INIT_MONARCH_PROCESS then we drop through
@@ -1439,7 +1621,7 @@ ia64_init_handler(struct pt_regs *regs, struct switch_stack *sw,
1439 if (notify_die(DIE_INIT_MONARCH_LEAVE, "INIT", regs, (long)&nd, 0, 0) 1621 if (notify_die(DIE_INIT_MONARCH_LEAVE, "INIT", regs, (long)&nd, 0, 0)
1440 == NOTIFY_STOP) 1622 == NOTIFY_STOP)
1441 ia64_mca_spin(__FUNCTION__); 1623 ia64_mca_spin(__FUNCTION__);
1442 printk("\nINIT dump complete. Monarch on cpu %d returning to normal service.\n", cpu); 1624 mprintk("\nINIT dump complete. Monarch on cpu %d returning to normal service.\n", cpu);
1443 atomic_dec(&monarchs); 1625 atomic_dec(&monarchs);
1444 set_curr_task(cpu, previous_current); 1626 set_curr_task(cpu, previous_current);
1445 monarch_cpu = -1; 1627 monarch_cpu = -1;
diff --git a/arch/ia64/kernel/mca_asm.S b/arch/ia64/kernel/mca_asm.S
index 96047491d1b9..c6b607c00dee 100644
--- a/arch/ia64/kernel/mca_asm.S
+++ b/arch/ia64/kernel/mca_asm.S
@@ -1025,18 +1025,13 @@ ia64_old_stack:
1025 1025
1026ia64_set_kernel_registers: 1026ia64_set_kernel_registers:
1027 add temp3=MCA_SP_OFFSET, r3 1027 add temp3=MCA_SP_OFFSET, r3
1028 add temp4=MCA_SOS_OFFSET+SOS(OS_GP), r3
1029 mov b0=r2 // save return address 1028 mov b0=r2 // save return address
1030 GET_IA64_MCA_DATA(temp1) 1029 GET_IA64_MCA_DATA(temp1)
1031 ;; 1030 ;;
1032 add temp4=temp4, temp1 // &struct ia64_sal_os_state.os_gp
1033 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack 1031 add r12=temp1, temp3 // kernel stack pointer on MCA/INIT stack
1034 add r13=temp1, r3 // set current to start of MCA/INIT stack 1032 add r13=temp1, r3 // set current to start of MCA/INIT stack
1035 add r20=temp1, r3 // physical start of MCA/INIT stack 1033 add r20=temp1, r3 // physical start of MCA/INIT stack
1036 ;; 1034 ;;
1037 ld8 r1=[temp4] // OS GP from SAL OS state
1038 ;;
1039 DATA_PA_TO_VA(r1,temp1)
1040 DATA_PA_TO_VA(r12,temp2) 1035 DATA_PA_TO_VA(r12,temp2)
1041 DATA_PA_TO_VA(r13,temp3) 1036 DATA_PA_TO_VA(r13,temp3)
1042 ;; 1037 ;;
@@ -1067,6 +1062,10 @@ ia64_set_kernel_registers:
1067 mov cr.itir=r18 1062 mov cr.itir=r18
1068 mov cr.ifa=r13 1063 mov cr.ifa=r13
1069 mov r20=IA64_TR_CURRENT_STACK 1064 mov r20=IA64_TR_CURRENT_STACK
1065
1066 movl r17=FPSR_DEFAULT
1067 ;;
1068 mov.m ar.fpsr=r17 // set ar.fpsr to kernel default value
1070 ;; 1069 ;;
1071 itr.d dtr[r20]=r21 1070 itr.d dtr[r20]=r21
1072 ;; 1071 ;;
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
index 8db6e0cedadc..a45009d2bc90 100644
--- a/arch/ia64/kernel/mca_drv.c
+++ b/arch/ia64/kernel/mca_drv.c
@@ -79,14 +79,30 @@ static int
79fatal_mca(const char *fmt, ...) 79fatal_mca(const char *fmt, ...)
80{ 80{
81 va_list args; 81 va_list args;
82 char buf[256];
82 83
83 va_start(args, fmt); 84 va_start(args, fmt);
84 vprintk(fmt, args); 85 vsnprintf(buf, sizeof(buf), fmt, args);
85 va_end(args); 86 va_end(args);
87 ia64_mca_printk(KERN_ALERT "MCA: %s\n", buf);
86 88
87 return MCA_NOT_RECOVERED; 89 return MCA_NOT_RECOVERED;
88} 90}
89 91
92static int
93mca_recovered(const char *fmt, ...)
94{
95 va_list args;
96 char buf[256];
97
98 va_start(args, fmt);
99 vsnprintf(buf, sizeof(buf), fmt, args);
100 va_end(args);
101 ia64_mca_printk(KERN_INFO "MCA: %s\n", buf);
102
103 return MCA_RECOVERED;
104}
105
90/** 106/**
91 * mca_page_isolate - isolate a poisoned page in order not to use it later 107 * mca_page_isolate - isolate a poisoned page in order not to use it later
92 * @paddr: poisoned memory location 108 * @paddr: poisoned memory location
@@ -140,6 +156,7 @@ mca_page_isolate(unsigned long paddr)
140void 156void
141mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr) 157mca_handler_bh(unsigned long paddr, void *iip, unsigned long ipsr)
142{ 158{
159 ia64_mlogbuf_dump();
143 printk(KERN_ERR "OS_MCA: process [cpu %d, pid: %d, uid: %d, " 160 printk(KERN_ERR "OS_MCA: process [cpu %d, pid: %d, uid: %d, "
144 "iip: %p, psr: 0x%lx,paddr: 0x%lx](%s) encounters MCA.\n", 161 "iip: %p, psr: 0x%lx,paddr: 0x%lx](%s) encounters MCA.\n",
145 raw_smp_processor_id(), current->pid, current->uid, 162 raw_smp_processor_id(), current->pid, current->uid,
@@ -440,7 +457,7 @@ recover_from_read_error(slidx_table_t *slidx,
440 457
441 /* Is target address valid? */ 458 /* Is target address valid? */
442 if (!pbci->tv) 459 if (!pbci->tv)
443 return fatal_mca(KERN_ALERT "MCA: target address not valid\n"); 460 return fatal_mca("target address not valid");
444 461
445 /* 462 /*
446 * cpu read or memory-mapped io read 463 * cpu read or memory-mapped io read
@@ -458,7 +475,7 @@ recover_from_read_error(slidx_table_t *slidx,
458 475
459 /* Is minstate valid? */ 476 /* Is minstate valid? */
460 if (!peidx_bottom(peidx) || !(peidx_bottom(peidx)->valid.minstate)) 477 if (!peidx_bottom(peidx) || !(peidx_bottom(peidx)->valid.minstate))
461 return fatal_mca(KERN_ALERT "MCA: minstate not valid\n"); 478 return fatal_mca("minstate not valid");
462 psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr); 479 psr1 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_ipsr);
463 psr2 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_xpsr); 480 psr2 =(struct ia64_psr *)&(peidx_minstate_area(peidx)->pmsa_xpsr);
464 481
@@ -492,13 +509,14 @@ recover_from_read_error(slidx_table_t *slidx,
492 psr2->bn = 1; 509 psr2->bn = 1;
493 psr2->i = 0; 510 psr2->i = 0;
494 511
495 return MCA_RECOVERED; 512 return mca_recovered("user memory corruption. "
513 "kill affected process - recovered.");
496 } 514 }
497 515
498 } 516 }
499 517
500 return fatal_mca(KERN_ALERT "MCA: kernel context not recovered," 518 return fatal_mca("kernel context not recovered, iip 0x%lx\n",
501 " iip 0x%lx\n", pmsa->pmsa_iip); 519 pmsa->pmsa_iip);
502} 520}
503 521
504/** 522/**
@@ -584,13 +602,13 @@ recover_from_processor_error(int platform, slidx_table_t *slidx,
584 * The machine check is corrected. 602 * The machine check is corrected.
585 */ 603 */
586 if (psp->cm == 1) 604 if (psp->cm == 1)
587 return MCA_RECOVERED; 605 return mca_recovered("machine check is already corrected.");
588 606
589 /* 607 /*
590 * The error was not contained. Software must be reset. 608 * The error was not contained. Software must be reset.
591 */ 609 */
592 if (psp->us || psp->ci == 0) 610 if (psp->us || psp->ci == 0)
593 return fatal_mca(KERN_ALERT "MCA: error not contained\n"); 611 return fatal_mca("error not contained");
594 612
595 /* 613 /*
596 * The cache check and bus check bits have four possible states 614 * The cache check and bus check bits have four possible states
@@ -601,22 +619,22 @@ recover_from_processor_error(int platform, slidx_table_t *slidx,
601 * 1 1 Memory error, attempt recovery 619 * 1 1 Memory error, attempt recovery
602 */ 620 */
603 if (psp->bc == 0 || pbci == NULL) 621 if (psp->bc == 0 || pbci == NULL)
604 return fatal_mca(KERN_ALERT "MCA: No bus check\n"); 622 return fatal_mca("No bus check");
605 623
606 /* 624 /*
607 * Sorry, we cannot handle so many. 625 * Sorry, we cannot handle so many.
608 */ 626 */
609 if (peidx_bus_check_num(peidx) > 1) 627 if (peidx_bus_check_num(peidx) > 1)
610 return fatal_mca(KERN_ALERT "MCA: Too many bus checks\n"); 628 return fatal_mca("Too many bus checks");
611 /* 629 /*
612 * Well, here is only one bus error. 630 * Well, here is only one bus error.
613 */ 631 */
614 if (pbci->ib) 632 if (pbci->ib)
615 return fatal_mca(KERN_ALERT "MCA: Internal Bus error\n"); 633 return fatal_mca("Internal Bus error");
616 if (pbci->cc) 634 if (pbci->cc)
617 return fatal_mca(KERN_ALERT "MCA: Cache-cache error\n"); 635 return fatal_mca("Cache-cache error");
618 if (pbci->eb && pbci->bsi > 0) 636 if (pbci->eb && pbci->bsi > 0)
619 return fatal_mca(KERN_ALERT "MCA: External bus check fatal status\n"); 637 return fatal_mca("External bus check fatal status");
620 638
621 /* 639 /*
622 * This is a local MCA and estimated as recoverble external bus error. 640 * This is a local MCA and estimated as recoverble external bus error.
@@ -628,7 +646,7 @@ recover_from_processor_error(int platform, slidx_table_t *slidx,
628 /* 646 /*
629 * On account of strange SAL error record, we cannot recover. 647 * On account of strange SAL error record, we cannot recover.
630 */ 648 */
631 return fatal_mca(KERN_ALERT "MCA: Strange SAL record\n"); 649 return fatal_mca("Strange SAL record");
632} 650}
633 651
634/** 652/**
@@ -657,10 +675,10 @@ mca_try_to_recover(void *rec, struct ia64_sal_os_state *sos)
657 675
658 /* Now, OS can recover when there is one processor error section */ 676 /* Now, OS can recover when there is one processor error section */
659 if (n_proc_err > 1) 677 if (n_proc_err > 1)
660 return fatal_mca(KERN_ALERT "MCA: Too Many Errors\n"); 678 return fatal_mca("Too Many Errors");
661 else if (n_proc_err == 0) 679 else if (n_proc_err == 0)
662 /* Weird SAL record ... We need not to recover */ 680 /* Weird SAL record ... We can't do anything */
663 return fatal_mca(KERN_ALERT "MCA: Weird SAL record\n"); 681 return fatal_mca("Weird SAL record");
664 682
665 /* Make index of processor error section */ 683 /* Make index of processor error section */
666 mca_make_peidx((sal_log_processor_info_t*) 684 mca_make_peidx((sal_log_processor_info_t*)
@@ -671,7 +689,7 @@ mca_try_to_recover(void *rec, struct ia64_sal_os_state *sos)
671 689
672 /* Check whether MCA is global or not */ 690 /* Check whether MCA is global or not */
673 if (is_mca_global(&peidx, &pbci, sos)) 691 if (is_mca_global(&peidx, &pbci, sos))
674 return fatal_mca(KERN_ALERT "MCA: global MCA\n"); 692 return fatal_mca("global MCA");
675 693
676 /* Try to recover a processor error */ 694 /* Try to recover a processor error */
677 return recover_from_processor_error(platform_err, &slidx, &peidx, 695 return recover_from_processor_error(platform_err, &slidx, &peidx,
diff --git a/arch/ia64/kernel/mca_drv.h b/arch/ia64/kernel/mca_drv.h
index 31a2e52bb16f..c85e943ba5fd 100644
--- a/arch/ia64/kernel/mca_drv.h
+++ b/arch/ia64/kernel/mca_drv.h
@@ -118,3 +118,7 @@ struct mca_table_entry {
118 118
119extern const struct mca_table_entry *search_mca_tables (unsigned long addr); 119extern const struct mca_table_entry *search_mca_tables (unsigned long addr);
120extern int mca_recover_range(unsigned long); 120extern int mca_recover_range(unsigned long);
121extern void ia64_mca_printk(const char * fmt, ...)
122 __attribute__ ((format (printf, 1, 2)));
123extern void ia64_mlogbuf_dump(void);
124
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c
index 7bb7696e4ce2..281004ff7b00 100644
--- a/arch/ia64/kernel/perfmon.c
+++ b/arch/ia64/kernel/perfmon.c
@@ -63,6 +63,9 @@
63 63
64#define PFM_INVALID_ACTIVATION (~0UL) 64#define PFM_INVALID_ACTIVATION (~0UL)
65 65
66#define PFM_NUM_PMC_REGS 64 /* PMC save area for ctxsw */
67#define PFM_NUM_PMD_REGS 64 /* PMD save area for ctxsw */
68
66/* 69/*
67 * depth of message queue 70 * depth of message queue
68 */ 71 */
@@ -297,14 +300,17 @@ typedef struct pfm_context {
297 unsigned long ctx_reload_pmcs[4]; /* bitmask of force reload PMC on ctxsw in */ 300 unsigned long ctx_reload_pmcs[4]; /* bitmask of force reload PMC on ctxsw in */
298 unsigned long ctx_used_monitors[4]; /* bitmask of monitor PMC being used */ 301 unsigned long ctx_used_monitors[4]; /* bitmask of monitor PMC being used */
299 302
300 unsigned long ctx_pmcs[IA64_NUM_PMC_REGS]; /* saved copies of PMC values */ 303 unsigned long ctx_pmcs[PFM_NUM_PMC_REGS]; /* saved copies of PMC values */
301 304
302 unsigned int ctx_used_ibrs[1]; /* bitmask of used IBR (speedup ctxsw in) */ 305 unsigned int ctx_used_ibrs[1]; /* bitmask of used IBR (speedup ctxsw in) */
303 unsigned int ctx_used_dbrs[1]; /* bitmask of used DBR (speedup ctxsw in) */ 306 unsigned int ctx_used_dbrs[1]; /* bitmask of used DBR (speedup ctxsw in) */
304 unsigned long ctx_dbrs[IA64_NUM_DBG_REGS]; /* DBR values (cache) when not loaded */ 307 unsigned long ctx_dbrs[IA64_NUM_DBG_REGS]; /* DBR values (cache) when not loaded */
305 unsigned long ctx_ibrs[IA64_NUM_DBG_REGS]; /* IBR values (cache) when not loaded */ 308 unsigned long ctx_ibrs[IA64_NUM_DBG_REGS]; /* IBR values (cache) when not loaded */
306 309
307 pfm_counter_t ctx_pmds[IA64_NUM_PMD_REGS]; /* software state for PMDS */ 310 pfm_counter_t ctx_pmds[PFM_NUM_PMD_REGS]; /* software state for PMDS */
311
312 unsigned long th_pmcs[PFM_NUM_PMC_REGS]; /* PMC thread save state */
313 unsigned long th_pmds[PFM_NUM_PMD_REGS]; /* PMD thread save state */
308 314
309 u64 ctx_saved_psr_up; /* only contains psr.up value */ 315 u64 ctx_saved_psr_up; /* only contains psr.up value */
310 316
@@ -868,7 +874,6 @@ static void
868pfm_mask_monitoring(struct task_struct *task) 874pfm_mask_monitoring(struct task_struct *task)
869{ 875{
870 pfm_context_t *ctx = PFM_GET_CTX(task); 876 pfm_context_t *ctx = PFM_GET_CTX(task);
871 struct thread_struct *th = &task->thread;
872 unsigned long mask, val, ovfl_mask; 877 unsigned long mask, val, ovfl_mask;
873 int i; 878 int i;
874 879
@@ -889,7 +894,7 @@ pfm_mask_monitoring(struct task_struct *task)
889 * So in both cases, the live register contains the owner's 894 * So in both cases, the live register contains the owner's
890 * state. We can ONLY touch the PMU registers and NOT the PSR. 895 * state. We can ONLY touch the PMU registers and NOT the PSR.
891 * 896 *
892 * As a consequence to this call, the thread->pmds[] array 897 * As a consequence to this call, the ctx->th_pmds[] array
893 * contains stale information which must be ignored 898 * contains stale information which must be ignored
894 * when context is reloaded AND monitoring is active (see 899 * when context is reloaded AND monitoring is active (see
895 * pfm_restart). 900 * pfm_restart).
@@ -924,9 +929,9 @@ pfm_mask_monitoring(struct task_struct *task)
924 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; 929 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
925 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { 930 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
926 if ((mask & 0x1) == 0UL) continue; 931 if ((mask & 0x1) == 0UL) continue;
927 ia64_set_pmc(i, th->pmcs[i] & ~0xfUL); 932 ia64_set_pmc(i, ctx->th_pmcs[i] & ~0xfUL);
928 th->pmcs[i] &= ~0xfUL; 933 ctx->th_pmcs[i] &= ~0xfUL;
929 DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, th->pmcs[i])); 934 DPRINT_ovfl(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i]));
930 } 935 }
931 /* 936 /*
932 * make all of this visible 937 * make all of this visible
@@ -943,7 +948,6 @@ static void
943pfm_restore_monitoring(struct task_struct *task) 948pfm_restore_monitoring(struct task_struct *task)
944{ 949{
945 pfm_context_t *ctx = PFM_GET_CTX(task); 950 pfm_context_t *ctx = PFM_GET_CTX(task);
946 struct thread_struct *th = &task->thread;
947 unsigned long mask, ovfl_mask; 951 unsigned long mask, ovfl_mask;
948 unsigned long psr, val; 952 unsigned long psr, val;
949 int i, is_system; 953 int i, is_system;
@@ -1009,9 +1013,9 @@ pfm_restore_monitoring(struct task_struct *task)
1009 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER; 1013 mask = ctx->ctx_used_monitors[0] >> PMU_FIRST_COUNTER;
1010 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) { 1014 for(i= PMU_FIRST_COUNTER; mask; i++, mask>>=1) {
1011 if ((mask & 0x1) == 0UL) continue; 1015 if ((mask & 0x1) == 0UL) continue;
1012 th->pmcs[i] = ctx->ctx_pmcs[i]; 1016 ctx->th_pmcs[i] = ctx->ctx_pmcs[i];
1013 ia64_set_pmc(i, th->pmcs[i]); 1017 ia64_set_pmc(i, ctx->th_pmcs[i]);
1014 DPRINT(("[%d] pmc[%d]=0x%lx\n", task->pid, i, th->pmcs[i])); 1018 DPRINT(("[%d] pmc[%d]=0x%lx\n", task->pid, i, ctx->th_pmcs[i]));
1015 } 1019 }
1016 ia64_srlz_d(); 1020 ia64_srlz_d();
1017 1021
@@ -1070,7 +1074,6 @@ pfm_restore_pmds(unsigned long *pmds, unsigned long mask)
1070static inline void 1074static inline void
1071pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx) 1075pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1072{ 1076{
1073 struct thread_struct *thread = &task->thread;
1074 unsigned long ovfl_val = pmu_conf->ovfl_val; 1077 unsigned long ovfl_val = pmu_conf->ovfl_val;
1075 unsigned long mask = ctx->ctx_all_pmds[0]; 1078 unsigned long mask = ctx->ctx_all_pmds[0];
1076 unsigned long val; 1079 unsigned long val;
@@ -1092,11 +1095,11 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1092 ctx->ctx_pmds[i].val = val & ~ovfl_val; 1095 ctx->ctx_pmds[i].val = val & ~ovfl_val;
1093 val &= ovfl_val; 1096 val &= ovfl_val;
1094 } 1097 }
1095 thread->pmds[i] = val; 1098 ctx->th_pmds[i] = val;
1096 1099
1097 DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n", 1100 DPRINT(("pmd[%d]=0x%lx soft_val=0x%lx\n",
1098 i, 1101 i,
1099 thread->pmds[i], 1102 ctx->th_pmds[i],
1100 ctx->ctx_pmds[i].val)); 1103 ctx->ctx_pmds[i].val));
1101 } 1104 }
1102} 1105}
@@ -1107,7 +1110,6 @@ pfm_copy_pmds(struct task_struct *task, pfm_context_t *ctx)
1107static inline void 1110static inline void
1108pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx) 1111pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx)
1109{ 1112{
1110 struct thread_struct *thread = &task->thread;
1111 unsigned long mask = ctx->ctx_all_pmcs[0]; 1113 unsigned long mask = ctx->ctx_all_pmcs[0];
1112 int i; 1114 int i;
1113 1115
@@ -1115,8 +1117,8 @@ pfm_copy_pmcs(struct task_struct *task, pfm_context_t *ctx)
1115 1117
1116 for (i=0; mask; i++, mask>>=1) { 1118 for (i=0; mask; i++, mask>>=1) {
1117 /* masking 0 with ovfl_val yields 0 */ 1119 /* masking 0 with ovfl_val yields 0 */
1118 thread->pmcs[i] = ctx->ctx_pmcs[i]; 1120 ctx->th_pmcs[i] = ctx->ctx_pmcs[i];
1119 DPRINT(("pmc[%d]=0x%lx\n", i, thread->pmcs[i])); 1121 DPRINT(("pmc[%d]=0x%lx\n", i, ctx->th_pmcs[i]));
1120 } 1122 }
1121} 1123}
1122 1124
@@ -2860,7 +2862,6 @@ pfm_reset_regs(pfm_context_t *ctx, unsigned long *ovfl_regs, int is_long_reset)
2860static int 2862static int
2861pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 2863pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
2862{ 2864{
2863 struct thread_struct *thread = NULL;
2864 struct task_struct *task; 2865 struct task_struct *task;
2865 pfarg_reg_t *req = (pfarg_reg_t *)arg; 2866 pfarg_reg_t *req = (pfarg_reg_t *)arg;
2866 unsigned long value, pmc_pm; 2867 unsigned long value, pmc_pm;
@@ -2881,7 +2882,6 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
2881 if (state == PFM_CTX_ZOMBIE) return -EINVAL; 2882 if (state == PFM_CTX_ZOMBIE) return -EINVAL;
2882 2883
2883 if (is_loaded) { 2884 if (is_loaded) {
2884 thread = &task->thread;
2885 /* 2885 /*
2886 * In system wide and when the context is loaded, access can only happen 2886 * In system wide and when the context is loaded, access can only happen
2887 * when the caller is running on the CPU being monitored by the session. 2887 * when the caller is running on the CPU being monitored by the session.
@@ -3036,7 +3036,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3036 * 3036 *
3037 * The value in ctx_pmcs[] can only be changed in pfm_write_pmcs(). 3037 * The value in ctx_pmcs[] can only be changed in pfm_write_pmcs().
3038 * 3038 *
3039 * The value in thread->pmcs[] may be modified on overflow, i.e., when 3039 * The value in th_pmcs[] may be modified on overflow, i.e., when
3040 * monitoring needs to be stopped. 3040 * monitoring needs to be stopped.
3041 */ 3041 */
3042 if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum); 3042 if (is_monitor) CTX_USED_MONITOR(ctx, 1UL << cnum);
@@ -3050,7 +3050,7 @@ pfm_write_pmcs(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3050 /* 3050 /*
3051 * write thread state 3051 * write thread state
3052 */ 3052 */
3053 if (is_system == 0) thread->pmcs[cnum] = value; 3053 if (is_system == 0) ctx->th_pmcs[cnum] = value;
3054 3054
3055 /* 3055 /*
3056 * write hardware register if we can 3056 * write hardware register if we can
@@ -3102,7 +3102,6 @@ error:
3102static int 3102static int
3103pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 3103pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3104{ 3104{
3105 struct thread_struct *thread = NULL;
3106 struct task_struct *task; 3105 struct task_struct *task;
3107 pfarg_reg_t *req = (pfarg_reg_t *)arg; 3106 pfarg_reg_t *req = (pfarg_reg_t *)arg;
3108 unsigned long value, hw_value, ovfl_mask; 3107 unsigned long value, hw_value, ovfl_mask;
@@ -3126,7 +3125,6 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3126 * the owner of the local PMU. 3125 * the owner of the local PMU.
3127 */ 3126 */
3128 if (likely(is_loaded)) { 3127 if (likely(is_loaded)) {
3129 thread = &task->thread;
3130 /* 3128 /*
3131 * In system wide and when the context is loaded, access can only happen 3129 * In system wide and when the context is loaded, access can only happen
3132 * when the caller is running on the CPU being monitored by the session. 3130 * when the caller is running on the CPU being monitored by the session.
@@ -3234,7 +3232,7 @@ pfm_write_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3234 /* 3232 /*
3235 * write thread state 3233 * write thread state
3236 */ 3234 */
3237 if (is_system == 0) thread->pmds[cnum] = hw_value; 3235 if (is_system == 0) ctx->th_pmds[cnum] = hw_value;
3238 3236
3239 /* 3237 /*
3240 * write hardware register if we can 3238 * write hardware register if we can
@@ -3300,7 +3298,6 @@ abort_mission:
3300static int 3298static int
3301pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs) 3299pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3302{ 3300{
3303 struct thread_struct *thread = NULL;
3304 struct task_struct *task; 3301 struct task_struct *task;
3305 unsigned long val = 0UL, lval, ovfl_mask, sval; 3302 unsigned long val = 0UL, lval, ovfl_mask, sval;
3306 pfarg_reg_t *req = (pfarg_reg_t *)arg; 3303 pfarg_reg_t *req = (pfarg_reg_t *)arg;
@@ -3324,7 +3321,6 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3324 if (state == PFM_CTX_ZOMBIE) return -EINVAL; 3321 if (state == PFM_CTX_ZOMBIE) return -EINVAL;
3325 3322
3326 if (likely(is_loaded)) { 3323 if (likely(is_loaded)) {
3327 thread = &task->thread;
3328 /* 3324 /*
3329 * In system wide and when the context is loaded, access can only happen 3325 * In system wide and when the context is loaded, access can only happen
3330 * when the caller is running on the CPU being monitored by the session. 3326 * when the caller is running on the CPU being monitored by the session.
@@ -3386,7 +3382,7 @@ pfm_read_pmds(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
3386 * if context is zombie, then task does not exist anymore. 3382 * if context is zombie, then task does not exist anymore.
3387 * In this case, we use the full value saved in the context (pfm_flush_regs()). 3383 * In this case, we use the full value saved in the context (pfm_flush_regs()).
3388 */ 3384 */
3389 val = is_loaded ? thread->pmds[cnum] : 0UL; 3385 val = is_loaded ? ctx->th_pmds[cnum] : 0UL;
3390 } 3386 }
3391 rd_func = pmu_conf->pmd_desc[cnum].read_check; 3387 rd_func = pmu_conf->pmd_desc[cnum].read_check;
3392 3388
@@ -4355,8 +4351,8 @@ pfm_context_load(pfm_context_t *ctx, void *arg, int count, struct pt_regs *regs)
4355 pfm_copy_pmds(task, ctx); 4351 pfm_copy_pmds(task, ctx);
4356 pfm_copy_pmcs(task, ctx); 4352 pfm_copy_pmcs(task, ctx);
4357 4353
4358 pmcs_source = thread->pmcs; 4354 pmcs_source = ctx->th_pmcs;
4359 pmds_source = thread->pmds; 4355 pmds_source = ctx->th_pmds;
4360 4356
4361 /* 4357 /*
4362 * always the case for system-wide 4358 * always the case for system-wide
@@ -5865,14 +5861,12 @@ void
5865pfm_save_regs(struct task_struct *task) 5861pfm_save_regs(struct task_struct *task)
5866{ 5862{
5867 pfm_context_t *ctx; 5863 pfm_context_t *ctx;
5868 struct thread_struct *t;
5869 unsigned long flags; 5864 unsigned long flags;
5870 u64 psr; 5865 u64 psr;
5871 5866
5872 5867
5873 ctx = PFM_GET_CTX(task); 5868 ctx = PFM_GET_CTX(task);
5874 if (ctx == NULL) return; 5869 if (ctx == NULL) return;
5875 t = &task->thread;
5876 5870
5877 /* 5871 /*
5878 * we always come here with interrupts ALREADY disabled by 5872 * we always come here with interrupts ALREADY disabled by
@@ -5930,19 +5924,19 @@ pfm_save_regs(struct task_struct *task)
5930 * guarantee we will be schedule at that same 5924 * guarantee we will be schedule at that same
5931 * CPU again. 5925 * CPU again.
5932 */ 5926 */
5933 pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); 5927 pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]);
5934 5928
5935 /* 5929 /*
5936 * save pmc0 ia64_srlz_d() done in pfm_save_pmds() 5930 * save pmc0 ia64_srlz_d() done in pfm_save_pmds()
5937 * we will need it on the restore path to check 5931 * we will need it on the restore path to check
5938 * for pending overflow. 5932 * for pending overflow.
5939 */ 5933 */
5940 t->pmcs[0] = ia64_get_pmc(0); 5934 ctx->th_pmcs[0] = ia64_get_pmc(0);
5941 5935
5942 /* 5936 /*
5943 * unfreeze PMU if had pending overflows 5937 * unfreeze PMU if had pending overflows
5944 */ 5938 */
5945 if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); 5939 if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu();
5946 5940
5947 /* 5941 /*
5948 * finally, allow context access. 5942 * finally, allow context access.
@@ -5987,7 +5981,6 @@ static void
5987pfm_lazy_save_regs (struct task_struct *task) 5981pfm_lazy_save_regs (struct task_struct *task)
5988{ 5982{
5989 pfm_context_t *ctx; 5983 pfm_context_t *ctx;
5990 struct thread_struct *t;
5991 unsigned long flags; 5984 unsigned long flags;
5992 5985
5993 { u64 psr = pfm_get_psr(); 5986 { u64 psr = pfm_get_psr();
@@ -5995,7 +5988,6 @@ pfm_lazy_save_regs (struct task_struct *task)
5995 } 5988 }
5996 5989
5997 ctx = PFM_GET_CTX(task); 5990 ctx = PFM_GET_CTX(task);
5998 t = &task->thread;
5999 5991
6000 /* 5992 /*
6001 * we need to mask PMU overflow here to 5993 * we need to mask PMU overflow here to
@@ -6020,19 +6012,19 @@ pfm_lazy_save_regs (struct task_struct *task)
6020 /* 6012 /*
6021 * save all the pmds we use 6013 * save all the pmds we use
6022 */ 6014 */
6023 pfm_save_pmds(t->pmds, ctx->ctx_used_pmds[0]); 6015 pfm_save_pmds(ctx->th_pmds, ctx->ctx_used_pmds[0]);
6024 6016
6025 /* 6017 /*
6026 * save pmc0 ia64_srlz_d() done in pfm_save_pmds() 6018 * save pmc0 ia64_srlz_d() done in pfm_save_pmds()
6027 * it is needed to check for pended overflow 6019 * it is needed to check for pended overflow
6028 * on the restore path 6020 * on the restore path
6029 */ 6021 */
6030 t->pmcs[0] = ia64_get_pmc(0); 6022 ctx->th_pmcs[0] = ia64_get_pmc(0);
6031 6023
6032 /* 6024 /*
6033 * unfreeze PMU if had pending overflows 6025 * unfreeze PMU if had pending overflows
6034 */ 6026 */
6035 if (t->pmcs[0] & ~0x1UL) pfm_unfreeze_pmu(); 6027 if (ctx->th_pmcs[0] & ~0x1UL) pfm_unfreeze_pmu();
6036 6028
6037 /* 6029 /*
6038 * now get can unmask PMU interrupts, they will 6030 * now get can unmask PMU interrupts, they will
@@ -6051,7 +6043,6 @@ void
6051pfm_load_regs (struct task_struct *task) 6043pfm_load_regs (struct task_struct *task)
6052{ 6044{
6053 pfm_context_t *ctx; 6045 pfm_context_t *ctx;
6054 struct thread_struct *t;
6055 unsigned long pmc_mask = 0UL, pmd_mask = 0UL; 6046 unsigned long pmc_mask = 0UL, pmd_mask = 0UL;
6056 unsigned long flags; 6047 unsigned long flags;
6057 u64 psr, psr_up; 6048 u64 psr, psr_up;
@@ -6062,11 +6053,10 @@ pfm_load_regs (struct task_struct *task)
6062 6053
6063 BUG_ON(GET_PMU_OWNER()); 6054 BUG_ON(GET_PMU_OWNER());
6064 6055
6065 t = &task->thread;
6066 /* 6056 /*
6067 * possible on unload 6057 * possible on unload
6068 */ 6058 */
6069 if (unlikely((t->flags & IA64_THREAD_PM_VALID) == 0)) return; 6059 if (unlikely((task->thread.flags & IA64_THREAD_PM_VALID) == 0)) return;
6070 6060
6071 /* 6061 /*
6072 * we always come here with interrupts ALREADY disabled by 6062 * we always come here with interrupts ALREADY disabled by
@@ -6148,21 +6138,21 @@ pfm_load_regs (struct task_struct *task)
6148 * 6138 *
6149 * XXX: optimize here 6139 * XXX: optimize here
6150 */ 6140 */
6151 if (pmd_mask) pfm_restore_pmds(t->pmds, pmd_mask); 6141 if (pmd_mask) pfm_restore_pmds(ctx->th_pmds, pmd_mask);
6152 if (pmc_mask) pfm_restore_pmcs(t->pmcs, pmc_mask); 6142 if (pmc_mask) pfm_restore_pmcs(ctx->th_pmcs, pmc_mask);
6153 6143
6154 /* 6144 /*
6155 * check for pending overflow at the time the state 6145 * check for pending overflow at the time the state
6156 * was saved. 6146 * was saved.
6157 */ 6147 */
6158 if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { 6148 if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) {
6159 /* 6149 /*
6160 * reload pmc0 with the overflow information 6150 * reload pmc0 with the overflow information
6161 * On McKinley PMU, this will trigger a PMU interrupt 6151 * On McKinley PMU, this will trigger a PMU interrupt
6162 */ 6152 */
6163 ia64_set_pmc(0, t->pmcs[0]); 6153 ia64_set_pmc(0, ctx->th_pmcs[0]);
6164 ia64_srlz_d(); 6154 ia64_srlz_d();
6165 t->pmcs[0] = 0UL; 6155 ctx->th_pmcs[0] = 0UL;
6166 6156
6167 /* 6157 /*
6168 * will replay the PMU interrupt 6158 * will replay the PMU interrupt
@@ -6215,7 +6205,6 @@ pfm_load_regs (struct task_struct *task)
6215void 6205void
6216pfm_load_regs (struct task_struct *task) 6206pfm_load_regs (struct task_struct *task)
6217{ 6207{
6218 struct thread_struct *t;
6219 pfm_context_t *ctx; 6208 pfm_context_t *ctx;
6220 struct task_struct *owner; 6209 struct task_struct *owner;
6221 unsigned long pmd_mask, pmc_mask; 6210 unsigned long pmd_mask, pmc_mask;
@@ -6224,7 +6213,6 @@ pfm_load_regs (struct task_struct *task)
6224 6213
6225 owner = GET_PMU_OWNER(); 6214 owner = GET_PMU_OWNER();
6226 ctx = PFM_GET_CTX(task); 6215 ctx = PFM_GET_CTX(task);
6227 t = &task->thread;
6228 psr = pfm_get_psr(); 6216 psr = pfm_get_psr();
6229 6217
6230 BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP)); 6218 BUG_ON(psr & (IA64_PSR_UP|IA64_PSR_PP));
@@ -6287,22 +6275,22 @@ pfm_load_regs (struct task_struct *task)
6287 */ 6275 */
6288 pmc_mask = ctx->ctx_all_pmcs[0]; 6276 pmc_mask = ctx->ctx_all_pmcs[0];
6289 6277
6290 pfm_restore_pmds(t->pmds, pmd_mask); 6278 pfm_restore_pmds(ctx->th_pmds, pmd_mask);
6291 pfm_restore_pmcs(t->pmcs, pmc_mask); 6279 pfm_restore_pmcs(ctx->th_pmcs, pmc_mask);
6292 6280
6293 /* 6281 /*
6294 * check for pending overflow at the time the state 6282 * check for pending overflow at the time the state
6295 * was saved. 6283 * was saved.
6296 */ 6284 */
6297 if (unlikely(PMC0_HAS_OVFL(t->pmcs[0]))) { 6285 if (unlikely(PMC0_HAS_OVFL(ctx->th_pmcs[0]))) {
6298 /* 6286 /*
6299 * reload pmc0 with the overflow information 6287 * reload pmc0 with the overflow information
6300 * On McKinley PMU, this will trigger a PMU interrupt 6288 * On McKinley PMU, this will trigger a PMU interrupt
6301 */ 6289 */
6302 ia64_set_pmc(0, t->pmcs[0]); 6290 ia64_set_pmc(0, ctx->th_pmcs[0]);
6303 ia64_srlz_d(); 6291 ia64_srlz_d();
6304 6292
6305 t->pmcs[0] = 0UL; 6293 ctx->th_pmcs[0] = 0UL;
6306 6294
6307 /* 6295 /*
6308 * will replay the PMU interrupt 6296 * will replay the PMU interrupt
@@ -6377,11 +6365,11 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6377 */ 6365 */
6378 pfm_unfreeze_pmu(); 6366 pfm_unfreeze_pmu();
6379 } else { 6367 } else {
6380 pmc0 = task->thread.pmcs[0]; 6368 pmc0 = ctx->th_pmcs[0];
6381 /* 6369 /*
6382 * clear whatever overflow status bits there were 6370 * clear whatever overflow status bits there were
6383 */ 6371 */
6384 task->thread.pmcs[0] = 0; 6372 ctx->th_pmcs[0] = 0;
6385 } 6373 }
6386 ovfl_val = pmu_conf->ovfl_val; 6374 ovfl_val = pmu_conf->ovfl_val;
6387 /* 6375 /*
@@ -6402,7 +6390,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6402 /* 6390 /*
6403 * can access PMU always true in system wide mode 6391 * can access PMU always true in system wide mode
6404 */ 6392 */
6405 val = pmd_val = can_access_pmu ? ia64_get_pmd(i) : task->thread.pmds[i]; 6393 val = pmd_val = can_access_pmu ? ia64_get_pmd(i) : ctx->th_pmds[i];
6406 6394
6407 if (PMD_IS_COUNTING(i)) { 6395 if (PMD_IS_COUNTING(i)) {
6408 DPRINT(("[%d] pmd[%d] ctx_pmd=0x%lx hw_pmd=0x%lx\n", 6396 DPRINT(("[%d] pmd[%d] ctx_pmd=0x%lx hw_pmd=0x%lx\n",
@@ -6434,7 +6422,7 @@ pfm_flush_pmds(struct task_struct *task, pfm_context_t *ctx)
6434 6422
6435 DPRINT(("[%d] ctx_pmd[%d]=0x%lx pmd_val=0x%lx\n", task->pid, i, val, pmd_val)); 6423 DPRINT(("[%d] ctx_pmd[%d]=0x%lx pmd_val=0x%lx\n", task->pid, i, val, pmd_val));
6436 6424
6437 if (is_self) task->thread.pmds[i] = pmd_val; 6425 if (is_self) ctx->th_pmds[i] = pmd_val;
6438 6426
6439 ctx->ctx_pmds[i].val = val; 6427 ctx->ctx_pmds[i].val = val;
6440 } 6428 }
@@ -6678,7 +6666,7 @@ pfm_init(void)
6678 ffz(pmu_conf->ovfl_val)); 6666 ffz(pmu_conf->ovfl_val));
6679 6667
6680 /* sanity check */ 6668 /* sanity check */
6681 if (pmu_conf->num_pmds >= IA64_NUM_PMD_REGS || pmu_conf->num_pmcs >= IA64_NUM_PMC_REGS) { 6669 if (pmu_conf->num_pmds >= PFM_NUM_PMD_REGS || pmu_conf->num_pmcs >= PFM_NUM_PMC_REGS) {
6682 printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n"); 6670 printk(KERN_ERR "perfmon: not enough pmc/pmd, perfmon disabled\n");
6683 pmu_conf = NULL; 6671 pmu_conf = NULL;
6684 return -1; 6672 return -1;
@@ -6753,7 +6741,6 @@ void
6753dump_pmu_state(const char *from) 6741dump_pmu_state(const char *from)
6754{ 6742{
6755 struct task_struct *task; 6743 struct task_struct *task;
6756 struct thread_struct *t;
6757 struct pt_regs *regs; 6744 struct pt_regs *regs;
6758 pfm_context_t *ctx; 6745 pfm_context_t *ctx;
6759 unsigned long psr, dcr, info, flags; 6746 unsigned long psr, dcr, info, flags;
@@ -6798,16 +6785,14 @@ dump_pmu_state(const char *from)
6798 ia64_psr(regs)->up = 0; 6785 ia64_psr(regs)->up = 0;
6799 ia64_psr(regs)->pp = 0; 6786 ia64_psr(regs)->pp = 0;
6800 6787
6801 t = &current->thread;
6802
6803 for (i=1; PMC_IS_LAST(i) == 0; i++) { 6788 for (i=1; PMC_IS_LAST(i) == 0; i++) {
6804 if (PMC_IS_IMPL(i) == 0) continue; 6789 if (PMC_IS_IMPL(i) == 0) continue;
6805 printk("->CPU%d pmc[%d]=0x%lx thread_pmc[%d]=0x%lx\n", this_cpu, i, ia64_get_pmc(i), i, t->pmcs[i]); 6790 printk("->CPU%d pmc[%d]=0x%lx thread_pmc[%d]=0x%lx\n", this_cpu, i, ia64_get_pmc(i), i, ctx->th_pmcs[i]);
6806 } 6791 }
6807 6792
6808 for (i=1; PMD_IS_LAST(i) == 0; i++) { 6793 for (i=1; PMD_IS_LAST(i) == 0; i++) {
6809 if (PMD_IS_IMPL(i) == 0) continue; 6794 if (PMD_IS_IMPL(i) == 0) continue;
6810 printk("->CPU%d pmd[%d]=0x%lx thread_pmd[%d]=0x%lx\n", this_cpu, i, ia64_get_pmd(i), i, t->pmds[i]); 6795 printk("->CPU%d pmd[%d]=0x%lx thread_pmd[%d]=0x%lx\n", this_cpu, i, ia64_get_pmd(i), i, ctx->th_pmds[i]);
6811 } 6796 }
6812 6797
6813 if (ctx) { 6798 if (ctx) {
diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
index 9065f0f01ba3..e63b8ca5344a 100644
--- a/arch/ia64/kernel/salinfo.c
+++ b/arch/ia64/kernel/salinfo.c
@@ -266,6 +266,7 @@ salinfo_log_wakeup(int type, u8 *buffer, u64 size, int irqsafe)
266/* Check for outstanding MCA/INIT records every minute (arbitrary) */ 266/* Check for outstanding MCA/INIT records every minute (arbitrary) */
267#define SALINFO_TIMER_DELAY (60*HZ) 267#define SALINFO_TIMER_DELAY (60*HZ)
268static struct timer_list salinfo_timer; 268static struct timer_list salinfo_timer;
269extern void ia64_mlogbuf_dump(void);
269 270
270static void 271static void
271salinfo_timeout_check(struct salinfo_data *data) 272salinfo_timeout_check(struct salinfo_data *data)
@@ -283,6 +284,7 @@ salinfo_timeout_check(struct salinfo_data *data)
283static void 284static void
284salinfo_timeout (unsigned long arg) 285salinfo_timeout (unsigned long arg)
285{ 286{
287 ia64_mlogbuf_dump();
286 salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA); 288 salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_MCA);
287 salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_INIT); 289 salinfo_timeout_check(salinfo_data + SAL_INFO_TYPE_INIT);
288 salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY; 290 salinfo_timer.expires = jiffies + SALINFO_TIMER_DELAY;
@@ -332,6 +334,8 @@ retry:
332 if (cpu == -1) 334 if (cpu == -1)
333 goto retry; 335 goto retry;
334 336
337 ia64_mlogbuf_dump();
338
335 /* for next read, start checking at next CPU */ 339 /* for next read, start checking at next CPU */
336 data->cpu_check = cpu; 340 data->cpu_check = cpu;
337 if (++data->cpu_check == NR_CPUS) 341 if (++data->cpu_check == NR_CPUS)
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index 7ad0d9cc6db6..84f93c0f2c66 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -509,7 +509,7 @@ show_cpuinfo (struct seq_file *m, void *v)
509 { 1UL << 1, "spontaneous deferral"}, 509 { 1UL << 1, "spontaneous deferral"},
510 { 1UL << 2, "16-byte atomic ops" } 510 { 1UL << 2, "16-byte atomic ops" }
511 }; 511 };
512 char family[32], features[128], *cp, sep; 512 char features[128], *cp, sep;
513 struct cpuinfo_ia64 *c = v; 513 struct cpuinfo_ia64 *c = v;
514 unsigned long mask; 514 unsigned long mask;
515 unsigned long proc_freq; 515 unsigned long proc_freq;
@@ -517,12 +517,6 @@ show_cpuinfo (struct seq_file *m, void *v)
517 517
518 mask = c->features; 518 mask = c->features;
519 519
520 switch (c->family) {
521 case 0x07: memcpy(family, "Itanium", 8); break;
522 case 0x1f: memcpy(family, "Itanium 2", 10); break;
523 default: sprintf(family, "%u", c->family); break;
524 }
525
526 /* build the feature string: */ 520 /* build the feature string: */
527 memcpy(features, " standard", 10); 521 memcpy(features, " standard", 10);
528 cp = features; 522 cp = features;
@@ -553,8 +547,9 @@ show_cpuinfo (struct seq_file *m, void *v)
553 "processor : %d\n" 547 "processor : %d\n"
554 "vendor : %s\n" 548 "vendor : %s\n"
555 "arch : IA-64\n" 549 "arch : IA-64\n"
556 "family : %s\n" 550 "family : %u\n"
557 "model : %u\n" 551 "model : %u\n"
552 "model name : %s\n"
558 "revision : %u\n" 553 "revision : %u\n"
559 "archrev : %u\n" 554 "archrev : %u\n"
560 "features :%s\n" /* don't change this---it _is_ right! */ 555 "features :%s\n" /* don't change this---it _is_ right! */
@@ -563,7 +558,8 @@ show_cpuinfo (struct seq_file *m, void *v)
563 "cpu MHz : %lu.%06lu\n" 558 "cpu MHz : %lu.%06lu\n"
564 "itc MHz : %lu.%06lu\n" 559 "itc MHz : %lu.%06lu\n"
565 "BogoMIPS : %lu.%02lu\n", 560 "BogoMIPS : %lu.%02lu\n",
566 cpunum, c->vendor, family, c->model, c->revision, c->archrev, 561 cpunum, c->vendor, c->family, c->model,
562 c->model_name, c->revision, c->archrev,
567 features, c->ppn, c->number, 563 features, c->ppn, c->number,
568 proc_freq / 1000, proc_freq % 1000, 564 proc_freq / 1000, proc_freq % 1000,
569 c->itc_freq / 1000000, c->itc_freq % 1000000, 565 c->itc_freq / 1000000, c->itc_freq % 1000000,
@@ -611,6 +607,31 @@ struct seq_operations cpuinfo_op = {
611 .show = show_cpuinfo 607 .show = show_cpuinfo
612}; 608};
613 609
610static char brandname[128];
611
612static char * __cpuinit
613get_model_name(__u8 family, __u8 model)
614{
615 char brand[128];
616
617 if (ia64_pal_get_brand_info(brand)) {
618 if (family == 0x7)
619 memcpy(brand, "Merced", 7);
620 else if (family == 0x1f) switch (model) {
621 case 0: memcpy(brand, "McKinley", 9); break;
622 case 1: memcpy(brand, "Madison", 8); break;
623 case 2: memcpy(brand, "Madison up to 9M cache", 23); break;
624 } else
625 memcpy(brand, "Unknown", 8);
626 }
627 if (brandname[0] == '\0')
628 return strcpy(brandname, brand);
629 else if (strcmp(brandname, brand) == 0)
630 return brandname;
631 else
632 return kstrdup(brand, GFP_KERNEL);
633}
634
614static void __cpuinit 635static void __cpuinit
615identify_cpu (struct cpuinfo_ia64 *c) 636identify_cpu (struct cpuinfo_ia64 *c)
616{ 637{
@@ -640,7 +661,6 @@ identify_cpu (struct cpuinfo_ia64 *c)
640 pal_status_t status; 661 pal_status_t status;
641 unsigned long impl_va_msb = 50, phys_addr_size = 44; /* Itanium defaults */ 662 unsigned long impl_va_msb = 50, phys_addr_size = 44; /* Itanium defaults */
642 int i; 663 int i;
643
644 for (i = 0; i < 5; ++i) 664 for (i = 0; i < 5; ++i)
645 cpuid.bits[i] = ia64_get_cpuid(i); 665 cpuid.bits[i] = ia64_get_cpuid(i);
646 666
@@ -663,6 +683,7 @@ identify_cpu (struct cpuinfo_ia64 *c)
663 c->family = cpuid.field.family; 683 c->family = cpuid.field.family;
664 c->archrev = cpuid.field.archrev; 684 c->archrev = cpuid.field.archrev;
665 c->features = cpuid.field.features; 685 c->features = cpuid.field.features;
686 c->model_name = get_model_name(c->family, c->model);
666 687
667 status = ia64_pal_vm_summary(&vm1, &vm2); 688 status = ia64_pal_vm_summary(&vm1, &vm2);
668 if (status == PAL_STATUS_SUCCESS) { 689 if (status == PAL_STATUS_SUCCESS) {
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c
index 6203ed4ec8cf..f7d7f5668144 100644
--- a/arch/ia64/kernel/smpboot.c
+++ b/arch/ia64/kernel/smpboot.c
@@ -879,3 +879,27 @@ identify_siblings(struct cpuinfo_ia64 *c)
879 c->core_id = info.log1_cid; 879 c->core_id = info.log1_cid;
880 c->thread_id = info.log1_tid; 880 c->thread_id = info.log1_tid;
881} 881}
882
883/*
884 * returns non zero, if multi-threading is enabled
885 * on at least one physical package. Due to hotplug cpu
886 * and (maxcpus=), all threads may not necessarily be enabled
887 * even though the processor supports multi-threading.
888 */
889int is_multithreading_enabled(void)
890{
891 int i, j;
892
893 for_each_present_cpu(i) {
894 for_each_present_cpu(j) {
895 if (j == i)
896 continue;
897 if ((cpu_data(j)->socket_id == cpu_data(i)->socket_id)) {
898 if (cpu_data(j)->core_id == cpu_data(i)->core_id)
899 return 1;
900 }
901 }
902 }
903 return 0;
904}
905EXPORT_SYMBOL_GPL(is_multithreading_enabled);
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index 05bdf7affb43..5629b45e89c6 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -36,10 +36,8 @@ int arch_register_cpu(int num)
36 */ 36 */
37 if (!can_cpei_retarget() && is_cpu_cpei_target(num)) 37 if (!can_cpei_retarget() && is_cpu_cpei_target(num))
38 sysfs_cpus[num].cpu.no_control = 1; 38 sysfs_cpus[num].cpu.no_control = 1;
39#ifdef CONFIG_NUMA
40 map_cpu_to_node(num, node_cpuid[num].nid); 39 map_cpu_to_node(num, node_cpuid[num].nid);
41#endif 40#endif
42#endif
43 41
44 return register_cpu(&sysfs_cpus[num].cpu, num); 42 return register_cpu(&sysfs_cpus[num].cpu, num);
45} 43}
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 5b0d5f64a9b1..b3b2e389d6b2 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -184,7 +184,9 @@ SECTIONS
184 *(.data.gate) 184 *(.data.gate)
185 __stop_gate_section = .; 185 __stop_gate_section = .;
186 } 186 }
187 . = ALIGN(PAGE_SIZE); /* make sure the gate page doesn't expose kernel data */ 187 . = ALIGN(PAGE_SIZE); /* make sure the gate page doesn't expose
188 * kernel data
189 */
188 190
189 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) 191 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET)
190 { *(.data.read_mostly) } 192 { *(.data.read_mostly) }
@@ -202,7 +204,9 @@ SECTIONS
202 *(.data.percpu) 204 *(.data.percpu)
203 __per_cpu_end = .; 205 __per_cpu_end = .;
204 } 206 }
205 . = __phys_per_cpu_start + PERCPU_PAGE_SIZE; /* ensure percpu data fits into percpu page size */ 207 . = __phys_per_cpu_start + PERCPU_PAGE_SIZE; /* ensure percpu data fits
208 * into percpu page size
209 */
206 210
207 data : { } :data 211 data : { } :data
208 .data : AT(ADDR(.data) - LOAD_OFFSET) 212 .data : AT(ADDR(.data) - LOAD_OFFSET)
diff --git a/arch/ia64/mm/contig.c b/arch/ia64/mm/contig.c
index e004143ba86b..daf977ff2920 100644
--- a/arch/ia64/mm/contig.c
+++ b/arch/ia64/mm/contig.c
@@ -26,7 +26,6 @@
26#include <asm/mca.h> 26#include <asm/mca.h>
27 27
28#ifdef CONFIG_VIRTUAL_MEM_MAP 28#ifdef CONFIG_VIRTUAL_MEM_MAP
29static unsigned long num_dma_physpages;
30static unsigned long max_gap; 29static unsigned long max_gap;
31#endif 30#endif
32 31
@@ -41,10 +40,11 @@ show_mem (void)
41 int i, total = 0, reserved = 0; 40 int i, total = 0, reserved = 0;
42 int shared = 0, cached = 0; 41 int shared = 0, cached = 0;
43 42
44 printk("Mem-info:\n"); 43 printk(KERN_INFO "Mem-info:\n");
45 show_free_areas(); 44 show_free_areas();
46 45
47 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 46 printk(KERN_INFO "Free swap: %6ldkB\n",
47 nr_swap_pages<<(PAGE_SHIFT-10));
48 i = max_mapnr; 48 i = max_mapnr;
49 for (i = 0; i < max_mapnr; i++) { 49 for (i = 0; i < max_mapnr; i++) {
50 if (!pfn_valid(i)) { 50 if (!pfn_valid(i)) {
@@ -63,12 +63,12 @@ show_mem (void)
63 else if (page_count(mem_map + i)) 63 else if (page_count(mem_map + i))
64 shared += page_count(mem_map + i) - 1; 64 shared += page_count(mem_map + i) - 1;
65 } 65 }
66 printk("%d pages of RAM\n", total); 66 printk(KERN_INFO "%d pages of RAM\n", total);
67 printk("%d reserved pages\n", reserved); 67 printk(KERN_INFO "%d reserved pages\n", reserved);
68 printk("%d pages shared\n", shared); 68 printk(KERN_INFO "%d pages shared\n", shared);
69 printk("%d pages swap cached\n", cached); 69 printk(KERN_INFO "%d pages swap cached\n", cached);
70 printk("%ld pages in page table cache\n", 70 printk(KERN_INFO "%ld pages in page table cache\n",
71 pgtable_quicklist_total_size()); 71 pgtable_quicklist_total_size());
72} 72}
73 73
74/* physical address where the bootmem map is located */ 74/* physical address where the bootmem map is located */
@@ -218,18 +218,6 @@ count_pages (u64 start, u64 end, void *arg)
218 return 0; 218 return 0;
219} 219}
220 220
221#ifdef CONFIG_VIRTUAL_MEM_MAP
222static int
223count_dma_pages (u64 start, u64 end, void *arg)
224{
225 unsigned long *count = arg;
226
227 if (start < MAX_DMA_ADDRESS)
228 *count += (min(end, MAX_DMA_ADDRESS) - start) >> PAGE_SHIFT;
229 return 0;
230}
231#endif
232
233/* 221/*
234 * Set up the page tables. 222 * Set up the page tables.
235 */ 223 */
@@ -238,45 +226,22 @@ void __init
238paging_init (void) 226paging_init (void)
239{ 227{
240 unsigned long max_dma; 228 unsigned long max_dma;
241 unsigned long zones_size[MAX_NR_ZONES]; 229 unsigned long nid = 0;
242#ifdef CONFIG_VIRTUAL_MEM_MAP 230 unsigned long max_zone_pfns[MAX_NR_ZONES];
243 unsigned long zholes_size[MAX_NR_ZONES];
244#endif
245
246 /* initialize mem_map[] */
247
248 memset(zones_size, 0, sizeof(zones_size));
249 231
250 num_physpages = 0; 232 num_physpages = 0;
251 efi_memmap_walk(count_pages, &num_physpages); 233 efi_memmap_walk(count_pages, &num_physpages);
252 234
253 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 235 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
236 max_zone_pfns[ZONE_DMA] = max_dma;
237 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
254 238
255#ifdef CONFIG_VIRTUAL_MEM_MAP 239#ifdef CONFIG_VIRTUAL_MEM_MAP
256 memset(zholes_size, 0, sizeof(zholes_size)); 240 efi_memmap_walk(register_active_ranges, &nid);
257
258 num_dma_physpages = 0;
259 efi_memmap_walk(count_dma_pages, &num_dma_physpages);
260
261 if (max_low_pfn < max_dma) {
262 zones_size[ZONE_DMA] = max_low_pfn;
263 zholes_size[ZONE_DMA] = max_low_pfn - num_dma_physpages;
264 } else {
265 zones_size[ZONE_DMA] = max_dma;
266 zholes_size[ZONE_DMA] = max_dma - num_dma_physpages;
267 if (num_physpages > num_dma_physpages) {
268 zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
269 zholes_size[ZONE_NORMAL] =
270 ((max_low_pfn - max_dma) -
271 (num_physpages - num_dma_physpages));
272 }
273 }
274
275 efi_memmap_walk(find_largest_hole, (u64 *)&max_gap); 241 efi_memmap_walk(find_largest_hole, (u64 *)&max_gap);
276 if (max_gap < LARGE_GAP) { 242 if (max_gap < LARGE_GAP) {
277 vmem_map = (struct page *) 0; 243 vmem_map = (struct page *) 0;
278 free_area_init_node(0, NODE_DATA(0), zones_size, 0, 244 free_area_init_nodes(max_zone_pfns);
279 zholes_size);
280 } else { 245 } else {
281 unsigned long map_size; 246 unsigned long map_size;
282 247
@@ -288,20 +253,19 @@ paging_init (void)
288 vmem_map = (struct page *) vmalloc_end; 253 vmem_map = (struct page *) vmalloc_end;
289 efi_memmap_walk(create_mem_map_page_table, NULL); 254 efi_memmap_walk(create_mem_map_page_table, NULL);
290 255
291 NODE_DATA(0)->node_mem_map = vmem_map; 256 /*
292 free_area_init_node(0, NODE_DATA(0), zones_size, 257 * alloc_node_mem_map makes an adjustment for mem_map
293 0, zholes_size); 258 * which isn't compatible with vmem_map.
259 */
260 NODE_DATA(0)->node_mem_map = vmem_map +
261 find_min_pfn_with_active_regions();
262 free_area_init_nodes(max_zone_pfns);
294 263
295 printk("Virtual mem_map starts at 0x%p\n", mem_map); 264 printk("Virtual mem_map starts at 0x%p\n", mem_map);
296 } 265 }
297#else /* !CONFIG_VIRTUAL_MEM_MAP */ 266#else /* !CONFIG_VIRTUAL_MEM_MAP */
298 if (max_low_pfn < max_dma) 267 add_active_range(0, 0, max_low_pfn);
299 zones_size[ZONE_DMA] = max_low_pfn; 268 free_area_init_nodes(max_zone_pfns);
300 else {
301 zones_size[ZONE_DMA] = max_dma;
302 zones_size[ZONE_NORMAL] = max_low_pfn - max_dma;
303 }
304 free_area_init(zones_size);
305#endif /* !CONFIG_VIRTUAL_MEM_MAP */ 269#endif /* !CONFIG_VIRTUAL_MEM_MAP */
306 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 270 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
307} 271}
diff --git a/arch/ia64/mm/discontig.c b/arch/ia64/mm/discontig.c
index d260bffa01ab..d497b6b0f5b2 100644
--- a/arch/ia64/mm/discontig.c
+++ b/arch/ia64/mm/discontig.c
@@ -547,15 +547,16 @@ void show_mem(void)
547 unsigned long total_present = 0; 547 unsigned long total_present = 0;
548 pg_data_t *pgdat; 548 pg_data_t *pgdat;
549 549
550 printk("Mem-info:\n"); 550 printk(KERN_INFO "Mem-info:\n");
551 show_free_areas(); 551 show_free_areas();
552 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 552 printk(KERN_INFO "Free swap: %6ldkB\n",
553 nr_swap_pages<<(PAGE_SHIFT-10));
554 printk(KERN_INFO "Node memory in pages:\n");
553 for_each_online_pgdat(pgdat) { 555 for_each_online_pgdat(pgdat) {
554 unsigned long present; 556 unsigned long present;
555 unsigned long flags; 557 unsigned long flags;
556 int shared = 0, cached = 0, reserved = 0; 558 int shared = 0, cached = 0, reserved = 0;
557 559
558 printk("Node ID: %d\n", pgdat->node_id);
559 pgdat_resize_lock(pgdat, &flags); 560 pgdat_resize_lock(pgdat, &flags);
560 present = pgdat->node_present_pages; 561 present = pgdat->node_present_pages;
561 for(i = 0; i < pgdat->node_spanned_pages; i++) { 562 for(i = 0; i < pgdat->node_spanned_pages; i++) {
@@ -579,18 +580,17 @@ void show_mem(void)
579 total_reserved += reserved; 580 total_reserved += reserved;
580 total_cached += cached; 581 total_cached += cached;
581 total_shared += shared; 582 total_shared += shared;
582 printk("\t%ld pages of RAM\n", present); 583 printk(KERN_INFO "Node %4d: RAM: %11ld, rsvd: %8d, "
583 printk("\t%d reserved pages\n", reserved); 584 "shrd: %10d, swpd: %10d\n", pgdat->node_id,
584 printk("\t%d pages shared\n", shared); 585 present, reserved, shared, cached);
585 printk("\t%d pages swap cached\n", cached);
586 } 586 }
587 printk("%ld pages of RAM\n", total_present); 587 printk(KERN_INFO "%ld pages of RAM\n", total_present);
588 printk("%d reserved pages\n", total_reserved); 588 printk(KERN_INFO "%d reserved pages\n", total_reserved);
589 printk("%d pages shared\n", total_shared); 589 printk(KERN_INFO "%d pages shared\n", total_shared);
590 printk("%d pages swap cached\n", total_cached); 590 printk(KERN_INFO "%d pages swap cached\n", total_cached);
591 printk("Total of %ld pages in page table cache\n", 591 printk(KERN_INFO "Total of %ld pages in page table cache\n",
592 pgtable_quicklist_total_size()); 592 pgtable_quicklist_total_size());
593 printk("%d free buffer pages\n", nr_free_buffer_pages()); 593 printk(KERN_INFO "%d free buffer pages\n", nr_free_buffer_pages());
594} 594}
595 595
596/** 596/**
@@ -654,6 +654,7 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
654{ 654{
655 unsigned long end = start + len; 655 unsigned long end = start + len;
656 656
657 add_active_range(node, start >> PAGE_SHIFT, end >> PAGE_SHIFT);
657 mem_data[node].num_physpages += len >> PAGE_SHIFT; 658 mem_data[node].num_physpages += len >> PAGE_SHIFT;
658 if (start <= __pa(MAX_DMA_ADDRESS)) 659 if (start <= __pa(MAX_DMA_ADDRESS))
659 mem_data[node].num_dma_physpages += 660 mem_data[node].num_dma_physpages +=
@@ -678,10 +679,10 @@ static __init int count_node_pages(unsigned long start, unsigned long len, int n
678void __init paging_init(void) 679void __init paging_init(void)
679{ 680{
680 unsigned long max_dma; 681 unsigned long max_dma;
681 unsigned long zones_size[MAX_NR_ZONES];
682 unsigned long zholes_size[MAX_NR_ZONES];
683 unsigned long pfn_offset = 0; 682 unsigned long pfn_offset = 0;
683 unsigned long max_pfn = 0;
684 int node; 684 int node;
685 unsigned long max_zone_pfns[MAX_NR_ZONES];
685 686
686 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT; 687 max_dma = virt_to_phys((void *) MAX_DMA_ADDRESS) >> PAGE_SHIFT;
687 688
@@ -698,47 +699,20 @@ void __init paging_init(void)
698#endif 699#endif
699 700
700 for_each_online_node(node) { 701 for_each_online_node(node) {
701 memset(zones_size, 0, sizeof(zones_size));
702 memset(zholes_size, 0, sizeof(zholes_size));
703
704 num_physpages += mem_data[node].num_physpages; 702 num_physpages += mem_data[node].num_physpages;
705
706 if (mem_data[node].min_pfn >= max_dma) {
707 /* All of this node's memory is above ZONE_DMA */
708 zones_size[ZONE_NORMAL] = mem_data[node].max_pfn -
709 mem_data[node].min_pfn;
710 zholes_size[ZONE_NORMAL] = mem_data[node].max_pfn -
711 mem_data[node].min_pfn -
712 mem_data[node].num_physpages;
713 } else if (mem_data[node].max_pfn < max_dma) {
714 /* All of this node's memory is in ZONE_DMA */
715 zones_size[ZONE_DMA] = mem_data[node].max_pfn -
716 mem_data[node].min_pfn;
717 zholes_size[ZONE_DMA] = mem_data[node].max_pfn -
718 mem_data[node].min_pfn -
719 mem_data[node].num_dma_physpages;
720 } else {
721 /* This node has memory in both zones */
722 zones_size[ZONE_DMA] = max_dma -
723 mem_data[node].min_pfn;
724 zholes_size[ZONE_DMA] = zones_size[ZONE_DMA] -
725 mem_data[node].num_dma_physpages;
726 zones_size[ZONE_NORMAL] = mem_data[node].max_pfn -
727 max_dma;
728 zholes_size[ZONE_NORMAL] = zones_size[ZONE_NORMAL] -
729 (mem_data[node].num_physpages -
730 mem_data[node].num_dma_physpages);
731 }
732
733 pfn_offset = mem_data[node].min_pfn; 703 pfn_offset = mem_data[node].min_pfn;
734 704
735#ifdef CONFIG_VIRTUAL_MEM_MAP 705#ifdef CONFIG_VIRTUAL_MEM_MAP
736 NODE_DATA(node)->node_mem_map = vmem_map + pfn_offset; 706 NODE_DATA(node)->node_mem_map = vmem_map + pfn_offset;
737#endif 707#endif
738 free_area_init_node(node, NODE_DATA(node), zones_size, 708 if (mem_data[node].max_pfn > max_pfn)
739 pfn_offset, zholes_size); 709 max_pfn = mem_data[node].max_pfn;
740 } 710 }
741 711
712 max_zone_pfns[ZONE_DMA] = max_dma;
713 max_zone_pfns[ZONE_NORMAL] = max_pfn;
714 free_area_init_nodes(max_zone_pfns);
715
742 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page)); 716 zero_page_memmap_ptr = virt_to_page(ia64_imva(empty_zero_page));
743} 717}
744 718
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index 30617ccb4f7e..ff87a5cba399 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -593,6 +593,18 @@ find_largest_hole (u64 start, u64 end, void *arg)
593 last_end = end; 593 last_end = end;
594 return 0; 594 return 0;
595} 595}
596
597int __init
598register_active_ranges(u64 start, u64 end, void *nid)
599{
600 BUG_ON(nid == NULL);
601 BUG_ON(*(unsigned long *)nid >= MAX_NUMNODES);
602
603 add_active_range(*(unsigned long *)nid,
604 __pa(start) >> PAGE_SHIFT,
605 __pa(end) >> PAGE_SHIFT);
606 return 0;
607}
596#endif /* CONFIG_VIRTUAL_MEM_MAP */ 608#endif /* CONFIG_VIRTUAL_MEM_MAP */
597 609
598static int __init 610static int __init
diff --git a/arch/ia64/pci/pci.c b/arch/ia64/pci/pci.c
index 60b45e79f080..15c7c670da39 100644
--- a/arch/ia64/pci/pci.c
+++ b/arch/ia64/pci/pci.c
@@ -562,7 +562,8 @@ pcibios_enable_device (struct pci_dev *dev, int mask)
562void 562void
563pcibios_disable_device (struct pci_dev *dev) 563pcibios_disable_device (struct pci_dev *dev)
564{ 564{
565 acpi_pci_irq_disable(dev); 565 if (dev->is_enabled)
566 acpi_pci_irq_disable(dev);
566} 567}
567 568
568void 569void
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index 27dee4584061..7f73ad4408aa 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -277,8 +277,7 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
277 } 277 }
278 278
279 /* temporary buffer used during unaligned transfers */ 279 /* temporary buffer used during unaligned transfers */
280 bteBlock_unaligned = kmalloc(len + 3 * L1_CACHE_BYTES, 280 bteBlock_unaligned = kmalloc(len + 3 * L1_CACHE_BYTES, GFP_KERNEL);
281 GFP_KERNEL | GFP_DMA);
282 if (bteBlock_unaligned == NULL) { 281 if (bteBlock_unaligned == NULL) {
283 return BTEFAIL_NOTAVAIL; 282 return BTEFAIL_NOTAVAIL;
284 } 283 }
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 330f6abc7703..30750c54bdf5 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -126,7 +126,7 @@ config BASLER_EXCITE
126 select IRQ_CPU 126 select IRQ_CPU
127 select IRQ_CPU_RM7K 127 select IRQ_CPU_RM7K
128 select IRQ_CPU_RM9K 128 select IRQ_CPU_RM9K
129 select SERIAL_RM9000 129 select MIPS_RM9122
130 select SYS_HAS_CPU_RM9000 130 select SYS_HAS_CPU_RM9000
131 select SYS_SUPPORTS_32BIT_KERNEL 131 select SYS_SUPPORTS_32BIT_KERNEL
132 select SYS_SUPPORTS_64BIT_KERNEL 132 select SYS_SUPPORTS_64BIT_KERNEL
@@ -203,26 +203,6 @@ config MIPS_EV64120
203 <http://www.marvell.com/>. Say Y here if you wish to build a 203 <http://www.marvell.com/>. Say Y here if you wish to build a
204 kernel for this platform. 204 kernel for this platform.
205 205
206config MIPS_EV96100
207 bool "Galileo EV96100 Evaluation board (EXPERIMENTAL)"
208 depends on EXPERIMENTAL
209 select DMA_NONCOHERENT
210 select HW_HAS_PCI
211 select IRQ_CPU
212 select MIPS_GT96100
213 select RM7000_CPU_SCACHE
214 select SWAP_IO_SPACE
215 select SYS_HAS_CPU_R5000
216 select SYS_HAS_CPU_RM7000
217 select SYS_SUPPORTS_32BIT_KERNEL
218 select SYS_SUPPORTS_64BIT_KERNEL if EXPERIMENTAL
219 select SYS_SUPPORTS_BIG_ENDIAN
220 help
221 This is an evaluation board based on the Galileo GT-96100 LAN/WAN
222 communications controllers containing a MIPS R5000 compatible core
223 running at 83MHz. Their website is <http://www.marvell.com/>. Say Y
224 here if you wish to build a kernel for this platform.
225
226config MIPS_IVR 206config MIPS_IVR
227 bool "Globespan IVR board" 207 bool "Globespan IVR board"
228 select DMA_NONCOHERENT 208 select DMA_NONCOHERENT
@@ -974,6 +954,12 @@ config MIPS_TX3927
974 bool 954 bool
975 select HAS_TXX9_SERIAL 955 select HAS_TXX9_SERIAL
976 956
957config MIPS_RM9122
958 bool
959 select SERIAL_RM9000
960 select GPI_RM9000
961 select WDT_RM9000
962
977config PCI_MARVELL 963config PCI_MARVELL
978 bool 964 bool
979 965
@@ -1024,6 +1010,15 @@ config EMMA2RH
1024 depends on MARKEINS 1010 depends on MARKEINS
1025 default y 1011 default y
1026 1012
1013config SERIAL_RM9000
1014 bool
1015
1016config GPI_RM9000
1017 bool
1018
1019config WDT_RM9000
1020 bool
1021
1027# 1022#
1028# Unfortunately not all GT64120 systems run the chip at the same clock. 1023# Unfortunately not all GT64120 systems run the chip at the same clock.
1029# As the user for the clock rate and try to minimize the available options. 1024# As the user for the clock rate and try to minimize the available options.
@@ -1054,10 +1049,6 @@ config AU1X00_USB_DEVICE
1054 depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 1049 depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000
1055 default n 1050 default n
1056 1051
1057config MIPS_GT96100
1058 bool
1059 select MIPS_GT64120
1060
1061config IT8172_CIR 1052config IT8172_CIR
1062 bool 1053 bool
1063 depends on MIPS_ITE8172 || MIPS_IVR 1054 depends on MIPS_ITE8172 || MIPS_IVR
@@ -1527,6 +1518,7 @@ config MIPS_MT_SMTC
1527 select CPU_MIPSR2_SRS 1518 select CPU_MIPSR2_SRS
1528 select MIPS_MT 1519 select MIPS_MT
1529 select SMP 1520 select SMP
1521 select SYS_SUPPORTS_SMP
1530 help 1522 help
1531 This is a kernel model which is known a SMTC or lately has been 1523 This is a kernel model which is known a SMTC or lately has been
1532 marketesed into SMVP. 1524 marketesed into SMVP.
@@ -1538,6 +1530,7 @@ config MIPS_MT_SMP
1538 select CPU_MIPSR2_SRS 1530 select CPU_MIPSR2_SRS
1539 select MIPS_MT 1531 select MIPS_MT
1540 select SMP 1532 select SMP
1533 select SYS_SUPPORTS_SMP
1541 help 1534 help
1542 This is a kernel model which is also known a VSMP or lately 1535 This is a kernel model which is also known a VSMP or lately
1543 has been marketesed into SMVP. 1536 has been marketesed into SMVP.
@@ -1649,9 +1642,7 @@ config GENERIC_IRQ_PROBE
1649 default y 1642 default y
1650 1643
1651config IRQ_PER_CPU 1644config IRQ_PER_CPU
1652 depends on SMP
1653 bool 1645 bool
1654 default y
1655 1646
1656# 1647#
1657# - Highmem only makes sense for the 32-bit kernel. 1648# - Highmem only makes sense for the 32-bit kernel.
@@ -1719,6 +1710,7 @@ source "mm/Kconfig"
1719config SMP 1710config SMP
1720 bool "Multi-Processing support" 1711 bool "Multi-Processing support"
1721 depends on SYS_SUPPORTS_SMP 1712 depends on SYS_SUPPORTS_SMP
1713 select IRQ_PER_CPU
1722 help 1714 help
1723 This enables support for systems with more than one CPU. If you have 1715 This enables support for systems with more than one CPU. If you have
1724 a system with only one CPU, like most personal computers, say N. If 1716 a system with only one CPU, like most personal computers, say N. If
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index d333ce4ba26b..e521826b4234 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -280,13 +280,6 @@ cflags-$(CONFIG_MIPS_EV64120) += -Iinclude/asm-mips/mach-ev64120
280load-$(CONFIG_MIPS_EV64120) += 0xffffffff80100000 280load-$(CONFIG_MIPS_EV64120) += 0xffffffff80100000
281 281
282# 282#
283# Galileo EV96100 Board
284#
285core-$(CONFIG_MIPS_EV96100) += arch/mips/galileo-boards/ev96100/
286cflags-$(CONFIG_MIPS_EV96100) += -Iinclude/asm-mips/mach-ev96100
287load-$(CONFIG_MIPS_EV96100) += 0xffffffff80100000
288
289#
290# Wind River PPMC Board (4KC + GT64120) 283# Wind River PPMC Board (4KC + GT64120)
291# 284#
292core-$(CONFIG_WR_PPMC) += arch/mips/gt64120/wrppmc/ 285core-$(CONFIG_WR_PPMC) += arch/mips/gt64120/wrppmc/
@@ -330,6 +323,7 @@ load-$(CONFIG_MIPS_MALTA) += 0xffffffff80100000
330# MIPS SEAD board 323# MIPS SEAD board
331# 324#
332core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/ 325core-$(CONFIG_MIPS_SEAD) += arch/mips/mips-boards/sead/
326cflags-$(CONFIG_MIPS_SEAD) += -Iinclude/asm-mips/mach-mips
333load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000 327load-$(CONFIG_MIPS_SEAD) += 0xffffffff80100000
334 328
335# 329#
diff --git a/arch/mips/au1000/db1x00/Makefile b/arch/mips/au1000/db1x00/Makefile
index 4c7d763f2113..51d62bd5d900 100644
--- a/arch/mips/au1000/db1x00/Makefile
+++ b/arch/mips/au1000/db1x00/Makefile
@@ -6,4 +6,3 @@
6# Makefile for the Alchemy Semiconductor Db1x00 board. 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
9obj-$(CONFIG_WM97XX_COMODULE) += mirage_ts.o
diff --git a/arch/mips/au1000/db1x00/mirage_ts.c b/arch/mips/au1000/db1x00/mirage_ts.c
deleted file mode 100644
index 0942dcf69518..000000000000
--- a/arch/mips/au1000/db1x00/mirage_ts.c
+++ /dev/null
@@ -1,260 +0,0 @@
1/*
2 * linux/arch/mips/au1000/db1x00/mirage_ts.c
3 *
4 * BRIEF MODULE DESCRIPTION
5 * Glue between Mirage board-specific touchscreen pieces
6 * and generic Wolfson Codec touchscreen support.
7 *
8 * Based on pb1100_ts.c used in Hydrogen II.
9 *
10 * Copyright (c) 2003 Embedded Edge, LLC
11 * dan@embeddededge.com
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
19 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
21 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
24 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#include <linux/types.h>
35#include <linux/module.h>
36#include <linux/sched.h>
37#include <linux/kernel.h>
38#include <linux/init.h>
39#include <linux/fs.h>
40#include <linux/poll.h>
41#include <linux/proc_fs.h>
42#include <linux/smp.h>
43#include <linux/smp_lock.h>
44#include <linux/wait.h>
45
46#include <asm/segment.h>
47#include <asm/irq.h>
48#include <asm/uaccess.h>
49#include <asm/delay.h>
50#include <asm/au1000.h>
51
52/*
53 * Imported interface to Wolfson Codec driver.
54 */
55extern void *wm97xx_ts_get_handle(int which);
56extern int wm97xx_ts_ready(void* ts_handle);
57extern void wm97xx_ts_set_cal(void* ts_handle, int xscale, int xtrans, int yscale, int ytrans);
58extern u16 wm97xx_ts_get_ac97(void* ts_handle, u8 reg);
59extern void wm97xx_ts_set_ac97(void* ts_handle, u8 reg, u16 val);
60extern int wm97xx_ts_read_data(void* ts_handle, long* x, long* y, long* pressure);
61extern void wm97xx_ts_send_data(void* ts_handle, long x, long y, long z);
62
63int wm97xx_comodule_present = 1;
64
65
66#define TS_NAME "mirage_ts"
67
68#define err(format, arg...) printk(KERN_ERR TS_NAME ": " format "\n" , ## arg)
69#define info(format, arg...) printk(KERN_INFO TS_NAME ": " format "\n" , ## arg)
70#define warn(format, arg...) printk(KERN_WARNING TS_NAME ": " format "\n" , ## arg)
71#define DPRINTK(format, arg...) printk("%s: " format "\n", __FUNCTION__ , ## arg)
72
73
74#define PEN_DOWN_IRQ AU1000_GPIO_7
75
76static struct task_struct *ts_task = 0;
77static DECLARE_COMPLETION(ts_complete);
78static DECLARE_WAIT_QUEUE_HEAD(pendown_wait);
79
80#ifdef CONFIG_WM97XX_FIVEWIRETS
81static int release_pressure = 1;
82#else
83static int release_pressure = 50;
84#endif
85
86typedef struct {
87 long x;
88 long y;
89} DOWN_EVENT;
90
91#define SAMPLE_RATE 50 /* samples per second */
92#define PEN_DEBOUNCE 5 /* samples for settling - fn of SAMPLE_RATE */
93#define PEN_UP_TIMEOUT 10 /* in seconds */
94#define PEN_UP_SETTLE 5 /* samples per second */
95
96static struct {
97 int xscale;
98 int xtrans;
99 int yscale;
100 int ytrans;
101} mirage_ts_cal =
102{
103#if 0
104 .xscale = 84,
105 .xtrans = -157,
106 .yscale = 66,
107 .ytrans = -150,
108#else
109 .xscale = 84,
110 .xtrans = -150,
111 .yscale = 66,
112 .ytrans = -146,
113#endif
114};
115
116
117static void pendown_irq(int irqnr, void *devid, struct pt_regs *regs)
118{
119//DPRINTK("got one 0x%x", au_readl(SYS_PINSTATERD));
120 wake_up(&pendown_wait);
121}
122
123static int ts_thread(void *id)
124{
125 static int pen_was_down = 0;
126 static DOWN_EVENT pen_xy;
127 long x, y, z;
128 void *ts; /* handle */
129 struct task_struct *tsk = current;
130 int timeout = HZ / SAMPLE_RATE;
131
132 ts_task = tsk;
133
134 daemonize();
135 tsk->tty = NULL;
136 tsk->policy = SCHED_FIFO;
137 tsk->rt_priority = 1;
138 strcpy(tsk->comm, "touchscreen");
139
140 /* only want to receive SIGKILL */
141 spin_lock_irq(&tsk->sigmask_lock);
142 siginitsetinv(&tsk->blocked, sigmask(SIGKILL));
143 recalc_sigpending(tsk);
144 spin_unlock_irq(&tsk->sigmask_lock);
145
146 /* get handle for codec */
147 ts = wm97xx_ts_get_handle(0);
148
149 /* proceed only after everybody is ready */
150 wait_event_timeout(pendown_wait, wm97xx_ts_ready(ts), HZ/4);
151
152 /* board-specific calibration */
153 wm97xx_ts_set_cal(ts,
154 mirage_ts_cal.xscale,
155 mirage_ts_cal.xtrans,
156 mirage_ts_cal.yscale,
157 mirage_ts_cal.ytrans);
158
159 /* route Wolfson pendown interrupts to our GPIO */
160 au_sync();
161 wm97xx_ts_set_ac97(ts, 0x4c, wm97xx_ts_get_ac97(ts, 0x4c) & ~0x0008);
162 au_sync();
163 wm97xx_ts_set_ac97(ts, 0x56, wm97xx_ts_get_ac97(ts, 0x56) & ~0x0008);
164 au_sync();
165 wm97xx_ts_set_ac97(ts, 0x52, wm97xx_ts_get_ac97(ts, 0x52) | 0x2008);
166 au_sync();
167
168 for (;;) {
169 interruptible_sleep_on_timeout(&pendown_wait, timeout);
170 disable_irq(PEN_DOWN_IRQ);
171 if (signal_pending(tsk)) {
172 break;
173 }
174
175 /* read codec */
176 if (!wm97xx_ts_read_data(ts, &x, &y, &z))
177 z = 0; /* treat no-data and pen-up the same */
178
179 if (signal_pending(tsk)) {
180 break;
181 }
182
183 if (z >= release_pressure) {
184 y = ~y; /* top to bottom */
185 if (pen_was_down > 1 /*&& pen_was_down < PEN_DEBOUNCE*/) {//THXXX
186 /* bounce ? */
187 x = pen_xy.x;
188 y = pen_xy.y;
189 --pen_was_down;
190 } else if (pen_was_down <= 1) {
191 pen_xy.x = x;
192 pen_xy.y = y;
193 if (pen_was_down)
194 wm97xx_ts_send_data(ts, x, y, z);
195 pen_was_down = PEN_DEBOUNCE;
196 }
197 //wm97xx_ts_send_data(ts, x, y, z);
198 timeout = HZ / SAMPLE_RATE;
199 } else {
200 if (pen_was_down) {
201 if (--pen_was_down)
202 z = release_pressure;
203 else //THXXX
204 wm97xx_ts_send_data(ts, pen_xy.x, pen_xy.y, z);
205 }
206 /* The pendown signal takes some time to settle after
207 * reading the pen pressure so wait a little
208 * before enabling the pen.
209 */
210 if (! pen_was_down) {
211// interruptible_sleep_on_timeout(&pendown_wait, HZ / PEN_UP_SETTLE);
212 timeout = HZ * PEN_UP_TIMEOUT;
213 }
214 }
215 enable_irq(PEN_DOWN_IRQ);
216 }
217 enable_irq(PEN_DOWN_IRQ);
218 ts_task = NULL;
219 complete(&ts_complete);
220 return 0;
221}
222
223static int __init ts_mirage_init(void)
224{
225 int ret;
226
227 /* pen down signal is connected to GPIO 7 */
228
229 ret = request_irq(PEN_DOWN_IRQ, pendown_irq, 0, "ts-pendown", NULL);
230 if (ret) {
231 err("unable to get pendown irq%d: [%d]", PEN_DOWN_IRQ, ret);
232 return ret;
233 }
234
235 lock_kernel();
236 ret = kernel_thread(ts_thread, NULL, CLONE_FS | CLONE_FILES);
237 if (ret < 0) {
238 unlock_kernel();
239 return ret;
240 }
241 unlock_kernel();
242
243 info("Mirage touchscreen IRQ initialized.");
244
245 return 0;
246}
247
248static void __exit ts_mirage_exit(void)
249{
250 if (ts_task) {
251 send_sig(SIGKILL, ts_task, 1);
252 wait_for_completion(&ts_complete);
253 }
254
255 free_irq(PEN_DOWN_IRQ, NULL);
256}
257
258module_init(ts_mirage_init);
259module_exit(ts_mirage_exit);
260
diff --git a/arch/mips/basler/excite/excite_device.c b/arch/mips/basler/excite/excite_device.c
index bbb4ea43da88..cc1ce77eab4a 100644
--- a/arch/mips/basler/excite/excite_device.c
+++ b/arch/mips/basler/excite/excite_device.c
@@ -68,7 +68,7 @@ enum {
68 68
69 69
70static struct resource 70static struct resource
71 excite_ctr_resource = { 71 excite_ctr_resource __attribute__((unused)) = {
72 .name = "GPI counters", 72 .name = "GPI counters",
73 .start = 0, 73 .start = 0,
74 .end = 5, 74 .end = 5,
@@ -77,7 +77,7 @@ static struct resource
77 .sibling = NULL, 77 .sibling = NULL,
78 .child = NULL 78 .child = NULL
79 }, 79 },
80 excite_gpislice_resource = { 80 excite_gpislice_resource __attribute__((unused)) = {
81 .name = "GPI slices", 81 .name = "GPI slices",
82 .start = 0, 82 .start = 0,
83 .end = 1, 83 .end = 1,
@@ -86,7 +86,7 @@ static struct resource
86 .sibling = NULL, 86 .sibling = NULL,
87 .child = NULL 87 .child = NULL
88 }, 88 },
89 excite_mdio_channel_resource = { 89 excite_mdio_channel_resource __attribute__((unused)) = {
90 .name = "MDIO channels", 90 .name = "MDIO channels",
91 .start = 0, 91 .start = 0,
92 .end = 1, 92 .end = 1,
@@ -95,7 +95,7 @@ static struct resource
95 .sibling = NULL, 95 .sibling = NULL,
96 .child = NULL 96 .child = NULL
97 }, 97 },
98 excite_fifomem_resource = { 98 excite_fifomem_resource __attribute__((unused)) = {
99 .name = "FIFO memory", 99 .name = "FIFO memory",
100 .start = 0, 100 .start = 0,
101 .end = 767, 101 .end = 767,
@@ -104,7 +104,7 @@ static struct resource
104 .sibling = NULL, 104 .sibling = NULL,
105 .child = NULL 105 .child = NULL
106 }, 106 },
107 excite_scram_resource = { 107 excite_scram_resource __attribute__((unused)) = {
108 .name = "Scratch RAM", 108 .name = "Scratch RAM",
109 .start = EXCITE_PHYS_SCRAM, 109 .start = EXCITE_PHYS_SCRAM,
110 .end = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1, 110 .end = EXCITE_PHYS_SCRAM + EXCITE_SIZE_SCRAM - 1,
@@ -113,7 +113,7 @@ static struct resource
113 .sibling = NULL, 113 .sibling = NULL,
114 .child = NULL 114 .child = NULL
115 }, 115 },
116 excite_fpga_resource = { 116 excite_fpga_resource __attribute__((unused)) = {
117 .name = "System FPGA", 117 .name = "System FPGA",
118 .start = EXCITE_PHYS_FPGA, 118 .start = EXCITE_PHYS_FPGA,
119 .end = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1, 119 .end = EXCITE_PHYS_FPGA + EXCITE_SIZE_FPGA - 1,
@@ -122,7 +122,7 @@ static struct resource
122 .sibling = NULL, 122 .sibling = NULL,
123 .child = NULL 123 .child = NULL
124 }, 124 },
125 excite_nand_resource = { 125 excite_nand_resource __attribute__((unused)) = {
126 .name = "NAND flash control", 126 .name = "NAND flash control",
127 .start = EXCITE_PHYS_NAND, 127 .start = EXCITE_PHYS_NAND,
128 .end = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1, 128 .end = EXCITE_PHYS_NAND + EXCITE_SIZE_NAND - 1,
@@ -131,7 +131,7 @@ static struct resource
131 .sibling = NULL, 131 .sibling = NULL,
132 .child = NULL 132 .child = NULL
133 }, 133 },
134 excite_titan_resource = { 134 excite_titan_resource __attribute__((unused)) = {
135 .name = "TITAN registers", 135 .name = "TITAN registers",
136 .start = EXCITE_PHYS_TITAN, 136 .start = EXCITE_PHYS_TITAN,
137 .end = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1, 137 .end = EXCITE_PHYS_TITAN + EXCITE_SIZE_TITAN - 1,
diff --git a/arch/mips/configs/atlas_defconfig b/arch/mips/configs/atlas_defconfig
index 54274065e9a5..d3705284de39 100644
--- a/arch/mips/configs/atlas_defconfig
+++ b/arch/mips/configs/atlas_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -1193,7 +1192,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1193CONFIG_PROC_FS=y 1192CONFIG_PROC_FS=y
1194CONFIG_PROC_KCORE=y 1193CONFIG_PROC_KCORE=y
1195CONFIG_SYSFS=y 1194CONFIG_SYSFS=y
1196# CONFIG_TMPFS is not set 1195CONFIG_TMPFS=y
1197# CONFIG_HUGETLB_PAGE is not set 1196# CONFIG_HUGETLB_PAGE is not set
1198CONFIG_RAMFS=y 1197CONFIG_RAMFS=y
1199# CONFIG_CONFIGFS_FS is not set 1198# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/bigsur_defconfig b/arch/mips/configs/bigsur_defconfig
index 887fd959482a..e12a475dcbf4 100644
--- a/arch/mips/configs/bigsur_defconfig
+++ b/arch/mips/configs/bigsur_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/capcella_defconfig b/arch/mips/configs/capcella_defconfig
index a01344f3a4c2..bfade9abb767 100644
--- a/arch/mips/configs/capcella_defconfig
+++ b/arch/mips/configs/capcella_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/cobalt_defconfig b/arch/mips/configs/cobalt_defconfig
index c95682445a28..4baf2ff1128a 100644
--- a/arch/mips/configs/cobalt_defconfig
+++ b/arch/mips/configs/cobalt_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25CONFIG_MIPS_COBALT=y 25CONFIG_MIPS_COBALT=y
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -828,7 +827,7 @@ CONFIG_FUSE_FS=y
828CONFIG_PROC_FS=y 827CONFIG_PROC_FS=y
829CONFIG_PROC_KCORE=y 828CONFIG_PROC_KCORE=y
830CONFIG_SYSFS=y 829CONFIG_SYSFS=y
831# CONFIG_TMPFS is not set 830CONFIG_TMPFS=y
832# CONFIG_HUGETLB_PAGE is not set 831# CONFIG_HUGETLB_PAGE is not set
833CONFIG_RAMFS=y 832CONFIG_RAMFS=y
834# CONFIG_CONFIGFS_FS is not set 833# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/db1000_defconfig b/arch/mips/configs/db1000_defconfig
index c2f33d3af62c..93cca1585bc3 100644
--- a/arch/mips/configs/db1000_defconfig
+++ b/arch/mips/configs/db1000_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_DB1000=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/db1100_defconfig b/arch/mips/configs/db1100_defconfig
index 8c44d16ae9a2..ffd99252a837 100644
--- a/arch/mips/configs/db1100_defconfig
+++ b/arch/mips/configs/db1100_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_DB1100=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/db1200_defconfig b/arch/mips/configs/db1200_defconfig
index c13768e75ac5..63eac5e89b9c 100644
--- a/arch/mips/configs/db1200_defconfig
+++ b/arch/mips/configs/db1200_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_DB1200=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/db1500_defconfig b/arch/mips/configs/db1500_defconfig
index 8aea73fae7fb..25a095f7dc4e 100644
--- a/arch/mips/configs/db1500_defconfig
+++ b/arch/mips/configs/db1500_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_DB1500=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/db1550_defconfig b/arch/mips/configs/db1550_defconfig
index 90ccb7359630..dda469c842b3 100644
--- a/arch/mips/configs/db1550_defconfig
+++ b/arch/mips/configs/db1550_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_DB1550=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/ddb5477_defconfig b/arch/mips/configs/ddb5477_defconfig
index b598cf08f156..fcd3dd19bc74 100644
--- a/arch/mips/configs/ddb5477_defconfig
+++ b/arch/mips/configs/ddb5477_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/decstation_defconfig b/arch/mips/configs/decstation_defconfig
index 597150b14077..8683e0df12e0 100644
--- a/arch/mips/configs/decstation_defconfig
+++ b/arch/mips/configs/decstation_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26CONFIG_MACH_DECSTATION=y 26CONFIG_MACH_DECSTATION=y
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/e55_defconfig b/arch/mips/configs/e55_defconfig
index fa2996bb4b7c..4ace61c95778 100644
--- a/arch/mips/configs/e55_defconfig
+++ b/arch/mips/configs/e55_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.18-rc2
4# Thu Jul 6 10:04:02 2006 4# Tue Jul 25 23:15:03 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -227,7 +226,6 @@ CONFIG_MMU=y
227# 226#
228# PCCARD (PCMCIA/CardBus) support 227# PCCARD (PCMCIA/CardBus) support
229# 228#
230# CONFIG_PCCARD is not set
231 229
232# 230#
233# PCI Hotplug Support 231# PCI Hotplug Support
@@ -254,7 +252,6 @@ CONFIG_TRAD_SIGNALS=y
254# 252#
255CONFIG_STANDALONE=y 253CONFIG_STANDALONE=y
256CONFIG_PREVENT_FIRMWARE_BUILD=y 254CONFIG_PREVENT_FIRMWARE_BUILD=y
257# CONFIG_FW_LOADER is not set
258# CONFIG_SYS_HYPERVISOR is not set 255# CONFIG_SYS_HYPERVISOR is not set
259 256
260# 257#
@@ -284,6 +281,7 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y
284CONFIG_BLK_DEV_RAM=m 281CONFIG_BLK_DEV_RAM=m
285CONFIG_BLK_DEV_RAM_COUNT=16 282CONFIG_BLK_DEV_RAM_COUNT=16
286CONFIG_BLK_DEV_RAM_SIZE=4096 283CONFIG_BLK_DEV_RAM_SIZE=4096
284CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
287# CONFIG_BLK_DEV_INITRD is not set 285# CONFIG_BLK_DEV_INITRD is not set
288# CONFIG_CDROM_PKTCDVD is not set 286# CONFIG_CDROM_PKTCDVD is not set
289 287
@@ -643,6 +641,7 @@ CONFIG_MSDOS_PARTITION=y
643# 641#
644# Kernel hacking 642# Kernel hacking
645# 643#
644CONFIG_TRACE_IRQFLAGS_SUPPORT=y
646# CONFIG_PRINTK_TIME is not set 645# CONFIG_PRINTK_TIME is not set
647# CONFIG_MAGIC_SYSRQ is not set 646# CONFIG_MAGIC_SYSRQ is not set
648# CONFIG_UNUSED_SYMBOLS is not set 647# CONFIG_UNUSED_SYMBOLS is not set
@@ -650,7 +649,7 @@ CONFIG_MSDOS_PARTITION=y
650CONFIG_LOG_BUF_SHIFT=14 649CONFIG_LOG_BUF_SHIFT=14
651# CONFIG_DEBUG_FS is not set 650# CONFIG_DEBUG_FS is not set
652CONFIG_CROSSCOMPILE=y 651CONFIG_CROSSCOMPILE=y
653CONFIG_CMDLINE="console=ttyVR0,19200 mem=8M" 652CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x1f0,0x3f6,40 mem=8M"
654 653
655# 654#
656# Security options 655# Security options
diff --git a/arch/mips/configs/emma2rh_defconfig b/arch/mips/configs/emma2rh_defconfig
index 375b2ac24a49..5847c916c130 100644
--- a/arch/mips/configs/emma2rh_defconfig
+++ b/arch/mips/configs/emma2rh_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/ev64120_defconfig b/arch/mips/configs/ev64120_defconfig
index b0afc118bd5c..bc4c4f125c48 100644
--- a/arch/mips/configs/ev64120_defconfig
+++ b/arch/mips/configs/ev64120_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27CONFIG_MIPS_EV64120=y 27CONFIG_MIPS_EV64120=y
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/excite_defconfig b/arch/mips/configs/excite_defconfig
index 045ebd089893..eb87cbbfd037 100644
--- a/arch/mips/configs/excite_defconfig
+++ b/arch/mips/configs/excite_defconfig
@@ -26,7 +26,6 @@ CONFIG_BASLER_EXCITE=y
26# CONFIG_MIPS_COBALT is not set 26# CONFIG_MIPS_COBALT is not set
27# CONFIG_MACH_DECSTATION is not set 27# CONFIG_MACH_DECSTATION is not set
28# CONFIG_MIPS_EV64120 is not set 28# CONFIG_MIPS_EV64120 is not set
29# CONFIG_MIPS_EV96100 is not set
30# CONFIG_MIPS_IVR is not set 29# CONFIG_MIPS_IVR is not set
31# CONFIG_MIPS_ITE8172 is not set 30# CONFIG_MIPS_ITE8172 is not set
32# CONFIG_MACH_JAZZ is not set 31# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/ip22_defconfig b/arch/mips/configs/ip22_defconfig
index ef16d1fb5071..cc9b24eda9e8 100644
--- a/arch/mips/configs/ip22_defconfig
+++ b/arch/mips/configs/ip22_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -1013,7 +1012,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1013CONFIG_PROC_FS=y 1012CONFIG_PROC_FS=y
1014CONFIG_PROC_KCORE=y 1013CONFIG_PROC_KCORE=y
1015CONFIG_SYSFS=y 1014CONFIG_SYSFS=y
1016# CONFIG_TMPFS is not set 1015CONFIG_TMPFS=y
1017# CONFIG_HUGETLB_PAGE is not set 1016# CONFIG_HUGETLB_PAGE is not set
1018CONFIG_RAMFS=y 1017CONFIG_RAMFS=y
1019# CONFIG_CONFIGFS_FS is not set 1018# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/ip27_defconfig b/arch/mips/configs/ip27_defconfig
index 4bf1ee7f5f00..50092ba8aa71 100644
--- a/arch/mips/configs/ip27_defconfig
+++ b/arch/mips/configs/ip27_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -900,7 +899,7 @@ CONFIG_FUSE_FS=m
900CONFIG_PROC_FS=y 899CONFIG_PROC_FS=y
901CONFIG_PROC_KCORE=y 900CONFIG_PROC_KCORE=y
902CONFIG_SYSFS=y 901CONFIG_SYSFS=y
903# CONFIG_TMPFS is not set 902CONFIG_TMPFS=y
904# CONFIG_HUGETLB_PAGE is not set 903# CONFIG_HUGETLB_PAGE is not set
905CONFIG_RAMFS=y 904CONFIG_RAMFS=y
906# CONFIG_CONFIGFS_FS is not set 905# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/ip32_defconfig b/arch/mips/configs/ip32_defconfig
index f83dc09c3ca9..dec2ba6ba03f 100644
--- a/arch/mips/configs/ip32_defconfig
+++ b/arch/mips/configs/ip32_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/it8172_defconfig b/arch/mips/configs/it8172_defconfig
index a91d72a9ca86..37f9dd7187b1 100644
--- a/arch/mips/configs/it8172_defconfig
+++ b/arch/mips/configs/it8172_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30CONFIG_MIPS_ITE8172=y 29CONFIG_MIPS_ITE8172=y
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/ivr_defconfig b/arch/mips/configs/ivr_defconfig
index cebc67212d06..18874a4c24fe 100644
--- a/arch/mips/configs/ivr_defconfig
+++ b/arch/mips/configs/ivr_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29CONFIG_MIPS_IVR=y 28CONFIG_MIPS_IVR=y
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/jaguar-atx_defconfig b/arch/mips/configs/jaguar-atx_defconfig
index 5d9eb11aba3d..9f1e3048d623 100644
--- a/arch/mips/configs/jaguar-atx_defconfig
+++ b/arch/mips/configs/jaguar-atx_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -731,7 +730,7 @@ CONFIG_FUSE_FS=m
731CONFIG_PROC_FS=y 730CONFIG_PROC_FS=y
732CONFIG_PROC_KCORE=y 731CONFIG_PROC_KCORE=y
733CONFIG_SYSFS=y 732CONFIG_SYSFS=y
734# CONFIG_TMPFS is not set 733CONFIG_TMPFS=y
735# CONFIG_HUGETLB_PAGE is not set 734# CONFIG_HUGETLB_PAGE is not set
736CONFIG_RAMFS=y 735CONFIG_RAMFS=y
737 736
diff --git a/arch/mips/configs/jmr3927_defconfig b/arch/mips/configs/jmr3927_defconfig
index be45a9044d06..fded3f73815f 100644
--- a/arch/mips/configs/jmr3927_defconfig
+++ b/arch/mips/configs/jmr3927_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/lasat200_defconfig b/arch/mips/configs/lasat200_defconfig
index 64dc9f45a19c..320b8cdd6e58 100644
--- a/arch/mips/configs/lasat200_defconfig
+++ b/arch/mips/configs/lasat200_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -905,7 +904,7 @@ CONFIG_FUSE_FS=m
905CONFIG_PROC_FS=y 904CONFIG_PROC_FS=y
906CONFIG_PROC_KCORE=y 905CONFIG_PROC_KCORE=y
907CONFIG_SYSFS=y 906CONFIG_SYSFS=y
908# CONFIG_TMPFS is not set 907CONFIG_TMPFS=y
909# CONFIG_HUGETLB_PAGE is not set 908# CONFIG_HUGETLB_PAGE is not set
910CONFIG_RAMFS=y 909CONFIG_RAMFS=y
911# CONFIG_CONFIGFS_FS is not set 910# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 2690baf15a85..0ba1ef5048fb 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -1230,7 +1229,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1230CONFIG_PROC_FS=y 1229CONFIG_PROC_FS=y
1231CONFIG_PROC_KCORE=y 1230CONFIG_PROC_KCORE=y
1232CONFIG_SYSFS=y 1231CONFIG_SYSFS=y
1233# CONFIG_TMPFS is not set 1232CONFIG_TMPFS=y
1234# CONFIG_HUGETLB_PAGE is not set 1233# CONFIG_HUGETLB_PAGE is not set
1235CONFIG_RAMFS=y 1234CONFIG_RAMFS=y
1236# CONFIG_CONFIGFS_FS is not set 1235# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/mipssim_defconfig b/arch/mips/configs/mipssim_defconfig
index c298979c18ae..adbeeadddb8f 100644
--- a/arch/mips/configs/mipssim_defconfig
+++ b/arch/mips/configs/mipssim_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/mpc30x_defconfig b/arch/mips/configs/mpc30x_defconfig
index 938b38ab5239..79fd544fcb2a 100644
--- a/arch/mips/configs/mpc30x_defconfig
+++ b/arch/mips/configs/mpc30x_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.18-rc2
4# Thu Jul 6 10:04:15 2006 4# Tue Jul 25 23:16:46 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -71,7 +70,6 @@ CONFIG_MACH_VR41XX=y
71CONFIG_VICTOR_MPC30X=y 70CONFIG_VICTOR_MPC30X=y
72# CONFIG_ZAO_CAPCELLA is not set 71# CONFIG_ZAO_CAPCELLA is not set
73CONFIG_PCI_VR41XX=y 72CONFIG_PCI_VR41XX=y
74CONFIG_VRC4173=y
75CONFIG_RWSEM_GENERIC_SPINLOCK=y 73CONFIG_RWSEM_GENERIC_SPINLOCK=y
76CONFIG_GENERIC_FIND_NEXT_BIT=y 74CONFIG_GENERIC_FIND_NEXT_BIT=y
77CONFIG_GENERIC_HWEIGHT=y 75CONFIG_GENERIC_HWEIGHT=y
@@ -168,6 +166,7 @@ CONFIG_SWAP=y
168CONFIG_SYSVIPC=y 166CONFIG_SYSVIPC=y
169# CONFIG_POSIX_MQUEUE is not set 167# CONFIG_POSIX_MQUEUE is not set
170# CONFIG_BSD_PROCESS_ACCT is not set 168# CONFIG_BSD_PROCESS_ACCT is not set
169# CONFIG_TASKSTATS is not set
171CONFIG_SYSCTL=y 170CONFIG_SYSCTL=y
172# CONFIG_AUDIT is not set 171# CONFIG_AUDIT is not set
173# CONFIG_IKCONFIG is not set 172# CONFIG_IKCONFIG is not set
@@ -841,7 +840,7 @@ CONFIG_USB_PEGASUS=m
841# CONFIG_USB_LEGOTOWER is not set 840# CONFIG_USB_LEGOTOWER is not set
842# CONFIG_USB_LCD is not set 841# CONFIG_USB_LCD is not set
843# CONFIG_USB_LED is not set 842# CONFIG_USB_LED is not set
844# CONFIG_USB_CY7C63 is not set 843# CONFIG_USB_CYPRESS_CY7C63 is not set
845# CONFIG_USB_CYTHERM is not set 844# CONFIG_USB_CYTHERM is not set
846# CONFIG_USB_PHIDGETKIT is not set 845# CONFIG_USB_PHIDGETKIT is not set
847# CONFIG_USB_PHIDGETSERVO is not set 846# CONFIG_USB_PHIDGETSERVO is not set
@@ -982,7 +981,6 @@ CONFIG_SUNRPC=y
982# CONFIG_RPCSEC_GSS_SPKM3 is not set 981# CONFIG_RPCSEC_GSS_SPKM3 is not set
983# CONFIG_SMB_FS is not set 982# CONFIG_SMB_FS is not set
984# CONFIG_CIFS is not set 983# CONFIG_CIFS is not set
985# CONFIG_CIFS_DEBUG2 is not set
986# CONFIG_NCP_FS is not set 984# CONFIG_NCP_FS is not set
987# CONFIG_CODA_FS is not set 985# CONFIG_CODA_FS is not set
988# CONFIG_AFS_FS is not set 986# CONFIG_AFS_FS is not set
@@ -1007,6 +1005,7 @@ CONFIG_MSDOS_PARTITION=y
1007# 1005#
1008# Kernel hacking 1006# Kernel hacking
1009# 1007#
1008CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1010# CONFIG_PRINTK_TIME is not set 1009# CONFIG_PRINTK_TIME is not set
1011# CONFIG_MAGIC_SYSRQ is not set 1010# CONFIG_MAGIC_SYSRQ is not set
1012# CONFIG_UNUSED_SYMBOLS is not set 1011# CONFIG_UNUSED_SYMBOLS is not set
@@ -1014,7 +1013,7 @@ CONFIG_MSDOS_PARTITION=y
1014CONFIG_LOG_BUF_SHIFT=14 1013CONFIG_LOG_BUF_SHIFT=14
1015# CONFIG_DEBUG_FS is not set 1014# CONFIG_DEBUG_FS is not set
1016CONFIG_CROSSCOMPILE=y 1015CONFIG_CROSSCOMPILE=y
1017CONFIG_CMDLINE="mem=32M console=ttyVR0,19200" 1016CONFIG_CMDLINE="mem=32M console=ttyVR0,19200 ide0=0x170,0x376,73"
1018 1017
1019# 1018#
1020# Security options 1019# Security options
diff --git a/arch/mips/configs/ocelot_3_defconfig b/arch/mips/configs/ocelot_3_defconfig
index ec5758f22676..4d87da2b99fd 100644
--- a/arch/mips/configs/ocelot_3_defconfig
+++ b/arch/mips/configs/ocelot_3_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/ocelot_c_defconfig b/arch/mips/configs/ocelot_c_defconfig
index 0d33d87de1a1..a7ac2b0a8273 100644
--- a/arch/mips/configs/ocelot_c_defconfig
+++ b/arch/mips/configs/ocelot_c_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -774,7 +773,7 @@ CONFIG_FUSE_FS=y
774CONFIG_PROC_FS=y 773CONFIG_PROC_FS=y
775CONFIG_PROC_KCORE=y 774CONFIG_PROC_KCORE=y
776CONFIG_SYSFS=y 775CONFIG_SYSFS=y
777# CONFIG_TMPFS is not set 776CONFIG_TMPFS=y
778# CONFIG_HUGETLB_PAGE is not set 777# CONFIG_HUGETLB_PAGE is not set
779CONFIG_RAMFS=y 778CONFIG_RAMFS=y
780# CONFIG_CONFIGFS_FS is not set 779# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/ocelot_defconfig b/arch/mips/configs/ocelot_defconfig
index 4b999102715e..853e7bba5122 100644
--- a/arch/mips/configs/ocelot_defconfig
+++ b/arch/mips/configs/ocelot_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -723,7 +722,7 @@ CONFIG_FUSE_FS=y
723CONFIG_PROC_FS=y 722CONFIG_PROC_FS=y
724CONFIG_PROC_KCORE=y 723CONFIG_PROC_KCORE=y
725CONFIG_SYSFS=y 724CONFIG_SYSFS=y
726# CONFIG_TMPFS is not set 725CONFIG_TMPFS=y
727# CONFIG_HUGETLB_PAGE is not set 726# CONFIG_HUGETLB_PAGE is not set
728CONFIG_RAMFS=y 727CONFIG_RAMFS=y
729# CONFIG_CONFIGFS_FS is not set 728# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/ocelot_g_defconfig b/arch/mips/configs/ocelot_g_defconfig
index 827b344f6010..8524efa23a49 100644
--- a/arch/mips/configs/ocelot_g_defconfig
+++ b/arch/mips/configs/ocelot_g_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -777,7 +776,7 @@ CONFIG_FUSE_FS=y
777CONFIG_PROC_FS=y 776CONFIG_PROC_FS=y
778CONFIG_PROC_KCORE=y 777CONFIG_PROC_KCORE=y
779CONFIG_SYSFS=y 778CONFIG_SYSFS=y
780# CONFIG_TMPFS is not set 779CONFIG_TMPFS=y
781# CONFIG_HUGETLB_PAGE is not set 780# CONFIG_HUGETLB_PAGE is not set
782CONFIG_RAMFS=y 781CONFIG_RAMFS=y
783# CONFIG_CONFIGFS_FS is not set 782# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig
index 9ed60fef69e0..1a16e92900cb 100644
--- a/arch/mips/configs/pb1100_defconfig
+++ b/arch/mips/configs/pb1100_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_PB1100=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig
index 6774254b1be6..9ea8edea6f29 100644
--- a/arch/mips/configs/pb1500_defconfig
+++ b/arch/mips/configs/pb1500_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_PB1500=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/pb1550_defconfig b/arch/mips/configs/pb1550_defconfig
index 1afe5bf6e765..c4a158976f8f 100644
--- a/arch/mips/configs/pb1550_defconfig
+++ b/arch/mips/configs/pb1550_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS_PB1550=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/pnx8550-jbs_defconfig b/arch/mips/configs/pnx8550-jbs_defconfig
index ac616c82d348..1cbf270c301c 100644
--- a/arch/mips/configs/pnx8550-jbs_defconfig
+++ b/arch/mips/configs/pnx8550-jbs_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/pnx8550-v2pci_defconfig b/arch/mips/configs/pnx8550-v2pci_defconfig
index a8eb51bae3f3..bec30b15b9bd 100644
--- a/arch/mips/configs/pnx8550-v2pci_defconfig
+++ b/arch/mips/configs/pnx8550-v2pci_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/qemu_defconfig b/arch/mips/configs/qemu_defconfig
index 6a63a113b7ea..f5f799e93707 100644
--- a/arch/mips/configs/qemu_defconfig
+++ b/arch/mips/configs/qemu_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -687,7 +686,7 @@ CONFIG_FUSE_FS=y
687CONFIG_PROC_FS=y 686CONFIG_PROC_FS=y
688CONFIG_PROC_KCORE=y 687CONFIG_PROC_KCORE=y
689CONFIG_SYSFS=y 688CONFIG_SYSFS=y
690# CONFIG_TMPFS is not set 689CONFIG_TMPFS=y
691# CONFIG_HUGETLB_PAGE is not set 690# CONFIG_HUGETLB_PAGE is not set
692CONFIG_RAMFS=y 691CONFIG_RAMFS=y
693 692
diff --git a/arch/mips/configs/rbhma4500_defconfig b/arch/mips/configs/rbhma4500_defconfig
index 6779f449bd2d..2f5650227ba3 100644
--- a/arch/mips/configs/rbhma4500_defconfig
+++ b/arch/mips/configs/rbhma4500_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index b7826d3a2b77..4fee90b2b100 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -1442,7 +1441,7 @@ CONFIG_NTFS_FS=m
1442CONFIG_PROC_FS=y 1441CONFIG_PROC_FS=y
1443CONFIG_PROC_KCORE=y 1442CONFIG_PROC_KCORE=y
1444CONFIG_SYSFS=y 1443CONFIG_SYSFS=y
1445# CONFIG_TMPFS is not set 1444CONFIG_TMPFS=y
1446# CONFIG_HUGETLB_PAGE is not set 1445# CONFIG_HUGETLB_PAGE is not set
1447CONFIG_RAMFS=y 1446CONFIG_RAMFS=y
1448# CONFIG_CONFIGFS_FS is not set 1447# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/configs/sb1250-swarm_defconfig b/arch/mips/configs/sb1250-swarm_defconfig
index 625c1c619b6b..9041f095f96f 100644
--- a/arch/mips/configs/sb1250-swarm_defconfig
+++ b/arch/mips/configs/sb1250-swarm_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/sead_defconfig b/arch/mips/configs/sead_defconfig
index 4401b602118f..02abb2f1bfaf 100644
--- a/arch/mips/configs/sead_defconfig
+++ b/arch/mips/configs/sead_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/tb0226_defconfig b/arch/mips/configs/tb0226_defconfig
index 2ba4e25e8c34..ca3d0c4ba15b 100644
--- a/arch/mips/configs/tb0226_defconfig
+++ b/arch/mips/configs/tb0226_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/tb0229_defconfig b/arch/mips/configs/tb0229_defconfig
index fc8a407c1add..4e2009ace278 100644
--- a/arch/mips/configs/tb0229_defconfig
+++ b/arch/mips/configs/tb0229_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/tb0287_defconfig b/arch/mips/configs/tb0287_defconfig
index effcb63b81a3..535a813d01a9 100644
--- a/arch/mips/configs/tb0287_defconfig
+++ b/arch/mips/configs/tb0287_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/workpad_defconfig b/arch/mips/configs/workpad_defconfig
index 4891d02ef8ca..3a3ef20b21cc 100644
--- a/arch/mips/configs/workpad_defconfig
+++ b/arch/mips/configs/workpad_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.18-rc2
4# Thu Jul 6 10:04:21 2006 4# Tue Jul 25 23:13:04 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -166,6 +165,7 @@ CONFIG_SWAP=y
166CONFIG_SYSVIPC=y 165CONFIG_SYSVIPC=y
167# CONFIG_POSIX_MQUEUE is not set 166# CONFIG_POSIX_MQUEUE is not set
168# CONFIG_BSD_PROCESS_ACCT is not set 167# CONFIG_BSD_PROCESS_ACCT is not set
168# CONFIG_TASKSTATS is not set
169CONFIG_SYSCTL=y 169CONFIG_SYSCTL=y
170# CONFIG_AUDIT is not set 170# CONFIG_AUDIT is not set
171# CONFIG_IKCONFIG is not set 171# CONFIG_IKCONFIG is not set
@@ -379,6 +379,7 @@ CONFIG_CONNECTOR=m
379CONFIG_BLK_DEV_RAM=m 379CONFIG_BLK_DEV_RAM=m
380CONFIG_BLK_DEV_RAM_COUNT=16 380CONFIG_BLK_DEV_RAM_COUNT=16
381CONFIG_BLK_DEV_RAM_SIZE=4096 381CONFIG_BLK_DEV_RAM_SIZE=4096
382CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
382# CONFIG_BLK_DEV_INITRD is not set 383# CONFIG_BLK_DEV_INITRD is not set
383# CONFIG_CDROM_PKTCDVD is not set 384# CONFIG_CDROM_PKTCDVD is not set
384# CONFIG_ATA_OVER_ETH is not set 385# CONFIG_ATA_OVER_ETH is not set
@@ -855,7 +856,6 @@ CONFIG_SUNRPC=y
855# CONFIG_RPCSEC_GSS_SPKM3 is not set 856# CONFIG_RPCSEC_GSS_SPKM3 is not set
856# CONFIG_SMB_FS is not set 857# CONFIG_SMB_FS is not set
857# CONFIG_CIFS is not set 858# CONFIG_CIFS is not set
858# CONFIG_CIFS_DEBUG2 is not set
859# CONFIG_NCP_FS is not set 859# CONFIG_NCP_FS is not set
860# CONFIG_CODA_FS is not set 860# CONFIG_CODA_FS is not set
861# CONFIG_AFS_FS is not set 861# CONFIG_AFS_FS is not set
@@ -880,6 +880,7 @@ CONFIG_MSDOS_PARTITION=y
880# 880#
881# Kernel hacking 881# Kernel hacking
882# 882#
883CONFIG_TRACE_IRQFLAGS_SUPPORT=y
883# CONFIG_PRINTK_TIME is not set 884# CONFIG_PRINTK_TIME is not set
884# CONFIG_MAGIC_SYSRQ is not set 885# CONFIG_MAGIC_SYSRQ is not set
885# CONFIG_UNUSED_SYMBOLS is not set 886# CONFIG_UNUSED_SYMBOLS is not set
@@ -887,7 +888,7 @@ CONFIG_MSDOS_PARTITION=y
887CONFIG_LOG_BUF_SHIFT=14 888CONFIG_LOG_BUF_SHIFT=14
888# CONFIG_DEBUG_FS is not set 889# CONFIG_DEBUG_FS is not set
889CONFIG_CROSSCOMPILE=y 890CONFIG_CROSSCOMPILE=y
890CONFIG_CMDLINE="console=ttyVR0,19200 mem=16M" 891CONFIG_CMDLINE="console=ttyVR0,19200 ide0=0x170,0x376,49 mem=16M"
891 892
892# 893#
893# Security options 894# Security options
diff --git a/arch/mips/configs/wrppmc_defconfig b/arch/mips/configs/wrppmc_defconfig
index 3e4b16b39827..e6b1dea55842 100644
--- a/arch/mips/configs/wrppmc_defconfig
+++ b/arch/mips/configs/wrppmc_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig
index 3a68d8a25b66..06a072b77b1c 100644
--- a/arch/mips/configs/yosemite_defconfig
+++ b/arch/mips/configs/yosemite_defconfig
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
diff --git a/arch/mips/defconfig b/arch/mips/defconfig
index fff6fcc96212..cc9b24eda9e8 100644
--- a/arch/mips/defconfig
+++ b/arch/mips/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.18-rc1
4# Thu Jul 6 09:49:33 2006 4# Thu Jul 6 10:04:10 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_MIPS=y
7 7
@@ -25,7 +25,6 @@ CONFIG_MIPS=y
25# CONFIG_MIPS_COBALT is not set 25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set 26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set 27# CONFIG_MIPS_EV64120 is not set
28# CONFIG_MIPS_EV96100 is not set
29# CONFIG_MIPS_IVR is not set 28# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set 29# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set 30# CONFIG_MACH_JAZZ is not set
@@ -1013,7 +1012,7 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1013CONFIG_PROC_FS=y 1012CONFIG_PROC_FS=y
1014CONFIG_PROC_KCORE=y 1013CONFIG_PROC_KCORE=y
1015CONFIG_SYSFS=y 1014CONFIG_SYSFS=y
1016# CONFIG_TMPFS is not set 1015CONFIG_TMPFS=y
1017# CONFIG_HUGETLB_PAGE is not set 1016# CONFIG_HUGETLB_PAGE is not set
1018CONFIG_RAMFS=y 1017CONFIG_RAMFS=y
1019# CONFIG_CONFIGFS_FS is not set 1018# CONFIG_CONFIGFS_FS is not set
diff --git a/arch/mips/galileo-boards/ev96100/Makefile b/arch/mips/galileo-boards/ev96100/Makefile
deleted file mode 100644
index cd868ec78cbc..000000000000
--- a/arch/mips/galileo-boards/ev96100/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
1#
2# Copyright 2000 MontaVista Software Inc.
3# Author: MontaVista Software, Inc.
4# ppopov@mvista.com or source@mvista.com
5#
6# Makefile for the Galileo EV96100 board.
7#
8
9obj-y += init.o irq.o puts.o reset.o time.o setup.o
diff --git a/arch/mips/galileo-boards/ev96100/init.c b/arch/mips/galileo-boards/ev96100/init.c
deleted file mode 100644
index a01fe9b36f2c..000000000000
--- a/arch/mips/galileo-boards/ev96100/init.c
+++ /dev/null
@@ -1,173 +0,0 @@
1/*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ppopov@mvista.com or source@mvista.com
5 *
6 * This file was derived from Carsten Langgaard's
7 * arch/mips/mips-boards/generic/generic.c
8 *
9 * Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32#include <linux/init.h>
33#include <linux/mm.h>
34#include <linux/sched.h>
35#include <linux/bootmem.h>
36#include <linux/string.h>
37#include <linux/kernel.h>
38
39#include <asm/addrspace.h>
40#include <asm/bootinfo.h>
41#include <asm/gt64120.h>
42
43
44/* Environment variable */
45
46typedef struct {
47 char *name;
48 char *val;
49} t_env_var;
50
51int prom_argc;
52char **prom_argv, **prom_envp;
53
54int init_debug = 0;
55
56char * __init prom_getcmdline(void)
57{
58 return &(arcs_cmdline[0]);
59}
60
61unsigned long __init prom_free_prom_memory(void)
62{
63 return 0;
64}
65
66void __init prom_init_cmdline(void)
67{
68 char *cp;
69 int actr;
70
71 actr = 1; /* Always ignore argv[0] */
72
73 cp = &(arcs_cmdline[0]);
74 while(actr < prom_argc) {
75 strcpy(cp, prom_argv[actr]);
76 cp += strlen(prom_argv[actr]);
77 *cp++ = ' ';
78 actr++;
79 }
80 if (cp != &(arcs_cmdline[0])) /* get rid of trailing space */
81 --cp;
82 *cp = '\0';
83}
84
85char *prom_getenv(char *envname)
86{
87 /*
88 * Return a pointer to the given environment variable.
89 */
90
91 t_env_var *env = (t_env_var *) prom_envp;
92 int i;
93
94 i = strlen(envname);
95
96 while (env->name) {
97 if (strncmp(envname, env->name, i) == 0) {
98 return (env->val);
99 }
100 env++;
101 }
102 return (NULL);
103}
104
105static inline unsigned char str2hexnum(unsigned char c)
106{
107 if (c >= '0' && c <= '9')
108 return c - '0';
109 if (c >= 'a' && c <= 'f')
110 return c - 'a' + 10;
111 return 0; /* foo */
112}
113
114static inline void str2eaddr(unsigned char *ea, unsigned char *str)
115{
116 int i;
117
118 for (i = 0; i < 6; i++) {
119 unsigned char num;
120
121 if ((*str == '.') || (*str == ':'))
122 str++;
123 num = str2hexnum(*str++) << 4;
124 num |= (str2hexnum(*str++));
125 ea[i] = num;
126 }
127}
128
129int get_ethernet_addr(char *ethernet_addr)
130{
131 char *ethaddr_str;
132
133 ethaddr_str = prom_getenv("ethaddr");
134 if (!ethaddr_str) {
135 printk("ethaddr not set in boot prom\n");
136 return -1;
137 }
138 str2eaddr(ethernet_addr, ethaddr_str);
139
140 if (init_debug > 1) {
141 int i;
142 printk("get_ethernet_addr: ");
143 for (i = 0; i < 5; i++)
144 printk("%02x:",
145 (unsigned char) *(ethernet_addr + i));
146 printk("%02x\n", *(ethernet_addr + i));
147 }
148
149 return 0;
150}
151
152const char *get_system_type(void)
153{
154 return "Galileo EV96100";
155}
156
157void __init prom_init(void)
158{
159 volatile unsigned char *uart;
160 char ppbuf[8];
161
162 prom_argc = fw_arg0;
163 prom_argv = (char **) fw_arg1;
164 prom_envp = (char **) fw_arg2;
165
166 mips_machgroup = MACH_GROUP_GALILEO;
167 mips_machtype = MACH_EV96100;
168
169 prom_init_cmdline();
170
171 /* 32 MB upgradable */
172 add_memory_region(0, 32 << 20, BOOT_MEM_RAM);
173}
diff --git a/arch/mips/galileo-boards/ev96100/irq.c b/arch/mips/galileo-boards/ev96100/irq.c
deleted file mode 100644
index ee5d6720f23b..000000000000
--- a/arch/mips/galileo-boards/ev96100/irq.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ppopov@mvista.com or source@mvista.com
5 *
6 * This file was derived from Carsten Langgaard's
7 * arch/mips/mips-boards/atlas/atlas_int.c.
8 *
9 * Carsten Langgaard, carstenl@mips.com
10 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
11 *
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
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
20 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * You should have received a copy of the GNU General Public License along
29 * with this program; if not, write to the Free Software Foundation, Inc.,
30 * 675 Mass Ave, Cambridge, MA 02139, USA.
31 */
32#include <linux/errno.h>
33#include <linux/init.h>
34#include <linux/kernel_stat.h>
35#include <linux/irq.h>
36#include <linux/module.h>
37#include <linux/signal.h>
38#include <linux/sched.h>
39#include <linux/types.h>
40#include <linux/interrupt.h>
41#include <asm/irq_cpu.h>
42
43static inline unsigned int ffz8(unsigned int word)
44{
45 unsigned long k;
46
47 k = 7;
48 if (word & 0x0fUL) { k -= 4; word <<= 4; }
49 if (word & 0x30UL) { k -= 2; word <<= 2; }
50 if (word & 0x40UL) { k -= 1; }
51
52 return k;
53}
54
55extern void mips_timer_interrupt(struct pt_regs *regs);
56
57asmlinkage void ev96100_cpu_irq(unsigned int pending, struct pt_regs *regs)
58{
59 do_IRQ(ffz8(pending >> 8), regs);
60}
61
62asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
63{
64 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
65
66 if (pending & CAUSEF_IP7)
67 mips_timer_interrupt(regs);
68 else if (pending)
69 ev96100_cpu_irq(pending, regs);
70 else
71 spurious_interrupt(regs);
72}
73
74void __init arch_init_irq(void)
75{
76 mips_cpu_irq_init(0);
77}
diff --git a/arch/mips/galileo-boards/ev96100/puts.c b/arch/mips/galileo-boards/ev96100/puts.c
deleted file mode 100644
index 49dc6d137b9c..000000000000
--- a/arch/mips/galileo-boards/ev96100/puts.c
+++ /dev/null
@@ -1,138 +0,0 @@
1
2/*
3 * Debug routines which directly access the uart.
4 */
5
6#include <linux/types.h>
7#include <asm/gt64120.h>
8
9
10//#define SERIAL_BASE EV96100_UART0_REGS_BASE
11#define SERIAL_BASE 0xBD000020
12#define NS16550_BASE SERIAL_BASE
13
14#define SERA_CMD 0x0D
15#define SERA_DATA 0x08
16//#define SERB_CMD 0x05
17#define SERB_CMD 20
18#define SERB_DATA 0x00
19#define TX_BUSY 0x20
20
21#define TIMEOUT 0xffff
22#undef SLOW_DOWN
23
24static const char digits[16] = "0123456789abcdef";
25static volatile unsigned char *const com1 = (unsigned char *) SERIAL_BASE;
26
27
28#ifdef SLOW_DOWN
29static inline void slow_down()
30{
31 int k;
32 for (k = 0; k < 10000; k++);
33}
34#else
35#define slow_down()
36#endif
37
38void putch(const unsigned char c)
39{
40 unsigned char ch;
41 int i = 0;
42
43 do {
44 ch = com1[SERB_CMD];
45 slow_down();
46 i++;
47 if (i > TIMEOUT) {
48 break;
49 }
50 } while (0 == (ch & TX_BUSY));
51 com1[SERB_DATA] = c;
52}
53
54void putchar(const unsigned char c)
55{
56 unsigned char ch;
57 int i = 0;
58
59 do {
60 ch = com1[SERB_CMD];
61 slow_down();
62 i++;
63 if (i > TIMEOUT) {
64 break;
65 }
66 } while (0 == (ch & TX_BUSY));
67 com1[SERB_DATA] = c;
68}
69
70void puts(unsigned char *cp)
71{
72 unsigned char ch;
73 int i = 0;
74
75 while (*cp) {
76 do {
77 ch = com1[SERB_CMD];
78 slow_down();
79 i++;
80 if (i > TIMEOUT) {
81 break;
82 }
83 } while (0 == (ch & TX_BUSY));
84 com1[SERB_DATA] = *cp++;
85 }
86 putch('\r');
87 putch('\n');
88}
89
90void fputs(unsigned char *cp)
91{
92 unsigned char ch;
93 int i = 0;
94
95 while (*cp) {
96
97 do {
98 ch = com1[SERB_CMD];
99 slow_down();
100 i++;
101 if (i > TIMEOUT) {
102 break;
103 }
104 } while (0 == (ch & TX_BUSY));
105 com1[SERB_DATA] = *cp++;
106 }
107}
108
109
110void put64(uint64_t ul)
111{
112 int cnt;
113 unsigned ch;
114
115 cnt = 16; /* 16 nibbles in a 64 bit long */
116 putch('0');
117 putch('x');
118 do {
119 cnt--;
120 ch = (unsigned char) (ul >> cnt * 4) & 0x0F;
121 putch(digits[ch]);
122 } while (cnt > 0);
123}
124
125void put32(unsigned u)
126{
127 int cnt;
128 unsigned ch;
129
130 cnt = 8; /* 8 nibbles in a 32 bit long */
131 putch('0');
132 putch('x');
133 do {
134 cnt--;
135 ch = (unsigned char) (u >> cnt * 4) & 0x0F;
136 putch(digits[ch]);
137 } while (cnt > 0);
138}
diff --git a/arch/mips/galileo-boards/ev96100/reset.c b/arch/mips/galileo-boards/ev96100/reset.c
deleted file mode 100644
index 5ef9b7f896e6..000000000000
--- a/arch/mips/galileo-boards/ev96100/reset.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Galileo EV96100 reset routines.
4 *
5 * Copyright 2000 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc.
7 * ppopov@mvista.com or source@mvista.com
8 *
9 * This file was derived from Carsten Langgaard's
10 * arch/mips/mips-boards/generic/reset.c
11 *
12 * Carsten Langgaard, carstenl@mips.com
13 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35#include <linux/sched.h>
36#include <linux/mm.h>
37#include <asm/io.h>
38#include <asm/pgtable.h>
39#include <asm/processor.h>
40#include <asm/reboot.h>
41#include <asm/system.h>
42#include <asm/gt64120.h>
43
44static void mips_machine_restart(char *command);
45static void mips_machine_halt(void);
46
47static void mips_machine_restart(char *command)
48{
49 set_c0_status(ST0_BEV | ST0_ERL);
50 change_c0_config(CONF_CM_CMASK, CONF_CM_UNCACHED);
51 flush_cache_all();
52 write_c0_wired(0);
53 __asm__ __volatile__("jr\t%0"::"r"(0xbfc00000));
54 while (1);
55}
56
57static void mips_machine_halt(void)
58{
59 printk(KERN_NOTICE "You can safely turn off the power\n");
60 while (1)
61 __asm__(".set\tmips3\n\t"
62 "wait\n\t"
63 ".set\tmips0");
64}
65
66void mips_reboot_setup(void)
67{
68 _machine_restart = mips_machine_restart;
69 _machine_halt = mips_machine_halt;
70}
diff --git a/arch/mips/galileo-boards/ev96100/setup.c b/arch/mips/galileo-boards/ev96100/setup.c
deleted file mode 100644
index 639ad5562c63..000000000000
--- a/arch/mips/galileo-boards/ev96100/setup.c
+++ /dev/null
@@ -1,159 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Galileo EV96100 setup.
4 *
5 * Copyright 2000 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc.
7 * ppopov@mvista.com or source@mvista.com
8 *
9 * This file was derived from Carsten Langgaard's
10 * arch/mips/mips-boards/atlas/atlas_setup.c.
11 *
12 * Carsten Langgaard, carstenl@mips.com
13 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35#include <linux/init.h>
36#include <linux/sched.h>
37#include <linux/ioport.h>
38#include <linux/string.h>
39#include <linux/ctype.h>
40#include <linux/pci.h>
41
42#include <asm/cpu.h>
43#include <asm/bootinfo.h>
44#include <asm/mipsregs.h>
45#include <asm/irq.h>
46#include <asm/delay.h>
47#include <asm/gt64120.h>
48#include <asm/galileo-boards/ev96100int.h>
49
50
51extern char *__init prom_getcmdline(void);
52
53extern void mips_reboot_setup(void);
54
55unsigned char mac_0_1[12];
56
57void __init plat_mem_setup(void)
58{
59 unsigned int config = read_c0_config();
60 unsigned int status = read_c0_status();
61 unsigned int info = read_c0_info();
62 u32 tmp;
63
64 char *argptr;
65
66 clear_c0_status(ST0_FR);
67
68 if (config & 0x8)
69 printk("Secondary cache is enabled\n");
70 else
71 printk("Secondary cache is disabled\n");
72
73 if (status & (1 << 27))
74 printk("User-mode cache ops enabled\n");
75 else
76 printk("User-mode cache ops disabled\n");
77
78 printk("CP0 info reg: %x\n", (unsigned) info);
79 if (info & (1 << 28))
80 printk("burst mode Scache RAMS\n");
81 else
82 printk("pipelined Scache RAMS\n");
83
84 if (info & 0x1)
85 printk("Atomic Enable is set\n");
86
87 argptr = prom_getcmdline();
88#ifdef CONFIG_SERIAL_CONSOLE
89 if (strstr(argptr, "console=") == NULL) {
90 argptr = prom_getcmdline();
91 strcat(argptr, " console=ttyS0,115200");
92 }
93#endif
94
95 mips_reboot_setup();
96
97 set_io_port_base(KSEG1);
98 ioport_resource.start = GT_PCI_IO_BASE;
99 ioport_resource.end = GT_PCI_IO_BASE + 0x01ffffff;
100
101#ifdef CONFIG_BLK_DEV_INITRD
102 ROOT_DEV = MKDEV(RAMDISK_MAJOR, 0);
103#endif
104
105
106 /*
107 * Setup GT controller master bit so we can do config cycles
108 */
109
110 /* Clear cause register bits */
111 GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT |
112 GT_INTRCAUSE_TARABORT0_BIT));
113 /* Setup address */
114 GT_WRITE(GT_PCI0_CFGADDR_OFS,
115 (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) |
116 (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
117 ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) |
118 GT_PCI0_CFGADDR_CONFIGEN_BIT);
119
120 udelay(2);
121 tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
122
123 tmp |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY |
124 PCI_COMMAND_MASTER | PCI_COMMAND_SERR);
125 GT_WRITE(GT_PCI0_CFGADDR_OFS,
126 (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) |
127 (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
128 ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) |
129 GT_PCI0_CFGADDR_CONFIGEN_BIT);
130 udelay(2);
131 GT_WRITE(GT_PCI0_CFGDATA_OFS, tmp);
132
133 /* Setup address */
134 GT_WRITE(GT_PCI0_CFGADDR_OFS,
135 (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) |
136 (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
137 ((PCI_COMMAND / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) |
138 GT_PCI0_CFGADDR_CONFIGEN_BIT);
139
140 udelay(2);
141 tmp = GT_READ(GT_PCI0_CFGDATA_OFS);
142}
143
144unsigned short get_gt_devid(void)
145{
146 u32 gt_devid;
147
148 /* Figure out if this is a gt96100 or gt96100A */
149 GT_WRITE(GT_PCI0_CFGADDR_OFS,
150 (0 << GT_PCI0_CFGADDR_BUSNUM_SHF) |
151 (0 << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
152 ((PCI_VENDOR_ID / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) |
153 GT_PCI0_CFGADDR_CONFIGEN_BIT);
154
155 udelay(4);
156 gt_devid = GT_READ(GT_PCI0_CFGDATA_OFS);
157
158 return gt_devid >> 16;
159}
diff --git a/arch/mips/galileo-boards/ev96100/time.c b/arch/mips/galileo-boards/ev96100/time.c
deleted file mode 100644
index 8cbe8426491a..000000000000
--- a/arch/mips/galileo-boards/ev96100/time.c
+++ /dev/null
@@ -1,88 +0,0 @@
1/*
2 * BRIEF MODULE DESCRIPTION
3 * Galileo EV96100 rtc routines.
4 *
5 * Copyright 2000 MontaVista Software Inc.
6 * Author: MontaVista Software, Inc.
7 * ppopov@mvista.com or source@mvista.com
8 *
9 * This file was derived from Carsten Langgaard's
10 * arch/mips/mips-boards/atlas/atlas_rtc.c.
11 *
12 * Carsten Langgaard, carstenl@mips.com
13 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
14 *
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the
17 * Free Software Foundation; either version 2 of the License, or (at your
18 * option) any later version.
19 *
20 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
23 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
27 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 *
31 * You should have received a copy of the GNU General Public License along
32 * with this program; if not, write to the Free Software Foundation, Inc.,
33 * 675 Mass Ave, Cambridge, MA 02139, USA.
34 */
35#include <linux/init.h>
36#include <linux/kernel_stat.h>
37#include <linux/module.h>
38#include <linux/sched.h>
39#include <linux/spinlock.h>
40#include <linux/timex.h>
41
42#include <asm/mipsregs.h>
43#include <asm/ptrace.h>
44#include <asm/time.h>
45
46
47#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
48
49extern volatile unsigned long wall_jiffies;
50unsigned long missed_heart_beats = 0;
51
52static unsigned long r4k_offset; /* Amount to increment compare reg each time */
53static unsigned long r4k_cur; /* What counter should be at next timer irq */
54
55static inline void ack_r4ktimer(unsigned long newval)
56{
57 write_c0_compare(newval);
58}
59
60/*
61 * There are a lot of conceptually broken versions of the MIPS timer interrupt
62 * handler floating around. This one is rather different, but the algorithm
63 * is probably more robust.
64 */
65void mips_timer_interrupt(struct pt_regs *regs)
66{
67 int irq = 7; /* FIX ME */
68
69 if (r4k_offset == 0) {
70 goto null;
71 }
72
73 do {
74 kstat_this_cpu.irqs[irq]++;
75 do_timer(regs);
76#ifndef CONFIG_SMP
77 update_process_times(user_mode(regs));
78#endif
79 r4k_cur += r4k_offset;
80 ack_r4ktimer(r4k_cur);
81
82 } while (((unsigned long)read_c0_count()
83 - r4k_cur) < 0x7fffffff);
84 return;
85
86null:
87 ack_r4ktimer(0);
88}
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c
index aa2caa67299a..9fbf8430c849 100644
--- a/arch/mips/kernel/cpu-probe.c
+++ b/arch/mips/kernel/cpu-probe.c
@@ -38,15 +38,40 @@ static void r3081_wait(void)
38 38
39static void r39xx_wait(void) 39static void r39xx_wait(void)
40{ 40{
41 unsigned long cfg = read_c0_conf(); 41 local_irq_disable();
42 write_c0_conf(cfg | TX39_CONF_HALT); 42 if (!need_resched())
43 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
44 local_irq_enable();
43} 45}
44 46
47/*
48 * There is a race when WAIT instruction executed with interrupt
49 * enabled.
50 * But it is implementation-dependent wheter the pipelie restarts when
51 * a non-enabled interrupt is requested.
52 */
45static void r4k_wait(void) 53static void r4k_wait(void)
46{ 54{
47 __asm__(".set\tmips3\n\t" 55 __asm__(" .set mips3 \n"
48 "wait\n\t" 56 " wait \n"
49 ".set\tmips0"); 57 " .set mips0 \n");
58}
59
60/*
61 * This variant is preferable as it allows testing need_resched and going to
62 * sleep depending on the outcome atomically. Unfortunately the "It is
63 * implementation-dependent whether the pipeline restarts when a non-enabled
64 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
65 * using this version a gamble.
66 */
67static void r4k_wait_irqoff(void)
68{
69 local_irq_disable();
70 if (!need_resched())
71 __asm__(" .set mips3 \n"
72 " wait \n"
73 " .set mips0 \n");
74 local_irq_enable();
50} 75}
51 76
52/* The Au1xxx wait is available only if using 32khz counter or 77/* The Au1xxx wait is available only if using 32khz counter or
@@ -56,17 +81,17 @@ int allow_au1k_wait;
56static void au1k_wait(void) 81static void au1k_wait(void)
57{ 82{
58 /* using the wait instruction makes CP0 counter unusable */ 83 /* using the wait instruction makes CP0 counter unusable */
59 __asm__(".set mips3\n\t" 84 __asm__(" .set mips3 \n"
60 "cache 0x14, 0(%0)\n\t" 85 " cache 0x14, 0(%0) \n"
61 "cache 0x14, 32(%0)\n\t" 86 " cache 0x14, 32(%0) \n"
62 "sync\n\t" 87 " sync \n"
63 "nop\n\t" 88 " nop \n"
64 "wait\n\t" 89 " wait \n"
65 "nop\n\t" 90 " nop \n"
66 "nop\n\t" 91 " nop \n"
67 "nop\n\t" 92 " nop \n"
68 "nop\n\t" 93 " nop \n"
69 ".set mips0\n\t" 94 " .set mips0 \n"
70 : : "r" (au1k_wait)); 95 : : "r" (au1k_wait));
71} 96}
72 97
@@ -111,7 +136,6 @@ static inline void check_wait(void)
111 case CPU_NEVADA: 136 case CPU_NEVADA:
112 case CPU_RM7000: 137 case CPU_RM7000:
113 case CPU_RM9000: 138 case CPU_RM9000:
114 case CPU_TX49XX:
115 case CPU_4KC: 139 case CPU_4KC:
116 case CPU_4KEC: 140 case CPU_4KEC:
117 case CPU_4KSC: 141 case CPU_4KSC:
@@ -125,6 +149,10 @@ static inline void check_wait(void)
125 cpu_wait = r4k_wait; 149 cpu_wait = r4k_wait;
126 printk(" available.\n"); 150 printk(" available.\n");
127 break; 151 break;
152 case CPU_TX49XX:
153 cpu_wait = r4k_wait_irqoff;
154 printk(" available.\n");
155 break;
128 case CPU_AU1000: 156 case CPU_AU1000:
129 case CPU_AU1100: 157 case CPU_AU1100:
130 case CPU_AU1500: 158 case CPU_AU1500:
diff --git a/arch/mips/kernel/irixsig.c b/arch/mips/kernel/irixsig.c
index 676e868d26fb..2132485caa74 100644
--- a/arch/mips/kernel/irixsig.c
+++ b/arch/mips/kernel/irixsig.c
@@ -17,6 +17,7 @@
17 17
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
19#include <asm/uaccess.h> 19#include <asm/uaccess.h>
20#include <asm/unistd.h>
20 21
21#undef DEBUG_SIG 22#undef DEBUG_SIG
22 23
@@ -172,11 +173,12 @@ static inline int handle_signal(unsigned long sig, siginfo_t *info,
172 return ret; 173 return ret;
173} 174}
174 175
175asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs) 176void do_irix_signal(struct pt_regs *regs)
176{ 177{
177 struct k_sigaction ka; 178 struct k_sigaction ka;
178 siginfo_t info; 179 siginfo_t info;
179 int signr; 180 int signr;
181 sigset_t *oldset;
180 182
181 /* 183 /*
182 * We want the common case to go fast, which is why we may in certain 184 * We want the common case to go fast, which is why we may in certain
@@ -184,19 +186,28 @@ asmlinkage int do_irix_signal(sigset_t *oldset, struct pt_regs *regs)
184 * if so. 186 * if so.
185 */ 187 */
186 if (!user_mode(regs)) 188 if (!user_mode(regs))
187 return 1; 189 return;
188 190
189 if (try_to_freeze()) 191 if (test_thread_flag(TIF_RESTORE_SIGMASK))
190 goto no_signal; 192 oldset = &current->saved_sigmask;
191 193 else
192 if (!oldset)
193 oldset = &current->blocked; 194 oldset = &current->blocked;
194 195
195 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 196 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
196 if (signr > 0) 197 if (signr > 0) {
197 return handle_signal(signr, &info, &ka, oldset, regs); 198 /* Whee! Actually deliver the signal. */
199 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
200 /* a signal was successfully delivered; the saved
201 * sigmask will have been stored in the signal frame,
202 * and will be restored by sigreturn, so we can simply
203 * clear the TIF_RESTORE_SIGMASK flag */
204 if (test_thread_flag(TIF_RESTORE_SIGMASK))
205 clear_thread_flag(TIF_RESTORE_SIGMASK);
206 }
207
208 return;
209 }
198 210
199no_signal:
200 /* 211 /*
201 * Who's code doesn't conform to the restartable syscall convention 212 * Who's code doesn't conform to the restartable syscall convention
202 * dies here!!! The li instruction, a single machine instruction, 213 * dies here!!! The li instruction, a single machine instruction,
@@ -208,8 +219,22 @@ no_signal:
208 regs->regs[2] == ERESTARTNOINTR) { 219 regs->regs[2] == ERESTARTNOINTR) {
209 regs->cp0_epc -= 8; 220 regs->cp0_epc -= 8;
210 } 221 }
222 if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
223 regs->regs[2] = __NR_restart_syscall;
224 regs->regs[7] = regs->regs[26];
225 regs->cp0_epc -= 4;
226 }
227 regs->regs[0] = 0; /* Don't deal with this again. */
228 }
229
230 /*
231 * If there's no signal to deliver, we just put the saved sigmask
232 * back
233 */
234 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
235 clear_thread_flag(TIF_RESTORE_SIGMASK);
236 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
211 } 237 }
212 return 0;
213} 238}
214 239
215asmlinkage void 240asmlinkage void
@@ -298,6 +323,9 @@ struct sigact_irix5 {
298 int _unused0[2]; 323 int _unused0[2];
299}; 324};
300 325
326#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
327 set only the low 32 bit of the sigset. */
328
301#ifdef DEBUG_SIG 329#ifdef DEBUG_SIG
302static inline void dump_sigact_irix5(struct sigact_irix5 *p) 330static inline void dump_sigact_irix5(struct sigact_irix5 *p)
303{ 331{
@@ -413,7 +441,7 @@ asmlinkage int irix_sigprocmask(int how, irix_sigset_t __user *new,
413 441
414asmlinkage int irix_sigsuspend(struct pt_regs *regs) 442asmlinkage int irix_sigsuspend(struct pt_regs *regs)
415{ 443{
416 sigset_t saveset, newset; 444 sigset_t newset;
417 sigset_t __user *uset; 445 sigset_t __user *uset;
418 446
419 uset = (sigset_t __user *) regs->regs[4]; 447 uset = (sigset_t __user *) regs->regs[4];
@@ -422,18 +450,15 @@ asmlinkage int irix_sigsuspend(struct pt_regs *regs)
422 sigdelsetmask(&newset, ~_BLOCKABLE); 450 sigdelsetmask(&newset, ~_BLOCKABLE);
423 451
424 spin_lock_irq(&current->sighand->siglock); 452 spin_lock_irq(&current->sighand->siglock);
425 saveset = current->blocked; 453 current->saved_sigmask = current->blocked;
426 current->blocked = newset; 454 current->blocked = newset;
427 recalc_sigpending(); 455 recalc_sigpending();
428 spin_unlock_irq(&current->sighand->siglock); 456 spin_unlock_irq(&current->sighand->siglock);
429 457
430 regs->regs[2] = -EINTR; 458 current->state = TASK_INTERRUPTIBLE;
431 while (1) { 459 schedule();
432 current->state = TASK_INTERRUPTIBLE; 460 set_thread_flag(TIF_RESTORE_SIGMASK);
433 schedule(); 461 return -ERESTARTNOHAND;
434 if (do_irix_signal(&saveset, regs))
435 return -EINTR;
436 }
437} 462}
438 463
439/* hate hate hate... */ 464/* hate hate hate... */
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 450ac592da57..43b1162d714f 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -991,7 +991,7 @@ struct sysctl_args32
991 unsigned int __unused[4]; 991 unsigned int __unused[4];
992}; 992};
993 993
994#ifdef CONFIG_SYSCTL 994#ifdef CONFIG_SYSCTL_SYSCALL
995 995
996asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args) 996asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args)
997{ 997{
@@ -1032,7 +1032,7 @@ asmlinkage long sys32_sysctl(struct sysctl_args32 __user *args)
1032 return error; 1032 return error;
1033} 1033}
1034 1034
1035#endif /* CONFIG_SYSCTL */ 1035#endif /* CONFIG_SYSCTL_SYSCALL */
1036 1036
1037asmlinkage long sys32_newuname(struct new_utsname __user * name) 1037asmlinkage long sys32_newuname(struct new_utsname __user * name)
1038{ 1038{
@@ -1296,9 +1296,3 @@ _sys32_clone(nabi_no_regargs struct pt_regs regs)
1296 return do_fork(clone_flags, newsp, &regs, 0, 1296 return do_fork(clone_flags, newsp, &regs, 0,
1297 parent_tidptr, child_tidptr); 1297 parent_tidptr, child_tidptr);
1298} 1298}
1299
1300extern asmlinkage void sys_set_thread_area(u32 addr);
1301asmlinkage void sys32_set_thread_area(u32 addr)
1302{
1303 sys_set_thread_area(AA(addr));
1304}
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 7ab67f786bfe..2613a0dd4b82 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -273,104 +273,107 @@ long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
273 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL); 273 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
274} 274}
275 275
276static struct mips_frame_info { 276/*
277 void *func; 277 *
278 unsigned long func_size; 278 */
279 int frame_size; 279struct mips_frame_info {
280 int pc_offset; 280 void *func;
281} *schedule_frame, mfinfo[64]; 281 unsigned long func_size;
282static int mfinfo_num; 282 int frame_size;
283 283 int pc_offset;
284static int __init get_frame_info(struct mips_frame_info *info) 284};
285
286static inline int is_ra_save_ins(union mips_instruction *ip)
285{ 287{
286 int i; 288 /* sw / sd $ra, offset($sp) */
287 void *func = info->func; 289 return (ip->i_format.opcode == sw_op || ip->i_format.opcode == sd_op) &&
288 union mips_instruction *ip = (union mips_instruction *)func; 290 ip->i_format.rs == 29 &&
291 ip->i_format.rt == 31;
292}
293
294static inline int is_jal_jalr_jr_ins(union mips_instruction *ip)
295{
296 if (ip->j_format.opcode == jal_op)
297 return 1;
298 if (ip->r_format.opcode != spec_op)
299 return 0;
300 return ip->r_format.func == jalr_op || ip->r_format.func == jr_op;
301}
302
303static inline int is_sp_move_ins(union mips_instruction *ip)
304{
305 /* addiu/daddiu sp,sp,-imm */
306 if (ip->i_format.rs != 29 || ip->i_format.rt != 29)
307 return 0;
308 if (ip->i_format.opcode == addiu_op || ip->i_format.opcode == daddiu_op)
309 return 1;
310 return 0;
311}
312
313static int get_frame_info(struct mips_frame_info *info)
314{
315 union mips_instruction *ip = info->func;
316 unsigned max_insns = info->func_size / sizeof(union mips_instruction);
317 unsigned i;
318
289 info->pc_offset = -1; 319 info->pc_offset = -1;
290 info->frame_size = 0; 320 info->frame_size = 0;
291 for (i = 0; i < 128; i++, ip++) {
292 /* if jal, jalr, jr, stop. */
293 if (ip->j_format.opcode == jal_op ||
294 (ip->r_format.opcode == spec_op &&
295 (ip->r_format.func == jalr_op ||
296 ip->r_format.func == jr_op)))
297 break;
298 321
299 if (info->func_size && i >= info->func_size / 4) 322 if (!ip)
323 goto err;
324
325 if (max_insns == 0)
326 max_insns = 128U; /* unknown function size */
327 max_insns = min(128U, max_insns);
328
329 for (i = 0; i < max_insns; i++, ip++) {
330
331 if (is_jal_jalr_jr_ins(ip))
300 break; 332 break;
301 if ( 333 if (!info->frame_size) {
302#ifdef CONFIG_32BIT 334 if (is_sp_move_ins(ip))
303 ip->i_format.opcode == addiu_op && 335 info->frame_size = - ip->i_format.simmediate;
304#endif 336 continue;
305#ifdef CONFIG_64BIT
306 ip->i_format.opcode == daddiu_op &&
307#endif
308 ip->i_format.rs == 29 &&
309 ip->i_format.rt == 29) {
310 /* addiu/daddiu sp,sp,-imm */
311 if (info->frame_size)
312 continue;
313 info->frame_size = - ip->i_format.simmediate;
314 } 337 }
315 338 if (info->pc_offset == -1 && is_ra_save_ins(ip)) {
316 if (
317#ifdef CONFIG_32BIT
318 ip->i_format.opcode == sw_op &&
319#endif
320#ifdef CONFIG_64BIT
321 ip->i_format.opcode == sd_op &&
322#endif
323 ip->i_format.rs == 29 &&
324 ip->i_format.rt == 31) {
325 /* sw / sd $ra, offset($sp) */
326 if (info->pc_offset != -1)
327 continue;
328 info->pc_offset = 339 info->pc_offset =
329 ip->i_format.simmediate / sizeof(long); 340 ip->i_format.simmediate / sizeof(long);
341 break;
330 } 342 }
331 } 343 }
332 if (info->pc_offset == -1 || info->frame_size == 0) { 344 if (info->frame_size && info->pc_offset >= 0) /* nested */
333 if (func == schedule) 345 return 0;
334 printk("Can't analyze prologue code at %p\n", func); 346 if (info->pc_offset < 0) /* leaf */
335 info->pc_offset = -1; 347 return 1;
336 info->frame_size = 0; 348 /* prologue seems boggus... */
337 } 349err:
338 350 return -1;
339 return 0;
340} 351}
341 352
353static struct mips_frame_info schedule_mfi __read_mostly;
354
342static int __init frame_info_init(void) 355static int __init frame_info_init(void)
343{ 356{
344 int i; 357 unsigned long size = 0;
345#ifdef CONFIG_KALLSYMS 358#ifdef CONFIG_KALLSYMS
359 unsigned long ofs;
346 char *modname; 360 char *modname;
347 char namebuf[KSYM_NAME_LEN + 1]; 361 char namebuf[KSYM_NAME_LEN + 1];
348 unsigned long start, size, ofs; 362
349 extern char __sched_text_start[], __sched_text_end[]; 363 kallsyms_lookup((unsigned long)schedule, &size, &ofs, &modname, namebuf);
350 extern char __lock_text_start[], __lock_text_end[];
351
352 start = (unsigned long)__sched_text_start;
353 for (i = 0; i < ARRAY_SIZE(mfinfo); i++) {
354 if (start == (unsigned long)schedule)
355 schedule_frame = &mfinfo[i];
356 if (!kallsyms_lookup(start, &size, &ofs, &modname, namebuf))
357 break;
358 mfinfo[i].func = (void *)(start + ofs);
359 mfinfo[i].func_size = size;
360 start += size - ofs;
361 if (start >= (unsigned long)__lock_text_end)
362 break;
363 if (start == (unsigned long)__sched_text_end)
364 start = (unsigned long)__lock_text_start;
365 }
366#else
367 mfinfo[0].func = schedule;
368 schedule_frame = &mfinfo[0];
369#endif 364#endif
370 for (i = 0; i < ARRAY_SIZE(mfinfo) && mfinfo[i].func; i++) 365 schedule_mfi.func = schedule;
371 get_frame_info(&mfinfo[i]); 366 schedule_mfi.func_size = size;
367
368 get_frame_info(&schedule_mfi);
369
370 /*
371 * Without schedule() frame info, result given by
372 * thread_saved_pc() and get_wchan() are not reliable.
373 */
374 if (schedule_mfi.pc_offset < 0)
375 printk("Can't analyze schedule() prologue at %p\n", schedule);
372 376
373 mfinfo_num = i;
374 return 0; 377 return 0;
375} 378}
376 379
@@ -386,54 +389,86 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
386 /* New born processes are a special case */ 389 /* New born processes are a special case */
387 if (t->reg31 == (unsigned long) ret_from_fork) 390 if (t->reg31 == (unsigned long) ret_from_fork)
388 return t->reg31; 391 return t->reg31;
389 392 if (schedule_mfi.pc_offset < 0)
390 if (!schedule_frame || schedule_frame->pc_offset < 0)
391 return 0; 393 return 0;
392 return ((unsigned long *)t->reg29)[schedule_frame->pc_offset]; 394 return ((unsigned long *)t->reg29)[schedule_mfi.pc_offset];
393} 395}
394 396
395/* get_wchan - a maintenance nightmare^W^Wpain in the ass ... */ 397
396unsigned long get_wchan(struct task_struct *p) 398#ifdef CONFIG_KALLSYMS
399/* used by show_backtrace() */
400unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
401 unsigned long pc, unsigned long ra)
397{ 402{
398 unsigned long stack_page; 403 unsigned long stack_page;
399 unsigned long pc; 404 struct mips_frame_info info;
400#ifdef CONFIG_KALLSYMS 405 char *modname;
401 unsigned long frame; 406 char namebuf[KSYM_NAME_LEN + 1];
402#endif 407 unsigned long size, ofs;
408 int leaf;
403 409
404 if (!p || p == current || p->state == TASK_RUNNING) 410 stack_page = (unsigned long)task_stack_page(task);
411 if (!stack_page)
405 return 0; 412 return 0;
406 413
407 stack_page = (unsigned long)task_stack_page(p); 414 if (!kallsyms_lookup(pc, &size, &ofs, &modname, namebuf))
408 if (!stack_page || !mfinfo_num) 415 return 0;
416 /*
417 * Return ra if an exception occured at the first instruction
418 */
419 if (unlikely(ofs == 0))
420 return ra;
421
422 info.func = (void *)(pc - ofs);
423 info.func_size = ofs; /* analyze from start to ofs */
424 leaf = get_frame_info(&info);
425 if (leaf < 0)
426 return 0;
427
428 if (*sp < stack_page ||
429 *sp + info.frame_size > stack_page + THREAD_SIZE - 32)
409 return 0; 430 return 0;
410 431
411 pc = thread_saved_pc(p); 432 if (leaf)
433 /*
434 * For some extreme cases, get_frame_info() can
435 * consider wrongly a nested function as a leaf
436 * one. In that cases avoid to return always the
437 * same value.
438 */
439 pc = pc != ra ? ra : 0;
440 else
441 pc = ((unsigned long *)(*sp))[info.pc_offset];
442
443 *sp += info.frame_size;
444 return __kernel_text_address(pc) ? pc : 0;
445}
446#endif
447
448/*
449 * get_wchan - a maintenance nightmare^W^Wpain in the ass ...
450 */
451unsigned long get_wchan(struct task_struct *task)
452{
453 unsigned long pc = 0;
412#ifdef CONFIG_KALLSYMS 454#ifdef CONFIG_KALLSYMS
413 if (!in_sched_functions(pc)) 455 unsigned long sp;
414 return pc; 456#endif
415 457
416 frame = p->thread.reg29 + schedule_frame->frame_size; 458 if (!task || task == current || task->state == TASK_RUNNING)
417 do { 459 goto out;
418 int i; 460 if (!task_stack_page(task))
461 goto out;
419 462
420 if (frame < stack_page || frame > stack_page + THREAD_SIZE - 32) 463 pc = thread_saved_pc(task);
421 return 0;
422 464
423 for (i = mfinfo_num - 1; i >= 0; i--) { 465#ifdef CONFIG_KALLSYMS
424 if (pc >= (unsigned long) mfinfo[i].func) 466 sp = task->thread.reg29 + schedule_mfi.frame_size;
425 break;
426 }
427 if (i < 0)
428 break;
429 467
430 pc = ((unsigned long *)frame)[mfinfo[i].pc_offset]; 468 while (in_sched_functions(pc))
431 if (!mfinfo[i].frame_size) 469 pc = unwind_stack(task, &sp, pc, 0);
432 break;
433 frame += mfinfo[i].frame_size;
434 } while (in_sched_functions(pc));
435#endif 470#endif
436 471
472out:
437 return pc; 473 return pc;
438} 474}
439
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index ba1bcd83c7d3..e71785102206 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -662,6 +662,8 @@ einval: li v0, -EINVAL
662 sys sys_tee 4 662 sys sys_tee 4
663 sys sys_vmsplice 4 663 sys sys_vmsplice 4
664 sys sys_move_pages 6 664 sys sys_move_pages 6
665 sys sys_set_robust_list 2
666 sys sys_get_robust_list 3
665 .endm 667 .endm
666 668
667 /* We pre-compute the number of _instruction_ bytes needed to 669 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index 939e172db953..4c22d0b4825d 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -466,3 +466,5 @@ sys_call_table:
466 PTR sys_tee /* 5265 */ 466 PTR sys_tee /* 5265 */
467 PTR sys_vmsplice 467 PTR sys_vmsplice
468 PTR sys_move_pages 468 PTR sys_move_pages
469 PTR sys_set_robust_list
470 PTR sys_get_robust_list
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 98abbc5a9f13..f25c2a2f1038 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -247,7 +247,7 @@ EXPORT(sysn32_call_table)
247 PTR sys_capset 247 PTR sys_capset
248 PTR sys32_rt_sigpending /* 6125 */ 248 PTR sys32_rt_sigpending /* 6125 */
249 PTR compat_sys_rt_sigtimedwait 249 PTR compat_sys_rt_sigtimedwait
250 PTR sys_rt_sigqueueinfo 250 PTR sys32_rt_sigqueueinfo
251 PTR sysn32_rt_sigsuspend 251 PTR sysn32_rt_sigsuspend
252 PTR sys32_sigaltstack 252 PTR sys32_sigaltstack
253 PTR compat_sys_utime /* 6130 */ 253 PTR compat_sys_utime /* 6130 */
@@ -390,5 +390,7 @@ EXPORT(sysn32_call_table)
390 PTR sys_splice 390 PTR sys_splice
391 PTR sys_sync_file_range 391 PTR sys_sync_file_range
392 PTR sys_tee 392 PTR sys_tee
393 PTR sys_vmsplice /* 6271 */ 393 PTR sys_vmsplice /* 6270 */
394 PTR sys_move_pages 394 PTR sys_move_pages
395 PTR compat_sys_set_robust_list
396 PTR compat_sys_get_robust_list
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 505c9ee54009..288ee4ac4dbb 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -498,7 +498,7 @@ sys_call_table:
498 PTR sys_mknodat /* 4290 */ 498 PTR sys_mknodat /* 4290 */
499 PTR sys_fchownat 499 PTR sys_fchownat
500 PTR compat_sys_futimesat 500 PTR compat_sys_futimesat
501 PTR compat_sys_newfstatat 501 PTR sys_newfstatat
502 PTR sys_unlinkat 502 PTR sys_unlinkat
503 PTR sys_renameat /* 4295 */ 503 PTR sys_renameat /* 4295 */
504 PTR sys_linkat 504 PTR sys_linkat
@@ -514,4 +514,6 @@ sys_call_table:
514 PTR sys_tee 514 PTR sys_tee
515 PTR sys_vmsplice 515 PTR sys_vmsplice
516 PTR compat_sys_move_pages 516 PTR compat_sys_move_pages
517 PTR compat_sys_set_robust_list
518 PTR compat_sys_get_robust_list /* 4310 */
517 .size sys_call_table,.-sys_call_table 519 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8c2b596a136f..fdbb508661c5 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -10,29 +10,15 @@
10 * Copyright (C) 1999 Silicon Graphics, Inc. 10 * Copyright (C) 1999 Silicon Graphics, Inc.
11 * Copyright (C) 2000 2001, 2002 Maciej W. Rozycki 11 * Copyright (C) 2000 2001, 2002 Maciej W. Rozycki
12 */ 12 */
13#include <linux/errno.h>
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/ioport.h> 14#include <linux/ioport.h>
16#include <linux/sched.h>
17#include <linux/kernel.h>
18#include <linux/mm.h>
19#include <linux/module.h> 15#include <linux/module.h>
20#include <linux/stddef.h>
21#include <linux/string.h>
22#include <linux/unistd.h>
23#include <linux/slab.h>
24#include <linux/user.h>
25#include <linux/utsname.h>
26#include <linux/a.out.h>
27#include <linux/screen_info.h> 16#include <linux/screen_info.h>
28#include <linux/bootmem.h> 17#include <linux/bootmem.h>
29#include <linux/initrd.h> 18#include <linux/initrd.h>
30#include <linux/major.h>
31#include <linux/kdev_t.h>
32#include <linux/root_dev.h> 19#include <linux/root_dev.h>
33#include <linux/highmem.h> 20#include <linux/highmem.h>
34#include <linux/console.h> 21#include <linux/console.h>
35#include <linux/mmzone.h>
36#include <linux/pfn.h> 22#include <linux/pfn.h>
37 23
38#include <asm/addrspace.h> 24#include <asm/addrspace.h>
@@ -96,6 +82,12 @@ void __init add_memory_region(phys_t start, phys_t size, long type)
96 int x = boot_mem_map.nr_map; 82 int x = boot_mem_map.nr_map;
97 struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1; 83 struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1;
98 84
85 /* Sanity check */
86 if (start + size < start) {
87 printk("Trying to add an invalid memory region, skipped\n");
88 return;
89 }
90
99 /* 91 /*
100 * Try to merge with previous entry if any. This is far less than 92 * Try to merge with previous entry if any. This is far less than
101 * perfect but is sufficient for most real world cases. 93 * perfect but is sufficient for most real world cases.
@@ -143,167 +135,132 @@ static void __init print_memory_map(void)
143 } 135 }
144} 136}
145 137
146static inline void parse_cmdline_early(void) 138/*
139 * Manage initrd
140 */
141#ifdef CONFIG_BLK_DEV_INITRD
142
143static int __init rd_start_early(char *p)
147{ 144{
148 char c = ' ', *to = command_line, *from = saved_command_line; 145 unsigned long start = memparse(p, &p);
149 unsigned long start_at, mem_size;
150 int len = 0;
151 int usermem = 0;
152 146
153 printk("Determined physical RAM map:\n"); 147#ifdef CONFIG_64BIT
154 print_memory_map(); 148 /* HACK: Guess if the sign extension was forgotten */
149 if (start > 0x0000000080000000 && start < 0x00000000ffffffff)
150 start |= 0xffffffff00000000UL;
151#endif
152 initrd_start = start;
153 initrd_end += start;
155 154
156 for (;;) { 155 return 0;
157 /* 156}
158 * "mem=XXX[kKmM]" defines a memory region from 157early_param("rd_start", rd_start_early);
159 * 0 to <XXX>, overriding the determined size.
160 * "mem=XXX[KkmM]@YYY[KkmM]" defines a memory region from
161 * <YYY> to <YYY>+<XXX>, overriding the determined size.
162 */
163 if (c == ' ' && !memcmp(from, "mem=", 4)) {
164 if (to != command_line)
165 to--;
166 /*
167 * If a user specifies memory size, we
168 * blow away any automatically generated
169 * size.
170 */
171 if (usermem == 0) {
172 boot_mem_map.nr_map = 0;
173 usermem = 1;
174 }
175 mem_size = memparse(from + 4, &from);
176 if (*from == '@')
177 start_at = memparse(from + 1, &from);
178 else
179 start_at = 0;
180 add_memory_region(start_at, mem_size, BOOT_MEM_RAM);
181 }
182 c = *(from++);
183 if (!c)
184 break;
185 if (CL_SIZE <= ++len)
186 break;
187 *(to++) = c;
188 }
189 *to = '\0';
190 158
191 if (usermem) { 159static int __init rd_size_early(char *p)
192 printk("User-defined physical RAM map:\n"); 160{
193 print_memory_map(); 161 initrd_end += memparse(p, &p);
194 } 162
163 return 0;
195} 164}
165early_param("rd_size", rd_size_early);
196 166
197static inline int parse_rd_cmdline(unsigned long* rd_start, unsigned long* rd_end) 167static unsigned long __init init_initrd(void)
198{ 168{
169 unsigned long tmp, end, size;
170 u32 *initrd_header;
171
172 ROOT_DEV = Root_RAM0;
173
199 /* 174 /*
200 * "rd_start=0xNNNNNNNN" defines the memory address of an initrd 175 * Board specific code or command line parser should have
201 * "rd_size=0xNN" it's size 176 * already set up initrd_start and initrd_end. In these cases
177 * perfom sanity checks and use them if all looks good.
202 */ 178 */
203 unsigned long start = 0; 179 size = initrd_end - initrd_start;
204 unsigned long size = 0; 180 if (initrd_end == 0 || size == 0) {
205 unsigned long end; 181 initrd_start = 0;
206 char cmd_line[CL_SIZE]; 182 initrd_end = 0;
207 char *start_str; 183 } else
208 char *size_str; 184 return initrd_end;
209 char *tmp; 185
210 186 end = (unsigned long)&_end;
211 strcpy(cmd_line, command_line); 187 tmp = PAGE_ALIGN(end) - sizeof(u32) * 2;
212 *command_line = 0; 188 if (tmp < end)
213 tmp = cmd_line; 189 tmp += PAGE_SIZE;
214 /* Ignore "rd_start=" strings in other parameters. */ 190
215 start_str = strstr(cmd_line, "rd_start="); 191 initrd_header = (u32 *)tmp;
216 if (start_str && start_str != cmd_line && *(start_str - 1) != ' ') 192 if (initrd_header[0] == 0x494E5244) {
217 start_str = strstr(start_str, " rd_start="); 193 initrd_start = (unsigned long)&initrd_header[2];
218 while (start_str) { 194 initrd_end = initrd_start + initrd_header[1];
219 if (start_str != cmd_line)
220 strncat(command_line, tmp, start_str - tmp);
221 start = memparse(start_str + 9, &start_str);
222 tmp = start_str + 1;
223 start_str = strstr(start_str, " rd_start=");
224 } 195 }
225 if (*tmp) 196 return initrd_end;
226 strcat(command_line, tmp); 197}
227 198
228 strcpy(cmd_line, command_line); 199static void __init finalize_initrd(void)
229 *command_line = 0; 200{
230 tmp = cmd_line; 201 unsigned long size = initrd_end - initrd_start;
231 /* Ignore "rd_size" strings in other parameters. */ 202
232 size_str = strstr(cmd_line, "rd_size="); 203 if (size == 0) {
233 if (size_str && size_str != cmd_line && *(size_str - 1) != ' ') 204 printk(KERN_INFO "Initrd not found or empty");
234 size_str = strstr(size_str, " rd_size="); 205 goto disable;
235 while (size_str) { 206 }
236 if (size_str != cmd_line) 207 if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) {
237 strncat(command_line, tmp, size_str - tmp); 208 printk("Initrd extends beyond end of memory");
238 size = memparse(size_str + 8, &size_str); 209 goto disable;
239 tmp = size_str + 1;
240 size_str = strstr(size_str, " rd_size=");
241 } 210 }
242 if (*tmp)
243 strcat(command_line, tmp);
244 211
245#ifdef CONFIG_64BIT 212 reserve_bootmem(CPHYSADDR(initrd_start), size);
246 /* HACK: Guess if the sign extension was forgotten */ 213 initrd_below_start_ok = 1;
247 if (start > 0x0000000080000000 && start < 0x00000000ffffffff) 214
248 start |= 0xffffffff00000000UL; 215 printk(KERN_INFO "Initial ramdisk at: 0x%lx (%lu bytes)\n",
216 initrd_start, size);
217 return;
218disable:
219 printk(" - disabling initrd\n");
220 initrd_start = 0;
221 initrd_end = 0;
222}
223
224#else /* !CONFIG_BLK_DEV_INITRD */
225
226#define init_initrd() 0
227#define finalize_initrd() do {} while (0)
228
249#endif 229#endif
250 230
251 end = start + size; 231/*
252 if (start && end) { 232 * Initialize the bootmem allocator. It also setup initrd related data
253 *rd_start = start; 233 * if needed.
254 *rd_end = end; 234 */
255 return 1; 235#ifdef CONFIG_SGI_IP27
256 } 236
257 return 0; 237static void __init bootmem_init(void)
238{
239 init_initrd();
240 finalize_initrd();
258} 241}
259 242
260#define MAXMEM HIGHMEM_START 243#else /* !CONFIG_SGI_IP27 */
261#define MAXMEM_PFN PFN_DOWN(MAXMEM)
262 244
263static inline void bootmem_init(void) 245static void __init bootmem_init(void)
264{ 246{
265 unsigned long start_pfn; 247 unsigned long reserved_end;
266 unsigned long reserved_end = (unsigned long)&_end; 248 unsigned long highest = 0;
267#ifndef CONFIG_SGI_IP27 249 unsigned long mapstart = -1UL;
268 unsigned long first_usable_pfn;
269 unsigned long bootmap_size; 250 unsigned long bootmap_size;
270 int i; 251 int i;
271#endif
272#ifdef CONFIG_BLK_DEV_INITRD
273 int initrd_reserve_bootmem = 0;
274
275 /* Board specific code should have set up initrd_start and initrd_end */
276 ROOT_DEV = Root_RAM0;
277 if (parse_rd_cmdline(&initrd_start, &initrd_end)) {
278 reserved_end = max(reserved_end, initrd_end);
279 initrd_reserve_bootmem = 1;
280 } else {
281 unsigned long tmp;
282 u32 *initrd_header;
283
284 tmp = ((reserved_end + PAGE_SIZE-1) & PAGE_MASK) - sizeof(u32) * 2;
285 if (tmp < reserved_end)
286 tmp += PAGE_SIZE;
287 initrd_header = (u32 *)tmp;
288 if (initrd_header[0] == 0x494E5244) {
289 initrd_start = (unsigned long)&initrd_header[2];
290 initrd_end = initrd_start + initrd_header[1];
291 reserved_end = max(reserved_end, initrd_end);
292 initrd_reserve_bootmem = 1;
293 }
294 }
295#endif /* CONFIG_BLK_DEV_INITRD */
296 252
297 /* 253 /*
298 * Partially used pages are not usable - thus 254 * Init any data related to initrd. It's a nop if INITRD is
299 * we are rounding upwards. 255 * not selected. Once that done we can determine the low bound
256 * of usable memory.
300 */ 257 */
301 start_pfn = PFN_UP(CPHYSADDR(reserved_end)); 258 reserved_end = init_initrd();
259 reserved_end = PFN_UP(CPHYSADDR(max(reserved_end, (unsigned long)&_end)));
302 260
303#ifndef CONFIG_SGI_IP27 261 /*
304 /* Find the highest page frame number we have available. */ 262 * Find the highest page frame number we have available.
305 max_pfn = 0; 263 */
306 first_usable_pfn = -1UL;
307 for (i = 0; i < boot_mem_map.nr_map; i++) { 264 for (i = 0; i < boot_mem_map.nr_map; i++) {
308 unsigned long start, end; 265 unsigned long start, end;
309 266
@@ -312,56 +269,38 @@ static inline void bootmem_init(void)
312 269
313 start = PFN_UP(boot_mem_map.map[i].addr); 270 start = PFN_UP(boot_mem_map.map[i].addr);
314 end = PFN_DOWN(boot_mem_map.map[i].addr 271 end = PFN_DOWN(boot_mem_map.map[i].addr
315 + boot_mem_map.map[i].size); 272 + boot_mem_map.map[i].size);
316 273
317 if (start >= end) 274 if (end > highest)
275 highest = end;
276 if (end <= reserved_end)
318 continue; 277 continue;
319 if (end > max_pfn) 278 if (start >= mapstart)
320 max_pfn = end; 279 continue;
321 if (start < first_usable_pfn) { 280 mapstart = max(reserved_end, start);
322 if (start > start_pfn) {
323 first_usable_pfn = start;
324 } else if (end > start_pfn) {
325 first_usable_pfn = start_pfn;
326 }
327 }
328 } 281 }
329 282
330 /* 283 /*
331 * Determine low and high memory ranges 284 * Determine low and high memory ranges
332 */ 285 */
333 max_low_pfn = max_pfn; 286 if (highest > PFN_DOWN(HIGHMEM_START)) {
334 if (max_low_pfn > MAXMEM_PFN) { 287#ifdef CONFIG_HIGHMEM
335 max_low_pfn = MAXMEM_PFN; 288 highstart_pfn = PFN_DOWN(HIGHMEM_START);
336#ifndef CONFIG_HIGHMEM 289 highend_pfn = highest;
337 /* Maximum memory usable is what is directly addressable */
338 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
339 MAXMEM >> 20);
340 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
341#endif 290#endif
291 highest = PFN_DOWN(HIGHMEM_START);
342 } 292 }
343 293
344#ifdef CONFIG_HIGHMEM
345 /* 294 /*
346 * Crude, we really should make a better attempt at detecting 295 * Initialize the boot-time allocator with low memory only.
347 * highstart_pfn
348 */ 296 */
349 highstart_pfn = highend_pfn = max_pfn; 297 bootmap_size = init_bootmem(mapstart, highest);
350 if (max_pfn > MAXMEM_PFN) {
351 highstart_pfn = MAXMEM_PFN;
352 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
353 (highend_pfn - highstart_pfn) >> (20 - PAGE_SHIFT));
354 }
355#endif
356
357 /* Initialize the boot-time allocator with low memory only. */
358 bootmap_size = init_bootmem(first_usable_pfn, max_low_pfn);
359 298
360 /* 299 /*
361 * Register fully available low RAM pages with the bootmem allocator. 300 * Register fully available low RAM pages with the bootmem allocator.
362 */ 301 */
363 for (i = 0; i < boot_mem_map.nr_map; i++) { 302 for (i = 0; i < boot_mem_map.nr_map; i++) {
364 unsigned long curr_pfn, last_pfn, size; 303 unsigned long start, end, size;
365 304
366 /* 305 /*
367 * Reserve usable memory. 306 * Reserve usable memory.
@@ -369,85 +308,50 @@ static inline void bootmem_init(void)
369 if (boot_mem_map.map[i].type != BOOT_MEM_RAM) 308 if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
370 continue; 309 continue;
371 310
372 /* 311 start = PFN_UP(boot_mem_map.map[i].addr);
373 * We are rounding up the start address of usable memory: 312 end = PFN_DOWN(boot_mem_map.map[i].addr
374 */
375 curr_pfn = PFN_UP(boot_mem_map.map[i].addr);
376 if (curr_pfn >= max_low_pfn)
377 continue;
378 if (curr_pfn < start_pfn)
379 curr_pfn = start_pfn;
380
381 /*
382 * ... and at the end of the usable range downwards:
383 */
384 last_pfn = PFN_DOWN(boot_mem_map.map[i].addr
385 + boot_mem_map.map[i].size); 313 + boot_mem_map.map[i].size);
386
387 if (last_pfn > max_low_pfn)
388 last_pfn = max_low_pfn;
389
390 /* 314 /*
391 * Only register lowmem part of lowmem segment with bootmem. 315 * We are rounding up the start address of usable memory
316 * and at the end of the usable range downwards.
392 */ 317 */
393 size = last_pfn - curr_pfn; 318 if (start >= max_low_pfn)
394 if (curr_pfn > PFN_DOWN(HIGHMEM_START))
395 continue;
396 if (curr_pfn + size - 1 > PFN_DOWN(HIGHMEM_START))
397 size = PFN_DOWN(HIGHMEM_START) - curr_pfn;
398 if (!size)
399 continue; 319 continue;
320 if (start < reserved_end)
321 start = reserved_end;
322 if (end > max_low_pfn)
323 end = max_low_pfn;
400 324
401 /* 325 /*
402 * ... finally, did all the rounding and playing 326 * ... finally, is the area going away?
403 * around just make the area go away?
404 */ 327 */
405 if (last_pfn <= curr_pfn) 328 if (end <= start)
406 continue; 329 continue;
330 size = end - start;
407 331
408 /* Register lowmem ranges */ 332 /* Register lowmem ranges */
409 free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(size)); 333 free_bootmem(PFN_PHYS(start), size << PAGE_SHIFT);
410 memory_present(0, curr_pfn, curr_pfn + size - 1); 334 memory_present(0, start, end);
411 } 335 }
412 336
413 /* Reserve the bootmap memory. */ 337 /*
414 reserve_bootmem(PFN_PHYS(first_usable_pfn), bootmap_size); 338 * Reserve the bootmap memory.
415#endif /* CONFIG_SGI_IP27 */ 339 */
416 340 reserve_bootmem(PFN_PHYS(mapstart), bootmap_size);
417#ifdef CONFIG_BLK_DEV_INITRD
418 initrd_below_start_ok = 1;
419 if (initrd_start) {
420 unsigned long initrd_size = ((unsigned char *)initrd_end) -
421 ((unsigned char *)initrd_start);
422 const int width = sizeof(long) * 2;
423
424 printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
425 (void *)initrd_start, initrd_size);
426
427 if (CPHYSADDR(initrd_end) > PFN_PHYS(max_low_pfn)) {
428 printk("initrd extends beyond end of memory "
429 "(0x%0*Lx > 0x%0*Lx)\ndisabling initrd\n",
430 width,
431 (unsigned long long) CPHYSADDR(initrd_end),
432 width,
433 (unsigned long long) PFN_PHYS(max_low_pfn));
434 initrd_start = initrd_end = 0;
435 initrd_reserve_bootmem = 0;
436 }
437 341
438 if (initrd_reserve_bootmem) 342 /*
439 reserve_bootmem(CPHYSADDR(initrd_start), initrd_size); 343 * Reserve initrd memory if needed.
440 } 344 */
441#endif /* CONFIG_BLK_DEV_INITRD */ 345 finalize_initrd();
442} 346}
443 347
348#endif /* CONFIG_SGI_IP27 */
349
444/* 350/*
445 * arch_mem_init - initialize memory managment subsystem 351 * arch_mem_init - initialize memory managment subsystem
446 * 352 *
447 * o plat_mem_setup() detects the memory configuration and will record detected 353 * o plat_mem_setup() detects the memory configuration and will record detected
448 * memory areas using add_memory_region. 354 * memory areas using add_memory_region.
449 * o parse_cmdline_early() parses the command line for mem= options which,
450 * iff detected, will override the results of the automatic detection.
451 * 355 *
452 * At this stage the memory configuration of the system is known to the 356 * At this stage the memory configuration of the system is known to the
453 * kernel but generic memory managment system is still entirely uninitialized. 357 * kernel but generic memory managment system is still entirely uninitialized.
@@ -465,25 +369,59 @@ static inline void bootmem_init(void)
465 * initialization hook for anything else was introduced. 369 * initialization hook for anything else was introduced.
466 */ 370 */
467 371
468extern void plat_mem_setup(void); 372static int usermem __initdata = 0;
373
374static int __init early_parse_mem(char *p)
375{
376 unsigned long start, size;
377
378 /*
379 * If a user specifies memory size, we
380 * blow away any automatically generated
381 * size.
382 */
383 if (usermem == 0) {
384 boot_mem_map.nr_map = 0;
385 usermem = 1;
386 }
387 start = 0;
388 size = memparse(p, &p);
389 if (*p == '@')
390 start = memparse(p + 1, &p);
391
392 add_memory_region(start, size, BOOT_MEM_RAM);
393 return 0;
394}
395early_param("mem", early_parse_mem);
469 396
470static void __init arch_mem_init(char **cmdline_p) 397static void __init arch_mem_init(char **cmdline_p)
471{ 398{
399 extern void plat_mem_setup(void);
400
472 /* call board setup routine */ 401 /* call board setup routine */
473 plat_mem_setup(); 402 plat_mem_setup();
474 403
404 printk("Determined physical RAM map:\n");
405 print_memory_map();
406
475 strlcpy(command_line, arcs_cmdline, sizeof(command_line)); 407 strlcpy(command_line, arcs_cmdline, sizeof(command_line));
476 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 408 strlcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
477 409
478 *cmdline_p = command_line; 410 *cmdline_p = command_line;
479 411
480 parse_cmdline_early(); 412 parse_early_param();
413
414 if (usermem) {
415 printk("User-defined physical RAM map:\n");
416 print_memory_map();
417 }
418
481 bootmem_init(); 419 bootmem_init();
482 sparse_init(); 420 sparse_init();
483 paging_init(); 421 paging_init();
484} 422}
485 423
486static inline void resource_init(void) 424static void __init resource_init(void)
487{ 425{
488 int i; 426 int i;
489 427
@@ -504,10 +442,10 @@ static inline void resource_init(void)
504 442
505 start = boot_mem_map.map[i].addr; 443 start = boot_mem_map.map[i].addr;
506 end = boot_mem_map.map[i].addr + boot_mem_map.map[i].size - 1; 444 end = boot_mem_map.map[i].addr + boot_mem_map.map[i].size - 1;
507 if (start >= MAXMEM) 445 if (start >= HIGHMEM_START)
508 continue; 446 continue;
509 if (end >= MAXMEM) 447 if (end >= HIGHMEM_START)
510 end = MAXMEM - 1; 448 end = HIGHMEM_START - 1;
511 449
512 res = alloc_bootmem(sizeof(struct resource)); 450 res = alloc_bootmem(sizeof(struct resource));
513 switch (boot_mem_map.map[i].type) { 451 switch (boot_mem_map.map[i].type) {
@@ -536,9 +474,6 @@ static inline void resource_init(void)
536 } 474 }
537} 475}
538 476
539#undef MAXMEM
540#undef MAXMEM_PFN
541
542void __init setup_arch(char **cmdline_p) 477void __init setup_arch(char **cmdline_p)
543{ 478{
544 cpu_probe(); 479 cpu_probe();
diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
index 6b4d9be31615..b9d358e05214 100644
--- a/arch/mips/kernel/signal.c
+++ b/arch/mips/kernel/signal.c
@@ -424,15 +424,11 @@ void do_signal(struct pt_regs *regs)
424 if (!user_mode(regs)) 424 if (!user_mode(regs))
425 return; 425 return;
426 426
427 if (try_to_freeze())
428 goto no_signal;
429
430 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 427 if (test_thread_flag(TIF_RESTORE_SIGMASK))
431 oldset = &current->saved_sigmask; 428 oldset = &current->saved_sigmask;
432 else 429 else
433 oldset = &current->blocked; 430 oldset = &current->blocked;
434 431
435
436 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 432 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
437 if (signr > 0) { 433 if (signr > 0) {
438 /* Whee! Actually deliver the signal. */ 434 /* Whee! Actually deliver the signal. */
@@ -446,9 +442,10 @@ void do_signal(struct pt_regs *regs)
446 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 442 if (test_thread_flag(TIF_RESTORE_SIGMASK))
447 clear_thread_flag(TIF_RESTORE_SIGMASK); 443 clear_thread_flag(TIF_RESTORE_SIGMASK);
448 } 444 }
445
446 return;
449 } 447 }
450 448
451no_signal:
452 /* 449 /*
453 * Who's code doesn't conform to the restartable syscall convention 450 * Who's code doesn't conform to the restartable syscall convention
454 * dies here!!! The li instruction, a single machine instruction, 451 * dies here!!! The li instruction, a single machine instruction,
@@ -466,6 +463,7 @@ no_signal:
466 regs->regs[7] = regs->regs[26]; 463 regs->regs[7] = regs->regs[26];
467 regs->cp0_epc -= 4; 464 regs->cp0_epc -= 4;
468 } 465 }
466 regs->regs[0] = 0; /* Don't deal with this again. */
469 } 467 }
470 468
471 /* 469 /*
diff --git a/arch/mips/kernel/signal32.c b/arch/mips/kernel/signal32.c
index f32a22997c3d..c86a5ddff050 100644
--- a/arch/mips/kernel/signal32.c
+++ b/arch/mips/kernel/signal32.c
@@ -815,9 +815,6 @@ void do_signal32(struct pt_regs *regs)
815 if (!user_mode(regs)) 815 if (!user_mode(regs))
816 return; 816 return;
817 817
818 if (try_to_freeze())
819 goto no_signal;
820
821 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 818 if (test_thread_flag(TIF_RESTORE_SIGMASK))
822 oldset = &current->saved_sigmask; 819 oldset = &current->saved_sigmask;
823 else 820 else
@@ -836,9 +833,10 @@ void do_signal32(struct pt_regs *regs)
836 if (test_thread_flag(TIF_RESTORE_SIGMASK)) 833 if (test_thread_flag(TIF_RESTORE_SIGMASK))
837 clear_thread_flag(TIF_RESTORE_SIGMASK); 834 clear_thread_flag(TIF_RESTORE_SIGMASK);
838 } 835 }
836
837 return;
839 } 838 }
840 839
841no_signal:
842 /* 840 /*
843 * Who's code doesn't conform to the restartable syscall convention 841 * Who's code doesn't conform to the restartable syscall convention
844 * dies here!!! The li instruction, a single machine instruction, 842 * dies here!!! The li instruction, a single machine instruction,
@@ -856,6 +854,7 @@ no_signal:
856 regs->regs[7] = regs->regs[26]; 854 regs->regs[7] = regs->regs[26];
857 regs->cp0_epc -= 4; 855 regs->cp0_epc -= 4;
858 } 856 }
857 regs->regs[0] = 0; /* Don't deal with this again. */
859 } 858 }
860 859
861 /* 860 /*
diff --git a/arch/mips/kernel/smp-mt.c b/arch/mips/kernel/smp-mt.c
index 93429a4d3012..766253c44f3f 100644
--- a/arch/mips/kernel/smp-mt.c
+++ b/arch/mips/kernel/smp-mt.c
@@ -203,7 +203,7 @@ void plat_smp_setup(void)
203 write_vpe_c0_config( read_c0_config()); 203 write_vpe_c0_config( read_c0_config());
204 204
205 /* make sure there are no software interrupts pending */ 205 /* make sure there are no software interrupts pending */
206 write_vpe_c0_cause(read_vpe_c0_cause() & ~(C_SW1|C_SW0)); 206 write_vpe_c0_cause(0);
207 207
208 /* Propagate Config7 */ 208 /* Propagate Config7 */
209 write_vpe_c0_config7(read_c0_config7()); 209 write_vpe_c0_config7(read_c0_config7());
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S
index 4cc3dea36612..76cb31d57482 100644
--- a/arch/mips/kernel/smtc-asm.S
+++ b/arch/mips/kernel/smtc-asm.S
@@ -8,7 +8,7 @@
8#include <asm/regdef.h> 8#include <asm/regdef.h>
9#include <asm/asmmacro.h> 9#include <asm/asmmacro.h>
10#include <asm/stackframe.h> 10#include <asm/stackframe.h>
11#include <asm/stackframe.h> 11#include <asm/irqflags.h>
12 12
13/* 13/*
14 * "Software Interrupt" linkage. 14 * "Software Interrupt" linkage.
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 0721314db657..9951240cc3fd 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -263,7 +263,7 @@ asmlinkage int sys_olduname(struct oldold_utsname __user * name)
263 return error; 263 return error;
264} 264}
265 265
266void sys_set_thread_area(unsigned long addr) 266asmlinkage int sys_set_thread_area(unsigned long addr)
267{ 267{
268 struct thread_info *ti = task_thread_info(current); 268 struct thread_info *ti = task_thread_info(current);
269 269
@@ -271,6 +271,8 @@ void sys_set_thread_area(unsigned long addr)
271 271
272 /* If some future MIPS implementation has this register in hardware, 272 /* If some future MIPS implementation has this register in hardware,
273 * we will need to update it here (and in context switches). */ 273 * we will need to update it here (and in context switches). */
274
275 return 0;
274} 276}
275 277
276asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3) 278asmlinkage int _sys_sysmips(int cmd, long arg1, int arg2, int arg3)
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 954a198494ef..e51d8fd9a152 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -20,6 +20,7 @@
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/kallsyms.h> 21#include <linux/kallsyms.h>
22#include <linux/bootmem.h> 22#include <linux/bootmem.h>
23#include <linux/interrupt.h>
23 24
24#include <asm/bootinfo.h> 25#include <asm/bootinfo.h>
25#include <asm/branch.h> 26#include <asm/branch.h>
@@ -72,28 +73,68 @@ void (*board_nmi_handler_setup)(void);
72void (*board_ejtag_handler_setup)(void); 73void (*board_ejtag_handler_setup)(void);
73void (*board_bind_eic_interrupt)(int irq, int regset); 74void (*board_bind_eic_interrupt)(int irq, int regset);
74 75
75/* 76
76 * These constant is for searching for possible module text segments. 77static void show_raw_backtrace(unsigned long reg29)
77 * MODULE_RANGE is a guess of how much space is likely to be vmalloced. 78{
78 */ 79 unsigned long *sp = (unsigned long *)reg29;
79#define MODULE_RANGE (8*1024*1024) 80 unsigned long addr;
81
82 printk("Call Trace:");
83#ifdef CONFIG_KALLSYMS
84 printk("\n");
85#endif
86 while (!kstack_end(sp)) {
87 addr = *sp++;
88 if (__kernel_text_address(addr))
89 print_ip_sym(addr);
90 }
91 printk("\n");
92}
93
94#ifdef CONFIG_KALLSYMS
95static int raw_show_trace;
96static int __init set_raw_show_trace(char *str)
97{
98 raw_show_trace = 1;
99 return 1;
100}
101__setup("raw_show_trace", set_raw_show_trace);
102
103extern unsigned long unwind_stack(struct task_struct *task, unsigned long *sp,
104 unsigned long pc, unsigned long ra);
105
106static void show_backtrace(struct task_struct *task, struct pt_regs *regs)
107{
108 unsigned long sp = regs->regs[29];
109 unsigned long ra = regs->regs[31];
110 unsigned long pc = regs->cp0_epc;
111
112 if (raw_show_trace || !__kernel_text_address(pc)) {
113 show_raw_backtrace(sp);
114 return;
115 }
116 printk("Call Trace:\n");
117 do {
118 print_ip_sym(pc);
119 pc = unwind_stack(task, &sp, pc, ra);
120 ra = 0;
121 } while (pc);
122 printk("\n");
123}
124#else
125#define show_backtrace(task, r) show_raw_backtrace((r)->regs[29]);
126#endif
80 127
81/* 128/*
82 * This routine abuses get_user()/put_user() to reference pointers 129 * This routine abuses get_user()/put_user() to reference pointers
83 * with at least a bit of error checking ... 130 * with at least a bit of error checking ...
84 */ 131 */
85void show_stack(struct task_struct *task, unsigned long *sp) 132static void show_stacktrace(struct task_struct *task, struct pt_regs *regs)
86{ 133{
87 const int field = 2 * sizeof(unsigned long); 134 const int field = 2 * sizeof(unsigned long);
88 long stackdata; 135 long stackdata;
89 int i; 136 int i;
90 137 unsigned long *sp = (unsigned long *)regs->regs[29];
91 if (!sp) {
92 if (task && task != current)
93 sp = (unsigned long *) task->thread.reg29;
94 else
95 sp = (unsigned long *) &sp;
96 }
97 138
98 printk("Stack :"); 139 printk("Stack :");
99 i = 0; 140 i = 0;
@@ -114,32 +155,48 @@ void show_stack(struct task_struct *task, unsigned long *sp)
114 i++; 155 i++;
115 } 156 }
116 printk("\n"); 157 printk("\n");
158 show_backtrace(task, regs);
117} 159}
118 160
119void show_trace(struct task_struct *task, unsigned long *stack) 161static __always_inline void prepare_frametrace(struct pt_regs *regs)
120{ 162{
121 const int field = 2 * sizeof(unsigned long); 163 __asm__ __volatile__(
122 unsigned long addr; 164 ".set push\n\t"
123 165 ".set noat\n\t"
124 if (!stack) { 166#ifdef CONFIG_64BIT
125 if (task && task != current) 167 "1: dla $1, 1b\n\t"
126 stack = (unsigned long *) task->thread.reg29; 168 "sd $1, %0\n\t"
127 else 169 "sd $29, %1\n\t"
128 stack = (unsigned long *) &stack; 170 "sd $31, %2\n\t"
129 } 171#else
130 172 "1: la $1, 1b\n\t"
131 printk("Call Trace:"); 173 "sw $1, %0\n\t"
132#ifdef CONFIG_KALLSYMS 174 "sw $29, %1\n\t"
133 printk("\n"); 175 "sw $31, %2\n\t"
134#endif 176#endif
135 while (!kstack_end(stack)) { 177 ".set pop\n\t"
136 addr = *stack++; 178 : "=m" (regs->cp0_epc),
137 if (__kernel_text_address(addr)) { 179 "=m" (regs->regs[29]), "=m" (regs->regs[31])
138 printk(" [<%0*lx>] ", field, addr); 180 : : "memory");
139 print_symbol("%s\n", addr); 181}
182
183void show_stack(struct task_struct *task, unsigned long *sp)
184{
185 struct pt_regs regs;
186 if (sp) {
187 regs.regs[29] = (unsigned long)sp;
188 regs.regs[31] = 0;
189 regs.cp0_epc = 0;
190 } else {
191 if (task && task != current) {
192 regs.regs[29] = task->thread.reg29;
193 regs.regs[31] = 0;
194 regs.cp0_epc = task->thread.reg31;
195 } else {
196 prepare_frametrace(&regs);
140 } 197 }
141 } 198 }
142 printk("\n"); 199 show_stacktrace(task, &regs);
143} 200}
144 201
145/* 202/*
@@ -147,9 +204,15 @@ void show_trace(struct task_struct *task, unsigned long *stack)
147 */ 204 */
148void dump_stack(void) 205void dump_stack(void)
149{ 206{
150 unsigned long stack; 207 struct pt_regs regs;
151 208
152 show_trace(current, &stack); 209 /*
210 * Remove any garbage that may be in regs (specially func
211 * addresses) to avoid show_raw_backtrace() to report them
212 */
213 memset(&regs, 0, sizeof(regs));
214 prepare_frametrace(&regs);
215 show_backtrace(current, &regs);
153} 216}
154 217
155EXPORT_SYMBOL(dump_stack); 218EXPORT_SYMBOL(dump_stack);
@@ -268,8 +331,7 @@ void show_registers(struct pt_regs *regs)
268 print_modules(); 331 print_modules();
269 printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n", 332 printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
270 current->comm, current->pid, current_thread_info(), current); 333 current->comm, current->pid, current_thread_info(), current);
271 show_stack(current, (long *) regs->regs[29]); 334 show_stacktrace(current, regs);
272 show_trace(current, (long *) regs->regs[29]);
273 show_code((unsigned int *) regs->cp0_epc); 335 show_code((unsigned int *) regs->cp0_epc);
274 printk("\n"); 336 printk("\n");
275} 337}
@@ -292,6 +354,16 @@ NORET_TYPE void ATTRIB_NORET die(const char * str, struct pt_regs * regs)
292 printk("%s[#%d]:\n", str, ++die_counter); 354 printk("%s[#%d]:\n", str, ++die_counter);
293 show_registers(regs); 355 show_registers(regs);
294 spin_unlock_irq(&die_lock); 356 spin_unlock_irq(&die_lock);
357
358 if (in_interrupt())
359 panic("Fatal exception in interrupt");
360
361 if (panic_on_oops) {
362 printk(KERN_EMERG "Fatal exception: panic in 5 seconds\n");
363 ssleep(5);
364 panic("Fatal exception");
365 }
366
295 do_exit(SIGSEGV); 367 do_exit(SIGSEGV);
296} 368}
297 369
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 9ee0ec2cd067..51ddd2166898 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -768,10 +768,16 @@ int vpe_run(struct vpe * v)
768 */ 768 */
769 write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | v->minor); 769 write_tc_c0_tcbind((read_tc_c0_tcbind() & ~TCBIND_CURVPE) | v->minor);
770 770
771 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() & ~(VPECONF0_VPA));
772
773 back_to_back_c0_hazard();
774
771 /* Set up the XTC bit in vpeconf0 to point at our tc */ 775 /* Set up the XTC bit in vpeconf0 to point at our tc */
772 write_vpe_c0_vpeconf0( (read_vpe_c0_vpeconf0() & ~(VPECONF0_XTC)) 776 write_vpe_c0_vpeconf0( (read_vpe_c0_vpeconf0() & ~(VPECONF0_XTC))
773 | (t->index << VPECONF0_XTC_SHIFT)); 777 | (t->index << VPECONF0_XTC_SHIFT));
774 778
779 back_to_back_c0_hazard();
780
775 /* enable this VPE */ 781 /* enable this VPE */
776 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA); 782 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_VPA);
777 783
diff --git a/arch/mips/mips-boards/atlas/atlas_int.c b/arch/mips/mips-boards/atlas/atlas_int.c
index fb25e0377f11..a020a3cb4f4b 100644
--- a/arch/mips/mips-boards/atlas/atlas_int.c
+++ b/arch/mips/mips-boards/atlas/atlas_int.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 1999, 2000, 2006 MIPS Technologies, Inc.
3 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. 3 * All rights reserved.
4 * Authors: Carsten Langgaard <carstenl@mips.com>
5 * Maciej W. Rozycki <macro@mips.com>
4 * 6 *
5 * ######################################################################## 7 * ########################################################################
6 * 8 *
@@ -25,17 +27,20 @@
25 */ 27 */
26#include <linux/compiler.h> 28#include <linux/compiler.h>
27#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/irq.h>
28#include <linux/sched.h> 31#include <linux/sched.h>
29#include <linux/slab.h> 32#include <linux/slab.h>
30#include <linux/interrupt.h> 33#include <linux/interrupt.h>
31#include <linux/kernel_stat.h> 34#include <linux/kernel_stat.h>
32 35
33#include <asm/irq.h> 36#include <asm/gdb-stub.h>
34#include <asm/io.h> 37#include <asm/io.h>
38#include <asm/irq_cpu.h>
39#include <asm/msc01_ic.h>
40
35#include <asm/mips-boards/atlas.h> 41#include <asm/mips-boards/atlas.h>
36#include <asm/mips-boards/atlasint.h> 42#include <asm/mips-boards/atlasint.h>
37#include <asm/gdb-stub.h> 43#include <asm/mips-boards/generic.h>
38
39 44
40static struct atlas_ictrl_regs *atlas_hw0_icregs; 45static struct atlas_ictrl_regs *atlas_hw0_icregs;
41 46
@@ -47,13 +52,13 @@ static struct atlas_ictrl_regs *atlas_hw0_icregs;
47 52
48void disable_atlas_irq(unsigned int irq_nr) 53void disable_atlas_irq(unsigned int irq_nr)
49{ 54{
50 atlas_hw0_icregs->intrsten = (1 << (irq_nr-ATLASINT_BASE)); 55 atlas_hw0_icregs->intrsten = 1 << (irq_nr - ATLAS_INT_BASE);
51 iob(); 56 iob();
52} 57}
53 58
54void enable_atlas_irq(unsigned int irq_nr) 59void enable_atlas_irq(unsigned int irq_nr)
55{ 60{
56 atlas_hw0_icregs->intseten = (1 << (irq_nr-ATLASINT_BASE)); 61 atlas_hw0_icregs->intseten = 1 << (irq_nr - ATLAS_INT_BASE);
57 iob(); 62 iob();
58} 63}
59 64
@@ -107,7 +112,7 @@ static inline void atlas_hw0_irqdispatch(struct pt_regs *regs)
107 if (unlikely(int_status == 0)) 112 if (unlikely(int_status == 0))
108 return; 113 return;
109 114
110 irq = ATLASINT_BASE + ls1bit32(int_status); 115 irq = ATLAS_INT_BASE + ls1bit32(int_status);
111 116
112 DEBUG_INT("atlas_hw0_irqdispatch: irq=%d\n", irq); 117 DEBUG_INT("atlas_hw0_irqdispatch: irq=%d\n", irq);
113 118
@@ -161,15 +166,14 @@ static inline unsigned int irq_ffs(unsigned int pending)
161} 166}
162 167
163/* 168/*
164 * IRQs on the Atlas board look basically (barring software IRQs which we 169 * IRQs on the Atlas board look basically like (all external interrupt
165 * don't use at all and all external interrupt sources are combined together 170 * sources are combined together on hardware interrupt 0 (MIPS IRQ 2)):
166 * on hardware interrupt 0 (MIPS IRQ 2)) like:
167 * 171 *
168 * MIPS IRQ Source 172 * MIPS IRQ Source
169 * -------- ------ 173 * -------- ------
170 * 0 Software (ignored) 174 * 0 Software 0 (reschedule IPI on MT)
171 * 1 Software (ignored) 175 * 1 Software 1 (remote call IPI on MT)
172 * 2 Combined hardware interrupt (hw0) 176 * 2 Combined Atlas hardware interrupt (hw0)
173 * 3 Hardware (ignored) 177 * 3 Hardware (ignored)
174 * 4 Hardware (ignored) 178 * 4 Hardware (ignored)
175 * 5 Hardware (ignored) 179 * 5 Hardware (ignored)
@@ -179,7 +183,7 @@ static inline unsigned int irq_ffs(unsigned int pending)
179 * We handle the IRQ according to _our_ priority which is: 183 * We handle the IRQ according to _our_ priority which is:
180 * 184 *
181 * Highest ---- R4k Timer 185 * Highest ---- R4k Timer
182 * Lowest ---- Combined hardware interrupt 186 * Lowest ---- Software 0
183 * 187 *
184 * then we just return, if multiple IRQs are pending then we will just take 188 * then we just return, if multiple IRQs are pending then we will just take
185 * another exception, big deal. 189 * another exception, big deal.
@@ -193,17 +197,19 @@ asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
193 197
194 if (irq == MIPSCPU_INT_ATLAS) 198 if (irq == MIPSCPU_INT_ATLAS)
195 atlas_hw0_irqdispatch(regs); 199 atlas_hw0_irqdispatch(regs);
196 else if (irq > 0) 200 else if (irq >= 0)
197 do_IRQ(MIPSCPU_INT_BASE + irq, regs); 201 do_IRQ(MIPSCPU_INT_BASE + irq, regs);
198 else 202 else
199 spurious_interrupt(regs); 203 spurious_interrupt(regs);
200} 204}
201 205
202void __init arch_init_irq(void) 206static inline void init_atlas_irqs (int base)
203{ 207{
204 int i; 208 int i;
205 209
206 atlas_hw0_icregs = (struct atlas_ictrl_regs *)ioremap (ATLAS_ICTRL_REGS_BASE, sizeof(struct atlas_ictrl_regs *)); 210 atlas_hw0_icregs = (struct atlas_ictrl_regs *)
211 ioremap(ATLAS_ICTRL_REGS_BASE,
212 sizeof(struct atlas_ictrl_regs *));
207 213
208 /* 214 /*
209 * Mask out all interrupt by writing "1" to all bit position in 215 * Mask out all interrupt by writing "1" to all bit position in
@@ -211,7 +217,7 @@ void __init arch_init_irq(void)
211 */ 217 */
212 atlas_hw0_icregs->intrsten = 0xffffffff; 218 atlas_hw0_icregs->intrsten = 0xffffffff;
213 219
214 for (i = ATLASINT_BASE; i <= ATLASINT_END; i++) { 220 for (i = ATLAS_INT_BASE; i <= ATLAS_INT_END; i++) {
215 irq_desc[i].status = IRQ_DISABLED; 221 irq_desc[i].status = IRQ_DISABLED;
216 irq_desc[i].action = 0; 222 irq_desc[i].action = 0;
217 irq_desc[i].depth = 1; 223 irq_desc[i].depth = 1;
@@ -219,3 +225,62 @@ void __init arch_init_irq(void)
219 spin_lock_init(&irq_desc[i].lock); 225 spin_lock_init(&irq_desc[i].lock);
220 } 226 }
221} 227}
228
229static struct irqaction atlasirq = {
230 .handler = no_action,
231 .name = "Atlas cascade"
232};
233
234msc_irqmap_t __initdata msc_irqmap[] = {
235 {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0},
236 {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0},
237};
238int __initdata msc_nr_irqs = sizeof(msc_irqmap) / sizeof(*msc_irqmap);
239
240msc_irqmap_t __initdata msc_eicirqmap[] = {
241 {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0},
242 {MSC01E_INT_SW1, MSC01_IRQ_LEVEL, 0},
243 {MSC01E_INT_ATLAS, MSC01_IRQ_LEVEL, 0},
244 {MSC01E_INT_TMR, MSC01_IRQ_EDGE, 0},
245 {MSC01E_INT_PCI, MSC01_IRQ_LEVEL, 0},
246 {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0},
247 {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0}
248};
249int __initdata msc_nr_eicirqs = sizeof(msc_eicirqmap) / sizeof(*msc_eicirqmap);
250
251void __init arch_init_irq(void)
252{
253 init_atlas_irqs(ATLAS_INT_BASE);
254
255 if (!cpu_has_veic)
256 mips_cpu_irq_init(MIPSCPU_INT_BASE);
257
258 switch(mips_revision_corid) {
259 case MIPS_REVISION_CORID_CORE_MSC:
260 case MIPS_REVISION_CORID_CORE_FPGA2:
261 case MIPS_REVISION_CORID_CORE_FPGA3:
262 case MIPS_REVISION_CORID_CORE_24K:
263 case MIPS_REVISION_CORID_CORE_EMUL_MSC:
264 if (cpu_has_veic)
265 init_msc_irqs (MSC01E_INT_BASE,
266 msc_eicirqmap, msc_nr_eicirqs);
267 else
268 init_msc_irqs (MSC01C_INT_BASE,
269 msc_irqmap, msc_nr_irqs);
270 }
271
272
273 if (cpu_has_veic) {
274 set_vi_handler (MSC01E_INT_ATLAS, atlas_hw0_irqdispatch);
275 setup_irq (MSC01E_INT_BASE + MSC01E_INT_ATLAS, &atlasirq);
276 } else if (cpu_has_vint) {
277 set_vi_handler (MIPSCPU_INT_ATLAS, atlas_hw0_irqdispatch);
278#ifdef CONFIG_MIPS_MT_SMTC
279 setup_irq_smtc (MIPSCPU_INT_BASE + MIPSCPU_INT_ATLAS,
280 &atlasirq, (0x100 << MIPSCPU_INT_ATLAS));
281#else /* Not SMTC */
282 setup_irq(MIPSCPU_INT_BASE + MIPSCPU_INT_ATLAS, &atlasirq);
283#endif /* CONFIG_MIPS_MT_SMTC */
284 } else
285 setup_irq(MIPSCPU_INT_BASE + MIPSCPU_INT_ATLAS, &atlasirq);
286}
diff --git a/arch/mips/mips-boards/atlas/atlas_setup.c b/arch/mips/mips-boards/atlas/atlas_setup.c
index 9871a91fdb07..0c6b0ce15028 100644
--- a/arch/mips/mips-boards/atlas/atlas_setup.c
+++ b/arch/mips/mips-boards/atlas/atlas_setup.c
@@ -77,7 +77,7 @@ static void __init serial_init(void)
77#else 77#else
78 s.iobase = ATLAS_UART_REGS_BASE+3; 78 s.iobase = ATLAS_UART_REGS_BASE+3;
79#endif 79#endif
80 s.irq = ATLASINT_UART; 80 s.irq = ATLAS_INT_UART;
81 s.uartclk = ATLAS_BASE_BAUD * 16; 81 s.uartclk = ATLAS_BASE_BAUD * 16;
82 s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ; 82 s.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ;
83 s.iotype = UPIO_PORT; 83 s.iotype = UPIO_PORT;
diff --git a/arch/mips/mips-boards/generic/time.c b/arch/mips/mips-boards/generic/time.c
index 557bf961f36a..8d15861fce61 100644
--- a/arch/mips/mips-boards/generic/time.c
+++ b/arch/mips/mips-boards/generic/time.c
@@ -41,8 +41,13 @@
41 41
42#include <asm/mips-boards/generic.h> 42#include <asm/mips-boards/generic.h>
43#include <asm/mips-boards/prom.h> 43#include <asm/mips-boards/prom.h>
44
45#ifdef CONFIG_MIPS_ATLAS
46#include <asm/mips-boards/atlasint.h>
47#endif
48#ifdef CONFIG_MIPS_MALTA
44#include <asm/mips-boards/maltaint.h> 49#include <asm/mips-boards/maltaint.h>
45#include <asm/mc146818-time.h> 50#endif
46 51
47unsigned long cpu_khz; 52unsigned long cpu_khz;
48 53
@@ -92,10 +97,9 @@ extern int (*perf_irq)(struct pt_regs *regs);
92irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 97irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
93{ 98{
94 int cpu = smp_processor_id(); 99 int cpu = smp_processor_id();
95 int r2 = cpu_has_mips_r2;
96 100
97#ifdef CONFIG_MIPS_MT_SMTC 101#ifdef CONFIG_MIPS_MT_SMTC
98 /* 102 /*
99 * In an SMTC system, one Count/Compare set exists per VPE. 103 * In an SMTC system, one Count/Compare set exists per VPE.
100 * Which TC within a VPE gets the interrupt is essentially 104 * Which TC within a VPE gets the interrupt is essentially
101 * random - we only know that it shouldn't be one with 105 * random - we only know that it shouldn't be one with
@@ -108,29 +112,46 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
108 * the general MIPS timer_interrupt routine. 112 * the general MIPS timer_interrupt routine.
109 */ 113 */
110 114
115 int vpflags;
116
111 /* 117 /*
112 * DVPE is necessary so long as cross-VPE interrupts 118 * We could be here due to timer interrupt,
113 * are done via read-modify-write of Cause register. 119 * perf counter overflow, or both.
114 */ 120 */
115 int vpflags = dvpe(); 121 if (read_c0_cause() & (1 << 26))
116 write_c0_compare (read_c0_count() - 1); 122 perf_irq(regs);
117 clear_c0_cause(CPUCTR_IMASKBIT);
118 evpe(vpflags);
119 123
120 if (cpu_data[cpu].vpe_id == 0) { 124 if (read_c0_cause() & (1 << 30)) {
121 timer_interrupt(irq, dev_id, regs); 125 /* If timer interrupt, make it de-assert */
122 scroll_display_message(); 126 write_c0_compare (read_c0_count() - 1);
123 } else
124 write_c0_compare (read_c0_count() + ( mips_hpt_frequency/HZ));
125 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
126
127 if (cpu != 0)
128 /* 127 /*
129 * Other CPUs should do profiling and process accounting 128 * DVPE is necessary so long as cross-VPE interrupts
129 * are done via read-modify-write of Cause register.
130 */ 130 */
131 local_timer_interrupt(irq, dev_id, regs); 131 vpflags = dvpe();
132 132 clear_c0_cause(CPUCTR_IMASKBIT);
133 evpe(vpflags);
134 /*
135 * There are things we only want to do once per tick
136 * in an "MP" system. One TC of each VPE will take
137 * the actual timer interrupt. The others will get
138 * timer broadcast IPIs. We use whoever it is that takes
139 * the tick on VPE 0 to run the full timer_interrupt().
140 */
141 if (cpu_data[cpu].vpe_id == 0) {
142 timer_interrupt(irq, NULL, regs);
143 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
144 scroll_display_message();
145 } else {
146 write_c0_compare(read_c0_count() +
147 (mips_hpt_frequency/HZ));
148 local_timer_interrupt(irq, dev_id, regs);
149 smtc_timer_broadcast(cpu_data[cpu].vpe_id);
150 }
151 }
133#else /* CONFIG_MIPS_MT_SMTC */ 152#else /* CONFIG_MIPS_MT_SMTC */
153 int r2 = cpu_has_mips_r2;
154
134 if (cpu == 0) { 155 if (cpu == 0) {
135 /* 156 /*
136 * CPU 0 handles the global timer interrupt job and process 157 * CPU 0 handles the global timer interrupt job and process
@@ -161,9 +182,8 @@ irqreturn_t mips_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
161 */ 182 */
162 local_timer_interrupt(irq, dev_id, regs); 183 local_timer_interrupt(irq, dev_id, regs);
163 } 184 }
164#endif /* CONFIG_MIPS_MT_SMTC */
165
166out: 185out:
186#endif /* CONFIG_MIPS_MT_SMTC */
167 return IRQ_HANDLED; 187 return IRQ_HANDLED;
168} 188}
169 189
diff --git a/arch/mips/mm/c-r3k.c b/arch/mips/mm/c-r3k.c
index bb041a22f20a..e1f35ef81145 100644
--- a/arch/mips/mm/c-r3k.c
+++ b/arch/mips/mm/c-r3k.c
@@ -335,7 +335,7 @@ void __init r3k_cache_init(void)
335 flush_cache_mm = r3k_flush_cache_mm; 335 flush_cache_mm = r3k_flush_cache_mm;
336 flush_cache_range = r3k_flush_cache_range; 336 flush_cache_range = r3k_flush_cache_range;
337 flush_cache_page = r3k_flush_cache_page; 337 flush_cache_page = r3k_flush_cache_page;
338 flush_icache_page = r3k_flush_icache_page; 338 __flush_icache_page = r3k_flush_icache_page;
339 flush_icache_range = r3k_flush_icache_range; 339 flush_icache_range = r3k_flush_icache_range;
340 340
341 flush_cache_sigtramp = r3k_flush_cache_sigtramp; 341 flush_cache_sigtramp = r3k_flush_cache_sigtramp;
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 069803f58f3b..0b2da53750bd 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -89,7 +89,7 @@ static inline void r4k_blast_dcache_page_dc32(unsigned long addr)
89 blast_dcache32_page(addr); 89 blast_dcache32_page(addr);
90} 90}
91 91
92static inline void r4k_blast_dcache_page_setup(void) 92static void __init r4k_blast_dcache_page_setup(void)
93{ 93{
94 unsigned long dc_lsize = cpu_dcache_line_size(); 94 unsigned long dc_lsize = cpu_dcache_line_size();
95 95
@@ -103,7 +103,7 @@ static inline void r4k_blast_dcache_page_setup(void)
103 103
104static void (* r4k_blast_dcache_page_indexed)(unsigned long addr); 104static void (* r4k_blast_dcache_page_indexed)(unsigned long addr);
105 105
106static inline void r4k_blast_dcache_page_indexed_setup(void) 106static void __init r4k_blast_dcache_page_indexed_setup(void)
107{ 107{
108 unsigned long dc_lsize = cpu_dcache_line_size(); 108 unsigned long dc_lsize = cpu_dcache_line_size();
109 109
@@ -117,7 +117,7 @@ static inline void r4k_blast_dcache_page_indexed_setup(void)
117 117
118static void (* r4k_blast_dcache)(void); 118static void (* r4k_blast_dcache)(void);
119 119
120static inline void r4k_blast_dcache_setup(void) 120static void __init r4k_blast_dcache_setup(void)
121{ 121{
122 unsigned long dc_lsize = cpu_dcache_line_size(); 122 unsigned long dc_lsize = cpu_dcache_line_size();
123 123
@@ -202,7 +202,7 @@ static inline void tx49_blast_icache32_page_indexed(unsigned long page)
202 202
203static void (* r4k_blast_icache_page)(unsigned long addr); 203static void (* r4k_blast_icache_page)(unsigned long addr);
204 204
205static inline void r4k_blast_icache_page_setup(void) 205static void __init r4k_blast_icache_page_setup(void)
206{ 206{
207 unsigned long ic_lsize = cpu_icache_line_size(); 207 unsigned long ic_lsize = cpu_icache_line_size();
208 208
@@ -219,7 +219,7 @@ static inline void r4k_blast_icache_page_setup(void)
219 219
220static void (* r4k_blast_icache_page_indexed)(unsigned long addr); 220static void (* r4k_blast_icache_page_indexed)(unsigned long addr);
221 221
222static inline void r4k_blast_icache_page_indexed_setup(void) 222static void __init r4k_blast_icache_page_indexed_setup(void)
223{ 223{
224 unsigned long ic_lsize = cpu_icache_line_size(); 224 unsigned long ic_lsize = cpu_icache_line_size();
225 225
@@ -243,7 +243,7 @@ static inline void r4k_blast_icache_page_indexed_setup(void)
243 243
244static void (* r4k_blast_icache)(void); 244static void (* r4k_blast_icache)(void);
245 245
246static inline void r4k_blast_icache_setup(void) 246static void __init r4k_blast_icache_setup(void)
247{ 247{
248 unsigned long ic_lsize = cpu_icache_line_size(); 248 unsigned long ic_lsize = cpu_icache_line_size();
249 249
@@ -264,7 +264,7 @@ static inline void r4k_blast_icache_setup(void)
264 264
265static void (* r4k_blast_scache_page)(unsigned long addr); 265static void (* r4k_blast_scache_page)(unsigned long addr);
266 266
267static inline void r4k_blast_scache_page_setup(void) 267static void __init r4k_blast_scache_page_setup(void)
268{ 268{
269 unsigned long sc_lsize = cpu_scache_line_size(); 269 unsigned long sc_lsize = cpu_scache_line_size();
270 270
@@ -282,7 +282,7 @@ static inline void r4k_blast_scache_page_setup(void)
282 282
283static void (* r4k_blast_scache_page_indexed)(unsigned long addr); 283static void (* r4k_blast_scache_page_indexed)(unsigned long addr);
284 284
285static inline void r4k_blast_scache_page_indexed_setup(void) 285static void __init r4k_blast_scache_page_indexed_setup(void)
286{ 286{
287 unsigned long sc_lsize = cpu_scache_line_size(); 287 unsigned long sc_lsize = cpu_scache_line_size();
288 288
@@ -300,7 +300,7 @@ static inline void r4k_blast_scache_page_indexed_setup(void)
300 300
301static void (* r4k_blast_scache)(void); 301static void (* r4k_blast_scache)(void);
302 302
303static inline void r4k_blast_scache_setup(void) 303static void __init r4k_blast_scache_setup(void)
304{ 304{
305 unsigned long sc_lsize = cpu_scache_line_size(); 305 unsigned long sc_lsize = cpu_scache_line_size();
306 306
@@ -475,7 +475,7 @@ static inline void local_r4k_flush_cache_page(void *args)
475 } 475 }
476 } 476 }
477 if (exec) { 477 if (exec) {
478 if (cpu_has_vtag_icache) { 478 if (cpu_has_vtag_icache && mm == current->active_mm) {
479 int cpu = smp_processor_id(); 479 int cpu = smp_processor_id();
480 480
481 if (cpu_context(cpu, mm) != 0) 481 if (cpu_context(cpu, mm) != 0)
@@ -599,7 +599,7 @@ static inline void local_r4k_flush_icache_page(void *args)
599 * We're not sure of the virtual address(es) involved here, so 599 * We're not sure of the virtual address(es) involved here, so
600 * we have to flush the entire I-cache. 600 * we have to flush the entire I-cache.
601 */ 601 */
602 if (cpu_has_vtag_icache) { 602 if (cpu_has_vtag_icache && vma->vm_mm == current->active_mm) {
603 int cpu = smp_processor_id(); 603 int cpu = smp_processor_id();
604 604
605 if (cpu_context(cpu, vma->vm_mm) != 0) 605 if (cpu_context(cpu, vma->vm_mm) != 0)
@@ -1221,7 +1221,7 @@ void au1x00_fixup_config_od(void)
1221 } 1221 }
1222} 1222}
1223 1223
1224static inline void coherency_setup(void) 1224static void __init coherency_setup(void)
1225{ 1225{
1226 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT); 1226 change_c0_config(CONF_CM_CMASK, CONF_CM_DEFAULT);
1227 1227
@@ -1242,7 +1242,7 @@ static inline void coherency_setup(void)
1242 clear_c0_config(CONF_CU); 1242 clear_c0_config(CONF_CU);
1243 break; 1243 break;
1244 /* 1244 /*
1245 * We need to catch the ealry Alchemy SOCs with 1245 * We need to catch the early Alchemy SOCs with
1246 * the write-only co_config.od bit and set it back to one... 1246 * the write-only co_config.od bit and set it back to one...
1247 */ 1247 */
1248 case CPU_AU1000: /* rev. DA, HA, HB */ 1248 case CPU_AU1000: /* rev. DA, HA, HB */
@@ -1291,7 +1291,7 @@ void __init r4k_cache_init(void)
1291 __flush_cache_all = r4k___flush_cache_all; 1291 __flush_cache_all = r4k___flush_cache_all;
1292 flush_cache_mm = r4k_flush_cache_mm; 1292 flush_cache_mm = r4k_flush_cache_mm;
1293 flush_cache_page = r4k_flush_cache_page; 1293 flush_cache_page = r4k_flush_cache_page;
1294 flush_icache_page = r4k_flush_icache_page; 1294 __flush_icache_page = r4k_flush_icache_page;
1295 flush_cache_range = r4k_flush_cache_range; 1295 flush_cache_range = r4k_flush_cache_range;
1296 1296
1297 flush_cache_sigtramp = r4k_flush_cache_sigtramp; 1297 flush_cache_sigtramp = r4k_flush_cache_sigtramp;
diff --git a/arch/mips/mm/c-sb1.c b/arch/mips/mm/c-sb1.c
index 2d71efb82ac5..16bad7c0a63f 100644
--- a/arch/mips/mm/c-sb1.c
+++ b/arch/mips/mm/c-sb1.c
@@ -155,6 +155,26 @@ static inline void __sb1_flush_icache_all(void)
155} 155}
156 156
157/* 157/*
158 * Invalidate a range of the icache. The addresses are virtual, and
159 * the cache is virtually indexed and tagged. However, we don't
160 * necessarily have the right ASID context, so use index ops instead
161 * of hit ops.
162 */
163static inline void __sb1_flush_icache_range(unsigned long start,
164 unsigned long end)
165{
166 start &= ~(icache_line_size - 1);
167 end = (end + icache_line_size - 1) & ~(icache_line_size - 1);
168
169 while (start != end) {
170 cache_set_op(Index_Invalidate_I, start & icache_index_mask);
171 start += icache_line_size;
172 }
173 mispredict();
174 sync();
175}
176
177/*
158 * Flush the icache for a given physical page. Need to writeback the 178 * Flush the icache for a given physical page. Need to writeback the
159 * dcache first, then invalidate the icache. If the page isn't 179 * dcache first, then invalidate the icache. If the page isn't
160 * executable, nothing is required. 180 * executable, nothing is required.
@@ -173,8 +193,11 @@ static void local_sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long
173 /* 193 /*
174 * Bumping the ASID is probably cheaper than the flush ... 194 * Bumping the ASID is probably cheaper than the flush ...
175 */ 195 */
176 if (cpu_context(cpu, vma->vm_mm) != 0) 196 if (vma->vm_mm == current->active_mm) {
177 drop_mmu_context(vma->vm_mm, cpu); 197 if (cpu_context(cpu, vma->vm_mm) != 0)
198 drop_mmu_context(vma->vm_mm, cpu);
199 } else
200 __sb1_flush_icache_range(addr, addr + PAGE_SIZE);
178} 201}
179 202
180#ifdef CONFIG_SMP 203#ifdef CONFIG_SMP
@@ -210,26 +233,6 @@ void sb1_flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsign
210 __attribute__((alias("local_sb1_flush_cache_page"))); 233 __attribute__((alias("local_sb1_flush_cache_page")));
211#endif 234#endif
212 235
213/*
214 * Invalidate a range of the icache. The addresses are virtual, and
215 * the cache is virtually indexed and tagged. However, we don't
216 * necessarily have the right ASID context, so use index ops instead
217 * of hit ops.
218 */
219static inline void __sb1_flush_icache_range(unsigned long start,
220 unsigned long end)
221{
222 start &= ~(icache_line_size - 1);
223 end = (end + icache_line_size - 1) & ~(icache_line_size - 1);
224
225 while (start != end) {
226 cache_set_op(Index_Invalidate_I, start & icache_index_mask);
227 start += icache_line_size;
228 }
229 mispredict();
230 sync();
231}
232
233 236
234/* 237/*
235 * Invalidate all caches on this CPU 238 * Invalidate all caches on this CPU
@@ -326,9 +329,12 @@ static void local_sb1_flush_icache_page(struct vm_area_struct *vma,
326 * If there's a context, bump the ASID (cheaper than a flush, 329 * If there's a context, bump the ASID (cheaper than a flush,
327 * since we don't know VAs!) 330 * since we don't know VAs!)
328 */ 331 */
329 if (cpu_context(cpu, vma->vm_mm) != 0) { 332 if (vma->vm_mm == current->active_mm) {
330 drop_mmu_context(vma->vm_mm, cpu); 333 if (cpu_context(cpu, vma->vm_mm) != 0)
331 } 334 drop_mmu_context(vma->vm_mm, cpu);
335 } else
336 __sb1_flush_icache_range(start, start + PAGE_SIZE);
337
332} 338}
333 339
334#ifdef CONFIG_SMP 340#ifdef CONFIG_SMP
@@ -520,7 +526,7 @@ void sb1_cache_init(void)
520 526
521 /* These routines are for Icache coherence with the Dcache */ 527 /* These routines are for Icache coherence with the Dcache */
522 flush_icache_range = sb1_flush_icache_range; 528 flush_icache_range = sb1_flush_icache_range;
523 flush_icache_page = sb1_flush_icache_page; 529 __flush_icache_page = sb1_flush_icache_page;
524 flush_icache_all = __sb1_flush_icache_all; /* local only */ 530 flush_icache_all = __sb1_flush_icache_all; /* local only */
525 531
526 /* This implies an Icache flush too, so can't be nop'ed */ 532 /* This implies an Icache flush too, so can't be nop'ed */
diff --git a/arch/mips/mm/c-tx39.c b/arch/mips/mm/c-tx39.c
index 5dfc9b1901f6..932a09d7ef84 100644
--- a/arch/mips/mm/c-tx39.c
+++ b/arch/mips/mm/c-tx39.c
@@ -382,7 +382,7 @@ void __init tx39_cache_init(void)
382 flush_cache_mm = (void *) tx39h_flush_icache_all; 382 flush_cache_mm = (void *) tx39h_flush_icache_all;
383 flush_cache_range = (void *) tx39h_flush_icache_all; 383 flush_cache_range = (void *) tx39h_flush_icache_all;
384 flush_cache_page = (void *) tx39h_flush_icache_all; 384 flush_cache_page = (void *) tx39h_flush_icache_all;
385 flush_icache_page = (void *) tx39h_flush_icache_all; 385 __flush_icache_page = (void *) tx39h_flush_icache_all;
386 flush_icache_range = (void *) tx39h_flush_icache_all; 386 flush_icache_range = (void *) tx39h_flush_icache_all;
387 387
388 flush_cache_sigtramp = (void *) tx39h_flush_icache_all; 388 flush_cache_sigtramp = (void *) tx39h_flush_icache_all;
@@ -408,7 +408,7 @@ void __init tx39_cache_init(void)
408 flush_cache_mm = tx39_flush_cache_mm; 408 flush_cache_mm = tx39_flush_cache_mm;
409 flush_cache_range = tx39_flush_cache_range; 409 flush_cache_range = tx39_flush_cache_range;
410 flush_cache_page = tx39_flush_cache_page; 410 flush_cache_page = tx39_flush_cache_page;
411 flush_icache_page = tx39_flush_icache_page; 411 __flush_icache_page = tx39_flush_icache_page;
412 flush_icache_range = tx39_flush_icache_range; 412 flush_icache_range = tx39_flush_icache_range;
413 413
414 flush_cache_sigtramp = tx39_flush_cache_sigtramp; 414 flush_cache_sigtramp = tx39_flush_cache_sigtramp;
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index ddd3a2de1d73..40c8b0235183 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -25,7 +25,7 @@ void (*flush_cache_range)(struct vm_area_struct *vma, unsigned long start,
25void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, 25void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page,
26 unsigned long pfn); 26 unsigned long pfn);
27void (*flush_icache_range)(unsigned long start, unsigned long end); 27void (*flush_icache_range)(unsigned long start, unsigned long end);
28void (*flush_icache_page)(struct vm_area_struct *vma, struct page *page); 28void (*__flush_icache_page)(struct vm_area_struct *vma, struct page *page);
29 29
30/* MIPS specific cache operations */ 30/* MIPS specific cache operations */
31void (*flush_cache_sigtramp)(unsigned long addr); 31void (*flush_cache_sigtramp)(unsigned long addr);
@@ -70,6 +70,8 @@ void __flush_dcache_page(struct page *page)
70 struct address_space *mapping = page_mapping(page); 70 struct address_space *mapping = page_mapping(page);
71 unsigned long addr; 71 unsigned long addr;
72 72
73 if (PageHighMem(page))
74 return;
73 if (mapping && !mapping_mapped(mapping)) { 75 if (mapping && !mapping_mapped(mapping)) {
74 SetPageDcacheDirty(page); 76 SetPageDcacheDirty(page);
75 return; 77 return;
@@ -91,16 +93,16 @@ void __update_cache(struct vm_area_struct *vma, unsigned long address,
91{ 93{
92 struct page *page; 94 struct page *page;
93 unsigned long pfn, addr; 95 unsigned long pfn, addr;
96 int exec = (vma->vm_flags & VM_EXEC) && !cpu_has_ic_fills_f_dc;
94 97
95 pfn = pte_pfn(pte); 98 pfn = pte_pfn(pte);
96 if (pfn_valid(pfn) && (page = pfn_to_page(pfn), page_mapping(page)) && 99 if (unlikely(!pfn_valid(pfn)))
97 Page_dcache_dirty(page)) { 100 return;
98 if (pages_do_alias((unsigned long)page_address(page), 101 page = pfn_to_page(pfn);
99 address & PAGE_MASK)) { 102 if (page_mapping(page) && Page_dcache_dirty(page)) {
100 addr = (unsigned long) page_address(page); 103 addr = (unsigned long) page_address(page);
104 if (exec || pages_do_alias(addr, address & PAGE_MASK))
101 flush_data_cache_page(addr); 105 flush_data_cache_page(addr);
102 }
103
104 ClearPageDcacheDirty(page); 106 ClearPageDcacheDirty(page);
105 } 107 }
106} 108}
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index e3a617224868..a4f8c45c4e8e 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -89,7 +89,7 @@ good_area:
89 if (!(vma->vm_flags & VM_WRITE)) 89 if (!(vma->vm_flags & VM_WRITE))
90 goto bad_area; 90 goto bad_area;
91 } else { 91 } else {
92 if (!(vma->vm_flags & (VM_READ | VM_EXEC))) 92 if (!(vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)))
93 goto bad_area; 93 goto bad_area;
94 } 94 }
95 95
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 2cde1b772443..2e0e21ef433e 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -26,11 +26,6 @@ extern void build_tlb_refill_handler(void);
26 */ 26 */
27#define UNIQUE_ENTRYHI(idx) (CKSEG0 + ((idx) << (PAGE_SHIFT + 1))) 27#define UNIQUE_ENTRYHI(idx) (CKSEG0 + ((idx) << (PAGE_SHIFT + 1)))
28 28
29/* CP0 hazard avoidance. */
30#define BARRIER __asm__ __volatile__(".set noreorder\n\t" \
31 "nop; nop; nop; nop; nop; nop;\n\t" \
32 ".set reorder\n\t")
33
34/* Atomicity and interruptability */ 29/* Atomicity and interruptability */
35#ifdef CONFIG_MIPS_MT_SMTC 30#ifdef CONFIG_MIPS_MT_SMTC
36 31
@@ -126,7 +121,7 @@ void local_flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
126 start += (PAGE_SIZE << 1); 121 start += (PAGE_SIZE << 1);
127 mtc0_tlbw_hazard(); 122 mtc0_tlbw_hazard();
128 tlb_probe(); 123 tlb_probe();
129 BARRIER; 124 tlb_probe_hazard();
130 idx = read_c0_index(); 125 idx = read_c0_index();
131 write_c0_entrylo0(0); 126 write_c0_entrylo0(0);
132 write_c0_entrylo1(0); 127 write_c0_entrylo1(0);
@@ -168,7 +163,7 @@ void local_flush_tlb_kernel_range(unsigned long start, unsigned long end)
168 start += (PAGE_SIZE << 1); 163 start += (PAGE_SIZE << 1);
169 mtc0_tlbw_hazard(); 164 mtc0_tlbw_hazard();
170 tlb_probe(); 165 tlb_probe();
171 BARRIER; 166 tlb_probe_hazard();
172 idx = read_c0_index(); 167 idx = read_c0_index();
173 write_c0_entrylo0(0); 168 write_c0_entrylo0(0);
174 write_c0_entrylo1(0); 169 write_c0_entrylo1(0);
@@ -202,7 +197,7 @@ void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
202 write_c0_entryhi(page | newpid); 197 write_c0_entryhi(page | newpid);
203 mtc0_tlbw_hazard(); 198 mtc0_tlbw_hazard();
204 tlb_probe(); 199 tlb_probe();
205 BARRIER; 200 tlb_probe_hazard();
206 idx = read_c0_index(); 201 idx = read_c0_index();
207 write_c0_entrylo0(0); 202 write_c0_entrylo0(0);
208 write_c0_entrylo1(0); 203 write_c0_entrylo1(0);
@@ -235,7 +230,7 @@ void local_flush_tlb_one(unsigned long page)
235 write_c0_entryhi(page); 230 write_c0_entryhi(page);
236 mtc0_tlbw_hazard(); 231 mtc0_tlbw_hazard();
237 tlb_probe(); 232 tlb_probe();
238 BARRIER; 233 tlb_probe_hazard();
239 idx = read_c0_index(); 234 idx = read_c0_index();
240 write_c0_entrylo0(0); 235 write_c0_entrylo0(0);
241 write_c0_entrylo1(0); 236 write_c0_entrylo1(0);
@@ -279,7 +274,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
279 pgdp = pgd_offset(vma->vm_mm, address); 274 pgdp = pgd_offset(vma->vm_mm, address);
280 mtc0_tlbw_hazard(); 275 mtc0_tlbw_hazard();
281 tlb_probe(); 276 tlb_probe();
282 BARRIER; 277 tlb_probe_hazard();
283 pudp = pud_offset(pgdp, address); 278 pudp = pud_offset(pgdp, address);
284 pmdp = pmd_offset(pudp, address); 279 pmdp = pmd_offset(pudp, address);
285 idx = read_c0_index(); 280 idx = read_c0_index();
@@ -320,7 +315,7 @@ static void r4k_update_mmu_cache_hwbug(struct vm_area_struct * vma,
320 pgdp = pgd_offset(vma->vm_mm, address); 315 pgdp = pgd_offset(vma->vm_mm, address);
321 mtc0_tlbw_hazard(); 316 mtc0_tlbw_hazard();
322 tlb_probe(); 317 tlb_probe();
323 BARRIER; 318 tlb_probe_hazard();
324 pmdp = pmd_offset(pgdp, address); 319 pmdp = pmd_offset(pgdp, address);
325 idx = read_c0_index(); 320 idx = read_c0_index();
326 ptep = pte_offset_map(pmdp, address); 321 ptep = pte_offset_map(pmdp, address);
@@ -351,7 +346,7 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
351 wired = read_c0_wired(); 346 wired = read_c0_wired();
352 write_c0_wired(wired + 1); 347 write_c0_wired(wired + 1);
353 write_c0_index(wired); 348 write_c0_index(wired);
354 BARRIER; 349 tlbw_use_hazard(); /* What is the hazard here? */
355 write_c0_pagemask(pagemask); 350 write_c0_pagemask(pagemask);
356 write_c0_entryhi(entryhi); 351 write_c0_entryhi(entryhi);
357 write_c0_entrylo0(entrylo0); 352 write_c0_entrylo0(entrylo0);
@@ -361,7 +356,7 @@ void __init add_wired_entry(unsigned long entrylo0, unsigned long entrylo1,
361 tlbw_use_hazard(); 356 tlbw_use_hazard();
362 357
363 write_c0_entryhi(old_ctx); 358 write_c0_entryhi(old_ctx);
364 BARRIER; 359 tlbw_use_hazard(); /* What is the hazard here? */
365 write_c0_pagemask(old_pagemask); 360 write_c0_pagemask(old_pagemask);
366 local_flush_tlb_all(); 361 local_flush_tlb_all();
367 EXIT_CRITICAL(flags); 362 EXIT_CRITICAL(flags);
diff --git a/arch/mips/pci/Makefile b/arch/mips/pci/Makefile
index 35d5927706ea..edefa97b2330 100644
--- a/arch/mips/pci/Makefile
+++ b/arch/mips/pci/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_ITE_BOARD_GEN) += ops-it8172.o
11obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o 11obj-$(CONFIG_MIPS_BONITO64) += ops-bonito64.o
12obj-$(CONFIG_MIPS_GT64111) += ops-gt64111.o 12obj-$(CONFIG_MIPS_GT64111) += ops-gt64111.o
13obj-$(CONFIG_MIPS_GT64120) += ops-gt64120.o 13obj-$(CONFIG_MIPS_GT64120) += ops-gt64120.o
14obj-$(CONFIG_MIPS_GT96100) += ops-gt96100.o
15obj-$(CONFIG_PCI_MARVELL) += ops-marvell.o 14obj-$(CONFIG_PCI_MARVELL) += ops-marvell.o
16obj-$(CONFIG_MIPS_MSC) += ops-msc.o 15obj-$(CONFIG_MIPS_MSC) += ops-msc.o
17obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o 16obj-$(CONFIG_MIPS_NILE4) += ops-nile4.o
@@ -28,8 +27,7 @@ obj-$(CONFIG_DDB5477) += fixup-ddb5477.o pci-ddb5477.o ops-ddb5477.o
28obj-$(CONFIG_LASAT) += pci-lasat.o 27obj-$(CONFIG_LASAT) += pci-lasat.o
29obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o 28obj-$(CONFIG_MIPS_ATLAS) += fixup-atlas.o
30obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o 29obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o
31obj-$(CONFIG_MIPS_EV96100) += fixup-ev64120.o 30obj-$(CONFIG_MIPS_EV64120) += fixup-ev64120.o
32obj-$(CONFIG_MIPS_EV96100) += fixup-ev96100.o pci-ev96100.o
33obj-$(CONFIG_MIPS_ITE8172) += fixup-ite8172g.o 31obj-$(CONFIG_MIPS_ITE8172) += fixup-ite8172g.o
34obj-$(CONFIG_MIPS_IVR) += fixup-ivr.o 32obj-$(CONFIG_MIPS_IVR) += fixup-ivr.o
35obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o 33obj-$(CONFIG_SOC_AU1500) += fixup-au1000.o ops-au1000.o
diff --git a/arch/mips/pci/fixup-atlas.c b/arch/mips/pci/fixup-atlas.c
index 439510af3037..c6cd6e9cdfbc 100644
--- a/arch/mips/pci/fixup-atlas.c
+++ b/arch/mips/pci/fixup-atlas.c
@@ -21,16 +21,16 @@
21 21
22#include <asm/mips-boards/atlasint.h> 22#include <asm/mips-boards/atlasint.h>
23 23
24#define PCIA ATLASINT_PCIA 24#define PCIA ATLAS_INT_PCIA
25#define PCIB ATLASINT_PCIB 25#define PCIB ATLAS_INT_PCIB
26#define PCIC ATLASINT_PCIC 26#define PCIC ATLAS_INT_PCIC
27#define PCID ATLASINT_PCID 27#define PCID ATLAS_INT_PCID
28#define INTA ATLASINT_INTA 28#define INTA ATLAS_INT_INTA
29#define INTB ATLASINT_INTB 29#define INTB ATLAS_INT_INTB
30#define ETH ATLASINT_ETH 30#define ETH ATLAS_INT_ETH
31#define INTC ATLASINT_INTC 31#define INTC ATLAS_INT_INTC
32#define SCSI ATLASINT_SCSI 32#define SCSI ATLAS_INT_SCSI
33#define INTD ATLASINT_INTD 33#define INTD ATLAS_INT_INTD
34 34
35static char irq_tab[][5] __initdata = { 35static char irq_tab[][5] __initdata = {
36 /* INTA INTB INTC INTD */ 36 /* INTA INTB INTC INTD */
diff --git a/arch/mips/pci/fixup-ev96100.c b/arch/mips/pci/fixup-ev96100.c
deleted file mode 100644
index e2bc977b6d58..000000000000
--- a/arch/mips/pci/fixup-ev96100.c
+++ /dev/null
@@ -1,48 +0,0 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * EV96100 Board specific pci fixups.
5 *
6 * Copyright 2001 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * ppopov@mvista.com or source@mvista.com
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
18 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
21 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 675 Mass Ave, Cambridge, MA 02139, USA.
29 */
30#include <linux/init.h>
31#include <linux/types.h>
32#include <linux/pci.h>
33
34static char irq_tab_ev96100[][5] __initdata = {
35 [8] = { 0, 5, 5, 5, 5 },
36 [9] = { 0, 2, 2, 2, 2 }
37};
38
39int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
40{
41 return irq_tab_ev96100[slot][pin];
42}
43
44/* Do platform specific device initialization at pci_enable_device() time */
45int pcibios_plat_dev_init(struct pci_dev *dev)
46{
47 return 0;
48}
diff --git a/arch/mips/pci/ops-au1000.c b/arch/mips/pci/ops-au1000.c
index 0c0c1e6519f9..8ae46481fcb7 100644
--- a/arch/mips/pci/ops-au1000.c
+++ b/arch/mips/pci/ops-au1000.c
@@ -110,7 +110,7 @@ static int config_access(unsigned char access_type, struct pci_bus *bus,
110 if (first_cfg) { 110 if (first_cfg) {
111 /* reserve a wired entry for pci config accesses */ 111 /* reserve a wired entry for pci config accesses */
112 first_cfg = 0; 112 first_cfg = 0;
113 pci_cfg_vm = get_vm_area(0x2000, 0); 113 pci_cfg_vm = get_vm_area(0x2000, VM_IOREMAP);
114 if (!pci_cfg_vm) 114 if (!pci_cfg_vm)
115 panic (KERN_ERR "PCI unable to get vm area\n"); 115 panic (KERN_ERR "PCI unable to get vm area\n");
116 pci_cfg_wired_entry = read_c0_wired(); 116 pci_cfg_wired_entry = read_c0_wired();
diff --git a/arch/mips/pci/ops-gt96100.c b/arch/mips/pci/ops-gt96100.c
deleted file mode 100644
index 9e4ea6627e21..000000000000
--- a/arch/mips/pci/ops-gt96100.c
+++ /dev/null
@@ -1,169 +0,0 @@
1/*
2 *
3 * BRIEF MODULE DESCRIPTION
4 * Galileo EV96100 board specific pci support.
5 *
6 * Copyright 2000 MontaVista Software Inc.
7 * Author: MontaVista Software, Inc.
8 * ppopov@mvista.com or source@mvista.com
9 *
10 * This file was derived from Carsten Langgaard's
11 * arch/mips/mips-boards/generic/pci.c
12 *
13 * Carsten Langgaard, carstenl@mips.com
14 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
15 *
16 * This program is free software; you can redistribute it and/or modify it
17 * under the terms of the GNU General Public License as published by the
18 * Free Software Foundation; either version 2 of the License, or (at your
19 * option) any later version.
20 *
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
24 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * You should have received a copy of the GNU General Public License along
33 * with this program; if not, write to the Free Software Foundation, Inc.,
34 * 675 Mass Ave, Cambridge, MA 02139, USA.
35 */
36#include <linux/types.h>
37#include <linux/pci.h>
38#include <linux/kernel.h>
39#include <linux/init.h>
40
41#include <asm/delay.h>
42#include <asm/gt64120.h>
43#include <asm/galileo-boards/ev96100.h>
44
45#define PCI_ACCESS_READ 0
46#define PCI_ACCESS_WRITE 1
47
48static int static gt96100_config_access(unsigned char access_type,
49 struct pci_bus *bus, unsigned int devfn, int where, u32 * data)
50{
51 unsigned char bus = bus->number;
52 u32 intr;
53
54 /*
55 * Because of a bug in the galileo (for slot 31).
56 */
57 if (bus == 0 && devfn >= PCI_DEVFN(31, 0))
58 return PCIBIOS_DEVICE_NOT_FOUND;
59
60 /* Clear cause register bits */
61 GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT |
62 GT_INTRCAUSE_TARABORT0_BIT));
63
64 /* Setup address */
65 GT_WRITE(GT_PCI0_CFGADDR_OFS,
66 (bus << GT_PCI0_CFGADDR_BUSNUM_SHF) |
67 (devfn << GT_PCI0_CFGADDR_FUNCTNUM_SHF) |
68 ((where / 4) << GT_PCI0_CFGADDR_REGNUM_SHF) |
69 GT_PCI0_CFGADDR_CONFIGEN_BIT);
70 udelay(2);
71
72
73 if (access_type == PCI_ACCESS_WRITE) {
74 if (devfn != 0)
75 *data = le32_to_cpu(*data);
76 GT_WRITE(GT_PCI0_CFGDATA_OFS, *data);
77 } else {
78 *data = GT_READ(GT_PCI0_CFGDATA_OFS);
79 if (devfn != 0)
80 *data = le32_to_cpu(*data);
81 }
82
83 udelay(2);
84
85 /* Check for master or target abort */
86 intr = GT_READ(GT_INTRCAUSE_OFS);
87
88 if (intr & (GT_INTRCAUSE_MASABORT0_BIT | GT_INTRCAUSE_TARABORT0_BIT)) {
89 /* Error occured */
90
91 /* Clear bits */
92 GT_WRITE(GT_INTRCAUSE_OFS, ~(GT_INTRCAUSE_MASABORT0_BIT |
93 GT_INTRCAUSE_TARABORT0_BIT));
94 return -1;
95 }
96 return 0;
97}
98
99/*
100 * We can't address 8 and 16 bit words directly. Instead we have to
101 * read/write a 32bit word and mask/modify the data we actually want.
102 */
103static int gt96100_pcibios_read(struct pci_bus *bus, unsigned int devfn,
104 int where, int size, u32 * val)
105{
106 u32 data = 0;
107
108 if (gt96100_config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
109 return PCIBIOS_DEVICE_NOT_FOUND;
110
111 switch (size) {
112 case 1:
113 *val = (data >> ((where & 3) << 3)) & 0xff;
114 break;
115
116 case 2:
117 *val = (data >> ((where & 3) << 3)) & 0xffff;
118 break;
119
120 case 4:
121 *val = data;
122 break;
123 }
124 return PCIBIOS_SUCCESSFUL;
125}
126
127static int gt96100_pcibios_write(struct pci_bus *bus, unsigned int devfn,
128 int where, int size, u32 val)
129{
130 u32 data = 0;
131
132 switch (size) {
133 case 1:
134 if (gt96100_config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
135 return -1;
136
137 data = (data & ~(0xff << ((where & 3) << 3))) |
138 (val << ((where & 3) << 3));
139
140 if (gt96100_config_access(PCI_ACCESS_WRITE, bus, devfn, where, &data))
141 return -1;
142
143 return PCIBIOS_SUCCESSFUL;
144
145 case 2:
146 if (gt96100_config_access(PCI_ACCESS_READ, bus, devfn, where, &data))
147 return -1;
148
149 data = (data & ~(0xffff << ((where & 3) << 3))) |
150 (val << ((where & 3) << 3));
151
152 if (gt96100_config_access(PCI_ACCESS_WRITE, dev, where, &data))
153 return -1;
154
155
156 return PCIBIOS_SUCCESSFUL;
157
158 case 4:
159 if (gt96100_config_access(PCI_ACCESS_WRITE, dev, where, &val))
160 return -1;
161
162 return PCIBIOS_SUCCESSFUL;
163 }
164}
165
166struct pci_ops gt96100_pci_ops = {
167 .read = gt96100_pcibios_read,
168 .write = gt96100_pcibios_write
169};
diff --git a/arch/mips/pci/pci-ev96100.c b/arch/mips/pci/pci-ev96100.c
deleted file mode 100644
index f9457ea00def..000000000000
--- a/arch/mips/pci/pci-ev96100.c
+++ /dev/null
@@ -1,63 +0,0 @@
1/*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * ppopov@mvista.com or source@mvista.com
5 *
6 * Carsten Langgaard, carstenl@mips.com
7 * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved.
8 *
9 * Copyright (C) 2004 by Ralf Baechle (ralf@linux-mips.org)
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
19 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */
31#include <linux/types.h>
32#include <linux/pci.h>
33#include <linux/kernel.h>
34#include <linux/init.h>
35
36static struct resource pci_io_resource = {
37 .name = "io pci IO space",
38 .start = 0x10000000,
39 .end = 0x11ffffff,
40 .flags = IORESOURCE_IO
41};
42
43static struct resource pci_mem_resource = {
44 .name = "ext pci memory space",
45 .start = 0x12000000,
46 .end = 0x13ffffff,
47 .flags = IORESOURCE_MEM
48};
49
50extern struct pci_ops gt96100_pci_ops;
51
52struct pci_controller ev96100_controller = {
53 .pci_ops = &gt96100_pci_ops,
54 .io_resource = &pci_io_resource,
55 .mem_resource = &pci_mem_resource,
56};
57
58static void ev96100_pci_init(void)
59{
60 register_pci_controller(&ev96100_controller);
61}
62
63arch_initcall(ev96100_pci_init);
diff --git a/arch/mips/pci/pci-ip27.c b/arch/mips/pci/pci-ip27.c
index 80eb9af9ecdf..405ce0152739 100644
--- a/arch/mips/pci/pci-ip27.c
+++ b/arch/mips/pci/pci-ip27.c
@@ -16,8 +16,6 @@
16#include <asm/sn/intr.h> 16#include <asm/sn/intr.h>
17#include <asm/sn/sn0/hub.h> 17#include <asm/sn/sn0/hub.h>
18 18
19extern unsigned int allocate_irqno(void);
20
21/* 19/*
22 * Max #PCI busses we can handle; ie, max #PCI bridges. 20 * Max #PCI busses we can handle; ie, max #PCI bridges.
23 */ 21 */
diff --git a/arch/mips/sibyte/bcm1480/irq.c b/arch/mips/sibyte/bcm1480/irq.c
index ed325f0ab28a..a0222fa4416c 100644
--- a/arch/mips/sibyte/bcm1480/irq.c
+++ b/arch/mips/sibyte/bcm1480/irq.c
@@ -469,21 +469,6 @@ void bcm1480_kgdb_interrupt(struct pt_regs *regs)
469 469
470#endif /* CONFIG_KGDB */ 470#endif /* CONFIG_KGDB */
471 471
472static inline int dclz(unsigned long long x)
473{
474 int lz;
475
476 __asm__ (
477 " .set push \n"
478 " .set mips64 \n"
479 " dclz %0, %1 \n"
480 " .set pop \n"
481 : "=r" (lz)
482 : "r" (x));
483
484 return lz;
485}
486
487extern void bcm1480_timer_interrupt(struct pt_regs *regs); 472extern void bcm1480_timer_interrupt(struct pt_regs *regs);
488extern void bcm1480_mailbox_interrupt(struct pt_regs *regs); 473extern void bcm1480_mailbox_interrupt(struct pt_regs *regs);
489extern void bcm1480_kgdb_interrupt(struct pt_regs *regs); 474extern void bcm1480_kgdb_interrupt(struct pt_regs *regs);
@@ -536,9 +521,9 @@ asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
536 521
537 if (mask_h) { 522 if (mask_h) {
538 if (mask_h ^ 1) 523 if (mask_h ^ 1)
539 do_IRQ(63 - dclz(mask_h), regs); 524 do_IRQ(fls64(mask_h) - 1, regs);
540 else 525 else
541 do_IRQ(127 - dclz(mask_l), regs); 526 do_IRQ(63 + fls64(mask_l), regs);
542 } 527 }
543 } 528 }
544} 529}
diff --git a/arch/mips/sibyte/sb1250/irq.c b/arch/mips/sibyte/sb1250/irq.c
index 1de71adec6c6..a451b4c7732d 100644
--- a/arch/mips/sibyte/sb1250/irq.c
+++ b/arch/mips/sibyte/sb1250/irq.c
@@ -419,21 +419,6 @@ static void sb1250_kgdb_interrupt(struct pt_regs *regs)
419 419
420#endif /* CONFIG_KGDB */ 420#endif /* CONFIG_KGDB */
421 421
422static inline int dclz(unsigned long long x)
423{
424 int lz;
425
426 __asm__ (
427 " .set push \n"
428 " .set mips64 \n"
429 " dclz %0, %1 \n"
430 " .set pop \n"
431 : "=r" (lz)
432 : "r" (x));
433
434 return lz;
435}
436
437extern void sb1250_timer_interrupt(struct pt_regs *regs); 422extern void sb1250_timer_interrupt(struct pt_regs *regs);
438extern void sb1250_mailbox_interrupt(struct pt_regs *regs); 423extern void sb1250_mailbox_interrupt(struct pt_regs *regs);
439extern void sb1250_kgdb_interrupt(struct pt_regs *regs); 424extern void sb1250_kgdb_interrupt(struct pt_regs *regs);
@@ -490,6 +475,6 @@ asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
490 mask = __raw_readq(IOADDR(A_IMR_REGISTER(smp_processor_id(), 475 mask = __raw_readq(IOADDR(A_IMR_REGISTER(smp_processor_id(),
491 R_IMR_INTERRUPT_STATUS_BASE))); 476 R_IMR_INTERRUPT_STATUS_BASE)));
492 if (mask) 477 if (mask)
493 do_IRQ(63 - dclz(mask), regs); 478 do_IRQ(fls64(mask) - 1, regs);
494 } 479 }
495} 480}
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index de1ef2fa1a20..a0dd1b0ee483 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -731,11 +731,10 @@ config ARCH_SPARSEMEM_DEFAULT
731 def_bool y 731 def_bool y
732 depends on SMP && PPC_PSERIES 732 depends on SMP && PPC_PSERIES
733 733
734source "mm/Kconfig" 734config ARCH_POPULATES_NODE_MAP
735
736config HAVE_ARCH_EARLY_PFN_TO_NID
737 def_bool y 735 def_bool y
738 depends on NEED_MULTIPLE_NODES 736
737source "mm/Kconfig"
739 738
740config ARCH_MEMORY_PROBE 739config ARCH_MEMORY_PROBE
741 def_bool y 740 def_bool y
diff --git a/arch/powerpc/kernel/sys_ppc32.c b/arch/powerpc/kernel/sys_ppc32.c
index 2e292863e982..5e391fc25340 100644
--- a/arch/powerpc/kernel/sys_ppc32.c
+++ b/arch/powerpc/kernel/sys_ppc32.c
@@ -740,7 +740,7 @@ asmlinkage long compat_sys_umask(u32 mask)
740 return sys_umask((int)mask); 740 return sys_umask((int)mask);
741} 741}
742 742
743#ifdef CONFIG_SYSCTL 743#ifdef CONFIG_SYSCTL_SYSCALL
744struct __sysctl_args32 { 744struct __sysctl_args32 {
745 u32 name; 745 u32 name;
746 int nlen; 746 int nlen;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index eebd8b83a6b0..16fe027bbc12 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -256,20 +256,22 @@ void __init do_init_bootmem(void)
256 256
257 boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages); 257 boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
258 258
259 /* Add active regions with valid PFNs */
260 for (i = 0; i < lmb.memory.cnt; i++) {
261 unsigned long start_pfn, end_pfn;
262 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT;
263 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i);
264 add_active_range(0, start_pfn, end_pfn);
265 }
266
259 /* Add all physical memory to the bootmem map, mark each area 267 /* Add all physical memory to the bootmem map, mark each area
260 * present. 268 * present.
261 */ 269 */
262 for (i = 0; i < lmb.memory.cnt; i++) {
263 unsigned long base = lmb.memory.region[i].base;
264 unsigned long size = lmb_size_bytes(&lmb.memory, i);
265#ifdef CONFIG_HIGHMEM 270#ifdef CONFIG_HIGHMEM
266 if (base >= total_lowmem) 271 free_bootmem_with_active_regions(0, total_lowmem >> PAGE_SHIFT);
267 continue; 272#else
268 if (base + size > total_lowmem) 273 free_bootmem_with_active_regions(0, max_pfn);
269 size = total_lowmem - base;
270#endif 274#endif
271 free_bootmem(base, size);
272 }
273 275
274 /* reserve the sections we're already using */ 276 /* reserve the sections we're already using */
275 for (i = 0; i < lmb.reserved.cnt; i++) 277 for (i = 0; i < lmb.reserved.cnt; i++)
@@ -277,9 +279,8 @@ void __init do_init_bootmem(void)
277 lmb_size_bytes(&lmb.reserved, i)); 279 lmb_size_bytes(&lmb.reserved, i));
278 280
279 /* XXX need to clip this if using highmem? */ 281 /* XXX need to clip this if using highmem? */
280 for (i = 0; i < lmb.memory.cnt; i++) 282 sparse_memory_present_with_active_regions(0);
281 memory_present(0, lmb_start_pfn(&lmb.memory, i), 283
282 lmb_end_pfn(&lmb.memory, i));
283 init_bootmem_done = 1; 284 init_bootmem_done = 1;
284} 285}
285 286
@@ -288,10 +289,9 @@ void __init do_init_bootmem(void)
288 */ 289 */
289void __init paging_init(void) 290void __init paging_init(void)
290{ 291{
291 unsigned long zones_size[MAX_NR_ZONES];
292 unsigned long zholes_size[MAX_NR_ZONES];
293 unsigned long total_ram = lmb_phys_mem_size(); 292 unsigned long total_ram = lmb_phys_mem_size();
294 unsigned long top_of_ram = lmb_end_of_DRAM(); 293 unsigned long top_of_ram = lmb_end_of_DRAM();
294 unsigned long max_zone_pfns[MAX_NR_ZONES];
295 295
296#ifdef CONFIG_HIGHMEM 296#ifdef CONFIG_HIGHMEM
297 map_page(PKMAP_BASE, 0, 0); /* XXX gross */ 297 map_page(PKMAP_BASE, 0, 0); /* XXX gross */
@@ -307,26 +307,13 @@ void __init paging_init(void)
307 top_of_ram, total_ram); 307 top_of_ram, total_ram);
308 printk(KERN_DEBUG "Memory hole size: %ldMB\n", 308 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
309 (top_of_ram - total_ram) >> 20); 309 (top_of_ram - total_ram) >> 20);
310 /*
311 * All pages are DMA-able so we put them all in the DMA zone.
312 */
313 memset(zones_size, 0, sizeof(zones_size));
314 memset(zholes_size, 0, sizeof(zholes_size));
315
316 zones_size[ZONE_DMA] = top_of_ram >> PAGE_SHIFT;
317 zholes_size[ZONE_DMA] = (top_of_ram - total_ram) >> PAGE_SHIFT;
318
319#ifdef CONFIG_HIGHMEM 310#ifdef CONFIG_HIGHMEM
320 zones_size[ZONE_DMA] = total_lowmem >> PAGE_SHIFT; 311 max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
321 zones_size[ZONE_HIGHMEM] = (total_memory - total_lowmem) >> PAGE_SHIFT; 312 max_zone_pfns[1] = top_of_ram >> PAGE_SHIFT;
322 zholes_size[ZONE_HIGHMEM] = (top_of_ram - total_ram) >> PAGE_SHIFT;
323#else 313#else
324 zones_size[ZONE_DMA] = top_of_ram >> PAGE_SHIFT; 314 max_zone_pfns[0] = top_of_ram >> PAGE_SHIFT;
325 zholes_size[ZONE_DMA] = (top_of_ram - total_ram) >> PAGE_SHIFT; 315#endif
326#endif /* CONFIG_HIGHMEM */ 316 free_area_init_nodes(max_zone_pfns);
327
328 free_area_init_node(0, NODE_DATA(0), zones_size,
329 __pa(PAGE_OFFSET) >> PAGE_SHIFT, zholes_size);
330} 317}
331#endif /* ! CONFIG_NEED_MULTIPLE_NODES */ 318#endif /* ! CONFIG_NEED_MULTIPLE_NODES */
332 319
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 6c0f1c7d83e5..43c272075e1a 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -39,96 +39,6 @@ static bootmem_data_t __initdata plat_node_bdata[MAX_NUMNODES];
39static int min_common_depth; 39static int min_common_depth;
40static int n_mem_addr_cells, n_mem_size_cells; 40static int n_mem_addr_cells, n_mem_size_cells;
41 41
42/*
43 * We need somewhere to store start/end/node for each region until we have
44 * allocated the real node_data structures.
45 */
46#define MAX_REGIONS (MAX_LMB_REGIONS*2)
47static struct {
48 unsigned long start_pfn;
49 unsigned long end_pfn;
50 int nid;
51} init_node_data[MAX_REGIONS] __initdata;
52
53int __init early_pfn_to_nid(unsigned long pfn)
54{
55 unsigned int i;
56
57 for (i = 0; init_node_data[i].end_pfn; i++) {
58 unsigned long start_pfn = init_node_data[i].start_pfn;
59 unsigned long end_pfn = init_node_data[i].end_pfn;
60
61 if ((start_pfn <= pfn) && (pfn < end_pfn))
62 return init_node_data[i].nid;
63 }
64
65 return -1;
66}
67
68void __init add_region(unsigned int nid, unsigned long start_pfn,
69 unsigned long pages)
70{
71 unsigned int i;
72
73 dbg("add_region nid %d start_pfn 0x%lx pages 0x%lx\n",
74 nid, start_pfn, pages);
75
76 for (i = 0; init_node_data[i].end_pfn; i++) {
77 if (init_node_data[i].nid != nid)
78 continue;
79 if (init_node_data[i].end_pfn == start_pfn) {
80 init_node_data[i].end_pfn += pages;
81 return;
82 }
83 if (init_node_data[i].start_pfn == (start_pfn + pages)) {
84 init_node_data[i].start_pfn -= pages;
85 return;
86 }
87 }
88
89 /*
90 * Leave last entry NULL so we dont iterate off the end (we use
91 * entry.end_pfn to terminate the walk).
92 */
93 if (i >= (MAX_REGIONS - 1)) {
94 printk(KERN_ERR "WARNING: too many memory regions in "
95 "numa code, truncating\n");
96 return;
97 }
98
99 init_node_data[i].start_pfn = start_pfn;
100 init_node_data[i].end_pfn = start_pfn + pages;
101 init_node_data[i].nid = nid;
102}
103
104/* We assume init_node_data has no overlapping regions */
105void __init get_region(unsigned int nid, unsigned long *start_pfn,
106 unsigned long *end_pfn, unsigned long *pages_present)
107{
108 unsigned int i;
109
110 *start_pfn = -1UL;
111 *end_pfn = *pages_present = 0;
112
113 for (i = 0; init_node_data[i].end_pfn; i++) {
114 if (init_node_data[i].nid != nid)
115 continue;
116
117 *pages_present += init_node_data[i].end_pfn -
118 init_node_data[i].start_pfn;
119
120 if (init_node_data[i].start_pfn < *start_pfn)
121 *start_pfn = init_node_data[i].start_pfn;
122
123 if (init_node_data[i].end_pfn > *end_pfn)
124 *end_pfn = init_node_data[i].end_pfn;
125 }
126
127 /* We didnt find a matching region, return start/end as 0 */
128 if (*start_pfn == -1UL)
129 *start_pfn = 0;
130}
131
132static void __cpuinit map_cpu_to_node(int cpu, int node) 42static void __cpuinit map_cpu_to_node(int cpu, int node)
133{ 43{
134 numa_cpu_lookup_table[cpu] = node; 44 numa_cpu_lookup_table[cpu] = node;
@@ -468,8 +378,8 @@ new_range:
468 continue; 378 continue;
469 } 379 }
470 380
471 add_region(nid, start >> PAGE_SHIFT, 381 add_active_range(nid, start >> PAGE_SHIFT,
472 size >> PAGE_SHIFT); 382 (start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
473 383
474 if (--ranges) 384 if (--ranges)
475 goto new_range; 385 goto new_range;
@@ -482,6 +392,7 @@ static void __init setup_nonnuma(void)
482{ 392{
483 unsigned long top_of_ram = lmb_end_of_DRAM(); 393 unsigned long top_of_ram = lmb_end_of_DRAM();
484 unsigned long total_ram = lmb_phys_mem_size(); 394 unsigned long total_ram = lmb_phys_mem_size();
395 unsigned long start_pfn, end_pfn;
485 unsigned int i; 396 unsigned int i;
486 397
487 printk(KERN_DEBUG "Top of RAM: 0x%lx, Total RAM: 0x%lx\n", 398 printk(KERN_DEBUG "Top of RAM: 0x%lx, Total RAM: 0x%lx\n",
@@ -489,9 +400,11 @@ static void __init setup_nonnuma(void)
489 printk(KERN_DEBUG "Memory hole size: %ldMB\n", 400 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
490 (top_of_ram - total_ram) >> 20); 401 (top_of_ram - total_ram) >> 20);
491 402
492 for (i = 0; i < lmb.memory.cnt; ++i) 403 for (i = 0; i < lmb.memory.cnt; ++i) {
493 add_region(0, lmb.memory.region[i].base >> PAGE_SHIFT, 404 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT;
494 lmb_size_pages(&lmb.memory, i)); 405 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i);
406 add_active_range(0, start_pfn, end_pfn);
407 }
495 node_set_online(0); 408 node_set_online(0);
496} 409}
497 410
@@ -630,11 +543,11 @@ void __init do_init_bootmem(void)
630 (void *)(unsigned long)boot_cpuid); 543 (void *)(unsigned long)boot_cpuid);
631 544
632 for_each_online_node(nid) { 545 for_each_online_node(nid) {
633 unsigned long start_pfn, end_pfn, pages_present; 546 unsigned long start_pfn, end_pfn;
634 unsigned long bootmem_paddr; 547 unsigned long bootmem_paddr;
635 unsigned long bootmap_pages; 548 unsigned long bootmap_pages;
636 549
637 get_region(nid, &start_pfn, &end_pfn, &pages_present); 550 get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
638 551
639 /* Allocate the node structure node local if possible */ 552 /* Allocate the node structure node local if possible */
640 NODE_DATA(nid) = careful_allocation(nid, 553 NODE_DATA(nid) = careful_allocation(nid,
@@ -667,19 +580,7 @@ void __init do_init_bootmem(void)
667 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT, 580 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
668 start_pfn, end_pfn); 581 start_pfn, end_pfn);
669 582
670 /* Add free regions on this node */ 583 free_bootmem_with_active_regions(nid, end_pfn);
671 for (i = 0; init_node_data[i].end_pfn; i++) {
672 unsigned long start, end;
673
674 if (init_node_data[i].nid != nid)
675 continue;
676
677 start = init_node_data[i].start_pfn << PAGE_SHIFT;
678 end = init_node_data[i].end_pfn << PAGE_SHIFT;
679
680 dbg("free_bootmem %lx %lx\n", start, end - start);
681 free_bootmem_node(NODE_DATA(nid), start, end - start);
682 }
683 584
684 /* Mark reserved regions on this node */ 585 /* Mark reserved regions on this node */
685 for (i = 0; i < lmb.reserved.cnt; i++) { 586 for (i = 0; i < lmb.reserved.cnt; i++) {
@@ -710,44 +611,16 @@ void __init do_init_bootmem(void)
710 } 611 }
711 } 612 }
712 613
713 /* Add regions into sparsemem */ 614 sparse_memory_present_with_active_regions(nid);
714 for (i = 0; init_node_data[i].end_pfn; i++) {
715 unsigned long start, end;
716
717 if (init_node_data[i].nid != nid)
718 continue;
719
720 start = init_node_data[i].start_pfn;
721 end = init_node_data[i].end_pfn;
722
723 memory_present(nid, start, end);
724 }
725 } 615 }
726} 616}
727 617
728void __init paging_init(void) 618void __init paging_init(void)
729{ 619{
730 unsigned long zones_size[MAX_NR_ZONES]; 620 unsigned long max_zone_pfns[MAX_NR_ZONES] = {
731 unsigned long zholes_size[MAX_NR_ZONES]; 621 lmb_end_of_DRAM() >> PAGE_SHIFT
732 int nid; 622 };
733 623 free_area_init_nodes(max_zone_pfns);
734 memset(zones_size, 0, sizeof(zones_size));
735 memset(zholes_size, 0, sizeof(zholes_size));
736
737 for_each_online_node(nid) {
738 unsigned long start_pfn, end_pfn, pages_present;
739
740 get_region(nid, &start_pfn, &end_pfn, &pages_present);
741
742 zones_size[ZONE_DMA] = end_pfn - start_pfn;
743 zholes_size[ZONE_DMA] = zones_size[ZONE_DMA] - pages_present;
744
745 dbg("free_area_init node %d %lx %lx (hole: %lx)\n", nid,
746 zones_size[ZONE_DMA], start_pfn, zholes_size[ZONE_DMA]);
747
748 free_area_init_node(nid, NODE_DATA(nid), zones_size, start_pfn,
749 zholes_size);
750 }
751} 624}
752 625
753static int __init early_numa(char *p) 626static int __init early_numa(char *p)
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 7b4572805db9..3950ddccb2c8 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -82,7 +82,6 @@ spufs_new_inode(struct super_block *sb, int mode)
82 inode->i_mode = mode; 82 inode->i_mode = mode;
83 inode->i_uid = current->fsuid; 83 inode->i_uid = current->fsuid;
84 inode->i_gid = current->fsgid; 84 inode->i_gid = current->fsgid;
85 inode->i_blksize = PAGE_CACHE_SIZE;
86 inode->i_blocks = 0; 85 inode->i_blocks = 0;
87 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 86 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
88out: 87out:
@@ -120,7 +119,7 @@ spufs_new_file(struct super_block *sb, struct dentry *dentry,
120 ret = 0; 119 ret = 0;
121 inode->i_op = &spufs_file_iops; 120 inode->i_op = &spufs_file_iops;
122 inode->i_fop = fops; 121 inode->i_fop = fops;
123 inode->u.generic_ip = SPUFS_I(inode)->i_ctx = get_spu_context(ctx); 122 inode->i_private = SPUFS_I(inode)->i_ctx = get_spu_context(ctx);
124 d_add(dentry, inode); 123 d_add(dentry, inode);
125out: 124out:
126 return ret; 125 return ret;
diff --git a/arch/powerpc/platforms/pseries/hvCall_inst.c b/arch/powerpc/platforms/pseries/hvCall_inst.c
index 641e6511cf06..446e17d162a5 100644
--- a/arch/powerpc/platforms/pseries/hvCall_inst.c
+++ b/arch/powerpc/platforms/pseries/hvCall_inst.c
@@ -85,7 +85,7 @@ static int hcall_inst_seq_open(struct inode *inode, struct file *file)
85 85
86 rc = seq_open(file, &hcall_inst_seq_ops); 86 rc = seq_open(file, &hcall_inst_seq_ops);
87 seq = file->private_data; 87 seq = file->private_data;
88 seq->private = file->f_dentry->d_inode->u.generic_ip; 88 seq->private = file->f_dentry->d_inode->i_private;
89 89
90 return rc; 90 return rc;
91} 91}
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index b604926401f5..723972bb5bd9 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -339,7 +339,7 @@ static void __init mpic_scan_ht_pic(struct mpic *mpic, u8 __iomem *devbase,
339 for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0; 339 for (pos = readb(devbase + PCI_CAPABILITY_LIST); pos != 0;
340 pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) { 340 pos = readb(devbase + pos + PCI_CAP_LIST_NEXT)) {
341 u8 id = readb(devbase + pos + PCI_CAP_LIST_ID); 341 u8 id = readb(devbase + pos + PCI_CAP_LIST_ID);
342 if (id == PCI_CAP_ID_HT_IRQCONF) { 342 if (id == PCI_CAP_ID_HT) {
343 id = readb(devbase + pos + 3); 343 id = readb(devbase + pos + 3);
344 if (id == 0x80) 344 if (id == 0x80)
345 break; 345 break;
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 8fa10cf661a8..fdd9e7b66244 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -953,6 +953,9 @@ config NR_CPUS
953config HIGHMEM 953config HIGHMEM
954 bool "High memory support" 954 bool "High memory support"
955 955
956config ARCH_POPULATES_NODE_MAP
957 def_bool y
958
956source kernel/Kconfig.hz 959source kernel/Kconfig.hz
957source kernel/Kconfig.preempt 960source kernel/Kconfig.preempt
958source "mm/Kconfig" 961source "mm/Kconfig"
diff --git a/arch/ppc/mm/init.c b/arch/ppc/mm/init.c
index 523392d460fa..410200046af1 100644
--- a/arch/ppc/mm/init.c
+++ b/arch/ppc/mm/init.c
@@ -358,8 +358,8 @@ void __init do_init_bootmem(void)
358 */ 358 */
359void __init paging_init(void) 359void __init paging_init(void)
360{ 360{
361 unsigned long zones_size[MAX_NR_ZONES], i; 361 unsigned long start_pfn, end_pfn;
362 362 unsigned long max_zone_pfns[MAX_NR_ZONES];
363#ifdef CONFIG_HIGHMEM 363#ifdef CONFIG_HIGHMEM
364 map_page(PKMAP_BASE, 0, 0); /* XXX gross */ 364 map_page(PKMAP_BASE, 0, 0); /* XXX gross */
365 pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k 365 pkmap_page_table = pte_offset_kernel(pmd_offset(pgd_offset_k
@@ -369,19 +369,18 @@ void __init paging_init(void)
369 (KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN); 369 (KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN);
370 kmap_prot = PAGE_KERNEL; 370 kmap_prot = PAGE_KERNEL;
371#endif /* CONFIG_HIGHMEM */ 371#endif /* CONFIG_HIGHMEM */
372 372 /* All pages are DMA-able so we put them all in the DMA zone. */
373 /* 373 start_pfn = __pa(PAGE_OFFSET) >> PAGE_SHIFT;
374 * All pages are DMA-able so we put them all in the DMA zone. 374 end_pfn = start_pfn + (total_memory >> PAGE_SHIFT);
375 */ 375 add_active_range(0, start_pfn, end_pfn);
376 zones_size[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
377 for (i = 1; i < MAX_NR_ZONES; i++)
378 zones_size[i] = 0;
379 376
380#ifdef CONFIG_HIGHMEM 377#ifdef CONFIG_HIGHMEM
381 zones_size[ZONE_HIGHMEM] = (total_memory - total_lowmem) >> PAGE_SHIFT; 378 max_zone_pfns[0] = total_lowmem >> PAGE_SHIFT;
379 max_zone_pfns[1] = total_memory >> PAGE_SHIFT;
380#else
381 max_zone_pfns[0] = total_memory >> PAGE_SHIFT;
382#endif /* CONFIG_HIGHMEM */ 382#endif /* CONFIG_HIGHMEM */
383 383 free_area_init_nodes(max_zone_pfns);
384 free_area_init(zones_size);
385} 384}
386 385
387void __init mem_init(void) 386void __init mem_init(void)
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c
index bdade5f2e325..813fc21358f9 100644
--- a/arch/s390/hypfs/inode.c
+++ b/arch/s390/hypfs/inode.c
@@ -91,7 +91,6 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode)
91 ret->i_mode = mode; 91 ret->i_mode = mode;
92 ret->i_uid = hypfs_info->uid; 92 ret->i_uid = hypfs_info->uid;
93 ret->i_gid = hypfs_info->gid; 93 ret->i_gid = hypfs_info->gid;
94 ret->i_blksize = PAGE_CACHE_SIZE;
95 ret->i_blocks = 0; 94 ret->i_blocks = 0;
96 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 95 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
97 if (mode & S_IFDIR) 96 if (mode & S_IFDIR)
@@ -104,13 +103,13 @@ static struct inode *hypfs_make_inode(struct super_block *sb, int mode)
104 103
105static void hypfs_drop_inode(struct inode *inode) 104static void hypfs_drop_inode(struct inode *inode)
106{ 105{
107 kfree(inode->u.generic_ip); 106 kfree(inode->i_private);
108 generic_delete_inode(inode); 107 generic_delete_inode(inode);
109} 108}
110 109
111static int hypfs_open(struct inode *inode, struct file *filp) 110static int hypfs_open(struct inode *inode, struct file *filp)
112{ 111{
113 char *data = filp->f_dentry->d_inode->u.generic_ip; 112 char *data = filp->f_dentry->d_inode->i_private;
114 struct hypfs_sb_info *fs_info; 113 struct hypfs_sb_info *fs_info;
115 114
116 if (filp->f_mode & FMODE_WRITE) { 115 if (filp->f_mode & FMODE_WRITE) {
@@ -352,7 +351,7 @@ static struct dentry *hypfs_create_file(struct super_block *sb,
352 parent->d_inode->i_nlink++; 351 parent->d_inode->i_nlink++;
353 } else 352 } else
354 BUG(); 353 BUG();
355 inode->u.generic_ip = data; 354 inode->i_private = data;
356 d_instantiate(dentry, inode); 355 d_instantiate(dentry, inode);
357 dget(dentry); 356 dget(dentry);
358 return dentry; 357 return dentry;
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index 785c9f70ac98..91b2884fa5c4 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -708,7 +708,7 @@ asmlinkage long sys32_sendfile64(int out_fd, int in_fd,
708 return ret; 708 return ret;
709} 709}
710 710
711#ifdef CONFIG_SYSCTL 711#ifdef CONFIG_SYSCTL_SYSCALL
712struct __sysctl_args32 { 712struct __sysctl_args32 {
713 u32 name; 713 u32 name;
714 int nlen; 714 int nlen;
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 7ba20922a535..43f3d0c7e132 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -603,7 +603,7 @@ debug_open(struct inode *inode, struct file *file)
603 debug_info_t *debug_info, *debug_info_snapshot; 603 debug_info_t *debug_info, *debug_info_snapshot;
604 604
605 down(&debug_lock); 605 down(&debug_lock);
606 debug_info = (struct debug_info*)file->f_dentry->d_inode->u.generic_ip; 606 debug_info = file->f_dentry->d_inode->i_private;
607 /* find debug view */ 607 /* find debug view */
608 for (i = 0; i < DEBUG_MAX_VIEWS; i++) { 608 for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
609 if (!debug_info->views[i]) 609 if (!debug_info->views[i])
diff --git a/arch/s390/kernel/stacktrace.c b/arch/s390/kernel/stacktrace.c
index de83f38288d0..d9428a0fc8fb 100644
--- a/arch/s390/kernel/stacktrace.c
+++ b/arch/s390/kernel/stacktrace.c
@@ -59,9 +59,7 @@ static inline unsigned long save_context_stack(struct stack_trace *trace,
59 } 59 }
60} 60}
61 61
62void save_stack_trace(struct stack_trace *trace, 62void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
63 struct task_struct *task, int all_contexts,
64 unsigned int skip)
65{ 63{
66 register unsigned long sp asm ("15"); 64 register unsigned long sp asm ("15");
67 unsigned long orig_sp; 65 unsigned long orig_sp;
@@ -69,22 +67,23 @@ void save_stack_trace(struct stack_trace *trace,
69 sp &= PSW_ADDR_INSN; 67 sp &= PSW_ADDR_INSN;
70 orig_sp = sp; 68 orig_sp = sp;
71 69
72 sp = save_context_stack(trace, &skip, sp, 70 sp = save_context_stack(trace, &trace->skip, sp,
73 S390_lowcore.panic_stack - PAGE_SIZE, 71 S390_lowcore.panic_stack - PAGE_SIZE,
74 S390_lowcore.panic_stack); 72 S390_lowcore.panic_stack);
75 if ((sp != orig_sp) && !all_contexts) 73 if ((sp != orig_sp) && !trace->all_contexts)
76 return; 74 return;
77 sp = save_context_stack(trace, &skip, sp, 75 sp = save_context_stack(trace, &trace->skip, sp,
78 S390_lowcore.async_stack - ASYNC_SIZE, 76 S390_lowcore.async_stack - ASYNC_SIZE,
79 S390_lowcore.async_stack); 77 S390_lowcore.async_stack);
80 if ((sp != orig_sp) && !all_contexts) 78 if ((sp != orig_sp) && !trace->all_contexts)
81 return; 79 return;
82 if (task) 80 if (task)
83 save_context_stack(trace, &skip, sp, 81 save_context_stack(trace, &trace->skip, sp,
84 (unsigned long) task_stack_page(task), 82 (unsigned long) task_stack_page(task),
85 (unsigned long) task_stack_page(task) + THREAD_SIZE); 83 (unsigned long) task_stack_page(task) + THREAD_SIZE);
86 else 84 else
87 save_context_stack(trace, &skip, sp, S390_lowcore.thread_info, 85 save_context_stack(trace, &trace->skip, sp,
86 S390_lowcore.thread_info,
88 S390_lowcore.thread_info + THREAD_SIZE); 87 S390_lowcore.thread_info + THREAD_SIZE);
89 return; 88 return;
90} 89}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 1a0db1d4c952..1cc5c9b27bfd 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -8,6 +8,7 @@ mainmenu "Linux/SuperH Kernel Configuration"
8config SUPERH 8config SUPERH
9 bool 9 bool
10 default y 10 default y
11 select EMBEDDED
11 help 12 help
12 The SuperH is a RISC processor targeted for use in embedded systems 13 The SuperH is a RISC processor targeted for use in embedded systems
13 and consumer electronics; it was also used in the Sega Dreamcast 14 and consumer electronics; it was also used in the Sega Dreamcast
@@ -51,18 +52,23 @@ source "init/Kconfig"
51 52
52menu "System type" 53menu "System type"
53 54
55config SOLUTION_ENGINE
56 bool
57
54choice 58choice
55 prompt "SuperH system type" 59 prompt "SuperH system type"
56 default SH_UNKNOWN 60 default SH_UNKNOWN
57 61
58config SH_SOLUTION_ENGINE 62config SH_SOLUTION_ENGINE
59 bool "SolutionEngine" 63 bool "SolutionEngine"
64 select SOLUTION_ENGINE
60 help 65 help
61 Select SolutionEngine if configuring for a Hitachi SH7709 66 Select SolutionEngine if configuring for a Hitachi SH7709
62 or SH7750 evaluation board. 67 or SH7750 evaluation board.
63 68
64config SH_7751_SOLUTION_ENGINE 69config SH_7751_SOLUTION_ENGINE
65 bool "SolutionEngine7751" 70 bool "SolutionEngine7751"
71 select SOLUTION_ENGINE
66 select CPU_SUBTYPE_SH7751 72 select CPU_SUBTYPE_SH7751
67 help 73 help
68 Select 7751 SolutionEngine if configuring for a Hitachi SH7751 74 Select 7751 SolutionEngine if configuring for a Hitachi SH7751
@@ -70,17 +76,27 @@ config SH_7751_SOLUTION_ENGINE
70 76
71config SH_7300_SOLUTION_ENGINE 77config SH_7300_SOLUTION_ENGINE
72 bool "SolutionEngine7300" 78 bool "SolutionEngine7300"
79 select SOLUTION_ENGINE
73 select CPU_SUBTYPE_SH7300 80 select CPU_SUBTYPE_SH7300
74 help 81 help
75 Select 7300 SolutionEngine if configuring for a Hitachi SH7300(SH-Mobile V) 82 Select 7300 SolutionEngine if configuring for a Hitachi
76 evaluation board. 83 SH7300(SH-Mobile V) evaluation board.
84
85config SH_7343_SOLUTION_ENGINE
86 bool "SolutionEngine7343"
87 select SOLUTION_ENGINE
88 select CPU_SUBTYPE_SH7343
89 help
90 Select 7343 SolutionEngine if configuring for a Hitachi
91 SH7343 (SH-Mobile 3AS) evaluation board.
77 92
78config SH_73180_SOLUTION_ENGINE 93config SH_73180_SOLUTION_ENGINE
79 bool "SolutionEngine73180" 94 bool "SolutionEngine73180"
80 select CPU_SUBTYPE_SH73180 95 select SOLUTION_ENGINE
81 help 96 select CPU_SUBTYPE_SH73180
82 Select 73180 SolutionEngine if configuring for a Hitachi SH73180(SH-Mobile 3) 97 help
83 evaluation board. 98 Select 73180 SolutionEngine if configuring for a Hitachi
99 SH73180(SH-Mobile 3) evaluation board.
84 100
85config SH_7751_SYSTEMH 101config SH_7751_SYSTEMH
86 bool "SystemH7751R" 102 bool "SystemH7751R"
@@ -89,12 +105,6 @@ config SH_7751_SYSTEMH
89 Select SystemH if you are configuring for a Renesas SystemH 105 Select SystemH if you are configuring for a Renesas SystemH
90 7751R evaluation board. 106 7751R evaluation board.
91 107
92config SH_STB1_HARP
93 bool "STB1_Harp"
94
95config SH_STB1_OVERDRIVE
96 bool "STB1_Overdrive"
97
98config SH_HP6XX 108config SH_HP6XX
99 bool "HP6XX" 109 bool "HP6XX"
100 help 110 help
@@ -102,19 +112,6 @@ config SH_HP6XX
102 More information (hardware only) at 112 More information (hardware only) at
103 <http://www.hp.com/jornada/>. 113 <http://www.hp.com/jornada/>.
104 114
105config SH_CQREEK
106 bool "CqREEK"
107 help
108 Select CqREEK if configuring for a CqREEK SH7708 or SH7750.
109 More information at
110 <http://sources.redhat.com/ecos/hardware.html#SuperH>.
111
112config SH_DMIDA
113 bool "DMIDA"
114 help
115 Select DMIDA if configuring for a DataMyte 4000 Industrial
116 Digital Assistant. More information at <http://www.dmida.com/>.
117
118config SH_EC3104 115config SH_EC3104
119 bool "EC3104" 116 bool "EC3104"
120 help 117 help
@@ -136,25 +133,9 @@ config SH_DREAMCAST
136 <http://www.m17n.org/linux-sh/dreamcast/>. There is a 133 <http://www.m17n.org/linux-sh/dreamcast/>. There is a
137 Dreamcast project is at <http://linuxdc.sourceforge.net/>. 134 Dreamcast project is at <http://linuxdc.sourceforge.net/>.
138 135
139config SH_CAT68701
140 bool "CAT68701"
141
142config SH_BIGSUR 136config SH_BIGSUR
143 bool "BigSur" 137 bool "BigSur"
144 138
145config SH_SH2000
146 bool "SH2000"
147 select CPU_SUBTYPE_SH7709
148 help
149 SH-2000 is a single-board computer based around SH7709A chip
150 intended for embedded applications.
151 It has an Ethernet interface (CS8900A), direct connected
152 Compact Flash socket, three serial ports and PC-104 bus.
153 More information at <http://sh2000.sh-linux.org>.
154
155config SH_ADX
156 bool "ADX"
157
158config SH_MPC1211 139config SH_MPC1211
159 bool "Interface MPC1211" 140 bool "Interface MPC1211"
160 help 141 help
@@ -184,6 +165,13 @@ config SH_HS7751RVOIP
184 Select HS7751RVOIP if configuring for a Renesas Technology 165 Select HS7751RVOIP if configuring for a Renesas Technology
185 Sales VoIP board. 166 Sales VoIP board.
186 167
168config SH_7710VOIPGW
169 bool "SH7710-VOIP-GW"
170 select CPU_SUBTYPE_SH7710
171 help
172 Select this option to build a kernel for the SH7710 based
173 VOIP GW.
174
187config SH_RTS7751R2D 175config SH_RTS7751R2D
188 bool "RTS7751R2D" 176 bool "RTS7751R2D"
189 select CPU_SUBTYPE_SH7751R 177 select CPU_SUBTYPE_SH7751R
@@ -222,6 +210,12 @@ config SH_TITAN
222 Select Titan if you are configuring for a Nimble Microsystems 210 Select Titan if you are configuring for a Nimble Microsystems
223 NetEngine NP51R. 211 NetEngine NP51R.
224 212
213config SH_SHMIN
214 bool "SHMIN"
215 select CPU_SUBTYPE_SH7706
216 help
217 Select SHMIN if configureing for the SHMIN board
218
225config SH_UNKNOWN 219config SH_UNKNOWN
226 bool "BareCPU" 220 bool "BareCPU"
227 help 221 help
@@ -238,35 +232,9 @@ endchoice
238 232
239source "arch/sh/mm/Kconfig" 233source "arch/sh/mm/Kconfig"
240 234
241config MEMORY_START
242 hex "Physical memory start address"
243 default "0x08000000"
244 ---help---
245 Computers built with Hitachi SuperH processors always
246 map the ROM starting at address zero. But the processor
247 does not specify the range that RAM takes.
248
249 The physical memory (RAM) start address will be automatically
250 set to 08000000. Other platforms, such as the Solution Engine
251 boards typically map RAM at 0C000000.
252
253 Tweak this only when porting to a new machine which does not
254 already have a defconfig. Changing it from the known correct
255 value on any of the known systems will only lead to disaster.
256
257config MEMORY_SIZE
258 hex "Physical memory size"
259 default "0x00400000"
260 help
261 This sets the default memory size assumed by your SH kernel. It can
262 be overridden as normal by the 'mem=' argument on the kernel command
263 line. If unsure, consult your board specifications or just leave it
264 as 0x00400000 which was the default value before this became
265 configurable.
266
267config CF_ENABLER 235config CF_ENABLER
268 bool "Compact Flash Enabler support" 236 bool "Compact Flash Enabler support"
269 depends on SH_ADX || SH_SOLUTION_ENGINE || SH_UNKNOWN || SH_CAT68701 || SH_SH03 237 depends on SH_SOLUTION_ENGINE || SH_UNKNOWN || SH_SH03
270 ---help--- 238 ---help---
271 Compact Flash is a small, removable mass storage device introduced 239 Compact Flash is a small, removable mass storage device introduced
272 in 1994 originally as a PCMCIA device. If you say `Y' here, you 240 in 1994 originally as a PCMCIA device. If you say `Y' here, you
@@ -294,7 +262,7 @@ config CF_AREA5
294 - "Area5" if CompactFlash is connected to Area 5 (0x14000000) 262 - "Area5" if CompactFlash is connected to Area 5 (0x14000000)
295 - "Area6" if it is connected to Area 6 (0x18000000) 263 - "Area6" if it is connected to Area 6 (0x18000000)
296 264
297 "Area6" will work for most boards. For ADX, select "Area5". 265 "Area6" will work for most boards.
298 266
299config CF_AREA6 267config CF_AREA6
300 bool "Area6" 268 bool "Area6"
@@ -316,19 +284,6 @@ config CPU_LITTLE_ENDIAN
316 endian byte order. These modes require different kernels. Say Y if 284 endian byte order. These modes require different kernels. Say Y if
317 your machine is little endian, N if it's a big endian machine. 285 your machine is little endian, N if it's a big endian machine.
318 286
319# The SH7750 RTC module is disabled in the Dreamcast
320config SH_RTC
321 bool
322 depends on !SH_DREAMCAST && !SH_SATURN && !SH_7300_SOLUTION_ENGINE && \
323 !SH_73180_SOLUTION_ENGINE && !SH_LANDISK && \
324 !SH_R7780RP
325 default y
326 help
327 Selecting this option will allow the Linux kernel to emulate
328 PC's RTC.
329
330 If unsure, say N.
331
332config SH_FPU 287config SH_FPU
333 bool "FPU support" 288 bool "FPU support"
334 depends on !CPU_SH3 289 depends on !CPU_SH3
@@ -339,14 +294,22 @@ config SH_FPU
339 294
340 This option must be set in order to enable the FPU. 295 This option must be set in order to enable the FPU.
341 296
297config SH_FPU_EMU
298 bool "FPU emulation support"
299 depends on !SH_FPU && EXPERIMENTAL
300 default n
301 help
302 Selecting this option will enable support for software FPU emulation.
303 Most SH-3 users will want to say Y here, whereas most SH-4 users will
304 want to say N.
305
342config SH_DSP 306config SH_DSP
343 bool "DSP support" 307 bool "DSP support"
344 depends on !CPU_SH4 308 default y if SH4AL_DSP || !CPU_SH4
345 default y 309 default n
346 help 310 help
347 Selecting this option will enable support for SH processors that 311 Selecting this option will enable support for SH processors that
348 have DSP units (ie, SH2-DSP and SH3-DSP). It is safe to say Y here 312 have DSP units (ie, SH2-DSP, SH3-DSP, and SH4AL-DSP).
349 by default, as the existance of the DSP will be probed at runtime.
350 313
351 This option must be set in order to enable the DSP. 314 This option must be set in order to enable the DSP.
352 315
@@ -373,6 +336,9 @@ config CPU_HAS_INTEVT
373config CPU_HAS_PINT_IRQ 336config CPU_HAS_PINT_IRQ
374 bool 337 bool
375 338
339config CPU_HAS_MASKREG_IRQ
340 bool
341
376config CPU_HAS_INTC2_IRQ 342config CPU_HAS_INTC2_IRQ
377 bool 343 bool
378 344
@@ -400,16 +366,19 @@ config SH_TMU
400 366
401endmenu 367endmenu
402 368
403#source "arch/sh/boards/renesas/hs7751rvoip/Kconfig" 369source "arch/sh/boards/renesas/hs7751rvoip/Kconfig"
370
371source "arch/sh/boards/renesas/rts7751r2d/Kconfig"
404 372
405#source "arch/sh/boards/renesas/rts7751r2d/Kconfig" 373source "arch/sh/boards/renesas/r7780rp/Kconfig"
406 374
407config SH_PCLK_FREQ 375config SH_PCLK_FREQ
408 int "Peripheral clock frequency (in Hz)" 376 int "Peripheral clock frequency (in Hz)"
409 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780 377 default "50000000" if CPU_SUBTYPE_SH7750 || CPU_SUBTYPE_SH7780
410 default "60000000" if CPU_SUBTYPE_SH7751 378 default "60000000" if CPU_SUBTYPE_SH7751
411 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || CPU_SUBTYPE_SH7760 379 default "33333333" if CPU_SUBTYPE_SH7300 || CPU_SUBTYPE_SH7770 || \
412 default "27000000" if CPU_SUBTYPE_SH73180 380 CPU_SUBTYPE_SH7760
381 default "27000000" if CPU_SUBTYPE_SH73180 || CPU_SUBTYPE_SH7343
413 default "66000000" if CPU_SUBTYPE_SH4_202 382 default "66000000" if CPU_SUBTYPE_SH4_202
414 help 383 help
415 This option is used to specify the peripheral clock frequency. 384 This option is used to specify the peripheral clock frequency.
@@ -440,10 +409,8 @@ source "arch/sh/cchips/Kconfig"
440 409
441config HEARTBEAT 410config HEARTBEAT
442 bool "Heartbeat LED" 411 bool "Heartbeat LED"
443 depends on SH_MPC1211 || SH_SH03 || SH_CAT68701 || \ 412 depends on SH_MPC1211 || SH_SH03 || \
444 SH_STB1_HARP || SH_STB1_OVERDRIVE || SH_BIGSUR || \ 413 SH_BIGSUR || SOLUTION_ENGINE || \
445 SH_7751_SOLUTION_ENGINE || SH_7300_SOLUTION_ENGINE || \
446 SH_73180_SOLUTION_ENGINE || SH_SOLUTION_ENGINE || \
447 SH_RTS7751R2D || SH_SH4202_MICRODEV || SH_LANDISK 414 SH_RTS7751R2D || SH_SH4202_MICRODEV || SH_LANDISK
448 help 415 help
449 Use the power-on LED on your machine as a load meter. The exact 416 Use the power-on LED on your machine as a load meter. The exact
@@ -459,6 +426,8 @@ config ISA_DMA_API
459 426
460menu "Kernel features" 427menu "Kernel features"
461 428
429source kernel/Kconfig.hz
430
462config KEXEC 431config KEXEC
463 bool "kexec system call (EXPERIMENTAL)" 432 bool "kexec system call (EXPERIMENTAL)"
464 depends on EXPERIMENTAL 433 depends on EXPERIMENTAL
@@ -476,10 +445,6 @@ config KEXEC
476 support. As of this writing the exact hardware interface is 445 support. As of this writing the exact hardware interface is
477 strongly in flux, so no good recommendation can be made. 446 strongly in flux, so no good recommendation can be made.
478 447
479config PREEMPT
480 bool "Preemptible Kernel (EXPERIMENTAL)"
481 depends on EXPERIMENTAL
482
483config SMP 448config SMP
484 bool "Symmetric multi-processing support" 449 bool "Symmetric multi-processing support"
485 ---help--- 450 ---help---
@@ -515,6 +480,8 @@ config NR_CPUS
515 This is purely to save memory - each supported CPU adds 480 This is purely to save memory - each supported CPU adds
516 approximately eight kilobytes to the kernel image. 481 approximately eight kilobytes to the kernel image.
517 482
483source "kernel/Kconfig.preempt"
484
518config CPU_HAS_SR_RB 485config CPU_HAS_SR_RB
519 bool "CPU has SR.RB" 486 bool "CPU has SR.RB"
520 depends on CPU_SH3 || CPU_SH4 487 depends on CPU_SH3 || CPU_SH4
@@ -636,6 +603,16 @@ source "fs/Kconfig.binfmt"
636 603
637endmenu 604endmenu
638 605
606menu "Power management options (EXPERIMENTAL)"
607depends on EXPERIMENTAL
608
609source kernel/power/Kconfig
610
611config APM
612 bool "Advanced Power Management Emulation"
613 depends on PM
614endmenu
615
639source "net/Kconfig" 616source "net/Kconfig"
640 617
641source "drivers/Kconfig" 618source "drivers/Kconfig"
diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
index 8fb31ab2c02c..48479e014dac 100644
--- a/arch/sh/Kconfig.debug
+++ b/arch/sh/Kconfig.debug
@@ -30,8 +30,35 @@ config EARLY_PRINTK
30 when the kernel may crash or hang before the serial console is 30 when the kernel may crash or hang before the serial console is
31 initialised. If unsure, say N. 31 initialised. If unsure, say N.
32 32
33config DEBUG_STACKOVERFLOW
34 bool "Check for stack overflows"
35 depends on DEBUG_KERNEL
36 help
37 This option will cause messages to be printed if free stack space
38 drops below a certain limit.
39
40config DEBUG_STACK_USAGE
41 bool "Stack utilization instrumentation"
42 depends on DEBUG_KERNEL
43 help
44 Enables the display of the minimum amount of free stack which each
45 task has ever had available in the sysrq-T and sysrq-P debug output.
46
47 This option will slow down process creation somewhat.
48
49config 4KSTACKS
50 bool "Use 4Kb for kernel stacks instead of 8Kb"
51 depends on DEBUG_KERNEL
52 help
53 If you say Y here the kernel will use a 4Kb stacksize for the
54 kernel stack attached to each process/thread. This facilitates
55 running more threads on a system and also reduces the pressure
56 on the VM subsystem for higher order allocations. This option
57 will also use IRQ stacks to compensate for the reduced stackspace.
58
33config KGDB 59config KGDB
34 bool "Include KGDB kernel debugger" 60 bool "Include KGDB kernel debugger"
61 select FRAME_POINTER
35 help 62 help
36 Include in-kernel hooks for kgdb, the Linux kernel source level 63 Include in-kernel hooks for kgdb, the Linux kernel source level
37 debugger. See <http://kgdb.sourceforge.net/> for more information. 64 debugger. See <http://kgdb.sourceforge.net/> for more information.
@@ -112,13 +139,4 @@ endchoice
112 139
113endmenu 140endmenu
114 141
115config FRAME_POINTER
116 bool "Compile the kernel with frame pointers"
117 default y if KGDB
118 help
119 If you say Y here the resulting kernel image will be slightly larger
120 and slower, but it will give very useful debugging information.
121 If you don't debug the kernel, you can say N, but we may not be able
122 to solve problems without frame pointers.
123
124endmenu 142endmenu
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index e467a450662b..26d62ff51a64 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -18,11 +18,13 @@ cflags-y := -mb
18cflags-$(CONFIG_CPU_LITTLE_ENDIAN) := -ml 18cflags-$(CONFIG_CPU_LITTLE_ENDIAN) := -ml
19 19
20isa-y := any 20isa-y := any
21isa-$(CONFIG_SH_DSP) := sh
21isa-$(CONFIG_CPU_SH2) := sh2 22isa-$(CONFIG_CPU_SH2) := sh2
23isa-$(CONFIG_CPU_SH2A) := sh2a
22isa-$(CONFIG_CPU_SH3) := sh3 24isa-$(CONFIG_CPU_SH3) := sh3
23isa-$(CONFIG_CPU_SH4) := sh4 25isa-$(CONFIG_CPU_SH4) := sh4
24isa-$(CONFIG_CPU_SH4A) := sh4a 26isa-$(CONFIG_CPU_SH4A) := sh4a
25isa-$(CONFIG_CPU_SH2A) := sh2a 27isa-$(CONFIG_CPU_SH4AL_DSP) := sh4al
26 28
27isa-$(CONFIG_SH_DSP) := $(isa-y)-dsp 29isa-$(CONFIG_SH_DSP) := $(isa-y)-dsp
28 30
@@ -30,9 +32,11 @@ ifndef CONFIG_MMU
30isa-y := $(isa-y)-nommu 32isa-y := $(isa-y)-nommu
31endif 33endif
32 34
35ifndef CONFIG_SH_DSP
33ifndef CONFIG_SH_FPU 36ifndef CONFIG_SH_FPU
34isa-y := $(isa-y)-nofpu 37isa-y := $(isa-y)-nofpu
35endif 38endif
39endif
36 40
37cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) 41cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
38 42
@@ -79,24 +83,19 @@ head-y := arch/sh/kernel/head.o arch/sh/kernel/init_task.o
79LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) 83LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
80 84
81core-y += arch/sh/kernel/ arch/sh/mm/ 85core-y += arch/sh/kernel/ arch/sh/mm/
86core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
82 87
83# Boards 88# Boards
84machdir-$(CONFIG_SH_SOLUTION_ENGINE) := se/770x 89machdir-$(CONFIG_SH_SOLUTION_ENGINE) := se/770x
85machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE) := se/7751 90machdir-$(CONFIG_SH_7751_SOLUTION_ENGINE) := se/7751
86machdir-$(CONFIG_SH_7300_SOLUTION_ENGINE) := se/7300 91machdir-$(CONFIG_SH_7300_SOLUTION_ENGINE) := se/7300
92machdir-$(CONFIG_SH_7343_SOLUTION_ENGINE) := se/7343
87machdir-$(CONFIG_SH_73180_SOLUTION_ENGINE) := se/73180 93machdir-$(CONFIG_SH_73180_SOLUTION_ENGINE) := se/73180
88machdir-$(CONFIG_SH_STB1_HARP) := harp
89machdir-$(CONFIG_SH_STB1_OVERDRIVE) := overdrive
90machdir-$(CONFIG_SH_HP6XX) := hp6xx 94machdir-$(CONFIG_SH_HP6XX) := hp6xx
91machdir-$(CONFIG_SH_CQREEK) := cqreek
92machdir-$(CONFIG_SH_DMIDA) := dmida
93machdir-$(CONFIG_SH_EC3104) := ec3104 95machdir-$(CONFIG_SH_EC3104) := ec3104
94machdir-$(CONFIG_SH_SATURN) := saturn 96machdir-$(CONFIG_SH_SATURN) := saturn
95machdir-$(CONFIG_SH_DREAMCAST) := dreamcast 97machdir-$(CONFIG_SH_DREAMCAST) := dreamcast
96machdir-$(CONFIG_SH_CAT68701) := cat68701
97machdir-$(CONFIG_SH_BIGSUR) := bigsur 98machdir-$(CONFIG_SH_BIGSUR) := bigsur
98machdir-$(CONFIG_SH_SH2000) := sh2000
99machdir-$(CONFIG_SH_ADX) := adx
100machdir-$(CONFIG_SH_MPC1211) := mpc1211 99machdir-$(CONFIG_SH_MPC1211) := mpc1211
101machdir-$(CONFIG_SH_SH03) := sh03 100machdir-$(CONFIG_SH_SH03) := sh03
102machdir-$(CONFIG_SH_SECUREEDGE5410) := snapgear 101machdir-$(CONFIG_SH_SECUREEDGE5410) := snapgear
@@ -104,16 +103,16 @@ machdir-$(CONFIG_SH_HS7751RVOIP) := renesas/hs7751rvoip
104machdir-$(CONFIG_SH_RTS7751R2D) := renesas/rts7751r2d 103machdir-$(CONFIG_SH_RTS7751R2D) := renesas/rts7751r2d
105machdir-$(CONFIG_SH_7751_SYSTEMH) := renesas/systemh 104machdir-$(CONFIG_SH_7751_SYSTEMH) := renesas/systemh
106machdir-$(CONFIG_SH_EDOSK7705) := renesas/edosk7705 105machdir-$(CONFIG_SH_EDOSK7705) := renesas/edosk7705
106machdir-$(CONFIG_SH_R7780RP) := renesas/r7780rp
107machdir-$(CONFIG_SH_7710VOIPGW) := renesas/sh7710voipgw
107machdir-$(CONFIG_SH_SH4202_MICRODEV) := superh/microdev 108machdir-$(CONFIG_SH_SH4202_MICRODEV) := superh/microdev
109machdir-$(CONFIG_SH_LANDISK) := landisk
110machdir-$(CONFIG_SH_TITAN) := titan
111machdir-$(CONFIG_SH_SHMIN) := shmin
108machdir-$(CONFIG_SH_UNKNOWN) := unknown 112machdir-$(CONFIG_SH_UNKNOWN) := unknown
109 113
110incdir-y := $(notdir $(machdir-y)) 114incdir-y := $(notdir $(machdir-y))
111 115incdir-$(CONFIG_SH_HP6XX) := hp6xx
112incdir-$(CONFIG_SH_SOLUTION_ENGINE) := se
113incdir-$(CONFIG_SH_7751_SOLUTION_ENGINE) := se7751
114incdir-$(CONFIG_SH_7300_SOLUTION_ENGINE) := se7300
115incdir-$(CONFIG_SH_73180_SOLUTION_ENGINE) := se73180
116incdir-$(CONFIG_SH_HP600) := hp6xx
117 116
118ifneq ($(machdir-y),) 117ifneq ($(machdir-y),)
119core-y += arch/sh/boards/$(machdir-y)/ 118core-y += arch/sh/boards/$(machdir-y)/
@@ -137,17 +136,14 @@ boot := arch/sh/boot
137 136
138CPPFLAGS_vmlinux.lds := -traditional 137CPPFLAGS_vmlinux.lds := -traditional
139 138
140ifneq ($(KBUILD_SRC),)
141incdir-prefix := $(srctree)/include/asm-sh/ 139incdir-prefix := $(srctree)/include/asm-sh/
142else
143incdir-prefix :=
144endif
145 140
146# Update machine arch and proc symlinks if something which affects 141# Update machine arch and proc symlinks if something which affects
147# them changed. We use .arch and .mach to indicate when they were 142# them changed. We use .arch and .mach to indicate when they were
148# updated last, otherwise make uses the target directory mtime. 143# updated last, otherwise make uses the target directory mtime.
149 144
150include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/auto.conf 145include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) \
146 include/config/auto.conf FORCE
151 @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)' 147 @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)'
152 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi 148 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
153 $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu 149 $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu
@@ -157,7 +153,8 @@ include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/auto.conf
157# don't, just reference the parent directory so the semantics are 153# don't, just reference the parent directory so the semantics are
158# kept roughly the same. 154# kept roughly the same.
159 155
160include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/auto.conf 156include/asm-sh/.mach: $(wildcard include/config/sh/*.h) \
157 include/config/auto.conf FORCE
161 @echo -n ' SYMLINK include/asm-sh/mach -> ' 158 @echo -n ' SYMLINK include/asm-sh/mach -> '
162 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi 159 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
163 $(Q)if [ -d $(incdir-prefix)$(incdir-y) ]; then \ 160 $(Q)if [ -d $(incdir-prefix)$(incdir-y) ]; then \
@@ -170,7 +167,7 @@ include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/auto.conf
170 fi 167 fi
171 @touch $@ 168 @touch $@
172 169
173archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach 170archprepare: include/asm-sh/.cpu include/asm-sh/.mach maketools
174 171
175PHONY += maketools FORCE 172PHONY += maketools FORCE
176maketools: include/linux/version.h FORCE 173maketools: include/linux/version.h FORCE
@@ -191,4 +188,3 @@ CLEAN_FILES += include/asm-sh/machtypes.h
191define archhelp 188define archhelp
192 @echo ' zImage - Compressed kernel image (arch/sh/boot/zImage)' 189 @echo ' zImage - Compressed kernel image (arch/sh/boot/zImage)'
193endef 190endef
194
diff --git a/arch/sh/boards/adx/Makefile b/arch/sh/boards/adx/Makefile
deleted file mode 100644
index 5b1c531b3991..000000000000
--- a/arch/sh/boards/adx/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for ADX boards
3#
4
5obj-y := setup.o irq.o irq_maskreq.o
6
diff --git a/arch/sh/boards/adx/irq.c b/arch/sh/boards/adx/irq.c
deleted file mode 100644
index c6ca409dff98..000000000000
--- a/arch/sh/boards/adx/irq.c
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * linux/arch/sh/boards/adx/irq.c
3 *
4 * Copyright (C) 2001 A&D Co., Ltd.
5 *
6 * I/O routine and setup routines for A&D ADX Board
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 *
12 */
13
14#include <asm/irq.h>
15
16void init_adx_IRQ(void)
17{
18 int i;
19
20/* printk("init_adx_IRQ()\n");*/
21 /* setup irq_mask_register */
22 irq_mask_register = (unsigned short *)0xa6000008;
23
24 /* cover all external interrupt area by maskreg_irq_type
25 * (Actually, irq15 doesn't exist)
26 */
27 for (i = 0; i < 16; i++) {
28 make_maskreg_irq(i);
29 disable_irq(i);
30 }
31}
diff --git a/arch/sh/boards/adx/setup.c b/arch/sh/boards/adx/setup.c
deleted file mode 100644
index 4938d9592343..000000000000
--- a/arch/sh/boards/adx/setup.c
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * linux/arch/sh/board/adx/setup.c
3 *
4 * Copyright (C) 2001 A&D Co., Ltd.
5 *
6 * I/O routine and setup routines for A&D ADX Board
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 *
12 */
13
14#include <asm/machvec.h>
15#include <linux/module.h>
16
17extern void init_adx_IRQ(void);
18extern void *cf_io_base;
19
20const char *get_system_type(void)
21{
22 return "A&D ADX";
23}
24
25unsigned long adx_isa_port2addr(unsigned long offset)
26{
27 /* CompactFlash (IDE) */
28 if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset == 0x3f6)) {
29 return (unsigned long)cf_io_base + offset;
30 }
31
32 /* eth0 */
33 if ((offset >= 0x300) && (offset <= 0x30f)) {
34 return 0xa5000000 + offset; /* COMM BOARD (AREA1) */
35 }
36
37 return offset + 0xb0000000; /* IOBUS (AREA 4)*/
38}
39
40/*
41 * The Machine Vector
42 */
43
44struct sh_machine_vector mv_adx __initmv = {
45 .mv_nr_irqs = 48,
46 .mv_isa_port2addr = adx_isa_port2addr,
47 .mv_init_irq = init_adx_IRQ,
48};
49ALIAS_MV(adx)
50
51int __init platform_setup(void)
52{
53 /* Nothing to see here .. */
54 return 0;
55}
56
diff --git a/arch/sh/boards/bigsur/irq.c b/arch/sh/boards/bigsur/irq.c
index ac946a2201c7..1ab04da36382 100644
--- a/arch/sh/boards/bigsur/irq.c
+++ b/arch/sh/boards/bigsur/irq.c
@@ -19,6 +19,7 @@
19 * IRQ functions for a Hitachi Big Sur Evaluation Board. 19 * IRQ functions for a Hitachi Big Sur Evaluation Board.
20 * 20 *
21 */ 21 */
22#undef DEBUG
22 23
23#include <linux/sched.h> 24#include <linux/sched.h>
24#include <linux/module.h> 25#include <linux/module.h>
@@ -41,10 +42,8 @@
41#undef BIGSUR_DEBUG 42#undef BIGSUR_DEBUG
42 43
43#ifdef BIGSUR_DEBUG 44#ifdef BIGSUR_DEBUG
44#define DPRINTK(args...) printk(args)
45#define DIPRINTK(n, args...) if (BIGSUR_DEBUG>(n)) printk(args) 45#define DIPRINTK(n, args...) if (BIGSUR_DEBUG>(n)) printk(args)
46#else 46#else
47#define DPRINTK(args...)
48#define DIPRINTK(n, args...) 47#define DIPRINTK(n, args...)
49#endif /* BIGSUR_DEBUG */ 48#endif /* BIGSUR_DEBUG */
50 49
@@ -60,45 +59,39 @@ extern int hd64465_irq_demux(int irq);
60/* Level 1 IRQ routines */ 59/* Level 1 IRQ routines */
61static void disable_bigsur_l1irq(unsigned int irq) 60static void disable_bigsur_l1irq(unsigned int irq)
62{ 61{
63 unsigned long flags;
64 unsigned char mask; 62 unsigned char mask;
65 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0; 63 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
66 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) ); 64 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) );
67 65
68 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) { 66 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
69 DPRINTK("Disable L1 IRQ %d\n", irq); 67 pr_debug("Disable L1 IRQ %d\n", irq);
70 DIPRINTK(2,"disable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n", 68 DIPRINTK(2,"disable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
71 mask_port, bit); 69 mask_port, bit);
72 local_irq_save(flags);
73 70
74 /* Disable IRQ - set mask bit */ 71 /* Disable IRQ - set mask bit */
75 mask = inb(mask_port) | bit; 72 mask = inb(mask_port) | bit;
76 outb(mask, mask_port); 73 outb(mask, mask_port);
77 local_irq_restore(flags);
78 return; 74 return;
79 } 75 }
80 DPRINTK("disable_bigsur_l1irq: Invalid IRQ %d\n", irq); 76 pr_debug("disable_bigsur_l1irq: Invalid IRQ %d\n", irq);
81} 77}
82 78
83static void enable_bigsur_l1irq(unsigned int irq) 79static void enable_bigsur_l1irq(unsigned int irq)
84{ 80{
85 unsigned long flags;
86 unsigned char mask; 81 unsigned char mask;
87 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0; 82 unsigned int mask_port = ((irq - BIGSUR_IRQ_LOW)/8) ? BIGSUR_IRLMR1 : BIGSUR_IRLMR0;
88 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) ); 83 unsigned char bit = (1 << ((irq - MGATE_IRQ_LOW)%8) );
89 84
90 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) { 85 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
91 DPRINTK("Enable L1 IRQ %d\n", irq); 86 pr_debug("Enable L1 IRQ %d\n", irq);
92 DIPRINTK(2,"enable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n", 87 DIPRINTK(2,"enable_bigsur_l1irq: IMR=0x%08x mask=0x%x\n",
93 mask_port, bit); 88 mask_port, bit);
94 local_irq_save(flags);
95 /* Enable L1 IRQ - clear mask bit */ 89 /* Enable L1 IRQ - clear mask bit */
96 mask = inb(mask_port) & ~bit; 90 mask = inb(mask_port) & ~bit;
97 outb(mask, mask_port); 91 outb(mask, mask_port);
98 local_irq_restore(flags);
99 return; 92 return;
100 } 93 }
101 DPRINTK("enable_bigsur_l1irq: Invalid IRQ %d\n", irq); 94 pr_debug("enable_bigsur_l1irq: Invalid IRQ %d\n", irq);
102} 95}
103 96
104 97
@@ -126,51 +119,45 @@ static const u32 imr_offset = BIGSUR_IMR0 - BIGSUR_IMR1;
126/* Level 2 IRQ routines */ 119/* Level 2 IRQ routines */
127static void disable_bigsur_l2irq(unsigned int irq) 120static void disable_bigsur_l2irq(unsigned int irq)
128{ 121{
129 unsigned long flags;
130 unsigned char mask; 122 unsigned char mask;
131 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8); 123 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
132 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset; 124 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
133 125
134 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) { 126 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
135 DPRINTK("Disable L2 IRQ %d\n", irq); 127 pr_debug("Disable L2 IRQ %d\n", irq);
136 DIPRINTK(2,"disable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n", 128 DIPRINTK(2,"disable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
137 mask_port, bit); 129 mask_port, bit);
138 local_irq_save(flags);
139 130
140 /* Disable L2 IRQ - set mask bit */ 131 /* Disable L2 IRQ - set mask bit */
141 mask = inb(mask_port) | bit; 132 mask = inb(mask_port) | bit;
142 outb(mask, mask_port); 133 outb(mask, mask_port);
143 local_irq_restore(flags);
144 return; 134 return;
145 } 135 }
146 DPRINTK("disable_bigsur_l2irq: Invalid IRQ %d\n", irq); 136 pr_debug("disable_bigsur_l2irq: Invalid IRQ %d\n", irq);
147} 137}
148 138
149static void enable_bigsur_l2irq(unsigned int irq) 139static void enable_bigsur_l2irq(unsigned int irq)
150{ 140{
151 unsigned long flags;
152 unsigned char mask; 141 unsigned char mask;
153 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8); 142 unsigned char bit = 1 << ((irq-BIGSUR_2NDLVL_IRQ_LOW)%8);
154 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset; 143 unsigned int mask_port = imr_base - REG_NUM(irq)*imr_offset;
155 144
156 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) { 145 if(irq >= BIGSUR_2NDLVL_IRQ_LOW && irq < BIGSUR_2NDLVL_IRQ_HIGH) {
157 DPRINTK("Enable L2 IRQ %d\n", irq); 146 pr_debug("Enable L2 IRQ %d\n", irq);
158 DIPRINTK(2,"enable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n", 147 DIPRINTK(2,"enable_bigsur_l2irq: IMR=0x%08x mask=0x%x\n",
159 mask_port, bit); 148 mask_port, bit);
160 local_irq_save(flags);
161 149
162 /* Enable L2 IRQ - clear mask bit */ 150 /* Enable L2 IRQ - clear mask bit */
163 mask = inb(mask_port) & ~bit; 151 mask = inb(mask_port) & ~bit;
164 outb(mask, mask_port); 152 outb(mask, mask_port);
165 local_irq_restore(flags);
166 return; 153 return;
167 } 154 }
168 DPRINTK("enable_bigsur_l2irq: Invalid IRQ %d\n", irq); 155 pr_debug("enable_bigsur_l2irq: Invalid IRQ %d\n", irq);
169} 156}
170 157
171static void mask_and_ack_bigsur(unsigned int irq) 158static void mask_and_ack_bigsur(unsigned int irq)
172{ 159{
173 DPRINTK("mask_and_ack_bigsur IRQ %d\n", irq); 160 pr_debug("mask_and_ack_bigsur IRQ %d\n", irq);
174 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) 161 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
175 disable_bigsur_l1irq(irq); 162 disable_bigsur_l1irq(irq);
176 else 163 else
@@ -179,7 +166,7 @@ static void mask_and_ack_bigsur(unsigned int irq)
179 166
180static void end_bigsur_irq(unsigned int irq) 167static void end_bigsur_irq(unsigned int irq)
181{ 168{
182 DPRINTK("end_bigsur_irq IRQ %d\n", irq); 169 pr_debug("end_bigsur_irq IRQ %d\n", irq);
183 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) { 170 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) {
184 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) 171 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
185 enable_bigsur_l1irq(irq); 172 enable_bigsur_l1irq(irq);
@@ -193,7 +180,7 @@ static unsigned int startup_bigsur_irq(unsigned int irq)
193 u8 mask; 180 u8 mask;
194 u32 reg; 181 u32 reg;
195 182
196 DPRINTK("startup_bigsur_irq IRQ %d\n", irq); 183 pr_debug("startup_bigsur_irq IRQ %d\n", irq);
197 184
198 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) { 185 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) {
199 /* Enable the L1 IRQ */ 186 /* Enable the L1 IRQ */
@@ -218,7 +205,7 @@ static unsigned int startup_bigsur_irq(unsigned int irq)
218 205
219static void shutdown_bigsur_irq(unsigned int irq) 206static void shutdown_bigsur_irq(unsigned int irq)
220{ 207{
221 DPRINTK("shutdown_bigsur_irq IRQ %d\n", irq); 208 pr_debug("shutdown_bigsur_irq IRQ %d\n", irq);
222 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH) 209 if(irq >= BIGSUR_IRQ_LOW && irq < BIGSUR_IRQ_HIGH)
223 disable_bigsur_l1irq(irq); 210 disable_bigsur_l1irq(irq);
224 else 211 else
@@ -260,7 +247,7 @@ static void make_bigsur_l1isr(unsigned int irq) {
260 disable_bigsur_l1irq(irq); 247 disable_bigsur_l1irq(irq);
261 return; 248 return;
262 } 249 }
263 DPRINTK("make_bigsur_l1isr: bad irq, %d\n", irq); 250 pr_debug("make_bigsur_l1isr: bad irq, %d\n", irq);
264 return; 251 return;
265} 252}
266 253
@@ -277,7 +264,7 @@ static void make_bigsur_l2isr(unsigned int irq) {
277 disable_bigsur_l2irq(irq); 264 disable_bigsur_l2irq(irq);
278 return; 265 return;
279 } 266 }
280 DPRINTK("make_bigsur_l2isr: bad irq, %d\n", irq); 267 pr_debug("make_bigsur_l2isr: bad irq, %d\n", irq);
281 return; 268 return;
282} 269}
283 270
diff --git a/arch/sh/boards/bigsur/setup.c b/arch/sh/boards/bigsur/setup.c
index dfeede9da50f..9711c20fc9e4 100644
--- a/arch/sh/boards/bigsur/setup.c
+++ b/arch/sh/boards/bigsur/setup.c
@@ -41,31 +41,7 @@
41// Big Sur Init Routines 41// Big Sur Init Routines
42/*===========================================================*/ 42/*===========================================================*/
43 43
44const char *get_system_type(void) 44static void __init bigsur_setup(char **cmdline_p)
45{
46 return "Big Sur";
47}
48
49/*
50 * The Machine Vector
51 */
52extern void heartbeat_bigsur(void);
53extern void init_bigsur_IRQ(void);
54
55struct sh_machine_vector mv_bigsur __initmv = {
56 .mv_nr_irqs = NR_IRQS, // Defined in <asm/irq.h>
57
58 .mv_isa_port2addr = bigsur_isa_port2addr,
59 .mv_irq_demux = bigsur_irq_demux,
60
61 .mv_init_irq = init_bigsur_IRQ,
62#ifdef CONFIG_HEARTBEAT
63 .mv_heartbeat = heartbeat_bigsur,
64#endif
65};
66ALIAS_MV(bigsur)
67
68int __init platform_setup(void)
69{ 45{
70 /* Mask all 2nd level IRQ's */ 46 /* Mask all 2nd level IRQ's */
71 outb(-1,BIGSUR_IMR0); 47 outb(-1,BIGSUR_IMR0);
@@ -89,7 +65,24 @@ int __init platform_setup(void)
89 outw(1, BIGSUR_ETHR+0xe); 65 outw(1, BIGSUR_ETHR+0xe);
90 /* set the IO port to BIGSUR_ETHER_IOPORT */ 66 /* set the IO port to BIGSUR_ETHER_IOPORT */
91 outw(BIGSUR_ETHER_IOPORT<<3, BIGSUR_ETHR+0x2); 67 outw(BIGSUR_ETHER_IOPORT<<3, BIGSUR_ETHR+0x2);
92
93 return 0;
94} 68}
95 69
70/*
71 * The Machine Vector
72 */
73extern void heartbeat_bigsur(void);
74extern void init_bigsur_IRQ(void);
75
76struct sh_machine_vector mv_bigsur __initmv = {
77 .mv_name = "Big Sur",
78 .mv_setup = bigsur_setup,
79
80 .mv_isa_port2addr = bigsur_isa_port2addr,
81 .mv_irq_demux = bigsur_irq_demux,
82
83 .mv_init_irq = init_bigsur_IRQ,
84#ifdef CONFIG_HEARTBEAT
85 .mv_heartbeat = heartbeat_bigsur,
86#endif
87};
88ALIAS_MV(bigsur)
diff --git a/arch/sh/boards/cat68701/Makefile b/arch/sh/boards/cat68701/Makefile
deleted file mode 100644
index 52c1de0a6dfd..000000000000
--- a/arch/sh/boards/cat68701/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for the CAT-68701 specific parts of the kernel
3#
4
5obj-y := setup.o irq.o
6
diff --git a/arch/sh/boards/cat68701/irq.c b/arch/sh/boards/cat68701/irq.c
deleted file mode 100644
index f9a6d185fb8b..000000000000
--- a/arch/sh/boards/cat68701/irq.c
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * linux/arch/sh/boards/cat68701/irq.c
3 *
4 * Copyright (C) 2000 Niibe Yutaka
5 * 2001 Yutaro Ebihara
6 *
7 * Setup routines for A-ONE Corp CAT-68701 SH7708 Board
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 *
13 */
14
15#include <asm/irq.h>
16
17int cat68701_irq_demux(int irq)
18{
19 if(irq==13) return 14;
20 if(irq==7) return 10;
21 return irq;
22}
23
24void init_cat68701_IRQ()
25{
26 make_imask_irq(10);
27 make_imask_irq(14);
28}
diff --git a/arch/sh/boards/cat68701/setup.c b/arch/sh/boards/cat68701/setup.c
deleted file mode 100644
index 90e5175df227..000000000000
--- a/arch/sh/boards/cat68701/setup.c
+++ /dev/null
@@ -1,85 +0,0 @@
1/*
2 * linux/arch/sh/boards/cat68701/setup.c
3 *
4 * Copyright (C) 2000 Niibe Yutaka
5 * 2001 Yutaro Ebihara
6 *
7 * Setup routines for A-ONE Corp CAT-68701 SH7708 Board
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 *
13 */
14
15#include <asm/io.h>
16#include <asm/machvec.h>
17#include <asm/mach/io.h>
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/sched.h>
21
22const char *get_system_type(void)
23{
24 return "CAT-68701";
25}
26
27#ifdef CONFIG_HEARTBEAT
28void heartbeat_cat68701()
29{
30 static unsigned int cnt = 0, period = 0 , bit = 0;
31 cnt += 1;
32 if (cnt < period) {
33 return;
34 }
35 cnt = 0;
36
37 /* Go through the points (roughly!):
38 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
39 */
40 period = 110 - ( (300<<FSHIFT)/
41 ((avenrun[0]/5) + (3<<FSHIFT)) );
42
43 if(bit){ bit=0; }else{ bit=1; }
44 outw(bit<<15,0x3fe);
45}
46#endif /* CONFIG_HEARTBEAT */
47
48unsigned long cat68701_isa_port2addr(unsigned long offset)
49{
50 /* CompactFlash (IDE) */
51 if (((offset >= 0x1f0) && (offset <= 0x1f7)) || (offset==0x3f6))
52 return 0xba000000 + offset;
53
54 /* INPUT PORT */
55 if ((offset >= 0x3fc) && (offset <= 0x3fd))
56 return 0xb4007000 + offset;
57
58 /* OUTPUT PORT */
59 if ((offset >= 0x3fe) && (offset <= 0x3ff))
60 return 0xb4007400 + offset;
61
62 return offset + 0xb4000000; /* other I/O (EREA 5)*/
63}
64
65/*
66 * The Machine Vector
67 */
68
69struct sh_machine_vector mv_cat68701 __initmv = {
70 .mv_nr_irqs = 32,
71 .mv_isa_port2addr = cat68701_isa_port2addr,
72 .mv_irq_demux = cat68701_irq_demux,
73
74 .mv_init_irq = init_cat68701_IRQ,
75#ifdef CONFIG_HEARTBEAT
76 .mv_heartbeat = heartbeat_cat68701,
77#endif
78};
79ALIAS_MV(cat68701)
80
81int __init platform_setup(void)
82{
83 /* dummy read erea5 (CS8900A) */
84}
85
diff --git a/arch/sh/boards/cqreek/Makefile b/arch/sh/boards/cqreek/Makefile
deleted file mode 100644
index 1a788a85eba3..000000000000
--- a/arch/sh/boards/cqreek/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for the CqREEK specific parts of the kernel
3#
4
5obj-y := setup.o irq.o
6
diff --git a/arch/sh/boards/cqreek/irq.c b/arch/sh/boards/cqreek/irq.c
deleted file mode 100644
index 2955adc52310..000000000000
--- a/arch/sh/boards/cqreek/irq.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/* $Id: irq.c,v 1.1.2.4 2002/11/04 20:33:56 lethal Exp $
2 *
3 * arch/sh/boards/cqreek/irq.c
4 *
5 * Copyright (C) 2000 Niibe Yutaka
6 *
7 * CqREEK IDE/ISA Bridge Support.
8 *
9 */
10
11#include <linux/irq.h>
12#include <linux/init.h>
13
14#include <asm/cqreek/cqreek.h>
15#include <asm/io.h>
16#include <asm/io_generic.h>
17#include <asm/irq.h>
18#include <asm/machvec.h>
19#include <asm/machvec_init.h>
20#include <asm/rtc.h>
21
22struct cqreek_irq_data {
23 unsigned short mask_port; /* Port of Interrupt Mask Register */
24 unsigned short stat_port; /* Port of Interrupt Status Register */
25 unsigned short bit; /* Value of the bit */
26};
27static struct cqreek_irq_data cqreek_irq_data[NR_IRQS];
28
29static void disable_cqreek_irq(unsigned int irq)
30{
31 unsigned long flags;
32 unsigned short mask;
33 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
34 unsigned short bit = cqreek_irq_data[irq].bit;
35
36 local_irq_save(flags);
37 /* Disable IRQ */
38 mask = inw(mask_port) & ~bit;
39 outw_p(mask, mask_port);
40 local_irq_restore(flags);
41}
42
43static void enable_cqreek_irq(unsigned int irq)
44{
45 unsigned long flags;
46 unsigned short mask;
47 unsigned short mask_port = cqreek_irq_data[irq].mask_port;
48 unsigned short bit = cqreek_irq_data[irq].bit;
49
50 local_irq_save(flags);
51 /* Enable IRQ */
52 mask = inw(mask_port) | bit;
53 outw_p(mask, mask_port);
54 local_irq_restore(flags);
55}
56
57static void mask_and_ack_cqreek(unsigned int irq)
58{
59 unsigned short stat_port = cqreek_irq_data[irq].stat_port;
60 unsigned short bit = cqreek_irq_data[irq].bit;
61
62 disable_cqreek_irq(irq);
63 /* Clear IRQ (it might be edge IRQ) */
64 inw(stat_port);
65 outw_p(bit, stat_port);
66}
67
68static void end_cqreek_irq(unsigned int irq)
69{
70 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
71 enable_cqreek_irq(irq);
72}
73
74static unsigned int startup_cqreek_irq(unsigned int irq)
75{
76 enable_cqreek_irq(irq);
77 return 0;
78}
79
80static void shutdown_cqreek_irq(unsigned int irq)
81{
82 disable_cqreek_irq(irq);
83}
84
85static struct hw_interrupt_type cqreek_irq_type = {
86 .typename = "CqREEK-IRQ",
87 .startup = startup_cqreek_irq,
88 .shutdown = shutdown_cqreek_irq,
89 .enable = enable_cqreek_irq,
90 .disable = disable_cqreek_irq,
91 .ack = mask_and_ack_cqreek,
92 .end = end_cqreek_irq
93};
94
95int cqreek_has_ide, cqreek_has_isa;
96
97/* XXX: This is just for test for my NE2000 ISA board
98 What we really need is virtualized IRQ and demultiplexer like HP600 port */
99void __init init_cqreek_IRQ(void)
100{
101 if (cqreek_has_ide) {
102 cqreek_irq_data[14].mask_port = BRIDGE_IDE_INTR_MASK;
103 cqreek_irq_data[14].stat_port = BRIDGE_IDE_INTR_STAT;
104 cqreek_irq_data[14].bit = 1;
105
106 irq_desc[14].chip = &cqreek_irq_type;
107 irq_desc[14].status = IRQ_DISABLED;
108 irq_desc[14].action = 0;
109 irq_desc[14].depth = 1;
110
111 disable_cqreek_irq(14);
112 }
113
114 if (cqreek_has_isa) {
115 cqreek_irq_data[10].mask_port = BRIDGE_ISA_INTR_MASK;
116 cqreek_irq_data[10].stat_port = BRIDGE_ISA_INTR_STAT;
117 cqreek_irq_data[10].bit = (1 << 10);
118
119 /* XXX: Err... we may need demultiplexer for ISA irq... */
120 irq_desc[10].chip = &cqreek_irq_type;
121 irq_desc[10].status = IRQ_DISABLED;
122 irq_desc[10].action = 0;
123 irq_desc[10].depth = 1;
124
125 disable_cqreek_irq(10);
126 }
127}
128
diff --git a/arch/sh/boards/cqreek/setup.c b/arch/sh/boards/cqreek/setup.c
deleted file mode 100644
index eff4ed93599f..000000000000
--- a/arch/sh/boards/cqreek/setup.c
+++ /dev/null
@@ -1,100 +0,0 @@
1/* $Id: setup.c,v 1.5 2003/08/04 01:51:58 lethal Exp $
2 *
3 * arch/sh/kernel/setup_cqreek.c
4 *
5 * Copyright (C) 2000 Niibe Yutaka
6 *
7 * CqREEK IDE/ISA Bridge Support.
8 *
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/irq.h>
14
15#include <asm/mach/cqreek.h>
16#include <asm/machvec.h>
17#include <asm/io.h>
18#include <asm/io_generic.h>
19#include <asm/irq.h>
20#include <asm/rtc.h>
21
22#define IDE_OFFSET 0xA4000000UL
23#define ISA_OFFSET 0xA4A00000UL
24
25const char *get_system_type(void)
26{
27 return "CqREEK";
28}
29
30static unsigned long cqreek_port2addr(unsigned long port)
31{
32 if (0x0000<=port && port<=0x0040)
33 return IDE_OFFSET + port;
34 if ((0x01f0<=port && port<=0x01f7) || port == 0x03f6)
35 return IDE_OFFSET + port;
36
37 return ISA_OFFSET + port;
38}
39
40/*
41 * The Machine Vector
42 */
43struct sh_machine_vector mv_cqreek __initmv = {
44#if defined(CONFIG_CPU_SH4)
45 .mv_nr_irqs = 48,
46#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
47 .mv_nr_irqs = 32,
48#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
49 .mv_nr_irqs = 61,
50#endif
51
52 .mv_init_irq = init_cqreek_IRQ,
53
54 .mv_isa_port2addr = cqreek_port2addr,
55};
56ALIAS_MV(cqreek)
57
58/*
59 * Initialize the board
60 */
61void __init platform_setup(void)
62{
63 int i;
64/* udelay is not available at setup time yet... */
65#define DELAY() do {for (i=0; i<10000; i++) ctrl_inw(0xa0000000);} while(0)
66
67 if ((inw (BRIDGE_FEATURE) & 1)) { /* We have IDE interface */
68 outw_p(0, BRIDGE_IDE_INTR_LVL);
69 outw_p(0, BRIDGE_IDE_INTR_MASK);
70
71 outw_p(0, BRIDGE_IDE_CTRL);
72 DELAY();
73
74 outw_p(0x8000, BRIDGE_IDE_CTRL);
75 DELAY();
76
77 outw_p(0xffff, BRIDGE_IDE_INTR_STAT); /* Clear interrupt status */
78 outw_p(0x0f-14, BRIDGE_IDE_INTR_LVL); /* Use 14 IPR */
79 outw_p(1, BRIDGE_IDE_INTR_MASK); /* Enable interrupt */
80 cqreek_has_ide=1;
81 }
82
83 if ((inw (BRIDGE_FEATURE) & 2)) { /* We have ISA interface */
84 outw_p(0, BRIDGE_ISA_INTR_LVL);
85 outw_p(0, BRIDGE_ISA_INTR_MASK);
86
87 outw_p(0, BRIDGE_ISA_CTRL);
88 DELAY();
89 outw_p(0x8000, BRIDGE_ISA_CTRL);
90 DELAY();
91
92 outw_p(0xffff, BRIDGE_ISA_INTR_STAT); /* Clear interrupt status */
93 outw_p(0x0f-10, BRIDGE_ISA_INTR_LVL); /* Use 10 IPR */
94 outw_p(0xfff8, BRIDGE_ISA_INTR_MASK); /* Enable interrupt */
95 cqreek_has_isa=1;
96 }
97
98 printk(KERN_INFO "CqREEK Setup (IDE=%d, ISA=%d)...done\n", cqreek_has_ide, cqreek_has_isa);
99}
100
diff --git a/arch/sh/boards/dmida/Makefile b/arch/sh/boards/dmida/Makefile
deleted file mode 100644
index 75999aa0a2d9..000000000000
--- a/arch/sh/boards/dmida/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
1#
2# Makefile for the DataMyte Industrial Digital Assistant(tm) specific parts
3# of the kernel
4#
5
6obj-y := mach.o
7
diff --git a/arch/sh/boards/dmida/mach.c b/arch/sh/boards/dmida/mach.c
deleted file mode 100644
index d03a25f989c2..000000000000
--- a/arch/sh/boards/dmida/mach.c
+++ /dev/null
@@ -1,59 +0,0 @@
1/*
2 * linux/arch/sh/boards/dmida/mach.c
3 *
4 * by Greg Banks <gbanks@pocketpenguins.com>
5 * (c) 2000 PocketPenguins Inc
6 *
7 * Derived from mach_hp600.c, which bore the message:
8 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
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 * Machine vector for the DataMyte Industrial Digital Assistant(tm).
14 * See http://www.dmida.com
15 *
16 */
17
18#include <linux/init.h>
19
20#include <asm/machvec.h>
21#include <asm/rtc.h>
22#include <asm/machvec_init.h>
23
24#include <asm/io.h>
25#include <asm/hd64465/hd64465.h>
26#include <asm/irq.h>
27
28/*
29 * The Machine Vector
30 */
31
32struct sh_machine_vector mv_dmida __initmv = {
33 .mv_nr_irqs = HD64465_IRQ_BASE+HD64465_IRQ_NUM,
34
35 .mv_inb = hd64465_inb,
36 .mv_inw = hd64465_inw,
37 .mv_inl = hd64465_inl,
38 .mv_outb = hd64465_outb,
39 .mv_outw = hd64465_outw,
40 .mv_outl = hd64465_outl,
41
42 .mv_inb_p = hd64465_inb_p,
43 .mv_inw_p = hd64465_inw,
44 .mv_inl_p = hd64465_inl,
45 .mv_outb_p = hd64465_outb_p,
46 .mv_outw_p = hd64465_outw,
47 .mv_outl_p = hd64465_outl,
48
49 .mv_insb = hd64465_insb,
50 .mv_insw = hd64465_insw,
51 .mv_insl = hd64465_insl,
52 .mv_outsb = hd64465_outsb,
53 .mv_outsw = hd64465_outsw,
54 .mv_outsl = hd64465_outsl,
55
56 .mv_irq_demux = hd64465_irq_demux,
57};
58ALIAS_MV(dmida)
59
diff --git a/arch/sh/boards/dreamcast/irq.c b/arch/sh/boards/dreamcast/irq.c
index b10a6b11c034..5bf01f86c20c 100644
--- a/arch/sh/boards/dreamcast/irq.c
+++ b/arch/sh/boards/dreamcast/irq.c
@@ -10,7 +10,6 @@
10 */ 10 */
11 11
12#include <linux/irq.h> 12#include <linux/irq.h>
13
14#include <asm/io.h> 13#include <asm/io.h>
15#include <asm/irq.h> 14#include <asm/irq.h>
16#include <asm/dreamcast/sysasic.h> 15#include <asm/dreamcast/sysasic.h>
@@ -26,10 +25,10 @@
26 event. 25 event.
27 26
28 There are three 32-bit ESRs located at 0xa05f8900 - 0xa05f6908. Event 27 There are three 32-bit ESRs located at 0xa05f8900 - 0xa05f6908. Event
29 types can be found in include/asm-sh/dc_sysasic.h. There are three groups 28 types can be found in include/asm-sh/dreamcast/sysasic.h. There are three
30 of EMRs that parallel the ESRs. Each EMR group corresponds to an IRQ, so 29 groups of EMRs that parallel the ESRs. Each EMR group corresponds to an
31 0xa05f6910 - 0xa05f6918 triggers IRQ 13, 0xa05f6920 - 0xa05f6928 triggers 30 IRQ, so 0xa05f6910 - 0xa05f6918 triggers IRQ 13, 0xa05f6920 - 0xa05f6928
32 IRQ 11, and 0xa05f6930 - 0xa05f6938 triggers IRQ 9. 31 triggers IRQ 11, and 0xa05f6930 - 0xa05f6938 triggers IRQ 9.
33 32
34 In the kernel, these events are mapped to virtual IRQs so that drivers can 33 In the kernel, these events are mapped to virtual IRQs so that drivers can
35 respond to them as they would a normal interrupt. In order to keep this 34 respond to them as they would a normal interrupt. In order to keep this
@@ -57,29 +56,23 @@
57/* Disable the hardware event by masking its bit in its EMR */ 56/* Disable the hardware event by masking its bit in its EMR */
58static inline void disable_systemasic_irq(unsigned int irq) 57static inline void disable_systemasic_irq(unsigned int irq)
59{ 58{
60 unsigned long flags;
61 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 59 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
62 __u32 mask; 60 __u32 mask;
63 61
64 local_irq_save(flags);
65 mask = inl(emr); 62 mask = inl(emr);
66 mask &= ~(1 << EVENT_BIT(irq)); 63 mask &= ~(1 << EVENT_BIT(irq));
67 outl(mask, emr); 64 outl(mask, emr);
68 local_irq_restore(flags);
69} 65}
70 66
71/* Enable the hardware event by setting its bit in its EMR */ 67/* Enable the hardware event by setting its bit in its EMR */
72static inline void enable_systemasic_irq(unsigned int irq) 68static inline void enable_systemasic_irq(unsigned int irq)
73{ 69{
74 unsigned long flags;
75 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2); 70 __u32 emr = EMR_BASE + (LEVEL(irq) << 4) + (LEVEL(irq) << 2);
76 __u32 mask; 71 __u32 mask;
77 72
78 local_irq_save(flags);
79 mask = inl(emr); 73 mask = inl(emr);
80 mask |= (1 << EVENT_BIT(irq)); 74 mask |= (1 << EVENT_BIT(irq));
81 outl(mask, emr); 75 outl(mask, emr);
82 local_irq_restore(flags);
83} 76}
84 77
85/* Acknowledge a hardware event by writing its bit back to its ESR */ 78/* Acknowledge a hardware event by writing its bit back to its ESR */
diff --git a/arch/sh/boards/dreamcast/rtc.c b/arch/sh/boards/dreamcast/rtc.c
index 379de1629134..b3a876a3b859 100644
--- a/arch/sh/boards/dreamcast/rtc.c
+++ b/arch/sh/boards/dreamcast/rtc.c
@@ -1,4 +1,5 @@
1/* arch/sh/kernel/rtc-aica.c 1/*
2 * arch/sh/boards/dreamcast/rtc.c
2 * 3 *
3 * Dreamcast AICA RTC routines. 4 * Dreamcast AICA RTC routines.
4 * 5 *
@@ -10,15 +11,12 @@
10 */ 11 */
11 12
12#include <linux/time.h> 13#include <linux/time.h>
13 14#include <asm/rtc.h>
14#include <asm/io.h> 15#include <asm/io.h>
15 16
16extern void (*rtc_get_time)(struct timespec *);
17extern int (*rtc_set_time)(const time_t);
18
19/* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in 17/* The AICA RTC has an Epoch of 1/1/1950, so we must subtract 20 years (in
20 seconds to get the standard Unix Epoch when getting the time, and add 20 18 seconds) to get the standard Unix Epoch when getting the time, and add
21 years when setting the time. */ 19 20 years when setting the time. */
22#define TWENTY_YEARS ((20 * 365LU + 5) * 86400) 20#define TWENTY_YEARS ((20 * 365LU + 5) * 86400)
23 21
24/* The AICA RTC is represented by a 32-bit seconds counter stored in 2 16-bit 22/* The AICA RTC is represented by a 32-bit seconds counter stored in 2 16-bit
@@ -32,7 +30,8 @@ extern int (*rtc_set_time)(const time_t);
32 * 30 *
33 * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch. 31 * Grabs the current RTC seconds counter and adjusts it to the Unix Epoch.
34 */ 32 */
35void aica_rtc_gettimeofday(struct timespec *ts) { 33void aica_rtc_gettimeofday(struct timespec *ts)
34{
36 unsigned long val1, val2; 35 unsigned long val1, val2;
37 36
38 do { 37 do {
@@ -55,7 +54,8 @@ void aica_rtc_gettimeofday(struct timespec *ts) {
55 * 54 *
56 * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter. 55 * Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.
57 */ 56 */
58int aica_rtc_settimeofday(const time_t secs) { 57int aica_rtc_settimeofday(const time_t secs)
58{
59 unsigned long val1, val2; 59 unsigned long val1, val2;
60 unsigned long adj = secs + TWENTY_YEARS; 60 unsigned long adj = secs + TWENTY_YEARS;
61 61
@@ -75,7 +75,7 @@ int aica_rtc_settimeofday(const time_t secs) {
75 75
76void aica_time_init(void) 76void aica_time_init(void)
77{ 77{
78 rtc_get_time = aica_rtc_gettimeofday; 78 rtc_sh_get_time = aica_rtc_gettimeofday;
79 rtc_set_time = aica_rtc_settimeofday; 79 rtc_sh_set_time = aica_rtc_settimeofday;
80} 80}
81 81
diff --git a/arch/sh/boards/dreamcast/setup.c b/arch/sh/boards/dreamcast/setup.c
index 0027b80a2343..f13017eeeb27 100644
--- a/arch/sh/boards/dreamcast/setup.c
+++ b/arch/sh/boards/dreamcast/setup.c
@@ -22,41 +22,21 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/irq.h> 23#include <linux/irq.h>
24#include <linux/device.h> 24#include <linux/device.h>
25
26#include <asm/io.h> 25#include <asm/io.h>
27#include <asm/irq.h> 26#include <asm/irq.h>
27#include <asm/rtc.h>
28#include <asm/machvec.h> 28#include <asm/machvec.h>
29#include <asm/machvec_init.h>
30#include <asm/mach/sysasic.h> 29#include <asm/mach/sysasic.h>
31 30
32extern struct hw_interrupt_type systemasic_int; 31extern struct hw_interrupt_type systemasic_int;
33/* XXX: Move this into it's proper header. */
34extern void (*board_time_init)(void);
35extern void aica_time_init(void); 32extern void aica_time_init(void);
36extern int gapspci_init(void); 33extern int gapspci_init(void);
37extern int systemasic_irq_demux(int); 34extern int systemasic_irq_demux(int);
38 35
39void *dreamcast_consistent_alloc(struct device *, size_t, dma_addr_t *, int); 36void *dreamcast_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
40int dreamcast_consistent_free(struct device *, size_t, void *, dma_addr_t); 37int dreamcast_consistent_free(struct device *, size_t, void *, dma_addr_t);
41 38
42const char *get_system_type(void) 39static void __init dreamcast_setup(char **cmdline_p)
43{
44 return "Sega Dreamcast";
45}
46
47struct sh_machine_vector mv_dreamcast __initmv = {
48 .mv_nr_irqs = NR_IRQS,
49
50 .mv_irq_demux = systemasic_irq_demux,
51
52#ifdef CONFIG_PCI
53 .mv_consistent_alloc = dreamcast_consistent_alloc,
54 .mv_consistent_free = dreamcast_consistent_free,
55#endif
56};
57ALIAS_MV(dreamcast)
58
59int __init platform_setup(void)
60{ 40{
61 int i; 41 int i;
62 42
@@ -78,6 +58,16 @@ int __init platform_setup(void)
78 if (gapspci_init() < 0) 58 if (gapspci_init() < 0)
79 printk(KERN_WARNING "GAPSPCI was not detected.\n"); 59 printk(KERN_WARNING "GAPSPCI was not detected.\n");
80#endif 60#endif
81
82 return 0;
83} 61}
62
63struct sh_machine_vector mv_dreamcast __initmv = {
64 .mv_name = "Sega Dreamcast",
65 .mv_setup = dreamcast_setup,
66 .mv_irq_demux = systemasic_irq_demux,
67
68#ifdef CONFIG_PCI
69 .mv_consistent_alloc = dreamcast_consistent_alloc,
70 .mv_consistent_free = dreamcast_consistent_free,
71#endif
72};
73ALIAS_MV(dreamcast)
diff --git a/arch/sh/boards/ec3104/setup.c b/arch/sh/boards/ec3104/setup.c
index 4b3ef16a0e96..902bc975a13e 100644
--- a/arch/sh/boards/ec3104/setup.c
+++ b/arch/sh/boards/ec3104/setup.c
@@ -21,22 +21,36 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/irq.h> 22#include <linux/irq.h>
23#include <linux/types.h> 23#include <linux/types.h>
24
25#include <asm/io.h> 24#include <asm/io.h>
26#include <asm/irq.h> 25#include <asm/irq.h>
27#include <asm/machvec.h> 26#include <asm/machvec.h>
28#include <asm/mach/ec3104.h> 27#include <asm/mach/ec3104.h>
29 28
30const char *get_system_type(void) 29static void __init ec3104_setup(char **cmdline_p)
31{ 30{
32 return "EC3104"; 31 char str[8];
32 int i;
33
34 for (i=0; i<8; i++)
35 str[i] = ctrl_readb(EC3104_BASE + i);
36
37 for (i = EC3104_IRQBASE; i < EC3104_IRQBASE + 32; i++)
38 irq_desc[i].handler = &ec3104_int;
39
40 printk("initializing EC3104 \"%.8s\" at %08x, IRQ %d, IRQ base %d\n",
41 str, EC3104_BASE, EC3104_IRQ, EC3104_IRQBASE);
42
43 /* mask all interrupts. this should have been done by the boot
44 * loader for us but we want to be sure ... */
45 ctrl_writel(0xffffffff, EC3104_IMR);
33} 46}
34 47
35/* 48/*
36 * The Machine Vector 49 * The Machine Vector
37 */ 50 */
38
39struct sh_machine_vector mv_ec3104 __initmv = { 51struct sh_machine_vector mv_ec3104 __initmv = {
52 .mv_name = "EC3104",
53 .mv_setup = ec3104_setup,
40 .mv_nr_irqs = 96, 54 .mv_nr_irqs = 96,
41 55
42 .mv_inb = ec3104_inb, 56 .mv_inb = ec3104_inb,
@@ -48,31 +62,4 @@ struct sh_machine_vector mv_ec3104 __initmv = {
48 62
49 .mv_irq_demux = ec3104_irq_demux, 63 .mv_irq_demux = ec3104_irq_demux,
50}; 64};
51
52ALIAS_MV(ec3104) 65ALIAS_MV(ec3104)
53
54int __init platform_setup(void)
55{
56 char str[8];
57 int i;
58
59 if (0)
60 return 0;
61
62 for (i=0; i<8; i++)
63 str[i] = ctrl_readb(EC3104_BASE + i);
64
65 for (i = EC3104_IRQBASE; i < EC3104_IRQBASE + 32; i++)
66 irq_desc[i].chip = &ec3104_int;
67
68 printk("initializing EC3104 \"%.8s\" at %08x, IRQ %d, IRQ base %d\n",
69 str, EC3104_BASE, EC3104_IRQ, EC3104_IRQBASE);
70
71
72 /* mask all interrupts. this should have been done by the boot
73 * loader for us but we want to be sure ... */
74 ctrl_writel(0xffffffff, EC3104_IMR);
75
76 return 0;
77}
78
diff --git a/arch/sh/boards/harp/Makefile b/arch/sh/boards/harp/Makefile
deleted file mode 100644
index eb753d31812e..000000000000
--- a/arch/sh/boards/harp/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for STMicroelectronics board specific parts of the kernel
3#
4
5obj-y := irq.o setup.o mach.o led.o
6
7obj-$(CONFIG_PCI) += pcidma.o
8
diff --git a/arch/sh/boards/harp/irq.c b/arch/sh/boards/harp/irq.c
deleted file mode 100644
index 96bb41c9fc55..000000000000
--- a/arch/sh/boards/harp/irq.c
+++ /dev/null
@@ -1,147 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Looks after interrupts on the HARP board.
8 *
9 * Bases on the IPR irq system
10 */
11
12#include <linux/init.h>
13#include <linux/irq.h>
14
15#include <asm/system.h>
16#include <asm/io.h>
17#include <asm/harp/harp.h>
18
19
20#define NUM_EXTERNAL_IRQS 16
21
22// Early versions of the STB1 Overdrive required this nasty frig
23//#define INVERT_INTMASK_WRITES
24
25static void enable_harp_irq(unsigned int irq);
26static void disable_harp_irq(unsigned int irq);
27
28/* shutdown is same as "disable" */
29#define shutdown_harp_irq disable_harp_irq
30
31static void mask_and_ack_harp(unsigned int);
32static void end_harp_irq(unsigned int irq);
33
34static unsigned int startup_harp_irq(unsigned int irq)
35{
36 enable_harp_irq(irq);
37 return 0; /* never anything pending */
38}
39
40static struct hw_interrupt_type harp_irq_type = {
41 .typename = "Harp-IRQ",
42 .startup = startup_harp_irq,
43 .shutdown = shutdown_harp_irq,
44 .enable = enable_harp_irq,
45 .disable = disable_harp_irq,
46 .ack = mask_and_ack_harp,
47 .end = end_harp_irq
48};
49
50static void disable_harp_irq(unsigned int irq)
51{
52 unsigned val, flags;
53 unsigned maskReg;
54 unsigned mask;
55 int pri;
56
57 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
58 return;
59
60 pri = 15 - irq;
61
62 if (pri < 8) {
63 maskReg = EPLD_INTMASK0;
64 } else {
65 maskReg = EPLD_INTMASK1;
66 pri -= 8;
67 }
68
69 local_irq_save(flags);
70 mask = ctrl_inl(maskReg);
71 mask &= (~(1 << pri));
72#if defined(INVERT_INTMASK_WRITES)
73 mask ^= 0xff;
74#endif
75 ctrl_outl(mask, maskReg);
76 local_irq_restore(flags);
77}
78
79static void enable_harp_irq(unsigned int irq)
80{
81 unsigned flags;
82 unsigned maskReg;
83 unsigned mask;
84 int pri;
85
86 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
87 return;
88
89 pri = 15 - irq;
90
91 if (pri < 8) {
92 maskReg = EPLD_INTMASK0;
93 } else {
94 maskReg = EPLD_INTMASK1;
95 pri -= 8;
96 }
97
98 local_irq_save(flags);
99 mask = ctrl_inl(maskReg);
100
101
102 mask |= (1 << pri);
103
104#if defined(INVERT_INTMASK_WRITES)
105 mask ^= 0xff;
106#endif
107 ctrl_outl(mask, maskReg);
108
109 local_irq_restore(flags);
110}
111
112/* This functions sets the desired irq handler to be an overdrive type */
113static void __init make_harp_irq(unsigned int irq)
114{
115 disable_irq_nosync(irq);
116 irq_desc[irq].chip = &harp_irq_type;
117 disable_harp_irq(irq);
118}
119
120static void mask_and_ack_harp(unsigned int irq)
121{
122 disable_harp_irq(irq);
123}
124
125static void end_harp_irq(unsigned int irq)
126{
127 enable_harp_irq(irq);
128}
129
130void __init init_harp_irq(void)
131{
132 int i;
133
134#if !defined(INVERT_INTMASK_WRITES)
135 // On the harp these are set to enable an interrupt
136 ctrl_outl(0x00, EPLD_INTMASK0);
137 ctrl_outl(0x00, EPLD_INTMASK1);
138#else
139 // On the Overdrive the data is inverted before being stored in the reg
140 ctrl_outl(0xff, EPLD_INTMASK0);
141 ctrl_outl(0xff, EPLD_INTMASK1);
142#endif
143
144 for (i = 0; i < NUM_EXTERNAL_IRQS; i++) {
145 make_harp_irq(i);
146 }
147}
diff --git a/arch/sh/boards/harp/led.c b/arch/sh/boards/harp/led.c
deleted file mode 100644
index aeb7b392b190..000000000000
--- a/arch/sh/boards/harp/led.c
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * linux/arch/sh/stboards/led.c
3 *
4 * Copyright (C) 2000 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * This file contains ST40STB1 HARP and compatible code.
10 */
11
12#include <asm/io.h>
13#include <asm/harp/harp.h>
14
15/* Harp: Flash LD10 (front pannel) connected to EPLD (IC8) */
16/* Overdrive: Flash LD1 (front panel) connected to EPLD (IC4) */
17/* Works for HARP and overdrive */
18static void mach_led(int position, int value)
19{
20 if (value) {
21 ctrl_outl(EPLD_LED_ON, EPLD_LED);
22 } else {
23 ctrl_outl(EPLD_LED_OFF, EPLD_LED);
24 }
25}
26
27#ifdef CONFIG_HEARTBEAT
28
29#include <linux/sched.h>
30
31/* acts like an actual heart beat -- ie thump-thump-pause... */
32void heartbeat_harp(void)
33{
34 static unsigned cnt = 0, period = 0, dist = 0;
35
36 if (cnt == 0 || cnt == dist)
37 mach_led( -1, 1);
38 else if (cnt == 7 || cnt == dist+7)
39 mach_led( -1, 0);
40
41 if (++cnt > period) {
42 cnt = 0;
43 /* The hyperbolic function below modifies the heartbeat period
44 * length in dependency of the current (5min) load. It goes
45 * through the points f(0)=126, f(1)=86, f(5)=51,
46 * f(inf)->30. */
47 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
48 dist = period / 4;
49 }
50}
51#endif
diff --git a/arch/sh/boards/harp/mach.c b/arch/sh/boards/harp/mach.c
deleted file mode 100644
index a946dd1674ca..000000000000
--- a/arch/sh/boards/harp/mach.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * linux/arch/sh/boards/harp/mach.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the STMicroelectronics STB1 HARP and compatible boards
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/machvec_init.h>
17#include <asm/hd64465/io.h>
18#include <asm/hd64465/hd64465.h>
19
20void setup_harp(void);
21void init_harp_irq(void);
22void heartbeat_harp(void);
23
24/*
25 * The Machine Vector
26 */
27
28struct sh_machine_vector mv_harp __initmv = {
29 .mv_nr_irqs = 89 + HD64465_IRQ_NUM,
30
31 .mv_inb = hd64465_inb,
32 .mv_inw = hd64465_inw,
33 .mv_inl = hd64465_inl,
34 .mv_outb = hd64465_outb,
35 .mv_outw = hd64465_outw,
36 .mv_outl = hd64465_outl,
37
38 .mv_inb_p = hd64465_inb_p,
39 .mv_inw_p = hd64465_inw,
40 .mv_inl_p = hd64465_inl,
41 .mv_outb_p = hd64465_outb_p,
42 .mv_outw_p = hd64465_outw,
43 .mv_outl_p = hd64465_outl,
44
45 .mv_insb = hd64465_insb,
46 .mv_insw = hd64465_insw,
47 .mv_insl = hd64465_insl,
48 .mv_outsb = hd64465_outsb,
49 .mv_outsw = hd64465_outsw,
50 .mv_outsl = hd64465_outsl,
51
52 .mv_isa_port2addr = hd64465_isa_port2addr,
53
54#ifdef CONFIG_PCI
55 .mv_init_irq = init_harp_irq,
56#endif
57#ifdef CONFIG_HEARTBEAT
58 .mv_heartbeat = heartbeat_harp,
59#endif
60};
61
62ALIAS_MV(harp)
diff --git a/arch/sh/boards/harp/pcidma.c b/arch/sh/boards/harp/pcidma.c
deleted file mode 100644
index 475311390fd6..000000000000
--- a/arch/sh/boards/harp/pcidma.c
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Dynamic DMA mapping support.
8 */
9
10#include <linux/types.h>
11#include <linux/mm.h>
12#include <linux/string.h>
13#include <linux/pci.h>
14#include <asm/io.h>
15#include <asm/addrspace.h>
16
17
18void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
19 dma_addr_t * dma_handle)
20{
21 void *ret;
22 int gfp = GFP_ATOMIC;
23
24 ret = (void *) __get_free_pages(gfp, get_order(size));
25
26 if (ret != NULL) {
27 /* Is it neccessary to do the memset? */
28 memset(ret, 0, size);
29 *dma_handle = virt_to_bus(ret);
30 }
31 /* We must flush the cache before we pass it on to the device */
32 flush_cache_all();
33 return P2SEGADDR(ret);
34}
35
36void pci_free_consistent(struct pci_dev *hwdev, size_t size,
37 void *vaddr, dma_addr_t dma_handle)
38{
39 unsigned long p1addr=P1SEGADDR((unsigned long)vaddr);
40
41 free_pages(p1addr, get_order(size));
42}
diff --git a/arch/sh/boards/harp/setup.c b/arch/sh/boards/harp/setup.c
deleted file mode 100644
index 886e450ab63e..000000000000
--- a/arch/sh/boards/harp/setup.c
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * arch/sh/stboard/setup.c
3 *
4 * Copyright (C) 2001 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * STMicroelectronics ST40STB1 HARP and compatible support.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <asm/io.h>
15#include <asm/harp/harp.h>
16
17const char *get_system_type(void)
18{
19 return "STB1 Harp";
20}
21
22/*
23 * Initialize the board
24 */
25int __init platform_setup(void)
26{
27#ifdef CONFIG_SH_STB1_HARP
28 unsigned long ic8_version, ic36_version;
29
30 ic8_version = ctrl_inl(EPLD_REVID2);
31 ic36_version = ctrl_inl(EPLD_REVID1);
32
33 printk("STMicroelectronics STB1 HARP initialisaton\n");
34 printk("EPLD versions: IC8: %d.%02d, IC36: %d.%02d\n",
35 (ic8_version >> 4) & 0xf, ic8_version & 0xf,
36 (ic36_version >> 4) & 0xf, ic36_version & 0xf);
37#elif defined(CONFIG_SH_STB1_OVERDRIVE)
38 unsigned long version;
39
40 version = ctrl_inl(EPLD_REVID);
41
42 printk("STMicroelectronics STB1 Overdrive initialisaton\n");
43 printk("EPLD version: %d.%02d\n",
44 (version >> 4) & 0xf, version & 0xf);
45#else
46#error Undefined machine
47#endif
48
49 /* Currently all STB1 chips have problems with the sleep instruction,
50 * so disable it here.
51 */
52 disable_hlt();
53
54 return 0;
55}
56
57/*
58 * pcibios_map_platform_irq
59 *
60 * This is board specific and returns the IRQ for a given PCI device.
61 * It is used by the PCI code (arch/sh/kernel/st40_pci*)
62 *
63 */
64
65#define HARP_PCI_IRQ 1
66#define HARP_BRIDGE_IRQ 2
67#define OVERDRIVE_SLOT0_IRQ 0
68
69
70int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
71{
72 switch (slot) {
73#ifdef CONFIG_SH_STB1_HARP
74 case 2: /*This is the PCI slot on the */
75 return HARP_PCI_IRQ;
76 case 1: /* this is the bridge */
77 return HARP_BRIDGE_IRQ;
78#elif defined(CONFIG_SH_STB1_OVERDRIVE)
79 case 1:
80 case 2:
81 case 3:
82 return slot - 1;
83#else
84#error Unknown board
85#endif
86 default:
87 return -1;
88 }
89}
90
diff --git a/arch/sh/boards/hp6xx/Makefile b/arch/sh/boards/hp6xx/Makefile
index 927fe0aa5dfa..ff1b7f5b4e91 100644
--- a/arch/sh/boards/hp6xx/Makefile
+++ b/arch/sh/boards/hp6xx/Makefile
@@ -2,5 +2,6 @@
2# Makefile for the HP6xx specific parts of the kernel 2# Makefile for the HP6xx specific parts of the kernel
3# 3#
4 4
5obj-y := mach.o setup.o 5obj-y := setup.o
6 6obj-$(CONFIG_PM) += pm.o pm_wakeup.o
7obj-$(CONFIG_APM) += hp6xx_apm.o
diff --git a/arch/sh/boards/hp6xx/hp6xx_apm.c b/arch/sh/boards/hp6xx/hp6xx_apm.c
new file mode 100644
index 000000000000..ad0e712c29f6
--- /dev/null
+++ b/arch/sh/boards/hp6xx/hp6xx_apm.c
@@ -0,0 +1,123 @@
1/*
2 * bios-less APM driver for hp680
3 *
4 * Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
8 */
9#include <linux/config.h>
10#include <linux/module.h>
11#include <linux/apm_bios.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/interrupt.h>
15#include <asm/io.h>
16#include <asm/apm.h>
17#include <asm/adc.h>
18#include <asm/hp6xx/hp6xx.h>
19
20#define SH7709_PGDR 0xa400012c
21
22#define APM_CRITICAL 10
23#define APM_LOW 30
24
25#define HP680_BATTERY_MAX 875
26#define HP680_BATTERY_MIN 600
27#define HP680_BATTERY_AC_ON 900
28
29#define MODNAME "hp6x0_apm"
30
31static int hp6x0_apm_get_info(char *buf, char **start, off_t fpos, int length)
32{
33 u8 pgdr;
34 char *p;
35 int battery_status;
36 int battery_flag;
37 int ac_line_status;
38 int time_units = APM_BATTERY_LIFE_UNKNOWN;
39
40 int battery = adc_single(ADC_CHANNEL_BATTERY);
41 int backup = adc_single(ADC_CHANNEL_BACKUP);
42 int charging = adc_single(ADC_CHANNEL_CHARGE);
43 int percentage;
44
45 percentage = 100 * (battery - HP680_BATTERY_MIN) /
46 (HP680_BATTERY_MAX - HP680_BATTERY_MIN);
47
48 ac_line_status = (battery > HP680_BATTERY_AC_ON) ?
49 APM_AC_ONLINE : APM_AC_OFFLINE;
50
51 p = buf;
52
53 pgdr = ctrl_inb(SH7709_PGDR);
54 if (pgdr & PGDR_MAIN_BATTERY_OUT) {
55 battery_status = APM_BATTERY_STATUS_NOT_PRESENT;
56 battery_flag = 0x80;
57 percentage = -1;
58 } else if (charging < 8 ) {
59 battery_status = APM_BATTERY_STATUS_CHARGING;
60 battery_flag = 0x08;
61 ac_line_status = 0xff;
62 } else if (percentage <= APM_CRITICAL) {
63 battery_status = APM_BATTERY_STATUS_CRITICAL;
64 battery_flag = 0x04;
65 } else if (percentage <= APM_LOW) {
66 battery_status = APM_BATTERY_STATUS_LOW;
67 battery_flag = 0x02;
68 } else {
69 battery_status = APM_BATTERY_STATUS_HIGH;
70 battery_flag = 0x01;
71 }
72
73 p += sprintf(p, "1.0 1.2 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
74 APM_32_BIT_SUPPORT,
75 ac_line_status,
76 battery_status,
77 battery_flag,
78 percentage,
79 time_units,
80 "min");
81 p += sprintf(p, "bat=%d backup=%d charge=%d\n",
82 battery, backup, charging);
83
84 return p - buf;
85}
86
87static irqreturn_t hp6x0_apm_interrupt(int irq, void *dev, struct pt_regs *regs)
88{
89 if (!apm_suspended)
90 apm_queue_event(APM_USER_SUSPEND);
91
92 return IRQ_HANDLED;
93}
94
95static int __init hp6x0_apm_init(void)
96{
97 int ret;
98
99 ret = request_irq(HP680_BTN_IRQ, hp6x0_apm_interrupt,
100 SA_INTERRUPT, MODNAME, 0);
101 if (unlikely(ret < 0)) {
102 printk(KERN_ERR MODNAME ": IRQ %d request failed\n",
103 HP680_BTN_IRQ);
104 return ret;
105 }
106
107 apm_get_info = hp6x0_apm_get_info;
108
109 return ret;
110}
111
112static void __exit hp6x0_apm_exit(void)
113{
114 free_irq(HP680_BTN_IRQ, 0);
115 apm_get_info = 0;
116}
117
118module_init(hp6x0_apm_init);
119module_exit(hp6x0_apm_exit);
120
121MODULE_AUTHOR("Adriy Skulysh");
122MODULE_DESCRIPTION("hp6xx Advanced Power Management");
123MODULE_LICENSE("GPL");
diff --git a/arch/sh/boards/hp6xx/pm.c b/arch/sh/boards/hp6xx/pm.c
new file mode 100644
index 000000000000..0e501bcbd7a9
--- /dev/null
+++ b/arch/sh/boards/hp6xx/pm.c
@@ -0,0 +1,88 @@
1/*
2 * hp6x0 Power Management Routines
3 *
4 * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
8 */
9#include <linux/config.h>
10#include <linux/init.h>
11#include <linux/suspend.h>
12#include <linux/errno.h>
13#include <linux/time.h>
14#include <asm/io.h>
15#include <asm/hd64461.h>
16#include <asm/hp6xx/hp6xx.h>
17#include <asm/cpu/dac.h>
18#include <asm/pm.h>
19
20#define STBCR 0xffffff82
21#define STBCR2 0xffffff88
22
23static int hp6x0_pm_enter(suspend_state_t state)
24{
25 u8 stbcr, stbcr2;
26#ifdef CONFIG_HD64461_ENABLER
27 u8 scr;
28 u16 hd64461_stbcr;
29#endif
30
31 if (state != PM_SUSPEND_MEM)
32 return -EINVAL;
33
34#ifdef CONFIG_HD64461_ENABLER
35 outb(0, HD64461_PCC1CSCIER);
36
37 scr = inb(HD64461_PCC1SCR);
38 scr |= HD64461_PCCSCR_VCC1;
39 outb(scr, HD64461_PCC1SCR);
40
41 hd64461_stbcr = inw(HD64461_STBCR);
42 hd64461_stbcr |= HD64461_STBCR_SPC1ST;
43 outw(hd64461_stbcr, HD64461_STBCR);
44#endif
45
46 ctrl_outb(0x1f, DACR);
47
48 stbcr = ctrl_inb(STBCR);
49 ctrl_outb(0x01, STBCR);
50
51 stbcr2 = ctrl_inb(STBCR2);
52 ctrl_outb(0x7f , STBCR2);
53
54 outw(0xf07f, HD64461_SCPUCR);
55
56 pm_enter();
57
58 outw(0, HD64461_SCPUCR);
59 ctrl_outb(stbcr, STBCR);
60 ctrl_outb(stbcr2, STBCR2);
61
62#ifdef CONFIG_HD64461_ENABLER
63 hd64461_stbcr = inw(HD64461_STBCR);
64 hd64461_stbcr &= ~HD64461_STBCR_SPC1ST;
65 outw(hd64461_stbcr, HD64461_STBCR);
66
67 outb(0x4c, HD64461_PCC1CSCIER);
68 outb(0x00, HD64461_PCC1CSCR);
69#endif
70
71 return 0;
72}
73
74/*
75 * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk.
76 */
77static struct pm_ops hp6x0_pm_ops = {
78 .pm_disk_mode = PM_DISK_FIRMWARE,
79 .enter = hp6x0_pm_enter,
80};
81
82static int __init hp6x0_pm_init(void)
83{
84 pm_set_ops(&hp6x0_pm_ops);
85 return 0;
86}
87
88late_initcall(hp6x0_pm_init);
diff --git a/arch/sh/boards/hp6xx/pm_wakeup.S b/arch/sh/boards/hp6xx/pm_wakeup.S
new file mode 100644
index 000000000000..45e9bf0b9115
--- /dev/null
+++ b/arch/sh/boards/hp6xx/pm_wakeup.S
@@ -0,0 +1,58 @@
1/*
2 * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 */
9
10#include <linux/linkage.h>
11#include <asm/cpu/mmu_context.h>
12
13#define k0 r0
14#define k1 r1
15#define k2 r2
16#define k3 r3
17#define k4 r4
18
19/*
20 * Kernel mode register usage:
21 * k0 scratch
22 * k1 scratch
23 * k2 scratch (Exception code)
24 * k3 scratch (Return address)
25 * k4 scratch
26 * k5 reserved
27 * k6 Global Interrupt Mask (0--15 << 4)
28 * k7 CURRENT_THREAD_INFO (pointer to current thread info)
29 */
30
31ENTRY(wakeup_start)
32! clear STBY bit
33 mov #-126, k2
34 and #127, k0
35 mov.b k0, @k2
36! enable refresh
37 mov.l 5f, k1
38 mov.w 6f, k0
39 mov.w k0, @k1
40! jump to handler
41 mov.l 2f, k2
42 mov.l 3f, k3
43 mov.l @k2, k2
44
45 mov.l 4f, k1
46 jmp @k1
47 nop
48
49 .align 2
501: .long EXPEVT
512: .long INTEVT
523: .long ret_from_irq
534: .long handle_exception
545: .long 0xffffff68
556: .word 0x0524
56
57ENTRY(wakeup_end)
58 nop
diff --git a/arch/sh/boards/hp6xx/setup.c b/arch/sh/boards/hp6xx/setup.c
index 71f315663cc9..60ab17ad6054 100644
--- a/arch/sh/boards/hp6xx/setup.c
+++ b/arch/sh/boards/hp6xx/setup.c
@@ -8,22 +8,22 @@
8 * 8 *
9 * Setup code for an HP680 (internal peripherials only) 9 * Setup code for an HP680 (internal peripherials only)
10 */ 10 */
11 11#include <linux/types.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/io.h>
14#include <asm/hd64461.h> 13#include <asm/hd64461.h>
14#include <asm/io.h>
15#include <asm/irq.h>
15#include <asm/hp6xx/hp6xx.h> 16#include <asm/hp6xx/hp6xx.h>
16#include <asm/cpu/dac.h> 17#include <asm/cpu/dac.h>
17 18
18const char *get_system_type(void) 19#define SCPCR 0xa4000116
19{ 20#define SCPDR 0xa4000136
20 return "HP6xx";
21}
22 21
23int __init platform_setup(void) 22static void __init hp6xx_setup(char **cmdline_p)
24{ 23{
25 u8 v8; 24 u8 v8;
26 u16 v; 25 u16 v;
26
27 v = inw(HD64461_STBCR); 27 v = inw(HD64461_STBCR);
28 v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST | 28 v |= HD64461_STBCR_SURTST | HD64461_STBCR_SIRST |
29 HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST | 29 HD64461_STBCR_STM1ST | HD64461_STBCR_STM0ST |
@@ -50,5 +50,51 @@ int __init platform_setup(void)
50 v8 &= ~DACR_DAE; 50 v8 &= ~DACR_DAE;
51 ctrl_outb(v8,DACR); 51 ctrl_outb(v8,DACR);
52 52
53 return 0; 53 v8 = ctrl_inb(SCPDR);
54 v8 |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
55 v8 &= ~SCPDR_TS_SCAN_ENABLE;
56 ctrl_outb(v8, SCPDR);
57
58 v = ctrl_inw(SCPCR);
59 v &= ~SCPCR_TS_MASK;
60 v |= SCPCR_TS_ENABLE;
61 ctrl_outw(v, SCPCR);
54} 62}
63
64/*
65 * XXX: This is stupid, we should have a generic machine vector for the cchips
66 * and just wrap the platform setup code in to this, as it's the only thing
67 * that ends up being different.
68 */
69struct sh_machine_vector mv_hp6xx __initmv = {
70 .mv_name = "hp6xx",
71 .mv_setup = hp6xx_setup,
72 .mv_nr_irqs = HD64461_IRQBASE + HD64461_IRQ_NUM,
73
74 .mv_inb = hd64461_inb,
75 .mv_inw = hd64461_inw,
76 .mv_inl = hd64461_inl,
77 .mv_outb = hd64461_outb,
78 .mv_outw = hd64461_outw,
79 .mv_outl = hd64461_outl,
80
81 .mv_inb_p = hd64461_inb_p,
82 .mv_inw_p = hd64461_inw,
83 .mv_inl_p = hd64461_inl,
84 .mv_outb_p = hd64461_outb_p,
85 .mv_outw_p = hd64461_outw,
86 .mv_outl_p = hd64461_outl,
87
88 .mv_insb = hd64461_insb,
89 .mv_insw = hd64461_insw,
90 .mv_insl = hd64461_insl,
91 .mv_outsb = hd64461_outsb,
92 .mv_outsw = hd64461_outsw,
93 .mv_outsl = hd64461_outsl,
94
95 .mv_readw = hd64461_readw,
96 .mv_writew = hd64461_writew,
97
98 .mv_irq_demux = hd64461_irq_demux,
99};
100ALIAS_MV(hp6xx)
diff --git a/arch/sh/boards/landisk/Makefile b/arch/sh/boards/landisk/Makefile
new file mode 100644
index 000000000000..89e4beb2ad47
--- /dev/null
+++ b/arch/sh/boards/landisk/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for I-O DATA DEVICE, INC. "LANDISK Series"
3#
4
5obj-y := setup.o io.o irq.o rtc.o landisk_pwb.o
diff --git a/arch/sh/boards/landisk/io.c b/arch/sh/boards/landisk/io.c
new file mode 100644
index 000000000000..92498b4947d5
--- /dev/null
+++ b/arch/sh/boards/landisk/io.c
@@ -0,0 +1,250 @@
1/*
2 * arch/sh/boards/landisk/io.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
6 *
7 * I/O routine for I-O Data Device, Inc. LANDISK.
8 *
9 * Initial version only to support LAN access; some
10 * placeholder code from io_landisk.c left in with the
11 * expectation of later SuperIO and PCMCIA access.
12 */
13/*
14 * modifed by kogiidena
15 * 2005.03.03
16 */
17#include <linux/kernel.h>
18#include <linux/types.h>
19#include <linux/pci.h>
20#include <asm/landisk/iodata_landisk.h>
21#include <asm/addrspace.h>
22#include <asm/io.h>
23
24extern void *area5_io_base; /* Area 5 I/O Base address */
25extern void *area6_io_base; /* Area 6 I/O Base address */
26
27static inline unsigned long port2adr(unsigned int port)
28{
29 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
30 if (port == 0x3f6)
31 return ((unsigned long)area5_io_base + 0x2c);
32 else
33 return ((unsigned long)area5_io_base + PA_PIDE_OFFSET +
34 ((port - 0x1f0) << 1));
35 else if ((0x170 <= port && port < 0x178) || port == 0x376)
36 if (port == 0x376)
37 return ((unsigned long)area6_io_base + 0x2c);
38 else
39 return ((unsigned long)area6_io_base + PA_SIDE_OFFSET +
40 ((port - 0x170) << 1));
41 else
42 maybebadio((unsigned long)port);
43
44 return port;
45}
46
47/*
48 * General outline: remap really low stuff [eventually] to SuperIO,
49 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
50 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
51 * should be way beyond the window, and is used w/o translation for
52 * compatibility.
53 */
54u8 landisk_inb(unsigned long port)
55{
56 if (PXSEG(port))
57 return ctrl_inb(port);
58 else if (is_pci_ioaddr(port))
59 return ctrl_inb(pci_ioaddr(port));
60
61 return ctrl_inw(port2adr(port)) & 0xff;
62}
63
64u8 landisk_inb_p(unsigned long port)
65{
66 u8 v;
67
68 if (PXSEG(port))
69 v = ctrl_inb(port);
70 else if (is_pci_ioaddr(port))
71 v = ctrl_inb(pci_ioaddr(port));
72 else
73 v = ctrl_inw(port2adr(port)) & 0xff;
74
75 ctrl_delay();
76
77 return v;
78}
79
80u16 landisk_inw(unsigned long port)
81{
82 if (PXSEG(port))
83 return ctrl_inw(port);
84 else if (is_pci_ioaddr(port))
85 return ctrl_inw(pci_ioaddr(port));
86 else
87 maybebadio(port);
88
89 return 0;
90}
91
92u32 landisk_inl(unsigned long port)
93{
94 if (PXSEG(port))
95 return ctrl_inl(port);
96 else if (is_pci_ioaddr(port))
97 return ctrl_inl(pci_ioaddr(port));
98 else
99 maybebadio(port);
100
101 return 0;
102}
103
104void landisk_outb(u8 value, unsigned long port)
105{
106 if (PXSEG(port))
107 ctrl_outb(value, port);
108 else if (is_pci_ioaddr(port))
109 ctrl_outb(value, pci_ioaddr(port));
110 else
111 ctrl_outw(value, port2adr(port));
112}
113
114void landisk_outb_p(u8 value, unsigned long port)
115{
116 if (PXSEG(port))
117 ctrl_outb(value, port);
118 else if (is_pci_ioaddr(port))
119 ctrl_outb(value, pci_ioaddr(port));
120 else
121 ctrl_outw(value, port2adr(port));
122 ctrl_delay();
123}
124
125void landisk_outw(u16 value, unsigned long port)
126{
127 if (PXSEG(port))
128 ctrl_outw(value, port);
129 else if (is_pci_ioaddr(port))
130 ctrl_outw(value, pci_ioaddr(port));
131 else
132 maybebadio(port);
133}
134
135void landisk_outl(u32 value, unsigned long port)
136{
137 if (PXSEG(port))
138 ctrl_outl(value, port);
139 else if (is_pci_ioaddr(port))
140 ctrl_outl(value, pci_ioaddr(port));
141 else
142 maybebadio(port);
143}
144
145void landisk_insb(unsigned long port, void *dst, unsigned long count)
146{
147 volatile u16 *p;
148 u8 *buf = dst;
149
150 if (PXSEG(port)) {
151 while (count--)
152 *buf++ = *(volatile u8 *)port;
153 } else if (is_pci_ioaddr(port)) {
154 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
155
156 while (count--)
157 *buf++ = *bp;
158 } else {
159 p = (volatile u16 *)port2adr(port);
160 while (count--)
161 *buf++ = *p & 0xff;
162 }
163}
164
165void landisk_insw(unsigned long port, void *dst, unsigned long count)
166{
167 volatile u16 *p;
168 u16 *buf = dst;
169
170 if (PXSEG(port))
171 p = (volatile u16 *)port;
172 else if (is_pci_ioaddr(port))
173 p = (volatile u16 *)pci_ioaddr(port);
174 else
175 p = (volatile u16 *)port2adr(port);
176 while (count--)
177 *buf++ = *p;
178}
179
180void landisk_insl(unsigned long port, void *dst, unsigned long count)
181{
182 u32 *buf = dst;
183
184 if (is_pci_ioaddr(port)) {
185 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
186
187 while (count--)
188 *buf++ = *p;
189 } else
190 maybebadio(port);
191}
192
193void landisk_outsb(unsigned long port, const void *src, unsigned long count)
194{
195 volatile u16 *p;
196 const u8 *buf = src;
197
198 if (PXSEG(port))
199 while (count--)
200 ctrl_outb(*buf++, port);
201 else if (is_pci_ioaddr(port)) {
202 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
203
204 while (count--)
205 *bp = *buf++;
206 } else {
207 p = (volatile u16 *)port2adr(port);
208 while (count--)
209 *p = *buf++;
210 }
211}
212
213void landisk_outsw(unsigned long port, const void *src, unsigned long count)
214{
215 volatile u16 *p;
216 const u16 *buf = src;
217
218 if (PXSEG(port))
219 p = (volatile u16 *)port;
220 else if (is_pci_ioaddr(port))
221 p = (volatile u16 *)pci_ioaddr(port);
222 else
223 p = (volatile u16 *)port2adr(port);
224
225 while (count--)
226 *p = *buf++;
227}
228
229void landisk_outsl(unsigned long port, const void *src, unsigned long count)
230{
231 const u32 *buf = src;
232
233 if (is_pci_ioaddr(port)) {
234 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
235
236 while (count--)
237 *p = *buf++;
238 } else
239 maybebadio(port);
240}
241
242void __iomem *landisk_ioport_map(unsigned long port, unsigned int size)
243{
244 if (PXSEG(port))
245 return (void __iomem *)port;
246 else if (is_pci_ioaddr(port))
247 return (void __iomem *)pci_ioaddr(port);
248
249 return (void __iomem *)port2adr(port);
250}
diff --git a/arch/sh/boards/landisk/irq.c b/arch/sh/boards/landisk/irq.c
new file mode 100644
index 000000000000..a006d6443225
--- /dev/null
+++ b/arch/sh/boards/landisk/irq.c
@@ -0,0 +1,99 @@
1/*
2 * arch/sh/boards/landisk/irq.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c.
6 *
7 * I/O routine for I-O Data Device, Inc. LANDISK.
8 *
9 * Initial version only to support LAN access; some
10 * placeholder code from io_landisk.c left in with the
11 * expectation of later SuperIO and PCMCIA access.
12 */
13/*
14 * modified by kogiidena
15 * 2005.03.03
16 */
17
18#include <linux/config.h>
19#include <linux/init.h>
20#include <linux/irq.h>
21#include <asm/io.h>
22#include <asm/irq.h>
23#include <asm/landisk/iodata_landisk.h>
24
25static void enable_landisk_irq(unsigned int irq);
26static void disable_landisk_irq(unsigned int irq);
27
28/* shutdown is same as "disable" */
29#define shutdown_landisk_irq disable_landisk_irq
30
31static void ack_landisk_irq(unsigned int irq);
32static void end_landisk_irq(unsigned int irq);
33
34static unsigned int startup_landisk_irq(unsigned int irq)
35{
36 enable_landisk_irq(irq);
37 return 0; /* never anything pending */
38}
39
40static void disable_landisk_irq(unsigned int irq)
41{
42 unsigned char val;
43 unsigned char mask = 0xff ^ (0x01 << (irq - 5));
44
45 /* Set the priority in IPR to 0 */
46 val = ctrl_inb(PA_IMASK);
47 val &= mask;
48 ctrl_outb(val, PA_IMASK);
49}
50
51static void enable_landisk_irq(unsigned int irq)
52{
53 unsigned char val;
54 unsigned char value = (0x01 << (irq - 5));
55
56 /* Set priority in IPR back to original value */
57 val = ctrl_inb(PA_IMASK);
58 val |= value;
59 ctrl_outb(val, PA_IMASK);
60}
61
62static void ack_landisk_irq(unsigned int irq)
63{
64 disable_landisk_irq(irq);
65}
66
67static void end_landisk_irq(unsigned int irq)
68{
69 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
70 enable_landisk_irq(irq);
71}
72
73static struct hw_interrupt_type landisk_irq_type = {
74 .typename = "LANDISK IRQ",
75 .startup = startup_landisk_irq,
76 .shutdown = shutdown_landisk_irq,
77 .enable = enable_landisk_irq,
78 .disable = disable_landisk_irq,
79 .ack = ack_landisk_irq,
80 .end = end_landisk_irq
81};
82
83static void make_landisk_irq(unsigned int irq)
84{
85 disable_irq_nosync(irq);
86 irq_desc[irq].handler = &landisk_irq_type;
87 disable_landisk_irq(irq);
88}
89
90/*
91 * Initialize IRQ setting
92 */
93void __init init_landisk_IRQ(void)
94{
95 int i;
96
97 for (i = 5; i < 14; i++)
98 make_landisk_irq(i);
99}
diff --git a/arch/sh/boards/landisk/landisk_pwb.c b/arch/sh/boards/landisk/landisk_pwb.c
new file mode 100644
index 000000000000..e75cb578a28b
--- /dev/null
+++ b/arch/sh/boards/landisk/landisk_pwb.c
@@ -0,0 +1,348 @@
1/*
2 * arch/sh/boards/landisk/landisk_pwb.c -- driver for the Power control switch.
3 *
4 * This driver will also support the I-O DATA Device, Inc. LANDISK Board.
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 * Copylight (C) 2002 Atom Create Engineering Co., Ltd.
11 *
12 * LED control drive function added by kogiidena
13 */
14
15#include <linux/config.h>
16#include <linux/module.h>
17#include <linux/errno.h>
18#include <linux/signal.h>
19#include <linux/major.h>
20#include <linux/poll.h>
21#include <linux/init.h>
22#include <linux/delay.h>
23#include <linux/sched.h>
24#include <linux/timer.h>
25#include <linux/interrupt.h>
26
27#include <asm/system.h>
28#include <asm/io.h>
29#include <asm/irq.h>
30#include <asm/uaccess.h>
31#include <asm/landisk/iodata_landisk.h>
32
33#define SHUTDOWN_BTN_MINOR 1 /* Shutdown button device minor no. */
34#define LED_MINOR 21 /* LED minor no. */
35#define BTN_MINOR 22 /* BUTTON minor no. */
36#define GIO_MINOR 40 /* GIO minor no. */
37
38static int openCnt;
39static int openCntLED;
40static int openCntGio;
41static int openCntBtn;
42static int landisk_btn;
43static int landisk_btnctrlpid;
44/*
45 * Functions prototypes
46 */
47
48static int gio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
49 unsigned long arg);
50
51static int swdrv_open(struct inode *inode, struct file *filp)
52{
53 int minor;
54
55 minor = MINOR(inode->i_rdev);
56 filp->private_data = (void *)minor;
57
58 if (minor == SHUTDOWN_BTN_MINOR) {
59 if (openCnt > 0) {
60 return -EALREADY;
61 } else {
62 openCnt++;
63 return 0;
64 }
65 } else if (minor == LED_MINOR) {
66 if (openCntLED > 0) {
67 return -EALREADY;
68 } else {
69 openCntLED++;
70 return 0;
71 }
72 } else if (minor == BTN_MINOR) {
73 if (openCntBtn > 0) {
74 return -EALREADY;
75 } else {
76 openCntBtn++;
77 return 0;
78 }
79 } else if (minor == GIO_MINOR) {
80 if (openCntGio > 0) {
81 return -EALREADY;
82 } else {
83 openCntGio++;
84 return 0;
85 }
86 }
87 return -ENOENT;
88
89}
90
91static int swdrv_close(struct inode *inode, struct file *filp)
92{
93 int minor;
94
95 minor = MINOR(inode->i_rdev);
96 if (minor == SHUTDOWN_BTN_MINOR) {
97 openCnt--;
98 } else if (minor == LED_MINOR) {
99 openCntLED--;
100 } else if (minor == BTN_MINOR) {
101 openCntBtn--;
102 } else if (minor == GIO_MINOR) {
103 openCntGio--;
104 }
105 return 0;
106}
107
108static int swdrv_read(struct file *filp, char *buff, size_t count,
109 loff_t * ppos)
110{
111 int minor;
112 minor = (int)(filp->private_data);
113
114 if (!access_ok(VERIFY_WRITE, (void *)buff, count))
115 return -EFAULT;
116
117 if (minor == SHUTDOWN_BTN_MINOR) {
118 if (landisk_btn & 0x10) {
119 put_user(1, buff);
120 return 1;
121 } else {
122 return 0;
123 }
124 }
125 return 0;
126}
127
128static int swdrv_write(struct file *filp, const char *buff, size_t count,
129 loff_t * ppos)
130{
131 int minor;
132 minor = (int)(filp->private_data);
133
134 if (minor == SHUTDOWN_BTN_MINOR) {
135 return count;
136 }
137 return count;
138}
139
140static irqreturn_t sw_interrupt(int irq, void *dev_id, struct pt_regs *regs)
141{
142 landisk_btn = (0x0ff & (~ctrl_inb(PA_STATUS)));
143 disable_irq(IRQ_BUTTON);
144 disable_irq(IRQ_POWER);
145 ctrl_outb(0x00, PA_PWRINT_CLR);
146
147 if (landisk_btnctrlpid != 0) {
148 kill_proc(landisk_btnctrlpid, SIGUSR1, 1);
149 landisk_btnctrlpid = 0;
150 }
151
152 return IRQ_HANDLED;
153}
154
155static struct file_operations swdrv_fops = {
156 .read = swdrv_read, /* read */
157 .write = swdrv_write, /* write */
158 .open = swdrv_open, /* open */
159 .release = swdrv_close, /* release */
160 .ioctl = gio_ioctl, /* ioctl */
161
162};
163
164static char banner[] __initdata =
165 KERN_INFO "LANDISK and USL-5P Button, LED and GIO driver initialized\n";
166
167int __init swdrv_init(void)
168{
169 int error;
170
171 printk("%s", banner);
172
173 openCnt = 0;
174 openCntLED = 0;
175 openCntBtn = 0;
176 openCntGio = 0;
177 landisk_btn = 0;
178 landisk_btnctrlpid = 0;
179
180 if ((error = register_chrdev(SHUTDOWN_BTN_MAJOR, "swdrv", &swdrv_fops))) {
181 printk(KERN_ERR
182 "Button, LED and GIO driver:Couldn't register driver, error=%d\n",
183 error);
184 return 1;
185 }
186
187 if (request_irq(IRQ_POWER, sw_interrupt, 0, "SHUTDOWNSWITCH", NULL)) {
188 printk(KERN_ERR "Unable to get IRQ 11.\n");
189 return 1;
190 }
191 if (request_irq(IRQ_BUTTON, sw_interrupt, 0, "USL-5P BUTTON", NULL)) {
192 printk(KERN_ERR "Unable to get IRQ 12.\n");
193 return 1;
194 }
195 ctrl_outb(0x00, PA_PWRINT_CLR);
196
197 return 0;
198}
199
200module_init(swdrv_init);
201
202/*
203 * gio driver
204 *
205 */
206
207#include <asm/landisk/gio.h>
208
209static int gio_ioctl(struct inode *inode, struct file *filp,
210 unsigned int cmd, unsigned long arg)
211{
212 int minor;
213 unsigned int data, mask;
214 static unsigned int addr = 0;
215
216 minor = (int)(filp->private_data);
217
218 /* access control */
219 if (minor == GIO_MINOR) {
220 ;
221 } else if (minor == LED_MINOR) {
222 if (((cmd & 0x0ff) >= 9) && ((cmd & 0x0ff) < 20)) {
223 ;
224 } else {
225 return -EINVAL;
226 }
227 } else if (minor == BTN_MINOR) {
228 if (((cmd & 0x0ff) >= 20) && ((cmd & 0x0ff) < 30)) {
229 ;
230 } else {
231 return -EINVAL;
232 }
233 } else {
234 return -EINVAL;
235 }
236
237 if (cmd & 0x01) { /* write */
238 if (copy_from_user(&data, (int *)arg, sizeof(int))) {
239 return -EFAULT;
240 }
241 }
242
243 switch (cmd) {
244 case GIODRV_IOCSGIOSETADDR: /* addres set */
245 addr = data;
246 break;
247
248 case GIODRV_IOCSGIODATA1: /* write byte */
249 ctrl_outb((unsigned char)(0x0ff & data), addr);
250 break;
251
252 case GIODRV_IOCSGIODATA2: /* write word */
253 if (addr & 0x01) {
254 return -EFAULT;
255 }
256 ctrl_outw((unsigned short int)(0x0ffff & data), addr);
257 break;
258
259 case GIODRV_IOCSGIODATA4: /* write long */
260 if (addr & 0x03) {
261 return -EFAULT;
262 }
263 ctrl_outl(data, addr);
264 break;
265
266 case GIODRV_IOCGGIODATA1: /* read byte */
267 data = ctrl_inb(addr);
268 break;
269
270 case GIODRV_IOCGGIODATA2: /* read word */
271 if (addr & 0x01) {
272 return -EFAULT;
273 }
274 data = ctrl_inw(addr);
275 break;
276
277 case GIODRV_IOCGGIODATA4: /* read long */
278 if (addr & 0x03) {
279 return -EFAULT;
280 }
281 data = ctrl_inl(addr);
282 break;
283 case GIODRV_IOCSGIO_LED: /* write */
284 mask = ((data & 0x00ffffff) << 8)
285 | ((data & 0x0000ffff) << 16)
286 | ((data & 0x000000ff) << 24);
287 landisk_ledparam = data & (~mask);
288 if (landisk_arch == 0) { /* arch == landisk */
289 landisk_ledparam &= 0x03030303;
290 mask = (~(landisk_ledparam >> 22)) & 0x000c;
291 landisk_ledparam |= mask;
292 } else { /* arch == usl-5p */
293 mask = (landisk_ledparam >> 24) & 0x0001;
294 landisk_ledparam |= mask;
295 landisk_ledparam &= 0x007f7f7f;
296 }
297 landisk_ledparam |= 0x80;
298 break;
299 case GIODRV_IOCGGIO_LED: /* read */
300 data = landisk_ledparam;
301 if (landisk_arch == 0) { /* arch == landisk */
302 data &= 0x03030303;
303 } else { /* arch == usl-5p */
304 ;
305 }
306 data &= (~0x080);
307 break;
308 case GIODRV_IOCSGIO_BUZZER: /* write */
309 landisk_buzzerparam = data;
310 landisk_ledparam |= 0x80;
311 break;
312 case GIODRV_IOCGGIO_LANDISK: /* read */
313 data = landisk_arch & 0x01;
314 break;
315 case GIODRV_IOCGGIO_BTN: /* read */
316 data = (0x0ff & ctrl_inb(PA_PWRINT_CLR));
317 data <<= 8;
318 data |= (0x0ff & ctrl_inb(PA_IMASK));
319 data <<= 8;
320 data |= (0x0ff & landisk_btn);
321 data <<= 8;
322 data |= (0x0ff & (~ctrl_inb(PA_STATUS)));
323 break;
324 case GIODRV_IOCSGIO_BTNPID: /* write */
325 landisk_btnctrlpid = data;
326 landisk_btn = 0;
327 if (irq_desc[IRQ_BUTTON].depth) {
328 enable_irq(IRQ_BUTTON);
329 }
330 if (irq_desc[IRQ_POWER].depth) {
331 enable_irq(IRQ_POWER);
332 }
333 break;
334 case GIODRV_IOCGGIO_BTNPID: /* read */
335 data = landisk_btnctrlpid;
336 break;
337 default:
338 return -EFAULT;
339 break;
340 }
341
342 if ((cmd & 0x01) == 0) { /* read */
343 if (copy_to_user((int *)arg, &data, sizeof(int))) {
344 return -EFAULT;
345 }
346 }
347 return 0;
348}
diff --git a/arch/sh/boards/landisk/rtc.c b/arch/sh/boards/landisk/rtc.c
new file mode 100644
index 000000000000..35ba726a0979
--- /dev/null
+++ b/arch/sh/boards/landisk/rtc.c
@@ -0,0 +1,93 @@
1/*
2 * arch/sh/boards/landisk/rtc.c -- RTC support
3 *
4 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
5 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
6 */
7/*
8 * modifed by kogiidena
9 * 2005.09.16
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14#include <linux/kernel.h>
15#include <linux/sched.h>
16#include <linux/time.h>
17#include <linux/delay.h>
18#include <linux/spinlock.h>
19#include <linux/bcd.h>
20#include <asm/rtc.h>
21
22extern spinlock_t rtc_lock;
23
24extern void
25rs5c313_set_cmos_time(unsigned int BCD_yr, unsigned int BCD_mon,
26 unsigned int BCD_day, unsigned int BCD_hr,
27 unsigned int BCD_min, unsigned int BCD_sec);
28
29extern unsigned long
30rs5c313_get_cmos_time(unsigned int *BCD_yr, unsigned int *BCD_mon,
31 unsigned int *BCD_day, unsigned int *BCD_hr,
32 unsigned int *BCD_min, unsigned int *BCD_sec);
33
34void landisk_rtc_gettimeofday(struct timespec *tv)
35{
36 unsigned int BCD_yr, BCD_mon, BCD_day, BCD_hr, BCD_min, BCD_sec;
37 unsigned long flags;
38
39 spin_lock_irqsave(&rtc_lock, flags);
40 tv->tv_sec = rs5c313_get_cmos_time
41 (&BCD_yr, &BCD_mon, &BCD_day, &BCD_hr, &BCD_min, &BCD_sec);
42 tv->tv_nsec = 0;
43 spin_unlock_irqrestore(&rtc_lock, flags);
44}
45
46int landisk_rtc_settimeofday(const time_t secs)
47{
48 int retval = 0;
49 int real_seconds, real_minutes, cmos_minutes;
50 unsigned long flags;
51 unsigned long nowtime = secs;
52 unsigned int BCD_yr, BCD_mon, BCD_day, BCD_hr, BCD_min, BCD_sec;
53
54 spin_lock_irqsave(&rtc_lock, flags);
55
56 rs5c313_get_cmos_time
57 (&BCD_yr, &BCD_mon, &BCD_day, &BCD_hr, &BCD_min, &BCD_sec);
58 cmos_minutes = BCD_min;
59 BCD_TO_BIN(cmos_minutes);
60
61 /*
62 * since we're only adjusting minutes and seconds,
63 * don't interfere with hour overflow. This avoids
64 * messing with unknown time zones but requires your
65 * RTC not to be off by more than 15 minutes
66 */
67 real_seconds = nowtime % 60;
68 real_minutes = nowtime / 60;
69 if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
70 real_minutes += 30; /* correct for half hour time zone */
71 real_minutes %= 60;
72
73 if (abs(real_minutes - cmos_minutes) < 30) {
74 BIN_TO_BCD(real_seconds);
75 BIN_TO_BCD(real_minutes);
76 rs5c313_set_cmos_time(BCD_yr, BCD_mon, BCD_day, BCD_hr,
77 real_minutes, real_seconds);
78 } else {
79 printk(KERN_WARNING
80 "set_rtc_time: can't update from %d to %d\n",
81 cmos_minutes, real_minutes);
82 retval = -1;
83 }
84
85 spin_unlock_irqrestore(&rtc_lock, flags);
86 return retval;
87}
88
89void landisk_time_init(void)
90{
91 rtc_sh_get_time = landisk_rtc_gettimeofday;
92 rtc_sh_set_time = landisk_rtc_settimeofday;
93}
diff --git a/arch/sh/boards/landisk/setup.c b/arch/sh/boards/landisk/setup.c
new file mode 100644
index 000000000000..127b9e020e00
--- /dev/null
+++ b/arch/sh/boards/landisk/setup.c
@@ -0,0 +1,177 @@
1/*
2 * arch/sh/boards/landisk/setup.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 * Copyright (C) 2002 Paul Mundt
6 *
7 * I-O DATA Device, Inc. LANDISK Support.
8 *
9 * Modified for LANDISK by
10 * Atom Create Engineering Co., Ltd. 2002.
11 *
12 * modifed by kogiidena
13 * 2005.09.16
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
18 */
19#include <linux/config.h>
20#include <linux/init.h>
21#include <linux/pm.h>
22#include <linux/mm.h>
23#include <asm/machvec.h>
24#include <asm/rtc.h>
25#include <asm/landisk/iodata_landisk.h>
26#include <asm/io.h>
27
28void landisk_time_init(void);
29void init_landisk_IRQ(void);
30
31int landisk_ledparam;
32int landisk_buzzerparam;
33int landisk_arch;
34
35/* cycle the led's in the clasic knightrider/sun pattern */
36static void heartbeat_landisk(void)
37{
38 static unsigned int cnt = 0, blink = 0x00, period = 25;
39 volatile u8 *p = (volatile u8 *)PA_LED;
40 char data;
41
42 if ((landisk_ledparam & 0x080) == 0)
43 return;
44
45 cnt += 1;
46
47 if (cnt < period)
48 return;
49
50 cnt = 0;
51 blink++;
52
53 data = (blink & 0x01) ? (landisk_ledparam >> 16) : 0;
54 data |= (blink & 0x02) ? (landisk_ledparam >> 8) : 0;
55 data |= landisk_ledparam;
56
57 /* buzzer */
58 if (landisk_buzzerparam & 0x1) {
59 data |= 0x80;
60 } else {
61 data &= 0x7f;
62 }
63 *p = data;
64
65 if (((landisk_ledparam & 0x007f7f00) == 0) &&
66 (landisk_buzzerparam == 0))
67 landisk_ledparam &= (~0x0080);
68
69 landisk_buzzerparam >>= 1;
70}
71
72static void landisk_power_off(void)
73{
74 ctrl_outb(0x01, PA_SHUTDOWN);
75}
76
77static void check_usl5p(void)
78{
79 volatile u8 *p = (volatile u8 *)PA_LED;
80 u8 tmp1, tmp2;
81
82 tmp1 = *p;
83 *p = 0x40;
84 tmp2 = *p;
85 *p = tmp1;
86
87 landisk_arch = (tmp2 == 0x40);
88 if (landisk_arch == 1) {
89 /* arch == usl-5p */
90 landisk_ledparam = 0x00000380;
91 landisk_ledparam |= (tmp1 & 0x07c);
92 } else {
93 /* arch == landisk */
94 landisk_ledparam = 0x02000180;
95 landisk_ledparam |= 0x04;
96 }
97}
98
99void *area5_io_base;
100void *area6_io_base;
101
102static int __init landisk_cf_init(void)
103{
104 pgprot_t prot;
105 unsigned long paddrbase, psize;
106
107 /* open I/O area window */
108 paddrbase = virt_to_phys((void *)PA_AREA5_IO);
109 psize = PAGE_SIZE;
110 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
111 area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
112 if (!area5_io_base) {
113 printk("allocate_cf_area : can't open CF I/O window!\n");
114 return -ENOMEM;
115 }
116
117 paddrbase = virt_to_phys((void *)PA_AREA6_IO);
118 psize = PAGE_SIZE;
119 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
120 area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
121 if (!area6_io_base) {
122 printk("allocate_cf_area : can't open HDD I/O window!\n");
123 return -ENOMEM;
124 }
125
126 printk(KERN_INFO "Allocate Area5/6 success.\n");
127
128 /* XXX : do we need attribute and common-memory area also? */
129
130 return 0;
131}
132
133static void __init landisk_setup(char **cmdline_p)
134{
135 device_initcall(landisk_cf_init);
136
137 landisk_buzzerparam = 0;
138 check_usl5p();
139
140 printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
141
142 board_time_init = landisk_time_init;
143 pm_power_off = landisk_power_off;
144}
145
146/*
147 * The Machine Vector
148 */
149struct sh_machine_vector mv_landisk __initmv = {
150 .mv_name = "LANDISK",
151 .mv_setup = landisk_setup,
152 .mv_nr_irqs = 72,
153 .mv_inb = landisk_inb,
154 .mv_inw = landisk_inw,
155 .mv_inl = landisk_inl,
156 .mv_outb = landisk_outb,
157 .mv_outw = landisk_outw,
158 .mv_outl = landisk_outl,
159 .mv_inb_p = landisk_inb_p,
160 .mv_inw_p = landisk_inw,
161 .mv_inl_p = landisk_inl,
162 .mv_outb_p = landisk_outb_p,
163 .mv_outw_p = landisk_outw,
164 .mv_outl_p = landisk_outl,
165 .mv_insb = landisk_insb,
166 .mv_insw = landisk_insw,
167 .mv_insl = landisk_insl,
168 .mv_outsb = landisk_outsb,
169 .mv_outsw = landisk_outsw,
170 .mv_outsl = landisk_outsl,
171 .mv_ioport_map = landisk_ioport_map,
172 .mv_init_irq = init_landisk_IRQ,
173#ifdef CONFIG_HEARTBEAT
174 .mv_heartbeat = heartbeat_landisk,
175#endif
176};
177ALIAS_MV(landisk)
diff --git a/arch/sh/boards/mpc1211/rtc.c b/arch/sh/boards/mpc1211/rtc.c
index a76c655dceee..03b123a4bba4 100644
--- a/arch/sh/boards/mpc1211/rtc.c
+++ b/arch/sh/boards/mpc1211/rtc.c
@@ -130,7 +130,7 @@ int mpc1211_rtc_settimeofday(const struct timeval *tv)
130 130
131void mpc1211_time_init(void) 131void mpc1211_time_init(void)
132{ 132{
133 rtc_get_time = mpc1211_rtc_gettimeofday; 133 rtc_sh_get_time = mpc1211_rtc_gettimeofday;
134 rtc_set_time = mpc1211_rtc_settimeofday; 134 rtc_sh_set_time = mpc1211_rtc_settimeofday;
135} 135}
136 136
diff --git a/arch/sh/boards/mpc1211/setup.c b/arch/sh/boards/mpc1211/setup.c
index 2bfb221cc35c..8eb5d4303972 100644
--- a/arch/sh/boards/mpc1211/setup.c
+++ b/arch/sh/boards/mpc1211/setup.c
@@ -10,14 +10,12 @@
10#include <linux/hdreg.h> 10#include <linux/hdreg.h>
11#include <linux/ide.h> 11#include <linux/ide.h>
12#include <linux/interrupt.h> 12#include <linux/interrupt.h>
13
14#include <asm/io.h> 13#include <asm/io.h>
15#include <asm/machvec.h> 14#include <asm/machvec.h>
16#include <asm/mpc1211/mpc1211.h> 15#include <asm/mpc1211/mpc1211.h>
17#include <asm/mpc1211/pci.h> 16#include <asm/mpc1211/pci.h>
18#include <asm/mpc1211/m1543c.h> 17#include <asm/mpc1211/m1543c.h>
19 18
20
21/* ALI15X3 SMBus address offsets */ 19/* ALI15X3 SMBus address offsets */
22#define SMBHSTSTS (0 + 0x3100) 20#define SMBHSTSTS (0 + 0x3100)
23#define SMBHSTCNT (1 + 0x3100) 21#define SMBHSTCNT (1 + 0x3100)
@@ -50,11 +48,6 @@
50#define ALI15X3_STS_TERM 0x80 /* terminated by abort */ 48#define ALI15X3_STS_TERM 0x80 /* terminated by abort */
51#define ALI15X3_STS_ERR 0xE0 /* all the bad error bits */ 49#define ALI15X3_STS_ERR 0xE0 /* all the bad error bits */
52 50
53const char *get_system_type(void)
54{
55 return "Interface MPC-1211(CTP/PCI/MPC-SH02)";
56}
57
58static void __init pci_write_config(unsigned long busNo, 51static void __init pci_write_config(unsigned long busNo,
59 unsigned long devNo, 52 unsigned long devNo,
60 unsigned long fncNo, 53 unsigned long fncNo,
@@ -80,9 +73,6 @@ volatile unsigned long irq_err_count;
80 73
81static void disable_mpc1211_irq(unsigned int irq) 74static void disable_mpc1211_irq(unsigned int irq)
82{ 75{
83 unsigned long flags;
84
85 save_and_cli(flags);
86 if( irq < 8) { 76 if( irq < 8) {
87 m_irq_mask |= (1 << irq); 77 m_irq_mask |= (1 << irq);
88 outb(m_irq_mask,I8259_M_MR); 78 outb(m_irq_mask,I8259_M_MR);
@@ -90,16 +80,11 @@ static void disable_mpc1211_irq(unsigned int irq)
90 s_irq_mask |= (1 << (irq - 8)); 80 s_irq_mask |= (1 << (irq - 8));
91 outb(s_irq_mask,I8259_S_MR); 81 outb(s_irq_mask,I8259_S_MR);
92 } 82 }
93 restore_flags(flags);
94 83
95} 84}
96 85
97static void enable_mpc1211_irq(unsigned int irq) 86static void enable_mpc1211_irq(unsigned int irq)
98{ 87{
99 unsigned long flags;
100
101 save_and_cli(flags);
102
103 if( irq < 8) { 88 if( irq < 8) {
104 m_irq_mask &= ~(1 << irq); 89 m_irq_mask &= ~(1 << irq);
105 outb(m_irq_mask,I8259_M_MR); 90 outb(m_irq_mask,I8259_M_MR);
@@ -107,7 +92,6 @@ static void enable_mpc1211_irq(unsigned int irq)
107 s_irq_mask &= ~(1 << (irq - 8)); 92 s_irq_mask &= ~(1 << (irq - 8));
108 outb(s_irq_mask,I8259_S_MR); 93 outb(s_irq_mask,I8259_S_MR);
109 } 94 }
110 restore_flags(flags);
111} 95}
112 96
113static inline int mpc1211_irq_real(unsigned int irq) 97static inline int mpc1211_irq_real(unsigned int irq)
@@ -131,10 +115,6 @@ static inline int mpc1211_irq_real(unsigned int irq)
131 115
132static void mask_and_ack_mpc1211(unsigned int irq) 116static void mask_and_ack_mpc1211(unsigned int irq)
133{ 117{
134 unsigned long flags;
135
136 save_and_cli(flags);
137
138 if(irq < 8) { 118 if(irq < 8) {
139 if(m_irq_mask & (1<<irq)){ 119 if(m_irq_mask & (1<<irq)){
140 if(!mpc1211_irq_real(irq)){ 120 if(!mpc1211_irq_real(irq)){
@@ -162,7 +142,6 @@ static void mask_and_ack_mpc1211(unsigned int irq)
162 outb(0x60+(irq-8),I8259_S_CR); /* EOI */ 142 outb(0x60+(irq-8),I8259_S_CR); /* EOI */
163 outb(0x60+2,I8259_M_CR); 143 outb(0x60+2,I8259_M_CR);
164 } 144 }
165 restore_flags(flags);
166} 145}
167 146
168static void end_mpc1211_irq(unsigned int irq) 147static void end_mpc1211_irq(unsigned int irq)
@@ -219,7 +198,7 @@ int mpc1211_irq_demux(int irq)
219 return irq; 198 return irq;
220} 199}
221 200
222void __init init_mpc1211_IRQ(void) 201static void __init init_mpc1211_IRQ(void)
223{ 202{
224 int i; 203 int i;
225 /* 204 /*
@@ -255,23 +234,12 @@ void __init init_mpc1211_IRQ(void)
255 } 234 }
256} 235}
257 236
258/* 237static void delay1000(void)
259 Initialize the board
260*/
261
262
263static void delay (void)
264{
265 volatile unsigned short tmp;
266 tmp = *(volatile unsigned short *) 0xa0000000;
267}
268
269static void delay1000 (void)
270{ 238{
271 int i; 239 int i;
272 240
273 for (i=0; i<1000; i++) 241 for (i=0; i<1000; i++)
274 delay (); 242 ctrl_delay();
275} 243}
276 244
277static int put_smb_blk(unsigned char *p, int address, int command, int no) 245static int put_smb_blk(unsigned char *p, int address, int command, int no)
@@ -314,26 +282,10 @@ static int put_smb_blk(unsigned char *p, int address, int command, int no)
314 return 0; 282 return 0;
315} 283}
316 284
317/*
318 * The Machine Vector
319 */
320
321struct sh_machine_vector mv_mpc1211 __initmv = {
322 .mv_nr_irqs = 48,
323 .mv_irq_demux = mpc1211_irq_demux,
324 .mv_init_irq = init_mpc1211_IRQ,
325
326#ifdef CONFIG_HEARTBEAT
327 .mv_heartbeat = heartbeat_mpc1211,
328#endif
329};
330
331ALIAS_MV(mpc1211)
332
333/* arch/sh/boards/mpc1211/rtc.c */ 285/* arch/sh/boards/mpc1211/rtc.c */
334void mpc1211_time_init(void); 286void mpc1211_time_init(void);
335 287
336int __init platform_setup(void) 288static void __init mpc1211_setup(char **cmdline_p)
337{ 289{
338 unsigned char spd_buf[128]; 290 unsigned char spd_buf[128];
339 291
@@ -357,3 +309,18 @@ int __init platform_setup(void)
357 return 0; 309 return 0;
358} 310}
359 311
312/*
313 * The Machine Vector
314 */
315struct sh_machine_vector mv_mpc1211 __initmv = {
316 .mv_name = "Interface MPC-1211(CTP/PCI/MPC-SH02)",
317 .mv_setup = mpc1211_setup,
318 .mv_nr_irqs = 48,
319 .mv_irq_demux = mpc1211_irq_demux,
320 .mv_init_irq = init_mpc1211_IRQ,
321
322#ifdef CONFIG_HEARTBEAT
323 .mv_heartbeat = heartbeat_mpc1211,
324#endif
325};
326ALIAS_MV(mpc1211)
diff --git a/arch/sh/boards/overdrive/Makefile b/arch/sh/boards/overdrive/Makefile
deleted file mode 100644
index 245f03baf762..000000000000
--- a/arch/sh/boards/overdrive/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
1#
2# Makefile for the STMicroelectronics Overdrive specific parts of the kernel
3#
4
5obj-y := mach.o setup.o io.o irq.o led.o
6
7obj-$(CONFIG_PCI) += fpga.o galileo.o pcidma.o
8
diff --git a/arch/sh/boards/overdrive/fpga.c b/arch/sh/boards/overdrive/fpga.c
deleted file mode 100644
index 956c23901228..000000000000
--- a/arch/sh/boards/overdrive/fpga.c
+++ /dev/null
@@ -1,133 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file handles programming up the Altera Flex10K that interfaces to
8 * the Galileo, and does the PS/2 keyboard and mouse
9 *
10 */
11
12
13#include <linux/kernel.h>
14#include <linux/smp.h>
15#include <linux/smp_lock.h>
16#include <linux/init.h>
17#include <linux/errno.h>
18#include <linux/pci.h>
19#include <linux/delay.h>
20
21
22#include <asm/overdriver/gt64111.h>
23#include <asm/overdrive/overdrive.h>
24#include <asm/overdrive/fpga.h>
25
26#define FPGA_NotConfigHigh() (*FPGA_ControlReg) = (*FPGA_ControlReg) | ENABLE_FPGA_BIT
27#define FPGA_NotConfigLow() (*FPGA_ControlReg) = (*FPGA_ControlReg) & RESET_FPGA_MASK
28
29/* I need to find out what (if any) the real delay factor here is */
30/* The delay is definately not critical */
31#define long_delay() {int i;for(i=0;i<10000;i++);}
32#define short_delay() {int i;for(i=0;i<100;i++);}
33
34static void __init program_overdrive_fpga(const unsigned char *fpgacode,
35 int size)
36{
37 int timeout = 0;
38 int i, j;
39 unsigned char b;
40 static volatile unsigned char *FPGA_ControlReg =
41 (volatile unsigned char *) (OVERDRIVE_CTRL);
42 static volatile unsigned char *FPGA_ProgramReg =
43 (volatile unsigned char *) (FPGA_DCLK_ADDRESS);
44
45 printk("FPGA: Commencing FPGA Programming\n");
46
47 /* The PCI reset but MUST be low when programming the FPGA !!! */
48 b = (*FPGA_ControlReg) & RESET_PCI_MASK;
49
50 (*FPGA_ControlReg) = b;
51
52 /* Prepare FPGA to program */
53
54 FPGA_NotConfigHigh();
55 long_delay();
56
57 FPGA_NotConfigLow();
58 short_delay();
59
60 while ((*FPGA_ProgramReg & FPGA_NOT_STATUS) != 0) {
61 printk("FPGA: Waiting for NotStatus to go Low ... \n");
62 }
63
64 FPGA_NotConfigHigh();
65
66 /* Wait for FPGA "ready to be programmed" signal */
67 printk("FPGA: Waiting for NotStatus to go high (FPGA ready)... \n");
68
69 for (timeout = 0;
70 (((*FPGA_ProgramReg & FPGA_NOT_STATUS) == 0)
71 && (timeout < FPGA_TIMEOUT)); timeout++);
72
73 /* Check if timeout condition occured - i.e. an error */
74
75 if (timeout == FPGA_TIMEOUT) {
76 printk
77 ("FPGA: Failed to program - Timeout waiting for notSTATUS to go high\n");
78 return;
79 }
80
81 printk("FPGA: Copying data to FPGA ... %d bytes\n", size);
82
83 /* Copy array to FPGA - bit at a time */
84
85 for (i = 0; i < size; i++) {
86 volatile unsigned w = 0;
87
88 for (j = 0; j < 8; j++) {
89 *FPGA_ProgramReg = (fpgacode[i] >> j) & 0x01;
90 short_delay();
91 }
92 if ((i & 0x3ff) == 0) {
93 printk(".");
94 }
95 }
96
97 /* Waiting for CONFDONE to go high - means the program is complete */
98
99 for (timeout = 0;
100 (((*FPGA_ProgramReg & FPGA_CONFDONE) == 0)
101 && (timeout < FPGA_TIMEOUT)); timeout++) {
102
103 *FPGA_ProgramReg = 0x0;
104 long_delay();
105 }
106
107 if (timeout == FPGA_TIMEOUT) {
108 printk
109 ("FPGA: Failed to program - Timeout waiting for CONFDONE to go high\n");
110 return;
111 } else { /* Clock another 10 times - gets the device into a working state */
112 for (i = 0; i < 10; i++) {
113 *FPGA_ProgramReg = 0x0;
114 short_delay();
115 }
116 }
117
118 printk("FPGA: Programming complete\n");
119}
120
121
122static const unsigned char __init fpgacode[] = {
123#include "./overdrive.ttf" /* Code from maxplus2 compiler */
124 , 0, 0
125};
126
127
128int __init init_overdrive_fpga(void)
129{
130 program_overdrive_fpga(fpgacode, sizeof(fpgacode));
131
132 return 0;
133}
diff --git a/arch/sh/boards/overdrive/galileo.c b/arch/sh/boards/overdrive/galileo.c
deleted file mode 100644
index 29e48971bba0..000000000000
--- a/arch/sh/boards/overdrive/galileo.c
+++ /dev/null
@@ -1,587 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file contains the PCI routines required for the Galileo GT6411
8 * PCI bridge as used on the Orion and Overdrive boards.
9 *
10 */
11
12#include <linux/kernel.h>
13#include <linux/smp.h>
14#include <linux/smp_lock.h>
15#include <linux/init.h>
16#include <linux/errno.h>
17#include <linux/pci.h>
18#include <linux/delay.h>
19#include <linux/types.h>
20#include <linux/ioport.h>
21
22#include <asm/overdrive/overdrive.h>
23#include <asm/overdrive/gt64111.h>
24
25
26/* After boot, we shift the Galileo registers so that they appear
27 * in BANK6, along with IO space. This means we can have one contingous
28 * lump of PCI address space without these registers appearing in the
29 * middle of them
30 */
31
32#define GT64111_BASE_ADDRESS 0xbb000000
33#define GT64111_IO_BASE_ADDRESS 0x1000
34/* The GT64111 registers appear at this address to the SH4 after reset */
35#define RESET_GT64111_BASE_ADDRESS 0xb4000000
36
37/* Macros used to access the Galileo registers */
38#define RESET_GT64111_REG(x) (RESET_GT64111_BASE_ADDRESS+x)
39#define GT64111_REG(x) (GT64111_BASE_ADDRESS+x)
40
41#define RESET_GT_WRITE(x,v) writel((v),RESET_GT64111_REG(x))
42
43#define RESET_GT_READ(x) readl(RESET_GT64111_REG(x))
44
45#define GT_WRITE(x,v) writel((v),GT64111_REG(x))
46#define GT_WRITE_BYTE(x,v) writeb((v),GT64111_REG(x))
47#define GT_WRITE_SHORT(x,v) writew((v),GT64111_REG(x))
48
49#define GT_READ(x) readl(GT64111_REG(x))
50#define GT_READ_BYTE(x) readb(GT64111_REG(x))
51#define GT_READ_SHORT(x) readw(GT64111_REG(x))
52
53
54/* Where the various SH banks start at */
55#define SH_BANK4_ADR 0xb0000000
56#define SH_BANK5_ADR 0xb4000000
57#define SH_BANK6_ADR 0xb8000000
58
59/* Masks out everything but lines 28,27,26 */
60#define BANK_SELECT_MASK 0x1c000000
61
62#define SH4_TO_BANK(x) ( (x) & BANK_SELECT_MASK)
63
64/*
65 * Masks used for address conversaion. Bank 6 is used for IO and
66 * has all the address bits zeroed by the FPGA. Special case this
67 */
68#define MEMORY_BANK_MASK 0x1fffffff
69#define IO_BANK_MASK 0x03ffffff
70
71/* Mark bank 6 as the bank used for IO. You can change this in the FPGA code
72 * if you want
73 */
74#define IO_BANK_ADR PCI_GTIO_BASE
75
76/* Will select the correct mask to apply depending on the SH$ address */
77#define SELECT_BANK_MASK(x) \
78 ( (SH4_TO_BANK(x)==SH4_TO_BANK(IO_BANK_ADR)) ? IO_BANK_MASK : MEMORY_BANK_MASK)
79
80/* Converts between PCI space and P2 region */
81#define SH4_TO_PCI(x) ((x)&SELECT_BANK_MASK(x))
82
83/* Various macros for figuring out what to stick in the Galileo registers.
84 * You *really* don't want to figure this stuff out by hand, you always get
85 * it wrong
86 */
87#define GT_MEM_LO_ADR(x) ((((unsigned)((x)&SELECT_BANK_MASK(x)))>>21)&0x7ff)
88#define GT_MEM_HI_ADR(x) ((((unsigned)((x)&SELECT_BANK_MASK(x)))>>21)&0x7f)
89#define GT_MEM_SUB_ADR(x) ((((unsigned)((x)&SELECT_BANK_MASK(x)))>>20)&0xff)
90
91#define PROGRAM_HI_LO(block,a,s) \
92 GT_WRITE(block##_LO_DEC_ADR,GT_MEM_LO_ADR(a));\
93 GT_WRITE(block##_HI_DEC_ADR,GT_MEM_HI_ADR(a+s-1))
94
95#define PROGRAM_SUB_HI_LO(block,a,s) \
96 GT_WRITE(block##_LO_DEC_ADR,GT_MEM_SUB_ADR(a));\
97 GT_WRITE(block##_HI_DEC_ADR,GT_MEM_SUB_ADR(a+s-1))
98
99/* We need to set the size, and the offset register */
100
101#define GT_BAR_MASK(x) ((x)&~0xfff)
102
103/* Macro to set up the BAR in the Galileo. Essentially used for the DRAM */
104#define PROGRAM_GT_BAR(block,a,s) \
105 GT_WRITE(PCI_##block##_BANK_SIZE,GT_BAR_MASK((s-1)));\
106 write_config_to_galileo(PCI_CONFIG_##block##_BASE_ADR,\
107 GT_BAR_MASK(a))
108
109#define DISABLE_GT_BAR(block) \
110 GT_WRITE(PCI_##block##_BANK_SIZE,0),\
111 GT_CONFIG_WRITE(PCI_CONFIG_##block##_BASE_ADR,\
112 0x80000000)
113
114/* Macros to disable things we are not going to use */
115#define DISABLE_DECODE(x) GT_WRITE(x##_LO_DEC_ADR,0x7ff);\
116 GT_WRITE(x##_HI_DEC_ADR,0x00)
117
118#define DISABLE_SUB_DECODE(x) GT_WRITE(x##_LO_DEC_ADR,0xff);\
119 GT_WRITE(x##_HI_DEC_ADR,0x00)
120
121static void __init reset_pci(void)
122{
123 /* Set RESET_PCI bit high */
124 writeb(readb(OVERDRIVE_CTRL) | ENABLE_PCI_BIT, OVERDRIVE_CTRL);
125 udelay(250);
126
127 /* Set RESET_PCI bit low */
128 writeb(readb(OVERDRIVE_CTRL) & RESET_PCI_MASK, OVERDRIVE_CTRL);
129 udelay(250);
130
131 writeb(readb(OVERDRIVE_CTRL) | ENABLE_PCI_BIT, OVERDRIVE_CTRL);
132 udelay(250);
133}
134
135static int write_config_to_galileo(int where, u32 val);
136#define GT_CONFIG_WRITE(where,val) write_config_to_galileo(where,val)
137
138#define ENABLE_PCI_DRAM
139
140
141#ifdef TEST_DRAM
142/* Test function to check out if the PCI DRAM is working OK */
143static int /* __init */ test_dram(unsigned *base, unsigned size)
144{
145 unsigned *p = base;
146 unsigned *end = (unsigned *) (((unsigned) base) + size);
147 unsigned w;
148
149 for (p = base; p < end; p++) {
150 *p = 0xffffffff;
151 if (*p != 0xffffffff) {
152 printk("AAARGH -write failed!!! at %p is %x\n", p,
153 *p);
154 return 0;
155 }
156 *p = 0x0;
157 if (*p != 0x0) {
158 printk("AAARGH -write failed!!!\n");
159 return 0;
160 }
161 }
162
163 for (p = base; p < end; p++) {
164 *p = (unsigned) p;
165 if (*p != (unsigned) p) {
166 printk("Failed at 0x%p, actually is 0x%x\n", p,
167 *p);
168 return 0;
169 }
170 }
171
172 for (p = base; p < end; p++) {
173 w = ((unsigned) p & 0xffff0000);
174 *p = w | (w >> 16);
175 }
176
177 for (p = base; p < end; p++) {
178 w = ((unsigned) p & 0xffff0000);
179 w |= (w >> 16);
180 if (*p != w) {
181 printk
182 ("Failed at 0x%p, should be 0x%x actually is 0x%x\n",
183 p, w, *p);
184 return 0;
185 }
186 }
187
188 return 1;
189}
190#endif
191
192
193/* Function to set up and initialise the galileo. This sets up the BARS,
194 * maps the DRAM into the address space etc,etc
195 */
196int __init galileo_init(void)
197{
198 reset_pci();
199
200 /* Now shift the galileo regs into this block */
201 RESET_GT_WRITE(INTERNAL_SPACE_DEC,
202 GT_MEM_LO_ADR(GT64111_BASE_ADDRESS));
203
204 /* Should have a sanity check here, that you can read back at the new
205 * address what you just wrote
206 */
207
208 /* Disable decode for all regions */
209 DISABLE_DECODE(RAS10);
210 DISABLE_DECODE(RAS32);
211 DISABLE_DECODE(CS20);
212 DISABLE_DECODE(CS3);
213 DISABLE_DECODE(PCI_IO);
214 DISABLE_DECODE(PCI_MEM0);
215 DISABLE_DECODE(PCI_MEM1);
216
217 /* Disable all BARS */
218 GT_WRITE(BAR_ENABLE_ADR, 0x1ff);
219 DISABLE_GT_BAR(RAS10);
220 DISABLE_GT_BAR(RAS32);
221 DISABLE_GT_BAR(CS20);
222 DISABLE_GT_BAR(CS3);
223
224 /* Tell the BAR where the IO registers now are */
225 GT_CONFIG_WRITE(PCI_CONFIG_INT_REG_IO_ADR,GT_BAR_MASK(
226 (GT64111_IO_BASE_ADDRESS &
227 IO_BANK_MASK)));
228 /* set up a 112 Mb decode */
229 PROGRAM_HI_LO(PCI_MEM0, SH_BANK4_ADR, 112 * 1024 * 1024);
230
231 /* Set up a 32 MB io space decode */
232 PROGRAM_HI_LO(PCI_IO, IO_BANK_ADR, 32 * 1024 * 1024);
233
234#ifdef ENABLE_PCI_DRAM
235 /* Program up the DRAM configuration - there is DRAM only in bank 0 */
236 /* Now set up the DRAM decode */
237 PROGRAM_HI_LO(RAS10, PCI_DRAM_BASE, PCI_DRAM_SIZE);
238 /* And the sub decode */
239 PROGRAM_SUB_HI_LO(RAS0, PCI_DRAM_BASE, PCI_DRAM_SIZE);
240
241 DISABLE_SUB_DECODE(RAS1);
242
243 /* Set refresh rate */
244 GT_WRITE(DRAM_BANK0_PARMS, 0x3f);
245 GT_WRITE(DRAM_CFG, 0x100);
246
247 /* we have to lob off the top bits rememeber!! */
248 PROGRAM_GT_BAR(RAS10, SH4_TO_PCI(PCI_DRAM_BASE), PCI_DRAM_SIZE);
249
250#endif
251
252 /* We are only interested in decoding RAS10 and the Galileo's internal
253 * registers (as IO) on the PCI bus
254 */
255#ifdef ENABLE_PCI_DRAM
256 GT_WRITE(BAR_ENABLE_ADR, (~((1 << 8) | (1 << 3))) & 0x1ff);
257#else
258 GT_WRITE(BAR_ENABLE_ADR, (~(1 << 3)) & 0x1ff);
259#endif
260
261 /* Change the class code to host bridge, it actually powers up
262 * as a memory controller
263 */
264 GT_CONFIG_WRITE(8, 0x06000011);
265
266 /* Allow the galileo to master the PCI bus */
267 GT_CONFIG_WRITE(PCI_COMMAND,
268 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
269 PCI_COMMAND_IO);
270
271
272#if 0
273 printk("Testing PCI DRAM - ");
274 if(test_dram(PCI_DRAM_BASE,PCI_DRAM_SIZE)) {
275 printk("Passed\n");
276 }else {
277 printk("FAILED\n");
278 }
279#endif
280 return 0;
281
282}
283
284
285#define SET_CONFIG_BITS(bus,devfn,where)\
286 ((1<<31) | ((bus) << 16) | ((devfn) << 8) | ((where) & ~3))
287
288#define CONFIG_CMD(dev, where) SET_CONFIG_BITS((dev)->bus->number,(dev)->devfn,where)
289
290/* This write to the galileo config registers, unlike the functions below, can
291 * be used before the PCI subsystem has started up
292 */
293static int __init write_config_to_galileo(int where, u32 val)
294{
295 GT_WRITE(PCI_CFG_ADR, SET_CONFIG_BITS(0, 0, where));
296
297 GT_WRITE(PCI_CFG_DATA, val);
298 return 0;
299}
300
301/* We exclude the galileo and slot 31, the galileo because I don't know how to stop
302 * the setup code shagging up the setup I have done on it, and 31 because the whole
303 * thing locks up if you try to access that slot (which doesn't exist of course anyway
304 */
305
306#define EXCLUDED_DEV(dev) ((dev->bus->number==0) && ((PCI_SLOT(dev->devfn)==0) || (PCI_SLOT(dev->devfn) == 31)))
307
308static int galileo_read_config_byte(struct pci_dev *dev, int where,
309 u8 * val)
310{
311
312
313 /* I suspect this doesn't work because this drives a special cycle ? */
314 if (EXCLUDED_DEV(dev)) {
315 *val = 0xff;
316 return PCIBIOS_SUCCESSFUL;
317 }
318 /* Start the config cycle */
319 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
320 /* Read back the result */
321 *val = GT_READ_BYTE(PCI_CFG_DATA + (where & 3));
322
323 return PCIBIOS_SUCCESSFUL;
324}
325
326
327static int galileo_read_config_word(struct pci_dev *dev, int where,
328 u16 * val)
329{
330
331 if (EXCLUDED_DEV(dev)) {
332 *val = 0xffff;
333 return PCIBIOS_SUCCESSFUL;
334 }
335
336 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
337 *val = GT_READ_SHORT(PCI_CFG_DATA + (where & 2));
338
339 return PCIBIOS_SUCCESSFUL;
340}
341
342
343static int galileo_read_config_dword(struct pci_dev *dev, int where,
344 u32 * val)
345{
346 if (EXCLUDED_DEV(dev)) {
347 *val = 0xffffffff;
348 return PCIBIOS_SUCCESSFUL;
349 }
350
351 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
352 *val = GT_READ(PCI_CFG_DATA);
353
354 return PCIBIOS_SUCCESSFUL;
355}
356
357static int galileo_write_config_byte(struct pci_dev *dev, int where,
358 u8 val)
359{
360 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
361
362 GT_WRITE_BYTE(PCI_CFG_DATA + (where & 3), val);
363
364 return PCIBIOS_SUCCESSFUL;
365}
366
367
368static int galileo_write_config_word(struct pci_dev *dev, int where,
369 u16 val)
370{
371 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
372
373 GT_WRITE_SHORT(PCI_CFG_DATA + (where & 2), val);
374
375 return PCIBIOS_SUCCESSFUL;
376}
377
378static int galileo_write_config_dword(struct pci_dev *dev, int where,
379 u32 val)
380{
381 GT_WRITE(PCI_CFG_ADR, CONFIG_CMD(dev, where));
382
383 GT_WRITE(PCI_CFG_DATA, val);
384
385 return PCIBIOS_SUCCESSFUL;
386}
387
388static struct pci_ops pci_config_ops = {
389 galileo_read_config_byte,
390 galileo_read_config_word,
391 galileo_read_config_dword,
392 galileo_write_config_byte,
393 galileo_write_config_word,
394 galileo_write_config_dword
395};
396
397
398/* Everything hangs off this */
399static struct pci_bus *pci_root_bus;
400
401
402static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
403{
404 return PCI_SLOT(dev->devfn);
405}
406
407static int __init map_od_irq(struct pci_dev *dev, u8 slot, u8 pin)
408{
409 /* Slot 1: Galileo
410 * Slot 2: PCI Slot 1
411 * Slot 3: PCI Slot 2
412 * Slot 4: ESS
413 */
414 switch (slot) {
415 case 2:
416 return OVERDRIVE_PCI_IRQ1;
417 case 3:
418 /* Note this assumes you have a hacked card in slot 2 */
419 return OVERDRIVE_PCI_IRQ2;
420 case 4:
421 return OVERDRIVE_ESS_IRQ;
422 default:
423 /* printk("PCI: Unexpected IRQ mapping request for slot %d\n", slot); */
424 return -1;
425 }
426}
427
428
429
430void __init
431pcibios_fixup_pbus_ranges(struct pci_bus *bus, struct pbus_set_ranges_data *ranges)
432{
433 ranges->io_start -= bus->resource[0]->start;
434 ranges->io_end -= bus->resource[0]->start;
435 ranges->mem_start -= bus->resource[1]->start;
436 ranges->mem_end -= bus->resource[1]->start;
437}
438
439static void __init pci_fixup_ide_bases(struct pci_dev *d)
440{
441 int i;
442
443 /*
444 * PCI IDE controllers use non-standard I/O port decoding, respect it.
445 */
446 if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
447 return;
448 printk("PCI: IDE base address fixup for %s\n", pci_name(d));
449 for(i=0; i<4; i++) {
450 struct resource *r = &d->resource[i];
451 if ((r->start & ~0x80) == 0x374) {
452 r->start |= 2;
453 r->end = r->start;
454 }
455 }
456}
457DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases);
458
459void __init pcibios_init(void)
460{
461 static struct resource galio,galmem;
462
463 /* Allocate the registers used by the Galileo */
464 galio.flags = IORESOURCE_IO;
465 galio.name = "Galileo GT64011";
466 galmem.flags = IORESOURCE_MEM|IORESOURCE_PREFETCH;
467 galmem.name = "Galileo GT64011 DRAM";
468
469 allocate_resource(&ioport_resource, &galio, 256,
470 GT64111_IO_BASE_ADDRESS,GT64111_IO_BASE_ADDRESS+256, 256, NULL, NULL);
471 allocate_resource(&iomem_resource, &galmem,PCI_DRAM_SIZE,
472 PHYSADDR(PCI_DRAM_BASE), PHYSADDR(PCI_DRAM_BASE)+PCI_DRAM_SIZE,
473 PCI_DRAM_SIZE, NULL, NULL);
474
475 /* ok, do the scan man */
476 pci_root_bus = pci_scan_bus(0, &pci_config_ops, NULL);
477
478 pci_assign_unassigned_resources();
479 pci_fixup_irqs(no_swizzle, map_od_irq);
480
481#ifdef TEST_DRAM
482 printk("Testing PCI DRAM - ");
483 if(test_dram(PCI_DRAM_BASE,PCI_DRAM_SIZE)) {
484 printk("Passed\n");
485 }else {
486 printk("FAILED\n");
487 }
488#endif
489
490}
491
492char * __init pcibios_setup(char *str)
493{
494 return str;
495}
496
497
498
499int pcibios_enable_device(struct pci_dev *dev)
500{
501
502 u16 cmd, old_cmd;
503 int idx;
504 struct resource *r;
505
506 pci_read_config_word(dev, PCI_COMMAND, &cmd);
507 old_cmd = cmd;
508 for (idx = 0; idx < 6; idx++) {
509 r = dev->resource + idx;
510 if (!r->start && r->end) {
511 printk(KERN_ERR
512 "PCI: Device %s not available because"
513 " of resource collisions\n",
514 pci_name(dev));
515 return -EINVAL;
516 }
517 if (r->flags & IORESOURCE_IO)
518 cmd |= PCI_COMMAND_IO;
519 if (r->flags & IORESOURCE_MEM)
520 cmd |= PCI_COMMAND_MEMORY;
521 }
522 if (cmd != old_cmd) {
523 printk("PCI: enabling device %s (%04x -> %04x)\n",
524 pci_name(dev), old_cmd, cmd);
525 pci_write_config_word(dev, PCI_COMMAND, cmd);
526 }
527 return 0;
528
529}
530
531/* We should do some optimisation work here I think. Ok for now though */
532void __init pcibios_fixup_bus(struct pci_bus *bus)
533{
534
535}
536
537void pcibios_align_resource(void *data, struct resource *res,
538 resource_size_t size)
539{
540}
541
542void __init pcibios_update_resource(struct pci_dev *dev, struct resource *root,
543 struct resource *res, int resource)
544{
545
546 unsigned long where, size;
547 u32 reg;
548
549
550 printk("PCI: Assigning %3s %08lx to %s\n",
551 res->flags & IORESOURCE_IO ? "IO" : "MEM",
552 res->start, dev->name);
553
554 where = PCI_BASE_ADDRESS_0 + resource * 4;
555 size = res->end - res->start;
556
557 pci_read_config_dword(dev, where, &reg);
558 reg = (reg & size) | (((u32) (res->start - root->start)) & ~size);
559 pci_write_config_dword(dev, where, reg);
560}
561
562
563void __init pcibios_update_irq(struct pci_dev *dev, int irq)
564{
565 printk("PCI: Assigning IRQ %02d to %s\n", irq, dev->name);
566 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
567}
568
569/*
570 * If we set up a device for bus mastering, we need to check the latency
571 * timer as certain crappy BIOSes forget to set it properly.
572 */
573unsigned int pcibios_max_latency = 255;
574
575void pcibios_set_master(struct pci_dev *dev)
576{
577 u8 lat;
578 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
579 if (lat < 16)
580 lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
581 else if (lat > pcibios_max_latency)
582 lat = pcibios_max_latency;
583 else
584 return;
585 printk("PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat);
586 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
587}
diff --git a/arch/sh/boards/overdrive/io.c b/arch/sh/boards/overdrive/io.c
deleted file mode 100644
index 4671b6b047bb..000000000000
--- a/arch/sh/boards/overdrive/io.c
+++ /dev/null
@@ -1,172 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file contains the I/O routines for use on the overdrive board
8 *
9 */
10
11#include <linux/types.h>
12#include <linux/delay.h>
13#include <asm/processor.h>
14#include <asm/io.h>
15#include <asm/addrspace.h>
16
17#include <asm/overdrive/overdrive.h>
18
19/*
20 * readX/writeX() are used to access memory mapped devices. On some
21 * architectures the memory mapped IO stuff needs to be accessed
22 * differently. On the SuperH architecture, we just read/write the
23 * memory location directly.
24 */
25
26#define dprintk(x...)
27
28/* Translates an IO address to where it is mapped in memory */
29
30#define io_addr(x) (((unsigned)(x))|PCI_GTIO_BASE)
31
32unsigned char od_inb(unsigned long port)
33{
34dprintk("od_inb(%x)\n", port);
35 return readb(io_addr(port)) & 0xff;
36}
37
38
39unsigned short od_inw(unsigned long port)
40{
41dprintk("od_inw(%x)\n", port);
42 return readw(io_addr(port)) & 0xffff;
43}
44
45unsigned int od_inl(unsigned long port)
46{
47dprintk("od_inl(%x)\n", port);
48 return readl(io_addr(port));
49}
50
51void od_outb(unsigned char value, unsigned long port)
52{
53dprintk("od_outb(%x, %x)\n", value, port);
54 writeb(value, io_addr(port));
55}
56
57void od_outw(unsigned short value, unsigned long port)
58{
59dprintk("od_outw(%x, %x)\n", value, port);
60 writew(value, io_addr(port));
61}
62
63void od_outl(unsigned int value, unsigned long port)
64{
65dprintk("od_outl(%x, %x)\n", value, port);
66 writel(value, io_addr(port));
67}
68
69/* This is horrible at the moment - needs more work to do something sensible */
70#define IO_DELAY() udelay(10)
71
72#define OUT_DELAY(x,type) \
73void od_out##x##_p(unsigned type value,unsigned long port){out##x(value,port);IO_DELAY();}
74
75#define IN_DELAY(x,type) \
76unsigned type od_in##x##_p(unsigned long port) {unsigned type tmp=in##x(port);IO_DELAY();return tmp;}
77
78
79OUT_DELAY(b,char)
80OUT_DELAY(w,short)
81OUT_DELAY(l,int)
82
83IN_DELAY(b,char)
84IN_DELAY(w,short)
85IN_DELAY(l,int)
86
87
88/* Now for the string version of these functions */
89void od_outsb(unsigned long port, const void *addr, unsigned long count)
90{
91 int i;
92 unsigned char *p = (unsigned char *) addr;
93
94 for (i = 0; i < count; i++, p++) {
95 outb(*p, port);
96 }
97}
98
99
100void od_insb(unsigned long port, void *addr, unsigned long count)
101{
102 int i;
103 unsigned char *p = (unsigned char *) addr;
104
105 for (i = 0; i < count; i++, p++) {
106 *p = inb(port);
107 }
108}
109
110/* For the 16 and 32 bit string functions, we have to worry about alignment.
111 * The SH does not do unaligned accesses, so we have to read as bytes and
112 * then write as a word or dword.
113 * This can be optimised a lot more, especially in the case where the data
114 * is aligned
115 */
116
117void od_outsw(unsigned long port, const void *addr, unsigned long count)
118{
119 int i;
120 unsigned short tmp;
121 unsigned char *p = (unsigned char *) addr;
122
123 for (i = 0; i < count; i++, p += 2) {
124 tmp = (*p) | ((*(p + 1)) << 8);
125 outw(tmp, port);
126 }
127}
128
129
130void od_insw(unsigned long port, void *addr, unsigned long count)
131{
132 int i;
133 unsigned short tmp;
134 unsigned char *p = (unsigned char *) addr;
135
136 for (i = 0; i < count; i++, p += 2) {
137 tmp = inw(port);
138 p[0] = tmp & 0xff;
139 p[1] = (tmp >> 8) & 0xff;
140 }
141}
142
143
144void od_outsl(unsigned long port, const void *addr, unsigned long count)
145{
146 int i;
147 unsigned tmp;
148 unsigned char *p = (unsigned char *) addr;
149
150 for (i = 0; i < count; i++, p += 4) {
151 tmp = (*p) | ((*(p + 1)) << 8) | ((*(p + 2)) << 16) |
152 ((*(p + 3)) << 24);
153 outl(tmp, port);
154 }
155}
156
157
158void od_insl(unsigned long port, void *addr, unsigned long count)
159{
160 int i;
161 unsigned tmp;
162 unsigned char *p = (unsigned char *) addr;
163
164 for (i = 0; i < count; i++, p += 4) {
165 tmp = inl(port);
166 p[0] = tmp & 0xff;
167 p[1] = (tmp >> 8) & 0xff;
168 p[2] = (tmp >> 16) & 0xff;
169 p[3] = (tmp >> 24) & 0xff;
170
171 }
172}
diff --git a/arch/sh/boards/overdrive/irq.c b/arch/sh/boards/overdrive/irq.c
deleted file mode 100644
index 5d730c70389e..000000000000
--- a/arch/sh/boards/overdrive/irq.c
+++ /dev/null
@@ -1,191 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Looks after interrupts on the overdrive board.
8 *
9 * Bases on the IPR irq system
10 */
11
12#include <linux/init.h>
13#include <linux/irq.h>
14
15#include <asm/system.h>
16#include <asm/io.h>
17
18#include <asm/overdrive/overdrive.h>
19
20struct od_data {
21 int overdrive_irq;
22 int irq_mask;
23};
24
25#define NUM_EXTERNAL_IRQS 16
26#define EXTERNAL_IRQ_NOT_IN_USE (-1)
27#define EXTERNAL_IRQ_NOT_ASSIGNED (-1)
28
29/*
30 * This table is used to determine what to program into the FPGA's CT register
31 * for the specified Linux IRQ.
32 *
33 * The irq_mask gives the interrupt number from the PCI board (PCI_Int(6:0))
34 * but is one greater than that because the because the FPGA treats 0
35 * as disabled, a value of 1 asserts PCI_Int0, and so on.
36 *
37 * The overdrive_irq specifies which of the eight interrupt sources generates
38 * that interrupt, and but is multiplied by four to give the bit offset into
39 * the CT register.
40 *
41 * The seven interrupts levels (SH4 IRL's) we have available here is hardwired
42 * by the EPLD. The assignments here of which PCI interrupt generates each
43 * level is arbitary.
44 */
45static struct od_data od_data_table[NUM_EXTERNAL_IRQS] = {
46 /* overdrive_irq , irq_mask */
47 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 0 */
48 {EXTERNAL_IRQ_NOT_ASSIGNED, 7}, /* 1 */
49 {EXTERNAL_IRQ_NOT_ASSIGNED, 6}, /* 2 */
50 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 3 */
51 {EXTERNAL_IRQ_NOT_ASSIGNED, 5}, /* 4 */
52 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 5 */
53 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 6 */
54 {EXTERNAL_IRQ_NOT_ASSIGNED, 4}, /* 7 */
55 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 8 */
56 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 9 */
57 {EXTERNAL_IRQ_NOT_ASSIGNED, 3}, /* 10 */
58 {EXTERNAL_IRQ_NOT_ASSIGNED, 2}, /* 11 */
59 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 12 */
60 {EXTERNAL_IRQ_NOT_ASSIGNED, 1}, /* 13 */
61 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE}, /* 14 */
62 {EXTERNAL_IRQ_NOT_ASSIGNED, EXTERNAL_IRQ_NOT_IN_USE} /* 15 */
63};
64
65static void set_od_data(int overdrive_irq, int irq)
66{
67 if (irq >= NUM_EXTERNAL_IRQS || irq < 0)
68 return;
69 od_data_table[irq].overdrive_irq = overdrive_irq << 2;
70}
71
72static void enable_od_irq(unsigned int irq);
73void disable_od_irq(unsigned int irq);
74
75/* shutdown is same as "disable" */
76#define shutdown_od_irq disable_od_irq
77
78static void mask_and_ack_od(unsigned int);
79static void end_od_irq(unsigned int irq);
80
81static unsigned int startup_od_irq(unsigned int irq)
82{
83 enable_od_irq(irq);
84 return 0; /* never anything pending */
85}
86
87static struct hw_interrupt_type od_irq_type = {
88 .typename = "Overdrive-IRQ",
89 .startup = startup_od_irq,
90 .shutdown = shutdown_od_irq,
91 .enable = enable_od_irq,
92 .disable = disable_od_irq,
93 .ack = mask_and_ack_od,
94 .end = end_od_irq
95};
96
97static void disable_od_irq(unsigned int irq)
98{
99 unsigned val, flags;
100 int overdrive_irq;
101 unsigned mask;
102
103 /* Not a valid interrupt */
104 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
105 return;
106
107 /* Is is necessary to use a cli here? Would a spinlock not be
108 * mroe efficient?
109 */
110 local_irq_save(flags);
111 overdrive_irq = od_data_table[irq].overdrive_irq;
112 if (overdrive_irq != EXTERNAL_IRQ_NOT_ASSIGNED) {
113 mask = ~(0x7 << overdrive_irq);
114 val = ctrl_inl(OVERDRIVE_INT_CT);
115 val &= mask;
116 ctrl_outl(val, OVERDRIVE_INT_CT);
117 }
118 local_irq_restore(flags);
119}
120
121static void enable_od_irq(unsigned int irq)
122{
123 unsigned val, flags;
124 int overdrive_irq;
125 unsigned mask;
126
127 /* Not a valid interrupt */
128 if (irq < 0 || irq >= NUM_EXTERNAL_IRQS)
129 return;
130
131 /* Set priority in OD back to original value */
132 local_irq_save(flags);
133 /* This one is not in use currently */
134 overdrive_irq = od_data_table[irq].overdrive_irq;
135 if (overdrive_irq != EXTERNAL_IRQ_NOT_ASSIGNED) {
136 val = ctrl_inl(OVERDRIVE_INT_CT);
137 mask = ~(0x7 << overdrive_irq);
138 val &= mask;
139 mask = od_data_table[irq].irq_mask << overdrive_irq;
140 val |= mask;
141 ctrl_outl(val, OVERDRIVE_INT_CT);
142 }
143 local_irq_restore(flags);
144}
145
146
147
148/* this functions sets the desired irq handler to be an overdrive type */
149static void __init make_od_irq(unsigned int irq)
150{
151 disable_irq_nosync(irq);
152 irq_desc[irq].chip = &od_irq_type;
153 disable_od_irq(irq);
154}
155
156
157static void mask_and_ack_od(unsigned int irq)
158{
159 disable_od_irq(irq);
160}
161
162static void end_od_irq(unsigned int irq)
163{
164 enable_od_irq(irq);
165}
166
167void __init init_overdrive_irq(void)
168{
169 int i;
170
171 /* Disable all interrupts */
172 ctrl_outl(0, OVERDRIVE_INT_CT);
173
174 /* Update interrupt pin mode to use encoded interrupts */
175 i = ctrl_inw(INTC_ICR);
176 i &= ~INTC_ICR_IRLM;
177 ctrl_outw(i, INTC_ICR);
178
179 for (i = 0; i < NUM_EXTERNAL_IRQS; i++) {
180 if (od_data_table[i].irq_mask != EXTERNAL_IRQ_NOT_IN_USE) {
181 make_od_irq(i);
182 } else if (i != 15) { // Cannot use imask on level 15
183 make_imask_irq(i);
184 }
185 }
186
187 /* Set up the interrupts */
188 set_od_data(OVERDRIVE_PCI_INTA, OVERDRIVE_PCI_IRQ1);
189 set_od_data(OVERDRIVE_PCI_INTB, OVERDRIVE_PCI_IRQ2);
190 set_od_data(OVERDRIVE_AUDIO_INT, OVERDRIVE_ESS_IRQ);
191}
diff --git a/arch/sh/boards/overdrive/led.c b/arch/sh/boards/overdrive/led.c
deleted file mode 100644
index 860d7f204a4e..000000000000
--- a/arch/sh/boards/overdrive/led.c
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 * linux/arch/sh/overdrive/led.c
3 *
4 * Copyright (C) 1999 Stuart Menefy <stuart.menefy@st.com>
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * This file contains an Overdrive specific LED feature.
10 */
11
12#include <asm/system.h>
13#include <asm/io.h>
14#include <asm/overdrive/overdrive.h>
15
16static void mach_led(int position, int value)
17{
18 unsigned long flags;
19 unsigned long reg;
20
21 local_irq_save(flags);
22
23 reg = readl(OVERDRIVE_CTRL);
24 if (value) {
25 reg |= (1<<3);
26 } else {
27 reg &= ~(1<<3);
28 }
29 writel(reg, OVERDRIVE_CTRL);
30
31 local_irq_restore(flags);
32}
33
34#ifdef CONFIG_HEARTBEAT
35
36#include <linux/sched.h>
37
38/* acts like an actual heart beat -- ie thump-thump-pause... */
39void heartbeat_od(void)
40{
41 static unsigned cnt = 0, period = 0, dist = 0;
42
43 if (cnt == 0 || cnt == dist)
44 mach_led( -1, 1);
45 else if (cnt == 7 || cnt == dist+7)
46 mach_led( -1, 0);
47
48 if (++cnt > period) {
49 cnt = 0;
50 /* The hyperbolic function below modifies the heartbeat period
51 * length in dependency of the current (5min) load. It goes
52 * through the points f(0)=126, f(1)=86, f(5)=51,
53 * f(inf)->30. */
54 period = ((672<<FSHIFT)/(5*avenrun[0]+(7<<FSHIFT))) + 30;
55 dist = period / 4;
56 }
57}
58#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/overdrive/mach.c b/arch/sh/boards/overdrive/mach.c
deleted file mode 100644
index 2834a03ae477..000000000000
--- a/arch/sh/boards/overdrive/mach.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * linux/arch/sh/overdrive/mach.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the STMicroelectronics Overdrive
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/machvec_init.h>
17
18#include <asm/io_unknown.h>
19#include <asm/io_generic.h>
20#include <asm/overdrive/io.h>
21
22void heartbeat_od(void);
23void init_overdrive_irq(void);
24void galileo_pcibios_init(void);
25
26/*
27 * The Machine Vector
28 */
29
30struct sh_machine_vector mv_od __initmv = {
31 .mv_nr_irqs = 48,
32
33 .mv_inb = od_inb,
34 .mv_inw = od_inw,
35 .mv_inl = od_inl,
36 .mv_outb = od_outb,
37 .mv_outw = od_outw,
38 .mv_outl = od_outl,
39
40 .mv_inb_p = od_inb_p,
41 .mv_inw_p = od_inw_p,
42 .mv_inl_p = od_inl_p,
43 .mv_outb_p = od_outb_p,
44 .mv_outw_p = od_outw_p,
45 .mv_outl_p = od_outl_p,
46
47 .mv_insb = od_insb,
48 .mv_insw = od_insw,
49 .mv_insl = od_insl,
50 .mv_outsb = od_outsb,
51 .mv_outsw = od_outsw,
52 .mv_outsl = od_outsl,
53
54#ifdef CONFIG_PCI
55 .mv_init_irq = init_overdrive_irq,
56#endif
57#ifdef CONFIG_HEARTBEAT
58 .mv_heartbeat = heartbeat_od,
59#endif
60};
61
62ALIAS_MV(od)
diff --git a/arch/sh/boards/overdrive/pcidma.c b/arch/sh/boards/overdrive/pcidma.c
deleted file mode 100644
index 1c9bfeda00b7..000000000000
--- a/arch/sh/boards/overdrive/pcidma.c
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Dynamic DMA mapping support.
8 *
9 * On the overdrive, we can only DMA from memory behind the PCI bus!
10 * this means that all DMA'able memory must come from there.
11 * this restriction will not apply to later boards.
12 */
13
14#include <linux/types.h>
15#include <linux/mm.h>
16#include <linux/string.h>
17#include <linux/pci.h>
18#include <asm/io.h>
19
20void *pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
21 dma_addr_t * dma_handle)
22{
23 void *ret;
24 int gfp = GFP_ATOMIC;
25
26 printk("BUG: pci_alloc_consistent() called - not yet supported\n");
27 /* We ALWAYS need DMA memory on the overdrive hardware,
28 * due to it's extreme weirdness
29 * Need to flush the cache here as well, since the memory
30 * can still be seen through the cache!
31 */
32 gfp |= GFP_DMA;
33 ret = (void *) __get_free_pages(gfp, get_order(size));
34
35 if (ret != NULL) {
36 memset(ret, 0, size);
37 *dma_handle = virt_to_bus(ret);
38 }
39 return ret;
40}
41
42void pci_free_consistent(struct pci_dev *hwdev, size_t size,
43 void *vaddr, dma_addr_t dma_handle)
44{
45 free_pages((unsigned long) vaddr, get_order(size));
46}
diff --git a/arch/sh/boards/overdrive/setup.c b/arch/sh/boards/overdrive/setup.c
deleted file mode 100644
index a3a7744c2047..000000000000
--- a/arch/sh/boards/overdrive/setup.c
+++ /dev/null
@@ -1,36 +0,0 @@
1/*
2 * arch/sh/overdrive/setup.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * STMicroelectronics Overdrive Support.
10 */
11
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <asm/io.h>
15
16#include <asm/overdrive/overdrive.h>
17#include <asm/overdrive/fpga.h>
18
19const char *get_system_type(void)
20{
21 return "SH7750 Overdrive";
22}
23
24/*
25 * Initialize the board
26 */
27int __init platform_setup(void)
28{
29#ifdef CONFIG_PCI
30 init_overdrive_fpga();
31 galileo_init();
32#endif
33
34 /* Enable RS232 receive buffers */
35 writel(0x1e, OVERDRIVE_CTRL);
36}
diff --git a/arch/sh/boards/renesas/edosk7705/Makefile b/arch/sh/boards/renesas/edosk7705/Makefile
index 7fccbf2e4a1d..14bdd531f116 100644
--- a/arch/sh/boards/renesas/edosk7705/Makefile
+++ b/arch/sh/boards/renesas/edosk7705/Makefile
@@ -1,10 +1,6 @@
1# 1#
2# Makefile for the EDOSK7705 specific parts of the kernel 2# Makefile for the EDOSK7705 specific parts of the kernel
3# 3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8 4
9obj-y := setup.o io.o 5obj-y := setup.o io.o
10 6
diff --git a/arch/sh/boards/renesas/edosk7705/setup.c b/arch/sh/boards/renesas/edosk7705/setup.c
index ba143fa4afaa..ec5be0107719 100644
--- a/arch/sh/boards/renesas/edosk7705/setup.c
+++ b/arch/sh/boards/renesas/edosk7705/setup.c
@@ -8,19 +8,21 @@
8 * Modified for edosk7705 development 8 * Modified for edosk7705 development
9 * board by S. Dunn, 2003. 9 * board by S. Dunn, 2003.
10 */ 10 */
11
12#include <linux/init.h> 11#include <linux/init.h>
13#include <asm/machvec.h> 12#include <asm/machvec.h>
14#include <asm/machvec_init.h>
15#include <asm/edosk7705/io.h> 13#include <asm/edosk7705/io.h>
16 14
17static void init_edosk7705(void); 15static void __init sh_edosk7705_init_irq(void)
16{
17 /* This is the Ethernet interrupt */
18 make_imask_irq(0x09);
19}
18 20
19/* 21/*
20 * The Machine Vector 22 * The Machine Vector
21 */ 23 */
22
23struct sh_machine_vector mv_edosk7705 __initmv = { 24struct sh_machine_vector mv_edosk7705 __initmv = {
25 .mv_name = "EDOSK7705",
24 .mv_nr_irqs = 80, 26 .mv_nr_irqs = 80,
25 27
26 .mv_inb = sh_edosk7705_inb, 28 .mv_inb = sh_edosk7705_inb,
@@ -37,23 +39,6 @@ struct sh_machine_vector mv_edosk7705 __initmv = {
37 .mv_outsl = sh_edosk7705_outsl, 39 .mv_outsl = sh_edosk7705_outsl,
38 40
39 .mv_isa_port2addr = sh_edosk7705_isa_port2addr, 41 .mv_isa_port2addr = sh_edosk7705_isa_port2addr,
40 .mv_init_irq = init_edosk7705, 42 .mv_init_irq = sh_edosk7705_init_irq,
41}; 43};
42ALIAS_MV(edosk7705) 44ALIAS_MV(edosk7705)
43
44static void __init init_edosk7705(void)
45{
46 /* This is the Ethernet interrupt */
47 make_imask_irq(0x09);
48}
49
50const char *get_system_type(void)
51{
52 return "EDOSK7705";
53}
54
55void __init platform_setup(void)
56{
57 /* Nothing .. */
58}
59
diff --git a/arch/sh/boards/renesas/hs7751rvoip/Kconfig b/arch/sh/boards/renesas/hs7751rvoip/Kconfig
new file mode 100644
index 000000000000..1743be477be5
--- /dev/null
+++ b/arch/sh/boards/renesas/hs7751rvoip/Kconfig
@@ -0,0 +1,12 @@
1if SH_HS7751RVOIP
2
3menu "HS7751RVoIP options"
4
5config HS7751RVOIP_CODEC
6 bool "Support VoIP Codec section"
7 help
8 Selecting this option will support CODEC section.
9
10endmenu
11
12endif
diff --git a/arch/sh/boards/renesas/hs7751rvoip/Makefile b/arch/sh/boards/renesas/hs7751rvoip/Makefile
index e8b4109ace11..e626377c55ee 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/Makefile
+++ b/arch/sh/boards/renesas/hs7751rvoip/Makefile
@@ -1,12 +1,8 @@
1# 1#
2# Makefile for the HS7751RVoIP specific parts of the kernel 2# Makefile for the HS7751RVoIP specific parts of the kernel
3# 3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8 4
9obj-y := mach.o setup.o io.o irq.o led.o 5obj-y := setup.o io.o irq.o
10 6
11obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
12 8
diff --git a/arch/sh/boards/renesas/hs7751rvoip/io.c b/arch/sh/boards/renesas/hs7751rvoip/io.c
index 3a1abfa2fefb..9ea1136b219b 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/io.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/io.c
@@ -10,21 +10,16 @@
10 * placeholder code from io_hs7751rvoip.c left in with the 10 * placeholder code from io_hs7751rvoip.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 11 * expectation of later SuperIO and PCMCIA access.
12 */ 12 */
13
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/types.h> 14#include <linux/types.h>
15#include <linux/module.h>
16#include <linux/pci.h>
16#include <asm/io.h> 17#include <asm/io.h>
17#include <asm/hs7751rvoip/hs7751rvoip.h> 18#include <asm/hs7751rvoip/hs7751rvoip.h>
18#include <asm/addrspace.h> 19#include <asm/addrspace.h>
19 20
20#include <linux/module.h>
21#include <linux/pci.h>
22#include "../../../drivers/pci/pci-sh7751.h"
23
24extern void *area5_io8_base; /* Area 5 8bit I/O Base address */
25extern void *area6_io8_base; /* Area 6 8bit I/O Base address */ 21extern void *area6_io8_base; /* Area 6 8bit I/O Base address */
26extern void *area5_io16_base; /* Area 5 16bit I/O Base address */ 22extern void *area5_io16_base; /* Area 5 16bit I/O Base address */
27extern void *area6_io16_base; /* Area 6 16bit I/O Base address */
28 23
29/* 24/*
30 * The 7751R HS7751RVoIP uses the built-in PCI controller (PCIC) 25 * The 7751R HS7751RVoIP uses the built-in PCI controller (PCIC)
@@ -33,25 +28,8 @@ extern void *area6_io16_base; /* Area 6 16bit I/O Base address */
33 * like the other Solution Engine boards. 28 * like the other Solution Engine boards.
34 */ 29 */
35 30
36#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
37#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
38#define PCI_IO_AREA SH7751_PCI_IO_BASE
39#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
40
41#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
42
43#if defined(CONFIG_HS7751RVOIP_CODEC)
44#define CODEC_IO_BASE 0x1000 31#define CODEC_IO_BASE 0x1000
45#endif 32#define CODEC_IOMAP(a) ((unsigned long)area6_io8_base + ((a) - CODEC_IO_BASE))
46
47#define maybebadio(name,port) \
48 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
49 #name, (port), (__u32) __builtin_return_address(0))
50
51static inline void delay(void)
52{
53 ctrl_inw(0xa0000000);
54}
55 33
56static inline unsigned long port2adr(unsigned int port) 34static inline unsigned long port2adr(unsigned int port)
57{ 35{
@@ -59,9 +37,10 @@ static inline unsigned long port2adr(unsigned int port)
59 if (port == 0x3f6) 37 if (port == 0x3f6)
60 return ((unsigned long)area5_io16_base + 0x0c); 38 return ((unsigned long)area5_io16_base + 0x0c);
61 else 39 else
62 return ((unsigned long)area5_io16_base + 0x800 + ((port-0x1f0) << 1)); 40 return ((unsigned long)area5_io16_base + 0x800 +
41 ((port-0x1f0) << 1));
63 else 42 else
64 maybebadio(port2adr, (unsigned long)port); 43 maybebadio((unsigned long)port);
65 return port; 44 return port;
66} 45}
67 46
@@ -78,25 +57,10 @@ static inline int shifted_port(unsigned long port)
78} 57}
79 58
80#if defined(CONFIG_HS7751RVOIP_CODEC) 59#if defined(CONFIG_HS7751RVOIP_CODEC)
81static inline int 60#define codec_port(port) \
82codec_port(unsigned long port) 61 ((CODEC_IO_BASE <= (port)) && ((port) < (CODEC_IO_BASE + 0x20)))
83{
84 if (CODEC_IO_BASE <= port && port < (CODEC_IO_BASE+0x20))
85 return 1;
86 else
87 return 0;
88}
89#endif
90
91/* In case someone configures the kernel w/o PCI support: in that */
92/* scenario, don't ever bother to check for PCI-window addresses */
93
94/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
95#if defined(CONFIG_PCI)
96#define CHECK_SH7751_PCIIO(port) \
97 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
98#else 62#else
99#define CHECK_SH7751_PCIIO(port) (0) 63#define codec_port(port) (0)
100#endif 64#endif
101 65
102/* 66/*
@@ -109,15 +73,13 @@ codec_port(unsigned long port)
109unsigned char hs7751rvoip_inb(unsigned long port) 73unsigned char hs7751rvoip_inb(unsigned long port)
110{ 74{
111 if (PXSEG(port)) 75 if (PXSEG(port))
112 return *(volatile unsigned char *)port; 76 return ctrl_inb(port);
113#if defined(CONFIG_HS7751RVOIP_CODEC)
114 else if (codec_port(port)) 77 else if (codec_port(port))
115 return *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); 78 return ctrl_inb(CODEC_IOMAP(port));
116#endif 79 else if (is_pci_ioaddr(port) || shifted_port(port))
117 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 80 return ctrl_inb(pci_ioaddr(port));
118 return *(volatile unsigned char *)PCI_IOMAP(port);
119 else 81 else
120 return (*(volatile unsigned short *)port2adr(port) & 0xff); 82 return ctrl_inw(port2adr(port)) & 0xff;
121} 83}
122 84
123unsigned char hs7751rvoip_inb_p(unsigned long port) 85unsigned char hs7751rvoip_inb_p(unsigned long port)
@@ -125,38 +87,36 @@ unsigned char hs7751rvoip_inb_p(unsigned long port)
125 unsigned char v; 87 unsigned char v;
126 88
127 if (PXSEG(port)) 89 if (PXSEG(port))
128 v = *(volatile unsigned char *)port; 90 v = ctrl_inb(port);
129#if defined(CONFIG_HS7751RVOIP_CODEC)
130 else if (codec_port(port)) 91 else if (codec_port(port))
131 v = *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); 92 v = ctrl_inb(CODEC_IOMAP(port));
132#endif 93 else if (is_pci_ioaddr(port) || shifted_port(port))
133 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 94 v = ctrl_inb(pci_ioaddr(port));
134 v = *(volatile unsigned char *)PCI_IOMAP(port);
135 else 95 else
136 v = (*(volatile unsigned short *)port2adr(port) & 0xff); 96 v = ctrl_inw(port2adr(port)) & 0xff;
137 delay(); 97 ctrl_delay();
138 return v; 98 return v;
139} 99}
140 100
141unsigned short hs7751rvoip_inw(unsigned long port) 101unsigned short hs7751rvoip_inw(unsigned long port)
142{ 102{
143 if (PXSEG(port)) 103 if (PXSEG(port))
144 return *(volatile unsigned short *)port; 104 return ctrl_inw(port);
145 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 105 else if (is_pci_ioaddr(port) || shifted_port(port))
146 return *(volatile unsigned short *)PCI_IOMAP(port); 106 return ctrl_inw(pci_ioaddr(port));
147 else 107 else
148 maybebadio(inw, port); 108 maybebadio(port);
149 return 0; 109 return 0;
150} 110}
151 111
152unsigned int hs7751rvoip_inl(unsigned long port) 112unsigned int hs7751rvoip_inl(unsigned long port)
153{ 113{
154 if (PXSEG(port)) 114 if (PXSEG(port))
155 return *(volatile unsigned long *)port; 115 return ctrl_inl(port);
156 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 116 else if (is_pci_ioaddr(port) || shifted_port(port))
157 return *(volatile unsigned long *)PCI_IOMAP(port); 117 return ctrl_inl(pci_ioaddr(port));
158 else 118 else
159 maybebadio(inl, port); 119 maybebadio(port);
160 return 0; 120 return 0;
161} 121}
162 122
@@ -164,146 +124,160 @@ void hs7751rvoip_outb(unsigned char value, unsigned long port)
164{ 124{
165 125
166 if (PXSEG(port)) 126 if (PXSEG(port))
167 *(volatile unsigned char *)port = value; 127 ctrl_outb(value, port);
168#if defined(CONFIG_HS7751RVOIP_CODEC)
169 else if (codec_port(port)) 128 else if (codec_port(port))
170 *(volatile unsigned cjar *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = value; 129 ctrl_outb(value, CODEC_IOMAP(port));
171#endif 130 else if (is_pci_ioaddr(port) || shifted_port(port))
172 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 131 ctrl_outb(value, pci_ioaddr(port));
173 *(unsigned char *)PCI_IOMAP(port) = value;
174 else 132 else
175 *(volatile unsigned short *)port2adr(port) = value; 133 ctrl_outb(value, port2adr(port));
176} 134}
177 135
178void hs7751rvoip_outb_p(unsigned char value, unsigned long port) 136void hs7751rvoip_outb_p(unsigned char value, unsigned long port)
179{ 137{
180 if (PXSEG(port)) 138 if (PXSEG(port))
181 *(volatile unsigned char *)port = value; 139 ctrl_outb(value, port);
182#if defined(CONFIG_HS7751RVOIP_CODEC)
183 else if (codec_port(port)) 140 else if (codec_port(port))
184 *(volatile unsigned cjar *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = value; 141 ctrl_outb(value, CODEC_IOMAP(port));
185#endif 142 else if (is_pci_ioaddr(port) || shifted_port(port))
186 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 143 ctrl_outb(value, pci_ioaddr(port));
187 *(unsigned char *)PCI_IOMAP(port) = value;
188 else 144 else
189 *(volatile unsigned short *)port2adr(port) = value; 145 ctrl_outw(value, port2adr(port));
190 delay(); 146
147 ctrl_delay();
191} 148}
192 149
193void hs7751rvoip_outw(unsigned short value, unsigned long port) 150void hs7751rvoip_outw(unsigned short value, unsigned long port)
194{ 151{
195 if (PXSEG(port)) 152 if (PXSEG(port))
196 *(volatile unsigned short *)port = value; 153 ctrl_outw(value, port);
197 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 154 else if (is_pci_ioaddr(port) || shifted_port(port))
198 *(unsigned short *)PCI_IOMAP(port) = value; 155 ctrl_outw(value, pci_ioaddr(port));
199 else 156 else
200 maybebadio(outw, port); 157 maybebadio(port);
201} 158}
202 159
203void hs7751rvoip_outl(unsigned int value, unsigned long port) 160void hs7751rvoip_outl(unsigned int value, unsigned long port)
204{ 161{
205 if (PXSEG(port)) 162 if (PXSEG(port))
206 *(volatile unsigned long *)port = value; 163 ctrl_outl(value, port);
207 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 164 else if (is_pci_ioaddr(port) || shifted_port(port))
208 *((unsigned long *)PCI_IOMAP(port)) = value; 165 ctrl_outl(value, pci_ioaddr(port));
209 else 166 else
210 maybebadio(outl, port); 167 maybebadio(port);
211} 168}
212 169
213void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count) 170void hs7751rvoip_insb(unsigned long port, void *addr, unsigned long count)
214{ 171{
172 u8 *buf = addr;
173
215 if (PXSEG(port)) 174 if (PXSEG(port))
216 while (count--) *((unsigned char *) addr)++ = *(volatile unsigned char *)port; 175 while (count--)
217#if defined(CONFIG_HS7751RVOIP_CODEC) 176 *buf++ = ctrl_inb(port);
218 else if (codec_port(port)) 177 else if (codec_port(port))
219 while (count--) *((unsigned char *) addr)++ = *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)); 178 while (count--)
220#endif 179 *buf++ = ctrl_inb(CODEC_IOMAP(port));
221 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 180 else if (is_pci_ioaddr(port) || shifted_port(port)) {
222 volatile __u8 *bp = (__u8 *)PCI_IOMAP(port); 181 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
223 182
224 while (count--) *((volatile unsigned char *) addr)++ = *bp; 183 while (count--)
184 *buf++ = *bp;
225 } else { 185 } else {
226 volatile __u16 *p = (volatile unsigned short *)port2adr(port); 186 volatile u16 *p = (volatile u16 *)port2adr(port);
227 187
228 while (count--) *((unsigned char *) addr)++ = *p & 0xff; 188 while (count--)
189 *buf++ = *p & 0xff;
229 } 190 }
230} 191}
231 192
232void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count) 193void hs7751rvoip_insw(unsigned long port, void *addr, unsigned long count)
233{ 194{
234 volatile __u16 *p; 195 volatile u16 *p;
196 u16 *buf = addr;
235 197
236 if (PXSEG(port)) 198 if (PXSEG(port))
237 p = (volatile unsigned short *)port; 199 p = (volatile u16 *)port;
238 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 200 else if (is_pci_ioaddr(port) || shifted_port(port))
239 p = (volatile unsigned short *)PCI_IOMAP(port); 201 p = (volatile u16 *)pci_ioaddr(port);
240 else 202 else
241 p = (volatile unsigned short *)port2adr(port); 203 p = (volatile u16 *)port2adr(port);
242 while (count--) *((__u16 *) addr)++ = *p; 204 while (count--)
205 *buf++ = *p;
243} 206}
244 207
245void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count) 208void hs7751rvoip_insl(unsigned long port, void *addr, unsigned long count)
246{ 209{
247 if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) {
248 volatile __u32 *p = (__u32 *)PCI_IOMAP(port);
249 210
250 while (count--) *((__u32 *) addr)++ = *p; 211 if (is_pci_ioaddr(port) || shifted_port(port)) {
212 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
213 u32 *buf = addr;
214
215 while (count--)
216 *buf++ = *p;
251 } else 217 } else
252 maybebadio(insl, port); 218 maybebadio(port);
253} 219}
254 220
255void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count) 221void hs7751rvoip_outsb(unsigned long port, const void *addr, unsigned long count)
256{ 222{
223 const u8 *buf = addr;
224
257 if (PXSEG(port)) 225 if (PXSEG(port))
258 while (count--) *(volatile unsigned char *)port = *((unsigned char *) addr)++; 226 while (count--)
259#if defined(CONFIG_HS7751RVOIP_CODEC) 227 ctrl_outb(*buf++, port);
260 else if (codec_port(port)) 228 else if (codec_port(port))
261 while (count--) *(volatile unsigned char *)((unsigned long)area6_io8_base+(port-CODEC_IO_BASE)) = *((unsigned char *) addr)++; 229 while (count--)
262#endif 230 ctrl_outb(*buf++, CODEC_IOMAP(port));
263 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 231 else if (is_pci_ioaddr(port) || shifted_port(port)) {
264 volatile __u8 *bp = (__u8 *)PCI_IOMAP(port); 232 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
265 233
266 while (count--) *bp = *((volatile unsigned char *) addr)++; 234 while (count--)
235 *bp = *buf++;
267 } else { 236 } else {
268 volatile __u16 *p = (volatile unsigned short *)port2adr(port); 237 volatile u16 *p = (volatile u16 *)port2adr(port);
269 238
270 while (count--) *p = *((unsigned char *) addr)++; 239 while (count--)
240 *p = *buf++;
271 } 241 }
272} 242}
273 243
274void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count) 244void hs7751rvoip_outsw(unsigned long port, const void *addr, unsigned long count)
275{ 245{
276 volatile __u16 *p; 246 volatile u16 *p;
247 const u16 *buf = addr;
277 248
278 if (PXSEG(port)) 249 if (PXSEG(port))
279 p = (volatile unsigned short *)port; 250 p = (volatile u16 *)port;
280 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 251 else if (is_pci_ioaddr(port) || shifted_port(port))
281 p = (volatile unsigned short *)PCI_IOMAP(port); 252 p = (volatile u16 *)pci_ioaddr(port);
282 else 253 else
283 p = (volatile unsigned short *)port2adr(port); 254 p = (volatile u16 *)port2adr(port);
284 while (count--) *p = *((__u16 *) addr)++; 255
256 while (count--)
257 *p = *buf++;
285} 258}
286 259
287void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count) 260void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count)
288{ 261{
289 if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 262 const u32 *buf = addr;
290 volatile __u32 *p = (__u32 *)PCI_IOMAP(port);
291 263
292 while (count--) *p = *((__u32 *) addr)++; 264 if (is_pci_ioaddr(port) || shifted_port(port)) {
265 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
266
267 while (count--)
268 *p = *buf++;
293 } else 269 } else
294 maybebadio(outsl, port); 270 maybebadio(port);
295} 271}
296 272
297void *hs7751rvoip_ioremap(unsigned long offset, unsigned long size) 273void __iomem *hs7751rvoip_ioport_map(unsigned long port, unsigned int size)
298{ 274{
299 if (offset >= 0xfd000000) 275 if (PXSEG(port))
300 return (void *)offset; 276 return (void __iomem *)port;
301 else 277 else if (unlikely(codec_port(port) && (size == 1)))
302 return (void *)P2SEGADDR(offset); 278 return (void __iomem *)CODEC_IOMAP(port);
303} 279 else if (is_pci_ioaddr(port))
304EXPORT_SYMBOL(hs7751rvoip_ioremap); 280 return (void __iomem *)pci_ioaddr(port);
305 281
306unsigned long hs7751rvoip_isa_port2addr(unsigned long offset) 282 return (void __iomem *)port2adr(port);
307{
308 return port2adr(offset);
309} 283}
diff --git a/arch/sh/boards/renesas/hs7751rvoip/irq.c b/arch/sh/boards/renesas/hs7751rvoip/irq.c
index 705b7ddcb0d2..c617b188258a 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/irq.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/irq.c
@@ -35,30 +35,24 @@ static unsigned int startup_hs7751rvoip_irq(unsigned int irq)
35 35
36static void disable_hs7751rvoip_irq(unsigned int irq) 36static void disable_hs7751rvoip_irq(unsigned int irq)
37{ 37{
38 unsigned long flags;
39 unsigned short val; 38 unsigned short val;
40 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]); 39 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
41 40
42 /* Set the priority in IPR to 0 */ 41 /* Set the priority in IPR to 0 */
43 local_irq_save(flags);
44 val = ctrl_inw(IRLCNTR3); 42 val = ctrl_inw(IRLCNTR3);
45 val &= mask; 43 val &= mask;
46 ctrl_outw(val, IRLCNTR3); 44 ctrl_outw(val, IRLCNTR3);
47 local_irq_restore(flags);
48} 45}
49 46
50static void enable_hs7751rvoip_irq(unsigned int irq) 47static void enable_hs7751rvoip_irq(unsigned int irq)
51{ 48{
52 unsigned long flags;
53 unsigned short val; 49 unsigned short val;
54 unsigned short value = (0x0001 << mask_pos[irq]); 50 unsigned short value = (0x0001 << mask_pos[irq]);
55 51
56 /* Set priority in IPR back to original value */ 52 /* Set priority in IPR back to original value */
57 local_irq_save(flags);
58 val = ctrl_inw(IRLCNTR3); 53 val = ctrl_inw(IRLCNTR3);
59 val |= value; 54 val |= value;
60 ctrl_outw(val, IRLCNTR3); 55 ctrl_outw(val, IRLCNTR3);
61 local_irq_restore(flags);
62} 56}
63 57
64static void ack_hs7751rvoip_irq(unsigned int irq) 58static void ack_hs7751rvoip_irq(unsigned int irq)
diff --git a/arch/sh/boards/renesas/hs7751rvoip/led.c b/arch/sh/boards/renesas/hs7751rvoip/led.c
deleted file mode 100644
index b6608fff9f38..000000000000
--- a/arch/sh/boards/renesas/hs7751rvoip/led.c
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * linux/arch/sh/kernel/setup_hs7751rvoip.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Renesas Technology Sales HS7751RVoIP Support.
7 *
8 * Modified for HS7751RVoIP by
9 * Atom Create Engineering Co., Ltd. 2002.
10 * Lineo uSolutions, Inc. 2003.
11 */
12
13#include <asm/io.h>
14#include <asm/hs7751rvoip/hs7751rvoip.h>
15
16extern unsigned int debug_counter;
17
18void debug_led_disp(void)
19{
20 unsigned short value;
21
22 value = (unsigned char)debug_counter++;
23 ctrl_outb((0xf0|value), PA_OUTPORTR);
24 if (value == 0x0f)
25 debug_counter = 0;
26}
diff --git a/arch/sh/boards/renesas/hs7751rvoip/mach.c b/arch/sh/boards/renesas/hs7751rvoip/mach.c
deleted file mode 100644
index caf967f77c61..000000000000
--- a/arch/sh/boards/renesas/hs7751rvoip/mach.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * linux/arch/sh/kernel/mach_hs7751rvoip.c
3 *
4 * Minor tweak of mach_se.c file to reference hs7751rvoip-specific items.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the Renesas Technology sales HS7751RVoIP
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/irq.h>
17#include <asm/hs7751rvoip/io.h>
18
19extern void init_hs7751rvoip_IRQ(void);
20extern void *hs7751rvoip_ioremap(unsigned long, unsigned long);
21
22/*
23 * The Machine Vector
24 */
25
26struct sh_machine_vector mv_hs7751rvoip __initmv = {
27 .mv_nr_irqs = 72,
28
29 .mv_inb = hs7751rvoip_inb,
30 .mv_inw = hs7751rvoip_inw,
31 .mv_inl = hs7751rvoip_inl,
32 .mv_outb = hs7751rvoip_outb,
33 .mv_outw = hs7751rvoip_outw,
34 .mv_outl = hs7751rvoip_outl,
35
36 .mv_inb_p = hs7751rvoip_inb_p,
37 .mv_inw_p = hs7751rvoip_inw,
38 .mv_inl_p = hs7751rvoip_inl,
39 .mv_outb_p = hs7751rvoip_outb_p,
40 .mv_outw_p = hs7751rvoip_outw,
41 .mv_outl_p = hs7751rvoip_outl,
42
43 .mv_insb = hs7751rvoip_insb,
44 .mv_insw = hs7751rvoip_insw,
45 .mv_insl = hs7751rvoip_insl,
46 .mv_outsb = hs7751rvoip_outsb,
47 .mv_outsw = hs7751rvoip_outsw,
48 .mv_outsl = hs7751rvoip_outsl,
49
50 .mv_ioremap = hs7751rvoip_ioremap,
51 .mv_isa_port2addr = hs7751rvoip_isa_port2addr,
52 .mv_init_irq = init_hs7751rvoip_IRQ,
53};
54ALIAS_MV(hs7751rvoip)
diff --git a/arch/sh/boards/renesas/hs7751rvoip/setup.c b/arch/sh/boards/renesas/hs7751rvoip/setup.c
index 29fb5ff70fb5..0414c15c3458 100644
--- a/arch/sh/boards/renesas/hs7751rvoip/setup.c
+++ b/arch/sh/boards/renesas/hs7751rvoip/setup.c
@@ -1,44 +1,38 @@
1/* 1/*
2 * linux/arch/sh/kernel/setup_hs7751rvoip.c 2 * Renesas Technology Sales HS7751RVoIP Support.
3 * 3 *
4 * Copyright (C) 2000 Kazumoto Kojima 4 * Copyright (C) 2000 Kazumoto Kojima
5 * 5 *
6 * Renesas Technology Sales HS7751RVoIP Support.
7 *
8 * Modified for HS7751RVoIP by 6 * Modified for HS7751RVoIP by
9 * Atom Create Engineering Co., Ltd. 2002. 7 * Atom Create Engineering Co., Ltd. 2002.
10 * Lineo uSolutions, Inc. 2003. 8 * Lineo uSolutions, Inc. 2003.
11 */ 9 */
12
13#include <linux/init.h> 10#include <linux/init.h>
14#include <linux/irq.h> 11#include <linux/irq.h>
15 12#include <linux/mm.h>
13#include <linux/vmalloc.h>
16#include <linux/hdreg.h> 14#include <linux/hdreg.h>
17#include <linux/ide.h> 15#include <linux/ide.h>
16#include <linux/pm.h>
18#include <asm/io.h> 17#include <asm/io.h>
19#include <asm/hs7751rvoip/hs7751rvoip.h> 18#include <asm/hs7751rvoip/hs7751rvoip.h>
19#include <asm/machvec.h>
20#include <asm/rtc.h>
21#include <asm/irq.h>
20 22
21#include <linux/mm.h> 23static void __init hs7751rvoip_init_irq(void)
22#include <linux/vmalloc.h>
23
24/* defined in mm/ioremap.c */
25extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags);
26
27unsigned int debug_counter;
28
29const char *get_system_type(void)
30{ 24{
31 return "HS7751RVoIP"; 25#if defined(CONFIG_HS7751RVOIP_CODEC)
26 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
27 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
28#endif
29
30 init_hs7751rvoip_IRQ();
32} 31}
33 32
34/* 33static void hs7751rvoip_power_off(void)
35 * Initialize the board
36 */
37void __init platform_setup(void)
38{ 34{
39 printk(KERN_INFO "Renesas Technology Sales HS7751RVoIP-2 support.\n"); 35 ctrl_outw(ctrl_inw(PA_OUTPORTR) & 0xffdf, PA_OUTPORTR);
40 ctrl_outb(0xf0, PA_OUTPORTR);
41 debug_counter = 0;
42} 36}
43 37
44void *area5_io8_base; 38void *area5_io8_base;
@@ -46,16 +40,15 @@ void *area6_io8_base;
46void *area5_io16_base; 40void *area5_io16_base;
47void *area6_io16_base; 41void *area6_io16_base;
48 42
49int __init cf_init(void) 43static int __init hs7751rvoip_cf_init(void)
50{ 44{
51 pgprot_t prot; 45 pgprot_t prot;
52 unsigned long paddrbase, psize; 46 unsigned long paddrbase;
53 47
54 /* open I/O area window */ 48 /* open I/O area window */
55 paddrbase = virt_to_phys((void *)(PA_AREA5_IO+0x00000800)); 49 paddrbase = virt_to_phys((void *)(PA_AREA5_IO+0x00000800));
56 psize = PAGE_SIZE;
57 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_COM16); 50 prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_COM16);
58 area5_io16_base = p3_ioremap(paddrbase, psize, prot.pgprot); 51 area5_io16_base = p3_ioremap(paddrbase, PAGE_SIZE, prot.pgprot);
59 if (!area5_io16_base) { 52 if (!area5_io16_base) {
60 printk("allocate_cf_area : can't open CF I/O window!\n"); 53 printk("allocate_cf_area : can't open CF I/O window!\n");
61 return -ENOMEM; 54 return -ENOMEM;
@@ -64,19 +57,18 @@ int __init cf_init(void)
64 /* XXX : do we need attribute and common-memory area also? */ 57 /* XXX : do we need attribute and common-memory area also? */
65 58
66 paddrbase = virt_to_phys((void *)PA_AREA6_IO); 59 paddrbase = virt_to_phys((void *)PA_AREA6_IO);
67 psize = PAGE_SIZE;
68#if defined(CONFIG_HS7751RVOIP_CODEC) 60#if defined(CONFIG_HS7751RVOIP_CODEC)
69 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_COM8); 61 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_COM8);
70#else 62#else
71 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO8); 63 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO8);
72#endif 64#endif
73 area6_io8_base = p3_ioremap(paddrbase, psize, prot.pgprot); 65 area6_io8_base = p3_ioremap(paddrbase, PAGE_SIZE, prot.pgprot);
74 if (!area6_io8_base) { 66 if (!area6_io8_base) {
75 printk("allocate_cf_area : can't open CODEC I/O 8bit window!\n"); 67 printk("allocate_cf_area : can't open CODEC I/O 8bit window!\n");
76 return -ENOMEM; 68 return -ENOMEM;
77 } 69 }
78 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16); 70 prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
79 area6_io16_base = p3_ioremap(paddrbase, psize, prot.pgprot); 71 area6_io16_base = p3_ioremap(paddrbase, PAGE_SIZE, prot.pgprot);
80 if (!area6_io16_base) { 72 if (!area6_io16_base) {
81 printk("allocate_cf_area : can't open CODEC I/O 16bit window!\n"); 73 printk("allocate_cf_area : can't open CODEC I/O 16bit window!\n");
82 return -ENOMEM; 74 return -ENOMEM;
@@ -85,4 +77,46 @@ int __init cf_init(void)
85 return 0; 77 return 0;
86} 78}
87 79
88__initcall (cf_init); 80/*
81 * Initialize the board
82 */
83static void __init hs7751rvoip_setup(char **cmdline_p)
84{
85 device_initcall(hs7751rvoip_cf_init);
86
87 ctrl_outb(0xf0, PA_OUTPORTR);
88 pm_power_off = hs7751rvoip_power_off;
89
90 printk(KERN_INFO "Renesas Technology Sales HS7751RVoIP-2 support.\n");
91}
92
93struct sh_machine_vector mv_hs7751rvoip __initmv = {
94 .mv_name = "HS7751RVoIP",
95 .mv_setup = hs7751rvoip_setup,
96 .mv_nr_irqs = 72,
97
98 .mv_inb = hs7751rvoip_inb,
99 .mv_inw = hs7751rvoip_inw,
100 .mv_inl = hs7751rvoip_inl,
101 .mv_outb = hs7751rvoip_outb,
102 .mv_outw = hs7751rvoip_outw,
103 .mv_outl = hs7751rvoip_outl,
104
105 .mv_inb_p = hs7751rvoip_inb_p,
106 .mv_inw_p = hs7751rvoip_inw,
107 .mv_inl_p = hs7751rvoip_inl,
108 .mv_outb_p = hs7751rvoip_outb_p,
109 .mv_outw_p = hs7751rvoip_outw,
110 .mv_outl_p = hs7751rvoip_outl,
111
112 .mv_insb = hs7751rvoip_insb,
113 .mv_insw = hs7751rvoip_insw,
114 .mv_insl = hs7751rvoip_insl,
115 .mv_outsb = hs7751rvoip_outsb,
116 .mv_outsw = hs7751rvoip_outsw,
117 .mv_outsl = hs7751rvoip_outsl,
118
119 .mv_init_irq = hs7751rvoip_init_irq,
120 .mv_ioport_map = hs7751rvoip_ioport_map,
121};
122ALIAS_MV(hs7751rvoip)
diff --git a/arch/sh/boards/renesas/r7780rp/Kconfig b/arch/sh/boards/renesas/r7780rp/Kconfig
new file mode 100644
index 000000000000..c26d9813d239
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/Kconfig
@@ -0,0 +1,14 @@
1if SH_R7780RP
2
3menu "R7780RP options"
4
5config SH_R7780MP
6 bool "R7780MP board support"
7 default y
8 help
9 Selecting this option will enable support for the mass-production
10 version of the R7780RP. If in doubt, say Y.
11
12endmenu
13
14endif
diff --git a/arch/sh/boards/renesas/r7780rp/Makefile b/arch/sh/boards/renesas/r7780rp/Makefile
new file mode 100644
index 000000000000..f1776d027978
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for the R7780RP-1 specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/renesas/r7780rp/io.c b/arch/sh/boards/renesas/r7780rp/io.c
new file mode 100644
index 000000000000..db92d6e6ae99
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/io.c
@@ -0,0 +1,301 @@
1/*
2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
3 * Based largely on io_se.c.
4 *
5 * I/O routine for Renesas Solutions Highlander R7780RP-1
6 *
7 * Initial version only to support LAN access; some
8 * placeholder code from io_r7780rp.c left in with the
9 * expectation of later SuperIO and PCMCIA access.
10 */
11#include <linux/pci.h>
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <asm/r7780rp/r7780rp.h>
15#include <asm/addrspace.h>
16#include <asm/io.h>
17
18static inline unsigned long port2adr(unsigned int port)
19{
20 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
21 if (port == 0x3f6)
22 return (PA_AREA5_IO + 0x80c);
23 else
24 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1));
25 else
26 maybebadio((unsigned long)port);
27
28 return port;
29}
30
31static inline unsigned long port88796l(unsigned int port, int flag)
32{
33 unsigned long addr;
34
35 if (flag)
36 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1);
37 else
38 addr = PA_AX88796L + ((port - AX88796L_IO_BASE) << 1) + 0x1000;
39
40 return addr;
41}
42
43/* The 7780 R7780RP-1 seems to have everything hooked */
44/* up pretty normally (nothing on high-bytes only...) so this */
45/* shouldn't be needed */
46static inline int shifted_port(unsigned long port)
47{
48 /* For IDE registers, value is not shifted */
49 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
50 return 0;
51 else
52 return 1;
53}
54
55#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
56#define CHECK_AX88796L_PORT(port) \
57 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
58#else
59#define CHECK_AX88796L_PORT(port) (0)
60#endif
61
62/*
63 * General outline: remap really low stuff [eventually] to SuperIO,
64 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
65 * is mapped through the PCI IO window. Stuff with high bits (PXSEG)
66 * should be way beyond the window, and is used w/o translation for
67 * compatibility.
68 */
69u8 r7780rp_inb(unsigned long port)
70{
71 if (CHECK_AX88796L_PORT(port))
72 return ctrl_inw(port88796l(port, 0)) & 0xff;
73 else if (PXSEG(port))
74 return ctrl_inb(port);
75 else if (is_pci_ioaddr(port) || shifted_port(port))
76 return ctrl_inb(pci_ioaddr(port));
77
78 return ctrl_inw(port2adr(port)) & 0xff;
79}
80
81u8 r7780rp_inb_p(unsigned long port)
82{
83 u8 v;
84
85 if (CHECK_AX88796L_PORT(port))
86 v = ctrl_inw(port88796l(port, 0)) & 0xff;
87 else if (PXSEG(port))
88 v = ctrl_inb(port);
89 else if (is_pci_ioaddr(port) || shifted_port(port))
90 v = ctrl_inb(pci_ioaddr(port));
91 else
92 v = ctrl_inw(port2adr(port)) & 0xff;
93
94 ctrl_delay();
95
96 return v;
97}
98
99u16 r7780rp_inw(unsigned long port)
100{
101 if (CHECK_AX88796L_PORT(port))
102 maybebadio(port);
103 else if (PXSEG(port))
104 return ctrl_inw(port);
105 else if (is_pci_ioaddr(port) || shifted_port(port))
106 return ctrl_inw(pci_ioaddr(port));
107 else
108 maybebadio(port);
109
110 return 0;
111}
112
113u32 r7780rp_inl(unsigned long port)
114{
115 if (CHECK_AX88796L_PORT(port))
116 maybebadio(port);
117 else if (PXSEG(port))
118 return ctrl_inl(port);
119 else if (is_pci_ioaddr(port) || shifted_port(port))
120 return ctrl_inl(pci_ioaddr(port));
121 else
122 maybebadio(port);
123
124 return 0;
125}
126
127void r7780rp_outb(u8 value, unsigned long port)
128{
129 if (CHECK_AX88796L_PORT(port))
130 ctrl_outw(value, port88796l(port, 0));
131 else if (PXSEG(port))
132 ctrl_outb(value, port);
133 else if (is_pci_ioaddr(port) || shifted_port(port))
134 ctrl_outb(value, pci_ioaddr(port));
135 else
136 ctrl_outw(value, port2adr(port));
137}
138
139void r7780rp_outb_p(u8 value, unsigned long port)
140{
141 if (CHECK_AX88796L_PORT(port))
142 ctrl_outw(value, port88796l(port, 0));
143 else if (PXSEG(port))
144 ctrl_outb(value, port);
145 else if (is_pci_ioaddr(port) || shifted_port(port))
146 ctrl_outb(value, pci_ioaddr(port));
147 else
148 ctrl_outw(value, port2adr(port));
149
150 ctrl_delay();
151}
152
153void r7780rp_outw(u16 value, unsigned long port)
154{
155 if (CHECK_AX88796L_PORT(port))
156 maybebadio(port);
157 else if (PXSEG(port))
158 ctrl_outw(value, port);
159 else if (is_pci_ioaddr(port) || shifted_port(port))
160 ctrl_outw(value, pci_ioaddr(port));
161 else
162 maybebadio(port);
163}
164
165void r7780rp_outl(u32 value, unsigned long port)
166{
167 if (CHECK_AX88796L_PORT(port))
168 maybebadio(port);
169 else if (PXSEG(port))
170 ctrl_outl(value, port);
171 else if (is_pci_ioaddr(port) || shifted_port(port))
172 ctrl_outl(value, pci_ioaddr(port));
173 else
174 maybebadio(port);
175}
176
177void r7780rp_insb(unsigned long port, void *dst, unsigned long count)
178{
179 volatile u16 *p;
180 u8 *buf = dst;
181
182 if (CHECK_AX88796L_PORT(port)) {
183 p = (volatile u16 *)port88796l(port, 0);
184 while (count--)
185 *buf++ = *p & 0xff;
186 } else if (PXSEG(port)) {
187 while (count--)
188 *buf++ = *(volatile u8 *)port;
189 } else if (is_pci_ioaddr(port) || shifted_port(port)) {
190 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
191
192 while (count--)
193 *buf++ = *bp;
194 } else {
195 p = (volatile u16 *)port2adr(port);
196 while (count--)
197 *buf++ = *p & 0xff;
198 }
199}
200
201void r7780rp_insw(unsigned long port, void *dst, unsigned long count)
202{
203 volatile u16 *p;
204 u16 *buf = dst;
205
206 if (CHECK_AX88796L_PORT(port))
207 p = (volatile u16 *)port88796l(port, 1);
208 else if (PXSEG(port))
209 p = (volatile u16 *)port;
210 else if (is_pci_ioaddr(port) || shifted_port(port))
211 p = (volatile u16 *)pci_ioaddr(port);
212 else
213 p = (volatile u16 *)port2adr(port);
214
215 while (count--)
216 *buf++ = *p;
217}
218
219void r7780rp_insl(unsigned long port, void *dst, unsigned long count)
220{
221 u32 *buf = dst;
222
223 if (CHECK_AX88796L_PORT(port))
224 maybebadio(port);
225 else if (is_pci_ioaddr(port) || shifted_port(port)) {
226 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
227
228 while (count--)
229 *buf++ = *p;
230 } else
231 maybebadio(port);
232}
233
234void r7780rp_outsb(unsigned long port, const void *src, unsigned long count)
235{
236 volatile u16 *p;
237 const u8 *buf = src;
238
239 if (CHECK_AX88796L_PORT(port)) {
240 p = (volatile u16 *)port88796l(port, 0);
241 while (count--)
242 *p = *buf++;
243 } else if (PXSEG(port))
244 while (count--)
245 ctrl_outb(*buf++, port);
246 else if (is_pci_ioaddr(port) || shifted_port(port)) {
247 volatile u8 *bp = (volatile u8 *)pci_ioaddr(port);
248
249 while (count--)
250 *bp = *buf++;
251 } else {
252 p = (volatile u16 *)port2adr(port);
253 while (count--)
254 *p = *buf++;
255 }
256}
257
258void r7780rp_outsw(unsigned long port, const void *src, unsigned long count)
259{
260 volatile u16 *p;
261 const u16 *buf = src;
262
263 if (CHECK_AX88796L_PORT(port))
264 p = (volatile u16 *)port88796l(port, 1);
265 else if (PXSEG(port))
266 p = (volatile u16 *)port;
267 else if (is_pci_ioaddr(port) || shifted_port(port))
268 p = (volatile u16 *)pci_ioaddr(port);
269 else
270 p = (volatile u16 *)port2adr(port);
271
272 while (count--)
273 *p = *buf++;
274}
275
276void r7780rp_outsl(unsigned long port, const void *src, unsigned long count)
277{
278 const u32 *buf = src;
279
280 if (CHECK_AX88796L_PORT(port))
281 maybebadio(port);
282 else if (is_pci_ioaddr(port) || shifted_port(port)) {
283 volatile u32 *p = (volatile u32 *)pci_ioaddr(port);
284
285 while (count--)
286 *p = *buf++;
287 } else
288 maybebadio(port);
289}
290
291void __iomem *r7780rp_ioport_map(unsigned long port, unsigned int size)
292{
293 if (CHECK_AX88796L_PORT(port))
294 return (void __iomem *)port88796l(port, size > 1);
295 else if (PXSEG(port))
296 return (void __iomem *)port;
297 else if (is_pci_ioaddr(port) || shifted_port(port))
298 return (void __iomem *)pci_ioaddr(port);
299
300 return (void __iomem *)port2adr(port);
301}
diff --git a/arch/sh/boards/renesas/r7780rp/irq.c b/arch/sh/boards/renesas/r7780rp/irq.c
new file mode 100644
index 000000000000..61d5e5d3c294
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/irq.c
@@ -0,0 +1,117 @@
1/*
2 * linux/arch/sh/boards/renesas/r7780rp/irq.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Renesas Solutions Highlander R7780RP-1 Support.
7 *
8 * Modified for R7780RP-1 by
9 * Atom Create Engineering Co., Ltd. 2002.
10 */
11
12#include <linux/config.h>
13#include <linux/init.h>
14#include <linux/irq.h>
15#include <asm/io.h>
16#include <asm/irq.h>
17#include <asm/r7780rp/r7780rp.h>
18
19#ifdef CONFIG_SH_R7780MP
20static int mask_pos[] = {12, 11, 9, 14, 15, 8, 13, 6, 5, 4, 3, 2, 0, 0, 1, 0};
21#else
22static int mask_pos[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 5, 6, 4, 0, 1, 2, 0};
23#endif
24
25static void enable_r7780rp_irq(unsigned int irq);
26static void disable_r7780rp_irq(unsigned int irq);
27
28/* shutdown is same as "disable" */
29#define shutdown_r7780rp_irq disable_r7780rp_irq
30
31static void ack_r7780rp_irq(unsigned int irq);
32static void end_r7780rp_irq(unsigned int irq);
33
34static unsigned int startup_r7780rp_irq(unsigned int irq)
35{
36 enable_r7780rp_irq(irq);
37 return 0; /* never anything pending */
38}
39
40static void disable_r7780rp_irq(unsigned int irq)
41{
42 unsigned short val;
43 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
44
45 /* Set the priority in IPR to 0 */
46 val = ctrl_inw(IRLCNTR1);
47 val &= mask;
48 ctrl_outw(val, IRLCNTR1);
49}
50
51static void enable_r7780rp_irq(unsigned int irq)
52{
53 unsigned short val;
54 unsigned short value = (0x0001 << mask_pos[irq]);
55
56 /* Set priority in IPR back to original value */
57 val = ctrl_inw(IRLCNTR1);
58 val |= value;
59 ctrl_outw(val, IRLCNTR1);
60}
61
62static void ack_r7780rp_irq(unsigned int irq)
63{
64 disable_r7780rp_irq(irq);
65}
66
67static void end_r7780rp_irq(unsigned int irq)
68{
69 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
70 enable_r7780rp_irq(irq);
71}
72
73static struct hw_interrupt_type r7780rp_irq_type = {
74 .typename = "R7780RP-IRQ",
75 .startup = startup_r7780rp_irq,
76 .shutdown = shutdown_r7780rp_irq,
77 .enable = enable_r7780rp_irq,
78 .disable = disable_r7780rp_irq,
79 .ack = ack_r7780rp_irq,
80 .end = end_r7780rp_irq,
81};
82
83static void make_r7780rp_irq(unsigned int irq)
84{
85 disable_irq_nosync(irq);
86 irq_desc[irq].handler = &r7780rp_irq_type;
87 disable_r7780rp_irq(irq);
88}
89
90/*
91 * Initialize IRQ setting
92 */
93void __init init_r7780rp_IRQ(void)
94{
95 int i;
96
97 /* IRL0=PCI Slot #A
98 * IRL1=PCI Slot #B
99 * IRL2=PCI Slot #C
100 * IRL3=PCI Slot #D
101 * IRL4=CF Card
102 * IRL5=CF Card Insert
103 * IRL6=M66596
104 * IRL7=SD Card
105 * IRL8=Touch Panel
106 * IRL9=SCI
107 * IRL10=Serial
108 * IRL11=Extention #A
109 * IRL11=Extention #B
110 * IRL12=Debug LAN
111 * IRL13=Push Switch
112 * IRL14=ZiggBee IO
113 */
114
115 for (i=0; i<15; i++)
116 make_r7780rp_irq(i);
117}
diff --git a/arch/sh/boards/renesas/r7780rp/led.c b/arch/sh/boards/renesas/r7780rp/led.c
new file mode 100644
index 000000000000..9f02766b6f53
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/led.c
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) Atom Create Engineering Co., Ltd.
3 *
4 * May be copied or modified under the terms of GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * This file contains Renesas Solutions HIGHLANDER R7780RP-1 specific LED code.
8 */
9
10#include <linux/config.h>
11#include <linux/sched.h>
12#include <asm/io.h>
13#include <asm/r7780rp/r7780rp.h>
14
15/* Cycle the LED's in the clasic Knightriger/Sun pattern */
16void heartbeat_r7780rp(void)
17{
18 static unsigned int cnt = 0, period = 0;
19 volatile unsigned short *p = (volatile unsigned short *)PA_OBLED;
20 static unsigned bit = 0, up = 1;
21 unsigned bit_pos[] = {2, 1, 0, 3, 6, 5, 4, 7};
22
23 cnt += 1;
24 if (cnt < period)
25 return;
26
27 cnt = 0;
28
29 /* Go through the points (roughly!):
30 * f(0)=10, f(1)=16, f(2)=20, f(5)=35, f(int)->110
31 */
32 period = 110 - ((300 << FSHIFT)/((avenrun[0]/5) + (3<<FSHIFT)));
33
34 *p = 1 << bit_pos[bit];
35 if (up)
36 if (bit == 7) {
37 bit--;
38 up = 0;
39 } else
40 bit++;
41 else if (bit == 0)
42 up = 1;
43 else
44 bit--;
45}
diff --git a/arch/sh/boards/renesas/r7780rp/setup.c b/arch/sh/boards/renesas/r7780rp/setup.c
new file mode 100644
index 000000000000..b941aa0aa34e
--- /dev/null
+++ b/arch/sh/boards/renesas/r7780rp/setup.c
@@ -0,0 +1,163 @@
1/*
2 * arch/sh/boards/renesas/r7780rp/setup.c
3 *
4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
5 * Copyright (C) 2005, 2006 Paul Mundt
6 *
7 * Renesas Solutions Highlander R7780RP-1 Support.
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <asm/machvec.h>
16#include <asm/r7780rp/r7780rp.h>
17#include <asm/clock.h>
18#include <asm/io.h>
19
20extern void heartbeat_r7780rp(void);
21extern void init_r7780rp_IRQ(void);
22
23static struct resource m66596_usb_host_resources[] = {
24 [0] = {
25 .start = 0xa4800000,
26 .end = 0xa4ffffff,
27 .flags = IORESOURCE_MEM,
28 },
29 [1] = {
30 .start = 6, /* irq number */
31 .end = 6,
32 .flags = IORESOURCE_IRQ,
33 },
34};
35
36static struct platform_device m66596_usb_host_device = {
37 .name = "m66596-hcd",
38 .id = 0,
39 .dev = {
40 .dma_mask = NULL, /* don't use dma */
41 .coherent_dma_mask = 0xffffffff,
42 },
43 .num_resources = ARRAY_SIZE(m66596_usb_host_resources),
44 .resource = m66596_usb_host_resources,
45};
46
47static struct platform_device *r7780rp_devices[] __initdata = {
48 &m66596_usb_host_device,
49};
50
51static int __init r7780rp_devices_setup(void)
52{
53 return platform_add_devices(r7780rp_devices,
54 ARRAY_SIZE(r7780rp_devices));
55}
56
57/*
58 * Platform specific clocks
59 */
60static void ivdr_clk_enable(struct clk *clk)
61{
62 ctrl_outw(ctrl_inw(PA_IVDRCTL) | (1 << 8), PA_IVDRCTL);
63}
64
65static void ivdr_clk_disable(struct clk *clk)
66{
67 ctrl_outw(ctrl_inw(PA_IVDRCTL) & ~(1 << 8), PA_IVDRCTL);
68}
69
70static struct clk_ops ivdr_clk_ops = {
71 .enable = ivdr_clk_enable,
72 .disable = ivdr_clk_disable,
73};
74
75static struct clk ivdr_clk = {
76 .name = "ivdr_clk",
77 .ops = &ivdr_clk_ops,
78};
79
80static struct clk *r7780rp_clocks[] = {
81 &ivdr_clk,
82};
83
84static void r7780rp_power_off(void)
85{
86#ifdef CONFIG_SH_R7780MP
87 ctrl_outw(0x0001, PA_POFF);
88#endif
89}
90
91/*
92 * Initialize the board
93 */
94static void __init r7780rp_setup(char **cmdline_p)
95{
96 u16 ver = ctrl_inw(PA_VERREG);
97 int i;
98
99 device_initcall(r7780rp_devices_setup);
100
101 printk(KERN_INFO "Renesas Solutions Highlander R7780RP-1 support.\n");
102
103 printk(KERN_INFO "Board version: %d (revision %d), "
104 "FPGA version: %d (revision %d)\n",
105 (ver >> 12) & 0xf, (ver >> 8) & 0xf,
106 (ver >> 4) & 0xf, ver & 0xf);
107
108 /*
109 * Enable the important clocks right away..
110 */
111 for (i = 0; i < ARRAY_SIZE(r7780rp_clocks); i++) {
112 struct clk *clk = r7780rp_clocks[i];
113
114 clk_register(clk);
115 clk_enable(clk);
116 }
117
118 ctrl_outw(0x0000, PA_OBLED); /* Clear LED. */
119#ifndef CONFIG_SH_R7780MP
120 ctrl_outw(0x0001, PA_SDPOW); /* SD Power ON */
121#endif
122 ctrl_outw(ctrl_inw(PA_IVDRCTL) | 0x0100, PA_IVDRCTL); /* Si13112 */
123
124 pm_power_off = r7780rp_power_off;
125}
126
127/*
128 * The Machine Vector
129 */
130struct sh_machine_vector mv_r7780rp __initmv = {
131 .mv_name = "Highlander R7780RP-1",
132 .mv_setup = r7780rp_setup,
133
134 .mv_nr_irqs = 109,
135
136 .mv_inb = r7780rp_inb,
137 .mv_inw = r7780rp_inw,
138 .mv_inl = r7780rp_inl,
139 .mv_outb = r7780rp_outb,
140 .mv_outw = r7780rp_outw,
141 .mv_outl = r7780rp_outl,
142
143 .mv_inb_p = r7780rp_inb_p,
144 .mv_inw_p = r7780rp_inw,
145 .mv_inl_p = r7780rp_inl,
146 .mv_outb_p = r7780rp_outb_p,
147 .mv_outw_p = r7780rp_outw,
148 .mv_outl_p = r7780rp_outl,
149
150 .mv_insb = r7780rp_insb,
151 .mv_insw = r7780rp_insw,
152 .mv_insl = r7780rp_insl,
153 .mv_outsb = r7780rp_outsb,
154 .mv_outsw = r7780rp_outsw,
155 .mv_outsl = r7780rp_outsl,
156
157 .mv_ioport_map = r7780rp_ioport_map,
158 .mv_init_irq = init_r7780rp_IRQ,
159#ifdef CONFIG_HEARTBEAT
160 .mv_heartbeat = heartbeat_r7780rp,
161#endif
162};
163ALIAS_MV(r7780rp)
diff --git a/arch/sh/boards/renesas/rts7751r2d/Kconfig b/arch/sh/boards/renesas/rts7751r2d/Kconfig
new file mode 100644
index 000000000000..7780d1fb13ff
--- /dev/null
+++ b/arch/sh/boards/renesas/rts7751r2d/Kconfig
@@ -0,0 +1,12 @@
1if SH_RTS7751R2D
2
3menu "RTS7751R2D options"
4
5config RTS7751R2D_REV11
6 bool "RTS7751R2D Rev. 1.1 board support"
7 help
8 Selecting this option will support version rev. 1.1.
9endmenu
10
11endif
12
diff --git a/arch/sh/boards/renesas/rts7751r2d/Makefile b/arch/sh/boards/renesas/rts7751r2d/Makefile
index daa53334bdc3..686fc9ea5989 100644
--- a/arch/sh/boards/renesas/rts7751r2d/Makefile
+++ b/arch/sh/boards/renesas/rts7751r2d/Makefile
@@ -1,10 +1,6 @@
1# 1#
2# Makefile for the RTS7751R2D specific parts of the kernel 2# Makefile for the RTS7751R2D specific parts of the kernel
3# 3#
4# Note! Dependencies are done automagically by 'make dep', which also
5# removes any old dependencies. DON'T put your own dependencies here
6# unless it's something special (ie not a .c file).
7#
8
9obj-y := mach.o setup.o io.o irq.o led.o
10 4
5obj-y := setup.o io.o irq.o
6obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/renesas/rts7751r2d/io.c b/arch/sh/boards/renesas/rts7751r2d/io.c
index 123abbbc91e0..135aa0b5e62d 100644
--- a/arch/sh/boards/renesas/rts7751r2d/io.c
+++ b/arch/sh/boards/renesas/rts7751r2d/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_rts7751r2d.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c. 3 * Based largely on io_se.c.
6 * 4 *
@@ -10,17 +8,13 @@
10 * placeholder code from io_rts7751r2d.c left in with the 8 * placeholder code from io_rts7751r2d.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 9 * expectation of later SuperIO and PCMCIA access.
12 */ 10 */
13
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
16#include <asm/io.h> 13#include <linux/pci.h>
17#include <asm/rts7751r2d/rts7751r2d.h> 14#include <asm/rts7751r2d/rts7751r2d.h>
15#include <asm/io.h>
18#include <asm/addrspace.h> 16#include <asm/addrspace.h>
19 17
20#include <linux/module.h>
21#include <linux/pci.h>
22#include "../../../drivers/pci/pci-sh7751.h"
23
24/* 18/*
25 * The 7751R RTS7751R2D uses the built-in PCI controller (PCIC) 19 * The 7751R RTS7751R2D uses the built-in PCI controller (PCIC)
26 * of the 7751R processor, and has a SuperIO accessible via the PCI. 20 * of the 7751R processor, and has a SuperIO accessible via the PCI.
@@ -28,22 +22,6 @@
28 * like the other Solution Engine boards. 22 * like the other Solution Engine boards.
29 */ 23 */
30 24
31#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
32#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
33#define PCI_IO_AREA SH7751_PCI_IO_BASE
34#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
35
36#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
37
38#define maybebadio(name,port) \
39 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
40 #name, (port), (__u32) __builtin_return_address(0))
41
42static inline void delay(void)
43{
44 ctrl_inw(0xa0000000);
45}
46
47static inline unsigned long port2adr(unsigned int port) 25static inline unsigned long port2adr(unsigned int port)
48{ 26{
49 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6) 27 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
@@ -52,7 +30,7 @@ static inline unsigned long port2adr(unsigned int port)
52 else 30 else
53 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1)); 31 return (PA_AREA5_IO + 0x1000 + ((port-0x1f0) << 1));
54 else 32 else
55 maybebadio(port2adr, (unsigned long)port); 33 maybebadio((unsigned long)port);
56 34
57 return port; 35 return port;
58} 36}
@@ -81,17 +59,6 @@ static inline int shifted_port(unsigned long port)
81 return 1; 59 return 1;
82} 60}
83 61
84/* In case someone configures the kernel w/o PCI support: in that */
85/* scenario, don't ever bother to check for PCI-window addresses */
86
87/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
88#if defined(CONFIG_PCI)
89#define CHECK_SH7751_PCIIO(port) \
90 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
91#else
92#define CHECK_SH7751_PCIIO(port) (0)
93#endif
94
95#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE) 62#if defined(CONFIG_NE2000) || defined(CONFIG_NE2000_MODULE)
96#define CHECK_AX88796L_PORT(port) \ 63#define CHECK_AX88796L_PORT(port) \
97 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20))) 64 ((port >= AX88796L_IO_BASE) && (port < (AX88796L_IO_BASE+0x20)))
@@ -112,8 +79,8 @@ unsigned char rts7751r2d_inb(unsigned long port)
112 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; 79 return (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
113 else if (PXSEG(port)) 80 else if (PXSEG(port))
114 return *(volatile unsigned char *)port; 81 return *(volatile unsigned char *)port;
115 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 82 else if (is_pci_ioaddr(port) || shifted_port(port))
116 return *(volatile unsigned char *)PCI_IOMAP(port); 83 return *(volatile unsigned char *)pci_ioaddr(port);
117 else 84 else
118 return (*(volatile unsigned short *)port2adr(port) & 0xff); 85 return (*(volatile unsigned short *)port2adr(port) & 0xff);
119} 86}
@@ -126,11 +93,12 @@ unsigned char rts7751r2d_inb_p(unsigned long port)
126 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff; 93 v = (*(volatile unsigned short *)port88796l(port, 0)) & 0xff;
127 else if (PXSEG(port)) 94 else if (PXSEG(port))
128 v = *(volatile unsigned char *)port; 95 v = *(volatile unsigned char *)port;
129 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 96 else if (is_pci_ioaddr(port) || shifted_port(port))
130 v = *(volatile unsigned char *)PCI_IOMAP(port); 97 v = *(volatile unsigned char *)pci_ioaddr(port);
131 else 98 else
132 v = (*(volatile unsigned short *)port2adr(port) & 0xff); 99 v = (*(volatile unsigned short *)port2adr(port) & 0xff);
133 delay(); 100
101 ctrl_delay();
134 102
135 return v; 103 return v;
136} 104}
@@ -138,13 +106,13 @@ unsigned char rts7751r2d_inb_p(unsigned long port)
138unsigned short rts7751r2d_inw(unsigned long port) 106unsigned short rts7751r2d_inw(unsigned long port)
139{ 107{
140 if (CHECK_AX88796L_PORT(port)) 108 if (CHECK_AX88796L_PORT(port))
141 maybebadio(inw, port); 109 maybebadio(port);
142 else if (PXSEG(port)) 110 else if (PXSEG(port))
143 return *(volatile unsigned short *)port; 111 return *(volatile unsigned short *)port;
144 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 112 else if (is_pci_ioaddr(port) || shifted_port(port))
145 return *(volatile unsigned short *)PCI_IOMAP(port); 113 return *(volatile unsigned short *)pci_ioaddr(port);
146 else 114 else
147 maybebadio(inw, port); 115 maybebadio(port);
148 116
149 return 0; 117 return 0;
150} 118}
@@ -152,13 +120,13 @@ unsigned short rts7751r2d_inw(unsigned long port)
152unsigned int rts7751r2d_inl(unsigned long port) 120unsigned int rts7751r2d_inl(unsigned long port)
153{ 121{
154 if (CHECK_AX88796L_PORT(port)) 122 if (CHECK_AX88796L_PORT(port))
155 maybebadio(inl, port); 123 maybebadio(port);
156 else if (PXSEG(port)) 124 else if (PXSEG(port))
157 return *(volatile unsigned long *)port; 125 return *(volatile unsigned long *)port;
158 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 126 else if (is_pci_ioaddr(port) || shifted_port(port))
159 return *(volatile unsigned long *)PCI_IOMAP(port); 127 return *(volatile unsigned long *)pci_ioaddr(port);
160 else 128 else
161 maybebadio(inl, port); 129 maybebadio(port);
162 130
163 return 0; 131 return 0;
164} 132}
@@ -169,8 +137,8 @@ void rts7751r2d_outb(unsigned char value, unsigned long port)
169 *((volatile unsigned short *)port88796l(port, 0)) = value; 137 *((volatile unsigned short *)port88796l(port, 0)) = value;
170 else if (PXSEG(port)) 138 else if (PXSEG(port))
171 *(volatile unsigned char *)port = value; 139 *(volatile unsigned char *)port = value;
172 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 140 else if (is_pci_ioaddr(port) || shifted_port(port))
173 *(volatile unsigned char *)PCI_IOMAP(port) = value; 141 *(volatile unsigned char *)pci_ioaddr(port) = value;
174 else 142 else
175 *(volatile unsigned short *)port2adr(port) = value; 143 *(volatile unsigned short *)port2adr(port) = value;
176} 144}
@@ -181,143 +149,152 @@ void rts7751r2d_outb_p(unsigned char value, unsigned long port)
181 *((volatile unsigned short *)port88796l(port, 0)) = value; 149 *((volatile unsigned short *)port88796l(port, 0)) = value;
182 else if (PXSEG(port)) 150 else if (PXSEG(port))
183 *(volatile unsigned char *)port = value; 151 *(volatile unsigned char *)port = value;
184 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 152 else if (is_pci_ioaddr(port) || shifted_port(port))
185 *(volatile unsigned char *)PCI_IOMAP(port) = value; 153 *(volatile unsigned char *)pci_ioaddr(port) = value;
186 else 154 else
187 *(volatile unsigned short *)port2adr(port) = value; 155 *(volatile unsigned short *)port2adr(port) = value;
188 delay(); 156
157 ctrl_delay();
189} 158}
190 159
191void rts7751r2d_outw(unsigned short value, unsigned long port) 160void rts7751r2d_outw(unsigned short value, unsigned long port)
192{ 161{
193 if (CHECK_AX88796L_PORT(port)) 162 if (CHECK_AX88796L_PORT(port))
194 maybebadio(outw, port); 163 maybebadio(port);
195 else if (PXSEG(port)) 164 else if (PXSEG(port))
196 *(volatile unsigned short *)port = value; 165 *(volatile unsigned short *)port = value;
197 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 166 else if (is_pci_ioaddr(port) || shifted_port(port))
198 *(volatile unsigned short *)PCI_IOMAP(port) = value; 167 *(volatile unsigned short *)pci_ioaddr(port) = value;
199 else 168 else
200 maybebadio(outw, port); 169 maybebadio(port);
201} 170}
202 171
203void rts7751r2d_outl(unsigned int value, unsigned long port) 172void rts7751r2d_outl(unsigned int value, unsigned long port)
204{ 173{
205 if (CHECK_AX88796L_PORT(port)) 174 if (CHECK_AX88796L_PORT(port))
206 maybebadio(outl, port); 175 maybebadio(port);
207 else if (PXSEG(port)) 176 else if (PXSEG(port))
208 *(volatile unsigned long *)port = value; 177 *(volatile unsigned long *)port = value;
209 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 178 else if (is_pci_ioaddr(port) || shifted_port(port))
210 *(volatile unsigned long *)PCI_IOMAP(port) = value; 179 *(volatile unsigned long *)pci_ioaddr(port) = value;
211 else 180 else
212 maybebadio(outl, port); 181 maybebadio(port);
213} 182}
214 183
215void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count) 184void rts7751r2d_insb(unsigned long port, void *addr, unsigned long count)
216{ 185{
186 unsigned long a = (unsigned long)addr;
217 volatile __u8 *bp; 187 volatile __u8 *bp;
218 volatile __u16 *p; 188 volatile __u16 *p;
219 unsigned char *s = addr;
220 189
221 if (CHECK_AX88796L_PORT(port)) { 190 if (CHECK_AX88796L_PORT(port)) {
222 p = (volatile unsigned short *)port88796l(port, 0); 191 p = (volatile unsigned short *)port88796l(port, 0);
223 while (count--) *s++ = *p & 0xff; 192 while (count--)
193 ctrl_outb(*p & 0xff, a++);
224 } else if (PXSEG(port)) 194 } else if (PXSEG(port))
225 while (count--) *s++ = *(volatile unsigned char *)port; 195 while (count--)
226 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 196 ctrl_outb(ctrl_inb(port), a++);
227 bp = (__u8 *)PCI_IOMAP(port); 197 else if (is_pci_ioaddr(port) || shifted_port(port)) {
228 while (count--) *s++ = *bp; 198 bp = (__u8 *)pci_ioaddr(port);
199 while (count--)
200 ctrl_outb(*bp, a++);
229 } else { 201 } else {
230 p = (volatile unsigned short *)port2adr(port); 202 p = (volatile unsigned short *)port2adr(port);
231 while (count--) *s++ = *p & 0xff; 203 while (count--)
204 ctrl_outb(*p & 0xff, a++);
232 } 205 }
233} 206}
234 207
235void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count) 208void rts7751r2d_insw(unsigned long port, void *addr, unsigned long count)
236{ 209{
210 unsigned long a = (unsigned long)addr;
237 volatile __u16 *p; 211 volatile __u16 *p;
238 __u16 *s = addr;
239 212
240 if (CHECK_AX88796L_PORT(port)) 213 if (CHECK_AX88796L_PORT(port))
241 p = (volatile unsigned short *)port88796l(port, 1); 214 p = (volatile unsigned short *)port88796l(port, 1);
242 else if (PXSEG(port)) 215 else if (PXSEG(port))
243 p = (volatile unsigned short *)port; 216 p = (volatile unsigned short *)port;
244 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 217 else if (is_pci_ioaddr(port) || shifted_port(port))
245 p = (volatile unsigned short *)PCI_IOMAP(port); 218 p = (volatile unsigned short *)pci_ioaddr(port);
246 else 219 else
247 p = (volatile unsigned short *)port2adr(port); 220 p = (volatile unsigned short *)port2adr(port);
248 while (count--) *s++ = *p; 221 while (count--)
222 ctrl_outw(*p, a++);
249} 223}
250 224
251void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count) 225void rts7751r2d_insl(unsigned long port, void *addr, unsigned long count)
252{ 226{
253 if (CHECK_AX88796L_PORT(port)) 227 if (CHECK_AX88796L_PORT(port))
254 maybebadio(insl, port); 228 maybebadio(port);
255 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 229 else if (is_pci_ioaddr(port) || shifted_port(port)) {
256 volatile __u32 *p = (__u32 *)PCI_IOMAP(port); 230 unsigned long a = (unsigned long)addr;
257 __u32 *s = addr; 231
258 232 while (count--) {
259 while (count--) *s++ = *p; 233 ctrl_outl(ctrl_inl(pci_ioaddr(port)), a);
234 a += 4;
235 }
260 } else 236 } else
261 maybebadio(insl, port); 237 maybebadio(port);
262} 238}
263 239
264void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count) 240void rts7751r2d_outsb(unsigned long port, const void *addr, unsigned long count)
265{ 241{
242 unsigned long a = (unsigned long)addr;
266 volatile __u8 *bp; 243 volatile __u8 *bp;
267 volatile __u16 *p; 244 volatile __u16 *p;
268 const __u8 *s = addr;
269 245
270 if (CHECK_AX88796L_PORT(port)) { 246 if (CHECK_AX88796L_PORT(port)) {
271 p = (volatile unsigned short *)port88796l(port, 0); 247 p = (volatile unsigned short *)port88796l(port, 0);
272 while (count--) *p = *s++; 248 while (count--)
249 *p = ctrl_inb(a++);
273 } else if (PXSEG(port)) 250 } else if (PXSEG(port))
274 while (count--) *(volatile unsigned char *)port = *s++; 251 while (count--)
275 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 252 ctrl_outb(a++, port);
276 bp = (__u8 *)PCI_IOMAP(port); 253 else if (is_pci_ioaddr(port) || shifted_port(port)) {
277 while (count--) *bp = *s++; 254 bp = (__u8 *)pci_ioaddr(port);
255 while (count--)
256 *bp = ctrl_inb(a++);
278 } else { 257 } else {
279 p = (volatile unsigned short *)port2adr(port); 258 p = (volatile unsigned short *)port2adr(port);
280 while (count--) *p = *s++; 259 while (count--)
260 *p = ctrl_inb(a++);
281 } 261 }
282} 262}
283 263
284void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count) 264void rts7751r2d_outsw(unsigned long port, const void *addr, unsigned long count)
285{ 265{
266 unsigned long a = (unsigned long)addr;
286 volatile __u16 *p; 267 volatile __u16 *p;
287 const __u16 *s = addr;
288 268
289 if (CHECK_AX88796L_PORT(port)) 269 if (CHECK_AX88796L_PORT(port))
290 p = (volatile unsigned short *)port88796l(port, 1); 270 p = (volatile unsigned short *)port88796l(port, 1);
291 else if (PXSEG(port)) 271 else if (PXSEG(port))
292 p = (volatile unsigned short *)port; 272 p = (volatile unsigned short *)port;
293 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) 273 else if (is_pci_ioaddr(port) || shifted_port(port))
294 p = (volatile unsigned short *)PCI_IOMAP(port); 274 p = (volatile unsigned short *)pci_ioaddr(port);
295 else 275 else
296 p = (volatile unsigned short *)port2adr(port); 276 p = (volatile unsigned short *)port2adr(port);
297 while (count--) *p = *s++; 277
278 while (count--) {
279 ctrl_outw(*p, a);
280 a += 2;
281 }
298} 282}
299 283
300void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count) 284void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count)
301{ 285{
302 if (CHECK_AX88796L_PORT(port)) 286 if (CHECK_AX88796L_PORT(port))
303 maybebadio(outsl, port); 287 maybebadio(port);
304 else if (CHECK_SH7751_PCIIO(port) || shifted_port(port)) { 288 else if (is_pci_ioaddr(port) || shifted_port(port)) {
305 volatile __u32 *p = (__u32 *)PCI_IOMAP(port); 289 unsigned long a = (unsigned long)addr;
306 const __u32 *s = addr; 290
307 291 while (count--) {
308 while (count--) *p = *s++; 292 ctrl_outl(ctrl_inl(a), pci_ioaddr(port));
293 a += 4;
294 }
309 } else 295 } else
310 maybebadio(outsl, port); 296 maybebadio(port);
311}
312
313void *rts7751r2d_ioremap(unsigned long offset, unsigned long size)
314{
315 if (offset >= 0xfd000000)
316 return (void *)offset;
317 else
318 return (void *)P2SEGADDR(offset);
319} 297}
320EXPORT_SYMBOL(rts7751r2d_ioremap);
321 298
322unsigned long rts7751r2d_isa_port2addr(unsigned long offset) 299unsigned long rts7751r2d_isa_port2addr(unsigned long offset)
323{ 300{
diff --git a/arch/sh/boards/renesas/rts7751r2d/irq.c b/arch/sh/boards/renesas/rts7751r2d/irq.c
index 154535440bbf..c915e7a3693a 100644
--- a/arch/sh/boards/renesas/rts7751r2d/irq.c
+++ b/arch/sh/boards/renesas/rts7751r2d/irq.c
@@ -41,30 +41,24 @@ static unsigned int startup_rts7751r2d_irq(unsigned int irq)
41 41
42static void disable_rts7751r2d_irq(unsigned int irq) 42static void disable_rts7751r2d_irq(unsigned int irq)
43{ 43{
44 unsigned long flags;
45 unsigned short val; 44 unsigned short val;
46 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]); 45 unsigned short mask = 0xffff ^ (0x0001 << mask_pos[irq]);
47 46
48 /* Set the priority in IPR to 0 */ 47 /* Set the priority in IPR to 0 */
49 local_irq_save(flags);
50 val = ctrl_inw(IRLCNTR1); 48 val = ctrl_inw(IRLCNTR1);
51 val &= mask; 49 val &= mask;
52 ctrl_outw(val, IRLCNTR1); 50 ctrl_outw(val, IRLCNTR1);
53 local_irq_restore(flags);
54} 51}
55 52
56static void enable_rts7751r2d_irq(unsigned int irq) 53static void enable_rts7751r2d_irq(unsigned int irq)
57{ 54{
58 unsigned long flags;
59 unsigned short val; 55 unsigned short val;
60 unsigned short value = (0x0001 << mask_pos[irq]); 56 unsigned short value = (0x0001 << mask_pos[irq]);
61 57
62 /* Set priority in IPR back to original value */ 58 /* Set priority in IPR back to original value */
63 local_irq_save(flags);
64 val = ctrl_inw(IRLCNTR1); 59 val = ctrl_inw(IRLCNTR1);
65 val |= value; 60 val |= value;
66 ctrl_outw(val, IRLCNTR1); 61 ctrl_outw(val, IRLCNTR1);
67 local_irq_restore(flags);
68} 62}
69 63
70int rts7751r2d_irq_demux(int irq) 64int rts7751r2d_irq_demux(int irq)
diff --git a/arch/sh/boards/renesas/rts7751r2d/led.c b/arch/sh/boards/renesas/rts7751r2d/led.c
index 4d16de71fac1..e14a13d12d4a 100644
--- a/arch/sh/boards/renesas/rts7751r2d/led.c
+++ b/arch/sh/boards/renesas/rts7751r2d/led.c
@@ -12,8 +12,6 @@
12#include <asm/io.h> 12#include <asm/io.h>
13#include <asm/rts7751r2d/rts7751r2d.h> 13#include <asm/rts7751r2d/rts7751r2d.h>
14 14
15extern unsigned int debug_counter;
16
17#ifdef CONFIG_HEARTBEAT 15#ifdef CONFIG_HEARTBEAT
18 16
19#include <linux/sched.h> 17#include <linux/sched.h>
@@ -55,12 +53,3 @@ void rts7751r2d_led(unsigned short value)
55 ctrl_outw(value, PA_OUTPORT); 53 ctrl_outw(value, PA_OUTPORT);
56} 54}
57 55
58void debug_led_disp(void)
59{
60 unsigned short value;
61
62 value = (unsigned short)debug_counter++;
63 rts7751r2d_led(value);
64 if (value == 0xff)
65 debug_counter = 0;
66}
diff --git a/arch/sh/boards/renesas/rts7751r2d/mach.c b/arch/sh/boards/renesas/rts7751r2d/mach.c
deleted file mode 100644
index 5ed9e97ea197..000000000000
--- a/arch/sh/boards/renesas/rts7751r2d/mach.c
+++ /dev/null
@@ -1,69 +0,0 @@
1/*
2 * linux/arch/sh/kernel/mach_rts7751r2d.c
3 *
4 * Minor tweak of mach_se.c file to reference rts7751r2d-specific items.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the Renesas Technology sales RTS7751R2D
10 */
11
12#include <linux/init.h>
13#include <linux/types.h>
14
15#include <asm/machvec.h>
16#include <asm/rtc.h>
17#include <asm/irq.h>
18#include <asm/rts7751r2d/io.h>
19
20extern void heartbeat_rts7751r2d(void);
21extern void init_rts7751r2d_IRQ(void);
22extern void *rts7751r2d_ioremap(unsigned long, unsigned long);
23extern int rts7751r2d_irq_demux(int irq);
24
25extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
26extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
27
28/*
29 * The Machine Vector
30 */
31
32struct sh_machine_vector mv_rts7751r2d __initmv = {
33 .mv_nr_irqs = 72,
34
35 .mv_inb = rts7751r2d_inb,
36 .mv_inw = rts7751r2d_inw,
37 .mv_inl = rts7751r2d_inl,
38 .mv_outb = rts7751r2d_outb,
39 .mv_outw = rts7751r2d_outw,
40 .mv_outl = rts7751r2d_outl,
41
42 .mv_inb_p = rts7751r2d_inb_p,
43 .mv_inw_p = rts7751r2d_inw,
44 .mv_inl_p = rts7751r2d_inl,
45 .mv_outb_p = rts7751r2d_outb_p,
46 .mv_outw_p = rts7751r2d_outw,
47 .mv_outl_p = rts7751r2d_outl,
48
49 .mv_insb = rts7751r2d_insb,
50 .mv_insw = rts7751r2d_insw,
51 .mv_insl = rts7751r2d_insl,
52 .mv_outsb = rts7751r2d_outsb,
53 .mv_outsw = rts7751r2d_outsw,
54 .mv_outsl = rts7751r2d_outsl,
55
56 .mv_ioremap = rts7751r2d_ioremap,
57 .mv_isa_port2addr = rts7751r2d_isa_port2addr,
58 .mv_init_irq = init_rts7751r2d_IRQ,
59#ifdef CONFIG_HEARTBEAT
60 .mv_heartbeat = heartbeat_rts7751r2d,
61#endif
62 .mv_irq_demux = rts7751r2d_irq_demux,
63
64#ifdef CONFIG_USB_OHCI_HCD
65 .mv_consistent_alloc = voyagergx_consistent_alloc,
66 .mv_consistent_free = voyagergx_consistent_free,
67#endif
68};
69ALIAS_MV(rts7751r2d)
diff --git a/arch/sh/boards/renesas/rts7751r2d/setup.c b/arch/sh/boards/renesas/rts7751r2d/setup.c
index 2587fd1a0240..20597a6e6702 100644
--- a/arch/sh/boards/renesas/rts7751r2d/setup.c
+++ b/arch/sh/boards/renesas/rts7751r2d/setup.c
@@ -1,31 +1,142 @@
1/* 1/*
2 * linux/arch/sh/kernel/setup_rts7751r2d.c
3 *
4 * Copyright (C) 2000 Kazumoto Kojima
5 *
6 * Renesas Technology Sales RTS7751R2D Support. 2 * Renesas Technology Sales RTS7751R2D Support.
7 * 3 *
8 * Modified for RTS7751R2D by 4 * Copyright (C) 2002 Atom Create Engineering Co., Ltd.
9 * Atom Create Engineering Co., Ltd. 2002. 5 * Copyright (C) 2004 - 2006 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */ 10 */
11
12#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/platform_device.h>
13#include <linux/serial_8250.h>
14#include <linux/pm.h>
13#include <asm/io.h> 15#include <asm/io.h>
14#include <asm/rts7751r2d/rts7751r2d.h> 16#include <asm/machvec.h>
17#include <asm/mach/rts7751r2d.h>
18#include <asm/voyagergx.h>
19
20extern void heartbeat_rts7751r2d(void);
21extern void init_rts7751r2d_IRQ(void);
22extern int rts7751r2d_irq_demux(int irq);
23
24extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
25extern int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
26
27static struct plat_serial8250_port uart_platform_data[] = {
28 {
29 .membase = (void *)VOYAGER_UART_BASE,
30 .mapbase = VOYAGER_UART_BASE,
31 .iotype = UPIO_MEM,
32 .irq = VOYAGER_UART0_IRQ,
33 .flags = UPF_BOOT_AUTOCONF,
34 .regshift = 2,
35 .uartclk = (9600 * 16),
36 }, {
37 .flags = 0,
38 },
39};
40
41static void __init voyagergx_serial_init(void)
42{
43 unsigned long val;
44
45 /*
46 * GPIO Control
47 */
48 val = inl(GPIO_MUX_HIGH);
49 val |= 0x00001fe0;
50 outl(val, GPIO_MUX_HIGH);
51
52 /*
53 * Power Mode Gate
54 */
55 val = inl(POWER_MODE0_GATE);
56 val |= (POWER_MODE0_GATE_U0 | POWER_MODE0_GATE_U1);
57 outl(val, POWER_MODE0_GATE);
58
59 val = inl(POWER_MODE1_GATE);
60 val |= (POWER_MODE1_GATE_U0 | POWER_MODE1_GATE_U1);
61 outl(val, POWER_MODE1_GATE);
62}
63
64static struct platform_device uart_device = {
65 .name = "serial8250",
66 .id = -1,
67 .dev = {
68 .platform_data = uart_platform_data,
69 },
70};
71
72static struct platform_device *rts7751r2d_devices[] __initdata = {
73 &uart_device,
74};
15 75
16unsigned int debug_counter; 76static int __init rts7751r2d_devices_setup(void)
77{
78 return platform_add_devices(rts7751r2d_devices,
79 ARRAY_SIZE(rts7751r2d_devices));
80}
17 81
18const char *get_system_type(void) 82static void rts7751r2d_power_off(void)
19{ 83{
20 return "RTS7751R2D"; 84 ctrl_outw(0x0001, PA_POWOFF);
21} 85}
22 86
23/* 87/*
24 * Initialize the board 88 * Initialize the board
25 */ 89 */
26void __init platform_setup(void) 90static void __init rts7751r2d_setup(char **cmdline_p)
27{ 91{
28 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n"); 92 device_initcall(rts7751r2d_devices_setup);
93
29 ctrl_outw(0x0000, PA_OUTPORT); 94 ctrl_outw(0x0000, PA_OUTPORT);
30 debug_counter = 0; 95 pm_power_off = rts7751r2d_power_off;
96
97 voyagergx_serial_init();
98
99 printk(KERN_INFO "Renesas Technology Sales RTS7751R2D support.\n");
31} 100}
101
102/*
103 * The Machine Vector
104 */
105struct sh_machine_vector mv_rts7751r2d __initmv = {
106 .mv_name = "RTS7751R2D",
107 .mv_setup = rts7751r2d_setup,
108 .mv_nr_irqs = 72,
109
110 .mv_inb = rts7751r2d_inb,
111 .mv_inw = rts7751r2d_inw,
112 .mv_inl = rts7751r2d_inl,
113 .mv_outb = rts7751r2d_outb,
114 .mv_outw = rts7751r2d_outw,
115 .mv_outl = rts7751r2d_outl,
116
117 .mv_inb_p = rts7751r2d_inb_p,
118 .mv_inw_p = rts7751r2d_inw,
119 .mv_inl_p = rts7751r2d_inl,
120 .mv_outb_p = rts7751r2d_outb_p,
121 .mv_outw_p = rts7751r2d_outw,
122 .mv_outl_p = rts7751r2d_outl,
123
124 .mv_insb = rts7751r2d_insb,
125 .mv_insw = rts7751r2d_insw,
126 .mv_insl = rts7751r2d_insl,
127 .mv_outsb = rts7751r2d_outsb,
128 .mv_outsw = rts7751r2d_outsw,
129 .mv_outsl = rts7751r2d_outsl,
130
131 .mv_init_irq = init_rts7751r2d_IRQ,
132#ifdef CONFIG_HEARTBEAT
133 .mv_heartbeat = heartbeat_rts7751r2d,
134#endif
135 .mv_irq_demux = rts7751r2d_irq_demux,
136
137#ifdef CONFIG_USB_SM501
138 .mv_consistent_alloc = voyagergx_consistent_alloc,
139 .mv_consistent_free = voyagergx_consistent_free,
140#endif
141};
142ALIAS_MV(rts7751r2d)
diff --git a/arch/sh/boards/renesas/sh7710voipgw/Makefile b/arch/sh/boards/renesas/sh7710voipgw/Makefile
new file mode 100644
index 000000000000..77037567633b
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7710voipgw/Makefile
@@ -0,0 +1 @@
obj-y := setup.o
diff --git a/arch/sh/boards/renesas/sh7710voipgw/setup.c b/arch/sh/boards/renesas/sh7710voipgw/setup.c
new file mode 100644
index 000000000000..e57e7afab8c6
--- /dev/null
+++ b/arch/sh/boards/renesas/sh7710voipgw/setup.c
@@ -0,0 +1,109 @@
1/*
2 * Renesas Technology SH7710 VoIP Gateway
3 *
4 * Copyright (C) 2006 Ranjit Deshpande
5 * Kenati Technologies Inc.
6 *
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
9 */
10#include <linux/init.h>
11#include <asm/machvec.h>
12#include <asm/irq.h>
13#include <asm/io.h>
14#include <asm/irq.h>
15
16/*
17 * Initialize IRQ setting
18 */
19static void __init sh7710voipgw_init_irq(void)
20{
21 /* Disable all interrupts in IPR registers */
22 ctrl_outw(0x0, INTC_IPRA);
23 ctrl_outw(0x0, INTC_IPRB);
24 ctrl_outw(0x0, INTC_IPRC);
25 ctrl_outw(0x0, INTC_IPRD);
26 ctrl_outw(0x0, INTC_IPRE);
27 ctrl_outw(0x0, INTC_IPRF);
28 ctrl_outw(0x0, INTC_IPRG);
29 ctrl_outw(0x0, INTC_IPRH);
30 ctrl_outw(0x0, INTC_IPRI);
31
32 /* Ack all interrupt sources in the IRR0 register */
33 ctrl_outb(0x3f, INTC_IRR0);
34
35 /* Use IRQ0 - IRQ3 as active low interrupt lines i.e. disable
36 * IRL mode.
37 */
38 ctrl_outw(0x2aa, INTC_ICR1);
39
40 /* Now make IPR interrupts */
41 make_ipr_irq(TIMER2_IRQ, TIMER2_IPR_ADDR,
42 TIMER2_IPR_POS, TIMER2_PRIORITY);
43 make_ipr_irq(WDT_IRQ, WDT_IPR_ADDR, WDT_IPR_POS, WDT_PRIORITY);
44
45 /* SCIF0 */
46 make_ipr_irq(SCIF0_ERI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
47 SCIF0_PRIORITY);
48 make_ipr_irq(SCIF0_RXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
49 SCIF0_PRIORITY);
50 make_ipr_irq(SCIF0_BRI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
51 SCIF0_PRIORITY);
52 make_ipr_irq(SCIF0_TXI_IRQ, SCIF0_IPR_ADDR, SCIF0_IPR_POS,
53 SCIF0_PRIORITY);
54
55 /* DMAC-1 */
56 make_ipr_irq(DMTE0_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
57 make_ipr_irq(DMTE1_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
58 make_ipr_irq(DMTE2_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
59 make_ipr_irq(DMTE3_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
60
61 /* DMAC-2 */
62 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
63 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
64
65 /* IPSEC */
66 make_ipr_irq(IPSEC_IRQ, IPSEC_IPR_ADDR, IPSEC_IPR_POS, IPSEC_PRIORITY);
67
68 /* EDMAC */
69 make_ipr_irq(EDMAC0_IRQ, EDMAC0_IPR_ADDR, EDMAC0_IPR_POS,
70 EDMAC0_PRIORITY);
71 make_ipr_irq(EDMAC1_IRQ, EDMAC1_IPR_ADDR, EDMAC1_IPR_POS,
72 EDMAC1_PRIORITY);
73 make_ipr_irq(EDMAC2_IRQ, EDMAC2_IPR_ADDR, EDMAC2_IPR_POS,
74 EDMAC2_PRIORITY);
75
76 /* SIOF0 */
77 make_ipr_irq(SIOF0_ERI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
78 SIOF0_PRIORITY);
79 make_ipr_irq(SIOF0_TXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
80 SIOF0_PRIORITY);
81 make_ipr_irq(SIOF0_RXI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
82 SIOF0_PRIORITY);
83 make_ipr_irq(SIOF0_CCI_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS,
84 SIOF0_PRIORITY);
85
86 /* SIOF1 */
87 make_ipr_irq(SIOF1_ERI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
88 SIOF1_PRIORITY);
89 make_ipr_irq(SIOF1_TXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
90 SIOF1_PRIORITY);
91 make_ipr_irq(SIOF1_RXI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
92 SIOF1_PRIORITY);
93 make_ipr_irq(SIOF1_CCI_IRQ, SIOF1_IPR_ADDR, SIOF1_IPR_POS,
94 SIOF1_PRIORITY);
95
96 /* SLIC IRQ's */
97 make_ipr_irq(IRQ1_IRQ, IRQ1_IPR_ADDR, IRQ1_IPR_POS, IRQ1_PRIORITY);
98 make_ipr_irq(IRQ2_IRQ, IRQ2_IPR_ADDR, IRQ2_IPR_POS, IRQ2_PRIORITY);
99}
100
101/*
102 * The Machine Vector
103 */
104struct sh_machine_vector mv_sh7710voipgw __initmv = {
105 .mv_name = "SH7710 VoIP Gateway",
106 .mv_nr_irqs = 104,
107 .mv_init_irq = sh7710voipgw_init_irq,
108};
109ALIAS_MV(sh7710voipgw)
diff --git a/arch/sh/boards/renesas/systemh/io.c b/arch/sh/boards/renesas/systemh/io.c
index cf979011aa94..cde6e5d192c4 100644
--- a/arch/sh/boards/renesas/systemh/io.c
+++ b/arch/sh/boards/renesas/systemh/io.c
@@ -5,66 +5,25 @@
5 * Based largely on io_se.c. 5 * Based largely on io_se.c.
6 * 6 *
7 * I/O routine for Hitachi 7751 Systemh. 7 * I/O routine for Hitachi 7751 Systemh.
8 *
9 */ 8 */
10
11#include <linux/kernel.h> 9#include <linux/kernel.h>
12#include <linux/types.h> 10#include <linux/types.h>
13#include <asm/systemh/7751systemh.h> 11#include <linux/pci.h>
12#include <asm/systemh7751.h>
14#include <asm/addrspace.h> 13#include <asm/addrspace.h>
15#include <asm/io.h> 14#include <asm/io.h>
16 15
17#include <linux/pci.h>
18#include "../../drivers/pci/pci-sh7751.h"
19
20/*
21 * The 7751 SystemH Engine uses the built-in PCI controller (PCIC)
22 * of the 7751 processor, and has a SuperIO accessible on its memory
23 * bus.
24 */
25
26#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
27#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
28#define PCI_IO_AREA SH7751_PCI_IO_BASE
29#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
30
31#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
32#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area 16#define ETHER_IOMAP(adr) (0xB3000000 + (adr)) /*map to 16bits access area
33 of smc lan chip*/ 17 of smc lan chip*/
34
35#define maybebadio(name,port) \
36 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
37 #name, (port), (__u32) __builtin_return_address(0))
38
39static inline void delay(void)
40{
41 ctrl_inw(0xa0000000);
42}
43
44static inline volatile __u16 * 18static inline volatile __u16 *
45port2adr(unsigned int port) 19port2adr(unsigned int port)
46{ 20{
47 if (port >= 0x2000) 21 if (port >= 0x2000)
48 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); 22 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
49#if 0 23 maybebadio((unsigned long)port);
50 else
51 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
52#endif
53 maybebadio(name,(unsigned long)port);
54 return (volatile __u16*)port; 24 return (volatile __u16*)port;
55} 25}
56 26
57/* In case someone configures the kernel w/o PCI support: in that */
58/* scenario, don't ever bother to check for PCI-window addresses */
59
60/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
61#if defined(CONFIG_PCI)
62#define CHECK_SH7751_PCIIO(port) \
63 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
64#else
65#define CHECK_SH7751_PCIIO(port) (0)
66#endif
67
68/* 27/*
69 * General outline: remap really low stuff [eventually] to SuperIO, 28 * General outline: remap really low stuff [eventually] to SuperIO,
70 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 29 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -76,8 +35,8 @@ unsigned char sh7751systemh_inb(unsigned long port)
76{ 35{
77 if (PXSEG(port)) 36 if (PXSEG(port))
78 return *(volatile unsigned char *)port; 37 return *(volatile unsigned char *)port;
79 else if (CHECK_SH7751_PCIIO(port)) 38 else if (is_pci_ioaddr(port))
80 return *(volatile unsigned char *)PCI_IOMAP(port); 39 return *(volatile unsigned char *)pci_ioaddr(port);
81 else if (port <= 0x3F1) 40 else if (port <= 0x3F1)
82 return *(volatile unsigned char *)ETHER_IOMAP(port); 41 return *(volatile unsigned char *)ETHER_IOMAP(port);
83 else 42 else
@@ -90,13 +49,13 @@ unsigned char sh7751systemh_inb_p(unsigned long port)
90 49
91 if (PXSEG(port)) 50 if (PXSEG(port))
92 v = *(volatile unsigned char *)port; 51 v = *(volatile unsigned char *)port;
93 else if (CHECK_SH7751_PCIIO(port)) 52 else if (is_pci_ioaddr(port))
94 v = *(volatile unsigned char *)PCI_IOMAP(port); 53 v = *(volatile unsigned char *)pci_ioaddr(port);
95 else if (port <= 0x3F1) 54 else if (port <= 0x3F1)
96 v = *(volatile unsigned char *)ETHER_IOMAP(port); 55 v = *(volatile unsigned char *)ETHER_IOMAP(port);
97 else 56 else
98 v = (*port2adr(port))&0xff; 57 v = (*port2adr(port))&0xff;
99 delay(); 58 ctrl_delay();
100 return v; 59 return v;
101} 60}
102 61
@@ -104,14 +63,14 @@ unsigned short sh7751systemh_inw(unsigned long port)
104{ 63{
105 if (PXSEG(port)) 64 if (PXSEG(port))
106 return *(volatile unsigned short *)port; 65 return *(volatile unsigned short *)port;
107 else if (CHECK_SH7751_PCIIO(port)) 66 else if (is_pci_ioaddr(port))
108 return *(volatile unsigned short *)PCI_IOMAP(port); 67 return *(volatile unsigned short *)pci_ioaddr(port);
109 else if (port >= 0x2000) 68 else if (port >= 0x2000)
110 return *port2adr(port); 69 return *port2adr(port);
111 else if (port <= 0x3F1) 70 else if (port <= 0x3F1)
112 return *(volatile unsigned int *)ETHER_IOMAP(port); 71 return *(volatile unsigned int *)ETHER_IOMAP(port);
113 else 72 else
114 maybebadio(inw, port); 73 maybebadio(port);
115 return 0; 74 return 0;
116} 75}
117 76
@@ -119,14 +78,14 @@ unsigned int sh7751systemh_inl(unsigned long port)
119{ 78{
120 if (PXSEG(port)) 79 if (PXSEG(port))
121 return *(volatile unsigned long *)port; 80 return *(volatile unsigned long *)port;
122 else if (CHECK_SH7751_PCIIO(port)) 81 else if (is_pci_ioaddr(port))
123 return *(volatile unsigned int *)PCI_IOMAP(port); 82 return *(volatile unsigned int *)pci_ioaddr(port);
124 else if (port >= 0x2000) 83 else if (port >= 0x2000)
125 return *port2adr(port); 84 return *port2adr(port);
126 else if (port <= 0x3F1) 85 else if (port <= 0x3F1)
127 return *(volatile unsigned int *)ETHER_IOMAP(port); 86 return *(volatile unsigned int *)ETHER_IOMAP(port);
128 else 87 else
129 maybebadio(inl, port); 88 maybebadio(port);
130 return 0; 89 return 0;
131} 90}
132 91
@@ -135,8 +94,8 @@ void sh7751systemh_outb(unsigned char value, unsigned long port)
135 94
136 if (PXSEG(port)) 95 if (PXSEG(port))
137 *(volatile unsigned char *)port = value; 96 *(volatile unsigned char *)port = value;
138 else if (CHECK_SH7751_PCIIO(port)) 97 else if (is_pci_ioaddr(port))
139 *((unsigned char*)PCI_IOMAP(port)) = value; 98 *((unsigned char*)pci_ioaddr(port)) = value;
140 else if (port <= 0x3F1) 99 else if (port <= 0x3F1)
141 *(volatile unsigned char *)ETHER_IOMAP(port) = value; 100 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
142 else 101 else
@@ -147,37 +106,37 @@ void sh7751systemh_outb_p(unsigned char value, unsigned long port)
147{ 106{
148 if (PXSEG(port)) 107 if (PXSEG(port))
149 *(volatile unsigned char *)port = value; 108 *(volatile unsigned char *)port = value;
150 else if (CHECK_SH7751_PCIIO(port)) 109 else if (is_pci_ioaddr(port))
151 *((unsigned char*)PCI_IOMAP(port)) = value; 110 *((unsigned char*)pci_ioaddr(port)) = value;
152 else if (port <= 0x3F1) 111 else if (port <= 0x3F1)
153 *(volatile unsigned char *)ETHER_IOMAP(port) = value; 112 *(volatile unsigned char *)ETHER_IOMAP(port) = value;
154 else 113 else
155 *(port2adr(port)) = value; 114 *(port2adr(port)) = value;
156 delay(); 115 ctrl_delay();
157} 116}
158 117
159void sh7751systemh_outw(unsigned short value, unsigned long port) 118void sh7751systemh_outw(unsigned short value, unsigned long port)
160{ 119{
161 if (PXSEG(port)) 120 if (PXSEG(port))
162 *(volatile unsigned short *)port = value; 121 *(volatile unsigned short *)port = value;
163 else if (CHECK_SH7751_PCIIO(port)) 122 else if (is_pci_ioaddr(port))
164 *((unsigned short *)PCI_IOMAP(port)) = value; 123 *((unsigned short *)pci_ioaddr(port)) = value;
165 else if (port >= 0x2000) 124 else if (port >= 0x2000)
166 *port2adr(port) = value; 125 *port2adr(port) = value;
167 else if (port <= 0x3F1) 126 else if (port <= 0x3F1)
168 *(volatile unsigned short *)ETHER_IOMAP(port) = value; 127 *(volatile unsigned short *)ETHER_IOMAP(port) = value;
169 else 128 else
170 maybebadio(outw, port); 129 maybebadio(port);
171} 130}
172 131
173void sh7751systemh_outl(unsigned int value, unsigned long port) 132void sh7751systemh_outl(unsigned int value, unsigned long port)
174{ 133{
175 if (PXSEG(port)) 134 if (PXSEG(port))
176 *(volatile unsigned long *)port = value; 135 *(volatile unsigned long *)port = value;
177 else if (CHECK_SH7751_PCIIO(port)) 136 else if (is_pci_ioaddr(port))
178 *((unsigned long*)PCI_IOMAP(port)) = value; 137 *((unsigned long*)pci_ioaddr(port)) = value;
179 else 138 else
180 maybebadio(outl, port); 139 maybebadio(port);
181} 140}
182 141
183void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count) 142void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count)
@@ -194,7 +153,7 @@ void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count)
194 153
195void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count) 154void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count)
196{ 155{
197 maybebadio(insl, port); 156 maybebadio(port);
198} 157}
199 158
200void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count) 159void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count)
@@ -211,73 +170,5 @@ void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long cou
211 170
212void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count) 171void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count)
213{ 172{
214 maybebadio(outsw, port); 173 maybebadio(port);
215}
216
217/* For read/write calls, just copy generic (pass-thru); PCIMBR is */
218/* already set up. For a larger memory space, these would need to */
219/* reset PCIMBR as needed on a per-call basis... */
220
221unsigned char sh7751systemh_readb(unsigned long addr)
222{
223 return *(volatile unsigned char*)addr;
224}
225
226unsigned short sh7751systemh_readw(unsigned long addr)
227{
228 return *(volatile unsigned short*)addr;
229}
230
231unsigned int sh7751systemh_readl(unsigned long addr)
232{
233 return *(volatile unsigned long*)addr;
234}
235
236void sh7751systemh_writeb(unsigned char b, unsigned long addr)
237{
238 *(volatile unsigned char*)addr = b;
239}
240
241void sh7751systemh_writew(unsigned short b, unsigned long addr)
242{
243 *(volatile unsigned short*)addr = b;
244}
245
246void sh7751systemh_writel(unsigned int b, unsigned long addr)
247{
248 *(volatile unsigned long*)addr = b;
249}
250
251
252
253/* Map ISA bus address to the real address. Only for PCMCIA. */
254
255/* ISA page descriptor. */
256static __u32 sh_isa_memmap[256];
257
258#if 0
259static int
260sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
261{
262 int idx;
263
264 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
265 return -1;
266
267 idx = start >> 12;
268 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
269 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
270 start, length, offset, idx, sh_isa_memmap[idx]);
271 return 0;
272}
273#endif
274
275unsigned long
276sh7751systemh_isa_port2addr(unsigned long offset)
277{
278 int idx;
279
280 idx = (offset >> 12) & 0xff;
281 offset &= 0xfff;
282 return sh_isa_memmap[idx] + offset;
283} 174}
diff --git a/arch/sh/boards/renesas/systemh/irq.c b/arch/sh/boards/renesas/systemh/irq.c
index 8372d967f601..8d016dae2333 100644
--- a/arch/sh/boards/renesas/systemh/irq.c
+++ b/arch/sh/boards/renesas/systemh/irq.c
@@ -15,7 +15,7 @@
15#include <linux/hdreg.h> 15#include <linux/hdreg.h>
16#include <linux/ide.h> 16#include <linux/ide.h>
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/mach/7751systemh.h> 18#include <asm/systemh7751.h>
19#include <asm/smc37c93x.h> 19#include <asm/smc37c93x.h>
20 20
21/* address of external interrupt mask register 21/* address of external interrupt mask register
@@ -57,12 +57,9 @@ static void shutdown_systemh_irq(unsigned int irq)
57static void disable_systemh_irq(unsigned int irq) 57static void disable_systemh_irq(unsigned int irq)
58{ 58{
59 if (systemh_irq_mask_register) { 59 if (systemh_irq_mask_register) {
60 unsigned long flags;
61 unsigned long val, mask = 0x01 << 1; 60 unsigned long val, mask = 0x01 << 1;
62 61
63 /* Clear the "irq"th bit in the mask and set it in the request */ 62 /* Clear the "irq"th bit in the mask and set it in the request */
64 local_irq_save(flags);
65
66 val = ctrl_inl((unsigned long)systemh_irq_mask_register); 63 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
67 val &= ~mask; 64 val &= ~mask;
68 ctrl_outl(val, (unsigned long)systemh_irq_mask_register); 65 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
@@ -70,23 +67,18 @@ static void disable_systemh_irq(unsigned int irq)
70 val = ctrl_inl((unsigned long)systemh_irq_request_register); 67 val = ctrl_inl((unsigned long)systemh_irq_request_register);
71 val |= mask; 68 val |= mask;
72 ctrl_outl(val, (unsigned long)systemh_irq_request_register); 69 ctrl_outl(val, (unsigned long)systemh_irq_request_register);
73
74 local_irq_restore(flags);
75 } 70 }
76} 71}
77 72
78static void enable_systemh_irq(unsigned int irq) 73static void enable_systemh_irq(unsigned int irq)
79{ 74{
80 if (systemh_irq_mask_register) { 75 if (systemh_irq_mask_register) {
81 unsigned long flags;
82 unsigned long val, mask = 0x01 << 1; 76 unsigned long val, mask = 0x01 << 1;
83 77
84 /* Set "irq"th bit in the mask register */ 78 /* Set "irq"th bit in the mask register */
85 local_irq_save(flags);
86 val = ctrl_inl((unsigned long)systemh_irq_mask_register); 79 val = ctrl_inl((unsigned long)systemh_irq_mask_register);
87 val |= mask; 80 val |= mask;
88 ctrl_outl(val, (unsigned long)systemh_irq_mask_register); 81 ctrl_outl(val, (unsigned long)systemh_irq_mask_register);
89 local_irq_restore(flags);
90 } 82 }
91} 83}
92 84
diff --git a/arch/sh/boards/renesas/systemh/setup.c b/arch/sh/boards/renesas/systemh/setup.c
index 826fa3d7669c..a8467bf90c25 100644
--- a/arch/sh/boards/renesas/systemh/setup.c
+++ b/arch/sh/boards/renesas/systemh/setup.c
@@ -15,28 +15,21 @@
15 * for more details. 15 * for more details.
16 */ 16 */
17#include <linux/init.h> 17#include <linux/init.h>
18#include <asm/mach/7751systemh.h>
19#include <asm/mach/io.h>
20#include <asm/machvec.h> 18#include <asm/machvec.h>
19#include <asm/systemh7751.h>
21 20
22extern void make_systemh_irq(unsigned int irq); 21extern void make_systemh_irq(unsigned int irq);
23 22
24const char *get_system_type(void)
25{
26 return "7751 SystemH";
27}
28
29/* 23/*
30 * Initialize IRQ setting 24 * Initialize IRQ setting
31 */ 25 */
32void __init init_7751systemh_IRQ(void) 26static void __init sh7751systemh_init_irq(void)
33{ 27{
34/* make_ipr_irq(10, BCR_ILCRD, 1, 0x0f-10); LAN */
35/* make_ipr_irq(14, BCR_ILCRA, 2, 0x0f-4); */
36 make_systemh_irq(0xb); /* Ethernet interrupt */ 28 make_systemh_irq(0xb); /* Ethernet interrupt */
37} 29}
38 30
39struct sh_machine_vector mv_7751systemh __initmv = { 31struct sh_machine_vector mv_7751systemh __initmv = {
32 .mv_name = "7751 SystemH",
40 .mv_nr_irqs = 72, 33 .mv_nr_irqs = 72,
41 34
42 .mv_inb = sh7751systemh_inb, 35 .mv_inb = sh7751systemh_inb,
@@ -60,21 +53,6 @@ struct sh_machine_vector mv_7751systemh __initmv = {
60 .mv_outsw = sh7751systemh_outsw, 53 .mv_outsw = sh7751systemh_outsw,
61 .mv_outsl = sh7751systemh_outsl, 54 .mv_outsl = sh7751systemh_outsl,
62 55
63 .mv_readb = sh7751systemh_readb, 56 .mv_init_irq = sh7751system_init_irq,
64 .mv_readw = sh7751systemh_readw,
65 .mv_readl = sh7751systemh_readl,
66 .mv_writeb = sh7751systemh_writeb,
67 .mv_writew = sh7751systemh_writew,
68 .mv_writel = sh7751systemh_writel,
69
70 .mv_isa_port2addr = sh7751systemh_isa_port2addr,
71
72 .mv_init_irq = init_7751systemh_IRQ,
73}; 57};
74ALIAS_MV(7751systemh) 58ALIAS_MV(7751systemh)
75
76int __init platform_setup(void)
77{
78 return 0;
79}
80
diff --git a/arch/sh/boards/saturn/setup.c b/arch/sh/boards/saturn/setup.c
index bea6c572ad82..a3a37c9aad2e 100644
--- a/arch/sh/boards/saturn/setup.c
+++ b/arch/sh/boards/saturn/setup.c
@@ -9,22 +9,17 @@
9 */ 9 */
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/init.h> 11#include <linux/init.h>
12
13#include <asm/io.h> 12#include <asm/io.h>
14#include <asm/machvec.h> 13#include <asm/machvec.h>
15#include <asm/mach/io.h> 14#include <asm/mach/io.h>
16 15
17extern int saturn_irq_demux(int irq_nr); 16extern int saturn_irq_demux(int irq_nr);
18 17
19const char *get_system_type(void)
20{
21 return "Sega Saturn";
22}
23
24/* 18/*
25 * The Machine Vector 19 * The Machine Vector
26 */ 20 */
27struct sh_machine_vector mv_saturn __initmv = { 21struct sh_machine_vector mv_saturn __initmv = {
22 .mv_name = "Sega Saturn",
28 .mv_nr_irqs = 80, /* Fix this later */ 23 .mv_nr_irqs = 80, /* Fix this later */
29 24
30 .mv_isa_port2addr = saturn_isa_port2addr, 25 .mv_isa_port2addr = saturn_isa_port2addr,
@@ -33,11 +28,4 @@ struct sh_machine_vector mv_saturn __initmv = {
33 .mv_ioremap = saturn_ioremap, 28 .mv_ioremap = saturn_ioremap,
34 .mv_iounmap = saturn_iounmap, 29 .mv_iounmap = saturn_iounmap,
35}; 30};
36
37ALIAS_MV(saturn) 31ALIAS_MV(saturn)
38
39int __init platform_setup(void)
40{
41 return 0;
42}
43
diff --git a/arch/sh/boards/se/7300/io.c b/arch/sh/boards/se/7300/io.c
index f449a94ddffd..8a03d7a52a7c 100644
--- a/arch/sh/boards/se/7300/io.c
+++ b/arch/sh/boards/se/7300/io.c
@@ -9,8 +9,8 @@
9 */ 9 */
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <asm/mach/se7300.h>
13#include <asm/io.h> 12#include <asm/io.h>
13#include <asm/se7300.h>
14 14
15#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a) 15#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
16 16
@@ -99,6 +99,7 @@ bad_outb(struct iop *p, unsigned char value, unsigned long port)
99 badio(inw, port); 99 badio(inw, port);
100} 100}
101 101
102#ifdef CONFIG_SMC91X
102/* MSTLANEX01 LAN at 0xb400:0000 */ 103/* MSTLANEX01 LAN at 0xb400:0000 */
103static struct iop laniop = { 104static struct iop laniop = {
104 .start = 0x300, 105 .start = 0x300,
@@ -110,6 +111,7 @@ static struct iop laniop = {
110 .outb = simple_outb, 111 .outb = simple_outb,
111 .outw = simple_outw, 112 .outw = simple_outw,
112}; 113};
114#endif
113 115
114/* NE2000 pc card NIC */ 116/* NE2000 pc card NIC */
115static struct iop neiop = { 117static struct iop neiop = {
@@ -123,6 +125,7 @@ static struct iop neiop = {
123 .outw = simple_outw, 125 .outw = simple_outw,
124}; 126};
125 127
128#ifdef CONFIG_IDE
126/* CF in CF slot */ 129/* CF in CF slot */
127static struct iop cfiop = { 130static struct iop cfiop = {
128 .base = 0xb0600000, 131 .base = 0xb0600000,
@@ -132,12 +135,13 @@ static struct iop cfiop = {
132 .outb = pcc_outb, 135 .outb = pcc_outb,
133 .outw = simple_outw, 136 .outw = simple_outw,
134}; 137};
138#endif
135 139
136static __inline__ struct iop * 140static __inline__ struct iop *
137port2iop(unsigned long port) 141port2iop(unsigned long port)
138{ 142{
139 if (0) ; 143 if (0) ;
140#if defined(CONFIG_SMC91111) 144#if defined(CONFIG_SMC91X)
141 else if (laniop.check(&laniop, port)) 145 else if (laniop.check(&laniop, port))
142 return &laniop; 146 return &laniop;
143#endif 147#endif
diff --git a/arch/sh/boards/se/7300/irq.c b/arch/sh/boards/se/7300/irq.c
index 216a78d1a108..ad1034f98a29 100644
--- a/arch/sh/boards/se/7300/irq.c
+++ b/arch/sh/boards/se/7300/irq.c
@@ -11,7 +11,7 @@
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <asm/irq.h> 12#include <asm/irq.h>
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/mach/se7300.h> 14#include <asm/se7300.h>
15 15
16/* 16/*
17 * Initialize IRQ setting 17 * Initialize IRQ setting
diff --git a/arch/sh/boards/se/7300/led.c b/arch/sh/boards/se/7300/led.c
index ad51f0a9c1e3..4d03bb7774be 100644
--- a/arch/sh/boards/se/7300/led.c
+++ b/arch/sh/boards/se/7300/led.c
@@ -12,24 +12,10 @@
12 */ 12 */
13 13
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <asm/mach/se7300.h> 15#include <asm/se7300.h>
16
17static void
18mach_led(int position, int value)
19{
20 volatile unsigned short *p = (volatile unsigned short *) PA_LED;
21
22 if (value) {
23 *p |= (1 << 8);
24 } else {
25 *p &= ~(1 << 8);
26 }
27}
28
29 16
30/* Cycle the LED's in the clasic Knightrider/Sun pattern */ 17/* Cycle the LED's in the clasic Knightrider/Sun pattern */
31void 18void heartbeat_7300se(void)
32heartbeat_7300se(void)
33{ 19{
34 static unsigned int cnt = 0, period = 0; 20 static unsigned int cnt = 0, period = 0;
35 volatile unsigned short *p = (volatile unsigned short *) PA_LED; 21 volatile unsigned short *p = (volatile unsigned short *) PA_LED;
diff --git a/arch/sh/boards/se/7300/setup.c b/arch/sh/boards/se/7300/setup.c
index ebcd98d4c081..6f082a722d42 100644
--- a/arch/sh/boards/se/7300/setup.c
+++ b/arch/sh/boards/se/7300/setup.c
@@ -9,23 +9,16 @@
9 9
10#include <linux/init.h> 10#include <linux/init.h>
11#include <asm/machvec.h> 11#include <asm/machvec.h>
12#include <asm/machvec_init.h> 12#include <asm/se7300.h>
13#include <asm/mach/io.h>
14 13
15void heartbeat_7300se(void); 14void heartbeat_7300se(void);
16void init_7300se_IRQ(void); 15void init_7300se_IRQ(void);
17 16
18const char *
19get_system_type(void)
20{
21 return "SolutionEngine 7300";
22}
23
24/* 17/*
25 * The Machine Vector 18 * The Machine Vector
26 */ 19 */
27
28struct sh_machine_vector mv_7300se __initmv = { 20struct sh_machine_vector mv_7300se __initmv = {
21 .mv_name = "SolutionEngine 7300",
29 .mv_nr_irqs = 109, 22 .mv_nr_irqs = 109,
30 .mv_inb = sh7300se_inb, 23 .mv_inb = sh7300se_inb,
31 .mv_inw = sh7300se_inw, 24 .mv_inw = sh7300se_inw,
@@ -53,13 +46,4 @@ struct sh_machine_vector mv_7300se __initmv = {
53 .mv_heartbeat = heartbeat_7300se, 46 .mv_heartbeat = heartbeat_7300se,
54#endif 47#endif
55}; 48};
56
57ALIAS_MV(7300se) 49ALIAS_MV(7300se)
58/*
59 * Initialize the board
60 */
61void __init
62platform_setup(void)
63{
64
65}
diff --git a/arch/sh/boards/se/73180/io.c b/arch/sh/boards/se/73180/io.c
index 755df5ac4a4e..72715575458b 100644
--- a/arch/sh/boards/se/73180/io.c
+++ b/arch/sh/boards/se/73180/io.c
@@ -99,6 +99,7 @@ bad_outb(struct iop *p, unsigned char value, unsigned long port)
99 badio(inw, port); 99 badio(inw, port);
100} 100}
101 101
102#ifdef CONFIG_SMC91X
102/* MSTLANEX01 LAN at 0xb400:0000 */ 103/* MSTLANEX01 LAN at 0xb400:0000 */
103static struct iop laniop = { 104static struct iop laniop = {
104 .start = 0x300, 105 .start = 0x300,
@@ -110,6 +111,7 @@ static struct iop laniop = {
110 .outb = simple_outb, 111 .outb = simple_outb,
111 .outw = simple_outw, 112 .outw = simple_outw,
112}; 113};
114#endif
113 115
114/* NE2000 pc card NIC */ 116/* NE2000 pc card NIC */
115static struct iop neiop = { 117static struct iop neiop = {
@@ -123,6 +125,7 @@ static struct iop neiop = {
123 .outw = simple_outw, 125 .outw = simple_outw,
124}; 126};
125 127
128#ifdef CONFIG_IDE
126/* CF in CF slot */ 129/* CF in CF slot */
127static struct iop cfiop = { 130static struct iop cfiop = {
128 .base = 0xb0600000, 131 .base = 0xb0600000,
@@ -132,12 +135,13 @@ static struct iop cfiop = {
132 .outb = pcc_outb, 135 .outb = pcc_outb,
133 .outw = simple_outw, 136 .outw = simple_outw,
134}; 137};
138#endif
135 139
136static __inline__ struct iop * 140static __inline__ struct iop *
137port2iop(unsigned long port) 141port2iop(unsigned long port)
138{ 142{
139 if (0) ; 143 if (0) ;
140#if defined(CONFIG_SMC91111) 144#if defined(CONFIG_SMC91X)
141 else if (laniop.check(&laniop, port)) 145 else if (laniop.check(&laniop, port))
142 return &laniop; 146 return &laniop;
143#endif 147#endif
diff --git a/arch/sh/boards/se/73180/irq.c b/arch/sh/boards/se/73180/irq.c
index 4344d0ef24aa..2c62b8ea350e 100644
--- a/arch/sh/boards/se/73180/irq.c
+++ b/arch/sh/boards/se/73180/irq.c
@@ -7,7 +7,6 @@
7 * Modified for SH-Mobile SolutionEngine 73180 Support 7 * Modified for SH-Mobile SolutionEngine 73180 Support
8 * by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp> 8 * by YOSHII Takashi <yoshii-takashi@hitachi-ul.co.jp>
9 * 9 *
10 *
11 */ 10 */
12 11
13#include <linux/init.h> 12#include <linux/init.h>
@@ -17,14 +16,6 @@
17#include <asm/mach/se73180.h> 16#include <asm/mach/se73180.h>
18 17
19static int 18static int
20intreq2irq(int i)
21{
22 if (i == 5)
23 return 10;
24 return 32 + 7 - i;
25}
26
27static int
28irq2intreq(int irq) 19irq2intreq(int irq)
29{ 20{
30 if (irq == 10) 21 if (irq == 10)
diff --git a/arch/sh/boards/se/73180/led.c b/arch/sh/boards/se/73180/led.c
index 610439fde6ee..4b72e9a3ead9 100644
--- a/arch/sh/boards/se/73180/led.c
+++ b/arch/sh/boards/se/73180/led.c
@@ -14,21 +14,8 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <asm/mach/se73180.h> 15#include <asm/mach/se73180.h>
16 16
17static void
18mach_led(int position, int value)
19{
20 volatile unsigned short *p = (volatile unsigned short *) PA_LED;
21
22 if (value) {
23 *p |= (1 << LED_SHIFT);
24 } else {
25 *p &= ~(1 << LED_SHIFT);
26 }
27}
28
29/* Cycle the LED's in the clasic Knightrider/Sun pattern */ 17/* Cycle the LED's in the clasic Knightrider/Sun pattern */
30void 18void heartbeat_73180se(void)
31heartbeat_73180se(void)
32{ 19{
33 static unsigned int cnt = 0, period = 0; 20 static unsigned int cnt = 0, period = 0;
34 volatile unsigned short *p = (volatile unsigned short *) PA_LED; 21 volatile unsigned short *p = (volatile unsigned short *) PA_LED;
diff --git a/arch/sh/boards/se/73180/setup.c b/arch/sh/boards/se/73180/setup.c
index cdb7b5f8d942..b38ef50a160a 100644
--- a/arch/sh/boards/se/73180/setup.c
+++ b/arch/sh/boards/se/73180/setup.c
@@ -11,23 +11,17 @@
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/machvec.h> 13#include <asm/machvec.h>
14#include <asm/machvec_init.h> 14#include <asm/se73180.h>
15#include <asm/mach/io.h> 15#include <asm/irq.h>
16 16
17void heartbeat_73180se(void); 17void heartbeat_73180se(void);
18void init_73180se_IRQ(void); 18void init_73180se_IRQ(void);
19 19
20const char *
21get_system_type(void)
22{
23 return "SolutionEngine 73180";
24}
25
26/* 20/*
27 * The Machine Vector 21 * The Machine Vector
28 */ 22 */
29
30struct sh_machine_vector mv_73180se __initmv = { 23struct sh_machine_vector mv_73180se __initmv = {
24 .mv_name = "SolutionEngine 73180",
31 .mv_nr_irqs = 108, 25 .mv_nr_irqs = 108,
32 .mv_inb = sh73180se_inb, 26 .mv_inb = sh73180se_inb,
33 .mv_inw = sh73180se_inw, 27 .mv_inw = sh73180se_inw,
@@ -51,17 +45,9 @@ struct sh_machine_vector mv_73180se __initmv = {
51 .mv_outsl = sh73180se_outsl, 45 .mv_outsl = sh73180se_outsl,
52 46
53 .mv_init_irq = init_73180se_IRQ, 47 .mv_init_irq = init_73180se_IRQ,
48 .mv_irq_demux = shmse_irq_demux,
54#ifdef CONFIG_HEARTBEAT 49#ifdef CONFIG_HEARTBEAT
55 .mv_heartbeat = heartbeat_73180se, 50 .mv_heartbeat = heartbeat_73180se,
56#endif 51#endif
57}; 52};
58
59ALIAS_MV(73180se) 53ALIAS_MV(73180se)
60/*
61 * Initialize the board
62 */
63void __init
64platform_setup(void)
65{
66
67}
diff --git a/arch/sh/boards/se/7343/Makefile b/arch/sh/boards/se/7343/Makefile
new file mode 100644
index 000000000000..4291069c0b4f
--- /dev/null
+++ b/arch/sh/boards/se/7343/Makefile
@@ -0,0 +1,7 @@
1#
2# Makefile for the 7343 SolutionEngine specific parts of the kernel
3#
4
5obj-y := setup.o io.o irq.o
6
7obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/7343/io.c b/arch/sh/boards/se/7343/io.c
new file mode 100644
index 000000000000..646661a146ad
--- /dev/null
+++ b/arch/sh/boards/se/7343/io.c
@@ -0,0 +1,275 @@
1/*
2 * arch/sh/boards/se/7343/io.c
3 *
4 * I/O routine for SH-Mobile3AS 7343 SolutionEngine.
5 *
6 */
7
8#include <linux/config.h>
9#include <linux/kernel.h>
10#include <asm/io.h>
11#include <asm/mach/se7343.h>
12
13#define badio(fn, a) panic("bad i/o operation %s for %08lx.", #fn, a)
14
15struct iop {
16 unsigned long start, end;
17 unsigned long base;
18 struct iop *(*check) (struct iop * p, unsigned long port);
19 unsigned char (*inb) (struct iop * p, unsigned long port);
20 unsigned short (*inw) (struct iop * p, unsigned long port);
21 void (*outb) (struct iop * p, unsigned char value, unsigned long port);
22 void (*outw) (struct iop * p, unsigned short value, unsigned long port);
23};
24
25struct iop *
26simple_check(struct iop *p, unsigned long port)
27{
28 static int count;
29
30 if (count < 100)
31 count++;
32
33 port &= 0xFFFF;
34
35 if ((p->start <= port) && (port <= p->end))
36 return p;
37 else
38 badio(check, port);
39}
40
41struct iop *
42ide_check(struct iop *p, unsigned long port)
43{
44 if (((0x1f0 <= port) && (port <= 0x1f7)) || (port == 0x3f7))
45 return p;
46 return NULL;
47}
48
49unsigned char
50simple_inb(struct iop *p, unsigned long port)
51{
52 return *(unsigned char *) (p->base + port);
53}
54
55unsigned short
56simple_inw(struct iop *p, unsigned long port)
57{
58 return *(unsigned short *) (p->base + port);
59}
60
61void
62simple_outb(struct iop *p, unsigned char value, unsigned long port)
63{
64 *(unsigned char *) (p->base + port) = value;
65}
66
67void
68simple_outw(struct iop *p, unsigned short value, unsigned long port)
69{
70 *(unsigned short *) (p->base + port) = value;
71}
72
73unsigned char
74pcc_inb(struct iop *p, unsigned long port)
75{
76 unsigned long addr = p->base + port + 0x40000;
77 unsigned long v;
78
79 if (port & 1)
80 addr += 0x00400000;
81 v = *(volatile unsigned char *) addr;
82 return v;
83}
84
85void
86pcc_outb(struct iop *p, unsigned char value, unsigned long port)
87{
88 unsigned long addr = p->base + port + 0x40000;
89
90 if (port & 1)
91 addr += 0x00400000;
92 *(volatile unsigned char *) addr = value;
93}
94
95unsigned char
96bad_inb(struct iop *p, unsigned long port)
97{
98 badio(inb, port);
99}
100
101void
102bad_outb(struct iop *p, unsigned char value, unsigned long port)
103{
104 badio(inw, port);
105}
106
107#ifdef CONFIG_SMC91X
108/* MSTLANEX01 LAN at 0xb400:0000 */
109static struct iop laniop = {
110 .start = 0x00,
111 .end = 0x0F,
112 .base = 0x04000000,
113 .check = simple_check,
114 .inb = simple_inb,
115 .inw = simple_inw,
116 .outb = simple_outb,
117 .outw = simple_outw,
118};
119#endif
120
121#ifdef CONFIG_NE2000
122/* NE2000 pc card NIC */
123static struct iop neiop = {
124 .start = 0x280,
125 .end = 0x29f,
126 .base = 0xb0600000 + 0x80, /* soft 0x280 -> hard 0x300 */
127 .check = simple_check,
128 .inb = pcc_inb,
129 .inw = simple_inw,
130 .outb = pcc_outb,
131 .outw = simple_outw,
132};
133#endif
134
135#ifdef CONFIG_IDE
136/* CF in CF slot */
137static struct iop cfiop = {
138 .base = 0xb0600000,
139 .check = ide_check,
140 .inb = pcc_inb,
141 .inw = simple_inw,
142 .outb = pcc_outb,
143 .outw = simple_outw,
144};
145#endif
146
147static __inline__ struct iop *
148port2iop(unsigned long port)
149{
150 if (0) ;
151#if defined(CONFIG_SMC91X)
152 else if (laniop.check(&laniop, port))
153 return &laniop;
154#endif
155#if defined(CONFIG_NE2000)
156 else if (neiop.check(&neiop, port))
157 return &neiop;
158#endif
159#if defined(CONFIG_IDE)
160 else if (cfiop.check(&cfiop, port))
161 return &cfiop;
162#endif
163 else
164 return NULL;
165}
166
167static inline void
168delay(void)
169{
170 ctrl_inw(0xac000000);
171 ctrl_inw(0xac000000);
172}
173
174unsigned char
175sh7343se_inb(unsigned long port)
176{
177 struct iop *p = port2iop(port);
178 return (p->inb) (p, port);
179}
180
181unsigned char
182sh7343se_inb_p(unsigned long port)
183{
184 unsigned char v = sh7343se_inb(port);
185 delay();
186 return v;
187}
188
189unsigned short
190sh7343se_inw(unsigned long port)
191{
192 struct iop *p = port2iop(port);
193 return (p->inw) (p, port);
194}
195
196unsigned int
197sh7343se_inl(unsigned long port)
198{
199 badio(inl, port);
200}
201
202void
203sh7343se_outb(unsigned char value, unsigned long port)
204{
205 struct iop *p = port2iop(port);
206 (p->outb) (p, value, port);
207}
208
209void
210sh7343se_outb_p(unsigned char value, unsigned long port)
211{
212 sh7343se_outb(value, port);
213 delay();
214}
215
216void
217sh7343se_outw(unsigned short value, unsigned long port)
218{
219 struct iop *p = port2iop(port);
220 (p->outw) (p, value, port);
221}
222
223void
224sh7343se_outl(unsigned int value, unsigned long port)
225{
226 badio(outl, port);
227}
228
229void
230sh7343se_insb(unsigned long port, void *addr, unsigned long count)
231{
232 unsigned char *a = addr;
233 struct iop *p = port2iop(port);
234 while (count--)
235 *a++ = (p->inb) (p, port);
236}
237
238void
239sh7343se_insw(unsigned long port, void *addr, unsigned long count)
240{
241 unsigned short *a = addr;
242 struct iop *p = port2iop(port);
243 while (count--)
244 *a++ = (p->inw) (p, port);
245}
246
247void
248sh7343se_insl(unsigned long port, void *addr, unsigned long count)
249{
250 badio(insl, port);
251}
252
253void
254sh7343se_outsb(unsigned long port, const void *addr, unsigned long count)
255{
256 unsigned char *a = (unsigned char *) addr;
257 struct iop *p = port2iop(port);
258 while (count--)
259 (p->outb) (p, *a++, port);
260}
261
262void
263sh7343se_outsw(unsigned long port, const void *addr, unsigned long count)
264{
265 unsigned short *a = (unsigned short *) addr;
266 struct iop *p = port2iop(port);
267 while (count--)
268 (p->outw) (p, *a++, port);
269}
270
271void
272sh7343se_outsl(unsigned long port, const void *addr, unsigned long count)
273{
274 badio(outsw, port);
275}
diff --git a/arch/sh/boards/se/7343/irq.c b/arch/sh/boards/se/7343/irq.c
new file mode 100644
index 000000000000..b41e3d4ea37c
--- /dev/null
+++ b/arch/sh/boards/se/7343/irq.c
@@ -0,0 +1,193 @@
1/*
2 * arch/sh/boards/se/7343/irq.c
3 *
4 */
5
6#include <linux/config.h>
7#include <linux/init.h>
8#include <linux/interrupt.h>
9#include <linux/irq.h>
10#include <asm/irq.h>
11#include <asm/io.h>
12#include <asm/mach/se7343.h>
13
14static void
15disable_intreq_irq(unsigned int irq)
16{
17 int bit = irq - OFFCHIP_IRQ_BASE;
18 u16 val;
19
20 val = ctrl_inw(PA_CPLD_IMSK);
21 val |= 1 << bit;
22 ctrl_outw(val, PA_CPLD_IMSK);
23}
24
25static void
26enable_intreq_irq(unsigned int irq)
27{
28 int bit = irq - OFFCHIP_IRQ_BASE;
29 u16 val;
30
31 val = ctrl_inw(PA_CPLD_IMSK);
32 val &= ~(1 << bit);
33 ctrl_outw(val, PA_CPLD_IMSK);
34}
35
36static void
37mask_and_ack_intreq_irq(unsigned int irq)
38{
39 disable_intreq_irq(irq);
40}
41
42static unsigned int
43startup_intreq_irq(unsigned int irq)
44{
45 enable_intreq_irq(irq);
46 return 0;
47}
48
49static void
50shutdown_intreq_irq(unsigned int irq)
51{
52 disable_intreq_irq(irq);
53}
54
55static void
56end_intreq_irq(unsigned int irq)
57{
58 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
59 enable_intreq_irq(irq);
60}
61
62static struct hw_interrupt_type intreq_irq_type = {
63 .typename = "FPGA-IRQ",
64 .startup = startup_intreq_irq,
65 .shutdown = shutdown_intreq_irq,
66 .enable = enable_intreq_irq,
67 .disable = disable_intreq_irq,
68 .ack = mask_and_ack_intreq_irq,
69 .end = end_intreq_irq
70};
71
72static void
73make_intreq_irq(unsigned int irq)
74{
75 disable_irq_nosync(irq);
76 irq_desc[irq].handler = &intreq_irq_type;
77 disable_intreq_irq(irq);
78}
79
80int
81shmse_irq_demux(int irq)
82{
83 int bit;
84 volatile u16 val;
85
86 if (irq == IRQ5_IRQ) {
87 /* Read status Register */
88 val = ctrl_inw(PA_CPLD_ST);
89 bit = ffs(val);
90 if (bit != 0)
91 return OFFCHIP_IRQ_BASE + bit - 1;
92 }
93 return irq;
94}
95
96/* IRQ5 is multiplexed between the following sources:
97 * 1. PC Card socket
98 * 2. Extension slot
99 * 3. USB Controller
100 * 4. Serial Controller
101 *
102 * We configure IRQ5 as a cascade IRQ.
103 */
104static struct irqaction irq5 = { no_action, 0, CPU_MASK_NONE, "IRQ5-cascade",
105 NULL, NULL};
106
107/*
108 * Initialize IRQ setting
109 */
110void __init
111init_7343se_IRQ(void)
112{
113 /* Setup Multiplexed interrupts */
114 ctrl_outw(8, PA_CPLD_MODESET); /* Set all CPLD interrupts to active
115 * low.
116 */
117 /* Mask all CPLD controller interrupts */
118 ctrl_outw(0x0fff, PA_CPLD_IMSK);
119
120 /* PC Card interrupts */
121 make_intreq_irq(PC_IRQ0);
122 make_intreq_irq(PC_IRQ1);
123 make_intreq_irq(PC_IRQ2);
124 make_intreq_irq(PC_IRQ3);
125
126 /* Extension Slot Interrupts */
127 make_intreq_irq(EXT_IRQ0);
128 make_intreq_irq(EXT_IRQ1);
129 make_intreq_irq(EXT_IRQ2);
130 make_intreq_irq(EXT_IRQ3);
131
132 /* USB Controller interrupts */
133 make_intreq_irq(USB_IRQ0);
134 make_intreq_irq(USB_IRQ1);
135
136 /* Serial Controller interrupts */
137 make_intreq_irq(UART_IRQ0);
138 make_intreq_irq(UART_IRQ1);
139
140 /* Setup all external interrupts to be active low */
141 ctrl_outw(0xaaaa, INTC_ICR1);
142
143 make_ipr_irq(IRQ5_IRQ, IRQ5_IPR_ADDR+2, IRQ5_IPR_POS, IRQ5_PRIORITY);
144 setup_irq(IRQ5_IRQ, &irq5);
145 /* Set port control to use IRQ5 */
146 *(u16 *)0xA4050108 &= ~0xc;
147
148 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
149 make_ipr_irq(VPU_IRQ, VPU_IPR_ADDR, VPU_IPR_POS, 8);
150
151 ctrl_outb(0x0f, INTC_IMCR5); /* enable SCIF IRQ */
152
153 make_ipr_irq(DMTE0_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
154 make_ipr_irq(DMTE1_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
155 make_ipr_irq(DMTE2_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
156 make_ipr_irq(DMTE3_IRQ, DMA1_IPR_ADDR, DMA1_IPR_POS, DMA1_PRIORITY);
157 make_ipr_irq(DMTE4_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
158 make_ipr_irq(DMTE5_IRQ, DMA2_IPR_ADDR, DMA2_IPR_POS, DMA2_PRIORITY);
159
160 /* I2C block */
161 make_ipr_irq(IIC0_ALI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
162 make_ipr_irq(IIC0_TACKI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
163 IIC0_PRIORITY);
164 make_ipr_irq(IIC0_WAITI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS,
165 IIC0_PRIORITY);
166 make_ipr_irq(IIC0_DTEI_IRQ, IIC0_IPR_ADDR, IIC0_IPR_POS, IIC0_PRIORITY);
167
168 make_ipr_irq(IIC1_ALI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
169 make_ipr_irq(IIC1_TACKI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
170 IIC1_PRIORITY);
171 make_ipr_irq(IIC1_WAITI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS,
172 IIC1_PRIORITY);
173 make_ipr_irq(IIC1_DTEI_IRQ, IIC1_IPR_ADDR, IIC1_IPR_POS, IIC1_PRIORITY);
174
175 /* SIOF */
176 make_ipr_irq(SIOF0_IRQ, SIOF0_IPR_ADDR, SIOF0_IPR_POS, SIOF0_PRIORITY);
177
178 /* SIU */
179 make_ipr_irq(SIU_IRQ, SIU_IPR_ADDR, SIU_IPR_POS, SIU_PRIORITY);
180
181 /* VIO interrupt */
182 make_ipr_irq(CEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
183 make_ipr_irq(BEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
184 make_ipr_irq(VEU_IRQ, VIO_IPR_ADDR, VIO_IPR_POS, VIO_PRIORITY);
185
186 /*MFI interrupt*/
187
188 make_ipr_irq(MFI_IRQ, MFI_IPR_ADDR, MFI_IPR_POS, MFI_PRIORITY);
189
190 /* LCD controller */
191 make_ipr_irq(LCDC_IRQ, LCDC_IPR_ADDR, LCDC_IPR_POS, LCDC_PRIORITY);
192 ctrl_outw(0x2000, PA_MRSHPC + 0x0c); /* mrshpc irq enable */
193}
diff --git a/arch/sh/boards/se/7343/led.c b/arch/sh/boards/se/7343/led.c
new file mode 100644
index 000000000000..6a439cf83e46
--- /dev/null
+++ b/arch/sh/boards/se/7343/led.c
@@ -0,0 +1,46 @@
1/*
2 * arch/sh/boards/se/7343/led.c
3 *
4 */
5
6#include <linux/config.h>
7#include <linux/sched.h>
8#include <asm/mach/se7343.h>
9
10/* Cycle the LED's in the clasic Knightrider/Sun pattern */
11void heartbeat_7343se(void)
12{
13 static unsigned int cnt = 0, period = 0;
14 volatile unsigned short *p = (volatile unsigned short *) PA_LED;
15 static unsigned bit = 0, up = 1;
16
17 cnt += 1;
18 if (cnt < period) {
19 return;
20 }
21
22 cnt = 0;
23
24 /* Go through the points (roughly!):
25 * f(0)=10, f(1)=16, f(2)=20, f(5)=35,f(inf)->110
26 */
27 period = 110 - ((300 << FSHIFT) / ((avenrun[0] / 5) + (3 << FSHIFT)));
28
29 if (up) {
30 if (bit == 7) {
31 bit--;
32 up = 0;
33 } else {
34 bit++;
35 }
36 } else {
37 if (bit == 0) {
38 bit++;
39 up = 1;
40 } else {
41 bit--;
42 }
43 }
44 *p = 1 << (bit + LED_SHIFT);
45
46}
diff --git a/arch/sh/boards/se/7343/setup.c b/arch/sh/boards/se/7343/setup.c
new file mode 100644
index 000000000000..787322291fb3
--- /dev/null
+++ b/arch/sh/boards/se/7343/setup.c
@@ -0,0 +1,84 @@
1#include <linux/config.h>
2#include <linux/init.h>
3#include <linux/platform_device.h>
4#include <asm/machvec.h>
5#include <asm/mach/se7343.h>
6#include <asm/irq.h>
7
8void heartbeat_7343se(void);
9void init_7343se_IRQ(void);
10
11static struct resource smc91x_resources[] = {
12 [0] = {
13 .start = 0x10000000,
14 .end = 0x1000000F,
15 .flags = IORESOURCE_MEM,
16 },
17 [1] = {
18 /*
19 * shared with other devices via externel
20 * interrupt controller in FPGA...
21 */
22 .start = EXT_IRQ2,
23 .end = EXT_IRQ2,
24 .flags = IORESOURCE_IRQ,
25 },
26};
27
28static struct platform_device smc91x_device = {
29 .name = "smc91x",
30 .id = 0,
31 .num_resources = ARRAY_SIZE(smc91x_resources),
32 .resource = smc91x_resources,
33};
34
35static struct platform_device *smc91x_platform_devices[] __initdata = {
36 &smc91x_device,
37};
38
39static int __init sh7343se_devices_setup(void)
40{
41 return platform_add_devices(smc91x_platform_devices,
42 ARRAY_SIZE(smc91x_platform_devices));
43}
44
45static void __init sh7343se_setup(char **cmdline_p)
46{
47 device_initcall(sh7343se_devices_setup);
48}
49
50/*
51 * The Machine Vector
52 */
53struct sh_machine_vector mv_7343se __initmv = {
54 .mv_name = "SolutionEngine 7343",
55 .mv_setup = sh7343se_setup,
56 .mv_nr_irqs = 108,
57 .mv_inb = sh7343se_inb,
58 .mv_inw = sh7343se_inw,
59 .mv_inl = sh7343se_inl,
60 .mv_outb = sh7343se_outb,
61 .mv_outw = sh7343se_outw,
62 .mv_outl = sh7343se_outl,
63
64 .mv_inb_p = sh7343se_inb_p,
65 .mv_inw_p = sh7343se_inw,
66 .mv_inl_p = sh7343se_inl,
67 .mv_outb_p = sh7343se_outb_p,
68 .mv_outw_p = sh7343se_outw,
69 .mv_outl_p = sh7343se_outl,
70
71 .mv_insb = sh7343se_insb,
72 .mv_insw = sh7343se_insw,
73 .mv_insl = sh7343se_insl,
74 .mv_outsb = sh7343se_outsb,
75 .mv_outsw = sh7343se_outsw,
76 .mv_outsl = sh7343se_outsl,
77
78 .mv_init_irq = init_7343se_IRQ,
79 .mv_irq_demux = shmse_irq_demux,
80#ifdef CONFIG_HEARTBEAT
81 .mv_heartbeat = heartbeat_7343se,
82#endif
83};
84ALIAS_MV(7343se)
diff --git a/arch/sh/boards/se/770x/Makefile b/arch/sh/boards/se/770x/Makefile
index be89a73cc418..9a5035f80ec0 100644
--- a/arch/sh/boards/se/770x/Makefile
+++ b/arch/sh/boards/se/770x/Makefile
@@ -2,5 +2,5 @@
2# Makefile for the 770x SolutionEngine specific parts of the kernel 2# Makefile for the 770x SolutionEngine specific parts of the kernel
3# 3#
4 4
5obj-y := mach.o setup.o io.o irq.o led.o 5obj-y := setup.o io.o irq.o
6 6obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/770x/io.c b/arch/sh/boards/se/770x/io.c
index 9a39ee963143..9941949331ab 100644
--- a/arch/sh/boards/se/770x/io.c
+++ b/arch/sh/boards/se/770x/io.c
@@ -1,4 +1,4 @@
1/* $Id: io.c,v 1.5 2004/02/22 23:08:43 kkojima Exp $ 1/* $Id: io.c,v 1.7 2006/02/05 21:55:29 lethal Exp $
2 * 2 *
3 * linux/arch/sh/kernel/io_se.c 3 * linux/arch/sh/kernel/io_se.c
4 * 4 *
@@ -11,7 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/types.h> 12#include <linux/types.h>
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se/se.h> 14#include <asm/se.h>
15 15
16/* SH pcmcia io window base, start and end. */ 16/* SH pcmcia io window base, start and end. */
17int sh_pcic_io_wbase = 0xb8400000; 17int sh_pcic_io_wbase = 0xb8400000;
@@ -20,11 +20,6 @@ int sh_pcic_io_stop;
20int sh_pcic_io_type; 20int sh_pcic_io_type;
21int sh_pcic_io_dummy; 21int sh_pcic_io_dummy;
22 22
23static inline void delay(void)
24{
25 ctrl_inw(0xa0000000);
26}
27
28/* MS7750 requires special versions of in*, out* routines, since 23/* MS7750 requires special versions of in*, out* routines, since
29 PC-like io ports are located at upper half byte of 16-bit word which 24 PC-like io ports are located at upper half byte of 16-bit word which
30 can be accessed only with 16-bit wide. */ 25 can be accessed only with 16-bit wide. */
@@ -52,10 +47,6 @@ shifted_port(unsigned long port)
52 return 1; 47 return 1;
53} 48}
54 49
55#define maybebadio(name,port) \
56 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
57 #name, (port), (__u32) __builtin_return_address(0))
58
59unsigned char se_inb(unsigned long port) 50unsigned char se_inb(unsigned long port)
60{ 51{
61 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop) 52 if (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)
@@ -76,7 +67,7 @@ unsigned char se_inb_p(unsigned long port)
76 v = (*port2adr(port) >> 8); 67 v = (*port2adr(port) >> 8);
77 else 68 else
78 v = (*port2adr(port))&0xff; 69 v = (*port2adr(port))&0xff;
79 delay(); 70 ctrl_delay();
80 return v; 71 return v;
81} 72}
82 73
@@ -86,13 +77,13 @@ unsigned short se_inw(unsigned long port)
86 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)) 77 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
87 return *port2adr(port); 78 return *port2adr(port);
88 else 79 else
89 maybebadio(inw, port); 80 maybebadio(port);
90 return 0; 81 return 0;
91} 82}
92 83
93unsigned int se_inl(unsigned long port) 84unsigned int se_inl(unsigned long port)
94{ 85{
95 maybebadio(inl, port); 86 maybebadio(port);
96 return 0; 87 return 0;
97} 88}
98 89
@@ -114,7 +105,7 @@ void se_outb_p(unsigned char value, unsigned long port)
114 *(port2adr(port)) = value << 8; 105 *(port2adr(port)) = value << 8;
115 else 106 else
116 *(port2adr(port)) = value; 107 *(port2adr(port)) = value;
117 delay(); 108 ctrl_delay();
118} 109}
119 110
120void se_outw(unsigned short value, unsigned long port) 111void se_outw(unsigned short value, unsigned long port)
@@ -123,12 +114,12 @@ void se_outw(unsigned short value, unsigned long port)
123 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop)) 114 (sh_pcic_io_start <= port && port <= sh_pcic_io_stop))
124 *port2adr(port) = value; 115 *port2adr(port) = value;
125 else 116 else
126 maybebadio(outw, port); 117 maybebadio(port);
127} 118}
128 119
129void se_outl(unsigned int value, unsigned long port) 120void se_outl(unsigned int value, unsigned long port)
130{ 121{
131 maybebadio(outl, port); 122 maybebadio(port);
132} 123}
133 124
134void se_insb(unsigned long port, void *addr, unsigned long count) 125void se_insb(unsigned long port, void *addr, unsigned long count)
@@ -159,7 +150,7 @@ void se_insw(unsigned long port, void *addr, unsigned long count)
159 150
160void se_insl(unsigned long port, void *addr, unsigned long count) 151void se_insl(unsigned long port, void *addr, unsigned long count)
161{ 152{
162 maybebadio(insl, port); 153 maybebadio(port);
163} 154}
164 155
165void se_outsb(unsigned long port, const void *addr, unsigned long count) 156void se_outsb(unsigned long port, const void *addr, unsigned long count)
@@ -190,37 +181,5 @@ void se_outsw(unsigned long port, const void *addr, unsigned long count)
190 181
191void se_outsl(unsigned long port, const void *addr, unsigned long count) 182void se_outsl(unsigned long port, const void *addr, unsigned long count)
192{ 183{
193 maybebadio(outsw, port); 184 maybebadio(port);
194}
195
196/* Map ISA bus address to the real address. Only for PCMCIA. */
197
198/* ISA page descriptor. */
199static __u32 sh_isa_memmap[256];
200
201static int
202sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
203{
204 int idx;
205
206 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
207 return -1;
208
209 idx = start >> 12;
210 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
211#if 0
212 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
213 start, length, offset, idx, sh_isa_memmap[idx]);
214#endif
215 return 0;
216}
217
218unsigned long
219se_isa_port2addr(unsigned long offset)
220{
221 int idx;
222
223 idx = (offset >> 12) & 0xff;
224 offset &= 0xfff;
225 return sh_isa_memmap[idx] + offset;
226} 185}
diff --git a/arch/sh/boards/se/770x/irq.c b/arch/sh/boards/se/770x/irq.c
index 3e558716ce10..cff6700bbafd 100644
--- a/arch/sh/boards/se/770x/irq.c
+++ b/arch/sh/boards/se/770x/irq.c
@@ -11,7 +11,7 @@
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <asm/irq.h> 12#include <asm/irq.h>
13#include <asm/io.h> 13#include <asm/io.h>
14#include <asm/se/se.h> 14#include <asm/se.h>
15 15
16/* 16/*
17 * Initialize IRQ setting 17 * Initialize IRQ setting
diff --git a/arch/sh/boards/se/770x/led.c b/arch/sh/boards/se/770x/led.c
index 3cddbda025fc..daf7b1ee786a 100644
--- a/arch/sh/boards/se/770x/led.c
+++ b/arch/sh/boards/se/770x/led.c
@@ -9,22 +9,8 @@
9 * This file contains Solution Engine specific LED code. 9 * This file contains Solution Engine specific LED code.
10 */ 10 */
11 11
12#include <asm/se/se.h>
13
14static void mach_led(int position, int value)
15{
16 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
17
18 if (value) {
19 *p |= (1<<8);
20 } else {
21 *p &= ~(1<<8);
22 }
23}
24
25#ifdef CONFIG_HEARTBEAT
26
27#include <linux/sched.h> 12#include <linux/sched.h>
13#include <asm/se.h>
28 14
29/* Cycle the LED's in the clasic Knightrider/Sun pattern */ 15/* Cycle the LED's in the clasic Knightrider/Sun pattern */
30void heartbeat_se(void) 16void heartbeat_se(void)
@@ -64,4 +50,3 @@ void heartbeat_se(void)
64 *p = 1<<(bit+8); 50 *p = 1<<(bit+8);
65 51
66} 52}
67#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/se/770x/mach.c b/arch/sh/boards/se/770x/mach.c
deleted file mode 100644
index 6ec07bd3dcf1..000000000000
--- a/arch/sh/boards/se/770x/mach.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/*
2 * linux/arch/sh/kernel/mach_se.c
3 *
4 * Copyright (C) 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the Hitachi SolutionEngine
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/machvec_init.h>
17
18#include <asm/se/io.h>
19
20void heartbeat_se(void);
21void setup_se(void);
22void init_se_IRQ(void);
23
24/*
25 * The Machine Vector
26 */
27
28struct sh_machine_vector mv_se __initmv = {
29#if defined(CONFIG_CPU_SH4)
30 .mv_nr_irqs = 48,
31#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
32 .mv_nr_irqs = 32,
33#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
34 .mv_nr_irqs = 61,
35#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
36 .mv_nr_irqs = 86,
37#endif
38
39 .mv_inb = se_inb,
40 .mv_inw = se_inw,
41 .mv_inl = se_inl,
42 .mv_outb = se_outb,
43 .mv_outw = se_outw,
44 .mv_outl = se_outl,
45
46 .mv_inb_p = se_inb_p,
47 .mv_inw_p = se_inw,
48 .mv_inl_p = se_inl,
49 .mv_outb_p = se_outb_p,
50 .mv_outw_p = se_outw,
51 .mv_outl_p = se_outl,
52
53 .mv_insb = se_insb,
54 .mv_insw = se_insw,
55 .mv_insl = se_insl,
56 .mv_outsb = se_outsb,
57 .mv_outsw = se_outsw,
58 .mv_outsl = se_outsl,
59
60 .mv_isa_port2addr = se_isa_port2addr,
61
62 .mv_init_irq = init_se_IRQ,
63#ifdef CONFIG_HEARTBEAT
64 .mv_heartbeat = heartbeat_se,
65#endif
66};
67ALIAS_MV(se)
diff --git a/arch/sh/boards/se/770x/setup.c b/arch/sh/boards/se/770x/setup.c
index 7d1a071727cc..f3f82b7c8217 100644
--- a/arch/sh/boards/se/770x/setup.c
+++ b/arch/sh/boards/se/770x/setup.c
@@ -7,15 +7,17 @@
7 * Hitachi SolutionEngine Support. 7 * Hitachi SolutionEngine Support.
8 * 8 *
9 */ 9 */
10
11#include <linux/init.h> 10#include <linux/init.h>
12#include <linux/irq.h> 11#include <linux/irq.h>
13
14#include <linux/hdreg.h> 12#include <linux/hdreg.h>
15#include <linux/ide.h> 13#include <linux/ide.h>
16#include <asm/io.h> 14#include <asm/io.h>
17#include <asm/se/se.h> 15#include <asm/se.h>
18#include <asm/se/smc37c93x.h> 16#include <asm/smc37c93x.h>
17#include <asm/machvec.h>
18
19void heartbeat_se(void);
20void init_se_IRQ(void);
19 21
20/* 22/*
21 * Configure the Super I/O chip 23 * Configure the Super I/O chip
@@ -26,7 +28,8 @@ static void __init smsc_config(int index, int data)
26 outb_p(data, DATA_PORT); 28 outb_p(data, DATA_PORT);
27} 29}
28 30
29static void __init init_smsc(void) 31/* XXX: Another candidate for a more generic cchip machine vector */
32static void __init smsc_setup(char **cmdline_p)
30{ 33{
31 outb_p(CONFIG_ENTER, CONFIG_PORT); 34 outb_p(CONFIG_ENTER, CONFIG_PORT);
32 outb_p(CONFIG_ENTER, CONFIG_PORT); 35 outb_p(CONFIG_ENTER, CONFIG_PORT);
@@ -69,16 +72,46 @@ static void __init init_smsc(void)
69 outb_p(CONFIG_EXIT, CONFIG_PORT); 72 outb_p(CONFIG_EXIT, CONFIG_PORT);
70} 73}
71 74
72const char *get_system_type(void)
73{
74 return "SolutionEngine";
75}
76
77/* 75/*
78 * Initialize the board 76 * The Machine Vector
79 */ 77 */
80void __init platform_setup(void) 78struct sh_machine_vector mv_se __initmv = {
81{ 79 .mv_name = "SolutionEngine",
82 init_smsc(); 80 .mv_setup = smsc_setup,
83 /* XXX: RTC setting comes here */ 81#if defined(CONFIG_CPU_SH4)
84} 82 .mv_nr_irqs = 48,
83#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
84 .mv_nr_irqs = 32,
85#elif defined(CONFIG_CPU_SUBTYPE_SH7709)
86 .mv_nr_irqs = 61,
87#elif defined(CONFIG_CPU_SUBTYPE_SH7705)
88 .mv_nr_irqs = 86,
89#endif
90
91 .mv_inb = se_inb,
92 .mv_inw = se_inw,
93 .mv_inl = se_inl,
94 .mv_outb = se_outb,
95 .mv_outw = se_outw,
96 .mv_outl = se_outl,
97
98 .mv_inb_p = se_inb_p,
99 .mv_inw_p = se_inw,
100 .mv_inl_p = se_inl,
101 .mv_outb_p = se_outb_p,
102 .mv_outw_p = se_outw,
103 .mv_outl_p = se_outl,
104
105 .mv_insb = se_insb,
106 .mv_insw = se_insw,
107 .mv_insl = se_insl,
108 .mv_outsb = se_outsb,
109 .mv_outsw = se_outsw,
110 .mv_outsl = se_outsl,
111
112 .mv_init_irq = init_se_IRQ,
113#ifdef CONFIG_HEARTBEAT
114 .mv_heartbeat = heartbeat_se,
115#endif
116};
117ALIAS_MV(se)
diff --git a/arch/sh/boards/se/7751/Makefile b/arch/sh/boards/se/7751/Makefile
index ce7ca247f84d..188900c48321 100644
--- a/arch/sh/boards/se/7751/Makefile
+++ b/arch/sh/boards/se/7751/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the 7751 SolutionEngine specific parts of the kernel 2# Makefile for the 7751 SolutionEngine specific parts of the kernel
3# 3#
4 4
5obj-y := mach.o setup.o io.o irq.o led.o 5obj-y := setup.o io.o irq.o
6 6
7obj-$(CONFIG_PCI) += pci.o 7obj-$(CONFIG_PCI) += pci.o
8 8obj-$(CONFIG_HEARTBEAT) += led.o
diff --git a/arch/sh/boards/se/7751/io.c b/arch/sh/boards/se/7751/io.c
index 99041b269261..e8d846cec89d 100644
--- a/arch/sh/boards/se/7751/io.c
+++ b/arch/sh/boards/se/7751/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_7751se.c
3 *
4 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 2 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
5 * Based largely on io_se.c. 3 * Based largely on io_se.c.
6 * 4 *
@@ -10,96 +8,21 @@
10 * placeholder code from io_se.c left in with the 8 * placeholder code from io_se.c left in with the
11 * expectation of later SuperIO and PCMCIA access. 9 * expectation of later SuperIO and PCMCIA access.
12 */ 10 */
13
14#include <linux/kernel.h> 11#include <linux/kernel.h>
15#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/pci.h>
16#include <asm/io.h> 14#include <asm/io.h>
17#include <asm/se7751/se7751.h> 15#include <asm/se7751.h>
18#include <asm/addrspace.h> 16#include <asm/addrspace.h>
19 17
20#include <linux/pci.h> 18static inline volatile u16 *port2adr(unsigned int port)
21#include "../../../drivers/pci/pci-sh7751.h"
22
23#if 0
24/******************************************************************
25 * Variables from io_se.c, related to PCMCIA (not PCI); we're not
26 * compiling them in, and have removed references from functions
27 * which follow. [Many checked for IO ports in the range bounded
28 * by sh_pcic_io_start/stop, and used sh_pcic_io_wbase as offset.
29 * As start/stop are uninitialized, only port 0x0 would match?]
30 * When used, remember to adjust names to avoid clash with io_se?
31 *****************************************************************/
32/* SH pcmcia io window base, start and end. */
33int sh_pcic_io_wbase = 0xb8400000;
34int sh_pcic_io_start;
35int sh_pcic_io_stop;
36int sh_pcic_io_type;
37int sh_pcic_io_dummy;
38/*************************************************************/
39#endif
40
41/*
42 * The 7751 Solution Engine uses the built-in PCI controller (PCIC)
43 * of the 7751 processor, and has a SuperIO accessible via the PCI.
44 * The board also includes a PCMCIA controller on its memory bus,
45 * like the other Solution Engine boards.
46 */
47
48#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
49#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
50#define PCI_IO_AREA SH7751_PCI_IO_BASE
51#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
52
53#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
54
55#define maybebadio(name,port) \
56 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
57 #name, (port), (__u32) __builtin_return_address(0))
58
59static inline void delay(void)
60{
61 ctrl_inw(0xa0000000);
62}
63
64static inline volatile __u16 *
65port2adr(unsigned int port)
66{ 19{
67 if (port >= 0x2000) 20 if (port >= 0x2000)
68 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000)); 21 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
69#if 0 22 maybebadio((unsigned long)port);
70 else
71 return (volatile __u16 *) (PA_SUPERIO + (port << 1));
72#endif
73 maybebadio(name,(unsigned long)port);
74 return (volatile __u16*)port; 23 return (volatile __u16*)port;
75} 24}
76 25
77#if 0
78/* The 7751 Solution Engine seems to have everything hooked */
79/* up pretty normally (nothing on high-bytes only...) so this */
80/* shouldn't be needed */
81static inline int
82shifted_port(unsigned long port)
83{
84 /* For IDE registers, value is not shifted */
85 if ((0x1f0 <= port && port < 0x1f8) || port == 0x3f6)
86 return 0;
87 else
88 return 1;
89}
90#endif
91
92/* In case someone configures the kernel w/o PCI support: in that */
93/* scenario, don't ever bother to check for PCI-window addresses */
94
95/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
96#if defined(CONFIG_PCI)
97#define CHECK_SH7751_PCIIO(port) \
98 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
99#else
100#define CHECK_SH7751_PCIIO(port) (0)
101#endif
102
103/* 26/*
104 * General outline: remap really low stuff [eventually] to SuperIO, 27 * General outline: remap really low stuff [eventually] to SuperIO,
105 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 28 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -111,10 +34,10 @@ unsigned char sh7751se_inb(unsigned long port)
111{ 34{
112 if (PXSEG(port)) 35 if (PXSEG(port))
113 return *(volatile unsigned char *)port; 36 return *(volatile unsigned char *)port;
114 else if (CHECK_SH7751_PCIIO(port)) 37 else if (is_pci_ioaddr(port))
115 return *(volatile unsigned char *)PCI_IOMAP(port); 38 return *(volatile unsigned char *)pci_ioaddr(port);
116 else 39 else
117 return (*port2adr(port))&0xff; 40 return (*port2adr(port)) & 0xff;
118} 41}
119 42
120unsigned char sh7751se_inb_p(unsigned long port) 43unsigned char sh7751se_inb_p(unsigned long port)
@@ -123,11 +46,11 @@ unsigned char sh7751se_inb_p(unsigned long port)
123 46
124 if (PXSEG(port)) 47 if (PXSEG(port))
125 v = *(volatile unsigned char *)port; 48 v = *(volatile unsigned char *)port;
126 else if (CHECK_SH7751_PCIIO(port)) 49 else if (is_pci_ioaddr(port))
127 v = *(volatile unsigned char *)PCI_IOMAP(port); 50 v = *(volatile unsigned char *)pci_ioaddr(port);
128 else 51 else
129 v = (*port2adr(port))&0xff; 52 v = (*port2adr(port)) & 0xff;
130 delay(); 53 ctrl_delay();
131 return v; 54 return v;
132} 55}
133 56
@@ -135,12 +58,12 @@ unsigned short sh7751se_inw(unsigned long port)
135{ 58{
136 if (PXSEG(port)) 59 if (PXSEG(port))
137 return *(volatile unsigned short *)port; 60 return *(volatile unsigned short *)port;
138 else if (CHECK_SH7751_PCIIO(port)) 61 else if (is_pci_ioaddr(port))
139 return *(volatile unsigned short *)PCI_IOMAP(port); 62 return *(volatile unsigned short *)pci_ioaddr(port);
140 else if (port >= 0x2000) 63 else if (port >= 0x2000)
141 return *port2adr(port); 64 return *port2adr(port);
142 else 65 else
143 maybebadio(inw, port); 66 maybebadio(port);
144 return 0; 67 return 0;
145} 68}
146 69
@@ -148,12 +71,12 @@ unsigned int sh7751se_inl(unsigned long port)
148{ 71{
149 if (PXSEG(port)) 72 if (PXSEG(port))
150 return *(volatile unsigned long *)port; 73 return *(volatile unsigned long *)port;
151 else if (CHECK_SH7751_PCIIO(port)) 74 else if (is_pci_ioaddr(port))
152 return *(volatile unsigned int *)PCI_IOMAP(port); 75 return *(volatile unsigned int *)pci_ioaddr(port);
153 else if (port >= 0x2000) 76 else if (port >= 0x2000)
154 return *port2adr(port); 77 return *port2adr(port);
155 else 78 else
156 maybebadio(inl, port); 79 maybebadio(port);
157 return 0; 80 return 0;
158} 81}
159 82
@@ -162,8 +85,8 @@ void sh7751se_outb(unsigned char value, unsigned long port)
162 85
163 if (PXSEG(port)) 86 if (PXSEG(port))
164 *(volatile unsigned char *)port = value; 87 *(volatile unsigned char *)port = value;
165 else if (CHECK_SH7751_PCIIO(port)) 88 else if (is_pci_ioaddr(port))
166 *((unsigned char*)PCI_IOMAP(port)) = value; 89 *((unsigned char*)pci_ioaddr(port)) = value;
167 else 90 else
168 *(port2adr(port)) = value; 91 *(port2adr(port)) = value;
169} 92}
@@ -172,73 +95,41 @@ void sh7751se_outb_p(unsigned char value, unsigned long port)
172{ 95{
173 if (PXSEG(port)) 96 if (PXSEG(port))
174 *(volatile unsigned char *)port = value; 97 *(volatile unsigned char *)port = value;
175 else if (CHECK_SH7751_PCIIO(port)) 98 else if (is_pci_ioaddr(port))
176 *((unsigned char*)PCI_IOMAP(port)) = value; 99 *((unsigned char*)pci_ioaddr(port)) = value;
177 else 100 else
178 *(port2adr(port)) = value; 101 *(port2adr(port)) = value;
179 delay(); 102 ctrl_delay();
180} 103}
181 104
182void sh7751se_outw(unsigned short value, unsigned long port) 105void sh7751se_outw(unsigned short value, unsigned long port)
183{ 106{
184 if (PXSEG(port)) 107 if (PXSEG(port))
185 *(volatile unsigned short *)port = value; 108 *(volatile unsigned short *)port = value;
186 else if (CHECK_SH7751_PCIIO(port)) 109 else if (is_pci_ioaddr(port))
187 *((unsigned short *)PCI_IOMAP(port)) = value; 110 *((unsigned short *)pci_ioaddr(port)) = value;
188 else if (port >= 0x2000) 111 else if (port >= 0x2000)
189 *port2adr(port) = value; 112 *port2adr(port) = value;
190 else 113 else
191 maybebadio(outw, port); 114 maybebadio(port);
192} 115}
193 116
194void sh7751se_outl(unsigned int value, unsigned long port) 117void sh7751se_outl(unsigned int value, unsigned long port)
195{ 118{
196 if (PXSEG(port)) 119 if (PXSEG(port))
197 *(volatile unsigned long *)port = value; 120 *(volatile unsigned long *)port = value;
198 else if (CHECK_SH7751_PCIIO(port)) 121 else if (is_pci_ioaddr(port))
199 *((unsigned long*)PCI_IOMAP(port)) = value; 122 *((unsigned long*)pci_ioaddr(port)) = value;
200 else 123 else
201 maybebadio(outl, port); 124 maybebadio(port);
202} 125}
203 126
204void sh7751se_insl(unsigned long port, void *addr, unsigned long count) 127void sh7751se_insl(unsigned long port, void *addr, unsigned long count)
205{ 128{
206 maybebadio(insl, port); 129 maybebadio(port);
207} 130}
208 131
209void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count) 132void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count)
210{ 133{
211 maybebadio(outsw, port); 134 maybebadio(port);
212}
213
214/* Map ISA bus address to the real address. Only for PCMCIA. */
215
216/* ISA page descriptor. */
217static __u32 sh_isa_memmap[256];
218
219#if 0
220static int
221sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
222{
223 int idx;
224
225 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
226 return -1;
227
228 idx = start >> 12;
229 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
230 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
231 start, length, offset, idx, sh_isa_memmap[idx]);
232 return 0;
233}
234#endif
235
236unsigned long
237sh7751se_isa_port2addr(unsigned long offset)
238{
239 int idx;
240
241 idx = (offset >> 12) & 0xff;
242 offset &= 0xfff;
243 return sh_isa_memmap[idx] + offset;
244} 135}
diff --git a/arch/sh/boards/se/7751/irq.c b/arch/sh/boards/se/7751/irq.c
index bf6c023615df..c607b0a48479 100644
--- a/arch/sh/boards/se/7751/irq.c
+++ b/arch/sh/boards/se/7751/irq.c
@@ -12,7 +12,7 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14#include <asm/irq.h> 14#include <asm/irq.h>
15#include <asm/se7751/se7751.h> 15#include <asm/se7751.h>
16 16
17/* 17/*
18 * Initialize IRQ setting 18 * Initialize IRQ setting
diff --git a/arch/sh/boards/se/7751/led.c b/arch/sh/boards/se/7751/led.c
index a878726d3c7c..ff0355dea81b 100644
--- a/arch/sh/boards/se/7751/led.c
+++ b/arch/sh/boards/se/7751/led.c
@@ -8,23 +8,8 @@
8 * 8 *
9 * This file contains Solution Engine specific LED code. 9 * This file contains Solution Engine specific LED code.
10 */ 10 */
11
12#include <asm/se7751/se7751.h>
13
14static void mach_led(int position, int value)
15{
16 volatile unsigned short* p = (volatile unsigned short*)PA_LED;
17
18 if (value) {
19 *p |= (1<<8);
20 } else {
21 *p &= ~(1<<8);
22 }
23}
24
25#ifdef CONFIG_HEARTBEAT
26
27#include <linux/sched.h> 11#include <linux/sched.h>
12#include <asm/se7751.h>
28 13
29/* Cycle the LED's in the clasic Knightrider/Sun pattern */ 14/* Cycle the LED's in the clasic Knightrider/Sun pattern */
30void heartbeat_7751se(void) 15void heartbeat_7751se(void)
@@ -64,4 +49,3 @@ void heartbeat_7751se(void)
64 *p = 1<<(bit+8); 49 *p = 1<<(bit+8);
65 50
66} 51}
67#endif /* CONFIG_HEARTBEAT */
diff --git a/arch/sh/boards/se/7751/mach.c b/arch/sh/boards/se/7751/mach.c
deleted file mode 100644
index 62d8d3e62590..000000000000
--- a/arch/sh/boards/se/7751/mach.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/*
2 * linux/arch/sh/kernel/mach_7751se.c
3 *
4 * Minor tweak of mach_se.c file to reference 7751se-specific items.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * Machine vector for the Hitachi 7751 SolutionEngine
10 */
11
12#include <linux/init.h>
13
14#include <asm/machvec.h>
15#include <asm/rtc.h>
16#include <asm/machvec_init.h>
17
18#include <asm/se7751/io.h>
19
20void heartbeat_7751se(void);
21void init_7751se_IRQ(void);
22
23/*
24 * The Machine Vector
25 */
26
27struct sh_machine_vector mv_7751se __initmv = {
28 .mv_nr_irqs = 72,
29
30 .mv_inb = sh7751se_inb,
31 .mv_inw = sh7751se_inw,
32 .mv_inl = sh7751se_inl,
33 .mv_outb = sh7751se_outb,
34 .mv_outw = sh7751se_outw,
35 .mv_outl = sh7751se_outl,
36
37 .mv_inb_p = sh7751se_inb_p,
38 .mv_inw_p = sh7751se_inw,
39 .mv_inl_p = sh7751se_inl,
40 .mv_outb_p = sh7751se_outb_p,
41 .mv_outw_p = sh7751se_outw,
42 .mv_outl_p = sh7751se_outl,
43
44 .mv_insl = sh7751se_insl,
45 .mv_outsl = sh7751se_outsl,
46
47 .mv_isa_port2addr = sh7751se_isa_port2addr,
48
49 .mv_init_irq = init_7751se_IRQ,
50#ifdef CONFIG_HEARTBEAT
51 .mv_heartbeat = heartbeat_7751se,
52#endif
53};
54ALIAS_MV(7751se)
diff --git a/arch/sh/boards/se/7751/setup.c b/arch/sh/boards/se/7751/setup.c
index 48dc5aee67d4..73e826310ba8 100644
--- a/arch/sh/boards/se/7751/setup.c
+++ b/arch/sh/boards/se/7751/setup.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/setup_7751se.c 2 * linux/arch/sh/kernel/setup_7751se.c
3 * 3 *
4 * Copyright (C) 2000 Kazumoto Kojima 4 * Copyright (C) 2000 Kazumoto Kojima
@@ -11,78 +11,15 @@
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14
15#include <linux/hdreg.h>
16#include <linux/ide.h> 14#include <linux/ide.h>
17#include <asm/io.h> 15#include <asm/io.h>
18#include <asm/se7751/se7751.h> 16#include <asm/se7751.h>
19 17
20#ifdef CONFIG_SH_KGDB 18void heartbeat_7751se(void);
21#include <asm/kgdb.h> 19void init_7751se_IRQ(void);
22#endif
23
24/*
25 * Configure the Super I/O chip
26 */
27#if 0
28/* Leftover code from regular Solution Engine, for reference. */
29/* The SH7751 Solution Engine has a different SuperIO. */
30static void __init smsc_config(int index, int data)
31{
32 outb_p(index, INDEX_PORT);
33 outb_p(data, DATA_PORT);
34}
35
36static void __init init_smsc(void)
37{
38 outb_p(CONFIG_ENTER, CONFIG_PORT);
39 outb_p(CONFIG_ENTER, CONFIG_PORT);
40
41 /* FDC */
42 smsc_config(CURRENT_LDN_INDEX, LDN_FDC);
43 smsc_config(ACTIVATE_INDEX, 0x01);
44 smsc_config(IRQ_SELECT_INDEX, 6); /* IRQ6 */
45
46 /* IDE1 */
47 smsc_config(CURRENT_LDN_INDEX, LDN_IDE1);
48 smsc_config(ACTIVATE_INDEX, 0x01);
49 smsc_config(IRQ_SELECT_INDEX, 14); /* IRQ14 */
50
51 /* AUXIO (GPIO): to use IDE1 */
52 smsc_config(CURRENT_LDN_INDEX, LDN_AUXIO);
53 smsc_config(GPIO46_INDEX, 0x00); /* nIOROP */
54 smsc_config(GPIO47_INDEX, 0x00); /* nIOWOP */
55
56 /* COM1 */
57 smsc_config(CURRENT_LDN_INDEX, LDN_COM1);
58 smsc_config(ACTIVATE_INDEX, 0x01);
59 smsc_config(IO_BASE_HI_INDEX, 0x03);
60 smsc_config(IO_BASE_LO_INDEX, 0xf8);
61 smsc_config(IRQ_SELECT_INDEX, 4); /* IRQ4 */
62
63 /* COM2 */
64 smsc_config(CURRENT_LDN_INDEX, LDN_COM2);
65 smsc_config(ACTIVATE_INDEX, 0x01);
66 smsc_config(IO_BASE_HI_INDEX, 0x02);
67 smsc_config(IO_BASE_LO_INDEX, 0xf8);
68 smsc_config(IRQ_SELECT_INDEX, 3); /* IRQ3 */
69
70 /* RTC */
71 smsc_config(CURRENT_LDN_INDEX, LDN_RTC);
72 smsc_config(ACTIVATE_INDEX, 0x01);
73 smsc_config(IRQ_SELECT_INDEX, 8); /* IRQ8 */
74
75 /* XXX: PARPORT, KBD, and MOUSE will come here... */
76 outb_p(CONFIG_EXIT, CONFIG_PORT);
77}
78#endif
79
80const char *get_system_type(void)
81{
82 return "7751 SolutionEngine";
83}
84 20
85#ifdef CONFIG_SH_KGDB 21#ifdef CONFIG_SH_KGDB
22#include <asm/kgdb.h>
86static int kgdb_uart_setup(void); 23static int kgdb_uart_setup(void);
87static struct kgdb_sermap kgdb_uart_sermap = 24static struct kgdb_sermap kgdb_uart_sermap =
88{ "ttyS", 0, kgdb_uart_setup, NULL }; 25{ "ttyS", 0, kgdb_uart_setup, NULL };
@@ -91,7 +28,7 @@ static struct kgdb_sermap kgdb_uart_sermap =
91/* 28/*
92 * Initialize the board 29 * Initialize the board
93 */ 30 */
94void __init platform_setup(void) 31static void __init sh7751se_setup(char **cmdline_p)
95{ 32{
96 /* Call init_smsc() replacement to set up SuperIO. */ 33 /* Call init_smsc() replacement to set up SuperIO. */
97 /* XXX: RTC setting comes here */ 34 /* XXX: RTC setting comes here */
@@ -225,3 +162,37 @@ static int kgdb_uart_setup(void)
225 return 0; 162 return 0;
226} 163}
227#endif /* CONFIG_SH_KGDB */ 164#endif /* CONFIG_SH_KGDB */
165
166
167/*
168 * The Machine Vector
169 */
170
171struct sh_machine_vector mv_7751se __initmv = {
172 .mv_name = "7751 SolutionEngine",
173 .mv_setup = sh7751se_setup,
174 .mv_nr_irqs = 72,
175
176 .mv_inb = sh7751se_inb,
177 .mv_inw = sh7751se_inw,
178 .mv_inl = sh7751se_inl,
179 .mv_outb = sh7751se_outb,
180 .mv_outw = sh7751se_outw,
181 .mv_outl = sh7751se_outl,
182
183 .mv_inb_p = sh7751se_inb_p,
184 .mv_inw_p = sh7751se_inw,
185 .mv_inl_p = sh7751se_inl,
186 .mv_outb_p = sh7751se_outb_p,
187 .mv_outw_p = sh7751se_outw,
188 .mv_outl_p = sh7751se_outl,
189
190 .mv_insl = sh7751se_insl,
191 .mv_outsl = sh7751se_outsl,
192
193 .mv_init_irq = init_7751se_IRQ,
194#ifdef CONFIG_HEARTBEAT
195 .mv_heartbeat = heartbeat_7751se,
196#endif
197};
198ALIAS_MV(7751se)
diff --git a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c
index d609863cfe53..0a9266bb51c5 100644
--- a/arch/sh/boards/sh03/rtc.c
+++ b/arch/sh/boards/sh03/rtc.c
@@ -10,9 +10,10 @@
10#include <linux/sched.h> 10#include <linux/sched.h>
11#include <linux/time.h> 11#include <linux/time.h>
12#include <linux/bcd.h> 12#include <linux/bcd.h>
13#include <asm/io.h>
14#include <linux/rtc.h> 13#include <linux/rtc.h>
15#include <linux/spinlock.h> 14#include <linux/spinlock.h>
15#include <asm/io.h>
16#include <asm/rtc.h>
16 17
17#define RTC_BASE 0xb0000000 18#define RTC_BASE 0xb0000000
18#define RTC_SEC1 (RTC_BASE + 0) 19#define RTC_SEC1 (RTC_BASE + 0)
@@ -34,8 +35,6 @@
34#define RTC_BUSY 1 35#define RTC_BUSY 1
35#define RTC_STOP 2 36#define RTC_STOP 2
36 37
37extern void (*rtc_get_time)(struct timespec *);
38extern int (*rtc_set_time)(const time_t);
39extern spinlock_t rtc_lock; 38extern spinlock_t rtc_lock;
40 39
41unsigned long get_cmos_time(void) 40unsigned long get_cmos_time(void)
@@ -128,6 +127,6 @@ int sh03_rtc_settimeofday(const time_t secs)
128 127
129void sh03_time_init(void) 128void sh03_time_init(void)
130{ 129{
131 rtc_get_time = sh03_rtc_gettimeofday; 130 rtc_sh_get_time = sh03_rtc_gettimeofday;
132 rtc_set_time = sh03_rtc_settimeofday; 131 rtc_sh_set_time = sh03_rtc_settimeofday;
133} 132}
diff --git a/arch/sh/boards/sh03/setup.c b/arch/sh/boards/sh03/setup.c
index 60290f8f289c..6c310587ddfe 100644
--- a/arch/sh/boards/sh03/setup.c
+++ b/arch/sh/boards/sh03/setup.c
@@ -7,22 +7,13 @@
7 7
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/irq.h> 9#include <linux/irq.h>
10#include <linux/hdreg.h>
11#include <linux/ide.h>
12#include <asm/io.h> 10#include <asm/io.h>
11#include <asm/rtc.h>
13#include <asm/sh03/io.h> 12#include <asm/sh03/io.h>
14#include <asm/sh03/sh03.h> 13#include <asm/sh03/sh03.h>
15#include <asm/addrspace.h> 14#include <asm/addrspace.h>
16#include "../../drivers/pci/pci-sh7751.h"
17 15
18extern void (*board_time_init)(void); 16static void __init init_sh03_IRQ(void)
19
20const char *get_system_type(void)
21{
22 return "Interface CTP/PCI-SH03)";
23}
24
25void init_sh03_IRQ(void)
26{ 17{
27 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR); 18 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
28 19
@@ -34,38 +25,34 @@ void init_sh03_IRQ(void)
34 25
35extern void *cf_io_base; 26extern void *cf_io_base;
36 27
37unsigned long sh03_isa_port2addr(unsigned long port) 28static void __iomem *sh03_ioport_map(unsigned long port, unsigned int size)
38{ 29{
39 if (PXSEG(port)) 30 if (PXSEG(port))
40 return port; 31 return (void __iomem *)port;
41 /* CompactFlash (IDE) */ 32 /* CompactFlash (IDE) */
42 if (((port >= 0x1f0) && (port <= 0x1f7)) || (port == 0x3f6)) { 33 if (((port >= 0x1f0) && (port <= 0x1f7)) || (port == 0x3f6))
43 return (unsigned long)cf_io_base + port; 34 return (void __iomem *)((unsigned long)cf_io_base + port);
44 } 35
45 return port + SH7751_PCI_IO_BASE; 36 return (void __iomem *)(port + PCI_IO_BASE);
46} 37}
47 38
48/* 39/* arch/sh/boards/sh03/rtc.c */
49 * The Machine Vector 40void sh03_time_init(void);
50 */ 41
42static void __init sh03_setup(char **cmdline_p)
43{
44 board_time_init = sh03_time_init;
45}
51 46
52struct sh_machine_vector mv_sh03 __initmv = { 47struct sh_machine_vector mv_sh03 __initmv = {
48 .mv_name = "Interface (CTP/PCI-SH03)",
49 .mv_setup = sh03_setup,
53 .mv_nr_irqs = 48, 50 .mv_nr_irqs = 48,
54 .mv_isa_port2addr = sh03_isa_port2addr, 51 .mv_ioport_map = sh03_ioport_map,
55 .mv_init_irq = init_sh03_IRQ, 52 .mv_init_irq = init_sh03_IRQ,
56 53
57#ifdef CONFIG_HEARTBEAT 54#ifdef CONFIG_HEARTBEAT
58 .mv_heartbeat = heartbeat_sh03, 55 .mv_heartbeat = heartbeat_sh03,
59#endif 56#endif
60}; 57};
61
62ALIAS_MV(sh03) 58ALIAS_MV(sh03)
63
64/* arch/sh/boards/sh03/rtc.c */
65void sh03_time_init(void);
66
67int __init platform_setup(void)
68{
69 board_time_init = sh03_time_init;
70 return 0;
71}
diff --git a/arch/sh/boards/sh2000/Makefile b/arch/sh/boards/sh2000/Makefile
deleted file mode 100644
index 05d390c3599c..000000000000
--- a/arch/sh/boards/sh2000/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
1#
2# Makefile for the SH2000 specific parts of the kernel
3#
4
5obj-y := setup.o
6
diff --git a/arch/sh/boards/sh2000/setup.c b/arch/sh/boards/sh2000/setup.c
deleted file mode 100644
index 2fe6a11765e9..000000000000
--- a/arch/sh/boards/sh2000/setup.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * linux/arch/sh/kernel/setup_sh2000.c
3 *
4 * Copyright (C) 2001 SUGIOKA Tochinobu
5 *
6 * SH-2000 Support.
7 *
8 */
9
10#include <linux/init.h>
11#include <linux/irq.h>
12
13#include <asm/io.h>
14#include <asm/machvec.h>
15#include <asm/mach/sh2000.h>
16
17#define CF_CIS_BASE 0xb4200000
18
19#define PORT_PECR 0xa4000108
20#define PORT_PHCR 0xa400010E
21#define PORT_ICR1 0xa4000010
22#define PORT_IRR0 0xa4000004
23
24#define IDE_OFFSET 0xb6200000
25#define NIC_OFFSET 0xb6000000
26#define EXTBUS_OFFSET 0xba000000
27
28
29const char *get_system_type(void)
30{
31 return "sh2000";
32}
33
34static unsigned long sh2000_isa_port2addr(unsigned long offset)
35{
36 if((offset & ~7) == 0x1f0 || offset == 0x3f6)
37 return IDE_OFFSET + offset;
38 else if((offset & ~0x1f) == 0x300)
39 return NIC_OFFSET + offset;
40 return EXTBUS_OFFSET + offset;
41}
42
43/*
44 * The Machine Vector
45 */
46struct sh_machine_vector mv_sh2000 __initmv = {
47 .mv_nr_irqs = 80,
48 .mv_isa_port2addr = sh2000_isa_port2addr,
49};
50ALIAS_MV(sh2000)
51
52/*
53 * Initialize the board
54 */
55int __init platform_setup(void)
56{
57 /* XXX: RTC setting comes here */
58
59 /* These should be done by BIOS/IPL ... */
60 /* Enable nCE2A, nCE2B output */
61 ctrl_outw(ctrl_inw(PORT_PECR) & ~0xf00, PORT_PECR);
62 /* Enable the Compact Flash card, and set the level interrupt */
63 ctrl_outw(0x0042, CF_CIS_BASE+0x0200);
64 /* Enable interrupt */
65 ctrl_outw(ctrl_inw(PORT_PHCR) & ~0x03f3, PORT_PHCR);
66 ctrl_outw(1, PORT_ICR1);
67 ctrl_outw(ctrl_inw(PORT_IRR0) & ~0xff3f, PORT_IRR0);
68 printk(KERN_INFO "SH-2000 Setup...done\n");
69 return 0;
70}
diff --git a/arch/sh/boards/shmin/Makefile b/arch/sh/boards/shmin/Makefile
new file mode 100644
index 000000000000..3190cc72430e
--- /dev/null
+++ b/arch/sh/boards/shmin/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the SHMIN board.
3#
4
5obj-y := setup.o
diff --git a/arch/sh/boards/shmin/setup.c b/arch/sh/boards/shmin/setup.c
new file mode 100644
index 000000000000..2f0c19706cf9
--- /dev/null
+++ b/arch/sh/boards/shmin/setup.c
@@ -0,0 +1,41 @@
1/*
2 * arch/sh/boards/shmin/setup.c
3 *
4 * Copyright (C) 2006 Takashi YOSHII
5 *
6 * SHMIN Support.
7 */
8#include <linux/init.h>
9#include <asm/machvec.h>
10#include <asm/shmin/shmin.h>
11#include <asm/clock.h>
12#include <asm/irq.h>
13#include <asm/io.h>
14
15#define PFC_PHCR 0xa400010e
16
17static void __init init_shmin_irq(void)
18{
19 ctrl_outw(0x2a00, PFC_PHCR); // IRQ0-3=IRQ
20 ctrl_outw(0x0aaa, INTC_ICR1); // IRQ0-3=IRQ-mode,Low-active.
21}
22
23static void __iomem *shmin_ioport_map(unsigned long port, unsigned int size)
24{
25 static int dummy;
26
27 if ((port & ~0x1f) == SHMIN_NE_BASE)
28 return (void __iomem *)(SHMIN_IO_BASE + port);
29
30 dummy = 0;
31
32 return &dummy;
33
34}
35
36struct sh_machine_vector mv_shmin __initmv = {
37 .mv_name = "SHMIN",
38 .mv_init_irq = init_shmin_irq,
39 .mv_ioport_map = shmin_ioport_map,
40};
41ALIAS_MV(shmin)
diff --git a/arch/sh/boards/snapgear/io.c b/arch/sh/boards/snapgear/io.c
index e2eb78fc381d..0f4824264557 100644
--- a/arch/sh/boards/snapgear/io.c
+++ b/arch/sh/boards/snapgear/io.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/sh/kernel/io_7751se.c
3 *
4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com> 2 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
5 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel 3 * Copyright (C) 2001 Ian da Silva, Jeremy Siegel
6 * Based largely on io_se.c. 4 * Based largely on io_se.c.
@@ -11,67 +9,22 @@
11 * placeholder code from io_se.c left in with the 9 * placeholder code from io_se.c left in with the
12 * expectation of later SuperIO and PCMCIA access. 10 * expectation of later SuperIO and PCMCIA access.
13 */ 11 */
14
15#include <linux/kernel.h> 12#include <linux/kernel.h>
16#include <linux/types.h> 13#include <linux/types.h>
17#include <linux/pci.h> 14#include <linux/pci.h>
18#include <asm/io.h> 15#include <asm/io.h>
19#include <asm/addrspace.h> 16#include <asm/addrspace.h>
20 17
21#include <asm/pci.h>
22#include "../../drivers/pci/pci-sh7751.h"
23
24#ifdef CONFIG_SH_SECUREEDGE5410 18#ifdef CONFIG_SH_SECUREEDGE5410
25unsigned short secureedge5410_ioport; 19unsigned short secureedge5410_ioport;
26#endif 20#endif
27 21
28/*
29 * The SnapGear uses the built-in PCI controller (PCIC)
30 * of the 7751 processor
31 */
32
33#define PCIIOBR (volatile long *)PCI_REG(SH7751_PCIIOBR)
34#define PCIMBR (volatile long *)PCI_REG(SH7751_PCIMBR)
35#define PCI_IO_AREA SH7751_PCI_IO_BASE
36#define PCI_MEM_AREA SH7751_PCI_CONFIG_BASE
37
38
39#define PCI_IOMAP(adr) (PCI_IO_AREA + (adr & ~SH7751_PCIIOBR_MASK))
40
41
42#define maybebadio(name,port) \
43 printk("bad PC-like io %s for port 0x%lx at 0x%08x\n", \
44 #name, (port), (__u32) __builtin_return_address(0))
45
46
47static inline void delay(void)
48{
49 ctrl_inw(0xa0000000);
50}
51
52
53static inline volatile __u16 *port2adr(unsigned int port) 22static inline volatile __u16 *port2adr(unsigned int port)
54{ 23{
55#if 0 24 maybebadio((unsigned long)port);
56 if (port >= 0x2000)
57 return (volatile __u16 *) (PA_MRSHPC + (port - 0x2000));
58#endif
59 maybebadio(name,(unsigned long)port);
60 return (volatile __u16*)port; 25 return (volatile __u16*)port;
61} 26}
62 27
63
64/* In case someone configures the kernel w/o PCI support: in that */
65/* scenario, don't ever bother to check for PCI-window addresses */
66
67/* NOTE: WINDOW CHECK MAY BE A BIT OFF, HIGH PCIBIOS_MIN_IO WRAPS? */
68#if defined(CONFIG_PCI)
69#define CHECK_SH7751_PCIIO(port) \
70 ((port >= PCIBIOS_MIN_IO) && (port < (PCIBIOS_MIN_IO + SH7751_PCI_IO_SIZE)))
71#else
72#define CHECK_SH7751_PCIIO(port) (0)
73#endif
74
75/* 28/*
76 * General outline: remap really low stuff [eventually] to SuperIO, 29 * General outline: remap really low stuff [eventually] to SuperIO,
77 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO) 30 * stuff in PCI IO space (at or above window at pci.h:PCIBIOS_MIN_IO)
@@ -79,148 +32,106 @@ static inline volatile __u16 *port2adr(unsigned int port)
79 * should be way beyond the window, and is used w/o translation for 32 * should be way beyond the window, and is used w/o translation for
80 * compatibility. 33 * compatibility.
81 */ 34 */
82
83unsigned char snapgear_inb(unsigned long port) 35unsigned char snapgear_inb(unsigned long port)
84{ 36{
85 if (PXSEG(port)) 37 if (PXSEG(port))
86 return *(volatile unsigned char *)port; 38 return *(volatile unsigned char *)port;
87 else if (CHECK_SH7751_PCIIO(port)) 39 else if (is_pci_ioaddr(port))
88 return *(volatile unsigned char *)PCI_IOMAP(port); 40 return *(volatile unsigned char *)pci_ioaddr(port);
89 else 41 else
90 return (*port2adr(port))&0xff; 42 return (*port2adr(port)) & 0xff;
91} 43}
92 44
93
94unsigned char snapgear_inb_p(unsigned long port) 45unsigned char snapgear_inb_p(unsigned long port)
95{ 46{
96 unsigned char v; 47 unsigned char v;
97 48
98 if (PXSEG(port)) 49 if (PXSEG(port))
99 v = *(volatile unsigned char *)port; 50 v = *(volatile unsigned char *)port;
100 else if (CHECK_SH7751_PCIIO(port)) 51 else if (is_pci_ioaddr(port))
101 v = *(volatile unsigned char *)PCI_IOMAP(port); 52 v = *(volatile unsigned char *)pci_ioaddr(port);
102 else 53 else
103 v = (*port2adr(port))&0xff; 54 v = (*port2adr(port))&0xff;
104 delay(); 55 ctrl_delay();
105 return v; 56 return v;
106} 57}
107 58
108
109unsigned short snapgear_inw(unsigned long port) 59unsigned short snapgear_inw(unsigned long port)
110{ 60{
111 if (PXSEG(port)) 61 if (PXSEG(port))
112 return *(volatile unsigned short *)port; 62 return *(volatile unsigned short *)port;
113 else if (CHECK_SH7751_PCIIO(port)) 63 else if (is_pci_ioaddr(port))
114 return *(volatile unsigned short *)PCI_IOMAP(port); 64 return *(volatile unsigned short *)pci_ioaddr(port);
115 else if (port >= 0x2000) 65 else if (port >= 0x2000)
116 return *port2adr(port); 66 return *port2adr(port);
117 else 67 else
118 maybebadio(inw, port); 68 maybebadio(port);
119 return 0; 69 return 0;
120} 70}
121 71
122
123unsigned int snapgear_inl(unsigned long port) 72unsigned int snapgear_inl(unsigned long port)
124{ 73{
125 if (PXSEG(port)) 74 if (PXSEG(port))
126 return *(volatile unsigned long *)port; 75 return *(volatile unsigned long *)port;
127 else if (CHECK_SH7751_PCIIO(port)) 76 else if (is_pci_ioaddr(port))
128 return *(volatile unsigned int *)PCI_IOMAP(port); 77 return *(volatile unsigned int *)pci_ioaddr(port);
129 else if (port >= 0x2000) 78 else if (port >= 0x2000)
130 return *port2adr(port); 79 return *port2adr(port);
131 else 80 else
132 maybebadio(inl, port); 81 maybebadio(port);
133 return 0; 82 return 0;
134} 83}
135 84
136
137void snapgear_outb(unsigned char value, unsigned long port) 85void snapgear_outb(unsigned char value, unsigned long port)
138{ 86{
139 87
140 if (PXSEG(port)) 88 if (PXSEG(port))
141 *(volatile unsigned char *)port = value; 89 *(volatile unsigned char *)port = value;
142 else if (CHECK_SH7751_PCIIO(port)) 90 else if (is_pci_ioaddr(port))
143 *((unsigned char*)PCI_IOMAP(port)) = value; 91 *((unsigned char*)pci_ioaddr(port)) = value;
144 else 92 else
145 *(port2adr(port)) = value; 93 *(port2adr(port)) = value;
146} 94}
147 95
148
149void snapgear_outb_p(unsigned char value, unsigned long port) 96void snapgear_outb_p(unsigned char value, unsigned long port)
150{ 97{
151 if (PXSEG(port)) 98 if (PXSEG(port))
152 *(volatile unsigned char *)port = value; 99 *(volatile unsigned char *)port = value;
153 else if (CHECK_SH7751_PCIIO(port)) 100 else if (is_pci_ioaddr(port))
154 *((unsigned char*)PCI_IOMAP(port)) = value; 101 *((unsigned char*)pci_ioaddr(port)) = value;
155 else 102 else
156 *(port2adr(port)) = value; 103 *(port2adr(port)) = value;
157 delay(); 104 ctrl_delay();
158} 105}
159 106
160
161void snapgear_outw(unsigned short value, unsigned long port) 107void snapgear_outw(unsigned short value, unsigned long port)
162{ 108{
163 if (PXSEG(port)) 109 if (PXSEG(port))
164 *(volatile unsigned short *)port = value; 110 *(volatile unsigned short *)port = value;
165 else if (CHECK_SH7751_PCIIO(port)) 111 else if (is_pci_ioaddr(port))
166 *((unsigned short *)PCI_IOMAP(port)) = value; 112 *((unsigned short *)pci_ioaddr(port)) = value;
167 else if (port >= 0x2000) 113 else if (port >= 0x2000)
168 *port2adr(port) = value; 114 *port2adr(port) = value;
169 else 115 else
170 maybebadio(outw, port); 116 maybebadio(port);
171} 117}
172 118
173
174void snapgear_outl(unsigned int value, unsigned long port) 119void snapgear_outl(unsigned int value, unsigned long port)
175{ 120{
176 if (PXSEG(port)) 121 if (PXSEG(port))
177 *(volatile unsigned long *)port = value; 122 *(volatile unsigned long *)port = value;
178 else if (CHECK_SH7751_PCIIO(port)) 123 else if (is_pci_ioaddr(port))
179 *((unsigned long*)PCI_IOMAP(port)) = value; 124 *((unsigned long*)pci_ioaddr(port)) = value;
180 else 125 else
181 maybebadio(outl, port); 126 maybebadio(port);
182} 127}
183 128
184void snapgear_insl(unsigned long port, void *addr, unsigned long count) 129void snapgear_insl(unsigned long port, void *addr, unsigned long count)
185{ 130{
186 maybebadio(insl, port); 131 maybebadio(port);
187} 132}
188 133
189void snapgear_outsl(unsigned long port, const void *addr, unsigned long count) 134void snapgear_outsl(unsigned long port, const void *addr, unsigned long count)
190{ 135{
191 maybebadio(outsw, port); 136 maybebadio(port);
192}
193
194/* Map ISA bus address to the real address. Only for PCMCIA. */
195
196
197/* ISA page descriptor. */
198static __u32 sh_isa_memmap[256];
199
200
201#if 0
202static int sh_isa_mmap(__u32 start, __u32 length, __u32 offset)
203{
204 int idx;
205
206 if (start >= 0x100000 || (start & 0xfff) || (length != 0x1000))
207 return -1;
208
209 idx = start >> 12;
210 sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff);
211#if 0
212 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n",
213 start, length, offset, idx, sh_isa_memmap[idx]);
214#endif
215 return 0;
216}
217#endif
218
219unsigned long snapgear_isa_port2addr(unsigned long offset)
220{
221 int idx;
222
223 idx = (offset >> 12) & 0xff;
224 offset &= 0xfff;
225 return sh_isa_memmap[idx] + offset;
226} 137}
diff --git a/arch/sh/boards/snapgear/rtc.c b/arch/sh/boards/snapgear/rtc.c
index b71e009da35c..1659fdd6695a 100644
--- a/arch/sh/boards/snapgear/rtc.c
+++ b/arch/sh/boards/snapgear/rtc.c
@@ -17,14 +17,9 @@
17#include <linux/time.h> 17#include <linux/time.h>
18#include <linux/rtc.h> 18#include <linux/rtc.h>
19#include <linux/mc146818rtc.h> 19#include <linux/mc146818rtc.h>
20
21#include <asm/io.h> 20#include <asm/io.h>
22#include <asm/rtc.h>
23#include <asm/mc146818rtc.h>
24
25/****************************************************************************/
26 21
27static int use_ds1302 = 0; 22static int use_ds1302;
28 23
29/****************************************************************************/ 24/****************************************************************************/
30/* 25/*
@@ -82,10 +77,6 @@ static unsigned int ds1302_readbyte(unsigned int addr)
82 unsigned int val; 77 unsigned int val;
83 unsigned long flags; 78 unsigned long flags;
84 79
85#if 0
86 printk("SnapGear RTC: ds1302_readbyte(addr=%x)\n", addr);
87#endif
88
89 local_irq_save(flags); 80 local_irq_save(flags);
90 set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); 81 set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK);
91 set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); 82 set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK));
@@ -104,10 +95,6 @@ static void ds1302_writebyte(unsigned int addr, unsigned int val)
104{ 95{
105 unsigned long flags; 96 unsigned long flags;
106 97
107#if 0
108 printk("SnapGear RTC: ds1302_writebyte(addr=%x)\n", addr);
109#endif
110
111 local_irq_save(flags); 98 local_irq_save(flags);
112 set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); 99 set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK);
113 set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); 100 set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK));
@@ -168,11 +155,8 @@ void __init secureedge5410_rtc_init(void)
168 } 155 }
169 156
170 if (use_ds1302) { 157 if (use_ds1302) {
171 rtc_get_time = snapgear_rtc_gettimeofday; 158 rtc_sh_get_time = snapgear_rtc_gettimeofday;
172 rtc_set_time = snapgear_rtc_settimeofday; 159 rtc_sh_set_time = snapgear_rtc_settimeofday;
173 } else {
174 rtc_get_time = sh_rtc_gettimeofday;
175 rtc_set_time = sh_rtc_settimeofday;
176 } 160 }
177 161
178 printk("SnapGear RTC: using %s rtc.\n", use_ds1302 ? "ds1302" : "internal"); 162 printk("SnapGear RTC: using %s rtc.\n", use_ds1302 ? "ds1302" : "internal");
@@ -187,10 +171,8 @@ void snapgear_rtc_gettimeofday(struct timespec *ts)
187{ 171{
188 unsigned int sec, min, hr, day, mon, yr; 172 unsigned int sec, min, hr, day, mon, yr;
189 173
190 if (!use_ds1302) { 174 if (!use_ds1302)
191 sh_rtc_gettimeofday(ts);
192 return; 175 return;
193 }
194 176
195 sec = bcd2int(ds1302_readbyte(RTC_ADDR_SEC)); 177 sec = bcd2int(ds1302_readbyte(RTC_ADDR_SEC));
196 min = bcd2int(ds1302_readbyte(RTC_ADDR_MIN)); 178 min = bcd2int(ds1302_readbyte(RTC_ADDR_MIN));
@@ -231,7 +213,7 @@ int snapgear_rtc_settimeofday(const time_t secs)
231 unsigned long nowtime; 213 unsigned long nowtime;
232 214
233 if (!use_ds1302) 215 if (!use_ds1302)
234 return sh_rtc_settimeofday(secs); 216 return 0;
235 217
236/* 218/*
237 * This is called direct from the kernel timer handling code. 219 * This is called direct from the kernel timer handling code.
@@ -240,10 +222,6 @@ int snapgear_rtc_settimeofday(const time_t secs)
240 222
241 nowtime = secs; 223 nowtime = secs;
242 224
243#if 1
244 printk("SnapGear RTC: snapgear_rtc_settimeofday(nowtime=%ld)\n", nowtime);
245#endif
246
247 /* STOP RTC */ 225 /* STOP RTC */
248 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); 226 ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80);
249 227
@@ -329,5 +307,3 @@ void secureedge5410_cmos_write(unsigned char val, int addr)
329 default: break; 307 default: break;
330 } 308 }
331} 309}
332
333/****************************************************************************/
diff --git a/arch/sh/boards/snapgear/setup.c b/arch/sh/boards/snapgear/setup.c
index f1f7c70c9402..f5e98c56b530 100644
--- a/arch/sh/boards/snapgear/setup.c
+++ b/arch/sh/boards/snapgear/setup.c
@@ -1,5 +1,4 @@
1/****************************************************************************/ 1/*
2/*
3 * linux/arch/sh/boards/snapgear/setup.c 2 * linux/arch/sh/boards/snapgear/setup.c
4 * 3 *
5 * Copyright (C) 2002 David McCullough <davidm@snapgear.com> 4 * Copyright (C) 2002 David McCullough <davidm@snapgear.com>
@@ -12,8 +11,6 @@
12 * Modified for 7751 Solution Engine by 11 * Modified for 7751 Solution Engine by
13 * Ian da Silva and Jeremy Siegel, 2001. 12 * Ian da Silva and Jeremy Siegel, 2001.
14 */ 13 */
15/****************************************************************************/
16
17#include <linux/init.h> 14#include <linux/init.h>
18#include <linux/irq.h> 15#include <linux/irq.h>
19#include <linux/interrupt.h> 16#include <linux/interrupt.h>
@@ -21,14 +18,13 @@
21#include <linux/delay.h> 18#include <linux/delay.h>
22#include <linux/module.h> 19#include <linux/module.h>
23#include <linux/sched.h> 20#include <linux/sched.h>
24
25#include <asm/machvec.h> 21#include <asm/machvec.h>
26#include <asm/mach/io.h> 22#include <asm/snapgear.h>
27#include <asm/irq.h> 23#include <asm/irq.h>
28#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/rtc.h>
29#include <asm/cpu/timer.h> 26#include <asm/cpu/timer.h>
30 27
31extern void (*board_time_init)(void);
32extern void secureedge5410_rtc_init(void); 28extern void secureedge5410_rtc_init(void);
33extern void pcibios_init(void); 29extern void pcibios_init(void);
34 30
@@ -85,101 +81,20 @@ static void __init init_snapgear_IRQ(void)
85 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY); 81 make_ipr_irq(IRL3_IRQ, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY);
86} 82}
87 83
88/****************************************************************************/
89/*
90 * Fast poll interrupt simulator.
91 */
92
93/* 84/*
94 * Leave all of the fast timer/fast poll stuff commented out for now, since 85 * Initialize the board
95 * it's not clear whether it actually works or not. Since it wasn't being used
96 * at all in 2.4, we'll assume it's not sane for 2.6 either.. -- PFM
97 */
98#if 0
99#define FAST_POLL 1000
100//#define FAST_POLL_INTR
101
102#define FASTTIMER_IRQ 17
103#define FASTTIMER_IPR_ADDR INTC_IPRA
104#define FASTTIMER_IPR_POS 2
105#define FASTTIMER_PRIORITY 3
106
107#ifdef FAST_POLL_INTR
108#define TMU1_TCR_INIT 0x0020
109#else
110#define TMU1_TCR_INIT 0
111#endif
112#define TMU_TSTR_INIT 1
113#define TMU1_TCR_CALIB 0x0000
114
115
116#ifdef FAST_POLL_INTR
117static void fast_timer_irq(int irq, void *dev_instance, struct pt_regs *regs)
118{
119 unsigned long timer_status;
120 timer_status = ctrl_inw(TMU1_TCR);
121 timer_status &= ~0x100;
122 ctrl_outw(timer_status, TMU1_TCR);
123}
124#endif
125
126/*
127 * return the current ticks on the fast timer
128 */
129
130unsigned long fast_timer_count(void)
131{
132 return(ctrl_inl(TMU1_TCNT));
133}
134
135/*
136 * setup a fast timer for profiling etc etc
137 */ 86 */
138 87static void __init snapgear_setup(char **cmdline_p)
139static void setup_fast_timer()
140{
141 unsigned long interval;
142
143#ifdef FAST_POLL_INTR
144 interval = (current_cpu_data.module_clock/4 + FAST_POLL/2) / FAST_POLL;
145
146 make_ipr_irq(FASTTIMER_IRQ, FASTTIMER_IPR_ADDR, FASTTIMER_IPR_POS,
147 FASTTIMER_PRIORITY);
148
149 printk("SnapGear: %dHz fast timer on IRQ %d\n",FAST_POLL,FASTTIMER_IRQ);
150
151 if (request_irq(FASTTIMER_IRQ, fast_timer_irq, 0, "SnapGear fast timer",
152 NULL) != 0)
153 printk("%s(%d): request_irq() failed?\n", __FILE__, __LINE__);
154#else
155 printk("SnapGear: fast timer running\n",FAST_POLL,FASTTIMER_IRQ);
156 interval = 0xffffffff;
157#endif
158
159 ctrl_outb(ctrl_inb(TMU_TSTR) & ~0x2, TMU_TSTR); /* disable timer 1 */
160 ctrl_outw(TMU1_TCR_INIT, TMU1_TCR);
161 ctrl_outl(interval, TMU1_TCOR);
162 ctrl_outl(interval, TMU1_TCNT);
163 ctrl_outb(ctrl_inb(TMU_TSTR) | 0x2, TMU_TSTR); /* enable timer 1 */
164
165 printk("Timer count 1 = 0x%x\n", fast_timer_count());
166 udelay(1000);
167 printk("Timer count 2 = 0x%x\n", fast_timer_count());
168}
169#endif
170
171/****************************************************************************/
172
173const char *get_system_type(void)
174{ 88{
175 return "SnapGear SecureEdge5410"; 89 board_time_init = secureedge5410_rtc_init;
176} 90}
177 91
178/* 92/*
179 * The Machine Vector 93 * The Machine Vector
180 */ 94 */
181
182struct sh_machine_vector mv_snapgear __initmv = { 95struct sh_machine_vector mv_snapgear __initmv = {
96 .mv_name = "SnapGear SecureEdge5410",
97 .mv_setup = snapgear_setup,
183 .mv_nr_irqs = 72, 98 .mv_nr_irqs = 72,
184 99
185 .mv_inb = snapgear_inb, 100 .mv_inb = snapgear_inb,
@@ -196,20 +111,6 @@ struct sh_machine_vector mv_snapgear __initmv = {
196 .mv_outw_p = snapgear_outw, 111 .mv_outw_p = snapgear_outw,
197 .mv_outl_p = snapgear_outl, 112 .mv_outl_p = snapgear_outl,
198 113
199 .mv_isa_port2addr = snapgear_isa_port2addr,
200
201 .mv_init_irq = init_snapgear_IRQ, 114 .mv_init_irq = init_snapgear_IRQ,
202}; 115};
203ALIAS_MV(snapgear) 116ALIAS_MV(snapgear)
204
205/*
206 * Initialize the board
207 */
208
209int __init platform_setup(void)
210{
211 board_time_init = secureedge5410_rtc_init;
212
213 return 0;
214}
215
diff --git a/arch/sh/boards/superh/microdev/irq.c b/arch/sh/boards/superh/microdev/irq.c
index 236398fbc083..8c64baa30364 100644
--- a/arch/sh/boards/superh/microdev/irq.c
+++ b/arch/sh/boards/superh/microdev/irq.c
@@ -11,14 +11,12 @@
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14
15#include <asm/system.h> 14#include <asm/system.h>
16#include <asm/io.h> 15#include <asm/io.h>
17#include <asm/microdev.h> 16#include <asm/microdev.h>
18 17
19#define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */ 18#define NUM_EXTERNAL_IRQS 16 /* IRL0 .. IRL15 */
20 19
21
22static const struct { 20static const struct {
23 unsigned char fpgaIrq; 21 unsigned char fpgaIrq;
24 unsigned char mapped; 22 unsigned char mapped;
@@ -93,53 +91,42 @@ static struct hw_interrupt_type microdev_irq_type = {
93 91
94static void disable_microdev_irq(unsigned int irq) 92static void disable_microdev_irq(unsigned int irq)
95{ 93{
96 unsigned int flags;
97 unsigned int fpgaIrq; 94 unsigned int fpgaIrq;
98 95
99 if (irq >= NUM_EXTERNAL_IRQS) return; 96 if (irq >= NUM_EXTERNAL_IRQS)
100 if (!fpgaIrqTable[irq].mapped) return; 97 return;
98 if (!fpgaIrqTable[irq].mapped)
99 return;
101 100
102 fpgaIrq = fpgaIrqTable[irq].fpgaIrq; 101 fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
103 102
104 /* disable interrupts */ 103 /* disable interupts on the FPGA INTC register */
105 local_irq_save(flags);
106
107 /* disable interupts on the FPGA INTC register */
108 ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG); 104 ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTDSB_REG);
109
110 /* restore interrupts */
111 local_irq_restore(flags);
112} 105}
113 106
114static void enable_microdev_irq(unsigned int irq) 107static void enable_microdev_irq(unsigned int irq)
115{ 108{
116 unsigned long priorityReg, priorities, pri; 109 unsigned long priorityReg, priorities, pri;
117 unsigned int flags;
118 unsigned int fpgaIrq; 110 unsigned int fpgaIrq;
119 111
120 112 if (unlikely(irq >= NUM_EXTERNAL_IRQS))
121 if (irq >= NUM_EXTERNAL_IRQS) return; 113 return;
122 if (!fpgaIrqTable[irq].mapped) return; 114 if (unlikely(!fpgaIrqTable[irq].mapped))
115 return;
123 116
124 pri = 15 - irq; 117 pri = 15 - irq;
125 118
126 fpgaIrq = fpgaIrqTable[irq].fpgaIrq; 119 fpgaIrq = fpgaIrqTable[irq].fpgaIrq;
127 priorityReg = MICRODEV_FPGA_INTPRI_REG(fpgaIrq); 120 priorityReg = MICRODEV_FPGA_INTPRI_REG(fpgaIrq);
128 121
129 /* disable interrupts */ 122 /* set priority for the interrupt */
130 local_irq_save(flags);
131
132 /* set priority for the interrupt */
133 priorities = ctrl_inl(priorityReg); 123 priorities = ctrl_inl(priorityReg);
134 priorities &= ~MICRODEV_FPGA_INTPRI_MASK(fpgaIrq); 124 priorities &= ~MICRODEV_FPGA_INTPRI_MASK(fpgaIrq);
135 priorities |= MICRODEV_FPGA_INTPRI_LEVEL(fpgaIrq, pri); 125 priorities |= MICRODEV_FPGA_INTPRI_LEVEL(fpgaIrq, pri);
136 ctrl_outl(priorities, priorityReg); 126 ctrl_outl(priorities, priorityReg);
137 127
138 /* enable interupts on the FPGA INTC register */ 128 /* enable interupts on the FPGA INTC register */
139 ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG); 129 ctrl_outl(MICRODEV_FPGA_INTC_MASK(fpgaIrq), MICRODEV_FPGA_INTENB_REG);
140
141 /* restore interrupts */
142 local_irq_restore(flags);
143} 130}
144 131
145 /* This functions sets the desired irq handler to be a MicroDev type */ 132 /* This functions sets the desired irq handler to be a MicroDev type */
@@ -158,9 +145,7 @@ static void mask_and_ack_microdev(unsigned int irq)
158static void end_microdev_irq(unsigned int irq) 145static void end_microdev_irq(unsigned int irq)
159{ 146{
160 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 147 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
161 {
162 enable_microdev_irq(irq); 148 enable_microdev_irq(irq);
163 }
164} 149}
165 150
166extern void __init init_microdev_irq(void) 151extern void __init init_microdev_irq(void)
@@ -171,9 +156,7 @@ extern void __init init_microdev_irq(void)
171 ctrl_outl(~0ul, MICRODEV_FPGA_INTDSB_REG); 156 ctrl_outl(~0ul, MICRODEV_FPGA_INTDSB_REG);
172 157
173 for (i = 0; i < NUM_EXTERNAL_IRQS; i++) 158 for (i = 0; i < NUM_EXTERNAL_IRQS; i++)
174 {
175 make_microdev_irq(i); 159 make_microdev_irq(i);
176 }
177} 160}
178 161
179extern void microdev_print_fpga_intc_status(void) 162extern void microdev_print_fpga_intc_status(void)
diff --git a/arch/sh/boards/superh/microdev/setup.c b/arch/sh/boards/superh/microdev/setup.c
index 61b402a3f5d7..031c814e6e76 100644
--- a/arch/sh/boards/superh/microdev/setup.c
+++ b/arch/sh/boards/superh/microdev/setup.c
@@ -10,7 +10,6 @@
10 * May be copied or modified under the terms of the GNU General Public 10 * May be copied or modified under the terms of the GNU General Public
11 * License. See linux/COPYING for more information. 11 * License. See linux/COPYING for more information.
12 */ 12 */
13
14#include <linux/init.h> 13#include <linux/init.h>
15#include <linux/platform_device.h> 14#include <linux/platform_device.h>
16#include <linux/ioport.h> 15#include <linux/ioport.h>
@@ -21,41 +20,6 @@
21 20
22extern void microdev_heartbeat(void); 21extern void microdev_heartbeat(void);
23 22
24/*
25 * The Machine Vector
26 */
27
28struct sh_machine_vector mv_sh4202_microdev __initmv = {
29 .mv_nr_irqs = 72, /* QQQ need to check this - use the MACRO */
30
31 .mv_inb = microdev_inb,
32 .mv_inw = microdev_inw,
33 .mv_inl = microdev_inl,
34 .mv_outb = microdev_outb,
35 .mv_outw = microdev_outw,
36 .mv_outl = microdev_outl,
37
38 .mv_inb_p = microdev_inb_p,
39 .mv_inw_p = microdev_inw_p,
40 .mv_inl_p = microdev_inl_p,
41 .mv_outb_p = microdev_outb_p,
42 .mv_outw_p = microdev_outw_p,
43 .mv_outl_p = microdev_outl_p,
44
45 .mv_insb = microdev_insb,
46 .mv_insw = microdev_insw,
47 .mv_insl = microdev_insl,
48 .mv_outsb = microdev_outsb,
49 .mv_outsw = microdev_outsw,
50 .mv_outsl = microdev_outsl,
51
52 .mv_init_irq = init_microdev_irq,
53
54#ifdef CONFIG_HEARTBEAT
55 .mv_heartbeat = microdev_heartbeat,
56#endif
57};
58ALIAS_MV(sh4202_microdev)
59 23
60/****************************************************************************/ 24/****************************************************************************/
61 25
@@ -113,11 +77,6 @@ ALIAS_MV(sh4202_microdev)
113 /* assume a Keyboard Controller is present */ 77 /* assume a Keyboard Controller is present */
114int microdev_kbd_controller_present = 1; 78int microdev_kbd_controller_present = 1;
115 79
116const char *get_system_type(void)
117{
118 return "SH4-202 MicroDev";
119}
120
121static struct resource smc91x_resources[] = { 80static struct resource smc91x_resources[] = {
122 [0] = { 81 [0] = {
123 .start = 0x300, 82 .start = 0x300,
@@ -291,25 +250,9 @@ static int __init microdev_devices_setup(void)
291 return platform_add_devices(microdev_devices, ARRAY_SIZE(microdev_devices)); 250 return platform_add_devices(microdev_devices, ARRAY_SIZE(microdev_devices));
292} 251}
293 252
294__initcall(microdev_devices_setup); 253/*
295 254 * Setup for the SMSC FDC37C93xAPM
296void __init platform_setup(void) 255 */
297{
298 int * const fpgaRevisionRegister = (int*)(MICRODEV_FPGA_GP_BASE + 0x8ul);
299 const int fpgaRevision = *fpgaRevisionRegister;
300 int * const CacheControlRegister = (int*)CCR;
301
302 printk("SuperH %s board (FPGA rev: 0x%0x, CCR: 0x%0x)\n",
303 get_system_type(), fpgaRevision, *CacheControlRegister);
304}
305
306
307/****************************************************************************/
308
309
310 /*
311 * Setup for the SMSC FDC37C93xAPM
312 */
313static int __init smsc_superio_setup(void) 256static int __init smsc_superio_setup(void)
314{ 257{
315 258
@@ -412,8 +355,52 @@ static int __init smsc_superio_setup(void)
412 return 0; 355 return 0;
413} 356}
414 357
358static void __init microdev_setup(char **cmdline_p)
359{
360 int * const fpgaRevisionRegister = (int*)(MICRODEV_FPGA_GP_BASE + 0x8ul);
361 const int fpgaRevision = *fpgaRevisionRegister;
362 int * const CacheControlRegister = (int*)CCR;
363
364 device_initcall(microdev_devices_setup);
365 device_initcall(smsc_superio_setup);
415 366
416/* This is grotty, but, because kernel is always referenced on the link line 367 printk("SuperH %s board (FPGA rev: 0x%0x, CCR: 0x%0x)\n",
417 * before any devices, this is safe. 368 get_system_type(), fpgaRevision, *CacheControlRegister);
369}
370
371/*
372 * The Machine Vector
418 */ 373 */
419__initcall(smsc_superio_setup); 374struct sh_machine_vector mv_sh4202_microdev __initmv = {
375 .mv_name = "SH4-202 MicroDev",
376 .mv_setup = microdev_setup,
377 .mv_nr_irqs = 72, /* QQQ need to check this - use the MACRO */
378
379 .mv_inb = microdev_inb,
380 .mv_inw = microdev_inw,
381 .mv_inl = microdev_inl,
382 .mv_outb = microdev_outb,
383 .mv_outw = microdev_outw,
384 .mv_outl = microdev_outl,
385
386 .mv_inb_p = microdev_inb_p,
387 .mv_inw_p = microdev_inw_p,
388 .mv_inl_p = microdev_inl_p,
389 .mv_outb_p = microdev_outb_p,
390 .mv_outw_p = microdev_outw_p,
391 .mv_outl_p = microdev_outl_p,
392
393 .mv_insb = microdev_insb,
394 .mv_insw = microdev_insw,
395 .mv_insl = microdev_insl,
396 .mv_outsb = microdev_outsb,
397 .mv_outsw = microdev_outsw,
398 .mv_outsl = microdev_outsl,
399
400 .mv_init_irq = init_microdev_irq,
401
402#ifdef CONFIG_HEARTBEAT
403 .mv_heartbeat = microdev_heartbeat,
404#endif
405};
406ALIAS_MV(sh4202_microdev)
diff --git a/arch/sh/boards/titan/Makefile b/arch/sh/boards/titan/Makefile
new file mode 100644
index 000000000000..08d753700062
--- /dev/null
+++ b/arch/sh/boards/titan/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the Nimble Microsystems TITAN specific parts of the kernel
3#
4
5obj-y := setup.o io.o
diff --git a/arch/sh/boards/titan/io.c b/arch/sh/boards/titan/io.c
new file mode 100644
index 000000000000..4730c1dd697d
--- /dev/null
+++ b/arch/sh/boards/titan/io.c
@@ -0,0 +1,126 @@
1/*
2 * I/O routines for Titan
3 */
4#include <linux/pci.h>
5#include <asm/machvec.h>
6#include <asm/addrspace.h>
7#include <asm/titan.h>
8#include <asm/io.h>
9
10static inline unsigned int port2adr(unsigned int port)
11{
12 maybebadio((unsigned long)port);
13 return port;
14}
15
16u8 titan_inb(unsigned long port)
17{
18 if (PXSEG(port))
19 return ctrl_inb(port);
20 else if (is_pci_ioaddr(port))
21 return ctrl_inb(pci_ioaddr(port));
22 return ctrl_inw(port2adr(port)) & 0xff;
23}
24
25u8 titan_inb_p(unsigned long port)
26{
27 u8 v;
28
29 if (PXSEG(port))
30 v = ctrl_inb(port);
31 else if (is_pci_ioaddr(port))
32 v = ctrl_inb(pci_ioaddr(port));
33 else
34 v = ctrl_inw(port2adr(port)) & 0xff;
35 ctrl_delay();
36 return v;
37}
38
39u16 titan_inw(unsigned long port)
40{
41 if (PXSEG(port))
42 return ctrl_inw(port);
43 else if (is_pci_ioaddr(port))
44 return ctrl_inw(pci_ioaddr(port));
45 else if (port >= 0x2000)
46 return ctrl_inw(port2adr(port));
47 else
48 maybebadio(port);
49 return 0;
50}
51
52u32 titan_inl(unsigned long port)
53{
54 if (PXSEG(port))
55 return ctrl_inl(port);
56 else if (is_pci_ioaddr(port))
57 return ctrl_inl(pci_ioaddr(port));
58 else if (port >= 0x2000)
59 return ctrl_inw(port2adr(port));
60 else
61 maybebadio(port);
62 return 0;
63}
64
65void titan_outb(u8 value, unsigned long port)
66{
67 if (PXSEG(port))
68 ctrl_outb(value, port);
69 else if (is_pci_ioaddr(port))
70 ctrl_outb(value, pci_ioaddr(port));
71 else
72 ctrl_outw(value, port2adr(port));
73}
74
75void titan_outb_p(u8 value, unsigned long port)
76{
77 if (PXSEG(port))
78 ctrl_outb(value, port);
79 else if (is_pci_ioaddr(port))
80 ctrl_outb(value, pci_ioaddr(port));
81 else
82 ctrl_outw(value, port2adr(port));
83 ctrl_delay();
84}
85
86void titan_outw(u16 value, unsigned long port)
87{
88 if (PXSEG(port))
89 ctrl_outw(value, port);
90 else if (is_pci_ioaddr(port))
91 ctrl_outw(value, pci_ioaddr(port));
92 else if (port >= 0x2000)
93 ctrl_outw(value, port2adr(port));
94 else
95 maybebadio(port);
96}
97
98void titan_outl(u32 value, unsigned long port)
99{
100 if (PXSEG(port))
101 ctrl_outl(value, port);
102 else if (is_pci_ioaddr(port))
103 ctrl_outl(value, pci_ioaddr(port));
104 else
105 maybebadio(port);
106}
107
108void titan_insl(unsigned long port, void *dst, unsigned long count)
109{
110 maybebadio(port);
111}
112
113void titan_outsl(unsigned long port, const void *src, unsigned long count)
114{
115 maybebadio(port);
116}
117
118void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
119{
120 if (PXSEG(port) || is_pci_memaddr(port))
121 return (void __iomem *)port;
122 else if (is_pci_ioaddr(port))
123 return (void __iomem *)pci_ioaddr(port);
124
125 return (void __iomem *)port2adr(port);
126}
diff --git a/arch/sh/boards/titan/setup.c b/arch/sh/boards/titan/setup.c
new file mode 100644
index 000000000000..52b66d8b8d2a
--- /dev/null
+++ b/arch/sh/boards/titan/setup.c
@@ -0,0 +1,48 @@
1/*
2 * Setup for Titan
3 */
4
5#include <linux/init.h>
6#include <asm/irq.h>
7#include <asm/titan.h>
8#include <asm/io.h>
9
10extern void __init pcibios_init_platform(void);
11
12static void __init init_titan_irq(void)
13{
14 /* enable individual interrupt mode for externals */
15 ctrl_outw(ctrl_inw(INTC_ICR) | INTC_ICR_IRLM, INTC_ICR);
16
17 make_ipr_irq( TITAN_IRQ_WAN, IRL0_IPR_ADDR, IRL0_IPR_POS, IRL0_PRIORITY); /* PCIRQ0 */
18 make_ipr_irq( TITAN_IRQ_LAN, IRL1_IPR_ADDR, IRL1_IPR_POS, IRL1_PRIORITY); /* PCIRQ1 */
19 make_ipr_irq( TITAN_IRQ_MPCIA, IRL2_IPR_ADDR, IRL2_IPR_POS, IRL2_PRIORITY); /* PCIRQ2 */
20 make_ipr_irq( TITAN_IRQ_USB, IRL3_IPR_ADDR, IRL3_IPR_POS, IRL3_PRIORITY); /* PCIRQ3 */
21}
22
23struct sh_machine_vector mv_titan __initmv = {
24 .mv_name = "Titan",
25
26 .mv_inb = titan_inb,
27 .mv_inw = titan_inw,
28 .mv_inl = titan_inl,
29 .mv_outb = titan_outb,
30 .mv_outw = titan_outw,
31 .mv_outl = titan_outl,
32
33 .mv_inb_p = titan_inb_p,
34 .mv_inw_p = titan_inw,
35 .mv_inl_p = titan_inl,
36 .mv_outb_p = titan_outb_p,
37 .mv_outw_p = titan_outw,
38 .mv_outl_p = titan_outl,
39
40 .mv_insl = titan_insl,
41 .mv_outsl = titan_outsl,
42
43 .mv_ioport_map = titan_ioport_map,
44
45 .mv_init_irq = init_titan_irq,
46 .mv_init_pci = pcibios_init_platform,
47};
48ALIAS_MV(titan)
diff --git a/arch/sh/boards/unknown/setup.c b/arch/sh/boards/unknown/setup.c
index c5e4ed10876b..1c941370a2e3 100644
--- a/arch/sh/boards/unknown/setup.c
+++ b/arch/sh/boards/unknown/setup.c
@@ -14,19 +14,8 @@
14 */ 14 */
15#include <linux/init.h> 15#include <linux/init.h>
16#include <asm/machvec.h> 16#include <asm/machvec.h>
17#include <asm/irq.h>
18 17
19struct sh_machine_vector mv_unknown __initmv = { 18struct sh_machine_vector mv_unknown __initmv = {
20 .mv_nr_irqs = NR_IRQS, 19 .mv_name = "Unknown",
21}; 20};
22ALIAS_MV(unknown) 21ALIAS_MV(unknown)
23
24const char *get_system_type(void)
25{
26 return "Unknown";
27}
28
29void __init platform_setup(void)
30{
31}
32
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 75a6876bf6c6..e5f443790079 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -18,13 +18,20 @@ endif
18# Assign dummy values if these 2 variables are not defined, 18# Assign dummy values if these 2 variables are not defined,
19# in order to suppress error message. 19# in order to suppress error message.
20# 20#
21CONFIG_PAGE_OFFSET ?= 0x80000000
21CONFIG_MEMORY_START ?= 0x0c000000 22CONFIG_MEMORY_START ?= 0x0c000000
22CONFIG_BOOT_LINK_OFFSET ?= 0x00800000 23CONFIG_BOOT_LINK_OFFSET ?= 0x00800000
23IMAGE_OFFSET := $(shell printf "0x%8x" $$[0x80000000+$(CONFIG_MEMORY_START)+$(CONFIG_BOOT_LINK_OFFSET)]) 24
25IMAGE_OFFSET := $(shell printf "0x%08x" $$[$(CONFIG_PAGE_OFFSET) + \
26 $(CONFIG_MEMORY_START) + \
27 $(CONFIG_BOOT_LINK_OFFSET)])
28
29LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
24 30
25LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds 31LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds
26 32
27$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o FORCE 33
34$(obj)/vmlinux: $(OBJECTS) $(obj)/piggy.o $(LIBGCC) FORCE
28 $(call if_changed,ld) 35 $(call if_changed,ld)
29 @: 36 @:
30 37
diff --git a/arch/sh/cchips/Kconfig b/arch/sh/cchips/Kconfig
index 155d139884c3..0582ca8346b6 100644
--- a/arch/sh/cchips/Kconfig
+++ b/arch/sh/cchips/Kconfig
@@ -65,6 +65,11 @@ config HD64461_IRQ
65 65
66 Do not change this unless you know what you are doing. 66 Do not change this unless you know what you are doing.
67 67
68config HD64461_IOBASE
69 hex "HD64461 start address"
70 depends on HD64461
71 default "0xb0000000"
72
68config HD64461_ENABLER 73config HD64461_ENABLER
69 bool "HD64461 PCMCIA enabler" 74 bool "HD64461 PCMCIA enabler"
70 depends on HD64461 75 depends on HD64461
@@ -73,7 +78,6 @@ config HD64461_ENABLER
73 via the HD64461 companion chip. 78 via the HD64461 companion chip.
74 Otherwise, say N. 79 Otherwise, say N.
75 80
76
77config HD64465_IOBASE 81config HD64465_IOBASE
78 hex "HD64465 start address" 82 hex "HD64465 start address"
79 depends on HD64465 83 depends on HD64465
diff --git a/arch/sh/cchips/hd6446x/hd64461/io.c b/arch/sh/cchips/hd6446x/hd64461/io.c
index ac3062671db7..7909a1b7b512 100644
--- a/arch/sh/cchips/hd6446x/hd64461/io.c
+++ b/arch/sh/cchips/hd6446x/hd64461/io.c
@@ -1,11 +1,10 @@
1/* 1/*
2 * $Id: io.c,v 1.6 2004/03/16 00:07:50 lethal Exp $
3 * Copyright (C) 2000 YAEGASHI Takeshi 2 * Copyright (C) 2000 YAEGASHI Takeshi
4 * Typical I/O routines for HD64461 system. 3 * Typical I/O routines for HD64461 system.
5 */ 4 */
6 5
7#include <asm/io.h> 6#include <asm/io.h>
8#include <asm/hd64461/hd64461.h> 7#include <asm/hd64461.h>
9 8
10#define MEM_BASE (CONFIG_HD64461_IOBASE - HD64461_STBCR) 9#define MEM_BASE (CONFIG_HD64461_IOBASE - HD64461_STBCR)
11 10
@@ -54,11 +53,6 @@ static __inline__ unsigned long PORT2ADDR(unsigned long port)
54 return 0xa0000000 + (port & 0x1fffffff); 53 return 0xa0000000 + (port & 0x1fffffff);
55} 54}
56 55
57static inline void delay(void)
58{
59 ctrl_inw(0xa0000000);
60}
61
62unsigned char hd64461_inb(unsigned long port) 56unsigned char hd64461_inb(unsigned long port)
63{ 57{
64 return *(volatile unsigned char*)PORT2ADDR(port); 58 return *(volatile unsigned char*)PORT2ADDR(port);
@@ -67,7 +61,7 @@ unsigned char hd64461_inb(unsigned long port)
67unsigned char hd64461_inb_p(unsigned long port) 61unsigned char hd64461_inb_p(unsigned long port)
68{ 62{
69 unsigned long v = *(volatile unsigned char*)PORT2ADDR(port); 63 unsigned long v = *(volatile unsigned char*)PORT2ADDR(port);
70 delay(); 64 ctrl_delay();
71 return v; 65 return v;
72} 66}
73 67
@@ -89,7 +83,7 @@ void hd64461_outb(unsigned char b, unsigned long port)
89void hd64461_outb_p(unsigned char b, unsigned long port) 83void hd64461_outb_p(unsigned char b, unsigned long port)
90{ 84{
91 *(volatile unsigned char*)PORT2ADDR(port) = b; 85 *(volatile unsigned char*)PORT2ADDR(port) = b;
92 delay(); 86 ctrl_delay();
93} 87}
94 88
95void hd64461_outw(unsigned short b, unsigned long port) 89void hd64461_outw(unsigned short b, unsigned long port)
@@ -144,13 +138,13 @@ void hd64461_outsl(unsigned long port, const void *buffer, unsigned long count)
144 while(count--) *addr=*buf++; 138 while(count--) *addr=*buf++;
145} 139}
146 140
147unsigned short hd64461_readw(unsigned long addr) 141unsigned short hd64461_readw(void __iomem *addr)
148{ 142{
149 return *(volatile unsigned short*)(MEM_BASE+addr); 143 return ctrl_inw(MEM_BASE+(unsigned long __force)addr);
150} 144}
151 145
152void hd64461_writew(unsigned short b, unsigned long addr) 146void hd64461_writew(unsigned short b, void __iomem *addr)
153{ 147{
154 *(volatile unsigned short*)(MEM_BASE+addr) = b; 148 ctrl_outw(b, MEM_BASE+(unsigned long __force)addr);
155} 149}
156 150
diff --git a/arch/sh/cchips/hd6446x/hd64461/setup.c b/arch/sh/cchips/hd6446x/hd64461/setup.c
index ad126016720f..38f1e8171a3a 100644
--- a/arch/sh/cchips/hd6446x/hd64461/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64461/setup.c
@@ -11,36 +11,28 @@
11#include <linux/interrupt.h> 11#include <linux/interrupt.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/irq.h> 13#include <linux/irq.h>
14
15#include <asm/io.h> 14#include <asm/io.h>
16#include <asm/irq.h> 15#include <asm/irq.h>
17 16#include <asm/hd64461.h>
18#include <asm/hd64461/hd64461.h>
19 17
20static void disable_hd64461_irq(unsigned int irq) 18static void disable_hd64461_irq(unsigned int irq)
21{ 19{
22 unsigned long flags;
23 unsigned short nimr; 20 unsigned short nimr;
24 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 21 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
25 22
26 local_irq_save(flags);
27 nimr = inw(HD64461_NIMR); 23 nimr = inw(HD64461_NIMR);
28 nimr |= mask; 24 nimr |= mask;
29 outw(nimr, HD64461_NIMR); 25 outw(nimr, HD64461_NIMR);
30 local_irq_restore(flags);
31} 26}
32 27
33static void enable_hd64461_irq(unsigned int irq) 28static void enable_hd64461_irq(unsigned int irq)
34{ 29{
35 unsigned long flags;
36 unsigned short nimr; 30 unsigned short nimr;
37 unsigned short mask = 1 << (irq - HD64461_IRQBASE); 31 unsigned short mask = 1 << (irq - HD64461_IRQBASE);
38 32
39 local_irq_save(flags);
40 nimr = inw(HD64461_NIMR); 33 nimr = inw(HD64461_NIMR);
41 nimr &= ~mask; 34 nimr &= ~mask;
42 outw(nimr, HD64461_NIMR); 35 outw(nimr, HD64461_NIMR);
43 local_irq_restore(flags);
44} 36}
45 37
46static void mask_and_ack_hd64461(unsigned int irq) 38static void mask_and_ack_hd64461(unsigned int irq)
diff --git a/arch/sh/cchips/hd6446x/hd64465/setup.c b/arch/sh/cchips/hd6446x/hd64465/setup.c
index d2b2851bc44b..30573d3e1966 100644
--- a/arch/sh/cchips/hd6446x/hd64465/setup.c
+++ b/arch/sh/cchips/hd6446x/hd64465/setup.c
@@ -25,31 +25,25 @@
25 25
26static void disable_hd64465_irq(unsigned int irq) 26static void disable_hd64465_irq(unsigned int irq)
27{ 27{
28 unsigned long flags;
29 unsigned short nimr; 28 unsigned short nimr;
30 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); 29 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
31 30
32 pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask); 31 pr_debug("disable_hd64465_irq(%d): mask=%x\n", irq, mask);
33 local_irq_save(flags);
34 nimr = inw(HD64465_REG_NIMR); 32 nimr = inw(HD64465_REG_NIMR);
35 nimr |= mask; 33 nimr |= mask;
36 outw(nimr, HD64465_REG_NIMR); 34 outw(nimr, HD64465_REG_NIMR);
37 local_irq_restore(flags);
38} 35}
39 36
40 37
41static void enable_hd64465_irq(unsigned int irq) 38static void enable_hd64465_irq(unsigned int irq)
42{ 39{
43 unsigned long flags;
44 unsigned short nimr; 40 unsigned short nimr;
45 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE); 41 unsigned short mask = 1 << (irq - HD64465_IRQ_BASE);
46 42
47 pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask); 43 pr_debug("enable_hd64465_irq(%d): mask=%x\n", irq, mask);
48 local_irq_save(flags);
49 nimr = inw(HD64465_REG_NIMR); 44 nimr = inw(HD64465_REG_NIMR);
50 nimr &= ~mask; 45 nimr &= ~mask;
51 outw(nimr, HD64465_REG_NIMR); 46 outw(nimr, HD64465_REG_NIMR);
52 local_irq_restore(flags);
53} 47}
54 48
55 49
diff --git a/arch/sh/cchips/voyagergx/irq.c b/arch/sh/cchips/voyagergx/irq.c
index 0dc1fb8f9687..392c8b12ce36 100644
--- a/arch/sh/cchips/voyagergx/irq.c
+++ b/arch/sh/cchips/voyagergx/irq.c
@@ -32,37 +32,30 @@
32 32
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/rts7751r2d/rts7751r2d.h> 35#include <asm/voyagergx.h>
36#include <asm/rts7751r2d/voyagergx_reg.h>
37 36
38static void disable_voyagergx_irq(unsigned int irq) 37static void disable_voyagergx_irq(unsigned int irq)
39{ 38{
40 unsigned long flags, val; 39 unsigned long val;
41 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE); 40 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
42 41
43 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask); 42 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
44 local_irq_save(flags);
45 val = inl(VOYAGER_INT_MASK); 43 val = inl(VOYAGER_INT_MASK);
46 val &= ~mask; 44 val &= ~mask;
47 outl(val, VOYAGER_INT_MASK); 45 outl(val, VOYAGER_INT_MASK);
48 local_irq_restore(flags);
49} 46}
50 47
51
52static void enable_voyagergx_irq(unsigned int irq) 48static void enable_voyagergx_irq(unsigned int irq)
53{ 49{
54 unsigned long flags, val; 50 unsigned long val;
55 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE); 51 unsigned long mask = 1 << (irq - VOYAGER_IRQ_BASE);
56 52
57 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask); 53 pr_debug("disable_voyagergx_irq(%d): mask=%x\n", irq, mask);
58 local_irq_save(flags);
59 val = inl(VOYAGER_INT_MASK); 54 val = inl(VOYAGER_INT_MASK);
60 val |= mask; 55 val |= mask;
61 outl(val, VOYAGER_INT_MASK); 56 outl(val, VOYAGER_INT_MASK);
62 local_irq_restore(flags);
63} 57}
64 58
65
66static void mask_and_ack_voyagergx(unsigned int irq) 59static void mask_and_ack_voyagergx(unsigned int irq)
67{ 60{
68 disable_voyagergx_irq(irq); 61 disable_voyagergx_irq(irq);
@@ -95,7 +88,8 @@ static struct hw_interrupt_type voyagergx_irq_type = {
95 .end = end_voyagergx_irq, 88 .end = end_voyagergx_irq,
96}; 89};
97 90
98static irqreturn_t voyagergx_interrupt(int irq, void *dev_id, struct pt_regs *regs) 91static irqreturn_t voyagergx_interrupt(int irq, void *dev_id,
92 struct pt_regs *regs)
99{ 93{
100 printk(KERN_INFO 94 printk(KERN_INFO
101 "VoyagerGX: spurious interrupt, status: 0x%x\n", 95 "VoyagerGX: spurious interrupt, status: 0x%x\n",
@@ -103,9 +97,6 @@ static irqreturn_t voyagergx_interrupt(int irq, void *dev_id, struct pt_regs *re
103 return IRQ_HANDLED; 97 return IRQ_HANDLED;
104} 98}
105 99
106
107/*====================================================*/
108
109static struct { 100static struct {
110 int (*func)(int, void *); 101 int (*func)(int, void *);
111 void *dev; 102 void *dev;
diff --git a/arch/sh/cchips/voyagergx/setup.c b/arch/sh/cchips/voyagergx/setup.c
index 139ca88ac9e6..66b2fedd7ad9 100644
--- a/arch/sh/cchips/voyagergx/setup.c
+++ b/arch/sh/cchips/voyagergx/setup.c
@@ -13,7 +13,7 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <asm/io.h> 15#include <asm/io.h>
16#include <asm/rts7751r2d/voyagergx_reg.h> 16#include <asm/voyagergx.h>
17 17
18static int __init setup_voyagergx(void) 18static int __init setup_voyagergx(void)
19{ 19{
diff --git a/arch/sh/configs/landisk_defconfig b/arch/sh/configs/landisk_defconfig
new file mode 100644
index 000000000000..6b43316d03cf
--- /dev/null
+++ b/arch/sh/configs/landisk_defconfig
@@ -0,0 +1,1373 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.13-sh
4# Sun Sep 11 13:00:46 2005
5#
6CONFIG_SUPERH=y
7CONFIG_UID16=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_HARDIRQS=y
10CONFIG_GENERIC_IRQ_PROBE=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y
12CONFIG_GENERIC_IOMAP=y
13
14#
15# Code maturity level options
16#
17CONFIG_EXPERIMENTAL=y
18CONFIG_CLEAN_COMPILE=y
19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
30# CONFIG_BSD_PROCESS_ACCT is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35# CONFIG_IKCONFIG is not set
36CONFIG_INITRAMFS_SOURCE=""
37# CONFIG_EMBEDDED is not set
38CONFIG_KALLSYMS=y
39CONFIG_KALLSYMS_EXTRA_PASS=y
40CONFIG_PRINTK=y
41CONFIG_BUG=y
42CONFIG_BASE_FULL=y
43CONFIG_FUTEX=y
44CONFIG_EPOLL=y
45CONFIG_SHMEM=y
46CONFIG_CC_ALIGN_FUNCTIONS=0
47CONFIG_CC_ALIGN_LABELS=0
48CONFIG_CC_ALIGN_LOOPS=0
49CONFIG_CC_ALIGN_JUMPS=0
50# CONFIG_TINY_SHMEM is not set
51CONFIG_BASE_SMALL=0
52
53#
54# Loadable module support
55#
56CONFIG_MODULES=y
57CONFIG_MODULE_UNLOAD=y
58CONFIG_MODULE_FORCE_UNLOAD=y
59CONFIG_OBSOLETE_MODPARM=y
60# CONFIG_MODVERSIONS is not set
61# CONFIG_MODULE_SRCVERSION_ALL is not set
62CONFIG_KMOD=y
63
64#
65# System type
66#
67# CONFIG_SH_SOLUTION_ENGINE is not set
68# CONFIG_SH_7751_SOLUTION_ENGINE is not set
69# CONFIG_SH_7300_SOLUTION_ENGINE is not set
70# CONFIG_SH_73180_SOLUTION_ENGINE is not set
71# CONFIG_SH_7751_SYSTEMH is not set
72# CONFIG_SH_STB1_HARP is not set
73# CONFIG_SH_STB1_OVERDRIVE is not set
74# CONFIG_SH_HP6XX is not set
75# CONFIG_SH_CQREEK is not set
76# CONFIG_SH_DMIDA is not set
77# CONFIG_SH_EC3104 is not set
78# CONFIG_SH_SATURN is not set
79# CONFIG_SH_DREAMCAST is not set
80# CONFIG_SH_CAT68701 is not set
81# CONFIG_SH_BIGSUR is not set
82# CONFIG_SH_SH2000 is not set
83# CONFIG_SH_ADX is not set
84# CONFIG_SH_MPC1211 is not set
85# CONFIG_SH_SH03 is not set
86# CONFIG_SH_SECUREEDGE5410 is not set
87# CONFIG_SH_HS7751RVOIP is not set
88# CONFIG_SH_RTS7751R2D is not set
89# CONFIG_SH_EDOSK7705 is not set
90# CONFIG_SH_SH4202_MICRODEV is not set
91CONFIG_SH_LANDISK=y
92# CONFIG_SH_TITAN is not set
93# CONFIG_SH_UNKNOWN is not set
94
95#
96# Processor selection
97#
98CONFIG_CPU_SH4=y
99
100#
101# SH-2 Processor Support
102#
103# CONFIG_CPU_SUBTYPE_SH7604 is not set
104
105#
106# SH-3 Processor Support
107#
108# CONFIG_CPU_SUBTYPE_SH7300 is not set
109# CONFIG_CPU_SUBTYPE_SH7705 is not set
110# CONFIG_CPU_SUBTYPE_SH7707 is not set
111# CONFIG_CPU_SUBTYPE_SH7708 is not set
112# CONFIG_CPU_SUBTYPE_SH7709 is not set
113
114#
115# SH-4 Processor Support
116#
117# CONFIG_CPU_SUBTYPE_SH7750 is not set
118# CONFIG_CPU_SUBTYPE_SH7091 is not set
119# CONFIG_CPU_SUBTYPE_SH7750R is not set
120# CONFIG_CPU_SUBTYPE_SH7750S is not set
121CONFIG_CPU_SUBTYPE_SH7751=y
122CONFIG_CPU_SUBTYPE_SH7751R=y
123# CONFIG_CPU_SUBTYPE_SH7760 is not set
124# CONFIG_CPU_SUBTYPE_SH4_202 is not set
125
126#
127# ST40 Processor Support
128#
129# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
130# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
131
132#
133# SH-4A Processor Support
134#
135# CONFIG_CPU_SUBTYPE_SH73180 is not set
136# CONFIG_CPU_SUBTYPE_SH7770 is not set
137# CONFIG_CPU_SUBTYPE_SH7780 is not set
138
139#
140# Memory management options
141#
142CONFIG_MMU=y
143CONFIG_SELECT_MEMORY_MODEL=y
144CONFIG_FLATMEM_MANUAL=y
145# CONFIG_DISCONTIGMEM_MANUAL is not set
146# CONFIG_SPARSEMEM_MANUAL is not set
147CONFIG_FLATMEM=y
148CONFIG_FLAT_NODE_MEM_MAP=y
149# CONFIG_SPARSEMEM_STATIC is not set
150
151#
152# Cache configuration
153#
154# CONFIG_SH_DIRECT_MAPPED is not set
155# CONFIG_SH_WRITETHROUGH is not set
156# CONFIG_SH_OCRAM is not set
157CONFIG_MEMORY_START=0x0c000000
158CONFIG_MEMORY_SIZE=0x04000000
159
160#
161# Processor features
162#
163CONFIG_CPU_LITTLE_ENDIAN=y
164CONFIG_SH_FPU=y
165# CONFIG_SH_STORE_QUEUES is not set
166
167#
168# Timer support
169#
170CONFIG_SH_TMU=y
171CONFIG_SH_PCLK_FREQ_BOOL=y
172CONFIG_SH_PCLK_FREQ=33333333
173
174#
175# CPU Frequency scaling
176#
177# CONFIG_CPU_FREQ is not set
178
179#
180# DMA support
181#
182CONFIG_SH_DMA=y
183CONFIG_NR_ONCHIP_DMA_CHANNELS=4
184# CONFIG_NR_DMA_CHANNELS_BOOL is not set
185
186#
187# Companion Chips
188#
189# CONFIG_HD6446X_SERIES is not set
190CONFIG_HEARTBEAT=y
191
192#
193# Kernel features
194#
195CONFIG_KEXEC=y
196# CONFIG_PREEMPT is not set
197# CONFIG_SMP is not set
198
199#
200# Boot options
201#
202CONFIG_ZERO_PAGE_OFFSET=0x00001000
203CONFIG_BOOT_LINK_OFFSET=0x00800000
204# CONFIG_UBC_WAKEUP is not set
205# CONFIG_CMDLINE_BOOL is not set
206
207#
208# Bus options
209#
210CONFIG_ISA=y
211CONFIG_PCI=y
212CONFIG_SH_PCIDMA_NONCOHERENT=y
213CONFIG_PCI_AUTO=y
214CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
215CONFIG_PCI_LEGACY_PROC=y
216
217#
218# PCCARD (PCMCIA/CardBus) support
219#
220CONFIG_PCCARD=y
221# CONFIG_PCMCIA_DEBUG is not set
222CONFIG_PCMCIA=y
223CONFIG_PCMCIA_LOAD_CIS=y
224CONFIG_PCMCIA_IOCTL=y
225CONFIG_CARDBUS=y
226
227#
228# PC-card bridges
229#
230CONFIG_YENTA=y
231# CONFIG_PD6729 is not set
232# CONFIG_I82092 is not set
233# CONFIG_I82365 is not set
234# CONFIG_TCIC is not set
235CONFIG_PCMCIA_PROBE=y
236CONFIG_PCCARD_NONSTATIC=y
237
238#
239# PCI Hotplug Support
240#
241# CONFIG_HOTPLUG_PCI is not set
242
243#
244# Executable file formats
245#
246CONFIG_BINFMT_ELF=y
247# CONFIG_BINFMT_FLAT is not set
248# CONFIG_BINFMT_MISC is not set
249
250#
251# Networking
252#
253CONFIG_NET=y
254
255#
256# Networking options
257#
258CONFIG_PACKET=y
259# CONFIG_PACKET_MMAP is not set
260CONFIG_UNIX=y
261# CONFIG_NET_KEY is not set
262CONFIG_INET=y
263# CONFIG_IP_MULTICAST is not set
264CONFIG_IP_ADVANCED_ROUTER=y
265CONFIG_ASK_IP_FIB_HASH=y
266# CONFIG_IP_FIB_TRIE is not set
267CONFIG_IP_FIB_HASH=y
268# CONFIG_IP_MULTIPLE_TABLES is not set
269# CONFIG_IP_ROUTE_MULTIPATH is not set
270# CONFIG_IP_ROUTE_VERBOSE is not set
271CONFIG_IP_PNP=y
272# CONFIG_IP_PNP_DHCP is not set
273# CONFIG_IP_PNP_BOOTP is not set
274# CONFIG_IP_PNP_RARP is not set
275# CONFIG_NET_IPIP is not set
276# CONFIG_NET_IPGRE is not set
277# CONFIG_ARPD is not set
278# CONFIG_SYN_COOKIES is not set
279# CONFIG_INET_AH is not set
280# CONFIG_INET_ESP is not set
281# CONFIG_INET_IPCOMP is not set
282# CONFIG_INET_TUNNEL is not set
283CONFIG_INET_DIAG=y
284CONFIG_INET_TCP_DIAG=y
285# CONFIG_TCP_CONG_ADVANCED is not set
286CONFIG_TCP_CONG_BIC=y
287
288#
289# IP: Virtual Server Configuration
290#
291# CONFIG_IP_VS is not set
292# CONFIG_IPV6 is not set
293CONFIG_NETFILTER=y
294# CONFIG_NETFILTER_DEBUG is not set
295# CONFIG_NETFILTER_NETLINK is not set
296
297#
298# IP: Netfilter Configuration
299#
300CONFIG_IP_NF_CONNTRACK=m
301CONFIG_IP_NF_CT_ACCT=y
302CONFIG_IP_NF_CONNTRACK_MARK=y
303# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
304# CONFIG_IP_NF_CT_PROTO_SCTP is not set
305CONFIG_IP_NF_FTP=m
306CONFIG_IP_NF_IRC=m
307# CONFIG_IP_NF_NETBIOS_NS is not set
308CONFIG_IP_NF_TFTP=m
309CONFIG_IP_NF_AMANDA=m
310# CONFIG_IP_NF_PPTP is not set
311CONFIG_IP_NF_QUEUE=m
312CONFIG_IP_NF_IPTABLES=m
313CONFIG_IP_NF_MATCH_LIMIT=m
314CONFIG_IP_NF_MATCH_IPRANGE=m
315CONFIG_IP_NF_MATCH_MAC=m
316CONFIG_IP_NF_MATCH_PKTTYPE=m
317CONFIG_IP_NF_MATCH_MARK=m
318CONFIG_IP_NF_MATCH_MULTIPORT=m
319CONFIG_IP_NF_MATCH_TOS=m
320CONFIG_IP_NF_MATCH_RECENT=m
321CONFIG_IP_NF_MATCH_ECN=m
322CONFIG_IP_NF_MATCH_DSCP=m
323CONFIG_IP_NF_MATCH_AH_ESP=m
324CONFIG_IP_NF_MATCH_LENGTH=m
325CONFIG_IP_NF_MATCH_TTL=m
326CONFIG_IP_NF_MATCH_TCPMSS=m
327CONFIG_IP_NF_MATCH_HELPER=m
328CONFIG_IP_NF_MATCH_STATE=m
329CONFIG_IP_NF_MATCH_CONNTRACK=m
330CONFIG_IP_NF_MATCH_OWNER=m
331CONFIG_IP_NF_MATCH_ADDRTYPE=m
332CONFIG_IP_NF_MATCH_REALM=m
333CONFIG_IP_NF_MATCH_SCTP=m
334# CONFIG_IP_NF_MATCH_DCCP is not set
335CONFIG_IP_NF_MATCH_COMMENT=m
336CONFIG_IP_NF_MATCH_CONNMARK=m
337# CONFIG_IP_NF_MATCH_CONNBYTES is not set
338CONFIG_IP_NF_MATCH_HASHLIMIT=m
339# CONFIG_IP_NF_MATCH_STRING is not set
340CONFIG_IP_NF_FILTER=m
341CONFIG_IP_NF_TARGET_REJECT=m
342CONFIG_IP_NF_TARGET_LOG=m
343CONFIG_IP_NF_TARGET_ULOG=m
344CONFIG_IP_NF_TARGET_TCPMSS=m
345# CONFIG_IP_NF_TARGET_NFQUEUE is not set
346CONFIG_IP_NF_NAT=m
347CONFIG_IP_NF_NAT_NEEDED=y
348CONFIG_IP_NF_TARGET_MASQUERADE=m
349CONFIG_IP_NF_TARGET_REDIRECT=m
350CONFIG_IP_NF_TARGET_NETMAP=m
351CONFIG_IP_NF_TARGET_SAME=m
352# CONFIG_IP_NF_NAT_SNMP_BASIC is not set
353CONFIG_IP_NF_NAT_IRC=m
354CONFIG_IP_NF_NAT_FTP=m
355CONFIG_IP_NF_NAT_TFTP=m
356CONFIG_IP_NF_NAT_AMANDA=m
357CONFIG_IP_NF_MANGLE=m
358CONFIG_IP_NF_TARGET_TOS=m
359CONFIG_IP_NF_TARGET_ECN=m
360CONFIG_IP_NF_TARGET_DSCP=m
361CONFIG_IP_NF_TARGET_MARK=m
362CONFIG_IP_NF_TARGET_CLASSIFY=m
363# CONFIG_IP_NF_TARGET_TTL is not set
364CONFIG_IP_NF_TARGET_CONNMARK=m
365# CONFIG_IP_NF_TARGET_CLUSTERIP is not set
366CONFIG_IP_NF_RAW=m
367CONFIG_IP_NF_TARGET_NOTRACK=m
368CONFIG_IP_NF_ARPTABLES=m
369CONFIG_IP_NF_ARPFILTER=m
370CONFIG_IP_NF_ARP_MANGLE=m
371
372#
373# DCCP Configuration (EXPERIMENTAL)
374#
375# CONFIG_IP_DCCP is not set
376
377#
378# SCTP Configuration (EXPERIMENTAL)
379#
380# CONFIG_IP_SCTP is not set
381# CONFIG_ATM is not set
382# CONFIG_BRIDGE is not set
383# CONFIG_VLAN_8021Q is not set
384# CONFIG_DECNET is not set
385CONFIG_LLC=m
386# CONFIG_LLC2 is not set
387# CONFIG_IPX is not set
388CONFIG_ATALK=m
389# CONFIG_DEV_APPLETALK is not set
390# CONFIG_X25 is not set
391# CONFIG_LAPB is not set
392# CONFIG_NET_DIVERT is not set
393# CONFIG_ECONET is not set
394# CONFIG_WAN_ROUTER is not set
395# CONFIG_NET_SCHED is not set
396CONFIG_NET_CLS_ROUTE=y
397
398#
399# Network testing
400#
401# CONFIG_NET_PKTGEN is not set
402# CONFIG_HAMRADIO is not set
403# CONFIG_IRDA is not set
404# CONFIG_BT is not set
405# CONFIG_IEEE80211 is not set
406
407#
408# Device Drivers
409#
410
411#
412# Generic Driver Options
413#
414CONFIG_STANDALONE=y
415CONFIG_PREVENT_FIRMWARE_BUILD=y
416CONFIG_FW_LOADER=y
417
418#
419# Connector - unified userspace <-> kernelspace linker
420#
421# CONFIG_CONNECTOR is not set
422
423#
424# Memory Technology Devices (MTD)
425#
426# CONFIG_MTD is not set
427
428#
429# Parallel port support
430#
431# CONFIG_PARPORT is not set
432
433#
434# Plug and Play support
435#
436# CONFIG_PNP is not set
437
438#
439# Block devices
440#
441# CONFIG_BLK_CPQ_DA is not set
442# CONFIG_BLK_CPQ_CISS_DA is not set
443# CONFIG_BLK_DEV_DAC960 is not set
444# CONFIG_BLK_DEV_UMEM is not set
445# CONFIG_BLK_DEV_COW_COMMON is not set
446CONFIG_BLK_DEV_LOOP=y
447# CONFIG_BLK_DEV_CRYPTOLOOP is not set
448# CONFIG_BLK_DEV_NBD is not set
449# CONFIG_BLK_DEV_SX8 is not set
450# CONFIG_BLK_DEV_UB is not set
451CONFIG_BLK_DEV_RAM=y
452CONFIG_BLK_DEV_RAM_COUNT=16
453CONFIG_BLK_DEV_RAM_SIZE=4096
454# CONFIG_BLK_DEV_INITRD is not set
455# CONFIG_LBD is not set
456# CONFIG_CDROM_PKTCDVD is not set
457
458#
459# IO Schedulers
460#
461CONFIG_IOSCHED_NOOP=y
462CONFIG_IOSCHED_AS=y
463CONFIG_IOSCHED_DEADLINE=y
464CONFIG_IOSCHED_CFQ=y
465# CONFIG_ATA_OVER_ETH is not set
466
467#
468# ATA/ATAPI/MFM/RLL support
469#
470CONFIG_IDE=y
471CONFIG_IDE_MAX_HWIFS=4
472CONFIG_BLK_DEV_IDE=y
473
474#
475# Please see Documentation/ide.txt for help/info on IDE drives
476#
477# CONFIG_BLK_DEV_IDE_SATA is not set
478CONFIG_BLK_DEV_IDEDISK=y
479# CONFIG_IDEDISK_MULTI_MODE is not set
480# CONFIG_BLK_DEV_IDECS is not set
481CONFIG_BLK_DEV_IDECD=y
482# CONFIG_BLK_DEV_IDETAPE is not set
483# CONFIG_BLK_DEV_IDEFLOPPY is not set
484CONFIG_BLK_DEV_IDESCSI=y
485# CONFIG_IDE_TASK_IOCTL is not set
486
487#
488# IDE chipset support/bugfixes
489#
490CONFIG_IDE_GENERIC=y
491CONFIG_BLK_DEV_IDEPCI=y
492CONFIG_IDEPCI_SHARE_IRQ=y
493CONFIG_BLK_DEV_OFFBOARD=y
494CONFIG_BLK_DEV_GENERIC=y
495# CONFIG_BLK_DEV_OPTI621 is not set
496CONFIG_BLK_DEV_IDEDMA_PCI=y
497# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
498CONFIG_IDEDMA_PCI_AUTO=y
499CONFIG_IDEDMA_ONLYDISK=y
500CONFIG_BLK_DEV_AEC62XX=y
501# CONFIG_BLK_DEV_ALI15X3 is not set
502# CONFIG_BLK_DEV_AMD74XX is not set
503# CONFIG_BLK_DEV_CMD64X is not set
504# CONFIG_BLK_DEV_TRIFLEX is not set
505# CONFIG_BLK_DEV_CY82C693 is not set
506# CONFIG_BLK_DEV_CS5520 is not set
507# CONFIG_BLK_DEV_CS5530 is not set
508# CONFIG_BLK_DEV_HPT34X is not set
509# CONFIG_BLK_DEV_HPT366 is not set
510# CONFIG_BLK_DEV_SC1200 is not set
511# CONFIG_BLK_DEV_PIIX is not set
512# CONFIG_BLK_DEV_IT821X is not set
513# CONFIG_BLK_DEV_NS87415 is not set
514# CONFIG_BLK_DEV_PDC202XX_OLD is not set
515# CONFIG_BLK_DEV_PDC202XX_NEW is not set
516# CONFIG_BLK_DEV_SVWKS is not set
517# CONFIG_BLK_DEV_SIIMAGE is not set
518# CONFIG_BLK_DEV_SLC90E66 is not set
519# CONFIG_BLK_DEV_TRM290 is not set
520# CONFIG_BLK_DEV_VIA82CXXX is not set
521CONFIG_IDE_SH=y
522# CONFIG_IDE_ARM is not set
523# CONFIG_IDE_CHIPSETS is not set
524CONFIG_BLK_DEV_IDEDMA=y
525# CONFIG_IDEDMA_IVB is not set
526CONFIG_IDEDMA_AUTO=y
527# CONFIG_BLK_DEV_HD is not set
528
529#
530# SCSI device support
531#
532# CONFIG_RAID_ATTRS is not set
533CONFIG_SCSI=y
534CONFIG_SCSI_PROC_FS=y
535
536#
537# SCSI support type (disk, tape, CD-ROM)
538#
539CONFIG_BLK_DEV_SD=y
540# CONFIG_CHR_DEV_ST is not set
541# CONFIG_CHR_DEV_OSST is not set
542# CONFIG_BLK_DEV_SR is not set
543# CONFIG_CHR_DEV_SG is not set
544# CONFIG_CHR_DEV_SCH is not set
545
546#
547# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
548#
549CONFIG_SCSI_MULTI_LUN=y
550# CONFIG_SCSI_CONSTANTS is not set
551# CONFIG_SCSI_LOGGING is not set
552
553#
554# SCSI Transport Attributes
555#
556# CONFIG_SCSI_SPI_ATTRS is not set
557# CONFIG_SCSI_FC_ATTRS is not set
558# CONFIG_SCSI_ISCSI_ATTRS is not set
559# CONFIG_SCSI_SAS_ATTRS is not set
560
561#
562# SCSI low-level drivers
563#
564# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
565# CONFIG_SCSI_3W_9XXX is not set
566# CONFIG_SCSI_ACARD is not set
567# CONFIG_SCSI_AHA152X is not set
568# CONFIG_SCSI_AACRAID is not set
569# CONFIG_SCSI_AIC7XXX is not set
570# CONFIG_SCSI_AIC7XXX_OLD is not set
571# CONFIG_SCSI_AIC79XX is not set
572# CONFIG_SCSI_DPT_I2O is not set
573# CONFIG_SCSI_IN2000 is not set
574# CONFIG_MEGARAID_NEWGEN is not set
575# CONFIG_MEGARAID_LEGACY is not set
576# CONFIG_MEGARAID_SAS is not set
577# CONFIG_SCSI_SATA is not set
578# CONFIG_SCSI_DMX3191D is not set
579# CONFIG_SCSI_DTC3280 is not set
580# CONFIG_SCSI_FUTURE_DOMAIN is not set
581# CONFIG_SCSI_GENERIC_NCR5380 is not set
582# CONFIG_SCSI_GENERIC_NCR5380_MMIO is not set
583# CONFIG_SCSI_IPS is not set
584# CONFIG_SCSI_INITIO is not set
585# CONFIG_SCSI_INIA100 is not set
586# CONFIG_SCSI_NCR53C406A is not set
587# CONFIG_SCSI_SYM53C8XX_2 is not set
588# CONFIG_SCSI_IPR is not set
589# CONFIG_SCSI_PAS16 is not set
590# CONFIG_SCSI_PSI240I is not set
591# CONFIG_SCSI_QLOGIC_FAS is not set
592# CONFIG_SCSI_QLOGIC_FC is not set
593# CONFIG_SCSI_QLOGIC_1280 is not set
594CONFIG_SCSI_QLA2XXX=y
595# CONFIG_SCSI_QLA21XX is not set
596# CONFIG_SCSI_QLA22XX is not set
597# CONFIG_SCSI_QLA2300 is not set
598# CONFIG_SCSI_QLA2322 is not set
599# CONFIG_SCSI_QLA6312 is not set
600# CONFIG_SCSI_QLA24XX is not set
601# CONFIG_SCSI_LPFC is not set
602# CONFIG_SCSI_SYM53C416 is not set
603# CONFIG_SCSI_DC395x is not set
604# CONFIG_SCSI_DC390T is not set
605# CONFIG_SCSI_T128 is not set
606# CONFIG_SCSI_NSP32 is not set
607# CONFIG_SCSI_DEBUG is not set
608
609#
610# PCMCIA SCSI adapter support
611#
612# CONFIG_PCMCIA_AHA152X is not set
613# CONFIG_PCMCIA_FDOMAIN is not set
614# CONFIG_PCMCIA_NINJA_SCSI is not set
615# CONFIG_PCMCIA_QLOGIC is not set
616# CONFIG_PCMCIA_SYM53C500 is not set
617
618#
619# Old CD-ROM drivers (not SCSI, not IDE)
620#
621# CONFIG_CD_NO_IDESCSI is not set
622
623#
624# Multi-device support (RAID and LVM)
625#
626CONFIG_MD=y
627CONFIG_BLK_DEV_MD=m
628CONFIG_MD_LINEAR=m
629CONFIG_MD_RAID0=m
630CONFIG_MD_RAID1=m
631# CONFIG_MD_RAID10 is not set
632# CONFIG_MD_RAID5 is not set
633# CONFIG_MD_RAID6 is not set
634# CONFIG_MD_MULTIPATH is not set
635# CONFIG_MD_FAULTY is not set
636# CONFIG_BLK_DEV_DM is not set
637
638#
639# Fusion MPT device support
640#
641# CONFIG_FUSION is not set
642# CONFIG_FUSION_SPI is not set
643# CONFIG_FUSION_FC is not set
644# CONFIG_FUSION_SAS is not set
645
646#
647# IEEE 1394 (FireWire) support
648#
649# CONFIG_IEEE1394 is not set
650
651#
652# I2O device support
653#
654# CONFIG_I2O is not set
655
656#
657# Network device support
658#
659CONFIG_NETDEVICES=y
660# CONFIG_DUMMY is not set
661# CONFIG_BONDING is not set
662# CONFIG_EQUALIZER is not set
663CONFIG_TUN=m
664
665#
666# ARCnet devices
667#
668# CONFIG_ARCNET is not set
669
670#
671# PHY device support
672#
673# CONFIG_PHYLIB is not set
674
675#
676# Ethernet (10 or 100Mbit)
677#
678CONFIG_NET_ETHERNET=y
679CONFIG_MII=y
680# CONFIG_STNIC is not set
681# CONFIG_HAPPYMEAL is not set
682# CONFIG_SUNGEM is not set
683# CONFIG_CASSINI is not set
684# CONFIG_NET_VENDOR_3COM is not set
685# CONFIG_NET_VENDOR_SMC is not set
686# CONFIG_SMC91X is not set
687# CONFIG_NET_VENDOR_RACAL is not set
688
689#
690# Tulip family network device support
691#
692# CONFIG_NET_TULIP is not set
693# CONFIG_AT1700 is not set
694# CONFIG_DEPCA is not set
695# CONFIG_HP100 is not set
696# CONFIG_NET_ISA is not set
697# CONFIG_NE2000 is not set
698CONFIG_NET_PCI=y
699# CONFIG_PCNET32 is not set
700# CONFIG_AMD8111_ETH is not set
701# CONFIG_ADAPTEC_STARFIRE is not set
702# CONFIG_AC3200 is not set
703# CONFIG_APRICOT is not set
704# CONFIG_B44 is not set
705# CONFIG_FORCEDETH is not set
706# CONFIG_CS89x0 is not set
707# CONFIG_DGRS is not set
708# CONFIG_EEPRO100 is not set
709# CONFIG_E100 is not set
710# CONFIG_FEALNX is not set
711# CONFIG_NATSEMI is not set
712# CONFIG_NE2K_PCI is not set
713CONFIG_8139CP=y
714# CONFIG_8139TOO is not set
715# CONFIG_SIS900 is not set
716# CONFIG_EPIC100 is not set
717# CONFIG_SUNDANCE is not set
718# CONFIG_TLAN is not set
719# CONFIG_VIA_RHINE is not set
720
721#
722# Ethernet (1000 Mbit)
723#
724# CONFIG_ACENIC is not set
725# CONFIG_DL2K is not set
726# CONFIG_E1000 is not set
727# CONFIG_NS83820 is not set
728# CONFIG_HAMACHI is not set
729# CONFIG_YELLOWFIN is not set
730# CONFIG_R8169 is not set
731# CONFIG_SIS190 is not set
732# CONFIG_SKGE is not set
733# CONFIG_SK98LIN is not set
734# CONFIG_VIA_VELOCITY is not set
735# CONFIG_TIGON3 is not set
736# CONFIG_BNX2 is not set
737
738#
739# Ethernet (10000 Mbit)
740#
741# CONFIG_CHELSIO_T1 is not set
742# CONFIG_IXGB is not set
743# CONFIG_S2IO is not set
744
745#
746# Token Ring devices
747#
748# CONFIG_TR is not set
749
750#
751# Wireless LAN (non-hamradio)
752#
753# CONFIG_NET_RADIO is not set
754
755#
756# PCMCIA network device support
757#
758# CONFIG_NET_PCMCIA is not set
759
760#
761# Wan interfaces
762#
763# CONFIG_WAN is not set
764# CONFIG_FDDI is not set
765# CONFIG_HIPPI is not set
766# CONFIG_PPP is not set
767# CONFIG_SLIP is not set
768# CONFIG_NET_FC is not set
769# CONFIG_SHAPER is not set
770# CONFIG_NETCONSOLE is not set
771# CONFIG_NETPOLL is not set
772# CONFIG_NET_POLL_CONTROLLER is not set
773
774#
775# ISDN subsystem
776#
777# CONFIG_ISDN is not set
778
779#
780# Telephony Support
781#
782# CONFIG_PHONE is not set
783
784#
785# Input device support
786#
787CONFIG_INPUT=y
788
789#
790# Userland interfaces
791#
792CONFIG_INPUT_MOUSEDEV=y
793# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
794CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
795CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
796# CONFIG_INPUT_JOYDEV is not set
797# CONFIG_INPUT_TSDEV is not set
798# CONFIG_INPUT_EVDEV is not set
799# CONFIG_INPUT_EVBUG is not set
800
801#
802# Input Device Drivers
803#
804# CONFIG_INPUT_KEYBOARD is not set
805# CONFIG_INPUT_MOUSE is not set
806# CONFIG_INPUT_JOYSTICK is not set
807# CONFIG_INPUT_TOUCHSCREEN is not set
808# CONFIG_INPUT_MISC is not set
809
810#
811# Hardware I/O ports
812#
813# CONFIG_SERIO is not set
814# CONFIG_GAMEPORT is not set
815
816#
817# Character devices
818#
819CONFIG_VT=y
820CONFIG_VT_CONSOLE=y
821CONFIG_HW_CONSOLE=y
822# CONFIG_SERIAL_NONSTANDARD is not set
823
824#
825# Serial drivers
826#
827# CONFIG_SERIAL_8250 is not set
828
829#
830# Non-8250 serial port support
831#
832CONFIG_SERIAL_SH_SCI=y
833CONFIG_SERIAL_SH_SCI_CONSOLE=y
834CONFIG_SERIAL_CORE=y
835CONFIG_SERIAL_CORE_CONSOLE=y
836# CONFIG_SERIAL_JSM is not set
837CONFIG_UNIX98_PTYS=y
838CONFIG_LEGACY_PTYS=y
839CONFIG_LEGACY_PTY_COUNT=256
840
841#
842# IPMI
843#
844# CONFIG_IPMI_HANDLER is not set
845
846#
847# Watchdog Cards
848#
849# CONFIG_WATCHDOG is not set
850# CONFIG_RTC is not set
851CONFIG_RS5C313_RTC=y
852# CONFIG_GEN_RTC is not set
853# CONFIG_DTLK is not set
854# CONFIG_R3964 is not set
855# CONFIG_APPLICOM is not set
856
857#
858# Ftape, the floppy tape device driver
859#
860# CONFIG_DRM is not set
861
862#
863# PCMCIA character devices
864#
865# CONFIG_SYNCLINK_CS is not set
866# CONFIG_RAW_DRIVER is not set
867
868#
869# TPM devices
870#
871# CONFIG_TCG_TPM is not set
872
873#
874# I2C support
875#
876# CONFIG_I2C is not set
877
878#
879# Dallas's 1-wire bus
880#
881# CONFIG_W1 is not set
882
883#
884# Hardware Monitoring support
885#
886CONFIG_HWMON=y
887# CONFIG_HWMON_VID is not set
888# CONFIG_HWMON_DEBUG_CHIP is not set
889
890#
891# Misc devices
892#
893
894#
895# Multimedia Capabilities Port drivers
896#
897
898#
899# Multimedia devices
900#
901CONFIG_VIDEO_DEV=m
902
903#
904# Video For Linux
905#
906
907#
908# Video Adapters
909#
910# CONFIG_VIDEO_PMS is not set
911# CONFIG_VIDEO_CPIA is not set
912# CONFIG_VIDEO_STRADIS is not set
913# CONFIG_VIDEO_MXB is not set
914# CONFIG_VIDEO_DPC is not set
915# CONFIG_VIDEO_HEXIUM_ORION is not set
916# CONFIG_VIDEO_HEXIUM_GEMINI is not set
917
918#
919# Radio Adapters
920#
921# CONFIG_RADIO_CADET is not set
922# CONFIG_RADIO_RTRACK is not set
923# CONFIG_RADIO_RTRACK2 is not set
924# CONFIG_RADIO_AZTECH is not set
925# CONFIG_RADIO_GEMTEK is not set
926# CONFIG_RADIO_GEMTEK_PCI is not set
927# CONFIG_RADIO_MAXIRADIO is not set
928# CONFIG_RADIO_MAESTRO is not set
929# CONFIG_RADIO_SF16FMI is not set
930# CONFIG_RADIO_SF16FMR2 is not set
931# CONFIG_RADIO_TERRATEC is not set
932# CONFIG_RADIO_TRUST is not set
933# CONFIG_RADIO_TYPHOON is not set
934# CONFIG_RADIO_ZOLTRIX is not set
935
936#
937# Digital Video Broadcasting Devices
938#
939# CONFIG_DVB is not set
940
941#
942# Graphics support
943#
944# CONFIG_FB is not set
945
946#
947# Console display driver support
948#
949# CONFIG_MDA_CONSOLE is not set
950CONFIG_DUMMY_CONSOLE=y
951CONFIG_FONT_8x16=y
952
953#
954# Sound
955#
956CONFIG_SOUND=m
957
958#
959# Advanced Linux Sound Architecture
960#
961# CONFIG_SND is not set
962
963#
964# Open Sound System
965#
966CONFIG_SOUND_PRIME=m
967# CONFIG_SOUND_BT878 is not set
968# CONFIG_SOUND_CMPCI is not set
969# CONFIG_SOUND_EMU10K1 is not set
970# CONFIG_SOUND_FUSION is not set
971# CONFIG_SOUND_CS4281 is not set
972# CONFIG_SOUND_ES1370 is not set
973# CONFIG_SOUND_ES1371 is not set
974# CONFIG_SOUND_ESSSOLO1 is not set
975# CONFIG_SOUND_MAESTRO is not set
976# CONFIG_SOUND_MAESTRO3 is not set
977# CONFIG_SOUND_ICH is not set
978# CONFIG_SOUND_SONICVIBES is not set
979# CONFIG_SOUND_TRIDENT is not set
980# CONFIG_SOUND_MSNDCLAS is not set
981# CONFIG_SOUND_MSNDPIN is not set
982# CONFIG_SOUND_VIA82CXXX is not set
983# CONFIG_SOUND_ALI5455 is not set
984# CONFIG_SOUND_FORTE is not set
985# CONFIG_SOUND_RME96XX is not set
986# CONFIG_SOUND_AD1980 is not set
987
988#
989# USB support
990#
991CONFIG_USB_ARCH_HAS_HCD=y
992CONFIG_USB_ARCH_HAS_OHCI=y
993CONFIG_USB=y
994# CONFIG_USB_DEBUG is not set
995
996#
997# Miscellaneous USB options
998#
999CONFIG_USB_DEVICEFS=y
1000# CONFIG_USB_BANDWIDTH is not set
1001# CONFIG_USB_DYNAMIC_MINORS is not set
1002# CONFIG_USB_OTG is not set
1003
1004#
1005# USB Host Controller Drivers
1006#
1007CONFIG_USB_EHCI_HCD=y
1008# CONFIG_USB_EHCI_SPLIT_ISO is not set
1009# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1010# CONFIG_USB_ISP116X_HCD is not set
1011CONFIG_USB_OHCI_HCD=y
1012# CONFIG_USB_OHCI_BIG_ENDIAN is not set
1013CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1014# CONFIG_USB_UHCI_HCD is not set
1015# CONFIG_USB_SL811_HCD is not set
1016
1017#
1018# USB Device Class drivers
1019#
1020CONFIG_OBSOLETE_OSS_USB_DRIVER=y
1021CONFIG_USB_AUDIO=m
1022# CONFIG_USB_BLUETOOTH_TTY is not set
1023CONFIG_USB_MIDI=m
1024# CONFIG_USB_ACM is not set
1025CONFIG_USB_PRINTER=m
1026
1027#
1028# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
1029#
1030CONFIG_USB_STORAGE=m
1031# CONFIG_USB_STORAGE_DEBUG is not set
1032CONFIG_USB_STORAGE_DATAFAB=y
1033CONFIG_USB_STORAGE_FREECOM=y
1034CONFIG_USB_STORAGE_ISD200=y
1035CONFIG_USB_STORAGE_DPCM=y
1036# CONFIG_USB_STORAGE_USBAT is not set
1037CONFIG_USB_STORAGE_SDDR09=y
1038CONFIG_USB_STORAGE_SDDR55=y
1039CONFIG_USB_STORAGE_JUMPSHOT=y
1040
1041#
1042# USB Input Devices
1043#
1044CONFIG_USB_HID=m
1045CONFIG_USB_HIDINPUT=y
1046# CONFIG_HID_FF is not set
1047# CONFIG_USB_HIDDEV is not set
1048
1049#
1050# USB HID Boot Protocol drivers
1051#
1052# CONFIG_USB_KBD is not set
1053# CONFIG_USB_MOUSE is not set
1054# CONFIG_USB_AIPTEK is not set
1055# CONFIG_USB_WACOM is not set
1056# CONFIG_USB_ACECAD is not set
1057# CONFIG_USB_KBTAB is not set
1058# CONFIG_USB_POWERMATE is not set
1059# CONFIG_USB_MTOUCH is not set
1060# CONFIG_USB_ITMTOUCH is not set
1061# CONFIG_USB_EGALAX is not set
1062# CONFIG_USB_YEALINK is not set
1063# CONFIG_USB_XPAD is not set
1064# CONFIG_USB_ATI_REMOTE is not set
1065# CONFIG_USB_KEYSPAN_REMOTE is not set
1066# CONFIG_USB_APPLETOUCH is not set
1067
1068#
1069# USB Imaging devices
1070#
1071# CONFIG_USB_MDC800 is not set
1072# CONFIG_USB_MICROTEK is not set
1073
1074#
1075# USB Multimedia devices
1076#
1077CONFIG_USB_DABUSB=m
1078CONFIG_USB_VICAM=m
1079CONFIG_USB_DSBR=m
1080CONFIG_USB_IBMCAM=m
1081CONFIG_USB_KONICAWC=m
1082CONFIG_USB_OV511=m
1083CONFIG_USB_SE401=m
1084CONFIG_USB_SN9C102=m
1085CONFIG_USB_STV680=m
1086CONFIG_USB_PWC=m
1087
1088#
1089# USB Network Adapters
1090#
1091# CONFIG_USB_CATC is not set
1092# CONFIG_USB_KAWETH is not set
1093CONFIG_USB_PEGASUS=m
1094CONFIG_USB_RTL8150=m
1095# CONFIG_USB_USBNET is not set
1096CONFIG_USB_MON=y
1097
1098#
1099# USB port drivers
1100#
1101
1102#
1103# USB Serial Converter support
1104#
1105CONFIG_USB_SERIAL=m
1106# CONFIG_USB_SERIAL_GENERIC is not set
1107# CONFIG_USB_SERIAL_AIRPRIME is not set
1108# CONFIG_USB_SERIAL_BELKIN is not set
1109# CONFIG_USB_SERIAL_WHITEHEAT is not set
1110# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1111# CONFIG_USB_SERIAL_CP2101 is not set
1112# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1113# CONFIG_USB_SERIAL_EMPEG is not set
1114CONFIG_USB_SERIAL_FTDI_SIO=m
1115# CONFIG_USB_SERIAL_VISOR is not set
1116# CONFIG_USB_SERIAL_IPAQ is not set
1117# CONFIG_USB_SERIAL_IR is not set
1118# CONFIG_USB_SERIAL_EDGEPORT is not set
1119# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1120# CONFIG_USB_SERIAL_GARMIN is not set
1121# CONFIG_USB_SERIAL_IPW is not set
1122# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1123# CONFIG_USB_SERIAL_KEYSPAN is not set
1124# CONFIG_USB_SERIAL_KLSI is not set
1125# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1126# CONFIG_USB_SERIAL_MCT_U232 is not set
1127CONFIG_USB_SERIAL_PL2303=m
1128# CONFIG_USB_SERIAL_HP4X is not set
1129# CONFIG_USB_SERIAL_SAFE is not set
1130# CONFIG_USB_SERIAL_TI is not set
1131# CONFIG_USB_SERIAL_CYBERJACK is not set
1132# CONFIG_USB_SERIAL_XIRCOM is not set
1133# CONFIG_USB_SERIAL_OPTION is not set
1134# CONFIG_USB_SERIAL_OMNINET is not set
1135
1136#
1137# USB Miscellaneous drivers
1138#
1139CONFIG_USB_EMI62=m
1140CONFIG_USB_EMI26=m
1141# CONFIG_USB_AUERSWALD is not set
1142# CONFIG_USB_RIO500 is not set
1143# CONFIG_USB_LEGOTOWER is not set
1144# CONFIG_USB_LCD is not set
1145# CONFIG_USB_LED is not set
1146# CONFIG_USB_CYTHERM is not set
1147# CONFIG_USB_PHIDGETKIT is not set
1148# CONFIG_USB_PHIDGETSERVO is not set
1149# CONFIG_USB_IDMOUSE is not set
1150CONFIG_USB_SISUSBVGA=m
1151CONFIG_USB_SISUSBVGA_CON=y
1152# CONFIG_USB_LD is not set
1153# CONFIG_USB_TEST is not set
1154
1155#
1156# USB DSL modem support
1157#
1158
1159#
1160# USB Gadget Support
1161#
1162# CONFIG_USB_GADGET is not set
1163
1164#
1165# MMC/SD Card support
1166#
1167# CONFIG_MMC is not set
1168
1169#
1170# InfiniBand support
1171#
1172# CONFIG_INFINIBAND is not set
1173
1174#
1175# SN Devices
1176#
1177
1178#
1179# File systems
1180#
1181CONFIG_EXT2_FS=y
1182# CONFIG_EXT2_FS_XATTR is not set
1183# CONFIG_EXT2_FS_XIP is not set
1184CONFIG_EXT3_FS=y
1185CONFIG_EXT3_FS_XATTR=y
1186# CONFIG_EXT3_FS_POSIX_ACL is not set
1187# CONFIG_EXT3_FS_SECURITY is not set
1188CONFIG_JBD=y
1189# CONFIG_JBD_DEBUG is not set
1190CONFIG_FS_MBCACHE=y
1191CONFIG_REISERFS_FS=y
1192# CONFIG_REISERFS_CHECK is not set
1193# CONFIG_REISERFS_PROC_INFO is not set
1194# CONFIG_REISERFS_FS_XATTR is not set
1195# CONFIG_JFS_FS is not set
1196# CONFIG_FS_POSIX_ACL is not set
1197# CONFIG_XFS_FS is not set
1198# CONFIG_MINIX_FS is not set
1199CONFIG_ROMFS_FS=y
1200CONFIG_INOTIFY=y
1201# CONFIG_QUOTA is not set
1202CONFIG_DNOTIFY=y
1203# CONFIG_AUTOFS_FS is not set
1204# CONFIG_AUTOFS4_FS is not set
1205# CONFIG_FUSE_FS is not set
1206
1207#
1208# CD-ROM/DVD Filesystems
1209#
1210CONFIG_ISO9660_FS=m
1211# CONFIG_JOLIET is not set
1212# CONFIG_ZISOFS is not set
1213# CONFIG_UDF_FS is not set
1214
1215#
1216# DOS/FAT/NT Filesystems
1217#
1218CONFIG_FAT_FS=y
1219CONFIG_MSDOS_FS=y
1220CONFIG_VFAT_FS=y
1221CONFIG_FAT_DEFAULT_CODEPAGE=437
1222CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1223CONFIG_NTFS_FS=m
1224# CONFIG_NTFS_DEBUG is not set
1225CONFIG_NTFS_RW=y
1226
1227#
1228# Pseudo filesystems
1229#
1230CONFIG_PROC_FS=y
1231# CONFIG_PROC_KCORE is not set
1232CONFIG_SYSFS=y
1233CONFIG_TMPFS=y
1234# CONFIG_HUGETLBFS is not set
1235# CONFIG_HUGETLB_PAGE is not set
1236CONFIG_RAMFS=y
1237# CONFIG_RELAYFS_FS is not set
1238
1239#
1240# Miscellaneous filesystems
1241#
1242# CONFIG_ADFS_FS is not set
1243# CONFIG_AFFS_FS is not set
1244# CONFIG_HFS_FS is not set
1245# CONFIG_HFSPLUS_FS is not set
1246# CONFIG_BEFS_FS is not set
1247# CONFIG_BFS_FS is not set
1248# CONFIG_EFS_FS is not set
1249# CONFIG_CRAMFS is not set
1250# CONFIG_VXFS_FS is not set
1251# CONFIG_HPFS_FS is not set
1252# CONFIG_QNX4FS_FS is not set
1253# CONFIG_SYSV_FS is not set
1254CONFIG_UFS_FS=m
1255CONFIG_UFS_FS_WRITE=y
1256
1257#
1258# Network File Systems
1259#
1260CONFIG_NFS_FS=m
1261CONFIG_NFS_V3=y
1262# CONFIG_NFS_V3_ACL is not set
1263# CONFIG_NFS_V4 is not set
1264# CONFIG_NFS_DIRECTIO is not set
1265CONFIG_NFSD=m
1266CONFIG_NFSD_V3=y
1267# CONFIG_NFSD_V3_ACL is not set
1268# CONFIG_NFSD_V4 is not set
1269CONFIG_NFSD_TCP=y
1270CONFIG_LOCKD=m
1271CONFIG_LOCKD_V4=y
1272CONFIG_EXPORTFS=m
1273CONFIG_NFS_COMMON=y
1274CONFIG_SUNRPC=m
1275# CONFIG_RPCSEC_GSS_KRB5 is not set
1276# CONFIG_RPCSEC_GSS_SPKM3 is not set
1277CONFIG_SMB_FS=m
1278# CONFIG_SMB_NLS_DEFAULT is not set
1279# CONFIG_CIFS is not set
1280# CONFIG_NCP_FS is not set
1281# CONFIG_CODA_FS is not set
1282# CONFIG_AFS_FS is not set
1283# CONFIG_9P_FS is not set
1284
1285#
1286# Partition Types
1287#
1288# CONFIG_PARTITION_ADVANCED is not set
1289CONFIG_MSDOS_PARTITION=y
1290
1291#
1292# Native Language Support
1293#
1294CONFIG_NLS=y
1295CONFIG_NLS_DEFAULT="iso8859-1"
1296CONFIG_NLS_CODEPAGE_437=y
1297# CONFIG_NLS_CODEPAGE_737 is not set
1298# CONFIG_NLS_CODEPAGE_775 is not set
1299# CONFIG_NLS_CODEPAGE_850 is not set
1300# CONFIG_NLS_CODEPAGE_852 is not set
1301# CONFIG_NLS_CODEPAGE_855 is not set
1302# CONFIG_NLS_CODEPAGE_857 is not set
1303# CONFIG_NLS_CODEPAGE_860 is not set
1304# CONFIG_NLS_CODEPAGE_861 is not set
1305# CONFIG_NLS_CODEPAGE_862 is not set
1306# CONFIG_NLS_CODEPAGE_863 is not set
1307# CONFIG_NLS_CODEPAGE_864 is not set
1308# CONFIG_NLS_CODEPAGE_865 is not set
1309# CONFIG_NLS_CODEPAGE_866 is not set
1310# CONFIG_NLS_CODEPAGE_869 is not set
1311# CONFIG_NLS_CODEPAGE_936 is not set
1312# CONFIG_NLS_CODEPAGE_950 is not set
1313CONFIG_NLS_CODEPAGE_932=y
1314# CONFIG_NLS_CODEPAGE_949 is not set
1315# CONFIG_NLS_CODEPAGE_874 is not set
1316# CONFIG_NLS_ISO8859_8 is not set
1317# CONFIG_NLS_CODEPAGE_1250 is not set
1318# CONFIG_NLS_CODEPAGE_1251 is not set
1319# CONFIG_NLS_ASCII is not set
1320# CONFIG_NLS_ISO8859_1 is not set
1321# CONFIG_NLS_ISO8859_2 is not set
1322# CONFIG_NLS_ISO8859_3 is not set
1323# CONFIG_NLS_ISO8859_4 is not set
1324# CONFIG_NLS_ISO8859_5 is not set
1325# CONFIG_NLS_ISO8859_6 is not set
1326# CONFIG_NLS_ISO8859_7 is not set
1327# CONFIG_NLS_ISO8859_9 is not set
1328# CONFIG_NLS_ISO8859_13 is not set
1329# CONFIG_NLS_ISO8859_14 is not set
1330# CONFIG_NLS_ISO8859_15 is not set
1331# CONFIG_NLS_KOI8_R is not set
1332# CONFIG_NLS_KOI8_U is not set
1333# CONFIG_NLS_UTF8 is not set
1334
1335#
1336# Profiling support
1337#
1338# CONFIG_PROFILING is not set
1339
1340#
1341# Kernel hacking
1342#
1343# CONFIG_PRINTK_TIME is not set
1344# CONFIG_DEBUG_KERNEL is not set
1345CONFIG_LOG_BUF_SHIFT=14
1346# CONFIG_FRAME_POINTER is not set
1347CONFIG_SH_STANDARD_BIOS=y
1348# CONFIG_EARLY_SCIF_CONSOLE is not set
1349# CONFIG_EARLY_PRINTK is not set
1350# CONFIG_KGDB is not set
1351
1352#
1353# Security options
1354#
1355# CONFIG_KEYS is not set
1356# CONFIG_SECURITY is not set
1357
1358#
1359# Cryptographic options
1360#
1361# CONFIG_CRYPTO is not set
1362
1363#
1364# Hardware crypto devices
1365#
1366
1367#
1368# Library routines
1369#
1370# CONFIG_CRC_CCITT is not set
1371# CONFIG_CRC16 is not set
1372CONFIG_CRC32=y
1373# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh/configs/r7780rp_defconfig b/arch/sh/configs/r7780rp_defconfig
new file mode 100644
index 000000000000..d597fc571549
--- /dev/null
+++ b/arch/sh/configs/r7780rp_defconfig
@@ -0,0 +1,1099 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.15-sh
4# Sat Jan 7 19:47:53 2006
5#
6CONFIG_SUPERH=y
7CONFIG_UID16=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_HARDIRQS=y
10CONFIG_GENERIC_IRQ_PROBE=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y
12
13#
14# Code maturity level options
15#
16CONFIG_EXPERIMENTAL=y
17CONFIG_CLEAN_COMPILE=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_LOCK_KERNEL=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
30CONFIG_BSD_PROCESS_ACCT=y
31# CONFIG_BSD_PROCESS_ACCT_V3 is not set
32CONFIG_SYSCTL=y
33# CONFIG_AUDIT is not set
34CONFIG_HOTPLUG=y
35CONFIG_KOBJECT_UEVENT=y
36CONFIG_IKCONFIG=y
37CONFIG_IKCONFIG_PROC=y
38CONFIG_INITRAMFS_SOURCE=""
39CONFIG_CC_OPTIMIZE_FOR_SIZE=y
40CONFIG_EMBEDDED=y
41CONFIG_KALLSYMS=y
42# CONFIG_KALLSYMS_ALL is not set
43# CONFIG_KALLSYMS_EXTRA_PASS is not set
44CONFIG_PRINTK=y
45CONFIG_BUG=y
46CONFIG_BASE_FULL=y
47# CONFIG_FUTEX is not set
48# CONFIG_EPOLL is not set
49CONFIG_SHMEM=y
50CONFIG_CC_ALIGN_FUNCTIONS=0
51CONFIG_CC_ALIGN_LABELS=0
52CONFIG_CC_ALIGN_LOOPS=0
53CONFIG_CC_ALIGN_JUMPS=0
54# CONFIG_TINY_SHMEM is not set
55CONFIG_BASE_SMALL=0
56
57#
58# Loadable module support
59#
60CONFIG_MODULES=y
61CONFIG_MODULE_UNLOAD=y
62# CONFIG_MODULE_FORCE_UNLOAD is not set
63CONFIG_OBSOLETE_MODPARM=y
64# CONFIG_MODVERSIONS is not set
65# CONFIG_MODULE_SRCVERSION_ALL is not set
66CONFIG_KMOD=y
67
68#
69# Block layer
70#
71# CONFIG_LBD is not set
72
73#
74# IO Schedulers
75#
76CONFIG_IOSCHED_NOOP=y
77# CONFIG_IOSCHED_AS is not set
78# CONFIG_IOSCHED_DEADLINE is not set
79# CONFIG_IOSCHED_CFQ is not set
80# CONFIG_DEFAULT_AS is not set
81# CONFIG_DEFAULT_DEADLINE is not set
82# CONFIG_DEFAULT_CFQ is not set
83CONFIG_DEFAULT_NOOP=y
84CONFIG_DEFAULT_IOSCHED="noop"
85
86#
87# System type
88#
89# CONFIG_SH_SOLUTION_ENGINE is not set
90# CONFIG_SH_7751_SOLUTION_ENGINE is not set
91# CONFIG_SH_7300_SOLUTION_ENGINE is not set
92# CONFIG_SH_73180_SOLUTION_ENGINE is not set
93# CONFIG_SH_7751_SYSTEMH is not set
94# CONFIG_SH_STB1_HARP is not set
95# CONFIG_SH_STB1_OVERDRIVE is not set
96# CONFIG_SH_HP6XX is not set
97# CONFIG_SH_CQREEK is not set
98# CONFIG_SH_DMIDA is not set
99# CONFIG_SH_EC3104 is not set
100# CONFIG_SH_SATURN is not set
101# CONFIG_SH_DREAMCAST is not set
102# CONFIG_SH_CAT68701 is not set
103# CONFIG_SH_BIGSUR is not set
104# CONFIG_SH_SH2000 is not set
105# CONFIG_SH_ADX is not set
106# CONFIG_SH_MPC1211 is not set
107# CONFIG_SH_SH03 is not set
108# CONFIG_SH_SECUREEDGE5410 is not set
109# CONFIG_SH_HS7751RVOIP is not set
110# CONFIG_SH_RTS7751R2D is not set
111# CONFIG_SH_R77703DRP is not set
112CONFIG_SH_R7780RP=y
113# CONFIG_SH_EDOSK7705 is not set
114# CONFIG_SH_SH4202_MICRODEV is not set
115# CONFIG_SH_LANDISK is not set
116# CONFIG_SH_TITAN is not set
117# CONFIG_SH_UNKNOWN is not set
118
119#
120# Processor selection
121#
122CONFIG_CPU_SH4=y
123CONFIG_CPU_SH4A=y
124
125#
126# SH-2 Processor Support
127#
128# CONFIG_CPU_SUBTYPE_SH7604 is not set
129
130#
131# SH-3 Processor Support
132#
133# CONFIG_CPU_SUBTYPE_SH7300 is not set
134# CONFIG_CPU_SUBTYPE_SH7705 is not set
135# CONFIG_CPU_SUBTYPE_SH7707 is not set
136# CONFIG_CPU_SUBTYPE_SH7708 is not set
137# CONFIG_CPU_SUBTYPE_SH7709 is not set
138
139#
140# SH-4 Processor Support
141#
142# CONFIG_CPU_SUBTYPE_SH7750 is not set
143# CONFIG_CPU_SUBTYPE_SH7091 is not set
144# CONFIG_CPU_SUBTYPE_SH7750R is not set
145# CONFIG_CPU_SUBTYPE_SH7750S is not set
146# CONFIG_CPU_SUBTYPE_SH7751 is not set
147# CONFIG_CPU_SUBTYPE_SH7751R is not set
148# CONFIG_CPU_SUBTYPE_SH7760 is not set
149# CONFIG_CPU_SUBTYPE_SH4_202 is not set
150
151#
152# ST40 Processor Support
153#
154# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
155# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
156
157#
158# SH-4A Processor Support
159#
160# CONFIG_CPU_SUBTYPE_SH73180 is not set
161# CONFIG_CPU_SUBTYPE_SH7770 is not set
162CONFIG_CPU_SUBTYPE_SH7780=y
163
164#
165# Memory management options
166#
167CONFIG_MMU=y
168CONFIG_32BIT=y
169CONFIG_HUGETLB_PAGE_SIZE_64K=y
170# CONFIG_HUGETLB_PAGE_SIZE_1MB is not set
171CONFIG_SELECT_MEMORY_MODEL=y
172CONFIG_FLATMEM_MANUAL=y
173# CONFIG_DISCONTIGMEM_MANUAL is not set
174# CONFIG_SPARSEMEM_MANUAL is not set
175CONFIG_FLATMEM=y
176CONFIG_FLAT_NODE_MEM_MAP=y
177# CONFIG_SPARSEMEM_STATIC is not set
178CONFIG_SPLIT_PTLOCK_CPUS=4
179
180#
181# Cache configuration
182#
183# CONFIG_SH_DIRECT_MAPPED is not set
184# CONFIG_SH_WRITETHROUGH is not set
185# CONFIG_SH_OCRAM is not set
186CONFIG_MEMORY_START=0x08000000
187CONFIG_MEMORY_SIZE=0x08000000
188
189#
190# Processor features
191#
192CONFIG_CPU_LITTLE_ENDIAN=y
193CONFIG_SH_FPU=y
194CONFIG_SH_STORE_QUEUES=y
195
196#
197# Timer support
198#
199CONFIG_SH_TMU=y
200CONFIG_SH_PCLK_FREQ_BOOL=y
201CONFIG_SH_PCLK_FREQ=32000000
202
203#
204# CPU Frequency scaling
205#
206# CONFIG_CPU_FREQ is not set
207
208#
209# DMA support
210#
211CONFIG_SH_DMA=y
212CONFIG_NR_ONCHIP_DMA_CHANNELS=6
213# CONFIG_NR_DMA_CHANNELS_BOOL is not set
214
215#
216# Companion Chips
217#
218# CONFIG_HD6446X_SERIES is not set
219
220#
221# Kernel features
222#
223# CONFIG_KEXEC is not set
224CONFIG_PREEMPT=y
225# CONFIG_SMP is not set
226CONFIG_CPU_HAS_INTEVT=y
227CONFIG_CPU_HAS_INTC2_IRQ=y
228
229#
230# Boot options
231#
232CONFIG_ZERO_PAGE_OFFSET=0x00001000
233CONFIG_BOOT_LINK_OFFSET=0x00800000
234# CONFIG_UBC_WAKEUP is not set
235CONFIG_CMDLINE_BOOL=y
236CONFIG_CMDLINE="mem=128M console=ttySC0,115200 root=/dev/hda1"
237
238#
239# Bus options
240#
241CONFIG_PCI=y
242CONFIG_SH_PCIDMA_NONCOHERENT=y
243CONFIG_PCI_AUTO=y
244CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
245CONFIG_PCI_LEGACY_PROC=y
246# CONFIG_PCI_DEBUG is not set
247
248#
249# PCCARD (PCMCIA/CardBus) support
250#
251# CONFIG_PCCARD is not set
252
253#
254# PCI Hotplug Support
255#
256CONFIG_HOTPLUG_PCI=y
257# CONFIG_HOTPLUG_PCI_FAKE is not set
258# CONFIG_HOTPLUG_PCI_CPCI is not set
259# CONFIG_HOTPLUG_PCI_SHPC is not set
260
261#
262# Executable file formats
263#
264CONFIG_BINFMT_ELF=y
265# CONFIG_BINFMT_FLAT is not set
266# CONFIG_BINFMT_MISC is not set
267
268#
269# Networking
270#
271CONFIG_NET=y
272
273#
274# Networking options
275#
276CONFIG_PACKET=y
277# CONFIG_PACKET_MMAP is not set
278CONFIG_UNIX=y
279# CONFIG_NET_KEY is not set
280CONFIG_INET=y
281# CONFIG_IP_MULTICAST is not set
282CONFIG_IP_ADVANCED_ROUTER=y
283CONFIG_ASK_IP_FIB_HASH=y
284# CONFIG_IP_FIB_TRIE is not set
285CONFIG_IP_FIB_HASH=y
286# CONFIG_IP_MULTIPLE_TABLES is not set
287# CONFIG_IP_ROUTE_MULTIPATH is not set
288# CONFIG_IP_ROUTE_VERBOSE is not set
289CONFIG_IP_PNP=y
290CONFIG_IP_PNP_DHCP=y
291# CONFIG_IP_PNP_BOOTP is not set
292# CONFIG_IP_PNP_RARP is not set
293# CONFIG_NET_IPIP is not set
294# CONFIG_NET_IPGRE is not set
295# CONFIG_ARPD is not set
296# CONFIG_SYN_COOKIES is not set
297# CONFIG_INET_AH is not set
298# CONFIG_INET_ESP is not set
299# CONFIG_INET_IPCOMP is not set
300# CONFIG_INET_TUNNEL is not set
301CONFIG_INET_DIAG=y
302CONFIG_INET_TCP_DIAG=y
303# CONFIG_TCP_CONG_ADVANCED is not set
304CONFIG_TCP_CONG_BIC=y
305# CONFIG_IPV6 is not set
306# CONFIG_NETFILTER is not set
307
308#
309# DCCP Configuration (EXPERIMENTAL)
310#
311# CONFIG_IP_DCCP is not set
312
313#
314# SCTP Configuration (EXPERIMENTAL)
315#
316# CONFIG_IP_SCTP is not set
317# CONFIG_ATM is not set
318CONFIG_BRIDGE=m
319# CONFIG_VLAN_8021Q is not set
320# CONFIG_DECNET is not set
321# CONFIG_LLC2 is not set
322# CONFIG_IPX is not set
323# CONFIG_ATALK is not set
324# CONFIG_X25 is not set
325# CONFIG_LAPB is not set
326# CONFIG_NET_DIVERT is not set
327# CONFIG_ECONET is not set
328# CONFIG_WAN_ROUTER is not set
329
330#
331# QoS and/or fair queueing
332#
333# CONFIG_NET_SCHED is not set
334
335#
336# Network testing
337#
338# CONFIG_NET_PKTGEN is not set
339# CONFIG_HAMRADIO is not set
340# CONFIG_IRDA is not set
341# CONFIG_BT is not set
342# CONFIG_IEEE80211 is not set
343
344#
345# Device Drivers
346#
347
348#
349# Generic Driver Options
350#
351CONFIG_STANDALONE=y
352CONFIG_PREVENT_FIRMWARE_BUILD=y
353CONFIG_FW_LOADER=m
354# CONFIG_DEBUG_DRIVER is not set
355
356#
357# Connector - unified userspace <-> kernelspace linker
358#
359# CONFIG_CONNECTOR is not set
360
361#
362# Memory Technology Devices (MTD)
363#
364# CONFIG_MTD is not set
365
366#
367# Parallel port support
368#
369# CONFIG_PARPORT is not set
370
371#
372# Plug and Play support
373#
374
375#
376# Block devices
377#
378# CONFIG_BLK_CPQ_DA is not set
379# CONFIG_BLK_CPQ_CISS_DA is not set
380# CONFIG_BLK_DEV_DAC960 is not set
381# CONFIG_BLK_DEV_UMEM is not set
382# CONFIG_BLK_DEV_COW_COMMON is not set
383# CONFIG_BLK_DEV_LOOP is not set
384# CONFIG_BLK_DEV_NBD is not set
385# CONFIG_BLK_DEV_SX8 is not set
386CONFIG_BLK_DEV_RAM=y
387CONFIG_BLK_DEV_RAM_COUNT=16
388CONFIG_BLK_DEV_RAM_SIZE=4096
389# CONFIG_BLK_DEV_INITRD is not set
390# CONFIG_CDROM_PKTCDVD is not set
391# CONFIG_ATA_OVER_ETH is not set
392
393#
394# ATA/ATAPI/MFM/RLL support
395#
396CONFIG_IDE=m
397CONFIG_IDE_MAX_HWIFS=4
398CONFIG_BLK_DEV_IDE=m
399
400#
401# Please see Documentation/ide.txt for help/info on IDE drives
402#
403CONFIG_BLK_DEV_IDE_SATA=y
404CONFIG_BLK_DEV_IDEDISK=m
405CONFIG_IDEDISK_MULTI_MODE=y
406# CONFIG_BLK_DEV_IDECD is not set
407# CONFIG_BLK_DEV_IDETAPE is not set
408# CONFIG_BLK_DEV_IDEFLOPPY is not set
409CONFIG_BLK_DEV_IDESCSI=m
410# CONFIG_IDE_TASK_IOCTL is not set
411
412#
413# IDE chipset support/bugfixes
414#
415CONFIG_IDE_GENERIC=m
416CONFIG_BLK_DEV_IDEPCI=y
417CONFIG_IDEPCI_SHARE_IRQ=y
418# CONFIG_BLK_DEV_OFFBOARD is not set
419CONFIG_BLK_DEV_GENERIC=m
420# CONFIG_BLK_DEV_OPTI621 is not set
421CONFIG_BLK_DEV_IDEDMA_PCI=y
422# CONFIG_BLK_DEV_IDEDMA_FORCED is not set
423CONFIG_IDEDMA_PCI_AUTO=y
424# CONFIG_IDEDMA_ONLYDISK is not set
425CONFIG_BLK_DEV_AEC62XX=m
426# CONFIG_BLK_DEV_ALI15X3 is not set
427# CONFIG_BLK_DEV_AMD74XX is not set
428# CONFIG_BLK_DEV_CMD64X is not set
429# CONFIG_BLK_DEV_TRIFLEX is not set
430# CONFIG_BLK_DEV_CY82C693 is not set
431# CONFIG_BLK_DEV_CS5520 is not set
432# CONFIG_BLK_DEV_CS5530 is not set
433# CONFIG_BLK_DEV_HPT34X is not set
434# CONFIG_BLK_DEV_HPT366 is not set
435# CONFIG_BLK_DEV_SC1200 is not set
436# CONFIG_BLK_DEV_PIIX is not set
437# CONFIG_BLK_DEV_IT821X is not set
438# CONFIG_BLK_DEV_NS87415 is not set
439# CONFIG_BLK_DEV_PDC202XX_OLD is not set
440CONFIG_BLK_DEV_PDC202XX_NEW=m
441# CONFIG_PDC202XX_FORCE is not set
442# CONFIG_BLK_DEV_SVWKS is not set
443CONFIG_BLK_DEV_SIIMAGE=m
444# CONFIG_BLK_DEV_SLC90E66 is not set
445# CONFIG_BLK_DEV_TRM290 is not set
446# CONFIG_BLK_DEV_VIA82CXXX is not set
447CONFIG_IDE_SH=y
448# CONFIG_IDE_ARM is not set
449CONFIG_BLK_DEV_IDEDMA=y
450# CONFIG_IDEDMA_IVB is not set
451CONFIG_IDEDMA_AUTO=y
452# CONFIG_BLK_DEV_HD is not set
453
454#
455# SCSI device support
456#
457# CONFIG_RAID_ATTRS is not set
458CONFIG_SCSI=m
459CONFIG_SCSI_PROC_FS=y
460
461#
462# SCSI support type (disk, tape, CD-ROM)
463#
464CONFIG_BLK_DEV_SD=m
465# CONFIG_CHR_DEV_ST is not set
466# CONFIG_CHR_DEV_OSST is not set
467# CONFIG_BLK_DEV_SR is not set
468CONFIG_CHR_DEV_SG=m
469# CONFIG_CHR_DEV_SCH is not set
470
471#
472# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
473#
474# CONFIG_SCSI_MULTI_LUN is not set
475# CONFIG_SCSI_CONSTANTS is not set
476# CONFIG_SCSI_LOGGING is not set
477
478#
479# SCSI Transport Attributes
480#
481# CONFIG_SCSI_SPI_ATTRS is not set
482# CONFIG_SCSI_FC_ATTRS is not set
483# CONFIG_SCSI_ISCSI_ATTRS is not set
484# CONFIG_SCSI_SAS_ATTRS is not set
485
486#
487# SCSI low-level drivers
488#
489# CONFIG_ISCSI_TCP is not set
490# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
491# CONFIG_SCSI_3W_9XXX is not set
492# CONFIG_SCSI_ACARD is not set
493# CONFIG_SCSI_AACRAID is not set
494# CONFIG_SCSI_AIC7XXX is not set
495# CONFIG_SCSI_AIC7XXX_OLD is not set
496# CONFIG_SCSI_AIC79XX is not set
497# CONFIG_SCSI_DPT_I2O is not set
498# CONFIG_MEGARAID_NEWGEN is not set
499# CONFIG_MEGARAID_LEGACY is not set
500# CONFIG_MEGARAID_SAS is not set
501# CONFIG_SCSI_SATA is not set
502# CONFIG_SCSI_DMX3191D is not set
503# CONFIG_SCSI_FUTURE_DOMAIN is not set
504# CONFIG_SCSI_IPS is not set
505# CONFIG_SCSI_INITIO is not set
506# CONFIG_SCSI_INIA100 is not set
507# CONFIG_SCSI_SYM53C8XX_2 is not set
508# CONFIG_SCSI_IPR is not set
509# CONFIG_SCSI_QLOGIC_FC is not set
510# CONFIG_SCSI_QLOGIC_1280 is not set
511CONFIG_SCSI_QLA2XXX=m
512# CONFIG_SCSI_QLA21XX is not set
513# CONFIG_SCSI_QLA22XX is not set
514# CONFIG_SCSI_QLA2300 is not set
515# CONFIG_SCSI_QLA2322 is not set
516# CONFIG_SCSI_QLA6312 is not set
517# CONFIG_SCSI_QLA24XX is not set
518# CONFIG_SCSI_LPFC is not set
519# CONFIG_SCSI_DC395x is not set
520# CONFIG_SCSI_DC390T is not set
521# CONFIG_SCSI_NSP32 is not set
522# CONFIG_SCSI_DEBUG is not set
523
524#
525# Multi-device support (RAID and LVM)
526#
527# CONFIG_MD is not set
528
529#
530# Fusion MPT device support
531#
532# CONFIG_FUSION is not set
533# CONFIG_FUSION_SPI is not set
534# CONFIG_FUSION_FC is not set
535# CONFIG_FUSION_SAS is not set
536
537#
538# IEEE 1394 (FireWire) support
539#
540# CONFIG_IEEE1394 is not set
541
542#
543# I2O device support
544#
545# CONFIG_I2O is not set
546
547#
548# Network device support
549#
550CONFIG_NETDEVICES=y
551# CONFIG_DUMMY is not set
552# CONFIG_BONDING is not set
553# CONFIG_EQUALIZER is not set
554# CONFIG_TUN is not set
555
556#
557# ARCnet devices
558#
559# CONFIG_ARCNET is not set
560
561#
562# PHY device support
563#
564# CONFIG_PHYLIB is not set
565
566#
567# Ethernet (10 or 100Mbit)
568#
569CONFIG_NET_ETHERNET=y
570CONFIG_MII=y
571# CONFIG_STNIC is not set
572# CONFIG_HAPPYMEAL is not set
573# CONFIG_SUNGEM is not set
574# CONFIG_CASSINI is not set
575# CONFIG_NET_VENDOR_3COM is not set
576# CONFIG_SMC91X is not set
577
578#
579# Tulip family network device support
580#
581# CONFIG_NET_TULIP is not set
582# CONFIG_HP100 is not set
583CONFIG_NE2000=y
584CONFIG_NET_PCI=y
585CONFIG_PCNET32=m
586# CONFIG_AMD8111_ETH is not set
587# CONFIG_ADAPTEC_STARFIRE is not set
588# CONFIG_B44 is not set
589# CONFIG_FORCEDETH is not set
590# CONFIG_DGRS is not set
591# CONFIG_EEPRO100 is not set
592# CONFIG_E100 is not set
593# CONFIG_FEALNX is not set
594# CONFIG_NATSEMI is not set
595# CONFIG_NE2K_PCI is not set
596CONFIG_8139CP=m
597CONFIG_8139TOO=m
598# CONFIG_8139TOO_PIO is not set
599# CONFIG_8139TOO_TUNE_TWISTER is not set
600CONFIG_8139TOO_8129=y
601# CONFIG_8139_OLD_RX_RESET is not set
602# CONFIG_SIS900 is not set
603# CONFIG_EPIC100 is not set
604# CONFIG_SUNDANCE is not set
605# CONFIG_TLAN is not set
606CONFIG_VIA_RHINE=m
607CONFIG_VIA_RHINE_MMIO=y
608
609#
610# Ethernet (1000 Mbit)
611#
612# CONFIG_ACENIC is not set
613# CONFIG_DL2K is not set
614CONFIG_E1000=m
615# CONFIG_E1000_NAPI is not set
616# CONFIG_NS83820 is not set
617# CONFIG_HAMACHI is not set
618# CONFIG_YELLOWFIN is not set
619CONFIG_R8169=y
620# CONFIG_R8169_NAPI is not set
621# CONFIG_SIS190 is not set
622# CONFIG_SKGE is not set
623# CONFIG_SK98LIN is not set
624# CONFIG_VIA_VELOCITY is not set
625# CONFIG_TIGON3 is not set
626# CONFIG_BNX2 is not set
627
628#
629# Ethernet (10000 Mbit)
630#
631# CONFIG_CHELSIO_T1 is not set
632# CONFIG_IXGB is not set
633# CONFIG_S2IO is not set
634
635#
636# Token Ring devices
637#
638# CONFIG_TR is not set
639
640#
641# Wireless LAN (non-hamradio)
642#
643CONFIG_NET_RADIO=y
644
645#
646# Obsolete Wireless cards support (pre-802.11)
647#
648# CONFIG_STRIP is not set
649
650#
651# Wireless 802.11b ISA/PCI cards support
652#
653CONFIG_HERMES=m
654# CONFIG_PLX_HERMES is not set
655# CONFIG_TMD_HERMES is not set
656# CONFIG_NORTEL_HERMES is not set
657# CONFIG_PCI_HERMES is not set
658# CONFIG_ATMEL is not set
659
660#
661# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
662#
663CONFIG_PRISM54=m
664# CONFIG_HOSTAP is not set
665CONFIG_NET_WIRELESS=y
666
667#
668# Wan interfaces
669#
670# CONFIG_WAN is not set
671# CONFIG_FDDI is not set
672# CONFIG_HIPPI is not set
673# CONFIG_PPP is not set
674# CONFIG_SLIP is not set
675# CONFIG_NET_FC is not set
676# CONFIG_SHAPER is not set
677# CONFIG_NETCONSOLE is not set
678# CONFIG_NETPOLL is not set
679# CONFIG_NET_POLL_CONTROLLER is not set
680
681#
682# ISDN subsystem
683#
684# CONFIG_ISDN is not set
685
686#
687# Telephony Support
688#
689# CONFIG_PHONE is not set
690
691#
692# Input device support
693#
694CONFIG_INPUT=y
695
696#
697# Userland interfaces
698#
699CONFIG_INPUT_MOUSEDEV=y
700# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
701CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
702CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
703# CONFIG_INPUT_JOYDEV is not set
704# CONFIG_INPUT_TSDEV is not set
705# CONFIG_INPUT_EVDEV is not set
706# CONFIG_INPUT_EVBUG is not set
707
708#
709# Input Device Drivers
710#
711CONFIG_INPUT_KEYBOARD=y
712CONFIG_KEYBOARD_ATKBD=y
713# CONFIG_KEYBOARD_SUNKBD is not set
714# CONFIG_KEYBOARD_LKKBD is not set
715# CONFIG_KEYBOARD_XTKBD is not set
716# CONFIG_KEYBOARD_NEWTON is not set
717# CONFIG_INPUT_MOUSE is not set
718# CONFIG_INPUT_JOYSTICK is not set
719# CONFIG_INPUT_TOUCHSCREEN is not set
720# CONFIG_INPUT_MISC is not set
721
722#
723# Hardware I/O ports
724#
725CONFIG_SERIO=y
726# CONFIG_SERIO_I8042 is not set
727# CONFIG_SERIO_SERPORT is not set
728# CONFIG_SERIO_PCIPS2 is not set
729CONFIG_SERIO_LIBPS2=y
730# CONFIG_SERIO_RAW is not set
731# CONFIG_GAMEPORT is not set
732
733#
734# Character devices
735#
736# CONFIG_VT is not set
737# CONFIG_SERIAL_NONSTANDARD is not set
738
739#
740# Serial drivers
741#
742# CONFIG_SERIAL_8250 is not set
743
744#
745# Non-8250 serial port support
746#
747CONFIG_SERIAL_SH_SCI=y
748CONFIG_SERIAL_SH_SCI_CONSOLE=y
749CONFIG_SERIAL_CORE=y
750CONFIG_SERIAL_CORE_CONSOLE=y
751# CONFIG_SERIAL_JSM is not set
752CONFIG_UNIX98_PTYS=y
753CONFIG_LEGACY_PTYS=y
754CONFIG_LEGACY_PTY_COUNT=256
755
756#
757# IPMI
758#
759# CONFIG_IPMI_HANDLER is not set
760
761#
762# Watchdog Cards
763#
764# CONFIG_WATCHDOG is not set
765# CONFIG_RTC is not set
766# CONFIG_GEN_RTC is not set
767# CONFIG_DTLK is not set
768# CONFIG_R3964 is not set
769# CONFIG_APPLICOM is not set
770
771#
772# Ftape, the floppy tape device driver
773#
774# CONFIG_DRM is not set
775# CONFIG_RAW_DRIVER is not set
776
777#
778# TPM devices
779#
780# CONFIG_TCG_TPM is not set
781# CONFIG_TELCLOCK is not set
782
783#
784# I2C support
785#
786# CONFIG_I2C is not set
787
788#
789# Dallas's 1-wire bus
790#
791# CONFIG_W1 is not set
792
793#
794# Hardware Monitoring support
795#
796CONFIG_HWMON=y
797# CONFIG_HWMON_VID is not set
798# CONFIG_HWMON_DEBUG_CHIP is not set
799
800#
801# Misc devices
802#
803
804#
805# Multimedia Capabilities Port drivers
806#
807
808#
809# Multimedia devices
810#
811# CONFIG_VIDEO_DEV is not set
812
813#
814# Digital Video Broadcasting Devices
815#
816# CONFIG_DVB is not set
817
818#
819# Graphics support
820#
821# CONFIG_FB is not set
822
823#
824# Sound
825#
826CONFIG_SOUND=m
827
828#
829# Advanced Linux Sound Architecture
830#
831# CONFIG_SND is not set
832
833#
834# Open Sound System
835#
836CONFIG_SOUND_PRIME=m
837# CONFIG_OBSOLETE_OSS_DRIVER is not set
838# CONFIG_SOUND_FUSION is not set
839# CONFIG_SOUND_ICH is not set
840# CONFIG_SOUND_TRIDENT is not set
841# CONFIG_SOUND_MSNDCLAS is not set
842# CONFIG_SOUND_MSNDPIN is not set
843
844#
845# USB support
846#
847CONFIG_USB_ARCH_HAS_HCD=y
848CONFIG_USB_ARCH_HAS_OHCI=y
849# CONFIG_USB is not set
850
851#
852# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
853#
854
855#
856# USB Gadget Support
857#
858# CONFIG_USB_GADGET is not set
859
860#
861# MMC/SD Card support
862#
863# CONFIG_MMC is not set
864
865#
866# InfiniBand support
867#
868# CONFIG_INFINIBAND is not set
869
870#
871# SN Devices
872#
873
874#
875# File systems
876#
877CONFIG_EXT2_FS=y
878# CONFIG_EXT2_FS_XATTR is not set
879# CONFIG_EXT2_FS_XIP is not set
880CONFIG_EXT3_FS=y
881CONFIG_EXT3_FS_XATTR=y
882# CONFIG_EXT3_FS_POSIX_ACL is not set
883# CONFIG_EXT3_FS_SECURITY is not set
884CONFIG_JBD=y
885# CONFIG_JBD_DEBUG is not set
886CONFIG_FS_MBCACHE=y
887# CONFIG_REISERFS_FS is not set
888# CONFIG_JFS_FS is not set
889CONFIG_FS_POSIX_ACL=y
890# CONFIG_XFS_FS is not set
891CONFIG_MINIX_FS=y
892# CONFIG_ROMFS_FS is not set
893CONFIG_INOTIFY=y
894# CONFIG_QUOTA is not set
895CONFIG_DNOTIFY=y
896# CONFIG_AUTOFS_FS is not set
897# CONFIG_AUTOFS4_FS is not set
898# CONFIG_FUSE_FS is not set
899
900#
901# CD-ROM/DVD Filesystems
902#
903# CONFIG_ISO9660_FS is not set
904# CONFIG_UDF_FS is not set
905
906#
907# DOS/FAT/NT Filesystems
908#
909CONFIG_FAT_FS=y
910CONFIG_MSDOS_FS=y
911CONFIG_VFAT_FS=y
912CONFIG_FAT_DEFAULT_CODEPAGE=437
913CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
914CONFIG_NTFS_FS=y
915# CONFIG_NTFS_DEBUG is not set
916CONFIG_NTFS_RW=y
917
918#
919# Pseudo filesystems
920#
921CONFIG_PROC_FS=y
922CONFIG_PROC_KCORE=y
923CONFIG_SYSFS=y
924# CONFIG_TMPFS is not set
925CONFIG_HUGETLBFS=y
926CONFIG_HUGETLB_PAGE=y
927CONFIG_RAMFS=y
928# CONFIG_RELAYFS_FS is not set
929
930#
931# Miscellaneous filesystems
932#
933# CONFIG_ADFS_FS is not set
934# CONFIG_AFFS_FS is not set
935# CONFIG_HFS_FS is not set
936# CONFIG_HFSPLUS_FS is not set
937# CONFIG_BEFS_FS is not set
938# CONFIG_BFS_FS is not set
939# CONFIG_EFS_FS is not set
940# CONFIG_CRAMFS is not set
941# CONFIG_VXFS_FS is not set
942# CONFIG_HPFS_FS is not set
943# CONFIG_QNX4FS_FS is not set
944# CONFIG_SYSV_FS is not set
945# CONFIG_UFS_FS is not set
946
947#
948# Network File Systems
949#
950CONFIG_NFS_FS=y
951CONFIG_NFS_V3=y
952# CONFIG_NFS_V3_ACL is not set
953CONFIG_NFS_V4=y
954# CONFIG_NFS_DIRECTIO is not set
955CONFIG_NFSD=y
956CONFIG_NFSD_V3=y
957# CONFIG_NFSD_V3_ACL is not set
958CONFIG_NFSD_V4=y
959CONFIG_NFSD_TCP=y
960CONFIG_ROOT_NFS=y
961CONFIG_LOCKD=y
962CONFIG_LOCKD_V4=y
963CONFIG_EXPORTFS=y
964CONFIG_NFS_COMMON=y
965CONFIG_SUNRPC=y
966CONFIG_SUNRPC_GSS=y
967CONFIG_RPCSEC_GSS_KRB5=y
968# CONFIG_RPCSEC_GSS_SPKM3 is not set
969# CONFIG_SMB_FS is not set
970# CONFIG_CIFS is not set
971# CONFIG_NCP_FS is not set
972# CONFIG_CODA_FS is not set
973# CONFIG_AFS_FS is not set
974# CONFIG_9P_FS is not set
975
976#
977# Partition Types
978#
979# CONFIG_PARTITION_ADVANCED is not set
980CONFIG_MSDOS_PARTITION=y
981
982#
983# Native Language Support
984#
985CONFIG_NLS=y
986CONFIG_NLS_DEFAULT="iso8859-1"
987CONFIG_NLS_CODEPAGE_437=y
988# CONFIG_NLS_CODEPAGE_737 is not set
989# CONFIG_NLS_CODEPAGE_775 is not set
990# CONFIG_NLS_CODEPAGE_850 is not set
991# CONFIG_NLS_CODEPAGE_852 is not set
992# CONFIG_NLS_CODEPAGE_855 is not set
993# CONFIG_NLS_CODEPAGE_857 is not set
994# CONFIG_NLS_CODEPAGE_860 is not set
995# CONFIG_NLS_CODEPAGE_861 is not set
996# CONFIG_NLS_CODEPAGE_862 is not set
997# CONFIG_NLS_CODEPAGE_863 is not set
998# CONFIG_NLS_CODEPAGE_864 is not set
999# CONFIG_NLS_CODEPAGE_865 is not set
1000# CONFIG_NLS_CODEPAGE_866 is not set
1001# CONFIG_NLS_CODEPAGE_869 is not set
1002# CONFIG_NLS_CODEPAGE_936 is not set
1003# CONFIG_NLS_CODEPAGE_950 is not set
1004CONFIG_NLS_CODEPAGE_932=y
1005# CONFIG_NLS_CODEPAGE_949 is not set
1006# CONFIG_NLS_CODEPAGE_874 is not set
1007# CONFIG_NLS_ISO8859_8 is not set
1008# CONFIG_NLS_CODEPAGE_1250 is not set
1009# CONFIG_NLS_CODEPAGE_1251 is not set
1010# CONFIG_NLS_ASCII is not set
1011CONFIG_NLS_ISO8859_1=y
1012# CONFIG_NLS_ISO8859_2 is not set
1013# CONFIG_NLS_ISO8859_3 is not set
1014# CONFIG_NLS_ISO8859_4 is not set
1015# CONFIG_NLS_ISO8859_5 is not set
1016# CONFIG_NLS_ISO8859_6 is not set
1017# CONFIG_NLS_ISO8859_7 is not set
1018# CONFIG_NLS_ISO8859_9 is not set
1019# CONFIG_NLS_ISO8859_13 is not set
1020# CONFIG_NLS_ISO8859_14 is not set
1021# CONFIG_NLS_ISO8859_15 is not set
1022# CONFIG_NLS_KOI8_R is not set
1023# CONFIG_NLS_KOI8_U is not set
1024# CONFIG_NLS_UTF8 is not set
1025
1026#
1027# Profiling support
1028#
1029# CONFIG_PROFILING is not set
1030
1031#
1032# Kernel hacking
1033#
1034# CONFIG_PRINTK_TIME is not set
1035CONFIG_DEBUG_KERNEL=y
1036# CONFIG_MAGIC_SYSRQ is not set
1037CONFIG_LOG_BUF_SHIFT=14
1038CONFIG_DETECT_SOFTLOCKUP=y
1039# CONFIG_SCHEDSTATS is not set
1040# CONFIG_DEBUG_SLAB is not set
1041CONFIG_DEBUG_PREEMPT=y
1042CONFIG_DEBUG_SPINLOCK=y
1043# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1044# CONFIG_DEBUG_KOBJECT is not set
1045# CONFIG_DEBUG_INFO is not set
1046CONFIG_DEBUG_FS=y
1047# CONFIG_DEBUG_VM is not set
1048CONFIG_FRAME_POINTER=y
1049# CONFIG_RCU_TORTURE_TEST is not set
1050# CONFIG_SH_STANDARD_BIOS is not set
1051# CONFIG_EARLY_SCIF_CONSOLE is not set
1052# CONFIG_KGDB is not set
1053
1054#
1055# Security options
1056#
1057# CONFIG_KEYS is not set
1058# CONFIG_SECURITY is not set
1059
1060#
1061# Cryptographic options
1062#
1063CONFIG_CRYPTO=y
1064CONFIG_CRYPTO_HMAC=y
1065# CONFIG_CRYPTO_NULL is not set
1066# CONFIG_CRYPTO_MD4 is not set
1067CONFIG_CRYPTO_MD5=y
1068# CONFIG_CRYPTO_SHA1 is not set
1069# CONFIG_CRYPTO_SHA256 is not set
1070# CONFIG_CRYPTO_SHA512 is not set
1071# CONFIG_CRYPTO_WP512 is not set
1072# CONFIG_CRYPTO_TGR192 is not set
1073CONFIG_CRYPTO_DES=y
1074# CONFIG_CRYPTO_BLOWFISH is not set
1075# CONFIG_CRYPTO_TWOFISH is not set
1076# CONFIG_CRYPTO_SERPENT is not set
1077# CONFIG_CRYPTO_AES is not set
1078# CONFIG_CRYPTO_CAST5 is not set
1079# CONFIG_CRYPTO_CAST6 is not set
1080# CONFIG_CRYPTO_TEA is not set
1081# CONFIG_CRYPTO_ARC4 is not set
1082# CONFIG_CRYPTO_KHAZAD is not set
1083# CONFIG_CRYPTO_ANUBIS is not set
1084# CONFIG_CRYPTO_DEFLATE is not set
1085# CONFIG_CRYPTO_MICHAEL_MIC is not set
1086# CONFIG_CRYPTO_CRC32C is not set
1087# CONFIG_CRYPTO_TEST is not set
1088
1089#
1090# Hardware crypto devices
1091#
1092
1093#
1094# Library routines
1095#
1096# CONFIG_CRC_CCITT is not set
1097# CONFIG_CRC16 is not set
1098CONFIG_CRC32=y
1099# CONFIG_LIBCRC32C is not set
diff --git a/arch/sh/configs/se73180_defconfig b/arch/sh/configs/se73180_defconfig
index d217e44c89a6..fe19feb95ca9 100644
--- a/arch/sh/configs/se73180_defconfig
+++ b/arch/sh/configs/se73180_defconfig
@@ -78,6 +78,7 @@ CONFIG_SH_73180_SOLUTION_ENGINE=y
78# CONFIG_SH_SECUREEDGE5410 is not set 78# CONFIG_SH_SECUREEDGE5410 is not set
79# CONFIG_SH_HS7751RVOIP is not set 79# CONFIG_SH_HS7751RVOIP is not set
80# CONFIG_SH_RTS7751R2D is not set 80# CONFIG_SH_RTS7751R2D is not set
81# CONFIG_SH_R7780RP is not set
81# CONFIG_SH_EDOSK7705 is not set 82# CONFIG_SH_EDOSK7705 is not set
82# CONFIG_SH_SH4202_MICRODEV is not set 83# CONFIG_SH_SH4202_MICRODEV is not set
83# CONFIG_SH_UNKNOWN is not set 84# CONFIG_SH_UNKNOWN is not set
diff --git a/arch/sh/configs/se7343_defconfig b/arch/sh/configs/se7343_defconfig
new file mode 100644
index 000000000000..948e507b52be
--- /dev/null
+++ b/arch/sh/configs/se7343_defconfig
@@ -0,0 +1,997 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17
4# Mon Aug 7 20:14:44 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13
14#
15# Code maturity level options
16#
17CONFIG_EXPERIMENTAL=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20
21#
22# General setup
23#
24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
26# CONFIG_SWAP is not set
27CONFIG_SYSVIPC=y
28CONFIG_POSIX_MQUEUE=y
29# CONFIG_BSD_PROCESS_ACCT is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32# CONFIG_IKCONFIG is not set
33# CONFIG_RELAY is not set
34CONFIG_INITRAMFS_SOURCE=""
35CONFIG_UID16=y
36CONFIG_CC_OPTIMIZE_FOR_SIZE=y
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_HOTPLUG=y
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y
45# CONFIG_FUTEX is not set
46# CONFIG_EPOLL is not set
47# CONFIG_SHMEM is not set
48CONFIG_SLAB=y
49CONFIG_TINY_SHMEM=y
50CONFIG_BASE_SMALL=0
51# CONFIG_SLOB is not set
52CONFIG_OBSOLETE_INTERMODULE=y
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y
59CONFIG_MODULE_FORCE_UNLOAD=y
60# CONFIG_MODVERSIONS is not set
61# CONFIG_MODULE_SRCVERSION_ALL is not set
62# CONFIG_KMOD is not set
63
64#
65# Block layer
66#
67# CONFIG_LBD is not set
68# CONFIG_BLK_DEV_IO_TRACE is not set
69# CONFIG_LSF is not set
70
71#
72# IO Schedulers
73#
74CONFIG_IOSCHED_NOOP=y
75# CONFIG_IOSCHED_AS is not set
76CONFIG_IOSCHED_DEADLINE=y
77# CONFIG_IOSCHED_CFQ is not set
78# CONFIG_DEFAULT_AS is not set
79CONFIG_DEFAULT_DEADLINE=y
80# CONFIG_DEFAULT_CFQ is not set
81# CONFIG_DEFAULT_NOOP is not set
82CONFIG_DEFAULT_IOSCHED="deadline"
83
84#
85# System type
86#
87CONFIG_SOLUTION_ENGINE=y
88# CONFIG_SH_SOLUTION_ENGINE is not set
89# CONFIG_SH_7751_SOLUTION_ENGINE is not set
90# CONFIG_SH_7300_SOLUTION_ENGINE is not set
91CONFIG_SH_7343_SOLUTION_ENGINE=y
92# CONFIG_SH_73180_SOLUTION_ENGINE is not set
93# CONFIG_SH_7751_SYSTEMH is not set
94# CONFIG_SH_HP6XX is not set
95# CONFIG_SH_EC3104 is not set
96# CONFIG_SH_SATURN is not set
97# CONFIG_SH_DREAMCAST is not set
98# CONFIG_SH_BIGSUR is not set
99# CONFIG_SH_MPC1211 is not set
100# CONFIG_SH_SH03 is not set
101# CONFIG_SH_SECUREEDGE5410 is not set
102# CONFIG_SH_HS7751RVOIP is not set
103# CONFIG_SH_7710VOIPGW is not set
104# CONFIG_SH_RTS7751R2D is not set
105# CONFIG_SH_R7780RP is not set
106# CONFIG_SH_EDOSK7705 is not set
107# CONFIG_SH_SH4202_MICRODEV is not set
108# CONFIG_SH_LANDISK is not set
109# CONFIG_SH_TITAN is not set
110# CONFIG_SH_SHMIN is not set
111# CONFIG_SH_UNKNOWN is not set
112
113#
114# Processor selection
115#
116CONFIG_CPU_SH4=y
117CONFIG_CPU_SH4A=y
118
119#
120# SH-2 Processor Support
121#
122# CONFIG_CPU_SUBTYPE_SH7604 is not set
123
124#
125# SH-3 Processor Support
126#
127# CONFIG_CPU_SUBTYPE_SH7300 is not set
128# CONFIG_CPU_SUBTYPE_SH7705 is not set
129# CONFIG_CPU_SUBTYPE_SH7706 is not set
130# CONFIG_CPU_SUBTYPE_SH7707 is not set
131# CONFIG_CPU_SUBTYPE_SH7708 is not set
132# CONFIG_CPU_SUBTYPE_SH7709 is not set
133# CONFIG_CPU_SUBTYPE_SH7710 is not set
134
135#
136# SH-4 Processor Support
137#
138# CONFIG_CPU_SUBTYPE_SH7750 is not set
139# CONFIG_CPU_SUBTYPE_SH7091 is not set
140# CONFIG_CPU_SUBTYPE_SH7750R is not set
141# CONFIG_CPU_SUBTYPE_SH7750S is not set
142# CONFIG_CPU_SUBTYPE_SH7751 is not set
143# CONFIG_CPU_SUBTYPE_SH7751R is not set
144# CONFIG_CPU_SUBTYPE_SH7760 is not set
145# CONFIG_CPU_SUBTYPE_SH4_202 is not set
146
147#
148# ST40 Processor Support
149#
150# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
151# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
152
153#
154# SH-4A Processor Support
155#
156# CONFIG_CPU_SUBTYPE_SH73180 is not set
157CONFIG_CPU_SUBTYPE_SH7343=y
158# CONFIG_CPU_SUBTYPE_SH7770 is not set
159# CONFIG_CPU_SUBTYPE_SH7780 is not set
160
161#
162# Memory management options
163#
164CONFIG_MMU=y
165CONFIG_PAGE_OFFSET=0x80000000
166CONFIG_MEMORY_START=0x0c000000
167CONFIG_MEMORY_SIZE=0x01000000
168CONFIG_32BIT=y
169CONFIG_SELECT_MEMORY_MODEL=y
170CONFIG_FLATMEM_MANUAL=y
171# CONFIG_DISCONTIGMEM_MANUAL is not set
172# CONFIG_SPARSEMEM_MANUAL is not set
173CONFIG_FLATMEM=y
174CONFIG_FLAT_NODE_MEM_MAP=y
175# CONFIG_SPARSEMEM_STATIC is not set
176CONFIG_SPLIT_PTLOCK_CPUS=4
177
178#
179# Cache configuration
180#
181# CONFIG_SH_DIRECT_MAPPED is not set
182# CONFIG_SH_WRITETHROUGH is not set
183# CONFIG_SH_OCRAM is not set
184
185#
186# Processor features
187#
188CONFIG_CPU_LITTLE_ENDIAN=y
189# CONFIG_SH_FPU is not set
190# CONFIG_SH_FPU_EMU is not set
191CONFIG_SH_DSP=y
192# CONFIG_SH_STORE_QUEUES is not set
193CONFIG_CPU_HAS_INTEVT=y
194CONFIG_CPU_HAS_SR_RB=y
195
196#
197# Timer support
198#
199CONFIG_SH_TMU=y
200CONFIG_SH_PCLK_FREQ=27000000
201
202#
203# CPU Frequency scaling
204#
205# CONFIG_CPU_FREQ is not set
206
207#
208# DMA support
209#
210# CONFIG_SH_DMA is not set
211
212#
213# Companion Chips
214#
215# CONFIG_HD6446X_SERIES is not set
216CONFIG_HEARTBEAT=y
217
218#
219# Kernel features
220#
221# CONFIG_HZ_100 is not set
222CONFIG_HZ_250=y
223# CONFIG_HZ_1000 is not set
224CONFIG_HZ=250
225# CONFIG_KEXEC is not set
226# CONFIG_SMP is not set
227CONFIG_PREEMPT_NONE=y
228# CONFIG_PREEMPT_VOLUNTARY is not set
229# CONFIG_PREEMPT is not set
230
231#
232# Boot options
233#
234CONFIG_ZERO_PAGE_OFFSET=0x00001000
235CONFIG_BOOT_LINK_OFFSET=0x00800000
236# CONFIG_UBC_WAKEUP is not set
237# CONFIG_CMDLINE_BOOL is not set
238
239#
240# Bus options
241#
242# CONFIG_PCI is not set
243
244#
245# PCCARD (PCMCIA/CardBus) support
246#
247# CONFIG_PCCARD is not set
248
249#
250# PCI Hotplug Support
251#
252
253#
254# Executable file formats
255#
256CONFIG_BINFMT_ELF=y
257# CONFIG_BINFMT_FLAT is not set
258# CONFIG_BINFMT_MISC is not set
259
260#
261# Power management options (EXPERIMENTAL)
262#
263# CONFIG_PM is not set
264
265#
266# Networking
267#
268CONFIG_NET=y
269
270#
271# Networking options
272#
273# CONFIG_NETDEBUG is not set
274CONFIG_PACKET=y
275CONFIG_PACKET_MMAP=y
276CONFIG_UNIX=y
277# CONFIG_NET_KEY is not set
278CONFIG_INET=y
279# CONFIG_IP_MULTICAST is not set
280# CONFIG_IP_ADVANCED_ROUTER is not set
281CONFIG_IP_FIB_HASH=y
282CONFIG_IP_PNP=y
283CONFIG_IP_PNP_DHCP=y
284# CONFIG_IP_PNP_BOOTP is not set
285# CONFIG_IP_PNP_RARP is not set
286# CONFIG_NET_IPIP is not set
287# CONFIG_NET_IPGRE is not set
288# CONFIG_ARPD is not set
289CONFIG_SYN_COOKIES=y
290# CONFIG_INET_AH is not set
291# CONFIG_INET_ESP is not set
292# CONFIG_INET_IPCOMP is not set
293# CONFIG_INET_XFRM_TUNNEL is not set
294# CONFIG_INET_TUNNEL is not set
295# CONFIG_INET_DIAG is not set
296# CONFIG_TCP_CONG_ADVANCED is not set
297CONFIG_TCP_CONG_BIC=y
298# CONFIG_IPV6 is not set
299# CONFIG_INET6_XFRM_TUNNEL is not set
300# CONFIG_INET6_TUNNEL is not set
301# CONFIG_NETFILTER is not set
302
303#
304# DCCP Configuration (EXPERIMENTAL)
305#
306# CONFIG_IP_DCCP is not set
307
308#
309# SCTP Configuration (EXPERIMENTAL)
310#
311# CONFIG_IP_SCTP is not set
312
313#
314# TIPC Configuration (EXPERIMENTAL)
315#
316# CONFIG_TIPC is not set
317# CONFIG_ATM is not set
318# CONFIG_BRIDGE is not set
319# CONFIG_VLAN_8021Q is not set
320# CONFIG_DECNET is not set
321# CONFIG_LLC2 is not set
322# CONFIG_IPX is not set
323# CONFIG_ATALK is not set
324# CONFIG_X25 is not set
325# CONFIG_LAPB is not set
326# CONFIG_NET_DIVERT is not set
327# CONFIG_ECONET is not set
328# CONFIG_WAN_ROUTER is not set
329
330#
331# QoS and/or fair queueing
332#
333# CONFIG_NET_SCHED is not set
334
335#
336# Network testing
337#
338# CONFIG_NET_PKTGEN is not set
339# CONFIG_HAMRADIO is not set
340# CONFIG_IRDA is not set
341# CONFIG_BT is not set
342# CONFIG_IEEE80211 is not set
343
344#
345# Device Drivers
346#
347
348#
349# Generic Driver Options
350#
351CONFIG_STANDALONE=y
352CONFIG_PREVENT_FIRMWARE_BUILD=y
353CONFIG_FW_LOADER=y
354
355#
356# Connector - unified userspace <-> kernelspace linker
357#
358# CONFIG_CONNECTOR is not set
359
360#
361# Memory Technology Devices (MTD)
362#
363CONFIG_MTD=y
364# CONFIG_MTD_DEBUG is not set
365CONFIG_MTD_CONCAT=y
366CONFIG_MTD_PARTITIONS=y
367# CONFIG_MTD_REDBOOT_PARTS is not set
368# CONFIG_MTD_CMDLINE_PARTS is not set
369
370#
371# User Modules And Translation Layers
372#
373CONFIG_MTD_CHAR=y
374CONFIG_MTD_BLOCK=y
375# CONFIG_FTL is not set
376# CONFIG_NFTL is not set
377# CONFIG_INFTL is not set
378# CONFIG_RFD_FTL is not set
379
380#
381# RAM/ROM/Flash chip drivers
382#
383CONFIG_MTD_CFI=y
384# CONFIG_MTD_JEDECPROBE is not set
385CONFIG_MTD_GEN_PROBE=y
386# CONFIG_MTD_CFI_ADV_OPTIONS is not set
387CONFIG_MTD_MAP_BANK_WIDTH_1=y
388CONFIG_MTD_MAP_BANK_WIDTH_2=y
389CONFIG_MTD_MAP_BANK_WIDTH_4=y
390# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
391# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
392# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
393CONFIG_MTD_CFI_I1=y
394CONFIG_MTD_CFI_I2=y
395# CONFIG_MTD_CFI_I4 is not set
396# CONFIG_MTD_CFI_I8 is not set
397# CONFIG_MTD_CFI_INTELEXT is not set
398CONFIG_MTD_CFI_AMDSTD=y
399# CONFIG_MTD_CFI_STAA is not set
400CONFIG_MTD_CFI_UTIL=y
401CONFIG_MTD_RAM=y
402# CONFIG_MTD_ROM is not set
403# CONFIG_MTD_ABSENT is not set
404# CONFIG_MTD_OBSOLETE_CHIPS is not set
405
406#
407# Mapping drivers for chip access
408#
409# CONFIG_MTD_COMPLEX_MAPPINGS is not set
410# CONFIG_MTD_PHYSMAP is not set
411# CONFIG_MTD_SOLUTIONENGINE is not set
412# CONFIG_MTD_PLATRAM is not set
413
414#
415# Self-contained MTD device drivers
416#
417# CONFIG_MTD_SLRAM is not set
418# CONFIG_MTD_PHRAM is not set
419# CONFIG_MTD_MTDRAM is not set
420# CONFIG_MTD_BLOCK2MTD is not set
421
422#
423# Disk-On-Chip Device Drivers
424#
425# CONFIG_MTD_DOC2000 is not set
426# CONFIG_MTD_DOC2001 is not set
427# CONFIG_MTD_DOC2001PLUS is not set
428
429#
430# NAND Flash Device Drivers
431#
432# CONFIG_MTD_NAND is not set
433
434#
435# OneNAND Flash Device Drivers
436#
437# CONFIG_MTD_ONENAND is not set
438
439#
440# Parallel port support
441#
442# CONFIG_PARPORT is not set
443
444#
445# Plug and Play support
446#
447
448#
449# Block devices
450#
451# CONFIG_BLK_DEV_COW_COMMON is not set
452# CONFIG_BLK_DEV_LOOP is not set
453# CONFIG_BLK_DEV_NBD is not set
454# CONFIG_BLK_DEV_RAM is not set
455# CONFIG_BLK_DEV_INITRD is not set
456# CONFIG_CDROM_PKTCDVD is not set
457# CONFIG_ATA_OVER_ETH is not set
458
459#
460# ATA/ATAPI/MFM/RLL support
461#
462# CONFIG_IDE is not set
463
464#
465# SCSI device support
466#
467# CONFIG_RAID_ATTRS is not set
468# CONFIG_SCSI is not set
469
470#
471# Multi-device support (RAID and LVM)
472#
473# CONFIG_MD is not set
474
475#
476# Fusion MPT device support
477#
478# CONFIG_FUSION is not set
479
480#
481# IEEE 1394 (FireWire) support
482#
483
484#
485# I2O device support
486#
487
488#
489# Network device support
490#
491CONFIG_NETDEVICES=y
492# CONFIG_DUMMY is not set
493# CONFIG_BONDING is not set
494# CONFIG_EQUALIZER is not set
495# CONFIG_TUN is not set
496
497#
498# PHY device support
499#
500# CONFIG_PHYLIB is not set
501
502#
503# Ethernet (10 or 100Mbit)
504#
505CONFIG_NET_ETHERNET=y
506CONFIG_MII=y
507# CONFIG_STNIC is not set
508CONFIG_SMC91X=y
509# CONFIG_NE2000 is not set
510
511#
512# Ethernet (1000 Mbit)
513#
514
515#
516# Ethernet (10000 Mbit)
517#
518
519#
520# Token Ring devices
521#
522
523#
524# Wireless LAN (non-hamradio)
525#
526# CONFIG_NET_RADIO is not set
527
528#
529# Wan interfaces
530#
531# CONFIG_WAN is not set
532# CONFIG_PPP is not set
533# CONFIG_SLIP is not set
534# CONFIG_SHAPER is not set
535# CONFIG_NETCONSOLE is not set
536# CONFIG_NETPOLL is not set
537# CONFIG_NET_POLL_CONTROLLER is not set
538
539#
540# ISDN subsystem
541#
542# CONFIG_ISDN is not set
543
544#
545# Telephony Support
546#
547# CONFIG_PHONE is not set
548
549#
550# Input device support
551#
552CONFIG_INPUT=y
553
554#
555# Userland interfaces
556#
557# CONFIG_INPUT_MOUSEDEV is not set
558# CONFIG_INPUT_JOYDEV is not set
559# CONFIG_INPUT_TSDEV is not set
560# CONFIG_INPUT_EVDEV is not set
561# CONFIG_INPUT_EVBUG is not set
562
563#
564# Input Device Drivers
565#
566# CONFIG_INPUT_KEYBOARD is not set
567# CONFIG_INPUT_MOUSE is not set
568# CONFIG_INPUT_JOYSTICK is not set
569# CONFIG_INPUT_TOUCHSCREEN is not set
570# CONFIG_INPUT_MISC is not set
571
572#
573# Hardware I/O ports
574#
575# CONFIG_SERIO is not set
576# CONFIG_GAMEPORT is not set
577
578#
579# Character devices
580#
581CONFIG_VT=y
582CONFIG_VT_CONSOLE=y
583CONFIG_HW_CONSOLE=y
584# CONFIG_SERIAL_NONSTANDARD is not set
585
586#
587# Serial drivers
588#
589# CONFIG_SERIAL_8250 is not set
590
591#
592# Non-8250 serial port support
593#
594CONFIG_SERIAL_SH_SCI=y
595CONFIG_SERIAL_SH_SCI_NR_UARTS=2
596CONFIG_SERIAL_SH_SCI_CONSOLE=y
597CONFIG_SERIAL_CORE=y
598CONFIG_SERIAL_CORE_CONSOLE=y
599# CONFIG_UNIX98_PTYS is not set
600CONFIG_LEGACY_PTYS=y
601CONFIG_LEGACY_PTY_COUNT=256
602
603#
604# IPMI
605#
606# CONFIG_IPMI_HANDLER is not set
607
608#
609# Watchdog Cards
610#
611# CONFIG_WATCHDOG is not set
612# CONFIG_RTC is not set
613# CONFIG_GEN_RTC is not set
614# CONFIG_DTLK is not set
615# CONFIG_R3964 is not set
616
617#
618# Ftape, the floppy tape device driver
619#
620# CONFIG_RAW_DRIVER is not set
621
622#
623# TPM devices
624#
625# CONFIG_TCG_TPM is not set
626# CONFIG_TELCLOCK is not set
627
628#
629# I2C support
630#
631CONFIG_I2C=y
632CONFIG_I2C_CHARDEV=y
633
634#
635# I2C Algorithms
636#
637# CONFIG_I2C_ALGOBIT is not set
638# CONFIG_I2C_ALGOPCF is not set
639# CONFIG_I2C_ALGOPCA is not set
640
641#
642# I2C Hardware Bus support
643#
644# CONFIG_I2C_PARPORT_LIGHT is not set
645# CONFIG_I2C_STUB is not set
646# CONFIG_I2C_PCA_ISA is not set
647CONFIG_I2C_SH7343=y
648
649#
650# Miscellaneous I2C Chip support
651#
652# CONFIG_SENSORS_DS1337 is not set
653# CONFIG_SENSORS_DS1374 is not set
654# CONFIG_SENSORS_EEPROM is not set
655# CONFIG_SENSORS_PCF8574 is not set
656# CONFIG_SENSORS_PCA9539 is not set
657# CONFIG_SENSORS_PCF8591 is not set
658# CONFIG_SENSORS_MAX6875 is not set
659# CONFIG_I2C_DEBUG_CORE is not set
660# CONFIG_I2C_DEBUG_ALGO is not set
661# CONFIG_I2C_DEBUG_BUS is not set
662# CONFIG_I2C_DEBUG_CHIP is not set
663
664#
665# SPI support
666#
667# CONFIG_SPI is not set
668# CONFIG_SPI_MASTER is not set
669
670#
671# Dallas's 1-wire bus
672#
673# CONFIG_W1 is not set
674
675#
676# Hardware Monitoring support
677#
678# CONFIG_HWMON is not set
679# CONFIG_HWMON_VID is not set
680
681#
682# Misc devices
683#
684
685#
686# Multimedia devices
687#
688CONFIG_VIDEO_DEV=y
689CONFIG_VIDEO_V4L1=y
690CONFIG_VIDEO_V4L1_COMPAT=y
691CONFIG_VIDEO_V4L2=y
692
693#
694# Video Capture Adapters
695#
696
697#
698# Video Capture Adapters
699#
700# CONFIG_VIDEO_ADV_DEBUG is not set
701# CONFIG_VIDEO_VIVI is not set
702# CONFIG_VIDEO_CPIA is not set
703# CONFIG_VIDEO_SAA5246A is not set
704# CONFIG_VIDEO_SAA5249 is not set
705# CONFIG_TUNER_3036 is not set
706# CONFIG_VIDEO_OVCAMCHIP is not set
707
708#
709# Encoders and Decoders
710#
711# CONFIG_VIDEO_MSP3400 is not set
712# CONFIG_VIDEO_CS53L32A is not set
713# CONFIG_VIDEO_WM8775 is not set
714# CONFIG_VIDEO_WM8739 is not set
715# CONFIG_VIDEO_CX25840 is not set
716# CONFIG_VIDEO_SAA711X is not set
717# CONFIG_VIDEO_SAA7127 is not set
718# CONFIG_VIDEO_UPD64031A is not set
719# CONFIG_VIDEO_UPD64083 is not set
720
721#
722# Radio Adapters
723#
724# CONFIG_RADIO_MAESTRO is not set
725
726#
727# Digital Video Broadcasting Devices
728#
729# CONFIG_DVB is not set
730
731#
732# Graphics support
733#
734CONFIG_FB=y
735# CONFIG_FB_CFB_FILLRECT is not set
736# CONFIG_FB_CFB_COPYAREA is not set
737# CONFIG_FB_CFB_IMAGEBLIT is not set
738# CONFIG_FB_MACMODES is not set
739CONFIG_FB_FIRMWARE_EDID=y
740# CONFIG_FB_MODE_HELPERS is not set
741# CONFIG_FB_TILEBLITTING is not set
742# CONFIG_FB_EPSON1355 is not set
743# CONFIG_FB_S1D13XXX is not set
744# CONFIG_FB_VIRTUAL is not set
745
746#
747# Console display driver support
748#
749CONFIG_DUMMY_CONSOLE=y
750# CONFIG_FRAMEBUFFER_CONSOLE is not set
751
752#
753# Logo configuration
754#
755# CONFIG_LOGO is not set
756# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
757
758#
759# Sound
760#
761CONFIG_SOUND=y
762
763#
764# Advanced Linux Sound Architecture
765#
766CONFIG_SND=y
767CONFIG_SND_TIMER=y
768CONFIG_SND_PCM=y
769CONFIG_SND_SEQUENCER=y
770# CONFIG_SND_SEQ_DUMMY is not set
771CONFIG_SND_OSSEMUL=y
772# CONFIG_SND_MIXER_OSS is not set
773CONFIG_SND_PCM_OSS=y
774CONFIG_SND_PCM_OSS_PLUGINS=y
775# CONFIG_SND_SEQUENCER_OSS is not set
776# CONFIG_SND_DYNAMIC_MINORS is not set
777CONFIG_SND_SUPPORT_OLD_API=y
778CONFIG_SND_VERBOSE_PROCFS=y
779# CONFIG_SND_VERBOSE_PRINTK is not set
780# CONFIG_SND_DEBUG is not set
781
782#
783# Generic devices
784#
785# CONFIG_SND_DUMMY is not set
786# CONFIG_SND_VIRMIDI is not set
787# CONFIG_SND_MTPAV is not set
788# CONFIG_SND_SERIAL_U16550 is not set
789# CONFIG_SND_MPU401 is not set
790
791#
792# SuperH devices
793#
794CONFIG_SH7343_SIU=m
795CONFIG_AK4537_CODEC=y
796
797#
798# Open Sound System
799#
800# CONFIG_SOUND_PRIME is not set
801
802#
803# USB support
804#
805# CONFIG_USB_ARCH_HAS_HCD is not set
806# CONFIG_USB_ARCH_HAS_OHCI is not set
807# CONFIG_USB_ARCH_HAS_EHCI is not set
808
809#
810# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
811#
812
813#
814# USB Gadget Support
815#
816# CONFIG_USB_GADGET is not set
817
818#
819# MMC/SD Card support
820#
821# CONFIG_MMC is not set
822
823#
824# LED devices
825#
826# CONFIG_NEW_LEDS is not set
827
828#
829# LED drivers
830#
831
832#
833# LED Triggers
834#
835
836#
837# InfiniBand support
838#
839
840#
841# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
842#
843
844#
845# Real Time Clock
846#
847# CONFIG_RTC_CLASS is not set
848
849#
850# File systems
851#
852# CONFIG_EXT2_FS is not set
853# CONFIG_EXT3_FS is not set
854# CONFIG_REISERFS_FS is not set
855# CONFIG_JFS_FS is not set
856# CONFIG_FS_POSIX_ACL is not set
857# CONFIG_XFS_FS is not set
858# CONFIG_OCFS2_FS is not set
859# CONFIG_MINIX_FS is not set
860# CONFIG_ROMFS_FS is not set
861# CONFIG_INOTIFY is not set
862# CONFIG_QUOTA is not set
863# CONFIG_DNOTIFY is not set
864# CONFIG_AUTOFS_FS is not set
865# CONFIG_AUTOFS4_FS is not set
866# CONFIG_FUSE_FS is not set
867
868#
869# CD-ROM/DVD Filesystems
870#
871# CONFIG_ISO9660_FS is not set
872# CONFIG_UDF_FS is not set
873
874#
875# DOS/FAT/NT Filesystems
876#
877# CONFIG_MSDOS_FS is not set
878# CONFIG_VFAT_FS is not set
879# CONFIG_NTFS_FS is not set
880
881#
882# Pseudo filesystems
883#
884CONFIG_PROC_FS=y
885# CONFIG_PROC_KCORE is not set
886CONFIG_SYSFS=y
887CONFIG_TMPFS=y
888# CONFIG_HUGETLBFS is not set
889# CONFIG_HUGETLB_PAGE is not set
890CONFIG_RAMFS=y
891# CONFIG_CONFIGFS_FS is not set
892
893#
894# Miscellaneous filesystems
895#
896# CONFIG_ADFS_FS is not set
897# CONFIG_AFFS_FS is not set
898# CONFIG_HFS_FS is not set
899# CONFIG_HFSPLUS_FS is not set
900# CONFIG_BEFS_FS is not set
901# CONFIG_BFS_FS is not set
902# CONFIG_EFS_FS is not set
903# CONFIG_JFFS_FS is not set
904CONFIG_JFFS2_FS=y
905CONFIG_JFFS2_FS_DEBUG=0
906CONFIG_JFFS2_FS_WRITEBUFFER=y
907# CONFIG_JFFS2_SUMMARY is not set
908# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
909CONFIG_JFFS2_ZLIB=y
910CONFIG_JFFS2_RTIME=y
911# CONFIG_JFFS2_RUBIN is not set
912# CONFIG_CRAMFS is not set
913# CONFIG_VXFS_FS is not set
914# CONFIG_HPFS_FS is not set
915# CONFIG_QNX4FS_FS is not set
916# CONFIG_SYSV_FS is not set
917# CONFIG_UFS_FS is not set
918
919#
920# Network File Systems
921#
922CONFIG_NFS_FS=y
923CONFIG_NFS_V3=y
924# CONFIG_NFS_V3_ACL is not set
925# CONFIG_NFS_V4 is not set
926# CONFIG_NFS_DIRECTIO is not set
927CONFIG_NFSD=y
928# CONFIG_NFSD_V3 is not set
929# CONFIG_NFSD_TCP is not set
930CONFIG_ROOT_NFS=y
931CONFIG_LOCKD=y
932CONFIG_LOCKD_V4=y
933CONFIG_EXPORTFS=y
934CONFIG_NFS_COMMON=y
935CONFIG_SUNRPC=y
936# CONFIG_RPCSEC_GSS_KRB5 is not set
937# CONFIG_RPCSEC_GSS_SPKM3 is not set
938# CONFIG_SMB_FS is not set
939# CONFIG_CIFS is not set
940# CONFIG_NCP_FS is not set
941# CONFIG_CODA_FS is not set
942# CONFIG_AFS_FS is not set
943# CONFIG_9P_FS is not set
944
945#
946# Partition Types
947#
948# CONFIG_PARTITION_ADVANCED is not set
949CONFIG_MSDOS_PARTITION=y
950
951#
952# Native Language Support
953#
954# CONFIG_NLS is not set
955
956#
957# Profiling support
958#
959# CONFIG_PROFILING is not set
960
961#
962# Kernel hacking
963#
964# CONFIG_PRINTK_TIME is not set
965# CONFIG_MAGIC_SYSRQ is not set
966# CONFIG_DEBUG_KERNEL is not set
967CONFIG_LOG_BUF_SHIFT=14
968# CONFIG_DEBUG_BUGVERBOSE is not set
969# CONFIG_DEBUG_FS is not set
970# CONFIG_SH_STANDARD_BIOS is not set
971# CONFIG_EARLY_SCIF_CONSOLE is not set
972# CONFIG_KGDB is not set
973
974#
975# Security options
976#
977# CONFIG_KEYS is not set
978# CONFIG_SECURITY is not set
979
980#
981# Cryptographic options
982#
983# CONFIG_CRYPTO is not set
984
985#
986# Hardware crypto devices
987#
988
989#
990# Library routines
991#
992# CONFIG_CRC_CCITT is not set
993# CONFIG_CRC16 is not set
994CONFIG_CRC32=y
995# CONFIG_LIBCRC32C is not set
996CONFIG_ZLIB_INFLATE=y
997CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/sh/configs/sh7710voipgw_defconfig b/arch/sh/configs/sh7710voipgw_defconfig
new file mode 100644
index 000000000000..ec9a3034daa5
--- /dev/null
+++ b/arch/sh/configs/sh7710voipgw_defconfig
@@ -0,0 +1,913 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.17
4# Mon Aug 7 17:07:06 2006
5#
6CONFIG_SUPERH=y
7CONFIG_RWSEM_GENERIC_SPINLOCK=y
8CONFIG_GENERIC_FIND_NEXT_BIT=y
9CONFIG_GENERIC_HWEIGHT=y
10CONFIG_GENERIC_HARDIRQS=y
11CONFIG_GENERIC_IRQ_PROBE=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y
13
14#
15# Code maturity level options
16#
17CONFIG_EXPERIMENTAL=y
18CONFIG_BROKEN_ON_SMP=y
19CONFIG_INIT_ENV_ARG_LIMIT=32
20
21#
22# General setup
23#
24CONFIG_LOCALVERSION=""
25CONFIG_LOCALVERSION_AUTO=y
26# CONFIG_SWAP is not set
27CONFIG_SYSVIPC=y
28CONFIG_POSIX_MQUEUE=y
29# CONFIG_BSD_PROCESS_ACCT is not set
30CONFIG_SYSCTL=y
31# CONFIG_AUDIT is not set
32# CONFIG_IKCONFIG is not set
33# CONFIG_RELAY is not set
34CONFIG_INITRAMFS_SOURCE=""
35CONFIG_UID16=y
36CONFIG_CC_OPTIMIZE_FOR_SIZE=y
37CONFIG_EMBEDDED=y
38CONFIG_KALLSYMS=y
39# CONFIG_KALLSYMS_EXTRA_PASS is not set
40CONFIG_HOTPLUG=y
41CONFIG_PRINTK=y
42CONFIG_BUG=y
43CONFIG_ELF_CORE=y
44CONFIG_BASE_FULL=y
45# CONFIG_FUTEX is not set
46# CONFIG_EPOLL is not set
47# CONFIG_SHMEM is not set
48CONFIG_SLAB=y
49CONFIG_TINY_SHMEM=y
50CONFIG_BASE_SMALL=0
51# CONFIG_SLOB is not set
52CONFIG_OBSOLETE_INTERMODULE=y
53
54#
55# Loadable module support
56#
57CONFIG_MODULES=y
58CONFIG_MODULE_UNLOAD=y
59CONFIG_MODULE_FORCE_UNLOAD=y
60# CONFIG_MODVERSIONS is not set
61# CONFIG_MODULE_SRCVERSION_ALL is not set
62# CONFIG_KMOD is not set
63
64#
65# Block layer
66#
67# CONFIG_LBD is not set
68# CONFIG_BLK_DEV_IO_TRACE is not set
69# CONFIG_LSF is not set
70
71#
72# IO Schedulers
73#
74CONFIG_IOSCHED_NOOP=y
75# CONFIG_IOSCHED_AS is not set
76CONFIG_IOSCHED_DEADLINE=y
77# CONFIG_IOSCHED_CFQ is not set
78# CONFIG_DEFAULT_AS is not set
79CONFIG_DEFAULT_DEADLINE=y
80# CONFIG_DEFAULT_CFQ is not set
81# CONFIG_DEFAULT_NOOP is not set
82CONFIG_DEFAULT_IOSCHED="deadline"
83
84#
85# System type
86#
87# CONFIG_SH_SOLUTION_ENGINE is not set
88# CONFIG_SH_7751_SOLUTION_ENGINE is not set
89# CONFIG_SH_7300_SOLUTION_ENGINE is not set
90# CONFIG_SH_73180_SOLUTION_ENGINE is not set
91# CONFIG_SH_7751_SYSTEMH is not set
92# CONFIG_SH_HP6XX is not set
93# CONFIG_SH_EC3104 is not set
94# CONFIG_SH_SATURN is not set
95# CONFIG_SH_DREAMCAST is not set
96# CONFIG_SH_BIGSUR is not set
97# CONFIG_SH_MPC1211 is not set
98# CONFIG_SH_SH03 is not set
99# CONFIG_SH_SECUREEDGE5410 is not set
100# CONFIG_SH_HS7751RVOIP is not set
101CONFIG_SH_7710VOIPGW=y
102# CONFIG_SH_RTS7751R2D is not set
103# CONFIG_SH_R7780RP is not set
104# CONFIG_SH_EDOSK7705 is not set
105# CONFIG_SH_SH4202_MICRODEV is not set
106# CONFIG_SH_LANDISK is not set
107# CONFIG_SH_TITAN is not set
108# CONFIG_SH_SHMIN is not set
109# CONFIG_SH_UNKNOWN is not set
110
111#
112# Processor selection
113#
114CONFIG_CPU_SH3=y
115
116#
117# SH-2 Processor Support
118#
119# CONFIG_CPU_SUBTYPE_SH7604 is not set
120
121#
122# SH-3 Processor Support
123#
124# CONFIG_CPU_SUBTYPE_SH7300 is not set
125# CONFIG_CPU_SUBTYPE_SH7705 is not set
126# CONFIG_CPU_SUBTYPE_SH7706 is not set
127# CONFIG_CPU_SUBTYPE_SH7707 is not set
128# CONFIG_CPU_SUBTYPE_SH7708 is not set
129# CONFIG_CPU_SUBTYPE_SH7709 is not set
130CONFIG_CPU_SUBTYPE_SH7710=y
131
132#
133# SH-4 Processor Support
134#
135# CONFIG_CPU_SUBTYPE_SH7750 is not set
136# CONFIG_CPU_SUBTYPE_SH7091 is not set
137# CONFIG_CPU_SUBTYPE_SH7750R is not set
138# CONFIG_CPU_SUBTYPE_SH7750S is not set
139# CONFIG_CPU_SUBTYPE_SH7751 is not set
140# CONFIG_CPU_SUBTYPE_SH7751R is not set
141# CONFIG_CPU_SUBTYPE_SH7760 is not set
142# CONFIG_CPU_SUBTYPE_SH4_202 is not set
143
144#
145# ST40 Processor Support
146#
147# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
148# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
149
150#
151# SH-4A Processor Support
152#
153# CONFIG_CPU_SUBTYPE_SH73180 is not set
154# CONFIG_CPU_SUBTYPE_SH7770 is not set
155# CONFIG_CPU_SUBTYPE_SH7780 is not set
156
157#
158# Memory management options
159#
160CONFIG_MMU=y
161CONFIG_PAGE_OFFSET=0x80000000
162CONFIG_MEMORY_START=0x0c000000
163CONFIG_MEMORY_SIZE=0x00800000
164CONFIG_SELECT_MEMORY_MODEL=y
165CONFIG_FLATMEM_MANUAL=y
166# CONFIG_DISCONTIGMEM_MANUAL is not set
167# CONFIG_SPARSEMEM_MANUAL is not set
168CONFIG_FLATMEM=y
169CONFIG_FLAT_NODE_MEM_MAP=y
170# CONFIG_SPARSEMEM_STATIC is not set
171CONFIG_SPLIT_PTLOCK_CPUS=4
172
173#
174# Cache configuration
175#
176# CONFIG_SH_DIRECT_MAPPED is not set
177# CONFIG_SH_WRITETHROUGH is not set
178# CONFIG_SH_OCRAM is not set
179
180#
181# Processor features
182#
183CONFIG_CPU_LITTLE_ENDIAN=y
184# CONFIG_SH_FPU_EMU is not set
185CONFIG_SH_DSP=y
186# CONFIG_SH_ADC is not set
187CONFIG_CPU_HAS_INTEVT=y
188CONFIG_CPU_HAS_SR_RB=y
189
190#
191# Timer support
192#
193CONFIG_SH_TMU=y
194CONFIG_SH_PCLK_FREQ=32768000
195
196#
197# CPU Frequency scaling
198#
199# CONFIG_CPU_FREQ is not set
200
201#
202# DMA support
203#
204# CONFIG_SH_DMA is not set
205
206#
207# Companion Chips
208#
209# CONFIG_HD6446X_SERIES is not set
210
211#
212# Kernel features
213#
214# CONFIG_HZ_100 is not set
215CONFIG_HZ_250=y
216# CONFIG_HZ_1000 is not set
217CONFIG_HZ=250
218# CONFIG_KEXEC is not set
219# CONFIG_PREEMPT is not set
220# CONFIG_SMP is not set
221CONFIG_PREEMPT_NONE=y
222# CONFIG_PREEMPT_VOLUNTARY is not set
223
224#
225# Boot options
226#
227CONFIG_ZERO_PAGE_OFFSET=0x00001000
228CONFIG_BOOT_LINK_OFFSET=0x00800000
229# CONFIG_UBC_WAKEUP is not set
230# CONFIG_CMDLINE_BOOL is not set
231
232#
233# Bus options
234#
235# CONFIG_PCI is not set
236
237#
238# PCCARD (PCMCIA/CardBus) support
239#
240# CONFIG_PCCARD is not set
241
242#
243# PCI Hotplug Support
244#
245
246#
247# Executable file formats
248#
249CONFIG_BINFMT_ELF=y
250# CONFIG_BINFMT_FLAT is not set
251# CONFIG_BINFMT_MISC is not set
252
253#
254# Power management options (EXPERIMENTAL)
255#
256# CONFIG_PM is not set
257
258#
259# Networking
260#
261CONFIG_NET=y
262
263#
264# Networking options
265#
266# CONFIG_NETDEBUG is not set
267CONFIG_PACKET=y
268# CONFIG_PACKET_MMAP is not set
269CONFIG_UNIX=y
270# CONFIG_NET_KEY is not set
271CONFIG_INET=y
272# CONFIG_IP_MULTICAST is not set
273# CONFIG_IP_ADVANCED_ROUTER is not set
274CONFIG_IP_FIB_HASH=y
275# CONFIG_IP_PNP is not set
276# CONFIG_NET_IPIP is not set
277# CONFIG_NET_IPGRE is not set
278# CONFIG_ARPD is not set
279CONFIG_SYN_COOKIES=y
280# CONFIG_INET_AH is not set
281# CONFIG_INET_ESP is not set
282# CONFIG_INET_IPCOMP is not set
283# CONFIG_INET_XFRM_TUNNEL is not set
284# CONFIG_INET_TUNNEL is not set
285# CONFIG_INET_DIAG is not set
286# CONFIG_TCP_CONG_ADVANCED is not set
287CONFIG_TCP_CONG_BIC=y
288
289#
290# IP: Virtual Server Configuration
291#
292# CONFIG_IP_VS is not set
293# CONFIG_IPV6 is not set
294# CONFIG_INET6_XFRM_TUNNEL is not set
295# CONFIG_INET6_TUNNEL is not set
296CONFIG_NETFILTER=y
297# CONFIG_NETFILTER_DEBUG is not set
298
299#
300# Core Netfilter Configuration
301#
302# CONFIG_NETFILTER_NETLINK is not set
303# CONFIG_NETFILTER_XTABLES is not set
304
305#
306# IP: Netfilter Configuration
307#
308CONFIG_IP_NF_CONNTRACK=y
309# CONFIG_IP_NF_CT_ACCT is not set
310# CONFIG_IP_NF_CONNTRACK_MARK is not set
311# CONFIG_IP_NF_CONNTRACK_EVENTS is not set
312# CONFIG_IP_NF_CT_PROTO_SCTP is not set
313CONFIG_IP_NF_FTP=m
314# CONFIG_IP_NF_IRC is not set
315# CONFIG_IP_NF_NETBIOS_NS is not set
316# CONFIG_IP_NF_TFTP is not set
317# CONFIG_IP_NF_AMANDA is not set
318CONFIG_IP_NF_PPTP=m
319# CONFIG_IP_NF_H323 is not set
320# CONFIG_IP_NF_QUEUE is not set
321
322#
323# DCCP Configuration (EXPERIMENTAL)
324#
325# CONFIG_IP_DCCP is not set
326
327#
328# SCTP Configuration (EXPERIMENTAL)
329#
330# CONFIG_IP_SCTP is not set
331
332#
333# TIPC Configuration (EXPERIMENTAL)
334#
335# CONFIG_TIPC is not set
336# CONFIG_ATM is not set
337# CONFIG_BRIDGE is not set
338# CONFIG_VLAN_8021Q is not set
339# CONFIG_DECNET is not set
340# CONFIG_LLC2 is not set
341# CONFIG_IPX is not set
342# CONFIG_ATALK is not set
343# CONFIG_X25 is not set
344# CONFIG_LAPB is not set
345# CONFIG_NET_DIVERT is not set
346# CONFIG_ECONET is not set
347# CONFIG_WAN_ROUTER is not set
348
349#
350# QoS and/or fair queueing
351#
352CONFIG_NET_SCHED=y
353CONFIG_NET_SCH_CLK_JIFFIES=y
354# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
355# CONFIG_NET_SCH_CLK_CPU is not set
356
357#
358# Queueing/Scheduling
359#
360CONFIG_NET_SCH_CBQ=y
361# CONFIG_NET_SCH_HTB is not set
362# CONFIG_NET_SCH_HFSC is not set
363# CONFIG_NET_SCH_PRIO is not set
364# CONFIG_NET_SCH_RED is not set
365# CONFIG_NET_SCH_SFQ is not set
366# CONFIG_NET_SCH_TEQL is not set
367# CONFIG_NET_SCH_TBF is not set
368# CONFIG_NET_SCH_GRED is not set
369# CONFIG_NET_SCH_DSMARK is not set
370# CONFIG_NET_SCH_NETEM is not set
371CONFIG_NET_SCH_INGRESS=y
372
373#
374# Classification
375#
376CONFIG_NET_CLS=y
377CONFIG_NET_CLS_BASIC=y
378CONFIG_NET_CLS_TCINDEX=y
379CONFIG_NET_CLS_ROUTE4=y
380CONFIG_NET_CLS_ROUTE=y
381# CONFIG_NET_CLS_FW is not set
382CONFIG_NET_CLS_U32=y
383# CONFIG_CLS_U32_PERF is not set
384# CONFIG_CLS_U32_MARK is not set
385# CONFIG_NET_CLS_RSVP is not set
386# CONFIG_NET_CLS_RSVP6 is not set
387# CONFIG_NET_EMATCH is not set
388# CONFIG_NET_CLS_ACT is not set
389CONFIG_NET_CLS_POLICE=y
390# CONFIG_NET_CLS_IND is not set
391CONFIG_NET_ESTIMATOR=y
392
393#
394# Network testing
395#
396# CONFIG_NET_PKTGEN is not set
397# CONFIG_HAMRADIO is not set
398# CONFIG_IRDA is not set
399# CONFIG_BT is not set
400# CONFIG_IEEE80211 is not set
401
402#
403# Device Drivers
404#
405
406#
407# Generic Driver Options
408#
409CONFIG_STANDALONE=y
410CONFIG_PREVENT_FIRMWARE_BUILD=y
411CONFIG_FW_LOADER=y
412
413#
414# Connector - unified userspace <-> kernelspace linker
415#
416# CONFIG_CONNECTOR is not set
417
418#
419# Memory Technology Devices (MTD)
420#
421CONFIG_MTD=y
422# CONFIG_MTD_DEBUG is not set
423# CONFIG_MTD_CONCAT is not set
424CONFIG_MTD_PARTITIONS=y
425# CONFIG_MTD_REDBOOT_PARTS is not set
426# CONFIG_MTD_CMDLINE_PARTS is not set
427
428#
429# User Modules And Translation Layers
430#
431CONFIG_MTD_CHAR=y
432CONFIG_MTD_BLOCK=y
433# CONFIG_FTL is not set
434# CONFIG_NFTL is not set
435# CONFIG_INFTL is not set
436# CONFIG_RFD_FTL is not set
437
438#
439# RAM/ROM/Flash chip drivers
440#
441CONFIG_MTD_CFI=y
442# CONFIG_MTD_JEDECPROBE is not set
443CONFIG_MTD_GEN_PROBE=y
444# CONFIG_MTD_CFI_ADV_OPTIONS is not set
445CONFIG_MTD_MAP_BANK_WIDTH_1=y
446CONFIG_MTD_MAP_BANK_WIDTH_2=y
447CONFIG_MTD_MAP_BANK_WIDTH_4=y
448# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
449# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
450# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
451CONFIG_MTD_CFI_I1=y
452CONFIG_MTD_CFI_I2=y
453# CONFIG_MTD_CFI_I4 is not set
454# CONFIG_MTD_CFI_I8 is not set
455# CONFIG_MTD_CFI_INTELEXT is not set
456CONFIG_MTD_CFI_AMDSTD=y
457# CONFIG_MTD_CFI_STAA is not set
458CONFIG_MTD_CFI_UTIL=y
459CONFIG_MTD_RAM=y
460# CONFIG_MTD_ROM is not set
461# CONFIG_MTD_ABSENT is not set
462# CONFIG_MTD_OBSOLETE_CHIPS is not set
463
464#
465# Mapping drivers for chip access
466#
467# CONFIG_MTD_COMPLEX_MAPPINGS is not set
468# CONFIG_MTD_PHYSMAP is not set
469# CONFIG_MTD_SOLUTIONENGINE is not set
470CONFIG_MTD_SH7710VOIPGW=y
471# CONFIG_MTD_PLATRAM is not set
472
473#
474# Self-contained MTD device drivers
475#
476# CONFIG_MTD_SLRAM is not set
477# CONFIG_MTD_PHRAM is not set
478# CONFIG_MTD_MTDRAM is not set
479# CONFIG_MTD_BLOCK2MTD is not set
480
481#
482# Disk-On-Chip Device Drivers
483#
484# CONFIG_MTD_DOC2000 is not set
485# CONFIG_MTD_DOC2001 is not set
486# CONFIG_MTD_DOC2001PLUS is not set
487
488#
489# NAND Flash Device Drivers
490#
491# CONFIG_MTD_NAND is not set
492
493#
494# OneNAND Flash Device Drivers
495#
496# CONFIG_MTD_ONENAND is not set
497
498#
499# Parallel port support
500#
501# CONFIG_PARPORT is not set
502
503#
504# Plug and Play support
505#
506
507#
508# Block devices
509#
510# CONFIG_BLK_DEV_COW_COMMON is not set
511# CONFIG_BLK_DEV_LOOP is not set
512# CONFIG_BLK_DEV_NBD is not set
513# CONFIG_BLK_DEV_RAM is not set
514# CONFIG_BLK_DEV_INITRD is not set
515# CONFIG_CDROM_PKTCDVD is not set
516# CONFIG_ATA_OVER_ETH is not set
517
518#
519# ATA/ATAPI/MFM/RLL support
520#
521# CONFIG_IDE is not set
522
523#
524# SCSI device support
525#
526# CONFIG_RAID_ATTRS is not set
527# CONFIG_SCSI is not set
528
529#
530# Multi-device support (RAID and LVM)
531#
532# CONFIG_MD is not set
533
534#
535# Fusion MPT device support
536#
537# CONFIG_FUSION is not set
538
539#
540# IEEE 1394 (FireWire) support
541#
542
543#
544# I2O device support
545#
546
547#
548# Network device support
549#
550CONFIG_NETDEVICES=y
551# CONFIG_DUMMY is not set
552# CONFIG_BONDING is not set
553# CONFIG_EQUALIZER is not set
554# CONFIG_TUN is not set
555
556#
557# PHY device support
558#
559# CONFIG_PHYLIB is not set
560
561#
562# Ethernet (10 or 100Mbit)
563#
564CONFIG_NET_ETHERNET=y
565# CONFIG_MII is not set
566# CONFIG_STNIC is not set
567# CONFIG_SMC91X is not set
568# CONFIG_NE2000 is not set
569
570#
571# Ethernet (1000 Mbit)
572#
573
574#
575# Ethernet (10000 Mbit)
576#
577
578#
579# Token Ring devices
580#
581
582#
583# Wireless LAN (non-hamradio)
584#
585# CONFIG_NET_RADIO is not set
586
587#
588# Wan interfaces
589#
590# CONFIG_WAN is not set
591# CONFIG_PPP is not set
592# CONFIG_SLIP is not set
593# CONFIG_SHAPER is not set
594# CONFIG_NETCONSOLE is not set
595# CONFIG_NETPOLL is not set
596# CONFIG_NET_POLL_CONTROLLER is not set
597
598#
599# ISDN subsystem
600#
601# CONFIG_ISDN is not set
602
603#
604# Telephony Support
605#
606CONFIG_PHONE=y
607# CONFIG_PHONE_IXJ is not set
608
609#
610# Input device support
611#
612CONFIG_INPUT=y
613
614#
615# Userland interfaces
616#
617# CONFIG_INPUT_MOUSEDEV is not set
618# CONFIG_INPUT_JOYDEV is not set
619# CONFIG_INPUT_TSDEV is not set
620# CONFIG_INPUT_EVDEV is not set
621# CONFIG_INPUT_EVBUG is not set
622
623#
624# Input Device Drivers
625#
626# CONFIG_INPUT_KEYBOARD is not set
627# CONFIG_INPUT_MOUSE is not set
628# CONFIG_INPUT_JOYSTICK is not set
629# CONFIG_INPUT_TOUCHSCREEN is not set
630# CONFIG_INPUT_MISC is not set
631
632#
633# Hardware I/O ports
634#
635# CONFIG_SERIO is not set
636# CONFIG_GAMEPORT is not set
637
638#
639# Character devices
640#
641# CONFIG_VT is not set
642# CONFIG_SERIAL_NONSTANDARD is not set
643
644#
645# Serial drivers
646#
647# CONFIG_SERIAL_8250 is not set
648
649#
650# Non-8250 serial port support
651#
652CONFIG_SERIAL_SH_SCI=y
653CONFIG_SERIAL_SH_SCI_NR_UARTS=2
654CONFIG_SERIAL_SH_SCI_CONSOLE=y
655CONFIG_SERIAL_CORE=y
656CONFIG_SERIAL_CORE_CONSOLE=y
657# CONFIG_UNIX98_PTYS is not set
658CONFIG_LEGACY_PTYS=y
659CONFIG_LEGACY_PTY_COUNT=256
660
661#
662# IPMI
663#
664# CONFIG_IPMI_HANDLER is not set
665
666#
667# Watchdog Cards
668#
669# CONFIG_WATCHDOG is not set
670# CONFIG_RTC is not set
671# CONFIG_GEN_RTC is not set
672# CONFIG_DTLK is not set
673# CONFIG_R3964 is not set
674
675#
676# Ftape, the floppy tape device driver
677#
678# CONFIG_RAW_DRIVER is not set
679
680#
681# TPM devices
682#
683# CONFIG_TCG_TPM is not set
684# CONFIG_TELCLOCK is not set
685
686#
687# I2C support
688#
689# CONFIG_I2C is not set
690
691#
692# SPI support
693#
694# CONFIG_SPI is not set
695# CONFIG_SPI_MASTER is not set
696
697#
698# Dallas's 1-wire bus
699#
700# CONFIG_W1 is not set
701
702#
703# Hardware Monitoring support
704#
705# CONFIG_HWMON is not set
706# CONFIG_HWMON_VID is not set
707
708#
709# Misc devices
710#
711
712#
713# Multimedia devices
714#
715# CONFIG_VIDEO_DEV is not set
716CONFIG_VIDEO_V4L2=y
717
718#
719# Digital Video Broadcasting Devices
720#
721# CONFIG_DVB is not set
722
723#
724# Graphics support
725#
726# CONFIG_FB is not set
727
728#
729# Sound
730#
731# CONFIG_SOUND is not set
732
733#
734# USB support
735#
736# CONFIG_USB_ARCH_HAS_HCD is not set
737# CONFIG_USB_ARCH_HAS_OHCI is not set
738# CONFIG_USB_ARCH_HAS_EHCI is not set
739
740#
741# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
742#
743
744#
745# USB Gadget Support
746#
747# CONFIG_USB_GADGET is not set
748
749#
750# MMC/SD Card support
751#
752# CONFIG_MMC is not set
753
754#
755# LED devices
756#
757# CONFIG_NEW_LEDS is not set
758
759#
760# LED drivers
761#
762
763#
764# LED Triggers
765#
766
767#
768# InfiniBand support
769#
770
771#
772# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
773#
774
775#
776# Real Time Clock
777#
778# CONFIG_RTC_CLASS is not set
779
780#
781# File systems
782#
783# CONFIG_EXT2_FS is not set
784# CONFIG_EXT3_FS is not set
785# CONFIG_REISERFS_FS is not set
786# CONFIG_JFS_FS is not set
787# CONFIG_FS_POSIX_ACL is not set
788# CONFIG_XFS_FS is not set
789# CONFIG_OCFS2_FS is not set
790# CONFIG_MINIX_FS is not set
791# CONFIG_ROMFS_FS is not set
792# CONFIG_INOTIFY is not set
793# CONFIG_QUOTA is not set
794# CONFIG_DNOTIFY is not set
795# CONFIG_AUTOFS_FS is not set
796# CONFIG_AUTOFS4_FS is not set
797# CONFIG_FUSE_FS is not set
798
799#
800# CD-ROM/DVD Filesystems
801#
802# CONFIG_ISO9660_FS is not set
803# CONFIG_UDF_FS is not set
804
805#
806# DOS/FAT/NT Filesystems
807#
808# CONFIG_MSDOS_FS is not set
809# CONFIG_VFAT_FS is not set
810# CONFIG_NTFS_FS is not set
811
812#
813# Pseudo filesystems
814#
815CONFIG_PROC_FS=y
816# CONFIG_PROC_KCORE is not set
817CONFIG_SYSFS=y
818CONFIG_TMPFS=y
819# CONFIG_HUGETLBFS is not set
820# CONFIG_HUGETLB_PAGE is not set
821CONFIG_RAMFS=y
822# CONFIG_CONFIGFS_FS is not set
823
824#
825# Miscellaneous filesystems
826#
827# CONFIG_ADFS_FS is not set
828# CONFIG_AFFS_FS is not set
829# CONFIG_HFS_FS is not set
830# CONFIG_HFSPLUS_FS is not set
831# CONFIG_BEFS_FS is not set
832# CONFIG_BFS_FS is not set
833# CONFIG_EFS_FS is not set
834# CONFIG_JFFS_FS is not set
835CONFIG_JFFS2_FS=y
836CONFIG_JFFS2_FS_DEBUG=0
837CONFIG_JFFS2_FS_WRITEBUFFER=y
838# CONFIG_JFFS2_SUMMARY is not set
839# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
840CONFIG_JFFS2_ZLIB=y
841CONFIG_JFFS2_RTIME=y
842# CONFIG_JFFS2_RUBIN is not set
843# CONFIG_CRAMFS is not set
844# CONFIG_VXFS_FS is not set
845# CONFIG_HPFS_FS is not set
846# CONFIG_QNX4FS_FS is not set
847# CONFIG_SYSV_FS is not set
848# CONFIG_UFS_FS is not set
849
850#
851# Network File Systems
852#
853# CONFIG_NFS_FS is not set
854# CONFIG_NFSD is not set
855# CONFIG_SMB_FS is not set
856# CONFIG_CIFS is not set
857# CONFIG_NCP_FS is not set
858# CONFIG_CODA_FS is not set
859# CONFIG_AFS_FS is not set
860# CONFIG_9P_FS is not set
861
862#
863# Partition Types
864#
865# CONFIG_PARTITION_ADVANCED is not set
866CONFIG_MSDOS_PARTITION=y
867
868#
869# Native Language Support
870#
871# CONFIG_NLS is not set
872
873#
874# Profiling support
875#
876# CONFIG_PROFILING is not set
877
878#
879# Kernel hacking
880#
881# CONFIG_PRINTK_TIME is not set
882# CONFIG_MAGIC_SYSRQ is not set
883# CONFIG_DEBUG_KERNEL is not set
884CONFIG_LOG_BUF_SHIFT=14
885# CONFIG_DEBUG_BUGVERBOSE is not set
886# CONFIG_DEBUG_FS is not set
887# CONFIG_SH_STANDARD_BIOS is not set
888# CONFIG_KGDB is not set
889
890#
891# Security options
892#
893# CONFIG_KEYS is not set
894# CONFIG_SECURITY is not set
895
896#
897# Cryptographic options
898#
899# CONFIG_CRYPTO is not set
900
901#
902# Hardware crypto devices
903#
904
905#
906# Library routines
907#
908# CONFIG_CRC_CCITT is not set
909# CONFIG_CRC16 is not set
910CONFIG_CRC32=y
911# CONFIG_LIBCRC32C is not set
912CONFIG_ZLIB_INFLATE=y
913CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/mips/configs/ev96100_defconfig b/arch/sh/configs/shmin_defconfig
index 0bdc10f11610..382b3bd3963b 100644
--- a/arch/mips/configs/ev96100_defconfig
+++ b/arch/sh/configs/shmin_defconfig
@@ -1,159 +1,16 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc1 3# Linux kernel version: 2.6.17
4# Thu Jul 6 10:04:05 2006 4# Wed Aug 2 01:45:03 2006
5# 5#
6CONFIG_MIPS=y 6CONFIG_SUPERH=y
7
8#
9# Machine selection
10#
11# CONFIG_MIPS_MTX1 is not set
12# CONFIG_MIPS_BOSPORUS is not set
13# CONFIG_MIPS_PB1000 is not set
14# CONFIG_MIPS_PB1100 is not set
15# CONFIG_MIPS_PB1500 is not set
16# CONFIG_MIPS_PB1550 is not set
17# CONFIG_MIPS_PB1200 is not set
18# CONFIG_MIPS_DB1000 is not set
19# CONFIG_MIPS_DB1100 is not set
20# CONFIG_MIPS_DB1500 is not set
21# CONFIG_MIPS_DB1550 is not set
22# CONFIG_MIPS_DB1200 is not set
23# CONFIG_MIPS_MIRAGE is not set
24# CONFIG_BASLER_EXCITE is not set
25# CONFIG_MIPS_COBALT is not set
26# CONFIG_MACH_DECSTATION is not set
27# CONFIG_MIPS_EV64120 is not set
28CONFIG_MIPS_EV96100=y
29# CONFIG_MIPS_IVR is not set
30# CONFIG_MIPS_ITE8172 is not set
31# CONFIG_MACH_JAZZ is not set
32# CONFIG_LASAT is not set
33# CONFIG_MIPS_ATLAS is not set
34# CONFIG_MIPS_MALTA is not set
35# CONFIG_MIPS_SEAD is not set
36# CONFIG_WR_PPMC is not set
37# CONFIG_MIPS_SIM is not set
38# CONFIG_MOMENCO_JAGUAR_ATX is not set
39# CONFIG_MOMENCO_OCELOT is not set
40# CONFIG_MOMENCO_OCELOT_3 is not set
41# CONFIG_MOMENCO_OCELOT_C is not set
42# CONFIG_MOMENCO_OCELOT_G is not set
43# CONFIG_MIPS_XXS1500 is not set
44# CONFIG_PNX8550_V2PCI is not set
45# CONFIG_PNX8550_JBS is not set
46# CONFIG_DDB5477 is not set
47# CONFIG_MACH_VR41XX is not set
48# CONFIG_PMC_YOSEMITE is not set
49# CONFIG_QEMU is not set
50# CONFIG_MARKEINS is not set
51# CONFIG_SGI_IP22 is not set
52# CONFIG_SGI_IP27 is not set
53# CONFIG_SGI_IP32 is not set
54# CONFIG_SIBYTE_BIGSUR is not set
55# CONFIG_SIBYTE_SWARM is not set
56# CONFIG_SIBYTE_SENTOSA is not set
57# CONFIG_SIBYTE_RHONE is not set
58# CONFIG_SIBYTE_CARMEL is not set
59# CONFIG_SIBYTE_PTSWARM is not set
60# CONFIG_SIBYTE_LITTLESUR is not set
61# CONFIG_SIBYTE_CRHINE is not set
62# CONFIG_SIBYTE_CRHONE is not set
63# CONFIG_SNI_RM200_PCI is not set
64# CONFIG_TOSHIBA_JMR3927 is not set
65# CONFIG_TOSHIBA_RBTX4927 is not set
66# CONFIG_TOSHIBA_RBTX4938 is not set
67CONFIG_RWSEM_GENERIC_SPINLOCK=y 7CONFIG_RWSEM_GENERIC_SPINLOCK=y
68CONFIG_GENERIC_FIND_NEXT_BIT=y 8CONFIG_GENERIC_FIND_NEXT_BIT=y
69CONFIG_GENERIC_HWEIGHT=y 9CONFIG_GENERIC_HWEIGHT=y
70CONFIG_GENERIC_CALIBRATE_DELAY=y
71CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
72CONFIG_DMA_NONCOHERENT=y
73CONFIG_DMA_NEED_PCI_MAP_STATE=y
74CONFIG_CPU_BIG_ENDIAN=y
75# CONFIG_CPU_LITTLE_ENDIAN is not set
76CONFIG_SYS_SUPPORTS_BIG_ENDIAN=y
77CONFIG_IRQ_CPU=y
78CONFIG_MIPS_GT64120=y
79CONFIG_SWAP_IO_SPACE=y
80CONFIG_MIPS_GT96100=y
81CONFIG_MIPS_L1_CACHE_SHIFT=5
82
83#
84# CPU selection
85#
86# CONFIG_CPU_MIPS32_R1 is not set
87# CONFIG_CPU_MIPS32_R2 is not set
88# CONFIG_CPU_MIPS64_R1 is not set
89# CONFIG_CPU_MIPS64_R2 is not set
90# CONFIG_CPU_R3000 is not set
91# CONFIG_CPU_TX39XX is not set
92# CONFIG_CPU_VR41XX is not set
93# CONFIG_CPU_R4300 is not set
94# CONFIG_CPU_R4X00 is not set
95# CONFIG_CPU_TX49XX is not set
96# CONFIG_CPU_R5000 is not set
97# CONFIG_CPU_R5432 is not set
98# CONFIG_CPU_R6000 is not set
99# CONFIG_CPU_NEVADA is not set
100# CONFIG_CPU_R8000 is not set
101# CONFIG_CPU_R10000 is not set
102CONFIG_CPU_RM7000=y
103# CONFIG_CPU_RM9000 is not set
104# CONFIG_CPU_SB1 is not set
105CONFIG_SYS_HAS_CPU_R5000=y
106CONFIG_SYS_HAS_CPU_RM7000=y
107CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y
108CONFIG_SYS_SUPPORTS_64BIT_KERNEL=y
109CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y
110CONFIG_CPU_SUPPORTS_64BIT_KERNEL=y
111
112#
113# Kernel type
114#
115CONFIG_32BIT=y
116# CONFIG_64BIT is not set
117CONFIG_PAGE_SIZE_4KB=y
118# CONFIG_PAGE_SIZE_8KB is not set
119# CONFIG_PAGE_SIZE_16KB is not set
120# CONFIG_PAGE_SIZE_64KB is not set
121CONFIG_BOARD_SCACHE=y
122CONFIG_RM7000_CPU_SCACHE=y
123CONFIG_CPU_HAS_PREFETCH=y
124CONFIG_MIPS_MT_DISABLED=y
125# CONFIG_MIPS_MT_SMTC is not set
126# CONFIG_MIPS_MT_SMP is not set
127# CONFIG_MIPS_VPE_LOADER is not set
128# CONFIG_64BIT_PHYS_ADDR is not set
129CONFIG_CPU_HAS_LLSC=y
130CONFIG_CPU_HAS_SYNC=y
131CONFIG_GENERIC_HARDIRQS=y 10CONFIG_GENERIC_HARDIRQS=y
132CONFIG_GENERIC_IRQ_PROBE=y 11CONFIG_GENERIC_IRQ_PROBE=y
133CONFIG_CPU_SUPPORTS_HIGHMEM=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
134CONFIG_ARCH_FLATMEM_ENABLE=y 13CONFIG_PTRACE=y
135CONFIG_SELECT_MEMORY_MODEL=y
136CONFIG_FLATMEM_MANUAL=y
137# CONFIG_DISCONTIGMEM_MANUAL is not set
138# CONFIG_SPARSEMEM_MANUAL is not set
139CONFIG_FLATMEM=y
140CONFIG_FLAT_NODE_MEM_MAP=y
141# CONFIG_SPARSEMEM_STATIC is not set
142CONFIG_SPLIT_PTLOCK_CPUS=4
143# CONFIG_RESOURCES_64BIT is not set
144# CONFIG_HZ_48 is not set
145# CONFIG_HZ_100 is not set
146# CONFIG_HZ_128 is not set
147# CONFIG_HZ_250 is not set
148# CONFIG_HZ_256 is not set
149CONFIG_HZ_1000=y
150# CONFIG_HZ_1024 is not set
151CONFIG_SYS_SUPPORTS_ARBIT_HZ=y
152CONFIG_HZ=1000
153CONFIG_PREEMPT_NONE=y
154# CONFIG_PREEMPT_VOLUNTARY is not set
155# CONFIG_PREEMPT is not set
156CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
157 14
158# 15#
159# Code maturity level options 16# Code maturity level options
@@ -167,70 +24,210 @@ CONFIG_INIT_ENV_ARG_LIMIT=32
167# 24#
168CONFIG_LOCALVERSION="" 25CONFIG_LOCALVERSION=""
169CONFIG_LOCALVERSION_AUTO=y 26CONFIG_LOCALVERSION_AUTO=y
170CONFIG_SWAP=y 27# CONFIG_SWAP is not set
171CONFIG_SYSVIPC=y 28# CONFIG_SYSVIPC is not set
172# CONFIG_POSIX_MQUEUE is not set 29# CONFIG_POSIX_MQUEUE is not set
173# CONFIG_BSD_PROCESS_ACCT is not set 30# CONFIG_BSD_PROCESS_ACCT is not set
174CONFIG_SYSCTL=y 31# CONFIG_SYSCTL is not set
175# CONFIG_AUDIT is not set 32# CONFIG_AUDIT is not set
176# CONFIG_IKCONFIG is not set 33# CONFIG_IKCONFIG is not set
177CONFIG_RELAY=y 34# CONFIG_RELAY is not set
178CONFIG_INITRAMFS_SOURCE="" 35CONFIG_INITRAMFS_SOURCE=""
179# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 36# CONFIG_UID16 is not set
37CONFIG_CC_OPTIMIZE_FOR_SIZE=y
180CONFIG_EMBEDDED=y 38CONFIG_EMBEDDED=y
181CONFIG_KALLSYMS=y 39# CONFIG_KALLSYMS is not set
182# CONFIG_KALLSYMS_EXTRA_PASS is not set
183# CONFIG_HOTPLUG is not set 40# CONFIG_HOTPLUG is not set
184CONFIG_PRINTK=y 41CONFIG_PRINTK=y
185CONFIG_BUG=y 42# CONFIG_BUG is not set
186CONFIG_ELF_CORE=y 43# CONFIG_ELF_CORE is not set
187CONFIG_BASE_FULL=y 44# CONFIG_BASE_FULL is not set
188CONFIG_RT_MUTEXES=y 45# CONFIG_FUTEX is not set
189CONFIG_FUTEX=y 46# CONFIG_EPOLL is not set
190CONFIG_EPOLL=y 47# CONFIG_SHMEM is not set
191CONFIG_SHMEM=y 48# CONFIG_SLAB is not set
192CONFIG_SLAB=y 49CONFIG_TINY_SHMEM=y
193CONFIG_VM_EVENT_COUNTERS=y 50CONFIG_BASE_SMALL=1
194# CONFIG_TINY_SHMEM is not set 51CONFIG_SLOB=y
195CONFIG_BASE_SMALL=0 52CONFIG_OBSOLETE_INTERMODULE=y
196# CONFIG_SLOB is not set
197 53
198# 54#
199# Loadable module support 55# Loadable module support
200# 56#
201CONFIG_MODULES=y 57# CONFIG_MODULES is not set
202CONFIG_MODULE_UNLOAD=y
203# CONFIG_MODULE_FORCE_UNLOAD is not set
204CONFIG_MODVERSIONS=y
205CONFIG_MODULE_SRCVERSION_ALL=y
206# CONFIG_KMOD is not set
207 58
208# 59#
209# Block layer 60# Block layer
210# 61#
211# CONFIG_LBD is not set 62# CONFIG_LBD is not set
212# CONFIG_BLK_DEV_IO_TRACE is not set
213# CONFIG_LSF is not set 63# CONFIG_LSF is not set
214 64
215# 65#
216# IO Schedulers 66# IO Schedulers
217# 67#
218CONFIG_IOSCHED_NOOP=y 68CONFIG_IOSCHED_NOOP=y
219CONFIG_IOSCHED_AS=y 69# CONFIG_IOSCHED_AS is not set
220CONFIG_IOSCHED_DEADLINE=y 70# CONFIG_IOSCHED_DEADLINE is not set
221CONFIG_IOSCHED_CFQ=y 71# CONFIG_IOSCHED_CFQ is not set
222CONFIG_DEFAULT_AS=y 72# CONFIG_DEFAULT_AS is not set
223# CONFIG_DEFAULT_DEADLINE is not set 73# CONFIG_DEFAULT_DEADLINE is not set
224# CONFIG_DEFAULT_CFQ is not set 74# CONFIG_DEFAULT_CFQ is not set
225# CONFIG_DEFAULT_NOOP is not set 75CONFIG_DEFAULT_NOOP=y
226CONFIG_DEFAULT_IOSCHED="anticipatory" 76CONFIG_DEFAULT_IOSCHED="noop"
227 77
228# 78#
229# Bus options (PCI, PCMCIA, EISA, ISA, TC) 79# System type
80#
81# CONFIG_SH_SOLUTION_ENGINE is not set
82# CONFIG_SH_7709_SOLUTION_ENGINE is not set
83# CONFIG_SH_7751_SOLUTION_ENGINE is not set
84# CONFIG_SH_7300_SOLUTION_ENGINE is not set
85# CONFIG_SH_73180_SOLUTION_ENGINE is not set
86# CONFIG_SH_7751_SYSTEMH is not set
87# CONFIG_SH_STB1_HARP is not set
88# CONFIG_SH_STB1_OVERDRIVE is not set
89# CONFIG_SH_HP6XX is not set
90# CONFIG_SH_CQREEK is not set
91# CONFIG_SH_DMIDA is not set
92# CONFIG_SH_EC3104 is not set
93# CONFIG_SH_SATURN is not set
94# CONFIG_SH_DREAMCAST is not set
95# CONFIG_SH_CAT68701 is not set
96# CONFIG_SH_BIGSUR is not set
97# CONFIG_SH_SH2000 is not set
98# CONFIG_SH_ADX is not set
99# CONFIG_SH_MPC1211 is not set
100# CONFIG_SH_SH03 is not set
101# CONFIG_SH_SECUREEDGE5410 is not set
102# CONFIG_SH_HS7751RVOIP is not set
103# CONFIG_SH_RTS7751R2D is not set
104# CONFIG_SH_R7780RP is not set
105# CONFIG_SH_EDOSK7705 is not set
106# CONFIG_SH_SH4202_MICRODEV is not set
107# CONFIG_SH_LANDISK is not set
108# CONFIG_SH_TITAN is not set
109CONFIG_SH_SHMIN=y
110# CONFIG_SH_UNKNOWN is not set
111
112#
113# Processor selection
114#
115CONFIG_CPU_SH3=y
116
117#
118# SH-2 Processor Support
119#
120# CONFIG_CPU_SUBTYPE_SH7604 is not set
121
122#
123# SH-3 Processor Support
124#
125# CONFIG_CPU_SUBTYPE_SH7300 is not set
126# CONFIG_CPU_SUBTYPE_SH7705 is not set
127CONFIG_CPU_SUBTYPE_SH7706=y
128# CONFIG_CPU_SUBTYPE_SH7707 is not set
129# CONFIG_CPU_SUBTYPE_SH7708 is not set
130# CONFIG_CPU_SUBTYPE_SH7709 is not set
131
132#
133# SH-4 Processor Support
134#
135# CONFIG_CPU_SUBTYPE_SH7750 is not set
136# CONFIG_CPU_SUBTYPE_SH7091 is not set
137# CONFIG_CPU_SUBTYPE_SH7750R is not set
138# CONFIG_CPU_SUBTYPE_SH7750S is not set
139# CONFIG_CPU_SUBTYPE_SH7751 is not set
140# CONFIG_CPU_SUBTYPE_SH7751R is not set
141# CONFIG_CPU_SUBTYPE_SH7760 is not set
142# CONFIG_CPU_SUBTYPE_SH4_202 is not set
143
144#
145# ST40 Processor Support
146#
147# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
148# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
149
150#
151# SH-4A Processor Support
152#
153# CONFIG_CPU_SUBTYPE_SH73180 is not set
154# CONFIG_CPU_SUBTYPE_SH7770 is not set
155# CONFIG_CPU_SUBTYPE_SH7780 is not set
156
157#
158# Memory management options
230# 159#
231CONFIG_HW_HAS_PCI=y
232# CONFIG_PCI is not set
233CONFIG_MMU=y 160CONFIG_MMU=y
161CONFIG_PAGE_OFFSET=0x80000000
162CONFIG_MEMORY_START=0x0c000000
163CONFIG_MEMORY_SIZE=0x00800000
164CONFIG_SELECT_MEMORY_MODEL=y
165CONFIG_FLATMEM_MANUAL=y
166# CONFIG_DISCONTIGMEM_MANUAL is not set
167# CONFIG_SPARSEMEM_MANUAL is not set
168CONFIG_FLATMEM=y
169CONFIG_FLAT_NODE_MEM_MAP=y
170# CONFIG_SPARSEMEM_STATIC is not set
171CONFIG_SPLIT_PTLOCK_CPUS=4
172
173#
174# Cache configuration
175#
176# CONFIG_SH_DIRECT_MAPPED is not set
177# CONFIG_SH_WRITETHROUGH is not set
178# CONFIG_SH_OCRAM is not set
179
180#
181# Processor features
182#
183CONFIG_CPU_LITTLE_ENDIAN=y
184# CONFIG_SH_FPU_EMU is not set
185# CONFIG_SH_DSP is not set
186# CONFIG_SH_ADC is not set
187CONFIG_CPU_HAS_INTEVT=y
188CONFIG_CPU_HAS_SR_RB=y
189
190#
191# Timer support
192#
193CONFIG_SH_TMU=y
194CONFIG_SH_PCLK_FREQ=32000000
195
196#
197# CPU Frequency scaling
198#
199# CONFIG_CPU_FREQ is not set
200
201#
202# DMA support
203#
204# CONFIG_SH_DMA is not set
205
206#
207# Companion Chips
208#
209# CONFIG_HD6446X_SERIES is not set
210
211#
212# Kernel features
213#
214# CONFIG_KEXEC is not set
215# CONFIG_PREEMPT is not set
216# CONFIG_SMP is not set
217
218#
219# Boot options
220#
221CONFIG_ZERO_PAGE_OFFSET=0x00001000
222CONFIG_BOOT_LINK_OFFSET=0x00210000
223# CONFIG_UBC_WAKEUP is not set
224CONFIG_CMDLINE_BOOL=y
225CONFIG_CMDLINE="console=ttySC1,115200 root=1f01 mtdparts=phys_mapped_flash:64k(firm)ro,-(sys) netdev=34,0x300,eth0 "
226
227#
228# Bus options
229#
230# CONFIG_PCI is not set
234 231
235# 232#
236# PCCARD (PCMCIA/CardBus) support 233# PCCARD (PCMCIA/CardBus) support
@@ -245,8 +242,13 @@ CONFIG_MMU=y
245# Executable file formats 242# Executable file formats
246# 243#
247CONFIG_BINFMT_ELF=y 244CONFIG_BINFMT_ELF=y
245# CONFIG_BINFMT_FLAT is not set
248# CONFIG_BINFMT_MISC is not set 246# CONFIG_BINFMT_MISC is not set
249CONFIG_TRAD_SIGNALS=y 247
248#
249# Power management options (EXPERIMENTAL)
250#
251# CONFIG_PM is not set
250 252
251# 253#
252# Networking 254# Networking
@@ -259,16 +261,14 @@ CONFIG_NET=y
259# CONFIG_NETDEBUG is not set 261# CONFIG_NETDEBUG is not set
260# CONFIG_PACKET is not set 262# CONFIG_PACKET is not set
261CONFIG_UNIX=y 263CONFIG_UNIX=y
262CONFIG_XFRM=y 264# CONFIG_NET_KEY is not set
263CONFIG_XFRM_USER=m
264CONFIG_NET_KEY=y
265CONFIG_INET=y 265CONFIG_INET=y
266# CONFIG_IP_MULTICAST is not set 266# CONFIG_IP_MULTICAST is not set
267# CONFIG_IP_ADVANCED_ROUTER is not set 267# CONFIG_IP_ADVANCED_ROUTER is not set
268CONFIG_IP_FIB_HASH=y 268CONFIG_IP_FIB_HASH=y
269CONFIG_IP_PNP=y 269CONFIG_IP_PNP=y
270# CONFIG_IP_PNP_DHCP is not set 270# CONFIG_IP_PNP_DHCP is not set
271CONFIG_IP_PNP_BOOTP=y 271# CONFIG_IP_PNP_BOOTP is not set
272# CONFIG_IP_PNP_RARP is not set 272# CONFIG_IP_PNP_RARP is not set
273# CONFIG_NET_IPIP is not set 273# CONFIG_NET_IPIP is not set
274# CONFIG_NET_IPGRE is not set 274# CONFIG_NET_IPGRE is not set
@@ -279,8 +279,6 @@ CONFIG_IP_PNP_BOOTP=y
279# CONFIG_INET_IPCOMP is not set 279# CONFIG_INET_IPCOMP is not set
280# CONFIG_INET_XFRM_TUNNEL is not set 280# CONFIG_INET_XFRM_TUNNEL is not set
281# CONFIG_INET_TUNNEL is not set 281# CONFIG_INET_TUNNEL is not set
282CONFIG_INET_XFRM_MODE_TRANSPORT=m
283CONFIG_INET_XFRM_MODE_TUNNEL=m
284CONFIG_INET_DIAG=y 282CONFIG_INET_DIAG=y
285CONFIG_INET_TCP_DIAG=y 283CONFIG_INET_TCP_DIAG=y
286# CONFIG_TCP_CONG_ADVANCED is not set 284# CONFIG_TCP_CONG_ADVANCED is not set
@@ -288,7 +286,6 @@ CONFIG_TCP_CONG_BIC=y
288# CONFIG_IPV6 is not set 286# CONFIG_IPV6 is not set
289# CONFIG_INET6_XFRM_TUNNEL is not set 287# CONFIG_INET6_XFRM_TUNNEL is not set
290# CONFIG_INET6_TUNNEL is not set 288# CONFIG_INET6_TUNNEL is not set
291CONFIG_NETWORK_SECMARK=y
292# CONFIG_NETFILTER is not set 289# CONFIG_NETFILTER is not set
293 290
294# 291#
@@ -330,13 +327,7 @@ CONFIG_NETWORK_SECMARK=y
330# CONFIG_HAMRADIO is not set 327# CONFIG_HAMRADIO is not set
331# CONFIG_IRDA is not set 328# CONFIG_IRDA is not set
332# CONFIG_BT is not set 329# CONFIG_BT is not set
333CONFIG_IEEE80211=m 330# CONFIG_IEEE80211 is not set
334# CONFIG_IEEE80211_DEBUG is not set
335CONFIG_IEEE80211_CRYPT_WEP=m
336CONFIG_IEEE80211_CRYPT_CCMP=m
337CONFIG_IEEE80211_SOFTMAC=m
338# CONFIG_IEEE80211_SOFTMAC_DEBUG is not set
339CONFIG_WIRELESS_EXT=y
340 331
341# 332#
342# Device Drivers 333# Device Drivers
@@ -348,17 +339,92 @@ CONFIG_WIRELESS_EXT=y
348CONFIG_STANDALONE=y 339CONFIG_STANDALONE=y
349CONFIG_PREVENT_FIRMWARE_BUILD=y 340CONFIG_PREVENT_FIRMWARE_BUILD=y
350# CONFIG_FW_LOADER is not set 341# CONFIG_FW_LOADER is not set
351# CONFIG_SYS_HYPERVISOR is not set
352 342
353# 343#
354# Connector - unified userspace <-> kernelspace linker 344# Connector - unified userspace <-> kernelspace linker
355# 345#
356CONFIG_CONNECTOR=m 346# CONFIG_CONNECTOR is not set
357 347
358# 348#
359# Memory Technology Devices (MTD) 349# Memory Technology Devices (MTD)
360# 350#
361# CONFIG_MTD is not set 351CONFIG_MTD=y
352# CONFIG_MTD_DEBUG is not set
353# CONFIG_MTD_CONCAT is not set
354CONFIG_MTD_PARTITIONS=y
355# CONFIG_MTD_REDBOOT_PARTS is not set
356CONFIG_MTD_CMDLINE_PARTS=y
357
358#
359# User Modules And Translation Layers
360#
361# CONFIG_MTD_CHAR is not set
362CONFIG_MTD_BLOCK=y
363# CONFIG_FTL is not set
364# CONFIG_NFTL is not set
365# CONFIG_INFTL is not set
366# CONFIG_RFD_FTL is not set
367
368#
369# RAM/ROM/Flash chip drivers
370#
371# CONFIG_MTD_CFI is not set
372CONFIG_MTD_JEDECPROBE=y
373CONFIG_MTD_GEN_PROBE=y
374# CONFIG_MTD_CFI_ADV_OPTIONS is not set
375CONFIG_MTD_MAP_BANK_WIDTH_1=y
376CONFIG_MTD_MAP_BANK_WIDTH_2=y
377CONFIG_MTD_MAP_BANK_WIDTH_4=y
378# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
379# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
380# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
381CONFIG_MTD_CFI_I1=y
382CONFIG_MTD_CFI_I2=y
383# CONFIG_MTD_CFI_I4 is not set
384# CONFIG_MTD_CFI_I8 is not set
385# CONFIG_MTD_CFI_INTELEXT is not set
386CONFIG_MTD_CFI_AMDSTD=y
387# CONFIG_MTD_CFI_STAA is not set
388CONFIG_MTD_CFI_UTIL=y
389# CONFIG_MTD_RAM is not set
390# CONFIG_MTD_ROM is not set
391# CONFIG_MTD_ABSENT is not set
392# CONFIG_MTD_OBSOLETE_CHIPS is not set
393
394#
395# Mapping drivers for chip access
396#
397# CONFIG_MTD_COMPLEX_MAPPINGS is not set
398CONFIG_MTD_PHYSMAP=y
399CONFIG_MTD_PHYSMAP_START=0xa0000000
400CONFIG_MTD_PHYSMAP_LEN=0x80000
401CONFIG_MTD_PHYSMAP_BANKWIDTH=1
402# CONFIG_MTD_PLATRAM is not set
403
404#
405# Self-contained MTD device drivers
406#
407# CONFIG_MTD_SLRAM is not set
408# CONFIG_MTD_PHRAM is not set
409# CONFIG_MTD_MTDRAM is not set
410# CONFIG_MTD_BLOCK2MTD is not set
411
412#
413# Disk-On-Chip Device Drivers
414#
415# CONFIG_MTD_DOC2000 is not set
416# CONFIG_MTD_DOC2001 is not set
417# CONFIG_MTD_DOC2001PLUS is not set
418
419#
420# NAND Flash Device Drivers
421#
422# CONFIG_MTD_NAND is not set
423
424#
425# OneNAND Flash Device Drivers
426#
427# CONFIG_MTD_ONENAND is not set
362 428
363# 429#
364# Parallel port support 430# Parallel port support
@@ -373,14 +439,13 @@ CONFIG_CONNECTOR=m
373# Block devices 439# Block devices
374# 440#
375# CONFIG_BLK_DEV_COW_COMMON is not set 441# CONFIG_BLK_DEV_COW_COMMON is not set
376# CONFIG_BLK_DEV_LOOP is not set 442CONFIG_BLK_DEV_LOOP=y
443# CONFIG_BLK_DEV_CRYPTOLOOP is not set
377# CONFIG_BLK_DEV_NBD is not set 444# CONFIG_BLK_DEV_NBD is not set
378# CONFIG_BLK_DEV_RAM is not set 445# CONFIG_BLK_DEV_RAM is not set
379# CONFIG_BLK_DEV_INITRD is not set 446# CONFIG_BLK_DEV_INITRD is not set
380CONFIG_CDROM_PKTCDVD=m 447# CONFIG_CDROM_PKTCDVD is not set
381CONFIG_CDROM_PKTCDVD_BUFFERS=8 448# CONFIG_ATA_OVER_ETH is not set
382# CONFIG_CDROM_PKTCDVD_WCACHE is not set
383CONFIG_ATA_OVER_ETH=m
384 449
385# 450#
386# ATA/ATAPI/MFM/RLL support 451# ATA/ATAPI/MFM/RLL support
@@ -390,7 +455,7 @@ CONFIG_ATA_OVER_ETH=m
390# 455#
391# SCSI device support 456# SCSI device support
392# 457#
393CONFIG_RAID_ATTRS=m 458# CONFIG_RAID_ATTRS is not set
394# CONFIG_SCSI is not set 459# CONFIG_SCSI is not set
395 460
396# 461#
@@ -423,26 +488,16 @@ CONFIG_NETDEVICES=y
423# 488#
424# PHY device support 489# PHY device support
425# 490#
426CONFIG_PHYLIB=m 491# CONFIG_PHYLIB is not set
427
428#
429# MII PHY device drivers
430#
431CONFIG_MARVELL_PHY=m
432CONFIG_DAVICOM_PHY=m
433CONFIG_QSEMI_PHY=m
434CONFIG_LXT_PHY=m
435CONFIG_CICADA_PHY=m
436CONFIG_VITESSE_PHY=m
437CONFIG_SMSC_PHY=m
438 492
439# 493#
440# Ethernet (10 or 100Mbit) 494# Ethernet (10 or 100Mbit)
441# 495#
442CONFIG_NET_ETHERNET=y 496CONFIG_NET_ETHERNET=y
443# CONFIG_MII is not set 497# CONFIG_MII is not set
444CONFIG_MIPS_GT96100ETH=y 498# CONFIG_STNIC is not set
445# CONFIG_DM9000 is not set 499# CONFIG_SMC91X is not set
500CONFIG_NE2000=y
446 501
447# 502#
448# Ethernet (1000 Mbit) 503# Ethernet (1000 Mbit)
@@ -485,60 +540,31 @@ CONFIG_MIPS_GT96100ETH=y
485# 540#
486# Input device support 541# Input device support
487# 542#
488CONFIG_INPUT=y 543# CONFIG_INPUT is not set
489
490#
491# Userland interfaces
492#
493CONFIG_INPUT_MOUSEDEV=y
494CONFIG_INPUT_MOUSEDEV_PSAUX=y
495CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
496CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
497# CONFIG_INPUT_JOYDEV is not set
498# CONFIG_INPUT_TSDEV is not set
499# CONFIG_INPUT_EVDEV is not set
500# CONFIG_INPUT_EVBUG is not set
501
502#
503# Input Device Drivers
504#
505# CONFIG_INPUT_KEYBOARD is not set
506# CONFIG_INPUT_MOUSE is not set
507# CONFIG_INPUT_JOYSTICK is not set
508# CONFIG_INPUT_TOUCHSCREEN is not set
509# CONFIG_INPUT_MISC is not set
510 544
511# 545#
512# Hardware I/O ports 546# Hardware I/O ports
513# 547#
514CONFIG_SERIO=y 548# CONFIG_SERIO is not set
515# CONFIG_SERIO_I8042 is not set
516CONFIG_SERIO_SERPORT=y
517# CONFIG_SERIO_LIBPS2 is not set
518CONFIG_SERIO_RAW=m
519# CONFIG_GAMEPORT is not set 549# CONFIG_GAMEPORT is not set
520 550
521# 551#
522# Character devices 552# Character devices
523# 553#
524CONFIG_VT=y 554# CONFIG_VT is not set
525CONFIG_VT_CONSOLE=y
526CONFIG_HW_CONSOLE=y
527CONFIG_VT_HW_CONSOLE_BINDING=y
528# CONFIG_SERIAL_NONSTANDARD is not set 555# CONFIG_SERIAL_NONSTANDARD is not set
529 556
530# 557#
531# Serial drivers 558# Serial drivers
532# 559#
533CONFIG_SERIAL_8250=y 560# CONFIG_SERIAL_8250 is not set
534CONFIG_SERIAL_8250_CONSOLE=y
535CONFIG_SERIAL_8250_NR_UARTS=4
536CONFIG_SERIAL_8250_RUNTIME_UARTS=4
537# CONFIG_SERIAL_8250_EXTENDED is not set
538 561
539# 562#
540# Non-8250 serial port support 563# Non-8250 serial port support
541# 564#
565CONFIG_SERIAL_SH_SCI=y
566CONFIG_SERIAL_SH_SCI_NR_UARTS=2
567CONFIG_SERIAL_SH_SCI_CONSOLE=y
542CONFIG_SERIAL_CORE=y 568CONFIG_SERIAL_CORE=y
543CONFIG_SERIAL_CORE_CONSOLE=y 569CONFIG_SERIAL_CORE_CONSOLE=y
544CONFIG_UNIX98_PTYS=y 570CONFIG_UNIX98_PTYS=y
@@ -554,7 +580,6 @@ CONFIG_LEGACY_PTY_COUNT=256
554# Watchdog Cards 580# Watchdog Cards
555# 581#
556# CONFIG_WATCHDOG is not set 582# CONFIG_WATCHDOG is not set
557# CONFIG_HW_RANDOM is not set
558# CONFIG_RTC is not set 583# CONFIG_RTC is not set
559# CONFIG_GEN_RTC is not set 584# CONFIG_GEN_RTC is not set
560# CONFIG_DTLK is not set 585# CONFIG_DTLK is not set
@@ -611,16 +636,9 @@ CONFIG_VIDEO_V4L2=y
611# 636#
612# Graphics support 637# Graphics support
613# 638#
614# CONFIG_FIRMWARE_EDID is not set
615# CONFIG_FB is not set 639# CONFIG_FB is not set
616 640
617# 641#
618# Console display driver support
619#
620# CONFIG_VGA_CONSOLE is not set
621CONFIG_DUMMY_CONSOLE=y
622
623#
624# Sound 642# Sound
625# 643#
626# CONFIG_SOUND is not set 644# CONFIG_SOUND is not set
@@ -673,24 +691,9 @@ CONFIG_DUMMY_CONSOLE=y
673# CONFIG_RTC_CLASS is not set 691# CONFIG_RTC_CLASS is not set
674 692
675# 693#
676# DMA Engine support
677#
678# CONFIG_DMA_ENGINE is not set
679
680#
681# DMA Clients
682#
683
684#
685# DMA Devices
686#
687
688#
689# File systems 694# File systems
690# 695#
691CONFIG_EXT2_FS=y 696# CONFIG_EXT2_FS is not set
692# CONFIG_EXT2_FS_XATTR is not set
693# CONFIG_EXT2_FS_XIP is not set
694# CONFIG_EXT3_FS is not set 697# CONFIG_EXT3_FS is not set
695# CONFIG_REISERFS_FS is not set 698# CONFIG_REISERFS_FS is not set
696# CONFIG_JFS_FS is not set 699# CONFIG_JFS_FS is not set
@@ -699,13 +702,12 @@ CONFIG_EXT2_FS=y
699# CONFIG_OCFS2_FS is not set 702# CONFIG_OCFS2_FS is not set
700# CONFIG_MINIX_FS is not set 703# CONFIG_MINIX_FS is not set
701# CONFIG_ROMFS_FS is not set 704# CONFIG_ROMFS_FS is not set
702CONFIG_INOTIFY=y 705# CONFIG_INOTIFY is not set
703CONFIG_INOTIFY_USER=y
704# CONFIG_QUOTA is not set 706# CONFIG_QUOTA is not set
705CONFIG_DNOTIFY=y 707# CONFIG_DNOTIFY is not set
706# CONFIG_AUTOFS_FS is not set 708# CONFIG_AUTOFS_FS is not set
707# CONFIG_AUTOFS4_FS is not set 709# CONFIG_AUTOFS4_FS is not set
708CONFIG_FUSE_FS=m 710# CONFIG_FUSE_FS is not set
709 711
710# 712#
711# CD-ROM/DVD Filesystems 713# CD-ROM/DVD Filesystems
@@ -724,12 +726,12 @@ CONFIG_FUSE_FS=m
724# Pseudo filesystems 726# Pseudo filesystems
725# 727#
726CONFIG_PROC_FS=y 728CONFIG_PROC_FS=y
727CONFIG_PROC_KCORE=y 729# CONFIG_PROC_KCORE is not set
728CONFIG_SYSFS=y 730# CONFIG_SYSFS is not set
729# CONFIG_TMPFS is not set 731CONFIG_TMPFS=y
732# CONFIG_HUGETLBFS is not set
730# CONFIG_HUGETLB_PAGE is not set 733# CONFIG_HUGETLB_PAGE is not set
731CONFIG_RAMFS=y 734CONFIG_RAMFS=y
732# CONFIG_CONFIGFS_FS is not set
733 735
734# 736#
735# Miscellaneous filesystems 737# Miscellaneous filesystems
@@ -741,7 +743,9 @@ CONFIG_RAMFS=y
741# CONFIG_BEFS_FS is not set 743# CONFIG_BEFS_FS is not set
742# CONFIG_BFS_FS is not set 744# CONFIG_BFS_FS is not set
743# CONFIG_EFS_FS is not set 745# CONFIG_EFS_FS is not set
744# CONFIG_CRAMFS is not set 746# CONFIG_JFFS_FS is not set
747# CONFIG_JFFS2_FS is not set
748CONFIG_CRAMFS=y
745# CONFIG_VXFS_FS is not set 749# CONFIG_VXFS_FS is not set
746# CONFIG_HPFS_FS is not set 750# CONFIG_HPFS_FS is not set
747# CONFIG_QNX4FS_FS is not set 751# CONFIG_QNX4FS_FS is not set
@@ -752,19 +756,20 @@ CONFIG_RAMFS=y
752# Network File Systems 756# Network File Systems
753# 757#
754CONFIG_NFS_FS=y 758CONFIG_NFS_FS=y
755# CONFIG_NFS_V3 is not set 759CONFIG_NFS_V3=y
760# CONFIG_NFS_V3_ACL is not set
756# CONFIG_NFS_V4 is not set 761# CONFIG_NFS_V4 is not set
757# CONFIG_NFS_DIRECTIO is not set 762# CONFIG_NFS_DIRECTIO is not set
758# CONFIG_NFSD is not set 763# CONFIG_NFSD is not set
759CONFIG_ROOT_NFS=y 764CONFIG_ROOT_NFS=y
760CONFIG_LOCKD=y 765CONFIG_LOCKD=y
766CONFIG_LOCKD_V4=y
761CONFIG_NFS_COMMON=y 767CONFIG_NFS_COMMON=y
762CONFIG_SUNRPC=y 768CONFIG_SUNRPC=y
763# CONFIG_RPCSEC_GSS_KRB5 is not set 769# CONFIG_RPCSEC_GSS_KRB5 is not set
764# CONFIG_RPCSEC_GSS_SPKM3 is not set 770# CONFIG_RPCSEC_GSS_SPKM3 is not set
765# CONFIG_SMB_FS is not set 771# CONFIG_SMB_FS is not set
766# CONFIG_CIFS is not set 772# CONFIG_CIFS is not set
767# CONFIG_CIFS_DEBUG2 is not set
768# CONFIG_NCP_FS is not set 773# CONFIG_NCP_FS is not set
769# CONFIG_CODA_FS is not set 774# CONFIG_CODA_FS is not set
770# CONFIG_AFS_FS is not set 775# CONFIG_AFS_FS is not set
@@ -791,48 +796,22 @@ CONFIG_MSDOS_PARTITION=y
791# 796#
792# CONFIG_PRINTK_TIME is not set 797# CONFIG_PRINTK_TIME is not set
793# CONFIG_MAGIC_SYSRQ is not set 798# CONFIG_MAGIC_SYSRQ is not set
794# CONFIG_UNUSED_SYMBOLS is not set
795# CONFIG_DEBUG_KERNEL is not set 799# CONFIG_DEBUG_KERNEL is not set
796CONFIG_LOG_BUF_SHIFT=14 800CONFIG_LOG_BUF_SHIFT=14
797# CONFIG_DEBUG_FS is not set 801# CONFIG_UNWIND_INFO is not set
798CONFIG_CROSSCOMPILE=y 802CONFIG_SH_STANDARD_BIOS=y
799CONFIG_CMDLINE="" 803CONFIG_EARLY_PRINTK=y
804# CONFIG_KGDB is not set
800 805
801# 806#
802# Security options 807# Security options
803# 808#
804CONFIG_KEYS=y 809# CONFIG_KEYS is not set
805CONFIG_KEYS_DEBUG_PROC_KEYS=y
806# CONFIG_SECURITY is not set
807 810
808# 811#
809# Cryptographic options 812# Cryptographic options
810# 813#
811CONFIG_CRYPTO=y 814# CONFIG_CRYPTO is not set
812CONFIG_CRYPTO_HMAC=y
813CONFIG_CRYPTO_NULL=m
814CONFIG_CRYPTO_MD4=m
815CONFIG_CRYPTO_MD5=m
816CONFIG_CRYPTO_SHA1=m
817CONFIG_CRYPTO_SHA256=m
818CONFIG_CRYPTO_SHA512=m
819CONFIG_CRYPTO_WP512=m
820CONFIG_CRYPTO_TGR192=m
821CONFIG_CRYPTO_DES=m
822CONFIG_CRYPTO_BLOWFISH=m
823CONFIG_CRYPTO_TWOFISH=m
824CONFIG_CRYPTO_SERPENT=m
825CONFIG_CRYPTO_AES=m
826CONFIG_CRYPTO_CAST5=m
827CONFIG_CRYPTO_CAST6=m
828CONFIG_CRYPTO_TEA=m
829CONFIG_CRYPTO_ARC4=m
830CONFIG_CRYPTO_KHAZAD=m
831CONFIG_CRYPTO_ANUBIS=m
832CONFIG_CRYPTO_DEFLATE=m
833CONFIG_CRYPTO_MICHAEL_MIC=m
834CONFIG_CRYPTO_CRC32C=m
835# CONFIG_CRYPTO_TEST is not set
836 815
837# 816#
838# Hardware crypto devices 817# Hardware crypto devices
@@ -842,9 +821,7 @@ CONFIG_CRYPTO_CRC32C=m
842# Library routines 821# Library routines
843# 822#
844# CONFIG_CRC_CCITT is not set 823# CONFIG_CRC_CCITT is not set
845CONFIG_CRC16=m 824# CONFIG_CRC16 is not set
846CONFIG_CRC32=m 825CONFIG_CRC32=y
847CONFIG_LIBCRC32C=m 826# CONFIG_LIBCRC32C is not set
848CONFIG_ZLIB_INFLATE=m 827CONFIG_ZLIB_INFLATE=y
849CONFIG_ZLIB_DEFLATE=m
850CONFIG_PLIST=y
diff --git a/arch/sh/configs/titan_defconfig b/arch/sh/configs/titan_defconfig
new file mode 100644
index 000000000000..1db2904de9e5
--- /dev/null
+++ b/arch/sh/configs/titan_defconfig
@@ -0,0 +1,1367 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.14-sh
4# Wed Nov 9 00:35:56 2005
5#
6CONFIG_SUPERH=y
7CONFIG_UID16=y
8CONFIG_RWSEM_GENERIC_SPINLOCK=y
9CONFIG_GENERIC_HARDIRQS=y
10CONFIG_GENERIC_IRQ_PROBE=y
11CONFIG_GENERIC_CALIBRATE_DELAY=y
12CONFIG_GENERIC_IOMAP=y
13
14#
15# Code maturity level options
16#
17CONFIG_EXPERIMENTAL=y
18CONFIG_CLEAN_COMPILE=y
19CONFIG_BROKEN_ON_SMP=y
20CONFIG_INIT_ENV_ARG_LIMIT=32
21
22#
23# General setup
24#
25CONFIG_LOCALVERSION=""
26CONFIG_LOCALVERSION_AUTO=y
27CONFIG_SWAP=y
28CONFIG_SYSVIPC=y
29# CONFIG_POSIX_MQUEUE is not set
30# CONFIG_BSD_PROCESS_ACCT is not set
31CONFIG_SYSCTL=y
32# CONFIG_AUDIT is not set
33CONFIG_HOTPLUG=y
34CONFIG_KOBJECT_UEVENT=y
35CONFIG_IKCONFIG=y
36CONFIG_IKCONFIG_PROC=y
37CONFIG_INITRAMFS_SOURCE=""
38# CONFIG_EMBEDDED is not set
39CONFIG_KALLSYMS=y
40# CONFIG_KALLSYMS_ALL is not set
41# CONFIG_KALLSYMS_EXTRA_PASS is not set
42CONFIG_PRINTK=y
43CONFIG_BUG=y
44CONFIG_BASE_FULL=y
45CONFIG_FUTEX=y
46CONFIG_EPOLL=y
47CONFIG_SHMEM=y
48CONFIG_CC_ALIGN_FUNCTIONS=0
49CONFIG_CC_ALIGN_LABELS=0
50CONFIG_CC_ALIGN_LOOPS=0
51CONFIG_CC_ALIGN_JUMPS=0
52# CONFIG_TINY_SHMEM is not set
53CONFIG_BASE_SMALL=0
54
55#
56# Loadable module support
57#
58CONFIG_MODULES=y
59CONFIG_MODULE_UNLOAD=y
60CONFIG_MODULE_FORCE_UNLOAD=y
61CONFIG_OBSOLETE_MODPARM=y
62# CONFIG_MODVERSIONS is not set
63# CONFIG_MODULE_SRCVERSION_ALL is not set
64CONFIG_KMOD=y
65
66#
67# System type
68#
69# CONFIG_SH_SOLUTION_ENGINE is not set
70# CONFIG_SH_7751_SOLUTION_ENGINE is not set
71# CONFIG_SH_7300_SOLUTION_ENGINE is not set
72# CONFIG_SH_73180_SOLUTION_ENGINE is not set
73# CONFIG_SH_7751_SYSTEMH is not set
74CONFIG_SH_TITAN=y
75# CONFIG_SH_STB1_HARP is not set
76# CONFIG_SH_STB1_OVERDRIVE is not set
77# CONFIG_SH_HP6XX is not set
78# CONFIG_SH_CQREEK is not set
79# CONFIG_SH_DMIDA is not set
80# CONFIG_SH_EC3104 is not set
81# CONFIG_SH_SATURN is not set
82# CONFIG_SH_DREAMCAST is not set
83# CONFIG_SH_CAT68701 is not set
84# CONFIG_SH_BIGSUR is not set
85# CONFIG_SH_SH2000 is not set
86# CONFIG_SH_ADX is not set
87# CONFIG_SH_MPC1211 is not set
88# CONFIG_SH_SH03 is not set
89# CONFIG_SH_SECUREEDGE5410 is not set
90# CONFIG_SH_HS7751RVOIP is not set
91# CONFIG_SH_RTS7751R2D is not set
92# CONFIG_SH_EDOSK7705 is not set
93# CONFIG_SH_SH4202_MICRODEV is not set
94# CONFIG_SH_LANDISK is not set
95# CONFIG_SH_UNKNOWN is not set
96
97#
98# Processor selection
99#
100CONFIG_CPU_SH4=y
101
102#
103# SH-2 Processor Support
104#
105# CONFIG_CPU_SUBTYPE_SH7604 is not set
106
107#
108# SH-3 Processor Support
109#
110# CONFIG_CPU_SUBTYPE_SH7300 is not set
111# CONFIG_CPU_SUBTYPE_SH7705 is not set
112# CONFIG_CPU_SUBTYPE_SH7707 is not set
113# CONFIG_CPU_SUBTYPE_SH7708 is not set
114# CONFIG_CPU_SUBTYPE_SH7709 is not set
115
116#
117# SH-4 Processor Support
118#
119# CONFIG_CPU_SUBTYPE_SH7750 is not set
120# CONFIG_CPU_SUBTYPE_SH7091 is not set
121# CONFIG_CPU_SUBTYPE_SH7750R is not set
122# CONFIG_CPU_SUBTYPE_SH7750S is not set
123CONFIG_CPU_SUBTYPE_SH7751=y
124CONFIG_CPU_SUBTYPE_SH7751R=y
125# CONFIG_CPU_SUBTYPE_SH7760 is not set
126# CONFIG_CPU_SUBTYPE_SH4_202 is not set
127
128#
129# ST40 Processor Support
130#
131# CONFIG_CPU_SUBTYPE_ST40STB1 is not set
132# CONFIG_CPU_SUBTYPE_ST40GX1 is not set
133
134#
135# SH-4A Processor Support
136#
137# CONFIG_CPU_SUBTYPE_SH73180 is not set
138# CONFIG_CPU_SUBTYPE_SH7770 is not set
139# CONFIG_CPU_SUBTYPE_SH7780 is not set
140
141#
142# Memory management options
143#
144CONFIG_MMU=y
145CONFIG_SELECT_MEMORY_MODEL=y
146CONFIG_FLATMEM_MANUAL=y
147# CONFIG_DISCONTIGMEM_MANUAL is not set
148# CONFIG_SPARSEMEM_MANUAL is not set
149CONFIG_FLATMEM=y
150CONFIG_FLAT_NODE_MEM_MAP=y
151# CONFIG_SPARSEMEM_STATIC is not set
152
153#
154# Cache configuration
155#
156# CONFIG_SH_DIRECT_MAPPED is not set
157# CONFIG_SH_WRITETHROUGH is not set
158# CONFIG_SH_OCRAM is not set
159CONFIG_MEMORY_START=0x08030000
160CONFIG_MEMORY_SIZE=0x7fd0000
161
162#
163# Processor features
164#
165CONFIG_CPU_LITTLE_ENDIAN=y
166CONFIG_SH_RTC=y
167CONFIG_SH_FPU=y
168# CONFIG_SH_STORE_QUEUES is not set
169
170#
171# Timer support
172#
173CONFIG_SH_TMU=y
174CONFIG_SH_PCLK_FREQ_BOOL=y
175CONFIG_SH_PCLK_FREQ=30000000
176
177#
178# CPU Frequency scaling
179#
180# CONFIG_CPU_FREQ is not set
181
182#
183# DMA support
184#
185CONFIG_SH_DMA=y
186CONFIG_NR_ONCHIP_DMA_CHANNELS=8
187# CONFIG_NR_DMA_CHANNELS_BOOL is not set
188
189#
190# Companion Chips
191#
192# CONFIG_HD6446X_SERIES is not set
193
194#
195# Kernel features
196#
197# CONFIG_KEXEC is not set
198# CONFIG_PREEMPT is not set
199# CONFIG_SMP is not set
200
201#
202# Boot options
203#
204CONFIG_ZERO_PAGE_OFFSET=0x00001000
205CONFIG_BOOT_LINK_OFFSET=0x009e0000
206# CONFIG_UBC_WAKEUP is not set
207CONFIG_CMDLINE_BOOL=y
208CONFIG_CMDLINE="console=ttySC1,38400N81 root=/dev/nfs ip=:::::eth1:autoconf"
209
210#
211# Bus options
212#
213CONFIG_PCI=y
214CONFIG_SH_PCIDMA_NONCOHERENT=y
215CONFIG_PCI_AUTO=y
216CONFIG_PCI_AUTO_UPDATE_RESOURCES=y
217CONFIG_PCI_LEGACY_PROC=y
218#CONFIG_PCI_DEBUG is not set
219
220#
221# PCCARD (PCMCIA/CardBus) support
222#
223# CONFIG_PCCARD is not set
224
225#
226# PCI Hotplug Support
227#
228CONFIG_HOTPLUG_PCI=y
229# CONFIG_HOTPLUG_PCI_FAKE is not set
230# CONFIG_HOTPLUG_PCI_CPCI is not set
231# CONFIG_HOTPLUG_PCI_SHPC is not set
232
233#
234# Executable file formats
235#
236CONFIG_BINFMT_ELF=y
237# CONFIG_BINFMT_FLAT is not set
238# CONFIG_BINFMT_MISC is not set
239
240#
241# Networking
242#
243CONFIG_NET=y
244
245#
246# Networking options
247#
248CONFIG_PACKET=y
249CONFIG_PACKET_MMAP=y
250CONFIG_UNIX=y
251CONFIG_XFRM=y
252# CONFIG_XFRM_USER is not set
253CONFIG_NET_KEY=y
254CONFIG_INET=y
255CONFIG_IP_MULTICAST=y
256CONFIG_IP_ADVANCED_ROUTER=y
257CONFIG_ASK_IP_FIB_HASH=y
258# CONFIG_IP_FIB_TRIE is not set
259CONFIG_IP_FIB_HASH=y
260CONFIG_IP_MULTIPLE_TABLES=y
261# CONFIG_IP_ROUTE_FWMARK is not set
262CONFIG_IP_ROUTE_MULTIPATH=y
263CONFIG_IP_ROUTE_MULTIPATH_CACHED=y
264CONFIG_IP_ROUTE_MULTIPATH_RR=m
265CONFIG_IP_ROUTE_MULTIPATH_RANDOM=m
266CONFIG_IP_ROUTE_MULTIPATH_WRANDOM=m
267CONFIG_IP_ROUTE_MULTIPATH_DRR=m
268# CONFIG_IP_ROUTE_VERBOSE is not set
269CONFIG_IP_PNP=y
270CONFIG_IP_PNP_DHCP=y
271CONFIG_IP_PNP_BOOTP=y
272CONFIG_IP_PNP_RARP=y
273CONFIG_NET_IPIP=m
274CONFIG_NET_IPGRE=m
275CONFIG_NET_IPGRE_BROADCAST=y
276CONFIG_IP_MROUTE=y
277CONFIG_IP_PIMSM_V1=y
278CONFIG_IP_PIMSM_V2=y
279# CONFIG_ARPD is not set
280CONFIG_SYN_COOKIES=y
281CONFIG_INET_AH=m
282CONFIG_INET_ESP=m
283CONFIG_INET_IPCOMP=m
284CONFIG_INET_TUNNEL=m
285CONFIG_INET_DIAG=m
286CONFIG_INET_TCP_DIAG=m
287# CONFIG_TCP_CONG_ADVANCED is not set
288CONFIG_TCP_CONG_BIC=y
289
290#
291# IP: Virtual Server Configuration
292#
293# CONFIG_IP_VS is not set
294CONFIG_IPV6=m
295CONFIG_IPV6_PRIVACY=y
296CONFIG_INET6_AH=m
297CONFIG_INET6_ESP=m
298CONFIG_INET6_IPCOMP=m
299CONFIG_INET6_TUNNEL=m
300CONFIG_IPV6_TUNNEL=m
301CONFIG_NETFILTER=y
302# CONFIG_NETFILTER_DEBUG is not set
303CONFIG_BRIDGE_NETFILTER=y
304CONFIG_NETFILTER_NETLINK=m
305CONFIG_NETFILTER_NETLINK_QUEUE=m
306CONFIG_NETFILTER_NETLINK_LOG=m
307
308#
309# IP: Netfilter Configuration
310#
311CONFIG_IP_NF_CONNTRACK=m
312CONFIG_IP_NF_CT_ACCT=y
313CONFIG_IP_NF_CONNTRACK_MARK=y
314CONFIG_IP_NF_CONNTRACK_EVENTS=y
315CONFIG_IP_NF_CONNTRACK_NETLINK=m
316# CONFIG_IP_NF_CT_PROTO_SCTP is not set
317CONFIG_IP_NF_FTP=m
318CONFIG_IP_NF_IRC=m
319CONFIG_IP_NF_NETBIOS_NS=m
320CONFIG_IP_NF_TFTP=m
321# CONFIG_IP_NF_AMANDA is not set
322CONFIG_IP_NF_PPTP=m
323CONFIG_IP_NF_QUEUE=m
324CONFIG_IP_NF_IPTABLES=m
325CONFIG_IP_NF_MATCH_LIMIT=m
326CONFIG_IP_NF_MATCH_IPRANGE=m
327CONFIG_IP_NF_MATCH_MAC=m
328CONFIG_IP_NF_MATCH_PKTTYPE=m
329CONFIG_IP_NF_MATCH_MARK=m
330CONFIG_IP_NF_MATCH_MULTIPORT=m
331CONFIG_IP_NF_MATCH_TOS=m
332CONFIG_IP_NF_MATCH_RECENT=m
333CONFIG_IP_NF_MATCH_ECN=m
334CONFIG_IP_NF_MATCH_DSCP=m
335CONFIG_IP_NF_MATCH_AH_ESP=m
336CONFIG_IP_NF_MATCH_LENGTH=m
337CONFIG_IP_NF_MATCH_TTL=m
338CONFIG_IP_NF_MATCH_TCPMSS=m
339CONFIG_IP_NF_MATCH_HELPER=m
340CONFIG_IP_NF_MATCH_STATE=m
341CONFIG_IP_NF_MATCH_CONNTRACK=m
342CONFIG_IP_NF_MATCH_OWNER=m
343# CONFIG_IP_NF_MATCH_PHYSDEV is not set
344CONFIG_IP_NF_MATCH_ADDRTYPE=m
345CONFIG_IP_NF_MATCH_REALM=m
346# CONFIG_IP_NF_MATCH_SCTP is not set
347# CONFIG_IP_NF_MATCH_DCCP is not set
348CONFIG_IP_NF_MATCH_COMMENT=m
349CONFIG_IP_NF_MATCH_CONNMARK=m
350CONFIG_IP_NF_MATCH_CONNBYTES=m
351CONFIG_IP_NF_MATCH_HASHLIMIT=m
352CONFIG_IP_NF_MATCH_STRING=m
353CONFIG_IP_NF_FILTER=m
354CONFIG_IP_NF_TARGET_REJECT=m
355CONFIG_IP_NF_TARGET_LOG=m
356CONFIG_IP_NF_TARGET_ULOG=m
357CONFIG_IP_NF_TARGET_TCPMSS=m
358CONFIG_IP_NF_TARGET_NFQUEUE=m
359CONFIG_IP_NF_NAT=m
360CONFIG_IP_NF_NAT_NEEDED=y
361CONFIG_IP_NF_TARGET_MASQUERADE=m
362CONFIG_IP_NF_TARGET_REDIRECT=m
363CONFIG_IP_NF_TARGET_NETMAP=m
364CONFIG_IP_NF_TARGET_SAME=m
365CONFIG_IP_NF_NAT_SNMP_BASIC=m
366CONFIG_IP_NF_NAT_IRC=m
367CONFIG_IP_NF_NAT_FTP=m
368CONFIG_IP_NF_NAT_TFTP=m
369CONFIG_IP_NF_NAT_PPTP=m
370CONFIG_IP_NF_MANGLE=m
371CONFIG_IP_NF_TARGET_TOS=m
372CONFIG_IP_NF_TARGET_ECN=m
373CONFIG_IP_NF_TARGET_DSCP=m
374CONFIG_IP_NF_TARGET_MARK=m
375CONFIG_IP_NF_TARGET_CLASSIFY=m
376CONFIG_IP_NF_TARGET_TTL=m
377CONFIG_IP_NF_TARGET_CONNMARK=m
378CONFIG_IP_NF_TARGET_CLUSTERIP=m
379CONFIG_IP_NF_RAW=m
380CONFIG_IP_NF_TARGET_NOTRACK=m
381CONFIG_IP_NF_ARPTABLES=m
382CONFIG_IP_NF_ARPFILTER=m
383CONFIG_IP_NF_ARP_MANGLE=m
384
385#
386# IPv6: Netfilter Configuration (EXPERIMENTAL)
387#
388CONFIG_IP6_NF_QUEUE=m
389CONFIG_IP6_NF_IPTABLES=m
390CONFIG_IP6_NF_MATCH_LIMIT=m
391CONFIG_IP6_NF_MATCH_MAC=m
392CONFIG_IP6_NF_MATCH_RT=m
393CONFIG_IP6_NF_MATCH_OPTS=m
394CONFIG_IP6_NF_MATCH_FRAG=m
395CONFIG_IP6_NF_MATCH_HL=m
396CONFIG_IP6_NF_MATCH_MULTIPORT=m
397CONFIG_IP6_NF_MATCH_OWNER=m
398CONFIG_IP6_NF_MATCH_MARK=m
399CONFIG_IP6_NF_MATCH_IPV6HEADER=m
400CONFIG_IP6_NF_MATCH_AHESP=m
401CONFIG_IP6_NF_MATCH_LENGTH=m
402CONFIG_IP6_NF_MATCH_EUI64=m
403# CONFIG_IP6_NF_MATCH_PHYSDEV is not set
404CONFIG_IP6_NF_FILTER=m
405CONFIG_IP6_NF_TARGET_LOG=m
406CONFIG_IP6_NF_TARGET_REJECT=m
407CONFIG_IP6_NF_TARGET_NFQUEUE=m
408CONFIG_IP6_NF_MANGLE=m
409CONFIG_IP6_NF_TARGET_MARK=m
410CONFIG_IP6_NF_TARGET_HL=m
411CONFIG_IP6_NF_RAW=m
412
413#
414# Bridge: Netfilter Configuration
415#
416# CONFIG_BRIDGE_NF_EBTABLES is not set
417
418#
419# DCCP Configuration (EXPERIMENTAL)
420#
421# CONFIG_IP_DCCP is not set
422
423#
424# SCTP Configuration (EXPERIMENTAL)
425#
426# CONFIG_IP_SCTP is not set
427# CONFIG_ATM is not set
428CONFIG_BRIDGE=m
429CONFIG_VLAN_8021Q=m
430# CONFIG_DECNET is not set
431# CONFIG_LLC2 is not set
432# CONFIG_IPX is not set
433# CONFIG_ATALK is not set
434# CONFIG_X25 is not set
435# CONFIG_LAPB is not set
436# CONFIG_NET_DIVERT is not set
437# CONFIG_ECONET is not set
438# CONFIG_WAN_ROUTER is not set
439CONFIG_NET_SCHED=y
440CONFIG_NET_SCH_CLK_JIFFIES=y
441# CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set
442# CONFIG_NET_SCH_CLK_CPU is not set
443CONFIG_NET_SCH_CBQ=m
444CONFIG_NET_SCH_HTB=m
445CONFIG_NET_SCH_HFSC=m
446CONFIG_NET_SCH_PRIO=m
447CONFIG_NET_SCH_RED=m
448CONFIG_NET_SCH_SFQ=m
449CONFIG_NET_SCH_TEQL=m
450CONFIG_NET_SCH_TBF=m
451CONFIG_NET_SCH_GRED=m
452CONFIG_NET_SCH_DSMARK=m
453CONFIG_NET_SCH_NETEM=m
454CONFIG_NET_SCH_INGRESS=m
455CONFIG_NET_QOS=y
456CONFIG_NET_ESTIMATOR=y
457CONFIG_NET_CLS=y
458CONFIG_NET_CLS_BASIC=m
459CONFIG_NET_CLS_TCINDEX=m
460CONFIG_NET_CLS_ROUTE4=m
461CONFIG_NET_CLS_ROUTE=y
462CONFIG_NET_CLS_FW=m
463CONFIG_NET_CLS_U32=m
464CONFIG_CLS_U32_PERF=y
465CONFIG_NET_CLS_IND=y
466CONFIG_CLS_U32_MARK=y
467CONFIG_NET_CLS_RSVP=m
468CONFIG_NET_CLS_RSVP6=m
469CONFIG_NET_EMATCH=y
470CONFIG_NET_EMATCH_STACK=32
471CONFIG_NET_EMATCH_CMP=m
472CONFIG_NET_EMATCH_NBYTE=m
473CONFIG_NET_EMATCH_U32=m
474CONFIG_NET_EMATCH_META=m
475CONFIG_NET_EMATCH_TEXT=m
476CONFIG_NET_CLS_ACT=y
477CONFIG_NET_ACT_POLICE=m
478CONFIG_NET_ACT_GACT=m
479CONFIG_GACT_PROB=y
480CONFIG_NET_ACT_MIRRED=m
481CONFIG_NET_ACT_IPT=m
482CONFIG_NET_ACT_PEDIT=m
483# CONFIG_NET_ACT_SIMP is not set
484
485#
486# Network testing
487#
488# CONFIG_NET_PKTGEN is not set
489# CONFIG_HAMRADIO is not set
490# CONFIG_IRDA is not set
491# CONFIG_BT is not set
492# CONFIG_IEEE80211 is not set
493
494#
495# Device Drivers
496#
497
498#
499# Generic Driver Options
500#
501CONFIG_STANDALONE=y
502CONFIG_PREVENT_FIRMWARE_BUILD=y
503CONFIG_FW_LOADER=m
504# CONFIG_DEBUG_DRIVER is not set
505
506#
507# Connector - unified userspace <-> kernelspace linker
508#
509CONFIG_CONNECTOR=m
510
511#
512# Memory Technology Devices (MTD)
513#
514# CONFIG_MTD is not set
515
516#
517# Parallel port support
518#
519# CONFIG_PARPORT is not set
520
521#
522# Plug and Play support
523#
524
525#
526# Block devices
527#
528# CONFIG_BLK_CPQ_DA is not set
529# CONFIG_BLK_CPQ_CISS_DA is not set
530# CONFIG_BLK_DEV_DAC960 is not set
531CONFIG_BLK_SSFDC=y
532# CONFIG_BLK_DEV_UMEM is not set
533# CONFIG_BLK_DEV_COW_COMMON is not set
534CONFIG_BLK_DEV_LOOP=m
535# CONFIG_BLK_DEV_CRYPTOLOOP is not set
536# CONFIG_BLK_DEV_NBD is not set
537# CONFIG_BLK_DEV_SX8 is not set
538# CONFIG_BLK_DEV_UB is not set
539CONFIG_BLK_DEV_RAM=y
540CONFIG_BLK_DEV_RAM_COUNT=16
541CONFIG_BLK_DEV_RAM_SIZE=4096
542CONFIG_BLK_DEV_INITRD=y
543# CONFIG_LBD is not set
544# CONFIG_CDROM_PKTCDVD is not set
545
546#
547# IO Schedulers
548#
549CONFIG_IOSCHED_NOOP=y
550CONFIG_IOSCHED_AS=y
551CONFIG_IOSCHED_DEADLINE=y
552CONFIG_IOSCHED_CFQ=y
553# CONFIG_ATA_OVER_ETH is not set
554
555#
556# ATA/ATAPI/MFM/RLL support
557#
558# CONFIG_IDE is not set
559
560#
561# SCSI device support
562#
563# CONFIG_RAID_ATTRS is not set
564CONFIG_SCSI=m
565CONFIG_SCSI_PROC_FS=y
566
567#
568# SCSI support type (disk, tape, CD-ROM)
569#
570CONFIG_BLK_DEV_SD=m
571# CONFIG_CHR_DEV_ST is not set
572# CONFIG_CHR_DEV_OSST is not set
573CONFIG_BLK_DEV_SR=m
574# CONFIG_BLK_DEV_SR_VENDOR is not set
575CONFIG_CHR_DEV_SG=m
576# CONFIG_CHR_DEV_SCH is not set
577
578#
579# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
580#
581# CONFIG_SCSI_MULTI_LUN is not set
582# CONFIG_SCSI_CONSTANTS is not set
583# CONFIG_SCSI_LOGGING is not set
584
585#
586# SCSI Transport Attributes
587#
588# CONFIG_SCSI_SPI_ATTRS is not set
589# CONFIG_SCSI_FC_ATTRS is not set
590# CONFIG_SCSI_ISCSI_ATTRS is not set
591# CONFIG_SCSI_SAS_ATTRS is not set
592
593#
594# SCSI low-level drivers
595#
596# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
597# CONFIG_SCSI_3W_9XXX is not set
598# CONFIG_SCSI_ACARD is not set
599# CONFIG_SCSI_AACRAID is not set
600# CONFIG_SCSI_AIC7XXX is not set
601# CONFIG_SCSI_AIC7XXX_OLD is not set
602# CONFIG_SCSI_AIC79XX is not set
603# CONFIG_SCSI_DPT_I2O is not set
604# CONFIG_MEGARAID_NEWGEN is not set
605# CONFIG_MEGARAID_LEGACY is not set
606# CONFIG_MEGARAID_SAS is not set
607# CONFIG_SCSI_SATA is not set
608# CONFIG_SCSI_DMX3191D is not set
609# CONFIG_SCSI_FUTURE_DOMAIN is not set
610# CONFIG_SCSI_IPS is not set
611# CONFIG_SCSI_INITIO is not set
612# CONFIG_SCSI_INIA100 is not set
613# CONFIG_SCSI_SYM53C8XX_2 is not set
614# CONFIG_SCSI_IPR is not set
615# CONFIG_SCSI_QLOGIC_FC is not set
616# CONFIG_SCSI_QLOGIC_1280 is not set
617CONFIG_SCSI_QLA2XXX=m
618# CONFIG_SCSI_QLA21XX is not set
619# CONFIG_SCSI_QLA22XX is not set
620# CONFIG_SCSI_QLA2300 is not set
621# CONFIG_SCSI_QLA2322 is not set
622# CONFIG_SCSI_QLA6312 is not set
623# CONFIG_SCSI_QLA24XX is not set
624# CONFIG_SCSI_LPFC is not set
625# CONFIG_SCSI_DC395x is not set
626# CONFIG_SCSI_DC390T is not set
627# CONFIG_SCSI_NSP32 is not set
628# CONFIG_SCSI_DEBUG is not set
629
630#
631# Multi-device support (RAID and LVM)
632#
633# CONFIG_MD is not set
634
635#
636# Fusion MPT device support
637#
638# CONFIG_FUSION is not set
639# CONFIG_FUSION_SPI is not set
640# CONFIG_FUSION_FC is not set
641# CONFIG_FUSION_SAS is not set
642
643#
644# IEEE 1394 (FireWire) support
645#
646# CONFIG_IEEE1394 is not set
647
648#
649# I2O device support
650#
651# CONFIG_I2O is not set
652
653#
654# Network device support
655#
656CONFIG_NETDEVICES=y
657# CONFIG_DUMMY is not set
658# CONFIG_BONDING is not set
659# CONFIG_EQUALIZER is not set
660CONFIG_TUN=m
661
662#
663# ARCnet devices
664#
665# CONFIG_ARCNET is not set
666
667#
668# PHY device support
669#
670CONFIG_PHYLIB=m
671CONFIG_PHYCONTROL=y
672
673#
674# MII PHY device drivers
675#
676CONFIG_MARVELL_PHY=m
677CONFIG_DAVICOM_PHY=m
678CONFIG_QSEMI_PHY=m
679CONFIG_LXT_PHY=m
680CONFIG_CICADA_PHY=m
681
682#
683# Ethernet (10 or 100Mbit)
684#
685CONFIG_NET_ETHERNET=y
686CONFIG_MII=y
687# CONFIG_STNIC is not set
688# CONFIG_HAPPYMEAL is not set
689# CONFIG_SUNGEM is not set
690CONFIG_CASSINI=m
691# CONFIG_NET_VENDOR_3COM is not set
692# CONFIG_SMC91X is not set
693
694#
695# Tulip family network device support
696#
697# CONFIG_NET_TULIP is not set
698# CONFIG_HP100 is not set
699# CONFIG_NE2000 is not set
700CONFIG_NET_PCI=y
701# CONFIG_PCNET32 is not set
702# CONFIG_AMD8111_ETH is not set
703# CONFIG_ADAPTEC_STARFIRE is not set
704# CONFIG_B44 is not set
705# CONFIG_FORCEDETH is not set
706# CONFIG_DGRS is not set
707# CONFIG_EEPRO100 is not set
708# CONFIG_E100 is not set
709# CONFIG_FEALNX is not set
710# CONFIG_NATSEMI is not set
711# CONFIG_NE2K_PCI is not set
712# CONFIG_8139CP is not set
713CONFIG_8139TOO=y
714# CONFIG_8139TOO_PIO is not set
715CONFIG_8139TOO_TUNE_TWISTER=y
716# CONFIG_8139TOO_8129 is not set
717CONFIG_8139_OLD_RX_RESET=y
718# CONFIG_SIS900 is not set
719# CONFIG_EPIC100 is not set
720# CONFIG_SUNDANCE is not set
721# CONFIG_TLAN is not set
722# CONFIG_VIA_RHINE is not set
723
724#
725# Ethernet (1000 Mbit)
726#
727# CONFIG_ACENIC is not set
728# CONFIG_DL2K is not set
729# CONFIG_E1000 is not set
730# CONFIG_NS83820 is not set
731# CONFIG_HAMACHI is not set
732# CONFIG_YELLOWFIN is not set
733# CONFIG_R8169 is not set
734# CONFIG_SIS190 is not set
735# CONFIG_SKGE is not set
736# CONFIG_SK98LIN is not set
737# CONFIG_VIA_VELOCITY is not set
738# CONFIG_TIGON3 is not set
739# CONFIG_BNX2 is not set
740
741#
742# Ethernet (10000 Mbit)
743#
744# CONFIG_CHELSIO_T1 is not set
745# CONFIG_IXGB is not set
746# CONFIG_S2IO is not set
747
748#
749# Token Ring devices
750#
751# CONFIG_TR is not set
752
753#
754# Wireless LAN (non-hamradio)
755#
756CONFIG_NET_RADIO=y
757
758#
759# Obsolete Wireless cards support (pre-802.11)
760#
761# CONFIG_STRIP is not set
762
763#
764# Wireless 802.11b ISA/PCI cards support
765#
766# CONFIG_HERMES is not set
767# CONFIG_ATMEL is not set
768
769#
770# Prism GT/Duette 802.11(a/b/g) PCI/Cardbus support
771#
772CONFIG_PRISM54=m
773# CONFIG_HOSTAP is not set
774CONFIG_NET_WIRELESS=y
775
776#
777# Wan interfaces
778#
779# CONFIG_WAN is not set
780# CONFIG_FDDI is not set
781# CONFIG_HIPPI is not set
782CONFIG_PPP=m
783CONFIG_PPP_MULTILINK=y
784CONFIG_PPP_FILTER=y
785CONFIG_PPP_ASYNC=m
786CONFIG_PPP_SYNC_TTY=m
787CONFIG_PPP_DEFLATE=m
788CONFIG_PPP_BSDCOMP=m
789CONFIG_PPPOE=m
790# CONFIG_SLIP is not set
791# CONFIG_NET_FC is not set
792# CONFIG_SHAPER is not set
793# CONFIG_NETCONSOLE is not set
794# CONFIG_NETPOLL is not set
795# CONFIG_NET_POLL_CONTROLLER is not set
796
797#
798# ISDN subsystem
799#
800# CONFIG_ISDN is not set
801
802#
803# Telephony Support
804#
805# CONFIG_PHONE is not set
806
807#
808# Input device support
809#
810CONFIG_INPUT=y
811
812#
813# Userland interfaces
814#
815CONFIG_INPUT_MOUSEDEV=y
816# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
817CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
818CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
819# CONFIG_INPUT_JOYDEV is not set
820# CONFIG_INPUT_TSDEV is not set
821# CONFIG_INPUT_EVDEV is not set
822# CONFIG_INPUT_EVBUG is not set
823
824#
825# Input Device Drivers
826#
827# CONFIG_INPUT_KEYBOARD is not set
828# CONFIG_INPUT_MOUSE is not set
829# CONFIG_INPUT_JOYSTICK is not set
830# CONFIG_INPUT_TOUCHSCREEN is not set
831# CONFIG_INPUT_MISC is not set
832
833#
834# Hardware I/O ports
835#
836# CONFIG_SERIO is not set
837# CONFIG_GAMEPORT is not set
838
839#
840# Character devices
841#
842CONFIG_VT=y
843CONFIG_VT_CONSOLE=y
844CONFIG_HW_CONSOLE=y
845# CONFIG_SERIAL_NONSTANDARD is not set
846
847#
848# Serial drivers
849#
850# CONFIG_SERIAL_8250 is not set
851
852#
853# Non-8250 serial port support
854#
855CONFIG_SERIAL_SH_SCI=y
856CONFIG_SERIAL_SH_SCI_CONSOLE=y
857CONFIG_SERIAL_CORE=y
858CONFIG_SERIAL_CORE_CONSOLE=y
859# CONFIG_SERIAL_JSM is not set
860CONFIG_UNIX98_PTYS=y
861CONFIG_LEGACY_PTYS=y
862CONFIG_LEGACY_PTY_COUNT=256
863
864#
865# IPMI
866#
867# CONFIG_IPMI_HANDLER is not set
868
869#
870# Watchdog Cards
871#
872# CONFIG_WATCHDOG is not set
873# CONFIG_RTC is not set
874# CONFIG_GEN_RTC is not set
875# CONFIG_DTLK is not set
876# CONFIG_R3964 is not set
877# CONFIG_APPLICOM is not set
878
879#
880# Ftape, the floppy tape device driver
881#
882# CONFIG_DRM is not set
883# CONFIG_RAW_DRIVER is not set
884
885#
886# TPM devices
887#
888# CONFIG_TCG_TPM is not set
889
890#
891# I2C support
892#
893# CONFIG_I2C is not set
894
895#
896# Dallas's 1-wire bus
897#
898# CONFIG_W1 is not set
899
900#
901# Hardware Monitoring support
902#
903CONFIG_HWMON=y
904# CONFIG_HWMON_VID is not set
905# CONFIG_HWMON_DEBUG_CHIP is not set
906
907#
908# Misc devices
909#
910
911#
912# Multimedia Capabilities Port drivers
913#
914
915#
916# Multimedia devices
917#
918# CONFIG_VIDEO_DEV is not set
919
920#
921# Digital Video Broadcasting Devices
922#
923# CONFIG_DVB is not set
924
925#
926# Graphics support
927#
928# CONFIG_FB is not set
929
930#
931# Console display driver support
932#
933CONFIG_DUMMY_CONSOLE=y
934
935#
936# Sound
937#
938# CONFIG_SOUND is not set
939
940#
941# USB support
942#
943CONFIG_USB_ARCH_HAS_HCD=y
944CONFIG_USB_ARCH_HAS_OHCI=y
945CONFIG_USB=m
946# CONFIG_USB_DEBUG is not set
947
948#
949# Miscellaneous USB options
950#
951CONFIG_USB_DEVICEFS=y
952# CONFIG_USB_BANDWIDTH is not set
953# CONFIG_USB_DYNAMIC_MINORS is not set
954# CONFIG_USB_OTG is not set
955
956#
957# USB Host Controller Drivers
958#
959CONFIG_USB_EHCI_HCD=m
960# CONFIG_USB_EHCI_SPLIT_ISO is not set
961# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
962# CONFIG_USB_ISP116X_HCD is not set
963CONFIG_USB_OHCI_HCD=m
964# CONFIG_USB_OHCI_BIG_ENDIAN is not set
965CONFIG_USB_OHCI_LITTLE_ENDIAN=y
966# CONFIG_USB_UHCI_HCD is not set
967# CONFIG_USB_SL811_HCD is not set
968
969#
970# USB Device Class drivers
971#
972# CONFIG_USB_BLUETOOTH_TTY is not set
973# CONFIG_USB_ACM is not set
974# CONFIG_USB_PRINTER is not set
975
976#
977# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' may also be needed; see USB_STORAGE Help for more information
978#
979CONFIG_USB_STORAGE=m
980# CONFIG_USB_STORAGE_DEBUG is not set
981# CONFIG_USB_STORAGE_DATAFAB is not set
982# CONFIG_USB_STORAGE_FREECOM is not set
983# CONFIG_USB_STORAGE_DPCM is not set
984# CONFIG_USB_STORAGE_USBAT is not set
985# CONFIG_USB_STORAGE_SDDR09 is not set
986# CONFIG_USB_STORAGE_SDDR55 is not set
987# CONFIG_USB_STORAGE_JUMPSHOT is not set
988
989#
990# USB Input Devices
991#
992# CONFIG_USB_HID is not set
993
994#
995# USB HID Boot Protocol drivers
996#
997# CONFIG_USB_KBD is not set
998# CONFIG_USB_MOUSE is not set
999# CONFIG_USB_AIPTEK is not set
1000# CONFIG_USB_WACOM is not set
1001# CONFIG_USB_ACECAD is not set
1002# CONFIG_USB_KBTAB is not set
1003# CONFIG_USB_POWERMATE is not set
1004# CONFIG_USB_MTOUCH is not set
1005# CONFIG_USB_ITMTOUCH is not set
1006# CONFIG_USB_EGALAX is not set
1007# CONFIG_USB_YEALINK is not set
1008# CONFIG_USB_XPAD is not set
1009# CONFIG_USB_ATI_REMOTE is not set
1010# CONFIG_USB_KEYSPAN_REMOTE is not set
1011# CONFIG_USB_APPLETOUCH is not set
1012
1013#
1014# USB Imaging devices
1015#
1016# CONFIG_USB_MDC800 is not set
1017# CONFIG_USB_MICROTEK is not set
1018
1019#
1020# USB Multimedia devices
1021#
1022# CONFIG_USB_DABUSB is not set
1023
1024#
1025# Video4Linux support is needed for USB Multimedia device support
1026#
1027
1028#
1029# USB Network Adapters
1030#
1031# CONFIG_USB_CATC is not set
1032# CONFIG_USB_KAWETH is not set
1033# CONFIG_USB_PEGASUS is not set
1034# CONFIG_USB_RTL8150 is not set
1035# CONFIG_USB_USBNET is not set
1036# CONFIG_USB_ZD1201 is not set
1037CONFIG_USB_MON=y
1038
1039#
1040# USB port drivers
1041#
1042
1043#
1044# USB Serial Converter support
1045#
1046CONFIG_USB_SERIAL=m
1047CONFIG_USB_SERIAL_GENERIC=y
1048# CONFIG_USB_SERIAL_AIRPRIME is not set
1049# CONFIG_USB_SERIAL_BELKIN is not set
1050# CONFIG_USB_SERIAL_WHITEHEAT is not set
1051# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
1052# CONFIG_USB_SERIAL_CP2101 is not set
1053# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
1054# CONFIG_USB_SERIAL_EMPEG is not set
1055# CONFIG_USB_SERIAL_FTDI_SIO is not set
1056# CONFIG_USB_SERIAL_VISOR is not set
1057# CONFIG_USB_SERIAL_IPAQ is not set
1058# CONFIG_USB_SERIAL_IR is not set
1059# CONFIG_USB_SERIAL_EDGEPORT is not set
1060# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
1061# CONFIG_USB_SERIAL_GARMIN is not set
1062# CONFIG_USB_SERIAL_IPW is not set
1063# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
1064# CONFIG_USB_SERIAL_KEYSPAN is not set
1065# CONFIG_USB_SERIAL_KLSI is not set
1066# CONFIG_USB_SERIAL_KOBIL_SCT is not set
1067# CONFIG_USB_SERIAL_MCT_U232 is not set
1068CONFIG_USB_SERIAL_PL2303=m
1069# CONFIG_USB_SERIAL_HP4X is not set
1070# CONFIG_USB_SERIAL_SAFE is not set
1071# CONFIG_USB_SERIAL_TI is not set
1072# CONFIG_USB_SERIAL_CYBERJACK is not set
1073# CONFIG_USB_SERIAL_XIRCOM is not set
1074# CONFIG_USB_SERIAL_OMNINET is not set
1075
1076#
1077# USB Miscellaneous drivers
1078#
1079# CONFIG_USB_EMI62 is not set
1080# CONFIG_USB_EMI26 is not set
1081# CONFIG_USB_AUERSWALD is not set
1082# CONFIG_USB_RIO500 is not set
1083# CONFIG_USB_LEGOTOWER is not set
1084# CONFIG_USB_LCD is not set
1085# CONFIG_USB_LED is not set
1086# CONFIG_USB_CYTHERM is not set
1087# CONFIG_USB_PHIDGETKIT is not set
1088# CONFIG_USB_PHIDGETSERVO is not set
1089# CONFIG_USB_IDMOUSE is not set
1090# CONFIG_USB_SISUSBVGA is not set
1091# CONFIG_USB_LD is not set
1092# CONFIG_USB_TEST is not set
1093
1094#
1095# USB DSL modem support
1096#
1097
1098#
1099# USB Gadget Support
1100#
1101# CONFIG_USB_GADGET is not set
1102
1103#
1104# MMC/SD Card support
1105#
1106# CONFIG_MMC is not set
1107
1108#
1109# InfiniBand support
1110#
1111# CONFIG_INFINIBAND is not set
1112
1113#
1114# SN Devices
1115#
1116
1117#
1118# File systems
1119#
1120CONFIG_EXT2_FS=y
1121CONFIG_EXT2_FS_XATTR=y
1122CONFIG_EXT2_FS_POSIX_ACL=y
1123CONFIG_EXT2_FS_SECURITY=y
1124# CONFIG_EXT2_FS_XIP is not set
1125CONFIG_EXT3_FS=y
1126CONFIG_EXT3_FS_XATTR=y
1127CONFIG_EXT3_FS_POSIX_ACL=y
1128CONFIG_EXT3_FS_SECURITY=y
1129CONFIG_JBD=y
1130# CONFIG_JBD_DEBUG is not set
1131CONFIG_FS_MBCACHE=y
1132CONFIG_REISERFS_FS=m
1133# CONFIG_REISERFS_CHECK is not set
1134# CONFIG_REISERFS_PROC_INFO is not set
1135# CONFIG_REISERFS_FS_XATTR is not set
1136# CONFIG_JFS_FS is not set
1137CONFIG_FS_POSIX_ACL=y
1138# CONFIG_XFS_FS is not set
1139# CONFIG_MINIX_FS is not set
1140# CONFIG_ROMFS_FS is not set
1141CONFIG_INOTIFY=y
1142# CONFIG_QUOTA is not set
1143CONFIG_DNOTIFY=y
1144# CONFIG_AUTOFS_FS is not set
1145# CONFIG_AUTOFS4_FS is not set
1146CONFIG_FUSE_FS=m
1147
1148#
1149# CD-ROM/DVD Filesystems
1150#
1151CONFIG_ISO9660_FS=m
1152CONFIG_JOLIET=y
1153CONFIG_ZISOFS=y
1154CONFIG_ZISOFS_FS=m
1155CONFIG_UDF_FS=m
1156CONFIG_UDF_NLS=y
1157
1158#
1159# DOS/FAT/NT Filesystems
1160#
1161CONFIG_FAT_FS=m
1162CONFIG_MSDOS_FS=m
1163CONFIG_VFAT_FS=m
1164CONFIG_FAT_DEFAULT_CODEPAGE=437
1165CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1166# CONFIG_NTFS_FS is not set
1167
1168#
1169# Pseudo filesystems
1170#
1171CONFIG_PROC_FS=y
1172CONFIG_PROC_KCORE=y
1173CONFIG_SYSFS=y
1174CONFIG_TMPFS=y
1175# CONFIG_HUGETLBFS is not set
1176# CONFIG_HUGETLB_PAGE is not set
1177CONFIG_RAMFS=y
1178CONFIG_RELAYFS_FS=m
1179
1180#
1181# Miscellaneous filesystems
1182#
1183# CONFIG_ADFS_FS is not set
1184# CONFIG_AFFS_FS is not set
1185# CONFIG_HFS_FS is not set
1186# CONFIG_HFSPLUS_FS is not set
1187# CONFIG_BEFS_FS is not set
1188# CONFIG_BFS_FS is not set
1189# CONFIG_EFS_FS is not set
1190# CONFIG_CRAMFS is not set
1191# CONFIG_VXFS_FS is not set
1192# CONFIG_HPFS_FS is not set
1193# CONFIG_QNX4FS_FS is not set
1194# CONFIG_SYSV_FS is not set
1195# CONFIG_UFS_FS is not set
1196
1197#
1198# Network File Systems
1199#
1200CONFIG_NFS_FS=y
1201CONFIG_NFS_V3=y
1202# CONFIG_NFS_V3_ACL is not set
1203# CONFIG_NFS_V4 is not set
1204# CONFIG_NFS_DIRECTIO is not set
1205CONFIG_NFSD=y
1206CONFIG_NFSD_V3=y
1207# CONFIG_NFSD_V3_ACL is not set
1208# CONFIG_NFSD_V4 is not set
1209CONFIG_NFSD_TCP=y
1210CONFIG_ROOT_NFS=y
1211CONFIG_LOCKD=y
1212CONFIG_LOCKD_V4=y
1213CONFIG_EXPORTFS=y
1214CONFIG_NFS_COMMON=y
1215CONFIG_SUNRPC=y
1216# CONFIG_RPCSEC_GSS_KRB5 is not set
1217# CONFIG_RPCSEC_GSS_SPKM3 is not set
1218CONFIG_SMB_FS=m
1219# CONFIG_SMB_NLS_DEFAULT is not set
1220# CONFIG_CIFS is not set
1221# CONFIG_NCP_FS is not set
1222# CONFIG_CODA_FS is not set
1223# CONFIG_AFS_FS is not set
1224CONFIG_9P_FS=m
1225
1226#
1227# Partition Types
1228#
1229CONFIG_PARTITION_ADVANCED=y
1230# CONFIG_ACORN_PARTITION is not set
1231# CONFIG_OSF_PARTITION is not set
1232# CONFIG_AMIGA_PARTITION is not set
1233# CONFIG_ATARI_PARTITION is not set
1234# CONFIG_MAC_PARTITION is not set
1235CONFIG_MSDOS_PARTITION=y
1236# CONFIG_BSD_DISKLABEL is not set
1237# CONFIG_MINIX_SUBPARTITION is not set
1238# CONFIG_SOLARIS_X86_PARTITION is not set
1239# CONFIG_UNIXWARE_DISKLABEL is not set
1240# CONFIG_LDM_PARTITION is not set
1241# CONFIG_SGI_PARTITION is not set
1242# CONFIG_ULTRIX_PARTITION is not set
1243# CONFIG_SUN_PARTITION is not set
1244# CONFIG_EFI_PARTITION is not set
1245
1246#
1247# Native Language Support
1248#
1249CONFIG_NLS=m
1250CONFIG_NLS_DEFAULT="iso8859-1"
1251CONFIG_NLS_CODEPAGE_437=m
1252# CONFIG_NLS_CODEPAGE_737 is not set
1253# CONFIG_NLS_CODEPAGE_775 is not set
1254# CONFIG_NLS_CODEPAGE_850 is not set
1255# CONFIG_NLS_CODEPAGE_852 is not set
1256# CONFIG_NLS_CODEPAGE_855 is not set
1257# CONFIG_NLS_CODEPAGE_857 is not set
1258# CONFIG_NLS_CODEPAGE_860 is not set
1259# CONFIG_NLS_CODEPAGE_861 is not set
1260# CONFIG_NLS_CODEPAGE_862 is not set
1261# CONFIG_NLS_CODEPAGE_863 is not set
1262# CONFIG_NLS_CODEPAGE_864 is not set
1263# CONFIG_NLS_CODEPAGE_865 is not set
1264# CONFIG_NLS_CODEPAGE_866 is not set
1265# CONFIG_NLS_CODEPAGE_869 is not set
1266# CONFIG_NLS_CODEPAGE_936 is not set
1267# CONFIG_NLS_CODEPAGE_950 is not set
1268# CONFIG_NLS_CODEPAGE_932 is not set
1269# CONFIG_NLS_CODEPAGE_949 is not set
1270# CONFIG_NLS_CODEPAGE_874 is not set
1271# CONFIG_NLS_ISO8859_8 is not set
1272# CONFIG_NLS_CODEPAGE_1250 is not set
1273# CONFIG_NLS_CODEPAGE_1251 is not set
1274CONFIG_NLS_ASCII=m
1275CONFIG_NLS_ISO8859_1=m
1276# CONFIG_NLS_ISO8859_2 is not set
1277# CONFIG_NLS_ISO8859_3 is not set
1278# CONFIG_NLS_ISO8859_4 is not set
1279# CONFIG_NLS_ISO8859_5 is not set
1280# CONFIG_NLS_ISO8859_6 is not set
1281# CONFIG_NLS_ISO8859_7 is not set
1282# CONFIG_NLS_ISO8859_9 is not set
1283# CONFIG_NLS_ISO8859_13 is not set
1284# CONFIG_NLS_ISO8859_14 is not set
1285# CONFIG_NLS_ISO8859_15 is not set
1286# CONFIG_NLS_KOI8_R is not set
1287# CONFIG_NLS_KOI8_U is not set
1288CONFIG_NLS_UTF8=m
1289
1290#
1291# Profiling support
1292#
1293# CONFIG_PROFILING is not set
1294
1295#
1296# Kernel hacking
1297#
1298# CONFIG_PRINTK_TIME is not set
1299CONFIG_DEBUG_KERNEL=y
1300CONFIG_MAGIC_SYSRQ=y
1301CONFIG_LOG_BUF_SHIFT=16
1302# CONFIG_DETECT_SOFTLOCKUP is not set
1303# CONFIG_SCHEDSTATS is not set
1304CONFIG_DEBUG_SLAB=y
1305# CONFIG_DEBUG_SPINLOCK is not set
1306# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1307# CONFIG_DEBUG_KOBJECT is not set
1308# CONFIG_DEBUG_INFO is not set
1309# CONFIG_DEBUG_FS is not set
1310# CONFIG_FRAME_POINTER is not set
1311# CONFIG_SH_STANDARD_BIOS is not set
1312CONFIG_EARLY_SCIF_CONSOLE=y
1313# CONFIG_EARLY_PRINTK is not set
1314# CONFIG_KGDB is not set
1315
1316#
1317# Security options
1318#
1319# CONFIG_KEYS is not set
1320# CONFIG_SECURITY is not set
1321
1322#
1323# Cryptographic options
1324#
1325CONFIG_CRYPTO=y
1326CONFIG_CRYPTO_HMAC=y
1327# CONFIG_CRYPTO_NULL is not set
1328CONFIG_CRYPTO_MD4=m
1329CONFIG_CRYPTO_MD5=m
1330CONFIG_CRYPTO_SHA1=m
1331CONFIG_CRYPTO_SHA256=m
1332CONFIG_CRYPTO_SHA512=m
1333CONFIG_CRYPTO_WP512=m
1334CONFIG_CRYPTO_TGR192=m
1335CONFIG_CRYPTO_DES=m
1336CONFIG_CRYPTO_BLOWFISH=m
1337CONFIG_CRYPTO_TWOFISH=m
1338CONFIG_CRYPTO_SERPENT=m
1339CONFIG_CRYPTO_AES=m
1340CONFIG_CRYPTO_CAST5=m
1341CONFIG_CRYPTO_CAST6=m
1342CONFIG_CRYPTO_TEA=m
1343CONFIG_CRYPTO_ARC4=m
1344CONFIG_CRYPTO_KHAZAD=m
1345CONFIG_CRYPTO_ANUBIS=m
1346CONFIG_CRYPTO_DEFLATE=m
1347CONFIG_CRYPTO_MICHAEL_MIC=m
1348CONFIG_CRYPTO_CRC32C=m
1349# CONFIG_CRYPTO_TEST is not set
1350
1351#
1352# Hardware crypto devices
1353#
1354
1355#
1356# Library routines
1357#
1358CONFIG_CRC_CCITT=m
1359CONFIG_CRC16=m
1360CONFIG_CRC32=y
1361CONFIG_LIBCRC32C=m
1362CONFIG_ZLIB_INFLATE=m
1363CONFIG_ZLIB_DEFLATE=m
1364CONFIG_TEXTSEARCH=y
1365CONFIG_TEXTSEARCH_KMP=m
1366CONFIG_TEXTSEARCH_BM=m
1367CONFIG_TEXTSEARCH_FSM=m
diff --git a/arch/sh/drivers/dma/Kconfig b/arch/sh/drivers/dma/Kconfig
index 0f15216cd39d..defc13c37d48 100644
--- a/arch/sh/drivers/dma/Kconfig
+++ b/arch/sh/drivers/dma/Kconfig
@@ -11,6 +11,8 @@ config SH_DMA
11config NR_ONCHIP_DMA_CHANNELS 11config NR_ONCHIP_DMA_CHANNELS
12 depends on SH_DMA 12 depends on SH_DMA
13 int "Number of on-chip DMAC channels" 13 int "Number of on-chip DMAC channels"
14 default "8" if CPU_SUBTYPE_SH7750R || CPU_SUBTYPE_SH7751R
15 default "12" if CPU_SUBTYPE_SH7780
14 default "4" 16 default "4"
15 help 17 help
16 This allows you to specify the number of channels that the on-chip 18 This allows you to specify the number of channels that the on-chip
@@ -52,4 +54,3 @@ config DMA_PAGE_OPS_CHANNEL
52 are dual-address capable. 54 are dual-address capable.
53 55
54endmenu 56endmenu
55
diff --git a/arch/sh/drivers/dma/dma-g2.c b/arch/sh/drivers/dma/dma-g2.c
index 0f866f8789f0..9cb070924180 100644
--- a/arch/sh/drivers/dma/dma-g2.c
+++ b/arch/sh/drivers/dma/dma-g2.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * G2 bus DMA support 4 * G2 bus DMA support
5 * 5 *
6 * Copyright (C) 2003, 2004 Paul Mundt 6 * Copyright (C) 2003 - 2006 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -13,7 +13,7 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16 16#include <asm/cacheflush.h>
17#include <asm/mach/sysasic.h> 17#include <asm/mach/sysasic.h>
18#include <asm/mach/dma.h> 18#include <asm/mach/dma.h>
19#include <asm/dma.h> 19#include <asm/dma.h>
@@ -47,17 +47,31 @@ struct g2_dma_info {
47 47
48static volatile struct g2_dma_info *g2_dma = (volatile struct g2_dma_info *)0xa05f7800; 48static volatile struct g2_dma_info *g2_dma = (volatile struct g2_dma_info *)0xa05f7800;
49 49
50#define g2_bytes_remaining(i) \
51 ((g2_dma->channel[i].size - \
52 g2_dma->status[i].size) & 0x0fffffff)
53
50static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 54static irqreturn_t g2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
51{ 55{
52 /* FIXME: Do some meaningful completion work here.. */ 56 int i;
53 return IRQ_HANDLED;
54}
55 57
56static struct irqaction g2_dma_irq = { 58 for (i = 0; i < G2_NR_DMA_CHANNELS; i++) {
57 .name = "g2 DMA handler", 59 if (g2_dma->status[i].status & 0x20000000) {
58 .handler = g2_dma_interrupt, 60 unsigned int bytes = g2_bytes_remaining(i);
59 .flags = IRQF_DISABLED, 61
60}; 62 if (likely(bytes == 0)) {
63 struct dma_info *info = dev_id;
64 struct dma_channel *chan = info->channels + i;
65
66 wake_up(&chan->wait_queue);
67
68 return IRQ_HANDLED;
69 }
70 }
71 }
72
73 return IRQ_NONE;
74}
61 75
62static int g2_enable_dma(struct dma_channel *chan) 76static int g2_enable_dma(struct dma_channel *chan)
63{ 77{
@@ -135,8 +149,14 @@ static int g2_xfer_dma(struct dma_channel *chan)
135 return 0; 149 return 0;
136} 150}
137 151
152static int g2_get_residue(struct dma_channel *chan)
153{
154 return g2_bytes_remaining(chan->chan);
155}
156
138static struct dma_ops g2_dma_ops = { 157static struct dma_ops g2_dma_ops = {
139 .xfer = g2_xfer_dma, 158 .xfer = g2_xfer_dma,
159 .get_residue = g2_get_residue,
140}; 160};
141 161
142static struct dma_info g2_dma_info = { 162static struct dma_info g2_dma_info = {
@@ -148,13 +168,22 @@ static struct dma_info g2_dma_info = {
148 168
149static int __init g2_dma_init(void) 169static int __init g2_dma_init(void)
150{ 170{
151 setup_irq(HW_EVENT_G2_DMA, &g2_dma_irq); 171 int ret;
172
173 ret = request_irq(HW_EVENT_G2_DMA, g2_dma_interrupt, IRQF_DISABLED,
174 "g2 DMA handler", &g2_dma_info);
175 if (unlikely(ret))
176 return -EINVAL;
152 177
153 /* Magic */ 178 /* Magic */
154 g2_dma->wait_state = 27; 179 g2_dma->wait_state = 27;
155 g2_dma->magic = 0x4659404f; 180 g2_dma->magic = 0x4659404f;
156 181
157 return register_dmac(&g2_dma_info); 182 ret = register_dmac(&g2_dma_info);
183 if (unlikely(ret != 0))
184 free_irq(HW_EVENT_G2_DMA, 0);
185
186 return ret;
158} 187}
159 188
160static void __exit g2_dma_exit(void) 189static void __exit g2_dma_exit(void)
@@ -169,4 +198,3 @@ module_exit(g2_dma_exit);
169MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>"); 198MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
170MODULE_DESCRIPTION("G2 bus DMA driver"); 199MODULE_DESCRIPTION("G2 bus DMA driver");
171MODULE_LICENSE("GPL"); 200MODULE_LICENSE("GPL");
172
diff --git a/arch/sh/drivers/dma/dma-pvr2.c b/arch/sh/drivers/dma/dma-pvr2.c
index 30a580aa7cbd..3b0b0f60bb3c 100644
--- a/arch/sh/drivers/dma/dma-pvr2.c
+++ b/arch/sh/drivers/dma/dma-pvr2.c
@@ -18,8 +18,8 @@
18#include <asm/dma.h> 18#include <asm/dma.h>
19#include <asm/io.h> 19#include <asm/io.h>
20 20
21static unsigned int xfer_complete = 0; 21static unsigned int xfer_complete;
22static int count = 0; 22static int count;
23 23
24static irqreturn_t pvr2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs) 24static irqreturn_t pvr2_dma_interrupt(int irq, void *dev_id, struct pt_regs *regs)
25{ 25{
@@ -107,4 +107,3 @@ module_exit(pvr2_dma_exit);
107MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>"); 107MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
108MODULE_DESCRIPTION("NEC PowerVR 2 DMA driver"); 108MODULE_DESCRIPTION("NEC PowerVR 2 DMA driver");
109MODULE_LICENSE("GPL"); 109MODULE_LICENSE("GPL");
110
diff --git a/arch/sh/drivers/dma/dma-sh.c b/arch/sh/drivers/dma/dma-sh.c
index e028a2d2a4ea..cbbe8bce3d67 100644
--- a/arch/sh/drivers/dma/dma-sh.c
+++ b/arch/sh/drivers/dma/dma-sh.c
@@ -11,14 +11,10 @@
11 * License. See the file "COPYING" in the main directory of this archive 11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details. 12 * for more details.
13 */ 13 */
14
15#include <linux/init.h> 14#include <linux/init.h>
16#include <linux/irq.h>
17#include <linux/interrupt.h> 15#include <linux/interrupt.h>
18#include <linux/module.h> 16#include <linux/module.h>
19#include <asm/dreamcast/dma.h> 17#include <asm/dreamcast/dma.h>
20#include <asm/signal.h>
21#include <asm/irq.h>
22#include <asm/dma.h> 18#include <asm/dma.h>
23#include <asm/io.h> 19#include <asm/io.h>
24#include "dma-sh.h" 20#include "dma-sh.h"
@@ -84,18 +80,23 @@ static irqreturn_t dma_tei(int irq, void *dev_id, struct pt_regs *regs)
84 80
85static int sh_dmac_request_dma(struct dma_channel *chan) 81static int sh_dmac_request_dma(struct dma_channel *chan)
86{ 82{
87 char name[32]; 83 if (unlikely(!chan->flags & DMA_TEI_CAPABLE))
84 return 0;
88 85
89 snprintf(name, sizeof(name), "DMAC Transfer End (Channel %d)", 86 chan->name = kzalloc(32, GFP_KERNEL);
87 if (unlikely(chan->name == NULL))
88 return -ENOMEM;
89 snprintf(chan->name, 32, "DMAC Transfer End (Channel %d)",
90 chan->chan); 90 chan->chan);
91 91
92 return request_irq(get_dmte_irq(chan->chan), dma_tei, 92 return request_irq(get_dmte_irq(chan->chan), dma_tei,
93 IRQF_DISABLED, name, chan); 93 IRQF_DISABLED, chan->name, chan);
94} 94}
95 95
96static void sh_dmac_free_dma(struct dma_channel *chan) 96static void sh_dmac_free_dma(struct dma_channel *chan)
97{ 97{
98 free_irq(get_dmte_irq(chan->chan), chan); 98 free_irq(get_dmte_irq(chan->chan), chan);
99 kfree(chan->name);
99} 100}
100 101
101static void 102static void
@@ -259,7 +260,7 @@ static int __init sh_dmac_init(void)
259#ifdef CONFIG_CPU_SH4 260#ifdef CONFIG_CPU_SH4
260 make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY); 261 make_ipr_irq(DMAE_IRQ, DMA_IPR_ADDR, DMA_IPR_POS, DMA_PRIORITY);
261 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0); 262 i = request_irq(DMAE_IRQ, dma_err, IRQF_DISABLED, "DMAC Address Error", 0);
262 if (i < 0) 263 if (unlikely(i < 0))
263 return i; 264 return i;
264#endif 265#endif
265 266
@@ -274,7 +275,7 @@ static int __init sh_dmac_init(void)
274 * been set. 275 * been set.
275 */ 276 */
276 i = dmaor_reset(); 277 i = dmaor_reset();
277 if (i < 0) 278 if (unlikely(i != 0))
278 return i; 279 return i;
279 280
280 return register_dmac(info); 281 return register_dmac(info);
diff --git a/arch/sh/drivers/pci/Makefile b/arch/sh/drivers/pci/Makefile
index 365bc16a4a83..9e00cb8a39e9 100644
--- a/arch/sh/drivers/pci/Makefile
+++ b/arch/sh/drivers/pci/Makefile
@@ -6,7 +6,8 @@ obj-y += pci.o
6obj-$(CONFIG_PCI_AUTO) += pci-auto.o 6obj-$(CONFIG_PCI_AUTO) += pci-auto.o
7 7
8obj-$(CONFIG_CPU_SUBTYPE_ST40STB1) += pci-st40.o 8obj-$(CONFIG_CPU_SUBTYPE_ST40STB1) += pci-st40.o
9obj-$(CONFIG_CPU_SUBTYPE_SH7751) += pci-sh7751.o 9obj-$(CONFIG_CPU_SUBTYPE_SH7751) += pci-sh7751.o ops-sh4.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7780) += pci-sh7780.o ops-sh4.o
10 11
11obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o \ 12obj-$(CONFIG_SH_DREAMCAST) += ops-dreamcast.o fixups-dreamcast.o \
12 dma-dreamcast.o 13 dma-dreamcast.o
@@ -14,3 +15,6 @@ obj-$(CONFIG_SH_SECUREEDGE5410) += ops-snapgear.o
14obj-$(CONFIG_SH_BIGSUR) += ops-bigsur.o 15obj-$(CONFIG_SH_BIGSUR) += ops-bigsur.o
15obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o 16obj-$(CONFIG_SH_RTS7751R2D) += ops-rts7751r2d.o fixups-rts7751r2d.o
16obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o 17obj-$(CONFIG_SH_SH03) += ops-sh03.o fixups-sh03.o
18obj-$(CONFIG_SH_R7780RP) += ops-r7780rp.o fixups-r7780rp.o
19obj-$(CONFIG_SH_TITAN) += ops-titan.o
20obj-$(CONFIG_SH_LANDISK) += ops-landisk.o
diff --git a/arch/sh/drivers/pci/fixups-dreamcast.c b/arch/sh/drivers/pci/fixups-dreamcast.c
index 63b1c6f4b8d2..c0af5f7ef414 100644
--- a/arch/sh/drivers/pci/fixups-dreamcast.c
+++ b/arch/sh/drivers/pci/fixups-dreamcast.c
@@ -4,7 +4,7 @@
4 * PCI fixups for the Sega Dreamcast 4 * PCI fixups for the Sega Dreamcast
5 * 5 *
6 * Copyright (C) 2001, 2002 M. R. Brown 6 * Copyright (C) 2001, 2002 M. R. Brown
7 * Copyright (C) 2002, 2003 Paul Mundt 7 * Copyright (C) 2002, 2003, 2006 Paul Mundt
8 * 8 *
9 * This file originally bore the message (with enclosed-$): 9 * This file originally bore the message (with enclosed-$):
10 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp 10 * Id: pci.c,v 1.3 2003/05/04 19:29:46 lethal Exp
@@ -45,36 +45,16 @@ static void __init gapspci_fixup_resources(struct pci_dev *dev)
45 printk("PCI: Failed resource fixup\n"); 45 printk("PCI: Failed resource fixup\n");
46 } 46 }
47} 47}
48
49DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources); 48DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, gapspci_fixup_resources);
50 49
51void __init pcibios_fixup_bus(struct pci_bus *bus) 50int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
52{ 51{
53 /* 52 /*
54 * We don't have any sub bus to fix up, and this is a rather 53 * The interrupt routing semantics here are quite trivial.
55 * stupid place to put general device fixups. Don't do it. 54 *
56 * Use the pcibios_fixups table or suffer the consequences. 55 * We basically only support one interrupt, so we only bother
56 * updating a device's interrupt line with this single shared
57 * interrupt. Keeps routing quite simple, doesn't it?
57 */ 58 */
59 return GAPSPCI_IRQ;
58} 60}
59
60void __init pcibios_fixup_irqs(void)
61{
62 struct pci_dev *dev = 0;
63
64 for_each_pci_dev(dev) {
65 /*
66 * The interrupt routing semantics here are quite trivial.
67 *
68 * We basically only support one interrupt, so we only bother
69 * updating a device's interrupt line with this single shared
70 * interrupt. Keeps routing quite simple, doesn't it?
71 */
72 printk(KERN_NOTICE "PCI: Fixing up IRQ routing for device %s\n",
73 pci_name(dev));
74
75 dev->irq = GAPSPCI_IRQ;
76
77 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
78 }
79}
80
diff --git a/arch/sh/drivers/pci/fixups-r7780rp.c b/arch/sh/drivers/pci/fixups-r7780rp.c
new file mode 100644
index 000000000000..3e321df65d22
--- /dev/null
+++ b/arch/sh/drivers/pci/fixups-r7780rp.c
@@ -0,0 +1,45 @@
1/*
2 * arch/sh/drivers/pci/fixups-r7780rp.c
3 *
4 * Highlander R7780RP-1 PCI fixups
5 *
6 * Copyright (C) 2003 Lineo uSolutions, Inc.
7 * Copyright (C) 2004 - 2006 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/pci.h>
14#include "pci-sh4.h"
15#include <asm/io.h>
16
17int pci_fixup_pcic(void)
18{
19 pci_write_reg(0x000043ff, SH4_PCIINTM);
20 pci_write_reg(0x0000380f, SH4_PCIAINTM);
21
22 pci_write_reg(0xfbb00047, SH7780_PCICMD);
23 pci_write_reg(0x00000000, SH7780_PCIIBAR);
24
25 pci_write_reg(0x00011912, SH7780_PCISVID);
26 pci_write_reg(0x08000000, SH7780_PCICSCR0);
27 pci_write_reg(0x0000001b, SH7780_PCICSAR0);
28 pci_write_reg(0xfd000000, SH7780_PCICSCR1);
29 pci_write_reg(0x0000000f, SH7780_PCICSAR1);
30
31 pci_write_reg(0xfd000000, SH7780_PCIMBR0);
32 pci_write_reg(0x00fc0000, SH7780_PCIMBMR0);
33
34#ifdef CONFIG_32BIT
35 pci_write_reg(0xc0000000, SH7780_PCIMBR2);
36 pci_write_reg(0x20000000 - SH7780_PCI_IO_SIZE, SH7780_PCIMBMR2);
37#endif
38
39 /* Set IOBR for windows containing area specified in pci.h */
40 pci_write_reg((PCIBIOS_MIN_IO & ~(SH7780_PCI_IO_SIZE - 1)),
41 SH7780_PCIIOBR);
42 pci_write_reg(((SH7780_PCI_IO_SIZE-1) & (7<<18)), SH7780_PCIIOBMR);
43
44 return 0;
45}
diff --git a/arch/sh/drivers/pci/fixups-rts7751r2d.c b/arch/sh/drivers/pci/fixups-rts7751r2d.c
index 0c590fc7a081..e72ceb560d5b 100644
--- a/arch/sh/drivers/pci/fixups-rts7751r2d.c
+++ b/arch/sh/drivers/pci/fixups-rts7751r2d.c
@@ -10,8 +10,7 @@
10 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details. 11 * for more details.
12 */ 12 */
13#include "pci-sh7751.h" 13#include "pci-sh4.h"
14#include <asm/io.h>
15 14
16#define PCIMCR_MRSET_OFF 0xBFFFFFFF 15#define PCIMCR_MRSET_OFF 0xBFFFFFFF
17#define PCIMCR_RFSH_OFF 0xFFFFFFFB 16#define PCIMCR_RFSH_OFF 0xFFFFFFFB
@@ -22,22 +21,23 @@ int pci_fixup_pcic(void)
22 21
23 bcr1 = inl(SH7751_BCR1); 22 bcr1 = inl(SH7751_BCR1);
24 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */ 23 bcr1 |= 0x40080000; /* Enable Bit 19 BREQEN, set PCIC to slave */
25 outl(bcr1, PCI_REG(SH7751_PCIBCR1)); 24 pci_write_reg(bcr1, SH4_PCIBCR1);
26 25
27 /* Enable all interrupts, so we known what to fix */ 26 /* Enable all interrupts, so we known what to fix */
28 outl(0x0000c3ff, PCI_REG(SH7751_PCIINTM)); 27 pci_write_reg(0x0000c3ff, SH4_PCIINTM);
29 outl(0x0000380f, PCI_REG(SH7751_PCIAINTM)); 28 pci_write_reg(0x0000380f, SH4_PCIAINTM);
30 29
31 outl(0xfb900047, PCI_REG(SH7751_PCICONF1)); 30 pci_write_reg(0xfb900047, SH7751_PCICONF1);
32 outl(0xab000001, PCI_REG(SH7751_PCICONF4)); 31 pci_write_reg(0xab000001, SH7751_PCICONF4);
33 32
34 mcr = inl(SH7751_MCR); 33 mcr = inl(SH7751_MCR);
35 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF; 34 mcr = (mcr & PCIMCR_MRSET_OFF) & PCIMCR_RFSH_OFF;
36 outl(mcr, PCI_REG(SH7751_PCIMCR)); 35 pci_write_reg(mcr, SH4_PCIMCR);
36
37 pci_write_reg(0x0c000000, SH7751_PCICONF5);
38 pci_write_reg(0xd0000000, SH7751_PCICONF6);
39 pci_write_reg(0x0c000000, SH4_PCILAR0);
40 pci_write_reg(0x00000000, SH4_PCILAR1);
37 41
38 outl(0x0c000000, PCI_REG(SH7751_PCICONF5));
39 outl(0xd0000000, PCI_REG(SH7751_PCICONF6));
40 outl(0x0c000000, PCI_REG(SH7751_PCILAR0));
41 outl(0x00000000, PCI_REG(SH7751_PCILAR1));
42 return 0; 42 return 0;
43} 43}
diff --git a/arch/sh/drivers/pci/fixups-sh03.c b/arch/sh/drivers/pci/fixups-sh03.c
index 57ac26c2171f..2e8a18b7ee53 100644
--- a/arch/sh/drivers/pci/fixups-sh03.c
+++ b/arch/sh/drivers/pci/fixups-sh03.c
@@ -3,11 +3,7 @@
3#include <linux/types.h> 3#include <linux/types.h>
4#include <linux/pci.h> 4#include <linux/pci.h>
5 5
6/* 6int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin)
7 * IRQ functions
8 */
9
10int __init pcibios_map_platform_irq(u8 slot, u8 pin, struct pci_dev *dev)
11{ 7{
12 int irq; 8 int irq;
13 9
@@ -17,8 +13,9 @@ int __init pcibios_map_platform_irq(u8 slot, u8 pin, struct pci_dev *dev)
17 case 8: return 5; /* eth1 */ 13 case 8: return 5; /* eth1 */
18 case 6: return 2; /* PCI bridge */ 14 case 6: return 2; /* PCI bridge */
19 default: 15 default:
20 printk("PCI: Bad IRQ mapping request for slot %d\n", slot); 16 printk(KERN_ERR "PCI: Bad IRQ mapping request "
21 return 2; 17 "for slot %d\n", slot);
18 return 2;
22 } 19 }
23 } else { 20 } else {
24 switch (pin) { 21 switch (pin) {
@@ -32,30 +29,3 @@ int __init pcibios_map_platform_irq(u8 slot, u8 pin, struct pci_dev *dev)
32 } 29 }
33 return irq; 30 return irq;
34} 31}
35
36static u8 __init sh03_no_swizzle(struct pci_dev *dev, u8 *pin)
37{
38 /* no swizzling */
39 return PCI_SLOT(dev->devfn);
40}
41
42static int sh03_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
43{
44 int irq = -1;
45
46 /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
47 irq = pcibios_map_platform_irq(slot, pin, dev);
48 if( irq < 0 ) {
49 pr_debug("PCI: Error mapping IRQ on device %s\n", pci_name(dev));
50 return irq;
51 }
52
53 pr_debug("Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
54
55 return irq;
56}
57
58void __init pcibios_fixup_irqs(void)
59{
60 pci_fixup_irqs(sh03_no_swizzle, sh03_pci_lookup_irq);
61}
diff --git a/arch/sh/drivers/pci/ops-bigsur.c b/arch/sh/drivers/pci/ops-bigsur.c
index ae82c6ca05e5..5da501bd77b5 100644
--- a/arch/sh/drivers/pci/ops-bigsur.c
+++ b/arch/sh/drivers/pci/ops-bigsur.c
@@ -10,15 +10,12 @@
10 * 10 *
11 * PCI initialization for the Hitachi Big Sur Evaluation Board 11 * PCI initialization for the Hitachi Big Sur Evaluation Board
12 */ 12 */
13
14#include <linux/kernel.h> 13#include <linux/kernel.h>
15#include <linux/types.h> 14#include <linux/types.h>
16#include <linux/init.h> 15#include <linux/init.h>
17#include <linux/delay.h>
18#include <linux/pci.h> 16#include <linux/pci.h>
19
20#include <asm/io.h> 17#include <asm/io.h>
21#include "pci-sh7751.h" 18#include "pci-sh4.h"
22#include <asm/bigsur/bigsur.h> 19#include <asm/bigsur/bigsur.h>
23 20
24#define BIGSUR_PCI_IO 0x4000 21#define BIGSUR_PCI_IO 0x4000
@@ -41,11 +38,11 @@ static struct resource sh7751_mem_resource = {
41extern struct pci_ops sh7751_pci_ops; 38extern struct pci_ops sh7751_pci_ops;
42 39
43struct pci_channel board_pci_channels[] = { 40struct pci_channel board_pci_channels[] = {
44 { &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff }, 41 { &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
45 { 0, } 42 { 0, }
46}; 43};
47 44
48static struct sh7751_pci_address_map sh7751_pci_map = { 45static struct sh4_pci_address_map sh7751_pci_map = {
49 .window0 = { 46 .window0 = {
50 .base = SH7751_CS3_BASE_ADDR, 47 .base = SH7751_CS3_BASE_ADDR,
51 .size = BIGSUR_LSR0_SIZE, 48 .size = BIGSUR_LSR0_SIZE,
@@ -58,7 +55,7 @@ static struct sh7751_pci_address_map sh7751_pci_map = {
58}; 55};
59 56
60/* 57/*
61 * Initialize the Big Sur PCI interface 58 * Initialize the Big Sur PCI interface
62 * Setup hardware to be Central Funtion 59 * Setup hardware to be Central Funtion
63 * Copy the BSR regs to the PCI interface 60 * Copy the BSR regs to the PCI interface
64 * Setup PCI windows into local RAM 61 * Setup PCI windows into local RAM
@@ -68,15 +65,15 @@ int __init pcibios_init_platform(void)
68 return sh7751_pcic_init(&sh7751_pci_map); 65 return sh7751_pcic_init(&sh7751_pci_map);
69} 66}
70 67
71int pcibios_map_platform_irq(u8 slot, u8 pin) 68int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
72{ 69{
73 /* 70 /*
74 * The Big Sur can be used in a CPCI chassis, but the SH7751 PCI 71 * The Big Sur can be used in a CPCI chassis, but the SH7751 PCI
75 * interface is on the wrong end of the board so that it can also 72 * interface is on the wrong end of the board so that it can also
76 * support a V320 CPI interface chip... Therefor the IRQ mapping is 73 * support a V320 CPI interface chip... Therefor the IRQ mapping is
77 * somewhat use dependent... I'l assume a linear map for now, i.e. 74 * somewhat use dependent... I'l assume a linear map for now, i.e.
78 * INTA=slot0,pin0... INTD=slot3,pin0... 75 * INTA=slot0,pin0... INTD=slot3,pin0...
79 */ 76 */
80 int irq = (slot + pin-1) % 4 + BIGSUR_SH7751_PCI_IRQ_BASE; 77 int irq = (slot + pin-1) % 4 + BIGSUR_SH7751_PCI_IRQ_BASE;
81 78
82 PCIDBG(2, "PCI: Mapping Big Sur IRQ for slot %d, pin %c to irq %d\n", 79 PCIDBG(2, "PCI: Mapping Big Sur IRQ for slot %d, pin %c to irq %d\n",
@@ -84,4 +81,3 @@ int pcibios_map_platform_irq(u8 slot, u8 pin)
84 81
85 return irq; 82 return irq;
86} 83}
87
diff --git a/arch/sh/drivers/pci/ops-landisk.c b/arch/sh/drivers/pci/ops-landisk.c
new file mode 100644
index 000000000000..ada301c21fe7
--- /dev/null
+++ b/arch/sh/drivers/pci/ops-landisk.c
@@ -0,0 +1,68 @@
1/*
2 * arch/sh/drivers/pci/ops-landisk.c
3 *
4 * PCI initialization for the I-O DATA Device, Inc. LANDISK board
5 *
6 * Copyright (C) 2006 kogiidena
7 *
8 * May be copied or modified under the terms of the GNU General Public
9 * License. See linux/COPYING for more information.
10 */
11#include <linux/config.h>
12#include <linux/kernel.h>
13#include <linux/types.h>
14#include <linux/init.h>
15#include <linux/delay.h>
16#include <linux/pci.h>
17#include "pci-sh4.h"
18
19static struct resource sh7751_io_resource = {
20 .name = "SH7751 IO",
21 .start = 0x4000,
22 .end = 0x4000 + SH7751_PCI_IO_SIZE - 1,
23 .flags = IORESOURCE_IO
24};
25
26static struct resource sh7751_mem_resource = {
27 .name = "SH7751 mem",
28 .start = SH7751_PCI_MEMORY_BASE,
29 .end = SH7751_PCI_MEMORY_BASE + SH7751_PCI_MEM_SIZE - 1,
30 .flags = IORESOURCE_MEM
31};
32
33struct pci_channel board_pci_channels[] = {
34 {&sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0x3ff},
35 {NULL, NULL, NULL, 0, 0},
36};
37
38static struct sh4_pci_address_map sh7751_pci_map = {
39 .window0 = {
40 .base = SH7751_CS3_BASE_ADDR,
41 .size = (64 << 20), /* 64MB */
42 },
43
44 .flags = SH4_PCIC_NO_RESET,
45};
46
47int __init pcibios_init_platform(void)
48{
49 return sh7751_pcic_init(&sh7751_pci_map);
50}
51
52int pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
53{
54 /*
55 * slot0: pin1-4 = irq5,6,7,8
56 * slot1: pin1-4 = irq6,7,8,5
57 * slot2: pin1-4 = irq7,8,5,6
58 * slot3: pin1-4 = irq8,5,6,7
59 */
60 int irq = ((slot + pin - 1) & 0x3) + 5;
61
62 if ((slot | (pin - 1)) > 0x3) {
63 printk("PCI: Bad IRQ mapping request for slot %d pin %c\n",
64 slot, pin - 1 + 'A');
65 return -1;
66 }
67 return irq;
68}
diff --git a/arch/sh/drivers/pci/ops-r7780rp.c b/arch/sh/drivers/pci/ops-r7780rp.c
new file mode 100644
index 000000000000..554d5ed2c586
--- /dev/null
+++ b/arch/sh/drivers/pci/ops-r7780rp.c
@@ -0,0 +1,75 @@
1/*
2 * Author: Ian DaSilva (idasilva@mvista.com)
3 *
4 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * PCI initialization for the Renesas SH7780 Highlander R7780RP-1 board
10 */
11
12#include <linux/config.h>
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/pci.h>
18#include <asm/r7780rp/r7780rp.h>
19#include <asm/io.h>
20#include "pci-sh4.h"
21
22int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
23{
24 switch (slot) {
25 case 0: return IRQ_PCISLOT1; /* PCI Interrupt #1 */
26 case 1: return IRQ_PCISLOT2; /* PCI Interrupt #2 */
27 case 2: return IRQ_PCISLOT3; /* PCI Interrupt #3 */
28 case 3: return IRQ_PCISLOT4; /* PCI Interrupt E4 */
29 default:
30 printk(KERN_ERR "PCI: Bad IRQ mapping "
31 "request for slot %d, func %d\n", slot, pin-1);
32 return -1;
33 }
34}
35
36static struct resource sh7780_io_resource = {
37 .name = "SH7780_IO",
38 .start = 0x2000,
39 .end = 0x2000 + SH7780_PCI_IO_SIZE - 1,
40 .flags = IORESOURCE_IO
41};
42
43static struct resource sh7780_mem_resource = {
44 .name = "SH7780_mem",
45 .start = SH7780_PCI_MEMORY_BASE,
46 .end = SH7780_PCI_MEMORY_BASE + SH7780_PCI_MEM_SIZE - 1,
47 .flags = IORESOURCE_MEM
48};
49
50extern struct pci_ops sh7780_pci_ops;
51
52struct pci_channel board_pci_channels[] = {
53 { &sh4_pci_ops, &sh7780_io_resource, &sh7780_mem_resource, 0, 0xff },
54 { NULL, NULL, NULL, 0, 0 },
55};
56EXPORT_SYMBOL(board_pci_channels);
57
58static struct sh4_pci_address_map sh7780_pci_map = {
59 .window0 = {
60 .base = SH7780_CS2_BASE_ADDR,
61 .size = 0x04000000,
62 },
63
64 .window1 = {
65 .base = SH7780_CS3_BASE_ADDR,
66 .size = 0x04000000,
67 },
68
69 .flags = SH4_PCIC_NO_RESET,
70};
71
72int __init pcibios_init_platform(void)
73{
74 return sh7780_pcic_init(&sh7780_pci_map);
75}
diff --git a/arch/sh/drivers/pci/ops-rts7751r2d.c b/arch/sh/drivers/pci/ops-rts7751r2d.c
index 83171d10141a..88f44e245424 100644
--- a/arch/sh/drivers/pci/ops-rts7751r2d.c
+++ b/arch/sh/drivers/pci/ops-rts7751r2d.c
@@ -17,12 +17,11 @@
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/module.h> 19#include <linux/module.h>
20
21#include <asm/io.h>
22#include "pci-sh7751.h"
23#include <asm/rts7751r2d/rts7751r2d.h> 20#include <asm/rts7751r2d/rts7751r2d.h>
21#include <asm/io.h>
22#include "pci-sh4.h"
24 23
25int __init pcibios_map_platform_irq(u8 slot, u8 pin) 24int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
26{ 25{
27 switch (slot) { 26 switch (slot) {
28 case 0: return IRQ_PCISLOT1; /* PCI Extend slot #1 */ 27 case 0: return IRQ_PCISLOT1; /* PCI Extend slot #1 */
@@ -52,12 +51,12 @@ static struct resource sh7751_mem_resource = {
52extern struct pci_ops sh7751_pci_ops; 51extern struct pci_ops sh7751_pci_ops;
53 52
54struct pci_channel board_pci_channels[] = { 53struct pci_channel board_pci_channels[] = {
55 { &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff }, 54 { &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
56 { NULL, NULL, NULL, 0, 0 }, 55 { NULL, NULL, NULL, 0, 0 },
57}; 56};
58EXPORT_SYMBOL(board_pci_channels); 57EXPORT_SYMBOL(board_pci_channels);
59 58
60static struct sh7751_pci_address_map sh7751_pci_map = { 59static struct sh4_pci_address_map sh7751_pci_map = {
61 .window0 = { 60 .window0 = {
62 .base = SH7751_CS3_BASE_ADDR, 61 .base = SH7751_CS3_BASE_ADDR,
63 .size = 0x04000000, 62 .size = 0x04000000,
@@ -68,7 +67,7 @@ static struct sh7751_pci_address_map sh7751_pci_map = {
68 .size = 0x00000000, /* Unused */ 67 .size = 0x00000000, /* Unused */
69 }, 68 },
70 69
71 .flags = SH7751_PCIC_NO_RESET, 70 .flags = SH4_PCIC_NO_RESET,
72}; 71};
73 72
74int __init pcibios_init_platform(void) 73int __init pcibios_init_platform(void)
diff --git a/arch/sh/drivers/pci/ops-sh4.c b/arch/sh/drivers/pci/ops-sh4.c
new file mode 100644
index 000000000000..2d4371009a5e
--- /dev/null
+++ b/arch/sh/drivers/pci/ops-sh4.c
@@ -0,0 +1,164 @@
1/*
2 * Generic SH-4 / SH-4A PCIC operations (SH7751, SH7780).
3 *
4 * Copyright (C) 2002 - 2006 Paul Mundt
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License v2. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10#include <linux/pci.h>
11#include <asm/addrspace.h>
12#include <asm/io.h>
13#include "pci-sh4.h"
14
15/*
16 * Direct access to PCI hardware...
17 */
18#define CONFIG_CMD(bus, devfn, where) \
19 P1SEGADDR((bus->number << 16) | (devfn << 8) | (where & ~3))
20
21static DEFINE_SPINLOCK(sh4_pci_lock);
22
23/*
24 * Functions for accessing PCI configuration space with type 1 accesses
25 */
26static int sh4_pci_read(struct pci_bus *bus, unsigned int devfn,
27 int where, int size, u32 *val)
28{
29 unsigned long flags;
30 u32 data;
31
32 /*
33 * PCIPDR may only be accessed as 32 bit words,
34 * so we must do byte alignment by hand
35 */
36 spin_lock_irqsave(&sh4_pci_lock, flags);
37 pci_write_reg(CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
38 data = pci_read_reg(SH4_PCIPDR);
39 spin_unlock_irqrestore(&sh4_pci_lock, flags);
40
41 switch (size) {
42 case 1:
43 *val = (data >> ((where & 3) << 3)) & 0xff;
44 break;
45 case 2:
46 *val = (data >> ((where & 2) << 3)) & 0xffff;
47 break;
48 case 4:
49 *val = data;
50 break;
51 default:
52 return PCIBIOS_FUNC_NOT_SUPPORTED;
53 }
54
55 return PCIBIOS_SUCCESSFUL;
56}
57
58/*
59 * Since SH4 only does 32bit access we'll have to do a read,
60 * mask,write operation.
61 * We'll allow an odd byte offset, though it should be illegal.
62 */
63static int sh4_pci_write(struct pci_bus *bus, unsigned int devfn,
64 int where, int size, u32 val)
65{
66 unsigned long flags;
67 int shift;
68 u32 data;
69
70 spin_lock_irqsave(&sh4_pci_lock, flags);
71 pci_write_reg(CONFIG_CMD(bus, devfn, where), SH4_PCIPAR);
72 data = pci_read_reg(SH4_PCIPDR);
73 spin_unlock_irqrestore(&sh4_pci_lock, flags);
74
75 switch (size) {
76 case 1:
77 shift = (where & 3) << 3;
78 data &= ~(0xff << shift);
79 data |= ((val & 0xff) << shift);
80 break;
81 case 2:
82 shift = (where & 2) << 3;
83 data &= ~(0xffff << shift);
84 data |= ((val & 0xffff) << shift);
85 break;
86 case 4:
87 data = val;
88 break;
89 default:
90 return PCIBIOS_FUNC_NOT_SUPPORTED;
91 }
92
93 pci_write_reg(data, SH4_PCIPDR);
94
95 return PCIBIOS_SUCCESSFUL;
96}
97
98struct pci_ops sh4_pci_ops = {
99 .read = sh4_pci_read,
100 .write = sh4_pci_write,
101};
102
103/*
104 * Not really related to pci_ops, but it's common and not worth shoving
105 * somewhere else for now..
106 */
107static unsigned int pci_probe = PCI_PROBE_CONF1;
108
109int __init sh4_pci_check_direct(void)
110{
111 /*
112 * Check if configuration works.
113 */
114 if (pci_probe & PCI_PROBE_CONF1) {
115 unsigned int tmp = pci_read_reg(SH4_PCIPAR);
116
117 pci_write_reg(P1SEG, SH4_PCIPAR);
118
119 if (pci_read_reg(SH4_PCIPAR) == P1SEG) {
120 pci_write_reg(tmp, SH4_PCIPAR);
121 printk(KERN_INFO "PCI: Using configuration type 1\n");
122 request_region(PCI_REG(SH4_PCIPAR), 8, "PCI conf1");
123
124 return 0;
125 }
126
127 pci_write_reg(tmp, SH4_PCIPAR);
128 }
129
130 pr_debug("PCI: pci_check_direct failed\n");
131 return -EINVAL;
132}
133
134/* Handle generic fixups */
135static void __init pci_fixup_ide_bases(struct pci_dev *d)
136{
137 int i;
138
139 /*
140 * PCI IDE controllers use non-standard I/O port decoding, respect it.
141 */
142 if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
143 return;
144 pr_debug("PCI: IDE base address fixup for %s\n", pci_name(d));
145 for(i = 0; i < 4; i++) {
146 struct resource *r = &d->resource[i];
147
148 if ((r->start & ~0x80) == 0x374) {
149 r->start |= 2;
150 r->end = r->start;
151 }
152 }
153}
154DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases);
155
156char * __init pcibios_setup(char *str)
157{
158 if (!strcmp(str, "off")) {
159 pci_probe = 0;
160 return NULL;
161 }
162
163 return str;
164}
diff --git a/arch/sh/drivers/pci/ops-snapgear.c b/arch/sh/drivers/pci/ops-snapgear.c
index 3cbd14dd28fe..53dd893d4e54 100644
--- a/arch/sh/drivers/pci/ops-snapgear.c
+++ b/arch/sh/drivers/pci/ops-snapgear.c
@@ -2,7 +2,7 @@
2 * arch/sh/drivers/pci/ops-snapgear.c 2 * arch/sh/drivers/pci/ops-snapgear.c
3 * 3 *
4 * Author: David McCullough <davidm@snapgear.com> 4 * Author: David McCullough <davidm@snapgear.com>
5 * 5 *
6 * Ported to new API by Paul Mundt <lethal@linux-sh.org> 6 * Ported to new API by Paul Mundt <lethal@linux-sh.org>
7 * 7 *
8 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire. 8 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
@@ -12,15 +12,11 @@
12 * 12 *
13 * PCI initialization for the SnapGear boards 13 * PCI initialization for the SnapGear boards
14 */ 14 */
15
16#include <linux/kernel.h> 15#include <linux/kernel.h>
17#include <linux/types.h> 16#include <linux/types.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/delay.h>
20#include <linux/pci.h> 18#include <linux/pci.h>
21 19#include "pci-sh4.h"
22#include <asm/io.h>
23#include "pci-sh7751.h"
24 20
25#define SNAPGEAR_PCI_IO 0x4000 21#define SNAPGEAR_PCI_IO 0x4000
26#define SNAPGEAR_PCI_MEM 0xfd000000 22#define SNAPGEAR_PCI_MEM 0xfd000000
@@ -43,14 +39,12 @@ static struct resource sh7751_mem_resource = {
43 .flags = IORESOURCE_MEM, 39 .flags = IORESOURCE_MEM,
44}; 40};
45 41
46extern struct pci_ops sh7751_pci_ops;
47
48struct pci_channel board_pci_channels[] = { 42struct pci_channel board_pci_channels[] = {
49 { &sh7751_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff }, 43 { &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
50 { 0, } 44 { 0, }
51}; 45};
52 46
53static struct sh7751_pci_address_map sh7751_pci_map = { 47static struct sh4_pci_address_map sh7751_pci_map = {
54 .window0 = { 48 .window0 = {
55 .base = SH7751_CS2_BASE_ADDR, 49 .base = SH7751_CS2_BASE_ADDR,
56 .size = SNAPGEAR_LSR0_SIZE, 50 .size = SNAPGEAR_LSR0_SIZE,
@@ -61,11 +55,11 @@ static struct sh7751_pci_address_map sh7751_pci_map = {
61 .size = SNAPGEAR_LSR1_SIZE, 55 .size = SNAPGEAR_LSR1_SIZE,
62 }, 56 },
63 57
64 .flags = SH7751_PCIC_NO_RESET, 58 .flags = SH4_PCIC_NO_RESET,
65}; 59};
66 60
67/* 61/*
68 * Initialize the SnapGear PCI interface 62 * Initialize the SnapGear PCI interface
69 * Setup hardware to be Central Funtion 63 * Setup hardware to be Central Funtion
70 * Copy the BSR regs to the PCI interface 64 * Copy the BSR regs to the PCI interface
71 * Setup PCI windows into local RAM 65 * Setup PCI windows into local RAM
@@ -75,7 +69,7 @@ int __init pcibios_init_platform(void)
75 return sh7751_pcic_init(&sh7751_pci_map); 69 return sh7751_pcic_init(&sh7751_pci_map);
76} 70}
77 71
78int __init pcibios_map_platform_irq(u8 slot, u8 pin) 72int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
79{ 73{
80 int irq = -1; 74 int irq = -1;
81 75
@@ -98,4 +92,3 @@ void __init pcibios_fixup(void)
98{ 92{
99 /* Nothing to fixup .. */ 93 /* Nothing to fixup .. */
100} 94}
101
diff --git a/arch/sh/drivers/pci/ops-titan.c b/arch/sh/drivers/pci/ops-titan.c
new file mode 100644
index 000000000000..c6097bcd97fd
--- /dev/null
+++ b/arch/sh/drivers/pci/ops-titan.c
@@ -0,0 +1,83 @@
1/*
2 * arch/sh/drivers/pci/ops-titan.c
3 *
4 * Ported to new API by Paul Mundt <lethal@linux-sh.org>
5 *
6 * Modified from ops-snapgear.c written by David McCullough
7 * Highly leveraged from pci-bigsur.c, written by Dustin McIntire.
8 *
9 * May be copied or modified under the terms of the GNU General Public
10 * License. See linux/COPYING for more information.
11 *
12 * PCI initialization for the Titan boards
13 */
14
15#include <linux/config.h>
16#include <linux/kernel.h>
17#include <linux/types.h>
18#include <linux/init.h>
19#include <linux/pci.h>
20#include <asm/io.h>
21#include <asm/titan.h>
22#include "pci-sh4.h"
23
24int __init pcibios_map_platform_irq(struct pci_dev *pdev, u8 slot, u8 pin)
25{
26 int irq = -1;
27
28 switch (slot) {
29 case 0: irq = TITAN_IRQ_WAN; break; /* eth0 (WAN) */
30 case 1: irq = TITAN_IRQ_LAN; break; /* eth1 (LAN) */
31 case 2: irq = TITAN_IRQ_MPCIA; break; /* mPCI A */
32 case 3: irq = TITAN_IRQ_MPCIB; break; /* mPCI B */
33 case 4: irq = TITAN_IRQ_USB; break; /* USB */
34 default:
35 printk(KERN_INFO "PCI: Bad IRQ mapping "
36 "request for slot %d\n", slot);
37 return -1;
38 }
39
40 printk("PCI: Mapping TITAN IRQ for slot %d, pin %c to irq %d\n",
41 slot, pin - 1 + 'A', irq);
42
43 return irq;
44}
45
46static struct resource sh7751_io_resource = {
47 .name = "SH7751_IO",
48 .start = SH7751_PCI_IO_BASE,
49 .end = SH7751_PCI_IO_BASE + SH7751_PCI_IO_SIZE - 1,
50 .flags = IORESOURCE_IO
51};
52
53static struct resource sh7751_mem_resource = {
54 .name = "SH7751_mem",
55 .start = SH7751_PCI_MEMORY_BASE,
56 .end = SH7751_PCI_MEMORY_BASE + SH7751_PCI_MEM_SIZE - 1,
57 .flags = IORESOURCE_MEM
58};
59
60struct pci_channel board_pci_channels[] = {
61 { &sh4_pci_ops, &sh7751_io_resource, &sh7751_mem_resource, 0, 0xff },
62 { NULL, NULL, NULL, 0, 0 },
63};
64EXPORT_SYMBOL(board_pci_channels);
65
66static struct sh4_pci_address_map sh7751_pci_map = {
67 .window0 = {
68 .base = SH7751_CS2_BASE_ADDR,
69 .size = SH7751_MEM_REGION_SIZE*2, /* cs2 and cs3 */
70 },
71
72 .window1 = {
73 .base = SH7751_CS2_BASE_ADDR,
74 .size = SH7751_MEM_REGION_SIZE*2,
75 },
76
77 .flags = SH4_PCIC_NO_RESET,
78};
79
80int __init pcibios_init_platform(void)
81{
82 return sh7751_pcic_init(&sh7751_pci_map);
83}
diff --git a/arch/sh/drivers/pci/pci-auto.c b/arch/sh/drivers/pci/pci-auto.c
index 4cef4d1d8c84..ecf16344f94a 100644
--- a/arch/sh/drivers/pci/pci-auto.c
+++ b/arch/sh/drivers/pci/pci-auto.c
@@ -45,11 +45,11 @@
45#include <linux/types.h> 45#include <linux/types.h>
46#include <linux/pci.h> 46#include <linux/pci.h>
47 47
48#undef DEBUG 48#define DEBUG
49#ifdef DEBUG 49#ifdef DEBUG
50#define DBG(x...) printk(x) 50#define DBG(x...) printk(x)
51#else 51#else
52#define DBG(x...) 52#define DBG(x...)
53#endif 53#endif
54 54
55/* 55/*
@@ -102,7 +102,7 @@ static u32 pciauto_upper_iospc;
102static u32 pciauto_lower_memspc; 102static u32 pciauto_lower_memspc;
103static u32 pciauto_upper_memspc; 103static u32 pciauto_upper_memspc;
104 104
105static void __init 105static void __init
106pciauto_setup_bars(struct pci_channel *hose, 106pciauto_setup_bars(struct pci_channel *hose,
107 int top_bus, 107 int top_bus,
108 int current_bus, 108 int current_bus,
@@ -116,7 +116,6 @@ pciauto_setup_bars(struct pci_channel *hose,
116 int found_mem64 = 0; 116 int found_mem64 = 0;
117 117
118 for (bar = PCI_BASE_ADDRESS_0; bar <= bar_limit; bar+=4) { 118 for (bar = PCI_BASE_ADDRESS_0; bar <= bar_limit; bar+=4) {
119#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
120 u32 bar_addr; 119 u32 bar_addr;
121 120
122 /* Read the old BAR value */ 121 /* Read the old BAR value */
@@ -125,7 +124,6 @@ pciauto_setup_bars(struct pci_channel *hose,
125 pci_devfn, 124 pci_devfn,
126 bar, 125 bar,
127 &bar_addr); 126 &bar_addr);
128#endif
129 127
130 /* Tickle the BAR and get the response */ 128 /* Tickle the BAR and get the response */
131 early_write_config_dword(hose, top_bus, 129 early_write_config_dword(hose, top_bus,
@@ -140,8 +138,7 @@ pciauto_setup_bars(struct pci_channel *hose,
140 bar, 138 bar,
141 &bar_response); 139 &bar_response);
142 140
143#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D) 141 /*
144 /*
145 * Write the old BAR value back out, only update the BAR 142 * Write the old BAR value back out, only update the BAR
146 * if we implicitly want resources to be updated, which 143 * if we implicitly want resources to be updated, which
147 * is done by the generic code further down. -- PFM. 144 * is done by the generic code further down. -- PFM.
@@ -151,7 +148,6 @@ pciauto_setup_bars(struct pci_channel *hose,
151 pci_devfn, 148 pci_devfn,
152 bar, 149 bar,
153 bar_addr); 150 bar_addr);
154#endif
155 151
156 /* If BAR is not implemented go to the next BAR */ 152 /* If BAR is not implemented go to the next BAR */
157 if (!bar_response) 153 if (!bar_response)
@@ -177,7 +173,7 @@ retry:
177 PCI_BASE_ADDRESS_MEM_TYPE_64) 173 PCI_BASE_ADDRESS_MEM_TYPE_64)
178 found_mem64 = 1; 174 found_mem64 = 1;
179 175
180 addr_mask = PCI_BASE_ADDRESS_MEM_MASK; 176 addr_mask = PCI_BASE_ADDRESS_MEM_MASK;
181 upper_limit = &pciauto_upper_memspc; 177 upper_limit = &pciauto_upper_memspc;
182 lower_limit = &pciauto_lower_memspc; 178 lower_limit = &pciauto_lower_memspc;
183 DBG(" Mem"); 179 DBG(" Mem");
@@ -193,22 +189,22 @@ retry:
193 if ((bar_value + bar_size) > *upper_limit) { 189 if ((bar_value + bar_size) > *upper_limit) {
194 if (bar_response & PCI_BASE_ADDRESS_SPACE) { 190 if (bar_response & PCI_BASE_ADDRESS_SPACE) {
195 if (io_resource_inuse->child) { 191 if (io_resource_inuse->child) {
196 io_resource_inuse = 192 io_resource_inuse =
197 io_resource_inuse->child; 193 io_resource_inuse->child;
198 pciauto_lower_iospc = 194 pciauto_lower_iospc =
199 io_resource_inuse->start; 195 io_resource_inuse->start;
200 pciauto_upper_iospc = 196 pciauto_upper_iospc =
201 io_resource_inuse->end + 1; 197 io_resource_inuse->end + 1;
202 goto retry; 198 goto retry;
203 } 199 }
204 200
205 } else { 201 } else {
206 if (mem_resource_inuse->child) { 202 if (mem_resource_inuse->child) {
207 mem_resource_inuse = 203 mem_resource_inuse =
208 mem_resource_inuse->child; 204 mem_resource_inuse->child;
209 pciauto_lower_memspc = 205 pciauto_lower_memspc =
210 mem_resource_inuse->start; 206 mem_resource_inuse->start;
211 pciauto_upper_memspc = 207 pciauto_upper_memspc =
212 mem_resource_inuse->end + 1; 208 mem_resource_inuse->end + 1;
213 goto retry; 209 goto retry;
214 } 210 }
@@ -230,7 +226,7 @@ retry:
230 * If we are a 64-bit decoder then increment to the 226 * If we are a 64-bit decoder then increment to the
231 * upper 32 bits of the bar and force it to locate 227 * upper 32 bits of the bar and force it to locate
232 * in the lower 4GB of memory. 228 * in the lower 4GB of memory.
233 */ 229 */
234 if (found_mem64) { 230 if (found_mem64) {
235 bar += 4; 231 bar += 4;
236 early_write_config_dword(hose, top_bus, 232 early_write_config_dword(hose, top_bus,
@@ -362,7 +358,6 @@ pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
362{ 358{
363 u32 temp; 359 u32 temp;
364 360
365#if !defined(CONFIG_SH_HS7751RVOIP) && !defined(CONFIG_SH_RTS7751R2D)
366 /* 361 /*
367 * [jsun] we always bump up baselines a little, so that if there 362 * [jsun] we always bump up baselines a little, so that if there
368 * nothing behind P2P bridge, we don't wind up overlapping IO/MEM 363 * nothing behind P2P bridge, we don't wind up overlapping IO/MEM
@@ -370,7 +365,6 @@ pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
370 */ 365 */
371 pciauto_lower_memspc += 1; 366 pciauto_lower_memspc += 1;
372 pciauto_lower_iospc += 1; 367 pciauto_lower_iospc += 1;
373#endif
374 368
375 /* 369 /*
376 * Configure subordinate bus number. The PCI subsystem 370 * Configure subordinate bus number. The PCI subsystem
@@ -396,11 +390,6 @@ pciauto_postscan_setup_cardbus_bridge(struct pci_channel *hose,
396 * configured by this routine to happily live behind a 390 * configured by this routine to happily live behind a
397 * P2P bridge in a system. 391 * P2P bridge in a system.
398 */ 392 */
399#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
400 pciauto_lower_memspc += 0x00400000;
401 pciauto_lower_iospc += 0x00004000;
402#endif
403
404 /* Align memory and I/O to 4KB and 4 byte boundaries. */ 393 /* Align memory and I/O to 4KB and 4 byte boundaries. */
405 pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1)) 394 pciauto_lower_memspc = (pciauto_lower_memspc + (0x1000 - 1))
406 & ~(0x1000 - 1); 395 & ~(0x1000 - 1);
@@ -433,12 +422,12 @@ pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
433 int devfn_stop = 0xff; 422 int devfn_stop = 0xff;
434 423
435 sub_bus = current_bus; 424 sub_bus = current_bus;
436 425
437 if (hose->first_devfn) 426 if (hose->first_devfn)
438 devfn_start = hose->first_devfn; 427 devfn_start = hose->first_devfn;
439 if (hose->last_devfn) 428 if (hose->last_devfn)
440 devfn_stop = hose->last_devfn; 429 devfn_stop = hose->last_devfn;
441 430
442 for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) { 431 for (pci_devfn=devfn_start; pci_devfn<devfn_stop; pci_devfn++) {
443 432
444 if (PCI_FUNC(pci_devfn) && !found_multi) 433 if (PCI_FUNC(pci_devfn) && !found_multi)
@@ -471,9 +460,6 @@ pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
471 if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) { 460 if ((pci_class >> 16) == PCI_CLASS_BRIDGE_PCI) {
472 DBG(" Bridge: primary=%.2x, secondary=%.2x\n", 461 DBG(" Bridge: primary=%.2x, secondary=%.2x\n",
473 current_bus, sub_bus + 1); 462 current_bus, sub_bus + 1);
474#if defined(CONFIG_SH_HS7751RVOIP) || defined(CONFIG_SH_RTS7751R2D)
475 pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_1);
476#endif
477 pciauto_prescan_setup_bridge(hose, top_bus, current_bus, 463 pciauto_prescan_setup_bridge(hose, top_bus, current_bus,
478 pci_devfn, sub_bus); 464 pci_devfn, sub_bus);
479 DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n", 465 DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
@@ -490,10 +476,10 @@ pciauto_bus_scan(struct pci_channel *hose, int top_bus, int current_bus)
490 DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn)); 476 DBG("PCI Autoconfig: Found CardBus bridge, device %d function %d\n", PCI_SLOT(pci_devfn), PCI_FUNC(pci_devfn));
491 /* Place CardBus Socket/ExCA registers */ 477 /* Place CardBus Socket/ExCA registers */
492 pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_0); 478 pciauto_setup_bars(hose, top_bus, current_bus, pci_devfn, PCI_BASE_ADDRESS_0);
493 479
494 pciauto_prescan_setup_cardbus_bridge(hose, top_bus, 480 pciauto_prescan_setup_cardbus_bridge(hose, top_bus,
495 current_bus, pci_devfn, sub_bus); 481 current_bus, pci_devfn, sub_bus);
496 482
497 DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n", 483 DBG("Scanning sub bus %.2x, I/O 0x%.8x, Mem 0x%.8x\n",
498 sub_bus + 1, 484 sub_bus + 1,
499 pciauto_lower_iospc, pciauto_lower_memspc); 485 pciauto_lower_iospc, pciauto_lower_memspc);
diff --git a/arch/sh/drivers/pci/pci-sh4.h b/arch/sh/drivers/pci/pci-sh4.h
new file mode 100644
index 000000000000..5a61d6041f2c
--- /dev/null
+++ b/arch/sh/drivers/pci/pci-sh4.h
@@ -0,0 +1,180 @@
1#ifndef __PCI_SH4_H
2#define __PCI_SH4_H
3
4#ifdef CONFIG_CPU_SUBTYPE_SH7780
5#include "pci-sh7780.h"
6#else
7#include "pci-sh7751.h"
8#endif
9
10#include <asm/io.h>
11
12/* startup values */
13#define PCI_PROBE_BIOS 1
14#define PCI_PROBE_CONF1 2
15#define PCI_PROBE_CONF2 4
16#define PCI_NO_SORT 0x100
17#define PCI_BIOS_SORT 0x200
18#define PCI_NO_CHECKS 0x400
19#define PCI_ASSIGN_ROMS 0x1000
20#define PCI_BIOS_IRQ_SCAN 0x2000
21
22#define SH4_PCICR 0x100 /* PCI Control Register */
23 #define SH4_PCICR_PREFIX 0xA5000000 /* CR prefix for write */
24 #define SH4_PCICR_FTO 0x00000400 /* TRDY/IRDY Enable */
25 #define SH4_PCICR_TRSB 0x00000200 /* Target Read Single */
26 #define SH4_PCICR_BSWP 0x00000100 /* Target Byte Swap */
27 #define SH4_PCICR_PLUP 0x00000080 /* Enable PCI Pullup */
28 #define SH4_PCICR_ARBM 0x00000040 /* PCI Arbitration Mode */
29 #define SH4_PCICR_MD 0x00000030 /* MD9 and MD10 status */
30 #define SH4_PCICR_SERR 0x00000008 /* SERR output assert */
31 #define SH4_PCICR_INTA 0x00000004 /* INTA output assert */
32 #define SH4_PCICR_PRST 0x00000002 /* PCI Reset Assert */
33 #define SH4_PCICR_CFIN 0x00000001 /* Central Fun. Init Done */
34#define SH4_PCILSR0 0x104 /* PCI Local Space Register0 */
35#define SH4_PCILSR1 0x108 /* PCI Local Space Register1 */
36#define SH4_PCILAR0 0x10C /* PCI Local Addr Register1 */
37#define SH4_PCILAR1 0x110 /* PCI Local Addr Register1 */
38#define SH4_PCIINT 0x114 /* PCI Interrupt Register */
39 #define SH4_PCIINT_MLCK 0x00008000 /* Master Lock Error */
40 #define SH4_PCIINT_TABT 0x00004000 /* Target Abort Error */
41 #define SH4_PCIINT_TRET 0x00000200 /* Target Retry Error */
42 #define SH4_PCIINT_MFDE 0x00000100 /* Master Func. Disable Error */
43 #define SH4_PCIINT_PRTY 0x00000080 /* Address Parity Error */
44 #define SH4_PCIINT_SERR 0x00000040 /* SERR Detection Error */
45 #define SH4_PCIINT_TWDP 0x00000020 /* Tgt. Write Parity Error */
46 #define SH4_PCIINT_TRDP 0x00000010 /* Tgt. Read Parity Err Det. */
47 #define SH4_PCIINT_MTABT 0x00000008 /* Master-Tgt. Abort Error */
48 #define SH4_PCIINT_MMABT 0x00000004 /* Master-Master Abort Error */
49 #define SH4_PCIINT_MWPD 0x00000002 /* Master Write PERR Detect */
50 #define SH4_PCIINT_MRPD 0x00000001 /* Master Read PERR Detect */
51#define SH4_PCIINTM 0x118 /* PCI Interrupt Mask */
52#define SH4_PCIALR 0x11C /* Error Address Register */
53#define SH4_PCICLR 0x120 /* Error Command/Data */
54 #define SH4_PCICLR_MPIO 0x80000000
55 #define SH4_PCICLR_MDMA0 0x40000000 /* DMA0 Transfer Error */
56 #define SH4_PCICLR_MDMA1 0x20000000 /* DMA1 Transfer Error */
57 #define SH4_PCICLR_MDMA2 0x10000000 /* DMA2 Transfer Error */
58 #define SH4_PCICLR_MDMA3 0x08000000 /* DMA3 Transfer Error */
59 #define SH4_PCICLR_TGT 0x04000000 /* Target Transfer Error */
60 #define SH4_PCICLR_CMDL 0x0000000F /* PCI Command at Error */
61#define SH4_PCIAINT 0x130 /* Arbiter Interrupt Register */
62 #define SH4_PCIAINT_MBKN 0x00002000 /* Master Broken Interrupt */
63 #define SH4_PCIAINT_TBTO 0x00001000 /* Target Bus Time Out */
64 #define SH4_PCIAINT_MBTO 0x00001000 /* Master Bus Time Out */
65 #define SH4_PCIAINT_TABT 0x00000008 /* Target Abort */
66 #define SH4_PCIAINT_MABT 0x00000004 /* Master Abort */
67 #define SH4_PCIAINT_RDPE 0x00000002 /* Read Data Parity Error */
68 #define SH4_PCIAINT_WDPE 0x00000001 /* Write Data Parity Error */
69#define SH4_PCIAINTM 0x134 /* Arbiter Int. Mask Register */
70#define SH4_PCIBMLR 0x138 /* Error Bus Master Register */
71 #define SH4_PCIBMLR_REQ4 0x00000010 /* REQ4 bus master at error */
72 #define SH4_PCIBMLR_REQ3 0x00000008 /* REQ3 bus master at error */
73 #define SH4_PCIBMLR_REQ2 0x00000004 /* REQ2 bus master at error */
74 #define SH4_PCIBMLR_REQ1 0x00000002 /* REQ1 bus master at error */
75 #define SH4_PCIBMLR_REQ0 0x00000001 /* REQ0 bus master at error */
76#define SH4_PCIDMABT 0x140 /* DMA Transfer Arb. Register */
77 #define SH4_PCIDMABT_RRBN 0x00000001 /* DMA Arbitor Round-Robin */
78#define SH4_PCIDPA0 0x180 /* DMA0 Transfer Addr. */
79#define SH4_PCIDLA0 0x184 /* DMA0 Local Addr. */
80#define SH4_PCIDTC0 0x188 /* DMA0 Transfer Cnt. */
81#define SH4_PCIDCR0 0x18C /* DMA0 Control Register */
82 #define SH4_PCIDCR_ALGN 0x00000600 /* DMA Alignment Mode */
83 #define SH4_PCIDCR_MAST 0x00000100 /* DMA Termination Type */
84 #define SH4_PCIDCR_INTM 0x00000080 /* DMA Interrupt Done Mask*/
85 #define SH4_PCIDCR_INTS 0x00000040 /* DMA Interrupt Done Status */
86 #define SH4_PCIDCR_LHLD 0x00000020 /* Local Address Control */
87 #define SH4_PCIDCR_PHLD 0x00000010 /* PCI Address Control*/
88 #define SH4_PCIDCR_IOSEL 0x00000008 /* PCI Address Space Type */
89 #define SH4_PCIDCR_DIR 0x00000004 /* DMA Transfer Direction */
90 #define SH4_PCIDCR_STOP 0x00000002 /* Force DMA Stop */
91 #define SH4_PCIDCR_STRT 0x00000001 /* DMA Start */
92#define SH4_PCIDPA1 0x190 /* DMA1 Transfer Addr. */
93#define SH4_PCIDLA1 0x194 /* DMA1 Local Addr. */
94#define SH4_PCIDTC1 0x198 /* DMA1 Transfer Cnt. */
95#define SH4_PCIDCR1 0x19C /* DMA1 Control Register */
96#define SH4_PCIDPA2 0x1A0 /* DMA2 Transfer Addr. */
97#define SH4_PCIDLA2 0x1A4 /* DMA2 Local Addr. */
98#define SH4_PCIDTC2 0x1A8 /* DMA2 Transfer Cnt. */
99#define SH4_PCIDCR2 0x1AC /* DMA2 Control Register */
100#define SH4_PCIDPA3 0x1B0 /* DMA3 Transfer Addr. */
101#define SH4_PCIDLA3 0x1B4 /* DMA3 Local Addr. */
102#define SH4_PCIDTC3 0x1B8 /* DMA3 Transfer Cnt. */
103#define SH4_PCIDCR3 0x1BC /* DMA3 Control Register */
104#define SH4_PCIPAR 0x1C0 /* PIO Address Register */
105 #define SH4_PCIPAR_CFGEN 0x80000000 /* Configuration Enable */
106 #define SH4_PCIPAR_BUSNO 0x00FF0000 /* Config. Bus Number */
107 #define SH4_PCIPAR_DEVNO 0x0000FF00 /* Config. Device Number */
108 #define SH4_PCIPAR_REGAD 0x000000FC /* Register Address Number */
109#define SH4_PCIMBR 0x1C4 /* Memory Base Address */
110 #define SH4_PCIMBR_MASK 0xFF000000 /* Memory Space Mask */
111 #define SH4_PCIMBR_LOCK 0x00000001 /* Lock Memory Space */
112#define SH4_PCIIOBR 0x1C8 /* I/O Base Address Register */
113 #define SH4_PCIIOBR_MASK 0xFFFC0000 /* IO Space Mask */
114 #define SH4_PCIIOBR_LOCK 0x00000001 /* Lock IO Space */
115#define SH4_PCIPINT 0x1CC /* Power Mgmnt Int. Register */
116 #define SH4_PCIPINT_D3 0x00000002 /* D3 Pwr Mgmt. Interrupt */
117 #define SH4_PCIPINT_D0 0x00000001 /* D0 Pwr Mgmt. Interrupt */
118#define SH4_PCIPINTM 0x1D0 /* Power Mgmnt Mask Register */
119#define SH4_PCICLKR 0x1D4 /* Clock Ctrl. Register */
120 #define SH4_PCICLKR_PCSTP 0x00000002 /* PCI Clock Stop */
121 #define SH4_PCICLKR_BCSTP 0x00000001 /* BCLK Clock Stop */
122/* For definitions of BCR, MCR see ... */
123#define SH4_PCIBCR1 0x1E0 /* Memory BCR1 Register */
124 #define SH4_PCIMBR0 SH4_PCIBCR1
125#define SH4_PCIBCR2 0x1E4 /* Memory BCR2 Register */
126 #define SH4_PCIMBMR0 SH4_PCIBCR2
127#define SH4_PCIWCR1 0x1E8 /* Wait Control 1 Register */
128#define SH4_PCIWCR2 0x1EC /* Wait Control 2 Register */
129#define SH4_PCIWCR3 0x1F0 /* Wait Control 3 Register */
130 #define SH4_PCIMBR2 SH4_PCIWCR3
131#define SH4_PCIMCR 0x1F4 /* Memory Control Register */
132#define SH4_PCIBCR3 0x1f8 /* Memory BCR3 Register */
133#define SH4_PCIPCTR 0x200 /* Port Control Register */
134 #define SH4_PCIPCTR_P2EN 0x000400000 /* Port 2 Enable */
135 #define SH4_PCIPCTR_P1EN 0x000200000 /* Port 1 Enable */
136 #define SH4_PCIPCTR_P0EN 0x000100000 /* Port 0 Enable */
137 #define SH4_PCIPCTR_P2UP 0x000000020 /* Port2 Pull Up Enable */
138 #define SH4_PCIPCTR_P2IO 0x000000010 /* Port2 Output Enable */
139 #define SH4_PCIPCTR_P1UP 0x000000008 /* Port1 Pull Up Enable */
140 #define SH4_PCIPCTR_P1IO 0x000000004 /* Port1 Output Enable */
141 #define SH4_PCIPCTR_P0UP 0x000000002 /* Port0 Pull Up Enable */
142 #define SH4_PCIPCTR_P0IO 0x000000001 /* Port0 Output Enable */
143#define SH4_PCIPDTR 0x204 /* Port Data Register */
144 #define SH4_PCIPDTR_PB5 0x000000020 /* Port 5 Enable */
145 #define SH4_PCIPDTR_PB4 0x000000010 /* Port 4 Enable */
146 #define SH4_PCIPDTR_PB3 0x000000008 /* Port 3 Enable */
147 #define SH4_PCIPDTR_PB2 0x000000004 /* Port 2 Enable */
148 #define SH4_PCIPDTR_PB1 0x000000002 /* Port 1 Enable */
149 #define SH4_PCIPDTR_PB0 0x000000001 /* Port 0 Enable */
150#define SH4_PCIPDR 0x220 /* Port IO Data Register */
151
152/* Flags */
153#define SH4_PCIC_NO_RESET 0x0001
154
155/* arch/sh/kernel/drivers/pci/ops-sh4.c */
156extern struct pci_ops sh4_pci_ops;
157int sh4_pci_check_direct(void);
158int pci_fixup_pcic(void);
159
160struct sh4_pci_address_space {
161 unsigned long base;
162 unsigned long size;
163};
164
165struct sh4_pci_address_map {
166 struct sh4_pci_address_space window0;
167 struct sh4_pci_address_space window1;
168 unsigned long flags;
169};
170
171static inline void pci_write_reg(unsigned long val, unsigned long reg)
172{
173 outl(val, PCI_REG(reg));
174}
175
176static inline unsigned long pci_read_reg(unsigned long reg)
177{
178 return inl(PCI_REG(reg));
179}
180#endif /* __PCI_SH4_H */
diff --git a/arch/sh/drivers/pci/pci-sh7751.c b/arch/sh/drivers/pci/pci-sh7751.c
index 682f3dae305d..dbe837884983 100644
--- a/arch/sh/drivers/pci/pci-sh7751.c
+++ b/arch/sh/drivers/pci/pci-sh7751.c
@@ -15,180 +15,14 @@
15 15
16#undef DEBUG 16#undef DEBUG
17 17
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/init.h> 18#include <linux/init.h>
21#include <linux/pci.h> 19#include <linux/pci.h>
22#include <linux/sched.h> 20#include <linux/types.h>
23#include <linux/ioport.h>
24#include <linux/errno.h> 21#include <linux/errno.h>
25#include <linux/irq.h>
26#include <linux/delay.h> 22#include <linux/delay.h>
27 23#include "pci-sh4.h"
28#include <asm/machvec.h> 24#include <asm/addrspace.h>
29#include <asm/io.h> 25#include <asm/io.h>
30#include "pci-sh7751.h"
31
32static unsigned int pci_probe = PCI_PROBE_CONF1;
33extern int pci_fixup_pcic(void);
34
35void pcibios_fixup_irqs(void) __attribute__ ((weak));
36
37/*
38 * Direct access to PCI hardware...
39 */
40
41#define CONFIG_CMD(bus, devfn, where) (0x80000000 | (bus->number << 16) | (devfn << 8) | (where & ~3))
42
43/*
44 * Functions for accessing PCI configuration space with type 1 accesses
45 */
46static int sh7751_pci_read(struct pci_bus *bus, unsigned int devfn,
47 int where, int size, u32 *val)
48{
49 unsigned long flags;
50 u32 data;
51
52 /*
53 * PCIPDR may only be accessed as 32 bit words,
54 * so we must do byte alignment by hand
55 */
56 local_irq_save(flags);
57 outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
58 data = inl(PCI_REG(SH7751_PCIPDR));
59 local_irq_restore(flags);
60
61 switch (size) {
62 case 1:
63 *val = (data >> ((where & 3) << 3)) & 0xff;
64 break;
65 case 2:
66 *val = (data >> ((where & 2) << 3)) & 0xffff;
67 break;
68 case 4:
69 *val = data;
70 break;
71 default:
72 return PCIBIOS_FUNC_NOT_SUPPORTED;
73 }
74
75 return PCIBIOS_SUCCESSFUL;
76}
77
78/*
79 * Since SH7751 only does 32bit access we'll have to do a read,
80 * mask,write operation.
81 * We'll allow an odd byte offset, though it should be illegal.
82 */
83static int sh7751_pci_write(struct pci_bus *bus, unsigned int devfn,
84 int where, int size, u32 val)
85{
86 unsigned long flags;
87 int shift;
88 u32 data;
89
90 local_irq_save(flags);
91 outl(CONFIG_CMD(bus,devfn,where), PCI_REG(SH7751_PCIPAR));
92 data = inl(PCI_REG(SH7751_PCIPDR));
93 local_irq_restore(flags);
94
95 switch (size) {
96 case 1:
97 shift = (where & 3) << 3;
98 data &= ~(0xff << shift);
99 data |= ((val & 0xff) << shift);
100 break;
101 case 2:
102 shift = (where & 2) << 3;
103 data &= ~(0xffff << shift);
104 data |= ((val & 0xffff) << shift);
105 break;
106 case 4:
107 data = val;
108 break;
109 default:
110 return PCIBIOS_FUNC_NOT_SUPPORTED;
111 }
112
113 outl(data, PCI_REG(SH7751_PCIPDR));
114
115 return PCIBIOS_SUCCESSFUL;
116}
117
118#undef CONFIG_CMD
119
120struct pci_ops sh7751_pci_ops = {
121 .read = sh7751_pci_read,
122 .write = sh7751_pci_write,
123};
124
125static int __init pci_check_direct(void)
126{
127 unsigned int tmp, id;
128
129 /* check for SH7751/SH7751R hardware */
130 id = inl(SH7751_PCIREG_BASE+SH7751_PCICONF0);
131 if (id != ((SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID) &&
132 id != ((SH7751R_DEVICE_ID << 16) | SH7751_VENDOR_ID)) {
133 pr_debug("PCI: This is not an SH7751(R) (%x)\n", id);
134 return -ENODEV;
135 }
136
137 /*
138 * Check if configuration works.
139 */
140 if (pci_probe & PCI_PROBE_CONF1) {
141 tmp = inl (PCI_REG(SH7751_PCIPAR));
142 outl (0x80000000, PCI_REG(SH7751_PCIPAR));
143 if (inl (PCI_REG(SH7751_PCIPAR)) == 0x80000000) {
144 outl (tmp, PCI_REG(SH7751_PCIPAR));
145 printk(KERN_INFO "PCI: Using configuration type 1\n");
146 request_region(PCI_REG(SH7751_PCIPAR), 8, "PCI conf1");
147 return 0;
148 }
149 outl (tmp, PCI_REG(SH7751_PCIPAR));
150 }
151
152 pr_debug("PCI: pci_check_direct failed\n");
153 return -EINVAL;
154}
155
156/***************************************************************************************/
157
158/*
159 * Handle bus scanning and fixups ....
160 */
161
162static void __init pci_fixup_ide_bases(struct pci_dev *d)
163{
164 int i;
165
166 /*
167 * PCI IDE controllers use non-standard I/O port decoding, respect it.
168 */
169 if ((d->class >> 8) != PCI_CLASS_STORAGE_IDE)
170 return;
171 pr_debug("PCI: IDE base address fixup for %s\n", pci_name(d));
172 for(i=0; i<4; i++) {
173 struct resource *r = &d->resource[i];
174 if ((r->start & ~0x80) == 0x374) {
175 r->start |= 2;
176 r->end = r->start;
177 }
178 }
179}
180
181DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, pci_fixup_ide_bases);
182
183/*
184 * Called after each bus is probed, but before its children
185 * are examined.
186 */
187
188void __init pcibios_fixup_bus(struct pci_bus *b)
189{
190 pci_read_bridge_bases(b);
191}
192 26
193/* 27/*
194 * Initialization. Try all known PCI access methods. Note that we support 28 * Initialization. Try all known PCI access methods. Note that we support
@@ -196,25 +30,29 @@ void __init pcibios_fixup_bus(struct pci_bus *b)
196 * to access config space. 30 * to access config space.
197 * 31 *
198 * Note that the platform specific initialization (BSC registers, and memory 32 * Note that the platform specific initialization (BSC registers, and memory
199 * space mapping) will be called via the machine vectors (sh_mv.mv_pci_init()) if it 33 * space mapping) will be called via the platform defined function
200 * exitst and via the platform defined function pcibios_init_platform(). 34 * pcibios_init_platform().
201 * See pci_bigsur.c for implementation;
202 *
203 * The BIOS version of the pci functions is not yet implemented but it is left
204 * in for completeness. Currently an error will be genereated at compile time.
205 */ 35 */
206
207static int __init sh7751_pci_init(void) 36static int __init sh7751_pci_init(void)
208{ 37{
38 unsigned int id;
209 int ret; 39 int ret;
210 40
211 pr_debug("PCI: Starting intialization.\n"); 41 pr_debug("PCI: Starting intialization.\n");
212 if ((ret = pci_check_direct()) != 0) 42
43 /* check for SH7751/SH7751R hardware */
44 id = pci_read_reg(SH7751_PCICONF0);
45 if (id != ((SH7751_DEVICE_ID << 16) | SH7751_VENDOR_ID) &&
46 id != ((SH7751R_DEVICE_ID << 16) | SH7751_VENDOR_ID)) {
47 pr_debug("PCI: This is not an SH7751(R) (%x)\n", id);
48 return -ENODEV;
49 }
50
51 if ((ret = sh4_pci_check_direct()) != 0)
213 return ret; 52 return ret;
214 53
215 return pcibios_init_platform(); 54 return pcibios_init_platform();
216} 55}
217
218subsys_initcall(sh7751_pci_init); 56subsys_initcall(sh7751_pci_init);
219 57
220static int __init __area_sdram_check(unsigned int area) 58static int __init __area_sdram_check(unsigned int area)
@@ -223,26 +61,26 @@ static int __init __area_sdram_check(unsigned int area)
223 61
224 word = inl(SH7751_BCR1); 62 word = inl(SH7751_BCR1);
225 /* check BCR for SDRAM in area */ 63 /* check BCR for SDRAM in area */
226 if(((word >> area) & 1) == 0) { 64 if (((word >> area) & 1) == 0) {
227 printk("PCI: Area %d is not configured for SDRAM. BCR1=0x%x\n", 65 printk("PCI: Area %d is not configured for SDRAM. BCR1=0x%x\n",
228 area, word); 66 area, word);
229 return 0; 67 return 0;
230 } 68 }
231 outl(word, PCI_REG(SH7751_PCIBCR1)); 69 pci_write_reg(word, SH4_PCIBCR1);
232 70
233 word = (u16)inw(SH7751_BCR2); 71 word = (u16)inw(SH7751_BCR2);
234 /* check BCR2 for 32bit SDRAM interface*/ 72 /* check BCR2 for 32bit SDRAM interface*/
235 if(((word >> (area << 1)) & 0x3) != 0x3) { 73 if (((word >> (area << 1)) & 0x3) != 0x3) {
236 printk("PCI: Area %d is not 32 bit SDRAM. BCR2=0x%x\n", 74 printk("PCI: Area %d is not 32 bit SDRAM. BCR2=0x%x\n",
237 area, word); 75 area, word);
238 return 0; 76 return 0;
239 } 77 }
240 outl(word, PCI_REG(SH7751_PCIBCR2)); 78 pci_write_reg(word, SH4_PCIBCR2);
241 79
242 return 1; 80 return 1;
243} 81}
244 82
245int __init sh7751_pcic_init(struct sh7751_pci_address_map *map) 83int __init sh7751_pcic_init(struct sh4_pci_address_map *map)
246{ 84{
247 u32 reg; 85 u32 reg;
248 u32 word; 86 u32 word;
@@ -251,39 +89,39 @@ int __init sh7751_pcic_init(struct sh7751_pci_address_map *map)
251 reg = inl(SH7751_BCR1); 89 reg = inl(SH7751_BCR1);
252 reg |= 0x80000; 90 reg |= 0x80000;
253 outl(reg, SH7751_BCR1); 91 outl(reg, SH7751_BCR1);
254 92
255 /* Turn the clocks back on (not done in reset)*/ 93 /* Turn the clocks back on (not done in reset)*/
256 outl(0, PCI_REG(SH7751_PCICLKR)); 94 pci_write_reg(0, SH4_PCICLKR);
257 /* Clear Powerdown IRQ's (not done in reset) */ 95 /* Clear Powerdown IRQ's (not done in reset) */
258 word = SH7751_PCIPINT_D3 | SH7751_PCIPINT_D0; 96 word = SH4_PCIPINT_D3 | SH4_PCIPINT_D0;
259 outl(word, PCI_REG(SH7751_PCIPINT)); 97 pci_write_reg(word, SH4_PCIPINT);
260 98
261 /* 99 /*
262 * This code is unused for some boards as it is done in the 100 * This code is unused for some boards as it is done in the
263 * bootloader and doing it here means the MAC addresses loaded 101 * bootloader and doing it here means the MAC addresses loaded
264 * by the bootloader get lost. 102 * by the bootloader get lost.
265 */ 103 */
266 if (!(map->flags & SH7751_PCIC_NO_RESET)) { 104 if (!(map->flags & SH4_PCIC_NO_RESET)) {
267 /* toggle PCI reset pin */ 105 /* toggle PCI reset pin */
268 word = SH7751_PCICR_PREFIX | SH7751_PCICR_PRST; 106 word = SH4_PCICR_PREFIX | SH4_PCICR_PRST;
269 outl(word,PCI_REG(SH7751_PCICR)); 107 pci_write_reg(word, SH4_PCICR);
270 /* Wait for a long time... not 1 sec. but long enough */ 108 /* Wait for a long time... not 1 sec. but long enough */
271 mdelay(100); 109 mdelay(100);
272 word = SH7751_PCICR_PREFIX; 110 word = SH4_PCICR_PREFIX;
273 outl(word,PCI_REG(SH7751_PCICR)); 111 pci_write_reg(word, SH4_PCICR);
274 } 112 }
275 113
276 /* set the command/status bits to: 114 /* set the command/status bits to:
277 * Wait Cycle Control + Parity Enable + Bus Master + 115 * Wait Cycle Control + Parity Enable + Bus Master +
278 * Mem space enable 116 * Mem space enable
279 */ 117 */
280 word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER | 118 word = SH7751_PCICONF1_WCC | SH7751_PCICONF1_PER |
281 SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES; 119 SH7751_PCICONF1_BUM | SH7751_PCICONF1_MES;
282 outl(word, PCI_REG(SH7751_PCICONF1)); 120 pci_write_reg(word, SH7751_PCICONF1);
283 121
284 /* define this host as the host bridge */ 122 /* define this host as the host bridge */
285 word = SH7751_PCI_HOST_BRIDGE << 24; 123 word = PCI_BASE_CLASS_BRIDGE << 24;
286 outl(word, PCI_REG(SH7751_PCICONF2)); 124 pci_write_reg(word, SH7751_PCICONF2);
287 125
288 /* Set IO and Mem windows to local address 126 /* Set IO and Mem windows to local address
289 * Make PCI and local address the same for easy 1 to 1 mapping 127 * Make PCI and local address the same for easy 1 to 1 mapping
@@ -291,46 +129,49 @@ int __init sh7751_pcic_init(struct sh7751_pci_address_map *map)
291 * Window1 = map->window1.size @ cached area base = SDRAM 129 * Window1 = map->window1.size @ cached area base = SDRAM
292 */ 130 */
293 word = map->window0.size - 1; 131 word = map->window0.size - 1;
294 outl(word, PCI_REG(SH7751_PCILSR0)); 132 pci_write_reg(word, SH4_PCILSR0);
295 word = map->window1.size - 1; 133 word = map->window1.size - 1;
296 outl(word, PCI_REG(SH7751_PCILSR1)); 134 pci_write_reg(word, SH4_PCILSR1);
297 /* Set the values on window 0 PCI config registers */ 135 /* Set the values on window 0 PCI config registers */
298 word = P2SEGADDR(map->window0.base); 136 word = P2SEGADDR(map->window0.base);
299 outl(word, PCI_REG(SH7751_PCILAR0)); 137 pci_write_reg(word, SH4_PCILAR0);
300 outl(word, PCI_REG(SH7751_PCICONF5)); 138 pci_write_reg(word, SH7751_PCICONF5);
301 /* Set the values on window 1 PCI config registers */ 139 /* Set the values on window 1 PCI config registers */
302 word = PHYSADDR(map->window1.base); 140 word = PHYSADDR(map->window1.base);
303 outl(word, PCI_REG(SH7751_PCILAR1)); 141 pci_write_reg(word, SH4_PCILAR1);
304 outl(word, PCI_REG(SH7751_PCICONF6)); 142 pci_write_reg(word, SH7751_PCICONF6);
305 143
306 /* Set the local 16MB PCI memory space window to 144 /* Set the local 16MB PCI memory space window to
307 * the lowest PCI mapped address 145 * the lowest PCI mapped address
308 */ 146 */
309 word = PCIBIOS_MIN_MEM & SH7751_PCIMBR_MASK; 147 word = PCIBIOS_MIN_MEM & SH4_PCIMBR_MASK;
310 PCIDBG(2,"PCI: Setting upper bits of Memory window to 0x%x\n", word); 148 pr_debug("PCI: Setting upper bits of Memory window to 0x%x\n", word);
311 outl(word , PCI_REG(SH7751_PCIMBR)); 149 pci_write_reg(word , SH4_PCIMBR);
312 150
313 /* Map IO space into PCI IO window 151 /* Map IO space into PCI IO window
314 * The IO window is 64K-PCIBIOS_MIN_IO in size 152 * The IO window is 64K-PCIBIOS_MIN_IO in size
315 * IO addresses will be translated to the 153 * IO addresses will be translated to the
316 * PCI IO window base address 154 * PCI IO window base address
317 */ 155 */
318 PCIDBG(3,"PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n", PCIBIOS_MIN_IO, 156 pr_debug("PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n",
319 (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO); 157 PCIBIOS_MIN_IO, (64 << 10),
158 SH4_PCI_IO_BASE + PCIBIOS_MIN_IO);
320 159
321 /* 160 /*
322 * XXX: For now, leave this board-specific. In the event we have other 161 * XXX: For now, leave this board-specific. In the event we have other
323 * boards that need to do similar work, this can be wrapped. 162 * boards that need to do similar work, this can be wrapped.
324 */ 163 */
325#ifdef CONFIG_SH_BIGSUR 164#ifdef CONFIG_SH_BIGSUR
326 bigsur_port_map(PCIBIOS_MIN_IO, (64*1024), SH7751_PCI_IO_BASE+PCIBIOS_MIN_IO,0); 165 bigsur_port_map(PCIBIOS_MIN_IO, (64 << 10),
166 SH4_PCI_IO_BASE + PCIBIOS_MIN_IO, 0);
327#endif 167#endif
328 168
329 /* Make sure the MSB's of IO window are set to access PCI space correctly */ 169 /* Make sure the MSB's of IO window are set to access PCI space
330 word = PCIBIOS_MIN_IO & SH7751_PCIIOBR_MASK; 170 * correctly */
331 PCIDBG(2,"PCI: Setting upper bits of IO window to 0x%x\n", word); 171 word = PCIBIOS_MIN_IO & SH4_PCIIOBR_MASK;
332 outl(word, PCI_REG(SH7751_PCIIOBR)); 172 pr_debug("PCI: Setting upper bits of IO window to 0x%x\n", word);
333 173 pci_write_reg(word, SH4_PCIIOBR);
174
334 /* Set PCI WCRx, BCRx's, copy from BSC locations */ 175 /* Set PCI WCRx, BCRx's, copy from BSC locations */
335 176
336 /* check BCR for SDRAM in specified area */ 177 /* check BCR for SDRAM in specified area */
@@ -349,13 +190,13 @@ int __init sh7751_pcic_init(struct sh7751_pci_address_map *map)
349 190
350 /* configure the wait control registers */ 191 /* configure the wait control registers */
351 word = inl(SH7751_WCR1); 192 word = inl(SH7751_WCR1);
352 outl(word, PCI_REG(SH7751_PCIWCR1)); 193 pci_write_reg(word, SH4_PCIWCR1);
353 word = inl(SH7751_WCR2); 194 word = inl(SH7751_WCR2);
354 outl(word, PCI_REG(SH7751_PCIWCR2)); 195 pci_write_reg(word, SH4_PCIWCR2);
355 word = inl(SH7751_WCR3); 196 word = inl(SH7751_WCR3);
356 outl(word, PCI_REG(SH7751_PCIWCR3)); 197 pci_write_reg(word, SH4_PCIWCR3);
357 word = inl(SH7751_MCR); 198 word = inl(SH7751_MCR);
358 outl(word, PCI_REG(SH7751_PCIMCR)); 199 pci_write_reg(word, SH4_PCIMCR);
359 200
360 /* NOTE: I'm ignoring the PCI error IRQs for now.. 201 /* NOTE: I'm ignoring the PCI error IRQs for now..
361 * TODO: add support for the internal error interrupts and 202 * TODO: add support for the internal error interrupts and
@@ -368,49 +209,8 @@ int __init sh7751_pcic_init(struct sh7751_pci_address_map *map)
368 209
369 /* SH7751 init done, set central function init complete */ 210 /* SH7751 init done, set central function init complete */
370 /* use round robin mode to stop a device starving/overruning */ 211 /* use round robin mode to stop a device starving/overruning */
371 word = SH7751_PCICR_PREFIX | SH7751_PCICR_CFIN | SH7751_PCICR_ARBM; 212 word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_ARBM;
372 outl(word,PCI_REG(SH7751_PCICR)); 213 pci_write_reg(word, SH4_PCICR);
373 214
374 return 1; 215 return 1;
375} 216}
376
377char * __init pcibios_setup(char *str)
378{
379 if (!strcmp(str, "off")) {
380 pci_probe = 0;
381 return NULL;
382 }
383
384 return str;
385}
386
387/*
388 * IRQ functions
389 */
390static u8 __init sh7751_no_swizzle(struct pci_dev *dev, u8 *pin)
391{
392 /* no swizzling */
393 return PCI_SLOT(dev->devfn);
394}
395
396static int sh7751_pci_lookup_irq(struct pci_dev *dev, u8 slot, u8 pin)
397{
398 int irq = -1;
399
400 /* now lookup the actual IRQ on a platform specific basis (pci-'platform'.c) */
401 irq = pcibios_map_platform_irq(slot,pin);
402 if( irq < 0 ) {
403 pr_debug("PCI: Error mapping IRQ on device %s\n", pci_name(dev));
404 return irq;
405 }
406
407 pr_debug("Setting IRQ for slot %s to %d\n", pci_name(dev), irq);
408
409 return irq;
410}
411
412void __init pcibios_fixup_irqs(void)
413{
414 pci_fixup_irqs(sh7751_no_swizzle, sh7751_pci_lookup_irq);
415}
416
diff --git a/arch/sh/drivers/pci/pci-sh7751.h b/arch/sh/drivers/pci/pci-sh7751.h
index 1fee5cae10d1..68e3cb5e6bec 100644
--- a/arch/sh/drivers/pci/pci-sh7751.h
+++ b/arch/sh/drivers/pci/pci-sh7751.h
@@ -3,7 +3,7 @@
3 * 3 *
4 * Dustin McIntire (dustin@sensoria.com) (c) 2001 4 * Dustin McIntire (dustin@sensoria.com) (c) 2001
5 * Paul Mundt (lethal@linux-sh.org) (c) 2003 5 * Paul Mundt (lethal@linux-sh.org) (c) 2003
6 * 6 *
7 * May be copied or modified under the terms of the GNU General Public 7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information. 8 * License. See linux/COPYING for more information.
9 * 9 *
@@ -12,28 +12,6 @@
12#ifndef _PCI_SH7751_H_ 12#ifndef _PCI_SH7751_H_
13#define _PCI_SH7751_H_ 13#define _PCI_SH7751_H_
14 14
15#include <linux/pci.h>
16
17/* set debug level 4=verbose...1=terse */
18//#define DEBUG_PCI 3
19#undef DEBUG_PCI
20
21#ifdef DEBUG_PCI
22#define PCIDBG(n, x...) { if(DEBUG_PCI>=n) printk(x); }
23#else
24#define PCIDBG(n, x...)
25#endif
26
27/* startup values */
28#define PCI_PROBE_BIOS 1
29#define PCI_PROBE_CONF1 2
30#define PCI_PROBE_CONF2 4
31#define PCI_NO_SORT 0x100
32#define PCI_BIOS_SORT 0x200
33#define PCI_NO_CHECKS 0x400
34#define PCI_ASSIGN_ROMS 0x1000
35#define PCI_BIOS_IRQ_SCAN 0x2000
36
37/* Platform Specific Values */ 15/* Platform Specific Values */
38#define SH7751_VENDOR_ID 0x1054 16#define SH7751_VENDOR_ID 0x1054
39#define SH7751_DEVICE_ID 0x3505 17#define SH7751_DEVICE_ID 0x3505
@@ -128,131 +106,6 @@
128 #define SH7751_PCICONF17_PMEN 0x00010000 /* PME Enable */ 106 #define SH7751_PCICONF17_PMEN 0x00010000 /* PME Enable */
129 #define SH7751_PCICONF17_PWST 0x00000003 /* Power State */ 107 #define SH7751_PCICONF17_PWST 0x00000003 /* Power State */
130/* SH7715 Internal PCI Registers */ 108/* SH7715 Internal PCI Registers */
131#define SH7751_PCICR 0x100 /* PCI Control Register */
132 #define SH7751_PCICR_PREFIX 0xA5000000 /* CR prefix for write */
133 #define SH7751_PCICR_TRSB 0x00000200 /* Target Read Single */
134 #define SH7751_PCICR_BSWP 0x00000100 /* Target Byte Swap */
135 #define SH7751_PCICR_PLUP 0x00000080 /* Enable PCI Pullup */
136 #define SH7751_PCICR_ARBM 0x00000040 /* PCI Arbitration Mode */
137 #define SH7751_PCICR_MD 0x00000030 /* MD9 and MD10 status */
138 #define SH7751_PCICR_SERR 0x00000008 /* SERR output assert */
139 #define SH7751_PCICR_INTA 0x00000004 /* INTA output assert */
140 #define SH7751_PCICR_PRST 0x00000002 /* PCI Reset Assert */
141 #define SH7751_PCICR_CFIN 0x00000001 /* Central Fun. Init Done */
142#define SH7751_PCILSR0 0x104 /* PCI Local Space Register0 */
143#define SH7751_PCILSR1 0x108 /* PCI Local Space Register1 */
144#define SH7751_PCILAR0 0x10C /* PCI Local Address Register1 */
145#define SH7751_PCILAR1 0x110 /* PCI Local Address Register1 */
146#define SH7751_PCIINT 0x114 /* PCI Interrupt Register */
147 #define SH7751_PCIINT_MLCK 0x00008000 /* Master Lock Error */
148 #define SH7751_PCIINT_TABT 0x00004000 /* Target Abort Error */
149 #define SH7751_PCIINT_TRET 0x00000200 /* Target Retry Error */
150 #define SH7751_PCIINT_MFDE 0x00000100 /* Master Func. Disable Error */
151 #define SH7751_PCIINT_PRTY 0x00000080 /* Address Parity Error */
152 #define SH7751_PCIINT_SERR 0x00000040 /* SERR Detection Error */
153 #define SH7751_PCIINT_TWDP 0x00000020 /* Tgt. Write Parity Error */
154 #define SH7751_PCIINT_TRDP 0x00000010 /* Tgt. Read Parity Error Det. */
155 #define SH7751_PCIINT_MTABT 0x00000008 /* Master-Tgt. Abort Error */
156 #define SH7751_PCIINT_MMABT 0x00000004 /* Master-Master Abort Error */
157 #define SH7751_PCIINT_MWPD 0x00000002 /* Master Write PERR Detect */
158 #define SH7751_PCIINT_MRPD 0x00000002 /* Master Read PERR Detect */
159#define SH7751_PCIINTM 0x118 /* PCI Interrupt Mask Register */
160#define SH7751_PCIALR 0x11C /* Error Address Register */
161#define SH7751_PCICLR 0x120 /* Error Command/Data Register */
162 #define SH7751_PCICLR_MPIO 0x80000000 /* Error Command/Data Register */
163 #define SH7751_PCICLR_MDMA0 0x40000000 /* DMA0 Transfer Error */
164 #define SH7751_PCICLR_MDMA1 0x20000000 /* DMA1 Transfer Error */
165 #define SH7751_PCICLR_MDMA2 0x10000000 /* DMA2 Transfer Error */
166 #define SH7751_PCICLR_MDMA3 0x08000000 /* DMA3 Transfer Error */
167 #define SH7751_PCICLR_TGT 0x04000000 /* Target Transfer Error */
168 #define SH7751_PCICLR_CMDL 0x0000000F /* PCI Command at Error */
169#define SH7751_PCIAINT 0x130 /* Arbiter Interrupt Register */
170 #define SH7751_PCIAINT_MBKN 0x00002000 /* Master Broken Interrupt */
171 #define SH7751_PCIAINT_TBTO 0x00001000 /* Target Bus Time Out */
172 #define SH7751_PCIAINT_MBTO 0x00001000 /* Master Bus Time Out */
173 #define SH7751_PCIAINT_TABT 0x00000008 /* Target Abort */
174 #define SH7751_PCIAINT_MABT 0x00000004 /* Master Abort */
175 #define SH7751_PCIAINT_RDPE 0x00000002 /* Read Data Parity Error */
176 #define SH7751_PCIAINT_WDPE 0x00000002 /* Write Data Parity Error */
177#define SH7751_PCIAINTM 0x134 /* Arbiter Int. Mask Register */
178#define SH7751_PCIBMLR 0x138 /* Error Bus Master Register */
179 #define SH7751_PCIBMLR_REQ4 0x00000010 /* REQ4 bus master at error */
180 #define SH7751_PCIBMLR_REQ3 0x00000008 /* REQ3 bus master at error */
181 #define SH7751_PCIBMLR_REQ2 0x00000004 /* REQ2 bus master at error */
182 #define SH7751_PCIBMLR_REQ1 0x00000002 /* REQ1 bus master at error */
183 #define SH7751_PCIBMLR_REQ0 0x00000001 /* REQ0 bus master at error */
184#define SH7751_PCIDMABT 0x140 /* DMA Transfer Arb. Register */
185 #define SH7751_PCIDMABT_RRBN 0x00000001 /* DMA Arbitor Round-Robin */
186#define SH7751_PCIDPA0 0x180 /* DMA0 Transfer Addr. Register */
187#define SH7751_PCIDLA0 0x184 /* DMA0 Local Addr. Register */
188#define SH7751_PCIDTC0 0x188 /* DMA0 Transfer Cnt. Register */
189#define SH7751_PCIDCR0 0x18C /* DMA0 Control Register */
190 #define SH7751_PCIDCR_ALGN 0x00000600 /* DMA Alignment Mode */
191 #define SH7751_PCIDCR_MAST 0x00000100 /* DMA Termination Type */
192 #define SH7751_PCIDCR_INTM 0x00000080 /* DMA Interrupt Done Mask*/
193 #define SH7751_PCIDCR_INTS 0x00000040 /* DMA Interrupt Done Status */
194 #define SH7751_PCIDCR_LHLD 0x00000020 /* Local Address Control */
195 #define SH7751_PCIDCR_PHLD 0x00000010 /* PCI Address Control*/
196 #define SH7751_PCIDCR_IOSEL 0x00000008 /* PCI Address Space Type */
197 #define SH7751_PCIDCR_DIR 0x00000004 /* DMA Transfer Direction */
198 #define SH7751_PCIDCR_STOP 0x00000002 /* Force DMA Stop */
199 #define SH7751_PCIDCR_STRT 0x00000001 /* DMA Start */
200#define SH7751_PCIDPA1 0x190 /* DMA1 Transfer Addr. Register */
201#define SH7751_PCIDLA1 0x194 /* DMA1 Local Addr. Register */
202#define SH7751_PCIDTC1 0x198 /* DMA1 Transfer Cnt. Register */
203#define SH7751_PCIDCR1 0x19C /* DMA1 Control Register */
204#define SH7751_PCIDPA2 0x1A0 /* DMA2 Transfer Addr. Register */
205#define SH7751_PCIDLA2 0x1A4 /* DMA2 Local Addr. Register */
206#define SH7751_PCIDTC2 0x1A8 /* DMA2 Transfer Cnt. Register */
207#define SH7751_PCIDCR2 0x1AC /* DMA2 Control Register */
208#define SH7751_PCIDPA3 0x1B0 /* DMA3 Transfer Addr. Register */
209#define SH7751_PCIDLA3 0x1B4 /* DMA3 Local Addr. Register */
210#define SH7751_PCIDTC3 0x1B8 /* DMA3 Transfer Cnt. Register */
211#define SH7751_PCIDCR3 0x1BC /* DMA3 Control Register */
212#define SH7751_PCIPAR 0x1C0 /* PIO Address Register */
213 #define SH7751_PCIPAR_CFGEN 0x80000000 /* Configuration Enable */
214 #define SH7751_PCIPAR_BUSNO 0x00FF0000 /* Config. Bus Number */
215 #define SH7751_PCIPAR_DEVNO 0x0000FF00 /* Config. Device Number */
216 #define SH7751_PCIPAR_REGAD 0x000000FC /* Register Address Number */
217#define SH7751_PCIMBR 0x1C4 /* Memory Base Address Register */
218 #define SH7751_PCIMBR_MASK 0xFF000000 /* Memory Space Mask */
219 #define SH7751_PCIMBR_LOCK 0x00000001 /* Lock Memory Space */
220#define SH7751_PCIIOBR 0x1C8 /* I/O Base Address Register */
221 #define SH7751_PCIIOBR_MASK 0xFFFC0000 /* IO Space Mask */
222 #define SH7751_PCIIOBR_LOCK 0x00000001 /* Lock IO Space */
223#define SH7751_PCIPINT 0x1CC /* Power Mgmnt Int. Register */
224 #define SH7751_PCIPINT_D3 0x00000002 /* D3 Pwr Mgmt. Interrupt */
225 #define SH7751_PCIPINT_D0 0x00000001 /* D0 Pwr Mgmt. Interrupt */
226#define SH7751_PCIPINTM 0x1D0 /* Power Mgmnt Mask Register */
227#define SH7751_PCICLKR 0x1D4 /* Clock Ctrl. Register */
228 #define SH7751_PCICLKR_PCSTP 0x00000002 /* PCI Clock Stop */
229 #define SH7751_PCICLKR_BCSTP 0x00000002 /* BCLK Clock Stop */
230/* For definitions of BCR, MCR see ... */
231#define SH7751_PCIBCR1 0x1E0 /* Memory BCR1 Register */
232#define SH7751_PCIBCR2 0x1E4 /* Memory BCR2 Register */
233#define SH7751_PCIWCR1 0x1E8 /* Wait Control 1 Register */
234#define SH7751_PCIWCR2 0x1EC /* Wait Control 2 Register */
235#define SH7751_PCIWCR3 0x1F0 /* Wait Control 3 Register */
236#define SH7751_PCIMCR 0x1F4 /* Memory Control Register */
237#define SH7751_PCIBCR3 0x1f8 /* Memory BCR3 Register */
238#define SH7751_PCIPCTR 0x200 /* Port Control Register */
239 #define SH7751_PCIPCTR_P2EN 0x000400000 /* Port 2 Enable */
240 #define SH7751_PCIPCTR_P1EN 0x000200000 /* Port 1 Enable */
241 #define SH7751_PCIPCTR_P0EN 0x000100000 /* Port 0 Enable */
242 #define SH7751_PCIPCTR_P2UP 0x000000020 /* Port2 Pull Up Enable */
243 #define SH7751_PCIPCTR_P2IO 0x000000010 /* Port2 Output Enable */
244 #define SH7751_PCIPCTR_P1UP 0x000000008 /* Port1 Pull Up Enable */
245 #define SH7751_PCIPCTR_P1IO 0x000000004 /* Port1 Output Enable */
246 #define SH7751_PCIPCTR_P0UP 0x000000002 /* Port0 Pull Up Enable */
247 #define SH7751_PCIPCTR_P0IO 0x000000001 /* Port0 Output Enable */
248#define SH7751_PCIPDTR 0x204 /* Port Data Register */
249 #define SH7751_PCIPDTR_PB5 0x000000020 /* Port 5 Enable */
250 #define SH7751_PCIPDTR_PB4 0x000000010 /* Port 4 Enable */
251 #define SH7751_PCIPDTR_PB3 0x000000008 /* Port 3 Enable */
252 #define SH7751_PCIPDTR_PB2 0x000000004 /* Port 2 Enable */
253 #define SH7751_PCIPDTR_PB1 0x000000002 /* Port 1 Enable */
254 #define SH7751_PCIPDTR_PB0 0x000000001 /* Port 0 Enable */
255#define SH7751_PCIPDR 0x220 /* Port IO Data Register */
256 109
257/* Memory Control Registers */ 110/* Memory Control Registers */
258#define SH7751_BCR1 0xFF800000 /* Memory BCR1 Register */ 111#define SH7751_BCR1 0xFF800000 /* Memory BCR1 Register */
@@ -274,30 +127,9 @@
274#define SH7751_CS5_BASE_ADDR (SH7751_CS4_BASE_ADDR + SH7751_MEM_REGION_SIZE) 127#define SH7751_CS5_BASE_ADDR (SH7751_CS4_BASE_ADDR + SH7751_MEM_REGION_SIZE)
275#define SH7751_CS6_BASE_ADDR (SH7751_CS5_BASE_ADDR + SH7751_MEM_REGION_SIZE) 128#define SH7751_CS6_BASE_ADDR (SH7751_CS5_BASE_ADDR + SH7751_MEM_REGION_SIZE)
276 129
277/* General PCI values */ 130struct sh4_pci_address_map;
278#define SH7751_PCI_HOST_BRIDGE 0x6
279
280/* Flags */
281#define SH7751_PCIC_NO_RESET 0x0001
282
283/* External functions defined per platform i.e. Big Sur, SE... (these could be routed
284 * through the machine vectors... */
285extern int pcibios_init_platform(void);
286extern int pcibios_map_platform_irq(u8 slot, u8 pin);
287
288struct sh7751_pci_address_space {
289 unsigned long base;
290 unsigned long size;
291};
292
293struct sh7751_pci_address_map {
294 struct sh7751_pci_address_space window0;
295 struct sh7751_pci_address_space window1;
296 unsigned long flags;
297};
298 131
299/* arch/sh/drivers/pci/pci-sh7751.c */ 132/* arch/sh/drivers/pci/pci-sh7751.c */
300extern int sh7751_pcic_init(struct sh7751_pci_address_map *map); 133int sh7751_pcic_init(struct sh4_pci_address_map *map);
301 134
302#endif /* _PCI_SH7751_H_ */ 135#endif /* _PCI_SH7751_H_ */
303
diff --git a/arch/sh/drivers/pci/pci-sh7780.c b/arch/sh/drivers/pci/pci-sh7780.c
new file mode 100644
index 000000000000..bd3064a82087
--- /dev/null
+++ b/arch/sh/drivers/pci/pci-sh7780.c
@@ -0,0 +1,139 @@
1/*
2 * Low-Level PCI Support for the SH7780
3 *
4 * Dustin McIntire (dustin@sensoria.com)
5 * Derived from arch/i386/kernel/pci-*.c which bore the message:
6 * (c) 1999--2000 Martin Mares <mj@ucw.cz>
7 *
8 * Ported to the new API by Paul Mundt <lethal@linux-sh.org>
9 * With cleanup by Paul van Gool <pvangool@mimotech.com>
10 *
11 * May be copied or modified under the terms of the GNU General Public
12 * License. See linux/COPYING for more information.
13 *
14 */
15
16#undef DEBUG
17
18#include <linux/config.h>
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/pci.h>
23#include <linux/errno.h>
24#include <linux/delay.h>
25#include "pci-sh4.h"
26
27/*
28 * Initialization. Try all known PCI access methods. Note that we support
29 * using both PCI BIOS and direct access: in such cases, we use I/O ports
30 * to access config space.
31 *
32 * Note that the platform specific initialization (BSC registers, and memory
33 * space mapping) will be called via the platform defined function
34 * pcibios_init_platform().
35 */
36static int __init sh7780_pci_init(void)
37{
38 unsigned int id;
39 int ret;
40
41 pr_debug("PCI: Starting intialization.\n");
42
43 outl(0x00000001, SH7780_PCI_VCR2); /* Enable PCIC */
44
45 /* check for SH7780/SH7780R hardware */
46 id = pci_read_reg(SH7780_PCIVID);
47 if ((id != ((SH7780_DEVICE_ID << 16) | SH7780_VENDOR_ID)) &&
48 (id != ((SH7781_DEVICE_ID << 16) | SH7780_VENDOR_ID))) {
49 printk(KERN_ERR "PCI: This is not an SH7780 (%x)\n", id);
50 return -ENODEV;
51 }
52
53 /* Setup the INTC */
54 ctrl_outl(0x00200000, INTC_ICR0); /* INTC SH-4 Mode */
55 ctrl_outl(0x00078000, INTC_INT2MSKCR); /* enable PCIINTA - PCIINTD */
56 ctrl_outl(0x40000000, INTC_INTMSK1); /* disable IRL4-7 Interrupt */
57 ctrl_outl(0x0000fffe, INTC_INTMSK2); /* disable IRL4-7 Interrupt */
58 ctrl_outl(0x80000000, INTC_INTMSKCLR1); /* enable IRL0-3 Interrupt */
59 ctrl_outl(0xfffe0000, INTC_INTMSKCLR2); /* enable IRL0-3 Interrupt */
60
61 if ((ret = sh4_pci_check_direct()) != 0)
62 return ret;
63
64 return pcibios_init_platform();
65}
66core_initcall(sh7780_pci_init);
67
68int __init sh7780_pcic_init(struct sh4_pci_address_map *map)
69{
70 u32 word;
71
72 /*
73 * This code is unused for some boards as it is done in the
74 * bootloader and doing it here means the MAC addresses loaded
75 * by the bootloader get lost.
76 */
77 if (!(map->flags & SH4_PCIC_NO_RESET)) {
78 /* toggle PCI reset pin */
79 word = SH4_PCICR_PREFIX | SH4_PCICR_PRST;
80 pci_write_reg(word, SH4_PCICR);
81 /* Wait for a long time... not 1 sec. but long enough */
82 mdelay(100);
83 word = SH4_PCICR_PREFIX;
84 pci_write_reg(word, SH4_PCICR);
85 }
86
87 /* set the command/status bits to:
88 * Wait Cycle Control + Parity Enable + Bus Master +
89 * Mem space enable
90 */
91 pci_write_reg(0x00000046, SH7780_PCICMD);
92
93 /* define this host as the host bridge */
94 word = PCI_BASE_CLASS_BRIDGE << 24;
95 pci_write_reg(word, SH7780_PCIRID);
96
97 /* Set IO and Mem windows to local address
98 * Make PCI and local address the same for easy 1 to 1 mapping
99 * Window0 = map->window0.size @ non-cached area base = SDRAM
100 * Window1 = map->window1.size @ cached area base = SDRAM
101 */
102 word = ((map->window0.size - 1) & 0x1ff00001) | 0x01;
103 pci_write_reg(0x07f00001, SH4_PCILSR0);
104 word = ((map->window1.size - 1) & 0x1ff00001) | 0x01;
105 pci_write_reg(0x00000001, SH4_PCILSR1);
106 /* Set the values on window 0 PCI config registers */
107 word = P2SEGADDR(map->window0.base);
108 pci_write_reg(0xa8000000, SH4_PCILAR0);
109 pci_write_reg(0x08000000, SH7780_PCIMBAR0);
110 /* Set the values on window 1 PCI config registers */
111 word = P2SEGADDR(map->window1.base);
112 pci_write_reg(0x00000000, SH4_PCILAR1);
113 pci_write_reg(0x00000000, SH7780_PCIMBAR1);
114
115 /* Map IO space into PCI IO window
116 * The IO window is 64K-PCIBIOS_MIN_IO in size
117 * IO addresses will be translated to the
118 * PCI IO window base address
119 */
120 pr_debug("PCI: Mapping IO address 0x%x - 0x%x to base 0x%x\n",
121 PCIBIOS_MIN_IO, (64 << 10),
122 SH7780_PCI_IO_BASE + PCIBIOS_MIN_IO);
123
124 /* NOTE: I'm ignoring the PCI error IRQs for now..
125 * TODO: add support for the internal error interrupts and
126 * DMA interrupts...
127 */
128
129#ifdef CONFIG_SH_R7780RP
130 pci_fixup_pcic();
131#endif
132
133 /* SH7780 init done, set central function init complete */
134 /* use round robin mode to stop a device starving/overruning */
135 word = SH4_PCICR_PREFIX | SH4_PCICR_CFIN | SH4_PCICR_FTO;
136 pci_write_reg(word, SH4_PCICR);
137
138 return 1;
139}
diff --git a/arch/sh/drivers/pci/pci-sh7780.h b/arch/sh/drivers/pci/pci-sh7780.h
new file mode 100644
index 000000000000..f02d2180a4bc
--- /dev/null
+++ b/arch/sh/drivers/pci/pci-sh7780.h
@@ -0,0 +1,94 @@
1/*
2 * Low-Level PCI Support for SH7780 targets
3 *
4 * Dustin McIntire (dustin@sensoria.com) (c) 2001
5 * Paul Mundt (lethal@linux-sh.org) (c) 2003
6 *
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
9 *
10 */
11
12#ifndef _PCI_SH7780_H_
13#define _PCI_SH7780_H_
14
15/* Platform Specific Values */
16#define SH7780_VENDOR_ID 0x1912
17#define SH7780_DEVICE_ID 0x0002
18#define SH7781_DEVICE_ID 0x0001
19
20/* SH7780 Control Registers */
21#define SH7780_PCI_VCR0 0xFE000000
22#define SH7780_PCI_VCR1 0xFE000004
23#define SH7780_PCI_VCR2 0xFE000008
24
25/* SH7780 Specific Values */
26#define SH7780_PCI_CONFIG_BASE 0xFD000000 /* Config space base addr */
27#define SH7780_PCI_CONFIG_SIZE 0x01000000 /* Config space size */
28
29#define SH7780_PCI_MEMORY_BASE 0xFD000000 /* Memory space base addr */
30#define SH7780_PCI_MEM_SIZE 0x01000000 /* Size of Memory window */
31
32#define SH7780_PCI_IO_BASE 0xFE400000 /* IO space base address */
33#define SH7780_PCI_IO_SIZE 0x00400000 /* Size of IO window */
34
35#define SH7780_PCIREG_BASE 0xFE040000 /* PCI regs base address */
36#define PCI_REG(n) (SH7780_PCIREG_BASE+n)
37
38/* SH7780 PCI Config Registers */
39#define SH7780_PCIVID 0x000 /* Vendor ID */
40#define SH7780_PCIDID 0x002 /* Device ID */
41#define SH7780_PCICMD 0x004 /* Command */
42#define SH7780_PCISTATUS 0x006 /* Status */
43#define SH7780_PCIRID 0x008 /* Revision ID */
44#define SH7780_PCIPIF 0x009 /* Program Interface */
45#define SH7780_PCISUB 0x00a /* Sub class code */
46#define SH7780_PCIBCC 0x00b /* Base class code */
47#define SH7780_PCICLS 0x00c /* Cache line size */
48#define SH7780_PCILTM 0x00d /* latency timer */
49#define SH7780_PCIHDR 0x00e /* Header type */
50#define SH7780_PCIBIST 0x00f /* BIST */
51#define SH7780_PCIIBAR 0x010 /* IO Base address */
52#define SH7780_PCIMBAR0 0x014 /* Memory base address0 */
53#define SH7780_PCIMBAR1 0x018 /* Memory base address1 */
54#define SH7780_PCISVID 0x02c /* Sub system vendor ID */
55#define SH7780_PCISID 0x02e /* Sub system ID */
56#define SH7780_PCICP 0x034
57#define SH7780_PCIINTLINE 0x03c /* Interrupt line */
58#define SH7780_PCIINTPIN 0x03d /* Interrupt pin */
59#define SH7780_PCIMINGNT 0x03e /* Minumum grand */
60#define SH7780_PCIMAXLAT 0x03f /* Maxmum latency */
61#define SH7780_PCICID 0x040
62#define SH7780_PCINIP 0x041
63#define SH7780_PCIPMC 0x042
64#define SH7780_PCIPMCSR 0x044
65#define SH7780_PCIPMCSR_BSE 0x046
66#define SH7780_PCICDD 0x047
67
68#define SH7780_PCIMBR0 0x1E0
69#define SH7780_PCIMBMR0 0x1E4
70#define SH7780_PCIMBR2 0x1F0
71#define SH7780_PCIMBMR2 0x1F4
72#define SH7780_PCIIOBR 0x1F8
73#define SH7780_PCIIOBMR 0x1FC
74#define SH7780_PCICSCR0 0x210 /* Cache Snoop1 Cnt. Register */
75#define SH7780_PCICSCR1 0x214 /* Cache Snoop2 Cnt. Register */
76#define SH7780_PCICSAR0 0x218 /* Cache Snoop1 Addr. Register */
77#define SH7780_PCICSAR1 0x21C /* Cache Snoop2 Addr. Register */
78
79/* General Memory Config Addresses */
80#define SH7780_CS0_BASE_ADDR 0x0
81#define SH7780_MEM_REGION_SIZE 0x04000000
82#define SH7780_CS1_BASE_ADDR (SH7780_CS0_BASE_ADDR + SH7780_MEM_REGION_SIZE)
83#define SH7780_CS2_BASE_ADDR (SH7780_CS1_BASE_ADDR + SH7780_MEM_REGION_SIZE)
84#define SH7780_CS3_BASE_ADDR (SH7780_CS2_BASE_ADDR + SH7780_MEM_REGION_SIZE)
85#define SH7780_CS4_BASE_ADDR (SH7780_CS3_BASE_ADDR + SH7780_MEM_REGION_SIZE)
86#define SH7780_CS5_BASE_ADDR (SH7780_CS4_BASE_ADDR + SH7780_MEM_REGION_SIZE)
87#define SH7780_CS6_BASE_ADDR (SH7780_CS5_BASE_ADDR + SH7780_MEM_REGION_SIZE)
88
89struct sh4_pci_address_map;
90
91/* arch/sh/drivers/pci/pci-sh7780.c */
92int sh7780_pcic_init(struct sh4_pci_address_map *map);
93
94#endif /* _PCI_SH7780_H_ */
diff --git a/arch/sh/drivers/pci/pci-st40.c b/arch/sh/drivers/pci/pci-st40.c
index 7c81b8b65bb5..4ab5ea6b35fb 100644
--- a/arch/sh/drivers/pci/pci-st40.c
+++ b/arch/sh/drivers/pci/pci-st40.c
@@ -70,12 +70,6 @@
70static void pci_set_rbar_region(unsigned int region, unsigned long localAddr, 70static void pci_set_rbar_region(unsigned int region, unsigned long localAddr,
71 unsigned long pciOffset, unsigned long regionSize); 71 unsigned long pciOffset, unsigned long regionSize);
72 72
73/*
74 * The pcibios_map_platform_irq function is defined in the appropriate
75 * board specific code and referenced here
76 */
77extern int __init pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
78
79static __init void SetPCIPLL(void) 73static __init void SetPCIPLL(void)
80{ 74{
81 { 75 {
@@ -422,13 +416,6 @@ struct pci_ops st40pci_config_ops = {
422/* Everything hangs off this */ 416/* Everything hangs off this */
423static struct pci_bus *pci_root_bus; 417static struct pci_bus *pci_root_bus;
424 418
425
426static u8 __init no_swizzle(struct pci_dev *dev, u8 * pin)
427{
428 return PCI_SLOT(dev->devfn);
429}
430
431
432static int __init pcibios_init(void) 419static int __init pcibios_init(void)
433{ 420{
434 extern unsigned long memory_start, memory_end; 421 extern unsigned long memory_start, memory_end;
@@ -465,17 +452,11 @@ static int __init pcibios_init(void)
465 /* ok, do the scan man */ 452 /* ok, do the scan man */
466 pci_root_bus = pci_scan_bus(0, &st40pci_config_ops, NULL); 453 pci_root_bus = pci_scan_bus(0, &st40pci_config_ops, NULL);
467 pci_assign_unassigned_resources(); 454 pci_assign_unassigned_resources();
468 pci_fixup_irqs(no_swizzle, pcibios_map_platform_irq);
469 455
470 return 0; 456 return 0;
471} 457}
472
473subsys_initcall(pcibios_init); 458subsys_initcall(pcibios_init);
474 459
475void __init pcibios_fixup_bus(struct pci_bus *bus)
476{
477}
478
479/* 460/*
480 * Publish a region of local address space over the PCI bus 461 * Publish a region of local address space over the PCI bus
481 * to other devices. 462 * to other devices.
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c
index 3d546ba329cf..d439336d2e18 100644
--- a/arch/sh/drivers/pci/pci.c
+++ b/arch/sh/drivers/pci/pci.c
@@ -1,21 +1,45 @@
1/* arch/sh/kernel/pci.c 1/*
2 * $Id: pci.c,v 1.1 2003/08/24 19:15:45 lethal Exp $ 2 * arch/sh/drivers/pci/pci.c
3 * 3 *
4 * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org> 4 * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
5 * 5 * Copyright (c) 2004 - 2006 Paul Mundt <lethal@linux-sh.org>
6 * 6 *
7 * These functions are collected here to reduce duplication of common 7 * These functions are collected here to reduce duplication of common
8 * code amongst the many platform-specific PCI support code files. 8 * code amongst the many platform-specific PCI support code files.
9 * 9 *
10 * These routines require the following board-specific routines: 10 * These routines require the following board-specific routines:
11 * void pcibios_fixup_irqs(); 11 * void pcibios_fixup_irqs();
12 * 12 *
13 * See include/asm-sh/pci.h for more information. 13 * See include/asm-sh/pci.h for more information.
14 *
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
14 */ 18 */
15
16#include <linux/kernel.h> 19#include <linux/kernel.h>
17#include <linux/pci.h> 20#include <linux/pci.h>
18#include <linux/init.h> 21#include <linux/init.h>
22#include <asm/io.h>
23
24static inline u8 bridge_swizzle(u8 pin, u8 slot)
25{
26 return (((pin - 1) + slot) % 4) + 1;
27}
28
29static u8 __init simple_swizzle(struct pci_dev *dev, u8 *pinp)
30{
31 u8 pin = *pinp;
32
33 while (dev->bus->parent) {
34 pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
35 /* Move up the chain of bridges. */
36 dev = dev->bus->self;
37 }
38 *pinp = pin;
39
40 /* The slot is the slot of the last bridge. */
41 return PCI_SLOT(dev->devfn);
42}
19 43
20static int __init pcibios_init(void) 44static int __init pcibios_init(void)
21{ 45{
@@ -26,26 +50,32 @@ static int __init pcibios_init(void)
26#ifdef CONFIG_PCI_AUTO 50#ifdef CONFIG_PCI_AUTO
27 /* assign resources */ 51 /* assign resources */
28 busno = 0; 52 busno = 0;
29 for (p = board_pci_channels; p->pci_ops != NULL; p++) { 53 for (p = board_pci_channels; p->pci_ops != NULL; p++)
30 busno = pciauto_assign_resources(busno, p) + 1; 54 busno = pciauto_assign_resources(busno, p) + 1;
31 }
32#endif 55#endif
33 56
34 /* scan the buses */ 57 /* scan the buses */
35 busno = 0; 58 busno = 0;
36 for (p= board_pci_channels; p->pci_ops != NULL; p++) { 59 for (p = board_pci_channels; p->pci_ops != NULL; p++) {
37 bus = pci_scan_bus(busno, p->pci_ops, p); 60 bus = pci_scan_bus(busno, p->pci_ops, p);
38 busno = bus->subordinate+1; 61 busno = bus->subordinate + 1;
39 } 62 }
40 63
41 /* board-specific fixups */ 64 pci_fixup_irqs(simple_swizzle, pcibios_map_platform_irq);
42 pcibios_fixup_irqs();
43 65
44 return 0; 66 return 0;
45} 67}
46
47subsys_initcall(pcibios_init); 68subsys_initcall(pcibios_init);
48 69
70/*
71 * Called after each bus is probed, but before its children
72 * are examined.
73 */
74void __init pcibios_fixup_bus(struct pci_bus *bus)
75{
76 pci_read_bridge_bases(bus);
77}
78
49void 79void
50pcibios_update_resource(struct pci_dev *dev, struct resource *root, 80pcibios_update_resource(struct pci_dev *dev, struct resource *root,
51 struct resource *res, int resource) 81 struct resource *res, int resource)
@@ -61,13 +91,17 @@ pcibios_update_resource(struct pci_dev *dev, struct resource *root,
61 new |= PCI_ROM_ADDRESS_ENABLE; 91 new |= PCI_ROM_ADDRESS_ENABLE;
62 reg = dev->rom_base_reg; 92 reg = dev->rom_base_reg;
63 } else { 93 } else {
64 /* Somebody might have asked allocation of a non-standard resource */ 94 /*
95 * Somebody might have asked allocation of a non-standard
96 * resource
97 */
65 return; 98 return;
66 } 99 }
67 100
68 pci_write_config_dword(dev, reg, new); 101 pci_write_config_dword(dev, reg, new);
69 pci_read_config_dword(dev, reg, &check); 102 pci_read_config_dword(dev, reg, &check);
70 if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ? PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) { 103 if ((new ^ check) & ((new & PCI_BASE_ADDRESS_SPACE_IO) ?
104 PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK)) {
71 printk(KERN_ERR "PCI: Error while updating region " 105 printk(KERN_ERR "PCI: Error while updating region "
72 "%s/%d (%08x != %08x)\n", pci_name(dev), resource, 106 "%s/%d (%08x != %08x)\n", pci_name(dev), resource,
73 new, check); 107 new, check);
@@ -145,7 +179,8 @@ void pcibios_set_master(struct pci_dev *dev)
145 lat = pcibios_max_latency; 179 lat = pcibios_max_latency;
146 else 180 else
147 return; 181 return;
148 printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n", pci_name(dev), lat); 182 printk(KERN_INFO "PCI: Setting latency timer of device %s to %d\n",
183 pci_name(dev), lat);
149 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); 184 pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
150} 185}
151 186
@@ -153,3 +188,39 @@ void __init pcibios_update_irq(struct pci_dev *dev, int irq)
153{ 188{
154 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); 189 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
155} 190}
191
192void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
193{
194 unsigned long start = pci_resource_start(dev, bar);
195 unsigned long len = pci_resource_len(dev, bar);
196 unsigned long flags = pci_resource_flags(dev, bar);
197
198 if (unlikely(!len || !start))
199 return NULL;
200 if (maxlen && len > maxlen)
201 len = maxlen;
202
203 /*
204 * Presently the IORESOURCE_MEM case is a bit special, most
205 * SH7751 style PCI controllers have PCI memory at a fixed
206 * location in the address space where no remapping is desired
207 * (typically at 0xfd000000, but is_pci_memaddr() will know
208 * best). With the IORESOURCE_MEM case more care has to be taken
209 * to inhibit page table mapping for legacy cores, but this is
210 * punted off to __ioremap().
211 * -- PFM.
212 */
213 if (flags & IORESOURCE_IO)
214 return ioport_map(start, len);
215 if (flags & IORESOURCE_MEM)
216 return ioremap(start, len);
217
218 return NULL;
219}
220EXPORT_SYMBOL(pci_iomap);
221
222void pci_iounmap(struct pci_dev *dev, void __iomem *addr)
223{
224 iounmap(addr);
225}
226EXPORT_SYMBOL(pci_iounmap);
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index f05cd96f8867..5da88a43d350 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -6,9 +6,10 @@ extra-y := head.o init_task.o vmlinux.lds
6 6
7obj-y := process.o signal.o entry.o traps.o irq.o \ 7obj-y := process.o signal.o entry.o traps.o irq.o \
8 ptrace.o setup.o time.o sys_sh.o semaphore.o \ 8 ptrace.o setup.o time.o sys_sh.o semaphore.o \
9 io.o io_generic.o sh_ksyms.o 9 io.o io_generic.o sh_ksyms.o syscalls.o
10 10
11obj-y += cpu/ timers/ 11obj-y += cpu/ timers/
12obj-$(CONFIG_VSYSCALL) += vsyscall/
12 13
13obj-$(CONFIG_SMP) += smp.o 14obj-$(CONFIG_SMP) += smp.o
14obj-$(CONFIG_CF_ENABLER) += cf-enabler.o 15obj-$(CONFIG_CF_ENABLER) += cf-enabler.o
@@ -18,3 +19,5 @@ obj-$(CONFIG_SH_CPU_FREQ) += cpufreq.o
18obj-$(CONFIG_MODULES) += module.o 19obj-$(CONFIG_MODULES) += module.o
19obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 20obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
20obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o 21obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
22obj-$(CONFIG_APM) += apm.o
23obj-$(CONFIG_PM) += pm.o
diff --git a/arch/sh/kernel/apm.c b/arch/sh/kernel/apm.c
new file mode 100644
index 000000000000..871e7d640002
--- /dev/null
+++ b/arch/sh/kernel/apm.c
@@ -0,0 +1,539 @@
1/*
2 * bios-less APM driver for hp680
3 *
4 * Copyright 2005 (c) Andriy Skulysh <askulysh@gmail.com>
5 *
6 * based on ARM APM driver by
7 * Jamey Hicks <jamey@crl.dec.com>
8 *
9 * adapted from the APM BIOS driver for Linux by
10 * Stephen Rothwell (sfr@linuxcare.com)
11 *
12 * APM 1.2 Reference:
13 * Intel Corporation, Microsoft Corporation. Advanced Power Management
14 * (APM) BIOS Interface Specification, Revision 1.2, February 1996.
15 *
16 * [This document is available from Microsoft at:
17 * http://www.microsoft.com/hwdev/busbios/amp_12.htm]
18 */
19#include <linux/config.h>
20#include <linux/module.h>
21#include <linux/poll.h>
22#include <linux/timer.h>
23#include <linux/slab.h>
24#include <linux/proc_fs.h>
25#include <linux/miscdevice.h>
26#include <linux/apm_bios.h>
27#include <linux/pm.h>
28#include <linux/pm_legacy.h>
29#include <asm/apm.h>
30
31#define MODNAME "apm"
32
33/*
34 * The apm_bios device is one of the misc char devices.
35 * This is its minor number.
36 */
37#define APM_MINOR_DEV 134
38
39/*
40 * Maximum number of events stored
41 */
42#define APM_MAX_EVENTS 16
43
44struct apm_queue {
45 unsigned int event_head;
46 unsigned int event_tail;
47 apm_event_t events[APM_MAX_EVENTS];
48};
49
50/*
51 * The per-file APM data
52 */
53struct apm_user {
54 struct list_head list;
55
56 unsigned int suser: 1;
57 unsigned int writer: 1;
58 unsigned int reader: 1;
59
60 int suspend_result;
61 unsigned int suspend_state;
62#define SUSPEND_NONE 0 /* no suspend pending */
63#define SUSPEND_PENDING 1 /* suspend pending read */
64#define SUSPEND_READ 2 /* suspend read, pending ack */
65#define SUSPEND_ACKED 3 /* suspend acked */
66#define SUSPEND_DONE 4 /* suspend completed */
67
68 struct apm_queue queue;
69};
70
71/*
72 * Local variables
73 */
74static int suspends_pending;
75
76static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
77static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
78
79/*
80 * This is a list of everyone who has opened /dev/apm_bios
81 */
82static DECLARE_RWSEM(user_list_lock);
83static LIST_HEAD(apm_user_list);
84
85/*
86 * kapmd info. kapmd provides us a process context to handle
87 * "APM" events within - specifically necessary if we're going
88 * to be suspending the system.
89 */
90static DECLARE_WAIT_QUEUE_HEAD(kapmd_wait);
91static DECLARE_COMPLETION(kapmd_exit);
92static DEFINE_SPINLOCK(kapmd_queue_lock);
93static struct apm_queue kapmd_queue;
94
95int apm_suspended;
96EXPORT_SYMBOL(apm_suspended);
97
98/* Platform-specific apm_read_proc(). */
99int (*apm_get_info)(char *buf, char **start, off_t fpos, int length);
100EXPORT_SYMBOL(apm_get_info);
101
102/*
103 * APM event queue management.
104 */
105static inline int queue_empty(struct apm_queue *q)
106{
107 return q->event_head == q->event_tail;
108}
109
110static inline apm_event_t queue_get_event(struct apm_queue *q)
111{
112 q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
113 return q->events[q->event_tail];
114}
115
116static void queue_add_event(struct apm_queue *q, apm_event_t event)
117{
118 q->event_head = (q->event_head + 1) % APM_MAX_EVENTS;
119 if (q->event_head == q->event_tail) {
120 static int notified;
121
122 if (notified++ == 0)
123 printk(KERN_ERR "apm: an event queue overflowed\n");
124
125 q->event_tail = (q->event_tail + 1) % APM_MAX_EVENTS;
126 }
127 q->events[q->event_head] = event;
128}
129
130static void queue_event_one_user(struct apm_user *as, apm_event_t event)
131{
132 if (as->suser && as->writer) {
133 switch (event) {
134 case APM_SYS_SUSPEND:
135 case APM_USER_SUSPEND:
136 /*
137 * If this user already has a suspend pending,
138 * don't queue another one.
139 */
140 if (as->suspend_state != SUSPEND_NONE)
141 return;
142
143 as->suspend_state = SUSPEND_PENDING;
144 suspends_pending++;
145 break;
146 }
147 }
148 queue_add_event(&as->queue, event);
149}
150
151static void queue_event(apm_event_t event, struct apm_user *sender)
152{
153 struct apm_user *as;
154
155 down_read(&user_list_lock);
156
157 list_for_each_entry(as, &apm_user_list, list)
158 if (as != sender && as->reader)
159 queue_event_one_user(as, event);
160
161 up_read(&user_list_lock);
162 wake_up_interruptible(&apm_waitqueue);
163}
164
165/**
166 * apm_queue_event - queue an APM event for kapmd
167 * @event: APM event
168 *
169 * Queue an APM event for kapmd to process and ultimately take the
170 * appropriate action. Only a subset of events are handled:
171 * %APM_LOW_BATTERY
172 * %APM_POWER_STATUS_CHANGE
173 * %APM_USER_SUSPEND
174 * %APM_SYS_SUSPEND
175 * %APM_CRITICAL_SUSPEND
176 */
177void apm_queue_event(apm_event_t event)
178{
179 spin_lock_irq(&kapmd_queue_lock);
180 queue_add_event(&kapmd_queue, event);
181 spin_unlock_irq(&kapmd_queue_lock);
182
183 wake_up_interruptible(&kapmd_wait);
184}
185EXPORT_SYMBOL(apm_queue_event);
186
187static void apm_suspend(void)
188{
189 struct apm_user *as;
190 int err;
191
192 apm_suspended = 1;
193 err = pm_suspend(PM_SUSPEND_MEM);
194
195 /*
196 * Anyone on the APM queues will think we're still suspended.
197 * Send a message so everyone knows we're now awake again.
198 */
199 queue_event(APM_NORMAL_RESUME, NULL);
200
201 /*
202 * Finally, wake up anyone who is sleeping on the suspend.
203 */
204 down_read(&user_list_lock);
205 list_for_each_entry(as, &apm_user_list, list) {
206 as->suspend_result = err;
207 as->suspend_state = SUSPEND_DONE;
208 }
209 up_read(&user_list_lock);
210
211 wake_up(&apm_suspend_waitqueue);
212 apm_suspended = 0;
213}
214
215static ssize_t apm_read(struct file *fp, char __user *buf,
216 size_t count, loff_t *ppos)
217{
218 struct apm_user *as = fp->private_data;
219 apm_event_t event;
220 int i = count, ret = 0;
221
222 if (count < sizeof(apm_event_t))
223 return -EINVAL;
224
225 if (queue_empty(&as->queue) && fp->f_flags & O_NONBLOCK)
226 return -EAGAIN;
227
228 wait_event_interruptible(apm_waitqueue, !queue_empty(&as->queue));
229
230 while ((i >= sizeof(event)) && !queue_empty(&as->queue)) {
231 event = queue_get_event(&as->queue);
232
233 ret = -EFAULT;
234 if (copy_to_user(buf, &event, sizeof(event)))
235 break;
236
237 if (event == APM_SYS_SUSPEND || event == APM_USER_SUSPEND)
238 as->suspend_state = SUSPEND_READ;
239
240 buf += sizeof(event);
241 i -= sizeof(event);
242 }
243
244 if (i < count)
245 ret = count - i;
246
247 return ret;
248}
249
250static unsigned int apm_poll(struct file *fp, poll_table * wait)
251{
252 struct apm_user *as = fp->private_data;
253
254 poll_wait(fp, &apm_waitqueue, wait);
255 return queue_empty(&as->queue) ? 0 : POLLIN | POLLRDNORM;
256}
257
258/*
259 * apm_ioctl - handle APM ioctl
260 *
261 * APM_IOC_SUSPEND
262 * This IOCTL is overloaded, and performs two functions. It is used to:
263 * - initiate a suspend
264 * - acknowledge a suspend read from /dev/apm_bios.
265 * Only when everyone who has opened /dev/apm_bios with write permission
266 * has acknowledge does the actual suspend happen.
267 */
268static int
269apm_ioctl(struct inode * inode, struct file *filp, u_int cmd, u_long arg)
270{
271 struct apm_user *as = filp->private_data;
272 unsigned long flags;
273 int err = -EINVAL;
274
275 if (!as->suser || !as->writer)
276 return -EPERM;
277
278 switch (cmd) {
279 case APM_IOC_SUSPEND:
280 as->suspend_result = -EINTR;
281
282 if (as->suspend_state == SUSPEND_READ) {
283 /*
284 * If we read a suspend command from /dev/apm_bios,
285 * then the corresponding APM_IOC_SUSPEND ioctl is
286 * interpreted as an acknowledge.
287 */
288 as->suspend_state = SUSPEND_ACKED;
289 suspends_pending--;
290 } else {
291 /*
292 * Otherwise it is a request to suspend the system.
293 * Queue an event for all readers, and expect an
294 * acknowledge from all writers who haven't already
295 * acknowledged.
296 */
297 queue_event(APM_USER_SUSPEND, as);
298 }
299
300 /*
301 * If there are no further acknowledges required, suspend
302 * the system.
303 */
304 if (suspends_pending == 0)
305 apm_suspend();
306
307 /*
308 * Wait for the suspend/resume to complete. If there are
309 * pending acknowledges, we wait here for them.
310 *
311 * Note that we need to ensure that the PM subsystem does
312 * not kick us out of the wait when it suspends the threads.
313 */
314 flags = current->flags;
315 current->flags |= PF_NOFREEZE;
316
317 /*
318 * Note: do not allow a thread which is acking the suspend
319 * to escape until the resume is complete.
320 */
321 if (as->suspend_state == SUSPEND_ACKED)
322 wait_event(apm_suspend_waitqueue,
323 as->suspend_state == SUSPEND_DONE);
324 else
325 wait_event_interruptible(apm_suspend_waitqueue,
326 as->suspend_state == SUSPEND_DONE);
327
328 current->flags = flags;
329 err = as->suspend_result;
330 as->suspend_state = SUSPEND_NONE;
331 break;
332 }
333
334 return err;
335}
336
337static int apm_release(struct inode * inode, struct file * filp)
338{
339 struct apm_user *as = filp->private_data;
340 filp->private_data = NULL;
341
342 down_write(&user_list_lock);
343 list_del(&as->list);
344 up_write(&user_list_lock);
345
346 /*
347 * We are now unhooked from the chain. As far as new
348 * events are concerned, we no longer exist. However, we
349 * need to balance suspends_pending, which means the
350 * possibility of sleeping.
351 */
352 if (as->suspend_state != SUSPEND_NONE) {
353 suspends_pending -= 1;
354 if (suspends_pending == 0)
355 apm_suspend();
356 }
357
358 kfree(as);
359 return 0;
360}
361
362static int apm_open(struct inode * inode, struct file * filp)
363{
364 struct apm_user *as;
365
366 as = kzalloc(sizeof(*as), GFP_KERNEL);
367 if (as) {
368 /*
369 * XXX - this is a tiny bit broken, when we consider BSD
370 * process accounting. If the device is opened by root, we
371 * instantly flag that we used superuser privs. Who knows,
372 * we might close the device immediately without doing a
373 * privileged operation -- cevans
374 */
375 as->suser = capable(CAP_SYS_ADMIN);
376 as->writer = (filp->f_mode & FMODE_WRITE) == FMODE_WRITE;
377 as->reader = (filp->f_mode & FMODE_READ) == FMODE_READ;
378
379 down_write(&user_list_lock);
380 list_add(&as->list, &apm_user_list);
381 up_write(&user_list_lock);
382
383 filp->private_data = as;
384 }
385
386 return as ? 0 : -ENOMEM;
387}
388
389static struct file_operations apm_bios_fops = {
390 .owner = THIS_MODULE,
391 .read = apm_read,
392 .poll = apm_poll,
393 .ioctl = apm_ioctl,
394 .open = apm_open,
395 .release = apm_release,
396};
397
398static struct miscdevice apm_device = {
399 .minor = APM_MINOR_DEV,
400 .name = "apm_bios",
401 .fops = &apm_bios_fops
402};
403
404
405#ifdef CONFIG_PROC_FS
406/*
407 * Arguments, with symbols from linux/apm_bios.h.
408 *
409 * 0) Linux driver version (this will change if format changes)
410 * 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2.
411 * 2) APM flags from APM Installation Check (0x00):
412 * bit 0: APM_16_BIT_SUPPORT
413 * bit 1: APM_32_BIT_SUPPORT
414 * bit 2: APM_IDLE_SLOWS_CLOCK
415 * bit 3: APM_BIOS_DISABLED
416 * bit 4: APM_BIOS_DISENGAGED
417 * 3) AC line status
418 * 0x00: Off-line
419 * 0x01: On-line
420 * 0x02: On backup power (BIOS >= 1.1 only)
421 * 0xff: Unknown
422 * 4) Battery status
423 * 0x00: High
424 * 0x01: Low
425 * 0x02: Critical
426 * 0x03: Charging
427 * 0x04: Selected battery not present (BIOS >= 1.2 only)
428 * 0xff: Unknown
429 * 5) Battery flag
430 * bit 0: High
431 * bit 1: Low
432 * bit 2: Critical
433 * bit 3: Charging
434 * bit 7: No system battery
435 * 0xff: Unknown
436 * 6) Remaining battery life (percentage of charge):
437 * 0-100: valid
438 * -1: Unknown
439 * 7) Remaining battery life (time units):
440 * Number of remaining minutes or seconds
441 * -1: Unknown
442 * 8) min = minutes; sec = seconds
443 */
444static int apm_read_proc(char *buf, char **start, off_t fpos, int length)
445{
446 if (likely(apm_get_info))
447 return apm_get_info(buf, start, fpos, length);
448
449 return -EINVAL;
450}
451#endif
452
453static int kapmd(void *arg)
454{
455 daemonize("kapmd");
456 current->flags |= PF_NOFREEZE;
457
458 do {
459 apm_event_t event;
460
461 wait_event_interruptible(kapmd_wait,
462 !queue_empty(&kapmd_queue) || !pm_active);
463
464 if (!pm_active)
465 break;
466
467 spin_lock_irq(&kapmd_queue_lock);
468 event = 0;
469 if (!queue_empty(&kapmd_queue))
470 event = queue_get_event(&kapmd_queue);
471 spin_unlock_irq(&kapmd_queue_lock);
472
473 switch (event) {
474 case 0:
475 break;
476
477 case APM_LOW_BATTERY:
478 case APM_POWER_STATUS_CHANGE:
479 queue_event(event, NULL);
480 break;
481
482 case APM_USER_SUSPEND:
483 case APM_SYS_SUSPEND:
484 queue_event(event, NULL);
485 if (suspends_pending == 0)
486 apm_suspend();
487 break;
488
489 case APM_CRITICAL_SUSPEND:
490 apm_suspend();
491 break;
492 }
493 } while (1);
494
495 complete_and_exit(&kapmd_exit, 0);
496}
497
498static int __init apm_init(void)
499{
500 int ret;
501
502 pm_active = 1;
503
504 ret = kernel_thread(kapmd, NULL, CLONE_KERNEL);
505 if (unlikely(ret < 0)) {
506 pm_active = 0;
507 return ret;
508 }
509
510 create_proc_info_entry("apm", 0, NULL, apm_read_proc);
511
512 ret = misc_register(&apm_device);
513 if (unlikely(ret != 0)) {
514 remove_proc_entry("apm", NULL);
515
516 pm_active = 0;
517 wake_up(&kapmd_wait);
518 wait_for_completion(&kapmd_exit);
519 }
520
521 return ret;
522}
523
524static void __exit apm_exit(void)
525{
526 misc_deregister(&apm_device);
527 remove_proc_entry("apm", NULL);
528
529 pm_active = 0;
530 wake_up(&kapmd_wait);
531 wait_for_completion(&kapmd_exit);
532}
533
534module_init(apm_init);
535module_exit(apm_exit);
536
537MODULE_AUTHOR("Stephen Rothwell, Andriy Skulysh");
538MODULE_DESCRIPTION("Advanced Power Management");
539MODULE_LICENSE("GPL");
diff --git a/arch/sh/kernel/cf-enabler.c b/arch/sh/kernel/cf-enabler.c
index f1f9ab87f0b0..3e5fa1e24df0 100644
--- a/arch/sh/kernel/cf-enabler.c
+++ b/arch/sh/kernel/cf-enabler.c
@@ -10,7 +10,8 @@
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
13 13#include <linux/mm.h>
14#include <linux/vmalloc.h>
14#include <asm/io.h> 15#include <asm/io.h>
15#include <asm/irq.h> 16#include <asm/irq.h>
16 17
@@ -32,8 +33,6 @@
32/* SH4 can't access PCMCIA interface through P2 area. 33/* SH4 can't access PCMCIA interface through P2 area.
33 * we must remap it with appropreate attribute bit of the page set. 34 * we must remap it with appropreate attribute bit of the page set.
34 * this part is based on Greg Banks' hd64465_ss.c implementation - Masahiro Abe */ 35 * this part is based on Greg Banks' hd64465_ss.c implementation - Masahiro Abe */
35#include <linux/mm.h>
36#include <linux/vmalloc.h>
37 36
38#if defined(CONFIG_CF_AREA6) 37#if defined(CONFIG_CF_AREA6)
39#define slot_no 0 38#define slot_no 0
@@ -41,9 +40,6 @@
41#define slot_no 1 40#define slot_no 1
42#endif 41#endif
43 42
44/* defined in mm/ioremap.c */
45extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags);
46
47/* use this pointer to access to directly connected compact flash io area*/ 43/* use this pointer to access to directly connected compact flash io area*/
48void *cf_io_base; 44void *cf_io_base;
49 45
@@ -62,7 +58,7 @@ static int __init allocate_cf_area(void)
62 return -ENOMEM; 58 return -ENOMEM;
63 } 59 }
64/* printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n", 60/* printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n",
65 paddrbase, psize, prot.pgprot, cf_io_base);*/ 61 paddrbase, psize, prot.pgprot, cf_io_base);*/
66 62
67 /* XXX : do we need attribute and common-memory area also? */ 63 /* XXX : do we need attribute and common-memory area also? */
68 64
@@ -87,7 +83,7 @@ static int __init cf_init_default(void)
87} 83}
88 84
89#if defined(CONFIG_SH_SOLUTION_ENGINE) 85#if defined(CONFIG_SH_SOLUTION_ENGINE)
90#include <asm/se/se.h> 86#include <asm/se.h>
91 87
92/* 88/*
93 * SolutionEngine 89 * SolutionEngine
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index 59d5b748752f..fb5dac069382 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -8,6 +8,5 @@ obj-$(CONFIG_CPU_SH2) += sh2/
8obj-$(CONFIG_CPU_SH3) += sh3/ 8obj-$(CONFIG_CPU_SH3) += sh3/
9obj-$(CONFIG_CPU_SH4) += sh4/ 9obj-$(CONFIG_CPU_SH4) += sh4/
10 10
11obj-$(CONFIG_SH_RTC) += rtc.o
12obj-$(CONFIG_UBC_WAKEUP) += ubc.o 11obj-$(CONFIG_UBC_WAKEUP) += ubc.o
13obj-$(CONFIG_SH_ADC) += adc.o 12obj-$(CONFIG_SH_ADC) += adc.o
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 97fa37f42b84..51ec64cdf348 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/sh/kernel/cpu/clock.c - SuperH clock framework 2 * arch/sh/kernel/cpu/clock.c - SuperH clock framework
3 * 3 *
4 * Copyright (C) 2005 Paul Mundt 4 * Copyright (C) 2005, 2006 Paul Mundt
5 * 5 *
6 * This clock framework is derived from the OMAP version by: 6 * This clock framework is derived from the OMAP version by:
7 * 7 *
@@ -15,6 +15,7 @@
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/mutex.h>
18#include <linux/list.h> 19#include <linux/list.h>
19#include <linux/kref.h> 20#include <linux/kref.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
@@ -24,7 +25,7 @@
24 25
25static LIST_HEAD(clock_list); 26static LIST_HEAD(clock_list);
26static DEFINE_SPINLOCK(clock_lock); 27static DEFINE_SPINLOCK(clock_lock);
27static DECLARE_MUTEX(clock_list_sem); 28static DEFINE_MUTEX(clock_list_sem);
28 29
29/* 30/*
30 * Each subtype is expected to define the init routines for these clocks, 31 * Each subtype is expected to define the init routines for these clocks,
@@ -140,21 +141,21 @@ void clk_disable(struct clk *clk)
140 141
141int clk_register(struct clk *clk) 142int clk_register(struct clk *clk)
142{ 143{
143 down(&clock_list_sem); 144 mutex_lock(&clock_list_sem);
144 145
145 list_add(&clk->node, &clock_list); 146 list_add(&clk->node, &clock_list);
146 kref_init(&clk->kref); 147 kref_init(&clk->kref);
147 148
148 up(&clock_list_sem); 149 mutex_unlock(&clock_list_sem);
149 150
150 return 0; 151 return 0;
151} 152}
152 153
153void clk_unregister(struct clk *clk) 154void clk_unregister(struct clk *clk)
154{ 155{
155 down(&clock_list_sem); 156 mutex_lock(&clock_list_sem);
156 list_del(&clk->node); 157 list_del(&clk->node);
157 up(&clock_list_sem); 158 mutex_unlock(&clock_list_sem);
158} 159}
159 160
160inline unsigned long clk_get_rate(struct clk *clk) 161inline unsigned long clk_get_rate(struct clk *clk)
@@ -198,14 +199,14 @@ struct clk *clk_get(const char *id)
198{ 199{
199 struct clk *p, *clk = ERR_PTR(-ENOENT); 200 struct clk *p, *clk = ERR_PTR(-ENOENT);
200 201
201 down(&clock_list_sem); 202 mutex_lock(&clock_list_sem);
202 list_for_each_entry(p, &clock_list, node) { 203 list_for_each_entry(p, &clock_list, node) {
203 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) { 204 if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
204 clk = p; 205 clk = p;
205 break; 206 break;
206 } 207 }
207 } 208 }
208 up(&clock_list_sem); 209 mutex_unlock(&clock_list_sem);
209 210
210 return clk; 211 return clk;
211} 212}
@@ -225,7 +226,7 @@ int __init clk_init(void)
225{ 226{
226 int i, ret = 0; 227 int i, ret = 0;
227 228
228 BUG_ON(unlikely(!master_clk.rate)); 229 BUG_ON(!master_clk.rate);
229 230
230 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { 231 for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) {
231 struct clk *clk = onchip_clocks[i]; 232 struct clk *clk = onchip_clocks[i];
diff --git a/arch/sh/kernel/cpu/init.c b/arch/sh/kernel/cpu/init.c
index 868e68b28880..bfb90eb0b7a6 100644
--- a/arch/sh/kernel/cpu/init.c
+++ b/arch/sh/kernel/cpu/init.c
@@ -4,6 +4,7 @@
4 * CPU init code 4 * CPU init code
5 * 5 *
6 * Copyright (C) 2002, 2003 Paul Mundt 6 * Copyright (C) 2002, 2003 Paul Mundt
7 * Copyright (C) 2003 Richard Curnow
7 * 8 *
8 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
@@ -13,6 +14,7 @@
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <asm/processor.h> 15#include <asm/processor.h>
15#include <asm/uaccess.h> 16#include <asm/uaccess.h>
17#include <asm/page.h>
16#include <asm/system.h> 18#include <asm/system.h>
17#include <asm/cacheflush.h> 19#include <asm/cacheflush.h>
18#include <asm/cache.h> 20#include <asm/cache.h>
@@ -51,7 +53,15 @@ static void __init cache_init(void)
51 ccr = ctrl_inl(CCR); 53 ccr = ctrl_inl(CCR);
52 54
53 /* 55 /*
54 * If the cache is already enabled .. flush it. 56 * At this point we don't know whether the cache is enabled or not - a
57 * bootloader may have enabled it. There are at least 2 things that
58 * could be dirty in the cache at this point:
59 * 1. kernel command line set up by boot loader
60 * 2. spilled registers from the prolog of this function
61 * => before re-initialising the cache, we must do a purge of the whole
62 * cache out to memory for safety. As long as nothing is spilled
63 * during the loop to lines that have already been done, this is safe.
64 * - RPC
55 */ 65 */
56 if (ccr & CCR_CACHE_ENABLE) { 66 if (ccr & CCR_CACHE_ENABLE) {
57 unsigned long ways, waysize, addrstart; 67 unsigned long ways, waysize, addrstart;
@@ -98,6 +108,8 @@ static void __init cache_init(void)
98 /* Force EMODE if possible */ 108 /* Force EMODE if possible */
99 if (cpu_data->dcache.ways > 1) 109 if (cpu_data->dcache.ways > 1)
100 flags |= CCR_CACHE_EMODE; 110 flags |= CCR_CACHE_EMODE;
111 else
112 flags &= ~CCR_CACHE_EMODE;
101#endif 113#endif
102 114
103#ifdef CONFIG_SH_WRITETHROUGH 115#ifdef CONFIG_SH_WRITETHROUGH
@@ -112,6 +124,9 @@ static void __init cache_init(void)
112 /* Turn on OCRAM -- halve the OC */ 124 /* Turn on OCRAM -- halve the OC */
113 flags |= CCR_CACHE_ORA; 125 flags |= CCR_CACHE_ORA;
114 cpu_data->dcache.sets >>= 1; 126 cpu_data->dcache.sets >>= 1;
127
128 cpu_data->dcache.way_size = cpu_data->dcache.sets *
129 cpu_data->dcache.linesz;
115#endif 130#endif
116 131
117 ctrl_outl(flags, CCR); 132 ctrl_outl(flags, CCR);
@@ -184,6 +199,10 @@ asmlinkage void __init sh_cpu_init(void)
184 /* Init the cache */ 199 /* Init the cache */
185 cache_init(); 200 cache_init();
186 201
202 shm_align_mask = max_t(unsigned long,
203 cpu_data->dcache.way_size - 1,
204 PAGE_SIZE - 1);
205
187 /* Disable the FPU */ 206 /* Disable the FPU */
188 if (fpu_disabled) { 207 if (fpu_disabled) {
189 printk("FPU Disabled\n"); 208 printk("FPU Disabled\n");
diff --git a/arch/sh/kernel/cpu/irq/Makefile b/arch/sh/kernel/cpu/irq/Makefile
index e3cccea15e1d..1c034c283f59 100644
--- a/arch/sh/kernel/cpu/irq/Makefile
+++ b/arch/sh/kernel/cpu/irq/Makefile
@@ -3,5 +3,6 @@
3# 3#
4obj-y += ipr.o imask.o 4obj-y += ipr.o imask.o
5 5
6obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o 6obj-$(CONFIG_CPU_HAS_PINT_IRQ) += pint.o
7obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o 7obj-$(CONFIG_CPU_HAS_MASKREG_IRQ) += maskreg.o
8obj-$(CONFIG_CPU_HAS_INTC2_IRQ) += intc2.o
diff --git a/arch/sh/kernel/cpu/irq/intc2.c b/arch/sh/kernel/cpu/irq/intc2.c
index 30064bf6e154..e30e4b7aa70e 100644
--- a/arch/sh/kernel/cpu/irq/intc2.c
+++ b/arch/sh/kernel/cpu/irq/intc2.c
@@ -241,9 +241,9 @@ static struct intc2_init {
241 /* 110-111 reserved/unused */ 241 /* 110-111 reserved/unused */
242#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 242#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
243 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2}, 243 { TIMER_IRQ, 0, 24, 0, INTC_TMU0_MSK, 2},
244#ifdef CONFIG_SH_RTC 244 { 21, 1, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY },
245 { RTC_IRQ, 4, 0, 0, INTC_RTC_MSK, TIMER_PRIORITY }, 245 { 22, 1, 1, 0, INTC_RTC_MSK, TIMER_PRIORITY },
246#endif 246 { 23, 1, 2, 0, INTC_RTC_MSK, TIMER_PRIORITY },
247 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, 247 { SCIF0_ERI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
248 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, 248 { SCIF0_RXI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
249 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY }, 249 { SCIF0_BRI_IRQ, 8, 24, 0, INTC_SCIF0_MSK, SCIF0_PRIORITY },
diff --git a/arch/sh/kernel/cpu/irq/ipr.c b/arch/sh/kernel/cpu/irq/ipr.c
index 0f545941fb4f..f785822cd5de 100644
--- a/arch/sh/kernel/cpu/irq/ipr.c
+++ b/arch/sh/kernel/cpu/irq/ipr.c
@@ -57,31 +57,27 @@ static struct hw_interrupt_type ipr_irq_type = {
57 57
58static void disable_ipr_irq(unsigned int irq) 58static void disable_ipr_irq(unsigned int irq)
59{ 59{
60 unsigned long val, flags; 60 unsigned long val;
61 unsigned int addr = ipr_data[irq].addr; 61 unsigned int addr = ipr_data[irq].addr;
62 unsigned short mask = 0xffff ^ (0x0f << ipr_data[irq].shift); 62 unsigned short mask = 0xffff ^ (0x0f << ipr_data[irq].shift);
63 63
64 /* Set the priority in IPR to 0 */ 64 /* Set the priority in IPR to 0 */
65 local_irq_save(flags);
66 val = ctrl_inw(addr); 65 val = ctrl_inw(addr);
67 val &= mask; 66 val &= mask;
68 ctrl_outw(val, addr); 67 ctrl_outw(val, addr);
69 local_irq_restore(flags);
70} 68}
71 69
72static void enable_ipr_irq(unsigned int irq) 70static void enable_ipr_irq(unsigned int irq)
73{ 71{
74 unsigned long val, flags; 72 unsigned long val;
75 unsigned int addr = ipr_data[irq].addr; 73 unsigned int addr = ipr_data[irq].addr;
76 int priority = ipr_data[irq].priority; 74 int priority = ipr_data[irq].priority;
77 unsigned short value = (priority << ipr_data[irq].shift); 75 unsigned short value = (priority << ipr_data[irq].shift);
78 76
79 /* Set priority in IPR back to original value */ 77 /* Set priority in IPR back to original value */
80 local_irq_save(flags);
81 val = ctrl_inw(addr); 78 val = ctrl_inw(addr);
82 val |= value; 79 val |= value;
83 ctrl_outw(val, addr); 80 ctrl_outw(val, addr);
84 local_irq_restore(flags);
85} 81}
86 82
87static void mask_and_ack_ipr(unsigned int irq) 83static void mask_and_ack_ipr(unsigned int irq)
@@ -89,6 +85,7 @@ static void mask_and_ack_ipr(unsigned int irq)
89 disable_ipr_irq(irq); 85 disable_ipr_irq(irq);
90 86
91#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 87#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
88 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
92 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 89 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
93 /* This is needed when we use edge triggered setting */ 90 /* This is needed when we use edge triggered setting */
94 /* XXX: Is it really needed? */ 91 /* XXX: Is it really needed? */
@@ -123,7 +120,7 @@ void __init init_IRQ(void)
123#ifndef CONFIG_CPU_SUBTYPE_SH7780 120#ifndef CONFIG_CPU_SUBTYPE_SH7780
124 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); 121 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY);
125 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); 122 make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY);
126#if defined(CONFIG_SH_RTC) 123#ifdef RTC_IRQ
127 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); 124 make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY);
128#endif 125#endif
129 126
@@ -162,6 +159,7 @@ void __init init_IRQ(void)
162#endif 159#endif
163 160
164#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 161#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \
162 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
165 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 163 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705)
166 /* 164 /*
167 * Initialize the Interrupt Controller (INTC) 165 * Initialize the Interrupt Controller (INTC)
@@ -192,6 +190,8 @@ void __init init_IRQ(void)
192 /* Perform the machine specific initialisation */ 190 /* Perform the machine specific initialisation */
193 if (sh_mv.mv_init_irq != NULL) 191 if (sh_mv.mv_init_irq != NULL)
194 sh_mv.mv_init_irq(); 192 sh_mv.mv_init_irq();
193
194 irq_ctx_init(smp_processor_id());
195} 195}
196 196
197#if !defined(CONFIG_CPU_HAS_PINT_IRQ) 197#if !defined(CONFIG_CPU_HAS_PINT_IRQ)
diff --git a/arch/sh/boards/adx/irq_maskreg.c b/arch/sh/kernel/cpu/irq/maskreg.c
index 4b2abe5eb165..492db31b3cab 100644
--- a/arch/sh/boards/adx/irq_maskreg.c
+++ b/arch/sh/kernel/cpu/irq/maskreg.c
@@ -1,30 +1,23 @@
1/* 1/*
2 * linux/arch/sh/kernel/irq_maskreg.c 2 * Interrupt handling for Simple external interrupt mask register
3 * 3 *
4 * Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp> 4 * Copyright (C) 2001 A&D Co., Ltd. <http://www.aandd.co.jp>
5 * 5 *
6 * This file may be copied or modified under the terms of the GNU
7 * General Public License. See linux/COPYING for more information.
8 *
9 * Interrupt handling for Simple external interrupt mask register
10 *
11 * This is for the machine which have single 16 bit register 6 * This is for the machine which have single 16 bit register
12 * for masking external IRQ individually. 7 * for masking external IRQ individually.
13 * Each bit of the register is for masking each interrupt. 8 * Each bit of the register is for masking each interrupt.
9 *
10 * This file may be copied or modified under the terms of the GNU
11 * General Public License. See linux/COPYING for more information.
14 */ 12 */
15
16#include <linux/kernel.h> 13#include <linux/kernel.h>
17#include <linux/init.h> 14#include <linux/init.h>
18#include <linux/irq.h> 15#include <linux/irq.h>
19
20#include <asm/system.h> 16#include <asm/system.h>
21#include <asm/io.h> 17#include <asm/io.h>
22#include <asm/machvec.h>
23 18
24/* address of external interrupt mask register 19/* address of external interrupt mask register */
25 * address must be set prior to use these (maybe in init_XXX_irq()) 20unsigned long irq_mask_register;
26 * XXX : is it better to use .config than specifying it in code? */
27unsigned short *irq_mask_register = 0;
28 21
29/* forward declaration */ 22/* forward declaration */
30static unsigned int startup_maskreg_irq(unsigned int irq); 23static unsigned int startup_maskreg_irq(unsigned int irq);
@@ -36,7 +29,7 @@ static void end_maskreg_irq(unsigned int irq);
36 29
37/* hw_interrupt_type */ 30/* hw_interrupt_type */
38static struct hw_interrupt_type maskreg_irq_type = { 31static struct hw_interrupt_type maskreg_irq_type = {
39 .typename = " Mask Register", 32 .typename = "Mask Register",
40 .startup = startup_maskreg_irq, 33 .startup = startup_maskreg_irq,
41 .shutdown = shutdown_maskreg_irq, 34 .shutdown = shutdown_maskreg_irq,
42 .enable = enable_maskreg_irq, 35 .enable = enable_maskreg_irq,
@@ -47,7 +40,7 @@ static struct hw_interrupt_type maskreg_irq_type = {
47 40
48/* actual implementatin */ 41/* actual implementatin */
49static unsigned int startup_maskreg_irq(unsigned int irq) 42static unsigned int startup_maskreg_irq(unsigned int irq)
50{ 43{
51 enable_maskreg_irq(irq); 44 enable_maskreg_irq(irq);
52 return 0; /* never anything pending */ 45 return 0; /* never anything pending */
53} 46}
@@ -59,32 +52,26 @@ static void shutdown_maskreg_irq(unsigned int irq)
59 52
60static void disable_maskreg_irq(unsigned int irq) 53static void disable_maskreg_irq(unsigned int irq)
61{ 54{
62 if (irq_mask_register) { 55 unsigned short val, mask = 0x01 << irq;
63 unsigned long flags; 56
64 unsigned short val, mask = 0x01 << irq; 57 BUG_ON(!irq_mask_register);
65 58
66 /* Set "irq"th bit */ 59 /* Set "irq"th bit */
67 local_irq_save(flags); 60 val = ctrl_inw(irq_mask_register);
68 val = ctrl_inw((unsigned long)irq_mask_register); 61 val |= mask;
69 val |= mask; 62 ctrl_outw(val, irq_mask_register);
70 ctrl_outw(val, (unsigned long)irq_mask_register);
71 local_irq_restore(flags);
72 }
73} 63}
74 64
75static void enable_maskreg_irq(unsigned int irq) 65static void enable_maskreg_irq(unsigned int irq)
76{ 66{
77 if (irq_mask_register) { 67 unsigned short val, mask = ~(0x01 << irq);
78 unsigned long flags; 68
79 unsigned short val, mask = ~(0x01 << irq); 69 BUG_ON(!irq_mask_register);
80 70
81 /* Clear "irq"th bit */ 71 /* Clear "irq"th bit */
82 local_irq_save(flags); 72 val = ctrl_inw(irq_mask_register);
83 val = ctrl_inw((unsigned long)irq_mask_register); 73 val &= mask;
84 val &= mask; 74 ctrl_outw(val, irq_mask_register);
85 ctrl_outw(val, (unsigned long)irq_mask_register);
86 local_irq_restore(flags);
87 }
88} 75}
89 76
90static void mask_and_ack_maskreg(unsigned int irq) 77static void mask_and_ack_maskreg(unsigned int irq)
@@ -101,6 +88,6 @@ static void end_maskreg_irq(unsigned int irq)
101void make_maskreg_irq(unsigned int irq) 88void make_maskreg_irq(unsigned int irq)
102{ 89{
103 disable_irq_nosync(irq); 90 disable_irq_nosync(irq);
104 irq_desc[irq].chip = &maskreg_irq_type; 91 irq_desc[irq].handler = &maskreg_irq_type;
105 disable_maskreg_irq(irq); 92 disable_maskreg_irq(irq);
106} 93}
diff --git a/arch/sh/kernel/cpu/irq/pint.c b/arch/sh/kernel/cpu/irq/pint.c
index 80cd8108d36a..17f47b373d6e 100644
--- a/arch/sh/kernel/cpu/irq/pint.c
+++ b/arch/sh/kernel/cpu/irq/pint.c
@@ -48,26 +48,22 @@ static struct hw_interrupt_type pint_irq_type = {
48 48
49static void disable_pint_irq(unsigned int irq) 49static void disable_pint_irq(unsigned int irq)
50{ 50{
51 unsigned long val, flags; 51 unsigned long val;
52 52
53 local_irq_save(flags);
54 val = ctrl_inw(INTC_INTER); 53 val = ctrl_inw(INTC_INTER);
55 val &= ~(1 << (irq - PINT_IRQ_BASE)); 54 val &= ~(1 << (irq - PINT_IRQ_BASE));
56 ctrl_outw(val, INTC_INTER); /* disable PINTn */ 55 ctrl_outw(val, INTC_INTER); /* disable PINTn */
57 portcr_mask &= ~(3 << (irq - PINT_IRQ_BASE)*2); 56 portcr_mask &= ~(3 << (irq - PINT_IRQ_BASE)*2);
58 local_irq_restore(flags);
59} 57}
60 58
61static void enable_pint_irq(unsigned int irq) 59static void enable_pint_irq(unsigned int irq)
62{ 60{
63 unsigned long val, flags; 61 unsigned long val;
64 62
65 local_irq_save(flags);
66 val = ctrl_inw(INTC_INTER); 63 val = ctrl_inw(INTC_INTER);
67 val |= 1 << (irq - PINT_IRQ_BASE); 64 val |= 1 << (irq - PINT_IRQ_BASE);
68 ctrl_outw(val, INTC_INTER); /* enable PINTn */ 65 ctrl_outw(val, INTC_INTER); /* enable PINTn */
69 portcr_mask |= 3 << (irq - PINT_IRQ_BASE)*2; 66 portcr_mask |= 3 << (irq - PINT_IRQ_BASE)*2;
70 local_irq_restore(flags);
71} 67}
72 68
73static void mask_and_ack_pint(unsigned int irq) 69static void mask_and_ack_pint(unsigned int irq)
diff --git a/arch/sh/kernel/cpu/rtc.c b/arch/sh/kernel/cpu/rtc.c
deleted file mode 100644
index 4304cf75cfa2..000000000000
--- a/arch/sh/kernel/cpu/rtc.c
+++ /dev/null
@@ -1,128 +0,0 @@
1/*
2 * linux/arch/sh/kernel/rtc.c -- SH3 / SH4 on-chip RTC support
3 *
4 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
5 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
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 <asm/io.h>
14#include <asm/rtc.h>
15
16void sh_rtc_gettimeofday(struct timespec *ts)
17{
18 unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit;
19 unsigned long flags;
20
21 again:
22 do {
23 local_irq_save(flags);
24 ctrl_outb(0, RCR1); /* Clear CF-bit */
25 sec128 = ctrl_inb(R64CNT);
26 sec = ctrl_inb(RSECCNT);
27 min = ctrl_inb(RMINCNT);
28 hr = ctrl_inb(RHRCNT);
29 wk = ctrl_inb(RWKCNT);
30 day = ctrl_inb(RDAYCNT);
31 mon = ctrl_inb(RMONCNT);
32#if defined(CONFIG_CPU_SH4)
33 yr = ctrl_inw(RYRCNT);
34 yr100 = (yr >> 8);
35 yr &= 0xff;
36#else
37 yr = ctrl_inb(RYRCNT);
38 yr100 = (yr == 0x99) ? 0x19 : 0x20;
39#endif
40 sec2 = ctrl_inb(R64CNT);
41 cf_bit = ctrl_inb(RCR1) & RCR1_CF;
42 local_irq_restore(flags);
43 } while (cf_bit != 0 || ((sec128 ^ sec2) & RTC_BIT_INVERTED) != 0);
44
45 BCD_TO_BIN(yr100);
46 BCD_TO_BIN(yr);
47 BCD_TO_BIN(mon);
48 BCD_TO_BIN(day);
49 BCD_TO_BIN(hr);
50 BCD_TO_BIN(min);
51 BCD_TO_BIN(sec);
52
53 if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 ||
54 hr > 23 || min > 59 || sec > 59) {
55 printk(KERN_ERR
56 "SH RTC: invalid value, resetting to 1 Jan 2000\n");
57 local_irq_save(flags);
58 ctrl_outb(RCR2_RESET, RCR2); /* Reset & Stop */
59 ctrl_outb(0, RSECCNT);
60 ctrl_outb(0, RMINCNT);
61 ctrl_outb(0, RHRCNT);
62 ctrl_outb(6, RWKCNT);
63 ctrl_outb(1, RDAYCNT);
64 ctrl_outb(1, RMONCNT);
65#if defined(CONFIG_CPU_SH4)
66 ctrl_outw(0x2000, RYRCNT);
67#else
68 ctrl_outb(0, RYRCNT);
69#endif
70 ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start */
71 goto again;
72 }
73
74#if RTC_BIT_INVERTED != 0
75 if ((sec128 & RTC_BIT_INVERTED))
76 sec--;
77#endif
78
79 ts->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec);
80 ts->tv_nsec = ((sec128 * 1000000) / 128) * 1000;
81}
82
83/*
84 * Changed to only care about tv_sec, and not the full timespec struct
85 * (i.e. tv_nsec). It can easily be switched to timespec for future cpus
86 * that support setting usec or nsec RTC values.
87 */
88int sh_rtc_settimeofday(const time_t secs)
89{
90 int retval = 0;
91 int real_seconds, real_minutes, cmos_minutes;
92 unsigned long flags;
93
94 local_irq_save(flags);
95 ctrl_outb(RCR2_RESET, RCR2); /* Reset pre-scaler & stop RTC */
96
97 cmos_minutes = ctrl_inb(RMINCNT);
98 BCD_TO_BIN(cmos_minutes);
99
100 /*
101 * since we're only adjusting minutes and seconds,
102 * don't interfere with hour overflow. This avoids
103 * messing with unknown time zones but requires your
104 * RTC not to be off by more than 15 minutes
105 */
106 real_seconds = secs % 60;
107 real_minutes = secs / 60;
108 if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
109 real_minutes += 30; /* correct for half hour time zone */
110 real_minutes %= 60;
111
112 if (abs(real_minutes - cmos_minutes) < 30) {
113 BIN_TO_BCD(real_seconds);
114 BIN_TO_BCD(real_minutes);
115 ctrl_outb(real_seconds, RSECCNT);
116 ctrl_outb(real_minutes, RMINCNT);
117 } else {
118 printk(KERN_WARNING
119 "set_rtc_time: can't update from %d to %d\n",
120 cmos_minutes, real_minutes);
121 retval = -1;
122 }
123
124 ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */
125 local_irq_restore(flags);
126
127 return retval;
128}
diff --git a/arch/sh/kernel/cpu/sh3/Makefile b/arch/sh/kernel/cpu/sh3/Makefile
index b54dbb9a0c86..58d3815695ff 100644
--- a/arch/sh/kernel/cpu/sh3/Makefile
+++ b/arch/sh/kernel/cpu/sh3/Makefile
@@ -4,10 +4,21 @@
4 4
5obj-y := ex.o probe.o 5obj-y := ex.o probe.o
6 6
7# CPU subtype setup
8obj-$(CONFIG_CPU_SUBTYPE_SH7705) += setup-sh7705.o
9obj-$(CONFIG_CPU_SUBTYPE_SH7706) += setup-sh7709.o
10obj-$(CONFIG_CPU_SUBTYPE_SH7707) += setup-sh7709.o
11obj-$(CONFIG_CPU_SUBTYPE_SH7708) += setup-sh7708.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7709) += setup-sh7709.o
13obj-$(CONFIG_CPU_SUBTYPE_SH7300) += setup-sh7300.o
14obj-$(CONFIG_CPU_SUBTYPE_SH7710) += setup-sh7710.o
15
16# Primary on-chip clocks (common)
7clock-$(CONFIG_CPU_SH3) := clock-sh3.o 17clock-$(CONFIG_CPU_SH3) := clock-sh3.o
8clock-$(CONFIG_CPU_SUBTYPE_SH7300) := clock-sh7300.o 18clock-$(CONFIG_CPU_SUBTYPE_SH7300) := clock-sh7300.o
9clock-$(CONFIG_CPU_SUBTYPE_SH7705) := clock-sh7705.o 19clock-$(CONFIG_CPU_SUBTYPE_SH7705) := clock-sh7705.o
20clock-$(CONFIG_CPU_SUBTYPE_SH7706) := clock-sh7706.o
10clock-$(CONFIG_CPU_SUBTYPE_SH7709) := clock-sh7709.o 21clock-$(CONFIG_CPU_SUBTYPE_SH7709) := clock-sh7709.o
22clock-$(CONFIG_CPU_SUBTYPE_SH7710) := clock-sh7300.o
11 23
12obj-y += $(clock-y) 24obj-y += $(clock-y)
13
diff --git a/arch/sh/kernel/cpu/sh3/clock-sh7706.c b/arch/sh/kernel/cpu/sh3/clock-sh7706.c
new file mode 100644
index 000000000000..0cf96f9833bc
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/clock-sh7706.c
@@ -0,0 +1,84 @@
1/*
2 * arch/sh/kernel/cpu/sh3/clock-sh7706.c
3 *
4 * SH7706 support for the clock framework
5 *
6 * Copyright (C) 2006 Takashi YOSHII
7 *
8 * Based on arch/sh/kernel/cpu/sh3/clock-sh7709.c
9 * Copyright (C) 2005 Andriy Skulysh
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <asm/clock.h>
18#include <asm/freq.h>
19#include <asm/io.h>
20
21static int stc_multipliers[] = { 1, 2, 4, 1, 3, 6, 1, 1 };
22static int ifc_divisors[] = { 1, 2, 4, 1, 3, 1, 1, 1 };
23static int pfc_divisors[] = { 1, 2, 4, 1, 3, 6, 1, 1 };
24
25static void master_clk_init(struct clk *clk)
26{
27 int frqcr = ctrl_inw(FRQCR);
28 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
29
30 clk->rate *= pfc_divisors[idx];
31}
32
33static struct clk_ops sh7706_master_clk_ops = {
34 .init = master_clk_init,
35};
36
37static void module_clk_recalc(struct clk *clk)
38{
39 int frqcr = ctrl_inw(FRQCR);
40 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
41
42 clk->rate = clk->parent->rate / pfc_divisors[idx];
43}
44
45static struct clk_ops sh7706_module_clk_ops = {
46 .recalc = module_clk_recalc,
47};
48
49static void bus_clk_recalc(struct clk *clk)
50{
51 int frqcr = ctrl_inw(FRQCR);
52 int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);
53
54 clk->rate = clk->parent->rate / stc_multipliers[idx];
55}
56
57static struct clk_ops sh7706_bus_clk_ops = {
58 .recalc = bus_clk_recalc,
59};
60
61static void cpu_clk_recalc(struct clk *clk)
62{
63 int frqcr = ctrl_inw(FRQCR);
64 int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);
65
66 clk->rate = clk->parent->rate / ifc_divisors[idx];
67}
68
69static struct clk_ops sh7706_cpu_clk_ops = {
70 .recalc = cpu_clk_recalc,
71};
72
73static struct clk_ops *sh7706_clk_ops[] = {
74 &sh7706_master_clk_ops,
75 &sh7706_module_clk_ops,
76 &sh7706_bus_clk_ops,
77 &sh7706_cpu_clk_ops,
78};
79
80void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
81{
82 if (idx < ARRAY_SIZE(sh7706_clk_ops))
83 *ops = sh7706_clk_ops[idx];
84}
diff --git a/arch/sh/kernel/cpu/sh3/ex.S b/arch/sh/kernel/cpu/sh3/ex.S
index cc04e9e239ff..44daf44833f9 100644
--- a/arch/sh/kernel/cpu/sh3/ex.S
+++ b/arch/sh/kernel/cpu/sh3/ex.S
@@ -84,8 +84,12 @@ ENTRY(interrupt_table)
84 .long do_IRQ ! rovi 84 .long do_IRQ ! rovi
85 .long do_IRQ 85 .long do_IRQ
86 .long do_IRQ /* 5E0 */ 86 .long do_IRQ /* 5E0 */
87#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 87#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
88 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 88 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
89 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
90 defined(CONFIG_CPU_SUBTYPE_SH7300) || \
91 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
92 defined(CONFIG_CPU_SUBTYPE_SH7710)
89 .long do_IRQ ! 32 IRQ irq0 /* 600 */ 93 .long do_IRQ ! 32 IRQ irq0 /* 600 */
90 .long do_IRQ ! 33 irq1 94 .long do_IRQ ! 33 irq1
91 .long do_IRQ ! 34 irq2 95 .long do_IRQ ! 34 irq2
@@ -147,6 +151,51 @@ ENTRY(interrupt_table)
147 .long do_IRQ ! 62 PCC pcc0i 151 .long do_IRQ ! 62 PCC pcc0i
148 .long do_IRQ ! 63 pcc1i /* 9E0 */ 152 .long do_IRQ ! 63 pcc1i /* 9E0 */
149#endif 153#endif
154#if defined(CONFIG_CPU_SUBTYPE_SH7710)
155 .long exception_none ! 61 /* 9A0 */
156 .long exception_none ! 62
157 .long exception_none ! 63
158 .long exception_none ! 64 /* A00 */
159 .long exception_none ! 65
160 .long exception_none ! 66
161 .long exception_none ! 67
162 .long exception_none ! 68
163 .long exception_none ! 69
164 .long exception_none ! 70
165 .long exception_none ! 71
166 .long exception_none ! 72 /* B00 */
167 .long exception_none ! 73
168 .long exception_none ! 74
169 .long exception_none ! 75
170 .long do_IRQ ! 76 DMAC2 dei4 /* B80 */
171 .long do_IRQ ! 77 DMAC2 dei5
172 .long exception_none ! 78
173 .long do_IRQ ! 79 IPSEC ipseci /* BE0 */
174 .long do_IRQ ! 80 EDMAC eint0 /* C00 */
175 .long do_IRQ ! 81 EDMAC eint1
176 .long do_IRQ ! 82 EDMAC eint2
177 .long exception_none ! 83 /* C60 */
178 .long exception_none ! 84
179 .long exception_none ! 85
180 .long exception_none ! 86
181 .long exception_none ! 87
182 .long exception_none ! 88 /* D00 */
183 .long exception_none ! 89
184 .long exception_none ! 90
185 .long exception_none ! 91
186 .long exception_none ! 92
187 .long exception_none ! 93
188 .long exception_none ! 94
189 .long exception_none ! 95
190 .long do_IRQ ! 96 SIOF eri0 /* E00 */
191 .long do_IRQ ! 97 txi0
192 .long do_IRQ ! 98 rxi0
193 .long do_IRQ ! 99 cci0
194 .long do_IRQ ! 100 eri1 /* E80 */
195 .long do_IRQ ! 101 txi1
196 .long do_IRQ ! 102 rxi2
197 .long do_IRQ ! 103 cci3
198#endif
150#if defined(CONFIG_CPU_SUBTYPE_SH7300) 199#if defined(CONFIG_CPU_SUBTYPE_SH7300)
151 .long do_IRQ ! 64 200 .long do_IRQ ! 64
152 .long do_IRQ ! 65 201 .long do_IRQ ! 65
@@ -195,4 +244,3 @@ ENTRY(interrupt_table)
195 .long do_IRQ ! 108 244 .long do_IRQ ! 108
196#endif 245#endif
197#endif 246#endif
198
diff --git a/arch/sh/kernel/cpu/sh3/probe.c b/arch/sh/kernel/cpu/sh3/probe.c
index 5cdc88638601..e67098836290 100644
--- a/arch/sh/kernel/cpu/sh3/probe.c
+++ b/arch/sh/kernel/cpu/sh3/probe.c
@@ -72,6 +72,12 @@ int __init detect_cpu_and_cache_system(void)
72 cpu_data->dcache.sets = 256; 72 cpu_data->dcache.sets = 256;
73 cpu_data->type = CPU_SH7729; 73 cpu_data->type = CPU_SH7729;
74 74
75#if defined(CONFIG_CPU_SUBTYPE_SH7706)
76 cpu_data->type = CPU_SH7706;
77#endif
78#if defined(CONFIG_CPU_SUBTYPE_SH7710)
79 cpu_data->type = CPU_SH7710;
80#endif
75#if defined(CONFIG_CPU_SUBTYPE_SH7705) 81#if defined(CONFIG_CPU_SUBTYPE_SH7705)
76 cpu_data->type = CPU_SH7705; 82 cpu_data->type = CPU_SH7705;
77 83
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7300.c b/arch/sh/kernel/cpu/sh3/setup-sh7300.c
new file mode 100644
index 000000000000..ab4d204bfba5
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7300.c
@@ -0,0 +1,43 @@
1/*
2 * SH7300 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xa4430000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCI,
20 .irqs = { 80, 80, 80, 80 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh7300_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh7300_devices_setup(void)
39{
40 return platform_add_devices(sh7300_devices,
41 ARRAY_SIZE(sh7300_devices));
42}
43__initcall(sh7300_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7705.c b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
new file mode 100644
index 000000000000..a8e41c5241fa
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
@@ -0,0 +1,48 @@
1/*
2 * SH7705 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xa4400000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 52, 53, 55, 54 },
21 }, {
22 .mapbase = 0xa4410000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 56, 57, 59, 58 },
26 }, {
27 .flags = 0,
28 }
29};
30
31static struct platform_device sci_device = {
32 .name = "sh-sci",
33 .id = -1,
34 .dev = {
35 .platform_data = sci_platform_data,
36 },
37};
38
39static struct platform_device *sh7705_devices[] __initdata = {
40 &sci_device,
41};
42
43static int __init sh7705_devices_setup(void)
44{
45 return platform_add_devices(sh7705_devices,
46 ARRAY_SIZE(sh7705_devices));
47}
48__initcall(sh7705_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7708.c b/arch/sh/kernel/cpu/sh3/setup-sh7708.c
new file mode 100644
index 000000000000..f933723911ca
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7708.c
@@ -0,0 +1,43 @@
1/*
2 * SH7708 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xfffffe80,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCI,
20 .irqs = { 23, 24, 25, 0 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh7708_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh7708_devices_setup(void)
39{
40 return platform_add_devices(sh7708_devices,
41 ARRAY_SIZE(sh7708_devices));
42}
43__initcall(sh7708_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7709.c b/arch/sh/kernel/cpu/sh3/setup-sh7709.c
new file mode 100644
index 000000000000..ff43ef2a1f0c
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7709.c
@@ -0,0 +1,53 @@
1/*
2 * SH7707/SH7709 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xfffffe80,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCI,
20 .irqs = { 23, 24, 25, 0 },
21 }, {
22 .mapbase = 0xa4000150,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 56, 57, 59, 58 },
26 }, {
27 .mapbase = 0xa4000140,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_IRDA,
30 .irqs = { 52, 53, 55, 54 },
31 }, {
32 .flags = 0,
33 }
34};
35
36static struct platform_device sci_device = {
37 .name = "sh-sci",
38 .id = -1,
39 .dev = {
40 .platform_data = sci_platform_data,
41 },
42};
43
44static struct platform_device *sh7709_devices[] __initdata = {
45 &sci_device,
46};
47
48static int __init sh7709_devices_setup(void)
49{
50 return platform_add_devices(sh7709_devices,
51 ARRAY_SIZE(sh7709_devices));
52}
53__initcall(sh7709_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7710.c b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
new file mode 100644
index 000000000000..895f99ee6a95
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
@@ -0,0 +1,43 @@
1/*
2 * SH7710 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xa4400000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 52, 53, 55, 54 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh7710_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh7710_devices_setup(void)
39{
40 return platform_add_devices(sh7710_devices,
41 ARRAY_SIZE(sh7710_devices));
42}
43__initcall(sh7710_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
index 3d5cafc71ae3..8dbf3895ece7 100644
--- a/arch/sh/kernel/cpu/sh4/Makefile
+++ b/arch/sh/kernel/cpu/sh4/Makefile
@@ -7,6 +7,16 @@ obj-y := ex.o probe.o
7obj-$(CONFIG_SH_FPU) += fpu.o 7obj-$(CONFIG_SH_FPU) += fpu.o
8obj-$(CONFIG_SH_STORE_QUEUES) += sq.o 8obj-$(CONFIG_SH_STORE_QUEUES) += sq.o
9 9
10# CPU subtype setup
11obj-$(CONFIG_CPU_SUBTYPE_SH7750) += setup-sh7750.o
12obj-$(CONFIG_CPU_SUBTYPE_SH7751) += setup-sh7750.o
13obj-$(CONFIG_CPU_SUBTYPE_SH7760) += setup-sh7760.o
14obj-$(CONFIG_CPU_SUBTYPE_SH7770) += setup-sh7770.o
15obj-$(CONFIG_CPU_SUBTYPE_SH7780) += setup-sh7780.o
16obj-$(CONFIG_CPU_SUBTYPE_SH73180) += setup-sh73180.o
17obj-$(CONFIG_CPU_SUBTYPE_SH7343) += setup-sh7343.o
18obj-$(CONFIG_CPU_SUBTYPE_SH4_202) += setup-sh4-202.o
19
10# Primary on-chip clocks (common) 20# Primary on-chip clocks (common)
11clock-$(CONFIG_CPU_SH4) := clock-sh4.o 21clock-$(CONFIG_CPU_SH4) := clock-sh4.o
12clock-$(CONFIG_CPU_SUBTYPE_SH73180) := clock-sh73180.o 22clock-$(CONFIG_CPU_SUBTYPE_SH73180) := clock-sh73180.o
diff --git a/arch/sh/kernel/cpu/sh4/ex.S b/arch/sh/kernel/cpu/sh4/ex.S
index 26a27df06505..7146893a6cca 100644
--- a/arch/sh/kernel/cpu/sh4/ex.S
+++ b/arch/sh/kernel/cpu/sh4/ex.S
@@ -72,6 +72,7 @@ ENTRY(interrupt_table)
72 .long do_IRQ ! 1110 72 .long do_IRQ ! 1110
73 .long exception_error 73 .long exception_error
74 ! Internal hardware 74 ! Internal hardware
75#ifndef CONFIG_CPU_SUBTYPE_SH7780
75 .long do_IRQ ! TMU0 tuni0 /* 400 */ 76 .long do_IRQ ! TMU0 tuni0 /* 400 */
76 .long do_IRQ ! TMU1 tuni1 77 .long do_IRQ ! TMU1 tuni1
77 .long do_IRQ ! TMU2 tuni2 78 .long do_IRQ ! TMU2 tuni2
@@ -122,6 +123,13 @@ ENTRY(interrupt_table)
122 .long do_IRQ ! 45 dmte5 123 .long do_IRQ ! 45 dmte5
123 .long do_IRQ ! 46 dmte6 124 .long do_IRQ ! 46 dmte6
124 .long do_IRQ ! 47 dmte7 /* 7E0 */ 125 .long do_IRQ ! 47 dmte7 /* 7E0 */
126#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
127 .long do_IRQ ! 44 IIC1 ali /* 780 */
128 .long do_IRQ ! 45 tacki
129 .long do_IRQ ! 46 waiti
130 .long do_IRQ ! 47 dtei /* 7E0 */
131 .long do_IRQ ! 48 DMAC dei0 /* 800 */
132 .long do_IRQ ! 49 dei1 /* 820 */
125#else 133#else
126 .long exception_error ! 44 /* 780 */ 134 .long exception_error ! 44 /* 780 */
127 .long exception_error ! 45 135 .long exception_error ! 45
@@ -131,7 +139,8 @@ ENTRY(interrupt_table)
131#if defined(CONFIG_SH_FPU) 139#if defined(CONFIG_SH_FPU)
132 .long do_fpu_state_restore ! 48 /* 800 */ 140 .long do_fpu_state_restore ! 48 /* 800 */
133 .long do_fpu_state_restore ! 49 /* 820 */ 141 .long do_fpu_state_restore ! 49 /* 820 */
134#else 142#elif !defined(CONFIG_CPU_SUBTYPE_SH7343) && \
143 !defined(CONFIG_CPU_SUBTYPE_SH73180)
135 .long exception_error 144 .long exception_error
136 .long exception_error 145 .long exception_error
137#endif 146#endif
@@ -224,7 +233,7 @@ ENTRY(interrupt_table)
224 .long exception_error 233 .long exception_error
225 .long do_IRQ ! ADC adi 234 .long do_IRQ ! ADC adi
226 .long do_IRQ ! CMT cmti /* FA0 */ 235 .long do_IRQ ! CMT cmti /* FA0 */
227#elif defined(CONFIG_CPU_SUBTYPE_SH73180) 236#elif defined(CONFIG_CPU_SUBTYPE_SH73180) || defined(CONFIG_CPU_SUBTYPE_SH7343)
228 .long do_IRQ ! 50 0x840 237 .long do_IRQ ! 50 0x840
229 .long do_IRQ ! 51 0x860 238 .long do_IRQ ! 51 0x860
230 .long do_IRQ ! 52 0x880 239 .long do_IRQ ! 52 0x880
@@ -379,5 +388,168 @@ ENTRY(interrupt_table)
379 .long exception_error ! 141 0x13a0 388 .long exception_error ! 141 0x13a0
380 .long exception_error ! 142 0x13c0 389 .long exception_error ! 142 0x13c0
381 .long exception_error ! 143 0x13e0 390 .long exception_error ! 143 0x13e0
391#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
392 .long do_IRQ ! 50 0x840
393 .long do_IRQ ! 51 0x860
394 .long do_IRQ ! 52 0x880
395 .long do_IRQ ! 53 0x8a0
396 .long do_IRQ ! 54 0x8c0
397 .long do_IRQ ! 55 0x8e0
398 .long do_IRQ ! 56 0x900
399 .long do_IRQ ! 57 0x920
400 .long do_IRQ ! 58 0x940
401 .long do_IRQ ! 59 0x960
402 .long do_IRQ ! 60 0x980
403 .long do_IRQ ! 61 0x9a0
404 .long do_IRQ ! 62 0x9c0
405 .long do_IRQ ! 63 0x9e0
406 .long do_IRQ ! 64 0xa00
407 .long do_IRQ ! 65 0xa20
408 .long do_IRQ ! 66 0xa4d
409 .long do_IRQ ! 67 0xa60
410 .long do_IRQ ! 68 0xa80
411 .long do_IRQ ! 69 0xaa0
412 .long do_IRQ ! 70 0xac0
413 .long do_IRQ ! 71 0xae0
414 .long do_IRQ ! 72 0xb00
415 .long do_IRQ ! 73 0xb20
416 .long do_IRQ ! 74 0xb40
417 .long do_IRQ ! 75 0xb60
418 .long do_IRQ ! 76 0xb80
419 .long do_IRQ ! 77 0xba0
420 .long do_IRQ ! 78 0xbc0
421 .long do_IRQ ! 79 0xbe0
422 .long do_IRQ ! 80 0xc00
423 .long do_IRQ ! 81 0xc20
424 .long do_IRQ ! 82 0xc40
425 .long do_IRQ ! 83 0xc60
426 .long do_IRQ ! 84 0xc80
427 .long do_IRQ ! 85 0xca0
428 .long do_IRQ ! 86 0xcc0
429 .long do_IRQ ! 87 0xce0
430 .long do_IRQ ! 88 0xd00
431 .long do_IRQ ! 89 0xd20
432 .long do_IRQ ! 90 0xd40
433 .long do_IRQ ! 91 0xd60
434 .long do_IRQ ! 92 0xd80
435 .long do_IRQ ! 93 0xda0
436 .long do_IRQ ! 94 0xdc0
437 .long do_IRQ ! 95 0xde0
438 .long do_IRQ ! 96 0xe00
439 .long do_IRQ ! 97 0xe20
440 .long do_IRQ ! 98 0xe40
441 .long do_IRQ ! 99 0xe60
442 .long do_IRQ ! 100 0xe80
443 .long do_IRQ ! 101 0xea0
444 .long do_IRQ ! 102 0xec0
445 .long do_IRQ ! 103 0xee0
446 .long do_IRQ ! 104 0xf00
447 .long do_IRQ ! 105 0xf20
448 .long do_IRQ ! 106 0xf40
449 .long do_IRQ ! 107 0xf60
450 .long do_IRQ ! 108 0xf80
451#endif
452#else
453 .long exception_error /* 400 */
454 .long exception_error
455 .long exception_error
456 .long exception_error
457 .long do_IRQ ! RTC ati
458 .long do_IRQ ! pri
459 .long do_IRQ ! cui
460 .long exception_error
461 .long exception_error /* 500 */
462 .long exception_error
463 .long exception_error
464 .long do_IRQ ! WDT iti /* 560 */
465 .long do_IRQ ! TMU-ch0
466 .long do_IRQ ! TMU-ch1
467 .long do_IRQ ! TMU-ch2
468 .long do_IRQ ! ticpi2 /* 5E0 */
469 .long do_IRQ ! 32 Hitachi UDI /* 600 */
470 .long exception_error
471 .long do_IRQ ! 34 DMAC dmte0
472 .long do_IRQ ! 35 dmte1
473 .long do_IRQ ! 36 dmte2
474 .long do_IRQ ! 37 dmte3
475 .long do_IRQ ! 38 dmae
476 .long exception_error ! 39 /* 6E0 */
477 .long do_IRQ ! 40 SCIF-ch0 eri /* 700 */
478 .long do_IRQ ! 41 rxi
479 .long do_IRQ ! 42 bri
480 .long do_IRQ ! 43 txi
481 .long do_IRQ ! 44 DMAC dmte4 /* 780 */
482 .long do_IRQ ! 45 dmte5
483 .long do_IRQ ! 46 dmte6
484 .long do_IRQ ! 47 dmte7 /* 7E0 */
485#if defined(CONFIG_SH_FPU)
486 .long do_fpu_state_restore ! 48 /* 800 */
487 .long do_fpu_state_restore ! 49 /* 820 */
488#else
489 .long exception_error
490 .long exception_error
491#endif
492 .long exception_error /* 840 */
493 .long exception_error
494 .long exception_error
495 .long exception_error
496 .long exception_error
497 .long exception_error
498 .long do_IRQ ! 56 CMT /* 900 */
499 .long exception_error
500 .long exception_error
501 .long exception_error
502 .long do_IRQ ! 60 HAC
503 .long exception_error
504 .long exception_error
505 .long exception_error
506 .long do_IRQ ! PCI serr /* A00 */
507 .long do_IRQ ! INTA
508 .long do_IRQ ! INTB
509 .long do_IRQ ! INTC
510 .long do_IRQ ! INTD
511 .long do_IRQ ! err
512 .long do_IRQ ! pwd3
513 .long do_IRQ ! pwd2
514 .long do_IRQ ! pwd1 /* B00 */
515 .long do_IRQ ! pwd0
516 .long exception_error
517 .long exception_error
518 .long do_IRQ ! SCIF-ch1 eri /* B80 */
519 .long do_IRQ ! rxi
520 .long do_IRQ ! bri
521 .long do_IRQ ! txi
522 .long do_IRQ ! SIOF /* C00 */
523 .long exception_error
524 .long exception_error
525 .long exception_error
526 .long do_IRQ ! HSPI /* C80 */
527 .long exception_error
528 .long exception_error
529 .long exception_error
530 .long do_IRQ ! MMCIF fatat /* D00 */
531 .long do_IRQ ! tran
532 .long do_IRQ ! err
533 .long do_IRQ ! frdy
534 .long do_IRQ ! DMAC dmint8 /* D80 */
535 .long do_IRQ ! dmint9
536 .long do_IRQ ! dmint10
537 .long do_IRQ ! dmint11
538 .long do_IRQ ! TMU-ch3 /* E00 */
539 .long do_IRQ ! TMU-ch4
540 .long do_IRQ ! TMU-ch5
541 .long exception_error
542 .long do_IRQ ! SSI
543 .long exception_error
544 .long exception_error
545 .long exception_error
546 .long do_IRQ ! FLCTL flste /* F00 */
547 .long do_IRQ ! fltend
548 .long do_IRQ ! fltrq0
549 .long do_IRQ ! fltrq1
550 .long do_IRQ ! GPIO gpioi0 /* F80 */
551 .long do_IRQ ! gpioi1
552 .long do_IRQ ! gpioi2
553 .long do_IRQ ! gpioi3
382#endif 554#endif
383 555
diff --git a/arch/sh/kernel/cpu/sh4/probe.c b/arch/sh/kernel/cpu/sh4/probe.c
index 42427b79697b..c294de1e14a3 100644
--- a/arch/sh/kernel/cpu/sh4/probe.c
+++ b/arch/sh/kernel/cpu/sh4/probe.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * CPU Subtype Probing for SH-4. 4 * CPU Subtype Probing for SH-4.
5 * 5 *
6 * Copyright (C) 2001, 2002, 2003, 2004 Paul Mundt 6 * Copyright (C) 2001 - 2006 Paul Mundt
7 * Copyright (C) 2003 Richard Curnow 7 * Copyright (C) 2003 Richard Curnow
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
@@ -29,7 +29,7 @@ int __init detect_cpu_and_cache_system(void)
29 [9] = (1 << 16) 29 [9] = (1 << 16)
30 }; 30 };
31 31
32 pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffff; 32 pvr = (ctrl_inl(CCN_PVR) >> 8) & 0xffffff;
33 prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff; 33 prr = (ctrl_inl(CCN_PRR) >> 4) & 0xff;
34 cvr = (ctrl_inl(CCN_CVR)); 34 cvr = (ctrl_inl(CCN_CVR));
35 35
@@ -38,7 +38,6 @@ int __init detect_cpu_and_cache_system(void)
38 */ 38 */
39 cpu_data->icache.way_incr = (1 << 13); 39 cpu_data->icache.way_incr = (1 << 13);
40 cpu_data->icache.entry_shift = 5; 40 cpu_data->icache.entry_shift = 5;
41 cpu_data->icache.entry_mask = 0x1fe0;
42 cpu_data->icache.sets = 256; 41 cpu_data->icache.sets = 256;
43 cpu_data->icache.ways = 1; 42 cpu_data->icache.ways = 1;
44 cpu_data->icache.linesz = L1_CACHE_BYTES; 43 cpu_data->icache.linesz = L1_CACHE_BYTES;
@@ -48,13 +47,29 @@ int __init detect_cpu_and_cache_system(void)
48 */ 47 */
49 cpu_data->dcache.way_incr = (1 << 14); 48 cpu_data->dcache.way_incr = (1 << 14);
50 cpu_data->dcache.entry_shift = 5; 49 cpu_data->dcache.entry_shift = 5;
51 cpu_data->dcache.entry_mask = 0x3fe0;
52 cpu_data->dcache.sets = 512; 50 cpu_data->dcache.sets = 512;
53 cpu_data->dcache.ways = 1; 51 cpu_data->dcache.ways = 1;
54 cpu_data->dcache.linesz = L1_CACHE_BYTES; 52 cpu_data->dcache.linesz = L1_CACHE_BYTES;
55 53
56 /* Set the FPU flag, virtually all SH-4's have one */ 54 /*
57 cpu_data->flags |= CPU_HAS_FPU; 55 * Setup some generic flags we can probe
56 * (L2 and DSP detection only work on SH-4A)
57 */
58 if (((pvr >> 16) & 0xff) == 0x10) {
59 if ((cvr & 0x02000000) == 0)
60 cpu_data->flags |= CPU_HAS_L2_CACHE;
61 if ((cvr & 0x10000000) == 0)
62 cpu_data->flags |= CPU_HAS_DSP;
63
64 cpu_data->flags |= CPU_HAS_LLSC;
65 }
66
67 /* FPU detection works for everyone */
68 if ((cvr & 0x20000000) == 1)
69 cpu_data->flags |= CPU_HAS_FPU;
70
71 /* Mask off the upper chip ID */
72 pvr &= 0xffff;
58 73
59 /* 74 /*
60 * Probe the underlying processor version/revision and 75 * Probe the underlying processor version/revision and
@@ -63,56 +78,101 @@ int __init detect_cpu_and_cache_system(void)
63 switch (pvr) { 78 switch (pvr) {
64 case 0x205: 79 case 0x205:
65 cpu_data->type = CPU_SH7750; 80 cpu_data->type = CPU_SH7750;
66 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_PERF_COUNTER; 81 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
82 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA;
67 break; 83 break;
68 case 0x206: 84 case 0x206:
69 cpu_data->type = CPU_SH7750S; 85 cpu_data->type = CPU_SH7750S;
70 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_PERF_COUNTER; 86 cpu_data->flags |= CPU_HAS_P2_FLUSH_BUG | CPU_HAS_FPU |
87 CPU_HAS_PERF_COUNTER | CPU_HAS_PTEA;
71 break; 88 break;
72 case 0x1100: 89 case 0x1100:
73 cpu_data->type = CPU_SH7751; 90 cpu_data->type = CPU_SH7751;
91 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA;
74 break; 92 break;
75 case 0x2000: 93 case 0x2000:
76 cpu_data->type = CPU_SH73180; 94 cpu_data->type = CPU_SH73180;
77 cpu_data->icache.ways = 4; 95 cpu_data->icache.ways = 4;
78 cpu_data->dcache.ways = 4; 96 cpu_data->dcache.ways = 4;
79 cpu_data->flags &= ~CPU_HAS_FPU; 97 cpu_data->flags |= CPU_HAS_LLSC;
98 break;
99 case 0x2001:
100 case 0x2004:
101 cpu_data->type = CPU_SH7770;
102 cpu_data->icache.ways = 4;
103 cpu_data->dcache.ways = 4;
104
105 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_LLSC;
106 break;
107 case 0x2006:
108 case 0x200A:
109 if (prr == 0x61)
110 cpu_data->type = CPU_SH7781;
111 else
112 cpu_data->type = CPU_SH7780;
113
114 cpu_data->icache.ways = 4;
115 cpu_data->dcache.ways = 4;
116
117 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PERF_COUNTER |
118 CPU_HAS_LLSC;
119 break;
120 case 0x3000:
121 case 0x3003:
122 cpu_data->type = CPU_SH7343;
123 cpu_data->icache.ways = 4;
124 cpu_data->dcache.ways = 4;
125 cpu_data->flags |= CPU_HAS_LLSC;
80 break; 126 break;
81 case 0x8000: 127 case 0x8000:
82 cpu_data->type = CPU_ST40RA; 128 cpu_data->type = CPU_ST40RA;
129 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA;
83 break; 130 break;
84 case 0x8100: 131 case 0x8100:
85 cpu_data->type = CPU_ST40GX1; 132 cpu_data->type = CPU_ST40GX1;
133 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA;
86 break; 134 break;
87 case 0x700: 135 case 0x700:
88 cpu_data->type = CPU_SH4_501; 136 cpu_data->type = CPU_SH4_501;
89 cpu_data->icache.ways = 2; 137 cpu_data->icache.ways = 2;
90 cpu_data->dcache.ways = 2; 138 cpu_data->dcache.ways = 2;
91 139 cpu_data->flags |= CPU_HAS_PTEA;
92 /* No FPU on the SH4-500 series.. */
93 cpu_data->flags &= ~CPU_HAS_FPU;
94 break; 140 break;
95 case 0x600: 141 case 0x600:
96 cpu_data->type = CPU_SH4_202; 142 cpu_data->type = CPU_SH4_202;
97 cpu_data->icache.ways = 2; 143 cpu_data->icache.ways = 2;
98 cpu_data->dcache.ways = 2; 144 cpu_data->dcache.ways = 2;
145 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA;
99 break; 146 break;
100 case 0x500 ... 0x501: 147 case 0x500 ... 0x501:
101 switch (prr) { 148 switch (prr) {
102 case 0x10: cpu_data->type = CPU_SH7750R; break; 149 case 0x10:
103 case 0x11: cpu_data->type = CPU_SH7751R; break; 150 cpu_data->type = CPU_SH7750R;
104 case 0x50: cpu_data->type = CPU_SH7760; break; 151 break;
152 case 0x11:
153 cpu_data->type = CPU_SH7751R;
154 break;
155 case 0x50 ... 0x5f:
156 cpu_data->type = CPU_SH7760;
157 break;
105 } 158 }
106 159
107 cpu_data->icache.ways = 2; 160 cpu_data->icache.ways = 2;
108 cpu_data->dcache.ways = 2; 161 cpu_data->dcache.ways = 2;
109 162
163 cpu_data->flags |= CPU_HAS_FPU | CPU_HAS_PTEA;
164
110 break; 165 break;
111 default: 166 default:
112 cpu_data->type = CPU_SH_NONE; 167 cpu_data->type = CPU_SH_NONE;
113 break; 168 break;
114 } 169 }
115 170
171#ifdef CONFIG_SH_DIRECT_MAPPED
172 cpu_data->icache.ways = 1;
173 cpu_data->dcache.ways = 1;
174#endif
175
116 /* 176 /*
117 * On anything that's not a direct-mapped cache, look to the CVR 177 * On anything that's not a direct-mapped cache, look to the CVR
118 * for I/D-cache specifics. 178 * for I/D-cache specifics.
@@ -121,18 +181,56 @@ int __init detect_cpu_and_cache_system(void)
121 size = sizes[(cvr >> 20) & 0xf]; 181 size = sizes[(cvr >> 20) & 0xf];
122 cpu_data->icache.way_incr = (size >> 1); 182 cpu_data->icache.way_incr = (size >> 1);
123 cpu_data->icache.sets = (size >> 6); 183 cpu_data->icache.sets = (size >> 6);
124 cpu_data->icache.entry_mask = 184
125 (cpu_data->icache.way_incr - (1 << 5));
126 } 185 }
127 186
187 /* Setup the rest of the I-cache info */
188 cpu_data->icache.entry_mask = cpu_data->icache.way_incr -
189 cpu_data->icache.linesz;
190
191 cpu_data->icache.way_size = cpu_data->icache.sets *
192 cpu_data->icache.linesz;
193
194 /* And the rest of the D-cache */
128 if (cpu_data->dcache.ways > 1) { 195 if (cpu_data->dcache.ways > 1) {
129 size = sizes[(cvr >> 16) & 0xf]; 196 size = sizes[(cvr >> 16) & 0xf];
130 cpu_data->dcache.way_incr = (size >> 1); 197 cpu_data->dcache.way_incr = (size >> 1);
131 cpu_data->dcache.sets = (size >> 6); 198 cpu_data->dcache.sets = (size >> 6);
132 cpu_data->dcache.entry_mask = 199 }
133 (cpu_data->dcache.way_incr - (1 << 5)); 200
201 cpu_data->dcache.entry_mask = cpu_data->dcache.way_incr -
202 cpu_data->dcache.linesz;
203
204 cpu_data->dcache.way_size = cpu_data->dcache.sets *
205 cpu_data->dcache.linesz;
206
207 /*
208 * Setup the L2 cache desc
209 *
210 * SH-4A's have an optional PIPT L2.
211 */
212 if (cpu_data->flags & CPU_HAS_L2_CACHE) {
213 /*
214 * Size calculation is much more sensible
215 * than it is for the L1.
216 *
217 * Sizes are 128KB, 258KB, 512KB, and 1MB.
218 */
219 size = (cvr & 0xf) << 17;
220
221 BUG_ON(!size);
222
223 cpu_data->scache.way_incr = (1 << 16);
224 cpu_data->scache.entry_shift = 5;
225 cpu_data->scache.ways = 4;
226 cpu_data->scache.linesz = L1_CACHE_BYTES;
227 cpu_data->scache.entry_mask =
228 (cpu_data->scache.way_incr - cpu_data->scache.linesz);
229 cpu_data->scache.sets = size /
230 (cpu_data->scache.linesz * cpu_data->scache.ways);
231 cpu_data->scache.way_size =
232 (cpu_data->scache.sets * cpu_data->scache.linesz);
134 } 233 }
135 234
136 return 0; 235 return 0;
137} 236}
138
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
new file mode 100644
index 000000000000..6e4e96541358
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
@@ -0,0 +1,43 @@
1/*
2 * SH4-202 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xffe80000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 40, 41, 43, 42 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh4202_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh4202_devices_setup(void)
39{
40 return platform_add_devices(sh4202_devices,
41 ARRAY_SIZE(sh4202_devices));
42}
43__initcall(sh4202_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh73180.c b/arch/sh/kernel/cpu/sh4/setup-sh73180.c
new file mode 100644
index 000000000000..cc9ea1e2e5df
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh73180.c
@@ -0,0 +1,43 @@
1/*
2 * SH73180 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xffe80000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 80, 81, 83, 82 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh73180_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh73180_devices_setup(void)
39{
40 return platform_add_devices(sh73180_devices,
41 ARRAY_SIZE(sh73180_devices));
42}
43__initcall(sh73180_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7343.c b/arch/sh/kernel/cpu/sh4/setup-sh7343.c
new file mode 100644
index 000000000000..91d61cf91ba1
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7343.c
@@ -0,0 +1,43 @@
1/*
2 * SH7343 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xffe00000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 80, 81, 83, 82 },
21 }, {
22 .flags = 0,
23 }
24};
25
26static struct platform_device sci_device = {
27 .name = "sh-sci",
28 .id = -1,
29 .dev = {
30 .platform_data = sci_platform_data,
31 },
32};
33
34static struct platform_device *sh7343_devices[] __initdata = {
35 &sci_device,
36};
37
38static int __init sh7343_devices_setup(void)
39{
40 return platform_add_devices(sh7343_devices,
41 ARRAY_SIZE(sh7343_devices));
42}
43__initcall(sh7343_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
new file mode 100644
index 000000000000..50812d57c1c1
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -0,0 +1,48 @@
1/*
2 * SH7750/SH7751 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xffe00000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCI,
20 .irqs = { 23, 24, 25, 0 },
21 }, {
22 .mapbase = 0xffe80000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 40, 41, 43, 42 },
26 }, {
27 .flags = 0,
28 }
29};
30
31static struct platform_device sci_device = {
32 .name = "sh-sci",
33 .id = -1,
34 .dev = {
35 .platform_data = sci_platform_data,
36 },
37};
38
39static struct platform_device *sh7750_devices[] __initdata = {
40 &sci_device,
41};
42
43static int __init sh7750_devices_setup(void)
44{
45 return platform_add_devices(sh7750_devices,
46 ARRAY_SIZE(sh7750_devices));
47}
48__initcall(sh7750_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
new file mode 100644
index 000000000000..97f1c9af35d6
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
@@ -0,0 +1,53 @@
1/*
2 * SH7760 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xfe600000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 52, 53, 55, 54 },
21 }, {
22 .mapbase = 0xfe610000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 72, 73, 75, 74 },
26 }, {
27 .mapbase = 0xfe620000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 76, 77, 79, 78 },
31 }, {
32 .flags = 0,
33 }
34};
35
36static struct platform_device sci_device = {
37 .name = "sh-sci",
38 .id = -1,
39 .dev = {
40 .platform_data = sci_platform_data,
41 },
42};
43
44static struct platform_device *sh7760_devices[] __initdata = {
45 &sci_device,
46};
47
48static int __init sh7760_devices_setup(void)
49{
50 return platform_add_devices(sh7760_devices,
51 ARRAY_SIZE(sh7760_devices));
52}
53__initcall(sh7760_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7770.c b/arch/sh/kernel/cpu/sh4/setup-sh7770.c
new file mode 100644
index 000000000000..6a04cc5f5aca
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7770.c
@@ -0,0 +1,53 @@
1/*
2 * SH7770 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct plat_sci_port sci_platform_data[] = {
16 {
17 .mapbase = 0xff923000,
18 .flags = UPF_BOOT_AUTOCONF,
19 .type = PORT_SCIF,
20 .irqs = { 61, 61, 61, 61 },
21 }, {
22 .mapbase = 0xff924000,
23 .flags = UPF_BOOT_AUTOCONF,
24 .type = PORT_SCIF,
25 .irqs = { 62, 62, 62, 62 },
26 }, {
27 .mapbase = 0xff925000,
28 .flags = UPF_BOOT_AUTOCONF,
29 .type = PORT_SCIF,
30 .irqs = { 63, 63, 63, 63 },
31 }, {
32 .flags = 0,
33 }
34};
35
36static struct platform_device sci_device = {
37 .name = "sh-sci",
38 .id = -1,
39 .dev = {
40 .platform_data = sci_platform_data,
41 },
42};
43
44static struct platform_device *sh7770_devices[] __initdata = {
45 &sci_device,
46};
47
48static int __init sh7770_devices_setup(void)
49{
50 return platform_add_devices(sh7770_devices,
51 ARRAY_SIZE(sh7770_devices));
52}
53__initcall(sh7770_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7780.c b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
new file mode 100644
index 000000000000..72493f259edc
--- /dev/null
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7780.c
@@ -0,0 +1,79 @@
1/*
2 * SH7780 Setup
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/platform_device.h>
11#include <linux/init.h>
12#include <linux/serial.h>
13#include <asm/sci.h>
14
15static struct resource rtc_resources[] = {
16 [0] = {
17 .start = 0xffe80000,
18 .end = 0xffe80000 + 0x58 - 1,
19 .flags = IORESOURCE_IO,
20 },
21 [1] = {
22 /* Period IRQ */
23 .start = 21,
24 .flags = IORESOURCE_IRQ,
25 },
26 [2] = {
27 /* Carry IRQ */
28 .start = 22,
29 .flags = IORESOURCE_IRQ,
30 },
31 [3] = {
32 /* Alarm IRQ */
33 .start = 23,
34 .flags = IORESOURCE_IRQ,
35 },
36};
37
38static struct platform_device rtc_device = {
39 .name = "sh-rtc",
40 .id = -1,
41 .num_resources = ARRAY_SIZE(rtc_resources),
42 .resource = rtc_resources,
43};
44
45static struct plat_sci_port sci_platform_data[] = {
46 {
47 .mapbase = 0xffe00000,
48 .flags = UPF_BOOT_AUTOCONF,
49 .type = PORT_SCIF,
50 .irqs = { 40, 41, 43, 42 },
51 }, {
52 .mapbase = 0xffe10000,
53 .flags = UPF_BOOT_AUTOCONF,
54 .type = PORT_SCIF,
55 .irqs = { 76, 77, 79, 78 },
56 }, {
57 .flags = 0,
58 }
59};
60
61static struct platform_device sci_device = {
62 .name = "sh-sci",
63 .id = -1,
64 .dev = {
65 .platform_data = sci_platform_data,
66 },
67};
68
69static struct platform_device *sh7780_devices[] __initdata = {
70 &rtc_device,
71 &sci_device,
72};
73
74static int __init sh7780_devices_setup(void)
75{
76 return platform_add_devices(sh7780_devices,
77 ARRAY_SIZE(sh7780_devices));
78}
79__initcall(sh7780_devices_setup);
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c
index b09805f3ee23..7bcc73f9b8df 100644
--- a/arch/sh/kernel/cpu/sh4/sq.c
+++ b/arch/sh/kernel/cpu/sh4/sq.c
@@ -1,49 +1,52 @@
1/* 1/*
2 * arch/sh/kernel/cpu/sq.c 2 * arch/sh/kernel/cpu/sh4/sq.c
3 * 3 *
4 * General management API for SH-4 integrated Store Queues 4 * General management API for SH-4 integrated Store Queues
5 * 5 *
6 * Copyright (C) 2001, 2002, 2003, 2004 Paul Mundt 6 * Copyright (C) 2001 - 2006 Paul Mundt
7 * Copyright (C) 2001, 2002 M. R. Brown 7 * Copyright (C) 2001, 2002 M. R. Brown
8 * 8 *
9 * Some of this code has been adopted directly from the old arch/sh/mm/sq.c
10 * hack that was part of the LinuxDC project. For all intents and purposes,
11 * this is a completely new interface that really doesn't have much in common
12 * with the old zone-based approach at all. In fact, it's only listed here for
13 * general completeness.
14 *
15 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive 10 * License. See the file "COPYING" in the main directory of this archive
17 * for more details. 11 * for more details.
18 */ 12 */
19#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/cpu.h>
15#include <linux/bitmap.h>
16#include <linux/sysdev.h>
20#include <linux/kernel.h> 17#include <linux/kernel.h>
21#include <linux/module.h> 18#include <linux/module.h>
22#include <linux/slab.h> 19#include <linux/slab.h>
23#include <linux/list.h>
24#include <linux/proc_fs.h>
25#include <linux/miscdevice.h>
26#include <linux/vmalloc.h> 20#include <linux/vmalloc.h>
27 21#include <linux/mm.h>
28#include <asm/io.h> 22#include <asm/io.h>
29#include <asm/page.h> 23#include <asm/page.h>
30#include <asm/mmu_context.h> 24#include <asm/cacheflush.h>
31#include <asm/cpu/sq.h> 25#include <asm/cpu/sq.h>
32 26
33static LIST_HEAD(sq_mapping_list); 27struct sq_mapping;
28
29struct sq_mapping {
30 const char *name;
31
32 unsigned long sq_addr;
33 unsigned long addr;
34 unsigned int size;
35
36 struct sq_mapping *next;
37};
38
39static struct sq_mapping *sq_mapping_list;
34static DEFINE_SPINLOCK(sq_mapping_lock); 40static DEFINE_SPINLOCK(sq_mapping_lock);
41static kmem_cache_t *sq_cache;
42static unsigned long *sq_bitmap;
35 43
36/** 44#define store_queue_barrier() \
37 * sq_flush - Flush (prefetch) the store queue cache 45do { \
38 * @addr: the store queue address to flush 46 (void)ctrl_inl(P4SEG_STORE_QUE); \
39 * 47 ctrl_outl(0, P4SEG_STORE_QUE + 0); \
40 * Executes a prefetch instruction on the specified store queue cache, 48 ctrl_outl(0, P4SEG_STORE_QUE + 8); \
41 * so that the cached data is written to physical memory. 49} while (0);
42 */
43inline void sq_flush(void *addr)
44{
45 __asm__ __volatile__ ("pref @%0" : : "r" (addr) : "memory");
46}
47 50
48/** 51/**
49 * sq_flush_range - Flush (prefetch) a specific SQ range 52 * sq_flush_range - Flush (prefetch) a specific SQ range
@@ -56,152 +59,73 @@ inline void sq_flush(void *addr)
56void sq_flush_range(unsigned long start, unsigned int len) 59void sq_flush_range(unsigned long start, unsigned int len)
57{ 60{
58 volatile unsigned long *sq = (unsigned long *)start; 61 volatile unsigned long *sq = (unsigned long *)start;
59 unsigned long dummy;
60 62
61 /* Flush the queues */ 63 /* Flush the queues */
62 for (len >>= 5; len--; sq += 8) 64 for (len >>= 5; len--; sq += 8)
63 sq_flush((void *)sq); 65 prefetchw((void *)sq);
64 66
65 /* Wait for completion */ 67 /* Wait for completion */
66 dummy = ctrl_inl(P4SEG_STORE_QUE); 68 store_queue_barrier();
67
68 ctrl_outl(0, P4SEG_STORE_QUE + 0);
69 ctrl_outl(0, P4SEG_STORE_QUE + 8);
70} 69}
71 70
72static struct sq_mapping *__sq_alloc_mapping(unsigned long virt, unsigned long phys, unsigned long size, const char *name) 71static inline void sq_mapping_list_add(struct sq_mapping *map)
73{ 72{
74 struct sq_mapping *map; 73 struct sq_mapping **p, *tmp;
75
76 if (virt + size > SQ_ADDRMAX)
77 return ERR_PTR(-ENOSPC);
78
79 map = kmalloc(sizeof(struct sq_mapping), GFP_KERNEL);
80 if (!map)
81 return ERR_PTR(-ENOMEM);
82 74
83 INIT_LIST_HEAD(&map->list); 75 spin_lock_irq(&sq_mapping_lock);
84 76
85 map->sq_addr = virt; 77 p = &sq_mapping_list;
86 map->addr = phys; 78 while ((tmp = *p) != NULL)
87 map->size = size + 1; 79 p = &tmp->next;
88 map->name = name;
89 80
90 list_add(&map->list, &sq_mapping_list); 81 map->next = tmp;
82 *p = map;
91 83
92 return map; 84 spin_unlock_irq(&sq_mapping_lock);
93} 85}
94 86
95static unsigned long __sq_get_next_addr(void) 87static inline void sq_mapping_list_del(struct sq_mapping *map)
96{ 88{
97 if (!list_empty(&sq_mapping_list)) { 89 struct sq_mapping **p, *tmp;
98 struct list_head *pos, *tmp; 90
99 91 spin_lock_irq(&sq_mapping_lock);
100 /* 92
101 * Read one off the list head, as it will have the highest 93 for (p = &sq_mapping_list; (tmp = *p); p = &tmp->next)
102 * mapped allocation. Set the next one up right above it. 94 if (tmp == map) {
103 * 95 *p = tmp->next;
104 * This is somewhat sub-optimal, as we don't look at 96 break;
105 * gaps between allocations or anything lower then the
106 * highest-level allocation.
107 *
108 * However, in the interest of performance and the general
109 * lack of desire to do constant list rebalancing, we don't
110 * worry about it.
111 */
112 list_for_each_safe(pos, tmp, &sq_mapping_list) {
113 struct sq_mapping *entry;
114
115 entry = list_entry(pos, typeof(*entry), list);
116
117 return entry->sq_addr + entry->size;
118 } 97 }
119 }
120 98
121 return P4SEG_STORE_QUE; 99 spin_unlock_irq(&sq_mapping_lock);
122} 100}
123 101
124/** 102static int __sq_remap(struct sq_mapping *map, unsigned long flags)
125 * __sq_remap - Perform a translation from the SQ to a phys addr
126 * @map: sq mapping containing phys and store queue addresses.
127 *
128 * Maps the store queue address specified in the mapping to the physical
129 * address specified in the mapping.
130 */
131static struct sq_mapping *__sq_remap(struct sq_mapping *map)
132{ 103{
133 unsigned long flags, pteh, ptel; 104#if defined(CONFIG_MMU)
134 struct vm_struct *vma; 105 struct vm_struct *vma;
135 pgprot_t pgprot;
136
137 /*
138 * Without an MMU (or with it turned off), this is much more
139 * straightforward, as we can just load up each queue's QACR with
140 * the physical address appropriately masked.
141 */
142
143 ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR0);
144 ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR1);
145 106
146#ifdef CONFIG_MMU
147 /*
148 * With an MMU on the other hand, things are slightly more involved.
149 * Namely, we have to have a direct mapping between the SQ addr and
150 * the associated physical address in the UTLB by way of setting up
151 * a virt<->phys translation by hand. We do this by simply specifying
152 * the SQ addr in UTLB.VPN and the associated physical address in
153 * UTLB.PPN.
154 *
155 * Notably, even though this is a special case translation, and some
156 * of the configuration bits are meaningless, we're still required
157 * to have a valid ASID context in PTEH.
158 *
159 * We could also probably get by without explicitly setting PTEA, but
160 * we do it here just for good measure.
161 */
162 spin_lock_irqsave(&sq_mapping_lock, flags);
163
164 pteh = map->sq_addr;
165 ctrl_outl((pteh & MMU_VPN_MASK) | get_asid(), MMU_PTEH);
166
167 ptel = map->addr & PAGE_MASK;
168 ctrl_outl(((ptel >> 28) & 0xe) | (ptel & 0x1), MMU_PTEA);
169
170 pgprot = pgprot_noncached(PAGE_KERNEL);
171
172 ptel &= _PAGE_FLAGS_HARDWARE_MASK;
173 ptel |= pgprot_val(pgprot);
174 ctrl_outl(ptel, MMU_PTEL);
175
176 __asm__ __volatile__ ("ldtlb" : : : "memory");
177
178 spin_unlock_irqrestore(&sq_mapping_lock, flags);
179
180 /*
181 * Next, we need to map ourselves in the kernel page table, so that
182 * future accesses after a TLB flush will be handled when we take a
183 * page fault.
184 *
185 * Theoretically we could just do this directly and not worry about
186 * setting up the translation by hand ahead of time, but for the
187 * cases where we want a one-shot SQ mapping followed by a quick
188 * writeout before we hit the TLB flush, we do it anyways. This way
189 * we at least save ourselves the initial page fault overhead.
190 */
191 vma = __get_vm_area(map->size, VM_ALLOC, map->sq_addr, SQ_ADDRMAX); 107 vma = __get_vm_area(map->size, VM_ALLOC, map->sq_addr, SQ_ADDRMAX);
192 if (!vma) 108 if (!vma)
193 return ERR_PTR(-ENOMEM); 109 return -ENOMEM;
194 110
195 vma->phys_addr = map->addr; 111 vma->phys_addr = map->addr;
196 112
197 if (remap_area_pages((unsigned long)vma->addr, vma->phys_addr, 113 if (remap_area_pages((unsigned long)vma->addr, vma->phys_addr,
198 map->size, pgprot_val(pgprot))) { 114 map->size, flags)) {
199 vunmap(vma->addr); 115 vunmap(vma->addr);
200 return NULL; 116 return -EAGAIN;
201 } 117 }
202#endif /* CONFIG_MMU */ 118#else
119 /*
120 * Without an MMU (or with it turned off), this is much more
121 * straightforward, as we can just load up each queue's QACR with
122 * the physical address appropriately masked.
123 */
124 ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR0);
125 ctrl_outl(((map->addr >> 26) << 2) & 0x1c, SQ_QACR1);
126#endif
203 127
204 return map; 128 return 0;
205} 129}
206 130
207/** 131/**
@@ -209,42 +133,65 @@ static struct sq_mapping *__sq_remap(struct sq_mapping *map)
209 * @phys: Physical address of mapping. 133 * @phys: Physical address of mapping.
210 * @size: Length of mapping. 134 * @size: Length of mapping.
211 * @name: User invoking mapping. 135 * @name: User invoking mapping.
136 * @flags: Protection flags.
212 * 137 *
213 * Remaps the physical address @phys through the next available store queue 138 * Remaps the physical address @phys through the next available store queue
214 * address of @size length. @name is logged at boot time as well as through 139 * address of @size length. @name is logged at boot time as well as through
215 * the procfs interface. 140 * the sysfs interface.
216 *
217 * A pre-allocated and filled sq_mapping pointer is returned, and must be
218 * cleaned up with a call to sq_unmap() when the user is done with the
219 * mapping.
220 */ 141 */
221struct sq_mapping *sq_remap(unsigned long phys, unsigned int size, const char *name) 142unsigned long sq_remap(unsigned long phys, unsigned int size,
143 const char *name, unsigned long flags)
222{ 144{
223 struct sq_mapping *map; 145 struct sq_mapping *map;
224 unsigned long virt, end; 146 unsigned long end;
225 unsigned int psz; 147 unsigned int psz;
148 int ret, page;
226 149
227 /* Don't allow wraparound or zero size */ 150 /* Don't allow wraparound or zero size */
228 end = phys + size - 1; 151 end = phys + size - 1;
229 if (!size || end < phys) 152 if (unlikely(!size || end < phys))
230 return NULL; 153 return -EINVAL;
231 /* Don't allow anyone to remap normal memory.. */ 154 /* Don't allow anyone to remap normal memory.. */
232 if (phys < virt_to_phys(high_memory)) 155 if (unlikely(phys < virt_to_phys(high_memory)))
233 return NULL; 156 return -EINVAL;
234 157
235 phys &= PAGE_MASK; 158 phys &= PAGE_MASK;
159 size = PAGE_ALIGN(end + 1) - phys;
160
161 map = kmem_cache_alloc(sq_cache, GFP_KERNEL);
162 if (unlikely(!map))
163 return -ENOMEM;
164
165 map->addr = phys;
166 map->size = size;
167 map->name = name;
168
169 page = bitmap_find_free_region(sq_bitmap, 0x04000000,
170 get_order(map->size));
171 if (unlikely(page < 0)) {
172 ret = -ENOSPC;
173 goto out;
174 }
175
176 map->sq_addr = P4SEG_STORE_QUE + (page << PAGE_SHIFT);
177
178 ret = __sq_remap(map, flags);
179 if (unlikely(ret != 0))
180 goto out;
181
182 psz = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
183 pr_info("sqremap: %15s [%4d page%s] va 0x%08lx pa 0x%08lx\n",
184 likely(map->name) ? map->name : "???",
185 psz, psz == 1 ? " " : "s",
186 map->sq_addr, map->addr);
236 187
237 size = PAGE_ALIGN(end + 1) - phys; 188 sq_mapping_list_add(map);
238 virt = __sq_get_next_addr();
239 psz = (size + (PAGE_SIZE - 1)) / PAGE_SIZE;
240 map = __sq_alloc_mapping(virt, phys, size, name);
241 189
242 printk("sqremap: %15s [%4d page%s] va 0x%08lx pa 0x%08lx\n", 190 return map->sq_addr;
243 map->name ? map->name : "???",
244 psz, psz == 1 ? " " : "s",
245 map->sq_addr, map->addr);
246 191
247 return __sq_remap(map); 192out:
193 kmem_cache_free(sq_cache, map);
194 return ret;
248} 195}
249 196
250/** 197/**
@@ -255,188 +202,198 @@ struct sq_mapping *sq_remap(unsigned long phys, unsigned int size, const char *n
255 * sq_remap(). Also frees up the pte that was previously inserted into 202 * sq_remap(). Also frees up the pte that was previously inserted into
256 * the kernel page table and discards the UTLB translation. 203 * the kernel page table and discards the UTLB translation.
257 */ 204 */
258void sq_unmap(struct sq_mapping *map) 205void sq_unmap(unsigned long vaddr)
259{ 206{
260 if (map->sq_addr > (unsigned long)high_memory) 207 struct sq_mapping **p, *map;
261 vfree((void *)(map->sq_addr & PAGE_MASK)); 208 struct vm_struct *vma;
209 int page;
262 210
263 list_del(&map->list); 211 for (p = &sq_mapping_list; (map = *p); p = &map->next)
264 kfree(map); 212 if (map->sq_addr == vaddr)
265} 213 break;
266 214
267/** 215 if (unlikely(!map)) {
268 * sq_clear - Clear a store queue range 216 printk("%s: bad store queue address 0x%08lx\n",
269 * @addr: Address to start clearing from. 217 __FUNCTION__, vaddr);
270 * @len: Length to clear. 218 return;
271 * 219 }
272 * A quick zero-fill implementation for clearing out memory that has been
273 * remapped through the store queues.
274 */
275void sq_clear(unsigned long addr, unsigned int len)
276{
277 int i;
278 220
279 /* Clear out both queues linearly */ 221 page = (map->sq_addr - P4SEG_STORE_QUE) >> PAGE_SHIFT;
280 for (i = 0; i < 8; i++) { 222 bitmap_release_region(sq_bitmap, page, get_order(map->size));
281 ctrl_outl(0, addr + i + 0); 223
282 ctrl_outl(0, addr + i + 8); 224#ifdef CONFIG_MMU
225 vma = remove_vm_area((void *)(map->sq_addr & PAGE_MASK));
226 if (!vma) {
227 printk(KERN_ERR "%s: bad address 0x%08lx\n",
228 __FUNCTION__, map->sq_addr);
229 return;
283 } 230 }
231#endif
232
233 sq_mapping_list_del(map);
284 234
285 sq_flush_range(addr, len); 235 kmem_cache_free(sq_cache, map);
286} 236}
287 237
288/** 238/*
289 * sq_vma_unmap - Unmap a VMA range 239 * Needlessly complex sysfs interface. Unfortunately it doesn't seem like
290 * @area: VMA containing range. 240 * there is any other easy way to add things on a per-cpu basis without
291 * @addr: Start of range. 241 * putting the directory entries somewhere stupid and having to create
292 * @len: Length of range. 242 * links in sysfs by hand back in to the per-cpu directories.
293 * 243 *
294 * Searches the sq_mapping_list for a mapping matching the sq addr @addr, 244 * Some day we may want to have an additional abstraction per store
295 * and subsequently frees up the entry. Further cleanup is done by generic 245 * queue, but considering the kobject hell we already have to deal with,
296 * code. 246 * it's simply not worth the trouble.
297 */ 247 */
298static void sq_vma_unmap(struct vm_area_struct *area, 248static struct kobject *sq_kobject[NR_CPUS];
299 unsigned long addr, size_t len)
300{
301 struct list_head *pos, *tmp;
302 249
303 list_for_each_safe(pos, tmp, &sq_mapping_list) { 250struct sq_sysfs_attr {
304 struct sq_mapping *entry; 251 struct attribute attr;
252 ssize_t (*show)(char *buf);
253 ssize_t (*store)(const char *buf, size_t count);
254};
305 255
306 entry = list_entry(pos, typeof(*entry), list); 256#define to_sq_sysfs_attr(attr) container_of(attr, struct sq_sysfs_attr, attr)
307 257
308 if (entry->sq_addr == addr) { 258static ssize_t sq_sysfs_show(struct kobject *kobj, struct attribute *attr,
309 /* 259 char *buf)
310 * We could probably get away without doing the tlb flush 260{
311 * here, as generic code should take care of most of this 261 struct sq_sysfs_attr *sattr = to_sq_sysfs_attr(attr);
312 * when unmapping the rest of the VMA range for us. Leave
313 * it in for added sanity for the time being..
314 */
315 __flush_tlb_page(get_asid(), entry->sq_addr & PAGE_MASK);
316 262
317 list_del(&entry->list); 263 if (likely(sattr->show))
318 kfree(entry); 264 return sattr->show(buf);
319 265
320 return; 266 return -EIO;
321 }
322 }
323} 267}
324 268
325/** 269static ssize_t sq_sysfs_store(struct kobject *kobj, struct attribute *attr,
326 * sq_vma_sync - Sync a VMA range 270 const char *buf, size_t count)
327 * @area: VMA containing range.
328 * @start: Start of range.
329 * @len: Length of range.
330 * @flags: Additional flags.
331 *
332 * Synchronizes an sq mapped range by flushing the store queue cache for
333 * the duration of the mapping.
334 *
335 * Used internally for user mappings, which must use msync() to prefetch
336 * the store queue cache.
337 */
338static int sq_vma_sync(struct vm_area_struct *area,
339 unsigned long start, size_t len, unsigned int flags)
340{ 271{
341 sq_flush_range(start, len); 272 struct sq_sysfs_attr *sattr = to_sq_sysfs_attr(attr);
342 273
343 return 0; 274 if (likely(sattr->store))
275 return sattr->store(buf, count);
276
277 return -EIO;
344} 278}
345 279
346static struct vm_operations_struct sq_vma_ops = { 280static ssize_t mapping_show(char *buf)
347 .unmap = sq_vma_unmap, 281{
348 .sync = sq_vma_sync, 282 struct sq_mapping **list, *entry;
349}; 283 char *p = buf;
350 284
351/** 285 for (list = &sq_mapping_list; (entry = *list); list = &entry->next)
352 * sq_mmap - mmap() for /dev/cpu/sq 286 p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n",
353 * @file: unused. 287 entry->sq_addr, entry->sq_addr + entry->size,
354 * @vma: VMA to remap. 288 entry->addr, entry->name);
355 * 289
356 * Remap the specified vma @vma through the store queues, and setup associated 290 return p - buf;
357 * information for the new mapping. Also build up the page tables for the new 291}
358 * area. 292
359 */ 293static ssize_t mapping_store(const char *buf, size_t count)
360static int sq_mmap(struct file *file, struct vm_area_struct *vma)
361{ 294{
362 unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; 295 unsigned long base = 0, len = 0;
363 unsigned long size = vma->vm_end - vma->vm_start;
364 struct sq_mapping *map;
365 296
366 /* 297 sscanf(buf, "%lx %lx", &base, &len);
367 * We're not interested in any arbitrary virtual address that has 298 if (!base)
368 * been stuck in the VMA, as we already know what addresses we 299 return -EIO;
369 * want. Save off the size, and reposition the VMA to begin at
370 * the next available sq address.
371 */
372 vma->vm_start = __sq_get_next_addr();
373 vma->vm_end = vma->vm_start + size;
374 300
375 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 301 if (likely(len)) {
302 int ret = sq_remap(base, len, "Userspace",
303 pgprot_val(PAGE_SHARED));
304 if (ret < 0)
305 return ret;
306 } else
307 sq_unmap(base);
376 308
377 vma->vm_flags |= VM_IO | VM_RESERVED; 309 return count;
310}
378 311
379 map = __sq_alloc_mapping(vma->vm_start, offset, size, "Userspace"); 312static struct sq_sysfs_attr mapping_attr =
313 __ATTR(mapping, 0644, mapping_show, mapping_store);
380 314
381 if (io_remap_pfn_range(vma, map->sq_addr, map->addr >> PAGE_SHIFT, 315static struct attribute *sq_sysfs_attrs[] = {
382 size, vma->vm_page_prot)) 316 &mapping_attr.attr,
383 return -EAGAIN; 317 NULL,
318};
384 319
385 vma->vm_ops = &sq_vma_ops; 320static struct sysfs_ops sq_sysfs_ops = {
321 .show = sq_sysfs_show,
322 .store = sq_sysfs_store,
323};
386 324
387 return 0; 325static struct kobj_type ktype_percpu_entry = {
388} 326 .sysfs_ops = &sq_sysfs_ops,
327 .default_attrs = sq_sysfs_attrs,
328};
389 329
390#ifdef CONFIG_PROC_FS 330static int __devinit sq_sysdev_add(struct sys_device *sysdev)
391static int sq_mapping_read_proc(char *buf, char **start, off_t off,
392 int len, int *eof, void *data)
393{ 331{
394 struct list_head *pos; 332 unsigned int cpu = sysdev->id;
395 char *p = buf; 333 struct kobject *kobj;
396 334
397 list_for_each_prev(pos, &sq_mapping_list) { 335 sq_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL);
398 struct sq_mapping *entry; 336 if (unlikely(!sq_kobject[cpu]))
337 return -ENOMEM;
399 338
400 entry = list_entry(pos, typeof(*entry), list); 339 kobj = sq_kobject[cpu];
340 kobj->parent = &sysdev->kobj;
341 kobject_set_name(kobj, "%s", "sq");
342 kobj->ktype = &ktype_percpu_entry;
401 343
402 p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n", entry->sq_addr, 344 return kobject_register(kobj);
403 entry->sq_addr + entry->size - 1, entry->addr,
404 entry->name);
405 }
406
407 return p - buf;
408} 345}
409#endif
410 346
411static struct file_operations sq_fops = { 347static int __devexit sq_sysdev_remove(struct sys_device *sysdev)
412 .owner = THIS_MODULE, 348{
413 .mmap = sq_mmap, 349 unsigned int cpu = sysdev->id;
414}; 350 struct kobject *kobj = sq_kobject[cpu];
415 351
416static struct miscdevice sq_dev = { 352 kobject_unregister(kobj);
417 .minor = STORE_QUEUE_MINOR, 353 return 0;
418 .name = "sq", 354}
419 .fops = &sq_fops, 355
356static struct sysdev_driver sq_sysdev_driver = {
357 .add = sq_sysdev_add,
358 .remove = __devexit_p(sq_sysdev_remove),
420}; 359};
421 360
422static int __init sq_api_init(void) 361static int __init sq_api_init(void)
423{ 362{
424 int ret; 363 unsigned int nr_pages = 0x04000000 >> PAGE_SHIFT;
364 unsigned int size = (nr_pages + (BITS_PER_LONG - 1)) / BITS_PER_LONG;
365 int ret = -ENOMEM;
366
425 printk(KERN_NOTICE "sq: Registering store queue API.\n"); 367 printk(KERN_NOTICE "sq: Registering store queue API.\n");
426 368
427 create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0); 369 sq_cache = kmem_cache_create("store_queue_cache",
370 sizeof(struct sq_mapping), 0, 0,
371 NULL, NULL);
372 if (unlikely(!sq_cache))
373 return ret;
428 374
429 ret = misc_register(&sq_dev); 375 sq_bitmap = kzalloc(size, GFP_KERNEL);
430 if (ret) 376 if (unlikely(!sq_bitmap))
431 remove_proc_entry("sq_mapping", NULL); 377 goto out;
378
379 ret = sysdev_driver_register(&cpu_sysdev_class, &sq_sysdev_driver);
380 if (unlikely(ret != 0))
381 goto out;
382
383 return 0;
384
385out:
386 kfree(sq_bitmap);
387 kmem_cache_destroy(sq_cache);
432 388
433 return ret; 389 return ret;
434} 390}
435 391
436static void __exit sq_api_exit(void) 392static void __exit sq_api_exit(void)
437{ 393{
438 misc_deregister(&sq_dev); 394 sysdev_driver_unregister(&cpu_sysdev_class, &sq_sysdev_driver);
439 remove_proc_entry("sq_mapping", NULL); 395 kfree(sq_bitmap);
396 kmem_cache_destroy(sq_cache);
440} 397}
441 398
442module_init(sq_api_init); 399module_init(sq_api_init);
@@ -445,11 +402,7 @@ module_exit(sq_api_exit);
445MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>"); 402MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
446MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues"); 403MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");
447MODULE_LICENSE("GPL"); 404MODULE_LICENSE("GPL");
448MODULE_ALIAS_MISCDEV(STORE_QUEUE_MINOR);
449 405
450EXPORT_SYMBOL(sq_remap); 406EXPORT_SYMBOL(sq_remap);
451EXPORT_SYMBOL(sq_unmap); 407EXPORT_SYMBOL(sq_unmap);
452EXPORT_SYMBOL(sq_clear);
453EXPORT_SYMBOL(sq_flush);
454EXPORT_SYMBOL(sq_flush_range); 408EXPORT_SYMBOL(sq_flush_range);
455
diff --git a/arch/sh/kernel/early_printk.c b/arch/sh/kernel/early_printk.c
index 1378db375e17..a00022722e9e 100644
--- a/arch/sh/kernel/early_printk.c
+++ b/arch/sh/kernel/early_printk.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 1999, 2000 Niibe Yutaka 4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002 M. R. Brown 5 * Copyright (C) 2002 M. R. Brown
6 * Copyright (C) 2004 Paul Mundt 6 * Copyright (C) 2004 - 2006 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
@@ -49,7 +49,7 @@ static int __init sh_console_setup(struct console *co, char *options)
49 return 0; 49 return 0;
50} 50}
51 51
52static struct console early_console = { 52static struct console bios_console = {
53 .name = "bios", 53 .name = "bios",
54 .write = sh_console_write, 54 .write = sh_console_write,
55 .setup = sh_console_setup, 55 .setup = sh_console_setup,
@@ -59,34 +59,43 @@ static struct console early_console = {
59#endif 59#endif
60 60
61#ifdef CONFIG_EARLY_SCIF_CONSOLE 61#ifdef CONFIG_EARLY_SCIF_CONSOLE
62#include <linux/serial_core.h>
63#include "../../../drivers/serial/sh-sci.h"
64
65#ifdef CONFIG_CPU_SH4
62#define SCIF_REG 0xffe80000 66#define SCIF_REG 0xffe80000
67#elif defined(CONFIG_CPU_SUBTYPE_SH72060)
68#define SCIF_REG 0xfffe9800
69#else
70#error "Undefined SCIF for this subtype"
71#endif
72
73static struct uart_port scif_port = {
74 .mapbase = SCIF_REG,
75 .membase = (char __iomem *)SCIF_REG,
76};
63 77
64static void scif_sercon_putc(int c) 78static void scif_sercon_putc(int c)
65{ 79{
66 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x20)) ; 80 while (((sci_in(&scif_port, SCFDR) & 0x1f00 >> 8) == 16))
81 ;
67 82
68 ctrl_outb(c, SCIF_REG + 12); 83 sci_out(&scif_port, SCxTDR, c);
69 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0x9f), SCIF_REG + 0x10); 84 sci_in(&scif_port, SCxSR);
85 sci_out(&scif_port, SCxSR, 0xf3 & ~(0x20 | 0x40));
86
87 while ((sci_in(&scif_port, SCxSR) & 0x40) == 0);
88 ;
70 89
71 if (c == '\n') 90 if (c == '\n')
72 scif_sercon_putc('\r'); 91 scif_sercon_putc('\r');
73} 92}
74 93
75static void scif_sercon_flush(void) 94static void scif_sercon_write(struct console *con, const char *s,
76{ 95 unsigned count)
77 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
78
79 while (!(ctrl_inw(SCIF_REG + 0x10) & 0x40)) ;
80
81 ctrl_outw((ctrl_inw(SCIF_REG + 0x10) & 0xbf), SCIF_REG + 0x10);
82}
83
84static void scif_sercon_write(struct console *con, const char *s, unsigned count)
85{ 96{
86 while (count-- > 0) 97 while (count-- > 0)
87 scif_sercon_putc(*s++); 98 scif_sercon_putc(*s++);
88
89 scif_sercon_flush();
90} 99}
91 100
92static int __init scif_sercon_setup(struct console *con, char *options) 101static int __init scif_sercon_setup(struct console *con, char *options)
@@ -96,7 +105,7 @@ static int __init scif_sercon_setup(struct console *con, char *options)
96 return 0; 105 return 0;
97} 106}
98 107
99static struct console early_console = { 108static struct console scif_console = {
100 .name = "sercon", 109 .name = "sercon",
101 .write = scif_sercon_write, 110 .write = scif_sercon_write,
102 .setup = scif_sercon_setup, 111 .setup = scif_sercon_setup,
@@ -104,7 +113,7 @@ static struct console early_console = {
104 .index = -1, 113 .index = -1,
105}; 114};
106 115
107void scif_sercon_init(int baud) 116static void scif_sercon_init(int baud)
108{ 117{
109 ctrl_outw(0, SCIF_REG + 8); 118 ctrl_outw(0, SCIF_REG + 8);
110 ctrl_outw(0, SCIF_REG); 119 ctrl_outw(0, SCIF_REG);
@@ -122,16 +131,61 @@ void scif_sercon_init(int baud)
122} 131}
123#endif 132#endif
124 133
125void __init enable_early_printk(void) 134/*
135 * Setup a default console, if more than one is compiled in, rely on the
136 * earlyprintk= parsing to give priority.
137 */
138static struct console *early_console =
139#ifdef CONFIG_SH_STANDARD_BIOS
140 &bios_console
141#elif defined(CONFIG_EARLY_SCIF_CONSOLE)
142 &scif_console
143#else
144 NULL
145#endif
146 ;
147
148static int __initdata keep_early;
149
150int __init setup_early_printk(char *opt)
126{ 151{
127#ifdef CONFIG_EARLY_SCIF_CONSOLE 152 char *space;
128 scif_sercon_init(115200); 153 char buf[256];
154
155 strlcpy(buf, opt, sizeof(buf));
156 space = strchr(buf, ' ');
157 if (space)
158 *space = 0;
159
160 if (strstr(buf, "keep"))
161 keep_early = 1;
162
163#ifdef CONFIG_SH_STANDARD_BIOS
164 if (!strncmp(buf, "bios", 4))
165 early_console = &bios_console;
166#endif
167#if defined(CONFIG_EARLY_SCIF_CONSOLE)
168 if (!strncmp(buf, "serial", 6)) {
169 early_console = &scif_console;
170
171#ifdef CONFIG_CPU_SH4
172 scif_sercon_init(115200);
173#endif
174 }
129#endif 175#endif
130 register_console(&early_console); 176
177 if (likely(early_console))
178 register_console(early_console);
179
180 return 1;
131} 181}
182__setup("earlyprintk=", setup_early_printk);
132 183
133void disable_early_printk(void) 184void __init disable_early_printk(void)
134{ 185{
135 unregister_console(&early_console); 186 if (!keep_early) {
187 printk("disabling early console\n");
188 unregister_console(early_console);
189 } else
190 printk("keeping early console\n");
136} 191}
137
diff --git a/arch/sh/kernel/entry.S b/arch/sh/kernel/entry.S
index 7dfd2ba75f7f..fe8221855b28 100644
--- a/arch/sh/kernel/entry.S
+++ b/arch/sh/kernel/entry.S
@@ -18,24 +18,6 @@
18#include <asm/cpu/mmu_context.h> 18#include <asm/cpu/mmu_context.h>
19#include <asm/unistd.h> 19#include <asm/unistd.h>
20 20
21#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE)
22#define sys_nfsservctl sys_ni_syscall
23#endif
24
25#if !defined(CONFIG_MMU)
26#define sys_madvise sys_ni_syscall
27#define sys_readahead sys_ni_syscall
28#define sys_mprotect sys_ni_syscall
29#define sys_msync sys_ni_syscall
30#define sys_mlock sys_ni_syscall
31#define sys_munlock sys_ni_syscall
32#define sys_mlockall sys_ni_syscall
33#define sys_munlockall sys_ni_syscall
34#define sys_mremap sys_ni_syscall
35#define sys_mincore sys_ni_syscall
36#define sys_remap_file_pages sys_ni_syscall
37#endif
38
39! NOTE: 21! NOTE:
40! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address 22! GNU as (as of 2.9.1) changes bf/s into bt/s and bra, when the address
41! to be jumped is too far, but it causes illegal slot exception. 23! to be jumped is too far, but it causes illegal slot exception.
@@ -326,7 +308,7 @@ ENTRY(exception_error)
326 .align 2 308 .align 2
327ret_from_exception: 309ret_from_exception:
328 preempt_stop() 310 preempt_stop()
329ret_from_irq: 311ENTRY(ret_from_irq)
330 ! 312 !
331 mov #OFF_SR, r0 313 mov #OFF_SR, r0
332 mov.l @(r0,r15), r0 ! get status register 314 mov.l @(r0,r15), r0 ! get status register
@@ -389,11 +371,12 @@ work_pending:
389 ! r8: current_thread_info 371 ! r8: current_thread_info
390 ! t: result of "tst #_TIF_NEED_RESCHED, r0" 372 ! t: result of "tst #_TIF_NEED_RESCHED, r0"
391 bf/s work_resched 373 bf/s work_resched
392 tst #_TIF_SIGPENDING, r0 374 tst #(_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r0
393work_notifysig: 375work_notifysig:
394 bt/s restore_all 376 bt/s restore_all
395 mov r15, r4 377 mov r15, r4
396 mov #0, r5 378 mov r12, r5 ! set arg1(save_r0)
379 mov r0, r6
397 mov.l 2f, r1 380 mov.l 2f, r1
398 mova restore_all, r0 381 mova restore_all, r0
399 jmp @r1 382 jmp @r1
@@ -431,7 +414,7 @@ work_resched:
431 414
432 .align 2 415 .align 2
4331: .long schedule 4161: .long schedule
4342: .long do_signal 4172: .long do_notify_resume
435 418
436 .align 2 419 .align 2
437syscall_exit_work: 420syscall_exit_work:
@@ -552,6 +535,7 @@ syscall_call:
552 mov.l @r9, r8 535 mov.l @r9, r8
553 jsr @r8 ! jump to specific syscall handler 536 jsr @r8 ! jump to specific syscall handler
554 nop 537 nop
538 mov.l @(OFF_R0,r15), r12 ! save r0
555 mov.l r0, @(OFF_R0,r15) ! save the return value 539 mov.l r0, @(OFF_R0,r15) ! save the return value
556 ! 540 !
557syscall_exit: 541syscall_exit:
@@ -644,7 +628,7 @@ skip_restore:
644 ! 628 !
645#if defined(CONFIG_KGDB_NMI) 629#if defined(CONFIG_KGDB_NMI)
646 ! Clear in_nmi 630 ! Clear in_nmi
647 mov.l 4f, k0 631 mov.l 6f, k0
648 mov #0, k1 632 mov #0, k1
649 mov.b k1, @k0 633 mov.b k1, @k0
650#endif 634#endif
@@ -722,7 +706,7 @@ interrupt:
722! 706!
723! 707!
724 .align 2 708 .align 2
725handle_exception: 709ENTRY(handle_exception)
726 ! Using k0, k1 for scratch registers (r0_bank1, r1_bank), 710 ! Using k0, k1 for scratch registers (r0_bank1, r1_bank),
727 ! save all registers onto stack. 711 ! save all registers onto stack.
728 ! 712 !
@@ -732,8 +716,8 @@ handle_exception:
732 bt/s 1f ! It's a kernel to kernel transition. 716 bt/s 1f ! It's a kernel to kernel transition.
733 mov r15, k0 ! save original stack to k0 717 mov r15, k0 ! save original stack to k0
734 /* User space to kernel */ 718 /* User space to kernel */
735 mov #0x20, k1 719 mov #(THREAD_SIZE >> 8), k1
736 shll8 k1 ! k1 := 8192 (== THREAD_SIZE) 720 shll8 k1 ! k1 := THREAD_SIZE
737 add current, k1 721 add current, k1
738 mov k1, r15 ! change to kernel stack 722 mov k1, r15 ! change to kernel stack
739 ! 723 !
@@ -838,300 +822,3 @@ ENTRY(exception_none)
838 rts 822 rts
839 nop 823 nop
840 824
841 .data
842ENTRY(sys_call_table)
843 .long sys_ni_syscall /* 0 - old "setup()" system call*/
844 .long sys_exit
845 .long sys_fork
846 .long sys_read
847 .long sys_write
848 .long sys_open /* 5 */
849 .long sys_close
850 .long sys_waitpid
851 .long sys_creat
852 .long sys_link
853 .long sys_unlink /* 10 */
854 .long sys_execve
855 .long sys_chdir
856 .long sys_time
857 .long sys_mknod
858 .long sys_chmod /* 15 */
859 .long sys_lchown16
860 .long sys_ni_syscall /* old break syscall holder */
861 .long sys_stat
862 .long sys_lseek
863 .long sys_getpid /* 20 */
864 .long sys_mount
865 .long sys_oldumount
866 .long sys_setuid16
867 .long sys_getuid16
868 .long sys_stime /* 25 */
869 .long sys_ptrace
870 .long sys_alarm
871 .long sys_fstat
872 .long sys_pause
873 .long sys_utime /* 30 */
874 .long sys_ni_syscall /* old stty syscall holder */
875 .long sys_ni_syscall /* old gtty syscall holder */
876 .long sys_access
877 .long sys_nice
878 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
879 .long sys_sync
880 .long sys_kill
881 .long sys_rename
882 .long sys_mkdir
883 .long sys_rmdir /* 40 */
884 .long sys_dup
885 .long sys_pipe
886 .long sys_times
887 .long sys_ni_syscall /* old prof syscall holder */
888 .long sys_brk /* 45 */
889 .long sys_setgid16
890 .long sys_getgid16
891 .long sys_signal
892 .long sys_geteuid16
893 .long sys_getegid16 /* 50 */
894 .long sys_acct
895 .long sys_umount /* recycled never used phys() */
896 .long sys_ni_syscall /* old lock syscall holder */
897 .long sys_ioctl
898 .long sys_fcntl /* 55 */
899 .long sys_ni_syscall /* old mpx syscall holder */
900 .long sys_setpgid
901 .long sys_ni_syscall /* old ulimit syscall holder */
902 .long sys_ni_syscall /* sys_olduname */
903 .long sys_umask /* 60 */
904 .long sys_chroot
905 .long sys_ustat
906 .long sys_dup2
907 .long sys_getppid
908 .long sys_getpgrp /* 65 */
909 .long sys_setsid
910 .long sys_sigaction
911 .long sys_sgetmask
912 .long sys_ssetmask
913 .long sys_setreuid16 /* 70 */
914 .long sys_setregid16
915 .long sys_sigsuspend
916 .long sys_sigpending
917 .long sys_sethostname
918 .long sys_setrlimit /* 75 */
919 .long sys_old_getrlimit
920 .long sys_getrusage
921 .long sys_gettimeofday
922 .long sys_settimeofday
923 .long sys_getgroups16 /* 80 */
924 .long sys_setgroups16
925 .long sys_ni_syscall /* sys_oldselect */
926 .long sys_symlink
927 .long sys_lstat
928 .long sys_readlink /* 85 */
929 .long sys_uselib
930 .long sys_swapon
931 .long sys_reboot
932 .long old_readdir
933 .long old_mmap /* 90 */
934 .long sys_munmap
935 .long sys_truncate
936 .long sys_ftruncate
937 .long sys_fchmod
938 .long sys_fchown16 /* 95 */
939 .long sys_getpriority
940 .long sys_setpriority
941 .long sys_ni_syscall /* old profil syscall holder */
942 .long sys_statfs
943 .long sys_fstatfs /* 100 */
944 .long sys_ni_syscall /* ioperm */
945 .long sys_socketcall
946 .long sys_syslog
947 .long sys_setitimer
948 .long sys_getitimer /* 105 */
949 .long sys_newstat
950 .long sys_newlstat
951 .long sys_newfstat
952 .long sys_uname
953 .long sys_ni_syscall /* 110 */ /* iopl */
954 .long sys_vhangup
955 .long sys_ni_syscall /* idle */
956 .long sys_ni_syscall /* vm86old */
957 .long sys_wait4
958 .long sys_swapoff /* 115 */
959 .long sys_sysinfo
960 .long sys_ipc
961 .long sys_fsync
962 .long sys_sigreturn
963 .long sys_clone /* 120 */
964 .long sys_setdomainname
965 .long sys_newuname
966 .long sys_ni_syscall /* sys_modify_ldt */
967 .long sys_adjtimex
968 .long sys_mprotect /* 125 */
969 .long sys_sigprocmask
970 .long sys_ni_syscall /* old "create_module" */
971 .long sys_init_module
972 .long sys_delete_module
973 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
974 .long sys_quotactl
975 .long sys_getpgid
976 .long sys_fchdir
977 .long sys_bdflush
978 .long sys_sysfs /* 135 */
979 .long sys_personality
980 .long sys_ni_syscall /* for afs_syscall */
981 .long sys_setfsuid16
982 .long sys_setfsgid16
983 .long sys_llseek /* 140 */
984 .long sys_getdents
985 .long sys_select
986 .long sys_flock
987 .long sys_msync
988 .long sys_readv /* 145 */
989 .long sys_writev
990 .long sys_getsid
991 .long sys_fdatasync
992 .long sys_sysctl
993 .long sys_mlock /* 150 */
994 .long sys_munlock
995 .long sys_mlockall
996 .long sys_munlockall
997 .long sys_sched_setparam
998 .long sys_sched_getparam /* 155 */
999 .long sys_sched_setscheduler
1000 .long sys_sched_getscheduler
1001 .long sys_sched_yield
1002 .long sys_sched_get_priority_max
1003 .long sys_sched_get_priority_min /* 160 */
1004 .long sys_sched_rr_get_interval
1005 .long sys_nanosleep
1006 .long sys_mremap
1007 .long sys_setresuid16
1008 .long sys_getresuid16 /* 165 */
1009 .long sys_ni_syscall /* vm86 */
1010 .long sys_ni_syscall /* old "query_module" */
1011 .long sys_poll
1012 .long sys_nfsservctl
1013 .long sys_setresgid16 /* 170 */
1014 .long sys_getresgid16
1015 .long sys_prctl
1016 .long sys_rt_sigreturn
1017 .long sys_rt_sigaction
1018 .long sys_rt_sigprocmask /* 175 */
1019 .long sys_rt_sigpending
1020 .long sys_rt_sigtimedwait
1021 .long sys_rt_sigqueueinfo
1022 .long sys_rt_sigsuspend
1023 .long sys_pread_wrapper /* 180 */
1024 .long sys_pwrite_wrapper
1025 .long sys_chown16
1026 .long sys_getcwd
1027 .long sys_capget
1028 .long sys_capset /* 185 */
1029 .long sys_sigaltstack
1030 .long sys_sendfile
1031 .long sys_ni_syscall /* streams1 */
1032 .long sys_ni_syscall /* streams2 */
1033 .long sys_vfork /* 190 */
1034 .long sys_getrlimit
1035 .long sys_mmap2
1036 .long sys_truncate64
1037 .long sys_ftruncate64
1038 .long sys_stat64 /* 195 */
1039 .long sys_lstat64
1040 .long sys_fstat64
1041 .long sys_lchown
1042 .long sys_getuid
1043 .long sys_getgid /* 200 */
1044 .long sys_geteuid
1045 .long sys_getegid
1046 .long sys_setreuid
1047 .long sys_setregid
1048 .long sys_getgroups /* 205 */
1049 .long sys_setgroups
1050 .long sys_fchown
1051 .long sys_setresuid
1052 .long sys_getresuid
1053 .long sys_setresgid /* 210 */
1054 .long sys_getresgid
1055 .long sys_chown
1056 .long sys_setuid
1057 .long sys_setgid
1058 .long sys_setfsuid /* 215 */
1059 .long sys_setfsgid
1060 .long sys_pivot_root
1061 .long sys_mincore
1062 .long sys_madvise
1063 .long sys_getdents64 /* 220 */
1064 .long sys_fcntl64
1065 .long sys_ni_syscall /* reserved for TUX */
1066 .long sys_ni_syscall /* Reserved for Security */
1067 .long sys_gettid
1068 .long sys_readahead /* 225 */
1069 .long sys_setxattr
1070 .long sys_lsetxattr
1071 .long sys_fsetxattr
1072 .long sys_getxattr
1073 .long sys_lgetxattr /* 230 */
1074 .long sys_fgetxattr
1075 .long sys_listxattr
1076 .long sys_llistxattr
1077 .long sys_flistxattr
1078 .long sys_removexattr /* 235 */
1079 .long sys_lremovexattr
1080 .long sys_fremovexattr
1081 .long sys_tkill
1082 .long sys_sendfile64
1083 .long sys_futex /* 240 */
1084 .long sys_sched_setaffinity
1085 .long sys_sched_getaffinity
1086 .long sys_ni_syscall
1087 .long sys_ni_syscall
1088 .long sys_io_setup /* 245 */
1089 .long sys_io_destroy
1090 .long sys_io_getevents
1091 .long sys_io_submit
1092 .long sys_io_cancel
1093 .long sys_fadvise64 /* 250 */
1094 .long sys_ni_syscall
1095 .long sys_exit_group
1096 .long sys_lookup_dcookie
1097 .long sys_epoll_create
1098 .long sys_epoll_ctl /* 255 */
1099 .long sys_epoll_wait
1100 .long sys_remap_file_pages
1101 .long sys_set_tid_address
1102 .long sys_timer_create
1103 .long sys_timer_settime /* 260 */
1104 .long sys_timer_gettime
1105 .long sys_timer_getoverrun
1106 .long sys_timer_delete
1107 .long sys_clock_settime
1108 .long sys_clock_gettime /* 265 */
1109 .long sys_clock_getres
1110 .long sys_clock_nanosleep
1111 .long sys_statfs64
1112 .long sys_fstatfs64
1113 .long sys_tgkill /* 270 */
1114 .long sys_utimes
1115 .long sys_fadvise64_64_wrapper
1116 .long sys_ni_syscall /* Reserved for vserver */
1117 .long sys_ni_syscall /* Reserved for mbind */
1118 .long sys_ni_syscall /* 275 - get_mempolicy */
1119 .long sys_ni_syscall /* set_mempolicy */
1120 .long sys_mq_open
1121 .long sys_mq_unlink
1122 .long sys_mq_timedsend
1123 .long sys_mq_timedreceive /* 280 */
1124 .long sys_mq_notify
1125 .long sys_mq_getsetattr
1126 .long sys_ni_syscall /* Reserved for kexec */
1127 .long sys_waitid
1128 .long sys_add_key /* 285 */
1129 .long sys_request_key
1130 .long sys_keyctl
1131 .long sys_ioprio_set
1132 .long sys_ioprio_get
1133 .long sys_inotify_init /* 290 */
1134 .long sys_inotify_add_watch
1135 .long sys_inotify_rm_watch
1136
1137/* End of entry.S */
diff --git a/arch/sh/kernel/head.S b/arch/sh/kernel/head.S
index 9b9e6ef626ce..f5f53d14f245 100644
--- a/arch/sh/kernel/head.S
+++ b/arch/sh/kernel/head.S
@@ -11,6 +11,18 @@
11 * Head.S contains the SH exception handlers and startup code. 11 * Head.S contains the SH exception handlers and startup code.
12 */ 12 */
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <asm/thread_info.h>
15
16#ifdef CONFIG_CPU_SH4A
17#define SYNCO() synco
18
19#define PREFI(label, reg) \
20 mov.l label, reg; \
21 prefi @reg
22#else
23#define SYNCO()
24#define PREFI(label, reg)
25#endif
14 26
15 .section .empty_zero_page, "aw" 27 .section .empty_zero_page, "aw"
16ENTRY(empty_zero_page) 28ENTRY(empty_zero_page)
@@ -42,18 +54,25 @@ ENTRY(_stext)
42 ! Initialize global interrupt mask 54 ! Initialize global interrupt mask
43 mov #0, r0 55 mov #0, r0
44 ldc r0, r6_bank 56 ldc r0, r6_bank
57
58 /*
59 * Prefetch if possible to reduce cache miss penalty.
60 *
61 * We do this early on for SH-4A as a micro-optimization,
62 * as later on we will have speculative execution enabled
63 * and this will become less of an issue.
64 */
65 PREFI(5f, r0)
66 PREFI(6f, r0)
67
45 ! 68 !
46 mov.l 2f, r0 69 mov.l 2f, r0
47 mov r0, r15 ! Set initial r15 (stack pointer) 70 mov r0, r15 ! Set initial r15 (stack pointer)
48 mov #0x20, r1 ! 71 mov #(THREAD_SIZE >> 8), r1
49 shll8 r1 ! r1 = 8192 72 shll8 r1 ! r1 = THREAD_SIZE
50 sub r1, r0 ! 73 sub r1, r0 !
51 ldc r0, r7_bank ! ... and initial thread_info 74 ldc r0, r7_bank ! ... and initial thread_info
52 ! 75
53 ! Additional CPU initialization
54 mov.l 6f, r0
55 jsr @r0
56 nop
57 ! Clear BSS area 76 ! Clear BSS area
58 mov.l 3f, r1 77 mov.l 3f, r1
59 add #4, r1 78 add #4, r1
@@ -62,6 +81,14 @@ ENTRY(_stext)
629: cmp/hs r2, r1 819: cmp/hs r2, r1
63 bf/s 9b ! while (r1 < r2) 82 bf/s 9b ! while (r1 < r2)
64 mov.l r0,@-r2 83 mov.l r0,@-r2
84
85 ! Additional CPU initialization
86 mov.l 6f, r0
87 jsr @r0
88 nop
89
90 SYNCO() ! Wait for pending instructions..
91
65 ! Start kernel 92 ! Start kernel
66 mov.l 5f, r0 93 mov.l 5f, r0
67 jmp @r0 94 jmp @r0
@@ -69,7 +96,7 @@ ENTRY(_stext)
69 96
70 .balign 4 97 .balign 4
711: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF 981: .long 0x400080F0 ! MD=1, RB=0, BL=0, FD=1, IMASK=0xF
722: .long stack 992: .long init_thread_union+THREAD_SIZE
733: .long __bss_start 1003: .long __bss_start
744: .long _end 1014: .long _end
755: .long start_kernel 1025: .long start_kernel
diff --git a/arch/sh/kernel/io.c b/arch/sh/kernel/io.c
index 71c9fde2fd90..501fe03e3715 100644
--- a/arch/sh/kernel/io.c
+++ b/arch/sh/kernel/io.c
@@ -61,6 +61,73 @@ void memset_io(volatile void __iomem *dst, int c, unsigned long count)
61} 61}
62EXPORT_SYMBOL(memset_io); 62EXPORT_SYMBOL(memset_io);
63 63
64void __raw_readsl(unsigned long addr, void *datap, int len)
65{
66 u32 *data;
67
68 for (data = datap; (len != 0) && (((u32)data & 0x1f) != 0); len--)
69 *data++ = ctrl_inl(addr);
70
71 if (likely(len >= (0x20 >> 2))) {
72 int tmp2, tmp3, tmp4, tmp5, tmp6;
73
74 __asm__ __volatile__(
75 "1: \n\t"
76 "mov.l @%7, r0 \n\t"
77 "mov.l @%7, %2 \n\t"
78#ifdef CONFIG_CPU_SH4
79 "movca.l r0, @%0 \n\t"
80#else
81 "mov.l r0, @%0 \n\t"
82#endif
83 "mov.l @%7, %3 \n\t"
84 "mov.l @%7, %4 \n\t"
85 "mov.l @%7, %5 \n\t"
86 "mov.l @%7, %6 \n\t"
87 "mov.l @%7, r7 \n\t"
88 "mov.l @%7, r0 \n\t"
89 "mov.l %2, @(0x04,%0) \n\t"
90 "mov #0x20>>2, %2 \n\t"
91 "mov.l %3, @(0x08,%0) \n\t"
92 "sub %2, %1 \n\t"
93 "mov.l %4, @(0x0c,%0) \n\t"
94 "cmp/hi %1, %2 ! T if 32 > len \n\t"
95 "mov.l %5, @(0x10,%0) \n\t"
96 "mov.l %6, @(0x14,%0) \n\t"
97 "mov.l r7, @(0x18,%0) \n\t"
98 "mov.l r0, @(0x1c,%0) \n\t"
99 "bf.s 1b \n\t"
100 " add #0x20, %0 \n\t"
101 : "=&r" (data), "=&r" (len),
102 "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4),
103 "=&r" (tmp5), "=&r" (tmp6)
104 : "r"(addr), "0" (data), "1" (len)
105 : "r0", "r7", "t", "memory");
106 }
107
108 for (; len != 0; len--)
109 *data++ = ctrl_inl(addr);
110}
111EXPORT_SYMBOL(__raw_readsl);
112
113void __raw_writesl(unsigned long addr, const void *data, int len)
114{
115 if (likely(len != 0)) {
116 int tmp1;
117
118 __asm__ __volatile__ (
119 "1: \n\t"
120 "mov.l @%0+, %1 \n\t"
121 "dt %3 \n\t"
122 "bf.s 1b \n\t"
123 " mov.l %1, @%4 \n\t"
124 : "=&r" (data), "=&r" (tmp1)
125 : "0" (data), "r" (len), "r"(addr)
126 : "t", "memory");
127 }
128}
129EXPORT_SYMBOL(__raw_writesl);
130
64void __iomem *ioport_map(unsigned long port, unsigned int nr) 131void __iomem *ioport_map(unsigned long port, unsigned int nr)
65{ 132{
66 return sh_mv.mv_ioport_map(port, nr); 133 return sh_mv.mv_ioport_map(port, nr);
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index c2e07f7f3496..c7ebd6aec951 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -1,5 +1,4 @@
1/* $Id: irq.c,v 1.20 2004/01/13 05:52:11 kkojima Exp $ 1/*
2 *
3 * linux/arch/sh/kernel/irq.c 2 * linux/arch/sh/kernel/irq.c
4 * 3 *
5 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar 4 * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
@@ -7,13 +6,15 @@
7 * 6 *
8 * SuperH version: Copyright (C) 1999 Niibe Yutaka 7 * SuperH version: Copyright (C) 1999 Niibe Yutaka
9 */ 8 */
10
11#include <linux/irq.h> 9#include <linux/irq.h>
12#include <linux/interrupt.h> 10#include <linux/interrupt.h>
11#include <linux/module.h>
13#include <linux/kernel_stat.h> 12#include <linux/kernel_stat.h>
14#include <linux/seq_file.h> 13#include <linux/seq_file.h>
15#include <asm/irq.h> 14#include <asm/irq.h>
16#include <asm/processor.h> 15#include <asm/processor.h>
16#include <asm/uaccess.h>
17#include <asm/thread_info.h>
17#include <asm/cpu/mmu_context.h> 18#include <asm/cpu/mmu_context.h>
18 19
19/* 20/*
@@ -60,15 +61,46 @@ unlock:
60} 61}
61#endif 62#endif
62 63
64#ifdef CONFIG_4KSTACKS
65/*
66 * per-CPU IRQ handling contexts (thread information and stack)
67 */
68union irq_ctx {
69 struct thread_info tinfo;
70 u32 stack[THREAD_SIZE/sizeof(u32)];
71};
72
73static union irq_ctx *hardirq_ctx[NR_CPUS];
74static union irq_ctx *softirq_ctx[NR_CPUS];
75#endif
63 76
64asmlinkage int do_IRQ(unsigned long r4, unsigned long r5, 77asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
65 unsigned long r6, unsigned long r7, 78 unsigned long r6, unsigned long r7,
66 struct pt_regs regs) 79 struct pt_regs regs)
67{ 80{
68 int irq = r4; 81 int irq = r4;
82#ifdef CONFIG_4KSTACKS
83 union irq_ctx *curctx, *irqctx;
84#endif
69 85
70 irq_enter(); 86 irq_enter();
71 87
88#ifdef CONFIG_DEBUG_STACKOVERFLOW
89 /* Debugging check for stack overflow: is there less than 1KB free? */
90 {
91 long sp;
92
93 __asm__ __volatile__ ("and r15, %0" :
94 "=r" (sp) : "0" (THREAD_SIZE - 1));
95
96 if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
97 printk("do_IRQ: stack overflow: %ld\n",
98 sp - sizeof(struct thread_info));
99 dump_stack();
100 }
101 }
102#endif
103
72#ifdef CONFIG_CPU_HAS_INTEVT 104#ifdef CONFIG_CPU_HAS_INTEVT
73 __asm__ __volatile__ ( 105 __asm__ __volatile__ (
74#ifdef CONFIG_CPU_HAS_SR_RB 106#ifdef CONFIG_CPU_HAS_SR_RB
@@ -87,7 +119,135 @@ asmlinkage int do_IRQ(unsigned long r4, unsigned long r5,
87#endif 119#endif
88 120
89 irq = irq_demux(irq); 121 irq = irq_demux(irq);
90 __do_IRQ(irq, &regs); 122
123#ifdef CONFIG_4KSTACKS
124 curctx = (union irq_ctx *)current_thread_info();
125 irqctx = hardirq_ctx[smp_processor_id()];
126
127 /*
128 * this is where we switch to the IRQ stack. However, if we are
129 * already using the IRQ stack (because we interrupted a hardirq
130 * handler) we can't do that and just have to keep using the
131 * current stack (which is the irq stack already after all)
132 */
133 if (curctx != irqctx) {
134 u32 *isp;
135
136 isp = (u32 *)((char *)irqctx + sizeof(*irqctx));
137 irqctx->tinfo.task = curctx->tinfo.task;
138 irqctx->tinfo.previous_sp = current_stack_pointer;
139
140 __asm__ __volatile__ (
141 "mov %0, r4 \n"
142 "mov %1, r5 \n"
143 "mov r15, r9 \n"
144 "jsr @%2 \n"
145 /* swith to the irq stack */
146 " mov %3, r15 \n"
147 /* restore the stack (ring zero) */
148 "mov r9, r15 \n"
149 : /* no outputs */
150 : "r" (irq), "r" (&regs), "r" (__do_IRQ), "r" (isp)
151 /* XXX: A somewhat excessive clobber list? -PFM */
152 : "memory", "r0", "r1", "r2", "r3", "r4",
153 "r5", "r6", "r7", "r8", "t", "pr"
154 );
155 } else
156#endif
157 __do_IRQ(irq, &regs);
158
91 irq_exit(); 159 irq_exit();
160
92 return 1; 161 return 1;
93} 162}
163
164#ifdef CONFIG_4KSTACKS
165/*
166 * These should really be __section__(".bss.page_aligned") as well, but
167 * gcc's 3.0 and earlier don't handle that correctly.
168 */
169static char softirq_stack[NR_CPUS * THREAD_SIZE]
170 __attribute__((__aligned__(THREAD_SIZE)));
171
172static char hardirq_stack[NR_CPUS * THREAD_SIZE]
173 __attribute__((__aligned__(THREAD_SIZE)));
174
175/*
176 * allocate per-cpu stacks for hardirq and for softirq processing
177 */
178void irq_ctx_init(int cpu)
179{
180 union irq_ctx *irqctx;
181
182 if (hardirq_ctx[cpu])
183 return;
184
185 irqctx = (union irq_ctx *)&hardirq_stack[cpu * THREAD_SIZE];
186 irqctx->tinfo.task = NULL;
187 irqctx->tinfo.exec_domain = NULL;
188 irqctx->tinfo.cpu = cpu;
189 irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
190 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
191
192 hardirq_ctx[cpu] = irqctx;
193
194 irqctx = (union irq_ctx *)&softirq_stack[cpu * THREAD_SIZE];
195 irqctx->tinfo.task = NULL;
196 irqctx->tinfo.exec_domain = NULL;
197 irqctx->tinfo.cpu = cpu;
198 irqctx->tinfo.preempt_count = SOFTIRQ_OFFSET;
199 irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
200
201 softirq_ctx[cpu] = irqctx;
202
203 printk("CPU %u irqstacks, hard=%p soft=%p\n",
204 cpu, hardirq_ctx[cpu], softirq_ctx[cpu]);
205}
206
207void irq_ctx_exit(int cpu)
208{
209 hardirq_ctx[cpu] = NULL;
210}
211
212extern asmlinkage void __do_softirq(void);
213
214asmlinkage void do_softirq(void)
215{
216 unsigned long flags;
217 struct thread_info *curctx;
218 union irq_ctx *irqctx;
219 u32 *isp;
220
221 if (in_interrupt())
222 return;
223
224 local_irq_save(flags);
225
226 if (local_softirq_pending()) {
227 curctx = current_thread_info();
228 irqctx = softirq_ctx[smp_processor_id()];
229 irqctx->tinfo.task = curctx->task;
230 irqctx->tinfo.previous_sp = current_stack_pointer;
231
232 /* build the stack frame on the softirq stack */
233 isp = (u32 *)((char *)irqctx + sizeof(*irqctx));
234
235 __asm__ __volatile__ (
236 "mov r15, r9 \n"
237 "jsr @%0 \n"
238 /* switch to the softirq stack */
239 " mov %1, r15 \n"
240 /* restore the thread stack */
241 "mov r9, r15 \n"
242 : /* no outputs */
243 : "r" (__do_softirq), "r" (isp)
244 /* XXX: A somewhat excessive clobber list? -PFM */
245 : "memory", "r0", "r1", "r2", "r3", "r4",
246 "r5", "r6", "r7", "r8", "r9", "r15", "t", "pr"
247 );
248 }
249
250 local_irq_restore(flags);
251}
252EXPORT_SYMBOL(do_softirq);
253#endif
diff --git a/arch/sh/kernel/kgdb_stub.c b/arch/sh/kernel/kgdb_stub.c
index 42638b92b51c..9c6315f0335d 100644
--- a/arch/sh/kernel/kgdb_stub.c
+++ b/arch/sh/kernel/kgdb_stub.c
@@ -101,16 +101,17 @@
101#include <linux/linkage.h> 101#include <linux/linkage.h>
102#include <linux/init.h> 102#include <linux/init.h>
103 103
104#ifdef CONFIG_SH_KGDB_CONSOLE
105#include <linux/console.h>
106#endif
107
104#include <asm/system.h> 108#include <asm/system.h>
105#include <asm/current.h> 109#include <asm/current.h>
106#include <asm/signal.h> 110#include <asm/signal.h>
107#include <asm/pgtable.h> 111#include <asm/pgtable.h>
108#include <asm/ptrace.h> 112#include <asm/ptrace.h>
109#include <asm/kgdb.h> 113#include <asm/kgdb.h>
110 114#include <asm/io.h>
111#ifdef CONFIG_SH_KGDB_CONSOLE
112#include <linux/console.h>
113#endif
114 115
115/* Function pointers for linkage */ 116/* Function pointers for linkage */
116kgdb_debug_hook_t *kgdb_debug_hook; 117kgdb_debug_hook_t *kgdb_debug_hook;
@@ -240,7 +241,6 @@ static jmp_buf rem_com_env;
240/* Misc static */ 241/* Misc static */
241static int stepped_address; 242static int stepped_address;
242static short stepped_opcode; 243static short stepped_opcode;
243static const char hexchars[] = "0123456789abcdef";
244static char in_buffer[BUFMAX]; 244static char in_buffer[BUFMAX];
245static char out_buffer[OUTBUFMAX]; 245static char out_buffer[OUTBUFMAX];
246 246
@@ -253,29 +253,6 @@ typedef unsigned char threadref[8];
253#define BUF_THREAD_ID_SIZE 16 253#define BUF_THREAD_ID_SIZE 16
254#endif 254#endif
255 255
256/* Return addr as a real volatile address */
257static inline unsigned int ctrl_inl(const unsigned long addr)
258{
259 return *(volatile unsigned long *) addr;
260}
261
262/* Correctly set *addr using volatile */
263static inline void ctrl_outl(const unsigned int b, unsigned long addr)
264{
265 *(volatile unsigned long *) addr = b;
266}
267
268/* Get high hex bits */
269static char highhex(const int x)
270{
271 return hexchars[(x >> 4) & 0xf];
272}
273
274/* Get low hex bits */
275static char lowhex(const int x)
276{
277 return hexchars[x & 0xf];
278}
279 256
280/* Convert ch to hex */ 257/* Convert ch to hex */
281static int hex(const char ch) 258static int hex(const char ch)
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 6bcd8d92399f..08587cdb64d6 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -29,12 +29,6 @@ extern const unsigned char relocate_new_kernel[];
29extern const unsigned int relocate_new_kernel_size; 29extern const unsigned int relocate_new_kernel_size;
30extern void *gdb_vbr_vector; 30extern void *gdb_vbr_vector;
31 31
32/*
33 * Provide a dummy crash_notes definition while crash dump arrives to ppc.
34 * This prevents breakage of crash_notes attribute in kernel/ksysfs.c.
35 */
36void *crash_notes = NULL;
37
38void machine_shutdown(void) 32void machine_shutdown(void)
39{ 33{
40} 34}
diff --git a/arch/sh/kernel/pm.c b/arch/sh/kernel/pm.c
new file mode 100644
index 000000000000..10ab62c9aede
--- /dev/null
+++ b/arch/sh/kernel/pm.c
@@ -0,0 +1,88 @@
1/*
2 * Generic Power Management Routine
3 *
4 * Copyright (c) 2006 Andriy Skulysh <askulsyh@gmail.com>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License.
8 */
9#include <linux/suspend.h>
10#include <linux/delay.h>
11#include <linux/gfp.h>
12#include <asm/freq.h>
13#include <asm/io.h>
14#include <asm/watchdog.h>
15#include <asm/pm.h>
16
17#define INTR_OFFSET 0x600
18
19#define STBCR 0xffffff82
20#define STBCR2 0xffffff88
21
22#define STBCR_STBY 0x80
23#define STBCR_MSTP2 0x04
24
25#define MCR 0xffffff68
26#define RTCNT 0xffffff70
27
28#define MCR_RMODE 2
29#define MCR_RFSH 4
30
31void pm_enter(void)
32{
33 u8 stbcr, csr;
34 u16 frqcr, mcr;
35 u32 vbr_new, vbr_old;
36
37 set_bl_bit();
38
39 /* set wdt */
40 csr = sh_wdt_read_csr();
41 csr &= ~WTCSR_TME;
42 csr |= WTCSR_CKS_4096;
43 sh_wdt_write_csr(csr);
44 csr = sh_wdt_read_csr();
45 sh_wdt_write_cnt(0);
46
47 /* disable PLL1 */
48 frqcr = ctrl_inw(FRQCR);
49 frqcr &= ~(FRQCR_PLLEN | FRQCR_PSTBY);
50 ctrl_outw(frqcr, FRQCR);
51
52 /* enable standby */
53 stbcr = ctrl_inb(STBCR);
54 ctrl_outb(stbcr | STBCR_STBY | STBCR_MSTP2, STBCR);
55
56 /* set self-refresh */
57 mcr = ctrl_inw(MCR);
58 ctrl_outw(mcr & ~MCR_RFSH, MCR);
59
60 /* set interrupt handler */
61 asm volatile("stc vbr, %0" : "=r" (vbr_old));
62 vbr_new = get_zeroed_page(GFP_ATOMIC);
63 udelay(50);
64 memcpy((void*)(vbr_new + INTR_OFFSET),
65 &wakeup_start, &wakeup_end - &wakeup_start);
66 asm volatile("ldc %0, vbr" : : "r" (vbr_new));
67
68 ctrl_outw(0, RTCNT);
69 ctrl_outw(mcr | MCR_RFSH | MCR_RMODE, MCR);
70
71 cpu_sleep();
72
73 asm volatile("ldc %0, vbr" : : "r" (vbr_old));
74
75 free_page(vbr_new);
76
77 /* enable PLL1 */
78 frqcr = ctrl_inw(FRQCR);
79 frqcr |= FRQCR_PSTBY;
80 ctrl_outw(frqcr, FRQCR);
81 udelay(50);
82 frqcr |= FRQCR_PLLEN;
83 ctrl_outw(frqcr, FRQCR);
84
85 ctrl_outb(stbcr, STBCR);
86
87 clear_bl_bit();
88}
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index f2031314cb2b..0b1d5dd7a93b 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -81,16 +81,6 @@ void cpu_idle(void)
81 81
82void machine_restart(char * __unused) 82void machine_restart(char * __unused)
83{ 83{
84
85#ifdef CONFIG_KEXEC
86 struct kimage *image;
87 image = xchg(&kexec_image, 0);
88 if (image) {
89 machine_shutdown();
90 machine_kexec(image);
91 }
92#endif
93
94 /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */ 84 /* SR.BL=1 and invoke address error to let CPU reset (manual reset) */
95 asm volatile("ldc %0, sr\n\t" 85 asm volatile("ldc %0, sr\n\t"
96 "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001)); 86 "mov.l @%1, %0" : : "r" (0x10000000), "r" (0x80000001));
@@ -263,6 +253,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
263 unsigned long unused, 253 unsigned long unused,
264 struct task_struct *p, struct pt_regs *regs) 254 struct task_struct *p, struct pt_regs *regs)
265{ 255{
256 struct thread_info *ti = task_thread_info(p);
266 struct pt_regs *childregs; 257 struct pt_regs *childregs;
267#if defined(CONFIG_SH_FPU) 258#if defined(CONFIG_SH_FPU)
268 struct task_struct *tsk = current; 259 struct task_struct *tsk = current;
@@ -277,8 +268,10 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
277 268
278 if (user_mode(regs)) { 269 if (user_mode(regs)) {
279 childregs->regs[15] = usp; 270 childregs->regs[15] = usp;
271 ti->addr_limit = USER_DS;
280 } else { 272 } else {
281 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE; 273 childregs->regs[15] = (unsigned long)task_stack_page(p) + THREAD_SIZE;
274 ti->addr_limit = KERNEL_DS;
282 } 275 }
283 if (clone_flags & CLONE_SETTLS) { 276 if (clone_flags & CLONE_SETTLS) {
284 childregs->gbr = childregs->regs[0]; 277 childregs->gbr = childregs->regs[0];
@@ -299,13 +292,15 @@ ubc_set_tracing(int asid, unsigned long pc)
299{ 292{
300 ctrl_outl(pc, UBC_BARA); 293 ctrl_outl(pc, UBC_BARA);
301 294
295#ifdef CONFIG_MMU
302 /* We don't have any ASID settings for the SH-2! */ 296 /* We don't have any ASID settings for the SH-2! */
303 if (cpu_data->type != CPU_SH7604) 297 if (cpu_data->type != CPU_SH7604)
304 ctrl_outb(asid, UBC_BASRA); 298 ctrl_outb(asid, UBC_BASRA);
299#endif
305 300
306 ctrl_outl(0, UBC_BAMRA); 301 ctrl_outl(0, UBC_BAMRA);
307 302
308 if (cpu_data->type == CPU_SH7729) { 303 if (cpu_data->type == CPU_SH7729 || cpu_data->type == CPU_SH7710) {
309 ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRA); 304 ctrl_outw(BBR_INST | BBR_READ | BBR_CPU, UBC_BBRA);
310 ctrl_outl(BRCR_PCBA | BRCR_PCTE, UBC_BRCR); 305 ctrl_outl(BRCR_PCBA | BRCR_PCTE, UBC_BRCR);
311 } else { 306 } else {
@@ -344,6 +339,7 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
344 } 339 }
345#endif 340#endif
346 341
342#ifdef CONFIG_MMU
347 /* 343 /*
348 * Restore the kernel mode register 344 * Restore the kernel mode register
349 * k7 (r7_bank1) 345 * k7 (r7_bank1)
@@ -351,19 +347,21 @@ struct task_struct *__switch_to(struct task_struct *prev, struct task_struct *ne
351 asm volatile("ldc %0, r7_bank" 347 asm volatile("ldc %0, r7_bank"
352 : /* no output */ 348 : /* no output */
353 : "r" (task_thread_info(next))); 349 : "r" (task_thread_info(next)));
350#endif
354 351
355#ifdef CONFIG_MMU
356 /* If no tasks are using the UBC, we're done */ 352 /* If no tasks are using the UBC, we're done */
357 if (ubc_usercnt == 0) 353 if (ubc_usercnt == 0)
358 /* If no tasks are using the UBC, we're done */; 354 /* If no tasks are using the UBC, we're done */;
359 else if (next->thread.ubc_pc && next->mm) { 355 else if (next->thread.ubc_pc && next->mm) {
360 ubc_set_tracing(next->mm->context & MMU_CONTEXT_ASID_MASK, 356 int asid = 0;
361 next->thread.ubc_pc); 357#ifdef CONFIG_MMU
358 asid |= next->mm->context.id & MMU_CONTEXT_ASID_MASK;
359#endif
360 ubc_set_tracing(asid, next->thread.ubc_pc);
362 } else { 361 } else {
363 ctrl_outw(0, UBC_BBRA); 362 ctrl_outw(0, UBC_BBRA);
364 ctrl_outw(0, UBC_BBRB); 363 ctrl_outw(0, UBC_BBRB);
365 } 364 }
366#endif
367 365
368 return prev; 366 return prev;
369} 367}
diff --git a/arch/sh/kernel/ptrace.c b/arch/sh/kernel/ptrace.c
index f7eebbde3291..04ca13a041c1 100644
--- a/arch/sh/kernel/ptrace.c
+++ b/arch/sh/kernel/ptrace.c
@@ -224,7 +224,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
224 224
225 case PTRACE_SETDSPREGS: { 225 case PTRACE_SETDSPREGS: {
226 unsigned long dp; 226 unsigned long dp;
227 int i;
228 227
229 ret = -EIO; 228 ret = -EIO;
230 dp = ((unsigned long) child) + THREAD_SIZE - 229 dp = ((unsigned long) child) + THREAD_SIZE -
diff --git a/arch/sh/kernel/semaphore.c b/arch/sh/kernel/semaphore.c
index a3c24dcbf01d..184119eeae56 100644
--- a/arch/sh/kernel/semaphore.c
+++ b/arch/sh/kernel/semaphore.c
@@ -14,7 +14,7 @@
14#include <asm/semaphore.h> 14#include <asm/semaphore.h>
15#include <asm/semaphore-helper.h> 15#include <asm/semaphore-helper.h>
16 16
17spinlock_t semaphore_wake_lock; 17DEFINE_SPINLOCK(semaphore_wake_lock);
18 18
19/* 19/*
20 * Semaphores are implemented using a two-way counter: 20 * Semaphores are implemented using a two-way counter:
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index e75189cb1db7..5f587332234a 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -43,27 +43,14 @@ extern void * __rd_start, * __rd_end;
43 * The bigger value means no problem. 43 * The bigger value means no problem.
44 */ 44 */
45struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, }; 45struct sh_cpuinfo boot_cpu_data = { CPU_SH_NONE, 10000000, };
46#ifdef CONFIG_VT
46struct screen_info screen_info; 47struct screen_info screen_info;
48#endif
47 49
48#if defined(CONFIG_SH_UNKNOWN) 50#if defined(CONFIG_SH_UNKNOWN)
49struct sh_machine_vector sh_mv; 51struct sh_machine_vector sh_mv;
50#endif 52#endif
51 53
52/* We need this to satisfy some external references. */
53struct screen_info screen_info = {
54 0, 25, /* orig-x, orig-y */
55 0, /* unused */
56 0, /* orig-video-page */
57 0, /* orig-video-mode */
58 80, /* orig-video-cols */
59 0,0,0, /* ega_ax, ega_bx, ega_cx */
60 25, /* orig-video-lines */
61 0, /* orig-video-isVGA */
62 16 /* orig-video-points */
63};
64
65extern void platform_setup(void);
66extern char *get_system_type(void);
67extern int root_mountflags; 54extern int root_mountflags;
68 55
69#define MV_NAME_SIZE 32 56#define MV_NAME_SIZE 32
@@ -90,29 +77,8 @@ static struct sh_machine_vector* __init get_mv_byname(const char* name);
90 77
91static char command_line[COMMAND_LINE_SIZE] = { 0, }; 78static char command_line[COMMAND_LINE_SIZE] = { 0, };
92 79
93struct resource standard_io_resources[] = { 80static struct resource code_resource = { .name = "Kernel code", };
94 { "dma1", 0x00, 0x1f }, 81static struct resource data_resource = { .name = "Kernel data", };
95 { "pic1", 0x20, 0x3f },
96 { "timer", 0x40, 0x5f },
97 { "keyboard", 0x60, 0x6f },
98 { "dma page reg", 0x80, 0x8f },
99 { "pic2", 0xa0, 0xbf },
100 { "dma2", 0xc0, 0xdf },
101 { "fpu", 0xf0, 0xff }
102};
103
104#define STANDARD_IO_RESOURCES (sizeof(standard_io_resources)/sizeof(struct resource))
105
106/* System RAM - interrupted by the 640kB-1M hole */
107#define code_resource (ram_resources[3])
108#define data_resource (ram_resources[4])
109static struct resource ram_resources[] = {
110 { "System RAM", 0x000000, 0x09ffff, IORESOURCE_BUSY },
111 { "System RAM", 0x100000, 0x100000, IORESOURCE_BUSY },
112 { "Video RAM area", 0x0a0000, 0x0bffff },
113 { "Kernel code", 0x100000, 0 },
114 { "Kernel data", 0, 0 }
115};
116 82
117unsigned long memory_start, memory_end; 83unsigned long memory_start, memory_end;
118 84
@@ -145,6 +111,24 @@ static inline void parse_cmdline (char ** cmdline_p, char mv_name[MV_NAME_SIZE],
145 memory_end = memory_start + mem_size; 111 memory_end = memory_start + mem_size;
146 } 112 }
147 } 113 }
114
115#ifdef CONFIG_EARLY_PRINTK
116 if (c == ' ' && !memcmp(from, "earlyprintk=", 12)) {
117 char *ep_end;
118
119 if (to != command_line)
120 to--;
121
122 from += 12;
123 ep_end = strchr(from, ' ');
124
125 setup_early_printk(from);
126 printk("early console enabled\n");
127
128 from = ep_end;
129 }
130#endif
131
148 if (c == ' ' && !memcmp(from, "sh_mv=", 6)) { 132 if (c == ' ' && !memcmp(from, "sh_mv=", 6)) {
149 char* mv_end; 133 char* mv_end;
150 char* mv_comma; 134 char* mv_comma;
@@ -237,6 +221,9 @@ static int __init sh_mv_setup(char **cmdline_p)
237 __set_io_port_base(mv_io_base); 221 __set_io_port_base(mv_io_base);
238#endif 222#endif
239 223
224 if (!sh_mv.mv_nr_irqs)
225 sh_mv.mv_nr_irqs = NR_IRQS;
226
240 return 0; 227 return 0;
241} 228}
242 229
@@ -245,11 +232,6 @@ void __init setup_arch(char **cmdline_p)
245 unsigned long bootmap_size; 232 unsigned long bootmap_size;
246 unsigned long start_pfn, max_pfn, max_low_pfn; 233 unsigned long start_pfn, max_pfn, max_low_pfn;
247 234
248#ifdef CONFIG_EARLY_PRINTK
249 extern void enable_early_printk(void);
250
251 enable_early_printk();
252#endif
253#ifdef CONFIG_CMDLINE_BOOL 235#ifdef CONFIG_CMDLINE_BOOL
254 strcpy(COMMAND_LINE, CONFIG_CMDLINE); 236 strcpy(COMMAND_LINE, CONFIG_CMDLINE);
255#endif 237#endif
@@ -368,14 +350,14 @@ void __init setup_arch(char **cmdline_p)
368#endif 350#endif
369 351
370 /* Perform the machine specific initialisation */ 352 /* Perform the machine specific initialisation */
371 platform_setup(); 353 if (likely(sh_mv.mv_setup))
354 sh_mv.mv_setup(cmdline_p);
372 355
373 paging_init(); 356 paging_init();
374} 357}
375 358
376struct sh_machine_vector* __init get_mv_byname(const char* name) 359struct sh_machine_vector* __init get_mv_byname(const char* name)
377{ 360{
378 extern int strcasecmp(const char *, const char *);
379 extern long __machvec_start, __machvec_end; 361 extern long __machvec_start, __machvec_end;
380 struct sh_machine_vector *all_vecs = 362 struct sh_machine_vector *all_vecs =
381 (struct sh_machine_vector *)&__machvec_start; 363 (struct sh_machine_vector *)&__machvec_start;
@@ -410,25 +392,18 @@ static int __init topology_init(void)
410subsys_initcall(topology_init); 392subsys_initcall(topology_init);
411 393
412static const char *cpu_name[] = { 394static const char *cpu_name[] = {
413 [CPU_SH7604] = "SH7604", 395 [CPU_SH7604] = "SH7604", [CPU_SH7300] = "SH7300",
414 [CPU_SH7705] = "SH7705", 396 [CPU_SH7705] = "SH7705", [CPU_SH7706] = "SH7706",
415 [CPU_SH7708] = "SH7708", 397 [CPU_SH7707] = "SH7707", [CPU_SH7708] = "SH7708",
416 [CPU_SH7729] = "SH7729", 398 [CPU_SH7709] = "SH7709", [CPU_SH7710] = "SH7710",
417 [CPU_SH7300] = "SH7300", 399 [CPU_SH7729] = "SH7729", [CPU_SH7750] = "SH7750",
418 [CPU_SH7750] = "SH7750", 400 [CPU_SH7750S] = "SH7750S", [CPU_SH7750R] = "SH7750R",
419 [CPU_SH7750S] = "SH7750S", 401 [CPU_SH7751] = "SH7751", [CPU_SH7751R] = "SH7751R",
420 [CPU_SH7750R] = "SH7750R", 402 [CPU_SH7760] = "SH7760", [CPU_SH73180] = "SH73180",
421 [CPU_SH7751] = "SH7751", 403 [CPU_ST40RA] = "ST40RA", [CPU_ST40GX1] = "ST40GX1",
422 [CPU_SH7751R] = "SH7751R", 404 [CPU_SH4_202] = "SH4-202", [CPU_SH4_501] = "SH4-501",
423 [CPU_SH7760] = "SH7760", 405 [CPU_SH7770] = "SH7770", [CPU_SH7780] = "SH7780",
424 [CPU_SH73180] = "SH73180", 406 [CPU_SH7781] = "SH7781", [CPU_SH7343] = "SH7343",
425 [CPU_ST40RA] = "ST40RA",
426 [CPU_ST40GX1] = "ST40GX1",
427 [CPU_SH4_202] = "SH4-202",
428 [CPU_SH4_501] = "SH4-501",
429 [CPU_SH7770] = "SH7770",
430 [CPU_SH7780] = "SH7780",
431 [CPU_SH7781] = "SH7781",
432 [CPU_SH_NONE] = "Unknown" 407 [CPU_SH_NONE] = "Unknown"
433}; 408};
434 409
@@ -438,8 +413,10 @@ const char *get_cpu_subtype(void)
438} 413}
439 414
440#ifdef CONFIG_PROC_FS 415#ifdef CONFIG_PROC_FS
416/* Symbolic CPU flags, keep in sync with asm/cpu-features.h */
441static const char *cpu_flags[] = { 417static const char *cpu_flags[] = {
442 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr", "ptea", NULL 418 "none", "fpu", "p2flush", "mmuassoc", "dsp", "perfctr",
419 "ptea", "llsc", "l2", NULL
443}; 420};
444 421
445static void show_cpuflags(struct seq_file *m) 422static void show_cpuflags(struct seq_file *m)
@@ -460,7 +437,8 @@ static void show_cpuflags(struct seq_file *m)
460 seq_printf(m, "\n"); 437 seq_printf(m, "\n");
461} 438}
462 439
463static void show_cacheinfo(struct seq_file *m, const char *type, struct cache_info info) 440static void show_cacheinfo(struct seq_file *m, const char *type,
441 struct cache_info info)
464{ 442{
465 unsigned int cache_size; 443 unsigned int cache_size;
466 444
@@ -493,7 +471,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
493 * unified cache on the SH-2 and SH-3, as well as the harvard 471 * unified cache on the SH-2 and SH-3, as well as the harvard
494 * style cache on the SH-4. 472 * style cache on the SH-4.
495 */ 473 */
496 if (test_bit(SH_CACHE_COMBINED, &(boot_cpu_data.icache.flags))) { 474 if (boot_cpu_data.icache.flags & SH_CACHE_COMBINED) {
497 seq_printf(m, "unified\n"); 475 seq_printf(m, "unified\n");
498 show_cacheinfo(m, "cache", boot_cpu_data.icache); 476 show_cacheinfo(m, "cache", boot_cpu_data.icache);
499 } else { 477 } else {
@@ -502,6 +480,10 @@ static int show_cpuinfo(struct seq_file *m, void *v)
502 show_cacheinfo(m, "dcache", boot_cpu_data.dcache); 480 show_cacheinfo(m, "dcache", boot_cpu_data.dcache);
503 } 481 }
504 482
483 /* Optional secondary cache */
484 if (boot_cpu_data.flags & CPU_HAS_L2_CACHE)
485 show_cacheinfo(m, "scache", boot_cpu_data.scache);
486
505 seq_printf(m, "bogomips\t: %lu.%02lu\n", 487 seq_printf(m, "bogomips\t: %lu.%02lu\n",
506 boot_cpu_data.loops_per_jiffy/(500000/HZ), 488 boot_cpu_data.loops_per_jiffy/(500000/HZ),
507 (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100); 489 (boot_cpu_data.loops_per_jiffy/(5000/HZ)) % 100);
@@ -617,4 +599,3 @@ static int __init kgdb_parse_options(char *options)
617} 599}
618__setup("kgdb=", kgdb_parse_options); 600__setup("kgdb=", kgdb_parse_options);
619#endif /* CONFIG_SH_KGDB */ 601#endif /* CONFIG_SH_KGDB */
620
diff --git a/arch/sh/kernel/sh_ksyms.c b/arch/sh/kernel/sh_ksyms.c
index 245ed8f945e8..d3cbfa2ad4a7 100644
--- a/arch/sh/kernel/sh_ksyms.c
+++ b/arch/sh/kernel/sh_ksyms.c
@@ -27,21 +27,11 @@ EXPORT_SYMBOL(sh_mv);
27 27
28/* platform dependent support */ 28/* platform dependent support */
29EXPORT_SYMBOL(dump_fpu); 29EXPORT_SYMBOL(dump_fpu);
30EXPORT_SYMBOL(iounmap);
31EXPORT_SYMBOL(enable_irq);
32EXPORT_SYMBOL(disable_irq);
33EXPORT_SYMBOL(probe_irq_mask);
34EXPORT_SYMBOL(kernel_thread); 30EXPORT_SYMBOL(kernel_thread);
35EXPORT_SYMBOL(disable_irq_nosync);
36EXPORT_SYMBOL(irq_desc); 31EXPORT_SYMBOL(irq_desc);
37EXPORT_SYMBOL(no_irq_type); 32EXPORT_SYMBOL(no_irq_type);
38 33
39EXPORT_SYMBOL(strstr);
40EXPORT_SYMBOL(strlen); 34EXPORT_SYMBOL(strlen);
41EXPORT_SYMBOL(strnlen);
42EXPORT_SYMBOL(strchr);
43EXPORT_SYMBOL(strcat);
44EXPORT_SYMBOL(strncat);
45 35
46/* PCI exports */ 36/* PCI exports */
47#ifdef CONFIG_PCI 37#ifdef CONFIG_PCI
@@ -52,13 +42,8 @@ EXPORT_SYMBOL(pci_free_consistent);
52/* mem exports */ 42/* mem exports */
53EXPORT_SYMBOL(memchr); 43EXPORT_SYMBOL(memchr);
54EXPORT_SYMBOL(memcpy); 44EXPORT_SYMBOL(memcpy);
55EXPORT_SYMBOL(memcpy_fromio);
56EXPORT_SYMBOL(memcpy_toio);
57EXPORT_SYMBOL(memset); 45EXPORT_SYMBOL(memset);
58EXPORT_SYMBOL(memset_io);
59EXPORT_SYMBOL(memmove); 46EXPORT_SYMBOL(memmove);
60EXPORT_SYMBOL(memcmp);
61EXPORT_SYMBOL(memscan);
62EXPORT_SYMBOL(__copy_user); 47EXPORT_SYMBOL(__copy_user);
63EXPORT_SYMBOL(boot_cpu_data); 48EXPORT_SYMBOL(boot_cpu_data);
64 49
@@ -94,7 +79,9 @@ EXPORT_SYMBOL(strcpy);
94DECLARE_EXPORT(__movstr_i4_even); 79DECLARE_EXPORT(__movstr_i4_even);
95DECLARE_EXPORT(__movstr_i4_odd); 80DECLARE_EXPORT(__movstr_i4_odd);
96DECLARE_EXPORT(__movstrSI12_i4); 81DECLARE_EXPORT(__movstrSI12_i4);
82#endif
97 83
84#if defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)
98/* needed by some modules */ 85/* needed by some modules */
99EXPORT_SYMBOL(flush_cache_all); 86EXPORT_SYMBOL(flush_cache_all);
100EXPORT_SYMBOL(flush_cache_range); 87EXPORT_SYMBOL(flush_cache_range);
@@ -102,11 +89,9 @@ EXPORT_SYMBOL(flush_dcache_page);
102EXPORT_SYMBOL(__flush_purge_region); 89EXPORT_SYMBOL(__flush_purge_region);
103#endif 90#endif
104 91
105#if defined(CONFIG_SH7705_CACHE_32KB) 92#if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
106EXPORT_SYMBOL(flush_cache_all); 93 defined(CONFIG_SH7705_CACHE_32KB))
107EXPORT_SYMBOL(flush_cache_range); 94EXPORT_SYMBOL(clear_user_page);
108EXPORT_SYMBOL(flush_dcache_page);
109EXPORT_SYMBOL(__flush_purge_region);
110#endif 95#endif
111 96
112EXPORT_SYMBOL(flush_tlb_page); 97EXPORT_SYMBOL(flush_tlb_page);
@@ -116,7 +101,12 @@ EXPORT_SYMBOL(__down_trylock);
116EXPORT_SYMBOL(synchronize_irq); 101EXPORT_SYMBOL(synchronize_irq);
117#endif 102#endif
118 103
104#ifdef CONFIG_PM
105EXPORT_SYMBOL(pm_suspend);
106#endif
107
119EXPORT_SYMBOL(csum_partial); 108EXPORT_SYMBOL(csum_partial);
109#ifdef CONFIG_IPV6
120EXPORT_SYMBOL(csum_ipv6_magic); 110EXPORT_SYMBOL(csum_ipv6_magic);
121EXPORT_SYMBOL(consistent_sync); 111#endif
122EXPORT_SYMBOL(clear_page); 112EXPORT_SYMBOL(clear_page);
diff --git a/arch/sh/kernel/signal.c b/arch/sh/kernel/signal.c
index b475c4d2405f..5213f5bc6ce0 100644
--- a/arch/sh/kernel/signal.c
+++ b/arch/sh/kernel/signal.c
@@ -8,7 +8,6 @@
8 * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima 8 * SuperH version: Copyright (C) 1999, 2000 Niibe Yutaka & Kaz Kojima
9 * 9 *
10 */ 10 */
11
12#include <linux/sched.h> 11#include <linux/sched.h>
13#include <linux/mm.h> 12#include <linux/mm.h>
14#include <linux/smp.h> 13#include <linux/smp.h>
@@ -21,6 +20,7 @@
21#include <linux/unistd.h> 20#include <linux/unistd.h>
22#include <linux/stddef.h> 21#include <linux/stddef.h>
23#include <linux/tty.h> 22#include <linux/tty.h>
23#include <linux/elf.h>
24#include <linux/personality.h> 24#include <linux/personality.h>
25#include <linux/binfmts.h> 25#include <linux/binfmts.h>
26 26
@@ -29,12 +29,8 @@
29#include <asm/pgtable.h> 29#include <asm/pgtable.h>
30#include <asm/cacheflush.h> 30#include <asm/cacheflush.h>
31 31
32#define DEBUG_SIG 0
33
34#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) 32#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
35 33
36asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
37
38/* 34/*
39 * Atomically swap in the new signal mask, and wait for a signal. 35 * Atomically swap in the new signal mask, and wait for a signal.
40 */ 36 */
@@ -43,51 +39,17 @@ sys_sigsuspend(old_sigset_t mask,
43 unsigned long r5, unsigned long r6, unsigned long r7, 39 unsigned long r5, unsigned long r6, unsigned long r7,
44 struct pt_regs regs) 40 struct pt_regs regs)
45{ 41{
46 sigset_t saveset;
47
48 mask &= _BLOCKABLE; 42 mask &= _BLOCKABLE;
49 spin_lock_irq(&current->sighand->siglock); 43 spin_lock_irq(&current->sighand->siglock);
50 saveset = current->blocked; 44 current->saved_sigmask = current->blocked;
51 siginitset(&current->blocked, mask); 45 siginitset(&current->blocked, mask);
52 recalc_sigpending(); 46 recalc_sigpending();
53 spin_unlock_irq(&current->sighand->siglock); 47 spin_unlock_irq(&current->sighand->siglock);
54 48
55 regs.regs[0] = -EINTR; 49 current->state = TASK_INTERRUPTIBLE;
56 while (1) { 50 schedule();
57 current->state = TASK_INTERRUPTIBLE; 51 set_thread_flag(TIF_RESTORE_SIGMASK);
58 schedule(); 52 return -ERESTARTNOHAND;
59 if (do_signal(&regs, &saveset))
60 return -EINTR;
61 }
62}
63
64asmlinkage int
65sys_rt_sigsuspend(sigset_t *unewset, size_t sigsetsize,
66 unsigned long r6, unsigned long r7,
67 struct pt_regs regs)
68{
69 sigset_t saveset, newset;
70
71 /* XXX: Don't preclude handling different sized sigset_t's. */
72 if (sigsetsize != sizeof(sigset_t))
73 return -EINVAL;
74
75 if (copy_from_user(&newset, unewset, sizeof(newset)))
76 return -EFAULT;
77 sigdelsetmask(&newset, ~_BLOCKABLE);
78 spin_lock_irq(&current->sighand->siglock);
79 saveset = current->blocked;
80 current->blocked = newset;
81 recalc_sigpending();
82 spin_unlock_irq(&current->sighand->siglock);
83
84 regs.regs[0] = -EINTR;
85 while (1) {
86 current->state = TASK_INTERRUPTIBLE;
87 schedule();
88 if (do_signal(&regs, &saveset))
89 return -EINTR;
90 }
91} 53}
92 54
93asmlinkage int 55asmlinkage int
@@ -348,7 +310,12 @@ get_sigframe(struct k_sigaction *ka, unsigned long sp, size_t frame_size)
348 return (void __user *)((sp - frame_size) & -8ul); 310 return (void __user *)((sp - frame_size) & -8ul);
349} 311}
350 312
351static void setup_frame(int sig, struct k_sigaction *ka, 313/* These symbols are defined with the addresses in the vsyscall page.
314 See vsyscall-trapa.S. */
315extern void __user __kernel_sigreturn;
316extern void __user __kernel_rt_sigreturn;
317
318static int setup_frame(int sig, struct k_sigaction *ka,
352 sigset_t *set, struct pt_regs *regs) 319 sigset_t *set, struct pt_regs *regs)
353{ 320{
354 struct sigframe __user *frame; 321 struct sigframe __user *frame;
@@ -368,15 +335,18 @@ static void setup_frame(int sig, struct k_sigaction *ka,
368 335
369 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]); 336 err |= setup_sigcontext(&frame->sc, regs, set->sig[0]);
370 337
371 if (_NSIG_WORDS > 1) { 338 if (_NSIG_WORDS > 1)
372 err |= __copy_to_user(frame->extramask, &set->sig[1], 339 err |= __copy_to_user(frame->extramask, &set->sig[1],
373 sizeof(frame->extramask)); 340 sizeof(frame->extramask));
374 }
375 341
376 /* Set up to return from userspace. If provided, use a stub 342 /* Set up to return from userspace. If provided, use a stub
377 already in userspace. */ 343 already in userspace. */
378 if (ka->sa.sa_flags & SA_RESTORER) { 344 if (ka->sa.sa_flags & SA_RESTORER) {
379 regs->pr = (unsigned long) ka->sa.sa_restorer; 345 regs->pr = (unsigned long) ka->sa.sa_restorer;
346#ifdef CONFIG_VSYSCALL
347 } else if (likely(current->mm->context.vdso)) {
348 regs->pr = VDSO_SYM(&__kernel_sigreturn);
349#endif
380 } else { 350 } else {
381 /* Generate return code (system call to sigreturn) */ 351 /* Generate return code (system call to sigreturn) */
382 err |= __put_user(MOVW(7), &frame->retcode[0]); 352 err |= __put_user(MOVW(7), &frame->retcode[0]);
@@ -402,21 +372,22 @@ static void setup_frame(int sig, struct k_sigaction *ka,
402 372
403 set_fs(USER_DS); 373 set_fs(USER_DS);
404 374
405#if DEBUG_SIG 375 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
406 printk("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n", 376 current->comm, current->pid, frame, regs->pc, regs->pr);
407 current->comm, current->pid, frame, regs->pc, regs->pr);
408#endif
409 377
410 flush_cache_sigtramp(regs->pr); 378 flush_cache_sigtramp(regs->pr);
379
411 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode)) 380 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
412 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES); 381 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
413 return; 382
383 return 0;
414 384
415give_sigsegv: 385give_sigsegv:
416 force_sigsegv(sig, current); 386 force_sigsegv(sig, current);
387 return -EFAULT;
417} 388}
418 389
419static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 390static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
420 sigset_t *set, struct pt_regs *regs) 391 sigset_t *set, struct pt_regs *regs)
421{ 392{
422 struct rt_sigframe __user *frame; 393 struct rt_sigframe __user *frame;
@@ -452,6 +423,10 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
452 already in userspace. */ 423 already in userspace. */
453 if (ka->sa.sa_flags & SA_RESTORER) { 424 if (ka->sa.sa_flags & SA_RESTORER) {
454 regs->pr = (unsigned long) ka->sa.sa_restorer; 425 regs->pr = (unsigned long) ka->sa.sa_restorer;
426#ifdef CONFIG_VSYSCALL
427 } else if (likely(current->mm->context.vdso)) {
428 regs->pr = VDSO_SYM(&__kernel_rt_sigreturn);
429#endif
455 } else { 430 } else {
456 /* Generate return code (system call to rt_sigreturn) */ 431 /* Generate return code (system call to rt_sigreturn) */
457 err |= __put_user(MOVW(7), &frame->retcode[0]); 432 err |= __put_user(MOVW(7), &frame->retcode[0]);
@@ -477,28 +452,31 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
477 452
478 set_fs(USER_DS); 453 set_fs(USER_DS);
479 454
480#if DEBUG_SIG 455 pr_debug("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n",
481 printk("SIG deliver (%s:%d): sp=%p pc=%08lx pr=%08lx\n", 456 current->comm, current->pid, frame, regs->pc, regs->pr);
482 current->comm, current->pid, frame, regs->pc, regs->pr);
483#endif
484 457
485 flush_cache_sigtramp(regs->pr); 458 flush_cache_sigtramp(regs->pr);
459
486 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode)) 460 if ((-regs->pr & (L1_CACHE_BYTES-1)) < sizeof(frame->retcode))
487 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES); 461 flush_cache_sigtramp(regs->pr + L1_CACHE_BYTES);
488 return; 462
463 return 0;
489 464
490give_sigsegv: 465give_sigsegv:
491 force_sigsegv(sig, current); 466 force_sigsegv(sig, current);
467 return -EFAULT;
492} 468}
493 469
494/* 470/*
495 * OK, we're invoking a handler 471 * OK, we're invoking a handler
496 */ 472 */
497 473
498static void 474static int
499handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info, 475handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
500 sigset_t *oldset, struct pt_regs *regs) 476 sigset_t *oldset, struct pt_regs *regs)
501{ 477{
478 int ret;
479
502 /* Are we from a system call? */ 480 /* Are we from a system call? */
503 if (regs->tra >= 0) { 481 if (regs->tra >= 0) {
504 /* If so, check system call restarting.. */ 482 /* If so, check system call restarting.. */
@@ -539,19 +517,23 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
539 517
540 /* Set up the stack frame */ 518 /* Set up the stack frame */
541 if (ka->sa.sa_flags & SA_SIGINFO) 519 if (ka->sa.sa_flags & SA_SIGINFO)
542 setup_rt_frame(sig, ka, info, oldset, regs); 520 ret = setup_rt_frame(sig, ka, info, oldset, regs);
543 else 521 else
544 setup_frame(sig, ka, oldset, regs); 522 ret = setup_frame(sig, ka, oldset, regs);
545 523
546 if (ka->sa.sa_flags & SA_ONESHOT) 524 if (ka->sa.sa_flags & SA_ONESHOT)
547 ka->sa.sa_handler = SIG_DFL; 525 ka->sa.sa_handler = SIG_DFL;
548 526
549 spin_lock_irq(&current->sighand->siglock); 527 if (ret == 0) {
550 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask); 528 spin_lock_irq(&current->sighand->siglock);
551 if (!(ka->sa.sa_flags & SA_NODEFER)) 529 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
552 sigaddset(&current->blocked,sig); 530 if (!(ka->sa.sa_flags & SA_NODEFER))
553 recalc_sigpending(); 531 sigaddset(&current->blocked,sig);
554 spin_unlock_irq(&current->sighand->siglock); 532 recalc_sigpending();
533 spin_unlock_irq(&current->sighand->siglock);
534 }
535
536 return ret;
555} 537}
556 538
557/* 539/*
@@ -563,11 +545,12 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
563 * the kernel can handle, and then we build all the user-level signal handling 545 * the kernel can handle, and then we build all the user-level signal handling
564 * stack-frames in one go after that. 546 * stack-frames in one go after that.
565 */ 547 */
566int do_signal(struct pt_regs *regs, sigset_t *oldset) 548static void do_signal(struct pt_regs *regs, unsigned int save_r0)
567{ 549{
568 siginfo_t info; 550 siginfo_t info;
569 int signr; 551 int signr;
570 struct k_sigaction ka; 552 struct k_sigaction ka;
553 sigset_t *oldset;
571 554
572 /* 555 /*
573 * We want the common case to go fast, which 556 * We want the common case to go fast, which
@@ -576,19 +559,27 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
576 * if so. 559 * if so.
577 */ 560 */
578 if (!user_mode(regs)) 561 if (!user_mode(regs))
579 return 1; 562 return;
580 563
581 if (try_to_freeze()) 564 if (try_to_freeze())
582 goto no_signal; 565 goto no_signal;
583 566
584 if (!oldset) 567 if (test_thread_flag(TIF_RESTORE_SIGMASK))
568 oldset = &current->saved_sigmask;
569 else
585 oldset = &current->blocked; 570 oldset = &current->blocked;
586 571
587 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 572 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
588 if (signr > 0) { 573 if (signr > 0) {
589 /* Whee! Actually deliver the signal. */ 574 /* Whee! Actually deliver the signal. */
590 handle_signal(signr, &ka, &info, oldset, regs); 575 if (handle_signal(signr, &ka, &info, oldset, regs) == 0) {
591 return 1; 576 /* a signal was successfully delivered; the saved
577 * sigmask will have been stored in the signal frame,
578 * and will be restored by sigreturn, so we can simply
579 * clear the TIF_RESTORE_SIGMASK flag */
580 if (test_thread_flag(TIF_RESTORE_SIGMASK))
581 clear_thread_flag(TIF_RESTORE_SIGMASK);
582 }
592 } 583 }
593 584
594 no_signal: 585 no_signal:
@@ -597,10 +588,27 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
597 /* Restart the system call - no handlers present */ 588 /* Restart the system call - no handlers present */
598 if (regs->regs[0] == -ERESTARTNOHAND || 589 if (regs->regs[0] == -ERESTARTNOHAND ||
599 regs->regs[0] == -ERESTARTSYS || 590 regs->regs[0] == -ERESTARTSYS ||
600 regs->regs[0] == -ERESTARTNOINTR || 591 regs->regs[0] == -ERESTARTNOINTR) {
601 regs->regs[0] == -ERESTART_RESTARTBLOCK) { 592 regs->regs[0] = save_r0;
593 regs->pc -= 2;
594 } else if (regs->regs[0] == -ERESTART_RESTARTBLOCK) {
602 regs->pc -= 2; 595 regs->pc -= 2;
596 regs->regs[3] = __NR_restart_syscall;
603 } 597 }
604 } 598 }
605 return 0; 599
600 /* if there's no signal to deliver, we just put the saved sigmask
601 * back */
602 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
603 clear_thread_flag(TIF_RESTORE_SIGMASK);
604 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
605 }
606}
607
608asmlinkage void do_notify_resume(struct pt_regs *regs, unsigned int save_r0,
609 __u32 thread_info_flags)
610{
611 /* deal with pending signal delivery */
612 if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
613 do_signal(regs, save_r0);
606} 614}
diff --git a/arch/sh/kernel/sys_sh.c b/arch/sh/kernel/sys_sh.c
index 917b2f32f260..b68ff705f067 100644
--- a/arch/sh/kernel/sys_sh.c
+++ b/arch/sh/kernel/sys_sh.c
@@ -21,7 +21,8 @@
21#include <linux/mman.h> 21#include <linux/mman.h>
22#include <linux/file.h> 22#include <linux/file.h>
23#include <linux/utsname.h> 23#include <linux/utsname.h>
24 24#include <linux/module.h>
25#include <asm/cacheflush.h>
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include <asm/ipc.h> 27#include <asm/ipc.h>
27 28
@@ -44,11 +45,16 @@ asmlinkage int sys_pipe(unsigned long r4, unsigned long r5,
44 return error; 45 return error;
45} 46}
46 47
47#if defined(HAVE_ARCH_UNMAPPED_AREA) 48unsigned long shm_align_mask = PAGE_SIZE - 1; /* Sane caches */
49
50EXPORT_SYMBOL(shm_align_mask);
51
48/* 52/*
49 * To avoid cache alias, we map the shard page with same color. 53 * To avoid cache aliases, we map the shared page with same color.
50 */ 54 */
51#define COLOUR_ALIGN(addr) (((addr)+SHMLBA-1)&~(SHMLBA-1)) 55#define COLOUR_ALIGN(addr, pgoff) \
56 ((((addr) + shm_align_mask) & ~shm_align_mask) + \
57 (((pgoff) << PAGE_SHIFT) & shm_align_mask))
52 58
53unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, 59unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
54 unsigned long len, unsigned long pgoff, unsigned long flags) 60 unsigned long len, unsigned long pgoff, unsigned long flags)
@@ -56,43 +62,52 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
56 struct mm_struct *mm = current->mm; 62 struct mm_struct *mm = current->mm;
57 struct vm_area_struct *vma; 63 struct vm_area_struct *vma;
58 unsigned long start_addr; 64 unsigned long start_addr;
65 int do_colour_align;
59 66
60 if (flags & MAP_FIXED) { 67 if (flags & MAP_FIXED) {
61 /* We do not accept a shared mapping if it would violate 68 /* We do not accept a shared mapping if it would violate
62 * cache aliasing constraints. 69 * cache aliasing constraints.
63 */ 70 */
64 if ((flags & MAP_SHARED) && (addr & (SHMLBA - 1))) 71 if ((flags & MAP_SHARED) && (addr & shm_align_mask))
65 return -EINVAL; 72 return -EINVAL;
66 return addr; 73 return addr;
67 } 74 }
68 75
69 if (len > TASK_SIZE) 76 if (unlikely(len > TASK_SIZE))
70 return -ENOMEM; 77 return -ENOMEM;
71 78
79 do_colour_align = 0;
80 if (filp || (flags & MAP_SHARED))
81 do_colour_align = 1;
82
72 if (addr) { 83 if (addr) {
73 if (flags & MAP_PRIVATE) 84 if (do_colour_align)
74 addr = PAGE_ALIGN(addr); 85 addr = COLOUR_ALIGN(addr, pgoff);
75 else 86 else
76 addr = COLOUR_ALIGN(addr); 87 addr = PAGE_ALIGN(addr);
88
77 vma = find_vma(mm, addr); 89 vma = find_vma(mm, addr);
78 if (TASK_SIZE - len >= addr && 90 if (TASK_SIZE - len >= addr &&
79 (!vma || addr + len <= vma->vm_start)) 91 (!vma || addr + len <= vma->vm_start))
80 return addr; 92 return addr;
81 } 93 }
82 if (len <= mm->cached_hole_size) { 94
95 if (len > mm->cached_hole_size) {
96 start_addr = addr = mm->free_area_cache;
97 } else {
83 mm->cached_hole_size = 0; 98 mm->cached_hole_size = 0;
84 mm->free_area_cache = TASK_UNMAPPED_BASE; 99 start_addr = addr = TASK_UNMAPPED_BASE;
85 } 100 }
86 if (flags & MAP_PRIVATE)
87 addr = PAGE_ALIGN(mm->free_area_cache);
88 else
89 addr = COLOUR_ALIGN(mm->free_area_cache);
90 start_addr = addr;
91 101
92full_search: 102full_search:
103 if (do_colour_align)
104 addr = COLOUR_ALIGN(addr, pgoff);
105 else
106 addr = PAGE_ALIGN(mm->free_area_cache);
107
93 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) { 108 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
94 /* At this point: (!vma || addr < vma->vm_end). */ 109 /* At this point: (!vma || addr < vma->vm_end). */
95 if (TASK_SIZE - len < addr) { 110 if (unlikely(TASK_SIZE - len < addr)) {
96 /* 111 /*
97 * Start a new search - just in case we missed 112 * Start a new search - just in case we missed
98 * some holes. 113 * some holes.
@@ -104,7 +119,7 @@ full_search:
104 } 119 }
105 return -ENOMEM; 120 return -ENOMEM;
106 } 121 }
107 if (!vma || addr + len <= vma->vm_start) { 122 if (likely(!vma || addr + len <= vma->vm_start)) {
108 /* 123 /*
109 * Remember the place where we stopped the search: 124 * Remember the place where we stopped the search:
110 */ 125 */
@@ -115,11 +130,10 @@ full_search:
115 mm->cached_hole_size = vma->vm_start - addr; 130 mm->cached_hole_size = vma->vm_start - addr;
116 131
117 addr = vma->vm_end; 132 addr = vma->vm_end;
118 if (!(flags & MAP_PRIVATE)) 133 if (do_colour_align)
119 addr = COLOUR_ALIGN(addr); 134 addr = COLOUR_ALIGN(addr, pgoff);
120 } 135 }
121} 136}
122#endif
123 137
124static inline long 138static inline long
125do_mmap2(unsigned long addr, unsigned long len, unsigned long prot, 139do_mmap2(unsigned long addr, unsigned long len, unsigned long prot,
diff --git a/arch/sh/kernel/syscalls.S b/arch/sh/kernel/syscalls.S
new file mode 100644
index 000000000000..768334e95075
--- /dev/null
+++ b/arch/sh/kernel/syscalls.S
@@ -0,0 +1,353 @@
1/*
2 * arch/sh/kernel/syscalls.S
3 *
4 * System call table for SuperH
5 *
6 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
7 * Copyright (C) 2003 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 *
13 */
14#include <linux/sys.h>
15#include <linux/linkage.h>
16
17#if !defined(CONFIG_NFSD) && !defined(CONFIG_NFSD_MODULE)
18#define sys_nfsservctl sys_ni_syscall
19#endif
20
21#if !defined(CONFIG_MMU)
22#define sys_madvise sys_ni_syscall
23#define sys_readahead sys_ni_syscall
24#define sys_mprotect sys_ni_syscall
25#define sys_msync sys_ni_syscall
26#define sys_mlock sys_ni_syscall
27#define sys_munlock sys_ni_syscall
28#define sys_mlockall sys_ni_syscall
29#define sys_munlockall sys_ni_syscall
30#define sys_mremap sys_ni_syscall
31#define sys_mincore sys_ni_syscall
32#define sys_remap_file_pages sys_ni_syscall
33#endif
34
35 .data
36ENTRY(sys_call_table)
37 .long sys_restart_syscall /* 0 - old "setup()" system call*/
38 .long sys_exit
39 .long sys_fork
40 .long sys_read
41 .long sys_write
42 .long sys_open /* 5 */
43 .long sys_close
44 .long sys_waitpid
45 .long sys_creat
46 .long sys_link
47 .long sys_unlink /* 10 */
48 .long sys_execve
49 .long sys_chdir
50 .long sys_time
51 .long sys_mknod
52 .long sys_chmod /* 15 */
53 .long sys_lchown16
54 .long sys_ni_syscall /* old break syscall holder */
55 .long sys_stat
56 .long sys_lseek
57 .long sys_getpid /* 20 */
58 .long sys_mount
59 .long sys_oldumount
60 .long sys_setuid16
61 .long sys_getuid16
62 .long sys_stime /* 25 */
63 .long sys_ptrace
64 .long sys_alarm
65 .long sys_fstat
66 .long sys_pause
67 .long sys_utime /* 30 */
68 .long sys_ni_syscall /* old stty syscall holder */
69 .long sys_ni_syscall /* old gtty syscall holder */
70 .long sys_access
71 .long sys_nice
72 .long sys_ni_syscall /* 35 */ /* old ftime syscall holder */
73 .long sys_sync
74 .long sys_kill
75 .long sys_rename
76 .long sys_mkdir
77 .long sys_rmdir /* 40 */
78 .long sys_dup
79 .long sys_pipe
80 .long sys_times
81 .long sys_ni_syscall /* old prof syscall holder */
82 .long sys_brk /* 45 */
83 .long sys_setgid16
84 .long sys_getgid16
85 .long sys_signal
86 .long sys_geteuid16
87 .long sys_getegid16 /* 50 */
88 .long sys_acct
89 .long sys_umount /* recycled never used phys() */
90 .long sys_ni_syscall /* old lock syscall holder */
91 .long sys_ioctl
92 .long sys_fcntl /* 55 */
93 .long sys_ni_syscall /* old mpx syscall holder */
94 .long sys_setpgid
95 .long sys_ni_syscall /* old ulimit syscall holder */
96 .long sys_ni_syscall /* sys_olduname */
97 .long sys_umask /* 60 */
98 .long sys_chroot
99 .long sys_ustat
100 .long sys_dup2
101 .long sys_getppid
102 .long sys_getpgrp /* 65 */
103 .long sys_setsid
104 .long sys_sigaction
105 .long sys_sgetmask
106 .long sys_ssetmask
107 .long sys_setreuid16 /* 70 */
108 .long sys_setregid16
109 .long sys_sigsuspend
110 .long sys_sigpending
111 .long sys_sethostname
112 .long sys_setrlimit /* 75 */
113 .long sys_old_getrlimit
114 .long sys_getrusage
115 .long sys_gettimeofday
116 .long sys_settimeofday
117 .long sys_getgroups16 /* 80 */
118 .long sys_setgroups16
119 .long sys_ni_syscall /* sys_oldselect */
120 .long sys_symlink
121 .long sys_lstat
122 .long sys_readlink /* 85 */
123 .long sys_uselib
124 .long sys_swapon
125 .long sys_reboot
126 .long old_readdir
127 .long old_mmap /* 90 */
128 .long sys_munmap
129 .long sys_truncate
130 .long sys_ftruncate
131 .long sys_fchmod
132 .long sys_fchown16 /* 95 */
133 .long sys_getpriority
134 .long sys_setpriority
135 .long sys_ni_syscall /* old profil syscall holder */
136 .long sys_statfs
137 .long sys_fstatfs /* 100 */
138 .long sys_ni_syscall /* ioperm */
139 .long sys_socketcall
140 .long sys_syslog
141 .long sys_setitimer
142 .long sys_getitimer /* 105 */
143 .long sys_newstat
144 .long sys_newlstat
145 .long sys_newfstat
146 .long sys_uname
147 .long sys_ni_syscall /* 110 */ /* iopl */
148 .long sys_vhangup
149 .long sys_ni_syscall /* idle */
150 .long sys_ni_syscall /* vm86old */
151 .long sys_wait4
152 .long sys_swapoff /* 115 */
153 .long sys_sysinfo
154 .long sys_ipc
155 .long sys_fsync
156 .long sys_sigreturn
157 .long sys_clone /* 120 */
158 .long sys_setdomainname
159 .long sys_newuname
160 .long sys_ni_syscall /* sys_modify_ldt */
161 .long sys_adjtimex
162 .long sys_mprotect /* 125 */
163 .long sys_sigprocmask
164 .long sys_ni_syscall /* old "create_module" */
165 .long sys_init_module
166 .long sys_delete_module
167 .long sys_ni_syscall /* 130: old "get_kernel_syms" */
168 .long sys_quotactl
169 .long sys_getpgid
170 .long sys_fchdir
171 .long sys_bdflush
172 .long sys_sysfs /* 135 */
173 .long sys_personality
174 .long sys_ni_syscall /* for afs_syscall */
175 .long sys_setfsuid16
176 .long sys_setfsgid16
177 .long sys_llseek /* 140 */
178 .long sys_getdents
179 .long sys_select
180 .long sys_flock
181 .long sys_msync
182 .long sys_readv /* 145 */
183 .long sys_writev
184 .long sys_getsid
185 .long sys_fdatasync
186 .long sys_sysctl
187 .long sys_mlock /* 150 */
188 .long sys_munlock
189 .long sys_mlockall
190 .long sys_munlockall
191 .long sys_sched_setparam
192 .long sys_sched_getparam /* 155 */
193 .long sys_sched_setscheduler
194 .long sys_sched_getscheduler
195 .long sys_sched_yield
196 .long sys_sched_get_priority_max
197 .long sys_sched_get_priority_min /* 160 */
198 .long sys_sched_rr_get_interval
199 .long sys_nanosleep
200 .long sys_mremap
201 .long sys_setresuid16
202 .long sys_getresuid16 /* 165 */
203 .long sys_ni_syscall /* vm86 */
204 .long sys_ni_syscall /* old "query_module" */
205 .long sys_poll
206 .long sys_nfsservctl
207 .long sys_setresgid16 /* 170 */
208 .long sys_getresgid16
209 .long sys_prctl
210 .long sys_rt_sigreturn
211 .long sys_rt_sigaction
212 .long sys_rt_sigprocmask /* 175 */
213 .long sys_rt_sigpending
214 .long sys_rt_sigtimedwait
215 .long sys_rt_sigqueueinfo
216 .long sys_rt_sigsuspend
217 .long sys_pread_wrapper /* 180 */
218 .long sys_pwrite_wrapper
219 .long sys_chown16
220 .long sys_getcwd
221 .long sys_capget
222 .long sys_capset /* 185 */
223 .long sys_sigaltstack
224 .long sys_sendfile
225 .long sys_ni_syscall /* streams1 */
226 .long sys_ni_syscall /* streams2 */
227 .long sys_vfork /* 190 */
228 .long sys_getrlimit
229 .long sys_mmap2
230 .long sys_truncate64
231 .long sys_ftruncate64
232 .long sys_stat64 /* 195 */
233 .long sys_lstat64
234 .long sys_fstat64
235 .long sys_lchown
236 .long sys_getuid
237 .long sys_getgid /* 200 */
238 .long sys_geteuid
239 .long sys_getegid
240 .long sys_setreuid
241 .long sys_setregid
242 .long sys_getgroups /* 205 */
243 .long sys_setgroups
244 .long sys_fchown
245 .long sys_setresuid
246 .long sys_getresuid
247 .long sys_setresgid /* 210 */
248 .long sys_getresgid
249 .long sys_chown
250 .long sys_setuid
251 .long sys_setgid
252 .long sys_setfsuid /* 215 */
253 .long sys_setfsgid
254 .long sys_pivot_root
255 .long sys_mincore
256 .long sys_madvise
257 .long sys_getdents64 /* 220 */
258 .long sys_fcntl64
259 .long sys_ni_syscall /* reserved for TUX */
260 .long sys_ni_syscall /* Reserved for Security */
261 .long sys_gettid
262 .long sys_readahead /* 225 */
263 .long sys_setxattr
264 .long sys_lsetxattr
265 .long sys_fsetxattr
266 .long sys_getxattr
267 .long sys_lgetxattr /* 230 */
268 .long sys_fgetxattr
269 .long sys_listxattr
270 .long sys_llistxattr
271 .long sys_flistxattr
272 .long sys_removexattr /* 235 */
273 .long sys_lremovexattr
274 .long sys_fremovexattr
275 .long sys_tkill
276 .long sys_sendfile64
277 .long sys_futex /* 240 */
278 .long sys_sched_setaffinity
279 .long sys_sched_getaffinity
280 .long sys_ni_syscall
281 .long sys_ni_syscall
282 .long sys_io_setup /* 245 */
283 .long sys_io_destroy
284 .long sys_io_getevents
285 .long sys_io_submit
286 .long sys_io_cancel
287 .long sys_fadvise64 /* 250 */
288 .long sys_ni_syscall
289 .long sys_exit_group
290 .long sys_lookup_dcookie
291 .long sys_epoll_create
292 .long sys_epoll_ctl /* 255 */
293 .long sys_epoll_wait
294 .long sys_remap_file_pages
295 .long sys_set_tid_address
296 .long sys_timer_create
297 .long sys_timer_settime /* 260 */
298 .long sys_timer_gettime
299 .long sys_timer_getoverrun
300 .long sys_timer_delete
301 .long sys_clock_settime
302 .long sys_clock_gettime /* 265 */
303 .long sys_clock_getres
304 .long sys_clock_nanosleep
305 .long sys_statfs64
306 .long sys_fstatfs64
307 .long sys_tgkill /* 270 */
308 .long sys_utimes
309 .long sys_fadvise64_64_wrapper
310 .long sys_ni_syscall /* Reserved for vserver */
311 .long sys_ni_syscall /* Reserved for mbind */
312 .long sys_ni_syscall /* 275 - get_mempolicy */
313 .long sys_ni_syscall /* set_mempolicy */
314 .long sys_mq_open
315 .long sys_mq_unlink
316 .long sys_mq_timedsend
317 .long sys_mq_timedreceive /* 280 */
318 .long sys_mq_notify
319 .long sys_mq_getsetattr
320 .long sys_kexec_load
321 .long sys_waitid
322 .long sys_ni_syscall /* 285 */
323 .long sys_add_key
324 .long sys_request_key
325 .long sys_keyctl
326 .long sys_ioprio_set
327 .long sys_ioprio_get /* 290 */
328 .long sys_inotify_init
329 .long sys_inotify_add_watch
330 .long sys_inotify_rm_watch
331 .long sys_migrate_pages
332 .long sys_openat /* 295 */
333 .long sys_mkdirat
334 .long sys_mknodat
335 .long sys_fchownat
336 .long sys_futimesat
337 .long sys_fstatat64 /* 300 */
338 .long sys_unlinkat
339 .long sys_renameat
340 .long sys_linkat
341 .long sys_symlinkat
342 .long sys_readlinkat /* 305 */
343 .long sys_fchmodat
344 .long sys_faccessat
345 .long sys_pselect6
346 .long sys_ppoll
347 .long sys_unshare /* 310 */
348 .long sys_set_robust_list
349 .long sys_get_robust_list
350 .long sys_splice
351 .long sys_sync_file_range
352 .long sys_tee /* 315 */
353 .long sys_vmsplice
diff --git a/arch/sh/kernel/time.c b/arch/sh/kernel/time.c
index a1589f85499d..149d9713eddf 100644
--- a/arch/sh/kernel/time.c
+++ b/arch/sh/kernel/time.c
@@ -3,13 +3,12 @@
3 * 3 *
4 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka 4 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
5 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> 5 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
6 * Copyright (C) 2002, 2003, 2004, 2005 Paul Mundt 6 * Copyright (C) 2002 - 2006 Paul Mundt
7 * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org> 7 * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org>
8 * 8 *
9 * Some code taken from i386 version. 9 * Some code taken from i386 version.
10 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 10 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
11 */ 11 */
12
13#include <linux/kernel.h> 12#include <linux/kernel.h>
14#include <linux/module.h> 13#include <linux/module.h>
15#include <linux/init.h> 14#include <linux/init.h>
@@ -26,15 +25,20 @@ struct sys_timer *sys_timer;
26DEFINE_SPINLOCK(rtc_lock); 25DEFINE_SPINLOCK(rtc_lock);
27EXPORT_SYMBOL(rtc_lock); 26EXPORT_SYMBOL(rtc_lock);
28 27
29/* XXX: Can we initialize this in a routine somewhere? Dreamcast doesn't want 28/* Dummy RTC ops */
30 * these routines anywhere... */ 29static void null_rtc_get_time(struct timespec *tv)
31#ifdef CONFIG_SH_RTC 30{
32void (*rtc_get_time)(struct timespec *) = sh_rtc_gettimeofday; 31 tv->tv_sec = mktime(2000, 1, 1, 0, 0, 0);
33int (*rtc_set_time)(const time_t) = sh_rtc_settimeofday; 32 tv->tv_nsec = 0;
34#else 33}
35void (*rtc_get_time)(struct timespec *); 34
36int (*rtc_set_time)(const time_t); 35static int null_rtc_set_time(const time_t secs)
37#endif 36{
37 return 0;
38}
39
40void (*rtc_sh_get_time)(struct timespec *) = null_rtc_get_time;
41int (*rtc_sh_set_time)(const time_t) = null_rtc_set_time;
38 42
39/* 43/*
40 * Scheduler clock - returns current time in nanosec units. 44 * Scheduler clock - returns current time in nanosec units.
@@ -70,7 +74,6 @@ void do_gettimeofday(struct timeval *tv)
70 tv->tv_sec = sec; 74 tv->tv_sec = sec;
71 tv->tv_usec = usec; 75 tv->tv_usec = usec;
72} 76}
73
74EXPORT_SYMBOL(do_gettimeofday); 77EXPORT_SYMBOL(do_gettimeofday);
75 78
76int do_settimeofday(struct timespec *tv) 79int do_settimeofday(struct timespec *tv)
@@ -103,7 +106,6 @@ int do_settimeofday(struct timespec *tv)
103 106
104 return 0; 107 return 0;
105} 108}
106
107EXPORT_SYMBOL(do_settimeofday); 109EXPORT_SYMBOL(do_settimeofday);
108 110
109/* last time the RTC clock got updated */ 111/* last time the RTC clock got updated */
@@ -135,7 +137,7 @@ void handle_timer_tick(struct pt_regs *regs)
135 xtime.tv_sec > last_rtc_update + 660 && 137 xtime.tv_sec > last_rtc_update + 660 &&
136 (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 && 138 (xtime.tv_nsec / 1000) >= 500000 - ((unsigned) TICK_SIZE) / 2 &&
137 (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) { 139 (xtime.tv_nsec / 1000) <= 500000 + ((unsigned) TICK_SIZE) / 2) {
138 if (rtc_set_time(xtime.tv_sec) == 0) 140 if (rtc_sh_set_time(xtime.tv_sec) == 0)
139 last_rtc_update = xtime.tv_sec; 141 last_rtc_update = xtime.tv_sec;
140 else 142 else
141 /* do it again in 60s */ 143 /* do it again in 60s */
@@ -143,8 +145,33 @@ void handle_timer_tick(struct pt_regs *regs)
143 } 145 }
144} 146}
145 147
148#ifdef CONFIG_PM
149int timer_suspend(struct sys_device *dev, pm_message_t state)
150{
151 struct sys_timer *sys_timer = container_of(dev, struct sys_timer, dev);
152
153 sys_timer->ops->stop();
154
155 return 0;
156}
157
158int timer_resume(struct sys_device *dev)
159{
160 struct sys_timer *sys_timer = container_of(dev, struct sys_timer, dev);
161
162 sys_timer->ops->start();
163
164 return 0;
165}
166#else
167#define timer_suspend NULL
168#define timer_resume NULL
169#endif
170
146static struct sysdev_class timer_sysclass = { 171static struct sysdev_class timer_sysclass = {
147 set_kset_name("timer"), 172 set_kset_name("timer"),
173 .suspend = timer_suspend,
174 .resume = timer_resume,
148}; 175};
149 176
150static int __init timer_init_sysfs(void) 177static int __init timer_init_sysfs(void)
@@ -156,7 +183,6 @@ static int __init timer_init_sysfs(void)
156 sys_timer->dev.cls = &timer_sysclass; 183 sys_timer->dev.cls = &timer_sysclass;
157 return sysdev_register(&sys_timer->dev); 184 return sysdev_register(&sys_timer->dev);
158} 185}
159
160device_initcall(timer_init_sysfs); 186device_initcall(timer_init_sysfs);
161 187
162void (*board_time_init)(void); 188void (*board_time_init)(void);
@@ -168,15 +194,9 @@ void __init time_init(void)
168 194
169 clk_init(); 195 clk_init();
170 196
171 if (rtc_get_time) { 197 rtc_sh_get_time(&xtime);
172 rtc_get_time(&xtime); 198 set_normalized_timespec(&wall_to_monotonic,
173 } else { 199 -xtime.tv_sec, -xtime.tv_nsec);
174 xtime.tv_sec = mktime(2000, 1, 1, 0, 0, 0);
175 xtime.tv_nsec = 0;
176 }
177
178 set_normalized_timespec(&wall_to_monotonic,
179 -xtime.tv_sec, -xtime.tv_nsec);
180 200
181 /* 201 /*
182 * Find the timer to use as the system timer, it will be 202 * Find the timer to use as the system timer, it will be
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index d4212add53b2..205816fcf0da 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -132,17 +132,17 @@ static unsigned long tmu_timer_get_frequency(void)
132 ctrl_outl(0xffffffff, TMU0_TCOR); 132 ctrl_outl(0xffffffff, TMU0_TCOR);
133 ctrl_outl(0xffffffff, TMU0_TCNT); 133 ctrl_outl(0xffffffff, TMU0_TCNT);
134 134
135 rtc_get_time(&ts2); 135 rtc_sh_get_time(&ts2);
136 136
137 do { 137 do {
138 rtc_get_time(&ts1); 138 rtc_sh_get_time(&ts1);
139 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec); 139 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
140 140
141 /* actually start the timer */ 141 /* actually start the timer */
142 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR); 142 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR);
143 143
144 do { 144 do {
145 rtc_get_time(&ts2); 145 rtc_sh_get_time(&ts2);
146 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec); 146 } while (ts1.tv_nsec == ts2.tv_nsec && ts1.tv_sec == ts2.tv_sec);
147 147
148 freq = 0xffffffff - ctrl_inl(TMU0_TCNT); 148 freq = 0xffffffff - ctrl_inl(TMU0_TCNT);
@@ -188,6 +188,18 @@ static struct clk tmu0_clk = {
188 .ops = &tmu_clk_ops, 188 .ops = &tmu_clk_ops,
189}; 189};
190 190
191static int tmu_timer_start(void)
192{
193 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR);
194 return 0;
195}
196
197static int tmu_timer_stop(void)
198{
199 ctrl_outb(0, TMU_TSTR);
200 return 0;
201}
202
191static int tmu_timer_init(void) 203static int tmu_timer_init(void)
192{ 204{
193 unsigned long interval; 205 unsigned long interval;
@@ -197,7 +209,7 @@ static int tmu_timer_init(void)
197 tmu0_clk.parent = clk_get("module_clk"); 209 tmu0_clk.parent = clk_get("module_clk");
198 210
199 /* Start TMU0 */ 211 /* Start TMU0 */
200 ctrl_outb(0, TMU_TSTR); 212 tmu_timer_stop();
201#if !defined(CONFIG_CPU_SUBTYPE_SH7300) && !defined(CONFIG_CPU_SUBTYPE_SH7760) 213#if !defined(CONFIG_CPU_SUBTYPE_SH7300) && !defined(CONFIG_CPU_SUBTYPE_SH7760)
202 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR); 214 ctrl_outb(TMU_TOCR_INIT, TMU_TOCR);
203#endif 215#endif
@@ -211,13 +223,15 @@ static int tmu_timer_init(void)
211 ctrl_outl(interval, TMU0_TCOR); 223 ctrl_outl(interval, TMU0_TCOR);
212 ctrl_outl(interval, TMU0_TCNT); 224 ctrl_outl(interval, TMU0_TCNT);
213 225
214 ctrl_outb(TMU_TSTR_INIT, TMU_TSTR); 226 tmu_timer_start();
215 227
216 return 0; 228 return 0;
217} 229}
218 230
219struct sys_timer_ops tmu_timer_ops = { 231struct sys_timer_ops tmu_timer_ops = {
220 .init = tmu_timer_init, 232 .init = tmu_timer_init,
233 .start = tmu_timer_start,
234 .stop = tmu_timer_stop,
221 .get_frequency = tmu_timer_get_frequency, 235 .get_frequency = tmu_timer_get_frequency,
222 .get_offset = tmu_timer_get_offset, 236 .get_offset = tmu_timer_get_offset,
223}; 237};
diff --git a/arch/sh/kernel/traps.c b/arch/sh/kernel/traps.c
index d9db1180f770..c2c597e09482 100644
--- a/arch/sh/kernel/traps.c
+++ b/arch/sh/kernel/traps.c
@@ -36,40 +36,15 @@
36 36
37#ifdef CONFIG_SH_KGDB 37#ifdef CONFIG_SH_KGDB
38#include <asm/kgdb.h> 38#include <asm/kgdb.h>
39#define CHK_REMOTE_DEBUG(regs) \ 39#define CHK_REMOTE_DEBUG(regs) \
40{ \ 40{ \
41 if ((kgdb_debug_hook != (kgdb_debug_hook_t *) NULL) && (!user_mode(regs))) \ 41 if (kgdb_debug_hook && !user_mode(regs))\
42 { \ 42 (*kgdb_debug_hook)(regs); \
43 (*kgdb_debug_hook)(regs); \
44 } \
45} 43}
46#else 44#else
47#define CHK_REMOTE_DEBUG(regs) 45#define CHK_REMOTE_DEBUG(regs)
48#endif 46#endif
49 47
50#define DO_ERROR(trapnr, signr, str, name, tsk) \
51asmlinkage void do_##name(unsigned long r4, unsigned long r5, \
52 unsigned long r6, unsigned long r7, \
53 struct pt_regs regs) \
54{ \
55 unsigned long error_code; \
56 \
57 /* Check if it's a DSP instruction */ \
58 if (is_dsp_inst(&regs)) { \
59 /* Enable DSP mode, and restart instruction. */ \
60 regs.sr |= SR_DSP; \
61 return; \
62 } \
63 \
64 asm volatile("stc r2_bank, %0": "=r" (error_code)); \
65 local_irq_enable(); \
66 tsk->thread.error_code = error_code; \
67 tsk->thread.trap_no = trapnr; \
68 CHK_REMOTE_DEBUG(&regs); \
69 force_sig(signr, tsk); \
70 die_if_no_fixup(str,&regs,error_code); \
71}
72
73#ifdef CONFIG_CPU_SH2 48#ifdef CONFIG_CPU_SH2
74#define TRAP_RESERVED_INST 4 49#define TRAP_RESERVED_INST 4
75#define TRAP_ILLEGAL_SLOT_INST 6 50#define TRAP_ILLEGAL_SLOT_INST 6
@@ -86,7 +61,7 @@ asmlinkage void do_##name(unsigned long r4, unsigned long r5, \
86#define VMALLOC_OFFSET (8*1024*1024) 61#define VMALLOC_OFFSET (8*1024*1024)
87#define MODULE_RANGE (8*1024*1024) 62#define MODULE_RANGE (8*1024*1024)
88 63
89spinlock_t die_lock; 64DEFINE_SPINLOCK(die_lock);
90 65
91void die(const char * str, struct pt_regs * regs, long err) 66void die(const char * str, struct pt_regs * regs, long err)
92{ 67{
@@ -575,8 +550,117 @@ int is_dsp_inst(struct pt_regs *regs)
575#define is_dsp_inst(regs) (0) 550#define is_dsp_inst(regs) (0)
576#endif /* CONFIG_SH_DSP */ 551#endif /* CONFIG_SH_DSP */
577 552
578DO_ERROR(TRAP_RESERVED_INST, SIGILL, "reserved instruction", reserved_inst, current) 553extern int do_fpu_inst(unsigned short, struct pt_regs*);
579DO_ERROR(TRAP_ILLEGAL_SLOT_INST, SIGILL, "illegal slot instruction", illegal_slot_inst, current) 554
555asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5,
556 unsigned long r6, unsigned long r7,
557 struct pt_regs regs)
558{
559 unsigned long error_code;
560 struct task_struct *tsk = current;
561
562#ifdef CONFIG_SH_FPU_EMU
563 unsigned short inst;
564 int err;
565
566 get_user(inst, (unsigned short*)regs.pc);
567
568 err = do_fpu_inst(inst, &regs);
569 if (!err) {
570 regs.pc += 2;
571 return;
572 }
573 /* not a FPU inst. */
574#endif
575
576#ifdef CONFIG_SH_DSP
577 /* Check if it's a DSP instruction */
578 if (is_dsp_inst(&regs)) {
579 /* Enable DSP mode, and restart instruction. */
580 regs.sr |= SR_DSP;
581 return;
582 }
583#endif
584
585 asm volatile("stc r2_bank, %0": "=r" (error_code));
586 local_irq_enable();
587 tsk->thread.error_code = error_code;
588 tsk->thread.trap_no = TRAP_RESERVED_INST;
589 CHK_REMOTE_DEBUG(&regs);
590 force_sig(SIGILL, tsk);
591 die_if_no_fixup("reserved instruction", &regs, error_code);
592}
593
594#ifdef CONFIG_SH_FPU_EMU
595static int emulate_branch(unsigned short inst, struct pt_regs* regs)
596{
597 /*
598 * bfs: 8fxx: PC+=d*2+4;
599 * bts: 8dxx: PC+=d*2+4;
600 * bra: axxx: PC+=D*2+4;
601 * bsr: bxxx: PC+=D*2+4 after PR=PC+4;
602 * braf:0x23: PC+=Rn*2+4;
603 * bsrf:0x03: PC+=Rn*2+4 after PR=PC+4;
604 * jmp: 4x2b: PC=Rn;
605 * jsr: 4x0b: PC=Rn after PR=PC+4;
606 * rts: 000b: PC=PR;
607 */
608 if ((inst & 0xfd00) == 0x8d00) {
609 regs->pc += SH_PC_8BIT_OFFSET(inst);
610 return 0;
611 }
612
613 if ((inst & 0xe000) == 0xa000) {
614 regs->pc += SH_PC_12BIT_OFFSET(inst);
615 return 0;
616 }
617
618 if ((inst & 0xf0df) == 0x0003) {
619 regs->pc += regs->regs[(inst & 0x0f00) >> 8] + 4;
620 return 0;
621 }
622
623 if ((inst & 0xf0df) == 0x400b) {
624 regs->pc = regs->regs[(inst & 0x0f00) >> 8];
625 return 0;
626 }
627
628 if ((inst & 0xffff) == 0x000b) {
629 regs->pc = regs->pr;
630 return 0;
631 }
632
633 return 1;
634}
635#endif
636
637asmlinkage void do_illegal_slot_inst(unsigned long r4, unsigned long r5,
638 unsigned long r6, unsigned long r7,
639 struct pt_regs regs)
640{
641 unsigned long error_code;
642 struct task_struct *tsk = current;
643#ifdef CONFIG_SH_FPU_EMU
644 unsigned short inst;
645
646 get_user(inst, (unsigned short *)regs.pc + 1);
647 if (!do_fpu_inst(inst, &regs)) {
648 get_user(inst, (unsigned short *)regs.pc);
649 if (!emulate_branch(inst, &regs))
650 return;
651 /* fault in branch.*/
652 }
653 /* not a FPU inst. */
654#endif
655
656 asm volatile("stc r2_bank, %0": "=r" (error_code));
657 local_irq_enable();
658 tsk->thread.error_code = error_code;
659 tsk->thread.trap_no = TRAP_RESERVED_INST;
660 CHK_REMOTE_DEBUG(&regs);
661 force_sig(SIGILL, tsk);
662 die_if_no_fixup("illegal slot instruction", &regs, error_code);
663}
580 664
581asmlinkage void do_exception_error(unsigned long r4, unsigned long r5, 665asmlinkage void do_exception_error(unsigned long r4, unsigned long r5,
582 unsigned long r6, unsigned long r7, 666 unsigned long r6, unsigned long r7,
@@ -634,14 +718,16 @@ void __init trap_init(void)
634 exception_handling_table[TRAP_ILLEGAL_SLOT_INST] 718 exception_handling_table[TRAP_ILLEGAL_SLOT_INST]
635 = (void *)do_illegal_slot_inst; 719 = (void *)do_illegal_slot_inst;
636 720
637#ifdef CONFIG_CPU_SH4 721#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_SH_FPU) || \
638 if (!(cpu_data->flags & CPU_HAS_FPU)) { 722 defined(CONFIG_SH_FPU_EMU)
639 /* For SH-4 lacking an FPU, treat floating point instructions 723 /*
640 as reserved. */ 724 * For SH-4 lacking an FPU, treat floating point instructions as
641 /* entry 64 corresponds to EXPEVT=0x800 */ 725 * reserved. They'll be handled in the math-emu case, or faulted on
642 exception_handling_table[64] = (void *)do_reserved_inst; 726 * otherwise.
643 exception_handling_table[65] = (void *)do_illegal_slot_inst; 727 */
644 } 728 /* entry 64 corresponds to EXPEVT=0x800 */
729 exception_handling_table[64] = (void *)do_reserved_inst;
730 exception_handling_table[65] = (void *)do_illegal_slot_inst;
645#endif 731#endif
646 732
647 /* Setup VBR for boot cpu */ 733 /* Setup VBR for boot cpu */
@@ -655,20 +741,12 @@ void show_stack(struct task_struct *tsk, unsigned long *sp)
655 unsigned long module_end = VMALLOC_END; 741 unsigned long module_end = VMALLOC_END;
656 int i = 1; 742 int i = 1;
657 743
658 if (tsk && !sp) { 744 if (!tsk)
745 tsk = current;
746 if (tsk == current)
747 sp = (unsigned long *)current_stack_pointer;
748 else
659 sp = (unsigned long *)tsk->thread.sp; 749 sp = (unsigned long *)tsk->thread.sp;
660 }
661
662 if (!sp) {
663 __asm__ __volatile__ (
664 "mov r15, %0\n\t"
665 "stc r7_bank, %1\n\t"
666 : "=r" (module_start),
667 "=r" (module_end)
668 );
669
670 sp = (unsigned long *)module_start;
671 }
672 750
673 stack = sp; 751 stack = sp;
674 752
diff --git a/arch/sh/kernel/vmlinux.lds.S b/arch/sh/kernel/vmlinux.lds.S
index 95fdd9135fcf..5eb930918186 100644
--- a/arch/sh/kernel/vmlinux.lds.S
+++ b/arch/sh/kernel/vmlinux.lds.S
@@ -2,6 +2,7 @@
2 * ld script to make SuperH Linux kernel 2 * ld script to make SuperH Linux kernel
3 * Written by Niibe Yutaka 3 * Written by Niibe Yutaka
4 */ 4 */
5#include <asm/thread_info.h>
5#include <asm-generic/vmlinux.lds.h> 6#include <asm-generic/vmlinux.lds.h>
6 7
7#ifdef CONFIG_CPU_LITTLE_ENDIAN 8#ifdef CONFIG_CPU_LITTLE_ENDIAN
@@ -13,7 +14,7 @@ OUTPUT_ARCH(sh)
13ENTRY(_start) 14ENTRY(_start)
14SECTIONS 15SECTIONS
15{ 16{
16 . = 0x80000000 + CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET; 17 . = CONFIG_PAGE_OFFSET + CONFIG_MEMORY_START + CONFIG_ZERO_PAGE_OFFSET;
17 _text = .; /* Text and read-only data */ 18 _text = .; /* Text and read-only data */
18 text = .; /* Text and read-only data */ 19 text = .; /* Text and read-only data */
19 .empty_zero_page : { 20 .empty_zero_page : {
@@ -40,16 +41,16 @@ SECTIONS
40 *(.data) 41 *(.data)
41 42
42 /* Align the initial ramdisk image (INITRD) on page boundaries. */ 43 /* Align the initial ramdisk image (INITRD) on page boundaries. */
43 . = ALIGN(4096); 44 . = ALIGN(PAGE_SIZE);
44 __rd_start = .; 45 __rd_start = .;
45 *(.initrd) 46 *(.initrd)
46 . = ALIGN(4096); 47 . = ALIGN(PAGE_SIZE);
47 __rd_end = .; 48 __rd_end = .;
48 49
49 CONSTRUCTORS 50 CONSTRUCTORS
50 } 51 }
51 52
52 . = ALIGN(4096); 53 . = ALIGN(PAGE_SIZE);
53 .data.page_aligned : { *(.data.idt) } 54 .data.page_aligned : { *(.data.idt) }
54 55
55 . = ALIGN(32); 56 . = ALIGN(32);
@@ -60,12 +61,10 @@ SECTIONS
60 61
61 _edata = .; /* End of data section */ 62 _edata = .; /* End of data section */
62 63
63 . = ALIGN(8192); /* init_task */ 64 . = ALIGN(THREAD_SIZE); /* init_task */
64 .data.init_task : { *(.data.init_task) } 65 .data.init_task : { *(.data.init_task) }
65 /* stack */
66 .stack : { stack = .; _stack = .; }
67 66
68 . = ALIGN(4096); /* Init code and data */ 67 . = ALIGN(PAGE_SIZE); /* Init code and data */
69 __init_begin = .; 68 __init_begin = .;
70 _sinittext = .; 69 _sinittext = .;
71 .init.text : { *(.init.text) } 70 .init.text : { *(.init.text) }
@@ -96,7 +95,7 @@ SECTIONS
96 __machvec_start = .; 95 __machvec_start = .;
97 .init.machvec : { *(.init.machvec) } 96 .init.machvec : { *(.init.machvec) }
98 __machvec_end = .; 97 __machvec_end = .;
99 . = ALIGN(4096); 98 . = ALIGN(PAGE_SIZE);
100 __init_end = .; 99 __init_end = .;
101 100
102 . = ALIGN(4); 101 . = ALIGN(4);
diff --git a/arch/sh/kernel/vsyscall/Makefile b/arch/sh/kernel/vsyscall/Makefile
new file mode 100644
index 000000000000..4bbce1cfa359
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/Makefile
@@ -0,0 +1,36 @@
1obj-y += vsyscall.o vsyscall-syscall.o
2
3$(obj)/vsyscall-syscall.o: \
4 $(foreach F,trapa,$(obj)/vsyscall-$F.so)
5
6# Teach kbuild about targets
7targets += $(foreach F,trapa,vsyscall-$F.o vsyscall-$F.so)
8targets += vsyscall-note.o vsyscall.lds
9
10# The DSO images are built using a special linker script
11quiet_cmd_syscall = SYSCALL $@
12 cmd_syscall = $(CC) -nostdlib $(SYSCFLAGS_$(@F)) \
13 -Wl,-T,$(filter-out FORCE,$^) -o $@
14
15export CPPFLAGS_vsyscall.lds += -P -C -Ush
16
17vsyscall-flags = -shared -s -Wl,-soname=linux-gate.so.1 \
18 $(call ld-option, -Wl$(comma)--hash-style=sysv)
19
20SYSCFLAGS_vsyscall-trapa.so = $(vsyscall-flags)
21
22$(obj)/vsyscall-trapa.so: \
23$(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(obj)/vsyscall-%.o FORCE
24 $(call if_changed,syscall)
25
26# We also create a special relocatable object that should mirror the symbol
27# table and layout of the linked DSO. With ld -R we can then refer to
28# these symbols in the kernel code rather than hand-coded addresses.
29extra-y += vsyscall-syms.o
30$(obj)/built-in.o: $(obj)/vsyscall-syms.o
31$(obj)/built-in.o: ld_flags += -R $(obj)/vsyscall-syms.o
32
33SYSCFLAGS_vsyscall-syms.o = -r
34$(obj)/vsyscall-syms.o: $(src)/vsyscall.lds \
35 $(obj)/vsyscall-trapa.o $(obj)/vsyscall-note.o FORCE
36 $(call if_changed,syscall)
diff --git a/arch/sh/kernel/vsyscall/vsyscall-note.S b/arch/sh/kernel/vsyscall/vsyscall-note.S
new file mode 100644
index 000000000000..d4b5be4f3d5f
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall-note.S
@@ -0,0 +1,25 @@
1/*
2 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
3 * Here we can supply some information useful to userland.
4 */
5
6#include <linux/uts.h>
7#include <linux/version.h>
8
9#define ASM_ELF_NOTE_BEGIN(name, flags, vendor, type) \
10 .section name, flags; \
11 .balign 4; \
12 .long 1f - 0f; /* name length */ \
13 .long 3f - 2f; /* data length */ \
14 .long type; /* note type */ \
150: .asciz vendor; /* vendor name */ \
161: .balign 4; \
172:
18
19#define ASM_ELF_NOTE_END \
203: .balign 4; /* pad out section */ \
21 .previous
22
23 ASM_ELF_NOTE_BEGIN(".note.kernel-version", "a", UTS_SYSNAME, 0)
24 .long LINUX_VERSION_CODE
25 ASM_ELF_NOTE_END
diff --git a/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S b/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S
new file mode 100644
index 000000000000..555a64f124ca
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall-sigreturn.S
@@ -0,0 +1,39 @@
1#include <asm/unistd.h>
2
3 .text
4 .balign 32
5 .globl __kernel_sigreturn
6 .type __kernel_sigreturn,@function
7__kernel_sigreturn:
8.LSTART_sigreturn:
9 mov.w 1f, r3
10 trapa #0x10
11 or r0, r0
12 or r0, r0
13 or r0, r0
14 or r0, r0
15 or r0, r0
16
171: .short __NR_sigreturn
18.LEND_sigreturn:
19 .size __kernel_sigreturn,.-.LSTART_sigreturn
20
21 .balign 32
22 .globl __kernel_rt_sigreturn
23 .type __kernel_rt_sigreturn,@function
24__kernel_rt_sigreturn:
25.LSTART_rt_sigreturn:
26 mov.w 1f, r3
27 trapa #0x10
28 or r0, r0
29 or r0, r0
30 or r0, r0
31 or r0, r0
32 or r0, r0
33
341: .short __NR_rt_sigreturn
35.LEND_rt_sigreturn:
36 .size __kernel_rt_sigreturn,.-.LSTART_rt_sigreturn
37
38 .section .eh_frame,"a",@progbits
39 .previous
diff --git a/arch/sh/kernel/vsyscall/vsyscall-syscall.S b/arch/sh/kernel/vsyscall/vsyscall-syscall.S
new file mode 100644
index 000000000000..c2ac7f0282b3
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall-syscall.S
@@ -0,0 +1,10 @@
1#include <linux/init.h>
2
3__INITDATA
4
5 .globl vsyscall_trapa_start, vsyscall_trapa_end
6vsyscall_trapa_start:
7 .incbin "arch/sh/kernel/vsyscall/vsyscall-trapa.so"
8vsyscall_trapa_end:
9
10__FINIT
diff --git a/arch/sh/kernel/vsyscall/vsyscall-trapa.S b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
new file mode 100644
index 000000000000..3b6eb34c43fa
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall-trapa.S
@@ -0,0 +1,42 @@
1 .text
2 .globl __kernel_vsyscall
3 .type __kernel_vsyscall,@function
4__kernel_vsyscall:
5.LSTART_vsyscall:
6 /* XXX: We'll have to do something here once we opt to use the vDSO
7 * page for something other than the signal trampoline.. as well as
8 * fill out .eh_frame -- PFM. */
9.LEND_vsyscall:
10 .size __kernel_vsyscall,.-.LSTART_vsyscall
11 .previous
12
13 .section .eh_frame,"a",@progbits
14.LCIE:
15 .ualong .LCIE_end - .LCIE_start
16.LCIE_start:
17 .ualong 0 /* CIE ID */
18 .byte 0x1 /* Version number */
19 .string "zRS" /* NUL-terminated augmentation string */
20 .uleb128 0x1 /* Code alignment factor */
21 .sleb128 -4 /* Data alignment factor */
22 .byte 0x11 /* Return address register column */
23 /* Augmentation length and data (none) */
24 .byte 0xc /* DW_CFA_def_cfa */
25 .uleb128 0xf /* r15 */
26 .uleb128 0x0 /* offset 0 */
27
28 .align 2
29.LCIE_end:
30
31 .ualong .LFDE_end-.LFDE_start /* Length FDE */
32.LFDE_start:
33 .ualong .LCIE /* CIE pointer */
34 .ualong .LSTART_vsyscall-. /* start address */
35 .ualong .LEND_vsyscall-.LSTART_vsyscall
36 .uleb128 0
37 .align 2
38.LFDE_end:
39 .previous
40
41/* Get the common code for the sigreturn entry points */
42#include "vsyscall-sigreturn.S"
diff --git a/arch/sh/kernel/vsyscall/vsyscall.c b/arch/sh/kernel/vsyscall/vsyscall.c
new file mode 100644
index 000000000000..075d6cc1a2d7
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall.c
@@ -0,0 +1,150 @@
1/*
2 * arch/sh/kernel/vsyscall.c
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * vDSO randomization
7 * Copyright(C) 2005-2006, Red Hat, Inc., Ingo Molnar
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/mm.h>
14#include <linux/slab.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/gfp.h>
18#include <linux/module.h>
19#include <linux/elf.h>
20
21/*
22 * Should the kernel map a VDSO page into processes and pass its
23 * address down to glibc upon exec()?
24 */
25unsigned int __read_mostly vdso_enabled = 1;
26EXPORT_SYMBOL_GPL(vdso_enabled);
27
28static int __init vdso_setup(char *s)
29{
30 vdso_enabled = simple_strtoul(s, NULL, 0);
31 return 1;
32}
33__setup("vdso=", vdso_setup);
34
35/*
36 * These symbols are defined by vsyscall.o to mark the bounds
37 * of the ELF DSO images included therein.
38 */
39extern const char vsyscall_trapa_start, vsyscall_trapa_end;
40static void *syscall_page;
41
42int __init vsyscall_init(void)
43{
44 syscall_page = (void *)get_zeroed_page(GFP_ATOMIC);
45
46 /*
47 * XXX: Map this page to a fixmap entry if we get around
48 * to adding the page to ELF core dumps
49 */
50
51 memcpy(syscall_page,
52 &vsyscall_trapa_start,
53 &vsyscall_trapa_end - &vsyscall_trapa_start);
54
55 return 0;
56}
57
58static struct page *syscall_vma_nopage(struct vm_area_struct *vma,
59 unsigned long address, int *type)
60{
61 unsigned long offset = address - vma->vm_start;
62 struct page *page;
63
64 if (address < vma->vm_start || address > vma->vm_end)
65 return NOPAGE_SIGBUS;
66
67 page = virt_to_page(syscall_page + offset);
68
69 get_page(page);
70
71 return page;
72}
73
74/* Prevent VMA merging */
75static void syscall_vma_close(struct vm_area_struct *vma)
76{
77}
78
79static struct vm_operations_struct syscall_vm_ops = {
80 .nopage = syscall_vma_nopage,
81 .close = syscall_vma_close,
82};
83
84/* Setup a VMA at program startup for the vsyscall page */
85int arch_setup_additional_pages(struct linux_binprm *bprm,
86 int executable_stack)
87{
88 struct vm_area_struct *vma;
89 struct mm_struct *mm = current->mm;
90 unsigned long addr;
91 int ret;
92
93 down_write(&mm->mmap_sem);
94 addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
95 if (IS_ERR_VALUE(addr)) {
96 ret = addr;
97 goto up_fail;
98 }
99
100 vma = kmem_cache_zalloc(vm_area_cachep, SLAB_KERNEL);
101 if (!vma) {
102 ret = -ENOMEM;
103 goto up_fail;
104 }
105
106 vma->vm_start = addr;
107 vma->vm_end = addr + PAGE_SIZE;
108 /* MAYWRITE to allow gdb to COW and set breakpoints */
109 vma->vm_flags = VM_READ|VM_EXEC|VM_MAYREAD|VM_MAYEXEC|VM_MAYWRITE;
110 vma->vm_flags |= mm->def_flags;
111 vma->vm_page_prot = protection_map[vma->vm_flags & 7];
112 vma->vm_ops = &syscall_vm_ops;
113 vma->vm_mm = mm;
114
115 ret = insert_vm_struct(mm, vma);
116 if (unlikely(ret)) {
117 kmem_cache_free(vm_area_cachep, vma);
118 goto up_fail;
119 }
120
121 current->mm->context.vdso = (void *)addr;
122
123 mm->total_vm++;
124up_fail:
125 up_write(&mm->mmap_sem);
126 return ret;
127}
128
129const char *arch_vma_name(struct vm_area_struct *vma)
130{
131 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
132 return "[vdso]";
133
134 return NULL;
135}
136
137struct vm_area_struct *get_gate_vma(struct task_struct *task)
138{
139 return NULL;
140}
141
142int in_gate_area(struct task_struct *task, unsigned long address)
143{
144 return 0;
145}
146
147int in_gate_area_no_task(unsigned long address)
148{
149 return 0;
150}
diff --git a/arch/sh/kernel/vsyscall/vsyscall.lds.S b/arch/sh/kernel/vsyscall/vsyscall.lds.S
new file mode 100644
index 000000000000..b13c3d439fee
--- /dev/null
+++ b/arch/sh/kernel/vsyscall/vsyscall.lds.S
@@ -0,0 +1,74 @@
1/*
2 * Linker script for vsyscall DSO. The vsyscall page is an ELF shared
3 * object prelinked to its virtual address, and with only one read-only
4 * segment (that fits in one page). This script controls its layout.
5 */
6#include <asm/asm-offsets.h>
7
8#ifdef CONFIG_CPU_LITTLE_ENDIAN
9OUTPUT_FORMAT("elf32-sh-linux", "elf32-sh-linux", "elf32-sh-linux")
10#else
11OUTPUT_FORMAT("elf32-shbig-linux", "elf32-shbig-linux", "elf32-shbig-linux")
12#endif
13OUTPUT_ARCH(sh)
14
15/* The ELF entry point can be used to set the AT_SYSINFO value. */
16ENTRY(__kernel_vsyscall);
17
18SECTIONS
19{
20 . = SIZEOF_HEADERS;
21
22 .hash : { *(.hash) } :text
23 .gnu.hash : { *(.gnu.hash) }
24 .dynsym : { *(.dynsym) }
25 .dynstr : { *(.dynstr) }
26 .gnu.version : { *(.gnu.version) }
27 .gnu.version_d : { *(.gnu.version_d) }
28 .gnu.version_r : { *(.gnu.version_r) }
29
30 /* This linker script is used both with -r and with -shared.
31 For the layouts to match, we need to skip more than enough
32 space for the dynamic symbol table et al. If this amount
33 is insufficient, ld -shared will barf. Just increase it here. */
34 . = 0x400;
35
36 .text : { *(.text) } :text =0x90909090
37 .note : { *(.note.*) } :text :note
38 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
39 .eh_frame : { KEEP (*(.eh_frame)) } :text
40 .dynamic : { *(.dynamic) } :text :dynamic
41 .useless : {
42 *(.got.plt) *(.got)
43 *(.data .data.* .gnu.linkonce.d.*)
44 *(.dynbss)
45 *(.bss .bss.* .gnu.linkonce.b.*)
46 } :text
47}
48
49/*
50 * We must supply the ELF program headers explicitly to get just one
51 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
52 */
53PHDRS
54{
55 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
56 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
57 note PT_NOTE FLAGS(4); /* PF_R */
58 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
59}
60
61/*
62 * This controls what symbols we export from the DSO.
63 */
64VERSION
65{
66 LINUX_2.6 {
67 global:
68 __kernel_vsyscall;
69 __kernel_sigreturn;
70 __kernel_rt_sigreturn;
71
72 local: *;
73 };
74}
diff --git a/arch/sh/lib/checksum.S b/arch/sh/lib/checksum.S
index 7c50dfe68c07..cbdd0d40e545 100644
--- a/arch/sh/lib/checksum.S
+++ b/arch/sh/lib/checksum.S
@@ -202,8 +202,9 @@ ENTRY(csum_partial_copy_generic)
202 cmp/pz r6 ! Jump if we had at least two bytes. 202 cmp/pz r6 ! Jump if we had at least two bytes.
203 bt/s 1f 203 bt/s 1f
204 clrt 204 clrt
205 add #2,r6 ! r6 was < 2. Deal with it.
205 bra 4f 206 bra 4f
206 add #2,r6 ! r6 was < 2. Deal with it. 207 mov r6,r2
207 208
2083: ! Handle different src and dest alignments. 2093: ! Handle different src and dest alignments.
209 ! This is not common, so simple byte by byte copy will do. 210 ! This is not common, so simple byte by byte copy will do.
diff --git a/arch/sh/lib/memcpy-sh4.S b/arch/sh/lib/memcpy-sh4.S
index db6b736537ad..560bc17eebdd 100644
--- a/arch/sh/lib/memcpy-sh4.S
+++ b/arch/sh/lib/memcpy-sh4.S
@@ -727,8 +727,8 @@ ENTRY(memcpy)
727 mov.l @(0x04,r5), r11 ! 18 LS (latency=2) 727 mov.l @(0x04,r5), r11 ! 18 LS (latency=2)
728 xtrct r9, r8 ! 48 EX 728 xtrct r9, r8 ! 48 EX
729 729
730 mov.w @(0x02,r5), r12 ! 18 LS (latency=2) 730 mov.l @(0x00,r5), r12 ! 18 LS (latency=2)
731 xtrct r10, r9 ! 48 EX 731 xtrct r10, r9 ! 48 EX
732 732
733 movca.l r0,@r1 ! 40 LS (latency=3-7) 733 movca.l r0,@r1 ! 40 LS (latency=3-7)
734 add #-0x1c, r1 ! 50 EX 734 add #-0x1c, r1 ! 50 EX
diff --git a/arch/sh/lib/memset.S b/arch/sh/lib/memset.S
index 95670090680e..af91fe2b72a6 100644
--- a/arch/sh/lib/memset.S
+++ b/arch/sh/lib/memset.S
@@ -29,6 +29,7 @@ ENTRY(memset)
29 bf/s 1b 29 bf/s 1b
30 mov.b r5,@-r4 30 mov.b r5,@-r4
312: ! make VVVV 312: ! make VVVV
32 extu.b r5,r5
32 swap.b r5,r0 ! V0 33 swap.b r5,r0 ! V0
33 or r0,r5 ! VV 34 or r0,r5 ! VV
34 swap.w r5,r0 ! VV00 35 swap.w r5,r0 ! VV00
diff --git a/arch/sh/math-emu/Makefile b/arch/sh/math-emu/Makefile
new file mode 100644
index 000000000000..638b342c781a
--- /dev/null
+++ b/arch/sh/math-emu/Makefile
@@ -0,0 +1 @@
obj-y := math.o
diff --git a/arch/sh/math-emu/math.c b/arch/sh/math-emu/math.c
new file mode 100644
index 000000000000..26b6046814fd
--- /dev/null
+++ b/arch/sh/math-emu/math.c
@@ -0,0 +1,624 @@
1/*
2 * arch/sh/math-emu/math.c
3 *
4 * Copyright (C) 2006 Takashi YOSHII <takasi-y@ops.dti.ne.jp>
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#include <linux/config.h>
11#include <linux/kernel.h>
12#include <linux/errno.h>
13#include <linux/types.h>
14#include <linux/sched.h>
15#include <linux/signal.h>
16
17#include <asm/system.h>
18#include <asm/uaccess.h>
19#include <asm/processor.h>
20#include <asm/io.h>
21
22#include "sfp-util.h"
23#include <math-emu/soft-fp.h>
24#include <math-emu/single.h>
25#include <math-emu/double.h>
26
27#define FPUL (fregs->fpul)
28#define FPSCR (fregs->fpscr)
29#define FPSCR_RM (FPSCR&3)
30#define FPSCR_DN ((FPSCR>>18)&1)
31#define FPSCR_PR ((FPSCR>>19)&1)
32#define FPSCR_SZ ((FPSCR>>20)&1)
33#define FPSCR_FR ((FPSCR>>21)&1)
34#define FPSCR_MASK 0x003fffffUL
35
36#define BANK(n) (n^(FPSCR_FR?16:0))
37#define FR ((unsigned long*)(fregs->fp_regs))
38#define FR0 (FR[BANK(0)])
39#define FRn (FR[BANK(n)])
40#define FRm (FR[BANK(m)])
41#define DR ((unsigned long long*)(fregs->fp_regs))
42#define DRn (DR[BANK(n)/2])
43#define DRm (DR[BANK(m)/2])
44
45#define XREG(n) (n^16)
46#define XFn (FR[BANK(XREG(n))])
47#define XFm (FR[BANK(XREG(m))])
48#define XDn (DR[BANK(XREG(n))/2])
49#define XDm (DR[BANK(XREG(m))/2])
50
51#define R0 (regs->regs[0])
52#define Rn (regs->regs[n])
53#define Rm (regs->regs[m])
54
55#define WRITE(d,a) ({if(put_user(d, (typeof (d)*)a)) return -EFAULT;})
56#define READ(d,a) ({if(get_user(d, (typeof (d)*)a)) return -EFAULT;})
57
58#define PACK_S(r,f) FP_PACK_SP(&r,f)
59#define UNPACK_S(f,r) FP_UNPACK_SP(f,&r)
60#define PACK_D(r,f) \
61 {u32 t[2]; FP_PACK_DP(t,f); ((u32*)&r)[0]=t[1]; ((u32*)&r)[1]=t[0];}
62#define UNPACK_D(f,r) \
63 {u32 t[2]; t[0]=((u32*)&r)[1]; t[1]=((u32*)&r)[0]; FP_UNPACK_DP(f,t);}
64
65// 2 args instructions.
66#define BOTH_PRmn(op,x) \
67 FP_DECL_EX; if(FPSCR_PR) op(D,x,DRm,DRn); else op(S,x,FRm,FRn);
68
69#define CMP_X(SZ,R,M,N) do{ \
70 FP_DECL_##SZ(Fm); FP_DECL_##SZ(Fn); \
71 UNPACK_##SZ(Fm, M); UNPACK_##SZ(Fn, N); \
72 FP_CMP_##SZ(R, Fn, Fm, 2); }while(0)
73#define EQ_X(SZ,R,M,N) do{ \
74 FP_DECL_##SZ(Fm); FP_DECL_##SZ(Fn); \
75 UNPACK_##SZ(Fm, M); UNPACK_##SZ(Fn, N); \
76 FP_CMP_EQ_##SZ(R, Fn, Fm); }while(0)
77#define CMP(OP) ({ int r; BOTH_PRmn(OP##_X,r); r; })
78
79static int
80fcmp_gt(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
81{
82 if (CMP(CMP) > 0)
83 regs->sr |= 1;
84 else
85 regs->sr &= ~1;
86
87 return 0;
88}
89
90static int
91fcmp_eq(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
92{
93 if (CMP(CMP /*EQ*/) == 0)
94 regs->sr |= 1;
95 else
96 regs->sr &= ~1;
97 return 0;
98}
99
100#define ARITH_X(SZ,OP,M,N) do{ \
101 FP_DECL_##SZ(Fm); FP_DECL_##SZ(Fn); FP_DECL_##SZ(Fr); \
102 UNPACK_##SZ(Fm, M); UNPACK_##SZ(Fn, N); \
103 FP_##OP##_##SZ(Fr, Fn, Fm); \
104 PACK_##SZ(N, Fr); }while(0)
105
106static int
107fadd(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
108{
109 BOTH_PRmn(ARITH_X, ADD);
110 return 0;
111}
112
113static int
114fsub(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
115{
116 BOTH_PRmn(ARITH_X, SUB);
117 return 0;
118}
119
120static int
121fmul(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
122{
123 BOTH_PRmn(ARITH_X, MUL);
124 return 0;
125}
126
127static int
128fdiv(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
129{
130 BOTH_PRmn(ARITH_X, DIV);
131 return 0;
132}
133
134static int
135fmac(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
136{
137 FP_DECL_EX;
138 FP_DECL_S(Fr);
139 FP_DECL_S(Ft);
140 FP_DECL_S(F0);
141 FP_DECL_S(Fm);
142 FP_DECL_S(Fn);
143 UNPACK_S(F0, FR0);
144 UNPACK_S(Fm, FRm);
145 UNPACK_S(Fn, FRn);
146 FP_MUL_S(Ft, Fm, F0);
147 FP_ADD_S(Fr, Fn, Ft);
148 PACK_S(FRn, Fr);
149 return 0;
150}
151
152// to process fmov's extention (odd n for DR access XD).
153#define FMOV_EXT(x) if(x&1) x+=16-1
154
155static int
156fmov_idx_reg(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
157 int n)
158{
159 if (FPSCR_SZ) {
160 FMOV_EXT(n);
161 READ(FRn, Rm + R0 + 4);
162 n++;
163 READ(FRn, Rm + R0);
164 } else {
165 READ(FRn, Rm + R0);
166 }
167
168 return 0;
169}
170
171static int
172fmov_mem_reg(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
173 int n)
174{
175 if (FPSCR_SZ) {
176 FMOV_EXT(n);
177 READ(FRn, Rm + 4);
178 n++;
179 READ(FRn, Rm);
180 } else {
181 READ(FRn, Rm);
182 }
183
184 return 0;
185}
186
187static int
188fmov_inc_reg(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
189 int n)
190{
191 if (FPSCR_SZ) {
192 FMOV_EXT(n);
193 READ(FRn, Rm + 4);
194 n++;
195 READ(FRn, Rm);
196 Rm += 8;
197 } else {
198 READ(FRn, Rm);
199 Rm += 4;
200 }
201
202 return 0;
203}
204
205static int
206fmov_reg_idx(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
207 int n)
208{
209 if (FPSCR_SZ) {
210 FMOV_EXT(m);
211 WRITE(FRm, Rn + R0 + 4);
212 m++;
213 WRITE(FRm, Rn + R0);
214 } else {
215 WRITE(FRm, Rn + R0);
216 }
217
218 return 0;
219}
220
221static int
222fmov_reg_mem(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
223 int n)
224{
225 if (FPSCR_SZ) {
226 FMOV_EXT(m);
227 WRITE(FRm, Rn + 4);
228 m++;
229 WRITE(FRm, Rn);
230 } else {
231 WRITE(FRm, Rn);
232 }
233
234 return 0;
235}
236
237static int
238fmov_reg_dec(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
239 int n)
240{
241 if (FPSCR_SZ) {
242 FMOV_EXT(m);
243 Rn -= 8;
244 WRITE(FRm, Rn + 4);
245 m++;
246 WRITE(FRm, Rn);
247 } else {
248 Rn -= 4;
249 WRITE(FRm, Rn);
250 }
251
252 return 0;
253}
254
255static int
256fmov_reg_reg(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m,
257 int n)
258{
259 if (FPSCR_SZ) {
260 FMOV_EXT(m);
261 FMOV_EXT(n);
262 DRn = DRm;
263 } else {
264 FRn = FRm;
265 }
266
267 return 0;
268}
269
270static int
271fnop_mn(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int m, int n)
272{
273 return -EINVAL;
274}
275
276// 1 arg instructions.
277#define NOTYETn(i) static int i(struct sh_fpu_soft_struct *fregs, int n) \
278 { printk( #i " not yet done.\n"); return 0; }
279
280NOTYETn(ftrv)
281NOTYETn(fsqrt)
282NOTYETn(fipr)
283NOTYETn(fsca)
284NOTYETn(fsrra)
285
286#define EMU_FLOAT_X(SZ,N) do { \
287 FP_DECL_##SZ(Fn); \
288 FP_FROM_INT_##SZ(Fn, FPUL, 32, int); \
289 PACK_##SZ(N, Fn); }while(0)
290static int ffloat(struct sh_fpu_soft_struct *fregs, int n)
291{
292 FP_DECL_EX;
293
294 if (FPSCR_PR)
295 EMU_FLOAT_X(D, DRn);
296 else
297 EMU_FLOAT_X(S, FRn);
298
299 return 0;
300}
301
302#define EMU_FTRC_X(SZ,N) do { \
303 FP_DECL_##SZ(Fn); \
304 UNPACK_##SZ(Fn, N); \
305 FP_TO_INT_##SZ(FPUL, Fn, 32, 1); }while(0)
306static int ftrc(struct sh_fpu_soft_struct *fregs, int n)
307{
308 FP_DECL_EX;
309
310 if (FPSCR_PR)
311 EMU_FTRC_X(D, DRn);
312 else
313 EMU_FTRC_X(S, FRn);
314
315 return 0;
316}
317
318static int fcnvsd(struct sh_fpu_soft_struct *fregs, int n)
319{
320 FP_DECL_EX;
321 FP_DECL_S(Fn);
322 FP_DECL_D(Fr);
323 UNPACK_S(Fn, FPUL);
324 FP_CONV(D, S, 2, 1, Fr, Fn);
325 PACK_D(DRn, Fr);
326 return 0;
327}
328
329static int fcnvds(struct sh_fpu_soft_struct *fregs, int n)
330{
331 FP_DECL_EX;
332 FP_DECL_D(Fn);
333 FP_DECL_S(Fr);
334 UNPACK_D(Fn, DRn);
335 FP_CONV(S, D, 1, 2, Fr, Fn);
336 PACK_S(FPUL, Fr);
337 return 0;
338}
339
340static int fxchg(struct sh_fpu_soft_struct *fregs, int flag)
341{
342 FPSCR ^= flag;
343 return 0;
344}
345
346static int fsts(struct sh_fpu_soft_struct *fregs, int n)
347{
348 FRn = FPUL;
349 return 0;
350}
351
352static int flds(struct sh_fpu_soft_struct *fregs, int n)
353{
354 FPUL = FRn;
355 return 0;
356}
357
358static int fneg(struct sh_fpu_soft_struct *fregs, int n)
359{
360 FRn ^= (1 << (_FP_W_TYPE_SIZE - 1));
361 return 0;
362}
363
364static int fabs(struct sh_fpu_soft_struct *fregs, int n)
365{
366 FRn &= ~(1 << (_FP_W_TYPE_SIZE - 1));
367 return 0;
368}
369
370static int fld0(struct sh_fpu_soft_struct *fregs, int n)
371{
372 FRn = 0;
373 return 0;
374}
375
376static int fld1(struct sh_fpu_soft_struct *fregs, int n)
377{
378 FRn = (_FP_EXPBIAS_S << (_FP_FRACBITS_S - 1));
379 return 0;
380}
381
382static int fnop_n(struct sh_fpu_soft_struct *fregs, int n)
383{
384 return -EINVAL;
385}
386
387/// Instruction decoders.
388
389static int id_fxfd(struct sh_fpu_soft_struct *, int);
390static int id_fnxd(struct sh_fpu_soft_struct *, struct pt_regs *, int, int);
391
392static int (*fnxd[])(struct sh_fpu_soft_struct *, int) = {
393 fsts, flds, ffloat, ftrc, fneg, fabs, fsqrt, fsrra,
394 fld0, fld1, fcnvsd, fcnvds, fnop_n, fnop_n, fipr, id_fxfd
395};
396
397static int (*fnmx[])(struct sh_fpu_soft_struct *, struct pt_regs *, int, int) = {
398 fadd, fsub, fmul, fdiv, fcmp_eq, fcmp_gt, fmov_idx_reg, fmov_reg_idx,
399 fmov_mem_reg, fmov_inc_reg, fmov_reg_mem, fmov_reg_dec,
400 fmov_reg_reg, id_fnxd, fmac, fnop_mn};
401
402static int id_fxfd(struct sh_fpu_soft_struct *fregs, int x)
403{
404 const int flag[] = { FPSCR_SZ, FPSCR_PR, FPSCR_FR, 0 };
405 switch (x & 3) {
406 case 3:
407 fxchg(fregs, flag[x >> 2]);
408 break;
409 case 1:
410 ftrv(fregs, x - 1);
411 break;
412 default:
413 fsca(fregs, x);
414 }
415 return 0;
416}
417
418static int
419id_fnxd(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, int x, int n)
420{
421 return (fnxd[x])(fregs, n);
422}
423
424static int
425id_fnmx(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, u16 code)
426{
427 int n = (code >> 8) & 0xf, m = (code >> 4) & 0xf, x = code & 0xf;
428 return (fnmx[x])(fregs, regs, m, n);
429}
430
431static int
432id_sys(struct sh_fpu_soft_struct *fregs, struct pt_regs *regs, u16 code)
433{
434 int n = ((code >> 8) & 0xf);
435 unsigned long *reg = (code & 0x0010) ? &FPUL : &FPSCR;
436
437 switch (code & 0xf0ff) {
438 case 0x005a:
439 case 0x006a:
440 Rn = *reg;
441 break;
442 case 0x405a:
443 case 0x406a:
444 *reg = Rn;
445 break;
446 case 0x4052:
447 case 0x4062:
448 Rn -= 4;
449 WRITE(*reg, Rn);
450 break;
451 case 0x4056:
452 case 0x4066:
453 READ(*reg, Rn);
454 Rn += 4;
455 break;
456 default:
457 return -EINVAL;
458 }
459
460 return 0;
461}
462
463static int fpu_emulate(u16 code, struct sh_fpu_soft_struct *fregs, struct pt_regs *regs)
464{
465 if ((code & 0xf000) == 0xf000)
466 return id_fnmx(fregs, regs, code);
467 else
468 return id_sys(fregs, regs, code);
469}
470
471/**
472 * denormal_to_double - Given denormalized float number,
473 * store double float
474 *
475 * @fpu: Pointer to sh_fpu_hard structure
476 * @n: Index to FP register
477 */
478static void denormal_to_double(struct sh_fpu_hard_struct *fpu, int n)
479{
480 unsigned long du, dl;
481 unsigned long x = fpu->fpul;
482 int exp = 1023 - 126;
483
484 if (x != 0 && (x & 0x7f800000) == 0) {
485 du = (x & 0x80000000);
486 while ((x & 0x00800000) == 0) {
487 x <<= 1;
488 exp--;
489 }
490 x &= 0x007fffff;
491 du |= (exp << 20) | (x >> 3);
492 dl = x << 29;
493
494 fpu->fp_regs[n] = du;
495 fpu->fp_regs[n+1] = dl;
496 }
497}
498
499/**
500 * ieee_fpe_handler - Handle denormalized number exception
501 *
502 * @regs: Pointer to register structure
503 *
504 * Returns 1 when it's handled (should not cause exception).
505 */
506static int ieee_fpe_handler(struct pt_regs *regs)
507{
508 unsigned short insn = *(unsigned short *)regs->pc;
509 unsigned short finsn;
510 unsigned long nextpc;
511 int nib[4] = {
512 (insn >> 12) & 0xf,
513 (insn >> 8) & 0xf,
514 (insn >> 4) & 0xf,
515 insn & 0xf};
516
517 if (nib[0] == 0xb ||
518 (nib[0] == 0x4 && nib[2] == 0x0 && nib[3] == 0xb)) /* bsr & jsr */
519 regs->pr = regs->pc + 4;
520
521 if (nib[0] == 0xa || nib[0] == 0xb) { /* bra & bsr */
522 nextpc = regs->pc + 4 + ((short) ((insn & 0xfff) << 4) >> 3);
523 finsn = *(unsigned short *) (regs->pc + 2);
524 } else if (nib[0] == 0x8 && nib[1] == 0xd) { /* bt/s */
525 if (regs->sr & 1)
526 nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1);
527 else
528 nextpc = regs->pc + 4;
529 finsn = *(unsigned short *) (regs->pc + 2);
530 } else if (nib[0] == 0x8 && nib[1] == 0xf) { /* bf/s */
531 if (regs->sr & 1)
532 nextpc = regs->pc + 4;
533 else
534 nextpc = regs->pc + 4 + ((char) (insn & 0xff) << 1);
535 finsn = *(unsigned short *) (regs->pc + 2);
536 } else if (nib[0] == 0x4 && nib[3] == 0xb &&
537 (nib[2] == 0x0 || nib[2] == 0x2)) { /* jmp & jsr */
538 nextpc = regs->regs[nib[1]];
539 finsn = *(unsigned short *) (regs->pc + 2);
540 } else if (nib[0] == 0x0 && nib[3] == 0x3 &&
541 (nib[2] == 0x0 || nib[2] == 0x2)) { /* braf & bsrf */
542 nextpc = regs->pc + 4 + regs->regs[nib[1]];
543 finsn = *(unsigned short *) (regs->pc + 2);
544 } else if (insn == 0x000b) { /* rts */
545 nextpc = regs->pr;
546 finsn = *(unsigned short *) (regs->pc + 2);
547 } else {
548 nextpc = regs->pc + 2;
549 finsn = insn;
550 }
551
552 if ((finsn & 0xf1ff) == 0xf0ad) { /* fcnvsd */
553 struct task_struct *tsk = current;
554
555 if ((tsk->thread.fpu.hard.fpscr & (1 << 17))) {
556 /* FPU error */
557 denormal_to_double (&tsk->thread.fpu.hard,
558 (finsn >> 8) & 0xf);
559 tsk->thread.fpu.hard.fpscr &=
560 ~(FPSCR_CAUSE_MASK | FPSCR_FLAG_MASK);
561 set_tsk_thread_flag(tsk, TIF_USEDFPU);
562 } else {
563 tsk->thread.trap_no = 11;
564 tsk->thread.error_code = 0;
565 force_sig(SIGFPE, tsk);
566 }
567
568 regs->pc = nextpc;
569 return 1;
570 }
571
572 return 0;
573}
574
575asmlinkage void do_fpu_error(unsigned long r4, unsigned long r5,
576 unsigned long r6, unsigned long r7,
577 struct pt_regs regs)
578{
579 struct task_struct *tsk = current;
580
581 if (ieee_fpe_handler (&regs))
582 return;
583
584 regs.pc += 2;
585 tsk->thread.trap_no = 11;
586 tsk->thread.error_code = 0;
587 force_sig(SIGFPE, tsk);
588}
589
590/**
591 * fpu_init - Initialize FPU registers
592 * @fpu: Pointer to software emulated FPU registers.
593 */
594static void fpu_init(struct sh_fpu_soft_struct *fpu)
595{
596 int i;
597
598 fpu->fpscr = FPSCR_INIT;
599 fpu->fpul = 0;
600
601 for (i = 0; i < 16; i++) {
602 fpu->fp_regs[i] = 0;
603 fpu->xfp_regs[i]= 0;
604 }
605}
606
607/**
608 * do_fpu_inst - Handle reserved instructions for FPU emulation
609 * @inst: instruction code.
610 * @regs: registers on stack.
611 */
612int do_fpu_inst(unsigned short inst, struct pt_regs *regs)
613{
614 struct task_struct *tsk = current;
615 struct sh_fpu_soft_struct *fpu = &(tsk->thread.fpu.soft);
616
617 if (!test_tsk_thread_flag(tsk, TIF_USEDFPU)) {
618 /* initialize once. */
619 fpu_init(fpu);
620 set_tsk_thread_flag(tsk, TIF_USEDFPU);
621 }
622
623 return fpu_emulate(inst, fpu, regs);
624}
diff --git a/arch/sh/math-emu/sfp-util.h b/arch/sh/math-emu/sfp-util.h
new file mode 100644
index 000000000000..8ae1bd310ad0
--- /dev/null
+++ b/arch/sh/math-emu/sfp-util.h
@@ -0,0 +1,72 @@
1/*
2 * These are copied from glibc/stdlib/longlong.h
3 */
4
5#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
6 do { \
7 UWtype __x; \
8 __x = (al) + (bl); \
9 (sh) = (ah) + (bh) + (__x < (al)); \
10 (sl) = __x; \
11 } while (0)
12
13#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
14 do { \
15 UWtype __x; \
16 __x = (al) - (bl); \
17 (sh) = (ah) - (bh) - (__x > (al)); \
18 (sl) = __x; \
19 } while (0)
20
21#define umul_ppmm(w1, w0, u, v) \
22 __asm__ ("dmulu.l %2,%3\n\tsts macl,%1\n\tsts mach,%0" \
23 : "=r" ((u32)(w1)), "=r" ((u32)(w0)) \
24 : "r" ((u32)(u)), "r" ((u32)(v)) \
25 : "macl", "mach")
26
27#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
28#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
29#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
30
31#define udiv_qrnnd(q, r, n1, n0, d) \
32 do { \
33 UWtype __d1, __d0, __q1, __q0; \
34 UWtype __r1, __r0, __m; \
35 __d1 = __ll_highpart (d); \
36 __d0 = __ll_lowpart (d); \
37 \
38 __r1 = (n1) % __d1; \
39 __q1 = (n1) / __d1; \
40 __m = (UWtype) __q1 * __d0; \
41 __r1 = __r1 * __ll_B | __ll_highpart (n0); \
42 if (__r1 < __m) \
43 { \
44 __q1--, __r1 += (d); \
45 if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
46 if (__r1 < __m) \
47 __q1--, __r1 += (d); \
48 } \
49 __r1 -= __m; \
50 \
51 __r0 = __r1 % __d1; \
52 __q0 = __r1 / __d1; \
53 __m = (UWtype) __q0 * __d0; \
54 __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
55 if (__r0 < __m) \
56 { \
57 __q0--, __r0 += (d); \
58 if (__r0 >= (d)) \
59 if (__r0 < __m) \
60 __q0--, __r0 += (d); \
61 } \
62 __r0 -= __m; \
63 \
64 (q) = (UWtype) __q1 * __ll_B | __q0; \
65 (r) = __r0; \
66 } while (0)
67
68#define abort() return 0
69
70#define __BYTE_ORDER __LITTLE_ENDIAN
71
72
diff --git a/arch/sh/mm/Kconfig b/arch/sh/mm/Kconfig
index fb586b1cf8bb..9dd606464d23 100644
--- a/arch/sh/mm/Kconfig
+++ b/arch/sh/mm/Kconfig
@@ -20,7 +20,10 @@ config CPU_SH4
20config CPU_SH4A 20config CPU_SH4A
21 bool 21 bool
22 select CPU_SH4 22 select CPU_SH4
23 select CPU_HAS_INTC2_IRQ 23
24config CPU_SH4AL_DSP
25 bool
26 select CPU_SH4A
24 27
25config CPU_SUBTYPE_ST40 28config CPU_SUBTYPE_ST40
26 bool 29 bool
@@ -48,6 +51,12 @@ config CPU_SUBTYPE_SH7705
48 select CPU_SH3 51 select CPU_SH3
49 select CPU_HAS_PINT_IRQ 52 select CPU_HAS_PINT_IRQ
50 53
54config CPU_SUBTYPE_SH7706
55 bool "Support SH7706 processor"
56 select CPU_SH3
57 help
58 Select SH7706 if you have a 133 Mhz SH-3 HD6417706 CPU.
59
51config CPU_SUBTYPE_SH7707 60config CPU_SUBTYPE_SH7707
52 bool "Support SH7707 processor" 61 bool "Support SH7707 processor"
53 select CPU_SH3 62 select CPU_SH3
@@ -69,6 +78,12 @@ config CPU_SUBTYPE_SH7709
69 help 78 help
70 Select SH7709 if you have a 80 Mhz SH-3 HD6417709 CPU. 79 Select SH7709 if you have a 80 Mhz SH-3 HD6417709 CPU.
71 80
81config CPU_SUBTYPE_SH7710
82 bool "Support SH7710 processor"
83 select CPU_SH3
84 help
85 Select SH7710 if you have a SH3-DSP SH7710 CPU.
86
72comment "SH-4 Processor Support" 87comment "SH-4 Processor Support"
73 88
74config CPU_SUBTYPE_SH7750 89config CPU_SUBTYPE_SH7750
@@ -133,10 +148,6 @@ config CPU_SUBTYPE_ST40GX1
133 148
134comment "SH-4A Processor Support" 149comment "SH-4A Processor Support"
135 150
136config CPU_SUBTYPE_SH73180
137 bool "Support SH73180 processor"
138 select CPU_SH4A
139
140config CPU_SUBTYPE_SH7770 151config CPU_SUBTYPE_SH7770
141 bool "Support SH7770 processor" 152 bool "Support SH7770 processor"
142 select CPU_SH4A 153 select CPU_SH4A
@@ -144,6 +155,17 @@ config CPU_SUBTYPE_SH7770
144config CPU_SUBTYPE_SH7780 155config CPU_SUBTYPE_SH7780
145 bool "Support SH7780 processor" 156 bool "Support SH7780 processor"
146 select CPU_SH4A 157 select CPU_SH4A
158 select CPU_HAS_INTC2_IRQ
159
160comment "SH4AL-DSP Processor Support"
161
162config CPU_SUBTYPE_SH73180
163 bool "Support SH73180 processor"
164 select CPU_SH4AL_DSP
165
166config CPU_SUBTYPE_SH7343
167 bool "Support SH7343 processor"
168 select CPU_SH4AL_DSP
147 169
148endmenu 170endmenu
149 171
@@ -161,15 +183,59 @@ config MMU
161 turning this off will boot the kernel on these machines with the 183 turning this off will boot the kernel on these machines with the
162 MMU implicitly switched off. 184 MMU implicitly switched off.
163 185
186config PAGE_OFFSET
187 hex
188 default "0x80000000" if MMU
189 default "0x00000000"
190
191config MEMORY_START
192 hex "Physical memory start address"
193 default "0x08000000"
194 ---help---
195 Computers built with Hitachi SuperH processors always
196 map the ROM starting at address zero. But the processor
197 does not specify the range that RAM takes.
198
199 The physical memory (RAM) start address will be automatically
200 set to 08000000. Other platforms, such as the Solution Engine
201 boards typically map RAM at 0C000000.
202
203 Tweak this only when porting to a new machine which does not
204 already have a defconfig. Changing it from the known correct
205 value on any of the known systems will only lead to disaster.
206
207config MEMORY_SIZE
208 hex "Physical memory size"
209 default "0x00400000"
210 help
211 This sets the default memory size assumed by your SH kernel. It can
212 be overridden as normal by the 'mem=' argument on the kernel command
213 line. If unsure, consult your board specifications or just leave it
214 as 0x00400000 which was the default value before this became
215 configurable.
216
164config 32BIT 217config 32BIT
165 bool "Support 32-bit physical addressing through PMB" 218 bool "Support 32-bit physical addressing through PMB"
166 depends on CPU_SH4A 219 depends on CPU_SH4A && MMU
167 default y 220 default y
168 help 221 help
169 If you say Y here, physical addressing will be extended to 222 If you say Y here, physical addressing will be extended to
170 32-bits through the SH-4A PMB. If this is not set, legacy 223 32-bits through the SH-4A PMB. If this is not set, legacy
171 29-bit physical addressing will be used. 224 29-bit physical addressing will be used.
172 225
226config VSYSCALL
227 bool "Support vsyscall page"
228 depends on MMU
229 default y
230 help
231 This will enable support for the kernel mapping a vDSO page
232 in process space, and subsequently handing down the entry point
233 to the libc through the ELF auxiliary vector.
234
235 From the kernel side this is used for the signal trampoline.
236 For systems with an MMU that can afford to give up a page,
237 (the default value) say Y.
238
173choice 239choice
174 prompt "HugeTLB page size" 240 prompt "HugeTLB page size"
175 depends on HUGETLB_PAGE && CPU_SH4 && MMU 241 depends on HUGETLB_PAGE && CPU_SH4 && MMU
diff --git a/arch/sh/mm/Makefile b/arch/sh/mm/Makefile
index 9489a1424644..3ffd7f68c0a2 100644
--- a/arch/sh/mm/Makefile
+++ b/arch/sh/mm/Makefile
@@ -6,20 +6,26 @@ obj-y := init.o extable.o consistent.o
6 6
7obj-$(CONFIG_CPU_SH2) += cache-sh2.o 7obj-$(CONFIG_CPU_SH2) += cache-sh2.o
8obj-$(CONFIG_CPU_SH3) += cache-sh3.o 8obj-$(CONFIG_CPU_SH3) += cache-sh3.o
9obj-$(CONFIG_CPU_SH4) += cache-sh4.o pg-sh4.o 9obj-$(CONFIG_CPU_SH4) += cache-sh4.o
10 10
11obj-$(CONFIG_DMA_PAGE_OPS) += pg-dma.o 11obj-$(CONFIG_DMA_PAGE_OPS) += pg-dma.o
12obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 12obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
13 13
14mmu-y := fault-nommu.o tlb-nommu.o pg-nommu.o 14mmu-y := fault-nommu.o tlb-nommu.o pg-nommu.o
15mmu-$(CONFIG_MMU) := fault.o clear_page.o copy_page.o 15mmu-$(CONFIG_MMU) := fault.o clear_page.o copy_page.o tlb-flush.o \
16 ioremap.o
16 17
17obj-y += $(mmu-y) 18obj-y += $(mmu-y)
18 19
20ifdef CONFIG_DEBUG_FS
21obj-$(CONFIG_CPU_SH4) += cache-debugfs.o
22endif
23
19ifdef CONFIG_MMU 24ifdef CONFIG_MMU
20obj-$(CONFIG_CPU_SH3) += tlb-sh3.o 25obj-$(CONFIG_CPU_SH3) += tlb-sh3.o
21obj-$(CONFIG_CPU_SH4) += tlb-sh4.o ioremap.o 26obj-$(CONFIG_CPU_SH4) += tlb-sh4.o pg-sh4.o
22obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o 27obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o
23endif 28endif
24 29
25obj-$(CONFIG_SH7705_CACHE_32KB) += cache-sh7705.o 30obj-$(CONFIG_SH7705_CACHE_32KB) += cache-sh7705.o
31obj-$(CONFIG_32BIT) += pmb.o
diff --git a/arch/sh/mm/cache-debugfs.c b/arch/sh/mm/cache-debugfs.c
new file mode 100644
index 000000000000..a22d914e4d15
--- /dev/null
+++ b/arch/sh/mm/cache-debugfs.c
@@ -0,0 +1,147 @@
1/*
2 * debugfs ops for the L1 cache
3 *
4 * Copyright (C) 2006 Paul Mundt
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#include <linux/init.h>
11#include <linux/module.h>
12#include <linux/debugfs.h>
13#include <linux/seq_file.h>
14#include <asm/processor.h>
15#include <asm/uaccess.h>
16#include <asm/cache.h>
17#include <asm/io.h>
18
19enum cache_type {
20 CACHE_TYPE_ICACHE,
21 CACHE_TYPE_DCACHE,
22 CACHE_TYPE_UNIFIED,
23};
24
25static int cache_seq_show(struct seq_file *file, void *iter)
26{
27 unsigned int cache_type = (unsigned int)file->private;
28 struct cache_info *cache;
29 unsigned int waysize, way, cache_size;
30 unsigned long ccr, base;
31 static unsigned long addrstart = 0;
32
33 /*
34 * Go uncached immediately so we don't skew the results any
35 * more than we already are..
36 */
37 jump_to_P2();
38
39 ccr = ctrl_inl(CCR);
40 if ((ccr & CCR_CACHE_ENABLE) == 0) {
41 back_to_P1();
42
43 seq_printf(file, "disabled\n");
44 return 0;
45 }
46
47 if (cache_type == CACHE_TYPE_DCACHE) {
48 base = CACHE_OC_ADDRESS_ARRAY;
49 cache = &cpu_data->dcache;
50 } else {
51 base = CACHE_IC_ADDRESS_ARRAY;
52 cache = &cpu_data->icache;
53 }
54
55 /*
56 * Due to the amount of data written out (depending on the cache size),
57 * we may be iterated over multiple times. In this case, keep track of
58 * the entry position in addrstart, and rewind it when we've hit the
59 * end of the cache.
60 *
61 * Likewise, the same code is used for multiple caches, so care must
62 * be taken for bouncing addrstart back and forth so the appropriate
63 * cache is hit.
64 */
65 cache_size = cache->ways * cache->sets * cache->linesz;
66 if (((addrstart & 0xff000000) != base) ||
67 (addrstart & 0x00ffffff) > cache_size)
68 addrstart = base;
69
70 waysize = cache->sets;
71
72 /*
73 * If the OC is already in RAM mode, we only have
74 * half of the entries to consider..
75 */
76 if ((ccr & CCR_CACHE_ORA) && cache_type == CACHE_TYPE_DCACHE)
77 waysize >>= 1;
78
79 waysize <<= cache->entry_shift;
80
81 for (way = 0; way < cache->ways; way++) {
82 unsigned long addr;
83 unsigned int line;
84
85 seq_printf(file, "-----------------------------------------\n");
86 seq_printf(file, "Way %d\n", way);
87 seq_printf(file, "-----------------------------------------\n");
88
89 for (addr = addrstart, line = 0;
90 addr < addrstart + waysize;
91 addr += cache->linesz, line++) {
92 unsigned long data = ctrl_inl(addr);
93
94 /* Check the V bit, ignore invalid cachelines */
95 if ((data & 1) == 0)
96 continue;
97
98 /* U: Dirty, cache tag is 10 bits up */
99 seq_printf(file, "%3d: %c 0x%lx\n",
100 line, data & 2 ? 'U' : ' ',
101 data & 0x1ffffc00);
102 }
103
104 addrstart += cache->way_incr;
105 }
106
107 back_to_P1();
108
109 return 0;
110}
111
112static int cache_debugfs_open(struct inode *inode, struct file *file)
113{
114 return single_open(file, cache_seq_show, inode->u.generic_ip);
115}
116
117static struct file_operations cache_debugfs_fops = {
118 .owner = THIS_MODULE,
119 .open = cache_debugfs_open,
120 .read = seq_read,
121 .llseek = seq_lseek,
122 .release = seq_release,
123};
124
125static int __init cache_debugfs_init(void)
126{
127 struct dentry *dcache_dentry, *icache_dentry;
128
129 dcache_dentry = debugfs_create_file("dcache", S_IRUSR, NULL,
130 (unsigned int *)CACHE_TYPE_DCACHE,
131 &cache_debugfs_fops);
132 if (IS_ERR(dcache_dentry))
133 return PTR_ERR(dcache_dentry);
134
135 icache_dentry = debugfs_create_file("icache", S_IRUSR, NULL,
136 (unsigned int *)CACHE_TYPE_ICACHE,
137 &cache_debugfs_fops);
138 if (IS_ERR(icache_dentry)) {
139 debugfs_remove(dcache_dentry);
140 return PTR_ERR(icache_dentry);
141 }
142
143 return 0;
144}
145module_init(cache_debugfs_init);
146
147MODULE_LICENSE("GPL v2");
diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c
index 524cea5b47f9..e48cc22724d9 100644
--- a/arch/sh/mm/cache-sh4.c
+++ b/arch/sh/mm/cache-sh4.c
@@ -2,49 +2,120 @@
2 * arch/sh/mm/cache-sh4.c 2 * arch/sh/mm/cache-sh4.c
3 * 3 *
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2001, 2002, 2003, 2004 Paul Mundt 5 * Copyright (C) 2001 - 2006 Paul Mundt
6 * Copyright (C) 2003 Richard Curnow 6 * Copyright (C) 2003 Richard Curnow
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General Public 8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive 9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details. 10 * for more details.
11 */ 11 */
12
13#include <linux/init.h> 12#include <linux/init.h>
14#include <linux/mman.h>
15#include <linux/mm.h> 13#include <linux/mm.h>
16#include <linux/threads.h>
17#include <asm/addrspace.h> 14#include <asm/addrspace.h>
18#include <asm/page.h>
19#include <asm/pgtable.h> 15#include <asm/pgtable.h>
20#include <asm/processor.h> 16#include <asm/processor.h>
21#include <asm/cache.h> 17#include <asm/cache.h>
22#include <asm/io.h> 18#include <asm/io.h>
23#include <asm/uaccess.h>
24#include <asm/pgalloc.h> 19#include <asm/pgalloc.h>
25#include <asm/mmu_context.h> 20#include <asm/mmu_context.h>
26#include <asm/cacheflush.h> 21#include <asm/cacheflush.h>
27 22
28extern void __flush_cache_4096_all(unsigned long start); 23/*
29static void __flush_cache_4096_all_ex(unsigned long start); 24 * The maximum number of pages we support up to when doing ranged dcache
30extern void __flush_dcache_all(void); 25 * flushing. Anything exceeding this will simply flush the dcache in its
31static void __flush_dcache_all_ex(void); 26 * entirety.
27 */
28#define MAX_DCACHE_PAGES 64 /* XXX: Tune for ways */
29
30static void __flush_dcache_segment_1way(unsigned long start,
31 unsigned long extent);
32static void __flush_dcache_segment_2way(unsigned long start,
33 unsigned long extent);
34static void __flush_dcache_segment_4way(unsigned long start,
35 unsigned long extent);
36
37static void __flush_cache_4096(unsigned long addr, unsigned long phys,
38 unsigned long exec_offset);
39
40/*
41 * This is initialised here to ensure that it is not placed in the BSS. If
42 * that were to happen, note that cache_init gets called before the BSS is
43 * cleared, so this would get nulled out which would be hopeless.
44 */
45static void (*__flush_dcache_segment_fn)(unsigned long, unsigned long) =
46 (void (*)(unsigned long, unsigned long))0xdeadbeef;
47
48static void compute_alias(struct cache_info *c)
49{
50 c->alias_mask = ((c->sets - 1) << c->entry_shift) & ~(PAGE_SIZE - 1);
51 c->n_aliases = (c->alias_mask >> PAGE_SHIFT) + 1;
52}
53
54static void __init emit_cache_params(void)
55{
56 printk("PVR=%08x CVR=%08x PRR=%08x\n",
57 ctrl_inl(CCN_PVR),
58 ctrl_inl(CCN_CVR),
59 ctrl_inl(CCN_PRR));
60 printk("I-cache : n_ways=%d n_sets=%d way_incr=%d\n",
61 cpu_data->icache.ways,
62 cpu_data->icache.sets,
63 cpu_data->icache.way_incr);
64 printk("I-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
65 cpu_data->icache.entry_mask,
66 cpu_data->icache.alias_mask,
67 cpu_data->icache.n_aliases);
68 printk("D-cache : n_ways=%d n_sets=%d way_incr=%d\n",
69 cpu_data->dcache.ways,
70 cpu_data->dcache.sets,
71 cpu_data->dcache.way_incr);
72 printk("D-cache : entry_mask=0x%08x alias_mask=0x%08x n_aliases=%d\n",
73 cpu_data->dcache.entry_mask,
74 cpu_data->dcache.alias_mask,
75 cpu_data->dcache.n_aliases);
76
77 if (!__flush_dcache_segment_fn)
78 panic("unknown number of cache ways\n");
79}
32 80
33/* 81/*
34 * SH-4 has virtually indexed and physically tagged cache. 82 * SH-4 has virtually indexed and physically tagged cache.
35 */ 83 */
36 84
37struct semaphore p3map_sem[4]; 85/* Worst case assumed to be 64k cache, direct-mapped i.e. 4 synonym bits. */
86#define MAX_P3_SEMAPHORES 16
87
88struct semaphore p3map_sem[MAX_P3_SEMAPHORES];
38 89
39void __init p3_cache_init(void) 90void __init p3_cache_init(void)
40{ 91{
41 if (remap_area_pages(P3SEG, 0, PAGE_SIZE*4, _PAGE_CACHABLE)) 92 int i;
93
94 compute_alias(&cpu_data->icache);
95 compute_alias(&cpu_data->dcache);
96
97 switch (cpu_data->dcache.ways) {
98 case 1:
99 __flush_dcache_segment_fn = __flush_dcache_segment_1way;
100 break;
101 case 2:
102 __flush_dcache_segment_fn = __flush_dcache_segment_2way;
103 break;
104 case 4:
105 __flush_dcache_segment_fn = __flush_dcache_segment_4way;
106 break;
107 default:
108 __flush_dcache_segment_fn = NULL;
109 break;
110 }
111
112 emit_cache_params();
113
114 if (remap_area_pages(P3SEG, 0, PAGE_SIZE * 4, _PAGE_CACHABLE))
42 panic("%s failed.", __FUNCTION__); 115 panic("%s failed.", __FUNCTION__);
43 116
44 sema_init (&p3map_sem[0], 1); 117 for (i = 0; i < cpu_data->dcache.n_aliases; i++)
45 sema_init (&p3map_sem[1], 1); 118 sema_init(&p3map_sem[i], 1);
46 sema_init (&p3map_sem[2], 1);
47 sema_init (&p3map_sem[3], 1);
48} 119}
49 120
50/* 121/*
@@ -89,7 +160,6 @@ void __flush_purge_region(void *start, int size)
89 } 160 }
90} 161}
91 162
92
93/* 163/*
94 * No write back please 164 * No write back please
95 */ 165 */
@@ -108,40 +178,6 @@ void __flush_invalidate_region(void *start, int size)
108 } 178 }
109} 179}
110 180
111static void __flush_dcache_all_ex(void)
112{
113 unsigned long addr, end_addr, entry_offset;
114
115 end_addr = CACHE_OC_ADDRESS_ARRAY + (cpu_data->dcache.sets << cpu_data->dcache.entry_shift) * cpu_data->dcache.ways;
116 entry_offset = 1 << cpu_data->dcache.entry_shift;
117 for (addr = CACHE_OC_ADDRESS_ARRAY; addr < end_addr; addr += entry_offset) {
118 ctrl_outl(0, addr);
119 }
120}
121
122static void __flush_cache_4096_all_ex(unsigned long start)
123{
124 unsigned long addr, entry_offset;
125 int i;
126
127 entry_offset = 1 << cpu_data->dcache.entry_shift;
128 for (i = 0; i < cpu_data->dcache.ways; i++, start += cpu_data->dcache.way_incr) {
129 for (addr = CACHE_OC_ADDRESS_ARRAY + start;
130 addr < CACHE_OC_ADDRESS_ARRAY + 4096 + start;
131 addr += entry_offset) {
132 ctrl_outl(0, addr);
133 }
134 }
135}
136
137void flush_cache_4096_all(unsigned long start)
138{
139 if (cpu_data->dcache.ways == 1)
140 __flush_cache_4096_all(start);
141 else
142 __flush_cache_4096_all_ex(start);
143}
144
145/* 181/*
146 * Write back the range of D-cache, and purge the I-cache. 182 * Write back the range of D-cache, and purge the I-cache.
147 * 183 *
@@ -153,14 +189,14 @@ void flush_icache_range(unsigned long start, unsigned long end)
153} 189}
154 190
155/* 191/*
156 * Write back the D-cache and purge the I-cache for signal trampoline. 192 * Write back the D-cache and purge the I-cache for signal trampoline.
157 * .. which happens to be the same behavior as flush_icache_range(). 193 * .. which happens to be the same behavior as flush_icache_range().
158 * So, we simply flush out a line. 194 * So, we simply flush out a line.
159 */ 195 */
160void flush_cache_sigtramp(unsigned long addr) 196void flush_cache_sigtramp(unsigned long addr)
161{ 197{
162 unsigned long v, index; 198 unsigned long v, index;
163 unsigned long flags; 199 unsigned long flags;
164 int i; 200 int i;
165 201
166 v = addr & ~(L1_CACHE_BYTES-1); 202 v = addr & ~(L1_CACHE_BYTES-1);
@@ -172,30 +208,33 @@ void flush_cache_sigtramp(unsigned long addr)
172 208
173 local_irq_save(flags); 209 local_irq_save(flags);
174 jump_to_P2(); 210 jump_to_P2();
175 for(i = 0; i < cpu_data->icache.ways; i++, index += cpu_data->icache.way_incr) 211
212 for (i = 0; i < cpu_data->icache.ways;
213 i++, index += cpu_data->icache.way_incr)
176 ctrl_outl(0, index); /* Clear out Valid-bit */ 214 ctrl_outl(0, index); /* Clear out Valid-bit */
215
177 back_to_P1(); 216 back_to_P1();
217 wmb();
178 local_irq_restore(flags); 218 local_irq_restore(flags);
179} 219}
180 220
181static inline void flush_cache_4096(unsigned long start, 221static inline void flush_cache_4096(unsigned long start,
182 unsigned long phys) 222 unsigned long phys)
183{ 223{
184 unsigned long flags; 224 unsigned long flags, exec_offset = 0;
185 extern void __flush_cache_4096(unsigned long addr, unsigned long phys, unsigned long exec_offset);
186 225
187 /* 226 /*
188 * SH7751, SH7751R, and ST40 have no restriction to handle cache. 227 * All types of SH-4 require PC to be in P2 to operate on the I-cache.
189 * (While SH7750 must do that at P2 area.) 228 * Some types of SH-4 require PC to be in P2 to operate on the D-cache.
190 */ 229 */
191 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) 230 if ((cpu_data->flags & CPU_HAS_P2_FLUSH_BUG) ||
192 || start < CACHE_OC_ADDRESS_ARRAY) { 231 (start < CACHE_OC_ADDRESS_ARRAY))
193 local_irq_save(flags); 232 exec_offset = 0x20000000;
194 __flush_cache_4096(start | SH_CACHE_ASSOC, P1SEGADDR(phys), 0x20000000); 233
195 local_irq_restore(flags); 234 local_irq_save(flags);
196 } else { 235 __flush_cache_4096(start | SH_CACHE_ASSOC,
197 __flush_cache_4096(start | SH_CACHE_ASSOC, P1SEGADDR(phys), 0); 236 P1SEGADDR(phys), exec_offset);
198 } 237 local_irq_restore(flags);
199} 238}
200 239
201/* 240/*
@@ -206,15 +245,19 @@ void flush_dcache_page(struct page *page)
206{ 245{
207 if (test_bit(PG_mapped, &page->flags)) { 246 if (test_bit(PG_mapped, &page->flags)) {
208 unsigned long phys = PHYSADDR(page_address(page)); 247 unsigned long phys = PHYSADDR(page_address(page));
248 unsigned long addr = CACHE_OC_ADDRESS_ARRAY;
249 int i, n;
209 250
210 /* Loop all the D-cache */ 251 /* Loop all the D-cache */
211 flush_cache_4096(CACHE_OC_ADDRESS_ARRAY, phys); 252 n = cpu_data->dcache.n_aliases;
212 flush_cache_4096(CACHE_OC_ADDRESS_ARRAY | 0x1000, phys); 253 for (i = 0; i < n; i++, addr += PAGE_SIZE)
213 flush_cache_4096(CACHE_OC_ADDRESS_ARRAY | 0x2000, phys); 254 flush_cache_4096(addr, phys);
214 flush_cache_4096(CACHE_OC_ADDRESS_ARRAY | 0x3000, phys);
215 } 255 }
256
257 wmb();
216} 258}
217 259
260/* TODO: Selective icache invalidation through IC address array.. */
218static inline void flush_icache_all(void) 261static inline void flush_icache_all(void)
219{ 262{
220 unsigned long flags, ccr; 263 unsigned long flags, ccr;
@@ -227,34 +270,142 @@ static inline void flush_icache_all(void)
227 ccr |= CCR_CACHE_ICI; 270 ccr |= CCR_CACHE_ICI;
228 ctrl_outl(ccr, CCR); 271 ctrl_outl(ccr, CCR);
229 272
273 /*
274 * back_to_P1() will take care of the barrier for us, don't add
275 * another one!
276 */
277
230 back_to_P1(); 278 back_to_P1();
231 local_irq_restore(flags); 279 local_irq_restore(flags);
232} 280}
233 281
282void flush_dcache_all(void)
283{
284 (*__flush_dcache_segment_fn)(0UL, cpu_data->dcache.way_size);
285 wmb();
286}
287
234void flush_cache_all(void) 288void flush_cache_all(void)
235{ 289{
236 if (cpu_data->dcache.ways == 1) 290 flush_dcache_all();
237 __flush_dcache_all();
238 else
239 __flush_dcache_all_ex();
240 flush_icache_all(); 291 flush_icache_all();
241} 292}
242 293
294static void __flush_cache_mm(struct mm_struct *mm, unsigned long start,
295 unsigned long end)
296{
297 unsigned long d = 0, p = start & PAGE_MASK;
298 unsigned long alias_mask = cpu_data->dcache.alias_mask;
299 unsigned long n_aliases = cpu_data->dcache.n_aliases;
300 unsigned long select_bit;
301 unsigned long all_aliases_mask;
302 unsigned long addr_offset;
303 pgd_t *dir;
304 pmd_t *pmd;
305 pud_t *pud;
306 pte_t *pte;
307 int i;
308
309 dir = pgd_offset(mm, p);
310 pud = pud_offset(dir, p);
311 pmd = pmd_offset(pud, p);
312 end = PAGE_ALIGN(end);
313
314 all_aliases_mask = (1 << n_aliases) - 1;
315
316 do {
317 if (pmd_none(*pmd) || unlikely(pmd_bad(*pmd))) {
318 p &= PMD_MASK;
319 p += PMD_SIZE;
320 pmd++;
321
322 continue;
323 }
324
325 pte = pte_offset_kernel(pmd, p);
326
327 do {
328 unsigned long phys;
329 pte_t entry = *pte;
330
331 if (!(pte_val(entry) & _PAGE_PRESENT)) {
332 pte++;
333 p += PAGE_SIZE;
334 continue;
335 }
336
337 phys = pte_val(entry) & PTE_PHYS_MASK;
338
339 if ((p ^ phys) & alias_mask) {
340 d |= 1 << ((p & alias_mask) >> PAGE_SHIFT);
341 d |= 1 << ((phys & alias_mask) >> PAGE_SHIFT);
342
343 if (d == all_aliases_mask)
344 goto loop_exit;
345 }
346
347 pte++;
348 p += PAGE_SIZE;
349 } while (p < end && ((unsigned long)pte & ~PAGE_MASK));
350 pmd++;
351 } while (p < end);
352
353loop_exit:
354 addr_offset = 0;
355 select_bit = 1;
356
357 for (i = 0; i < n_aliases; i++) {
358 if (d & select_bit) {
359 (*__flush_dcache_segment_fn)(addr_offset, PAGE_SIZE);
360 wmb();
361 }
362
363 select_bit <<= 1;
364 addr_offset += PAGE_SIZE;
365 }
366}
367
368/*
369 * Note : (RPC) since the caches are physically tagged, the only point
370 * of flush_cache_mm for SH-4 is to get rid of aliases from the
371 * D-cache. The assumption elsewhere, e.g. flush_cache_range, is that
372 * lines can stay resident so long as the virtual address they were
373 * accessed with (hence cache set) is in accord with the physical
374 * address (i.e. tag). It's no different here. So I reckon we don't
375 * need to flush the I-cache, since aliases don't matter for that. We
376 * should try that.
377 *
378 * Caller takes mm->mmap_sem.
379 */
243void flush_cache_mm(struct mm_struct *mm) 380void flush_cache_mm(struct mm_struct *mm)
244{ 381{
245 /* Is there any good way? */ 382 /*
246 /* XXX: possibly call flush_cache_range for each vm area */ 383 * If cache is only 4k-per-way, there are never any 'aliases'. Since
247 /* 384 * the cache is physically tagged, the data can just be left in there.
248 * FIXME: Really, the optimal solution here would be able to flush out
249 * individual lines created by the specified context, but this isn't
250 * feasible for a number of architectures (such as MIPS, and some
251 * SPARC) .. is this possible for SuperH?
252 *
253 * In the meantime, we'll just flush all of the caches.. this
254 * seems to be the simplest way to avoid at least a few wasted
255 * cache flushes. -Lethal
256 */ 385 */
257 flush_cache_all(); 386 if (cpu_data->dcache.n_aliases == 0)
387 return;
388
389 /*
390 * Don't bother groveling around the dcache for the VMA ranges
391 * if there are too many PTEs to make it worthwhile.
392 */
393 if (mm->nr_ptes >= MAX_DCACHE_PAGES)
394 flush_dcache_all();
395 else {
396 struct vm_area_struct *vma;
397
398 /*
399 * In this case there are reasonably sized ranges to flush,
400 * iterate through the VMA list and take care of any aliases.
401 */
402 for (vma = mm->mmap; vma; vma = vma->vm_next)
403 __flush_cache_mm(mm, vma->vm_start, vma->vm_end);
404 }
405
406 /* Only touch the icache if one of the VMAs has VM_EXEC set. */
407 if (mm->exec_vm)
408 flush_icache_all();
258} 409}
259 410
260/* 411/*
@@ -263,27 +414,40 @@ void flush_cache_mm(struct mm_struct *mm)
263 * ADDR: Virtual Address (U0 address) 414 * ADDR: Virtual Address (U0 address)
264 * PFN: Physical page number 415 * PFN: Physical page number
265 */ 416 */
266void flush_cache_page(struct vm_area_struct *vma, unsigned long address, unsigned long pfn) 417void flush_cache_page(struct vm_area_struct *vma, unsigned long address,
418 unsigned long pfn)
267{ 419{
268 unsigned long phys = pfn << PAGE_SHIFT; 420 unsigned long phys = pfn << PAGE_SHIFT;
421 unsigned int alias_mask;
422
423 alias_mask = cpu_data->dcache.alias_mask;
269 424
270 /* We only need to flush D-cache when we have alias */ 425 /* We only need to flush D-cache when we have alias */
271 if ((address^phys) & CACHE_ALIAS) { 426 if ((address^phys) & alias_mask) {
272 /* Loop 4K of the D-cache */ 427 /* Loop 4K of the D-cache */
273 flush_cache_4096( 428 flush_cache_4096(
274 CACHE_OC_ADDRESS_ARRAY | (address & CACHE_ALIAS), 429 CACHE_OC_ADDRESS_ARRAY | (address & alias_mask),
275 phys); 430 phys);
276 /* Loop another 4K of the D-cache */ 431 /* Loop another 4K of the D-cache */
277 flush_cache_4096( 432 flush_cache_4096(
278 CACHE_OC_ADDRESS_ARRAY | (phys & CACHE_ALIAS), 433 CACHE_OC_ADDRESS_ARRAY | (phys & alias_mask),
279 phys); 434 phys);
280 } 435 }
281 436
282 if (vma->vm_flags & VM_EXEC) 437 alias_mask = cpu_data->icache.alias_mask;
283 /* Loop 4K (half) of the I-cache */ 438 if (vma->vm_flags & VM_EXEC) {
439 /*
440 * Evict entries from the portion of the cache from which code
441 * may have been executed at this address (virtual). There's
442 * no need to evict from the portion corresponding to the
443 * physical address as for the D-cache, because we know the
444 * kernel has never executed the code through its identity
445 * translation.
446 */
284 flush_cache_4096( 447 flush_cache_4096(
285 CACHE_IC_ADDRESS_ARRAY | (address & 0x1000), 448 CACHE_IC_ADDRESS_ARRAY | (address & alias_mask),
286 phys); 449 phys);
450 }
287} 451}
288 452
289/* 453/*
@@ -298,52 +462,31 @@ void flush_cache_page(struct vm_area_struct *vma, unsigned long address, unsigne
298void flush_cache_range(struct vm_area_struct *vma, unsigned long start, 462void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
299 unsigned long end) 463 unsigned long end)
300{ 464{
301 unsigned long p = start & PAGE_MASK; 465 /*
302 pgd_t *dir; 466 * If cache is only 4k-per-way, there are never any 'aliases'. Since
303 pmd_t *pmd; 467 * the cache is physically tagged, the data can just be left in there.
304 pte_t *pte; 468 */
305 pte_t entry; 469 if (cpu_data->dcache.n_aliases == 0)
306 unsigned long phys; 470 return;
307 unsigned long d = 0;
308
309 dir = pgd_offset(vma->vm_mm, p);
310 pmd = pmd_offset(dir, p);
311 471
312 do { 472 /*
313 if (pmd_none(*pmd) || pmd_bad(*pmd)) { 473 * Don't bother with the lookup and alias check if we have a
314 p &= ~((1 << PMD_SHIFT) -1); 474 * wide range to cover, just blow away the dcache in its
315 p += (1 << PMD_SHIFT); 475 * entirety instead. -- PFM.
316 pmd++; 476 */
317 continue; 477 if (((end - start) >> PAGE_SHIFT) >= MAX_DCACHE_PAGES)
318 } 478 flush_dcache_all();
319 pte = pte_offset_kernel(pmd, p); 479 else
320 do { 480 __flush_cache_mm(vma->vm_mm, start, end);
321 entry = *pte; 481
322 if ((pte_val(entry) & _PAGE_PRESENT)) { 482 if (vma->vm_flags & VM_EXEC) {
323 phys = pte_val(entry)&PTE_PHYS_MASK; 483 /*
324 if ((p^phys) & CACHE_ALIAS) { 484 * TODO: Is this required??? Need to look at how I-cache
325 d |= 1 << ((p & CACHE_ALIAS)>>12); 485 * coherency is assured when new programs are loaded to see if
326 d |= 1 << ((phys & CACHE_ALIAS)>>12); 486 * this matters.
327 if (d == 0x0f) 487 */
328 goto loop_exit;
329 }
330 }
331 pte++;
332 p += PAGE_SIZE;
333 } while (p < end && ((unsigned long)pte & ~PAGE_MASK));
334 pmd++;
335 } while (p < end);
336 loop_exit:
337 if (d & 1)
338 flush_cache_4096_all(0);
339 if (d & 2)
340 flush_cache_4096_all(0x1000);
341 if (d & 4)
342 flush_cache_4096_all(0x2000);
343 if (d & 8)
344 flush_cache_4096_all(0x3000);
345 if (vma->vm_flags & VM_EXEC)
346 flush_icache_all(); 488 flush_icache_all();
489 }
347} 490}
348 491
349/* 492/*
@@ -357,5 +500,273 @@ void flush_icache_user_range(struct vm_area_struct *vma,
357 struct page *page, unsigned long addr, int len) 500 struct page *page, unsigned long addr, int len)
358{ 501{
359 flush_cache_page(vma, addr, page_to_pfn(page)); 502 flush_cache_page(vma, addr, page_to_pfn(page));
503 mb();
504}
505
506/**
507 * __flush_cache_4096
508 *
509 * @addr: address in memory mapped cache array
510 * @phys: P1 address to flush (has to match tags if addr has 'A' bit
511 * set i.e. associative write)
512 * @exec_offset: set to 0x20000000 if flush has to be executed from P2
513 * region else 0x0
514 *
515 * The offset into the cache array implied by 'addr' selects the
516 * 'colour' of the virtual address range that will be flushed. The
517 * operation (purge/write-back) is selected by the lower 2 bits of
518 * 'phys'.
519 */
520static void __flush_cache_4096(unsigned long addr, unsigned long phys,
521 unsigned long exec_offset)
522{
523 int way_count;
524 unsigned long base_addr = addr;
525 struct cache_info *dcache;
526 unsigned long way_incr;
527 unsigned long a, ea, p;
528 unsigned long temp_pc;
529
530 dcache = &cpu_data->dcache;
531 /* Write this way for better assembly. */
532 way_count = dcache->ways;
533 way_incr = dcache->way_incr;
534
535 /*
536 * Apply exec_offset (i.e. branch to P2 if required.).
537 *
538 * FIXME:
539 *
540 * If I write "=r" for the (temp_pc), it puts this in r6 hence
541 * trashing exec_offset before it's been added on - why? Hence
542 * "=&r" as a 'workaround'
543 */
544 asm volatile("mov.l 1f, %0\n\t"
545 "add %1, %0\n\t"
546 "jmp @%0\n\t"
547 "nop\n\t"
548 ".balign 4\n\t"
549 "1: .long 2f\n\t"
550 "2:\n" : "=&r" (temp_pc) : "r" (exec_offset));
551
552 /*
553 * We know there will be >=1 iteration, so write as do-while to avoid
554 * pointless nead-of-loop check for 0 iterations.
555 */
556 do {
557 ea = base_addr + PAGE_SIZE;
558 a = base_addr;
559 p = phys;
560
561 do {
562 *(volatile unsigned long *)a = p;
563 /*
564 * Next line: intentionally not p+32, saves an add, p
565 * will do since only the cache tag bits need to
566 * match.
567 */
568 *(volatile unsigned long *)(a+32) = p;
569 a += 64;
570 p += 64;
571 } while (a < ea);
572
573 base_addr += way_incr;
574 } while (--way_count != 0);
360} 575}
361 576
577/*
578 * Break the 1, 2 and 4 way variants of this out into separate functions to
579 * avoid nearly all the overhead of having the conditional stuff in the function
580 * bodies (+ the 1 and 2 way cases avoid saving any registers too).
581 */
582static void __flush_dcache_segment_1way(unsigned long start,
583 unsigned long extent_per_way)
584{
585 unsigned long orig_sr, sr_with_bl;
586 unsigned long base_addr;
587 unsigned long way_incr, linesz, way_size;
588 struct cache_info *dcache;
589 register unsigned long a0, a0e;
590
591 asm volatile("stc sr, %0" : "=r" (orig_sr));
592 sr_with_bl = orig_sr | (1<<28);
593 base_addr = ((unsigned long)&empty_zero_page[0]);
594
595 /*
596 * The previous code aligned base_addr to 16k, i.e. the way_size of all
597 * existing SH-4 D-caches. Whilst I don't see a need to have this
598 * aligned to any better than the cache line size (which it will be
599 * anyway by construction), let's align it to at least the way_size of
600 * any existing or conceivable SH-4 D-cache. -- RPC
601 */
602 base_addr = ((base_addr >> 16) << 16);
603 base_addr |= start;
604
605 dcache = &cpu_data->dcache;
606 linesz = dcache->linesz;
607 way_incr = dcache->way_incr;
608 way_size = dcache->way_size;
609
610 a0 = base_addr;
611 a0e = base_addr + extent_per_way;
612 do {
613 asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
614 asm volatile("movca.l r0, @%0\n\t"
615 "ocbi @%0" : : "r" (a0));
616 a0 += linesz;
617 asm volatile("movca.l r0, @%0\n\t"
618 "ocbi @%0" : : "r" (a0));
619 a0 += linesz;
620 asm volatile("movca.l r0, @%0\n\t"
621 "ocbi @%0" : : "r" (a0));
622 a0 += linesz;
623 asm volatile("movca.l r0, @%0\n\t"
624 "ocbi @%0" : : "r" (a0));
625 asm volatile("ldc %0, sr" : : "r" (orig_sr));
626 a0 += linesz;
627 } while (a0 < a0e);
628}
629
630static void __flush_dcache_segment_2way(unsigned long start,
631 unsigned long extent_per_way)
632{
633 unsigned long orig_sr, sr_with_bl;
634 unsigned long base_addr;
635 unsigned long way_incr, linesz, way_size;
636 struct cache_info *dcache;
637 register unsigned long a0, a1, a0e;
638
639 asm volatile("stc sr, %0" : "=r" (orig_sr));
640 sr_with_bl = orig_sr | (1<<28);
641 base_addr = ((unsigned long)&empty_zero_page[0]);
642
643 /* See comment under 1-way above */
644 base_addr = ((base_addr >> 16) << 16);
645 base_addr |= start;
646
647 dcache = &cpu_data->dcache;
648 linesz = dcache->linesz;
649 way_incr = dcache->way_incr;
650 way_size = dcache->way_size;
651
652 a0 = base_addr;
653 a1 = a0 + way_incr;
654 a0e = base_addr + extent_per_way;
655 do {
656 asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
657 asm volatile("movca.l r0, @%0\n\t"
658 "movca.l r0, @%1\n\t"
659 "ocbi @%0\n\t"
660 "ocbi @%1" : :
661 "r" (a0), "r" (a1));
662 a0 += linesz;
663 a1 += linesz;
664 asm volatile("movca.l r0, @%0\n\t"
665 "movca.l r0, @%1\n\t"
666 "ocbi @%0\n\t"
667 "ocbi @%1" : :
668 "r" (a0), "r" (a1));
669 a0 += linesz;
670 a1 += linesz;
671 asm volatile("movca.l r0, @%0\n\t"
672 "movca.l r0, @%1\n\t"
673 "ocbi @%0\n\t"
674 "ocbi @%1" : :
675 "r" (a0), "r" (a1));
676 a0 += linesz;
677 a1 += linesz;
678 asm volatile("movca.l r0, @%0\n\t"
679 "movca.l r0, @%1\n\t"
680 "ocbi @%0\n\t"
681 "ocbi @%1" : :
682 "r" (a0), "r" (a1));
683 asm volatile("ldc %0, sr" : : "r" (orig_sr));
684 a0 += linesz;
685 a1 += linesz;
686 } while (a0 < a0e);
687}
688
689static void __flush_dcache_segment_4way(unsigned long start,
690 unsigned long extent_per_way)
691{
692 unsigned long orig_sr, sr_with_bl;
693 unsigned long base_addr;
694 unsigned long way_incr, linesz, way_size;
695 struct cache_info *dcache;
696 register unsigned long a0, a1, a2, a3, a0e;
697
698 asm volatile("stc sr, %0" : "=r" (orig_sr));
699 sr_with_bl = orig_sr | (1<<28);
700 base_addr = ((unsigned long)&empty_zero_page[0]);
701
702 /* See comment under 1-way above */
703 base_addr = ((base_addr >> 16) << 16);
704 base_addr |= start;
705
706 dcache = &cpu_data->dcache;
707 linesz = dcache->linesz;
708 way_incr = dcache->way_incr;
709 way_size = dcache->way_size;
710
711 a0 = base_addr;
712 a1 = a0 + way_incr;
713 a2 = a1 + way_incr;
714 a3 = a2 + way_incr;
715 a0e = base_addr + extent_per_way;
716 do {
717 asm volatile("ldc %0, sr" : : "r" (sr_with_bl));
718 asm volatile("movca.l r0, @%0\n\t"
719 "movca.l r0, @%1\n\t"
720 "movca.l r0, @%2\n\t"
721 "movca.l r0, @%3\n\t"
722 "ocbi @%0\n\t"
723 "ocbi @%1\n\t"
724 "ocbi @%2\n\t"
725 "ocbi @%3\n\t" : :
726 "r" (a0), "r" (a1), "r" (a2), "r" (a3));
727 a0 += linesz;
728 a1 += linesz;
729 a2 += linesz;
730 a3 += linesz;
731 asm volatile("movca.l r0, @%0\n\t"
732 "movca.l r0, @%1\n\t"
733 "movca.l r0, @%2\n\t"
734 "movca.l r0, @%3\n\t"
735 "ocbi @%0\n\t"
736 "ocbi @%1\n\t"
737 "ocbi @%2\n\t"
738 "ocbi @%3\n\t" : :
739 "r" (a0), "r" (a1), "r" (a2), "r" (a3));
740 a0 += linesz;
741 a1 += linesz;
742 a2 += linesz;
743 a3 += linesz;
744 asm volatile("movca.l r0, @%0\n\t"
745 "movca.l r0, @%1\n\t"
746 "movca.l r0, @%2\n\t"
747 "movca.l r0, @%3\n\t"
748 "ocbi @%0\n\t"
749 "ocbi @%1\n\t"
750 "ocbi @%2\n\t"
751 "ocbi @%3\n\t" : :
752 "r" (a0), "r" (a1), "r" (a2), "r" (a3));
753 a0 += linesz;
754 a1 += linesz;
755 a2 += linesz;
756 a3 += linesz;
757 asm volatile("movca.l r0, @%0\n\t"
758 "movca.l r0, @%1\n\t"
759 "movca.l r0, @%2\n\t"
760 "movca.l r0, @%3\n\t"
761 "ocbi @%0\n\t"
762 "ocbi @%1\n\t"
763 "ocbi @%2\n\t"
764 "ocbi @%3\n\t" : :
765 "r" (a0), "r" (a1), "r" (a2), "r" (a3));
766 asm volatile("ldc %0, sr" : : "r" (orig_sr));
767 a0 += linesz;
768 a1 += linesz;
769 a2 += linesz;
770 a3 += linesz;
771 } while (a0 < a0e);
772}
diff --git a/arch/sh/mm/cache-sh7705.c b/arch/sh/mm/cache-sh7705.c
index bf94eedb0a8e..045abdf078f5 100644
--- a/arch/sh/mm/cache-sh7705.c
+++ b/arch/sh/mm/cache-sh7705.c
@@ -9,7 +9,6 @@
9 * for more details. 9 * for more details.
10 * 10 *
11 */ 11 */
12
13#include <linux/init.h> 12#include <linux/init.h>
14#include <linux/mman.h> 13#include <linux/mman.h>
15#include <linux/mm.h> 14#include <linux/mm.h>
@@ -25,14 +24,10 @@
25#include <asm/mmu_context.h> 24#include <asm/mmu_context.h>
26#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
27 26
28/* The 32KB cache on the SH7705 suffers from the same synonym problem 27/*
29 * as SH4 CPUs */ 28 * The 32KB cache on the SH7705 suffers from the same synonym problem
30 29 * as SH4 CPUs
31#define __pte_offset(address) \ 30 */
32 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
33#define pte_offset(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \
34 __pte_offset(address))
35
36static inline void cache_wback_all(void) 31static inline void cache_wback_all(void)
37{ 32{
38 unsigned long ways, waysize, addrstart; 33 unsigned long ways, waysize, addrstart;
@@ -73,7 +68,6 @@ void flush_icache_range(unsigned long start, unsigned long end)
73 __flush_wback_region((void *)start, end - start); 68 __flush_wback_region((void *)start, end - start);
74} 69}
75 70
76
77/* 71/*
78 * Writeback&Invalidate the D-cache of the page 72 * Writeback&Invalidate the D-cache of the page
79 */ 73 */
@@ -128,7 +122,6 @@ static void __flush_dcache_page(unsigned long phys)
128 local_irq_restore(flags); 122 local_irq_restore(flags);
129} 123}
130 124
131
132/* 125/*
133 * Write back & invalidate the D-cache of the page. 126 * Write back & invalidate the D-cache of the page.
134 * (To avoid "alias" issues) 127 * (To avoid "alias" issues)
@@ -186,7 +179,8 @@ void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
186 * 179 *
187 * ADDRESS: Virtual Address (U0 address) 180 * ADDRESS: Virtual Address (U0 address)
188 */ 181 */
189void flush_cache_page(struct vm_area_struct *vma, unsigned long address, unsigned long pfn) 182void flush_cache_page(struct vm_area_struct *vma, unsigned long address,
183 unsigned long pfn)
190{ 184{
191 __flush_dcache_page(pfn << PAGE_SHIFT); 185 __flush_dcache_page(pfn << PAGE_SHIFT);
192} 186}
@@ -203,4 +197,3 @@ void flush_icache_page(struct vm_area_struct *vma, struct page *page)
203{ 197{
204 __flush_purge_region(page_address(page), PAGE_SIZE); 198 __flush_purge_region(page_address(page), PAGE_SIZE);
205} 199}
206
diff --git a/arch/sh/mm/clear_page.S b/arch/sh/mm/clear_page.S
index 08acead7b2a1..7b96425ae270 100644
--- a/arch/sh/mm/clear_page.S
+++ b/arch/sh/mm/clear_page.S
@@ -193,102 +193,5 @@ ENTRY(__clear_user_page)
193 nop 193 nop
194.L4096: .word 4096 194.L4096: .word 4096
195 195
196ENTRY(__flush_cache_4096)
197 mov.l 1f,r3
198 add r6,r3
199 mov r4,r0
200 mov #64,r2
201 shll r2
202 mov #64,r6
203 jmp @r3
204 mov #96,r7
205 .align 2
2061: .long 2f
2072:
208 .rept 32
209 mov.l r5,@r0
210 mov.l r5,@(32,r0)
211 mov.l r5,@(r0,r6)
212 mov.l r5,@(r0,r7)
213 add r2,r5
214 add r2,r0
215 .endr
216 nop
217 nop
218 nop
219 nop
220 nop
221 nop
222 nop
223 rts
224 nop
225
226ENTRY(__flush_dcache_all)
227 mov.l 2f,r0
228 mov.l 3f,r4
229 and r0,r4 ! r4 = (unsigned long)&empty_zero_page[0] & ~0xffffc000
230 stc sr,r1 ! save SR
231 mov.l 4f,r2
232 or r1,r2
233 mov #32,r3
234 shll2 r3
2351:
236 ldc r2,sr ! set BL bit
237 movca.l r0,@r4
238 ocbi @r4
239 add #32,r4
240 movca.l r0,@r4
241 ocbi @r4
242 add #32,r4
243 movca.l r0,@r4
244 ocbi @r4
245 add #32,r4
246 movca.l r0,@r4
247 ocbi @r4
248 ldc r1,sr ! restore SR
249 dt r3
250 bf/s 1b
251 add #32,r4
252
253 rts
254 nop
255 .align 2
2562: .long 0xffffc000
2573: .long empty_zero_page
2584: .long 0x10000000 ! BL bit
259
260/* __flush_cache_4096_all(unsigned long addr) */
261ENTRY(__flush_cache_4096_all)
262 mov.l 2f,r0
263 mov.l 3f,r2
264 and r0,r2
265 or r2,r4 ! r4 = addr | (unsigned long)&empty_zero_page[0] & ~0x3fff
266 stc sr,r1 ! save SR
267 mov.l 4f,r2
268 or r1,r2
269 mov #32,r3
2701:
271 ldc r2,sr ! set BL bit
272 movca.l r0,@r4
273 ocbi @r4
274 add #32,r4
275 movca.l r0,@r4
276 ocbi @r4
277 add #32,r4
278 movca.l r0,@r4
279 ocbi @r4
280 add #32,r4
281 movca.l r0,@r4
282 ocbi @r4
283 ldc r1,sr ! restore SR
284 dt r3
285 bf/s 1b
286 add #32,r4
287
288 rts
289 nop
290 .align 2
2912: .long 0xffffc000
2923: .long empty_zero_page
2934: .long 0x10000000 ! BL bit
294#endif 196#endif
197
diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c
index ee73e30263af..c81e6b67ad30 100644
--- a/arch/sh/mm/consistent.c
+++ b/arch/sh/mm/consistent.c
@@ -9,6 +9,8 @@
9 */ 9 */
10#include <linux/mm.h> 10#include <linux/mm.h>
11#include <linux/dma-mapping.h> 11#include <linux/dma-mapping.h>
12#include <asm/cacheflush.h>
13#include <asm/addrspace.h>
12#include <asm/io.h> 14#include <asm/io.h>
13 15
14void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle) 16void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle)
diff --git a/arch/sh/mm/fault.c b/arch/sh/mm/fault.c
index 775f86cd3fe8..c69fd603226a 100644
--- a/arch/sh/mm/fault.c
+++ b/arch/sh/mm/fault.c
@@ -1,33 +1,22 @@
1/* $Id: fault.c,v 1.14 2004/01/13 05:52:11 kkojima Exp $ 1/*
2 * Page fault handler for SH with an MMU.
2 * 3 *
3 * linux/arch/sh/mm/fault.c
4 * Copyright (C) 1999 Niibe Yutaka 4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2003 Paul Mundt 5 * Copyright (C) 2003 Paul Mundt
6 * 6 *
7 * Based on linux/arch/i386/mm/fault.c: 7 * Based on linux/arch/i386/mm/fault.c:
8 * Copyright (C) 1995 Linus Torvalds 8 * Copyright (C) 1995 Linus Torvalds
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
9 */ 13 */
10
11#include <linux/signal.h>
12#include <linux/sched.h>
13#include <linux/kernel.h> 14#include <linux/kernel.h>
14#include <linux/errno.h>
15#include <linux/string.h>
16#include <linux/types.h>
17#include <linux/ptrace.h>
18#include <linux/mman.h>
19#include <linux/mm.h> 15#include <linux/mm.h>
20#include <linux/smp.h> 16#include <linux/hardirq.h>
21#include <linux/smp_lock.h> 17#include <linux/kprobes.h>
22#include <linux/interrupt.h>
23#include <linux/module.h>
24
25#include <asm/system.h> 18#include <asm/system.h>
26#include <asm/io.h>
27#include <asm/uaccess.h>
28#include <asm/pgalloc.h>
29#include <asm/mmu_context.h> 19#include <asm/mmu_context.h>
30#include <asm/cacheflush.h>
31#include <asm/kgdb.h> 20#include <asm/kgdb.h>
32 21
33extern void die(const char *,struct pt_regs *,long); 22extern void die(const char *,struct pt_regs *,long);
@@ -187,18 +176,30 @@ do_sigbus:
187 goto no_context; 176 goto no_context;
188} 177}
189 178
179#ifdef CONFIG_SH_STORE_QUEUES
190/* 180/*
191 * Called with interrupt disabled. 181 * This is a special case for the SH-4 store queues, as pages for this
182 * space still need to be faulted in before it's possible to flush the
183 * store queue cache for writeout to the remapped region.
192 */ 184 */
193asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess, 185#define P3_ADDR_MAX (P4SEG_STORE_QUE + 0x04000000)
194 unsigned long address) 186#else
187#define P3_ADDR_MAX P4SEG
188#endif
189
190/*
191 * Called with interrupts disabled.
192 */
193asmlinkage int __kprobes __do_page_fault(struct pt_regs *regs,
194 unsigned long writeaccess,
195 unsigned long address)
195{ 196{
196 unsigned long addrmax = P4SEG;
197 pgd_t *pgd; 197 pgd_t *pgd;
198 pud_t *pud;
198 pmd_t *pmd; 199 pmd_t *pmd;
199 pte_t *pte; 200 pte_t *pte;
200 pte_t entry; 201 pte_t entry;
201 struct mm_struct *mm; 202 struct mm_struct *mm = current->mm;
202 spinlock_t *ptl; 203 spinlock_t *ptl;
203 int ret = 1; 204 int ret = 1;
204 205
@@ -207,31 +208,37 @@ asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
207 kgdb_bus_err_hook(); 208 kgdb_bus_err_hook();
208#endif 209#endif
209 210
210#ifdef CONFIG_SH_STORE_QUEUES 211 /*
211 addrmax = P4SEG_STORE_QUE + 0x04000000; 212 * We don't take page faults for P1, P2, and parts of P4, these
212#endif 213 * are always mapped, whether it be due to legacy behaviour in
213 214 * 29-bit mode, or due to PMB configuration in 32-bit mode.
214 if (address >= P3SEG && address < addrmax) { 215 */
216 if (address >= P3SEG && address < P3_ADDR_MAX) {
215 pgd = pgd_offset_k(address); 217 pgd = pgd_offset_k(address);
216 mm = NULL; 218 mm = NULL;
217 } else if (address >= TASK_SIZE) 219 } else {
218 return 1; 220 if (unlikely(address >= TASK_SIZE || !mm))
219 else if (!(mm = current->mm)) 221 return 1;
220 return 1; 222
221 else
222 pgd = pgd_offset(mm, address); 223 pgd = pgd_offset(mm, address);
224 }
223 225
224 pmd = pmd_offset(pgd, address); 226 pud = pud_offset(pgd, address);
227 if (pud_none_or_clear_bad(pud))
228 return 1;
229 pmd = pmd_offset(pud, address);
225 if (pmd_none_or_clear_bad(pmd)) 230 if (pmd_none_or_clear_bad(pmd))
226 return 1; 231 return 1;
232
227 if (mm) 233 if (mm)
228 pte = pte_offset_map_lock(mm, pmd, address, &ptl); 234 pte = pte_offset_map_lock(mm, pmd, address, &ptl);
229 else 235 else
230 pte = pte_offset_kernel(pmd, address); 236 pte = pte_offset_kernel(pmd, address);
231 237
232 entry = *pte; 238 entry = *pte;
233 if (pte_none(entry) || pte_not_present(entry) 239 if (unlikely(pte_none(entry) || pte_not_present(entry)))
234 || (writeaccess && !pte_write(entry))) 240 goto unlock;
241 if (unlikely(writeaccess && !pte_write(entry)))
235 goto unlock; 242 goto unlock;
236 243
237 if (writeaccess) 244 if (writeaccess)
@@ -243,13 +250,7 @@ asmlinkage int __do_page_fault(struct pt_regs *regs, unsigned long writeaccess,
243 * ITLB is not affected by "ldtlb" instruction. 250 * ITLB is not affected by "ldtlb" instruction.
244 * So, we need to flush the entry by ourselves. 251 * So, we need to flush the entry by ourselves.
245 */ 252 */
246 253 __flush_tlb_page(get_asid(), address & PAGE_MASK);
247 {
248 unsigned long flags;
249 local_irq_save(flags);
250 __flush_tlb_page(get_asid(), address&PAGE_MASK);
251 local_irq_restore(flags);
252 }
253#endif 254#endif
254 255
255 set_pte(pte, entry); 256 set_pte(pte, entry);
@@ -260,121 +261,3 @@ unlock:
260 pte_unmap_unlock(pte, ptl); 261 pte_unmap_unlock(pte, ptl);
261 return ret; 262 return ret;
262} 263}
263
264void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
265{
266 if (vma->vm_mm && vma->vm_mm->context != NO_CONTEXT) {
267 unsigned long flags;
268 unsigned long asid;
269 unsigned long saved_asid = MMU_NO_ASID;
270
271 asid = vma->vm_mm->context & MMU_CONTEXT_ASID_MASK;
272 page &= PAGE_MASK;
273
274 local_irq_save(flags);
275 if (vma->vm_mm != current->mm) {
276 saved_asid = get_asid();
277 set_asid(asid);
278 }
279 __flush_tlb_page(asid, page);
280 if (saved_asid != MMU_NO_ASID)
281 set_asid(saved_asid);
282 local_irq_restore(flags);
283 }
284}
285
286void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
287 unsigned long end)
288{
289 struct mm_struct *mm = vma->vm_mm;
290
291 if (mm->context != NO_CONTEXT) {
292 unsigned long flags;
293 int size;
294
295 local_irq_save(flags);
296 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
297 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
298 mm->context = NO_CONTEXT;
299 if (mm == current->mm)
300 activate_context(mm);
301 } else {
302 unsigned long asid = mm->context&MMU_CONTEXT_ASID_MASK;
303 unsigned long saved_asid = MMU_NO_ASID;
304
305 start &= PAGE_MASK;
306 end += (PAGE_SIZE - 1);
307 end &= PAGE_MASK;
308 if (mm != current->mm) {
309 saved_asid = get_asid();
310 set_asid(asid);
311 }
312 while (start < end) {
313 __flush_tlb_page(asid, start);
314 start += PAGE_SIZE;
315 }
316 if (saved_asid != MMU_NO_ASID)
317 set_asid(saved_asid);
318 }
319 local_irq_restore(flags);
320 }
321}
322
323void flush_tlb_kernel_range(unsigned long start, unsigned long end)
324{
325 unsigned long flags;
326 int size;
327
328 local_irq_save(flags);
329 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
330 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
331 flush_tlb_all();
332 } else {
333 unsigned long asid = init_mm.context&MMU_CONTEXT_ASID_MASK;
334 unsigned long saved_asid = get_asid();
335
336 start &= PAGE_MASK;
337 end += (PAGE_SIZE - 1);
338 end &= PAGE_MASK;
339 set_asid(asid);
340 while (start < end) {
341 __flush_tlb_page(asid, start);
342 start += PAGE_SIZE;
343 }
344 set_asid(saved_asid);
345 }
346 local_irq_restore(flags);
347}
348
349void flush_tlb_mm(struct mm_struct *mm)
350{
351 /* Invalidate all TLB of this process. */
352 /* Instead of invalidating each TLB, we get new MMU context. */
353 if (mm->context != NO_CONTEXT) {
354 unsigned long flags;
355
356 local_irq_save(flags);
357 mm->context = NO_CONTEXT;
358 if (mm == current->mm)
359 activate_context(mm);
360 local_irq_restore(flags);
361 }
362}
363
364void flush_tlb_all(void)
365{
366 unsigned long flags, status;
367
368 /*
369 * Flush all the TLB.
370 *
371 * Write to the MMU control register's bit:
372 * TF-bit for SH-3, TI-bit for SH-4.
373 * It's same position, bit #2.
374 */
375 local_irq_save(flags);
376 status = ctrl_inl(MMUCR);
377 status |= 0x04;
378 ctrl_outl(status, MMUCR);
379 local_irq_restore(flags);
380}
diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c
index 2a85bc15a412..329059d6b54a 100644
--- a/arch/sh/mm/hugetlbpage.c
+++ b/arch/sh/mm/hugetlbpage.c
@@ -26,61 +26,41 @@
26pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr) 26pte_t *huge_pte_alloc(struct mm_struct *mm, unsigned long addr)
27{ 27{
28 pgd_t *pgd; 28 pgd_t *pgd;
29 pud_t *pud;
29 pmd_t *pmd; 30 pmd_t *pmd;
30 pte_t *pte = NULL; 31 pte_t *pte = NULL;
31 32
32 pgd = pgd_offset(mm, addr); 33 pgd = pgd_offset(mm, addr);
33 if (pgd) { 34 if (pgd) {
34 pmd = pmd_alloc(mm, pgd, addr); 35 pud = pud_alloc(mm, pgd, addr);
35 if (pmd) 36 if (pud) {
36 pte = pte_alloc_map(mm, pmd, addr); 37 pmd = pmd_alloc(mm, pud, addr);
38 if (pmd)
39 pte = pte_alloc_map(mm, pmd, addr);
40 }
37 } 41 }
42
38 return pte; 43 return pte;
39} 44}
40 45
41pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr) 46pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr)
42{ 47{
43 pgd_t *pgd; 48 pgd_t *pgd;
49 pud_t *pud;
44 pmd_t *pmd; 50 pmd_t *pmd;
45 pte_t *pte = NULL; 51 pte_t *pte = NULL;
46 52
47 pgd = pgd_offset(mm, addr); 53 pgd = pgd_offset(mm, addr);
48 if (pgd) { 54 if (pgd) {
49 pmd = pmd_offset(pgd, addr); 55 pud = pud_offset(pgd, addr);
50 if (pmd) 56 if (pud) {
51 pte = pte_offset_map(pmd, addr); 57 pmd = pmd_offset(pud, addr);
52 } 58 if (pmd)
53 return pte; 59 pte = pte_offset_map(pmd, addr);
54} 60 }
55
56void set_huge_pte_at(struct mm_struct *mm, unsigned long addr,
57 pte_t *ptep, pte_t entry)
58{
59 int i;
60
61 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) {
62 set_pte_at(mm, addr, ptep, entry);
63 ptep++;
64 addr += PAGE_SIZE;
65 pte_val(entry) += PAGE_SIZE;
66 } 61 }
67}
68
69pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr,
70 pte_t *ptep)
71{
72 pte_t entry;
73 int i;
74
75 entry = *ptep;
76 62
77 for (i = 0; i < (1 << HUGETLB_PAGE_ORDER); i++) { 63 return pte;
78 pte_clear(mm, addr, ptep);
79 addr += PAGE_SIZE;
80 ptep++;
81 }
82
83 return entry;
84} 64}
85 65
86struct page *follow_huge_addr(struct mm_struct *mm, 66struct page *follow_huge_addr(struct mm_struct *mm,
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 8ea27ca4b700..7154d1ce9785 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -24,7 +24,7 @@
24#include <linux/highmem.h> 24#include <linux/highmem.h>
25#include <linux/bootmem.h> 25#include <linux/bootmem.h>
26#include <linux/pagemap.h> 26#include <linux/pagemap.h>
27 27#include <linux/proc_fs.h>
28#include <asm/processor.h> 28#include <asm/processor.h>
29#include <asm/system.h> 29#include <asm/system.h>
30#include <asm/uaccess.h> 30#include <asm/uaccess.h>
@@ -80,6 +80,7 @@ void show_mem(void)
80static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) 80static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
81{ 81{
82 pgd_t *pgd; 82 pgd_t *pgd;
83 pud_t *pud;
83 pmd_t *pmd; 84 pmd_t *pmd;
84 pte_t *pte; 85 pte_t *pte;
85 86
@@ -89,7 +90,17 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot)
89 return; 90 return;
90 } 91 }
91 92
92 pmd = pmd_offset(pgd, addr); 93 pud = pud_offset(pgd, addr);
94 if (pud_none(*pud)) {
95 pmd = (pmd_t *)get_zeroed_page(GFP_ATOMIC);
96 set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE | _PAGE_USER));
97 if (pmd != pmd_offset(pud, 0)) {
98 pud_ERROR(*pud);
99 return;
100 }
101 }
102
103 pmd = pmd_offset(pud, addr);
93 if (pmd_none(*pmd)) { 104 if (pmd_none(*pmd)) {
94 pte = (pte_t *)get_zeroed_page(GFP_ATOMIC); 105 pte = (pte_t *)get_zeroed_page(GFP_ATOMIC);
95 set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER)); 106 set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE | _PAGE_USER));
@@ -212,6 +223,8 @@ void __init paging_init(void)
212 free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0); 223 free_area_init_node(0, NODE_DATA(0), zones_size, __MEMORY_START >> PAGE_SHIFT, 0);
213} 224}
214 225
226static struct kcore_list kcore_mem, kcore_vmalloc;
227
215void __init mem_init(void) 228void __init mem_init(void)
216{ 229{
217 extern unsigned long empty_zero_page[1024]; 230 extern unsigned long empty_zero_page[1024];
@@ -237,8 +250,13 @@ void __init mem_init(void)
237 * Setup wrappers for copy/clear_page(), these will get overridden 250 * Setup wrappers for copy/clear_page(), these will get overridden
238 * later in the boot process if a better method is available. 251 * later in the boot process if a better method is available.
239 */ 252 */
253#ifdef CONFIG_MMU
240 copy_page = copy_page_slow; 254 copy_page = copy_page_slow;
241 clear_page = clear_page_slow; 255 clear_page = clear_page_slow;
256#else
257 copy_page = copy_page_nommu;
258 clear_page = clear_page_nommu;
259#endif
242 260
243 /* this will put all low memory onto the freelists */ 261 /* this will put all low memory onto the freelists */
244 totalram_pages += free_all_bootmem_node(NODE_DATA(0)); 262 totalram_pages += free_all_bootmem_node(NODE_DATA(0));
@@ -254,7 +272,12 @@ void __init mem_init(void)
254 datasize = (unsigned long) &_edata - (unsigned long) &_etext; 272 datasize = (unsigned long) &_edata - (unsigned long) &_etext;
255 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; 273 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
256 274
257 printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init)\n", 275 kclist_add(&kcore_mem, __va(0), max_low_pfn << PAGE_SHIFT);
276 kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
277 VMALLOC_END - VMALLOC_START);
278
279 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
280 "%dk reserved, %dk data, %dk init)\n",
258 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), 281 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
259 max_mapnr << (PAGE_SHIFT-10), 282 max_mapnr << (PAGE_SHIFT-10),
260 codesize >> 10, 283 codesize >> 10,
@@ -263,6 +286,9 @@ void __init mem_init(void)
263 initsize >> 10); 286 initsize >> 10);
264 287
265 p3_cache_init(); 288 p3_cache_init();
289
290 /* Initialize the vDSO */
291 vsyscall_init();
266} 292}
267 293
268void free_initmem(void) 294void free_initmem(void)
diff --git a/arch/sh/mm/ioremap.c b/arch/sh/mm/ioremap.c
index 96fa4a999e2a..a9fe80cfc233 100644
--- a/arch/sh/mm/ioremap.c
+++ b/arch/sh/mm/ioremap.c
@@ -15,6 +15,7 @@
15#include <linux/vmalloc.h> 15#include <linux/vmalloc.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/mm.h> 17#include <linux/mm.h>
18#include <linux/pci.h>
18#include <asm/io.h> 19#include <asm/io.h>
19#include <asm/page.h> 20#include <asm/page.h>
20#include <asm/pgalloc.h> 21#include <asm/pgalloc.h>
@@ -135,6 +136,20 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
135 return (void __iomem *)phys_to_virt(phys_addr); 136 return (void __iomem *)phys_to_virt(phys_addr);
136 137
137 /* 138 /*
139 * If we're on an SH7751 or SH7780 PCI controller, PCI memory is
140 * mapped at the end of the address space (typically 0xfd000000)
141 * in a non-translatable area, so mapping through page tables for
142 * this area is not only pointless, but also fundamentally
143 * broken. Just return the physical address instead.
144 *
145 * For boards that map a small PCI memory aperture somewhere in
146 * P1/P2 space, ioremap() will already do the right thing,
147 * and we'll never get this far.
148 */
149 if (is_pci_memaddr(phys_addr) && is_pci_memaddr(last_addr))
150 return (void __iomem *)phys_addr;
151
152 /*
138 * Don't allow anybody to remap normal RAM that we're using.. 153 * Don't allow anybody to remap normal RAM that we're using..
139 */ 154 */
140 if (phys_addr < virt_to_phys(high_memory)) 155 if (phys_addr < virt_to_phys(high_memory))
@@ -192,7 +207,7 @@ void __iounmap(void __iomem *addr)
192 unsigned long vaddr = (unsigned long __force)addr; 207 unsigned long vaddr = (unsigned long __force)addr;
193 struct vm_struct *p; 208 struct vm_struct *p;
194 209
195 if (PXSEG(vaddr) < P3SEG) 210 if (PXSEG(vaddr) < P3SEG || is_pci_memaddr(vaddr))
196 return; 211 return;
197 212
198#ifdef CONFIG_32BIT 213#ifdef CONFIG_32BIT
diff --git a/arch/sh/mm/pg-nommu.c b/arch/sh/mm/pg-nommu.c
index 8f9165a4e333..d15221beaa16 100644
--- a/arch/sh/mm/pg-nommu.c
+++ b/arch/sh/mm/pg-nommu.c
@@ -14,23 +14,24 @@
14#include <linux/string.h> 14#include <linux/string.h>
15#include <asm/page.h> 15#include <asm/page.h>
16 16
17static void copy_page_nommu(void *to, void *from) 17void copy_page_nommu(void *to, void *from)
18{ 18{
19 memcpy(to, from, PAGE_SIZE); 19 memcpy(to, from, PAGE_SIZE);
20} 20}
21 21
22static void clear_page_nommu(void *to) 22void clear_page_nommu(void *to)
23{ 23{
24 memset(to, 0, PAGE_SIZE); 24 memset(to, 0, PAGE_SIZE);
25} 25}
26 26
27static int __init pg_nommu_init(void) 27__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n)
28{ 28{
29 copy_page = copy_page_nommu; 29 memcpy(to, from, n);
30 clear_page = clear_page_nommu;
31
32 return 0; 30 return 0;
33} 31}
34 32
35subsys_initcall(pg_nommu_init); 33__kernel_size_t __clear_user(void *to, __kernel_size_t n)
36 34{
35 memset(to, 0, n);
36 return 0;
37}
diff --git a/arch/sh/mm/pg-sh4.c b/arch/sh/mm/pg-sh4.c
index c776b60fc250..07371ed7a313 100644
--- a/arch/sh/mm/pg-sh4.c
+++ b/arch/sh/mm/pg-sh4.c
@@ -2,7 +2,7 @@
2 * arch/sh/mm/pg-sh4.c 2 * arch/sh/mm/pg-sh4.c
3 * 3 *
4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka 4 * Copyright (C) 1999, 2000, 2002 Niibe Yutaka
5 * Copyright (C) 2002 Paul Mundt 5 * Copyright (C) 2002 - 2005 Paul Mundt
6 * 6 *
7 * Released under the terms of the GNU GPL v2.0. 7 * Released under the terms of the GNU GPL v2.0.
8 */ 8 */
@@ -23,6 +23,8 @@
23 23
24extern struct semaphore p3map_sem[]; 24extern struct semaphore p3map_sem[];
25 25
26#define CACHE_ALIAS (cpu_data->dcache.alias_mask)
27
26/* 28/*
27 * clear_user_page 29 * clear_user_page
28 * @to: P1 address 30 * @to: P1 address
@@ -35,14 +37,15 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
35 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 37 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
36 clear_page(to); 38 clear_page(to);
37 else { 39 else {
38 pgprot_t pgprot = __pgprot(_PAGE_PRESENT | 40 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
39 _PAGE_RW | _PAGE_CACHABLE | 41 _PAGE_RW | _PAGE_CACHABLE |
40 _PAGE_DIRTY | _PAGE_ACCESSED | 42 _PAGE_DIRTY | _PAGE_ACCESSED |
41 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); 43 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
42 unsigned long phys_addr = PHYSADDR(to); 44 unsigned long phys_addr = PHYSADDR(to);
43 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 45 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
44 pgd_t *dir = pgd_offset_k(p3_addr); 46 pgd_t *pgd = pgd_offset_k(p3_addr);
45 pmd_t *pmd = pmd_offset(dir, p3_addr); 47 pud_t *pud = pud_offset(pgd, p3_addr);
48 pmd_t *pmd = pmd_offset(pud, p3_addr);
46 pte_t *pte = pte_offset_kernel(pmd, p3_addr); 49 pte_t *pte = pte_offset_kernel(pmd, p3_addr);
47 pte_t entry; 50 pte_t entry;
48 unsigned long flags; 51 unsigned long flags;
@@ -67,21 +70,22 @@ void clear_user_page(void *to, unsigned long address, struct page *page)
67 * @address: U0 address to be mapped 70 * @address: U0 address to be mapped
68 * @page: page (virt_to_page(to)) 71 * @page: page (virt_to_page(to))
69 */ 72 */
70void copy_user_page(void *to, void *from, unsigned long address, 73void copy_user_page(void *to, void *from, unsigned long address,
71 struct page *page) 74 struct page *page)
72{ 75{
73 __set_bit(PG_mapped, &page->flags); 76 __set_bit(PG_mapped, &page->flags);
74 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0) 77 if (((address ^ (unsigned long)to) & CACHE_ALIAS) == 0)
75 copy_page(to, from); 78 copy_page(to, from);
76 else { 79 else {
77 pgprot_t pgprot = __pgprot(_PAGE_PRESENT | 80 pgprot_t pgprot = __pgprot(_PAGE_PRESENT |
78 _PAGE_RW | _PAGE_CACHABLE | 81 _PAGE_RW | _PAGE_CACHABLE |
79 _PAGE_DIRTY | _PAGE_ACCESSED | 82 _PAGE_DIRTY | _PAGE_ACCESSED |
80 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD); 83 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD);
81 unsigned long phys_addr = PHYSADDR(to); 84 unsigned long phys_addr = PHYSADDR(to);
82 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS); 85 unsigned long p3_addr = P3SEG + (address & CACHE_ALIAS);
83 pgd_t *dir = pgd_offset_k(p3_addr); 86 pgd_t *pgd = pgd_offset_k(p3_addr);
84 pmd_t *pmd = pmd_offset(dir, p3_addr); 87 pud_t *pud = pud_offset(pgd, p3_addr);
88 pmd_t *pmd = pmd_offset(pud, p3_addr);
85 pte_t *pte = pte_offset_kernel(pmd, p3_addr); 89 pte_t *pte = pte_offset_kernel(pmd, p3_addr);
86 pte_t entry; 90 pte_t entry;
87 unsigned long flags; 91 unsigned long flags;
diff --git a/arch/sh/mm/pmb.c b/arch/sh/mm/pmb.c
new file mode 100644
index 000000000000..92e745341e4d
--- /dev/null
+++ b/arch/sh/mm/pmb.c
@@ -0,0 +1,400 @@
1/*
2 * arch/sh/mm/pmb.c
3 *
4 * Privileged Space Mapping Buffer (PMB) Support.
5 *
6 * Copyright (C) 2005, 2006 Paul Mundt
7 *
8 * P1/P2 Section mapping definitions from map32.h, which was:
9 *
10 * Copyright 2003 (c) Lineo Solutions,Inc.
11 *
12 * This file is subject to the terms and conditions of the GNU General Public
13 * License. See the file "COPYING" in the main directory of this archive
14 * for more details.
15 */
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/slab.h>
20#include <linux/bitops.h>
21#include <linux/debugfs.h>
22#include <linux/fs.h>
23#include <linux/seq_file.h>
24#include <linux/err.h>
25#include <asm/system.h>
26#include <asm/uaccess.h>
27#include <asm/pgtable.h>
28#include <asm/mmu.h>
29#include <asm/io.h>
30
31#define NR_PMB_ENTRIES 16
32
33static kmem_cache_t *pmb_cache;
34static unsigned long pmb_map;
35
36static struct pmb_entry pmb_init_map[] = {
37 /* vpn ppn flags (ub/sz/c/wt) */
38
39 /* P1 Section Mappings */
40 { 0x80000000, 0x00000000, PMB_SZ_64M | PMB_C, },
41 { 0x84000000, 0x04000000, PMB_SZ_64M | PMB_C, },
42 { 0x88000000, 0x08000000, PMB_SZ_128M | PMB_C, },
43 { 0x90000000, 0x10000000, PMB_SZ_64M | PMB_C, },
44 { 0x94000000, 0x14000000, PMB_SZ_64M | PMB_C, },
45 { 0x98000000, 0x18000000, PMB_SZ_64M | PMB_C, },
46
47 /* P2 Section Mappings */
48 { 0xa0000000, 0x00000000, PMB_UB | PMB_SZ_64M | PMB_WT, },
49 { 0xa4000000, 0x04000000, PMB_UB | PMB_SZ_64M | PMB_WT, },
50 { 0xa8000000, 0x08000000, PMB_UB | PMB_SZ_128M | PMB_WT, },
51 { 0xb0000000, 0x10000000, PMB_UB | PMB_SZ_64M | PMB_WT, },
52 { 0xb4000000, 0x14000000, PMB_UB | PMB_SZ_64M | PMB_WT, },
53 { 0xb8000000, 0x18000000, PMB_UB | PMB_SZ_64M | PMB_WT, },
54};
55
56static inline unsigned long mk_pmb_entry(unsigned int entry)
57{
58 return (entry & PMB_E_MASK) << PMB_E_SHIFT;
59}
60
61static inline unsigned long mk_pmb_addr(unsigned int entry)
62{
63 return mk_pmb_entry(entry) | PMB_ADDR;
64}
65
66static inline unsigned long mk_pmb_data(unsigned int entry)
67{
68 return mk_pmb_entry(entry) | PMB_DATA;
69}
70
71struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn,
72 unsigned long flags)
73{
74 struct pmb_entry *pmbe;
75
76 pmbe = kmem_cache_alloc(pmb_cache, GFP_KERNEL);
77 if (!pmbe)
78 return ERR_PTR(-ENOMEM);
79
80 pmbe->vpn = vpn;
81 pmbe->ppn = ppn;
82 pmbe->flags = flags;
83
84 return pmbe;
85}
86
87void pmb_free(struct pmb_entry *pmbe)
88{
89 kmem_cache_free(pmb_cache, pmbe);
90}
91
92/*
93 * Must be in P2 for __set_pmb_entry()
94 */
95int __set_pmb_entry(unsigned long vpn, unsigned long ppn,
96 unsigned long flags, int *entry)
97{
98 unsigned int pos = *entry;
99
100 if (unlikely(pos == PMB_NO_ENTRY))
101 pos = find_first_zero_bit(&pmb_map, NR_PMB_ENTRIES);
102
103repeat:
104 if (unlikely(pos > NR_PMB_ENTRIES))
105 return -ENOSPC;
106
107 if (test_and_set_bit(pos, &pmb_map)) {
108 pos = find_first_zero_bit(&pmb_map, NR_PMB_ENTRIES);
109 goto repeat;
110 }
111
112 ctrl_outl(vpn | PMB_V, mk_pmb_addr(pos));
113
114#ifdef CONFIG_SH_WRITETHROUGH
115 /*
116 * When we are in 32-bit address extended mode, CCR.CB becomes
117 * invalid, so care must be taken to manually adjust cacheable
118 * translations.
119 */
120 if (likely(flags & PMB_C))
121 flags |= PMB_WT;
122#endif
123
124 ctrl_outl(ppn | flags | PMB_V, mk_pmb_data(pos));
125
126 *entry = pos;
127
128 return 0;
129}
130
131int set_pmb_entry(struct pmb_entry *pmbe)
132{
133 int ret;
134
135 jump_to_P2();
136 ret = __set_pmb_entry(pmbe->vpn, pmbe->ppn, pmbe->flags, &pmbe->entry);
137 back_to_P1();
138
139 return ret;
140}
141
142void clear_pmb_entry(struct pmb_entry *pmbe)
143{
144 unsigned int entry = pmbe->entry;
145 unsigned long addr;
146
147 /*
148 * Don't allow clearing of wired init entries, P1 or P2 access
149 * without a corresponding mapping in the PMB will lead to reset
150 * by the TLB.
151 */
152 if (unlikely(entry < ARRAY_SIZE(pmb_init_map) ||
153 entry >= NR_PMB_ENTRIES))
154 return;
155
156 jump_to_P2();
157
158 /* Clear V-bit */
159 addr = mk_pmb_addr(entry);
160 ctrl_outl(ctrl_inl(addr) & ~PMB_V, addr);
161
162 addr = mk_pmb_data(entry);
163 ctrl_outl(ctrl_inl(addr) & ~PMB_V, addr);
164
165 back_to_P1();
166
167 clear_bit(entry, &pmb_map);
168}
169
170static DEFINE_SPINLOCK(pmb_list_lock);
171static struct pmb_entry *pmb_list;
172
173static inline void pmb_list_add(struct pmb_entry *pmbe)
174{
175 struct pmb_entry **p, *tmp;
176
177 p = &pmb_list;
178 while ((tmp = *p) != NULL)
179 p = &tmp->next;
180
181 pmbe->next = tmp;
182 *p = pmbe;
183}
184
185static inline void pmb_list_del(struct pmb_entry *pmbe)
186{
187 struct pmb_entry **p, *tmp;
188
189 for (p = &pmb_list; (tmp = *p); p = &tmp->next)
190 if (tmp == pmbe) {
191 *p = tmp->next;
192 return;
193 }
194}
195
196static struct {
197 unsigned long size;
198 int flag;
199} pmb_sizes[] = {
200 { .size = 0x20000000, .flag = PMB_SZ_512M, },
201 { .size = 0x08000000, .flag = PMB_SZ_128M, },
202 { .size = 0x04000000, .flag = PMB_SZ_64M, },
203 { .size = 0x01000000, .flag = PMB_SZ_16M, },
204};
205
206long pmb_remap(unsigned long vaddr, unsigned long phys,
207 unsigned long size, unsigned long flags)
208{
209 struct pmb_entry *pmbp;
210 unsigned long wanted;
211 int pmb_flags, i;
212
213 /* Convert typical pgprot value to the PMB equivalent */
214 if (flags & _PAGE_CACHABLE) {
215 if (flags & _PAGE_WT)
216 pmb_flags = PMB_WT;
217 else
218 pmb_flags = PMB_C;
219 } else
220 pmb_flags = PMB_WT | PMB_UB;
221
222 pmbp = NULL;
223 wanted = size;
224
225again:
226 for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++) {
227 struct pmb_entry *pmbe;
228 int ret;
229
230 if (size < pmb_sizes[i].size)
231 continue;
232
233 pmbe = pmb_alloc(vaddr, phys, pmb_flags | pmb_sizes[i].flag);
234 if (IS_ERR(pmbe))
235 return PTR_ERR(pmbe);
236
237 ret = set_pmb_entry(pmbe);
238 if (ret != 0) {
239 pmb_free(pmbe);
240 return -EBUSY;
241 }
242
243 phys += pmb_sizes[i].size;
244 vaddr += pmb_sizes[i].size;
245 size -= pmb_sizes[i].size;
246
247 /*
248 * Link adjacent entries that span multiple PMB entries
249 * for easier tear-down.
250 */
251 if (likely(pmbp))
252 pmbp->link = pmbe;
253
254 pmbp = pmbe;
255 }
256
257 if (size >= 0x1000000)
258 goto again;
259
260 return wanted - size;
261}
262
263void pmb_unmap(unsigned long addr)
264{
265 struct pmb_entry **p, *pmbe;
266
267 for (p = &pmb_list; (pmbe = *p); p = &pmbe->next)
268 if (pmbe->vpn == addr)
269 break;
270
271 if (unlikely(!pmbe))
272 return;
273
274 WARN_ON(!test_bit(pmbe->entry, &pmb_map));
275
276 do {
277 struct pmb_entry *pmblink = pmbe;
278
279 clear_pmb_entry(pmbe);
280 pmbe = pmblink->link;
281
282 pmb_free(pmblink);
283 } while (pmbe);
284}
285
286static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
287{
288 struct pmb_entry *pmbe = pmb;
289
290 memset(pmb, 0, sizeof(struct pmb_entry));
291
292 spin_lock_irq(&pmb_list_lock);
293
294 pmbe->entry = PMB_NO_ENTRY;
295 pmb_list_add(pmbe);
296
297 spin_unlock_irq(&pmb_list_lock);
298}
299
300static void pmb_cache_dtor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
301{
302 spin_lock_irq(&pmb_list_lock);
303 pmb_list_del(pmb);
304 spin_unlock_irq(&pmb_list_lock);
305}
306
307static int __init pmb_init(void)
308{
309 unsigned int nr_entries = ARRAY_SIZE(pmb_init_map);
310 unsigned int entry;
311
312 BUG_ON(unlikely(nr_entries >= NR_PMB_ENTRIES));
313
314 pmb_cache = kmem_cache_create("pmb", sizeof(struct pmb_entry),
315 0, 0, pmb_cache_ctor, pmb_cache_dtor);
316 BUG_ON(!pmb_cache);
317
318 jump_to_P2();
319
320 /*
321 * Ordering is important, P2 must be mapped in the PMB before we
322 * can set PMB.SE, and P1 must be mapped before we jump back to
323 * P1 space.
324 */
325 for (entry = 0; entry < nr_entries; entry++) {
326 struct pmb_entry *pmbe = pmb_init_map + entry;
327
328 __set_pmb_entry(pmbe->vpn, pmbe->ppn, pmbe->flags, &entry);
329 }
330
331 ctrl_outl(0, PMB_IRMCR);
332
333 /* PMB.SE and UB[7] */
334 ctrl_outl((1 << 31) | (1 << 7), PMB_PASCR);
335
336 back_to_P1();
337
338 return 0;
339}
340arch_initcall(pmb_init);
341
342static int pmb_seq_show(struct seq_file *file, void *iter)
343{
344 int i;
345
346 seq_printf(file, "V: Valid, C: Cacheable, WT: Write-Through\n"
347 "CB: Copy-Back, B: Buffered, UB: Unbuffered\n");
348 seq_printf(file, "ety vpn ppn size flags\n");
349
350 for (i = 0; i < NR_PMB_ENTRIES; i++) {
351 unsigned long addr, data;
352 unsigned int size;
353 char *sz_str = NULL;
354
355 addr = ctrl_inl(mk_pmb_addr(i));
356 data = ctrl_inl(mk_pmb_data(i));
357
358 size = data & PMB_SZ_MASK;
359 sz_str = (size == PMB_SZ_16M) ? " 16MB":
360 (size == PMB_SZ_64M) ? " 64MB":
361 (size == PMB_SZ_128M) ? "128MB":
362 "512MB";
363
364 /* 02: V 0x88 0x08 128MB C CB B */
365 seq_printf(file, "%02d: %c 0x%02lx 0x%02lx %s %c %s %s\n",
366 i, ((addr & PMB_V) && (data & PMB_V)) ? 'V' : ' ',
367 (addr >> 24) & 0xff, (data >> 24) & 0xff,
368 sz_str, (data & PMB_C) ? 'C' : ' ',
369 (data & PMB_WT) ? "WT" : "CB",
370 (data & PMB_UB) ? "UB" : " B");
371 }
372
373 return 0;
374}
375
376static int pmb_debugfs_open(struct inode *inode, struct file *file)
377{
378 return single_open(file, pmb_seq_show, NULL);
379}
380
381static struct file_operations pmb_debugfs_fops = {
382 .owner = THIS_MODULE,
383 .open = pmb_debugfs_open,
384 .read = seq_read,
385 .llseek = seq_lseek,
386 .release = seq_release,
387};
388
389static int __init pmb_debugfs_init(void)
390{
391 struct dentry *dentry;
392
393 dentry = debugfs_create_file("pmb", S_IFREG | S_IRUGO,
394 NULL, NULL, &pmb_debugfs_fops);
395 if (IS_ERR(dentry))
396 return PTR_ERR(dentry);
397
398 return 0;
399}
400postcore_initcall(pmb_debugfs_init);
diff --git a/arch/sh/mm/tlb-flush.c b/arch/sh/mm/tlb-flush.c
new file mode 100644
index 000000000000..73ec7f6084fa
--- /dev/null
+++ b/arch/sh/mm/tlb-flush.c
@@ -0,0 +1,134 @@
1/*
2 * TLB flushing operations for SH with an MMU.
3 *
4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2003 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
11#include <linux/mm.h>
12#include <asm/mmu_context.h>
13#include <asm/tlbflush.h>
14
15void flush_tlb_page(struct vm_area_struct *vma, unsigned long page)
16{
17 if (vma->vm_mm && vma->vm_mm->context.id != NO_CONTEXT) {
18 unsigned long flags;
19 unsigned long asid;
20 unsigned long saved_asid = MMU_NO_ASID;
21
22 asid = vma->vm_mm->context.id & MMU_CONTEXT_ASID_MASK;
23 page &= PAGE_MASK;
24
25 local_irq_save(flags);
26 if (vma->vm_mm != current->mm) {
27 saved_asid = get_asid();
28 set_asid(asid);
29 }
30 __flush_tlb_page(asid, page);
31 if (saved_asid != MMU_NO_ASID)
32 set_asid(saved_asid);
33 local_irq_restore(flags);
34 }
35}
36
37void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
38 unsigned long end)
39{
40 struct mm_struct *mm = vma->vm_mm;
41
42 if (mm->context.id != NO_CONTEXT) {
43 unsigned long flags;
44 int size;
45
46 local_irq_save(flags);
47 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
48 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
49 mm->context.id = NO_CONTEXT;
50 if (mm == current->mm)
51 activate_context(mm);
52 } else {
53 unsigned long asid;
54 unsigned long saved_asid = MMU_NO_ASID;
55
56 asid = mm->context.id & MMU_CONTEXT_ASID_MASK;
57 start &= PAGE_MASK;
58 end += (PAGE_SIZE - 1);
59 end &= PAGE_MASK;
60 if (mm != current->mm) {
61 saved_asid = get_asid();
62 set_asid(asid);
63 }
64 while (start < end) {
65 __flush_tlb_page(asid, start);
66 start += PAGE_SIZE;
67 }
68 if (saved_asid != MMU_NO_ASID)
69 set_asid(saved_asid);
70 }
71 local_irq_restore(flags);
72 }
73}
74
75void flush_tlb_kernel_range(unsigned long start, unsigned long end)
76{
77 unsigned long flags;
78 int size;
79
80 local_irq_save(flags);
81 size = (end - start + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
82 if (size > (MMU_NTLB_ENTRIES/4)) { /* Too many TLB to flush */
83 flush_tlb_all();
84 } else {
85 unsigned long asid;
86 unsigned long saved_asid = get_asid();
87
88 asid = init_mm.context.id & MMU_CONTEXT_ASID_MASK;
89 start &= PAGE_MASK;
90 end += (PAGE_SIZE - 1);
91 end &= PAGE_MASK;
92 set_asid(asid);
93 while (start < end) {
94 __flush_tlb_page(asid, start);
95 start += PAGE_SIZE;
96 }
97 set_asid(saved_asid);
98 }
99 local_irq_restore(flags);
100}
101
102void flush_tlb_mm(struct mm_struct *mm)
103{
104 /* Invalidate all TLB of this process. */
105 /* Instead of invalidating each TLB, we get new MMU context. */
106 if (mm->context.id != NO_CONTEXT) {
107 unsigned long flags;
108
109 local_irq_save(flags);
110 mm->context.id = NO_CONTEXT;
111 if (mm == current->mm)
112 activate_context(mm);
113 local_irq_restore(flags);
114 }
115}
116
117void flush_tlb_all(void)
118{
119 unsigned long flags, status;
120
121 /*
122 * Flush all the TLB.
123 *
124 * Write to the MMU control register's bit:
125 * TF-bit for SH-3, TI-bit for SH-4.
126 * It's same position, bit #2.
127 */
128 local_irq_save(flags);
129 status = ctrl_inl(MMUCR);
130 status |= 0x04;
131 ctrl_outl(status, MMUCR);
132 ctrl_barrier();
133 local_irq_restore(flags);
134}
diff --git a/arch/sh/mm/tlb-sh4.c b/arch/sh/mm/tlb-sh4.c
index 115b1b6be40b..812b2d567de2 100644
--- a/arch/sh/mm/tlb-sh4.c
+++ b/arch/sh/mm/tlb-sh4.c
@@ -36,7 +36,6 @@ void update_mmu_cache(struct vm_area_struct * vma,
36 unsigned long vpn; 36 unsigned long vpn;
37 struct page *page; 37 struct page *page;
38 unsigned long pfn; 38 unsigned long pfn;
39 unsigned long ptea;
40 39
41 /* Ptrace may call this routine. */ 40 /* Ptrace may call this routine. */
42 if (vma && current->active_mm != vma->vm_mm) 41 if (vma && current->active_mm != vma->vm_mm)
@@ -59,10 +58,11 @@ void update_mmu_cache(struct vm_area_struct * vma,
59 ctrl_outl(vpn, MMU_PTEH); 58 ctrl_outl(vpn, MMU_PTEH);
60 59
61 pteval = pte_val(pte); 60 pteval = pte_val(pte);
61
62 /* Set PTEA register */ 62 /* Set PTEA register */
63 /* TODO: make this look less hacky */ 63 if (cpu_data->flags & CPU_HAS_PTEA)
64 ptea = ((pteval >> 28) & 0xe) | (pteval & 0x1); 64 /* TODO: make this look less hacky */
65 ctrl_outl(ptea, MMU_PTEA); 65 ctrl_outl(((pteval >> 28) & 0xe) | (pteval & 0x1), MMU_PTEA);
66 66
67 /* Set PTEL register */ 67 /* Set PTEL register */
68 pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */ 68 pteval &= _PAGE_FLAGS_HARDWARE_MASK; /* drop software flags */
diff --git a/arch/sh/oprofile/Makefile b/arch/sh/oprofile/Makefile
index 686738d4aa3c..1f25d9bb7538 100644
--- a/arch/sh/oprofile/Makefile
+++ b/arch/sh/oprofile/Makefile
@@ -7,7 +7,11 @@ DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \
7 timer_int.o ) 7 timer_int.o )
8 8
9profdrvr-y := op_model_null.o 9profdrvr-y := op_model_null.o
10
11# SH7750-style performance counters exist across 7750/7750S and 7091.
12profdrvr-$(CONFIG_CPU_SUBTYPE_SH7750S) := op_model_sh7750.o
10profdrvr-$(CONFIG_CPU_SUBTYPE_SH7750) := op_model_sh7750.o 13profdrvr-$(CONFIG_CPU_SUBTYPE_SH7750) := op_model_sh7750.o
14profdrvr-$(CONFIG_CPU_SUBTYPE_SH7091) := op_model_sh7750.o
11 15
12oprofile-y := $(DRIVER_OBJS) $(profdrvr-y) 16oprofile-y := $(DRIVER_OBJS) $(profdrvr-y)
13 17
diff --git a/arch/sh/tools/mach-types b/arch/sh/tools/mach-types
index 182fe9092577..ac57638977ee 100644
--- a/arch/sh/tools/mach-types
+++ b/arch/sh/tools/mach-types
@@ -8,16 +8,15 @@
8SE SH_SOLUTION_ENGINE 8SE SH_SOLUTION_ENGINE
97751SE SH_7751_SOLUTION_ENGINE 97751SE SH_7751_SOLUTION_ENGINE
107300SE SH_7300_SOLUTION_ENGINE 107300SE SH_7300_SOLUTION_ENGINE
117343SE SH_7343_SOLUTION_ENGINE
1173180SE SH_73180_SOLUTION_ENGINE 1273180SE SH_73180_SOLUTION_ENGINE
127751SYSTEMH SH_7751_SYSTEMH 137751SYSTEMH SH_7751_SYSTEMH
13HP6XX SH_HP6XX 14HP6XX SH_HP6XX
14HD64461 HD64461 15HD64461 HD64461
15HD64465 HD64465 16HD64465 HD64465
16SH2000 SH_SH2000
17SATURN SH_SATURN 17SATURN SH_SATURN
18DREAMCAST SH_DREAMCAST 18DREAMCAST SH_DREAMCAST
19BIGSUR SH_BIGSUR 19BIGSUR SH_BIGSUR
20ADX SH_ADX
21MPC1211 SH_MPC1211 20MPC1211 SH_MPC1211
22SNAPGEAR SH_SECUREEDGE5410 21SNAPGEAR SH_SECUREEDGE5410
23HS7751RVOIP SH_HS7751RVOIP 22HS7751RVOIP SH_HS7751RVOIP
@@ -25,4 +24,9 @@ RTS7751R2D SH_RTS7751R2D
25EDOSK7705 SH_EDOSK7705 24EDOSK7705 SH_EDOSK7705
26SH4202_MICRODEV SH_SH4202_MICRODEV 25SH4202_MICRODEV SH_SH4202_MICRODEV
27SH03 SH_SH03 26SH03 SH_SH03
28 27LANDISK SH_LANDISK
28R7780RP SH_R7780RP
29R7780MP SH_R7780MP
30TITAN SH_TITAN
31SHMIN SH_SHMIN
327710VOIPGW SH_7710VOIPGW
diff --git a/arch/sparc64/defconfig b/arch/sparc64/defconfig
index 51cf6027b701..0fbdaa5daa8c 100644
--- a/arch/sparc64/defconfig
+++ b/arch/sparc64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18 3# Linux kernel version: 2.6.18
4# Sat Sep 23 18:32:19 2006 4# Tue Sep 26 23:09:35 2006
5# 5#
6CONFIG_SPARC=y 6CONFIG_SPARC=y
7CONFIG_SPARC64=y 7CONFIG_SPARC64=y
@@ -141,6 +141,7 @@ CONFIG_SUN_AUXIO=y
141CONFIG_SUN_IO=y 141CONFIG_SUN_IO=y
142CONFIG_PCI=y 142CONFIG_PCI=y
143CONFIG_PCI_DOMAINS=y 143CONFIG_PCI_DOMAINS=y
144# CONFIG_PCI_MULTITHREAD_PROBE is not set
144# CONFIG_PCI_DEBUG is not set 145# CONFIG_PCI_DEBUG is not set
145CONFIG_SUN_OPENPROMFS=m 146CONFIG_SUN_OPENPROMFS=m
146CONFIG_SPARC32_COMPAT=y 147CONFIG_SPARC32_COMPAT=y
@@ -194,21 +195,9 @@ CONFIG_INET_XFRM_MODE_TRANSPORT=y
194CONFIG_INET_XFRM_MODE_TUNNEL=y 195CONFIG_INET_XFRM_MODE_TUNNEL=y
195CONFIG_INET_DIAG=y 196CONFIG_INET_DIAG=y
196CONFIG_INET_TCP_DIAG=y 197CONFIG_INET_TCP_DIAG=y
197CONFIG_TCP_CONG_ADVANCED=y 198# CONFIG_TCP_CONG_ADVANCED is not set
198 199CONFIG_TCP_CONG_CUBIC=y
199# 200CONFIG_DEFAULT_TCP_CONG="cubic"
200# TCP congestion control
201#
202CONFIG_TCP_CONG_BIC=y
203CONFIG_TCP_CONG_CUBIC=m
204CONFIG_TCP_CONG_WESTWOOD=m
205CONFIG_TCP_CONG_HTCP=m
206CONFIG_TCP_CONG_HSTCP=m
207CONFIG_TCP_CONG_HYBLA=m
208CONFIG_TCP_CONG_VEGAS=m
209CONFIG_TCP_CONG_SCALABLE=m
210CONFIG_TCP_CONG_LP=m
211CONFIG_TCP_CONG_VENO=m
212CONFIG_IPV6=m 201CONFIG_IPV6=m
213CONFIG_IPV6_PRIVACY=y 202CONFIG_IPV6_PRIVACY=y
214CONFIG_IPV6_ROUTER_PREF=y 203CONFIG_IPV6_ROUTER_PREF=y
@@ -247,6 +236,7 @@ CONFIG_IP_DCCP_TFRC_LIB=m
247# DCCP Kernel Hacking 236# DCCP Kernel Hacking
248# 237#
249# CONFIG_IP_DCCP_DEBUG is not set 238# CONFIG_IP_DCCP_DEBUG is not set
239# CONFIG_NET_DCCPPROBE is not set
250 240
251# 241#
252# SCTP Configuration (EXPERIMENTAL) 242# SCTP Configuration (EXPERIMENTAL)
@@ -401,6 +391,7 @@ CONFIG_IDEDMA_AUTO=y
401# 391#
402CONFIG_RAID_ATTRS=m 392CONFIG_RAID_ATTRS=m
403CONFIG_SCSI=y 393CONFIG_SCSI=y
394CONFIG_SCSI_NETLINK=y
404CONFIG_SCSI_PROC_FS=y 395CONFIG_SCSI_PROC_FS=y
405 396
406# 397#
@@ -422,12 +413,13 @@ CONFIG_SCSI_CONSTANTS=y
422# CONFIG_SCSI_LOGGING is not set 413# CONFIG_SCSI_LOGGING is not set
423 414
424# 415#
425# SCSI Transport Attributes 416# SCSI Transports
426# 417#
427CONFIG_SCSI_SPI_ATTRS=y 418CONFIG_SCSI_SPI_ATTRS=y
428CONFIG_SCSI_FC_ATTRS=y 419CONFIG_SCSI_FC_ATTRS=y
429CONFIG_SCSI_ISCSI_ATTRS=m 420CONFIG_SCSI_ISCSI_ATTRS=m
430# CONFIG_SCSI_SAS_ATTRS is not set 421# CONFIG_SCSI_SAS_ATTRS is not set
422# CONFIG_SCSI_SAS_LIBSAS is not set
431 423
432# 424#
433# SCSI low-level drivers 425# SCSI low-level drivers
@@ -440,16 +432,18 @@ CONFIG_ISCSI_TCP=m
440# CONFIG_SCSI_AIC7XXX is not set 432# CONFIG_SCSI_AIC7XXX is not set
441# CONFIG_SCSI_AIC7XXX_OLD is not set 433# CONFIG_SCSI_AIC7XXX_OLD is not set
442# CONFIG_SCSI_AIC79XX is not set 434# CONFIG_SCSI_AIC79XX is not set
435# CONFIG_SCSI_AIC94XX is not set
436# CONFIG_SCSI_ARCMSR is not set
443# CONFIG_MEGARAID_NEWGEN is not set 437# CONFIG_MEGARAID_NEWGEN is not set
444# CONFIG_MEGARAID_LEGACY is not set 438# CONFIG_MEGARAID_LEGACY is not set
445# CONFIG_MEGARAID_SAS is not set 439# CONFIG_MEGARAID_SAS is not set
446# CONFIG_SCSI_SATA is not set
447# CONFIG_SCSI_HPTIOP is not set 440# CONFIG_SCSI_HPTIOP is not set
448# CONFIG_SCSI_DMX3191D is not set 441# CONFIG_SCSI_DMX3191D is not set
449# CONFIG_SCSI_FUTURE_DOMAIN is not set 442# CONFIG_SCSI_FUTURE_DOMAIN is not set
450# CONFIG_SCSI_IPS is not set 443# CONFIG_SCSI_IPS is not set
451# CONFIG_SCSI_INITIO is not set 444# CONFIG_SCSI_INITIO is not set
452# CONFIG_SCSI_INIA100 is not set 445# CONFIG_SCSI_INIA100 is not set
446# CONFIG_SCSI_STEX is not set
453# CONFIG_SCSI_SYM53C8XX_2 is not set 447# CONFIG_SCSI_SYM53C8XX_2 is not set
454# CONFIG_SCSI_IPR is not set 448# CONFIG_SCSI_IPR is not set
455# CONFIG_SCSI_QLOGIC_1280 is not set 449# CONFIG_SCSI_QLOGIC_1280 is not set
@@ -462,6 +456,11 @@ CONFIG_ISCSI_TCP=m
462# CONFIG_SCSI_SUNESP is not set 456# CONFIG_SCSI_SUNESP is not set
463 457
464# 458#
459# Serial ATA (prod) and Parallel ATA (experimental) drivers
460#
461# CONFIG_ATA is not set
462
463#
465# Multi-device support (RAID and LVM) 464# Multi-device support (RAID and LVM)
466# 465#
467CONFIG_MD=y 466CONFIG_MD=y
@@ -575,6 +574,7 @@ CONFIG_E1000_NAPI=y
575# CONFIG_VIA_VELOCITY is not set 574# CONFIG_VIA_VELOCITY is not set
576CONFIG_TIGON3=m 575CONFIG_TIGON3=m
577CONFIG_BNX2=m 576CONFIG_BNX2=m
577# CONFIG_QLA3XXX is not set
578 578
579# 579#
580# Ethernet (10000 Mbit) 580# Ethernet (10000 Mbit)
@@ -1006,6 +1006,7 @@ CONFIG_SND_ALI5451=m
1006# CONFIG_SND_VIA82XX_MODEM is not set 1006# CONFIG_SND_VIA82XX_MODEM is not set
1007# CONFIG_SND_VX222 is not set 1007# CONFIG_SND_VX222 is not set
1008# CONFIG_SND_YMFPCI is not set 1008# CONFIG_SND_YMFPCI is not set
1009# CONFIG_SND_AC97_POWER_SAVE is not set
1009 1010
1010# 1011#
1011# USB devices 1012# USB devices
@@ -1353,6 +1354,7 @@ CONFIG_KPROBES=y
1353# Kernel hacking 1354# Kernel hacking
1354# 1355#
1355CONFIG_PRINTK_TIME=y 1356CONFIG_PRINTK_TIME=y
1357CONFIG_ENABLE_MUST_CHECK=y
1356CONFIG_MAGIC_SYSRQ=y 1358CONFIG_MAGIC_SYSRQ=y
1357# CONFIG_UNUSED_SYMBOLS is not set 1359# CONFIG_UNUSED_SYMBOLS is not set
1358CONFIG_DEBUG_KERNEL=y 1360CONFIG_DEBUG_KERNEL=y
diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c
index c88ae23ce812..69444f266e2d 100644
--- a/arch/sparc64/kernel/sys_sparc32.c
+++ b/arch/sparc64/kernel/sys_sparc32.c
@@ -1016,7 +1016,7 @@ struct __sysctl_args32 {
1016 1016
1017asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args) 1017asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
1018{ 1018{
1019#ifndef CONFIG_SYSCTL 1019#ifndef CONFIG_SYSCTL_SYSCALL
1020 return -ENOSYS; 1020 return -ENOSYS;
1021#else 1021#else
1022 struct __sysctl_args32 tmp; 1022 struct __sysctl_args32 tmp;
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index dcba4e6ab570..09cb7fccc03a 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -920,8 +920,7 @@ static unsigned long __init bootmem_init(unsigned long *pages_avail,
920 if (sparc_ramdisk_image || sparc_ramdisk_image64) { 920 if (sparc_ramdisk_image || sparc_ramdisk_image64) {
921 unsigned long ramdisk_image = sparc_ramdisk_image ? 921 unsigned long ramdisk_image = sparc_ramdisk_image ?
922 sparc_ramdisk_image : sparc_ramdisk_image64; 922 sparc_ramdisk_image : sparc_ramdisk_image64;
923 if (ramdisk_image >= (unsigned long)_end - 2 * PAGE_SIZE) 923 ramdisk_image -= KERNBASE;
924 ramdisk_image -= KERNBASE;
925 initrd_start = ramdisk_image + phys_base; 924 initrd_start = ramdisk_image + phys_base;
926 initrd_end = initrd_start + sparc_ramdisk_size; 925 initrd_end = initrd_start + sparc_ramdisk_size;
927 if (initrd_end > end_of_phys_memory) { 926 if (initrd_end > end_of_phys_memory) {
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 9558a7cf34d5..11154b6773ec 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -4,10 +4,13 @@
4core-y += arch/um/sys-x86_64/ 4core-y += arch/um/sys-x86_64/
5START := 0x60000000 5START := 0x60000000
6 6
7_extra_flags_ = -fno-builtin -m64 -mcmodel=kernel
8
7#We #undef __x86_64__ for kernelspace, not for userspace where 9#We #undef __x86_64__ for kernelspace, not for userspace where
8#it's needed for headers to work! 10#it's needed for headers to work!
9CFLAGS += -U__$(SUBARCH)__ -fno-builtin -m64 11CFLAGS += -U__$(SUBARCH)__ $(_extra_flags_)
10USER_CFLAGS += -fno-builtin -m64 12USER_CFLAGS += $(_extra_flags_)
13
11CHECKFLAGS += -m64 14CHECKFLAGS += -m64
12AFLAGS += -m64 15AFLAGS += -m64
13LDFLAGS += -m elf_x86_64 16LDFLAGS += -m elf_x86_64
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index e82764f75e7f..3576b3cc505e 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -110,7 +110,7 @@ static void not_configged_free(void *data)
110 "UML\n"); 110 "UML\n");
111} 111}
112 112
113static struct chan_ops not_configged_ops = { 113static const struct chan_ops not_configged_ops = {
114 .init = not_configged_init, 114 .init = not_configged_init,
115 .open = not_configged_open, 115 .open = not_configged_open,
116 .close = not_configged_close, 116 .close = not_configged_close,
@@ -373,7 +373,7 @@ int console_write_chan(struct list_head *chans, const char *buf, int len)
373} 373}
374 374
375int console_open_chan(struct line *line, struct console *co, 375int console_open_chan(struct line *line, struct console *co,
376 struct chan_opts *opts) 376 const struct chan_opts *opts)
377{ 377{
378 int err; 378 int err;
379 379
@@ -494,10 +494,10 @@ int chan_config_string(struct list_head *chans, char *str, int size,
494 494
495struct chan_type { 495struct chan_type {
496 char *key; 496 char *key;
497 struct chan_ops *ops; 497 const struct chan_ops *ops;
498}; 498};
499 499
500static struct chan_type chan_table[] = { 500static const struct chan_type chan_table[] = {
501 { "fd", &fd_ops }, 501 { "fd", &fd_ops },
502 502
503#ifdef CONFIG_NULL_CHAN 503#ifdef CONFIG_NULL_CHAN
@@ -534,10 +534,10 @@ static struct chan_type chan_table[] = {
534}; 534};
535 535
536static struct chan *parse_chan(struct line *line, char *str, int device, 536static struct chan *parse_chan(struct line *line, char *str, int device,
537 struct chan_opts *opts) 537 const struct chan_opts *opts)
538{ 538{
539 struct chan_type *entry; 539 const struct chan_type *entry;
540 struct chan_ops *ops; 540 const struct chan_ops *ops;
541 struct chan *chan; 541 struct chan *chan;
542 void *data; 542 void *data;
543 int i; 543 int i;
@@ -582,7 +582,7 @@ static struct chan *parse_chan(struct line *line, char *str, int device,
582} 582}
583 583
584int parse_chan_pair(char *str, struct line *line, int device, 584int parse_chan_pair(char *str, struct line *line, int device,
585 struct chan_opts *opts) 585 const struct chan_opts *opts)
586{ 586{
587 struct list_head *chans = &line->chan_list; 587 struct list_head *chans = &line->chan_list;
588 struct chan *new, *chan; 588 struct chan *new, *chan;
diff --git a/arch/um/drivers/daemon.h b/arch/um/drivers/daemon.h
index 7326c42f7ef9..3bc3cf6b94aa 100644
--- a/arch/um/drivers/daemon.h
+++ b/arch/um/drivers/daemon.h
@@ -18,7 +18,7 @@ struct daemon_data {
18 void *dev; 18 void *dev;
19}; 19};
20 20
21extern struct net_user_info daemon_user_info; 21extern const struct net_user_info daemon_user_info;
22 22
23extern int daemon_user_write(int fd, void *buf, int len, 23extern int daemon_user_write(int fd, void *buf, int len,
24 struct daemon_data *pri); 24 struct daemon_data *pri);
diff --git a/arch/um/drivers/daemon_kern.c b/arch/um/drivers/daemon_kern.c
index 53d09ed78b42..824386974f88 100644
--- a/arch/um/drivers/daemon_kern.c
+++ b/arch/um/drivers/daemon_kern.c
@@ -57,7 +57,7 @@ static int daemon_write(int fd, struct sk_buff **skb,
57 (struct daemon_data *) &lp->user)); 57 (struct daemon_data *) &lp->user));
58} 58}
59 59
60static struct net_kern_info daemon_kern_info = { 60static const struct net_kern_info daemon_kern_info = {
61 .init = daemon_init, 61 .init = daemon_init,
62 .protocol = eth_protocol, 62 .protocol = eth_protocol,
63 .read = daemon_read, 63 .read = daemon_read,
diff --git a/arch/um/drivers/daemon_user.c b/arch/um/drivers/daemon_user.c
index c944265955e2..77954ea77043 100644
--- a/arch/um/drivers/daemon_user.c
+++ b/arch/um/drivers/daemon_user.c
@@ -182,7 +182,7 @@ static int daemon_set_mtu(int mtu, void *data)
182 return(mtu); 182 return(mtu);
183} 183}
184 184
185struct net_user_info daemon_user_info = { 185const struct net_user_info daemon_user_info = {
186 .init = daemon_user_init, 186 .init = daemon_user_init,
187 .open = daemon_open, 187 .open = daemon_open,
188 .close = NULL, 188 .close = NULL,
diff --git a/arch/um/drivers/fd.c b/arch/um/drivers/fd.c
index c41f75e4acb5..108b7dafbd0e 100644
--- a/arch/um/drivers/fd.c
+++ b/arch/um/drivers/fd.c
@@ -20,7 +20,7 @@ struct fd_chan {
20 char str[sizeof("1234567890\0")]; 20 char str[sizeof("1234567890\0")];
21}; 21};
22 22
23static void *fd_init(char *str, int device, struct chan_opts *opts) 23static void *fd_init(char *str, int device, const struct chan_opts *opts)
24{ 24{
25 struct fd_chan *data; 25 struct fd_chan *data;
26 char *end; 26 char *end;
@@ -77,7 +77,7 @@ static void fd_close(int fd, void *d)
77 } 77 }
78} 78}
79 79
80struct chan_ops fd_ops = { 80const struct chan_ops fd_ops = {
81 .type = "fd", 81 .type = "fd",
82 .init = fd_init, 82 .init = fd_init,
83 .open = fd_open, 83 .open = fd_open,
diff --git a/arch/um/drivers/hostaudio_kern.c b/arch/um/drivers/hostaudio_kern.c
index 37232f908cd7..d247ef45c374 100644
--- a/arch/um/drivers/hostaudio_kern.c
+++ b/arch/um/drivers/hostaudio_kern.c
@@ -280,7 +280,7 @@ static int hostmixer_release(struct inode *inode, struct file *file)
280 280
281/* kernel module operations */ 281/* kernel module operations */
282 282
283static struct file_operations hostaudio_fops = { 283static const struct file_operations hostaudio_fops = {
284 .owner = THIS_MODULE, 284 .owner = THIS_MODULE,
285 .llseek = no_llseek, 285 .llseek = no_llseek,
286 .read = hostaudio_read, 286 .read = hostaudio_read,
@@ -292,7 +292,7 @@ static struct file_operations hostaudio_fops = {
292 .release = hostaudio_release, 292 .release = hostaudio_release,
293}; 293};
294 294
295static struct file_operations hostmixer_fops = { 295static const struct file_operations hostmixer_fops = {
296 .owner = THIS_MODULE, 296 .owner = THIS_MODULE,
297 .llseek = no_llseek, 297 .llseek = no_llseek,
298 .ioctl = hostmixer_ioctl_mixdev, 298 .ioctl = hostmixer_ioctl_mixdev,
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index ebebaabb78ad..563ce7690a1e 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -251,7 +251,7 @@ void line_set_termios(struct tty_struct *tty, struct termios * old)
251 /* nothing */ 251 /* nothing */
252} 252}
253 253
254static struct { 254static const struct {
255 int cmd; 255 int cmd;
256 char *level; 256 char *level;
257 char *name; 257 char *name;
@@ -405,7 +405,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data,
405 405
406int line_setup_irq(int fd, int input, int output, struct line *line, void *data) 406int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
407{ 407{
408 struct line_driver *driver = line->driver; 408 const struct line_driver *driver = line->driver;
409 int err = 0, flags = IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM; 409 int err = 0, flags = IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM;
410 410
411 if (input) 411 if (input)
@@ -558,7 +558,7 @@ int line_setup(struct line *lines, unsigned int num, char *init)
558} 558}
559 559
560int line_config(struct line *lines, unsigned int num, char *str, 560int line_config(struct line *lines, unsigned int num, char *str,
561 struct chan_opts *opts) 561 const struct chan_opts *opts)
562{ 562{
563 struct line *line; 563 struct line *line;
564 char *new; 564 char *new;
diff --git a/arch/um/drivers/mcast.h b/arch/um/drivers/mcast.h
index a2c6db243458..bc56af9d3e53 100644
--- a/arch/um/drivers/mcast.h
+++ b/arch/um/drivers/mcast.h
@@ -13,7 +13,7 @@ struct mcast_data {
13 void *dev; 13 void *dev;
14}; 14};
15 15
16extern struct net_user_info mcast_user_info; 16extern const struct net_user_info mcast_user_info;
17 17
18extern int mcast_user_write(int fd, void *buf, int len, 18extern int mcast_user_write(int fd, void *buf, int len,
19 struct mcast_data *pri); 19 struct mcast_data *pri);
diff --git a/arch/um/drivers/mcast_kern.c b/arch/um/drivers/mcast_kern.c
index 3a7af18cf944..c090fbd464e7 100644
--- a/arch/um/drivers/mcast_kern.c
+++ b/arch/um/drivers/mcast_kern.c
@@ -61,7 +61,7 @@ static int mcast_write(int fd, struct sk_buff **skb,
61 (struct mcast_data *) &lp->user); 61 (struct mcast_data *) &lp->user);
62} 62}
63 63
64static struct net_kern_info mcast_kern_info = { 64static const struct net_kern_info mcast_kern_info = {
65 .init = mcast_init, 65 .init = mcast_init,
66 .protocol = eth_protocol, 66 .protocol = eth_protocol,
67 .read = mcast_read, 67 .read = mcast_read,
diff --git a/arch/um/drivers/mcast_user.c b/arch/um/drivers/mcast_user.c
index afe85bfa66e0..4d2bd39a85bc 100644
--- a/arch/um/drivers/mcast_user.c
+++ b/arch/um/drivers/mcast_user.c
@@ -152,7 +152,7 @@ static int mcast_set_mtu(int mtu, void *data)
152 return(mtu); 152 return(mtu);
153} 153}
154 154
155struct net_user_info mcast_user_info = { 155const struct net_user_info mcast_user_info = {
156 .init = mcast_user_init, 156 .init = mcast_user_init,
157 .open = mcast_open, 157 .open = mcast_open,
158 .close = mcast_close, 158 .close = mcast_close,
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 022f67bb6873..9a3b5daf6250 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -85,7 +85,7 @@ mmapper_release(struct inode *inode, struct file *file)
85 return 0; 85 return 0;
86} 86}
87 87
88static struct file_operations mmapper_fops = { 88static const struct file_operations mmapper_fops = {
89 .owner = THIS_MODULE, 89 .owner = THIS_MODULE,
90 .read = mmapper_read, 90 .read = mmapper_read,
91 .write = mmapper_write, 91 .write = mmapper_write,
@@ -95,7 +95,7 @@ static struct file_operations mmapper_fops = {
95 .release = mmapper_release, 95 .release = mmapper_release,
96}; 96};
97 97
98static struct miscdevice mmapper_dev = { 98static const struct miscdevice mmapper_dev = {
99 .minor = MISC_DYNAMIC_MINOR, 99 .minor = MISC_DYNAMIC_MINOR,
100 .name = "mmapper", 100 .name = "mmapper",
101 .fops = &mmapper_fops 101 .fops = &mmapper_fops
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 4a7966b21931..664c2e2fb820 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -114,8 +114,6 @@ static int uml_net_open(struct net_device *dev)
114 struct uml_net_private *lp = dev->priv; 114 struct uml_net_private *lp = dev->priv;
115 int err; 115 int err;
116 116
117 spin_lock(&lp->lock);
118
119 if(lp->fd >= 0){ 117 if(lp->fd >= 0){
120 err = -ENXIO; 118 err = -ENXIO;
121 goto out; 119 goto out;
@@ -149,8 +147,6 @@ static int uml_net_open(struct net_device *dev)
149 */ 147 */
150 while((err = uml_net_rx(dev)) > 0) ; 148 while((err = uml_net_rx(dev)) > 0) ;
151 149
152 spin_unlock(&lp->lock);
153
154 spin_lock(&opened_lock); 150 spin_lock(&opened_lock);
155 list_add(&lp->list, &opened); 151 list_add(&lp->list, &opened);
156 spin_unlock(&opened_lock); 152 spin_unlock(&opened_lock);
@@ -160,7 +156,6 @@ out_close:
160 if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user); 156 if(lp->close != NULL) (*lp->close)(lp->fd, &lp->user);
161 lp->fd = -1; 157 lp->fd = -1;
162out: 158out:
163 spin_unlock(&lp->lock);
164 return err; 159 return err;
165} 160}
166 161
@@ -169,15 +164,12 @@ static int uml_net_close(struct net_device *dev)
169 struct uml_net_private *lp = dev->priv; 164 struct uml_net_private *lp = dev->priv;
170 165
171 netif_stop_queue(dev); 166 netif_stop_queue(dev);
172 spin_lock(&lp->lock);
173 167
174 free_irq(dev->irq, dev); 168 free_irq(dev->irq, dev);
175 if(lp->close != NULL) 169 if(lp->close != NULL)
176 (*lp->close)(lp->fd, &lp->user); 170 (*lp->close)(lp->fd, &lp->user);
177 lp->fd = -1; 171 lp->fd = -1;
178 172
179 spin_unlock(&lp->lock);
180
181 spin_lock(&opened_lock); 173 spin_lock(&opened_lock);
182 list_del(&lp->list); 174 list_del(&lp->list);
183 spin_unlock(&opened_lock); 175 spin_unlock(&opened_lock);
@@ -246,9 +238,9 @@ static int uml_net_set_mac(struct net_device *dev, void *addr)
246 struct uml_net_private *lp = dev->priv; 238 struct uml_net_private *lp = dev->priv;
247 struct sockaddr *hwaddr = addr; 239 struct sockaddr *hwaddr = addr;
248 240
249 spin_lock(&lp->lock); 241 spin_lock_irq(&lp->lock);
250 set_ether_mac(dev, hwaddr->sa_data); 242 set_ether_mac(dev, hwaddr->sa_data);
251 spin_unlock(&lp->lock); 243 spin_unlock_irq(&lp->lock);
252 244
253 return(0); 245 return(0);
254} 246}
@@ -258,7 +250,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
258 struct uml_net_private *lp = dev->priv; 250 struct uml_net_private *lp = dev->priv;
259 int err = 0; 251 int err = 0;
260 252
261 spin_lock(&lp->lock); 253 spin_lock_irq(&lp->lock);
262 254
263 new_mtu = (*lp->set_mtu)(new_mtu, &lp->user); 255 new_mtu = (*lp->set_mtu)(new_mtu, &lp->user);
264 if(new_mtu < 0){ 256 if(new_mtu < 0){
@@ -269,7 +261,7 @@ static int uml_net_change_mtu(struct net_device *dev, int new_mtu)
269 dev->mtu = new_mtu; 261 dev->mtu = new_mtu;
270 262
271 out: 263 out:
272 spin_unlock(&lp->lock); 264 spin_unlock_irq(&lp->lock);
273 return err; 265 return err;
274} 266}
275 267
@@ -569,12 +561,13 @@ static int eth_setup(char *str)
569 int n, err; 561 int n, err;
570 562
571 err = eth_parse(str, &n, &str); 563 err = eth_parse(str, &n, &str);
572 if(err) return(1); 564 if(err)
565 return 1;
573 566
574 new = alloc_bootmem(sizeof(new)); 567 new = alloc_bootmem(sizeof(*new));
575 if (new == NULL){ 568 if (new == NULL){
576 printk("eth_init : alloc_bootmem failed\n"); 569 printk("eth_init : alloc_bootmem failed\n");
577 return(1); 570 return 1;
578 } 571 }
579 572
580 INIT_LIST_HEAD(&new->list); 573 INIT_LIST_HEAD(&new->list);
@@ -582,7 +575,7 @@ static int eth_setup(char *str)
582 new->init = str; 575 new->init = str;
583 576
584 list_add_tail(&new->list, &eth_cmd_line); 577 list_add_tail(&new->list, &eth_cmd_line);
585 return(1); 578 return 1;
586} 579}
587 580
588__setup("eth", eth_setup); 581__setup("eth", eth_setup);
diff --git a/arch/um/drivers/null.c b/arch/um/drivers/null.c
index 14cc5f78398a..3683ed44315d 100644
--- a/arch/um/drivers/null.c
+++ b/arch/um/drivers/null.c
@@ -10,7 +10,7 @@
10 10
11static int null_chan; 11static int null_chan;
12 12
13static void *null_init(char *str, int device, struct chan_opts *opts) 13static void *null_init(char *str, int device, const struct chan_opts *opts)
14{ 14{
15 return(&null_chan); 15 return(&null_chan);
16} 16}
@@ -31,7 +31,7 @@ static void null_free(void *data)
31{ 31{
32} 32}
33 33
34struct chan_ops null_ops = { 34const struct chan_ops null_ops = {
35 .type = "null", 35 .type = "null",
36 .init = null_init, 36 .init = null_init,
37 .open = null_open, 37 .open = null_open,
diff --git a/arch/um/drivers/pcap_kern.c b/arch/um/drivers/pcap_kern.c
index 4c767c7adb96..6e1ef8558283 100644
--- a/arch/um/drivers/pcap_kern.c
+++ b/arch/um/drivers/pcap_kern.c
@@ -46,7 +46,7 @@ static int pcap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
46 return(-EPERM); 46 return(-EPERM);
47} 47}
48 48
49static struct net_kern_info pcap_kern_info = { 49static const struct net_kern_info pcap_kern_info = {
50 .init = pcap_init, 50 .init = pcap_init,
51 .protocol = eth_protocol, 51 .protocol = eth_protocol,
52 .read = pcap_read, 52 .read = pcap_read,
diff --git a/arch/um/drivers/pcap_user.c b/arch/um/drivers/pcap_user.c
index edfcb29273e1..2ef641ded960 100644
--- a/arch/um/drivers/pcap_user.c
+++ b/arch/um/drivers/pcap_user.c
@@ -120,7 +120,7 @@ int pcap_user_read(int fd, void *buffer, int len, struct pcap_data *pri)
120 return(hdata.len); 120 return(hdata.len);
121} 121}
122 122
123struct net_user_info pcap_user_info = { 123const struct net_user_info pcap_user_info = {
124 .init = pcap_user_init, 124 .init = pcap_user_init,
125 .open = pcap_open, 125 .open = pcap_open,
126 .close = NULL, 126 .close = NULL,
diff --git a/arch/um/drivers/port_user.c b/arch/um/drivers/port_user.c
index c43e8bb32502..f2e8fc42ecc2 100644
--- a/arch/um/drivers/port_user.c
+++ b/arch/um/drivers/port_user.c
@@ -27,7 +27,7 @@ struct port_chan {
27 char dev[sizeof("32768\0")]; 27 char dev[sizeof("32768\0")];
28}; 28};
29 29
30static void *port_init(char *str, int device, struct chan_opts *opts) 30static void *port_init(char *str, int device, const struct chan_opts *opts)
31{ 31{
32 struct port_chan *data; 32 struct port_chan *data;
33 void *kern_data; 33 void *kern_data;
@@ -100,7 +100,7 @@ static void port_close(int fd, void *d)
100 os_close_file(fd); 100 os_close_file(fd);
101} 101}
102 102
103struct chan_ops port_ops = { 103const struct chan_ops port_ops = {
104 .type = "port", 104 .type = "port",
105 .init = port_init, 105 .init = port_init,
106 .open = port_open, 106 .open = port_open,
diff --git a/arch/um/drivers/pty.c b/arch/um/drivers/pty.c
index 1c555c38de4d..abec620e8380 100644
--- a/arch/um/drivers/pty.c
+++ b/arch/um/drivers/pty.c
@@ -22,7 +22,7 @@ struct pty_chan {
22 char dev_name[sizeof("/dev/pts/0123456\0")]; 22 char dev_name[sizeof("/dev/pts/0123456\0")];
23}; 23};
24 24
25static void *pty_chan_init(char *str, int device, struct chan_opts *opts) 25static void *pty_chan_init(char *str, int device, const struct chan_opts *opts)
26{ 26{
27 struct pty_chan *data; 27 struct pty_chan *data;
28 28
@@ -118,7 +118,7 @@ static int pty_open(int input, int output, int primary, void *d,
118 return(fd); 118 return(fd);
119} 119}
120 120
121struct chan_ops pty_ops = { 121const struct chan_ops pty_ops = {
122 .type = "pty", 122 .type = "pty",
123 .init = pty_chan_init, 123 .init = pty_chan_init,
124 .open = pty_open, 124 .open = pty_open,
@@ -131,7 +131,7 @@ struct chan_ops pty_ops = {
131 .winch = 0, 131 .winch = 0,
132}; 132};
133 133
134struct chan_ops pts_ops = { 134const struct chan_ops pts_ops = {
135 .type = "pts", 135 .type = "pts",
136 .init = pty_chan_init, 136 .init = pty_chan_init,
137 .open = pts_open, 137 .open = pts_open,
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c
index ba471f5864a6..ae9909415b9c 100644
--- a/arch/um/drivers/random.c
+++ b/arch/um/drivers/random.c
@@ -68,7 +68,7 @@ static ssize_t rng_dev_read (struct file *filp, char __user *buf, size_t size,
68 return ret; 68 return ret;
69} 69}
70 70
71static struct file_operations rng_chrdev_ops = { 71static const struct file_operations rng_chrdev_ops = {
72 .owner = THIS_MODULE, 72 .owner = THIS_MODULE,
73 .open = rng_dev_open, 73 .open = rng_dev_open,
74 .read = rng_dev_read, 74 .read = rng_dev_read,
diff --git a/arch/um/drivers/slip.h b/arch/um/drivers/slip.h
index bb0dab41c2e4..c64f8c61d274 100644
--- a/arch/um/drivers/slip.h
+++ b/arch/um/drivers/slip.h
@@ -12,7 +12,7 @@ struct slip_data {
12 struct slip_proto slip; 12 struct slip_proto slip;
13}; 13};
14 14
15extern struct net_user_info slip_user_info; 15extern const struct net_user_info slip_user_info;
16 16
17extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri); 17extern int slip_user_read(int fd, void *buf, int len, struct slip_data *pri);
18extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri); 18extern int slip_user_write(int fd, void *buf, int len, struct slip_data *pri);
diff --git a/arch/um/drivers/slip_kern.c b/arch/um/drivers/slip_kern.c
index 163ee0d5f75e..ccea2d7885e5 100644
--- a/arch/um/drivers/slip_kern.c
+++ b/arch/um/drivers/slip_kern.c
@@ -61,7 +61,7 @@ static int slip_write(int fd, struct sk_buff **skb,
61 (struct slip_data *) &lp->user)); 61 (struct slip_data *) &lp->user));
62} 62}
63 63
64struct net_kern_info slip_kern_info = { 64const struct net_kern_info slip_kern_info = {
65 .init = slip_init, 65 .init = slip_init,
66 .protocol = slip_protocol, 66 .protocol = slip_protocol,
67 .read = slip_read, 67 .read = slip_read,
diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
index 89fbec185cc1..8460285c69a5 100644
--- a/arch/um/drivers/slip_user.c
+++ b/arch/um/drivers/slip_user.c
@@ -241,7 +241,7 @@ static void slip_del_addr(unsigned char *addr, unsigned char *netmask,
241 close_addr(addr, netmask, pri->name); 241 close_addr(addr, netmask, pri->name);
242} 242}
243 243
244struct net_user_info slip_user_info = { 244const struct net_user_info slip_user_info = {
245 .init = slip_user_init, 245 .init = slip_user_init,
246 .open = slip_open, 246 .open = slip_open,
247 .close = slip_close, 247 .close = slip_close,
diff --git a/arch/um/drivers/slirp.h b/arch/um/drivers/slirp.h
index 6cf88ab580c9..89ccf83b7577 100644
--- a/arch/um/drivers/slirp.h
+++ b/arch/um/drivers/slirp.h
@@ -24,7 +24,7 @@ struct slirp_data {
24 struct slip_proto slip; 24 struct slip_proto slip;
25}; 25};
26 26
27extern struct net_user_info slirp_user_info; 27extern const struct net_user_info slirp_user_info;
28 28
29extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri); 29extern int slirp_user_read(int fd, void *buf, int len, struct slirp_data *pri);
30extern int slirp_user_write(int fd, void *buf, int len, 30extern int slirp_user_write(int fd, void *buf, int len,
diff --git a/arch/um/drivers/slirp_kern.c b/arch/um/drivers/slirp_kern.c
index 95e50c943e14..ae322e1c8a87 100644
--- a/arch/um/drivers/slirp_kern.c
+++ b/arch/um/drivers/slirp_kern.c
@@ -64,7 +64,7 @@ static int slirp_write(int fd, struct sk_buff **skb,
64 (struct slirp_data *) &lp->user)); 64 (struct slirp_data *) &lp->user));
65} 65}
66 66
67struct net_kern_info slirp_kern_info = { 67const struct net_kern_info slirp_kern_info = {
68 .init = slirp_init, 68 .init = slirp_init,
69 .protocol = slirp_protocol, 69 .protocol = slirp_protocol,
70 .read = slirp_read, 70 .read = slirp_read,
diff --git a/arch/um/drivers/slirp_user.c b/arch/um/drivers/slirp_user.c
index 33c5f6e625e8..ce5e85d1de3d 100644
--- a/arch/um/drivers/slirp_user.c
+++ b/arch/um/drivers/slirp_user.c
@@ -126,7 +126,7 @@ static int slirp_set_mtu(int mtu, void *data)
126 return(mtu); 126 return(mtu);
127} 127}
128 128
129struct net_user_info slirp_user_info = { 129const struct net_user_info slirp_user_info = {
130 .init = slirp_user_init, 130 .init = slirp_user_init,
131 .open = slirp_open, 131 .open = slirp_open,
132 .close = slirp_close, 132 .close = slirp_close,
diff --git a/arch/um/drivers/ssl.c b/arch/um/drivers/ssl.c
index 6dafd6fbfdae..6f13e7c71a82 100644
--- a/arch/um/drivers/ssl.c
+++ b/arch/um/drivers/ssl.c
@@ -23,7 +23,7 @@
23#include "irq_user.h" 23#include "irq_user.h"
24#include "mconsole_kern.h" 24#include "mconsole_kern.h"
25 25
26static int ssl_version = 1; 26static const int ssl_version = 1;
27 27
28/* Referenced only by tty_driver below - presumably it's locked correctly 28/* Referenced only by tty_driver below - presumably it's locked correctly
29 * by the tty driver. 29 * by the tty driver.
@@ -123,7 +123,7 @@ void ssl_hangup(struct tty_struct *tty)
123} 123}
124#endif 124#endif
125 125
126static struct tty_operations ssl_ops = { 126static const struct tty_operations ssl_ops = {
127 .open = ssl_open, 127 .open = ssl_open,
128 .close = line_close, 128 .close = line_close,
129 .write = line_write, 129 .write = line_write,
diff --git a/arch/um/drivers/stdio_console.c b/arch/um/drivers/stdio_console.c
index 856f568c2687..5e44adb07051 100644
--- a/arch/um/drivers/stdio_console.c
+++ b/arch/um/drivers/stdio_console.c
@@ -110,7 +110,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
110 110
111static int con_init_done = 0; 111static int con_init_done = 0;
112 112
113static struct tty_operations console_ops = { 113static const struct tty_operations console_ops = {
114 .open = con_open, 114 .open = con_open,
115 .close = line_close, 115 .close = line_close,
116 .write = line_write, 116 .write = line_write,
diff --git a/arch/um/drivers/tty.c b/arch/um/drivers/tty.c
index 9f70edf5d8ef..11de3ac1eb5c 100644
--- a/arch/um/drivers/tty.c
+++ b/arch/um/drivers/tty.c
@@ -18,7 +18,7 @@ struct tty_chan {
18 struct termios tt; 18 struct termios tt;
19}; 19};
20 20
21static void *tty_chan_init(char *str, int device, struct chan_opts *opts) 21static void *tty_chan_init(char *str, int device, const struct chan_opts *opts)
22{ 22{
23 struct tty_chan *data; 23 struct tty_chan *data;
24 24
@@ -62,7 +62,7 @@ static int tty_open(int input, int output, int primary, void *d,
62 return fd; 62 return fd;
63} 63}
64 64
65struct chan_ops tty_ops = { 65const struct chan_ops tty_ops = {
66 .type = "tty", 66 .type = "tty",
67 .init = tty_chan_init, 67 .init = tty_chan_init,
68 .open = tty_open, 68 .open = tty_open,
diff --git a/arch/um/drivers/xterm.c b/arch/um/drivers/xterm.c
index aaa636661043..386f8b952982 100644
--- a/arch/um/drivers/xterm.c
+++ b/arch/um/drivers/xterm.c
@@ -31,7 +31,7 @@ struct xterm_chan {
31}; 31};
32 32
33/* Not static because it's called directly by the tt mode gdb code */ 33/* Not static because it's called directly by the tt mode gdb code */
34void *xterm_init(char *str, int device, struct chan_opts *opts) 34void *xterm_init(char *str, int device, const struct chan_opts *opts)
35{ 35{
36 struct xterm_chan *data; 36 struct xterm_chan *data;
37 37
@@ -194,7 +194,7 @@ static void xterm_free(void *d)
194 free(d); 194 free(d);
195} 195}
196 196
197struct chan_ops xterm_ops = { 197const struct chan_ops xterm_ops = {
198 .type = "xterm", 198 .type = "xterm",
199 .init = xterm_init, 199 .init = xterm_init,
200 .open = xterm_open, 200 .open = xterm_open,
diff --git a/arch/um/include/chan_kern.h b/arch/um/include/chan_kern.h
index 1bb5e9d94270..572d286ed2c6 100644
--- a/arch/um/include/chan_kern.h
+++ b/arch/um/include/chan_kern.h
@@ -23,21 +23,21 @@ struct chan {
23 unsigned int opened:1; 23 unsigned int opened:1;
24 unsigned int enabled:1; 24 unsigned int enabled:1;
25 int fd; 25 int fd;
26 struct chan_ops *ops; 26 const struct chan_ops *ops;
27 void *data; 27 void *data;
28}; 28};
29 29
30extern void chan_interrupt(struct list_head *chans, struct work_struct *task, 30extern void chan_interrupt(struct list_head *chans, struct work_struct *task,
31 struct tty_struct *tty, int irq); 31 struct tty_struct *tty, int irq);
32extern int parse_chan_pair(char *str, struct line *line, int device, 32extern int parse_chan_pair(char *str, struct line *line, int device,
33 struct chan_opts *opts); 33 const struct chan_opts *opts);
34extern int open_chan(struct list_head *chans); 34extern int open_chan(struct list_head *chans);
35extern int write_chan(struct list_head *chans, const char *buf, int len, 35extern int write_chan(struct list_head *chans, const char *buf, int len,
36 int write_irq); 36 int write_irq);
37extern int console_write_chan(struct list_head *chans, const char *buf, 37extern int console_write_chan(struct list_head *chans, const char *buf,
38 int len); 38 int len);
39extern int console_open_chan(struct line *line, struct console *co, 39extern int console_open_chan(struct line *line, struct console *co,
40 struct chan_opts *opts); 40 const struct chan_opts *opts);
41extern void deactivate_chan(struct list_head *chans, int irq); 41extern void deactivate_chan(struct list_head *chans, int irq);
42extern void reactivate_chan(struct list_head *chans, int irq); 42extern void reactivate_chan(struct list_head *chans, int irq);
43extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty); 43extern void chan_enable_winch(struct list_head *chans, struct tty_struct *tty);
diff --git a/arch/um/include/chan_user.h b/arch/um/include/chan_user.h
index 659bb3cac32f..a795547a1dbd 100644
--- a/arch/um/include/chan_user.h
+++ b/arch/um/include/chan_user.h
@@ -20,7 +20,7 @@ enum chan_init_pri { INIT_STATIC, INIT_ALL, INIT_ONE };
20 20
21struct chan_ops { 21struct chan_ops {
22 char *type; 22 char *type;
23 void *(*init)(char *, int, struct chan_opts *); 23 void *(*init)(char *, int, const struct chan_opts *);
24 int (*open)(int, int, int, void *, char **); 24 int (*open)(int, int, int, void *, char **);
25 void (*close)(int, void *); 25 void (*close)(int, void *);
26 int (*read)(int, char *, void *); 26 int (*read)(int, char *, void *);
@@ -31,8 +31,8 @@ struct chan_ops {
31 int winch; 31 int winch;
32}; 32};
33 33
34extern struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops, tty_ops, 34extern const struct chan_ops fd_ops, null_ops, port_ops, pts_ops, pty_ops,
35 xterm_ops; 35 tty_ops, xterm_ops;
36 36
37extern void generic_close(int fd, void *unused); 37extern void generic_close(int fd, void *unused);
38extern int generic_read(int fd, char *c_out, void *unused); 38extern int generic_read(int fd, char *c_out, void *unused);
diff --git a/arch/um/include/kern_util.h b/arch/um/include/kern_util.h
index 89e1dc835a5b..59cfa9e0cad0 100644
--- a/arch/um/include/kern_util.h
+++ b/arch/um/include/kern_util.h
@@ -21,7 +21,7 @@ struct kern_handlers {
21 kern_hndl timer_handler; 21 kern_hndl timer_handler;
22}; 22};
23 23
24extern struct kern_handlers handlinfo_kern; 24extern const struct kern_handlers handlinfo_kern;
25 25
26extern int ncpus; 26extern int ncpus;
27extern char *linux_prog; 27extern char *linux_prog;
diff --git a/arch/um/include/line.h b/arch/um/include/line.h
index 27bf2f6fbc05..642c9a0320f9 100644
--- a/arch/um/include/line.h
+++ b/arch/um/include/line.h
@@ -52,7 +52,7 @@ struct line {
52 52
53 int sigio; 53 int sigio;
54 struct work_struct task; 54 struct work_struct task;
55 struct line_driver *driver; 55 const struct line_driver *driver;
56 int have_irq; 56 int have_irq;
57}; 57};
58 58
@@ -99,7 +99,7 @@ extern void lines_init(struct line *lines, int nlines, struct chan_opts *opts);
99extern void close_lines(struct line *lines, int nlines); 99extern void close_lines(struct line *lines, int nlines);
100 100
101extern int line_config(struct line *lines, unsigned int sizeof_lines, 101extern int line_config(struct line *lines, unsigned int sizeof_lines,
102 char *str, struct chan_opts *opts); 102 char *str, const struct chan_opts *opts);
103extern int line_id(char **str, int *start_out, int *end_out); 103extern int line_id(char **str, int *start_out, int *end_out);
104extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n); 104extern int line_remove(struct line *lines, unsigned int sizeof_lines, int n);
105extern int line_get_config(char *dev, struct line *lines, 105extern int line_get_config(char *dev, struct line *lines,
diff --git a/arch/um/include/net_kern.h b/arch/um/include/net_kern.h
index f7de6df60dd7..769fba43ee03 100644
--- a/arch/um/include/net_kern.h
+++ b/arch/um/include/net_kern.h
@@ -54,8 +54,8 @@ struct transport {
54 struct list_head list; 54 struct list_head list;
55 char *name; 55 char *name;
56 int (*setup)(char *, char **, void *); 56 int (*setup)(char *, char **, void *);
57 struct net_user_info *user; 57 const struct net_user_info *user;
58 struct net_kern_info *kern; 58 const struct net_kern_info *kern;
59 int private_size; 59 int private_size;
60 int setup_size; 60 int setup_size;
61}; 61};
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 24fb6d8680e1..120ca21a513a 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -14,6 +14,7 @@
14#include "skas/mm_id.h" 14#include "skas/mm_id.h"
15#include "irq_user.h" 15#include "irq_user.h"
16#include "sysdep/tls.h" 16#include "sysdep/tls.h"
17#include "sysdep/archsetjmp.h"
17 18
18#define OS_TYPE_FILE 1 19#define OS_TYPE_FILE 1
19#define OS_TYPE_DIR 2 20#define OS_TYPE_DIR 2
@@ -198,7 +199,9 @@ extern long os_ptrace_ldt(long pid, long addr, long data);
198extern int os_getpid(void); 199extern int os_getpid(void);
199extern int os_getpgrp(void); 200extern int os_getpgrp(void);
200 201
202#ifdef UML_CONFIG_MODE_TT
201extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)); 203extern void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int));
204#endif
202extern void init_new_thread_signals(void); 205extern void init_new_thread_signals(void);
203extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); 206extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
204 207
@@ -216,7 +219,6 @@ extern void os_flush_stdout(void);
216 */ 219 */
217extern void forward_ipi(int fd, int pid); 220extern void forward_ipi(int fd, int pid);
218extern void kill_child_dead(int pid); 221extern void kill_child_dead(int pid);
219extern void stop(void);
220extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); 222extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
221extern int protect_memory(unsigned long addr, unsigned long len, 223extern int protect_memory(unsigned long addr, unsigned long len,
222 int r, int w, int x, int must_succeed); 224 int r, int w, int x, int must_succeed);
@@ -307,12 +309,9 @@ extern int copy_context_skas0(unsigned long stack, int pid);
307extern void userspace(union uml_pt_regs *regs); 309extern void userspace(union uml_pt_regs *regs);
308extern void map_stub_pages(int fd, unsigned long code, 310extern void map_stub_pages(int fd, unsigned long code,
309 unsigned long data, unsigned long stack); 311 unsigned long data, unsigned long stack);
310extern void new_thread(void *stack, void **switch_buf_ptr, 312extern void new_thread(void *stack, jmp_buf *buf, void (*handler)(void));
311 void **fork_buf_ptr, void (*handler)(int)); 313extern void switch_threads(jmp_buf *me, jmp_buf *you);
312extern void thread_wait(void *sw, void *fb); 314extern int start_idle_thread(void *stack, jmp_buf *switch_buf);
313extern void switch_threads(void *me, void *next);
314extern int start_idle_thread(void *stack, void *switch_buf_ptr,
315 void **fork_buf_ptr);
316extern void initial_thread_cb_skas(void (*proc)(void *), 315extern void initial_thread_cb_skas(void (*proc)(void *),
317 void *arg); 316 void *arg);
318extern void halt_skas(void); 317extern void halt_skas(void);
diff --git a/arch/um/include/skas/skas.h b/arch/um/include/skas/skas.h
index 853b26f148c5..e88926b16072 100644
--- a/arch/um/include/skas/skas.h
+++ b/arch/um/include/skas/skas.h
@@ -14,8 +14,7 @@ extern int proc_mm, ptrace_faultinfo, ptrace_ldt;
14extern int skas_needs_stub; 14extern int skas_needs_stub;
15 15
16extern int user_thread(unsigned long stack, int flags); 16extern int user_thread(unsigned long stack, int flags);
17extern void new_thread_proc(void *stack, void (*handler)(int sig)); 17extern void new_thread_handler(void);
18extern void new_thread_handler(int sig);
19extern void handle_syscall(union uml_pt_regs *regs); 18extern void handle_syscall(union uml_pt_regs *regs);
20extern int new_mm(unsigned long stack); 19extern int new_mm(unsigned long stack);
21extern void get_skas_faultinfo(int pid, struct faultinfo * fi); 20extern void get_skas_faultinfo(int pid, struct faultinfo * fi);
diff --git a/arch/um/include/sysdep-i386/archsetjmp.h b/arch/um/include/sysdep-i386/archsetjmp.h
index ea1ba3d42aee..11bafab669e9 100644
--- a/arch/um/include/sysdep-i386/archsetjmp.h
+++ b/arch/um/include/sysdep-i386/archsetjmp.h
@@ -16,4 +16,7 @@ struct __jmp_buf {
16 16
17typedef struct __jmp_buf jmp_buf[1]; 17typedef struct __jmp_buf jmp_buf[1];
18 18
19#define JB_IP __eip
20#define JB_SP __esp
21
19#endif /* _SETJMP_H */ 22#endif /* _SETJMP_H */
diff --git a/arch/um/include/sysdep-x86_64/archsetjmp.h b/arch/um/include/sysdep-x86_64/archsetjmp.h
index 454fc60aff6d..9a5e1a6ec800 100644
--- a/arch/um/include/sysdep-x86_64/archsetjmp.h
+++ b/arch/um/include/sysdep-x86_64/archsetjmp.h
@@ -18,4 +18,7 @@ struct __jmp_buf {
18 18
19typedef struct __jmp_buf jmp_buf[1]; 19typedef struct __jmp_buf jmp_buf[1];
20 20
21#define JB_IP __rip
22#define JB_SP __rsp
23
21#endif /* _SETJMP_H */ 24#endif /* _SETJMP_H */
diff --git a/arch/um/include/sysdep-x86_64/ptrace.h b/arch/um/include/sysdep-x86_64/ptrace.h
index 8d353f0feec1..617bb9efc934 100644
--- a/arch/um/include/sysdep-x86_64/ptrace.h
+++ b/arch/um/include/sysdep-x86_64/ptrace.h
@@ -50,6 +50,21 @@
50#define HOST_FS 25 50#define HOST_FS 25
51#define HOST_GS 26 51#define HOST_GS 26
52 52
53/* Also defined in asm/ptrace-x86_64.h, but not in libc headers. So, these
54 * are already defined for kernel code, but not for userspace code.
55 */
56#ifndef FS_BASE
57/* These aren't defined in ptrace.h, but exist in struct user_regs_struct,
58 * which is what x86_64 ptrace actually uses.
59 */
60#define FS_BASE (HOST_FS_BASE * sizeof(long))
61#define GS_BASE (HOST_GS_BASE * sizeof(long))
62#define DS (HOST_DS * sizeof(long))
63#define ES (HOST_ES * sizeof(long))
64#define FS (HOST_FS * sizeof(long))
65#define GS (HOST_GS * sizeof(long))
66#endif
67
53#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE]) 68#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
54#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE]) 69#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
55#define REGS_DS(r) ((r)[HOST_DS]) 70#define REGS_DS(r) ((r)[HOST_DS])
@@ -89,9 +104,12 @@ union uml_pt_regs {
89#endif 104#endif
90#ifdef UML_CONFIG_MODE_SKAS 105#ifdef UML_CONFIG_MODE_SKAS
91 struct skas_regs { 106 struct skas_regs {
92 /* XXX */ 107 /* x86_64 ptrace uses sizeof(user_regs_struct) as its register
93 unsigned long regs[27]; 108 * file size, while i386 uses FRAME_SIZE. Therefore, we need
94 unsigned long fp[65]; 109 * to use UM_FRAME_SIZE here instead of HOST_FRAME_SIZE.
110 */
111 unsigned long regs[UM_FRAME_SIZE];
112 unsigned long fp[HOST_FP_SIZE];
95 struct faultinfo faultinfo; 113 struct faultinfo faultinfo;
96 long syscall; 114 long syscall;
97 int is_user; 115 int is_user;
@@ -120,11 +138,16 @@ extern int mode_tt;
120#define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs)) 138#define UPT_R14(r) __CHOOSE_MODE(SC_R14(UPT_SC(r)), REGS_R14((r)->skas.regs))
121#define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs)) 139#define UPT_R15(r) __CHOOSE_MODE(SC_R15(UPT_SC(r)), REGS_R15((r)->skas.regs))
122#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs)) 140#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
141#define UPT_FS_BASE(r) \
142 __CHOOSE_MODE(SC_FS_BASE(UPT_SC(r)), REGS_FS_BASE((r)->skas.regs))
123#define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs)) 143#define UPT_FS(r) __CHOOSE_MODE(SC_FS(UPT_SC(r)), REGS_FS((r)->skas.regs))
144#define UPT_GS_BASE(r) \
145 __CHOOSE_MODE(SC_GS_BASE(UPT_SC(r)), REGS_GS_BASE((r)->skas.regs))
124#define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs)) 146#define UPT_GS(r) __CHOOSE_MODE(SC_GS(UPT_SC(r)), REGS_GS((r)->skas.regs))
125#define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs)) 147#define UPT_DS(r) __CHOOSE_MODE(SC_DS(UPT_SC(r)), REGS_DS((r)->skas.regs))
126#define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs)) 148#define UPT_ES(r) __CHOOSE_MODE(SC_ES(UPT_SC(r)), REGS_ES((r)->skas.regs))
127#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs)) 149#define UPT_CS(r) __CHOOSE_MODE(SC_CS(UPT_SC(r)), REGS_CS((r)->skas.regs))
150#define UPT_SS(r) __CHOOSE_MODE(SC_SS(UPT_SC(r)), REGS_SS((r)->skas.regs))
128#define UPT_ORIG_RAX(r) \ 151#define UPT_ORIG_RAX(r) \
129 __CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs)) 152 __CHOOSE_MODE((r)->tt.orig_rax, REGS_ORIG_RAX((r)->skas.regs))
130 153
@@ -183,6 +206,13 @@ struct syscall_args {
183 case RBP: val = UPT_RBP(regs); break; \ 206 case RBP: val = UPT_RBP(regs); break; \
184 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \ 207 case ORIG_RAX: val = UPT_ORIG_RAX(regs); break; \
185 case CS: val = UPT_CS(regs); break; \ 208 case CS: val = UPT_CS(regs); break; \
209 case SS: val = UPT_SS(regs); break; \
210 case FS_BASE: val = UPT_FS_BASE(regs); break; \
211 case GS_BASE: val = UPT_GS_BASE(regs); break; \
212 case DS: val = UPT_DS(regs); break; \
213 case ES: val = UPT_ES(regs); break; \
214 case FS : val = UPT_FS (regs); break; \
215 case GS: val = UPT_GS(regs); break; \
186 case EFLAGS: val = UPT_EFLAGS(regs); break; \ 216 case EFLAGS: val = UPT_EFLAGS(regs); break; \
187 default : \ 217 default : \
188 panic("Bad register in UPT_REG : %d\n", reg); \ 218 panic("Bad register in UPT_REG : %d\n", reg); \
@@ -214,6 +244,13 @@ struct syscall_args {
214 case RBP: UPT_RBP(regs) = __upt_val; break; \ 244 case RBP: UPT_RBP(regs) = __upt_val; break; \
215 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \ 245 case ORIG_RAX: UPT_ORIG_RAX(regs) = __upt_val; break; \
216 case CS: UPT_CS(regs) = __upt_val; break; \ 246 case CS: UPT_CS(regs) = __upt_val; break; \
247 case SS: UPT_SS(regs) = __upt_val; break; \
248 case FS_BASE: UPT_FS_BASE(regs) = __upt_val; break; \
249 case GS_BASE: UPT_GS_BASE(regs) = __upt_val; break; \
250 case DS: UPT_DS(regs) = __upt_val; break; \
251 case ES: UPT_ES(regs) = __upt_val; break; \
252 case FS: UPT_FS(regs) = __upt_val; break; \
253 case GS: UPT_GS(regs) = __upt_val; break; \
217 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \ 254 case EFLAGS: UPT_EFLAGS(regs) = __upt_val; break; \
218 default : \ 255 default : \
219 panic("Bad register in UPT_SET : %d\n", reg); \ 256 panic("Bad register in UPT_SET : %d\n", reg); \
diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/include/sysdep-x86_64/sc.h
index a160d9fcc596..8aee45b07434 100644
--- a/arch/um/include/sysdep-x86_64/sc.h
+++ b/arch/um/include/sysdep-x86_64/sc.h
@@ -35,11 +35,11 @@
35#define SC_GS(sc) SC_OFFSET(sc, SC_GS) 35#define SC_GS(sc) SC_OFFSET(sc, SC_GS)
36#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) 36#define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS)
37#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) 37#define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK)
38#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
38#if 0 39#if 0
39#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX) 40#define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX)
40#define SC_DS(sc) SC_OFFSET(sc, SC_DS) 41#define SC_DS(sc) SC_OFFSET(sc, SC_DS)
41#define SC_ES(sc) SC_OFFSET(sc, SC_ES) 42#define SC_ES(sc) SC_OFFSET(sc, SC_ES)
42#define SC_SS(sc) SC_OFFSET(sc, SC_SS)
43#endif 43#endif
44 44
45#endif 45#endif
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index a2d93065b2d0..6fa63a2a89e3 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := vmlinux.lds
7clean-files := 7clean-files :=
8 8
9obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \ 9obj-y = config.o exec.o exitcode.o init_task.o irq.o ksyms.o mem.o \
10 physmem.o process_kern.o ptrace.o reboot.o resource.o sigio.o \ 10 physmem.o process.o ptrace.o reboot.o resource.o sigio.o \
11 signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \ 11 signal.o smp.o syscall.o sysrq.o time.o tlb.o trap.o uaccess.o \
12 um_arch.o umid.o 12 um_arch.o umid.o
13 13
diff --git a/arch/um/kernel/gmon_syms.c b/arch/um/kernel/gmon_syms.c
index 2c86e7fdb014..13aa115cd1b4 100644
--- a/arch/um/kernel/gmon_syms.c
+++ b/arch/um/kernel/gmon_syms.c
@@ -5,7 +5,7 @@
5 5
6#include "linux/module.h" 6#include "linux/module.h"
7 7
8extern void __bb_init_func(void *); 8extern void __bb_init_func(void *) __attribute__((weak));
9EXPORT_SYMBOL(__bb_init_func); 9EXPORT_SYMBOL(__bb_init_func);
10 10
11/* This is defined (and referred to in profiling stub code) only by some GCC 11/* This is defined (and referred to in profiling stub code) only by some GCC
@@ -21,14 +21,3 @@ EXPORT_SYMBOL(__gcov_init);
21 21
22extern void __gcov_merge_add(void *) __attribute__((weak)); 22extern void __gcov_merge_add(void *) __attribute__((weak));
23EXPORT_SYMBOL(__gcov_merge_add); 23EXPORT_SYMBOL(__gcov_merge_add);
24
25/*
26 * Overrides for Emacs so that we follow Linus's tabbing style.
27 * Emacs will notice this stuff at the end of the file and automatically
28 * adjust the settings for this buffer only. This must remain at the end
29 * of the file.
30 * ---------------------------------------------------------------------------
31 * Local variables:
32 * c-file-style: "linux"
33 * End:
34 */
diff --git a/arch/um/kernel/ksyms.c b/arch/um/kernel/ksyms.c
index c97045d6d89f..f030e44262ba 100644
--- a/arch/um/kernel/ksyms.c
+++ b/arch/um/kernel/ksyms.c
@@ -21,7 +21,6 @@
21#include "mem_user.h" 21#include "mem_user.h"
22#include "os.h" 22#include "os.h"
23 23
24EXPORT_SYMBOL(stop);
25EXPORT_SYMBOL(uml_physmem); 24EXPORT_SYMBOL(uml_physmem);
26EXPORT_SYMBOL(set_signals); 25EXPORT_SYMBOL(set_signals);
27EXPORT_SYMBOL(get_signals); 26EXPORT_SYMBOL(get_signals);
@@ -41,12 +40,14 @@ EXPORT_SYMBOL(handle_page_fault);
41EXPORT_SYMBOL(find_iomem); 40EXPORT_SYMBOL(find_iomem);
42 41
43#ifdef CONFIG_MODE_TT 42#ifdef CONFIG_MODE_TT
43EXPORT_SYMBOL(stop);
44EXPORT_SYMBOL(strncpy_from_user_tt); 44EXPORT_SYMBOL(strncpy_from_user_tt);
45EXPORT_SYMBOL(copy_from_user_tt); 45EXPORT_SYMBOL(copy_from_user_tt);
46EXPORT_SYMBOL(copy_to_user_tt); 46EXPORT_SYMBOL(copy_to_user_tt);
47#endif 47#endif
48 48
49#ifdef CONFIG_MODE_SKAS 49#ifdef CONFIG_MODE_SKAS
50EXPORT_SYMBOL(strnlen_user_skas);
50EXPORT_SYMBOL(strncpy_from_user_skas); 51EXPORT_SYMBOL(strncpy_from_user_skas);
51EXPORT_SYMBOL(copy_to_user_skas); 52EXPORT_SYMBOL(copy_to_user_skas);
52EXPORT_SYMBOL(copy_from_user_skas); 53EXPORT_SYMBOL(copy_from_user_skas);
diff --git a/arch/um/kernel/mem.c b/arch/um/kernel/mem.c
index 93121c6d26e5..c95855ba6ab5 100644
--- a/arch/um/kernel/mem.c
+++ b/arch/um/kernel/mem.c
@@ -226,7 +226,8 @@ void paging_init(void)
226 for(i = 0; i < ARRAY_SIZE(zones_size); i++) 226 for(i = 0; i < ARRAY_SIZE(zones_size); i++)
227 zones_size[i] = 0; 227 zones_size[i] = 0;
228 228
229 zones_size[ZONE_DMA] = (end_iomem >> PAGE_SHIFT) - (uml_physmem >> PAGE_SHIFT); 229 zones_size[ZONE_NORMAL] = (end_iomem >> PAGE_SHIFT) -
230 (uml_physmem >> PAGE_SHIFT);
230#ifdef CONFIG_HIGHMEM 231#ifdef CONFIG_HIGHMEM
231 zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT; 232 zones_size[ZONE_HIGHMEM] = highmem >> PAGE_SHIFT;
232#endif 233#endif
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process.c
index 537895d68ad1..fe6c64abda5b 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process.c
@@ -1,10 +1,9 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Copyright 2003 PathScale, Inc. 3 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL 4 * Licensed under the GPL
5 */ 5 */
6 6
7#include "linux/config.h"
8#include "linux/kernel.h" 7#include "linux/kernel.h"
9#include "linux/sched.h" 8#include "linux/sched.h"
10#include "linux/interrupt.h" 9#include "linux/interrupt.h"
@@ -113,11 +112,11 @@ void set_current(void *t)
113 112
114void *_switch_to(void *prev, void *next, void *last) 113void *_switch_to(void *prev, void *next, void *last)
115{ 114{
116 struct task_struct *from = prev; 115 struct task_struct *from = prev;
117 struct task_struct *to= next; 116 struct task_struct *to= next;
118 117
119 to->thread.prev_sched = from; 118 to->thread.prev_sched = from;
120 set_current(to); 119 set_current(to);
121 120
122 do { 121 do {
123 current->thread.saved_task = NULL ; 122 current->thread.saved_task = NULL ;
@@ -128,7 +127,7 @@ void *_switch_to(void *prev, void *next, void *last)
128 prev= current; 127 prev= current;
129 } while(current->thread.saved_task); 128 } while(current->thread.saved_task);
130 129
131 return(current->thread.prev_sched); 130 return(current->thread.prev_sched);
132 131
133} 132}
134 133
@@ -142,19 +141,19 @@ void release_thread(struct task_struct *task)
142{ 141{
143 CHOOSE_MODE(release_thread_tt(task), release_thread_skas(task)); 142 CHOOSE_MODE(release_thread_tt(task), release_thread_skas(task));
144} 143}
145 144
146void exit_thread(void) 145void exit_thread(void)
147{ 146{
148 unprotect_stack((unsigned long) current_thread); 147 unprotect_stack((unsigned long) current_thread);
149} 148}
150 149
151void *get_current(void) 150void *get_current(void)
152{ 151{
153 return(current); 152 return(current);
154} 153}
155 154
156int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, 155int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
157 unsigned long stack_top, struct task_struct * p, 156 unsigned long stack_top, struct task_struct * p,
158 struct pt_regs *regs) 157 struct pt_regs *regs)
159{ 158{
160 int ret; 159 int ret;
@@ -183,11 +182,11 @@ void initial_thread_cb(void (*proc)(void *), void *arg)
183 int save_kmalloc_ok = kmalloc_ok; 182 int save_kmalloc_ok = kmalloc_ok;
184 183
185 kmalloc_ok = 0; 184 kmalloc_ok = 0;
186 CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc, 185 CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc,
187 arg); 186 arg);
188 kmalloc_ok = save_kmalloc_ok; 187 kmalloc_ok = save_kmalloc_ok;
189} 188}
190 189
191unsigned long stack_sp(unsigned long page) 190unsigned long stack_sp(unsigned long page)
192{ 191{
193 return(page + PAGE_SIZE - sizeof(void *)); 192 return(page + PAGE_SIZE - sizeof(void *));
@@ -211,7 +210,7 @@ void default_idle(void)
211 */ 210 */
212 if(need_resched()) 211 if(need_resched())
213 schedule(); 212 schedule();
214 213
215 idle_sleep(10); 214 idle_sleep(10);
216 } 215 }
217} 216}
@@ -226,7 +225,7 @@ int page_size(void)
226 return(PAGE_SIZE); 225 return(PAGE_SIZE);
227} 226}
228 227
229void *um_virt_to_phys(struct task_struct *task, unsigned long addr, 228void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
230 pte_t *pte_out) 229 pte_t *pte_out)
231{ 230{
232 pgd_t *pgd; 231 pgd_t *pgd;
@@ -235,7 +234,7 @@ void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
235 pte_t *pte; 234 pte_t *pte;
236 pte_t ptent; 235 pte_t ptent;
237 236
238 if(task->mm == NULL) 237 if(task->mm == NULL)
239 return(ERR_PTR(-EINVAL)); 238 return(ERR_PTR(-EINVAL));
240 pgd = pgd_offset(task->mm, addr); 239 pgd = pgd_offset(task->mm, addr);
241 if(!pgd_present(*pgd)) 240 if(!pgd_present(*pgd))
@@ -246,7 +245,7 @@ void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
246 return(ERR_PTR(-EINVAL)); 245 return(ERR_PTR(-EINVAL));
247 246
248 pmd = pmd_offset(pud, addr); 247 pmd = pmd_offset(pud, addr);
249 if(!pmd_present(*pmd)) 248 if(!pmd_present(*pmd))
250 return(ERR_PTR(-EINVAL)); 249 return(ERR_PTR(-EINVAL));
251 250
252 pte = pte_offset_kernel(pmd, addr); 251 pte = pte_offset_kernel(pmd, addr);
@@ -271,7 +270,7 @@ char *current_cmd(void)
271 270
272void force_sigbus(void) 271void force_sigbus(void)
273{ 272{
274 printk(KERN_ERR "Killing pid %d because of a lack of memory\n", 273 printk(KERN_ERR "Killing pid %d because of a lack of memory\n",
275 current->pid); 274 current->pid);
276 lock_kernel(); 275 lock_kernel();
277 sigaddset(&current->pending.signal, SIGBUS); 276 sigaddset(&current->pending.signal, SIGBUS);
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile
index ea3a8e409a6e..3e3fa7e7e3cf 100644
--- a/arch/um/kernel/skas/Makefile
+++ b/arch/um/kernel/skas/Makefile
@@ -3,8 +3,7 @@
3# Licensed under the GPL 3# Licensed under the GPL
4# 4#
5 5
6obj-y := clone.o exec_kern.o mem.o mmu.o process_kern.o \ 6obj-y := clone.o exec.o mem.o mmu.o process.o syscall.o tlb.o uaccess.o
7 syscall.o tlb.o uaccess.o
8 7
9# clone.o is in the stub, so it can't be built with profiling 8# clone.o is in the stub, so it can't be built with profiling
10# GCC hardened also auto-enables -fpic, but we need %ebx so it can't work -> 9# GCC hardened also auto-enables -fpic, but we need %ebx so it can't work ->
diff --git a/arch/um/kernel/skas/exec.c b/arch/um/kernel/skas/exec.c
new file mode 100644
index 000000000000..54b795951372
--- /dev/null
+++ b/arch/um/kernel/skas/exec.c
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/kernel.h"
7#include "asm/current.h"
8#include "asm/page.h"
9#include "asm/signal.h"
10#include "asm/ptrace.h"
11#include "asm/uaccess.h"
12#include "asm/mmu_context.h"
13#include "tlb.h"
14#include "skas.h"
15#include "um_mmu.h"
16#include "os.h"
17
18void flush_thread_skas(void)
19{
20 force_flush_all();
21 switch_mm_skas(&current->mm->context.skas.id);
22}
23
24void start_thread_skas(struct pt_regs *regs, unsigned long eip,
25 unsigned long esp)
26{
27 set_fs(USER_DS);
28 PT_REGS_IP(regs) = eip;
29 PT_REGS_SP(regs) = esp;
30}
diff --git a/arch/um/kernel/skas/exec_kern.c b/arch/um/kernel/skas/exec_kern.c
deleted file mode 100644
index 77ed7bbab219..000000000000
--- a/arch/um/kernel/skas/exec_kern.c
+++ /dev/null
@@ -1,41 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/kernel.h"
7#include "asm/current.h"
8#include "asm/page.h"
9#include "asm/signal.h"
10#include "asm/ptrace.h"
11#include "asm/uaccess.h"
12#include "asm/mmu_context.h"
13#include "tlb.h"
14#include "skas.h"
15#include "um_mmu.h"
16#include "os.h"
17
18void flush_thread_skas(void)
19{
20 force_flush_all();
21 switch_mm_skas(&current->mm->context.skas.id);
22}
23
24void start_thread_skas(struct pt_regs *regs, unsigned long eip,
25 unsigned long esp)
26{
27 set_fs(USER_DS);
28 PT_REGS_IP(regs) = eip;
29 PT_REGS_SP(regs) = esp;
30}
31
32/*
33 * Overrides for Emacs so that we follow Linus's tabbing style.
34 * Emacs will notice this stuff at the end of the file and automatically
35 * adjust the settings for this buffer only. This must remain at the end
36 * of the file.
37 * ---------------------------------------------------------------------------
38 * Local variables:
39 * c-file-style: "linux"
40 * End:
41 */
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
new file mode 100644
index 000000000000..ae4fa71d3b8b
--- /dev/null
+++ b/arch/um/kernel/skas/process.c
@@ -0,0 +1,217 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/sched.h"
7#include "linux/slab.h"
8#include "linux/ptrace.h"
9#include "linux/proc_fs.h"
10#include "linux/file.h"
11#include "linux/errno.h"
12#include "linux/init.h"
13#include "asm/uaccess.h"
14#include "asm/atomic.h"
15#include "kern_util.h"
16#include "skas.h"
17#include "os.h"
18#include "user_util.h"
19#include "tlb.h"
20#include "kern.h"
21#include "mode.h"
22#include "registers.h"
23
24void switch_to_skas(void *prev, void *next)
25{
26 struct task_struct *from, *to;
27
28 from = prev;
29 to = next;
30
31 /* XXX need to check runqueues[cpu].idle */
32 if(current->pid == 0)
33 switch_timers(0);
34
35 switch_threads(&from->thread.mode.skas.switch_buf,
36 &to->thread.mode.skas.switch_buf);
37
38 arch_switch_to_skas(current->thread.prev_sched, current);
39
40 if(current->pid == 0)
41 switch_timers(1);
42}
43
44extern void schedule_tail(struct task_struct *prev);
45
46/* This is called magically, by its address being stuffed in a jmp_buf
47 * and being longjmp-d to.
48 */
49void new_thread_handler(void)
50{
51 int (*fn)(void *), n;
52 void *arg;
53
54 if(current->thread.prev_sched != NULL)
55 schedule_tail(current->thread.prev_sched);
56 current->thread.prev_sched = NULL;
57
58 fn = current->thread.request.u.thread.proc;
59 arg = current->thread.request.u.thread.arg;
60
61 /* The return value is 1 if the kernel thread execs a process,
62 * 0 if it just exits
63 */
64 n = run_kernel_thread(fn, arg, &current->thread.exec_buf);
65 if(n == 1){
66 /* Handle any immediate reschedules or signals */
67 interrupt_end();
68 userspace(&current->thread.regs.regs);
69 }
70 else do_exit(0);
71}
72
73void release_thread_skas(struct task_struct *task)
74{
75}
76
77/* Called magically, see new_thread_handler above */
78void fork_handler(void)
79{
80 force_flush_all();
81 if(current->thread.prev_sched == NULL)
82 panic("blech");
83
84 schedule_tail(current->thread.prev_sched);
85
86 /* XXX: if interrupt_end() calls schedule, this call to
87 * arch_switch_to_skas isn't needed. We could want to apply this to
88 * improve performance. -bb */
89 arch_switch_to_skas(current->thread.prev_sched, current);
90
91 current->thread.prev_sched = NULL;
92
93/* Handle any immediate reschedules or signals */
94 interrupt_end();
95
96 userspace(&current->thread.regs.regs);
97}
98
99int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
100 unsigned long stack_top, struct task_struct * p,
101 struct pt_regs *regs)
102{
103 void (*handler)(void);
104
105 if(current->thread.forking){
106 memcpy(&p->thread.regs.regs.skas, &regs->regs.skas,
107 sizeof(p->thread.regs.regs.skas));
108 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0);
109 if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
110
111 handler = fork_handler;
112
113 arch_copy_thread(&current->thread.arch, &p->thread.arch);
114 }
115 else {
116 init_thread_registers(&p->thread.regs.regs);
117 p->thread.request.u.thread = current->thread.request.u.thread;
118 handler = new_thread_handler;
119 }
120
121 new_thread(task_stack_page(p), &p->thread.mode.skas.switch_buf,
122 handler);
123 return(0);
124}
125
126int new_mm(unsigned long stack)
127{
128 int fd;
129
130 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
131 if(fd < 0)
132 return(fd);
133
134 if(skas_needs_stub)
135 map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack);
136
137 return(fd);
138}
139
140void init_idle_skas(void)
141{
142 cpu_tasks[current_thread->cpu].pid = os_getpid();
143 default_idle();
144}
145
146extern void start_kernel(void);
147
148static int start_kernel_proc(void *unused)
149{
150 int pid;
151
152 block_signals();
153 pid = os_getpid();
154
155 cpu_tasks[0].pid = pid;
156 cpu_tasks[0].task = current;
157#ifdef CONFIG_SMP
158 cpu_online_map = cpumask_of_cpu(0);
159#endif
160 start_kernel();
161 return(0);
162}
163
164extern int userspace_pid[];
165
166int start_uml_skas(void)
167{
168 if(proc_mm)
169 userspace_pid[0] = start_userspace(0);
170
171 init_new_thread_signals();
172
173 init_task.thread.request.u.thread.proc = start_kernel_proc;
174 init_task.thread.request.u.thread.arg = NULL;
175 return(start_idle_thread(task_stack_page(&init_task),
176 &init_task.thread.mode.skas.switch_buf));
177}
178
179int external_pid_skas(struct task_struct *task)
180{
181#warning Need to look up userspace_pid by cpu
182 return(userspace_pid[0]);
183}
184
185int thread_pid_skas(struct task_struct *task)
186{
187#warning Need to look up userspace_pid by cpu
188 return(userspace_pid[0]);
189}
190
191void kill_off_processes_skas(void)
192{
193 if(proc_mm)
194#warning need to loop over userspace_pids in kill_off_processes_skas
195 os_kill_ptraced_process(userspace_pid[0], 1);
196 else {
197 struct task_struct *p;
198 int pid, me;
199
200 me = os_getpid();
201 for_each_process(p){
202 if(p->mm == NULL)
203 continue;
204
205 pid = p->mm->context.skas.id.u.pid;
206 os_kill_ptraced_process(pid, 1);
207 }
208 }
209}
210
211unsigned long current_stub_stack(void)
212{
213 if(current->mm == NULL)
214 return(0);
215
216 return(current->mm->context.skas.id.stack);
217}
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index 55caeec8b257..0f3d5d084dc7 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -1,227 +1,484 @@
1/* 1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Copyright 2003 PathScale, Inc.
3 * Licensed under the GPL 4 * Licensed under the GPL
4 */ 5 */
5 6
7#include "linux/config.h"
8#include "linux/kernel.h"
6#include "linux/sched.h" 9#include "linux/sched.h"
10#include "linux/interrupt.h"
11#include "linux/string.h"
12#include "linux/mm.h"
7#include "linux/slab.h" 13#include "linux/slab.h"
8#include "linux/ptrace.h" 14#include "linux/utsname.h"
9#include "linux/proc_fs.h" 15#include "linux/fs.h"
10#include "linux/file.h" 16#include "linux/utime.h"
11#include "linux/errno.h" 17#include "linux/smp_lock.h"
18#include "linux/module.h"
12#include "linux/init.h" 19#include "linux/init.h"
20#include "linux/capability.h"
21#include "linux/vmalloc.h"
22#include "linux/spinlock.h"
23#include "linux/proc_fs.h"
24#include "linux/ptrace.h"
25#include "linux/random.h"
26#include "linux/personality.h"
27#include "asm/unistd.h"
28#include "asm/mman.h"
29#include "asm/segment.h"
30#include "asm/stat.h"
31#include "asm/pgtable.h"
32#include "asm/processor.h"
33#include "asm/tlbflush.h"
13#include "asm/uaccess.h" 34#include "asm/uaccess.h"
14#include "asm/atomic.h" 35#include "asm/user.h"
15#include "kern_util.h"
16#include "skas.h"
17#include "os.h"
18#include "user_util.h" 36#include "user_util.h"
19#include "tlb.h" 37#include "kern_util.h"
20#include "kern.h" 38#include "kern.h"
39#include "signal_kern.h"
40#include "init.h"
41#include "irq_user.h"
42#include "mem_user.h"
43#include "tlb.h"
44#include "frame_kern.h"
45#include "sigcontext.h"
46#include "os.h"
21#include "mode.h" 47#include "mode.h"
22#include "registers.h" 48#include "mode_kern.h"
49#include "choose-mode.h"
50
51/* This is a per-cpu array. A processor only modifies its entry and it only
52 * cares about its entry, so it's OK if another processor is modifying its
53 * entry.
54 */
55struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
56
57int external_pid(void *t)
58{
59 struct task_struct *task = t ? t : current;
60
61 return(CHOOSE_MODE_PROC(external_pid_tt, external_pid_skas, task));
62}
63
64int pid_to_processor_id(int pid)
65{
66 int i;
67
68 for(i = 0; i < ncpus; i++){
69 if(cpu_tasks[i].pid == pid) return(i);
70 }
71 return(-1);
72}
73
74void free_stack(unsigned long stack, int order)
75{
76 free_pages(stack, order);
77}
78
79unsigned long alloc_stack(int order, int atomic)
80{
81 unsigned long page;
82 gfp_t flags = GFP_KERNEL;
83
84 if (atomic)
85 flags = GFP_ATOMIC;
86 page = __get_free_pages(flags, order);
87 if(page == 0)
88 return(0);
89 stack_protections(page);
90 return(page);
91}
92
93int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
94{
95 int pid;
96
97 current->thread.request.u.thread.proc = fn;
98 current->thread.request.u.thread.arg = arg;
99 pid = do_fork(CLONE_VM | CLONE_UNTRACED | flags, 0,
100 &current->thread.regs, 0, NULL, NULL);
101 if(pid < 0)
102 panic("do_fork failed in kernel_thread, errno = %d", pid);
103 return(pid);
104}
23 105
24void switch_to_skas(void *prev, void *next) 106void set_current(void *t)
25{ 107{
26 struct task_struct *from, *to; 108 struct task_struct *task = t;
27 109
28 from = prev; 110 cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task)
29 to = next; 111 { external_pid(task), task });
112}
30 113
31 /* XXX need to check runqueues[cpu].idle */ 114void *_switch_to(void *prev, void *next, void *last)
32 if(current->pid == 0) 115{
33 switch_timers(0); 116 struct task_struct *from = prev;
117 struct task_struct *to= next;
34 118
35 switch_threads(&from->thread.mode.skas.switch_buf, 119 to->thread.prev_sched = from;
36 to->thread.mode.skas.switch_buf); 120 set_current(to);
37 121
38 arch_switch_to_skas(current->thread.prev_sched, current); 122 do {
123 current->thread.saved_task = NULL ;
124 CHOOSE_MODE_PROC(switch_to_tt, switch_to_skas, prev, next);
125 if(current->thread.saved_task)
126 show_regs(&(current->thread.regs));
127 next= current->thread.saved_task;
128 prev= current;
129 } while(current->thread.saved_task);
130
131 return(current->thread.prev_sched);
39 132
40 if(current->pid == 0)
41 switch_timers(1);
42} 133}
43 134
44extern void schedule_tail(struct task_struct *prev); 135void interrupt_end(void)
136{
137 if(need_resched()) schedule();
138 if(test_tsk_thread_flag(current, TIF_SIGPENDING)) do_signal();
139}
45 140
46void new_thread_handler(int sig) 141void release_thread(struct task_struct *task)
47{ 142{
48 int (*fn)(void *), n; 143 CHOOSE_MODE(release_thread_tt(task), release_thread_skas(task));
49 void *arg; 144}
50 145
51 fn = current->thread.request.u.thread.proc; 146void exit_thread(void)
52 arg = current->thread.request.u.thread.arg; 147{
53 os_usr1_signal(1); 148 unprotect_stack((unsigned long) current_thread);
54 thread_wait(&current->thread.mode.skas.switch_buf, 149}
55 current->thread.mode.skas.fork_buf);
56 150
57 if(current->thread.prev_sched != NULL) 151void *get_current(void)
58 schedule_tail(current->thread.prev_sched); 152{
59 current->thread.prev_sched = NULL; 153 return(current);
154}
155
156int copy_thread(int nr, unsigned long clone_flags, unsigned long sp,
157 unsigned long stack_top, struct task_struct * p,
158 struct pt_regs *regs)
159{
160 int ret;
60 161
61 /* The return value is 1 if the kernel thread execs a process, 162 p->thread = (struct thread_struct) INIT_THREAD;
62 * 0 if it just exits 163 ret = CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr,
164 clone_flags, sp, stack_top, p, regs);
165
166 if (ret || !current->thread.forking)
167 goto out;
168
169 clear_flushed_tls(p);
170
171 /*
172 * Set a new TLS for the child thread?
63 */ 173 */
64 n = run_kernel_thread(fn, arg, &current->thread.exec_buf); 174 if (clone_flags & CLONE_SETTLS)
65 if(n == 1){ 175 ret = arch_copy_tls(p);
66 /* Handle any immediate reschedules or signals */ 176
67 interrupt_end(); 177out:
68 userspace(&current->thread.regs.regs); 178 return ret;
179}
180
181void initial_thread_cb(void (*proc)(void *), void *arg)
182{
183 int save_kmalloc_ok = kmalloc_ok;
184
185 kmalloc_ok = 0;
186 CHOOSE_MODE_PROC(initial_thread_cb_tt, initial_thread_cb_skas, proc,
187 arg);
188 kmalloc_ok = save_kmalloc_ok;
189}
190
191unsigned long stack_sp(unsigned long page)
192{
193 return(page + PAGE_SIZE - sizeof(void *));
194}
195
196int current_pid(void)
197{
198 return(current->pid);
199}
200
201void default_idle(void)
202{
203 CHOOSE_MODE(uml_idle_timer(), (void) 0);
204
205 while(1){
206 /* endless idle loop with no priority at all */
207
208 /*
209 * although we are an idle CPU, we do not want to
210 * get into the scheduler unnecessarily.
211 */
212 if(need_resched())
213 schedule();
214
215 idle_sleep(10);
69 } 216 }
70 else do_exit(0);
71} 217}
72 218
73void new_thread_proc(void *stack, void (*handler)(int sig)) 219void cpu_idle(void)
74{ 220{
75 init_new_thread_stack(stack, handler); 221 CHOOSE_MODE(init_idle_tt(), init_idle_skas());
76 os_usr1_process(os_getpid());
77} 222}
78 223
79void release_thread_skas(struct task_struct *task) 224int page_size(void)
80{ 225{
226 return(PAGE_SIZE);
81} 227}
82 228
83void fork_handler(int sig) 229void *um_virt_to_phys(struct task_struct *task, unsigned long addr,
230 pte_t *pte_out)
84{ 231{
85 os_usr1_signal(1); 232 pgd_t *pgd;
86 thread_wait(&current->thread.mode.skas.switch_buf, 233 pud_t *pud;
87 current->thread.mode.skas.fork_buf); 234 pmd_t *pmd;
88 235 pte_t *pte;
89 force_flush_all(); 236 pte_t ptent;
90 if(current->thread.prev_sched == NULL) 237
91 panic("blech"); 238 if(task->mm == NULL)
239 return(ERR_PTR(-EINVAL));
240 pgd = pgd_offset(task->mm, addr);
241 if(!pgd_present(*pgd))
242 return(ERR_PTR(-EINVAL));
243
244 pud = pud_offset(pgd, addr);
245 if(!pud_present(*pud))
246 return(ERR_PTR(-EINVAL));
247
248 pmd = pmd_offset(pud, addr);
249 if(!pmd_present(*pmd))
250 return(ERR_PTR(-EINVAL));
251
252 pte = pte_offset_kernel(pmd, addr);
253 ptent = *pte;
254 if(!pte_present(ptent))
255 return(ERR_PTR(-EINVAL));
256
257 if(pte_out != NULL)
258 *pte_out = ptent;
259 return((void *) (pte_val(ptent) & PAGE_MASK) + (addr & ~PAGE_MASK));
260}
92 261
93 schedule_tail(current->thread.prev_sched); 262char *current_cmd(void)
263{
264#if defined(CONFIG_SMP) || defined(CONFIG_HIGHMEM)
265 return("(Unknown)");
266#else
267 void *addr = um_virt_to_phys(current, current->mm->arg_start, NULL);
268 return IS_ERR(addr) ? "(Unknown)": __va((unsigned long) addr);
269#endif
270}
94 271
95 /* XXX: if interrupt_end() calls schedule, this call to 272void force_sigbus(void)
96 * arch_switch_to_skas isn't needed. We could want to apply this to 273{
97 * improve performance. -bb */ 274 printk(KERN_ERR "Killing pid %d because of a lack of memory\n",
98 arch_switch_to_skas(current->thread.prev_sched, current); 275 current->pid);
276 lock_kernel();
277 sigaddset(&current->pending.signal, SIGBUS);
278 recalc_sigpending();
279 current->flags |= PF_SIGNALED;
280 do_exit(SIGBUS | 0x80);
281}
99 282
100 current->thread.prev_sched = NULL; 283void dump_thread(struct pt_regs *regs, struct user *u)
284{
285}
101 286
102/* Handle any immediate reschedules or signals */ 287void enable_hlt(void)
103 interrupt_end(); 288{
289 panic("enable_hlt");
290}
291
292EXPORT_SYMBOL(enable_hlt);
104 293
105 userspace(&current->thread.regs.regs); 294void disable_hlt(void)
295{
296 panic("disable_hlt");
106} 297}
107 298
108int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp, 299EXPORT_SYMBOL(disable_hlt);
109 unsigned long stack_top, struct task_struct * p, 300
110 struct pt_regs *regs) 301void *um_kmalloc(int size)
111{ 302{
112 void (*handler)(int); 303 return kmalloc(size, GFP_KERNEL);
304}
113 305
114 if(current->thread.forking){ 306void *um_kmalloc_atomic(int size)
115 memcpy(&p->thread.regs.regs.skas, &regs->regs.skas, 307{
116 sizeof(p->thread.regs.regs.skas)); 308 return kmalloc(size, GFP_ATOMIC);
117 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.skas.regs, 0); 309}
118 if(sp != 0) REGS_SP(p->thread.regs.regs.skas.regs) = sp;
119 310
120 handler = fork_handler; 311void *um_vmalloc(int size)
312{
313 return vmalloc(size);
314}
121 315
122 arch_copy_thread(&current->thread.arch, &p->thread.arch); 316void *um_vmalloc_atomic(int size)
123 } 317{
124 else { 318 return __vmalloc(size, GFP_ATOMIC | __GFP_HIGHMEM, PAGE_KERNEL);
125 init_thread_registers(&p->thread.regs.regs); 319}
126 p->thread.request.u.thread = current->thread.request.u.thread;
127 handler = new_thread_handler;
128 }
129 320
130 new_thread(task_stack_page(p), &p->thread.mode.skas.switch_buf, 321int __cant_sleep(void) {
131 &p->thread.mode.skas.fork_buf, handler); 322 return in_atomic() || irqs_disabled() || in_interrupt();
132 return(0); 323 /* Is in_interrupt() really needed? */
324}
325
326unsigned long get_fault_addr(void)
327{
328 return((unsigned long) current->thread.fault_addr);
133} 329}
134 330
135int new_mm(unsigned long stack) 331EXPORT_SYMBOL(get_fault_addr);
332
333void not_implemented(void)
136{ 334{
137 int fd; 335 printk(KERN_DEBUG "Something isn't implemented in here\n");
336}
138 337
139 fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0); 338EXPORT_SYMBOL(not_implemented);
140 if(fd < 0)
141 return(fd);
142 339
143 if(skas_needs_stub) 340int user_context(unsigned long sp)
144 map_stub_pages(fd, CONFIG_STUB_CODE, CONFIG_STUB_DATA, stack); 341{
342 unsigned long stack;
145 343
146 return(fd); 344 stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
345 return(stack != (unsigned long) current_thread);
147} 346}
148 347
149void init_idle_skas(void) 348extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end;
349
350void do_uml_exitcalls(void)
150{ 351{
151 cpu_tasks[current_thread->cpu].pid = os_getpid(); 352 exitcall_t *call;
152 default_idle(); 353
354 call = &__uml_exitcall_end;
355 while (--call >= &__uml_exitcall_begin)
356 (*call)();
153} 357}
154 358
155extern void start_kernel(void); 359char *uml_strdup(char *string)
360{
361 return kstrdup(string, GFP_KERNEL);
362}
156 363
157static int start_kernel_proc(void *unused) 364int copy_to_user_proc(void __user *to, void *from, int size)
158{ 365{
159 int pid; 366 return(copy_to_user(to, from, size));
367}
368
369int copy_from_user_proc(void *to, void __user *from, int size)
370{
371 return(copy_from_user(to, from, size));
372}
373
374int clear_user_proc(void __user *buf, int size)
375{
376 return(clear_user(buf, size));
377}
160 378
161 block_signals(); 379int strlen_user_proc(char __user *str)
162 pid = os_getpid(); 380{
381 return(strlen_user(str));
382}
163 383
164 cpu_tasks[0].pid = pid; 384int smp_sigio_handler(void)
165 cpu_tasks[0].task = current; 385{
166#ifdef CONFIG_SMP 386#ifdef CONFIG_SMP
167 cpu_online_map = cpumask_of_cpu(0); 387 int cpu = current_thread->cpu;
388 IPI_handler(cpu);
389 if(cpu != 0)
390 return(1);
168#endif 391#endif
169 start_kernel();
170 return(0); 392 return(0);
171} 393}
172 394
173extern int userspace_pid[]; 395int cpu(void)
174
175int start_uml_skas(void)
176{ 396{
177 if(proc_mm) 397 return(current_thread->cpu);
178 userspace_pid[0] = start_userspace(0); 398}
399
400static atomic_t using_sysemu = ATOMIC_INIT(0);
401int sysemu_supported;
179 402
180 init_new_thread_signals(); 403void set_using_sysemu(int value)
404{
405 if (value > sysemu_supported)
406 return;
407 atomic_set(&using_sysemu, value);
408}
181 409
182 init_task.thread.request.u.thread.proc = start_kernel_proc; 410int get_using_sysemu(void)
183 init_task.thread.request.u.thread.arg = NULL; 411{
184 return(start_idle_thread(task_stack_page(&init_task), 412 return atomic_read(&using_sysemu);
185 &init_task.thread.mode.skas.switch_buf,
186 &init_task.thread.mode.skas.fork_buf));
187} 413}
188 414
189int external_pid_skas(struct task_struct *task) 415static int proc_read_sysemu(char *buf, char **start, off_t offset, int size,int *eof, void *data)
190{ 416{
191#warning Need to look up userspace_pid by cpu 417 if (snprintf(buf, size, "%d\n", get_using_sysemu()) < size) /*No overflow*/
192 return(userspace_pid[0]); 418 *eof = 1;
419
420 return strlen(buf);
193} 421}
194 422
195int thread_pid_skas(struct task_struct *task) 423static int proc_write_sysemu(struct file *file,const char __user *buf, unsigned long count,void *data)
196{ 424{
197#warning Need to look up userspace_pid by cpu 425 char tmp[2];
198 return(userspace_pid[0]); 426
427 if (copy_from_user(tmp, buf, 1))
428 return -EFAULT;
429
430 if (tmp[0] >= '0' && tmp[0] <= '2')
431 set_using_sysemu(tmp[0] - '0');
432 return count; /*We use the first char, but pretend to write everything*/
199} 433}
200 434
201void kill_off_processes_skas(void) 435int __init make_proc_sysemu(void)
202{ 436{
203 if(proc_mm) 437 struct proc_dir_entry *ent;
204#warning need to loop over userspace_pids in kill_off_processes_skas 438 if (!sysemu_supported)
205 os_kill_ptraced_process(userspace_pid[0], 1); 439 return 0;
206 else {
207 struct task_struct *p;
208 int pid, me;
209 440
210 me = os_getpid(); 441 ent = create_proc_entry("sysemu", 0600, &proc_root);
211 for_each_process(p){
212 if(p->mm == NULL)
213 continue;
214 442
215 pid = p->mm->context.skas.id.u.pid; 443 if (ent == NULL)
216 os_kill_ptraced_process(pid, 1); 444 {
217 } 445 printk(KERN_WARNING "Failed to register /proc/sysemu\n");
446 return(0);
218 } 447 }
448
449 ent->read_proc = proc_read_sysemu;
450 ent->write_proc = proc_write_sysemu;
451
452 return 0;
219} 453}
220 454
221unsigned long current_stub_stack(void) 455late_initcall(make_proc_sysemu);
456
457int singlestepping(void * t)
222{ 458{
223 if(current->mm == NULL) 459 struct task_struct *task = t ? t : current;
460
461 if ( ! (task->ptrace & PT_DTRACE) )
224 return(0); 462 return(0);
225 463
226 return(current->mm->context.skas.id.stack); 464 if (task->thread.singlestep_syscall)
465 return(1);
466
467 return 2;
468}
469
470/*
471 * Only x86 and x86_64 have an arch_align_stack().
472 * All other arches have "#define arch_align_stack(x) (x)"
473 * in their asm/system.h
474 * As this is included in UML from asm-um/system-generic.h,
475 * we can use it to behave as the subarch does.
476 */
477#ifndef arch_align_stack
478unsigned long arch_align_stack(unsigned long sp)
479{
480 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
481 sp -= get_random_int() % 8192;
482 return sp & ~0xf;
227} 483}
484#endif
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 2454bbd9555d..820affbf3e16 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -95,7 +95,7 @@ irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
95 95
96 do_timer(regs); 96 do_timer(regs);
97 97
98 nsecs = get_time() + local_offset; 98 nsecs = get_time();
99 xtime.tv_sec = nsecs / NSEC_PER_SEC; 99 xtime.tv_sec = nsecs / NSEC_PER_SEC;
100 xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC; 100 xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
101 101
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index e5eeaf2b6af1..61a23fff4395 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -140,14 +140,6 @@ void segv_handler(int sig, union uml_pt_regs *regs)
140 segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs); 140 segv(*fi, UPT_IP(regs), UPT_IS_USER(regs), regs);
141} 141}
142 142
143struct kern_handlers handlinfo_kern = {
144 .relay_signal = relay_signal,
145 .winch = winch,
146 .bus_handler = relay_signal,
147 .page_fault = segv_handler,
148 .sigio_handler = sigio_handler,
149 .timer_handler = timer_handler
150};
151/* 143/*
152 * We give a *copy* of the faultinfo in the regs to segv. 144 * We give a *copy* of the faultinfo in the regs to segv.
153 * This must be done, since nesting SEGVs could overwrite 145 * This must be done, since nesting SEGVs could overwrite
@@ -253,6 +245,15 @@ void winch(int sig, union uml_pt_regs *regs)
253 do_IRQ(WINCH_IRQ, regs); 245 do_IRQ(WINCH_IRQ, regs);
254} 246}
255 247
248const struct kern_handlers handlinfo_kern = {
249 .relay_signal = relay_signal,
250 .winch = winch,
251 .bus_handler = bus_handler,
252 .page_fault = segv_handler,
253 .sigio_handler = sigio_handler,
254 .timer_handler = timer_handler
255};
256
256void trap_init(void) 257void trap_init(void)
257{ 258{
258} 259}
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 7896cf98232d..55005710dcbb 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -106,7 +106,7 @@ static void c_stop(struct seq_file *m, void *v)
106{ 106{
107} 107}
108 108
109struct seq_operations cpuinfo_op = { 109const struct seq_operations cpuinfo_op = {
110 .start = c_start, 110 .start = c_start,
111 .next = c_next, 111 .next = c_next,
112 .stop = c_stop, 112 .stop = c_stop,
diff --git a/arch/um/os-Linux/Makefile b/arch/um/os-Linux/Makefile
index f4bfc4c7ccac..b4183929b32c 100644
--- a/arch/um/os-Linux/Makefile
+++ b/arch/um/os-Linux/Makefile
@@ -4,15 +4,19 @@
4# 4#
5 5
6obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o \ 6obj-y = aio.o elf_aux.o file.o helper.o irq.o main.o mem.o process.o sigio.o \
7 signal.o start_up.o time.o trap.o tt.o tty.o uaccess.o umid.o tls.o \ 7 signal.o start_up.o time.o trap.o tty.o uaccess.o umid.o tls.o \
8 user_syms.o util.o drivers/ sys-$(SUBARCH)/ 8 user_syms.o util.o drivers/ sys-$(SUBARCH)/
9 9
10obj-$(CONFIG_MODE_SKAS) += skas/ 10obj-$(CONFIG_MODE_SKAS) += skas/
11
12obj-$(CONFIG_MODE_TT) += tt.o
13user-objs-$(CONFIG_MODE_TT) += tt.o
14
11obj-$(CONFIG_TTY_LOG) += tty_log.o 15obj-$(CONFIG_TTY_LOG) += tty_log.o
12user-objs-$(CONFIG_TTY_LOG) += tty_log.o 16user-objs-$(CONFIG_TTY_LOG) += tty_log.o
13 17
14USER_OBJS := $(user-objs-y) aio.o elf_aux.o file.o helper.o irq.o main.o mem.o \ 18USER_OBJS := $(user-objs-y) aio.o elf_aux.o file.o helper.o irq.o main.o mem.o \
15 process.o sigio.o signal.o start_up.o time.o trap.o tt.o tty.o tls.o \ 19 process.o sigio.o signal.o start_up.o time.o trap.o tty.o tls.o \
16 uaccess.o umid.o util.o 20 uaccess.o umid.o util.o
17 21
18CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) 22CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH)
diff --git a/arch/um/os-Linux/drivers/etap.h b/arch/um/os-Linux/drivers/etap.h
index b84f6c4740f7..57ecdaf2f67e 100644
--- a/arch/um/os-Linux/drivers/etap.h
+++ b/arch/um/os-Linux/drivers/etap.h
@@ -13,7 +13,7 @@ struct ethertap_data {
13 void *dev; 13 void *dev;
14}; 14};
15 15
16extern struct net_user_info ethertap_user_info; 16extern const struct net_user_info ethertap_user_info;
17 17
18/* 18/*
19 * Overrides for Emacs so that we follow Linus's tabbing style. 19 * Overrides for Emacs so that we follow Linus's tabbing style.
diff --git a/arch/um/os-Linux/drivers/ethertap_kern.c b/arch/um/os-Linux/drivers/ethertap_kern.c
index 768606bec233..16385e2ada85 100644
--- a/arch/um/os-Linux/drivers/ethertap_kern.c
+++ b/arch/um/os-Linux/drivers/ethertap_kern.c
@@ -65,7 +65,7 @@ static int etap_write(int fd, struct sk_buff **skb, struct uml_net_private *lp)
65 return(net_send(fd, (*skb)->data, (*skb)->len)); 65 return(net_send(fd, (*skb)->data, (*skb)->len));
66} 66}
67 67
68struct net_kern_info ethertap_kern_info = { 68const struct net_kern_info ethertap_kern_info = {
69 .init = etap_init, 69 .init = etap_init,
70 .protocol = eth_protocol, 70 .protocol = eth_protocol,
71 .read = etap_read, 71 .read = etap_read,
diff --git a/arch/um/os-Linux/drivers/ethertap_user.c b/arch/um/os-Linux/drivers/ethertap_user.c
index 8f49507e64ef..f559bdf746e6 100644
--- a/arch/um/os-Linux/drivers/ethertap_user.c
+++ b/arch/um/os-Linux/drivers/ethertap_user.c
@@ -216,7 +216,7 @@ static void etap_del_addr(unsigned char *addr, unsigned char *netmask,
216 etap_close_addr(addr, netmask, &pri->control_fd); 216 etap_close_addr(addr, netmask, &pri->control_fd);
217} 217}
218 218
219struct net_user_info ethertap_user_info = { 219const struct net_user_info ethertap_user_info = {
220 .init = etap_user_init, 220 .init = etap_user_init,
221 .open = etap_open, 221 .open = etap_open,
222 .close = etap_close, 222 .close = etap_close,
diff --git a/arch/um/os-Linux/drivers/tuntap.h b/arch/um/os-Linux/drivers/tuntap.h
index 25d4a2868814..d3e8d3af6245 100644
--- a/arch/um/os-Linux/drivers/tuntap.h
+++ b/arch/um/os-Linux/drivers/tuntap.h
@@ -16,7 +16,7 @@ struct tuntap_data {
16 void *dev; 16 void *dev;
17}; 17};
18 18
19extern struct net_user_info tuntap_user_info; 19extern const struct net_user_info tuntap_user_info;
20 20
21#endif 21#endif
22 22
diff --git a/arch/um/os-Linux/drivers/tuntap_kern.c b/arch/um/os-Linux/drivers/tuntap_kern.c
index 190009a6f89c..0edbac63c527 100644
--- a/arch/um/os-Linux/drivers/tuntap_kern.c
+++ b/arch/um/os-Linux/drivers/tuntap_kern.c
@@ -53,7 +53,7 @@ static int tuntap_write(int fd, struct sk_buff **skb,
53 return(net_write(fd, (*skb)->data, (*skb)->len)); 53 return(net_write(fd, (*skb)->data, (*skb)->len));
54} 54}
55 55
56struct net_kern_info tuntap_kern_info = { 56const struct net_kern_info tuntap_kern_info = {
57 .init = tuntap_init, 57 .init = tuntap_init,
58 .protocol = eth_protocol, 58 .protocol = eth_protocol,
59 .read = tuntap_read, 59 .read = tuntap_read,
diff --git a/arch/um/os-Linux/drivers/tuntap_user.c b/arch/um/os-Linux/drivers/tuntap_user.c
index 87c3aa0252db..e846b23f7558 100644
--- a/arch/um/os-Linux/drivers/tuntap_user.c
+++ b/arch/um/os-Linux/drivers/tuntap_user.c
@@ -205,7 +205,7 @@ static int tuntap_set_mtu(int mtu, void *data)
205 return(mtu); 205 return(mtu);
206} 206}
207 207
208struct net_user_info tuntap_user_info = { 208const struct net_user_info tuntap_user_info = {
209 .init = tuntap_user_init, 209 .init = tuntap_user_init,
210 .open = tuntap_open, 210 .open = tuntap_open,
211 .close = tuntap_close, 211 .close = tuntap_close,
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 42e3d1ed802c..cb9ab54146cc 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -444,56 +444,22 @@ void map_stub_pages(int fd, unsigned long code,
444 } 444 }
445} 445}
446 446
447void new_thread(void *stack, void **switch_buf_ptr, void **fork_buf_ptr, 447void new_thread(void *stack, jmp_buf *buf, void (*handler)(void))
448 void (*handler)(int))
449{ 448{
450 unsigned long flags; 449 (*buf)[0].JB_IP = (unsigned long) handler;
451 jmp_buf switch_buf, fork_buf; 450 (*buf)[0].JB_SP = (unsigned long) stack +
452 451 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) - sizeof(void *);
453 *switch_buf_ptr = &switch_buf;
454 *fork_buf_ptr = &fork_buf;
455
456 /* Somewhat subtle - siglongjmp restores the signal mask before doing
457 * the longjmp. This means that when jumping from one stack to another
458 * when the target stack has interrupts enabled, an interrupt may occur
459 * on the source stack. This is bad when starting up a process because
460 * it's not supposed to get timer ticks until it has been scheduled.
461 * So, we disable interrupts around the sigsetjmp to ensure that
462 * they can't happen until we get back here where they are safe.
463 */
464 flags = get_signals();
465 block_signals();
466 if(UML_SETJMP(&fork_buf) == 0)
467 new_thread_proc(stack, handler);
468
469 remove_sigstack();
470
471 set_signals(flags);
472} 452}
473 453
474#define INIT_JMP_NEW_THREAD 0 454#define INIT_JMP_NEW_THREAD 0
475#define INIT_JMP_REMOVE_SIGSTACK 1 455#define INIT_JMP_CALLBACK 1
476#define INIT_JMP_CALLBACK 2 456#define INIT_JMP_HALT 2
477#define INIT_JMP_HALT 3 457#define INIT_JMP_REBOOT 3
478#define INIT_JMP_REBOOT 4
479
480void thread_wait(void *sw, void *fb)
481{
482 jmp_buf buf, **switch_buf = sw, *fork_buf;
483
484 *switch_buf = &buf;
485 fork_buf = fb;
486 if(UML_SETJMP(&buf) == 0)
487 UML_LONGJMP(fork_buf, INIT_JMP_REMOVE_SIGSTACK);
488}
489 458
490void switch_threads(void *me, void *next) 459void switch_threads(jmp_buf *me, jmp_buf *you)
491{ 460{
492 jmp_buf my_buf, **me_ptr = me, *next_buf = next; 461 if(UML_SETJMP(me) == 0)
493 462 UML_LONGJMP(you, 1);
494 *me_ptr = &my_buf;
495 if(UML_SETJMP(&my_buf) == 0)
496 UML_LONGJMP(next_buf, 1);
497} 463}
498 464
499static jmp_buf initial_jmpbuf; 465static jmp_buf initial_jmpbuf;
@@ -503,23 +469,21 @@ static void (*cb_proc)(void *arg);
503static void *cb_arg; 469static void *cb_arg;
504static jmp_buf *cb_back; 470static jmp_buf *cb_back;
505 471
506int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) 472int start_idle_thread(void *stack, jmp_buf *switch_buf)
507{ 473{
508 jmp_buf **switch_buf = switch_buf_ptr;
509 int n; 474 int n;
510 475
511 set_handler(SIGWINCH, (__sighandler_t) sig_handler, 476 set_handler(SIGWINCH, (__sighandler_t) sig_handler,
512 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM, 477 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGALRM,
513 SIGVTALRM, -1); 478 SIGVTALRM, -1);
514 479
515 *fork_buf_ptr = &initial_jmpbuf;
516 n = UML_SETJMP(&initial_jmpbuf); 480 n = UML_SETJMP(&initial_jmpbuf);
517 switch(n){ 481 switch(n){
518 case INIT_JMP_NEW_THREAD: 482 case INIT_JMP_NEW_THREAD:
519 new_thread_proc((void *) stack, new_thread_handler); 483 (*switch_buf)[0].JB_IP = (unsigned long) new_thread_handler;
520 break; 484 (*switch_buf)[0].JB_SP = (unsigned long) stack +
521 case INIT_JMP_REMOVE_SIGSTACK: 485 (PAGE_SIZE << UML_CONFIG_KERNEL_STACK_ORDER) -
522 remove_sigstack(); 486 sizeof(void *);
523 break; 487 break;
524 case INIT_JMP_CALLBACK: 488 case INIT_JMP_CALLBACK:
525 (*cb_proc)(cb_arg); 489 (*cb_proc)(cb_arg);
@@ -534,7 +498,7 @@ int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr)
534 default: 498 default:
535 panic("Bad sigsetjmp return in start_idle_thread - %d\n", n); 499 panic("Bad sigsetjmp return in start_idle_thread - %d\n", n);
536 } 500 }
537 UML_LONGJMP(*switch_buf, 1); 501 UML_LONGJMP(switch_buf, 1);
538} 502}
539 503
540void initial_thread_cb_skas(void (*proc)(void *), void *arg) 504void initial_thread_cb_skas(void (*proc)(void *), void *arg)
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index 59cc70275754..0e32adf03be1 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -4,7 +4,7 @@ obj-y = bugs.o checksum.o delay.o fault.o ksyms.o ldt.o ptrace.o \
4 4
5obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o 5obj-$(CONFIG_MODE_SKAS) += stub.o stub_segv.o
6 6
7subarch-obj-y = lib/bitops.o kernel/semaphore.o 7subarch-obj-y = lib/bitops.o lib/semaphore.o
8subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o 8subarch-obj-$(CONFIG_HIGHMEM) += mm/highmem.o
9subarch-obj-$(CONFIG_MODULES) += kernel/module.o 9subarch-obj-$(CONFIG_MODULES) += kernel/module.o
10 10
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 581ce9af0ec8..32ae1378f35c 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -85,6 +85,9 @@ config ARCH_MAY_HAVE_PC_FDC
85 bool 85 bool
86 default y 86 default y
87 87
88config ARCH_POPULATES_NODE_MAP
89 def_bool y
90
88config DMI 91config DMI
89 bool 92 bool
90 default y 93 default y
@@ -109,6 +112,7 @@ config X86_PC
109 112
110config X86_VSMP 113config X86_VSMP
111 bool "Support for ScaleMP vSMP" 114 bool "Support for ScaleMP vSMP"
115 depends on PCI
112 help 116 help
113 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is 117 Support for ScaleMP vSMP systems. Say 'Y' here if this kernel is
114 supposed to run on these EM64T-based machines. Only choose this option 118 supposed to run on these EM64T-based machines. Only choose this option
@@ -167,6 +171,7 @@ config X86_GOOD_APIC
167 171
168config MICROCODE 172config MICROCODE
169 tristate "/dev/cpu/microcode - Intel CPU microcode support" 173 tristate "/dev/cpu/microcode - Intel CPU microcode support"
174 select FW_LOADER
170 ---help--- 175 ---help---
171 If you say Y here the 'File systems' section, you will be 176 If you say Y here the 'File systems' section, you will be
172 able to update the microcode on Intel processors. You will 177 able to update the microcode on Intel processors. You will
@@ -182,6 +187,11 @@ config MICROCODE
182 If you use modprobe or kmod you may also want to add the line 187 If you use modprobe or kmod you may also want to add the line
183 'alias char-major-10-184 microcode' to your /etc/modules.conf file. 188 'alias char-major-10-184 microcode' to your /etc/modules.conf file.
184 189
190config MICROCODE_OLD_INTERFACE
191 bool
192 depends on MICROCODE
193 default y
194
185config X86_MSR 195config X86_MSR
186 tristate "/dev/cpu/*/msr - Model-specific register support" 196 tristate "/dev/cpu/*/msr - Model-specific register support"
187 help 197 help
@@ -295,7 +305,7 @@ config NUMA
295 305
296config K8_NUMA 306config K8_NUMA
297 bool "Old style AMD Opteron NUMA detection" 307 bool "Old style AMD Opteron NUMA detection"
298 depends on NUMA 308 depends on NUMA && PCI
299 default y 309 default y
300 help 310 help
301 Enable K8 NUMA node topology detection. You should say Y here if 311 Enable K8 NUMA node topology detection. You should say Y here if
@@ -425,7 +435,6 @@ config IOMMU
425 435
426config CALGARY_IOMMU 436config CALGARY_IOMMU
427 bool "IBM Calgary IOMMU support" 437 bool "IBM Calgary IOMMU support"
428 default y
429 select SWIOTLB 438 select SWIOTLB
430 depends on PCI && EXPERIMENTAL 439 depends on PCI && EXPERIMENTAL
431 help 440 help
@@ -472,8 +481,7 @@ config X86_MCE_AMD
472 the DRAM Error Threshold. 481 the DRAM Error Threshold.
473 482
474config KEXEC 483config KEXEC
475 bool "kexec system call (EXPERIMENTAL)" 484 bool "kexec system call"
476 depends on EXPERIMENTAL
477 help 485 help
478 kexec is a system call that implements the ability to shutdown your 486 kexec is a system call that implements the ability to shutdown your
479 current kernel, and to start another kernel. It is like a reboot 487 current kernel, and to start another kernel. It is like a reboot
@@ -492,7 +500,14 @@ config CRASH_DUMP
492 bool "kernel crash dumps (EXPERIMENTAL)" 500 bool "kernel crash dumps (EXPERIMENTAL)"
493 depends on EXPERIMENTAL 501 depends on EXPERIMENTAL
494 help 502 help
495 Generate crash dump after being started by kexec. 503 Generate crash dump after being started by kexec.
504 This should be normally only set in special crash dump kernels
505 which are loaded in the main kernel with kexec-tools into
506 a specially reserved region and then later executed after
507 a crash by kdump/kexec. The crash dump kernel must be compiled
508 to a memory address not used by the main kernel or BIOS using
509 PHYSICAL_START.
510 For more details see Documentation/kdump/kdump.txt
496 511
497config PHYSICAL_START 512config PHYSICAL_START
498 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 513 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
@@ -530,6 +545,30 @@ config SECCOMP
530 545
531 If unsure, say Y. Only embedded should say N here. 546 If unsure, say Y. Only embedded should say N here.
532 547
548config CC_STACKPROTECTOR
549 bool "Enable -fstack-protector buffer overflow detection (EXPRIMENTAL)"
550 depends on EXPERIMENTAL
551 help
552 This option turns on the -fstack-protector GCC feature. This
553 feature puts, at the beginning of critical functions, a canary
554 value on the stack just before the return address, and validates
555 the value just before actually returning. Stack based buffer
556 overflows (that need to overwrite this return address) now also
557 overwrite the canary, which gets detected and the attack is then
558 neutralized via a kernel panic.
559
560 This feature requires gcc version 4.2 or above, or a distribution
561 gcc with the feature backported. Older versions are automatically
562 detected and for those versions, this configuration option is ignored.
563
564config CC_STACKPROTECTOR_ALL
565 bool "Use stack-protector for all functions"
566 depends on CC_STACKPROTECTOR
567 help
568 Normally, GCC only inserts the canary value protection for
569 functions that use large-ish on-stack buffers. By enabling
570 this option, GCC will be asked to do this for ALL functions.
571
533source kernel/Kconfig.hz 572source kernel/Kconfig.hz
534 573
535config REORDER 574config REORDER
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 431bb4bc36cd..1c0f18d4f887 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -54,6 +54,16 @@ endif
54cflags-y += $(call cc-option,-funit-at-a-time) 54cflags-y += $(call cc-option,-funit-at-a-time)
55# prevent gcc from generating any FP code by mistake 55# prevent gcc from generating any FP code by mistake
56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,) 56cflags-y += $(call cc-option,-mno-sse -mno-mmx -mno-sse2 -mno-3dnow,)
57# do binutils support CFI?
58cflags-y += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
59AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
60
61# is .cfi_signal_frame supported too?
62cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
63AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
64
65cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC) -fstack-protector )
66cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC) -fstack-protector-all )
57 67
58CFLAGS += $(cflags-y) 68CFLAGS += $(cflags-y)
59CFLAGS_KERNEL += $(cflags-kernel-y) 69CFLAGS_KERNEL += $(cflags-kernel-y)
diff --git a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
index f89d96f11a9f..e70fa6e1da08 100644
--- a/arch/x86_64/boot/compressed/Makefile
+++ b/arch/x86_64/boot/compressed/Makefile
@@ -7,7 +7,8 @@
7# 7#
8 8
9targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o 9targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
10EXTRA_AFLAGS := -traditional -m32 10EXTRA_AFLAGS := -traditional
11AFLAGS := $(subst -m64,-m32,$(AFLAGS))
11 12
12# cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with 13# cannot use EXTRA_CFLAGS because base CFLAGS contains -mkernel which conflicts with
13# -m32 14# -m32
diff --git a/arch/x86_64/boot/setup.S b/arch/x86_64/boot/setup.S
index a50b631f4d2b..c3bfd223ab49 100644
--- a/arch/x86_64/boot/setup.S
+++ b/arch/x86_64/boot/setup.S
@@ -526,12 +526,12 @@ is_disk1:
526 movw %cs, %ax # aka SETUPSEG 526 movw %cs, %ax # aka SETUPSEG
527 subw $DELTA_INITSEG, %ax # aka INITSEG 527 subw $DELTA_INITSEG, %ax # aka INITSEG
528 movw %ax, %ds 528 movw %ax, %ds
529 movw $0, (0x1ff) # default is no pointing device 529 movb $0, (0x1ff) # default is no pointing device
530 int $0x11 # int 0x11: equipment list 530 int $0x11 # int 0x11: equipment list
531 testb $0x04, %al # check if mouse installed 531 testb $0x04, %al # check if mouse installed
532 jz no_psmouse 532 jz no_psmouse
533 533
534 movw $0xAA, (0x1ff) # device present 534 movb $0xAA, (0x1ff) # device present
535no_psmouse: 535no_psmouse:
536 536
537#include "../../i386/boot/edd.S" 537#include "../../i386/boot/edd.S"
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 5fb970715941..647610ecb580 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.18-rc4 3# Linux kernel version: 2.6.18-git5
4# Thu Aug 24 21:05:55 2006 4# Tue Sep 26 09:30:47 2006
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
@@ -19,6 +19,7 @@ CONFIG_GENERIC_ISA_DMA=y
19CONFIG_GENERIC_IOMAP=y 19CONFIG_GENERIC_IOMAP=y
20CONFIG_ARCH_MAY_HAVE_PC_FDC=y 20CONFIG_ARCH_MAY_HAVE_PC_FDC=y
21CONFIG_DMI=y 21CONFIG_DMI=y
22CONFIG_AUDIT_ARCH=y
22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 23CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
23 24
24# 25#
@@ -38,16 +39,16 @@ CONFIG_SYSVIPC=y
38CONFIG_POSIX_MQUEUE=y 39CONFIG_POSIX_MQUEUE=y
39# CONFIG_BSD_PROCESS_ACCT is not set 40# CONFIG_BSD_PROCESS_ACCT is not set
40# CONFIG_TASKSTATS is not set 41# CONFIG_TASKSTATS is not set
41CONFIG_SYSCTL=y
42# CONFIG_AUDIT is not set 42# CONFIG_AUDIT is not set
43CONFIG_IKCONFIG=y 43CONFIG_IKCONFIG=y
44CONFIG_IKCONFIG_PROC=y 44CONFIG_IKCONFIG_PROC=y
45# CONFIG_CPUSETS is not set 45# CONFIG_CPUSETS is not set
46# CONFIG_RELAY is not set 46# CONFIG_RELAY is not set
47CONFIG_INITRAMFS_SOURCE="" 47CONFIG_INITRAMFS_SOURCE=""
48CONFIG_UID16=y
49CONFIG_CC_OPTIMIZE_FOR_SIZE=y 48CONFIG_CC_OPTIMIZE_FOR_SIZE=y
50# CONFIG_EMBEDDED is not set 49# CONFIG_EMBEDDED is not set
50CONFIG_UID16=y
51CONFIG_SYSCTL=y
51CONFIG_KALLSYMS=y 52CONFIG_KALLSYMS=y
52CONFIG_KALLSYMS_ALL=y 53CONFIG_KALLSYMS_ALL=y
53# CONFIG_KALLSYMS_EXTRA_PASS is not set 54# CONFIG_KALLSYMS_EXTRA_PASS is not set
@@ -56,12 +57,12 @@ CONFIG_PRINTK=y
56CONFIG_BUG=y 57CONFIG_BUG=y
57CONFIG_ELF_CORE=y 58CONFIG_ELF_CORE=y
58CONFIG_BASE_FULL=y 59CONFIG_BASE_FULL=y
59CONFIG_RT_MUTEXES=y
60CONFIG_FUTEX=y 60CONFIG_FUTEX=y
61CONFIG_EPOLL=y 61CONFIG_EPOLL=y
62CONFIG_SHMEM=y 62CONFIG_SHMEM=y
63CONFIG_SLAB=y 63CONFIG_SLAB=y
64CONFIG_VM_EVENT_COUNTERS=y 64CONFIG_VM_EVENT_COUNTERS=y
65CONFIG_RT_MUTEXES=y
65# CONFIG_TINY_SHMEM is not set 66# CONFIG_TINY_SHMEM is not set
66CONFIG_BASE_SMALL=0 67CONFIG_BASE_SMALL=0
67# CONFIG_SLOB is not set 68# CONFIG_SLOB is not set
@@ -160,6 +161,7 @@ CONFIG_X86_MCE_AMD=y
160# CONFIG_CRASH_DUMP is not set 161# CONFIG_CRASH_DUMP is not set
161CONFIG_PHYSICAL_START=0x200000 162CONFIG_PHYSICAL_START=0x200000
162CONFIG_SECCOMP=y 163CONFIG_SECCOMP=y
164# CONFIG_CC_STACKPROTECTOR is not set
163# CONFIG_HZ_100 is not set 165# CONFIG_HZ_100 is not set
164CONFIG_HZ_250=y 166CONFIG_HZ_250=y
165# CONFIG_HZ_1000 is not set 167# CONFIG_HZ_1000 is not set
@@ -307,18 +309,23 @@ CONFIG_IP_PNP_DHCP=y
307CONFIG_INET_DIAG=y 309CONFIG_INET_DIAG=y
308CONFIG_INET_TCP_DIAG=y 310CONFIG_INET_TCP_DIAG=y
309# CONFIG_TCP_CONG_ADVANCED is not set 311# CONFIG_TCP_CONG_ADVANCED is not set
310CONFIG_TCP_CONG_BIC=y 312CONFIG_TCP_CONG_CUBIC=y
313CONFIG_DEFAULT_TCP_CONG="cubic"
311CONFIG_IPV6=y 314CONFIG_IPV6=y
312# CONFIG_IPV6_PRIVACY is not set 315# CONFIG_IPV6_PRIVACY is not set
313# CONFIG_IPV6_ROUTER_PREF is not set 316# CONFIG_IPV6_ROUTER_PREF is not set
314# CONFIG_INET6_AH is not set 317# CONFIG_INET6_AH is not set
315# CONFIG_INET6_ESP is not set 318# CONFIG_INET6_ESP is not set
316# CONFIG_INET6_IPCOMP is not set 319# CONFIG_INET6_IPCOMP is not set
320# CONFIG_IPV6_MIP6 is not set
317# CONFIG_INET6_XFRM_TUNNEL is not set 321# CONFIG_INET6_XFRM_TUNNEL is not set
318# CONFIG_INET6_TUNNEL is not set 322# CONFIG_INET6_TUNNEL is not set
319# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set 323# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
320# CONFIG_INET6_XFRM_MODE_TUNNEL is not set 324# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
325# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
321# CONFIG_IPV6_TUNNEL is not set 326# CONFIG_IPV6_TUNNEL is not set
327# CONFIG_IPV6_SUBTREES is not set
328# CONFIG_IPV6_MULTIPLE_TABLES is not set
322# CONFIG_NETWORK_SECMARK is not set 329# CONFIG_NETWORK_SECMARK is not set
323# CONFIG_NETFILTER is not set 330# CONFIG_NETFILTER is not set
324 331
@@ -345,7 +352,6 @@ CONFIG_IPV6=y
345# CONFIG_ATALK is not set 352# CONFIG_ATALK is not set
346# CONFIG_X25 is not set 353# CONFIG_X25 is not set
347# CONFIG_LAPB is not set 354# CONFIG_LAPB is not set
348# CONFIG_NET_DIVERT is not set
349# CONFIG_ECONET is not set 355# CONFIG_ECONET is not set
350# CONFIG_WAN_ROUTER is not set 356# CONFIG_WAN_ROUTER is not set
351 357
@@ -487,6 +493,7 @@ CONFIG_IDEDMA_AUTO=y
487# 493#
488# CONFIG_RAID_ATTRS is not set 494# CONFIG_RAID_ATTRS is not set
489CONFIG_SCSI=y 495CONFIG_SCSI=y
496CONFIG_SCSI_NETLINK=y
490# CONFIG_SCSI_PROC_FS is not set 497# CONFIG_SCSI_PROC_FS is not set
491 498
492# 499#
@@ -508,12 +515,13 @@ CONFIG_SCSI_CONSTANTS=y
508# CONFIG_SCSI_LOGGING is not set 515# CONFIG_SCSI_LOGGING is not set
509 516
510# 517#
511# SCSI Transport Attributes 518# SCSI Transports
512# 519#
513CONFIG_SCSI_SPI_ATTRS=y 520CONFIG_SCSI_SPI_ATTRS=y
514CONFIG_SCSI_FC_ATTRS=y 521CONFIG_SCSI_FC_ATTRS=y
515# CONFIG_SCSI_ISCSI_ATTRS is not set 522# CONFIG_SCSI_ISCSI_ATTRS is not set
516CONFIG_SCSI_SAS_ATTRS=y 523CONFIG_SCSI_SAS_ATTRS=y
524# CONFIG_SCSI_SAS_LIBSAS is not set
517 525
518# 526#
519# SCSI low-level drivers 527# SCSI low-level drivers
@@ -532,29 +540,14 @@ CONFIG_AIC79XX_RESET_DELAY_MS=4000
532# CONFIG_AIC79XX_DEBUG_ENABLE is not set 540# CONFIG_AIC79XX_DEBUG_ENABLE is not set
533CONFIG_AIC79XX_DEBUG_MASK=0 541CONFIG_AIC79XX_DEBUG_MASK=0
534# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set 542# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
543# CONFIG_SCSI_AIC94XX is not set
544# CONFIG_SCSI_ARCMSR is not set
535CONFIG_MEGARAID_NEWGEN=y 545CONFIG_MEGARAID_NEWGEN=y
536CONFIG_MEGARAID_MM=y 546CONFIG_MEGARAID_MM=y
537CONFIG_MEGARAID_MAILBOX=y 547CONFIG_MEGARAID_MAILBOX=y
538# CONFIG_MEGARAID_LEGACY is not set 548# CONFIG_MEGARAID_LEGACY is not set
539CONFIG_MEGARAID_SAS=y 549CONFIG_MEGARAID_SAS=y
540CONFIG_SCSI_SATA=y
541CONFIG_SCSI_SATA_AHCI=y
542CONFIG_SCSI_SATA_SVW=y
543CONFIG_SCSI_ATA_PIIX=y
544# CONFIG_SCSI_SATA_MV is not set
545CONFIG_SCSI_SATA_NV=y
546# CONFIG_SCSI_PDC_ADMA is not set
547# CONFIG_SCSI_HPTIOP is not set 550# CONFIG_SCSI_HPTIOP is not set
548# CONFIG_SCSI_SATA_QSTOR is not set
549# CONFIG_SCSI_SATA_PROMISE is not set
550# CONFIG_SCSI_SATA_SX4 is not set
551CONFIG_SCSI_SATA_SIL=y
552# CONFIG_SCSI_SATA_SIL24 is not set
553# CONFIG_SCSI_SATA_SIS is not set
554# CONFIG_SCSI_SATA_ULI is not set
555CONFIG_SCSI_SATA_VIA=y
556# CONFIG_SCSI_SATA_VITESSE is not set
557CONFIG_SCSI_SATA_INTEL_COMBINED=y
558# CONFIG_SCSI_BUSLOGIC is not set 551# CONFIG_SCSI_BUSLOGIC is not set
559# CONFIG_SCSI_DMX3191D is not set 552# CONFIG_SCSI_DMX3191D is not set
560# CONFIG_SCSI_EATA is not set 553# CONFIG_SCSI_EATA is not set
@@ -563,6 +556,7 @@ CONFIG_SCSI_SATA_INTEL_COMBINED=y
563# CONFIG_SCSI_IPS is not set 556# CONFIG_SCSI_IPS is not set
564# CONFIG_SCSI_INITIO is not set 557# CONFIG_SCSI_INITIO is not set
565# CONFIG_SCSI_INIA100 is not set 558# CONFIG_SCSI_INIA100 is not set
559# CONFIG_SCSI_STEX is not set
566# CONFIG_SCSI_SYM53C8XX_2 is not set 560# CONFIG_SCSI_SYM53C8XX_2 is not set
567# CONFIG_SCSI_IPR is not set 561# CONFIG_SCSI_IPR is not set
568# CONFIG_SCSI_QLOGIC_1280 is not set 562# CONFIG_SCSI_QLOGIC_1280 is not set
@@ -573,6 +567,62 @@ CONFIG_SCSI_SATA_INTEL_COMBINED=y
573# CONFIG_SCSI_DEBUG is not set 567# CONFIG_SCSI_DEBUG is not set
574 568
575# 569#
570# Serial ATA (prod) and Parallel ATA (experimental) drivers
571#
572CONFIG_ATA=y
573CONFIG_SATA_AHCI=y
574CONFIG_SATA_SVW=y
575CONFIG_ATA_PIIX=y
576# CONFIG_SATA_MV is not set
577CONFIG_SATA_NV=y
578# CONFIG_PDC_ADMA is not set
579# CONFIG_SATA_QSTOR is not set
580# CONFIG_SATA_PROMISE is not set
581# CONFIG_SATA_SX4 is not set
582CONFIG_SATA_SIL=y
583# CONFIG_SATA_SIL24 is not set
584# CONFIG_SATA_SIS is not set
585# CONFIG_SATA_ULI is not set
586CONFIG_SATA_VIA=y
587# CONFIG_SATA_VITESSE is not set
588CONFIG_SATA_INTEL_COMBINED=y
589# CONFIG_PATA_ALI is not set
590# CONFIG_PATA_AMD is not set
591# CONFIG_PATA_ARTOP is not set
592# CONFIG_PATA_ATIIXP is not set
593# CONFIG_PATA_CMD64X is not set
594# CONFIG_PATA_CS5520 is not set
595# CONFIG_PATA_CS5530 is not set
596# CONFIG_PATA_CYPRESS is not set
597# CONFIG_PATA_EFAR is not set
598# CONFIG_ATA_GENERIC is not set
599# CONFIG_PATA_HPT366 is not set
600# CONFIG_PATA_HPT37X is not set
601# CONFIG_PATA_HPT3X2N is not set
602# CONFIG_PATA_HPT3X3 is not set
603# CONFIG_PATA_IT821X is not set
604# CONFIG_PATA_JMICRON is not set
605# CONFIG_PATA_LEGACY is not set
606# CONFIG_PATA_TRIFLEX is not set
607# CONFIG_PATA_MPIIX is not set
608# CONFIG_PATA_OLDPIIX is not set
609# CONFIG_PATA_NETCELL is not set
610# CONFIG_PATA_NS87410 is not set
611# CONFIG_PATA_OPTI is not set
612# CONFIG_PATA_OPTIDMA is not set
613# CONFIG_PATA_PDC_OLD is not set
614# CONFIG_PATA_QDI is not set
615# CONFIG_PATA_RADISYS is not set
616# CONFIG_PATA_RZ1000 is not set
617# CONFIG_PATA_SC1200 is not set
618# CONFIG_PATA_SERVERWORKS is not set
619# CONFIG_PATA_PDC2027X is not set
620# CONFIG_PATA_SIL680 is not set
621# CONFIG_PATA_SIS is not set
622# CONFIG_PATA_VIA is not set
623# CONFIG_PATA_WINBOND is not set
624
625#
576# Multi-device support (RAID and LVM) 626# Multi-device support (RAID and LVM)
577# 627#
578CONFIG_MD=y 628CONFIG_MD=y
@@ -678,6 +728,7 @@ CONFIG_NET_PCI=y
678# CONFIG_ADAPTEC_STARFIRE is not set 728# CONFIG_ADAPTEC_STARFIRE is not set
679CONFIG_B44=y 729CONFIG_B44=y
680CONFIG_FORCEDETH=y 730CONFIG_FORCEDETH=y
731# CONFIG_FORCEDETH_NAPI is not set
681# CONFIG_DGRS is not set 732# CONFIG_DGRS is not set
682# CONFIG_EEPRO100 is not set 733# CONFIG_EEPRO100 is not set
683CONFIG_E100=y 734CONFIG_E100=y
@@ -714,6 +765,7 @@ CONFIG_E1000=y
714# CONFIG_VIA_VELOCITY is not set 765# CONFIG_VIA_VELOCITY is not set
715CONFIG_TIGON3=y 766CONFIG_TIGON3=y
716CONFIG_BNX2=y 767CONFIG_BNX2=y
768# CONFIG_QLA3XXX is not set
717 769
718# 770#
719# Ethernet (10000 Mbit) 771# Ethernet (10000 Mbit)
@@ -1036,6 +1088,7 @@ CONFIG_SOUND=y
1036# Open Sound System 1088# Open Sound System
1037# 1089#
1038CONFIG_SOUND_PRIME=y 1090CONFIG_SOUND_PRIME=y
1091CONFIG_OSS_OBSOLETE_DRIVER=y
1039# CONFIG_SOUND_BT878 is not set 1092# CONFIG_SOUND_BT878 is not set
1040# CONFIG_SOUND_EMU10K1 is not set 1093# CONFIG_SOUND_EMU10K1 is not set
1041# CONFIG_SOUND_FUSION is not set 1094# CONFIG_SOUND_FUSION is not set
@@ -1046,7 +1099,6 @@ CONFIG_SOUND_ICH=y
1046# CONFIG_SOUND_MSNDPIN is not set 1099# CONFIG_SOUND_MSNDPIN is not set
1047# CONFIG_SOUND_VIA82CXXX is not set 1100# CONFIG_SOUND_VIA82CXXX is not set
1048# CONFIG_SOUND_OSS is not set 1101# CONFIG_SOUND_OSS is not set
1049# CONFIG_SOUND_TVMIXER is not set
1050 1102
1051# 1103#
1052# USB support 1104# USB support
@@ -1203,7 +1255,6 @@ CONFIG_USB_MON=y
1203# InfiniBand support 1255# InfiniBand support
1204# 1256#
1205# CONFIG_INFINIBAND is not set 1257# CONFIG_INFINIBAND is not set
1206# CONFIG_IPATH_CORE is not set
1207 1258
1208# 1259#
1209# EDAC - error detection and reporting (RAS) (EXPERIMENTAL) 1260# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
@@ -1449,10 +1500,6 @@ CONFIG_DEBUG_STACKOVERFLOW=y
1449# CONFIG_CRYPTO is not set 1500# CONFIG_CRYPTO is not set
1450 1501
1451# 1502#
1452# Hardware crypto devices
1453#
1454
1455#
1456# Library routines 1503# Library routines
1457# 1504#
1458# CONFIG_CRC_CCITT is not set 1505# CONFIG_CRC_CCITT is not set
diff --git a/arch/x86_64/ia32/ia32_aout.c b/arch/x86_64/ia32/ia32_aout.c
index 3bf58af98936..396d3c100011 100644
--- a/arch/x86_64/ia32/ia32_aout.c
+++ b/arch/x86_64/ia32/ia32_aout.c
@@ -333,7 +333,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
333 return error; 333 return error;
334 } 334 }
335 335
336 error = bprm->file->f_op->read(bprm->file, (char *)text_addr, 336 error = bprm->file->f_op->read(bprm->file,
337 (char __user *)text_addr,
337 ex.a_text+ex.a_data, &pos); 338 ex.a_text+ex.a_data, &pos);
338 if ((signed long)error < 0) { 339 if ((signed long)error < 0) {
339 send_sig(SIGKILL, current, 0); 340 send_sig(SIGKILL, current, 0);
@@ -366,7 +367,8 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
366 down_write(&current->mm->mmap_sem); 367 down_write(&current->mm->mmap_sem);
367 do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data); 368 do_brk(N_TXTADDR(ex), ex.a_text+ex.a_data);
368 up_write(&current->mm->mmap_sem); 369 up_write(&current->mm->mmap_sem);
369 bprm->file->f_op->read(bprm->file,(char *)N_TXTADDR(ex), 370 bprm->file->f_op->read(bprm->file,
371 (char __user *)N_TXTADDR(ex),
370 ex.a_text+ex.a_data, &pos); 372 ex.a_text+ex.a_data, &pos);
371 flush_icache_range((unsigned long) N_TXTADDR(ex), 373 flush_icache_range((unsigned long) N_TXTADDR(ex),
372 (unsigned long) N_TXTADDR(ex) + 374 (unsigned long) N_TXTADDR(ex) +
@@ -477,7 +479,7 @@ static int load_aout_library(struct file *file)
477 do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss); 479 do_brk(start_addr, ex.a_text + ex.a_data + ex.a_bss);
478 up_write(&current->mm->mmap_sem); 480 up_write(&current->mm->mmap_sem);
479 481
480 file->f_op->read(file, (char *)start_addr, 482 file->f_op->read(file, (char __user *)start_addr,
481 ex.a_text + ex.a_data, &pos); 483 ex.a_text + ex.a_data, &pos);
482 flush_icache_range((unsigned long) start_addr, 484 flush_icache_range((unsigned long) start_addr,
483 (unsigned long) start_addr + ex.a_text + ex.a_data); 485 (unsigned long) start_addr + ex.a_text + ex.a_data);
diff --git a/arch/x86_64/ia32/ia32_signal.c b/arch/x86_64/ia32/ia32_signal.c
index 25e5ca22204c..a6ba9951e86c 100644
--- a/arch/x86_64/ia32/ia32_signal.c
+++ b/arch/x86_64/ia32/ia32_signal.c
@@ -113,25 +113,19 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
113} 113}
114 114
115asmlinkage long 115asmlinkage long
116sys32_sigsuspend(int history0, int history1, old_sigset_t mask, 116sys32_sigsuspend(int history0, int history1, old_sigset_t mask)
117 struct pt_regs *regs)
118{ 117{
119 sigset_t saveset;
120
121 mask &= _BLOCKABLE; 118 mask &= _BLOCKABLE;
122 spin_lock_irq(&current->sighand->siglock); 119 spin_lock_irq(&current->sighand->siglock);
123 saveset = current->blocked; 120 current->saved_sigmask = current->blocked;
124 siginitset(&current->blocked, mask); 121 siginitset(&current->blocked, mask);
125 recalc_sigpending(); 122 recalc_sigpending();
126 spin_unlock_irq(&current->sighand->siglock); 123 spin_unlock_irq(&current->sighand->siglock);
127 124
128 regs->rax = -EINTR; 125 current->state = TASK_INTERRUPTIBLE;
129 while (1) { 126 schedule();
130 current->state = TASK_INTERRUPTIBLE; 127 set_thread_flag(TIF_RESTORE_SIGMASK);
131 schedule(); 128 return -ERESTARTNOHAND;
132 if (do_signal(regs, &saveset))
133 return -EINTR;
134 }
135} 129}
136 130
137asmlinkage long 131asmlinkage long
@@ -437,15 +431,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
437 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame))) 431 if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
438 goto give_sigsegv; 432 goto give_sigsegv;
439 433
440 { 434 err |= __put_user(sig, &frame->sig);
441 struct exec_domain *ed = current_thread_info()->exec_domain;
442 err |= __put_user((ed
443 && ed->signal_invmap
444 && sig < 32
445 ? ed->signal_invmap[sig]
446 : sig),
447 &frame->sig);
448 }
449 if (err) 435 if (err)
450 goto give_sigsegv; 436 goto give_sigsegv;
451 437
@@ -492,6 +478,11 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
492 regs->rsp = (unsigned long) frame; 478 regs->rsp = (unsigned long) frame;
493 regs->rip = (unsigned long) ka->sa.sa_handler; 479 regs->rip = (unsigned long) ka->sa.sa_handler;
494 480
481 /* Make -mregparm=3 work */
482 regs->rax = sig;
483 regs->rdx = 0;
484 regs->rcx = 0;
485
495 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS)); 486 asm volatile("movl %0,%%ds" :: "r" (__USER32_DS));
496 asm volatile("movl %0,%%es" :: "r" (__USER32_DS)); 487 asm volatile("movl %0,%%es" :: "r" (__USER32_DS));
497 488
@@ -499,20 +490,20 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
499 regs->ss = __USER32_DS; 490 regs->ss = __USER32_DS;
500 491
501 set_fs(USER_DS); 492 set_fs(USER_DS);
502 regs->eflags &= ~TF_MASK; 493 regs->eflags &= ~TF_MASK;
503 if (test_thread_flag(TIF_SINGLESTEP)) 494 if (test_thread_flag(TIF_SINGLESTEP))
504 ptrace_notify(SIGTRAP); 495 ptrace_notify(SIGTRAP);
505 496
506#if DEBUG_SIG 497#if DEBUG_SIG
507 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", 498 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
508 current->comm, current->pid, frame, regs->rip, frame->pretcode); 499 current->comm, current->pid, frame, regs->rip, frame->pretcode);
509#endif 500#endif
510 501
511 return 1; 502 return 0;
512 503
513give_sigsegv: 504give_sigsegv:
514 force_sigsegv(sig, current); 505 force_sigsegv(sig, current);
515 return 0; 506 return -EFAULT;
516} 507}
517 508
518int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, 509int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
@@ -595,18 +586,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
595 regs->ss = __USER32_DS; 586 regs->ss = __USER32_DS;
596 587
597 set_fs(USER_DS); 588 set_fs(USER_DS);
598 regs->eflags &= ~TF_MASK; 589 regs->eflags &= ~TF_MASK;
599 if (test_thread_flag(TIF_SINGLESTEP)) 590 if (test_thread_flag(TIF_SINGLESTEP))
600 ptrace_notify(SIGTRAP); 591 ptrace_notify(SIGTRAP);
601 592
602#if DEBUG_SIG 593#if DEBUG_SIG
603 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", 594 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
604 current->comm, current->pid, frame, regs->rip, frame->pretcode); 595 current->comm, current->pid, frame, regs->rip, frame->pretcode);
605#endif 596#endif
606 597
607 return 1; 598 return 0;
608 599
609give_sigsegv: 600give_sigsegv:
610 force_sigsegv(sig, current); 601 force_sigsegv(sig, current);
611 return 0; 602 return -EFAULT;
612} 603}
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 5d4a7d125ed0..b4aa875e175b 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -71,6 +71,7 @@
71 */ 71 */
72ENTRY(ia32_sysenter_target) 72ENTRY(ia32_sysenter_target)
73 CFI_STARTPROC32 simple 73 CFI_STARTPROC32 simple
74 CFI_SIGNAL_FRAME
74 CFI_DEF_CFA rsp,0 75 CFI_DEF_CFA rsp,0
75 CFI_REGISTER rsp,rbp 76 CFI_REGISTER rsp,rbp
76 swapgs 77 swapgs
@@ -186,6 +187,7 @@ ENDPROC(ia32_sysenter_target)
186 */ 187 */
187ENTRY(ia32_cstar_target) 188ENTRY(ia32_cstar_target)
188 CFI_STARTPROC32 simple 189 CFI_STARTPROC32 simple
190 CFI_SIGNAL_FRAME
189 CFI_DEF_CFA rsp,PDA_STACKOFFSET 191 CFI_DEF_CFA rsp,PDA_STACKOFFSET
190 CFI_REGISTER rip,rcx 192 CFI_REGISTER rip,rcx
191 /*CFI_REGISTER rflags,r11*/ 193 /*CFI_REGISTER rflags,r11*/
@@ -293,6 +295,7 @@ ia32_badarg:
293 295
294ENTRY(ia32_syscall) 296ENTRY(ia32_syscall)
295 CFI_STARTPROC simple 297 CFI_STARTPROC simple
298 CFI_SIGNAL_FRAME
296 CFI_DEF_CFA rsp,SS+8-RIP 299 CFI_DEF_CFA rsp,SS+8-RIP
297 /*CFI_REL_OFFSET ss,SS-RIP*/ 300 /*CFI_REL_OFFSET ss,SS-RIP*/
298 CFI_REL_OFFSET rsp,RSP-RIP 301 CFI_REL_OFFSET rsp,RSP-RIP
@@ -370,6 +373,7 @@ ENTRY(ia32_ptregs_common)
370 popq %r11 373 popq %r11
371 CFI_ENDPROC 374 CFI_ENDPROC
372 CFI_STARTPROC32 simple 375 CFI_STARTPROC32 simple
376 CFI_SIGNAL_FRAME
373 CFI_DEF_CFA rsp,SS+8-ARGOFFSET 377 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
374 CFI_REL_OFFSET rax,RAX-ARGOFFSET 378 CFI_REL_OFFSET rax,RAX-ARGOFFSET
375 CFI_REL_OFFSET rcx,RCX-ARGOFFSET 379 CFI_REL_OFFSET rcx,RCX-ARGOFFSET
@@ -703,8 +707,8 @@ ia32_sys_call_table:
703 .quad sys_readlinkat /* 305 */ 707 .quad sys_readlinkat /* 305 */
704 .quad sys_fchmodat 708 .quad sys_fchmodat
705 .quad sys_faccessat 709 .quad sys_faccessat
706 .quad quiet_ni_syscall /* pselect6 for now */ 710 .quad compat_sys_pselect6
707 .quad quiet_ni_syscall /* ppoll for now */ 711 .quad compat_sys_ppoll
708 .quad sys_unshare /* 310 */ 712 .quad sys_unshare /* 310 */
709 .quad compat_sys_set_robust_list 713 .quad compat_sys_set_robust_list
710 .quad compat_sys_get_robust_list 714 .quad compat_sys_get_robust_list
@@ -713,4 +717,5 @@ ia32_sys_call_table:
713 .quad sys_tee 717 .quad sys_tee
714 .quad compat_sys_vmsplice 718 .quad compat_sys_vmsplice
715 .quad compat_sys_move_pages 719 .quad compat_sys_move_pages
720 .quad sys_getcpu
716ia32_syscall_end: 721ia32_syscall_end:
diff --git a/arch/x86_64/ia32/ptrace32.c b/arch/x86_64/ia32/ptrace32.c
index 659c0722f6b8..d18198ed636b 100644
--- a/arch/x86_64/ia32/ptrace32.c
+++ b/arch/x86_64/ia32/ptrace32.c
@@ -117,6 +117,10 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
117 if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1) 117 if ((0x5454 >> ((val >> (16 + 4*i)) & 0xf)) & 1)
118 return -EIO; 118 return -EIO;
119 child->thread.debugreg7 = val; 119 child->thread.debugreg7 = val;
120 if (val)
121 set_tsk_thread_flag(child, TIF_DEBUG);
122 else
123 clear_tsk_thread_flag(child, TIF_DEBUG);
120 break; 124 break;
121 125
122 default: 126 default:
@@ -371,8 +375,10 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
371 ret = -EIO; 375 ret = -EIO;
372 if (!access_ok(VERIFY_READ, u, sizeof(*u))) 376 if (!access_ok(VERIFY_READ, u, sizeof(*u)))
373 break; 377 break;
374 /* no checking to be bug-to-bug compatible with i386 */ 378 /* no checking to be bug-to-bug compatible with i386. */
375 __copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)); 379 /* but silence warning */
380 if (__copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)))
381 ;
376 set_stopped_child_used_math(child); 382 set_stopped_child_used_math(child);
377 child->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask; 383 child->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask;
378 ret = 0; 384 ret = 0;
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 9c130993380d..f280d3665f4b 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -60,6 +60,7 @@
60#include <linux/highuid.h> 60#include <linux/highuid.h>
61#include <linux/vmalloc.h> 61#include <linux/vmalloc.h>
62#include <linux/fsnotify.h> 62#include <linux/fsnotify.h>
63#include <linux/sysctl.h>
63#include <asm/mman.h> 64#include <asm/mman.h>
64#include <asm/types.h> 65#include <asm/types.h>
65#include <asm/uaccess.h> 66#include <asm/uaccess.h>
@@ -389,7 +390,9 @@ sys32_rt_sigprocmask(int how, compat_sigset_t __user *set,
389 } 390 }
390 } 391 }
391 set_fs (KERNEL_DS); 392 set_fs (KERNEL_DS);
392 ret = sys_rt_sigprocmask(how, set ? &s : NULL, oset ? &s : NULL, 393 ret = sys_rt_sigprocmask(how,
394 set ? (sigset_t __user *)&s : NULL,
395 oset ? (sigset_t __user *)&s : NULL,
393 sigsetsize); 396 sigsetsize);
394 set_fs (old_fs); 397 set_fs (old_fs);
395 if (ret) return ret; 398 if (ret) return ret;
@@ -541,7 +544,7 @@ sys32_sysinfo(struct sysinfo32 __user *info)
541 int bitcount = 0; 544 int bitcount = 0;
542 545
543 set_fs (KERNEL_DS); 546 set_fs (KERNEL_DS);
544 ret = sys_sysinfo(&s); 547 ret = sys_sysinfo((struct sysinfo __user *)&s);
545 set_fs (old_fs); 548 set_fs (old_fs);
546 549
547 /* Check to see if any memory value is too large for 32-bit and scale 550 /* Check to see if any memory value is too large for 32-bit and scale
@@ -589,7 +592,7 @@ sys32_sched_rr_get_interval(compat_pid_t pid, struct compat_timespec __user *int
589 mm_segment_t old_fs = get_fs (); 592 mm_segment_t old_fs = get_fs ();
590 593
591 set_fs (KERNEL_DS); 594 set_fs (KERNEL_DS);
592 ret = sys_sched_rr_get_interval(pid, &t); 595 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
593 set_fs (old_fs); 596 set_fs (old_fs);
594 if (put_compat_timespec(&t, interval)) 597 if (put_compat_timespec(&t, interval))
595 return -EFAULT; 598 return -EFAULT;
@@ -605,7 +608,7 @@ sys32_rt_sigpending(compat_sigset_t __user *set, compat_size_t sigsetsize)
605 mm_segment_t old_fs = get_fs(); 608 mm_segment_t old_fs = get_fs();
606 609
607 set_fs (KERNEL_DS); 610 set_fs (KERNEL_DS);
608 ret = sys_rt_sigpending(&s, sigsetsize); 611 ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
609 set_fs (old_fs); 612 set_fs (old_fs);
610 if (!ret) { 613 if (!ret) {
611 switch (_NSIG_WORDS) { 614 switch (_NSIG_WORDS) {
@@ -630,7 +633,7 @@ sys32_rt_sigqueueinfo(int pid, int sig, compat_siginfo_t __user *uinfo)
630 if (copy_siginfo_from_user32(&info, uinfo)) 633 if (copy_siginfo_from_user32(&info, uinfo))
631 return -EFAULT; 634 return -EFAULT;
632 set_fs (KERNEL_DS); 635 set_fs (KERNEL_DS);
633 ret = sys_rt_sigqueueinfo(pid, sig, &info); 636 ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
634 set_fs (old_fs); 637 set_fs (old_fs);
635 return ret; 638 return ret;
636} 639}
@@ -645,7 +648,7 @@ sys32_pause(void)
645} 648}
646 649
647 650
648#ifdef CONFIG_SYSCTL 651#ifdef CONFIG_SYSCTL_SYSCALL
649struct sysctl_ia32 { 652struct sysctl_ia32 {
650 unsigned int name; 653 unsigned int name;
651 int nlen; 654 int nlen;
@@ -666,9 +669,6 @@ sys32_sysctl(struct sysctl_ia32 __user *args32)
666 size_t oldlen; 669 size_t oldlen;
667 int __user *namep; 670 int __user *namep;
668 long ret; 671 long ret;
669 extern int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
670 void *newval, size_t newlen);
671
672 672
673 if (copy_from_user(&a32, args32, sizeof (a32))) 673 if (copy_from_user(&a32, args32, sizeof (a32)))
674 return -EFAULT; 674 return -EFAULT;
@@ -692,7 +692,8 @@ sys32_sysctl(struct sysctl_ia32 __user *args32)
692 692
693 set_fs(KERNEL_DS); 693 set_fs(KERNEL_DS);
694 lock_kernel(); 694 lock_kernel();
695 ret = do_sysctl(namep, a32.nlen, oldvalp, &oldlen, newvalp, (size_t) a32.newlen); 695 ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *)&oldlen,
696 newvalp, (size_t) a32.newlen);
696 unlock_kernel(); 697 unlock_kernel();
697 set_fs(old_fs); 698 set_fs(old_fs);
698 699
@@ -743,7 +744,8 @@ sys32_sendfile(int out_fd, int in_fd, compat_off_t __user *offset, s32 count)
743 return -EFAULT; 744 return -EFAULT;
744 745
745 set_fs(KERNEL_DS); 746 set_fs(KERNEL_DS);
746 ret = sys_sendfile(out_fd, in_fd, offset ? &of : NULL, count); 747 ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
748 count);
747 set_fs(old_fs); 749 set_fs(old_fs);
748 750
749 if (offset && put_user(of, offset)) 751 if (offset && put_user(of, offset))
@@ -778,7 +780,7 @@ asmlinkage long sys32_mmap2(unsigned long addr, unsigned long len,
778 780
779asmlinkage long sys32_olduname(struct oldold_utsname __user * name) 781asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
780{ 782{
781 int error; 783 int err;
782 784
783 if (!name) 785 if (!name)
784 return -EFAULT; 786 return -EFAULT;
@@ -787,27 +789,31 @@ asmlinkage long sys32_olduname(struct oldold_utsname __user * name)
787 789
788 down_read(&uts_sem); 790 down_read(&uts_sem);
789 791
790 error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN); 792 err = __copy_to_user(&name->sysname,&system_utsname.sysname,
791 __put_user(0,name->sysname+__OLD_UTS_LEN); 793 __OLD_UTS_LEN);
792 __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN); 794 err |= __put_user(0,name->sysname+__OLD_UTS_LEN);
793 __put_user(0,name->nodename+__OLD_UTS_LEN); 795 err |= __copy_to_user(&name->nodename,&system_utsname.nodename,
794 __copy_to_user(&name->release,&system_utsname.release,__OLD_UTS_LEN); 796 __OLD_UTS_LEN);
795 __put_user(0,name->release+__OLD_UTS_LEN); 797 err |= __put_user(0,name->nodename+__OLD_UTS_LEN);
796 __copy_to_user(&name->version,&system_utsname.version,__OLD_UTS_LEN); 798 err |= __copy_to_user(&name->release,&system_utsname.release,
797 __put_user(0,name->version+__OLD_UTS_LEN); 799 __OLD_UTS_LEN);
800 err |= __put_user(0,name->release+__OLD_UTS_LEN);
801 err |= __copy_to_user(&name->version,&system_utsname.version,
802 __OLD_UTS_LEN);
803 err |= __put_user(0,name->version+__OLD_UTS_LEN);
798 { 804 {
799 char *arch = "x86_64"; 805 char *arch = "x86_64";
800 if (personality(current->personality) == PER_LINUX32) 806 if (personality(current->personality) == PER_LINUX32)
801 arch = "i686"; 807 arch = "i686";
802 808
803 __copy_to_user(&name->machine,arch,strlen(arch)+1); 809 err |= __copy_to_user(&name->machine,arch,strlen(arch)+1);
804 } 810 }
805 811
806 up_read(&uts_sem); 812 up_read(&uts_sem);
807 813
808 error = error ? -EFAULT : 0; 814 err = err ? -EFAULT : 0;
809 815
810 return error; 816 return err;
811} 817}
812 818
813long sys32_uname(struct old_utsname __user * name) 819long sys32_uname(struct old_utsname __user * name)
@@ -831,7 +837,7 @@ long sys32_ustat(unsigned dev, struct ustat32 __user *u32p)
831 837
832 seg = get_fs(); 838 seg = get_fs();
833 set_fs(KERNEL_DS); 839 set_fs(KERNEL_DS);
834 ret = sys_ustat(dev,&u); 840 ret = sys_ustat(dev, (struct ustat __user *)&u);
835 set_fs(seg); 841 set_fs(seg);
836 if (ret >= 0) { 842 if (ret >= 0) {
837 if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) || 843 if (!access_ok(VERIFY_WRITE,u32p,sizeof(struct ustat32)) ||
diff --git a/arch/x86_64/kernel/Makefile b/arch/x86_64/kernel/Makefile
index b5aaeafc1cd3..3c7cbff04d3d 100644
--- a/arch/x86_64/kernel/Makefile
+++ b/arch/x86_64/kernel/Makefile
@@ -11,7 +11,7 @@ obj-y := process.o signal.o entry.o traps.o irq.o \
11 pci-dma.o pci-nommu.o alternative.o 11 pci-dma.o pci-nommu.o alternative.o
12 12
13obj-$(CONFIG_STACKTRACE) += stacktrace.o 13obj-$(CONFIG_STACKTRACE) += stacktrace.o
14obj-$(CONFIG_X86_MCE) += mce.o 14obj-$(CONFIG_X86_MCE) += mce.o therm_throt.o
15obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o 15obj-$(CONFIG_X86_MCE_INTEL) += mce_intel.o
16obj-$(CONFIG_X86_MCE_AMD) += mce_amd.o 16obj-$(CONFIG_X86_MCE_AMD) += mce_amd.o
17obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/ 17obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/
@@ -20,8 +20,8 @@ obj-$(CONFIG_X86_MSR) += msr.o
20obj-$(CONFIG_MICROCODE) += microcode.o 20obj-$(CONFIG_MICROCODE) += microcode.o
21obj-$(CONFIG_X86_CPUID) += cpuid.o 21obj-$(CONFIG_X86_CPUID) += cpuid.o
22obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o 22obj-$(CONFIG_SMP) += smp.o smpboot.o trampoline.o
23obj-$(CONFIG_X86_LOCAL_APIC) += apic.o nmi.o 23obj-y += apic.o nmi.o
24obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o \ 24obj-y += io_apic.o mpparse.o \
25 genapic.o genapic_cluster.o genapic_flat.o 25 genapic.o genapic_cluster.o genapic_flat.o
26obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o 26obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o
27obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 27obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
@@ -39,12 +39,14 @@ obj-$(CONFIG_K8_NB) += k8.o
39obj-$(CONFIG_AUDIT) += audit.o 39obj-$(CONFIG_AUDIT) += audit.o
40 40
41obj-$(CONFIG_MODULES) += module.o 41obj-$(CONFIG_MODULES) += module.o
42obj-$(CONFIG_PCI) += early-quirks.o
42 43
43obj-y += topology.o 44obj-y += topology.o
44obj-y += intel_cacheinfo.o 45obj-y += intel_cacheinfo.o
45 46
46CFLAGS_vsyscall.o := $(PROFILING) -g0 47CFLAGS_vsyscall.o := $(PROFILING) -g0
47 48
49therm_throt-y += ../../i386/kernel/cpu/mcheck/therm_throt.o
48bootflag-y += ../../i386/kernel/bootflag.o 50bootflag-y += ../../i386/kernel/bootflag.o
49cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o 51cpuid-$(subst m,y,$(CONFIG_X86_CPUID)) += ../../i386/kernel/cpuid.o
50topology-y += ../../i386/kernel/topology.o 52topology-y += ../../i386/kernel/topology.o
@@ -54,4 +56,3 @@ quirks-y += ../../i386/kernel/quirks.o
54i8237-y += ../../i386/kernel/i8237.o 56i8237-y += ../../i386/kernel/i8237.o
55msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o 57msr-$(subst m,y,$(CONFIG_X86_MSR)) += ../../i386/kernel/msr.o
56alternative-y += ../../i386/kernel/alternative.o 58alternative-y += ../../i386/kernel/alternative.o
57
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index 58af8e73738b..b487396c4c5b 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -17,6 +17,7 @@
17#include <linux/pci_ids.h> 17#include <linux/pci_ids.h>
18#include <linux/pci.h> 18#include <linux/pci.h>
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/ioport.h>
20#include <asm/e820.h> 21#include <asm/e820.h>
21#include <asm/io.h> 22#include <asm/io.h>
22#include <asm/proto.h> 23#include <asm/proto.h>
@@ -33,6 +34,18 @@ int fallback_aper_force __initdata = 0;
33 34
34int fix_aperture __initdata = 1; 35int fix_aperture __initdata = 1;
35 36
37static struct resource gart_resource = {
38 .name = "GART",
39 .flags = IORESOURCE_MEM,
40};
41
42static void __init insert_aperture_resource(u32 aper_base, u32 aper_size)
43{
44 gart_resource.start = aper_base;
45 gart_resource.end = aper_base + aper_size - 1;
46 insert_resource(&iomem_resource, &gart_resource);
47}
48
36/* This code runs before the PCI subsystem is initialized, so just 49/* This code runs before the PCI subsystem is initialized, so just
37 access the northbridge directly. */ 50 access the northbridge directly. */
38 51
@@ -48,7 +61,7 @@ static u32 __init allocate_aperture(void)
48 61
49 /* 62 /*
50 * Aperture has to be naturally aligned. This means an 2GB aperture won't 63 * Aperture has to be naturally aligned. This means an 2GB aperture won't
51 * have much chances to find a place in the lower 4GB of memory. 64 * have much chance of finding a place in the lower 4GB of memory.
52 * Unfortunately we cannot move it up because that would make the 65 * Unfortunately we cannot move it up because that would make the
53 * IOMMU useless. 66 * IOMMU useless.
54 */ 67 */
@@ -62,6 +75,7 @@ static u32 __init allocate_aperture(void)
62 } 75 }
63 printk("Mapping aperture over %d KB of RAM @ %lx\n", 76 printk("Mapping aperture over %d KB of RAM @ %lx\n",
64 aper_size >> 10, __pa(p)); 77 aper_size >> 10, __pa(p));
78 insert_aperture_resource((u32)__pa(p), aper_size);
65 return (u32)__pa(p); 79 return (u32)__pa(p);
66} 80}
67 81
@@ -198,7 +212,7 @@ void __init iommu_hole_init(void)
198 u64 aper_base, last_aper_base = 0; 212 u64 aper_base, last_aper_base = 0;
199 int valid_agp = 0; 213 int valid_agp = 0;
200 214
201 if (iommu_aperture_disabled || !fix_aperture) 215 if (iommu_aperture_disabled || !fix_aperture || !early_pci_allowed())
202 return; 216 return;
203 217
204 printk("Checking aperture...\n"); 218 printk("Checking aperture...\n");
@@ -233,8 +247,13 @@ void __init iommu_hole_init(void)
233 last_aper_base = aper_base; 247 last_aper_base = aper_base;
234 } 248 }
235 249
236 if (!fix && !fallback_aper_force) 250 if (!fix && !fallback_aper_force) {
251 if (last_aper_base) {
252 unsigned long n = (32 * 1024 * 1024) << last_aper_order;
253 insert_aperture_resource((u32)last_aper_base, n);
254 }
237 return; 255 return;
256 }
238 257
239 if (!fallback_aper_force) 258 if (!fallback_aper_force)
240 aper_alloc = search_agp_bridge(&aper_order, &valid_agp); 259 aper_alloc = search_agp_bridge(&aper_order, &valid_agp);
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 2b8cef037a65..135ff25e6b44 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -25,6 +25,7 @@
25#include <linux/kernel_stat.h> 25#include <linux/kernel_stat.h>
26#include <linux/sysdev.h> 26#include <linux/sysdev.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/ioport.h>
28 29
29#include <asm/atomic.h> 30#include <asm/atomic.h>
30#include <asm/smp.h> 31#include <asm/smp.h>
@@ -36,13 +37,20 @@
36#include <asm/idle.h> 37#include <asm/idle.h>
37#include <asm/proto.h> 38#include <asm/proto.h>
38#include <asm/timex.h> 39#include <asm/timex.h>
40#include <asm/apic.h>
39 41
42int apic_mapped;
40int apic_verbosity; 43int apic_verbosity;
41int apic_runs_main_timer; 44int apic_runs_main_timer;
42int apic_calibrate_pmtmr __initdata; 45int apic_calibrate_pmtmr __initdata;
43 46
44int disable_apic_timer __initdata; 47int disable_apic_timer __initdata;
45 48
49static struct resource lapic_resource = {
50 .name = "Local APIC",
51 .flags = IORESOURCE_MEM | IORESOURCE_BUSY,
52};
53
46/* 54/*
47 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as 55 * cpu_mask that denotes the CPUs that needs timer interrupt coming in as
48 * IPIs in place of local APIC timers 56 * IPIs in place of local APIC timers
@@ -136,72 +144,40 @@ void clear_local_APIC(void)
136 apic_read(APIC_ESR); 144 apic_read(APIC_ESR);
137} 145}
138 146
139void __init connect_bsp_APIC(void)
140{
141 if (pic_mode) {
142 /*
143 * Do not trust the local APIC being empty at bootup.
144 */
145 clear_local_APIC();
146 /*
147 * PIC mode, enable APIC mode in the IMCR, i.e.
148 * connect BSP's local APIC to INT and NMI lines.
149 */
150 apic_printk(APIC_VERBOSE, "leaving PIC mode, enabling APIC mode.\n");
151 outb(0x70, 0x22);
152 outb(0x01, 0x23);
153 }
154}
155
156void disconnect_bsp_APIC(int virt_wire_setup) 147void disconnect_bsp_APIC(int virt_wire_setup)
157{ 148{
158 if (pic_mode) { 149 /* Go back to Virtual Wire compatibility mode */
159 /* 150 unsigned long value;
160 * Put the board back into PIC mode (has an effect 151
161 * only on certain older boards). Note that APIC 152 /* For the spurious interrupt use vector F, and enable it */
162 * interrupts, including IPIs, won't work beyond 153 value = apic_read(APIC_SPIV);
163 * this point! The only exception are INIT IPIs. 154 value &= ~APIC_VECTOR_MASK;
164 */ 155 value |= APIC_SPIV_APIC_ENABLED;
165 apic_printk(APIC_QUIET, "disabling APIC mode, entering PIC mode.\n"); 156 value |= 0xf;
166 outb(0x70, 0x22); 157 apic_write(APIC_SPIV, value);
167 outb(0x00, 0x23);
168 }
169 else {
170 /* Go back to Virtual Wire compatibility mode */
171 unsigned long value;
172
173 /* For the spurious interrupt use vector F, and enable it */
174 value = apic_read(APIC_SPIV);
175 value &= ~APIC_VECTOR_MASK;
176 value |= APIC_SPIV_APIC_ENABLED;
177 value |= 0xf;
178 apic_write(APIC_SPIV, value);
179
180 if (!virt_wire_setup) {
181 /* For LVT0 make it edge triggered, active high, external and enabled */
182 value = apic_read(APIC_LVT0);
183 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
184 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
185 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
186 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
187 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
188 apic_write(APIC_LVT0, value);
189 }
190 else {
191 /* Disable LVT0 */
192 apic_write(APIC_LVT0, APIC_LVT_MASKED);
193 }
194 158
195 /* For LVT1 make it edge triggered, active high, nmi and enabled */ 159 if (!virt_wire_setup) {
196 value = apic_read(APIC_LVT1); 160 /* For LVT0 make it edge triggered, active high, external and enabled */
197 value &= ~( 161 value = apic_read(APIC_LVT0);
198 APIC_MODE_MASK | APIC_SEND_PENDING | 162 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
199 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR | 163 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
200 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED); 164 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
201 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING; 165 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
202 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI); 166 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
203 apic_write(APIC_LVT1, value); 167 apic_write(APIC_LVT0, value);
168 } else {
169 /* Disable LVT0 */
170 apic_write(APIC_LVT0, APIC_LVT_MASKED);
204 } 171 }
172
173 /* For LVT1 make it edge triggered, active high, nmi and enabled */
174 value = apic_read(APIC_LVT1);
175 value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
176 APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
177 APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
178 value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
179 value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
180 apic_write(APIC_LVT1, value);
205} 181}
206 182
207void disable_local_APIC(void) 183void disable_local_APIC(void)
@@ -297,8 +273,6 @@ void __init sync_Arb_IDs(void)
297 | APIC_DM_INIT); 273 | APIC_DM_INIT);
298} 274}
299 275
300extern void __error_in_apic_c (void);
301
302/* 276/*
303 * An initial setup of the virtual wire mode. 277 * An initial setup of the virtual wire mode.
304 */ 278 */
@@ -345,8 +319,7 @@ void __cpuinit setup_local_APIC (void)
345 319
346 value = apic_read(APIC_LVR); 320 value = apic_read(APIC_LVR);
347 321
348 if ((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f) 322 BUILD_BUG_ON((SPURIOUS_APIC_VECTOR & 0x0f) != 0x0f);
349 __error_in_apic_c();
350 323
351 /* 324 /*
352 * Double-check whether this APIC is really registered. 325 * Double-check whether this APIC is really registered.
@@ -399,32 +372,8 @@ void __cpuinit setup_local_APIC (void)
399 */ 372 */
400 value |= APIC_SPIV_APIC_ENABLED; 373 value |= APIC_SPIV_APIC_ENABLED;
401 374
402 /* 375 /* We always use processor focus */
403 * Some unknown Intel IO/APIC (or APIC) errata is biting us with 376
404 * certain networking cards. If high frequency interrupts are
405 * happening on a particular IOAPIC pin, plus the IOAPIC routing
406 * entry is masked/unmasked at a high rate as well then sooner or
407 * later IOAPIC line gets 'stuck', no more interrupts are received
408 * from the device. If focus CPU is disabled then the hang goes
409 * away, oh well :-(
410 *
411 * [ This bug can be reproduced easily with a level-triggered
412 * PCI Ne2000 networking cards and PII/PIII processors, dual
413 * BX chipset. ]
414 */
415 /*
416 * Actually disabling the focus CPU check just makes the hang less
417 * frequent as it makes the interrupt distributon model be more
418 * like LRU than MRU (the short-term load is more even across CPUs).
419 * See also the comment in end_level_ioapic_irq(). --macro
420 */
421#if 1
422 /* Enable focus processor (bit==0) */
423 value &= ~APIC_SPIV_FOCUS_DISABLED;
424#else
425 /* Disable focus processor (bit==1) */
426 value |= APIC_SPIV_FOCUS_DISABLED;
427#endif
428 /* 377 /*
429 * Set spurious IRQ vector 378 * Set spurious IRQ vector
430 */ 379 */
@@ -442,7 +391,7 @@ void __cpuinit setup_local_APIC (void)
442 * TODO: set up through-local-APIC from through-I/O-APIC? --macro 391 * TODO: set up through-local-APIC from through-I/O-APIC? --macro
443 */ 392 */
444 value = apic_read(APIC_LVT0) & APIC_LVT_MASKED; 393 value = apic_read(APIC_LVT0) & APIC_LVT_MASKED;
445 if (!smp_processor_id() && (pic_mode || !value)) { 394 if (!smp_processor_id() && !value) {
446 value = APIC_DM_EXTINT; 395 value = APIC_DM_EXTINT;
447 apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", smp_processor_id()); 396 apic_printk(APIC_VERBOSE, "enabled ExtINT on CPU#%d\n", smp_processor_id());
448 } else { 397 } else {
@@ -479,8 +428,7 @@ void __cpuinit setup_local_APIC (void)
479 } 428 }
480 429
481 nmi_watchdog_default(); 430 nmi_watchdog_default();
482 if (nmi_watchdog == NMI_LOCAL_APIC) 431 setup_apic_nmi_watchdog(NULL);
483 setup_apic_nmi_watchdog();
484 apic_pm_activate(); 432 apic_pm_activate();
485} 433}
486 434
@@ -527,8 +475,7 @@ static int lapic_suspend(struct sys_device *dev, pm_message_t state)
527 apic_pm_state.apic_tmict = apic_read(APIC_TMICT); 475 apic_pm_state.apic_tmict = apic_read(APIC_TMICT);
528 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR); 476 apic_pm_state.apic_tdcr = apic_read(APIC_TDCR);
529 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR); 477 apic_pm_state.apic_thmr = apic_read(APIC_LVTTHMR);
530 local_save_flags(flags); 478 local_irq_save(flags);
531 local_irq_disable();
532 disable_local_APIC(); 479 disable_local_APIC();
533 local_irq_restore(flags); 480 local_irq_restore(flags);
534 return 0; 481 return 0;
@@ -606,18 +553,24 @@ static void apic_pm_activate(void) { }
606 553
607static int __init apic_set_verbosity(char *str) 554static int __init apic_set_verbosity(char *str)
608{ 555{
556 if (str == NULL) {
557 skip_ioapic_setup = 0;
558 ioapic_force = 1;
559 return 0;
560 }
609 if (strcmp("debug", str) == 0) 561 if (strcmp("debug", str) == 0)
610 apic_verbosity = APIC_DEBUG; 562 apic_verbosity = APIC_DEBUG;
611 else if (strcmp("verbose", str) == 0) 563 else if (strcmp("verbose", str) == 0)
612 apic_verbosity = APIC_VERBOSE; 564 apic_verbosity = APIC_VERBOSE;
613 else 565 else {
614 printk(KERN_WARNING "APIC Verbosity level %s not recognised" 566 printk(KERN_WARNING "APIC Verbosity level %s not recognised"
615 " use apic=verbose or apic=debug", str); 567 " use apic=verbose or apic=debug\n", str);
568 return -EINVAL;
569 }
616 570
617 return 1; 571 return 0;
618} 572}
619 573early_param("apic", apic_set_verbosity);
620__setup("apic=", apic_set_verbosity);
621 574
622/* 575/*
623 * Detect and enable local APICs on non-SMP boards. 576 * Detect and enable local APICs on non-SMP boards.
@@ -638,6 +591,40 @@ static int __init detect_init_APIC (void)
638 return 0; 591 return 0;
639} 592}
640 593
594#ifdef CONFIG_X86_IO_APIC
595static struct resource * __init ioapic_setup_resources(void)
596{
597#define IOAPIC_RESOURCE_NAME_SIZE 11
598 unsigned long n;
599 struct resource *res;
600 char *mem;
601 int i;
602
603 if (nr_ioapics <= 0)
604 return NULL;
605
606 n = IOAPIC_RESOURCE_NAME_SIZE + sizeof(struct resource);
607 n *= nr_ioapics;
608
609 res = alloc_bootmem(n);
610
611 if (!res)
612 return NULL;
613
614 memset(res, 0, n);
615 mem = (void *)&res[nr_ioapics];
616
617 for (i = 0; i < nr_ioapics; i++) {
618 res[i].name = mem;
619 res[i].flags = IORESOURCE_MEM | IORESOURCE_BUSY;
620 snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i);
621 mem += IOAPIC_RESOURCE_NAME_SIZE;
622 }
623
624 return res;
625}
626#endif
627
641void __init init_apic_mappings(void) 628void __init init_apic_mappings(void)
642{ 629{
643 unsigned long apic_phys; 630 unsigned long apic_phys;
@@ -654,19 +641,26 @@ void __init init_apic_mappings(void)
654 apic_phys = mp_lapic_addr; 641 apic_phys = mp_lapic_addr;
655 642
656 set_fixmap_nocache(FIX_APIC_BASE, apic_phys); 643 set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
644 apic_mapped = 1;
657 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys); 645 apic_printk(APIC_VERBOSE,"mapped APIC to %16lx (%16lx)\n", APIC_BASE, apic_phys);
658 646
647 /* Put local APIC into the resource map. */
648 lapic_resource.start = apic_phys;
649 lapic_resource.end = lapic_resource.start + PAGE_SIZE - 1;
650 insert_resource(&iomem_resource, &lapic_resource);
651
659 /* 652 /*
660 * Fetch the APIC ID of the BSP in case we have a 653 * Fetch the APIC ID of the BSP in case we have a
661 * default configuration (or the MP table is broken). 654 * default configuration (or the MP table is broken).
662 */ 655 */
663 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID)); 656 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
664 657
665#ifdef CONFIG_X86_IO_APIC
666 { 658 {
667 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0; 659 unsigned long ioapic_phys, idx = FIX_IO_APIC_BASE_0;
668 int i; 660 int i;
661 struct resource *ioapic_res;
669 662
663 ioapic_res = ioapic_setup_resources();
670 for (i = 0; i < nr_ioapics; i++) { 664 for (i = 0; i < nr_ioapics; i++) {
671 if (smp_found_config) { 665 if (smp_found_config) {
672 ioapic_phys = mp_ioapics[i].mpc_apicaddr; 666 ioapic_phys = mp_ioapics[i].mpc_apicaddr;
@@ -678,9 +672,15 @@ void __init init_apic_mappings(void)
678 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n", 672 apic_printk(APIC_VERBOSE,"mapped IOAPIC to %016lx (%016lx)\n",
679 __fix_to_virt(idx), ioapic_phys); 673 __fix_to_virt(idx), ioapic_phys);
680 idx++; 674 idx++;
675
676 if (ioapic_res) {
677 ioapic_res->start = ioapic_phys;
678 ioapic_res->end = ioapic_phys + (4 * 1024) - 1;
679 insert_resource(&iomem_resource, ioapic_res);
680 ioapic_res++;
681 }
681 } 682 }
682 } 683 }
683#endif
684} 684}
685 685
686/* 686/*
@@ -951,7 +951,7 @@ void smp_local_timer_interrupt(struct pt_regs *regs)
951 * We take the 'long' return path, and there every subsystem 951 * We take the 'long' return path, and there every subsystem
952 * grabs the appropriate locks (kernel lock/ irq lock). 952 * grabs the appropriate locks (kernel lock/ irq lock).
953 * 953 *
954 * we might want to decouple profiling from the 'long path', 954 * We might want to decouple profiling from the 'long path',
955 * and do the profiling totally in assembly. 955 * and do the profiling totally in assembly.
956 * 956 *
957 * Currently this isn't too much of an issue (performance wise), 957 * Currently this isn't too much of an issue (performance wise),
@@ -1123,19 +1123,15 @@ int __init APIC_init_uniprocessor (void)
1123 1123
1124 verify_local_APIC(); 1124 verify_local_APIC();
1125 1125
1126 connect_bsp_APIC();
1127
1128 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id); 1126 phys_cpu_present_map = physid_mask_of_physid(boot_cpu_id);
1129 apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id)); 1127 apic_write(APIC_ID, SET_APIC_ID(boot_cpu_id));
1130 1128
1131 setup_local_APIC(); 1129 setup_local_APIC();
1132 1130
1133#ifdef CONFIG_X86_IO_APIC
1134 if (smp_found_config && !skip_ioapic_setup && nr_ioapics) 1131 if (smp_found_config && !skip_ioapic_setup && nr_ioapics)
1135 setup_IO_APIC(); 1132 setup_IO_APIC();
1136 else 1133 else
1137 nr_ioapics = 0; 1134 nr_ioapics = 0;
1138#endif
1139 setup_boot_APIC_clock(); 1135 setup_boot_APIC_clock();
1140 check_nmi_watchdog(); 1136 check_nmi_watchdog();
1141 return 0; 1137 return 0;
@@ -1144,14 +1140,17 @@ int __init APIC_init_uniprocessor (void)
1144static __init int setup_disableapic(char *str) 1140static __init int setup_disableapic(char *str)
1145{ 1141{
1146 disable_apic = 1; 1142 disable_apic = 1;
1147 return 1; 1143 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
1148} 1144 return 0;
1145}
1146early_param("disableapic", setup_disableapic);
1149 1147
1148/* same as disableapic, for compatibility */
1150static __init int setup_nolapic(char *str) 1149static __init int setup_nolapic(char *str)
1151{ 1150{
1152 disable_apic = 1; 1151 return setup_disableapic(str);
1153 return 1;
1154} 1152}
1153early_param("nolapic", setup_nolapic);
1155 1154
1156static __init int setup_noapictimer(char *str) 1155static __init int setup_noapictimer(char *str)
1157{ 1156{
@@ -1184,11 +1183,5 @@ static __init int setup_apicpmtimer(char *s)
1184} 1183}
1185__setup("apicpmtimer", setup_apicpmtimer); 1184__setup("apicpmtimer", setup_apicpmtimer);
1186 1185
1187/* dummy parsing: see setup.c */
1188
1189__setup("disableapic", setup_disableapic);
1190__setup("nolapic", setup_nolapic); /* same as disableapic, for compatibility */
1191
1192__setup("noapictimer", setup_noapictimer); 1186__setup("noapictimer", setup_noapictimer);
1193 1187
1194/* no "lapic" flag - we only use the lapic when the BIOS tells us so. */
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index d8d5750d6106..3525f884af82 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -23,6 +23,7 @@
23#include <asm/nmi.h> 23#include <asm/nmi.h>
24#include <asm/hw_irq.h> 24#include <asm/hw_irq.h>
25#include <asm/mach_apic.h> 25#include <asm/mach_apic.h>
26#include <asm/kdebug.h>
26 27
27/* This keeps a track of which one is crashing cpu. */ 28/* This keeps a track of which one is crashing cpu. */
28static int crashing_cpu; 29static int crashing_cpu;
@@ -68,7 +69,7 @@ static void crash_save_this_cpu(struct pt_regs *regs, int cpu)
68 * for the data I pass, and I need tags 69 * for the data I pass, and I need tags
69 * on the data to indicate what information I have 70 * on the data to indicate what information I have
70 * squirrelled away. ELF notes happen to provide 71 * squirrelled away. ELF notes happen to provide
71 * all of that that no need to invent something new. 72 * all of that, no need to invent something new.
72 */ 73 */
73 74
74 buf = (u32*)per_cpu_ptr(crash_notes, cpu); 75 buf = (u32*)per_cpu_ptr(crash_notes, cpu);
@@ -95,15 +96,25 @@ static void crash_save_self(struct pt_regs *regs)
95#ifdef CONFIG_SMP 96#ifdef CONFIG_SMP
96static atomic_t waiting_for_crash_ipi; 97static atomic_t waiting_for_crash_ipi;
97 98
98static int crash_nmi_callback(struct pt_regs *regs, int cpu) 99static int crash_nmi_callback(struct notifier_block *self,
100 unsigned long val, void *data)
99{ 101{
102 struct pt_regs *regs;
103 int cpu;
104
105 if (val != DIE_NMI_IPI)
106 return NOTIFY_OK;
107
108 regs = ((struct die_args *)data)->regs;
109 cpu = raw_smp_processor_id();
110
100 /* 111 /*
101 * Don't do anything if this handler is invoked on crashing cpu. 112 * Don't do anything if this handler is invoked on crashing cpu.
102 * Otherwise, system will completely hang. Crashing cpu can get 113 * Otherwise, system will completely hang. Crashing cpu can get
103 * an NMI if system was initially booted with nmi_watchdog parameter. 114 * an NMI if system was initially booted with nmi_watchdog parameter.
104 */ 115 */
105 if (cpu == crashing_cpu) 116 if (cpu == crashing_cpu)
106 return 1; 117 return NOTIFY_STOP;
107 local_irq_disable(); 118 local_irq_disable();
108 119
109 crash_save_this_cpu(regs, cpu); 120 crash_save_this_cpu(regs, cpu);
@@ -127,12 +138,17 @@ static void smp_send_nmi_allbutself(void)
127 * cpu hotplug shouldn't matter. 138 * cpu hotplug shouldn't matter.
128 */ 139 */
129 140
141static struct notifier_block crash_nmi_nb = {
142 .notifier_call = crash_nmi_callback,
143};
144
130static void nmi_shootdown_cpus(void) 145static void nmi_shootdown_cpus(void)
131{ 146{
132 unsigned long msecs; 147 unsigned long msecs;
133 148
134 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); 149 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
135 set_nmi_callback(crash_nmi_callback); 150 if (register_die_notifier(&crash_nmi_nb))
151 return; /* return what? */
136 152
137 /* 153 /*
138 * Ensure the new callback function is set before sending 154 * Ensure the new callback function is set before sending
@@ -178,9 +194,7 @@ void machine_crash_shutdown(struct pt_regs *regs)
178 if(cpu_has_apic) 194 if(cpu_has_apic)
179 disable_local_APIC(); 195 disable_local_APIC();
180 196
181#if defined(CONFIG_X86_IO_APIC)
182 disable_IO_APIC(); 197 disable_IO_APIC();
183#endif
184 198
185 crash_save_self(regs); 199 crash_save_self(regs);
186} 200}
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 708a3cd9a27e..b3f0908668ec 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -25,6 +25,8 @@
25#include <asm/bootsetup.h> 25#include <asm/bootsetup.h>
26#include <asm/sections.h> 26#include <asm/sections.h>
27 27
28struct e820map e820 __initdata;
29
28/* 30/*
29 * PFN of last memory page. 31 * PFN of last memory page.
30 */ 32 */
@@ -41,7 +43,7 @@ unsigned long end_pfn_map;
41/* 43/*
42 * Last pfn which the user wants to use. 44 * Last pfn which the user wants to use.
43 */ 45 */
44unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT; 46static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT;
45 47
46extern struct resource code_resource, data_resource; 48extern struct resource code_resource, data_resource;
47 49
@@ -70,12 +72,7 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
70 return 1; 72 return 1;
71 } 73 }
72#endif 74#endif
73 /* kernel code + 640k memory hole (later should not be needed, but 75 /* kernel code */
74 be paranoid for now) */
75 if (last >= 640*1024 && addr < 1024*1024) {
76 *addrp = 1024*1024;
77 return 1;
78 }
79 if (last >= __pa_symbol(&_text) && last < __pa_symbol(&_end)) { 76 if (last >= __pa_symbol(&_text) && last < __pa_symbol(&_end)) {
80 *addrp = __pa_symbol(&_end); 77 *addrp = __pa_symbol(&_end);
81 return 1; 78 return 1;
@@ -165,59 +162,14 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi
165 return -1UL; 162 return -1UL;
166} 163}
167 164
168/*
169 * Free bootmem based on the e820 table for a node.
170 */
171void __init e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end)
172{
173 int i;
174 for (i = 0; i < e820.nr_map; i++) {
175 struct e820entry *ei = &e820.map[i];
176 unsigned long last, addr;
177
178 if (ei->type != E820_RAM ||
179 ei->addr+ei->size <= start ||
180 ei->addr >= end)
181 continue;
182
183 addr = round_up(ei->addr, PAGE_SIZE);
184 if (addr < start)
185 addr = start;
186
187 last = round_down(ei->addr + ei->size, PAGE_SIZE);
188 if (last >= end)
189 last = end;
190
191 if (last > addr && last-addr >= PAGE_SIZE)
192 free_bootmem_node(pgdat, addr, last-addr);
193 }
194}
195
196/* 165/*
197 * Find the highest page frame number we have available 166 * Find the highest page frame number we have available
198 */ 167 */
199unsigned long __init e820_end_of_ram(void) 168unsigned long __init e820_end_of_ram(void)
200{ 169{
201 int i;
202 unsigned long end_pfn = 0; 170 unsigned long end_pfn = 0;
171 end_pfn = find_max_pfn_with_active_regions();
203 172
204 for (i = 0; i < e820.nr_map; i++) {
205 struct e820entry *ei = &e820.map[i];
206 unsigned long start, end;
207
208 start = round_up(ei->addr, PAGE_SIZE);
209 end = round_down(ei->addr + ei->size, PAGE_SIZE);
210 if (start >= end)
211 continue;
212 if (ei->type == E820_RAM) {
213 if (end > end_pfn<<PAGE_SHIFT)
214 end_pfn = end>>PAGE_SHIFT;
215 } else {
216 if (end > end_pfn_map<<PAGE_SHIFT)
217 end_pfn_map = end>>PAGE_SHIFT;
218 }
219 }
220
221 if (end_pfn > end_pfn_map) 173 if (end_pfn > end_pfn_map)
222 end_pfn_map = end_pfn; 174 end_pfn_map = end_pfn;
223 if (end_pfn_map > MAXMEM>>PAGE_SHIFT) 175 if (end_pfn_map > MAXMEM>>PAGE_SHIFT)
@@ -227,43 +179,10 @@ unsigned long __init e820_end_of_ram(void)
227 if (end_pfn > end_pfn_map) 179 if (end_pfn > end_pfn_map)
228 end_pfn = end_pfn_map; 180 end_pfn = end_pfn_map;
229 181
182 printk("end_pfn_map = %lu\n", end_pfn_map);
230 return end_pfn; 183 return end_pfn;
231} 184}
232 185
233/*
234 * Compute how much memory is missing in a range.
235 * Unlike the other functions in this file the arguments are in page numbers.
236 */
237unsigned long __init
238e820_hole_size(unsigned long start_pfn, unsigned long end_pfn)
239{
240 unsigned long ram = 0;
241 unsigned long start = start_pfn << PAGE_SHIFT;
242 unsigned long end = end_pfn << PAGE_SHIFT;
243 int i;
244 for (i = 0; i < e820.nr_map; i++) {
245 struct e820entry *ei = &e820.map[i];
246 unsigned long last, addr;
247
248 if (ei->type != E820_RAM ||
249 ei->addr+ei->size <= start ||
250 ei->addr >= end)
251 continue;
252
253 addr = round_up(ei->addr, PAGE_SIZE);
254 if (addr < start)
255 addr = start;
256
257 last = round_down(ei->addr + ei->size, PAGE_SIZE);
258 if (last >= end)
259 last = end;
260
261 if (last > addr)
262 ram += last - addr;
263 }
264 return ((end - start) - ram) >> PAGE_SHIFT;
265}
266
267/* 186/*
268 * Mark e820 reserved areas as busy for the resource manager. 187 * Mark e820 reserved areas as busy for the resource manager.
269 */ 188 */
@@ -345,6 +264,49 @@ void __init e820_mark_nosave_regions(void)
345 } 264 }
346} 265}
347 266
267/* Walk the e820 map and register active regions within a node */
268void __init
269e820_register_active_regions(int nid, unsigned long start_pfn,
270 unsigned long end_pfn)
271{
272 int i;
273 unsigned long ei_startpfn, ei_endpfn;
274 for (i = 0; i < e820.nr_map; i++) {
275 struct e820entry *ei = &e820.map[i];
276 ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
277 ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE)
278 >> PAGE_SHIFT;
279
280 /* Skip map entries smaller than a page */
281 if (ei_startpfn > ei_endpfn)
282 continue;
283
284 /* Check if end_pfn_map should be updated */
285 if (ei->type != E820_RAM && ei_endpfn > end_pfn_map)
286 end_pfn_map = ei_endpfn;
287
288 /* Skip if map is outside the node */
289 if (ei->type != E820_RAM ||
290 ei_endpfn <= start_pfn ||
291 ei_startpfn >= end_pfn)
292 continue;
293
294 /* Check for overlaps */
295 if (ei_startpfn < start_pfn)
296 ei_startpfn = start_pfn;
297 if (ei_endpfn > end_pfn)
298 ei_endpfn = end_pfn;
299
300 /* Obey end_user_pfn to save on memmap */
301 if (ei_startpfn >= end_user_pfn)
302 continue;
303 if (ei_endpfn > end_user_pfn)
304 ei_endpfn = end_user_pfn;
305
306 add_active_range(nid, ei_startpfn, ei_endpfn);
307 }
308}
309
348/* 310/*
349 * Add a memory region to the kernel e820 map. 311 * Add a memory region to the kernel e820 map.
350 */ 312 */
@@ -565,13 +527,6 @@ static int __init sanitize_e820_map(struct e820entry * biosmap, char * pnr_map)
565 * If we're lucky and live on a modern system, the setup code 527 * If we're lucky and live on a modern system, the setup code
566 * will have given us a memory map that we can use to properly 528 * will have given us a memory map that we can use to properly
567 * set up memory. If we aren't, we'll fake a memory map. 529 * set up memory. If we aren't, we'll fake a memory map.
568 *
569 * We check to see that the memory map contains at least 2 elements
570 * before we'll use it, because the detection code in setup.S may
571 * not be perfect and most every PC known to man has two memory
572 * regions: one from 0 to 640k, and one from 1mb up. (The IBM
573 * thinkpad 560x, for example, does not cooperate with the memory
574 * detection code.)
575 */ 530 */
576static int __init copy_e820_map(struct e820entry * biosmap, int nr_map) 531static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
577{ 532{
@@ -589,34 +544,19 @@ static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
589 if (start > end) 544 if (start > end)
590 return -1; 545 return -1;
591 546
592 /*
593 * Some BIOSes claim RAM in the 640k - 1M region.
594 * Not right. Fix it up.
595 *
596 * This should be removed on Hammer which is supposed to not
597 * have non e820 covered ISA mappings there, but I had some strange
598 * problems so it stays for now. -AK
599 */
600 if (type == E820_RAM) {
601 if (start < 0x100000ULL && end > 0xA0000ULL) {
602 if (start < 0xA0000ULL)
603 add_memory_region(start, 0xA0000ULL-start, type);
604 if (end <= 0x100000ULL)
605 continue;
606 start = 0x100000ULL;
607 size = end - start;
608 }
609 }
610
611 add_memory_region(start, size, type); 547 add_memory_region(start, size, type);
612 } while (biosmap++,--nr_map); 548 } while (biosmap++,--nr_map);
613 return 0; 549 return 0;
614} 550}
615 551
616void __init setup_memory_region(void) 552void early_panic(char *msg)
617{ 553{
618 char *who = "BIOS-e820"; 554 early_printk(msg);
555 panic(msg);
556}
619 557
558void __init setup_memory_region(void)
559{
620 /* 560 /*
621 * Try to copy the BIOS-supplied E820-map. 561 * Try to copy the BIOS-supplied E820-map.
622 * 562 *
@@ -624,51 +564,70 @@ void __init setup_memory_region(void)
624 * the next section from 1mb->appropriate_mem_k 564 * the next section from 1mb->appropriate_mem_k
625 */ 565 */
626 sanitize_e820_map(E820_MAP, &E820_MAP_NR); 566 sanitize_e820_map(E820_MAP, &E820_MAP_NR);
627 if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0) { 567 if (copy_e820_map(E820_MAP, E820_MAP_NR) < 0)
628 unsigned long mem_size; 568 early_panic("Cannot find a valid memory map");
629
630 /* compare results from other methods and take the greater */
631 if (ALT_MEM_K < EXT_MEM_K) {
632 mem_size = EXT_MEM_K;
633 who = "BIOS-88";
634 } else {
635 mem_size = ALT_MEM_K;
636 who = "BIOS-e801";
637 }
638
639 e820.nr_map = 0;
640 add_memory_region(0, LOWMEMSIZE(), E820_RAM);
641 add_memory_region(HIGH_MEMORY, mem_size << 10, E820_RAM);
642 }
643 printk(KERN_INFO "BIOS-provided physical RAM map:\n"); 569 printk(KERN_INFO "BIOS-provided physical RAM map:\n");
644 e820_print_map(who); 570 e820_print_map("BIOS-e820");
645} 571}
646 572
647void __init parse_memopt(char *p, char **from) 573static int __init parse_memopt(char *p)
648{ 574{
649 end_user_pfn = memparse(p, from); 575 if (!p)
576 return -EINVAL;
577 end_user_pfn = memparse(p, &p);
650 end_user_pfn >>= PAGE_SHIFT; 578 end_user_pfn >>= PAGE_SHIFT;
579 return 0;
651} 580}
581early_param("mem", parse_memopt);
652 582
653void __init parse_memmapopt(char *p, char **from) 583static int userdef __initdata;
584
585static int __init parse_memmap_opt(char *p)
654{ 586{
587 char *oldp;
655 unsigned long long start_at, mem_size; 588 unsigned long long start_at, mem_size;
656 589
657 mem_size = memparse(p, from); 590 if (!strcmp(p, "exactmap")) {
658 p = *from; 591#ifdef CONFIG_CRASH_DUMP
592 /* If we are doing a crash dump, we
593 * still need to know the real mem
594 * size before original memory map is
595 * reset.
596 */
597 saved_max_pfn = e820_end_of_ram();
598#endif
599 end_pfn_map = 0;
600 e820.nr_map = 0;
601 userdef = 1;
602 return 0;
603 }
604
605 oldp = p;
606 mem_size = memparse(p, &p);
607 if (p == oldp)
608 return -EINVAL;
659 if (*p == '@') { 609 if (*p == '@') {
660 start_at = memparse(p+1, from); 610 start_at = memparse(p+1, &p);
661 add_memory_region(start_at, mem_size, E820_RAM); 611 add_memory_region(start_at, mem_size, E820_RAM);
662 } else if (*p == '#') { 612 } else if (*p == '#') {
663 start_at = memparse(p+1, from); 613 start_at = memparse(p+1, &p);
664 add_memory_region(start_at, mem_size, E820_ACPI); 614 add_memory_region(start_at, mem_size, E820_ACPI);
665 } else if (*p == '$') { 615 } else if (*p == '$') {
666 start_at = memparse(p+1, from); 616 start_at = memparse(p+1, &p);
667 add_memory_region(start_at, mem_size, E820_RESERVED); 617 add_memory_region(start_at, mem_size, E820_RESERVED);
668 } else { 618 } else {
669 end_user_pfn = (mem_size >> PAGE_SHIFT); 619 end_user_pfn = (mem_size >> PAGE_SHIFT);
670 } 620 }
671 p = *from; 621 return *p == '\0' ? 0 : -EINVAL;
622}
623early_param("memmap", parse_memmap_opt);
624
625void finish_e820_parsing(void)
626{
627 if (userdef) {
628 printk(KERN_INFO "user-defined physical RAM map:\n");
629 e820_print_map("user");
630 }
672} 631}
673 632
674unsigned long pci_mem_start = 0xaeedbabe; 633unsigned long pci_mem_start = 0xaeedbabe;
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
new file mode 100644
index 000000000000..208e38a372c1
--- /dev/null
+++ b/arch/x86_64/kernel/early-quirks.c
@@ -0,0 +1,122 @@
1/* Various workarounds for chipset bugs.
2 This code runs very early and can't use the regular PCI subsystem
3 The entries are keyed to PCI bridges which usually identify chipsets
4 uniquely.
5 This is only for whole classes of chipsets with specific problems which
6 need early invasive action (e.g. before the timers are initialized).
7 Most PCI device specific workarounds can be done later and should be
8 in standard PCI quirks
9 Mainboard specific bugs should be handled by DMI entries.
10 CPU specific bugs in setup.c */
11
12#include <linux/pci.h>
13#include <linux/acpi.h>
14#include <linux/pci_ids.h>
15#include <asm/pci-direct.h>
16#include <asm/proto.h>
17#include <asm/dma.h>
18
19static void via_bugs(void)
20{
21#ifdef CONFIG_IOMMU
22 if ((end_pfn > MAX_DMA32_PFN || force_iommu) &&
23 !iommu_aperture_allowed) {
24 printk(KERN_INFO
25 "Looks like a VIA chipset. Disabling IOMMU. Override with iommu=allowed\n");
26 iommu_aperture_disabled = 1;
27 }
28#endif
29}
30
31#ifdef CONFIG_ACPI
32
33static int nvidia_hpet_detected __initdata;
34
35static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
36{
37 nvidia_hpet_detected = 1;
38 return 0;
39}
40#endif
41
42static void nvidia_bugs(void)
43{
44#ifdef CONFIG_ACPI
45 /*
46 * All timer overrides on Nvidia are
47 * wrong unless HPET is enabled.
48 */
49 nvidia_hpet_detected = 0;
50 acpi_table_parse(ACPI_HPET, nvidia_hpet_check);
51 if (nvidia_hpet_detected == 0) {
52 acpi_skip_timer_override = 1;
53 printk(KERN_INFO "Nvidia board "
54 "detected. Ignoring ACPI "
55 "timer override.\n");
56 }
57#endif
58 /* RED-PEN skip them on mptables too? */
59
60}
61
62static void ati_bugs(void)
63{
64#if 1 /* for testing */
65 printk("ATI board detected\n");
66#endif
67 /* No bugs right now */
68}
69
70struct chipset {
71 u16 vendor;
72 void (*f)(void);
73};
74
75static struct chipset early_qrk[] = {
76 { PCI_VENDOR_ID_NVIDIA, nvidia_bugs },
77 { PCI_VENDOR_ID_VIA, via_bugs },
78 { PCI_VENDOR_ID_ATI, ati_bugs },
79 {}
80};
81
82void __init early_quirks(void)
83{
84 int num, slot, func;
85
86 if (!early_pci_allowed())
87 return;
88
89 /* Poor man's PCI discovery */
90 for (num = 0; num < 32; num++) {
91 for (slot = 0; slot < 32; slot++) {
92 for (func = 0; func < 8; func++) {
93 u32 class;
94 u32 vendor;
95 u8 type;
96 int i;
97 class = read_pci_config(num,slot,func,
98 PCI_CLASS_REVISION);
99 if (class == 0xffffffff)
100 break;
101
102 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
103 continue;
104
105 vendor = read_pci_config(num, slot, func,
106 PCI_VENDOR_ID);
107 vendor &= 0xffff;
108
109 for (i = 0; early_qrk[i].f; i++)
110 if (early_qrk[i].vendor == vendor) {
111 early_qrk[i].f();
112 return;
113 }
114
115 type = read_pci_config_byte(num, slot, func,
116 PCI_HEADER_TYPE);
117 if (!(type & 0x80))
118 break;
119 }
120 }
121 }
122}
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 140051e07fa6..e22ecd54870d 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -215,20 +215,16 @@ void early_printk(const char *fmt, ...)
215 215
216static int __initdata keep_early; 216static int __initdata keep_early;
217 217
218int __init setup_early_printk(char *opt) 218static int __init setup_early_printk(char *buf)
219{ 219{
220 char *space; 220 if (!buf)
221 char buf[256]; 221 return 0;
222 222
223 if (early_console_initialized) 223 if (early_console_initialized)
224 return 1; 224 return 0;
225 225 early_console_initialized = 1;
226 strlcpy(buf,opt,sizeof(buf));
227 space = strchr(buf, ' ');
228 if (space)
229 *space = 0;
230 226
231 if (strstr(buf,"keep")) 227 if (!strcmp(buf,"keep"))
232 keep_early = 1; 228 keep_early = 1;
233 229
234 if (!strncmp(buf, "serial", 6)) { 230 if (!strncmp(buf, "serial", 6)) {
@@ -248,11 +244,12 @@ int __init setup_early_printk(char *opt)
248 early_console = &simnow_console; 244 early_console = &simnow_console;
249 keep_early = 1; 245 keep_early = 1;
250 } 246 }
251 early_console_initialized = 1;
252 register_console(early_console); 247 register_console(early_console);
253 return 0; 248 return 0;
254} 249}
255 250
251early_param("earlyprintk", setup_early_printk);
252
256void __init disable_early_printk(void) 253void __init disable_early_printk(void)
257{ 254{
258 if (!early_console_initialized || !early_console) 255 if (!early_console_initialized || !early_console)
@@ -266,4 +263,3 @@ void __init disable_early_printk(void)
266 } 263 }
267} 264}
268 265
269__setup("earlyprintk=", setup_early_printk);
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index aa8d8939abc1..2802524104f3 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -4,8 +4,6 @@
4 * Copyright (C) 1991, 1992 Linus Torvalds 4 * Copyright (C) 1991, 1992 Linus Torvalds
5 * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs 5 * Copyright (C) 2000, 2001, 2002 Andi Kleen SuSE Labs
6 * Copyright (C) 2000 Pavel Machek <pavel@suse.cz> 6 * Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
7 *
8 * $Id$
9 */ 7 */
10 8
11/* 9/*
@@ -22,15 +20,25 @@
22 * at the top of the kernel process stack. 20 * at the top of the kernel process stack.
23 * - partial stack frame: partially saved registers upto R11. 21 * - partial stack frame: partially saved registers upto R11.
24 * - full stack frame: Like partial stack frame, but all register saved. 22 * - full stack frame: Like partial stack frame, but all register saved.
25 * 23 *
26 * TODO: 24 * Some macro usage:
27 * - schedule it carefully for the final hardware. 25 * - CFI macros are used to generate dwarf2 unwind information for better
26 * backtraces. They don't change any code.
27 * - SAVE_ALL/RESTORE_ALL - Save/restore all registers
28 * - SAVE_ARGS/RESTORE_ARGS - Save/restore registers that C functions modify.
29 * There are unfortunately lots of special cases where some registers
30 * not touched. The macro is a big mess that should be cleaned up.
31 * - SAVE_REST/RESTORE_REST - Handle the registers not saved by SAVE_ARGS.
32 * Gives a full stack frame.
33 * - ENTRY/END Define functions in the symbol table.
34 * - FIXUP_TOP_OF_STACK/RESTORE_TOP_OF_STACK - Fix up the hardware stack
35 * frame that is otherwise undefined after a SYSCALL
36 * - TRACE_IRQ_* - Trace hard interrupt state for lock debugging.
37 * - errorentry/paranoidentry/zeroentry - Define exception entry points.
28 */ 38 */
29 39
30#define ASSEMBLY 1
31#include <linux/linkage.h> 40#include <linux/linkage.h>
32#include <asm/segment.h> 41#include <asm/segment.h>
33#include <asm/smp.h>
34#include <asm/cache.h> 42#include <asm/cache.h>
35#include <asm/errno.h> 43#include <asm/errno.h>
36#include <asm/dwarf2.h> 44#include <asm/dwarf2.h>
@@ -115,6 +123,7 @@
115 .macro CFI_DEFAULT_STACK start=1 123 .macro CFI_DEFAULT_STACK start=1
116 .if \start 124 .if \start
117 CFI_STARTPROC simple 125 CFI_STARTPROC simple
126 CFI_SIGNAL_FRAME
118 CFI_DEF_CFA rsp,SS+8 127 CFI_DEF_CFA rsp,SS+8
119 .else 128 .else
120 CFI_DEF_CFA_OFFSET SS+8 129 CFI_DEF_CFA_OFFSET SS+8
@@ -146,6 +155,10 @@
146/* rdi: prev */ 155/* rdi: prev */
147ENTRY(ret_from_fork) 156ENTRY(ret_from_fork)
148 CFI_DEFAULT_STACK 157 CFI_DEFAULT_STACK
158 push kernel_eflags(%rip)
159 CFI_ADJUST_CFA_OFFSET 4
160 popf # reset kernel eflags
161 CFI_ADJUST_CFA_OFFSET -4
149 call schedule_tail 162 call schedule_tail
150 GET_THREAD_INFO(%rcx) 163 GET_THREAD_INFO(%rcx)
151 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx) 164 testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx)
@@ -199,6 +212,7 @@ END(ret_from_fork)
199 212
200ENTRY(system_call) 213ENTRY(system_call)
201 CFI_STARTPROC simple 214 CFI_STARTPROC simple
215 CFI_SIGNAL_FRAME
202 CFI_DEF_CFA rsp,PDA_STACKOFFSET 216 CFI_DEF_CFA rsp,PDA_STACKOFFSET
203 CFI_REGISTER rip,rcx 217 CFI_REGISTER rip,rcx
204 /*CFI_REGISTER rflags,r11*/ 218 /*CFI_REGISTER rflags,r11*/
@@ -316,6 +330,7 @@ END(system_call)
316 */ 330 */
317ENTRY(int_ret_from_sys_call) 331ENTRY(int_ret_from_sys_call)
318 CFI_STARTPROC simple 332 CFI_STARTPROC simple
333 CFI_SIGNAL_FRAME
319 CFI_DEF_CFA rsp,SS+8-ARGOFFSET 334 CFI_DEF_CFA rsp,SS+8-ARGOFFSET
320 /*CFI_REL_OFFSET ss,SS-ARGOFFSET*/ 335 /*CFI_REL_OFFSET ss,SS-ARGOFFSET*/
321 CFI_REL_OFFSET rsp,RSP-ARGOFFSET 336 CFI_REL_OFFSET rsp,RSP-ARGOFFSET
@@ -476,6 +491,7 @@ END(stub_rt_sigreturn)
476 */ 491 */
477 .macro _frame ref 492 .macro _frame ref
478 CFI_STARTPROC simple 493 CFI_STARTPROC simple
494 CFI_SIGNAL_FRAME
479 CFI_DEF_CFA rsp,SS+8-\ref 495 CFI_DEF_CFA rsp,SS+8-\ref
480 /*CFI_REL_OFFSET ss,SS-\ref*/ 496 /*CFI_REL_OFFSET ss,SS-\ref*/
481 CFI_REL_OFFSET rsp,RSP-\ref 497 CFI_REL_OFFSET rsp,RSP-\ref
@@ -511,7 +527,12 @@ END(stub_rt_sigreturn)
511 testl $3,CS(%rdi) 527 testl $3,CS(%rdi)
512 je 1f 528 je 1f
513 swapgs 529 swapgs
5141: incl %gs:pda_irqcount # RED-PEN should check preempt count 530 /* irqcount is used to check if a CPU is already on an interrupt
531 stack or not. While this is essentially redundant with preempt_count
532 it is a little cheaper to use a separate counter in the PDA
533 (short of moving irq_enter into assembly, which would be too
534 much work) */
5351: incl %gs:pda_irqcount
515 cmoveq %gs:pda_irqstackptr,%rsp 536 cmoveq %gs:pda_irqstackptr,%rsp
516 push %rbp # backlink for old unwinder 537 push %rbp # backlink for old unwinder
517 /* 538 /*
@@ -619,8 +640,7 @@ retint_signal:
619#ifdef CONFIG_PREEMPT 640#ifdef CONFIG_PREEMPT
620 /* Returning to kernel space. Check if we need preemption */ 641 /* Returning to kernel space. Check if we need preemption */
621 /* rcx: threadinfo. interrupts off. */ 642 /* rcx: threadinfo. interrupts off. */
622 .p2align 643ENTRY(retint_kernel)
623retint_kernel:
624 cmpl $0,threadinfo_preempt_count(%rcx) 644 cmpl $0,threadinfo_preempt_count(%rcx)
625 jnz retint_restore_args 645 jnz retint_restore_args
626 bt $TIF_NEED_RESCHED,threadinfo_flags(%rcx) 646 bt $TIF_NEED_RESCHED,threadinfo_flags(%rcx)
@@ -679,7 +699,6 @@ ENTRY(call_function_interrupt)
679END(call_function_interrupt) 699END(call_function_interrupt)
680#endif 700#endif
681 701
682#ifdef CONFIG_X86_LOCAL_APIC
683ENTRY(apic_timer_interrupt) 702ENTRY(apic_timer_interrupt)
684 apicinterrupt LOCAL_TIMER_VECTOR,smp_apic_timer_interrupt 703 apicinterrupt LOCAL_TIMER_VECTOR,smp_apic_timer_interrupt
685END(apic_timer_interrupt) 704END(apic_timer_interrupt)
@@ -691,7 +710,6 @@ END(error_interrupt)
691ENTRY(spurious_interrupt) 710ENTRY(spurious_interrupt)
692 apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt 711 apicinterrupt SPURIOUS_APIC_VECTOR,smp_spurious_interrupt
693END(spurious_interrupt) 712END(spurious_interrupt)
694#endif
695 713
696/* 714/*
697 * Exception entry points. 715 * Exception entry points.
@@ -768,7 +786,9 @@ paranoid_exit\trace:
768 testl $3,CS(%rsp) 786 testl $3,CS(%rsp)
769 jnz paranoid_userspace\trace 787 jnz paranoid_userspace\trace
770paranoid_swapgs\trace: 788paranoid_swapgs\trace:
789 .if \trace
771 TRACE_IRQS_IRETQ 0 790 TRACE_IRQS_IRETQ 0
791 .endif
772 swapgs 792 swapgs
773paranoid_restore\trace: 793paranoid_restore\trace:
774 RESTORE_ALL 8 794 RESTORE_ALL 8
@@ -814,7 +834,7 @@ paranoid_schedule\trace:
814 * Exception entry point. This expects an error code/orig_rax on the stack 834 * Exception entry point. This expects an error code/orig_rax on the stack
815 * and the exception handler in %rax. 835 * and the exception handler in %rax.
816 */ 836 */
817ENTRY(error_entry) 837KPROBE_ENTRY(error_entry)
818 _frame RDI 838 _frame RDI
819 /* rdi slot contains rax, oldrax contains error code */ 839 /* rdi slot contains rax, oldrax contains error code */
820 cld 840 cld
@@ -898,7 +918,7 @@ error_kernelspace:
898 cmpq $gs_change,RIP(%rsp) 918 cmpq $gs_change,RIP(%rsp)
899 je error_swapgs 919 je error_swapgs
900 jmp error_sti 920 jmp error_sti
901END(error_entry) 921KPROBE_END(error_entry)
902 922
903 /* Reload gs selector with exception handling */ 923 /* Reload gs selector with exception handling */
904 /* edi: new selector */ 924 /* edi: new selector */
@@ -1020,8 +1040,7 @@ ENDPROC(execve)
1020 1040
1021KPROBE_ENTRY(page_fault) 1041KPROBE_ENTRY(page_fault)
1022 errorentry do_page_fault 1042 errorentry do_page_fault
1023END(page_fault) 1043KPROBE_END(page_fault)
1024 .previous .text
1025 1044
1026ENTRY(coprocessor_error) 1045ENTRY(coprocessor_error)
1027 zeroentry do_coprocessor_error 1046 zeroentry do_coprocessor_error
@@ -1042,8 +1061,7 @@ KPROBE_ENTRY(debug)
1042 CFI_ADJUST_CFA_OFFSET 8 1061 CFI_ADJUST_CFA_OFFSET 8
1043 paranoidentry do_debug, DEBUG_STACK 1062 paranoidentry do_debug, DEBUG_STACK
1044 paranoidexit 1063 paranoidexit
1045END(debug) 1064KPROBE_END(debug)
1046 .previous .text
1047 1065
1048 /* runs on exception stack */ 1066 /* runs on exception stack */
1049KPROBE_ENTRY(nmi) 1067KPROBE_ENTRY(nmi)
@@ -1057,8 +1075,7 @@ KPROBE_ENTRY(nmi)
1057 jmp paranoid_exit1 1075 jmp paranoid_exit1
1058 CFI_ENDPROC 1076 CFI_ENDPROC
1059#endif 1077#endif
1060END(nmi) 1078KPROBE_END(nmi)
1061 .previous .text
1062 1079
1063KPROBE_ENTRY(int3) 1080KPROBE_ENTRY(int3)
1064 INTR_FRAME 1081 INTR_FRAME
@@ -1067,8 +1084,7 @@ KPROBE_ENTRY(int3)
1067 paranoidentry do_int3, DEBUG_STACK 1084 paranoidentry do_int3, DEBUG_STACK
1068 jmp paranoid_exit1 1085 jmp paranoid_exit1
1069 CFI_ENDPROC 1086 CFI_ENDPROC
1070END(int3) 1087KPROBE_END(int3)
1071 .previous .text
1072 1088
1073ENTRY(overflow) 1089ENTRY(overflow)
1074 zeroentry do_overflow 1090 zeroentry do_overflow
@@ -1116,8 +1132,7 @@ END(stack_segment)
1116 1132
1117KPROBE_ENTRY(general_protection) 1133KPROBE_ENTRY(general_protection)
1118 errorentry do_general_protection 1134 errorentry do_general_protection
1119END(general_protection) 1135KPROBE_END(general_protection)
1120 .previous .text
1121 1136
1122ENTRY(alignment_check) 1137ENTRY(alignment_check)
1123 errorentry do_alignment_check 1138 errorentry do_alignment_check
diff --git a/arch/x86_64/kernel/genapic_cluster.c b/arch/x86_64/kernel/genapic_cluster.c
index 3020917546de..cdb90e671b88 100644
--- a/arch/x86_64/kernel/genapic_cluster.c
+++ b/arch/x86_64/kernel/genapic_cluster.c
@@ -118,7 +118,6 @@ struct genapic apic_cluster = {
118 .name = "clustered", 118 .name = "clustered",
119 .int_delivery_mode = dest_Fixed, 119 .int_delivery_mode = dest_Fixed,
120 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 120 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
121 .int_delivery_dest = APIC_DEST_PHYSICAL | APIC_DM_FIXED,
122 .target_cpus = cluster_target_cpus, 121 .target_cpus = cluster_target_cpus,
123 .apic_id_registered = cluster_apic_id_registered, 122 .apic_id_registered = cluster_apic_id_registered,
124 .init_apic_ldr = cluster_init_apic_ldr, 123 .init_apic_ldr = cluster_init_apic_ldr,
diff --git a/arch/x86_64/kernel/genapic_flat.c b/arch/x86_64/kernel/genapic_flat.c
index eb86d374813a..50ad153eaac4 100644
--- a/arch/x86_64/kernel/genapic_flat.c
+++ b/arch/x86_64/kernel/genapic_flat.c
@@ -49,8 +49,7 @@ static void flat_send_IPI_mask(cpumask_t cpumask, int vector)
49 unsigned long cfg; 49 unsigned long cfg;
50 unsigned long flags; 50 unsigned long flags;
51 51
52 local_save_flags(flags); 52 local_irq_save(flags);
53 local_irq_disable();
54 53
55 /* 54 /*
56 * Wait for idle. 55 * Wait for idle.
@@ -121,7 +120,6 @@ struct genapic apic_flat = {
121 .name = "flat", 120 .name = "flat",
122 .int_delivery_mode = dest_LowestPrio, 121 .int_delivery_mode = dest_LowestPrio,
123 .int_dest_mode = (APIC_DEST_LOGICAL != 0), 122 .int_dest_mode = (APIC_DEST_LOGICAL != 0),
124 .int_delivery_dest = APIC_DEST_LOGICAL | APIC_DM_LOWEST,
125 .target_cpus = flat_target_cpus, 123 .target_cpus = flat_target_cpus,
126 .apic_id_registered = flat_apic_id_registered, 124 .apic_id_registered = flat_apic_id_registered,
127 .init_apic_ldr = flat_init_apic_ldr, 125 .init_apic_ldr = flat_init_apic_ldr,
@@ -180,7 +178,6 @@ struct genapic apic_physflat = {
180 .name = "physical flat", 178 .name = "physical flat",
181 .int_delivery_mode = dest_Fixed, 179 .int_delivery_mode = dest_Fixed,
182 .int_dest_mode = (APIC_DEST_PHYSICAL != 0), 180 .int_dest_mode = (APIC_DEST_PHYSICAL != 0),
183 .int_delivery_dest = APIC_DEST_PHYSICAL | APIC_DM_FIXED,
184 .target_cpus = physflat_target_cpus, 181 .target_cpus = physflat_target_cpus,
185 .apic_id_registered = flat_apic_id_registered, 182 .apic_id_registered = flat_apic_id_registered,
186 .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/ 183 .init_apic_ldr = flat_init_apic_ldr,/*not needed, but shouldn't hurt*/
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index c9739ca81d06..1e6f80870679 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -5,8 +5,6 @@
5 * Copyright (C) 2000 Pavel Machek <pavel@suse.cz> 5 * Copyright (C) 2000 Pavel Machek <pavel@suse.cz>
6 * Copyright (C) 2000 Karsten Keil <kkeil@suse.de> 6 * Copyright (C) 2000 Karsten Keil <kkeil@suse.de>
7 * Copyright (C) 2001,2002 Andi Kleen <ak@suse.de> 7 * Copyright (C) 2001,2002 Andi Kleen <ak@suse.de>
8 *
9 * $Id: head.S,v 1.49 2002/03/19 17:39:25 ak Exp $
10 */ 8 */
11 9
12 10
@@ -187,12 +185,15 @@ startup_64:
187 185
188 /* Finally jump to run C code and to be on real kernel address 186 /* Finally jump to run C code and to be on real kernel address
189 * Since we are running on identity-mapped space we have to jump 187 * Since we are running on identity-mapped space we have to jump
190 * to the full 64bit address , this is only possible as indirect 188 * to the full 64bit address, this is only possible as indirect
191 * jump 189 * jump. In addition we need to ensure %cs is set so we make this
190 * a far return.
192 */ 191 */
193 movq initial_code(%rip),%rax 192 movq initial_code(%rip),%rax
194 pushq $0 # fake return address 193 pushq $0 # fake return address to stop unwinder
195 jmp *%rax 194 pushq $__KERNEL_CS # set correct cs
195 pushq %rax # target address in negative space
196 lretq
196 197
197 /* SMP bootup changes these two */ 198 /* SMP bootup changes these two */
198 .align 8 199 .align 8
@@ -371,7 +372,7 @@ ENTRY(cpu_gdt_table)
371 .quad 0,0 /* TSS */ 372 .quad 0,0 /* TSS */
372 .quad 0,0 /* LDT */ 373 .quad 0,0 /* LDT */
373 .quad 0,0,0 /* three TLS descriptors */ 374 .quad 0,0,0 /* three TLS descriptors */
374 .quad 0 /* unused */ 375 .quad 0x0000f40000000000 /* node/CPU stored in limit */
375gdt_end: 376gdt_end:
376 /* asm/segment.h:GDT_ENTRIES must match this */ 377 /* asm/segment.h:GDT_ENTRIES must match this */
377 /* This should be a multiple of the cache line size */ 378 /* This should be a multiple of the cache line size */
diff --git a/arch/x86_64/kernel/head64.c b/arch/x86_64/kernel/head64.c
index 36647ce6aecb..9561eb3c5b5c 100644
--- a/arch/x86_64/kernel/head64.c
+++ b/arch/x86_64/kernel/head64.c
@@ -45,38 +45,16 @@ static void __init copy_bootdata(char *real_mode_data)
45 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER); 45 new_data = *(int *) (x86_boot_params + NEW_CL_POINTER);
46 if (!new_data) { 46 if (!new_data) {
47 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) { 47 if (OLD_CL_MAGIC != * (u16 *) OLD_CL_MAGIC_ADDR) {
48 printk("so old bootloader that it does not support commandline?!\n");
49 return; 48 return;
50 } 49 }
51 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET; 50 new_data = OLD_CL_BASE_ADDR + * (u16 *) OLD_CL_OFFSET;
52 printk("old bootloader convention, maybe loadlin?\n");
53 } 51 }
54 command_line = (char *) ((u64)(new_data)); 52 command_line = (char *) ((u64)(new_data));
55 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE); 53 memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
56 printk("Bootdata ok (command line is %s)\n", saved_command_line);
57}
58
59static void __init setup_boot_cpu_data(void)
60{
61 unsigned int dummy, eax;
62
63 /* get vendor info */
64 cpuid(0, (unsigned int *)&boot_cpu_data.cpuid_level,
65 (unsigned int *)&boot_cpu_data.x86_vendor_id[0],
66 (unsigned int *)&boot_cpu_data.x86_vendor_id[8],
67 (unsigned int *)&boot_cpu_data.x86_vendor_id[4]);
68
69 /* get cpu type */
70 cpuid(1, &eax, &dummy, &dummy,
71 (unsigned int *) &boot_cpu_data.x86_capability);
72 boot_cpu_data.x86 = (eax >> 8) & 0xf;
73 boot_cpu_data.x86_model = (eax >> 4) & 0xf;
74 boot_cpu_data.x86_mask = eax & 0xf;
75} 54}
76 55
77void __init x86_64_start_kernel(char * real_mode_data) 56void __init x86_64_start_kernel(char * real_mode_data)
78{ 57{
79 char *s;
80 int i; 58 int i;
81 59
82 for (i = 0; i < 256; i++) 60 for (i = 0; i < 256; i++)
@@ -84,10 +62,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
84 asm volatile("lidt %0" :: "m" (idt_descr)); 62 asm volatile("lidt %0" :: "m" (idt_descr));
85 clear_bss(); 63 clear_bss();
86 64
87 /* 65 early_printk("Kernel alive\n");
88 * This must be called really, really early:
89 */
90 lockdep_init();
91 66
92 /* 67 /*
93 * switch to init_level4_pgt from boot_level4_pgt 68 * switch to init_level4_pgt from boot_level4_pgt
@@ -103,22 +78,5 @@ void __init x86_64_start_kernel(char * real_mode_data)
103#ifdef CONFIG_SMP 78#ifdef CONFIG_SMP
104 cpu_set(0, cpu_online_map); 79 cpu_set(0, cpu_online_map);
105#endif 80#endif
106 s = strstr(saved_command_line, "earlyprintk=");
107 if (s != NULL)
108 setup_early_printk(strchr(s, '=') + 1);
109#ifdef CONFIG_NUMA
110 s = strstr(saved_command_line, "numa=");
111 if (s != NULL)
112 numa_setup(s+5);
113#endif
114#ifdef CONFIG_X86_IO_APIC
115 if (strstr(saved_command_line, "disableapic"))
116 disable_apic = 1;
117#endif
118 /* You need early console to see that */
119 if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
120 panic("Kernel too big for kernel mapping\n");
121
122 setup_boot_cpu_data();
123 start_kernel(); 81 start_kernel();
124} 82}
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 0434b1f8e3dd..2dd51f364ea2 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -55,7 +55,6 @@
55 */ 55 */
56BUILD_16_IRQS(0x0) 56BUILD_16_IRQS(0x0)
57 57
58#ifdef CONFIG_X86_LOCAL_APIC
59/* 58/*
60 * The IO-APIC gives us many more interrupt sources. Most of these 59 * The IO-APIC gives us many more interrupt sources. Most of these
61 * are unused but an SMP system is supposed to have enough memory ... 60 * are unused but an SMP system is supposed to have enough memory ...
@@ -75,8 +74,6 @@ BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd)
75 BUILD_15_IRQS(0xe) 74 BUILD_15_IRQS(0xe)
76#endif 75#endif
77 76
78#endif
79
80#undef BUILD_16_IRQS 77#undef BUILD_16_IRQS
81#undef BUILD_15_IRQS 78#undef BUILD_15_IRQS
82#undef BI 79#undef BI
@@ -100,7 +97,6 @@ BUILD_16_IRQS(0xc) BUILD_16_IRQS(0xd)
100void (*interrupt[NR_IRQS])(void) = { 97void (*interrupt[NR_IRQS])(void) = {
101 IRQLIST_16(0x0), 98 IRQLIST_16(0x0),
102 99
103#ifdef CONFIG_X86_IO_APIC
104 IRQLIST_16(0x1), IRQLIST_16(0x2), IRQLIST_16(0x3), 100 IRQLIST_16(0x1), IRQLIST_16(0x2), IRQLIST_16(0x3),
105 IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7), 101 IRQLIST_16(0x4), IRQLIST_16(0x5), IRQLIST_16(0x6), IRQLIST_16(0x7),
106 IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb), 102 IRQLIST_16(0x8), IRQLIST_16(0x9), IRQLIST_16(0xa), IRQLIST_16(0xb),
@@ -110,7 +106,6 @@ void (*interrupt[NR_IRQS])(void) = {
110 , IRQLIST_15(0xe) 106 , IRQLIST_15(0xe)
111#endif 107#endif
112 108
113#endif
114}; 109};
115 110
116#undef IRQ 111#undef IRQ
@@ -128,6 +123,8 @@ void (*interrupt[NR_IRQS])(void) = {
128 123
129DEFINE_SPINLOCK(i8259A_lock); 124DEFINE_SPINLOCK(i8259A_lock);
130 125
126static int i8259A_auto_eoi;
127
131static void end_8259A_irq (unsigned int irq) 128static void end_8259A_irq (unsigned int irq)
132{ 129{
133 if (irq > 256) { 130 if (irq > 256) {
@@ -341,6 +338,8 @@ void init_8259A(int auto_eoi)
341{ 338{
342 unsigned long flags; 339 unsigned long flags;
343 340
341 i8259A_auto_eoi = auto_eoi;
342
344 spin_lock_irqsave(&i8259A_lock, flags); 343 spin_lock_irqsave(&i8259A_lock, flags);
345 344
346 outb(0xff, 0x21); /* mask all of 8259A-1 */ 345 outb(0xff, 0x21); /* mask all of 8259A-1 */
@@ -399,7 +398,7 @@ static void save_ELCR(char *trigger)
399 398
400static int i8259A_resume(struct sys_device *dev) 399static int i8259A_resume(struct sys_device *dev)
401{ 400{
402 init_8259A(0); 401 init_8259A(i8259A_auto_eoi);
403 restore_ELCR(irq_trigger); 402 restore_ELCR(irq_trigger);
404 return 0; 403 return 0;
405} 404}
@@ -453,9 +452,7 @@ void __init init_ISA_irqs (void)
453{ 452{
454 int i; 453 int i;
455 454
456#ifdef CONFIG_X86_LOCAL_APIC
457 init_bsp_APIC(); 455 init_bsp_APIC();
458#endif
459 init_8259A(0); 456 init_8259A(0);
460 457
461 for (i = 0; i < NR_IRQS; i++) { 458 for (i = 0; i < NR_IRQS; i++) {
@@ -581,14 +578,12 @@ void __init init_IRQ(void)
581 set_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt); 578 set_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
582 set_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt); 579 set_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
583 580
584#ifdef CONFIG_X86_LOCAL_APIC
585 /* self generated IPI for local APIC timer */ 581 /* self generated IPI for local APIC timer */
586 set_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt); 582 set_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
587 583
588 /* IPI vectors for APIC spurious and error interrupts */ 584 /* IPI vectors for APIC spurious and error interrupts */
589 set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt); 585 set_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
590 set_intr_gate(ERROR_APIC_VECTOR, error_interrupt); 586 set_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
591#endif
592 587
593 /* 588 /*
594 * Set the clock to HZ Hz, we already have a valid 589 * Set the clock to HZ Hz, we already have a valid
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 924a4a332954..0491019d4c8d 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -48,7 +48,7 @@ int sis_apic_bug; /* not actually supported, dummy for compile */
48 48
49static int no_timer_check; 49static int no_timer_check;
50 50
51int disable_timer_pin_1 __initdata; 51static int disable_timer_pin_1 __initdata;
52 52
53int timer_over_8254 __initdata = 0; 53int timer_over_8254 __initdata = 0;
54 54
@@ -111,6 +111,33 @@ int vector_irq[NR_VECTORS] __read_mostly = { [0 ... NR_VECTORS - 1] = -1};
111 FINAL; \ 111 FINAL; \
112} 112}
113 113
114union entry_union {
115 struct { u32 w1, w2; };
116 struct IO_APIC_route_entry entry;
117};
118
119static struct IO_APIC_route_entry ioapic_read_entry(int apic, int pin)
120{
121 union entry_union eu;
122 unsigned long flags;
123 spin_lock_irqsave(&ioapic_lock, flags);
124 eu.w1 = io_apic_read(apic, 0x10 + 2 * pin);
125 eu.w2 = io_apic_read(apic, 0x11 + 2 * pin);
126 spin_unlock_irqrestore(&ioapic_lock, flags);
127 return eu.entry;
128}
129
130static void ioapic_write_entry(int apic, int pin, struct IO_APIC_route_entry e)
131{
132 unsigned long flags;
133 union entry_union eu;
134 eu.entry = e;
135 spin_lock_irqsave(&ioapic_lock, flags);
136 io_apic_write(apic, 0x10 + 2*pin, eu.w1);
137 io_apic_write(apic, 0x11 + 2*pin, eu.w2);
138 spin_unlock_irqrestore(&ioapic_lock, flags);
139}
140
114#ifdef CONFIG_SMP 141#ifdef CONFIG_SMP
115static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask) 142static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t mask)
116{ 143{
@@ -196,13 +223,9 @@ static void unmask_IO_APIC_irq (unsigned int irq)
196static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin) 223static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
197{ 224{
198 struct IO_APIC_route_entry entry; 225 struct IO_APIC_route_entry entry;
199 unsigned long flags;
200 226
201 /* Check delivery_mode to be sure we're not clearing an SMI pin */ 227 /* Check delivery_mode to be sure we're not clearing an SMI pin */
202 spin_lock_irqsave(&ioapic_lock, flags); 228 entry = ioapic_read_entry(apic, pin);
203 *(((int*)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
204 *(((int*)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
205 spin_unlock_irqrestore(&ioapic_lock, flags);
206 if (entry.delivery_mode == dest_SMI) 229 if (entry.delivery_mode == dest_SMI)
207 return; 230 return;
208 /* 231 /*
@@ -210,10 +233,7 @@ static void clear_IO_APIC_pin(unsigned int apic, unsigned int pin)
210 */ 233 */
211 memset(&entry, 0, sizeof(entry)); 234 memset(&entry, 0, sizeof(entry));
212 entry.mask = 1; 235 entry.mask = 1;
213 spin_lock_irqsave(&ioapic_lock, flags); 236 ioapic_write_entry(apic, pin, entry);
214 io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry) + 0));
215 io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry) + 1));
216 spin_unlock_irqrestore(&ioapic_lock, flags);
217} 237}
218 238
219static void clear_IO_APIC (void) 239static void clear_IO_APIC (void)
@@ -225,14 +245,6 @@ static void clear_IO_APIC (void)
225 clear_IO_APIC_pin(apic, pin); 245 clear_IO_APIC_pin(apic, pin);
226} 246}
227 247
228/*
229 * support for broken MP BIOSs, enables hand-redirection of PIRQ0-7 to
230 * specific CPU-side IRQs.
231 */
232
233#define MAX_PIRQS 8
234static int pirq_entries [MAX_PIRQS];
235static int pirqs_enabled;
236int skip_ioapic_setup; 248int skip_ioapic_setup;
237int ioapic_force; 249int ioapic_force;
238 250
@@ -241,18 +253,17 @@ int ioapic_force;
241static int __init disable_ioapic_setup(char *str) 253static int __init disable_ioapic_setup(char *str)
242{ 254{
243 skip_ioapic_setup = 1; 255 skip_ioapic_setup = 1;
244 return 1; 256 return 0;
245} 257}
258early_param("noapic", disable_ioapic_setup);
246 259
247static int __init enable_ioapic_setup(char *str) 260/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
261static int __init disable_timer_pin_setup(char *arg)
248{ 262{
249 ioapic_force = 1; 263 disable_timer_pin_1 = 1;
250 skip_ioapic_setup = 0;
251 return 1; 264 return 1;
252} 265}
253 266__setup("disable_timer_pin_1", disable_timer_pin_setup);
254__setup("noapic", disable_ioapic_setup);
255__setup("apic", enable_ioapic_setup);
256 267
257static int __init setup_disable_8254_timer(char *s) 268static int __init setup_disable_8254_timer(char *s)
258{ 269{
@@ -268,135 +279,6 @@ static int __init setup_enable_8254_timer(char *s)
268__setup("disable_8254_timer", setup_disable_8254_timer); 279__setup("disable_8254_timer", setup_disable_8254_timer);
269__setup("enable_8254_timer", setup_enable_8254_timer); 280__setup("enable_8254_timer", setup_enable_8254_timer);
270 281
271#include <asm/pci-direct.h>
272#include <linux/pci_ids.h>
273#include <linux/pci.h>
274
275
276#ifdef CONFIG_ACPI
277
278static int nvidia_hpet_detected __initdata;
279
280static int __init nvidia_hpet_check(unsigned long phys, unsigned long size)
281{
282 nvidia_hpet_detected = 1;
283 return 0;
284}
285#endif
286
287/* Temporary Hack. Nvidia and VIA boards currently only work with IO-APIC
288 off. Check for an Nvidia or VIA PCI bridge and turn it off.
289 Use pci direct infrastructure because this runs before the PCI subsystem.
290
291 Can be overwritten with "apic"
292
293 And another hack to disable the IOMMU on VIA chipsets.
294
295 ... and others. Really should move this somewhere else.
296
297 Kludge-O-Rama. */
298void __init check_ioapic(void)
299{
300 int num,slot,func;
301 /* Poor man's PCI discovery */
302 for (num = 0; num < 32; num++) {
303 for (slot = 0; slot < 32; slot++) {
304 for (func = 0; func < 8; func++) {
305 u32 class;
306 u32 vendor;
307 u8 type;
308 class = read_pci_config(num,slot,func,
309 PCI_CLASS_REVISION);
310 if (class == 0xffffffff)
311 break;
312
313 if ((class >> 16) != PCI_CLASS_BRIDGE_PCI)
314 continue;
315
316 vendor = read_pci_config(num, slot, func,
317 PCI_VENDOR_ID);
318 vendor &= 0xffff;
319 switch (vendor) {
320 case PCI_VENDOR_ID_VIA:
321#ifdef CONFIG_IOMMU
322 if ((end_pfn > MAX_DMA32_PFN ||
323 force_iommu) &&
324 !iommu_aperture_allowed) {
325 printk(KERN_INFO
326 "Looks like a VIA chipset. Disabling IOMMU. Override with \"iommu=allowed\"\n");
327 iommu_aperture_disabled = 1;
328 }
329#endif
330 return;
331 case PCI_VENDOR_ID_NVIDIA:
332#ifdef CONFIG_ACPI
333 /*
334 * All timer overrides on Nvidia are
335 * wrong unless HPET is enabled.
336 */
337 nvidia_hpet_detected = 0;
338 acpi_table_parse(ACPI_HPET,
339 nvidia_hpet_check);
340 if (nvidia_hpet_detected == 0) {
341 acpi_skip_timer_override = 1;
342 printk(KERN_INFO "Nvidia board "
343 "detected. Ignoring ACPI "
344 "timer override.\n");
345 }
346#endif
347 /* RED-PEN skip them on mptables too? */
348 return;
349
350 /* This should be actually default, but
351 for 2.6.16 let's do it for ATI only where
352 it's really needed. */
353 case PCI_VENDOR_ID_ATI:
354 if (timer_over_8254 == 1) {
355 timer_over_8254 = 0;
356 printk(KERN_INFO
357 "ATI board detected. Disabling timer routing over 8254.\n");
358 }
359 return;
360 }
361
362
363 /* No multi-function device? */
364 type = read_pci_config_byte(num,slot,func,
365 PCI_HEADER_TYPE);
366 if (!(type & 0x80))
367 break;
368 }
369 }
370 }
371}
372
373static int __init ioapic_pirq_setup(char *str)
374{
375 int i, max;
376 int ints[MAX_PIRQS+1];
377
378 get_options(str, ARRAY_SIZE(ints), ints);
379
380 for (i = 0; i < MAX_PIRQS; i++)
381 pirq_entries[i] = -1;
382
383 pirqs_enabled = 1;
384 apic_printk(APIC_VERBOSE, "PIRQ redirection, working around broken MP-BIOS.\n");
385 max = MAX_PIRQS;
386 if (ints[0] < MAX_PIRQS)
387 max = ints[0];
388
389 for (i = 0; i < max; i++) {
390 apic_printk(APIC_VERBOSE, "... PIRQ%d -> IRQ %d\n", i, ints[i+1]);
391 /*
392 * PIRQs are mapped upside down, usually.
393 */
394 pirq_entries[MAX_PIRQS-i-1] = ints[i+1];
395 }
396 return 1;
397}
398
399__setup("pirq=", ioapic_pirq_setup);
400 282
401/* 283/*
402 * Find the IRQ entry number of a certain pin. 284 * Find the IRQ entry number of a certain pin.
@@ -425,9 +307,7 @@ static int __init find_isa_irq_pin(int irq, int type)
425 for (i = 0; i < mp_irq_entries; i++) { 307 for (i = 0; i < mp_irq_entries; i++) {
426 int lbus = mp_irqs[i].mpc_srcbus; 308 int lbus = mp_irqs[i].mpc_srcbus;
427 309
428 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA || 310 if (test_bit(lbus, mp_bus_not_pci) &&
429 mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
430 mp_bus_id_to_type[lbus] == MP_BUS_MCA) &&
431 (mp_irqs[i].mpc_irqtype == type) && 311 (mp_irqs[i].mpc_irqtype == type) &&
432 (mp_irqs[i].mpc_srcbusirq == irq)) 312 (mp_irqs[i].mpc_srcbusirq == irq))
433 313
@@ -443,9 +323,7 @@ static int __init find_isa_irq_apic(int irq, int type)
443 for (i = 0; i < mp_irq_entries; i++) { 323 for (i = 0; i < mp_irq_entries; i++) {
444 int lbus = mp_irqs[i].mpc_srcbus; 324 int lbus = mp_irqs[i].mpc_srcbus;
445 325
446 if ((mp_bus_id_to_type[lbus] == MP_BUS_ISA || 326 if (test_bit(lbus, mp_bus_not_pci) &&
447 mp_bus_id_to_type[lbus] == MP_BUS_EISA ||
448 mp_bus_id_to_type[lbus] == MP_BUS_MCA) &&
449 (mp_irqs[i].mpc_irqtype == type) && 327 (mp_irqs[i].mpc_irqtype == type) &&
450 (mp_irqs[i].mpc_srcbusirq == irq)) 328 (mp_irqs[i].mpc_srcbusirq == irq))
451 break; 329 break;
@@ -485,7 +363,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
485 mp_irqs[i].mpc_dstapic == MP_APIC_ALL) 363 mp_irqs[i].mpc_dstapic == MP_APIC_ALL)
486 break; 364 break;
487 365
488 if ((mp_bus_id_to_type[lbus] == MP_BUS_PCI) && 366 if (!test_bit(lbus, mp_bus_not_pci) &&
489 !mp_irqs[i].mpc_irqtype && 367 !mp_irqs[i].mpc_irqtype &&
490 (bus == lbus) && 368 (bus == lbus) &&
491 (slot == ((mp_irqs[i].mpc_srcbusirq >> 2) & 0x1f))) { 369 (slot == ((mp_irqs[i].mpc_srcbusirq >> 2) & 0x1f))) {
@@ -508,27 +386,6 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin)
508 return best_guess; 386 return best_guess;
509} 387}
510 388
511/*
512 * EISA Edge/Level control register, ELCR
513 */
514static int EISA_ELCR(unsigned int irq)
515{
516 if (irq < 16) {
517 unsigned int port = 0x4d0 + (irq >> 3);
518 return (inb(port) >> (irq & 7)) & 1;
519 }
520 apic_printk(APIC_VERBOSE, "Broken MPtable reports ISA irq %d\n", irq);
521 return 0;
522}
523
524/* EISA interrupts are always polarity zero and can be edge or level
525 * trigger depending on the ELCR value. If an interrupt is listed as
526 * EISA conforming in the MP table, that means its trigger type must
527 * be read in from the ELCR */
528
529#define default_EISA_trigger(idx) (EISA_ELCR(mp_irqs[idx].mpc_srcbusirq))
530#define default_EISA_polarity(idx) (0)
531
532/* ISA interrupts are always polarity zero edge triggered, 389/* ISA interrupts are always polarity zero edge triggered,
533 * when listed as conforming in the MP table. */ 390 * when listed as conforming in the MP table. */
534 391
@@ -541,12 +398,6 @@ static int EISA_ELCR(unsigned int irq)
541#define default_PCI_trigger(idx) (1) 398#define default_PCI_trigger(idx) (1)
542#define default_PCI_polarity(idx) (1) 399#define default_PCI_polarity(idx) (1)
543 400
544/* MCA interrupts are always polarity zero level triggered,
545 * when listed as conforming in the MP table. */
546
547#define default_MCA_trigger(idx) (1)
548#define default_MCA_polarity(idx) (0)
549
550static int __init MPBIOS_polarity(int idx) 401static int __init MPBIOS_polarity(int idx)
551{ 402{
552 int bus = mp_irqs[idx].mpc_srcbus; 403 int bus = mp_irqs[idx].mpc_srcbus;
@@ -558,38 +409,11 @@ static int __init MPBIOS_polarity(int idx)
558 switch (mp_irqs[idx].mpc_irqflag & 3) 409 switch (mp_irqs[idx].mpc_irqflag & 3)
559 { 410 {
560 case 0: /* conforms, ie. bus-type dependent polarity */ 411 case 0: /* conforms, ie. bus-type dependent polarity */
561 { 412 if (test_bit(bus, mp_bus_not_pci))
562 switch (mp_bus_id_to_type[bus]) 413 polarity = default_ISA_polarity(idx);
563 { 414 else
564 case MP_BUS_ISA: /* ISA pin */ 415 polarity = default_PCI_polarity(idx);
565 {
566 polarity = default_ISA_polarity(idx);
567 break;
568 }
569 case MP_BUS_EISA: /* EISA pin */
570 {
571 polarity = default_EISA_polarity(idx);
572 break;
573 }
574 case MP_BUS_PCI: /* PCI pin */
575 {
576 polarity = default_PCI_polarity(idx);
577 break;
578 }
579 case MP_BUS_MCA: /* MCA pin */
580 {
581 polarity = default_MCA_polarity(idx);
582 break;
583 }
584 default:
585 {
586 printk(KERN_WARNING "broken BIOS!!\n");
587 polarity = 1;
588 break;
589 }
590 }
591 break; 416 break;
592 }
593 case 1: /* high active */ 417 case 1: /* high active */
594 { 418 {
595 polarity = 0; 419 polarity = 0;
@@ -627,38 +451,11 @@ static int MPBIOS_trigger(int idx)
627 switch ((mp_irqs[idx].mpc_irqflag>>2) & 3) 451 switch ((mp_irqs[idx].mpc_irqflag>>2) & 3)
628 { 452 {
629 case 0: /* conforms, ie. bus-type dependent */ 453 case 0: /* conforms, ie. bus-type dependent */
630 { 454 if (test_bit(bus, mp_bus_not_pci))
631 switch (mp_bus_id_to_type[bus]) 455 trigger = default_ISA_trigger(idx);
632 { 456 else
633 case MP_BUS_ISA: /* ISA pin */ 457 trigger = default_PCI_trigger(idx);
634 {
635 trigger = default_ISA_trigger(idx);
636 break;
637 }
638 case MP_BUS_EISA: /* EISA pin */
639 {
640 trigger = default_EISA_trigger(idx);
641 break;
642 }
643 case MP_BUS_PCI: /* PCI pin */
644 {
645 trigger = default_PCI_trigger(idx);
646 break;
647 }
648 case MP_BUS_MCA: /* MCA pin */
649 {
650 trigger = default_MCA_trigger(idx);
651 break;
652 }
653 default:
654 {
655 printk(KERN_WARNING "broken BIOS!!\n");
656 trigger = 1;
657 break;
658 }
659 }
660 break; 458 break;
661 }
662 case 1: /* edge */ 459 case 1: /* edge */
663 { 460 {
664 trigger = 0; 461 trigger = 0;
@@ -764,49 +561,17 @@ static int pin_2_irq(int idx, int apic, int pin)
764 if (mp_irqs[idx].mpc_dstirq != pin) 561 if (mp_irqs[idx].mpc_dstirq != pin)
765 printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n"); 562 printk(KERN_ERR "broken BIOS or MPTABLE parser, ayiee!!\n");
766 563
767 switch (mp_bus_id_to_type[bus]) 564 if (test_bit(bus, mp_bus_not_pci)) {
768 { 565 irq = mp_irqs[idx].mpc_srcbusirq;
769 case MP_BUS_ISA: /* ISA pin */ 566 } else {
770 case MP_BUS_EISA: 567 /*
771 case MP_BUS_MCA: 568 * PCI IRQs are mapped in order
772 { 569 */
773 irq = mp_irqs[idx].mpc_srcbusirq; 570 i = irq = 0;
774 break; 571 while (i < apic)
775 } 572 irq += nr_ioapic_registers[i++];
776 case MP_BUS_PCI: /* PCI pin */ 573 irq += pin;
777 { 574 irq = gsi_irq_sharing(irq);
778 /*
779 * PCI IRQs are mapped in order
780 */
781 i = irq = 0;
782 while (i < apic)
783 irq += nr_ioapic_registers[i++];
784 irq += pin;
785 irq = gsi_irq_sharing(irq);
786 break;
787 }
788 default:
789 {
790 printk(KERN_ERR "unknown bus type %d.\n",bus);
791 irq = 0;
792 break;
793 }
794 }
795 BUG_ON(irq >= NR_IRQS);
796
797 /*
798 * PCI IRQ command line redirection. Yes, limits are hardcoded.
799 */
800 if ((pin >= 16) && (pin <= 23)) {
801 if (pirq_entries[pin-16] != -1) {
802 if (!pirq_entries[pin-16]) {
803 apic_printk(APIC_VERBOSE, "disabling PIRQ%d\n", pin-16);
804 } else {
805 irq = pirq_entries[pin-16];
806 apic_printk(APIC_VERBOSE, "using PIRQ%d -> IRQ %d\n",
807 pin-16, irq);
808 }
809 }
810 } 575 }
811 BUG_ON(irq >= NR_IRQS); 576 BUG_ON(irq >= NR_IRQS);
812 return irq; 577 return irq;
@@ -943,9 +708,9 @@ static void __init setup_IO_APIC_irqs(void)
943 if (!apic && (irq < 16)) 708 if (!apic && (irq < 16))
944 disable_8259A_irq(irq); 709 disable_8259A_irq(irq);
945 } 710 }
711 ioapic_write_entry(apic, pin, entry);
712
946 spin_lock_irqsave(&ioapic_lock, flags); 713 spin_lock_irqsave(&ioapic_lock, flags);
947 io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
948 io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
949 set_native_irq_info(irq, TARGET_CPUS); 714 set_native_irq_info(irq, TARGET_CPUS);
950 spin_unlock_irqrestore(&ioapic_lock, flags); 715 spin_unlock_irqrestore(&ioapic_lock, flags);
951 } 716 }
@@ -1083,10 +848,7 @@ void __apicdebuginit print_IO_APIC(void)
1083 for (i = 0; i <= reg_01.bits.entries; i++) { 848 for (i = 0; i <= reg_01.bits.entries; i++) {
1084 struct IO_APIC_route_entry entry; 849 struct IO_APIC_route_entry entry;
1085 850
1086 spin_lock_irqsave(&ioapic_lock, flags); 851 entry = ioapic_read_entry(apic, i);
1087 *(((int *)&entry)+0) = io_apic_read(apic, 0x10+i*2);
1088 *(((int *)&entry)+1) = io_apic_read(apic, 0x11+i*2);
1089 spin_unlock_irqrestore(&ioapic_lock, flags);
1090 852
1091 printk(KERN_DEBUG " %02x %03X %02X ", 853 printk(KERN_DEBUG " %02x %03X %02X ",
1092 i, 854 i,
@@ -1281,9 +1043,6 @@ static void __init enable_IO_APIC(void)
1281 irq_2_pin[i].pin = -1; 1043 irq_2_pin[i].pin = -1;
1282 irq_2_pin[i].next = 0; 1044 irq_2_pin[i].next = 0;
1283 } 1045 }
1284 if (!pirqs_enabled)
1285 for (i = 0; i < MAX_PIRQS; i++)
1286 pirq_entries[i] = -1;
1287 1046
1288 /* 1047 /*
1289 * The number of IO-APIC IRQ registers (== #pins): 1048 * The number of IO-APIC IRQ registers (== #pins):
@@ -1299,11 +1058,7 @@ static void __init enable_IO_APIC(void)
1299 /* See if any of the pins is in ExtINT mode */ 1058 /* See if any of the pins is in ExtINT mode */
1300 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) { 1059 for (pin = 0; pin < nr_ioapic_registers[apic]; pin++) {
1301 struct IO_APIC_route_entry entry; 1060 struct IO_APIC_route_entry entry;
1302 spin_lock_irqsave(&ioapic_lock, flags); 1061 entry = ioapic_read_entry(apic, pin);
1303 *(((int *)&entry) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
1304 *(((int *)&entry) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
1305 spin_unlock_irqrestore(&ioapic_lock, flags);
1306
1307 1062
1308 /* If the interrupt line is enabled and in ExtInt mode 1063 /* If the interrupt line is enabled and in ExtInt mode
1309 * I have found the pin where the i8259 is connected. 1064 * I have found the pin where the i8259 is connected.
@@ -1355,7 +1110,6 @@ void disable_IO_APIC(void)
1355 */ 1110 */
1356 if (ioapic_i8259.pin != -1) { 1111 if (ioapic_i8259.pin != -1) {
1357 struct IO_APIC_route_entry entry; 1112 struct IO_APIC_route_entry entry;
1358 unsigned long flags;
1359 1113
1360 memset(&entry, 0, sizeof(entry)); 1114 memset(&entry, 0, sizeof(entry));
1361 entry.mask = 0; /* Enabled */ 1115 entry.mask = 0; /* Enabled */
@@ -1372,84 +1126,13 @@ void disable_IO_APIC(void)
1372 /* 1126 /*
1373 * Add it to the IO-APIC irq-routing table: 1127 * Add it to the IO-APIC irq-routing table:
1374 */ 1128 */
1375 spin_lock_irqsave(&ioapic_lock, flags); 1129 ioapic_write_entry(ioapic_i8259.apic, ioapic_i8259.pin, entry);
1376 io_apic_write(ioapic_i8259.apic, 0x11+2*ioapic_i8259.pin,
1377 *(((int *)&entry)+1));
1378 io_apic_write(ioapic_i8259.apic, 0x10+2*ioapic_i8259.pin,
1379 *(((int *)&entry)+0));
1380 spin_unlock_irqrestore(&ioapic_lock, flags);
1381 } 1130 }
1382 1131
1383 disconnect_bsp_APIC(ioapic_i8259.pin != -1); 1132 disconnect_bsp_APIC(ioapic_i8259.pin != -1);
1384} 1133}
1385 1134
1386/* 1135/*
1387 * function to set the IO-APIC physical IDs based on the
1388 * values stored in the MPC table.
1389 *
1390 * by Matt Domsch <Matt_Domsch@dell.com> Tue Dec 21 12:25:05 CST 1999
1391 */
1392
1393static void __init setup_ioapic_ids_from_mpc (void)
1394{
1395 union IO_APIC_reg_00 reg_00;
1396 int apic;
1397 int i;
1398 unsigned char old_id;
1399 unsigned long flags;
1400
1401 /*
1402 * Set the IOAPIC ID to the value stored in the MPC table.
1403 */
1404 for (apic = 0; apic < nr_ioapics; apic++) {
1405
1406 /* Read the register 0 value */
1407 spin_lock_irqsave(&ioapic_lock, flags);
1408 reg_00.raw = io_apic_read(apic, 0);
1409 spin_unlock_irqrestore(&ioapic_lock, flags);
1410
1411 old_id = mp_ioapics[apic].mpc_apicid;
1412
1413
1414 printk(KERN_INFO "Using IO-APIC %d\n", mp_ioapics[apic].mpc_apicid);
1415
1416
1417 /*
1418 * We need to adjust the IRQ routing table
1419 * if the ID changed.
1420 */
1421 if (old_id != mp_ioapics[apic].mpc_apicid)
1422 for (i = 0; i < mp_irq_entries; i++)
1423 if (mp_irqs[i].mpc_dstapic == old_id)
1424 mp_irqs[i].mpc_dstapic
1425 = mp_ioapics[apic].mpc_apicid;
1426
1427 /*
1428 * Read the right value from the MPC table and
1429 * write it into the ID register.
1430 */
1431 apic_printk(APIC_VERBOSE,KERN_INFO "...changing IO-APIC physical APIC ID to %d ...",
1432 mp_ioapics[apic].mpc_apicid);
1433
1434 reg_00.bits.ID = mp_ioapics[apic].mpc_apicid;
1435 spin_lock_irqsave(&ioapic_lock, flags);
1436 io_apic_write(apic, 0, reg_00.raw);
1437 spin_unlock_irqrestore(&ioapic_lock, flags);
1438
1439 /*
1440 * Sanity check
1441 */
1442 spin_lock_irqsave(&ioapic_lock, flags);
1443 reg_00.raw = io_apic_read(apic, 0);
1444 spin_unlock_irqrestore(&ioapic_lock, flags);
1445 if (reg_00.bits.ID != mp_ioapics[apic].mpc_apicid)
1446 printk("could not set ID!\n");
1447 else
1448 apic_printk(APIC_VERBOSE," ok.\n");
1449 }
1450}
1451
1452/*
1453 * There is a nasty bug in some older SMP boards, their mptable lies 1136 * There is a nasty bug in some older SMP boards, their mptable lies
1454 * about the timer IRQ. We do the following to work around the situation: 1137 * about the timer IRQ. We do the following to work around the situation:
1455 * 1138 *
@@ -1964,11 +1647,6 @@ void __init setup_IO_APIC(void)
1964 1647
1965 apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n"); 1648 apic_printk(APIC_VERBOSE, "ENABLING IO-APIC IRQs\n");
1966 1649
1967 /*
1968 * Set up the IO-APIC IRQ routing table.
1969 */
1970 if (!acpi_ioapic)
1971 setup_ioapic_ids_from_mpc();
1972 sync_Arb_IDs(); 1650 sync_Arb_IDs();
1973 setup_IO_APIC_irqs(); 1651 setup_IO_APIC_irqs();
1974 init_IO_APIC_traps(); 1652 init_IO_APIC_traps();
@@ -1987,17 +1665,12 @@ static int ioapic_suspend(struct sys_device *dev, pm_message_t state)
1987{ 1665{
1988 struct IO_APIC_route_entry *entry; 1666 struct IO_APIC_route_entry *entry;
1989 struct sysfs_ioapic_data *data; 1667 struct sysfs_ioapic_data *data;
1990 unsigned long flags;
1991 int i; 1668 int i;
1992 1669
1993 data = container_of(dev, struct sysfs_ioapic_data, dev); 1670 data = container_of(dev, struct sysfs_ioapic_data, dev);
1994 entry = data->entry; 1671 entry = data->entry;
1995 spin_lock_irqsave(&ioapic_lock, flags); 1672 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ )
1996 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) { 1673 *entry = ioapic_read_entry(dev->id, i);
1997 *(((int *)entry) + 1) = io_apic_read(dev->id, 0x11 + 2 * i);
1998 *(((int *)entry) + 0) = io_apic_read(dev->id, 0x10 + 2 * i);
1999 }
2000 spin_unlock_irqrestore(&ioapic_lock, flags);
2001 1674
2002 return 0; 1675 return 0;
2003} 1676}
@@ -2019,11 +1692,9 @@ static int ioapic_resume(struct sys_device *dev)
2019 reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid; 1692 reg_00.bits.ID = mp_ioapics[dev->id].mpc_apicid;
2020 io_apic_write(dev->id, 0, reg_00.raw); 1693 io_apic_write(dev->id, 0, reg_00.raw);
2021 } 1694 }
2022 for (i = 0; i < nr_ioapic_registers[dev->id]; i ++, entry ++ ) {
2023 io_apic_write(dev->id, 0x11+2*i, *(((int *)entry)+1));
2024 io_apic_write(dev->id, 0x10+2*i, *(((int *)entry)+0));
2025 }
2026 spin_unlock_irqrestore(&ioapic_lock, flags); 1695 spin_unlock_irqrestore(&ioapic_lock, flags);
1696 for (i = 0; i < nr_ioapic_registers[dev->id]; i++)
1697 ioapic_write_entry(dev->id, i, entry[i]);
2027 1698
2028 return 0; 1699 return 0;
2029} 1700}
@@ -2077,19 +1748,6 @@ device_initcall(ioapic_init_sysfs);
2077 1748
2078#define IO_APIC_MAX_ID 0xFE 1749#define IO_APIC_MAX_ID 0xFE
2079 1750
2080int __init io_apic_get_version (int ioapic)
2081{
2082 union IO_APIC_reg_01 reg_01;
2083 unsigned long flags;
2084
2085 spin_lock_irqsave(&ioapic_lock, flags);
2086 reg_01.raw = io_apic_read(ioapic, 1);
2087 spin_unlock_irqrestore(&ioapic_lock, flags);
2088
2089 return reg_01.bits.version;
2090}
2091
2092
2093int __init io_apic_get_redir_entries (int ioapic) 1751int __init io_apic_get_redir_entries (int ioapic)
2094{ 1752{
2095 union IO_APIC_reg_01 reg_01; 1753 union IO_APIC_reg_01 reg_01;
@@ -2148,10 +1806,10 @@ int io_apic_set_pci_routing (int ioapic, int pin, int irq, int triggering, int p
2148 if (!ioapic && (irq < 16)) 1806 if (!ioapic && (irq < 16))
2149 disable_8259A_irq(irq); 1807 disable_8259A_irq(irq);
2150 1808
1809 ioapic_write_entry(ioapic, pin, entry);
1810
2151 spin_lock_irqsave(&ioapic_lock, flags); 1811 spin_lock_irqsave(&ioapic_lock, flags);
2152 io_apic_write(ioapic, 0x11+2*pin, *(((int *)&entry)+1)); 1812 set_native_irq_info(use_pci_vector() ? entry.vector : irq, TARGET_CPUS);
2153 io_apic_write(ioapic, 0x10+2*pin, *(((int *)&entry)+0));
2154 set_native_irq_info(use_pci_vector() ? entry.vector : irq, TARGET_CPUS);
2155 spin_unlock_irqrestore(&ioapic_lock, flags); 1813 spin_unlock_irqrestore(&ioapic_lock, flags);
2156 1814
2157 return 0; 1815 return 0;
diff --git a/arch/x86_64/kernel/ioport.c b/arch/x86_64/kernel/ioport.c
index b81614970ecc..fe063d3cfe42 100644
--- a/arch/x86_64/kernel/ioport.c
+++ b/arch/x86_64/kernel/ioport.c
@@ -56,6 +56,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
56 56
57 memset(bitmap, 0xff, IO_BITMAP_BYTES); 57 memset(bitmap, 0xff, IO_BITMAP_BYTES);
58 t->io_bitmap_ptr = bitmap; 58 t->io_bitmap_ptr = bitmap;
59 set_thread_flag(TIF_IO_BITMAP);
59 } 60 }
60 61
61 /* 62 /*
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index 5221a53e90c1..b3677e6ccc6e 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -20,11 +20,6 @@
20#include <asm/idle.h> 20#include <asm/idle.h>
21 21
22atomic_t irq_err_count; 22atomic_t irq_err_count;
23#ifdef CONFIG_X86_IO_APIC
24#ifdef APIC_MISMATCH_DEBUG
25atomic_t irq_mis_count;
26#endif
27#endif
28 23
29#ifdef CONFIG_DEBUG_STACKOVERFLOW 24#ifdef CONFIG_DEBUG_STACKOVERFLOW
30/* 25/*
@@ -92,18 +87,11 @@ skip:
92 for_each_online_cpu(j) 87 for_each_online_cpu(j)
93 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count); 88 seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
94 seq_putc(p, '\n'); 89 seq_putc(p, '\n');
95#ifdef CONFIG_X86_LOCAL_APIC
96 seq_printf(p, "LOC: "); 90 seq_printf(p, "LOC: ");
97 for_each_online_cpu(j) 91 for_each_online_cpu(j)
98 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs); 92 seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
99 seq_putc(p, '\n'); 93 seq_putc(p, '\n');
100#endif
101 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count)); 94 seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
102#ifdef CONFIG_X86_IO_APIC
103#ifdef APIC_MISMATCH_DEBUG
104 seq_printf(p, "MIS: %10u\n", atomic_read(&irq_mis_count));
105#endif
106#endif
107 } 95 }
108 return 0; 96 return 0;
109} 97}
diff --git a/arch/x86_64/kernel/machine_kexec.c b/arch/x86_64/kernel/machine_kexec.c
index 106076b370fc..0497e3bd5bff 100644
--- a/arch/x86_64/kernel/machine_kexec.c
+++ b/arch/x86_64/kernel/machine_kexec.c
@@ -15,6 +15,15 @@
15#include <asm/mmu_context.h> 15#include <asm/mmu_context.h>
16#include <asm/io.h> 16#include <asm/io.h>
17 17
18#define PAGE_ALIGNED __attribute__ ((__aligned__(PAGE_SIZE)))
19static u64 kexec_pgd[512] PAGE_ALIGNED;
20static u64 kexec_pud0[512] PAGE_ALIGNED;
21static u64 kexec_pmd0[512] PAGE_ALIGNED;
22static u64 kexec_pte0[512] PAGE_ALIGNED;
23static u64 kexec_pud1[512] PAGE_ALIGNED;
24static u64 kexec_pmd1[512] PAGE_ALIGNED;
25static u64 kexec_pte1[512] PAGE_ALIGNED;
26
18static void init_level2_page(pmd_t *level2p, unsigned long addr) 27static void init_level2_page(pmd_t *level2p, unsigned long addr)
19{ 28{
20 unsigned long end_addr; 29 unsigned long end_addr;
@@ -144,32 +153,19 @@ static void load_segments(void)
144 ); 153 );
145} 154}
146 155
147typedef NORET_TYPE void (*relocate_new_kernel_t)(unsigned long indirection_page,
148 unsigned long control_code_buffer,
149 unsigned long start_address,
150 unsigned long pgtable) ATTRIB_NORET;
151
152extern const unsigned char relocate_new_kernel[];
153extern const unsigned long relocate_new_kernel_size;
154
155int machine_kexec_prepare(struct kimage *image) 156int machine_kexec_prepare(struct kimage *image)
156{ 157{
157 unsigned long start_pgtable, control_code_buffer; 158 unsigned long start_pgtable;
158 int result; 159 int result;
159 160
160 /* Calculate the offsets */ 161 /* Calculate the offsets */
161 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT; 162 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT;
162 control_code_buffer = start_pgtable + PAGE_SIZE;
163 163
164 /* Setup the identity mapped 64bit page table */ 164 /* Setup the identity mapped 64bit page table */
165 result = init_pgtable(image, start_pgtable); 165 result = init_pgtable(image, start_pgtable);
166 if (result) 166 if (result)
167 return result; 167 return result;
168 168
169 /* Place the code in the reboot code buffer */
170 memcpy(__va(control_code_buffer), relocate_new_kernel,
171 relocate_new_kernel_size);
172
173 return 0; 169 return 0;
174} 170}
175 171
@@ -184,28 +180,34 @@ void machine_kexec_cleanup(struct kimage *image)
184 */ 180 */
185NORET_TYPE void machine_kexec(struct kimage *image) 181NORET_TYPE void machine_kexec(struct kimage *image)
186{ 182{
187 unsigned long page_list; 183 unsigned long page_list[PAGES_NR];
188 unsigned long control_code_buffer; 184 void *control_page;
189 unsigned long start_pgtable;
190 relocate_new_kernel_t rnk;
191 185
192 /* Interrupts aren't acceptable while we reboot */ 186 /* Interrupts aren't acceptable while we reboot */
193 local_irq_disable(); 187 local_irq_disable();
194 188
195 /* Calculate the offsets */ 189 control_page = page_address(image->control_code_page) + PAGE_SIZE;
196 page_list = image->head; 190 memcpy(control_page, relocate_kernel, PAGE_SIZE);
197 start_pgtable = page_to_pfn(image->control_code_page) << PAGE_SHIFT; 191
198 control_code_buffer = start_pgtable + PAGE_SIZE; 192 page_list[PA_CONTROL_PAGE] = __pa(control_page);
199 193 page_list[VA_CONTROL_PAGE] = (unsigned long)relocate_kernel;
200 /* Set the low half of the page table to my identity mapped 194 page_list[PA_PGD] = __pa(kexec_pgd);
201 * page table for kexec. Leave the high half pointing at the 195 page_list[VA_PGD] = (unsigned long)kexec_pgd;
202 * kernel pages. Don't bother to flush the global pages 196 page_list[PA_PUD_0] = __pa(kexec_pud0);
203 * as that will happen when I fully switch to my identity mapped 197 page_list[VA_PUD_0] = (unsigned long)kexec_pud0;
204 * page table anyway. 198 page_list[PA_PMD_0] = __pa(kexec_pmd0);
205 */ 199 page_list[VA_PMD_0] = (unsigned long)kexec_pmd0;
206 memcpy(__va(read_cr3()), __va(start_pgtable), PAGE_SIZE/2); 200 page_list[PA_PTE_0] = __pa(kexec_pte0);
207 __flush_tlb(); 201 page_list[VA_PTE_0] = (unsigned long)kexec_pte0;
208 202 page_list[PA_PUD_1] = __pa(kexec_pud1);
203 page_list[VA_PUD_1] = (unsigned long)kexec_pud1;
204 page_list[PA_PMD_1] = __pa(kexec_pmd1);
205 page_list[VA_PMD_1] = (unsigned long)kexec_pmd1;
206 page_list[PA_PTE_1] = __pa(kexec_pte1);
207 page_list[VA_PTE_1] = (unsigned long)kexec_pte1;
208
209 page_list[PA_TABLE_PAGE] =
210 (unsigned long)__pa(page_address(image->control_code_page));
209 211
210 /* The segment registers are funny things, they have both a 212 /* The segment registers are funny things, they have both a
211 * visible and an invisible part. Whenever the visible part is 213 * visible and an invisible part. Whenever the visible part is
@@ -222,7 +224,36 @@ NORET_TYPE void machine_kexec(struct kimage *image)
222 */ 224 */
223 set_gdt(phys_to_virt(0),0); 225 set_gdt(phys_to_virt(0),0);
224 set_idt(phys_to_virt(0),0); 226 set_idt(phys_to_virt(0),0);
227
225 /* now call it */ 228 /* now call it */
226 rnk = (relocate_new_kernel_t) control_code_buffer; 229 relocate_kernel((unsigned long)image->head, (unsigned long)page_list,
227 (*rnk)(page_list, control_code_buffer, image->start, start_pgtable); 230 image->start);
228} 231}
232
233/* crashkernel=size@addr specifies the location to reserve for
234 * a crash kernel. By reserving this memory we guarantee
235 * that linux never set's it up as a DMA target.
236 * Useful for holding code to do something appropriate
237 * after a kernel panic.
238 */
239static int __init setup_crashkernel(char *arg)
240{
241 unsigned long size, base;
242 char *p;
243 if (!arg)
244 return -EINVAL;
245 size = memparse(arg, &p);
246 if (arg == p)
247 return -EINVAL;
248 if (*p == '@') {
249 base = memparse(p+1, &p);
250 /* FIXME: Do I want a sanity check to validate the
251 * memory range? Yes you do, but it's too early for
252 * e820 -AK */
253 crashk_res.start = base;
254 crashk_res.end = base + size - 1;
255 }
256 return 0;
257}
258early_param("crashkernel", setup_crashkernel);
259
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index 4e017fb30fb3..bbea88801d88 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -182,7 +182,7 @@ void do_machine_check(struct pt_regs * regs, long error_code)
182 goto out2; 182 goto out2;
183 183
184 memset(&m, 0, sizeof(struct mce)); 184 memset(&m, 0, sizeof(struct mce));
185 m.cpu = safe_smp_processor_id(); 185 m.cpu = smp_processor_id();
186 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); 186 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
187 if (!(m.mcgstatus & MCG_STATUS_RIPV)) 187 if (!(m.mcgstatus & MCG_STATUS_RIPV))
188 kill_it = 1; 188 kill_it = 1;
@@ -274,6 +274,33 @@ void do_machine_check(struct pt_regs * regs, long error_code)
274 atomic_dec(&mce_entry); 274 atomic_dec(&mce_entry);
275} 275}
276 276
277#ifdef CONFIG_X86_MCE_INTEL
278/***
279 * mce_log_therm_throt_event - Logs the thermal throttling event to mcelog
280 * @cpu: The CPU on which the event occured.
281 * @status: Event status information
282 *
283 * This function should be called by the thermal interrupt after the
284 * event has been processed and the decision was made to log the event
285 * further.
286 *
287 * The status parameter will be saved to the 'status' field of 'struct mce'
288 * and historically has been the register value of the
289 * MSR_IA32_THERMAL_STATUS (Intel) msr.
290 */
291void mce_log_therm_throt_event(unsigned int cpu, __u64 status)
292{
293 struct mce m;
294
295 memset(&m, 0, sizeof(m));
296 m.cpu = cpu;
297 m.bank = MCE_THERMAL_BANK;
298 m.status = status;
299 rdtscll(m.tsc);
300 mce_log(&m);
301}
302#endif /* CONFIG_X86_MCE_INTEL */
303
277/* 304/*
278 * Periodic polling timer for "silent" machine check errors. 305 * Periodic polling timer for "silent" machine check errors.
279 */ 306 */
diff --git a/arch/x86_64/kernel/mce_intel.c b/arch/x86_64/kernel/mce_intel.c
index 8f533d2c40cb..6551505d8a2c 100644
--- a/arch/x86_64/kernel/mce_intel.c
+++ b/arch/x86_64/kernel/mce_intel.c
@@ -11,36 +11,21 @@
11#include <asm/mce.h> 11#include <asm/mce.h>
12#include <asm/hw_irq.h> 12#include <asm/hw_irq.h>
13#include <asm/idle.h> 13#include <asm/idle.h>
14 14#include <asm/therm_throt.h>
15static DEFINE_PER_CPU(unsigned long, next_check);
16 15
17asmlinkage void smp_thermal_interrupt(void) 16asmlinkage void smp_thermal_interrupt(void)
18{ 17{
19 struct mce m; 18 __u64 msr_val;
20 19
21 ack_APIC_irq(); 20 ack_APIC_irq();
22 21
23 exit_idle(); 22 exit_idle();
24 irq_enter(); 23 irq_enter();
25 if (time_before(jiffies, __get_cpu_var(next_check)))
26 goto done;
27
28 __get_cpu_var(next_check) = jiffies + HZ*300;
29 memset(&m, 0, sizeof(m));
30 m.cpu = smp_processor_id();
31 m.bank = MCE_THERMAL_BANK;
32 rdtscll(m.tsc);
33 rdmsrl(MSR_IA32_THERM_STATUS, m.status);
34 if (m.status & 0x1) {
35 printk(KERN_EMERG
36 "CPU%d: Temperature above threshold, cpu clock throttled\n", m.cpu);
37 add_taint(TAINT_MACHINE_CHECK);
38 } else {
39 printk(KERN_EMERG "CPU%d: Temperature/speed normal\n", m.cpu);
40 }
41 24
42 mce_log(&m); 25 rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
43done: 26 if (therm_throt_process(msr_val & 1))
27 mce_log_therm_throt_event(smp_processor_id(), msr_val);
28
44 irq_exit(); 29 irq_exit();
45} 30}
46 31
@@ -92,6 +77,9 @@ static void __cpuinit intel_init_thermal(struct cpuinfo_x86 *c)
92 apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED); 77 apic_write(APIC_LVTTHMR, l & ~APIC_LVT_MASKED);
93 printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n", 78 printk(KERN_INFO "CPU%d: Thermal monitoring enabled (%s)\n",
94 cpu, tm2 ? "TM2" : "TM1"); 79 cpu, tm2 ? "TM2" : "TM1");
80
81 /* enable thermal throttle processing */
82 atomic_set(&therm_throt_en, 1);
95 return; 83 return;
96} 84}
97 85
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index a1ab4197f8a1..20e88f4b564b 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -41,8 +41,7 @@ int acpi_found_madt;
41 * Various Linux-internal data structures created from the 41 * Various Linux-internal data structures created from the
42 * MP-table. 42 * MP-table.
43 */ 43 */
44unsigned char apic_version [MAX_APICS]; 44DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
45unsigned char mp_bus_id_to_type [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
46int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 }; 45int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
47 46
48static int mp_current_pci_id = 0; 47static int mp_current_pci_id = 0;
@@ -56,7 +55,6 @@ struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
56int mp_irq_entries; 55int mp_irq_entries;
57 56
58int nr_ioapics; 57int nr_ioapics;
59int pic_mode;
60unsigned long mp_lapic_addr = 0; 58unsigned long mp_lapic_addr = 0;
61 59
62 60
@@ -71,19 +69,6 @@ unsigned disabled_cpus __initdata;
71/* Bitmask of physically existing CPUs */ 69/* Bitmask of physically existing CPUs */
72physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE; 70physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
73 71
74/* ACPI MADT entry parsing functions */
75#ifdef CONFIG_ACPI
76extern struct acpi_boot_flags acpi_boot;
77#ifdef CONFIG_X86_LOCAL_APIC
78extern int acpi_parse_lapic (acpi_table_entry_header *header);
79extern int acpi_parse_lapic_addr_ovr (acpi_table_entry_header *header);
80extern int acpi_parse_lapic_nmi (acpi_table_entry_header *header);
81#endif /*CONFIG_X86_LOCAL_APIC*/
82#ifdef CONFIG_X86_IO_APIC
83extern int acpi_parse_ioapic (acpi_table_entry_header *header);
84#endif /*CONFIG_X86_IO_APIC*/
85#endif /*CONFIG_ACPI*/
86
87u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID }; 72u8 bios_cpu_apicid[NR_CPUS] = { [0 ... NR_CPUS-1] = BAD_APICID };
88 73
89 74
@@ -108,24 +93,20 @@ static int __init mpf_checksum(unsigned char *mp, int len)
108static void __cpuinit MP_processor_info (struct mpc_config_processor *m) 93static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
109{ 94{
110 int cpu; 95 int cpu;
111 unsigned char ver;
112 cpumask_t tmp_map; 96 cpumask_t tmp_map;
97 char *bootup_cpu = "";
113 98
114 if (!(m->mpc_cpuflag & CPU_ENABLED)) { 99 if (!(m->mpc_cpuflag & CPU_ENABLED)) {
115 disabled_cpus++; 100 disabled_cpus++;
116 return; 101 return;
117 } 102 }
118
119 printk(KERN_INFO "Processor #%d %d:%d APIC version %d\n",
120 m->mpc_apicid,
121 (m->mpc_cpufeature & CPU_FAMILY_MASK)>>8,
122 (m->mpc_cpufeature & CPU_MODEL_MASK)>>4,
123 m->mpc_apicver);
124
125 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { 103 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
126 Dprintk(" Bootup CPU\n"); 104 bootup_cpu = " (Bootup-CPU)";
127 boot_cpu_id = m->mpc_apicid; 105 boot_cpu_id = m->mpc_apicid;
128 } 106 }
107
108 printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
109
129 if (num_processors >= NR_CPUS) { 110 if (num_processors >= NR_CPUS) {
130 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached." 111 printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
131 " Processor ignored.\n", NR_CPUS); 112 " Processor ignored.\n", NR_CPUS);
@@ -136,24 +117,7 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
136 cpus_complement(tmp_map, cpu_present_map); 117 cpus_complement(tmp_map, cpu_present_map);
137 cpu = first_cpu(tmp_map); 118 cpu = first_cpu(tmp_map);
138 119
139#if MAX_APICS < 255
140 if ((int)m->mpc_apicid > MAX_APICS) {
141 printk(KERN_ERR "Processor #%d INVALID. (Max ID: %d).\n",
142 m->mpc_apicid, MAX_APICS);
143 return;
144 }
145#endif
146 ver = m->mpc_apicver;
147
148 physid_set(m->mpc_apicid, phys_cpu_present_map); 120 physid_set(m->mpc_apicid, phys_cpu_present_map);
149 /*
150 * Validate version
151 */
152 if (ver == 0x0) {
153 printk(KERN_ERR "BIOS bug, APIC version is 0 for CPU#%d! fixing up to 0x10. (tell your hw vendor)\n", m->mpc_apicid);
154 ver = 0x10;
155 }
156 apic_version[m->mpc_apicid] = ver;
157 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) { 121 if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
158 /* 122 /*
159 * bios_cpu_apicid is required to have processors listed 123 * bios_cpu_apicid is required to have processors listed
@@ -178,15 +142,11 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
178 Dprintk("Bus #%d is %s\n", m->mpc_busid, str); 142 Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
179 143
180 if (strncmp(str, "ISA", 3) == 0) { 144 if (strncmp(str, "ISA", 3) == 0) {
181 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA; 145 set_bit(m->mpc_busid, mp_bus_not_pci);
182 } else if (strncmp(str, "EISA", 4) == 0) {
183 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_EISA;
184 } else if (strncmp(str, "PCI", 3) == 0) { 146 } else if (strncmp(str, "PCI", 3) == 0) {
185 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_PCI; 147 clear_bit(m->mpc_busid, mp_bus_not_pci);
186 mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id; 148 mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
187 mp_current_pci_id++; 149 mp_current_pci_id++;
188 } else if (strncmp(str, "MCA", 3) == 0) {
189 mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
190 } else { 150 } else {
191 printk(KERN_ERR "Unknown bustype %s\n", str); 151 printk(KERN_ERR "Unknown bustype %s\n", str);
192 } 152 }
@@ -197,8 +157,8 @@ static void __init MP_ioapic_info (struct mpc_config_ioapic *m)
197 if (!(m->mpc_flags & MPC_APIC_USABLE)) 157 if (!(m->mpc_flags & MPC_APIC_USABLE))
198 return; 158 return;
199 159
200 printk("I/O APIC #%d Version %d at 0x%X.\n", 160 printk("I/O APIC #%d at 0x%X.\n",
201 m->mpc_apicid, m->mpc_apicver, m->mpc_apicaddr); 161 m->mpc_apicid, m->mpc_apicaddr);
202 if (nr_ioapics >= MAX_IO_APICS) { 162 if (nr_ioapics >= MAX_IO_APICS) {
203 printk(KERN_ERR "Max # of I/O APICs (%d) exceeded (found %d).\n", 163 printk(KERN_ERR "Max # of I/O APICs (%d) exceeded (found %d).\n",
204 MAX_IO_APICS, nr_ioapics); 164 MAX_IO_APICS, nr_ioapics);
@@ -232,19 +192,6 @@ static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
232 m->mpc_irqtype, m->mpc_irqflag & 3, 192 m->mpc_irqtype, m->mpc_irqflag & 3,
233 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid, 193 (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
234 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint); 194 m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
235 /*
236 * Well it seems all SMP boards in existence
237 * use ExtINT/LVT1 == LINT0 and
238 * NMI/LVT2 == LINT1 - the following check
239 * will show us if this assumptions is false.
240 * Until then we do not have to add baggage.
241 */
242 if ((m->mpc_irqtype == mp_ExtINT) &&
243 (m->mpc_destapiclint != 0))
244 BUG();
245 if ((m->mpc_irqtype == mp_NMI) &&
246 (m->mpc_destapiclint != 1))
247 BUG();
248} 195}
249 196
250/* 197/*
@@ -258,7 +205,7 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
258 unsigned char *mpt=((unsigned char *)mpc)+count; 205 unsigned char *mpt=((unsigned char *)mpc)+count;
259 206
260 if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) { 207 if (memcmp(mpc->mpc_signature,MPC_SIGNATURE,4)) {
261 printk("SMP mptable: bad signature [%c%c%c%c]!\n", 208 printk("MPTABLE: bad signature [%c%c%c%c]!\n",
262 mpc->mpc_signature[0], 209 mpc->mpc_signature[0],
263 mpc->mpc_signature[1], 210 mpc->mpc_signature[1],
264 mpc->mpc_signature[2], 211 mpc->mpc_signature[2],
@@ -266,31 +213,31 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
266 return 0; 213 return 0;
267 } 214 }
268 if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) { 215 if (mpf_checksum((unsigned char *)mpc,mpc->mpc_length)) {
269 printk("SMP mptable: checksum error!\n"); 216 printk("MPTABLE: checksum error!\n");
270 return 0; 217 return 0;
271 } 218 }
272 if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) { 219 if (mpc->mpc_spec!=0x01 && mpc->mpc_spec!=0x04) {
273 printk(KERN_ERR "SMP mptable: bad table version (%d)!!\n", 220 printk(KERN_ERR "MPTABLE: bad table version (%d)!!\n",
274 mpc->mpc_spec); 221 mpc->mpc_spec);
275 return 0; 222 return 0;
276 } 223 }
277 if (!mpc->mpc_lapic) { 224 if (!mpc->mpc_lapic) {
278 printk(KERN_ERR "SMP mptable: null local APIC address!\n"); 225 printk(KERN_ERR "MPTABLE: null local APIC address!\n");
279 return 0; 226 return 0;
280 } 227 }
281 memcpy(str,mpc->mpc_oem,8); 228 memcpy(str,mpc->mpc_oem,8);
282 str[8]=0; 229 str[8] = 0;
283 printk(KERN_INFO "OEM ID: %s ",str); 230 printk(KERN_INFO "MPTABLE: OEM ID: %s ",str);
284 231
285 memcpy(str,mpc->mpc_productid,12); 232 memcpy(str,mpc->mpc_productid,12);
286 str[12]=0; 233 str[12] = 0;
287 printk("Product ID: %s ",str); 234 printk("MPTABLE: Product ID: %s ",str);
288 235
289 printk("APIC at: 0x%X\n",mpc->mpc_lapic); 236 printk("MPTABLE: APIC at: 0x%X\n",mpc->mpc_lapic);
290 237
291 /* save the local APIC address, it might be non-default */ 238 /* save the local APIC address, it might be non-default */
292 if (!acpi_lapic) 239 if (!acpi_lapic)
293 mp_lapic_addr = mpc->mpc_lapic; 240 mp_lapic_addr = mpc->mpc_lapic;
294 241
295 /* 242 /*
296 * Now process the configuration blocks. 243 * Now process the configuration blocks.
@@ -302,7 +249,7 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
302 struct mpc_config_processor *m= 249 struct mpc_config_processor *m=
303 (struct mpc_config_processor *)mpt; 250 (struct mpc_config_processor *)mpt;
304 if (!acpi_lapic) 251 if (!acpi_lapic)
305 MP_processor_info(m); 252 MP_processor_info(m);
306 mpt += sizeof(*m); 253 mpt += sizeof(*m);
307 count += sizeof(*m); 254 count += sizeof(*m);
308 break; 255 break;
@@ -321,8 +268,8 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
321 struct mpc_config_ioapic *m= 268 struct mpc_config_ioapic *m=
322 (struct mpc_config_ioapic *)mpt; 269 (struct mpc_config_ioapic *)mpt;
323 MP_ioapic_info(m); 270 MP_ioapic_info(m);
324 mpt+=sizeof(*m); 271 mpt += sizeof(*m);
325 count+=sizeof(*m); 272 count += sizeof(*m);
326 break; 273 break;
327 } 274 }
328 case MP_INTSRC: 275 case MP_INTSRC:
@@ -331,8 +278,8 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
331 (struct mpc_config_intsrc *)mpt; 278 (struct mpc_config_intsrc *)mpt;
332 279
333 MP_intsrc_info(m); 280 MP_intsrc_info(m);
334 mpt+=sizeof(*m); 281 mpt += sizeof(*m);
335 count+=sizeof(*m); 282 count += sizeof(*m);
336 break; 283 break;
337 } 284 }
338 case MP_LINTSRC: 285 case MP_LINTSRC:
@@ -340,15 +287,15 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
340 struct mpc_config_lintsrc *m= 287 struct mpc_config_lintsrc *m=
341 (struct mpc_config_lintsrc *)mpt; 288 (struct mpc_config_lintsrc *)mpt;
342 MP_lintsrc_info(m); 289 MP_lintsrc_info(m);
343 mpt+=sizeof(*m); 290 mpt += sizeof(*m);
344 count+=sizeof(*m); 291 count += sizeof(*m);
345 break; 292 break;
346 } 293 }
347 } 294 }
348 } 295 }
349 clustered_apic_check(); 296 clustered_apic_check();
350 if (!num_processors) 297 if (!num_processors)
351 printk(KERN_ERR "SMP mptable: no processors registered!\n"); 298 printk(KERN_ERR "MPTABLE: no processors registered!\n");
352 return num_processors; 299 return num_processors;
353} 300}
354 301
@@ -444,13 +391,10 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
444 * 2 CPUs, numbered 0 & 1. 391 * 2 CPUs, numbered 0 & 1.
445 */ 392 */
446 processor.mpc_type = MP_PROCESSOR; 393 processor.mpc_type = MP_PROCESSOR;
447 /* Either an integrated APIC or a discrete 82489DX. */ 394 processor.mpc_apicver = 0;
448 processor.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
449 processor.mpc_cpuflag = CPU_ENABLED; 395 processor.mpc_cpuflag = CPU_ENABLED;
450 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 396 processor.mpc_cpufeature = 0;
451 (boot_cpu_data.x86_model << 4) | 397 processor.mpc_featureflag = 0;
452 boot_cpu_data.x86_mask;
453 processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
454 processor.mpc_reserved[0] = 0; 398 processor.mpc_reserved[0] = 0;
455 processor.mpc_reserved[1] = 0; 399 processor.mpc_reserved[1] = 0;
456 for (i = 0; i < 2; i++) { 400 for (i = 0; i < 2; i++) {
@@ -469,14 +413,6 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
469 case 5: 413 case 5:
470 memcpy(bus.mpc_bustype, "ISA ", 6); 414 memcpy(bus.mpc_bustype, "ISA ", 6);
471 break; 415 break;
472 case 2:
473 case 6:
474 case 3:
475 memcpy(bus.mpc_bustype, "EISA ", 6);
476 break;
477 case 4:
478 case 7:
479 memcpy(bus.mpc_bustype, "MCA ", 6);
480 } 416 }
481 MP_bus_info(&bus); 417 MP_bus_info(&bus);
482 if (mpc_default_type > 4) { 418 if (mpc_default_type > 4) {
@@ -487,7 +423,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
487 423
488 ioapic.mpc_type = MP_IOAPIC; 424 ioapic.mpc_type = MP_IOAPIC;
489 ioapic.mpc_apicid = 2; 425 ioapic.mpc_apicid = 2;
490 ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01; 426 ioapic.mpc_apicver = 0;
491 ioapic.mpc_flags = MPC_APIC_USABLE; 427 ioapic.mpc_flags = MPC_APIC_USABLE;
492 ioapic.mpc_apicaddr = 0xFEC00000; 428 ioapic.mpc_apicaddr = 0xFEC00000;
493 MP_ioapic_info(&ioapic); 429 MP_ioapic_info(&ioapic);
@@ -530,13 +466,6 @@ void __init get_smp_config (void)
530 printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n"); 466 printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
531 467
532 printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification); 468 printk("Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
533 if (mpf->mpf_feature2 & (1<<7)) {
534 printk(KERN_INFO " IMCR and PIC compatibility mode.\n");
535 pic_mode = 1;
536 } else {
537 printk(KERN_INFO " Virtual Wire compatibility mode.\n");
538 pic_mode = 0;
539 }
540 469
541 /* 470 /*
542 * Now see if we need to read further. 471 * Now see if we need to read further.
@@ -616,7 +545,7 @@ static int __init smp_scan_config (unsigned long base, unsigned long length)
616 return 0; 545 return 0;
617} 546}
618 547
619void __init find_intel_smp (void) 548void __init find_smp_config(void)
620{ 549{
621 unsigned int address; 550 unsigned int address;
622 551
@@ -633,9 +562,7 @@ void __init find_intel_smp (void)
633 smp_scan_config(0xF0000,0x10000)) 562 smp_scan_config(0xF0000,0x10000))
634 return; 563 return;
635 /* 564 /*
636 * If it is an SMP machine we should know now, unless the 565 * If it is an SMP machine we should know now.
637 * configuration is in an EISA/MCA bus machine with an
638 * extended bios data area.
639 * 566 *
640 * there is a real-mode segmented pointer pointing to the 567 * there is a real-mode segmented pointer pointing to the
641 * 4K EBDA area at 0x40E, calculate and scan it here. 568 * 4K EBDA area at 0x40E, calculate and scan it here.
@@ -656,69 +583,41 @@ void __init find_intel_smp (void)
656 printk(KERN_INFO "No mptable found.\n"); 583 printk(KERN_INFO "No mptable found.\n");
657} 584}
658 585
659/*
660 * - Intel MP Configuration Table
661 */
662void __init find_smp_config (void)
663{
664#ifdef CONFIG_X86_LOCAL_APIC
665 find_intel_smp();
666#endif
667}
668
669
670/* -------------------------------------------------------------------------- 586/* --------------------------------------------------------------------------
671 ACPI-based MP Configuration 587 ACPI-based MP Configuration
672 -------------------------------------------------------------------------- */ 588 -------------------------------------------------------------------------- */
673 589
674#ifdef CONFIG_ACPI 590#ifdef CONFIG_ACPI
675 591
676void __init mp_register_lapic_address ( 592void __init mp_register_lapic_address(u64 address)
677 u64 address)
678{ 593{
679 mp_lapic_addr = (unsigned long) address; 594 mp_lapic_addr = (unsigned long) address;
680
681 set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr); 595 set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
682
683 if (boot_cpu_id == -1U) 596 if (boot_cpu_id == -1U)
684 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID)); 597 boot_cpu_id = GET_APIC_ID(apic_read(APIC_ID));
685
686 Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
687} 598}
688 599
689 600void __cpuinit mp_register_lapic (u8 id, u8 enabled)
690void __cpuinit mp_register_lapic (
691 u8 id,
692 u8 enabled)
693{ 601{
694 struct mpc_config_processor processor; 602 struct mpc_config_processor processor;
695 int boot_cpu = 0; 603 int boot_cpu = 0;
696 604
697 if (id >= MAX_APICS) { 605 if (id == boot_cpu_id)
698 printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
699 id, MAX_APICS);
700 return;
701 }
702
703 if (id == boot_cpu_physical_apicid)
704 boot_cpu = 1; 606 boot_cpu = 1;
705 607
706 processor.mpc_type = MP_PROCESSOR; 608 processor.mpc_type = MP_PROCESSOR;
707 processor.mpc_apicid = id; 609 processor.mpc_apicid = id;
708 processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR)); 610 processor.mpc_apicver = 0;
709 processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0); 611 processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
710 processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0); 612 processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
711 processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 613 processor.mpc_cpufeature = 0;
712 (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask; 614 processor.mpc_featureflag = 0;
713 processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
714 processor.mpc_reserved[0] = 0; 615 processor.mpc_reserved[0] = 0;
715 processor.mpc_reserved[1] = 0; 616 processor.mpc_reserved[1] = 0;
716 617
717 MP_processor_info(&processor); 618 MP_processor_info(&processor);
718} 619}
719 620
720#ifdef CONFIG_X86_IO_APIC
721
722#define MP_ISA_BUS 0 621#define MP_ISA_BUS 0
723#define MP_MAX_IOAPIC_PIN 127 622#define MP_MAX_IOAPIC_PIN 127
724 623
@@ -729,11 +628,9 @@ static struct mp_ioapic_routing {
729 u32 pin_programmed[4]; 628 u32 pin_programmed[4];
730} mp_ioapic_routing[MAX_IO_APICS]; 629} mp_ioapic_routing[MAX_IO_APICS];
731 630
732 631static int mp_find_ioapic(int gsi)
733static int mp_find_ioapic (
734 int gsi)
735{ 632{
736 int i = 0; 633 int i = 0;
737 634
738 /* Find the IOAPIC that manages this GSI. */ 635 /* Find the IOAPIC that manages this GSI. */
739 for (i = 0; i < nr_ioapics; i++) { 636 for (i = 0; i < nr_ioapics; i++) {
@@ -743,17 +640,12 @@ static int mp_find_ioapic (
743 } 640 }
744 641
745 printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi); 642 printk(KERN_ERR "ERROR: Unable to locate IOAPIC for GSI %d\n", gsi);
746
747 return -1; 643 return -1;
748} 644}
749
750 645
751void __init mp_register_ioapic ( 646void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
752 u8 id,
753 u32 address,
754 u32 gsi_base)
755{ 647{
756 int idx = 0; 648 int idx = 0;
757 649
758 if (nr_ioapics >= MAX_IO_APICS) { 650 if (nr_ioapics >= MAX_IO_APICS) {
759 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded " 651 printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
@@ -774,7 +666,7 @@ void __init mp_register_ioapic (
774 666
775 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); 667 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
776 mp_ioapics[idx].mpc_apicid = id; 668 mp_ioapics[idx].mpc_apicid = id;
777 mp_ioapics[idx].mpc_apicver = io_apic_get_version(idx); 669 mp_ioapics[idx].mpc_apicver = 0;
778 670
779 /* 671 /*
780 * Build basic IRQ lookup table to facilitate gsi->io_apic lookups 672 * Build basic IRQ lookup table to facilitate gsi->io_apic lookups
@@ -785,21 +677,15 @@ void __init mp_register_ioapic (
785 mp_ioapic_routing[idx].gsi_end = gsi_base + 677 mp_ioapic_routing[idx].gsi_end = gsi_base +
786 io_apic_get_redir_entries(idx); 678 io_apic_get_redir_entries(idx);
787 679
788 printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " 680 printk(KERN_INFO "IOAPIC[%d]: apic_id %d, address 0x%x, "
789 "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid, 681 "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
790 mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr, 682 mp_ioapics[idx].mpc_apicaddr,
791 mp_ioapic_routing[idx].gsi_start, 683 mp_ioapic_routing[idx].gsi_start,
792 mp_ioapic_routing[idx].gsi_end); 684 mp_ioapic_routing[idx].gsi_end);
793
794 return;
795} 685}
796 686
797 687void __init
798void __init mp_override_legacy_irq ( 688mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
799 u8 bus_irq,
800 u8 polarity,
801 u8 trigger,
802 u32 gsi)
803{ 689{
804 struct mpc_config_intsrc intsrc; 690 struct mpc_config_intsrc intsrc;
805 int ioapic = -1; 691 int ioapic = -1;
@@ -837,22 +723,18 @@ void __init mp_override_legacy_irq (
837 mp_irqs[mp_irq_entries] = intsrc; 723 mp_irqs[mp_irq_entries] = intsrc;
838 if (++mp_irq_entries == MAX_IRQ_SOURCES) 724 if (++mp_irq_entries == MAX_IRQ_SOURCES)
839 panic("Max # of irq sources exceeded!\n"); 725 panic("Max # of irq sources exceeded!\n");
840
841 return;
842} 726}
843 727
844 728void __init mp_config_acpi_legacy_irqs(void)
845void __init mp_config_acpi_legacy_irqs (void)
846{ 729{
847 struct mpc_config_intsrc intsrc; 730 struct mpc_config_intsrc intsrc;
848 int i = 0; 731 int i = 0;
849 int ioapic = -1; 732 int ioapic = -1;
850 733
851 /* 734 /*
852 * Fabricate the legacy ISA bus (bus #31). 735 * Fabricate the legacy ISA bus (bus #31).
853 */ 736 */
854 mp_bus_id_to_type[MP_ISA_BUS] = MP_BUS_ISA; 737 set_bit(MP_ISA_BUS, mp_bus_not_pci);
855 Dprintk("Bus #%d is ISA\n", MP_ISA_BUS);
856 738
857 /* 739 /*
858 * Locate the IOAPIC that manages the ISA IRQs (0-15). 740 * Locate the IOAPIC that manages the ISA IRQs (0-15).
@@ -905,24 +787,22 @@ void __init mp_config_acpi_legacy_irqs (void)
905 if (++mp_irq_entries == MAX_IRQ_SOURCES) 787 if (++mp_irq_entries == MAX_IRQ_SOURCES)
906 panic("Max # of irq sources exceeded!\n"); 788 panic("Max # of irq sources exceeded!\n");
907 } 789 }
908
909 return;
910} 790}
911 791
912#define MAX_GSI_NUM 4096 792#define MAX_GSI_NUM 4096
913 793
914int mp_register_gsi(u32 gsi, int triggering, int polarity) 794int mp_register_gsi(u32 gsi, int triggering, int polarity)
915{ 795{
916 int ioapic = -1; 796 int ioapic = -1;
917 int ioapic_pin = 0; 797 int ioapic_pin = 0;
918 int idx, bit = 0; 798 int idx, bit = 0;
919 static int pci_irq = 16; 799 static int pci_irq = 16;
920 /* 800 /*
921 * Mapping between Global System Interrupts, which 801 * Mapping between Global System Interrupts, which
922 * represent all possible interrupts, to the IRQs 802 * represent all possible interrupts, to the IRQs
923 * assigned to actual devices. 803 * assigned to actual devices.
924 */ 804 */
925 static int gsi_to_irq[MAX_GSI_NUM]; 805 static int gsi_to_irq[MAX_GSI_NUM];
926 806
927 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC) 807 if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
928 return gsi; 808 return gsi;
@@ -996,6 +876,4 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
996 polarity == ACPI_ACTIVE_HIGH ? 0 : 1); 876 polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
997 return gsi; 877 return gsi;
998} 878}
999
1000#endif /*CONFIG_X86_IO_APIC*/
1001#endif /*CONFIG_ACPI*/ 879#endif /*CONFIG_ACPI*/
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 5baa0c726e97..4d6fb047952e 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -28,71 +28,138 @@
28#include <asm/mce.h> 28#include <asm/mce.h>
29#include <asm/intel_arch_perfmon.h> 29#include <asm/intel_arch_perfmon.h>
30 30
31/* 31/* perfctr_nmi_owner tracks the ownership of the perfctr registers:
32 * lapic_nmi_owner tracks the ownership of the lapic NMI hardware: 32 * evtsel_nmi_owner tracks the ownership of the event selection
33 * - it may be reserved by some other driver, or not 33 * - different performance counters/ event selection may be reserved for
34 * - when not reserved by some other driver, it may be used for 34 * different subsystems this reservation system just tries to coordinate
35 * the NMI watchdog, or not 35 * things a little
36 *
37 * This is maintained separately from nmi_active because the NMI
38 * watchdog may also be driven from the I/O APIC timer.
39 */ 36 */
40static DEFINE_SPINLOCK(lapic_nmi_owner_lock); 37static DEFINE_PER_CPU(unsigned, perfctr_nmi_owner);
41static unsigned int lapic_nmi_owner; 38static DEFINE_PER_CPU(unsigned, evntsel_nmi_owner[2]);
42#define LAPIC_NMI_WATCHDOG (1<<0) 39
43#define LAPIC_NMI_RESERVED (1<<1) 40/* this number is calculated from Intel's MSR_P4_CRU_ESCR5 register and it's
41 * offset from MSR_P4_BSU_ESCR0. It will be the max for all platforms (for now)
42 */
43#define NMI_MAX_COUNTER_BITS 66
44 44
45/* nmi_active: 45/* nmi_active:
46 * +1: the lapic NMI watchdog is active, but can be disabled 46 * >0: the lapic NMI watchdog is active, but can be disabled
47 * 0: the lapic NMI watchdog has not been set up, and cannot 47 * <0: the lapic NMI watchdog has not been set up, and cannot
48 * be enabled 48 * be enabled
49 * -1: the lapic NMI watchdog is disabled, but can be enabled 49 * 0: the lapic NMI watchdog is disabled, but can be enabled
50 */ 50 */
51int nmi_active; /* oprofile uses this */ 51atomic_t nmi_active = ATOMIC_INIT(0); /* oprofile uses this */
52int panic_on_timeout; 52int panic_on_timeout;
53 53
54unsigned int nmi_watchdog = NMI_DEFAULT; 54unsigned int nmi_watchdog = NMI_DEFAULT;
55static unsigned int nmi_hz = HZ; 55static unsigned int nmi_hz = HZ;
56static unsigned int nmi_perfctr_msr; /* the MSR to reset in NMI handler */
57static unsigned int nmi_p4_cccr_val;
58 56
59/* Note that these events don't tick when the CPU idles. This means 57struct nmi_watchdog_ctlblk {
60 the frequency varies with CPU load. */ 58 int enabled;
59 u64 check_bit;
60 unsigned int cccr_msr;
61 unsigned int perfctr_msr; /* the MSR to reset in NMI handler */
62 unsigned int evntsel_msr; /* the MSR to select the events to handle */
63};
64static DEFINE_PER_CPU(struct nmi_watchdog_ctlblk, nmi_watchdog_ctlblk);
61 65
62#define K7_EVNTSEL_ENABLE (1 << 22) 66/* local prototypes */
63#define K7_EVNTSEL_INT (1 << 20) 67static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu);
64#define K7_EVNTSEL_OS (1 << 17)
65#define K7_EVNTSEL_USR (1 << 16)
66#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76
67#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING
68 68
69#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL 69/* converts an msr to an appropriate reservation bit */
70#define ARCH_PERFMON_NMI_EVENT_UMASK ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK 70static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr)
71{
72 /* returns the bit offset of the performance counter register */
73 switch (boot_cpu_data.x86_vendor) {
74 case X86_VENDOR_AMD:
75 return (msr - MSR_K7_PERFCTR0);
76 case X86_VENDOR_INTEL:
77 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
78 return (msr - MSR_ARCH_PERFMON_PERFCTR0);
79 else
80 return (msr - MSR_P4_BPU_PERFCTR0);
81 }
82 return 0;
83}
71 84
72#define MSR_P4_MISC_ENABLE 0x1A0 85/* converts an msr to an appropriate reservation bit */
73#define MSR_P4_MISC_ENABLE_PERF_AVAIL (1<<7) 86static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr)
74#define MSR_P4_MISC_ENABLE_PEBS_UNAVAIL (1<<12) 87{
75#define MSR_P4_PERFCTR0 0x300 88 /* returns the bit offset of the event selection register */
76#define MSR_P4_CCCR0 0x360 89 switch (boot_cpu_data.x86_vendor) {
77#define P4_ESCR_EVENT_SELECT(N) ((N)<<25) 90 case X86_VENDOR_AMD:
78#define P4_ESCR_OS (1<<3) 91 return (msr - MSR_K7_EVNTSEL0);
79#define P4_ESCR_USR (1<<2) 92 case X86_VENDOR_INTEL:
80#define P4_CCCR_OVF_PMI0 (1<<26) 93 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON))
81#define P4_CCCR_OVF_PMI1 (1<<27) 94 return (msr - MSR_ARCH_PERFMON_EVENTSEL0);
82#define P4_CCCR_THRESHOLD(N) ((N)<<20) 95 else
83#define P4_CCCR_COMPLEMENT (1<<19) 96 return (msr - MSR_P4_BSU_ESCR0);
84#define P4_CCCR_COMPARE (1<<18) 97 }
85#define P4_CCCR_REQUIRED (3<<16) 98 return 0;
86#define P4_CCCR_ESCR_SELECT(N) ((N)<<13) 99}
87#define P4_CCCR_ENABLE (1<<12) 100
88/* Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter 101/* checks for a bit availability (hack for oprofile) */
89 CRU_ESCR0 (with any non-null event selector) through a complemented 102int avail_to_resrv_perfctr_nmi_bit(unsigned int counter)
90 max threshold. [IA32-Vol3, Section 14.9.9] */ 103{
91#define MSR_P4_IQ_COUNTER0 0x30C 104 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
92#define P4_NMI_CRU_ESCR0 (P4_ESCR_EVENT_SELECT(0x3F)|P4_ESCR_OS|P4_ESCR_USR) 105
93#define P4_NMI_IQ_CCCR0 \ 106 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
94 (P4_CCCR_OVF_PMI0|P4_CCCR_THRESHOLD(15)|P4_CCCR_COMPLEMENT| \ 107}
95 P4_CCCR_COMPARE|P4_CCCR_REQUIRED|P4_CCCR_ESCR_SELECT(4)|P4_CCCR_ENABLE) 108
109/* checks the an msr for availability */
110int avail_to_resrv_perfctr_nmi(unsigned int msr)
111{
112 unsigned int counter;
113
114 counter = nmi_perfctr_msr_to_bit(msr);
115 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
116
117 return (!test_bit(counter, &__get_cpu_var(perfctr_nmi_owner)));
118}
119
120int reserve_perfctr_nmi(unsigned int msr)
121{
122 unsigned int counter;
123
124 counter = nmi_perfctr_msr_to_bit(msr);
125 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
126
127 if (!test_and_set_bit(counter, &__get_cpu_var(perfctr_nmi_owner)))
128 return 1;
129 return 0;
130}
131
132void release_perfctr_nmi(unsigned int msr)
133{
134 unsigned int counter;
135
136 counter = nmi_perfctr_msr_to_bit(msr);
137 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
138
139 clear_bit(counter, &__get_cpu_var(perfctr_nmi_owner));
140}
141
142int reserve_evntsel_nmi(unsigned int msr)
143{
144 unsigned int counter;
145
146 counter = nmi_evntsel_msr_to_bit(msr);
147 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
148
149 if (!test_and_set_bit(counter, &__get_cpu_var(evntsel_nmi_owner)))
150 return 1;
151 return 0;
152}
153
154void release_evntsel_nmi(unsigned int msr)
155{
156 unsigned int counter;
157
158 counter = nmi_evntsel_msr_to_bit(msr);
159 BUG_ON(counter > NMI_MAX_COUNTER_BITS);
160
161 clear_bit(counter, &__get_cpu_var(evntsel_nmi_owner));
162}
96 163
97static __cpuinit inline int nmi_known_cpu(void) 164static __cpuinit inline int nmi_known_cpu(void)
98{ 165{
@@ -109,7 +176,7 @@ static __cpuinit inline int nmi_known_cpu(void)
109} 176}
110 177
111/* Run after command line and cpu_init init, but before all other checks */ 178/* Run after command line and cpu_init init, but before all other checks */
112void __cpuinit nmi_watchdog_default(void) 179void nmi_watchdog_default(void)
113{ 180{
114 if (nmi_watchdog != NMI_DEFAULT) 181 if (nmi_watchdog != NMI_DEFAULT)
115 return; 182 return;
@@ -145,6 +212,12 @@ int __init check_nmi_watchdog (void)
145 int *counts; 212 int *counts;
146 int cpu; 213 int cpu;
147 214
215 if ((nmi_watchdog == NMI_NONE) || (nmi_watchdog == NMI_DEFAULT))
216 return 0;
217
218 if (!atomic_read(&nmi_active))
219 return 0;
220
148 counts = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL); 221 counts = kmalloc(NR_CPUS * sizeof(int), GFP_KERNEL);
149 if (!counts) 222 if (!counts)
150 return -1; 223 return -1;
@@ -162,26 +235,43 @@ int __init check_nmi_watchdog (void)
162 mdelay((10*1000)/nmi_hz); // wait 10 ticks 235 mdelay((10*1000)/nmi_hz); // wait 10 ticks
163 236
164 for_each_online_cpu(cpu) { 237 for_each_online_cpu(cpu) {
238 if (!per_cpu(nmi_watchdog_ctlblk, cpu).enabled)
239 continue;
165 if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) { 240 if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
166 endflag = 1;
167 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n", 241 printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
168 cpu, 242 cpu,
169 counts[cpu], 243 counts[cpu],
170 cpu_pda(cpu)->__nmi_count); 244 cpu_pda(cpu)->__nmi_count);
171 nmi_active = 0; 245 per_cpu(nmi_watchdog_ctlblk, cpu).enabled = 0;
172 lapic_nmi_owner &= ~LAPIC_NMI_WATCHDOG; 246 atomic_dec(&nmi_active);
173 nmi_perfctr_msr = 0;
174 kfree(counts);
175 return -1;
176 } 247 }
177 } 248 }
249 if (!atomic_read(&nmi_active)) {
250 kfree(counts);
251 atomic_set(&nmi_active, -1);
252 return -1;
253 }
178 endflag = 1; 254 endflag = 1;
179 printk("OK.\n"); 255 printk("OK.\n");
180 256
181 /* now that we know it works we can reduce NMI frequency to 257 /* now that we know it works we can reduce NMI frequency to
182 something more reasonable; makes a difference in some configs */ 258 something more reasonable; makes a difference in some configs */
183 if (nmi_watchdog == NMI_LOCAL_APIC) 259 if (nmi_watchdog == NMI_LOCAL_APIC) {
260 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
261
184 nmi_hz = 1; 262 nmi_hz = 1;
263 /*
264 * On Intel CPUs with ARCH_PERFMON only 32 bits in the counter
265 * are writable, with higher bits sign extending from bit 31.
266 * So, we can only program the counter with 31 bit values and
267 * 32nd bit should be 1, for 33.. to be 1.
268 * Find the appropriate nmi_hz
269 */
270 if (wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0 &&
271 ((u64)cpu_khz * 1000) > 0x7fffffffULL) {
272 nmi_hz = ((u64)cpu_khz * 1000) / 0x7fffffffUL + 1;
273 }
274 }
185 275
186 kfree(counts); 276 kfree(counts);
187 return 0; 277 return 0;
@@ -201,91 +291,65 @@ int __init setup_nmi_watchdog(char *str)
201 291
202 get_option(&str, &nmi); 292 get_option(&str, &nmi);
203 293
204 if (nmi >= NMI_INVALID) 294 if ((nmi >= NMI_INVALID) || (nmi < NMI_NONE))
205 return 0; 295 return 0;
296
297 if ((nmi == NMI_LOCAL_APIC) && (nmi_known_cpu() == 0))
298 return 0; /* no lapic support */
206 nmi_watchdog = nmi; 299 nmi_watchdog = nmi;
207 return 1; 300 return 1;
208} 301}
209 302
210__setup("nmi_watchdog=", setup_nmi_watchdog); 303__setup("nmi_watchdog=", setup_nmi_watchdog);
211 304
212static void disable_intel_arch_watchdog(void);
213
214static void disable_lapic_nmi_watchdog(void) 305static void disable_lapic_nmi_watchdog(void)
215{ 306{
216 if (nmi_active <= 0) 307 BUG_ON(nmi_watchdog != NMI_LOCAL_APIC);
308
309 if (atomic_read(&nmi_active) <= 0)
217 return; 310 return;
218 switch (boot_cpu_data.x86_vendor) {
219 case X86_VENDOR_AMD:
220 wrmsr(MSR_K7_EVNTSEL0, 0, 0);
221 break;
222 case X86_VENDOR_INTEL:
223 if (boot_cpu_data.x86 == 15) {
224 wrmsr(MSR_P4_IQ_CCCR0, 0, 0);
225 wrmsr(MSR_P4_CRU_ESCR0, 0, 0);
226 } else if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
227 disable_intel_arch_watchdog();
228 }
229 break;
230 }
231 nmi_active = -1;
232 /* tell do_nmi() and others that we're not active any more */
233 nmi_watchdog = 0;
234}
235 311
236static void enable_lapic_nmi_watchdog(void) 312 on_each_cpu(stop_apic_nmi_watchdog, NULL, 0, 1);
237{ 313
238 if (nmi_active < 0) { 314 BUG_ON(atomic_read(&nmi_active) != 0);
239 nmi_watchdog = NMI_LOCAL_APIC;
240 touch_nmi_watchdog();
241 setup_apic_nmi_watchdog();
242 }
243} 315}
244 316
245int reserve_lapic_nmi(void) 317static void enable_lapic_nmi_watchdog(void)
246{ 318{
247 unsigned int old_owner; 319 BUG_ON(nmi_watchdog != NMI_LOCAL_APIC);
248 320
249 spin_lock(&lapic_nmi_owner_lock); 321 /* are we already enabled */
250 old_owner = lapic_nmi_owner; 322 if (atomic_read(&nmi_active) != 0)
251 lapic_nmi_owner |= LAPIC_NMI_RESERVED; 323 return;
252 spin_unlock(&lapic_nmi_owner_lock);
253 if (old_owner & LAPIC_NMI_RESERVED)
254 return -EBUSY;
255 if (old_owner & LAPIC_NMI_WATCHDOG)
256 disable_lapic_nmi_watchdog();
257 return 0;
258}
259 324
260void release_lapic_nmi(void) 325 /* are we lapic aware */
261{ 326 if (nmi_known_cpu() <= 0)
262 unsigned int new_owner; 327 return;
263 328
264 spin_lock(&lapic_nmi_owner_lock); 329 on_each_cpu(setup_apic_nmi_watchdog, NULL, 0, 1);
265 new_owner = lapic_nmi_owner & ~LAPIC_NMI_RESERVED; 330 touch_nmi_watchdog();
266 lapic_nmi_owner = new_owner;
267 spin_unlock(&lapic_nmi_owner_lock);
268 if (new_owner & LAPIC_NMI_WATCHDOG)
269 enable_lapic_nmi_watchdog();
270} 331}
271 332
272void disable_timer_nmi_watchdog(void) 333void disable_timer_nmi_watchdog(void)
273{ 334{
274 if ((nmi_watchdog != NMI_IO_APIC) || (nmi_active <= 0)) 335 BUG_ON(nmi_watchdog != NMI_IO_APIC);
336
337 if (atomic_read(&nmi_active) <= 0)
275 return; 338 return;
276 339
277 disable_irq(0); 340 disable_irq(0);
278 unset_nmi_callback(); 341 on_each_cpu(stop_apic_nmi_watchdog, NULL, 0, 1);
279 nmi_active = -1; 342
280 nmi_watchdog = NMI_NONE; 343 BUG_ON(atomic_read(&nmi_active) != 0);
281} 344}
282 345
283void enable_timer_nmi_watchdog(void) 346void enable_timer_nmi_watchdog(void)
284{ 347{
285 if (nmi_active < 0) { 348 BUG_ON(nmi_watchdog != NMI_IO_APIC);
286 nmi_watchdog = NMI_IO_APIC; 349
350 if (atomic_read(&nmi_active) == 0) {
287 touch_nmi_watchdog(); 351 touch_nmi_watchdog();
288 nmi_active = 1; 352 on_each_cpu(setup_apic_nmi_watchdog, NULL, 0, 1);
289 enable_irq(0); 353 enable_irq(0);
290 } 354 }
291} 355}
@@ -296,15 +360,20 @@ static int nmi_pm_active; /* nmi_active before suspend */
296 360
297static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state) 361static int lapic_nmi_suspend(struct sys_device *dev, pm_message_t state)
298{ 362{
299 nmi_pm_active = nmi_active; 363 /* only CPU0 goes here, other CPUs should be offline */
300 disable_lapic_nmi_watchdog(); 364 nmi_pm_active = atomic_read(&nmi_active);
365 stop_apic_nmi_watchdog(NULL);
366 BUG_ON(atomic_read(&nmi_active) != 0);
301 return 0; 367 return 0;
302} 368}
303 369
304static int lapic_nmi_resume(struct sys_device *dev) 370static int lapic_nmi_resume(struct sys_device *dev)
305{ 371{
306 if (nmi_pm_active > 0) 372 /* only CPU0 goes here, other CPUs should be offline */
307 enable_lapic_nmi_watchdog(); 373 if (nmi_pm_active > 0) {
374 setup_apic_nmi_watchdog(NULL);
375 touch_nmi_watchdog();
376 }
308 return 0; 377 return 0;
309} 378}
310 379
@@ -323,7 +392,13 @@ static int __init init_lapic_nmi_sysfs(void)
323{ 392{
324 int error; 393 int error;
325 394
326 if (nmi_active == 0 || nmi_watchdog != NMI_LOCAL_APIC) 395 /* should really be a BUG_ON but b/c this is an
396 * init call, it just doesn't work. -dcz
397 */
398 if (nmi_watchdog != NMI_LOCAL_APIC)
399 return 0;
400
401 if ( atomic_read(&nmi_active) < 0 )
327 return 0; 402 return 0;
328 403
329 error = sysdev_class_register(&nmi_sysclass); 404 error = sysdev_class_register(&nmi_sysclass);
@@ -341,74 +416,209 @@ late_initcall(init_lapic_nmi_sysfs);
341 * Original code written by Keith Owens. 416 * Original code written by Keith Owens.
342 */ 417 */
343 418
344static void clear_msr_range(unsigned int base, unsigned int n) 419/* Note that these events don't tick when the CPU idles. This means
345{ 420 the frequency varies with CPU load. */
346 unsigned int i;
347 421
348 for(i = 0; i < n; ++i) 422#define K7_EVNTSEL_ENABLE (1 << 22)
349 wrmsr(base+i, 0, 0); 423#define K7_EVNTSEL_INT (1 << 20)
350} 424#define K7_EVNTSEL_OS (1 << 17)
425#define K7_EVNTSEL_USR (1 << 16)
426#define K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING 0x76
427#define K7_NMI_EVENT K7_EVENT_CYCLES_PROCESSOR_IS_RUNNING
351 428
352static void setup_k7_watchdog(void) 429static int setup_k7_watchdog(void)
353{ 430{
354 int i; 431 unsigned int perfctr_msr, evntsel_msr;
355 unsigned int evntsel; 432 unsigned int evntsel;
433 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
356 434
357 nmi_perfctr_msr = MSR_K7_PERFCTR0; 435 perfctr_msr = MSR_K7_PERFCTR0;
436 evntsel_msr = MSR_K7_EVNTSEL0;
437 if (!reserve_perfctr_nmi(perfctr_msr))
438 goto fail;
358 439
359 for(i = 0; i < 4; ++i) { 440 if (!reserve_evntsel_nmi(evntsel_msr))
360 /* Simulator may not support it */ 441 goto fail1;
361 if (checking_wrmsrl(MSR_K7_EVNTSEL0+i, 0UL)) { 442
362 nmi_perfctr_msr = 0; 443 /* Simulator may not support it */
363 return; 444 if (checking_wrmsrl(evntsel_msr, 0UL))
364 } 445 goto fail2;
365 wrmsrl(MSR_K7_PERFCTR0+i, 0UL); 446 wrmsrl(perfctr_msr, 0UL);
366 }
367 447
368 evntsel = K7_EVNTSEL_INT 448 evntsel = K7_EVNTSEL_INT
369 | K7_EVNTSEL_OS 449 | K7_EVNTSEL_OS
370 | K7_EVNTSEL_USR 450 | K7_EVNTSEL_USR
371 | K7_NMI_EVENT; 451 | K7_NMI_EVENT;
372 452
373 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 453 /* setup the timer */
374 wrmsrl(MSR_K7_PERFCTR0, -((u64)cpu_khz * 1000 / nmi_hz)); 454 wrmsr(evntsel_msr, evntsel, 0);
455 wrmsrl(perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz));
375 apic_write(APIC_LVTPC, APIC_DM_NMI); 456 apic_write(APIC_LVTPC, APIC_DM_NMI);
376 evntsel |= K7_EVNTSEL_ENABLE; 457 evntsel |= K7_EVNTSEL_ENABLE;
377 wrmsr(MSR_K7_EVNTSEL0, evntsel, 0); 458 wrmsr(evntsel_msr, evntsel, 0);
459
460 wd->perfctr_msr = perfctr_msr;
461 wd->evntsel_msr = evntsel_msr;
462 wd->cccr_msr = 0; //unused
463 wd->check_bit = 1ULL<<63;
464 return 1;
465fail2:
466 release_evntsel_nmi(evntsel_msr);
467fail1:
468 release_perfctr_nmi(perfctr_msr);
469fail:
470 return 0;
378} 471}
379 472
380static void disable_intel_arch_watchdog(void) 473static void stop_k7_watchdog(void)
381{ 474{
382 unsigned ebx; 475 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
383 476
384 /* 477 wrmsr(wd->evntsel_msr, 0, 0);
385 * Check whether the Architectural PerfMon supports 478
386 * Unhalted Core Cycles Event or not. 479 release_evntsel_nmi(wd->evntsel_msr);
387 * NOTE: Corresponding bit = 0 in ebp indicates event present. 480 release_perfctr_nmi(wd->perfctr_msr);
481}
482
483/* Note that these events don't tick when the CPU idles. This means
484 the frequency varies with CPU load. */
485
486#define MSR_P4_MISC_ENABLE_PERF_AVAIL (1<<7)
487#define P4_ESCR_EVENT_SELECT(N) ((N)<<25)
488#define P4_ESCR_OS (1<<3)
489#define P4_ESCR_USR (1<<2)
490#define P4_CCCR_OVF_PMI0 (1<<26)
491#define P4_CCCR_OVF_PMI1 (1<<27)
492#define P4_CCCR_THRESHOLD(N) ((N)<<20)
493#define P4_CCCR_COMPLEMENT (1<<19)
494#define P4_CCCR_COMPARE (1<<18)
495#define P4_CCCR_REQUIRED (3<<16)
496#define P4_CCCR_ESCR_SELECT(N) ((N)<<13)
497#define P4_CCCR_ENABLE (1<<12)
498#define P4_CCCR_OVF (1<<31)
499/* Set up IQ_COUNTER0 to behave like a clock, by having IQ_CCCR0 filter
500 CRU_ESCR0 (with any non-null event selector) through a complemented
501 max threshold. [IA32-Vol3, Section 14.9.9] */
502
503static int setup_p4_watchdog(void)
504{
505 unsigned int perfctr_msr, evntsel_msr, cccr_msr;
506 unsigned int evntsel, cccr_val;
507 unsigned int misc_enable, dummy;
508 unsigned int ht_num;
509 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
510
511 rdmsr(MSR_IA32_MISC_ENABLE, misc_enable, dummy);
512 if (!(misc_enable & MSR_P4_MISC_ENABLE_PERF_AVAIL))
513 return 0;
514
515#ifdef CONFIG_SMP
516 /* detect which hyperthread we are on */
517 if (smp_num_siblings == 2) {
518 unsigned int ebx, apicid;
519
520 ebx = cpuid_ebx(1);
521 apicid = (ebx >> 24) & 0xff;
522 ht_num = apicid & 1;
523 } else
524#endif
525 ht_num = 0;
526
527 /* performance counters are shared resources
528 * assign each hyperthread its own set
529 * (re-use the ESCR0 register, seems safe
530 * and keeps the cccr_val the same)
388 */ 531 */
389 ebx = cpuid_ebx(10); 532 if (!ht_num) {
390 if (!(ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) 533 /* logical cpu 0 */
391 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, 0, 0); 534 perfctr_msr = MSR_P4_IQ_PERFCTR0;
535 evntsel_msr = MSR_P4_CRU_ESCR0;
536 cccr_msr = MSR_P4_IQ_CCCR0;
537 cccr_val = P4_CCCR_OVF_PMI0 | P4_CCCR_ESCR_SELECT(4);
538 } else {
539 /* logical cpu 1 */
540 perfctr_msr = MSR_P4_IQ_PERFCTR1;
541 evntsel_msr = MSR_P4_CRU_ESCR0;
542 cccr_msr = MSR_P4_IQ_CCCR1;
543 cccr_val = P4_CCCR_OVF_PMI1 | P4_CCCR_ESCR_SELECT(4);
544 }
545
546 if (!reserve_perfctr_nmi(perfctr_msr))
547 goto fail;
548
549 if (!reserve_evntsel_nmi(evntsel_msr))
550 goto fail1;
551
552 evntsel = P4_ESCR_EVENT_SELECT(0x3F)
553 | P4_ESCR_OS
554 | P4_ESCR_USR;
555
556 cccr_val |= P4_CCCR_THRESHOLD(15)
557 | P4_CCCR_COMPLEMENT
558 | P4_CCCR_COMPARE
559 | P4_CCCR_REQUIRED;
560
561 wrmsr(evntsel_msr, evntsel, 0);
562 wrmsr(cccr_msr, cccr_val, 0);
563 wrmsrl(perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz));
564 apic_write(APIC_LVTPC, APIC_DM_NMI);
565 cccr_val |= P4_CCCR_ENABLE;
566 wrmsr(cccr_msr, cccr_val, 0);
567
568 wd->perfctr_msr = perfctr_msr;
569 wd->evntsel_msr = evntsel_msr;
570 wd->cccr_msr = cccr_msr;
571 wd->check_bit = 1ULL<<39;
572 return 1;
573fail1:
574 release_perfctr_nmi(perfctr_msr);
575fail:
576 return 0;
577}
578
579static void stop_p4_watchdog(void)
580{
581 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
582
583 wrmsr(wd->cccr_msr, 0, 0);
584 wrmsr(wd->evntsel_msr, 0, 0);
585
586 release_evntsel_nmi(wd->evntsel_msr);
587 release_perfctr_nmi(wd->perfctr_msr);
392} 588}
393 589
590#define ARCH_PERFMON_NMI_EVENT_SEL ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL
591#define ARCH_PERFMON_NMI_EVENT_UMASK ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK
592
394static int setup_intel_arch_watchdog(void) 593static int setup_intel_arch_watchdog(void)
395{ 594{
595 unsigned int ebx;
596 union cpuid10_eax eax;
597 unsigned int unused;
598 unsigned int perfctr_msr, evntsel_msr;
396 unsigned int evntsel; 599 unsigned int evntsel;
397 unsigned ebx; 600 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
398 601
399 /* 602 /*
400 * Check whether the Architectural PerfMon supports 603 * Check whether the Architectural PerfMon supports
401 * Unhalted Core Cycles Event or not. 604 * Unhalted Core Cycles Event or not.
402 * NOTE: Corresponding bit = 0 in ebp indicates event present. 605 * NOTE: Corresponding bit = 0 in ebx indicates event present.
403 */ 606 */
404 ebx = cpuid_ebx(10); 607 cpuid(10, &(eax.full), &ebx, &unused, &unused);
405 if ((ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT)) 608 if ((eax.split.mask_length < (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX+1)) ||
406 return 0; 609 (ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT))
610 goto fail;
611
612 perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0;
613 evntsel_msr = MSR_ARCH_PERFMON_EVENTSEL0;
407 614
408 nmi_perfctr_msr = MSR_ARCH_PERFMON_PERFCTR0; 615 if (!reserve_perfctr_nmi(perfctr_msr))
616 goto fail;
409 617
410 clear_msr_range(MSR_ARCH_PERFMON_EVENTSEL0, 2); 618 if (!reserve_evntsel_nmi(evntsel_msr))
411 clear_msr_range(MSR_ARCH_PERFMON_PERFCTR0, 2); 619 goto fail1;
620
621 wrmsrl(perfctr_msr, 0UL);
412 622
413 evntsel = ARCH_PERFMON_EVENTSEL_INT 623 evntsel = ARCH_PERFMON_EVENTSEL_INT
414 | ARCH_PERFMON_EVENTSEL_OS 624 | ARCH_PERFMON_EVENTSEL_OS
@@ -416,84 +626,122 @@ static int setup_intel_arch_watchdog(void)
416 | ARCH_PERFMON_NMI_EVENT_SEL 626 | ARCH_PERFMON_NMI_EVENT_SEL
417 | ARCH_PERFMON_NMI_EVENT_UMASK; 627 | ARCH_PERFMON_NMI_EVENT_UMASK;
418 628
419 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); 629 /* setup the timer */
420 wrmsrl(MSR_ARCH_PERFMON_PERFCTR0, -((u64)cpu_khz * 1000 / nmi_hz)); 630 wrmsr(evntsel_msr, evntsel, 0);
631 wrmsrl(perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz));
632
421 apic_write(APIC_LVTPC, APIC_DM_NMI); 633 apic_write(APIC_LVTPC, APIC_DM_NMI);
422 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE; 634 evntsel |= ARCH_PERFMON_EVENTSEL0_ENABLE;
423 wrmsr(MSR_ARCH_PERFMON_EVENTSEL0, evntsel, 0); 635 wrmsr(evntsel_msr, evntsel, 0);
636
637 wd->perfctr_msr = perfctr_msr;
638 wd->evntsel_msr = evntsel_msr;
639 wd->cccr_msr = 0; //unused
640 wd->check_bit = 1ULL << (eax.split.bit_width - 1);
424 return 1; 641 return 1;
642fail1:
643 release_perfctr_nmi(perfctr_msr);
644fail:
645 return 0;
425} 646}
426 647
427 648static void stop_intel_arch_watchdog(void)
428static int setup_p4_watchdog(void)
429{ 649{
430 unsigned int misc_enable, dummy; 650 unsigned int ebx;
651 union cpuid10_eax eax;
652 unsigned int unused;
653 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
431 654
432 rdmsr(MSR_P4_MISC_ENABLE, misc_enable, dummy); 655 /*
433 if (!(misc_enable & MSR_P4_MISC_ENABLE_PERF_AVAIL)) 656 * Check whether the Architectural PerfMon supports
434 return 0; 657 * Unhalted Core Cycles Event or not.
658 * NOTE: Corresponding bit = 0 in ebx indicates event present.
659 */
660 cpuid(10, &(eax.full), &ebx, &unused, &unused);
661 if ((eax.split.mask_length < (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX+1)) ||
662 (ebx & ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT))
663 return;
435 664
436 nmi_perfctr_msr = MSR_P4_IQ_COUNTER0; 665 wrmsr(wd->evntsel_msr, 0, 0);
437 nmi_p4_cccr_val = P4_NMI_IQ_CCCR0;
438#ifdef CONFIG_SMP
439 if (smp_num_siblings == 2)
440 nmi_p4_cccr_val |= P4_CCCR_OVF_PMI1;
441#endif
442 666
443 if (!(misc_enable & MSR_P4_MISC_ENABLE_PEBS_UNAVAIL)) 667 release_evntsel_nmi(wd->evntsel_msr);
444 clear_msr_range(0x3F1, 2); 668 release_perfctr_nmi(wd->perfctr_msr);
445 /* MSR 0x3F0 seems to have a default value of 0xFC00, but current
446 docs doesn't fully define it, so leave it alone for now. */
447 if (boot_cpu_data.x86_model >= 0x3) {
448 /* MSR_P4_IQ_ESCR0/1 (0x3ba/0x3bb) removed */
449 clear_msr_range(0x3A0, 26);
450 clear_msr_range(0x3BC, 3);
451 } else {
452 clear_msr_range(0x3A0, 31);
453 }
454 clear_msr_range(0x3C0, 6);
455 clear_msr_range(0x3C8, 6);
456 clear_msr_range(0x3E0, 2);
457 clear_msr_range(MSR_P4_CCCR0, 18);
458 clear_msr_range(MSR_P4_PERFCTR0, 18);
459
460 wrmsr(MSR_P4_CRU_ESCR0, P4_NMI_CRU_ESCR0, 0);
461 wrmsr(MSR_P4_IQ_CCCR0, P4_NMI_IQ_CCCR0 & ~P4_CCCR_ENABLE, 0);
462 Dprintk("setting P4_IQ_COUNTER0 to 0x%08lx\n", -(cpu_khz * 1000UL / nmi_hz));
463 wrmsrl(MSR_P4_IQ_COUNTER0, -((u64)cpu_khz * 1000 / nmi_hz));
464 apic_write(APIC_LVTPC, APIC_DM_NMI);
465 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0);
466 return 1;
467} 669}
468 670
469void setup_apic_nmi_watchdog(void) 671void setup_apic_nmi_watchdog(void *unused)
470{ 672{
471 switch (boot_cpu_data.x86_vendor) { 673 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
472 case X86_VENDOR_AMD: 674
473 if (boot_cpu_data.x86 != 15) 675 /* only support LOCAL and IO APICs for now */
474 return; 676 if ((nmi_watchdog != NMI_LOCAL_APIC) &&
475 if (strstr(boot_cpu_data.x86_model_id, "Screwdriver")) 677 (nmi_watchdog != NMI_IO_APIC))
476 return; 678 return;
477 setup_k7_watchdog(); 679
478 break; 680 if (wd->enabled == 1)
479 case X86_VENDOR_INTEL: 681 return;
480 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { 682
481 if (!setup_intel_arch_watchdog()) 683 /* cheap hack to support suspend/resume */
684 /* if cpu0 is not active neither should the other cpus */
685 if ((smp_processor_id() != 0) && (atomic_read(&nmi_active) <= 0))
686 return;
687
688 if (nmi_watchdog == NMI_LOCAL_APIC) {
689 switch (boot_cpu_data.x86_vendor) {
690 case X86_VENDOR_AMD:
691 if (strstr(boot_cpu_data.x86_model_id, "Screwdriver"))
482 return; 692 return;
483 } else if (boot_cpu_data.x86 == 15) { 693 if (!setup_k7_watchdog())
694 return;
695 break;
696 case X86_VENDOR_INTEL:
697 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
698 if (!setup_intel_arch_watchdog())
699 return;
700 break;
701 }
484 if (!setup_p4_watchdog()) 702 if (!setup_p4_watchdog())
485 return; 703 return;
486 } else { 704 break;
705 default:
487 return; 706 return;
488 } 707 }
708 }
709 wd->enabled = 1;
710 atomic_inc(&nmi_active);
711}
712
713void stop_apic_nmi_watchdog(void *unused)
714{
715 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
489 716
490 break; 717 /* only support LOCAL and IO APICs for now */
718 if ((nmi_watchdog != NMI_LOCAL_APIC) &&
719 (nmi_watchdog != NMI_IO_APIC))
720 return;
491 721
492 default: 722 if (wd->enabled == 0)
493 return; 723 return;
724
725 if (nmi_watchdog == NMI_LOCAL_APIC) {
726 switch (boot_cpu_data.x86_vendor) {
727 case X86_VENDOR_AMD:
728 if (strstr(boot_cpu_data.x86_model_id, "Screwdriver"))
729 return;
730 stop_k7_watchdog();
731 break;
732 case X86_VENDOR_INTEL:
733 if (cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) {
734 stop_intel_arch_watchdog();
735 break;
736 }
737 stop_p4_watchdog();
738 break;
739 default:
740 return;
741 }
494 } 742 }
495 lapic_nmi_owner = LAPIC_NMI_WATCHDOG; 743 wd->enabled = 0;
496 nmi_active = 1; 744 atomic_dec(&nmi_active);
497} 745}
498 746
499/* 747/*
@@ -526,93 +774,109 @@ void touch_nmi_watchdog (void)
526 touch_softlockup_watchdog(); 774 touch_softlockup_watchdog();
527} 775}
528 776
529void __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason) 777int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
530{ 778{
531 int sum; 779 int sum;
532 int touched = 0; 780 int touched = 0;
781 struct nmi_watchdog_ctlblk *wd = &__get_cpu_var(nmi_watchdog_ctlblk);
782 u64 dummy;
783 int rc=0;
784
785 /* check for other users first */
786 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT)
787 == NOTIFY_STOP) {
788 rc = 1;
789 touched = 1;
790 }
533 791
534 sum = read_pda(apic_timer_irqs); 792 sum = read_pda(apic_timer_irqs);
535 if (__get_cpu_var(nmi_touch)) { 793 if (__get_cpu_var(nmi_touch)) {
536 __get_cpu_var(nmi_touch) = 0; 794 __get_cpu_var(nmi_touch) = 0;
537 touched = 1; 795 touched = 1;
538 } 796 }
797
539#ifdef CONFIG_X86_MCE 798#ifdef CONFIG_X86_MCE
540 /* Could check oops_in_progress here too, but it's safer 799 /* Could check oops_in_progress here too, but it's safer
541 not too */ 800 not too */
542 if (atomic_read(&mce_entry) > 0) 801 if (atomic_read(&mce_entry) > 0)
543 touched = 1; 802 touched = 1;
544#endif 803#endif
804 /* if the apic timer isn't firing, this cpu isn't doing much */
545 if (!touched && __get_cpu_var(last_irq_sum) == sum) { 805 if (!touched && __get_cpu_var(last_irq_sum) == sum) {
546 /* 806 /*
547 * Ayiee, looks like this CPU is stuck ... 807 * Ayiee, looks like this CPU is stuck ...
548 * wait a few IRQs (5 seconds) before doing the oops ... 808 * wait a few IRQs (5 seconds) before doing the oops ...
549 */ 809 */
550 local_inc(&__get_cpu_var(alert_counter)); 810 local_inc(&__get_cpu_var(alert_counter));
551 if (local_read(&__get_cpu_var(alert_counter)) == 5*nmi_hz) { 811 if (local_read(&__get_cpu_var(alert_counter)) == 5*nmi_hz)
552 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) 812 die_nmi("NMI Watchdog detected LOCKUP on CPU %d\n", regs,
553 == NOTIFY_STOP) { 813 panic_on_timeout);
554 local_set(&__get_cpu_var(alert_counter), 0);
555 return;
556 }
557 die_nmi("NMI Watchdog detected LOCKUP on CPU %d\n", regs);
558 }
559 } else { 814 } else {
560 __get_cpu_var(last_irq_sum) = sum; 815 __get_cpu_var(last_irq_sum) = sum;
561 local_set(&__get_cpu_var(alert_counter), 0); 816 local_set(&__get_cpu_var(alert_counter), 0);
562 } 817 }
563 if (nmi_perfctr_msr) { 818
564 if (nmi_perfctr_msr == MSR_P4_IQ_COUNTER0) { 819 /* see if the nmi watchdog went off */
565 /* 820 if (wd->enabled) {
566 * P4 quirks: 821 if (nmi_watchdog == NMI_LOCAL_APIC) {
567 * - An overflown perfctr will assert its interrupt 822 rdmsrl(wd->perfctr_msr, dummy);
568 * until the OVF flag in its CCCR is cleared. 823 if (dummy & wd->check_bit){
569 * - LVTPC is masked on interrupt and must be 824 /* this wasn't a watchdog timer interrupt */
570 * unmasked by the LVTPC handler. 825 goto done;
571 */ 826 }
572 wrmsr(MSR_P4_IQ_CCCR0, nmi_p4_cccr_val, 0); 827
573 apic_write(APIC_LVTPC, APIC_DM_NMI); 828 /* only Intel uses the cccr msr */
574 } else if (nmi_perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) { 829 if (wd->cccr_msr != 0) {
575 /* 830 /*
576 * For Intel based architectural perfmon 831 * P4 quirks:
577 * - LVTPC is masked on interrupt and must be 832 * - An overflown perfctr will assert its interrupt
578 * unmasked by the LVTPC handler. 833 * until the OVF flag in its CCCR is cleared.
834 * - LVTPC is masked on interrupt and must be
835 * unmasked by the LVTPC handler.
836 */
837 rdmsrl(wd->cccr_msr, dummy);
838 dummy &= ~P4_CCCR_OVF;
839 wrmsrl(wd->cccr_msr, dummy);
840 apic_write(APIC_LVTPC, APIC_DM_NMI);
841 } else if (wd->perfctr_msr == MSR_ARCH_PERFMON_PERFCTR0) {
842 /*
843 * ArchPerfom/Core Duo needs to re-unmask
844 * the apic vector
845 */
846 apic_write(APIC_LVTPC, APIC_DM_NMI);
847 }
848 /* start the cycle over again */
849 wrmsrl(wd->perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz));
850 rc = 1;
851 } else if (nmi_watchdog == NMI_IO_APIC) {
852 /* don't know how to accurately check for this.
853 * just assume it was a watchdog timer interrupt
854 * This matches the old behaviour.
579 */ 855 */
580 apic_write(APIC_LVTPC, APIC_DM_NMI); 856 rc = 1;
581 } 857 } else
582 wrmsrl(nmi_perfctr_msr, -((u64)cpu_khz * 1000 / nmi_hz)); 858 printk(KERN_WARNING "Unknown enabled NMI hardware?!\n");
583 } 859 }
860done:
861 return rc;
584} 862}
585 863
586static __kprobes int dummy_nmi_callback(struct pt_regs * regs, int cpu)
587{
588 return 0;
589}
590
591static nmi_callback_t nmi_callback = dummy_nmi_callback;
592
593asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code) 864asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
594{ 865{
595 int cpu = safe_smp_processor_id();
596
597 nmi_enter(); 866 nmi_enter();
598 add_pda(__nmi_count,1); 867 add_pda(__nmi_count,1);
599 if (!rcu_dereference(nmi_callback)(regs, cpu)) 868 default_do_nmi(regs);
600 default_do_nmi(regs);
601 nmi_exit(); 869 nmi_exit();
602} 870}
603 871
604void set_nmi_callback(nmi_callback_t callback) 872int do_nmi_callback(struct pt_regs * regs, int cpu)
605{ 873{
606 vmalloc_sync_all(); 874#ifdef CONFIG_SYSCTL
607 rcu_assign_pointer(nmi_callback, callback); 875 if (unknown_nmi_panic)
608} 876 return unknown_nmi_panic_callback(regs, cpu);
609EXPORT_SYMBOL_GPL(set_nmi_callback); 877#endif
610 878 return 0;
611void unset_nmi_callback(void)
612{
613 nmi_callback = dummy_nmi_callback;
614} 879}
615EXPORT_SYMBOL_GPL(unset_nmi_callback);
616 880
617#ifdef CONFIG_SYSCTL 881#ifdef CONFIG_SYSCTL
618 882
@@ -621,36 +885,42 @@ static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
621 unsigned char reason = get_nmi_reason(); 885 unsigned char reason = get_nmi_reason();
622 char buf[64]; 886 char buf[64];
623 887
624 if (!(reason & 0xc0)) { 888 sprintf(buf, "NMI received for unknown reason %02x\n", reason);
625 sprintf(buf, "NMI received for unknown reason %02x\n", reason); 889 die_nmi(buf, regs, 1); /* Always panic here */
626 die_nmi(buf,regs);
627 }
628 return 0; 890 return 0;
629} 891}
630 892
631/* 893/*
632 * proc handler for /proc/sys/kernel/unknown_nmi_panic 894 * proc handler for /proc/sys/kernel/nmi
633 */ 895 */
634int proc_unknown_nmi_panic(struct ctl_table *table, int write, struct file *file, 896int proc_nmi_enabled(struct ctl_table *table, int write, struct file *file,
635 void __user *buffer, size_t *length, loff_t *ppos) 897 void __user *buffer, size_t *length, loff_t *ppos)
636{ 898{
637 int old_state; 899 int old_state;
638 900
639 old_state = unknown_nmi_panic; 901 nmi_watchdog_enabled = (atomic_read(&nmi_active) > 0) ? 1 : 0;
902 old_state = nmi_watchdog_enabled;
640 proc_dointvec(table, write, file, buffer, length, ppos); 903 proc_dointvec(table, write, file, buffer, length, ppos);
641 if (!!old_state == !!unknown_nmi_panic) 904 if (!!old_state == !!nmi_watchdog_enabled)
642 return 0; 905 return 0;
643 906
644 if (unknown_nmi_panic) { 907 if (atomic_read(&nmi_active) < 0) {
645 if (reserve_lapic_nmi() < 0) { 908 printk( KERN_WARNING "NMI watchdog is permanently disabled\n");
646 unknown_nmi_panic = 0; 909 return -EIO;
647 return -EBUSY; 910 }
648 } else { 911
649 set_nmi_callback(unknown_nmi_panic_callback); 912 /* if nmi_watchdog is not set yet, then set it */
650 } 913 nmi_watchdog_default();
914
915 if (nmi_watchdog == NMI_LOCAL_APIC) {
916 if (nmi_watchdog_enabled)
917 enable_lapic_nmi_watchdog();
918 else
919 disable_lapic_nmi_watchdog();
651 } else { 920 } else {
652 release_lapic_nmi(); 921 printk( KERN_WARNING
653 unset_nmi_callback(); 922 "NMI watchdog doesn't know what hardware to touch\n");
923 return -EIO;
654 } 924 }
655 return 0; 925 return 0;
656} 926}
@@ -659,8 +929,12 @@ int proc_unknown_nmi_panic(struct ctl_table *table, int write, struct file *file
659 929
660EXPORT_SYMBOL(nmi_active); 930EXPORT_SYMBOL(nmi_active);
661EXPORT_SYMBOL(nmi_watchdog); 931EXPORT_SYMBOL(nmi_watchdog);
662EXPORT_SYMBOL(reserve_lapic_nmi); 932EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi);
663EXPORT_SYMBOL(release_lapic_nmi); 933EXPORT_SYMBOL(avail_to_resrv_perfctr_nmi_bit);
934EXPORT_SYMBOL(reserve_perfctr_nmi);
935EXPORT_SYMBOL(release_perfctr_nmi);
936EXPORT_SYMBOL(reserve_evntsel_nmi);
937EXPORT_SYMBOL(release_evntsel_nmi);
664EXPORT_SYMBOL(disable_timer_nmi_watchdog); 938EXPORT_SYMBOL(disable_timer_nmi_watchdog);
665EXPORT_SYMBOL(enable_timer_nmi_watchdog); 939EXPORT_SYMBOL(enable_timer_nmi_watchdog);
666EXPORT_SYMBOL(touch_nmi_watchdog); 940EXPORT_SYMBOL(touch_nmi_watchdog);
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 146924ba5df5..cfb09b07ae99 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -86,7 +86,8 @@
86 86
87#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */ 87#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */
88#define MAX_NUM_CHASSIS 8 /* max number of chassis */ 88#define MAX_NUM_CHASSIS 8 /* max number of chassis */
89#define MAX_PHB_BUS_NUM (MAX_NUM_OF_PHBS * MAX_NUM_CHASSIS * 2) /* max dev->bus->number */ 89/* MAX_PHB_BUS_NUM is the maximal possible dev->bus->number */
90#define MAX_PHB_BUS_NUM (MAX_NUM_OF_PHBS * MAX_NUM_CHASSIS * 2)
90#define PHBS_PER_CALGARY 4 91#define PHBS_PER_CALGARY 4
91 92
92/* register offsets in Calgary's internal register space */ 93/* register offsets in Calgary's internal register space */
@@ -111,31 +112,49 @@ static const unsigned long phb_offsets[] = {
111 0xB000 /* PHB3 */ 112 0xB000 /* PHB3 */
112}; 113};
113 114
114static char bus_to_phb[MAX_PHB_BUS_NUM];
115void* tce_table_kva[MAX_PHB_BUS_NUM];
116unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED; 115unsigned int specified_table_size = TCE_TABLE_SIZE_UNSPECIFIED;
117static int translate_empty_slots __read_mostly = 0; 116static int translate_empty_slots __read_mostly = 0;
118static int calgary_detected __read_mostly = 0; 117static int calgary_detected __read_mostly = 0;
119 118
120/* 119struct calgary_bus_info {
121 * the bitmap of PHBs the user requested that we disable 120 void *tce_space;
122 * translation on. 121 unsigned char translation_disabled;
123 */ 122 signed char phbid;
124static DECLARE_BITMAP(translation_disabled, MAX_PHB_BUS_NUM); 123};
124
125static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, };
125 126
126static void tce_cache_blast(struct iommu_table *tbl); 127static void tce_cache_blast(struct iommu_table *tbl);
127 128
128/* enable this to stress test the chip's TCE cache */ 129/* enable this to stress test the chip's TCE cache */
129#ifdef CONFIG_IOMMU_DEBUG 130#ifdef CONFIG_IOMMU_DEBUG
130static inline void tce_cache_blast_stress(struct iommu_table *tbl) 131int debugging __read_mostly = 1;
132
133static inline unsigned long verify_bit_range(unsigned long* bitmap,
134 int expected, unsigned long start, unsigned long end)
131{ 135{
132 tce_cache_blast(tbl); 136 unsigned long idx = start;
137
138 BUG_ON(start >= end);
139
140 while (idx < end) {
141 if (!!test_bit(idx, bitmap) != expected)
142 return idx;
143 ++idx;
144 }
145
146 /* all bits have the expected value */
147 return ~0UL;
133} 148}
134#else 149#else /* debugging is disabled */
135static inline void tce_cache_blast_stress(struct iommu_table *tbl) 150int debugging __read_mostly = 0;
151
152static inline unsigned long verify_bit_range(unsigned long* bitmap,
153 int expected, unsigned long start, unsigned long end)
136{ 154{
155 return ~0UL;
137} 156}
138#endif /* BLAST_TCE_CACHE_ON_UNMAP */ 157#endif /* CONFIG_IOMMU_DEBUG */
139 158
140static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen) 159static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
141{ 160{
@@ -149,7 +168,7 @@ static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
149 168
150static inline int translate_phb(struct pci_dev* dev) 169static inline int translate_phb(struct pci_dev* dev)
151{ 170{
152 int disabled = test_bit(dev->bus->number, translation_disabled); 171 int disabled = bus_info[dev->bus->number].translation_disabled;
153 return !disabled; 172 return !disabled;
154} 173}
155 174
@@ -158,6 +177,7 @@ static void iommu_range_reserve(struct iommu_table *tbl,
158{ 177{
159 unsigned long index; 178 unsigned long index;
160 unsigned long end; 179 unsigned long end;
180 unsigned long badbit;
161 181
162 index = start_addr >> PAGE_SHIFT; 182 index = start_addr >> PAGE_SHIFT;
163 183
@@ -169,14 +189,15 @@ static void iommu_range_reserve(struct iommu_table *tbl,
169 if (end > tbl->it_size) /* don't go off the table */ 189 if (end > tbl->it_size) /* don't go off the table */
170 end = tbl->it_size; 190 end = tbl->it_size;
171 191
172 while (index < end) { 192 badbit = verify_bit_range(tbl->it_map, 0, index, end);
173 if (test_bit(index, tbl->it_map)) 193 if (badbit != ~0UL) {
194 if (printk_ratelimit())
174 printk(KERN_ERR "Calgary: entry already allocated at " 195 printk(KERN_ERR "Calgary: entry already allocated at "
175 "0x%lx tbl %p dma 0x%lx npages %u\n", 196 "0x%lx tbl %p dma 0x%lx npages %u\n",
176 index, tbl, start_addr, npages); 197 badbit, tbl, start_addr, npages);
177 ++index;
178 } 198 }
179 set_bit_string(tbl->it_map, start_addr >> PAGE_SHIFT, npages); 199
200 set_bit_string(tbl->it_map, index, npages);
180} 201}
181 202
182static unsigned long iommu_range_alloc(struct iommu_table *tbl, 203static unsigned long iommu_range_alloc(struct iommu_table *tbl,
@@ -243,7 +264,7 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
243 unsigned int npages) 264 unsigned int npages)
244{ 265{
245 unsigned long entry; 266 unsigned long entry;
246 unsigned long i; 267 unsigned long badbit;
247 268
248 entry = dma_addr >> PAGE_SHIFT; 269 entry = dma_addr >> PAGE_SHIFT;
249 270
@@ -251,16 +272,15 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
251 272
252 tce_free(tbl, entry, npages); 273 tce_free(tbl, entry, npages);
253 274
254 for (i = 0; i < npages; ++i) { 275 badbit = verify_bit_range(tbl->it_map, 1, entry, entry + npages);
255 if (!test_bit(entry + i, tbl->it_map)) 276 if (badbit != ~0UL) {
277 if (printk_ratelimit())
256 printk(KERN_ERR "Calgary: bit is off at 0x%lx " 278 printk(KERN_ERR "Calgary: bit is off at 0x%lx "
257 "tbl %p dma 0x%Lx entry 0x%lx npages %u\n", 279 "tbl %p dma 0x%Lx entry 0x%lx npages %u\n",
258 entry + i, tbl, dma_addr, entry, npages); 280 badbit, tbl, dma_addr, entry, npages);
259 } 281 }
260 282
261 __clear_bit_string(tbl->it_map, entry, npages); 283 __clear_bit_string(tbl->it_map, entry, npages);
262
263 tce_cache_blast_stress(tbl);
264} 284}
265 285
266static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 286static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
@@ -454,7 +474,7 @@ static struct dma_mapping_ops calgary_dma_ops = {
454 474
455static inline int busno_to_phbid(unsigned char num) 475static inline int busno_to_phbid(unsigned char num)
456{ 476{
457 return bus_to_phb[num]; 477 return bus_info[num].phbid;
458} 478}
459 479
460static inline unsigned long split_queue_offset(unsigned char num) 480static inline unsigned long split_queue_offset(unsigned char num)
@@ -631,6 +651,10 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
631 if (ret) 651 if (ret)
632 return ret; 652 return ret;
633 653
654 tbl = dev->sysdata;
655 tbl->it_base = (unsigned long)bus_info[dev->bus->number].tce_space;
656 tce_free(tbl, 0, tbl->it_size);
657
634 calgary_reserve_regions(dev); 658 calgary_reserve_regions(dev);
635 659
636 /* set TARs for each PHB */ 660 /* set TARs for each PHB */
@@ -654,11 +678,12 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
654 return 0; 678 return 0;
655} 679}
656 680
657static void __init calgary_free_tar(struct pci_dev *dev) 681static void __init calgary_free_bus(struct pci_dev *dev)
658{ 682{
659 u64 val64; 683 u64 val64;
660 struct iommu_table *tbl = dev->sysdata; 684 struct iommu_table *tbl = dev->sysdata;
661 void __iomem *target; 685 void __iomem *target;
686 unsigned int bitmapsz;
662 687
663 target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number)); 688 target = calgary_reg(tbl->bbar, tar_offset(dev->bus->number));
664 val64 = be64_to_cpu(readq(target)); 689 val64 = be64_to_cpu(readq(target));
@@ -666,8 +691,15 @@ static void __init calgary_free_tar(struct pci_dev *dev)
666 writeq(cpu_to_be64(val64), target); 691 writeq(cpu_to_be64(val64), target);
667 readq(target); /* flush */ 692 readq(target); /* flush */
668 693
694 bitmapsz = tbl->it_size / BITS_PER_BYTE;
695 free_pages((unsigned long)tbl->it_map, get_order(bitmapsz));
696 tbl->it_map = NULL;
697
669 kfree(tbl); 698 kfree(tbl);
670 dev->sysdata = NULL; 699 dev->sysdata = NULL;
700
701 /* Can't free bootmem allocated memory after system is up :-( */
702 bus_info[dev->bus->number].tce_space = NULL;
671} 703}
672 704
673static void calgary_watchdog(unsigned long data) 705static void calgary_watchdog(unsigned long data)
@@ -772,12 +804,11 @@ static inline unsigned int __init locate_register_space(struct pci_dev *dev)
772 return address; 804 return address;
773} 805}
774 806
775static int __init calgary_init_one_nontraslated(struct pci_dev *dev) 807static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
776{ 808{
809 pci_dev_get(dev);
777 dev->sysdata = NULL; 810 dev->sysdata = NULL;
778 dev->bus->self = dev; 811 dev->bus->self = dev;
779
780 return 0;
781} 812}
782 813
783static int __init calgary_init_one(struct pci_dev *dev) 814static int __init calgary_init_one(struct pci_dev *dev)
@@ -798,6 +829,7 @@ static int __init calgary_init_one(struct pci_dev *dev)
798 if (ret) 829 if (ret)
799 goto iounmap; 830 goto iounmap;
800 831
832 pci_dev_get(dev);
801 dev->bus->self = dev; 833 dev->bus->self = dev;
802 calgary_enable_translation(dev); 834 calgary_enable_translation(dev);
803 835
@@ -824,10 +856,9 @@ static int __init calgary_init(void)
824 calgary_init_one_nontraslated(dev); 856 calgary_init_one_nontraslated(dev);
825 continue; 857 continue;
826 } 858 }
827 if (!tce_table_kva[dev->bus->number] && !translate_empty_slots) { 859 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
828 pci_dev_put(dev);
829 continue; 860 continue;
830 } 861
831 ret = calgary_init_one(dev); 862 ret = calgary_init_one(dev);
832 if (ret) 863 if (ret)
833 goto error; 864 goto error;
@@ -840,15 +871,18 @@ error:
840 dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM, 871 dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
841 PCI_DEVICE_ID_IBM_CALGARY, 872 PCI_DEVICE_ID_IBM_CALGARY,
842 dev); 873 dev);
874 if (!dev)
875 break;
843 if (!translate_phb(dev)) { 876 if (!translate_phb(dev)) {
844 pci_dev_put(dev); 877 pci_dev_put(dev);
845 continue; 878 continue;
846 } 879 }
847 if (!tce_table_kva[dev->bus->number] && !translate_empty_slots) 880 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots)
848 continue; 881 continue;
882
849 calgary_disable_translation(dev); 883 calgary_disable_translation(dev);
850 calgary_free_tar(dev); 884 calgary_free_bus(dev);
851 pci_dev_put(dev); 885 pci_dev_put(dev); /* Undo calgary_init_one()'s pci_dev_get() */
852 } 886 }
853 887
854 return ret; 888 return ret;
@@ -890,13 +924,15 @@ void __init detect_calgary(void)
890 if (swiotlb || no_iommu || iommu_detected) 924 if (swiotlb || no_iommu || iommu_detected)
891 return; 925 return;
892 926
927 if (!early_pci_allowed())
928 return;
929
893 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE); 930 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
894 931
895 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) { 932 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
896 int dev; 933 int dev;
897 934 struct calgary_bus_info *info = &bus_info[bus];
898 tce_table_kva[bus] = NULL; 935 info->phbid = -1;
899 bus_to_phb[bus] = -1;
900 936
901 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY) 937 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY)
902 continue; 938 continue;
@@ -907,12 +943,9 @@ void __init detect_calgary(void)
907 */ 943 */
908 phb = (phb + 1) % PHBS_PER_CALGARY; 944 phb = (phb + 1) % PHBS_PER_CALGARY;
909 945
910 if (test_bit(bus, translation_disabled)) { 946 if (info->translation_disabled)
911 printk(KERN_INFO "Calgary: translation is disabled for "
912 "PHB 0x%x\n", bus);
913 /* skip this phb, don't allocate a tbl for it */
914 continue; 947 continue;
915 } 948
916 /* 949 /*
917 * Scan the slots of the PCI bus to see if there is a device present. 950 * Scan the slots of the PCI bus to see if there is a device present.
918 * The parent bus will be the zero-ith device, so start at 1. 951 * The parent bus will be the zero-ith device, so start at 1.
@@ -923,8 +956,8 @@ void __init detect_calgary(void)
923 tbl = alloc_tce_table(); 956 tbl = alloc_tce_table();
924 if (!tbl) 957 if (!tbl)
925 goto cleanup; 958 goto cleanup;
926 tce_table_kva[bus] = tbl; 959 info->tce_space = tbl;
927 bus_to_phb[bus] = phb; 960 info->phbid = phb;
928 calgary_found = 1; 961 calgary_found = 1;
929 break; 962 break;
930 } 963 }
@@ -934,15 +967,20 @@ void __init detect_calgary(void)
934 if (calgary_found) { 967 if (calgary_found) {
935 iommu_detected = 1; 968 iommu_detected = 1;
936 calgary_detected = 1; 969 calgary_detected = 1;
937 printk(KERN_INFO "PCI-DMA: Calgary IOMMU detected. " 970 printk(KERN_INFO "PCI-DMA: Calgary IOMMU detected.\n");
938 "TCE table spec is %d.\n", specified_table_size); 971 printk(KERN_INFO "PCI-DMA: Calgary TCE table spec is %d, "
972 "CONFIG_IOMMU_DEBUG is %s.\n", specified_table_size,
973 debugging ? "enabled" : "disabled");
939 } 974 }
940 return; 975 return;
941 976
942cleanup: 977cleanup:
943 for (--bus; bus >= 0; --bus) 978 for (--bus; bus >= 0; --bus) {
944 if (tce_table_kva[bus]) 979 struct calgary_bus_info *info = &bus_info[bus];
945 free_tce_table(tce_table_kva[bus]); 980
981 if (info->tce_space)
982 free_tce_table(info->tce_space);
983 }
946} 984}
947 985
948int __init calgary_iommu_init(void) 986int __init calgary_iommu_init(void)
@@ -1016,7 +1054,7 @@ static int __init calgary_parse_options(char *p)
1016 if (bridge < MAX_PHB_BUS_NUM) { 1054 if (bridge < MAX_PHB_BUS_NUM) {
1017 printk(KERN_INFO "Calgary: disabling " 1055 printk(KERN_INFO "Calgary: disabling "
1018 "translation for PHB 0x%x\n", bridge); 1056 "translation for PHB 0x%x\n", bridge);
1019 set_bit(bridge, translation_disabled); 1057 bus_info[bridge].translation_disabled = 1;
1020 } 1058 }
1021 } 1059 }
1022 1060
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index 9c44f4f2433d..4dcb671bd19f 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -236,6 +236,9 @@ __init int iommu_setup(char *p)
236{ 236{
237 iommu_merge = 1; 237 iommu_merge = 1;
238 238
239 if (!p)
240 return -EINVAL;
241
239 while (*p) { 242 while (*p) {
240 if (!strncmp(p,"off",3)) 243 if (!strncmp(p,"off",3))
241 no_iommu = 1; 244 no_iommu = 1;
@@ -278,9 +281,9 @@ __init int iommu_setup(char *p)
278 if (*p == ',') 281 if (*p == ',')
279 ++p; 282 ++p;
280 } 283 }
281 return 1; 284 return 0;
282} 285}
283__setup("iommu=", iommu_setup); 286early_param("iommu", iommu_setup);
284 287
285void __init pci_iommu_alloc(void) 288void __init pci_iommu_alloc(void)
286{ 289{
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index 6d3e61baf7a0..16261a8a3303 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -239,8 +239,6 @@ dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
239{ 239{
240 unsigned long phys_mem, bus; 240 unsigned long phys_mem, bus;
241 241
242 BUG_ON(dir == DMA_NONE);
243
244 if (!dev) 242 if (!dev)
245 dev = &fallback_dev; 243 dev = &fallback_dev;
246 244
@@ -383,7 +381,6 @@ int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
383 unsigned long pages = 0; 381 unsigned long pages = 0;
384 int need = 0, nextneed; 382 int need = 0, nextneed;
385 383
386 BUG_ON(dir == DMA_NONE);
387 if (nents == 0) 384 if (nents == 0)
388 return 0; 385 return 0;
389 386
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index aad7609d8e92..df09ab05a1bd 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -59,7 +59,6 @@ int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
59{ 59{
60 int i; 60 int i;
61 61
62 BUG_ON(direction == DMA_NONE);
63 for (i = 0; i < nents; i++ ) { 62 for (i = 0; i < nents; i++ ) {
64 struct scatterlist *s = &sg[i]; 63 struct scatterlist *s = &sg[i];
65 BUG_ON(!s->page); 64 BUG_ON(!s->page);
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index bb6745d13b8f..458006ae19f3 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -80,25 +80,25 @@ void idle_notifier_unregister(struct notifier_block *n)
80} 80}
81EXPORT_SYMBOL(idle_notifier_unregister); 81EXPORT_SYMBOL(idle_notifier_unregister);
82 82
83enum idle_state { CPU_IDLE, CPU_NOT_IDLE };
84static DEFINE_PER_CPU(enum idle_state, idle_state) = CPU_NOT_IDLE;
85
86void enter_idle(void) 83void enter_idle(void)
87{ 84{
88 __get_cpu_var(idle_state) = CPU_IDLE; 85 write_pda(isidle, 1);
89 atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL); 86 atomic_notifier_call_chain(&idle_notifier, IDLE_START, NULL);
90} 87}
91 88
92static void __exit_idle(void) 89static void __exit_idle(void)
93{ 90{
94 __get_cpu_var(idle_state) = CPU_NOT_IDLE; 91 if (read_pda(isidle) == 0)
92 return;
93 write_pda(isidle, 0);
95 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL); 94 atomic_notifier_call_chain(&idle_notifier, IDLE_END, NULL);
96} 95}
97 96
98/* Called from interrupts to signify idle end */ 97/* Called from interrupts to signify idle end */
99void exit_idle(void) 98void exit_idle(void)
100{ 99{
101 if (current->pid | read_pda(irqcount)) 100 /* idle loop has pid 0 */
101 if (current->pid)
102 return; 102 return;
103 __exit_idle(); 103 __exit_idle();
104} 104}
@@ -220,6 +220,9 @@ void cpu_idle (void)
220 play_dead(); 220 play_dead();
221 enter_idle(); 221 enter_idle();
222 idle(); 222 idle();
223 /* In many cases the interrupt that ended idle
224 has already called exit_idle. But some idle
225 loops can be woken up without interrupt. */
223 __exit_idle(); 226 __exit_idle();
224 } 227 }
225 228
@@ -350,6 +353,7 @@ void exit_thread(void)
350 353
351 kfree(t->io_bitmap_ptr); 354 kfree(t->io_bitmap_ptr);
352 t->io_bitmap_ptr = NULL; 355 t->io_bitmap_ptr = NULL;
356 clear_thread_flag(TIF_IO_BITMAP);
353 /* 357 /*
354 * Careful, clear this in the TSS too: 358 * Careful, clear this in the TSS too:
355 */ 359 */
@@ -369,6 +373,7 @@ void flush_thread(void)
369 if (t->flags & _TIF_IA32) 373 if (t->flags & _TIF_IA32)
370 current_thread_info()->status |= TS_COMPAT; 374 current_thread_info()->status |= TS_COMPAT;
371 } 375 }
376 t->flags &= ~_TIF_DEBUG;
372 377
373 tsk->thread.debugreg0 = 0; 378 tsk->thread.debugreg0 = 0;
374 tsk->thread.debugreg1 = 0; 379 tsk->thread.debugreg1 = 0;
@@ -461,7 +466,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp,
461 asm("mov %%es,%0" : "=m" (p->thread.es)); 466 asm("mov %%es,%0" : "=m" (p->thread.es));
462 asm("mov %%ds,%0" : "=m" (p->thread.ds)); 467 asm("mov %%ds,%0" : "=m" (p->thread.ds));
463 468
464 if (unlikely(me->thread.io_bitmap_ptr != NULL)) { 469 if (unlikely(test_tsk_thread_flag(me, TIF_IO_BITMAP))) {
465 p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); 470 p->thread.io_bitmap_ptr = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL);
466 if (!p->thread.io_bitmap_ptr) { 471 if (!p->thread.io_bitmap_ptr) {
467 p->thread.io_bitmap_max = 0; 472 p->thread.io_bitmap_max = 0;
@@ -469,6 +474,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long rsp,
469 } 474 }
470 memcpy(p->thread.io_bitmap_ptr, me->thread.io_bitmap_ptr, 475 memcpy(p->thread.io_bitmap_ptr, me->thread.io_bitmap_ptr,
471 IO_BITMAP_BYTES); 476 IO_BITMAP_BYTES);
477 set_tsk_thread_flag(p, TIF_IO_BITMAP);
472 } 478 }
473 479
474 /* 480 /*
@@ -498,6 +504,40 @@ out:
498 */ 504 */
499#define loaddebug(thread,r) set_debugreg(thread->debugreg ## r, r) 505#define loaddebug(thread,r) set_debugreg(thread->debugreg ## r, r)
500 506
507static inline void __switch_to_xtra(struct task_struct *prev_p,
508 struct task_struct *next_p,
509 struct tss_struct *tss)
510{
511 struct thread_struct *prev, *next;
512
513 prev = &prev_p->thread,
514 next = &next_p->thread;
515
516 if (test_tsk_thread_flag(next_p, TIF_DEBUG)) {
517 loaddebug(next, 0);
518 loaddebug(next, 1);
519 loaddebug(next, 2);
520 loaddebug(next, 3);
521 /* no 4 and 5 */
522 loaddebug(next, 6);
523 loaddebug(next, 7);
524 }
525
526 if (test_tsk_thread_flag(next_p, TIF_IO_BITMAP)) {
527 /*
528 * Copy the relevant range of the IO bitmap.
529 * Normally this is 128 bytes or less:
530 */
531 memcpy(tss->io_bitmap, next->io_bitmap_ptr,
532 max(prev->io_bitmap_max, next->io_bitmap_max));
533 } else if (test_tsk_thread_flag(prev_p, TIF_IO_BITMAP)) {
534 /*
535 * Clear any possible leftover bits:
536 */
537 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
538 }
539}
540
501/* 541/*
502 * switch_to(x,y) should switch tasks from x to y. 542 * switch_to(x,y) should switch tasks from x to y.
503 * 543 *
@@ -515,6 +555,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
515 int cpu = smp_processor_id(); 555 int cpu = smp_processor_id();
516 struct tss_struct *tss = &per_cpu(init_tss, cpu); 556 struct tss_struct *tss = &per_cpu(init_tss, cpu);
517 557
558 /* we're going to use this soon, after a few expensive things */
559 if (next_p->fpu_counter>5)
560 prefetch(&next->i387.fxsave);
561
518 /* 562 /*
519 * Reload esp0, LDT and the page table pointer: 563 * Reload esp0, LDT and the page table pointer:
520 */ 564 */
@@ -583,41 +627,29 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
583 And the AMD workaround requires it to be after DS reload. */ 627 And the AMD workaround requires it to be after DS reload. */
584 unlazy_fpu(prev_p); 628 unlazy_fpu(prev_p);
585 write_pda(kernelstack, 629 write_pda(kernelstack,
586 task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET); 630 (unsigned long)task_stack_page(next_p) + THREAD_SIZE - PDA_STACKOFFSET);
587 631#ifdef CONFIG_CC_STACKPROTECTOR
632 write_pda(stack_canary, next_p->stack_canary);
588 /* 633 /*
589 * Now maybe reload the debug registers 634 * Build time only check to make sure the stack_canary is at
635 * offset 40 in the pda; this is a gcc ABI requirement
590 */ 636 */
591 if (unlikely(next->debugreg7)) { 637 BUILD_BUG_ON(offsetof(struct x8664_pda, stack_canary) != 40);
592 loaddebug(next, 0); 638#endif
593 loaddebug(next, 1);
594 loaddebug(next, 2);
595 loaddebug(next, 3);
596 /* no 4 and 5 */
597 loaddebug(next, 6);
598 loaddebug(next, 7);
599 }
600
601 639
602 /* 640 /*
603 * Handle the IO bitmap 641 * Now maybe reload the debug registers and handle I/O bitmaps
604 */ 642 */
605 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) { 643 if (unlikely((task_thread_info(next_p)->flags & _TIF_WORK_CTXSW))
606 if (next->io_bitmap_ptr) 644 || test_tsk_thread_flag(prev_p, TIF_IO_BITMAP))
607 /* 645 __switch_to_xtra(prev_p, next_p, tss);
608 * Copy the relevant range of the IO bitmap.
609 * Normally this is 128 bytes or less:
610 */
611 memcpy(tss->io_bitmap, next->io_bitmap_ptr,
612 max(prev->io_bitmap_max, next->io_bitmap_max));
613 else {
614 /*
615 * Clear any possible leftover bits:
616 */
617 memset(tss->io_bitmap, 0xff, prev->io_bitmap_max);
618 }
619 }
620 646
647 /* If the task has used fpu the last 5 timeslices, just do a full
648 * restore of the math state immediately to avoid the trap; the
649 * chances of needing FPU soon are obviously high now
650 */
651 if (next_p->fpu_counter>5)
652 math_state_restore();
621 return prev_p; 653 return prev_p;
622} 654}
623 655
@@ -834,7 +866,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs)
834 866
835unsigned long arch_align_stack(unsigned long sp) 867unsigned long arch_align_stack(unsigned long sp)
836{ 868{
837 if (randomize_va_space) 869 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
838 sp -= get_random_int() % 8192; 870 sp -= get_random_int() % 8192;
839 return sp & ~0xf; 871 return sp & ~0xf;
840} 872}
diff --git a/arch/x86_64/kernel/ptrace.c b/arch/x86_64/kernel/ptrace.c
index 2d50024c9f30..addc14af0c56 100644
--- a/arch/x86_64/kernel/ptrace.c
+++ b/arch/x86_64/kernel/ptrace.c
@@ -116,17 +116,17 @@ unsigned long convert_rip_to_linear(struct task_struct *child, struct pt_regs *r
116 return addr; 116 return addr;
117} 117}
118 118
119static int is_at_popf(struct task_struct *child, struct pt_regs *regs) 119static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
120{ 120{
121 int i, copied; 121 int i, copied;
122 unsigned char opcode[16]; 122 unsigned char opcode[15];
123 unsigned long addr = convert_rip_to_linear(child, regs); 123 unsigned long addr = convert_rip_to_linear(child, regs);
124 124
125 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0); 125 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
126 for (i = 0; i < copied; i++) { 126 for (i = 0; i < copied; i++) {
127 switch (opcode[i]) { 127 switch (opcode[i]) {
128 /* popf */ 128 /* popf and iret */
129 case 0x9d: 129 case 0x9d: case 0xcf:
130 return 1; 130 return 1;
131 131
132 /* CHECKME: 64 65 */ 132 /* CHECKME: 64 65 */
@@ -138,14 +138,17 @@ static int is_at_popf(struct task_struct *child, struct pt_regs *regs)
138 case 0x26: case 0x2e: 138 case 0x26: case 0x2e:
139 case 0x36: case 0x3e: 139 case 0x36: case 0x3e:
140 case 0x64: case 0x65: 140 case 0x64: case 0x65:
141 case 0xf0: case 0xf2: case 0xf3: 141 case 0xf2: case 0xf3:
142 continue; 142 continue;
143 143
144 /* REX prefixes */
145 case 0x40 ... 0x4f: 144 case 0x40 ... 0x4f:
145 if (regs->cs != __USER_CS)
146 /* 32-bit mode: register increment */
147 return 0;
148 /* 64-bit mode: REX prefix */
146 continue; 149 continue;
147 150
148 /* CHECKME: f0, f2, f3 */ 151 /* CHECKME: f2, f3 */
149 152
150 /* 153 /*
151 * pushf: NOTE! We should probably not let 154 * pushf: NOTE! We should probably not let
@@ -186,10 +189,8 @@ static void set_singlestep(struct task_struct *child)
186 * ..but if TF is changed by the instruction we will trace, 189 * ..but if TF is changed by the instruction we will trace,
187 * don't mark it as being "us" that set it, so that we 190 * don't mark it as being "us" that set it, so that we
188 * won't clear it by hand later. 191 * won't clear it by hand later.
189 *
190 * AK: this is not enough, LAHF and IRET can change TF in user space too.
191 */ 192 */
192 if (is_at_popf(child, regs)) 193 if (is_setting_trap_flag(child, regs))
193 return; 194 return;
194 195
195 child->ptrace |= PT_DTRACE; 196 child->ptrace |= PT_DTRACE;
@@ -420,9 +421,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
420 if ((0x5554 >> ((data >> (16 + 4*i)) & 0xf)) & 1) 421 if ((0x5554 >> ((data >> (16 + 4*i)) & 0xf)) & 1)
421 break; 422 break;
422 if (i == 4) { 423 if (i == 4) {
423 child->thread.debugreg7 = data; 424 child->thread.debugreg7 = data;
425 if (data)
426 set_tsk_thread_flag(child, TIF_DEBUG);
427 else
428 clear_tsk_thread_flag(child, TIF_DEBUG);
424 ret = 0; 429 ret = 0;
425 } 430 }
426 break; 431 break;
427 } 432 }
428 break; 433 break;
diff --git a/arch/x86_64/kernel/relocate_kernel.S b/arch/x86_64/kernel/relocate_kernel.S
index d24fa9b72a2b..14e95872c6a3 100644
--- a/arch/x86_64/kernel/relocate_kernel.S
+++ b/arch/x86_64/kernel/relocate_kernel.S
@@ -7,31 +7,169 @@
7 */ 7 */
8 8
9#include <linux/linkage.h> 9#include <linux/linkage.h>
10#include <asm/page.h>
11#include <asm/kexec.h>
10 12
11 /* 13/*
12 * Must be relocatable PIC code callable as a C function, that once 14 * Must be relocatable PIC code callable as a C function
13 * it starts can not use the previous processes stack. 15 */
14 */ 16
15 .globl relocate_new_kernel 17#define PTR(x) (x << 3)
18#define PAGE_ALIGNED (1 << PAGE_SHIFT)
19#define PAGE_ATTR 0x63 /* _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY */
20
21 .text
22 .align PAGE_ALIGNED
16 .code64 23 .code64
24 .globl relocate_kernel
25relocate_kernel:
26 /* %rdi indirection_page
27 * %rsi page_list
28 * %rdx start address
29 */
30
31 /* map the control page at its virtual address */
32
33 movq $0x0000ff8000000000, %r10 /* mask */
34 mov $(39 - 3), %cl /* bits to shift */
35 movq PTR(VA_CONTROL_PAGE)(%rsi), %r11 /* address to map */
36
37 movq %r11, %r9
38 andq %r10, %r9
39 shrq %cl, %r9
40
41 movq PTR(VA_PGD)(%rsi), %r8
42 addq %r8, %r9
43 movq PTR(PA_PUD_0)(%rsi), %r8
44 orq $PAGE_ATTR, %r8
45 movq %r8, (%r9)
46
47 shrq $9, %r10
48 sub $9, %cl
49
50 movq %r11, %r9
51 andq %r10, %r9
52 shrq %cl, %r9
53
54 movq PTR(VA_PUD_0)(%rsi), %r8
55 addq %r8, %r9
56 movq PTR(PA_PMD_0)(%rsi), %r8
57 orq $PAGE_ATTR, %r8
58 movq %r8, (%r9)
59
60 shrq $9, %r10
61 sub $9, %cl
62
63 movq %r11, %r9
64 andq %r10, %r9
65 shrq %cl, %r9
66
67 movq PTR(VA_PMD_0)(%rsi), %r8
68 addq %r8, %r9
69 movq PTR(PA_PTE_0)(%rsi), %r8
70 orq $PAGE_ATTR, %r8
71 movq %r8, (%r9)
72
73 shrq $9, %r10
74 sub $9, %cl
75
76 movq %r11, %r9
77 andq %r10, %r9
78 shrq %cl, %r9
79
80 movq PTR(VA_PTE_0)(%rsi), %r8
81 addq %r8, %r9
82 movq PTR(PA_CONTROL_PAGE)(%rsi), %r8
83 orq $PAGE_ATTR, %r8
84 movq %r8, (%r9)
85
86 /* identity map the control page at its physical address */
87
88 movq $0x0000ff8000000000, %r10 /* mask */
89 mov $(39 - 3), %cl /* bits to shift */
90 movq PTR(PA_CONTROL_PAGE)(%rsi), %r11 /* address to map */
91
92 movq %r11, %r9
93 andq %r10, %r9
94 shrq %cl, %r9
95
96 movq PTR(VA_PGD)(%rsi), %r8
97 addq %r8, %r9
98 movq PTR(PA_PUD_1)(%rsi), %r8
99 orq $PAGE_ATTR, %r8
100 movq %r8, (%r9)
101
102 shrq $9, %r10
103 sub $9, %cl
104
105 movq %r11, %r9
106 andq %r10, %r9
107 shrq %cl, %r9
108
109 movq PTR(VA_PUD_1)(%rsi), %r8
110 addq %r8, %r9
111 movq PTR(PA_PMD_1)(%rsi), %r8
112 orq $PAGE_ATTR, %r8
113 movq %r8, (%r9)
114
115 shrq $9, %r10
116 sub $9, %cl
117
118 movq %r11, %r9
119 andq %r10, %r9
120 shrq %cl, %r9
121
122 movq PTR(VA_PMD_1)(%rsi), %r8
123 addq %r8, %r9
124 movq PTR(PA_PTE_1)(%rsi), %r8
125 orq $PAGE_ATTR, %r8
126 movq %r8, (%r9)
127
128 shrq $9, %r10
129 sub $9, %cl
130
131 movq %r11, %r9
132 andq %r10, %r9
133 shrq %cl, %r9
134
135 movq PTR(VA_PTE_1)(%rsi), %r8
136 addq %r8, %r9
137 movq PTR(PA_CONTROL_PAGE)(%rsi), %r8
138 orq $PAGE_ATTR, %r8
139 movq %r8, (%r9)
140
17relocate_new_kernel: 141relocate_new_kernel:
18 /* %rdi page_list 142 /* %rdi indirection_page
19 * %rsi reboot_code_buffer 143 * %rsi page_list
20 * %rdx start address 144 * %rdx start address
21 * %rcx page_table
22 * %r8 arg5
23 * %r9 arg6
24 */ 145 */
25 146
26 /* zero out flags, and disable interrupts */ 147 /* zero out flags, and disable interrupts */
27 pushq $0 148 pushq $0
28 popfq 149 popfq
29 150
30 /* set a new stack at the bottom of our page... */ 151 /* get physical address of control page now */
31 lea 4096(%rsi), %rsp 152 /* this is impossible after page table switch */
153 movq PTR(PA_CONTROL_PAGE)(%rsi), %r8
154
155 /* get physical address of page table now too */
156 movq PTR(PA_TABLE_PAGE)(%rsi), %rcx
32 157
33 /* store the parameters back on the stack */ 158 /* switch to new set of page tables */
34 pushq %rdx /* store the start address */ 159 movq PTR(PA_PGD)(%rsi), %r9
160 movq %r9, %cr3
161
162 /* setup a new stack at the end of the physical control page */
163 lea 4096(%r8), %rsp
164
165 /* jump to identity mapped page */
166 addq $(identity_mapped - relocate_kernel), %r8
167 pushq %r8
168 ret
169
170identity_mapped:
171 /* store the start address on the stack */
172 pushq %rdx
35 173
36 /* Set cr0 to a known state: 174 /* Set cr0 to a known state:
37 * 31 1 == Paging enabled 175 * 31 1 == Paging enabled
@@ -136,8 +274,3 @@ relocate_new_kernel:
136 xorq %r15, %r15 274 xorq %r15, %r15
137 275
138 ret 276 ret
139relocate_new_kernel_end:
140
141 .globl relocate_new_kernel_size
142relocate_new_kernel_size:
143 .quad relocate_new_kernel_end - relocate_new_kernel
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 4b39f0da17f3..0b00bb2ea576 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -74,16 +74,6 @@ EXPORT_SYMBOL(boot_cpu_data);
74 74
75unsigned long mmu_cr4_features; 75unsigned long mmu_cr4_features;
76 76
77int acpi_disabled;
78EXPORT_SYMBOL(acpi_disabled);
79#ifdef CONFIG_ACPI
80extern int __initdata acpi_ht;
81extern acpi_interrupt_flags acpi_sci_flags;
82int __initdata acpi_force = 0;
83#endif
84
85int acpi_numa __initdata;
86
87/* Boot loader ID as an integer, for the benefit of proc_dointvec */ 77/* Boot loader ID as an integer, for the benefit of proc_dointvec */
88int bootloader_type; 78int bootloader_type;
89 79
@@ -107,7 +97,6 @@ struct sys_desc_table_struct {
107 97
108struct edid_info edid_info; 98struct edid_info edid_info;
109EXPORT_SYMBOL_GPL(edid_info); 99EXPORT_SYMBOL_GPL(edid_info);
110struct e820map e820;
111 100
112extern int root_mountflags; 101extern int root_mountflags;
113 102
@@ -276,185 +265,22 @@ static void __init probe_roms(void)
276 } 265 }
277} 266}
278 267
279/* Check for full argument with no trailing characters */ 268#ifdef CONFIG_PROC_VMCORE
280static int fullarg(char *p, char *arg) 269/* elfcorehdr= specifies the location of elf core header
270 * stored by the crashed kernel. This option will be passed
271 * by kexec loader to the capture kernel.
272 */
273static int __init setup_elfcorehdr(char *arg)
281{ 274{
282 int l = strlen(arg); 275 char *end;
283 return !memcmp(p, arg, l) && (p[l] == 0 || isspace(p[l])); 276 if (!arg)
277 return -EINVAL;
278 elfcorehdr_addr = memparse(arg, &end);
279 return end > arg ? 0 : -EINVAL;
284} 280}
285 281early_param("elfcorehdr", setup_elfcorehdr);
286static __init void parse_cmdline_early (char ** cmdline_p)
287{
288 char c = ' ', *to = command_line, *from = COMMAND_LINE;
289 int len = 0;
290 int userdef = 0;
291
292 for (;;) {
293 if (c != ' ')
294 goto next_char;
295
296#ifdef CONFIG_SMP
297 /*
298 * If the BIOS enumerates physical processors before logical,
299 * maxcpus=N at enumeration-time can be used to disable HT.
300 */
301 else if (!memcmp(from, "maxcpus=", 8)) {
302 extern unsigned int maxcpus;
303
304 maxcpus = simple_strtoul(from + 8, NULL, 0);
305 }
306#endif
307#ifdef CONFIG_ACPI
308 /* "acpi=off" disables both ACPI table parsing and interpreter init */
309 if (fullarg(from,"acpi=off"))
310 disable_acpi();
311
312 if (fullarg(from, "acpi=force")) {
313 /* add later when we do DMI horrors: */
314 acpi_force = 1;
315 acpi_disabled = 0;
316 }
317
318 /* acpi=ht just means: do ACPI MADT parsing
319 at bootup, but don't enable the full ACPI interpreter */
320 if (fullarg(from, "acpi=ht")) {
321 if (!acpi_force)
322 disable_acpi();
323 acpi_ht = 1;
324 }
325 else if (fullarg(from, "pci=noacpi"))
326 acpi_disable_pci();
327 else if (fullarg(from, "acpi=noirq"))
328 acpi_noirq_set();
329
330 else if (fullarg(from, "acpi_sci=edge"))
331 acpi_sci_flags.trigger = 1;
332 else if (fullarg(from, "acpi_sci=level"))
333 acpi_sci_flags.trigger = 3;
334 else if (fullarg(from, "acpi_sci=high"))
335 acpi_sci_flags.polarity = 1;
336 else if (fullarg(from, "acpi_sci=low"))
337 acpi_sci_flags.polarity = 3;
338
339 /* acpi=strict disables out-of-spec workarounds */
340 else if (fullarg(from, "acpi=strict")) {
341 acpi_strict = 1;
342 }
343#ifdef CONFIG_X86_IO_APIC
344 else if (fullarg(from, "acpi_skip_timer_override"))
345 acpi_skip_timer_override = 1;
346#endif
347#endif
348
349 if (fullarg(from, "disable_timer_pin_1"))
350 disable_timer_pin_1 = 1;
351 if (fullarg(from, "enable_timer_pin_1"))
352 disable_timer_pin_1 = -1;
353
354 if (fullarg(from, "nolapic") || fullarg(from, "disableapic")) {
355 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
356 disable_apic = 1;
357 }
358
359 if (fullarg(from, "noapic"))
360 skip_ioapic_setup = 1;
361
362 if (fullarg(from,"apic")) {
363 skip_ioapic_setup = 0;
364 ioapic_force = 1;
365 }
366
367 if (!memcmp(from, "mem=", 4))
368 parse_memopt(from+4, &from);
369
370 if (!memcmp(from, "memmap=", 7)) {
371 /* exactmap option is for used defined memory */
372 if (!memcmp(from+7, "exactmap", 8)) {
373#ifdef CONFIG_CRASH_DUMP
374 /* If we are doing a crash dump, we
375 * still need to know the real mem
376 * size before original memory map is
377 * reset.
378 */
379 saved_max_pfn = e820_end_of_ram();
380#endif
381 from += 8+7;
382 end_pfn_map = 0;
383 e820.nr_map = 0;
384 userdef = 1;
385 }
386 else {
387 parse_memmapopt(from+7, &from);
388 userdef = 1;
389 }
390 }
391
392#ifdef CONFIG_NUMA
393 if (!memcmp(from, "numa=", 5))
394 numa_setup(from+5);
395#endif 282#endif
396 283
397 if (!memcmp(from,"iommu=",6)) {
398 iommu_setup(from+6);
399 }
400
401 if (fullarg(from,"oops=panic"))
402 panic_on_oops = 1;
403
404 if (!memcmp(from, "noexec=", 7))
405 nonx_setup(from + 7);
406
407#ifdef CONFIG_KEXEC
408 /* crashkernel=size@addr specifies the location to reserve for
409 * a crash kernel. By reserving this memory we guarantee
410 * that linux never set's it up as a DMA target.
411 * Useful for holding code to do something appropriate
412 * after a kernel panic.
413 */
414 else if (!memcmp(from, "crashkernel=", 12)) {
415 unsigned long size, base;
416 size = memparse(from+12, &from);
417 if (*from == '@') {
418 base = memparse(from+1, &from);
419 /* FIXME: Do I want a sanity check
420 * to validate the memory range?
421 */
422 crashk_res.start = base;
423 crashk_res.end = base + size - 1;
424 }
425 }
426#endif
427
428#ifdef CONFIG_PROC_VMCORE
429 /* elfcorehdr= specifies the location of elf core header
430 * stored by the crashed kernel. This option will be passed
431 * by kexec loader to the capture kernel.
432 */
433 else if(!memcmp(from, "elfcorehdr=", 11))
434 elfcorehdr_addr = memparse(from+11, &from);
435#endif
436
437#ifdef CONFIG_HOTPLUG_CPU
438 else if (!memcmp(from, "additional_cpus=", 16))
439 setup_additional_cpus(from+16);
440#endif
441
442 next_char:
443 c = *(from++);
444 if (!c)
445 break;
446 if (COMMAND_LINE_SIZE <= ++len)
447 break;
448 *(to++) = c;
449 }
450 if (userdef) {
451 printk(KERN_INFO "user-defined physical RAM map:\n");
452 e820_print_map("user");
453 }
454 *to = '\0';
455 *cmdline_p = command_line;
456}
457
458#ifndef CONFIG_NUMA 284#ifndef CONFIG_NUMA
459static void __init 285static void __init
460contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn) 286contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
@@ -466,7 +292,8 @@ contig_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
466 if (bootmap == -1L) 292 if (bootmap == -1L)
467 panic("Cannot find bootmem map of size %ld\n",bootmap_size); 293 panic("Cannot find bootmem map of size %ld\n",bootmap_size);
468 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn); 294 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, end_pfn);
469 e820_bootmem_free(NODE_DATA(0), 0, end_pfn << PAGE_SHIFT); 295 e820_register_active_regions(0, start_pfn, end_pfn);
296 free_bootmem_with_active_regions(0, end_pfn);
470 reserve_bootmem(bootmap, bootmap_size); 297 reserve_bootmem(bootmap, bootmap_size);
471} 298}
472#endif 299#endif
@@ -521,6 +348,8 @@ static void discover_ebda(void)
521 348
522void __init setup_arch(char **cmdline_p) 349void __init setup_arch(char **cmdline_p)
523{ 350{
351 printk(KERN_INFO "Command line: %s\n", saved_command_line);
352
524 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV); 353 ROOT_DEV = old_decode_dev(ORIG_ROOT_DEV);
525 screen_info = SCREEN_INFO; 354 screen_info = SCREEN_INFO;
526 edid_info = EDID_INFO; 355 edid_info = EDID_INFO;
@@ -547,16 +376,22 @@ void __init setup_arch(char **cmdline_p)
547 data_resource.start = virt_to_phys(&_etext); 376 data_resource.start = virt_to_phys(&_etext);
548 data_resource.end = virt_to_phys(&_edata)-1; 377 data_resource.end = virt_to_phys(&_edata)-1;
549 378
550 parse_cmdline_early(cmdline_p);
551
552 early_identify_cpu(&boot_cpu_data); 379 early_identify_cpu(&boot_cpu_data);
553 380
381 strlcpy(command_line, saved_command_line, COMMAND_LINE_SIZE);
382 *cmdline_p = command_line;
383
384 parse_early_param();
385
386 finish_e820_parsing();
387
388 e820_register_active_regions(0, 0, -1UL);
554 /* 389 /*
555 * partially used pages are not usable - thus 390 * partially used pages are not usable - thus
556 * we are rounding upwards: 391 * we are rounding upwards:
557 */ 392 */
558 end_pfn = e820_end_of_ram(); 393 end_pfn = e820_end_of_ram();
559 num_physpages = end_pfn; /* for pfn_valid */ 394 num_physpages = end_pfn;
560 395
561 check_efer(); 396 check_efer();
562 397
@@ -576,6 +411,14 @@ void __init setup_arch(char **cmdline_p)
576 acpi_boot_table_init(); 411 acpi_boot_table_init();
577#endif 412#endif
578 413
414 /* How many end-of-memory variables you have, grandma! */
415 max_low_pfn = end_pfn;
416 max_pfn = end_pfn;
417 high_memory = (void *)__va(end_pfn * PAGE_SIZE - 1) + 1;
418
419 /* Remove active ranges so rediscovery with NUMA-awareness happens */
420 remove_all_active_ranges();
421
579#ifdef CONFIG_ACPI_NUMA 422#ifdef CONFIG_ACPI_NUMA
580 /* 423 /*
581 * Parse SRAT to discover nodes. 424 * Parse SRAT to discover nodes.
@@ -625,12 +468,10 @@ void __init setup_arch(char **cmdline_p)
625 */ 468 */
626 acpi_reserve_bootmem(); 469 acpi_reserve_bootmem();
627#endif 470#endif
628#ifdef CONFIG_X86_LOCAL_APIC
629 /* 471 /*
630 * Find and reserve possible boot-time SMP configuration: 472 * Find and reserve possible boot-time SMP configuration:
631 */ 473 */
632 find_smp_config(); 474 find_smp_config();
633#endif
634#ifdef CONFIG_BLK_DEV_INITRD 475#ifdef CONFIG_BLK_DEV_INITRD
635 if (LOADER_TYPE && INITRD_START) { 476 if (LOADER_TYPE && INITRD_START) {
636 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) { 477 if (INITRD_START + INITRD_SIZE <= (end_pfn << PAGE_SHIFT)) {
@@ -657,7 +498,9 @@ void __init setup_arch(char **cmdline_p)
657 498
658 paging_init(); 499 paging_init();
659 500
660 check_ioapic(); 501#ifdef CONFIG_PCI
502 early_quirks();
503#endif
661 504
662 /* 505 /*
663 * set this early, so we dont allocate cpu0 506 * set this early, so we dont allocate cpu0
@@ -674,14 +517,12 @@ void __init setup_arch(char **cmdline_p)
674 517
675 init_cpu_to_node(); 518 init_cpu_to_node();
676 519
677#ifdef CONFIG_X86_LOCAL_APIC
678 /* 520 /*
679 * get boot-time SMP configuration: 521 * get boot-time SMP configuration:
680 */ 522 */
681 if (smp_found_config) 523 if (smp_found_config)
682 get_smp_config(); 524 get_smp_config();
683 init_apic_mappings(); 525 init_apic_mappings();
684#endif
685 526
686 /* 527 /*
687 * Request address space for all standard RAM and ROM resources 528 * Request address space for all standard RAM and ROM resources
@@ -839,7 +680,7 @@ static void __init amd_detect_cmp(struct cpuinfo_x86 *c)
839#endif 680#endif
840} 681}
841 682
842static void __init init_amd(struct cpuinfo_x86 *c) 683static void __cpuinit init_amd(struct cpuinfo_x86 *c)
843{ 684{
844 unsigned level; 685 unsigned level;
845 686
@@ -895,6 +736,12 @@ static void __init init_amd(struct cpuinfo_x86 *c)
895 736
896 /* Fix cpuid4 emulation for more */ 737 /* Fix cpuid4 emulation for more */
897 num_cache_leaves = 3; 738 num_cache_leaves = 3;
739
740 /* When there is only one core no need to synchronize RDTSC */
741 if (num_possible_cpus() == 1)
742 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
743 else
744 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
898} 745}
899 746
900static void __cpuinit detect_ht(struct cpuinfo_x86 *c) 747static void __cpuinit detect_ht(struct cpuinfo_x86 *c)
@@ -976,8 +823,7 @@ static void srat_detect_node(void)
976 node = first_node(node_online_map); 823 node = first_node(node_online_map);
977 numa_set_node(cpu, node); 824 numa_set_node(cpu, node);
978 825
979 if (acpi_numa > 0) 826 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
980 printk(KERN_INFO "CPU %d/%x -> Node %d\n", cpu, apicid, node);
981#endif 827#endif
982} 828}
983 829
@@ -1011,6 +857,8 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
1011 if ((c->x86 == 0xf && c->x86_model >= 0x03) || 857 if ((c->x86 == 0xf && c->x86_model >= 0x03) ||
1012 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 858 (c->x86 == 0x6 && c->x86_model >= 0x0e))
1013 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability); 859 set_bit(X86_FEATURE_CONSTANT_TSC, &c->x86_capability);
860 if (c->x86 == 6)
861 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
1014 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability); 862 set_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
1015 c->x86_max_cores = intel_num_cpu_cores(c); 863 c->x86_max_cores = intel_num_cpu_cores(c);
1016 864
@@ -1229,8 +1077,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
1229 1077
1230 /* Intel-defined (#2) */ 1078 /* Intel-defined (#2) */
1231 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est", 1079 "pni", NULL, NULL, "monitor", "ds_cpl", "vmx", "smx", "est",
1232 "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL, 1080 "tm2", "ssse3", "cid", NULL, NULL, "cx16", "xtpr", NULL,
1233 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1081 NULL, NULL, "dca", NULL, NULL, NULL, NULL, NULL,
1234 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1082 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
1235 1083
1236 /* VIA/Cyrix/Centaur-defined */ 1084 /* VIA/Cyrix/Centaur-defined */
diff --git a/arch/x86_64/kernel/setup64.c b/arch/x86_64/kernel/setup64.c
index 417de564456e..8c4b80fe71a1 100644
--- a/arch/x86_64/kernel/setup64.c
+++ b/arch/x86_64/kernel/setup64.c
@@ -24,7 +24,7 @@
24#include <asm/proto.h> 24#include <asm/proto.h>
25#include <asm/sections.h> 25#include <asm/sections.h>
26 26
27char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,}; 27char x86_boot_params[BOOT_PARAM_SIZE] __initdata;
28 28
29cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE; 29cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
30 30
@@ -46,8 +46,10 @@ Control non executable mappings for 64bit processes.
46on Enable(default) 46on Enable(default)
47off Disable 47off Disable
48*/ 48*/
49int __init nonx_setup(char *str) 49static int __init nonx_setup(char *str)
50{ 50{
51 if (!str)
52 return -EINVAL;
51 if (!strncmp(str, "on", 2)) { 53 if (!strncmp(str, "on", 2)) {
52 __supported_pte_mask |= _PAGE_NX; 54 __supported_pte_mask |= _PAGE_NX;
53 do_not_nx = 0; 55 do_not_nx = 0;
@@ -55,9 +57,9 @@ int __init nonx_setup(char *str)
55 do_not_nx = 1; 57 do_not_nx = 1;
56 __supported_pte_mask &= ~_PAGE_NX; 58 __supported_pte_mask &= ~_PAGE_NX;
57 } 59 }
58 return 1; 60 return 0;
59} 61}
60__setup("noexec=", nonx_setup); /* parsed early actually */ 62early_param("noexec", nonx_setup);
61 63
62int force_personality32 = 0; 64int force_personality32 = 0;
63 65
@@ -93,12 +95,9 @@ void __init setup_per_cpu_areas(void)
93#endif 95#endif
94 96
95 /* Copy section for each CPU (we discard the original) */ 97 /* Copy section for each CPU (we discard the original) */
96 size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES); 98 size = PERCPU_ENOUGH_ROOM;
97#ifdef CONFIG_MODULES
98 if (size < PERCPU_ENOUGH_ROOM)
99 size = PERCPU_ENOUGH_ROOM;
100#endif
101 99
100 printk(KERN_INFO "PERCPU: Allocating %lu bytes of per cpu data\n", size);
102 for_each_cpu_mask (i, cpu_possible_map) { 101 for_each_cpu_mask (i, cpu_possible_map) {
103 char *ptr; 102 char *ptr;
104 103
@@ -122,7 +121,10 @@ void pda_init(int cpu)
122 121
123 /* Setup up data that may be needed in __get_free_pages early */ 122 /* Setup up data that may be needed in __get_free_pages early */
124 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0)); 123 asm volatile("movl %0,%%fs ; movl %0,%%gs" :: "r" (0));
124 /* Memory clobbers used to order PDA accessed */
125 mb();
125 wrmsrl(MSR_GS_BASE, pda); 126 wrmsrl(MSR_GS_BASE, pda);
127 mb();
126 128
127 pda->cpunumber = cpu; 129 pda->cpunumber = cpu;
128 pda->irqcount = -1; 130 pda->irqcount = -1;
@@ -178,6 +180,8 @@ void __cpuinit check_efer(void)
178 } 180 }
179} 181}
180 182
183unsigned long kernel_eflags;
184
181/* 185/*
182 * cpu_init() initializes state that is per-CPU. Some data is already 186 * cpu_init() initializes state that is per-CPU. Some data is already
183 * initialized (naturally) in the bootstrap process, such as the GDT 187 * initialized (naturally) in the bootstrap process, such as the GDT
@@ -235,28 +239,17 @@ void __cpuinit cpu_init (void)
235 * set up and load the per-CPU TSS 239 * set up and load the per-CPU TSS
236 */ 240 */
237 for (v = 0; v < N_EXCEPTION_STACKS; v++) { 241 for (v = 0; v < N_EXCEPTION_STACKS; v++) {
242 static const unsigned int order[N_EXCEPTION_STACKS] = {
243 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
244 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
245 };
238 if (cpu) { 246 if (cpu) {
239 static const unsigned int order[N_EXCEPTION_STACKS] = {
240 [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STACK_ORDER,
241 [DEBUG_STACK - 1] = DEBUG_STACK_ORDER
242 };
243
244 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]); 247 estacks = (char *)__get_free_pages(GFP_ATOMIC, order[v]);
245 if (!estacks) 248 if (!estacks)
246 panic("Cannot allocate exception stack %ld %d\n", 249 panic("Cannot allocate exception stack %ld %d\n",
247 v, cpu); 250 v, cpu);
248 } 251 }
249 switch (v + 1) { 252 estacks += PAGE_SIZE << order[v];
250#if DEBUG_STKSZ > EXCEPTION_STKSZ
251 case DEBUG_STACK:
252 cpu_pda(cpu)->debugstack = (unsigned long)estacks;
253 estacks += DEBUG_STKSZ;
254 break;
255#endif
256 default:
257 estacks += EXCEPTION_STKSZ;
258 break;
259 }
260 orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks; 253 orig_ist->ist[v] = t->ist[v] = (unsigned long)estacks;
261 } 254 }
262 255
@@ -290,4 +283,6 @@ void __cpuinit cpu_init (void)
290 set_debugreg(0UL, 7); 283 set_debugreg(0UL, 7);
291 284
292 fpu_init(); 285 fpu_init();
286
287 raw_local_save_flags(kernel_eflags);
293} 288}
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 28161170fb0a..49ec324cd141 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -38,37 +38,6 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
38 sigset_t *set, struct pt_regs * regs); 38 sigset_t *set, struct pt_regs * regs);
39 39
40asmlinkage long 40asmlinkage long
41sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize, struct pt_regs *regs)
42{
43 sigset_t saveset, newset;
44
45 /* XXX: Don't preclude handling different sized sigset_t's. */
46 if (sigsetsize != sizeof(sigset_t))
47 return -EINVAL;
48
49 if (copy_from_user(&newset, unewset, sizeof(newset)))
50 return -EFAULT;
51 sigdelsetmask(&newset, ~_BLOCKABLE);
52
53 spin_lock_irq(&current->sighand->siglock);
54 saveset = current->blocked;
55 current->blocked = newset;
56 recalc_sigpending();
57 spin_unlock_irq(&current->sighand->siglock);
58#ifdef DEBUG_SIG
59 printk("rt_sigsuspend savset(%lx) newset(%lx) regs(%p) rip(%lx)\n",
60 saveset, newset, regs, regs->rip);
61#endif
62 regs->rax = -EINTR;
63 while (1) {
64 current->state = TASK_INTERRUPTIBLE;
65 schedule();
66 if (do_signal(regs, &saveset))
67 return -EINTR;
68 }
69}
70
71asmlinkage long
72sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, 41sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
73 struct pt_regs *regs) 42 struct pt_regs *regs)
74{ 43{
@@ -308,11 +277,6 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
308#endif 277#endif
309 278
310 /* Set up registers for signal handler */ 279 /* Set up registers for signal handler */
311 {
312 struct exec_domain *ed = current_thread_info()->exec_domain;
313 if (unlikely(ed && ed->signal_invmap && sig < 32))
314 sig = ed->signal_invmap[sig];
315 }
316 regs->rdi = sig; 280 regs->rdi = sig;
317 /* In case the signal handler was declared without prototypes */ 281 /* In case the signal handler was declared without prototypes */
318 regs->rax = 0; 282 regs->rax = 0;
@@ -341,11 +305,11 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
341 current->comm, current->pid, frame, regs->rip, frame->pretcode); 305 current->comm, current->pid, frame, regs->rip, frame->pretcode);
342#endif 306#endif
343 307
344 return 1; 308 return 0;
345 309
346give_sigsegv: 310give_sigsegv:
347 force_sigsegv(sig, current); 311 force_sigsegv(sig, current);
348 return 0; 312 return -EFAULT;
349} 313}
350 314
351/* 315/*
@@ -408,7 +372,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
408#endif 372#endif
409 ret = setup_rt_frame(sig, ka, info, oldset, regs); 373 ret = setup_rt_frame(sig, ka, info, oldset, regs);
410 374
411 if (ret) { 375 if (ret == 0) {
412 spin_lock_irq(&current->sighand->siglock); 376 spin_lock_irq(&current->sighand->siglock);
413 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask); 377 sigorsets(&current->blocked,&current->blocked,&ka->sa.sa_mask);
414 if (!(ka->sa.sa_flags & SA_NODEFER)) 378 if (!(ka->sa.sa_flags & SA_NODEFER))
@@ -425,11 +389,12 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
425 * want to handle. Thus you cannot kill init even with a SIGKILL even by 389 * want to handle. Thus you cannot kill init even with a SIGKILL even by
426 * mistake. 390 * mistake.
427 */ 391 */
428int do_signal(struct pt_regs *regs, sigset_t *oldset) 392static void do_signal(struct pt_regs *regs)
429{ 393{
430 struct k_sigaction ka; 394 struct k_sigaction ka;
431 siginfo_t info; 395 siginfo_t info;
432 int signr; 396 int signr;
397 sigset_t *oldset;
433 398
434 /* 399 /*
435 * We want the common case to go fast, which 400 * We want the common case to go fast, which
@@ -438,9 +403,11 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
438 * if so. 403 * if so.
439 */ 404 */
440 if (!user_mode(regs)) 405 if (!user_mode(regs))
441 return 1; 406 return;
442 407
443 if (!oldset) 408 if (test_thread_flag(TIF_RESTORE_SIGMASK))
409 oldset = &current->saved_sigmask;
410 else
444 oldset = &current->blocked; 411 oldset = &current->blocked;
445 412
446 signr = get_signal_to_deliver(&info, &ka, regs, NULL); 413 signr = get_signal_to_deliver(&info, &ka, regs, NULL);
@@ -454,30 +421,46 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
454 set_debugreg(current->thread.debugreg7, 7); 421 set_debugreg(current->thread.debugreg7, 7);
455 422
456 /* Whee! Actually deliver the signal. */ 423 /* Whee! Actually deliver the signal. */
457 return handle_signal(signr, &info, &ka, oldset, regs); 424 if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
425 /* a signal was successfully delivered; the saved
426 * sigmask will have been stored in the signal frame,
427 * and will be restored by sigreturn, so we can simply
428 * clear the TIF_RESTORE_SIGMASK flag */
429 clear_thread_flag(TIF_RESTORE_SIGMASK);
430 }
431 return;
458 } 432 }
459 433
460 /* Did we come from a system call? */ 434 /* Did we come from a system call? */
461 if ((long)regs->orig_rax >= 0) { 435 if ((long)regs->orig_rax >= 0) {
462 /* Restart the system call - no handlers present */ 436 /* Restart the system call - no handlers present */
463 long res = regs->rax; 437 long res = regs->rax;
464 if (res == -ERESTARTNOHAND || 438 switch (res) {
465 res == -ERESTARTSYS || 439 case -ERESTARTNOHAND:
466 res == -ERESTARTNOINTR) { 440 case -ERESTARTSYS:
441 case -ERESTARTNOINTR:
467 regs->rax = regs->orig_rax; 442 regs->rax = regs->orig_rax;
468 regs->rip -= 2; 443 regs->rip -= 2;
469 } 444 break;
470 if (regs->rax == (unsigned long)-ERESTART_RESTARTBLOCK) { 445 case -ERESTART_RESTARTBLOCK:
471 regs->rax = test_thread_flag(TIF_IA32) ? 446 regs->rax = test_thread_flag(TIF_IA32) ?
472 __NR_ia32_restart_syscall : 447 __NR_ia32_restart_syscall :
473 __NR_restart_syscall; 448 __NR_restart_syscall;
474 regs->rip -= 2; 449 regs->rip -= 2;
450 break;
475 } 451 }
476 } 452 }
477 return 0; 453
454 /* if there's no signal to deliver, we just put the saved sigmask
455 back. */
456 if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
457 clear_thread_flag(TIF_RESTORE_SIGMASK);
458 sigprocmask(SIG_SETMASK, &current->saved_sigmask, NULL);
459 }
478} 460}
479 461
480void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, __u32 thread_info_flags) 462void
463do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
481{ 464{
482#ifdef DEBUG_SIG 465#ifdef DEBUG_SIG
483 printk("do_notify_resume flags:%x rip:%lx rsp:%lx caller:%lx pending:%lx\n", 466 printk("do_notify_resume flags:%x rip:%lx rsp:%lx caller:%lx pending:%lx\n",
@@ -491,8 +474,8 @@ void do_notify_resume(struct pt_regs *regs, sigset_t *oldset, __u32 thread_info_
491 } 474 }
492 475
493 /* deal with pending signal delivery */ 476 /* deal with pending signal delivery */
494 if (thread_info_flags & _TIF_SIGPENDING) 477 if (thread_info_flags & (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK))
495 do_signal(regs,oldset); 478 do_signal(regs);
496} 479}
497 480
498void signal_fault(struct pt_regs *regs, void __user *frame, char *where) 481void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 06af6ca60129..4f67697f5036 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -522,26 +522,3 @@ asmlinkage void smp_call_function_interrupt(void)
522 } 522 }
523} 523}
524 524
525int safe_smp_processor_id(void)
526{
527 unsigned apicid, i;
528
529 if (disable_apic)
530 return 0;
531
532 apicid = hard_smp_processor_id();
533 if (apicid < NR_CPUS && x86_cpu_to_apicid[apicid] == apicid)
534 return apicid;
535
536 for (i = 0; i < NR_CPUS; ++i) {
537 if (x86_cpu_to_apicid[i] == apicid)
538 return i;
539 }
540
541 /* No entries in x86_cpu_to_apicid? Either no MPS|ACPI,
542 * or called too early. Either way, we must be CPU 0. */
543 if (x86_cpu_to_apicid[0] == BAD_APICID)
544 return 0;
545
546 return 0; /* Should not happen */
547}
diff --git a/arch/x86_64/kernel/smpboot.c b/arch/x86_64/kernel/smpboot.c
index 3ae9ffddddc0..7b7a6870288a 100644
--- a/arch/x86_64/kernel/smpboot.c
+++ b/arch/x86_64/kernel/smpboot.c
@@ -1091,7 +1091,6 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
1091 /* 1091 /*
1092 * Switch from PIC to APIC mode. 1092 * Switch from PIC to APIC mode.
1093 */ 1093 */
1094 connect_bsp_APIC();
1095 setup_local_APIC(); 1094 setup_local_APIC();
1096 1095
1097 if (GET_APIC_ID(apic_read(APIC_ID)) != boot_cpu_id) { 1096 if (GET_APIC_ID(apic_read(APIC_ID)) != boot_cpu_id) {
@@ -1176,12 +1175,9 @@ int __cpuinit __cpu_up(unsigned int cpu)
1176void __init smp_cpus_done(unsigned int max_cpus) 1175void __init smp_cpus_done(unsigned int max_cpus)
1177{ 1176{
1178 smp_cleanup_boot(); 1177 smp_cleanup_boot();
1179
1180#ifdef CONFIG_X86_IO_APIC
1181 setup_ioapic_dest(); 1178 setup_ioapic_dest();
1182#endif
1183
1184 check_nmi_watchdog(); 1179 check_nmi_watchdog();
1180 time_init_gtod();
1185} 1181}
1186 1182
1187#ifdef CONFIG_HOTPLUG_CPU 1183#ifdef CONFIG_HOTPLUG_CPU
@@ -1234,6 +1230,8 @@ int __cpu_disable(void)
1234 if (cpu == 0) 1230 if (cpu == 0)
1235 return -EBUSY; 1231 return -EBUSY;
1236 1232
1233 if (nmi_watchdog == NMI_LOCAL_APIC)
1234 stop_apic_nmi_watchdog(NULL);
1237 clear_local_APIC(); 1235 clear_local_APIC();
1238 1236
1239 /* 1237 /*
@@ -1273,11 +1271,11 @@ void __cpu_die(unsigned int cpu)
1273 printk(KERN_ERR "CPU %u didn't die...\n", cpu); 1271 printk(KERN_ERR "CPU %u didn't die...\n", cpu);
1274} 1272}
1275 1273
1276__init int setup_additional_cpus(char *s) 1274static __init int setup_additional_cpus(char *s)
1277{ 1275{
1278 return get_option(&s, &additional_cpus); 1276 return s && get_option(&s, &additional_cpus) ? 0 : -EINVAL;
1279} 1277}
1280__setup("additional_cpus=", setup_additional_cpus); 1278early_param("additional_cpus", setup_additional_cpus);
1281 1279
1282#else /* ... !CONFIG_HOTPLUG_CPU */ 1280#else /* ... !CONFIG_HOTPLUG_CPU */
1283 1281
diff --git a/arch/x86_64/kernel/stacktrace.c b/arch/x86_64/kernel/stacktrace.c
index 32cf55eb9af8..6026b31d037e 100644
--- a/arch/x86_64/kernel/stacktrace.c
+++ b/arch/x86_64/kernel/stacktrace.c
@@ -7,215 +7,49 @@
7 */ 7 */
8#include <linux/sched.h> 8#include <linux/sched.h>
9#include <linux/stacktrace.h> 9#include <linux/stacktrace.h>
10#include <linux/module.h>
11#include <asm/stacktrace.h>
10 12
11#include <asm/smp.h> 13static void save_stack_warning(void *data, char *msg)
12
13static inline int
14in_range(unsigned long start, unsigned long addr, unsigned long end)
15{ 14{
16 return addr >= start && addr <= end;
17} 15}
18 16
19static unsigned long 17static void
20get_stack_end(struct task_struct *task, unsigned long stack) 18save_stack_warning_symbol(void *data, char *msg, unsigned long symbol)
21{ 19{
22 unsigned long stack_start, stack_end, flags;
23 int i, cpu;
24
25 /*
26 * The most common case is that we are in the task stack:
27 */
28 stack_start = (unsigned long)task->thread_info;
29 stack_end = stack_start + THREAD_SIZE;
30
31 if (in_range(stack_start, stack, stack_end))
32 return stack_end;
33
34 /*
35 * We are in an interrupt if irqstackptr is set:
36 */
37 raw_local_irq_save(flags);
38 cpu = safe_smp_processor_id();
39 stack_end = (unsigned long)cpu_pda(cpu)->irqstackptr;
40
41 if (stack_end) {
42 stack_start = stack_end & ~(IRQSTACKSIZE-1);
43 if (in_range(stack_start, stack, stack_end))
44 goto out_restore;
45 /*
46 * We get here if we are in an IRQ context but we
47 * are also in an exception stack.
48 */
49 }
50
51 /*
52 * Iterate over all exception stacks, and figure out whether
53 * 'stack' is in one of them:
54 */
55 for (i = 0; i < N_EXCEPTION_STACKS; i++) {
56 /*
57 * set 'end' to the end of the exception stack.
58 */
59 stack_end = per_cpu(init_tss, cpu).ist[i];
60 stack_start = stack_end - EXCEPTION_STKSZ;
61
62 /*
63 * Is 'stack' above this exception frame's end?
64 * If yes then skip to the next frame.
65 */
66 if (stack >= stack_end)
67 continue;
68 /*
69 * Is 'stack' above this exception frame's start address?
70 * If yes then we found the right frame.
71 */
72 if (stack >= stack_start)
73 goto out_restore;
74
75 /*
76 * If this is a debug stack, and if it has a larger size than
77 * the usual exception stacks, then 'stack' might still
78 * be within the lower portion of the debug stack:
79 */
80#if DEBUG_STKSZ > EXCEPTION_STKSZ
81 if (i == DEBUG_STACK - 1 && stack >= stack_end - DEBUG_STKSZ) {
82 /*
83 * Black magic. A large debug stack is composed of
84 * multiple exception stack entries, which we
85 * iterate through now. Dont look:
86 */
87 do {
88 stack_end -= EXCEPTION_STKSZ;
89 stack_start -= EXCEPTION_STKSZ;
90 } while (stack < stack_start);
91
92 goto out_restore;
93 }
94#endif
95 }
96 /*
97 * Ok, 'stack' is not pointing to any of the system stacks.
98 */
99 stack_end = 0;
100
101out_restore:
102 raw_local_irq_restore(flags);
103
104 return stack_end;
105} 20}
106 21
107 22static int save_stack_stack(void *data, char *name)
108/*
109 * Save stack-backtrace addresses into a stack_trace buffer:
110 */
111static inline unsigned long
112save_context_stack(struct stack_trace *trace, unsigned int skip,
113 unsigned long stack, unsigned long stack_end)
114{ 23{
115 unsigned long addr; 24 struct stack_trace *trace = (struct stack_trace *)data;
116 25 return trace->all_contexts ? 0 : -1;
117#ifdef CONFIG_FRAME_POINTER 26}
118 unsigned long prev_stack = 0;
119 27
120 while (in_range(prev_stack, stack, stack_end)) { 28static void save_stack_address(void *data, unsigned long addr)
121 pr_debug("stack: %p\n", (void *)stack); 29{
122 addr = (unsigned long)(((unsigned long *)stack)[1]); 30 struct stack_trace *trace = (struct stack_trace *)data;
123 pr_debug("addr: %p\n", (void *)addr); 31 if (trace->skip > 0) {
124 if (!skip) 32 trace->skip--;
125 trace->entries[trace->nr_entries++] = addr-1; 33 return;
126 else
127 skip--;
128 if (trace->nr_entries >= trace->max_entries)
129 break;
130 if (!addr)
131 return 0;
132 /*
133 * Stack frames must go forwards (otherwise a loop could
134 * happen if the stackframe is corrupted), so we move
135 * prev_stack forwards:
136 */
137 prev_stack = stack;
138 stack = (unsigned long)(((unsigned long *)stack)[0]);
139 }
140 pr_debug("invalid: %p\n", (void *)stack);
141#else
142 while (stack < stack_end) {
143 addr = ((unsigned long *)stack)[0];
144 stack += sizeof(long);
145 if (__kernel_text_address(addr)) {
146 if (!skip)
147 trace->entries[trace->nr_entries++] = addr-1;
148 else
149 skip--;
150 if (trace->nr_entries >= trace->max_entries)
151 break;
152 }
153 } 34 }
154#endif 35 if (trace->nr_entries < trace->max_entries - 1)
155 return stack; 36 trace->entries[trace->nr_entries++] = addr;
156} 37}
157 38
158#define MAX_STACKS 10 39static struct stacktrace_ops save_stack_ops = {
40 .warning = save_stack_warning,
41 .warning_symbol = save_stack_warning_symbol,
42 .stack = save_stack_stack,
43 .address = save_stack_address,
44};
159 45
160/* 46/*
161 * Save stack-backtrace addresses into a stack_trace buffer. 47 * Save stack-backtrace addresses into a stack_trace buffer.
162 * If all_contexts is set, all contexts (hardirq, softirq and process)
163 * are saved. If not set then only the current context is saved.
164 */ 48 */
165void save_stack_trace(struct stack_trace *trace, 49void save_stack_trace(struct stack_trace *trace, struct task_struct *task)
166 struct task_struct *task, int all_contexts,
167 unsigned int skip)
168{ 50{
169 unsigned long stack = (unsigned long)&stack; 51 dump_trace(task, NULL, NULL, &save_stack_ops, trace);
170 int i, nr_stacks = 0, stacks_done[MAX_STACKS]; 52 trace->entries[trace->nr_entries++] = ULONG_MAX;
171
172 WARN_ON(trace->nr_entries || !trace->max_entries);
173
174 if (!task)
175 task = current;
176
177 pr_debug("task: %p, ti: %p\n", task, task->thread_info);
178
179 if (!task || task == current) {
180 /* Grab rbp right from our regs: */
181 asm ("mov %%rbp, %0" : "=r" (stack));
182 pr_debug("rbp: %p\n", (void *)stack);
183 } else {
184 /* rbp is the last reg pushed by switch_to(): */
185 stack = task->thread.rsp;
186 pr_debug("other task rsp: %p\n", (void *)stack);
187 stack = (unsigned long)(((unsigned long *)stack)[0]);
188 pr_debug("other task rbp: %p\n", (void *)stack);
189 }
190
191 while (1) {
192 unsigned long stack_end = get_stack_end(task, stack);
193
194 pr_debug("stack: %p\n", (void *)stack);
195 pr_debug("stack end: %p\n", (void *)stack_end);
196
197 /*
198 * Invalid stack addres?
199 */
200 if (!stack_end)
201 return;
202 /*
203 * Were we in this stack already? (recursion)
204 */
205 for (i = 0; i < nr_stacks; i++)
206 if (stacks_done[i] == stack_end)
207 return;
208 stacks_done[nr_stacks] = stack_end;
209
210 stack = save_context_stack(trace, skip, stack, stack_end);
211 if (!all_contexts || !stack ||
212 trace->nr_entries >= trace->max_entries)
213 return;
214 trace->entries[trace->nr_entries++] = ULONG_MAX;
215 if (trace->nr_entries >= trace->max_entries)
216 return;
217 if (++nr_stacks >= MAX_STACKS)
218 return;
219 }
220} 53}
54EXPORT_SYMBOL(save_stack_trace);
221 55
diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
index 5530dda3f27a..cbabfdf78e06 100644
--- a/arch/x86_64/kernel/tce.c
+++ b/arch/x86_64/kernel/tce.c
@@ -1,4 +1,6 @@
1/* 1/*
2 * This file manages the translation entries for the IBM Calgary IOMMU.
3 *
2 * Derived from arch/powerpc/platforms/pseries/iommu.c 4 * Derived from arch/powerpc/platforms/pseries/iommu.c
3 * 5 *
4 * Copyright (C) IBM Corporation, 2006 6 * Copyright (C) IBM Corporation, 2006
@@ -104,14 +106,6 @@ static int tce_table_setparms(struct pci_dev *dev, struct iommu_table *tbl)
104 /* set the tce table size - measured in entries */ 106 /* set the tce table size - measured in entries */
105 tbl->it_size = table_size_to_number_of_entries(specified_table_size); 107 tbl->it_size = table_size_to_number_of_entries(specified_table_size);
106 108
107 tbl->it_base = (unsigned long)tce_table_kva[dev->bus->number];
108 if (!tbl->it_base) {
109 printk(KERN_ERR "Calgary: iommu_table_setparms: "
110 "no table allocated?!\n");
111 ret = -ENOMEM;
112 goto done;
113 }
114
115 /* 109 /*
116 * number of bytes needed for the bitmap size in number of 110 * number of bytes needed for the bitmap size in number of
117 * entries; we need one bit per entry 111 * entries; we need one bit per entry
@@ -160,8 +154,6 @@ int build_tce_table(struct pci_dev *dev, void __iomem *bbar)
160 if (ret) 154 if (ret)
161 goto free_tbl; 155 goto free_tbl;
162 156
163 tce_free(tbl, 0, tbl->it_size);
164
165 tbl->bbar = bbar; 157 tbl->bbar = bbar;
166 158
167 /* 159 /*
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 7700e6cd2bd9..1c255ee76e7c 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -24,6 +24,8 @@
24#include <linux/device.h> 24#include <linux/device.h>
25#include <linux/sysdev.h> 25#include <linux/sysdev.h>
26#include <linux/bcd.h> 26#include <linux/bcd.h>
27#include <linux/notifier.h>
28#include <linux/cpu.h>
27#include <linux/kallsyms.h> 29#include <linux/kallsyms.h>
28#include <linux/acpi.h> 30#include <linux/acpi.h>
29#ifdef CONFIG_ACPI 31#ifdef CONFIG_ACPI
@@ -39,9 +41,7 @@
39#include <asm/sections.h> 41#include <asm/sections.h>
40#include <linux/cpufreq.h> 42#include <linux/cpufreq.h>
41#include <linux/hpet.h> 43#include <linux/hpet.h>
42#ifdef CONFIG_X86_LOCAL_APIC
43#include <asm/apic.h> 44#include <asm/apic.h>
44#endif
45 45
46#ifdef CONFIG_CPU_FREQ 46#ifdef CONFIG_CPU_FREQ
47static void cpufreq_delayed_get(void); 47static void cpufreq_delayed_get(void);
@@ -49,7 +49,7 @@ static void cpufreq_delayed_get(void);
49extern void i8254_timer_resume(void); 49extern void i8254_timer_resume(void);
50extern int using_apic_timer; 50extern int using_apic_timer;
51 51
52static char *time_init_gtod(void); 52static char *timename = NULL;
53 53
54DEFINE_SPINLOCK(rtc_lock); 54DEFINE_SPINLOCK(rtc_lock);
55EXPORT_SYMBOL(rtc_lock); 55EXPORT_SYMBOL(rtc_lock);
@@ -187,20 +187,15 @@ unsigned long profile_pc(struct pt_regs *regs)
187{ 187{
188 unsigned long pc = instruction_pointer(regs); 188 unsigned long pc = instruction_pointer(regs);
189 189
190 /* Assume the lock function has either no stack frame or only a single 190 /* Assume the lock function has either no stack frame or a copy
191 word. This checks if the address on the stack looks like a kernel 191 of eflags from PUSHF
192 text address. 192 Eflags always has bits 22 and up cleared unlike kernel addresses. */
193 There is a small window for false hits, but in that case the tick
194 is just accounted to the spinlock function.
195 Better would be to write these functions in assembler again
196 and check exactly. */
197 if (!user_mode(regs) && in_lock_functions(pc)) { 193 if (!user_mode(regs) && in_lock_functions(pc)) {
198 char *v = *(char **)regs->rsp; 194 unsigned long *sp = (unsigned long *)regs->rsp;
199 if ((v >= _stext && v <= _etext) || 195 if (sp[0] >> 22)
200 (v >= _sinittext && v <= _einittext) || 196 return sp[0];
201 (v >= (char *)MODULES_VADDR && v <= (char *)MODULES_END)) 197 if (sp[1] >> 22)
202 return (unsigned long)v; 198 return sp[1];
203 return ((unsigned long *)regs->rsp)[1];
204 } 199 }
205 return pc; 200 return pc;
206} 201}
@@ -281,6 +276,7 @@ static void set_rtc_mmss(unsigned long nowtime)
281 * Note: This function is required to return accurate 276 * Note: This function is required to return accurate
282 * time even in the absence of multiple timer ticks. 277 * time even in the absence of multiple timer ticks.
283 */ 278 */
279static inline unsigned long long cycles_2_ns(unsigned long long cyc);
284unsigned long long monotonic_clock(void) 280unsigned long long monotonic_clock(void)
285{ 281{
286 unsigned long seq; 282 unsigned long seq;
@@ -305,8 +301,7 @@ unsigned long long monotonic_clock(void)
305 base = monotonic_base; 301 base = monotonic_base;
306 } while (read_seqretry(&xtime_lock, seq)); 302 } while (read_seqretry(&xtime_lock, seq));
307 this_offset = get_cycles_sync(); 303 this_offset = get_cycles_sync();
308 /* FIXME: 1000 or 1000000? */ 304 offset = cycles_2_ns(this_offset - last_offset);
309 offset = (this_offset - last_offset)*1000 / cpu_khz;
310 } 305 }
311 return base + offset; 306 return base + offset;
312} 307}
@@ -410,8 +405,7 @@ void main_timer_handler(struct pt_regs *regs)
410 offset %= USEC_PER_TICK; 405 offset %= USEC_PER_TICK;
411 } 406 }
412 407
413 /* FIXME: 1000 or 1000000? */ 408 monotonic_base += cycles_2_ns(tsc - vxtime.last_tsc);
414 monotonic_base += (tsc - vxtime.last_tsc) * 1000000 / cpu_khz;
415 409
416 vxtime.last_tsc = tsc - vxtime.quot * delay / vxtime.tsc_quot; 410 vxtime.last_tsc = tsc - vxtime.quot * delay / vxtime.tsc_quot;
417 411
@@ -441,12 +435,8 @@ void main_timer_handler(struct pt_regs *regs)
441 * have to call the local interrupt handler. 435 * have to call the local interrupt handler.
442 */ 436 */
443 437
444#ifndef CONFIG_X86_LOCAL_APIC
445 profile_tick(CPU_PROFILING, regs);
446#else
447 if (!using_apic_timer) 438 if (!using_apic_timer)
448 smp_local_timer_interrupt(regs); 439 smp_local_timer_interrupt(regs);
449#endif
450 440
451/* 441/*
452 * If we have an externally synchronized Linux clock, then update CMOS clock 442 * If we have an externally synchronized Linux clock, then update CMOS clock
@@ -470,10 +460,8 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
470 if (apic_runs_main_timer > 1) 460 if (apic_runs_main_timer > 1)
471 return IRQ_HANDLED; 461 return IRQ_HANDLED;
472 main_timer_handler(regs); 462 main_timer_handler(regs);
473#ifdef CONFIG_X86_LOCAL_APIC
474 if (using_apic_timer) 463 if (using_apic_timer)
475 smp_send_timer_broadcast_ipi(); 464 smp_send_timer_broadcast_ipi();
476#endif
477 return IRQ_HANDLED; 465 return IRQ_HANDLED;
478} 466}
479 467
@@ -893,11 +881,17 @@ static struct irqaction irq0 = {
893 timer_interrupt, IRQF_DISABLED, CPU_MASK_NONE, "timer", NULL, NULL 881 timer_interrupt, IRQF_DISABLED, CPU_MASK_NONE, "timer", NULL, NULL
894}; 882};
895 883
896void __init time_init(void) 884static int __cpuinit
885time_cpu_notifier(struct notifier_block *nb, unsigned long action, void *hcpu)
897{ 886{
898 char *timename; 887 unsigned cpu = (unsigned long) hcpu;
899 char *gtod; 888 if (action == CPU_ONLINE)
889 vsyscall_set_cpu(cpu);
890 return NOTIFY_DONE;
891}
900 892
893void __init time_init(void)
894{
901 if (nohpet) 895 if (nohpet)
902 vxtime.hpet_address = 0; 896 vxtime.hpet_address = 0;
903 897
@@ -931,18 +925,17 @@ void __init time_init(void)
931 } 925 }
932 926
933 vxtime.mode = VXTIME_TSC; 927 vxtime.mode = VXTIME_TSC;
934 gtod = time_init_gtod();
935
936 printk(KERN_INFO "time.c: Using %ld.%06ld MHz WALL %s GTOD %s timer.\n",
937 vxtime_hz / 1000000, vxtime_hz % 1000000, timename, gtod);
938 printk(KERN_INFO "time.c: Detected %d.%03d MHz processor.\n",
939 cpu_khz / 1000, cpu_khz % 1000);
940 vxtime.quot = (USEC_PER_SEC << US_SCALE) / vxtime_hz; 928 vxtime.quot = (USEC_PER_SEC << US_SCALE) / vxtime_hz;
941 vxtime.tsc_quot = (USEC_PER_MSEC << US_SCALE) / cpu_khz; 929 vxtime.tsc_quot = (USEC_PER_MSEC << US_SCALE) / cpu_khz;
942 vxtime.last_tsc = get_cycles_sync(); 930 vxtime.last_tsc = get_cycles_sync();
931 set_cyc2ns_scale(cpu_khz);
943 setup_irq(0, &irq0); 932 setup_irq(0, &irq0);
933 hotcpu_notifier(time_cpu_notifier, 0);
934 time_cpu_notifier(NULL, CPU_ONLINE, (void *)(long)smp_processor_id());
944 935
945 set_cyc2ns_scale(cpu_khz); 936#ifndef CONFIG_SMP
937 time_init_gtod();
938#endif
946} 939}
947 940
948/* 941/*
@@ -973,12 +966,18 @@ __cpuinit int unsynchronized_tsc(void)
973/* 966/*
974 * Decide what mode gettimeofday should use. 967 * Decide what mode gettimeofday should use.
975 */ 968 */
976__init static char *time_init_gtod(void) 969void time_init_gtod(void)
977{ 970{
978 char *timetype; 971 char *timetype;
979 972
980 if (unsynchronized_tsc()) 973 if (unsynchronized_tsc())
981 notsc = 1; 974 notsc = 1;
975
976 if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
977 vgetcpu_mode = VGETCPU_RDTSCP;
978 else
979 vgetcpu_mode = VGETCPU_LSL;
980
982 if (vxtime.hpet_address && notsc) { 981 if (vxtime.hpet_address && notsc) {
983 timetype = hpet_use_timer ? "HPET" : "PIT/HPET"; 982 timetype = hpet_use_timer ? "HPET" : "PIT/HPET";
984 if (hpet_use_timer) 983 if (hpet_use_timer)
@@ -1001,7 +1000,16 @@ __init static char *time_init_gtod(void)
1001 timetype = hpet_use_timer ? "HPET/TSC" : "PIT/TSC"; 1000 timetype = hpet_use_timer ? "HPET/TSC" : "PIT/TSC";
1002 vxtime.mode = VXTIME_TSC; 1001 vxtime.mode = VXTIME_TSC;
1003 } 1002 }
1004 return timetype; 1003
1004 printk(KERN_INFO "time.c: Using %ld.%06ld MHz WALL %s GTOD %s timer.\n",
1005 vxtime_hz / 1000000, vxtime_hz % 1000000, timename, timetype);
1006 printk(KERN_INFO "time.c: Detected %d.%03d MHz processor.\n",
1007 cpu_khz / 1000, cpu_khz % 1000);
1008 vxtime.quot = (USEC_PER_SEC << US_SCALE) / vxtime_hz;
1009 vxtime.tsc_quot = (USEC_PER_MSEC << US_SCALE) / cpu_khz;
1010 vxtime.last_tsc = get_cycles_sync();
1011
1012 set_cyc2ns_scale(cpu_khz);
1005} 1013}
1006 1014
1007__setup("report_lost_ticks", time_setup); 1015__setup("report_lost_ticks", time_setup);
@@ -1031,8 +1039,16 @@ static int timer_resume(struct sys_device *dev)
1031 unsigned long flags; 1039 unsigned long flags;
1032 unsigned long sec; 1040 unsigned long sec;
1033 unsigned long ctime = get_cmos_time(); 1041 unsigned long ctime = get_cmos_time();
1034 unsigned long sleep_length = (ctime - sleep_start) * HZ; 1042 long sleep_length = (ctime - sleep_start) * HZ;
1035 1043
1044 if (sleep_length < 0) {
1045 printk(KERN_WARNING "Time skew detected in timer resume!\n");
1046 /* The time after the resume must not be earlier than the time
1047 * before the suspend or some nasty things will happen
1048 */
1049 sleep_length = 0;
1050 ctime = sleep_start;
1051 }
1036 if (vxtime.hpet_address) 1052 if (vxtime.hpet_address)
1037 hpet_reenable(); 1053 hpet_reenable();
1038 else 1054 else
diff --git a/arch/x86_64/kernel/trampoline.S b/arch/x86_64/kernel/trampoline.S
index 23a03eb91fc7..c79b99a9e2f6 100644
--- a/arch/x86_64/kernel/trampoline.S
+++ b/arch/x86_64/kernel/trampoline.S
@@ -64,7 +64,7 @@ idt_48:
64 .word 0, 0 # idt base = 0L 64 .word 0, 0 # idt base = 0L
65 65
66gdt_48: 66gdt_48:
67 .short __KERNEL32_CS + 7 # gdt limit 67 .short GDT_ENTRIES*8 - 1 # gdt limit
68 .long cpu_gdt_table-__START_KERNEL_map 68 .long cpu_gdt_table-__START_KERNEL_map
69 69
70.globl trampoline_end 70.globl trampoline_end
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index b1249774d1e8..01f2a8d254c2 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -45,6 +45,7 @@
45#include <asm/pda.h> 45#include <asm/pda.h>
46#include <asm/proto.h> 46#include <asm/proto.h>
47#include <asm/nmi.h> 47#include <asm/nmi.h>
48#include <asm/stacktrace.h>
48 49
49asmlinkage void divide_error(void); 50asmlinkage void divide_error(void);
50asmlinkage void debug(void); 51asmlinkage void debug(void);
@@ -142,7 +143,7 @@ void printk_address(unsigned long address)
142#endif 143#endif
143 144
144static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack, 145static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
145 unsigned *usedp, const char **idp) 146 unsigned *usedp, char **idp)
146{ 147{
147 static char ids[][8] = { 148 static char ids[][8] = {
148 [DEBUG_STACK - 1] = "#DB", 149 [DEBUG_STACK - 1] = "#DB",
@@ -161,26 +162,7 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
161 * 'stack' is in one of them: 162 * 'stack' is in one of them:
162 */ 163 */
163 for (k = 0; k < N_EXCEPTION_STACKS; k++) { 164 for (k = 0; k < N_EXCEPTION_STACKS; k++) {
164 unsigned long end; 165 unsigned long end = per_cpu(orig_ist, cpu).ist[k];
165
166 /*
167 * set 'end' to the end of the exception stack.
168 */
169 switch (k + 1) {
170 /*
171 * TODO: this block is not needed i think, because
172 * setup64.c:cpu_init() sets up t->ist[DEBUG_STACK]
173 * properly too.
174 */
175#if DEBUG_STKSZ > EXCEPTION_STKSZ
176 case DEBUG_STACK:
177 end = cpu_pda(cpu)->debugstack + DEBUG_STKSZ;
178 break;
179#endif
180 default:
181 end = per_cpu(orig_ist, cpu).ist[k];
182 break;
183 }
184 /* 166 /*
185 * Is 'stack' above this exception frame's end? 167 * Is 'stack' above this exception frame's end?
186 * If yes then skip to the next frame. 168 * If yes then skip to the next frame.
@@ -234,13 +216,19 @@ static unsigned long *in_exception_stack(unsigned cpu, unsigned long stack,
234 return NULL; 216 return NULL;
235} 217}
236 218
237static int show_trace_unwind(struct unwind_frame_info *info, void *context) 219struct ops_and_data {
220 struct stacktrace_ops *ops;
221 void *data;
222};
223
224static int dump_trace_unwind(struct unwind_frame_info *info, void *context)
238{ 225{
226 struct ops_and_data *oad = (struct ops_and_data *)context;
239 int n = 0; 227 int n = 0;
240 228
241 while (unwind(info) == 0 && UNW_PC(info)) { 229 while (unwind(info) == 0 && UNW_PC(info)) {
242 n++; 230 n++;
243 printk_address(UNW_PC(info)); 231 oad->ops->address(oad->data, UNW_PC(info));
244 if (arch_unw_user_mode(info)) 232 if (arch_unw_user_mode(info))
245 break; 233 break;
246 } 234 }
@@ -254,45 +242,53 @@ static int show_trace_unwind(struct unwind_frame_info *info, void *context)
254 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack 242 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
255 */ 243 */
256 244
257void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack) 245void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * stack,
246 struct stacktrace_ops *ops, void *data)
258{ 247{
259 const unsigned cpu = safe_smp_processor_id(); 248 const unsigned cpu = smp_processor_id();
260 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr; 249 unsigned long *irqstack_end = (unsigned long *)cpu_pda(cpu)->irqstackptr;
261 unsigned used = 0; 250 unsigned used = 0;
262 251
263 printk("\nCall Trace:\n");
264
265 if (!tsk) 252 if (!tsk)
266 tsk = current; 253 tsk = current;
267 254
268 if (call_trace >= 0) { 255 if (call_trace >= 0) {
269 int unw_ret = 0; 256 int unw_ret = 0;
270 struct unwind_frame_info info; 257 struct unwind_frame_info info;
258 struct ops_and_data oad = { .ops = ops, .data = data };
271 259
272 if (regs) { 260 if (regs) {
273 if (unwind_init_frame_info(&info, tsk, regs) == 0) 261 if (unwind_init_frame_info(&info, tsk, regs) == 0)
274 unw_ret = show_trace_unwind(&info, NULL); 262 unw_ret = dump_trace_unwind(&info, &oad);
275 } else if (tsk == current) 263 } else if (tsk == current)
276 unw_ret = unwind_init_running(&info, show_trace_unwind, NULL); 264 unw_ret = unwind_init_running(&info, dump_trace_unwind, &oad);
277 else { 265 else {
278 if (unwind_init_blocked(&info, tsk) == 0) 266 if (unwind_init_blocked(&info, tsk) == 0)
279 unw_ret = show_trace_unwind(&info, NULL); 267 unw_ret = dump_trace_unwind(&info, &oad);
280 } 268 }
281 if (unw_ret > 0) { 269 if (unw_ret > 0) {
282 if (call_trace == 1 && !arch_unw_user_mode(&info)) { 270 if (call_trace == 1 && !arch_unw_user_mode(&info)) {
283 print_symbol("DWARF2 unwinder stuck at %s\n", 271 ops->warning_symbol(data, "DWARF2 unwinder stuck at %s\n",
284 UNW_PC(&info)); 272 UNW_PC(&info));
285 if ((long)UNW_SP(&info) < 0) { 273 if ((long)UNW_SP(&info) < 0) {
286 printk("Leftover inexact backtrace:\n"); 274 ops->warning(data, "Leftover inexact backtrace:\n");
287 stack = (unsigned long *)UNW_SP(&info); 275 stack = (unsigned long *)UNW_SP(&info);
276 if (!stack)
277 return;
288 } else 278 } else
289 printk("Full inexact backtrace again:\n"); 279 ops->warning(data, "Full inexact backtrace again:\n");
290 } else if (call_trace >= 1) 280 } else if (call_trace >= 1)
291 return; 281 return;
292 else 282 else
293 printk("Full inexact backtrace again:\n"); 283 ops->warning(data, "Full inexact backtrace again:\n");
294 } else 284 } else
295 printk("Inexact backtrace:\n"); 285 ops->warning(data, "Inexact backtrace:\n");
286 }
287 if (!stack) {
288 unsigned long dummy;
289 stack = &dummy;
290 if (tsk && tsk != current)
291 stack = (unsigned long *)tsk->thread.rsp;
296 } 292 }
297 293
298 /* 294 /*
@@ -303,7 +299,9 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
303#define HANDLE_STACK(cond) \ 299#define HANDLE_STACK(cond) \
304 do while (cond) { \ 300 do while (cond) { \
305 unsigned long addr = *stack++; \ 301 unsigned long addr = *stack++; \
306 if (kernel_text_address(addr)) { \ 302 if (oops_in_progress ? \
303 __kernel_text_address(addr) : \
304 kernel_text_address(addr)) { \
307 /* \ 305 /* \
308 * If the address is either in the text segment of the \ 306 * If the address is either in the text segment of the \
309 * kernel, or in the region which contains vmalloc'ed \ 307 * kernel, or in the region which contains vmalloc'ed \
@@ -312,7 +310,7 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
312 * down the cause of the crash will be able to figure \ 310 * down the cause of the crash will be able to figure \
313 * out the call path that was taken. \ 311 * out the call path that was taken. \
314 */ \ 312 */ \
315 printk_address(addr); \ 313 ops->address(data, addr); \
316 } \ 314 } \
317 } while (0) 315 } while (0)
318 316
@@ -321,16 +319,17 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
321 * current stack address. If the stacks consist of nested 319 * current stack address. If the stacks consist of nested
322 * exceptions 320 * exceptions
323 */ 321 */
324 for ( ; ; ) { 322 for (;;) {
325 const char *id; 323 char *id;
326 unsigned long *estack_end; 324 unsigned long *estack_end;
327 estack_end = in_exception_stack(cpu, (unsigned long)stack, 325 estack_end = in_exception_stack(cpu, (unsigned long)stack,
328 &used, &id); 326 &used, &id);
329 327
330 if (estack_end) { 328 if (estack_end) {
331 printk(" <%s>", id); 329 if (ops->stack(data, id) < 0)
330 break;
332 HANDLE_STACK (stack < estack_end); 331 HANDLE_STACK (stack < estack_end);
333 printk(" <EOE>"); 332 ops->stack(data, "<EOE>");
334 /* 333 /*
335 * We link to the next stack via the 334 * We link to the next stack via the
336 * second-to-last pointer (index -2 to end) in the 335 * second-to-last pointer (index -2 to end) in the
@@ -345,7 +344,8 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
345 (IRQSTACKSIZE - 64) / sizeof(*irqstack); 344 (IRQSTACKSIZE - 64) / sizeof(*irqstack);
346 345
347 if (stack >= irqstack && stack < irqstack_end) { 346 if (stack >= irqstack && stack < irqstack_end) {
348 printk(" <IRQ>"); 347 if (ops->stack(data, "IRQ") < 0)
348 break;
349 HANDLE_STACK (stack < irqstack_end); 349 HANDLE_STACK (stack < irqstack_end);
350 /* 350 /*
351 * We link to the next stack (which would be 351 * We link to the next stack (which would be
@@ -354,7 +354,7 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
354 */ 354 */
355 stack = (unsigned long *) (irqstack_end[-1]); 355 stack = (unsigned long *) (irqstack_end[-1]);
356 irqstack_end = NULL; 356 irqstack_end = NULL;
357 printk(" <EOI>"); 357 ops->stack(data, "EOI");
358 continue; 358 continue;
359 } 359 }
360 } 360 }
@@ -362,19 +362,57 @@ void show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long * s
362 } 362 }
363 363
364 /* 364 /*
365 * This prints the process stack: 365 * This handles the process stack:
366 */ 366 */
367 HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0); 367 HANDLE_STACK (((long) stack & (THREAD_SIZE-1)) != 0);
368#undef HANDLE_STACK 368#undef HANDLE_STACK
369}
370EXPORT_SYMBOL(dump_trace);
371
372static void
373print_trace_warning_symbol(void *data, char *msg, unsigned long symbol)
374{
375 print_symbol(msg, symbol);
376 printk("\n");
377}
378
379static void print_trace_warning(void *data, char *msg)
380{
381 printk("%s\n", msg);
382}
383
384static int print_trace_stack(void *data, char *name)
385{
386 printk(" <%s> ", name);
387 return 0;
388}
389
390static void print_trace_address(void *data, unsigned long addr)
391{
392 printk_address(addr);
393}
394
395static struct stacktrace_ops print_trace_ops = {
396 .warning = print_trace_warning,
397 .warning_symbol = print_trace_warning_symbol,
398 .stack = print_trace_stack,
399 .address = print_trace_address,
400};
369 401
402void
403show_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack)
404{
405 printk("\nCall Trace:\n");
406 dump_trace(tsk, regs, stack, &print_trace_ops, NULL);
370 printk("\n"); 407 printk("\n");
371} 408}
372 409
373static void _show_stack(struct task_struct *tsk, struct pt_regs *regs, unsigned long * rsp) 410static void
411_show_stack(struct task_struct *tsk, struct pt_regs *regs, unsigned long *rsp)
374{ 412{
375 unsigned long *stack; 413 unsigned long *stack;
376 int i; 414 int i;
377 const int cpu = safe_smp_processor_id(); 415 const int cpu = smp_processor_id();
378 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr); 416 unsigned long *irqstack_end = (unsigned long *) (cpu_pda(cpu)->irqstackptr);
379 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE); 417 unsigned long *irqstack = (unsigned long *) (cpu_pda(cpu)->irqstackptr - IRQSTACKSIZE);
380 418
@@ -428,7 +466,7 @@ void show_registers(struct pt_regs *regs)
428 int i; 466 int i;
429 int in_kernel = !user_mode(regs); 467 int in_kernel = !user_mode(regs);
430 unsigned long rsp; 468 unsigned long rsp;
431 const int cpu = safe_smp_processor_id(); 469 const int cpu = smp_processor_id();
432 struct task_struct *cur = cpu_pda(cpu)->pcurrent; 470 struct task_struct *cur = cpu_pda(cpu)->pcurrent;
433 471
434 rsp = regs->rsp; 472 rsp = regs->rsp;
@@ -503,9 +541,11 @@ static unsigned int die_nest_count;
503 541
504unsigned __kprobes long oops_begin(void) 542unsigned __kprobes long oops_begin(void)
505{ 543{
506 int cpu = safe_smp_processor_id(); 544 int cpu = smp_processor_id();
507 unsigned long flags; 545 unsigned long flags;
508 546
547 oops_enter();
548
509 /* racy, but better than risking deadlock. */ 549 /* racy, but better than risking deadlock. */
510 local_irq_save(flags); 550 local_irq_save(flags);
511 if (!spin_trylock(&die_lock)) { 551 if (!spin_trylock(&die_lock)) {
@@ -534,6 +574,7 @@ void __kprobes oops_end(unsigned long flags)
534 spin_unlock_irqrestore(&die_lock, flags); 574 spin_unlock_irqrestore(&die_lock, flags);
535 if (panic_on_oops) 575 if (panic_on_oops)
536 panic("Fatal exception"); 576 panic("Fatal exception");
577 oops_exit();
537} 578}
538 579
539void __kprobes __die(const char * str, struct pt_regs * regs, long err) 580void __kprobes __die(const char * str, struct pt_regs * regs, long err)
@@ -570,7 +611,7 @@ void die(const char * str, struct pt_regs * regs, long err)
570 do_exit(SIGSEGV); 611 do_exit(SIGSEGV);
571} 612}
572 613
573void __kprobes die_nmi(char *str, struct pt_regs *regs) 614void __kprobes die_nmi(char *str, struct pt_regs *regs, int do_panic)
574{ 615{
575 unsigned long flags = oops_begin(); 616 unsigned long flags = oops_begin();
576 617
@@ -578,13 +619,12 @@ void __kprobes die_nmi(char *str, struct pt_regs *regs)
578 * We are in trouble anyway, lets at least try 619 * We are in trouble anyway, lets at least try
579 * to get a message out. 620 * to get a message out.
580 */ 621 */
581 printk(str, safe_smp_processor_id()); 622 printk(str, smp_processor_id());
582 show_registers(regs); 623 show_registers(regs);
583 if (kexec_should_crash(current)) 624 if (kexec_should_crash(current))
584 crash_kexec(regs); 625 crash_kexec(regs);
585 if (panic_on_timeout || panic_on_oops) 626 if (do_panic || panic_on_oops)
586 panic("nmi watchdog"); 627 panic("Non maskable interrupt");
587 printk("console shuts up ...\n");
588 oops_end(flags); 628 oops_end(flags);
589 nmi_exit(); 629 nmi_exit();
590 local_irq_enable(); 630 local_irq_enable();
@@ -730,8 +770,15 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
730static __kprobes void 770static __kprobes void
731mem_parity_error(unsigned char reason, struct pt_regs * regs) 771mem_parity_error(unsigned char reason, struct pt_regs * regs)
732{ 772{
733 printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); 773 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
734 printk("You probably have a hardware problem with your RAM chips\n"); 774 reason);
775 printk(KERN_EMERG "You probably have a hardware problem with your "
776 "RAM chips\n");
777
778 if (panic_on_unrecovered_nmi)
779 panic("NMI: Not continuing");
780
781 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
735 782
736 /* Clear and disable the memory parity error line. */ 783 /* Clear and disable the memory parity error line. */
737 reason = (reason & 0xf) | 4; 784 reason = (reason & 0xf) | 4;
@@ -754,9 +801,15 @@ io_check_error(unsigned char reason, struct pt_regs * regs)
754 801
755static __kprobes void 802static __kprobes void
756unknown_nmi_error(unsigned char reason, struct pt_regs * regs) 803unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
757{ printk("Uhhuh. NMI received for unknown reason %02x.\n", reason); 804{
758 printk("Dazed and confused, but trying to continue\n"); 805 printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
759 printk("Do you have a strange power saving mode enabled?\n"); 806 reason);
807 printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
808
809 if (panic_on_unrecovered_nmi)
810 panic("NMI: Not continuing");
811
812 printk(KERN_EMERG "Dazed and confused, but trying to continue\n");
760} 813}
761 814
762/* Runs on IST stack. This code must keep interrupts off all the time. 815/* Runs on IST stack. This code must keep interrupts off all the time.
@@ -776,17 +829,15 @@ asmlinkage __kprobes void default_do_nmi(struct pt_regs *regs)
776 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT) 829 if (notify_die(DIE_NMI_IPI, "nmi_ipi", regs, reason, 2, SIGINT)
777 == NOTIFY_STOP) 830 == NOTIFY_STOP)
778 return; 831 return;
779#ifdef CONFIG_X86_LOCAL_APIC
780 /* 832 /*
781 * Ok, so this is none of the documented NMI sources, 833 * Ok, so this is none of the documented NMI sources,
782 * so it must be the NMI watchdog. 834 * so it must be the NMI watchdog.
783 */ 835 */
784 if (nmi_watchdog > 0) { 836 if (nmi_watchdog_tick(regs,reason))
785 nmi_watchdog_tick(regs,reason);
786 return; 837 return;
787 } 838 if (!do_nmi_callback(regs,cpu))
788#endif 839 unknown_nmi_error(reason, regs);
789 unknown_nmi_error(reason, regs); 840
790 return; 841 return;
791 } 842 }
792 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP) 843 if (notify_die(DIE_NMI, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
@@ -1071,6 +1122,7 @@ asmlinkage void math_state_restore(void)
1071 init_fpu(me); 1122 init_fpu(me);
1072 restore_fpu_checking(&me->thread.i387.fxsave); 1123 restore_fpu_checking(&me->thread.i387.fxsave);
1073 task_thread_info(me)->status |= TS_USEDFPU; 1124 task_thread_info(me)->status |= TS_USEDFPU;
1125 me->fpu_counter++;
1074} 1126}
1075 1127
1076void __init trap_init(void) 1128void __init trap_init(void)
@@ -1109,24 +1161,30 @@ void __init trap_init(void)
1109} 1161}
1110 1162
1111 1163
1112/* Actual parsing is done early in setup.c. */ 1164static int __init oops_setup(char *s)
1113static int __init oops_dummy(char *s)
1114{ 1165{
1115 panic_on_oops = 1; 1166 if (!s)
1116 return 1; 1167 return -EINVAL;
1168 if (!strcmp(s, "panic"))
1169 panic_on_oops = 1;
1170 return 0;
1117} 1171}
1118__setup("oops=", oops_dummy); 1172early_param("oops", oops_setup);
1119 1173
1120static int __init kstack_setup(char *s) 1174static int __init kstack_setup(char *s)
1121{ 1175{
1176 if (!s)
1177 return -EINVAL;
1122 kstack_depth_to_print = simple_strtoul(s,NULL,0); 1178 kstack_depth_to_print = simple_strtoul(s,NULL,0);
1123 return 1; 1179 return 0;
1124} 1180}
1125__setup("kstack=", kstack_setup); 1181early_param("kstack", kstack_setup);
1126 1182
1127#ifdef CONFIG_STACK_UNWIND 1183#ifdef CONFIG_STACK_UNWIND
1128static int __init call_trace_setup(char *s) 1184static int __init call_trace_setup(char *s)
1129{ 1185{
1186 if (!s)
1187 return -EINVAL;
1130 if (strcmp(s, "old") == 0) 1188 if (strcmp(s, "old") == 0)
1131 call_trace = -1; 1189 call_trace = -1;
1132 else if (strcmp(s, "both") == 0) 1190 else if (strcmp(s, "both") == 0)
@@ -1135,7 +1193,7 @@ static int __init call_trace_setup(char *s)
1135 call_trace = 1; 1193 call_trace = 1;
1136 else if (strcmp(s, "new") == 0) 1194 else if (strcmp(s, "new") == 0)
1137 call_trace = 2; 1195 call_trace = 2;
1138 return 1; 1196 return 0;
1139} 1197}
1140__setup("call_trace=", call_trace_setup); 1198early_param("call_trace", call_trace_setup);
1141#endif 1199#endif
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 7c4de31471d4..d0564f1bcb0b 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -13,6 +13,12 @@ OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
13OUTPUT_ARCH(i386:x86-64) 13OUTPUT_ARCH(i386:x86-64)
14ENTRY(phys_startup_64) 14ENTRY(phys_startup_64)
15jiffies_64 = jiffies; 15jiffies_64 = jiffies;
16PHDRS {
17 text PT_LOAD FLAGS(5); /* R_E */
18 data PT_LOAD FLAGS(7); /* RWE */
19 user PT_LOAD FLAGS(7); /* RWE */
20 note PT_NOTE FLAGS(4); /* R__ */
21}
16SECTIONS 22SECTIONS
17{ 23{
18 . = __START_KERNEL; 24 . = __START_KERNEL;
@@ -31,7 +37,7 @@ SECTIONS
31 KPROBES_TEXT 37 KPROBES_TEXT
32 *(.fixup) 38 *(.fixup)
33 *(.gnu.warning) 39 *(.gnu.warning)
34 } = 0x9090 40 } :text = 0x9090
35 /* out-of-line lock text */ 41 /* out-of-line lock text */
36 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) } 42 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) { *(.text.lock) }
37 43
@@ -57,7 +63,7 @@ SECTIONS
57 .data : AT(ADDR(.data) - LOAD_OFFSET) { 63 .data : AT(ADDR(.data) - LOAD_OFFSET) {
58 *(.data) 64 *(.data)
59 CONSTRUCTORS 65 CONSTRUCTORS
60 } 66 } :data
61 67
62 _edata = .; /* End of data section */ 68 _edata = .; /* End of data section */
63 69
@@ -89,7 +95,7 @@ SECTIONS
89#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET) 95#define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
90 96
91 . = VSYSCALL_ADDR; 97 . = VSYSCALL_ADDR;
92 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } 98 .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { *(.vsyscall_0) } :user
93 __vsyscall_0 = VSYSCALL_VIRT_ADDR; 99 __vsyscall_0 = VSYSCALL_VIRT_ADDR;
94 100
95 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); 101 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
@@ -99,6 +105,9 @@ SECTIONS
99 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) } 105 .vxtime : AT(VLOAD(.vxtime)) { *(.vxtime) }
100 vxtime = VVIRT(.vxtime); 106 vxtime = VVIRT(.vxtime);
101 107
108 .vgetcpu_mode : AT(VLOAD(.vgetcpu_mode)) { *(.vgetcpu_mode) }
109 vgetcpu_mode = VVIRT(.vgetcpu_mode);
110
102 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) } 111 .wall_jiffies : AT(VLOAD(.wall_jiffies)) { *(.wall_jiffies) }
103 wall_jiffies = VVIRT(.wall_jiffies); 112 wall_jiffies = VVIRT(.wall_jiffies);
104 113
@@ -132,7 +141,7 @@ SECTIONS
132 . = ALIGN(8192); /* init_task */ 141 . = ALIGN(8192); /* init_task */
133 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { 142 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) {
134 *(.data.init_task) 143 *(.data.init_task)
135 } 144 } :data
136 145
137 . = ALIGN(4096); 146 . = ALIGN(4096);
138 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { 147 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
@@ -207,14 +216,12 @@ SECTIONS
207 __initramfs_start = .; 216 __initramfs_start = .;
208 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) } 217 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
209 __initramfs_end = .; 218 __initramfs_end = .;
210 /* temporary here to work around NR_CPUS. If you see this comment in 2.6.17+ 219 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
211 complain */
212 . = ALIGN(4096);
213 __init_end = .;
214 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
215 __per_cpu_start = .; 220 __per_cpu_start = .;
216 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) } 221 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
217 __per_cpu_end = .; 222 __per_cpu_end = .;
223 . = ALIGN(4096);
224 __init_end = .;
218 225
219 . = ALIGN(4096); 226 . = ALIGN(4096);
220 __nosave_begin = .; 227 __nosave_begin = .;
diff --git a/arch/x86_64/kernel/vsmp.c b/arch/x86_64/kernel/vsmp.c
index 92f70c74965f..044e852bd25e 100644
--- a/arch/x86_64/kernel/vsmp.c
+++ b/arch/x86_64/kernel/vsmp.c
@@ -20,6 +20,9 @@ static int __init vsmp_init(void)
20 void *address; 20 void *address;
21 unsigned int cap, ctl; 21 unsigned int cap, ctl;
22 22
23 if (!early_pci_allowed())
24 return 0;
25
23 /* Check if we are running on a ScaleMP vSMP box */ 26 /* Check if we are running on a ScaleMP vSMP box */
24 if ((read_pci_config_16(0, 0x1f, 0, PCI_VENDOR_ID) != PCI_VENDOR_ID_SCALEMP) || 27 if ((read_pci_config_16(0, 0x1f, 0, PCI_VENDOR_ID) != PCI_VENDOR_ID_SCALEMP) ||
25 (read_pci_config_16(0, 0x1f, 0, PCI_DEVICE_ID) != PCI_DEVICE_ID_SCALEMP_VSMP_CTL)) 28 (read_pci_config_16(0, 0x1f, 0, PCI_DEVICE_ID) != PCI_DEVICE_ID_SCALEMP_VSMP_CTL))
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index f603037df162..ac48c3857ddb 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -26,6 +26,7 @@
26#include <linux/seqlock.h> 26#include <linux/seqlock.h>
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/sysctl.h> 28#include <linux/sysctl.h>
29#include <linux/getcpu.h>
29 30
30#include <asm/vsyscall.h> 31#include <asm/vsyscall.h>
31#include <asm/pgtable.h> 32#include <asm/pgtable.h>
@@ -33,11 +34,15 @@
33#include <asm/fixmap.h> 34#include <asm/fixmap.h>
34#include <asm/errno.h> 35#include <asm/errno.h>
35#include <asm/io.h> 36#include <asm/io.h>
37#include <asm/segment.h>
38#include <asm/desc.h>
39#include <asm/topology.h>
36 40
37#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 41#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
38 42
39int __sysctl_vsyscall __section_sysctl_vsyscall = 1; 43int __sysctl_vsyscall __section_sysctl_vsyscall = 1;
40seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED; 44seqlock_t __xtime_lock __section_xtime_lock = SEQLOCK_UNLOCKED;
45int __vgetcpu_mode __section_vgetcpu_mode;
41 46
42#include <asm/unistd.h> 47#include <asm/unistd.h>
43 48
@@ -72,7 +77,8 @@ static __always_inline void do_vgettimeofday(struct timeval * tv)
72 __vxtime.tsc_quot) >> 32; 77 __vxtime.tsc_quot) >> 32;
73 /* See comment in x86_64 do_gettimeofday. */ 78 /* See comment in x86_64 do_gettimeofday. */
74 } else { 79 } else {
75 usec += ((readl((void *)fix_to_virt(VSYSCALL_HPET) + 0xf0) - 80 usec += ((readl((void __iomem *)
81 fix_to_virt(VSYSCALL_HPET) + 0xf0) -
76 __vxtime.last) * __vxtime.quot) >> 32; 82 __vxtime.last) * __vxtime.quot) >> 32;
77 } 83 }
78 } while (read_seqretry(&__xtime_lock, sequence)); 84 } while (read_seqretry(&__xtime_lock, sequence));
@@ -127,9 +133,46 @@ time_t __vsyscall(1) vtime(time_t *t)
127 return __xtime.tv_sec; 133 return __xtime.tv_sec;
128} 134}
129 135
130long __vsyscall(2) venosys_0(void) 136/* Fast way to get current CPU and node.
137 This helps to do per node and per CPU caches in user space.
138 The result is not guaranteed without CPU affinity, but usually
139 works out because the scheduler tries to keep a thread on the same
140 CPU.
141
142 tcache must point to a two element sized long array.
143 All arguments can be NULL. */
144long __vsyscall(2)
145vgetcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
131{ 146{
132 return -ENOSYS; 147 unsigned int dummy, p;
148 unsigned long j = 0;
149
150 /* Fast cache - only recompute value once per jiffies and avoid
151 relatively costly rdtscp/cpuid otherwise.
152 This works because the scheduler usually keeps the process
153 on the same CPU and this syscall doesn't guarantee its
154 results anyways.
155 We do this here because otherwise user space would do it on
156 its own in a likely inferior way (no access to jiffies).
157 If you don't like it pass NULL. */
158 if (tcache && tcache->t0 == (j = __jiffies)) {
159 p = tcache->t1;
160 } else if (__vgetcpu_mode == VGETCPU_RDTSCP) {
161 /* Load per CPU data from RDTSCP */
162 rdtscp(dummy, dummy, p);
163 } else {
164 /* Load per CPU data from GDT */
165 asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
166 }
167 if (tcache) {
168 tcache->t0 = j;
169 tcache->t1 = p;
170 }
171 if (cpu)
172 *cpu = p & 0xfff;
173 if (node)
174 *node = p >> 12;
175 return 0;
133} 176}
134 177
135long __vsyscall(3) venosys_1(void) 178long __vsyscall(3) venosys_1(void)
@@ -149,7 +192,8 @@ static int vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * filp,
149 void __user *buffer, size_t *lenp, loff_t *ppos) 192 void __user *buffer, size_t *lenp, loff_t *ppos)
150{ 193{
151 extern u16 vsysc1, vsysc2; 194 extern u16 vsysc1, vsysc2;
152 u16 *map1, *map2; 195 u16 __iomem *map1;
196 u16 __iomem *map2;
153 int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos); 197 int ret = proc_dointvec(ctl, write, filp, buffer, lenp, ppos);
154 if (!write) 198 if (!write)
155 return ret; 199 return ret;
@@ -164,11 +208,11 @@ static int vsyscall_sysctl_change(ctl_table *ctl, int write, struct file * filp,
164 goto out; 208 goto out;
165 } 209 }
166 if (!sysctl_vsyscall) { 210 if (!sysctl_vsyscall) {
167 *map1 = SYSCALL; 211 writew(SYSCALL, map1);
168 *map2 = SYSCALL; 212 writew(SYSCALL, map2);
169 } else { 213 } else {
170 *map1 = NOP2; 214 writew(NOP2, map1);
171 *map2 = NOP2; 215 writew(NOP2, map2);
172 } 216 }
173 iounmap(map2); 217 iounmap(map2);
174out: 218out:
@@ -200,6 +244,43 @@ static ctl_table kernel_root_table2[] = {
200 244
201#endif 245#endif
202 246
247static void __cpuinit write_rdtscp_cb(void *info)
248{
249 write_rdtscp_aux((unsigned long)info);
250}
251
252void __cpuinit vsyscall_set_cpu(int cpu)
253{
254 unsigned long *d;
255 unsigned long node = 0;
256#ifdef CONFIG_NUMA
257 node = cpu_to_node[cpu];
258#endif
259 if (cpu_has(&cpu_data[cpu], X86_FEATURE_RDTSCP)) {
260 void *info = (void *)((node << 12) | cpu);
261 /* Can happen on preemptive kernel */
262 if (get_cpu() == cpu)
263 write_rdtscp_cb(info);
264#ifdef CONFIG_SMP
265 else {
266 /* the notifier is unfortunately not executed on the
267 target CPU */
268 smp_call_function_single(cpu,write_rdtscp_cb,info,0,1);
269 }
270#endif
271 put_cpu();
272 }
273
274 /* Store cpu number in limit so that it can be loaded quickly
275 in user space in vgetcpu.
276 12 bits for the CPU and 8 bits for the node. */
277 d = (unsigned long *)(cpu_gdt(cpu) + GDT_ENTRY_PER_CPU);
278 *d = 0x0f40000000000ULL;
279 *d |= cpu;
280 *d |= (node & 0xf) << 12;
281 *d |= (node >> 4) << 48;
282}
283
203static void __init map_vsyscall(void) 284static void __init map_vsyscall(void)
204{ 285{
205 extern char __vsyscall_0; 286 extern char __vsyscall_0;
@@ -214,6 +295,7 @@ static int __init vsyscall_init(void)
214 VSYSCALL_ADDR(__NR_vgettimeofday))); 295 VSYSCALL_ADDR(__NR_vgettimeofday)));
215 BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime)); 296 BUG_ON((unsigned long) &vtime != VSYSCALL_ADDR(__NR_vtime));
216 BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE))); 297 BUG_ON((VSYSCALL_ADDR(0) != __fix_to_virt(VSYSCALL_FIRST_PAGE)));
298 BUG_ON((unsigned long) &vgetcpu != VSYSCALL_ADDR(__NR_vgetcpu));
217 map_vsyscall(); 299 map_vsyscall();
218#ifdef CONFIG_SYSCTL 300#ifdef CONFIG_SYSCTL
219 register_sysctl_table(kernel_root_table2, 0); 301 register_sysctl_table(kernel_root_table2, 0);
diff --git a/arch/x86_64/kernel/x8664_ksyms.c b/arch/x86_64/kernel/x8664_ksyms.c
index 370952c4ff22..c3454af5e3a2 100644
--- a/arch/x86_64/kernel/x8664_ksyms.c
+++ b/arch/x86_64/kernel/x8664_ksyms.c
@@ -29,6 +29,7 @@ EXPORT_SYMBOL(__put_user_8);
29EXPORT_SYMBOL(copy_user_generic); 29EXPORT_SYMBOL(copy_user_generic);
30EXPORT_SYMBOL(copy_from_user); 30EXPORT_SYMBOL(copy_from_user);
31EXPORT_SYMBOL(copy_to_user); 31EXPORT_SYMBOL(copy_to_user);
32EXPORT_SYMBOL(__copy_from_user_inatomic);
32 33
33EXPORT_SYMBOL(copy_page); 34EXPORT_SYMBOL(copy_page);
34EXPORT_SYMBOL(clear_page); 35EXPORT_SYMBOL(clear_page);
diff --git a/arch/x86_64/lib/Makefile b/arch/x86_64/lib/Makefile
index ccef6ae747a3..b78d4170fce2 100644
--- a/arch/x86_64/lib/Makefile
+++ b/arch/x86_64/lib/Makefile
@@ -9,4 +9,4 @@ obj-y := io.o iomap_copy.o
9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \ 9lib-y := csum-partial.o csum-copy.o csum-wrappers.o delay.o \
10 usercopy.o getuser.o putuser.o \ 10 usercopy.o getuser.o putuser.o \
11 thunk.o clear_page.o copy_page.o bitstr.o bitops.o 11 thunk.o clear_page.o copy_page.o bitstr.o bitops.o
12lib-y += memcpy.o memmove.o memset.o copy_user.o 12lib-y += memcpy.o memmove.o memset.o copy_user.o rwlock.o
diff --git a/arch/x86_64/lib/clear_page.S b/arch/x86_64/lib/clear_page.S
index 1f81b79b796c..9a10a78bb4a4 100644
--- a/arch/x86_64/lib/clear_page.S
+++ b/arch/x86_64/lib/clear_page.S
@@ -1,10 +1,22 @@
1#include <linux/linkage.h>
2#include <asm/dwarf2.h>
3
1/* 4/*
2 * Zero a page. 5 * Zero a page.
3 * rdi page 6 * rdi page
4 */ 7 */
5 .globl clear_page 8 ALIGN
6 .p2align 4 9clear_page_c:
7clear_page: 10 CFI_STARTPROC
11 movl $4096/8,%ecx
12 xorl %eax,%eax
13 rep stosq
14 ret
15 CFI_ENDPROC
16ENDPROC(clear_page)
17
18ENTRY(clear_page)
19 CFI_STARTPROC
8 xorl %eax,%eax 20 xorl %eax,%eax
9 movl $4096/64,%ecx 21 movl $4096/64,%ecx
10 .p2align 4 22 .p2align 4
@@ -23,28 +35,25 @@ clear_page:
23 jnz .Lloop 35 jnz .Lloop
24 nop 36 nop
25 ret 37 ret
26clear_page_end: 38 CFI_ENDPROC
39.Lclear_page_end:
40ENDPROC(clear_page)
27 41
28 /* Some CPUs run faster using the string instructions. 42 /* Some CPUs run faster using the string instructions.
29 It is also a lot simpler. Use this when possible */ 43 It is also a lot simpler. Use this when possible */
30 44
31#include <asm/cpufeature.h> 45#include <asm/cpufeature.h>
32 46
47 .section .altinstr_replacement,"ax"
481: .byte 0xeb /* jmp <disp8> */
49 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
502:
51 .previous
33 .section .altinstructions,"a" 52 .section .altinstructions,"a"
34 .align 8 53 .align 8
35 .quad clear_page 54 .quad clear_page
36 .quad clear_page_c 55 .quad 1b
37 .byte X86_FEATURE_REP_GOOD 56 .byte X86_FEATURE_REP_GOOD
38 .byte clear_page_end-clear_page 57 .byte .Lclear_page_end - clear_page
39 .byte clear_page_c_end-clear_page_c 58 .byte 2b - 1b
40 .previous
41
42 .section .altinstr_replacement,"ax"
43clear_page_c:
44 movl $4096/8,%ecx
45 xorl %eax,%eax
46 rep
47 stosq
48 ret
49clear_page_c_end:
50 .previous 59 .previous
diff --git a/arch/x86_64/lib/copy_page.S b/arch/x86_64/lib/copy_page.S
index 8fa19d96a7ee..0ebb03b60e79 100644
--- a/arch/x86_64/lib/copy_page.S
+++ b/arch/x86_64/lib/copy_page.S
@@ -1,17 +1,33 @@
1/* Written 2003 by Andi Kleen, based on a kernel by Evandro Menezes */ 1/* Written 2003 by Andi Kleen, based on a kernel by Evandro Menezes */
2 2
3#include <linux/config.h>
4#include <linux/linkage.h>
5#include <asm/dwarf2.h>
6
7 ALIGN
8copy_page_c:
9 CFI_STARTPROC
10 movl $4096/8,%ecx
11 rep movsq
12 ret
13 CFI_ENDPROC
14ENDPROC(copy_page_c)
15
3/* Don't use streaming store because it's better when the target 16/* Don't use streaming store because it's better when the target
4 ends up in cache. */ 17 ends up in cache. */
5 18
6/* Could vary the prefetch distance based on SMP/UP */ 19/* Could vary the prefetch distance based on SMP/UP */
7 20
8 .globl copy_page 21ENTRY(copy_page)
9 .p2align 4 22 CFI_STARTPROC
10copy_page:
11 subq $3*8,%rsp 23 subq $3*8,%rsp
24 CFI_ADJUST_CFA_OFFSET 3*8
12 movq %rbx,(%rsp) 25 movq %rbx,(%rsp)
26 CFI_REL_OFFSET rbx, 0
13 movq %r12,1*8(%rsp) 27 movq %r12,1*8(%rsp)
28 CFI_REL_OFFSET r12, 1*8
14 movq %r13,2*8(%rsp) 29 movq %r13,2*8(%rsp)
30 CFI_REL_OFFSET r13, 2*8
15 31
16 movl $(4096/64)-5,%ecx 32 movl $(4096/64)-5,%ecx
17 .p2align 4 33 .p2align 4
@@ -72,30 +88,33 @@ copy_page:
72 jnz .Loop2 88 jnz .Loop2
73 89
74 movq (%rsp),%rbx 90 movq (%rsp),%rbx
91 CFI_RESTORE rbx
75 movq 1*8(%rsp),%r12 92 movq 1*8(%rsp),%r12
93 CFI_RESTORE r12
76 movq 2*8(%rsp),%r13 94 movq 2*8(%rsp),%r13
95 CFI_RESTORE r13
77 addq $3*8,%rsp 96 addq $3*8,%rsp
97 CFI_ADJUST_CFA_OFFSET -3*8
78 ret 98 ret
99.Lcopy_page_end:
100 CFI_ENDPROC
101ENDPROC(copy_page)
79 102
80 /* Some CPUs run faster using the string copy instructions. 103 /* Some CPUs run faster using the string copy instructions.
81 It is also a lot simpler. Use this when possible */ 104 It is also a lot simpler. Use this when possible */
82 105
83#include <asm/cpufeature.h> 106#include <asm/cpufeature.h>
84 107
108 .section .altinstr_replacement,"ax"
1091: .byte 0xeb /* jmp <disp8> */
110 .byte (copy_page_c - copy_page) - (2f - 1b) /* offset */
1112:
112 .previous
85 .section .altinstructions,"a" 113 .section .altinstructions,"a"
86 .align 8 114 .align 8
87 .quad copy_page 115 .quad copy_page
88 .quad copy_page_c 116 .quad 1b
89 .byte X86_FEATURE_REP_GOOD 117 .byte X86_FEATURE_REP_GOOD
90 .byte copy_page_c_end-copy_page_c 118 .byte .Lcopy_page_end - copy_page
91 .byte copy_page_c_end-copy_page_c 119 .byte 2b - 1b
92 .previous
93
94 .section .altinstr_replacement,"ax"
95copy_page_c:
96 movl $4096/8,%ecx
97 rep
98 movsq
99 ret
100copy_page_c_end:
101 .previous 120 .previous
diff --git a/arch/x86_64/lib/copy_user.S b/arch/x86_64/lib/copy_user.S
index f64569b83b54..70bebd310408 100644
--- a/arch/x86_64/lib/copy_user.S
+++ b/arch/x86_64/lib/copy_user.S
@@ -4,56 +4,78 @@
4 * Functions to copy from and to user space. 4 * Functions to copy from and to user space.
5 */ 5 */
6 6
7#include <linux/linkage.h>
8#include <asm/dwarf2.h>
9
7#define FIX_ALIGNMENT 1 10#define FIX_ALIGNMENT 1
8 11
9 #include <asm/current.h> 12#include <asm/current.h>
10 #include <asm/asm-offsets.h> 13#include <asm/asm-offsets.h>
11 #include <asm/thread_info.h> 14#include <asm/thread_info.h>
12 #include <asm/cpufeature.h> 15#include <asm/cpufeature.h>
13 16
14/* Standard copy_to_user with segment limit checking */ 17 .macro ALTERNATIVE_JUMP feature,orig,alt
15 .globl copy_to_user 180:
16 .p2align 4
17copy_to_user:
18 GET_THREAD_INFO(%rax)
19 movq %rdi,%rcx
20 addq %rdx,%rcx
21 jc bad_to_user
22 cmpq threadinfo_addr_limit(%rax),%rcx
23 jae bad_to_user
242:
25 .byte 0xe9 /* 32bit jump */ 19 .byte 0xe9 /* 32bit jump */
26 .long .Lcug-1f 20 .long \orig-1f /* by default jump to orig */
271: 211:
28
29 .section .altinstr_replacement,"ax" 22 .section .altinstr_replacement,"ax"
303: .byte 0xe9 /* replacement jmp with 8 bit immediate */ 232: .byte 0xe9 /* near jump with 32bit immediate */
31 .long copy_user_generic_c-1b /* offset */ 24 .long \alt-1b /* offset */ /* or alternatively to alt */
32 .previous 25 .previous
33 .section .altinstructions,"a" 26 .section .altinstructions,"a"
34 .align 8 27 .align 8
28 .quad 0b
35 .quad 2b 29 .quad 2b
36 .quad 3b 30 .byte \feature /* when feature is set */
37 .byte X86_FEATURE_REP_GOOD
38 .byte 5 31 .byte 5
39 .byte 5 32 .byte 5
40 .previous 33 .previous
34 .endm
35
36/* Standard copy_to_user with segment limit checking */
37ENTRY(copy_to_user)
38 CFI_STARTPROC
39 GET_THREAD_INFO(%rax)
40 movq %rdi,%rcx
41 addq %rdx,%rcx
42 jc bad_to_user
43 cmpq threadinfo_addr_limit(%rax),%rcx
44 jae bad_to_user
45 xorl %eax,%eax /* clear zero flag */
46 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
47 CFI_ENDPROC
48
49ENTRY(copy_user_generic)
50 CFI_STARTPROC
51 movl $1,%ecx /* set zero flag */
52 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
53 CFI_ENDPROC
54
55ENTRY(__copy_from_user_inatomic)
56 CFI_STARTPROC
57 xorl %ecx,%ecx /* clear zero flag */
58 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
59 CFI_ENDPROC
41 60
42/* Standard copy_from_user with segment limit checking */ 61/* Standard copy_from_user with segment limit checking */
43 .globl copy_from_user 62ENTRY(copy_from_user)
44 .p2align 4 63 CFI_STARTPROC
45copy_from_user:
46 GET_THREAD_INFO(%rax) 64 GET_THREAD_INFO(%rax)
47 movq %rsi,%rcx 65 movq %rsi,%rcx
48 addq %rdx,%rcx 66 addq %rdx,%rcx
49 jc bad_from_user 67 jc bad_from_user
50 cmpq threadinfo_addr_limit(%rax),%rcx 68 cmpq threadinfo_addr_limit(%rax),%rcx
51 jae bad_from_user 69 jae bad_from_user
52 /* FALL THROUGH to copy_user_generic */ 70 movl $1,%ecx /* set zero flag */
71 ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,copy_user_generic_unrolled,copy_user_generic_string
72 CFI_ENDPROC
73ENDPROC(copy_from_user)
53 74
54 .section .fixup,"ax" 75 .section .fixup,"ax"
55 /* must zero dest */ 76 /* must zero dest */
56bad_from_user: 77bad_from_user:
78 CFI_STARTPROC
57 movl %edx,%ecx 79 movl %edx,%ecx
58 xorl %eax,%eax 80 xorl %eax,%eax
59 rep 81 rep
@@ -61,40 +83,32 @@ bad_from_user:
61bad_to_user: 83bad_to_user:
62 movl %edx,%eax 84 movl %edx,%eax
63 ret 85 ret
86 CFI_ENDPROC
87END(bad_from_user)
64 .previous 88 .previous
65 89
66 90
67/* 91/*
68 * copy_user_generic - memory copy with exception handling. 92 * copy_user_generic_unrolled - memory copy with exception handling.
93 * This version is for CPUs like P4 that don't have efficient micro code for rep movsq
69 * 94 *
70 * Input: 95 * Input:
71 * rdi destination 96 * rdi destination
72 * rsi source 97 * rsi source
73 * rdx count 98 * rdx count
99 * ecx zero flag -- if true zero destination on error
74 * 100 *
75 * Output: 101 * Output:
76 * eax uncopied bytes or 0 if successful. 102 * eax uncopied bytes or 0 if successful.
77 */ 103 */
78 .globl copy_user_generic 104ENTRY(copy_user_generic_unrolled)
79 .p2align 4 105 CFI_STARTPROC
80copy_user_generic:
81 .byte 0x66,0x66,0x90 /* 5 byte nop for replacement jump */
82 .byte 0x66,0x90
831:
84 .section .altinstr_replacement,"ax"
852: .byte 0xe9 /* near jump with 32bit immediate */
86 .long copy_user_generic_c-1b /* offset */
87 .previous
88 .section .altinstructions,"a"
89 .align 8
90 .quad copy_user_generic
91 .quad 2b
92 .byte X86_FEATURE_REP_GOOD
93 .byte 5
94 .byte 5
95 .previous
96.Lcug:
97 pushq %rbx 106 pushq %rbx
107 CFI_ADJUST_CFA_OFFSET 8
108 CFI_REL_OFFSET rbx, 0
109 pushq %rcx
110 CFI_ADJUST_CFA_OFFSET 8
111 CFI_REL_OFFSET rcx, 0
98 xorl %eax,%eax /*zero for the exception handler */ 112 xorl %eax,%eax /*zero for the exception handler */
99 113
100#ifdef FIX_ALIGNMENT 114#ifdef FIX_ALIGNMENT
@@ -168,9 +182,16 @@ copy_user_generic:
168 decl %ecx 182 decl %ecx
169 jnz .Lloop_1 183 jnz .Lloop_1
170 184
185 CFI_REMEMBER_STATE
171.Lende: 186.Lende:
187 popq %rcx
188 CFI_ADJUST_CFA_OFFSET -8
189 CFI_RESTORE rcx
172 popq %rbx 190 popq %rbx
191 CFI_ADJUST_CFA_OFFSET -8
192 CFI_RESTORE rbx
173 ret 193 ret
194 CFI_RESTORE_STATE
174 195
175#ifdef FIX_ALIGNMENT 196#ifdef FIX_ALIGNMENT
176 /* align destination */ 197 /* align destination */
@@ -252,6 +273,8 @@ copy_user_generic:
252 addl %ecx,%edx 273 addl %ecx,%edx
253 /* edx: bytes to zero, rdi: dest, eax:zero */ 274 /* edx: bytes to zero, rdi: dest, eax:zero */
254.Lzero_rest: 275.Lzero_rest:
276 cmpl $0,(%rsp)
277 jz .Le_zero
255 movq %rdx,%rcx 278 movq %rdx,%rcx
256.Le_byte: 279.Le_byte:
257 xorl %eax,%eax 280 xorl %eax,%eax
@@ -261,6 +284,9 @@ copy_user_generic:
261.Le_zero: 284.Le_zero:
262 movq %rdx,%rax 285 movq %rdx,%rax
263 jmp .Lende 286 jmp .Lende
287 CFI_ENDPROC
288ENDPROC(copy_user_generic)
289
264 290
265 /* Some CPUs run faster using the string copy instructions. 291 /* Some CPUs run faster using the string copy instructions.
266 This is also a lot simpler. Use them when possible. 292 This is also a lot simpler. Use them when possible.
@@ -270,6 +296,7 @@ copy_user_generic:
270 /* rdi destination 296 /* rdi destination
271 * rsi source 297 * rsi source
272 * rdx count 298 * rdx count
299 * ecx zero flag
273 * 300 *
274 * Output: 301 * Output:
275 * eax uncopied bytes or 0 if successfull. 302 * eax uncopied bytes or 0 if successfull.
@@ -280,22 +307,48 @@ copy_user_generic:
280 * And more would be dangerous because both Intel and AMD have 307 * And more would be dangerous because both Intel and AMD have
281 * errata with rep movsq > 4GB. If someone feels the need to fix 308 * errata with rep movsq > 4GB. If someone feels the need to fix
282 * this please consider this. 309 * this please consider this.
283 */ 310 */
284copy_user_generic_c: 311ENTRY(copy_user_generic_string)
312 CFI_STARTPROC
313 movl %ecx,%r8d /* save zero flag */
285 movl %edx,%ecx 314 movl %edx,%ecx
286 shrl $3,%ecx 315 shrl $3,%ecx
287 andl $7,%edx 316 andl $7,%edx
317 jz 10f
2881: rep 3181: rep
289 movsq 319 movsq
290 movl %edx,%ecx 320 movl %edx,%ecx
2912: rep 3212: rep
292 movsb 322 movsb
2934: movl %ecx,%eax 3239: movl %ecx,%eax
294 ret 324 ret
2953: lea (%rdx,%rcx,8),%rax 325
326 /* multiple of 8 byte */
32710: rep
328 movsq
329 xor %eax,%eax
296 ret 330 ret
297 331
332 /* exception handling */
3333: lea (%rdx,%rcx,8),%rax /* exception on quad loop */
334 jmp 6f
3355: movl %ecx,%eax /* exception on byte loop */
336 /* eax: left over bytes */
3376: testl %r8d,%r8d /* zero flag set? */
338 jz 7f
339 movl %eax,%ecx /* initialize x86 loop counter */
340 push %rax
341 xorl %eax,%eax
3428: rep
343 stosb /* zero the rest */
34411: pop %rax
3457: ret
346 CFI_ENDPROC
347END(copy_user_generic_c)
348
298 .section __ex_table,"a" 349 .section __ex_table,"a"
299 .quad 1b,3b 350 .quad 1b,3b
300 .quad 2b,4b 351 .quad 2b,5b
352 .quad 8b,11b
353 .quad 10b,3b
301 .previous 354 .previous
diff --git a/arch/x86_64/lib/csum-copy.S b/arch/x86_64/lib/csum-copy.S
index 72fd55ee896e..f0dba36578ea 100644
--- a/arch/x86_64/lib/csum-copy.S
+++ b/arch/x86_64/lib/csum-copy.S
@@ -5,8 +5,9 @@
5 * License. See the file COPYING in the main directory of this archive 5 * License. See the file COPYING in the main directory of this archive
6 * for more details. No warranty for anything given at all. 6 * for more details. No warranty for anything given at all.
7 */ 7 */
8 #include <linux/linkage.h> 8#include <linux/linkage.h>
9 #include <asm/errno.h> 9#include <asm/dwarf2.h>
10#include <asm/errno.h>
10 11
11/* 12/*
12 * Checksum copy with exception handling. 13 * Checksum copy with exception handling.
@@ -53,19 +54,24 @@
53 .endm 54 .endm
54 55
55 56
56 .globl csum_partial_copy_generic 57ENTRY(csum_partial_copy_generic)
57 .p2align 4 58 CFI_STARTPROC
58csum_partial_copy_generic:
59 cmpl $3*64,%edx 59 cmpl $3*64,%edx
60 jle .Lignore 60 jle .Lignore
61 61
62.Lignore: 62.Lignore:
63 subq $7*8,%rsp 63 subq $7*8,%rsp
64 CFI_ADJUST_CFA_OFFSET 7*8
64 movq %rbx,2*8(%rsp) 65 movq %rbx,2*8(%rsp)
66 CFI_REL_OFFSET rbx, 2*8
65 movq %r12,3*8(%rsp) 67 movq %r12,3*8(%rsp)
68 CFI_REL_OFFSET r12, 3*8
66 movq %r14,4*8(%rsp) 69 movq %r14,4*8(%rsp)
70 CFI_REL_OFFSET r14, 4*8
67 movq %r13,5*8(%rsp) 71 movq %r13,5*8(%rsp)
72 CFI_REL_OFFSET r13, 5*8
68 movq %rbp,6*8(%rsp) 73 movq %rbp,6*8(%rsp)
74 CFI_REL_OFFSET rbp, 6*8
69 75
70 movq %r8,(%rsp) 76 movq %r8,(%rsp)
71 movq %r9,1*8(%rsp) 77 movq %r9,1*8(%rsp)
@@ -208,14 +214,22 @@ csum_partial_copy_generic:
208 addl %ebx,%eax 214 addl %ebx,%eax
209 adcl %r9d,%eax /* carry */ 215 adcl %r9d,%eax /* carry */
210 216
217 CFI_REMEMBER_STATE
211.Lende: 218.Lende:
212 movq 2*8(%rsp),%rbx 219 movq 2*8(%rsp),%rbx
220 CFI_RESTORE rbx
213 movq 3*8(%rsp),%r12 221 movq 3*8(%rsp),%r12
222 CFI_RESTORE r12
214 movq 4*8(%rsp),%r14 223 movq 4*8(%rsp),%r14
224 CFI_RESTORE r14
215 movq 5*8(%rsp),%r13 225 movq 5*8(%rsp),%r13
226 CFI_RESTORE r13
216 movq 6*8(%rsp),%rbp 227 movq 6*8(%rsp),%rbp
228 CFI_RESTORE rbp
217 addq $7*8,%rsp 229 addq $7*8,%rsp
230 CFI_ADJUST_CFA_OFFSET -7*8
218 ret 231 ret
232 CFI_RESTORE_STATE
219 233
220 /* Exception handlers. Very simple, zeroing is done in the wrappers */ 234 /* Exception handlers. Very simple, zeroing is done in the wrappers */
221.Lbad_source: 235.Lbad_source:
@@ -231,3 +245,5 @@ csum_partial_copy_generic:
231 jz .Lende 245 jz .Lende
232 movl $-EFAULT,(%rax) 246 movl $-EFAULT,(%rax)
233 jmp .Lende 247 jmp .Lende
248 CFI_ENDPROC
249ENDPROC(csum_partial_copy_generic)
diff --git a/arch/x86_64/lib/getuser.S b/arch/x86_64/lib/getuser.S
index 3844d5e885a4..5448876261f8 100644
--- a/arch/x86_64/lib/getuser.S
+++ b/arch/x86_64/lib/getuser.S
@@ -27,25 +27,26 @@
27 */ 27 */
28 28
29#include <linux/linkage.h> 29#include <linux/linkage.h>
30#include <asm/dwarf2.h>
30#include <asm/page.h> 31#include <asm/page.h>
31#include <asm/errno.h> 32#include <asm/errno.h>
32#include <asm/asm-offsets.h> 33#include <asm/asm-offsets.h>
33#include <asm/thread_info.h> 34#include <asm/thread_info.h>
34 35
35 .text 36 .text
36 .p2align 4 37ENTRY(__get_user_1)
37.globl __get_user_1 38 CFI_STARTPROC
38__get_user_1:
39 GET_THREAD_INFO(%r8) 39 GET_THREAD_INFO(%r8)
40 cmpq threadinfo_addr_limit(%r8),%rcx 40 cmpq threadinfo_addr_limit(%r8),%rcx
41 jae bad_get_user 41 jae bad_get_user
421: movzb (%rcx),%edx 421: movzb (%rcx),%edx
43 xorl %eax,%eax 43 xorl %eax,%eax
44 ret 44 ret
45 CFI_ENDPROC
46ENDPROC(__get_user_1)
45 47
46 .p2align 4 48ENTRY(__get_user_2)
47.globl __get_user_2 49 CFI_STARTPROC
48__get_user_2:
49 GET_THREAD_INFO(%r8) 50 GET_THREAD_INFO(%r8)
50 addq $1,%rcx 51 addq $1,%rcx
51 jc 20f 52 jc 20f
@@ -57,10 +58,11 @@ __get_user_2:
57 ret 58 ret
5820: decq %rcx 5920: decq %rcx
59 jmp bad_get_user 60 jmp bad_get_user
61 CFI_ENDPROC
62ENDPROC(__get_user_2)
60 63
61 .p2align 4 64ENTRY(__get_user_4)
62.globl __get_user_4 65 CFI_STARTPROC
63__get_user_4:
64 GET_THREAD_INFO(%r8) 66 GET_THREAD_INFO(%r8)
65 addq $3,%rcx 67 addq $3,%rcx
66 jc 30f 68 jc 30f
@@ -72,10 +74,11 @@ __get_user_4:
72 ret 74 ret
7330: subq $3,%rcx 7530: subq $3,%rcx
74 jmp bad_get_user 76 jmp bad_get_user
77 CFI_ENDPROC
78ENDPROC(__get_user_4)
75 79
76 .p2align 4 80ENTRY(__get_user_8)
77.globl __get_user_8 81 CFI_STARTPROC
78__get_user_8:
79 GET_THREAD_INFO(%r8) 82 GET_THREAD_INFO(%r8)
80 addq $7,%rcx 83 addq $7,%rcx
81 jc 40f 84 jc 40f
@@ -87,11 +90,16 @@ __get_user_8:
87 ret 90 ret
8840: subq $7,%rcx 9140: subq $7,%rcx
89 jmp bad_get_user 92 jmp bad_get_user
93 CFI_ENDPROC
94ENDPROC(__get_user_8)
90 95
91bad_get_user: 96bad_get_user:
97 CFI_STARTPROC
92 xorl %edx,%edx 98 xorl %edx,%edx
93 movq $(-EFAULT),%rax 99 movq $(-EFAULT),%rax
94 ret 100 ret
101 CFI_ENDPROC
102END(bad_get_user)
95 103
96.section __ex_table,"a" 104.section __ex_table,"a"
97 .quad 1b,bad_get_user 105 .quad 1b,bad_get_user
diff --git a/arch/x86_64/lib/iomap_copy.S b/arch/x86_64/lib/iomap_copy.S
index 8bbade5fea05..05a95e713da8 100644
--- a/arch/x86_64/lib/iomap_copy.S
+++ b/arch/x86_64/lib/iomap_copy.S
@@ -15,12 +15,16 @@
15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 15 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
16 */ 16 */
17 17
18#include <linux/linkage.h>
19#include <asm/dwarf2.h>
20
18/* 21/*
19 * override generic version in lib/iomap_copy.c 22 * override generic version in lib/iomap_copy.c
20 */ 23 */
21 .globl __iowrite32_copy 24ENTRY(__iowrite32_copy)
22 .p2align 4 25 CFI_STARTPROC
23__iowrite32_copy:
24 movl %edx,%ecx 26 movl %edx,%ecx
25 rep movsd 27 rep movsd
26 ret 28 ret
29 CFI_ENDPROC
30ENDPROC(__iowrite32_copy)
diff --git a/arch/x86_64/lib/memcpy.S b/arch/x86_64/lib/memcpy.S
index 5554948b5554..967b22fa7d07 100644
--- a/arch/x86_64/lib/memcpy.S
+++ b/arch/x86_64/lib/memcpy.S
@@ -1,6 +1,10 @@
1/* Copyright 2002 Andi Kleen */ 1/* Copyright 2002 Andi Kleen */
2 2
3 #include <asm/cpufeature.h> 3#include <linux/config.h>
4#include <linux/linkage.h>
5#include <asm/dwarf2.h>
6#include <asm/cpufeature.h>
7
4/* 8/*
5 * memcpy - Copy a memory block. 9 * memcpy - Copy a memory block.
6 * 10 *
@@ -13,12 +17,26 @@
13 * rax original destination 17 * rax original destination
14 */ 18 */
15 19
16 .globl __memcpy 20 ALIGN
17 .globl memcpy 21memcpy_c:
18 .p2align 4 22 CFI_STARTPROC
19__memcpy: 23 movq %rdi,%rax
20memcpy: 24 movl %edx,%ecx
25 shrl $3,%ecx
26 andl $7,%edx
27 rep movsq
28 movl %edx,%ecx
29 rep movsb
30 ret
31 CFI_ENDPROC
32ENDPROC(memcpy_c)
33
34ENTRY(__memcpy)
35ENTRY(memcpy)
36 CFI_STARTPROC
21 pushq %rbx 37 pushq %rbx
38 CFI_ADJUST_CFA_OFFSET 8
39 CFI_REL_OFFSET rbx, 0
22 movq %rdi,%rax 40 movq %rdi,%rax
23 41
24 movl %edx,%ecx 42 movl %edx,%ecx
@@ -86,36 +104,27 @@ memcpy:
86 104
87.Lende: 105.Lende:
88 popq %rbx 106 popq %rbx
107 CFI_ADJUST_CFA_OFFSET -8
108 CFI_RESTORE rbx
89 ret 109 ret
90.Lfinal: 110.Lfinal:
111 CFI_ENDPROC
112ENDPROC(memcpy)
113ENDPROC(__memcpy)
91 114
92 /* Some CPUs run faster using the string copy instructions. 115 /* Some CPUs run faster using the string copy instructions.
93 It is also a lot simpler. Use this when possible */ 116 It is also a lot simpler. Use this when possible */
94 117
118 .section .altinstr_replacement,"ax"
1191: .byte 0xeb /* jmp <disp8> */
120 .byte (memcpy_c - memcpy) - (2f - 1b) /* offset */
1212:
122 .previous
95 .section .altinstructions,"a" 123 .section .altinstructions,"a"
96 .align 8 124 .align 8
97 .quad memcpy 125 .quad memcpy
98 .quad memcpy_c 126 .quad 1b
99 .byte X86_FEATURE_REP_GOOD 127 .byte X86_FEATURE_REP_GOOD
100 .byte .Lfinal-memcpy 128 .byte .Lfinal - memcpy
101 .byte memcpy_c_end-memcpy_c 129 .byte 2b - 1b
102 .previous
103
104 .section .altinstr_replacement,"ax"
105 /* rdi destination
106 * rsi source
107 * rdx count
108 */
109memcpy_c:
110 movq %rdi,%rax
111 movl %edx,%ecx
112 shrl $3,%ecx
113 andl $7,%edx
114 rep
115 movsq
116 movl %edx,%ecx
117 rep
118 movsb
119 ret
120memcpy_c_end:
121 .previous 130 .previous
diff --git a/arch/x86_64/lib/memset.S b/arch/x86_64/lib/memset.S
index ad397f2c7de8..09ed1f6b0eaa 100644
--- a/arch/x86_64/lib/memset.S
+++ b/arch/x86_64/lib/memset.S
@@ -1,4 +1,9 @@
1/* Copyright 2002 Andi Kleen, SuSE Labs */ 1/* Copyright 2002 Andi Kleen, SuSE Labs */
2
3#include <linux/config.h>
4#include <linux/linkage.h>
5#include <asm/dwarf2.h>
6
2/* 7/*
3 * ISO C memset - set a memory block to a byte value. 8 * ISO C memset - set a memory block to a byte value.
4 * 9 *
@@ -8,11 +13,29 @@
8 * 13 *
9 * rax original destination 14 * rax original destination
10 */ 15 */
11 .globl __memset 16 ALIGN
12 .globl memset 17memset_c:
13 .p2align 4 18 CFI_STARTPROC
14memset: 19 movq %rdi,%r9
15__memset: 20 movl %edx,%r8d
21 andl $7,%r8d
22 movl %edx,%ecx
23 shrl $3,%ecx
24 /* expand byte value */
25 movzbl %sil,%esi
26 movabs $0x0101010101010101,%rax
27 mulq %rsi /* with rax, clobbers rdx */
28 rep stosq
29 movl %r8d,%ecx
30 rep stosb
31 movq %r9,%rax
32 ret
33 CFI_ENDPROC
34ENDPROC(memset_c)
35
36ENTRY(memset)
37ENTRY(__memset)
38 CFI_STARTPROC
16 movq %rdi,%r10 39 movq %rdi,%r10
17 movq %rdx,%r11 40 movq %rdx,%r11
18 41
@@ -25,6 +48,7 @@ __memset:
25 movl %edi,%r9d 48 movl %edi,%r9d
26 andl $7,%r9d 49 andl $7,%r9d
27 jnz .Lbad_alignment 50 jnz .Lbad_alignment
51 CFI_REMEMBER_STATE
28.Lafter_bad_alignment: 52.Lafter_bad_alignment:
29 53
30 movl %r11d,%ecx 54 movl %r11d,%ecx
@@ -75,6 +99,7 @@ __memset:
75 movq %r10,%rax 99 movq %r10,%rax
76 ret 100 ret
77 101
102 CFI_RESTORE_STATE
78.Lbad_alignment: 103.Lbad_alignment:
79 cmpq $7,%r11 104 cmpq $7,%r11
80 jbe .Lhandle_7 105 jbe .Lhandle_7
@@ -84,42 +109,26 @@ __memset:
84 addq %r8,%rdi 109 addq %r8,%rdi
85 subq %r8,%r11 110 subq %r8,%r11
86 jmp .Lafter_bad_alignment 111 jmp .Lafter_bad_alignment
112.Lfinal:
113 CFI_ENDPROC
114ENDPROC(memset)
115ENDPROC(__memset)
87 116
88 /* Some CPUs run faster using the string instructions. 117 /* Some CPUs run faster using the string instructions.
89 It is also a lot simpler. Use this when possible */ 118 It is also a lot simpler. Use this when possible */
90 119
91#include <asm/cpufeature.h> 120#include <asm/cpufeature.h>
92 121
122 .section .altinstr_replacement,"ax"
1231: .byte 0xeb /* jmp <disp8> */
124 .byte (memset_c - memset) - (2f - 1b) /* offset */
1252:
126 .previous
93 .section .altinstructions,"a" 127 .section .altinstructions,"a"
94 .align 8 128 .align 8
95 .quad memset 129 .quad memset
96 .quad memset_c 130 .quad 1b
97 .byte X86_FEATURE_REP_GOOD 131 .byte X86_FEATURE_REP_GOOD
98 .byte memset_c_end-memset_c 132 .byte .Lfinal - memset
99 .byte memset_c_end-memset_c 133 .byte 2b - 1b
100 .previous
101
102 .section .altinstr_replacement,"ax"
103 /* rdi destination
104 * rsi value
105 * rdx count
106 */
107memset_c:
108 movq %rdi,%r9
109 movl %edx,%r8d
110 andl $7,%r8d
111 movl %edx,%ecx
112 shrl $3,%ecx
113 /* expand byte value */
114 movzbl %sil,%esi
115 movabs $0x0101010101010101,%rax
116 mulq %rsi /* with rax, clobbers rdx */
117 rep
118 stosq
119 movl %r8d,%ecx
120 rep
121 stosb
122 movq %r9,%rax
123 ret
124memset_c_end:
125 .previous 134 .previous
diff --git a/arch/x86_64/lib/putuser.S b/arch/x86_64/lib/putuser.S
index 7f5593974e2d..4989f5a8fa9b 100644
--- a/arch/x86_64/lib/putuser.S
+++ b/arch/x86_64/lib/putuser.S
@@ -25,25 +25,26 @@
25 */ 25 */
26 26
27#include <linux/linkage.h> 27#include <linux/linkage.h>
28#include <asm/dwarf2.h>
28#include <asm/page.h> 29#include <asm/page.h>
29#include <asm/errno.h> 30#include <asm/errno.h>
30#include <asm/asm-offsets.h> 31#include <asm/asm-offsets.h>
31#include <asm/thread_info.h> 32#include <asm/thread_info.h>
32 33
33 .text 34 .text
34 .p2align 4 35ENTRY(__put_user_1)
35.globl __put_user_1 36 CFI_STARTPROC
36__put_user_1:
37 GET_THREAD_INFO(%r8) 37 GET_THREAD_INFO(%r8)
38 cmpq threadinfo_addr_limit(%r8),%rcx 38 cmpq threadinfo_addr_limit(%r8),%rcx
39 jae bad_put_user 39 jae bad_put_user
401: movb %dl,(%rcx) 401: movb %dl,(%rcx)
41 xorl %eax,%eax 41 xorl %eax,%eax
42 ret 42 ret
43 CFI_ENDPROC
44ENDPROC(__put_user_1)
43 45
44 .p2align 4 46ENTRY(__put_user_2)
45.globl __put_user_2 47 CFI_STARTPROC
46__put_user_2:
47 GET_THREAD_INFO(%r8) 48 GET_THREAD_INFO(%r8)
48 addq $1,%rcx 49 addq $1,%rcx
49 jc 20f 50 jc 20f
@@ -55,10 +56,11 @@ __put_user_2:
55 ret 56 ret
5620: decq %rcx 5720: decq %rcx
57 jmp bad_put_user 58 jmp bad_put_user
59 CFI_ENDPROC
60ENDPROC(__put_user_2)
58 61
59 .p2align 4 62ENTRY(__put_user_4)
60.globl __put_user_4 63 CFI_STARTPROC
61__put_user_4:
62 GET_THREAD_INFO(%r8) 64 GET_THREAD_INFO(%r8)
63 addq $3,%rcx 65 addq $3,%rcx
64 jc 30f 66 jc 30f
@@ -70,10 +72,11 @@ __put_user_4:
70 ret 72 ret
7130: subq $3,%rcx 7330: subq $3,%rcx
72 jmp bad_put_user 74 jmp bad_put_user
75 CFI_ENDPROC
76ENDPROC(__put_user_4)
73 77
74 .p2align 4 78ENTRY(__put_user_8)
75.globl __put_user_8 79 CFI_STARTPROC
76__put_user_8:
77 GET_THREAD_INFO(%r8) 80 GET_THREAD_INFO(%r8)
78 addq $7,%rcx 81 addq $7,%rcx
79 jc 40f 82 jc 40f
@@ -85,10 +88,15 @@ __put_user_8:
85 ret 88 ret
8640: subq $7,%rcx 8940: subq $7,%rcx
87 jmp bad_put_user 90 jmp bad_put_user
91 CFI_ENDPROC
92ENDPROC(__put_user_8)
88 93
89bad_put_user: 94bad_put_user:
95 CFI_STARTPROC
90 movq $(-EFAULT),%rax 96 movq $(-EFAULT),%rax
91 ret 97 ret
98 CFI_ENDPROC
99END(bad_put_user)
92 100
93.section __ex_table,"a" 101.section __ex_table,"a"
94 .quad 1b,bad_put_user 102 .quad 1b,bad_put_user
diff --git a/arch/x86_64/lib/rwlock.S b/arch/x86_64/lib/rwlock.S
new file mode 100644
index 000000000000..0cde1f807314
--- /dev/null
+++ b/arch/x86_64/lib/rwlock.S
@@ -0,0 +1,38 @@
1/* Slow paths of read/write spinlocks. */
2
3#include <linux/linkage.h>
4#include <asm/rwlock.h>
5#include <asm/alternative-asm.i>
6#include <asm/dwarf2.h>
7
8/* rdi: pointer to rwlock_t */
9ENTRY(__write_lock_failed)
10 CFI_STARTPROC
11 LOCK_PREFIX
12 addl $RW_LOCK_BIAS,(%rdi)
131: rep
14 nop
15 cmpl $RW_LOCK_BIAS,(%rdi)
16 jne 1b
17 LOCK_PREFIX
18 subl $RW_LOCK_BIAS,(%rdi)
19 jnz __write_lock_failed
20 ret
21 CFI_ENDPROC
22END(__write_lock_failed)
23
24/* rdi: pointer to rwlock_t */
25ENTRY(__read_lock_failed)
26 CFI_STARTPROC
27 LOCK_PREFIX
28 incl (%rdi)
291: rep
30 nop
31 cmpl $1,(%rdi)
32 js 1b
33 LOCK_PREFIX
34 decl (%rdi)
35 js __read_lock_failed
36 ret
37 CFI_ENDPROC
38END(__read_lock_failed)
diff --git a/arch/x86_64/lib/thunk.S b/arch/x86_64/lib/thunk.S
index 332ea5dff916..0025535cac8d 100644
--- a/arch/x86_64/lib/thunk.S
+++ b/arch/x86_64/lib/thunk.S
@@ -1,10 +1,9 @@
1 /* 1/*
2 * Save registers before calling assembly functions. This avoids 2 * Save registers before calling assembly functions. This avoids
3 * disturbance of register allocation in some inline assembly constructs. 3 * disturbance of register allocation in some inline assembly constructs.
4 * Copyright 2001,2002 by Andi Kleen, SuSE Labs. 4 * Copyright 2001,2002 by Andi Kleen, SuSE Labs.
5 * Subject to the GNU public license, v.2. No warranty of any kind. 5 * Subject to the GNU public license, v.2. No warranty of any kind.
6 * $Id: thunk.S,v 1.2 2002/03/13 20:06:58 ak Exp $ 6 */
7 */
8 7
9 #include <linux/config.h> 8 #include <linux/config.h>
10 #include <linux/linkage.h> 9 #include <linux/linkage.h>
@@ -67,33 +66,3 @@ restore_norax:
67 RESTORE_ARGS 1 66 RESTORE_ARGS 1
68 ret 67 ret
69 CFI_ENDPROC 68 CFI_ENDPROC
70
71#ifdef CONFIG_SMP
72/* Support for read/write spinlocks. */
73 .text
74/* rax: pointer to rwlock_t */
75ENTRY(__write_lock_failed)
76 lock
77 addl $RW_LOCK_BIAS,(%rax)
781: rep
79 nop
80 cmpl $RW_LOCK_BIAS,(%rax)
81 jne 1b
82 lock
83 subl $RW_LOCK_BIAS,(%rax)
84 jnz __write_lock_failed
85 ret
86
87/* rax: pointer to rwlock_t */
88ENTRY(__read_lock_failed)
89 lock
90 incl (%rax)
911: rep
92 nop
93 cmpl $1,(%rax)
94 js 1b
95 lock
96 decl (%rax)
97 js __read_lock_failed
98 ret
99#endif
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 4198798e1469..1a17b0733ab5 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -40,8 +40,7 @@
40#define PF_RSVD (1<<3) 40#define PF_RSVD (1<<3)
41#define PF_INSTR (1<<4) 41#define PF_INSTR (1<<4)
42 42
43#ifdef CONFIG_KPROBES 43static ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
44ATOMIC_NOTIFIER_HEAD(notify_page_fault_chain);
45 44
46/* Hook to register for page fault notifications */ 45/* Hook to register for page fault notifications */
47int register_page_fault_notifier(struct notifier_block *nb) 46int register_page_fault_notifier(struct notifier_block *nb)
@@ -49,11 +48,13 @@ int register_page_fault_notifier(struct notifier_block *nb)
49 vmalloc_sync_all(); 48 vmalloc_sync_all();
50 return atomic_notifier_chain_register(&notify_page_fault_chain, nb); 49 return atomic_notifier_chain_register(&notify_page_fault_chain, nb);
51} 50}
51EXPORT_SYMBOL_GPL(register_page_fault_notifier);
52 52
53int unregister_page_fault_notifier(struct notifier_block *nb) 53int unregister_page_fault_notifier(struct notifier_block *nb)
54{ 54{
55 return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb); 55 return atomic_notifier_chain_unregister(&notify_page_fault_chain, nb);
56} 56}
57EXPORT_SYMBOL_GPL(unregister_page_fault_notifier);
57 58
58static inline int notify_page_fault(enum die_val val, const char *str, 59static inline int notify_page_fault(enum die_val val, const char *str,
59 struct pt_regs *regs, long err, int trap, int sig) 60 struct pt_regs *regs, long err, int trap, int sig)
@@ -67,13 +68,6 @@ static inline int notify_page_fault(enum die_val val, const char *str,
67 }; 68 };
68 return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args); 69 return atomic_notifier_call_chain(&notify_page_fault_chain, val, &args);
69} 70}
70#else
71static inline int notify_page_fault(enum die_val val, const char *str,
72 struct pt_regs *regs, long err, int trap, int sig)
73{
74 return NOTIFY_DONE;
75}
76#endif
77 71
78void bust_spinlocks(int yes) 72void bust_spinlocks(int yes)
79{ 73{
@@ -102,7 +96,7 @@ void bust_spinlocks(int yes)
102static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr, 96static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
103 unsigned long error_code) 97 unsigned long error_code)
104{ 98{
105 unsigned char *instr; 99 unsigned char __user *instr;
106 int scan_more = 1; 100 int scan_more = 1;
107 int prefetch = 0; 101 int prefetch = 0;
108 unsigned char *max_instr; 102 unsigned char *max_instr;
@@ -111,7 +105,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
111 if (error_code & PF_INSTR) 105 if (error_code & PF_INSTR)
112 return 0; 106 return 0;
113 107
114 instr = (unsigned char *)convert_rip_to_linear(current, regs); 108 instr = (unsigned char __user *)convert_rip_to_linear(current, regs);
115 max_instr = instr + 15; 109 max_instr = instr + 15;
116 110
117 if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE) 111 if (user_mode(regs) && instr >= (unsigned char *)TASK_SIZE)
@@ -122,7 +116,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
122 unsigned char instr_hi; 116 unsigned char instr_hi;
123 unsigned char instr_lo; 117 unsigned char instr_lo;
124 118
125 if (__get_user(opcode, instr)) 119 if (__get_user(opcode, (char __user *)instr))
126 break; 120 break;
127 121
128 instr_hi = opcode & 0xf0; 122 instr_hi = opcode & 0xf0;
@@ -160,7 +154,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
160 case 0x00: 154 case 0x00:
161 /* Prefetch instruction is 0x0F0D or 0x0F18 */ 155 /* Prefetch instruction is 0x0F0D or 0x0F18 */
162 scan_more = 0; 156 scan_more = 0;
163 if (__get_user(opcode, instr)) 157 if (__get_user(opcode, (char __user *)instr))
164 break; 158 break;
165 prefetch = (instr_lo == 0xF) && 159 prefetch = (instr_lo == 0xF) &&
166 (opcode == 0x0D || opcode == 0x18); 160 (opcode == 0x0D || opcode == 0x18);
@@ -176,7 +170,7 @@ static noinline int is_prefetch(struct pt_regs *regs, unsigned long addr,
176static int bad_address(void *p) 170static int bad_address(void *p)
177{ 171{
178 unsigned long dummy; 172 unsigned long dummy;
179 return __get_user(dummy, (unsigned long *)p); 173 return __get_user(dummy, (unsigned long __user *)p);
180} 174}
181 175
182void dump_pagetable(unsigned long address) 176void dump_pagetable(unsigned long address)
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 52fd42c40c86..3e16fe08150e 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -229,7 +229,6 @@ __init void *early_ioremap(unsigned long addr, unsigned long size)
229 229
230 /* actually usually some more */ 230 /* actually usually some more */
231 if (size >= LARGE_PAGE_SIZE) { 231 if (size >= LARGE_PAGE_SIZE) {
232 printk("SMBIOS area too long %lu\n", size);
233 return NULL; 232 return NULL;
234 } 233 }
235 set_pmd(temp_mappings[0].pmd, __pmd(map | _KERNPG_TABLE | _PAGE_PSE)); 234 set_pmd(temp_mappings[0].pmd, __pmd(map | _KERNPG_TABLE | _PAGE_PSE));
@@ -250,12 +249,13 @@ __init void early_iounmap(void *addr, unsigned long size)
250} 249}
251 250
252static void __meminit 251static void __meminit
253phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end) 252phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end)
254{ 253{
255 int i; 254 int i = pmd_index(address);
256 255
257 for (i = 0; i < PTRS_PER_PMD; pmd++, i++, address += PMD_SIZE) { 256 for (; i < PTRS_PER_PMD; i++, address += PMD_SIZE) {
258 unsigned long entry; 257 unsigned long entry;
258 pmd_t *pmd = pmd_page + pmd_index(address);
259 259
260 if (address >= end) { 260 if (address >= end) {
261 if (!after_bootmem) 261 if (!after_bootmem)
@@ -263,6 +263,10 @@ phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
263 set_pmd(pmd, __pmd(0)); 263 set_pmd(pmd, __pmd(0));
264 break; 264 break;
265 } 265 }
266
267 if (pmd_val(*pmd))
268 continue;
269
266 entry = _PAGE_NX|_PAGE_PSE|_KERNPG_TABLE|_PAGE_GLOBAL|address; 270 entry = _PAGE_NX|_PAGE_PSE|_KERNPG_TABLE|_PAGE_GLOBAL|address;
267 entry &= __supported_pte_mask; 271 entry &= __supported_pte_mask;
268 set_pmd(pmd, __pmd(entry)); 272 set_pmd(pmd, __pmd(entry));
@@ -272,45 +276,41 @@ phys_pmd_init(pmd_t *pmd, unsigned long address, unsigned long end)
272static void __meminit 276static void __meminit
273phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end) 277phys_pmd_update(pud_t *pud, unsigned long address, unsigned long end)
274{ 278{
275 pmd_t *pmd = pmd_offset(pud, (unsigned long)__va(address)); 279 pmd_t *pmd = pmd_offset(pud,0);
276 280 spin_lock(&init_mm.page_table_lock);
277 if (pmd_none(*pmd)) { 281 phys_pmd_init(pmd, address, end);
278 spin_lock(&init_mm.page_table_lock); 282 spin_unlock(&init_mm.page_table_lock);
279 phys_pmd_init(pmd, address, end); 283 __flush_tlb_all();
280 spin_unlock(&init_mm.page_table_lock);
281 __flush_tlb_all();
282 }
283} 284}
284 285
285static void __meminit phys_pud_init(pud_t *pud, unsigned long address, unsigned long end) 286static void __meminit phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
286{ 287{
287 long i = pud_index(address); 288 int i = pud_index(addr);
288 289
289 pud = pud + i;
290 290
291 if (after_bootmem && pud_val(*pud)) { 291 for (; i < PTRS_PER_PUD; i++, addr = (addr & PUD_MASK) + PUD_SIZE ) {
292 phys_pmd_update(pud, address, end);
293 return;
294 }
295
296 for (; i < PTRS_PER_PUD; pud++, i++) {
297 int map; 292 int map;
298 unsigned long paddr, pmd_phys; 293 unsigned long pmd_phys;
294 pud_t *pud = pud_page + pud_index(addr);
299 pmd_t *pmd; 295 pmd_t *pmd;
300 296
301 paddr = (address & PGDIR_MASK) + i*PUD_SIZE; 297 if (addr >= end)
302 if (paddr >= end)
303 break; 298 break;
304 299
305 if (!after_bootmem && !e820_any_mapped(paddr, paddr+PUD_SIZE, 0)) { 300 if (!after_bootmem && !e820_any_mapped(addr,addr+PUD_SIZE,0)) {
306 set_pud(pud, __pud(0)); 301 set_pud(pud, __pud(0));
307 continue; 302 continue;
308 } 303 }
309 304
305 if (pud_val(*pud)) {
306 phys_pmd_update(pud, addr, end);
307 continue;
308 }
309
310 pmd = alloc_low_page(&map, &pmd_phys); 310 pmd = alloc_low_page(&map, &pmd_phys);
311 spin_lock(&init_mm.page_table_lock); 311 spin_lock(&init_mm.page_table_lock);
312 set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE)); 312 set_pud(pud, __pud(pmd_phys | _KERNPG_TABLE));
313 phys_pmd_init(pmd, paddr, end); 313 phys_pmd_init(pmd, addr, end);
314 spin_unlock(&init_mm.page_table_lock); 314 spin_unlock(&init_mm.page_table_lock);
315 unmap_low_page(map); 315 unmap_low_page(map);
316 } 316 }
@@ -403,69 +403,15 @@ void __cpuinit zap_low_mappings(int cpu)
403 __flush_tlb_all(); 403 __flush_tlb_all();
404} 404}
405 405
406/* Compute zone sizes for the DMA and DMA32 zones in a node. */
407__init void
408size_zones(unsigned long *z, unsigned long *h,
409 unsigned long start_pfn, unsigned long end_pfn)
410{
411 int i;
412 unsigned long w;
413
414 for (i = 0; i < MAX_NR_ZONES; i++)
415 z[i] = 0;
416
417 if (start_pfn < MAX_DMA_PFN)
418 z[ZONE_DMA] = MAX_DMA_PFN - start_pfn;
419 if (start_pfn < MAX_DMA32_PFN) {
420 unsigned long dma32_pfn = MAX_DMA32_PFN;
421 if (dma32_pfn > end_pfn)
422 dma32_pfn = end_pfn;
423 z[ZONE_DMA32] = dma32_pfn - start_pfn;
424 }
425 z[ZONE_NORMAL] = end_pfn - start_pfn;
426
427 /* Remove lower zones from higher ones. */
428 w = 0;
429 for (i = 0; i < MAX_NR_ZONES; i++) {
430 if (z[i])
431 z[i] -= w;
432 w += z[i];
433 }
434
435 /* Compute holes */
436 w = start_pfn;
437 for (i = 0; i < MAX_NR_ZONES; i++) {
438 unsigned long s = w;
439 w += z[i];
440 h[i] = e820_hole_size(s, w);
441 }
442
443 /* Add the space pace needed for mem_map to the holes too. */
444 for (i = 0; i < MAX_NR_ZONES; i++)
445 h[i] += (z[i] * sizeof(struct page)) / PAGE_SIZE;
446
447 /* The 16MB DMA zone has the kernel and other misc mappings.
448 Account them too */
449 if (h[ZONE_DMA]) {
450 h[ZONE_DMA] += dma_reserve;
451 if (h[ZONE_DMA] >= z[ZONE_DMA]) {
452 printk(KERN_WARNING
453 "Kernel too large and filling up ZONE_DMA?\n");
454 h[ZONE_DMA] = z[ZONE_DMA];
455 }
456 }
457}
458
459#ifndef CONFIG_NUMA 406#ifndef CONFIG_NUMA
460void __init paging_init(void) 407void __init paging_init(void)
461{ 408{
462 unsigned long zones[MAX_NR_ZONES], holes[MAX_NR_ZONES]; 409 unsigned long max_zone_pfns[MAX_NR_ZONES] = {MAX_DMA_PFN,
463 410 MAX_DMA32_PFN,
411 end_pfn};
464 memory_present(0, 0, end_pfn); 412 memory_present(0, 0, end_pfn);
465 sparse_init(); 413 sparse_init();
466 size_zones(zones, holes, 0, end_pfn); 414 free_area_init_nodes(max_zone_pfns);
467 free_area_init_node(0, NODE_DATA(0), zones,
468 __pa(PAGE_OFFSET) >> PAGE_SHIFT, holes);
469} 415}
470#endif 416#endif
471 417
@@ -597,12 +543,6 @@ void __init mem_init(void)
597 543
598 pci_iommu_alloc(); 544 pci_iommu_alloc();
599 545
600 /* How many end-of-memory variables you have, grandma! */
601 max_low_pfn = end_pfn;
602 max_pfn = end_pfn;
603 num_physpages = end_pfn;
604 high_memory = (void *) __va(end_pfn * PAGE_SIZE);
605
606 /* clear the zero-page */ 546 /* clear the zero-page */
607 memset(empty_zero_page, 0, PAGE_SIZE); 547 memset(empty_zero_page, 0, PAGE_SIZE);
608 548
@@ -614,7 +554,8 @@ void __init mem_init(void)
614#else 554#else
615 totalram_pages = free_all_bootmem(); 555 totalram_pages = free_all_bootmem();
616#endif 556#endif
617 reservedpages = end_pfn - totalram_pages - e820_hole_size(0, end_pfn); 557 reservedpages = end_pfn - totalram_pages -
558 absent_pages_in_range(0, end_pfn);
618 559
619 after_bootmem = 1; 560 after_bootmem = 1;
620 561
@@ -714,8 +655,10 @@ void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
714#else 655#else
715 reserve_bootmem(phys, len); 656 reserve_bootmem(phys, len);
716#endif 657#endif
717 if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) 658 if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
718 dma_reserve += len / PAGE_SIZE; 659 dma_reserve += len / PAGE_SIZE;
660 set_dma_reserve(dma_reserve);
661 }
719} 662}
720 663
721int kern_addr_valid(unsigned long addr) 664int kern_addr_valid(unsigned long addr)
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index 7c45c2d2b8b2..b5b8dba28b4e 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -54,6 +54,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
54 54
55 nodes_clear(nodes_parsed); 55 nodes_clear(nodes_parsed);
56 56
57 if (!early_pci_allowed())
58 return -1;
59
57 nb = find_northbridge(); 60 nb = find_northbridge();
58 if (nb < 0) 61 if (nb < 0)
59 return nb; 62 return nb;
@@ -146,6 +149,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
146 149
147 nodes[nodeid].start = base; 150 nodes[nodeid].start = base;
148 nodes[nodeid].end = limit; 151 nodes[nodeid].end = limit;
152 e820_register_active_regions(nodeid,
153 nodes[nodeid].start >> PAGE_SHIFT,
154 nodes[nodeid].end >> PAGE_SHIFT);
149 155
150 prevbase = base; 156 prevbase = base;
151 157
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index b2fac14baac0..829a008bd39b 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -161,7 +161,7 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
161 bootmap_start >> PAGE_SHIFT, 161 bootmap_start >> PAGE_SHIFT,
162 start_pfn, end_pfn); 162 start_pfn, end_pfn);
163 163
164 e820_bootmem_free(NODE_DATA(nodeid), start, end); 164 free_bootmem_with_active_regions(nodeid, end);
165 165
166 reserve_bootmem_node(NODE_DATA(nodeid), nodedata_phys, pgdat_size); 166 reserve_bootmem_node(NODE_DATA(nodeid), nodedata_phys, pgdat_size);
167 reserve_bootmem_node(NODE_DATA(nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT); 167 reserve_bootmem_node(NODE_DATA(nodeid), bootmap_start, bootmap_pages<<PAGE_SHIFT);
@@ -175,13 +175,11 @@ void __init setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
175void __init setup_node_zones(int nodeid) 175void __init setup_node_zones(int nodeid)
176{ 176{
177 unsigned long start_pfn, end_pfn, memmapsize, limit; 177 unsigned long start_pfn, end_pfn, memmapsize, limit;
178 unsigned long zones[MAX_NR_ZONES];
179 unsigned long holes[MAX_NR_ZONES];
180 178
181 start_pfn = node_start_pfn(nodeid); 179 start_pfn = node_start_pfn(nodeid);
182 end_pfn = node_end_pfn(nodeid); 180 end_pfn = node_end_pfn(nodeid);
183 181
184 Dprintk(KERN_INFO "Setting up node %d %lx-%lx\n", 182 Dprintk(KERN_INFO "Setting up memmap for node %d %lx-%lx\n",
185 nodeid, start_pfn, end_pfn); 183 nodeid, start_pfn, end_pfn);
186 184
187 /* Try to allocate mem_map at end to not fill up precious <4GB 185 /* Try to allocate mem_map at end to not fill up precious <4GB
@@ -195,10 +193,6 @@ void __init setup_node_zones(int nodeid)
195 round_down(limit - memmapsize, PAGE_SIZE), 193 round_down(limit - memmapsize, PAGE_SIZE),
196 limit); 194 limit);
197#endif 195#endif
198
199 size_zones(zones, holes, start_pfn, end_pfn);
200 free_area_init_node(nodeid, NODE_DATA(nodeid), zones,
201 start_pfn, holes);
202} 196}
203 197
204void __init numa_init_array(void) 198void __init numa_init_array(void)
@@ -225,7 +219,7 @@ void __init numa_init_array(void)
225int numa_fake __initdata = 0; 219int numa_fake __initdata = 0;
226 220
227/* Numa emulation */ 221/* Numa emulation */
228static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn) 222static int __init numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
229{ 223{
230 int i; 224 int i;
231 struct bootnode nodes[MAX_NUMNODES]; 225 struct bootnode nodes[MAX_NUMNODES];
@@ -259,8 +253,11 @@ static int numa_emulation(unsigned long start_pfn, unsigned long end_pfn)
259 printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\n"); 253 printk(KERN_ERR "No NUMA hash function found. Emulation disabled.\n");
260 return -1; 254 return -1;
261 } 255 }
262 for_each_online_node(i) 256 for_each_online_node(i) {
257 e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
258 nodes[i].end >> PAGE_SHIFT);
263 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 259 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
260 }
264 numa_init_array(); 261 numa_init_array();
265 return 0; 262 return 0;
266} 263}
@@ -299,6 +296,7 @@ void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
299 for (i = 0; i < NR_CPUS; i++) 296 for (i = 0; i < NR_CPUS; i++)
300 numa_set_node(i, 0); 297 numa_set_node(i, 0);
301 node_to_cpumask[0] = cpumask_of_cpu(0); 298 node_to_cpumask[0] = cpumask_of_cpu(0);
299 e820_register_active_regions(0, start_pfn, end_pfn);
302 setup_node_bootmem(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT); 300 setup_node_bootmem(0, start_pfn << PAGE_SHIFT, end_pfn << PAGE_SHIFT);
303} 301}
304 302
@@ -340,17 +338,23 @@ static void __init arch_sparse_init(void)
340void __init paging_init(void) 338void __init paging_init(void)
341{ 339{
342 int i; 340 int i;
341 unsigned long max_zone_pfns[MAX_NR_ZONES] = { MAX_DMA_PFN,
342 MAX_DMA32_PFN,
343 end_pfn};
343 344
344 arch_sparse_init(); 345 arch_sparse_init();
345 346
346 for_each_online_node(i) { 347 for_each_online_node(i) {
347 setup_node_zones(i); 348 setup_node_zones(i);
348 } 349 }
350
351 free_area_init_nodes(max_zone_pfns);
349} 352}
350 353
351/* [numa=off] */ 354static __init int numa_setup(char *opt)
352__init int numa_setup(char *opt)
353{ 355{
356 if (!opt)
357 return -EINVAL;
354 if (!strncmp(opt,"off",3)) 358 if (!strncmp(opt,"off",3))
355 numa_off = 1; 359 numa_off = 1;
356#ifdef CONFIG_NUMA_EMU 360#ifdef CONFIG_NUMA_EMU
@@ -366,9 +370,11 @@ __init int numa_setup(char *opt)
366 if (!strncmp(opt,"hotadd=", 7)) 370 if (!strncmp(opt,"hotadd=", 7))
367 hotadd_percent = simple_strtoul(opt+7, NULL, 10); 371 hotadd_percent = simple_strtoul(opt+7, NULL, 10);
368#endif 372#endif
369 return 1; 373 return 0;
370} 374}
371 375
376early_param("numa", numa_setup);
377
372/* 378/*
373 * Setup early cpu_to_node. 379 * Setup early cpu_to_node.
374 * 380 *
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 2685b1f3671c..3e231d762aaa 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -108,8 +108,8 @@ static void revert_page(unsigned long address, pgprot_t ref_prot)
108 BUG_ON(pud_none(*pud)); 108 BUG_ON(pud_none(*pud));
109 pmd = pmd_offset(pud, address); 109 pmd = pmd_offset(pud, address);
110 BUG_ON(pmd_val(*pmd) & _PAGE_PSE); 110 BUG_ON(pmd_val(*pmd) & _PAGE_PSE);
111 pgprot_val(ref_prot) |= _PAGE_PSE;
112 large_pte = mk_pte_phys(__pa(address) & LARGE_PAGE_MASK, ref_prot); 111 large_pte = mk_pte_phys(__pa(address) & LARGE_PAGE_MASK, ref_prot);
112 large_pte = pte_mkhuge(large_pte);
113 set_pte((pte_t *)pmd, large_pte); 113 set_pte((pte_t *)pmd, large_pte);
114} 114}
115 115
@@ -119,32 +119,28 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
119{ 119{
120 pte_t *kpte; 120 pte_t *kpte;
121 struct page *kpte_page; 121 struct page *kpte_page;
122 unsigned kpte_flags;
123 pgprot_t ref_prot2; 122 pgprot_t ref_prot2;
124 kpte = lookup_address(address); 123 kpte = lookup_address(address);
125 if (!kpte) return 0; 124 if (!kpte) return 0;
126 kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK); 125 kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
127 kpte_flags = pte_val(*kpte);
128 if (pgprot_val(prot) != pgprot_val(ref_prot)) { 126 if (pgprot_val(prot) != pgprot_val(ref_prot)) {
129 if ((kpte_flags & _PAGE_PSE) == 0) { 127 if (!pte_huge(*kpte)) {
130 set_pte(kpte, pfn_pte(pfn, prot)); 128 set_pte(kpte, pfn_pte(pfn, prot));
131 } else { 129 } else {
132 /* 130 /*
133 * split_large_page will take the reference for this 131 * split_large_page will take the reference for this
134 * change_page_attr on the split page. 132 * change_page_attr on the split page.
135 */ 133 */
136
137 struct page *split; 134 struct page *split;
138 ref_prot2 = __pgprot(pgprot_val(pte_pgprot(*lookup_address(address))) & ~(1<<_PAGE_BIT_PSE)); 135 ref_prot2 = pte_pgprot(pte_clrhuge(*kpte));
139
140 split = split_large_page(address, prot, ref_prot2); 136 split = split_large_page(address, prot, ref_prot2);
141 if (!split) 137 if (!split)
142 return -ENOMEM; 138 return -ENOMEM;
143 set_pte(kpte,mk_pte(split, ref_prot2)); 139 set_pte(kpte, mk_pte(split, ref_prot2));
144 kpte_page = split; 140 kpte_page = split;
145 } 141 }
146 page_private(kpte_page)++; 142 page_private(kpte_page)++;
147 } else if ((kpte_flags & _PAGE_PSE) == 0) { 143 } else if (!pte_huge(*kpte)) {
148 set_pte(kpte, pfn_pte(pfn, ref_prot)); 144 set_pte(kpte, pfn_pte(pfn, ref_prot));
149 BUG_ON(page_private(kpte_page) == 0); 145 BUG_ON(page_private(kpte_page) == 0);
150 page_private(kpte_page)--; 146 page_private(kpte_page)--;
@@ -190,10 +186,12 @@ int change_page_attr_addr(unsigned long address, int numpages, pgprot_t prot)
190 * lowmem */ 186 * lowmem */
191 if (__pa(address) < KERNEL_TEXT_SIZE) { 187 if (__pa(address) < KERNEL_TEXT_SIZE) {
192 unsigned long addr2; 188 unsigned long addr2;
193 pgprot_t prot2 = prot; 189 pgprot_t prot2;
194 addr2 = __START_KERNEL_map + __pa(address); 190 addr2 = __START_KERNEL_map + __pa(address);
195 pgprot_val(prot2) &= ~_PAGE_NX; 191 /* Make sure the kernel mappings stay executable */
196 err = __change_page_attr(addr2, pfn, prot2, PAGE_KERNEL_EXEC); 192 prot2 = pte_pgprot(pte_mkexec(pfn_pte(0, prot)));
193 err = __change_page_attr(addr2, pfn, prot2,
194 PAGE_KERNEL_EXEC);
197 } 195 }
198 } 196 }
199 up_write(&init_mm.mmap_sem); 197 up_write(&init_mm.mmap_sem);
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 502fce65e96a..f8c04d6935c9 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -21,6 +21,8 @@
21#include <asm/numa.h> 21#include <asm/numa.h>
22#include <asm/e820.h> 22#include <asm/e820.h>
23 23
24int acpi_numa __initdata;
25
24#if (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \ 26#if (defined(CONFIG_ACPI_HOTPLUG_MEMORY) || \
25 defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) \ 27 defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)) \
26 && !defined(CONFIG_MEMORY_HOTPLUG) 28 && !defined(CONFIG_MEMORY_HOTPLUG)
@@ -91,6 +93,7 @@ static __init void bad_srat(void)
91 apicid_to_node[i] = NUMA_NO_NODE; 93 apicid_to_node[i] = NUMA_NO_NODE;
92 for (i = 0; i < MAX_NUMNODES; i++) 94 for (i = 0; i < MAX_NUMNODES; i++)
93 nodes_add[i].start = nodes[i].end = 0; 95 nodes_add[i].start = nodes[i].end = 0;
96 remove_all_active_ranges();
94} 97}
95 98
96static __init inline int srat_disabled(void) 99static __init inline int srat_disabled(void)
@@ -173,7 +176,7 @@ static int hotadd_enough_memory(struct bootnode *nd)
173 176
174 if (mem < 0) 177 if (mem < 0)
175 return 0; 178 return 0;
176 allowed = (end_pfn - e820_hole_size(0, end_pfn)) * PAGE_SIZE; 179 allowed = (end_pfn - absent_pages_in_range(0, end_pfn)) * PAGE_SIZE;
177 allowed = (allowed / 100) * hotadd_percent; 180 allowed = (allowed / 100) * hotadd_percent;
178 if (allocated + mem > allowed) { 181 if (allocated + mem > allowed) {
179 unsigned long range; 182 unsigned long range;
@@ -223,8 +226,10 @@ static int reserve_hotadd(int node, unsigned long start, unsigned long end)
223 } 226 }
224 227
225 /* This check might be a bit too strict, but I'm keeping it for now. */ 228 /* This check might be a bit too strict, but I'm keeping it for now. */
226 if (e820_hole_size(s_pfn, e_pfn) != e_pfn - s_pfn) { 229 if (absent_pages_in_range(s_pfn, e_pfn) != e_pfn - s_pfn) {
227 printk(KERN_ERR "SRAT: Hotplug area has existing memory\n"); 230 printk(KERN_ERR
231 "SRAT: Hotplug area %lu -> %lu has existing memory\n",
232 s_pfn, e_pfn);
228 return -1; 233 return -1;
229 } 234 }
230 235
@@ -317,6 +322,10 @@ acpi_numa_memory_affinity_init(struct acpi_table_memory_affinity *ma)
317 322
318 printk(KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n", node, pxm, 323 printk(KERN_INFO "SRAT: Node %u PXM %u %Lx-%Lx\n", node, pxm,
319 nd->start, nd->end); 324 nd->start, nd->end);
325 e820_register_active_regions(node, nd->start >> PAGE_SHIFT,
326 nd->end >> PAGE_SHIFT);
327 push_node_boundaries(node, nd->start >> PAGE_SHIFT,
328 nd->end >> PAGE_SHIFT);
320 329
321#ifdef RESERVE_HOTADD 330#ifdef RESERVE_HOTADD
322 if (ma->flags.hot_pluggable && reserve_hotadd(node, start, end) < 0) { 331 if (ma->flags.hot_pluggable && reserve_hotadd(node, start, end) < 0) {
@@ -341,13 +350,13 @@ static int nodes_cover_memory(void)
341 unsigned long s = nodes[i].start >> PAGE_SHIFT; 350 unsigned long s = nodes[i].start >> PAGE_SHIFT;
342 unsigned long e = nodes[i].end >> PAGE_SHIFT; 351 unsigned long e = nodes[i].end >> PAGE_SHIFT;
343 pxmram += e - s; 352 pxmram += e - s;
344 pxmram -= e820_hole_size(s, e); 353 pxmram -= absent_pages_in_range(s, e);
345 pxmram -= nodes_add[i].end - nodes_add[i].start; 354 pxmram -= nodes_add[i].end - nodes_add[i].start;
346 if ((long)pxmram < 0) 355 if ((long)pxmram < 0)
347 pxmram = 0; 356 pxmram = 0;
348 } 357 }
349 358
350 e820ram = end_pfn - e820_hole_size(0, end_pfn); 359 e820ram = end_pfn - absent_pages_in_range(0, end_pfn);
351 /* We seem to lose 3 pages somewhere. Allow a bit of slack. */ 360 /* We seem to lose 3 pages somewhere. Allow a bit of slack. */
352 if ((long)(e820ram - pxmram) >= 1*1024*1024) { 361 if ((long)(e820ram - pxmram) >= 1*1024*1024) {
353 printk(KERN_ERR 362 printk(KERN_ERR
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile
index a3f6ad570179..1eb18f421edf 100644
--- a/arch/x86_64/pci/Makefile
+++ b/arch/x86_64/pci/Makefile
@@ -9,7 +9,7 @@ obj-y := i386.o
9obj-$(CONFIG_PCI_DIRECT)+= direct.o 9obj-$(CONFIG_PCI_DIRECT)+= direct.o
10obj-y += fixup.o init.o 10obj-y += fixup.o init.o
11obj-$(CONFIG_ACPI) += acpi.o 11obj-$(CONFIG_ACPI) += acpi.o
12obj-y += legacy.o irq.o common.o 12obj-y += legacy.o irq.o common.o early.o
13# mmconfig has a 64bit special 13# mmconfig has a 64bit special
14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o 14obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o
15 15
@@ -23,3 +23,4 @@ common-y += ../../i386/pci/common.o
23fixup-y += ../../i386/pci/fixup.o 23fixup-y += ../../i386/pci/fixup.o
24i386-y += ../../i386/pci/i386.o 24i386-y += ../../i386/pci/i386.o
25init-y += ../../i386/pci/init.o 25init-y += ../../i386/pci/init.o
26early-y += ../../i386/pci/early.o
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 3c55c76c6fd5..7732f4254d21 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -156,15 +156,45 @@ static __init void unreachable_devices(void)
156 addr = pci_dev_base(0, k, PCI_DEVFN(i, 0)); 156 addr = pci_dev_base(0, k, PCI_DEVFN(i, 0));
157 if (addr == NULL|| readl(addr) != val1) { 157 if (addr == NULL|| readl(addr) != val1) {
158 set_bit(i + 32*k, fallback_slots); 158 set_bit(i + 32*k, fallback_slots);
159 printk(KERN_NOTICE 159 printk(KERN_NOTICE "PCI: No mmconfig possible"
160 "PCI: No mmconfig possible on device %x:%x\n", 160 " on device %02x:%02x\n", k, i);
161 k, i);
162 } 161 }
163 } 162 }
164 } 163 }
165} 164}
166 165
167void __init pci_mmcfg_init(void) 166static __init void pci_mmcfg_insert_resources(void)
167{
168#define PCI_MMCFG_RESOURCE_NAME_LEN 19
169 int i;
170 struct resource *res;
171 char *names;
172 unsigned num_buses;
173
174 res = kcalloc(PCI_MMCFG_RESOURCE_NAME_LEN + sizeof(*res),
175 pci_mmcfg_config_num, GFP_KERNEL);
176
177 if (!res) {
178 printk(KERN_ERR "PCI: Unable to allocate MMCONFIG resources\n");
179 return;
180 }
181
182 names = (void *)&res[pci_mmcfg_config_num];
183 for (i = 0; i < pci_mmcfg_config_num; i++, res++) {
184 num_buses = pci_mmcfg_config[i].end_bus_number -
185 pci_mmcfg_config[i].start_bus_number + 1;
186 res->name = names;
187 snprintf(names, PCI_MMCFG_RESOURCE_NAME_LEN, "PCI MMCONFIG %u",
188 pci_mmcfg_config[i].pci_segment_group_number);
189 res->start = pci_mmcfg_config[i].base_address;
190 res->end = res->start + (num_buses << 20) - 1;
191 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
192 insert_resource(&iomem_resource, res);
193 names += PCI_MMCFG_RESOURCE_NAME_LEN;
194 }
195}
196
197void __init pci_mmcfg_init(int type)
168{ 198{
169 int i; 199 int i;
170 200
@@ -177,7 +207,9 @@ void __init pci_mmcfg_init(void)
177 (pci_mmcfg_config[0].base_address == 0)) 207 (pci_mmcfg_config[0].base_address == 0))
178 return; 208 return;
179 209
180 if (!e820_all_mapped(pci_mmcfg_config[0].base_address, 210 /* Only do this check when type 1 works. If it doesn't work
211 assume we run on a Mac and always use MCFG */
212 if (type == 1 && !e820_all_mapped(pci_mmcfg_config[0].base_address,
181 pci_mmcfg_config[0].base_address + MMCONFIG_APER_MIN, 213 pci_mmcfg_config[0].base_address + MMCONFIG_APER_MIN,
182 E820_RESERVED)) { 214 E820_RESERVED)) {
183 printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %x is not E820-reserved\n", 215 printk(KERN_ERR "PCI: BIOS Bug: MCFG area at %x is not E820-reserved\n",
@@ -186,7 +218,6 @@ void __init pci_mmcfg_init(void)
186 return; 218 return;
187 } 219 }
188 220
189 /* RED-PEN i386 doesn't do _nocache right now */
190 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL); 221 pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
191 if (pci_mmcfg_virt == NULL) { 222 if (pci_mmcfg_virt == NULL) {
192 printk("PCI: Can not allocate memory for mmconfig structures\n"); 223 printk("PCI: Can not allocate memory for mmconfig structures\n");
@@ -205,6 +236,7 @@ void __init pci_mmcfg_init(void)
205 } 236 }
206 237
207 unreachable_devices(); 238 unreachable_devices();
239 pci_mmcfg_insert_resources();
208 240
209 raw_pci_ops = &pci_mmcfg; 241 raw_pci_ops = &pci_mmcfg;
210 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 242 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
diff --git a/block/blktrace.c b/block/blktrace.c
index 265f7a830619..2b4ef2b89b8d 100644
--- a/block/blktrace.c
+++ b/block/blktrace.c
@@ -217,7 +217,7 @@ static int blk_trace_remove(request_queue_t *q)
217 217
218static int blk_dropped_open(struct inode *inode, struct file *filp) 218static int blk_dropped_open(struct inode *inode, struct file *filp)
219{ 219{
220 filp->private_data = inode->u.generic_ip; 220 filp->private_data = inode->i_private;
221 221
222 return 0; 222 return 0;
223} 223}
diff --git a/drivers/acorn/char/i2c.c b/drivers/acorn/char/i2c.c
index c26c08b36829..bdb9c8b78ed8 100644
--- a/drivers/acorn/char/i2c.c
+++ b/drivers/acorn/char/i2c.c
@@ -308,7 +308,6 @@ static struct i2c_algo_bit_data ioc_data = {
308 .getsda = ioc_getsda, 308 .getsda = ioc_getsda,
309 .getscl = ioc_getscl, 309 .getscl = ioc_getscl,
310 .udelay = 80, 310 .udelay = 80,
311 .mdelay = 80,
312 .timeout = 100 311 .timeout = 100
313}; 312};
314 313
diff --git a/drivers/acpi/i2c_ec.c b/drivers/acpi/i2c_ec.c
index 6809c283ec58..6342e612c203 100644
--- a/drivers/acpi/i2c_ec.c
+++ b/drivers/acpi/i2c_ec.c
@@ -293,7 +293,7 @@ static u32 acpi_ec_smb_func(struct i2c_adapter *adapter)
293 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC); 293 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC);
294} 294}
295 295
296static struct i2c_algorithm acpi_ec_smbus_algorithm = { 296static const struct i2c_algorithm acpi_ec_smbus_algorithm = {
297 .smbus_xfer = acpi_ec_smb_access, 297 .smbus_xfer = acpi_ec_smb_access,
298 .functionality = acpi_ec_smb_func, 298 .functionality = acpi_ec_smb_func,
299}; 299};
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 507f051d1cef..20beea778ea2 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1079,7 +1079,7 @@ acpi_status acpi_os_purge_cache(acpi_cache_t * cache)
1079 1079
1080acpi_status acpi_os_delete_cache(acpi_cache_t * cache) 1080acpi_status acpi_os_delete_cache(acpi_cache_t * cache)
1081{ 1081{
1082 (void)kmem_cache_destroy(cache); 1082 kmem_cache_destroy(cache);
1083 return (AE_OK); 1083 return (AE_OK);
1084} 1084}
1085 1085
diff --git a/drivers/base/base.h b/drivers/base/base.h
index c3b8dc98b8a7..d26644a59537 100644
--- a/drivers/base/base.h
+++ b/drivers/base/base.h
@@ -16,7 +16,7 @@ extern int cpu_dev_init(void);
16extern int attribute_container_init(void); 16extern int attribute_container_init(void);
17 17
18extern int bus_add_device(struct device * dev); 18extern int bus_add_device(struct device * dev);
19extern void bus_attach_device(struct device * dev); 19extern int bus_attach_device(struct device * dev);
20extern void bus_remove_device(struct device * dev); 20extern void bus_remove_device(struct device * dev);
21extern struct bus_type *get_bus(struct bus_type * bus); 21extern struct bus_type *get_bus(struct bus_type * bus);
22extern void put_bus(struct bus_type * bus); 22extern void put_bus(struct bus_type * bus);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 2e954d07175a..12173d16bea7 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -371,12 +371,20 @@ int bus_add_device(struct device * dev)
371 if (bus) { 371 if (bus) {
372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id); 372 pr_debug("bus %s: add device %s\n", bus->name, dev->bus_id);
373 error = device_add_attrs(bus, dev); 373 error = device_add_attrs(bus, dev);
374 if (!error) { 374 if (error)
375 sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id); 375 goto out;
376 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "subsystem"); 376 error = sysfs_create_link(&bus->devices.kobj,
377 sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus"); 377 &dev->kobj, dev->bus_id);
378 } 378 if (error)
379 goto out;
380 error = sysfs_create_link(&dev->kobj,
381 &dev->bus->subsys.kset.kobj, "subsystem");
382 if (error)
383 goto out;
384 error = sysfs_create_link(&dev->kobj,
385 &dev->bus->subsys.kset.kobj, "bus");
379 } 386 }
387out:
380 return error; 388 return error;
381} 389}
382 390
@@ -384,16 +392,24 @@ int bus_add_device(struct device * dev)
384 * bus_attach_device - add device to bus 392 * bus_attach_device - add device to bus
385 * @dev: device tried to attach to a driver 393 * @dev: device tried to attach to a driver
386 * 394 *
395 * - Add device to bus's list of devices.
387 * - Try to attach to driver. 396 * - Try to attach to driver.
388 */ 397 */
389void bus_attach_device(struct device * dev) 398int bus_attach_device(struct device * dev)
390{ 399{
391 struct bus_type * bus = dev->bus; 400 struct bus_type *bus = dev->bus;
401 int ret = 0;
392 402
393 if (bus) { 403 if (bus) {
394 device_attach(dev); 404 dev->is_registered = 1;
395 klist_add_tail(&dev->knode_bus, &bus->klist_devices); 405 ret = device_attach(dev);
406 if (ret >= 0) {
407 klist_add_tail(&dev->knode_bus, &bus->klist_devices);
408 ret = 0;
409 } else
410 dev->is_registered = 0;
396 } 411 }
412 return ret;
397} 413}
398 414
399/** 415/**
@@ -412,7 +428,8 @@ void bus_remove_device(struct device * dev)
412 sysfs_remove_link(&dev->kobj, "bus"); 428 sysfs_remove_link(&dev->kobj, "bus");
413 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id); 429 sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
414 device_remove_attrs(dev->bus, dev); 430 device_remove_attrs(dev->bus, dev);
415 klist_remove(&dev->knode_bus); 431 dev->is_registered = 0;
432 klist_del(&dev->knode_bus);
416 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id); 433 pr_debug("bus %s: remove device %s\n", dev->bus->name, dev->bus_id);
417 device_release_driver(dev); 434 device_release_driver(dev);
418 put_bus(dev->bus); 435 put_bus(dev->bus);
@@ -455,10 +472,17 @@ static void driver_remove_attrs(struct bus_type * bus, struct device_driver * dr
455 * Thanks to drivers making their tables __devinit, we can't allow manual 472 * Thanks to drivers making their tables __devinit, we can't allow manual
456 * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled. 473 * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled.
457 */ 474 */
458static void add_bind_files(struct device_driver *drv) 475static int __must_check add_bind_files(struct device_driver *drv)
459{ 476{
460 driver_create_file(drv, &driver_attr_unbind); 477 int ret;
461 driver_create_file(drv, &driver_attr_bind); 478
479 ret = driver_create_file(drv, &driver_attr_unbind);
480 if (ret == 0) {
481 ret = driver_create_file(drv, &driver_attr_bind);
482 if (ret)
483 driver_remove_file(drv, &driver_attr_unbind);
484 }
485 return ret;
462} 486}
463 487
464static void remove_bind_files(struct device_driver *drv) 488static void remove_bind_files(struct device_driver *drv)
@@ -467,7 +491,7 @@ static void remove_bind_files(struct device_driver *drv)
467 driver_remove_file(drv, &driver_attr_unbind); 491 driver_remove_file(drv, &driver_attr_unbind);
468} 492}
469#else 493#else
470static inline void add_bind_files(struct device_driver *drv) {} 494static inline int add_bind_files(struct device_driver *drv) { return 0; }
471static inline void remove_bind_files(struct device_driver *drv) {} 495static inline void remove_bind_files(struct device_driver *drv) {}
472#endif 496#endif
473 497
@@ -476,7 +500,7 @@ static inline void remove_bind_files(struct device_driver *drv) {}
476 * @drv: driver. 500 * @drv: driver.
477 * 501 *
478 */ 502 */
479int bus_add_driver(struct device_driver * drv) 503int bus_add_driver(struct device_driver *drv)
480{ 504{
481 struct bus_type * bus = get_bus(drv->bus); 505 struct bus_type * bus = get_bus(drv->bus);
482 int error = 0; 506 int error = 0;
@@ -484,27 +508,39 @@ int bus_add_driver(struct device_driver * drv)
484 if (bus) { 508 if (bus) {
485 pr_debug("bus %s: add driver %s\n", bus->name, drv->name); 509 pr_debug("bus %s: add driver %s\n", bus->name, drv->name);
486 error = kobject_set_name(&drv->kobj, "%s", drv->name); 510 error = kobject_set_name(&drv->kobj, "%s", drv->name);
487 if (error) { 511 if (error)
488 put_bus(bus); 512 goto out_put_bus;
489 return error;
490 }
491 drv->kobj.kset = &bus->drivers; 513 drv->kobj.kset = &bus->drivers;
492 if ((error = kobject_register(&drv->kobj))) { 514 if ((error = kobject_register(&drv->kobj)))
493 put_bus(bus); 515 goto out_put_bus;
494 return error;
495 }
496 516
497 driver_attach(drv); 517 error = driver_attach(drv);
518 if (error)
519 goto out_unregister;
498 klist_add_tail(&drv->knode_bus, &bus->klist_drivers); 520 klist_add_tail(&drv->knode_bus, &bus->klist_drivers);
499 module_add_driver(drv->owner, drv); 521 module_add_driver(drv->owner, drv);
500 522
501 driver_add_attrs(bus, drv); 523 error = driver_add_attrs(bus, drv);
502 add_bind_files(drv); 524 if (error) {
525 /* How the hell do we get out of this pickle? Give up */
526 printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
527 __FUNCTION__, drv->name);
528 }
529 error = add_bind_files(drv);
530 if (error) {
531 /* Ditto */
532 printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
533 __FUNCTION__, drv->name);
534 }
503 } 535 }
504 return error; 536 return error;
537out_unregister:
538 kobject_unregister(&drv->kobj);
539out_put_bus:
540 put_bus(bus);
541 return error;
505} 542}
506 543
507
508/** 544/**
509 * bus_remove_driver - delete driver from bus's knowledge. 545 * bus_remove_driver - delete driver from bus's knowledge.
510 * @drv: driver. 546 * @drv: driver.
@@ -530,16 +566,21 @@ void bus_remove_driver(struct device_driver * drv)
530 566
531 567
532/* Helper for bus_rescan_devices's iter */ 568/* Helper for bus_rescan_devices's iter */
533static int bus_rescan_devices_helper(struct device *dev, void *data) 569static int __must_check bus_rescan_devices_helper(struct device *dev,
570 void *data)
534{ 571{
572 int ret = 0;
573
535 if (!dev->driver) { 574 if (!dev->driver) {
536 if (dev->parent) /* Needed for USB */ 575 if (dev->parent) /* Needed for USB */
537 down(&dev->parent->sem); 576 down(&dev->parent->sem);
538 device_attach(dev); 577 ret = device_attach(dev);
539 if (dev->parent) 578 if (dev->parent)
540 up(&dev->parent->sem); 579 up(&dev->parent->sem);
580 if (ret > 0)
581 ret = 0;
541 } 582 }
542 return 0; 583 return ret < 0 ? ret : 0;
543} 584}
544 585
545/** 586/**
@@ -550,9 +591,9 @@ static int bus_rescan_devices_helper(struct device *dev, void *data)
550 * attached and rescan it against existing drivers to see if it matches 591 * attached and rescan it against existing drivers to see if it matches
551 * any by calling device_attach() for the unbound devices. 592 * any by calling device_attach() for the unbound devices.
552 */ 593 */
553void bus_rescan_devices(struct bus_type * bus) 594int bus_rescan_devices(struct bus_type * bus)
554{ 595{
555 bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper); 596 return bus_for_each_dev(bus, NULL, NULL, bus_rescan_devices_helper);
556} 597}
557 598
558/** 599/**
@@ -564,7 +605,7 @@ void bus_rescan_devices(struct bus_type * bus)
564 * to use if probing criteria changed during a devices lifetime and 605 * to use if probing criteria changed during a devices lifetime and
565 * driver attachment should change accordingly. 606 * driver attachment should change accordingly.
566 */ 607 */
567void device_reprobe(struct device *dev) 608int device_reprobe(struct device *dev)
568{ 609{
569 if (dev->driver) { 610 if (dev->driver) {
570 if (dev->parent) /* Needed for USB */ 611 if (dev->parent) /* Needed for USB */
@@ -573,14 +614,14 @@ void device_reprobe(struct device *dev)
573 if (dev->parent) 614 if (dev->parent)
574 up(&dev->parent->sem); 615 up(&dev->parent->sem);
575 } 616 }
576 617 return bus_rescan_devices_helper(dev, NULL);
577 bus_rescan_devices_helper(dev, NULL);
578} 618}
579EXPORT_SYMBOL_GPL(device_reprobe); 619EXPORT_SYMBOL_GPL(device_reprobe);
580 620
581struct bus_type * get_bus(struct bus_type * bus) 621struct bus_type *get_bus(struct bus_type *bus)
582{ 622{
583 return bus ? container_of(subsys_get(&bus->subsys), struct bus_type, subsys) : NULL; 623 return bus ? container_of(subsys_get(&bus->subsys),
624 struct bus_type, subsys) : NULL;
584} 625}
585 626
586void put_bus(struct bus_type * bus) 627void put_bus(struct bus_type * bus)
@@ -655,22 +696,6 @@ static void klist_devices_put(struct klist_node *n)
655 put_device(dev); 696 put_device(dev);
656} 697}
657 698
658static void klist_drivers_get(struct klist_node *n)
659{
660 struct device_driver *drv = container_of(n, struct device_driver,
661 knode_bus);
662
663 get_driver(drv);
664}
665
666static void klist_drivers_put(struct klist_node *n)
667{
668 struct device_driver *drv = container_of(n, struct device_driver,
669 knode_bus);
670
671 put_driver(drv);
672}
673
674/** 699/**
675 * bus_register - register a bus with the system. 700 * bus_register - register a bus with the system.
676 * @bus: bus. 701 * @bus: bus.
@@ -706,7 +731,7 @@ int bus_register(struct bus_type * bus)
706 goto bus_drivers_fail; 731 goto bus_drivers_fail;
707 732
708 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put); 733 klist_init(&bus->klist_devices, klist_devices_get, klist_devices_put);
709 klist_init(&bus->klist_drivers, klist_drivers_get, klist_drivers_put); 734 klist_init(&bus->klist_drivers, NULL, NULL);
710 bus_add_attrs(bus); 735 bus_add_attrs(bus);
711 736
712 pr_debug("bus type '%s' registered\n", bus->name); 737 pr_debug("bus type '%s' registered\n", bus->name);
diff --git a/drivers/base/class.c b/drivers/base/class.c
index de8908320f23..b06b0e2b9c62 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -19,6 +19,8 @@
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include "base.h" 20#include "base.h"
21 21
22extern struct subsystem devices_subsys;
23
22#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr) 24#define to_class_attr(_attr) container_of(_attr, struct class_attribute, attr)
23#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj) 25#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
24 26
@@ -197,7 +199,7 @@ static int class_device_create_uevent(struct class_device *class_dev,
197 * Note, the pointer created here is to be destroyed when finished by 199 * Note, the pointer created here is to be destroyed when finished by
198 * making a call to class_destroy(). 200 * making a call to class_destroy().
199 */ 201 */
200struct class *class_create(struct module *owner, char *name) 202struct class *class_create(struct module *owner, const char *name)
201{ 203{
202 struct class *cls; 204 struct class *cls;
203 int retval; 205 int retval;
@@ -361,7 +363,7 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
361 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); 363 pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
362 364
363 if (class_dev->dev) { 365 if (class_dev->dev) {
364 /* add physical device, backing this device */ 366 /* add device, backing this class device (deprecated) */
365 struct device *dev = class_dev->dev; 367 struct device *dev = class_dev->dev;
366 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); 368 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
367 369
@@ -679,7 +681,8 @@ int class_device_register(struct class_device *class_dev)
679struct class_device *class_device_create(struct class *cls, 681struct class_device *class_device_create(struct class *cls,
680 struct class_device *parent, 682 struct class_device *parent,
681 dev_t devt, 683 dev_t devt,
682 struct device *device, char *fmt, ...) 684 struct device *device,
685 const char *fmt, ...)
683{ 686{
684 va_list args; 687 va_list args;
685 struct class_device *class_dev = NULL; 688 struct class_device *class_dev = NULL;
@@ -839,6 +842,7 @@ int class_interface_register(struct class_interface *class_intf)
839{ 842{
840 struct class *parent; 843 struct class *parent;
841 struct class_device *class_dev; 844 struct class_device *class_dev;
845 struct device *dev;
842 846
843 if (!class_intf || !class_intf->class) 847 if (!class_intf || !class_intf->class)
844 return -ENODEV; 848 return -ENODEV;
@@ -853,6 +857,10 @@ int class_interface_register(struct class_interface *class_intf)
853 list_for_each_entry(class_dev, &parent->children, node) 857 list_for_each_entry(class_dev, &parent->children, node)
854 class_intf->add(class_dev, class_intf); 858 class_intf->add(class_dev, class_intf);
855 } 859 }
860 if (class_intf->add_dev) {
861 list_for_each_entry(dev, &parent->devices, node)
862 class_intf->add_dev(dev, class_intf);
863 }
856 up(&parent->sem); 864 up(&parent->sem);
857 865
858 return 0; 866 return 0;
@@ -862,6 +870,7 @@ void class_interface_unregister(struct class_interface *class_intf)
862{ 870{
863 struct class * parent = class_intf->class; 871 struct class * parent = class_intf->class;
864 struct class_device *class_dev; 872 struct class_device *class_dev;
873 struct device *dev;
865 874
866 if (!parent) 875 if (!parent)
867 return; 876 return;
@@ -872,12 +881,31 @@ void class_interface_unregister(struct class_interface *class_intf)
872 list_for_each_entry(class_dev, &parent->children, node) 881 list_for_each_entry(class_dev, &parent->children, node)
873 class_intf->remove(class_dev, class_intf); 882 class_intf->remove(class_dev, class_intf);
874 } 883 }
884 if (class_intf->remove_dev) {
885 list_for_each_entry(dev, &parent->devices, node)
886 class_intf->remove_dev(dev, class_intf);
887 }
875 up(&parent->sem); 888 up(&parent->sem);
876 889
877 class_put(parent); 890 class_put(parent);
878} 891}
879 892
893int virtual_device_parent(struct device *dev)
894{
895 if (!dev->class)
896 return -ENODEV;
897
898 if (!dev->class->virtual_dir) {
899 static struct kobject *virtual_dir = NULL;
900
901 if (!virtual_dir)
902 virtual_dir = kobject_add_dir(&devices_subsys.kset.kobj, "virtual");
903 dev->class->virtual_dir = kobject_add_dir(virtual_dir, dev->class->name);
904 }
880 905
906 dev->kobj.parent = dev->class->virtual_dir;
907 return 0;
908}
881 909
882int __init classes_init(void) 910int __init classes_init(void)
883{ 911{
diff --git a/drivers/base/core.c b/drivers/base/core.c
index be6b5bc0677d..b224bb43ff63 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3,6 +3,8 @@
3 * 3 *
4 * Copyright (c) 2002-3 Patrick Mochel 4 * Copyright (c) 2002-3 Patrick Mochel
5 * Copyright (c) 2002-3 Open Source Development Labs 5 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2006 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (c) 2006 Novell, Inc.
6 * 8 *
7 * This file is released under the GPLv2 9 * This file is released under the GPLv2
8 * 10 *
@@ -92,6 +94,8 @@ static void device_release(struct kobject * kobj)
92 94
93 if (dev->release) 95 if (dev->release)
94 dev->release(dev); 96 dev->release(dev);
97 else if (dev->class && dev->class->dev_release)
98 dev->class->dev_release(dev);
95 else { 99 else {
96 printk(KERN_ERR "Device '%s' does not have a release() function, " 100 printk(KERN_ERR "Device '%s' does not have a release() function, "
97 "it is broken and must be fixed.\n", 101 "it is broken and must be fixed.\n",
@@ -149,17 +153,21 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
149 "MINOR=%u", MINOR(dev->devt)); 153 "MINOR=%u", MINOR(dev->devt));
150 } 154 }
151 155
152 /* add bus name of physical device */ 156 /* add bus name (same as SUBSYSTEM, deprecated) */
153 if (dev->bus) 157 if (dev->bus)
154 add_uevent_var(envp, num_envp, &i, 158 add_uevent_var(envp, num_envp, &i,
155 buffer, buffer_size, &length, 159 buffer, buffer_size, &length,
156 "PHYSDEVBUS=%s", dev->bus->name); 160 "PHYSDEVBUS=%s", dev->bus->name);
157 161
158 /* add driver name of physical device */ 162 /* add driver name (PHYSDEV* values are deprecated)*/
159 if (dev->driver) 163 if (dev->driver) {
164 add_uevent_var(envp, num_envp, &i,
165 buffer, buffer_size, &length,
166 "DRIVER=%s", dev->driver->name);
160 add_uevent_var(envp, num_envp, &i, 167 add_uevent_var(envp, num_envp, &i,
161 buffer, buffer_size, &length, 168 buffer, buffer_size, &length,
162 "PHYSDEVDRIVER=%s", dev->driver->name); 169 "PHYSDEVDRIVER=%s", dev->driver->name);
170 }
163 171
164 /* terminate, set to next free slot, shrink available space */ 172 /* terminate, set to next free slot, shrink available space */
165 envp[i] = NULL; 173 envp[i] = NULL;
@@ -177,6 +185,15 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
177 } 185 }
178 } 186 }
179 187
188 if (dev->class && dev->class->dev_uevent) {
189 /* have the class specific function add its stuff */
190 retval = dev->class->dev_uevent(dev, envp, num_envp, buffer, buffer_size);
191 if (retval) {
192 pr_debug("%s - dev_uevent() returned %d\n",
193 __FUNCTION__, retval);
194 }
195 }
196
180 return retval; 197 return retval;
181} 198}
182 199
@@ -193,6 +210,72 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
193 return count; 210 return count;
194} 211}
195 212
213static int device_add_groups(struct device *dev)
214{
215 int i;
216 int error = 0;
217
218 if (dev->groups) {
219 for (i = 0; dev->groups[i]; i++) {
220 error = sysfs_create_group(&dev->kobj, dev->groups[i]);
221 if (error) {
222 while (--i >= 0)
223 sysfs_remove_group(&dev->kobj, dev->groups[i]);
224 goto out;
225 }
226 }
227 }
228out:
229 return error;
230}
231
232static void device_remove_groups(struct device *dev)
233{
234 int i;
235 if (dev->groups) {
236 for (i = 0; dev->groups[i]; i++) {
237 sysfs_remove_group(&dev->kobj, dev->groups[i]);
238 }
239 }
240}
241
242static int device_add_attrs(struct device *dev)
243{
244 struct class *class = dev->class;
245 int error = 0;
246 int i;
247
248 if (!class)
249 return 0;
250
251 if (class->dev_attrs) {
252 for (i = 0; attr_name(class->dev_attrs[i]); i++) {
253 error = device_create_file(dev, &class->dev_attrs[i]);
254 if (error)
255 break;
256 }
257 }
258 if (error)
259 while (--i >= 0)
260 device_remove_file(dev, &class->dev_attrs[i]);
261 return error;
262}
263
264static void device_remove_attrs(struct device *dev)
265{
266 struct class *class = dev->class;
267 int i;
268
269 if (!class)
270 return;
271
272 if (class->dev_attrs) {
273 for (i = 0; attr_name(class->dev_attrs[i]); i++)
274 device_remove_file(dev, &class->dev_attrs[i]);
275 }
276}
277
278
196static ssize_t show_dev(struct device *dev, struct device_attribute *attr, 279static ssize_t show_dev(struct device *dev, struct device_attribute *attr,
197 char *buf) 280 char *buf)
198{ 281{
@@ -236,6 +319,32 @@ void device_remove_file(struct device * dev, struct device_attribute * attr)
236 } 319 }
237} 320}
238 321
322/**
323 * device_create_bin_file - create sysfs binary attribute file for device.
324 * @dev: device.
325 * @attr: device binary attribute descriptor.
326 */
327int device_create_bin_file(struct device *dev, struct bin_attribute *attr)
328{
329 int error = -EINVAL;
330 if (dev)
331 error = sysfs_create_bin_file(&dev->kobj, attr);
332 return error;
333}
334EXPORT_SYMBOL_GPL(device_create_bin_file);
335
336/**
337 * device_remove_bin_file - remove sysfs binary attribute file
338 * @dev: device.
339 * @attr: device binary attribute descriptor.
340 */
341void device_remove_bin_file(struct device *dev, struct bin_attribute *attr)
342{
343 if (dev)
344 sysfs_remove_bin_file(&dev->kobj, attr);
345}
346EXPORT_SYMBOL_GPL(device_remove_bin_file);
347
239static void klist_children_get(struct klist_node *n) 348static void klist_children_get(struct klist_node *n)
240{ 349{
241 struct device *dev = container_of(n, struct device, knode_parent); 350 struct device *dev = container_of(n, struct device, knode_parent);
@@ -289,12 +398,20 @@ int device_add(struct device *dev)
289{ 398{
290 struct device *parent = NULL; 399 struct device *parent = NULL;
291 char *class_name = NULL; 400 char *class_name = NULL;
401 struct class_interface *class_intf;
292 int error = -EINVAL; 402 int error = -EINVAL;
293 403
294 dev = get_device(dev); 404 dev = get_device(dev);
295 if (!dev || !strlen(dev->bus_id)) 405 if (!dev || !strlen(dev->bus_id))
296 goto Error; 406 goto Error;
297 407
408 /* if this is a class device, and has no parent, create one */
409 if ((dev->class) && (dev->parent == NULL)) {
410 error = virtual_device_parent(dev);
411 if (error)
412 goto Error;
413 }
414
298 parent = get_device(dev->parent); 415 parent = get_device(dev->parent);
299 416
300 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id); 417 pr_debug("DEV: registering device: ID = '%s'\n", dev->bus_id);
@@ -307,6 +424,10 @@ int device_add(struct device *dev)
307 if ((error = kobject_add(&dev->kobj))) 424 if ((error = kobject_add(&dev->kobj)))
308 goto Error; 425 goto Error;
309 426
427 /* notify platform of device entry */
428 if (platform_notify)
429 platform_notify(dev);
430
310 dev->uevent_attr.attr.name = "uevent"; 431 dev->uevent_attr.attr.name = "uevent";
311 dev->uevent_attr.attr.mode = S_IWUSR; 432 dev->uevent_attr.attr.mode = S_IWUSR;
312 if (dev->driver) 433 if (dev->driver)
@@ -340,12 +461,17 @@ int device_add(struct device *dev)
340 "subsystem"); 461 "subsystem");
341 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj, 462 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj,
342 dev->bus_id); 463 dev->bus_id);
343 464 if (parent) {
344 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device"); 465 sysfs_create_link(&dev->kobj, &dev->parent->kobj, "device");
345 class_name = make_class_name(dev->class->name, &dev->kobj); 466 class_name = make_class_name(dev->class->name, &dev->kobj);
346 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name); 467 sysfs_create_link(&dev->parent->kobj, &dev->kobj, class_name);
468 }
347 } 469 }
348 470
471 if ((error = device_add_attrs(dev)))
472 goto AttrsError;
473 if ((error = device_add_groups(dev)))
474 goto GroupError;
349 if ((error = device_pm_add(dev))) 475 if ((error = device_pm_add(dev)))
350 goto PMError; 476 goto PMError;
351 if ((error = bus_add_device(dev))) 477 if ((error = bus_add_device(dev)))
@@ -356,15 +482,16 @@ int device_add(struct device *dev)
356 klist_add_tail(&dev->knode_parent, &parent->klist_children); 482 klist_add_tail(&dev->knode_parent, &parent->klist_children);
357 483
358 if (dev->class) { 484 if (dev->class) {
359 /* tie the class to the device */
360 down(&dev->class->sem); 485 down(&dev->class->sem);
486 /* tie the class to the device */
361 list_add_tail(&dev->node, &dev->class->devices); 487 list_add_tail(&dev->node, &dev->class->devices);
488
489 /* notify any interfaces that the device is here */
490 list_for_each_entry(class_intf, &dev->class->interfaces, node)
491 if (class_intf->add_dev)
492 class_intf->add_dev(dev, class_intf);
362 up(&dev->class->sem); 493 up(&dev->class->sem);
363 } 494 }
364
365 /* notify platform of device entry */
366 if (platform_notify)
367 platform_notify(dev);
368 Done: 495 Done:
369 kfree(class_name); 496 kfree(class_name);
370 put_device(dev); 497 put_device(dev);
@@ -372,6 +499,10 @@ int device_add(struct device *dev)
372 BusError: 499 BusError:
373 device_pm_remove(dev); 500 device_pm_remove(dev);
374 PMError: 501 PMError:
502 device_remove_groups(dev);
503 GroupError:
504 device_remove_attrs(dev);
505 AttrsError:
375 if (dev->devt_attr) { 506 if (dev->devt_attr) {
376 device_remove_file(dev, dev->devt_attr); 507 device_remove_file(dev, dev->devt_attr);
377 kfree(dev->devt_attr); 508 kfree(dev->devt_attr);
@@ -449,6 +580,7 @@ void device_del(struct device * dev)
449{ 580{
450 struct device * parent = dev->parent; 581 struct device * parent = dev->parent;
451 char *class_name = NULL; 582 char *class_name = NULL;
583 struct class_interface *class_intf;
452 584
453 if (parent) 585 if (parent)
454 klist_del(&dev->knode_parent); 586 klist_del(&dev->knode_parent);
@@ -458,14 +590,23 @@ void device_del(struct device * dev)
458 sysfs_remove_link(&dev->kobj, "subsystem"); 590 sysfs_remove_link(&dev->kobj, "subsystem");
459 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id); 591 sysfs_remove_link(&dev->class->subsys.kset.kobj, dev->bus_id);
460 class_name = make_class_name(dev->class->name, &dev->kobj); 592 class_name = make_class_name(dev->class->name, &dev->kobj);
461 sysfs_remove_link(&dev->kobj, "device"); 593 if (parent) {
462 sysfs_remove_link(&dev->parent->kobj, class_name); 594 sysfs_remove_link(&dev->kobj, "device");
595 sysfs_remove_link(&dev->parent->kobj, class_name);
596 }
463 kfree(class_name); 597 kfree(class_name);
464 down(&dev->class->sem); 598 down(&dev->class->sem);
599 /* notify any interfaces that the device is now gone */
600 list_for_each_entry(class_intf, &dev->class->interfaces, node)
601 if (class_intf->remove_dev)
602 class_intf->remove_dev(dev, class_intf);
603 /* remove the device from the class list */
465 list_del_init(&dev->node); 604 list_del_init(&dev->node);
466 up(&dev->class->sem); 605 up(&dev->class->sem);
467 } 606 }
468 device_remove_file(dev, &dev->uevent_attr); 607 device_remove_file(dev, &dev->uevent_attr);
608 device_remove_groups(dev);
609 device_remove_attrs(dev);
469 610
470 /* Notify the platform of the removal, in case they 611 /* Notify the platform of the removal, in case they
471 * need to do anything... 612 * need to do anything...
@@ -579,7 +720,7 @@ static void device_create_release(struct device *dev)
579 * been created with a call to class_create(). 720 * been created with a call to class_create().
580 */ 721 */
581struct device *device_create(struct class *class, struct device *parent, 722struct device *device_create(struct class *class, struct device *parent,
582 dev_t devt, char *fmt, ...) 723 dev_t devt, const char *fmt, ...)
583{ 724{
584 va_list args; 725 va_list args;
585 struct device *dev = NULL; 726 struct device *dev = NULL;
@@ -587,10 +728,6 @@ struct device *device_create(struct class *class, struct device *parent,
587 728
588 if (class == NULL || IS_ERR(class)) 729 if (class == NULL || IS_ERR(class))
589 goto error; 730 goto error;
590 if (parent == NULL) {
591 printk(KERN_WARNING "%s does not work yet for NULL parents\n", __FUNCTION__);
592 goto error;
593 }
594 731
595 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 732 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
596 if (!dev) { 733 if (!dev) {
@@ -644,3 +781,58 @@ void device_destroy(struct class *class, dev_t devt)
644 device_unregister(dev); 781 device_unregister(dev);
645} 782}
646EXPORT_SYMBOL_GPL(device_destroy); 783EXPORT_SYMBOL_GPL(device_destroy);
784
785/**
786 * device_rename - renames a device
787 * @dev: the pointer to the struct device to be renamed
788 * @new_name: the new name of the device
789 */
790int device_rename(struct device *dev, char *new_name)
791{
792 char *old_class_name = NULL;
793 char *new_class_name = NULL;
794 char *old_symlink_name = NULL;
795 int error;
796
797 dev = get_device(dev);
798 if (!dev)
799 return -EINVAL;
800
801 pr_debug("DEVICE: renaming '%s' to '%s'\n", dev->bus_id, new_name);
802
803 if ((dev->class) && (dev->parent))
804 old_class_name = make_class_name(dev->class->name, &dev->kobj);
805
806 if (dev->class) {
807 old_symlink_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL);
808 if (!old_symlink_name)
809 return -ENOMEM;
810 strlcpy(old_symlink_name, dev->bus_id, BUS_ID_SIZE);
811 }
812
813 strlcpy(dev->bus_id, new_name, BUS_ID_SIZE);
814
815 error = kobject_rename(&dev->kobj, new_name);
816
817 if (old_class_name) {
818 new_class_name = make_class_name(dev->class->name, &dev->kobj);
819 if (new_class_name) {
820 sysfs_create_link(&dev->parent->kobj, &dev->kobj,
821 new_class_name);
822 sysfs_remove_link(&dev->parent->kobj, old_class_name);
823 }
824 }
825 if (dev->class) {
826 sysfs_remove_link(&dev->class->subsys.kset.kobj,
827 old_symlink_name);
828 sysfs_create_link(&dev->class->subsys.kset.kobj, &dev->kobj,
829 dev->bus_id);
830 }
831 put_device(dev);
832
833 kfree(old_class_name);
834 kfree(new_class_name);
835 kfree(old_symlink_name);
836
837 return error;
838}
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 889c71111239..b5f43c3e44fa 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -17,6 +17,7 @@
17 17
18#include <linux/device.h> 18#include <linux/device.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/kthread.h>
20 21
21#include "base.h" 22#include "base.h"
22#include "power/power.h" 23#include "power/power.h"
@@ -38,66 +39,73 @@
38 * 39 *
39 * This function must be called with @dev->sem held. 40 * This function must be called with @dev->sem held.
40 */ 41 */
41void device_bind_driver(struct device * dev) 42int device_bind_driver(struct device *dev)
42{ 43{
43 if (klist_node_attached(&dev->knode_driver)) 44 int ret;
44 return; 45
46 if (klist_node_attached(&dev->knode_driver)) {
47 printk(KERN_WARNING "%s: device %s already bound\n",
48 __FUNCTION__, kobject_name(&dev->kobj));
49 return 0;
50 }
45 51
46 pr_debug("bound device '%s' to driver '%s'\n", 52 pr_debug("bound device '%s' to driver '%s'\n",
47 dev->bus_id, dev->driver->name); 53 dev->bus_id, dev->driver->name);
48 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices); 54 klist_add_tail(&dev->knode_driver, &dev->driver->klist_devices);
49 sysfs_create_link(&dev->driver->kobj, &dev->kobj, 55 ret = sysfs_create_link(&dev->driver->kobj, &dev->kobj,
50 kobject_name(&dev->kobj)); 56 kobject_name(&dev->kobj));
51 sysfs_create_link(&dev->kobj, &dev->driver->kobj, "driver"); 57 if (ret == 0) {
58 ret = sysfs_create_link(&dev->kobj, &dev->driver->kobj,
59 "driver");
60 if (ret)
61 sysfs_remove_link(&dev->driver->kobj,
62 kobject_name(&dev->kobj));
63 }
64 return ret;
52} 65}
53 66
54/** 67struct stupid_thread_structure {
55 * driver_probe_device - attempt to bind device & driver. 68 struct device_driver *drv;
56 * @drv: driver. 69 struct device *dev;
57 * @dev: device. 70};
58 * 71
59 * First, we call the bus's match function, if one present, which 72static atomic_t probe_count = ATOMIC_INIT(0);
60 * should compare the device IDs the driver supports with the 73static int really_probe(void *void_data)
61 * device IDs of the device. Note we don't do this ourselves
62 * because we don't know the format of the ID structures, nor what
63 * is to be considered a match and what is not.
64 *
65 * This function returns 1 if a match is found, an error if one
66 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
67 *
68 * This function must be called with @dev->sem held. When called
69 * for a USB interface, @dev->parent->sem must be held as well.
70 */
71int driver_probe_device(struct device_driver * drv, struct device * dev)
72{ 74{
75 struct stupid_thread_structure *data = void_data;
76 struct device_driver *drv = data->drv;
77 struct device *dev = data->dev;
73 int ret = 0; 78 int ret = 0;
74 79
75 if (drv->bus->match && !drv->bus->match(dev, drv)) 80 atomic_inc(&probe_count);
76 goto Done; 81 pr_debug("%s: Probing driver %s with device %s\n",
82 drv->bus->name, drv->name, dev->bus_id);
77 83
78 pr_debug("%s: Matched Device %s with Driver %s\n",
79 drv->bus->name, dev->bus_id, drv->name);
80 dev->driver = drv; 84 dev->driver = drv;
81 if (dev->bus->probe) { 85 if (dev->bus->probe) {
82 ret = dev->bus->probe(dev); 86 ret = dev->bus->probe(dev);
83 if (ret) { 87 if (ret) {
84 dev->driver = NULL; 88 dev->driver = NULL;
85 goto ProbeFailed; 89 goto probe_failed;
86 } 90 }
87 } else if (drv->probe) { 91 } else if (drv->probe) {
88 ret = drv->probe(dev); 92 ret = drv->probe(dev);
89 if (ret) { 93 if (ret) {
90 dev->driver = NULL; 94 dev->driver = NULL;
91 goto ProbeFailed; 95 goto probe_failed;
92 } 96 }
93 } 97 }
94 device_bind_driver(dev); 98 if (device_bind_driver(dev)) {
99 printk(KERN_ERR "%s: device_bind_driver(%s) failed\n",
100 __FUNCTION__, dev->bus_id);
101 /* How does undo a ->probe? We're screwed. */
102 }
95 ret = 1; 103 ret = 1;
96 pr_debug("%s: Bound Device %s to Driver %s\n", 104 pr_debug("%s: Bound Device %s to Driver %s\n",
97 drv->bus->name, dev->bus_id, drv->name); 105 drv->bus->name, dev->bus_id, drv->name);
98 goto Done; 106 goto done;
99 107
100 ProbeFailed: 108probe_failed:
101 if (ret == -ENODEV || ret == -ENXIO) { 109 if (ret == -ENODEV || ret == -ENXIO) {
102 /* Driver matched, but didn't support device 110 /* Driver matched, but didn't support device
103 * or device not found. 111 * or device not found.
@@ -110,7 +118,71 @@ int driver_probe_device(struct device_driver * drv, struct device * dev)
110 "%s: probe of %s failed with error %d\n", 118 "%s: probe of %s failed with error %d\n",
111 drv->name, dev->bus_id, ret); 119 drv->name, dev->bus_id, ret);
112 } 120 }
113 Done: 121done:
122 kfree(data);
123 atomic_dec(&probe_count);
124 return ret;
125}
126
127/**
128 * driver_probe_done
129 * Determine if the probe sequence is finished or not.
130 *
131 * Should somehow figure out how to use a semaphore, not an atomic variable...
132 */
133int driver_probe_done(void)
134{
135 pr_debug("%s: probe_count = %d\n", __FUNCTION__,
136 atomic_read(&probe_count));
137 if (atomic_read(&probe_count))
138 return -EBUSY;
139 return 0;
140}
141
142/**
143 * driver_probe_device - attempt to bind device & driver together
144 * @drv: driver to bind a device to
145 * @dev: device to try to bind to the driver
146 *
147 * First, we call the bus's match function, if one present, which should
148 * compare the device IDs the driver supports with the device IDs of the
149 * device. Note we don't do this ourselves because we don't know the
150 * format of the ID structures, nor what is to be considered a match and
151 * what is not.
152 *
153 * This function returns 1 if a match is found, an error if one occurs
154 * (that is not -ENODEV or -ENXIO), and 0 otherwise.
155 *
156 * This function must be called with @dev->sem held. When called for a
157 * USB interface, @dev->parent->sem must be held as well.
158 */
159int driver_probe_device(struct device_driver * drv, struct device * dev)
160{
161 struct stupid_thread_structure *data;
162 struct task_struct *probe_task;
163 int ret = 0;
164
165 if (!device_is_registered(dev))
166 return -ENODEV;
167 if (drv->bus->match && !drv->bus->match(dev, drv))
168 goto done;
169
170 pr_debug("%s: Matched Device %s with Driver %s\n",
171 drv->bus->name, dev->bus_id, drv->name);
172
173 data = kmalloc(sizeof(*data), GFP_KERNEL);
174 data->drv = drv;
175 data->dev = dev;
176
177 if (drv->multithread_probe) {
178 probe_task = kthread_run(really_probe, data,
179 "probe-%s", dev->bus_id);
180 if (IS_ERR(probe_task))
181 ret = PTR_ERR(probe_task);
182 } else
183 ret = really_probe(data);
184
185done:
114 return ret; 186 return ret;
115} 187}
116 188
@@ -139,8 +211,9 @@ int device_attach(struct device * dev)
139 211
140 down(&dev->sem); 212 down(&dev->sem);
141 if (dev->driver) { 213 if (dev->driver) {
142 device_bind_driver(dev); 214 ret = device_bind_driver(dev);
143 ret = 1; 215 if (ret == 0)
216 ret = 1;
144 } else 217 } else
145 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach); 218 ret = bus_for_each_drv(dev->bus, NULL, dev, __device_attach);
146 up(&dev->sem); 219 up(&dev->sem);
@@ -182,9 +255,9 @@ static int __driver_attach(struct device * dev, void * data)
182 * returns 0 and the @dev->driver is set, we've found a 255 * returns 0 and the @dev->driver is set, we've found a
183 * compatible pair. 256 * compatible pair.
184 */ 257 */
185void driver_attach(struct device_driver * drv) 258int driver_attach(struct device_driver * drv)
186{ 259{
187 bus_for_each_dev(drv->bus, NULL, drv, __driver_attach); 260 return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
188} 261}
189 262
190/** 263/**
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 562600dd540a..1214cbd17d86 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -142,20 +142,6 @@ void put_driver(struct device_driver * drv)
142 kobject_put(&drv->kobj); 142 kobject_put(&drv->kobj);
143} 143}
144 144
145static void klist_devices_get(struct klist_node *n)
146{
147 struct device *dev = container_of(n, struct device, knode_driver);
148
149 get_device(dev);
150}
151
152static void klist_devices_put(struct klist_node *n)
153{
154 struct device *dev = container_of(n, struct device, knode_driver);
155
156 put_device(dev);
157}
158
159/** 145/**
160 * driver_register - register driver with bus 146 * driver_register - register driver with bus
161 * @drv: driver to register 147 * @drv: driver to register
@@ -175,7 +161,7 @@ int driver_register(struct device_driver * drv)
175 (drv->bus->shutdown && drv->shutdown)) { 161 (drv->bus->shutdown && drv->shutdown)) {
176 printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name); 162 printk(KERN_WARNING "Driver '%s' needs updating - please use bus_type methods\n", drv->name);
177 } 163 }
178 klist_init(&drv->klist_devices, klist_devices_get, klist_devices_put); 164 klist_init(&drv->klist_devices, NULL, NULL);
179 init_completion(&drv->unloaded); 165 init_completion(&drv->unloaded);
180 return bus_add_driver(drv); 166 return bus_add_driver(drv);
181} 167}
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5d6c011183f5..77bf8826e2f9 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -602,7 +602,7 @@ firmware_class_exit(void)
602 class_unregister(&firmware_class); 602 class_unregister(&firmware_class);
603} 603}
604 604
605module_init(firmware_class_init); 605fs_initcall(firmware_class_init);
606module_exit(firmware_class_exit); 606module_exit(firmware_class_exit);
607 607
608EXPORT_SYMBOL(release_firmware); 608EXPORT_SYMBOL(release_firmware);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 2b8755db76c6..940ce41f1887 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -505,12 +505,36 @@ static int platform_match(struct device * dev, struct device_driver * drv)
505 return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0); 505 return (strncmp(pdev->name, drv->name, BUS_ID_SIZE) == 0);
506} 506}
507 507
508static int platform_suspend(struct device * dev, pm_message_t state) 508static int platform_suspend(struct device *dev, pm_message_t mesg)
509{ 509{
510 int ret = 0; 510 int ret = 0;
511 511
512 if (dev->driver && dev->driver->suspend) 512 if (dev->driver && dev->driver->suspend)
513 ret = dev->driver->suspend(dev, state); 513 ret = dev->driver->suspend(dev, mesg);
514
515 return ret;
516}
517
518static int platform_suspend_late(struct device *dev, pm_message_t mesg)
519{
520 struct platform_driver *drv = to_platform_driver(dev->driver);
521 struct platform_device *pdev = container_of(dev, struct platform_device, dev);
522 int ret = 0;
523
524 if (dev->driver && drv->suspend_late)
525 ret = drv->suspend_late(pdev, mesg);
526
527 return ret;
528}
529
530static int platform_resume_early(struct device *dev)
531{
532 struct platform_driver *drv = to_platform_driver(dev->driver);
533 struct platform_device *pdev = container_of(dev, struct platform_device, dev);
534 int ret = 0;
535
536 if (dev->driver && drv->resume_early)
537 ret = drv->resume_early(pdev);
514 538
515 return ret; 539 return ret;
516} 540}
@@ -531,6 +555,8 @@ struct bus_type platform_bus_type = {
531 .match = platform_match, 555 .match = platform_match,
532 .uevent = platform_uevent, 556 .uevent = platform_uevent,
533 .suspend = platform_suspend, 557 .suspend = platform_suspend,
558 .suspend_late = platform_suspend_late,
559 .resume_early = platform_resume_early,
534 .resume = platform_resume, 560 .resume = platform_resume,
535}; 561};
536EXPORT_SYMBOL_GPL(platform_bus_type); 562EXPORT_SYMBOL_GPL(platform_bus_type);
diff --git a/drivers/base/power/resume.c b/drivers/base/power/resume.c
index 826093ef4c7e..020be36705a6 100644
--- a/drivers/base/power/resume.c
+++ b/drivers/base/power/resume.c
@@ -38,13 +38,35 @@ int resume_device(struct device * dev)
38 dev_dbg(dev,"resuming\n"); 38 dev_dbg(dev,"resuming\n");
39 error = dev->bus->resume(dev); 39 error = dev->bus->resume(dev);
40 } 40 }
41 if (dev->class && dev->class->resume) {
42 dev_dbg(dev,"class resume\n");
43 error = dev->class->resume(dev);
44 }
41 up(&dev->sem); 45 up(&dev->sem);
42 TRACE_RESUME(error); 46 TRACE_RESUME(error);
43 return error; 47 return error;
44} 48}
45 49
46 50
51static int resume_device_early(struct device * dev)
52{
53 int error = 0;
47 54
55 TRACE_DEVICE(dev);
56 TRACE_RESUME(0);
57 if (dev->bus && dev->bus->resume_early) {
58 dev_dbg(dev,"EARLY resume\n");
59 error = dev->bus->resume_early(dev);
60 }
61 TRACE_RESUME(error);
62 return error;
63}
64
65/*
66 * Resume the devices that have either not gone through
67 * the late suspend, or that did go through it but also
68 * went through the early resume
69 */
48void dpm_resume(void) 70void dpm_resume(void)
49{ 71{
50 down(&dpm_list_sem); 72 down(&dpm_list_sem);
@@ -74,6 +96,7 @@ void dpm_resume(void)
74 96
75void device_resume(void) 97void device_resume(void)
76{ 98{
99 might_sleep();
77 down(&dpm_sem); 100 down(&dpm_sem);
78 dpm_resume(); 101 dpm_resume();
79 up(&dpm_sem); 102 up(&dpm_sem);
@@ -83,12 +106,12 @@ EXPORT_SYMBOL_GPL(device_resume);
83 106
84 107
85/** 108/**
86 * device_power_up_irq - Power on some devices. 109 * dpm_power_up - Power on some devices.
87 * 110 *
88 * Walk the dpm_off_irq list and power each device up. This 111 * Walk the dpm_off_irq list and power each device up. This
89 * is used for devices that required they be powered down with 112 * is used for devices that required they be powered down with
90 * interrupts disabled. As devices are powered on, they are moved to 113 * interrupts disabled. As devices are powered on, they are moved
91 * the dpm_suspended list. 114 * to the dpm_active list.
92 * 115 *
93 * Interrupts must be disabled when calling this. 116 * Interrupts must be disabled when calling this.
94 */ 117 */
@@ -99,16 +122,14 @@ void dpm_power_up(void)
99 struct list_head * entry = dpm_off_irq.next; 122 struct list_head * entry = dpm_off_irq.next;
100 struct device * dev = to_device(entry); 123 struct device * dev = to_device(entry);
101 124
102 get_device(dev); 125 list_move_tail(entry, &dpm_off);
103 list_move_tail(entry, &dpm_active); 126 resume_device_early(dev);
104 resume_device(dev);
105 put_device(dev);
106 } 127 }
107} 128}
108 129
109 130
110/** 131/**
111 * device_pm_power_up - Turn on all devices that need special attention. 132 * device_power_up - Turn on all devices that need special attention.
112 * 133 *
113 * Power on system devices then devices that required we shut them down 134 * Power on system devices then devices that required we shut them down
114 * with interrupts disabled. 135 * with interrupts disabled.
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 69509e02f703..ece136bf97e3 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -34,6 +34,7 @@ static inline char *suspend_verb(u32 event)
34 switch (event) { 34 switch (event) {
35 case PM_EVENT_SUSPEND: return "suspend"; 35 case PM_EVENT_SUSPEND: return "suspend";
36 case PM_EVENT_FREEZE: return "freeze"; 36 case PM_EVENT_FREEZE: return "freeze";
37 case PM_EVENT_PRETHAW: return "prethaw";
37 default: return "(unknown suspend event)"; 38 default: return "(unknown suspend event)";
38 } 39 }
39} 40}
@@ -65,7 +66,19 @@ int suspend_device(struct device * dev, pm_message_t state)
65 66
66 dev->power.prev_state = dev->power.power_state; 67 dev->power.prev_state = dev->power.power_state;
67 68
68 if (dev->bus && dev->bus->suspend && !dev->power.power_state.event) { 69 if (dev->class && dev->class->suspend && !dev->power.power_state.event) {
70 dev_dbg(dev, "class %s%s\n",
71 suspend_verb(state.event),
72 ((state.event == PM_EVENT_SUSPEND)
73 && device_may_wakeup(dev))
74 ? ", may wakeup"
75 : ""
76 );
77 error = dev->class->suspend(dev, state);
78 suspend_report_result(dev->class->suspend, error);
79 }
80
81 if (!error && dev->bus && dev->bus->suspend && !dev->power.power_state.event) {
69 dev_dbg(dev, "%s%s\n", 82 dev_dbg(dev, "%s%s\n",
70 suspend_verb(state.event), 83 suspend_verb(state.event),
71 ((state.event == PM_EVENT_SUSPEND) 84 ((state.event == PM_EVENT_SUSPEND)
@@ -81,15 +94,42 @@ int suspend_device(struct device * dev, pm_message_t state)
81} 94}
82 95
83 96
97/*
98 * This is called with interrupts off, only a single CPU
99 * running. We can't do down() on a semaphore (and we don't
100 * need the protection)
101 */
102static int suspend_device_late(struct device *dev, pm_message_t state)
103{
104 int error = 0;
105
106 if (dev->bus && dev->bus->suspend_late && !dev->power.power_state.event) {
107 dev_dbg(dev, "LATE %s%s\n",
108 suspend_verb(state.event),
109 ((state.event == PM_EVENT_SUSPEND)
110 && device_may_wakeup(dev))
111 ? ", may wakeup"
112 : ""
113 );
114 error = dev->bus->suspend_late(dev, state);
115 suspend_report_result(dev->bus->suspend_late, error);
116 }
117 return error;
118}
119
84/** 120/**
85 * device_suspend - Save state and stop all devices in system. 121 * device_suspend - Save state and stop all devices in system.
86 * @state: Power state to put each device in. 122 * @state: Power state to put each device in.
87 * 123 *
88 * Walk the dpm_active list, call ->suspend() for each device, and move 124 * Walk the dpm_active list, call ->suspend() for each device, and move
89 * it to dpm_off. 125 * it to the dpm_off list.
90 * Check the return value for each. If it returns 0, then we move the 126 *
91 * the device to the dpm_off list. If it returns -EAGAIN, we move it to 127 * (For historical reasons, if it returns -EAGAIN, that used to mean
92 * the dpm_off_irq list. If we get a different error, try and back out. 128 * that the device would be called again with interrupts disabled.
129 * These days, we use the "suspend_late()" callback for that, so we
130 * print a warning and consider it an error).
131 *
132 * If we get a different error, try and back out.
93 * 133 *
94 * If we hit a failure with any of the devices, call device_resume() 134 * If we hit a failure with any of the devices, call device_resume()
95 * above to bring the suspended devices back to life. 135 * above to bring the suspended devices back to life.
@@ -100,6 +140,7 @@ int device_suspend(pm_message_t state)
100{ 140{
101 int error = 0; 141 int error = 0;
102 142
143 might_sleep();
103 down(&dpm_sem); 144 down(&dpm_sem);
104 down(&dpm_list_sem); 145 down(&dpm_list_sem);
105 while (!list_empty(&dpm_active) && error == 0) { 146 while (!list_empty(&dpm_active) && error == 0) {
@@ -115,39 +156,27 @@ int device_suspend(pm_message_t state)
115 156
116 /* Check if the device got removed */ 157 /* Check if the device got removed */
117 if (!list_empty(&dev->power.entry)) { 158 if (!list_empty(&dev->power.entry)) {
118 /* Move it to the dpm_off or dpm_off_irq list */ 159 /* Move it to the dpm_off list */
119 if (!error) 160 if (!error)
120 list_move(&dev->power.entry, &dpm_off); 161 list_move(&dev->power.entry, &dpm_off);
121 else if (error == -EAGAIN) {
122 list_move(&dev->power.entry, &dpm_off_irq);
123 error = 0;
124 }
125 } 162 }
126 if (error) 163 if (error)
127 printk(KERN_ERR "Could not suspend device %s: " 164 printk(KERN_ERR "Could not suspend device %s: "
128 "error %d\n", kobject_name(&dev->kobj), error); 165 "error %d%s\n",
166 kobject_name(&dev->kobj), error,
167 error == -EAGAIN ? " (please convert to suspend_late)" : "");
129 put_device(dev); 168 put_device(dev);
130 } 169 }
131 up(&dpm_list_sem); 170 up(&dpm_list_sem);
132 if (error) { 171 if (error)
133 /* we failed... before resuming, bring back devices from
134 * dpm_off_irq list back to main dpm_off list, we do want
135 * to call resume() on them, in case they partially suspended
136 * despite returning -EAGAIN
137 */
138 while (!list_empty(&dpm_off_irq)) {
139 struct list_head * entry = dpm_off_irq.next;
140 list_move(entry, &dpm_off);
141 }
142 dpm_resume(); 172 dpm_resume();
143 } 173
144 up(&dpm_sem); 174 up(&dpm_sem);
145 return error; 175 return error;
146} 176}
147 177
148EXPORT_SYMBOL_GPL(device_suspend); 178EXPORT_SYMBOL_GPL(device_suspend);
149 179
150
151/** 180/**
152 * device_power_down - Shut down special devices. 181 * device_power_down - Shut down special devices.
153 * @state: Power state to enter. 182 * @state: Power state to enter.
@@ -162,14 +191,17 @@ int device_power_down(pm_message_t state)
162 int error = 0; 191 int error = 0;
163 struct device * dev; 192 struct device * dev;
164 193
165 list_for_each_entry_reverse(dev, &dpm_off_irq, power.entry) { 194 while (!list_empty(&dpm_off)) {
166 if ((error = suspend_device(dev, state))) 195 struct list_head * entry = dpm_off.prev;
167 break; 196
197 dev = to_device(entry);
198 error = suspend_device_late(dev, state);
199 if (error)
200 goto Error;
201 list_move(&dev->power.entry, &dpm_off_irq);
168 } 202 }
169 if (error) 203
170 goto Error; 204 error = sysdev_suspend(state);
171 if ((error = sysdev_suspend(state)))
172 goto Error;
173 Done: 205 Done:
174 return error; 206 return error;
175 Error: 207 Error:
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 40d7242a07c1..2d47517dbe32 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -7,22 +7,29 @@
7#include "power.h" 7#include "power.h"
8 8
9 9
10#ifdef CONFIG_PM_SYSFS_DEPRECATED
11
10/** 12/**
11 * state - Control current power state of device 13 * state - Control current power state of device
12 * 14 *
13 * show() returns the current power state of the device. '0' indicates 15 * show() returns the current power state of the device. '0' indicates
14 * the device is on. Other values (1-3) indicate the device is in a low 16 * the device is on. Other values (2) indicate the device is in some low
15 * power state. 17 * power state.
16 * 18 *
17 * store() sets the current power state, which is an integer value 19 * store() sets the current power state, which is an integer valued
18 * between 0-3. If the device is on ('0'), and the value written is 20 * 0, 2, or 3. Devices with bus.suspend_late(), or bus.resume_early()
19 * greater than 0, then the device is placed directly into the low-power 21 * methods fail this operation; those methods couldn't be called.
20 * state (via its driver's ->suspend() method). 22 * Otherwise,
21 * If the device is currently in a low-power state, and the value is 0, 23 *
22 * the device is powered back on (via the ->resume() method). 24 * - If the recorded dev->power.power_state.event matches the
23 * If the device is in a low-power state, and a different low-power state 25 * target value, nothing is done.
24 * is requested, the device is first resumed, then suspended into the new 26 * - If the recorded event code is nonzero, the device is reactivated
25 * low-power state. 27 * by calling bus.resume() and/or class.resume().
28 * - If the target value is nonzero, the device is suspended by
29 * calling class.suspend() and/or bus.suspend() with event code
30 * PM_EVENT_SUSPEND.
31 *
32 * This mechanism is DEPRECATED and should only be used for testing.
26 */ 33 */
27 34
28static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf) 35static ssize_t state_show(struct device * dev, struct device_attribute *attr, char * buf)
@@ -38,6 +45,10 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c
38 pm_message_t state; 45 pm_message_t state;
39 int error = -EINVAL; 46 int error = -EINVAL;
40 47
48 /* disallow incomplete suspend sequences */
49 if (dev->bus && (dev->bus->suspend_late || dev->bus->resume_early))
50 return error;
51
41 state.event = PM_EVENT_SUSPEND; 52 state.event = PM_EVENT_SUSPEND;
42 /* Older apps expected to write "3" here - confused with PCI D3 */ 53 /* Older apps expected to write "3" here - confused with PCI D3 */
43 if ((n == 1) && !strcmp(buf, "3")) 54 if ((n == 1) && !strcmp(buf, "3"))
@@ -57,6 +68,8 @@ static ssize_t state_store(struct device * dev, struct device_attribute *attr, c
57static DEVICE_ATTR(state, 0644, state_show, state_store); 68static DEVICE_ATTR(state, 0644, state_show, state_store);
58 69
59 70
71#endif /* CONFIG_PM_SYSFS_DEPRECATED */
72
60/* 73/*
61 * wakeup - Report/change current wakeup option for device 74 * wakeup - Report/change current wakeup option for device
62 * 75 *
@@ -130,7 +143,9 @@ static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
130 143
131 144
132static struct attribute * power_attrs[] = { 145static struct attribute * power_attrs[] = {
146#ifdef CONFIG_PM_SYSFS_DEPRECATED
133 &dev_attr_state.attr, 147 &dev_attr_state.attr,
148#endif
134 &dev_attr_wakeup.attr, 149 &dev_attr_wakeup.attr,
135 NULL, 150 NULL,
136}; 151};
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 7b3b94ddddcc..c774121684d7 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -662,7 +662,8 @@ static void do_loop_switch(struct loop_device *lo, struct switch_request *p)
662 662
663 mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask); 663 mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask);
664 lo->lo_backing_file = file; 664 lo->lo_backing_file = file;
665 lo->lo_blocksize = mapping->host->i_blksize; 665 lo->lo_blocksize = S_ISBLK(mapping->host->i_mode) ?
666 mapping->host->i_bdev->bd_block_size : PAGE_SIZE;
666 lo->old_gfp_mask = mapping_gfp_mask(mapping); 667 lo->old_gfp_mask = mapping_gfp_mask(mapping);
667 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); 668 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
668 complete(&p->wait); 669 complete(&p->wait);
@@ -794,7 +795,9 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
794 if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write) 795 if (!(lo_flags & LO_FLAGS_USE_AOPS) && !file->f_op->write)
795 lo_flags |= LO_FLAGS_READ_ONLY; 796 lo_flags |= LO_FLAGS_READ_ONLY;
796 797
797 lo_blocksize = inode->i_blksize; 798 lo_blocksize = S_ISBLK(inode->i_mode) ?
799 inode->i_bdev->bd_block_size : PAGE_SIZE;
800
798 error = 0; 801 error = 0;
799 } else { 802 } else {
800 goto out_putf; 803 goto out_putf;
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index d62b49fbf10c..45a8f402b07b 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -358,7 +358,7 @@ static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
358static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, 358static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
359 struct ub_scsi_cmd *cmd, struct ub_request *urq); 359 struct ub_scsi_cmd *cmd, struct ub_request *urq);
360static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 360static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
361static void ub_end_rq(struct request *rq, int uptodate); 361static void ub_end_rq(struct request *rq, unsigned int status);
362static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun, 362static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
363 struct ub_request *urq, struct ub_scsi_cmd *cmd); 363 struct ub_request *urq, struct ub_scsi_cmd *cmd);
364static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 364static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
@@ -639,9 +639,15 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
639 struct ub_request *urq; 639 struct ub_request *urq;
640 int n_elem; 640 int n_elem;
641 641
642 if (atomic_read(&sc->poison) || lun->changed) { 642 if (atomic_read(&sc->poison)) {
643 blkdev_dequeue_request(rq);
644 ub_end_rq(rq, DID_NO_CONNECT << 16);
645 return 0;
646 }
647
648 if (lun->changed && !blk_pc_request(rq)) {
643 blkdev_dequeue_request(rq); 649 blkdev_dequeue_request(rq);
644 ub_end_rq(rq, 0); 650 ub_end_rq(rq, SAM_STAT_CHECK_CONDITION);
645 return 0; 651 return 0;
646 } 652 }
647 653
@@ -693,7 +699,7 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
693 699
694drop: 700drop:
695 ub_put_cmd(lun, cmd); 701 ub_put_cmd(lun, cmd);
696 ub_end_rq(rq, 0); 702 ub_end_rq(rq, DID_ERROR << 16);
697 return 0; 703 return 0;
698} 704}
699 705
@@ -761,47 +767,53 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
761 struct ub_lun *lun = cmd->lun; 767 struct ub_lun *lun = cmd->lun;
762 struct ub_request *urq = cmd->back; 768 struct ub_request *urq = cmd->back;
763 struct request *rq; 769 struct request *rq;
764 int uptodate; 770 unsigned int scsi_status;
765 771
766 rq = urq->rq; 772 rq = urq->rq;
767 773
768 if (cmd->error == 0) { 774 if (cmd->error == 0) {
769 uptodate = 1;
770
771 if (blk_pc_request(rq)) { 775 if (blk_pc_request(rq)) {
772 if (cmd->act_len >= rq->data_len) 776 if (cmd->act_len >= rq->data_len)
773 rq->data_len = 0; 777 rq->data_len = 0;
774 else 778 else
775 rq->data_len -= cmd->act_len; 779 rq->data_len -= cmd->act_len;
776 } 780 }
781 scsi_status = 0;
777 } else { 782 } else {
778 uptodate = 0;
779
780 if (blk_pc_request(rq)) { 783 if (blk_pc_request(rq)) {
781 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */ 784 /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */
782 memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE); 785 memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE);
783 rq->sense_len = UB_SENSE_SIZE; 786 rq->sense_len = UB_SENSE_SIZE;
784 if (sc->top_sense[0] != 0) 787 if (sc->top_sense[0] != 0)
785 rq->errors = SAM_STAT_CHECK_CONDITION; 788 scsi_status = SAM_STAT_CHECK_CONDITION;
786 else 789 else
787 rq->errors = DID_ERROR << 16; 790 scsi_status = DID_ERROR << 16;
788 } else { 791 } else {
789 if (cmd->error == -EIO) { 792 if (cmd->error == -EIO) {
790 if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0) 793 if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0)
791 return; 794 return;
792 } 795 }
796 scsi_status = SAM_STAT_CHECK_CONDITION;
793 } 797 }
794 } 798 }
795 799
796 urq->rq = NULL; 800 urq->rq = NULL;
797 801
798 ub_put_cmd(lun, cmd); 802 ub_put_cmd(lun, cmd);
799 ub_end_rq(rq, uptodate); 803 ub_end_rq(rq, scsi_status);
800 blk_start_queue(lun->disk->queue); 804 blk_start_queue(lun->disk->queue);
801} 805}
802 806
803static void ub_end_rq(struct request *rq, int uptodate) 807static void ub_end_rq(struct request *rq, unsigned int scsi_status)
804{ 808{
809 int uptodate;
810
811 if (scsi_status == 0) {
812 uptodate = 1;
813 } else {
814 uptodate = 0;
815 rq->errors = scsi_status;
816 }
805 end_that_request_first(rq, uptodate, rq->hard_nr_sectors); 817 end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
806 end_that_request_last(rq, uptodate); 818 end_that_request_last(rq, uptodate);
807} 819}
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 52ea94b891f5..1b21c3a911d9 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -439,6 +439,14 @@ config SGI_MBCS
439 If you have an SGI Altix with an attached SABrick 439 If you have an SGI Altix with an attached SABrick
440 say Y or M here, otherwise say N. 440 say Y or M here, otherwise say N.
441 441
442config MSPEC
443 tristate "Memory special operations driver"
444 depends on IA64
445 help
446 If you have an ia64 and you want to enable memory special
447 operations support (formerly known as fetchop), say Y here,
448 otherwise say N.
449
442source "drivers/serial/Kconfig" 450source "drivers/serial/Kconfig"
443 451
444config UNIX98_PTYS 452config UNIX98_PTYS
@@ -739,7 +747,7 @@ config NVRAM
739 747
740config RTC 748config RTC
741 tristate "Enhanced Real Time Clock Support" 749 tristate "Enhanced Real Time Clock Support"
742 depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM 750 depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV && !ARM && !SUPERH
743 ---help--- 751 ---help---
744 If you say Y here and create a character special file /dev/rtc with 752 If you say Y here and create a character special file /dev/rtc with
745 major number 10 and minor number 135 using mknod ("man mknod"), you 753 major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 8c6dfc621520..b583d0cd9fbe 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -47,6 +47,7 @@ obj-$(CONFIG_HVC_RTAS) += hvc_rtas.o
47obj-$(CONFIG_HVC_DRIVER) += hvc_console.o 47obj-$(CONFIG_HVC_DRIVER) += hvc_console.o
48obj-$(CONFIG_RAW_DRIVER) += raw.o 48obj-$(CONFIG_RAW_DRIVER) += raw.o
49obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o 49obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
50obj-$(CONFIG_MSPEC) += mspec.o
50obj-$(CONFIG_MMTIMER) += mmtimer.o 51obj-$(CONFIG_MMTIMER) += mmtimer.o
51obj-$(CONFIG_VIOCONS) += viocons.o 52obj-$(CONFIG_VIOCONS) += viocons.o
52obj-$(CONFIG_VIOTAPE) += viotape.o 53obj-$(CONFIG_VIOTAPE) += viotape.o
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 8afba339f05a..58b0eb581114 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -868,8 +868,8 @@ int hpet_alloc(struct hpet_data *hdp)
868 do_div(temp, period); 868 do_div(temp, period);
869 hpetp->hp_tick_freq = temp; /* ticks per second */ 869 hpetp->hp_tick_freq = temp; /* ticks per second */
870 870
871 printk(KERN_INFO "hpet%d: at MMIO 0x%lx (virtual 0x%p), IRQ%s", 871 printk(KERN_INFO "hpet%d: at MMIO 0x%lx, IRQ%s",
872 hpetp->hp_which, hdp->hd_phys_address, hdp->hd_address, 872 hpetp->hp_which, hdp->hd_phys_address,
873 hpetp->hp_ntimer > 1 ? "s" : ""); 873 hpetp->hp_ntimer > 1 ? "s" : "");
874 for (i = 0; i < hpetp->hp_ntimer; i++) 874 for (i = 0; i < hpetp->hp_ntimer; i++)
875 printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]); 875 printk("%s %d", i > 0 ? "," : "", hdp->hd_irq[i]);
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 917b20402664..4ac70ec697f0 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -238,6 +238,32 @@ static pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
238} 238}
239#endif 239#endif
240 240
241#ifndef CONFIG_MMU
242static unsigned long get_unmapped_area_mem(struct file *file,
243 unsigned long addr,
244 unsigned long len,
245 unsigned long pgoff,
246 unsigned long flags)
247{
248 if (!valid_mmap_phys_addr_range(pgoff, len))
249 return (unsigned long) -EINVAL;
250 return pgoff;
251}
252
253/* can't do an in-place private mapping if there's no MMU */
254static inline int private_mapping_ok(struct vm_area_struct *vma)
255{
256 return vma->vm_flags & VM_MAYSHARE;
257}
258#else
259#define get_unmapped_area_mem NULL
260
261static inline int private_mapping_ok(struct vm_area_struct *vma)
262{
263 return 1;
264}
265#endif
266
241static int mmap_mem(struct file * file, struct vm_area_struct * vma) 267static int mmap_mem(struct file * file, struct vm_area_struct * vma)
242{ 268{
243 size_t size = vma->vm_end - vma->vm_start; 269 size_t size = vma->vm_end - vma->vm_start;
@@ -245,6 +271,9 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
245 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size)) 271 if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
246 return -EINVAL; 272 return -EINVAL;
247 273
274 if (!private_mapping_ok(vma))
275 return -ENOSYS;
276
248 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff, 277 vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
249 size, 278 size,
250 vma->vm_page_prot); 279 vma->vm_page_prot);
@@ -782,6 +811,7 @@ static const struct file_operations mem_fops = {
782 .write = write_mem, 811 .write = write_mem,
783 .mmap = mmap_mem, 812 .mmap = mmap_mem,
784 .open = open_mem, 813 .open = open_mem,
814 .get_unmapped_area = get_unmapped_area_mem,
785}; 815};
786 816
787static const struct file_operations kmem_fops = { 817static const struct file_operations kmem_fops = {
@@ -790,6 +820,7 @@ static const struct file_operations kmem_fops = {
790 .write = write_kmem, 820 .write = write_kmem,
791 .mmap = mmap_kmem, 821 .mmap = mmap_kmem,
792 .open = open_kmem, 822 .open = open_kmem,
823 .get_unmapped_area = get_unmapped_area_mem,
793}; 824};
794 825
795static const struct file_operations null_fops = { 826static const struct file_operations null_fops = {
@@ -815,6 +846,10 @@ static const struct file_operations zero_fops = {
815 .mmap = mmap_zero, 846 .mmap = mmap_zero,
816}; 847};
817 848
849/*
850 * capabilities for /dev/zero
851 * - permits private mappings, "copies" are taken of the source of zeros
852 */
818static struct backing_dev_info zero_bdi = { 853static struct backing_dev_info zero_bdi = {
819 .capabilities = BDI_CAP_MAP_COPY, 854 .capabilities = BDI_CAP_MAP_COPY,
820}; 855};
@@ -862,9 +897,13 @@ static int memory_open(struct inode * inode, struct file * filp)
862 switch (iminor(inode)) { 897 switch (iminor(inode)) {
863 case 1: 898 case 1:
864 filp->f_op = &mem_fops; 899 filp->f_op = &mem_fops;
900 filp->f_mapping->backing_dev_info =
901 &directly_mappable_cdev_bdi;
865 break; 902 break;
866 case 2: 903 case 2:
867 filp->f_op = &kmem_fops; 904 filp->f_op = &kmem_fops;
905 filp->f_mapping->backing_dev_info =
906 &directly_mappable_cdev_bdi;
868 break; 907 break;
869 case 3: 908 case 3:
870 filp->f_op = &null_fops; 909 filp->f_op = &null_fops;
diff --git a/drivers/char/mspec.c b/drivers/char/mspec.c
new file mode 100644
index 000000000000..5426b1e5595f
--- /dev/null
+++ b/drivers/char/mspec.c
@@ -0,0 +1,421 @@
1/*
2 * Copyright (C) 2001-2006 Silicon Graphics, Inc. All rights
3 * reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 */
9
10/*
11 * SN Platform Special Memory (mspec) Support
12 *
13 * This driver exports the SN special memory (mspec) facility to user
14 * processes.
15 * There are three types of memory made available thru this driver:
16 * fetchops, uncached and cached.
17 *
18 * Fetchops are atomic memory operations that are implemented in the
19 * memory controller on SGI SN hardware.
20 *
21 * Uncached are used for memory write combining feature of the ia64
22 * cpu.
23 *
24 * Cached are used for areas of memory that are used as cached addresses
25 * on our partition and used as uncached addresses from other partitions.
26 * Due to a design constraint of the SN2 Shub, you can not have processors
27 * on the same FSB perform both a cached and uncached reference to the
28 * same cache line. These special memory cached regions prevent the
29 * kernel from ever dropping in a TLB entry and therefore prevent the
30 * processor from ever speculating a cache line from this page.
31 */
32
33#include <linux/config.h>
34#include <linux/types.h>
35#include <linux/kernel.h>
36#include <linux/module.h>
37#include <linux/init.h>
38#include <linux/errno.h>
39#include <linux/miscdevice.h>
40#include <linux/spinlock.h>
41#include <linux/mm.h>
42#include <linux/vmalloc.h>
43#include <linux/string.h>
44#include <linux/slab.h>
45#include <linux/numa.h>
46#include <asm/page.h>
47#include <asm/system.h>
48#include <asm/pgtable.h>
49#include <asm/atomic.h>
50#include <asm/tlbflush.h>
51#include <asm/uncached.h>
52#include <asm/sn/addrs.h>
53#include <asm/sn/arch.h>
54#include <asm/sn/mspec.h>
55#include <asm/sn/sn_cpuid.h>
56#include <asm/sn/io.h>
57#include <asm/sn/bte.h>
58#include <asm/sn/shubio.h>
59
60
61#define FETCHOP_ID "SGI Fetchop,"
62#define CACHED_ID "Cached,"
63#define UNCACHED_ID "Uncached"
64#define REVISION "4.0"
65#define MSPEC_BASENAME "mspec"
66
67/*
68 * Page types allocated by the device.
69 */
70enum {
71 MSPEC_FETCHOP = 1,
72 MSPEC_CACHED,
73 MSPEC_UNCACHED
74};
75
76static int is_sn2;
77
78/*
79 * One of these structures is allocated when an mspec region is mmaped. The
80 * structure is pointed to by the vma->vm_private_data field in the vma struct.
81 * This structure is used to record the addresses of the mspec pages.
82 */
83struct vma_data {
84 atomic_t refcnt; /* Number of vmas sharing the data. */
85 spinlock_t lock; /* Serialize access to the vma. */
86 int count; /* Number of pages allocated. */
87 int type; /* Type of pages allocated. */
88 unsigned long maddr[0]; /* Array of MSPEC addresses. */
89};
90
91/* used on shub2 to clear FOP cache in the HUB */
92static unsigned long scratch_page[MAX_NUMNODES];
93#define SH2_AMO_CACHE_ENTRIES 4
94
95static inline int
96mspec_zero_block(unsigned long addr, int len)
97{
98 int status;
99
100 if (is_sn2) {
101 if (is_shub2()) {
102 int nid;
103 void *p;
104 int i;
105
106 nid = nasid_to_cnodeid(get_node_number(__pa(addr)));
107 p = (void *)TO_AMO(scratch_page[nid]);
108
109 for (i=0; i < SH2_AMO_CACHE_ENTRIES; i++) {
110 FETCHOP_LOAD_OP(p, FETCHOP_LOAD);
111 p += FETCHOP_VAR_SIZE;
112 }
113 }
114
115 status = bte_copy(0, addr & ~__IA64_UNCACHED_OFFSET, len,
116 BTE_WACQUIRE | BTE_ZERO_FILL, NULL);
117 } else {
118 memset((char *) addr, 0, len);
119 status = 0;
120 }
121 return status;
122}
123
124/*
125 * mspec_open
126 *
127 * Called when a device mapping is created by a means other than mmap
128 * (via fork, etc.). Increments the reference count on the underlying
129 * mspec data so it is not freed prematurely.
130 */
131static void
132mspec_open(struct vm_area_struct *vma)
133{
134 struct vma_data *vdata;
135
136 vdata = vma->vm_private_data;
137 atomic_inc(&vdata->refcnt);
138}
139
140/*
141 * mspec_close
142 *
143 * Called when unmapping a device mapping. Frees all mspec pages
144 * belonging to the vma.
145 */
146static void
147mspec_close(struct vm_area_struct *vma)
148{
149 struct vma_data *vdata;
150 int i, pages, result, vdata_size;
151
152 vdata = vma->vm_private_data;
153 if (!atomic_dec_and_test(&vdata->refcnt))
154 return;
155
156 pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
157 vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
158 for (i = 0; i < pages; i++) {
159 if (vdata->maddr[i] == 0)
160 continue;
161 /*
162 * Clear the page before sticking it back
163 * into the pool.
164 */
165 result = mspec_zero_block(vdata->maddr[i], PAGE_SIZE);
166 if (!result)
167 uncached_free_page(vdata->maddr[i]);
168 else
169 printk(KERN_WARNING "mspec_close(): "
170 "failed to zero page %i\n",
171 result);
172 }
173
174 if (vdata_size <= PAGE_SIZE)
175 kfree(vdata);
176 else
177 vfree(vdata);
178}
179
180
181/*
182 * mspec_nopfn
183 *
184 * Creates a mspec page and maps it to user space.
185 */
186static unsigned long
187mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
188{
189 unsigned long paddr, maddr;
190 unsigned long pfn;
191 int index;
192 struct vma_data *vdata = vma->vm_private_data;
193
194 index = (address - vma->vm_start) >> PAGE_SHIFT;
195 maddr = (volatile unsigned long) vdata->maddr[index];
196 if (maddr == 0) {
197 maddr = uncached_alloc_page(numa_node_id());
198 if (maddr == 0)
199 return NOPFN_OOM;
200
201 spin_lock(&vdata->lock);
202 if (vdata->maddr[index] == 0) {
203 vdata->count++;
204 vdata->maddr[index] = maddr;
205 } else {
206 uncached_free_page(maddr);
207 maddr = vdata->maddr[index];
208 }
209 spin_unlock(&vdata->lock);
210 }
211
212 if (vdata->type == MSPEC_FETCHOP)
213 paddr = TO_AMO(maddr);
214 else
215 paddr = __pa(TO_CAC(maddr));
216
217 pfn = paddr >> PAGE_SHIFT;
218
219 return pfn;
220}
221
222static struct vm_operations_struct mspec_vm_ops = {
223 .open = mspec_open,
224 .close = mspec_close,
225 .nopfn = mspec_nopfn
226};
227
228/*
229 * mspec_mmap
230 *
231 * Called when mmaping the device. Initializes the vma with a fault handler
232 * and private data structure necessary to allocate, track, and free the
233 * underlying pages.
234 */
235static int
236mspec_mmap(struct file *file, struct vm_area_struct *vma, int type)
237{
238 struct vma_data *vdata;
239 int pages, vdata_size;
240
241 if (vma->vm_pgoff != 0)
242 return -EINVAL;
243
244 if ((vma->vm_flags & VM_SHARED) == 0)
245 return -EINVAL;
246
247 if ((vma->vm_flags & VM_WRITE) == 0)
248 return -EPERM;
249
250 pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
251 vdata_size = sizeof(struct vma_data) + pages * sizeof(long);
252 if (vdata_size <= PAGE_SIZE)
253 vdata = kmalloc(vdata_size, GFP_KERNEL);
254 else
255 vdata = vmalloc(vdata_size);
256 if (!vdata)
257 return -ENOMEM;
258 memset(vdata, 0, vdata_size);
259
260 vdata->type = type;
261 spin_lock_init(&vdata->lock);
262 vdata->refcnt = ATOMIC_INIT(1);
263 vma->vm_private_data = vdata;
264
265 vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED | VM_PFNMAP);
266 if (vdata->type == MSPEC_FETCHOP || vdata->type == MSPEC_UNCACHED)
267 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
268 vma->vm_ops = &mspec_vm_ops;
269
270 return 0;
271}
272
273static int
274fetchop_mmap(struct file *file, struct vm_area_struct *vma)
275{
276 return mspec_mmap(file, vma, MSPEC_FETCHOP);
277}
278
279static int
280cached_mmap(struct file *file, struct vm_area_struct *vma)
281{
282 return mspec_mmap(file, vma, MSPEC_CACHED);
283}
284
285static int
286uncached_mmap(struct file *file, struct vm_area_struct *vma)
287{
288 return mspec_mmap(file, vma, MSPEC_UNCACHED);
289}
290
291static struct file_operations fetchop_fops = {
292 .owner = THIS_MODULE,
293 .mmap = fetchop_mmap
294};
295
296static struct miscdevice fetchop_miscdev = {
297 .minor = MISC_DYNAMIC_MINOR,
298 .name = "sgi_fetchop",
299 .fops = &fetchop_fops
300};
301
302static struct file_operations cached_fops = {
303 .owner = THIS_MODULE,
304 .mmap = cached_mmap
305};
306
307static struct miscdevice cached_miscdev = {
308 .minor = MISC_DYNAMIC_MINOR,
309 .name = "mspec_cached",
310 .fops = &cached_fops
311};
312
313static struct file_operations uncached_fops = {
314 .owner = THIS_MODULE,
315 .mmap = uncached_mmap
316};
317
318static struct miscdevice uncached_miscdev = {
319 .minor = MISC_DYNAMIC_MINOR,
320 .name = "mspec_uncached",
321 .fops = &uncached_fops
322};
323
324/*
325 * mspec_init
326 *
327 * Called at boot time to initialize the mspec facility.
328 */
329static int __init
330mspec_init(void)
331{
332 int ret;
333 int nid;
334
335 /*
336 * The fetchop device only works on SN2 hardware, uncached and cached
337 * memory drivers should both be valid on all ia64 hardware
338 */
339 if (ia64_platform_is("sn2")) {
340 is_sn2 = 1;
341 if (is_shub2()) {
342 ret = -ENOMEM;
343 for_each_online_node(nid) {
344 int actual_nid;
345 int nasid;
346 unsigned long phys;
347
348 scratch_page[nid] = uncached_alloc_page(nid);
349 if (scratch_page[nid] == 0)
350 goto free_scratch_pages;
351 phys = __pa(scratch_page[nid]);
352 nasid = get_node_number(phys);
353 actual_nid = nasid_to_cnodeid(nasid);
354 if (actual_nid != nid)
355 goto free_scratch_pages;
356 }
357 }
358
359 ret = misc_register(&fetchop_miscdev);
360 if (ret) {
361 printk(KERN_ERR
362 "%s: failed to register device %i\n",
363 FETCHOP_ID, ret);
364 goto free_scratch_pages;
365 }
366 }
367 ret = misc_register(&cached_miscdev);
368 if (ret) {
369 printk(KERN_ERR "%s: failed to register device %i\n",
370 CACHED_ID, ret);
371 if (is_sn2)
372 misc_deregister(&fetchop_miscdev);
373 goto free_scratch_pages;
374 }
375 ret = misc_register(&uncached_miscdev);
376 if (ret) {
377 printk(KERN_ERR "%s: failed to register device %i\n",
378 UNCACHED_ID, ret);
379 misc_deregister(&cached_miscdev);
380 if (is_sn2)
381 misc_deregister(&fetchop_miscdev);
382 goto free_scratch_pages;
383 }
384
385 printk(KERN_INFO "%s %s initialized devices: %s %s %s\n",
386 MSPEC_BASENAME, REVISION, is_sn2 ? FETCHOP_ID : "",
387 CACHED_ID, UNCACHED_ID);
388
389 return 0;
390
391 free_scratch_pages:
392 for_each_node(nid) {
393 if (scratch_page[nid] != 0)
394 uncached_free_page(scratch_page[nid]);
395 }
396 return ret;
397}
398
399static void __exit
400mspec_exit(void)
401{
402 int nid;
403
404 misc_deregister(&uncached_miscdev);
405 misc_deregister(&cached_miscdev);
406 if (is_sn2) {
407 misc_deregister(&fetchop_miscdev);
408
409 for_each_node(nid) {
410 if (scratch_page[nid] != 0)
411 uncached_free_page(scratch_page[nid]);
412 }
413 }
414}
415
416module_init(mspec_init);
417module_exit(mspec_exit);
418
419MODULE_AUTHOR("Silicon Graphics, Inc. <linux-altix@sgi.com>");
420MODULE_DESCRIPTION("Driver for SGI SN special memory operations");
421MODULE_LICENSE("GPL");
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index fff89c2d88fd..f114d7b5bb2a 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -510,6 +510,14 @@ config SH_WDT
510 To compile this driver as a module, choose M here: the 510 To compile this driver as a module, choose M here: the
511 module will be called shwdt. 511 module will be called shwdt.
512 512
513config SH_WDT_MMAP
514 bool "Allow mmap of SH WDT"
515 default n
516 depends on SH_WDT
517 help
518 If you say Y here, user applications will be able to mmap the
519 WDT/CPG registers.
520#
513# SPARC64 Architecture 521# SPARC64 Architecture
514 522
515config WATCHDOG_CP1XXX 523config WATCHDOG_CP1XXX
diff --git a/drivers/char/watchdog/shwdt.c b/drivers/char/watchdog/shwdt.c
index 1355038f1044..e5b8c64f1d65 100644
--- a/drivers/char/watchdog/shwdt.c
+++ b/drivers/char/watchdog/shwdt.c
@@ -27,7 +27,7 @@
27#include <linux/notifier.h> 27#include <linux/notifier.h>
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30 30#include <linux/mm.h>
31#include <asm/io.h> 31#include <asm/io.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <asm/watchdog.h> 33#include <asm/watchdog.h>
@@ -125,7 +125,6 @@ static void sh_wdt_start(void)
125 125
126/** 126/**
127 * sh_wdt_stop - Stop the Watchdog 127 * sh_wdt_stop - Stop the Watchdog
128 *
129 * Stops the watchdog. 128 * Stops the watchdog.
130 */ 129 */
131static void sh_wdt_stop(void) 130static void sh_wdt_stop(void)
@@ -141,22 +140,20 @@ static void sh_wdt_stop(void)
141 140
142/** 141/**
143 * sh_wdt_keepalive - Keep the Userspace Watchdog Alive 142 * sh_wdt_keepalive - Keep the Userspace Watchdog Alive
144 *
145 * The Userspace watchdog got a KeepAlive: schedule the next heartbeat. 143 * The Userspace watchdog got a KeepAlive: schedule the next heartbeat.
146 */ 144 */
147static void sh_wdt_keepalive(void) 145static inline void sh_wdt_keepalive(void)
148{ 146{
149 next_heartbeat = jiffies + (heartbeat * HZ); 147 next_heartbeat = jiffies + (heartbeat * HZ);
150} 148}
151 149
152/** 150/**
153 * sh_wdt_set_heartbeat - Set the Userspace Watchdog heartbeat 151 * sh_wdt_set_heartbeat - Set the Userspace Watchdog heartbeat
154 *
155 * Set the Userspace Watchdog heartbeat 152 * Set the Userspace Watchdog heartbeat
156 */ 153 */
157static int sh_wdt_set_heartbeat(int t) 154static int sh_wdt_set_heartbeat(int t)
158{ 155{
159 if ((t < 1) || (t > 3600)) /* arbitrary upper limit */ 156 if (unlikely((t < 1) || (t > 3600))) /* arbitrary upper limit */
160 return -EINVAL; 157 return -EINVAL;
161 158
162 heartbeat = t; 159 heartbeat = t;
@@ -165,7 +162,6 @@ static int sh_wdt_set_heartbeat(int t)
165 162
166/** 163/**
167 * sh_wdt_ping - Ping the Watchdog 164 * sh_wdt_ping - Ping the Watchdog
168 *
169 * @data: Unused 165 * @data: Unused
170 * 166 *
171 * Clears overflow bit, resets timer counter. 167 * Clears overflow bit, resets timer counter.
@@ -182,14 +178,13 @@ static void sh_wdt_ping(unsigned long data)
182 sh_wdt_write_cnt(0); 178 sh_wdt_write_cnt(0);
183 179
184 mod_timer(&timer, next_ping_period(clock_division_ratio)); 180 mod_timer(&timer, next_ping_period(clock_division_ratio));
185 } else { 181 } else
186 printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n"); 182 printk(KERN_WARNING PFX "Heartbeat lost! Will not ping "
187 } 183 "the watchdog\n");
188} 184}
189 185
190/** 186/**
191 * sh_wdt_open - Open the Device 187 * sh_wdt_open - Open the Device
192 *
193 * @inode: inode of device 188 * @inode: inode of device
194 * @file: file handle of device 189 * @file: file handle of device
195 * 190 *
@@ -209,7 +204,6 @@ static int sh_wdt_open(struct inode *inode, struct file *file)
209 204
210/** 205/**
211 * sh_wdt_close - Close the Device 206 * sh_wdt_close - Close the Device
212 *
213 * @inode: inode of device 207 * @inode: inode of device
214 * @file: file handle of device 208 * @file: file handle of device
215 * 209 *
@@ -220,7 +214,8 @@ static int sh_wdt_close(struct inode *inode, struct file *file)
220 if (shwdt_expect_close == 42) { 214 if (shwdt_expect_close == 42) {
221 sh_wdt_stop(); 215 sh_wdt_stop();
222 } else { 216 } else {
223 printk(KERN_CRIT PFX "Unexpected close, not stopping watchdog!\n"); 217 printk(KERN_CRIT PFX "Unexpected close, not "
218 "stopping watchdog!\n");
224 sh_wdt_keepalive(); 219 sh_wdt_keepalive();
225 } 220 }
226 221
@@ -232,7 +227,6 @@ static int sh_wdt_close(struct inode *inode, struct file *file)
232 227
233/** 228/**
234 * sh_wdt_write - Write to Device 229 * sh_wdt_write - Write to Device
235 *
236 * @file: file handle of device 230 * @file: file handle of device
237 * @buf: buffer to write 231 * @buf: buffer to write
238 * @count: length of buffer 232 * @count: length of buffer
@@ -264,8 +258,56 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf,
264} 258}
265 259
266/** 260/**
267 * sh_wdt_ioctl - Query Device 261 * sh_wdt_mmap - map WDT/CPG registers into userspace
262 * @file: file structure for the device
263 * @vma: VMA to map the registers into
264 *
265 * A simple mmap() implementation for the corner cases where the counter
266 * needs to be mapped in userspace directly. Due to the relatively small
267 * size of the area, neighbouring registers not necessarily tied to the
268 * CPG will also be accessible through the register page, so this remains
269 * configurable for users that really know what they're doing.
268 * 270 *
271 * Additionaly, the register page maps in the CPG register base relative
272 * to the nearest page-aligned boundary, which requires that userspace do
273 * the appropriate CPU subtype math for calculating the page offset for
274 * the counter value.
275 */
276static int sh_wdt_mmap(struct file *file, struct vm_area_struct *vma)
277{
278 int ret = -ENOSYS;
279
280#ifdef CONFIG_SH_WDT_MMAP
281 unsigned long addr;
282
283 /* Only support the simple cases where we map in a register page. */
284 if (((vma->vm_end - vma->vm_start) != PAGE_SIZE) || vma->vm_pgoff)
285 return -EINVAL;
286
287 /*
288 * Pick WTCNT as the start, it's usually the first register after the
289 * FRQCR, and neither one are generally page-aligned out of the box.
290 */
291 addr = WTCNT & ~(PAGE_SIZE - 1);
292
293 vma->vm_flags |= VM_IO;
294 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
295
296 if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT,
297 PAGE_SIZE, vma->vm_page_prot)) {
298 printk(KERN_ERR PFX "%s: io_remap_pfn_range failed\n",
299 __FUNCTION__);
300 return -EAGAIN;
301 }
302
303 ret = 0;
304#endif
305
306 return ret;
307}
308
309/**
310 * sh_wdt_ioctl - Query Device
269 * @inode: inode of device 311 * @inode: inode of device
270 * @file: file handle of device 312 * @file: file handle of device
271 * @cmd: watchdog command 313 * @cmd: watchdog command
@@ -326,7 +368,6 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file,
326 368
327/** 369/**
328 * sh_wdt_notify_sys - Notifier Handler 370 * sh_wdt_notify_sys - Notifier Handler
329 *
330 * @this: notifier block 371 * @this: notifier block
331 * @code: notifier event 372 * @code: notifier event
332 * @unused: unused 373 * @unused: unused
@@ -337,9 +378,8 @@ static int sh_wdt_ioctl(struct inode *inode, struct file *file,
337static int sh_wdt_notify_sys(struct notifier_block *this, 378static int sh_wdt_notify_sys(struct notifier_block *this,
338 unsigned long code, void *unused) 379 unsigned long code, void *unused)
339{ 380{
340 if (code == SYS_DOWN || code == SYS_HALT) { 381 if (code == SYS_DOWN || code == SYS_HALT)
341 sh_wdt_stop(); 382 sh_wdt_stop();
342 }
343 383
344 return NOTIFY_DONE; 384 return NOTIFY_DONE;
345} 385}
@@ -351,10 +391,12 @@ static const struct file_operations sh_wdt_fops = {
351 .ioctl = sh_wdt_ioctl, 391 .ioctl = sh_wdt_ioctl,
352 .open = sh_wdt_open, 392 .open = sh_wdt_open,
353 .release = sh_wdt_close, 393 .release = sh_wdt_close,
394 .mmap = sh_wdt_mmap,
354}; 395};
355 396
356static struct watchdog_info sh_wdt_info = { 397static struct watchdog_info sh_wdt_info = {
357 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, 398 .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
399 WDIOF_MAGICCLOSE,
358 .firmware_version = 1, 400 .firmware_version = 1,
359 .identity = "SH WDT", 401 .identity = "SH WDT",
360}; 402};
@@ -371,7 +413,6 @@ static struct miscdevice sh_wdt_miscdev = {
371 413
372/** 414/**
373 * sh_wdt_init - Initialize module 415 * sh_wdt_init - Initialize module
374 *
375 * Registers the device and notifier handler. Actual device 416 * Registers the device and notifier handler. Actual device
376 * initialization is handled by sh_wdt_open(). 417 * initialization is handled by sh_wdt_open().
377 */ 418 */
@@ -381,15 +422,15 @@ static int __init sh_wdt_init(void)
381 422
382 if ((clock_division_ratio < 0x5) || (clock_division_ratio > 0x7)) { 423 if ((clock_division_ratio < 0x5) || (clock_division_ratio > 0x7)) {
383 clock_division_ratio = WTCSR_CKS_4096; 424 clock_division_ratio = WTCSR_CKS_4096;
384 printk(KERN_INFO PFX "clock_division_ratio value must be 0x5<=x<=0x7, using %d\n", 425 printk(KERN_INFO PFX "clock_division_ratio value must "
385 clock_division_ratio); 426 "be 0x5<=x<=0x7, using %d\n", clock_division_ratio);
386 } 427 }
387 428
388 if (sh_wdt_set_heartbeat(heartbeat)) 429 rc = sh_wdt_set_heartbeat(heartbeat);
389 { 430 if (unlikely(rc)) {
390 heartbeat = WATCHDOG_HEARTBEAT; 431 heartbeat = WATCHDOG_HEARTBEAT;
391 printk(KERN_INFO PFX "heartbeat value must be 1<=x<=3600, using %d\n", 432 printk(KERN_INFO PFX "heartbeat value must "
392 heartbeat); 433 "be 1<=x<=3600, using %d\n", heartbeat);
393 } 434 }
394 435
395 init_timer(&timer); 436 init_timer(&timer);
@@ -397,15 +438,16 @@ static int __init sh_wdt_init(void)
397 timer.data = 0; 438 timer.data = 0;
398 439
399 rc = register_reboot_notifier(&sh_wdt_notifier); 440 rc = register_reboot_notifier(&sh_wdt_notifier);
400 if (rc) { 441 if (unlikely(rc)) {
401 printk(KERN_ERR PFX "Can't register reboot notifier (err=%d)\n", rc); 442 printk(KERN_ERR PFX "Can't register reboot notifier (err=%d)\n",
443 rc);
402 return rc; 444 return rc;
403 } 445 }
404 446
405 rc = misc_register(&sh_wdt_miscdev); 447 rc = misc_register(&sh_wdt_miscdev);
406 if (rc) { 448 if (unlikely(rc)) {
407 printk(KERN_ERR PFX "Can't register miscdev on minor=%d (err=%d)\n", 449 printk(KERN_ERR PFX "Can't register miscdev on "
408 sh_wdt_miscdev.minor, rc); 450 "minor=%d (err=%d)\n", sh_wdt_miscdev.minor, rc);
409 unregister_reboot_notifier(&sh_wdt_notifier); 451 unregister_reboot_notifier(&sh_wdt_notifier);
410 return rc; 452 return rc;
411 } 453 }
@@ -418,7 +460,6 @@ static int __init sh_wdt_init(void)
418 460
419/** 461/**
420 * sh_wdt_exit - Deinitialize module 462 * sh_wdt_exit - Deinitialize module
421 *
422 * Unregisters the device and notifier handler. Actual device 463 * Unregisters the device and notifier handler. Actual device
423 * deinitialization is handled by sh_wdt_close(). 464 * deinitialization is handled by sh_wdt_close().
424 */ 465 */
@@ -434,14 +475,13 @@ MODULE_LICENSE("GPL");
434MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 475MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
435 476
436module_param(clock_division_ratio, int, 0); 477module_param(clock_division_ratio, int, 0);
437MODULE_PARM_DESC(clock_division_ratio, "Clock division ratio. Valid ranges are from 0x5 (1.31ms) to 0x7 (5.25ms). Defaults to 0x7."); 478MODULE_PARM_DESC(clock_division_ratio, "Clock division ratio. Valid ranges are from 0x5 (1.31ms) to 0x7 (5.25ms). (default=" __MODULE_STRING(clock_division_ratio) ")");
438 479
439module_param(heartbeat, int, 0); 480module_param(heartbeat, int, 0);
440MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<=heartbeat<=3600, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")"); 481MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (1<=heartbeat<=3600, default=" __MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
441 482
442module_param(nowayout, int, 0); 483module_param(nowayout, int, 0);
443MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 484MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
444 485
445module_init(sh_wdt_init); 486module_init(sh_wdt_init);
446module_exit(sh_wdt_exit); 487module_exit(sh_wdt_exit);
447
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 6078e2f58817..3a365e159d89 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -128,9 +128,23 @@ static int eisa_bus_match (struct device *dev, struct device_driver *drv)
128 return 0; 128 return 0;
129} 129}
130 130
131static int eisa_bus_uevent(struct device *dev, char **envp, int num_envp,
132 char *buffer, int buffer_size)
133{
134 struct eisa_device *edev = to_eisa_device(dev);
135 int i = 0;
136 int length = 0;
137
138 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
139 "MODALIAS=" EISA_DEVICE_MODALIAS_FMT, edev->id.sig);
140 envp[i] = NULL;
141 return 0;
142}
143
131struct bus_type eisa_bus_type = { 144struct bus_type eisa_bus_type = {
132 .name = "eisa", 145 .name = "eisa",
133 .match = eisa_bus_match, 146 .match = eisa_bus_match,
147 .uevent = eisa_bus_uevent,
134}; 148};
135 149
136int eisa_driver_register (struct eisa_driver *edrv) 150int eisa_driver_register (struct eisa_driver *edrv)
@@ -160,6 +174,14 @@ static ssize_t eisa_show_state (struct device *dev, struct device_attribute *att
160 174
161static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL); 175static DEVICE_ATTR(enabled, S_IRUGO, eisa_show_state, NULL);
162 176
177static ssize_t eisa_show_modalias (struct device *dev, struct device_attribute *attr, char *buf)
178{
179 struct eisa_device *edev = to_eisa_device (dev);
180 return sprintf (buf, EISA_DEVICE_MODALIAS_FMT "\n", edev->id.sig);
181}
182
183static DEVICE_ATTR(modalias, S_IRUGO, eisa_show_modalias, NULL);
184
163static int __init eisa_init_device (struct eisa_root_device *root, 185static int __init eisa_init_device (struct eisa_root_device *root,
164 struct eisa_device *edev, 186 struct eisa_device *edev,
165 int slot) 187 int slot)
@@ -209,6 +231,7 @@ static int __init eisa_register_device (struct eisa_device *edev)
209 231
210 device_create_file (&edev->dev, &dev_attr_signature); 232 device_create_file (&edev->dev, &dev_attr_signature);
211 device_create_file (&edev->dev, &dev_attr_enabled); 233 device_create_file (&edev->dev, &dev_attr_enabled);
234 device_create_file (&edev->dev, &dev_attr_modalias);
212 235
213 return 0; 236 return 0;
214} 237}
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 06df92b3ee49..b0ee57492228 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -243,6 +243,7 @@ static struct i2c_driver it87_driver = {
243 243
244static struct i2c_driver it87_isa_driver = { 244static struct i2c_driver it87_isa_driver = {
245 .driver = { 245 .driver = {
246 .owner = THIS_MODULE,
246 .name = "it87-isa", 247 .name = "it87-isa",
247 }, 248 },
248 .attach_adapter = it87_isa_attach_adapter, 249 .attach_adapter = it87_isa_attach_adapter,
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index a6ce7abf8602..fa1715b9a996 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -175,6 +175,7 @@ static struct i2c_driver lm78_driver = {
175 175
176static struct i2c_driver lm78_isa_driver = { 176static struct i2c_driver lm78_isa_driver = {
177 .driver = { 177 .driver = {
178 .owner = THIS_MODULE,
178 .name = "lm78-isa", 179 .name = "lm78-isa",
179 }, 180 },
180 .attach_adapter = lm78_isa_attach_adapter, 181 .attach_adapter = lm78_isa_attach_adapter,
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index ae05e483a778..236f9f29c624 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -238,6 +238,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
238 238
239static struct i2c_driver pc87360_driver = { 239static struct i2c_driver pc87360_driver = {
240 .driver = { 240 .driver = {
241 .owner = THIS_MODULE,
241 .name = "pc87360", 242 .name = "pc87360",
242 }, 243 },
243 .attach_adapter = pc87360_detect, 244 .attach_adapter = pc87360_detect,
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 063f71c5f07e..3783af4195bd 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -200,6 +200,7 @@ static void sis5595_init_client(struct i2c_client *client);
200 200
201static struct i2c_driver sis5595_driver = { 201static struct i2c_driver sis5595_driver = {
202 .driver = { 202 .driver = {
203 .owner = THIS_MODULE,
203 .name = "sis5595", 204 .name = "sis5595",
204 }, 205 },
205 .attach_adapter = sis5595_detect, 206 .attach_adapter = sis5595_detect,
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index b6086186d225..a85869393bab 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -228,6 +228,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter);
228 228
229static struct i2c_driver smsc47b397_driver = { 229static struct i2c_driver smsc47b397_driver = {
230 .driver = { 230 .driver = {
231 .owner = THIS_MODULE,
231 .name = "smsc47b397", 232 .name = "smsc47b397",
232 }, 233 },
233 .attach_adapter = smsc47b397_detect, 234 .attach_adapter = smsc47b397_detect,
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 825e8f72698f..6c81b843d831 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -128,6 +128,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
128 128
129static struct i2c_driver smsc47m1_driver = { 129static struct i2c_driver smsc47m1_driver = {
130 .driver = { 130 .driver = {
131 .owner = THIS_MODULE,
131 .name = "smsc47m1", 132 .name = "smsc47m1",
132 }, 133 },
133 .attach_adapter = smsc47m1_detect, 134 .attach_adapter = smsc47m1_detect,
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 166298f1f190..95ae056e5a94 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -574,6 +574,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
574 smbus_driver and isa_driver, and clients could be of either kind */ 574 smbus_driver and isa_driver, and clients could be of either kind */
575static struct i2c_driver via686a_driver = { 575static struct i2c_driver via686a_driver = {
576 .driver = { 576 .driver = {
577 .owner = THIS_MODULE,
577 .name = "via686a", 578 .name = "via686a",
578 }, 579 },
579 .attach_adapter = via686a_detect, 580 .attach_adapter = via686a_detect,
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 686f3deb3093..236ccf0e915d 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -587,6 +587,7 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
587 587
588static struct i2c_driver vt8231_driver = { 588static struct i2c_driver vt8231_driver = {
589 .driver = { 589 .driver = {
590 .owner = THIS_MODULE,
590 .name = "vt8231", 591 .name = "vt8231",
591 }, 592 },
592 .attach_adapter = vt8231_detect, 593 .attach_adapter = vt8231_detect,
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 40301bc6ce18..b21d6b9d7eac 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -903,6 +903,7 @@ static int w83627ehf_detach_client(struct i2c_client *client)
903 903
904static struct i2c_driver w83627ehf_driver = { 904static struct i2c_driver w83627ehf_driver = {
905 .driver = { 905 .driver = {
906 .owner = THIS_MODULE,
906 .name = "w83627ehf", 907 .name = "w83627ehf",
907 }, 908 },
908 .attach_adapter = w83627ehf_detect, 909 .attach_adapter = w83627ehf_detect,
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 79368d53c363..30295028ea99 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -339,6 +339,7 @@ static void w83627hf_init_client(struct i2c_client *client);
339 339
340static struct i2c_driver w83627hf_driver = { 340static struct i2c_driver w83627hf_driver = {
341 .driver = { 341 .driver = {
342 .owner = THIS_MODULE,
342 .name = "w83627hf", 343 .name = "w83627hf",
343 }, 344 },
344 .attach_adapter = w83627hf_detect, 345 .attach_adapter = w83627hf_detect,
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 7be469ed0f8f..95221b14e13a 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -288,6 +288,7 @@ static struct i2c_driver w83781d_driver = {
288 288
289static struct i2c_driver w83781d_isa_driver = { 289static struct i2c_driver w83781d_isa_driver = {
290 .driver = { 290 .driver = {
291 .owner = THIS_MODULE,
291 .name = "w83781d-isa", 292 .name = "w83781d-isa",
292 }, 293 },
293 .attach_adapter = w83781d_isa_attach_adapter, 294 .attach_adapter = w83781d_isa_attach_adapter,
diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 24383afdda76..11935f66fcd8 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -1,5 +1,5 @@
1# 1#
2# Character device configuration 2# I2C subsystem configuration
3# 3#
4 4
5menu "I2C support" 5menu "I2C support"
diff --git a/drivers/i2c/algos/Kconfig b/drivers/i2c/algos/Kconfig
index 30408015d231..c034820615bb 100644
--- a/drivers/i2c/algos/Kconfig
+++ b/drivers/i2c/algos/Kconfig
@@ -53,12 +53,6 @@ config I2C_ALGO8XX
53 tristate "MPC8xx CPM I2C interface" 53 tristate "MPC8xx CPM I2C interface"
54 depends on 8xx && I2C 54 depends on 8xx && I2C
55 55
56config I2C_ALGO_SIBYTE
57 tristate "SiByte SMBus interface"
58 depends on SIBYTE_SB1xxx_SOC && I2C
59 help
60 Supports the SiByte SOC on-chip I2C interfaces (2 channels).
61
62config I2C_ALGO_SGI 56config I2C_ALGO_SGI
63 tristate "I2C SGI interfaces" 57 tristate "I2C SGI interfaces"
64 depends on I2C && (SGI_IP22 || SGI_IP32 || X86_VISWS) 58 depends on I2C && (SGI_IP22 || SGI_IP32 || X86_VISWS)
diff --git a/drivers/i2c/algos/Makefile b/drivers/i2c/algos/Makefile
index 867fe1f67401..208be04a3dbd 100644
--- a/drivers/i2c/algos/Makefile
+++ b/drivers/i2c/algos/Makefile
@@ -6,7 +6,6 @@ obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o
6obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o 6obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o
7obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o 7obj-$(CONFIG_I2C_ALGOPCA) += i2c-algo-pca.o
8obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o 8obj-$(CONFIG_I2C_ALGOITE) += i2c-algo-ite.o
9obj-$(CONFIG_I2C_ALGO_SIBYTE) += i2c-algo-sibyte.o
10obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o 9obj-$(CONFIG_I2C_ALGO_SGI) += i2c-algo-sgi.o
11 10
12ifeq ($(CONFIG_I2C_DEBUG_ALGO),y) 11ifeq ($(CONFIG_I2C_DEBUG_ALGO),y)
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index ab230c033f99..21c36bfb5e6b 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -76,17 +76,15 @@ static inline void scllo(struct i2c_algo_bit_data *adap)
76 * Raise scl line, and do checking for delays. This is necessary for slower 76 * Raise scl line, and do checking for delays. This is necessary for slower
77 * devices. 77 * devices.
78 */ 78 */
79static inline int sclhi(struct i2c_algo_bit_data *adap) 79static int sclhi(struct i2c_algo_bit_data *adap)
80{ 80{
81 unsigned long start; 81 unsigned long start;
82 82
83 setscl(adap,1); 83 setscl(adap,1);
84 84
85 /* Not all adapters have scl sense line... */ 85 /* Not all adapters have scl sense line... */
86 if (adap->getscl == NULL ) { 86 if (!adap->getscl)
87 udelay(adap->udelay); 87 goto done;
88 return 0;
89 }
90 88
91 start=jiffies; 89 start=jiffies;
92 while (! getscl(adap) ) { 90 while (! getscl(adap) ) {
@@ -101,6 +99,8 @@ static inline int sclhi(struct i2c_algo_bit_data *adap)
101 cond_resched(); 99 cond_resched();
102 } 100 }
103 DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); 101 DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start));
102
103done:
104 udelay(adap->udelay); 104 udelay(adap->udelay);
105 return 0; 105 return 0;
106} 106}
@@ -121,7 +121,6 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap)
121 DEBPROTO(printk(" Sr ")); 121 DEBPROTO(printk(" Sr "));
122 setsda(adap,1); 122 setsda(adap,1);
123 sclhi(adap); 123 sclhi(adap);
124 udelay(adap->udelay);
125 124
126 sdalo(adap); 125 sdalo(adap);
127 scllo(adap); 126 scllo(adap);
@@ -306,7 +305,7 @@ bailout:
306 * 0 chip did not answer 305 * 0 chip did not answer
307 * -x transmission error 306 * -x transmission error
308 */ 307 */
309static inline int try_address(struct i2c_adapter *i2c_adap, 308static int try_address(struct i2c_adapter *i2c_adap,
310 unsigned char addr, int retries) 309 unsigned char addr, int retries)
311{ 310{
312 struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 311 struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
@@ -354,15 +353,11 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
354 return (retval<0)? retval : -EFAULT; 353 return (retval<0)? retval : -EFAULT;
355 /* got a better one ?? */ 354 /* got a better one ?? */
356 } 355 }
357#if 0
358 /* from asm/delay.h */
359 __delay(adap->mdelay * (loops_per_sec / 1000) );
360#endif
361 } 356 }
362 return wrcount; 357 return wrcount;
363} 358}
364 359
365static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) 360static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
366{ 361{
367 int inval; 362 int inval;
368 int rdcount=0; /* counts bytes read */ 363 int rdcount=0; /* counts bytes read */
@@ -412,7 +407,7 @@ static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
412 * -x an error occurred (like: -EREMOTEIO if the device did not answer, or 407 * -x an error occurred (like: -EREMOTEIO if the device did not answer, or
413 * -ETIMEDOUT, for example if the lines are stuck...) 408 * -ETIMEDOUT, for example if the lines are stuck...)
414 */ 409 */
415static inline int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) 410static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
416{ 411{
417 unsigned short flags = msg->flags; 412 unsigned short flags = msg->flags;
418 unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; 413 unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
@@ -517,7 +512,7 @@ static u32 bit_func(struct i2c_adapter *adap)
517 512
518/* -----exported algorithm data: ------------------------------------- */ 513/* -----exported algorithm data: ------------------------------------- */
519 514
520static struct i2c_algorithm i2c_bit_algo = { 515static const struct i2c_algorithm i2c_bit_algo = {
521 .master_xfer = bit_xfer, 516 .master_xfer = bit_xfer,
522 .functionality = bit_func, 517 .functionality = bit_func,
523}; 518};
diff --git a/drivers/i2c/algos/i2c-algo-pca.c b/drivers/i2c/algos/i2c-algo-pca.c
index b88a6fcf7bd0..9081c9fbcd29 100644
--- a/drivers/i2c/algos/i2c-algo-pca.c
+++ b/drivers/i2c/algos/i2c-algo-pca.c
@@ -355,7 +355,7 @@ static int pca_init(struct i2c_algo_pca_data *adap)
355 return 0; 355 return 0;
356} 356}
357 357
358static struct i2c_algorithm pca_algo = { 358static const struct i2c_algorithm pca_algo = {
359 .master_xfer = pca_xfer, 359 .master_xfer = pca_xfer,
360 .functionality = pca_func, 360 .functionality = pca_func,
361}; 361};
diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 5b24930adb5a..3b2003398966 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -458,7 +458,7 @@ static u32 pcf_func(struct i2c_adapter *adap)
458 458
459/* -----exported algorithm data: ------------------------------------- */ 459/* -----exported algorithm data: ------------------------------------- */
460 460
461static struct i2c_algorithm pcf_algo = { 461static const struct i2c_algorithm pcf_algo = {
462 .master_xfer = pcf_xfer, 462 .master_xfer = pcf_xfer,
463 .functionality = pcf_func, 463 .functionality = pcf_func,
464}; 464};
diff --git a/drivers/i2c/algos/i2c-algo-sgi.c b/drivers/i2c/algos/i2c-algo-sgi.c
index 932c4fa86c73..490d99997fd0 100644
--- a/drivers/i2c/algos/i2c-algo-sgi.c
+++ b/drivers/i2c/algos/i2c-algo-sgi.c
@@ -157,7 +157,7 @@ static u32 sgi_func(struct i2c_adapter *adap)
157 return I2C_FUNC_SMBUS_EMUL; 157 return I2C_FUNC_SMBUS_EMUL;
158} 158}
159 159
160static struct i2c_algorithm sgi_algo = { 160static const struct i2c_algorithm sgi_algo = {
161 .master_xfer = sgi_xfer, 161 .master_xfer = sgi_xfer,
162 .functionality = sgi_func, 162 .functionality = sgi_func,
163}; 163};
diff --git a/drivers/i2c/algos/i2c-algo-sibyte.c b/drivers/i2c/algos/i2c-algo-sibyte.c
deleted file mode 100644
index 32d41c6fac0f..000000000000
--- a/drivers/i2c/algos/i2c-algo-sibyte.c
+++ /dev/null
@@ -1,215 +0,0 @@
1/* ------------------------------------------------------------------------- */
2/* i2c-algo-sibyte.c i2c driver algorithms for bit-shift adapters */
3/* ------------------------------------------------------------------------- */
4/* Copyright (C) 2001,2002,2003 Broadcom Corporation
5 Copyright (C) 1995-2000 Simon G. Vogl
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/* With some changes from Kyösti Mälkki <kmalkki@cc.hut.fi> and even
23 Frodo Looijaard <frodol@dds.nl>. */
24
25/* Ported for SiByte SOCs by Broadcom Corporation. */
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/init.h>
30
31#include <asm/io.h>
32#include <asm/sibyte/sb1250_regs.h>
33#include <asm/sibyte/sb1250_smbus.h>
34
35#include <linux/i2c.h>
36#include <linux/i2c-algo-sibyte.h>
37
38/* ----- global defines ----------------------------------------------- */
39#define SMB_CSR(a,r) ((long)(a->reg_base + r))
40
41/* ----- global variables --------------------------------------------- */
42
43/* module parameters:
44 */
45static int bit_scan; /* have a look at what's hanging 'round */
46
47
48static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
49 unsigned short flags, char read_write,
50 u8 command, int size, union i2c_smbus_data * data)
51{
52 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
53 int data_bytes = 0;
54 int error;
55
56 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
57 ;
58
59 switch (size) {
60 case I2C_SMBUS_QUICK:
61 csr_out32((V_SMB_ADDR(addr) | (read_write == I2C_SMBUS_READ ? M_SMB_QDATA : 0) |
62 V_SMB_TT_QUICKCMD), SMB_CSR(adap, R_SMB_START));
63 break;
64 case I2C_SMBUS_BYTE:
65 if (read_write == I2C_SMBUS_READ) {
66 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_RD1BYTE),
67 SMB_CSR(adap, R_SMB_START));
68 data_bytes = 1;
69 } else {
70 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
71 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR1BYTE),
72 SMB_CSR(adap, R_SMB_START));
73 }
74 break;
75 case I2C_SMBUS_BYTE_DATA:
76 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
77 if (read_write == I2C_SMBUS_READ) {
78 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD1BYTE),
79 SMB_CSR(adap, R_SMB_START));
80 data_bytes = 1;
81 } else {
82 csr_out32(V_SMB_LB(data->byte), SMB_CSR(adap, R_SMB_DATA));
83 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE),
84 SMB_CSR(adap, R_SMB_START));
85 }
86 break;
87 case I2C_SMBUS_WORD_DATA:
88 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
89 if (read_write == I2C_SMBUS_READ) {
90 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD2BYTE),
91 SMB_CSR(adap, R_SMB_START));
92 data_bytes = 2;
93 } else {
94 csr_out32(V_SMB_LB(data->word & 0xff), SMB_CSR(adap, R_SMB_DATA));
95 csr_out32(V_SMB_MB(data->word >> 8), SMB_CSR(adap, R_SMB_DATA));
96 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE),
97 SMB_CSR(adap, R_SMB_START));
98 }
99 break;
100 default:
101 return -1; /* XXXKW better error code? */
102 }
103
104 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
105 ;
106
107 error = csr_in32(SMB_CSR(adap, R_SMB_STATUS));
108 if (error & M_SMB_ERROR) {
109 /* Clear error bit by writing a 1 */
110 csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
111 return -1; /* XXXKW better error code? */
112 }
113
114 if (data_bytes == 1)
115 data->byte = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xff;
116 if (data_bytes == 2)
117 data->word = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xffff;
118
119 return 0;
120}
121
122static int algo_control(struct i2c_adapter *adapter,
123 unsigned int cmd, unsigned long arg)
124{
125 return 0;
126}
127
128static u32 bit_func(struct i2c_adapter *adap)
129{
130 return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
131 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA);
132}
133
134
135/* -----exported algorithm data: ------------------------------------- */
136
137static struct i2c_algorithm i2c_sibyte_algo = {
138 .smbus_xfer = smbus_xfer,
139 .algo_control = algo_control, /* ioctl */
140 .functionality = bit_func,
141};
142
143/*
144 * registering functions to load algorithms at runtime
145 */
146int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
147{
148 int i;
149 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
150
151 /* register new adapter to i2c module... */
152 i2c_adap->algo = &i2c_sibyte_algo;
153
154 /* Set the frequency to 100 kHz */
155 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
156 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
157
158 /* scan bus */
159 if (bit_scan) {
160 union i2c_smbus_data data;
161 int rc;
162 printk(KERN_INFO " i2c-algo-sibyte.o: scanning bus %s.\n",
163 i2c_adap->name);
164 for (i = 0x00; i < 0x7f; i++) {
165 /* XXXKW is this a realistic probe? */
166 rc = smbus_xfer(i2c_adap, i, 0, I2C_SMBUS_READ, 0,
167 I2C_SMBUS_BYTE_DATA, &data);
168 if (!rc) {
169 printk("(%02x)",i);
170 } else
171 printk(".");
172 }
173 printk("\n");
174 }
175
176 return i2c_add_adapter(i2c_adap);
177}
178
179
180int i2c_sibyte_del_bus(struct i2c_adapter *adap)
181{
182 int res;
183
184 if ((res = i2c_del_adapter(adap)) < 0)
185 return res;
186
187 return 0;
188}
189
190int __init i2c_algo_sibyte_init (void)
191{
192 printk("i2c-algo-sibyte.o: i2c SiByte algorithm module\n");
193 return 0;
194}
195
196
197EXPORT_SYMBOL(i2c_sibyte_add_bus);
198EXPORT_SYMBOL(i2c_sibyte_del_bus);
199
200#ifdef MODULE
201MODULE_AUTHOR("Kip Walker, Broadcom Corp.");
202MODULE_DESCRIPTION("SiByte I2C-Bus algorithm");
203module_param(bit_scan, int, 0);
204MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus");
205MODULE_LICENSE("GPL");
206
207int init_module(void)
208{
209 return i2c_algo_sibyte_init();
210}
211
212void cleanup_module(void)
213{
214}
215#endif
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 884320e70403..9e56c3989d68 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -75,11 +75,11 @@ config I2C_AMD8111
75 will be called i2c-amd8111. 75 will be called i2c-amd8111.
76 76
77config I2C_AU1550 77config I2C_AU1550
78 tristate "Au1550 SMBus interface" 78 tristate "Au1550/Au1200 SMBus interface"
79 depends on I2C && SOC_AU1550 79 depends on I2C && (SOC_AU1550 || SOC_AU1200)
80 help 80 help
81 If you say yes to this option, support will be included for the 81 If you say yes to this option, support will be included for the
82 Au1550 SMBus interface. 82 Au1550 and Au1200 SMBus interface.
83 83
84 This driver can also be built as a module. If so, the module 84 This driver can also be built as a module. If so, the module
85 will be called i2c-au1550. 85 will be called i2c-au1550.
@@ -287,6 +287,16 @@ config I2C_OCORES
287 This driver can also be built as a module. If so, the module 287 This driver can also be built as a module. If so, the module
288 will be called i2c-ocores. 288 will be called i2c-ocores.
289 289
290config I2C_OMAP
291 tristate "OMAP I2C adapter"
292 depends on I2C && ARCH_OMAP
293 default y if MACH_OMAP_H3 || MACH_OMAP_OSK
294 help
295 If you say yes to this option, support will be included for the
296 I2C interface on the Texas Instruments OMAP1/2 family of processors.
297 Like OMAP1510/1610/1710/5912 and OMAP242x.
298 For details see http://www.ti.com/omap.
299
290config I2C_PARPORT 300config I2C_PARPORT
291 tristate "Parallel port adapter" 301 tristate "Parallel port adapter"
292 depends on I2C && PARPORT 302 depends on I2C && PARPORT
@@ -482,19 +492,19 @@ config I2C_VIA
482 will be called i2c-via. 492 will be called i2c-via.
483 493
484config I2C_VIAPRO 494config I2C_VIAPRO
485 tristate "VIA 82C596/82C686/823x" 495 tristate "VIA 82C596/82C686/82xx"
486 depends on I2C && PCI 496 depends on I2C && PCI
487 help 497 help
488 If you say yes to this option, support will be included for the VIA 498 If you say yes to this option, support will be included for the VIA
489 82C596/82C686/823x I2C interfaces. Specifically, the following 499 82C596/82C686/82xx I2C interfaces. Specifically, the following
490 chipsets are supported: 500 chipsets are supported:
491 82C596A/B 501 VT82C596A/B
492 82C686A/B 502 VT82C686A/B
493 8231 503 VT8231
494 8233 504 VT8233/A
495 8233A 505 VT8235
496 8235 506 VT8237R/A
497 8237 507 VT8251
498 508
499 This driver can also be built as a module. If so, the module 509 This driver can also be built as a module. If so, the module
500 will be called i2c-viapro. 510 will be called i2c-viapro.
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index ac56df53155b..493c87289b62 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_I2C_MPC) += i2c-mpc.o
24obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o 24obj-$(CONFIG_I2C_MV64XXX) += i2c-mv64xxx.o
25obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o 25obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
26obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o 26obj-$(CONFIG_I2C_OCORES) += i2c-ocores.o
27obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
27obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o 28obj-$(CONFIG_I2C_PARPORT) += i2c-parport.o
28obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o 29obj-$(CONFIG_I2C_PARPORT_LIGHT) += i2c-parport-light.o
29obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 30obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index d3ef46aeeb3c..e75d339a3481 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -468,7 +468,7 @@ static u32 ali1535_func(struct i2c_adapter *adapter)
468 I2C_FUNC_SMBUS_BLOCK_DATA; 468 I2C_FUNC_SMBUS_BLOCK_DATA;
469} 469}
470 470
471static struct i2c_algorithm smbus_algorithm = { 471static const struct i2c_algorithm smbus_algorithm = {
472 .smbus_xfer = ali1535_access, 472 .smbus_xfer = ali1535_access,
473 .functionality = ali1535_func, 473 .functionality = ali1535_func,
474}; 474};
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index e6f63208fc4a..33fbb47100a3 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -367,7 +367,7 @@ static void ali1563_shutdown(struct pci_dev *dev)
367 release_region(ali1563_smba,ALI1563_SMB_IOSIZE); 367 release_region(ali1563_smba,ALI1563_SMB_IOSIZE);
368} 368}
369 369
370static struct i2c_algorithm ali1563_algorithm = { 370static const struct i2c_algorithm ali1563_algorithm = {
371 .smbus_xfer = ali1563_access, 371 .smbus_xfer = ali1563_access,
372 .functionality = ali1563_func, 372 .functionality = ali1563_func,
373}; 373};
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 7a5c0941dbc1..3f11b6e1a341 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -463,7 +463,7 @@ static u32 ali15x3_func(struct i2c_adapter *adapter)
463 I2C_FUNC_SMBUS_BLOCK_DATA; 463 I2C_FUNC_SMBUS_BLOCK_DATA;
464} 464}
465 465
466static struct i2c_algorithm smbus_algorithm = { 466static const struct i2c_algorithm smbus_algorithm = {
467 .smbus_xfer = ali15x3_access, 467 .smbus_xfer = ali15x3_access,
468 .functionality = ali15x3_func, 468 .functionality = ali15x3_func,
469}; 469};
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index 1750dedaf4b5..2d21afdc5b1c 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -294,7 +294,7 @@ static u32 amd756_func(struct i2c_adapter *adapter)
294 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL; 294 I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_PROC_CALL;
295} 295}
296 296
297static struct i2c_algorithm smbus_algorithm = { 297static const struct i2c_algorithm smbus_algorithm = {
298 .smbus_xfer = amd756_access, 298 .smbus_xfer = amd756_access,
299 .functionality = amd756_func, 299 .functionality = amd756_func,
300}; 300};
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index e5ef560e686a..0fbc7186c91a 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -316,7 +316,7 @@ static u32 amd8111_func(struct i2c_adapter *adapter)
316 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC; 316 I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_HWPEC_CALC;
317} 317}
318 318
319static struct i2c_algorithm smbus_algorithm = { 319static const struct i2c_algorithm smbus_algorithm = {
320 .smbus_xfer = amd8111_access, 320 .smbus_xfer = amd8111_access,
321 .functionality = amd8111_func, 321 .functionality = amd8111_func,
322}; 322};
diff --git a/drivers/i2c/busses/i2c-au1550.c b/drivers/i2c/busses/i2c-au1550.c
index d06edce03bf4..d7e7c359fc36 100644
--- a/drivers/i2c/busses/i2c-au1550.c
+++ b/drivers/i2c/busses/i2c-au1550.c
@@ -34,8 +34,7 @@
34#include <linux/errno.h> 34#include <linux/errno.h>
35#include <linux/i2c.h> 35#include <linux/i2c.h>
36 36
37#include <asm/mach-au1x00/au1000.h> 37#include <asm/mach-au1x00/au1xxx.h>
38#include <asm/mach-pb1x00/pb1550.h>
39#include <asm/mach-au1x00/au1xxx_psc.h> 38#include <asm/mach-au1x00/au1xxx_psc.h>
40 39
41#include "i2c-au1550.h" 40#include "i2c-au1550.h"
@@ -118,13 +117,19 @@ do_address(struct i2c_au1550_data *adap, unsigned int addr, int rd)
118 117
119 /* Reset the FIFOs, clear events. 118 /* Reset the FIFOs, clear events.
120 */ 119 */
121 sp->psc_smbpcr = PSC_SMBPCR_DC; 120 stat = sp->psc_smbstat;
122 sp->psc_smbevnt = PSC_SMBEVNT_ALLCLR; 121 sp->psc_smbevnt = PSC_SMBEVNT_ALLCLR;
123 au_sync(); 122 au_sync();
124 do { 123
125 stat = sp->psc_smbpcr; 124 if (!(stat & PSC_SMBSTAT_TE) || !(stat & PSC_SMBSTAT_RE)) {
125 sp->psc_smbpcr = PSC_SMBPCR_DC;
126 au_sync(); 126 au_sync();
127 } while ((stat & PSC_SMBPCR_DC) != 0); 127 do {
128 stat = sp->psc_smbpcr;
129 au_sync();
130 } while ((stat & PSC_SMBPCR_DC) != 0);
131 udelay(50);
132 }
128 133
129 /* Write out the i2c chip address and specify operation 134 /* Write out the i2c chip address and specify operation
130 */ 135 */
@@ -279,10 +284,10 @@ au1550_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs, int num)
279static u32 284static u32
280au1550_func(struct i2c_adapter *adap) 285au1550_func(struct i2c_adapter *adap)
281{ 286{
282 return I2C_FUNC_I2C; 287 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
283} 288}
284 289
285static struct i2c_algorithm au1550_algo = { 290static const struct i2c_algorithm au1550_algo = {
286 .master_xfer = au1550_xfer, 291 .master_xfer = au1550_xfer,
287 .functionality = au1550_func, 292 .functionality = au1550_func,
288}; 293};
diff --git a/drivers/i2c/busses/i2c-elektor.c b/drivers/i2c/busses/i2c-elektor.c
index 59f8308c2356..caa8e5c8bfbb 100644
--- a/drivers/i2c/busses/i2c-elektor.c
+++ b/drivers/i2c/busses/i2c-elektor.c
@@ -196,7 +196,6 @@ static struct i2c_algo_pcf_data pcf_isa_data = {
196 .getclock = pcf_isa_getclock, 196 .getclock = pcf_isa_getclock,
197 .waitforpin = pcf_isa_waitforpin, 197 .waitforpin = pcf_isa_waitforpin,
198 .udelay = 10, 198 .udelay = 10,
199 .mdelay = 10,
200 .timeout = 100, 199 .timeout = 100,
201}; 200};
202 201
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index e0cb3b0f92fa..457d48a0ab9d 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -99,7 +99,6 @@ static struct i2c_algo_bit_data hydra_bit_data = {
99 .getsda = hydra_bit_getsda, 99 .getsda = hydra_bit_getsda,
100 .getscl = hydra_bit_getscl, 100 .getscl = hydra_bit_getscl,
101 .udelay = 5, 101 .udelay = 5,
102 .mdelay = 5,
103 .timeout = HZ 102 .timeout = HZ
104}; 103};
105 104
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 7be1d0a3e8f8..bbb2fbee836f 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -434,7 +434,7 @@ static u32 i801_func(struct i2c_adapter *adapter)
434 | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0); 434 | (isich4 ? I2C_FUNC_SMBUS_HWPEC_CALC : 0);
435} 435}
436 436
437static struct i2c_algorithm smbus_algorithm = { 437static const struct i2c_algorithm smbus_algorithm = {
438 .smbus_xfer = i801_access, 438 .smbus_xfer = i801_access,
439 .functionality = i801_func, 439 .functionality = i801_func,
440}; 440};
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index 748be30f2bae..b66fb6bb1870 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -166,7 +166,6 @@ static struct i2c_algo_bit_data i810_i2c_bit_data = {
166 .getsda = bit_i810i2c_getsda, 166 .getsda = bit_i810i2c_getsda,
167 .getscl = bit_i810i2c_getscl, 167 .getscl = bit_i810i2c_getscl,
168 .udelay = CYCLE_DELAY, 168 .udelay = CYCLE_DELAY,
169 .mdelay = CYCLE_DELAY,
170 .timeout = TIMEOUT, 169 .timeout = TIMEOUT,
171}; 170};
172 171
@@ -182,7 +181,6 @@ static struct i2c_algo_bit_data i810_ddc_bit_data = {
182 .getsda = bit_i810ddc_getsda, 181 .getsda = bit_i810ddc_getsda,
183 .getscl = bit_i810ddc_getscl, 182 .getscl = bit_i810ddc_getscl,
184 .udelay = CYCLE_DELAY, 183 .udelay = CYCLE_DELAY,
185 .mdelay = CYCLE_DELAY,
186 .timeout = TIMEOUT, 184 .timeout = TIMEOUT,
187}; 185};
188 186
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 0599bbd65d93..5bccb5d68318 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -625,7 +625,7 @@ static u32 iic_func(struct i2c_adapter *adap)
625 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR; 625 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR;
626} 626}
627 627
628static struct i2c_algorithm iic_algo = { 628static const struct i2c_algorithm iic_algo = {
629 .master_xfer = iic_xfer, 629 .master_xfer = iic_xfer,
630 .functionality = iic_func 630 .functionality = iic_func
631}; 631};
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index 48c56939c861..8e413150af37 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -401,7 +401,7 @@ iop3xx_i2c_func(struct i2c_adapter *adap)
401 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 401 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
402} 402}
403 403
404static struct i2c_algorithm iop3xx_i2c_algo = { 404static const struct i2c_algorithm iop3xx_i2c_algo = {
405 .master_xfer = iop3xx_i2c_master_xfer, 405 .master_xfer = iop3xx_i2c_master_xfer,
406 .algo_control = iop3xx_i2c_algo_control, 406 .algo_control = iop3xx_i2c_algo_control,
407 .functionality = iop3xx_i2c_func, 407 .functionality = iop3xx_i2c_func,
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index c3e1d3e888d7..4380653748a4 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -43,7 +43,7 @@
43static u32 isa_func(struct i2c_adapter *adapter); 43static u32 isa_func(struct i2c_adapter *adapter);
44 44
45/* This is the actual algorithm we define */ 45/* This is the actual algorithm we define */
46static struct i2c_algorithm isa_algorithm = { 46static const struct i2c_algorithm isa_algorithm = {
47 .functionality = isa_func, 47 .functionality = isa_func,
48}; 48};
49 49
@@ -89,9 +89,14 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
89 dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->driver.name); 89 dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->driver.name);
90 90
91 /* Now look for clients */ 91 /* Now look for clients */
92 driver->attach_adapter(&isa_adapter); 92 res = driver->attach_adapter(&isa_adapter);
93 93 if (res) {
94 return 0; 94 dev_err(&isa_adapter.dev,
95 "Driver %s failed to attach adapter, unregistering\n",
96 driver->driver.name);
97 driver_unregister(&driver->driver);
98 }
99 return res;
95} 100}
96 101
97int i2c_isa_del_driver(struct i2c_driver *driver) 102int i2c_isa_del_driver(struct i2c_driver *driver)
@@ -125,6 +130,8 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
125 130
126static int __init i2c_isa_init(void) 131static int __init i2c_isa_init(void)
127{ 132{
133 int err;
134
128 mutex_init(&isa_adapter.clist_lock); 135 mutex_init(&isa_adapter.clist_lock);
129 INIT_LIST_HEAD(&isa_adapter.clients); 136 INIT_LIST_HEAD(&isa_adapter.clients);
130 137
@@ -133,8 +140,16 @@ static int __init i2c_isa_init(void)
133 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); 140 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr);
134 isa_adapter.dev.driver = &i2c_adapter_driver; 141 isa_adapter.dev.driver = &i2c_adapter_driver;
135 isa_adapter.dev.release = &i2c_adapter_dev_release; 142 isa_adapter.dev.release = &i2c_adapter_dev_release;
136 device_register(&isa_adapter.dev); 143 err = device_register(&isa_adapter.dev);
137 device_create_file(&isa_adapter.dev, &dev_attr_name); 144 if (err) {
145 printk(KERN_ERR "i2c-isa: Failed to register device\n");
146 goto exit;
147 }
148 err = device_create_file(&isa_adapter.dev, &dev_attr_name);
149 if (err) {
150 printk(KERN_ERR "i2c-isa: Failed to create name file\n");
151 goto exit_unregister;
152 }
138 153
139 /* Add this adapter to the i2c_adapter class */ 154 /* Add this adapter to the i2c_adapter class */
140 memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device)); 155 memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device));
@@ -142,11 +157,24 @@ static int __init i2c_isa_init(void)
142 isa_adapter.class_dev.class = &i2c_adapter_class; 157 isa_adapter.class_dev.class = &i2c_adapter_class;
143 strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id, 158 strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id,
144 BUS_ID_SIZE); 159 BUS_ID_SIZE);
145 class_device_register(&isa_adapter.class_dev); 160 err = class_device_register(&isa_adapter.class_dev);
161 if (err) {
162 printk(KERN_ERR "i2c-isa: Failed to register class device\n");
163 goto exit_remove_name;
164 }
146 165
147 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); 166 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name);
148 167
149 return 0; 168 return 0;
169
170exit_remove_name:
171 device_remove_file(&isa_adapter.dev, &dev_attr_name);
172exit_unregister:
173 init_completion(&isa_adapter.dev_released); /* Needed? */
174 device_unregister(&isa_adapter.dev);
175 wait_for_completion(&isa_adapter.dev_released);
176exit:
177 return err;
150} 178}
151 179
152static void __exit i2c_isa_exit(void) 180static void __exit i2c_isa_exit(void)
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index cd6f45d186ab..dd3f4cd3aa68 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -114,7 +114,6 @@ static int ixp2000_i2c_probe(struct platform_device *plat_dev)
114 drv_data->algo_data.getsda = ixp2000_bit_getsda; 114 drv_data->algo_data.getsda = ixp2000_bit_getsda;
115 drv_data->algo_data.getscl = ixp2000_bit_getscl; 115 drv_data->algo_data.getscl = ixp2000_bit_getscl;
116 drv_data->algo_data.udelay = 6; 116 drv_data->algo_data.udelay = 6;
117 drv_data->algo_data.mdelay = 6;
118 drv_data->algo_data.timeout = 100; 117 drv_data->algo_data.timeout = 100;
119 118
120 drv_data->adapter.id = I2C_HW_B_IXP2000, 119 drv_data->adapter.id = I2C_HW_B_IXP2000,
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index 2ed07112d683..ab573254a8aa 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -122,7 +122,6 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
122 drv_data->algo_data.getsda = ixp4xx_bit_getsda; 122 drv_data->algo_data.getsda = ixp4xx_bit_getsda;
123 drv_data->algo_data.getscl = ixp4xx_bit_getscl; 123 drv_data->algo_data.getscl = ixp4xx_bit_getscl;
124 drv_data->algo_data.udelay = 10; 124 drv_data->algo_data.udelay = 10;
125 drv_data->algo_data.mdelay = 10;
126 drv_data->algo_data.timeout = 100; 125 drv_data->algo_data.timeout = 100;
127 126
128 drv_data->adapter.id = I2C_HW_B_IXP4XX; 127 drv_data->adapter.id = I2C_HW_B_IXP4XX;
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 377ab40944b8..155a986de516 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -272,7 +272,7 @@ static u32 mpc_functionality(struct i2c_adapter *adap)
272 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 272 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
273} 273}
274 274
275static struct i2c_algorithm mpc_algo = { 275static const struct i2c_algorithm mpc_algo = {
276 .master_xfer = mpc_xfer, 276 .master_xfer = mpc_xfer,
277 .functionality = mpc_functionality, 277 .functionality = mpc_functionality,
278}; 278};
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index ac5cde1bbd2b..eacbaf745b64 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -431,7 +431,7 @@ mv64xxx_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
431 return num; 431 return num;
432} 432}
433 433
434static struct i2c_algorithm mv64xxx_i2c_algo = { 434static const struct i2c_algorithm mv64xxx_i2c_algo = {
435 .master_xfer = mv64xxx_i2c_xfer, 435 .master_xfer = mv64xxx_i2c_xfer,
436 .functionality = mv64xxx_i2c_functionality, 436 .functionality = mv64xxx_i2c_functionality,
437}; 437};
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 604b49e22df1..e0292e414ab2 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -109,7 +109,7 @@ static s32 nforce2_access(struct i2c_adapter *adap, u16 addr,
109static u32 nforce2_func(struct i2c_adapter *adapter); 109static u32 nforce2_func(struct i2c_adapter *adapter);
110 110
111 111
112static struct i2c_algorithm smbus_algorithm = { 112static const struct i2c_algorithm smbus_algorithm = {
113 .smbus_xfer = nforce2_access, 113 .smbus_xfer = nforce2_access,
114 .functionality = nforce2_func, 114 .functionality = nforce2_func,
115}; 115};
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index 592824087c49..952a28d485ce 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -199,7 +199,7 @@ static u32 ocores_func(struct i2c_adapter *adap)
199 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 199 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
200} 200}
201 201
202static struct i2c_algorithm ocores_algorithm = { 202static const struct i2c_algorithm ocores_algorithm = {
203 .master_xfer = ocores_xfer, 203 .master_xfer = ocores_xfer,
204 .functionality = ocores_func, 204 .functionality = ocores_func,
205}; 205};
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
new file mode 100644
index 000000000000..81d87d2c2a2d
--- /dev/null
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -0,0 +1,676 @@
1/*
2 * TI OMAP I2C master mode driver
3 *
4 * Copyright (C) 2003 MontaVista Software, Inc.
5 * Copyright (C) 2004 Texas Instruments.
6 *
7 * Updated to work with multiple I2C interfaces on 24xx by
8 * Tony Lindgren <tony@atomide.com> and Imre Deak <imre.deak@nokia.com>
9 * Copyright (C) 2005 Nokia Corporation
10 *
11 * Cleaned up by Juha Yrjölä <juha.yrjola@nokia.com>
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#include <linux/module.h>
29#include <linux/delay.h>
30#include <linux/i2c.h>
31#include <linux/err.h>
32#include <linux/interrupt.h>
33#include <linux/completion.h>
34#include <linux/platform_device.h>
35#include <linux/clk.h>
36
37#include <asm/io.h>
38
39/* timeout waiting for the controller to respond */
40#define OMAP_I2C_TIMEOUT (msecs_to_jiffies(1000))
41
42#define OMAP_I2C_REV_REG 0x00
43#define OMAP_I2C_IE_REG 0x04
44#define OMAP_I2C_STAT_REG 0x08
45#define OMAP_I2C_IV_REG 0x0c
46#define OMAP_I2C_SYSS_REG 0x10
47#define OMAP_I2C_BUF_REG 0x14
48#define OMAP_I2C_CNT_REG 0x18
49#define OMAP_I2C_DATA_REG 0x1c
50#define OMAP_I2C_SYSC_REG 0x20
51#define OMAP_I2C_CON_REG 0x24
52#define OMAP_I2C_OA_REG 0x28
53#define OMAP_I2C_SA_REG 0x2c
54#define OMAP_I2C_PSC_REG 0x30
55#define OMAP_I2C_SCLL_REG 0x34
56#define OMAP_I2C_SCLH_REG 0x38
57#define OMAP_I2C_SYSTEST_REG 0x3c
58
59/* I2C Interrupt Enable Register (OMAP_I2C_IE): */
60#define OMAP_I2C_IE_XRDY (1 << 4) /* TX data ready int enable */
61#define OMAP_I2C_IE_RRDY (1 << 3) /* RX data ready int enable */
62#define OMAP_I2C_IE_ARDY (1 << 2) /* Access ready int enable */
63#define OMAP_I2C_IE_NACK (1 << 1) /* No ack interrupt enable */
64#define OMAP_I2C_IE_AL (1 << 0) /* Arbitration lost int ena */
65
66/* I2C Status Register (OMAP_I2C_STAT): */
67#define OMAP_I2C_STAT_SBD (1 << 15) /* Single byte data */
68#define OMAP_I2C_STAT_BB (1 << 12) /* Bus busy */
69#define OMAP_I2C_STAT_ROVR (1 << 11) /* Receive overrun */
70#define OMAP_I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
71#define OMAP_I2C_STAT_AAS (1 << 9) /* Address as slave */
72#define OMAP_I2C_STAT_AD0 (1 << 8) /* Address zero */
73#define OMAP_I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
74#define OMAP_I2C_STAT_RRDY (1 << 3) /* Receive data ready */
75#define OMAP_I2C_STAT_ARDY (1 << 2) /* Register access ready */
76#define OMAP_I2C_STAT_NACK (1 << 1) /* No ack interrupt enable */
77#define OMAP_I2C_STAT_AL (1 << 0) /* Arbitration lost int ena */
78
79/* I2C Buffer Configuration Register (OMAP_I2C_BUF): */
80#define OMAP_I2C_BUF_RDMA_EN (1 << 15) /* RX DMA channel enable */
81#define OMAP_I2C_BUF_XDMA_EN (1 << 7) /* TX DMA channel enable */
82
83/* I2C Configuration Register (OMAP_I2C_CON): */
84#define OMAP_I2C_CON_EN (1 << 15) /* I2C module enable */
85#define OMAP_I2C_CON_BE (1 << 14) /* Big endian mode */
86#define OMAP_I2C_CON_STB (1 << 11) /* Start byte mode (master) */
87#define OMAP_I2C_CON_MST (1 << 10) /* Master/slave mode */
88#define OMAP_I2C_CON_TRX (1 << 9) /* TX/RX mode (master only) */
89#define OMAP_I2C_CON_XA (1 << 8) /* Expand address */
90#define OMAP_I2C_CON_RM (1 << 2) /* Repeat mode (master only) */
91#define OMAP_I2C_CON_STP (1 << 1) /* Stop cond (master only) */
92#define OMAP_I2C_CON_STT (1 << 0) /* Start condition (master) */
93
94/* I2C System Test Register (OMAP_I2C_SYSTEST): */
95#ifdef DEBUG
96#define OMAP_I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
97#define OMAP_I2C_SYSTEST_FREE (1 << 14) /* Free running mode */
98#define OMAP_I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */
99#define OMAP_I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */
100#define OMAP_I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense in */
101#define OMAP_I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive out */
102#define OMAP_I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense in */
103#define OMAP_I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive out */
104#endif
105
106/* I2C System Status register (OMAP_I2C_SYSS): */
107#define OMAP_I2C_SYSS_RDONE (1 << 0) /* Reset Done */
108
109/* I2C System Configuration Register (OMAP_I2C_SYSC): */
110#define OMAP_I2C_SYSC_SRST (1 << 1) /* Soft Reset */
111
112/* REVISIT: Use platform_data instead of module parameters */
113/* Fast Mode = 400 kHz, Standard = 100 kHz */
114static int clock = 100; /* Default: 100 kHz */
115module_param(clock, int, 0);
116MODULE_PARM_DESC(clock, "Set I2C clock in kHz: 400=fast mode (default == 100)");
117
118struct omap_i2c_dev {
119 struct device *dev;
120 void __iomem *base; /* virtual */
121 int irq;
122 struct clk *iclk; /* Interface clock */
123 struct clk *fclk; /* Functional clock */
124 struct completion cmd_complete;
125 struct resource *ioarea;
126 u16 cmd_err;
127 u8 *buf;
128 size_t buf_len;
129 struct i2c_adapter adapter;
130 unsigned rev1:1;
131};
132
133static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev,
134 int reg, u16 val)
135{
136 __raw_writew(val, i2c_dev->base + reg);
137}
138
139static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg)
140{
141 return __raw_readw(i2c_dev->base + reg);
142}
143
144static int omap_i2c_get_clocks(struct omap_i2c_dev *dev)
145{
146 if (cpu_is_omap16xx() || cpu_is_omap24xx()) {
147 dev->iclk = clk_get(dev->dev, "i2c_ick");
148 if (IS_ERR(dev->iclk)) {
149 dev->iclk = NULL;
150 return -ENODEV;
151 }
152 }
153
154 dev->fclk = clk_get(dev->dev, "i2c_fck");
155 if (IS_ERR(dev->fclk)) {
156 if (dev->iclk != NULL) {
157 clk_put(dev->iclk);
158 dev->iclk = NULL;
159 }
160 dev->fclk = NULL;
161 return -ENODEV;
162 }
163
164 return 0;
165}
166
167static void omap_i2c_put_clocks(struct omap_i2c_dev *dev)
168{
169 clk_put(dev->fclk);
170 dev->fclk = NULL;
171 if (dev->iclk != NULL) {
172 clk_put(dev->iclk);
173 dev->iclk = NULL;
174 }
175}
176
177static void omap_i2c_enable_clocks(struct omap_i2c_dev *dev)
178{
179 if (dev->iclk != NULL)
180 clk_enable(dev->iclk);
181 clk_enable(dev->fclk);
182}
183
184static void omap_i2c_disable_clocks(struct omap_i2c_dev *dev)
185{
186 if (dev->iclk != NULL)
187 clk_disable(dev->iclk);
188 clk_disable(dev->fclk);
189}
190
191static int omap_i2c_init(struct omap_i2c_dev *dev)
192{
193 u16 psc = 0;
194 unsigned long fclk_rate = 12000000;
195 unsigned long timeout;
196
197 if (!dev->rev1) {
198 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, OMAP_I2C_SYSC_SRST);
199 /* For some reason we need to set the EN bit before the
200 * reset done bit gets set. */
201 timeout = jiffies + OMAP_I2C_TIMEOUT;
202 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
203 while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) &
204 OMAP_I2C_SYSS_RDONE)) {
205 if (time_after(jiffies, timeout)) {
206 dev_warn(dev->dev, "timeout waiting"
207 "for controller reset\n");
208 return -ETIMEDOUT;
209 }
210 msleep(1);
211 }
212 }
213 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
214
215 if (cpu_class_is_omap1()) {
216 struct clk *armxor_ck;
217
218 armxor_ck = clk_get(NULL, "armxor_ck");
219 if (IS_ERR(armxor_ck))
220 dev_warn(dev->dev, "Could not get armxor_ck\n");
221 else {
222 fclk_rate = clk_get_rate(armxor_ck);
223 clk_put(armxor_ck);
224 }
225 /* TRM for 5912 says the I2C clock must be prescaled to be
226 * between 7 - 12 MHz. The XOR input clock is typically
227 * 12, 13 or 19.2 MHz. So we should have code that produces:
228 *
229 * XOR MHz Divider Prescaler
230 * 12 1 0
231 * 13 2 1
232 * 19.2 2 1
233 */
234 if (fclk_rate > 16000000)
235 psc = (fclk_rate + 8000000) / 12000000;
236 }
237
238 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */
239 omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, psc);
240
241 /* Program desired operating rate */
242 fclk_rate /= (psc + 1) * 1000;
243 if (psc > 2)
244 psc = 2;
245
246 omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG,
247 fclk_rate / (clock * 2) - 7 + psc);
248 omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG,
249 fclk_rate / (clock * 2) - 7 + psc);
250
251 /* Take the I2C module out of reset: */
252 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN);
253
254 /* Enable interrupts */
255 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG,
256 (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY |
257 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK |
258 OMAP_I2C_IE_AL));
259 return 0;
260}
261
262/*
263 * Waiting on Bus Busy
264 */
265static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev)
266{
267 unsigned long timeout;
268
269 timeout = jiffies + OMAP_I2C_TIMEOUT;
270 while (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) {
271 if (time_after(jiffies, timeout)) {
272 dev_warn(dev->dev, "timeout waiting for bus ready\n");
273 return -ETIMEDOUT;
274 }
275 msleep(1);
276 }
277
278 return 0;
279}
280
281/*
282 * Low level master read/write transaction.
283 */
284static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
285 struct i2c_msg *msg, int stop)
286{
287 struct omap_i2c_dev *dev = i2c_get_adapdata(adap);
288 int r;
289 u16 w;
290
291 dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n",
292 msg->addr, msg->len, msg->flags, stop);
293
294 if (msg->len == 0)
295 return -EINVAL;
296
297 omap_i2c_write_reg(dev, OMAP_I2C_SA_REG, msg->addr);
298
299 /* REVISIT: Could the STB bit of I2C_CON be used with probing? */
300 dev->buf = msg->buf;
301 dev->buf_len = msg->len;
302
303 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len);
304
305 init_completion(&dev->cmd_complete);
306 dev->cmd_err = 0;
307
308 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT;
309 if (msg->flags & I2C_M_TEN)
310 w |= OMAP_I2C_CON_XA;
311 if (!(msg->flags & I2C_M_RD))
312 w |= OMAP_I2C_CON_TRX;
313 if (stop)
314 w |= OMAP_I2C_CON_STP;
315 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
316
317 r = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
318 OMAP_I2C_TIMEOUT);
319 dev->buf_len = 0;
320 if (r < 0)
321 return r;
322 if (r == 0) {
323 dev_err(dev->dev, "controller timed out\n");
324 omap_i2c_init(dev);
325 return -ETIMEDOUT;
326 }
327
328 if (likely(!dev->cmd_err))
329 return 0;
330
331 /* We have an error */
332 if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
333 OMAP_I2C_STAT_XUDF)) {
334 omap_i2c_init(dev);
335 return -EIO;
336 }
337
338 if (dev->cmd_err & OMAP_I2C_STAT_NACK) {
339 if (msg->flags & I2C_M_IGNORE_NAK)
340 return 0;
341 if (stop) {
342 w = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG);
343 w |= OMAP_I2C_CON_STP;
344 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w);
345 }
346 return -EREMOTEIO;
347 }
348 return -EIO;
349}
350
351
352/*
353 * Prepare controller for a transaction and call omap_i2c_xfer_msg
354 * to do the work during IRQ processing.
355 */
356static int
357omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
358{
359 struct omap_i2c_dev *dev = i2c_get_adapdata(adap);
360 int i;
361 int r;
362
363 omap_i2c_enable_clocks(dev);
364
365 /* REVISIT: initialize and use adap->retries. This is an optional
366 * feature */
367 if ((r = omap_i2c_wait_for_bb(dev)) < 0)
368 goto out;
369
370 for (i = 0; i < num; i++) {
371 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1)));
372 if (r != 0)
373 break;
374 }
375
376 if (r == 0)
377 r = num;
378out:
379 omap_i2c_disable_clocks(dev);
380 return r;
381}
382
383static u32
384omap_i2c_func(struct i2c_adapter *adap)
385{
386 return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
387}
388
389static inline void
390omap_i2c_complete_cmd(struct omap_i2c_dev *dev, u16 err)
391{
392 dev->cmd_err |= err;
393 complete(&dev->cmd_complete);
394}
395
396static inline void
397omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat)
398{
399 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
400}
401
402static irqreturn_t
403omap_i2c_rev1_isr(int this_irq, void *dev_id, struct pt_regs *regs)
404{
405 struct omap_i2c_dev *dev = dev_id;
406 u16 iv, w;
407
408 iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG);
409 switch (iv) {
410 case 0x00: /* None */
411 break;
412 case 0x01: /* Arbitration lost */
413 dev_err(dev->dev, "Arbitration lost\n");
414 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_AL);
415 break;
416 case 0x02: /* No acknowledgement */
417 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_NACK);
418 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP);
419 break;
420 case 0x03: /* Register access ready */
421 omap_i2c_complete_cmd(dev, 0);
422 break;
423 case 0x04: /* Receive data ready */
424 if (dev->buf_len) {
425 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
426 *dev->buf++ = w;
427 dev->buf_len--;
428 if (dev->buf_len) {
429 *dev->buf++ = w >> 8;
430 dev->buf_len--;
431 }
432 } else
433 dev_err(dev->dev, "RRDY IRQ while no data requested\n");
434 break;
435 case 0x05: /* Transmit data ready */
436 if (dev->buf_len) {
437 w = *dev->buf++;
438 dev->buf_len--;
439 if (dev->buf_len) {
440 w |= *dev->buf++ << 8;
441 dev->buf_len--;
442 }
443 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
444 } else
445 dev_err(dev->dev, "XRDY IRQ while no data to send\n");
446 break;
447 default:
448 return IRQ_NONE;
449 }
450
451 return IRQ_HANDLED;
452}
453
454static irqreturn_t
455omap_i2c_isr(int this_irq, void *dev_id, struct pt_regs *regs)
456{
457 struct omap_i2c_dev *dev = dev_id;
458 u16 bits;
459 u16 stat, w;
460 int count = 0;
461
462 bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG);
463 while ((stat = (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG))) & bits) {
464 dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat);
465 if (count++ == 100) {
466 dev_warn(dev->dev, "Too much work in one IRQ\n");
467 break;
468 }
469
470 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
471
472 if (stat & OMAP_I2C_STAT_ARDY) {
473 omap_i2c_complete_cmd(dev, 0);
474 continue;
475 }
476 if (stat & OMAP_I2C_STAT_RRDY) {
477 w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG);
478 if (dev->buf_len) {
479 *dev->buf++ = w;
480 dev->buf_len--;
481 if (dev->buf_len) {
482 *dev->buf++ = w >> 8;
483 dev->buf_len--;
484 }
485 } else
486 dev_err(dev->dev, "RRDY IRQ while no data"
487 "requested\n");
488 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY);
489 continue;
490 }
491 if (stat & OMAP_I2C_STAT_XRDY) {
492 w = 0;
493 if (dev->buf_len) {
494 w = *dev->buf++;
495 dev->buf_len--;
496 if (dev->buf_len) {
497 w |= *dev->buf++ << 8;
498 dev->buf_len--;
499 }
500 } else
501 dev_err(dev->dev, "XRDY IRQ while no"
502 "data to send\n");
503 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
504 omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY);
505 continue;
506 }
507 if (stat & OMAP_I2C_STAT_ROVR) {
508 dev_err(dev->dev, "Receive overrun\n");
509 dev->cmd_err |= OMAP_I2C_STAT_ROVR;
510 }
511 if (stat & OMAP_I2C_STAT_XUDF) {
512 dev_err(dev->dev, "Transmit overflow\n");
513 dev->cmd_err |= OMAP_I2C_STAT_XUDF;
514 }
515 if (stat & OMAP_I2C_STAT_NACK) {
516 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_NACK);
517 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
518 OMAP_I2C_CON_STP);
519 }
520 if (stat & OMAP_I2C_STAT_AL) {
521 dev_err(dev->dev, "Arbitration lost\n");
522 omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_AL);
523 }
524 }
525
526 return count ? IRQ_HANDLED : IRQ_NONE;
527}
528
529static const struct i2c_algorithm omap_i2c_algo = {
530 .master_xfer = omap_i2c_xfer,
531 .functionality = omap_i2c_func,
532};
533
534static int
535omap_i2c_probe(struct platform_device *pdev)
536{
537 struct omap_i2c_dev *dev;
538 struct i2c_adapter *adap;
539 struct resource *mem, *irq, *ioarea;
540 int r;
541
542 /* NOTE: driver uses the static register mapping */
543 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
544 if (!mem) {
545 dev_err(&pdev->dev, "no mem resource?\n");
546 return -ENODEV;
547 }
548 irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
549 if (!irq) {
550 dev_err(&pdev->dev, "no irq resource?\n");
551 return -ENODEV;
552 }
553
554 ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1,
555 pdev->name);
556 if (!ioarea) {
557 dev_err(&pdev->dev, "I2C region already claimed\n");
558 return -EBUSY;
559 }
560
561 if (clock > 200)
562 clock = 400; /* Fast mode */
563 else
564 clock = 100; /* Standard mode */
565
566 dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
567 if (!dev) {
568 r = -ENOMEM;
569 goto err_release_region;
570 }
571
572 dev->dev = &pdev->dev;
573 dev->irq = irq->start;
574 dev->base = (void __iomem *) IO_ADDRESS(mem->start);
575 platform_set_drvdata(pdev, dev);
576
577 if ((r = omap_i2c_get_clocks(dev)) != 0)
578 goto err_free_mem;
579
580 omap_i2c_enable_clocks(dev);
581
582 if (cpu_is_omap15xx())
583 dev->rev1 = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) < 0x20;
584
585 /* reset ASAP, clearing any IRQs */
586 omap_i2c_init(dev);
587
588 r = request_irq(dev->irq, dev->rev1 ? omap_i2c_rev1_isr : omap_i2c_isr,
589 0, pdev->name, dev);
590
591 if (r) {
592 dev_err(dev->dev, "failure requesting irq %i\n", dev->irq);
593 goto err_unuse_clocks;
594 }
595 r = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG) & 0xff;
596 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n",
597 pdev->id, r >> 4, r & 0xf, clock);
598
599 adap = &dev->adapter;
600 i2c_set_adapdata(adap, dev);
601 adap->owner = THIS_MODULE;
602 adap->class = I2C_CLASS_HWMON;
603 strncpy(adap->name, "OMAP I2C adapter", sizeof(adap->name));
604 adap->algo = &omap_i2c_algo;
605 adap->dev.parent = &pdev->dev;
606
607 /* i2c device drivers may be active on return from add_adapter() */
608 r = i2c_add_adapter(adap);
609 if (r) {
610 dev_err(dev->dev, "failure adding adapter\n");
611 goto err_free_irq;
612 }
613
614 omap_i2c_disable_clocks(dev);
615
616 return 0;
617
618err_free_irq:
619 free_irq(dev->irq, dev);
620err_unuse_clocks:
621 omap_i2c_disable_clocks(dev);
622 omap_i2c_put_clocks(dev);
623err_free_mem:
624 platform_set_drvdata(pdev, NULL);
625 kfree(dev);
626err_release_region:
627 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
628 release_mem_region(mem->start, (mem->end - mem->start) + 1);
629
630 return r;
631}
632
633static int
634omap_i2c_remove(struct platform_device *pdev)
635{
636 struct omap_i2c_dev *dev = platform_get_drvdata(pdev);
637 struct resource *mem;
638
639 platform_set_drvdata(pdev, NULL);
640
641 free_irq(dev->irq, dev);
642 i2c_del_adapter(&dev->adapter);
643 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
644 omap_i2c_put_clocks(dev);
645 kfree(dev);
646 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
647 release_mem_region(mem->start, (mem->end - mem->start) + 1);
648 return 0;
649}
650
651static struct platform_driver omap_i2c_driver = {
652 .probe = omap_i2c_probe,
653 .remove = omap_i2c_remove,
654 .driver = {
655 .name = "i2c_omap",
656 .owner = THIS_MODULE,
657 },
658};
659
660/* I2C may be needed to bring up other drivers */
661static int __init
662omap_i2c_init_driver(void)
663{
664 return platform_driver_register(&omap_i2c_driver);
665}
666subsys_initcall(omap_i2c_init_driver);
667
668static void __exit omap_i2c_exit_driver(void)
669{
670 platform_driver_unregister(&omap_i2c_driver);
671}
672module_exit(omap_i2c_exit_driver);
673
674MODULE_AUTHOR("MontaVista Software, Inc. (and others)");
675MODULE_DESCRIPTION("TI OMAP I2C bus adapter");
676MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-parport-light.c b/drivers/i2c/busses/i2c-parport-light.c
index e09ebbb2f9f0..5eb2bd294fd9 100644
--- a/drivers/i2c/busses/i2c-parport-light.c
+++ b/drivers/i2c/busses/i2c-parport-light.c
@@ -103,7 +103,6 @@ static struct i2c_algo_bit_data parport_algo_data = {
103 .getsda = parport_getsda, 103 .getsda = parport_getsda,
104 .getscl = parport_getscl, 104 .getscl = parport_getscl,
105 .udelay = 50, 105 .udelay = 50,
106 .mdelay = 50,
107 .timeout = HZ, 106 .timeout = HZ,
108}; 107};
109 108
diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c
index 934bd55bae15..48a829431c7b 100644
--- a/drivers/i2c/busses/i2c-parport.c
+++ b/drivers/i2c/busses/i2c-parport.c
@@ -138,7 +138,6 @@ static struct i2c_algo_bit_data parport_algo_data = {
138 .getsda = parport_getsda, 138 .getsda = parport_getsda,
139 .getscl = parport_getscl, 139 .getscl = parport_getscl,
140 .udelay = 60, 140 .udelay = 60,
141 .mdelay = 60,
142 .timeout = HZ, 141 .timeout = HZ,
143}; 142};
144 143
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 8f2f65b793b9..30c7a1b38cbd 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -376,7 +376,7 @@ static u32 piix4_func(struct i2c_adapter *adapter)
376 I2C_FUNC_SMBUS_BLOCK_DATA; 376 I2C_FUNC_SMBUS_BLOCK_DATA;
377} 377}
378 378
379static struct i2c_algorithm smbus_algorithm = { 379static const struct i2c_algorithm smbus_algorithm = {
380 .smbus_xfer = piix4_access, 380 .smbus_xfer = piix4_access,
381 .functionality = piix4_func, 381 .functionality = piix4_func,
382}; 382};
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index d658d9107955..a508cb962d24 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -175,7 +175,7 @@ static u32 i2c_powermac_func(struct i2c_adapter * adapter)
175} 175}
176 176
177/* For now, we only handle smbus */ 177/* For now, we only handle smbus */
178static struct i2c_algorithm i2c_powermac_algorithm = { 178static const struct i2c_algorithm i2c_powermac_algorithm = {
179 .smbus_xfer = i2c_powermac_smbus_xfer, 179 .smbus_xfer = i2c_powermac_smbus_xfer,
180 .master_xfer = i2c_powermac_master_xfer, 180 .master_xfer = i2c_powermac_master_xfer,
181 .functionality = i2c_powermac_func, 181 .functionality = i2c_powermac_func,
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
index 9479525892e3..7745e21874a8 100644
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ b/drivers/i2c/busses/i2c-prosavage.c
@@ -180,7 +180,6 @@ static int i2c_register_bus(struct pci_dev *dev, struct s_i2c_bus *p, void __iom
180 p->algo.getsda = bit_s3via_getsda; 180 p->algo.getsda = bit_s3via_getsda;
181 p->algo.getscl = bit_s3via_getscl; 181 p->algo.getscl = bit_s3via_getscl;
182 p->algo.udelay = CYCLE_DELAY; 182 p->algo.udelay = CYCLE_DELAY;
183 p->algo.mdelay = CYCLE_DELAY;
184 p->algo.timeout = TIMEOUT; 183 p->algo.timeout = TIMEOUT;
185 p->algo.data = p; 184 p->algo.data = p;
186 p->mmvga = mmvga; 185 p->mmvga = mmvga;
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index ee114b48face..cd4ad98ad517 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -926,7 +926,7 @@ static u32 i2c_pxa_functionality(struct i2c_adapter *adap)
926 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL; 926 return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
927} 927}
928 928
929static struct i2c_algorithm i2c_pxa_algorithm = { 929static const struct i2c_algorithm i2c_pxa_algorithm = {
930 .master_xfer = i2c_pxa_xfer, 930 .master_xfer = i2c_pxa_xfer,
931 .functionality = i2c_pxa_functionality, 931 .functionality = i2c_pxa_functionality,
932}; 932};
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5d2950e91fc5..9ebe429a0a0f 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -566,7 +566,7 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
566 566
567/* i2c bus registration info */ 567/* i2c bus registration info */
568 568
569static struct i2c_algorithm s3c24xx_i2c_algorithm = { 569static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
570 .master_xfer = s3c24xx_i2c_xfer, 570 .master_xfer = s3c24xx_i2c_xfer,
571 .functionality = s3c24xx_i2c_func, 571 .functionality = s3c24xx_i2c_func,
572}; 572};
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index 0c8518298e4d..209f47ea1750 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -140,7 +140,6 @@ static struct i2c_algo_bit_data sav_i2c_bit_data = {
140 .getsda = bit_savi2c_getsda, 140 .getsda = bit_savi2c_getsda,
141 .getscl = bit_savi2c_getscl, 141 .getscl = bit_savi2c_getscl,
142 .udelay = CYCLE_DELAY, 142 .udelay = CYCLE_DELAY,
143 .mdelay = CYCLE_DELAY,
144 .timeout = TIMEOUT 143 .timeout = TIMEOUT
145}; 144};
146 145
diff --git a/drivers/i2c/busses/i2c-sibyte.c b/drivers/i2c/busses/i2c-sibyte.c
index fa503ed9f86d..8f2b1f0deb81 100644
--- a/drivers/i2c/busses/i2c-sibyte.c
+++ b/drivers/i2c/busses/i2c-sibyte.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * Copyright (C) 2004 Steven J. Hill 2 * Copyright (C) 2004 Steven J. Hill
3 * Copyright (C) 2001,2002,2003 Broadcom Corporation 3 * Copyright (C) 2001,2002,2003 Broadcom Corporation
4 * Copyright (C) 1995-2000 Simon G. Vogl
4 * 5 *
5 * This program is free software; you can redistribute it and/or 6 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 7 * modify it under the terms of the GNU General Public License
@@ -17,11 +18,162 @@
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */ 19 */
19 20
21#include <linux/kernel.h>
20#include <linux/module.h> 22#include <linux/module.h>
21#include <linux/i2c-algo-sibyte.h> 23#include <linux/init.h>
24#include <linux/i2c.h>
25#include <asm/io.h>
22#include <asm/sibyte/sb1250_regs.h> 26#include <asm/sibyte/sb1250_regs.h>
23#include <asm/sibyte/sb1250_smbus.h> 27#include <asm/sibyte/sb1250_smbus.h>
24 28
29
30struct i2c_algo_sibyte_data {
31 void *data; /* private data */
32 int bus; /* which bus */
33 void *reg_base; /* CSR base */
34};
35
36/* ----- global defines ----------------------------------------------- */
37#define SMB_CSR(a,r) ((long)(a->reg_base + r))
38
39/* ----- global variables --------------------------------------------- */
40
41/* module parameters:
42 */
43static int bit_scan; /* have a look at what's hanging 'round */
44module_param(bit_scan, int, 0);
45MODULE_PARM_DESC(bit_scan, "Scan for active chips on the bus");
46
47
48static int smbus_xfer(struct i2c_adapter *i2c_adap, u16 addr,
49 unsigned short flags, char read_write,
50 u8 command, int size, union i2c_smbus_data * data)
51{
52 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
53 int data_bytes = 0;
54 int error;
55
56 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
57 ;
58
59 switch (size) {
60 case I2C_SMBUS_QUICK:
61 csr_out32((V_SMB_ADDR(addr) |
62 (read_write == I2C_SMBUS_READ ? M_SMB_QDATA : 0) |
63 V_SMB_TT_QUICKCMD), SMB_CSR(adap, R_SMB_START));
64 break;
65 case I2C_SMBUS_BYTE:
66 if (read_write == I2C_SMBUS_READ) {
67 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_RD1BYTE),
68 SMB_CSR(adap, R_SMB_START));
69 data_bytes = 1;
70 } else {
71 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
72 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR1BYTE),
73 SMB_CSR(adap, R_SMB_START));
74 }
75 break;
76 case I2C_SMBUS_BYTE_DATA:
77 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
78 if (read_write == I2C_SMBUS_READ) {
79 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD1BYTE),
80 SMB_CSR(adap, R_SMB_START));
81 data_bytes = 1;
82 } else {
83 csr_out32(V_SMB_LB(data->byte),
84 SMB_CSR(adap, R_SMB_DATA));
85 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE),
86 SMB_CSR(adap, R_SMB_START));
87 }
88 break;
89 case I2C_SMBUS_WORD_DATA:
90 csr_out32(V_SMB_CMD(command), SMB_CSR(adap, R_SMB_CMD));
91 if (read_write == I2C_SMBUS_READ) {
92 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_CMD_RD2BYTE),
93 SMB_CSR(adap, R_SMB_START));
94 data_bytes = 2;
95 } else {
96 csr_out32(V_SMB_LB(data->word & 0xff),
97 SMB_CSR(adap, R_SMB_DATA));
98 csr_out32(V_SMB_MB(data->word >> 8),
99 SMB_CSR(adap, R_SMB_DATA));
100 csr_out32((V_SMB_ADDR(addr) | V_SMB_TT_WR2BYTE),
101 SMB_CSR(adap, R_SMB_START));
102 }
103 break;
104 default:
105 return -1; /* XXXKW better error code? */
106 }
107
108 while (csr_in32(SMB_CSR(adap, R_SMB_STATUS)) & M_SMB_BUSY)
109 ;
110
111 error = csr_in32(SMB_CSR(adap, R_SMB_STATUS));
112 if (error & M_SMB_ERROR) {
113 /* Clear error bit by writing a 1 */
114 csr_out32(M_SMB_ERROR, SMB_CSR(adap, R_SMB_STATUS));
115 return -1; /* XXXKW better error code? */
116 }
117
118 if (data_bytes == 1)
119 data->byte = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xff;
120 if (data_bytes == 2)
121 data->word = csr_in32(SMB_CSR(adap, R_SMB_DATA)) & 0xffff;
122
123 return 0;
124}
125
126static u32 bit_func(struct i2c_adapter *adap)
127{
128 return (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
129 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA);
130}
131
132
133/* -----exported algorithm data: ------------------------------------- */
134
135static const struct i2c_algorithm i2c_sibyte_algo = {
136 .smbus_xfer = smbus_xfer,
137 .functionality = bit_func,
138};
139
140/*
141 * registering functions to load algorithms at runtime
142 */
143int i2c_sibyte_add_bus(struct i2c_adapter *i2c_adap, int speed)
144{
145 int i;
146 struct i2c_algo_sibyte_data *adap = i2c_adap->algo_data;
147
148 /* register new adapter to i2c module... */
149 i2c_adap->algo = &i2c_sibyte_algo;
150
151 /* Set the frequency to 100 kHz */
152 csr_out32(speed, SMB_CSR(adap,R_SMB_FREQ));
153 csr_out32(0, SMB_CSR(adap,R_SMB_CONTROL));
154
155 /* scan bus */
156 if (bit_scan) {
157 union i2c_smbus_data data;
158 int rc;
159 printk(KERN_INFO " i2c-algo-sibyte.o: scanning bus %s.\n",
160 i2c_adap->name);
161 for (i = 0x00; i < 0x7f; i++) {
162 /* XXXKW is this a realistic probe? */
163 rc = smbus_xfer(i2c_adap, i, 0, I2C_SMBUS_READ, 0,
164 I2C_SMBUS_BYTE_DATA, &data);
165 if (!rc) {
166 printk("(%02x)",i);
167 } else
168 printk(".");
169 }
170 printk("\n");
171 }
172
173 return i2c_add_adapter(i2c_adap);
174}
175
176
25static struct i2c_algo_sibyte_data sibyte_board_data[2] = { 177static struct i2c_algo_sibyte_data sibyte_board_data[2] = {
26 { NULL, 0, (void *) (CKSEG1+A_SMB_BASE(0)) }, 178 { NULL, 0, (void *) (CKSEG1+A_SMB_BASE(0)) },
27 { NULL, 1, (void *) (CKSEG1+A_SMB_BASE(1)) } 179 { NULL, 1, (void *) (CKSEG1+A_SMB_BASE(1)) }
@@ -58,13 +210,13 @@ static int __init i2c_sibyte_init(void)
58 210
59static void __exit i2c_sibyte_exit(void) 211static void __exit i2c_sibyte_exit(void)
60{ 212{
61 i2c_sibyte_del_bus(&sibyte_board_adapter[0]); 213 i2c_del_bus(&sibyte_board_adapter[0]);
62 i2c_sibyte_del_bus(&sibyte_board_adapter[1]); 214 i2c_del_bus(&sibyte_board_adapter[1]);
63} 215}
64 216
65module_init(i2c_sibyte_init); 217module_init(i2c_sibyte_init);
66module_exit(i2c_sibyte_exit); 218module_exit(i2c_sibyte_exit);
67 219
68MODULE_AUTHOR("Kip Walker <kwalker@broadcom.com>, Steven J. Hill <sjhill@realitydiluted.com>"); 220MODULE_AUTHOR("Kip Walker (Broadcom Corp.), Steven J. Hill <sjhill@realitydiluted.com>");
69MODULE_DESCRIPTION("SMBus adapter routines for SiByte boards"); 221MODULE_DESCRIPTION("SMBus adapter routines for SiByte boards");
70MODULE_LICENSE("GPL"); 222MODULE_LICENSE("GPL");
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index b57ab74d23ec..38bbfd840b6b 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -358,7 +358,7 @@ static u32 sis5595_func(struct i2c_adapter *adapter)
358 I2C_FUNC_SMBUS_PROC_CALL; 358 I2C_FUNC_SMBUS_PROC_CALL;
359} 359}
360 360
361static struct i2c_algorithm smbus_algorithm = { 361static const struct i2c_algorithm smbus_algorithm = {
362 .smbus_xfer = sis5595_access, 362 .smbus_xfer = sis5595_access,
363 .functionality = sis5595_func, 363 .functionality = sis5595_func,
364}; 364};
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index acb75e282414..dec0bafb52ab 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -450,7 +450,7 @@ exit:
450} 450}
451 451
452 452
453static struct i2c_algorithm smbus_algorithm = { 453static const struct i2c_algorithm smbus_algorithm = {
454 .smbus_xfer = sis630_access, 454 .smbus_xfer = sis630_access,
455 .functionality = sis630_func, 455 .functionality = sis630_func,
456}; 456};
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 1a73c0532fc7..7fd07fbac336 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -242,7 +242,7 @@ static u32 sis96x_func(struct i2c_adapter *adapter)
242 I2C_FUNC_SMBUS_PROC_CALL; 242 I2C_FUNC_SMBUS_PROC_CALL;
243} 243}
244 244
245static struct i2c_algorithm smbus_algorithm = { 245static const struct i2c_algorithm smbus_algorithm = {
246 .smbus_xfer = sis96x_access, 246 .smbus_xfer = sis96x_access,
247 .functionality = sis96x_func, 247 .functionality = sis96x_func,
248}; 248};
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/busses/i2c-stub.c
index 73f481e93a36..a54adc50d162 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/busses/i2c-stub.c
@@ -27,6 +27,10 @@
27#include <linux/errno.h> 27#include <linux/errno.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29 29
30static unsigned short chip_addr;
31module_param(chip_addr, ushort, S_IRUGO);
32MODULE_PARM_DESC(chip_addr, "Chip address (between 0x03 and 0x77)\n");
33
30static u8 stub_pointer; 34static u8 stub_pointer;
31static u8 stub_bytes[256]; 35static u8 stub_bytes[256];
32static u16 stub_words[256]; 36static u16 stub_words[256];
@@ -37,6 +41,9 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
37{ 41{
38 s32 ret; 42 s32 ret;
39 43
44 if (addr != chip_addr)
45 return -ENODEV;
46
40 switch (size) { 47 switch (size) {
41 48
42 case I2C_SMBUS_QUICK: 49 case I2C_SMBUS_QUICK:
@@ -108,7 +115,7 @@ static u32 stub_func(struct i2c_adapter *adapter)
108 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA; 115 I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA;
109} 116}
110 117
111static struct i2c_algorithm smbus_algorithm = { 118static const struct i2c_algorithm smbus_algorithm = {
112 .functionality = stub_func, 119 .functionality = stub_func,
113 .smbus_xfer = stub_xfer, 120 .smbus_xfer = stub_xfer,
114}; 121};
@@ -122,7 +129,17 @@ static struct i2c_adapter stub_adapter = {
122 129
123static int __init i2c_stub_init(void) 130static int __init i2c_stub_init(void)
124{ 131{
125 printk(KERN_INFO "i2c-stub loaded\n"); 132 if (!chip_addr) {
133 printk(KERN_ERR "i2c-stub: Please specify a chip address\n");
134 return -ENODEV;
135 }
136 if (chip_addr < 0x03 || chip_addr > 0x77) {
137 printk(KERN_ERR "i2c-stub: Invalid chip address 0x%02x\n",
138 chip_addr);
139 return -EINVAL;
140 }
141
142 printk(KERN_INFO "i2c-stub: Virtual chip at 0x%02x\n", chip_addr);
126 return i2c_add_adapter(&stub_adapter); 143 return i2c_add_adapter(&stub_adapter);
127} 144}
128 145
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 484bbacfce6b..910e200ad500 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -81,7 +81,6 @@ static struct i2c_algo_bit_data bit_data = {
81 .getsda = bit_via_getsda, 81 .getsda = bit_via_getsda,
82 .getscl = bit_via_getscl, 82 .getscl = bit_via_getscl,
83 .udelay = 5, 83 .udelay = 5,
84 .mdelay = 5,
85 .timeout = HZ 84 .timeout = HZ
86}; 85};
87 86
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index 47e52bf2c5ec..efc6bbf0cc0a 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -34,6 +34,8 @@
34 VT8233A 0x3147 yes? 34 VT8233A 0x3147 yes?
35 VT8235 0x3177 yes 35 VT8235 0x3177 yes
36 VT8237R 0x3227 yes 36 VT8237R 0x3227 yes
37 VT8237A 0x3337 yes
38 VT8251 0x3287 yes
37 39
38 Note: we assume there can only be one device, with one SMBus interface. 40 Note: we assume there can only be one device, with one SMBus interface.
39*/ 41*/
@@ -297,7 +299,7 @@ static u32 vt596_func(struct i2c_adapter *adapter)
297 return func; 299 return func;
298} 300}
299 301
300static struct i2c_algorithm smbus_algorithm = { 302static const struct i2c_algorithm smbus_algorithm = {
301 .smbus_xfer = vt596_access, 303 .smbus_xfer = vt596_access,
302 .functionality = vt596_func, 304 .functionality = vt596_func,
303}; 305};
@@ -381,7 +383,9 @@ found:
381 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba); 383 dev_dbg(&pdev->dev, "VT596_smba = 0x%X\n", vt596_smba);
382 384
383 switch (pdev->device) { 385 switch (pdev->device) {
386 case PCI_DEVICE_ID_VIA_8251:
384 case PCI_DEVICE_ID_VIA_8237: 387 case PCI_DEVICE_ID_VIA_8237:
388 case PCI_DEVICE_ID_VIA_8237A:
385 case PCI_DEVICE_ID_VIA_8235: 389 case PCI_DEVICE_ID_VIA_8235:
386 case PCI_DEVICE_ID_VIA_8233A: 390 case PCI_DEVICE_ID_VIA_8233A:
387 case PCI_DEVICE_ID_VIA_8233_0: 391 case PCI_DEVICE_ID_VIA_8233_0:
@@ -432,8 +436,12 @@ static struct pci_device_id vt596_ids[] = {
432 .driver_data = SMBBA3 }, 436 .driver_data = SMBBA3 },
433 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237), 437 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237),
434 .driver_data = SMBBA3 }, 438 .driver_data = SMBBA3 },
439 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237A),
440 .driver_data = SMBBA3 },
435 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4), 441 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4),
436 .driver_data = SMBBA1 }, 442 .driver_data = SMBBA1 },
443 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8251),
444 .driver_data = SMBBA3 },
437 { 0, } 445 { 0, }
438}; 446};
439 447
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index b675773b0cc1..6c8d25183382 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -160,7 +160,6 @@ static struct i2c_algo_bit_data voo_i2c_bit_data = {
160 .getsda = bit_vooi2c_getsda, 160 .getsda = bit_vooi2c_getsda,
161 .getscl = bit_vooi2c_getscl, 161 .getscl = bit_vooi2c_getscl,
162 .udelay = CYCLE_DELAY, 162 .udelay = CYCLE_DELAY,
163 .mdelay = CYCLE_DELAY,
164 .timeout = TIMEOUT 163 .timeout = TIMEOUT
165}; 164};
166 165
@@ -177,7 +176,6 @@ static struct i2c_algo_bit_data voo_ddc_bit_data = {
177 .getsda = bit_vooddc_getsda, 176 .getsda = bit_vooddc_getsda,
178 .getscl = bit_vooddc_getscl, 177 .getscl = bit_vooddc_getscl,
179 .udelay = CYCLE_DELAY, 178 .udelay = CYCLE_DELAY,
180 .mdelay = CYCLE_DELAY,
181 .timeout = TIMEOUT 179 .timeout = TIMEOUT
182}; 180};
183 181
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index eae9e81be375..32aab0d34ee9 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -383,7 +383,7 @@ static u32 scx200_acb_func(struct i2c_adapter *adapter)
383} 383}
384 384
385/* For now, we only handle combined mode (smbus) */ 385/* For now, we only handle combined mode (smbus) */
386static struct i2c_algorithm scx200_acb_algorithm = { 386static const struct i2c_algorithm scx200_acb_algorithm = {
387 .smbus_xfer = scx200_acb_smbus_xfer, 387 .smbus_xfer = scx200_acb_smbus_xfer,
388 .functionality = scx200_acb_func, 388 .functionality = scx200_acb_func,
389}; 389};
diff --git a/drivers/i2c/busses/scx200_i2c.c b/drivers/i2c/busses/scx200_i2c.c
index cb3ef5ac99fd..8b65a5cf8251 100644
--- a/drivers/i2c/busses/scx200_i2c.c
+++ b/drivers/i2c/busses/scx200_i2c.c
@@ -71,12 +71,12 @@ static int scx200_i2c_getsda(void *data)
71 */ 71 */
72 72
73static struct i2c_algo_bit_data scx200_i2c_data = { 73static struct i2c_algo_bit_data scx200_i2c_data = {
74 NULL, 74 .setsda = scx200_i2c_setsda,
75 scx200_i2c_setsda, 75 .setscl = scx200_i2c_setscl,
76 scx200_i2c_setscl, 76 .getsda = scx200_i2c_getsda,
77 scx200_i2c_getsda, 77 .getscl = scx200_i2c_getscl,
78 scx200_i2c_getscl, 78 .udelay = 10,
79 10, 10, 100, /* waits, timeout */ 79 .timeout = 100,
80}; 80};
81 81
82static struct i2c_adapter scx200_i2c_ops = { 82static struct i2c_adapter scx200_i2c_ops = {
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 13c108269a6d..cec3a0c3894d 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -209,10 +209,14 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
209 } 209 }
210 210
211 /* create the sysfs eeprom file */ 211 /* create the sysfs eeprom file */
212 sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr); 212 err = sysfs_create_bin_file(&new_client->dev.kobj, &eeprom_attr);
213 if (err)
214 goto exit_detach;
213 215
214 return 0; 216 return 0;
215 217
218exit_detach:
219 i2c_detach_client(new_client);
216exit_kfree: 220exit_kfree:
217 kfree(data); 221 kfree(data);
218exit: 222exit:
@@ -223,6 +227,8 @@ static int eeprom_detach_client(struct i2c_client *client)
223{ 227{
224 int err; 228 int err;
225 229
230 sysfs_remove_bin_file(&client->dev.kobj, &eeprom_attr);
231
226 err = i2c_detach_client(client); 232 err = i2c_detach_client(client);
227 if (err) 233 if (err)
228 return err; 234 return err;
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index f92505b94c61..182f04953466 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -30,7 +30,7 @@
30#include <linux/usb_ch9.h> 30#include <linux/usb_ch9.h>
31#include <linux/usb_gadget.h> 31#include <linux/usb_gadget.h>
32#include <linux/usb.h> 32#include <linux/usb.h>
33#include <linux/usb_otg.h> 33#include <linux/usb/otg.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36 36
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 88d2ddee4490..76645c142977 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -199,8 +199,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
199 mutex_init(&data->update_lock); 199 mutex_init(&data->update_lock);
200 200
201 /* Init fake client data */ 201 /* Init fake client data */
202 /* set the client data to the i2c_client so that it will get freed */ 202 i2c_set_clientdata(fake_client, NULL);
203 i2c_set_clientdata(fake_client, fake_client);
204 fake_client->addr = address | 1; 203 fake_client->addr = address | 1;
205 fake_client->adapter = adapter; 204 fake_client->adapter = adapter;
206 fake_client->driver = &max6875_driver; 205 fake_client->driver = &max6875_driver;
@@ -214,13 +213,17 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
214 goto exit_kfree2; 213 goto exit_kfree2;
215 214
216 if ((err = i2c_attach_client(fake_client)) != 0) 215 if ((err = i2c_attach_client(fake_client)) != 0)
217 goto exit_detach; 216 goto exit_detach1;
218 217
219 sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr); 218 err = sysfs_create_bin_file(&real_client->dev.kobj, &user_eeprom_attr);
219 if (err)
220 goto exit_detach2;
220 221
221 return 0; 222 return 0;
222 223
223exit_detach: 224exit_detach2:
225 i2c_detach_client(fake_client);
226exit_detach1:
224 i2c_detach_client(real_client); 227 i2c_detach_client(real_client);
225exit_kfree2: 228exit_kfree2:
226 kfree(fake_client); 229 kfree(fake_client);
@@ -229,14 +232,24 @@ exit_kfree1:
229 return err; 232 return err;
230} 233}
231 234
235/* Will be called for both the real client and the fake client */
232static int max6875_detach_client(struct i2c_client *client) 236static int max6875_detach_client(struct i2c_client *client)
233{ 237{
234 int err; 238 int err;
239 struct max6875_data *data = i2c_get_clientdata(client);
240
241 /* data is NULL for the fake client */
242 if (data)
243 sysfs_remove_bin_file(&client->dev.kobj, &user_eeprom_attr);
235 244
236 err = i2c_detach_client(client); 245 err = i2c_detach_client(client);
237 if (err) 246 if (err)
238 return err; 247 return err;
239 kfree(i2c_get_clientdata(client)); 248
249 if (data) /* real client */
250 kfree(data);
251 else /* fake client */
252 kfree(client);
240 return 0; 253 return 0;
241} 254}
242 255
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index cb22280cdd27..f43c4e79b55e 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -148,11 +148,16 @@ static int pca9539_detect(struct i2c_adapter *adapter, int address, int kind)
148 if ((err = i2c_attach_client(new_client))) 148 if ((err = i2c_attach_client(new_client)))
149 goto exit_kfree; 149 goto exit_kfree;
150 150
151 /* Register sysfs hooks (don't care about failure) */ 151 /* Register sysfs hooks */
152 sysfs_create_group(&new_client->dev.kobj, &pca9539_defattr_group); 152 err = sysfs_create_group(&new_client->dev.kobj,
153 &pca9539_defattr_group);
154 if (err)
155 goto exit_detach;
153 156
154 return 0; 157 return 0;
155 158
159exit_detach:
160 i2c_detach_client(new_client);
156exit_kfree: 161exit_kfree:
157 kfree(data); 162 kfree(data);
158exit: 163exit:
@@ -163,6 +168,8 @@ static int pca9539_detach_client(struct i2c_client *client)
163{ 168{
164 int err; 169 int err;
165 170
171 sysfs_remove_group(&client->dev.kobj, &pca9539_defattr_group);
172
166 if ((err = i2c_detach_client(client))) 173 if ((err = i2c_detach_client(client)))
167 return err; 174 return err;
168 175
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index c3e6449c4481..32b25427eaba 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -105,6 +105,16 @@ static ssize_t set_write(struct device *dev, struct device_attribute *attr, cons
105 105
106static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write); 106static DEVICE_ATTR(write, S_IWUSR | S_IRUGO, show_write, set_write);
107 107
108static struct attribute *pcf8574_attributes[] = {
109 &dev_attr_read.attr,
110 &dev_attr_write.attr,
111 NULL
112};
113
114static const struct attribute_group pcf8574_attr_group = {
115 .attrs = pcf8574_attributes,
116};
117
108/* 118/*
109 * Real code 119 * Real code
110 */ 120 */
@@ -166,13 +176,13 @@ static int pcf8574_detect(struct i2c_adapter *adapter, int address, int kind)
166 pcf8574_init_client(new_client); 176 pcf8574_init_client(new_client);
167 177
168 /* Register sysfs hooks */ 178 /* Register sysfs hooks */
169 device_create_file(&new_client->dev, &dev_attr_read); 179 err = sysfs_create_group(&new_client->dev.kobj, &pcf8574_attr_group);
170 device_create_file(&new_client->dev, &dev_attr_write); 180 if (err)
181 goto exit_detach;
171 return 0; 182 return 0;
172 183
173/* OK, this is not exactly good programming practice, usually. But it is 184 exit_detach:
174 very code-efficient in this case. */ 185 i2c_detach_client(new_client);
175
176 exit_free: 186 exit_free:
177 kfree(data); 187 kfree(data);
178 exit: 188 exit:
@@ -183,6 +193,8 @@ static int pcf8574_detach_client(struct i2c_client *client)
183{ 193{
184 int err; 194 int err;
185 195
196 sysfs_remove_group(&client->dev.kobj, &pcf8574_attr_group);
197
186 if ((err = i2c_detach_client(client))) 198 if ((err = i2c_detach_client(client)))
187 return err; 199 return err;
188 200
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 925a6b371fd2..4dc36376eb32 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -158,6 +158,28 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
158static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO, 158static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
159 show_out0_enable, set_out0_enable); 159 show_out0_enable, set_out0_enable);
160 160
161static struct attribute *pcf8591_attributes[] = {
162 &dev_attr_out0_enable.attr,
163 &dev_attr_out0_output.attr,
164 &dev_attr_in0_input.attr,
165 &dev_attr_in1_input.attr,
166 NULL
167};
168
169static const struct attribute_group pcf8591_attr_group = {
170 .attrs = pcf8591_attributes,
171};
172
173static struct attribute *pcf8591_attributes_opt[] = {
174 &dev_attr_in2_input.attr,
175 &dev_attr_in3_input.attr,
176 NULL
177};
178
179static const struct attribute_group pcf8591_attr_group_opt = {
180 .attrs = pcf8591_attributes_opt,
181};
182
161/* 183/*
162 * Real code 184 * Real code
163 */ 185 */
@@ -211,24 +233,31 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
211 pcf8591_init_client(new_client); 233 pcf8591_init_client(new_client);
212 234
213 /* Register sysfs hooks */ 235 /* Register sysfs hooks */
214 device_create_file(&new_client->dev, &dev_attr_out0_enable); 236 err = sysfs_create_group(&new_client->dev.kobj, &pcf8591_attr_group);
215 device_create_file(&new_client->dev, &dev_attr_out0_output); 237 if (err)
216 device_create_file(&new_client->dev, &dev_attr_in0_input); 238 goto exit_detach;
217 device_create_file(&new_client->dev, &dev_attr_in1_input);
218 239
219 /* Register input2 if not in "two differential inputs" mode */ 240 /* Register input2 if not in "two differential inputs" mode */
220 if (input_mode != 3 ) 241 if (input_mode != 3) {
221 device_create_file(&new_client->dev, &dev_attr_in2_input); 242 if ((err = device_create_file(&new_client->dev,
222 243 &dev_attr_in2_input)))
244 goto exit_sysfs_remove;
245 }
246
223 /* Register input3 only in "four single ended inputs" mode */ 247 /* Register input3 only in "four single ended inputs" mode */
224 if (input_mode == 0) 248 if (input_mode == 0) {
225 device_create_file(&new_client->dev, &dev_attr_in3_input); 249 if ((err = device_create_file(&new_client->dev,
226 250 &dev_attr_in3_input)))
251 goto exit_sysfs_remove;
252 }
253
227 return 0; 254 return 0;
228
229 /* OK, this is not exactly good programming practice, usually. But it is
230 very code-efficient in this case. */
231 255
256exit_sysfs_remove:
257 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group_opt);
258 sysfs_remove_group(&new_client->dev.kobj, &pcf8591_attr_group);
259exit_detach:
260 i2c_detach_client(new_client);
232exit_kfree: 261exit_kfree:
233 kfree(data); 262 kfree(data);
234exit: 263exit:
@@ -239,6 +268,9 @@ static int pcf8591_detach_client(struct i2c_client *client)
239{ 268{
240 int err; 269 int err;
241 270
271 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group_opt);
272 sysfs_remove_group(&client->dev.kobj, &pcf8591_attr_group);
273
242 if ((err = i2c_detach_client(client))) 274 if ((err = i2c_detach_client(client)))
243 return err; 275 return err;
244 276
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 0be6fd6a267d..6a7578217177 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -305,7 +305,7 @@ static int dbg_show(struct seq_file *s, void *_)
305 305
306static int dbg_tps_open(struct inode *inode, struct file *file) 306static int dbg_tps_open(struct inode *inode, struct file *file)
307{ 307{
308 return single_open(file, dbg_show, inode->u.generic_ip); 308 return single_open(file, dbg_show, inode->i_private);
309} 309}
310 310
311static struct file_operations debug_fops = { 311static struct file_operations debug_fops = {
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 9cb277d6aa48..01233f0f7771 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -183,15 +183,21 @@ int i2c_add_adapter(struct i2c_adapter *adap)
183 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 183 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
184 adap->dev.driver = &i2c_adapter_driver; 184 adap->dev.driver = &i2c_adapter_driver;
185 adap->dev.release = &i2c_adapter_dev_release; 185 adap->dev.release = &i2c_adapter_dev_release;
186 device_register(&adap->dev); 186 res = device_register(&adap->dev);
187 device_create_file(&adap->dev, &dev_attr_name); 187 if (res)
188 goto out_list;
189 res = device_create_file(&adap->dev, &dev_attr_name);
190 if (res)
191 goto out_unregister;
188 192
189 /* Add this adapter to the i2c_adapter class */ 193 /* Add this adapter to the i2c_adapter class */
190 memset(&adap->class_dev, 0x00, sizeof(struct class_device)); 194 memset(&adap->class_dev, 0x00, sizeof(struct class_device));
191 adap->class_dev.dev = &adap->dev; 195 adap->class_dev.dev = &adap->dev;
192 adap->class_dev.class = &i2c_adapter_class; 196 adap->class_dev.class = &i2c_adapter_class;
193 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE); 197 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
194 class_device_register(&adap->class_dev); 198 res = class_device_register(&adap->class_dev);
199 if (res)
200 goto out_remove_name;
195 201
196 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 202 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
197 203
@@ -206,6 +212,17 @@ int i2c_add_adapter(struct i2c_adapter *adap)
206out_unlock: 212out_unlock:
207 mutex_unlock(&core_lists); 213 mutex_unlock(&core_lists);
208 return res; 214 return res;
215
216out_remove_name:
217 device_remove_file(&adap->dev, &dev_attr_name);
218out_unregister:
219 init_completion(&adap->dev_released); /* Needed? */
220 device_unregister(&adap->dev);
221 wait_for_completion(&adap->dev_released);
222out_list:
223 list_del(&adap->list);
224 idr_remove(&i2c_adapter_idr, adap->nr);
225 goto out_unlock;
209} 226}
210 227
211 228
@@ -394,14 +411,14 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr)
394int i2c_attach_client(struct i2c_client *client) 411int i2c_attach_client(struct i2c_client *client)
395{ 412{
396 struct i2c_adapter *adapter = client->adapter; 413 struct i2c_adapter *adapter = client->adapter;
414 int res = 0;
397 415
398 mutex_lock(&adapter->clist_lock); 416 mutex_lock(&adapter->clist_lock);
399 if (__i2c_check_addr(client->adapter, client->addr)) { 417 if (__i2c_check_addr(client->adapter, client->addr)) {
400 mutex_unlock(&adapter->clist_lock); 418 res = -EBUSY;
401 return -EBUSY; 419 goto out_unlock;
402 } 420 }
403 list_add_tail(&client->list,&adapter->clients); 421 list_add_tail(&client->list,&adapter->clients);
404 mutex_unlock(&adapter->clist_lock);
405 422
406 if (adapter->client_register) { 423 if (adapter->client_register) {
407 if (adapter->client_register(client)) { 424 if (adapter->client_register(client)) {
@@ -422,10 +439,26 @@ int i2c_attach_client(struct i2c_client *client)
422 "%d-%04x", i2c_adapter_id(adapter), client->addr); 439 "%d-%04x", i2c_adapter_id(adapter), client->addr);
423 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n", 440 dev_dbg(&adapter->dev, "client [%s] registered with bus id %s\n",
424 client->name, client->dev.bus_id); 441 client->name, client->dev.bus_id);
425 device_register(&client->dev); 442 res = device_register(&client->dev);
426 device_create_file(&client->dev, &dev_attr_client_name); 443 if (res)
427 444 goto out_list;
428 return 0; 445 res = device_create_file(&client->dev, &dev_attr_client_name);
446 if (res)
447 goto out_unregister;
448
449out_unlock:
450 mutex_unlock(&adapter->clist_lock);
451 return res;
452
453out_unregister:
454 init_completion(&client->released); /* Needed? */
455 device_unregister(&client->dev);
456 wait_for_completion(&client->released);
457out_list:
458 list_del(&client->list);
459 dev_err(&adapter->dev, "Failed to attach i2c client %s at 0x%02x "
460 "(%d)\n", client->name, client->addr, res);
461 goto out_unlock;
429} 462}
430 463
431 464
@@ -674,11 +707,16 @@ static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind,
674 707
675 /* Finally call the custom detection function */ 708 /* Finally call the custom detection function */
676 err = found_proc(adapter, addr, kind); 709 err = found_proc(adapter, addr, kind);
677
678 /* -ENODEV can be returned if there is a chip at the given address 710 /* -ENODEV can be returned if there is a chip at the given address
679 but it isn't supported by this chip driver. We catch it here as 711 but it isn't supported by this chip driver. We catch it here as
680 this isn't an error. */ 712 this isn't an error. */
681 return (err == -ENODEV) ? 0 : err; 713 if (err == -ENODEV)
714 err = 0;
715
716 if (err)
717 dev_warn(&adapter->dev, "Client creation failed at 0x%x (%d)\n",
718 addr, err);
719 return err;
682} 720}
683 721
684int i2c_probe(struct i2c_adapter *adapter, 722int i2c_probe(struct i2c_adapter *adapter,
@@ -868,7 +906,7 @@ s32 i2c_smbus_read_byte(struct i2c_client *client)
868 I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data)) 906 I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data))
869 return -1; 907 return -1;
870 else 908 else
871 return 0x0FF & data.byte; 909 return data.byte;
872} 910}
873 911
874s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value) 912s32 i2c_smbus_write_byte(struct i2c_client *client, u8 value)
@@ -884,7 +922,7 @@ s32 i2c_smbus_read_byte_data(struct i2c_client *client, u8 command)
884 I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data)) 922 I2C_SMBUS_READ,command, I2C_SMBUS_BYTE_DATA,&data))
885 return -1; 923 return -1;
886 else 924 else
887 return 0x0FF & data.byte; 925 return data.byte;
888} 926}
889 927
890s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value) 928s32 i2c_smbus_write_byte_data(struct i2c_client *client, u8 command, u8 value)
@@ -903,7 +941,7 @@ s32 i2c_smbus_read_word_data(struct i2c_client *client, u8 command)
903 I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data)) 941 I2C_SMBUS_READ,command, I2C_SMBUS_WORD_DATA, &data))
904 return -1; 942 return -1;
905 else 943 else
906 return 0x0FFFF & data.word; 944 return data.word;
907} 945}
908 946
909s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value) 947s32 i2c_smbus_write_word_data(struct i2c_client *client, u8 command, u16 value)
@@ -1006,7 +1044,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1006 else { 1044 else {
1007 msg[0].len=3; 1045 msg[0].len=3;
1008 msgbuf0[1] = data->word & 0xff; 1046 msgbuf0[1] = data->word & 0xff;
1009 msgbuf0[2] = (data->word >> 8) & 0xff; 1047 msgbuf0[2] = data->word >> 8;
1010 } 1048 }
1011 break; 1049 break;
1012 case I2C_SMBUS_PROC_CALL: 1050 case I2C_SMBUS_PROC_CALL:
@@ -1015,7 +1053,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,
1015 msg[0].len = 3; 1053 msg[0].len = 3;
1016 msg[1].len = 2; 1054 msg[1].len = 2;
1017 msgbuf0[1] = data->word & 0xff; 1055 msgbuf0[1] = data->word & 0xff;
1018 msgbuf0[2] = (data->word >> 8) & 0xff; 1056 msgbuf0[2] = data->word >> 8;
1019 break; 1057 break;
1020 case I2C_SMBUS_BLOCK_DATA: 1058 case I2C_SMBUS_BLOCK_DATA:
1021 if (read_write == I2C_SMBUS_READ) { 1059 if (read_write == I2C_SMBUS_READ) {
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 58ccddd5c237..3f869033ed70 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -32,43 +32,35 @@
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/list.h>
35#include <linux/i2c.h> 36#include <linux/i2c.h>
36#include <linux/i2c-dev.h> 37#include <linux/i2c-dev.h>
37#include <linux/platform_device.h>
38#include <asm/uaccess.h> 38#include <asm/uaccess.h>
39 39
40static struct i2c_client i2cdev_client_template; 40static struct i2c_driver i2cdev_driver;
41 41
42struct i2c_dev { 42struct i2c_dev {
43 int minor; 43 struct list_head list;
44 struct i2c_adapter *adap; 44 struct i2c_adapter *adap;
45 struct class_device *class_dev; 45 struct class_device *class_dev;
46}; 46};
47#define to_i2c_dev(d) container_of(d, struct i2c_dev, class_dev)
48 47
49#define I2C_MINORS 256 48#define I2C_MINORS 256
50static struct i2c_dev *i2c_dev_array[I2C_MINORS]; 49static LIST_HEAD(i2c_dev_list);
51static DEFINE_SPINLOCK(i2c_dev_array_lock); 50static DEFINE_SPINLOCK(i2c_dev_list_lock);
52 51
53static struct i2c_dev *i2c_dev_get_by_minor(unsigned index) 52static struct i2c_dev *i2c_dev_get_by_minor(unsigned index)
54{ 53{
55 struct i2c_dev *i2c_dev; 54 struct i2c_dev *i2c_dev;
56 55
57 spin_lock(&i2c_dev_array_lock); 56 spin_lock(&i2c_dev_list_lock);
58 i2c_dev = i2c_dev_array[index]; 57 list_for_each_entry(i2c_dev, &i2c_dev_list, list) {
59 spin_unlock(&i2c_dev_array_lock); 58 if (i2c_dev->adap->nr == index)
60 return i2c_dev; 59 goto found;
61} 60 }
62 61 i2c_dev = NULL;
63static struct i2c_dev *i2c_dev_get_by_adapter(struct i2c_adapter *adap) 62found:
64{ 63 spin_unlock(&i2c_dev_list_lock);
65 struct i2c_dev *i2c_dev = NULL;
66
67 spin_lock(&i2c_dev_array_lock);
68 if ((i2c_dev_array[adap->nr]) &&
69 (i2c_dev_array[adap->nr]->adap == adap))
70 i2c_dev = i2c_dev_array[adap->nr];
71 spin_unlock(&i2c_dev_array_lock);
72 return i2c_dev; 64 return i2c_dev;
73} 65}
74 66
@@ -76,30 +68,28 @@ static struct i2c_dev *get_free_i2c_dev(struct i2c_adapter *adap)
76{ 68{
77 struct i2c_dev *i2c_dev; 69 struct i2c_dev *i2c_dev;
78 70
71 if (adap->nr >= I2C_MINORS) {
72 printk(KERN_ERR "i2c-dev: Out of device minors (%d)\n",
73 adap->nr);
74 return ERR_PTR(-ENODEV);
75 }
76
79 i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL); 77 i2c_dev = kzalloc(sizeof(*i2c_dev), GFP_KERNEL);
80 if (!i2c_dev) 78 if (!i2c_dev)
81 return ERR_PTR(-ENOMEM); 79 return ERR_PTR(-ENOMEM);
80 i2c_dev->adap = adap;
82 81
83 spin_lock(&i2c_dev_array_lock); 82 spin_lock(&i2c_dev_list_lock);
84 if (i2c_dev_array[adap->nr]) { 83 list_add_tail(&i2c_dev->list, &i2c_dev_list);
85 spin_unlock(&i2c_dev_array_lock); 84 spin_unlock(&i2c_dev_list_lock);
86 dev_err(&adap->dev, "i2c-dev already has a device assigned to this adapter\n");
87 goto error;
88 }
89 i2c_dev->minor = adap->nr;
90 i2c_dev_array[adap->nr] = i2c_dev;
91 spin_unlock(&i2c_dev_array_lock);
92 return i2c_dev; 85 return i2c_dev;
93error:
94 kfree(i2c_dev);
95 return ERR_PTR(-ENODEV);
96} 86}
97 87
98static void return_i2c_dev(struct i2c_dev *i2c_dev) 88static void return_i2c_dev(struct i2c_dev *i2c_dev)
99{ 89{
100 spin_lock(&i2c_dev_array_lock); 90 spin_lock(&i2c_dev_list_lock);
101 i2c_dev_array[i2c_dev->minor] = NULL; 91 list_del(&i2c_dev->list);
102 spin_unlock(&i2c_dev_array_lock); 92 spin_unlock(&i2c_dev_list_lock);
103} 93}
104 94
105static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) 95static ssize_t show_adapter_name(struct class_device *class_dev, char *buf)
@@ -375,12 +365,13 @@ static int i2cdev_open(struct inode *inode, struct file *file)
375 if (!adap) 365 if (!adap)
376 return -ENODEV; 366 return -ENODEV;
377 367
378 client = kmalloc(sizeof(*client), GFP_KERNEL); 368 client = kzalloc(sizeof(*client), GFP_KERNEL);
379 if (!client) { 369 if (!client) {
380 i2c_put_adapter(adap); 370 i2c_put_adapter(adap);
381 return -ENOMEM; 371 return -ENOMEM;
382 } 372 }
383 memcpy(client, &i2cdev_client_template, sizeof(*client)); 373 snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
374 client->driver = &i2cdev_driver;
384 375
385 /* registered with adapter, passed as client to user */ 376 /* registered with adapter, passed as client to user */
386 client->adapter = adap; 377 client->adapter = adap;
@@ -415,41 +406,47 @@ static struct class *i2c_dev_class;
415static int i2cdev_attach_adapter(struct i2c_adapter *adap) 406static int i2cdev_attach_adapter(struct i2c_adapter *adap)
416{ 407{
417 struct i2c_dev *i2c_dev; 408 struct i2c_dev *i2c_dev;
418 struct device *dev; 409 int res;
419 410
420 i2c_dev = get_free_i2c_dev(adap); 411 i2c_dev = get_free_i2c_dev(adap);
421 if (IS_ERR(i2c_dev)) 412 if (IS_ERR(i2c_dev))
422 return PTR_ERR(i2c_dev); 413 return PTR_ERR(i2c_dev);
423 414
424 pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
425 adap->name, i2c_dev->minor);
426
427 /* register this i2c device with the driver core */ 415 /* register this i2c device with the driver core */
428 i2c_dev->adap = adap;
429 dev = &adap->dev;
430 i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL, 416 i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL,
431 MKDEV(I2C_MAJOR, i2c_dev->minor), 417 MKDEV(I2C_MAJOR, adap->nr),
432 dev, "i2c-%d", i2c_dev->minor); 418 &adap->dev, "i2c-%d",
433 if (!i2c_dev->class_dev) 419 adap->nr);
420 if (!i2c_dev->class_dev) {
421 res = -ENODEV;
434 goto error; 422 goto error;
435 class_device_create_file(i2c_dev->class_dev, &class_device_attr_name); 423 }
424 res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
425 if (res)
426 goto error_destroy;
427
428 pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
429 adap->name, adap->nr);
436 return 0; 430 return 0;
431error_destroy:
432 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
437error: 433error:
438 return_i2c_dev(i2c_dev); 434 return_i2c_dev(i2c_dev);
439 kfree(i2c_dev); 435 kfree(i2c_dev);
440 return -ENODEV; 436 return res;
441} 437}
442 438
443static int i2cdev_detach_adapter(struct i2c_adapter *adap) 439static int i2cdev_detach_adapter(struct i2c_adapter *adap)
444{ 440{
445 struct i2c_dev *i2c_dev; 441 struct i2c_dev *i2c_dev;
446 442
447 i2c_dev = i2c_dev_get_by_adapter(adap); 443 i2c_dev = i2c_dev_get_by_minor(adap->nr);
448 if (!i2c_dev) 444 if (!i2c_dev) /* attach_adapter must have failed */
449 return -ENODEV; 445 return 0;
450 446
447 class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name);
451 return_i2c_dev(i2c_dev); 448 return_i2c_dev(i2c_dev);
452 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, i2c_dev->minor)); 449 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
453 kfree(i2c_dev); 450 kfree(i2c_dev);
454 451
455 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 452 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
@@ -471,12 +468,6 @@ static struct i2c_driver i2cdev_driver = {
471 .detach_client = i2cdev_detach_client, 468 .detach_client = i2cdev_detach_client,
472}; 469};
473 470
474static struct i2c_client i2cdev_client_template = {
475 .name = "I2C /dev entry",
476 .addr = -1,
477 .driver = &i2cdev_driver,
478};
479
480static int __init i2c_dev_init(void) 471static int __init i2c_dev_init(void)
481{ 472{
482 int res; 473 int res;
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index defd4b4bd374..9c8468de1a75 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1207,7 +1207,7 @@ int system_bus_clock (void)
1207 1207
1208EXPORT_SYMBOL(system_bus_clock); 1208EXPORT_SYMBOL(system_bus_clock);
1209 1209
1210static int generic_ide_suspend(struct device *dev, pm_message_t state) 1210static int generic_ide_suspend(struct device *dev, pm_message_t mesg)
1211{ 1211{
1212 ide_drive_t *drive = dev->driver_data; 1212 ide_drive_t *drive = dev->driver_data;
1213 struct request rq; 1213 struct request rq;
@@ -1221,7 +1221,9 @@ static int generic_ide_suspend(struct device *dev, pm_message_t state)
1221 rq.special = &args; 1221 rq.special = &args;
1222 rq.end_io_data = &rqpm; 1222 rq.end_io_data = &rqpm;
1223 rqpm.pm_step = ide_pm_state_start_suspend; 1223 rqpm.pm_step = ide_pm_state_start_suspend;
1224 rqpm.pm_state = state.event; 1224 if (mesg.event == PM_EVENT_PRETHAW)
1225 mesg.event = PM_EVENT_FREEZE;
1226 rqpm.pm_state = mesg.event;
1225 1227
1226 return ide_do_drive_cmd(drive, &rq, ide_wait); 1228 return ide_do_drive_cmd(drive, &rq, ide_wait);
1227} 1229}
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index 996c694341bc..31ad79f52df7 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1369,15 +1369,16 @@ pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
1369} 1369}
1370 1370
1371static int 1371static int
1372pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t state) 1372pmac_ide_macio_suspend(struct macio_dev *mdev, pm_message_t mesg)
1373{ 1373{
1374 ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev); 1374 ide_hwif_t *hwif = (ide_hwif_t *)dev_get_drvdata(&mdev->ofdev.dev);
1375 int rc = 0; 1375 int rc = 0;
1376 1376
1377 if (state.event != mdev->ofdev.dev.power.power_state.event && state.event >= PM_EVENT_SUSPEND) { 1377 if (mesg.event != mdev->ofdev.dev.power.power_state.event
1378 && mesg.event == PM_EVENT_SUSPEND) {
1378 rc = pmac_ide_do_suspend(hwif); 1379 rc = pmac_ide_do_suspend(hwif);
1379 if (rc == 0) 1380 if (rc == 0)
1380 mdev->ofdev.dev.power.power_state = state; 1381 mdev->ofdev.dev.power.power_state = mesg;
1381 } 1382 }
1382 1383
1383 return rc; 1384 return rc;
@@ -1473,15 +1474,16 @@ pmac_ide_pci_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1473} 1474}
1474 1475
1475static int 1476static int
1476pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t state) 1477pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1477{ 1478{
1478 ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev); 1479 ide_hwif_t *hwif = (ide_hwif_t *)pci_get_drvdata(pdev);
1479 int rc = 0; 1480 int rc = 0;
1480 1481
1481 if (state.event != pdev->dev.power.power_state.event && state.event >= 2) { 1482 if (mesg.event != pdev->dev.power.power_state.event
1483 && mesg.event == PM_EVENT_SUSPEND) {
1482 rc = pmac_ide_do_suspend(hwif); 1484 rc = pmac_ide_do_suspend(hwif);
1483 if (rc == 0) 1485 if (rc == 0)
1484 pdev->dev.power.power_state = state; 1486 pdev->dev.power.power_state = mesg;
1485 } 1487 }
1486 1488
1487 return rc; 1489 return rc;
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index e6f41238f5e8..b4f146f2c951 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -137,7 +137,6 @@ static struct i2c_algo_bit_data bit_data = {
137 .getsda = bit_getsda, 137 .getsda = bit_getsda,
138 .getscl = bit_getscl, 138 .getscl = bit_getscl,
139 .udelay = 5, 139 .udelay = 5,
140 .mdelay = 5,
141 .timeout = 100, 140 .timeout = 100,
142}; 141};
143 142
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 082f03c158f0..493f4c65c7a2 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -2987,10 +2987,7 @@ error1:
2987static void __exit ib_mad_cleanup_module(void) 2987static void __exit ib_mad_cleanup_module(void)
2988{ 2988{
2989 ib_unregister_client(&mad_client); 2989 ib_unregister_client(&mad_client);
2990 2990 kmem_cache_destroy(ib_mad_cache);
2991 if (kmem_cache_destroy(ib_mad_cache)) {
2992 printk(KERN_DEBUG PFX "Failed to destroy ib_mad cache\n");
2993 }
2994} 2991}
2995 2992
2996module_init(ib_mad_init_module); 2993module_init(ib_mad_init_module);
diff --git a/drivers/infiniband/hw/ipath/ipath_fs.c b/drivers/infiniband/hw/ipath/ipath_fs.c
index a5eb30a06a5c..c8a8af0fe471 100644
--- a/drivers/infiniband/hw/ipath/ipath_fs.c
+++ b/drivers/infiniband/hw/ipath/ipath_fs.c
@@ -61,10 +61,9 @@ static int ipathfs_mknod(struct inode *dir, struct dentry *dentry,
61 inode->i_mode = mode; 61 inode->i_mode = mode;
62 inode->i_uid = 0; 62 inode->i_uid = 0;
63 inode->i_gid = 0; 63 inode->i_gid = 0;
64 inode->i_blksize = PAGE_CACHE_SIZE;
65 inode->i_blocks = 0; 64 inode->i_blocks = 0;
66 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 65 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
67 inode->u.generic_ip = data; 66 inode->i_private = data;
68 if ((mode & S_IFMT) == S_IFDIR) { 67 if ((mode & S_IFMT) == S_IFDIR) {
69 inode->i_op = &simple_dir_inode_operations; 68 inode->i_op = &simple_dir_inode_operations;
70 inode->i_nlink++; 69 inode->i_nlink++;
@@ -119,7 +118,7 @@ static ssize_t atomic_counters_read(struct file *file, char __user *buf,
119 u16 i; 118 u16 i;
120 struct ipath_devdata *dd; 119 struct ipath_devdata *dd;
121 120
122 dd = file->f_dentry->d_inode->u.generic_ip; 121 dd = file->f_dentry->d_inode->i_private;
123 122
124 for (i = 0; i < NUM_COUNTERS; i++) 123 for (i = 0; i < NUM_COUNTERS; i++)
125 counters[i] = ipath_snap_cntr(dd, i); 124 counters[i] = ipath_snap_cntr(dd, i);
@@ -139,7 +138,7 @@ static ssize_t atomic_node_info_read(struct file *file, char __user *buf,
139 struct ipath_devdata *dd; 138 struct ipath_devdata *dd;
140 u64 guid; 139 u64 guid;
141 140
142 dd = file->f_dentry->d_inode->u.generic_ip; 141 dd = file->f_dentry->d_inode->i_private;
143 142
144 guid = be64_to_cpu(dd->ipath_guid); 143 guid = be64_to_cpu(dd->ipath_guid);
145 144
@@ -178,7 +177,7 @@ static ssize_t atomic_port_info_read(struct file *file, char __user *buf,
178 u32 tmp, tmp2; 177 u32 tmp, tmp2;
179 struct ipath_devdata *dd; 178 struct ipath_devdata *dd;
180 179
181 dd = file->f_dentry->d_inode->u.generic_ip; 180 dd = file->f_dentry->d_inode->i_private;
182 181
183 /* so we only initialize non-zero fields. */ 182 /* so we only initialize non-zero fields. */
184 memset(portinfo, 0, sizeof portinfo); 183 memset(portinfo, 0, sizeof portinfo);
@@ -325,7 +324,7 @@ static ssize_t flash_read(struct file *file, char __user *buf,
325 goto bail; 324 goto bail;
326 } 325 }
327 326
328 dd = file->f_dentry->d_inode->u.generic_ip; 327 dd = file->f_dentry->d_inode->i_private;
329 if (ipath_eeprom_read(dd, pos, tmp, count)) { 328 if (ipath_eeprom_read(dd, pos, tmp, count)) {
330 ipath_dev_err(dd, "failed to read from flash\n"); 329 ipath_dev_err(dd, "failed to read from flash\n");
331 ret = -ENXIO; 330 ret = -ENXIO;
@@ -381,7 +380,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
381 goto bail_tmp; 380 goto bail_tmp;
382 } 381 }
383 382
384 dd = file->f_dentry->d_inode->u.generic_ip; 383 dd = file->f_dentry->d_inode->i_private;
385 if (ipath_eeprom_write(dd, pos, tmp, count)) { 384 if (ipath_eeprom_write(dd, pos, tmp, count)) {
386 ret = -ENXIO; 385 ret = -ENXIO;
387 ipath_dev_err(dd, "failed to write to flash\n"); 386 ipath_dev_err(dd, "failed to write to flash\n");
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c
index bf2455a6d562..5c9b509e40e4 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba6110.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c
@@ -742,7 +742,6 @@ static int ipath_setup_ht_reset(struct ipath_devdata *dd)
742 return 0; 742 return 0;
743} 743}
744 744
745#define HT_CAPABILITY_ID 0x08 /* HT capabilities not defined in kernel */
746#define HT_INTR_DISC_CONFIG 0x80 /* HT interrupt and discovery cap */ 745#define HT_INTR_DISC_CONFIG 0x80 /* HT interrupt and discovery cap */
747#define HT_INTR_REG_INDEX 2 /* intconfig requires indirect accesses */ 746#define HT_INTR_REG_INDEX 2 /* intconfig requires indirect accesses */
748 747
@@ -973,7 +972,7 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd,
973 * do this early, before we ever enable errors or hardware errors, 972 * do this early, before we ever enable errors or hardware errors,
974 * mostly to avoid causing the chip to enter freeze mode. 973 * mostly to avoid causing the chip to enter freeze mode.
975 */ 974 */
976 pos = pci_find_capability(pdev, HT_CAPABILITY_ID); 975 pos = pci_find_capability(pdev, PCI_CAP_ID_HT);
977 if (!pos) { 976 if (!pos) {
978 ipath_dev_err(dd, "Couldn't find HyperTransport " 977 ipath_dev_err(dd, "Couldn't find HyperTransport "
979 "capability; no interrupts\n"); 978 "capability; no interrupts\n");
@@ -996,7 +995,7 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd,
996 else if (cap_type == HT_INTR_DISC_CONFIG) 995 else if (cap_type == HT_INTR_DISC_CONFIG)
997 ihandler = set_int_handler(dd, pdev, pos); 996 ihandler = set_int_handler(dd, pdev, pos);
998 } while ((pos = pci_find_next_capability(pdev, pos, 997 } while ((pos = pci_find_next_capability(pdev, pos,
999 HT_CAPABILITY_ID))); 998 PCI_CAP_ID_HT)));
1000 999
1001 if (!ihandler) { 1000 if (!ihandler) {
1002 ipath_dev_err(dd, "Couldn't find interrupt handler in " 1001 ipath_dev_err(dd, "Couldn't find interrupt handler in "
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 5dde380e8dbe..f1cb83688b31 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -141,7 +141,7 @@ static int ipoib_mcg_open(struct inode *inode, struct file *file)
141 return ret; 141 return ret;
142 142
143 seq = file->private_data; 143 seq = file->private_data;
144 seq->private = inode->u.generic_ip; 144 seq->private = inode->i_private;
145 145
146 return 0; 146 return 0;
147} 147}
@@ -247,7 +247,7 @@ static int ipoib_path_open(struct inode *inode, struct file *file)
247 return ret; 247 return ret;
248 248
249 seq = file->private_data; 249 seq = file->private_data;
250 seq->private = inode->u.generic_ip; 250 seq->private = inode->i_private;
251 251
252 return 0; 252 return 0;
253} 253}
diff --git a/drivers/input/touchscreen/hp680_ts_input.c b/drivers/input/touchscreen/hp680_ts_input.c
index fa97e0f79e7e..ee6c2f40cdf6 100644
--- a/drivers/input/touchscreen/hp680_ts_input.c
+++ b/drivers/input/touchscreen/hp680_ts_input.c
@@ -15,7 +15,6 @@
15#define HP680_TS_ABS_Y_MIN 80 15#define HP680_TS_ABS_Y_MIN 80
16#define HP680_TS_ABS_Y_MAX 910 16#define HP680_TS_ABS_Y_MAX 910
17 17
18#define SCPCR 0xa4000116
19#define PHDR 0xa400012e 18#define PHDR 0xa400012e
20#define SCPDR 0xa4000136 19#define SCPDR 0xa4000136
21 20
@@ -77,19 +76,6 @@ static irqreturn_t hp680_ts_interrupt(int irq, void *dev, struct pt_regs *regs)
77 76
78static int __init hp680_ts_init(void) 77static int __init hp680_ts_init(void)
79{ 78{
80 u8 scpdr;
81 u16 scpcr;
82
83 scpdr = ctrl_inb(SCPDR);
84 scpdr |= SCPDR_TS_SCAN_X | SCPDR_TS_SCAN_Y;
85 scpdr &= ~SCPDR_TS_SCAN_ENABLE;
86 ctrl_outb(scpdr, SCPDR);
87
88 scpcr = ctrl_inw(SCPCR);
89 scpcr &= ~SCPCR_TS_MASK;
90 scpcr |= SCPCR_TS_ENABLE;
91 ctrl_outw(scpcr, SCPCR);
92
93 hp680_ts_dev = input_allocate_device(); 79 hp680_ts_dev = input_allocate_device();
94 if (!hp680_ts_dev) 80 if (!hp680_ts_dev)
95 return -ENOMEM; 81 return -ENOMEM;
diff --git a/drivers/isdn/capi/capifs.c b/drivers/isdn/capi/capifs.c
index 9ea6bd0ddc35..2dd1b57b0ba4 100644
--- a/drivers/isdn/capi/capifs.c
+++ b/drivers/isdn/capi/capifs.c
@@ -104,7 +104,6 @@ capifs_fill_super(struct super_block *s, void *data, int silent)
104 inode->i_ino = 1; 104 inode->i_ino = 1;
105 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 105 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
106 inode->i_blocks = 0; 106 inode->i_blocks = 0;
107 inode->i_blksize = 1024;
108 inode->i_uid = inode->i_gid = 0; 107 inode->i_uid = inode->i_gid = 0;
109 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 108 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
110 inode->i_op = &simple_dir_inode_operations; 109 inode->i_op = &simple_dir_inode_operations;
@@ -149,7 +148,6 @@ void capifs_new_ncci(unsigned int number, dev_t device)
149 if (!inode) 148 if (!inode)
150 return; 149 return;
151 inode->i_ino = number+2; 150 inode->i_ino = number+2;
152 inode->i_blksize = 1024;
153 inode->i_uid = config.setuid ? config.uid : current->fsuid; 151 inode->i_uid = config.setuid ? config.uid : current->fsuid;
154 inode->i_gid = config.setgid ? config.gid : current->fsgid; 152 inode->i_gid = config.setgid ? config.gid : current->fsgid;
155 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 153 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 3845defd4901..5cfbe6a38010 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -192,7 +192,7 @@ static char *get_usb_statmsg(int status)
192 return "bit stuffing error, timeout, or unknown USB error"; 192 return "bit stuffing error, timeout, or unknown USB error";
193 case -EILSEQ: 193 case -EILSEQ:
194 return "CRC mismatch, timeout, or unknown USB error"; 194 return "CRC mismatch, timeout, or unknown USB error";
195 case -ETIMEDOUT: 195 case -ETIME:
196 return "timed out"; 196 return "timed out";
197 case -EPIPE: 197 case -EPIPE:
198 return "endpoint stalled"; 198 return "endpoint stalled";
diff --git a/drivers/isdn/hisax/hfc_usb.h b/drivers/isdn/hisax/hfc_usb.h
index ec52c1a7c22a..6349367ed480 100644
--- a/drivers/isdn/hisax/hfc_usb.h
+++ b/drivers/isdn/hisax/hfc_usb.h
@@ -137,11 +137,11 @@ static struct hfcusb_symbolic_list urb_errlist[] = {
137 {-ENXIO, "URB already queued"}, 137 {-ENXIO, "URB already queued"},
138 {-EFBIG, "Too much ISO frames requested"}, 138 {-EFBIG, "Too much ISO frames requested"},
139 {-ENOSR, "Buffer error (overrun)"}, 139 {-ENOSR, "Buffer error (overrun)"},
140 {-EPIPE, "Specified endpoint is stalled (device not responding)"}, 140 {-EPIPE, "Specified endpoint is stalled"},
141 {-EOVERFLOW, "Babble (bad cable?)"}, 141 {-EOVERFLOW, "Babble (bad cable?)"},
142 {-EPROTO, "Bit-stuff error (bad cable?)"}, 142 {-EPROTO, "Bit-stuff error (bad cable?)"},
143 {-EILSEQ, "CRC/Timeout"}, 143 {-EILSEQ, "CRC or missing token"},
144 {-ETIMEDOUT, "NAK (device does not respond)"}, 144 {-ETIME, "Device did not respond"},
145 {-ESHUTDOWN, "Device unplugged"}, 145 {-ESHUTDOWN, "Device unplugged"},
146 {-1, NULL} 146 {-1, NULL}
147}; 147};
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 001c71b6be61..410fa6d620ff 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -981,7 +981,7 @@ static int cinergyt2_suspend (struct usb_interface *intf, pm_message_t state)
981 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem)) 981 if (cinergyt2->disconnect_pending || mutex_lock_interruptible(&cinergyt2->sem))
982 return -ERESTARTSYS; 982 return -ERESTARTSYS;
983 983
984 if (state.event > PM_EVENT_ON) { 984 if (1) {
985 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf); 985 struct cinergyt2 *cinergyt2 = usb_get_intfdata (intf);
986 986
987 cinergyt2_suspend_rc(cinergyt2); 987 cinergyt2_suspend_rc(cinergyt2);
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
index 9002f35aa952..88b283731bb8 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-urb.c
@@ -80,7 +80,6 @@ static void dvb_usb_urb_complete(struct urb *urb, struct pt_regs *ptregs)
80 80
81 switch (urb->status) { 81 switch (urb->status) {
82 case 0: /* success */ 82 case 0: /* success */
83 case -ETIMEDOUT: /* NAK */
84 break; 83 break;
85 case -ECONNRESET: /* kill */ 84 case -ECONNRESET: /* kill */
86 case -ENOENT: 85 case -ENOENT:
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 6c1cb770bcf5..c9d663549dff 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -215,7 +215,7 @@ static void ttusb_dec_handle_irq( struct urb *urb, struct pt_regs *regs)
215 case -ECONNRESET: 215 case -ECONNRESET:
216 case -ENOENT: 216 case -ENOENT:
217 case -ESHUTDOWN: 217 case -ESHUTDOWN:
218 case -ETIMEDOUT: 218 case -ETIME:
219 /* this urb is dead, cleanup */ 219 /* this urb is dead, cleanup */
220 dprintk("%s:urb shutting down with status: %d\n", 220 dprintk("%s:urb shutting down with status: %d\n",
221 __FUNCTION__, urb->status); 221 __FUNCTION__, urb->status);
diff --git a/drivers/media/video/bt8xx/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 4b562b386fcf..0dfbcc85ebb9 100644
--- a/drivers/media/video/bt8xx/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -100,7 +100,6 @@ static struct i2c_algo_bit_data bttv_i2c_algo_bit_template = {
100 .getsda = bttv_bit_getsda, 100 .getsda = bttv_bit_getsda,
101 .getscl = bttv_bit_getscl, 101 .getscl = bttv_bit_getscl,
102 .udelay = 16, 102 .udelay = 16,
103 .mdelay = 10,
104 .timeout = 200, 103 .timeout = 200,
105}; 104};
106 105
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 70663805cc30..7bea34714861 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -155,7 +155,6 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
155 .getsda = cx8800_bit_getsda, 155 .getsda = cx8800_bit_getsda,
156 .getscl = cx8800_bit_getscl, 156 .getscl = cx8800_bit_getscl,
157 .udelay = 16, 157 .udelay = 16,
158 .mdelay = 10,
159 .timeout = 200, 158 .timeout = 200,
160}; 159};
161 160
diff --git a/drivers/media/video/cx88/cx88-vp3054-i2c.c b/drivers/media/video/cx88/cx88-vp3054-i2c.c
index 751a754a45e9..2b4f1970c7df 100644
--- a/drivers/media/video/cx88/cx88-vp3054-i2c.c
+++ b/drivers/media/video/cx88/cx88-vp3054-i2c.c
@@ -100,7 +100,6 @@ static struct i2c_algo_bit_data vp3054_i2c_algo_template = {
100 .getsda = vp3054_bit_getsda, 100 .getsda = vp3054_bit_getsda,
101 .getscl = vp3054_bit_getscl, 101 .getscl = vp3054_bit_getscl,
102 .udelay = 16, 102 .udelay = 16,
103 .mdelay = 10,
104 .timeout = 200, 103 .timeout = 200,
105}; 104};
106 105
diff --git a/drivers/media/video/ov511.c b/drivers/media/video/ov511.c
index 1b07a61c2ebb..5d8cd283fcd8 100644
--- a/drivers/media/video/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -301,10 +301,11 @@ static struct symbolic_list senlist[] = {
301static struct symbolic_list urb_errlist[] = { 301static struct symbolic_list urb_errlist[] = {
302 { -ENOSR, "Buffer error (overrun)" }, 302 { -ENOSR, "Buffer error (overrun)" },
303 { -EPIPE, "Stalled (device not responding)" }, 303 { -EPIPE, "Stalled (device not responding)" },
304 { -EOVERFLOW, "Babble (bad cable?)" }, 304 { -EOVERFLOW, "Babble (device sends too much data)" },
305 { -EPROTO, "Bit-stuff error (bad cable?)" }, 305 { -EPROTO, "Bit-stuff error (bad cable?)" },
306 { -EILSEQ, "CRC/Timeout" }, 306 { -EILSEQ, "CRC/Timeout (bad cable?)" },
307 { -ETIMEDOUT, "NAK (device does not respond)" }, 307 { -ETIME, "Device does not respond to token" },
308 { -ETIMEDOUT, "Device does not respond to command" },
308 { -1, NULL } 309 { -1, NULL }
309}; 310};
310 311
diff --git a/drivers/media/video/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index d4703944df9c..53c4b5790d5c 100644
--- a/drivers/media/video/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -711,7 +711,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
711 case -EOVERFLOW: errmsg = "Babble (bad cable?)"; break; 711 case -EOVERFLOW: errmsg = "Babble (bad cable?)"; break;
712 case -EPROTO: errmsg = "Bit-stuff error (bad cable?)"; break; 712 case -EPROTO: errmsg = "Bit-stuff error (bad cable?)"; break;
713 case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break; 713 case -EILSEQ: errmsg = "CRC/Timeout (could be anything)"; break;
714 case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break; 714 case -ETIME: errmsg = "Device does not respond"; break;
715 } 715 }
716 PWC_DEBUG_FLOW("pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg); 716 PWC_DEBUG_FLOW("pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
717 /* Give up after a number of contiguous errors on the USB bus. 717 /* Give up after a number of contiguous errors on the USB bus.
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c
index 20f211b55ad4..2912326a5aef 100644
--- a/drivers/media/video/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -586,15 +586,14 @@ static struct w9968cf_symbolic_list urb_errlist[] = {
586 { -EFBIG, "Too much ISO frames requested" }, 586 { -EFBIG, "Too much ISO frames requested" },
587 { -ENOSR, "Buffer error (overrun)" }, 587 { -ENOSR, "Buffer error (overrun)" },
588 { -EPIPE, "Specified endpoint is stalled (device not responding)"}, 588 { -EPIPE, "Specified endpoint is stalled (device not responding)"},
589 { -EOVERFLOW, "Babble (bad cable?)" }, 589 { -EOVERFLOW, "Babble (too much data)" },
590 { -EPROTO, "Bit-stuff error (bad cable?)" }, 590 { -EPROTO, "Bit-stuff error (bad cable?)" },
591 { -EILSEQ, "CRC/Timeout" }, 591 { -EILSEQ, "CRC/Timeout" },
592 { -ETIMEDOUT, "NAK (device does not respond)" }, 592 { -ETIME, "Device does not respond to token" },
593 { -ETIMEDOUT, "Device does not respond to command" },
593 { -1, NULL } 594 { -1, NULL }
594}; 595};
595 596
596
597
598/**************************************************************************** 597/****************************************************************************
599 * Memory management functions * 598 * Memory management functions *
600 ****************************************************************************/ 599 ****************************************************************************/
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index f2249ed25273..29f59c36f001 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -820,7 +820,6 @@ static struct i2c_algo_bit_data zoran_i2c_bit_data_template = {
820 .getsda = zoran_i2c_getsda, 820 .getsda = zoran_i2c_getsda,
821 .getscl = zoran_i2c_getscl, 821 .getscl = zoran_i2c_getscl,
822 .udelay = 10, 822 .udelay = 10,
823 .mdelay = 0,
824 .timeout = 100, 823 .timeout = 100,
825}; 824};
826 825
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index 4a35caff5d02..b99dc507de2e 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -147,7 +147,6 @@ static struct inode *ibmasmfs_make_inode(struct super_block *sb, int mode)
147 if (ret) { 147 if (ret) {
148 ret->i_mode = mode; 148 ret->i_mode = mode;
149 ret->i_uid = ret->i_gid = 0; 149 ret->i_uid = ret->i_gid = 0;
150 ret->i_blksize = PAGE_CACHE_SIZE;
151 ret->i_blocks = 0; 150 ret->i_blocks = 0;
152 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 151 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
153 } 152 }
@@ -175,7 +174,7 @@ static struct dentry *ibmasmfs_create_file (struct super_block *sb,
175 } 174 }
176 175
177 inode->i_fop = fops; 176 inode->i_fop = fops;
178 inode->u.generic_ip = data; 177 inode->i_private = data;
179 178
180 d_add(dentry, inode); 179 d_add(dentry, inode);
181 return dentry; 180 return dentry;
@@ -244,7 +243,7 @@ static int command_file_open(struct inode *inode, struct file *file)
244{ 243{
245 struct ibmasmfs_command_data *command_data; 244 struct ibmasmfs_command_data *command_data;
246 245
247 if (!inode->u.generic_ip) 246 if (!inode->i_private)
248 return -ENODEV; 247 return -ENODEV;
249 248
250 command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL); 249 command_data = kmalloc(sizeof(struct ibmasmfs_command_data), GFP_KERNEL);
@@ -252,7 +251,7 @@ static int command_file_open(struct inode *inode, struct file *file)
252 return -ENOMEM; 251 return -ENOMEM;
253 252
254 command_data->command = NULL; 253 command_data->command = NULL;
255 command_data->sp = inode->u.generic_ip; 254 command_data->sp = inode->i_private;
256 file->private_data = command_data; 255 file->private_data = command_data;
257 return 0; 256 return 0;
258} 257}
@@ -351,10 +350,10 @@ static int event_file_open(struct inode *inode, struct file *file)
351 struct ibmasmfs_event_data *event_data; 350 struct ibmasmfs_event_data *event_data;
352 struct service_processor *sp; 351 struct service_processor *sp;
353 352
354 if (!inode->u.generic_ip) 353 if (!inode->i_private)
355 return -ENODEV; 354 return -ENODEV;
356 355
357 sp = inode->u.generic_ip; 356 sp = inode->i_private;
358 357
359 event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL); 358 event_data = kmalloc(sizeof(struct ibmasmfs_event_data), GFP_KERNEL);
360 if (!event_data) 359 if (!event_data)
@@ -439,14 +438,14 @@ static int r_heartbeat_file_open(struct inode *inode, struct file *file)
439{ 438{
440 struct ibmasmfs_heartbeat_data *rhbeat; 439 struct ibmasmfs_heartbeat_data *rhbeat;
441 440
442 if (!inode->u.generic_ip) 441 if (!inode->i_private)
443 return -ENODEV; 442 return -ENODEV;
444 443
445 rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL); 444 rhbeat = kmalloc(sizeof(struct ibmasmfs_heartbeat_data), GFP_KERNEL);
446 if (!rhbeat) 445 if (!rhbeat)
447 return -ENOMEM; 446 return -ENOMEM;
448 447
449 rhbeat->sp = (struct service_processor *)inode->u.generic_ip; 448 rhbeat->sp = inode->i_private;
450 rhbeat->active = 0; 449 rhbeat->active = 0;
451 ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat); 450 ibmasm_init_reverse_heartbeat(rhbeat->sp, &rhbeat->heartbeat);
452 file->private_data = rhbeat; 451 file->private_data = rhbeat;
@@ -508,7 +507,7 @@ static ssize_t r_heartbeat_file_write(struct file *file, const char __user *buf,
508 507
509static int remote_settings_file_open(struct inode *inode, struct file *file) 508static int remote_settings_file_open(struct inode *inode, struct file *file)
510{ 509{
511 file->private_data = inode->u.generic_ip; 510 file->private_data = inode->i_private;
512 return 0; 511 return 0;
513} 512}
514 513
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 59c33925be62..b936373ab2a5 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -225,6 +225,7 @@ static struct eisa_device_id el3_eisa_ids[] = {
225 { "TCM5095" }, 225 { "TCM5095" },
226 { "" } 226 { "" }
227}; 227};
228MODULE_DEVICE_TABLE(eisa, el3_eisa_ids);
228 229
229static int el3_eisa_probe (struct device *device); 230static int el3_eisa_probe (struct device *device);
230 231
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index af301f09d674..df42e28cc80f 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -851,6 +851,7 @@ static struct eisa_device_id vortex_eisa_ids[] = {
851 { "TCM5970", CH_3C597 }, 851 { "TCM5970", CH_3C597 },
852 { "" } 852 { "" }
853}; 853};
854MODULE_DEVICE_TABLE(eisa, vortex_eisa_ids);
854 855
855static int vortex_eisa_probe(struct device *device); 856static int vortex_eisa_probe(struct device *device);
856static int vortex_eisa_remove(struct device *device); 857static int vortex_eisa_remove(struct device *device);
diff --git a/drivers/net/acenic.c b/drivers/net/acenic.c
index a075246f6f43..71a4f60f7325 100644
--- a/drivers/net/acenic.c
+++ b/drivers/net/acenic.c
@@ -163,11 +163,7 @@ MODULE_DEVICE_TABLE(pci, acenic_pci_tbl);
163#define SET_NETDEV_DEV(net, pdev) do{} while(0) 163#define SET_NETDEV_DEV(net, pdev) do{} while(0)
164#endif 164#endif
165 165
166#if LINUX_VERSION_CODE >= 0x2051c
167#define ace_sync_irq(irq) synchronize_irq(irq) 166#define ace_sync_irq(irq) synchronize_irq(irq)
168#else
169#define ace_sync_irq(irq) synchronize_irq()
170#endif
171 167
172#ifndef offset_in_page 168#ifndef offset_in_page
173#define offset_in_page(ptr) ((unsigned long)(ptr) & ~PAGE_MASK) 169#define offset_in_page(ptr) ((unsigned long)(ptr) & ~PAGE_MASK)
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index 6a407070c2e8..3fb354d9c515 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -85,6 +85,7 @@
85#define AD_LINK_SPEED_BITMASK_10MBPS 0x2 85#define AD_LINK_SPEED_BITMASK_10MBPS 0x2
86#define AD_LINK_SPEED_BITMASK_100MBPS 0x4 86#define AD_LINK_SPEED_BITMASK_100MBPS 0x4
87#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8 87#define AD_LINK_SPEED_BITMASK_1000MBPS 0x8
88#define AD_LINK_SPEED_BITMASK_10000MBPS 0x10
88//endalloun 89//endalloun
89 90
90// compare MAC addresses 91// compare MAC addresses
@@ -99,7 +100,7 @@ static u16 __get_link_speed(struct port *port);
99static u8 __get_duplex(struct port *port); 100static u8 __get_duplex(struct port *port);
100static inline void __initialize_port_locks(struct port *port); 101static inline void __initialize_port_locks(struct port *port);
101//conversions 102//conversions
102static void __ntohs_lacpdu(struct lacpdu *lacpdu); 103static void __htons_lacpdu(struct lacpdu *lacpdu);
103static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par); 104static u16 __ad_timer_to_ticks(u16 timer_type, u16 Par);
104 105
105 106
@@ -330,7 +331,8 @@ static inline void __release_rx_machine_lock(struct port *port)
330 * 0, 331 * 0,
331 * %AD_LINK_SPEED_BITMASK_10MBPS, 332 * %AD_LINK_SPEED_BITMASK_10MBPS,
332 * %AD_LINK_SPEED_BITMASK_100MBPS, 333 * %AD_LINK_SPEED_BITMASK_100MBPS,
333 * %AD_LINK_SPEED_BITMASK_1000MBPS 334 * %AD_LINK_SPEED_BITMASK_1000MBPS,
335 * %AD_LINK_SPEED_BITMASK_10000MBPS
334 */ 336 */
335static u16 __get_link_speed(struct port *port) 337static u16 __get_link_speed(struct port *port)
336{ 338{
@@ -357,6 +359,10 @@ static u16 __get_link_speed(struct port *port)
357 speed = AD_LINK_SPEED_BITMASK_1000MBPS; 359 speed = AD_LINK_SPEED_BITMASK_1000MBPS;
358 break; 360 break;
359 361
362 case SPEED_10000:
363 speed = AD_LINK_SPEED_BITMASK_10000MBPS;
364 break;
365
360 default: 366 default:
361 speed = 0; // unknown speed value from ethtool. shouldn't happen 367 speed = 0; // unknown speed value from ethtool. shouldn't happen
362 break; 368 break;
@@ -414,23 +420,23 @@ static inline void __initialize_port_locks(struct port *port)
414 420
415//conversions 421//conversions
416/** 422/**
417 * __ntohs_lacpdu - convert the contents of a LACPDU to host byte order 423 * __htons_lacpdu - convert the contents of a LACPDU to network byte order
418 * @lacpdu: the speicifed lacpdu 424 * @lacpdu: the speicifed lacpdu
419 * 425 *
420 * For each multi-byte field in the lacpdu, convert its content 426 * For each multi-byte field in the lacpdu, convert its content
421 */ 427 */
422static void __ntohs_lacpdu(struct lacpdu *lacpdu) 428static void __htons_lacpdu(struct lacpdu *lacpdu)
423{ 429{
424 if (lacpdu) { 430 if (lacpdu) {
425 lacpdu->actor_system_priority = ntohs(lacpdu->actor_system_priority); 431 lacpdu->actor_system_priority = htons(lacpdu->actor_system_priority);
426 lacpdu->actor_key = ntohs(lacpdu->actor_key); 432 lacpdu->actor_key = htons(lacpdu->actor_key);
427 lacpdu->actor_port_priority = ntohs(lacpdu->actor_port_priority); 433 lacpdu->actor_port_priority = htons(lacpdu->actor_port_priority);
428 lacpdu->actor_port = ntohs(lacpdu->actor_port); 434 lacpdu->actor_port = htons(lacpdu->actor_port);
429 lacpdu->partner_system_priority = ntohs(lacpdu->partner_system_priority); 435 lacpdu->partner_system_priority = htons(lacpdu->partner_system_priority);
430 lacpdu->partner_key = ntohs(lacpdu->partner_key); 436 lacpdu->partner_key = htons(lacpdu->partner_key);
431 lacpdu->partner_port_priority = ntohs(lacpdu->partner_port_priority); 437 lacpdu->partner_port_priority = htons(lacpdu->partner_port_priority);
432 lacpdu->partner_port = ntohs(lacpdu->partner_port); 438 lacpdu->partner_port = htons(lacpdu->partner_port);
433 lacpdu->collector_max_delay = ntohs(lacpdu->collector_max_delay); 439 lacpdu->collector_max_delay = htons(lacpdu->collector_max_delay);
434 } 440 }
435} 441}
436 442
@@ -490,11 +496,11 @@ static void __record_pdu(struct lacpdu *lacpdu, struct port *port)
490 // validate lacpdu and port 496 // validate lacpdu and port
491 if (lacpdu && port) { 497 if (lacpdu && port) {
492 // record the new parameter values for the partner operational 498 // record the new parameter values for the partner operational
493 port->partner_oper_port_number = lacpdu->actor_port; 499 port->partner_oper_port_number = ntohs(lacpdu->actor_port);
494 port->partner_oper_port_priority = lacpdu->actor_port_priority; 500 port->partner_oper_port_priority = ntohs(lacpdu->actor_port_priority);
495 port->partner_oper_system = lacpdu->actor_system; 501 port->partner_oper_system = lacpdu->actor_system;
496 port->partner_oper_system_priority = lacpdu->actor_system_priority; 502 port->partner_oper_system_priority = ntohs(lacpdu->actor_system_priority);
497 port->partner_oper_key = lacpdu->actor_key; 503 port->partner_oper_key = ntohs(lacpdu->actor_key);
498 // zero partener's lase states 504 // zero partener's lase states
499 port->partner_oper_port_state = 0; 505 port->partner_oper_port_state = 0;
500 port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY); 506 port->partner_oper_port_state |= (lacpdu->actor_state & AD_STATE_LACP_ACTIVITY);
@@ -561,11 +567,11 @@ static void __update_selected(struct lacpdu *lacpdu, struct port *port)
561 // validate lacpdu and port 567 // validate lacpdu and port
562 if (lacpdu && port) { 568 if (lacpdu && port) {
563 // check if any parameter is different 569 // check if any parameter is different
564 if ((lacpdu->actor_port != port->partner_oper_port_number) || 570 if ((ntohs(lacpdu->actor_port) != port->partner_oper_port_number) ||
565 (lacpdu->actor_port_priority != port->partner_oper_port_priority) || 571 (ntohs(lacpdu->actor_port_priority) != port->partner_oper_port_priority) ||
566 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) || 572 MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->partner_oper_system)) ||
567 (lacpdu->actor_system_priority != port->partner_oper_system_priority) || 573 (ntohs(lacpdu->actor_system_priority) != port->partner_oper_system_priority) ||
568 (lacpdu->actor_key != port->partner_oper_key) || 574 (ntohs(lacpdu->actor_key) != port->partner_oper_key) ||
569 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION)) 575 ((lacpdu->actor_state & AD_STATE_AGGREGATION) != (port->partner_oper_port_state & AD_STATE_AGGREGATION))
570 ) { 576 ) {
571 // update the state machine Selected variable 577 // update the state machine Selected variable
@@ -628,11 +634,11 @@ static void __choose_matched(struct lacpdu *lacpdu, struct port *port)
628 // validate lacpdu and port 634 // validate lacpdu and port
629 if (lacpdu && port) { 635 if (lacpdu && port) {
630 // check if all parameters are alike 636 // check if all parameters are alike
631 if (((lacpdu->partner_port == port->actor_port_number) && 637 if (((ntohs(lacpdu->partner_port) == port->actor_port_number) &&
632 (lacpdu->partner_port_priority == port->actor_port_priority) && 638 (ntohs(lacpdu->partner_port_priority) == port->actor_port_priority) &&
633 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) && 639 !MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) &&
634 (lacpdu->partner_system_priority == port->actor_system_priority) && 640 (ntohs(lacpdu->partner_system_priority) == port->actor_system_priority) &&
635 (lacpdu->partner_key == port->actor_oper_port_key) && 641 (ntohs(lacpdu->partner_key) == port->actor_oper_port_key) &&
636 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) || 642 ((lacpdu->partner_state & AD_STATE_AGGREGATION) == (port->actor_oper_port_state & AD_STATE_AGGREGATION))) ||
637 // or this is individual link(aggregation == FALSE) 643 // or this is individual link(aggregation == FALSE)
638 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0) 644 ((lacpdu->actor_state & AD_STATE_AGGREGATION) == 0)
@@ -662,11 +668,11 @@ static void __update_ntt(struct lacpdu *lacpdu, struct port *port)
662 // validate lacpdu and port 668 // validate lacpdu and port
663 if (lacpdu && port) { 669 if (lacpdu && port) {
664 // check if any parameter is different 670 // check if any parameter is different
665 if ((lacpdu->partner_port != port->actor_port_number) || 671 if ((ntohs(lacpdu->partner_port) != port->actor_port_number) ||
666 (lacpdu->partner_port_priority != port->actor_port_priority) || 672 (ntohs(lacpdu->partner_port_priority) != port->actor_port_priority) ||
667 MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) || 673 MAC_ADDRESS_COMPARE(&(lacpdu->partner_system), &(port->actor_system)) ||
668 (lacpdu->partner_system_priority != port->actor_system_priority) || 674 (ntohs(lacpdu->partner_system_priority) != port->actor_system_priority) ||
669 (lacpdu->partner_key != port->actor_oper_port_key) || 675 (ntohs(lacpdu->partner_key) != port->actor_oper_port_key) ||
670 ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) || 676 ((lacpdu->partner_state & AD_STATE_LACP_ACTIVITY) != (port->actor_oper_port_state & AD_STATE_LACP_ACTIVITY)) ||
671 ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) || 677 ((lacpdu->partner_state & AD_STATE_LACP_TIMEOUT) != (port->actor_oper_port_state & AD_STATE_LACP_TIMEOUT)) ||
672 ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) || 678 ((lacpdu->partner_state & AD_STATE_SYNCHRONIZATION) != (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION)) ||
@@ -775,6 +781,9 @@ static u32 __get_agg_bandwidth(struct aggregator *aggregator)
775 case AD_LINK_SPEED_BITMASK_1000MBPS: 781 case AD_LINK_SPEED_BITMASK_1000MBPS:
776 bandwidth = aggregator->num_of_ports * 1000; 782 bandwidth = aggregator->num_of_ports * 1000;
777 break; 783 break;
784 case AD_LINK_SPEED_BITMASK_10000MBPS:
785 bandwidth = aggregator->num_of_ports * 10000;
786 break;
778 default: 787 default:
779 bandwidth=0; // to silent the compilor .... 788 bandwidth=0; // to silent the compilor ....
780 } 789 }
@@ -847,7 +856,7 @@ static inline void __update_lacpdu_from_port(struct port *port)
847 */ 856 */
848 857
849 /* Convert all non u8 parameters to Big Endian for transmit */ 858 /* Convert all non u8 parameters to Big Endian for transmit */
850 __ntohs_lacpdu(lacpdu); 859 __htons_lacpdu(lacpdu);
851} 860}
852 861
853////////////////////////////////////////////////////////////////////////////////////// 862//////////////////////////////////////////////////////////////////////////////////////
@@ -2171,7 +2180,6 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2171 2180
2172 switch (lacpdu->subtype) { 2181 switch (lacpdu->subtype) {
2173 case AD_TYPE_LACPDU: 2182 case AD_TYPE_LACPDU:
2174 __ntohs_lacpdu(lacpdu);
2175 dprintk("Received LACPDU on port %d\n", port->actor_port_number); 2183 dprintk("Received LACPDU on port %d\n", port->actor_port_number);
2176 ad_rx_machine(lacpdu, port); 2184 ad_rx_machine(lacpdu, port);
2177 break; 2185 break;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 850aae21a2fe..0fb5f653d3ce 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -96,6 +96,7 @@ static char *lacp_rate = NULL;
96static char *xmit_hash_policy = NULL; 96static char *xmit_hash_policy = NULL;
97static int arp_interval = BOND_LINK_ARP_INTERV; 97static int arp_interval = BOND_LINK_ARP_INTERV;
98static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 98static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
99static char *arp_validate = NULL;
99struct bond_params bonding_defaults; 100struct bond_params bonding_defaults;
100 101
101module_param(max_bonds, int, 0); 102module_param(max_bonds, int, 0);
@@ -127,6 +128,8 @@ module_param(arp_interval, int, 0);
127MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); 128MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
128module_param_array(arp_ip_target, charp, NULL, 0); 129module_param_array(arp_ip_target, charp, NULL, 0);
129MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); 130MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
131module_param(arp_validate, charp, 0);
132MODULE_PARM_DESC(arp_validate, "validate src/dst of ARP probes: none (default), active, backup or all");
130 133
131/*----------------------------- Global variables ----------------------------*/ 134/*----------------------------- Global variables ----------------------------*/
132 135
@@ -170,6 +173,14 @@ struct bond_parm_tbl xmit_hashtype_tbl[] = {
170{ NULL, -1}, 173{ NULL, -1},
171}; 174};
172 175
176struct bond_parm_tbl arp_validate_tbl[] = {
177{ "none", BOND_ARP_VALIDATE_NONE},
178{ "active", BOND_ARP_VALIDATE_ACTIVE},
179{ "backup", BOND_ARP_VALIDATE_BACKUP},
180{ "all", BOND_ARP_VALIDATE_ALL},
181{ NULL, -1},
182};
183
173/*-------------------------- Forward declarations ---------------------------*/ 184/*-------------------------- Forward declarations ---------------------------*/
174 185
175static void bond_send_gratuitous_arp(struct bonding *bond); 186static void bond_send_gratuitous_arp(struct bonding *bond);
@@ -638,6 +649,7 @@ verify:
638 case SPEED_10: 649 case SPEED_10:
639 case SPEED_100: 650 case SPEED_100:
640 case SPEED_1000: 651 case SPEED_1000:
652 case SPEED_10000:
641 break; 653 break;
642 default: 654 default:
643 return -1; 655 return -1;
@@ -1210,10 +1222,14 @@ static int bond_compute_features(struct bonding *bond)
1210 unsigned long features = BOND_INTERSECT_FEATURES; 1222 unsigned long features = BOND_INTERSECT_FEATURES;
1211 struct slave *slave; 1223 struct slave *slave;
1212 struct net_device *bond_dev = bond->dev; 1224 struct net_device *bond_dev = bond->dev;
1225 unsigned short max_hard_header_len = ETH_HLEN;
1213 int i; 1226 int i;
1214 1227
1215 bond_for_each_slave(bond, slave, i) 1228 bond_for_each_slave(bond, slave, i) {
1216 features &= (slave->dev->features & BOND_INTERSECT_FEATURES); 1229 features &= (slave->dev->features & BOND_INTERSECT_FEATURES);
1230 if (slave->dev->hard_header_len > max_hard_header_len)
1231 max_hard_header_len = slave->dev->hard_header_len;
1232 }
1217 1233
1218 if ((features & NETIF_F_SG) && 1234 if ((features & NETIF_F_SG) &&
1219 !(features & NETIF_F_ALL_CSUM)) 1235 !(features & NETIF_F_ALL_CSUM))
@@ -1231,6 +1247,7 @@ static int bond_compute_features(struct bonding *bond)
1231 1247
1232 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES); 1248 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES);
1233 bond_dev->features = features; 1249 bond_dev->features = features;
1250 bond_dev->hard_header_len = max_hard_header_len;
1234 1251
1235 return 0; 1252 return 0;
1236} 1253}
@@ -1365,6 +1382,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1365 } 1382 }
1366 1383
1367 new_slave->dev = slave_dev; 1384 new_slave->dev = slave_dev;
1385 slave_dev->priv_flags |= IFF_BONDING;
1368 1386
1369 if ((bond->params.mode == BOND_MODE_TLB) || 1387 if ((bond->params.mode == BOND_MODE_TLB) ||
1370 (bond->params.mode == BOND_MODE_ALB)) { 1388 (bond->params.mode == BOND_MODE_ALB)) {
@@ -1417,6 +1435,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1417 1435
1418 bond_compute_features(bond); 1436 bond_compute_features(bond);
1419 1437
1438 new_slave->last_arp_rx = jiffies;
1439
1420 if (bond->params.miimon && !bond->params.use_carrier) { 1440 if (bond->params.miimon && !bond->params.use_carrier) {
1421 link_reporting = bond_check_dev_link(bond, slave_dev, 1); 1441 link_reporting = bond_check_dev_link(bond, slave_dev, 1);
1422 1442
@@ -1493,29 +1513,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1493 1513
1494 switch (bond->params.mode) { 1514 switch (bond->params.mode) {
1495 case BOND_MODE_ACTIVEBACKUP: 1515 case BOND_MODE_ACTIVEBACKUP:
1496 /* if we're in active-backup mode, we need one and 1516 bond_set_slave_inactive_flags(new_slave);
1497 * only one active interface. The backup interfaces 1517 bond_select_active_slave(bond);
1498 * will have their SLAVE_INACTIVE flag set because we
1499 * need them to be drop all packets. Thus, since we
1500 * guarantee that curr_active_slave always point to
1501 * the last usable interface, we just have to verify
1502 * this interface's flag.
1503 */
1504 if (((!bond->curr_active_slave) ||
1505 (bond->curr_active_slave->dev->priv_flags & IFF_SLAVE_INACTIVE)) &&
1506 (new_slave->link != BOND_LINK_DOWN)) {
1507 /* first slave or no active slave yet, and this link
1508 is OK, so make this interface the active one */
1509 bond_change_active_slave(bond, new_slave);
1510 printk(KERN_INFO DRV_NAME
1511 ": %s: first active interface up!\n",
1512 bond->dev->name);
1513 netif_carrier_on(bond->dev);
1514
1515 } else {
1516 dprintk("This is just a backup slave\n");
1517 bond_set_slave_inactive_flags(new_slave);
1518 }
1519 break; 1518 break;
1520 case BOND_MODE_8023AD: 1519 case BOND_MODE_8023AD:
1521 /* in 802.3ad mode, the internal mechanism 1520 /* in 802.3ad mode, the internal mechanism
@@ -1778,7 +1777,8 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1778 dev_set_mac_address(slave_dev, &addr); 1777 dev_set_mac_address(slave_dev, &addr);
1779 1778
1780 slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB | 1779 slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB |
1781 IFF_SLAVE_INACTIVE); 1780 IFF_SLAVE_INACTIVE | IFF_BONDING |
1781 IFF_SLAVE_NEEDARP);
1782 1782
1783 kfree(slave); 1783 kfree(slave);
1784 1784
@@ -2291,6 +2291,25 @@ static int bond_has_ip(struct bonding *bond)
2291 return 0; 2291 return 0;
2292} 2292}
2293 2293
2294static int bond_has_this_ip(struct bonding *bond, u32 ip)
2295{
2296 struct vlan_entry *vlan, *vlan_next;
2297
2298 if (ip == bond->master_ip)
2299 return 1;
2300
2301 if (list_empty(&bond->vlan_list))
2302 return 0;
2303
2304 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2305 vlan_list) {
2306 if (ip == vlan->vlan_ip)
2307 return 1;
2308 }
2309
2310 return 0;
2311}
2312
2294/* 2313/*
2295 * We go to the (large) trouble of VLAN tagging ARP frames because 2314 * We go to the (large) trouble of VLAN tagging ARP frames because
2296 * switches in VLAN mode (especially if ports are configured as 2315 * switches in VLAN mode (especially if ports are configured as
@@ -2429,6 +2448,93 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
2429 } 2448 }
2430} 2449}
2431 2450
2451static void bond_validate_arp(struct bonding *bond, struct slave *slave, u32 sip, u32 tip)
2452{
2453 int i;
2454 u32 *targets = bond->params.arp_targets;
2455
2456 targets = bond->params.arp_targets;
2457 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) {
2458 dprintk("bva: sip %u.%u.%u.%u tip %u.%u.%u.%u t[%d] "
2459 "%u.%u.%u.%u bhti(tip) %d\n",
2460 NIPQUAD(sip), NIPQUAD(tip), i, NIPQUAD(targets[i]),
2461 bond_has_this_ip(bond, tip));
2462 if (sip == targets[i]) {
2463 if (bond_has_this_ip(bond, tip))
2464 slave->last_arp_rx = jiffies;
2465 return;
2466 }
2467 }
2468}
2469
2470static int bond_arp_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
2471{
2472 struct arphdr *arp;
2473 struct slave *slave;
2474 struct bonding *bond;
2475 unsigned char *arp_ptr;
2476 u32 sip, tip;
2477
2478 if (!(dev->priv_flags & IFF_BONDING) || !(dev->flags & IFF_MASTER))
2479 goto out;
2480
2481 bond = dev->priv;
2482 read_lock(&bond->lock);
2483
2484 dprintk("bond_arp_rcv: bond %s skb->dev %s orig_dev %s\n",
2485 bond->dev->name, skb->dev ? skb->dev->name : "NULL",
2486 orig_dev ? orig_dev->name : "NULL");
2487
2488 slave = bond_get_slave_by_dev(bond, orig_dev);
2489 if (!slave || !slave_do_arp_validate(bond, slave))
2490 goto out_unlock;
2491
2492 /* ARP header, plus 2 device addresses, plus 2 IP addresses. */
2493 if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
2494 (2 * dev->addr_len) +
2495 (2 * sizeof(u32)))))
2496 goto out_unlock;
2497
2498 arp = skb->nh.arph;
2499 if (arp->ar_hln != dev->addr_len ||
2500 skb->pkt_type == PACKET_OTHERHOST ||
2501 skb->pkt_type == PACKET_LOOPBACK ||
2502 arp->ar_hrd != htons(ARPHRD_ETHER) ||
2503 arp->ar_pro != htons(ETH_P_IP) ||
2504 arp->ar_pln != 4)
2505 goto out_unlock;
2506
2507 arp_ptr = (unsigned char *)(arp + 1);
2508 arp_ptr += dev->addr_len;
2509 memcpy(&sip, arp_ptr, 4);
2510 arp_ptr += 4 + dev->addr_len;
2511 memcpy(&tip, arp_ptr, 4);
2512
2513 dprintk("bond_arp_rcv: %s %s/%d av %d sv %d sip %u.%u.%u.%u"
2514 " tip %u.%u.%u.%u\n", bond->dev->name, slave->dev->name,
2515 slave->state, bond->params.arp_validate,
2516 slave_do_arp_validate(bond, slave), NIPQUAD(sip), NIPQUAD(tip));
2517
2518 /*
2519 * Backup slaves won't see the ARP reply, but do come through
2520 * here for each ARP probe (so we swap the sip/tip to validate
2521 * the probe). In a "redundant switch, common router" type of
2522 * configuration, the ARP probe will (hopefully) travel from
2523 * the active, through one switch, the router, then the other
2524 * switch before reaching the backup.
2525 */
2526 if (slave->state == BOND_STATE_ACTIVE)
2527 bond_validate_arp(bond, slave, sip, tip);
2528 else
2529 bond_validate_arp(bond, slave, tip, sip);
2530
2531out_unlock:
2532 read_unlock(&bond->lock);
2533out:
2534 dev_kfree_skb(skb);
2535 return NET_RX_SUCCESS;
2536}
2537
2432/* 2538/*
2433 * this function is called regularly to monitor each slave's link 2539 * this function is called regularly to monitor each slave's link
2434 * ensuring that traffic is being sent and received when arp monitoring 2540 * ensuring that traffic is being sent and received when arp monitoring
@@ -2593,7 +2699,8 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2593 */ 2699 */
2594 bond_for_each_slave(bond, slave, i) { 2700 bond_for_each_slave(bond, slave, i) {
2595 if (slave->link != BOND_LINK_UP) { 2701 if (slave->link != BOND_LINK_UP) {
2596 if ((jiffies - slave->dev->last_rx) <= delta_in_ticks) { 2702 if ((jiffies - slave_last_rx(bond, slave)) <=
2703 delta_in_ticks) {
2597 2704
2598 slave->link = BOND_LINK_UP; 2705 slave->link = BOND_LINK_UP;
2599 2706
@@ -2638,7 +2745,7 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2638 2745
2639 if ((slave != bond->curr_active_slave) && 2746 if ((slave != bond->curr_active_slave) &&
2640 (!bond->current_arp_slave) && 2747 (!bond->current_arp_slave) &&
2641 (((jiffies - slave->dev->last_rx) >= 3*delta_in_ticks) && 2748 (((jiffies - slave_last_rx(bond, slave)) >= 3*delta_in_ticks) &&
2642 bond_has_ip(bond))) { 2749 bond_has_ip(bond))) {
2643 /* a backup slave has gone down; three times 2750 /* a backup slave has gone down; three times
2644 * the delta allows the current slave to be 2751 * the delta allows the current slave to be
@@ -2685,7 +2792,7 @@ void bond_activebackup_arp_mon(struct net_device *bond_dev)
2685 * if it is up and needs to take over as the curr_active_slave 2792 * if it is up and needs to take over as the curr_active_slave
2686 */ 2793 */
2687 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || 2794 if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) ||
2688 (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && 2795 (((jiffies - slave_last_rx(bond, slave)) >= (2*delta_in_ticks)) &&
2689 bond_has_ip(bond))) && 2796 bond_has_ip(bond))) &&
2690 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { 2797 ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) {
2691 2798
@@ -2950,7 +3057,7 @@ static void bond_info_show_slave(struct seq_file *seq, const struct slave *slave
2950 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name); 3057 seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
2951 seq_printf(seq, "MII Status: %s\n", 3058 seq_printf(seq, "MII Status: %s\n",
2952 (slave->link == BOND_LINK_UP) ? "up" : "down"); 3059 (slave->link == BOND_LINK_UP) ? "up" : "down");
2953 seq_printf(seq, "Link Failure Count: %d\n", 3060 seq_printf(seq, "Link Failure Count: %u\n",
2954 slave->link_failure_count); 3061 slave->link_failure_count);
2955 3062
2956 seq_printf(seq, 3063 seq_printf(seq,
@@ -3210,6 +3317,9 @@ static int bond_netdev_event(struct notifier_block *this, unsigned long event, v
3210 (event_dev ? event_dev->name : "None"), 3317 (event_dev ? event_dev->name : "None"),
3211 event); 3318 event);
3212 3319
3320 if (!(event_dev->priv_flags & IFF_BONDING))
3321 return NOTIFY_DONE;
3322
3213 if (event_dev->flags & IFF_MASTER) { 3323 if (event_dev->flags & IFF_MASTER) {
3214 dprintk("IFF_MASTER\n"); 3324 dprintk("IFF_MASTER\n");
3215 return bond_master_netdev_event(event, event_dev); 3325 return bond_master_netdev_event(event, event_dev);
@@ -3305,6 +3415,21 @@ static void bond_unregister_lacpdu(struct bonding *bond)
3305 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type)); 3415 dev_remove_pack(&(BOND_AD_INFO(bond).ad_pkt_type));
3306} 3416}
3307 3417
3418void bond_register_arp(struct bonding *bond)
3419{
3420 struct packet_type *pt = &bond->arp_mon_pt;
3421
3422 pt->type = htons(ETH_P_ARP);
3423 pt->dev = NULL; /*bond->dev;XXX*/
3424 pt->func = bond_arp_rcv;
3425 dev_add_pack(pt);
3426}
3427
3428void bond_unregister_arp(struct bonding *bond)
3429{
3430 dev_remove_pack(&bond->arp_mon_pt);
3431}
3432
3308/*---------------------------- Hashing Policies -----------------------------*/ 3433/*---------------------------- Hashing Policies -----------------------------*/
3309 3434
3310/* 3435/*
@@ -3391,6 +3516,9 @@ static int bond_open(struct net_device *bond_dev)
3391 } else { 3516 } else {
3392 arp_timer->function = (void *)&bond_loadbalance_arp_mon; 3517 arp_timer->function = (void *)&bond_loadbalance_arp_mon;
3393 } 3518 }
3519 if (bond->params.arp_validate)
3520 bond_register_arp(bond);
3521
3394 add_timer(arp_timer); 3522 add_timer(arp_timer);
3395 } 3523 }
3396 3524
@@ -3418,9 +3546,11 @@ static int bond_close(struct net_device *bond_dev)
3418 bond_unregister_lacpdu(bond); 3546 bond_unregister_lacpdu(bond);
3419 } 3547 }
3420 3548
3549 if (bond->params.arp_validate)
3550 bond_unregister_arp(bond);
3551
3421 write_lock_bh(&bond->lock); 3552 write_lock_bh(&bond->lock);
3422 3553
3423 bond_mc_list_destroy(bond);
3424 3554
3425 /* signal timers not to re-arm */ 3555 /* signal timers not to re-arm */
3426 bond->kill_timers = 1; 3556 bond->kill_timers = 1;
@@ -3451,8 +3581,6 @@ static int bond_close(struct net_device *bond_dev)
3451 break; 3581 break;
3452 } 3582 }
3453 3583
3454 /* Release the bonded slaves */
3455 bond_release_all(bond_dev);
3456 3584
3457 if ((bond->params.mode == BOND_MODE_TLB) || 3585 if ((bond->params.mode == BOND_MODE_TLB) ||
3458 (bond->params.mode == BOND_MODE_ALB)) { 3586 (bond->params.mode == BOND_MODE_ALB)) {
@@ -4179,6 +4307,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4179 /* Initialize the device options */ 4307 /* Initialize the device options */
4180 bond_dev->tx_queue_len = 0; 4308 bond_dev->tx_queue_len = 0;
4181 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; 4309 bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
4310 bond_dev->priv_flags |= IFF_BONDING;
4182 4311
4183 /* At first, we block adding VLANs. That's the only way to 4312 /* At first, we block adding VLANs. That's the only way to
4184 * prevent problems that occur when adding VLANs over an 4313 * prevent problems that occur when adding VLANs over an
@@ -4237,6 +4366,9 @@ static void bond_free_all(void)
4237 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { 4366 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) {
4238 struct net_device *bond_dev = bond->dev; 4367 struct net_device *bond_dev = bond->dev;
4239 4368
4369 bond_mc_list_destroy(bond);
4370 /* Release the bonded slaves */
4371 bond_release_all(bond_dev);
4240 unregister_netdevice(bond_dev); 4372 unregister_netdevice(bond_dev);
4241 bond_deinit(bond_dev); 4373 bond_deinit(bond_dev);
4242 } 4374 }
@@ -4270,6 +4402,8 @@ int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl)
4270 4402
4271static int bond_check_params(struct bond_params *params) 4403static int bond_check_params(struct bond_params *params)
4272{ 4404{
4405 int arp_validate_value;
4406
4273 /* 4407 /*
4274 * Convert string parameters. 4408 * Convert string parameters.
4275 */ 4409 */
@@ -4473,6 +4607,29 @@ static int bond_check_params(struct bond_params *params)
4473 arp_interval = 0; 4607 arp_interval = 0;
4474 } 4608 }
4475 4609
4610 if (arp_validate) {
4611 if (bond_mode != BOND_MODE_ACTIVEBACKUP) {
4612 printk(KERN_ERR DRV_NAME
4613 ": arp_validate only supported in active-backup mode\n");
4614 return -EINVAL;
4615 }
4616 if (!arp_interval) {
4617 printk(KERN_ERR DRV_NAME
4618 ": arp_validate requires arp_interval\n");
4619 return -EINVAL;
4620 }
4621
4622 arp_validate_value = bond_parse_parm(arp_validate,
4623 arp_validate_tbl);
4624 if (arp_validate_value == -1) {
4625 printk(KERN_ERR DRV_NAME
4626 ": Error: invalid arp_validate \"%s\"\n",
4627 arp_validate == NULL ? "NULL" : arp_validate);
4628 return -EINVAL;
4629 }
4630 } else
4631 arp_validate_value = 0;
4632
4476 if (miimon) { 4633 if (miimon) {
4477 printk(KERN_INFO DRV_NAME 4634 printk(KERN_INFO DRV_NAME
4478 ": MII link monitoring set to %d ms\n", 4635 ": MII link monitoring set to %d ms\n",
@@ -4481,8 +4638,10 @@ static int bond_check_params(struct bond_params *params)
4481 int i; 4638 int i;
4482 4639
4483 printk(KERN_INFO DRV_NAME 4640 printk(KERN_INFO DRV_NAME
4484 ": ARP monitoring set to %d ms with %d target(s):", 4641 ": ARP monitoring set to %d ms, validate %s, with %d target(s):",
4485 arp_interval, arp_ip_count); 4642 arp_interval,
4643 arp_validate_tbl[arp_validate_value].modename,
4644 arp_ip_count);
4486 4645
4487 for (i = 0; i < arp_ip_count; i++) 4646 for (i = 0; i < arp_ip_count; i++)
4488 printk (" %s", arp_ip_target[i]); 4647 printk (" %s", arp_ip_target[i]);
@@ -4516,6 +4675,7 @@ static int bond_check_params(struct bond_params *params)
4516 params->xmit_policy = xmit_hashtype; 4675 params->xmit_policy = xmit_hashtype;
4517 params->miimon = miimon; 4676 params->miimon = miimon;
4518 params->arp_interval = arp_interval; 4677 params->arp_interval = arp_interval;
4678 params->arp_validate = arp_validate_value;
4519 params->updelay = updelay; 4679 params->updelay = updelay;
4520 params->downdelay = downdelay; 4680 params->downdelay = downdelay;
4521 params->use_carrier = use_carrier; 4681 params->use_carrier = use_carrier;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index cfe4dc3a93a3..ced9ed8f995a 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -51,6 +51,7 @@ extern struct bond_params bonding_defaults;
51extern struct bond_parm_tbl bond_mode_tbl[]; 51extern struct bond_parm_tbl bond_mode_tbl[];
52extern struct bond_parm_tbl bond_lacp_tbl[]; 52extern struct bond_parm_tbl bond_lacp_tbl[];
53extern struct bond_parm_tbl xmit_hashtype_tbl[]; 53extern struct bond_parm_tbl xmit_hashtype_tbl[];
54extern struct bond_parm_tbl arp_validate_tbl[];
54 55
55static int expected_refcount = -1; 56static int expected_refcount = -1;
56static struct class *netdev_class; 57static struct class *netdev_class;
@@ -503,6 +504,53 @@ out:
503static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash); 504static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash);
504 505
505/* 506/*
507 * Show and set arp_validate.
508 */
509static ssize_t bonding_show_arp_validate(struct class_device *cd, char *buf)
510{
511 struct bonding *bond = to_bond(cd);
512
513 return sprintf(buf, "%s %d\n",
514 arp_validate_tbl[bond->params.arp_validate].modename,
515 bond->params.arp_validate) + 1;
516}
517
518static ssize_t bonding_store_arp_validate(struct class_device *cd, const char *buf, size_t count)
519{
520 int new_value;
521 struct bonding *bond = to_bond(cd);
522
523 new_value = bond_parse_parm((char *)buf, arp_validate_tbl);
524 if (new_value < 0) {
525 printk(KERN_ERR DRV_NAME
526 ": %s: Ignoring invalid arp_validate value %s\n",
527 bond->dev->name, buf);
528 return -EINVAL;
529 }
530 if (new_value && (bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
531 printk(KERN_ERR DRV_NAME
532 ": %s: arp_validate only supported in active-backup mode.\n",
533 bond->dev->name);
534 return -EINVAL;
535 }
536 printk(KERN_INFO DRV_NAME ": %s: setting arp_validate to %s (%d).\n",
537 bond->dev->name, arp_validate_tbl[new_value].modename,
538 new_value);
539
540 if (!bond->params.arp_validate && new_value) {
541 bond_register_arp(bond);
542 } else if (bond->params.arp_validate && !new_value) {
543 bond_unregister_arp(bond);
544 }
545
546 bond->params.arp_validate = new_value;
547
548 return count;
549}
550
551static CLASS_DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, bonding_store_arp_validate);
552
553/*
506 * Show and set the arp timer interval. There are two tricky bits 554 * Show and set the arp timer interval. There are two tricky bits
507 * here. First, if ARP monitoring is activated, then we must disable 555 * here. First, if ARP monitoring is activated, then we must disable
508 * MII monitoring. Second, if the ARP timer isn't running, we must 556 * MII monitoring. Second, if the ARP timer isn't running, we must
@@ -914,6 +962,11 @@ static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, si
914 "ARP monitoring. Disabling ARP monitoring...\n", 962 "ARP monitoring. Disabling ARP monitoring...\n",
915 bond->dev->name); 963 bond->dev->name);
916 bond->params.arp_interval = 0; 964 bond->params.arp_interval = 0;
965 if (bond->params.arp_validate) {
966 bond_unregister_arp(bond);
967 bond->params.arp_validate =
968 BOND_ARP_VALIDATE_NONE;
969 }
917 /* Kill ARP timer, else it brings bond's link down */ 970 /* Kill ARP timer, else it brings bond's link down */
918 if (bond->mii_timer.function) { 971 if (bond->mii_timer.function) {
919 printk(KERN_INFO DRV_NAME 972 printk(KERN_INFO DRV_NAME
@@ -1093,7 +1146,7 @@ static ssize_t bonding_store_active_slave(struct class_device *cd, const char *b
1093 strlen(slave->dev->name)) == 0) { 1146 strlen(slave->dev->name)) == 0) {
1094 old_active = bond->curr_active_slave; 1147 old_active = bond->curr_active_slave;
1095 new_active = slave; 1148 new_active = slave;
1096 if (new_active && (new_active == old_active)) { 1149 if (new_active == old_active) {
1097 /* do nothing */ 1150 /* do nothing */
1098 printk(KERN_INFO DRV_NAME 1151 printk(KERN_INFO DRV_NAME
1099 ": %s: %s is already the current active slave.\n", 1152 ": %s: %s is already the current active slave.\n",
@@ -1273,6 +1326,7 @@ static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, N
1273static struct attribute *per_bond_attrs[] = { 1326static struct attribute *per_bond_attrs[] = {
1274 &class_device_attr_slaves.attr, 1327 &class_device_attr_slaves.attr,
1275 &class_device_attr_mode.attr, 1328 &class_device_attr_mode.attr,
1329 &class_device_attr_arp_validate.attr,
1276 &class_device_attr_arp_interval.attr, 1330 &class_device_attr_arp_interval.attr,
1277 &class_device_attr_arp_ip_target.attr, 1331 &class_device_attr_arp_ip_target.attr,
1278 &class_device_attr_downdelay.attr, 1332 &class_device_attr_downdelay.attr,
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 0bdfe2c71453..dc434fb6da85 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -22,8 +22,8 @@
22#include "bond_3ad.h" 22#include "bond_3ad.h"
23#include "bond_alb.h" 23#include "bond_alb.h"
24 24
25#define DRV_VERSION "3.0.3" 25#define DRV_VERSION "3.1.1"
26#define DRV_RELDATE "March 23, 2006" 26#define DRV_RELDATE "September 26, 2006"
27#define DRV_NAME "bonding" 27#define DRV_NAME "bonding"
28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
29 29
@@ -126,6 +126,7 @@ struct bond_params {
126 int xmit_policy; 126 int xmit_policy;
127 int miimon; 127 int miimon;
128 int arp_interval; 128 int arp_interval;
129 int arp_validate;
129 int use_carrier; 130 int use_carrier;
130 int updelay; 131 int updelay;
131 int downdelay; 132 int downdelay;
@@ -149,8 +150,9 @@ struct slave {
149 struct net_device *dev; /* first - useful for panic debug */ 150 struct net_device *dev; /* first - useful for panic debug */
150 struct slave *next; 151 struct slave *next;
151 struct slave *prev; 152 struct slave *prev;
152 s16 delay; 153 int delay;
153 u32 jiffies; 154 u32 jiffies;
155 u32 last_arp_rx;
154 s8 link; /* one of BOND_LINK_XXXX */ 156 s8 link; /* one of BOND_LINK_XXXX */
155 s8 state; /* one of BOND_STATE_XXXX */ 157 s8 state; /* one of BOND_STATE_XXXX */
156 u32 original_flags; 158 u32 original_flags;
@@ -198,6 +200,7 @@ struct bonding {
198 struct bond_params params; 200 struct bond_params params;
199 struct list_head vlan_list; 201 struct list_head vlan_list;
200 struct vlan_group *vlgrp; 202 struct vlan_group *vlgrp;
203 struct packet_type arp_mon_pt;
201}; 204};
202 205
203/** 206/**
@@ -228,6 +231,25 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
228 return (struct bonding *)slave->dev->master->priv; 231 return (struct bonding *)slave->dev->master->priv;
229} 232}
230 233
234#define BOND_ARP_VALIDATE_NONE 0
235#define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE)
236#define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP)
237#define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \
238 BOND_ARP_VALIDATE_BACKUP)
239
240extern inline int slave_do_arp_validate(struct bonding *bond, struct slave *slave)
241{
242 return bond->params.arp_validate & (1 << slave->state);
243}
244
245extern inline u32 slave_last_rx(struct bonding *bond, struct slave *slave)
246{
247 if (slave_do_arp_validate(bond, slave))
248 return slave->last_arp_rx;
249
250 return slave->dev->last_rx;
251}
252
231static inline void bond_set_slave_inactive_flags(struct slave *slave) 253static inline void bond_set_slave_inactive_flags(struct slave *slave)
232{ 254{
233 struct bonding *bond = slave->dev->master->priv; 255 struct bonding *bond = slave->dev->master->priv;
@@ -235,12 +257,14 @@ static inline void bond_set_slave_inactive_flags(struct slave *slave)
235 bond->params.mode != BOND_MODE_ALB) 257 bond->params.mode != BOND_MODE_ALB)
236 slave->state = BOND_STATE_BACKUP; 258 slave->state = BOND_STATE_BACKUP;
237 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE; 259 slave->dev->priv_flags |= IFF_SLAVE_INACTIVE;
260 if (slave_do_arp_validate(bond, slave))
261 slave->dev->priv_flags |= IFF_SLAVE_NEEDARP;
238} 262}
239 263
240static inline void bond_set_slave_active_flags(struct slave *slave) 264static inline void bond_set_slave_active_flags(struct slave *slave)
241{ 265{
242 slave->state = BOND_STATE_ACTIVE; 266 slave->state = BOND_STATE_ACTIVE;
243 slave->dev->priv_flags &= ~IFF_SLAVE_INACTIVE; 267 slave->dev->priv_flags &= ~(IFF_SLAVE_INACTIVE | IFF_SLAVE_NEEDARP);
244} 268}
245 269
246static inline void bond_set_master_3ad_flags(struct bonding *bond) 270static inline void bond_set_master_3ad_flags(struct bonding *bond)
@@ -284,6 +308,8 @@ int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl);
284const char *bond_mode_name(int mode); 308const char *bond_mode_name(int mode);
285void bond_select_active_slave(struct bonding *bond); 309void bond_select_active_slave(struct bonding *bond);
286void bond_change_active_slave(struct bonding *bond, struct slave *new_active); 310void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
311void bond_register_arp(struct bonding *);
312void bond_unregister_arp(struct bonding *);
287 313
288#endif /* _LINUX_BONDING_H */ 314#endif /* _LINUX_BONDING_H */
289 315
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index a170e96251f6..4020acb55005 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -1367,8 +1367,8 @@ struct e1000_hw_stats {
1367 1367
1368/* Structure containing variables used by the shared code (e1000_hw.c) */ 1368/* Structure containing variables used by the shared code (e1000_hw.c) */
1369struct e1000_hw { 1369struct e1000_hw {
1370 uint8_t *hw_addr; 1370 uint8_t __iomem *hw_addr;
1371 uint8_t *flash_address; 1371 uint8_t __iomem *flash_address;
1372 e1000_mac_type mac_type; 1372 e1000_mac_type mac_type;
1373 e1000_phy_type phy_type; 1373 e1000_phy_type phy_type;
1374 uint32_t phy_init_script; 1374 uint32_t phy_init_script;
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 97db910fbc8c..eea1d66c530e 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -3789,6 +3789,12 @@ static int nv_loopback_test(struct net_device *dev)
3789 /* setup packet for tx */ 3789 /* setup packet for tx */
3790 pkt_len = ETH_DATA_LEN; 3790 pkt_len = ETH_DATA_LEN;
3791 tx_skb = dev_alloc_skb(pkt_len); 3791 tx_skb = dev_alloc_skb(pkt_len);
3792 if (!tx_skb) {
3793 printk(KERN_ERR "dev_alloc_skb() failed during loopback test"
3794 " of %s\n", dev->name);
3795 ret = 0;
3796 goto out;
3797 }
3792 pkt_data = skb_put(tx_skb, pkt_len); 3798 pkt_data = skb_put(tx_skb, pkt_len);
3793 for (i = 0; i < pkt_len; i++) 3799 for (i = 0; i < pkt_len; i++)
3794 pkt_data[i] = (u8)(i & 0xff); 3800 pkt_data[i] = (u8)(i & 0xff);
@@ -3853,7 +3859,7 @@ static int nv_loopback_test(struct net_device *dev)
3853 tx_skb->end-tx_skb->data, 3859 tx_skb->end-tx_skb->data,
3854 PCI_DMA_TODEVICE); 3860 PCI_DMA_TODEVICE);
3855 dev_kfree_skb_any(tx_skb); 3861 dev_kfree_skb_any(tx_skb);
3856 3862 out:
3857 /* stop engines */ 3863 /* stop engines */
3858 nv_stop_rx(dev); 3864 nv_stop_rx(dev);
3859 nv_stop_tx(dev); 3865 nv_stop_tx(dev);
diff --git a/drivers/net/gt64240eth.h b/drivers/net/gt64240eth.h
deleted file mode 100644
index 0d6f486e4579..000000000000
--- a/drivers/net/gt64240eth.h
+++ /dev/null
@@ -1,402 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2001 Patton Electronics Company
7 * Copyright (C) 2002 Momentum Computer
8 *
9 * Copyright 2000 MontaVista Software Inc.
10 * Author: MontaVista Software, Inc.
11 * stevel@mvista.com or support@mvista.com
12 *
13 * This program is free software; you can distribute it and/or modify it
14 * under the terms of the GNU General Public License (Version 2) as
15 * published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * for more details.
21 *
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 *
26 * Ethernet driver definitions for the MIPS GT96100 Advanced
27 * Communication Controller.
28 *
29 * Modified for the Marvellous GT64240 Retarded Communication Controller.
30 */
31#ifndef _GT64240ETH_H
32#define _GT64240ETH_H
33
34#include <asm/gt64240.h>
35
36#define ETHERNET_PORTS_DIFFERENCE_OFFSETS 0x400
37
38/* Translate those weanie names from Galileo/VxWorks header files: */
39
40#define GT64240_MRR MAIN_ROUTING_REGISTER
41#define GT64240_CIU_ARBITER_CONFIG COMM_UNIT_ARBITER_CONFIGURATION_REGISTER
42#define GT64240_CIU_ARBITER_CONTROL COMM_UNIT_ARBITER_CONTROL
43#define GT64240_MAIN_LOW_CAUSE LOW_INTERRUPT_CAUSE_REGISTER
44#define GT64240_MAIN_HIGH_CAUSE HIGH_INTERRUPT_CAUSE_REGISTER
45#define GT64240_CPU_LOW_MASK CPU_INTERRUPT_MASK_REGISTER_LOW
46#define GT64240_CPU_HIGH_MASK CPU_INTERRUPT_MASK_REGISTER_HIGH
47#define GT64240_CPU_SELECT_CAUSE CPU_SELECT_CAUSE_REGISTER
48
49#define GT64240_ETH_PHY_ADDR_REG ETHERNET_PHY_ADDRESS_REGISTER
50#define GT64240_ETH_PORT_CONFIG ETHERNET0_PORT_CONFIGURATION_REGISTER
51#define GT64240_ETH_PORT_CONFIG_EXT ETHERNET0_PORT_CONFIGURATION_EXTEND_REGISTER
52#define GT64240_ETH_PORT_COMMAND ETHERNET0_PORT_COMMAND_REGISTER
53#define GT64240_ETH_PORT_STATUS ETHERNET0_PORT_STATUS_REGISTER
54#define GT64240_ETH_IO_SIZE ETHERNET_PORTS_DIFFERENCE_OFFSETS
55#define GT64240_ETH_SMI_REG ETHERNET_SMI_REGISTER
56#define GT64240_ETH_MIB_COUNT_BASE ETHERNET0_MIB_COUNTER_BASE
57#define GT64240_ETH_SDMA_CONFIG ETHERNET0_SDMA_CONFIGURATION_REGISTER
58#define GT64240_ETH_SDMA_COMM ETHERNET0_SDMA_COMMAND_REGISTER
59#define GT64240_ETH_INT_MASK ETHERNET0_INTERRUPT_MASK_REGISTER
60#define GT64240_ETH_INT_CAUSE ETHERNET0_INTERRUPT_CAUSE_REGISTER
61#define GT64240_ETH_CURR_TX_DESC_PTR0 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER0
62#define GT64240_ETH_CURR_TX_DESC_PTR1 ETHERNET0_CURRENT_TX_DESCRIPTOR_POINTER1
63#define GT64240_ETH_1ST_RX_DESC_PTR0 ETHERNET0_FIRST_RX_DESCRIPTOR_POINTER0
64#define GT64240_ETH_CURR_RX_DESC_PTR0 ETHERNET0_CURRENT_RX_DESCRIPTOR_POINTER0
65#define GT64240_ETH_HASH_TBL_PTR ETHERNET0_HASH_TABLE_POINTER_REGISTER
66
67/* Turn on NAPI by default */
68
69#define GT64240_NAPI 1
70
71/* Some 64240 settings that SHOULD eventually be setup in PROM monitor: */
72/* (Board-specific to the DSL3224 Rev A board ONLY!) */
73#define D3224_MPP_CTRL0_SETTING 0x66669900
74#define D3224_MPP_CTRL1_SETTING 0x00000000
75#define D3224_MPP_CTRL2_SETTING 0x00887700
76#define D3224_MPP_CTRL3_SETTING 0x00000044
77#define D3224_GPP_IO_CTRL_SETTING 0x0000e800
78#define D3224_GPP_LEVEL_CTRL_SETTING 0xf001f703
79#define D3224_GPP_VALUE_SETTING 0x00000000
80
81/* Keep the ring sizes a power of two for efficiency. */
82//-#define TX_RING_SIZE 16
83#define TX_RING_SIZE 64 /* TESTING !!! */
84#define RX_RING_SIZE 32
85#define PKT_BUF_SZ 1536 /* Size of each temporary Rx buffer. */
86
87#define RX_HASH_TABLE_SIZE 16384
88#define HASH_HOP_NUMBER 12
89
90#define NUM_INTERFACES 3
91
92#define GT64240ETH_TX_TIMEOUT HZ/4
93
94#define MIPS_GT64240_BASE 0xf4000000
95#define GT64240_ETH0_BASE (MIPS_GT64240_BASE + GT64240_ETH_PORT_CONFIG)
96#define GT64240_ETH1_BASE (GT64240_ETH0_BASE + GT64240_ETH_IO_SIZE)
97#define GT64240_ETH2_BASE (GT64240_ETH1_BASE + GT64240_ETH_IO_SIZE)
98
99#if defined(CONFIG_MIPS_DSL3224)
100#define GT64240_ETHER0_IRQ 4
101#define GT64240_ETHER1_IRQ 4
102#else
103#define GT64240_ETHER0_IRQ -1
104#define GT64240_ETHER1_IRQ -1
105#endif
106
107#define REV_GT64240 0x1
108#define REV_GT64240A 0x10
109
110#define GT64240ETH_READ(gp, offset) \
111 GT_READ((gp)->port_offset + (offset))
112
113#define GT64240ETH_WRITE(gp, offset, data) \
114 GT_WRITE((gp)->port_offset + (offset), (data))
115
116#define GT64240ETH_SETBIT(gp, offset, bits) \
117 GT64240ETH_WRITE((gp), (offset), \
118 GT64240ETH_READ((gp), (offset)) | (bits))
119
120#define GT64240ETH_CLRBIT(gp, offset, bits) \
121 GT64240ETH_WRITE((gp), (offset), \
122 GT64240ETH_READ((gp), (offset)) & ~(bits))
123
124#define GT64240_READ(ofs) GT_READ(ofs)
125#define GT64240_WRITE(ofs, data) GT_WRITE((ofs), (data))
126
127/* Bit definitions of the SMI Reg */
128enum {
129 smirDataMask = 0xffff,
130 smirPhyAdMask = 0x1f << 16,
131 smirPhyAdBit = 16,
132 smirRegAdMask = 0x1f << 21,
133 smirRegAdBit = 21,
134 smirOpCode = 1 << 26,
135 smirReadValid = 1 << 27,
136 smirBusy = 1 << 28
137};
138
139/* Bit definitions of the Port Config Reg */
140enum pcr_bits {
141 pcrPM = 1 << 0,
142 pcrRBM = 1 << 1,
143 pcrPBF = 1 << 2,
144 pcrEN = 1 << 7,
145 pcrLPBKMask = 0x3 << 8,
146 pcrLPBKBit = 1 << 8,
147 pcrFC = 1 << 10,
148 pcrHS = 1 << 12,
149 pcrHM = 1 << 13,
150 pcrHDM = 1 << 14,
151 pcrHD = 1 << 15,
152 pcrISLMask = 0x7 << 28,
153 pcrISLBit = 28,
154 pcrACCS = 1 << 31
155};
156
157/* Bit definitions of the Port Config Extend Reg */
158enum pcxr_bits {
159 pcxrIGMP = 1,
160 pcxrSPAN = 2,
161 pcxrPAR = 4,
162 pcxrPRIOtxMask = 0x7 << 3,
163 pcxrPRIOtxBit = 3,
164 pcxrPRIOrxMask = 0x3 << 6,
165 pcxrPRIOrxBit = 6,
166 pcxrPRIOrxOverride = 1 << 8,
167 pcxrDPLXen = 1 << 9,
168 pcxrFCTLen = 1 << 10,
169 pcxrFLP = 1 << 11,
170 pcxrFCTL = 1 << 12,
171 pcxrMFLMask = 0x3 << 14,
172 pcxrMFLBit = 14,
173 pcxrMIBclrMode = 1 << 16,
174 pcxrSpeed = 1 << 18,
175 pcxrSpeeden = 1 << 19,
176 pcxrRMIIen = 1 << 20,
177 pcxrDSCPen = 1 << 21
178};
179
180/* Bit definitions of the Port Command Reg */
181enum pcmr_bits {
182 pcmrFJ = 1 << 15
183};
184
185
186/* Bit definitions of the Port Status Reg */
187enum psr_bits {
188 psrSpeed = 1,
189 psrDuplex = 2,
190 psrFctl = 4,
191 psrLink = 8,
192 psrPause = 1 << 4,
193 psrTxLow = 1 << 5,
194 psrTxHigh = 1 << 6,
195 psrTxInProg = 1 << 7
196};
197
198/* Bit definitions of the SDMA Config Reg */
199enum sdcr_bits {
200 sdcrRCMask = 0xf << 2,
201 sdcrRCBit = 2,
202 sdcrBLMR = 1 << 6,
203 sdcrBLMT = 1 << 7,
204 sdcrPOVR = 1 << 8,
205 sdcrRIFB = 1 << 9,
206 sdcrBSZMask = 0x3 << 12,
207 sdcrBSZBit = 12
208};
209
210/* Bit definitions of the SDMA Command Reg */
211enum sdcmr_bits {
212 sdcmrERD = 1 << 7,
213 sdcmrAR = 1 << 15,
214 sdcmrSTDH = 1 << 16,
215 sdcmrSTDL = 1 << 17,
216 sdcmrTXDH = 1 << 23,
217 sdcmrTXDL = 1 << 24,
218 sdcmrAT = 1 << 31
219};
220
221/* Bit definitions of the Interrupt Cause Reg */
222enum icr_bits {
223 icrRxBuffer = 1,
224 icrTxBufferHigh = 1 << 2,
225 icrTxBufferLow = 1 << 3,
226 icrTxEndHigh = 1 << 6,
227 icrTxEndLow = 1 << 7,
228 icrRxError = 1 << 8,
229 icrTxErrorHigh = 1 << 10,
230 icrTxErrorLow = 1 << 11,
231 icrRxOVR = 1 << 12,
232 icrTxUdr = 1 << 13,
233 icrRxBufferQ0 = 1 << 16,
234 icrRxBufferQ1 = 1 << 17,
235 icrRxBufferQ2 = 1 << 18,
236 icrRxBufferQ3 = 1 << 19,
237 icrRxErrorQ0 = 1 << 20,
238 icrRxErrorQ1 = 1 << 21,
239 icrRxErrorQ2 = 1 << 22,
240 icrRxErrorQ3 = 1 << 23,
241 icrMIIPhySTC = 1 << 28,
242 icrSMIdone = 1 << 29,
243 icrEtherIntSum = 1 << 31
244};
245
246
247/* The Rx and Tx descriptor lists. */
248#ifdef __LITTLE_ENDIAN
249typedef struct {
250 u32 cmdstat;
251 u16 reserved; //-prk21aug01 u32 reserved:16;
252 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
253 u32 buff_ptr;
254 u32 next;
255} gt64240_td_t;
256
257typedef struct {
258 u32 cmdstat;
259 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
260 u16 buff_sz; //-prk21aug01 u32 buff_sz:16;
261 u32 buff_ptr;
262 u32 next;
263} gt64240_rd_t;
264#elif defined(__BIG_ENDIAN)
265typedef struct {
266 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
267 u16 reserved; //-prk21aug01 u32 reserved:16;
268 u32 cmdstat;
269 u32 next;
270 u32 buff_ptr;
271} gt64240_td_t;
272
273typedef struct {
274 u16 buff_sz; //-prk21aug01 u32 buff_sz:16;
275 u16 byte_cnt; //-prk21aug01 u32 byte_cnt:16;
276 u32 cmdstat;
277 u32 next;
278 u32 buff_ptr;
279} gt64240_rd_t;
280#else
281#error Either __BIG_ENDIAN or __LITTLE_ENDIAN must be defined!
282#endif
283
284
285/* Values for the Tx command-status descriptor entry. */
286enum td_cmdstat {
287 txOwn = 1 << 31,
288 txAutoMode = 1 << 30,
289 txEI = 1 << 23,
290 txGenCRC = 1 << 22,
291 txPad = 1 << 18,
292 txFirst = 1 << 17,
293 txLast = 1 << 16,
294 txErrorSummary = 1 << 15,
295 txReTxCntMask = 0x0f << 10,
296 txReTxCntBit = 10,
297 txCollision = 1 << 9,
298 txReTxLimit = 1 << 8,
299 txUnderrun = 1 << 6,
300 txLateCollision = 1 << 5
301};
302
303
304/* Values for the Rx command-status descriptor entry. */
305enum rd_cmdstat {
306 rxOwn = 1 << 31,
307 rxAutoMode = 1 << 30,
308 rxEI = 1 << 23,
309 rxFirst = 1 << 17,
310 rxLast = 1 << 16,
311 rxErrorSummary = 1 << 15,
312 rxIGMP = 1 << 14,
313 rxHashExpired = 1 << 13,
314 rxMissedFrame = 1 << 12,
315 rxFrameType = 1 << 11,
316 rxShortFrame = 1 << 8,
317 rxMaxFrameLen = 1 << 7,
318 rxOverrun = 1 << 6,
319 rxCollision = 1 << 4,
320 rxCRCError = 1
321};
322
323/* Bit fields of a Hash Table Entry */
324enum hash_table_entry {
325 hteValid = 1,
326 hteSkip = 2,
327 hteRD = 4
328};
329
330// The MIB counters
331typedef struct {
332 u32 byteReceived;
333 u32 byteSent;
334 u32 framesReceived;
335 u32 framesSent;
336 u32 totalByteReceived;
337 u32 totalFramesReceived;
338 u32 broadcastFramesReceived;
339 u32 multicastFramesReceived;
340 u32 cRCError;
341 u32 oversizeFrames;
342 u32 fragments;
343 u32 jabber;
344 u32 collision;
345 u32 lateCollision;
346 u32 frames64;
347 u32 frames65_127;
348 u32 frames128_255;
349 u32 frames256_511;
350 u32 frames512_1023;
351 u32 frames1024_MaxSize;
352 u32 macRxError;
353 u32 droppedFrames;
354 u32 outMulticastFrames;
355 u32 outBroadcastFrames;
356 u32 undersizeFrames;
357} mib_counters_t;
358
359
360struct gt64240_private {
361 gt64240_rd_t *rx_ring;
362 gt64240_td_t *tx_ring;
363 // The Rx and Tx rings must be 16-byte aligned
364 dma_addr_t rx_ring_dma;
365 dma_addr_t tx_ring_dma;
366 char *hash_table;
367 // The Hash Table must be 8-byte aligned
368 dma_addr_t hash_table_dma;
369 int hash_mode;
370
371 // The Rx buffers must be 8-byte aligned
372 char *rx_buff;
373 dma_addr_t rx_buff_dma;
374 // Tx buffers (tx_skbuff[i]->data) with less than 8 bytes
375 // of payload must be 8-byte aligned
376 struct sk_buff *tx_skbuff[TX_RING_SIZE];
377 int rx_next_out; /* The next free ring entry to receive */
378 int tx_next_in; /* The next free ring entry to send */
379 int tx_next_out; /* The last ring entry the ISR processed */
380 int tx_count; /* current # of pkts waiting to be sent in Tx ring */
381 int intr_work_done; /* number of Rx and Tx pkts processed in the isr */
382 int tx_full; /* Tx ring is full */
383
384 mib_counters_t mib;
385 struct net_device_stats stats;
386
387 int io_size;
388 int port_num; // 0 or 1
389 u32 port_offset;
390
391 int phy_addr; // PHY address
392 u32 last_psr; // last value of the port status register
393
394 int options; /* User-settable misc. driver options. */
395 int drv_flags;
396 spinlock_t lock; /* Serialise access to device */
397 struct mii_if_info mii_if;
398
399 u32 msg_enable;
400};
401
402#endif /* _GT64240ETH_H */
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index 2a0d538b387f..383cef1f5999 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -671,10 +671,8 @@ static void irda_usb_net_timeout(struct net_device *netdev)
671 * Jean II */ 671 * Jean II */
672 done = 1; 672 done = 1;
673 break; 673 break;
674 case -ECONNABORTED: /* -103 */ 674 case -ECONNRESET:
675 case -ECONNRESET: /* -104 */ 675 case -ENOENT: /* urb unlinked by us */
676 case -ETIMEDOUT: /* -110 */
677 case -ENOENT: /* -2 (urb unlinked by us) */
678 default: /* ??? - Play safe */ 676 default: /* ??? - Play safe */
679 urb->status = 0; 677 urb->status = 0;
680 netif_wake_queue(self->netdev); 678 netif_wake_queue(self->netdev);
@@ -712,10 +710,8 @@ static void irda_usb_net_timeout(struct net_device *netdev)
712 * Jean II */ 710 * Jean II */
713 done = 1; 711 done = 1;
714 break; 712 break;
715 case -ECONNABORTED: /* -103 */ 713 case -ECONNRESET:
716 case -ECONNRESET: /* -104 */ 714 case -ENOENT: /* urb unlinked by us */
717 case -ETIMEDOUT: /* -110 */
718 case -ENOENT: /* -2 (urb unlinked by us) */
719 default: /* ??? - Play safe */ 715 default: /* ??? - Play safe */
720 if(skb != NULL) { 716 if(skb != NULL) {
721 dev_kfree_skb_any(skb); 717 dev_kfree_skb_any(skb);
@@ -845,14 +841,14 @@ static void irda_usb_receive(struct urb *urb, struct pt_regs *regs)
845 self->stats.rx_crc_errors++; 841 self->stats.rx_crc_errors++;
846 /* Also precursor to a hot-unplug on UHCI. */ 842 /* Also precursor to a hot-unplug on UHCI. */
847 /* Fallthrough... */ 843 /* Fallthrough... */
848 case -ECONNRESET: /* -104 */ 844 case -ECONNRESET:
849 /* Random error, if I remember correctly */ 845 /* Random error, if I remember correctly */
850 /* uhci_cleanup_unlink() is going to kill the Rx 846 /* uhci_cleanup_unlink() is going to kill the Rx
851 * URB just after we return. No problem, at this 847 * URB just after we return. No problem, at this
852 * point the URB will be idle ;-) - Jean II */ 848 * point the URB will be idle ;-) - Jean II */
853 case -ESHUTDOWN: /* -108 */ 849 case -ESHUTDOWN:
854 /* That's usually a hot-unplug. Submit will fail... */ 850 /* That's usually a hot-unplug. Submit will fail... */
855 case -ETIMEDOUT: /* -110 */ 851 case -ETIME:
856 /* Usually precursor to a hot-unplug on OHCI. */ 852 /* Usually precursor to a hot-unplug on OHCI. */
857 default: 853 default:
858 self->stats.rx_errors++; 854 self->stats.rx_errors++;
diff --git a/drivers/net/irda/vlsi_ir.h b/drivers/net/irda/vlsi_ir.h
index a82a4ba8de4f..c37f0bc4c7f9 100644
--- a/drivers/net/irda/vlsi_ir.h
+++ b/drivers/net/irda/vlsi_ir.h
@@ -58,7 +58,7 @@ typedef void irqreturn_t;
58 58
59/* PDE() introduced in 2.5.4 */ 59/* PDE() introduced in 2.5.4 */
60#ifdef CONFIG_PROC_FS 60#ifdef CONFIG_PROC_FS
61#define PDE(inode) ((inode)->u.generic_ip) 61#define PDE(inode) ((inode)->i_private)
62#endif 62#endif
63 63
64/* irda crc16 calculation exported in 2.5.42 */ 64/* irda crc16 calculation exported in 2.5.42 */
diff --git a/drivers/net/ne3210.c b/drivers/net/ne3210.c
index 0fa8e4d22769..d66328975425 100644
--- a/drivers/net/ne3210.c
+++ b/drivers/net/ne3210.c
@@ -343,6 +343,7 @@ static struct eisa_device_id ne3210_ids[] = {
343 { "NVL1801" }, 343 { "NVL1801" },
344 { "" }, 344 { "" },
345}; 345};
346MODULE_DEVICE_TABLE(eisa, ne3210_ids);
346 347
347static struct eisa_driver ne3210_eisa_driver = { 348static struct eisa_driver ne3210_eisa_driver = {
348 .id_table = ne3210_ids, 349 .id_table = ne3210_ids,
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 2d1ecfdc80db..ecd3da151e2d 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -522,7 +522,7 @@ EXPORT_SYMBOL(genphy_read_status);
522 522
523static int genphy_config_init(struct phy_device *phydev) 523static int genphy_config_init(struct phy_device *phydev)
524{ 524{
525 u32 val; 525 int val;
526 u32 features; 526 u32 features;
527 527
528 /* For now, I'll claim that the generic driver supports 528 /* For now, I'll claim that the generic driver supports
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index f5dbeb27b6f0..1bf23e41f580 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -2904,7 +2904,7 @@ static void s2io_mdio_write(u32 mmd_type, u64 addr, u16 value, struct net_device
2904{ 2904{
2905 u64 val64 = 0x0; 2905 u64 val64 = 0x0;
2906 nic_t *sp = dev->priv; 2906 nic_t *sp = dev->priv;
2907 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0; 2907 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2908 2908
2909 //address transaction 2909 //address transaction
2910 val64 = val64 | MDIO_MMD_INDX_ADDR(addr) 2910 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
@@ -2953,7 +2953,7 @@ static u64 s2io_mdio_read(u32 mmd_type, u64 addr, struct net_device *dev)
2953 u64 val64 = 0x0; 2953 u64 val64 = 0x0;
2954 u64 rval64 = 0x0; 2954 u64 rval64 = 0x0;
2955 nic_t *sp = dev->priv; 2955 nic_t *sp = dev->priv;
2956 XENA_dev_config_t *bar0 = (XENA_dev_config_t *)sp->bar0; 2956 XENA_dev_config_t __iomem *bar0 = sp->bar0;
2957 2957
2958 /* address transaction */ 2958 /* address transaction */
2959 val64 = val64 | MDIO_MMD_INDX_ADDR(addr) 2959 val64 = val64 | MDIO_MMD_INDX_ADDR(addr)
@@ -3276,7 +3276,7 @@ static void alarm_intr_handler(struct s2io_nic *nic)
3276 * SUCCESS on success and FAILURE on failure. 3276 * SUCCESS on success and FAILURE on failure.
3277 */ 3277 */
3278 3278
3279static int wait_for_cmd_complete(void *addr, u64 busy_bit) 3279static int wait_for_cmd_complete(void __iomem *addr, u64 busy_bit)
3280{ 3280{
3281 int ret = FAILURE, cnt = 0; 3281 int ret = FAILURE, cnt = 0;
3282 u64 val64; 3282 u64 val64;
@@ -4303,11 +4303,11 @@ static struct net_device_stats *s2io_get_stats(struct net_device *dev)
4303 sp->stats.tx_errors = 4303 sp->stats.tx_errors =
4304 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms); 4304 le32_to_cpu(mac_control->stats_info->tmac_any_err_frms);
4305 sp->stats.rx_errors = 4305 sp->stats.rx_errors =
4306 le32_to_cpu(mac_control->stats_info->rmac_drop_frms); 4306 le64_to_cpu(mac_control->stats_info->rmac_drop_frms);
4307 sp->stats.multicast = 4307 sp->stats.multicast =
4308 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms); 4308 le32_to_cpu(mac_control->stats_info->rmac_vld_mcst_frms);
4309 sp->stats.rx_length_errors = 4309 sp->stats.rx_length_errors =
4310 le32_to_cpu(mac_control->stats_info->rmac_long_frms); 4310 le64_to_cpu(mac_control->stats_info->rmac_long_frms);
4311 4311
4312 return (&sp->stats); 4312 return (&sp->stats);
4313} 4313}
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 9142d91355bc..705e9a8fa30f 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -58,6 +58,7 @@
58#define TX_WATCHDOG (5 * HZ) 58#define TX_WATCHDOG (5 * HZ)
59#define NAPI_WEIGHT 64 59#define NAPI_WEIGHT 64
60#define BLINK_MS 250 60#define BLINK_MS 250
61#define LINK_HZ (HZ/2)
61 62
62MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver"); 63MODULE_DESCRIPTION("SysKonnect Gigabit Ethernet driver");
63MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>"); 64MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
@@ -605,7 +606,12 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
605 if (hw->chip_id == CHIP_ID_GENESIS) { 606 if (hw->chip_id == CHIP_ID_GENESIS) {
606 switch (mode) { 607 switch (mode) {
607 case LED_MODE_OFF: 608 case LED_MODE_OFF:
608 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF); 609 if (hw->phy_type == SK_PHY_BCOM)
610 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_OFF);
611 else {
612 skge_write32(hw, SK_REG(port, TX_LED_VAL), 0);
613 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_T_OFF);
614 }
609 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF); 615 skge_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
610 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0); 616 skge_write32(hw, SK_REG(port, RX_LED_VAL), 0);
611 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF); 617 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_T_OFF);
@@ -625,8 +631,14 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
625 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100); 631 skge_write32(hw, SK_REG(port, RX_LED_VAL), 100);
626 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START); 632 skge_write8(hw, SK_REG(port, RX_LED_CTRL), LED_START);
627 633
628 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON); 634 if (hw->phy_type == SK_PHY_BCOM)
629 break; 635 xm_phy_write(hw, port, PHY_BCOM_P_EXT_CTRL, PHY_B_PEC_LED_ON);
636 else {
637 skge_write8(hw, SK_REG(port, TX_LED_TST), LED_T_ON);
638 skge_write32(hw, SK_REG(port, TX_LED_VAL), 100);
639 skge_write8(hw, SK_REG(port, TX_LED_CTRL), LED_START);
640 }
641
630 } 642 }
631 } else { 643 } else {
632 switch (mode) { 644 switch (mode) {
@@ -879,6 +891,9 @@ static int __xm_phy_read(struct skge_hw *hw, int port, u16 reg, u16 *val)
879 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr); 891 xm_write16(hw, port, XM_PHY_ADDR, reg | hw->phy_addr);
880 *val = xm_read16(hw, port, XM_PHY_DATA); 892 *val = xm_read16(hw, port, XM_PHY_DATA);
881 893
894 if (hw->phy_type == SK_PHY_XMAC)
895 goto ready;
896
882 for (i = 0; i < PHY_RETRIES; i++) { 897 for (i = 0; i < PHY_RETRIES; i++) {
883 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY) 898 if (xm_read16(hw, port, XM_MMU_CMD) & XM_MMU_PHY_RDY)
884 goto ready; 899 goto ready;
@@ -965,7 +980,8 @@ static void genesis_reset(struct skge_hw *hw, int port)
965 xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */ 980 xm_write16(hw, port, XM_RX_CMD, 0); /* reset RX CMD Reg */
966 981
967 /* disable Broadcom PHY IRQ */ 982 /* disable Broadcom PHY IRQ */
968 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff); 983 if (hw->phy_type == SK_PHY_BCOM)
984 xm_write16(hw, port, PHY_BCOM_INT_MASK, 0xffff);
969 985
970 xm_outhash(hw, port, XM_HSM, zero); 986 xm_outhash(hw, port, XM_HSM, zero);
971} 987}
@@ -1000,60 +1016,64 @@ static void bcom_check_link(struct skge_hw *hw, int port)
1000 1016
1001 if (netif_carrier_ok(dev)) 1017 if (netif_carrier_ok(dev))
1002 skge_link_down(skge); 1018 skge_link_down(skge);
1003 } else { 1019 return;
1004 if (skge->autoneg == AUTONEG_ENABLE && 1020 }
1005 (status & PHY_ST_AN_OVER)) {
1006 u16 lpa = xm_phy_read(hw, port, PHY_BCOM_AUNE_LP);
1007 u16 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1008
1009 if (lpa & PHY_B_AN_RF) {
1010 printk(KERN_NOTICE PFX "%s: remote fault\n",
1011 dev->name);
1012 return;
1013 }
1014 1021
1015 /* Check Duplex mismatch */ 1022 if (skge->autoneg == AUTONEG_ENABLE) {
1016 switch (aux & PHY_B_AS_AN_RES_MSK) { 1023 u16 lpa, aux;
1017 case PHY_B_RES_1000FD:
1018 skge->duplex = DUPLEX_FULL;
1019 break;
1020 case PHY_B_RES_1000HD:
1021 skge->duplex = DUPLEX_HALF;
1022 break;
1023 default:
1024 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1025 dev->name);
1026 return;
1027 }
1028 1024
1025 if (!(status & PHY_ST_AN_OVER))
1026 return;
1029 1027
1030 /* We are using IEEE 802.3z/D5.0 Table 37-4 */ 1028 lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
1031 switch (aux & PHY_B_AS_PAUSE_MSK) { 1029 if (lpa & PHY_B_AN_RF) {
1032 case PHY_B_AS_PAUSE_MSK: 1030 printk(KERN_NOTICE PFX "%s: remote fault\n",
1033 skge->flow_control = FLOW_MODE_SYMMETRIC; 1031 dev->name);
1034 break; 1032 return;
1035 case PHY_B_AS_PRR: 1033 }
1036 skge->flow_control = FLOW_MODE_REM_SEND;
1037 break;
1038 case PHY_B_AS_PRT:
1039 skge->flow_control = FLOW_MODE_LOC_SEND;
1040 break;
1041 default:
1042 skge->flow_control = FLOW_MODE_NONE;
1043 }
1044 1034
1045 skge->speed = SPEED_1000; 1035 aux = xm_phy_read(hw, port, PHY_BCOM_AUX_STAT);
1036
1037 /* Check Duplex mismatch */
1038 switch (aux & PHY_B_AS_AN_RES_MSK) {
1039 case PHY_B_RES_1000FD:
1040 skge->duplex = DUPLEX_FULL;
1041 break;
1042 case PHY_B_RES_1000HD:
1043 skge->duplex = DUPLEX_HALF;
1044 break;
1045 default:
1046 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1047 dev->name);
1048 return;
1046 } 1049 }
1047 1050
1048 if (!netif_carrier_ok(dev)) 1051
1049 genesis_link_up(skge); 1052 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1053 switch (aux & PHY_B_AS_PAUSE_MSK) {
1054 case PHY_B_AS_PAUSE_MSK:
1055 skge->flow_control = FLOW_MODE_SYMMETRIC;
1056 break;
1057 case PHY_B_AS_PRR:
1058 skge->flow_control = FLOW_MODE_REM_SEND;
1059 break;
1060 case PHY_B_AS_PRT:
1061 skge->flow_control = FLOW_MODE_LOC_SEND;
1062 break;
1063 default:
1064 skge->flow_control = FLOW_MODE_NONE;
1065 }
1066 skge->speed = SPEED_1000;
1050 } 1067 }
1068
1069 if (!netif_carrier_ok(dev))
1070 genesis_link_up(skge);
1051} 1071}
1052 1072
1053/* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional 1073/* Broadcom 5400 only supports giagabit! SysKonnect did not put an additional
1054 * Phy on for 100 or 10Mbit operation 1074 * Phy on for 100 or 10Mbit operation
1055 */ 1075 */
1056static void bcom_phy_init(struct skge_port *skge, int jumbo) 1076static void bcom_phy_init(struct skge_port *skge)
1057{ 1077{
1058 struct skge_hw *hw = skge->hw; 1078 struct skge_hw *hw = skge->hw;
1059 int port = skge->port; 1079 int port = skge->port;
@@ -1144,7 +1164,7 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
1144 phy_pause_map[skge->flow_control] | PHY_AN_CSMA); 1164 phy_pause_map[skge->flow_control] | PHY_AN_CSMA);
1145 1165
1146 /* Handle Jumbo frames */ 1166 /* Handle Jumbo frames */
1147 if (jumbo) { 1167 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
1148 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, 1168 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1149 PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK); 1169 PHY_B_AC_TX_TST | PHY_B_AC_LONG_PACK);
1150 1170
@@ -1157,8 +1177,154 @@ static void bcom_phy_init(struct skge_port *skge, int jumbo)
1157 1177
1158 /* Use link status change interrupt */ 1178 /* Use link status change interrupt */
1159 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK); 1179 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1180}
1160 1181
1161 bcom_check_link(hw, port); 1182static void xm_phy_init(struct skge_port *skge)
1183{
1184 struct skge_hw *hw = skge->hw;
1185 int port = skge->port;
1186 u16 ctrl = 0;
1187
1188 if (skge->autoneg == AUTONEG_ENABLE) {
1189 if (skge->advertising & ADVERTISED_1000baseT_Half)
1190 ctrl |= PHY_X_AN_HD;
1191 if (skge->advertising & ADVERTISED_1000baseT_Full)
1192 ctrl |= PHY_X_AN_FD;
1193
1194 switch(skge->flow_control) {
1195 case FLOW_MODE_NONE:
1196 ctrl |= PHY_X_P_NO_PAUSE;
1197 break;
1198 case FLOW_MODE_LOC_SEND:
1199 ctrl |= PHY_X_P_ASYM_MD;
1200 break;
1201 case FLOW_MODE_SYMMETRIC:
1202 ctrl |= PHY_X_P_BOTH_MD;
1203 break;
1204 }
1205
1206 xm_phy_write(hw, port, PHY_XMAC_AUNE_ADV, ctrl);
1207
1208 /* Restart Auto-negotiation */
1209 ctrl = PHY_CT_ANE | PHY_CT_RE_CFG;
1210 } else {
1211 /* Set DuplexMode in Config register */
1212 if (skge->duplex == DUPLEX_FULL)
1213 ctrl |= PHY_CT_DUP_MD;
1214 /*
1215 * Do NOT enable Auto-negotiation here. This would hold
1216 * the link down because no IDLEs are transmitted
1217 */
1218 }
1219
1220 xm_phy_write(hw, port, PHY_XMAC_CTRL, ctrl);
1221
1222 /* Poll PHY for status changes */
1223 schedule_delayed_work(&skge->link_thread, LINK_HZ);
1224}
1225
1226static void xm_check_link(struct net_device *dev)
1227{
1228 struct skge_port *skge = netdev_priv(dev);
1229 struct skge_hw *hw = skge->hw;
1230 int port = skge->port;
1231 u16 status;
1232
1233 /* read twice because of latch */
1234 (void) xm_phy_read(hw, port, PHY_XMAC_STAT);
1235 status = xm_phy_read(hw, port, PHY_XMAC_STAT);
1236
1237 if ((status & PHY_ST_LSYNC) == 0) {
1238 u16 cmd = xm_read16(hw, port, XM_MMU_CMD);
1239 cmd &= ~(XM_MMU_ENA_RX | XM_MMU_ENA_TX);
1240 xm_write16(hw, port, XM_MMU_CMD, cmd);
1241 /* dummy read to ensure writing */
1242 (void) xm_read16(hw, port, XM_MMU_CMD);
1243
1244 if (netif_carrier_ok(dev))
1245 skge_link_down(skge);
1246 return;
1247 }
1248
1249 if (skge->autoneg == AUTONEG_ENABLE) {
1250 u16 lpa, res;
1251
1252 if (!(status & PHY_ST_AN_OVER))
1253 return;
1254
1255 lpa = xm_phy_read(hw, port, PHY_XMAC_AUNE_LP);
1256 if (lpa & PHY_B_AN_RF) {
1257 printk(KERN_NOTICE PFX "%s: remote fault\n",
1258 dev->name);
1259 return;
1260 }
1261
1262 res = xm_phy_read(hw, port, PHY_XMAC_RES_ABI);
1263
1264 /* Check Duplex mismatch */
1265 switch (res & (PHY_X_RS_HD | PHY_X_RS_FD)) {
1266 case PHY_X_RS_FD:
1267 skge->duplex = DUPLEX_FULL;
1268 break;
1269 case PHY_X_RS_HD:
1270 skge->duplex = DUPLEX_HALF;
1271 break;
1272 default:
1273 printk(KERN_NOTICE PFX "%s: duplex mismatch\n",
1274 dev->name);
1275 return;
1276 }
1277
1278 /* We are using IEEE 802.3z/D5.0 Table 37-4 */
1279 if (lpa & PHY_X_P_SYM_MD)
1280 skge->flow_control = FLOW_MODE_SYMMETRIC;
1281 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_ASYM_MD)
1282 skge->flow_control = FLOW_MODE_REM_SEND;
1283 else if ((lpa & PHY_X_RS_PAUSE) == PHY_X_P_BOTH_MD)
1284 skge->flow_control = FLOW_MODE_LOC_SEND;
1285 else
1286 skge->flow_control = FLOW_MODE_NONE;
1287
1288
1289 skge->speed = SPEED_1000;
1290 }
1291
1292 if (!netif_carrier_ok(dev))
1293 genesis_link_up(skge);
1294}
1295
1296/* Poll to check for link coming up.
1297 * Since internal PHY is wired to a level triggered pin, can't
1298 * get an interrupt when carrier is detected.
1299 */
1300static void xm_link_timer(void *arg)
1301{
1302 struct net_device *dev = arg;
1303 struct skge_port *skge = netdev_priv(arg);
1304 struct skge_hw *hw = skge->hw;
1305 int port = skge->port;
1306
1307 if (!netif_running(dev))
1308 return;
1309
1310 if (netif_carrier_ok(dev)) {
1311 xm_read16(hw, port, XM_ISRC);
1312 if (!(xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS))
1313 goto nochange;
1314 } else {
1315 if (xm_read32(hw, port, XM_GP_PORT) & XM_GP_INP_ASS)
1316 goto nochange;
1317 xm_read16(hw, port, XM_ISRC);
1318 if (xm_read16(hw, port, XM_ISRC) & XM_IS_INP_ASS)
1319 goto nochange;
1320 }
1321
1322 mutex_lock(&hw->phy_mutex);
1323 xm_check_link(dev);
1324 mutex_unlock(&hw->phy_mutex);
1325
1326nochange:
1327 schedule_delayed_work(&skge->link_thread, LINK_HZ);
1162} 1328}
1163 1329
1164static void genesis_mac_init(struct skge_hw *hw, int port) 1330static void genesis_mac_init(struct skge_hw *hw, int port)
@@ -1189,20 +1355,29 @@ static void genesis_mac_init(struct skge_hw *hw, int port)
1189 * namely for the 1000baseTX cards that use the XMAC's 1355 * namely for the 1000baseTX cards that use the XMAC's
1190 * GMII mode. 1356 * GMII mode.
1191 */ 1357 */
1192 /* Take external Phy out of reset */ 1358 if (hw->phy_type != SK_PHY_XMAC) {
1193 r = skge_read32(hw, B2_GP_IO); 1359 /* Take external Phy out of reset */
1194 if (port == 0) 1360 r = skge_read32(hw, B2_GP_IO);
1195 r |= GP_DIR_0|GP_IO_0; 1361 if (port == 0)
1196 else 1362 r |= GP_DIR_0|GP_IO_0;
1197 r |= GP_DIR_2|GP_IO_2; 1363 else
1364 r |= GP_DIR_2|GP_IO_2;
1198 1365
1199 skge_write32(hw, B2_GP_IO, r); 1366 skge_write32(hw, B2_GP_IO, r);
1200 1367
1368 /* Enable GMII interface */
1369 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1370 }
1201 1371
1202 /* Enable GMII interface */
1203 xm_write16(hw, port, XM_HW_CFG, XM_HW_GMII_MD);
1204 1372
1205 bcom_phy_init(skge, jumbo); 1373 switch(hw->phy_type) {
1374 case SK_PHY_XMAC:
1375 xm_phy_init(skge);
1376 break;
1377 case SK_PHY_BCOM:
1378 bcom_phy_init(skge);
1379 bcom_check_link(hw, port);
1380 }
1206 1381
1207 /* Set Station Address */ 1382 /* Set Station Address */
1208 xm_outaddr(hw, port, XM_SA, dev->dev_addr); 1383 xm_outaddr(hw, port, XM_SA, dev->dev_addr);
@@ -1335,16 +1510,18 @@ static void genesis_stop(struct skge_port *skge)
1335 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST); 1510 skge_write16(hw, SK_REG(port, TX_MFF_CTRL1), MFF_SET_MAC_RST);
1336 1511
1337 /* For external PHYs there must be special handling */ 1512 /* For external PHYs there must be special handling */
1338 reg = skge_read32(hw, B2_GP_IO); 1513 if (hw->phy_type != SK_PHY_XMAC) {
1339 if (port == 0) { 1514 reg = skge_read32(hw, B2_GP_IO);
1340 reg |= GP_DIR_0; 1515 if (port == 0) {
1341 reg &= ~GP_IO_0; 1516 reg |= GP_DIR_0;
1342 } else { 1517 reg &= ~GP_IO_0;
1343 reg |= GP_DIR_2; 1518 } else {
1344 reg &= ~GP_IO_2; 1519 reg |= GP_DIR_2;
1520 reg &= ~GP_IO_2;
1521 }
1522 skge_write32(hw, B2_GP_IO, reg);
1523 skge_read32(hw, B2_GP_IO);
1345 } 1524 }
1346 skge_write32(hw, B2_GP_IO, reg);
1347 skge_read32(hw, B2_GP_IO);
1348 1525
1349 xm_write16(hw, port, XM_MMU_CMD, 1526 xm_write16(hw, port, XM_MMU_CMD,
1350 xm_read16(hw, port, XM_MMU_CMD) 1527 xm_read16(hw, port, XM_MMU_CMD)
@@ -1406,7 +1583,7 @@ static void genesis_link_up(struct skge_port *skge)
1406 struct skge_hw *hw = skge->hw; 1583 struct skge_hw *hw = skge->hw;
1407 int port = skge->port; 1584 int port = skge->port;
1408 u16 cmd; 1585 u16 cmd;
1409 u32 mode, msk; 1586 u32 mode;
1410 1587
1411 cmd = xm_read16(hw, port, XM_MMU_CMD); 1588 cmd = xm_read16(hw, port, XM_MMU_CMD);
1412 1589
@@ -1454,27 +1631,24 @@ static void genesis_link_up(struct skge_port *skge)
1454 } 1631 }
1455 1632
1456 xm_write32(hw, port, XM_MODE, mode); 1633 xm_write32(hw, port, XM_MODE, mode);
1457 1634 xm_write16(hw, port, XM_IMSK, XM_DEF_MSK);
1458 msk = XM_DEF_MSK;
1459 /* disable GP0 interrupt bit for external Phy */
1460 msk |= XM_IS_INP_ASS;
1461
1462 xm_write16(hw, port, XM_IMSK, msk);
1463 xm_read16(hw, port, XM_ISRC); 1635 xm_read16(hw, port, XM_ISRC);
1464 1636
1465 /* get MMU Command Reg. */ 1637 /* get MMU Command Reg. */
1466 cmd = xm_read16(hw, port, XM_MMU_CMD); 1638 cmd = xm_read16(hw, port, XM_MMU_CMD);
1467 if (skge->duplex == DUPLEX_FULL) 1639 if (hw->phy_type != SK_PHY_XMAC && skge->duplex == DUPLEX_FULL)
1468 cmd |= XM_MMU_GMII_FD; 1640 cmd |= XM_MMU_GMII_FD;
1469 1641
1470 /* 1642 /*
1471 * Workaround BCOM Errata (#10523) for all BCom Phys 1643 * Workaround BCOM Errata (#10523) for all BCom Phys
1472 * Enable Power Management after link up 1644 * Enable Power Management after link up
1473 */ 1645 */
1474 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL, 1646 if (hw->phy_type == SK_PHY_BCOM) {
1475 xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL) 1647 xm_phy_write(hw, port, PHY_BCOM_AUX_CTRL,
1476 & ~PHY_B_AC_DIS_PM); 1648 xm_phy_read(hw, port, PHY_BCOM_AUX_CTRL)
1477 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK); 1649 & ~PHY_B_AC_DIS_PM);
1650 xm_phy_write(hw, port, PHY_BCOM_INT_MASK, PHY_B_DEF_MSK);
1651 }
1478 1652
1479 /* enable Rx/Tx */ 1653 /* enable Rx/Tx */
1480 xm_write16(hw, port, XM_MMU_CMD, 1654 xm_write16(hw, port, XM_MMU_CMD,
@@ -2240,6 +2414,8 @@ static int skge_down(struct net_device *dev)
2240 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 2414 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
2241 2415
2242 netif_stop_queue(dev); 2416 netif_stop_queue(dev);
2417 if (hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC)
2418 cancel_rearming_delayed_work(&skge->link_thread);
2243 2419
2244 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF); 2420 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
2245 if (hw->chip_id == CHIP_ID_GENESIS) 2421 if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2862,7 +3038,7 @@ static void skge_extirq(void *arg)
2862 if (netif_running(dev)) { 3038 if (netif_running(dev)) {
2863 if (hw->chip_id != CHIP_ID_GENESIS) 3039 if (hw->chip_id != CHIP_ID_GENESIS)
2864 yukon_phy_intr(skge); 3040 yukon_phy_intr(skge);
2865 else 3041 else if (hw->phy_type == SK_PHY_BCOM)
2866 bcom_phy_intr(skge); 3042 bcom_phy_intr(skge);
2867 } 3043 }
2868 } 3044 }
@@ -3014,7 +3190,7 @@ static int skge_reset(struct skge_hw *hw)
3014{ 3190{
3015 u32 reg; 3191 u32 reg;
3016 u16 ctst, pci_status; 3192 u16 ctst, pci_status;
3017 u8 t8, mac_cfg, pmd_type, phy_type; 3193 u8 t8, mac_cfg, pmd_type;
3018 int i; 3194 int i;
3019 3195
3020 ctst = skge_read16(hw, B0_CTST); 3196 ctst = skge_read16(hw, B0_CTST);
@@ -3038,19 +3214,22 @@ static int skge_reset(struct skge_hw *hw)
3038 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA)); 3214 ctst & (CS_CLK_RUN_HOT|CS_CLK_RUN_RST|CS_CLK_RUN_ENA));
3039 3215
3040 hw->chip_id = skge_read8(hw, B2_CHIP_ID); 3216 hw->chip_id = skge_read8(hw, B2_CHIP_ID);
3041 phy_type = skge_read8(hw, B2_E_1) & 0xf; 3217 hw->phy_type = skge_read8(hw, B2_E_1) & 0xf;
3042 pmd_type = skge_read8(hw, B2_PMD_TYP); 3218 pmd_type = skge_read8(hw, B2_PMD_TYP);
3043 hw->copper = (pmd_type == 'T' || pmd_type == '1'); 3219 hw->copper = (pmd_type == 'T' || pmd_type == '1');
3044 3220
3045 switch (hw->chip_id) { 3221 switch (hw->chip_id) {
3046 case CHIP_ID_GENESIS: 3222 case CHIP_ID_GENESIS:
3047 switch (phy_type) { 3223 switch (hw->phy_type) {
3224 case SK_PHY_XMAC:
3225 hw->phy_addr = PHY_ADDR_XMAC;
3226 break;
3048 case SK_PHY_BCOM: 3227 case SK_PHY_BCOM:
3049 hw->phy_addr = PHY_ADDR_BCOM; 3228 hw->phy_addr = PHY_ADDR_BCOM;
3050 break; 3229 break;
3051 default: 3230 default:
3052 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n", 3231 printk(KERN_ERR PFX "%s: unsupported phy type 0x%x\n",
3053 pci_name(hw->pdev), phy_type); 3232 pci_name(hw->pdev), hw->phy_type);
3054 return -EOPNOTSUPP; 3233 return -EOPNOTSUPP;
3055 } 3234 }
3056 break; 3235 break;
@@ -3058,7 +3237,7 @@ static int skge_reset(struct skge_hw *hw)
3058 case CHIP_ID_YUKON: 3237 case CHIP_ID_YUKON:
3059 case CHIP_ID_YUKON_LITE: 3238 case CHIP_ID_YUKON_LITE:
3060 case CHIP_ID_YUKON_LP: 3239 case CHIP_ID_YUKON_LP:
3061 if (phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S') 3240 if (hw->phy_type < SK_PHY_MARV_COPPER && pmd_type != 'S')
3062 hw->copper = 1; 3241 hw->copper = 1;
3063 3242
3064 hw->phy_addr = PHY_ADDR_MARV; 3243 hw->phy_addr = PHY_ADDR_MARV;
@@ -3089,10 +3268,13 @@ static int skge_reset(struct skge_hw *hw)
3089 else 3268 else
3090 hw->ram_size = t8 * 4096; 3269 hw->ram_size = t8 * 4096;
3091 3270
3092 hw->intr_mask = IS_HW_ERR | IS_EXT_REG | IS_PORT_1; 3271 hw->intr_mask = IS_HW_ERR | IS_PORT_1;
3093 if (hw->ports > 1) 3272 if (hw->ports > 1)
3094 hw->intr_mask |= IS_PORT_2; 3273 hw->intr_mask |= IS_PORT_2;
3095 3274
3275 if (!(hw->chip_id == CHIP_ID_GENESIS && hw->phy_type == SK_PHY_XMAC))
3276 hw->intr_mask |= IS_EXT_REG;
3277
3096 if (hw->chip_id == CHIP_ID_GENESIS) 3278 if (hw->chip_id == CHIP_ID_GENESIS)
3097 genesis_init(hw); 3279 genesis_init(hw);
3098 else { 3280 else {
@@ -3226,6 +3408,9 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
3226 3408
3227 skge->port = port; 3409 skge->port = port;
3228 3410
3411 /* Only used for Genesis XMAC */
3412 INIT_WORK(&skge->link_thread, xm_link_timer, dev);
3413
3229 if (hw->chip_id != CHIP_ID_GENESIS) { 3414 if (hw->chip_id != CHIP_ID_GENESIS) {
3230 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 3415 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
3231 skge->rx_csum = 1; 3416 skge->rx_csum = 1;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 79e09271bcf9..d0b47d46cf9d 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -934,7 +934,7 @@ enum {
934 PHY_XMAC_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */ 934 PHY_XMAC_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */
935 PHY_XMAC_AUNE_LP = 0x05,/* 16 bit r/o Link Partner Abi Reg */ 935 PHY_XMAC_AUNE_LP = 0x05,/* 16 bit r/o Link Partner Abi Reg */
936 PHY_XMAC_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */ 936 PHY_XMAC_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */
937 PHY_XMAC_NEPG = 0x07,/* 16 bit r/w Next Page Register */ 937 PHY_XMAC_NEPG = 0x07,/* 16 bit r/w Next Page Register */
938 PHY_XMAC_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */ 938 PHY_XMAC_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */
939 939
940 PHY_XMAC_EXT_STAT = 0x0f,/* 16 bit r/o Ext Status Register */ 940 PHY_XMAC_EXT_STAT = 0x0f,/* 16 bit r/o Ext Status Register */
@@ -1097,13 +1097,36 @@ enum {
1097 1097
1098/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */ 1098/* Pause Bits (PHY_X_AN_PAUSE and PHY_X_RS_PAUSE) encoding */
1099enum { 1099enum {
1100 PHY_X_P_NO_PAUSE = 0<<7,/* Bit 8..7: no Pause Mode */ 1100 PHY_X_P_NO_PAUSE= 0<<7,/* Bit 8..7: no Pause Mode */
1101 PHY_X_P_SYM_MD = 1<<7, /* Bit 8..7: symmetric Pause Mode */ 1101 PHY_X_P_SYM_MD = 1<<7, /* Bit 8..7: symmetric Pause Mode */
1102 PHY_X_P_ASYM_MD = 2<<7,/* Bit 8..7: asymmetric Pause Mode */ 1102 PHY_X_P_ASYM_MD = 2<<7,/* Bit 8..7: asymmetric Pause Mode */
1103 PHY_X_P_BOTH_MD = 3<<7,/* Bit 8..7: both Pause Mode */ 1103 PHY_X_P_BOTH_MD = 3<<7,/* Bit 8..7: both Pause Mode */
1104}; 1104};
1105 1105
1106 1106
1107/***** PHY_XMAC_EXT_STAT 16 bit r/w Extended Status Register *****/
1108enum {
1109 PHY_X_EX_FD = 1<<15, /* Bit 15: Device Supports Full Duplex */
1110 PHY_X_EX_HD = 1<<14, /* Bit 14: Device Supports Half Duplex */
1111};
1112
1113/***** PHY_XMAC_RES_ABI 16 bit r/o PHY Resolved Ability *****/
1114enum {
1115 PHY_X_RS_PAUSE = 3<<7, /* Bit 8..7: selected Pause Mode */
1116 PHY_X_RS_HD = 1<<6, /* Bit 6: Half Duplex Mode selected */
1117 PHY_X_RS_FD = 1<<5, /* Bit 5: Full Duplex Mode selected */
1118 PHY_X_RS_ABLMIS = 1<<4, /* Bit 4: duplex or pause cap mismatch */
1119 PHY_X_RS_PAUMIS = 1<<3, /* Bit 3: pause capability mismatch */
1120};
1121
1122/* Remote Fault Bits (PHY_X_AN_RFB) encoding */
1123enum {
1124 X_RFB_OK = 0<<12,/* Bit 13..12 No errors, Link OK */
1125 X_RFB_LF = 1<<12,/* Bit 13..12 Link Failure */
1126 X_RFB_OFF = 2<<12,/* Bit 13..12 Offline */
1127 X_RFB_AN_ERR = 3<<12,/* Bit 13..12 Auto-Negotiation Error */
1128};
1129
1107/* Broadcom-Specific */ 1130/* Broadcom-Specific */
1108/***** PHY_BCOM_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ 1131/***** PHY_BCOM_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
1109enum { 1132enum {
@@ -2158,8 +2181,8 @@ enum {
2158 XM_IS_LNK_AE = 1<<14, /* Bit 14: Link Asynchronous Event */ 2181 XM_IS_LNK_AE = 1<<14, /* Bit 14: Link Asynchronous Event */
2159 XM_IS_TX_ABORT = 1<<13, /* Bit 13: Transmit Abort, late Col. etc */ 2182 XM_IS_TX_ABORT = 1<<13, /* Bit 13: Transmit Abort, late Col. etc */
2160 XM_IS_FRC_INT = 1<<12, /* Bit 12: Force INT bit set in GP */ 2183 XM_IS_FRC_INT = 1<<12, /* Bit 12: Force INT bit set in GP */
2161 XM_IS_INP_ASS = 1<<11, /* Bit 11: Input Asserted, GP bit 0 set */ 2184 XM_IS_INP_ASS = 1<<11, /* Bit 11: Input Asserted, GP bit 0 set */
2162 XM_IS_LIPA_RC = 1<<10, /* Bit 10: Link Partner requests config */ 2185 XM_IS_LIPA_RC = 1<<10, /* Bit 10: Link Partner requests config */
2163 XM_IS_RX_PAGE = 1<<9, /* Bit 9: Page Received */ 2186 XM_IS_RX_PAGE = 1<<9, /* Bit 9: Page Received */
2164 XM_IS_TX_PAGE = 1<<8, /* Bit 8: Next Page Loaded for Transmit */ 2187 XM_IS_TX_PAGE = 1<<8, /* Bit 8: Next Page Loaded for Transmit */
2165 XM_IS_AND = 1<<7, /* Bit 7: Auto-Negotiation Done */ 2188 XM_IS_AND = 1<<7, /* Bit 7: Auto-Negotiation Done */
@@ -2172,9 +2195,7 @@ enum {
2172 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */ 2195 XM_IS_RX_COMP = 1<<0, /* Bit 0: Frame Rx Complete */
2173}; 2196};
2174 2197
2175#define XM_DEF_MSK (~(XM_IS_INP_ASS | XM_IS_LIPA_RC | XM_IS_RX_PAGE | \ 2198#define XM_DEF_MSK (~(XM_IS_RXC_OV | XM_IS_TXC_OV | XM_IS_RXF_OV | XM_IS_TXF_UR))
2176 XM_IS_AND | XM_IS_RXC_OV | XM_IS_TXC_OV | \
2177 XM_IS_RXF_OV | XM_IS_TXF_UR))
2178 2199
2179 2200
2180/* XM_HW_CFG 16 bit r/w Hardware Config Register */ 2201/* XM_HW_CFG 16 bit r/w Hardware Config Register */
@@ -2396,6 +2417,7 @@ struct skge_hw {
2396 u8 chip_rev; 2417 u8 chip_rev;
2397 u8 copper; 2418 u8 copper;
2398 u8 ports; 2419 u8 ports;
2420 u8 phy_type;
2399 2421
2400 u32 ram_size; 2422 u32 ram_size;
2401 u32 ram_offset; 2423 u32 ram_offset;
@@ -2422,6 +2444,7 @@ struct skge_port {
2422 2444
2423 struct net_device_stats net_stats; 2445 struct net_device_stats net_stats;
2424 2446
2447 struct work_struct link_thread;
2425 u8 rx_csum; 2448 u8 rx_csum;
2426 u8 blink_on; 2449 u8 blink_on;
2427 u8 flow_control; 2450 u8 flow_control;
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 7aa7fbac8224..c660e33f43a2 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -379,6 +379,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r,
379 379
380#define SMC_IRQ_FLAGS (0) 380#define SMC_IRQ_FLAGS (0)
381 381
382#elif defined(CONFIG_ARCH_VERSATILE)
383
384#define SMC_CAN_USE_8BIT 1
385#define SMC_CAN_USE_16BIT 1
386#define SMC_CAN_USE_32BIT 1
387#define SMC_NOWAIT 1
388
389#define SMC_inb(a, r) readb((a) + (r))
390#define SMC_inw(a, r) readw((a) + (r))
391#define SMC_inl(a, r) readl((a) + (r))
392#define SMC_outb(v, a, r) writeb(v, (a) + (r))
393#define SMC_outw(v, a, r) writew(v, (a) + (r))
394#define SMC_outl(v, a, r) writel(v, (a) + (r))
395#define SMC_insl(a, r, p, l) readsl((a) + (r), p, l)
396#define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l)
397
398#define SMC_IRQ_FLAGS (0)
399
382#else 400#else
383 401
384#define SMC_CAN_USE_8BIT 1 402#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/stnic.c b/drivers/net/stnic.c
index 3fd7a4fee665..e6f90427160c 100644
--- a/drivers/net/stnic.c
+++ b/drivers/net/stnic.c
@@ -19,7 +19,7 @@
19 19
20#include <asm/system.h> 20#include <asm/system.h>
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/se/se.h> 22#include <asm/se.h>
23#include <asm/machvec.h> 23#include <asm/machvec.h>
24#ifdef CONFIG_SH_STANDARD_BIOS 24#ifdef CONFIG_SH_STANDARD_BIOS
25#include <asm/sh_bios.h> 25#include <asm/sh_bios.h>
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c
index 0d66700c6ced..bfc8c3eae9a1 100644
--- a/drivers/net/tokenring/lanstreamer.c
+++ b/drivers/net/tokenring/lanstreamer.c
@@ -1876,7 +1876,6 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1876 datap[size+1]=io_word & 0xff; 1876 datap[size+1]=io_word & 0xff;
1877 } 1877 }
1878 1878
1879
1880 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name); 1879 size = sprintf(buffer, "\n%6s: Adapter Address : Node Address : Functional Addr\n", dev->name);
1881 1880
1882 size += sprintf(buffer + size, 1881 size += sprintf(buffer + size,
@@ -1932,64 +1931,6 @@ static int sprintf_info(char *buffer, struct net_device *dev)
1932#endif 1931#endif
1933#endif 1932#endif
1934 1933
1935#if STREAMER_IOCTL && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1936static int streamer_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1937{
1938 int i;
1939 struct streamer_private *streamer_priv = (struct streamer_private *) dev->priv;
1940 u8 __iomem *streamer_mmio = streamer_priv->streamer_mmio;
1941
1942 switch(cmd) {
1943 case IOCTL_SISR_MASK:
1944 writew(SISR_MI, streamer_mmio + SISR_MASK_SUM);
1945 break;
1946 case IOCTL_SPIN_LOCK_TEST:
1947 printk(KERN_INFO "spin_lock() called.\n");
1948 spin_lock(&streamer_priv->streamer_lock);
1949 spin_unlock(&streamer_priv->streamer_lock);
1950 printk(KERN_INFO "spin_unlock() finished.\n");
1951 break;
1952 case IOCTL_PRINT_BDAS:
1953 printk(KERN_INFO "bdas: RXBDA: %x RXLBDA: %x TX2FDA: %x TX2LFDA: %x\n",
1954 readw(streamer_mmio + RXBDA),
1955 readw(streamer_mmio + RXLBDA),
1956 readw(streamer_mmio + TX2FDA),
1957 readw(streamer_mmio + TX2LFDA));
1958 break;
1959 case IOCTL_PRINT_REGISTERS:
1960 printk(KERN_INFO "registers:\n");
1961 printk(KERN_INFO "SISR: %04x MISR: %04x LISR: %04x BCTL: %04x BMCTL: %04x\nmask %04x mask %04x\n",
1962 readw(streamer_mmio + SISR),
1963 readw(streamer_mmio + MISR_RUM),
1964 readw(streamer_mmio + LISR),
1965 readw(streamer_mmio + BCTL),
1966 readw(streamer_mmio + BMCTL_SUM),
1967 readw(streamer_mmio + SISR_MASK),
1968 readw(streamer_mmio + MISR_MASK));
1969 break;
1970 case IOCTL_PRINT_RX_BUFS:
1971 printk(KERN_INFO "Print rx bufs:\n");
1972 for(i=0; i<STREAMER_RX_RING_SIZE; i++)
1973 printk(KERN_INFO "rx_ring %d status: 0x%x\n", i,
1974 streamer_priv->streamer_rx_ring[i].status);
1975 break;
1976 case IOCTL_PRINT_TX_BUFS:
1977 printk(KERN_INFO "Print tx bufs:\n");
1978 for(i=0; i<STREAMER_TX_RING_SIZE; i++)
1979 printk(KERN_INFO "tx_ring %d status: 0x%x\n", i,
1980 streamer_priv->streamer_tx_ring[i].status);
1981 break;
1982 case IOCTL_RX_CMD:
1983 streamer_rx(dev);
1984 printk(KERN_INFO "Sent rx command.\n");
1985 break;
1986 default:
1987 printk(KERN_INFO "Bad ioctl!\n");
1988 }
1989 return 0;
1990}
1991#endif
1992
1993static struct pci_driver streamer_pci_driver = { 1934static struct pci_driver streamer_pci_driver = {
1994 .name = "lanstreamer", 1935 .name = "lanstreamer",
1995 .id_table = streamer_pci_tbl, 1936 .id_table = streamer_pci_tbl,
diff --git a/drivers/net/tokenring/lanstreamer.h b/drivers/net/tokenring/lanstreamer.h
index 5557d8e1e22d..e7bb3494afc7 100644
--- a/drivers/net/tokenring/lanstreamer.h
+++ b/drivers/net/tokenring/lanstreamer.h
@@ -62,18 +62,6 @@
62 62
63#include <linux/version.h> 63#include <linux/version.h>
64 64
65#if STREAMER_IOCTL && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
66#include <asm/ioctl.h>
67#define IOCTL_PRINT_RX_BUFS SIOCDEVPRIVATE
68#define IOCTL_PRINT_TX_BUFS SIOCDEVPRIVATE+1
69#define IOCTL_RX_CMD SIOCDEVPRIVATE+2
70#define IOCTL_TX_CMD SIOCDEVPRIVATE+3
71#define IOCTL_PRINT_REGISTERS SIOCDEVPRIVATE+4
72#define IOCTL_PRINT_BDAS SIOCDEVPRIVATE+5
73#define IOCTL_SPIN_LOCK_TEST SIOCDEVPRIVATE+6
74#define IOCTL_SISR_MASK SIOCDEVPRIVATE+7
75#endif
76
77/* MAX_INTR - the maximum number of times we can loop 65/* MAX_INTR - the maximum number of times we can loop
78 * inside the interrupt function before returning 66 * inside the interrupt function before returning
79 * control to the OS (maximum value is 256) 67 * control to the OS (maximum value is 256)
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index e661d0a9cc64..fb5fa7d68888 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -2114,6 +2114,7 @@ static struct eisa_device_id de4x5_eisa_ids[] = {
2114 { "DEC4250", 0 }, /* 0 is the board name index... */ 2114 { "DEC4250", 0 }, /* 0 is the board name index... */
2115 { "" } 2115 { "" }
2116}; 2116};
2117MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids);
2117 2118
2118static struct eisa_driver de4x5_eisa_driver = { 2119static struct eisa_driver de4x5_eisa_driver = {
2119 .id_table = de4x5_eisa_ids, 2120 .id_table = de4x5_eisa_ids,
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
index 8f6f6fd8b87d..d5c32e9caa97 100644
--- a/drivers/net/typhoon.c
+++ b/drivers/net/typhoon.c
@@ -333,11 +333,7 @@ enum state_values {
333#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY) 333#define TYPHOON_RESET_TIMEOUT_NOSLEEP ((6 * 1000000) / TYPHOON_UDELAY)
334#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY) 334#define TYPHOON_WAIT_TIMEOUT ((1000000 / 2) / TYPHOON_UDELAY)
335 335
336#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 28)
337#define typhoon_synchronize_irq(x) synchronize_irq()
338#else
339#define typhoon_synchronize_irq(x) synchronize_irq(x) 336#define typhoon_synchronize_irq(x) synchronize_irq(x)
340#endif
341 337
342#if defined(NETIF_F_TSO) 338#if defined(NETIF_F_TSO)
343#define skb_tso_size(x) (skb_shinfo(x)->gso_size) 339#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
diff --git a/drivers/net/wan/Kconfig b/drivers/net/wan/Kconfig
index 54b8e492ef97..58b7efbb0750 100644
--- a/drivers/net/wan/Kconfig
+++ b/drivers/net/wan/Kconfig
@@ -154,7 +154,7 @@ config HDLC
154 If unsure, say N. 154 If unsure, say N.
155 155
156config HDLC_RAW 156config HDLC_RAW
157 bool "Raw HDLC support" 157 tristate "Raw HDLC support"
158 depends on HDLC 158 depends on HDLC
159 help 159 help
160 Generic HDLC driver supporting raw HDLC over WAN connections. 160 Generic HDLC driver supporting raw HDLC over WAN connections.
@@ -162,7 +162,7 @@ config HDLC_RAW
162 If unsure, say N. 162 If unsure, say N.
163 163
164config HDLC_RAW_ETH 164config HDLC_RAW_ETH
165 bool "Raw HDLC Ethernet device support" 165 tristate "Raw HDLC Ethernet device support"
166 depends on HDLC 166 depends on HDLC
167 help 167 help
168 Generic HDLC driver supporting raw HDLC Ethernet device emulation 168 Generic HDLC driver supporting raw HDLC Ethernet device emulation
@@ -173,7 +173,7 @@ config HDLC_RAW_ETH
173 If unsure, say N. 173 If unsure, say N.
174 174
175config HDLC_CISCO 175config HDLC_CISCO
176 bool "Cisco HDLC support" 176 tristate "Cisco HDLC support"
177 depends on HDLC 177 depends on HDLC
178 help 178 help
179 Generic HDLC driver supporting Cisco HDLC over WAN connections. 179 Generic HDLC driver supporting Cisco HDLC over WAN connections.
@@ -181,7 +181,7 @@ config HDLC_CISCO
181 If unsure, say N. 181 If unsure, say N.
182 182
183config HDLC_FR 183config HDLC_FR
184 bool "Frame Relay support" 184 tristate "Frame Relay support"
185 depends on HDLC 185 depends on HDLC
186 help 186 help
187 Generic HDLC driver supporting Frame Relay over WAN connections. 187 Generic HDLC driver supporting Frame Relay over WAN connections.
@@ -189,7 +189,7 @@ config HDLC_FR
189 If unsure, say N. 189 If unsure, say N.
190 190
191config HDLC_PPP 191config HDLC_PPP
192 bool "Synchronous Point-to-Point Protocol (PPP) support" 192 tristate "Synchronous Point-to-Point Protocol (PPP) support"
193 depends on HDLC 193 depends on HDLC
194 help 194 help
195 Generic HDLC driver supporting PPP over WAN connections. 195 Generic HDLC driver supporting PPP over WAN connections.
@@ -197,7 +197,7 @@ config HDLC_PPP
197 If unsure, say N. 197 If unsure, say N.
198 198
199config HDLC_X25 199config HDLC_X25
200 bool "X.25 protocol support" 200 tristate "X.25 protocol support"
201 depends on HDLC && (LAPB=m && HDLC=m || LAPB=y) 201 depends on HDLC && (LAPB=m && HDLC=m || LAPB=y)
202 help 202 help
203 Generic HDLC driver supporting X.25 over WAN connections. 203 Generic HDLC driver supporting X.25 over WAN connections.
diff --git a/drivers/net/wan/Makefile b/drivers/net/wan/Makefile
index 316ca6869d5e..83ec2c87ba3f 100644
--- a/drivers/net/wan/Makefile
+++ b/drivers/net/wan/Makefile
@@ -9,14 +9,13 @@ cyclomx-y := cycx_main.o
9cyclomx-$(CONFIG_CYCLOMX_X25) += cycx_x25.o 9cyclomx-$(CONFIG_CYCLOMX_X25) += cycx_x25.o
10cyclomx-objs := $(cyclomx-y) 10cyclomx-objs := $(cyclomx-y)
11 11
12hdlc-y := hdlc_generic.o 12obj-$(CONFIG_HDLC) += hdlc.o
13hdlc-$(CONFIG_HDLC_RAW) += hdlc_raw.o 13obj-$(CONFIG_HDLC_RAW) += hdlc_raw.o
14hdlc-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o 14obj-$(CONFIG_HDLC_RAW_ETH) += hdlc_raw_eth.o
15hdlc-$(CONFIG_HDLC_CISCO) += hdlc_cisco.o 15obj-$(CONFIG_HDLC_CISCO) += hdlc_cisco.o
16hdlc-$(CONFIG_HDLC_FR) += hdlc_fr.o 16obj-$(CONFIG_HDLC_FR) += hdlc_fr.o
17hdlc-$(CONFIG_HDLC_PPP) += hdlc_ppp.o 17obj-$(CONFIG_HDLC_PPP) += hdlc_ppp.o syncppp.o
18hdlc-$(CONFIG_HDLC_X25) += hdlc_x25.o 18obj-$(CONFIG_HDLC_X25) += hdlc_x25.o
19hdlc-objs := $(hdlc-y)
20 19
21pc300-y := pc300_drv.o 20pc300-y := pc300_drv.o
22pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o 21pc300-$(CONFIG_PC300_MLPPP) += pc300_tty.o
@@ -38,10 +37,6 @@ obj-$(CONFIG_CYCLADES_SYNC) += cycx_drv.o cyclomx.o
38obj-$(CONFIG_LAPBETHER) += lapbether.o 37obj-$(CONFIG_LAPBETHER) += lapbether.o
39obj-$(CONFIG_SBNI) += sbni.o 38obj-$(CONFIG_SBNI) += sbni.o
40obj-$(CONFIG_PC300) += pc300.o 39obj-$(CONFIG_PC300) += pc300.o
41obj-$(CONFIG_HDLC) += hdlc.o
42ifeq ($(CONFIG_HDLC_PPP),y)
43 obj-$(CONFIG_HDLC) += syncppp.o
44endif
45obj-$(CONFIG_N2) += n2.o 40obj-$(CONFIG_N2) += n2.o
46obj-$(CONFIG_C101) += c101.o 41obj-$(CONFIG_C101) += c101.o
47obj-$(CONFIG_WANXL) += wanxl.o 42obj-$(CONFIG_WANXL) += wanxl.o
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc.c
index 04ca1f7b6424..db354e0edbe5 100644
--- a/drivers/net/wan/hdlc_generic.c
+++ b/drivers/net/wan/hdlc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * 3 *
4 * Copyright (C) 1999 - 2005 Krzysztof Halasa <khc@pm.waw.pl> 4 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of version 2 of the GNU General Public License 7 * under the terms of version 2 of the GNU General Public License
@@ -17,9 +17,9 @@
17 * Use sethdlc utility to set line parameters, protocol and PVCs 17 * Use sethdlc utility to set line parameters, protocol and PVCs
18 * 18 *
19 * How does it work: 19 * How does it work:
20 * - proto.open(), close(), start(), stop() calls are serialized. 20 * - proto->open(), close(), start(), stop() calls are serialized.
21 * The order is: open, [ start, stop ... ] close ... 21 * The order is: open, [ start, stop ... ] close ...
22 * - proto.start() and stop() are called with spin_lock_irq held. 22 * - proto->start() and stop() are called with spin_lock_irq held.
23 */ 23 */
24 24
25#include <linux/module.h> 25#include <linux/module.h>
@@ -38,10 +38,12 @@
38#include <linux/hdlc.h> 38#include <linux/hdlc.h>
39 39
40 40
41static const char* version = "HDLC support module revision 1.19"; 41static const char* version = "HDLC support module revision 1.20";
42 42
43#undef DEBUG_LINK 43#undef DEBUG_LINK
44 44
45static struct hdlc_proto *first_proto = NULL;
46
45 47
46static int hdlc_change_mtu(struct net_device *dev, int new_mtu) 48static int hdlc_change_mtu(struct net_device *dev, int new_mtu)
47{ 49{
@@ -63,11 +65,11 @@ static struct net_device_stats *hdlc_get_stats(struct net_device *dev)
63static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, 65static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
64 struct packet_type *p, struct net_device *orig_dev) 66 struct packet_type *p, struct net_device *orig_dev)
65{ 67{
66 hdlc_device *hdlc = dev_to_hdlc(dev); 68 struct hdlc_device_desc *desc = dev_to_desc(dev);
67 if (hdlc->proto.netif_rx) 69 if (desc->netif_rx)
68 return hdlc->proto.netif_rx(skb); 70 return desc->netif_rx(skb);
69 71
70 hdlc->stats.rx_dropped++; /* Shouldn't happen */ 72 desc->stats.rx_dropped++; /* Shouldn't happen */
71 dev_kfree_skb(skb); 73 dev_kfree_skb(skb);
72 return NET_RX_DROP; 74 return NET_RX_DROP;
73} 75}
@@ -77,8 +79,8 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
77static inline void hdlc_proto_start(struct net_device *dev) 79static inline void hdlc_proto_start(struct net_device *dev)
78{ 80{
79 hdlc_device *hdlc = dev_to_hdlc(dev); 81 hdlc_device *hdlc = dev_to_hdlc(dev);
80 if (hdlc->proto.start) 82 if (hdlc->proto->start)
81 return hdlc->proto.start(dev); 83 return hdlc->proto->start(dev);
82} 84}
83 85
84 86
@@ -86,8 +88,8 @@ static inline void hdlc_proto_start(struct net_device *dev)
86static inline void hdlc_proto_stop(struct net_device *dev) 88static inline void hdlc_proto_stop(struct net_device *dev)
87{ 89{
88 hdlc_device *hdlc = dev_to_hdlc(dev); 90 hdlc_device *hdlc = dev_to_hdlc(dev);
89 if (hdlc->proto.stop) 91 if (hdlc->proto->stop)
90 return hdlc->proto.stop(dev); 92 return hdlc->proto->stop(dev);
91} 93}
92 94
93 95
@@ -144,15 +146,15 @@ int hdlc_open(struct net_device *dev)
144{ 146{
145 hdlc_device *hdlc = dev_to_hdlc(dev); 147 hdlc_device *hdlc = dev_to_hdlc(dev);
146#ifdef DEBUG_LINK 148#ifdef DEBUG_LINK
147 printk(KERN_DEBUG "hdlc_open() carrier %i open %i\n", 149 printk(KERN_DEBUG "%s: hdlc_open() carrier %i open %i\n", dev->name,
148 hdlc->carrier, hdlc->open); 150 hdlc->carrier, hdlc->open);
149#endif 151#endif
150 152
151 if (hdlc->proto.id == -1) 153 if (hdlc->proto == NULL)
152 return -ENOSYS; /* no protocol attached */ 154 return -ENOSYS; /* no protocol attached */
153 155
154 if (hdlc->proto.open) { 156 if (hdlc->proto->open) {
155 int result = hdlc->proto.open(dev); 157 int result = hdlc->proto->open(dev);
156 if (result) 158 if (result)
157 return result; 159 return result;
158 } 160 }
@@ -178,7 +180,7 @@ void hdlc_close(struct net_device *dev)
178{ 180{
179 hdlc_device *hdlc = dev_to_hdlc(dev); 181 hdlc_device *hdlc = dev_to_hdlc(dev);
180#ifdef DEBUG_LINK 182#ifdef DEBUG_LINK
181 printk(KERN_DEBUG "hdlc_close() carrier %i open %i\n", 183 printk(KERN_DEBUG "%s: hdlc_close() carrier %i open %i\n", dev->name,
182 hdlc->carrier, hdlc->open); 184 hdlc->carrier, hdlc->open);
183#endif 185#endif
184 186
@@ -190,68 +192,34 @@ void hdlc_close(struct net_device *dev)
190 192
191 spin_unlock_irq(&hdlc->state_lock); 193 spin_unlock_irq(&hdlc->state_lock);
192 194
193 if (hdlc->proto.close) 195 if (hdlc->proto->close)
194 hdlc->proto.close(dev); 196 hdlc->proto->close(dev);
195} 197}
196 198
197 199
198 200
199#ifndef CONFIG_HDLC_RAW
200#define hdlc_raw_ioctl(dev, ifr) -ENOSYS
201#endif
202
203#ifndef CONFIG_HDLC_RAW_ETH
204#define hdlc_raw_eth_ioctl(dev, ifr) -ENOSYS
205#endif
206
207#ifndef CONFIG_HDLC_PPP
208#define hdlc_ppp_ioctl(dev, ifr) -ENOSYS
209#endif
210
211#ifndef CONFIG_HDLC_CISCO
212#define hdlc_cisco_ioctl(dev, ifr) -ENOSYS
213#endif
214
215#ifndef CONFIG_HDLC_FR
216#define hdlc_fr_ioctl(dev, ifr) -ENOSYS
217#endif
218
219#ifndef CONFIG_HDLC_X25
220#define hdlc_x25_ioctl(dev, ifr) -ENOSYS
221#endif
222
223
224int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 201int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
225{ 202{
226 hdlc_device *hdlc = dev_to_hdlc(dev); 203 struct hdlc_proto *proto = first_proto;
227 unsigned int proto; 204 int result;
228 205
229 if (cmd != SIOCWANDEV) 206 if (cmd != SIOCWANDEV)
230 return -EINVAL; 207 return -EINVAL;
231 208
232 switch(ifr->ifr_settings.type) { 209 if (dev_to_hdlc(dev)->proto) {
233 case IF_PROTO_HDLC: 210 result = dev_to_hdlc(dev)->proto->ioctl(dev, ifr);
234 case IF_PROTO_HDLC_ETH: 211 if (result != -EINVAL)
235 case IF_PROTO_PPP: 212 return result;
236 case IF_PROTO_CISCO:
237 case IF_PROTO_FR:
238 case IF_PROTO_X25:
239 proto = ifr->ifr_settings.type;
240 break;
241
242 default:
243 proto = hdlc->proto.id;
244 } 213 }
245 214
246 switch(proto) { 215 /* Not handled by currently attached protocol (if any) */
247 case IF_PROTO_HDLC: return hdlc_raw_ioctl(dev, ifr); 216
248 case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(dev, ifr); 217 while (proto) {
249 case IF_PROTO_PPP: return hdlc_ppp_ioctl(dev, ifr); 218 if ((result = proto->ioctl(dev, ifr)) != -EINVAL)
250 case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr); 219 return result;
251 case IF_PROTO_FR: return hdlc_fr_ioctl(dev, ifr); 220 proto = proto->next;
252 case IF_PROTO_X25: return hdlc_x25_ioctl(dev, ifr);
253 default: return -EINVAL;
254 } 221 }
222 return -EINVAL;
255} 223}
256 224
257void hdlc_setup(struct net_device *dev) 225void hdlc_setup(struct net_device *dev)
@@ -267,8 +235,6 @@ void hdlc_setup(struct net_device *dev)
267 235
268 dev->flags = IFF_POINTOPOINT | IFF_NOARP; 236 dev->flags = IFF_POINTOPOINT | IFF_NOARP;
269 237
270 hdlc->proto.id = -1;
271 hdlc->proto.detach = NULL;
272 hdlc->carrier = 1; 238 hdlc->carrier = 1;
273 hdlc->open = 0; 239 hdlc->open = 0;
274 spin_lock_init(&hdlc->state_lock); 240 spin_lock_init(&hdlc->state_lock);
@@ -277,7 +243,8 @@ void hdlc_setup(struct net_device *dev)
277struct net_device *alloc_hdlcdev(void *priv) 243struct net_device *alloc_hdlcdev(void *priv)
278{ 244{
279 struct net_device *dev; 245 struct net_device *dev;
280 dev = alloc_netdev(sizeof(hdlc_device), "hdlc%d", hdlc_setup); 246 dev = alloc_netdev(sizeof(struct hdlc_device_desc) +
247 sizeof(hdlc_device), "hdlc%d", hdlc_setup);
281 if (dev) 248 if (dev)
282 dev_to_hdlc(dev)->priv = priv; 249 dev_to_hdlc(dev)->priv = priv;
283 return dev; 250 return dev;
@@ -286,13 +253,71 @@ struct net_device *alloc_hdlcdev(void *priv)
286void unregister_hdlc_device(struct net_device *dev) 253void unregister_hdlc_device(struct net_device *dev)
287{ 254{
288 rtnl_lock(); 255 rtnl_lock();
289 hdlc_proto_detach(dev_to_hdlc(dev));
290 unregister_netdevice(dev); 256 unregister_netdevice(dev);
257 detach_hdlc_protocol(dev);
291 rtnl_unlock(); 258 rtnl_unlock();
292} 259}
293 260
294 261
295 262
263int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
264 int (*rx)(struct sk_buff *skb), size_t size)
265{
266 detach_hdlc_protocol(dev);
267
268 if (!try_module_get(proto->module))
269 return -ENOSYS;
270
271 if (size)
272 if ((dev_to_hdlc(dev)->state = kmalloc(size,
273 GFP_KERNEL)) == NULL) {
274 printk(KERN_WARNING "Memory squeeze on"
275 " hdlc_proto_attach()\n");
276 module_put(proto->module);
277 return -ENOBUFS;
278 }
279 dev_to_hdlc(dev)->proto = proto;
280 dev_to_desc(dev)->netif_rx = rx;
281 return 0;
282}
283
284
285void detach_hdlc_protocol(struct net_device *dev)
286{
287 hdlc_device *hdlc = dev_to_hdlc(dev);
288
289 if (hdlc->proto) {
290 if (hdlc->proto->detach)
291 hdlc->proto->detach(dev);
292 module_put(hdlc->proto->module);
293 hdlc->proto = NULL;
294 }
295 kfree(hdlc->state);
296 hdlc->state = NULL;
297}
298
299
300void register_hdlc_protocol(struct hdlc_proto *proto)
301{
302 proto->next = first_proto;
303 first_proto = proto;
304}
305
306
307void unregister_hdlc_protocol(struct hdlc_proto *proto)
308{
309 struct hdlc_proto **p = &first_proto;
310 while (*p) {
311 if (*p == proto) {
312 *p = proto->next;
313 return;
314 }
315 p = &((*p)->next);
316 }
317}
318
319
320
296MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>"); 321MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
297MODULE_DESCRIPTION("HDLC support module"); 322MODULE_DESCRIPTION("HDLC support module");
298MODULE_LICENSE("GPL v2"); 323MODULE_LICENSE("GPL v2");
@@ -303,6 +328,10 @@ EXPORT_SYMBOL(hdlc_ioctl);
303EXPORT_SYMBOL(hdlc_setup); 328EXPORT_SYMBOL(hdlc_setup);
304EXPORT_SYMBOL(alloc_hdlcdev); 329EXPORT_SYMBOL(alloc_hdlcdev);
305EXPORT_SYMBOL(unregister_hdlc_device); 330EXPORT_SYMBOL(unregister_hdlc_device);
331EXPORT_SYMBOL(register_hdlc_protocol);
332EXPORT_SYMBOL(unregister_hdlc_protocol);
333EXPORT_SYMBOL(attach_hdlc_protocol);
334EXPORT_SYMBOL(detach_hdlc_protocol);
306 335
307static struct packet_type hdlc_packet_type = { 336static struct packet_type hdlc_packet_type = {
308 .type = __constant_htons(ETH_P_HDLC), 337 .type = __constant_htons(ETH_P_HDLC),
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index f289daba0c7b..7ec2b2f9b7ee 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * Cisco HDLC support 3 * Cisco HDLC support
4 * 4 *
5 * Copyright (C) 2000 - 2003 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 2000 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -34,17 +34,56 @@
34#define CISCO_KEEPALIVE_REQ 2 /* Cisco keepalive request */ 34#define CISCO_KEEPALIVE_REQ 2 /* Cisco keepalive request */
35 35
36 36
37struct hdlc_header {
38 u8 address;
39 u8 control;
40 u16 protocol;
41}__attribute__ ((packed));
42
43
44struct cisco_packet {
45 u32 type; /* code */
46 u32 par1;
47 u32 par2;
48 u16 rel; /* reliability */
49 u32 time;
50}__attribute__ ((packed));
51#define CISCO_PACKET_LEN 18
52#define CISCO_BIG_PACKET_LEN 20
53
54
55struct cisco_state {
56 cisco_proto settings;
57
58 struct timer_list timer;
59 unsigned long last_poll;
60 int up;
61 int request_sent;
62 u32 txseq; /* TX sequence number */
63 u32 rxseq; /* RX sequence number */
64};
65
66
67static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr);
68
69
70static inline struct cisco_state * state(hdlc_device *hdlc)
71{
72 return(struct cisco_state *)(hdlc->state);
73}
74
75
37static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev, 76static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev,
38 u16 type, void *daddr, void *saddr, 77 u16 type, void *daddr, void *saddr,
39 unsigned int len) 78 unsigned int len)
40{ 79{
41 hdlc_header *data; 80 struct hdlc_header *data;
42#ifdef DEBUG_HARD_HEADER 81#ifdef DEBUG_HARD_HEADER
43 printk(KERN_DEBUG "%s: cisco_hard_header called\n", dev->name); 82 printk(KERN_DEBUG "%s: cisco_hard_header called\n", dev->name);
44#endif 83#endif
45 84
46 skb_push(skb, sizeof(hdlc_header)); 85 skb_push(skb, sizeof(struct hdlc_header));
47 data = (hdlc_header*)skb->data; 86 data = (struct hdlc_header*)skb->data;
48 if (type == CISCO_KEEPALIVE) 87 if (type == CISCO_KEEPALIVE)
49 data->address = CISCO_MULTICAST; 88 data->address = CISCO_MULTICAST;
50 else 89 else
@@ -52,7 +91,7 @@ static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev,
52 data->control = 0; 91 data->control = 0;
53 data->protocol = htons(type); 92 data->protocol = htons(type);
54 93
55 return sizeof(hdlc_header); 94 return sizeof(struct hdlc_header);
56} 95}
57 96
58 97
@@ -61,9 +100,10 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
61 u32 par1, u32 par2) 100 u32 par1, u32 par2)
62{ 101{
63 struct sk_buff *skb; 102 struct sk_buff *skb;
64 cisco_packet *data; 103 struct cisco_packet *data;
65 104
66 skb = dev_alloc_skb(sizeof(hdlc_header) + sizeof(cisco_packet)); 105 skb = dev_alloc_skb(sizeof(struct hdlc_header) +
106 sizeof(struct cisco_packet));
67 if (!skb) { 107 if (!skb) {
68 printk(KERN_WARNING 108 printk(KERN_WARNING
69 "%s: Memory squeeze on cisco_keepalive_send()\n", 109 "%s: Memory squeeze on cisco_keepalive_send()\n",
@@ -72,7 +112,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
72 } 112 }
73 skb_reserve(skb, 4); 113 skb_reserve(skb, 4);
74 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0); 114 cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0);
75 data = (cisco_packet*)(skb->data + 4); 115 data = (struct cisco_packet*)(skb->data + 4);
76 116
77 data->type = htonl(type); 117 data->type = htonl(type);
78 data->par1 = htonl(par1); 118 data->par1 = htonl(par1);
@@ -81,7 +121,7 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
81 /* we will need do_div here if 1000 % HZ != 0 */ 121 /* we will need do_div here if 1000 % HZ != 0 */
82 data->time = htonl((jiffies - INITIAL_JIFFIES) * (1000 / HZ)); 122 data->time = htonl((jiffies - INITIAL_JIFFIES) * (1000 / HZ));
83 123
84 skb_put(skb, sizeof(cisco_packet)); 124 skb_put(skb, sizeof(struct cisco_packet));
85 skb->priority = TC_PRIO_CONTROL; 125 skb->priority = TC_PRIO_CONTROL;
86 skb->dev = dev; 126 skb->dev = dev;
87 skb->nh.raw = skb->data; 127 skb->nh.raw = skb->data;
@@ -93,9 +133,9 @@ static void cisco_keepalive_send(struct net_device *dev, u32 type,
93 133
94static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev) 134static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
95{ 135{
96 hdlc_header *data = (hdlc_header*)skb->data; 136 struct hdlc_header *data = (struct hdlc_header*)skb->data;
97 137
98 if (skb->len < sizeof(hdlc_header)) 138 if (skb->len < sizeof(struct hdlc_header))
99 return __constant_htons(ETH_P_HDLC); 139 return __constant_htons(ETH_P_HDLC);
100 140
101 if (data->address != CISCO_MULTICAST && 141 if (data->address != CISCO_MULTICAST &&
@@ -106,7 +146,7 @@ static __be16 cisco_type_trans(struct sk_buff *skb, struct net_device *dev)
106 case __constant_htons(ETH_P_IP): 146 case __constant_htons(ETH_P_IP):
107 case __constant_htons(ETH_P_IPX): 147 case __constant_htons(ETH_P_IPX):
108 case __constant_htons(ETH_P_IPV6): 148 case __constant_htons(ETH_P_IPV6):
109 skb_pull(skb, sizeof(hdlc_header)); 149 skb_pull(skb, sizeof(struct hdlc_header));
110 return data->protocol; 150 return data->protocol;
111 default: 151 default:
112 return __constant_htons(ETH_P_HDLC); 152 return __constant_htons(ETH_P_HDLC);
@@ -118,12 +158,12 @@ static int cisco_rx(struct sk_buff *skb)
118{ 158{
119 struct net_device *dev = skb->dev; 159 struct net_device *dev = skb->dev;
120 hdlc_device *hdlc = dev_to_hdlc(dev); 160 hdlc_device *hdlc = dev_to_hdlc(dev);
121 hdlc_header *data = (hdlc_header*)skb->data; 161 struct hdlc_header *data = (struct hdlc_header*)skb->data;
122 cisco_packet *cisco_data; 162 struct cisco_packet *cisco_data;
123 struct in_device *in_dev; 163 struct in_device *in_dev;
124 u32 addr, mask; 164 u32 addr, mask;
125 165
126 if (skb->len < sizeof(hdlc_header)) 166 if (skb->len < sizeof(struct hdlc_header))
127 goto rx_error; 167 goto rx_error;
128 168
129 if (data->address != CISCO_MULTICAST && 169 if (data->address != CISCO_MULTICAST &&
@@ -137,15 +177,17 @@ static int cisco_rx(struct sk_buff *skb)
137 return NET_RX_SUCCESS; 177 return NET_RX_SUCCESS;
138 178
139 case CISCO_KEEPALIVE: 179 case CISCO_KEEPALIVE:
140 if (skb->len != sizeof(hdlc_header) + CISCO_PACKET_LEN && 180 if ((skb->len != sizeof(struct hdlc_header) +
141 skb->len != sizeof(hdlc_header) + CISCO_BIG_PACKET_LEN) { 181 CISCO_PACKET_LEN) &&
142 printk(KERN_INFO "%s: Invalid length of Cisco " 182 (skb->len != sizeof(struct hdlc_header) +
143 "control packet (%d bytes)\n", 183 CISCO_BIG_PACKET_LEN)) {
144 dev->name, skb->len); 184 printk(KERN_INFO "%s: Invalid length of Cisco control"
185 " packet (%d bytes)\n", dev->name, skb->len);
145 goto rx_error; 186 goto rx_error;
146 } 187 }
147 188
148 cisco_data = (cisco_packet*)(skb->data + sizeof(hdlc_header)); 189 cisco_data = (struct cisco_packet*)(skb->data + sizeof
190 (struct hdlc_header));
149 191
150 switch(ntohl (cisco_data->type)) { 192 switch(ntohl (cisco_data->type)) {
151 case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */ 193 case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */
@@ -178,11 +220,11 @@ static int cisco_rx(struct sk_buff *skb)
178 goto rx_error; 220 goto rx_error;
179 221
180 case CISCO_KEEPALIVE_REQ: 222 case CISCO_KEEPALIVE_REQ:
181 hdlc->state.cisco.rxseq = ntohl(cisco_data->par1); 223 state(hdlc)->rxseq = ntohl(cisco_data->par1);
182 if (hdlc->state.cisco.request_sent && 224 if (state(hdlc)->request_sent &&
183 ntohl(cisco_data->par2)==hdlc->state.cisco.txseq) { 225 ntohl(cisco_data->par2) == state(hdlc)->txseq) {
184 hdlc->state.cisco.last_poll = jiffies; 226 state(hdlc)->last_poll = jiffies;
185 if (!hdlc->state.cisco.up) { 227 if (!state(hdlc)->up) {
186 u32 sec, min, hrs, days; 228 u32 sec, min, hrs, days;
187 sec = ntohl(cisco_data->time) / 1000; 229 sec = ntohl(cisco_data->time) / 1000;
188 min = sec / 60; sec -= min * 60; 230 min = sec / 60; sec -= min * 60;
@@ -193,7 +235,7 @@ static int cisco_rx(struct sk_buff *skb)
193 dev->name, days, hrs, 235 dev->name, days, hrs,
194 min, sec); 236 min, sec);
195 netif_dormant_off(dev); 237 netif_dormant_off(dev);
196 hdlc->state.cisco.up = 1; 238 state(hdlc)->up = 1;
197 } 239 }
198 } 240 }
199 241
@@ -208,7 +250,7 @@ static int cisco_rx(struct sk_buff *skb)
208 return NET_RX_DROP; 250 return NET_RX_DROP;
209 251
210 rx_error: 252 rx_error:
211 hdlc->stats.rx_errors++; /* Mark error */ 253 dev_to_desc(dev)->stats.rx_errors++; /* Mark error */
212 dev_kfree_skb_any(skb); 254 dev_kfree_skb_any(skb);
213 return NET_RX_DROP; 255 return NET_RX_DROP;
214} 256}
@@ -220,23 +262,22 @@ static void cisco_timer(unsigned long arg)
220 struct net_device *dev = (struct net_device *)arg; 262 struct net_device *dev = (struct net_device *)arg;
221 hdlc_device *hdlc = dev_to_hdlc(dev); 263 hdlc_device *hdlc = dev_to_hdlc(dev);
222 264
223 if (hdlc->state.cisco.up && 265 if (state(hdlc)->up &&
224 time_after(jiffies, hdlc->state.cisco.last_poll + 266 time_after(jiffies, state(hdlc)->last_poll +
225 hdlc->state.cisco.settings.timeout * HZ)) { 267 state(hdlc)->settings.timeout * HZ)) {
226 hdlc->state.cisco.up = 0; 268 state(hdlc)->up = 0;
227 printk(KERN_INFO "%s: Link down\n", dev->name); 269 printk(KERN_INFO "%s: Link down\n", dev->name);
228 netif_dormant_on(dev); 270 netif_dormant_on(dev);
229 } 271 }
230 272
231 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, 273 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, ++state(hdlc)->txseq,
232 ++hdlc->state.cisco.txseq, 274 state(hdlc)->rxseq);
233 hdlc->state.cisco.rxseq); 275 state(hdlc)->request_sent = 1;
234 hdlc->state.cisco.request_sent = 1; 276 state(hdlc)->timer.expires = jiffies +
235 hdlc->state.cisco.timer.expires = jiffies + 277 state(hdlc)->settings.interval * HZ;
236 hdlc->state.cisco.settings.interval * HZ; 278 state(hdlc)->timer.function = cisco_timer;
237 hdlc->state.cisco.timer.function = cisco_timer; 279 state(hdlc)->timer.data = arg;
238 hdlc->state.cisco.timer.data = arg; 280 add_timer(&state(hdlc)->timer);
239 add_timer(&hdlc->state.cisco.timer);
240} 281}
241 282
242 283
@@ -244,15 +285,15 @@ static void cisco_timer(unsigned long arg)
244static void cisco_start(struct net_device *dev) 285static void cisco_start(struct net_device *dev)
245{ 286{
246 hdlc_device *hdlc = dev_to_hdlc(dev); 287 hdlc_device *hdlc = dev_to_hdlc(dev);
247 hdlc->state.cisco.up = 0; 288 state(hdlc)->up = 0;
248 hdlc->state.cisco.request_sent = 0; 289 state(hdlc)->request_sent = 0;
249 hdlc->state.cisco.txseq = hdlc->state.cisco.rxseq = 0; 290 state(hdlc)->txseq = state(hdlc)->rxseq = 0;
250 291
251 init_timer(&hdlc->state.cisco.timer); 292 init_timer(&state(hdlc)->timer);
252 hdlc->state.cisco.timer.expires = jiffies + HZ; /*First poll after 1s*/ 293 state(hdlc)->timer.expires = jiffies + HZ; /*First poll after 1s*/
253 hdlc->state.cisco.timer.function = cisco_timer; 294 state(hdlc)->timer.function = cisco_timer;
254 hdlc->state.cisco.timer.data = (unsigned long)dev; 295 state(hdlc)->timer.data = (unsigned long)dev;
255 add_timer(&hdlc->state.cisco.timer); 296 add_timer(&state(hdlc)->timer);
256} 297}
257 298
258 299
@@ -260,15 +301,24 @@ static void cisco_start(struct net_device *dev)
260static void cisco_stop(struct net_device *dev) 301static void cisco_stop(struct net_device *dev)
261{ 302{
262 hdlc_device *hdlc = dev_to_hdlc(dev); 303 hdlc_device *hdlc = dev_to_hdlc(dev);
263 del_timer_sync(&hdlc->state.cisco.timer); 304 del_timer_sync(&state(hdlc)->timer);
264 netif_dormant_on(dev); 305 netif_dormant_on(dev);
265 hdlc->state.cisco.up = 0; 306 state(hdlc)->up = 0;
266 hdlc->state.cisco.request_sent = 0; 307 state(hdlc)->request_sent = 0;
267} 308}
268 309
269 310
270 311
271int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr) 312static struct hdlc_proto proto = {
313 .start = cisco_start,
314 .stop = cisco_stop,
315 .type_trans = cisco_type_trans,
316 .ioctl = cisco_ioctl,
317 .module = THIS_MODULE,
318};
319
320
321static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
272{ 322{
273 cisco_proto __user *cisco_s = ifr->ifr_settings.ifs_ifsu.cisco; 323 cisco_proto __user *cisco_s = ifr->ifr_settings.ifs_ifsu.cisco;
274 const size_t size = sizeof(cisco_proto); 324 const size_t size = sizeof(cisco_proto);
@@ -278,12 +328,14 @@ int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
278 328
279 switch (ifr->ifr_settings.type) { 329 switch (ifr->ifr_settings.type) {
280 case IF_GET_PROTO: 330 case IF_GET_PROTO:
331 if (dev_to_hdlc(dev)->proto != &proto)
332 return -EINVAL;
281 ifr->ifr_settings.type = IF_PROTO_CISCO; 333 ifr->ifr_settings.type = IF_PROTO_CISCO;
282 if (ifr->ifr_settings.size < size) { 334 if (ifr->ifr_settings.size < size) {
283 ifr->ifr_settings.size = size; /* data size wanted */ 335 ifr->ifr_settings.size = size; /* data size wanted */
284 return -ENOBUFS; 336 return -ENOBUFS;
285 } 337 }
286 if (copy_to_user(cisco_s, &hdlc->state.cisco.settings, size)) 338 if (copy_to_user(cisco_s, &state(hdlc)->settings, size))
287 return -EFAULT; 339 return -EFAULT;
288 return 0; 340 return 0;
289 341
@@ -302,19 +354,15 @@ int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
302 return -EINVAL; 354 return -EINVAL;
303 355
304 result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); 356 result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT);
305
306 if (result) 357 if (result)
307 return result; 358 return result;
308 359
309 hdlc_proto_detach(hdlc); 360 result = attach_hdlc_protocol(dev, &proto, cisco_rx,
310 memcpy(&hdlc->state.cisco.settings, &new_settings, size); 361 sizeof(struct cisco_state));
311 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 362 if (result)
363 return result;
312 364
313 hdlc->proto.start = cisco_start; 365 memcpy(&state(hdlc)->settings, &new_settings, size);
314 hdlc->proto.stop = cisco_stop;
315 hdlc->proto.netif_rx = cisco_rx;
316 hdlc->proto.type_trans = cisco_type_trans;
317 hdlc->proto.id = IF_PROTO_CISCO;
318 dev->hard_start_xmit = hdlc->xmit; 366 dev->hard_start_xmit = hdlc->xmit;
319 dev->hard_header = cisco_hard_header; 367 dev->hard_header = cisco_hard_header;
320 dev->hard_header_cache = NULL; 368 dev->hard_header_cache = NULL;
@@ -327,3 +375,25 @@ int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr)
327 375
328 return -EINVAL; 376 return -EINVAL;
329} 377}
378
379
380static int __init mod_init(void)
381{
382 register_hdlc_protocol(&proto);
383 return 0;
384}
385
386
387
388static void __exit mod_exit(void)
389{
390 unregister_hdlc_protocol(&proto);
391}
392
393
394module_init(mod_init);
395module_exit(mod_exit);
396
397MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
398MODULE_DESCRIPTION("Cisco HDLC protocol support for generic HDLC");
399MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7bb737bbdeb9..b45ab680d2d6 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * Frame Relay support 3 * Frame Relay support
4 * 4 *
5 * Copyright (C) 1999 - 2005 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -52,6 +52,8 @@
52#undef DEBUG_PKT 52#undef DEBUG_PKT
53#undef DEBUG_ECN 53#undef DEBUG_ECN
54#undef DEBUG_LINK 54#undef DEBUG_LINK
55#undef DEBUG_PROTO
56#undef DEBUG_PVC
55 57
56#define FR_UI 0x03 58#define FR_UI 0x03
57#define FR_PAD 0x00 59#define FR_PAD 0x00
@@ -115,13 +117,53 @@ typedef struct {
115}__attribute__ ((packed)) fr_hdr; 117}__attribute__ ((packed)) fr_hdr;
116 118
117 119
120typedef struct pvc_device_struct {
121 struct net_device *frad;
122 struct net_device *main;
123 struct net_device *ether; /* bridged Ethernet interface */
124 struct pvc_device_struct *next; /* Sorted in ascending DLCI order */
125 int dlci;
126 int open_count;
127
128 struct {
129 unsigned int new: 1;
130 unsigned int active: 1;
131 unsigned int exist: 1;
132 unsigned int deleted: 1;
133 unsigned int fecn: 1;
134 unsigned int becn: 1;
135 unsigned int bandwidth; /* Cisco LMI reporting only */
136 }state;
137}pvc_device;
138
139
140struct frad_state {
141 fr_proto settings;
142 pvc_device *first_pvc;
143 int dce_pvc_count;
144
145 struct timer_list timer;
146 unsigned long last_poll;
147 int reliable;
148 int dce_changed;
149 int request;
150 int fullrep_sent;
151 u32 last_errors; /* last errors bit list */
152 u8 n391cnt;
153 u8 txseq; /* TX sequence number */
154 u8 rxseq; /* RX sequence number */
155};
156
157
158static int fr_ioctl(struct net_device *dev, struct ifreq *ifr);
159
160
118static inline u16 q922_to_dlci(u8 *hdr) 161static inline u16 q922_to_dlci(u8 *hdr)
119{ 162{
120 return ((hdr[0] & 0xFC) << 2) | ((hdr[1] & 0xF0) >> 4); 163 return ((hdr[0] & 0xFC) << 2) | ((hdr[1] & 0xF0) >> 4);
121} 164}
122 165
123 166
124
125static inline void dlci_to_q922(u8 *hdr, u16 dlci) 167static inline void dlci_to_q922(u8 *hdr, u16 dlci)
126{ 168{
127 hdr[0] = (dlci >> 2) & 0xFC; 169 hdr[0] = (dlci >> 2) & 0xFC;
@@ -129,10 +171,21 @@ static inline void dlci_to_q922(u8 *hdr, u16 dlci)
129} 171}
130 172
131 173
174static inline struct frad_state * state(hdlc_device *hdlc)
175{
176 return(struct frad_state *)(hdlc->state);
177}
178
179
180static __inline__ pvc_device* dev_to_pvc(struct net_device *dev)
181{
182 return dev->priv;
183}
184
132 185
133static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci) 186static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
134{ 187{
135 pvc_device *pvc = hdlc->state.fr.first_pvc; 188 pvc_device *pvc = state(hdlc)->first_pvc;
136 189
137 while (pvc) { 190 while (pvc) {
138 if (pvc->dlci == dlci) 191 if (pvc->dlci == dlci)
@@ -146,10 +199,10 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
146} 199}
147 200
148 201
149static inline pvc_device* add_pvc(struct net_device *dev, u16 dlci) 202static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
150{ 203{
151 hdlc_device *hdlc = dev_to_hdlc(dev); 204 hdlc_device *hdlc = dev_to_hdlc(dev);
152 pvc_device *pvc, **pvc_p = &hdlc->state.fr.first_pvc; 205 pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
153 206
154 while (*pvc_p) { 207 while (*pvc_p) {
155 if ((*pvc_p)->dlci == dlci) 208 if ((*pvc_p)->dlci == dlci)
@@ -160,12 +213,15 @@ static inline pvc_device* add_pvc(struct net_device *dev, u16 dlci)
160 } 213 }
161 214
162 pvc = kmalloc(sizeof(pvc_device), GFP_ATOMIC); 215 pvc = kmalloc(sizeof(pvc_device), GFP_ATOMIC);
216#ifdef DEBUG_PVC
217 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev);
218#endif
163 if (!pvc) 219 if (!pvc)
164 return NULL; 220 return NULL;
165 221
166 memset(pvc, 0, sizeof(pvc_device)); 222 memset(pvc, 0, sizeof(pvc_device));
167 pvc->dlci = dlci; 223 pvc->dlci = dlci;
168 pvc->master = dev; 224 pvc->frad = dev;
169 pvc->next = *pvc_p; /* Put it in the chain */ 225 pvc->next = *pvc_p; /* Put it in the chain */
170 *pvc_p = pvc; 226 *pvc_p = pvc;
171 return pvc; 227 return pvc;
@@ -174,7 +230,7 @@ static inline pvc_device* add_pvc(struct net_device *dev, u16 dlci)
174 230
175static inline int pvc_is_used(pvc_device *pvc) 231static inline int pvc_is_used(pvc_device *pvc)
176{ 232{
177 return pvc->main != NULL || pvc->ether != NULL; 233 return pvc->main || pvc->ether;
178} 234}
179 235
180 236
@@ -200,11 +256,14 @@ static inline void pvc_carrier(int on, pvc_device *pvc)
200 256
201static inline void delete_unused_pvcs(hdlc_device *hdlc) 257static inline void delete_unused_pvcs(hdlc_device *hdlc)
202{ 258{
203 pvc_device **pvc_p = &hdlc->state.fr.first_pvc; 259 pvc_device **pvc_p = &state(hdlc)->first_pvc;
204 260
205 while (*pvc_p) { 261 while (*pvc_p) {
206 if (!pvc_is_used(*pvc_p)) { 262 if (!pvc_is_used(*pvc_p)) {
207 pvc_device *pvc = *pvc_p; 263 pvc_device *pvc = *pvc_p;
264#ifdef DEBUG_PVC
265 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc);
266#endif
208 *pvc_p = pvc->next; 267 *pvc_p = pvc->next;
209 kfree(pvc); 268 kfree(pvc);
210 continue; 269 continue;
@@ -295,16 +354,16 @@ static int pvc_open(struct net_device *dev)
295{ 354{
296 pvc_device *pvc = dev_to_pvc(dev); 355 pvc_device *pvc = dev_to_pvc(dev);
297 356
298 if ((pvc->master->flags & IFF_UP) == 0) 357 if ((pvc->frad->flags & IFF_UP) == 0)
299 return -EIO; /* Master must be UP in order to activate PVC */ 358 return -EIO; /* Frad must be UP in order to activate PVC */
300 359
301 if (pvc->open_count++ == 0) { 360 if (pvc->open_count++ == 0) {
302 hdlc_device *hdlc = dev_to_hdlc(pvc->master); 361 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
303 if (hdlc->state.fr.settings.lmi == LMI_NONE) 362 if (state(hdlc)->settings.lmi == LMI_NONE)
304 pvc->state.active = netif_carrier_ok(pvc->master); 363 pvc->state.active = netif_carrier_ok(pvc->frad);
305 364
306 pvc_carrier(pvc->state.active, pvc); 365 pvc_carrier(pvc->state.active, pvc);
307 hdlc->state.fr.dce_changed = 1; 366 state(hdlc)->dce_changed = 1;
308 } 367 }
309 return 0; 368 return 0;
310} 369}
@@ -316,12 +375,12 @@ static int pvc_close(struct net_device *dev)
316 pvc_device *pvc = dev_to_pvc(dev); 375 pvc_device *pvc = dev_to_pvc(dev);
317 376
318 if (--pvc->open_count == 0) { 377 if (--pvc->open_count == 0) {
319 hdlc_device *hdlc = dev_to_hdlc(pvc->master); 378 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
320 if (hdlc->state.fr.settings.lmi == LMI_NONE) 379 if (state(hdlc)->settings.lmi == LMI_NONE)
321 pvc->state.active = 0; 380 pvc->state.active = 0;
322 381
323 if (hdlc->state.fr.settings.dce) { 382 if (state(hdlc)->settings.dce) {
324 hdlc->state.fr.dce_changed = 1; 383 state(hdlc)->dce_changed = 1;
325 pvc->state.active = 0; 384 pvc->state.active = 0;
326 } 385 }
327 } 386 }
@@ -348,7 +407,7 @@ static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
348 } 407 }
349 408
350 info.dlci = pvc->dlci; 409 info.dlci = pvc->dlci;
351 memcpy(info.master, pvc->master->name, IFNAMSIZ); 410 memcpy(info.master, pvc->frad->name, IFNAMSIZ);
352 if (copy_to_user(ifr->ifr_settings.ifs_ifsu.fr_pvc_info, 411 if (copy_to_user(ifr->ifr_settings.ifs_ifsu.fr_pvc_info,
353 &info, sizeof(info))) 412 &info, sizeof(info)))
354 return -EFAULT; 413 return -EFAULT;
@@ -361,7 +420,7 @@ static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
361 420
362static inline struct net_device_stats *pvc_get_stats(struct net_device *dev) 421static inline struct net_device_stats *pvc_get_stats(struct net_device *dev)
363{ 422{
364 return netdev_priv(dev); 423 return &dev_to_desc(dev)->stats;
365} 424}
366 425
367 426
@@ -393,7 +452,7 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev)
393 stats->tx_packets++; 452 stats->tx_packets++;
394 if (pvc->state.fecn) /* TX Congestion counter */ 453 if (pvc->state.fecn) /* TX Congestion counter */
395 stats->tx_compressed++; 454 stats->tx_compressed++;
396 skb->dev = pvc->master; 455 skb->dev = pvc->frad;
397 dev_queue_xmit(skb); 456 dev_queue_xmit(skb);
398 return 0; 457 return 0;
399 } 458 }
@@ -419,7 +478,7 @@ static int pvc_change_mtu(struct net_device *dev, int new_mtu)
419static inline void fr_log_dlci_active(pvc_device *pvc) 478static inline void fr_log_dlci_active(pvc_device *pvc)
420{ 479{
421 printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n", 480 printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n",
422 pvc->master->name, 481 pvc->frad->name,
423 pvc->dlci, 482 pvc->dlci,
424 pvc->main ? pvc->main->name : "", 483 pvc->main ? pvc->main->name : "",
425 pvc->main && pvc->ether ? " " : "", 484 pvc->main && pvc->ether ? " " : "",
@@ -438,21 +497,20 @@ static inline u8 fr_lmi_nextseq(u8 x)
438} 497}
439 498
440 499
441
442static void fr_lmi_send(struct net_device *dev, int fullrep) 500static void fr_lmi_send(struct net_device *dev, int fullrep)
443{ 501{
444 hdlc_device *hdlc = dev_to_hdlc(dev); 502 hdlc_device *hdlc = dev_to_hdlc(dev);
445 struct sk_buff *skb; 503 struct sk_buff *skb;
446 pvc_device *pvc = hdlc->state.fr.first_pvc; 504 pvc_device *pvc = state(hdlc)->first_pvc;
447 int lmi = hdlc->state.fr.settings.lmi; 505 int lmi = state(hdlc)->settings.lmi;
448 int dce = hdlc->state.fr.settings.dce; 506 int dce = state(hdlc)->settings.dce;
449 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH; 507 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH;
450 int stat_len = (lmi == LMI_CISCO) ? 6 : 3; 508 int stat_len = (lmi == LMI_CISCO) ? 6 : 3;
451 u8 *data; 509 u8 *data;
452 int i = 0; 510 int i = 0;
453 511
454 if (dce && fullrep) { 512 if (dce && fullrep) {
455 len += hdlc->state.fr.dce_pvc_count * (2 + stat_len); 513 len += state(hdlc)->dce_pvc_count * (2 + stat_len);
456 if (len > HDLC_MAX_MRU) { 514 if (len > HDLC_MAX_MRU) {
457 printk(KERN_WARNING "%s: Too many PVCs while sending " 515 printk(KERN_WARNING "%s: Too many PVCs while sending "
458 "LMI full report\n", dev->name); 516 "LMI full report\n", dev->name);
@@ -486,8 +544,9 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
486 data[i++] = fullrep ? LMI_FULLREP : LMI_INTEGRITY; 544 data[i++] = fullrep ? LMI_FULLREP : LMI_INTEGRITY;
487 data[i++] = lmi == LMI_CCITT ? LMI_CCITT_ALIVE : LMI_ANSI_CISCO_ALIVE; 545 data[i++] = lmi == LMI_CCITT ? LMI_CCITT_ALIVE : LMI_ANSI_CISCO_ALIVE;
488 data[i++] = LMI_INTEG_LEN; 546 data[i++] = LMI_INTEG_LEN;
489 data[i++] = hdlc->state.fr.txseq =fr_lmi_nextseq(hdlc->state.fr.txseq); 547 data[i++] = state(hdlc)->txseq =
490 data[i++] = hdlc->state.fr.rxseq; 548 fr_lmi_nextseq(state(hdlc)->txseq);
549 data[i++] = state(hdlc)->rxseq;
491 550
492 if (dce && fullrep) { 551 if (dce && fullrep) {
493 while (pvc) { 552 while (pvc) {
@@ -496,7 +555,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
496 data[i++] = stat_len; 555 data[i++] = stat_len;
497 556
498 /* LMI start/restart */ 557 /* LMI start/restart */
499 if (hdlc->state.fr.reliable && !pvc->state.exist) { 558 if (state(hdlc)->reliable && !pvc->state.exist) {
500 pvc->state.exist = pvc->state.new = 1; 559 pvc->state.exist = pvc->state.new = 1;
501 fr_log_dlci_active(pvc); 560 fr_log_dlci_active(pvc);
502 } 561 }
@@ -541,15 +600,15 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
541static void fr_set_link_state(int reliable, struct net_device *dev) 600static void fr_set_link_state(int reliable, struct net_device *dev)
542{ 601{
543 hdlc_device *hdlc = dev_to_hdlc(dev); 602 hdlc_device *hdlc = dev_to_hdlc(dev);
544 pvc_device *pvc = hdlc->state.fr.first_pvc; 603 pvc_device *pvc = state(hdlc)->first_pvc;
545 604
546 hdlc->state.fr.reliable = reliable; 605 state(hdlc)->reliable = reliable;
547 if (reliable) { 606 if (reliable) {
548 netif_dormant_off(dev); 607 netif_dormant_off(dev);
549 hdlc->state.fr.n391cnt = 0; /* Request full status */ 608 state(hdlc)->n391cnt = 0; /* Request full status */
550 hdlc->state.fr.dce_changed = 1; 609 state(hdlc)->dce_changed = 1;
551 610
552 if (hdlc->state.fr.settings.lmi == LMI_NONE) { 611 if (state(hdlc)->settings.lmi == LMI_NONE) {
553 while (pvc) { /* Activate all PVCs */ 612 while (pvc) { /* Activate all PVCs */
554 pvc_carrier(1, pvc); 613 pvc_carrier(1, pvc);
555 pvc->state.exist = pvc->state.active = 1; 614 pvc->state.exist = pvc->state.active = 1;
@@ -563,7 +622,7 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
563 pvc_carrier(0, pvc); 622 pvc_carrier(0, pvc);
564 pvc->state.exist = pvc->state.active = 0; 623 pvc->state.exist = pvc->state.active = 0;
565 pvc->state.new = 0; 624 pvc->state.new = 0;
566 if (!hdlc->state.fr.settings.dce) 625 if (!state(hdlc)->settings.dce)
567 pvc->state.bandwidth = 0; 626 pvc->state.bandwidth = 0;
568 pvc = pvc->next; 627 pvc = pvc->next;
569 } 628 }
@@ -571,7 +630,6 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
571} 630}
572 631
573 632
574
575static void fr_timer(unsigned long arg) 633static void fr_timer(unsigned long arg)
576{ 634{
577 struct net_device *dev = (struct net_device *)arg; 635 struct net_device *dev = (struct net_device *)arg;
@@ -579,62 +637,61 @@ static void fr_timer(unsigned long arg)
579 int i, cnt = 0, reliable; 637 int i, cnt = 0, reliable;
580 u32 list; 638 u32 list;
581 639
582 if (hdlc->state.fr.settings.dce) { 640 if (state(hdlc)->settings.dce) {
583 reliable = hdlc->state.fr.request && 641 reliable = state(hdlc)->request &&
584 time_before(jiffies, hdlc->state.fr.last_poll + 642 time_before(jiffies, state(hdlc)->last_poll +
585 hdlc->state.fr.settings.t392 * HZ); 643 state(hdlc)->settings.t392 * HZ);
586 hdlc->state.fr.request = 0; 644 state(hdlc)->request = 0;
587 } else { 645 } else {
588 hdlc->state.fr.last_errors <<= 1; /* Shift the list */ 646 state(hdlc)->last_errors <<= 1; /* Shift the list */
589 if (hdlc->state.fr.request) { 647 if (state(hdlc)->request) {
590 if (hdlc->state.fr.reliable) 648 if (state(hdlc)->reliable)
591 printk(KERN_INFO "%s: No LMI status reply " 649 printk(KERN_INFO "%s: No LMI status reply "
592 "received\n", dev->name); 650 "received\n", dev->name);
593 hdlc->state.fr.last_errors |= 1; 651 state(hdlc)->last_errors |= 1;
594 } 652 }
595 653
596 list = hdlc->state.fr.last_errors; 654 list = state(hdlc)->last_errors;
597 for (i = 0; i < hdlc->state.fr.settings.n393; i++, list >>= 1) 655 for (i = 0; i < state(hdlc)->settings.n393; i++, list >>= 1)
598 cnt += (list & 1); /* errors count */ 656 cnt += (list & 1); /* errors count */
599 657
600 reliable = (cnt < hdlc->state.fr.settings.n392); 658 reliable = (cnt < state(hdlc)->settings.n392);
601 } 659 }
602 660
603 if (hdlc->state.fr.reliable != reliable) { 661 if (state(hdlc)->reliable != reliable) {
604 printk(KERN_INFO "%s: Link %sreliable\n", dev->name, 662 printk(KERN_INFO "%s: Link %sreliable\n", dev->name,
605 reliable ? "" : "un"); 663 reliable ? "" : "un");
606 fr_set_link_state(reliable, dev); 664 fr_set_link_state(reliable, dev);
607 } 665 }
608 666
609 if (hdlc->state.fr.settings.dce) 667 if (state(hdlc)->settings.dce)
610 hdlc->state.fr.timer.expires = jiffies + 668 state(hdlc)->timer.expires = jiffies +
611 hdlc->state.fr.settings.t392 * HZ; 669 state(hdlc)->settings.t392 * HZ;
612 else { 670 else {
613 if (hdlc->state.fr.n391cnt) 671 if (state(hdlc)->n391cnt)
614 hdlc->state.fr.n391cnt--; 672 state(hdlc)->n391cnt--;
615 673
616 fr_lmi_send(dev, hdlc->state.fr.n391cnt == 0); 674 fr_lmi_send(dev, state(hdlc)->n391cnt == 0);
617 675
618 hdlc->state.fr.last_poll = jiffies; 676 state(hdlc)->last_poll = jiffies;
619 hdlc->state.fr.request = 1; 677 state(hdlc)->request = 1;
620 hdlc->state.fr.timer.expires = jiffies + 678 state(hdlc)->timer.expires = jiffies +
621 hdlc->state.fr.settings.t391 * HZ; 679 state(hdlc)->settings.t391 * HZ;
622 } 680 }
623 681
624 hdlc->state.fr.timer.function = fr_timer; 682 state(hdlc)->timer.function = fr_timer;
625 hdlc->state.fr.timer.data = arg; 683 state(hdlc)->timer.data = arg;
626 add_timer(&hdlc->state.fr.timer); 684 add_timer(&state(hdlc)->timer);
627} 685}
628 686
629 687
630
631static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) 688static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
632{ 689{
633 hdlc_device *hdlc = dev_to_hdlc(dev); 690 hdlc_device *hdlc = dev_to_hdlc(dev);
634 pvc_device *pvc; 691 pvc_device *pvc;
635 u8 rxseq, txseq; 692 u8 rxseq, txseq;
636 int lmi = hdlc->state.fr.settings.lmi; 693 int lmi = state(hdlc)->settings.lmi;
637 int dce = hdlc->state.fr.settings.dce; 694 int dce = state(hdlc)->settings.dce;
638 int stat_len = (lmi == LMI_CISCO) ? 6 : 3, reptype, error, no_ram, i; 695 int stat_len = (lmi == LMI_CISCO) ? 6 : 3, reptype, error, no_ram, i;
639 696
640 if (skb->len < (lmi == LMI_ANSI ? LMI_ANSI_LENGTH : 697 if (skb->len < (lmi == LMI_ANSI ? LMI_ANSI_LENGTH :
@@ -645,8 +702,8 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
645 702
646 if (skb->data[3] != (lmi == LMI_CISCO ? NLPID_CISCO_LMI : 703 if (skb->data[3] != (lmi == LMI_CISCO ? NLPID_CISCO_LMI :
647 NLPID_CCITT_ANSI_LMI)) { 704 NLPID_CCITT_ANSI_LMI)) {
648 printk(KERN_INFO "%s: Received non-LMI frame with LMI" 705 printk(KERN_INFO "%s: Received non-LMI frame with LMI DLCI\n",
649 " DLCI\n", dev->name); 706 dev->name);
650 return 1; 707 return 1;
651 } 708 }
652 709
@@ -706,53 +763,53 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
706 } 763 }
707 i++; 764 i++;
708 765
709 hdlc->state.fr.rxseq = skb->data[i++]; /* TX sequence from peer */ 766 state(hdlc)->rxseq = skb->data[i++]; /* TX sequence from peer */
710 rxseq = skb->data[i++]; /* Should confirm our sequence */ 767 rxseq = skb->data[i++]; /* Should confirm our sequence */
711 768
712 txseq = hdlc->state.fr.txseq; 769 txseq = state(hdlc)->txseq;
713 770
714 if (dce) 771 if (dce)
715 hdlc->state.fr.last_poll = jiffies; 772 state(hdlc)->last_poll = jiffies;
716 773
717 error = 0; 774 error = 0;
718 if (!hdlc->state.fr.reliable) 775 if (!state(hdlc)->reliable)
719 error = 1; 776 error = 1;
720 777
721 if (rxseq == 0 || rxseq != txseq) { 778 if (rxseq == 0 || rxseq != txseq) { /* Ask for full report next time */
722 hdlc->state.fr.n391cnt = 0; /* Ask for full report next time */ 779 state(hdlc)->n391cnt = 0;
723 error = 1; 780 error = 1;
724 } 781 }
725 782
726 if (dce) { 783 if (dce) {
727 if (hdlc->state.fr.fullrep_sent && !error) { 784 if (state(hdlc)->fullrep_sent && !error) {
728/* Stop sending full report - the last one has been confirmed by DTE */ 785/* Stop sending full report - the last one has been confirmed by DTE */
729 hdlc->state.fr.fullrep_sent = 0; 786 state(hdlc)->fullrep_sent = 0;
730 pvc = hdlc->state.fr.first_pvc; 787 pvc = state(hdlc)->first_pvc;
731 while (pvc) { 788 while (pvc) {
732 if (pvc->state.new) { 789 if (pvc->state.new) {
733 pvc->state.new = 0; 790 pvc->state.new = 0;
734 791
735/* Tell DTE that new PVC is now active */ 792/* Tell DTE that new PVC is now active */
736 hdlc->state.fr.dce_changed = 1; 793 state(hdlc)->dce_changed = 1;
737 } 794 }
738 pvc = pvc->next; 795 pvc = pvc->next;
739 } 796 }
740 } 797 }
741 798
742 if (hdlc->state.fr.dce_changed) { 799 if (state(hdlc)->dce_changed) {
743 reptype = LMI_FULLREP; 800 reptype = LMI_FULLREP;
744 hdlc->state.fr.fullrep_sent = 1; 801 state(hdlc)->fullrep_sent = 1;
745 hdlc->state.fr.dce_changed = 0; 802 state(hdlc)->dce_changed = 0;
746 } 803 }
747 804
748 hdlc->state.fr.request = 1; /* got request */ 805 state(hdlc)->request = 1; /* got request */
749 fr_lmi_send(dev, reptype == LMI_FULLREP ? 1 : 0); 806 fr_lmi_send(dev, reptype == LMI_FULLREP ? 1 : 0);
750 return 0; 807 return 0;
751 } 808 }
752 809
753 /* DTE */ 810 /* DTE */
754 811
755 hdlc->state.fr.request = 0; /* got response, no request pending */ 812 state(hdlc)->request = 0; /* got response, no request pending */
756 813
757 if (error) 814 if (error)
758 return 0; 815 return 0;
@@ -760,7 +817,7 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
760 if (reptype != LMI_FULLREP) 817 if (reptype != LMI_FULLREP)
761 return 0; 818 return 0;
762 819
763 pvc = hdlc->state.fr.first_pvc; 820 pvc = state(hdlc)->first_pvc;
764 821
765 while (pvc) { 822 while (pvc) {
766 pvc->state.deleted = 1; 823 pvc->state.deleted = 1;
@@ -827,7 +884,7 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
827 i += stat_len; 884 i += stat_len;
828 } 885 }
829 886
830 pvc = hdlc->state.fr.first_pvc; 887 pvc = state(hdlc)->first_pvc;
831 888
832 while (pvc) { 889 while (pvc) {
833 if (pvc->state.deleted && pvc->state.exist) { 890 if (pvc->state.deleted && pvc->state.exist) {
@@ -841,17 +898,16 @@ static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
841 } 898 }
842 899
843 /* Next full report after N391 polls */ 900 /* Next full report after N391 polls */
844 hdlc->state.fr.n391cnt = hdlc->state.fr.settings.n391; 901 state(hdlc)->n391cnt = state(hdlc)->settings.n391;
845 902
846 return 0; 903 return 0;
847} 904}
848 905
849 906
850
851static int fr_rx(struct sk_buff *skb) 907static int fr_rx(struct sk_buff *skb)
852{ 908{
853 struct net_device *ndev = skb->dev; 909 struct net_device *frad = skb->dev;
854 hdlc_device *hdlc = dev_to_hdlc(ndev); 910 hdlc_device *hdlc = dev_to_hdlc(frad);
855 fr_hdr *fh = (fr_hdr*)skb->data; 911 fr_hdr *fh = (fr_hdr*)skb->data;
856 u8 *data = skb->data; 912 u8 *data = skb->data;
857 u16 dlci; 913 u16 dlci;
@@ -864,11 +920,11 @@ static int fr_rx(struct sk_buff *skb)
864 dlci = q922_to_dlci(skb->data); 920 dlci = q922_to_dlci(skb->data);
865 921
866 if ((dlci == LMI_CCITT_ANSI_DLCI && 922 if ((dlci == LMI_CCITT_ANSI_DLCI &&
867 (hdlc->state.fr.settings.lmi == LMI_ANSI || 923 (state(hdlc)->settings.lmi == LMI_ANSI ||
868 hdlc->state.fr.settings.lmi == LMI_CCITT)) || 924 state(hdlc)->settings.lmi == LMI_CCITT)) ||
869 (dlci == LMI_CISCO_DLCI && 925 (dlci == LMI_CISCO_DLCI &&
870 hdlc->state.fr.settings.lmi == LMI_CISCO)) { 926 state(hdlc)->settings.lmi == LMI_CISCO)) {
871 if (fr_lmi_recv(ndev, skb)) 927 if (fr_lmi_recv(frad, skb))
872 goto rx_error; 928 goto rx_error;
873 dev_kfree_skb_any(skb); 929 dev_kfree_skb_any(skb);
874 return NET_RX_SUCCESS; 930 return NET_RX_SUCCESS;
@@ -878,7 +934,7 @@ static int fr_rx(struct sk_buff *skb)
878 if (!pvc) { 934 if (!pvc) {
879#ifdef DEBUG_PKT 935#ifdef DEBUG_PKT
880 printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n", 936 printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n",
881 ndev->name, dlci); 937 frad->name, dlci);
882#endif 938#endif
883 dev_kfree_skb_any(skb); 939 dev_kfree_skb_any(skb);
884 return NET_RX_DROP; 940 return NET_RX_DROP;
@@ -886,7 +942,7 @@ static int fr_rx(struct sk_buff *skb)
886 942
887 if (pvc->state.fecn != fh->fecn) { 943 if (pvc->state.fecn != fh->fecn) {
888#ifdef DEBUG_ECN 944#ifdef DEBUG_ECN
889 printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", ndev->name, 945 printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", frad->name,
890 dlci, fh->fecn ? "N" : "FF"); 946 dlci, fh->fecn ? "N" : "FF");
891#endif 947#endif
892 pvc->state.fecn ^= 1; 948 pvc->state.fecn ^= 1;
@@ -894,7 +950,7 @@ static int fr_rx(struct sk_buff *skb)
894 950
895 if (pvc->state.becn != fh->becn) { 951 if (pvc->state.becn != fh->becn) {
896#ifdef DEBUG_ECN 952#ifdef DEBUG_ECN
897 printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", ndev->name, 953 printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", frad->name,
898 dlci, fh->becn ? "N" : "FF"); 954 dlci, fh->becn ? "N" : "FF");
899#endif 955#endif
900 pvc->state.becn ^= 1; 956 pvc->state.becn ^= 1;
@@ -902,7 +958,7 @@ static int fr_rx(struct sk_buff *skb)
902 958
903 959
904 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 960 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
905 hdlc->stats.rx_dropped++; 961 dev_to_desc(frad)->stats.rx_dropped++;
906 return NET_RX_DROP; 962 return NET_RX_DROP;
907 } 963 }
908 964
@@ -938,13 +994,13 @@ static int fr_rx(struct sk_buff *skb)
938 994
939 default: 995 default:
940 printk(KERN_INFO "%s: Unsupported protocol, OUI=%x " 996 printk(KERN_INFO "%s: Unsupported protocol, OUI=%x "
941 "PID=%x\n", ndev->name, oui, pid); 997 "PID=%x\n", frad->name, oui, pid);
942 dev_kfree_skb_any(skb); 998 dev_kfree_skb_any(skb);
943 return NET_RX_DROP; 999 return NET_RX_DROP;
944 } 1000 }
945 } else { 1001 } else {
946 printk(KERN_INFO "%s: Unsupported protocol, NLPID=%x " 1002 printk(KERN_INFO "%s: Unsupported protocol, NLPID=%x "
947 "length = %i\n", ndev->name, data[3], skb->len); 1003 "length = %i\n", frad->name, data[3], skb->len);
948 dev_kfree_skb_any(skb); 1004 dev_kfree_skb_any(skb);
949 return NET_RX_DROP; 1005 return NET_RX_DROP;
950 } 1006 }
@@ -964,7 +1020,7 @@ static int fr_rx(struct sk_buff *skb)
964 } 1020 }
965 1021
966 rx_error: 1022 rx_error:
967 hdlc->stats.rx_errors++; /* Mark error */ 1023 dev_to_desc(frad)->stats.rx_errors++; /* Mark error */
968 dev_kfree_skb_any(skb); 1024 dev_kfree_skb_any(skb);
969 return NET_RX_DROP; 1025 return NET_RX_DROP;
970} 1026}
@@ -977,44 +1033,42 @@ static void fr_start(struct net_device *dev)
977#ifdef DEBUG_LINK 1033#ifdef DEBUG_LINK
978 printk(KERN_DEBUG "fr_start\n"); 1034 printk(KERN_DEBUG "fr_start\n");
979#endif 1035#endif
980 if (hdlc->state.fr.settings.lmi != LMI_NONE) { 1036 if (state(hdlc)->settings.lmi != LMI_NONE) {
981 hdlc->state.fr.reliable = 0; 1037 state(hdlc)->reliable = 0;
982 hdlc->state.fr.dce_changed = 1; 1038 state(hdlc)->dce_changed = 1;
983 hdlc->state.fr.request = 0; 1039 state(hdlc)->request = 0;
984 hdlc->state.fr.fullrep_sent = 0; 1040 state(hdlc)->fullrep_sent = 0;
985 hdlc->state.fr.last_errors = 0xFFFFFFFF; 1041 state(hdlc)->last_errors = 0xFFFFFFFF;
986 hdlc->state.fr.n391cnt = 0; 1042 state(hdlc)->n391cnt = 0;
987 hdlc->state.fr.txseq = hdlc->state.fr.rxseq = 0; 1043 state(hdlc)->txseq = state(hdlc)->rxseq = 0;
988 1044
989 init_timer(&hdlc->state.fr.timer); 1045 init_timer(&state(hdlc)->timer);
990 /* First poll after 1 s */ 1046 /* First poll after 1 s */
991 hdlc->state.fr.timer.expires = jiffies + HZ; 1047 state(hdlc)->timer.expires = jiffies + HZ;
992 hdlc->state.fr.timer.function = fr_timer; 1048 state(hdlc)->timer.function = fr_timer;
993 hdlc->state.fr.timer.data = (unsigned long)dev; 1049 state(hdlc)->timer.data = (unsigned long)dev;
994 add_timer(&hdlc->state.fr.timer); 1050 add_timer(&state(hdlc)->timer);
995 } else 1051 } else
996 fr_set_link_state(1, dev); 1052 fr_set_link_state(1, dev);
997} 1053}
998 1054
999 1055
1000
1001static void fr_stop(struct net_device *dev) 1056static void fr_stop(struct net_device *dev)
1002{ 1057{
1003 hdlc_device *hdlc = dev_to_hdlc(dev); 1058 hdlc_device *hdlc = dev_to_hdlc(dev);
1004#ifdef DEBUG_LINK 1059#ifdef DEBUG_LINK
1005 printk(KERN_DEBUG "fr_stop\n"); 1060 printk(KERN_DEBUG "fr_stop\n");
1006#endif 1061#endif
1007 if (hdlc->state.fr.settings.lmi != LMI_NONE) 1062 if (state(hdlc)->settings.lmi != LMI_NONE)
1008 del_timer_sync(&hdlc->state.fr.timer); 1063 del_timer_sync(&state(hdlc)->timer);
1009 fr_set_link_state(0, dev); 1064 fr_set_link_state(0, dev);
1010} 1065}
1011 1066
1012 1067
1013
1014static void fr_close(struct net_device *dev) 1068static void fr_close(struct net_device *dev)
1015{ 1069{
1016 hdlc_device *hdlc = dev_to_hdlc(dev); 1070 hdlc_device *hdlc = dev_to_hdlc(dev);
1017 pvc_device *pvc = hdlc->state.fr.first_pvc; 1071 pvc_device *pvc = state(hdlc)->first_pvc;
1018 1072
1019 while (pvc) { /* Shutdown all PVCs for this FRAD */ 1073 while (pvc) { /* Shutdown all PVCs for this FRAD */
1020 if (pvc->main) 1074 if (pvc->main)
@@ -1025,7 +1079,8 @@ static void fr_close(struct net_device *dev)
1025 } 1079 }
1026} 1080}
1027 1081
1028static void dlci_setup(struct net_device *dev) 1082
1083static void pvc_setup(struct net_device *dev)
1029{ 1084{
1030 dev->type = ARPHRD_DLCI; 1085 dev->type = ARPHRD_DLCI;
1031 dev->flags = IFF_POINTOPOINT; 1086 dev->flags = IFF_POINTOPOINT;
@@ -1033,9 +1088,9 @@ static void dlci_setup(struct net_device *dev)
1033 dev->addr_len = 2; 1088 dev->addr_len = 2;
1034} 1089}
1035 1090
1036static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type) 1091static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1037{ 1092{
1038 hdlc_device *hdlc = dev_to_hdlc(master); 1093 hdlc_device *hdlc = dev_to_hdlc(frad);
1039 pvc_device *pvc = NULL; 1094 pvc_device *pvc = NULL;
1040 struct net_device *dev; 1095 struct net_device *dev;
1041 int result, used; 1096 int result, used;
@@ -1044,9 +1099,9 @@ static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type)
1044 if (type == ARPHRD_ETHER) 1099 if (type == ARPHRD_ETHER)
1045 prefix = "pvceth%d"; 1100 prefix = "pvceth%d";
1046 1101
1047 if ((pvc = add_pvc(master, dlci)) == NULL) { 1102 if ((pvc = add_pvc(frad, dlci)) == NULL) {
1048 printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n", 1103 printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n",
1049 master->name); 1104 frad->name);
1050 return -ENOBUFS; 1105 return -ENOBUFS;
1051 } 1106 }
1052 1107
@@ -1060,11 +1115,11 @@ static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type)
1060 "pvceth%d", ether_setup); 1115 "pvceth%d", ether_setup);
1061 else 1116 else
1062 dev = alloc_netdev(sizeof(struct net_device_stats), 1117 dev = alloc_netdev(sizeof(struct net_device_stats),
1063 "pvc%d", dlci_setup); 1118 "pvc%d", pvc_setup);
1064 1119
1065 if (!dev) { 1120 if (!dev) {
1066 printk(KERN_WARNING "%s: Memory squeeze on fr_pvc()\n", 1121 printk(KERN_WARNING "%s: Memory squeeze on fr_pvc()\n",
1067 master->name); 1122 frad->name);
1068 delete_unused_pvcs(hdlc); 1123 delete_unused_pvcs(hdlc);
1069 return -ENOBUFS; 1124 return -ENOBUFS;
1070 } 1125 }
@@ -1102,8 +1157,8 @@ static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type)
1102 dev->destructor = free_netdev; 1157 dev->destructor = free_netdev;
1103 *get_dev_p(pvc, type) = dev; 1158 *get_dev_p(pvc, type) = dev;
1104 if (!used) { 1159 if (!used) {
1105 hdlc->state.fr.dce_changed = 1; 1160 state(hdlc)->dce_changed = 1;
1106 hdlc->state.fr.dce_pvc_count++; 1161 state(hdlc)->dce_pvc_count++;
1107 } 1162 }
1108 return 0; 1163 return 0;
1109} 1164}
@@ -1128,8 +1183,8 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1128 *get_dev_p(pvc, type) = NULL; 1183 *get_dev_p(pvc, type) = NULL;
1129 1184
1130 if (!pvc_is_used(pvc)) { 1185 if (!pvc_is_used(pvc)) {
1131 hdlc->state.fr.dce_pvc_count--; 1186 state(hdlc)->dce_pvc_count--;
1132 hdlc->state.fr.dce_changed = 1; 1187 state(hdlc)->dce_changed = 1;
1133 } 1188 }
1134 delete_unused_pvcs(hdlc); 1189 delete_unused_pvcs(hdlc);
1135 return 0; 1190 return 0;
@@ -1137,14 +1192,13 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1137 1192
1138 1193
1139 1194
1140static void fr_destroy(hdlc_device *hdlc) 1195static void fr_destroy(struct net_device *frad)
1141{ 1196{
1142 pvc_device *pvc; 1197 hdlc_device *hdlc = dev_to_hdlc(frad);
1143 1198 pvc_device *pvc = state(hdlc)->first_pvc;
1144 pvc = hdlc->state.fr.first_pvc; 1199 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */
1145 hdlc->state.fr.first_pvc = NULL; /* All PVCs destroyed */ 1200 state(hdlc)->dce_pvc_count = 0;
1146 hdlc->state.fr.dce_pvc_count = 0; 1201 state(hdlc)->dce_changed = 1;
1147 hdlc->state.fr.dce_changed = 1;
1148 1202
1149 while (pvc) { 1203 while (pvc) {
1150 pvc_device *next = pvc->next; 1204 pvc_device *next = pvc->next;
@@ -1161,8 +1215,17 @@ static void fr_destroy(hdlc_device *hdlc)
1161} 1215}
1162 1216
1163 1217
1218static struct hdlc_proto proto = {
1219 .close = fr_close,
1220 .start = fr_start,
1221 .stop = fr_stop,
1222 .detach = fr_destroy,
1223 .ioctl = fr_ioctl,
1224 .module = THIS_MODULE,
1225};
1226
1164 1227
1165int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr) 1228static int fr_ioctl(struct net_device *dev, struct ifreq *ifr)
1166{ 1229{
1167 fr_proto __user *fr_s = ifr->ifr_settings.ifs_ifsu.fr; 1230 fr_proto __user *fr_s = ifr->ifr_settings.ifs_ifsu.fr;
1168 const size_t size = sizeof(fr_proto); 1231 const size_t size = sizeof(fr_proto);
@@ -1173,12 +1236,14 @@ int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr)
1173 1236
1174 switch (ifr->ifr_settings.type) { 1237 switch (ifr->ifr_settings.type) {
1175 case IF_GET_PROTO: 1238 case IF_GET_PROTO:
1239 if (dev_to_hdlc(dev)->proto != &proto) /* Different proto */
1240 return -EINVAL;
1176 ifr->ifr_settings.type = IF_PROTO_FR; 1241 ifr->ifr_settings.type = IF_PROTO_FR;
1177 if (ifr->ifr_settings.size < size) { 1242 if (ifr->ifr_settings.size < size) {
1178 ifr->ifr_settings.size = size; /* data size wanted */ 1243 ifr->ifr_settings.size = size; /* data size wanted */
1179 return -ENOBUFS; 1244 return -ENOBUFS;
1180 } 1245 }
1181 if (copy_to_user(fr_s, &hdlc->state.fr.settings, size)) 1246 if (copy_to_user(fr_s, &state(hdlc)->settings, size))
1182 return -EFAULT; 1247 return -EFAULT;
1183 return 0; 1248 return 0;
1184 1249
@@ -1213,20 +1278,16 @@ int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr)
1213 if (result) 1278 if (result)
1214 return result; 1279 return result;
1215 1280
1216 if (hdlc->proto.id != IF_PROTO_FR) { 1281 if (dev_to_hdlc(dev)->proto != &proto) { /* Different proto */
1217 hdlc_proto_detach(hdlc); 1282 result = attach_hdlc_protocol(dev, &proto, fr_rx,
1218 hdlc->state.fr.first_pvc = NULL; 1283 sizeof(struct frad_state));
1219 hdlc->state.fr.dce_pvc_count = 0; 1284 if (result)
1285 return result;
1286 state(hdlc)->first_pvc = NULL;
1287 state(hdlc)->dce_pvc_count = 0;
1220 } 1288 }
1221 memcpy(&hdlc->state.fr.settings, &new_settings, size); 1289 memcpy(&state(hdlc)->settings, &new_settings, size);
1222 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 1290
1223
1224 hdlc->proto.close = fr_close;
1225 hdlc->proto.start = fr_start;
1226 hdlc->proto.stop = fr_stop;
1227 hdlc->proto.detach = fr_destroy;
1228 hdlc->proto.netif_rx = fr_rx;
1229 hdlc->proto.id = IF_PROTO_FR;
1230 dev->hard_start_xmit = hdlc->xmit; 1291 dev->hard_start_xmit = hdlc->xmit;
1231 dev->hard_header = NULL; 1292 dev->hard_header = NULL;
1232 dev->type = ARPHRD_FRAD; 1293 dev->type = ARPHRD_FRAD;
@@ -1238,6 +1299,9 @@ int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr)
1238 case IF_PROTO_FR_DEL_PVC: 1299 case IF_PROTO_FR_DEL_PVC:
1239 case IF_PROTO_FR_ADD_ETH_PVC: 1300 case IF_PROTO_FR_ADD_ETH_PVC:
1240 case IF_PROTO_FR_DEL_ETH_PVC: 1301 case IF_PROTO_FR_DEL_ETH_PVC:
1302 if (dev_to_hdlc(dev)->proto != &proto) /* Different proto */
1303 return -EINVAL;
1304
1241 if(!capable(CAP_NET_ADMIN)) 1305 if(!capable(CAP_NET_ADMIN))
1242 return -EPERM; 1306 return -EPERM;
1243 1307
@@ -1263,3 +1327,24 @@ int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr)
1263 1327
1264 return -EINVAL; 1328 return -EINVAL;
1265} 1329}
1330
1331
1332static int __init mod_init(void)
1333{
1334 register_hdlc_protocol(&proto);
1335 return 0;
1336}
1337
1338
1339static void __exit mod_exit(void)
1340{
1341 unregister_hdlc_protocol(&proto);
1342}
1343
1344
1345module_init(mod_init);
1346module_exit(mod_exit);
1347
1348MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
1349MODULE_DESCRIPTION("Frame-Relay protocol support for generic HDLC");
1350MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c
index fbaab5bf71eb..e9f717070fde 100644
--- a/drivers/net/wan/hdlc_ppp.c
+++ b/drivers/net/wan/hdlc_ppp.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * Point-to-point protocol support 3 * Point-to-point protocol support
4 * 4 *
5 * Copyright (C) 1999 - 2003 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -22,6 +22,21 @@
22#include <linux/lapb.h> 22#include <linux/lapb.h>
23#include <linux/rtnetlink.h> 23#include <linux/rtnetlink.h>
24#include <linux/hdlc.h> 24#include <linux/hdlc.h>
25#include <net/syncppp.h>
26
27struct ppp_state {
28 struct ppp_device pppdev;
29 struct ppp_device *syncppp_ptr;
30 int (*old_change_mtu)(struct net_device *dev, int new_mtu);
31};
32
33static int ppp_ioctl(struct net_device *dev, struct ifreq *ifr);
34
35
36static inline struct ppp_state* state(hdlc_device *hdlc)
37{
38 return(struct ppp_state *)(hdlc->state);
39}
25 40
26 41
27static int ppp_open(struct net_device *dev) 42static int ppp_open(struct net_device *dev)
@@ -30,16 +45,16 @@ static int ppp_open(struct net_device *dev)
30 void *old_ioctl; 45 void *old_ioctl;
31 int result; 46 int result;
32 47
33 dev->priv = &hdlc->state.ppp.syncppp_ptr; 48 dev->priv = &state(hdlc)->syncppp_ptr;
34 hdlc->state.ppp.syncppp_ptr = &hdlc->state.ppp.pppdev; 49 state(hdlc)->syncppp_ptr = &state(hdlc)->pppdev;
35 hdlc->state.ppp.pppdev.dev = dev; 50 state(hdlc)->pppdev.dev = dev;
36 51
37 old_ioctl = dev->do_ioctl; 52 old_ioctl = dev->do_ioctl;
38 hdlc->state.ppp.old_change_mtu = dev->change_mtu; 53 state(hdlc)->old_change_mtu = dev->change_mtu;
39 sppp_attach(&hdlc->state.ppp.pppdev); 54 sppp_attach(&state(hdlc)->pppdev);
40 /* sppp_attach nukes them. We don't need syncppp's ioctl */ 55 /* sppp_attach nukes them. We don't need syncppp's ioctl */
41 dev->do_ioctl = old_ioctl; 56 dev->do_ioctl = old_ioctl;
42 hdlc->state.ppp.pppdev.sppp.pp_flags &= ~PP_CISCO; 57 state(hdlc)->pppdev.sppp.pp_flags &= ~PP_CISCO;
43 dev->type = ARPHRD_PPP; 58 dev->type = ARPHRD_PPP;
44 result = sppp_open(dev); 59 result = sppp_open(dev);
45 if (result) { 60 if (result) {
@@ -59,7 +74,7 @@ static void ppp_close(struct net_device *dev)
59 sppp_close(dev); 74 sppp_close(dev);
60 sppp_detach(dev); 75 sppp_detach(dev);
61 dev->rebuild_header = NULL; 76 dev->rebuild_header = NULL;
62 dev->change_mtu = hdlc->state.ppp.old_change_mtu; 77 dev->change_mtu = state(hdlc)->old_change_mtu;
63 dev->mtu = HDLC_MAX_MTU; 78 dev->mtu = HDLC_MAX_MTU;
64 dev->hard_header_len = 16; 79 dev->hard_header_len = 16;
65} 80}
@@ -73,13 +88,24 @@ static __be16 ppp_type_trans(struct sk_buff *skb, struct net_device *dev)
73 88
74 89
75 90
76int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr) 91static struct hdlc_proto proto = {
92 .open = ppp_open,
93 .close = ppp_close,
94 .type_trans = ppp_type_trans,
95 .ioctl = ppp_ioctl,
96 .module = THIS_MODULE,
97};
98
99
100static int ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
77{ 101{
78 hdlc_device *hdlc = dev_to_hdlc(dev); 102 hdlc_device *hdlc = dev_to_hdlc(dev);
79 int result; 103 int result;
80 104
81 switch (ifr->ifr_settings.type) { 105 switch (ifr->ifr_settings.type) {
82 case IF_GET_PROTO: 106 case IF_GET_PROTO:
107 if (dev_to_hdlc(dev)->proto != &proto)
108 return -EINVAL;
83 ifr->ifr_settings.type = IF_PROTO_PPP; 109 ifr->ifr_settings.type = IF_PROTO_PPP;
84 return 0; /* return protocol only, no settable parameters */ 110 return 0; /* return protocol only, no settable parameters */
85 111
@@ -96,13 +122,10 @@ int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
96 if (result) 122 if (result)
97 return result; 123 return result;
98 124
99 hdlc_proto_detach(hdlc); 125 result = attach_hdlc_protocol(dev, &proto, NULL,
100 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 126 sizeof(struct ppp_state));
101 127 if (result)
102 hdlc->proto.open = ppp_open; 128 return result;
103 hdlc->proto.close = ppp_close;
104 hdlc->proto.type_trans = ppp_type_trans;
105 hdlc->proto.id = IF_PROTO_PPP;
106 dev->hard_start_xmit = hdlc->xmit; 129 dev->hard_start_xmit = hdlc->xmit;
107 dev->hard_header = NULL; 130 dev->hard_header = NULL;
108 dev->type = ARPHRD_PPP; 131 dev->type = ARPHRD_PPP;
@@ -113,3 +136,25 @@ int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
113 136
114 return -EINVAL; 137 return -EINVAL;
115} 138}
139
140
141static int __init mod_init(void)
142{
143 register_hdlc_protocol(&proto);
144 return 0;
145}
146
147
148
149static void __exit mod_exit(void)
150{
151 unregister_hdlc_protocol(&proto);
152}
153
154
155module_init(mod_init);
156module_exit(mod_exit);
157
158MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
159MODULE_DESCRIPTION("PPP protocol support for generic HDLC");
160MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c
index f15aa6ba77f1..fe3cae5c6b9d 100644
--- a/drivers/net/wan/hdlc_raw.c
+++ b/drivers/net/wan/hdlc_raw.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * HDLC support 3 * HDLC support
4 * 4 *
5 * Copyright (C) 1999 - 2003 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -24,6 +24,8 @@
24#include <linux/hdlc.h> 24#include <linux/hdlc.h>
25 25
26 26
27static int raw_ioctl(struct net_device *dev, struct ifreq *ifr);
28
27static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev) 29static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev)
28{ 30{
29 return __constant_htons(ETH_P_IP); 31 return __constant_htons(ETH_P_IP);
@@ -31,7 +33,14 @@ static __be16 raw_type_trans(struct sk_buff *skb, struct net_device *dev)
31 33
32 34
33 35
34int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr) 36static struct hdlc_proto proto = {
37 .type_trans = raw_type_trans,
38 .ioctl = raw_ioctl,
39 .module = THIS_MODULE,
40};
41
42
43static int raw_ioctl(struct net_device *dev, struct ifreq *ifr)
35{ 44{
36 raw_hdlc_proto __user *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc; 45 raw_hdlc_proto __user *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc;
37 const size_t size = sizeof(raw_hdlc_proto); 46 const size_t size = sizeof(raw_hdlc_proto);
@@ -41,12 +50,14 @@ int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr)
41 50
42 switch (ifr->ifr_settings.type) { 51 switch (ifr->ifr_settings.type) {
43 case IF_GET_PROTO: 52 case IF_GET_PROTO:
53 if (dev_to_hdlc(dev)->proto != &proto)
54 return -EINVAL;
44 ifr->ifr_settings.type = IF_PROTO_HDLC; 55 ifr->ifr_settings.type = IF_PROTO_HDLC;
45 if (ifr->ifr_settings.size < size) { 56 if (ifr->ifr_settings.size < size) {
46 ifr->ifr_settings.size = size; /* data size wanted */ 57 ifr->ifr_settings.size = size; /* data size wanted */
47 return -ENOBUFS; 58 return -ENOBUFS;
48 } 59 }
49 if (copy_to_user(raw_s, &hdlc->state.raw_hdlc.settings, size)) 60 if (copy_to_user(raw_s, hdlc->state, size))
50 return -EFAULT; 61 return -EFAULT;
51 return 0; 62 return 0;
52 63
@@ -71,12 +82,11 @@ int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr)
71 if (result) 82 if (result)
72 return result; 83 return result;
73 84
74 hdlc_proto_detach(hdlc); 85 result = attach_hdlc_protocol(dev, &proto, NULL,
75 memcpy(&hdlc->state.raw_hdlc.settings, &new_settings, size); 86 sizeof(raw_hdlc_proto));
76 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 87 if (result)
77 88 return result;
78 hdlc->proto.type_trans = raw_type_trans; 89 memcpy(hdlc->state, &new_settings, size);
79 hdlc->proto.id = IF_PROTO_HDLC;
80 dev->hard_start_xmit = hdlc->xmit; 90 dev->hard_start_xmit = hdlc->xmit;
81 dev->hard_header = NULL; 91 dev->hard_header = NULL;
82 dev->type = ARPHRD_RAWHDLC; 92 dev->type = ARPHRD_RAWHDLC;
@@ -88,3 +98,25 @@ int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr)
88 98
89 return -EINVAL; 99 return -EINVAL;
90} 100}
101
102
103static int __init mod_init(void)
104{
105 register_hdlc_protocol(&proto);
106 return 0;
107}
108
109
110
111static void __exit mod_exit(void)
112{
113 unregister_hdlc_protocol(&proto);
114}
115
116
117module_init(mod_init);
118module_exit(mod_exit);
119
120MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
121MODULE_DESCRIPTION("Raw HDLC protocol support for generic HDLC");
122MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c
index d1884987f94e..1a69a9aaa9b9 100644
--- a/drivers/net/wan/hdlc_raw_eth.c
+++ b/drivers/net/wan/hdlc_raw_eth.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * HDLC Ethernet emulation support 3 * HDLC Ethernet emulation support
4 * 4 *
5 * Copyright (C) 2002-2003 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 2002-2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -25,6 +25,7 @@
25#include <linux/etherdevice.h> 25#include <linux/etherdevice.h>
26#include <linux/hdlc.h> 26#include <linux/hdlc.h>
27 27
28static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr);
28 29
29static int eth_tx(struct sk_buff *skb, struct net_device *dev) 30static int eth_tx(struct sk_buff *skb, struct net_device *dev)
30{ 31{
@@ -44,7 +45,14 @@ static int eth_tx(struct sk_buff *skb, struct net_device *dev)
44} 45}
45 46
46 47
47int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr) 48static struct hdlc_proto proto = {
49 .type_trans = eth_type_trans,
50 .ioctl = raw_eth_ioctl,
51 .module = THIS_MODULE,
52};
53
54
55static int raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
48{ 56{
49 raw_hdlc_proto __user *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc; 57 raw_hdlc_proto __user *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc;
50 const size_t size = sizeof(raw_hdlc_proto); 58 const size_t size = sizeof(raw_hdlc_proto);
@@ -56,12 +64,14 @@ int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
56 64
57 switch (ifr->ifr_settings.type) { 65 switch (ifr->ifr_settings.type) {
58 case IF_GET_PROTO: 66 case IF_GET_PROTO:
67 if (dev_to_hdlc(dev)->proto != &proto)
68 return -EINVAL;
59 ifr->ifr_settings.type = IF_PROTO_HDLC_ETH; 69 ifr->ifr_settings.type = IF_PROTO_HDLC_ETH;
60 if (ifr->ifr_settings.size < size) { 70 if (ifr->ifr_settings.size < size) {
61 ifr->ifr_settings.size = size; /* data size wanted */ 71 ifr->ifr_settings.size = size; /* data size wanted */
62 return -ENOBUFS; 72 return -ENOBUFS;
63 } 73 }
64 if (copy_to_user(raw_s, &hdlc->state.raw_hdlc.settings, size)) 74 if (copy_to_user(raw_s, hdlc->state, size))
65 return -EFAULT; 75 return -EFAULT;
66 return 0; 76 return 0;
67 77
@@ -86,12 +96,11 @@ int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
86 if (result) 96 if (result)
87 return result; 97 return result;
88 98
89 hdlc_proto_detach(hdlc); 99 result = attach_hdlc_protocol(dev, &proto, NULL,
90 memcpy(&hdlc->state.raw_hdlc.settings, &new_settings, size); 100 sizeof(raw_hdlc_proto));
91 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 101 if (result)
92 102 return result;
93 hdlc->proto.type_trans = eth_type_trans; 103 memcpy(hdlc->state, &new_settings, size);
94 hdlc->proto.id = IF_PROTO_HDLC_ETH;
95 dev->hard_start_xmit = eth_tx; 104 dev->hard_start_xmit = eth_tx;
96 old_ch_mtu = dev->change_mtu; 105 old_ch_mtu = dev->change_mtu;
97 old_qlen = dev->tx_queue_len; 106 old_qlen = dev->tx_queue_len;
@@ -106,3 +115,25 @@ int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr)
106 115
107 return -EINVAL; 116 return -EINVAL;
108} 117}
118
119
120static int __init mod_init(void)
121{
122 register_hdlc_protocol(&proto);
123 return 0;
124}
125
126
127
128static void __exit mod_exit(void)
129{
130 unregister_hdlc_protocol(&proto);
131}
132
133
134module_init(mod_init);
135module_exit(mod_exit);
136
137MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
138MODULE_DESCRIPTION("Ethernet encapsulation support for generic HDLC");
139MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
index a867fb411f89..e4bb9f8ad433 100644
--- a/drivers/net/wan/hdlc_x25.c
+++ b/drivers/net/wan/hdlc_x25.c
@@ -2,7 +2,7 @@
2 * Generic HDLC support routines for Linux 2 * Generic HDLC support routines for Linux
3 * X.25 support 3 * X.25 support
4 * 4 *
5 * Copyright (C) 1999 - 2003 Krzysztof Halasa <khc@pm.waw.pl> 5 * Copyright (C) 1999 - 2006 Krzysztof Halasa <khc@pm.waw.pl>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify it 7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of version 2 of the GNU General Public License 8 * under the terms of version 2 of the GNU General Public License
@@ -25,6 +25,8 @@
25 25
26#include <net/x25device.h> 26#include <net/x25device.h>
27 27
28static int x25_ioctl(struct net_device *dev, struct ifreq *ifr);
29
28/* These functions are callbacks called by LAPB layer */ 30/* These functions are callbacks called by LAPB layer */
29 31
30static void x25_connect_disconnect(struct net_device *dev, int reason, int code) 32static void x25_connect_disconnect(struct net_device *dev, int reason, int code)
@@ -162,30 +164,39 @@ static void x25_close(struct net_device *dev)
162 164
163static int x25_rx(struct sk_buff *skb) 165static int x25_rx(struct sk_buff *skb)
164{ 166{
165 hdlc_device *hdlc = dev_to_hdlc(skb->dev); 167 struct hdlc_device_desc *desc = dev_to_desc(skb->dev);
166 168
167 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 169 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
168 hdlc->stats.rx_dropped++; 170 desc->stats.rx_dropped++;
169 return NET_RX_DROP; 171 return NET_RX_DROP;
170 } 172 }
171 173
172 if (lapb_data_received(skb->dev, skb) == LAPB_OK) 174 if (lapb_data_received(skb->dev, skb) == LAPB_OK)
173 return NET_RX_SUCCESS; 175 return NET_RX_SUCCESS;
174 176
175 hdlc->stats.rx_errors++; 177 desc->stats.rx_errors++;
176 dev_kfree_skb_any(skb); 178 dev_kfree_skb_any(skb);
177 return NET_RX_DROP; 179 return NET_RX_DROP;
178} 180}
179 181
180 182
183static struct hdlc_proto proto = {
184 .open = x25_open,
185 .close = x25_close,
186 .ioctl = x25_ioctl,
187 .module = THIS_MODULE,
188};
189
181 190
182int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr) 191static int x25_ioctl(struct net_device *dev, struct ifreq *ifr)
183{ 192{
184 hdlc_device *hdlc = dev_to_hdlc(dev); 193 hdlc_device *hdlc = dev_to_hdlc(dev);
185 int result; 194 int result;
186 195
187 switch (ifr->ifr_settings.type) { 196 switch (ifr->ifr_settings.type) {
188 case IF_GET_PROTO: 197 case IF_GET_PROTO:
198 if (dev_to_hdlc(dev)->proto != &proto)
199 return -EINVAL;
189 ifr->ifr_settings.type = IF_PROTO_X25; 200 ifr->ifr_settings.type = IF_PROTO_X25;
190 return 0; /* return protocol only, no settable parameters */ 201 return 0; /* return protocol only, no settable parameters */
191 202
@@ -200,14 +211,9 @@ int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr)
200 if (result) 211 if (result)
201 return result; 212 return result;
202 213
203 hdlc_proto_detach(hdlc); 214 if ((result = attach_hdlc_protocol(dev, &proto,
204 memset(&hdlc->proto, 0, sizeof(hdlc->proto)); 215 x25_rx, 0)) != 0)
205 216 return result;
206 hdlc->proto.open = x25_open;
207 hdlc->proto.close = x25_close;
208 hdlc->proto.netif_rx = x25_rx;
209 hdlc->proto.type_trans = NULL;
210 hdlc->proto.id = IF_PROTO_X25;
211 dev->hard_start_xmit = x25_xmit; 217 dev->hard_start_xmit = x25_xmit;
212 dev->hard_header = NULL; 218 dev->hard_header = NULL;
213 dev->type = ARPHRD_X25; 219 dev->type = ARPHRD_X25;
@@ -218,3 +224,25 @@ int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr)
218 224
219 return -EINVAL; 225 return -EINVAL;
220} 226}
227
228
229static int __init mod_init(void)
230{
231 register_hdlc_protocol(&proto);
232 return 0;
233}
234
235
236
237static void __exit mod_exit(void)
238{
239 unregister_hdlc_protocol(&proto);
240}
241
242
243module_init(mod_init);
244module_exit(mod_exit);
245
246MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
247MODULE_DESCRIPTION("X.25 protocol support for generic HDLC");
248MODULE_LICENSE("GPL v2");
diff --git a/drivers/net/wan/pc300.h b/drivers/net/wan/pc300.h
index 2024b26b99e6..63e9fcf31fb8 100644
--- a/drivers/net/wan/pc300.h
+++ b/drivers/net/wan/pc300.h
@@ -100,6 +100,7 @@
100#define _PC300_H 100#define _PC300_H
101 101
102#include <linux/hdlc.h> 102#include <linux/hdlc.h>
103#include <net/syncppp.h>
103#include "hd64572.h" 104#include "hd64572.h"
104#include "pc300-falc-lh.h" 105#include "pc300-falc-lh.h"
105 106
diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c
index 56e69403d178..8d9b959bf15b 100644
--- a/drivers/net/wan/pc300_drv.c
+++ b/drivers/net/wan/pc300_drv.c
@@ -2016,7 +2016,6 @@ static void sca_intr(pc300_t * card)
2016 pc300ch_t *chan = &card->chan[ch]; 2016 pc300ch_t *chan = &card->chan[ch];
2017 pc300dev_t *d = &chan->d; 2017 pc300dev_t *d = &chan->d;
2018 struct net_device *dev = d->dev; 2018 struct net_device *dev = d->dev;
2019 hdlc_device *hdlc = dev_to_hdlc(dev);
2020 2019
2021 spin_lock(&card->card_lock); 2020 spin_lock(&card->card_lock);
2022 2021
@@ -2049,8 +2048,8 @@ static void sca_intr(pc300_t * card)
2049 } 2048 }
2050 cpc_net_rx(dev); 2049 cpc_net_rx(dev);
2051 /* Discard invalid frames */ 2050 /* Discard invalid frames */
2052 hdlc->stats.rx_errors++; 2051 hdlc_stats(dev)->rx_errors++;
2053 hdlc->stats.rx_over_errors++; 2052 hdlc_stats(dev)->rx_over_errors++;
2054 chan->rx_first_bd = 0; 2053 chan->rx_first_bd = 0;
2055 chan->rx_last_bd = N_DMA_RX_BUF - 1; 2054 chan->rx_last_bd = N_DMA_RX_BUF - 1;
2056 rx_dma_start(card, ch); 2055 rx_dma_start(card, ch);
@@ -2116,8 +2115,8 @@ static void sca_intr(pc300_t * card)
2116 card->hw.cpld_reg2) & 2115 card->hw.cpld_reg2) &
2117 ~ (CPLD_REG2_FALC_LED1 << (2 * ch))); 2116 ~ (CPLD_REG2_FALC_LED1 << (2 * ch)));
2118 } 2117 }
2119 hdlc->stats.tx_errors++; 2118 hdlc_stats(dev)->tx_errors++;
2120 hdlc->stats.tx_fifo_errors++; 2119 hdlc_stats(dev)->tx_fifo_errors++;
2121 sca_tx_intr(d); 2120 sca_tx_intr(d);
2122 } 2121 }
2123 } 2122 }
@@ -2534,7 +2533,6 @@ static int cpc_change_mtu(struct net_device *dev, int new_mtu)
2534 2533
2535static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2534static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2536{ 2535{
2537 hdlc_device *hdlc = dev_to_hdlc(dev);
2538 pc300dev_t *d = (pc300dev_t *) dev->priv; 2536 pc300dev_t *d = (pc300dev_t *) dev->priv;
2539 pc300ch_t *chan = (pc300ch_t *) d->chan; 2537 pc300ch_t *chan = (pc300ch_t *) d->chan;
2540 pc300_t *card = (pc300_t *) chan->card; 2538 pc300_t *card = (pc300_t *) chan->card;
@@ -2552,10 +2550,10 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2552 case SIOCGPC300CONF: 2550 case SIOCGPC300CONF:
2553#ifdef CONFIG_PC300_MLPPP 2551#ifdef CONFIG_PC300_MLPPP
2554 if (conf->proto != PC300_PROTO_MLPPP) { 2552 if (conf->proto != PC300_PROTO_MLPPP) {
2555 conf->proto = hdlc->proto.id; 2553 conf->proto = /* FIXME hdlc->proto.id */ 0;
2556 } 2554 }
2557#else 2555#else
2558 conf->proto = hdlc->proto.id; 2556 conf->proto = /* FIXME hdlc->proto.id */ 0;
2559#endif 2557#endif
2560 memcpy(&conf_aux.conf, conf, sizeof(pc300chconf_t)); 2558 memcpy(&conf_aux.conf, conf, sizeof(pc300chconf_t));
2561 memcpy(&conf_aux.hw, &card->hw, sizeof(pc300hw_t)); 2559 memcpy(&conf_aux.hw, &card->hw, sizeof(pc300hw_t));
@@ -2588,12 +2586,12 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2588 } 2586 }
2589 } else { 2587 } else {
2590 memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t)); 2588 memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
2591 hdlc->proto.id = conf->proto; 2589 /* FIXME hdlc->proto.id = conf->proto; */
2592 } 2590 }
2593 } 2591 }
2594#else 2592#else
2595 memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t)); 2593 memcpy(conf, &conf_aux.conf, sizeof(pc300chconf_t));
2596 hdlc->proto.id = conf->proto; 2594 /* FIXME hdlc->proto.id = conf->proto; */
2597#endif 2595#endif
2598 return 0; 2596 return 0;
2599 case SIOCGPC300STATUS: 2597 case SIOCGPC300STATUS:
@@ -2606,7 +2604,7 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2606 case SIOCGPC300UTILSTATS: 2604 case SIOCGPC300UTILSTATS:
2607 { 2605 {
2608 if (!arg) { /* clear statistics */ 2606 if (!arg) { /* clear statistics */
2609 memset(&hdlc->stats, 0, sizeof(struct net_device_stats)); 2607 memset(hdlc_stats(dev), 0, sizeof(struct net_device_stats));
2610 if (card->hw.type == PC300_TE) { 2608 if (card->hw.type == PC300_TE) {
2611 memset(&chan->falc, 0, sizeof(falc_t)); 2609 memset(&chan->falc, 0, sizeof(falc_t));
2612 } 2610 }
@@ -2617,7 +2615,7 @@ static int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2617 pc300stats.hw_type = card->hw.type; 2615 pc300stats.hw_type = card->hw.type;
2618 pc300stats.line_on = card->chan[ch].d.line_on; 2616 pc300stats.line_on = card->chan[ch].d.line_on;
2619 pc300stats.line_off = card->chan[ch].d.line_off; 2617 pc300stats.line_off = card->chan[ch].d.line_off;
2620 memcpy(&pc300stats.gen_stats, &hdlc->stats, 2618 memcpy(&pc300stats.gen_stats, hdlc_stats(dev),
2621 sizeof(struct net_device_stats)); 2619 sizeof(struct net_device_stats));
2622 if (card->hw.type == PC300_TE) 2620 if (card->hw.type == PC300_TE)
2623 memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t)); 2621 memcpy(&pc300stats.te_stats,&chan->falc,sizeof(falc_t));
@@ -3147,7 +3145,6 @@ static void cpc_closech(pc300dev_t * d)
3147 3145
3148int cpc_open(struct net_device *dev) 3146int cpc_open(struct net_device *dev)
3149{ 3147{
3150 hdlc_device *hdlc = dev_to_hdlc(dev);
3151 pc300dev_t *d = (pc300dev_t *) dev->priv; 3148 pc300dev_t *d = (pc300dev_t *) dev->priv;
3152 struct ifreq ifr; 3149 struct ifreq ifr;
3153 int result; 3150 int result;
@@ -3156,12 +3153,14 @@ int cpc_open(struct net_device *dev)
3156 printk("pc300: cpc_open"); 3153 printk("pc300: cpc_open");
3157#endif 3154#endif
3158 3155
3156#ifdef FIXME
3159 if (hdlc->proto.id == IF_PROTO_PPP) { 3157 if (hdlc->proto.id == IF_PROTO_PPP) {
3160 d->if_ptr = &hdlc->state.ppp.pppdev; 3158 d->if_ptr = &hdlc->state.ppp.pppdev;
3161 } 3159 }
3160#endif
3162 3161
3163 result = hdlc_open(dev); 3162 result = hdlc_open(dev);
3164 if (hdlc->proto.id == IF_PROTO_PPP) { 3163 if (/* FIXME hdlc->proto.id == IF_PROTO_PPP*/ 0) {
3165 dev->priv = d; 3164 dev->priv = d;
3166 } 3165 }
3167 if (result) { 3166 if (result) {
@@ -3176,7 +3175,6 @@ int cpc_open(struct net_device *dev)
3176 3175
3177static int cpc_close(struct net_device *dev) 3176static int cpc_close(struct net_device *dev)
3178{ 3177{
3179 hdlc_device *hdlc = dev_to_hdlc(dev);
3180 pc300dev_t *d = (pc300dev_t *) dev->priv; 3178 pc300dev_t *d = (pc300dev_t *) dev->priv;
3181 pc300ch_t *chan = (pc300ch_t *) d->chan; 3179 pc300ch_t *chan = (pc300ch_t *) d->chan;
3182 pc300_t *card = (pc300_t *) chan->card; 3180 pc300_t *card = (pc300_t *) chan->card;
@@ -3193,7 +3191,7 @@ static int cpc_close(struct net_device *dev)
3193 CPC_UNLOCK(card, flags); 3191 CPC_UNLOCK(card, flags);
3194 3192
3195 hdlc_close(dev); 3193 hdlc_close(dev);
3196 if (hdlc->proto.id == IF_PROTO_PPP) { 3194 if (/* FIXME hdlc->proto.id == IF_PROTO_PPP*/ 0) {
3197 d->if_ptr = NULL; 3195 d->if_ptr = NULL;
3198 } 3196 }
3199#ifdef CONFIG_PC300_MLPPP 3197#ifdef CONFIG_PC300_MLPPP
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index bff04cba3fed..ba737c6cebec 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5868,7 +5868,7 @@ static int airo_set_essid(struct net_device *dev,
5868 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 5868 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
5869 5869
5870 /* Check the size of the string */ 5870 /* Check the size of the string */
5871 if(dwrq->length > IW_ESSID_MAX_SIZE+1) { 5871 if(dwrq->length > IW_ESSID_MAX_SIZE) {
5872 return -E2BIG ; 5872 return -E2BIG ;
5873 } 5873 }
5874 /* Check if index is valid */ 5874 /* Check if index is valid */
@@ -5880,7 +5880,7 @@ static int airo_set_essid(struct net_device *dev,
5880 memset(SSID_rid.ssids[index].ssid, 0, 5880 memset(SSID_rid.ssids[index].ssid, 0,
5881 sizeof(SSID_rid.ssids[index].ssid)); 5881 sizeof(SSID_rid.ssids[index].ssid));
5882 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length); 5882 memcpy(SSID_rid.ssids[index].ssid, extra, dwrq->length);
5883 SSID_rid.ssids[index].len = dwrq->length - 1; 5883 SSID_rid.ssids[index].len = dwrq->length;
5884 } 5884 }
5885 SSID_rid.len = sizeof(SSID_rid); 5885 SSID_rid.len = sizeof(SSID_rid);
5886 /* Write it to the card */ 5886 /* Write it to the card */
@@ -5990,7 +5990,7 @@ static int airo_set_nick(struct net_device *dev,
5990 struct airo_info *local = dev->priv; 5990 struct airo_info *local = dev->priv;
5991 5991
5992 /* Check the size of the string */ 5992 /* Check the size of the string */
5993 if(dwrq->length > 16 + 1) { 5993 if(dwrq->length > 16) {
5994 return -E2BIG; 5994 return -E2BIG;
5995 } 5995 }
5996 readConfigRid(local, 1); 5996 readConfigRid(local, 1);
@@ -6015,7 +6015,7 @@ static int airo_get_nick(struct net_device *dev,
6015 readConfigRid(local, 1); 6015 readConfigRid(local, 1);
6016 strncpy(extra, local->config.nodeName, 16); 6016 strncpy(extra, local->config.nodeName, 16);
6017 extra[16] = '\0'; 6017 extra[16] = '\0';
6018 dwrq->length = strlen(extra) + 1; 6018 dwrq->length = strlen(extra);
6019 6019
6020 return 0; 6020 return 0;
6021} 6021}
@@ -6767,9 +6767,9 @@ static int airo_set_retry(struct net_device *dev,
6767 } 6767 }
6768 readConfigRid(local, 1); 6768 readConfigRid(local, 1);
6769 if(vwrq->flags & IW_RETRY_LIMIT) { 6769 if(vwrq->flags & IW_RETRY_LIMIT) {
6770 if(vwrq->flags & IW_RETRY_MAX) 6770 if(vwrq->flags & IW_RETRY_LONG)
6771 local->config.longRetryLimit = vwrq->value; 6771 local->config.longRetryLimit = vwrq->value;
6772 else if (vwrq->flags & IW_RETRY_MIN) 6772 else if (vwrq->flags & IW_RETRY_SHORT)
6773 local->config.shortRetryLimit = vwrq->value; 6773 local->config.shortRetryLimit = vwrq->value;
6774 else { 6774 else {
6775 /* No modifier : set both */ 6775 /* No modifier : set both */
@@ -6805,14 +6805,14 @@ static int airo_get_retry(struct net_device *dev,
6805 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) { 6805 if((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
6806 vwrq->flags = IW_RETRY_LIFETIME; 6806 vwrq->flags = IW_RETRY_LIFETIME;
6807 vwrq->value = (int)local->config.txLifetime * 1024; 6807 vwrq->value = (int)local->config.txLifetime * 1024;
6808 } else if((vwrq->flags & IW_RETRY_MAX)) { 6808 } else if((vwrq->flags & IW_RETRY_LONG)) {
6809 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 6809 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
6810 vwrq->value = (int)local->config.longRetryLimit; 6810 vwrq->value = (int)local->config.longRetryLimit;
6811 } else { 6811 } else {
6812 vwrq->flags = IW_RETRY_LIMIT; 6812 vwrq->flags = IW_RETRY_LIMIT;
6813 vwrq->value = (int)local->config.shortRetryLimit; 6813 vwrq->value = (int)local->config.shortRetryLimit;
6814 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit) 6814 if((int)local->config.shortRetryLimit != (int)local->config.longRetryLimit)
6815 vwrq->flags |= IW_RETRY_MIN; 6815 vwrq->flags |= IW_RETRY_SHORT;
6816 } 6816 }
6817 6817
6818 return 0; 6818 return 0;
@@ -6990,6 +6990,7 @@ static int airo_set_power(struct net_device *dev,
6990 local->config.rmode |= RXMODE_BC_MC_ADDR; 6990 local->config.rmode |= RXMODE_BC_MC_ADDR;
6991 set_bit (FLAG_COMMIT, &local->flags); 6991 set_bit (FLAG_COMMIT, &local->flags);
6992 case IW_POWER_ON: 6992 case IW_POWER_ON:
6993 /* This is broken, fixme ;-) */
6993 break; 6994 break;
6994 default: 6995 default:
6995 return -EINVAL; 6996 return -EINVAL;
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 995c7bea5897..0fc267d626dc 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -1656,13 +1656,13 @@ static int atmel_set_essid(struct net_device *dev,
1656 priv->connect_to_any_BSS = 0; 1656 priv->connect_to_any_BSS = 0;
1657 1657
1658 /* Check the size of the string */ 1658 /* Check the size of the string */
1659 if (dwrq->length > MAX_SSID_LENGTH + 1) 1659 if (dwrq->length > MAX_SSID_LENGTH)
1660 return -E2BIG; 1660 return -E2BIG;
1661 if (index != 0) 1661 if (index != 0)
1662 return -EINVAL; 1662 return -EINVAL;
1663 1663
1664 memcpy(priv->new_SSID, extra, dwrq->length - 1); 1664 memcpy(priv->new_SSID, extra, dwrq->length);
1665 priv->new_SSID_size = dwrq->length - 1; 1665 priv->new_SSID_size = dwrq->length;
1666 } 1666 }
1667 1667
1668 return -EINPROGRESS; 1668 return -EINPROGRESS;
@@ -2120,9 +2120,9 @@ static int atmel_set_retry(struct net_device *dev,
2120 struct atmel_private *priv = netdev_priv(dev); 2120 struct atmel_private *priv = netdev_priv(dev);
2121 2121
2122 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { 2122 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) {
2123 if (vwrq->flags & IW_RETRY_MAX) 2123 if (vwrq->flags & IW_RETRY_LONG)
2124 priv->long_retry = vwrq->value; 2124 priv->long_retry = vwrq->value;
2125 else if (vwrq->flags & IW_RETRY_MIN) 2125 else if (vwrq->flags & IW_RETRY_SHORT)
2126 priv->short_retry = vwrq->value; 2126 priv->short_retry = vwrq->value;
2127 else { 2127 else {
2128 /* No modifier : set both */ 2128 /* No modifier : set both */
@@ -2144,15 +2144,15 @@ static int atmel_get_retry(struct net_device *dev,
2144 2144
2145 vwrq->disabled = 0; /* Can't be disabled */ 2145 vwrq->disabled = 0; /* Can't be disabled */
2146 2146
2147 /* Note : by default, display the min retry number */ 2147 /* Note : by default, display the short retry number */
2148 if (vwrq->flags & IW_RETRY_MAX) { 2148 if (vwrq->flags & IW_RETRY_LONG) {
2149 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 2149 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
2150 vwrq->value = priv->long_retry; 2150 vwrq->value = priv->long_retry;
2151 } else { 2151 } else {
2152 vwrq->flags = IW_RETRY_LIMIT; 2152 vwrq->flags = IW_RETRY_LIMIT;
2153 vwrq->value = priv->short_retry; 2153 vwrq->value = priv->short_retry;
2154 if (priv->long_retry != priv->short_retry) 2154 if (priv->long_retry != priv->short_retry)
2155 vwrq->flags |= IW_RETRY_MIN; 2155 vwrq->flags |= IW_RETRY_SHORT;
2156 } 2156 }
2157 2157
2158 return 0; 2158 return 0;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h
index 6d4ea36bc564..d6a8bf09878e 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx.h
+++ b/drivers/net/wireless/bcm43xx/bcm43xx.h
@@ -666,7 +666,6 @@ struct bcm43xx_noise_calculation {
666}; 666};
667 667
668struct bcm43xx_stats { 668struct bcm43xx_stats {
669 u8 link_quality;
670 u8 noise; 669 u8 noise;
671 struct iw_statistics wstats; 670 struct iw_statistics wstats;
672 /* Store the last TX/RX times here for updating the leds. */ 671 /* Store the last TX/RX times here for updating the leds. */
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
index 923275ea0789..b9df06a06ea9 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c
@@ -54,7 +54,7 @@ static ssize_t write_file_dummy(struct file *file, const char __user *buf,
54 54
55static int open_file_generic(struct inode *inode, struct file *file) 55static int open_file_generic(struct inode *inode, struct file *file)
56{ 56{
57 file->private_data = inode->u.generic_ip; 57 file->private_data = inode->i_private;
58 return 0; 58 return 0;
59} 59}
60 60
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
index cb9a3ae8463a..eb65db7393ba 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
@@ -2405,9 +2405,10 @@ static int bcm43xx_chip_init(struct bcm43xx_private *bcm)
2405 BCM43xx_UCODE_TIME) & 0x1f); 2405 BCM43xx_UCODE_TIME) & 0x1f);
2406 2406
2407 if ( value16 > 0x128 ) { 2407 if ( value16 > 0x128 ) {
2408 dprintk(KERN_ERR PFX 2408 printk(KERN_ERR PFX
2409 "Firmware: no support for microcode rev > 0x128\n"); 2409 "Firmware: no support for microcode extracted "
2410 err = -1; 2410 "from version 4.x binary drivers.\n");
2411 err = -EOPNOTSUPP;
2411 goto err_release_fw; 2412 goto err_release_fw;
2412 } 2413 }
2413 2414
@@ -3169,8 +3170,7 @@ static void bcm43xx_periodic_work_handler(void *d)
3169 * be preemtible. 3170 * be preemtible.
3170 */ 3171 */
3171 mutex_lock(&bcm->mutex); 3172 mutex_lock(&bcm->mutex);
3172 netif_stop_queue(bcm->net_dev); 3173 netif_tx_disable(bcm->net_dev);
3173 synchronize_net();
3174 spin_lock_irqsave(&bcm->irq_lock, flags); 3174 spin_lock_irqsave(&bcm->irq_lock, flags);
3175 bcm43xx_mac_suspend(bcm); 3175 bcm43xx_mac_suspend(bcm);
3176 if (bcm43xx_using_pio(bcm)) 3176 if (bcm43xx_using_pio(bcm))
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
index eafd0f662686..52ce2a9334fb 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c
@@ -361,7 +361,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
361 if (phy->rev <= 2) 361 if (phy->rev <= 2)
362 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++) 362 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
363 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg1[i]); 363 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg1[i]);
364 else if ((phy->rev == 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200)) 364 else if ((phy->rev >= 7) && (bcm43xx_phy_read(bcm, 0x0449) & 0x0200))
365 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++) 365 for (i = 0; i < BCM43xx_ILT_NOISESCALEG_SIZE; i++)
366 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg3[i]); 366 bcm43xx_ilt_write(bcm, 0x1400 + i, bcm43xx_ilt_noisescaleg3[i]);
367 else 367 else
@@ -371,7 +371,7 @@ static void bcm43xx_phy_setupg(struct bcm43xx_private *bcm)
371 if (phy->rev == 2) 371 if (phy->rev == 2)
372 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++) 372 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
373 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr1[i]); 373 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr1[i]);
374 else if ((phy->rev > 2) && (phy->rev <= 7)) 374 else if ((phy->rev > 2) && (phy->rev <= 8))
375 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++) 375 for (i = 0; i < BCM43xx_ILT_SIGMASQR_SIZE; i++)
376 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr2[i]); 376 bcm43xx_ilt_write(bcm, 0x5000 + i, bcm43xx_ilt_sigmasqr2[i]);
377 377
@@ -1197,7 +1197,7 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1197 1197
1198 if (phy->rev == 1) 1198 if (phy->rev == 1)
1199 bcm43xx_phy_initb5(bcm); 1199 bcm43xx_phy_initb5(bcm);
1200 else if (phy->rev >= 2 && phy->rev <= 7) 1200 else
1201 bcm43xx_phy_initb6(bcm); 1201 bcm43xx_phy_initb6(bcm);
1202 if (phy->rev >= 2 || phy->connected) 1202 if (phy->rev >= 2 || phy->connected)
1203 bcm43xx_phy_inita(bcm); 1203 bcm43xx_phy_inita(bcm);
@@ -1241,23 +1241,22 @@ static void bcm43xx_phy_initg(struct bcm43xx_private *bcm)
1241 bcm43xx_phy_lo_g_measure(bcm); 1241 bcm43xx_phy_lo_g_measure(bcm);
1242 } else { 1242 } else {
1243 if (radio->version == 0x2050 && radio->revision == 8) { 1243 if (radio->version == 0x2050 && radio->revision == 8) {
1244 //FIXME 1244 bcm43xx_radio_write16(bcm, 0x0052,
1245 (radio->txctl1 << 4) | radio->txctl2);
1245 } else { 1246 } else {
1246 bcm43xx_radio_write16(bcm, 0x0052, 1247 bcm43xx_radio_write16(bcm, 0x0052,
1247 (bcm43xx_radio_read16(bcm, 0x0052) 1248 (bcm43xx_radio_read16(bcm, 0x0052)
1248 & 0xFFF0) | radio->txctl1); 1249 & 0xFFF0) | radio->txctl1);
1249 } 1250 }
1250 if (phy->rev >= 6) { 1251 if (phy->rev >= 6) {
1251 /*
1252 bcm43xx_phy_write(bcm, 0x0036, 1252 bcm43xx_phy_write(bcm, 0x0036,
1253 (bcm43xx_phy_read(bcm, 0x0036) 1253 (bcm43xx_phy_read(bcm, 0x0036)
1254 & 0xF000) | (FIXME << 12)); 1254 & 0xF000) | (radio->txctl2 << 12));
1255 */
1256 } 1255 }
1257 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL) 1256 if (bcm->sprom.boardflags & BCM43xx_BFL_PACTRL)
1258 bcm43xx_phy_write(bcm, 0x002E, 0x8075); 1257 bcm43xx_phy_write(bcm, 0x002E, 0x8075);
1259 else 1258 else
1260 bcm43xx_phy_write(bcm, 0x003E, 0x807F); 1259 bcm43xx_phy_write(bcm, 0x002E, 0x807F);
1261 if (phy->rev < 2) 1260 if (phy->rev < 2)
1262 bcm43xx_phy_write(bcm, 0x002F, 0x0101); 1261 bcm43xx_phy_write(bcm, 0x002F, 0x0101);
1263 else 1262 else
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
index 888077fc14c4..9b7b15cf6561 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c
@@ -334,7 +334,7 @@ static int bcm43xx_wx_get_nick(struct net_device *net_dev,
334 size_t len; 334 size_t len;
335 335
336 mutex_lock(&bcm->mutex); 336 mutex_lock(&bcm->mutex);
337 len = strlen(bcm->nick) + 1; 337 len = strlen(bcm->nick);
338 memcpy(extra, bcm->nick, len); 338 memcpy(extra, bcm->nick, len);
339 data->data.length = (__u16)len; 339 data->data.length = (__u16)len;
340 data->data.flags = 1; 340 data->data.flags = 1;
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
index c0efbfe605a5..0159e4e93201 100644
--- a/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
+++ b/drivers/net/wireless/bcm43xx/bcm43xx_xmit.c
@@ -496,15 +496,14 @@ int bcm43xx_rx(struct bcm43xx_private *bcm,
496 stats.signal = bcm43xx_rssi_postprocess(bcm, rxhdr->rssi, is_ofdm, 496 stats.signal = bcm43xx_rssi_postprocess(bcm, rxhdr->rssi, is_ofdm,
497 !!(rxflags1 & BCM43xx_RXHDR_FLAGS1_2053RSSIADJ), 497 !!(rxflags1 & BCM43xx_RXHDR_FLAGS1_2053RSSIADJ),
498 !!(rxflags3 & BCM43xx_RXHDR_FLAGS3_2050RSSIADJ)); 498 !!(rxflags3 & BCM43xx_RXHDR_FLAGS3_2050RSSIADJ));
499//TODO stats.noise = 499 stats.noise = bcm->stats.noise;
500 if (is_ofdm) 500 if (is_ofdm)
501 stats.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp); 501 stats.rate = bcm43xx_plcp_get_bitrate_ofdm(plcp);
502 else 502 else
503 stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp); 503 stats.rate = bcm43xx_plcp_get_bitrate_cck(plcp);
504 stats.received_channel = radio->channel; 504 stats.received_channel = radio->channel;
505//TODO stats.control =
506 stats.mask = IEEE80211_STATMASK_SIGNAL | 505 stats.mask = IEEE80211_STATMASK_SIGNAL |
507//TODO IEEE80211_STATMASK_NOISE | 506 IEEE80211_STATMASK_NOISE |
508 IEEE80211_STATMASK_RATE | 507 IEEE80211_STATMASK_RATE |
509 IEEE80211_STATMASK_RSSI; 508 IEEE80211_STATMASK_RSSI;
510 if (phy->type == BCM43xx_PHYTYPE_A) 509 if (phy->type == BCM43xx_PHYTYPE_A)
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index 7a4978516eac..d061fb3443ff 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -1412,9 +1412,9 @@ static int prism2_ioctl_siwretry(struct net_device *dev,
1412 /* what could be done, if firmware would support this.. */ 1412 /* what could be done, if firmware would support this.. */
1413 1413
1414 if (rrq->flags & IW_RETRY_LIMIT) { 1414 if (rrq->flags & IW_RETRY_LIMIT) {
1415 if (rrq->flags & IW_RETRY_MAX) 1415 if (rrq->flags & IW_RETRY_LONG)
1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value; 1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
1417 else if (rrq->flags & IW_RETRY_MIN) 1417 else if (rrq->flags & IW_RETRY_SHORT)
1418 HFA384X_RID_SHORTRETRYLIMIT = rrq->value; 1418 HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
1419 else { 1419 else {
1420 HFA384X_RID_LONGRETRYLIMIT = rrq->value; 1420 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
@@ -1468,14 +1468,14 @@ static int prism2_ioctl_giwretry(struct net_device *dev,
1468 rrq->value = le16_to_cpu(altretry); 1468 rrq->value = le16_to_cpu(altretry);
1469 else 1469 else
1470 rrq->value = local->manual_retry_count; 1470 rrq->value = local->manual_retry_count;
1471 } else if ((rrq->flags & IW_RETRY_MAX)) { 1471 } else if ((rrq->flags & IW_RETRY_LONG)) {
1472 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1472 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1473 rrq->value = longretry; 1473 rrq->value = longretry;
1474 } else { 1474 } else {
1475 rrq->flags = IW_RETRY_LIMIT; 1475 rrq->flags = IW_RETRY_LIMIT;
1476 rrq->value = shortretry; 1476 rrq->value = shortretry;
1477 if (shortretry != longretry) 1477 if (shortretry != longretry)
1478 rrq->flags |= IW_RETRY_MIN; 1478 rrq->flags |= IW_RETRY_SHORT;
1479 } 1479 }
1480 } 1480 }
1481 return 0; 1481 return 0;
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index b4d81a04c895..6c5add701a6f 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -6958,7 +6958,7 @@ static int ipw2100_wx_set_essid(struct net_device *dev,
6958 } 6958 }
6959 6959
6960 if (wrqu->essid.flags && wrqu->essid.length) { 6960 if (wrqu->essid.flags && wrqu->essid.length) {
6961 length = wrqu->essid.length - 1; 6961 length = wrqu->essid.length;
6962 essid = extra; 6962 essid = extra;
6963 } 6963 }
6964 6964
@@ -7051,7 +7051,7 @@ static int ipw2100_wx_get_nick(struct net_device *dev,
7051 7051
7052 struct ipw2100_priv *priv = ieee80211_priv(dev); 7052 struct ipw2100_priv *priv = ieee80211_priv(dev);
7053 7053
7054 wrqu->data.length = strlen(priv->nick) + 1; 7054 wrqu->data.length = strlen(priv->nick);
7055 memcpy(extra, priv->nick, wrqu->data.length); 7055 memcpy(extra, priv->nick, wrqu->data.length);
7056 wrqu->data.flags = 1; /* active */ 7056 wrqu->data.flags = 1; /* active */
7057 7057
@@ -7343,14 +7343,14 @@ static int ipw2100_wx_set_retry(struct net_device *dev,
7343 goto done; 7343 goto done;
7344 } 7344 }
7345 7345
7346 if (wrqu->retry.flags & IW_RETRY_MIN) { 7346 if (wrqu->retry.flags & IW_RETRY_SHORT) {
7347 err = ipw2100_set_short_retry(priv, wrqu->retry.value); 7347 err = ipw2100_set_short_retry(priv, wrqu->retry.value);
7348 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n", 7348 IPW_DEBUG_WX("SET Short Retry Limit -> %d \n",
7349 wrqu->retry.value); 7349 wrqu->retry.value);
7350 goto done; 7350 goto done;
7351 } 7351 }
7352 7352
7353 if (wrqu->retry.flags & IW_RETRY_MAX) { 7353 if (wrqu->retry.flags & IW_RETRY_LONG) {
7354 err = ipw2100_set_long_retry(priv, wrqu->retry.value); 7354 err = ipw2100_set_long_retry(priv, wrqu->retry.value);
7355 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n", 7355 IPW_DEBUG_WX("SET Long Retry Limit -> %d \n",
7356 wrqu->retry.value); 7356 wrqu->retry.value);
@@ -7383,14 +7383,14 @@ static int ipw2100_wx_get_retry(struct net_device *dev,
7383 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) 7383 if ((wrqu->retry.flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME)
7384 return -EINVAL; 7384 return -EINVAL;
7385 7385
7386 if (wrqu->retry.flags & IW_RETRY_MAX) { 7386 if (wrqu->retry.flags & IW_RETRY_LONG) {
7387 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 7387 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
7388 wrqu->retry.value = priv->long_retry_limit; 7388 wrqu->retry.value = priv->long_retry_limit;
7389 } else { 7389 } else {
7390 wrqu->retry.flags = 7390 wrqu->retry.flags =
7391 (priv->short_retry_limit != 7391 (priv->short_retry_limit !=
7392 priv->long_retry_limit) ? 7392 priv->long_retry_limit) ?
7393 IW_RETRY_LIMIT | IW_RETRY_MIN : IW_RETRY_LIMIT; 7393 IW_RETRY_LIMIT | IW_RETRY_SHORT : IW_RETRY_LIMIT;
7394 7394
7395 wrqu->retry.value = priv->short_retry_limit; 7395 wrqu->retry.value = priv->short_retry_limit;
7396 } 7396 }
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 7358664e0908..5685d7ba55bb 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -8875,8 +8875,6 @@ static int ipw_wx_set_essid(struct net_device *dev,
8875 } 8875 }
8876 8876
8877 length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE); 8877 length = min((int)wrqu->essid.length, IW_ESSID_MAX_SIZE);
8878 if (!extra[length - 1])
8879 length--;
8880 8878
8881 priv->config |= CFG_STATIC_ESSID; 8879 priv->config |= CFG_STATIC_ESSID;
8882 8880
@@ -8953,7 +8951,7 @@ static int ipw_wx_get_nick(struct net_device *dev,
8953 struct ipw_priv *priv = ieee80211_priv(dev); 8951 struct ipw_priv *priv = ieee80211_priv(dev);
8954 IPW_DEBUG_WX("Getting nick\n"); 8952 IPW_DEBUG_WX("Getting nick\n");
8955 mutex_lock(&priv->mutex); 8953 mutex_lock(&priv->mutex);
8956 wrqu->data.length = strlen(priv->nick) + 1; 8954 wrqu->data.length = strlen(priv->nick);
8957 memcpy(extra, priv->nick, wrqu->data.length); 8955 memcpy(extra, priv->nick, wrqu->data.length);
8958 wrqu->data.flags = 1; /* active */ 8956 wrqu->data.flags = 1; /* active */
8959 mutex_unlock(&priv->mutex); 8957 mutex_unlock(&priv->mutex);
@@ -9276,9 +9274,9 @@ static int ipw_wx_set_retry(struct net_device *dev,
9276 return -EINVAL; 9274 return -EINVAL;
9277 9275
9278 mutex_lock(&priv->mutex); 9276 mutex_lock(&priv->mutex);
9279 if (wrqu->retry.flags & IW_RETRY_MIN) 9277 if (wrqu->retry.flags & IW_RETRY_SHORT)
9280 priv->short_retry_limit = (u8) wrqu->retry.value; 9278 priv->short_retry_limit = (u8) wrqu->retry.value;
9281 else if (wrqu->retry.flags & IW_RETRY_MAX) 9279 else if (wrqu->retry.flags & IW_RETRY_LONG)
9282 priv->long_retry_limit = (u8) wrqu->retry.value; 9280 priv->long_retry_limit = (u8) wrqu->retry.value;
9283 else { 9281 else {
9284 priv->short_retry_limit = (u8) wrqu->retry.value; 9282 priv->short_retry_limit = (u8) wrqu->retry.value;
@@ -9307,11 +9305,11 @@ static int ipw_wx_get_retry(struct net_device *dev,
9307 return -EINVAL; 9305 return -EINVAL;
9308 } 9306 }
9309 9307
9310 if (wrqu->retry.flags & IW_RETRY_MAX) { 9308 if (wrqu->retry.flags & IW_RETRY_LONG) {
9311 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 9309 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
9312 wrqu->retry.value = priv->long_retry_limit; 9310 wrqu->retry.value = priv->long_retry_limit;
9313 } else if (wrqu->retry.flags & IW_RETRY_MIN) { 9311 } else if (wrqu->retry.flags & IW_RETRY_SHORT) {
9314 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 9312 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
9315 wrqu->retry.value = priv->short_retry_limit; 9313 wrqu->retry.value = priv->short_retry_limit;
9316 } else { 9314 } else {
9317 wrqu->retry.flags = IW_RETRY_LIMIT; 9315 wrqu->retry.flags = IW_RETRY_LIMIT;
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 1840b69e3cb5..9e19a963febc 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -3037,7 +3037,7 @@ static int orinoco_ioctl_getessid(struct net_device *dev,
3037 } 3037 }
3038 3038
3039 erq->flags = 1; 3039 erq->flags = 1;
3040 erq->length = strlen(essidbuf) + 1; 3040 erq->length = strlen(essidbuf);
3041 3041
3042 return 0; 3042 return 0;
3043} 3043}
@@ -3078,7 +3078,7 @@ static int orinoco_ioctl_getnick(struct net_device *dev,
3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1); 3078 memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE+1);
3079 orinoco_unlock(priv, &flags); 3079 orinoco_unlock(priv, &flags);
3080 3080
3081 nrq->length = strlen(nickbuf)+1; 3081 nrq->length = strlen(nickbuf);
3082 3082
3083 return 0; 3083 return 0;
3084} 3084}
@@ -3575,14 +3575,14 @@ static int orinoco_ioctl_getretry(struct net_device *dev,
3575 rrq->value = lifetime * 1000; /* ??? */ 3575 rrq->value = lifetime * 1000; /* ??? */
3576 } else { 3576 } else {
3577 /* By default, display the min number */ 3577 /* By default, display the min number */
3578 if ((rrq->flags & IW_RETRY_MAX)) { 3578 if ((rrq->flags & IW_RETRY_LONG)) {
3579 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 3579 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
3580 rrq->value = long_limit; 3580 rrq->value = long_limit;
3581 } else { 3581 } else {
3582 rrq->flags = IW_RETRY_LIMIT; 3582 rrq->flags = IW_RETRY_LIMIT;
3583 rrq->value = short_limit; 3583 rrq->value = short_limit;
3584 if(short_limit != long_limit) 3584 if(short_limit != long_limit)
3585 rrq->flags |= IW_RETRY_MIN; 3585 rrq->flags |= IW_RETRY_SHORT;
3586 } 3586 }
3587 } 3587 }
3588 3588
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c
index c09fbf733b3a..286325ca3293 100644
--- a/drivers/net/wireless/prism54/isl_ioctl.c
+++ b/drivers/net/wireless/prism54/isl_ioctl.c
@@ -742,9 +742,9 @@ prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
742 742
743 /* Check if we were asked for `any' */ 743 /* Check if we were asked for `any' */
744 if (dwrq->flags && dwrq->length) { 744 if (dwrq->flags && dwrq->length) {
745 if (dwrq->length > min(33, IW_ESSID_MAX_SIZE + 1)) 745 if (dwrq->length > 32)
746 return -E2BIG; 746 return -E2BIG;
747 essid.length = dwrq->length - 1; 747 essid.length = dwrq->length;
748 memcpy(essid.octets, extra, dwrq->length); 748 memcpy(essid.octets, extra, dwrq->length);
749 } else 749 } else
750 essid.length = 0; 750 essid.length = 0;
@@ -814,7 +814,7 @@ prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
814 dwrq->length = 0; 814 dwrq->length = 0;
815 815
816 down_read(&priv->mib_sem); 816 down_read(&priv->mib_sem);
817 dwrq->length = strlen(priv->nickname) + 1; 817 dwrq->length = strlen(priv->nickname);
818 memcpy(extra, priv->nickname, dwrq->length); 818 memcpy(extra, priv->nickname, dwrq->length);
819 up_read(&priv->mib_sem); 819 up_read(&priv->mib_sem);
820 820
@@ -992,9 +992,9 @@ prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
992 return -EINVAL; 992 return -EINVAL;
993 993
994 if (vwrq->flags & IW_RETRY_LIMIT) { 994 if (vwrq->flags & IW_RETRY_LIMIT) {
995 if (vwrq->flags & IW_RETRY_MIN) 995 if (vwrq->flags & IW_RETRY_SHORT)
996 slimit = vwrq->value; 996 slimit = vwrq->value;
997 else if (vwrq->flags & IW_RETRY_MAX) 997 else if (vwrq->flags & IW_RETRY_LONG)
998 llimit = vwrq->value; 998 llimit = vwrq->value;
999 else { 999 else {
1000 /* we are asked to set both */ 1000 /* we are asked to set both */
@@ -1035,18 +1035,18 @@ prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
1035 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r); 1035 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1036 vwrq->value = r.u * 1024; 1036 vwrq->value = r.u * 1024;
1037 vwrq->flags = IW_RETRY_LIFETIME; 1037 vwrq->flags = IW_RETRY_LIFETIME;
1038 } else if ((vwrq->flags & IW_RETRY_MAX)) { 1038 } else if ((vwrq->flags & IW_RETRY_LONG)) {
1039 /* we are asked for the long retry limit */ 1039 /* we are asked for the long retry limit */
1040 rvalue |= 1040 rvalue |=
1041 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r); 1041 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1042 vwrq->value = r.u; 1042 vwrq->value = r.u;
1043 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1043 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1044 } else { 1044 } else {
1045 /* default. get the short retry limit */ 1045 /* default. get the short retry limit */
1046 rvalue |= 1046 rvalue |=
1047 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r); 1047 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1048 vwrq->value = r.u; 1048 vwrq->value = r.u;
1049 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 1049 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1050 } 1050 }
1051 1051
1052 return rvalue; 1052 return rvalue;
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 4574290f971f..e82548ea609a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -1173,7 +1173,7 @@ static int ray_set_essid(struct net_device *dev,
1173 return -EOPNOTSUPP; 1173 return -EOPNOTSUPP;
1174 } else { 1174 } else {
1175 /* Check the size of the string */ 1175 /* Check the size of the string */
1176 if(dwrq->length > IW_ESSID_MAX_SIZE + 1) { 1176 if(dwrq->length > IW_ESSID_MAX_SIZE) {
1177 return -E2BIG; 1177 return -E2BIG;
1178 } 1178 }
1179 1179
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index e0d294c12970..e3ae5f60d5be 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1802,15 +1802,15 @@ static int wl3501_get_retry(struct net_device *dev,
1802 &retry, sizeof(retry)); 1802 &retry, sizeof(retry));
1803 if (rc) 1803 if (rc)
1804 goto out; 1804 goto out;
1805 if (wrqu->retry.flags & IW_RETRY_MAX) { 1805 if (wrqu->retry.flags & IW_RETRY_LONG) {
1806 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1806 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1807 goto set_value; 1807 goto set_value;
1808 } 1808 }
1809 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT, 1809 rc = wl3501_get_mib_value(this, WL3501_MIB_ATTR_SHORT_RETRY_LIMIT,
1810 &retry, sizeof(retry)); 1810 &retry, sizeof(retry));
1811 if (rc) 1811 if (rc)
1812 goto out; 1812 goto out;
1813 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN; 1813 wrqu->retry.flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1814set_value: 1814set_value:
1815 wrqu->retry.value = retry; 1815 wrqu->retry.value = retry;
1816 wrqu->retry.disabled = 0; 1816 wrqu->retry.disabled = 0;
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c
index c52e9bcf8d02..80af9a9fcbb3 100644
--- a/drivers/net/wireless/zd1201.c
+++ b/drivers/net/wireless/zd1201.c
@@ -119,7 +119,7 @@ static void zd1201_usbfree(struct urb *urb, struct pt_regs *regs)
119 switch(urb->status) { 119 switch(urb->status) {
120 case -EILSEQ: 120 case -EILSEQ:
121 case -ENODEV: 121 case -ENODEV:
122 case -ETIMEDOUT: 122 case -ETIME:
123 case -ENOENT: 123 case -ENOENT:
124 case -EPIPE: 124 case -EPIPE:
125 case -EOVERFLOW: 125 case -EOVERFLOW:
@@ -201,7 +201,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs)
201 switch(urb->status) { 201 switch(urb->status) {
202 case -EILSEQ: 202 case -EILSEQ:
203 case -ENODEV: 203 case -ENODEV:
204 case -ETIMEDOUT: 204 case -ETIME:
205 case -ENOENT: 205 case -ENOENT:
206 case -EPIPE: 206 case -EPIPE:
207 case -EOVERFLOW: 207 case -EOVERFLOW:
@@ -1218,7 +1218,7 @@ static int zd1201_set_essid(struct net_device *dev,
1218 return -EINVAL; 1218 return -EINVAL;
1219 if (data->length < 1) 1219 if (data->length < 1)
1220 data->length = 1; 1220 data->length = 1;
1221 zd->essidlen = data->length-1; 1221 zd->essidlen = data->length;
1222 memset(zd->essid, 0, IW_ESSID_MAX_SIZE+1); 1222 memset(zd->essid, 0, IW_ESSID_MAX_SIZE+1);
1223 memcpy(zd->essid, essid, data->length); 1223 memcpy(zd->essid, essid, data->length);
1224 return zd1201_join(zd, zd->essid, zd->essidlen); 1224 return zd1201_join(zd, zd->essid, zd->essidlen);
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index 7c4e32cf0d47..aa661b2b76c7 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -249,7 +249,6 @@ int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value)
249{ 249{
250 int r; 250 int r;
251 251
252 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
253 mutex_lock(&chip->mutex); 252 mutex_lock(&chip->mutex);
254 r = zd_ioread16_locked(chip, value, addr); 253 r = zd_ioread16_locked(chip, value, addr);
255 mutex_unlock(&chip->mutex); 254 mutex_unlock(&chip->mutex);
@@ -260,7 +259,6 @@ int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value)
260{ 259{
261 int r; 260 int r;
262 261
263 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
264 mutex_lock(&chip->mutex); 262 mutex_lock(&chip->mutex);
265 r = zd_ioread32_locked(chip, value, addr); 263 r = zd_ioread32_locked(chip, value, addr);
266 mutex_unlock(&chip->mutex); 264 mutex_unlock(&chip->mutex);
@@ -271,7 +269,6 @@ int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value)
271{ 269{
272 int r; 270 int r;
273 271
274 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
275 mutex_lock(&chip->mutex); 272 mutex_lock(&chip->mutex);
276 r = zd_iowrite16_locked(chip, value, addr); 273 r = zd_iowrite16_locked(chip, value, addr);
277 mutex_unlock(&chip->mutex); 274 mutex_unlock(&chip->mutex);
@@ -282,7 +279,6 @@ int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value)
282{ 279{
283 int r; 280 int r;
284 281
285 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
286 mutex_lock(&chip->mutex); 282 mutex_lock(&chip->mutex);
287 r = zd_iowrite32_locked(chip, value, addr); 283 r = zd_iowrite32_locked(chip, value, addr);
288 mutex_unlock(&chip->mutex); 284 mutex_unlock(&chip->mutex);
@@ -294,7 +290,6 @@ int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
294{ 290{
295 int r; 291 int r;
296 292
297 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
298 mutex_lock(&chip->mutex); 293 mutex_lock(&chip->mutex);
299 r = zd_ioread32v_locked(chip, values, addresses, count); 294 r = zd_ioread32v_locked(chip, values, addresses, count);
300 mutex_unlock(&chip->mutex); 295 mutex_unlock(&chip->mutex);
@@ -306,7 +301,6 @@ int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
306{ 301{
307 int r; 302 int r;
308 303
309 ZD_ASSERT(!mutex_is_locked(&chip->mutex));
310 mutex_lock(&chip->mutex); 304 mutex_lock(&chip->mutex);
311 r = zd_iowrite32a_locked(chip, ioreqs, count); 305 r = zd_iowrite32a_locked(chip, ioreqs, count);
312 mutex_unlock(&chip->mutex); 306 mutex_unlock(&chip->mutex);
@@ -331,13 +325,22 @@ static int read_pod(struct zd_chip *chip, u8 *rf_type)
331 chip->patch_cr157 = (value >> 13) & 0x1; 325 chip->patch_cr157 = (value >> 13) & 0x1;
332 chip->patch_6m_band_edge = (value >> 21) & 0x1; 326 chip->patch_6m_band_edge = (value >> 21) & 0x1;
333 chip->new_phy_layout = (value >> 31) & 0x1; 327 chip->new_phy_layout = (value >> 31) & 0x1;
328 chip->link_led = ((value >> 4) & 1) ? LED1 : LED2;
329 chip->supports_tx_led = 1;
330 if (value & (1 << 24)) { /* LED scenario */
331 if (value & (1 << 29))
332 chip->supports_tx_led = 0;
333 }
334 334
335 dev_dbg_f(zd_chip_dev(chip), 335 dev_dbg_f(zd_chip_dev(chip),
336 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d " 336 "RF %s %#01x PA type %#01x patch CCK %d patch CR157 %d "
337 "patch 6M %d new PHY %d\n", 337 "patch 6M %d new PHY %d link LED%d tx led %d\n",
338 zd_rf_name(*rf_type), *rf_type, 338 zd_rf_name(*rf_type), *rf_type,
339 chip->pa_type, chip->patch_cck_gain, 339 chip->pa_type, chip->patch_cck_gain,
340 chip->patch_cr157, chip->patch_6m_band_edge, chip->new_phy_layout); 340 chip->patch_cr157, chip->patch_6m_band_edge,
341 chip->new_phy_layout,
342 chip->link_led == LED1 ? 1 : 2,
343 chip->supports_tx_led);
341 return 0; 344 return 0;
342error: 345error:
343 *rf_type = 0; 346 *rf_type = 0;
@@ -1181,7 +1184,7 @@ static int update_pwr_int(struct zd_chip *chip, u8 channel)
1181 u8 value = chip->pwr_int_values[channel - 1]; 1184 u8 value = chip->pwr_int_values[channel - 1];
1182 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n", 1185 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_int %#04x\n",
1183 channel, value); 1186 channel, value);
1184 return zd_iowrite32_locked(chip, value, CR31); 1187 return zd_iowrite16_locked(chip, value, CR31);
1185} 1188}
1186 1189
1187static int update_pwr_cal(struct zd_chip *chip, u8 channel) 1190static int update_pwr_cal(struct zd_chip *chip, u8 channel)
@@ -1189,12 +1192,12 @@ static int update_pwr_cal(struct zd_chip *chip, u8 channel)
1189 u8 value = chip->pwr_cal_values[channel-1]; 1192 u8 value = chip->pwr_cal_values[channel-1];
1190 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n", 1193 dev_dbg_f(zd_chip_dev(chip), "channel %d pwr_cal %#04x\n",
1191 channel, value); 1194 channel, value);
1192 return zd_iowrite32_locked(chip, value, CR68); 1195 return zd_iowrite16_locked(chip, value, CR68);
1193} 1196}
1194 1197
1195static int update_ofdm_cal(struct zd_chip *chip, u8 channel) 1198static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
1196{ 1199{
1197 struct zd_ioreq32 ioreqs[3]; 1200 struct zd_ioreq16 ioreqs[3];
1198 1201
1199 ioreqs[0].addr = CR67; 1202 ioreqs[0].addr = CR67;
1200 ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1]; 1203 ioreqs[0].value = chip->ofdm_cal_values[OFDM_36M_INDEX][channel-1];
@@ -1206,7 +1209,7 @@ static int update_ofdm_cal(struct zd_chip *chip, u8 channel)
1206 dev_dbg_f(zd_chip_dev(chip), 1209 dev_dbg_f(zd_chip_dev(chip),
1207 "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n", 1210 "channel %d ofdm_cal 36M %#04x 48M %#04x 54M %#04x\n",
1208 channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value); 1211 channel, ioreqs[0].value, ioreqs[1].value, ioreqs[2].value);
1209 return zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 1212 return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1210} 1213}
1211 1214
1212static int update_channel_integration_and_calibration(struct zd_chip *chip, 1215static int update_channel_integration_and_calibration(struct zd_chip *chip,
@@ -1218,7 +1221,7 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip,
1218 if (r) 1221 if (r)
1219 return r; 1222 return r;
1220 if (chip->is_zd1211b) { 1223 if (chip->is_zd1211b) {
1221 static const struct zd_ioreq32 ioreqs[] = { 1224 static const struct zd_ioreq16 ioreqs[] = {
1222 { CR69, 0x28 }, 1225 { CR69, 0x28 },
1223 {}, 1226 {},
1224 { CR69, 0x2a }, 1227 { CR69, 0x2a },
@@ -1230,7 +1233,7 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip,
1230 r = update_pwr_cal(chip, channel); 1233 r = update_pwr_cal(chip, channel);
1231 if (r) 1234 if (r)
1232 return r; 1235 return r;
1233 r = zd_iowrite32a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); 1236 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1234 if (r) 1237 if (r)
1235 return r; 1238 return r;
1236 } 1239 }
@@ -1252,7 +1255,7 @@ static int patch_cck_gain(struct zd_chip *chip)
1252 if (r) 1255 if (r)
1253 return r; 1256 return r;
1254 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff); 1257 dev_dbg_f(zd_chip_dev(chip), "patching value %x\n", value & 0xff);
1255 return zd_iowrite32_locked(chip, value & 0xff, CR47); 1258 return zd_iowrite16_locked(chip, value & 0xff, CR47);
1256} 1259}
1257 1260
1258int zd_chip_set_channel(struct zd_chip *chip, u8 channel) 1261int zd_chip_set_channel(struct zd_chip *chip, u8 channel)
@@ -1295,89 +1298,60 @@ u8 zd_chip_get_channel(struct zd_chip *chip)
1295 return channel; 1298 return channel;
1296} 1299}
1297 1300
1298static u16 led_mask(int led) 1301int zd_chip_control_leds(struct zd_chip *chip, enum led_status status)
1299{ 1302{
1300 switch (led) { 1303 static const zd_addr_t a[] = {
1301 case 1: 1304 FW_LINK_STATUS,
1302 return LED1; 1305 CR_LED,
1303 case 2: 1306 };
1304 return LED2;
1305 default:
1306 return 0;
1307 }
1308}
1309
1310static int read_led_reg(struct zd_chip *chip, u16 *status)
1311{
1312 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1313 return zd_ioread16_locked(chip, status, CR_LED);
1314}
1315
1316static int write_led_reg(struct zd_chip *chip, u16 status)
1317{
1318 ZD_ASSERT(mutex_is_locked(&chip->mutex));
1319 return zd_iowrite16_locked(chip, status, CR_LED);
1320}
1321 1307
1322int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status) 1308 int r;
1323{ 1309 u16 v[ARRAY_SIZE(a)];
1324 int r, ret; 1310 struct zd_ioreq16 ioreqs[ARRAY_SIZE(a)] = {
1325 u16 mask = led_mask(led); 1311 [0] = { FW_LINK_STATUS },
1326 u16 reg; 1312 [1] = { CR_LED },
1313 };
1314 u16 other_led;
1327 1315
1328 if (!mask)
1329 return -EINVAL;
1330 mutex_lock(&chip->mutex); 1316 mutex_lock(&chip->mutex);
1331 r = read_led_reg(chip, &reg); 1317 r = zd_ioread16v_locked(chip, v, (const zd_addr_t *)a, ARRAY_SIZE(a));
1332 if (r) 1318 if (r)
1333 return r; 1319 goto out;
1320
1321 other_led = chip->link_led == LED1 ? LED2 : LED1;
1322
1334 switch (status) { 1323 switch (status) {
1335 case LED_STATUS:
1336 return (reg & mask) ? LED_ON : LED_OFF;
1337 case LED_OFF: 1324 case LED_OFF:
1338 reg &= ~mask; 1325 ioreqs[0].value = FW_LINK_OFF;
1339 ret = LED_OFF; 1326 ioreqs[1].value = v[1] & ~(LED1|LED2);
1340 break; 1327 break;
1341 case LED_FLIP: 1328 case LED_SCANNING:
1342 reg ^= mask; 1329 ioreqs[0].value = FW_LINK_OFF;
1343 ret = (reg&mask) ? LED_ON : LED_OFF; 1330 ioreqs[1].value = v[1] & ~other_led;
1331 if (get_seconds() % 3 == 0) {
1332 ioreqs[1].value &= ~chip->link_led;
1333 } else {
1334 ioreqs[1].value |= chip->link_led;
1335 }
1344 break; 1336 break;
1345 case LED_ON: 1337 case LED_ASSOCIATED:
1346 reg |= mask; 1338 ioreqs[0].value = FW_LINK_TX;
1347 ret = LED_ON; 1339 ioreqs[1].value = v[1] & ~other_led;
1340 ioreqs[1].value |= chip->link_led;
1348 break; 1341 break;
1349 default: 1342 default:
1350 return -EINVAL; 1343 r = -EINVAL;
1351 }
1352 r = write_led_reg(chip, reg);
1353 if (r) {
1354 ret = r;
1355 goto out; 1344 goto out;
1356 } 1345 }
1357out:
1358 mutex_unlock(&chip->mutex);
1359 return r;
1360}
1361
1362int zd_chip_led_flip(struct zd_chip *chip, int led,
1363 const unsigned int *phases_msecs, unsigned int count)
1364{
1365 int i, r;
1366 enum led_status status;
1367 1346
1368 r = zd_chip_led_status(chip, led, LED_STATUS); 1347 if (v[0] != ioreqs[0].value || v[1] != ioreqs[1].value) {
1369 if (r) 1348 r = zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs));
1370 return r; 1349 if (r)
1371 status = r;
1372 for (i = 0; i < count; i++) {
1373 r = zd_chip_led_status(chip, led, LED_FLIP);
1374 if (r < 0)
1375 goto out; 1350 goto out;
1376 msleep(phases_msecs[i]);
1377 } 1351 }
1378 1352 r = 0;
1379out: 1353out:
1380 zd_chip_led_status(chip, led, status); 1354 mutex_unlock(&chip->mutex);
1381 return r; 1355 return r;
1382} 1356}
1383 1357
@@ -1679,4 +1653,3 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip,
1679 1653
1680 return 0; 1654 return 0;
1681} 1655}
1682
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h
index 4b1250859897..ae59597ce4e1 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/zd1211rw/zd_chip.h
@@ -428,6 +428,7 @@
428/* masks for controlling LEDs */ 428/* masks for controlling LEDs */
429#define LED1 0x0100 429#define LED1 0x0100
430#define LED2 0x0200 430#define LED2 0x0200
431#define LED_SW 0x0400
431 432
432/* Seems to indicate that the configuration is over. 433/* Seems to indicate that the configuration is over.
433 */ 434 */
@@ -629,6 +630,10 @@
629#define FW_SOFT_RESET FW_REG(4) 630#define FW_SOFT_RESET FW_REG(4)
630#define FW_FLASH_CHK FW_REG(5) 631#define FW_FLASH_CHK FW_REG(5)
631 632
633#define FW_LINK_OFF 0x0
634#define FW_LINK_TX 0x1
635/* 0x2 - link led on? */
636
632enum { 637enum {
633 CR_BASE_OFFSET = 0x9000, 638 CR_BASE_OFFSET = 0x9000,
634 FW_START_OFFSET = 0xee00, 639 FW_START_OFFSET = 0xee00,
@@ -663,8 +668,11 @@ struct zd_chip {
663 u8 pwr_int_values[E2P_CHANNEL_COUNT]; 668 u8 pwr_int_values[E2P_CHANNEL_COUNT];
664 /* SetPointOFDM in the vendor driver */ 669 /* SetPointOFDM in the vendor driver */
665 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT]; 670 u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
666 u8 pa_type:4, patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, 671 u16 link_led;
667 new_phy_layout:1, is_zd1211b:1; 672 unsigned int pa_type:4,
673 patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
674 new_phy_layout:1,
675 is_zd1211b:1, supports_tx_led:1;
668}; 676};
669 677
670static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb) 678static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
@@ -812,15 +820,12 @@ int zd_chip_lock_phy_regs(struct zd_chip *chip);
812int zd_chip_unlock_phy_regs(struct zd_chip *chip); 820int zd_chip_unlock_phy_regs(struct zd_chip *chip);
813 821
814enum led_status { 822enum led_status {
815 LED_OFF = 0, 823 LED_OFF = 0,
816 LED_ON = 1, 824 LED_SCANNING = 1,
817 LED_FLIP = 2, 825 LED_ASSOCIATED = 2,
818 LED_STATUS = 3,
819}; 826};
820 827
821int zd_chip_led_status(struct zd_chip *chip, int led, enum led_status status); 828int zd_chip_control_leds(struct zd_chip *chip, enum led_status status);
822int zd_chip_led_flip(struct zd_chip *chip, int led,
823 const unsigned int *phases_msecs, unsigned int count);
824 829
825int zd_set_beacon_interval(struct zd_chip *chip, u32 interval); 830int zd_set_beacon_interval(struct zd_chip *chip, u32 interval);
826 831
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 1989f1c05fbe..2d12837052b0 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -33,6 +33,10 @@
33static void ieee_init(struct ieee80211_device *ieee); 33static void ieee_init(struct ieee80211_device *ieee);
34static void softmac_init(struct ieee80211softmac_device *sm); 34static void softmac_init(struct ieee80211softmac_device *sm);
35 35
36static void housekeeping_init(struct zd_mac *mac);
37static void housekeeping_enable(struct zd_mac *mac);
38static void housekeeping_disable(struct zd_mac *mac);
39
36int zd_mac_init(struct zd_mac *mac, 40int zd_mac_init(struct zd_mac *mac,
37 struct net_device *netdev, 41 struct net_device *netdev,
38 struct usb_interface *intf) 42 struct usb_interface *intf)
@@ -46,6 +50,7 @@ int zd_mac_init(struct zd_mac *mac,
46 ieee_init(ieee); 50 ieee_init(ieee);
47 softmac_init(ieee80211_priv(netdev)); 51 softmac_init(ieee80211_priv(netdev));
48 zd_chip_init(&mac->chip, netdev, intf); 52 zd_chip_init(&mac->chip, netdev, intf);
53 housekeeping_init(mac);
49 return 0; 54 return 0;
50} 55}
51 56
@@ -178,6 +183,7 @@ int zd_mac_open(struct net_device *netdev)
178 if (r < 0) 183 if (r < 0)
179 goto disable_rx; 184 goto disable_rx;
180 185
186 housekeeping_enable(mac);
181 ieee80211softmac_start(netdev); 187 ieee80211softmac_start(netdev);
182 return 0; 188 return 0;
183disable_rx: 189disable_rx:
@@ -204,6 +210,7 @@ int zd_mac_stop(struct net_device *netdev)
204 */ 210 */
205 211
206 zd_chip_disable_rx(chip); 212 zd_chip_disable_rx(chip);
213 housekeeping_disable(mac);
207 ieee80211softmac_stop(netdev); 214 ieee80211softmac_stop(netdev);
208 215
209 zd_chip_disable_hwint(chip); 216 zd_chip_disable_hwint(chip);
@@ -1080,3 +1087,46 @@ void zd_dump_rx_status(const struct rx_status *status)
1080 } 1087 }
1081} 1088}
1082#endif /* DEBUG */ 1089#endif /* DEBUG */
1090
1091#define LINK_LED_WORK_DELAY HZ
1092
1093static void link_led_handler(void *p)
1094{
1095 struct zd_mac *mac = p;
1096 struct zd_chip *chip = &mac->chip;
1097 struct ieee80211softmac_device *sm = ieee80211_priv(mac->netdev);
1098 int is_associated;
1099 int r;
1100
1101 spin_lock_irq(&mac->lock);
1102 is_associated = sm->associated != 0;
1103 spin_unlock_irq(&mac->lock);
1104
1105 r = zd_chip_control_leds(chip,
1106 is_associated ? LED_ASSOCIATED : LED_SCANNING);
1107 if (r)
1108 dev_err(zd_mac_dev(mac), "zd_chip_control_leds error %d\n", r);
1109
1110 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1111 LINK_LED_WORK_DELAY);
1112}
1113
1114static void housekeeping_init(struct zd_mac *mac)
1115{
1116 INIT_WORK(&mac->housekeeping.link_led_work, link_led_handler, mac);
1117}
1118
1119static void housekeeping_enable(struct zd_mac *mac)
1120{
1121 dev_dbg_f(zd_mac_dev(mac), "\n");
1122 queue_delayed_work(zd_workqueue, &mac->housekeeping.link_led_work,
1123 0);
1124}
1125
1126static void housekeeping_disable(struct zd_mac *mac)
1127{
1128 dev_dbg_f(zd_mac_dev(mac), "\n");
1129 cancel_rearming_delayed_workqueue(zd_workqueue,
1130 &mac->housekeeping.link_led_work);
1131 zd_chip_control_leds(&mac->chip, LED_OFF);
1132}
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 29b51fd7d4e5..b8ea3de7924a 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -120,6 +120,10 @@ enum mac_flags {
120 MAC_FIXED_CHANNEL = 0x01, 120 MAC_FIXED_CHANNEL = 0x01,
121}; 121};
122 122
123struct housekeeping {
124 struct work_struct link_led_work;
125};
126
123#define ZD_MAC_STATS_BUFFER_SIZE 16 127#define ZD_MAC_STATS_BUFFER_SIZE 16
124 128
125struct zd_mac { 129struct zd_mac {
@@ -128,6 +132,7 @@ struct zd_mac {
128 struct net_device *netdev; 132 struct net_device *netdev;
129 /* Unlocked reading possible */ 133 /* Unlocked reading possible */
130 struct iw_statistics iw_stats; 134 struct iw_statistics iw_stats;
135 struct housekeeping housekeeping;
131 unsigned int stats_count; 136 unsigned int stats_count;
132 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 137 u8 qual_buffer[ZD_MAC_STATS_BUFFER_SIZE];
133 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE]; 138 u8 rssi_buffer[ZD_MAC_STATS_BUFFER_SIZE];
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c
index 440ef24b5fd1..af3a7b36d078 100644
--- a/drivers/net/wireless/zd1211rw/zd_netdev.c
+++ b/drivers/net/wireless/zd1211rw/zd_netdev.c
@@ -82,7 +82,7 @@ static int iw_get_nick(struct net_device *netdev,
82 union iwreq_data *req, char *extra) 82 union iwreq_data *req, char *extra)
83{ 83{
84 strcpy(extra, "zd1211"); 84 strcpy(extra, "zd1211");
85 req->data.length = strlen(extra) + 1; 85 req->data.length = strlen(extra);
86 req->data.flags = 1; 86 req->data.flags = 1;
87 return 0; 87 return 0;
88} 88}
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 31027e52b04b..5c265ad0485a 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -24,6 +24,7 @@
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/skbuff.h> 25#include <linux/skbuff.h>
26#include <linux/usb.h> 26#include <linux/usb.h>
27#include <linux/workqueue.h>
27#include <net/ieee80211.h> 28#include <net/ieee80211.h>
28 29
29#include "zd_def.h" 30#include "zd_def.h"
@@ -1112,12 +1113,20 @@ static struct usb_driver driver = {
1112 .disconnect = disconnect, 1113 .disconnect = disconnect,
1113}; 1114};
1114 1115
1116struct workqueue_struct *zd_workqueue;
1117
1115static int __init usb_init(void) 1118static int __init usb_init(void)
1116{ 1119{
1117 int r; 1120 int r;
1118 1121
1119 pr_debug("usb_init()\n"); 1122 pr_debug("usb_init()\n");
1120 1123
1124 zd_workqueue = create_singlethread_workqueue(driver.name);
1125 if (zd_workqueue == NULL) {
1126 printk(KERN_ERR "%s: couldn't create workqueue\n", driver.name);
1127 return -ENOMEM;
1128 }
1129
1121 r = usb_register(&driver); 1130 r = usb_register(&driver);
1122 if (r) { 1131 if (r) {
1123 printk(KERN_ERR "usb_register() failed. Error number %d\n", r); 1132 printk(KERN_ERR "usb_register() failed. Error number %d\n", r);
@@ -1132,6 +1141,7 @@ static void __exit usb_exit(void)
1132{ 1141{
1133 pr_debug("usb_exit()\n"); 1142 pr_debug("usb_exit()\n");
1134 usb_deregister(&driver); 1143 usb_deregister(&driver);
1144 destroy_workqueue(zd_workqueue);
1135} 1145}
1136 1146
1137module_init(usb_init); 1147module_init(usb_init);
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h
index ded39de5f72d..e81a2d3cfffd 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.h
+++ b/drivers/net/wireless/zd1211rw/zd_usb.h
@@ -238,4 +238,6 @@ int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs,
238 238
239int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits); 239int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits);
240 240
241extern struct workqueue_struct *zd_workqueue;
242
241#endif /* _ZD_USB_H */ 243#endif /* _ZD_USB_H */
diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
index 71c2da277d6e..5756401fb15b 100644
--- a/drivers/oprofile/oprofilefs.c
+++ b/drivers/oprofile/oprofilefs.c
@@ -31,7 +31,6 @@ static struct inode * oprofilefs_get_inode(struct super_block * sb, int mode)
31 inode->i_mode = mode; 31 inode->i_mode = mode;
32 inode->i_uid = 0; 32 inode->i_uid = 0;
33 inode->i_gid = 0; 33 inode->i_gid = 0;
34 inode->i_blksize = PAGE_CACHE_SIZE;
35 inode->i_blocks = 0; 34 inode->i_blocks = 0;
36 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 35 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
37 } 36 }
@@ -110,8 +109,8 @@ static ssize_t ulong_write_file(struct file * file, char const __user * buf, siz
110 109
111static int default_open(struct inode * inode, struct file * filp) 110static int default_open(struct inode * inode, struct file * filp)
112{ 111{
113 if (inode->u.generic_ip) 112 if (inode->i_private)
114 filp->private_data = inode->u.generic_ip; 113 filp->private_data = inode->i_private;
115 return 0; 114 return 0;
116} 115}
117 116
@@ -158,7 +157,7 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
158 if (!d) 157 if (!d)
159 return -EFAULT; 158 return -EFAULT;
160 159
161 d->d_inode->u.generic_ip = val; 160 d->d_inode->i_private = val;
162 return 0; 161 return 0;
163} 162}
164 163
@@ -171,7 +170,7 @@ int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
171 if (!d) 170 if (!d)
172 return -EFAULT; 171 return -EFAULT;
173 172
174 d->d_inode->u.generic_ip = val; 173 d->d_inode->i_private = val;
175 return 0; 174 return 0;
176} 175}
177 176
@@ -197,7 +196,7 @@ int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
197 if (!d) 196 if (!d)
198 return -EFAULT; 197 return -EFAULT;
199 198
200 d->d_inode->u.generic_ip = val; 199 d->d_inode->i_private = val;
201 return 0; 200 return 0;
202} 201}
203 202
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index 4d762fc4878c..c27e782e6df9 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -17,6 +17,31 @@ config PCI_MSI
17 17
18 If you don't know what to do here, say N. 18 If you don't know what to do here, say N.
19 19
20config PCI_MULTITHREAD_PROBE
21 bool "PCI Multi-threaded probe (EXPERIMENTAL)"
22 depends on PCI && EXPERIMENTAL
23 help
24 Say Y here if you want the PCI core to spawn a new thread for
25 every PCI device that is probed. This can cause a huge
26 speedup in boot times on multiprocessor machines, and even a
27 smaller speedup on single processor machines.
28
29 But it can also cause lots of bad things to happen. A number
30 of PCI drivers can not properly handle running in this way,
31 some will just not work properly at all, while others might
32 decide to blow up power supplies with a huge load all at once,
33 so use this option at your own risk.
34
35 It is very unwise to use this option if you are not using a
36 boot process that can handle devices being created in any
37 order. A program that can create persistant block and network
38 device names (like udev) is a good idea if you wish to use
39 this option.
40
41 Again, use this option at your own risk, you have been warned!
42
43 When in doubt, say N.
44
20config PCI_DEBUG 45config PCI_DEBUG
21 bool "PCI Debugging" 46 bool "PCI Debugging"
22 depends on PCI && DEBUG_KERNEL 47 depends on PCI && DEBUG_KERNEL
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 5f7db9d2436e..aadaa3c8096b 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -77,9 +77,12 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
77 * This adds a single pci device to the global 77 * This adds a single pci device to the global
78 * device list and adds sysfs and procfs entries 78 * device list and adds sysfs and procfs entries
79 */ 79 */
80void __devinit pci_bus_add_device(struct pci_dev *dev) 80int __devinit pci_bus_add_device(struct pci_dev *dev)
81{ 81{
82 device_add(&dev->dev); 82 int retval;
83 retval = device_add(&dev->dev);
84 if (retval)
85 return retval;
83 86
84 down_write(&pci_bus_sem); 87 down_write(&pci_bus_sem);
85 list_add_tail(&dev->global_list, &pci_devices); 88 list_add_tail(&dev->global_list, &pci_devices);
@@ -87,6 +90,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev)
87 90
88 pci_proc_attach_device(dev); 91 pci_proc_attach_device(dev);
89 pci_create_sysfs_dev_files(dev); 92 pci_create_sysfs_dev_files(dev);
93 return 0;
90} 94}
91 95
92/** 96/**
@@ -104,6 +108,7 @@ void __devinit pci_bus_add_device(struct pci_dev *dev)
104void __devinit pci_bus_add_devices(struct pci_bus *bus) 108void __devinit pci_bus_add_devices(struct pci_bus *bus)
105{ 109{
106 struct pci_dev *dev; 110 struct pci_dev *dev;
111 int retval;
107 112
108 list_for_each_entry(dev, &bus->devices, bus_list) { 113 list_for_each_entry(dev, &bus->devices, bus_list) {
109 /* 114 /*
@@ -112,7 +117,9 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus)
112 */ 117 */
113 if (!list_empty(&dev->global_list)) 118 if (!list_empty(&dev->global_list))
114 continue; 119 continue;
115 pci_bus_add_device(dev); 120 retval = pci_bus_add_device(dev);
121 if (retval)
122 dev_err(&dev->dev, "Error adding device, continuing\n");
116 } 123 }
117 124
118 list_for_each_entry(dev, &bus->devices, bus_list) { 125 list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -129,10 +136,13 @@ void __devinit pci_bus_add_devices(struct pci_bus *bus)
129 list_add_tail(&dev->subordinate->node, 136 list_add_tail(&dev->subordinate->node,
130 &dev->bus->children); 137 &dev->bus->children);
131 up_write(&pci_bus_sem); 138 up_write(&pci_bus_sem);
132 } 139 }
133 pci_bus_add_devices(dev->subordinate); 140 pci_bus_add_devices(dev->subordinate);
134 141 retval = sysfs_create_link(&dev->subordinate->class_dev.kobj,
135 sysfs_create_link(&dev->subordinate->class_dev.kobj, &dev->dev.kobj, "bridge"); 142 &dev->dev.kobj, "bridge");
143 if (retval)
144 dev_err(&dev->dev, "Error creating sysfs "
145 "bridge symlink, continuing...\n");
136 } 146 }
137 } 147 }
138} 148}
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index be104eced34c..7fff07e877c7 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -150,6 +150,11 @@ struct acpiphp_attention_info
150 struct module *owner; 150 struct module *owner;
151}; 151};
152 152
153struct acpiphp_ioapic {
154 struct pci_dev *dev;
155 u32 gsi_base;
156 struct list_head list;
157};
153 158
154/* PCI bus bridge HID */ 159/* PCI bus bridge HID */
155#define ACPI_PCI_HOST_HID "PNP0A03" 160#define ACPI_PCI_HOST_HID "PNP0A03"
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index ae67a8f55ba1..83e8e4412de5 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -53,6 +53,8 @@
53#include "acpiphp.h" 53#include "acpiphp.h"
54 54
55static LIST_HEAD(bridge_list); 55static LIST_HEAD(bridge_list);
56static LIST_HEAD(ioapic_list);
57static DEFINE_SPINLOCK(ioapic_list_lock);
56 58
57#define MY_NAME "acpiphp_glue" 59#define MY_NAME "acpiphp_glue"
58 60
@@ -797,6 +799,7 @@ ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv)
797 struct pci_dev *pdev; 799 struct pci_dev *pdev;
798 u32 gsi_base; 800 u32 gsi_base;
799 u64 phys_addr; 801 u64 phys_addr;
802 struct acpiphp_ioapic *ioapic;
800 803
801 /* Evaluate _STA if present */ 804 /* Evaluate _STA if present */
802 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 805 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
@@ -811,41 +814,107 @@ ioapic_add(acpi_handle handle, u32 lvl, void *context, void **rv)
811 if (get_gsi_base(handle, &gsi_base)) 814 if (get_gsi_base(handle, &gsi_base))
812 return AE_OK; 815 return AE_OK;
813 816
817 ioapic = kmalloc(sizeof(*ioapic), GFP_KERNEL);
818 if (!ioapic)
819 return AE_NO_MEMORY;
820
814 pdev = get_apic_pci_info(handle); 821 pdev = get_apic_pci_info(handle);
815 if (!pdev) 822 if (!pdev)
816 return AE_OK; 823 goto exit_kfree;
817 824
818 if (pci_enable_device(pdev)) { 825 if (pci_enable_device(pdev))
819 pci_dev_put(pdev); 826 goto exit_pci_dev_put;
820 return AE_OK;
821 }
822 827
823 pci_set_master(pdev); 828 pci_set_master(pdev);
824 829
825 if (pci_request_region(pdev, 0, "I/O APIC(acpiphp)")) { 830 if (pci_request_region(pdev, 0, "I/O APIC(acpiphp)"))
826 pci_disable_device(pdev); 831 goto exit_pci_disable_device;
827 pci_dev_put(pdev);
828 return AE_OK;
829 }
830 832
831 phys_addr = pci_resource_start(pdev, 0); 833 phys_addr = pci_resource_start(pdev, 0);
832 if (acpi_register_ioapic(handle, phys_addr, gsi_base)) { 834 if (acpi_register_ioapic(handle, phys_addr, gsi_base))
833 pci_release_region(pdev, 0); 835 goto exit_pci_release_region;
834 pci_disable_device(pdev); 836
835 pci_dev_put(pdev); 837 ioapic->gsi_base = gsi_base;
838 ioapic->dev = pdev;
839 spin_lock(&ioapic_list_lock);
840 list_add_tail(&ioapic->list, &ioapic_list);
841 spin_unlock(&ioapic_list_lock);
842
843 return AE_OK;
844
845 exit_pci_release_region:
846 pci_release_region(pdev, 0);
847 exit_pci_disable_device:
848 pci_disable_device(pdev);
849 exit_pci_dev_put:
850 pci_dev_put(pdev);
851 exit_kfree:
852 kfree(ioapic);
853
854 return AE_OK;
855}
856
857static acpi_status
858ioapic_remove(acpi_handle handle, u32 lvl, void *context, void **rv)
859{
860 acpi_status status;
861 unsigned long sta;
862 acpi_handle tmp;
863 u32 gsi_base;
864 struct acpiphp_ioapic *pos, *n, *ioapic = NULL;
865
866 /* Evaluate _STA if present */
867 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
868 if (ACPI_SUCCESS(status) && sta != ACPI_STA_ALL)
869 return AE_CTRL_DEPTH;
870
871 /* Scan only PCI bus scope */
872 status = acpi_get_handle(handle, "_HID", &tmp);
873 if (ACPI_SUCCESS(status))
874 return AE_CTRL_DEPTH;
875
876 if (get_gsi_base(handle, &gsi_base))
836 return AE_OK; 877 return AE_OK;
878
879 acpi_unregister_ioapic(handle, gsi_base);
880
881 spin_lock(&ioapic_list_lock);
882 list_for_each_entry_safe(pos, n, &ioapic_list, list) {
883 if (pos->gsi_base != gsi_base)
884 continue;
885 ioapic = pos;
886 list_del(&ioapic->list);
887 break;
837 } 888 }
889 spin_unlock(&ioapic_list_lock);
890
891 if (!ioapic)
892 return AE_OK;
893
894 pci_release_region(ioapic->dev, 0);
895 pci_disable_device(ioapic->dev);
896 pci_dev_put(ioapic->dev);
897 kfree(ioapic);
838 898
839 return AE_OK; 899 return AE_OK;
840} 900}
841 901
842static int acpiphp_configure_ioapics(acpi_handle handle) 902static int acpiphp_configure_ioapics(acpi_handle handle)
843{ 903{
904 ioapic_add(handle, 0, NULL, NULL);
844 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 905 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
845 ACPI_UINT32_MAX, ioapic_add, NULL, NULL); 906 ACPI_UINT32_MAX, ioapic_add, NULL, NULL);
846 return 0; 907 return 0;
847} 908}
848 909
910static int acpiphp_unconfigure_ioapics(acpi_handle handle)
911{
912 ioapic_remove(handle, 0, NULL, NULL);
913 acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
914 ACPI_UINT32_MAX, ioapic_remove, NULL, NULL);
915 return 0;
916}
917
849static int power_on_slot(struct acpiphp_slot *slot) 918static int power_on_slot(struct acpiphp_slot *slot)
850{ 919{
851 acpi_status status; 920 acpi_status status;
@@ -997,7 +1066,7 @@ acpiphp_bus_add_out:
997 * @handle: handle to acpi namespace 1066 * @handle: handle to acpi namespace
998 * 1067 *
999 */ 1068 */
1000int acpiphp_bus_trim(acpi_handle handle) 1069static int acpiphp_bus_trim(acpi_handle handle)
1001{ 1070{
1002 struct acpi_device *device; 1071 struct acpi_device *device;
1003 int retval; 1072 int retval;
@@ -1074,10 +1143,11 @@ static int enable_device(struct acpiphp_slot *slot)
1074 1143
1075 pci_bus_assign_resources(bus); 1144 pci_bus_assign_resources(bus);
1076 acpiphp_sanitize_bus(bus); 1145 acpiphp_sanitize_bus(bus);
1146 acpiphp_set_hpp_values(slot->bridge->handle, bus);
1147 list_for_each_entry(func, &slot->funcs, sibling)
1148 acpiphp_configure_ioapics(func->handle);
1077 pci_enable_bridges(bus); 1149 pci_enable_bridges(bus);
1078 pci_bus_add_devices(bus); 1150 pci_bus_add_devices(bus);
1079 acpiphp_set_hpp_values(slot->bridge->handle, bus);
1080 acpiphp_configure_ioapics(slot->bridge->handle);
1081 1151
1082 /* associate pci_dev to our representation */ 1152 /* associate pci_dev to our representation */
1083 list_for_each (l, &slot->funcs) { 1153 list_for_each (l, &slot->funcs) {
@@ -1103,6 +1173,16 @@ static int enable_device(struct acpiphp_slot *slot)
1103 return retval; 1173 return retval;
1104} 1174}
1105 1175
1176static void disable_bridges(struct pci_bus *bus)
1177{
1178 struct pci_dev *dev;
1179 list_for_each_entry(dev, &bus->devices, bus_list) {
1180 if (dev->subordinate) {
1181 disable_bridges(dev->subordinate);
1182 pci_disable_device(dev);
1183 }
1184 }
1185}
1106 1186
1107/** 1187/**
1108 * disable_device - disable a slot 1188 * disable_device - disable a slot
@@ -1127,6 +1207,19 @@ static int disable_device(struct acpiphp_slot *slot)
1127 func->bridge = NULL; 1207 func->bridge = NULL;
1128 } 1208 }
1129 1209
1210 if (func->pci_dev) {
1211 pci_stop_bus_device(func->pci_dev);
1212 if (func->pci_dev->subordinate) {
1213 disable_bridges(func->pci_dev->subordinate);
1214 pci_disable_device(func->pci_dev);
1215 }
1216 }
1217 }
1218
1219 list_for_each (l, &slot->funcs) {
1220 func = list_entry(l, struct acpiphp_func, sibling);
1221
1222 acpiphp_unconfigure_ioapics(func->handle);
1130 acpiphp_bus_trim(func->handle); 1223 acpiphp_bus_trim(func->handle);
1131 /* try to remove anyway. 1224 /* try to remove anyway.
1132 * acpiphp_bus_add might have been failed */ 1225 * acpiphp_bus_add might have been failed */
diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
index 317457dd4014..d0a07d9ab30c 100644
--- a/drivers/pci/hotplug/acpiphp_ibm.c
+++ b/drivers/pci/hotplug/acpiphp_ibm.c
@@ -487,9 +487,7 @@ static void __exit ibm_acpiphp_exit(void)
487 if (ACPI_FAILURE(status)) 487 if (ACPI_FAILURE(status))
488 err("%s: Notification handler removal failed\n", __FUNCTION__); 488 err("%s: Notification handler removal failed\n", __FUNCTION__);
489 /* remove the /sys entries */ 489 /* remove the /sys entries */
490 if (sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr)) 490 sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr);
491 err("%s: removal of sysfs file apci_table failed\n",
492 __FUNCTION__);
493} 491}
494 492
495module_init(ibm_acpiphp_init); 493module_init(ibm_acpiphp_init);
diff --git a/drivers/pci/hotplug/cpqphp_sysfs.c b/drivers/pci/hotplug/cpqphp_sysfs.c
index 8b3da007e859..5bab666cd67e 100644
--- a/drivers/pci/hotplug/cpqphp_sysfs.c
+++ b/drivers/pci/hotplug/cpqphp_sysfs.c
@@ -140,7 +140,7 @@ struct ctrl_dbg {
140 140
141static int open(struct inode *inode, struct file *file) 141static int open(struct inode *inode, struct file *file)
142{ 142{
143 struct controller *ctrl = inode->u.generic_ip; 143 struct controller *ctrl = inode->i_private;
144 struct ctrl_dbg *dbg; 144 struct ctrl_dbg *dbg;
145 int retval = -ENOMEM; 145 int retval = -ENOMEM;
146 146
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index dd2b762777c4..05a4f0f90186 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -176,7 +176,9 @@ static void pci_rescan_slot(struct pci_dev *temp)
176 struct pci_bus *bus = temp->bus; 176 struct pci_bus *bus = temp->bus;
177 struct pci_dev *dev; 177 struct pci_dev *dev;
178 int func; 178 int func;
179 int retval;
179 u8 hdr_type; 180 u8 hdr_type;
181
180 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) { 182 if (!pci_read_config_byte(temp, PCI_HEADER_TYPE, &hdr_type)) {
181 temp->hdr_type = hdr_type & 0x7f; 183 temp->hdr_type = hdr_type & 0x7f;
182 if (!pci_find_slot(bus->number, temp->devfn)) { 184 if (!pci_find_slot(bus->number, temp->devfn)) {
@@ -185,8 +187,12 @@ static void pci_rescan_slot(struct pci_dev *temp)
185 dbg("New device on %s function %x:%x\n", 187 dbg("New device on %s function %x:%x\n",
186 bus->name, temp->devfn >> 3, 188 bus->name, temp->devfn >> 3,
187 temp->devfn & 7); 189 temp->devfn & 7);
188 pci_bus_add_device(dev); 190 retval = pci_bus_add_device(dev);
189 add_slot(dev); 191 if (retval)
192 dev_err(&dev->dev, "error adding "
193 "device, continuing.\n");
194 else
195 add_slot(dev);
190 } 196 }
191 } 197 }
192 /* multifunction device? */ 198 /* multifunction device? */
@@ -205,8 +211,12 @@ static void pci_rescan_slot(struct pci_dev *temp)
205 dbg("New device on %s function %x:%x\n", 211 dbg("New device on %s function %x:%x\n",
206 bus->name, temp->devfn >> 3, 212 bus->name, temp->devfn >> 3,
207 temp->devfn & 7); 213 temp->devfn & 7);
208 pci_bus_add_device(dev); 214 retval = pci_bus_add_device(dev);
209 add_slot(dev); 215 if (retval)
216 dev_err(&dev->dev, "error adding "
217 "device, continuing.\n");
218 else
219 add_slot(dev);
210 } 220 }
211 } 221 }
212 } 222 }
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index e929b7c11429..772523dc3860 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -172,8 +172,8 @@ struct hotplug_slot {
172 172
173extern int pci_hp_register (struct hotplug_slot *slot); 173extern int pci_hp_register (struct hotplug_slot *slot);
174extern int pci_hp_deregister (struct hotplug_slot *slot); 174extern int pci_hp_deregister (struct hotplug_slot *slot);
175extern int pci_hp_change_slot_info (struct hotplug_slot *slot, 175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
176 struct hotplug_slot_info *info); 176 struct hotplug_slot_info *info);
177extern struct subsystem pci_hotplug_slots_subsys; 177extern struct subsystem pci_hotplug_slots_subsys;
178 178
179/* PCI Setting Record (Type 0) */ 179/* PCI Setting Record (Type 0) */
diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
index b7b378df89e3..e2823ea9c4ed 100644
--- a/drivers/pci/hotplug/pci_hotplug_core.c
+++ b/drivers/pci/hotplug/pci_hotplug_core.c
@@ -482,31 +482,95 @@ static int has_test_file (struct hotplug_slot *slot)
482 482
483static int fs_add_slot (struct hotplug_slot *slot) 483static int fs_add_slot (struct hotplug_slot *slot)
484{ 484{
485 if (has_power_file(slot) == 0) 485 int retval = 0;
486 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr);
487 486
488 if (has_attention_file(slot) == 0) 487 if (has_power_file(slot) == 0) {
489 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_attention.attr); 488 retval = sysfs_create_file(&slot->kobj, &hotplug_slot_attr_power.attr);
489 if (retval)
490 goto exit_power;
491 }
490 492
491 if (has_latch_file(slot) == 0) 493 if (has_attention_file(slot) == 0) {
492 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_latch.attr); 494 retval = sysfs_create_file(&slot->kobj,
495 &hotplug_slot_attr_attention.attr);
496 if (retval)
497 goto exit_attention;
498 }
493 499
494 if (has_adapter_file(slot) == 0) 500 if (has_latch_file(slot) == 0) {
495 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_presence.attr); 501 retval = sysfs_create_file(&slot->kobj,
502 &hotplug_slot_attr_latch.attr);
503 if (retval)
504 goto exit_latch;
505 }
496 506
497 if (has_address_file(slot) == 0) 507 if (has_adapter_file(slot) == 0) {
498 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_address.attr); 508 retval = sysfs_create_file(&slot->kobj,
509 &hotplug_slot_attr_presence.attr);
510 if (retval)
511 goto exit_adapter;
512 }
499 513
500 if (has_max_bus_speed_file(slot) == 0) 514 if (has_address_file(slot) == 0) {
501 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); 515 retval = sysfs_create_file(&slot->kobj,
516 &hotplug_slot_attr_address.attr);
517 if (retval)
518 goto exit_address;
519 }
502 520
521 if (has_max_bus_speed_file(slot) == 0) {
522 retval = sysfs_create_file(&slot->kobj,
523 &hotplug_slot_attr_max_bus_speed.attr);
524 if (retval)
525 goto exit_max_speed;
526 }
527
528 if (has_cur_bus_speed_file(slot) == 0) {
529 retval = sysfs_create_file(&slot->kobj,
530 &hotplug_slot_attr_cur_bus_speed.attr);
531 if (retval)
532 goto exit_cur_speed;
533 }
534
535 if (has_test_file(slot) == 0) {
536 retval = sysfs_create_file(&slot->kobj,
537 &hotplug_slot_attr_test.attr);
538 if (retval)
539 goto exit_test;
540 }
541
542 goto exit;
543
544exit_test:
503 if (has_cur_bus_speed_file(slot) == 0) 545 if (has_cur_bus_speed_file(slot) == 0)
504 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); 546 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr);
505 547
506 if (has_test_file(slot) == 0) 548exit_cur_speed:
507 sysfs_create_file(&slot->kobj, &hotplug_slot_attr_test.attr); 549 if (has_max_bus_speed_file(slot) == 0)
550 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr);
508 551
509 return 0; 552exit_max_speed:
553 if (has_address_file(slot) == 0)
554 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_address.attr);
555
556exit_address:
557 if (has_adapter_file(slot) == 0)
558 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_presence.attr);
559
560exit_adapter:
561 if (has_latch_file(slot) == 0)
562 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_latch.attr);
563
564exit_latch:
565 if (has_attention_file(slot) == 0)
566 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_attention.attr);
567
568exit_attention:
569 if (has_power_file(slot) == 0)
570 sysfs_remove_file(&slot->kobj, &hotplug_slot_attr_power.attr);
571exit_power:
572exit:
573 return retval;
510} 574}
511 575
512static void fs_remove_slot (struct hotplug_slot *slot) 576static void fs_remove_slot (struct hotplug_slot *slot)
@@ -626,8 +690,11 @@ int pci_hp_deregister (struct hotplug_slot *slot)
626 * 690 *
627 * Returns 0 if successful, anything else for an error. 691 * Returns 0 if successful, anything else for an error.
628 */ 692 */
629int pci_hp_change_slot_info (struct hotplug_slot *slot, struct hotplug_slot_info *info) 693int __must_check pci_hp_change_slot_info(struct hotplug_slot *slot,
694 struct hotplug_slot_info *info)
630{ 695{
696 int retval;
697
631 if ((slot == NULL) || (info == NULL)) 698 if ((slot == NULL) || (info == NULL))
632 return -ENODEV; 699 return -ENODEV;
633 700
@@ -636,32 +703,60 @@ int pci_hp_change_slot_info (struct hotplug_slot *slot, struct hotplug_slot_info
636 * for the files referring to the fields that have now changed. 703 * for the files referring to the fields that have now changed.
637 */ 704 */
638 if ((has_power_file(slot) == 0) && 705 if ((has_power_file(slot) == 0) &&
639 (slot->info->power_status != info->power_status)) 706 (slot->info->power_status != info->power_status)) {
640 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_power.attr); 707 retval = sysfs_update_file(&slot->kobj,
708 &hotplug_slot_attr_power.attr);
709 if (retval)
710 return retval;
711 }
641 712
642 if ((has_attention_file(slot) == 0) && 713 if ((has_attention_file(slot) == 0) &&
643 (slot->info->attention_status != info->attention_status)) 714 (slot->info->attention_status != info->attention_status)) {
644 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_attention.attr); 715 retval = sysfs_update_file(&slot->kobj,
716 &hotplug_slot_attr_attention.attr);
717 if (retval)
718 return retval;
719 }
645 720
646 if ((has_latch_file(slot) == 0) && 721 if ((has_latch_file(slot) == 0) &&
647 (slot->info->latch_status != info->latch_status)) 722 (slot->info->latch_status != info->latch_status)) {
648 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_latch.attr); 723 retval = sysfs_update_file(&slot->kobj,
724 &hotplug_slot_attr_latch.attr);
725 if (retval)
726 return retval;
727 }
649 728
650 if ((has_adapter_file(slot) == 0) && 729 if ((has_adapter_file(slot) == 0) &&
651 (slot->info->adapter_status != info->adapter_status)) 730 (slot->info->adapter_status != info->adapter_status)) {
652 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_presence.attr); 731 retval = sysfs_update_file(&slot->kobj,
732 &hotplug_slot_attr_presence.attr);
733 if (retval)
734 return retval;
735 }
653 736
654 if ((has_address_file(slot) == 0) && 737 if ((has_address_file(slot) == 0) &&
655 (slot->info->address != info->address)) 738 (slot->info->address != info->address)) {
656 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_address.attr); 739 retval = sysfs_update_file(&slot->kobj,
740 &hotplug_slot_attr_address.attr);
741 if (retval)
742 return retval;
743 }
657 744
658 if ((has_max_bus_speed_file(slot) == 0) && 745 if ((has_max_bus_speed_file(slot) == 0) &&
659 (slot->info->max_bus_speed != info->max_bus_speed)) 746 (slot->info->max_bus_speed != info->max_bus_speed)) {
660 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_max_bus_speed.attr); 747 retval = sysfs_update_file(&slot->kobj,
748 &hotplug_slot_attr_max_bus_speed.attr);
749 if (retval)
750 return retval;
751 }
661 752
662 if ((has_cur_bus_speed_file(slot) == 0) && 753 if ((has_cur_bus_speed_file(slot) == 0) &&
663 (slot->info->cur_bus_speed != info->cur_bus_speed)) 754 (slot->info->cur_bus_speed != info->cur_bus_speed)) {
664 sysfs_update_file(&slot->kobj, &hotplug_slot_attr_cur_bus_speed.attr); 755 retval = sysfs_update_file(&slot->kobj,
756 &hotplug_slot_attr_cur_bus_speed.attr);
757 if (retval)
758 return retval;
759 }
665 760
666 memcpy (slot->info, info, sizeof (struct hotplug_slot_info)); 761 memcpy (slot->info, info, sizeof (struct hotplug_slot_info));
667 762
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 33d198768356..41290a106bd8 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -762,14 +762,14 @@ int pciehp_enable_slot(struct slot *p_slot)
762 if (rc || !getstatus) { 762 if (rc || !getstatus) {
763 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 763 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
764 mutex_unlock(&p_slot->ctrl->crit_sect); 764 mutex_unlock(&p_slot->ctrl->crit_sect);
765 return 1; 765 return -ENODEV;
766 } 766 }
767 if (MRL_SENS(p_slot->ctrl->ctrlcap)) { 767 if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
768 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 768 rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
769 if (rc || getstatus) { 769 if (rc || getstatus) {
770 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 770 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
771 mutex_unlock(&p_slot->ctrl->crit_sect); 771 mutex_unlock(&p_slot->ctrl->crit_sect);
772 return 1; 772 return -ENODEV;
773 } 773 }
774 } 774 }
775 775
@@ -778,7 +778,7 @@ int pciehp_enable_slot(struct slot *p_slot)
778 if (rc || getstatus) { 778 if (rc || getstatus) {
779 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number); 779 info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
780 mutex_unlock(&p_slot->ctrl->crit_sect); 780 mutex_unlock(&p_slot->ctrl->crit_sect);
781 return 1; 781 return -EINVAL;
782 } 782 }
783 } 783 }
784 mutex_unlock(&p_slot->ctrl->crit_sect); 784 mutex_unlock(&p_slot->ctrl->crit_sect);
@@ -813,7 +813,7 @@ int pciehp_disable_slot(struct slot *p_slot)
813 if (ret || !getstatus) { 813 if (ret || !getstatus) {
814 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number); 814 info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
815 mutex_unlock(&p_slot->ctrl->crit_sect); 815 mutex_unlock(&p_slot->ctrl->crit_sect);
816 return 1; 816 return -ENODEV;
817 } 817 }
818 } 818 }
819 819
@@ -822,7 +822,7 @@ int pciehp_disable_slot(struct slot *p_slot)
822 if (ret || getstatus) { 822 if (ret || getstatus) {
823 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number); 823 info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
824 mutex_unlock(&p_slot->ctrl->crit_sect); 824 mutex_unlock(&p_slot->ctrl->crit_sect);
825 return 1; 825 return -ENODEV;
826 } 826 }
827 } 827 }
828 828
@@ -831,7 +831,7 @@ int pciehp_disable_slot(struct slot *p_slot)
831 if (ret || !getstatus) { 831 if (ret || !getstatus) {
832 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number); 832 info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
833 mutex_unlock(&p_slot->ctrl->crit_sect); 833 mutex_unlock(&p_slot->ctrl->crit_sect);
834 return 1; 834 return -EINVAL;
835 } 835 }
836 } 836 }
837 837
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 8ad446605f75..2b9e10e38613 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * PCI Hot Plug Controller Skeleton Driver - 0.2 2 * PCI Hot Plug Controller Skeleton Driver - 0.3
3 * 3 *
4 * Copyright (C) 2001,2003 Greg Kroah-Hartman (greg@kroah.com) 4 * Copyright (C) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
5 * Copyright (C) 2001,2003 IBM Corp. 5 * Copyright (C) 2001,2003 IBM Corp.
@@ -21,7 +21,7 @@
21 * along with this program; if not, write to the Free Software 21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * 23 *
24 * This driver is to be used as a skeleton driver to be show how to interface 24 * This driver is to be used as a skeleton driver to show how to interface
25 * with the pci hotplug core easily. 25 * with the pci hotplug core easily.
26 * 26 *
27 * Send feedback to <greg@kroah.com> 27 * Send feedback to <greg@kroah.com>
@@ -58,8 +58,6 @@ static LIST_HEAD(slot_list);
58#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg) 58#define info(format, arg...) printk(KERN_INFO "%s: " format "\n", MY_NAME , ## arg)
59#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg) 59#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
60 60
61
62
63/* local variables */ 61/* local variables */
64static int debug; 62static int debug;
65static int num_slots; 63static int num_slots;
@@ -109,7 +107,6 @@ static int enable_slot(struct hotplug_slot *hotplug_slot)
109 return retval; 107 return retval;
110} 108}
111 109
112
113static int disable_slot(struct hotplug_slot *hotplug_slot) 110static int disable_slot(struct hotplug_slot *hotplug_slot)
114{ 111{
115 struct slot *slot = hotplug_slot->private; 112 struct slot *slot = hotplug_slot->private;
@@ -342,7 +339,7 @@ static int __init pcihp_skel_init(void)
342 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 339 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
343 /* 340 /*
344 * Do specific initialization stuff for your driver here 341 * Do specific initialization stuff for your driver here
345 * Like initializing your controller hardware (if any) and 342 * like initializing your controller hardware (if any) and
346 * determining the number of slots you have in the system 343 * determining the number of slots you have in the system
347 * right now. 344 * right now.
348 */ 345 */
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 7208b95c6ee7..c7103ac5cd06 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -173,7 +173,7 @@ struct controller {
173#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n" 173#define msg_button_cancel "PCI slot #%s - action canceled due to button press.\n"
174 174
175/* sysfs functions for the hotplug controller info */ 175/* sysfs functions for the hotplug controller info */
176extern void shpchp_create_ctrl_files (struct controller *ctrl); 176extern int __must_check shpchp_create_ctrl_files(struct controller *ctrl);
177 177
178extern int shpchp_sysfs_enable_slot(struct slot *slot); 178extern int shpchp_sysfs_enable_slot(struct slot *slot);
179extern int shpchp_sysfs_disable_slot(struct slot *slot); 179extern int shpchp_sysfs_disable_slot(struct slot *slot);
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index a14e7de19846..235c18a22393 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -449,10 +449,14 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
449 ctrl->speed = PCI_SPEED_33MHz; 449 ctrl->speed = PCI_SPEED_33MHz;
450 } 450 }
451 451
452 shpchp_create_ctrl_files(ctrl); 452 rc = shpchp_create_ctrl_files(ctrl);
453 if (rc)
454 goto err_cleanup_slots;
453 455
454 return 0; 456 return 0;
455 457
458err_cleanup_slots:
459 cleanup_slots(ctrl);
456err_out_release_ctlr: 460err_out_release_ctlr:
457 ctrl->hpc_ops->release_ctlr(ctrl); 461 ctrl->hpc_ops->release_ctlr(ctrl);
458err_out_free_ctrl: 462err_out_free_ctrl:
diff --git a/drivers/pci/hotplug/shpchp_sysfs.c b/drivers/pci/hotplug/shpchp_sysfs.c
index 620e1139e607..29fa9d26adae 100644
--- a/drivers/pci/hotplug/shpchp_sysfs.c
+++ b/drivers/pci/hotplug/shpchp_sysfs.c
@@ -91,9 +91,9 @@ static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, cha
91} 91}
92static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL); 92static DEVICE_ATTR (ctrl, S_IRUGO, show_ctrl, NULL);
93 93
94void shpchp_create_ctrl_files (struct controller *ctrl) 94int __must_check shpchp_create_ctrl_files (struct controller *ctrl)
95{ 95{
96 device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl); 96 return device_create_file (&ctrl->pci_dev->dev, &dev_attr_ctrl);
97} 97}
98 98
99void shpchp_remove_ctrl_files(struct controller *ctrl) 99void shpchp_remove_ctrl_files(struct controller *ctrl)
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index a83c1f5735d6..27a057409eca 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -45,16 +45,10 @@ msi_register(struct msi_ops *ops)
45 return 0; 45 return 0;
46} 46}
47 47
48static void msi_cache_ctor(void *p, kmem_cache_t *cache, unsigned long flags)
49{
50 memset(p, 0, sizeof(struct msi_desc));
51}
52
53static int msi_cache_init(void) 48static int msi_cache_init(void)
54{ 49{
55 msi_cachep = kmem_cache_create("msi_cache", 50 msi_cachep = kmem_cache_create("msi_cache", sizeof(struct msi_desc),
56 sizeof(struct msi_desc), 51 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
57 0, SLAB_HWCACHE_ALIGN, msi_cache_ctor, NULL);
58 if (!msi_cachep) 52 if (!msi_cachep)
59 return -ENOMEM; 53 return -ENOMEM;
60 54
@@ -402,11 +396,10 @@ static struct msi_desc* alloc_msi_entry(void)
402{ 396{
403 struct msi_desc *entry; 397 struct msi_desc *entry;
404 398
405 entry = kmem_cache_alloc(msi_cachep, SLAB_KERNEL); 399 entry = kmem_cache_zalloc(msi_cachep, GFP_KERNEL);
406 if (!entry) 400 if (!entry)
407 return NULL; 401 return NULL;
408 402
409 memset(entry, 0, sizeof(struct msi_desc));
410 entry->link.tail = entry->link.head = 0; /* single message */ 403 entry->link.tail = entry->link.head = 0; /* single message */
411 entry->dev = NULL; 404 entry->dev = NULL;
412 405
@@ -901,6 +894,33 @@ static int msix_capability_init(struct pci_dev *dev,
901} 894}
902 895
903/** 896/**
897 * pci_msi_supported - check whether MSI may be enabled on device
898 * @dev: pointer to the pci_dev data structure of MSI device function
899 *
900 * MSI must be globally enabled and supported by the device and its root
901 * bus. But, the root bus is not easy to find since some architectures
902 * have virtual busses on top of the PCI hierarchy (for instance the
903 * hypertransport bus), while the actual bus where MSI must be supported
904 * is below. So we test the MSI flag on all parent busses and assume
905 * that no quirk will ever set the NO_MSI flag on a non-root bus.
906 **/
907static
908int pci_msi_supported(struct pci_dev * dev)
909{
910 struct pci_bus *bus;
911
912 if (!pci_msi_enable || !dev || dev->no_msi)
913 return -EINVAL;
914
915 /* check MSI flags of all parent busses */
916 for (bus = dev->bus; bus; bus = bus->parent)
917 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
918 return -EINVAL;
919
920 return 0;
921}
922
923/**
904 * pci_enable_msi - configure device's MSI capability structure 924 * pci_enable_msi - configure device's MSI capability structure
905 * @dev: pointer to the pci_dev data structure of MSI device function 925 * @dev: pointer to the pci_dev data structure of MSI device function
906 * 926 *
@@ -912,19 +932,11 @@ static int msix_capability_init(struct pci_dev *dev,
912 **/ 932 **/
913int pci_enable_msi(struct pci_dev* dev) 933int pci_enable_msi(struct pci_dev* dev)
914{ 934{
915 struct pci_bus *bus; 935 int pos, temp, status;
916 int pos, temp, status = -EINVAL;
917 u16 control; 936 u16 control;
918 937
919 if (!pci_msi_enable || !dev) 938 if (pci_msi_supported(dev) < 0)
920 return status; 939 return -EINVAL;
921
922 if (dev->no_msi)
923 return status;
924
925 for (bus = dev->bus; bus; bus = bus->parent)
926 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
927 return -EINVAL;
928 940
929 temp = dev->irq; 941 temp = dev->irq;
930 942
@@ -1134,22 +1146,14 @@ static int reroute_msix_table(int head, struct msix_entry *entries, int *nvec)
1134 **/ 1146 **/
1135int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) 1147int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
1136{ 1148{
1137 struct pci_bus *bus;
1138 int status, pos, nr_entries, free_vectors; 1149 int status, pos, nr_entries, free_vectors;
1139 int i, j, temp; 1150 int i, j, temp;
1140 u16 control; 1151 u16 control;
1141 unsigned long flags; 1152 unsigned long flags;
1142 1153
1143 if (!pci_msi_enable || !dev || !entries) 1154 if (!entries || pci_msi_supported(dev) < 0)
1144 return -EINVAL; 1155 return -EINVAL;
1145 1156
1146 if (dev->no_msi)
1147 return -EINVAL;
1148
1149 for (bus = dev->bus; bus; bus = bus->parent)
1150 if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
1151 return -EINVAL;
1152
1153 status = msi_init(); 1157 status = msi_init();
1154 if (status < 0) 1158 if (status < 0)
1155 return status; 1159 return status;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 474e9cd0e9e4..b1c0c707d96c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -17,6 +17,16 @@
17 * Registration of PCI drivers and handling of hot-pluggable devices. 17 * Registration of PCI drivers and handling of hot-pluggable devices.
18 */ 18 */
19 19
20/* multithreaded probe logic */
21static int pci_multithread_probe =
22#ifdef CONFIG_PCI_MULTITHREAD_PROBE
23 1;
24#else
25 0;
26#endif
27__module_param_call("", pci_multithread_probe, param_set_bool, param_get_bool, &pci_multithread_probe, 0644);
28
29
20/* 30/*
21 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG 31 * Dynamic device IDs are disabled for !CONFIG_HOTPLUG
22 */ 32 */
@@ -46,6 +56,7 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
46 subdevice=PCI_ANY_ID, class=0, class_mask=0; 56 subdevice=PCI_ANY_ID, class=0, class_mask=0;
47 unsigned long driver_data=0; 57 unsigned long driver_data=0;
48 int fields=0; 58 int fields=0;
59 int retval = 0;
49 60
50 fields = sscanf(buf, "%x %x %x %x %x %x %lux", 61 fields = sscanf(buf, "%x %x %x %x %x %x %lux",
51 &vendor, &device, &subvendor, &subdevice, 62 &vendor, &device, &subvendor, &subdevice,
@@ -72,10 +83,12 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
72 spin_unlock(&pdrv->dynids.lock); 83 spin_unlock(&pdrv->dynids.lock);
73 84
74 if (get_driver(&pdrv->driver)) { 85 if (get_driver(&pdrv->driver)) {
75 driver_attach(&pdrv->driver); 86 retval = driver_attach(&pdrv->driver);
76 put_driver(&pdrv->driver); 87 put_driver(&pdrv->driver);
77 } 88 }
78 89
90 if (retval)
91 return retval;
79 return count; 92 return count;
80} 93}
81static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 94static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
@@ -279,6 +292,18 @@ static int pci_device_suspend(struct device * dev, pm_message_t state)
279 return i; 292 return i;
280} 293}
281 294
295static int pci_device_suspend_late(struct device * dev, pm_message_t state)
296{
297 struct pci_dev * pci_dev = to_pci_dev(dev);
298 struct pci_driver * drv = pci_dev->driver;
299 int i = 0;
300
301 if (drv && drv->suspend_late) {
302 i = drv->suspend_late(pci_dev, state);
303 suspend_report_result(drv->suspend_late, i);
304 }
305 return i;
306}
282 307
283/* 308/*
284 * Default resume method for devices that have no driver provided resume, 309 * Default resume method for devices that have no driver provided resume,
@@ -313,6 +338,17 @@ static int pci_device_resume(struct device * dev)
313 return error; 338 return error;
314} 339}
315 340
341static int pci_device_resume_early(struct device * dev)
342{
343 int error = 0;
344 struct pci_dev * pci_dev = to_pci_dev(dev);
345 struct pci_driver * drv = pci_dev->driver;
346
347 if (drv && drv->resume_early)
348 error = drv->resume_early(pci_dev);
349 return error;
350}
351
316static void pci_device_shutdown(struct device *dev) 352static void pci_device_shutdown(struct device *dev)
317{ 353{
318 struct pci_dev *pci_dev = to_pci_dev(dev); 354 struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -386,6 +422,11 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
386 drv->driver.owner = owner; 422 drv->driver.owner = owner;
387 drv->driver.kobj.ktype = &pci_driver_kobj_type; 423 drv->driver.kobj.ktype = &pci_driver_kobj_type;
388 424
425 if (pci_multithread_probe)
426 drv->driver.multithread_probe = pci_multithread_probe;
427 else
428 drv->driver.multithread_probe = drv->multithread_probe;
429
389 spin_lock_init(&drv->dynids.lock); 430 spin_lock_init(&drv->dynids.lock);
390 INIT_LIST_HEAD(&drv->dynids.list); 431 INIT_LIST_HEAD(&drv->dynids.list);
391 432
@@ -509,8 +550,10 @@ struct bus_type pci_bus_type = {
509 .probe = pci_device_probe, 550 .probe = pci_device_probe,
510 .remove = pci_device_remove, 551 .remove = pci_device_remove,
511 .suspend = pci_device_suspend, 552 .suspend = pci_device_suspend,
512 .shutdown = pci_device_shutdown, 553 .suspend_late = pci_device_suspend_late,
554 .resume_early = pci_device_resume_early,
513 .resume = pci_device_resume, 555 .resume = pci_device_resume,
556 .shutdown = pci_device_shutdown,
514 .dev_attrs = pci_dev_attrs, 557 .dev_attrs = pci_dev_attrs,
515}; 558};
516 559
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index fdefa7dcd156..a1d2e979b17f 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -117,6 +117,7 @@ is_enabled_store(struct device *dev, struct device_attribute *attr,
117 const char *buf, size_t count) 117 const char *buf, size_t count)
118{ 118{
119 struct pci_dev *pdev = to_pci_dev(dev); 119 struct pci_dev *pdev = to_pci_dev(dev);
120 int retval = 0;
120 121
121 /* this can crash the machine when done on the "wrong" device */ 122 /* this can crash the machine when done on the "wrong" device */
122 if (!capable(CAP_SYS_ADMIN)) 123 if (!capable(CAP_SYS_ADMIN))
@@ -126,11 +127,53 @@ is_enabled_store(struct device *dev, struct device_attribute *attr,
126 pci_disable_device(pdev); 127 pci_disable_device(pdev);
127 128
128 if (*buf == '1') 129 if (*buf == '1')
129 pci_enable_device(pdev); 130 retval = pci_enable_device(pdev);
130 131
132 if (retval)
133 return retval;
131 return count; 134 return count;
132} 135}
133 136
137static ssize_t
138msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf)
139{
140 struct pci_dev *pdev = to_pci_dev(dev);
141
142 if (!pdev->subordinate)
143 return 0;
144
145 return sprintf (buf, "%u\n",
146 !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI));
147}
148
149static ssize_t
150msi_bus_store(struct device *dev, struct device_attribute *attr,
151 const char *buf, size_t count)
152{
153 struct pci_dev *pdev = to_pci_dev(dev);
154
155 /* bad things may happen if the no_msi flag is changed
156 * while some drivers are loaded */
157 if (!capable(CAP_SYS_ADMIN))
158 return count;
159
160 if (!pdev->subordinate)
161 return count;
162
163 if (*buf == '0') {
164 pdev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
165 dev_warn(&pdev->dev, "forced subordinate bus to not support MSI,"
166 " bad things could happen.\n");
167 }
168
169 if (*buf == '1') {
170 pdev->subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI;
171 dev_warn(&pdev->dev, "forced subordinate bus to support MSI,"
172 " bad things could happen.\n");
173 }
174
175 return count;
176}
134 177
135struct device_attribute pci_dev_attrs[] = { 178struct device_attribute pci_dev_attrs[] = {
136 __ATTR_RO(resource), 179 __ATTR_RO(resource),
@@ -145,6 +188,7 @@ struct device_attribute pci_dev_attrs[] = {
145 __ATTR(enable, 0600, is_enabled_show, is_enabled_store), 188 __ATTR(enable, 0600, is_enabled_show, is_enabled_store),
146 __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), 189 __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR),
147 broken_parity_status_show,broken_parity_status_store), 190 broken_parity_status_show,broken_parity_status_store),
191 __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store),
148 __ATTR_NULL, 192 __ATTR_NULL,
149}; 193};
150 194
@@ -385,15 +429,38 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
385} 429}
386 430
387/** 431/**
432 * pci_remove_resource_files - cleanup resource files
433 * @dev: dev to cleanup
434 *
435 * If we created resource files for @dev, remove them from sysfs and
436 * free their resources.
437 */
438static void
439pci_remove_resource_files(struct pci_dev *pdev)
440{
441 int i;
442
443 for (i = 0; i < PCI_ROM_RESOURCE; i++) {
444 struct bin_attribute *res_attr;
445
446 res_attr = pdev->res_attr[i];
447 if (res_attr) {
448 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr);
449 kfree(res_attr);
450 }
451 }
452}
453
454/**
388 * pci_create_resource_files - create resource files in sysfs for @dev 455 * pci_create_resource_files - create resource files in sysfs for @dev
389 * @dev: dev in question 456 * @dev: dev in question
390 * 457 *
391 * Walk the resources in @dev creating files for each resource available. 458 * Walk the resources in @dev creating files for each resource available.
392 */ 459 */
393static void 460static int pci_create_resource_files(struct pci_dev *pdev)
394pci_create_resource_files(struct pci_dev *pdev)
395{ 461{
396 int i; 462 int i;
463 int retval;
397 464
398 /* Expose the PCI resources from this device as files */ 465 /* Expose the PCI resources from this device as files */
399 for (i = 0; i < PCI_ROM_RESOURCE; i++) { 466 for (i = 0; i < PCI_ROM_RESOURCE; i++) {
@@ -416,35 +483,19 @@ pci_create_resource_files(struct pci_dev *pdev)
416 res_attr->size = pci_resource_len(pdev, i); 483 res_attr->size = pci_resource_len(pdev, i);
417 res_attr->mmap = pci_mmap_resource; 484 res_attr->mmap = pci_mmap_resource;
418 res_attr->private = &pdev->resource[i]; 485 res_attr->private = &pdev->resource[i];
419 sysfs_create_bin_file(&pdev->dev.kobj, res_attr); 486 retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
420 } 487 if (retval) {
421 } 488 pci_remove_resource_files(pdev);
422} 489 return retval;
423 490 }
424/** 491 } else {
425 * pci_remove_resource_files - cleanup resource files 492 return -ENOMEM;
426 * @dev: dev to cleanup
427 *
428 * If we created resource files for @dev, remove them from sysfs and
429 * free their resources.
430 */
431static void
432pci_remove_resource_files(struct pci_dev *pdev)
433{
434 int i;
435
436 for (i = 0; i < PCI_ROM_RESOURCE; i++) {
437 struct bin_attribute *res_attr;
438
439 res_attr = pdev->res_attr[i];
440 if (res_attr) {
441 sysfs_remove_bin_file(&pdev->dev.kobj, res_attr);
442 kfree(res_attr);
443 } 493 }
444 } 494 }
495 return 0;
445} 496}
446#else /* !HAVE_PCI_MMAP */ 497#else /* !HAVE_PCI_MMAP */
447static inline void pci_create_resource_files(struct pci_dev *dev) { return; } 498static inline int pci_create_resource_files(struct pci_dev *dev) { return 0; }
448static inline void pci_remove_resource_files(struct pci_dev *dev) { return; } 499static inline void pci_remove_resource_files(struct pci_dev *dev) { return; }
449#endif /* HAVE_PCI_MMAP */ 500#endif /* HAVE_PCI_MMAP */
450 501
@@ -529,22 +580,27 @@ static struct bin_attribute pcie_config_attr = {
529 .write = pci_write_config, 580 .write = pci_write_config,
530}; 581};
531 582
532int pci_create_sysfs_dev_files (struct pci_dev *pdev) 583int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
533{ 584{
585 struct bin_attribute *rom_attr = NULL;
586 int retval;
587
534 if (!sysfs_initialized) 588 if (!sysfs_initialized)
535 return -EACCES; 589 return -EACCES;
536 590
537 if (pdev->cfg_size < 4096) 591 if (pdev->cfg_size < 4096)
538 sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); 592 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr);
539 else 593 else
540 sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); 594 retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
595 if (retval)
596 goto err;
541 597
542 pci_create_resource_files(pdev); 598 retval = pci_create_resource_files(pdev);
599 if (retval)
600 goto err_bin_file;
543 601
544 /* If the device has a ROM, try to expose it in sysfs. */ 602 /* If the device has a ROM, try to expose it in sysfs. */
545 if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { 603 if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) {
546 struct bin_attribute *rom_attr;
547
548 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); 604 rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC);
549 if (rom_attr) { 605 if (rom_attr) {
550 pdev->rom_attr = rom_attr; 606 pdev->rom_attr = rom_attr;
@@ -554,13 +610,28 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev)
554 rom_attr->attr.owner = THIS_MODULE; 610 rom_attr->attr.owner = THIS_MODULE;
555 rom_attr->read = pci_read_rom; 611 rom_attr->read = pci_read_rom;
556 rom_attr->write = pci_write_rom; 612 rom_attr->write = pci_write_rom;
557 sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); 613 retval = sysfs_create_bin_file(&pdev->dev.kobj, rom_attr);
614 if (retval)
615 goto err_rom;
616 } else {
617 retval = -ENOMEM;
618 goto err_bin_file;
558 } 619 }
559 } 620 }
560 /* add platform-specific attributes */ 621 /* add platform-specific attributes */
561 pcibios_add_platform_entries(pdev); 622 pcibios_add_platform_entries(pdev);
562 623
563 return 0; 624 return 0;
625
626err_rom:
627 kfree(rom_attr);
628err_bin_file:
629 if (pdev->cfg_size < 4096)
630 sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr);
631 else
632 sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr);
633err:
634 return retval;
564} 635}
565 636
566/** 637/**
@@ -589,10 +660,14 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
589static int __init pci_sysfs_init(void) 660static int __init pci_sysfs_init(void)
590{ 661{
591 struct pci_dev *pdev = NULL; 662 struct pci_dev *pdev = NULL;
592 663 int retval;
664
593 sysfs_initialized = 1; 665 sysfs_initialized = 1;
594 for_each_pci_dev(pdev) 666 for_each_pci_dev(pdev) {
595 pci_create_sysfs_dev_files(pdev); 667 retval = pci_create_sysfs_dev_files(pdev);
668 if (retval)
669 return retval;
670 }
596 671
597 return 0; 672 return 0;
598} 673}
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 9f79dd6d51ab..a544997399b3 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -432,10 +432,12 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
432 case PM_EVENT_ON: 432 case PM_EVENT_ON:
433 return PCI_D0; 433 return PCI_D0;
434 case PM_EVENT_FREEZE: 434 case PM_EVENT_FREEZE:
435 case PM_EVENT_PRETHAW:
436 /* REVISIT both freeze and pre-thaw "should" use D0 */
435 case PM_EVENT_SUSPEND: 437 case PM_EVENT_SUSPEND:
436 return PCI_D3hot; 438 return PCI_D3hot;
437 default: 439 default:
438 printk("They asked me for state %d\n", state.event); 440 printk("Unrecognized suspend event %d\n", state.event);
439 BUG(); 441 BUG();
440 } 442 }
441 return PCI_D0; 443 return PCI_D0;
@@ -443,6 +445,51 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
443 445
444EXPORT_SYMBOL(pci_choose_state); 446EXPORT_SYMBOL(pci_choose_state);
445 447
448static int pci_save_pcie_state(struct pci_dev *dev)
449{
450 int pos, i = 0;
451 struct pci_cap_saved_state *save_state;
452 u16 *cap;
453
454 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
455 if (pos <= 0)
456 return 0;
457
458 save_state = kzalloc(sizeof(*save_state) + sizeof(u16) * 4, GFP_KERNEL);
459 if (!save_state) {
460 dev_err(&dev->dev, "Out of memory in pci_save_pcie_state\n");
461 return -ENOMEM;
462 }
463 cap = (u16 *)&save_state->data[0];
464
465 pci_read_config_word(dev, pos + PCI_EXP_DEVCTL, &cap[i++]);
466 pci_read_config_word(dev, pos + PCI_EXP_LNKCTL, &cap[i++]);
467 pci_read_config_word(dev, pos + PCI_EXP_SLTCTL, &cap[i++]);
468 pci_read_config_word(dev, pos + PCI_EXP_RTCTL, &cap[i++]);
469 pci_add_saved_cap(dev, save_state);
470 return 0;
471}
472
473static void pci_restore_pcie_state(struct pci_dev *dev)
474{
475 int i = 0, pos;
476 struct pci_cap_saved_state *save_state;
477 u16 *cap;
478
479 save_state = pci_find_saved_cap(dev, PCI_CAP_ID_EXP);
480 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
481 if (!save_state || pos <= 0)
482 return;
483 cap = (u16 *)&save_state->data[0];
484
485 pci_write_config_word(dev, pos + PCI_EXP_DEVCTL, cap[i++]);
486 pci_write_config_word(dev, pos + PCI_EXP_LNKCTL, cap[i++]);
487 pci_write_config_word(dev, pos + PCI_EXP_SLTCTL, cap[i++]);
488 pci_write_config_word(dev, pos + PCI_EXP_RTCTL, cap[i++]);
489 pci_remove_saved_cap(save_state);
490 kfree(save_state);
491}
492
446/** 493/**
447 * pci_save_state - save the PCI configuration space of a device before suspending 494 * pci_save_state - save the PCI configuration space of a device before suspending
448 * @dev: - PCI device that we're dealing with 495 * @dev: - PCI device that we're dealing with
@@ -458,6 +505,8 @@ pci_save_state(struct pci_dev *dev)
458 return i; 505 return i;
459 if ((i = pci_save_msix_state(dev)) != 0) 506 if ((i = pci_save_msix_state(dev)) != 0)
460 return i; 507 return i;
508 if ((i = pci_save_pcie_state(dev)) != 0)
509 return i;
461 return 0; 510 return 0;
462} 511}
463 512
@@ -471,6 +520,9 @@ pci_restore_state(struct pci_dev *dev)
471 int i; 520 int i;
472 int val; 521 int val;
473 522
523 /* PCI Express register must be restored first */
524 pci_restore_pcie_state(dev);
525
474 /* 526 /*
475 * The Base Address register should be programmed before the command 527 * The Base Address register should be programmed before the command
476 * register(s) 528 * register(s)
@@ -953,13 +1005,12 @@ static int __devinit pci_setup(char *str)
953 } 1005 }
954 str = k; 1006 str = k;
955 } 1007 }
956 return 1; 1008 return 0;
957} 1009}
1010early_param("pci", pci_setup);
958 1011
959device_initcall(pci_init); 1012device_initcall(pci_init);
960 1013
961__setup("pci=", pci_setup);
962
963#if defined(CONFIG_ISA) || defined(CONFIG_EISA) 1014#if defined(CONFIG_ISA) || defined(CONFIG_EISA)
964/* FIXME: Some boxes have multiple ISA bridges! */ 1015/* FIXME: Some boxes have multiple ISA bridges! */
965struct pci_dev *isa_bridge; 1016struct pci_dev *isa_bridge;
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 08d58fc78ee1..6bf327db5c5e 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -42,7 +42,7 @@ extern void pci_remove_legacy_files(struct pci_bus *bus);
42/* Lock for read/write access to pci device and bus lists */ 42/* Lock for read/write access to pci device and bus lists */
43extern struct rw_semaphore pci_bus_sem; 43extern struct rw_semaphore pci_bus_sem;
44 44
45#ifdef CONFIG_X86_IO_APIC 45#ifdef CONFIG_PCI_MSI
46extern int pci_msi_quirk; 46extern int pci_msi_quirk;
47#else 47#else
48#define pci_msi_quirk 0 48#define pci_msi_quirk 0
diff --git a/drivers/pci/pcie/Kconfig b/drivers/pci/pcie/Kconfig
index 1012db8b8b2c..0ad92a8ad8b1 100644
--- a/drivers/pci/pcie/Kconfig
+++ b/drivers/pci/pcie/Kconfig
@@ -34,3 +34,4 @@ config HOTPLUG_PCI_PCIE_POLL_EVENT_MODE
34 34
35 When in doubt, say N. 35 When in doubt, say N.
36 36
37source "drivers/pci/pcie/aer/Kconfig"
diff --git a/drivers/pci/pcie/Makefile b/drivers/pci/pcie/Makefile
index 984fa87283e3..e00fb99acf44 100644
--- a/drivers/pci/pcie/Makefile
+++ b/drivers/pci/pcie/Makefile
@@ -5,3 +5,6 @@
5pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o 5pcieportdrv-y := portdrv_core.o portdrv_pci.o portdrv_bus.o
6 6
7obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o 7obj-$(CONFIG_PCIEPORTBUS) += pcieportdrv.o
8
9# Build PCI Express AER if needed
10obj-$(CONFIG_PCIEAER) += aer/
diff --git a/drivers/pci/pcie/aer/Kconfig b/drivers/pci/pcie/aer/Kconfig
new file mode 100644
index 000000000000..3f37a60a6438
--- /dev/null
+++ b/drivers/pci/pcie/aer/Kconfig
@@ -0,0 +1,12 @@
1#
2# PCI Express Root Port Device AER Configuration
3#
4
5config PCIEAER
6 boolean "Root Port Advanced Error Reporting support"
7 depends on PCIEPORTBUS && ACPI
8 default y
9 help
10 This enables PCI Express Root Port Advanced Error Reporting
11 (AER) driver support. Error reporting messages sent to Root
12 Port will be handled by PCI Express AER driver.
diff --git a/drivers/pci/pcie/aer/Makefile b/drivers/pci/pcie/aer/Makefile
new file mode 100644
index 000000000000..15a4f40d520b
--- /dev/null
+++ b/drivers/pci/pcie/aer/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for PCI-Express Root Port Advanced Error Reporting Driver
3#
4
5obj-$(CONFIG_PCIEAER) += aerdriver.o
6
7aerdriver-objs := aerdrv_errprint.o aerdrv_core.o aerdrv.o aerdrv_acpi.o
8
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
new file mode 100644
index 000000000000..0d4ac027d53e
--- /dev/null
+++ b/drivers/pci/pcie/aer/aerdrv.c
@@ -0,0 +1,346 @@
1/*
2 * drivers/pci/pcie/aer/aerdrv.c
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * This file implements the AER root port service driver. The driver will
9 * register an irq handler. When root port triggers an AER interrupt, the irq
10 * handler will collect root port status and schedule a work.
11 *
12 * Copyright (C) 2006 Intel Corp.
13 * Tom Long Nguyen (tom.l.nguyen@intel.com)
14 * Zhang Yanmin (yanmin.zhang@intel.com)
15 *
16 */
17
18#include <linux/module.h>
19#include <linux/pci.h>
20#include <linux/kernel.h>
21#include <linux/errno.h>
22#include <linux/pm.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/delay.h>
26#include <linux/pcieport_if.h>
27
28#include "aerdrv.h"
29
30/*
31 * Version Information
32 */
33#define DRIVER_VERSION "v1.0"
34#define DRIVER_AUTHOR "tom.l.nguyen@intel.com"
35#define DRIVER_DESC "Root Port Advanced Error Reporting Driver"
36MODULE_AUTHOR(DRIVER_AUTHOR);
37MODULE_DESCRIPTION(DRIVER_DESC);
38MODULE_LICENSE("GPL");
39
40static int __devinit aer_probe (struct pcie_device *dev,
41 const struct pcie_port_service_id *id );
42static void aer_remove(struct pcie_device *dev);
43static int aer_suspend(struct pcie_device *dev, pm_message_t state)
44{return 0;}
45static int aer_resume(struct pcie_device *dev) {return 0;}
46static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
47 enum pci_channel_state error);
48static void aer_error_resume(struct pci_dev *dev);
49static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
50
51/*
52 * PCI Express bus's AER Root service driver data structure
53 */
54static struct pcie_port_service_id aer_id[] = {
55 {
56 .vendor = PCI_ANY_ID,
57 .device = PCI_ANY_ID,
58 .port_type = PCIE_RC_PORT,
59 .service_type = PCIE_PORT_SERVICE_AER,
60 },
61 { /* end: all zeroes */ }
62};
63
64static struct pci_error_handlers aer_error_handlers = {
65 .error_detected = aer_error_detected,
66 .resume = aer_error_resume,
67};
68
69static struct pcie_port_service_driver aerdrv = {
70 .name = "aer",
71 .id_table = &aer_id[0],
72
73 .probe = aer_probe,
74 .remove = aer_remove,
75
76 .suspend = aer_suspend,
77 .resume = aer_resume,
78
79 .err_handler = &aer_error_handlers,
80
81 .reset_link = aer_root_reset,
82};
83
84/**
85 * aer_irq - Root Port's ISR
86 * @irq: IRQ assigned to Root Port
87 * @context: pointer to Root Port data structure
88 * @r: pointer struct pt_regs
89 *
90 * Invoked when Root Port detects AER messages.
91 **/
92static irqreturn_t aer_irq(int irq, void *context, struct pt_regs * r)
93{
94 unsigned int status, id;
95 struct pcie_device *pdev = (struct pcie_device *)context;
96 struct aer_rpc *rpc = get_service_data(pdev);
97 int next_prod_idx;
98 unsigned long flags;
99 int pos;
100
101 pos = pci_find_aer_capability(pdev->port);
102 /*
103 * Must lock access to Root Error Status Reg, Root Error ID Reg,
104 * and Root error producer/consumer index
105 */
106 spin_lock_irqsave(&rpc->e_lock, flags);
107
108 /* Read error status */
109 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
110 if (!(status & ROOT_ERR_STATUS_MASKS)) {
111 spin_unlock_irqrestore(&rpc->e_lock, flags);
112 return IRQ_NONE;
113 }
114
115 /* Read error source and clear error status */
116 pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_COR_SRC, &id);
117 pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
118
119 /* Store error source for later DPC handler */
120 next_prod_idx = rpc->prod_idx + 1;
121 if (next_prod_idx == AER_ERROR_SOURCES_MAX)
122 next_prod_idx = 0;
123 if (next_prod_idx == rpc->cons_idx) {
124 /*
125 * Error Storm Condition - possibly the same error occurred.
126 * Drop the error.
127 */
128 spin_unlock_irqrestore(&rpc->e_lock, flags);
129 return IRQ_HANDLED;
130 }
131 rpc->e_sources[rpc->prod_idx].status = status;
132 rpc->e_sources[rpc->prod_idx].id = id;
133 rpc->prod_idx = next_prod_idx;
134 spin_unlock_irqrestore(&rpc->e_lock, flags);
135
136 /* Invoke DPC handler */
137 schedule_work(&rpc->dpc_handler);
138
139 return IRQ_HANDLED;
140}
141
142/**
143 * aer_alloc_rpc - allocate Root Port data structure
144 * @dev: pointer to the pcie_dev data structure
145 *
146 * Invoked when Root Port's AER service is loaded.
147 **/
148static struct aer_rpc* aer_alloc_rpc(struct pcie_device *dev)
149{
150 struct aer_rpc *rpc;
151
152 if (!(rpc = (struct aer_rpc *)kmalloc(sizeof(struct aer_rpc),
153 GFP_KERNEL)))
154 return NULL;
155
156 memset(rpc, 0, sizeof(struct aer_rpc));
157 /*
158 * Initialize Root lock access, e_lock, to Root Error Status Reg,
159 * Root Error ID Reg, and Root error producer/consumer index.
160 */
161 rpc->e_lock = SPIN_LOCK_UNLOCKED;
162
163 rpc->rpd = dev;
164 INIT_WORK(&rpc->dpc_handler, aer_isr, (void *)dev);
165 rpc->prod_idx = rpc->cons_idx = 0;
166 mutex_init(&rpc->rpc_mutex);
167 init_waitqueue_head(&rpc->wait_release);
168
169 /* Use PCIE bus function to store rpc into PCIE device */
170 set_service_data(dev, rpc);
171
172 return rpc;
173}
174
175/**
176 * aer_remove - clean up resources
177 * @dev: pointer to the pcie_dev data structure
178 *
179 * Invoked when PCI Express bus unloads or AER probe fails.
180 **/
181static void aer_remove(struct pcie_device *dev)
182{
183 struct aer_rpc *rpc = get_service_data(dev);
184
185 if (rpc) {
186 /* If register interrupt service, it must be free. */
187 if (rpc->isr)
188 free_irq(dev->irq, dev);
189
190 wait_event(rpc->wait_release, rpc->prod_idx == rpc->cons_idx);
191
192 aer_delete_rootport(rpc);
193 set_service_data(dev, NULL);
194 }
195}
196
197/**
198 * aer_probe - initialize resources
199 * @dev: pointer to the pcie_dev data structure
200 * @id: pointer to the service id data structure
201 *
202 * Invoked when PCI Express bus loads AER service driver.
203 **/
204static int __devinit aer_probe (struct pcie_device *dev,
205 const struct pcie_port_service_id *id )
206{
207 int status;
208 struct aer_rpc *rpc;
209 struct device *device = &dev->device;
210
211 /* Init */
212 if ((status = aer_init(dev)))
213 return status;
214
215 /* Alloc rpc data structure */
216 if (!(rpc = aer_alloc_rpc(dev))) {
217 printk(KERN_DEBUG "%s: Alloc rpc fails on PCIE device[%s]\n",
218 __FUNCTION__, device->bus_id);
219 aer_remove(dev);
220 return -ENOMEM;
221 }
222
223 /* Request IRQ ISR */
224 if ((status = request_irq(dev->irq, aer_irq, SA_SHIRQ, "aerdrv",
225 dev))) {
226 printk(KERN_DEBUG "%s: Request ISR fails on PCIE device[%s]\n",
227 __FUNCTION__, device->bus_id);
228 aer_remove(dev);
229 return status;
230 }
231
232 rpc->isr = 1;
233
234 aer_enable_rootport(rpc);
235
236 return status;
237}
238
239/**
240 * aer_root_reset - reset link on Root Port
241 * @dev: pointer to Root Port's pci_dev data structure
242 *
243 * Invoked by Port Bus driver when performing link reset at Root Port.
244 **/
245static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
246{
247 u16 p2p_ctrl;
248 u32 status;
249 int pos;
250
251 pos = pci_find_aer_capability(dev);
252
253 /* Disable Root's interrupt in response to error messages */
254 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, 0);
255
256 /* Assert Secondary Bus Reset */
257 pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &p2p_ctrl);
258 p2p_ctrl |= PCI_CB_BRIDGE_CTL_CB_RESET;
259 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl);
260
261 /* De-assert Secondary Bus Reset */
262 p2p_ctrl &= ~PCI_CB_BRIDGE_CTL_CB_RESET;
263 pci_write_config_word(dev, PCI_BRIDGE_CONTROL, p2p_ctrl);
264
265 /*
266 * System software must wait for at least 100ms from the end
267 * of a reset of one or more device before it is permitted
268 * to issue Configuration Requests to those devices.
269 */
270 msleep(200);
271 printk(KERN_DEBUG "Complete link reset at Root[%s]\n", dev->dev.bus_id);
272
273 /* Enable Root Port's interrupt in response to error messages */
274 pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status);
275 pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, status);
276 pci_write_config_dword(dev,
277 pos + PCI_ERR_ROOT_COMMAND,
278 ROOT_PORT_INTR_ON_MESG_MASK);
279
280 return PCI_ERS_RESULT_RECOVERED;
281}
282
283/**
284 * aer_error_detected - update severity status
285 * @dev: pointer to Root Port's pci_dev data structure
286 * @error: error severity being notified by port bus
287 *
288 * Invoked by Port Bus driver during error recovery.
289 **/
290static pci_ers_result_t aer_error_detected(struct pci_dev *dev,
291 enum pci_channel_state error)
292{
293 /* Root Port has no impact. Always recovers. */
294 return PCI_ERS_RESULT_CAN_RECOVER;
295}
296
297/**
298 * aer_error_resume - clean up corresponding error status bits
299 * @dev: pointer to Root Port's pci_dev data structure
300 *
301 * Invoked by Port Bus driver during nonfatal recovery.
302 **/
303static void aer_error_resume(struct pci_dev *dev)
304{
305 int pos;
306 u32 status, mask;
307 u16 reg16;
308
309 /* Clean up Root device status */
310 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
311 pci_read_config_word(dev, pos + PCI_EXP_DEVSTA, &reg16);
312 pci_write_config_word(dev, pos + PCI_EXP_DEVSTA, reg16);
313
314 /* Clean AER Root Error Status */
315 pos = pci_find_aer_capability(dev);
316 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
317 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask);
318 if (dev->error_state == pci_channel_io_normal)
319 status &= ~mask; /* Clear corresponding nonfatal bits */
320 else
321 status &= mask; /* Clear corresponding fatal bits */
322 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
323}
324
325/**
326 * aer_service_init - register AER root service driver
327 *
328 * Invoked when AER root service driver is loaded.
329 **/
330static int __init aer_service_init(void)
331{
332 return pcie_port_service_register(&aerdrv);
333}
334
335/**
336 * aer_service_exit - unregister AER root service driver
337 *
338 * Invoked when AER root service driver is unloaded.
339 **/
340static void __exit aer_service_exit(void)
341{
342 pcie_port_service_unregister(&aerdrv);
343}
344
345module_init(aer_service_init);
346module_exit(aer_service_exit);
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
new file mode 100644
index 000000000000..daf0cad88fc8
--- /dev/null
+++ b/drivers/pci/pcie/aer/aerdrv.h
@@ -0,0 +1,125 @@
1/*
2 * Copyright (C) 2006 Intel Corp.
3 * Tom Long Nguyen (tom.l.nguyen@intel.com)
4 * Zhang Yanmin (yanmin.zhang@intel.com)
5 *
6 */
7
8#ifndef _AERDRV_H_
9#define _AERDRV_H_
10
11#include <linux/pcieport_if.h>
12#include <linux/aer.h>
13
14#define AER_NONFATAL 0
15#define AER_FATAL 1
16#define AER_CORRECTABLE 2
17#define AER_UNCORRECTABLE 4
18#define AER_ERROR_MASK 0x001fffff
19#define AER_ERROR(d) (d & AER_ERROR_MASK)
20
21#define OSC_METHOD_RUN_SUCCESS 0
22#define OSC_METHOD_NOT_SUPPORTED 1
23#define OSC_METHOD_RUN_FAILURE 2
24
25/* Root Error Status Register Bits */
26#define ROOT_ERR_STATUS_MASKS 0x0f
27
28#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE| \
29 PCI_EXP_RTCTL_SENFEE| \
30 PCI_EXP_RTCTL_SEFEE)
31#define ROOT_PORT_INTR_ON_MESG_MASK (PCI_ERR_ROOT_CMD_COR_EN| \
32 PCI_ERR_ROOT_CMD_NONFATAL_EN| \
33 PCI_ERR_ROOT_CMD_FATAL_EN)
34#define ERR_COR_ID(d) (d & 0xffff)
35#define ERR_UNCOR_ID(d) (d >> 16)
36
37#define AER_SUCCESS 0
38#define AER_UNSUCCESS 1
39#define AER_ERROR_SOURCES_MAX 100
40
41#define AER_LOG_TLP_MASKS (PCI_ERR_UNC_POISON_TLP| \
42 PCI_ERR_UNC_ECRC| \
43 PCI_ERR_UNC_UNSUP| \
44 PCI_ERR_UNC_COMP_ABORT| \
45 PCI_ERR_UNC_UNX_COMP| \
46 PCI_ERR_UNC_MALF_TLP)
47
48/* AER Error Info Flags */
49#define AER_TLP_HEADER_VALID_FLAG 0x00000001
50#define AER_MULTI_ERROR_VALID_FLAG 0x00000002
51
52#define ERR_CORRECTABLE_ERROR_MASK 0x000031c1
53#define ERR_UNCORRECTABLE_ERROR_MASK 0x001ff010
54
55struct header_log_regs {
56 unsigned int dw0;
57 unsigned int dw1;
58 unsigned int dw2;
59 unsigned int dw3;
60};
61
62struct aer_err_info {
63 int severity; /* 0:NONFATAL | 1:FATAL | 2:COR */
64 int flags;
65 unsigned int status; /* COR/UNCOR Error Status */
66 struct header_log_regs tlp; /* TLP Header */
67};
68
69struct aer_err_source {
70 unsigned int status;
71 unsigned int id;
72};
73
74struct aer_rpc {
75 struct pcie_device *rpd; /* Root Port device */
76 struct work_struct dpc_handler;
77 struct aer_err_source e_sources[AER_ERROR_SOURCES_MAX];
78 unsigned short prod_idx; /* Error Producer Index */
79 unsigned short cons_idx; /* Error Consumer Index */
80 int isr;
81 spinlock_t e_lock; /*
82 * Lock access to Error Status/ID Regs
83 * and error producer/consumer index
84 */
85 struct mutex rpc_mutex; /*
86 * only one thread could do
87 * recovery on the same
88 * root port hierachy
89 */
90 wait_queue_head_t wait_release;
91};
92
93struct aer_broadcast_data {
94 enum pci_channel_state state;
95 enum pci_ers_result result;
96};
97
98static inline pci_ers_result_t merge_result(enum pci_ers_result orig,
99 enum pci_ers_result new)
100{
101 switch (orig) {
102 case PCI_ERS_RESULT_CAN_RECOVER:
103 case PCI_ERS_RESULT_RECOVERED:
104 orig = new;
105 break;
106 case PCI_ERS_RESULT_DISCONNECT:
107 if (new == PCI_ERS_RESULT_NEED_RESET)
108 orig = new;
109 break;
110 default:
111 break;
112 }
113
114 return orig;
115}
116
117extern struct bus_type pcie_port_bus_type;
118extern void aer_enable_rootport(struct aer_rpc *rpc);
119extern void aer_delete_rootport(struct aer_rpc *rpc);
120extern int aer_init(struct pcie_device *dev);
121extern void aer_isr(void *context);
122extern void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
123extern int aer_osc_setup(struct pci_dev *dev);
124
125#endif //_AERDRV_H_
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
new file mode 100644
index 000000000000..fa68e89ebec9
--- /dev/null
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -0,0 +1,68 @@
1/*
2 * Access ACPI _OSC method
3 *
4 * Copyright (C) 2006 Intel Corp.
5 * Tom Long Nguyen (tom.l.nguyen@intel.com)
6 * Zhang Yanmin (yanmin.zhang@intel.com)
7 *
8 */
9
10#include <linux/module.h>
11#include <linux/pci.h>
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/pm.h>
15#include <linux/suspend.h>
16#include <linux/acpi.h>
17#include <linux/pci-acpi.h>
18#include <linux/delay.h>
19#include "aerdrv.h"
20
21/**
22 * aer_osc_setup - run ACPI _OSC method
23 *
24 * Return:
25 * Zero if success. Nonzero for otherwise.
26 *
27 * Invoked when PCIE bus loads AER service driver. To avoid conflict with
28 * BIOS AER support requires BIOS to yield AER control to OS native driver.
29 **/
30int aer_osc_setup(struct pci_dev *dev)
31{
32 int retval = OSC_METHOD_RUN_SUCCESS;
33 acpi_status status;
34 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
35 struct pci_dev *pdev = dev;
36 struct pci_bus *parent;
37
38 while (!handle) {
39 if (!pdev || !pdev->bus->parent)
40 break;
41 parent = pdev->bus->parent;
42 if (!parent->self)
43 /* Parent must be a host bridge */
44 handle = acpi_get_pci_rootbridge_handle(
45 pci_domain_nr(parent),
46 parent->number);
47 else
48 handle = DEVICE_ACPI_HANDLE(
49 &(parent->self->dev));
50 pdev = parent->self;
51 }
52
53 if (!handle)
54 return OSC_METHOD_NOT_SUPPORTED;
55
56 pci_osc_support_set(OSC_EXT_PCI_CONFIG_SUPPORT);
57 status = pci_osc_control_set(handle, OSC_PCI_EXPRESS_AER_CONTROL |
58 OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL);
59 if (ACPI_FAILURE(status)) {
60 if (status == AE_SUPPORT)
61 retval = OSC_METHOD_NOT_SUPPORTED;
62 else
63 retval = OSC_METHOD_RUN_FAILURE;
64 }
65
66 return retval;
67}
68
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
new file mode 100644
index 000000000000..1c7e660d6535
--- /dev/null
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -0,0 +1,758 @@
1/*
2 * drivers/pci/pcie/aer/aerdrv_core.c
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * This file implements the core part of PCI-Express AER. When an pci-express
9 * error is delivered, an error message will be collected and printed to
10 * console, then, an error recovery procedure will be executed by following
11 * the pci error recovery rules.
12 *
13 * Copyright (C) 2006 Intel Corp.
14 * Tom Long Nguyen (tom.l.nguyen@intel.com)
15 * Zhang Yanmin (yanmin.zhang@intel.com)
16 *
17 */
18
19#include <linux/module.h>
20#include <linux/pci.h>
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/pm.h>
24#include <linux/suspend.h>
25#include <linux/acpi.h>
26#include <linux/pci-acpi.h>
27#include <linux/delay.h>
28#include "aerdrv.h"
29
30static int forceload;
31module_param(forceload, bool, 0);
32
33#define PCI_CFG_SPACE_SIZE (0x100)
34int pci_find_aer_capability(struct pci_dev *dev)
35{
36 int pos;
37 u32 reg32 = 0;
38
39 /* Check if it's a pci-express device */
40 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
41 if (!pos)
42 return 0;
43
44 /* Check if it supports pci-express AER */
45 pos = PCI_CFG_SPACE_SIZE;
46 while (pos) {
47 if (pci_read_config_dword(dev, pos, &reg32))
48 return 0;
49
50 /* some broken boards return ~0 */
51 if (reg32 == 0xffffffff)
52 return 0;
53
54 if (PCI_EXT_CAP_ID(reg32) == PCI_EXT_CAP_ID_ERR)
55 break;
56
57 pos = reg32 >> 20;
58 }
59
60 return pos;
61}
62
63int pci_enable_pcie_error_reporting(struct pci_dev *dev)
64{
65 u16 reg16 = 0;
66 int pos;
67
68 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
69 if (!pos)
70 return -EIO;
71
72 pci_read_config_word(dev, pos+PCI_EXP_DEVCTL, &reg16);
73 reg16 = reg16 |
74 PCI_EXP_DEVCTL_CERE |
75 PCI_EXP_DEVCTL_NFERE |
76 PCI_EXP_DEVCTL_FERE |
77 PCI_EXP_DEVCTL_URRE;
78 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL,
79 reg16);
80 return 0;
81}
82
83int pci_disable_pcie_error_reporting(struct pci_dev *dev)
84{
85 u16 reg16 = 0;
86 int pos;
87
88 pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
89 if (!pos)
90 return -EIO;
91
92 pci_read_config_word(dev, pos+PCI_EXP_DEVCTL, &reg16);
93 reg16 = reg16 & ~(PCI_EXP_DEVCTL_CERE |
94 PCI_EXP_DEVCTL_NFERE |
95 PCI_EXP_DEVCTL_FERE |
96 PCI_EXP_DEVCTL_URRE);
97 pci_write_config_word(dev, pos+PCI_EXP_DEVCTL,
98 reg16);
99 return 0;
100}
101
102int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
103{
104 int pos;
105 u32 status, mask;
106
107 pos = pci_find_aer_capability(dev);
108 if (!pos)
109 return -EIO;
110
111 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
112 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask);
113 if (dev->error_state == pci_channel_io_normal)
114 status &= ~mask; /* Clear corresponding nonfatal bits */
115 else
116 status &= mask; /* Clear corresponding fatal bits */
117 pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
118
119 return 0;
120}
121
122static int find_device_iter(struct device *device, void *data)
123{
124 struct pci_dev *dev;
125 u16 id = *(unsigned long *)data;
126 u8 secondary, subordinate, d_bus = id >> 8;
127
128 if (device->bus == &pci_bus_type) {
129 dev = to_pci_dev(device);
130 if (id == ((dev->bus->number << 8) | dev->devfn)) {
131 /*
132 * Device ID match
133 */
134 *(unsigned long*)data = (unsigned long)device;
135 return 1;
136 }
137
138 /*
139 * If device is P2P, check if it is an upstream?
140 */
141 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) {
142 pci_read_config_byte(dev, PCI_SECONDARY_BUS,
143 &secondary);
144 pci_read_config_byte(dev, PCI_SUBORDINATE_BUS,
145 &subordinate);
146 if (d_bus >= secondary && d_bus <= subordinate) {
147 *(unsigned long*)data = (unsigned long)device;
148 return 1;
149 }
150 }
151 }
152
153 return 0;
154}
155
156/**
157 * find_source_device - search through device hierarchy for source device
158 * @p_dev: pointer to Root Port pci_dev data structure
159 * @id: device ID of agent who sends an error message to this Root Port
160 *
161 * Invoked when error is detected at the Root Port.
162 **/
163static struct device* find_source_device(struct pci_dev *parent, u16 id)
164{
165 struct pci_dev *dev = parent;
166 struct device *device;
167 unsigned long device_addr;
168 int status;
169
170 /* Is Root Port an agent that sends error message? */
171 if (id == ((dev->bus->number << 8) | dev->devfn))
172 return &dev->dev;
173
174 do {
175 device_addr = id;
176 if ((status = device_for_each_child(&dev->dev,
177 &device_addr, find_device_iter))) {
178 device = (struct device*)device_addr;
179 dev = to_pci_dev(device);
180 if (id == ((dev->bus->number << 8) | dev->devfn))
181 return device;
182 }
183 }while (status);
184
185 return NULL;
186}
187
188static void report_error_detected(struct pci_dev *dev, void *data)
189{
190 pci_ers_result_t vote;
191 struct pci_error_handlers *err_handler;
192 struct aer_broadcast_data *result_data;
193 result_data = (struct aer_broadcast_data *) data;
194
195 dev->error_state = result_data->state;
196
197 if (!dev->driver ||
198 !dev->driver->err_handler ||
199 !dev->driver->err_handler->error_detected) {
200 if (result_data->state == pci_channel_io_frozen &&
201 !(dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)) {
202 /*
203 * In case of fatal recovery, if one of down-
204 * stream device has no driver. We might be
205 * unable to recover because a later insmod
206 * of a driver for this device is unaware of
207 * its hw state.
208 */
209 printk(KERN_DEBUG "Device ID[%s] has %s\n",
210 dev->dev.bus_id, (dev->driver) ?
211 "no AER-aware driver" : "no driver");
212 }
213 return;
214 }
215
216 err_handler = dev->driver->err_handler;
217 vote = err_handler->error_detected(dev, result_data->state);
218 result_data->result = merge_result(result_data->result, vote);
219 return;
220}
221
222static void report_mmio_enabled(struct pci_dev *dev, void *data)
223{
224 pci_ers_result_t vote;
225 struct pci_error_handlers *err_handler;
226 struct aer_broadcast_data *result_data;
227 result_data = (struct aer_broadcast_data *) data;
228
229 if (!dev->driver ||
230 !dev->driver->err_handler ||
231 !dev->driver->err_handler->mmio_enabled)
232 return;
233
234 err_handler = dev->driver->err_handler;
235 vote = err_handler->mmio_enabled(dev);
236 result_data->result = merge_result(result_data->result, vote);
237 return;
238}
239
240static void report_slot_reset(struct pci_dev *dev, void *data)
241{
242 pci_ers_result_t vote;
243 struct pci_error_handlers *err_handler;
244 struct aer_broadcast_data *result_data;
245 result_data = (struct aer_broadcast_data *) data;
246
247 if (!dev->driver ||
248 !dev->driver->err_handler ||
249 !dev->driver->err_handler->slot_reset)
250 return;
251
252 err_handler = dev->driver->err_handler;
253 vote = err_handler->slot_reset(dev);
254 result_data->result = merge_result(result_data->result, vote);
255 return;
256}
257
258static void report_resume(struct pci_dev *dev, void *data)
259{
260 struct pci_error_handlers *err_handler;
261
262 dev->error_state = pci_channel_io_normal;
263
264 if (!dev->driver ||
265 !dev->driver->err_handler ||
266 !dev->driver->err_handler->slot_reset)
267 return;
268
269 err_handler = dev->driver->err_handler;
270 err_handler->resume(dev);
271 return;
272}
273
274/**
275 * broadcast_error_message - handle message broadcast to downstream drivers
276 * @device: pointer to from where in a hierarchy message is broadcasted down
277 * @api: callback to be broadcasted
278 * @state: error state
279 *
280 * Invoked during error recovery process. Once being invoked, the content
281 * of error severity will be broadcasted to all downstream drivers in a
282 * hierarchy in question.
283 **/
284static pci_ers_result_t broadcast_error_message(struct pci_dev *dev,
285 enum pci_channel_state state,
286 char *error_mesg,
287 void (*cb)(struct pci_dev *, void *))
288{
289 struct aer_broadcast_data result_data;
290
291 printk(KERN_DEBUG "Broadcast %s message\n", error_mesg);
292 result_data.state = state;
293 if (cb == report_error_detected)
294 result_data.result = PCI_ERS_RESULT_CAN_RECOVER;
295 else
296 result_data.result = PCI_ERS_RESULT_RECOVERED;
297
298 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE) {
299 /*
300 * If the error is reported by a bridge, we think this error
301 * is related to the downstream link of the bridge, so we
302 * do error recovery on all subordinates of the bridge instead
303 * of the bridge and clear the error status of the bridge.
304 */
305 if (cb == report_error_detected)
306 dev->error_state = state;
307 pci_walk_bus(dev->subordinate, cb, &result_data);
308 if (cb == report_resume) {
309 pci_cleanup_aer_uncorrect_error_status(dev);
310 dev->error_state = pci_channel_io_normal;
311 }
312 }
313 else {
314 /*
315 * If the error is reported by an end point, we think this
316 * error is related to the upstream link of the end point.
317 */
318 pci_walk_bus(dev->bus, cb, &result_data);
319 }
320
321 return result_data.result;
322}
323
324struct find_aer_service_data {
325 struct pcie_port_service_driver *aer_driver;
326 int is_downstream;
327};
328
329static int find_aer_service_iter(struct device *device, void *data)
330{
331 struct device_driver *driver;
332 struct pcie_port_service_driver *service_driver;
333 struct pcie_device *pcie_dev;
334 struct find_aer_service_data *result;
335
336 result = (struct find_aer_service_data *) data;
337
338 if (device->bus == &pcie_port_bus_type) {
339 pcie_dev = to_pcie_device(device);
340 if (pcie_dev->id.port_type == PCIE_SW_DOWNSTREAM_PORT)
341 result->is_downstream = 1;
342
343 driver = device->driver;
344 if (driver) {
345 service_driver = to_service_driver(driver);
346 if (service_driver->id_table->service_type ==
347 PCIE_PORT_SERVICE_AER) {
348 result->aer_driver = service_driver;
349 return 1;
350 }
351 }
352 }
353
354 return 0;
355}
356
357static void find_aer_service(struct pci_dev *dev,
358 struct find_aer_service_data *data)
359{
360 int retval;
361 retval = device_for_each_child(&dev->dev, data, find_aer_service_iter);
362}
363
364static pci_ers_result_t reset_link(struct pcie_device *aerdev,
365 struct pci_dev *dev)
366{
367 struct pci_dev *udev;
368 pci_ers_result_t status;
369 struct find_aer_service_data data;
370
371 if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE)
372 udev = dev;
373 else
374 udev= dev->bus->self;
375
376 data.is_downstream = 0;
377 data.aer_driver = NULL;
378 find_aer_service(udev, &data);
379
380 /*
381 * Use the aer driver of the error agent firstly.
382 * If it hasn't the aer driver, use the root port's
383 */
384 if (!data.aer_driver || !data.aer_driver->reset_link) {
385 if (data.is_downstream &&
386 aerdev->device.driver &&
387 to_service_driver(aerdev->device.driver)->reset_link) {
388 data.aer_driver =
389 to_service_driver(aerdev->device.driver);
390 } else {
391 printk(KERN_DEBUG "No link-reset support to Device ID"
392 "[%s]\n",
393 dev->dev.bus_id);
394 return PCI_ERS_RESULT_DISCONNECT;
395 }
396 }
397
398 status = data.aer_driver->reset_link(udev);
399 if (status != PCI_ERS_RESULT_RECOVERED) {
400 printk(KERN_DEBUG "Link reset at upstream Device ID"
401 "[%s] failed\n",
402 udev->dev.bus_id);
403 return PCI_ERS_RESULT_DISCONNECT;
404 }
405
406 return status;
407}
408
409/**
410 * do_recovery - handle nonfatal/fatal error recovery process
411 * @aerdev: pointer to a pcie_device data structure of root port
412 * @dev: pointer to a pci_dev data structure of agent detecting an error
413 * @severity: error severity type
414 *
415 * Invoked when an error is nonfatal/fatal. Once being invoked, broadcast
416 * error detected message to all downstream drivers within a hierarchy in
417 * question and return the returned code.
418 **/
419static pci_ers_result_t do_recovery(struct pcie_device *aerdev,
420 struct pci_dev *dev,
421 int severity)
422{
423 pci_ers_result_t status, result = PCI_ERS_RESULT_RECOVERED;
424 enum pci_channel_state state;
425
426 if (severity == AER_FATAL)
427 state = pci_channel_io_frozen;
428 else
429 state = pci_channel_io_normal;
430
431 status = broadcast_error_message(dev,
432 state,
433 "error_detected",
434 report_error_detected);
435
436 if (severity == AER_FATAL) {
437 result = reset_link(aerdev, dev);
438 if (result != PCI_ERS_RESULT_RECOVERED) {
439 /* TODO: Should panic here? */
440 return result;
441 }
442 }
443
444 if (status == PCI_ERS_RESULT_CAN_RECOVER)
445 status = broadcast_error_message(dev,
446 state,
447 "mmio_enabled",
448 report_mmio_enabled);
449
450 if (status == PCI_ERS_RESULT_NEED_RESET) {
451 /*
452 * TODO: Should call platform-specific
453 * functions to reset slot before calling
454 * drivers' slot_reset callbacks?
455 */
456 status = broadcast_error_message(dev,
457 state,
458 "slot_reset",
459 report_slot_reset);
460 }
461
462 if (status == PCI_ERS_RESULT_RECOVERED)
463 broadcast_error_message(dev,
464 state,
465 "resume",
466 report_resume);
467
468 return status;
469}
470
471/**
472 * handle_error_source - handle logging error into an event log
473 * @aerdev: pointer to pcie_device data structure of the root port
474 * @dev: pointer to pci_dev data structure of error source device
475 * @info: comprehensive error information
476 *
477 * Invoked when an error being detected by Root Port.
478 **/
479static void handle_error_source(struct pcie_device * aerdev,
480 struct pci_dev *dev,
481 struct aer_err_info info)
482{
483 pci_ers_result_t status = 0;
484 int pos;
485
486 if (info.severity == AER_CORRECTABLE) {
487 /*
488 * Correctable error does not need software intevention.
489 * No need to go through error recovery process.
490 */
491 pos = pci_find_aer_capability(dev);
492 if (pos)
493 pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS,
494 info.status);
495 } else {
496 status = do_recovery(aerdev, dev, info.severity);
497 if (status == PCI_ERS_RESULT_RECOVERED) {
498 printk(KERN_DEBUG "AER driver successfully recovered\n");
499 } else {
500 /* TODO: Should kernel panic here? */
501 printk(KERN_DEBUG "AER driver didn't recover\n");
502 }
503 }
504}
505
506/**
507 * aer_enable_rootport - enable Root Port's interrupts when receiving messages
508 * @rpc: pointer to a Root Port data structure
509 *
510 * Invoked when PCIE bus loads AER service driver.
511 **/
512void aer_enable_rootport(struct aer_rpc *rpc)
513{
514 struct pci_dev *pdev = rpc->rpd->port;
515 int pos, aer_pos;
516 u16 reg16;
517 u32 reg32;
518
519 pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
520 /* Clear PCIE Capability's Device Status */
521 pci_read_config_word(pdev, pos+PCI_EXP_DEVSTA, &reg16);
522 pci_write_config_word(pdev, pos+PCI_EXP_DEVSTA, reg16);
523
524 /* Disable system error generation in response to error messages */
525 pci_read_config_word(pdev, pos + PCI_EXP_RTCTL, &reg16);
526 reg16 &= ~(SYSTEM_ERROR_INTR_ON_MESG_MASK);
527 pci_write_config_word(pdev, pos + PCI_EXP_RTCTL, reg16);
528
529 aer_pos = pci_find_aer_capability(pdev);
530 /* Clear error status */
531 pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, &reg32);
532 pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32);
533 pci_read_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, &reg32);
534 pci_write_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, reg32);
535 pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, &reg32);
536 pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32);
537
538 /* Enable Root Port device reporting error itself */
539 pci_read_config_word(pdev, pos+PCI_EXP_DEVCTL, &reg16);
540 reg16 = reg16 |
541 PCI_EXP_DEVCTL_CERE |
542 PCI_EXP_DEVCTL_NFERE |
543 PCI_EXP_DEVCTL_FERE |
544 PCI_EXP_DEVCTL_URRE;
545 pci_write_config_word(pdev, pos+PCI_EXP_DEVCTL,
546 reg16);
547
548 /* Enable Root Port's interrupt in response to error messages */
549 pci_write_config_dword(pdev,
550 aer_pos + PCI_ERR_ROOT_COMMAND,
551 ROOT_PORT_INTR_ON_MESG_MASK);
552}
553
554/**
555 * disable_root_aer - disable Root Port's interrupts when receiving messages
556 * @rpc: pointer to a Root Port data structure
557 *
558 * Invoked when PCIE bus unloads AER service driver.
559 **/
560static void disable_root_aer(struct aer_rpc *rpc)
561{
562 struct pci_dev *pdev = rpc->rpd->port;
563 u32 reg32;
564 int pos;
565
566 pos = pci_find_aer_capability(pdev);
567 /* Disable Root's interrupt in response to error messages */
568 pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, 0);
569
570 /* Clear Root's error status reg */
571 pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, &reg32);
572 pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, reg32);
573}
574
575/**
576 * get_e_source - retrieve an error source
577 * @rpc: pointer to the root port which holds an error
578 *
579 * Invoked by DPC handler to consume an error.
580 **/
581static struct aer_err_source* get_e_source(struct aer_rpc *rpc)
582{
583 struct aer_err_source *e_source;
584 unsigned long flags;
585
586 /* Lock access to Root error producer/consumer index */
587 spin_lock_irqsave(&rpc->e_lock, flags);
588 if (rpc->prod_idx == rpc->cons_idx) {
589 spin_unlock_irqrestore(&rpc->e_lock, flags);
590 return NULL;
591 }
592 e_source = &rpc->e_sources[rpc->cons_idx];
593 rpc->cons_idx++;
594 if (rpc->cons_idx == AER_ERROR_SOURCES_MAX)
595 rpc->cons_idx = 0;
596 spin_unlock_irqrestore(&rpc->e_lock, flags);
597
598 return e_source;
599}
600
601static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
602{
603 int pos;
604
605 pos = pci_find_aer_capability(dev);
606
607 /* The device might not support AER */
608 if (!pos)
609 return AER_SUCCESS;
610
611 if (info->severity == AER_CORRECTABLE) {
612 pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
613 &info->status);
614 if (!(info->status & ERR_CORRECTABLE_ERROR_MASK))
615 return AER_UNSUCCESS;
616 } else if (dev->hdr_type & PCI_HEADER_TYPE_BRIDGE ||
617 info->severity == AER_NONFATAL) {
618
619 /* Link is still healthy for IO reads */
620 pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
621 &info->status);
622 if (!(info->status & ERR_UNCORRECTABLE_ERROR_MASK))
623 return AER_UNSUCCESS;
624
625 if (info->status & AER_LOG_TLP_MASKS) {
626 info->flags |= AER_TLP_HEADER_VALID_FLAG;
627 pci_read_config_dword(dev,
628 pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0);
629 pci_read_config_dword(dev,
630 pos + PCI_ERR_HEADER_LOG + 4, &info->tlp.dw1);
631 pci_read_config_dword(dev,
632 pos + PCI_ERR_HEADER_LOG + 8, &info->tlp.dw2);
633 pci_read_config_dword(dev,
634 pos + PCI_ERR_HEADER_LOG + 12, &info->tlp.dw3);
635 }
636 }
637
638 return AER_SUCCESS;
639}
640
641/**
642 * aer_isr_one_error - consume an error detected by root port
643 * @p_device: pointer to error root port service device
644 * @e_src: pointer to an error source
645 **/
646static void aer_isr_one_error(struct pcie_device *p_device,
647 struct aer_err_source *e_src)
648{
649 struct device *s_device;
650 struct aer_err_info e_info = {0, 0, 0,};
651 int i;
652 u16 id;
653
654 /*
655 * There is a possibility that both correctable error and
656 * uncorrectable error being logged. Report correctable error first.
657 */
658 for (i = 1; i & ROOT_ERR_STATUS_MASKS ; i <<= 2) {
659 if (i > 4)
660 break;
661 if (!(e_src->status & i))
662 continue;
663
664 /* Init comprehensive error information */
665 if (i & PCI_ERR_ROOT_COR_RCV) {
666 id = ERR_COR_ID(e_src->id);
667 e_info.severity = AER_CORRECTABLE;
668 } else {
669 id = ERR_UNCOR_ID(e_src->id);
670 e_info.severity = ((e_src->status >> 6) & 1);
671 }
672 if (e_src->status &
673 (PCI_ERR_ROOT_MULTI_COR_RCV |
674 PCI_ERR_ROOT_MULTI_UNCOR_RCV))
675 e_info.flags |= AER_MULTI_ERROR_VALID_FLAG;
676 if (!(s_device = find_source_device(p_device->port, id))) {
677 printk(KERN_DEBUG "%s->can't find device of ID%04x\n",
678 __FUNCTION__, id);
679 continue;
680 }
681 if (get_device_error_info(to_pci_dev(s_device), &e_info) ==
682 AER_SUCCESS) {
683 aer_print_error(to_pci_dev(s_device), &e_info);
684 handle_error_source(p_device,
685 to_pci_dev(s_device),
686 e_info);
687 }
688 }
689}
690
691/**
692 * aer_isr - consume errors detected by root port
693 * @context: pointer to a private data of pcie device
694 *
695 * Invoked, as DPC, when root port records new detected error
696 **/
697void aer_isr(void *context)
698{
699 struct pcie_device *p_device = (struct pcie_device *) context;
700 struct aer_rpc *rpc = get_service_data(p_device);
701 struct aer_err_source *e_src;
702
703 mutex_lock(&rpc->rpc_mutex);
704 e_src = get_e_source(rpc);
705 while (e_src) {
706 aer_isr_one_error(p_device, e_src);
707 e_src = get_e_source(rpc);
708 }
709 mutex_unlock(&rpc->rpc_mutex);
710
711 wake_up(&rpc->wait_release);
712}
713
714/**
715 * aer_delete_rootport - disable root port aer and delete service data
716 * @rpc: pointer to a root port device being deleted
717 *
718 * Invoked when AER service unloaded on a specific Root Port
719 **/
720void aer_delete_rootport(struct aer_rpc *rpc)
721{
722 /* Disable root port AER itself */
723 disable_root_aer(rpc);
724
725 kfree(rpc);
726}
727
728/**
729 * aer_init - provide AER initialization
730 * @dev: pointer to AER pcie device
731 *
732 * Invoked when AER service driver is loaded.
733 **/
734int aer_init(struct pcie_device *dev)
735{
736 int status;
737
738 /* Run _OSC Method */
739 status = aer_osc_setup(dev->port);
740
741 if(status != OSC_METHOD_RUN_SUCCESS) {
742 printk(KERN_DEBUG "%s: AER service init fails - %s\n",
743 __FUNCTION__,
744 (status == OSC_METHOD_NOT_SUPPORTED) ?
745 "No ACPI _OSC support" : "Run ACPI _OSC fails");
746
747 if (!forceload)
748 return status;
749 }
750
751 return AER_SUCCESS;
752}
753
754EXPORT_SYMBOL_GPL(pci_find_aer_capability);
755EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
756EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
757EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
758
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
new file mode 100644
index 000000000000..3933d4f30e8c
--- /dev/null
+++ b/drivers/pci/pcie/aer/aerdrv_errprint.c
@@ -0,0 +1,248 @@
1/*
2 * drivers/pci/pcie/aer/aerdrv_errprint.c
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Format error messages and print them to console.
9 *
10 * Copyright (C) 2006 Intel Corp.
11 * Tom Long Nguyen (tom.l.nguyen@intel.com)
12 * Zhang Yanmin (yanmin.zhang@intel.com)
13 *
14 */
15
16#include <linux/module.h>
17#include <linux/pci.h>
18#include <linux/kernel.h>
19#include <linux/errno.h>
20#include <linux/pm.h>
21#include <linux/suspend.h>
22
23#include "aerdrv.h"
24
25#define AER_AGENT_RECEIVER 0
26#define AER_AGENT_REQUESTER 1
27#define AER_AGENT_COMPLETER 2
28#define AER_AGENT_TRANSMITTER 3
29
30#define AER_AGENT_REQUESTER_MASK (PCI_ERR_UNC_COMP_TIME| \
31 PCI_ERR_UNC_UNSUP)
32
33#define AER_AGENT_COMPLETER_MASK PCI_ERR_UNC_COMP_ABORT
34
35#define AER_AGENT_TRANSMITTER_MASK(t, e) (e & (PCI_ERR_COR_REP_ROLL| \
36 ((t == AER_CORRECTABLE) ? PCI_ERR_COR_REP_TIMER: 0)))
37
38#define AER_GET_AGENT(t, e) \
39 ((e & AER_AGENT_COMPLETER_MASK) ? AER_AGENT_COMPLETER : \
40 (e & AER_AGENT_REQUESTER_MASK) ? AER_AGENT_REQUESTER : \
41 (AER_AGENT_TRANSMITTER_MASK(t, e)) ? AER_AGENT_TRANSMITTER : \
42 AER_AGENT_RECEIVER)
43
44#define AER_PHYSICAL_LAYER_ERROR_MASK PCI_ERR_COR_RCVR
45#define AER_DATA_LINK_LAYER_ERROR_MASK(t, e) \
46 (PCI_ERR_UNC_DLP| \
47 PCI_ERR_COR_BAD_TLP| \
48 PCI_ERR_COR_BAD_DLLP| \
49 PCI_ERR_COR_REP_ROLL| \
50 ((t == AER_CORRECTABLE) ? \
51 PCI_ERR_COR_REP_TIMER: 0))
52
53#define AER_PHYSICAL_LAYER_ERROR 0
54#define AER_DATA_LINK_LAYER_ERROR 1
55#define AER_TRANSACTION_LAYER_ERROR 2
56
57#define AER_GET_LAYER_ERROR(t, e) \
58 ((e & AER_PHYSICAL_LAYER_ERROR_MASK) ? \
59 AER_PHYSICAL_LAYER_ERROR : \
60 (e & AER_DATA_LINK_LAYER_ERROR_MASK(t, e)) ? \
61 AER_DATA_LINK_LAYER_ERROR : \
62 AER_TRANSACTION_LAYER_ERROR)
63
64/*
65 * AER error strings
66 */
67static char* aer_error_severity_string[] = {
68 "Uncorrected (Non-Fatal)",
69 "Uncorrected (Fatal)",
70 "Corrected"
71};
72
73static char* aer_error_layer[] = {
74 "Physical Layer",
75 "Data Link Layer",
76 "Transaction Layer"
77};
78static char* aer_correctable_error_string[] = {
79 "Receiver Error ", /* Bit Position 0 */
80 NULL,
81 NULL,
82 NULL,
83 NULL,
84 NULL,
85 "Bad TLP ", /* Bit Position 6 */
86 "Bad DLLP ", /* Bit Position 7 */
87 "RELAY_NUM Rollover ", /* Bit Position 8 */
88 NULL,
89 NULL,
90 NULL,
91 "Replay Timer Timeout ", /* Bit Position 12 */
92 "Advisory Non-Fatal ", /* Bit Position 13 */
93 NULL,
94 NULL,
95 NULL,
96 NULL,
97 NULL,
98 NULL,
99 NULL,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 NULL,
105 NULL,
106 NULL,
107 NULL,
108 NULL,
109 NULL,
110 NULL,
111};
112
113static char* aer_uncorrectable_error_string[] = {
114 NULL,
115 NULL,
116 NULL,
117 NULL,
118 "Data Link Protocol ", /* Bit Position 4 */
119 NULL,
120 NULL,
121 NULL,
122 NULL,
123 NULL,
124 NULL,
125 NULL,
126 "Poisoned TLP ", /* Bit Position 12 */
127 "Flow Control Protocol ", /* Bit Position 13 */
128 "Completion Timeout ", /* Bit Position 14 */
129 "Completer Abort ", /* Bit Position 15 */
130 "Unexpected Completion ", /* Bit Position 16 */
131 "Receiver Overflow ", /* Bit Position 17 */
132 "Malformed TLP ", /* Bit Position 18 */
133 "ECRC ", /* Bit Position 19 */
134 "Unsupported Request ", /* Bit Position 20 */
135 NULL,
136 NULL,
137 NULL,
138 NULL,
139 NULL,
140 NULL,
141 NULL,
142 NULL,
143 NULL,
144 NULL,
145 NULL,
146};
147
148static char* aer_agent_string[] = {
149 "Receiver ID",
150 "Requester ID",
151 "Completer ID",
152 "Transmitter ID"
153};
154
155static char * aer_get_error_source_name(int severity,
156 unsigned int status,
157 char errmsg_buff[])
158{
159 int i;
160 char * errmsg = NULL;
161
162 for (i = 0; i < 32; i++) {
163 if (!(status & (1 << i)))
164 continue;
165
166 if (severity == AER_CORRECTABLE)
167 errmsg = aer_correctable_error_string[i];
168 else
169 errmsg = aer_uncorrectable_error_string[i];
170
171 if (!errmsg) {
172 sprintf(errmsg_buff, "Unknown Error Bit %2d ", i);
173 errmsg = errmsg_buff;
174 }
175
176 break;
177 }
178
179 return errmsg;
180}
181
182static DEFINE_SPINLOCK(logbuf_lock);
183static char errmsg_buff[100];
184void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
185{
186 char * errmsg;
187 int err_layer, agent;
188 char * loglevel;
189
190 if (info->severity == AER_CORRECTABLE)
191 loglevel = KERN_WARNING;
192 else
193 loglevel = KERN_ERR;
194
195 printk("%s+------ PCI-Express Device Error ------+\n", loglevel);
196 printk("%sError Severity\t\t: %s\n", loglevel,
197 aer_error_severity_string[info->severity]);
198
199 if ( info->status == 0) {
200 printk("%sPCIE Bus Error type\t: (Unaccessible)\n", loglevel);
201 printk("%sUnaccessible Received\t: %s\n", loglevel,
202 info->flags & AER_MULTI_ERROR_VALID_FLAG ?
203 "Multiple" : "First");
204 printk("%sUnregistered Agent ID\t: %04x\n", loglevel,
205 (dev->bus->number << 8) | dev->devfn);
206 } else {
207 err_layer = AER_GET_LAYER_ERROR(info->severity, info->status);
208 printk("%sPCIE Bus Error type\t: %s\n", loglevel,
209 aer_error_layer[err_layer]);
210
211 spin_lock(&logbuf_lock);
212 errmsg = aer_get_error_source_name(info->severity,
213 info->status,
214 errmsg_buff);
215 printk("%s%s\t: %s\n", loglevel, errmsg,
216 info->flags & AER_MULTI_ERROR_VALID_FLAG ?
217 "Multiple" : "First");
218 spin_unlock(&logbuf_lock);
219
220 agent = AER_GET_AGENT(info->severity, info->status);
221 printk("%s%s\t\t: %04x\n", loglevel,
222 aer_agent_string[agent],
223 (dev->bus->number << 8) | dev->devfn);
224
225 printk("%sVendorID=%04xh, DeviceID=%04xh,"
226 " Bus=%02xh, Device=%02xh, Function=%02xh\n",
227 loglevel,
228 dev->vendor,
229 dev->device,
230 dev->bus->number,
231 PCI_SLOT(dev->devfn),
232 PCI_FUNC(dev->devfn));
233
234 if (info->flags & AER_TLP_HEADER_VALID_FLAG) {
235 unsigned char *tlp = (unsigned char *) &info->tlp;
236 printk("%sTLB Header:\n", loglevel);
237 printk("%s%02x%02x%02x%02x %02x%02x%02x%02x"
238 " %02x%02x%02x%02x %02x%02x%02x%02x\n",
239 loglevel,
240 *(tlp + 3), *(tlp + 2), *(tlp + 1), *tlp,
241 *(tlp + 7), *(tlp + 6), *(tlp + 5), *(tlp + 4),
242 *(tlp + 11), *(tlp + 10), *(tlp + 9),
243 *(tlp + 8), *(tlp + 15), *(tlp + 14),
244 *(tlp + 13), *(tlp + 12));
245 }
246 }
247}
248
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index 1d317d22ee89..67fcd176babd 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -39,7 +39,7 @@ extern int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state);
39extern int pcie_port_device_resume(struct pci_dev *dev); 39extern int pcie_port_device_resume(struct pci_dev *dev);
40#endif 40#endif
41extern void pcie_port_device_remove(struct pci_dev *dev); 41extern void pcie_port_device_remove(struct pci_dev *dev);
42extern void pcie_port_bus_register(void); 42extern int pcie_port_bus_register(void);
43extern void pcie_port_bus_unregister(void); 43extern void pcie_port_bus_unregister(void);
44 44
45#endif /* _PORTDRV_H_ */ 45#endif /* _PORTDRV_H_ */
diff --git a/drivers/pci/pcie/portdrv_bus.c b/drivers/pci/pcie/portdrv_bus.c
index 3e84b501e6a4..3f0976868eda 100644
--- a/drivers/pci/pcie/portdrv_bus.c
+++ b/drivers/pci/pcie/portdrv_bus.c
@@ -24,6 +24,7 @@ struct bus_type pcie_port_bus_type = {
24 .suspend = pcie_port_bus_suspend, 24 .suspend = pcie_port_bus_suspend,
25 .resume = pcie_port_bus_resume, 25 .resume = pcie_port_bus_resume,
26}; 26};
27EXPORT_SYMBOL_GPL(pcie_port_bus_type);
27 28
28static int pcie_port_bus_match(struct device *dev, struct device_driver *drv) 29static int pcie_port_bus_match(struct device *dev, struct device_driver *drv)
29{ 30{
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 55c662267868..bd6615b4d40e 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -6,6 +6,7 @@
6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) 6 * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com)
7 */ 7 */
8 8
9#include <linux/compiler.h>
9#include <linux/module.h> 10#include <linux/module.h>
10#include <linux/pci.h> 11#include <linux/pci.h>
11#include <linux/kernel.h> 12#include <linux/kernel.h>
@@ -339,8 +340,7 @@ static int suspend_iter(struct device *dev, void *data)
339 340
340int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state) 341int pcie_port_device_suspend(struct pci_dev *dev, pm_message_t state)
341{ 342{
342 device_for_each_child(&dev->dev, &state, suspend_iter); 343 return device_for_each_child(&dev->dev, &state, suspend_iter);
343 return 0;
344} 344}
345 345
346static int resume_iter(struct device *dev, void *data) 346static int resume_iter(struct device *dev, void *data)
@@ -358,8 +358,7 @@ static int resume_iter(struct device *dev, void *data)
358 358
359int pcie_port_device_resume(struct pci_dev *dev) 359int pcie_port_device_resume(struct pci_dev *dev)
360{ 360{
361 device_for_each_child(&dev->dev, NULL, resume_iter); 361 return device_for_each_child(&dev->dev, NULL, resume_iter);
362 return 0;
363} 362}
364#endif 363#endif
365 364
@@ -402,9 +401,9 @@ void pcie_port_device_remove(struct pci_dev *dev)
402 pci_disable_msi(dev); 401 pci_disable_msi(dev);
403} 402}
404 403
405void pcie_port_bus_register(void) 404int __must_check pcie_port_bus_register(void)
406{ 405{
407 bus_register(&pcie_port_bus_type); 406 return bus_register(&pcie_port_bus_type);
408} 407}
409 408
410void pcie_port_bus_unregister(void) 409void pcie_port_bus_unregister(void)
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 478d0d28f7ad..037690e08f5f 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -14,8 +14,10 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/pcieport_if.h> 16#include <linux/pcieport_if.h>
17#include <linux/aer.h>
17 18
18#include "portdrv.h" 19#include "portdrv.h"
20#include "aer/aerdrv.h"
19 21
20/* 22/*
21 * Version Information 23 * Version Information
@@ -30,6 +32,43 @@ MODULE_LICENSE("GPL");
30/* global data */ 32/* global data */
31static const char device_name[] = "pcieport-driver"; 33static const char device_name[] = "pcieport-driver";
32 34
35static int pcie_portdrv_save_config(struct pci_dev *dev)
36{
37 return pci_save_state(dev);
38}
39
40#ifdef CONFIG_PM
41static int pcie_portdrv_restore_config(struct pci_dev *dev)
42{
43 int retval;
44
45 pci_restore_state(dev);
46 retval = pci_enable_device(dev);
47 if (retval)
48 return retval;
49 pci_set_master(dev);
50 return 0;
51}
52
53static int pcie_portdrv_suspend(struct pci_dev *dev, pm_message_t state)
54{
55 int ret = pcie_port_device_suspend(dev, state);
56
57 if (!ret)
58 ret = pcie_portdrv_save_config(dev);
59 return ret;
60}
61
62static int pcie_portdrv_resume(struct pci_dev *dev)
63{
64 pcie_portdrv_restore_config(dev);
65 return pcie_port_device_resume(dev);
66}
67#else
68#define pcie_portdrv_suspend NULL
69#define pcie_portdrv_resume NULL
70#endif
71
33/* 72/*
34 * pcie_portdrv_probe - Probe PCI-Express port devices 73 * pcie_portdrv_probe - Probe PCI-Express port devices
35 * @dev: PCI-Express port device being probed 74 * @dev: PCI-Express port device being probed
@@ -61,6 +100,10 @@ static int __devinit pcie_portdrv_probe (struct pci_dev *dev,
61 return -ENOMEM; 100 return -ENOMEM;
62 } 101 }
63 102
103 pcie_portdrv_save_config(dev);
104
105 pci_enable_pcie_error_reporting(dev);
106
64 return 0; 107 return 0;
65} 108}
66 109
@@ -70,39 +113,151 @@ static void pcie_portdrv_remove (struct pci_dev *dev)
70 kfree(pci_get_drvdata(dev)); 113 kfree(pci_get_drvdata(dev));
71} 114}
72 115
73#ifdef CONFIG_PM 116static int error_detected_iter(struct device *device, void *data)
74static int pcie_portdrv_save_config(struct pci_dev *dev)
75{ 117{
76 return pci_save_state(dev); 118 struct pcie_device *pcie_device;
119 struct pcie_port_service_driver *driver;
120 struct aer_broadcast_data *result_data;
121 pci_ers_result_t status;
122
123 result_data = (struct aer_broadcast_data *) data;
124
125 if (device->bus == &pcie_port_bus_type && device->driver) {
126 driver = to_service_driver(device->driver);
127 if (!driver ||
128 !driver->err_handler ||
129 !driver->err_handler->error_detected)
130 return 0;
131
132 pcie_device = to_pcie_device(device);
133
134 /* Forward error detected message to service drivers */
135 status = driver->err_handler->error_detected(
136 pcie_device->port,
137 result_data->state);
138 result_data->result =
139 merge_result(result_data->result, status);
140 }
141
142 return 0;
77} 143}
78 144
79static int pcie_portdrv_restore_config(struct pci_dev *dev) 145static pci_ers_result_t pcie_portdrv_error_detected(struct pci_dev *dev,
146 enum pci_channel_state error)
80{ 147{
148 struct aer_broadcast_data result_data =
149 {error, PCI_ERS_RESULT_CAN_RECOVER};
81 int retval; 150 int retval;
82 151
83 pci_restore_state(dev); 152 /* can not fail */
84 retval = pci_enable_device(dev); 153 retval = device_for_each_child(&dev->dev, &result_data, error_detected_iter);
85 if (retval) 154
86 return retval; 155 return result_data.result;
87 pci_set_master(dev); 156}
157
158static int mmio_enabled_iter(struct device *device, void *data)
159{
160 struct pcie_device *pcie_device;
161 struct pcie_port_service_driver *driver;
162 pci_ers_result_t status, *result;
163
164 result = (pci_ers_result_t *) data;
165
166 if (device->bus == &pcie_port_bus_type && device->driver) {
167 driver = to_service_driver(device->driver);
168 if (driver &&
169 driver->err_handler &&
170 driver->err_handler->mmio_enabled) {
171 pcie_device = to_pcie_device(device);
172
173 /* Forward error message to service drivers */
174 status = driver->err_handler->mmio_enabled(
175 pcie_device->port);
176 *result = merge_result(*result, status);
177 }
178 }
179
88 return 0; 180 return 0;
89} 181}
90 182
91static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state) 183static pci_ers_result_t pcie_portdrv_mmio_enabled(struct pci_dev *dev)
92{ 184{
93 int ret = pcie_port_device_suspend(dev, state); 185 pci_ers_result_t status = PCI_ERS_RESULT_RECOVERED;
186 int retval;
94 187
95 if (!ret) 188 /* get true return value from &status */
96 ret = pcie_portdrv_save_config(dev); 189 retval = device_for_each_child(&dev->dev, &status, mmio_enabled_iter);
97 return ret; 190 return status;
98} 191}
99 192
100static int pcie_portdrv_resume (struct pci_dev *dev) 193static int slot_reset_iter(struct device *device, void *data)
101{ 194{
102 pcie_portdrv_restore_config(dev); 195 struct pcie_device *pcie_device;
103 return pcie_port_device_resume(dev); 196 struct pcie_port_service_driver *driver;
197 pci_ers_result_t status, *result;
198
199 result = (pci_ers_result_t *) data;
200
201 if (device->bus == &pcie_port_bus_type && device->driver) {
202 driver = to_service_driver(device->driver);
203 if (driver &&
204 driver->err_handler &&
205 driver->err_handler->slot_reset) {
206 pcie_device = to_pcie_device(device);
207
208 /* Forward error message to service drivers */
209 status = driver->err_handler->slot_reset(
210 pcie_device->port);
211 *result = merge_result(*result, status);
212 }
213 }
214
215 return 0;
216}
217
218static pci_ers_result_t pcie_portdrv_slot_reset(struct pci_dev *dev)
219{
220 pci_ers_result_t status;
221 int retval;
222
223 /* If fatal, restore cfg space for possible link reset at upstream */
224 if (dev->error_state == pci_channel_io_frozen) {
225 pcie_portdrv_restore_config(dev);
226 pci_enable_pcie_error_reporting(dev);
227 }
228
229 /* get true return value from &status */
230 retval = device_for_each_child(&dev->dev, &status, slot_reset_iter);
231
232 return status;
233}
234
235static int resume_iter(struct device *device, void *data)
236{
237 struct pcie_device *pcie_device;
238 struct pcie_port_service_driver *driver;
239
240 if (device->bus == &pcie_port_bus_type && device->driver) {
241 driver = to_service_driver(device->driver);
242 if (driver &&
243 driver->err_handler &&
244 driver->err_handler->resume) {
245 pcie_device = to_pcie_device(device);
246
247 /* Forward error message to service drivers */
248 driver->err_handler->resume(pcie_device->port);
249 }
250 }
251
252 return 0;
253}
254
255static void pcie_portdrv_err_resume(struct pci_dev *dev)
256{
257 int retval;
258 /* nothing to do with error value, if it ever happens */
259 retval = device_for_each_child(&dev->dev, NULL, resume_iter);
104} 260}
105#endif
106 261
107/* 262/*
108 * LINUX Device Driver Model 263 * LINUX Device Driver Model
@@ -114,6 +269,13 @@ static const struct pci_device_id port_pci_ids[] = { {
114}; 269};
115MODULE_DEVICE_TABLE(pci, port_pci_ids); 270MODULE_DEVICE_TABLE(pci, port_pci_ids);
116 271
272static struct pci_error_handlers pcie_portdrv_err_handler = {
273 .error_detected = pcie_portdrv_error_detected,
274 .mmio_enabled = pcie_portdrv_mmio_enabled,
275 .slot_reset = pcie_portdrv_slot_reset,
276 .resume = pcie_portdrv_err_resume,
277};
278
117static struct pci_driver pcie_portdrv = { 279static struct pci_driver pcie_portdrv = {
118 .name = (char *)device_name, 280 .name = (char *)device_name,
119 .id_table = &port_pci_ids[0], 281 .id_table = &port_pci_ids[0],
@@ -121,20 +283,25 @@ static struct pci_driver pcie_portdrv = {
121 .probe = pcie_portdrv_probe, 283 .probe = pcie_portdrv_probe,
122 .remove = pcie_portdrv_remove, 284 .remove = pcie_portdrv_remove,
123 285
124#ifdef CONFIG_PM
125 .suspend = pcie_portdrv_suspend, 286 .suspend = pcie_portdrv_suspend,
126 .resume = pcie_portdrv_resume, 287 .resume = pcie_portdrv_resume,
127#endif /* PM */ 288
289 .err_handler = &pcie_portdrv_err_handler,
128}; 290};
129 291
130static int __init pcie_portdrv_init(void) 292static int __init pcie_portdrv_init(void)
131{ 293{
132 int retval = 0; 294 int retval;
133 295
134 pcie_port_bus_register(); 296 retval = pcie_port_bus_register();
297 if (retval) {
298 printk(KERN_WARNING "PCIE: bus_register error: %d\n", retval);
299 goto out;
300 }
135 retval = pci_register_driver(&pcie_portdrv); 301 retval = pci_register_driver(&pcie_portdrv);
136 if (retval) 302 if (retval)
137 pcie_port_bus_unregister(); 303 pcie_port_bus_unregister();
304 out:
138 return retval; 305 return retval;
139} 306}
140 307
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index c5a58d1c6c1c..a3b0a5eb5054 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -339,6 +339,7 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
339{ 339{
340 struct pci_bus *child; 340 struct pci_bus *child;
341 int i; 341 int i;
342 int retval;
342 343
343 /* 344 /*
344 * Allocate a new bus, and inherit stuff from the parent.. 345 * Allocate a new bus, and inherit stuff from the parent..
@@ -356,8 +357,13 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
356 357
357 child->class_dev.class = &pcibus_class; 358 child->class_dev.class = &pcibus_class;
358 sprintf(child->class_dev.class_id, "%04x:%02x", pci_domain_nr(child), busnr); 359 sprintf(child->class_dev.class_id, "%04x:%02x", pci_domain_nr(child), busnr);
359 class_device_register(&child->class_dev); 360 retval = class_device_register(&child->class_dev);
360 class_device_create_file(&child->class_dev, &class_device_attr_cpuaffinity); 361 if (retval)
362 goto error_register;
363 retval = class_device_create_file(&child->class_dev,
364 &class_device_attr_cpuaffinity);
365 if (retval)
366 goto error_file_create;
361 367
362 /* 368 /*
363 * Set up the primary, secondary and subordinate 369 * Set up the primary, secondary and subordinate
@@ -375,6 +381,12 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
375 bridge->subordinate = child; 381 bridge->subordinate = child;
376 382
377 return child; 383 return child;
384
385error_file_create:
386 class_device_unregister(&child->class_dev);
387error_register:
388 kfree(child);
389 return NULL;
378} 390}
379 391
380struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr) 392struct pci_bus * __devinit pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr)
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index def78a2a7c15..08cd86a6dd66 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -577,8 +577,6 @@ static void __init quirk_ioapic_rmw(struct pci_dev *dev)
577} 577}
578DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, PCI_ANY_ID, quirk_ioapic_rmw ); 578DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI, PCI_ANY_ID, quirk_ioapic_rmw );
579 579
580int pci_msi_quirk;
581
582#define AMD8131_revA0 0x01 580#define AMD8131_revA0 0x01
583#define AMD8131_revB0 0x11 581#define AMD8131_revB0 0x11
584#define AMD8131_MISC 0x40 582#define AMD8131_MISC 0x40
@@ -587,12 +585,6 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev)
587{ 585{
588 unsigned char revid, tmp; 586 unsigned char revid, tmp;
589 587
590 if (dev->subordinate) {
591 printk(KERN_WARNING "PCI: MSI quirk detected. "
592 "PCI_BUS_FLAGS_NO_MSI set for subordinate bus.\n");
593 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
594 }
595
596 if (nr_ioapics == 0) 588 if (nr_ioapics == 0)
597 return; 589 return;
598 590
@@ -605,13 +597,6 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev)
605 } 597 }
606} 598}
607DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic); 599DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_amd_8131_ioapic);
608
609static void __init quirk_svw_msi(struct pci_dev *dev)
610{
611 pci_msi_quirk = 1;
612 printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n");
613}
614DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_svw_msi );
615#endif /* CONFIG_X86_IO_APIC */ 600#endif /* CONFIG_X86_IO_APIC */
616 601
617 602
@@ -1690,6 +1675,95 @@ static void __devinit quirk_nvidia_ck804_pcie_aer_ext_cap(struct pci_dev *dev)
1690DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE, 1675DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
1691 quirk_nvidia_ck804_pcie_aer_ext_cap); 1676 quirk_nvidia_ck804_pcie_aer_ext_cap);
1692 1677
1678#ifdef CONFIG_PCI_MSI
1679/* To disable MSI globally */
1680int pci_msi_quirk;
1681
1682/* The Serverworks PCI-X chipset does not support MSI. We cannot easily rely
1683 * on setting PCI_BUS_FLAGS_NO_MSI in its bus flags because there are actually
1684 * some other busses controlled by the chipset even if Linux is not aware of it.
1685 * Instead of setting the flag on all busses in the machine, simply disable MSI
1686 * globally.
1687 */
1688static void __init quirk_svw_msi(struct pci_dev *dev)
1689{
1690 pci_msi_quirk = 1;
1691 printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n");
1692}
1693DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_GCNB_LE, quirk_svw_msi);
1694
1695/* Disable MSI on chipsets that are known to not support it */
1696static void __devinit quirk_disable_msi(struct pci_dev *dev)
1697{
1698 if (dev->subordinate) {
1699 printk(KERN_WARNING "PCI: MSI quirk detected. "
1700 "PCI_BUS_FLAGS_NO_MSI set for %s subordinate bus.\n",
1701 pci_name(dev));
1702 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
1703 }
1704}
1705DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE, quirk_disable_msi);
1706
1707/* Go through the list of Hypertransport capabilities and
1708 * return 1 if a HT MSI capability is found and enabled */
1709static int __devinit msi_ht_cap_enabled(struct pci_dev *dev)
1710{
1711 u8 pos;
1712 int ttl;
1713 for (pos = pci_find_capability(dev, PCI_CAP_ID_HT), ttl = 48;
1714 pos && ttl;
1715 pos = pci_find_next_capability(dev, pos, PCI_CAP_ID_HT), ttl--) {
1716 u32 cap_hdr;
1717 /* MSI mapping section according to Hypertransport spec */
1718 if (pci_read_config_dword(dev, pos, &cap_hdr) == 0
1719 && (cap_hdr & 0xf8000000) == 0xa8000000 /* MSI mapping */) {
1720 printk(KERN_INFO "PCI: Found HT MSI mapping on %s with capability %s\n",
1721 pci_name(dev), cap_hdr & 0x10000 ? "enabled" : "disabled");
1722 return (cap_hdr & 0x10000) != 0; /* MSI mapping cap enabled */
1723 }
1724 }
1725 return 0;
1726}
1727
1728/* Check the hypertransport MSI mapping to know whether MSI is enabled or not */
1729static void __devinit quirk_msi_ht_cap(struct pci_dev *dev)
1730{
1731 if (dev->subordinate && !msi_ht_cap_enabled(dev)) {
1732 printk(KERN_WARNING "PCI: MSI quirk detected. "
1733 "MSI disabled on chipset %s.\n",
1734 pci_name(dev));
1735 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
1736 }
1737}
1738DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE,
1739 quirk_msi_ht_cap);
1740
1741/* The nVidia CK804 chipset may have 2 HT MSI mappings.
1742 * MSI are supported if the MSI capability set in any of these mappings.
1743 */
1744static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
1745{
1746 struct pci_dev *pdev;
1747
1748 if (!dev->subordinate)
1749 return;
1750
1751 /* check HT MSI cap on this chipset and the root one.
1752 * a single one having MSI is enough to be sure that MSI are supported.
1753 */
1754 pdev = pci_find_slot(dev->bus->number, 0);
1755 if (dev->subordinate && !msi_ht_cap_enabled(dev)
1756 && !msi_ht_cap_enabled(pdev)) {
1757 printk(KERN_WARNING "PCI: MSI quirk detected. "
1758 "MSI disabled on chipset %s.\n",
1759 pci_name(dev));
1760 dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
1761 }
1762}
1763DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
1764 quirk_nvidia_ck804_msi_ht_cap);
1765#endif /* CONFIG_PCI_MSI */
1766
1693EXPORT_SYMBOL(pcie_mch_quirk); 1767EXPORT_SYMBOL(pcie_mch_quirk);
1694#ifdef CONFIG_HOTPLUG 1768#ifdef CONFIG_HOTPLUG
1695EXPORT_SYMBOL(pci_fixup_device); 1769EXPORT_SYMBOL(pci_fixup_device);
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
index 99ffbd478b29..430281b2e921 100644
--- a/drivers/pci/remove.c
+++ b/drivers/pci/remove.c
@@ -16,8 +16,11 @@ static void pci_free_resources(struct pci_dev *dev)
16 } 16 }
17} 17}
18 18
19static void pci_destroy_dev(struct pci_dev *dev) 19static void pci_stop_dev(struct pci_dev *dev)
20{ 20{
21 if (!dev->global_list.next)
22 return;
23
21 if (!list_empty(&dev->global_list)) { 24 if (!list_empty(&dev->global_list)) {
22 pci_proc_detach_device(dev); 25 pci_proc_detach_device(dev);
23 pci_remove_sysfs_dev_files(dev); 26 pci_remove_sysfs_dev_files(dev);
@@ -27,6 +30,11 @@ static void pci_destroy_dev(struct pci_dev *dev)
27 dev->global_list.next = dev->global_list.prev = NULL; 30 dev->global_list.next = dev->global_list.prev = NULL;
28 up_write(&pci_bus_sem); 31 up_write(&pci_bus_sem);
29 } 32 }
33}
34
35static void pci_destroy_dev(struct pci_dev *dev)
36{
37 pci_stop_dev(dev);
30 38
31 /* Remove the device from the device lists, and prevent any further 39 /* Remove the device from the device lists, and prevent any further
32 * list accesses from this device */ 40 * list accesses from this device */
@@ -119,5 +127,32 @@ void pci_remove_behind_bridge(struct pci_dev *dev)
119 } 127 }
120} 128}
121 129
130static void pci_stop_bus_devices(struct pci_bus *bus)
131{
132 struct list_head *l, *n;
133
134 list_for_each_safe(l, n, &bus->devices) {
135 struct pci_dev *dev = pci_dev_b(l);
136 pci_stop_bus_device(dev);
137 }
138}
139
140/**
141 * pci_stop_bus_device - stop a PCI device and any children
142 * @dev: the device to stop
143 *
144 * Stop a PCI device (detach the driver, remove from the global list
145 * and so on). This also stop any subordinate buses and children in a
146 * depth-first manner.
147 */
148void pci_stop_bus_device(struct pci_dev *dev)
149{
150 if (dev->subordinate)
151 pci_stop_bus_devices(dev->subordinate);
152
153 pci_stop_dev(dev);
154}
155
122EXPORT_SYMBOL(pci_remove_bus_device); 156EXPORT_SYMBOL(pci_remove_bus_device);
123EXPORT_SYMBOL(pci_remove_behind_bridge); 157EXPORT_SYMBOL(pci_remove_behind_bridge);
158EXPORT_SYMBOL_GPL(pci_stop_bus_device);
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 47c1071ad84e..54404917be9a 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -55,12 +55,19 @@ pbus_assign_resources_sorted(struct pci_bus *bus)
55 list_for_each_entry(dev, &bus->devices, bus_list) { 55 list_for_each_entry(dev, &bus->devices, bus_list) {
56 u16 class = dev->class >> 8; 56 u16 class = dev->class >> 8;
57 57
58 /* Don't touch classless devices or host bridges or ioapics. */ 58 /* Don't touch classless devices or host bridges. */
59 if (class == PCI_CLASS_NOT_DEFINED || 59 if (class == PCI_CLASS_NOT_DEFINED ||
60 class == PCI_CLASS_BRIDGE_HOST || 60 class == PCI_CLASS_BRIDGE_HOST)
61 class == PCI_CLASS_SYSTEM_PIC)
62 continue; 61 continue;
63 62
63 /* Don't touch ioapics if it has the assigned resources. */
64 if (class == PCI_CLASS_SYSTEM_PIC) {
65 res = &dev->resource[0];
66 if (res[0].start || res[1].start || res[2].start ||
67 res[3].start || res[4].start || res[5].start)
68 continue;
69 }
70
64 pdev_sort_resources(dev, &head); 71 pdev_sort_resources(dev, &head);
65 } 72 }
66 73
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 7ff1d88094b6..33a7b720539b 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -238,6 +238,16 @@ config RTC_DRV_SA1100
238 To compile this driver as a module, choose M here: the 238 To compile this driver as a module, choose M here: the
239 module will be called rtc-sa1100. 239 module will be called rtc-sa1100.
240 240
241config RTC_DRV_SH
242 tristate "SuperH On-Chip RTC"
243 depends on RTC_CLASS && SUPERH
244 help
245 Say Y here to enable support for the on-chip RTC found in
246 most SuperH processors.
247
248 To compile this driver as a module, choose M here: the
249 module will be called rtc-sh.
250
241config RTC_DRV_VR41XX 251config RTC_DRV_VR41XX
242 tristate "NEC VR41XX" 252 tristate "NEC VR41XX"
243 depends on RTC_CLASS && CPU_VR41XX 253 depends on RTC_CLASS && CPU_VR41XX
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index bbcfb09d81d9..e72d467ab214 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
31obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o 31obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o
32obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o 32obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o
33obj-$(CONFIG_RTC_DRV_AT91) += rtc-at91.o 33obj-$(CONFIG_RTC_DRV_AT91) += rtc-at91.o
34obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c
new file mode 100644
index 000000000000..d2ce0c8bb8f3
--- /dev/null
+++ b/drivers/rtc/rtc-sh.c
@@ -0,0 +1,467 @@
1/*
2 * SuperH On-Chip RTC Support
3 *
4 * Copyright (C) 2006 Paul Mundt
5 *
6 * Based on the old arch/sh/kernel/cpu/rtc.c by:
7 *
8 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
9 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/bcd.h>
18#include <linux/rtc.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21#include <linux/seq_file.h>
22#include <linux/interrupt.h>
23#include <linux/spinlock.h>
24#include <asm/io.h>
25
26#ifdef CONFIG_CPU_SH3
27#define rtc_reg_size sizeof(u16)
28#define RTC_BIT_INVERTED 0 /* No bug on SH7708, SH7709A */
29#elif defined(CONFIG_CPU_SH4)
30#define rtc_reg_size sizeof(u32)
31#define RTC_BIT_INVERTED 0x40 /* bug on SH7750, SH7750S */
32#endif
33
34#define RTC_REG(r) ((r) * rtc_reg_size)
35
36#define R64CNT RTC_REG(0)
37#define RSECCNT RTC_REG(1)
38#define RMINCNT RTC_REG(2)
39#define RHRCNT RTC_REG(3)
40#define RWKCNT RTC_REG(4)
41#define RDAYCNT RTC_REG(5)
42#define RMONCNT RTC_REG(6)
43#define RYRCNT RTC_REG(7)
44#define RSECAR RTC_REG(8)
45#define RMINAR RTC_REG(9)
46#define RHRAR RTC_REG(10)
47#define RWKAR RTC_REG(11)
48#define RDAYAR RTC_REG(12)
49#define RMONAR RTC_REG(13)
50#define RCR1 RTC_REG(14)
51#define RCR2 RTC_REG(15)
52
53/* RCR1 Bits */
54#define RCR1_CF 0x80 /* Carry Flag */
55#define RCR1_CIE 0x10 /* Carry Interrupt Enable */
56#define RCR1_AIE 0x08 /* Alarm Interrupt Enable */
57#define RCR1_AF 0x01 /* Alarm Flag */
58
59/* RCR2 Bits */
60#define RCR2_PEF 0x80 /* PEriodic interrupt Flag */
61#define RCR2_PESMASK 0x70 /* Periodic interrupt Set */
62#define RCR2_RTCEN 0x08 /* ENable RTC */
63#define RCR2_ADJ 0x04 /* ADJustment (30-second) */
64#define RCR2_RESET 0x02 /* Reset bit */
65#define RCR2_START 0x01 /* Start bit */
66
67struct sh_rtc {
68 void __iomem *regbase;
69 unsigned long regsize;
70 struct resource *res;
71 unsigned int alarm_irq, periodic_irq, carry_irq;
72 struct rtc_device *rtc_dev;
73 spinlock_t lock;
74};
75
76static irqreturn_t sh_rtc_interrupt(int irq, void *id, struct pt_regs *regs)
77{
78 struct platform_device *pdev = id;
79 struct sh_rtc *rtc = platform_get_drvdata(pdev);
80 unsigned int tmp, events = 0;
81
82 spin_lock(&rtc->lock);
83
84 tmp = readb(rtc->regbase + RCR1);
85
86 if (tmp & RCR1_AF)
87 events |= RTC_AF | RTC_IRQF;
88
89 tmp &= ~(RCR1_CF | RCR1_AF);
90
91 writeb(tmp, rtc->regbase + RCR1);
92
93 rtc_update_irq(&rtc->rtc_dev->class_dev, 1, events);
94
95 spin_unlock(&rtc->lock);
96
97 return IRQ_HANDLED;
98}
99
100static irqreturn_t sh_rtc_periodic(int irq, void *id, struct pt_regs *regs)
101{
102 struct sh_rtc *rtc = dev_get_drvdata(id);
103
104 spin_lock(&rtc->lock);
105
106 rtc_update_irq(&rtc->rtc_dev->class_dev, 1, RTC_PF | RTC_IRQF);
107
108 spin_unlock(&rtc->lock);
109
110 return IRQ_HANDLED;
111}
112
113static inline void sh_rtc_setpie(struct device *dev, unsigned int enable)
114{
115 struct sh_rtc *rtc = dev_get_drvdata(dev);
116 unsigned int tmp;
117
118 spin_lock_irq(&rtc->lock);
119
120 tmp = readb(rtc->regbase + RCR2);
121
122 if (enable) {
123 tmp &= ~RCR2_PESMASK;
124 tmp |= RCR2_PEF | (2 << 4);
125 } else
126 tmp &= ~(RCR2_PESMASK | RCR2_PEF);
127
128 writeb(tmp, rtc->regbase + RCR2);
129
130 spin_unlock_irq(&rtc->lock);
131}
132
133static inline void sh_rtc_setaie(struct device *dev, unsigned int enable)
134{
135 struct sh_rtc *rtc = dev_get_drvdata(dev);
136 unsigned int tmp;
137
138 spin_lock_irq(&rtc->lock);
139
140 tmp = readb(rtc->regbase + RCR1);
141
142 if (enable)
143 tmp |= RCR1_AIE;
144 else
145 tmp &= ~RCR1_AIE;
146
147 writeb(tmp, rtc->regbase + RCR1);
148
149 spin_unlock_irq(&rtc->lock);
150}
151
152static int sh_rtc_open(struct device *dev)
153{
154 struct sh_rtc *rtc = dev_get_drvdata(dev);
155 unsigned int tmp;
156 int ret;
157
158 tmp = readb(rtc->regbase + RCR1);
159 tmp &= ~RCR1_CF;
160 tmp |= RCR1_CIE;
161 writeb(tmp, rtc->regbase + RCR1);
162
163 ret = request_irq(rtc->periodic_irq, sh_rtc_periodic, SA_INTERRUPT,
164 "sh-rtc period", dev);
165 if (unlikely(ret)) {
166 dev_err(dev, "request period IRQ failed with %d, IRQ %d\n",
167 ret, rtc->periodic_irq);
168 return ret;
169 }
170
171 ret = request_irq(rtc->carry_irq, sh_rtc_interrupt, SA_INTERRUPT,
172 "sh-rtc carry", dev);
173 if (unlikely(ret)) {
174 dev_err(dev, "request carry IRQ failed with %d, IRQ %d\n",
175 ret, rtc->carry_irq);
176 free_irq(rtc->periodic_irq, dev);
177 goto err_bad_carry;
178 }
179
180 ret = request_irq(rtc->alarm_irq, sh_rtc_interrupt, SA_INTERRUPT,
181 "sh-rtc alarm", dev);
182 if (unlikely(ret)) {
183 dev_err(dev, "request alarm IRQ failed with %d, IRQ %d\n",
184 ret, rtc->alarm_irq);
185 goto err_bad_alarm;
186 }
187
188 return 0;
189
190err_bad_alarm:
191 free_irq(rtc->carry_irq, dev);
192err_bad_carry:
193 free_irq(rtc->periodic_irq, dev);
194
195 return ret;
196}
197
198static void sh_rtc_release(struct device *dev)
199{
200 struct sh_rtc *rtc = dev_get_drvdata(dev);
201
202 sh_rtc_setpie(dev, 0);
203
204 free_irq(rtc->periodic_irq, dev);
205 free_irq(rtc->carry_irq, dev);
206 free_irq(rtc->alarm_irq, dev);
207}
208
209static int sh_rtc_proc(struct device *dev, struct seq_file *seq)
210{
211 struct sh_rtc *rtc = dev_get_drvdata(dev);
212 unsigned int tmp;
213
214 tmp = readb(rtc->regbase + RCR1);
215 seq_printf(seq, "alarm_IRQ\t: %s\n",
216 (tmp & RCR1_AIE) ? "yes" : "no");
217 seq_printf(seq, "carry_IRQ\t: %s\n",
218 (tmp & RCR1_CIE) ? "yes" : "no");
219
220 tmp = readb(rtc->regbase + RCR2);
221 seq_printf(seq, "periodic_IRQ\t: %s\n",
222 (tmp & RCR2_PEF) ? "yes" : "no");
223
224 return 0;
225}
226
227static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
228{
229 unsigned int ret = -ENOIOCTLCMD;
230
231 switch (cmd) {
232 case RTC_PIE_OFF:
233 case RTC_PIE_ON:
234 sh_rtc_setpie(dev, cmd == RTC_PIE_ON);
235 ret = 0;
236 break;
237 case RTC_AIE_OFF:
238 case RTC_AIE_ON:
239 sh_rtc_setaie(dev, cmd == RTC_AIE_ON);
240 ret = 0;
241 break;
242 }
243
244 return ret;
245}
246
247static int sh_rtc_read_time(struct device *dev, struct rtc_time *tm)
248{
249 struct platform_device *pdev = to_platform_device(dev);
250 struct sh_rtc *rtc = platform_get_drvdata(pdev);
251 unsigned int sec128, sec2, yr, yr100, cf_bit;
252
253 do {
254 unsigned int tmp;
255
256 spin_lock_irq(&rtc->lock);
257
258 tmp = readb(rtc->regbase + RCR1);
259 tmp &= ~RCR1_CF; /* Clear CF-bit */
260 tmp |= RCR1_CIE;
261 writeb(tmp, rtc->regbase + RCR1);
262
263 sec128 = readb(rtc->regbase + R64CNT);
264
265 tm->tm_sec = BCD2BIN(readb(rtc->regbase + RSECCNT));
266 tm->tm_min = BCD2BIN(readb(rtc->regbase + RMINCNT));
267 tm->tm_hour = BCD2BIN(readb(rtc->regbase + RHRCNT));
268 tm->tm_wday = BCD2BIN(readb(rtc->regbase + RWKCNT));
269 tm->tm_mday = BCD2BIN(readb(rtc->regbase + RDAYCNT));
270 tm->tm_mon = BCD2BIN(readb(rtc->regbase + RMONCNT));
271
272#if defined(CONFIG_CPU_SH4)
273 yr = readw(rtc->regbase + RYRCNT);
274 yr100 = BCD2BIN(yr >> 8);
275 yr &= 0xff;
276#else
277 yr = readb(rtc->regbase + RYRCNT);
278 yr100 = BCD2BIN((yr == 0x99) ? 0x19 : 0x20);
279#endif
280
281 tm->tm_year = (yr100 * 100 + BCD2BIN(yr)) - 1900;
282
283 sec2 = readb(rtc->regbase + R64CNT);
284 cf_bit = readb(rtc->regbase + RCR1) & RCR1_CF;
285
286 spin_unlock_irq(&rtc->lock);
287 } while (cf_bit != 0 || ((sec128 ^ sec2) & RTC_BIT_INVERTED) != 0);
288
289#if RTC_BIT_INVERTED != 0
290 if ((sec128 & RTC_BIT_INVERTED))
291 tm->tm_sec--;
292#endif
293
294 dev_dbg(&dev, "%s: tm is secs=%d, mins=%d, hours=%d, "
295 "mday=%d, mon=%d, year=%d, wday=%d\n",
296 __FUNCTION__,
297 tm->tm_sec, tm->tm_min, tm->tm_hour,
298 tm->tm_mday, tm->tm_mon, tm->tm_year, tm->tm_wday);
299
300 if (rtc_valid_tm(tm) < 0)
301 dev_err(dev, "invalid date\n");
302
303 return 0;
304}
305
306static int sh_rtc_set_time(struct device *dev, struct rtc_time *tm)
307{
308 struct platform_device *pdev = to_platform_device(dev);
309 struct sh_rtc *rtc = platform_get_drvdata(pdev);
310 unsigned int tmp;
311 int year;
312
313 spin_lock_irq(&rtc->lock);
314
315 /* Reset pre-scaler & stop RTC */
316 tmp = readb(rtc->regbase + RCR2);
317 tmp |= RCR2_RESET;
318 writeb(tmp, rtc->regbase + RCR2);
319
320 writeb(BIN2BCD(tm->tm_sec), rtc->regbase + RSECCNT);
321 writeb(BIN2BCD(tm->tm_min), rtc->regbase + RMINCNT);
322 writeb(BIN2BCD(tm->tm_hour), rtc->regbase + RHRCNT);
323 writeb(BIN2BCD(tm->tm_wday), rtc->regbase + RWKCNT);
324 writeb(BIN2BCD(tm->tm_mday), rtc->regbase + RDAYCNT);
325 writeb(BIN2BCD(tm->tm_mon), rtc->regbase + RMONCNT);
326
327#ifdef CONFIG_CPU_SH3
328 year = tm->tm_year % 100;
329 writeb(BIN2BCD(year), rtc->regbase + RYRCNT);
330#else
331 year = (BIN2BCD((tm->tm_year + 1900) / 100) << 8) |
332 BIN2BCD(tm->tm_year % 100);
333 writew(year, rtc->regbase + RYRCNT);
334#endif
335
336 /* Start RTC */
337 tmp = readb(rtc->regbase + RCR2);
338 tmp &= ~RCR2_RESET;
339 tmp |= RCR2_RTCEN | RCR2_START;
340 writeb(tmp, rtc->regbase + RCR2);
341
342 spin_unlock_irq(&rtc->lock);
343
344 return 0;
345}
346
347static struct rtc_class_ops sh_rtc_ops = {
348 .open = sh_rtc_open,
349 .release = sh_rtc_release,
350 .ioctl = sh_rtc_ioctl,
351 .read_time = sh_rtc_read_time,
352 .set_time = sh_rtc_set_time,
353 .proc = sh_rtc_proc,
354};
355
356static int __devinit sh_rtc_probe(struct platform_device *pdev)
357{
358 struct sh_rtc *rtc;
359 struct resource *res;
360 int ret = -ENOENT;
361
362 rtc = kzalloc(sizeof(struct sh_rtc), GFP_KERNEL);
363 if (unlikely(!rtc))
364 return -ENOMEM;
365
366 spin_lock_init(&rtc->lock);
367
368 rtc->periodic_irq = platform_get_irq(pdev, 0);
369 if (unlikely(rtc->periodic_irq < 0)) {
370 dev_err(&pdev->dev, "No IRQ for period\n");
371 goto err_badres;
372 }
373
374 rtc->carry_irq = platform_get_irq(pdev, 1);
375 if (unlikely(rtc->carry_irq < 0)) {
376 dev_err(&pdev->dev, "No IRQ for carry\n");
377 goto err_badres;
378 }
379
380 rtc->alarm_irq = platform_get_irq(pdev, 2);
381 if (unlikely(rtc->alarm_irq < 0)) {
382 dev_err(&pdev->dev, "No IRQ for alarm\n");
383 goto err_badres;
384 }
385
386 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
387 if (unlikely(res == NULL)) {
388 dev_err(&pdev->dev, "No IO resource\n");
389 goto err_badres;
390 }
391
392 rtc->regsize = res->end - res->start + 1;
393
394 rtc->res = request_mem_region(res->start, rtc->regsize, pdev->name);
395 if (unlikely(!rtc->res)) {
396 ret = -EBUSY;
397 goto err_badres;
398 }
399
400 rtc->regbase = (void __iomem *)rtc->res->start;
401 if (unlikely(!rtc->regbase)) {
402 ret = -EINVAL;
403 goto err_badmap;
404 }
405
406 rtc->rtc_dev = rtc_device_register("sh", &pdev->dev,
407 &sh_rtc_ops, THIS_MODULE);
408 if (IS_ERR(rtc)) {
409 ret = PTR_ERR(rtc->rtc_dev);
410 goto err_badmap;
411 }
412
413 platform_set_drvdata(pdev, rtc);
414
415 return 0;
416
417err_badmap:
418 release_resource(rtc->res);
419err_badres:
420 kfree(rtc);
421
422 return ret;
423}
424
425static int __devexit sh_rtc_remove(struct platform_device *pdev)
426{
427 struct sh_rtc *rtc = platform_get_drvdata(pdev);
428
429 if (likely(rtc->rtc_dev))
430 rtc_device_unregister(rtc->rtc_dev);
431
432 sh_rtc_setpie(&pdev->dev, 0);
433 sh_rtc_setaie(&pdev->dev, 0);
434
435 release_resource(rtc->res);
436
437 platform_set_drvdata(pdev, NULL);
438
439 kfree(rtc);
440
441 return 0;
442}
443static struct platform_driver sh_rtc_platform_driver = {
444 .driver = {
445 .name = "sh-rtc",
446 .owner = THIS_MODULE,
447 },
448 .probe = sh_rtc_probe,
449 .remove = __devexit_p(sh_rtc_remove),
450};
451
452static int __init sh_rtc_init(void)
453{
454 return platform_driver_register(&sh_rtc_platform_driver);
455}
456
457static void __exit sh_rtc_exit(void)
458{
459 platform_driver_unregister(&sh_rtc_platform_driver);
460}
461
462module_init(sh_rtc_init);
463module_exit(sh_rtc_exit);
464
465MODULE_DESCRIPTION("SuperH on-chip RTC driver");
466MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>");
467MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 0e4a7ebe300a..6b35ed8301e0 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -681,6 +681,7 @@ static struct eisa_device_id aha1740_ids[] = {
681 { "ADP0400" }, /* 1744 */ 681 { "ADP0400" }, /* 1744 */
682 { "" } 682 { "" }
683}; 683};
684MODULE_DEVICE_TABLE(eisa, aha1740_ids);
684 685
685static struct eisa_driver aha1740_driver = { 686static struct eisa_driver aha1740_driver = {
686 .id_table = aha1740_ids, 687 .id_table = aha1740_ids,
diff --git a/drivers/scsi/aic7xxx/aic7770_osm.c b/drivers/scsi/aic7xxx/aic7770_osm.c
index 867cbe23579b..1ac119733bac 100644
--- a/drivers/scsi/aic7xxx/aic7770_osm.c
+++ b/drivers/scsi/aic7xxx/aic7770_osm.c
@@ -132,7 +132,8 @@ static struct eisa_device_id aic7770_ids[] = {
132 { "ADP7770", 5 }, /* AIC7770 generic */ 132 { "ADP7770", 5 }, /* AIC7770 generic */
133 { "" } 133 { "" }
134}; 134};
135 135MODULE_DEVICE_TABLE(eisa, aic7770_ids);
136
136static struct eisa_driver aic7770_driver = { 137static struct eisa_driver aic7770_driver = {
137 .id_table = aic7770_ids, 138 .id_table = aic7770_ids,
138 .driver = { 139 .driver = {
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 592b52afe658..683fc7ae4b8f 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1756,16 +1756,23 @@ static void set_mesh_power(struct mesh_state *ms, int state)
1756 pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 0); 1756 pmac_call_feature(PMAC_FTR_MESH_ENABLE, macio_get_of_node(ms->mdev), 0, 0);
1757 msleep(10); 1757 msleep(10);
1758 } 1758 }
1759} 1759}
1760 1760
1761 1761
1762#ifdef CONFIG_PM 1762#ifdef CONFIG_PM
1763static int mesh_suspend(struct macio_dev *mdev, pm_message_t state) 1763static int mesh_suspend(struct macio_dev *mdev, pm_message_t mesg)
1764{ 1764{
1765 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev); 1765 struct mesh_state *ms = (struct mesh_state *)macio_get_drvdata(mdev);
1766 unsigned long flags; 1766 unsigned long flags;
1767 1767
1768 if (state.event == mdev->ofdev.dev.power.power_state.event || state.event < 2) 1768 switch (mesg.event) {
1769 case PM_EVENT_SUSPEND:
1770 case PM_EVENT_FREEZE:
1771 break;
1772 default:
1773 return 0;
1774 }
1775 if (mesg.event == mdev->ofdev.dev.power.power_state.event)
1769 return 0; 1776 return 0;
1770 1777
1771 scsi_block_requests(ms->host); 1778 scsi_block_requests(ms->host);
@@ -1780,7 +1787,7 @@ static int mesh_suspend(struct macio_dev *mdev, pm_message_t state)
1780 disable_irq(ms->meshintr); 1787 disable_irq(ms->meshintr);
1781 set_mesh_power(ms, 0); 1788 set_mesh_power(ms, 0);
1782 1789
1783 mdev->ofdev.dev.power.power_state = state; 1790 mdev->ofdev.dev.power.power_state = mesg;
1784 1791
1785 return 0; 1792 return 0;
1786} 1793}
diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index b27e85428daa..551baccec523 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -282,6 +282,7 @@ static struct eisa_device_id sim710_eisa_ids[] = {
282 { "HWP0C80" }, 282 { "HWP0C80" },
283 { "" } 283 { "" }
284}; 284};
285MODULE_DEVICE_TABLE(eisa, sim710_eisa_ids);
285 286
286static __init int 287static __init int
287sim710_eisa_probe(struct device *dev) 288sim710_eisa_probe(struct device *dev)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 5b48ac22c9c5..261eaa442953 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -642,12 +642,17 @@ config V850E_UART_CONSOLE
642 select SERIAL_CORE_CONSOLE 642 select SERIAL_CORE_CONSOLE
643 643
644config SERIAL_SH_SCI 644config SERIAL_SH_SCI
645 tristate "SH SCI(F) serial port support" 645 tristate "SuperH SCI(F) serial port support"
646 depends on SUPERH || H8300 646 depends on SUPERH || H8300
647 select SERIAL_CORE 647 select SERIAL_CORE
648 648
649config SERIAL_SH_SCI_NR_UARTS
650 int "Maximum number of SCI(F) serial ports"
651 depends on SERIAL_SH_SCI
652 default "2"
653
649config SERIAL_SH_SCI_CONSOLE 654config SERIAL_SH_SCI_CONSOLE
650 bool "Support for console on SH SCI(F)" 655 bool "Support for console on SuperH SCI(F)"
651 depends on SERIAL_SH_SCI=y 656 depends on SERIAL_SH_SCI=y
652 select SERIAL_CORE_CONSOLE 657 select SERIAL_CORE_CONSOLE
653 658
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index cbede06cac27..f336ba6778dd 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO) 4 * SuperH on-chip serial module support. (SCI with no FIFO / with FIFO)
5 * 5 *
6 * Copyright (C) 2002, 2003, 2004 Paul Mundt 6 * Copyright (C) 2002 - 2006 Paul Mundt
7 * 7 *
8 * based off of the old drivers/char/sh-sci.c by: 8 * based off of the old drivers/char/sh-sci.c by:
9 * 9 *
@@ -20,10 +20,9 @@
20 20
21#undef DEBUG 21#undef DEBUG
22 22
23#include <linux/config.h>
23#include <linux/module.h> 24#include <linux/module.h>
24#include <linux/errno.h> 25#include <linux/errno.h>
25#include <linux/signal.h>
26#include <linux/sched.h>
27#include <linux/timer.h> 26#include <linux/timer.h>
28#include <linux/interrupt.h> 27#include <linux/interrupt.h>
29#include <linux/tty.h> 28#include <linux/tty.h>
@@ -32,71 +31,77 @@
32#include <linux/major.h> 31#include <linux/major.h>
33#include <linux/string.h> 32#include <linux/string.h>
34#include <linux/sysrq.h> 33#include <linux/sysrq.h>
35#include <linux/fcntl.h>
36#include <linux/ptrace.h>
37#include <linux/ioport.h> 34#include <linux/ioport.h>
38#include <linux/mm.h> 35#include <linux/mm.h>
39#include <linux/slab.h>
40#include <linux/init.h> 36#include <linux/init.h>
41#include <linux/delay.h> 37#include <linux/delay.h>
42#include <linux/console.h> 38#include <linux/console.h>
43#include <linux/bitops.h> 39#include <linux/platform_device.h>
44#include <linux/generic_serial.h>
45 40
46#ifdef CONFIG_CPU_FREQ 41#ifdef CONFIG_CPU_FREQ
47#include <linux/notifier.h> 42#include <linux/notifier.h>
48#include <linux/cpufreq.h> 43#include <linux/cpufreq.h>
49#endif 44#endif
50 45
51#include <asm/system.h>
52#include <asm/io.h>
53#include <asm/irq.h>
54#include <asm/uaccess.h>
55
56#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64) 46#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
57#include <asm/clock.h> 47#include <asm/clock.h>
58#endif
59
60#ifdef CONFIG_SH_STANDARD_BIOS
61#include <asm/sh_bios.h> 48#include <asm/sh_bios.h>
49#include <asm/kgdb.h>
62#endif 50#endif
63 51
52#include <asm/sci.h>
53
64#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) 54#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
65#define SUPPORT_SYSRQ 55#define SUPPORT_SYSRQ
66#endif 56#endif
67 57
68#include "sh-sci.h" 58#include "sh-sci.h"
69 59
70#ifdef CONFIG_SH_KGDB 60struct sci_port {
71#include <asm/kgdb.h> 61 struct uart_port port;
62
63 /* Port type */
64 unsigned int type;
65
66 /* Port IRQs: ERI, RXI, TXI, BRI (optional) */
67 unsigned int irqs[SCIx_NR_IRQS];
68
69 /* Port pin configuration */
70 void (*init_pins)(struct uart_port *port,
71 unsigned int cflag);
72 72
73static int kgdb_get_char(struct sci_port *port); 73 /* Port enable callback */
74static void kgdb_put_char(struct sci_port *port, char c); 74 void (*enable)(struct uart_port *port);
75static void kgdb_handle_error(struct sci_port *port); 75
76 /* Port disable callback */
77 void (*disable)(struct uart_port *port);
78
79 /* Break timer */
80 struct timer_list break_timer;
81 int break_flag;
82};
83
84#ifdef CONFIG_SH_KGDB
76static struct sci_port *kgdb_sci_port; 85static struct sci_port *kgdb_sci_port;
77#endif /* CONFIG_SH_KGDB */ 86#endif
78 87
79#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 88#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
80static struct sci_port *serial_console_port = 0; 89static struct sci_port *serial_console_port;
81#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 90#endif
82 91
83/* Function prototypes */ 92/* Function prototypes */
84static void sci_stop_tx(struct uart_port *port); 93static void sci_stop_tx(struct uart_port *port);
85static void sci_start_tx(struct uart_port *port);
86static void sci_start_rx(struct uart_port *port, unsigned int tty_start);
87static void sci_stop_rx(struct uart_port *port);
88static int sci_request_irq(struct sci_port *port);
89static void sci_free_irq(struct sci_port *port);
90
91static struct sci_port sci_ports[];
92static struct uart_driver sci_uart_driver;
93 94
94#define SCI_NPORTS sci_uart_driver.nr 95#define SCI_NPORTS CONFIG_SERIAL_SH_SCI_NR_UARTS
95 96
96#if defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB) 97static struct sci_port sci_ports[SCI_NPORTS];
98static struct uart_driver sci_uart_driver;
97 99
98static void handle_error(struct uart_port *port) 100#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) && \
99{ /* Clear error flags */ 101 defined(CONFIG_SH_STANDARD_BIOS) || defined(CONFIG_SH_KGDB)
102static inline void handle_error(struct uart_port *port)
103{
104 /* Clear error flags */
100 sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); 105 sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port));
101} 106}
102 107
@@ -106,8 +111,8 @@ static int get_char(struct uart_port *port)
106 unsigned short status; 111 unsigned short status;
107 int c; 112 int c;
108 113
109 local_irq_save(flags); 114 spin_lock_irqsave(&port->lock, flags);
110 do { 115 do {
111 status = sci_in(port, SCxSR); 116 status = sci_in(port, SCxSR);
112 if (status & SCxSR_ERRORS(port)) { 117 if (status & SCxSR_ERRORS(port)) {
113 handle_error(port); 118 handle_error(port);
@@ -117,38 +122,19 @@ static int get_char(struct uart_port *port)
117 c = sci_in(port, SCxRDR); 122 c = sci_in(port, SCxRDR);
118 sci_in(port, SCxSR); /* Dummy read */ 123 sci_in(port, SCxSR); /* Dummy read */
119 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port)); 124 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
120 local_irq_restore(flags); 125 spin_unlock_irqrestore(&port->lock, flags);
121 126
122 return c; 127 return c;
123} 128}
124
125/* Taken from sh-stub.c of GDB 4.18 */
126static const char hexchars[] = "0123456789abcdef";
127
128static __inline__ char highhex(int x)
129{
130 return hexchars[(x >> 4) & 0xf];
131}
132
133static __inline__ char lowhex(int x)
134{
135 return hexchars[x & 0xf];
136}
137
138#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */ 129#endif /* CONFIG_SH_STANDARD_BIOS || CONFIG_SH_KGDB */
139 130
140/* 131#if defined(CONFIG_SERIAL_SH_SCI_CONSOLE) || defined(CONFIG_SH_KGDB)
141 * Send the packet in buffer. The host gets one chance to read it.
142 * This routine does not wait for a positive acknowledge.
143 */
144
145#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
146static void put_char(struct uart_port *port, char c) 132static void put_char(struct uart_port *port, char c)
147{ 133{
148 unsigned long flags; 134 unsigned long flags;
149 unsigned short status; 135 unsigned short status;
150 136
151 local_irq_save(flags); 137 spin_lock_irqsave(&port->lock, flags);
152 138
153 do { 139 do {
154 status = sci_in(port, SCxSR); 140 status = sci_in(port, SCxSR);
@@ -158,9 +144,11 @@ static void put_char(struct uart_port *port, char c)
158 sci_in(port, SCxSR); /* Dummy read */ 144 sci_in(port, SCxSR); /* Dummy read */
159 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port)); 145 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
160 146
161 local_irq_restore(flags); 147 spin_unlock_irqrestore(&port->lock, flags);
162} 148}
149#endif
163 150
151#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
164static void put_string(struct sci_port *sci_port, const char *buffer, int count) 152static void put_string(struct sci_port *sci_port, const char *buffer, int count)
165{ 153{
166 struct uart_port *port = &sci_port->port; 154 struct uart_port *port = &sci_port->port;
@@ -213,96 +201,28 @@ static void put_string(struct sci_port *sci_port, const char *buffer, int count)
213} 201}
214#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 202#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
215 203
216
217#ifdef CONFIG_SH_KGDB 204#ifdef CONFIG_SH_KGDB
218
219/* Is the SCI ready, ie is there a char waiting? */
220static int kgdb_is_char_ready(struct sci_port *port)
221{
222 unsigned short status = sci_in(port, SCxSR);
223
224 if (status & (SCxSR_ERRORS(port) | SCxSR_BRK(port)))
225 kgdb_handle_error(port);
226
227 return (status & SCxSR_RDxF(port));
228}
229
230/* Write a char */
231static void kgdb_put_char(struct sci_port *port, char c)
232{
233 unsigned short status;
234
235 do
236 status = sci_in(port, SCxSR);
237 while (!(status & SCxSR_TDxE(port)));
238
239 sci_out(port, SCxTDR, c);
240 sci_in(port, SCxSR); /* Dummy read */
241 sci_out(port, SCxSR, SCxSR_TDxE_CLEAR(port));
242}
243
244/* Get a char if there is one, else ret -1 */
245static int kgdb_get_char(struct sci_port *port)
246{
247 int c;
248
249 if (kgdb_is_char_ready(port) == 0)
250 c = -1;
251 else {
252 c = sci_in(port, SCxRDR);
253 sci_in(port, SCxSR); /* Dummy read */
254 sci_out(port, SCxSR, SCxSR_RDxF_CLEAR(port));
255 }
256
257 return c;
258}
259
260/* Called from kgdbstub.c to get a character, i.e. is blocking */
261static int kgdb_sci_getchar(void) 205static int kgdb_sci_getchar(void)
262{ 206{
263 volatile int c; 207 int c;
264 208
265 /* Keep trying to read a character, this could be neater */ 209 /* Keep trying to read a character, this could be neater */
266 while ((c = kgdb_get_char(kgdb_sci_port)) < 0); 210 while ((c = get_char(kgdb_sci_port)) < 0)
211 cpu_relax();
267 212
268 return c; 213 return c;
269} 214}
270 215
271/* Called from kgdbstub.c to put a character, just a wrapper */ 216static inline void kgdb_sci_putchar(int c)
272static void kgdb_sci_putchar(int c)
273{
274
275 kgdb_put_char(kgdb_sci_port, c);
276}
277
278/* Clear any errors on the SCI */
279static void kgdb_handle_error(struct sci_port *port)
280{ 217{
281 sci_out(port, SCxSR, SCxSR_ERROR_CLEAR(port)); /* Clear error flags */ 218 put_char(kgdb_sci_port, c);
282} 219}
283
284/* Breakpoint if there's a break sent on the serial port */
285static void kgdb_break_interrupt(int irq, void *ptr, struct pt_regs *regs)
286{
287 struct sci_port *port = ptr;
288 unsigned short status = sci_in(port, SCxSR);
289
290 if (status & SCxSR_BRK(port)) {
291
292 /* Break into the debugger if a break is detected */
293 BREAKPOINT();
294
295 /* Clear */
296 sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
297 }
298}
299
300#endif /* CONFIG_SH_KGDB */ 220#endif /* CONFIG_SH_KGDB */
301 221
302#if defined(__H8300S__) 222#if defined(__H8300S__)
303enum { sci_disable, sci_enable }; 223enum { sci_disable, sci_enable };
304 224
305static void h8300_sci_enable(struct uart_port* port, unsigned int ctrl) 225static void h8300_sci_config(struct uart_port* port, unsigned int ctrl)
306{ 226{
307 volatile unsigned char *mstpcrl=(volatile unsigned char *)MSTPCRL; 227 volatile unsigned char *mstpcrl=(volatile unsigned char *)MSTPCRL;
308 int ch = (port->mapbase - SMR0) >> 3; 228 int ch = (port->mapbase - SMR0) >> 3;
@@ -314,32 +234,66 @@ static void h8300_sci_enable(struct uart_port* port, unsigned int ctrl)
314 *mstpcrl &= ~mask; 234 *mstpcrl &= ~mask;
315 } 235 }
316} 236}
237
238static inline void h8300_sci_enable(struct uart_port *port)
239{
240 h8300_sci_config(port, sci_enable);
241}
242
243static inline void h8300_sci_disable(struct uart_port *port)
244{
245 h8300_sci_config(port, sci_disable);
246}
317#endif 247#endif
318 248
319#if defined(SCI_ONLY) || defined(SCI_AND_SCIF) 249#if defined(SCI_ONLY) || defined(SCI_AND_SCIF) && \
320#if defined(__H8300H__) || defined(__H8300S__) 250 defined(__H8300H__) || defined(__H8300S__)
321static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag) 251static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
322{ 252{
323 int ch = (port->mapbase - SMR0) >> 3; 253 int ch = (port->mapbase - SMR0) >> 3;
324 254
325 /* set DDR regs */ 255 /* set DDR regs */
326 H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].rx,H8300_GPIO_INPUT); 256 H8300_GPIO_DDR(h8300_sci_pins[ch].port,
327 H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].tx,H8300_GPIO_OUTPUT); 257 h8300_sci_pins[ch].rx,
258 H8300_GPIO_INPUT);
259 H8300_GPIO_DDR(h8300_sci_pins[ch].port,
260 h8300_sci_pins[ch].tx,
261 H8300_GPIO_OUTPUT);
262
328 /* tx mark output*/ 263 /* tx mark output*/
329 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx; 264 H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
330} 265}
266#else
267#define sci_init_pins_sci NULL
268#endif
269
270#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
271static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
272{
273 unsigned int fcr_val = 0;
274
275 if (cflag & CRTSCTS)
276 fcr_val |= SCFCR_MCE;
277
278 sci_out(port, SCFCR, fcr_val);
279}
280#else
281#define sci_init_pins_irda NULL
331#endif 282#endif
283
284#ifdef SCI_ONLY
285#define sci_init_pins_scif NULL
332#endif 286#endif
333 287
334#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF) 288#if defined(SCIF_ONLY) || defined(SCI_AND_SCIF)
335#if defined(CONFIG_CPU_SUBTYPE_SH7300) 289#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7710)
336/* SH7300 doesn't use RTS/CTS */ 290/* SH7300 doesn't use RTS/CTS */
337static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 291static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
338{ 292{
339 sci_out(port, SCFCR, 0); 293 sci_out(port, SCFCR, 0);
340} 294}
341#elif defined(CONFIG_CPU_SH3) 295#elif defined(CONFIG_CPU_SH3)
342/* For SH7705, SH7707, SH7709, SH7709A, SH7729 */ 296/* For SH7705, SH7706, SH7707, SH7709, SH7709A, SH7729 */
343static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 297static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
344{ 298{
345 unsigned int fcr_val = 0; 299 unsigned int fcr_val = 0;
@@ -366,20 +320,7 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
366 320
367 sci_out(port, SCFCR, fcr_val); 321 sci_out(port, SCFCR, fcr_val);
368} 322}
369
370#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
371static void sci_init_pins_irda(struct uart_port *port, unsigned int cflag)
372{
373 unsigned int fcr_val = 0;
374
375 if (cflag & CRTSCTS)
376 fcr_val |= SCFCR_MCE;
377
378 sci_out(port, SCFCR, fcr_val);
379}
380#endif
381#else 323#else
382
383/* For SH7750 */ 324/* For SH7750 */
384static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag) 325static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
385{ 326{
@@ -388,7 +329,9 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
388 if (cflag & CRTSCTS) { 329 if (cflag & CRTSCTS) {
389 fcr_val |= SCFCR_MCE; 330 fcr_val |= SCFCR_MCE;
390 } else { 331 } else {
391#ifdef CONFIG_CPU_SUBTYPE_SH7780 332#ifdef CONFIG_CPU_SUBTYPE_SH7343
333 /* Nothing */
334#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
392 ctrl_outw(0x0080, SCSPTR0); /* Set RTS = 1 */ 335 ctrl_outw(0x0080, SCSPTR0); /* Set RTS = 1 */
393#else 336#else
394 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */ 337 ctrl_outw(0x0080, SCSPTR2); /* Set RTS = 1 */
@@ -396,10 +339,41 @@ static void sci_init_pins_scif(struct uart_port *port, unsigned int cflag)
396 } 339 }
397 sci_out(port, SCFCR, fcr_val); 340 sci_out(port, SCFCR, fcr_val);
398} 341}
342#endif
343
344#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780)
345static inline int scif_txroom(struct uart_port *port)
346{
347 return SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f);
348}
349
350static inline int scif_rxroom(struct uart_port *port)
351{
352 return sci_in(port, SCRFDR) & 0x7f;
353}
354#else
355static inline int scif_txroom(struct uart_port *port)
356{
357 return SCIF_TXROOM_MAX - (sci_in(port, SCFDR) >> 8);
358}
399 359
360static inline int scif_rxroom(struct uart_port *port)
361{
362 return sci_in(port, SCFDR) & SCIF_RFDC_MASK;
363}
400#endif 364#endif
401#endif /* SCIF_ONLY || SCI_AND_SCIF */ 365#endif /* SCIF_ONLY || SCI_AND_SCIF */
402 366
367static inline int sci_txroom(struct uart_port *port)
368{
369 return ((sci_in(port, SCxSR) & SCI_TDRE) != 0);
370}
371
372static inline int sci_rxroom(struct uart_port *port)
373{
374 return ((sci_in(port, SCxSR) & SCxSR_RDxF(port)) != 0);
375}
376
403/* ********************************************************************** * 377/* ********************************************************************** *
404 * the interrupt related routines * 378 * the interrupt related routines *
405 * ********************************************************************** */ 379 * ********************************************************************** */
@@ -408,14 +382,12 @@ static void sci_transmit_chars(struct uart_port *port)
408{ 382{
409 struct circ_buf *xmit = &port->info->xmit; 383 struct circ_buf *xmit = &port->info->xmit;
410 unsigned int stopped = uart_tx_stopped(port); 384 unsigned int stopped = uart_tx_stopped(port);
411 unsigned long flags;
412 unsigned short status; 385 unsigned short status;
413 unsigned short ctrl; 386 unsigned short ctrl;
414 int count, txroom; 387 int count;
415 388
416 status = sci_in(port, SCxSR); 389 status = sci_in(port, SCxSR);
417 if (!(status & SCxSR_TDxE(port))) { 390 if (!(status & SCxSR_TDxE(port))) {
418 local_irq_save(flags);
419 ctrl = sci_in(port, SCSCR); 391 ctrl = sci_in(port, SCSCR);
420 if (uart_circ_empty(xmit)) { 392 if (uart_circ_empty(xmit)) {
421 ctrl &= ~SCI_CTRL_FLAGS_TIE; 393 ctrl &= ~SCI_CTRL_FLAGS_TIE;
@@ -423,25 +395,15 @@ static void sci_transmit_chars(struct uart_port *port)
423 ctrl |= SCI_CTRL_FLAGS_TIE; 395 ctrl |= SCI_CTRL_FLAGS_TIE;
424 } 396 }
425 sci_out(port, SCSCR, ctrl); 397 sci_out(port, SCSCR, ctrl);
426 local_irq_restore(flags);
427 return; 398 return;
428 } 399 }
429 400
430#if !defined(SCI_ONLY) 401#ifndef SCI_ONLY
431 if (port->type == PORT_SCIF) { 402 if (port->type == PORT_SCIF)
432#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) 403 count = scif_txroom(port);
433 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCTFDR) & 0x7f); 404 else
434#else
435 txroom = SCIF_TXROOM_MAX - (sci_in(port, SCFDR)>>8);
436#endif
437 } else {
438 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
439 }
440#else
441 txroom = (sci_in(port, SCxSR) & SCI_TDRE)?1:0;
442#endif 405#endif
443 406 count = sci_txroom(port);
444 count = txroom;
445 407
446 do { 408 do {
447 unsigned char c; 409 unsigned char c;
@@ -468,7 +430,6 @@ static void sci_transmit_chars(struct uart_port *port)
468 if (uart_circ_empty(xmit)) { 430 if (uart_circ_empty(xmit)) {
469 sci_stop_tx(port); 431 sci_stop_tx(port);
470 } else { 432 } else {
471 local_irq_save(flags);
472 ctrl = sci_in(port, SCSCR); 433 ctrl = sci_in(port, SCSCR);
473 434
474#if !defined(SCI_ONLY) 435#if !defined(SCI_ONLY)
@@ -480,7 +441,6 @@ static void sci_transmit_chars(struct uart_port *port)
480 441
481 ctrl |= SCI_CTRL_FLAGS_TIE; 442 ctrl |= SCI_CTRL_FLAGS_TIE;
482 sci_out(port, SCSCR, ctrl); 443 sci_out(port, SCSCR, ctrl);
483 local_irq_restore(flags);
484 } 444 }
485} 445}
486 446
@@ -490,6 +450,7 @@ static void sci_transmit_chars(struct uart_port *port)
490static inline void sci_receive_chars(struct uart_port *port, 450static inline void sci_receive_chars(struct uart_port *port,
491 struct pt_regs *regs) 451 struct pt_regs *regs)
492{ 452{
453 struct sci_port *sci_port = (struct sci_port *)port;
493 struct tty_struct *tty = port->info->tty; 454 struct tty_struct *tty = port->info->tty;
494 int i, count, copied = 0; 455 int i, count, copied = 0;
495 unsigned short status; 456 unsigned short status;
@@ -501,18 +462,11 @@ static inline void sci_receive_chars(struct uart_port *port,
501 462
502 while (1) { 463 while (1) {
503#if !defined(SCI_ONLY) 464#if !defined(SCI_ONLY)
504 if (port->type == PORT_SCIF) { 465 if (port->type == PORT_SCIF)
505#if defined(CONFIG_CPU_SUBTYPE_SH7760) || defined(CONFIG_CPU_SUBTYPE_SH7780) 466 count = scif_rxroom(port);
506 count = sci_in(port, SCRFDR) & 0x7f; 467 else
507#else
508 count = sci_in(port, SCFDR)&SCIF_RFDC_MASK ;
509#endif
510 } else {
511 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
512 }
513#else
514 count = (sci_in(port, SCxSR)&SCxSR_RDxF(port))?1:0;
515#endif 468#endif
469 count = sci_rxroom(port);
516 470
517 /* Don't copy more bytes than there is room for in the buffer */ 471 /* Don't copy more bytes than there is room for in the buffer */
518 count = tty_buffer_request_room(tty, count); 472 count = tty_buffer_request_room(tty, count);
@@ -523,11 +477,10 @@ static inline void sci_receive_chars(struct uart_port *port,
523 477
524 if (port->type == PORT_SCI) { 478 if (port->type == PORT_SCI) {
525 char c = sci_in(port, SCxRDR); 479 char c = sci_in(port, SCxRDR);
526 if(((struct sci_port *)port)->break_flag 480 if (uart_handle_sysrq_char(port, c, regs) || sci_port->break_flag)
527 || uart_handle_sysrq_char(port, c, regs)) {
528 count = 0; 481 count = 0;
529 } else { 482 else {
530 tty_insert_flip_char(tty, c, TTY_NORMAL); 483 tty_insert_flip_char(tty, c, TTY_NORMAL);
531 } 484 }
532 } else { 485 } else {
533 for (i=0; i<count; i++) { 486 for (i=0; i<count; i++) {
@@ -535,15 +488,17 @@ static inline void sci_receive_chars(struct uart_port *port,
535 status = sci_in(port, SCxSR); 488 status = sci_in(port, SCxSR);
536#if defined(CONFIG_CPU_SH3) 489#if defined(CONFIG_CPU_SH3)
537 /* Skip "chars" during break */ 490 /* Skip "chars" during break */
538 if (((struct sci_port *)port)->break_flag) { 491 if (sci_port->break_flag) {
539 if ((c == 0) && 492 if ((c == 0) &&
540 (status & SCxSR_FER(port))) { 493 (status & SCxSR_FER(port))) {
541 count--; i--; 494 count--; i--;
542 continue; 495 continue;
543 } 496 }
497
544 /* Nonzero => end-of-break */ 498 /* Nonzero => end-of-break */
545 pr_debug("scif: debounce<%02x>\n", c); 499 pr_debug("scif: debounce<%02x>\n", c);
546 ((struct sci_port *)port)->break_flag = 0; 500 sci_port->break_flag = 0;
501
547 if (STEPFN(c)) { 502 if (STEPFN(c)) {
548 count--; i--; 503 count--; i--;
549 continue; 504 continue;
@@ -600,15 +555,17 @@ static void sci_schedule_break_timer(struct sci_port *port)
600/* Ensure that two consecutive samples find the break over. */ 555/* Ensure that two consecutive samples find the break over. */
601static void sci_break_timer(unsigned long data) 556static void sci_break_timer(unsigned long data)
602{ 557{
603 struct sci_port * port = (struct sci_port *)data; 558 struct sci_port *port = (struct sci_port *)data;
604 if(sci_rxd_in(&port->port) == 0) { 559
560 if (sci_rxd_in(&port->port) == 0) {
605 port->break_flag = 1; 561 port->break_flag = 1;
606 sci_schedule_break_timer(port); 562 sci_schedule_break_timer(port);
607 } else if(port->break_flag == 1){ 563 } else if (port->break_flag == 1) {
608 /* break is over. */ 564 /* break is over. */
609 port->break_flag = 2; 565 port->break_flag = 2;
610 sci_schedule_break_timer(port); 566 sci_schedule_break_timer(port);
611 } else port->break_flag = 0; 567 } else
568 port->break_flag = 0;
612} 569}
613 570
614static inline int sci_handle_errors(struct uart_port *port) 571static inline int sci_handle_errors(struct uart_port *port)
@@ -617,40 +574,41 @@ static inline int sci_handle_errors(struct uart_port *port)
617 unsigned short status = sci_in(port, SCxSR); 574 unsigned short status = sci_in(port, SCxSR);
618 struct tty_struct *tty = port->info->tty; 575 struct tty_struct *tty = port->info->tty;
619 576
620 if (status&SCxSR_ORER(port)) { 577 if (status & SCxSR_ORER(port)) {
621 /* overrun error */ 578 /* overrun error */
622 if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) 579 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN))
623 copied++; 580 copied++;
624 pr_debug("sci: overrun error\n"); 581 pr_debug("sci: overrun error\n");
625 } 582 }
626 583
627 if (status&SCxSR_FER(port)) { 584 if (status & SCxSR_FER(port)) {
628 if (sci_rxd_in(port) == 0) { 585 if (sci_rxd_in(port) == 0) {
629 /* Notify of BREAK */ 586 /* Notify of BREAK */
630 struct sci_port * sci_port = (struct sci_port *)port; 587 struct sci_port *sci_port = (struct sci_port *)port;
631 if(!sci_port->break_flag) { 588
632 sci_port->break_flag = 1; 589 if (!sci_port->break_flag) {
633 sci_schedule_break_timer((struct sci_port *)port); 590 sci_port->break_flag = 1;
591 sci_schedule_break_timer(sci_port);
592
634 /* Do sysrq handling. */ 593 /* Do sysrq handling. */
635 if(uart_handle_break(port)) 594 if (uart_handle_break(port))
636 return 0; 595 return 0;
637 pr_debug("sci: BREAK detected\n"); 596 pr_debug("sci: BREAK detected\n");
638 if(tty_insert_flip_char(tty, 0, TTY_BREAK)) 597 if (tty_insert_flip_char(tty, 0, TTY_BREAK))
639 copied++; 598 copied++;
640 } 599 }
641 } 600 } else {
642 else {
643 /* frame error */ 601 /* frame error */
644 if(tty_insert_flip_char(tty, 0, TTY_FRAME)) 602 if (tty_insert_flip_char(tty, 0, TTY_FRAME))
645 copied++; 603 copied++;
646 pr_debug("sci: frame error\n"); 604 pr_debug("sci: frame error\n");
647 } 605 }
648 } 606 }
649 607
650 if (status&SCxSR_PER(port)) { 608 if (status & SCxSR_PER(port)) {
651 if(tty_insert_flip_char(tty, 0, TTY_PARITY))
652 copied++;
653 /* parity error */ 609 /* parity error */
610 if (tty_insert_flip_char(tty, 0, TTY_PARITY))
611 copied++;
654 pr_debug("sci: parity error\n"); 612 pr_debug("sci: parity error\n");
655 } 613 }
656 614
@@ -673,7 +631,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
673 s->break_flag = 1; 631 s->break_flag = 1;
674#endif 632#endif
675 /* Notify of BREAK */ 633 /* Notify of BREAK */
676 if(tty_insert_flip_char(tty, 0, TTY_BREAK)) 634 if (tty_insert_flip_char(tty, 0, TTY_BREAK))
677 copied++; 635 copied++;
678 pr_debug("sci: BREAK detected\n"); 636 pr_debug("sci: BREAK detected\n");
679 } 637 }
@@ -682,7 +640,7 @@ static inline int sci_handle_breaks(struct uart_port *port)
682 /* XXX: Handle SCIF overrun error */ 640 /* XXX: Handle SCIF overrun error */
683 if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) { 641 if (port->type == PORT_SCIF && (sci_in(port, SCLSR) & SCIF_ORER) != 0) {
684 sci_out(port, SCLSR, 0); 642 sci_out(port, SCLSR, 0);
685 if(tty_insert_flip_char(tty, 0, TTY_OVERRUN)) { 643 if (tty_insert_flip_char(tty, 0, TTY_OVERRUN)) {
686 copied++; 644 copied++;
687 pr_debug("sci: overrun error\n"); 645 pr_debug("sci: overrun error\n");
688 } 646 }
@@ -691,13 +649,12 @@ static inline int sci_handle_breaks(struct uart_port *port)
691 649
692 if (copied) 650 if (copied)
693 tty_flip_buffer_push(tty); 651 tty_flip_buffer_push(tty);
652
694 return copied; 653 return copied;
695} 654}
696 655
697static irqreturn_t sci_rx_interrupt(int irq, void *ptr, struct pt_regs *regs) 656static irqreturn_t sci_rx_interrupt(int irq, void *port, struct pt_regs *regs)
698{ 657{
699 struct uart_port *port = ptr;
700
701 /* I think sci_receive_chars has to be called irrespective 658 /* I think sci_receive_chars has to be called irrespective
702 * of whether the I_IXOFF is set, otherwise, how is the interrupt 659 * of whether the I_IXOFF is set, otherwise, how is the interrupt
703 * to be disabled? 660 * to be disabled?
@@ -711,7 +668,9 @@ static irqreturn_t sci_tx_interrupt(int irq, void *ptr, struct pt_regs *regs)
711{ 668{
712 struct uart_port *port = ptr; 669 struct uart_port *port = ptr;
713 670
671 spin_lock_irq(&port->lock);
714 sci_transmit_chars(port); 672 sci_transmit_chars(port);
673 spin_unlock_irq(&port->lock);
715 674
716 return IRQ_HANDLED; 675 return IRQ_HANDLED;
717} 676}
@@ -755,6 +714,12 @@ static irqreturn_t sci_br_interrupt(int irq, void *ptr, struct pt_regs *regs)
755 714
756 /* Handle BREAKs */ 715 /* Handle BREAKs */
757 sci_handle_breaks(port); 716 sci_handle_breaks(port);
717
718#ifdef CONFIG_SH_KGDB
719 /* Break into the debugger if a break is detected */
720 BREAKPOINT();
721#endif
722
758 sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port)); 723 sci_out(port, SCxSR, SCxSR_BREAK_CLEAR(port));
759 724
760 return IRQ_HANDLED; 725 return IRQ_HANDLED;
@@ -769,16 +734,16 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr, struct pt_regs *regs)
769 scr_status = sci_in(port,SCSCR); 734 scr_status = sci_in(port,SCSCR);
770 735
771 /* Tx Interrupt */ 736 /* Tx Interrupt */
772 if ((ssr_status&0x0020) && (scr_status&0x0080)) 737 if ((ssr_status & 0x0020) && (scr_status & 0x0080))
773 sci_tx_interrupt(irq, ptr, regs); 738 sci_tx_interrupt(irq, ptr, regs);
774 /* Rx Interrupt */ 739 /* Rx Interrupt */
775 if ((ssr_status&0x0002) && (scr_status&0x0040)) 740 if ((ssr_status & 0x0002) && (scr_status & 0x0040))
776 sci_rx_interrupt(irq, ptr, regs); 741 sci_rx_interrupt(irq, ptr, regs);
777 /* Error Interrupt */ 742 /* Error Interrupt */
778 if ((ssr_status&0x0080) && (scr_status&0x0400)) 743 if ((ssr_status & 0x0080) && (scr_status & 0x0400))
779 sci_er_interrupt(irq, ptr, regs); 744 sci_er_interrupt(irq, ptr, regs);
780 /* Break Interrupt */ 745 /* Break Interrupt */
781 if ((ssr_status&0x0010) && (scr_status&0x0200)) 746 if ((ssr_status & 0x0010) && (scr_status & 0x0200))
782 sci_br_interrupt(irq, ptr, regs); 747 sci_br_interrupt(irq, ptr, regs);
783 748
784 return IRQ_HANDLED; 749 return IRQ_HANDLED;
@@ -789,7 +754,8 @@ static irqreturn_t sci_mpxed_interrupt(int irq, void *ptr, struct pt_regs *regs)
789 * Here we define a transistion notifier so that we can update all of our 754 * Here we define a transistion notifier so that we can update all of our
790 * ports' baud rate when the peripheral clock changes. 755 * ports' baud rate when the peripheral clock changes.
791 */ 756 */
792static int sci_notifier(struct notifier_block *self, unsigned long phase, void *p) 757static int sci_notifier(struct notifier_block *self,
758 unsigned long phase, void *p)
793{ 759{
794 struct cpufreq_freqs *freqs = p; 760 struct cpufreq_freqs *freqs = p;
795 int i; 761 int i;
@@ -816,8 +782,9 @@ static int sci_notifier(struct notifier_block *self, unsigned long phase, void *
816 clk_put(clk); 782 clk_put(clk);
817 } 783 }
818 784
819 printk("%s: got a postchange notification for cpu %d (old %d, new %d)\n", 785 printk(KERN_INFO "%s: got a postchange notification "
820 __FUNCTION__, freqs->cpu, freqs->old, freqs->new); 786 "for cpu %d (old %d, new %d)\n",
787 __FUNCTION__, freqs->cpu, freqs->old, freqs->new);
821 } 788 }
822 789
823 return NOTIFY_OK; 790 return NOTIFY_OK;
@@ -841,8 +808,9 @@ static int sci_request_irq(struct sci_port *port)
841 printk(KERN_ERR "sci: Cannot allocate irq.(IRQ=0)\n"); 808 printk(KERN_ERR "sci: Cannot allocate irq.(IRQ=0)\n");
842 return -ENODEV; 809 return -ENODEV;
843 } 810 }
844 if (request_irq(port->irqs[0], sci_mpxed_interrupt, IRQF_DISABLED, 811
845 "sci", port)) { 812 if (request_irq(port->irqs[0], sci_mpxed_interrupt,
813 SA_INTERRUPT, "sci", port)) {
846 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 814 printk(KERN_ERR "sci: Cannot allocate irq.\n");
847 return -ENODEV; 815 return -ENODEV;
848 } 816 }
@@ -850,8 +818,8 @@ static int sci_request_irq(struct sci_port *port)
850 for (i = 0; i < ARRAY_SIZE(handlers); i++) { 818 for (i = 0; i < ARRAY_SIZE(handlers); i++) {
851 if (!port->irqs[i]) 819 if (!port->irqs[i])
852 continue; 820 continue;
853 if (request_irq(port->irqs[i], handlers[i], IRQF_DISABLED, 821 if (request_irq(port->irqs[i], handlers[i],
854 desc[i], port)) { 822 SA_INTERRUPT, desc[i], port)) {
855 printk(KERN_ERR "sci: Cannot allocate irq.\n"); 823 printk(KERN_ERR "sci: Cannot allocate irq.\n");
856 return -ENODEV; 824 return -ENODEV;
857 } 825 }
@@ -903,50 +871,42 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
903 871
904static void sci_start_tx(struct uart_port *port) 872static void sci_start_tx(struct uart_port *port)
905{ 873{
906 struct sci_port *s = &sci_ports[port->line]; 874 unsigned short ctrl;
907 875
908 disable_irq(s->irqs[SCIx_TXI_IRQ]); 876 /* Set TIE (Transmit Interrupt Enable) bit in SCSCR */
909 sci_transmit_chars(port); 877 ctrl = sci_in(port, SCSCR);
910 enable_irq(s->irqs[SCIx_TXI_IRQ]); 878 ctrl |= SCI_CTRL_FLAGS_TIE;
879 sci_out(port, SCSCR, ctrl);
911} 880}
912 881
913static void sci_stop_tx(struct uart_port *port) 882static void sci_stop_tx(struct uart_port *port)
914{ 883{
915 unsigned long flags;
916 unsigned short ctrl; 884 unsigned short ctrl;
917 885
918 /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */ 886 /* Clear TIE (Transmit Interrupt Enable) bit in SCSCR */
919 local_irq_save(flags);
920 ctrl = sci_in(port, SCSCR); 887 ctrl = sci_in(port, SCSCR);
921 ctrl &= ~SCI_CTRL_FLAGS_TIE; 888 ctrl &= ~SCI_CTRL_FLAGS_TIE;
922 sci_out(port, SCSCR, ctrl); 889 sci_out(port, SCSCR, ctrl);
923 local_irq_restore(flags);
924} 890}
925 891
926static void sci_start_rx(struct uart_port *port, unsigned int tty_start) 892static void sci_start_rx(struct uart_port *port, unsigned int tty_start)
927{ 893{
928 unsigned long flags;
929 unsigned short ctrl; 894 unsigned short ctrl;
930 895
931 /* Set RIE (Receive Interrupt Enable) bit in SCSCR */ 896 /* Set RIE (Receive Interrupt Enable) bit in SCSCR */
932 local_irq_save(flags);
933 ctrl = sci_in(port, SCSCR); 897 ctrl = sci_in(port, SCSCR);
934 ctrl |= SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE; 898 ctrl |= SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE;
935 sci_out(port, SCSCR, ctrl); 899 sci_out(port, SCSCR, ctrl);
936 local_irq_restore(flags);
937} 900}
938 901
939static void sci_stop_rx(struct uart_port *port) 902static void sci_stop_rx(struct uart_port *port)
940{ 903{
941 unsigned long flags;
942 unsigned short ctrl; 904 unsigned short ctrl;
943 905
944 /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */ 906 /* Clear RIE (Receive Interrupt Enable) bit in SCSCR */
945 local_irq_save(flags);
946 ctrl = sci_in(port, SCSCR); 907 ctrl = sci_in(port, SCSCR);
947 ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE); 908 ctrl &= ~(SCI_CTRL_FLAGS_RIE | SCI_CTRL_FLAGS_REIE);
948 sci_out(port, SCSCR, ctrl); 909 sci_out(port, SCSCR, ctrl);
949 local_irq_restore(flags);
950} 910}
951 911
952static void sci_enable_ms(struct uart_port *port) 912static void sci_enable_ms(struct uart_port *port)
@@ -963,9 +923,8 @@ static int sci_startup(struct uart_port *port)
963{ 923{
964 struct sci_port *s = &sci_ports[port->line]; 924 struct sci_port *s = &sci_ports[port->line];
965 925
966#if defined(__H8300S__) 926 if (s->enable)
967 h8300_sci_enable(port, sci_enable); 927 s->enable(port);
968#endif
969 928
970 sci_request_irq(s); 929 sci_request_irq(s);
971 sci_start_tx(port); 930 sci_start_tx(port);
@@ -982,9 +941,8 @@ static void sci_shutdown(struct uart_port *port)
982 sci_stop_tx(port); 941 sci_stop_tx(port);
983 sci_free_irq(s); 942 sci_free_irq(s);
984 943
985#if defined(__H8300S__) 944 if (s->disable)
986 h8300_sci_enable(port, sci_disable); 945 s->disable(port);
987#endif
988} 946}
989 947
990static void sci_set_termios(struct uart_port *port, struct termios *termios, 948static void sci_set_termios(struct uart_port *port, struct termios *termios,
@@ -997,6 +955,23 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
997 955
998 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 956 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
999 957
958 switch (baud) {
959 case 0:
960 t = -1;
961 break;
962 default:
963 {
964#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
965 struct clk *clk = clk_get("module_clk");
966 t = SCBRR_VALUE(baud, clk_get_rate(clk));
967 clk_put(clk);
968#else
969 t = SCBRR_VALUE(baud);
970#endif
971 }
972 break;
973 }
974
1000 spin_lock_irqsave(&port->lock, flags); 975 spin_lock_irqsave(&port->lock, flags);
1001 976
1002 do { 977 do {
@@ -1006,9 +981,8 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1006 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */ 981 sci_out(port, SCSCR, 0x00); /* TE=0, RE=0, CKE1=0 */
1007 982
1008#if !defined(SCI_ONLY) 983#if !defined(SCI_ONLY)
1009 if (port->type == PORT_SCIF) { 984 if (port->type == PORT_SCIF)
1010 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST); 985 sci_out(port, SCFCR, SCFCR_RFRST | SCFCR_TFRST);
1011 }
1012#endif 986#endif
1013 987
1014 smr_val = sci_in(port, SCSMR) & 3; 988 smr_val = sci_in(port, SCSMR) & 3;
@@ -1025,23 +999,6 @@ static void sci_set_termios(struct uart_port *port, struct termios *termios,
1025 999
1026 sci_out(port, SCSMR, smr_val); 1000 sci_out(port, SCSMR, smr_val);
1027 1001
1028 switch (baud) {
1029 case 0:
1030 t = -1;
1031 break;
1032 default:
1033 {
1034#if defined(CONFIG_SUPERH) && !defined(CONFIG_SUPERH64)
1035 struct clk *clk = clk_get("module_clk");
1036 t = SCBRR_VALUE(baud, clk_get_rate(clk));
1037 clk_put(clk);
1038#else
1039 t = SCBRR_VALUE(baud);
1040#endif
1041 }
1042 break;
1043 }
1044
1045 if (t > 0) { 1002 if (t > 0) {
1046 if(t >= 256) { 1003 if(t >= 256) {
1047 sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1); 1004 sci_out(port, SCSMR, (sci_in(port, SCSMR) & ~3) | 1);
@@ -1092,11 +1049,23 @@ static void sci_config_port(struct uart_port *port, int flags)
1092 1049
1093 port->type = s->type; 1050 port->type = s->type;
1094 1051
1052 switch (port->type) {
1053 case PORT_SCI:
1054 s->init_pins = sci_init_pins_sci;
1055 break;
1056 case PORT_SCIF:
1057 s->init_pins = sci_init_pins_scif;
1058 break;
1059 case PORT_IRDA:
1060 s->init_pins = sci_init_pins_irda;
1061 break;
1062 }
1063
1095#if defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103) 1064#if defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
1096 if (port->mapbase == 0) 1065 if (port->mapbase == 0)
1097 port->mapbase = onchip_remap(SCIF_ADDR_SH5, 1024, "SCIF"); 1066 port->mapbase = onchip_remap(SCIF_ADDR_SH5, 1024, "SCIF");
1098 1067
1099 port->membase = (void *)port->mapbase; 1068 port->membase = (void __iomem *)port->mapbase;
1100#endif 1069#endif
1101} 1070}
1102 1071
@@ -1132,412 +1101,61 @@ static struct uart_ops sci_uart_ops = {
1132 .verify_port = sci_verify_port, 1101 .verify_port = sci_verify_port,
1133}; 1102};
1134 1103
1135static struct sci_port sci_ports[] = { 1104static void __init sci_init_ports(void)
1136#if defined(CONFIG_CPU_SUBTYPE_SH7708) 1105{
1137 { 1106 static int first = 1;
1138 .port = { 1107 int i;
1139 .membase = (void *)0xfffffe80, 1108
1140 .mapbase = 0xfffffe80, 1109 if (!first)
1141 .iotype = UPIO_MEM, 1110 return;
1142 .irq = 25, 1111
1143 .ops = &sci_uart_ops, 1112 first = 0;
1144 .flags = UPF_BOOT_AUTOCONF, 1113
1145 .line = 0, 1114 for (i = 0; i < SCI_NPORTS; i++) {
1146 }, 1115 sci_ports[i].port.ops = &sci_uart_ops;
1147 .type = PORT_SCI, 1116 sci_ports[i].port.iotype = UPIO_MEM;
1148 .irqs = SCI_IRQS, 1117 sci_ports[i].port.line = i;
1149 }, 1118 sci_ports[i].port.fifosize = 1;
1150#elif defined(CONFIG_CPU_SUBTYPE_SH7705) 1119
1151 { 1120#if defined(__H8300H__) || defined(__H8300S__)
1152 .port = { 1121#ifdef __H8300S__
1153 .membase = (void *)SCIF0, 1122 sci_ports[i].enable = h8300_sci_enable;
1154 .mapbase = SCIF0, 1123 sci_ports[i].disable = h8300_sci_disable;
1155 .iotype = UPIO_MEM, 1124#endif
1156 .irq = 55, 1125 sci_ports[i].port.uartclk = CONFIG_CPU_CLOCK;
1157 .ops = &sci_uart_ops, 1126#elif defined(CONFIG_SUPERH64)
1158 .flags = UPF_BOOT_AUTOCONF, 1127 sci_ports[i].port.uartclk = current_cpu_data.module_clock * 16;
1159 .line = 0,
1160 },
1161 .type = PORT_SCIF,
1162 .irqs = SH3_IRDA_IRQS,
1163 .init_pins = sci_init_pins_scif,
1164 },
1165 {
1166 .port = {
1167 .membase = (void *)SCIF2,
1168 .mapbase = SCIF2,
1169 .iotype = UPIO_MEM,
1170 .irq = 59,
1171 .ops = &sci_uart_ops,
1172 .flags = UPF_BOOT_AUTOCONF,
1173 .line = 1,
1174 },
1175 .type = PORT_SCIF,
1176 .irqs = SH3_SCIF_IRQS,
1177 .init_pins = sci_init_pins_scif,
1178 }
1179#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709)
1180 {
1181 .port = {
1182 .membase = (void *)0xfffffe80,
1183 .mapbase = 0xfffffe80,
1184 .iotype = UPIO_MEM,
1185 .irq = 25,
1186 .ops = &sci_uart_ops,
1187 .flags = UPF_BOOT_AUTOCONF,
1188 .line = 0,
1189 },
1190 .type = PORT_SCI,
1191 .irqs = SCI_IRQS,
1192 },
1193 {
1194 .port = {
1195 .membase = (void *)0xa4000150,
1196 .mapbase = 0xa4000150,
1197 .iotype = UPIO_MEM,
1198 .irq = 59,
1199 .ops = &sci_uart_ops,
1200 .flags = UPF_BOOT_AUTOCONF,
1201 .line = 1,
1202 },
1203 .type = PORT_SCIF,
1204 .irqs = SH3_SCIF_IRQS,
1205 .init_pins = sci_init_pins_scif,
1206 },
1207 {
1208 .port = {
1209 .membase = (void *)0xa4000140,
1210 .mapbase = 0xa4000140,
1211 .iotype = UPIO_MEM,
1212 .irq = 55,
1213 .ops = &sci_uart_ops,
1214 .flags = UPF_BOOT_AUTOCONF,
1215 .line = 2,
1216 },
1217 .type = PORT_IRDA,
1218 .irqs = SH3_IRDA_IRQS,
1219 .init_pins = sci_init_pins_irda,
1220 }
1221#elif defined(CONFIG_CPU_SUBTYPE_SH7300)
1222 {
1223 .port = {
1224 .membase = (void *)0xA4430000,
1225 .mapbase = 0xA4430000,
1226 .iotype = UPIO_MEM,
1227 .irq = 25,
1228 .ops = &sci_uart_ops,
1229 .flags = UPF_BOOT_AUTOCONF,
1230 .line = 0,
1231 },
1232 .type = PORT_SCIF,
1233 .irqs = SH7300_SCIF0_IRQS,
1234 .init_pins = sci_init_pins_scif,
1235 },
1236#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
1237 {
1238 .port = {
1239 .membase = (void *)0xffe00000,
1240 .mapbase = 0xffe00000,
1241 .iotype = UPIO_MEM,
1242 .irq = 25,
1243 .ops = &sci_uart_ops,
1244 .flags = UPF_BOOT_AUTOCONF,
1245 .line = 0,
1246 },
1247 .type = PORT_SCIF,
1248 .irqs = SH73180_SCIF_IRQS,
1249 .init_pins = sci_init_pins_scif,
1250 },
1251#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
1252 {
1253 .port = {
1254 .membase = (void *)0xffe80000,
1255 .mapbase = 0xffe80000,
1256 .iotype = UPIO_MEM,
1257 .irq = 43,
1258 .ops = &sci_uart_ops,
1259 .flags = UPF_BOOT_AUTOCONF,
1260 .line = 0,
1261 },
1262 .type = PORT_SCIF,
1263 .irqs = SH4_SCIF_IRQS,
1264 .init_pins = sci_init_pins_scif,
1265 },
1266#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || defined(CONFIG_CPU_SUBTYPE_SH7751)
1267 {
1268 .port = {
1269 .membase = (void *)0xffe00000,
1270 .mapbase = 0xffe00000,
1271 .iotype = UPIO_MEM,
1272 .irq = 25,
1273 .ops = &sci_uart_ops,
1274 .flags = UPF_BOOT_AUTOCONF,
1275 .line = 0,
1276 },
1277 .type = PORT_SCI,
1278 .irqs = SCI_IRQS,
1279 },
1280 {
1281 .port = {
1282 .membase = (void *)0xffe80000,
1283 .mapbase = 0xffe80000,
1284 .iotype = UPIO_MEM,
1285 .irq = 43,
1286 .ops = &sci_uart_ops,
1287 .flags = UPF_BOOT_AUTOCONF,
1288 .line = 1,
1289 },
1290 .type = PORT_SCIF,
1291 .irqs = SH4_SCIF_IRQS,
1292 .init_pins = sci_init_pins_scif,
1293 },
1294#elif defined(CONFIG_CPU_SUBTYPE_SH7760)
1295 {
1296 .port = {
1297 .membase = (void *)0xfe600000,
1298 .mapbase = 0xfe600000,
1299 .iotype = UPIO_MEM,
1300 .irq = 55,
1301 .ops = &sci_uart_ops,
1302 .flags = UPF_BOOT_AUTOCONF,
1303 .line = 0,
1304 },
1305 .type = PORT_SCIF,
1306 .irqs = SH7760_SCIF0_IRQS,
1307 .init_pins = sci_init_pins_scif,
1308 },
1309 {
1310 .port = {
1311 .membase = (void *)0xfe610000,
1312 .mapbase = 0xfe610000,
1313 .iotype = UPIO_MEM,
1314 .irq = 75,
1315 .ops = &sci_uart_ops,
1316 .flags = UPF_BOOT_AUTOCONF,
1317 .line = 1,
1318 },
1319 .type = PORT_SCIF,
1320 .irqs = SH7760_SCIF1_IRQS,
1321 .init_pins = sci_init_pins_scif,
1322 },
1323 {
1324 .port = {
1325 .membase = (void *)0xfe620000,
1326 .mapbase = 0xfe620000,
1327 .iotype = UPIO_MEM,
1328 .irq = 79,
1329 .ops = &sci_uart_ops,
1330 .flags = UPF_BOOT_AUTOCONF,
1331 .line = 2,
1332 },
1333 .type = PORT_SCIF,
1334 .irqs = SH7760_SCIF2_IRQS,
1335 .init_pins = sci_init_pins_scif,
1336 },
1337#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
1338 {
1339 .port = {
1340 .membase = (void *)0xffe00000,
1341 .mapbase = 0xffe00000,
1342 .iotype = UPIO_MEM,
1343 .irq = 26,
1344 .ops = &sci_uart_ops,
1345 .flags = UPF_BOOT_AUTOCONF,
1346 .line = 0,
1347 },
1348 .type = PORT_SCIF,
1349 .irqs = STB1_SCIF1_IRQS,
1350 .init_pins = sci_init_pins_scif,
1351 },
1352 {
1353 .port = {
1354 .membase = (void *)0xffe80000,
1355 .mapbase = 0xffe80000,
1356 .iotype = UPIO_MEM,
1357 .irq = 43,
1358 .ops = &sci_uart_ops,
1359 .flags = UPF_BOOT_AUTOCONF,
1360 .line = 1,
1361 },
1362 .type = PORT_SCIF,
1363 .irqs = SH4_SCIF_IRQS,
1364 .init_pins = sci_init_pins_scif,
1365 },
1366#elif defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
1367 {
1368 .port = {
1369 .iotype = UPIO_MEM,
1370 .irq = 42,
1371 .ops = &sci_uart_ops,
1372 .flags = UPF_BOOT_AUTOCONF,
1373 .line = 0,
1374 },
1375 .type = PORT_SCIF,
1376 .irqs = SH5_SCIF_IRQS,
1377 .init_pins = sci_init_pins_scif,
1378 },
1379#elif defined(CONFIG_H83007) || defined(CONFIG_H83068)
1380 {
1381 .port = {
1382 .membase = (void *)0x00ffffb0,
1383 .mapbase = 0x00ffffb0,
1384 .iotype = UPIO_MEM,
1385 .irq = 54,
1386 .ops = &sci_uart_ops,
1387 .flags = UPF_BOOT_AUTOCONF,
1388 .line = 0,
1389 },
1390 .type = PORT_SCI,
1391 .irqs = H8300H_SCI_IRQS0,
1392 .init_pins = sci_init_pins_sci,
1393 },
1394 {
1395 .port = {
1396 .membase = (void *)0x00ffffb8,
1397 .mapbase = 0x00ffffb8,
1398 .iotype = UPIO_MEM,
1399 .irq = 58,
1400 .ops = &sci_uart_ops,
1401 .flags = UPF_BOOT_AUTOCONF,
1402 .line = 1,
1403 },
1404 .type = PORT_SCI,
1405 .irqs = H8300H_SCI_IRQS1,
1406 .init_pins = sci_init_pins_sci,
1407 },
1408 {
1409 .port = {
1410 .membase = (void *)0x00ffffc0,
1411 .mapbase = 0x00ffffc0,
1412 .iotype = UPIO_MEM,
1413 .irq = 62,
1414 .ops = &sci_uart_ops,
1415 .flags = UPF_BOOT_AUTOCONF,
1416 .line = 2,
1417 },
1418 .type = PORT_SCI,
1419 .irqs = H8300H_SCI_IRQS2,
1420 .init_pins = sci_init_pins_sci,
1421 },
1422#elif defined(CONFIG_H8S2678)
1423 {
1424 .port = {
1425 .membase = (void *)0x00ffff78,
1426 .mapbase = 0x00ffff78,
1427 .iotype = UPIO_MEM,
1428 .irq = 90,
1429 .ops = &sci_uart_ops,
1430 .flags = UPF_BOOT_AUTOCONF,
1431 .line = 0,
1432 },
1433 .type = PORT_SCI,
1434 .irqs = H8S_SCI_IRQS0,
1435 .init_pins = sci_init_pins_sci,
1436 },
1437 {
1438 .port = {
1439 .membase = (void *)0x00ffff80,
1440 .mapbase = 0x00ffff80,
1441 .iotype = UPIO_MEM,
1442 .irq = 94,
1443 .ops = &sci_uart_ops,
1444 .flags = UPF_BOOT_AUTOCONF,
1445 .line = 1,
1446 },
1447 .type = PORT_SCI,
1448 .irqs = H8S_SCI_IRQS1,
1449 .init_pins = sci_init_pins_sci,
1450 },
1451 {
1452 .port = {
1453 .membase = (void *)0x00ffff88,
1454 .mapbase = 0x00ffff88,
1455 .iotype = UPIO_MEM,
1456 .irq = 98,
1457 .ops = &sci_uart_ops,
1458 .flags = UPF_BOOT_AUTOCONF,
1459 .line = 2,
1460 },
1461 .type = PORT_SCI,
1462 .irqs = H8S_SCI_IRQS2,
1463 .init_pins = sci_init_pins_sci,
1464 },
1465#elif defined(CONFIG_CPU_SUBTYPE_SH7770)
1466 {
1467 .port = {
1468 .membase = (void *)0xff923000,
1469 .mapbase = 0xff923000,
1470 .iotype = UPIO_MEM,
1471 .irq = 61,
1472 .ops = &sci_uart_ops,
1473 .flags = UPF_BOOT_AUTOCONF,
1474 .line = 0,
1475 },
1476 .type = PORT_SCIF,
1477 .irqs = SH7770_SCIF0_IRQS,
1478 .init_pins = sci_init_pins_scif,
1479 },
1480 {
1481 .port = {
1482 .membase = (void *)0xff924000,
1483 .mapbase = 0xff924000,
1484 .iotype = UPIO_MEM,
1485 .irq = 62,
1486 .ops = &sci_uart_ops,
1487 .flags = UPF_BOOT_AUTOCONF,
1488 .line = 1,
1489 },
1490 .type = PORT_SCIF,
1491 .irqs = SH7770_SCIF1_IRQS,
1492 .init_pins = sci_init_pins_scif,
1493 },
1494 {
1495 .port = {
1496 .membase = (void *)0xff925000,
1497 .mapbase = 0xff925000,
1498 .iotype = UPIO_MEM,
1499 .irq = 63,
1500 .ops = &sci_uart_ops,
1501 .flags = UPF_BOOT_AUTOCONF,
1502 .line = 2,
1503 },
1504 .type = PORT_SCIF,
1505 .irqs = SH7770_SCIF2_IRQS,
1506 .init_pins = sci_init_pins_scif,
1507 },
1508#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
1509 {
1510 .port = {
1511 .membase = (void *)0xffe00000,
1512 .mapbase = 0xffe00000,
1513 .iotype = UPIO_MEM,
1514 .irq = 43,
1515 .ops = &sci_uart_ops,
1516 .flags = UPF_BOOT_AUTOCONF,
1517 .line = 0,
1518 },
1519 .type = PORT_SCIF,
1520 .irqs = SH7780_SCIF0_IRQS,
1521 .init_pins = sci_init_pins_scif,
1522 },
1523 {
1524 .port = {
1525 .membase = (void *)0xffe10000,
1526 .mapbase = 0xffe10000,
1527 .iotype = UPIO_MEM,
1528 .irq = 79,
1529 .ops = &sci_uart_ops,
1530 .flags = UPF_BOOT_AUTOCONF,
1531 .line = 1,
1532 },
1533 .type = PORT_SCIF,
1534 .irqs = SH7780_SCIF1_IRQS,
1535 .init_pins = sci_init_pins_scif,
1536 },
1537#else 1128#else
1538#error "CPU subtype not defined" 1129 /*
1130 * XXX: We should use a proper SCI/SCIF clock
1131 */
1132 {
1133 struct clk *clk = clk_get("module_clk");
1134 sci_ports[i].port.uartclk = clk_get_rate(clk) * 16;
1135 clk_put(clk);
1136 }
1539#endif 1137#endif
1540}; 1138
1139 sci_ports[i].break_timer.data = (unsigned long)&sci_ports[i];
1140 sci_ports[i].break_timer.function = sci_break_timer;
1141
1142 init_timer(&sci_ports[i].break_timer);
1143 }
1144}
1145
1146int __init early_sci_setup(struct uart_port *port)
1147{
1148 if (unlikely(port->line > SCI_NPORTS))
1149 return -ENODEV;
1150
1151 sci_init_ports();
1152
1153 sci_ports[port->line].port.membase = port->membase;
1154 sci_ports[port->line].port.mapbase = port->mapbase;
1155 sci_ports[port->line].port.type = port->type;
1156
1157 return 0;
1158}
1541 1159
1542#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 1160#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
1543/* 1161/*
@@ -1559,34 +1177,38 @@ static int __init serial_console_setup(struct console *co, char *options)
1559 int flow = 'n'; 1177 int flow = 'n';
1560 int ret; 1178 int ret;
1561 1179
1180 /*
1181 * Check whether an invalid uart number has been specified, and
1182 * if so, search for the first available port that does have
1183 * console support.
1184 */
1185 if (co->index >= SCI_NPORTS)
1186 co->index = 0;
1187
1562 serial_console_port = &sci_ports[co->index]; 1188 serial_console_port = &sci_ports[co->index];
1563 port = &serial_console_port->port; 1189 port = &serial_console_port->port;
1564 port->type = serial_console_port->type;
1565
1566#ifdef CONFIG_SUPERH64
1567 /* This is especially needed on sh64 to remap the SCIF */
1568 sci_config_port(port, 0);
1569#endif
1570 1190
1571 /* 1191 /*
1572 * We need to set the initial uartclk here, since otherwise it will 1192 * Also need to check port->type, we don't actually have any
1573 * only ever be setup at sci_init() time. 1193 * UPIO_PORT ports, but uart_report_port() handily misreports
1194 * it anyways if we don't have a port available by the time this is
1195 * called.
1574 */ 1196 */
1575#if defined(__H8300H__) || defined(__H8300S__) 1197 if (!port->type)
1576 port->uartclk = CONFIG_CPU_CLOCK; 1198 return -ENODEV;
1199 if (!port->membase || !port->mapbase)
1200 return -ENODEV;
1201
1202 spin_lock_init(&port->lock);
1203
1204 port->type = serial_console_port->type;
1205
1206 if (port->flags & UPF_IOREMAP)
1207 sci_config_port(port, 0);
1208
1209 if (serial_console_port->enable)
1210 serial_console_port->enable(port);
1577 1211
1578#if defined(__H8300S__)
1579 h8300_sci_enable(port, sci_enable);
1580#endif
1581#elif defined(CONFIG_SUPERH64)
1582 port->uartclk = current_cpu_data.module_clock * 16;
1583#else
1584 {
1585 struct clk *clk = clk_get("module_clk");
1586 port->uartclk = clk_get_rate(clk) * 16;
1587 clk_put(clk);
1588 }
1589#endif
1590 if (options) 1212 if (options)
1591 uart_parse_options(options, &baud, &parity, &bits, &flow); 1213 uart_parse_options(options, &baud, &parity, &bits, &flow);
1592 1214
@@ -1604,17 +1226,17 @@ static struct console serial_console = {
1604 .device = uart_console_device, 1226 .device = uart_console_device,
1605 .write = serial_console_write, 1227 .write = serial_console_write,
1606 .setup = serial_console_setup, 1228 .setup = serial_console_setup,
1607 .flags = CON_PRINTBUFFER, 1229 .flags = CON_PRINTBUFFER,
1608 .index = -1, 1230 .index = -1,
1609 .data = &sci_uart_driver, 1231 .data = &sci_uart_driver,
1610}; 1232};
1611 1233
1612static int __init sci_console_init(void) 1234static int __init sci_console_init(void)
1613{ 1235{
1236 sci_init_ports();
1614 register_console(&serial_console); 1237 register_console(&serial_console);
1615 return 0; 1238 return 0;
1616} 1239}
1617
1618console_initcall(sci_console_init); 1240console_initcall(sci_console_init);
1619#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */ 1241#endif /* CONFIG_SERIAL_SH_SCI_CONSOLE */
1620 1242
@@ -1649,6 +1271,8 @@ int __init kgdb_console_setup(struct console *co, char *options)
1649 int parity = 'n'; 1271 int parity = 'n';
1650 int flow = 'n'; 1272 int flow = 'n';
1651 1273
1274 spin_lock_init(&port->lock);
1275
1652 if (co->index != kgdb_portnum) 1276 if (co->index != kgdb_portnum)
1653 co->index = kgdb_portnum; 1277 co->index = kgdb_portnum;
1654 1278
@@ -1677,10 +1301,10 @@ static struct console kgdb_console = {
1677/* Register the KGDB console so we get messages (d'oh!) */ 1301/* Register the KGDB console so we get messages (d'oh!) */
1678static int __init kgdb_console_init(void) 1302static int __init kgdb_console_init(void)
1679{ 1303{
1304 sci_init_ports();
1680 register_console(&kgdb_console); 1305 register_console(&kgdb_console);
1681 return 0; 1306 return 0;
1682} 1307}
1683
1684console_initcall(kgdb_console_init); 1308console_initcall(kgdb_console_init);
1685#endif /* CONFIG_SH_KGDB_CONSOLE */ 1309#endif /* CONFIG_SH_KGDB_CONSOLE */
1686 1310
@@ -1701,60 +1325,132 @@ static struct uart_driver sci_uart_driver = {
1701 .dev_name = "ttySC", 1325 .dev_name = "ttySC",
1702 .major = SCI_MAJOR, 1326 .major = SCI_MAJOR,
1703 .minor = SCI_MINOR_START, 1327 .minor = SCI_MINOR_START,
1328 .nr = SCI_NPORTS,
1704 .cons = SCI_CONSOLE, 1329 .cons = SCI_CONSOLE,
1705}; 1330};
1706 1331
1707static int __init sci_init(void) 1332/*
1333 * Register a set of serial devices attached to a platform device. The
1334 * list is terminated with a zero flags entry, which means we expect
1335 * all entries to have at least UPF_BOOT_AUTOCONF set. Platforms that need
1336 * remapping (such as sh64) should also set UPF_IOREMAP.
1337 */
1338static int __devinit sci_probe(struct platform_device *dev)
1708{ 1339{
1709 int chan, ret; 1340 struct plat_sci_port *p = dev->dev.platform_data;
1341 int i;
1710 1342
1711 printk("%s", banner); 1343 for (i = 0; p && p->flags != 0 && i < SCI_NPORTS; p++, i++) {
1344 struct sci_port *sciport = &sci_ports[i];
1712 1345
1713 sci_uart_driver.nr = ARRAY_SIZE(sci_ports); 1346 sciport->port.mapbase = p->mapbase;
1714 1347
1715 ret = uart_register_driver(&sci_uart_driver); 1348 /*
1716 if (ret == 0) { 1349 * For the simple (and majority of) cases where we don't need
1717 for (chan = 0; chan < SCI_NPORTS; chan++) { 1350 * to do any remapping, just cast the cookie directly.
1718 struct sci_port *sciport = &sci_ports[chan]; 1351 */
1352 if (p->mapbase && !p->membase && !(p->flags & UPF_IOREMAP))
1353 p->membase = (void __iomem *)p->mapbase;
1719 1354
1720#if defined(__H8300H__) || defined(__H8300S__) 1355 sciport->port.membase = p->membase;
1721 sciport->port.uartclk = CONFIG_CPU_CLOCK; 1356
1722#elif defined(CONFIG_SUPERH64) 1357 sciport->port.irq = p->irqs[SCIx_TXI_IRQ];
1723 sciport->port.uartclk = current_cpu_data.module_clock * 16; 1358 sciport->port.flags = p->flags;
1724#else 1359 sciport->port.dev = &dev->dev;
1725 struct clk *clk = clk_get("module_clk"); 1360
1726 sciport->port.uartclk = clk_get_rate(clk) * 16; 1361 sciport->type = sciport->port.type = p->type;
1727 clk_put(clk); 1362
1728#endif 1363 memcpy(&sciport->irqs, &p->irqs, sizeof(p->irqs));
1729 uart_add_one_port(&sci_uart_driver, &sciport->port); 1364
1730 sciport->break_timer.data = (unsigned long)sciport; 1365 uart_add_one_port(&sci_uart_driver, &sciport->port);
1731 sciport->break_timer.function = sci_break_timer;
1732 init_timer(&sciport->break_timer);
1733 }
1734 } 1366 }
1735 1367
1736#ifdef CONFIG_CPU_FREQ 1368#ifdef CONFIG_CPU_FREQ
1737 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER); 1369 cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
1738 printk("sci: CPU frequency notifier registered\n"); 1370 dev_info(&dev->dev, "sci: CPU frequency notifier registered\n");
1739#endif 1371#endif
1740 1372
1741#ifdef CONFIG_SH_STANDARD_BIOS 1373#ifdef CONFIG_SH_STANDARD_BIOS
1742 sh_bios_gdb_detach(); 1374 sh_bios_gdb_detach();
1743#endif 1375#endif
1744 1376
1745 return ret; 1377 return 0;
1746} 1378}
1747 1379
1748static void __exit sci_exit(void) 1380static int __devexit sci_remove(struct platform_device *dev)
1381{
1382 int i;
1383
1384 for (i = 0; i < SCI_NPORTS; i++)
1385 uart_remove_one_port(&sci_uart_driver, &sci_ports[i].port);
1386
1387 return 0;
1388}
1389
1390static int sci_suspend(struct platform_device *dev, pm_message_t state)
1749{ 1391{
1750 int chan; 1392 int i;
1393
1394 for (i = 0; i < SCI_NPORTS; i++) {
1395 struct sci_port *p = &sci_ports[i];
1396
1397 if (p->type != PORT_UNKNOWN && p->port.dev == &dev->dev)
1398 uart_suspend_port(&sci_uart_driver, &p->port);
1399 }
1751 1400
1752 for (chan = 0; chan < SCI_NPORTS; chan++) 1401 return 0;
1753 uart_remove_one_port(&sci_uart_driver, &sci_ports[chan].port); 1402}
1754 1403
1404static int sci_resume(struct platform_device *dev)
1405{
1406 int i;
1407
1408 for (i = 0; i < SCI_NPORTS; i++) {
1409 struct sci_port *p = &sci_ports[i];
1410
1411 if (p->type != PORT_UNKNOWN && p->port.dev == &dev->dev)
1412 uart_resume_port(&sci_uart_driver, &p->port);
1413 }
1414
1415 return 0;
1416}
1417
1418static struct platform_driver sci_driver = {
1419 .probe = sci_probe,
1420 .remove = __devexit_p(sci_remove),
1421 .suspend = sci_suspend,
1422 .resume = sci_resume,
1423 .driver = {
1424 .name = "sh-sci",
1425 .owner = THIS_MODULE,
1426 },
1427};
1428
1429static int __init sci_init(void)
1430{
1431 int ret;
1432
1433 printk(banner);
1434
1435 sci_init_ports();
1436
1437 ret = uart_register_driver(&sci_uart_driver);
1438 if (likely(ret == 0)) {
1439 ret = platform_driver_register(&sci_driver);
1440 if (unlikely(ret))
1441 uart_unregister_driver(&sci_uart_driver);
1442 }
1443
1444 return ret;
1445}
1446
1447static void __exit sci_exit(void)
1448{
1449 platform_driver_unregister(&sci_driver);
1755 uart_unregister_driver(&sci_uart_driver); 1450 uart_unregister_driver(&sci_uart_driver);
1756} 1451}
1757 1452
1758module_init(sci_init); 1453module_init(sci_init);
1759module_exit(sci_exit); 1454module_exit(sci_exit);
1760 1455
1456MODULE_LICENSE("GPL");
diff --git a/drivers/serial/sh-sci.h b/drivers/serial/sh-sci.h
index ab320fa3237c..28643c4dc850 100644
--- a/drivers/serial/sh-sci.h
+++ b/drivers/serial/sh-sci.h
@@ -10,7 +10,9 @@
10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003). 10 * Modified to support SH7300(SH-Mobile) SCIF. Takashi Kusuda (Jun 2003).
11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004). 11 * Modified to support H8/300 Series Yoshinori Sato (Feb 2004).
12 */ 12 */
13#include <linux/config.h>
13#include <linux/serial_core.h> 14#include <linux/serial_core.h>
15#include <asm/io.h>
14 16
15#if defined(__H8300H__) || defined(__H8300S__) 17#if defined(__H8300H__) || defined(__H8300S__)
16#include <asm/gpio.h> 18#include <asm/gpio.h>
@@ -22,40 +24,13 @@
22#endif 24#endif
23#endif 25#endif
24 26
25/* Offsets into the sci_port->irqs array */
26#define SCIx_ERI_IRQ 0
27#define SCIx_RXI_IRQ 1
28#define SCIx_TXI_IRQ 2
29
30/* ERI, RXI, TXI, BRI */
31#define SCI_IRQS { 23, 24, 25, 0 }
32#define SH3_SCIF_IRQS { 56, 57, 59, 58 }
33#define SH3_IRDA_IRQS { 52, 53, 55, 54 }
34#define SH4_SCIF_IRQS { 40, 41, 43, 42 }
35#define STB1_SCIF1_IRQS {23, 24, 26, 25 }
36#define SH7760_SCIF0_IRQS { 52, 53, 55, 54 }
37#define SH7760_SCIF1_IRQS { 72, 73, 75, 74 }
38#define SH7760_SCIF2_IRQS { 76, 77, 79, 78 }
39#define SH7300_SCIF0_IRQS {80, 80, 80, 80 }
40#define SH73180_SCIF_IRQS {80, 81, 83, 82 }
41#define H8300H_SCI_IRQS0 {52, 53, 54, 0 }
42#define H8300H_SCI_IRQS1 {56, 57, 58, 0 }
43#define H8300H_SCI_IRQS2 {60, 61, 62, 0 }
44#define H8S_SCI_IRQS0 {88, 89, 90, 0 }
45#define H8S_SCI_IRQS1 {92, 93, 94, 0 }
46#define H8S_SCI_IRQS2 {96, 97, 98, 0 }
47#define SH5_SCIF_IRQS {39, 40, 42, 0 }
48#define SH7770_SCIF0_IRQS {61, 61, 61, 61 }
49#define SH7770_SCIF1_IRQS {62, 62, 62, 62 }
50#define SH7770_SCIF2_IRQS {63, 63, 63, 63 }
51#define SH7780_SCIF0_IRQS {40, 41, 43, 42 }
52#define SH7780_SCIF1_IRQS {76, 77, 79, 78 }
53
54#if defined(CONFIG_CPU_SUBTYPE_SH7708) 27#if defined(CONFIG_CPU_SUBTYPE_SH7708)
55# define SCSPTR 0xffffff7c /* 8 bit */ 28# define SCSPTR 0xffffff7c /* 8 bit */
56# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 29# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
57# define SCI_ONLY 30# define SCI_ONLY
58#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) 31#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
33 defined(CONFIG_CPU_SUBTYPE_SH7706)
59# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */ 34# define SCPCR 0xA4000116 /* 16 bit SCI and SCIF */
60# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */ 35# define SCPDR 0xA4000136 /* 8 bit SCI and SCIF */
61# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */ 36# define SCSCR_INIT(port) 0x30 /* TIE=0,RIE=0,TE=1,RE=1 */
@@ -99,12 +74,23 @@
99# define SCPDR 0xA4050136 /* 16 bit SCIF */ 74# define SCPDR 0xA4050136 /* 16 bit SCIF */
100# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */ 75# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
101# define SCIF_ONLY 76# define SCIF_ONLY
77#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
78# define SCSPTR0 0xA4400000 /* 16 bit SCIF */
79# define SCSCR_INIT(port) 0x0030 /* TIE=0,RIE=0,TE=1,RE=1 */
80# define SCIF_ONLY
102#elif defined(CONFIG_CPU_SUBTYPE_SH73180) 81#elif defined(CONFIG_CPU_SUBTYPE_SH73180)
103# define SCPDR 0xA4050138 /* 16 bit SCIF */ 82# define SCPDR 0xA4050138 /* 16 bit SCIF */
104# define SCSPTR2 SCPDR 83# define SCSPTR2 SCPDR
105# define SCIF_ORER 0x0001 /* overrun error bit */ 84# define SCIF_ORER 0x0001 /* overrun error bit */
106# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */ 85# define SCSCR_INIT(port) 0x0038 /* TIE=0,RIE=0,TE=1,RE=1 */
107# define SCIF_ONLY 86# define SCIF_ONLY
87#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
88# define SCSPTR0 0xffe00010 /* 16 bit SCIF */
89# define SCSPTR1 0xffe10010 /* 16 bit SCIF */
90# define SCSPTR2 0xffe20010 /* 16 bit SCIF */
91# define SCSPTR3 0xffe30010 /* 16 bit SCIF */
92# define SCSCR_INIT(port) 0x32 /* TIE=0,RIE=0,TE=1,RE=1,REIE=0,CKE=1 */
93# define SCIF_ONLY
108#elif defined(CONFIG_CPU_SUBTYPE_SH4_202) 94#elif defined(CONFIG_CPU_SUBTYPE_SH4_202)
109# define SCSPTR2 0xffe80020 /* 16 bit SCIF */ 95# define SCSPTR2 0xffe80020 /* 16 bit SCIF */
110# define SCIF_ORER 0x0001 /* overrun error bit */ 96# define SCIF_ORER 0x0001 /* overrun error bit */
@@ -145,7 +131,7 @@
145#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 131#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
146# define SCSPTR0 0xffe00024 /* 16 bit SCIF */ 132# define SCSPTR0 0xffe00024 /* 16 bit SCIF */
147# define SCSPTR1 0xffe10024 /* 16 bit SCIF */ 133# define SCSPTR1 0xffe10024 /* 16 bit SCIF */
148# define SCIF_OPER 0x0001 /* Overrun error bit */ 134# define SCIF_ORER 0x0001 /* Overrun error bit */
149# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */ 135# define SCSCR_INIT(port) 0x3a /* TIE=0,RIE=0,TE=1,RE=1,REIE=1 */
150# define SCIF_ONLY 136# define SCIF_ONLY
151#else 137#else
@@ -273,15 +259,6 @@
273 */ 259 */
274#define SCI_EVENT_WRITE_WAKEUP 0 260#define SCI_EVENT_WRITE_WAKEUP 0
275 261
276struct sci_port {
277 struct uart_port port;
278 int type;
279 unsigned char irqs[4]; /* ERI, RXI, TXI, BRI */
280 void (*init_pins)(struct uart_port *port, unsigned int cflag);
281 int break_flag;
282 struct timer_list break_timer;
283};
284
285#define SCI_IN(size, offset) \ 262#define SCI_IN(size, offset) \
286 unsigned int addr = port->mapbase + (offset); \ 263 unsigned int addr = port->mapbase + (offset); \
287 if ((size) == 8) { \ 264 if ((size) == 8) { \
@@ -336,7 +313,9 @@ struct sci_port {
336 } 313 }
337 314
338#ifdef CONFIG_CPU_SH3 315#ifdef CONFIG_CPU_SH3
339#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 316#if defined(CONFIG_CPU_SUBTYPE_SH7300) || \
317 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
318 defined(CONFIG_CPU_SUBTYPE_SH7710)
340#define SCIF_FNS(name, scif_offset, scif_size) \ 319#define SCIF_FNS(name, scif_offset, scif_size) \
341 CPU_SCIF_FNS(name, scif_offset, scif_size) 320 CPU_SCIF_FNS(name, scif_offset, scif_size)
342#else 321#else
@@ -362,7 +341,9 @@ struct sci_port {
362 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size) 341 CPU_SCIF_FNS(name, sh4_scif_offset, sh4_scif_size)
363#endif 342#endif
364 343
365#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 344#if defined(CONFIG_CPU_SUBTYPE_SH7300) || \
345 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
346 defined(CONFIG_CPU_SUBTYPE_SH7710)
366SCIF_FNS(SCSMR, 0x00, 16) 347SCIF_FNS(SCSMR, 0x00, 16)
367SCIF_FNS(SCBRR, 0x04, 8) 348SCIF_FNS(SCBRR, 0x04, 8)
368SCIF_FNS(SCSCR, 0x08, 16) 349SCIF_FNS(SCSCR, 0x08, 16)
@@ -447,7 +428,9 @@ static inline int sci_rxd_in(struct uart_port *port)
447 return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */ 428 return ctrl_inb(SCSPTR)&0x01 ? 1 : 0; /* SCI */
448 return 1; 429 return 1;
449} 430}
450#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) 431#elif defined(CONFIG_CPU_SUBTYPE_SH7707) || \
432 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
433 defined(CONFIG_CPU_SUBTYPE_SH7706)
451static inline int sci_rxd_in(struct uart_port *port) 434static inline int sci_rxd_in(struct uart_port *port)
452{ 435{
453 if (port->mapbase == 0xfffffe80) 436 if (port->mapbase == 0xfffffe80)
@@ -467,6 +450,13 @@ static inline int sci_rxd_in(struct uart_port *port)
467 return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */ 450 return ctrl_inb(SCPDR)&0x10 ? 1 : 0; /* SCIF */
468 return 1; 451 return 1;
469} 452}
453#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
454static inline int sci_rxd_in(struct uart_port *port)
455{
456 if (port->mapbase == SCSPTR0)
457 return ctrl_inw(SCSPTR0 + 0x10) & 0x01 ? 1 : 0;
458 return 1;
459}
470#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \ 460#elif defined(CONFIG_CPU_SUBTYPE_SH7750) || \
471 defined(CONFIG_CPU_SUBTYPE_SH7751) || \ 461 defined(CONFIG_CPU_SUBTYPE_SH7751) || \
472 defined(CONFIG_CPU_SUBTYPE_SH4_202) 462 defined(CONFIG_CPU_SUBTYPE_SH4_202)
@@ -504,6 +494,19 @@ static inline int sci_rxd_in(struct uart_port *port)
504{ 494{
505 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */ 495 return ctrl_inb(SCPDR)&0x01 ? 1 : 0; /* SCIF0 */
506} 496}
497#elif defined(CONFIG_CPU_SUBTYPE_SH7343)
498static inline int sci_rxd_in(struct uart_port *port)
499{
500 if (port->mapbase == 0xffe00000)
501 return ctrl_inw(SCSPTR0) & 0x0001 ? 1 : 0; /* SCIF */
502 if (port->mapbase == 0xffe10000)
503 return ctrl_inw(SCSPTR1) & 0x0001 ? 1 : 0; /* SCIF */
504 if (port->mapbase == 0xffe20000)
505 return ctrl_inw(SCSPTR2) & 0x0001 ? 1 : 0; /* SCIF */
506 if (port->mapbase == 0xffe30000)
507 return ctrl_inw(SCSPTR3) & 0x0001 ? 1 : 0; /* SCIF */
508 return 1;
509}
507#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 510#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
508static inline int sci_rxd_in(struct uart_port *port) 511static inline int sci_rxd_in(struct uart_port *port)
509{ 512{
@@ -587,4 +590,3 @@ static inline int sci_rxd_in(struct uart_port *port)
587#else /* Generic SH */ 590#else /* Generic SH */
588#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1) 591#define SCBRR_VALUE(bps, clk) ((clk+16*bps)/(32*bps)-1)
589#endif 592#endif
590
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index 005043197527..f9b1719b9a37 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -25,6 +25,7 @@ config USB_ARCH_HAS_OHCI
25 default y if PXA27x 25 default y if PXA27x
26 default y if ARCH_EP93XX 26 default y if ARCH_EP93XX
27 default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261) 27 default y if (ARCH_AT91RM9200 || ARCH_AT91SAM9261)
28 default y if ARCH_PNX4008
28 # PPC: 29 # PPC:
29 default y if STB03xxx 30 default y if STB03xxx
30 default y if PPC_MPC52xx 31 default y if PPC_MPC52xx
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index 4710eb02ed64..97d57cfc343b 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_USB_ISP116X_HCD) += host/
14obj-$(CONFIG_USB_OHCI_HCD) += host/ 14obj-$(CONFIG_USB_OHCI_HCD) += host/
15obj-$(CONFIG_USB_UHCI_HCD) += host/ 15obj-$(CONFIG_USB_UHCI_HCD) += host/
16obj-$(CONFIG_USB_SL811_HCD) += host/ 16obj-$(CONFIG_USB_SL811_HCD) += host/
17obj-$(CONFIG_USB_U132_HCD) += host/
17obj-$(CONFIG_ETRAX_USB_HOST) += host/ 18obj-$(CONFIG_ETRAX_USB_HOST) += host/
18obj-$(CONFIG_USB_OHCI_AT91) += host/ 19obj-$(CONFIG_USB_OHCI_AT91) += host/
19 20
@@ -23,6 +24,7 @@ obj-$(CONFIG_USB_PRINTER) += class/
23obj-$(CONFIG_USB_STORAGE) += storage/ 24obj-$(CONFIG_USB_STORAGE) += storage/
24obj-$(CONFIG_USB) += storage/ 25obj-$(CONFIG_USB) += storage/
25 26
27obj-$(CONFIG_USB_ACECAD) += input/
26obj-$(CONFIG_USB_AIPTEK) += input/ 28obj-$(CONFIG_USB_AIPTEK) += input/
27obj-$(CONFIG_USB_ATI_REMOTE) += input/ 29obj-$(CONFIG_USB_ATI_REMOTE) += input/
28obj-$(CONFIG_USB_HID) += input/ 30obj-$(CONFIG_USB_HID) += input/
@@ -31,8 +33,8 @@ obj-$(CONFIG_USB_KBTAB) += input/
31obj-$(CONFIG_USB_MOUSE) += input/ 33obj-$(CONFIG_USB_MOUSE) += input/
32obj-$(CONFIG_USB_MTOUCH) += input/ 34obj-$(CONFIG_USB_MTOUCH) += input/
33obj-$(CONFIG_USB_POWERMATE) += input/ 35obj-$(CONFIG_USB_POWERMATE) += input/
36obj-$(CONFIG_USB_TRANCEVIBRATOR)+= input/
34obj-$(CONFIG_USB_WACOM) += input/ 37obj-$(CONFIG_USB_WACOM) += input/
35obj-$(CONFIG_USB_ACECAD) += input/
36obj-$(CONFIG_USB_XPAD) += input/ 38obj-$(CONFIG_USB_XPAD) += input/
37 39
38obj-$(CONFIG_USB_CATC) += net/ 40obj-$(CONFIG_USB_CATC) += net/
@@ -47,22 +49,24 @@ obj-$(CONFIG_USB_MICROTEK) += image/
47 49
48obj-$(CONFIG_USB_SERIAL) += serial/ 50obj-$(CONFIG_USB_SERIAL) += serial/
49 51
52obj-$(CONFIG_USB_ADUTUX) += misc/
53obj-$(CONFIG_USB_APPLEDISPLAY) += misc/
50obj-$(CONFIG_USB_AUERSWALD) += misc/ 54obj-$(CONFIG_USB_AUERSWALD) += misc/
51obj-$(CONFIG_USB_CYPRESS_CY7C63)+= misc/ 55obj-$(CONFIG_USB_CYPRESS_CY7C63)+= misc/
52obj-$(CONFIG_USB_CYTHERM) += misc/ 56obj-$(CONFIG_USB_CYTHERM) += misc/
53obj-$(CONFIG_USB_EMI26) += misc/ 57obj-$(CONFIG_USB_EMI26) += misc/
54obj-$(CONFIG_USB_EMI62) += misc/ 58obj-$(CONFIG_USB_EMI62) += misc/
59obj-$(CONFIG_USB_FTDI_ELAN) += misc/
55obj-$(CONFIG_USB_IDMOUSE) += misc/ 60obj-$(CONFIG_USB_IDMOUSE) += misc/
56obj-$(CONFIG_USB_LCD) += misc/ 61obj-$(CONFIG_USB_LCD) += misc/
57obj-$(CONFIG_USB_LD) += misc/ 62obj-$(CONFIG_USB_LD) += misc/
58obj-$(CONFIG_USB_LED) += misc/ 63obj-$(CONFIG_USB_LED) += misc/
59obj-$(CONFIG_USB_LEGOTOWER) += misc/ 64obj-$(CONFIG_USB_LEGOTOWER) += misc/
65obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
60obj-$(CONFIG_USB_RIO500) += misc/ 66obj-$(CONFIG_USB_RIO500) += misc/
67obj-$(CONFIG_USB_SISUSBVGA) += misc/
61obj-$(CONFIG_USB_TEST) += misc/ 68obj-$(CONFIG_USB_TEST) += misc/
62obj-$(CONFIG_USB_USS720) += misc/ 69obj-$(CONFIG_USB_USS720) += misc/
63obj-$(CONFIG_USB_PHIDGETSERVO) += misc/
64obj-$(CONFIG_USB_SISUSBVGA) += misc/
65obj-$(CONFIG_USB_APPLEDISPLAY) += misc/
66 70
67obj-$(CONFIG_USB_ATM) += atm/ 71obj-$(CONFIG_USB_ATM) += atm/
68obj-$(CONFIG_USB_SPEEDTOUCH) += atm/ 72obj-$(CONFIG_USB_SPEEDTOUCH) += atm/
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index b38990adf1cd..465961a26e4a 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -1621,26 +1621,32 @@ static int claim_interface(struct usb_device *usb_dev,
1621 return ret; 1621 return ret;
1622} 1622}
1623 1623
1624static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf) 1624static struct attribute *attrs[] = {
1625 &dev_attr_stat_status.attr,
1626 &dev_attr_stat_mflags.attr,
1627 &dev_attr_stat_human_status.attr,
1628 &dev_attr_stat_delin.attr,
1629 &dev_attr_stat_vidcpe.attr,
1630 &dev_attr_stat_usrate.attr,
1631 &dev_attr_stat_dsrate.attr,
1632 &dev_attr_stat_usattenuation.attr,
1633 &dev_attr_stat_dsattenuation.attr,
1634 &dev_attr_stat_usmargin.attr,
1635 &dev_attr_stat_dsmargin.attr,
1636 &dev_attr_stat_txflow.attr,
1637 &dev_attr_stat_rxflow.attr,
1638 &dev_attr_stat_uscorr.attr,
1639 &dev_attr_stat_dscorr.attr,
1640 &dev_attr_stat_usunc.attr,
1641 &dev_attr_stat_dsunc.attr,
1642};
1643static struct attribute_group attr_grp = {
1644 .attrs = attrs,
1645};
1646
1647static int create_fs_entries(struct usb_interface *intf)
1625{ 1648{
1626 /* sysfs interface */ 1649 return sysfs_create_group(&intf->dev.kobj, &attr_grp);
1627 device_create_file(&intf->dev, &dev_attr_stat_status);
1628 device_create_file(&intf->dev, &dev_attr_stat_mflags);
1629 device_create_file(&intf->dev, &dev_attr_stat_human_status);
1630 device_create_file(&intf->dev, &dev_attr_stat_delin);
1631 device_create_file(&intf->dev, &dev_attr_stat_vidcpe);
1632 device_create_file(&intf->dev, &dev_attr_stat_usrate);
1633 device_create_file(&intf->dev, &dev_attr_stat_dsrate);
1634 device_create_file(&intf->dev, &dev_attr_stat_usattenuation);
1635 device_create_file(&intf->dev, &dev_attr_stat_dsattenuation);
1636 device_create_file(&intf->dev, &dev_attr_stat_usmargin);
1637 device_create_file(&intf->dev, &dev_attr_stat_dsmargin);
1638 device_create_file(&intf->dev, &dev_attr_stat_txflow);
1639 device_create_file(&intf->dev, &dev_attr_stat_rxflow);
1640 device_create_file(&intf->dev, &dev_attr_stat_uscorr);
1641 device_create_file(&intf->dev, &dev_attr_stat_dscorr);
1642 device_create_file(&intf->dev, &dev_attr_stat_usunc);
1643 device_create_file(&intf->dev, &dev_attr_stat_dsunc);
1644} 1650}
1645 1651
1646static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, 1652static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
@@ -1708,37 +1714,25 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1708 return ret; 1714 return ret;
1709 } 1715 }
1710 1716
1711 create_fs_entries(sc, intf); 1717 ret = create_fs_entries(intf);
1718 if (ret) {
1719 uea_stop(sc);
1720 kfree(sc);
1721 return ret;
1722 }
1712 return 0; 1723 return 0;
1713} 1724}
1714 1725
1715static void destroy_fs_entries(struct uea_softc *sc, struct usb_interface *intf) 1726static void destroy_fs_entries(struct usb_interface *intf)
1716{ 1727{
1717 /* sysfs interface */ 1728 sysfs_remove_group(&intf->dev.kobj, &attr_grp);
1718 device_remove_file(&intf->dev, &dev_attr_stat_status);
1719 device_remove_file(&intf->dev, &dev_attr_stat_mflags);
1720 device_remove_file(&intf->dev, &dev_attr_stat_human_status);
1721 device_remove_file(&intf->dev, &dev_attr_stat_delin);
1722 device_remove_file(&intf->dev, &dev_attr_stat_vidcpe);
1723 device_remove_file(&intf->dev, &dev_attr_stat_usrate);
1724 device_remove_file(&intf->dev, &dev_attr_stat_dsrate);
1725 device_remove_file(&intf->dev, &dev_attr_stat_usattenuation);
1726 device_remove_file(&intf->dev, &dev_attr_stat_dsattenuation);
1727 device_remove_file(&intf->dev, &dev_attr_stat_usmargin);
1728 device_remove_file(&intf->dev, &dev_attr_stat_dsmargin);
1729 device_remove_file(&intf->dev, &dev_attr_stat_txflow);
1730 device_remove_file(&intf->dev, &dev_attr_stat_rxflow);
1731 device_remove_file(&intf->dev, &dev_attr_stat_uscorr);
1732 device_remove_file(&intf->dev, &dev_attr_stat_dscorr);
1733 device_remove_file(&intf->dev, &dev_attr_stat_usunc);
1734 device_remove_file(&intf->dev, &dev_attr_stat_dsunc);
1735} 1729}
1736 1730
1737static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) 1731static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1738{ 1732{
1739 struct uea_softc *sc = usbatm->driver_data; 1733 struct uea_softc *sc = usbatm->driver_data;
1740 1734
1741 destroy_fs_entries(sc, intf); 1735 destroy_fs_entries(intf);
1742 uea_stop(sc); 1736 uea_stop(sc);
1743 kfree(sc); 1737 kfree(sc);
1744} 1738}
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 48dee4b8d8e5..9cac11ca1bb7 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -813,7 +813,7 @@ static unsigned int usblp_quirks (__u16 vendor, __u16 product)
813 return 0; 813 return 0;
814} 814}
815 815
816static struct file_operations usblp_fops = { 816static const struct file_operations usblp_fops = {
817 .owner = THIS_MODULE, 817 .owner = THIS_MODULE,
818 .read = usblp_read, 818 .read = usblp_read,
819 .write = usblp_write, 819 .write = usblp_write,
@@ -927,7 +927,9 @@ static int usblp_probe(struct usb_interface *intf,
927 927
928 /* Retrieve and store the device ID string. */ 928 /* Retrieve and store the device ID string. */
929 usblp_cache_device_id_string(usblp); 929 usblp_cache_device_id_string(usblp);
930 device_create_file(&intf->dev, &dev_attr_ieee1284_id); 930 retval = device_create_file(&intf->dev, &dev_attr_ieee1284_id);
931 if (retval)
932 goto abort_intfdata;
931 933
932#ifdef DEBUG 934#ifdef DEBUG
933 usblp_check_status(usblp, 0); 935 usblp_check_status(usblp, 0);
@@ -1021,18 +1023,13 @@ static int usblp_select_alts(struct usblp *usblp)
1021 for (e = 0; e < ifd->desc.bNumEndpoints; e++) { 1023 for (e = 0; e < ifd->desc.bNumEndpoints; e++) {
1022 epd = &ifd->endpoint[e].desc; 1024 epd = &ifd->endpoint[e].desc;
1023 1025
1024 if ((epd->bmAttributes&USB_ENDPOINT_XFERTYPE_MASK)!= 1026 if (usb_endpoint_is_bulk_out(epd))
1025 USB_ENDPOINT_XFER_BULK)
1026 continue;
1027
1028 if (!(epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK)) {
1029 if (!epwrite) 1027 if (!epwrite)
1030 epwrite = epd; 1028 epwrite = epd;
1031 1029
1032 } else { 1030 if (usb_endpoint_is_bulk_in(epd))
1033 if (!epread) 1031 if (!epread)
1034 epread = epd; 1032 epread = epd;
1035 }
1036 } 1033 }
1037 1034
1038 /* Ignore buggy hardware without the right endpoints. */ 1035 /* Ignore buggy hardware without the right endpoints. */
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index ec510922af63..34e9bac319b4 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -4,7 +4,7 @@
4 4
5usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \ 5usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \
6 config.o file.o buffer.o sysfs.o endpoint.o \ 6 config.o file.o buffer.o sysfs.o endpoint.o \
7 devio.o notify.o 7 devio.o notify.o generic.o
8 8
9ifeq ($(CONFIG_PCI),y) 9ifeq ($(CONFIG_PCI),y)
10 usbcore-objs += hcd-pci.o 10 usbcore-objs += hcd-pci.o
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index f4f4ef0f377a..840442a25b61 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -104,7 +104,7 @@ void *hcd_buffer_alloc (
104 dma_addr_t *dma 104 dma_addr_t *dma
105) 105)
106{ 106{
107 struct usb_hcd *hcd = bus->hcpriv; 107 struct usb_hcd *hcd = bus_to_hcd(bus);
108 int i; 108 int i;
109 109
110 /* some USB hosts just use PIO */ 110 /* some USB hosts just use PIO */
@@ -127,7 +127,7 @@ void hcd_buffer_free (
127 dma_addr_t dma 127 dma_addr_t dma
128) 128)
129{ 129{
130 struct usb_hcd *hcd = bus->hcpriv; 130 struct usb_hcd *hcd = bus_to_hcd(bus);
131 int i; 131 int i;
132 132
133 if (!addr) 133 if (!addr)
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 4c9e63e665b6..bfb3731d42db 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -475,7 +475,9 @@ int usb_get_configuration(struct usb_device *dev)
475 if (result < 0) { 475 if (result < 0) {
476 dev_err(ddev, "unable to read config index %d " 476 dev_err(ddev, "unable to read config index %d "
477 "descriptor/%s\n", cfgno, "start"); 477 "descriptor/%s\n", cfgno, "start");
478 goto err; 478 dev_err(ddev, "chopping to %d config(s)\n", cfgno);
479 dev->descriptor.bNumConfigurations = cfgno;
480 break;
479 } else if (result < 4) { 481 } else if (result < 4) {
480 dev_err(ddev, "config index %d descriptor too short " 482 dev_err(ddev, "config index %d descriptor too short "
481 "(expected %i, got %i)\n", cfgno, 483 "(expected %i, got %i)\n", cfgno,
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index c0f37343a276..3538c2fdadfe 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -593,7 +593,7 @@ static ssize_t usb_device_read(struct file *file, char __user *buf, size_t nbyte
593/* Kernel lock for "lastev" protection */ 593/* Kernel lock for "lastev" protection */
594static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait) 594static unsigned int usb_device_poll(struct file *file, struct poll_table_struct *wait)
595{ 595{
596 struct usb_device_status *st = (struct usb_device_status *)file->private_data; 596 struct usb_device_status *st = file->private_data;
597 unsigned int mask = 0; 597 unsigned int mask = 0;
598 598
599 lock_kernel(); 599 lock_kernel();
@@ -603,7 +603,7 @@ static unsigned int usb_device_poll(struct file *file, struct poll_table_struct
603 unlock_kernel(); 603 unlock_kernel();
604 return POLLIN; 604 return POLLIN;
605 } 605 }
606 606
607 /* we may have dropped BKL - need to check for having lost the race */ 607 /* we may have dropped BKL - need to check for having lost the race */
608 if (file->private_data) { 608 if (file->private_data) {
609 kfree(st); 609 kfree(st);
@@ -667,7 +667,7 @@ static loff_t usb_device_lseek(struct file * file, loff_t offset, int orig)
667 return ret; 667 return ret;
668} 668}
669 669
670struct file_operations usbfs_devices_fops = { 670const struct file_operations usbfs_devices_fops = {
671 .llseek = usb_device_lseek, 671 .llseek = usb_device_lseek,
672 .read = usb_device_read, 672 .read = usb_device_read,
673 .poll = usb_device_poll, 673 .poll = usb_device_poll,
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 218621b9958e..a94c63bef632 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -59,6 +59,9 @@
59#define USB_DEVICE_MAX USB_MAXBUS * 128 59#define USB_DEVICE_MAX USB_MAXBUS * 128
60static struct class *usb_device_class; 60static struct class *usb_device_class;
61 61
62/* Mutual exclusion for removal, open, and release */
63DEFINE_MUTEX(usbfs_mutex);
64
62struct async { 65struct async {
63 struct list_head asynclist; 66 struct list_head asynclist;
64 struct dev_state *ps; 67 struct dev_state *ps;
@@ -87,9 +90,10 @@ MODULE_PARM_DESC (usbfs_snoop, "true to log all usbfs traffic");
87 90
88#define MAX_USBFS_BUFFER_SIZE 16384 91#define MAX_USBFS_BUFFER_SIZE 16384
89 92
90static inline int connected (struct usb_device *dev) 93static inline int connected (struct dev_state *ps)
91{ 94{
92 return dev->state != USB_STATE_NOTATTACHED; 95 return (!list_empty(&ps->list) &&
96 ps->dev->state != USB_STATE_NOTATTACHED);
93} 97}
94 98
95static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig) 99static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
@@ -118,7 +122,7 @@ static loff_t usbdev_lseek(struct file *file, loff_t offset, int orig)
118 122
119static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 123static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
120{ 124{
121 struct dev_state *ps = (struct dev_state *)file->private_data; 125 struct dev_state *ps = file->private_data;
122 struct usb_device *dev = ps->dev; 126 struct usb_device *dev = ps->dev;
123 ssize_t ret = 0; 127 ssize_t ret = 0;
124 unsigned len; 128 unsigned len;
@@ -127,7 +131,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes, l
127 131
128 pos = *ppos; 132 pos = *ppos;
129 usb_lock_device(dev); 133 usb_lock_device(dev);
130 if (!connected(dev)) { 134 if (!connected(ps)) {
131 ret = -ENODEV; 135 ret = -ENODEV;
132 goto err; 136 goto err;
133 } else if (pos < 0) { 137 } else if (pos < 0) {
@@ -301,7 +305,7 @@ static void snoop_urb(struct urb *urb, void __user *userurb)
301 305
302static void async_completed(struct urb *urb, struct pt_regs *regs) 306static void async_completed(struct urb *urb, struct pt_regs *regs)
303{ 307{
304 struct async *as = (struct async *)urb->context; 308 struct async *as = urb->context;
305 struct dev_state *ps = as->ps; 309 struct dev_state *ps = as->ps;
306 struct siginfo sinfo; 310 struct siginfo sinfo;
307 311
@@ -541,25 +545,25 @@ static int usbdev_open(struct inode *inode, struct file *file)
541 struct dev_state *ps; 545 struct dev_state *ps;
542 int ret; 546 int ret;
543 547
544 /* 548 /* Protect against simultaneous removal or release */
545 * no locking necessary here, as chrdev_open has the kernel lock 549 mutex_lock(&usbfs_mutex);
546 * (still acquire the kernel lock for safety) 550
547 */
548 ret = -ENOMEM; 551 ret = -ENOMEM;
549 if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL))) 552 if (!(ps = kmalloc(sizeof(struct dev_state), GFP_KERNEL)))
550 goto out_nolock; 553 goto out;
551 554
552 lock_kernel();
553 ret = -ENOENT; 555 ret = -ENOENT;
554 /* check if we are called from a real node or usbfs */ 556 /* check if we are called from a real node or usbfs */
555 if (imajor(inode) == USB_DEVICE_MAJOR) 557 if (imajor(inode) == USB_DEVICE_MAJOR)
556 dev = usbdev_lookup_minor(iminor(inode)); 558 dev = usbdev_lookup_minor(iminor(inode));
557 if (!dev) 559 if (!dev)
558 dev = inode->u.generic_ip; 560 dev = inode->i_private;
559 if (!dev) { 561 if (!dev)
560 kfree(ps);
561 goto out; 562 goto out;
562 } 563 ret = usb_autoresume_device(dev, 1);
564 if (ret)
565 goto out;
566
563 usb_get_dev(dev); 567 usb_get_dev(dev);
564 ret = 0; 568 ret = 0;
565 ps->dev = dev; 569 ps->dev = dev;
@@ -579,30 +583,36 @@ static int usbdev_open(struct inode *inode, struct file *file)
579 list_add_tail(&ps->list, &dev->filelist); 583 list_add_tail(&ps->list, &dev->filelist);
580 file->private_data = ps; 584 file->private_data = ps;
581 out: 585 out:
582 unlock_kernel(); 586 if (ret)
583 out_nolock: 587 kfree(ps);
584 return ret; 588 mutex_unlock(&usbfs_mutex);
589 return ret;
585} 590}
586 591
587static int usbdev_release(struct inode *inode, struct file *file) 592static int usbdev_release(struct inode *inode, struct file *file)
588{ 593{
589 struct dev_state *ps = (struct dev_state *)file->private_data; 594 struct dev_state *ps = file->private_data;
590 struct usb_device *dev = ps->dev; 595 struct usb_device *dev = ps->dev;
591 unsigned int ifnum; 596 unsigned int ifnum;
592 597
593 usb_lock_device(dev); 598 usb_lock_device(dev);
599
600 /* Protect against simultaneous open */
601 mutex_lock(&usbfs_mutex);
594 list_del_init(&ps->list); 602 list_del_init(&ps->list);
603 mutex_unlock(&usbfs_mutex);
604
595 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed); 605 for (ifnum = 0; ps->ifclaimed && ifnum < 8*sizeof(ps->ifclaimed);
596 ifnum++) { 606 ifnum++) {
597 if (test_bit(ifnum, &ps->ifclaimed)) 607 if (test_bit(ifnum, &ps->ifclaimed))
598 releaseintf(ps, ifnum); 608 releaseintf(ps, ifnum);
599 } 609 }
600 destroy_all_async(ps); 610 destroy_all_async(ps);
611 usb_autosuspend_device(dev, 1);
601 usb_unlock_device(dev); 612 usb_unlock_device(dev);
602 usb_put_dev(dev); 613 usb_put_dev(dev);
603 ps->dev = NULL;
604 kfree(ps); 614 kfree(ps);
605 return 0; 615 return 0;
606} 616}
607 617
608static int proc_control(struct dev_state *ps, void __user *arg) 618static int proc_control(struct dev_state *ps, void __user *arg)
@@ -1322,7 +1332,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1322 } 1332 }
1323 } 1333 }
1324 1334
1325 if (!connected(ps->dev)) { 1335 if (!connected(ps)) {
1326 kfree(buf); 1336 kfree(buf);
1327 return -ENODEV; 1337 return -ENODEV;
1328 } 1338 }
@@ -1349,7 +1359,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1349 /* let kernel drivers try to (re)bind to the interface */ 1359 /* let kernel drivers try to (re)bind to the interface */
1350 case USBDEVFS_CONNECT: 1360 case USBDEVFS_CONNECT:
1351 usb_unlock_device(ps->dev); 1361 usb_unlock_device(ps->dev);
1352 bus_rescan_devices(intf->dev.bus); 1362 retval = bus_rescan_devices(intf->dev.bus);
1353 usb_lock_device(ps->dev); 1363 usb_lock_device(ps->dev);
1354 break; 1364 break;
1355 1365
@@ -1413,7 +1423,7 @@ static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg)
1413 */ 1423 */
1414static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 1424static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
1415{ 1425{
1416 struct dev_state *ps = (struct dev_state *)file->private_data; 1426 struct dev_state *ps = file->private_data;
1417 struct usb_device *dev = ps->dev; 1427 struct usb_device *dev = ps->dev;
1418 void __user *p = (void __user *)arg; 1428 void __user *p = (void __user *)arg;
1419 int ret = -ENOTTY; 1429 int ret = -ENOTTY;
@@ -1421,7 +1431,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1421 if (!(file->f_mode & FMODE_WRITE)) 1431 if (!(file->f_mode & FMODE_WRITE))
1422 return -EPERM; 1432 return -EPERM;
1423 usb_lock_device(dev); 1433 usb_lock_device(dev);
1424 if (!connected(dev)) { 1434 if (!connected(ps)) {
1425 usb_unlock_device(dev); 1435 usb_unlock_device(dev);
1426 return -ENODEV; 1436 return -ENODEV;
1427 } 1437 }
@@ -1556,18 +1566,18 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1556/* No kernel lock - fine */ 1566/* No kernel lock - fine */
1557static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wait) 1567static unsigned int usbdev_poll(struct file *file, struct poll_table_struct *wait)
1558{ 1568{
1559 struct dev_state *ps = (struct dev_state *)file->private_data; 1569 struct dev_state *ps = file->private_data;
1560 unsigned int mask = 0; 1570 unsigned int mask = 0;
1561 1571
1562 poll_wait(file, &ps->wait, wait); 1572 poll_wait(file, &ps->wait, wait);
1563 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed)) 1573 if (file->f_mode & FMODE_WRITE && !list_empty(&ps->async_completed))
1564 mask |= POLLOUT | POLLWRNORM; 1574 mask |= POLLOUT | POLLWRNORM;
1565 if (!connected(ps->dev)) 1575 if (!connected(ps))
1566 mask |= POLLERR | POLLHUP; 1576 mask |= POLLERR | POLLHUP;
1567 return mask; 1577 return mask;
1568} 1578}
1569 1579
1570struct file_operations usbfs_device_file_operations = { 1580const struct file_operations usbfs_device_file_operations = {
1571 .llseek = usbdev_lseek, 1581 .llseek = usbdev_lseek,
1572 .read = usbdev_read, 1582 .read = usbdev_read,
1573 .poll = usbdev_poll, 1583 .poll = usbdev_poll,
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index ec8906501415..b10463244413 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -17,7 +17,8 @@
17 * 17 *
18 * NOTE! This is not actually a driver at all, rather this is 18 * NOTE! This is not actually a driver at all, rather this is
19 * just a collection of helper routines that implement the 19 * just a collection of helper routines that implement the
20 * generic USB things that the real drivers can use.. 20 * matching, probing, releasing, suspending and resuming for
21 * real drivers.
21 * 22 *
22 */ 23 */
23 24
@@ -34,38 +35,6 @@ struct usb_dynid {
34 struct usb_device_id id; 35 struct usb_device_id id;
35}; 36};
36 37
37
38static int generic_probe(struct device *dev)
39{
40 return 0;
41}
42static int generic_remove(struct device *dev)
43{
44 struct usb_device *udev = to_usb_device(dev);
45
46 /* if this is only an unbind, not a physical disconnect, then
47 * unconfigure the device */
48 if (udev->state == USB_STATE_CONFIGURED)
49 usb_set_configuration(udev, 0);
50
51 /* in case the call failed or the device was suspended */
52 if (udev->state >= USB_STATE_CONFIGURED)
53 usb_disable_device(udev, 0);
54 return 0;
55}
56
57struct device_driver usb_generic_driver = {
58 .owner = THIS_MODULE,
59 .name = "usb",
60 .bus = &usb_bus_type,
61 .probe = generic_probe,
62 .remove = generic_remove,
63};
64
65/* Fun hack to determine if the struct device is a
66 * usb device or a usb interface. */
67int usb_generic_driver_data;
68
69#ifdef CONFIG_HOTPLUG 38#ifdef CONFIG_HOTPLUG
70 39
71/* 40/*
@@ -80,6 +49,7 @@ static ssize_t store_new_id(struct device_driver *driver,
80 u32 idVendor = 0; 49 u32 idVendor = 0;
81 u32 idProduct = 0; 50 u32 idProduct = 0;
82 int fields = 0; 51 int fields = 0;
52 int retval = 0;
83 53
84 fields = sscanf(buf, "%x %x", &idVendor, &idProduct); 54 fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
85 if (fields < 2) 55 if (fields < 2)
@@ -99,10 +69,12 @@ static ssize_t store_new_id(struct device_driver *driver,
99 spin_unlock(&usb_drv->dynids.lock); 69 spin_unlock(&usb_drv->dynids.lock);
100 70
101 if (get_driver(driver)) { 71 if (get_driver(driver)) {
102 driver_attach(driver); 72 retval = driver_attach(driver);
103 put_driver(driver); 73 put_driver(driver);
104 } 74 }
105 75
76 if (retval)
77 return retval;
106 return count; 78 return count;
107} 79}
108static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id); 80static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
@@ -115,7 +87,7 @@ static int usb_create_newid_file(struct usb_driver *usb_drv)
115 goto exit; 87 goto exit;
116 88
117 if (usb_drv->probe != NULL) 89 if (usb_drv->probe != NULL)
118 error = sysfs_create_file(&usb_drv->driver.kobj, 90 error = sysfs_create_file(&usb_drv->drvwrap.driver.kobj,
119 &driver_attr_new_id.attr); 91 &driver_attr_new_id.attr);
120exit: 92exit:
121 return error; 93 return error;
@@ -127,7 +99,7 @@ static void usb_remove_newid_file(struct usb_driver *usb_drv)
127 return; 99 return;
128 100
129 if (usb_drv->probe != NULL) 101 if (usb_drv->probe != NULL)
130 sysfs_remove_file(&usb_drv->driver.kobj, 102 sysfs_remove_file(&usb_drv->drvwrap.driver.kobj,
131 &driver_attr_new_id.attr); 103 &driver_attr_new_id.attr);
132} 104}
133 105
@@ -174,21 +146,57 @@ static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *in
174} 146}
175 147
176 148
177/* called from driver core with usb_bus_type.subsys writelock */ 149/* called from driver core with dev locked */
150static int usb_probe_device(struct device *dev)
151{
152 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
153 struct usb_device *udev;
154 int error = -ENODEV;
155
156 dev_dbg(dev, "%s\n", __FUNCTION__);
157
158 if (!is_usb_device(dev)) /* Sanity check */
159 return error;
160
161 udev = to_usb_device(dev);
162
163 /* TODO: Add real matching code */
164
165 /* The device should always appear to be in use
166 * unless the driver suports autosuspend.
167 */
168 udev->pm_usage_cnt = !(udriver->supports_autosuspend);
169
170 error = udriver->probe(udev);
171 return error;
172}
173
174/* called from driver core with dev locked */
175static int usb_unbind_device(struct device *dev)
176{
177 struct usb_device_driver *udriver = to_usb_device_driver(dev->driver);
178
179 udriver->disconnect(to_usb_device(dev));
180 return 0;
181}
182
183
184/* called from driver core with dev locked */
178static int usb_probe_interface(struct device *dev) 185static int usb_probe_interface(struct device *dev)
179{ 186{
180 struct usb_interface * intf = to_usb_interface(dev); 187 struct usb_driver *driver = to_usb_driver(dev->driver);
181 struct usb_driver * driver = to_usb_driver(dev->driver); 188 struct usb_interface *intf;
189 struct usb_device *udev;
182 const struct usb_device_id *id; 190 const struct usb_device_id *id;
183 int error = -ENODEV; 191 int error = -ENODEV;
184 192
185 dev_dbg(dev, "%s\n", __FUNCTION__); 193 dev_dbg(dev, "%s\n", __FUNCTION__);
186 194
187 if (!driver->probe) 195 if (is_usb_device(dev)) /* Sanity check */
188 return error; 196 return error;
189 /* FIXME we'd much prefer to just resume it ... */ 197
190 if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED) 198 intf = to_usb_interface(dev);
191 return -EHOSTUNREACH; 199 udev = interface_to_usbdev(intf);
192 200
193 id = usb_match_id(intf, driver->id_table); 201 id = usb_match_id(intf, driver->id_table);
194 if (!id) 202 if (!id)
@@ -196,48 +204,165 @@ static int usb_probe_interface(struct device *dev)
196 if (id) { 204 if (id) {
197 dev_dbg(dev, "%s - got id\n", __FUNCTION__); 205 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
198 206
207 error = usb_autoresume_device(udev, 1);
208 if (error)
209 return error;
210
199 /* Interface "power state" doesn't correspond to any hardware 211 /* Interface "power state" doesn't correspond to any hardware
200 * state whatsoever. We use it to record when it's bound to 212 * state whatsoever. We use it to record when it's bound to
201 * a driver that may start I/0: it's not frozen/quiesced. 213 * a driver that may start I/0: it's not frozen/quiesced.
202 */ 214 */
203 mark_active(intf); 215 mark_active(intf);
204 intf->condition = USB_INTERFACE_BINDING; 216 intf->condition = USB_INTERFACE_BINDING;
217
218 /* The interface should always appear to be in use
219 * unless the driver suports autosuspend.
220 */
221 intf->pm_usage_cnt = !(driver->supports_autosuspend);
222
205 error = driver->probe(intf, id); 223 error = driver->probe(intf, id);
206 if (error) { 224 if (error) {
207 mark_quiesced(intf); 225 mark_quiesced(intf);
226 intf->needs_remote_wakeup = 0;
208 intf->condition = USB_INTERFACE_UNBOUND; 227 intf->condition = USB_INTERFACE_UNBOUND;
209 } else 228 } else
210 intf->condition = USB_INTERFACE_BOUND; 229 intf->condition = USB_INTERFACE_BOUND;
230
231 usb_autosuspend_device(udev, 1);
211 } 232 }
212 233
213 return error; 234 return error;
214} 235}
215 236
216/* called from driver core with usb_bus_type.subsys writelock */ 237/* called from driver core with dev locked */
217static int usb_unbind_interface(struct device *dev) 238static int usb_unbind_interface(struct device *dev)
218{ 239{
240 struct usb_driver *driver = to_usb_driver(dev->driver);
219 struct usb_interface *intf = to_usb_interface(dev); 241 struct usb_interface *intf = to_usb_interface(dev);
220 struct usb_driver *driver = to_usb_driver(intf->dev.driver); 242 struct usb_device *udev;
243 int error;
221 244
222 intf->condition = USB_INTERFACE_UNBINDING; 245 intf->condition = USB_INTERFACE_UNBINDING;
223 246
247 /* Autoresume for set_interface call below */
248 udev = interface_to_usbdev(intf);
249 error = usb_autoresume_device(udev, 1);
250
224 /* release all urbs for this interface */ 251 /* release all urbs for this interface */
225 usb_disable_interface(interface_to_usbdev(intf), intf); 252 usb_disable_interface(interface_to_usbdev(intf), intf);
226 253
227 if (driver && driver->disconnect) 254 driver->disconnect(intf);
228 driver->disconnect(intf);
229 255
230 /* reset other interface state */ 256 /* reset other interface state */
231 usb_set_interface(interface_to_usbdev(intf), 257 usb_set_interface(interface_to_usbdev(intf),
232 intf->altsetting[0].desc.bInterfaceNumber, 258 intf->altsetting[0].desc.bInterfaceNumber,
233 0); 259 0);
234 usb_set_intfdata(intf, NULL); 260 usb_set_intfdata(intf, NULL);
261
235 intf->condition = USB_INTERFACE_UNBOUND; 262 intf->condition = USB_INTERFACE_UNBOUND;
236 mark_quiesced(intf); 263 mark_quiesced(intf);
264 intf->needs_remote_wakeup = 0;
265
266 if (!error)
267 usb_autosuspend_device(udev, 1);
237 268
238 return 0; 269 return 0;
239} 270}
240 271
272/**
273 * usb_driver_claim_interface - bind a driver to an interface
274 * @driver: the driver to be bound
275 * @iface: the interface to which it will be bound; must be in the
276 * usb device's active configuration
277 * @priv: driver data associated with that interface
278 *
279 * This is used by usb device drivers that need to claim more than one
280 * interface on a device when probing (audio and acm are current examples).
281 * No device driver should directly modify internal usb_interface or
282 * usb_device structure members.
283 *
284 * Few drivers should need to use this routine, since the most natural
285 * way to bind to an interface is to return the private data from
286 * the driver's probe() method.
287 *
288 * Callers must own the device lock and the driver model's usb_bus_type.subsys
289 * writelock. So driver probe() entries don't need extra locking,
290 * but other call contexts may need to explicitly claim those locks.
291 */
292int usb_driver_claim_interface(struct usb_driver *driver,
293 struct usb_interface *iface, void* priv)
294{
295 struct device *dev = &iface->dev;
296 struct usb_device *udev = interface_to_usbdev(iface);
297 int retval = 0;
298
299 if (dev->driver)
300 return -EBUSY;
301
302 dev->driver = &driver->drvwrap.driver;
303 usb_set_intfdata(iface, priv);
304
305 mutex_lock_nested(&udev->pm_mutex, udev->level);
306 iface->condition = USB_INTERFACE_BOUND;
307 mark_active(iface);
308 iface->pm_usage_cnt = !(driver->supports_autosuspend);
309 mutex_unlock(&udev->pm_mutex);
310
311 /* if interface was already added, bind now; else let
312 * the future device_add() bind it, bypassing probe()
313 */
314 if (device_is_registered(dev))
315 retval = device_bind_driver(dev);
316
317 return retval;
318}
319EXPORT_SYMBOL(usb_driver_claim_interface);
320
321/**
322 * usb_driver_release_interface - unbind a driver from an interface
323 * @driver: the driver to be unbound
324 * @iface: the interface from which it will be unbound
325 *
326 * This can be used by drivers to release an interface without waiting
327 * for their disconnect() methods to be called. In typical cases this
328 * also causes the driver disconnect() method to be called.
329 *
330 * This call is synchronous, and may not be used in an interrupt context.
331 * Callers must own the device lock and the driver model's usb_bus_type.subsys
332 * writelock. So driver disconnect() entries don't need extra locking,
333 * but other call contexts may need to explicitly claim those locks.
334 */
335void usb_driver_release_interface(struct usb_driver *driver,
336 struct usb_interface *iface)
337{
338 struct device *dev = &iface->dev;
339 struct usb_device *udev = interface_to_usbdev(iface);
340
341 /* this should never happen, don't release something that's not ours */
342 if (!dev->driver || dev->driver != &driver->drvwrap.driver)
343 return;
344
345 /* don't release from within disconnect() */
346 if (iface->condition != USB_INTERFACE_BOUND)
347 return;
348
349 /* don't release if the interface hasn't been added yet */
350 if (device_is_registered(dev)) {
351 iface->condition = USB_INTERFACE_UNBINDING;
352 device_release_driver(dev);
353 }
354
355 dev->driver = NULL;
356 usb_set_intfdata(iface, NULL);
357
358 mutex_lock_nested(&udev->pm_mutex, udev->level);
359 iface->condition = USB_INTERFACE_UNBOUND;
360 mark_quiesced(iface);
361 iface->needs_remote_wakeup = 0;
362 mutex_unlock(&udev->pm_mutex);
363}
364EXPORT_SYMBOL(usb_driver_release_interface);
365
241/* returns 0 if no match, 1 if match */ 366/* returns 0 if no match, 1 if match */
242static int usb_match_one_id(struct usb_interface *interface, 367static int usb_match_one_id(struct usb_interface *interface,
243 const struct usb_device_id *id) 368 const struct usb_device_id *id)
@@ -381,35 +506,223 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_match_id);
381 506
382int usb_device_match(struct device *dev, struct device_driver *drv) 507int usb_device_match(struct device *dev, struct device_driver *drv)
383{ 508{
509 /* devices and interfaces are handled separately */
510 if (is_usb_device(dev)) {
511
512 /* interface drivers never match devices */
513 if (!is_usb_device_driver(drv))
514 return 0;
515
516 /* TODO: Add real matching code */
517 return 1;
518
519 } else {
520 struct usb_interface *intf;
521 struct usb_driver *usb_drv;
522 const struct usb_device_id *id;
523
524 /* device drivers never match interfaces */
525 if (is_usb_device_driver(drv))
526 return 0;
527
528 intf = to_usb_interface(dev);
529 usb_drv = to_usb_driver(drv);
530
531 id = usb_match_id(intf, usb_drv->id_table);
532 if (id)
533 return 1;
534
535 id = usb_match_dynamic_id(intf, usb_drv);
536 if (id)
537 return 1;
538 }
539
540 return 0;
541}
542
543#ifdef CONFIG_HOTPLUG
544
545/*
546 * This sends an uevent to userspace, typically helping to load driver
547 * or other modules, configure the device, and more. Drivers can provide
548 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
549 *
550 * We're called either from khubd (the typical case) or from root hub
551 * (init, kapmd, modprobe, rmmod, etc), but the agents need to handle
552 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
553 * device (and this configuration!) are still present.
554 */
555static int usb_uevent(struct device *dev, char **envp, int num_envp,
556 char *buffer, int buffer_size)
557{
384 struct usb_interface *intf; 558 struct usb_interface *intf;
385 struct usb_driver *usb_drv; 559 struct usb_device *usb_dev;
386 const struct usb_device_id *id; 560 struct usb_host_interface *alt;
561 int i = 0;
562 int length = 0;
387 563
388 /* check for generic driver, which we don't match any device with */ 564 if (!dev)
389 if (drv == &usb_generic_driver) 565 return -ENODEV;
390 return 0;
391 566
392 intf = to_usb_interface(dev); 567 /* driver is often null here; dev_dbg() would oops */
393 usb_drv = to_usb_driver(drv); 568 pr_debug ("usb %s: uevent\n", dev->bus_id);
394 569
395 id = usb_match_id(intf, usb_drv->id_table); 570 if (is_usb_device(dev)) {
396 if (id) 571 usb_dev = to_usb_device(dev);
397 return 1; 572 alt = NULL;
573 } else {
574 intf = to_usb_interface(dev);
575 usb_dev = interface_to_usbdev(intf);
576 alt = intf->cur_altsetting;
577 }
578
579 if (usb_dev->devnum < 0) {
580 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
581 return -ENODEV;
582 }
583 if (!usb_dev->bus) {
584 pr_debug ("usb %s: bus removed?\n", dev->bus_id);
585 return -ENODEV;
586 }
587
588#ifdef CONFIG_USB_DEVICEFS
589 /* If this is available, userspace programs can directly read
590 * all the device descriptors we don't tell them about. Or
591 * even act as usermode drivers.
592 *
593 * FIXME reduce hardwired intelligence here
594 */
595 if (add_uevent_var(envp, num_envp, &i,
596 buffer, buffer_size, &length,
597 "DEVICE=/proc/bus/usb/%03d/%03d",
598 usb_dev->bus->busnum, usb_dev->devnum))
599 return -ENOMEM;
600#endif
601
602 /* per-device configurations are common */
603 if (add_uevent_var(envp, num_envp, &i,
604 buffer, buffer_size, &length,
605 "PRODUCT=%x/%x/%x",
606 le16_to_cpu(usb_dev->descriptor.idVendor),
607 le16_to_cpu(usb_dev->descriptor.idProduct),
608 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
609 return -ENOMEM;
610
611 /* class-based driver binding models */
612 if (add_uevent_var(envp, num_envp, &i,
613 buffer, buffer_size, &length,
614 "TYPE=%d/%d/%d",
615 usb_dev->descriptor.bDeviceClass,
616 usb_dev->descriptor.bDeviceSubClass,
617 usb_dev->descriptor.bDeviceProtocol))
618 return -ENOMEM;
619
620 if (!is_usb_device(dev)) {
621
622 if (add_uevent_var(envp, num_envp, &i,
623 buffer, buffer_size, &length,
624 "INTERFACE=%d/%d/%d",
625 alt->desc.bInterfaceClass,
626 alt->desc.bInterfaceSubClass,
627 alt->desc.bInterfaceProtocol))
628 return -ENOMEM;
629
630 if (add_uevent_var(envp, num_envp, &i,
631 buffer, buffer_size, &length,
632 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
633 le16_to_cpu(usb_dev->descriptor.idVendor),
634 le16_to_cpu(usb_dev->descriptor.idProduct),
635 le16_to_cpu(usb_dev->descriptor.bcdDevice),
636 usb_dev->descriptor.bDeviceClass,
637 usb_dev->descriptor.bDeviceSubClass,
638 usb_dev->descriptor.bDeviceProtocol,
639 alt->desc.bInterfaceClass,
640 alt->desc.bInterfaceSubClass,
641 alt->desc.bInterfaceProtocol))
642 return -ENOMEM;
643 }
644
645 envp[i] = NULL;
398 646
399 id = usb_match_dynamic_id(intf, usb_drv);
400 if (id)
401 return 1;
402 return 0; 647 return 0;
403} 648}
404 649
650#else
651
652static int usb_uevent(struct device *dev, char **envp,
653 int num_envp, char *buffer, int buffer_size)
654{
655 return -ENODEV;
656}
657
658#endif /* CONFIG_HOTPLUG */
659
660/**
661 * usb_register_device_driver - register a USB device (not interface) driver
662 * @new_udriver: USB operations for the device driver
663 * @owner: module owner of this driver.
664 *
665 * Registers a USB device driver with the USB core. The list of
666 * unattached devices will be rescanned whenever a new driver is
667 * added, allowing the new driver to attach to any recognized devices.
668 * Returns a negative error code on failure and 0 on success.
669 */
670int usb_register_device_driver(struct usb_device_driver *new_udriver,
671 struct module *owner)
672{
673 int retval = 0;
674
675 if (usb_disabled())
676 return -ENODEV;
677
678 new_udriver->drvwrap.for_devices = 1;
679 new_udriver->drvwrap.driver.name = (char *) new_udriver->name;
680 new_udriver->drvwrap.driver.bus = &usb_bus_type;
681 new_udriver->drvwrap.driver.probe = usb_probe_device;
682 new_udriver->drvwrap.driver.remove = usb_unbind_device;
683 new_udriver->drvwrap.driver.owner = owner;
684
685 retval = driver_register(&new_udriver->drvwrap.driver);
686
687 if (!retval) {
688 pr_info("%s: registered new device driver %s\n",
689 usbcore_name, new_udriver->name);
690 usbfs_update_special();
691 } else {
692 printk(KERN_ERR "%s: error %d registering device "
693 " driver %s\n",
694 usbcore_name, retval, new_udriver->name);
695 }
696
697 return retval;
698}
699EXPORT_SYMBOL_GPL(usb_register_device_driver);
700
701/**
702 * usb_deregister_device_driver - unregister a USB device (not interface) driver
703 * @udriver: USB operations of the device driver to unregister
704 * Context: must be able to sleep
705 *
706 * Unlinks the specified driver from the internal USB driver list.
707 */
708void usb_deregister_device_driver(struct usb_device_driver *udriver)
709{
710 pr_info("%s: deregistering device driver %s\n",
711 usbcore_name, udriver->name);
712
713 driver_unregister(&udriver->drvwrap.driver);
714 usbfs_update_special();
715}
716EXPORT_SYMBOL_GPL(usb_deregister_device_driver);
717
405/** 718/**
406 * usb_register_driver - register a USB driver 719 * usb_register_driver - register a USB interface driver
407 * @new_driver: USB operations for the driver 720 * @new_driver: USB operations for the interface driver
408 * @owner: module owner of this driver. 721 * @owner: module owner of this driver.
409 * 722 *
410 * Registers a USB driver with the USB core. The list of unattached 723 * Registers a USB interface driver with the USB core. The list of
411 * interfaces will be rescanned whenever a new driver is added, allowing 724 * unattached interfaces will be rescanned whenever a new driver is
412 * the new driver to attach to any recognized devices. 725 * added, allowing the new driver to attach to any recognized interfaces.
413 * Returns a negative error code on failure and 0 on success. 726 * Returns a negative error code on failure and 0 on success.
414 * 727 *
415 * NOTE: if you want your driver to use the USB major number, you must call 728 * NOTE: if you want your driver to use the USB major number, you must call
@@ -423,23 +736,25 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
423 if (usb_disabled()) 736 if (usb_disabled())
424 return -ENODEV; 737 return -ENODEV;
425 738
426 new_driver->driver.name = (char *)new_driver->name; 739 new_driver->drvwrap.for_devices = 0;
427 new_driver->driver.bus = &usb_bus_type; 740 new_driver->drvwrap.driver.name = (char *) new_driver->name;
428 new_driver->driver.probe = usb_probe_interface; 741 new_driver->drvwrap.driver.bus = &usb_bus_type;
429 new_driver->driver.remove = usb_unbind_interface; 742 new_driver->drvwrap.driver.probe = usb_probe_interface;
430 new_driver->driver.owner = owner; 743 new_driver->drvwrap.driver.remove = usb_unbind_interface;
744 new_driver->drvwrap.driver.owner = owner;
431 spin_lock_init(&new_driver->dynids.lock); 745 spin_lock_init(&new_driver->dynids.lock);
432 INIT_LIST_HEAD(&new_driver->dynids.list); 746 INIT_LIST_HEAD(&new_driver->dynids.list);
433 747
434 retval = driver_register(&new_driver->driver); 748 retval = driver_register(&new_driver->drvwrap.driver);
435 749
436 if (!retval) { 750 if (!retval) {
437 pr_info("%s: registered new driver %s\n", 751 pr_info("%s: registered new interface driver %s\n",
438 usbcore_name, new_driver->name); 752 usbcore_name, new_driver->name);
439 usbfs_update_special(); 753 usbfs_update_special();
440 usb_create_newid_file(new_driver); 754 usb_create_newid_file(new_driver);
441 } else { 755 } else {
442 printk(KERN_ERR "%s: error %d registering driver %s\n", 756 printk(KERN_ERR "%s: error %d registering interface "
757 " driver %s\n",
443 usbcore_name, retval, new_driver->name); 758 usbcore_name, retval, new_driver->name);
444 } 759 }
445 760
@@ -448,8 +763,8 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
448EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver); 763EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver);
449 764
450/** 765/**
451 * usb_deregister - unregister a USB driver 766 * usb_deregister - unregister a USB interface driver
452 * @driver: USB operations of the driver to unregister 767 * @driver: USB operations of the interface driver to unregister
453 * Context: must be able to sleep 768 * Context: must be able to sleep
454 * 769 *
455 * Unlinks the specified driver from the internal USB driver list. 770 * Unlinks the specified driver from the internal USB driver list.
@@ -460,12 +775,554 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_register_driver);
460 */ 775 */
461void usb_deregister(struct usb_driver *driver) 776void usb_deregister(struct usb_driver *driver)
462{ 777{
463 pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name); 778 pr_info("%s: deregistering interface driver %s\n",
779 usbcore_name, driver->name);
464 780
465 usb_remove_newid_file(driver); 781 usb_remove_newid_file(driver);
466 usb_free_dynids(driver); 782 usb_free_dynids(driver);
467 driver_unregister(&driver->driver); 783 driver_unregister(&driver->drvwrap.driver);
468 784
469 usbfs_update_special(); 785 usbfs_update_special();
470} 786}
471EXPORT_SYMBOL_GPL_FUTURE(usb_deregister); 787EXPORT_SYMBOL_GPL_FUTURE(usb_deregister);
788
789#ifdef CONFIG_PM
790
791/* Caller has locked udev->pm_mutex */
792static int suspend_device(struct usb_device *udev, pm_message_t msg)
793{
794 struct usb_device_driver *udriver;
795 int status = 0;
796
797 if (udev->state == USB_STATE_NOTATTACHED ||
798 udev->state == USB_STATE_SUSPENDED)
799 goto done;
800
801 /* For devices that don't have a driver, we do a standard suspend. */
802 if (udev->dev.driver == NULL) {
803 udev->do_remote_wakeup = 0;
804 status = usb_port_suspend(udev);
805 goto done;
806 }
807
808 udriver = to_usb_device_driver(udev->dev.driver);
809 status = udriver->suspend(udev, msg);
810
811done:
812 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
813 if (status == 0)
814 udev->dev.power.power_state.event = msg.event;
815 return status;
816}
817
818/* Caller has locked udev->pm_mutex */
819static int resume_device(struct usb_device *udev)
820{
821 struct usb_device_driver *udriver;
822 int status = 0;
823
824 if (udev->state == USB_STATE_NOTATTACHED ||
825 udev->state != USB_STATE_SUSPENDED)
826 goto done;
827
828 /* Can't resume it if it doesn't have a driver. */
829 if (udev->dev.driver == NULL) {
830 status = -ENOTCONN;
831 goto done;
832 }
833
834 udriver = to_usb_device_driver(udev->dev.driver);
835 status = udriver->resume(udev);
836
837done:
838 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
839 if (status == 0)
840 udev->dev.power.power_state.event = PM_EVENT_ON;
841 return status;
842}
843
844/* Caller has locked intf's usb_device's pm_mutex */
845static int suspend_interface(struct usb_interface *intf, pm_message_t msg)
846{
847 struct usb_driver *driver;
848 int status = 0;
849
850 /* with no hardware, USB interfaces only use FREEZE and ON states */
851 if (interface_to_usbdev(intf)->state == USB_STATE_NOTATTACHED ||
852 !is_active(intf))
853 goto done;
854
855 if (intf->condition == USB_INTERFACE_UNBOUND) /* This can't happen */
856 goto done;
857 driver = to_usb_driver(intf->dev.driver);
858
859 if (driver->suspend && driver->resume) {
860 status = driver->suspend(intf, msg);
861 if (status == 0)
862 mark_quiesced(intf);
863 else if (!interface_to_usbdev(intf)->auto_pm)
864 dev_err(&intf->dev, "%s error %d\n",
865 "suspend", status);
866 } else {
867 // FIXME else if there's no suspend method, disconnect...
868 // Not possible if auto_pm is set...
869 dev_warn(&intf->dev, "no suspend for driver %s?\n",
870 driver->name);
871 mark_quiesced(intf);
872 }
873
874done:
875 // dev_dbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status);
876 if (status == 0)
877 intf->dev.power.power_state.event = msg.event;
878 return status;
879}
880
881/* Caller has locked intf's usb_device's pm_mutex */
882static int resume_interface(struct usb_interface *intf)
883{
884 struct usb_driver *driver;
885 int status = 0;
886
887 if (interface_to_usbdev(intf)->state == USB_STATE_NOTATTACHED ||
888 is_active(intf))
889 goto done;
890
891 /* Don't let autoresume interfere with unbinding */
892 if (intf->condition == USB_INTERFACE_UNBINDING)
893 goto done;
894
895 /* Can't resume it if it doesn't have a driver. */
896 if (intf->condition == USB_INTERFACE_UNBOUND) {
897 status = -ENOTCONN;
898 goto done;
899 }
900 driver = to_usb_driver(intf->dev.driver);
901
902 if (driver->resume) {
903 status = driver->resume(intf);
904 if (status)
905 dev_err(&intf->dev, "%s error %d\n",
906 "resume", status);
907 else
908 mark_active(intf);
909 } else {
910 dev_warn(&intf->dev, "no resume for driver %s?\n",
911 driver->name);
912 mark_active(intf);
913 }
914
915done:
916 // dev_dbg(&intf->dev, "%s: status %d\n", __FUNCTION__, status);
917 if (status == 0)
918 intf->dev.power.power_state.event = PM_EVENT_ON;
919 return status;
920}
921
922/**
923 * usb_suspend_both - suspend a USB device and its interfaces
924 * @udev: the usb_device to suspend
925 * @msg: Power Management message describing this state transition
926 *
927 * This is the central routine for suspending USB devices. It calls the
928 * suspend methods for all the interface drivers in @udev and then calls
929 * the suspend method for @udev itself. If an error occurs at any stage,
930 * all the interfaces which were suspended are resumed so that they remain
931 * in the same state as the device.
932 *
933 * If an autosuspend is in progress (@udev->auto_pm is set), the routine
934 * checks first to make sure that neither the device itself or any of its
935 * active interfaces is in use (pm_usage_cnt is greater than 0). If they
936 * are, the autosuspend fails.
937 *
938 * If the suspend succeeds, the routine recursively queues an autosuspend
939 * request for @udev's parent device, thereby propagating the change up
940 * the device tree. If all of the parent's children are now suspended,
941 * the parent will autosuspend in turn.
942 *
943 * The suspend method calls are subject to mutual exclusion under control
944 * of @udev's pm_mutex. Many of these calls are also under the protection
945 * of @udev's device lock (including all requests originating outside the
946 * USB subsystem), but autosuspend requests generated by a child device or
947 * interface driver may not be. Usbcore will insure that the method calls
948 * do not arrive during bind, unbind, or reset operations. However, drivers
949 * must be prepared to handle suspend calls arriving at unpredictable times.
950 * The only way to block such calls is to do an autoresume (preventing
951 * autosuspends) while holding @udev's device lock (preventing outside
952 * suspends).
953 *
954 * The caller must hold @udev->pm_mutex.
955 *
956 * This routine can run only in process context.
957 */
958int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
959{
960 int status = 0;
961 int i = 0;
962 struct usb_interface *intf;
963 struct usb_device *parent = udev->parent;
964
965 cancel_delayed_work(&udev->autosuspend);
966 if (udev->state == USB_STATE_NOTATTACHED)
967 return 0;
968 if (udev->state == USB_STATE_SUSPENDED)
969 return 0;
970
971 udev->do_remote_wakeup = device_may_wakeup(&udev->dev);
972
973 /* For autosuspend, fail fast if anything is in use.
974 * Also fail if any interfaces require remote wakeup but it
975 * isn't available. */
976 if (udev->auto_pm) {
977 if (udev->pm_usage_cnt > 0)
978 return -EBUSY;
979 if (udev->actconfig) {
980 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
981 intf = udev->actconfig->interface[i];
982 if (!is_active(intf))
983 continue;
984 if (intf->pm_usage_cnt > 0)
985 return -EBUSY;
986 if (intf->needs_remote_wakeup &&
987 !udev->do_remote_wakeup) {
988 dev_dbg(&udev->dev,
989 "remote wakeup needed for autosuspend\n");
990 return -EOPNOTSUPP;
991 }
992 }
993 i = 0;
994 }
995 }
996
997 /* Suspend all the interfaces and then udev itself */
998 if (udev->actconfig) {
999 for (; i < udev->actconfig->desc.bNumInterfaces; i++) {
1000 intf = udev->actconfig->interface[i];
1001 status = suspend_interface(intf, msg);
1002 if (status != 0)
1003 break;
1004 }
1005 }
1006 if (status == 0)
1007 status = suspend_device(udev, msg);
1008
1009 /* If the suspend failed, resume interfaces that did get suspended */
1010 if (status != 0) {
1011 while (--i >= 0) {
1012 intf = udev->actconfig->interface[i];
1013 resume_interface(intf);
1014 }
1015
1016 /* If the suspend succeeded, propagate it up the tree */
1017 } else if (parent)
1018 usb_autosuspend_device(parent, 0);
1019
1020 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
1021 return status;
1022}
1023
1024/**
1025 * usb_resume_both - resume a USB device and its interfaces
1026 * @udev: the usb_device to resume
1027 *
1028 * This is the central routine for resuming USB devices. It calls the
1029 * the resume method for @udev and then calls the resume methods for all
1030 * the interface drivers in @udev.
1031 *
1032 * Before starting the resume, the routine calls itself recursively for
1033 * the parent device of @udev, thereby propagating the change up the device
1034 * tree and assuring that @udev will be able to resume. If the parent is
1035 * unable to resume successfully, the routine fails.
1036 *
1037 * The resume method calls are subject to mutual exclusion under control
1038 * of @udev's pm_mutex. Many of these calls are also under the protection
1039 * of @udev's device lock (including all requests originating outside the
1040 * USB subsystem), but autoresume requests generated by a child device or
1041 * interface driver may not be. Usbcore will insure that the method calls
1042 * do not arrive during bind, unbind, or reset operations. However, drivers
1043 * must be prepared to handle resume calls arriving at unpredictable times.
1044 * The only way to block such calls is to do an autoresume (preventing
1045 * other autoresumes) while holding @udev's device lock (preventing outside
1046 * resumes).
1047 *
1048 * The caller must hold @udev->pm_mutex.
1049 *
1050 * This routine can run only in process context.
1051 */
1052int usb_resume_both(struct usb_device *udev)
1053{
1054 int status = 0;
1055 int i;
1056 struct usb_interface *intf;
1057 struct usb_device *parent = udev->parent;
1058
1059 cancel_delayed_work(&udev->autosuspend);
1060 if (udev->state == USB_STATE_NOTATTACHED)
1061 return -ENODEV;
1062
1063 /* Propagate the resume up the tree, if necessary */
1064 if (udev->state == USB_STATE_SUSPENDED) {
1065 if (parent) {
1066 mutex_lock_nested(&parent->pm_mutex, parent->level);
1067 parent->auto_pm = 1;
1068 status = usb_resume_both(parent);
1069 } else {
1070
1071 /* We can't progagate beyond the USB subsystem,
1072 * so if a root hub's controller is suspended
1073 * then we're stuck. */
1074 if (udev->dev.parent->power.power_state.event !=
1075 PM_EVENT_ON)
1076 status = -EHOSTUNREACH;
1077 }
1078 if (status == 0)
1079 status = resume_device(udev);
1080 if (parent)
1081 mutex_unlock(&parent->pm_mutex);
1082 } else {
1083
1084 /* Needed only for setting udev->dev.power.power_state.event
1085 * and for possible debugging message. */
1086 status = resume_device(udev);
1087 }
1088
1089 /* Now the parent won't suspend until we are finished */
1090
1091 if (status == 0 && udev->actconfig) {
1092 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1093 intf = udev->actconfig->interface[i];
1094 resume_interface(intf);
1095 }
1096 }
1097
1098 // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status);
1099 return status;
1100}
1101
1102#ifdef CONFIG_USB_SUSPEND
1103
1104/**
1105 * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces
1106 * @udev - the usb_device to autosuspend
1107 * @dec_usage_cnt - flag to decrement @udev's PM-usage counter
1108 *
1109 * This routine should be called when a core subsystem is finished using
1110 * @udev and wants to allow it to autosuspend. Examples would be when
1111 * @udev's device file in usbfs is closed or after a configuration change.
1112 *
1113 * @dec_usage_cnt should be 1 if the subsystem previously incremented
1114 * @udev's usage counter (such as by passing 1 to usb_autoresume_device);
1115 * otherwise it should be 0.
1116 *
1117 * If the usage counter for @udev or any of its active interfaces is greater
1118 * than 0, the autosuspend request will not be queued. (If an interface
1119 * driver does not support autosuspend then its usage counter is permanently
1120 * positive.) Likewise, if an interface driver requires remote-wakeup
1121 * capability during autosuspend but remote wakeup is disabled, the
1122 * autosuspend will fail.
1123 *
1124 * Often the caller will hold @udev's device lock, but this is not
1125 * necessary.
1126 *
1127 * This routine can run only in process context.
1128 */
1129void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt)
1130{
1131 mutex_lock_nested(&udev->pm_mutex, udev->level);
1132 udev->pm_usage_cnt -= dec_usage_cnt;
1133 if (udev->pm_usage_cnt <= 0)
1134 schedule_delayed_work(&udev->autosuspend,
1135 USB_AUTOSUSPEND_DELAY);
1136 mutex_unlock(&udev->pm_mutex);
1137 // dev_dbg(&udev->dev, "%s: cnt %d\n",
1138 // __FUNCTION__, udev->pm_usage_cnt);
1139}
1140
1141/**
1142 * usb_autoresume_device - immediately autoresume a USB device and its interfaces
1143 * @udev - the usb_device to autoresume
1144 * @inc_usage_cnt - flag to increment @udev's PM-usage counter
1145 *
1146 * This routine should be called when a core subsystem wants to use @udev
1147 * and needs to guarantee that it is not suspended. In addition, the
1148 * caller can prevent @udev from being autosuspended subsequently. (Note
1149 * that this will not prevent suspend events originating in the PM core.)
1150 * Examples would be when @udev's device file in usbfs is opened (autosuspend
1151 * should be prevented until the file is closed) or when a remote-wakeup
1152 * request is received (later autosuspends should not be prevented).
1153 *
1154 * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent
1155 * autosuspends. This prevention will persist until the usage counter is
1156 * decremented again (such as by passing 1 to usb_autosuspend_device).
1157 * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged.
1158 * Regardless, if the autoresume fails then the usage counter is not
1159 * incremented.
1160 *
1161 * Often the caller will hold @udev's device lock, but this is not
1162 * necessary (and attempting it might cause deadlock).
1163 *
1164 * This routine can run only in process context.
1165 */
1166int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt)
1167{
1168 int status;
1169
1170 mutex_lock_nested(&udev->pm_mutex, udev->level);
1171 udev->pm_usage_cnt += inc_usage_cnt;
1172 udev->auto_pm = 1;
1173 status = usb_resume_both(udev);
1174 if (status != 0)
1175 udev->pm_usage_cnt -= inc_usage_cnt;
1176 mutex_unlock(&udev->pm_mutex);
1177 // dev_dbg(&udev->dev, "%s: status %d cnt %d\n",
1178 // __FUNCTION__, status, udev->pm_usage_cnt);
1179 return status;
1180}
1181
1182/**
1183 * usb_autopm_put_interface - decrement a USB interface's PM-usage counter
1184 * @intf - the usb_interface whose counter should be decremented
1185 *
1186 * This routine should be called by an interface driver when it is
1187 * finished using @intf and wants to allow it to autosuspend. A typical
1188 * example would be a character-device driver when its device file is
1189 * closed.
1190 *
1191 * The routine decrements @intf's usage counter. When the counter reaches
1192 * 0, a delayed autosuspend request for @intf's device is queued. When
1193 * the delay expires, if @intf->pm_usage_cnt is still <= 0 along with all
1194 * the other usage counters for the sibling interfaces and @intf's
1195 * usb_device, the device and all its interfaces will be autosuspended.
1196 *
1197 * Note that @intf->pm_usage_cnt is owned by the interface driver. The
1198 * core will not change its value other than the increment and decrement
1199 * in usb_autopm_get_interface and usb_autopm_put_interface. The driver
1200 * may use this simple counter-oriented discipline or may set the value
1201 * any way it likes.
1202 *
1203 * If the driver has set @intf->needs_remote_wakeup then autosuspend will
1204 * take place only if the device's remote-wakeup facility is enabled.
1205 *
1206 * Suspend method calls queued by this routine can arrive at any time
1207 * while @intf is resumed and its usage counter is equal to 0. They are
1208 * not protected by the usb_device's lock but only by its pm_mutex.
1209 * Drivers must provide their own synchronization.
1210 *
1211 * This routine can run only in process context.
1212 */
1213void usb_autopm_put_interface(struct usb_interface *intf)
1214{
1215 struct usb_device *udev = interface_to_usbdev(intf);
1216
1217 mutex_lock_nested(&udev->pm_mutex, udev->level);
1218 if (intf->condition != USB_INTERFACE_UNBOUND) {
1219 if (--intf->pm_usage_cnt <= 0)
1220 schedule_delayed_work(&udev->autosuspend,
1221 USB_AUTOSUSPEND_DELAY);
1222 }
1223 mutex_unlock(&udev->pm_mutex);
1224 // dev_dbg(&intf->dev, "%s: cnt %d\n",
1225 // __FUNCTION__, intf->pm_usage_cnt);
1226}
1227EXPORT_SYMBOL_GPL(usb_autopm_put_interface);
1228
1229/**
1230 * usb_autopm_get_interface - increment a USB interface's PM-usage counter
1231 * @intf - the usb_interface whose counter should be incremented
1232 *
1233 * This routine should be called by an interface driver when it wants to
1234 * use @intf and needs to guarantee that it is not suspended. In addition,
1235 * the routine prevents @intf from being autosuspended subsequently. (Note
1236 * that this will not prevent suspend events originating in the PM core.)
1237 * This prevention will persist until usb_autopm_put_interface() is called
1238 * or @intf is unbound. A typical example would be a character-device
1239 * driver when its device file is opened.
1240 *
1241 * The routine increments @intf's usage counter. So long as the counter
1242 * is greater than 0, autosuspend will not be allowed for @intf or its
1243 * usb_device. When the driver is finished using @intf it should call
1244 * usb_autopm_put_interface() to decrement the usage counter and queue
1245 * a delayed autosuspend request (if the counter is <= 0).
1246 *
1247 * Note that @intf->pm_usage_cnt is owned by the interface driver. The
1248 * core will not change its value other than the increment and decrement
1249 * in usb_autopm_get_interface and usb_autopm_put_interface. The driver
1250 * may use this simple counter-oriented discipline or may set the value
1251 * any way it likes.
1252 *
1253 * Resume method calls generated by this routine can arrive at any time
1254 * while @intf is suspended. They are not protected by the usb_device's
1255 * lock but only by its pm_mutex. Drivers must provide their own
1256 * synchronization.
1257 *
1258 * This routine can run only in process context.
1259 */
1260int usb_autopm_get_interface(struct usb_interface *intf)
1261{
1262 struct usb_device *udev = interface_to_usbdev(intf);
1263 int status;
1264
1265 mutex_lock_nested(&udev->pm_mutex, udev->level);
1266 if (intf->condition == USB_INTERFACE_UNBOUND)
1267 status = -ENODEV;
1268 else {
1269 ++intf->pm_usage_cnt;
1270 udev->auto_pm = 1;
1271 status = usb_resume_both(udev);
1272 if (status != 0)
1273 --intf->pm_usage_cnt;
1274 }
1275 mutex_unlock(&udev->pm_mutex);
1276 // dev_dbg(&intf->dev, "%s: status %d cnt %d\n",
1277 // __FUNCTION__, status, intf->pm_usage_cnt);
1278 return status;
1279}
1280EXPORT_SYMBOL_GPL(usb_autopm_get_interface);
1281
1282#endif /* CONFIG_USB_SUSPEND */
1283
1284static int usb_suspend(struct device *dev, pm_message_t message)
1285{
1286 int status;
1287
1288 if (is_usb_device(dev)) {
1289 struct usb_device *udev = to_usb_device(dev);
1290
1291 mutex_lock_nested(&udev->pm_mutex, udev->level);
1292 udev->auto_pm = 0;
1293 status = usb_suspend_both(udev, message);
1294 mutex_unlock(&udev->pm_mutex);
1295 } else
1296 status = 0;
1297 return status;
1298}
1299
1300static int usb_resume(struct device *dev)
1301{
1302 int status;
1303
1304 if (is_usb_device(dev)) {
1305 struct usb_device *udev = to_usb_device(dev);
1306
1307 mutex_lock_nested(&udev->pm_mutex, udev->level);
1308 udev->auto_pm = 0;
1309 status = usb_resume_both(udev);
1310 mutex_unlock(&udev->pm_mutex);
1311
1312 /* Rebind drivers that had no suspend method? */
1313 } else
1314 status = 0;
1315 return status;
1316}
1317
1318#endif /* CONFIG_PM */
1319
1320struct bus_type usb_bus_type = {
1321 .name = "usb",
1322 .match = usb_device_match,
1323 .uevent = usb_uevent,
1324#ifdef CONFIG_PM
1325 .suspend = usb_suspend,
1326 .resume = usb_resume,
1327#endif
1328};
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c
index 247b5a4913a8..3ebb90149e93 100644
--- a/drivers/usb/core/endpoint.c
+++ b/drivers/usb/core/endpoint.c
@@ -207,9 +207,9 @@ static void ep_device_release(struct device *dev)
207 kfree(ep_dev); 207 kfree(ep_dev);
208} 208}
209 209
210void usb_create_ep_files(struct device *parent, 210int usb_create_ep_files(struct device *parent,
211 struct usb_host_endpoint *endpoint, 211 struct usb_host_endpoint *endpoint,
212 struct usb_device *udev) 212 struct usb_device *udev)
213{ 213{
214 char name[8]; 214 char name[8];
215 struct ep_device *ep_dev; 215 struct ep_device *ep_dev;
@@ -242,19 +242,33 @@ void usb_create_ep_files(struct device *parent,
242 retval = device_register(&ep_dev->dev); 242 retval = device_register(&ep_dev->dev);
243 if (retval) 243 if (retval)
244 goto error; 244 goto error;
245 sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); 245 retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
246 if (retval)
247 goto error_group;
246 248
247 endpoint->ep_dev = ep_dev; 249 endpoint->ep_dev = ep_dev;
248 250
249 /* create the symlink to the old-style "ep_XX" directory */ 251 /* create the symlink to the old-style "ep_XX" directory */
250 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); 252 sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress);
251 sysfs_create_link(&parent->kobj, &endpoint->ep_dev->dev.kobj, name); 253 retval = sysfs_create_link(&parent->kobj,
252 254 &endpoint->ep_dev->dev.kobj, name);
255 if (retval)
256 goto error_link;
253exit: 257exit:
254 return; 258 return retval;
259
260error_link:
261 sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp);
262
263error_group:
264 device_unregister(&ep_dev->dev);
265 endpoint->ep_dev = NULL;
266 destroy_endpoint_class();
267 return retval;
255error: 268error:
256 kfree(ep_dev); 269 kfree(ep_dev);
257 return; 270 destroy_endpoint_class();
271 return retval;
258} 272}
259 273
260void usb_remove_ep_files(struct usb_host_endpoint *endpoint) 274void usb_remove_ep_files(struct usb_host_endpoint *endpoint)
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index 8de4f8c99d61..c376c655c5de 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -55,7 +55,7 @@ static int usb_open(struct inode * inode, struct file * file)
55 return err; 55 return err;
56} 56}
57 57
58static struct file_operations usb_fops = { 58static const struct file_operations usb_fops = {
59 .owner = THIS_MODULE, 59 .owner = THIS_MODULE,
60 .open = usb_open, 60 .open = usb_open,
61}; 61};
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c
new file mode 100644
index 000000000000..16332cc57946
--- /dev/null
+++ b/drivers/usb/core/generic.c
@@ -0,0 +1,208 @@
1/*
2 * drivers/usb/generic.c - generic driver for USB devices (not interfaces)
3 *
4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * based on drivers/usb/usb.c which had the following copyrights:
7 * (C) Copyright Linus Torvalds 1999
8 * (C) Copyright Johannes Erdfelt 1999-2001
9 * (C) Copyright Andreas Gal 1999
10 * (C) Copyright Gregory P. Smith 1999
11 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
12 * (C) Copyright Randy Dunlap 2000
13 * (C) Copyright David Brownell 2000-2004
14 * (C) Copyright Yggdrasil Computing, Inc. 2000
15 * (usb_device_id matching changes by Adam J. Richter)
16 * (C) Copyright Greg Kroah-Hartman 2002-2003
17 *
18 */
19
20#include <linux/config.h>
21#include <linux/usb.h>
22#include "usb.h"
23
24static inline const char *plural(int n)
25{
26 return (n == 1 ? "" : "s");
27}
28
29static int choose_configuration(struct usb_device *udev)
30{
31 int i;
32 int num_configs;
33 int insufficient_power = 0;
34 struct usb_host_config *c, *best;
35
36 best = NULL;
37 c = udev->config;
38 num_configs = udev->descriptor.bNumConfigurations;
39 for (i = 0; i < num_configs; (i++, c++)) {
40 struct usb_interface_descriptor *desc = NULL;
41
42 /* It's possible that a config has no interfaces! */
43 if (c->desc.bNumInterfaces > 0)
44 desc = &c->intf_cache[0]->altsetting->desc;
45
46 /*
47 * HP's USB bus-powered keyboard has only one configuration
48 * and it claims to be self-powered; other devices may have
49 * similar errors in their descriptors. If the next test
50 * were allowed to execute, such configurations would always
51 * be rejected and the devices would not work as expected.
52 * In the meantime, we run the risk of selecting a config
53 * that requires external power at a time when that power
54 * isn't available. It seems to be the lesser of two evils.
55 *
56 * Bugzilla #6448 reports a device that appears to crash
57 * when it receives a GET_DEVICE_STATUS request! We don't
58 * have any other way to tell whether a device is self-powered,
59 * but since we don't use that information anywhere but here,
60 * the call has been removed.
61 *
62 * Maybe the GET_DEVICE_STATUS call and the test below can
63 * be reinstated when device firmwares become more reliable.
64 * Don't hold your breath.
65 */
66#if 0
67 /* Rule out self-powered configs for a bus-powered device */
68 if (bus_powered && (c->desc.bmAttributes &
69 USB_CONFIG_ATT_SELFPOWER))
70 continue;
71#endif
72
73 /*
74 * The next test may not be as effective as it should be.
75 * Some hubs have errors in their descriptor, claiming
76 * to be self-powered when they are really bus-powered.
77 * We will overestimate the amount of current such hubs
78 * make available for each port.
79 *
80 * This is a fairly benign sort of failure. It won't
81 * cause us to reject configurations that we should have
82 * accepted.
83 */
84
85 /* Rule out configs that draw too much bus current */
86 if (c->desc.bMaxPower * 2 > udev->bus_mA) {
87 insufficient_power++;
88 continue;
89 }
90
91 /* If the first config's first interface is COMM/2/0xff
92 * (MSFT RNDIS), rule it out unless Linux has host-side
93 * RNDIS support. */
94 if (i == 0 && desc
95 && desc->bInterfaceClass == USB_CLASS_COMM
96 && desc->bInterfaceSubClass == 2
97 && desc->bInterfaceProtocol == 0xff) {
98#ifndef CONFIG_USB_NET_RNDIS_HOST
99 continue;
100#else
101 best = c;
102#endif
103 }
104
105 /* From the remaining configs, choose the first one whose
106 * first interface is for a non-vendor-specific class.
107 * Reason: Linux is more likely to have a class driver
108 * than a vendor-specific driver. */
109 else if (udev->descriptor.bDeviceClass !=
110 USB_CLASS_VENDOR_SPEC &&
111 (!desc || desc->bInterfaceClass !=
112 USB_CLASS_VENDOR_SPEC)) {
113 best = c;
114 break;
115 }
116
117 /* If all the remaining configs are vendor-specific,
118 * choose the first one. */
119 else if (!best)
120 best = c;
121 }
122
123 if (insufficient_power > 0)
124 dev_info(&udev->dev, "rejected %d configuration%s "
125 "due to insufficient available bus power\n",
126 insufficient_power, plural(insufficient_power));
127
128 if (best) {
129 i = best->desc.bConfigurationValue;
130 dev_info(&udev->dev,
131 "configuration #%d chosen from %d choice%s\n",
132 i, num_configs, plural(num_configs));
133 } else {
134 i = -1;
135 dev_warn(&udev->dev,
136 "no configuration chosen from %d choice%s\n",
137 num_configs, plural(num_configs));
138 }
139 return i;
140}
141
142static int generic_probe(struct usb_device *udev)
143{
144 int err, c;
145
146 /* put device-specific files into sysfs */
147 usb_create_sysfs_dev_files(udev);
148
149 /* Choose and set the configuration. This registers the interfaces
150 * with the driver core and lets interface drivers bind to them.
151 */
152 c = choose_configuration(udev);
153 if (c >= 0) {
154 err = usb_set_configuration(udev, c);
155 if (err) {
156 dev_err(&udev->dev, "can't set config #%d, error %d\n",
157 c, err);
158 /* This need not be fatal. The user can try to
159 * set other configurations. */
160 }
161 }
162
163 /* USB device state == configured ... usable */
164 usb_notify_add_device(udev);
165
166 return 0;
167}
168
169static void generic_disconnect(struct usb_device *udev)
170{
171 usb_notify_remove_device(udev);
172
173 /* if this is only an unbind, not a physical disconnect, then
174 * unconfigure the device */
175 if (udev->actconfig)
176 usb_set_configuration(udev, 0);
177
178 usb_remove_sysfs_dev_files(udev);
179}
180
181#ifdef CONFIG_PM
182
183static int generic_suspend(struct usb_device *udev, pm_message_t msg)
184{
185 /* USB devices enter SUSPEND state through their hubs, but can be
186 * marked for FREEZE as soon as their children are already idled.
187 * But those semantics are useless, so we equate the two (sigh).
188 */
189 return usb_port_suspend(udev);
190}
191
192static int generic_resume(struct usb_device *udev)
193{
194 return usb_port_resume(udev);
195}
196
197#endif /* CONFIG_PM */
198
199struct usb_device_driver usb_generic_driver = {
200 .name = "usb",
201 .probe = generic_probe,
202 .disconnect = generic_disconnect,
203#ifdef CONFIG_PM
204 .suspend = generic_suspend,
205 .resume = generic_resume,
206#endif
207 .supports_autosuspend = 1,
208};
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 5078fb3375e3..edf4300a3f7a 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -281,7 +281,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
281 (void) usb_hcd_pci_resume (dev); 281 (void) usb_hcd_pci_resume (dev);
282 } 282 }
283 283
284 } else { 284 } else if (hcd->state != HC_STATE_HALT) {
285 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n", 285 dev_dbg (hcd->self.controller, "hcd state %d; not suspended\n",
286 hcd->state); 286 hcd->state);
287 WARN_ON(1); 287 WARN_ON(1);
@@ -413,4 +413,20 @@ EXPORT_SYMBOL (usb_hcd_pci_resume);
413 413
414#endif /* CONFIG_PM */ 414#endif /* CONFIG_PM */
415 415
416/**
417 * usb_hcd_pci_shutdown - shutdown host controller
418 * @dev: USB Host Controller being shutdown
419 */
420void usb_hcd_pci_shutdown (struct pci_dev *dev)
421{
422 struct usb_hcd *hcd;
423
424 hcd = pci_get_drvdata(dev);
425 if (!hcd)
426 return;
427
428 if (hcd->driver->shutdown)
429 hcd->driver->shutdown(hcd);
430}
431EXPORT_SYMBOL (usb_hcd_pci_shutdown);
416 432
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index fb4d058bbde0..e86f62957085 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -36,6 +36,7 @@
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <asm/irq.h> 37#include <asm/irq.h>
38#include <asm/byteorder.h> 38#include <asm/byteorder.h>
39#include <linux/platform_device.h>
39 40
40#include <linux/usb.h> 41#include <linux/usb.h>
41 42
@@ -632,31 +633,20 @@ static int rh_urb_enqueue (struct usb_hcd *hcd, struct urb *urb)
632 633
633/*-------------------------------------------------------------------------*/ 634/*-------------------------------------------------------------------------*/
634 635
635/* Asynchronous unlinks of root-hub control URBs are legal, but they 636/* Unlinks of root-hub control URBs are legal, but they don't do anything
636 * don't do anything. Status URB unlinks must be made in process context 637 * since these URBs always execute synchronously.
637 * with interrupts enabled.
638 */ 638 */
639static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb) 639static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
640{ 640{
641 if (usb_pipeendpoint(urb->pipe) == 0) { /* Control URB */ 641 unsigned long flags;
642 if (in_interrupt())
643 return 0; /* nothing to do */
644
645 spin_lock_irq(&urb->lock); /* from usb_kill_urb */
646 ++urb->reject;
647 spin_unlock_irq(&urb->lock);
648
649 wait_event(usb_kill_urb_queue,
650 atomic_read(&urb->use_count) == 0);
651 642
652 spin_lock_irq(&urb->lock); 643 if (usb_pipeendpoint(urb->pipe) == 0) { /* Control URB */
653 --urb->reject; 644 ; /* Do nothing */
654 spin_unlock_irq(&urb->lock);
655 645
656 } else { /* Status URB */ 646 } else { /* Status URB */
657 if (!hcd->uses_new_polling) 647 if (!hcd->uses_new_polling)
658 del_timer_sync (&hcd->rh_timer); 648 del_timer (&hcd->rh_timer);
659 local_irq_disable (); 649 local_irq_save (flags);
660 spin_lock (&hcd_root_hub_lock); 650 spin_lock (&hcd_root_hub_lock);
661 if (urb == hcd->status_urb) { 651 if (urb == hcd->status_urb) {
662 hcd->status_urb = NULL; 652 hcd->status_urb = NULL;
@@ -666,7 +656,7 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
666 spin_unlock (&hcd_root_hub_lock); 656 spin_unlock (&hcd_root_hub_lock);
667 if (urb) 657 if (urb)
668 usb_hcd_giveback_urb (hcd, urb, NULL); 658 usb_hcd_giveback_urb (hcd, urb, NULL);
669 local_irq_enable (); 659 local_irq_restore (flags);
670 } 660 }
671 661
672 return 0; 662 return 0;
@@ -674,31 +664,6 @@ static int usb_rh_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
674 664
675/*-------------------------------------------------------------------------*/ 665/*-------------------------------------------------------------------------*/
676 666
677/* exported only within usbcore */
678struct usb_bus *usb_bus_get(struct usb_bus *bus)
679{
680 if (bus)
681 kref_get(&bus->kref);
682 return bus;
683}
684
685static void usb_host_release(struct kref *kref)
686{
687 struct usb_bus *bus = container_of(kref, struct usb_bus, kref);
688
689 if (bus->release)
690 bus->release(bus);
691}
692
693/* exported only within usbcore */
694void usb_bus_put(struct usb_bus *bus)
695{
696 if (bus)
697 kref_put(&bus->kref, usb_host_release);
698}
699
700/*-------------------------------------------------------------------------*/
701
702static struct class *usb_host_class; 667static struct class *usb_host_class;
703 668
704int usb_host_init(void) 669int usb_host_init(void)
@@ -730,39 +695,12 @@ static void usb_bus_init (struct usb_bus *bus)
730 bus->devnum_next = 1; 695 bus->devnum_next = 1;
731 696
732 bus->root_hub = NULL; 697 bus->root_hub = NULL;
733 bus->hcpriv = NULL;
734 bus->busnum = -1; 698 bus->busnum = -1;
735 bus->bandwidth_allocated = 0; 699 bus->bandwidth_allocated = 0;
736 bus->bandwidth_int_reqs = 0; 700 bus->bandwidth_int_reqs = 0;
737 bus->bandwidth_isoc_reqs = 0; 701 bus->bandwidth_isoc_reqs = 0;
738 702
739 INIT_LIST_HEAD (&bus->bus_list); 703 INIT_LIST_HEAD (&bus->bus_list);
740
741 kref_init(&bus->kref);
742}
743
744/**
745 * usb_alloc_bus - creates a new USB host controller structure
746 * @op: pointer to a struct usb_operations that this bus structure should use
747 * Context: !in_interrupt()
748 *
749 * Creates a USB host controller bus structure with the specified
750 * usb_operations and initializes all the necessary internal objects.
751 *
752 * If no memory is available, NULL is returned.
753 *
754 * The caller should call usb_put_bus() when it is finished with the structure.
755 */
756struct usb_bus *usb_alloc_bus (struct usb_operations *op)
757{
758 struct usb_bus *bus;
759
760 bus = kzalloc (sizeof *bus, GFP_KERNEL);
761 if (!bus)
762 return NULL;
763 usb_bus_init (bus);
764 bus->op = op;
765 return bus;
766} 704}
767 705
768/*-------------------------------------------------------------------------*/ 706/*-------------------------------------------------------------------------*/
@@ -1112,10 +1050,10 @@ static void urb_unlink (struct urb *urb)
1112 * expects usb_submit_urb() to have sanity checked and conditioned all 1050 * expects usb_submit_urb() to have sanity checked and conditioned all
1113 * inputs in the urb 1051 * inputs in the urb
1114 */ 1052 */
1115static int hcd_submit_urb (struct urb *urb, gfp_t mem_flags) 1053int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1116{ 1054{
1117 int status; 1055 int status;
1118 struct usb_hcd *hcd = urb->dev->bus->hcpriv; 1056 struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus);
1119 struct usb_host_endpoint *ep; 1057 struct usb_host_endpoint *ep;
1120 unsigned long flags; 1058 unsigned long flags;
1121 1059
@@ -1186,7 +1124,7 @@ doit:
1186 /* lower level hcd code should use *_dma exclusively, 1124 /* lower level hcd code should use *_dma exclusively,
1187 * unless it uses pio or talks to another transport. 1125 * unless it uses pio or talks to another transport.
1188 */ 1126 */
1189 if (hcd->self.controller->dma_mask) { 1127 if (hcd->self.uses_dma) {
1190 if (usb_pipecontrol (urb->pipe) 1128 if (usb_pipecontrol (urb->pipe)
1191 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1129 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
1192 urb->setup_dma = dma_map_single ( 1130 urb->setup_dma = dma_map_single (
@@ -1221,9 +1159,10 @@ done:
1221/*-------------------------------------------------------------------------*/ 1159/*-------------------------------------------------------------------------*/
1222 1160
1223/* called in any context */ 1161/* called in any context */
1224static int hcd_get_frame_number (struct usb_device *udev) 1162int usb_hcd_get_frame_number (struct usb_device *udev)
1225{ 1163{
1226 struct usb_hcd *hcd = (struct usb_hcd *)udev->bus->hcpriv; 1164 struct usb_hcd *hcd = bus_to_hcd(udev->bus);
1165
1227 if (!HC_IS_RUNNING (hcd->state)) 1166 if (!HC_IS_RUNNING (hcd->state))
1228 return -ESHUTDOWN; 1167 return -ESHUTDOWN;
1229 return hcd->driver->get_frame_number (hcd); 1168 return hcd->driver->get_frame_number (hcd);
@@ -1263,7 +1202,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
1263 * caller guarantees urb won't be recycled till both unlink() 1202 * caller guarantees urb won't be recycled till both unlink()
1264 * and the urb's completion function return 1203 * and the urb's completion function return
1265 */ 1204 */
1266static int hcd_unlink_urb (struct urb *urb, int status) 1205int usb_hcd_unlink_urb (struct urb *urb, int status)
1267{ 1206{
1268 struct usb_host_endpoint *ep; 1207 struct usb_host_endpoint *ep;
1269 struct usb_hcd *hcd = NULL; 1208 struct usb_hcd *hcd = NULL;
@@ -1296,7 +1235,7 @@ static int hcd_unlink_urb (struct urb *urb, int status)
1296 spin_lock (&hcd_data_lock); 1235 spin_lock (&hcd_data_lock);
1297 1236
1298 sys = &urb->dev->dev; 1237 sys = &urb->dev->dev;
1299 hcd = urb->dev->bus->hcpriv; 1238 hcd = bus_to_hcd(urb->dev->bus);
1300 if (hcd == NULL) { 1239 if (hcd == NULL) {
1301 retval = -ENODEV; 1240 retval = -ENODEV;
1302 goto done; 1241 goto done;
@@ -1354,41 +1293,33 @@ done:
1354/*-------------------------------------------------------------------------*/ 1293/*-------------------------------------------------------------------------*/
1355 1294
1356/* disables the endpoint: cancels any pending urbs, then synchronizes with 1295/* disables the endpoint: cancels any pending urbs, then synchronizes with
1357 * the hcd to make sure all endpoint state is gone from hardware. use for 1296 * the hcd to make sure all endpoint state is gone from hardware, and then
1297 * waits until the endpoint's queue is completely drained. use for
1358 * set_configuration, set_interface, driver removal, physical disconnect. 1298 * set_configuration, set_interface, driver removal, physical disconnect.
1359 * 1299 *
1360 * example: a qh stored in ep->hcpriv, holding state related to endpoint 1300 * example: a qh stored in ep->hcpriv, holding state related to endpoint
1361 * type, maxpacket size, toggle, halt status, and scheduling. 1301 * type, maxpacket size, toggle, halt status, and scheduling.
1362 */ 1302 */
1363static void 1303void usb_hcd_endpoint_disable (struct usb_device *udev,
1364hcd_endpoint_disable (struct usb_device *udev, struct usb_host_endpoint *ep) 1304 struct usb_host_endpoint *ep)
1365{ 1305{
1366 struct usb_hcd *hcd; 1306 struct usb_hcd *hcd;
1367 struct urb *urb; 1307 struct urb *urb;
1368 1308
1369 hcd = udev->bus->hcpriv; 1309 hcd = bus_to_hcd(udev->bus);
1370 1310
1371 WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT && 1311 WARN_ON (!HC_IS_RUNNING (hcd->state) && hcd->state != HC_STATE_HALT &&
1372 udev->state != USB_STATE_NOTATTACHED); 1312 udev->state != USB_STATE_NOTATTACHED);
1373 1313
1374 local_irq_disable (); 1314 local_irq_disable ();
1375 1315
1376 /* FIXME move most of this into message.c as part of its
1377 * endpoint disable logic
1378 */
1379
1380 /* ep is already gone from udev->ep_{in,out}[]; no more submits */ 1316 /* ep is already gone from udev->ep_{in,out}[]; no more submits */
1381rescan: 1317rescan:
1382 spin_lock (&hcd_data_lock); 1318 spin_lock (&hcd_data_lock);
1383 list_for_each_entry (urb, &ep->urb_list, urb_list) { 1319 list_for_each_entry (urb, &ep->urb_list, urb_list) {
1384 int tmp; 1320 int tmp;
1385 1321
1386 /* another cpu may be in hcd, spinning on hcd_data_lock 1322 /* the urb may already have been unlinked */
1387 * to giveback() this urb. the races here should be
1388 * small, but a full fix needs a new "can't submit"
1389 * urb state.
1390 * FIXME urb->reject should allow that...
1391 */
1392 if (urb->status != -EINPROGRESS) 1323 if (urb->status != -EINPROGRESS)
1393 continue; 1324 continue;
1394 usb_get_urb (urb); 1325 usb_get_urb (urb);
@@ -1430,6 +1361,30 @@ rescan:
1430 might_sleep (); 1361 might_sleep ();
1431 if (hcd->driver->endpoint_disable) 1362 if (hcd->driver->endpoint_disable)
1432 hcd->driver->endpoint_disable (hcd, ep); 1363 hcd->driver->endpoint_disable (hcd, ep);
1364
1365 /* Wait until the endpoint queue is completely empty. Most HCDs
1366 * will have done this already in their endpoint_disable method,
1367 * but some might not. And there could be root-hub control URBs
1368 * still pending since they aren't affected by the HCDs'
1369 * endpoint_disable methods.
1370 */
1371 while (!list_empty (&ep->urb_list)) {
1372 spin_lock_irq (&hcd_data_lock);
1373
1374 /* The list may have changed while we acquired the spinlock */
1375 urb = NULL;
1376 if (!list_empty (&ep->urb_list)) {
1377 urb = list_entry (ep->urb_list.prev, struct urb,
1378 urb_list);
1379 usb_get_urb (urb);
1380 }
1381 spin_unlock_irq (&hcd_data_lock);
1382
1383 if (urb) {
1384 usb_kill_urb (urb);
1385 usb_put_urb (urb);
1386 }
1387 }
1433} 1388}
1434 1389
1435/*-------------------------------------------------------------------------*/ 1390/*-------------------------------------------------------------------------*/
@@ -1476,50 +1431,6 @@ int hcd_bus_resume (struct usb_bus *bus)
1476 return status; 1431 return status;
1477} 1432}
1478 1433
1479/*
1480 * usb_hcd_suspend_root_hub - HCD autosuspends downstream ports
1481 * @hcd: host controller for this root hub
1482 *
1483 * This call arranges that usb_hcd_resume_root_hub() is safe to call later;
1484 * that the HCD's root hub polling is deactivated; and that the root's hub
1485 * driver is suspended. HCDs may call this to autosuspend when their root
1486 * hub's downstream ports are all inactive: unpowered, disconnected,
1487 * disabled, or suspended.
1488 *
1489 * The HCD will autoresume on device connect change detection (using SRP
1490 * or a D+/D- pullup). The HCD also autoresumes on remote wakeup signaling
1491 * from any ports that are suspended (if that is enabled). In most cases,
1492 * overcurrent signaling (on powered ports) will also start autoresume.
1493 *
1494 * Always called with IRQs blocked.
1495 */
1496void usb_hcd_suspend_root_hub (struct usb_hcd *hcd)
1497{
1498 struct urb *urb;
1499
1500 spin_lock (&hcd_root_hub_lock);
1501 usb_suspend_root_hub (hcd->self.root_hub);
1502
1503 /* force status urb to complete/unlink while suspended */
1504 if (hcd->status_urb) {
1505 urb = hcd->status_urb;
1506 urb->status = -ECONNRESET;
1507 urb->hcpriv = NULL;
1508 urb->actual_length = 0;
1509
1510 del_timer (&hcd->rh_timer);
1511 hcd->poll_pending = 0;
1512 hcd->status_urb = NULL;
1513 } else
1514 urb = NULL;
1515 spin_unlock (&hcd_root_hub_lock);
1516 hcd->state = HC_STATE_SUSPENDED;
1517
1518 if (urb)
1519 usb_hcd_giveback_urb (hcd, urb, NULL);
1520}
1521EXPORT_SYMBOL_GPL(usb_hcd_suspend_root_hub);
1522
1523/** 1434/**
1524 * usb_hcd_resume_root_hub - called by HCD to resume its root hub 1435 * usb_hcd_resume_root_hub - called by HCD to resume its root hub
1525 * @hcd: host controller for this root hub 1436 * @hcd: host controller for this root hub
@@ -1583,20 +1494,6 @@ EXPORT_SYMBOL (usb_bus_start_enum);
1583 1494
1584/*-------------------------------------------------------------------------*/ 1495/*-------------------------------------------------------------------------*/
1585 1496
1586/*
1587 * usb_hcd_operations - adapts usb_bus framework to HCD framework (bus glue)
1588 */
1589static struct usb_operations usb_hcd_operations = {
1590 .get_frame_number = hcd_get_frame_number,
1591 .submit_urb = hcd_submit_urb,
1592 .unlink_urb = hcd_unlink_urb,
1593 .buffer_alloc = hcd_buffer_alloc,
1594 .buffer_free = hcd_buffer_free,
1595 .disable = hcd_endpoint_disable,
1596};
1597
1598/*-------------------------------------------------------------------------*/
1599
1600/** 1497/**
1601 * usb_hcd_giveback_urb - return URB from HCD to device driver 1498 * usb_hcd_giveback_urb - return URB from HCD to device driver
1602 * @hcd: host controller returning the URB 1499 * @hcd: host controller returning the URB
@@ -1617,8 +1514,9 @@ void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs
1617 at_root_hub = (urb->dev == hcd->self.root_hub); 1514 at_root_hub = (urb->dev == hcd->self.root_hub);
1618 urb_unlink (urb); 1515 urb_unlink (urb);
1619 1516
1620 /* lower level hcd code should use *_dma exclusively */ 1517 /* lower level hcd code should use *_dma exclusively if the
1621 if (hcd->self.controller->dma_mask && !at_root_hub) { 1518 * host controller does DMA */
1519 if (hcd->self.uses_dma && !at_root_hub) {
1622 if (usb_pipecontrol (urb->pipe) 1520 if (usb_pipecontrol (urb->pipe)
1623 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 1521 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
1624 dma_unmap_single (hcd->self.controller, urb->setup_dma, 1522 dma_unmap_single (hcd->self.controller, urb->setup_dma,
@@ -1704,14 +1602,6 @@ EXPORT_SYMBOL_GPL (usb_hc_died);
1704 1602
1705/*-------------------------------------------------------------------------*/ 1603/*-------------------------------------------------------------------------*/
1706 1604
1707static void hcd_release (struct usb_bus *bus)
1708{
1709 struct usb_hcd *hcd;
1710
1711 hcd = container_of(bus, struct usb_hcd, self);
1712 kfree(hcd);
1713}
1714
1715/** 1605/**
1716 * usb_create_hcd - create and initialize an HCD structure 1606 * usb_create_hcd - create and initialize an HCD structure
1717 * @driver: HC driver that will use this hcd 1607 * @driver: HC driver that will use this hcd
@@ -1736,13 +1626,12 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
1736 return NULL; 1626 return NULL;
1737 } 1627 }
1738 dev_set_drvdata(dev, hcd); 1628 dev_set_drvdata(dev, hcd);
1629 kref_init(&hcd->kref);
1739 1630
1740 usb_bus_init(&hcd->self); 1631 usb_bus_init(&hcd->self);
1741 hcd->self.op = &usb_hcd_operations;
1742 hcd->self.hcpriv = hcd;
1743 hcd->self.release = &hcd_release;
1744 hcd->self.controller = dev; 1632 hcd->self.controller = dev;
1745 hcd->self.bus_name = bus_name; 1633 hcd->self.bus_name = bus_name;
1634 hcd->self.uses_dma = (dev->dma_mask != NULL);
1746 1635
1747 init_timer(&hcd->rh_timer); 1636 init_timer(&hcd->rh_timer);
1748 hcd->rh_timer.function = rh_timer_func; 1637 hcd->rh_timer.function = rh_timer_func;
@@ -1756,10 +1645,25 @@ struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
1756} 1645}
1757EXPORT_SYMBOL (usb_create_hcd); 1646EXPORT_SYMBOL (usb_create_hcd);
1758 1647
1648static void hcd_release (struct kref *kref)
1649{
1650 struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref);
1651
1652 kfree(hcd);
1653}
1654
1655struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd)
1656{
1657 if (hcd)
1658 kref_get (&hcd->kref);
1659 return hcd;
1660}
1661EXPORT_SYMBOL (usb_get_hcd);
1662
1759void usb_put_hcd (struct usb_hcd *hcd) 1663void usb_put_hcd (struct usb_hcd *hcd)
1760{ 1664{
1761 dev_set_drvdata(hcd->self.controller, NULL); 1665 if (hcd)
1762 usb_bus_put(&hcd->self); 1666 kref_put (&hcd->kref, hcd_release);
1763} 1667}
1764EXPORT_SYMBOL (usb_put_hcd); 1668EXPORT_SYMBOL (usb_put_hcd);
1765 1669
@@ -1915,6 +1819,16 @@ void usb_remove_hcd(struct usb_hcd *hcd)
1915} 1819}
1916EXPORT_SYMBOL (usb_remove_hcd); 1820EXPORT_SYMBOL (usb_remove_hcd);
1917 1821
1822void
1823usb_hcd_platform_shutdown(struct platform_device* dev)
1824{
1825 struct usb_hcd *hcd = platform_get_drvdata(dev);
1826
1827 if (hcd->driver->shutdown)
1828 hcd->driver->shutdown(hcd);
1829}
1830EXPORT_SYMBOL (usb_hcd_platform_shutdown);
1831
1918/*-------------------------------------------------------------------------*/ 1832/*-------------------------------------------------------------------------*/
1919 1833
1920#if defined(CONFIG_USB_MON) 1834#if defined(CONFIG_USB_MON)
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 7022aafb2ae8..676877c15f81 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -55,12 +55,13 @@
55 55
56/*-------------------------------------------------------------------------*/ 56/*-------------------------------------------------------------------------*/
57 57
58struct usb_hcd { /* usb_bus.hcpriv points to this */ 58struct usb_hcd {
59 59
60 /* 60 /*
61 * housekeeping 61 * housekeeping
62 */ 62 */
63 struct usb_bus self; /* hcd is-a bus */ 63 struct usb_bus self; /* hcd is-a bus */
64 struct kref kref; /* reference counter */
64 65
65 const char *product_desc; /* product/vendor string */ 66 const char *product_desc; /* product/vendor string */
66 char irq_descr[24]; /* driver + bus # */ 67 char irq_descr[24]; /* driver + bus # */
@@ -85,6 +86,7 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */
85 unsigned uses_new_polling:1; 86 unsigned uses_new_polling:1;
86 unsigned poll_rh:1; /* poll for rh status? */ 87 unsigned poll_rh:1; /* poll for rh status? */
87 unsigned poll_pending:1; /* status has changed? */ 88 unsigned poll_pending:1; /* status has changed? */
89 unsigned wireless:1; /* Wireless USB HCD */
88 90
89 int irq; /* irq allocated */ 91 int irq; /* irq allocated */
90 void __iomem *regs; /* device memory/io */ 92 void __iomem *regs; /* device memory/io */
@@ -128,8 +130,10 @@ static inline struct usb_bus *hcd_to_bus (struct usb_hcd *hcd)
128 return &hcd->self; 130 return &hcd->self;
129} 131}
130 132
131 133static inline struct usb_hcd *bus_to_hcd (struct usb_bus *bus)
132// urb.hcpriv is really hardware-specific 134{
135 return container_of(bus, struct usb_hcd, self);
136}
133 137
134struct hcd_timeout { /* timeouts we allocate */ 138struct hcd_timeout { /* timeouts we allocate */
135 struct list_head timeout_list; 139 struct list_head timeout_list;
@@ -138,28 +142,6 @@ struct hcd_timeout { /* timeouts we allocate */
138 142
139/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
140 144
141/*
142 * FIXME usb_operations should vanish or become hc_driver,
143 * when usb_bus and usb_hcd become the same thing.
144 */
145
146struct usb_operations {
147 int (*get_frame_number) (struct usb_device *usb_dev);
148 int (*submit_urb) (struct urb *urb, gfp_t mem_flags);
149 int (*unlink_urb) (struct urb *urb, int status);
150
151 /* allocate dma-consistent buffer for URB_DMA_NOMAPPING */
152 void *(*buffer_alloc)(struct usb_bus *bus, size_t size,
153 gfp_t mem_flags,
154 dma_addr_t *dma);
155 void (*buffer_free)(struct usb_bus *bus, size_t size,
156 void *addr, dma_addr_t dma);
157
158 void (*disable)(struct usb_device *udev,
159 struct usb_host_endpoint *ep);
160};
161
162/* each driver provides one of these, and hardware init support */
163 145
164struct pt_regs; 146struct pt_regs;
165 147
@@ -192,6 +174,9 @@ struct hc_driver {
192 /* cleanly make HCD stop writing memory and doing I/O */ 174 /* cleanly make HCD stop writing memory and doing I/O */
193 void (*stop) (struct usb_hcd *hcd); 175 void (*stop) (struct usb_hcd *hcd);
194 176
177 /* shutdown HCD */
178 void (*shutdown) (struct usb_hcd *hcd);
179
195 /* return current frame number */ 180 /* return current frame number */
196 int (*get_frame_number) (struct usb_hcd *hcd); 181 int (*get_frame_number) (struct usb_hcd *hcd);
197 182
@@ -218,15 +203,25 @@ struct hc_driver {
218 /* Needed only if port-change IRQs are level-triggered */ 203 /* Needed only if port-change IRQs are level-triggered */
219}; 204};
220 205
221extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb, struct pt_regs *regs); 206extern int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags);
207extern int usb_hcd_unlink_urb (struct urb *urb, int status);
208extern void usb_hcd_giveback_urb (struct usb_hcd *hcd, struct urb *urb,
209 struct pt_regs *regs);
210extern void usb_hcd_endpoint_disable (struct usb_device *udev,
211 struct usb_host_endpoint *ep);
212extern int usb_hcd_get_frame_number (struct usb_device *udev);
222 213
223extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver, 214extern struct usb_hcd *usb_create_hcd (const struct hc_driver *driver,
224 struct device *dev, char *bus_name); 215 struct device *dev, char *bus_name);
216extern struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd);
225extern void usb_put_hcd (struct usb_hcd *hcd); 217extern void usb_put_hcd (struct usb_hcd *hcd);
226extern int usb_add_hcd(struct usb_hcd *hcd, 218extern int usb_add_hcd(struct usb_hcd *hcd,
227 unsigned int irqnum, unsigned long irqflags); 219 unsigned int irqnum, unsigned long irqflags);
228extern void usb_remove_hcd(struct usb_hcd *hcd); 220extern void usb_remove_hcd(struct usb_hcd *hcd);
229 221
222struct platform_device;
223extern void usb_hcd_platform_shutdown(struct platform_device* dev);
224
230#ifdef CONFIG_PCI 225#ifdef CONFIG_PCI
231struct pci_dev; 226struct pci_dev;
232struct pci_device_id; 227struct pci_device_id;
@@ -239,6 +234,8 @@ extern int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t state);
239extern int usb_hcd_pci_resume (struct pci_dev *dev); 234extern int usb_hcd_pci_resume (struct pci_dev *dev);
240#endif /* CONFIG_PM */ 235#endif /* CONFIG_PM */
241 236
237extern void usb_hcd_pci_shutdown (struct pci_dev *dev);
238
242#endif /* CONFIG_PCI */ 239#endif /* CONFIG_PCI */
243 240
244/* pci-ish (pdev null is ok) buffer alloc/mapping support */ 241/* pci-ish (pdev null is ok) buffer alloc/mapping support */
@@ -352,8 +349,6 @@ extern long usb_calc_bus_time (int speed, int is_input,
352 349
353/*-------------------------------------------------------------------------*/ 350/*-------------------------------------------------------------------------*/
354 351
355extern struct usb_bus *usb_alloc_bus (struct usb_operations *);
356
357extern void usb_set_device_state(struct usb_device *udev, 352extern void usb_set_device_state(struct usb_device *udev,
358 enum usb_device_state new_state); 353 enum usb_device_state new_state);
359 354
@@ -365,9 +360,6 @@ extern struct list_head usb_bus_list;
365extern struct mutex usb_bus_list_lock; 360extern struct mutex usb_bus_list_lock;
366extern wait_queue_head_t usb_kill_urb_queue; 361extern wait_queue_head_t usb_kill_urb_queue;
367 362
368extern struct usb_bus *usb_bus_get (struct usb_bus *bus);
369extern void usb_bus_put (struct usb_bus *bus);
370
371extern void usb_enable_root_hub_irq (struct usb_bus *bus); 363extern void usb_enable_root_hub_irq (struct usb_bus *bus);
372 364
373extern int usb_find_interface_driver (struct usb_device *dev, 365extern int usb_find_interface_driver (struct usb_device *dev,
@@ -376,17 +368,11 @@ extern int usb_find_interface_driver (struct usb_device *dev,
376#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) 368#define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN))
377 369
378#ifdef CONFIG_PM 370#ifdef CONFIG_PM
379extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd);
380extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); 371extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);
381extern void usb_root_hub_lost_power (struct usb_device *rhdev); 372extern void usb_root_hub_lost_power (struct usb_device *rhdev);
382extern int hcd_bus_suspend (struct usb_bus *bus); 373extern int hcd_bus_suspend (struct usb_bus *bus);
383extern int hcd_bus_resume (struct usb_bus *bus); 374extern int hcd_bus_resume (struct usb_bus *bus);
384#else 375#else
385static inline void usb_hcd_suspend_root_hub(struct usb_hcd *hcd)
386{
387 return;
388}
389
390static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 376static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
391{ 377{
392 return; 378 return;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 26c8cb5f3e67..2a8cb3c2b19c 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -293,7 +293,7 @@ void usb_kick_khubd(struct usb_device *hdev)
293/* completion function, fires on port status changes and various faults */ 293/* completion function, fires on port status changes and various faults */
294static void hub_irq(struct urb *urb, struct pt_regs *regs) 294static void hub_irq(struct urb *urb, struct pt_regs *regs)
295{ 295{
296 struct usb_hub *hub = (struct usb_hub *)urb->context; 296 struct usb_hub *hub = urb->context;
297 int status; 297 int status;
298 int i; 298 int i;
299 unsigned long bits; 299 unsigned long bits;
@@ -311,7 +311,7 @@ static void hub_irq(struct urb *urb, struct pt_regs *regs)
311 goto resubmit; 311 goto resubmit;
312 hub->error = urb->status; 312 hub->error = urb->status;
313 /* FALL THROUGH */ 313 /* FALL THROUGH */
314 314
315 /* let khubd handle things */ 315 /* let khubd handle things */
316 case 0: /* we got data: port status changed */ 316 case 0: /* we got data: port status changed */
317 bits = 0; 317 bits = 0;
@@ -452,18 +452,14 @@ static void hub_power_on(struct usb_hub *hub)
452 msleep(max(pgood_delay, (unsigned) 100)); 452 msleep(max(pgood_delay, (unsigned) 100));
453} 453}
454 454
455static inline void __hub_quiesce(struct usb_hub *hub) 455static void hub_quiesce(struct usb_hub *hub)
456{ 456{
457 /* (nonblocking) khubd and related activity won't re-trigger */ 457 /* (nonblocking) khubd and related activity won't re-trigger */
458 hub->quiescing = 1; 458 hub->quiescing = 1;
459 hub->activating = 0; 459 hub->activating = 0;
460 hub->resume_root_hub = 0; 460 hub->resume_root_hub = 0;
461}
462 461
463static void hub_quiesce(struct usb_hub *hub)
464{
465 /* (blocking) stop khubd and related activity */ 462 /* (blocking) stop khubd and related activity */
466 __hub_quiesce(hub);
467 usb_kill_urb(hub->urb); 463 usb_kill_urb(hub->urb);
468 if (hub->has_indicators) 464 if (hub->has_indicators)
469 cancel_delayed_work(&hub->leds); 465 cancel_delayed_work(&hub->leds);
@@ -868,13 +864,8 @@ descriptor_error:
868 864
869 endpoint = &desc->endpoint[0].desc; 865 endpoint = &desc->endpoint[0].desc;
870 866
871 /* Output endpoint? Curiouser and curiouser.. */ 867 /* If it's not an interrupt in endpoint, we'd better punt! */
872 if (!(endpoint->bEndpointAddress & USB_DIR_IN)) 868 if (!usb_endpoint_is_int_in(endpoint))
873 goto descriptor_error;
874
875 /* If it's not an interrupt endpoint, we'd better punt! */
876 if ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
877 != USB_ENDPOINT_XFER_INT)
878 goto descriptor_error; 869 goto descriptor_error;
879 870
880 /* We found a hub */ 871 /* We found a hub */
@@ -1022,26 +1013,29 @@ void usb_set_device_state(struct usb_device *udev,
1022 if (udev->state == USB_STATE_NOTATTACHED) 1013 if (udev->state == USB_STATE_NOTATTACHED)
1023 ; /* do nothing */ 1014 ; /* do nothing */
1024 else if (new_state != USB_STATE_NOTATTACHED) { 1015 else if (new_state != USB_STATE_NOTATTACHED) {
1025 udev->state = new_state;
1026 1016
1027 /* root hub wakeup capabilities are managed out-of-band 1017 /* root hub wakeup capabilities are managed out-of-band
1028 * and may involve silicon errata ... ignore them here. 1018 * and may involve silicon errata ... ignore them here.
1029 */ 1019 */
1030 if (udev->parent) { 1020 if (udev->parent) {
1031 if (new_state == USB_STATE_CONFIGURED) 1021 if (udev->state == USB_STATE_SUSPENDED
1022 || new_state == USB_STATE_SUSPENDED)
1023 ; /* No change to wakeup settings */
1024 else if (new_state == USB_STATE_CONFIGURED)
1032 device_init_wakeup(&udev->dev, 1025 device_init_wakeup(&udev->dev,
1033 (udev->actconfig->desc.bmAttributes 1026 (udev->actconfig->desc.bmAttributes
1034 & USB_CONFIG_ATT_WAKEUP)); 1027 & USB_CONFIG_ATT_WAKEUP));
1035 else if (new_state != USB_STATE_SUSPENDED) 1028 else
1036 device_init_wakeup(&udev->dev, 0); 1029 device_init_wakeup(&udev->dev, 0);
1037 } 1030 }
1031 udev->state = new_state;
1038 } else 1032 } else
1039 recursively_mark_NOTATTACHED(udev); 1033 recursively_mark_NOTATTACHED(udev);
1040 spin_unlock_irqrestore(&device_state_lock, flags); 1034 spin_unlock_irqrestore(&device_state_lock, flags);
1041} 1035}
1042 1036
1043 1037
1044#ifdef CONFIG_PM 1038#ifdef CONFIG_PM
1045 1039
1046/** 1040/**
1047 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power 1041 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
@@ -1059,6 +1053,12 @@ void usb_root_hub_lost_power(struct usb_device *rhdev)
1059 unsigned long flags; 1053 unsigned long flags;
1060 1054
1061 dev_warn(&rhdev->dev, "root hub lost power or was reset\n"); 1055 dev_warn(&rhdev->dev, "root hub lost power or was reset\n");
1056
1057 /* Make sure no potential wakeup events get lost,
1058 * by forcing the root hub to be resumed.
1059 */
1060 rhdev->dev.power.prev_state.event = PM_EVENT_ON;
1061
1062 spin_lock_irqsave(&device_state_lock, flags); 1062 spin_lock_irqsave(&device_state_lock, flags);
1063 hub = hdev_to_hub(rhdev); 1063 hub = hdev_to_hub(rhdev);
1064 for (port1 = 1; port1 <= rhdev->maxchild; ++port1) { 1064 for (port1 = 1; port1 <= rhdev->maxchild; ++port1) {
@@ -1072,7 +1072,7 @@ void usb_root_hub_lost_power(struct usb_device *rhdev)
1072} 1072}
1073EXPORT_SYMBOL_GPL(usb_root_hub_lost_power); 1073EXPORT_SYMBOL_GPL(usb_root_hub_lost_power);
1074 1074
1075#endif 1075#endif /* CONFIG_PM */
1076 1076
1077static void choose_address(struct usb_device *udev) 1077static void choose_address(struct usb_device *udev)
1078{ 1078{
@@ -1148,144 +1148,28 @@ void usb_disconnect(struct usb_device **pdev)
1148 * cleaning up all state associated with the current configuration 1148 * cleaning up all state associated with the current configuration
1149 * so that the hardware is now fully quiesced. 1149 * so that the hardware is now fully quiesced.
1150 */ 1150 */
1151 dev_dbg (&udev->dev, "unregistering device\n");
1151 usb_disable_device(udev, 0); 1152 usb_disable_device(udev, 0);
1152 1153
1153 usb_notify_remove_device(udev); 1154 usb_unlock_device(udev);
1154 1155
1155 /* Free the device number, remove the /proc/bus/usb entry and 1156 /* Unregister the device. The device driver is responsible
1156 * the sysfs attributes, and delete the parent's children[] 1157 * for removing the device files from usbfs and sysfs and for
1158 * de-configuring the device.
1159 */
1160 device_del(&udev->dev);
1161
1162 /* Free the device number and delete the parent's children[]
1157 * (or root_hub) pointer. 1163 * (or root_hub) pointer.
1158 */ 1164 */
1159 dev_dbg (&udev->dev, "unregistering device\n");
1160 release_address(udev); 1165 release_address(udev);
1161 usb_remove_sysfs_dev_files(udev);
1162 1166
1163 /* Avoid races with recursively_mark_NOTATTACHED() */ 1167 /* Avoid races with recursively_mark_NOTATTACHED() */
1164 spin_lock_irq(&device_state_lock); 1168 spin_lock_irq(&device_state_lock);
1165 *pdev = NULL; 1169 *pdev = NULL;
1166 spin_unlock_irq(&device_state_lock); 1170 spin_unlock_irq(&device_state_lock);
1167 1171
1168 usb_unlock_device(udev); 1172 put_device(&udev->dev);
1169
1170 device_unregister(&udev->dev);
1171}
1172
1173static inline const char *plural(int n)
1174{
1175 return (n == 1 ? "" : "s");
1176}
1177
1178static int choose_configuration(struct usb_device *udev)
1179{
1180 int i;
1181 int num_configs;
1182 int insufficient_power = 0;
1183 struct usb_host_config *c, *best;
1184
1185 best = NULL;
1186 c = udev->config;
1187 num_configs = udev->descriptor.bNumConfigurations;
1188 for (i = 0; i < num_configs; (i++, c++)) {
1189 struct usb_interface_descriptor *desc = NULL;
1190
1191 /* It's possible that a config has no interfaces! */
1192 if (c->desc.bNumInterfaces > 0)
1193 desc = &c->intf_cache[0]->altsetting->desc;
1194
1195 /*
1196 * HP's USB bus-powered keyboard has only one configuration
1197 * and it claims to be self-powered; other devices may have
1198 * similar errors in their descriptors. If the next test
1199 * were allowed to execute, such configurations would always
1200 * be rejected and the devices would not work as expected.
1201 * In the meantime, we run the risk of selecting a config
1202 * that requires external power at a time when that power
1203 * isn't available. It seems to be the lesser of two evils.
1204 *
1205 * Bugzilla #6448 reports a device that appears to crash
1206 * when it receives a GET_DEVICE_STATUS request! We don't
1207 * have any other way to tell whether a device is self-powered,
1208 * but since we don't use that information anywhere but here,
1209 * the call has been removed.
1210 *
1211 * Maybe the GET_DEVICE_STATUS call and the test below can
1212 * be reinstated when device firmwares become more reliable.
1213 * Don't hold your breath.
1214 */
1215#if 0
1216 /* Rule out self-powered configs for a bus-powered device */
1217 if (bus_powered && (c->desc.bmAttributes &
1218 USB_CONFIG_ATT_SELFPOWER))
1219 continue;
1220#endif
1221
1222 /*
1223 * The next test may not be as effective as it should be.
1224 * Some hubs have errors in their descriptor, claiming
1225 * to be self-powered when they are really bus-powered.
1226 * We will overestimate the amount of current such hubs
1227 * make available for each port.
1228 *
1229 * This is a fairly benign sort of failure. It won't
1230 * cause us to reject configurations that we should have
1231 * accepted.
1232 */
1233
1234 /* Rule out configs that draw too much bus current */
1235 if (c->desc.bMaxPower * 2 > udev->bus_mA) {
1236 insufficient_power++;
1237 continue;
1238 }
1239
1240 /* If the first config's first interface is COMM/2/0xff
1241 * (MSFT RNDIS), rule it out unless Linux has host-side
1242 * RNDIS support. */
1243 if (i == 0 && desc
1244 && desc->bInterfaceClass == USB_CLASS_COMM
1245 && desc->bInterfaceSubClass == 2
1246 && desc->bInterfaceProtocol == 0xff) {
1247#ifndef CONFIG_USB_NET_RNDIS_HOST
1248 continue;
1249#else
1250 best = c;
1251#endif
1252 }
1253
1254 /* From the remaining configs, choose the first one whose
1255 * first interface is for a non-vendor-specific class.
1256 * Reason: Linux is more likely to have a class driver
1257 * than a vendor-specific driver. */
1258 else if (udev->descriptor.bDeviceClass !=
1259 USB_CLASS_VENDOR_SPEC &&
1260 (!desc || desc->bInterfaceClass !=
1261 USB_CLASS_VENDOR_SPEC)) {
1262 best = c;
1263 break;
1264 }
1265
1266 /* If all the remaining configs are vendor-specific,
1267 * choose the first one. */
1268 else if (!best)
1269 best = c;
1270 }
1271
1272 if (insufficient_power > 0)
1273 dev_info(&udev->dev, "rejected %d configuration%s "
1274 "due to insufficient available bus power\n",
1275 insufficient_power, plural(insufficient_power));
1276
1277 if (best) {
1278 i = best->desc.bConfigurationValue;
1279 dev_info(&udev->dev,
1280 "configuration #%d chosen from %d choice%s\n",
1281 i, num_configs, plural(num_configs));
1282 } else {
1283 i = -1;
1284 dev_warn(&udev->dev,
1285 "no configuration chosen from %d choice%s\n",
1286 num_configs, plural(num_configs));
1287 }
1288 return i;
1289} 1173}
1290 1174
1291#ifdef DEBUG 1175#ifdef DEBUG
@@ -1328,7 +1212,6 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1328int usb_new_device(struct usb_device *udev) 1212int usb_new_device(struct usb_device *udev)
1329{ 1213{
1330 int err; 1214 int err;
1331 int c;
1332 1215
1333 err = usb_get_configuration(udev); 1216 err = usb_get_configuration(udev);
1334 if (err < 0) { 1217 if (err < 0) {
@@ -1371,8 +1254,7 @@ int usb_new_device(struct usb_device *udev)
1371 USB_DT_OTG, (void **) &desc) == 0) { 1254 USB_DT_OTG, (void **) &desc) == 0) {
1372 if (desc->bmAttributes & USB_OTG_HNP) { 1255 if (desc->bmAttributes & USB_OTG_HNP) {
1373 unsigned port1 = udev->portnum; 1256 unsigned port1 = udev->portnum;
1374 struct usb_device *root = udev->parent; 1257
1375
1376 dev_info(&udev->dev, 1258 dev_info(&udev->dev,
1377 "Dual-Role OTG device on %sHNP port\n", 1259 "Dual-Role OTG device on %sHNP port\n",
1378 (port1 == bus->otg_port) 1260 (port1 == bus->otg_port)
@@ -1407,9 +1289,9 @@ int usb_new_device(struct usb_device *udev)
1407 * (Includes HNP test device.) 1289 * (Includes HNP test device.)
1408 */ 1290 */
1409 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { 1291 if (udev->bus->b_hnp_enable || udev->bus->is_b_host) {
1410 static int __usb_suspend_device(struct usb_device *, 1292 static int __usb_port_suspend(struct usb_device *,
1411 int port1); 1293 int port1);
1412 err = __usb_suspend_device(udev, udev->bus->otg_port); 1294 err = __usb_port_suspend(udev, udev->bus->otg_port);
1413 if (err < 0) 1295 if (err < 0)
1414 dev_dbg(&udev->dev, "HNP fail, %d\n", err); 1296 dev_dbg(&udev->dev, "HNP fail, %d\n", err);
1415 } 1297 }
@@ -1418,34 +1300,15 @@ int usb_new_device(struct usb_device *udev)
1418 } 1300 }
1419#endif 1301#endif
1420 1302
1421 /* put device-specific files into sysfs */ 1303 /* Register the device. The device driver is responsible
1304 * for adding the device files to usbfs and sysfs and for
1305 * configuring the device.
1306 */
1422 err = device_add (&udev->dev); 1307 err = device_add (&udev->dev);
1423 if (err) { 1308 if (err) {
1424 dev_err(&udev->dev, "can't device_add, error %d\n", err); 1309 dev_err(&udev->dev, "can't device_add, error %d\n", err);
1425 goto fail; 1310 goto fail;
1426 } 1311 }
1427 usb_create_sysfs_dev_files (udev);
1428
1429 usb_lock_device(udev);
1430
1431 /* choose and set the configuration. that registers the interfaces
1432 * with the driver core, and lets usb device drivers bind to them.
1433 */
1434 c = choose_configuration(udev);
1435 if (c >= 0) {
1436 err = usb_set_configuration(udev, c);
1437 if (err) {
1438 dev_err(&udev->dev, "can't set config #%d, error %d\n",
1439 c, err);
1440 /* This need not be fatal. The user can try to
1441 * set other configurations. */
1442 }
1443 }
1444
1445 /* USB device state == configured ... usable */
1446 usb_notify_add_device(udev);
1447
1448 usb_unlock_device(udev);
1449 1312
1450 return 0; 1313 return 0;
1451 1314
@@ -1472,6 +1335,18 @@ static int hub_port_status(struct usb_hub *hub, int port1,
1472 return ret; 1335 return ret;
1473} 1336}
1474 1337
1338
1339/* Returns 1 if @hub is a WUSB root hub, 0 otherwise */
1340static unsigned hub_is_wusb(struct usb_hub *hub)
1341{
1342 struct usb_hcd *hcd;
1343 if (hub->hdev->parent != NULL) /* not a root hub? */
1344 return 0;
1345 hcd = container_of(hub->hdev->bus, struct usb_hcd, self);
1346 return hcd->wireless;
1347}
1348
1349
1475#define PORT_RESET_TRIES 5 1350#define PORT_RESET_TRIES 5
1476#define SET_ADDRESS_TRIES 2 1351#define SET_ADDRESS_TRIES 2
1477#define GET_DESCRIPTOR_TRIES 2 1352#define GET_DESCRIPTOR_TRIES 2
@@ -1512,7 +1387,9 @@ static int hub_port_wait_reset(struct usb_hub *hub, int port1,
1512 /* if we`ve finished resetting, then break out of the loop */ 1387 /* if we`ve finished resetting, then break out of the loop */
1513 if (!(portstatus & USB_PORT_STAT_RESET) && 1388 if (!(portstatus & USB_PORT_STAT_RESET) &&
1514 (portstatus & USB_PORT_STAT_ENABLE)) { 1389 (portstatus & USB_PORT_STAT_ENABLE)) {
1515 if (portstatus & USB_PORT_STAT_HIGH_SPEED) 1390 if (hub_is_wusb(hub))
1391 udev->speed = USB_SPEED_VARIABLE;
1392 else if (portstatus & USB_PORT_STAT_HIGH_SPEED)
1516 udev->speed = USB_SPEED_HIGH; 1393 udev->speed = USB_SPEED_HIGH;
1517 else if (portstatus & USB_PORT_STAT_LOW_SPEED) 1394 else if (portstatus & USB_PORT_STAT_LOW_SPEED)
1518 udev->speed = USB_SPEED_LOW; 1395 udev->speed = USB_SPEED_LOW;
@@ -1607,6 +1484,7 @@ static void hub_port_logical_disconnect(struct usb_hub *hub, int port1)
1607 kick_khubd(hub); 1484 kick_khubd(hub);
1608} 1485}
1609 1486
1487#ifdef CONFIG_PM
1610 1488
1611#ifdef CONFIG_USB_SUSPEND 1489#ifdef CONFIG_USB_SUSPEND
1612 1490
@@ -1633,7 +1511,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1633 * NOTE: OTG devices may issue remote wakeup (or SRP) even when 1511 * NOTE: OTG devices may issue remote wakeup (or SRP) even when
1634 * we don't explicitly enable it here. 1512 * we don't explicitly enable it here.
1635 */ 1513 */
1636 if (device_may_wakeup(&udev->dev)) { 1514 if (udev->do_remote_wakeup) {
1637 status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 1515 status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
1638 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE, 1516 USB_REQ_SET_FEATURE, USB_RECIP_DEVICE,
1639 USB_DEVICE_REMOTE_WAKEUP, 0, 1517 USB_DEVICE_REMOTE_WAKEUP, 0,
@@ -1659,7 +1537,8 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1659 USB_CTRL_SET_TIMEOUT); 1537 USB_CTRL_SET_TIMEOUT);
1660 } else { 1538 } else {
1661 /* device has up to 10 msec to fully suspend */ 1539 /* device has up to 10 msec to fully suspend */
1662 dev_dbg(&udev->dev, "usb suspend\n"); 1540 dev_dbg(&udev->dev, "usb %ssuspend\n",
1541 udev->auto_pm ? "auto-" : "");
1663 usb_set_device_state(udev, USB_STATE_SUSPENDED); 1542 usb_set_device_state(udev, USB_STATE_SUSPENDED);
1664 msleep(10); 1543 msleep(10);
1665 } 1544 }
@@ -1684,7 +1563,7 @@ static int hub_port_suspend(struct usb_hub *hub, int port1,
1684 * the root hub for their bus goes into global suspend ... so we don't 1563 * the root hub for their bus goes into global suspend ... so we don't
1685 * (falsely) update the device power state to say it suspended. 1564 * (falsely) update the device power state to say it suspended.
1686 */ 1565 */
1687static int __usb_suspend_device (struct usb_device *udev, int port1) 1566static int __usb_port_suspend (struct usb_device *udev, int port1)
1688{ 1567{
1689 int status = 0; 1568 int status = 0;
1690 1569
@@ -1692,49 +1571,29 @@ static int __usb_suspend_device (struct usb_device *udev, int port1)
1692 if (port1 < 0) 1571 if (port1 < 0)
1693 return port1; 1572 return port1;
1694 1573
1695 if (udev->state == USB_STATE_SUSPENDED 1574 /* we change the device's upstream USB link,
1696 || udev->state == USB_STATE_NOTATTACHED) { 1575 * but root hubs have no upstream USB link.
1697 return 0;
1698 }
1699
1700 /* all interfaces must already be suspended */
1701 if (udev->actconfig) {
1702 int i;
1703
1704 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1705 struct usb_interface *intf;
1706
1707 intf = udev->actconfig->interface[i];
1708 if (is_active(intf)) {
1709 dev_dbg(&intf->dev, "nyet suspended\n");
1710 return -EBUSY;
1711 }
1712 }
1713 }
1714
1715 /* we only change a device's upstream USB link.
1716 * root hubs have no upstream USB link.
1717 */ 1576 */
1718 if (udev->parent) 1577 if (udev->parent)
1719 status = hub_port_suspend(hdev_to_hub(udev->parent), port1, 1578 status = hub_port_suspend(hdev_to_hub(udev->parent), port1,
1720 udev); 1579 udev);
1721 1580 else {
1722 if (status == 0) 1581 dev_dbg(&udev->dev, "usb %ssuspend\n",
1723 udev->dev.power.power_state = PMSG_SUSPEND; 1582 udev->auto_pm ? "auto-" : "");
1583 usb_set_device_state(udev, USB_STATE_SUSPENDED);
1584 }
1724 return status; 1585 return status;
1725} 1586}
1726 1587
1727#endif
1728
1729/* 1588/*
1730 * usb_suspend_device - suspend a usb device 1589 * usb_port_suspend - suspend a usb device's upstream port
1731 * @udev: device that's no longer in active use 1590 * @udev: device that's no longer in active use
1732 * Context: must be able to sleep; device not locked; pm locks held 1591 * Context: must be able to sleep; device not locked; pm locks held
1733 * 1592 *
1734 * Suspends a USB device that isn't in active use, conserving power. 1593 * Suspends a USB device that isn't in active use, conserving power.
1735 * Devices may wake out of a suspend, if anything important happens, 1594 * Devices may wake out of a suspend, if anything important happens,
1736 * using the remote wakeup mechanism. They may also be taken out of 1595 * using the remote wakeup mechanism. They may also be taken out of
1737 * suspend by the host, using usb_resume_device(). It's also routine 1596 * suspend by the host, using usb_port_resume(). It's also routine
1738 * to disconnect devices while they are suspended. 1597 * to disconnect devices while they are suspended.
1739 * 1598 *
1740 * This only affects the USB hardware for a device; its interfaces 1599 * This only affects the USB hardware for a device; its interfaces
@@ -1746,17 +1605,9 @@ static int __usb_suspend_device (struct usb_device *udev, int port1)
1746 * 1605 *
1747 * Returns 0 on success, else negative errno. 1606 * Returns 0 on success, else negative errno.
1748 */ 1607 */
1749int usb_suspend_device(struct usb_device *udev) 1608int usb_port_suspend(struct usb_device *udev)
1750{ 1609{
1751#ifdef CONFIG_USB_SUSPEND 1610 return __usb_port_suspend(udev, udev->portnum);
1752 if (udev->state == USB_STATE_NOTATTACHED)
1753 return -ENODEV;
1754 return __usb_suspend_device(udev, udev->portnum);
1755#else
1756 /* NOTE: udev->state unchanged, it's not lying ... */
1757 udev->dev.power.power_state = PMSG_SUSPEND;
1758 return 0;
1759#endif
1760} 1611}
1761 1612
1762/* 1613/*
@@ -1767,7 +1618,7 @@ int usb_suspend_device(struct usb_device *udev)
1767 * resume (by host) or remote wakeup (by device) ... now see what changed 1618 * resume (by host) or remote wakeup (by device) ... now see what changed
1768 * in the tree that's rooted at this device. 1619 * in the tree that's rooted at this device.
1769 */ 1620 */
1770static int finish_device_resume(struct usb_device *udev) 1621static int finish_port_resume(struct usb_device *udev)
1771{ 1622{
1772 int status; 1623 int status;
1773 u16 devstatus; 1624 u16 devstatus;
@@ -1783,7 +1634,6 @@ static int finish_device_resume(struct usb_device *udev)
1783 usb_set_device_state(udev, udev->actconfig 1634 usb_set_device_state(udev, udev->actconfig
1784 ? USB_STATE_CONFIGURED 1635 ? USB_STATE_CONFIGURED
1785 : USB_STATE_ADDRESS); 1636 : USB_STATE_ADDRESS);
1786 udev->dev.power.power_state = PMSG_ON;
1787 1637
1788 /* 10.5.4.5 says be sure devices in the tree are still there. 1638 /* 10.5.4.5 says be sure devices in the tree are still there.
1789 * For now let's assume the device didn't go crazy on resume, 1639 * For now let's assume the device didn't go crazy on resume,
@@ -1798,9 +1648,6 @@ static int finish_device_resume(struct usb_device *udev)
1798 "gone after usb resume? status %d\n", 1648 "gone after usb resume? status %d\n",
1799 status); 1649 status);
1800 else if (udev->actconfig) { 1650 else if (udev->actconfig) {
1801 unsigned i;
1802 int (*resume)(struct device *);
1803
1804 le16_to_cpus(&devstatus); 1651 le16_to_cpus(&devstatus);
1805 if ((devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP)) 1652 if ((devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
1806 && udev->parent) { 1653 && udev->parent) {
@@ -1811,24 +1658,9 @@ static int finish_device_resume(struct usb_device *udev)
1811 USB_DEVICE_REMOTE_WAKEUP, 0, 1658 USB_DEVICE_REMOTE_WAKEUP, 0,
1812 NULL, 0, 1659 NULL, 0,
1813 USB_CTRL_SET_TIMEOUT); 1660 USB_CTRL_SET_TIMEOUT);
1814 if (status) { 1661 if (status)
1815 dev_dbg(&udev->dev, "disable remote " 1662 dev_dbg(&udev->dev, "disable remote "
1816 "wakeup, status %d\n", status); 1663 "wakeup, status %d\n", status);
1817 status = 0;
1818 }
1819 }
1820
1821 /* resume interface drivers; if this is a hub, it
1822 * may have a child resume event to deal with soon
1823 */
1824 resume = udev->dev.bus->resume;
1825 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1826 struct device *dev =
1827 &udev->actconfig->interface[i]->dev;
1828
1829 down(&dev->sem);
1830 (void) resume(dev);
1831 up(&dev->sem);
1832 } 1664 }
1833 status = 0; 1665 status = 0;
1834 1666
@@ -1839,8 +1671,6 @@ static int finish_device_resume(struct usb_device *udev)
1839 return status; 1671 return status;
1840} 1672}
1841 1673
1842#ifdef CONFIG_USB_SUSPEND
1843
1844static int 1674static int
1845hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) 1675hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1846{ 1676{
@@ -1848,6 +1678,8 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1848 1678
1849 // dev_dbg(hub->intfdev, "resume port %d\n", port1); 1679 // dev_dbg(hub->intfdev, "resume port %d\n", port1);
1850 1680
1681 set_bit(port1, hub->busy_bits);
1682
1851 /* see 7.1.7.7; affects power usage, but not budgeting */ 1683 /* see 7.1.7.7; affects power usage, but not budgeting */
1852 status = clear_port_feature(hub->hdev, 1684 status = clear_port_feature(hub->hdev,
1853 port1, USB_PORT_FEAT_SUSPEND); 1685 port1, USB_PORT_FEAT_SUSPEND);
@@ -1861,7 +1693,8 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1861 1693
1862 /* drive resume for at least 20 msec */ 1694 /* drive resume for at least 20 msec */
1863 if (udev) 1695 if (udev)
1864 dev_dbg(&udev->dev, "RESUME\n"); 1696 dev_dbg(&udev->dev, "usb %sresume\n",
1697 udev->auto_pm ? "auto-" : "");
1865 msleep(25); 1698 msleep(25);
1866 1699
1867#define LIVE_FLAGS ( USB_PORT_STAT_POWER \ 1700#define LIVE_FLAGS ( USB_PORT_STAT_POWER \
@@ -1891,19 +1724,21 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1891 /* TRSMRCY = 10 msec */ 1724 /* TRSMRCY = 10 msec */
1892 msleep(10); 1725 msleep(10);
1893 if (udev) 1726 if (udev)
1894 status = finish_device_resume(udev); 1727 status = finish_port_resume(udev);
1895 } 1728 }
1896 } 1729 }
1897 if (status < 0) 1730 if (status < 0)
1898 hub_port_logical_disconnect(hub, port1); 1731 hub_port_logical_disconnect(hub, port1);
1899 1732
1733 clear_bit(port1, hub->busy_bits);
1734 if (!hub->hdev->parent && !hub->busy_bits[0])
1735 usb_enable_root_hub_irq(hub->hdev->bus);
1736
1900 return status; 1737 return status;
1901} 1738}
1902 1739
1903#endif
1904
1905/* 1740/*
1906 * usb_resume_device - re-activate a suspended usb device 1741 * usb_port_resume - re-activate a suspended usb device's upstream port
1907 * @udev: device to re-activate 1742 * @udev: device to re-activate
1908 * Context: must be able to sleep; device not locked; pm locks held 1743 * Context: must be able to sleep; device not locked; pm locks held
1909 * 1744 *
@@ -1915,36 +1750,24 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1915 * 1750 *
1916 * Returns 0 on success, else negative errno. 1751 * Returns 0 on success, else negative errno.
1917 */ 1752 */
1918int usb_resume_device(struct usb_device *udev) 1753int usb_port_resume(struct usb_device *udev)
1919{ 1754{
1920 int status; 1755 int status;
1921 1756
1922 if (udev->state == USB_STATE_NOTATTACHED) 1757 /* we change the device's upstream USB link,
1923 return -ENODEV; 1758 * but root hubs have no upstream USB link.
1924 1759 */
1925 /* selective resume of one downstream hub-to-device port */
1926 if (udev->parent) { 1760 if (udev->parent) {
1927#ifdef CONFIG_USB_SUSPEND 1761 // NOTE this fails if parent is also suspended...
1928 if (udev->state == USB_STATE_SUSPENDED) { 1762 status = hub_port_resume(hdev_to_hub(udev->parent),
1929 // NOTE swsusp may bork us, device state being wrong... 1763 udev->portnum, udev);
1930 // NOTE this fails if parent is also suspended... 1764 } else {
1931 status = hub_port_resume(hdev_to_hub(udev->parent), 1765 dev_dbg(&udev->dev, "usb %sresume\n",
1932 udev->portnum, udev); 1766 udev->auto_pm ? "auto-" : "");
1933 } else 1767 status = finish_port_resume(udev);
1934#endif
1935 status = 0;
1936 } else
1937 status = finish_device_resume(udev);
1938 if (status < 0)
1939 dev_dbg(&udev->dev, "can't resume, status %d\n",
1940 status);
1941
1942 /* rebind drivers that had no suspend() */
1943 if (status == 0) {
1944 usb_unlock_device(udev);
1945 bus_rescan_devices(&usb_bus_type);
1946 usb_lock_device(udev);
1947 } 1768 }
1769 if (status < 0)
1770 dev_dbg(&udev->dev, "can't resume, status %d\n", status);
1948 return status; 1771 return status;
1949} 1772}
1950 1773
@@ -1952,23 +1775,60 @@ static int remote_wakeup(struct usb_device *udev)
1952{ 1775{
1953 int status = 0; 1776 int status = 0;
1954 1777
1955#ifdef CONFIG_USB_SUSPEND 1778 /* All this just to avoid sending a port-resume message
1779 * to the parent hub! */
1956 1780
1957 /* don't repeat RESUME sequence if this device
1958 * was already woken up by some other task
1959 */
1960 usb_lock_device(udev); 1781 usb_lock_device(udev);
1782 mutex_lock_nested(&udev->pm_mutex, udev->level);
1961 if (udev->state == USB_STATE_SUSPENDED) { 1783 if (udev->state == USB_STATE_SUSPENDED) {
1962 dev_dbg(&udev->dev, "RESUME (wakeup)\n"); 1784 dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-");
1963 /* TRSMRCY = 10 msec */ 1785 /* TRSMRCY = 10 msec */
1964 msleep(10); 1786 msleep(10);
1965 status = finish_device_resume(udev); 1787 status = finish_port_resume(udev);
1788 if (status == 0)
1789 udev->dev.power.power_state.event = PM_EVENT_ON;
1966 } 1790 }
1791 mutex_unlock(&udev->pm_mutex);
1792
1793 if (status == 0)
1794 usb_autoresume_device(udev, 0);
1967 usb_unlock_device(udev); 1795 usb_unlock_device(udev);
1968#endif
1969 return status; 1796 return status;
1970} 1797}
1971 1798
1799#else /* CONFIG_USB_SUSPEND */
1800
1801/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */
1802
1803int usb_port_suspend(struct usb_device *udev)
1804{
1805 return 0;
1806}
1807
1808static inline int
1809finish_port_resume(struct usb_device *udev)
1810{
1811 return 0;
1812}
1813
1814static inline int
1815hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1816{
1817 return 0;
1818}
1819
1820int usb_port_resume(struct usb_device *udev)
1821{
1822 return 0;
1823}
1824
1825static inline int remote_wakeup(struct usb_device *udev)
1826{
1827 return 0;
1828}
1829
1830#endif
1831
1972static int hub_suspend(struct usb_interface *intf, pm_message_t msg) 1832static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1973{ 1833{
1974 struct usb_hub *hub = usb_get_intfdata (intf); 1834 struct usb_hub *hub = usb_get_intfdata (intf);
@@ -1980,13 +1840,17 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1980 struct usb_device *udev; 1840 struct usb_device *udev;
1981 1841
1982 udev = hdev->children [port1-1]; 1842 udev = hdev->children [port1-1];
1983 if (udev && (udev->dev.power.power_state.event 1843 if (udev && msg.event == PM_EVENT_SUSPEND &&
1984 == PM_EVENT_ON
1985#ifdef CONFIG_USB_SUSPEND 1844#ifdef CONFIG_USB_SUSPEND
1986 || udev->state != USB_STATE_SUSPENDED 1845 udev->state != USB_STATE_SUSPENDED
1846#else
1847 udev->dev.power.power_state.event
1848 == PM_EVENT_ON
1987#endif 1849#endif
1988 )) { 1850 ) {
1989 dev_dbg(&intf->dev, "port %d nyet suspended\n", port1); 1851 if (!hdev->auto_pm)
1852 dev_dbg(&intf->dev, "port %d nyet suspended\n",
1853 port1);
1990 return -EBUSY; 1854 return -EBUSY;
1991 } 1855 }
1992 } 1856 }
@@ -2035,66 +1899,22 @@ static int hub_resume(struct usb_interface *intf)
2035 } 1899 }
2036 } 1900 }
2037 1901
1902 /* tell khubd to look for changes on this hub */
2038 hub_activate(hub); 1903 hub_activate(hub);
2039
2040 /* REVISIT: this recursion probably shouldn't exist. Remove
2041 * this code sometime, after retesting with different root and
2042 * external hubs.
2043 */
2044#ifdef CONFIG_USB_SUSPEND
2045 {
2046 unsigned port1;
2047
2048 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
2049 struct usb_device *udev;
2050 u16 portstat, portchange;
2051
2052 udev = hdev->children [port1-1];
2053 status = hub_port_status(hub, port1, &portstat, &portchange);
2054 if (status == 0) {
2055 if (portchange & USB_PORT_STAT_C_SUSPEND) {
2056 clear_port_feature(hdev, port1,
2057 USB_PORT_FEAT_C_SUSPEND);
2058 portchange &= ~USB_PORT_STAT_C_SUSPEND;
2059 }
2060
2061 /* let khubd handle disconnects etc */
2062 if (portchange)
2063 continue;
2064 }
2065
2066 if (!udev || status < 0)
2067 continue;
2068 usb_lock_device(udev);
2069 if (portstat & USB_PORT_STAT_SUSPEND)
2070 status = hub_port_resume(hub, port1, udev);
2071 else {
2072 status = finish_device_resume(udev);
2073 if (status < 0) {
2074 dev_dbg(&intf->dev, "resume port %d --> %d\n",
2075 port1, status);
2076 hub_port_logical_disconnect(hub, port1);
2077 }
2078 }
2079 usb_unlock_device(udev);
2080 }
2081 }
2082#endif
2083 return 0; 1904 return 0;
2084} 1905}
2085 1906
2086void usb_suspend_root_hub(struct usb_device *hdev) 1907#else /* CONFIG_PM */
2087{
2088 struct usb_hub *hub = hdev_to_hub(hdev);
2089 1908
2090 /* This also makes any led blinker stop retriggering. We're called 1909static inline int remote_wakeup(struct usb_device *udev)
2091 * from irq, so the blinker might still be scheduled. Caller promises 1910{
2092 * that the root hub status URB will be canceled. 1911 return 0;
2093 */
2094 __hub_quiesce(hub);
2095 mark_quiesced(to_usb_interface(hub->intfdev));
2096} 1912}
2097 1913
1914#define hub_suspend NULL
1915#define hub_resume NULL
1916#endif
1917
2098void usb_resume_root_hub(struct usb_device *hdev) 1918void usb_resume_root_hub(struct usb_device *hdev)
2099{ 1919{
2100 struct usb_hub *hub = hdev_to_hub(hdev); 1920 struct usb_hub *hub = hdev_to_hub(hdev);
@@ -2214,6 +2034,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2214 int i, j, retval; 2034 int i, j, retval;
2215 unsigned delay = HUB_SHORT_RESET_TIME; 2035 unsigned delay = HUB_SHORT_RESET_TIME;
2216 enum usb_device_speed oldspeed = udev->speed; 2036 enum usb_device_speed oldspeed = udev->speed;
2037 char *speed, *type;
2217 2038
2218 /* root hub ports have a slightly longer reset period 2039 /* root hub ports have a slightly longer reset period
2219 * (from USB 2.0 spec, section 7.1.7.5) 2040 * (from USB 2.0 spec, section 7.1.7.5)
@@ -2246,8 +2067,13 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2246 2067
2247 /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ... 2068 /* USB 2.0 section 5.5.3 talks about ep0 maxpacket ...
2248 * it's fixed size except for full speed devices. 2069 * it's fixed size except for full speed devices.
2070 * For Wireless USB devices, ep0 max packet is always 512 (tho
2071 * reported as 0xff in the device descriptor). WUSB1.0[4.8.1].
2249 */ 2072 */
2250 switch (udev->speed) { 2073 switch (udev->speed) {
2074 case USB_SPEED_VARIABLE: /* fixed at 512 */
2075 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(512);
2076 break;
2251 case USB_SPEED_HIGH: /* fixed at 64 */ 2077 case USB_SPEED_HIGH: /* fixed at 64 */
2252 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64); 2078 udev->ep0.desc.wMaxPacketSize = __constant_cpu_to_le16(64);
2253 break; 2079 break;
@@ -2265,17 +2091,21 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2265 goto fail; 2091 goto fail;
2266 } 2092 }
2267 2093
2094 type = "";
2095 switch (udev->speed) {
2096 case USB_SPEED_LOW: speed = "low"; break;
2097 case USB_SPEED_FULL: speed = "full"; break;
2098 case USB_SPEED_HIGH: speed = "high"; break;
2099 case USB_SPEED_VARIABLE:
2100 speed = "variable";
2101 type = "Wireless ";
2102 break;
2103 default: speed = "?"; break;
2104 }
2268 dev_info (&udev->dev, 2105 dev_info (&udev->dev,
2269 "%s %s speed USB device using %s and address %d\n", 2106 "%s %s speed %sUSB device using %s and address %d\n",
2270 (udev->config) ? "reset" : "new", 2107 (udev->config) ? "reset" : "new", speed, type,
2271 ({ char *speed; switch (udev->speed) { 2108 udev->bus->controller->driver->name, udev->devnum);
2272 case USB_SPEED_LOW: speed = "low"; break;
2273 case USB_SPEED_FULL: speed = "full"; break;
2274 case USB_SPEED_HIGH: speed = "high"; break;
2275 default: speed = "?"; break;
2276 }; speed;}),
2277 udev->bus->controller->driver->name,
2278 udev->devnum);
2279 2109
2280 /* Set up TT records, if needed */ 2110 /* Set up TT records, if needed */
2281 if (hdev->tt) { 2111 if (hdev->tt) {
@@ -2317,6 +2147,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2317 * down tremendously by NAKing the unexpectedly 2147 * down tremendously by NAKing the unexpectedly
2318 * early status stage. Also, retry on all errors; 2148 * early status stage. Also, retry on all errors;
2319 * some devices are flakey. 2149 * some devices are flakey.
2150 * 255 is for WUSB devices, we actually need to use 512.
2151 * WUSB1.0[4.8.1].
2320 */ 2152 */
2321 for (j = 0; j < 3; ++j) { 2153 for (j = 0; j < 3; ++j) {
2322 buf->bMaxPacketSize0 = 0; 2154 buf->bMaxPacketSize0 = 0;
@@ -2326,7 +2158,7 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2326 buf, GET_DESCRIPTOR_BUFSIZE, 2158 buf, GET_DESCRIPTOR_BUFSIZE,
2327 (i ? USB_CTRL_GET_TIMEOUT : 1000)); 2159 (i ? USB_CTRL_GET_TIMEOUT : 1000));
2328 switch (buf->bMaxPacketSize0) { 2160 switch (buf->bMaxPacketSize0) {
2329 case 8: case 16: case 32: case 64: 2161 case 8: case 16: case 32: case 64: case 255:
2330 if (buf->bDescriptorType == 2162 if (buf->bDescriptorType ==
2331 USB_DT_DEVICE) { 2163 USB_DT_DEVICE) {
2332 r = 0; 2164 r = 0;
@@ -2400,7 +2232,8 @@ hub_port_init (struct usb_hub *hub, struct usb_device *udev, int port1,
2400 if (retval) 2232 if (retval)
2401 goto fail; 2233 goto fail;
2402 2234
2403 i = udev->descriptor.bMaxPacketSize0; 2235 i = udev->descriptor.bMaxPacketSize0 == 0xff?
2236 512 : udev->descriptor.bMaxPacketSize0;
2404 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) { 2237 if (le16_to_cpu(udev->ep0.desc.wMaxPacketSize) != i) {
2405 if (udev->speed != USB_SPEED_FULL || 2238 if (udev->speed != USB_SPEED_FULL ||
2406 !(i == 8 || i == 16 || i == 32 || i == 64)) { 2239 !(i == 8 || i == 16 || i == 32 || i == 64)) {
@@ -2585,6 +2418,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2585 usb_set_device_state(udev, USB_STATE_POWERED); 2418 usb_set_device_state(udev, USB_STATE_POWERED);
2586 udev->speed = USB_SPEED_UNKNOWN; 2419 udev->speed = USB_SPEED_UNKNOWN;
2587 udev->bus_mA = hub->mA_per_port; 2420 udev->bus_mA = hub->mA_per_port;
2421 udev->level = hdev->level + 1;
2588 2422
2589 /* set the address */ 2423 /* set the address */
2590 choose_address(udev); 2424 choose_address(udev);
@@ -2736,17 +2570,6 @@ static void hub_events(void)
2736 usb_get_intf(intf); 2570 usb_get_intf(intf);
2737 spin_unlock_irq(&hub_event_lock); 2571 spin_unlock_irq(&hub_event_lock);
2738 2572
2739 /* Is this is a root hub wanting to reactivate the downstream
2740 * ports? If so, be sure the interface resumes even if its
2741 * stub "device" node was never suspended.
2742 */
2743 if (i) {
2744 dpm_runtime_resume(&hdev->dev);
2745 dpm_runtime_resume(&intf->dev);
2746 usb_put_intf(intf);
2747 continue;
2748 }
2749
2750 /* Lock the device, then check to see if we were 2573 /* Lock the device, then check to see if we were
2751 * disconnected while waiting for the lock to succeed. */ 2574 * disconnected while waiting for the lock to succeed. */
2752 if (locktree(hdev) < 0) { 2575 if (locktree(hdev) < 0) {
@@ -2763,6 +2586,13 @@ static void hub_events(void)
2763 goto loop; 2586 goto loop;
2764 } 2587 }
2765 2588
2589 /* Is this is a root hub wanting to reactivate the downstream
2590 * ports? If so, be sure the interface resumes even if its
2591 * stub "device" node was never suspended.
2592 */
2593 if (i)
2594 usb_autoresume_device(hdev, 0);
2595
2766 /* If this is an inactive or suspended hub, do nothing */ 2596 /* If this is an inactive or suspended hub, do nothing */
2767 if (hub->quiescing) 2597 if (hub->quiescing)
2768 goto loop; 2598 goto loop;
@@ -2900,7 +2730,7 @@ static void hub_events(void)
2900 2730
2901 /* If this is a root hub, tell the HCD it's okay to 2731 /* If this is a root hub, tell the HCD it's okay to
2902 * re-enable port-change interrupts now. */ 2732 * re-enable port-change interrupts now. */
2903 if (!hdev->parent) 2733 if (!hdev->parent && !hub->busy_bits[0])
2904 usb_enable_root_hub_irq(hdev->bus); 2734 usb_enable_root_hub_irq(hdev->bus);
2905 2735
2906loop: 2736loop:
@@ -3075,6 +2905,9 @@ int usb_reset_device(struct usb_device *udev)
3075 break; 2905 break;
3076 } 2906 }
3077 clear_bit(port1, parent_hub->busy_bits); 2907 clear_bit(port1, parent_hub->busy_bits);
2908 if (!parent_hdev->parent && !parent_hub->busy_bits[0])
2909 usb_enable_root_hub_irq(parent_hdev->bus);
2910
3078 if (ret < 0) 2911 if (ret < 0)
3079 goto re_enumerate; 2912 goto re_enumerate;
3080 2913
@@ -3128,6 +2961,7 @@ re_enumerate:
3128 hub_port_logical_disconnect(parent_hub, port1); 2961 hub_port_logical_disconnect(parent_hub, port1);
3129 return -ENODEV; 2962 return -ENODEV;
3130} 2963}
2964EXPORT_SYMBOL(usb_reset_device);
3131 2965
3132/** 2966/**
3133 * usb_reset_composite_device - warn interface drivers and perform a USB port reset 2967 * usb_reset_composite_device - warn interface drivers and perform a USB port reset
@@ -3163,6 +2997,9 @@ int usb_reset_composite_device(struct usb_device *udev,
3163 return -EINVAL; 2997 return -EINVAL;
3164 } 2998 }
3165 2999
3000 /* Prevent autosuspend during the reset */
3001 usb_autoresume_device(udev, 1);
3002
3166 if (iface && iface->condition != USB_INTERFACE_BINDING) 3003 if (iface && iface->condition != USB_INTERFACE_BINDING)
3167 iface = NULL; 3004 iface = NULL;
3168 3005
@@ -3204,5 +3041,7 @@ int usb_reset_composite_device(struct usb_device *udev,
3204 } 3041 }
3205 } 3042 }
3206 3043
3044 usb_autosuspend_device(udev, 1);
3207 return ret; 3045 return ret;
3208} 3046}
3047EXPORT_SYMBOL(usb_reset_composite_device);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index 29d5f45a8456..0f8e82a4d480 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -212,7 +212,8 @@ struct usb_hub {
212 unsigned long event_bits[1]; /* status change bitmask */ 212 unsigned long event_bits[1]; /* status change bitmask */
213 unsigned long change_bits[1]; /* ports with logical connect 213 unsigned long change_bits[1]; /* ports with logical connect
214 status change */ 214 status change */
215 unsigned long busy_bits[1]; /* ports being reset */ 215 unsigned long busy_bits[1]; /* ports being reset or
216 resumed */
216#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ 217#if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */
217#error event_bits[] is too short! 218#error event_bits[] is too short!
218#endif 219#endif
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 3182c2224ba2..df3d152f0493 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -44,7 +44,7 @@
44#include "hcd.h" 44#include "hcd.h"
45 45
46static struct super_operations usbfs_ops; 46static struct super_operations usbfs_ops;
47static struct file_operations default_file_operations; 47static const struct file_operations default_file_operations;
48static struct vfsmount *usbfs_mount; 48static struct vfsmount *usbfs_mount;
49static int usbfs_mount_count; /* = 0 */ 49static int usbfs_mount_count; /* = 0 */
50static int ignore_mount = 0; 50static int ignore_mount = 0;
@@ -249,7 +249,6 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
249 inode->i_mode = mode; 249 inode->i_mode = mode;
250 inode->i_uid = current->fsuid; 250 inode->i_uid = current->fsuid;
251 inode->i_gid = current->fsgid; 251 inode->i_gid = current->fsgid;
252 inode->i_blksize = PAGE_CACHE_SIZE;
253 inode->i_blocks = 0; 252 inode->i_blocks = 0;
254 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 253 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
255 switch (mode & S_IFMT) { 254 switch (mode & S_IFMT) {
@@ -402,13 +401,13 @@ static loff_t default_file_lseek (struct file *file, loff_t offset, int orig)
402 401
403static int default_open (struct inode *inode, struct file *file) 402static int default_open (struct inode *inode, struct file *file)
404{ 403{
405 if (inode->u.generic_ip) 404 if (inode->i_private)
406 file->private_data = inode->u.generic_ip; 405 file->private_data = inode->i_private;
407 406
408 return 0; 407 return 0;
409} 408}
410 409
411static struct file_operations default_file_operations = { 410static const struct file_operations default_file_operations = {
412 .read = default_read_file, 411 .read = default_read_file,
413 .write = default_write_file, 412 .write = default_write_file,
414 .open = default_open, 413 .open = default_open,
@@ -495,7 +494,7 @@ static int fs_create_by_name (const char *name, mode_t mode,
495 494
496static struct dentry *fs_create_file (const char *name, mode_t mode, 495static struct dentry *fs_create_file (const char *name, mode_t mode,
497 struct dentry *parent, void *data, 496 struct dentry *parent, void *data,
498 struct file_operations *fops, 497 const struct file_operations *fops,
499 uid_t uid, gid_t gid) 498 uid_t uid, gid_t gid)
500{ 499{
501 struct dentry *dentry; 500 struct dentry *dentry;
@@ -509,7 +508,7 @@ static struct dentry *fs_create_file (const char *name, mode_t mode,
509 } else { 508 } else {
510 if (dentry->d_inode) { 509 if (dentry->d_inode) {
511 if (data) 510 if (data)
512 dentry->d_inode->u.generic_ip = data; 511 dentry->d_inode->i_private = data;
513 if (fops) 512 if (fops)
514 dentry->d_inode->i_fop = fops; 513 dentry->d_inode->i_fop = fops;
515 dentry->d_inode->i_uid = uid; 514 dentry->d_inode->i_uid = uid;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 4cc8d3e67db7..85b1cd18336f 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -23,59 +23,44 @@ static void usb_api_blocking_completion(struct urb *urb, struct pt_regs *regs)
23} 23}
24 24
25 25
26static void timeout_kill(unsigned long data) 26/*
27{ 27 * Starts urb and waits for completion or timeout. Note that this call
28 struct urb *urb = (struct urb *) data; 28 * is NOT interruptible. Many device driver i/o requests should be
29 29 * interruptible and therefore these drivers should implement their
30 usb_unlink_urb(urb); 30 * own interruptible routines.
31} 31 */
32 32static int usb_start_wait_urb(struct urb *urb, int timeout, int *actual_length)
33// Starts urb and waits for completion or timeout
34// note that this call is NOT interruptible, while
35// many device driver i/o requests should be interruptible
36static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length)
37{ 33{
38 struct completion done; 34 struct completion done;
39 struct timer_list timer; 35 unsigned long expire;
40 int status; 36 int status;
41 37
42 init_completion(&done); 38 init_completion(&done);
43 urb->context = &done; 39 urb->context = &done;
44 urb->actual_length = 0; 40 urb->actual_length = 0;
45 status = usb_submit_urb(urb, GFP_NOIO); 41 status = usb_submit_urb(urb, GFP_NOIO);
46 42 if (unlikely(status))
47 if (status == 0) { 43 goto out;
48 if (timeout > 0) { 44
49 init_timer(&timer); 45 expire = timeout ? msecs_to_jiffies(timeout) : MAX_SCHEDULE_TIMEOUT;
50 timer.expires = jiffies + msecs_to_jiffies(timeout); 46 if (!wait_for_completion_timeout(&done, expire)) {
51 timer.data = (unsigned long)urb; 47
52 timer.function = timeout_kill; 48 dev_dbg(&urb->dev->dev,
53 /* grr. timeout _should_ include submit delays. */ 49 "%s timed out on ep%d%s len=%d/%d\n",
54 add_timer(&timer); 50 current->comm,
55 } 51 usb_pipeendpoint(urb->pipe),
56 wait_for_completion(&done); 52 usb_pipein(urb->pipe) ? "in" : "out",
53 urb->actual_length,
54 urb->transfer_buffer_length);
55
56 usb_kill_urb(urb);
57 status = urb->status == -ENOENT ? -ETIMEDOUT : urb->status;
58 } else
57 status = urb->status; 59 status = urb->status;
58 /* note: HCDs return ETIMEDOUT for other reasons too */ 60out:
59 if (status == -ECONNRESET) {
60 dev_dbg(&urb->dev->dev,
61 "%s timed out on ep%d%s len=%d/%d\n",
62 current->comm,
63 usb_pipeendpoint(urb->pipe),
64 usb_pipein(urb->pipe) ? "in" : "out",
65 urb->actual_length,
66 urb->transfer_buffer_length
67 );
68 if (urb->actual_length > 0)
69 status = 0;
70 else
71 status = -ETIMEDOUT;
72 }
73 if (timeout > 0)
74 del_timer_sync(&timer);
75 }
76
77 if (actual_length) 61 if (actual_length)
78 *actual_length = urb->actual_length; 62 *actual_length = urb->actual_length;
63
79 usb_free_urb(urb); 64 usb_free_urb(urb);
80 return status; 65 return status;
81} 66}
@@ -263,7 +248,7 @@ static void sg_clean (struct usb_sg_request *io)
263 248
264static void sg_complete (struct urb *urb, struct pt_regs *regs) 249static void sg_complete (struct urb *urb, struct pt_regs *regs)
265{ 250{
266 struct usb_sg_request *io = (struct usb_sg_request *) urb->context; 251 struct usb_sg_request *io = urb->context;
267 252
268 spin_lock (&io->lock); 253 spin_lock (&io->lock);
269 254
@@ -999,8 +984,8 @@ void usb_disable_endpoint(struct usb_device *dev, unsigned int epaddr)
999 ep = dev->ep_in[epnum]; 984 ep = dev->ep_in[epnum];
1000 dev->ep_in[epnum] = NULL; 985 dev->ep_in[epnum] = NULL;
1001 } 986 }
1002 if (ep && dev->bus && dev->bus->op && dev->bus->op->disable) 987 if (ep && dev->bus)
1003 dev->bus->op->disable(dev, ep); 988 usb_hcd_endpoint_disable(dev, ep);
1004} 989}
1005 990
1006/** 991/**
@@ -1381,9 +1366,6 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
1381 if (cp && configuration == 0) 1366 if (cp && configuration == 0)
1382 dev_warn(&dev->dev, "config 0 descriptor??\n"); 1367 dev_warn(&dev->dev, "config 0 descriptor??\n");
1383 1368
1384 if (dev->state == USB_STATE_SUSPENDED)
1385 return -EHOSTUNREACH;
1386
1387 /* Allocate memory for new interfaces before doing anything else, 1369 /* Allocate memory for new interfaces before doing anything else,
1388 * so that if we run out then nothing will have changed. */ 1370 * so that if we run out then nothing will have changed. */
1389 n = nintf = 0; 1371 n = nintf = 0;
@@ -1418,6 +1400,11 @@ free_interfaces:
1418 configuration, -i); 1400 configuration, -i);
1419 } 1401 }
1420 1402
1403 /* Wake up the device so we can send it the Set-Config request */
1404 ret = usb_autoresume_device(dev, 1);
1405 if (ret)
1406 goto free_interfaces;
1407
1421 /* if it's already configured, clear out old state first. 1408 /* if it's already configured, clear out old state first.
1422 * getting rid of old interfaces means unbinding their drivers. 1409 * getting rid of old interfaces means unbinding their drivers.
1423 */ 1410 */
@@ -1437,6 +1424,7 @@ free_interfaces:
1437 dev->actconfig = cp; 1424 dev->actconfig = cp;
1438 if (!cp) { 1425 if (!cp) {
1439 usb_set_device_state(dev, USB_STATE_ADDRESS); 1426 usb_set_device_state(dev, USB_STATE_ADDRESS);
1427 usb_autosuspend_device(dev, 1);
1440 goto free_interfaces; 1428 goto free_interfaces;
1441 } 1429 }
1442 usb_set_device_state(dev, USB_STATE_CONFIGURED); 1430 usb_set_device_state(dev, USB_STATE_CONFIGURED);
@@ -1505,8 +1493,68 @@ free_interfaces:
1505 usb_create_sysfs_intf_files (intf); 1493 usb_create_sysfs_intf_files (intf);
1506 } 1494 }
1507 1495
1496 usb_autosuspend_device(dev, 1);
1497 return 0;
1498}
1499
1500struct set_config_request {
1501 struct usb_device *udev;
1502 int config;
1503 struct work_struct work;
1504};
1505
1506/* Worker routine for usb_driver_set_configuration() */
1507static void driver_set_config_work(void *_req)
1508{
1509 struct set_config_request *req = _req;
1510
1511 usb_lock_device(req->udev);
1512 usb_set_configuration(req->udev, req->config);
1513 usb_unlock_device(req->udev);
1514 usb_put_dev(req->udev);
1515 kfree(req);
1516}
1517
1518/**
1519 * usb_driver_set_configuration - Provide a way for drivers to change device configurations
1520 * @udev: the device whose configuration is being updated
1521 * @config: the configuration being chosen.
1522 * Context: In process context, must be able to sleep
1523 *
1524 * Device interface drivers are not allowed to change device configurations.
1525 * This is because changing configurations will destroy the interface the
1526 * driver is bound to and create new ones; it would be like a floppy-disk
1527 * driver telling the computer to replace the floppy-disk drive with a
1528 * tape drive!
1529 *
1530 * Still, in certain specialized circumstances the need may arise. This
1531 * routine gets around the normal restrictions by using a work thread to
1532 * submit the change-config request.
1533 *
1534 * Returns 0 if the request was succesfully queued, error code otherwise.
1535 * The caller has no way to know whether the queued request will eventually
1536 * succeed.
1537 */
1538int usb_driver_set_configuration(struct usb_device *udev, int config)
1539{
1540 struct set_config_request *req;
1541
1542 req = kmalloc(sizeof(*req), GFP_KERNEL);
1543 if (!req)
1544 return -ENOMEM;
1545 req->udev = udev;
1546 req->config = config;
1547 INIT_WORK(&req->work, driver_set_config_work, req);
1548
1549 usb_get_dev(udev);
1550 if (!schedule_work(&req->work)) {
1551 usb_put_dev(udev);
1552 kfree(req);
1553 return -EINVAL;
1554 }
1508 return 0; 1555 return 0;
1509} 1556}
1557EXPORT_SYMBOL_GPL(usb_driver_set_configuration);
1510 1558
1511// synchronous request completion model 1559// synchronous request completion model
1512EXPORT_SYMBOL(usb_control_msg); 1560EXPORT_SYMBOL(usb_control_msg);
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c
index b042676af0a5..6b36897ca151 100644
--- a/drivers/usb/core/notify.c
+++ b/drivers/usb/core/notify.c
@@ -50,8 +50,11 @@ void usb_notify_add_device(struct usb_device *udev)
50 50
51void usb_notify_remove_device(struct usb_device *udev) 51void usb_notify_remove_device(struct usb_device *udev)
52{ 52{
53 /* Protect against simultaneous usbfs open */
54 mutex_lock(&usbfs_mutex);
53 blocking_notifier_call_chain(&usb_notifier_list, 55 blocking_notifier_call_chain(&usb_notifier_list,
54 USB_DEVICE_REMOVE, udev); 56 USB_DEVICE_REMOVE, udev);
57 mutex_unlock(&usbfs_mutex);
55} 58}
56 59
57void usb_notify_add_bus(struct usb_bus *ubus) 60void usb_notify_add_bus(struct usb_bus *ubus)
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index dec973affb0f..55d8f575206d 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -60,7 +60,7 @@ static ssize_t
60set_bConfigurationValue (struct device *dev, struct device_attribute *attr, 60set_bConfigurationValue (struct device *dev, struct device_attribute *attr,
61 const char *buf, size_t count) 61 const char *buf, size_t count)
62{ 62{
63 struct usb_device *udev = udev = to_usb_device (dev); 63 struct usb_device *udev = to_usb_device (dev);
64 int config, value; 64 int config, value;
65 65
66 if (sscanf (buf, "%u", &config) != 1 || config > 255) 66 if (sscanf (buf, "%u", &config) != 1 || config > 255)
@@ -186,6 +186,7 @@ usb_descriptor_attr (bMaxPacketSize0, "%d\n")
186 186
187static struct attribute *dev_attrs[] = { 187static struct attribute *dev_attrs[] = {
188 /* current configuration's attributes */ 188 /* current configuration's attributes */
189 &dev_attr_configuration.attr,
189 &dev_attr_bNumInterfaces.attr, 190 &dev_attr_bNumInterfaces.attr,
190 &dev_attr_bConfigurationValue.attr, 191 &dev_attr_bConfigurationValue.attr,
191 &dev_attr_bmAttributes.attr, 192 &dev_attr_bmAttributes.attr,
@@ -209,20 +210,40 @@ static struct attribute_group dev_attr_grp = {
209 .attrs = dev_attrs, 210 .attrs = dev_attrs,
210}; 211};
211 212
212void usb_create_sysfs_dev_files (struct usb_device *udev) 213int usb_create_sysfs_dev_files(struct usb_device *udev)
213{ 214{
214 struct device *dev = &udev->dev; 215 struct device *dev = &udev->dev;
216 int retval;
215 217
216 sysfs_create_group(&dev->kobj, &dev_attr_grp); 218 retval = sysfs_create_group(&dev->kobj, &dev_attr_grp);
219 if (retval)
220 return retval;
217 221
218 if (udev->manufacturer) 222 if (udev->manufacturer) {
219 device_create_file (dev, &dev_attr_manufacturer); 223 retval = device_create_file (dev, &dev_attr_manufacturer);
220 if (udev->product) 224 if (retval)
221 device_create_file (dev, &dev_attr_product); 225 goto error;
222 if (udev->serial) 226 }
223 device_create_file (dev, &dev_attr_serial); 227 if (udev->product) {
224 device_create_file (dev, &dev_attr_configuration); 228 retval = device_create_file (dev, &dev_attr_product);
225 usb_create_ep_files(dev, &udev->ep0, udev); 229 if (retval)
230 goto error;
231 }
232 if (udev->serial) {
233 retval = device_create_file (dev, &dev_attr_serial);
234 if (retval)
235 goto error;
236 }
237 retval = usb_create_ep_files(dev, &udev->ep0, udev);
238 if (retval)
239 goto error;
240 return 0;
241error:
242 usb_remove_ep_files(&udev->ep0);
243 device_remove_file(dev, &dev_attr_manufacturer);
244 device_remove_file(dev, &dev_attr_product);
245 device_remove_file(dev, &dev_attr_serial);
246 return retval;
226} 247}
227 248
228void usb_remove_sysfs_dev_files (struct usb_device *udev) 249void usb_remove_sysfs_dev_files (struct usb_device *udev)
@@ -238,7 +259,6 @@ void usb_remove_sysfs_dev_files (struct usb_device *udev)
238 device_remove_file(dev, &dev_attr_product); 259 device_remove_file(dev, &dev_attr_product);
239 if (udev->serial) 260 if (udev->serial)
240 device_remove_file(dev, &dev_attr_serial); 261 device_remove_file(dev, &dev_attr_serial);
241 device_remove_file (dev, &dev_attr_configuration);
242} 262}
243 263
244/* Interface fields */ 264/* Interface fields */
@@ -340,18 +360,28 @@ static inline void usb_remove_intf_ep_files(struct usb_interface *intf)
340 usb_remove_ep_files(&iface_desc->endpoint[i]); 360 usb_remove_ep_files(&iface_desc->endpoint[i]);
341} 361}
342 362
343void usb_create_sysfs_intf_files (struct usb_interface *intf) 363int usb_create_sysfs_intf_files(struct usb_interface *intf)
344{ 364{
345 struct usb_device *udev = interface_to_usbdev(intf); 365 struct usb_device *udev = interface_to_usbdev(intf);
346 struct usb_host_interface *alt = intf->cur_altsetting; 366 struct usb_host_interface *alt = intf->cur_altsetting;
367 int retval;
347 368
348 sysfs_create_group(&intf->dev.kobj, &intf_attr_grp); 369 retval = sysfs_create_group(&intf->dev.kobj, &intf_attr_grp);
370 if (retval)
371 goto error;
349 372
350 if (alt->string == NULL) 373 if (alt->string == NULL)
351 alt->string = usb_cache_string(udev, alt->desc.iInterface); 374 alt->string = usb_cache_string(udev, alt->desc.iInterface);
352 if (alt->string) 375 if (alt->string)
353 device_create_file(&intf->dev, &dev_attr_interface); 376 retval = device_create_file(&intf->dev, &dev_attr_interface);
354 usb_create_intf_ep_files(intf, udev); 377 usb_create_intf_ep_files(intf, udev);
378 return 0;
379error:
380 if (alt->string)
381 device_remove_file(&intf->dev, &dev_attr_interface);
382 sysfs_remove_group(&intf->dev.kobj, &intf_attr_grp);
383 usb_remove_intf_ep_files(intf);
384 return retval;
355} 385}
356 386
357void usb_remove_sysfs_intf_files (struct usb_interface *intf) 387void usb_remove_sysfs_intf_files (struct usb_interface *intf)
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 9864988377c7..9801d08edacf 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -57,7 +57,7 @@ struct urb *usb_alloc_urb(int iso_packets, gfp_t mem_flags)
57{ 57{
58 struct urb *urb; 58 struct urb *urb;
59 59
60 urb = (struct urb *)kmalloc(sizeof(struct urb) + 60 urb = kmalloc(sizeof(struct urb) +
61 iso_packets * sizeof(struct usb_iso_packet_descriptor), 61 iso_packets * sizeof(struct usb_iso_packet_descriptor),
62 mem_flags); 62 mem_flags);
63 if (!urb) { 63 if (!urb) {
@@ -221,7 +221,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
221{ 221{
222 int pipe, temp, max; 222 int pipe, temp, max;
223 struct usb_device *dev; 223 struct usb_device *dev;
224 struct usb_operations *op;
225 int is_out; 224 int is_out;
226 225
227 if (!urb || urb->hcpriv || !urb->complete) 226 if (!urb || urb->hcpriv || !urb->complete)
@@ -233,8 +232,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
233 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON 232 if (dev->bus->controller->power.power_state.event != PM_EVENT_ON
234 || dev->state == USB_STATE_SUSPENDED) 233 || dev->state == USB_STATE_SUSPENDED)
235 return -EHOSTUNREACH; 234 return -EHOSTUNREACH;
236 if (!(op = dev->bus->op) || !op->submit_urb)
237 return -ENODEV;
238 235
239 urb->status = -EINPROGRESS; 236 urb->status = -EINPROGRESS;
240 urb->actual_length = 0; 237 urb->actual_length = 0;
@@ -376,7 +373,7 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
376 urb->interval = temp; 373 urb->interval = temp;
377 } 374 }
378 375
379 return op->submit_urb (urb, mem_flags); 376 return usb_hcd_submit_urb (urb, mem_flags);
380} 377}
381 378
382/*-------------------------------------------------------------------*/ 379/*-------------------------------------------------------------------*/
@@ -440,9 +437,9 @@ int usb_unlink_urb(struct urb *urb)
440{ 437{
441 if (!urb) 438 if (!urb)
442 return -EINVAL; 439 return -EINVAL;
443 if (!(urb->dev && urb->dev->bus && urb->dev->bus->op)) 440 if (!(urb->dev && urb->dev->bus))
444 return -ENODEV; 441 return -ENODEV;
445 return urb->dev->bus->op->unlink_urb(urb, -ECONNRESET); 442 return usb_hcd_unlink_urb(urb, -ECONNRESET);
446} 443}
447 444
448/** 445/**
@@ -468,13 +465,13 @@ int usb_unlink_urb(struct urb *urb)
468void usb_kill_urb(struct urb *urb) 465void usb_kill_urb(struct urb *urb)
469{ 466{
470 might_sleep(); 467 might_sleep();
471 if (!(urb && urb->dev && urb->dev->bus && urb->dev->bus->op)) 468 if (!(urb && urb->dev && urb->dev->bus))
472 return; 469 return;
473 spin_lock_irq(&urb->lock); 470 spin_lock_irq(&urb->lock);
474 ++urb->reject; 471 ++urb->reject;
475 spin_unlock_irq(&urb->lock); 472 spin_unlock_irq(&urb->lock);
476 473
477 urb->dev->bus->op->unlink_urb(urb, -ENOENT); 474 usb_hcd_unlink_urb(urb, -ENOENT);
478 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 475 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
479 476
480 spin_lock_irq(&urb->lock); 477 spin_lock_irq(&urb->lock);
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 184c24660a4c..60ef4ef0101a 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -67,7 +67,8 @@ static int nousb; /* Disable USB when built into kernel image */
67 * Don't call this function unless you are bound to one of the interfaces 67 * Don't call this function unless you are bound to one of the interfaces
68 * on this device or you have locked the device! 68 * on this device or you have locked the device!
69 */ 69 */
70struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum) 70struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
71 unsigned ifnum)
71{ 72{
72 struct usb_host_config *config = dev->actconfig; 73 struct usb_host_config *config = dev->actconfig;
73 int i; 74 int i;
@@ -100,8 +101,8 @@ struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, unsigned ifnum)
100 * Don't call this function unless you are bound to the intf interface 101 * Don't call this function unless you are bound to the intf interface
101 * or you have locked the device! 102 * or you have locked the device!
102 */ 103 */
103struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf, 104struct usb_host_interface *usb_altnum_to_altsetting(const struct usb_interface *intf,
104 unsigned int altnum) 105 unsigned int altnum)
105{ 106{
106 int i; 107 int i;
107 108
@@ -112,87 +113,6 @@ struct usb_host_interface *usb_altnum_to_altsetting(struct usb_interface *intf,
112 return NULL; 113 return NULL;
113} 114}
114 115
115/**
116 * usb_driver_claim_interface - bind a driver to an interface
117 * @driver: the driver to be bound
118 * @iface: the interface to which it will be bound; must be in the
119 * usb device's active configuration
120 * @priv: driver data associated with that interface
121 *
122 * This is used by usb device drivers that need to claim more than one
123 * interface on a device when probing (audio and acm are current examples).
124 * No device driver should directly modify internal usb_interface or
125 * usb_device structure members.
126 *
127 * Few drivers should need to use this routine, since the most natural
128 * way to bind to an interface is to return the private data from
129 * the driver's probe() method.
130 *
131 * Callers must own the device lock and the driver model's usb_bus_type.subsys
132 * writelock. So driver probe() entries don't need extra locking,
133 * but other call contexts may need to explicitly claim those locks.
134 */
135int usb_driver_claim_interface(struct usb_driver *driver,
136 struct usb_interface *iface, void* priv)
137{
138 struct device *dev = &iface->dev;
139
140 if (dev->driver)
141 return -EBUSY;
142
143 dev->driver = &driver->driver;
144 usb_set_intfdata(iface, priv);
145 iface->condition = USB_INTERFACE_BOUND;
146 mark_active(iface);
147
148 /* if interface was already added, bind now; else let
149 * the future device_add() bind it, bypassing probe()
150 */
151 if (device_is_registered(dev))
152 device_bind_driver(dev);
153
154 return 0;
155}
156
157/**
158 * usb_driver_release_interface - unbind a driver from an interface
159 * @driver: the driver to be unbound
160 * @iface: the interface from which it will be unbound
161 *
162 * This can be used by drivers to release an interface without waiting
163 * for their disconnect() methods to be called. In typical cases this
164 * also causes the driver disconnect() method to be called.
165 *
166 * This call is synchronous, and may not be used in an interrupt context.
167 * Callers must own the device lock and the driver model's usb_bus_type.subsys
168 * writelock. So driver disconnect() entries don't need extra locking,
169 * but other call contexts may need to explicitly claim those locks.
170 */
171void usb_driver_release_interface(struct usb_driver *driver,
172 struct usb_interface *iface)
173{
174 struct device *dev = &iface->dev;
175
176 /* this should never happen, don't release something that's not ours */
177 if (!dev->driver || dev->driver != &driver->driver)
178 return;
179
180 /* don't release from within disconnect() */
181 if (iface->condition != USB_INTERFACE_BOUND)
182 return;
183
184 /* don't release if the interface hasn't been added yet */
185 if (device_is_registered(dev)) {
186 iface->condition = USB_INTERFACE_UNBINDING;
187 device_release_driver(dev);
188 }
189
190 dev->driver = NULL;
191 usb_set_intfdata(iface, NULL);
192 iface->condition = USB_INTERFACE_UNBOUND;
193 mark_quiesced(iface);
194}
195
196struct find_interface_arg { 116struct find_interface_arg {
197 int minor; 117 int minor;
198 struct usb_interface *interface; 118 struct usb_interface *interface;
@@ -204,7 +124,7 @@ static int __find_interface(struct device * dev, void * data)
204 struct usb_interface *intf; 124 struct usb_interface *intf;
205 125
206 /* can't look at usb devices, only interfaces */ 126 /* can't look at usb devices, only interfaces */
207 if (dev->driver == &usb_generic_driver) 127 if (is_usb_device(dev))
208 return 0; 128 return 0;
209 129
210 intf = to_usb_interface(dev); 130 intf = to_usb_interface(dev);
@@ -227,127 +147,16 @@ static int __find_interface(struct device * dev, void * data)
227struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) 147struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
228{ 148{
229 struct find_interface_arg argb; 149 struct find_interface_arg argb;
150 int retval;
230 151
231 argb.minor = minor; 152 argb.minor = minor;
232 argb.interface = NULL; 153 argb.interface = NULL;
233 driver_for_each_device(&drv->driver, NULL, &argb, __find_interface); 154 /* eat the error, it will be in argb.interface */
155 retval = driver_for_each_device(&drv->drvwrap.driver, NULL, &argb,
156 __find_interface);
234 return argb.interface; 157 return argb.interface;
235} 158}
236 159
237#ifdef CONFIG_HOTPLUG
238
239/*
240 * This sends an uevent to userspace, typically helping to load driver
241 * or other modules, configure the device, and more. Drivers can provide
242 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
243 *
244 * We're called either from khubd (the typical case) or from root hub
245 * (init, kapmd, modprobe, rmmod, etc), but the agents need to handle
246 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
247 * device (and this configuration!) are still present.
248 */
249static int usb_uevent(struct device *dev, char **envp, int num_envp,
250 char *buffer, int buffer_size)
251{
252 struct usb_interface *intf;
253 struct usb_device *usb_dev;
254 struct usb_host_interface *alt;
255 int i = 0;
256 int length = 0;
257
258 if (!dev)
259 return -ENODEV;
260
261 /* driver is often null here; dev_dbg() would oops */
262 pr_debug ("usb %s: uevent\n", dev->bus_id);
263
264 /* Must check driver_data here, as on remove driver is always NULL */
265 if ((dev->driver == &usb_generic_driver) ||
266 (dev->driver_data == &usb_generic_driver_data))
267 return 0;
268
269 intf = to_usb_interface(dev);
270 usb_dev = interface_to_usbdev (intf);
271 alt = intf->cur_altsetting;
272
273 if (usb_dev->devnum < 0) {
274 pr_debug ("usb %s: already deleted?\n", dev->bus_id);
275 return -ENODEV;
276 }
277 if (!usb_dev->bus) {
278 pr_debug ("usb %s: bus removed?\n", dev->bus_id);
279 return -ENODEV;
280 }
281
282#ifdef CONFIG_USB_DEVICEFS
283 /* If this is available, userspace programs can directly read
284 * all the device descriptors we don't tell them about. Or
285 * even act as usermode drivers.
286 *
287 * FIXME reduce hardwired intelligence here
288 */
289 if (add_uevent_var(envp, num_envp, &i,
290 buffer, buffer_size, &length,
291 "DEVICE=/proc/bus/usb/%03d/%03d",
292 usb_dev->bus->busnum, usb_dev->devnum))
293 return -ENOMEM;
294#endif
295
296 /* per-device configurations are common */
297 if (add_uevent_var(envp, num_envp, &i,
298 buffer, buffer_size, &length,
299 "PRODUCT=%x/%x/%x",
300 le16_to_cpu(usb_dev->descriptor.idVendor),
301 le16_to_cpu(usb_dev->descriptor.idProduct),
302 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
303 return -ENOMEM;
304
305 /* class-based driver binding models */
306 if (add_uevent_var(envp, num_envp, &i,
307 buffer, buffer_size, &length,
308 "TYPE=%d/%d/%d",
309 usb_dev->descriptor.bDeviceClass,
310 usb_dev->descriptor.bDeviceSubClass,
311 usb_dev->descriptor.bDeviceProtocol))
312 return -ENOMEM;
313
314 if (add_uevent_var(envp, num_envp, &i,
315 buffer, buffer_size, &length,
316 "INTERFACE=%d/%d/%d",
317 alt->desc.bInterfaceClass,
318 alt->desc.bInterfaceSubClass,
319 alt->desc.bInterfaceProtocol))
320 return -ENOMEM;
321
322 if (add_uevent_var(envp, num_envp, &i,
323 buffer, buffer_size, &length,
324 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
325 le16_to_cpu(usb_dev->descriptor.idVendor),
326 le16_to_cpu(usb_dev->descriptor.idProduct),
327 le16_to_cpu(usb_dev->descriptor.bcdDevice),
328 usb_dev->descriptor.bDeviceClass,
329 usb_dev->descriptor.bDeviceSubClass,
330 usb_dev->descriptor.bDeviceProtocol,
331 alt->desc.bInterfaceClass,
332 alt->desc.bInterfaceSubClass,
333 alt->desc.bInterfaceProtocol))
334 return -ENOMEM;
335
336 envp[i] = NULL;
337
338 return 0;
339}
340
341#else
342
343static int usb_uevent(struct device *dev, char **envp,
344 int num_envp, char *buffer, int buffer_size)
345{
346 return -ENODEV;
347}
348
349#endif /* CONFIG_HOTPLUG */
350
351/** 160/**
352 * usb_release_dev - free a usb device structure when all users of it are finished. 161 * usb_release_dev - free a usb device structure when all users of it are finished.
353 * @dev: device that's been disconnected 162 * @dev: device that's been disconnected
@@ -361,14 +170,33 @@ static void usb_release_dev(struct device *dev)
361 170
362 udev = to_usb_device(dev); 171 udev = to_usb_device(dev);
363 172
173#ifdef CONFIG_PM
174 cancel_delayed_work(&udev->autosuspend);
175 flush_scheduled_work();
176#endif
364 usb_destroy_configuration(udev); 177 usb_destroy_configuration(udev);
365 usb_bus_put(udev->bus); 178 usb_put_hcd(bus_to_hcd(udev->bus));
366 kfree(udev->product); 179 kfree(udev->product);
367 kfree(udev->manufacturer); 180 kfree(udev->manufacturer);
368 kfree(udev->serial); 181 kfree(udev->serial);
369 kfree(udev); 182 kfree(udev);
370} 183}
371 184
185#ifdef CONFIG_PM
186
187/* usb_autosuspend_work - callback routine to autosuspend a USB device */
188static void usb_autosuspend_work(void *_udev)
189{
190 struct usb_device *udev = _udev;
191
192 mutex_lock_nested(&udev->pm_mutex, udev->level);
193 udev->auto_pm = 1;
194 usb_suspend_both(udev, PMSG_SUSPEND);
195 mutex_unlock(&udev->pm_mutex);
196}
197
198#endif
199
372/** 200/**
373 * usb_alloc_dev - usb device constructor (usbcore-internal) 201 * usb_alloc_dev - usb device constructor (usbcore-internal)
374 * @parent: hub to which device is connected; null to allocate a root hub 202 * @parent: hub to which device is connected; null to allocate a root hub
@@ -390,8 +218,7 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
390 if (!dev) 218 if (!dev)
391 return NULL; 219 return NULL;
392 220
393 bus = usb_bus_get(bus); 221 if (!usb_get_hcd(bus_to_hcd(bus))) {
394 if (!bus) {
395 kfree(dev); 222 kfree(dev);
396 return NULL; 223 return NULL;
397 } 224 }
@@ -399,11 +226,12 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
399 device_initialize(&dev->dev); 226 device_initialize(&dev->dev);
400 dev->dev.bus = &usb_bus_type; 227 dev->dev.bus = &usb_bus_type;
401 dev->dev.dma_mask = bus->controller->dma_mask; 228 dev->dev.dma_mask = bus->controller->dma_mask;
402 dev->dev.driver_data = &usb_generic_driver_data;
403 dev->dev.driver = &usb_generic_driver;
404 dev->dev.release = usb_release_dev; 229 dev->dev.release = usb_release_dev;
405 dev->state = USB_STATE_ATTACHED; 230 dev->state = USB_STATE_ATTACHED;
406 231
232 /* This magic assignment distinguishes devices from interfaces */
233 dev->dev.platform_data = &usb_generic_driver;
234
407 INIT_LIST_HEAD(&dev->ep0.urb_list); 235 INIT_LIST_HEAD(&dev->ep0.urb_list);
408 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE; 236 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
409 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT; 237 dev->ep0.desc.bDescriptorType = USB_DT_ENDPOINT;
@@ -444,6 +272,10 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
444 dev->parent = parent; 272 dev->parent = parent;
445 INIT_LIST_HEAD(&dev->filelist); 273 INIT_LIST_HEAD(&dev->filelist);
446 274
275#ifdef CONFIG_PM
276 mutex_init(&dev->pm_mutex);
277 INIT_WORK(&dev->autosuspend, usb_autosuspend_work, dev);
278#endif
447 return dev; 279 return dev;
448} 280}
449 281
@@ -549,7 +381,7 @@ void usb_put_intf(struct usb_interface *intf)
549 * case the driver already owns the device lock.) 381 * case the driver already owns the device lock.)
550 */ 382 */
551int usb_lock_device_for_reset(struct usb_device *udev, 383int usb_lock_device_for_reset(struct usb_device *udev,
552 struct usb_interface *iface) 384 const struct usb_interface *iface)
553{ 385{
554 unsigned long jiffies_expire = jiffies + HZ; 386 unsigned long jiffies_expire = jiffies + HZ;
555 387
@@ -672,7 +504,139 @@ exit:
672 */ 504 */
673int usb_get_current_frame_number(struct usb_device *dev) 505int usb_get_current_frame_number(struct usb_device *dev)
674{ 506{
675 return dev->bus->op->get_frame_number (dev); 507 return usb_hcd_get_frame_number (dev);
508}
509
510/**
511 * usb_endpoint_dir_in - check if the endpoint has IN direction
512 * @epd: endpoint to be checked
513 *
514 * Returns true if the endpoint is of type IN, otherwise it returns false.
515 */
516int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
517{
518 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
519}
520
521/**
522 * usb_endpoint_dir_out - check if the endpoint has OUT direction
523 * @epd: endpoint to be checked
524 *
525 * Returns true if the endpoint is of type OUT, otherwise it returns false.
526 */
527int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
528{
529 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
530}
531
532/**
533 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
534 * @epd: endpoint to be checked
535 *
536 * Returns true if the endpoint is of type bulk, otherwise it returns false.
537 */
538int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
539{
540 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
541 USB_ENDPOINT_XFER_BULK);
542}
543
544/**
545 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
546 * @epd: endpoint to be checked
547 *
548 * Returns true if the endpoint is of type interrupt, otherwise it returns
549 * false.
550 */
551int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
552{
553 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
554 USB_ENDPOINT_XFER_INT);
555}
556
557/**
558 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
559 * @epd: endpoint to be checked
560 *
561 * Returns true if the endpoint is of type isochronous, otherwise it returns
562 * false.
563 */
564int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd)
565{
566 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
567 USB_ENDPOINT_XFER_ISOC);
568}
569
570/**
571 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
572 * @epd: endpoint to be checked
573 *
574 * Returns true if the endpoint has bulk transfer type and IN direction,
575 * otherwise it returns false.
576 */
577int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
578{
579 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
580}
581
582/**
583 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
584 * @epd: endpoint to be checked
585 *
586 * Returns true if the endpoint has bulk transfer type and OUT direction,
587 * otherwise it returns false.
588 */
589int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
590{
591 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
592}
593
594/**
595 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
596 * @epd: endpoint to be checked
597 *
598 * Returns true if the endpoint has interrupt transfer type and IN direction,
599 * otherwise it returns false.
600 */
601int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
602{
603 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
604}
605
606/**
607 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
608 * @epd: endpoint to be checked
609 *
610 * Returns true if the endpoint has interrupt transfer type and OUT direction,
611 * otherwise it returns false.
612 */
613int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd)
614{
615 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
616}
617
618/**
619 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
620 * @epd: endpoint to be checked
621 *
622 * Returns true if the endpoint has isochronous transfer type and IN direction,
623 * otherwise it returns false.
624 */
625int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd)
626{
627 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
628}
629
630/**
631 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
632 * @epd: endpoint to be checked
633 *
634 * Returns true if the endpoint has isochronous transfer type and OUT direction,
635 * otherwise it returns false.
636 */
637int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd)
638{
639 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
676} 640}
677 641
678/*-------------------------------------------------------------------*/ 642/*-------------------------------------------------------------------*/
@@ -737,9 +701,9 @@ void *usb_buffer_alloc (
737 dma_addr_t *dma 701 dma_addr_t *dma
738) 702)
739{ 703{
740 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_alloc) 704 if (!dev || !dev->bus)
741 return NULL; 705 return NULL;
742 return dev->bus->op->buffer_alloc (dev->bus, size, mem_flags, dma); 706 return hcd_buffer_alloc (dev->bus, size, mem_flags, dma);
743} 707}
744 708
745/** 709/**
@@ -760,9 +724,11 @@ void usb_buffer_free (
760 dma_addr_t dma 724 dma_addr_t dma
761) 725)
762{ 726{
763 if (!dev || !dev->bus || !dev->bus->op || !dev->bus->op->buffer_free) 727 if (!dev || !dev->bus)
764 return; 728 return;
765 dev->bus->op->buffer_free (dev->bus, size, addr, dma); 729 if (!addr)
730 return;
731 hcd_buffer_free (dev->bus, size, addr, dma);
766} 732}
767 733
768/** 734/**
@@ -911,8 +877,8 @@ void usb_buffer_unmap (struct urb *urb)
911 * 877 *
912 * Reverse the effect of this call with usb_buffer_unmap_sg(). 878 * Reverse the effect of this call with usb_buffer_unmap_sg().
913 */ 879 */
914int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, 880int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
915 struct scatterlist *sg, int nents) 881 struct scatterlist *sg, int nents)
916{ 882{
917 struct usb_bus *bus; 883 struct usb_bus *bus;
918 struct device *controller; 884 struct device *controller;
@@ -946,8 +912,8 @@ int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
946 * Use this when you are re-using a scatterlist's data buffers for 912 * Use this when you are re-using a scatterlist's data buffers for
947 * another USB request. 913 * another USB request.
948 */ 914 */
949void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, 915void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
950 struct scatterlist *sg, int n_hw_ents) 916 struct scatterlist *sg, int n_hw_ents)
951{ 917{
952 struct usb_bus *bus; 918 struct usb_bus *bus;
953 struct device *controller; 919 struct device *controller;
@@ -972,8 +938,8 @@ void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
972 * 938 *
973 * Reverses the effect of usb_buffer_map_sg(). 939 * Reverses the effect of usb_buffer_map_sg().
974 */ 940 */
975void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, 941void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
976 struct scatterlist *sg, int n_hw_ents) 942 struct scatterlist *sg, int n_hw_ents)
977{ 943{
978 struct usb_bus *bus; 944 struct usb_bus *bus;
979 struct device *controller; 945 struct device *controller;
@@ -988,116 +954,6 @@ void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
988 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); 954 usb_pipein (pipe) ? DMA_FROM_DEVICE : DMA_TO_DEVICE);
989} 955}
990 956
991static int verify_suspended(struct device *dev, void *unused)
992{
993 if (dev->driver == NULL)
994 return 0;
995 return (dev->power.power_state.event == PM_EVENT_ON) ? -EBUSY : 0;
996}
997
998static int usb_generic_suspend(struct device *dev, pm_message_t message)
999{
1000 struct usb_interface *intf;
1001 struct usb_driver *driver;
1002 int status;
1003
1004 /* USB devices enter SUSPEND state through their hubs, but can be
1005 * marked for FREEZE as soon as their children are already idled.
1006 * But those semantics are useless, so we equate the two (sigh).
1007 */
1008 if (dev->driver == &usb_generic_driver) {
1009 if (dev->power.power_state.event == message.event)
1010 return 0;
1011 /* we need to rule out bogus requests through sysfs */
1012 status = device_for_each_child(dev, NULL, verify_suspended);
1013 if (status)
1014 return status;
1015 return usb_suspend_device (to_usb_device(dev));
1016 }
1017
1018 if ((dev->driver == NULL) ||
1019 (dev->driver_data == &usb_generic_driver_data))
1020 return 0;
1021
1022 intf = to_usb_interface(dev);
1023 driver = to_usb_driver(dev->driver);
1024
1025 /* with no hardware, USB interfaces only use FREEZE and ON states */
1026 if (!is_active(intf))
1027 return 0;
1028
1029 if (driver->suspend && driver->resume) {
1030 status = driver->suspend(intf, message);
1031 if (status)
1032 dev_err(dev, "%s error %d\n", "suspend", status);
1033 else
1034 mark_quiesced(intf);
1035 } else {
1036 // FIXME else if there's no suspend method, disconnect...
1037 dev_warn(dev, "no suspend for driver %s?\n", driver->name);
1038 mark_quiesced(intf);
1039 status = 0;
1040 }
1041 return status;
1042}
1043
1044static int usb_generic_resume(struct device *dev)
1045{
1046 struct usb_interface *intf;
1047 struct usb_driver *driver;
1048 struct usb_device *udev;
1049 int status;
1050
1051 if (dev->power.power_state.event == PM_EVENT_ON)
1052 return 0;
1053
1054 /* mark things as "on" immediately, no matter what errors crop up */
1055 dev->power.power_state.event = PM_EVENT_ON;
1056
1057 /* devices resume through their hubs */
1058 if (dev->driver == &usb_generic_driver) {
1059 udev = to_usb_device(dev);
1060 if (udev->state == USB_STATE_NOTATTACHED)
1061 return 0;
1062 return usb_resume_device (to_usb_device(dev));
1063 }
1064
1065 if ((dev->driver == NULL) ||
1066 (dev->driver_data == &usb_generic_driver_data)) {
1067 dev->power.power_state.event = PM_EVENT_FREEZE;
1068 return 0;
1069 }
1070
1071 intf = to_usb_interface(dev);
1072 driver = to_usb_driver(dev->driver);
1073
1074 udev = interface_to_usbdev(intf);
1075 if (udev->state == USB_STATE_NOTATTACHED)
1076 return 0;
1077
1078 /* if driver was suspended, it has a resume method;
1079 * however, sysfs can wrongly mark things as suspended
1080 * (on the "no suspend method" FIXME path above)
1081 */
1082 if (driver->resume) {
1083 status = driver->resume(intf);
1084 if (status) {
1085 dev_err(dev, "%s error %d\n", "resume", status);
1086 mark_quiesced(intf);
1087 }
1088 } else
1089 dev_warn(dev, "no resume for driver %s?\n", driver->name);
1090 return 0;
1091}
1092
1093struct bus_type usb_bus_type = {
1094 .name = "usb",
1095 .match = usb_device_match,
1096 .uevent = usb_uevent,
1097 .suspend = usb_generic_suspend,
1098 .resume = usb_generic_resume,
1099};
1100
1101/* format to disable USB on kernel command line is: nousb */ 957/* format to disable USB on kernel command line is: nousb */
1102__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444); 958__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444);
1103 959
@@ -1141,7 +997,7 @@ static int __init usb_init(void)
1141 retval = usb_hub_init(); 997 retval = usb_hub_init();
1142 if (retval) 998 if (retval)
1143 goto hub_init_failed; 999 goto hub_init_failed;
1144 retval = driver_register(&usb_generic_driver); 1000 retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);
1145 if (!retval) 1001 if (!retval)
1146 goto out; 1002 goto out;
1147 1003
@@ -1171,7 +1027,7 @@ static void __exit usb_exit(void)
1171 if (nousb) 1027 if (nousb)
1172 return; 1028 return;
1173 1029
1174 driver_unregister(&usb_generic_driver); 1030 usb_deregister_device_driver(&usb_generic_driver);
1175 usb_major_cleanup(); 1031 usb_major_cleanup();
1176 usbfs_cleanup(); 1032 usbfs_cleanup();
1177 usb_deregister(&usbfs_driver); 1033 usb_deregister(&usbfs_driver);
@@ -1201,20 +1057,27 @@ EXPORT_SYMBOL(usb_hub_tt_clear_buffer);
1201 1057
1202EXPORT_SYMBOL(usb_lock_device_for_reset); 1058EXPORT_SYMBOL(usb_lock_device_for_reset);
1203 1059
1204EXPORT_SYMBOL(usb_driver_claim_interface);
1205EXPORT_SYMBOL(usb_driver_release_interface);
1206EXPORT_SYMBOL(usb_find_interface); 1060EXPORT_SYMBOL(usb_find_interface);
1207EXPORT_SYMBOL(usb_ifnum_to_if); 1061EXPORT_SYMBOL(usb_ifnum_to_if);
1208EXPORT_SYMBOL(usb_altnum_to_altsetting); 1062EXPORT_SYMBOL(usb_altnum_to_altsetting);
1209 1063
1210EXPORT_SYMBOL(usb_reset_device);
1211EXPORT_SYMBOL(usb_reset_composite_device);
1212
1213EXPORT_SYMBOL(__usb_get_extra_descriptor); 1064EXPORT_SYMBOL(__usb_get_extra_descriptor);
1214 1065
1215EXPORT_SYMBOL(usb_find_device); 1066EXPORT_SYMBOL(usb_find_device);
1216EXPORT_SYMBOL(usb_get_current_frame_number); 1067EXPORT_SYMBOL(usb_get_current_frame_number);
1217 1068
1069EXPORT_SYMBOL_GPL(usb_endpoint_dir_in);
1070EXPORT_SYMBOL_GPL(usb_endpoint_dir_out);
1071EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk);
1072EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int);
1073EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc);
1074EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in);
1075EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out);
1076EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in);
1077EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out);
1078EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in);
1079EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out);
1080
1218EXPORT_SYMBOL (usb_buffer_alloc); 1081EXPORT_SYMBOL (usb_buffer_alloc);
1219EXPORT_SYMBOL (usb_buffer_free); 1082EXPORT_SYMBOL (usb_buffer_free);
1220 1083
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 49f69236b420..0c09ecced6e1 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -1,10 +1,10 @@
1/* Functions local to drivers/usb/core/ */ 1/* Functions local to drivers/usb/core/ */
2 2
3extern void usb_create_sysfs_dev_files (struct usb_device *dev); 3extern int usb_create_sysfs_dev_files (struct usb_device *dev);
4extern void usb_remove_sysfs_dev_files (struct usb_device *dev); 4extern void usb_remove_sysfs_dev_files (struct usb_device *dev);
5extern void usb_create_sysfs_intf_files (struct usb_interface *intf); 5extern int usb_create_sysfs_intf_files (struct usb_interface *intf);
6extern void usb_remove_sysfs_intf_files (struct usb_interface *intf); 6extern void usb_remove_sysfs_intf_files (struct usb_interface *intf);
7extern void usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint, 7extern int usb_create_ep_files(struct device *parent, struct usb_host_endpoint *endpoint,
8 struct usb_device *udev); 8 struct usb_device *udev);
9extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint); 9extern void usb_remove_ep_files(struct usb_host_endpoint *endpoint);
10 10
@@ -20,7 +20,6 @@ extern char *usb_cache_string(struct usb_device *udev, int index);
20extern int usb_set_configuration(struct usb_device *dev, int configuration); 20extern int usb_set_configuration(struct usb_device *dev, int configuration);
21 21
22extern void usb_kick_khubd(struct usb_device *dev); 22extern void usb_kick_khubd(struct usb_device *dev);
23extern void usb_suspend_root_hub(struct usb_device *hdev);
24extern void usb_resume_root_hub(struct usb_device *dev); 23extern void usb_resume_root_hub(struct usb_device *dev);
25 24
26extern int usb_hub_init(void); 25extern int usb_hub_init(void);
@@ -30,28 +29,74 @@ extern void usb_major_cleanup(void);
30extern int usb_host_init(void); 29extern int usb_host_init(void);
31extern void usb_host_cleanup(void); 30extern void usb_host_cleanup(void);
32 31
33extern int usb_suspend_device(struct usb_device *dev); 32#ifdef CONFIG_PM
34extern int usb_resume_device(struct usb_device *dev);
35 33
36extern struct device_driver usb_generic_driver; 34extern int usb_suspend_both(struct usb_device *udev, pm_message_t msg);
37extern int usb_generic_driver_data; 35extern int usb_resume_both(struct usb_device *udev);
38extern int usb_device_match(struct device *dev, struct device_driver *drv); 36extern int usb_port_suspend(struct usb_device *dev);
37extern int usb_port_resume(struct usb_device *dev);
38
39#else
40
41#define usb_suspend_both(udev, msg) 0
42static inline int usb_resume_both(struct usb_device *udev)
43{
44 return 0;
45}
46#define usb_port_suspend(dev) 0
47#define usb_port_resume(dev) 0
48
49#endif
50
51#ifdef CONFIG_USB_SUSPEND
52
53#define USB_AUTOSUSPEND_DELAY (HZ*2)
54
55extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt);
56extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt);
57
58#else
59
60#define usb_autosuspend_device(udev, dec_busy_cnt) do {} while (0)
61#define usb_autoresume_device(udev, inc_busy_cnt) 0
62
63#endif
64
65extern struct bus_type usb_bus_type;
66extern struct usb_device_driver usb_generic_driver;
67
68/* Here's how we tell apart devices and interfaces. Luckily there's
69 * no such thing as a platform USB device, so we can steal the use
70 * of the platform_data field. */
71
72static inline int is_usb_device(const struct device *dev)
73{
74 return dev->platform_data == &usb_generic_driver;
75}
76
77/* Do the same for device drivers and interface drivers. */
78
79static inline int is_usb_device_driver(struct device_driver *drv)
80{
81 return container_of(drv, struct usbdrv_wrap, driver)->
82 for_devices;
83}
39 84
40/* Interfaces and their "power state" are owned by usbcore */ 85/* Interfaces and their "power state" are owned by usbcore */
41 86
42static inline void mark_active(struct usb_interface *f) 87static inline void mark_active(struct usb_interface *f)
43{ 88{
44 f->dev.power.power_state.event = PM_EVENT_ON; 89 f->is_active = 1;
45} 90}
46 91
47static inline void mark_quiesced(struct usb_interface *f) 92static inline void mark_quiesced(struct usb_interface *f)
48{ 93{
49 f->dev.power.power_state.event = PM_EVENT_FREEZE; 94 f->is_active = 0;
50} 95}
51 96
52static inline int is_active(struct usb_interface *f) 97static inline int is_active(const struct usb_interface *f)
53{ 98{
54 return f->dev.power.power_state.event == PM_EVENT_ON; 99 return f->is_active;
55} 100}
56 101
57 102
@@ -59,9 +104,10 @@ static inline int is_active(struct usb_interface *f)
59extern const char *usbcore_name; 104extern const char *usbcore_name;
60 105
61/* usbfs stuff */ 106/* usbfs stuff */
107extern struct mutex usbfs_mutex;
62extern struct usb_driver usbfs_driver; 108extern struct usb_driver usbfs_driver;
63extern struct file_operations usbfs_devices_fops; 109extern const struct file_operations usbfs_devices_fops;
64extern struct file_operations usbfs_device_file_operations; 110extern const struct file_operations usbfs_device_file_operations;
65extern void usbfs_conn_disc_event(void); 111extern void usbfs_conn_disc_event(void);
66 112
67extern int usbdev_init(void); 113extern int usbdev_init(void);
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 1a32d96774b4..8e5dd6f29d0b 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -26,7 +26,7 @@ config USB_GADGET
26 you need a low level bus controller driver, and some software 26 you need a low level bus controller driver, and some software
27 talking to it. Peripheral controllers are often discrete silicon, 27 talking to it. Peripheral controllers are often discrete silicon,
28 or are integrated with the CPU in a microcontroller. The more 28 or are integrated with the CPU in a microcontroller. The more
29 familiar host side controllers have names like like "EHCI", "OHCI", 29 familiar host side controllers have names like "EHCI", "OHCI",
30 or "UHCI", and are usually integrated into southbridges on PC 30 or "UHCI", and are usually integrated into southbridges on PC
31 motherboards. 31 motherboards.
32 32
@@ -404,6 +404,20 @@ config USB_G_SERIAL
404 which includes instructions and a "driver info file" needed to 404 which includes instructions and a "driver info file" needed to
405 make MS-Windows work with this driver. 405 make MS-Windows work with this driver.
406 406
407config USB_MIDI_GADGET
408 tristate "MIDI Gadget (EXPERIMENTAL)"
409 depends on SND && EXPERIMENTAL
410 select SND_RAWMIDI
411 help
412 The MIDI Gadget acts as a USB Audio device, with one MIDI
413 input and one MIDI output. These MIDI jacks appear as
414 a sound "card" in the ALSA sound system. Other MIDI
415 connections can then be made on the gadget system, using
416 ALSA's aconnect utility etc.
417
418 Say "y" to link the driver statically, or "m" to build a
419 dynamically linked module called "g_midi".
420
407 421
408# put drivers that need isochronous transfer support (for audio 422# put drivers that need isochronous transfer support (for audio
409# or video class gadget drivers), or specific hardware, here. 423# or video class gadget drivers), or specific hardware, here.
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 5a28e61392ec..e71e086a1cfa 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_AT91) += at91_udc.o
15g_zero-objs := zero.o usbstring.o config.o epautoconf.o 15g_zero-objs := zero.o usbstring.o config.o epautoconf.o
16g_ether-objs := ether.o usbstring.o config.o epautoconf.o 16g_ether-objs := ether.o usbstring.o config.o epautoconf.o
17g_serial-objs := serial.o usbstring.o config.o epautoconf.o 17g_serial-objs := serial.o usbstring.o config.o epautoconf.o
18g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
18gadgetfs-objs := inode.o 19gadgetfs-objs := inode.o
19g_file_storage-objs := file_storage.o usbstring.o config.o \ 20g_file_storage-objs := file_storage.o usbstring.o config.o \
20 epautoconf.o 21 epautoconf.o
@@ -28,4 +29,5 @@ obj-$(CONFIG_USB_ETH) += g_ether.o
28obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o 29obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
29obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o 30obj-$(CONFIG_USB_FILE_STORAGE) += g_file_storage.o
30obj-$(CONFIG_USB_G_SERIAL) += g_serial.o 31obj-$(CONFIG_USB_G_SERIAL) += g_serial.o
32obj-$(CONFIG_USB_MIDI_GADGET) += g_midi.o
31 33
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index cfebca05ead5..d00958a01cfb 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -247,7 +247,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
247 return single_open(file, proc_udc_show, PDE(inode)->data); 247 return single_open(file, proc_udc_show, PDE(inode)->data);
248} 248}
249 249
250static struct file_operations proc_ops = { 250static const struct file_operations proc_ops = {
251 .open = proc_udc_open, 251 .open = proc_udc_open,
252 .read = seq_read, 252 .read = seq_read,
253 .llseek = seq_lseek, 253 .llseek = seq_lseek,
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 7d1c22c34957..fdab97a27c08 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -889,11 +889,9 @@ EXPORT_SYMBOL (net2280_set_fifo_mode);
889static void 889static void
890dummy_gadget_release (struct device *dev) 890dummy_gadget_release (struct device *dev)
891{ 891{
892#if 0 /* usb_bus_put isn't EXPORTed! */
893 struct dummy *dum = gadget_dev_to_dummy (dev); 892 struct dummy *dum = gadget_dev_to_dummy (dev);
894 893
895 usb_bus_put (&dummy_to_hcd (dum)->self); 894 usb_put_hcd (dummy_to_hcd (dum));
896#endif
897} 895}
898 896
899static int dummy_udc_probe (struct platform_device *pdev) 897static int dummy_udc_probe (struct platform_device *pdev)
@@ -915,9 +913,7 @@ static int dummy_udc_probe (struct platform_device *pdev)
915 if (rc < 0) 913 if (rc < 0)
916 return rc; 914 return rc;
917 915
918#if 0 /* usb_bus_get isn't EXPORTed! */ 916 usb_get_hcd (dummy_to_hcd (dum));
919 usb_bus_get (&dummy_to_hcd (dum)->self);
920#endif
921 917
922 platform_set_drvdata (pdev, dum); 918 platform_set_drvdata (pdev, dum);
923 device_create_file (&dum->gadget.dev, &dev_attr_function); 919 device_create_file (&dum->gadget.dev, &dev_attr_function);
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 30299c620d97..366dc0a9e52c 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -262,7 +262,7 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
262#define DEV_CONFIG_CDC 262#define DEV_CONFIG_CDC
263#endif 263#endif
264 264
265#ifdef CONFIG_USB_GADGET_MUSBHDRC 265#ifdef CONFIG_USB_GADGET_MUSB_HDRC
266#define DEV_CONFIG_CDC 266#define DEV_CONFIG_CDC
267#endif 267#endif
268 268
@@ -2014,7 +2014,7 @@ rndis_control_ack_complete (struct usb_ep *ep, struct usb_request *req)
2014static int rndis_control_ack (struct net_device *net) 2014static int rndis_control_ack (struct net_device *net)
2015{ 2015{
2016 struct eth_dev *dev = netdev_priv(net); 2016 struct eth_dev *dev = netdev_priv(net);
2017 u32 length; 2017 int length;
2018 struct usb_request *resp = dev->stat_req; 2018 struct usb_request *resp = dev->stat_req;
2019 2019
2020 /* in case RNDIS calls this after disconnect */ 2020 /* in case RNDIS calls this after disconnect */
@@ -2230,6 +2230,9 @@ eth_bind (struct usb_gadget *gadget)
2230 if (gadget_is_pxa (gadget)) { 2230 if (gadget_is_pxa (gadget)) {
2231 /* pxa doesn't support altsettings */ 2231 /* pxa doesn't support altsettings */
2232 cdc = 0; 2232 cdc = 0;
2233 } else if (gadget_is_musbhdrc(gadget)) {
2234 /* reduce tx dma overhead by avoiding special cases */
2235 zlp = 0;
2233 } else if (gadget_is_sh(gadget)) { 2236 } else if (gadget_is_sh(gadget)) {
2234 /* sh doesn't support multiple interfaces or configs */ 2237 /* sh doesn't support multiple interfaces or configs */
2235 cdc = 0; 2238 cdc = 0;
@@ -2564,7 +2567,7 @@ static struct usb_gadget_driver eth_driver = {
2564 2567
2565 .function = (char *) driver_desc, 2568 .function = (char *) driver_desc,
2566 .bind = eth_bind, 2569 .bind = eth_bind,
2567 .unbind = __exit_p(eth_unbind), 2570 .unbind = eth_unbind,
2568 2571
2569 .setup = eth_setup, 2572 .setup = eth_setup,
2570 .disconnect = eth_disconnect, 2573 .disconnect = eth_disconnect,
diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c
new file mode 100644
index 000000000000..b68cecd57411
--- /dev/null
+++ b/drivers/usb/gadget/gmidi.c
@@ -0,0 +1,1337 @@
1/*
2 * gmidi.c -- USB MIDI Gadget Driver
3 *
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
7 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This code is based in part on:
12 *
13 * Gadget Zero driver, Copyright (C) 2003-2004 David Brownell.
14 * USB Audio driver, Copyright (C) 2002 by Takashi Iwai.
15 * USB MIDI driver, Copyright (C) 2002-2005 Clemens Ladisch.
16 *
17 * Refer to the USB Device Class Definition for MIDI Devices:
18 * http://www.usb.org/developers/devclass_docs/midi10.pdf
19 */
20
21#define DEBUG 1
22// #define VERBOSE
23
24#include <linux/config.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/delay.h>
28#include <linux/errno.h>
29#include <linux/init.h>
30#include <linux/utsname.h>
31#include <linux/device.h>
32#include <linux/moduleparam.h>
33
34#include <sound/driver.h>
35#include <sound/core.h>
36#include <sound/initval.h>
37#include <sound/rawmidi.h>
38
39#include <linux/usb_ch9.h>
40#include <linux/usb_gadget.h>
41#include <linux/usb/audio.h>
42#include <linux/usb/midi.h>
43
44#include "gadget_chips.h"
45
46MODULE_AUTHOR("Ben Williamson");
47MODULE_LICENSE("GPL v2");
48
49#define DRIVER_VERSION "25 Jul 2006"
50
51static const char shortname[] = "g_midi";
52static const char longname[] = "MIDI Gadget";
53
54static int index = SNDRV_DEFAULT_IDX1;
55static char *id = SNDRV_DEFAULT_STR1;
56
57module_param(index, int, 0444);
58MODULE_PARM_DESC(index, "Index value for the USB MIDI Gadget adapter.");
59module_param(id, charp, 0444);
60MODULE_PARM_DESC(id, "ID string for the USB MIDI Gadget adapter.");
61
62/* Some systems will want different product identifers published in the
63 * device descriptor, either numbers or strings or both. These string
64 * parameters are in UTF-8 (superset of ASCII's 7 bit characters).
65 */
66
67static ushort idVendor;
68module_param(idVendor, ushort, S_IRUGO);
69MODULE_PARM_DESC(idVendor, "USB Vendor ID");
70
71static ushort idProduct;
72module_param(idProduct, ushort, S_IRUGO);
73MODULE_PARM_DESC(idProduct, "USB Product ID");
74
75static ushort bcdDevice;
76module_param(bcdDevice, ushort, S_IRUGO);
77MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
78
79static char *iManufacturer;
80module_param(iManufacturer, charp, S_IRUGO);
81MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
82
83static char *iProduct;
84module_param(iProduct, charp, S_IRUGO);
85MODULE_PARM_DESC(iProduct, "USB Product string");
86
87static char *iSerialNumber;
88module_param(iSerialNumber, charp, S_IRUGO);
89MODULE_PARM_DESC(iSerialNumber, "SerialNumber");
90
91/*
92 * this version autoconfigures as much as possible,
93 * which is reasonable for most "bulk-only" drivers.
94 */
95static const char *EP_IN_NAME;
96static const char *EP_OUT_NAME;
97
98
99/* big enough to hold our biggest descriptor */
100#define USB_BUFSIZ 256
101
102
103/* This is a gadget, and the IN/OUT naming is from the host's perspective.
104 USB -> OUT endpoint -> rawmidi
105 USB <- IN endpoint <- rawmidi */
106struct gmidi_in_port {
107 struct gmidi_device* dev;
108 int active;
109 uint8_t cable; /* cable number << 4 */
110 uint8_t state;
111#define STATE_UNKNOWN 0
112#define STATE_1PARAM 1
113#define STATE_2PARAM_1 2
114#define STATE_2PARAM_2 3
115#define STATE_SYSEX_0 4
116#define STATE_SYSEX_1 5
117#define STATE_SYSEX_2 6
118 uint8_t data[2];
119};
120
121struct gmidi_device {
122 spinlock_t lock;
123 struct usb_gadget *gadget;
124 struct usb_request *req; /* for control responses */
125 u8 config;
126 struct usb_ep *in_ep, *out_ep;
127 struct snd_card *card;
128 struct snd_rawmidi *rmidi;
129 struct snd_rawmidi_substream *in_substream;
130 struct snd_rawmidi_substream *out_substream;
131
132 /* For the moment we only support one port in
133 each direction, but in_port is kept as a
134 separate struct so we can have more later. */
135 struct gmidi_in_port in_port;
136 unsigned long out_triggered;
137 struct tasklet_struct tasklet;
138};
139
140static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req);
141
142
143#define xprintk(d,level,fmt,args...) \
144 dev_printk(level , &(d)->gadget->dev , fmt , ## args)
145
146#ifdef DEBUG
147#define DBG(dev,fmt,args...) \
148 xprintk(dev , KERN_DEBUG , fmt , ## args)
149#else
150#define DBG(dev,fmt,args...) \
151 do { } while (0)
152#endif /* DEBUG */
153
154#ifdef VERBOSE
155#define VDBG DBG
156#else
157#define VDBG(dev,fmt,args...) \
158 do { } while (0)
159#endif /* VERBOSE */
160
161#define ERROR(dev,fmt,args...) \
162 xprintk(dev , KERN_ERR , fmt , ## args)
163#define WARN(dev,fmt,args...) \
164 xprintk(dev , KERN_WARNING , fmt , ## args)
165#define INFO(dev,fmt,args...) \
166 xprintk(dev , KERN_INFO , fmt , ## args)
167
168
169static unsigned buflen = 256;
170static unsigned qlen = 32;
171
172module_param(buflen, uint, S_IRUGO);
173module_param(qlen, uint, S_IRUGO);
174
175
176/* Thanks to Grey Innovation for donating this product ID.
177 *
178 * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
179 * Instead: allocate your own, using normal USB-IF procedures.
180 */
181#define DRIVER_VENDOR_NUM 0x17b3 /* Grey Innovation */
182#define DRIVER_PRODUCT_NUM 0x0004 /* Linux-USB "MIDI Gadget" */
183
184
185/*
186 * DESCRIPTORS ... most are static, but strings and (full)
187 * configuration descriptors are built on demand.
188 */
189
190#define STRING_MANUFACTURER 25
191#define STRING_PRODUCT 42
192#define STRING_SERIAL 101
193#define STRING_MIDI_GADGET 250
194
195/* We only have the one configuration, it's number 1. */
196#define GMIDI_CONFIG 1
197
198/* We have two interfaces- AudioControl and MIDIStreaming */
199#define GMIDI_AC_INTERFACE 0
200#define GMIDI_MS_INTERFACE 1
201#define GMIDI_NUM_INTERFACES 2
202
203DECLARE_USB_AC_HEADER_DESCRIPTOR(1);
204DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(1);
205DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(1);
206
207/* B.1 Device Descriptor */
208static struct usb_device_descriptor device_desc = {
209 .bLength = USB_DT_DEVICE_SIZE,
210 .bDescriptorType = USB_DT_DEVICE,
211 .bcdUSB = __constant_cpu_to_le16(0x0200),
212 .bDeviceClass = USB_CLASS_PER_INTERFACE,
213 .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM),
214 .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM),
215 .iManufacturer = STRING_MANUFACTURER,
216 .iProduct = STRING_PRODUCT,
217 .bNumConfigurations = 1,
218};
219
220/* B.2 Configuration Descriptor */
221static struct usb_config_descriptor config_desc = {
222 .bLength = USB_DT_CONFIG_SIZE,
223 .bDescriptorType = USB_DT_CONFIG,
224 /* compute wTotalLength on the fly */
225 .bNumInterfaces = GMIDI_NUM_INTERFACES,
226 .bConfigurationValue = GMIDI_CONFIG,
227 .iConfiguration = STRING_MIDI_GADGET,
228 /*
229 * FIXME: When embedding this driver in a device,
230 * these need to be set to reflect the actual
231 * power properties of the device. Is it selfpowered?
232 */
233 .bmAttributes = USB_CONFIG_ATT_ONE,
234 .bMaxPower = 1,
235};
236
237/* B.3.1 Standard AC Interface Descriptor */
238static const struct usb_interface_descriptor ac_interface_desc = {
239 .bLength = USB_DT_INTERFACE_SIZE,
240 .bDescriptorType = USB_DT_INTERFACE,
241 .bInterfaceNumber = GMIDI_AC_INTERFACE,
242 .bNumEndpoints = 0,
243 .bInterfaceClass = USB_CLASS_AUDIO,
244 .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL,
245 .iInterface = STRING_MIDI_GADGET,
246};
247
248/* B.3.2 Class-Specific AC Interface Descriptor */
249static const struct usb_ac_header_descriptor_1 ac_header_desc = {
250 .bLength = USB_DT_AC_HEADER_SIZE(1),
251 .bDescriptorType = USB_DT_CS_INTERFACE,
252 .bDescriptorSubtype = USB_MS_HEADER,
253 .bcdADC = __constant_cpu_to_le16(0x0100),
254 .wTotalLength = USB_DT_AC_HEADER_SIZE(1),
255 .bInCollection = 1,
256 .baInterfaceNr = {
257 [0] = GMIDI_MS_INTERFACE,
258 }
259};
260
261/* B.4.1 Standard MS Interface Descriptor */
262static const struct usb_interface_descriptor ms_interface_desc = {
263 .bLength = USB_DT_INTERFACE_SIZE,
264 .bDescriptorType = USB_DT_INTERFACE,
265 .bInterfaceNumber = GMIDI_MS_INTERFACE,
266 .bNumEndpoints = 2,
267 .bInterfaceClass = USB_CLASS_AUDIO,
268 .bInterfaceSubClass = USB_SUBCLASS_MIDISTREAMING,
269 .iInterface = STRING_MIDI_GADGET,
270};
271
272/* B.4.2 Class-Specific MS Interface Descriptor */
273static const struct usb_ms_header_descriptor ms_header_desc = {
274 .bLength = USB_DT_MS_HEADER_SIZE,
275 .bDescriptorType = USB_DT_CS_INTERFACE,
276 .bDescriptorSubtype = USB_MS_HEADER,
277 .bcdMSC = __constant_cpu_to_le16(0x0100),
278 .wTotalLength = USB_DT_MS_HEADER_SIZE
279 + 2*USB_DT_MIDI_IN_SIZE
280 + 2*USB_DT_MIDI_OUT_SIZE(1),
281};
282
283#define JACK_IN_EMB 1
284#define JACK_IN_EXT 2
285#define JACK_OUT_EMB 3
286#define JACK_OUT_EXT 4
287
288/* B.4.3 MIDI IN Jack Descriptors */
289static const struct usb_midi_in_jack_descriptor jack_in_emb_desc = {
290 .bLength = USB_DT_MIDI_IN_SIZE,
291 .bDescriptorType = USB_DT_CS_INTERFACE,
292 .bDescriptorSubtype = USB_MS_MIDI_IN_JACK,
293 .bJackType = USB_MS_EMBEDDED,
294 .bJackID = JACK_IN_EMB,
295};
296
297static const struct usb_midi_in_jack_descriptor jack_in_ext_desc = {
298 .bLength = USB_DT_MIDI_IN_SIZE,
299 .bDescriptorType = USB_DT_CS_INTERFACE,
300 .bDescriptorSubtype = USB_MS_MIDI_IN_JACK,
301 .bJackType = USB_MS_EXTERNAL,
302 .bJackID = JACK_IN_EXT,
303};
304
305/* B.4.4 MIDI OUT Jack Descriptors */
306static const struct usb_midi_out_jack_descriptor_1 jack_out_emb_desc = {
307 .bLength = USB_DT_MIDI_OUT_SIZE(1),
308 .bDescriptorType = USB_DT_CS_INTERFACE,
309 .bDescriptorSubtype = USB_MS_MIDI_OUT_JACK,
310 .bJackType = USB_MS_EMBEDDED,
311 .bJackID = JACK_OUT_EMB,
312 .bNrInputPins = 1,
313 .pins = {
314 [0] = {
315 .baSourceID = JACK_IN_EXT,
316 .baSourcePin = 1,
317 }
318 }
319};
320
321static const struct usb_midi_out_jack_descriptor_1 jack_out_ext_desc = {
322 .bLength = USB_DT_MIDI_OUT_SIZE(1),
323 .bDescriptorType = USB_DT_CS_INTERFACE,
324 .bDescriptorSubtype = USB_MS_MIDI_OUT_JACK,
325 .bJackType = USB_MS_EXTERNAL,
326 .bJackID = JACK_OUT_EXT,
327 .bNrInputPins = 1,
328 .pins = {
329 [0] = {
330 .baSourceID = JACK_IN_EMB,
331 .baSourcePin = 1,
332 }
333 }
334};
335
336/* B.5.1 Standard Bulk OUT Endpoint Descriptor */
337static struct usb_endpoint_descriptor bulk_out_desc = {
338 .bLength = USB_DT_ENDPOINT_AUDIO_SIZE,
339 .bDescriptorType = USB_DT_ENDPOINT,
340 .bEndpointAddress = USB_DIR_OUT,
341 .bmAttributes = USB_ENDPOINT_XFER_BULK,
342};
343
344/* B.5.2 Class-specific MS Bulk OUT Endpoint Descriptor */
345static const struct usb_ms_endpoint_descriptor_1 ms_out_desc = {
346 .bLength = USB_DT_MS_ENDPOINT_SIZE(1),
347 .bDescriptorType = USB_DT_CS_ENDPOINT,
348 .bDescriptorSubtype = USB_MS_GENERAL,
349 .bNumEmbMIDIJack = 1,
350 .baAssocJackID = {
351 [0] = JACK_IN_EMB,
352 }
353};
354
355/* B.6.1 Standard Bulk IN Endpoint Descriptor */
356static struct usb_endpoint_descriptor bulk_in_desc = {
357 .bLength = USB_DT_ENDPOINT_AUDIO_SIZE,
358 .bDescriptorType = USB_DT_ENDPOINT,
359 .bEndpointAddress = USB_DIR_IN,
360 .bmAttributes = USB_ENDPOINT_XFER_BULK,
361};
362
363/* B.6.2 Class-specific MS Bulk IN Endpoint Descriptor */
364static const struct usb_ms_endpoint_descriptor_1 ms_in_desc = {
365 .bLength = USB_DT_MS_ENDPOINT_SIZE(1),
366 .bDescriptorType = USB_DT_CS_ENDPOINT,
367 .bDescriptorSubtype = USB_MS_GENERAL,
368 .bNumEmbMIDIJack = 1,
369 .baAssocJackID = {
370 [0] = JACK_OUT_EMB,
371 }
372};
373
374static const struct usb_descriptor_header *gmidi_function [] = {
375 (struct usb_descriptor_header *)&ac_interface_desc,
376 (struct usb_descriptor_header *)&ac_header_desc,
377 (struct usb_descriptor_header *)&ms_interface_desc,
378
379 (struct usb_descriptor_header *)&ms_header_desc,
380 (struct usb_descriptor_header *)&jack_in_emb_desc,
381 (struct usb_descriptor_header *)&jack_in_ext_desc,
382 (struct usb_descriptor_header *)&jack_out_emb_desc,
383 (struct usb_descriptor_header *)&jack_out_ext_desc,
384 /* If you add more jacks, update ms_header_desc.wTotalLength */
385
386 (struct usb_descriptor_header *)&bulk_out_desc,
387 (struct usb_descriptor_header *)&ms_out_desc,
388 (struct usb_descriptor_header *)&bulk_in_desc,
389 (struct usb_descriptor_header *)&ms_in_desc,
390 NULL,
391};
392
393static char manufacturer[50];
394static char product_desc[40] = "MIDI Gadget";
395static char serial_number[20];
396
397/* static strings, in UTF-8 */
398static struct usb_string strings [] = {
399 { STRING_MANUFACTURER, manufacturer, },
400 { STRING_PRODUCT, product_desc, },
401 { STRING_SERIAL, serial_number, },
402 { STRING_MIDI_GADGET, longname, },
403 { } /* end of list */
404};
405
406static struct usb_gadget_strings stringtab = {
407 .language = 0x0409, /* en-us */
408 .strings = strings,
409};
410
411static int config_buf(struct usb_gadget *gadget,
412 u8 *buf, u8 type, unsigned index)
413{
414 int len;
415
416 /* only one configuration */
417 if (index != 0) {
418 return -EINVAL;
419 }
420 len = usb_gadget_config_buf(&config_desc,
421 buf, USB_BUFSIZ, gmidi_function);
422 if (len < 0) {
423 return len;
424 }
425 ((struct usb_config_descriptor *)buf)->bDescriptorType = type;
426 return len;
427}
428
429static struct usb_request* alloc_ep_req(struct usb_ep *ep, unsigned length)
430{
431 struct usb_request *req;
432
433 req = usb_ep_alloc_request(ep, GFP_ATOMIC);
434 if (req) {
435 req->length = length;
436 req->buf = kmalloc(length, GFP_ATOMIC);
437 if (!req->buf) {
438 usb_ep_free_request(ep, req);
439 req = NULL;
440 }
441 }
442 return req;
443}
444
445static void free_ep_req(struct usb_ep *ep, struct usb_request *req)
446{
447 kfree(req->buf);
448 usb_ep_free_request(ep, req);
449}
450
451static const uint8_t gmidi_cin_length[] = {
452 0, 0, 2, 3, 3, 1, 2, 3, 3, 3, 3, 3, 2, 2, 3, 1
453};
454
455/*
456 * Receives a chunk of MIDI data.
457 */
458static void gmidi_read_data(struct usb_ep *ep, int cable,
459 uint8_t* data, int length)
460{
461 struct gmidi_device *dev = ep->driver_data;
462 /* cable is ignored, because for now we only have one. */
463
464 if (!dev->out_substream) {
465 /* Nobody is listening - throw it on the floor. */
466 return;
467 }
468 if (!test_bit(dev->out_substream->number, &dev->out_triggered)) {
469 return;
470 }
471 snd_rawmidi_receive(dev->out_substream, data, length);
472}
473
474static void gmidi_handle_out_data(struct usb_ep *ep, struct usb_request *req)
475{
476 unsigned i;
477 u8 *buf = req->buf;
478
479 for (i = 0; i + 3 < req->actual; i += 4) {
480 if (buf[i] != 0) {
481 int cable = buf[i] >> 4;
482 int length = gmidi_cin_length[buf[i] & 0x0f];
483 gmidi_read_data(ep, cable, &buf[i + 1], length);
484 }
485 }
486}
487
488static void gmidi_complete(struct usb_ep *ep, struct usb_request *req)
489{
490 struct gmidi_device *dev = ep->driver_data;
491 int status = req->status;
492
493 switch (status) {
494 case 0: /* normal completion */
495 if (ep == dev->out_ep) {
496 /* we received stuff.
497 req is queued again, below */
498 gmidi_handle_out_data(ep, req);
499 } else if (ep == dev->in_ep) {
500 /* our transmit completed.
501 see if there's more to go.
502 gmidi_transmit eats req, don't queue it again. */
503 gmidi_transmit(dev, req);
504 return;
505 }
506 break;
507
508 /* this endpoint is normally active while we're configured */
509 case -ECONNABORTED: /* hardware forced ep reset */
510 case -ECONNRESET: /* request dequeued */
511 case -ESHUTDOWN: /* disconnect from host */
512 VDBG(dev, "%s gone (%d), %d/%d\n", ep->name, status,
513 req->actual, req->length);
514 if (ep == dev->out_ep) {
515 gmidi_handle_out_data(ep, req);
516 }
517 free_ep_req(ep, req);
518 return;
519
520 case -EOVERFLOW: /* buffer overrun on read means that
521 * we didn't provide a big enough
522 * buffer.
523 */
524 default:
525 DBG(dev, "%s complete --> %d, %d/%d\n", ep->name,
526 status, req->actual, req->length);
527 break;
528 case -EREMOTEIO: /* short read */
529 break;
530 }
531
532 status = usb_ep_queue(ep, req, GFP_ATOMIC);
533 if (status) {
534 ERROR(dev, "kill %s: resubmit %d bytes --> %d\n",
535 ep->name, req->length, status);
536 usb_ep_set_halt(ep);
537 /* FIXME recover later ... somehow */
538 }
539}
540
541static int set_gmidi_config(struct gmidi_device *dev, gfp_t gfp_flags)
542{
543 int err = 0;
544 struct usb_request *req;
545 struct usb_ep* ep;
546 unsigned i;
547
548 err = usb_ep_enable(dev->in_ep, &bulk_in_desc);
549 if (err) {
550 ERROR(dev, "can't start %s: %d\n", dev->in_ep->name, err);
551 goto fail;
552 }
553 dev->in_ep->driver_data = dev;
554
555 err = usb_ep_enable(dev->out_ep, &bulk_out_desc);
556 if (err) {
557 ERROR(dev, "can't start %s: %d\n", dev->out_ep->name, err);
558 goto fail;
559 }
560 dev->out_ep->driver_data = dev;
561
562 /* allocate a bunch of read buffers and queue them all at once. */
563 ep = dev->out_ep;
564 for (i = 0; i < qlen && err == 0; i++) {
565 req = alloc_ep_req(ep, buflen);
566 if (req) {
567 req->complete = gmidi_complete;
568 err = usb_ep_queue(ep, req, GFP_ATOMIC);
569 if (err) {
570 DBG(dev, "%s queue req: %d\n", ep->name, err);
571 }
572 } else {
573 err = -ENOMEM;
574 }
575 }
576fail:
577 /* caller is responsible for cleanup on error */
578 return err;
579}
580
581
582static void gmidi_reset_config(struct gmidi_device *dev)
583{
584 if (dev->config == 0) {
585 return;
586 }
587
588 DBG(dev, "reset config\n");
589
590 /* just disable endpoints, forcing completion of pending i/o.
591 * all our completion handlers free their requests in this case.
592 */
593 usb_ep_disable(dev->in_ep);
594 usb_ep_disable(dev->out_ep);
595 dev->config = 0;
596}
597
598/* change our operational config. this code must agree with the code
599 * that returns config descriptors, and altsetting code.
600 *
601 * it's also responsible for power management interactions. some
602 * configurations might not work with our current power sources.
603 *
604 * note that some device controller hardware will constrain what this
605 * code can do, perhaps by disallowing more than one configuration or
606 * by limiting configuration choices (like the pxa2xx).
607 */
608static int
609gmidi_set_config(struct gmidi_device *dev, unsigned number, gfp_t gfp_flags)
610{
611 int result = 0;
612 struct usb_gadget *gadget = dev->gadget;
613
614#if 0
615 /* FIXME */
616 /* Hacking this bit out fixes a bug where on receipt of two
617 USB_REQ_SET_CONFIGURATION messages, we end up with no
618 buffered OUT requests waiting for data. This is clearly
619 hiding a bug elsewhere, because if the config didn't
620 change then we really shouldn't do anything. */
621 /* Having said that, when we do "change" from config 1
622 to config 1, we at least gmidi_reset_config() which
623 clears out any requests on endpoints, so it's not like
624 we leak or anything. */
625 if (number == dev->config) {
626 return 0;
627 }
628#endif
629
630 if (gadget_is_sa1100(gadget) && dev->config) {
631 /* tx fifo is full, but we can't clear it...*/
632 INFO(dev, "can't change configurations\n");
633 return -ESPIPE;
634 }
635 gmidi_reset_config(dev);
636
637 switch (number) {
638 case GMIDI_CONFIG:
639 result = set_gmidi_config(dev, gfp_flags);
640 break;
641 default:
642 result = -EINVAL;
643 /* FALL THROUGH */
644 case 0:
645 return result;
646 }
647
648 if (!result && (!dev->in_ep || !dev->out_ep)) {
649 result = -ENODEV;
650 }
651 if (result) {
652 gmidi_reset_config(dev);
653 } else {
654 char *speed;
655
656 switch (gadget->speed) {
657 case USB_SPEED_LOW: speed = "low"; break;
658 case USB_SPEED_FULL: speed = "full"; break;
659 case USB_SPEED_HIGH: speed = "high"; break;
660 default: speed = "?"; break;
661 }
662
663 dev->config = number;
664 INFO(dev, "%s speed\n", speed);
665 }
666 return result;
667}
668
669
670static void gmidi_setup_complete(struct usb_ep *ep, struct usb_request *req)
671{
672 if (req->status || req->actual != req->length) {
673 DBG((struct gmidi_device *) ep->driver_data,
674 "setup complete --> %d, %d/%d\n",
675 req->status, req->actual, req->length);
676 }
677}
678
679/*
680 * The setup() callback implements all the ep0 functionality that's
681 * not handled lower down, in hardware or the hardware driver (like
682 * device and endpoint feature flags, and their status). It's all
683 * housekeeping for the gadget function we're implementing. Most of
684 * the work is in config-specific setup.
685 */
686static int gmidi_setup(struct usb_gadget *gadget,
687 const struct usb_ctrlrequest *ctrl)
688{
689 struct gmidi_device *dev = get_gadget_data(gadget);
690 struct usb_request *req = dev->req;
691 int value = -EOPNOTSUPP;
692 u16 w_index = le16_to_cpu(ctrl->wIndex);
693 u16 w_value = le16_to_cpu(ctrl->wValue);
694 u16 w_length = le16_to_cpu(ctrl->wLength);
695
696 /* usually this stores reply data in the pre-allocated ep0 buffer,
697 * but config change events will reconfigure hardware.
698 */
699 req->zero = 0;
700 switch (ctrl->bRequest) {
701
702 case USB_REQ_GET_DESCRIPTOR:
703 if (ctrl->bRequestType != USB_DIR_IN) {
704 goto unknown;
705 }
706 switch (w_value >> 8) {
707
708 case USB_DT_DEVICE:
709 value = min(w_length, (u16) sizeof(device_desc));
710 memcpy(req->buf, &device_desc, value);
711 break;
712 case USB_DT_CONFIG:
713 value = config_buf(gadget, req->buf,
714 w_value >> 8,
715 w_value & 0xff);
716 if (value >= 0) {
717 value = min(w_length, (u16)value);
718 }
719 break;
720
721 case USB_DT_STRING:
722 /* wIndex == language code.
723 * this driver only handles one language, you can
724 * add string tables for other languages, using
725 * any UTF-8 characters
726 */
727 value = usb_gadget_get_string(&stringtab,
728 w_value & 0xff, req->buf);
729 if (value >= 0) {
730 value = min(w_length, (u16)value);
731 }
732 break;
733 }
734 break;
735
736 /* currently two configs, two speeds */
737 case USB_REQ_SET_CONFIGURATION:
738 if (ctrl->bRequestType != 0) {
739 goto unknown;
740 }
741 if (gadget->a_hnp_support) {
742 DBG(dev, "HNP available\n");
743 } else if (gadget->a_alt_hnp_support) {
744 DBG(dev, "HNP needs a different root port\n");
745 } else {
746 VDBG(dev, "HNP inactive\n");
747 }
748 spin_lock(&dev->lock);
749 value = gmidi_set_config(dev, w_value, GFP_ATOMIC);
750 spin_unlock(&dev->lock);
751 break;
752 case USB_REQ_GET_CONFIGURATION:
753 if (ctrl->bRequestType != USB_DIR_IN) {
754 goto unknown;
755 }
756 *(u8 *)req->buf = dev->config;
757 value = min(w_length, (u16)1);
758 break;
759
760 /* until we add altsetting support, or other interfaces,
761 * only 0/0 are possible. pxa2xx only supports 0/0 (poorly)
762 * and already killed pending endpoint I/O.
763 */
764 case USB_REQ_SET_INTERFACE:
765 if (ctrl->bRequestType != USB_RECIP_INTERFACE) {
766 goto unknown;
767 }
768 spin_lock(&dev->lock);
769 if (dev->config && w_index < GMIDI_NUM_INTERFACES
770 && w_value == 0)
771 {
772 u8 config = dev->config;
773
774 /* resets interface configuration, forgets about
775 * previous transaction state (queued bufs, etc)
776 * and re-inits endpoint state (toggle etc)
777 * no response queued, just zero status == success.
778 * if we had more than one interface we couldn't
779 * use this "reset the config" shortcut.
780 */
781 gmidi_reset_config(dev);
782 gmidi_set_config(dev, config, GFP_ATOMIC);
783 value = 0;
784 }
785 spin_unlock(&dev->lock);
786 break;
787 case USB_REQ_GET_INTERFACE:
788 if (ctrl->bRequestType != (USB_DIR_IN|USB_RECIP_INTERFACE)) {
789 goto unknown;
790 }
791 if (!dev->config) {
792 break;
793 }
794 if (w_index >= GMIDI_NUM_INTERFACES) {
795 value = -EDOM;
796 break;
797 }
798 *(u8 *)req->buf = 0;
799 value = min(w_length, (u16)1);
800 break;
801
802 default:
803unknown:
804 VDBG(dev, "unknown control req%02x.%02x v%04x i%04x l%d\n",
805 ctrl->bRequestType, ctrl->bRequest,
806 w_value, w_index, w_length);
807 }
808
809 /* respond with data transfer before status phase? */
810 if (value >= 0) {
811 req->length = value;
812 req->zero = value < w_length;
813 value = usb_ep_queue(gadget->ep0, req, GFP_ATOMIC);
814 if (value < 0) {
815 DBG(dev, "ep_queue --> %d\n", value);
816 req->status = 0;
817 gmidi_setup_complete(gadget->ep0, req);
818 }
819 }
820
821 /* device either stalls (value < 0) or reports success */
822 return value;
823}
824
825static void gmidi_disconnect(struct usb_gadget *gadget)
826{
827 struct gmidi_device *dev = get_gadget_data(gadget);
828 unsigned long flags;
829
830 spin_lock_irqsave(&dev->lock, flags);
831 gmidi_reset_config(dev);
832
833 /* a more significant application might have some non-usb
834 * activities to quiesce here, saving resources like power
835 * or pushing the notification up a network stack.
836 */
837 spin_unlock_irqrestore(&dev->lock, flags);
838
839 /* next we may get setup() calls to enumerate new connections;
840 * or an unbind() during shutdown (including removing module).
841 */
842}
843
844static void /* __init_or_exit */ gmidi_unbind(struct usb_gadget *gadget)
845{
846 struct gmidi_device *dev = get_gadget_data(gadget);
847 struct snd_card* card;
848
849 DBG(dev, "unbind\n");
850
851 card = dev->card;
852 dev->card = NULL;
853 if (card) {
854 snd_card_free(card);
855 }
856
857 /* we've already been disconnected ... no i/o is active */
858 if (dev->req) {
859 dev->req->length = USB_BUFSIZ;
860 free_ep_req(gadget->ep0, dev->req);
861 }
862 kfree(dev);
863 set_gadget_data(gadget, NULL);
864}
865
866static int gmidi_snd_free(struct snd_device *device)
867{
868 return 0;
869}
870
871static void gmidi_transmit_packet(struct usb_request* req, uint8_t p0,
872 uint8_t p1, uint8_t p2, uint8_t p3)
873{
874 unsigned length = req->length;
875
876 uint8_t* buf = (uint8_t*)req->buf + length;
877 buf[0] = p0;
878 buf[1] = p1;
879 buf[2] = p2;
880 buf[3] = p3;
881 req->length = length + 4;
882}
883
884/*
885 * Converts MIDI commands to USB MIDI packets.
886 */
887static void gmidi_transmit_byte(struct usb_request* req,
888 struct gmidi_in_port* port, uint8_t b)
889{
890 uint8_t p0 = port->cable;
891
892 if (b >= 0xf8) {
893 gmidi_transmit_packet(req, p0 | 0x0f, b, 0, 0);
894 } else if (b >= 0xf0) {
895 switch (b) {
896 case 0xf0:
897 port->data[0] = b;
898 port->state = STATE_SYSEX_1;
899 break;
900 case 0xf1:
901 case 0xf3:
902 port->data[0] = b;
903 port->state = STATE_1PARAM;
904 break;
905 case 0xf2:
906 port->data[0] = b;
907 port->state = STATE_2PARAM_1;
908 break;
909 case 0xf4:
910 case 0xf5:
911 port->state = STATE_UNKNOWN;
912 break;
913 case 0xf6:
914 gmidi_transmit_packet(req, p0 | 0x05, 0xf6, 0, 0);
915 port->state = STATE_UNKNOWN;
916 break;
917 case 0xf7:
918 switch (port->state) {
919 case STATE_SYSEX_0:
920 gmidi_transmit_packet(req,
921 p0 | 0x05, 0xf7, 0, 0);
922 break;
923 case STATE_SYSEX_1:
924 gmidi_transmit_packet(req,
925 p0 | 0x06, port->data[0], 0xf7, 0);
926 break;
927 case STATE_SYSEX_2:
928 gmidi_transmit_packet(req,
929 p0 | 0x07, port->data[0],
930 port->data[1], 0xf7);
931 break;
932 }
933 port->state = STATE_UNKNOWN;
934 break;
935 }
936 } else if (b >= 0x80) {
937 port->data[0] = b;
938 if (b >= 0xc0 && b <= 0xdf)
939 port->state = STATE_1PARAM;
940 else
941 port->state = STATE_2PARAM_1;
942 } else { /* b < 0x80 */
943 switch (port->state) {
944 case STATE_1PARAM:
945 if (port->data[0] < 0xf0) {
946 p0 |= port->data[0] >> 4;
947 } else {
948 p0 |= 0x02;
949 port->state = STATE_UNKNOWN;
950 }
951 gmidi_transmit_packet(req, p0, port->data[0], b, 0);
952 break;
953 case STATE_2PARAM_1:
954 port->data[1] = b;
955 port->state = STATE_2PARAM_2;
956 break;
957 case STATE_2PARAM_2:
958 if (port->data[0] < 0xf0) {
959 p0 |= port->data[0] >> 4;
960 port->state = STATE_2PARAM_1;
961 } else {
962 p0 |= 0x03;
963 port->state = STATE_UNKNOWN;
964 }
965 gmidi_transmit_packet(req,
966 p0, port->data[0], port->data[1], b);
967 break;
968 case STATE_SYSEX_0:
969 port->data[0] = b;
970 port->state = STATE_SYSEX_1;
971 break;
972 case STATE_SYSEX_1:
973 port->data[1] = b;
974 port->state = STATE_SYSEX_2;
975 break;
976 case STATE_SYSEX_2:
977 gmidi_transmit_packet(req,
978 p0 | 0x04, port->data[0], port->data[1], b);
979 port->state = STATE_SYSEX_0;
980 break;
981 }
982 }
983}
984
985static void gmidi_transmit(struct gmidi_device* dev, struct usb_request* req)
986{
987 struct usb_ep* ep = dev->in_ep;
988 struct gmidi_in_port* port = &dev->in_port;
989
990 if (!ep) {
991 return;
992 }
993 if (!req) {
994 req = alloc_ep_req(ep, buflen);
995 }
996 if (!req) {
997 ERROR(dev, "gmidi_transmit: alloc_ep_request failed\n");
998 return;
999 }
1000 req->length = 0;
1001 req->complete = gmidi_complete;
1002
1003 if (port->active) {
1004 while (req->length + 3 < buflen) {
1005 uint8_t b;
1006 if (snd_rawmidi_transmit(dev->in_substream, &b, 1)
1007 != 1)
1008 {
1009 port->active = 0;
1010 break;
1011 }
1012 gmidi_transmit_byte(req, port, b);
1013 }
1014 }
1015 if (req->length > 0) {
1016 usb_ep_queue(ep, req, GFP_ATOMIC);
1017 } else {
1018 free_ep_req(ep, req);
1019 }
1020}
1021
1022static void gmidi_in_tasklet(unsigned long data)
1023{
1024 struct gmidi_device* dev = (struct gmidi_device*)data;
1025
1026 gmidi_transmit(dev, NULL);
1027}
1028
1029static int gmidi_in_open(struct snd_rawmidi_substream *substream)
1030{
1031 struct gmidi_device* dev = substream->rmidi->private_data;
1032
1033 VDBG(dev, "gmidi_in_open\n");
1034 dev->in_substream = substream;
1035 dev->in_port.state = STATE_UNKNOWN;
1036 return 0;
1037}
1038
1039static int gmidi_in_close(struct snd_rawmidi_substream *substream)
1040{
1041 VDBG(dev, "gmidi_in_close\n");
1042 return 0;
1043}
1044
1045static void gmidi_in_trigger(struct snd_rawmidi_substream *substream, int up)
1046{
1047 struct gmidi_device* dev = substream->rmidi->private_data;
1048
1049 VDBG(dev, "gmidi_in_trigger %d\n", up);
1050 dev->in_port.active = up;
1051 if (up) {
1052 tasklet_hi_schedule(&dev->tasklet);
1053 }
1054}
1055
1056static int gmidi_out_open(struct snd_rawmidi_substream *substream)
1057{
1058 struct gmidi_device* dev = substream->rmidi->private_data;
1059
1060 VDBG(dev, "gmidi_out_open\n");
1061 dev->out_substream = substream;
1062 return 0;
1063}
1064
1065static int gmidi_out_close(struct snd_rawmidi_substream *substream)
1066{
1067 VDBG(dev, "gmidi_out_close\n");
1068 return 0;
1069}
1070
1071static void gmidi_out_trigger(struct snd_rawmidi_substream *substream, int up)
1072{
1073 struct gmidi_device* dev = substream->rmidi->private_data;
1074
1075 VDBG(dev, "gmidi_out_trigger %d\n", up);
1076 if (up) {
1077 set_bit(substream->number, &dev->out_triggered);
1078 } else {
1079 clear_bit(substream->number, &dev->out_triggered);
1080 }
1081}
1082
1083static struct snd_rawmidi_ops gmidi_in_ops = {
1084 .open = gmidi_in_open,
1085 .close = gmidi_in_close,
1086 .trigger = gmidi_in_trigger,
1087};
1088
1089static struct snd_rawmidi_ops gmidi_out_ops = {
1090 .open = gmidi_out_open,
1091 .close = gmidi_out_close,
1092 .trigger = gmidi_out_trigger
1093};
1094
1095/* register as a sound "card" */
1096static int gmidi_register_card(struct gmidi_device *dev)
1097{
1098 struct snd_card *card;
1099 struct snd_rawmidi *rmidi;
1100 int err;
1101 int out_ports = 1;
1102 int in_ports = 1;
1103 static struct snd_device_ops ops = {
1104 .dev_free = gmidi_snd_free,
1105 };
1106
1107 card = snd_card_new(index, id, THIS_MODULE, 0);
1108 if (!card) {
1109 ERROR(dev, "snd_card_new failed\n");
1110 err = -ENOMEM;
1111 goto fail;
1112 }
1113 dev->card = card;
1114
1115 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, dev, &ops);
1116 if (err < 0) {
1117 ERROR(dev, "snd_device_new failed: error %d\n", err);
1118 goto fail;
1119 }
1120
1121 strcpy(card->driver, longname);
1122 strcpy(card->longname, longname);
1123 strcpy(card->shortname, shortname);
1124
1125 /* Set up rawmidi */
1126 dev->in_port.dev = dev;
1127 dev->in_port.active = 0;
1128 snd_component_add(card, "MIDI");
1129 err = snd_rawmidi_new(card, "USB MIDI Gadget", 0,
1130 out_ports, in_ports, &rmidi);
1131 if (err < 0) {
1132 ERROR(dev, "snd_rawmidi_new failed: error %d\n", err);
1133 goto fail;
1134 }
1135 dev->rmidi = rmidi;
1136 strcpy(rmidi->name, card->shortname);
1137 rmidi->info_flags = SNDRV_RAWMIDI_INFO_OUTPUT |
1138 SNDRV_RAWMIDI_INFO_INPUT |
1139 SNDRV_RAWMIDI_INFO_DUPLEX;
1140 rmidi->private_data = dev;
1141
1142 /* Yes, rawmidi OUTPUT = USB IN, and rawmidi INPUT = USB OUT.
1143 It's an upside-down world being a gadget. */
1144 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, &gmidi_in_ops);
1145 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, &gmidi_out_ops);
1146
1147 snd_card_set_dev(card, &dev->gadget->dev);
1148
1149 /* register it - we're ready to go */
1150 err = snd_card_register(card);
1151 if (err < 0) {
1152 ERROR(dev, "snd_card_register failed\n");
1153 goto fail;
1154 }
1155
1156 VDBG(dev, "gmidi_register_card finished ok\n");
1157 return 0;
1158
1159fail:
1160 if (dev->card) {
1161 snd_card_free(dev->card);
1162 dev->card = NULL;
1163 }
1164 return err;
1165}
1166
1167/*
1168 * Creates an output endpoint, and initializes output ports.
1169 */
1170static int __devinit gmidi_bind(struct usb_gadget *gadget)
1171{
1172 struct gmidi_device *dev;
1173 struct usb_ep *in_ep, *out_ep;
1174 int gcnum, err = 0;
1175
1176 /* support optional vendor/distro customization */
1177 if (idVendor) {
1178 if (!idProduct) {
1179 printk(KERN_ERR "idVendor needs idProduct!\n");
1180 return -ENODEV;
1181 }
1182 device_desc.idVendor = cpu_to_le16(idVendor);
1183 device_desc.idProduct = cpu_to_le16(idProduct);
1184 if (bcdDevice) {
1185 device_desc.bcdDevice = cpu_to_le16(bcdDevice);
1186 }
1187 }
1188 if (iManufacturer) {
1189 strlcpy(manufacturer, iManufacturer, sizeof(manufacturer));
1190 } else {
1191 snprintf(manufacturer, sizeof(manufacturer), "%s %s with %s",
1192 system_utsname.sysname, system_utsname.release,
1193 gadget->name);
1194 }
1195 if (iProduct) {
1196 strlcpy(product_desc, iProduct, sizeof(product_desc));
1197 }
1198 if (iSerialNumber) {
1199 device_desc.iSerialNumber = STRING_SERIAL,
1200 strlcpy(serial_number, iSerialNumber, sizeof(serial_number));
1201 }
1202
1203 /* Bulk-only drivers like this one SHOULD be able to
1204 * autoconfigure on any sane usb controller driver,
1205 * but there may also be important quirks to address.
1206 */
1207 usb_ep_autoconfig_reset(gadget);
1208 in_ep = usb_ep_autoconfig(gadget, &bulk_in_desc);
1209 if (!in_ep) {
1210autoconf_fail:
1211 printk(KERN_ERR "%s: can't autoconfigure on %s\n",
1212 shortname, gadget->name);
1213 return -ENODEV;
1214 }
1215 EP_IN_NAME = in_ep->name;
1216 in_ep->driver_data = in_ep; /* claim */
1217
1218 out_ep = usb_ep_autoconfig(gadget, &bulk_out_desc);
1219 if (!out_ep) {
1220 goto autoconf_fail;
1221 }
1222 EP_OUT_NAME = out_ep->name;
1223 out_ep->driver_data = out_ep; /* claim */
1224
1225 gcnum = usb_gadget_controller_number(gadget);
1226 if (gcnum >= 0) {
1227 device_desc.bcdDevice = cpu_to_le16(0x0200 + gcnum);
1228 } else {
1229 /* gmidi is so simple (no altsettings) that
1230 * it SHOULD NOT have problems with bulk-capable hardware.
1231 * so warn about unrecognized controllers, don't panic.
1232 */
1233 printk(KERN_WARNING "%s: controller '%s' not recognized\n",
1234 shortname, gadget->name);
1235 device_desc.bcdDevice = __constant_cpu_to_le16(0x9999);
1236 }
1237
1238
1239 /* ok, we made sense of the hardware ... */
1240 dev = kzalloc(sizeof(*dev), SLAB_KERNEL);
1241 if (!dev) {
1242 return -ENOMEM;
1243 }
1244 spin_lock_init(&dev->lock);
1245 dev->gadget = gadget;
1246 dev->in_ep = in_ep;
1247 dev->out_ep = out_ep;
1248 set_gadget_data(gadget, dev);
1249 tasklet_init(&dev->tasklet, gmidi_in_tasklet, (unsigned long)dev);
1250
1251 /* preallocate control response and buffer */
1252 dev->req = usb_ep_alloc_request(gadget->ep0, GFP_KERNEL);
1253 if (!dev->req) {
1254 err = -ENOMEM;
1255 goto fail;
1256 }
1257 dev->req->buf = usb_ep_alloc_buffer(gadget->ep0, USB_BUFSIZ,
1258 &dev->req->dma, GFP_KERNEL);
1259 if (!dev->req->buf) {
1260 err = -ENOMEM;
1261 goto fail;
1262 }
1263
1264 dev->req->complete = gmidi_setup_complete;
1265
1266 device_desc.bMaxPacketSize0 = gadget->ep0->maxpacket;
1267
1268 gadget->ep0->driver_data = dev;
1269
1270 INFO(dev, "%s, version: " DRIVER_VERSION "\n", longname);
1271 INFO(dev, "using %s, OUT %s IN %s\n", gadget->name,
1272 EP_OUT_NAME, EP_IN_NAME);
1273
1274 /* register as an ALSA sound card */
1275 err = gmidi_register_card(dev);
1276 if (err < 0) {
1277 goto fail;
1278 }
1279
1280 VDBG(dev, "gmidi_bind finished ok\n");
1281 return 0;
1282
1283fail:
1284 gmidi_unbind(gadget);
1285 return err;
1286}
1287
1288
1289static void gmidi_suspend(struct usb_gadget *gadget)
1290{
1291 struct gmidi_device *dev = get_gadget_data(gadget);
1292
1293 if (gadget->speed == USB_SPEED_UNKNOWN) {
1294 return;
1295 }
1296
1297 DBG(dev, "suspend\n");
1298}
1299
1300static void gmidi_resume(struct usb_gadget *gadget)
1301{
1302 struct gmidi_device *dev = get_gadget_data(gadget);
1303
1304 DBG(dev, "resume\n");
1305}
1306
1307
1308static struct usb_gadget_driver gmidi_driver = {
1309 .speed = USB_SPEED_FULL,
1310 .function = (char *)longname,
1311 .bind = gmidi_bind,
1312 .unbind = __exit_p(gmidi_unbind),
1313
1314 .setup = gmidi_setup,
1315 .disconnect = gmidi_disconnect,
1316
1317 .suspend = gmidi_suspend,
1318 .resume = gmidi_resume,
1319
1320 .driver = {
1321 .name = (char *)shortname,
1322 .owner = THIS_MODULE,
1323 },
1324};
1325
1326static int __init gmidi_init(void)
1327{
1328 return usb_gadget_register_driver(&gmidi_driver);
1329}
1330module_init(gmidi_init);
1331
1332static void __exit gmidi_cleanup(void)
1333{
1334 usb_gadget_unregister_driver(&gmidi_driver);
1335}
1336module_exit(gmidi_cleanup);
1337
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c
index 3bdc5e3ba234..4655522a08d9 100644
--- a/drivers/usb/gadget/inode.c
+++ b/drivers/usb/gadget/inode.c
@@ -32,6 +32,7 @@
32#include <linux/compiler.h> 32#include <linux/compiler.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/poll.h>
35 36
36#include <linux/device.h> 37#include <linux/device.h>
37#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
@@ -222,7 +223,6 @@ static void put_ep (struct ep_data *data)
222 /* needs no more cleanup */ 223 /* needs no more cleanup */
223 BUG_ON (!list_empty (&data->epfiles)); 224 BUG_ON (!list_empty (&data->epfiles));
224 BUG_ON (waitqueue_active (&data->wait)); 225 BUG_ON (waitqueue_active (&data->wait));
225 BUG_ON (down_trylock (&data->lock) != 0);
226 kfree (data); 226 kfree (data);
227} 227}
228 228
@@ -477,6 +477,10 @@ static int
477ep_release (struct inode *inode, struct file *fd) 477ep_release (struct inode *inode, struct file *fd)
478{ 478{
479 struct ep_data *data = fd->private_data; 479 struct ep_data *data = fd->private_data;
480 int value;
481
482 if ((value = down_interruptible(&data->lock)) < 0)
483 return value;
480 484
481 /* clean up if this can be reopened */ 485 /* clean up if this can be reopened */
482 if (data->state != STATE_EP_UNBOUND) { 486 if (data->state != STATE_EP_UNBOUND) {
@@ -485,6 +489,7 @@ ep_release (struct inode *inode, struct file *fd)
485 data->hs_desc.bDescriptorType = 0; 489 data->hs_desc.bDescriptorType = 0;
486 usb_ep_disable(data->ep); 490 usb_ep_disable(data->ep);
487 } 491 }
492 up (&data->lock);
488 put_ep (data); 493 put_ep (data);
489 return 0; 494 return 0;
490} 495}
@@ -709,7 +714,7 @@ ep_aio_write(struct kiocb *iocb, const char __user *ubuf, size_t len, loff_t o)
709/*----------------------------------------------------------------------*/ 714/*----------------------------------------------------------------------*/
710 715
711/* used after endpoint configuration */ 716/* used after endpoint configuration */
712static struct file_operations ep_io_operations = { 717static const struct file_operations ep_io_operations = {
713 .owner = THIS_MODULE, 718 .owner = THIS_MODULE,
714 .llseek = no_llseek, 719 .llseek = no_llseek,
715 720
@@ -741,7 +746,7 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
741 struct ep_data *data = fd->private_data; 746 struct ep_data *data = fd->private_data;
742 struct usb_ep *ep; 747 struct usb_ep *ep;
743 u32 tag; 748 u32 tag;
744 int value; 749 int value, length = len;
745 750
746 if ((value = down_interruptible (&data->lock)) < 0) 751 if ((value = down_interruptible (&data->lock)) < 0)
747 return value; 752 return value;
@@ -792,7 +797,6 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
792 goto fail0; 797 goto fail0;
793 } 798 }
794 } 799 }
795 value = len;
796 800
797 spin_lock_irq (&data->dev->lock); 801 spin_lock_irq (&data->dev->lock);
798 if (data->dev->state == STATE_DEV_UNBOUND) { 802 if (data->dev->state == STATE_DEV_UNBOUND) {
@@ -822,8 +826,10 @@ ep_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
822 data->name); 826 data->name);
823 data->state = STATE_EP_DEFER_ENABLE; 827 data->state = STATE_EP_DEFER_ENABLE;
824 } 828 }
825 if (value == 0) 829 if (value == 0) {
826 fd->f_op = &ep_io_operations; 830 fd->f_op = &ep_io_operations;
831 value = length;
832 }
827gone: 833gone:
828 spin_unlock_irq (&data->dev->lock); 834 spin_unlock_irq (&data->dev->lock);
829 if (value < 0) { 835 if (value < 0) {
@@ -844,7 +850,7 @@ fail1:
844static int 850static int
845ep_open (struct inode *inode, struct file *fd) 851ep_open (struct inode *inode, struct file *fd)
846{ 852{
847 struct ep_data *data = inode->u.generic_ip; 853 struct ep_data *data = inode->i_private;
848 int value = -EBUSY; 854 int value = -EBUSY;
849 855
850 if (down_interruptible (&data->lock) != 0) 856 if (down_interruptible (&data->lock) != 0)
@@ -867,7 +873,7 @@ ep_open (struct inode *inode, struct file *fd)
867} 873}
868 874
869/* used before endpoint configuration */ 875/* used before endpoint configuration */
870static struct file_operations ep_config_operations = { 876static const struct file_operations ep_config_operations = {
871 .owner = THIS_MODULE, 877 .owner = THIS_MODULE,
872 .llseek = no_llseek, 878 .llseek = no_llseek,
873 879
@@ -1009,7 +1015,7 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
1009 else { 1015 else {
1010 len = min (len, (size_t)dev->req->actual); 1016 len = min (len, (size_t)dev->req->actual);
1011// FIXME don't call this with the spinlock held ... 1017// FIXME don't call this with the spinlock held ...
1012 if (copy_to_user (buf, &dev->req->buf, len)) 1018 if (copy_to_user (buf, dev->req->buf, len))
1013 retval = -EFAULT; 1019 retval = -EFAULT;
1014 clean_req (dev->gadget->ep0, dev->req); 1020 clean_req (dev->gadget->ep0, dev->req);
1015 /* NOTE userspace can't yet choose to stall */ 1021 /* NOTE userspace can't yet choose to stall */
@@ -1229,6 +1235,35 @@ dev_release (struct inode *inode, struct file *fd)
1229 return 0; 1235 return 0;
1230} 1236}
1231 1237
1238static unsigned int
1239ep0_poll (struct file *fd, poll_table *wait)
1240{
1241 struct dev_data *dev = fd->private_data;
1242 int mask = 0;
1243
1244 poll_wait(fd, &dev->wait, wait);
1245
1246 spin_lock_irq (&dev->lock);
1247
1248 /* report fd mode change before acting on it */
1249 if (dev->setup_abort) {
1250 dev->setup_abort = 0;
1251 mask = POLLHUP;
1252 goto out;
1253 }
1254
1255 if (dev->state == STATE_SETUP) {
1256 if (dev->setup_in || dev->setup_can_stall)
1257 mask = POLLOUT;
1258 } else {
1259 if (dev->ev_next != 0)
1260 mask = POLLIN;
1261 }
1262out:
1263 spin_unlock_irq(&dev->lock);
1264 return mask;
1265}
1266
1232static int dev_ioctl (struct inode *inode, struct file *fd, 1267static int dev_ioctl (struct inode *inode, struct file *fd,
1233 unsigned code, unsigned long value) 1268 unsigned code, unsigned long value)
1234{ 1269{
@@ -1241,14 +1276,14 @@ static int dev_ioctl (struct inode *inode, struct file *fd,
1241} 1276}
1242 1277
1243/* used after device configuration */ 1278/* used after device configuration */
1244static struct file_operations ep0_io_operations = { 1279static const struct file_operations ep0_io_operations = {
1245 .owner = THIS_MODULE, 1280 .owner = THIS_MODULE,
1246 .llseek = no_llseek, 1281 .llseek = no_llseek,
1247 1282
1248 .read = ep0_read, 1283 .read = ep0_read,
1249 .write = ep0_write, 1284 .write = ep0_write,
1250 .fasync = ep0_fasync, 1285 .fasync = ep0_fasync,
1251 // .poll = ep0_poll, 1286 .poll = ep0_poll,
1252 .ioctl = dev_ioctl, 1287 .ioctl = dev_ioctl,
1253 .release = dev_release, 1288 .release = dev_release,
1254}; 1289};
@@ -1696,16 +1731,17 @@ gadgetfs_disconnect (struct usb_gadget *gadget)
1696{ 1731{
1697 struct dev_data *dev = get_gadget_data (gadget); 1732 struct dev_data *dev = get_gadget_data (gadget);
1698 1733
1734 spin_lock (&dev->lock);
1699 if (dev->state == STATE_UNCONNECTED) { 1735 if (dev->state == STATE_UNCONNECTED) {
1700 DBG (dev, "already unconnected\n"); 1736 DBG (dev, "already unconnected\n");
1701 return; 1737 goto exit;
1702 } 1738 }
1703 dev->state = STATE_UNCONNECTED; 1739 dev->state = STATE_UNCONNECTED;
1704 1740
1705 INFO (dev, "disconnected\n"); 1741 INFO (dev, "disconnected\n");
1706 spin_lock (&dev->lock);
1707 next_event (dev, GADGETFS_DISCONNECT); 1742 next_event (dev, GADGETFS_DISCONNECT);
1708 ep0_readable (dev); 1743 ep0_readable (dev);
1744exit:
1709 spin_unlock (&dev->lock); 1745 spin_unlock (&dev->lock);
1710} 1746}
1711 1747
@@ -1909,7 +1945,7 @@ fail:
1909static int 1945static int
1910dev_open (struct inode *inode, struct file *fd) 1946dev_open (struct inode *inode, struct file *fd)
1911{ 1947{
1912 struct dev_data *dev = inode->u.generic_ip; 1948 struct dev_data *dev = inode->i_private;
1913 int value = -EBUSY; 1949 int value = -EBUSY;
1914 1950
1915 if (dev->state == STATE_DEV_DISABLED) { 1951 if (dev->state == STATE_DEV_DISABLED) {
@@ -1922,7 +1958,7 @@ dev_open (struct inode *inode, struct file *fd)
1922 return value; 1958 return value;
1923} 1959}
1924 1960
1925static struct file_operations dev_init_operations = { 1961static const struct file_operations dev_init_operations = {
1926 .owner = THIS_MODULE, 1962 .owner = THIS_MODULE,
1927 .llseek = no_llseek, 1963 .llseek = no_llseek,
1928 1964
@@ -1966,11 +2002,10 @@ gadgetfs_make_inode (struct super_block *sb,
1966 inode->i_mode = mode; 2002 inode->i_mode = mode;
1967 inode->i_uid = default_uid; 2003 inode->i_uid = default_uid;
1968 inode->i_gid = default_gid; 2004 inode->i_gid = default_gid;
1969 inode->i_blksize = PAGE_CACHE_SIZE;
1970 inode->i_blocks = 0; 2005 inode->i_blocks = 0;
1971 inode->i_atime = inode->i_mtime = inode->i_ctime 2006 inode->i_atime = inode->i_mtime = inode->i_ctime
1972 = CURRENT_TIME; 2007 = CURRENT_TIME;
1973 inode->u.generic_ip = data; 2008 inode->i_private = data;
1974 inode->i_fop = fops; 2009 inode->i_fop = fops;
1975 } 2010 }
1976 return inode; 2011 return inode;
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 09243239d948..3bda37f9a35f 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2,7 +2,7 @@
2 * Driver for the PLX NET2280 USB device controller. 2 * Driver for the PLX NET2280 USB device controller.
3 * Specs and errata are available from <http://www.plxtech.com>. 3 * Specs and errata are available from <http://www.plxtech.com>.
4 * 4 *
5 * PLX Technology Inc. (formerly NetChip Technology) supported the 5 * PLX Technology Inc. (formerly NetChip Technology) supported the
6 * development of this driver. 6 * development of this driver.
7 * 7 *
8 * 8 *
@@ -26,7 +26,8 @@
26 * Copyright (C) 2003 David Brownell 26 * Copyright (C) 2003 David Brownell
27 * Copyright (C) 2003-2005 PLX Technology, Inc. 27 * Copyright (C) 2003-2005 PLX Technology, Inc.
28 * 28 *
29 * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility with 2282 chip 29 * Modified Seth Levy 2005 PLX Technology, Inc. to provide compatibility
30 * with 2282 chip
30 * 31 *
31 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
32 * it under the terms of the GNU General Public License as published by 33 * it under the terms of the GNU General Public License as published by
@@ -85,7 +86,7 @@ static const char driver_name [] = "net2280";
85static const char driver_desc [] = DRIVER_DESC; 86static const char driver_desc [] = DRIVER_DESC;
86 87
87static const char ep0name [] = "ep0"; 88static const char ep0name [] = "ep0";
88static const char *ep_name [] = { 89static const char *const ep_name [] = {
89 ep0name, 90 ep0name,
90 "ep-a", "ep-b", "ep-c", "ep-d", 91 "ep-a", "ep-b", "ep-c", "ep-d",
91 "ep-e", "ep-f", 92 "ep-e", "ep-f",
@@ -225,7 +226,9 @@ net2280_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc)
225 if (!ep->is_in) 226 if (!ep->is_in)
226 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp); 227 writel ((1 << SET_NAK_OUT_PACKETS), &ep->regs->ep_rsp);
227 else if (dev->pdev->device != 0x2280) { 228 else if (dev->pdev->device != 0x2280) {
228 /* Added for 2282, Don't use nak packets on an in endpoint, this was ignored on 2280 */ 229 /* Added for 2282, Don't use nak packets on an in endpoint,
230 * this was ignored on 2280
231 */
229 writel ((1 << CLEAR_NAK_OUT_PACKETS) 232 writel ((1 << CLEAR_NAK_OUT_PACKETS)
230 | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp); 233 | (1 << CLEAR_NAK_OUT_PACKETS_MODE), &ep->regs->ep_rsp);
231 } 234 }
@@ -288,7 +291,7 @@ static int handshake (u32 __iomem *ptr, u32 mask, u32 done, int usec)
288 return -ETIMEDOUT; 291 return -ETIMEDOUT;
289} 292}
290 293
291static struct usb_ep_ops net2280_ep_ops; 294static const struct usb_ep_ops net2280_ep_ops;
292 295
293static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep) 296static void ep_reset (struct net2280_regs __iomem *regs, struct net2280_ep *ep)
294{ 297{
@@ -449,34 +452,15 @@ net2280_free_request (struct usb_ep *_ep, struct usb_request *_req)
449 452
450/*-------------------------------------------------------------------------*/ 453/*-------------------------------------------------------------------------*/
451 454
452#undef USE_KMALLOC 455/*
453 456 * dma-coherent memory allocation (for dma-capable endpoints)
454/* many common platforms have dma-coherent caches, which means that it's
455 * safe to use kmalloc() memory for all i/o buffers without using any
456 * cache flushing calls. (unless you're trying to share cache lines
457 * between dma and non-dma activities, which is a slow idea in any case.)
458 * 457 *
459 * other platforms need more care, with 2.5 having a moderately general 458 * NOTE: the dma_*_coherent() API calls suck. Most implementations are
460 * solution (which falls down for allocations smaller than one page) 459 * (a) page-oriented, so small buffers lose big; and (b) asymmetric with
461 * that improves significantly on the 2.4 PCI allocators by removing 460 * respect to calls with irqs disabled: alloc is safe, free is not.
462 * the restriction that memory never be freed in_interrupt(). 461 * We currently work around (b), but not (a).
463 */ 462 */
464#if defined(CONFIG_X86)
465#define USE_KMALLOC
466
467#elif defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE)
468#define USE_KMALLOC
469 463
470#elif defined(CONFIG_MIPS) && !defined(CONFIG_DMA_NONCOHERENT)
471#define USE_KMALLOC
472
473/* FIXME there are other cases, including an x86-64 one ... */
474#endif
475
476/* allocating buffers this way eliminates dma mapping overhead, which
477 * on some platforms will mean eliminating a per-io buffer copy. with
478 * some kinds of system caches, further tweaks may still be needed.
479 */
480static void * 464static void *
481net2280_alloc_buffer ( 465net2280_alloc_buffer (
482 struct usb_ep *_ep, 466 struct usb_ep *_ep,
@@ -493,43 +477,71 @@ net2280_alloc_buffer (
493 return NULL; 477 return NULL;
494 *dma = DMA_ADDR_INVALID; 478 *dma = DMA_ADDR_INVALID;
495 479
496#if defined(USE_KMALLOC) 480 if (ep->dma)
497 retval = kmalloc(bytes, gfp_flags);
498 if (retval)
499 *dma = virt_to_phys(retval);
500#else
501 if (ep->dma) {
502 /* the main problem with this call is that it wastes memory
503 * on typical 1/N page allocations: it allocates 1-N pages.
504 */
505#warning Using dma_alloc_coherent even with buffers smaller than a page.
506 retval = dma_alloc_coherent(&ep->dev->pdev->dev, 481 retval = dma_alloc_coherent(&ep->dev->pdev->dev,
507 bytes, dma, gfp_flags); 482 bytes, dma, gfp_flags);
508 } else 483 else
509 retval = kmalloc(bytes, gfp_flags); 484 retval = kmalloc(bytes, gfp_flags);
510#endif
511 return retval; 485 return retval;
512} 486}
513 487
488static DEFINE_SPINLOCK(buflock);
489static LIST_HEAD(buffers);
490
491struct free_record {
492 struct list_head list;
493 struct device *dev;
494 unsigned bytes;
495 dma_addr_t dma;
496};
497
498static void do_free(unsigned long ignored)
499{
500 spin_lock_irq(&buflock);
501 while (!list_empty(&buffers)) {
502 struct free_record *buf;
503
504 buf = list_entry(buffers.next, struct free_record, list);
505 list_del(&buf->list);
506 spin_unlock_irq(&buflock);
507
508 dma_free_coherent(buf->dev, buf->bytes, buf, buf->dma);
509
510 spin_lock_irq(&buflock);
511 }
512 spin_unlock_irq(&buflock);
513}
514
515static DECLARE_TASKLET(deferred_free, do_free, 0);
516
514static void 517static void
515net2280_free_buffer ( 518net2280_free_buffer (
516 struct usb_ep *_ep, 519 struct usb_ep *_ep,
517 void *buf, 520 void *address,
518 dma_addr_t dma, 521 dma_addr_t dma,
519 unsigned bytes 522 unsigned bytes
520) { 523) {
521 /* free memory into the right allocator */ 524 /* free memory into the right allocator */
522#ifndef USE_KMALLOC
523 if (dma != DMA_ADDR_INVALID) { 525 if (dma != DMA_ADDR_INVALID) {
524 struct net2280_ep *ep; 526 struct net2280_ep *ep;
527 struct free_record *buf = address;
528 unsigned long flags;
525 529
526 ep = container_of(_ep, struct net2280_ep, ep); 530 ep = container_of(_ep, struct net2280_ep, ep);
527 if (!_ep) 531 if (!_ep)
528 return; 532 return;
529 dma_free_coherent(&ep->dev->pdev->dev, bytes, buf, dma); 533
534 ep = container_of (_ep, struct net2280_ep, ep);
535 buf->dev = &ep->dev->pdev->dev;
536 buf->bytes = bytes;
537 buf->dma = dma;
538
539 spin_lock_irqsave(&buflock, flags);
540 list_add_tail(&buf->list, &buffers);
541 tasklet_schedule(&deferred_free);
542 spin_unlock_irqrestore(&buflock, flags);
530 } else 543 } else
531#endif 544 kfree (address);
532 kfree (buf);
533} 545}
534 546
535/*-------------------------------------------------------------------------*/ 547/*-------------------------------------------------------------------------*/
@@ -737,7 +749,8 @@ fill_dma_desc (struct net2280_ep *ep, struct net2280_request *req, int valid)
737 */ 749 */
738 if (ep->is_in) 750 if (ep->is_in)
739 dmacount |= (1 << DMA_DIRECTION); 751 dmacount |= (1 << DMA_DIRECTION);
740 if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0) || ep->dev->pdev->device != 0x2280) 752 if ((!ep->is_in && (dmacount % ep->ep.maxpacket) != 0)
753 || ep->dev->pdev->device != 0x2280)
741 dmacount |= (1 << END_OF_CHAIN); 754 dmacount |= (1 << END_OF_CHAIN);
742 755
743 req->valid = valid; 756 req->valid = valid;
@@ -812,7 +825,7 @@ static void start_dma (struct net2280_ep *ep, struct net2280_request *req)
812 825
813 /* previous OUT packet might have been short */ 826 /* previous OUT packet might have been short */
814 if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat)) 827 if (!ep->is_in && ((tmp = readl (&ep->regs->ep_stat))
815 & (1 << NAK_OUT_PACKETS)) != 0) { 828 & (1 << NAK_OUT_PACKETS)) != 0) {
816 writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT), 829 writel ((1 << SHORT_PACKET_TRANSFERRED_INTERRUPT),
817 &ep->regs->ep_stat); 830 &ep->regs->ep_stat);
818 831
@@ -1373,7 +1386,7 @@ net2280_fifo_flush (struct usb_ep *_ep)
1373 (void) readl (&ep->regs->ep_rsp); 1386 (void) readl (&ep->regs->ep_rsp);
1374} 1387}
1375 1388
1376static struct usb_ep_ops net2280_ep_ops = { 1389static const struct usb_ep_ops net2280_ep_ops = {
1377 .enable = net2280_enable, 1390 .enable = net2280_enable,
1378 .disable = net2280_disable, 1391 .disable = net2280_disable,
1379 1392
@@ -1631,7 +1644,7 @@ show_registers (struct device *_dev, struct device_attribute *attr, char *buf)
1631 } 1644 }
1632 1645
1633 /* Indexed Registers */ 1646 /* Indexed Registers */
1634 // none yet 1647 // none yet
1635 1648
1636 /* Statistics */ 1649 /* Statistics */
1637 t = scnprintf (next, size, "\nirqs: "); 1650 t = scnprintf (next, size, "\nirqs: ");
@@ -1691,11 +1704,11 @@ show_queues (struct device *_dev, struct device_attribute *attr, char *buf)
1691 ({ char *val; 1704 ({ char *val;
1692 switch (d->bmAttributes & 0x03) { 1705 switch (d->bmAttributes & 0x03) {
1693 case USB_ENDPOINT_XFER_BULK: 1706 case USB_ENDPOINT_XFER_BULK:
1694 val = "bulk"; break; 1707 val = "bulk"; break;
1695 case USB_ENDPOINT_XFER_INT: 1708 case USB_ENDPOINT_XFER_INT:
1696 val = "intr"; break; 1709 val = "intr"; break;
1697 default: 1710 default:
1698 val = "iso"; break; 1711 val = "iso"; break;
1699 }; val; }), 1712 }; val; }),
1700 le16_to_cpu (d->wMaxPacketSize) & 0x1fff, 1713 le16_to_cpu (d->wMaxPacketSize) & 0x1fff,
1701 ep->dma ? "dma" : "pio", ep->fifo_size 1714 ep->dma ? "dma" : "pio", ep->fifo_size
@@ -1808,8 +1821,8 @@ extern int net2280_set_fifo_mode (struct usb_gadget *gadget, int mode);
1808 * net2280_set_fifo_mode - change allocation of fifo buffers 1821 * net2280_set_fifo_mode - change allocation of fifo buffers
1809 * @gadget: access to the net2280 device that will be updated 1822 * @gadget: access to the net2280 device that will be updated
1810 * @mode: 0 for default, four 1kB buffers (ep-a through ep-d); 1823 * @mode: 0 for default, four 1kB buffers (ep-a through ep-d);
1811 * 1 for two 2kB buffers (ep-a and ep-b only); 1824 * 1 for two 2kB buffers (ep-a and ep-b only);
1812 * 2 for one 2kB buffer (ep-a) and two 1kB ones (ep-b, ep-c). 1825 * 2 for one 2kB buffer (ep-a) and two 1kB ones (ep-b, ep-c).
1813 * 1826 *
1814 * returns zero on success, else negative errno. when this succeeds, 1827 * returns zero on success, else negative errno. when this succeeds,
1815 * the contents of gadget->ep_list may have changed. 1828 * the contents of gadget->ep_list may have changed.
@@ -2241,7 +2254,8 @@ static void handle_ep_small (struct net2280_ep *ep)
2241 req->td->dmacount = 0; 2254 req->td->dmacount = 0;
2242 t = readl (&ep->regs->ep_avail); 2255 t = readl (&ep->regs->ep_avail);
2243 dma_done (ep, req, count, 2256 dma_done (ep, req, count,
2244 (ep->out_overflow || t) ? -EOVERFLOW : 0); 2257 (ep->out_overflow || t)
2258 ? -EOVERFLOW : 0);
2245 } 2259 }
2246 2260
2247 /* also flush to prevent erratum 0106 trouble */ 2261 /* also flush to prevent erratum 0106 trouble */
@@ -2411,7 +2425,7 @@ static void handle_stat0_irqs (struct net2280 *dev, u32 stat)
2411 , &ep->regs->ep_stat); 2425 , &ep->regs->ep_stat);
2412 u.raw [0] = readl (&dev->usb->setup0123); 2426 u.raw [0] = readl (&dev->usb->setup0123);
2413 u.raw [1] = readl (&dev->usb->setup4567); 2427 u.raw [1] = readl (&dev->usb->setup4567);
2414 2428
2415 cpu_to_le32s (&u.raw [0]); 2429 cpu_to_le32s (&u.raw [0]);
2416 cpu_to_le32s (&u.raw [1]); 2430 cpu_to_le32s (&u.raw [1]);
2417 2431
@@ -2578,14 +2592,16 @@ static void handle_stat1_irqs (struct net2280 *dev, u32 stat)
2578 2592
2579 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set. 2593 /* VBUS disconnect is indicated by VBUS_PIN and VBUS_INTERRUPT set.
2580 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRRUPT set and 2594 * Root Port Reset is indicated by ROOT_PORT_RESET_INTERRRUPT set and
2581 * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT 2595 * both HIGH_SPEED and FULL_SPEED clear (as ROOT_PORT_RESET_INTERRUPT
2582 * only indicates a change in the reset state). 2596 * only indicates a change in the reset state).
2583 */ 2597 */
2584 if (stat & tmp) { 2598 if (stat & tmp) {
2585 writel (tmp, &dev->regs->irqstat1); 2599 writel (tmp, &dev->regs->irqstat1);
2586 if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT)) && 2600 if ((((stat & (1 << ROOT_PORT_RESET_INTERRUPT))
2587 ((readl (&dev->usb->usbstat) & mask) == 0)) 2601 && ((readl (&dev->usb->usbstat) & mask)
2588 || ((readl (&dev->usb->usbctl) & (1 << VBUS_PIN)) == 0) 2602 == 0))
2603 || ((readl (&dev->usb->usbctl)
2604 & (1 << VBUS_PIN)) == 0)
2589 ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) { 2605 ) && ( dev->gadget.speed != USB_SPEED_UNKNOWN)) {
2590 DEBUG (dev, "disconnect %s\n", 2606 DEBUG (dev, "disconnect %s\n",
2591 dev->driver->driver.name); 2607 dev->driver->driver.name);
@@ -2852,7 +2868,7 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2852 2868
2853 /* now all the pci goodies ... */ 2869 /* now all the pci goodies ... */
2854 if (pci_enable_device (pdev) < 0) { 2870 if (pci_enable_device (pdev) < 0) {
2855 retval = -ENODEV; 2871 retval = -ENODEV;
2856 goto done; 2872 goto done;
2857 } 2873 }
2858 dev->enabled = 1; 2874 dev->enabled = 1;
@@ -2870,6 +2886,10 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id)
2870 } 2886 }
2871 dev->region = 1; 2887 dev->region = 1;
2872 2888
2889 /* FIXME provide firmware download interface to put
2890 * 8051 code into the chip, e.g. to turn on PCI PM.
2891 */
2892
2873 base = ioremap_nocache (resource, len); 2893 base = ioremap_nocache (resource, len);
2874 if (base == NULL) { 2894 if (base == NULL) {
2875 DEBUG (dev, "can't map memory\n"); 2895 DEBUG (dev, "can't map memory\n");
@@ -2984,16 +3004,16 @@ static void net2280_shutdown (struct pci_dev *pdev)
2984 3004
2985/*-------------------------------------------------------------------------*/ 3005/*-------------------------------------------------------------------------*/
2986 3006
2987static struct pci_device_id pci_ids [] = { { 3007static const struct pci_device_id pci_ids [] = { {
2988 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), 3008 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
2989 .class_mask = ~0, 3009 .class_mask = ~0,
2990 .vendor = 0x17cc, 3010 .vendor = 0x17cc,
2991 .device = 0x2280, 3011 .device = 0x2280,
2992 .subvendor = PCI_ANY_ID, 3012 .subvendor = PCI_ANY_ID,
2993 .subdevice = PCI_ANY_ID, 3013 .subdevice = PCI_ANY_ID,
2994}, { 3014}, {
2995 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe), 3015 .class = ((PCI_CLASS_SERIAL_USB << 8) | 0xfe),
2996 .class_mask = ~0, 3016 .class_mask = ~0,
2997 .vendor = 0x17cc, 3017 .vendor = 0x17cc,
2998 .device = 0x2282, 3018 .device = 0x2282,
2999 .subvendor = PCI_ANY_ID, 3019 .subvendor = PCI_ANY_ID,
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 2de9748ee673..0a64504c2545 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -40,7 +40,7 @@
40#include <linux/platform_device.h> 40#include <linux/platform_device.h>
41#include <linux/usb_ch9.h> 41#include <linux/usb_ch9.h>
42#include <linux/usb_gadget.h> 42#include <linux/usb_gadget.h>
43#include <linux/usb_otg.h> 43#include <linux/usb/otg.h>
44#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
45 45
46#include <asm/byteorder.h> 46#include <asm/byteorder.h>
@@ -2437,7 +2437,7 @@ static int proc_udc_open(struct inode *inode, struct file *file)
2437 return single_open(file, proc_udc_show, NULL); 2437 return single_open(file, proc_udc_show, NULL);
2438} 2438}
2439 2439
2440static struct file_operations proc_ops = { 2440static const struct file_operations proc_ops = {
2441 .open = proc_udc_open, 2441 .open = proc_udc_open,
2442 .read = seq_read, 2442 .read = seq_read,
2443 .llseek = seq_lseek, 2443 .llseek = seq_lseek,
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index fff027d30a09..f1adcf8b2023 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -150,6 +150,39 @@ MODULE_PARM_DESC (fifo_mode, "pxa2xx udc fifo mode");
150static void pxa2xx_ep_fifo_flush (struct usb_ep *ep); 150static void pxa2xx_ep_fifo_flush (struct usb_ep *ep);
151static void nuke (struct pxa2xx_ep *, int status); 151static void nuke (struct pxa2xx_ep *, int status);
152 152
153/* one GPIO should be used to detect VBUS from the host */
154static int is_vbus_present(void)
155{
156 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
157
158 if (mach->gpio_vbus)
159 return pxa_gpio_get(mach->gpio_vbus);
160 if (mach->udc_is_connected)
161 return mach->udc_is_connected();
162 return 1;
163}
164
165/* one GPIO should control a D+ pullup, so host sees this device (or not) */
166static void pullup_off(void)
167{
168 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
169
170 if (mach->gpio_pullup)
171 pxa_gpio_set(mach->gpio_pullup, 0);
172 else if (mach->udc_command)
173 mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
174}
175
176static void pullup_on(void)
177{
178 struct pxa2xx_udc_mach_info *mach = the_controller->mach;
179
180 if (mach->gpio_pullup)
181 pxa_gpio_set(mach->gpio_pullup, 1);
182 else if (mach->udc_command)
183 mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
184}
185
153static void pio_irq_enable(int bEndpointAddress) 186static void pio_irq_enable(int bEndpointAddress)
154{ 187{
155 bEndpointAddress &= 0xf; 188 bEndpointAddress &= 0xf;
@@ -1721,6 +1754,16 @@ lubbock_vbus_irq(int irq, void *_dev, struct pt_regs *r)
1721 1754
1722#endif 1755#endif
1723 1756
1757static irqreturn_t
1758udc_vbus_irq(int irq, void *_dev, struct pt_regs *r)
1759{
1760 struct pxa2xx_udc *dev = _dev;
1761 int vbus = pxa_gpio_get(dev->mach->gpio_vbus);
1762
1763 pxa2xx_udc_vbus_session(&dev->gadget, vbus);
1764 return IRQ_HANDLED;
1765}
1766
1724 1767
1725/*-------------------------------------------------------------------------*/ 1768/*-------------------------------------------------------------------------*/
1726 1769
@@ -2438,7 +2481,7 @@ static struct pxa2xx_udc memory = {
2438static int __init pxa2xx_udc_probe(struct platform_device *pdev) 2481static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2439{ 2482{
2440 struct pxa2xx_udc *dev = &memory; 2483 struct pxa2xx_udc *dev = &memory;
2441 int retval, out_dma = 1; 2484 int retval, out_dma = 1, vbus_irq;
2442 u32 chiprev; 2485 u32 chiprev;
2443 2486
2444 /* insist on Intel/ARM/XScale */ 2487 /* insist on Intel/ARM/XScale */
@@ -2502,6 +2545,16 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2502 /* other non-static parts of init */ 2545 /* other non-static parts of init */
2503 dev->dev = &pdev->dev; 2546 dev->dev = &pdev->dev;
2504 dev->mach = pdev->dev.platform_data; 2547 dev->mach = pdev->dev.platform_data;
2548 if (dev->mach->gpio_vbus) {
2549 vbus_irq = IRQ_GPIO(dev->mach->gpio_vbus & GPIO_MD_MASK_NR);
2550 pxa_gpio_mode((dev->mach->gpio_vbus & GPIO_MD_MASK_NR)
2551 | GPIO_IN);
2552 set_irq_type(vbus_irq, IRQT_BOTHEDGE);
2553 } else
2554 vbus_irq = 0;
2555 if (dev->mach->gpio_pullup)
2556 pxa_gpio_mode((dev->mach->gpio_pullup & GPIO_MD_MASK_NR)
2557 | GPIO_OUT | GPIO_DFLT_LOW);
2505 2558
2506 init_timer(&dev->timer); 2559 init_timer(&dev->timer);
2507 dev->timer.function = udc_watchdog; 2560 dev->timer.function = udc_watchdog;
@@ -2557,8 +2610,19 @@ lubbock_fail0:
2557 HEX_DISPLAY(dev->stats.irqs); 2610 HEX_DISPLAY(dev->stats.irqs);
2558 LUB_DISC_BLNK_LED &= 0xff; 2611 LUB_DISC_BLNK_LED &= 0xff;
2559#endif 2612#endif
2560 } 2613 } else
2561#endif 2614#endif
2615 if (vbus_irq) {
2616 retval = request_irq(vbus_irq, udc_vbus_irq,
2617 SA_INTERRUPT | SA_SAMPLE_RANDOM,
2618 driver_name, dev);
2619 if (retval != 0) {
2620 printk(KERN_ERR "%s: can't get irq %i, err %d\n",
2621 driver_name, vbus_irq, retval);
2622 free_irq(IRQ_USB, dev);
2623 return -EBUSY;
2624 }
2625 }
2562 create_proc_files(); 2626 create_proc_files();
2563 2627
2564 return 0; 2628 return 0;
@@ -2587,6 +2651,8 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2587 free_irq(LUBBOCK_USB_IRQ, dev); 2651 free_irq(LUBBOCK_USB_IRQ, dev);
2588 } 2652 }
2589#endif 2653#endif
2654 if (dev->mach->gpio_vbus)
2655 free_irq(IRQ_GPIO(dev->mach->gpio_vbus), dev);
2590 platform_set_drvdata(pdev, NULL); 2656 platform_set_drvdata(pdev, NULL);
2591 the_controller = NULL; 2657 the_controller = NULL;
2592 return 0; 2658 return 0;
diff --git a/drivers/usb/gadget/pxa2xx_udc.h b/drivers/usb/gadget/pxa2xx_udc.h
index 19a883f7d1b8..8e598c8bf4e3 100644
--- a/drivers/usb/gadget/pxa2xx_udc.h
+++ b/drivers/usb/gadget/pxa2xx_udc.h
@@ -177,27 +177,19 @@ struct pxa2xx_udc {
177 177
178static struct pxa2xx_udc *the_controller; 178static struct pxa2xx_udc *the_controller;
179 179
180/* one GPIO should be used to detect VBUS from the host */ 180static inline int pxa_gpio_get(unsigned gpio)
181static inline int is_vbus_present(void)
182{ 181{
183 if (!the_controller->mach->udc_is_connected) 182 return (GPLR(gpio) & GPIO_bit(gpio)) != 0;
184 return 1;
185 return the_controller->mach->udc_is_connected();
186} 183}
187 184
188/* one GPIO should control a D+ pullup, so host sees this device (or not) */ 185static inline void pxa_gpio_set(unsigned gpio, int is_on)
189static inline void pullup_off(void)
190{ 186{
191 if (!the_controller->mach->udc_command) 187 int mask = GPIO_bit(gpio);
192 return;
193 the_controller->mach->udc_command(PXA2XX_UDC_CMD_DISCONNECT);
194}
195 188
196static inline void pullup_on(void) 189 if (is_on)
197{ 190 GPSR(gpio) = mask;
198 if (!the_controller->mach->udc_command) 191 else
199 return; 192 GPCR(gpio) = mask;
200 the_controller->mach->udc_command(PXA2XX_UDC_CMD_CONNECT);
201} 193}
202 194
203/*-------------------------------------------------------------------------*/ 195/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index e762aa19ab0a..b893e3118e1b 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -1120,12 +1120,15 @@ static int gs_send(struct gs_dev *dev)
1120gs_debug_level(3, "gs_send: len=%d, 0x%2.2x 0x%2.2x 0x%2.2x ...\n", len, *((unsigned char *)req->buf), *((unsigned char *)req->buf+1), *((unsigned char *)req->buf+2)); 1120gs_debug_level(3, "gs_send: len=%d, 0x%2.2x 0x%2.2x 0x%2.2x ...\n", len, *((unsigned char *)req->buf), *((unsigned char *)req->buf+1), *((unsigned char *)req->buf+2));
1121 list_del(&req_entry->re_entry); 1121 list_del(&req_entry->re_entry);
1122 req->length = len; 1122 req->length = len;
1123 spin_unlock_irqrestore(&dev->dev_lock, flags);
1123 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) { 1124 if ((ret=usb_ep_queue(ep, req, GFP_ATOMIC))) {
1124 printk(KERN_ERR 1125 printk(KERN_ERR
1125 "gs_send: cannot queue read request, ret=%d\n", 1126 "gs_send: cannot queue read request, ret=%d\n",
1126 ret); 1127 ret);
1128 spin_lock_irqsave(&dev->dev_lock, flags);
1127 break; 1129 break;
1128 } 1130 }
1131 spin_lock_irqsave(&dev->dev_lock, flags);
1129 } else { 1132 } else {
1130 break; 1133 break;
1131 } 1134 }
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index b93d71d28db7..cf10cbc98f80 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -83,6 +83,7 @@ config USB_OHCI_HCD
83 tristate "OHCI HCD support" 83 tristate "OHCI HCD support"
84 depends on USB && USB_ARCH_HAS_OHCI 84 depends on USB && USB_ARCH_HAS_OHCI
85 select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3 85 select ISP1301_OMAP if MACH_OMAP_H2 || MACH_OMAP_H3
86 select I2C if ARCH_PNX4008
86 ---help--- 87 ---help---
87 The Open Host Controller Interface (OHCI) is a standard for accessing 88 The Open Host Controller Interface (OHCI) is a standard for accessing
88 USB 1.1 host controller hardware. It does more in hardware than Intel's 89 USB 1.1 host controller hardware. It does more in hardware than Intel's
@@ -141,6 +142,34 @@ config USB_UHCI_HCD
141 To compile this driver as a module, choose M here: the 142 To compile this driver as a module, choose M here: the
142 module will be called uhci-hcd. 143 module will be called uhci-hcd.
143 144
145config USB_U132_HCD
146 tristate "Elan U132 Adapter Host Controller"
147 depends on USB && USB_FTDI_ELAN
148 default M
149 help
150 The U132 adapter is a USB to CardBus adapter specifically designed
151 for PC cards that contain an OHCI host controller. Typical PC cards
152 are the Orange Mobile 3G Option GlobeTrotter Fusion card. The U132
153 adapter will *NOT* work with PC cards that do not contain an OHCI
154 controller.
155
156 For those PC cards that contain multiple OHCI controllers only ther
157 first one is used.
158
159 The driver consists of two modules, the "ftdi-elan" module is a
160 USB client driver that interfaces to the FTDI chip within ELAN's
161 USB-to-PCMCIA adapter, and this "u132-hcd" module is a USB host
162 controller driver that talks to the OHCI controller within the
163 CardBus cards that are inserted in the U132 adapter.
164
165 This driver has been tested with a CardBus OHCI USB adapter, and
166 worked with a USB PEN Drive inserted into the first USB port of
167 the PCCARD. A rather pointless thing to do, but useful for testing.
168
169 It is safe to say M here.
170
171 See also <http://www.elandigitalsystems.com/support/ufaq/u132linux.php>
172
144config USB_SL811_HCD 173config USB_SL811_HCD
145 tristate "SL811HS HCD support" 174 tristate "SL811HS HCD support"
146 depends on USB 175 depends on USB
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index e3020f4b17be..a2e58c86849f 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -14,4 +14,5 @@ obj-$(CONFIG_USB_OHCI_HCD) += ohci-hcd.o
14obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o 14obj-$(CONFIG_USB_UHCI_HCD) += uhci-hcd.o
15obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o 15obj-$(CONFIG_USB_SL811_HCD) += sl811-hcd.o
16obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o 16obj-$(CONFIG_USB_SL811_CS) += sl811_cs.o
17obj-$(CONFIG_USB_U132_HCD) += u132-hcd.o
17obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o 18obj-$(CONFIG_ETRAX_ARCH_V10) += hc_crisv10.o
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 26ed757d22a6..5d1b12aad776 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -200,6 +200,7 @@ static const struct hc_driver ehci_au1xxx_hc_driver = {
200 .reset = ehci_init, 200 .reset = ehci_init,
201 .start = ehci_run, 201 .start = ehci_run,
202 .stop = ehci_stop, 202 .stop = ehci_stop,
203 .shutdown = ehci_shutdown,
203 204
204 /* 205 /*
205 * managing i/o requests and associated device resources 206 * managing i/o requests and associated device resources
@@ -268,6 +269,7 @@ MODULE_ALIAS("au1xxx-ehci");
268static struct platform_driver ehci_hcd_au1xxx_driver = { 269static struct platform_driver ehci_hcd_au1xxx_driver = {
269 .probe = ehci_hcd_au1xxx_drv_probe, 270 .probe = ehci_hcd_au1xxx_drv_probe,
270 .remove = ehci_hcd_au1xxx_drv_remove, 271 .remove = ehci_hcd_au1xxx_drv_remove,
272 .shutdown = usb_hcd_platform_shutdown,
271 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ 273 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */
272 /*.resume = ehci_hcd_au1xxx_drv_resume, */ 274 /*.resume = ehci_hcd_au1xxx_drv_resume, */
273 .driver = { 275 .driver = {
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index 65ac9fef3a7c..23b95b2bfe15 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2001-2002 by David Brownell 2 * Copyright (c) 2001-2002 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -65,7 +65,7 @@ static void dbg_hcs_params (struct ehci_hcd *ehci, char *label)
65 for (i = 0; i < HCS_N_PORTS (params); i++) { 65 for (i = 0; i < HCS_N_PORTS (params); i++) {
66 // FIXME MIPS won't readb() ... 66 // FIXME MIPS won't readb() ...
67 byte = readb (&ehci->caps->portroute[(i>>1)]); 67 byte = readb (&ehci->caps->portroute[(i>>1)]);
68 sprintf(tmp, "%d ", 68 sprintf(tmp, "%d ",
69 ((i & 0x1) ? ((byte)&0xf) : ((byte>>4)&0xf))); 69 ((i & 0x1) ? ((byte)&0xf) : ((byte>>4)&0xf)));
70 strcat(buf, tmp); 70 strcat(buf, tmp);
71 } 71 }
@@ -141,12 +141,12 @@ dbg_qh (const char *label, struct ehci_hcd *ehci, struct ehci_qh *qh)
141} 141}
142 142
143static void __attribute__((__unused__)) 143static void __attribute__((__unused__))
144dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd) 144dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
145{ 145{
146 ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n", 146 ehci_dbg (ehci, "%s [%d] itd %p, next %08x, urb %p\n",
147 label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb); 147 label, itd->frame, itd, le32_to_cpu(itd->hw_next), itd->urb);
148 ehci_dbg (ehci, 148 ehci_dbg (ehci,
149 " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n", 149 " trans: %08x %08x %08x %08x %08x %08x %08x %08x\n",
150 le32_to_cpu(itd->hw_transaction[0]), 150 le32_to_cpu(itd->hw_transaction[0]),
151 le32_to_cpu(itd->hw_transaction[1]), 151 le32_to_cpu(itd->hw_transaction[1]),
152 le32_to_cpu(itd->hw_transaction[2]), 152 le32_to_cpu(itd->hw_transaction[2]),
@@ -156,7 +156,7 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
156 le32_to_cpu(itd->hw_transaction[6]), 156 le32_to_cpu(itd->hw_transaction[6]),
157 le32_to_cpu(itd->hw_transaction[7])); 157 le32_to_cpu(itd->hw_transaction[7]));
158 ehci_dbg (ehci, 158 ehci_dbg (ehci,
159 " buf: %08x %08x %08x %08x %08x %08x %08x\n", 159 " buf: %08x %08x %08x %08x %08x %08x %08x\n",
160 le32_to_cpu(itd->hw_bufp[0]), 160 le32_to_cpu(itd->hw_bufp[0]),
161 le32_to_cpu(itd->hw_bufp[1]), 161 le32_to_cpu(itd->hw_bufp[1]),
162 le32_to_cpu(itd->hw_bufp[2]), 162 le32_to_cpu(itd->hw_bufp[2]),
@@ -171,12 +171,12 @@ dbg_itd (const char *label, struct ehci_hcd *ehci, struct ehci_itd *itd)
171} 171}
172 172
173static void __attribute__((__unused__)) 173static void __attribute__((__unused__))
174dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd) 174dbg_sitd (const char *label, struct ehci_hcd *ehci, struct ehci_sitd *sitd)
175{ 175{
176 ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n", 176 ehci_dbg (ehci, "%s [%d] sitd %p, next %08x, urb %p\n",
177 label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), sitd->urb); 177 label, sitd->frame, sitd, le32_to_cpu(sitd->hw_next), sitd->urb);
178 ehci_dbg (ehci, 178 ehci_dbg (ehci,
179 " addr %08x sched %04x result %08x buf %08x %08x\n", 179 " addr %08x sched %04x result %08x buf %08x %08x\n",
180 le32_to_cpu(sitd->hw_fullspeed_ep), 180 le32_to_cpu(sitd->hw_fullspeed_ep),
181 le32_to_cpu(sitd->hw_uframe), 181 le32_to_cpu(sitd->hw_uframe),
182 le32_to_cpu(sitd->hw_results), 182 le32_to_cpu(sitd->hw_results),
@@ -451,7 +451,7 @@ show_async (struct class_device *class_dev, char *buf)
451 *buf = 0; 451 *buf = 0;
452 452
453 bus = class_get_devdata(class_dev); 453 bus = class_get_devdata(class_dev);
454 hcd = bus->hcpriv; 454 hcd = bus_to_hcd(bus);
455 ehci = hcd_to_ehci (hcd); 455 ehci = hcd_to_ehci (hcd);
456 next = buf; 456 next = buf;
457 size = PAGE_SIZE; 457 size = PAGE_SIZE;
@@ -497,7 +497,7 @@ show_periodic (struct class_device *class_dev, char *buf)
497 seen_count = 0; 497 seen_count = 0;
498 498
499 bus = class_get_devdata(class_dev); 499 bus = class_get_devdata(class_dev);
500 hcd = bus->hcpriv; 500 hcd = bus_to_hcd(bus);
501 ehci = hcd_to_ehci (hcd); 501 ehci = hcd_to_ehci (hcd);
502 next = buf; 502 next = buf;
503 size = PAGE_SIZE; 503 size = PAGE_SIZE;
@@ -634,7 +634,7 @@ show_registers (struct class_device *class_dev, char *buf)
634 static char label [] = ""; 634 static char label [] = "";
635 635
636 bus = class_get_devdata(class_dev); 636 bus = class_get_devdata(class_dev);
637 hcd = bus->hcpriv; 637 hcd = bus_to_hcd(bus);
638 ehci = hcd_to_ehci (hcd); 638 ehci = hcd_to_ehci (hcd);
639 next = buf; 639 next = buf;
640 size = PAGE_SIZE; 640 size = PAGE_SIZE;
@@ -754,9 +754,7 @@ show_registers (struct class_device *class_dev, char *buf)
754 } 754 }
755 755
756 if (ehci->reclaim) { 756 if (ehci->reclaim) {
757 temp = scnprintf (next, size, "reclaim qh %p%s\n", 757 temp = scnprintf (next, size, "reclaim qh %p\n", ehci->reclaim);
758 ehci->reclaim,
759 ehci->reclaim_ready ? " ready" : "");
760 size -= temp; 758 size -= temp;
761 next += temp; 759 next += temp;
762 } 760 }
@@ -785,10 +783,11 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
785static inline void create_debug_files (struct ehci_hcd *ehci) 783static inline void create_debug_files (struct ehci_hcd *ehci)
786{ 784{
787 struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev; 785 struct class_device *cldev = ehci_to_hcd(ehci)->self.class_dev;
786 int retval;
788 787
789 class_device_create_file(cldev, &class_device_attr_async); 788 retval = class_device_create_file(cldev, &class_device_attr_async);
790 class_device_create_file(cldev, &class_device_attr_periodic); 789 retval = class_device_create_file(cldev, &class_device_attr_periodic);
791 class_device_create_file(cldev, &class_device_attr_registers); 790 retval = class_device_create_file(cldev, &class_device_attr_registers);
792} 791}
793 792
794static inline void remove_debug_files (struct ehci_hcd *ehci) 793static inline void remove_debug_files (struct ehci_hcd *ehci)
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index d030516edfb9..1a915e982c1c 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -285,6 +285,7 @@ static const struct hc_driver ehci_fsl_hc_driver = {
285 .resume = ehci_bus_resume, 285 .resume = ehci_bus_resume,
286#endif 286#endif
287 .stop = ehci_stop, 287 .stop = ehci_stop,
288 .shutdown = ehci_shutdown,
288 289
289 /* 290 /*
290 * managing i/o requests and associated device resources 291 * managing i/o requests and associated device resources
@@ -329,6 +330,7 @@ MODULE_ALIAS("fsl-ehci");
329static struct platform_driver ehci_fsl_driver = { 330static struct platform_driver ehci_fsl_driver = {
330 .probe = ehci_fsl_drv_probe, 331 .probe = ehci_fsl_drv_probe,
331 .remove = ehci_fsl_drv_remove, 332 .remove = ehci_fsl_drv_remove,
333 .shutdown = usb_hcd_platform_shutdown,
332 .driver = { 334 .driver = {
333 .name = "fsl-ehci", 335 .name = "fsl-ehci",
334 }, 336 },
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index d63177a8eaea..5ac918591131 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2000-2004 by David Brownell 2 * Copyright (c) 2000-2004 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -70,7 +70,7 @@
70 * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared; 70 * 2002-08-06 Handling for bulk and interrupt transfers is mostly shared;
71 * only scheduling is different, no arbitrary limitations. 71 * only scheduling is different, no arbitrary limitations.
72 * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support, 72 * 2002-07-25 Sanity check PCI reads, mostly for better cardbus support,
73 * clean up HC run state handshaking. 73 * clean up HC run state handshaking.
74 * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts 74 * 2002-05-24 Preliminary FS/LS interrupts, using scheduling shortcuts
75 * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other 75 * 2002-05-11 Clear TT errors for FS/LS ctrl/bulk. Fill in some other
76 * missing pieces: enabling 64bit dma, handoff from BIOS/SMM. 76 * missing pieces: enabling 64bit dma, handoff from BIOS/SMM.
@@ -111,7 +111,7 @@ static const char hcd_name [] = "ehci_hcd";
111#define EHCI_TUNE_MULT_TT 1 111#define EHCI_TUNE_MULT_TT 1
112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */ 112#define EHCI_TUNE_FLS 2 /* (small) 256 frame schedule */
113 113
114#define EHCI_IAA_JIFFIES (HZ/100) /* arbitrary; ~10 msec */ 114#define EHCI_IAA_MSECS 10 /* arbitrary */
115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */ 115#define EHCI_IO_JIFFIES (HZ/10) /* io watchdog > irq_thresh */
116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */ 116#define EHCI_ASYNC_JIFFIES (HZ/20) /* async idle timeout */
117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */ 117#define EHCI_SHRINK_JIFFIES (HZ/200) /* async qh unlink delay */
@@ -254,6 +254,7 @@ static void ehci_quiesce (struct ehci_hcd *ehci)
254 254
255/*-------------------------------------------------------------------------*/ 255/*-------------------------------------------------------------------------*/
256 256
257static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs);
257static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs); 258static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
258 259
259#include "ehci-hub.c" 260#include "ehci-hub.c"
@@ -263,28 +264,39 @@ static void ehci_work(struct ehci_hcd *ehci, struct pt_regs *regs);
263 264
264/*-------------------------------------------------------------------------*/ 265/*-------------------------------------------------------------------------*/
265 266
266static void ehci_watchdog (unsigned long param) 267static void ehci_iaa_watchdog (unsigned long param)
267{ 268{
268 struct ehci_hcd *ehci = (struct ehci_hcd *) param; 269 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
269 unsigned long flags; 270 unsigned long flags;
271 u32 status;
270 272
271 spin_lock_irqsave (&ehci->lock, flags); 273 spin_lock_irqsave (&ehci->lock, flags);
274 WARN_ON(!ehci->reclaim);
272 275
273 /* lost IAA irqs wedge things badly; seen with a vt8235 */ 276 /* lost IAA irqs wedge things badly; seen first with a vt8235 */
274 if (ehci->reclaim) { 277 if (ehci->reclaim) {
275 u32 status = readl (&ehci->regs->status); 278 status = readl (&ehci->regs->status);
276
277 if (status & STS_IAA) { 279 if (status & STS_IAA) {
278 ehci_vdbg (ehci, "lost IAA\n"); 280 ehci_vdbg (ehci, "lost IAA\n");
279 COUNT (ehci->stats.lost_iaa); 281 COUNT (ehci->stats.lost_iaa);
280 writel (STS_IAA, &ehci->regs->status); 282 writel (STS_IAA, &ehci->regs->status);
281 ehci->reclaim_ready = 1; 283 end_unlink_async (ehci, NULL);
282 } 284 }
283 } 285 }
284 286
285 /* stop async processing after it's idled a bit */ 287 spin_unlock_irqrestore (&ehci->lock, flags);
288}
289
290static void ehci_watchdog (unsigned long param)
291{
292 struct ehci_hcd *ehci = (struct ehci_hcd *) param;
293 unsigned long flags;
294
295 spin_lock_irqsave (&ehci->lock, flags);
296
297 /* stop async processing after it's idled a bit */
286 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions)) 298 if (test_bit (TIMER_ASYNC_OFF, &ehci->actions))
287 start_unlink_async (ehci, ehci->async); 299 start_unlink_async (ehci, ehci->async);
288 300
289 /* ehci could run by timer, without IRQs ... */ 301 /* ehci could run by timer, without IRQs ... */
290 ehci_work (ehci, NULL); 302 ehci_work (ehci, NULL);
@@ -292,21 +304,20 @@ static void ehci_watchdog (unsigned long param)
292 spin_unlock_irqrestore (&ehci->lock, flags); 304 spin_unlock_irqrestore (&ehci->lock, flags);
293} 305}
294 306
295/* Reboot notifiers kick in for silicon on any bus (not just pci, etc). 307/* ehci_shutdown kick in for silicon on any bus (not just pci, etc).
296 * This forcibly disables dma and IRQs, helping kexec and other cases 308 * This forcibly disables dma and IRQs, helping kexec and other cases
297 * where the next system software may expect clean state. 309 * where the next system software may expect clean state.
298 */ 310 */
299static int 311static void
300ehci_reboot (struct notifier_block *self, unsigned long code, void *null) 312ehci_shutdown (struct usb_hcd *hcd)
301{ 313{
302 struct ehci_hcd *ehci; 314 struct ehci_hcd *ehci;
303 315
304 ehci = container_of (self, struct ehci_hcd, reboot_notifier); 316 ehci = hcd_to_ehci (hcd);
305 (void) ehci_halt (ehci); 317 (void) ehci_halt (ehci);
306 318
307 /* make BIOS/etc use companion controller during reboot */ 319 /* make BIOS/etc use companion controller during reboot */
308 writel (0, &ehci->regs->configured_flag); 320 writel (0, &ehci->regs->configured_flag);
309 return 0;
310} 321}
311 322
312static void ehci_port_power (struct ehci_hcd *ehci, int is_on) 323static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
@@ -334,8 +345,6 @@ static void ehci_port_power (struct ehci_hcd *ehci, int is_on)
334static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs) 345static void ehci_work (struct ehci_hcd *ehci, struct pt_regs *regs)
335{ 346{
336 timer_action_done (ehci, TIMER_IO_WATCHDOG); 347 timer_action_done (ehci, TIMER_IO_WATCHDOG);
337 if (ehci->reclaim_ready)
338 end_unlink_async (ehci, regs);
339 348
340 /* another CPU may drop ehci->lock during a schedule scan while 349 /* another CPU may drop ehci->lock during a schedule scan while
341 * it reports urb completions. this flag guards against bogus 350 * it reports urb completions. this flag guards against bogus
@@ -370,6 +379,7 @@ static void ehci_stop (struct usb_hcd *hcd)
370 379
371 /* no more interrupts ... */ 380 /* no more interrupts ... */
372 del_timer_sync (&ehci->watchdog); 381 del_timer_sync (&ehci->watchdog);
382 del_timer_sync (&ehci->iaa_watchdog);
373 383
374 spin_lock_irq(&ehci->lock); 384 spin_lock_irq(&ehci->lock);
375 if (HC_IS_RUNNING (hcd->state)) 385 if (HC_IS_RUNNING (hcd->state))
@@ -381,7 +391,6 @@ static void ehci_stop (struct usb_hcd *hcd)
381 391
382 /* let companion controllers work when we aren't */ 392 /* let companion controllers work when we aren't */
383 writel (0, &ehci->regs->configured_flag); 393 writel (0, &ehci->regs->configured_flag);
384 unregister_reboot_notifier (&ehci->reboot_notifier);
385 394
386 remove_debug_files (ehci); 395 remove_debug_files (ehci);
387 396
@@ -417,6 +426,10 @@ static int ehci_init(struct usb_hcd *hcd)
417 ehci->watchdog.function = ehci_watchdog; 426 ehci->watchdog.function = ehci_watchdog;
418 ehci->watchdog.data = (unsigned long) ehci; 427 ehci->watchdog.data = (unsigned long) ehci;
419 428
429 init_timer(&ehci->iaa_watchdog);
430 ehci->iaa_watchdog.function = ehci_iaa_watchdog;
431 ehci->iaa_watchdog.data = (unsigned long) ehci;
432
420 /* 433 /*
421 * hw default: 1K periodic list heads, one per frame. 434 * hw default: 1K periodic list heads, one per frame.
422 * periodic_size can shrink by USBCMD update if hcc_params allows. 435 * periodic_size can shrink by USBCMD update if hcc_params allows.
@@ -427,13 +440,12 @@ static int ehci_init(struct usb_hcd *hcd)
427 440
428 /* controllers may cache some of the periodic schedule ... */ 441 /* controllers may cache some of the periodic schedule ... */
429 hcc_params = readl(&ehci->caps->hcc_params); 442 hcc_params = readl(&ehci->caps->hcc_params);
430 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache 443 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
431 ehci->i_thresh = 8; 444 ehci->i_thresh = 8;
432 else // N microframes cached 445 else // N microframes cached
433 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params); 446 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
434 447
435 ehci->reclaim = NULL; 448 ehci->reclaim = NULL;
436 ehci->reclaim_ready = 0;
437 ehci->next_uframe = -1; 449 ehci->next_uframe = -1;
438 450
439 /* 451 /*
@@ -483,9 +495,6 @@ static int ehci_init(struct usb_hcd *hcd)
483 } 495 }
484 ehci->command = temp; 496 ehci->command = temp;
485 497
486 ehci->reboot_notifier.notifier_call = ehci_reboot;
487 register_reboot_notifier(&ehci->reboot_notifier);
488
489 return 0; 498 return 0;
490} 499}
491 500
@@ -499,7 +508,6 @@ static int ehci_run (struct usb_hcd *hcd)
499 508
500 /* EHCI spec section 4.1 */ 509 /* EHCI spec section 4.1 */
501 if ((retval = ehci_reset(ehci)) != 0) { 510 if ((retval = ehci_reset(ehci)) != 0) {
502 unregister_reboot_notifier(&ehci->reboot_notifier);
503 ehci_mem_cleanup(ehci); 511 ehci_mem_cleanup(ehci);
504 return retval; 512 return retval;
505 } 513 }
@@ -611,7 +619,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
611 /* complete the unlinking of some qh [4.15.2.3] */ 619 /* complete the unlinking of some qh [4.15.2.3] */
612 if (status & STS_IAA) { 620 if (status & STS_IAA) {
613 COUNT (ehci->stats.reclaim); 621 COUNT (ehci->stats.reclaim);
614 ehci->reclaim_ready = 1; 622 end_unlink_async (ehci, regs);
615 bh = 1; 623 bh = 1;
616 } 624 }
617 625
@@ -715,10 +723,14 @@ static int ehci_urb_enqueue (
715 723
716static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh) 724static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
717{ 725{
718 /* if we need to use IAA and it's busy, defer */ 726 // BUG_ON(qh->qh_state != QH_STATE_LINKED);
719 if (qh->qh_state == QH_STATE_LINKED 727
720 && ehci->reclaim 728 /* failfast */
721 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) { 729 if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
730 end_unlink_async (ehci, NULL);
731
732 /* defer till later if busy */
733 else if (ehci->reclaim) {
722 struct ehci_qh *last; 734 struct ehci_qh *last;
723 735
724 for (last = ehci->reclaim; 736 for (last = ehci->reclaim;
@@ -728,12 +740,8 @@ static void unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
728 qh->qh_state = QH_STATE_UNLINK_WAIT; 740 qh->qh_state = QH_STATE_UNLINK_WAIT;
729 last->reclaim = qh; 741 last->reclaim = qh;
730 742
731 /* bypass IAA if the hc can't care */ 743 /* start IAA cycle */
732 } else if (!HC_IS_RUNNING (ehci_to_hcd(ehci)->state) && ehci->reclaim) 744 } else
733 end_unlink_async (ehci, NULL);
734
735 /* something else might have unlinked the qh by now */
736 if (qh->qh_state == QH_STATE_LINKED)
737 start_unlink_async (ehci, qh); 745 start_unlink_async (ehci, qh);
738} 746}
739 747
@@ -755,7 +763,19 @@ static int ehci_urb_dequeue (struct usb_hcd *hcd, struct urb *urb)
755 qh = (struct ehci_qh *) urb->hcpriv; 763 qh = (struct ehci_qh *) urb->hcpriv;
756 if (!qh) 764 if (!qh)
757 break; 765 break;
758 unlink_async (ehci, qh); 766 switch (qh->qh_state) {
767 case QH_STATE_LINKED:
768 case QH_STATE_COMPLETING:
769 unlink_async (ehci, qh);
770 break;
771 case QH_STATE_UNLINK:
772 case QH_STATE_UNLINK_WAIT:
773 /* already started */
774 break;
775 case QH_STATE_IDLE:
776 WARN_ON(1);
777 break;
778 }
759 break; 779 break;
760 780
761 case PIPE_INTERRUPT: 781 case PIPE_INTERRUPT:
@@ -847,6 +867,7 @@ rescan:
847 unlink_async (ehci, qh); 867 unlink_async (ehci, qh);
848 /* FALL THROUGH */ 868 /* FALL THROUGH */
849 case QH_STATE_UNLINK: /* wait for hw to finish? */ 869 case QH_STATE_UNLINK: /* wait for hw to finish? */
870 case QH_STATE_UNLINK_WAIT:
850idle_timeout: 871idle_timeout:
851 spin_unlock_irqrestore (&ehci->lock, flags); 872 spin_unlock_irqrestore (&ehci->lock, flags);
852 schedule_timeout_uninterruptible(1); 873 schedule_timeout_uninterruptible(1);
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index d03e3cad5ca8..b2ee13c58517 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001-2004 by David Brownell 2 * Copyright (C) 2001-2004 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -48,7 +48,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
48 } 48 }
49 ehci->command = readl (&ehci->regs->command); 49 ehci->command = readl (&ehci->regs->command);
50 if (ehci->reclaim) 50 if (ehci->reclaim)
51 ehci->reclaim_ready = 1; 51 end_unlink_async (ehci, NULL);
52 ehci_work(ehci, NULL); 52 ehci_work(ehci, NULL);
53 53
54 /* suspend any active/unsuspended ports, maybe allow wakeup */ 54 /* suspend any active/unsuspended ports, maybe allow wakeup */
@@ -103,10 +103,10 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
103 103
104 /* re-init operational registers in case we lost power */ 104 /* re-init operational registers in case we lost power */
105 if (readl (&ehci->regs->intr_enable) == 0) { 105 if (readl (&ehci->regs->intr_enable) == 0) {
106 /* at least some APM implementations will try to deliver 106 /* at least some APM implementations will try to deliver
107 * IRQs right away, so delay them until we're ready. 107 * IRQs right away, so delay them until we're ready.
108 */ 108 */
109 intr_enable = 1; 109 intr_enable = 1;
110 writel (0, &ehci->regs->segment); 110 writel (0, &ehci->regs->segment);
111 writel (ehci->periodic_dma, &ehci->regs->frame_list); 111 writel (ehci->periodic_dma, &ehci->regs->frame_list);
112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next); 112 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
@@ -232,7 +232,7 @@ ehci_hub_status_data (struct usb_hcd *hcd, char *buf)
232 buf [1] = 0; 232 buf [1] = 0;
233 retval++; 233 retval++;
234 } 234 }
235 235
236 /* no hub change reports (bit 0) for now (power, ...) */ 236 /* no hub change reports (bit 0) for now (power, ...) */
237 237
238 /* port N changes (bit N)? */ 238 /* port N changes (bit N)? */
@@ -304,7 +304,7 @@ ehci_hub_descriptor (
304 304
305/*-------------------------------------------------------------------------*/ 305/*-------------------------------------------------------------------------*/
306 306
307#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) 307#define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E)
308 308
309static int ehci_hub_control ( 309static int ehci_hub_control (
310 struct usb_hcd *hcd, 310 struct usb_hcd *hcd,
diff --git a/drivers/usb/host/ehci-mem.c b/drivers/usb/host/ehci-mem.c
index 766061e0260a..a8ba2e1497a4 100644
--- a/drivers/usb/host/ehci-mem.c
+++ b/drivers/usb/host/ehci-mem.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2001 by David Brownell 2 * Copyright (c) 2001 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -25,7 +25,7 @@
25 * - data used only by the HCD ... kmalloc is fine 25 * - data used only by the HCD ... kmalloc is fine
26 * - async and periodic schedules, shared by HC and HCD ... these 26 * - async and periodic schedules, shared by HC and HCD ... these
27 * need to use dma_pool or dma_alloc_coherent 27 * need to use dma_pool or dma_alloc_coherent
28 * - driver buffers, read/written by HC ... single shot DMA mapped 28 * - driver buffers, read/written by HC ... single shot DMA mapped
29 * 29 *
30 * There's also PCI "register" data, which is memory mapped. 30 * There's also PCI "register" data, which is memory mapped.
31 * No memory seen by this driver is pageable. 31 * No memory seen by this driver is pageable.
@@ -119,7 +119,7 @@ static inline void qh_put (struct ehci_qh *qh)
119 119
120/*-------------------------------------------------------------------------*/ 120/*-------------------------------------------------------------------------*/
121 121
122/* The queue heads and transfer descriptors are managed from pools tied 122/* The queue heads and transfer descriptors are managed from pools tied
123 * to each of the "per device" structures. 123 * to each of the "per device" structures.
124 * This is the initialisation and cleanup code. 124 * This is the initialisation and cleanup code.
125 */ 125 */
@@ -165,7 +165,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
165 int i; 165 int i;
166 166
167 /* QTDs for control/bulk/intr transfers */ 167 /* QTDs for control/bulk/intr transfers */
168 ehci->qtd_pool = dma_pool_create ("ehci_qtd", 168 ehci->qtd_pool = dma_pool_create ("ehci_qtd",
169 ehci_to_hcd(ehci)->self.controller, 169 ehci_to_hcd(ehci)->self.controller,
170 sizeof (struct ehci_qtd), 170 sizeof (struct ehci_qtd),
171 32 /* byte alignment (for hw parts) */, 171 32 /* byte alignment (for hw parts) */,
@@ -175,7 +175,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
175 } 175 }
176 176
177 /* QHs for control/bulk/intr transfers */ 177 /* QHs for control/bulk/intr transfers */
178 ehci->qh_pool = dma_pool_create ("ehci_qh", 178 ehci->qh_pool = dma_pool_create ("ehci_qh",
179 ehci_to_hcd(ehci)->self.controller, 179 ehci_to_hcd(ehci)->self.controller,
180 sizeof (struct ehci_qh), 180 sizeof (struct ehci_qh),
181 32 /* byte alignment (for hw parts) */, 181 32 /* byte alignment (for hw parts) */,
@@ -189,7 +189,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
189 } 189 }
190 190
191 /* ITD for high speed ISO transfers */ 191 /* ITD for high speed ISO transfers */
192 ehci->itd_pool = dma_pool_create ("ehci_itd", 192 ehci->itd_pool = dma_pool_create ("ehci_itd",
193 ehci_to_hcd(ehci)->self.controller, 193 ehci_to_hcd(ehci)->self.controller,
194 sizeof (struct ehci_itd), 194 sizeof (struct ehci_itd),
195 32 /* byte alignment (for hw parts) */, 195 32 /* byte alignment (for hw parts) */,
@@ -199,7 +199,7 @@ static int ehci_mem_init (struct ehci_hcd *ehci, gfp_t flags)
199 } 199 }
200 200
201 /* SITD for full/low speed split ISO transfers */ 201 /* SITD for full/low speed split ISO transfers */
202 ehci->sitd_pool = dma_pool_create ("ehci_sitd", 202 ehci->sitd_pool = dma_pool_create ("ehci_sitd",
203 ehci_to_hcd(ehci)->self.controller, 203 ehci_to_hcd(ehci)->self.controller,
204 sizeof (struct ehci_sitd), 204 sizeof (struct ehci_sitd),
205 32 /* byte alignment (for hw parts) */, 205 32 /* byte alignment (for hw parts) */,
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index cadffacd945b..08d0472d4f57 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -238,6 +238,12 @@ static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
238 writel (0, &ehci->regs->intr_enable); 238 writel (0, &ehci->regs->intr_enable);
239 (void)readl(&ehci->regs->intr_enable); 239 (void)readl(&ehci->regs->intr_enable);
240 240
241 /* make sure snapshot being resumed re-enumerates everything */
242 if (message.event == PM_EVENT_PRETHAW) {
243 ehci_halt(ehci);
244 ehci_reset(ehci);
245 }
246
241 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 247 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
242 bail: 248 bail:
243 spin_unlock_irqrestore (&ehci->lock, flags); 249 spin_unlock_irqrestore (&ehci->lock, flags);
@@ -297,7 +303,7 @@ restart:
297 /* emptying the schedule aborts any urbs */ 303 /* emptying the schedule aborts any urbs */
298 spin_lock_irq(&ehci->lock); 304 spin_lock_irq(&ehci->lock);
299 if (ehci->reclaim) 305 if (ehci->reclaim)
300 ehci->reclaim_ready = 1; 306 end_unlink_async (ehci, NULL);
301 ehci_work(ehci, NULL); 307 ehci_work(ehci, NULL);
302 spin_unlock_irq(&ehci->lock); 308 spin_unlock_irq(&ehci->lock);
303 309
@@ -332,6 +338,7 @@ static const struct hc_driver ehci_pci_hc_driver = {
332 .resume = ehci_pci_resume, 338 .resume = ehci_pci_resume,
333#endif 339#endif
334 .stop = ehci_stop, 340 .stop = ehci_stop,
341 .shutdown = ehci_shutdown,
335 342
336 /* 343 /*
337 * managing i/o requests and associated device resources 344 * managing i/o requests and associated device resources
@@ -378,4 +385,5 @@ static struct pci_driver ehci_pci_driver = {
378 .suspend = usb_hcd_pci_suspend, 385 .suspend = usb_hcd_pci_suspend,
379 .resume = usb_hcd_pci_resume, 386 .resume = usb_hcd_pci_resume,
380#endif 387#endif
388 .shutdown = usb_hcd_pci_shutdown,
381}; 389};
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index e469221e7ec3..7fc25b6bd7d2 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (C) 2001-2004 by David Brownell 2 * Copyright (C) 2001-2004 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -31,7 +31,7 @@
31 * ISO traffic uses "ISO TD" (itd, and sitd) records, and (along with 31 * ISO traffic uses "ISO TD" (itd, and sitd) records, and (along with
32 * interrupts) needs careful scheduling. Performance improvements can be 32 * interrupts) needs careful scheduling. Performance improvements can be
33 * an ongoing challenge. That's in "ehci-sched.c". 33 * an ongoing challenge. That's in "ehci-sched.c".
34 * 34 *
35 * USB 1.1 devices are handled (a) by "companion" OHCI or UHCI root hubs, 35 * USB 1.1 devices are handled (a) by "companion" OHCI or UHCI root hubs,
36 * or otherwise through transaction translators (TTs) in USB 2.0 hubs using 36 * or otherwise through transaction translators (TTs) in USB 2.0 hubs using
37 * (b) special fields in qh entries or (c) split iso entries. TTs will 37 * (b) special fields in qh entries or (c) split iso entries. TTs will
@@ -199,7 +199,7 @@ static void qtd_copy_status (
199 && ((token & QTD_STS_MMF) != 0 199 && ((token & QTD_STS_MMF) != 0
200 || QTD_CERR(token) == 0) 200 || QTD_CERR(token) == 0)
201 && (!ehci_is_TDI(ehci) 201 && (!ehci_is_TDI(ehci)
202 || urb->dev->tt->hub != 202 || urb->dev->tt->hub !=
203 ehci_to_hcd(ehci)->self.root_hub)) { 203 ehci_to_hcd(ehci)->self.root_hub)) {
204#ifdef DEBUG 204#ifdef DEBUG
205 struct usb_device *tt = urb->dev->tt->hub; 205 struct usb_device *tt = urb->dev->tt->hub;
@@ -364,7 +364,7 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh, struct pt_regs *regs)
364 */ 364 */
365 if (likely (urb->status == -EINPROGRESS)) 365 if (likely (urb->status == -EINPROGRESS))
366 continue; 366 continue;
367 367
368 /* issue status after short control reads */ 368 /* issue status after short control reads */
369 if (unlikely (do_status != 0) 369 if (unlikely (do_status != 0)
370 && QTD_PID (token) == 0 /* OUT */) { 370 && QTD_PID (token) == 0 /* OUT */) {
@@ -388,7 +388,7 @@ halt:
388 wmb (); 388 wmb ();
389 } 389 }
390 } 390 }
391 391
392 /* remove it from the queue */ 392 /* remove it from the queue */
393 spin_lock (&urb->lock); 393 spin_lock (&urb->lock);
394 qtd_copy_status (ehci, urb, qtd->length, token); 394 qtd_copy_status (ehci, urb, qtd->length, token);
@@ -518,7 +518,7 @@ qh_urb_transaction (
518 /* for zero length DATA stages, STATUS is always IN */ 518 /* for zero length DATA stages, STATUS is always IN */
519 if (len == 0) 519 if (len == 0)
520 token |= (1 /* "in" */ << 8); 520 token |= (1 /* "in" */ << 8);
521 } 521 }
522 522
523 /* 523 /*
524 * data transfer stage: buffer setup 524 * data transfer stage: buffer setup
@@ -759,7 +759,7 @@ qh_make (
759 } 759 }
760 break; 760 break;
761 default: 761 default:
762 dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed); 762 dbg ("bogus dev %p speed %d", urb->dev, urb->dev->speed);
763done: 763done:
764 qh_put (qh); 764 qh_put (qh);
765 return NULL; 765 return NULL;
@@ -967,17 +967,16 @@ static void end_unlink_async (struct ehci_hcd *ehci, struct pt_regs *regs)
967 struct ehci_qh *qh = ehci->reclaim; 967 struct ehci_qh *qh = ehci->reclaim;
968 struct ehci_qh *next; 968 struct ehci_qh *next;
969 969
970 timer_action_done (ehci, TIMER_IAA_WATCHDOG); 970 iaa_watchdog_done (ehci);
971 971
972 // qh->hw_next = cpu_to_le32 (qh->qh_dma); 972 // qh->hw_next = cpu_to_le32 (qh->qh_dma);
973 qh->qh_state = QH_STATE_IDLE; 973 qh->qh_state = QH_STATE_IDLE;
974 qh->qh_next.qh = NULL; 974 qh->qh_next.qh = NULL;
975 qh_put (qh); // refcount from reclaim 975 qh_put (qh); // refcount from reclaim
976 976
977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */ 977 /* other unlink(s) may be pending (in QH_STATE_UNLINK_WAIT) */
978 next = qh->reclaim; 978 next = qh->reclaim;
979 ehci->reclaim = next; 979 ehci->reclaim = next;
980 ehci->reclaim_ready = 0;
981 qh->reclaim = NULL; 980 qh->reclaim = NULL;
982 981
983 qh_completions (ehci, qh, regs); 982 qh_completions (ehci, qh, regs);
@@ -1031,7 +1030,7 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1031 timer_action_done (ehci, TIMER_ASYNC_OFF); 1030 timer_action_done (ehci, TIMER_ASYNC_OFF);
1032 } 1031 }
1033 return; 1032 return;
1034 } 1033 }
1035 1034
1036 qh->qh_state = QH_STATE_UNLINK; 1035 qh->qh_state = QH_STATE_UNLINK;
1037 ehci->reclaim = qh = qh_get (qh); 1036 ehci->reclaim = qh = qh_get (qh);
@@ -1046,17 +1045,16 @@ static void start_unlink_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
1046 1045
1047 if (unlikely (ehci_to_hcd(ehci)->state == HC_STATE_HALT)) { 1046 if (unlikely (ehci_to_hcd(ehci)->state == HC_STATE_HALT)) {
1048 /* if (unlikely (qh->reclaim != 0)) 1047 /* if (unlikely (qh->reclaim != 0))
1049 * this will recurse, probably not much 1048 * this will recurse, probably not much
1050 */ 1049 */
1051 end_unlink_async (ehci, NULL); 1050 end_unlink_async (ehci, NULL);
1052 return; 1051 return;
1053 } 1052 }
1054 1053
1055 ehci->reclaim_ready = 0;
1056 cmd |= CMD_IAAD; 1054 cmd |= CMD_IAAD;
1057 writel (cmd, &ehci->regs->command); 1055 writel (cmd, &ehci->regs->command);
1058 (void) readl (&ehci->regs->command); 1056 (void) readl (&ehci->regs->command);
1059 timer_action (ehci, TIMER_IAA_WATCHDOG); 1057 iaa_watchdog_start (ehci);
1060} 1058}
1061 1059
1062/*-------------------------------------------------------------------------*/ 1060/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 4859900bd135..e5e9c653c907 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2001-2004 by David Brownell 2 * Copyright (c) 2001-2004 by David Brownell
3 * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers 3 * Copyright (c) 2003 Michal Sojka, for high-speed iso transfers
4 * 4 *
5 * 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
6 * 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
7 * Free Software Foundation; either version 2 of the License, or (at your 7 * Free Software Foundation; either version 2 of the License, or (at your
@@ -613,7 +613,7 @@ static void intr_deschedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
613/*-------------------------------------------------------------------------*/ 613/*-------------------------------------------------------------------------*/
614 614
615static int check_period ( 615static int check_period (
616 struct ehci_hcd *ehci, 616 struct ehci_hcd *ehci,
617 unsigned frame, 617 unsigned frame,
618 unsigned uframe, 618 unsigned uframe,
619 unsigned period, 619 unsigned period,
@@ -629,7 +629,7 @@ static int check_period (
629 629
630 /* 630 /*
631 * 80% periodic == 100 usec/uframe available 631 * 80% periodic == 100 usec/uframe available
632 * convert "usecs we need" to "max already claimed" 632 * convert "usecs we need" to "max already claimed"
633 */ 633 */
634 usecs = 100 - usecs; 634 usecs = 100 - usecs;
635 635
@@ -659,14 +659,14 @@ static int check_period (
659} 659}
660 660
661static int check_intr_schedule ( 661static int check_intr_schedule (
662 struct ehci_hcd *ehci, 662 struct ehci_hcd *ehci,
663 unsigned frame, 663 unsigned frame,
664 unsigned uframe, 664 unsigned uframe,
665 const struct ehci_qh *qh, 665 const struct ehci_qh *qh,
666 __le32 *c_maskp 666 __le32 *c_maskp
667) 667)
668{ 668{
669 int retval = -ENOSPC; 669 int retval = -ENOSPC;
670 u8 mask = 0; 670 u8 mask = 0;
671 671
672 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */ 672 if (qh->c_usecs && uframe >= 6) /* FSTN territory? */
@@ -701,7 +701,7 @@ static int check_intr_schedule (
701 /* Make sure this tt's buffer is also available for CSPLITs. 701 /* Make sure this tt's buffer is also available for CSPLITs.
702 * We pessimize a bit; probably the typical full speed case 702 * We pessimize a bit; probably the typical full speed case
703 * doesn't need the second CSPLIT. 703 * doesn't need the second CSPLIT.
704 * 704 *
705 * NOTE: both SPLIT and CSPLIT could be checked in just 705 * NOTE: both SPLIT and CSPLIT could be checked in just
706 * one smart pass... 706 * one smart pass...
707 */ 707 */
@@ -728,7 +728,7 @@ done:
728 */ 728 */
729static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh) 729static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
730{ 730{
731 int status; 731 int status;
732 unsigned uframe; 732 unsigned uframe;
733 __le32 c_mask; 733 __le32 c_mask;
734 unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */ 734 unsigned frame; /* 0..(qh->period - 1), or NO_FRAME */
@@ -784,7 +784,7 @@ static int qh_schedule (struct ehci_hcd *ehci, struct ehci_qh *qh)
784 ehci_dbg (ehci, "reused qh %p schedule\n", qh); 784 ehci_dbg (ehci, "reused qh %p schedule\n", qh);
785 785
786 /* stuff into the periodic schedule */ 786 /* stuff into the periodic schedule */
787 status = qh_link_periodic (ehci, qh); 787 status = qh_link_periodic (ehci, qh);
788done: 788done:
789 return status; 789 return status;
790} 790}
@@ -1681,7 +1681,7 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1681 status = -ESHUTDOWN; 1681 status = -ESHUTDOWN;
1682 else 1682 else
1683 status = iso_stream_schedule (ehci, urb, stream); 1683 status = iso_stream_schedule (ehci, urb, stream);
1684 if (likely (status == 0)) 1684 if (likely (status == 0))
1685 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 1685 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
1686 spin_unlock_irqrestore (&ehci->lock, flags); 1686 spin_unlock_irqrestore (&ehci->lock, flags);
1687 1687
@@ -1738,7 +1738,7 @@ sitd_sched_init (
1738 if (packet->buf1 != (buf & ~(u64)0x0fff)) 1738 if (packet->buf1 != (buf & ~(u64)0x0fff))
1739 packet->cross = 1; 1739 packet->cross = 1;
1740 1740
1741 /* OUT uses multiple start-splits */ 1741 /* OUT uses multiple start-splits */
1742 if (stream->bEndpointAddress & USB_DIR_IN) 1742 if (stream->bEndpointAddress & USB_DIR_IN)
1743 continue; 1743 continue;
1744 length = (length + 187) / 188; 1744 length = (length + 187) / 188;
@@ -1925,7 +1925,7 @@ sitd_link_urb (
1925/*-------------------------------------------------------------------------*/ 1925/*-------------------------------------------------------------------------*/
1926 1926
1927#define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \ 1927#define SITD_ERRS (SITD_STS_ERR | SITD_STS_DBE | SITD_STS_BABBLE \
1928 | SITD_STS_XACT | SITD_STS_MMF) 1928 | SITD_STS_XACT | SITD_STS_MMF)
1929 1929
1930static unsigned 1930static unsigned
1931sitd_complete ( 1931sitd_complete (
@@ -2043,7 +2043,7 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
2043 status = -ESHUTDOWN; 2043 status = -ESHUTDOWN;
2044 else 2044 else
2045 status = iso_stream_schedule (ehci, urb, stream); 2045 status = iso_stream_schedule (ehci, urb, stream);
2046 if (status == 0) 2046 if (status == 0)
2047 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 2047 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
2048 spin_unlock_irqrestore (&ehci->lock, flags); 2048 spin_unlock_irqrestore (&ehci->lock, flags);
2049 2049
@@ -2226,5 +2226,5 @@ restart:
2226 now_uframe++; 2226 now_uframe++;
2227 now_uframe %= mod; 2227 now_uframe %= mod;
2228 } 2228 }
2229 } 2229 }
2230} 2230}
diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
index 679c1cdcc915..6aac39f50e07 100644
--- a/drivers/usb/host/ehci.h
+++ b/drivers/usb/host/ehci.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Copyright (c) 2001-2002 by David Brownell 2 * Copyright (c) 2001-2002 by David Brownell
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the 5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your 6 * Free Software Foundation; either version 2 of the License, or (at your
@@ -58,7 +58,6 @@ struct ehci_hcd { /* one per controller */
58 /* async schedule support */ 58 /* async schedule support */
59 struct ehci_qh *async; 59 struct ehci_qh *async;
60 struct ehci_qh *reclaim; 60 struct ehci_qh *reclaim;
61 unsigned reclaim_ready : 1;
62 unsigned scanning : 1; 61 unsigned scanning : 1;
63 62
64 /* periodic schedule support */ 63 /* periodic schedule support */
@@ -81,8 +80,8 @@ struct ehci_hcd { /* one per controller */
81 struct dma_pool *itd_pool; /* itd per iso urb */ 80 struct dma_pool *itd_pool; /* itd per iso urb */
82 struct dma_pool *sitd_pool; /* sitd per split iso urb */ 81 struct dma_pool *sitd_pool; /* sitd per split iso urb */
83 82
83 struct timer_list iaa_watchdog;
84 struct timer_list watchdog; 84 struct timer_list watchdog;
85 struct notifier_block reboot_notifier;
86 unsigned long actions; 85 unsigned long actions;
87 unsigned stamp; 86 unsigned stamp;
88 unsigned long next_statechange; 87 unsigned long next_statechange;
@@ -104,7 +103,7 @@ struct ehci_hcd { /* one per controller */
104#endif 103#endif
105}; 104};
106 105
107/* convert between an HCD pointer and the corresponding EHCI_HCD */ 106/* convert between an HCD pointer and the corresponding EHCI_HCD */
108static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd) 107static inline struct ehci_hcd *hcd_to_ehci (struct usb_hcd *hcd)
109{ 108{
110 return (struct ehci_hcd *) (hcd->hcd_priv); 109 return (struct ehci_hcd *) (hcd->hcd_priv);
@@ -115,9 +114,21 @@ static inline struct usb_hcd *ehci_to_hcd (struct ehci_hcd *ehci)
115} 114}
116 115
117 116
117static inline void
118iaa_watchdog_start (struct ehci_hcd *ehci)
119{
120 WARN_ON(timer_pending(&ehci->iaa_watchdog));
121 mod_timer (&ehci->iaa_watchdog,
122 jiffies + msecs_to_jiffies(EHCI_IAA_MSECS));
123}
124
125static inline void iaa_watchdog_done (struct ehci_hcd *ehci)
126{
127 del_timer (&ehci->iaa_watchdog);
128}
129
118enum ehci_timer_action { 130enum ehci_timer_action {
119 TIMER_IO_WATCHDOG, 131 TIMER_IO_WATCHDOG,
120 TIMER_IAA_WATCHDOG,
121 TIMER_ASYNC_SHRINK, 132 TIMER_ASYNC_SHRINK,
122 TIMER_ASYNC_OFF, 133 TIMER_ASYNC_OFF,
123}; 134};
@@ -135,9 +146,6 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
135 unsigned long t; 146 unsigned long t;
136 147
137 switch (action) { 148 switch (action) {
138 case TIMER_IAA_WATCHDOG:
139 t = EHCI_IAA_JIFFIES;
140 break;
141 case TIMER_IO_WATCHDOG: 149 case TIMER_IO_WATCHDOG:
142 t = EHCI_IO_JIFFIES; 150 t = EHCI_IO_JIFFIES;
143 break; 151 break;
@@ -154,8 +162,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
154 // async queue SHRINK often precedes IAA. while it's ready 162 // async queue SHRINK often precedes IAA. while it's ready
155 // to go OFF neither can matter, and afterwards the IO 163 // to go OFF neither can matter, and afterwards the IO
156 // watchdog stops unless there's still periodic traffic. 164 // watchdog stops unless there's still periodic traffic.
157 if (action != TIMER_IAA_WATCHDOG 165 if (time_before_eq(t, ehci->watchdog.expires)
158 && t > ehci->watchdog.expires
159 && timer_pending (&ehci->watchdog)) 166 && timer_pending (&ehci->watchdog))
160 return; 167 return;
161 mod_timer (&ehci->watchdog, t); 168 mod_timer (&ehci->watchdog, t);
@@ -179,8 +186,8 @@ struct ehci_caps {
179#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */ 186#define HCS_INDICATOR(p) ((p)&(1 << 16)) /* true: has port indicators */
180#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */ 187#define HCS_N_CC(p) (((p)>>12)&0xf) /* bits 15:12, #companion HCs */
181#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */ 188#define HCS_N_PCC(p) (((p)>>8)&0xf) /* bits 11:8, ports per CC */
182#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */ 189#define HCS_PORTROUTED(p) ((p)&(1 << 7)) /* true: port routing */
183#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */ 190#define HCS_PPC(p) ((p)&(1 << 4)) /* true: port power control */
184#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */ 191#define HCS_N_PORTS(p) (((p)>>0)&0xf) /* bits 3:0, ports on HC */
185 192
186 u32 hcc_params; /* HCCPARAMS - offset 0x8 */ 193 u32 hcc_params; /* HCCPARAMS - offset 0x8 */
@@ -205,7 +212,7 @@ struct ehci_regs {
205#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */ 212#define CMD_LRESET (1<<7) /* partial reset (no ports, etc) */
206#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */ 213#define CMD_IAAD (1<<6) /* "doorbell" interrupt async advance */
207#define CMD_ASE (1<<5) /* async schedule enable */ 214#define CMD_ASE (1<<5) /* async schedule enable */
208#define CMD_PSE (1<<4) /* periodic schedule enable */ 215#define CMD_PSE (1<<4) /* periodic schedule enable */
209/* 3:2 is periodic frame list size */ 216/* 3:2 is periodic frame list size */
210#define CMD_RESET (1<<1) /* reset HC not bus */ 217#define CMD_RESET (1<<1) /* reset HC not bus */
211#define CMD_RUN (1<<0) /* start/stop HC */ 218#define CMD_RUN (1<<0) /* start/stop HC */
@@ -231,9 +238,9 @@ struct ehci_regs {
231 /* FRINDEX: offset 0x0C */ 238 /* FRINDEX: offset 0x0C */
232 u32 frame_index; /* current microframe number */ 239 u32 frame_index; /* current microframe number */
233 /* CTRLDSSEGMENT: offset 0x10 */ 240 /* CTRLDSSEGMENT: offset 0x10 */
234 u32 segment; /* address bits 63:32 if needed */ 241 u32 segment; /* address bits 63:32 if needed */
235 /* PERIODICLISTBASE: offset 0x14 */ 242 /* PERIODICLISTBASE: offset 0x14 */
236 u32 frame_list; /* points to periodic list */ 243 u32 frame_list; /* points to periodic list */
237 /* ASYNCLISTADDR: offset 0x18 */ 244 /* ASYNCLISTADDR: offset 0x18 */
238 u32 async_next; /* address of next async queue head */ 245 u32 async_next; /* address of next async queue head */
239 246
@@ -302,7 +309,7 @@ struct ehci_dbg_port {
302 309
303/* 310/*
304 * EHCI Specification 0.95 Section 3.5 311 * EHCI Specification 0.95 Section 3.5
305 * QTD: describe data transfer components (buffer, direction, ...) 312 * QTD: describe data transfer components (buffer, direction, ...)
306 * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram". 313 * See Fig 3-6 "Queue Element Transfer Descriptor Block Diagram".
307 * 314 *
308 * These are associated only with "QH" (Queue Head) structures, 315 * These are associated only with "QH" (Queue Head) structures,
@@ -312,7 +319,7 @@ struct ehci_qtd {
312 /* first part defined by EHCI spec */ 319 /* first part defined by EHCI spec */
313 __le32 hw_next; /* see EHCI 3.5.1 */ 320 __le32 hw_next; /* see EHCI 3.5.1 */
314 __le32 hw_alt_next; /* see EHCI 3.5.2 */ 321 __le32 hw_alt_next; /* see EHCI 3.5.2 */
315 __le32 hw_token; /* see EHCI 3.5.3 */ 322 __le32 hw_token; /* see EHCI 3.5.3 */
316#define QTD_TOGGLE (1 << 31) /* data toggle */ 323#define QTD_TOGGLE (1 << 31) /* data toggle */
317#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff) 324#define QTD_LENGTH(tok) (((tok)>>16) & 0x7fff)
318#define QTD_IOC (1 << 15) /* interrupt on complete */ 325#define QTD_IOC (1 << 15) /* interrupt on complete */
@@ -349,8 +356,8 @@ struct ehci_qtd {
349/* values for that type tag */ 356/* values for that type tag */
350#define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1) 357#define Q_TYPE_ITD __constant_cpu_to_le32 (0 << 1)
351#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1) 358#define Q_TYPE_QH __constant_cpu_to_le32 (1 << 1)
352#define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1) 359#define Q_TYPE_SITD __constant_cpu_to_le32 (2 << 1)
353#define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1) 360#define Q_TYPE_FSTN __constant_cpu_to_le32 (3 << 1)
354 361
355/* next async queue entry, or pointer to interrupt/periodic QH */ 362/* next async queue entry, or pointer to interrupt/periodic QH */
356#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH) 363#define QH_NEXT(dma) (cpu_to_le32(((u32)dma)&~0x01f)|Q_TYPE_QH)
@@ -367,7 +374,7 @@ struct ehci_qtd {
367 * For entries in the async schedule, the type tag always says "qh". 374 * For entries in the async schedule, the type tag always says "qh".
368 */ 375 */
369union ehci_shadow { 376union ehci_shadow {
370 struct ehci_qh *qh; /* Q_TYPE_QH */ 377 struct ehci_qh *qh; /* Q_TYPE_QH */
371 struct ehci_itd *itd; /* Q_TYPE_ITD */ 378 struct ehci_itd *itd; /* Q_TYPE_ITD */
372 struct ehci_sitd *sitd; /* Q_TYPE_SITD */ 379 struct ehci_sitd *sitd; /* Q_TYPE_SITD */
373 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */ 380 struct ehci_fstn *fstn; /* Q_TYPE_FSTN */
@@ -397,7 +404,7 @@ struct ehci_qh {
397#define QH_HUBPORT 0x3f800000 404#define QH_HUBPORT 0x3f800000
398#define QH_MULT 0xc0000000 405#define QH_MULT 0xc0000000
399 __le32 hw_current; /* qtd list - see EHCI 3.6.4 */ 406 __le32 hw_current; /* qtd list - see EHCI 3.6.4 */
400 407
401 /* qtd overlay (hardware parts of a struct ehci_qtd) */ 408 /* qtd overlay (hardware parts of a struct ehci_qtd) */
402 __le32 hw_qtd_next; 409 __le32 hw_qtd_next;
403 __le32 hw_alt_next; 410 __le32 hw_alt_next;
@@ -472,7 +479,7 @@ struct ehci_iso_stream {
472 struct list_head td_list; /* queued itds/sitds */ 479 struct list_head td_list; /* queued itds/sitds */
473 struct list_head free_list; /* list of unused itds/sitds */ 480 struct list_head free_list; /* list of unused itds/sitds */
474 struct usb_device *udev; 481 struct usb_device *udev;
475 struct usb_host_endpoint *ep; 482 struct usb_host_endpoint *ep;
476 483
477 /* output of (re)scheduling */ 484 /* output of (re)scheduling */
478 unsigned long start; /* jiffies */ 485 unsigned long start; /* jiffies */
@@ -492,8 +499,8 @@ struct ehci_iso_stream {
492 unsigned bandwidth; 499 unsigned bandwidth;
493 500
494 /* This is used to initialize iTD's hw_bufp fields */ 501 /* This is used to initialize iTD's hw_bufp fields */
495 __le32 buf0; 502 __le32 buf0;
496 __le32 buf1; 503 __le32 buf1;
497 __le32 buf2; 504 __le32 buf2;
498 505
499 /* this is used to initialize sITD's tt info */ 506 /* this is used to initialize sITD's tt info */
@@ -521,7 +528,7 @@ struct ehci_itd {
521 528
522#define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE) 529#define ITD_ACTIVE __constant_cpu_to_le32(EHCI_ISOC_ACTIVE)
523 530
524 __le32 hw_bufp [7]; /* see EHCI 3.3.3 */ 531 __le32 hw_bufp [7]; /* see EHCI 3.3.3 */
525 __le32 hw_bufp_hi [7]; /* Appendix B */ 532 __le32 hw_bufp_hi [7]; /* Appendix B */
526 533
527 /* the rest is HCD-private */ 534 /* the rest is HCD-private */
@@ -542,7 +549,7 @@ struct ehci_itd {
542/*-------------------------------------------------------------------------*/ 549/*-------------------------------------------------------------------------*/
543 550
544/* 551/*
545 * EHCI Specification 0.95 Section 3.4 552 * EHCI Specification 0.95 Section 3.4
546 * siTD, aka split-transaction isochronous Transfer Descriptor 553 * siTD, aka split-transaction isochronous Transfer Descriptor
547 * ... describe full speed iso xfers through TT in hubs 554 * ... describe full speed iso xfers through TT in hubs
548 * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD) 555 * see Figure 3-5 "Split-transaction Isochronous Transaction Descriptor (siTD)
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 5147ed4a6662..a72e041df8e7 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1204,10 +1204,10 @@ static int isp116x_show_dbg(struct seq_file *s, void *unused)
1204 1204
1205static int isp116x_open_seq(struct inode *inode, struct file *file) 1205static int isp116x_open_seq(struct inode *inode, struct file *file)
1206{ 1206{
1207 return single_open(file, isp116x_show_dbg, inode->u.generic_ip); 1207 return single_open(file, isp116x_show_dbg, inode->i_private);
1208} 1208}
1209 1209
1210static struct file_operations isp116x_debug_fops = { 1210static const struct file_operations isp116x_debug_fops = {
1211 .open = isp116x_open_seq, 1211 .open = isp116x_open_seq,
1212 .read = seq_read, 1212 .read = seq_read,
1213 .llseek = seq_lseek, 1213 .llseek = seq_lseek,
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index a1b7c3813d3a..b91e2edd9c5c 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -233,7 +233,7 @@ static const int cc_to_error[16] = {
233 /* Bit Stuff */ -EPROTO, 233 /* Bit Stuff */ -EPROTO,
234 /* Data Togg */ -EILSEQ, 234 /* Data Togg */ -EILSEQ,
235 /* Stall */ -EPIPE, 235 /* Stall */ -EPIPE,
236 /* DevNotResp */ -ETIMEDOUT, 236 /* DevNotResp */ -ETIME,
237 /* PIDCheck */ -EPROTO, 237 /* PIDCheck */ -EPROTO,
238 /* UnExpPID */ -EPROTO, 238 /* UnExpPID */ -EPROTO,
239 /* DataOver */ -EOVERFLOW, 239 /* DataOver */ -EOVERFLOW,
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 85cc059705a6..b466581beb4a 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -193,7 +193,7 @@ ohci_at91_start (struct usb_hcd *hcd)
193 if ((ret = ohci_init(ohci)) < 0) 193 if ((ret = ohci_init(ohci)) < 0)
194 return ret; 194 return ret;
195 195
196 root->maxchild = board->ports; 196 ohci->num_ports = board->ports;
197 197
198 if ((ret = ohci_run(ohci)) < 0) { 198 if ((ret = ohci_run(ohci)) < 0) {
199 err("can't start %s", hcd->self.bus_name); 199 err("can't start %s", hcd->self.bus_name);
@@ -221,6 +221,7 @@ static const struct hc_driver ohci_at91_hc_driver = {
221 */ 221 */
222 .start = ohci_at91_start, 222 .start = ohci_at91_start,
223 .stop = ohci_stop, 223 .stop = ohci_stop,
224 .shutdown = ohci_shutdown,
224 225
225 /* 226 /*
226 * managing i/o requests and associated device resources 227 * managing i/o requests and associated device resources
@@ -239,7 +240,7 @@ static const struct hc_driver ohci_at91_hc_driver = {
239 */ 240 */
240 .hub_status_data = ohci_hub_status_data, 241 .hub_status_data = ohci_hub_status_data,
241 .hub_control = ohci_hub_control, 242 .hub_control = ohci_hub_control,
242 243 .hub_irq_enable = ohci_rhsc_enable,
243#ifdef CONFIG_PM 244#ifdef CONFIG_PM
244 .bus_suspend = ohci_bus_suspend, 245 .bus_suspend = ohci_bus_suspend,
245 .bus_resume = ohci_bus_resume, 246 .bus_resume = ohci_bus_resume,
@@ -296,6 +297,7 @@ static int ohci_hcd_at91_drv_resume(struct platform_device *pdev)
296 if (!clocked) { 297 if (!clocked) {
297 clk_enable(iclk); 298 clk_enable(iclk);
298 clk_enable(fclk); 299 clk_enable(fclk);
300 clocked = 1;
299 } 301 }
300 302
301 return 0; 303 return 0;
@@ -310,6 +312,7 @@ MODULE_ALIAS("at91_ohci");
310static struct platform_driver ohci_hcd_at91_driver = { 312static struct platform_driver ohci_hcd_at91_driver = {
311 .probe = ohci_hcd_at91_drv_probe, 313 .probe = ohci_hcd_at91_drv_probe,
312 .remove = ohci_hcd_at91_drv_remove, 314 .remove = ohci_hcd_at91_drv_remove,
315 .shutdown = usb_hcd_platform_shutdown,
313 .suspend = ohci_hcd_at91_drv_suspend, 316 .suspend = ohci_hcd_at91_drv_suspend,
314 .resume = ohci_hcd_at91_drv_resume, 317 .resume = ohci_hcd_at91_drv_resume,
315 .driver = { 318 .driver = {
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index f7a975d5db09..24e23c5783d8 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -268,11 +268,8 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
268 * basic lifecycle operations 268 * basic lifecycle operations
269 */ 269 */
270 .start = ohci_au1xxx_start, 270 .start = ohci_au1xxx_start,
271#ifdef CONFIG_PM
272 /* suspend: ohci_au1xxx_suspend, -- tbd */
273 /* resume: ohci_au1xxx_resume, -- tbd */
274#endif /*CONFIG_PM*/
275 .stop = ohci_stop, 271 .stop = ohci_stop,
272 .shutdown = ohci_shutdown,
276 273
277 /* 274 /*
278 * managing i/o requests and associated device resources 275 * managing i/o requests and associated device resources
@@ -291,6 +288,7 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
291 */ 288 */
292 .hub_status_data = ohci_hub_status_data, 289 .hub_status_data = ohci_hub_status_data,
293 .hub_control = ohci_hub_control, 290 .hub_control = ohci_hub_control,
291 .hub_irq_enable = ohci_rhsc_enable,
294#ifdef CONFIG_PM 292#ifdef CONFIG_PM
295 .bus_suspend = ohci_bus_suspend, 293 .bus_suspend = ohci_bus_suspend,
296 .bus_resume = ohci_bus_resume, 294 .bus_resume = ohci_bus_resume,
@@ -338,6 +336,7 @@ static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev)
338static struct platform_driver ohci_hcd_au1xxx_driver = { 336static struct platform_driver ohci_hcd_au1xxx_driver = {
339 .probe = ohci_hcd_au1xxx_drv_probe, 337 .probe = ohci_hcd_au1xxx_drv_probe,
340 .remove = ohci_hcd_au1xxx_drv_remove, 338 .remove = ohci_hcd_au1xxx_drv_remove,
339 .shutdown = usb_hcd_platform_shutdown,
341 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ 340 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */
342 /*.resume = ohci_hcd_au1xxx_drv_resume, */ 341 /*.resume = ohci_hcd_au1xxx_drv_resume, */
343 .driver = { 342 .driver = {
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c
index 7bfffcbbd226..8293c1d4be3f 100644
--- a/drivers/usb/host/ohci-dbg.c
+++ b/drivers/usb/host/ohci-dbg.c
@@ -477,7 +477,7 @@ show_async (struct class_device *class_dev, char *buf)
477 unsigned long flags; 477 unsigned long flags;
478 478
479 bus = class_get_devdata(class_dev); 479 bus = class_get_devdata(class_dev);
480 hcd = bus->hcpriv; 480 hcd = bus_to_hcd(bus);
481 ohci = hcd_to_ohci(hcd); 481 ohci = hcd_to_ohci(hcd);
482 482
483 /* display control and bulk lists together, for simplicity */ 483 /* display control and bulk lists together, for simplicity */
@@ -510,7 +510,7 @@ show_periodic (struct class_device *class_dev, char *buf)
510 seen_count = 0; 510 seen_count = 0;
511 511
512 bus = class_get_devdata(class_dev); 512 bus = class_get_devdata(class_dev);
513 hcd = bus->hcpriv; 513 hcd = bus_to_hcd(bus);
514 ohci = hcd_to_ohci(hcd); 514 ohci = hcd_to_ohci(hcd);
515 next = buf; 515 next = buf;
516 size = PAGE_SIZE; 516 size = PAGE_SIZE;
@@ -607,7 +607,7 @@ show_registers (struct class_device *class_dev, char *buf)
607 u32 rdata; 607 u32 rdata;
608 608
609 bus = class_get_devdata(class_dev); 609 bus = class_get_devdata(class_dev);
610 hcd = bus->hcpriv; 610 hcd = bus_to_hcd(bus);
611 ohci = hcd_to_ohci(hcd); 611 ohci = hcd_to_ohci(hcd);
612 regs = ohci->regs; 612 regs = ohci->regs;
613 next = buf; 613 next = buf;
@@ -667,6 +667,11 @@ show_registers (struct class_device *class_dev, char *buf)
667 size -= temp; 667 size -= temp;
668 next += temp; 668 next += temp;
669 669
670 temp = scnprintf (next, size, "hub poll timer %s\n",
671 ohci_to_hcd(ohci)->poll_rh ? "ON" : "off");
672 size -= temp;
673 next += temp;
674
670 /* roothub */ 675 /* roothub */
671 ohci_dump_roothub (ohci, 1, &next, &size); 676 ohci_dump_roothub (ohci, 1, &next, &size);
672 677
@@ -680,10 +685,11 @@ static CLASS_DEVICE_ATTR (registers, S_IRUGO, show_registers, NULL);
680static inline void create_debug_files (struct ohci_hcd *ohci) 685static inline void create_debug_files (struct ohci_hcd *ohci)
681{ 686{
682 struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev; 687 struct class_device *cldev = ohci_to_hcd(ohci)->self.class_dev;
688 int retval;
683 689
684 class_device_create_file(cldev, &class_device_attr_async); 690 retval = class_device_create_file(cldev, &class_device_attr_async);
685 class_device_create_file(cldev, &class_device_attr_periodic); 691 retval = class_device_create_file(cldev, &class_device_attr_periodic);
686 class_device_create_file(cldev, &class_device_attr_registers); 692 retval = class_device_create_file(cldev, &class_device_attr_registers);
687 ohci_dbg (ohci, "created debug files\n"); 693 ohci_dbg (ohci, "created debug files\n");
688} 694}
689 695
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c
index 6531c4d26527..1bf5e7a4e735 100644
--- a/drivers/usb/host/ohci-ep93xx.c
+++ b/drivers/usb/host/ohci-ep93xx.c
@@ -128,12 +128,14 @@ static struct hc_driver ohci_ep93xx_hc_driver = {
128 .flags = HCD_USB11 | HCD_MEMORY, 128 .flags = HCD_USB11 | HCD_MEMORY,
129 .start = ohci_ep93xx_start, 129 .start = ohci_ep93xx_start,
130 .stop = ohci_stop, 130 .stop = ohci_stop,
131 .shutdown = ohci_shutdown,
131 .urb_enqueue = ohci_urb_enqueue, 132 .urb_enqueue = ohci_urb_enqueue,
132 .urb_dequeue = ohci_urb_dequeue, 133 .urb_dequeue = ohci_urb_dequeue,
133 .endpoint_disable = ohci_endpoint_disable, 134 .endpoint_disable = ohci_endpoint_disable,
134 .get_frame_number = ohci_get_frame, 135 .get_frame_number = ohci_get_frame,
135 .hub_status_data = ohci_hub_status_data, 136 .hub_status_data = ohci_hub_status_data,
136 .hub_control = ohci_hub_control, 137 .hub_control = ohci_hub_control,
138 .hub_irq_enable = ohci_rhsc_enable,
137#ifdef CONFIG_PM 139#ifdef CONFIG_PM
138 .bus_suspend = ohci_bus_suspend, 140 .bus_suspend = ohci_bus_suspend,
139 .bus_resume = ohci_bus_resume, 141 .bus_resume = ohci_bus_resume,
@@ -202,6 +204,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev)
202static struct platform_driver ohci_hcd_ep93xx_driver = { 204static struct platform_driver ohci_hcd_ep93xx_driver = {
203 .probe = ohci_hcd_ep93xx_drv_probe, 205 .probe = ohci_hcd_ep93xx_drv_probe,
204 .remove = ohci_hcd_ep93xx_drv_remove, 206 .remove = ohci_hcd_ep93xx_drv_remove,
207 .shutdown = usb_hcd_platform_shutdown,
205#ifdef CONFIG_PM 208#ifdef CONFIG_PM
206 .suspend = ohci_hcd_ep93xx_drv_suspend, 209 .suspend = ohci_hcd_ep93xx_drv_suspend,
207 .resume = ohci_hcd_ep93xx_drv_resume, 210 .resume = ohci_hcd_ep93xx_drv_resume,
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 94d8cf4b36c1..1027aa04583d 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -88,7 +88,7 @@
88#include <linux/timer.h> 88#include <linux/timer.h>
89#include <linux/list.h> 89#include <linux/list.h>
90#include <linux/usb.h> 90#include <linux/usb.h>
91#include <linux/usb_otg.h> 91#include <linux/usb/otg.h>
92#include <linux/dma-mapping.h> 92#include <linux/dma-mapping.h>
93#include <linux/dmapool.h> 93#include <linux/dmapool.h>
94#include <linux/reboot.h> 94#include <linux/reboot.h>
@@ -101,7 +101,7 @@
101 101
102#include "../core/hcd.h" 102#include "../core/hcd.h"
103 103
104#define DRIVER_VERSION "2005 April 22" 104#define DRIVER_VERSION "2006 August 04"
105#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell" 105#define DRIVER_AUTHOR "Roman Weissgaerber, David Brownell"
106#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver" 106#define DRIVER_DESC "USB 1.1 'Open' Host Controller (OHCI) Driver"
107 107
@@ -110,9 +110,10 @@
110#undef OHCI_VERBOSE_DEBUG /* not always helpful */ 110#undef OHCI_VERBOSE_DEBUG /* not always helpful */
111 111
112/* For initializing controller (mask in an HCFS mode too) */ 112/* For initializing controller (mask in an HCFS mode too) */
113#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 113#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
114#define OHCI_INTR_INIT \ 114#define OHCI_INTR_INIT \
115 (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_WDH) 115 (OHCI_INTR_MIE | OHCI_INTR_RHSC | OHCI_INTR_UE \
116 | OHCI_INTR_RD | OHCI_INTR_WDH)
116 117
117#ifdef __hppa__ 118#ifdef __hppa__
118/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */ 119/* On PA-RISC, PDC can leave IR set incorrectly; ignore it there. */
@@ -128,12 +129,13 @@
128 129
129static const char hcd_name [] = "ohci_hcd"; 130static const char hcd_name [] = "ohci_hcd";
130 131
132#define STATECHANGE_DELAY msecs_to_jiffies(300)
133
131#include "ohci.h" 134#include "ohci.h"
132 135
133static void ohci_dump (struct ohci_hcd *ohci, int verbose); 136static void ohci_dump (struct ohci_hcd *ohci, int verbose);
134static int ohci_init (struct ohci_hcd *ohci); 137static int ohci_init (struct ohci_hcd *ohci);
135static void ohci_stop (struct usb_hcd *hcd); 138static void ohci_stop (struct usb_hcd *hcd);
136static int ohci_reboot (struct notifier_block *, unsigned long , void *);
137 139
138#include "ohci-hub.c" 140#include "ohci-hub.c"
139#include "ohci-dbg.c" 141#include "ohci-dbg.c"
@@ -416,21 +418,20 @@ static void ohci_usb_reset (struct ohci_hcd *ohci)
416 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 418 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
417} 419}
418 420
419/* reboot notifier forcibly disables IRQs and DMA, helping kexec and 421/* ohci_shutdown forcibly disables IRQs and DMA, helping kexec and
420 * other cases where the next software may expect clean state from the 422 * other cases where the next software may expect clean state from the
421 * "firmware". this is bus-neutral, unlike shutdown() methods. 423 * "firmware". this is bus-neutral, unlike shutdown() methods.
422 */ 424 */
423static int 425static void
424ohci_reboot (struct notifier_block *block, unsigned long code, void *null) 426ohci_shutdown (struct usb_hcd *hcd)
425{ 427{
426 struct ohci_hcd *ohci; 428 struct ohci_hcd *ohci;
427 429
428 ohci = container_of (block, struct ohci_hcd, reboot_notifier); 430 ohci = hcd_to_ohci (hcd);
429 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 431 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
430 ohci_usb_reset (ohci); 432 ohci_usb_reset (ohci);
431 /* flush the writes */ 433 /* flush the writes */
432 (void) ohci_readl (ohci, &ohci->regs->control); 434 (void) ohci_readl (ohci, &ohci->regs->control);
433 return 0;
434} 435}
435 436
436/*-------------------------------------------------------------------------* 437/*-------------------------------------------------------------------------*
@@ -446,7 +447,6 @@ static int ohci_init (struct ohci_hcd *ohci)
446 447
447 disable (ohci); 448 disable (ohci);
448 ohci->regs = hcd->regs; 449 ohci->regs = hcd->regs;
449 ohci->next_statechange = jiffies;
450 450
451 /* REVISIT this BIOS handshake is now moved into PCI "quirks", and 451 /* REVISIT this BIOS handshake is now moved into PCI "quirks", and
452 * was never needed for most non-PCI systems ... remove the code? 452 * was never needed for most non-PCI systems ... remove the code?
@@ -502,7 +502,6 @@ static int ohci_init (struct ohci_hcd *ohci)
502 if ((ret = ohci_mem_init (ohci)) < 0) 502 if ((ret = ohci_mem_init (ohci)) < 0)
503 ohci_stop (hcd); 503 ohci_stop (hcd);
504 else { 504 else {
505 register_reboot_notifier (&ohci->reboot_notifier);
506 create_debug_files (ohci); 505 create_debug_files (ohci);
507 } 506 }
508 507
@@ -637,10 +636,14 @@ retry:
637 return -EOVERFLOW; 636 return -EOVERFLOW;
638 } 637 }
639 638
640 /* start controller operations */ 639 /* use rhsc irqs after khubd is fully initialized */
640 hcd->poll_rh = 1;
641 hcd->uses_new_polling = 1;
642
643 /* start controller operations */
641 ohci->hc_control &= OHCI_CTRL_RWC; 644 ohci->hc_control &= OHCI_CTRL_RWC;
642 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER; 645 ohci->hc_control |= OHCI_CONTROL_INIT | OHCI_USB_OPER;
643 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); 646 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control);
644 hcd->state = HC_STATE_RUNNING; 647 hcd->state = HC_STATE_RUNNING;
645 648
646 /* wake on ConnectStatusChange, matching external hubs */ 649 /* wake on ConnectStatusChange, matching external hubs */
@@ -648,7 +651,7 @@ retry:
648 651
649 /* Choose the interrupts we care about now, others later on demand */ 652 /* Choose the interrupts we care about now, others later on demand */
650 mask = OHCI_INTR_INIT; 653 mask = OHCI_INTR_INIT;
651 ohci_writel (ohci, mask, &ohci->regs->intrstatus); 654 ohci_writel (ohci, ~0, &ohci->regs->intrstatus);
652 ohci_writel (ohci, mask, &ohci->regs->intrenable); 655 ohci_writel (ohci, mask, &ohci->regs->intrenable);
653 656
654 /* handle root hub init quirks ... */ 657 /* handle root hub init quirks ... */
@@ -672,6 +675,7 @@ retry:
672 // flush those writes 675 // flush those writes
673 (void) ohci_readl (ohci, &ohci->regs->control); 676 (void) ohci_readl (ohci, &ohci->regs->control);
674 677
678 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
675 spin_unlock_irq (&ohci->lock); 679 spin_unlock_irq (&ohci->lock);
676 680
677 // POTPGT delay is bits 24-31, in 2 ms units. 681 // POTPGT delay is bits 24-31, in 2 ms units.
@@ -709,7 +713,23 @@ static irqreturn_t ohci_irq (struct usb_hcd *hcd, struct pt_regs *ptregs)
709 /* interrupt for some other device? */ 713 /* interrupt for some other device? */
710 } else if ((ints &= ohci_readl (ohci, &regs->intrenable)) == 0) { 714 } else if ((ints &= ohci_readl (ohci, &regs->intrenable)) == 0) {
711 return IRQ_NOTMINE; 715 return IRQ_NOTMINE;
712 } 716 }
717
718 /* NOTE: vendors didn't always make the same implementation
719 * choices for RHSC. Sometimes it triggers on an edge (like
720 * setting and maybe clearing a port status change bit); and
721 * it's level-triggered on other silicon, active until khubd
722 * clears all active port status change bits. Poll by timer
723 * til it's fully debounced and the difference won't matter.
724 */
725 if (ints & OHCI_INTR_RHSC) {
726 ohci_vdbg (ohci, "rhsc\n");
727 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrdisable);
728 hcd->poll_rh = 1;
729 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
730 ohci_writel (ohci, OHCI_INTR_RHSC, &regs->intrstatus);
731 usb_hcd_poll_rh_status(hcd);
732 }
713 733
714 if (ints & OHCI_INTR_UE) { 734 if (ints & OHCI_INTR_UE) {
715 disable (ohci); 735 disable (ohci);
@@ -775,9 +795,10 @@ static void ohci_stop (struct usb_hcd *hcd)
775 795
776 ohci_usb_reset (ohci); 796 ohci_usb_reset (ohci);
777 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 797 ohci_writel (ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
778 798 free_irq(hcd->irq, hcd);
799 hcd->irq = -1;
800
779 remove_debug_files (ohci); 801 remove_debug_files (ohci);
780 unregister_reboot_notifier (&ohci->reboot_notifier);
781 ohci_mem_cleanup (ohci); 802 ohci_mem_cleanup (ohci);
782 if (ohci->hcca) { 803 if (ohci->hcca) {
783 dma_free_coherent (hcd->self.controller, 804 dma_free_coherent (hcd->self.controller,
@@ -917,6 +938,10 @@ MODULE_LICENSE ("GPL");
917#include "ohci-at91.c" 938#include "ohci-at91.c"
918#endif 939#endif
919 940
941#ifdef CONFIG_ARCH_PNX4008
942#include "ohci-pnx4008.c"
943#endif
944
920#if !(defined(CONFIG_PCI) \ 945#if !(defined(CONFIG_PCI) \
921 || defined(CONFIG_SA1111) \ 946 || defined(CONFIG_SA1111) \
922 || defined(CONFIG_ARCH_S3C2410) \ 947 || defined(CONFIG_ARCH_S3C2410) \
@@ -928,6 +953,7 @@ MODULE_LICENSE ("GPL");
928 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \ 953 || defined (CONFIG_USB_OHCI_HCD_PPC_SOC) \
929 || defined (CONFIG_ARCH_AT91RM9200) \ 954 || defined (CONFIG_ARCH_AT91RM9200) \
930 || defined (CONFIG_ARCH_AT91SAM9261) \ 955 || defined (CONFIG_ARCH_AT91SAM9261) \
956 || defined (CONFIG_ARCH_PNX4008) \
931 ) 957 )
932#error "missing bus glue for ohci-hcd" 958#error "missing bus glue for ohci-hcd"
933#endif 959#endif
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 5b0a23fd798b..0b899339cac8 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -36,6 +36,14 @@
36 36
37/*-------------------------------------------------------------------------*/ 37/*-------------------------------------------------------------------------*/
38 38
39/* hcd->hub_irq_enable() */
40static void ohci_rhsc_enable (struct usb_hcd *hcd)
41{
42 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
43
44 ohci_writel (ohci, OHCI_INTR_RHSC, &ohci->regs->intrenable);
45}
46
39#ifdef CONFIG_PM 47#ifdef CONFIG_PM
40 48
41#define OHCI_SCHED_ENABLES \ 49#define OHCI_SCHED_ENABLES \
@@ -123,10 +131,10 @@ static int ohci_bus_suspend (struct usb_hcd *hcd)
123 /* no resumes until devices finish suspending */ 131 /* no resumes until devices finish suspending */
124 ohci->next_statechange = jiffies + msecs_to_jiffies (5); 132 ohci->next_statechange = jiffies + msecs_to_jiffies (5);
125 133
134 /* no timer polling */
135 hcd->poll_rh = 0;
136
126done: 137done:
127 /* external suspend vs self autosuspend ... same effect */
128 if (status == 0)
129 usb_hcd_suspend_root_hub(hcd);
130 spin_unlock_irqrestore (&ohci->lock, flags); 138 spin_unlock_irqrestore (&ohci->lock, flags);
131 return status; 139 return status;
132} 140}
@@ -256,8 +264,8 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
256 /* TRSMRCY */ 264 /* TRSMRCY */
257 msleep (10); 265 msleep (10);
258 266
259 /* keep it alive for ~5x suspend + resume costs */ 267 /* keep it alive for more than ~5x suspend + resume costs */
260 ohci->next_statechange = jiffies + msecs_to_jiffies (250); 268 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
261 269
262 /* maybe turn schedules back on */ 270 /* maybe turn schedules back on */
263 enables = 0; 271 enables = 0;
@@ -302,9 +310,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
302{ 310{
303 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 311 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
304 int i, changed = 0, length = 1; 312 int i, changed = 0, length = 1;
305 int can_suspend = device_may_wakeup(&hcd->self.root_hub->dev); 313 int can_suspend;
306 unsigned long flags; 314 unsigned long flags;
307 315
316 can_suspend = device_may_wakeup(&hcd->self.root_hub->dev);
308 spin_lock_irqsave (&ohci->lock, flags); 317 spin_lock_irqsave (&ohci->lock, flags);
309 318
310 /* handle autosuspended root: finish resuming before 319 /* handle autosuspended root: finish resuming before
@@ -339,6 +348,10 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
339 for (i = 0; i < ohci->num_ports; i++) { 348 for (i = 0; i < ohci->num_ports; i++) {
340 u32 status = roothub_portstatus (ohci, i); 349 u32 status = roothub_portstatus (ohci, i);
341 350
351 /* can't autosuspend with active ports */
352 if ((status & RH_PS_PES) && !(status & RH_PS_PSS))
353 can_suspend = 0;
354
342 if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC 355 if (status & (RH_PS_CSC | RH_PS_PESC | RH_PS_PSSC
343 | RH_PS_OCIC | RH_PS_PRSC)) { 356 | RH_PS_OCIC | RH_PS_PRSC)) {
344 changed = 1; 357 changed = 1;
@@ -348,32 +361,41 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
348 buf [1] |= 1 << (i - 7); 361 buf [1] |= 1 << (i - 7);
349 continue; 362 continue;
350 } 363 }
364 }
351 365
352 /* can suspend if no ports are enabled; or if all all 366 /* after root hub changes, stop polling after debouncing
353 * enabled ports are suspended AND remote wakeup is on. 367 * for a while and maybe kicking in autosuspend
354 */ 368 */
355 if (!(status & RH_PS_CCS)) 369 if (changed) {
356 continue; 370 ohci->next_statechange = jiffies + STATECHANGE_DELAY;
357 if ((status & RH_PS_PSS) && can_suspend)
358 continue;
359 can_suspend = 0; 371 can_suspend = 0;
372 } else if (time_before (jiffies, ohci->next_statechange)) {
373 can_suspend = 0;
374 } else {
375#ifdef CONFIG_PM
376 can_suspend = can_suspend
377 && !ohci->ed_rm_list
378 && ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)
379 & ohci->hc_control)
380 == OHCI_USB_OPER;
381#endif
382 if (hcd->uses_new_polling) {
383 hcd->poll_rh = 0;
384 /* use INTR_RHSC iff INTR_RD won't apply */
385 if (!can_suspend)
386 ohci_writel (ohci, OHCI_INTR_RHSC,
387 &ohci->regs->intrenable);
388 }
360 } 389 }
390
361done: 391done:
362 spin_unlock_irqrestore (&ohci->lock, flags); 392 spin_unlock_irqrestore (&ohci->lock, flags);
363 393
364#ifdef CONFIG_PM 394#ifdef CONFIG_PM
365 /* save power by suspending idle root hubs; 395 /* save power by autosuspending idle root hubs;
366 * INTR_RD wakes us when there's work 396 * INTR_RD wakes us when there's work
367 */ 397 */
368 if (can_suspend 398 if (can_suspend && usb_trylock_device (hcd->self.root_hub) == 0) {
369 && !changed
370 && !ohci->ed_rm_list
371 && ((OHCI_CTRL_HCFS | OHCI_SCHED_ENABLES)
372 & ohci->hc_control)
373 == OHCI_USB_OPER
374 && time_after (jiffies, ohci->next_statechange)
375 && usb_trylock_device (hcd->self.root_hub) == 0
376 ) {
377 ohci_vdbg (ohci, "autosuspend\n"); 399 ohci_vdbg (ohci, "autosuspend\n");
378 (void) ohci_bus_suspend (hcd); 400 (void) ohci_bus_suspend (hcd);
379 usb_unlock_device (hcd->self.root_hub); 401 usb_unlock_device (hcd->self.root_hub);
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 5602da9bd52c..e121d97ed91c 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -173,11 +173,8 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
173 * basic lifecycle operations 173 * basic lifecycle operations
174 */ 174 */
175 .start = ohci_lh7a404_start, 175 .start = ohci_lh7a404_start,
176#ifdef CONFIG_PM
177 /* suspend: ohci_lh7a404_suspend, -- tbd */
178 /* resume: ohci_lh7a404_resume, -- tbd */
179#endif /*CONFIG_PM*/
180 .stop = ohci_stop, 176 .stop = ohci_stop,
177 .shutdown = ohci_shutdown,
181 178
182 /* 179 /*
183 * managing i/o requests and associated device resources 180 * managing i/o requests and associated device resources
@@ -196,6 +193,7 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
196 */ 193 */
197 .hub_status_data = ohci_hub_status_data, 194 .hub_status_data = ohci_hub_status_data,
198 .hub_control = ohci_hub_control, 195 .hub_control = ohci_hub_control,
196 .hub_irq_enable = ohci_rhsc_enable,
199#ifdef CONFIG_PM 197#ifdef CONFIG_PM
200 .bus_suspend = ohci_bus_suspend, 198 .bus_suspend = ohci_bus_suspend,
201 .bus_resume = ohci_bus_resume, 199 .bus_resume = ohci_bus_resume,
@@ -244,6 +242,7 @@ static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev)
244static struct platform_driver ohci_hcd_lh7a404_driver = { 242static struct platform_driver ohci_hcd_lh7a404_driver = {
245 .probe = ohci_hcd_lh7a404_drv_probe, 243 .probe = ohci_hcd_lh7a404_drv_probe,
246 .remove = ohci_hcd_lh7a404_drv_remove, 244 .remove = ohci_hcd_lh7a404_drv_remove,
245 .shutdown = usb_hcd_platform_shutdown,
247 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ 246 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
248 /*.resume = ohci_hcd_lh7a404_drv_resume, */ 247 /*.resume = ohci_hcd_lh7a404_drv_resume, */
249 .driver = { 248 .driver = {
diff --git a/drivers/usb/host/ohci-mem.c b/drivers/usb/host/ohci-mem.c
index bfbe328a4788..d976614eebd3 100644
--- a/drivers/usb/host/ohci-mem.c
+++ b/drivers/usb/host/ohci-mem.c
@@ -28,7 +28,6 @@ static void ohci_hcd_init (struct ohci_hcd *ohci)
28 ohci->next_statechange = jiffies; 28 ohci->next_statechange = jiffies;
29 spin_lock_init (&ohci->lock); 29 spin_lock_init (&ohci->lock);
30 INIT_LIST_HEAD (&ohci->pending); 30 INIT_LIST_HEAD (&ohci->pending);
31 ohci->reboot_notifier.notifier_call = ohci_reboot;
32} 31}
33 32
34/*-------------------------------------------------------------------------*/ 33/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index c4c4babd4767..9c02177de50a 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -4,7 +4,7 @@
4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at> 4 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
5 * (C) Copyright 2000-2005 David Brownell 5 * (C) Copyright 2000-2005 David Brownell
6 * (C) Copyright 2002 Hewlett-Packard Company 6 * (C) Copyright 2002 Hewlett-Packard Company
7 * 7 *
8 * OMAP Bus Glue 8 * OMAP Bus Glue
9 * 9 *
10 * Modified for OMAP by Tony Lindgren <tony@atomide.com> 10 * Modified for OMAP by Tony Lindgren <tony@atomide.com>
@@ -66,15 +66,20 @@ extern int usb_disabled(void);
66extern int ocpi_enable(void); 66extern int ocpi_enable(void);
67 67
68static struct clk *usb_host_ck; 68static struct clk *usb_host_ck;
69static struct clk *usb_dc_ck;
70static int host_enabled;
71static int host_initialized;
69 72
70static void omap_ohci_clock_power(int on) 73static void omap_ohci_clock_power(int on)
71{ 74{
72 if (on) { 75 if (on) {
76 clk_enable(usb_dc_ck);
73 clk_enable(usb_host_ck); 77 clk_enable(usb_host_ck);
74 /* guesstimate for T5 == 1x 32K clock + APLL lock time */ 78 /* guesstimate for T5 == 1x 32K clock + APLL lock time */
75 udelay(100); 79 udelay(100);
76 } else { 80 } else {
77 clk_disable(usb_host_ck); 81 clk_disable(usb_host_ck);
82 clk_disable(usb_dc_ck);
78 } 83 }
79} 84}
80 85
@@ -87,14 +92,14 @@ static int omap_ohci_transceiver_power(int on)
87 if (on) { 92 if (on) {
88 if (machine_is_omap_innovator() && cpu_is_omap1510()) 93 if (machine_is_omap_innovator() && cpu_is_omap1510())
89 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) 94 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL)
90 | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 95 | ((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
91 INNOVATOR_FPGA_CAM_USB_CONTROL); 96 INNOVATOR_FPGA_CAM_USB_CONTROL);
92 else if (machine_is_omap_osk()) 97 else if (machine_is_omap_osk())
93 tps65010_set_gpio_out_value(GPIO1, LOW); 98 tps65010_set_gpio_out_value(GPIO1, LOW);
94 } else { 99 } else {
95 if (machine_is_omap_innovator() && cpu_is_omap1510()) 100 if (machine_is_omap_innovator() && cpu_is_omap1510())
96 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL) 101 fpga_write(fpga_read(INNOVATOR_FPGA_CAM_USB_CONTROL)
97 & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)), 102 & ~((1 << 5/*usb1*/) | (1 << 3/*usb2*/)),
98 INNOVATOR_FPGA_CAM_USB_CONTROL); 103 INNOVATOR_FPGA_CAM_USB_CONTROL);
99 else if (machine_is_omap_osk()) 104 else if (machine_is_omap_osk())
100 tps65010_set_gpio_out_value(GPIO1, HIGH); 105 tps65010_set_gpio_out_value(GPIO1, HIGH);
@@ -103,6 +108,7 @@ static int omap_ohci_transceiver_power(int on)
103 return 0; 108 return 0;
104} 109}
105 110
111#ifdef CONFIG_ARCH_OMAP15XX
106/* 112/*
107 * OMAP-1510 specific Local Bus clock on/off 113 * OMAP-1510 specific Local Bus clock on/off
108 */ 114 */
@@ -121,8 +127,8 @@ static int omap_1510_local_bus_power(int on)
121/* 127/*
122 * OMAP-1510 specific Local Bus initialization 128 * OMAP-1510 specific Local Bus initialization
123 * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE. 129 * NOTE: This assumes 32MB memory size in OMAP1510LB_MEMSIZE.
124 * See also arch/mach-omap/memory.h for __virt_to_dma() and 130 * See also arch/mach-omap/memory.h for __virt_to_dma() and
125 * __dma_to_virt() which need to match with the physical 131 * __dma_to_virt() which need to match with the physical
126 * Local Bus address below. 132 * Local Bus address below.
127 */ 133 */
128static int omap_1510_local_bus_init(void) 134static int omap_1510_local_bus_init(void)
@@ -130,7 +136,7 @@ static int omap_1510_local_bus_init(void)
130 unsigned int tlb; 136 unsigned int tlb;
131 unsigned long lbaddr, physaddr; 137 unsigned long lbaddr, physaddr;
132 138
133 omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4, 139 omap_writel((omap_readl(OMAP1510_LB_CLOCK_DIV) & 0xfffffff8) | 0x4,
134 OMAP1510_LB_CLOCK_DIV); 140 OMAP1510_LB_CLOCK_DIV);
135 141
136 /* Configure the Local Bus MMU table */ 142 /* Configure the Local Bus MMU table */
@@ -138,7 +144,7 @@ static int omap_1510_local_bus_init(void)
138 lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET; 144 lbaddr = tlb * 0x00100000 + OMAP1510_LB_OFFSET;
139 physaddr = tlb * 0x00100000 + PHYS_OFFSET; 145 physaddr = tlb * 0x00100000 + PHYS_OFFSET;
140 omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H); 146 omap_writel((lbaddr & 0x0fffffff) >> 22, OMAP1510_LB_MMU_CAM_H);
141 omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc, 147 omap_writel(((lbaddr & 0x003ffc00) >> 6) | 0xc,
142 OMAP1510_LB_MMU_CAM_L); 148 OMAP1510_LB_MMU_CAM_L);
143 omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H); 149 omap_writel(physaddr >> 16, OMAP1510_LB_MMU_RAM_H);
144 omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L); 150 omap_writel((physaddr & 0x0000fc00) | 0x300, OMAP1510_LB_MMU_RAM_L);
@@ -152,6 +158,10 @@ static int omap_1510_local_bus_init(void)
152 158
153 return 0; 159 return 0;
154} 160}
161#else
162#define omap_1510_local_bus_power(x) {}
163#define omap_1510_local_bus_init() {}
164#endif
155 165
156#ifdef CONFIG_USB_OTG 166#ifdef CONFIG_USB_OTG
157 167
@@ -173,13 +183,14 @@ static void start_hnp(struct ohci_hcd *ohci)
173 183
174/*-------------------------------------------------------------------------*/ 184/*-------------------------------------------------------------------------*/
175 185
176static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) 186static int ohci_omap_init(struct usb_hcd *hcd)
177{ 187{
178 struct omap_usb_config *config = pdev->dev.platform_data; 188 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
189 struct omap_usb_config *config = hcd->self.controller->platform_data;
179 int need_transceiver = (config->otg != 0); 190 int need_transceiver = (config->otg != 0);
180 int ret; 191 int ret;
181 192
182 dev_dbg(&pdev->dev, "starting USB Controller\n"); 193 dev_dbg(hcd->self.controller, "starting USB Controller\n");
183 194
184 if (config->otg) { 195 if (config->otg) {
185 ohci_to_hcd(ohci)->self.otg_port = config->otg; 196 ohci_to_hcd(ohci)->self.otg_port = config->otg;
@@ -200,7 +211,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
200 if (ohci->transceiver) { 211 if (ohci->transceiver) {
201 int status = otg_set_host(ohci->transceiver, 212 int status = otg_set_host(ohci->transceiver,
202 &ohci_to_hcd(ohci)->self); 213 &ohci_to_hcd(ohci)->self);
203 dev_dbg(&pdev->dev, "init %s transceiver, status %d\n", 214 dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n",
204 ohci->transceiver->label, status); 215 ohci->transceiver->label, status);
205 if (status) { 216 if (status) {
206 if (ohci->transceiver) 217 if (ohci->transceiver)
@@ -208,7 +219,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
208 return status; 219 return status;
209 } 220 }
210 } else { 221 } else {
211 dev_err(&pdev->dev, "can't find transceiver\n"); 222 dev_err(hcd->self.controller, "can't find transceiver\n");
212 return -ENODEV; 223 return -ENODEV;
213 } 224 }
214 } 225 }
@@ -247,6 +258,10 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
247 } 258 }
248 ohci_writel(ohci, rh, &ohci->regs->roothub.a); 259 ohci_writel(ohci, rh, &ohci->regs->roothub.a);
249 distrust_firmware = 0; 260 distrust_firmware = 0;
261 } else if (machine_is_nokia770()) {
262 /* We require a self-powered hub, which should have
263 * plenty of power. */
264 ohci_to_hcd(ohci)->power_budget = 0;
250 } 265 }
251 266
252 /* FIXME khubd hub requests should manage power switching */ 267 /* FIXME khubd hub requests should manage power switching */
@@ -260,21 +275,15 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
260 return 0; 275 return 0;
261} 276}
262 277
263static void omap_stop_hc(struct platform_device *pdev) 278static void ohci_omap_stop(struct usb_hcd *hcd)
264{ 279{
265 dev_dbg(&pdev->dev, "stopping USB Controller\n"); 280 dev_dbg(hcd->self.controller, "stopping USB Controller\n");
266 omap_ohci_clock_power(0); 281 omap_ohci_clock_power(0);
267} 282}
268 283
269 284
270/*-------------------------------------------------------------------------*/ 285/*-------------------------------------------------------------------------*/
271 286
272void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);
273
274/* configure so an HC device and id are always provided */
275/* always called with process context; sleeping is OK */
276
277
278/** 287/**
279 * usb_hcd_omap_probe - initialize OMAP-based HCDs 288 * usb_hcd_omap_probe - initialize OMAP-based HCDs
280 * Context: !in_interrupt() 289 * Context: !in_interrupt()
@@ -283,7 +292,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);
283 * then invokes the start() method for the HCD associated with it 292 * then invokes the start() method for the HCD associated with it
284 * through the hotplug entry's driver_data. 293 * through the hotplug entry's driver_data.
285 */ 294 */
286int usb_hcd_omap_probe (const struct hc_driver *driver, 295static int usb_hcd_omap_probe (const struct hc_driver *driver,
287 struct platform_device *pdev) 296 struct platform_device *pdev)
288{ 297{
289 int retval, irq; 298 int retval, irq;
@@ -291,12 +300,12 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
291 struct ohci_hcd *ohci; 300 struct ohci_hcd *ohci;
292 301
293 if (pdev->num_resources != 2) { 302 if (pdev->num_resources != 2) {
294 printk(KERN_ERR "hcd probe: invalid num_resources: %i\n", 303 printk(KERN_ERR "hcd probe: invalid num_resources: %i\n",
295 pdev->num_resources); 304 pdev->num_resources);
296 return -ENODEV; 305 return -ENODEV;
297 } 306 }
298 307
299 if (pdev->resource[0].flags != IORESOURCE_MEM 308 if (pdev->resource[0].flags != IORESOURCE_MEM
300 || pdev->resource[1].flags != IORESOURCE_IRQ) { 309 || pdev->resource[1].flags != IORESOURCE_IRQ) {
301 printk(KERN_ERR "hcd probe: invalid resource type\n"); 310 printk(KERN_ERR "hcd probe: invalid resource type\n");
302 return -ENODEV; 311 return -ENODEV;
@@ -306,6 +315,17 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
306 if (IS_ERR(usb_host_ck)) 315 if (IS_ERR(usb_host_ck))
307 return PTR_ERR(usb_host_ck); 316 return PTR_ERR(usb_host_ck);
308 317
318 if (!cpu_is_omap1510())
319 usb_dc_ck = clk_get(0, "usb_dc_ck");
320 else
321 usb_dc_ck = clk_get(0, "lb_ck");
322
323 if (IS_ERR(usb_dc_ck)) {
324 clk_put(usb_host_ck);
325 return PTR_ERR(usb_dc_ck);
326 }
327
328
309 hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id); 329 hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id);
310 if (!hcd) { 330 if (!hcd) {
311 retval = -ENOMEM; 331 retval = -ENOMEM;
@@ -325,9 +345,8 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
325 ohci = hcd_to_ohci(hcd); 345 ohci = hcd_to_ohci(hcd);
326 ohci_hcd_init(ohci); 346 ohci_hcd_init(ohci);
327 347
328 retval = omap_start_hc(ohci, pdev); 348 host_initialized = 0;
329 if (retval < 0) 349 host_enabled = 1;
330 goto err2;
331 350
332 irq = platform_get_irq(pdev, 0); 351 irq = platform_get_irq(pdev, 0);
333 if (irq < 0) { 352 if (irq < 0) {
@@ -335,15 +354,21 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
335 goto err2; 354 goto err2;
336 } 355 }
337 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); 356 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
338 if (retval == 0) 357 if (retval)
339 return retval; 358 goto err2;
359
360 host_initialized = 1;
361
362 if (!host_enabled)
363 omap_ohci_clock_power(0);
340 364
341 omap_stop_hc(pdev); 365 return 0;
342err2: 366err2:
343 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 367 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
344err1: 368err1:
345 usb_put_hcd(hcd); 369 usb_put_hcd(hcd);
346err0: 370err0:
371 clk_put(usb_dc_ck);
347 clk_put(usb_host_ck); 372 clk_put(usb_host_ck);
348 return retval; 373 return retval;
349} 374}
@@ -359,31 +384,41 @@ err0:
359 * Reverses the effect of usb_hcd_omap_probe(), first invoking 384 * Reverses the effect of usb_hcd_omap_probe(), first invoking
360 * the HCD's stop() method. It is always called from a thread 385 * the HCD's stop() method. It is always called from a thread
361 * context, normally "rmmod", "apmd", or something similar. 386 * context, normally "rmmod", "apmd", or something similar.
362 *
363 */ 387 */
364void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) 388static inline void
389usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
365{ 390{
391 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
392
366 usb_remove_hcd(hcd); 393 usb_remove_hcd(hcd);
394 if (ohci->transceiver) {
395 (void) otg_set_host(ohci->transceiver, 0);
396 put_device(ohci->transceiver->dev);
397 }
367 if (machine_is_omap_osk()) 398 if (machine_is_omap_osk())
368 omap_free_gpio(9); 399 omap_free_gpio(9);
369 omap_stop_hc(pdev);
370 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 400 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
371 usb_put_hcd(hcd); 401 usb_put_hcd(hcd);
402 clk_put(usb_dc_ck);
372 clk_put(usb_host_ck); 403 clk_put(usb_host_ck);
373} 404}
374 405
375/*-------------------------------------------------------------------------*/ 406/*-------------------------------------------------------------------------*/
376 407
377static int __devinit 408static int
378ohci_omap_start (struct usb_hcd *hcd) 409ohci_omap_start (struct usb_hcd *hcd)
379{ 410{
380 struct omap_usb_config *config; 411 struct omap_usb_config *config;
381 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 412 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
382 int ret; 413 int ret;
383 414
415 if (!host_enabled)
416 return 0;
384 config = hcd->self.controller->platform_data; 417 config = hcd->self.controller->platform_data;
385 if (config->otg || config->rwc) 418 if (config->otg || config->rwc) {
419 ohci->hc_control = OHCI_CTRL_RWC;
386 writel(OHCI_CTRL_RWC, &ohci->regs->control); 420 writel(OHCI_CTRL_RWC, &ohci->regs->control);
421 }
387 422
388 if ((ret = ohci_run (ohci)) < 0) { 423 if ((ret = ohci_run (ohci)) < 0) {
389 dev_err(hcd->self.controller, "can't start\n"); 424 dev_err(hcd->self.controller, "can't start\n");
@@ -409,8 +444,10 @@ static const struct hc_driver ohci_omap_hc_driver = {
409 /* 444 /*
410 * basic lifecycle operations 445 * basic lifecycle operations
411 */ 446 */
447 .reset = ohci_omap_init,
412 .start = ohci_omap_start, 448 .start = ohci_omap_start,
413 .stop = ohci_stop, 449 .stop = ohci_omap_stop,
450 .shutdown = ohci_shutdown,
414 451
415 /* 452 /*
416 * managing i/o requests and associated device resources 453 * managing i/o requests and associated device resources
@@ -429,6 +466,7 @@ static const struct hc_driver ohci_omap_hc_driver = {
429 */ 466 */
430 .hub_status_data = ohci_hub_status_data, 467 .hub_status_data = ohci_hub_status_data,
431 .hub_control = ohci_hub_control, 468 .hub_control = ohci_hub_control,
469 .hub_irq_enable = ohci_rhsc_enable,
432#ifdef CONFIG_PM 470#ifdef CONFIG_PM
433 .bus_suspend = ohci_bus_suspend, 471 .bus_suspend = ohci_bus_suspend,
434 .bus_resume = ohci_bus_resume, 472 .bus_resume = ohci_bus_resume,
@@ -446,13 +484,8 @@ static int ohci_hcd_omap_drv_probe(struct platform_device *dev)
446static int ohci_hcd_omap_drv_remove(struct platform_device *dev) 484static int ohci_hcd_omap_drv_remove(struct platform_device *dev)
447{ 485{
448 struct usb_hcd *hcd = platform_get_drvdata(dev); 486 struct usb_hcd *hcd = platform_get_drvdata(dev);
449 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
450 487
451 usb_hcd_omap_remove(hcd, dev); 488 usb_hcd_omap_remove(hcd, dev);
452 if (ohci->transceiver) {
453 (void) otg_set_host(ohci->transceiver, 0);
454 put_device(ohci->transceiver->dev);
455 }
456 platform_set_drvdata(dev, NULL); 489 platform_set_drvdata(dev, NULL);
457 490
458 return 0; 491 return 0;
@@ -472,7 +505,7 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)
472 505
473 omap_ohci_clock_power(0); 506 omap_ohci_clock_power(0);
474 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; 507 ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
475 dev->power.power_state = PMSG_SUSPEND; 508 dev->dev.power.power_state = PMSG_SUSPEND;
476 return 0; 509 return 0;
477} 510}
478 511
@@ -485,8 +518,8 @@ static int ohci_omap_resume(struct platform_device *dev)
485 ohci->next_statechange = jiffies; 518 ohci->next_statechange = jiffies;
486 519
487 omap_ohci_clock_power(1); 520 omap_ohci_clock_power(1);
488 dev->power.power_state = PMSG_ON; 521 dev->dev.power.power_state = PMSG_ON;
489 usb_hcd_resume_root_hub(dev_get_drvdata(dev)); 522 usb_hcd_resume_root_hub(platform_get_drvdata(dev));
490 return 0; 523 return 0;
491} 524}
492 525
@@ -500,6 +533,7 @@ static int ohci_omap_resume(struct platform_device *dev)
500static struct platform_driver ohci_hcd_omap_driver = { 533static struct platform_driver ohci_hcd_omap_driver = {
501 .probe = ohci_hcd_omap_drv_probe, 534 .probe = ohci_hcd_omap_drv_probe,
502 .remove = ohci_hcd_omap_drv_remove, 535 .remove = ohci_hcd_omap_drv_remove,
536 .shutdown = usb_hcd_platform_shutdown,
503#ifdef CONFIG_PM 537#ifdef CONFIG_PM
504 .suspend = ohci_omap_suspend, 538 .suspend = ohci_omap_suspend,
505 .resume = ohci_omap_resume, 539 .resume = ohci_omap_resume,
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index b268537e389e..3732db7d68eb 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -135,6 +135,11 @@ static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
135 } 135 }
136 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 136 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
137 (void)ohci_readl(ohci, &ohci->regs->intrdisable); 137 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
138
139 /* make sure snapshot being resumed re-enumerates everything */
140 if (message.event == PM_EVENT_PRETHAW)
141 ohci_usb_reset(ohci);
142
138 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 143 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
139 bail: 144 bail:
140 spin_unlock_irqrestore (&ohci->lock, flags); 145 spin_unlock_irqrestore (&ohci->lock, flags);
@@ -171,11 +176,14 @@ static const struct hc_driver ohci_pci_hc_driver = {
171 */ 176 */
172 .reset = ohci_pci_reset, 177 .reset = ohci_pci_reset,
173 .start = ohci_pci_start, 178 .start = ohci_pci_start,
179 .stop = ohci_stop,
180 .shutdown = ohci_shutdown,
181
174#ifdef CONFIG_PM 182#ifdef CONFIG_PM
183 /* these suspend/resume entries are for upstream PCI glue ONLY */
175 .suspend = ohci_pci_suspend, 184 .suspend = ohci_pci_suspend,
176 .resume = ohci_pci_resume, 185 .resume = ohci_pci_resume,
177#endif 186#endif
178 .stop = ohci_stop,
179 187
180 /* 188 /*
181 * managing i/o requests and associated device resources 189 * managing i/o requests and associated device resources
@@ -194,6 +202,7 @@ static const struct hc_driver ohci_pci_hc_driver = {
194 */ 202 */
195 .hub_status_data = ohci_hub_status_data, 203 .hub_status_data = ohci_hub_status_data,
196 .hub_control = ohci_hub_control, 204 .hub_control = ohci_hub_control,
205 .hub_irq_enable = ohci_rhsc_enable,
197#ifdef CONFIG_PM 206#ifdef CONFIG_PM
198 .bus_suspend = ohci_bus_suspend, 207 .bus_suspend = ohci_bus_suspend,
199 .bus_resume = ohci_bus_resume, 208 .bus_resume = ohci_bus_resume,
@@ -224,6 +233,8 @@ static struct pci_driver ohci_pci_driver = {
224 .suspend = usb_hcd_pci_suspend, 233 .suspend = usb_hcd_pci_suspend,
225 .resume = usb_hcd_pci_resume, 234 .resume = usb_hcd_pci_resume,
226#endif 235#endif
236
237 .shutdown = usb_hcd_pci_shutdown,
227}; 238};
228 239
229 240
diff --git a/drivers/usb/host/ohci-pnx4008.c b/drivers/usb/host/ohci-pnx4008.c
new file mode 100644
index 000000000000..82cb22f002e7
--- /dev/null
+++ b/drivers/usb/host/ohci-pnx4008.c
@@ -0,0 +1,476 @@
1/*
2 * drivers/usb/host/ohci-pnx4008.c
3 *
4 * driver for Philips PNX4008 USB Host
5 *
6 * Authors: Dmitry Chigirev <source@mvista.com>
7 * Vitaly Wool <vitalywool@gmail.com>
8 *
9 * register initialization is based on code examples provided by Philips
10 * Copyright (c) 2005 Koninklijke Philips Electronics N.V.
11 *
12 * NOTE: This driver does not have suspend/resume functionality
13 * This driver is intended for engineering development purposes only
14 *
15 * 2005-2006 (c) MontaVista Software, Inc. This file is licensed under
16 * the terms of the GNU General Public License version 2. This program
17 * is licensed "as is" without any warranty of any kind, whether express
18 * or implied.
19 */
20#include <linux/clk.h>
21#include <linux/platform_device.h>
22#include <linux/i2c.h>
23
24#include <asm/hardware.h>
25#include <asm/io.h>
26#include <asm/mach-types.h>
27
28#include <asm/arch/platform.h>
29#include <asm/arch/irqs.h>
30#include <asm/arch/gpio.h>
31
32#define USB_CTRL IO_ADDRESS(PNX4008_PWRMAN_BASE + 0x64)
33
34/* USB_CTRL bit defines */
35#define USB_SLAVE_HCLK_EN (1 << 24)
36#define USB_HOST_NEED_CLK_EN (1 << 21)
37
38#define USB_OTG_CLK_CTRL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF4)
39#define USB_OTG_CLK_STAT IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0xFF8)
40
41/* USB_OTG_CLK_CTRL bit defines */
42#define AHB_M_CLOCK_ON (1 << 4)
43#define OTG_CLOCK_ON (1 << 3)
44#define I2C_CLOCK_ON (1 << 2)
45#define DEV_CLOCK_ON (1 << 1)
46#define HOST_CLOCK_ON (1 << 0)
47
48#define USB_OTG_STAT_CONTROL IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x110)
49
50/* USB_OTG_STAT_CONTROL bit defines */
51#define TRANSPARENT_I2C_EN (1 << 7)
52#define HOST_EN (1 << 0)
53
54/* ISP1301 USB transceiver I2C registers */
55#define ISP1301_MODE_CONTROL_1 0x04 /* u8 read, set, +1 clear */
56
57#define MC1_SPEED_REG (1 << 0)
58#define MC1_SUSPEND_REG (1 << 1)
59#define MC1_DAT_SE0 (1 << 2)
60#define MC1_TRANSPARENT (1 << 3)
61#define MC1_BDIS_ACON_EN (1 << 4)
62#define MC1_OE_INT_EN (1 << 5)
63#define MC1_UART_EN (1 << 6)
64#define MC1_MASK 0x7f
65
66#define ISP1301_MODE_CONTROL_2 0x12 /* u8 read, set, +1 clear */
67
68#define MC2_GLOBAL_PWR_DN (1 << 0)
69#define MC2_SPD_SUSP_CTRL (1 << 1)
70#define MC2_BI_DI (1 << 2)
71#define MC2_TRANSP_BDIR0 (1 << 3)
72#define MC2_TRANSP_BDIR1 (1 << 4)
73#define MC2_AUDIO_EN (1 << 5)
74#define MC2_PSW_EN (1 << 6)
75#define MC2_EN2V7 (1 << 7)
76
77#define ISP1301_OTG_CONTROL_1 0x06 /* u8 read, set, +1 clear */
78# define OTG1_DP_PULLUP (1 << 0)
79# define OTG1_DM_PULLUP (1 << 1)
80# define OTG1_DP_PULLDOWN (1 << 2)
81# define OTG1_DM_PULLDOWN (1 << 3)
82# define OTG1_ID_PULLDOWN (1 << 4)
83# define OTG1_VBUS_DRV (1 << 5)
84# define OTG1_VBUS_DISCHRG (1 << 6)
85# define OTG1_VBUS_CHRG (1 << 7)
86#define ISP1301_OTG_STATUS 0x10 /* u8 readonly */
87# define OTG_B_SESS_END (1 << 6)
88# define OTG_B_SESS_VLD (1 << 7)
89
90#define ISP1301_I2C_ADDR 0x2C
91
92#define ISP1301_I2C_MODE_CONTROL_1 0x4
93#define ISP1301_I2C_MODE_CONTROL_2 0x12
94#define ISP1301_I2C_OTG_CONTROL_1 0x6
95#define ISP1301_I2C_OTG_CONTROL_2 0x10
96#define ISP1301_I2C_INTERRUPT_SOURCE 0x8
97#define ISP1301_I2C_INTERRUPT_LATCH 0xA
98#define ISP1301_I2C_INTERRUPT_FALLING 0xC
99#define ISP1301_I2C_INTERRUPT_RISING 0xE
100#define ISP1301_I2C_REG_CLEAR_ADDR 1
101
102struct i2c_driver isp1301_driver;
103struct i2c_client *isp1301_i2c_client;
104
105extern int usb_disabled(void);
106extern int ocpi_enable(void);
107
108static struct clk *usb_clk;
109
110static int isp1301_probe(struct i2c_adapter *adap);
111static int isp1301_detach(struct i2c_client *client);
112static int isp1301_command(struct i2c_client *client, unsigned int cmd,
113 void *arg);
114
115static unsigned short normal_i2c[] =
116 { ISP1301_I2C_ADDR, ISP1301_I2C_ADDR + 1, I2C_CLIENT_END };
117static unsigned short dummy_i2c_addrlist[] = { I2C_CLIENT_END };
118
119static struct i2c_client_address_data addr_data = {
120 .normal_i2c = normal_i2c,
121 .probe = dummy_i2c_addrlist,
122 .ignore = dummy_i2c_addrlist,
123};
124
125struct i2c_driver isp1301_driver = {
126 .id = I2C_DRIVERID_I2CDEV, /* Fake Id */
127 .class = I2C_CLASS_HWMON,
128 .attach_adapter = isp1301_probe,
129 .detach_client = isp1301_detach,
130 .command = isp1301_command
131};
132
133static int isp1301_attach(struct i2c_adapter *adap, int addr, int kind)
134{
135 struct i2c_client *c;
136
137 c = (struct i2c_client *)kzalloc(sizeof(*c), SLAB_KERNEL);
138
139 if (!c)
140 return -ENOMEM;
141
142 strcpy(c->name, "isp1301");
143 c->flags = 0;
144 c->addr = addr;
145 c->adapter = adap;
146 c->driver = &isp1301_driver;
147
148 isp1301_i2c_client = c;
149
150 return i2c_attach_client(c);
151}
152
153static int isp1301_probe(struct i2c_adapter *adap)
154{
155 return i2c_probe(adap, &addr_data, isp1301_attach);
156}
157
158static int isp1301_detach(struct i2c_client *client)
159{
160 i2c_detach_client(client);
161 kfree(isp1301_i2c_client);
162 return 0;
163}
164
165/* No commands defined */
166static int isp1301_command(struct i2c_client *client, unsigned int cmd,
167 void *arg)
168{
169 return 0;
170}
171
172static void i2c_write(u8 buf, u8 subaddr)
173{
174 char tmpbuf[2];
175
176 tmpbuf[0] = subaddr; /*register number */
177 tmpbuf[1] = buf; /*register data */
178 i2c_master_send(isp1301_i2c_client, &tmpbuf[0], 2);
179}
180
181static void isp1301_configure(void)
182{
183 /* PNX4008 only supports DAT_SE0 USB mode */
184 /* PNX4008 R2A requires setting the MAX603 to output 3.6V */
185 /* Power up externel charge-pump */
186
187 i2c_write(MC1_DAT_SE0 | MC1_SPEED_REG, ISP1301_I2C_MODE_CONTROL_1);
188 i2c_write(~(MC1_DAT_SE0 | MC1_SPEED_REG),
189 ISP1301_I2C_MODE_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR);
190 i2c_write(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL,
191 ISP1301_I2C_MODE_CONTROL_2);
192 i2c_write(~(MC2_BI_DI | MC2_PSW_EN | MC2_SPD_SUSP_CTRL),
193 ISP1301_I2C_MODE_CONTROL_2 | ISP1301_I2C_REG_CLEAR_ADDR);
194 i2c_write(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN,
195 ISP1301_I2C_OTG_CONTROL_1);
196 i2c_write(~(OTG1_DM_PULLDOWN | OTG1_DP_PULLDOWN),
197 ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR);
198 i2c_write(0xFF,
199 ISP1301_I2C_INTERRUPT_LATCH | ISP1301_I2C_REG_CLEAR_ADDR);
200 i2c_write(0xFF,
201 ISP1301_I2C_INTERRUPT_FALLING | ISP1301_I2C_REG_CLEAR_ADDR);
202 i2c_write(0xFF,
203 ISP1301_I2C_INTERRUPT_RISING | ISP1301_I2C_REG_CLEAR_ADDR);
204
205}
206
207static inline void isp1301_vbus_on(void)
208{
209 i2c_write(OTG1_VBUS_DRV, ISP1301_I2C_OTG_CONTROL_1);
210}
211
212static inline void isp1301_vbus_off(void)
213{
214 i2c_write(OTG1_VBUS_DRV,
215 ISP1301_I2C_OTG_CONTROL_1 | ISP1301_I2C_REG_CLEAR_ADDR);
216}
217
218static void pnx4008_start_hc(void)
219{
220 unsigned long tmp = __raw_readl(USB_OTG_STAT_CONTROL) | HOST_EN;
221 __raw_writel(tmp, USB_OTG_STAT_CONTROL);
222 isp1301_vbus_on();
223}
224
225static void pnx4008_stop_hc(void)
226{
227 unsigned long tmp;
228 isp1301_vbus_off();
229 tmp = __raw_readl(USB_OTG_STAT_CONTROL) & ~HOST_EN;
230 __raw_writel(tmp, USB_OTG_STAT_CONTROL);
231}
232
233static int __devinit ohci_pnx4008_start(struct usb_hcd *hcd)
234{
235 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
236 int ret;
237
238 if ((ret = ohci_init(ohci)) < 0)
239 return ret;
240
241 if ((ret = ohci_run(ohci)) < 0) {
242 dev_err(hcd->self.controller, "can't start\n");
243 ohci_stop(hcd);
244 return ret;
245 }
246 return 0;
247}
248
249static const struct hc_driver ohci_pnx4008_hc_driver = {
250 .description = hcd_name,
251 .product_desc = "pnx4008 OHCI",
252
253 /*
254 * generic hardware linkage
255 */
256 .irq = ohci_irq,
257 .flags = HCD_USB11 | HCD_MEMORY,
258
259 .hcd_priv_size = sizeof(struct ohci_hcd),
260 /*
261 * basic lifecycle operations
262 */
263 .start = ohci_pnx4008_start,
264 .stop = ohci_stop,
265
266 /*
267 * managing i/o requests and associated device resources
268 */
269 .urb_enqueue = ohci_urb_enqueue,
270 .urb_dequeue = ohci_urb_dequeue,
271 .endpoint_disable = ohci_endpoint_disable,
272
273 /*
274 * scheduling support
275 */
276 .get_frame_number = ohci_get_frame,
277
278 /*
279 * root hub support
280 */
281 .hub_status_data = ohci_hub_status_data,
282 .hub_control = ohci_hub_control,
283
284 .start_port_reset = ohci_start_port_reset,
285};
286
287#define USB_CLOCK_MASK (AHB_M_CLOCK_ON| OTG_CLOCK_ON | HOST_CLOCK_ON | I2C_CLOCK_ON)
288
289static void pnx4008_set_usb_bits(void)
290{
291 start_int_set_falling_edge(SE_USB_OTG_ATX_INT_N);
292 start_int_ack(SE_USB_OTG_ATX_INT_N);
293 start_int_umask(SE_USB_OTG_ATX_INT_N);
294
295 start_int_set_rising_edge(SE_USB_OTG_TIMER_INT);
296 start_int_ack(SE_USB_OTG_TIMER_INT);
297 start_int_umask(SE_USB_OTG_TIMER_INT);
298
299 start_int_set_rising_edge(SE_USB_I2C_INT);
300 start_int_ack(SE_USB_I2C_INT);
301 start_int_umask(SE_USB_I2C_INT);
302
303 start_int_set_rising_edge(SE_USB_INT);
304 start_int_ack(SE_USB_INT);
305 start_int_umask(SE_USB_INT);
306
307 start_int_set_rising_edge(SE_USB_NEED_CLK_INT);
308 start_int_ack(SE_USB_NEED_CLK_INT);
309 start_int_umask(SE_USB_NEED_CLK_INT);
310
311 start_int_set_rising_edge(SE_USB_AHB_NEED_CLK_INT);
312 start_int_ack(SE_USB_AHB_NEED_CLK_INT);
313 start_int_umask(SE_USB_AHB_NEED_CLK_INT);
314}
315
316static void pnx4008_unset_usb_bits(void)
317{
318 start_int_mask(SE_USB_OTG_ATX_INT_N);
319 start_int_mask(SE_USB_OTG_TIMER_INT);
320 start_int_mask(SE_USB_I2C_INT);
321 start_int_mask(SE_USB_INT);
322 start_int_mask(SE_USB_NEED_CLK_INT);
323 start_int_mask(SE_USB_AHB_NEED_CLK_INT);
324}
325
326static int __devinit usb_hcd_pnx4008_probe(struct platform_device *pdev)
327{
328 struct usb_hcd *hcd = 0;
329 struct ohci_hcd *ohci;
330 const struct hc_driver *driver = &ohci_pnx4008_hc_driver;
331
332 int ret = 0, irq;
333
334 dev_dbg(&pdev->dev, "%s: " DRIVER_INFO " (pnx4008)\n", hcd_name);
335 if (usb_disabled()) {
336 err("USB is disabled");
337 ret = -ENODEV;
338 goto out;
339 }
340
341 if (pdev->num_resources != 2
342 || pdev->resource[0].flags != IORESOURCE_MEM
343 || pdev->resource[1].flags != IORESOURCE_IRQ) {
344 err("Invalid resource configuration");
345 ret = -ENODEV;
346 goto out;
347 }
348
349 /* Enable AHB slave USB clock, needed for further USB clock control */
350 __raw_writel(USB_SLAVE_HCLK_EN | (1 << 19), USB_CTRL);
351
352 ret = i2c_add_driver(&isp1301_driver);
353 if (ret < 0) {
354 err("failed to connect I2C to ISP1301 USB Transceiver");
355 goto out;
356 }
357
358 isp1301_configure();
359
360 /* Enable USB PLL */
361 usb_clk = clk_get(&pdev->dev, "ck_pll5");
362 if (IS_ERR(usb_clk)) {
363 err("failed to acquire USB PLL");
364 ret = PTR_ERR(usb_clk);
365 goto out1;
366 }
367
368 ret = clk_enable(usb_clk);
369 if (ret < 0) {
370 err("failed to start USB PLL");
371 goto out2;
372 }
373
374 ret = clk_set_rate(usb_clk, 48000);
375 if (ret < 0) {
376 err("failed to set USB clock rate");
377 goto out3;
378 }
379
380 __raw_writel(__raw_readl(USB_CTRL) | USB_HOST_NEED_CLK_EN, USB_CTRL);
381
382 /* Set to enable all needed USB clocks */
383 __raw_writel(USB_CLOCK_MASK, USB_OTG_CLK_CTRL);
384
385 while ((__raw_readl(USB_OTG_CLK_STAT) & USB_CLOCK_MASK) !=
386 USB_CLOCK_MASK) ;
387
388 hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id);
389 if (!hcd) {
390 err("Failed to allocate HC buffer");
391 ret = -ENOMEM;
392 goto out3;
393 }
394
395 /* Set all USB bits in the Start Enable register */
396 pnx4008_set_usb_bits();
397
398 hcd->rsrc_start = pdev->resource[0].start;
399 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
400 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
401 dev_dbg(&pdev->dev, "request_mem_region failed\n");
402 ret = -ENOMEM;
403 goto out4;
404 }
405 hcd->regs = (void __iomem *)pdev->resource[0].start;
406
407 irq = platform_get_irq(pdev, 0);
408 if (irq < 0) {
409 ret = -ENXIO;
410 goto out4;
411 }
412
413 hcd->self.hcpriv = (void *)hcd;
414
415 pnx4008_start_hc();
416 platform_set_drvdata(pdev, hcd);
417 ohci = hcd_to_ohci(hcd);
418 ohci_hcd_init(ohci);
419
420 dev_info(&pdev->dev, "at 0x%p, irq %d\n", hcd->regs, hcd->irq);
421 ret = usb_add_hcd(hcd, irq, SA_INTERRUPT);
422 if (ret == 0)
423 return ret;
424
425 pnx4008_stop_hc();
426out4:
427 pnx4008_unset_usb_bits();
428 usb_put_hcd(hcd);
429out3:
430 clk_disable(usb_clk);
431out2:
432 clk_put(usb_clk);
433out1:
434 i2c_del_driver(&isp1301_driver);
435out:
436 return ret;
437}
438
439static int usb_hcd_pnx4008_remove(struct platform_device *pdev)
440{
441 struct usb_hcd *hcd = platform_get_drvdata(pdev);
442
443 usb_remove_hcd(hcd);
444 pnx4008_stop_hc();
445 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
446 usb_put_hcd(hcd);
447 pnx4008_unset_usb_bits();
448 clk_disable(usb_clk);
449 clk_put(usb_clk);
450 i2c_del_driver(&isp1301_driver);
451
452 platform_set_drvdata(pdev, NULL);
453
454 return 0;
455}
456
457static struct platform_driver usb_hcd_pnx4008_driver = {
458 .driver = {
459 .name = "usb-ohci",
460 },
461 .probe = usb_hcd_pnx4008_probe,
462 .remove = usb_hcd_pnx4008_remove,
463};
464
465static int __init usb_hcd_pnx4008_init(void)
466{
467 return platform_driver_register(&usb_hcd_pnx4008_driver);
468}
469
470static void __exit usb_hcd_pnx4008_cleanup(void)
471{
472 return platform_driver_unregister(&usb_hcd_pnx4008_driver);
473}
474
475module_init(usb_hcd_pnx4008_init);
476module_exit(usb_hcd_pnx4008_cleanup);
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index 9fe56ff1615d..d9d1ae236bd5 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -148,6 +148,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
148 */ 148 */
149 .start = ohci_ppc_soc_start, 149 .start = ohci_ppc_soc_start,
150 .stop = ohci_stop, 150 .stop = ohci_stop,
151 .shutdown = ohci_shutdown,
151 152
152 /* 153 /*
153 * managing i/o requests and associated device resources 154 * managing i/o requests and associated device resources
@@ -166,6 +167,7 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
166 */ 167 */
167 .hub_status_data = ohci_hub_status_data, 168 .hub_status_data = ohci_hub_status_data,
168 .hub_control = ohci_hub_control, 169 .hub_control = ohci_hub_control,
170 .hub_irq_enable = ohci_rhsc_enable,
169#ifdef CONFIG_PM 171#ifdef CONFIG_PM
170 .bus_suspend = ohci_bus_suspend, 172 .bus_suspend = ohci_bus_suspend,
171 .bus_resume = ohci_bus_resume, 173 .bus_resume = ohci_bus_resume,
@@ -195,6 +197,7 @@ static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
195static struct platform_driver ohci_hcd_ppc_soc_driver = { 197static struct platform_driver ohci_hcd_ppc_soc_driver = {
196 .probe = ohci_hcd_ppc_soc_drv_probe, 198 .probe = ohci_hcd_ppc_soc_drv_probe,
197 .remove = ohci_hcd_ppc_soc_drv_remove, 199 .remove = ohci_hcd_ppc_soc_drv_remove,
200 .shutdown = usb_hcd_platform_shutdown,
198#ifdef CONFIG_PM 201#ifdef CONFIG_PM
199 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ 202 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
200 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ 203 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 6f559e102789..e176b04d7aeb 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -270,6 +270,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
270 */ 270 */
271 .start = ohci_pxa27x_start, 271 .start = ohci_pxa27x_start,
272 .stop = ohci_stop, 272 .stop = ohci_stop,
273 .shutdown = ohci_shutdown,
273 274
274 /* 275 /*
275 * managing i/o requests and associated device resources 276 * managing i/o requests and associated device resources
@@ -288,6 +289,7 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
288 */ 289 */
289 .hub_status_data = ohci_hub_status_data, 290 .hub_status_data = ohci_hub_status_data,
290 .hub_control = ohci_hub_control, 291 .hub_control = ohci_hub_control,
292 .hub_irq_enable = ohci_rhsc_enable,
291#ifdef CONFIG_PM 293#ifdef CONFIG_PM
292 .bus_suspend = ohci_bus_suspend, 294 .bus_suspend = ohci_bus_suspend,
293 .bus_resume = ohci_bus_resume, 295 .bus_resume = ohci_bus_resume,
@@ -357,6 +359,7 @@ static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
357static struct platform_driver ohci_hcd_pxa27x_driver = { 359static struct platform_driver ohci_hcd_pxa27x_driver = {
358 .probe = ohci_hcd_pxa27x_drv_probe, 360 .probe = ohci_hcd_pxa27x_drv_probe,
359 .remove = ohci_hcd_pxa27x_drv_remove, 361 .remove = ohci_hcd_pxa27x_drv_remove,
362 .shutdown = usb_hcd_platform_shutdown,
360#ifdef CONFIG_PM 363#ifdef CONFIG_PM
361 .suspend = ohci_hcd_pxa27x_drv_suspend, 364 .suspend = ohci_hcd_pxa27x_drv_suspend,
362 .resume = ohci_hcd_pxa27x_drv_resume, 365 .resume = ohci_hcd_pxa27x_drv_resume,
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index d2fc6969a9f7..59e436424d41 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -370,7 +370,7 @@ static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
370 goto err_mem; 370 goto err_mem;
371 } 371 }
372 372
373 usb_clk = clk_get(&dev->dev, "upll"); 373 usb_clk = clk_get(&dev->dev, "usb-bus-host");
374 if (IS_ERR(usb_clk)) { 374 if (IS_ERR(usb_clk)) {
375 dev_err(&dev->dev, "cannot get usb-host clock\n"); 375 dev_err(&dev->dev, "cannot get usb-host clock\n");
376 retval = -ENOENT; 376 retval = -ENOENT;
@@ -447,6 +447,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
447 */ 447 */
448 .start = ohci_s3c2410_start, 448 .start = ohci_s3c2410_start,
449 .stop = ohci_stop, 449 .stop = ohci_stop,
450 .shutdown = ohci_shutdown,
450 451
451 /* 452 /*
452 * managing i/o requests and associated device resources 453 * managing i/o requests and associated device resources
@@ -465,6 +466,7 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
465 */ 466 */
466 .hub_status_data = ohci_s3c2410_hub_status_data, 467 .hub_status_data = ohci_s3c2410_hub_status_data,
467 .hub_control = ohci_s3c2410_hub_control, 468 .hub_control = ohci_s3c2410_hub_control,
469 .hub_irq_enable = ohci_rhsc_enable,
468#ifdef CONFIG_PM 470#ifdef CONFIG_PM
469 .bus_suspend = ohci_bus_suspend, 471 .bus_suspend = ohci_bus_suspend,
470 .bus_resume = ohci_bus_resume, 472 .bus_resume = ohci_bus_resume,
@@ -490,6 +492,7 @@ static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev)
490static struct platform_driver ohci_hcd_s3c2410_driver = { 492static struct platform_driver ohci_hcd_s3c2410_driver = {
491 .probe = ohci_hcd_s3c2410_drv_probe, 493 .probe = ohci_hcd_s3c2410_drv_probe,
492 .remove = ohci_hcd_s3c2410_drv_remove, 494 .remove = ohci_hcd_s3c2410_drv_remove,
495 .shutdown = usb_hcd_platform_shutdown,
493 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ 496 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */
494 /*.resume = ohci_hcd_s3c2410_drv_resume, */ 497 /*.resume = ohci_hcd_s3c2410_drv_resume, */
495 .driver = { 498 .driver = {
diff --git a/drivers/usb/host/ohci-sa1111.c b/drivers/usb/host/ohci-sa1111.c
index ce3de106cadc..71371de32ada 100644
--- a/drivers/usb/host/ohci-sa1111.c
+++ b/drivers/usb/host/ohci-sa1111.c
@@ -212,10 +212,6 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
212 * basic lifecycle operations 212 * basic lifecycle operations
213 */ 213 */
214 .start = ohci_sa1111_start, 214 .start = ohci_sa1111_start,
215#ifdef CONFIG_PM
216 /* suspend: ohci_sa1111_suspend, -- tbd */
217 /* resume: ohci_sa1111_resume, -- tbd */
218#endif
219 .stop = ohci_stop, 215 .stop = ohci_stop,
220 216
221 /* 217 /*
@@ -235,6 +231,7 @@ static const struct hc_driver ohci_sa1111_hc_driver = {
235 */ 231 */
236 .hub_status_data = ohci_hub_status_data, 232 .hub_status_data = ohci_hub_status_data,
237 .hub_control = ohci_hub_control, 233 .hub_control = ohci_hub_control,
234 .hub_irq_enable = ohci_rhsc_enable,
238#ifdef CONFIG_PM 235#ifdef CONFIG_PM
239 .bus_suspend = ohci_bus_suspend, 236 .bus_suspend = ohci_bus_suspend,
240 .bus_resume = ohci_bus_resume, 237 .bus_resume = ohci_bus_resume,
diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
index caacf14371f5..93fdc3c35341 100644
--- a/drivers/usb/host/ohci.h
+++ b/drivers/usb/host/ohci.h
@@ -159,7 +159,7 @@ static const int cc_to_error [16] = {
159 /* Bit Stuff */ -EPROTO, 159 /* Bit Stuff */ -EPROTO,
160 /* Data Togg */ -EILSEQ, 160 /* Data Togg */ -EILSEQ,
161 /* Stall */ -EPIPE, 161 /* Stall */ -EPIPE,
162 /* DevNotResp */ -ETIMEDOUT, 162 /* DevNotResp */ -ETIME,
163 /* PIDCheck */ -EPROTO, 163 /* PIDCheck */ -EPROTO,
164 /* UnExpPID */ -EPROTO, 164 /* UnExpPID */ -EPROTO,
165 /* DataOver */ -EOVERFLOW, 165 /* DataOver */ -EOVERFLOW,
@@ -389,8 +389,6 @@ struct ohci_hcd {
389 unsigned long next_statechange; /* suspend/resume */ 389 unsigned long next_statechange; /* suspend/resume */
390 u32 fminterval; /* saved register */ 390 u32 fminterval; /* saved register */
391 391
392 struct notifier_block reboot_notifier;
393
394 unsigned long flags; /* for HC bugs */ 392 unsigned long flags; /* for HC bugs */
395#define OHCI_QUIRK_AMD756 0x01 /* erratum #4 */ 393#define OHCI_QUIRK_AMD756 0x01 /* erratum #4 */
396#define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */ 394#define OHCI_QUIRK_SUPERIO 0x02 /* natsemi */
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index fa34092bbcde..3a586aab3939 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -597,7 +597,7 @@ done(struct sl811 *sl811, struct sl811h_ep *ep, u8 bank, struct pt_regs *regs)
597 /* error? retry, until "3 strikes" */ 597 /* error? retry, until "3 strikes" */
598 } else if (++ep->error_count >= 3) { 598 } else if (++ep->error_count >= 3) {
599 if (status & SL11H_STATMASK_TMOUT) 599 if (status & SL11H_STATMASK_TMOUT)
600 urbstat = -ETIMEDOUT; 600 urbstat = -ETIME;
601 else if (status & SL11H_STATMASK_OVF) 601 else if (status & SL11H_STATMASK_OVF)
602 urbstat = -EOVERFLOW; 602 urbstat = -EOVERFLOW;
603 else 603 else
@@ -1517,7 +1517,7 @@ static int proc_sl811h_open(struct inode *inode, struct file *file)
1517 return single_open(file, proc_sl811h_show, PDE(inode)->data); 1517 return single_open(file, proc_sl811h_show, PDE(inode)->data);
1518} 1518}
1519 1519
1520static struct file_operations proc_ops = { 1520static const struct file_operations proc_ops = {
1521 .open = proc_sl811h_open, 1521 .open = proc_sl811h_open,
1522 .read = seq_read, 1522 .read = seq_read,
1523 .llseek = seq_lseek, 1523 .llseek = seq_lseek,
@@ -1783,10 +1783,15 @@ sl811h_suspend(struct platform_device *dev, pm_message_t state)
1783 struct sl811 *sl811 = hcd_to_sl811(hcd); 1783 struct sl811 *sl811 = hcd_to_sl811(hcd);
1784 int retval = 0; 1784 int retval = 0;
1785 1785
1786 if (state.event == PM_EVENT_FREEZE) 1786 switch (state.event) {
1787 case PM_EVENT_FREEZE:
1787 retval = sl811h_bus_suspend(hcd); 1788 retval = sl811h_bus_suspend(hcd);
1788 else if (state.event == PM_EVENT_SUSPEND) 1789 break;
1790 case PM_EVENT_SUSPEND:
1791 case PM_EVENT_PRETHAW: /* explicitly discard hw state */
1789 port_power(sl811, 0); 1792 port_power(sl811, 0);
1793 break;
1794 }
1790 if (retval == 0) 1795 if (retval == 0)
1791 dev->dev.power.power_state = state; 1796 dev->dev.power.power_state = state;
1792 return retval; 1797 return retval;
diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
new file mode 100644
index 000000000000..cb2e2a604d1b
--- /dev/null
+++ b/drivers/usb/host/u132-hcd.c
@@ -0,0 +1,3295 @@
1/*
2* Host Controller Driver for the Elan Digital Systems U132 adapter
3*
4* Copyright(C) 2006 Elan Digital Systems Limited
5* http://www.elandigitalsystems.com
6*
7* Author and Maintainer - Tony Olech - Elan Digital Systems
8* tony.olech@elandigitalsystems.com
9*
10* This program is free software;you can redistribute it and/or
11* modify it under the terms of the GNU General Public License as
12* published by the Free Software Foundation, version 2.
13*
14*
15* This driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
16* based on various USB host drivers in the 2.6.15 linux kernel
17* with constant reference to the 3rd Edition of Linux Device Drivers
18* published by O'Reilly
19*
20* The U132 adapter is a USB to CardBus adapter specifically designed
21* for PC cards that contain an OHCI host controller. Typical PC cards
22* are the Orange Mobile 3G Option GlobeTrotter Fusion card.
23*
24* The U132 adapter will *NOT *work with PC cards that do not contain
25* an OHCI controller. A simple way to test whether a PC card has an
26* OHCI controller as an interface is to insert the PC card directly
27* into a laptop(or desktop) with a CardBus slot and if "lspci" shows
28* a new USB controller and "lsusb -v" shows a new OHCI Host Controller
29* then there is a good chance that the U132 adapter will support the
30* PC card.(you also need the specific client driver for the PC card)
31*
32* Please inform the Author and Maintainer about any PC cards that
33* contain OHCI Host Controller and work when directly connected to
34* an embedded CardBus slot but do not work when they are connected
35* via an ELAN U132 adapter.
36*
37*/
38#include <linux/config.h>
39#include <linux/kernel.h>
40#include <linux/module.h>
41#include <linux/moduleparam.h>
42#include <linux/delay.h>
43#include <linux/ioport.h>
44#include <linux/sched.h>
45#include <linux/slab.h>
46#include <linux/smp_lock.h>
47#include <linux/errno.h>
48#include <linux/init.h>
49#include <linux/timer.h>
50#include <linux/list.h>
51#include <linux/interrupt.h>
52#include <linux/usb.h>
53#include <linux/workqueue.h>
54#include <linux/platform_device.h>
55#include <linux/pci_ids.h>
56#include <asm/io.h>
57#include <asm/irq.h>
58#include <asm/system.h>
59#include <asm/byteorder.h>
60#include "../core/hcd.h"
61#include "ohci.h"
62#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
63#define OHCI_INTR_INIT (OHCI_INTR_MIE | OHCI_INTR_UE | OHCI_INTR_RD | \
64 OHCI_INTR_WDH)
65MODULE_AUTHOR("Tony Olech - Elan Digital Systems Limited");
66MODULE_DESCRIPTION("U132 USB Host Controller Driver");
67MODULE_LICENSE("GPL");
68#define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444)
69INT_MODULE_PARM(testing, 0);
70/* Some boards misreport power switching/overcurrent*/
71static int distrust_firmware = 1;
72module_param(distrust_firmware, bool, 0);
73MODULE_PARM_DESC(distrust_firmware, "true to distrust firmware power/overcurren"
74 "t setup");
75DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
76/*
77* u132_module_lock exists to protect access to global variables
78*
79*/
80static struct semaphore u132_module_lock;
81static int u132_exiting = 0;
82static int u132_instances = 0;
83static struct list_head u132_static_list;
84/*
85* end of the global variables protected by u132_module_lock
86*/
87static struct workqueue_struct *workqueue;
88#define MAX_U132_PORTS 7
89#define MAX_U132_ADDRS 128
90#define MAX_U132_UDEVS 4
91#define MAX_U132_ENDPS 100
92#define MAX_U132_RINGS 4
93static const char *cc_to_text[16] = {
94 "No Error ",
95 "CRC Error ",
96 "Bit Stuff ",
97 "Data Togg ",
98 "Stall ",
99 "DevNotResp ",
100 "PIDCheck ",
101 "UnExpPID ",
102 "DataOver ",
103 "DataUnder ",
104 "(for hw) ",
105 "(for hw) ",
106 "BufferOver ",
107 "BuffUnder ",
108 "(for HCD) ",
109 "(for HCD) "
110};
111struct u132_port {
112 struct u132 *u132;
113 int reset;
114 int enable;
115 int power;
116 int Status;
117};
118struct u132_addr {
119 u8 address;
120};
121struct u132_udev {
122 struct kref kref;
123 struct usb_device *usb_device;
124 u8 enumeration;
125 u8 udev_number;
126 u8 usb_addr;
127 u8 portnumber;
128 u8 endp_number_in[16];
129 u8 endp_number_out[16];
130};
131#define ENDP_QUEUE_SHIFT 3
132#define ENDP_QUEUE_SIZE (1<<ENDP_QUEUE_SHIFT)
133#define ENDP_QUEUE_MASK (ENDP_QUEUE_SIZE-1)
134struct u132_urbq {
135 struct list_head urb_more;
136 struct urb *urb;
137};
138struct u132_spin {
139 spinlock_t slock;
140};
141struct u132_endp {
142 struct kref kref;
143 u8 udev_number;
144 u8 endp_number;
145 u8 usb_addr;
146 u8 usb_endp;
147 struct u132 *u132;
148 struct list_head endp_ring;
149 struct u132_ring *ring;
150 unsigned toggle_bits:2;
151 unsigned active:1;
152 unsigned delayed:1;
153 unsigned input:1;
154 unsigned output:1;
155 unsigned pipetype:2;
156 unsigned dequeueing:1;
157 unsigned edset_flush:1;
158 unsigned spare_bits:14;
159 unsigned long jiffies;
160 struct usb_host_endpoint *hep;
161 struct u132_spin queue_lock;
162 u16 queue_size;
163 u16 queue_last;
164 u16 queue_next;
165 struct urb *urb_list[ENDP_QUEUE_SIZE];
166 struct list_head urb_more;
167 struct work_struct scheduler;
168};
169struct u132_ring {
170 unsigned in_use:1;
171 unsigned length:7;
172 u8 number;
173 struct u132 *u132;
174 struct u132_endp *curr_endp;
175 struct work_struct scheduler;
176};
177#define OHCI_QUIRK_AMD756 0x01
178#define OHCI_QUIRK_SUPERIO 0x02
179#define OHCI_QUIRK_INITRESET 0x04
180#define OHCI_BIG_ENDIAN 0x08
181#define OHCI_QUIRK_ZFMICRO 0x10
182struct u132 {
183 struct kref kref;
184 struct list_head u132_list;
185 struct semaphore sw_lock;
186 struct semaphore scheduler_lock;
187 struct u132_platform_data *board;
188 struct platform_device *platform_dev;
189 struct u132_ring ring[MAX_U132_RINGS];
190 int sequence_num;
191 int going;
192 int power;
193 int reset;
194 int num_ports;
195 u32 hc_control;
196 u32 hc_fminterval;
197 u32 hc_roothub_status;
198 u32 hc_roothub_a;
199 u32 hc_roothub_portstatus[MAX_ROOT_PORTS];
200 int flags;
201 unsigned long next_statechange;
202 struct work_struct monitor;
203 int num_endpoints;
204 struct u132_addr addr[MAX_U132_ADDRS];
205 struct u132_udev udev[MAX_U132_UDEVS];
206 struct u132_port port[MAX_U132_PORTS];
207 struct u132_endp *endp[MAX_U132_ENDPS];
208};
209int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data);
210int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, u8 addressofs,
211 u8 width, u32 *data);
212int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, u8 addressofs,
213 u8 width, u32 data);
214/*
215* these can not be inlines because we need the structure offset!!
216* Does anyone have a better way?????
217*/
218#define u132_read_pcimem(u132, member, data) \
219 usb_ftdi_elan_read_pcimem(u132->platform_dev, offsetof(struct \
220 ohci_regs, member), 0, data);
221#define u132_write_pcimem(u132, member, data) \
222 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
223 ohci_regs, member), 0, data);
224#define u132_write_pcimem_byte(u132, member, data) \
225 usb_ftdi_elan_write_pcimem(u132->platform_dev, offsetof(struct \
226 ohci_regs, member), 0x0e, data);
227static inline struct u132 *udev_to_u132(struct u132_udev *udev)
228{
229 u8 udev_number = udev->udev_number;
230 return container_of(udev, struct u132, udev[udev_number]);
231}
232
233static inline struct u132 *hcd_to_u132(struct usb_hcd *hcd)
234{
235 return (struct u132 *)(hcd->hcd_priv);
236}
237
238static inline struct usb_hcd *u132_to_hcd(struct u132 *u132)
239{
240 return container_of((void *)u132, struct usb_hcd, hcd_priv);
241}
242
243static inline void u132_disable(struct u132 *u132)
244{
245 u132_to_hcd(u132)->state = HC_STATE_HALT;
246}
247
248
249#define kref_to_u132(d) container_of(d, struct u132, kref)
250#define kref_to_u132_endp(d) container_of(d, struct u132_endp, kref)
251#define kref_to_u132_udev(d) container_of(d, struct u132_udev, kref)
252#include "../misc/usb_u132.h"
253static const char hcd_name[] = "u132_hcd";
254#define PORT_C_MASK ((USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | \
255 USB_PORT_STAT_C_SUSPEND | USB_PORT_STAT_C_OVERCURRENT | \
256 USB_PORT_STAT_C_RESET) << 16)
257static void u132_hcd_delete(struct kref *kref)
258{
259 struct u132 *u132 = kref_to_u132(kref);
260 struct platform_device *pdev = u132->platform_dev;
261 struct usb_hcd *hcd = u132_to_hcd(u132);
262 u132->going += 1;
263 down(&u132_module_lock);
264 list_del_init(&u132->u132_list);
265 u132_instances -= 1;
266 up(&u132_module_lock);
267 dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13"
268 "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev);
269 usb_put_hcd(hcd);
270}
271
272static inline void u132_u132_put_kref(struct u132 *u132)
273{
274 kref_put(&u132->kref, u132_hcd_delete);
275}
276
277static inline void u132_u132_init_kref(struct u132 *u132)
278{
279 kref_init(&u132->kref);
280}
281
282static void u132_udev_delete(struct kref *kref)
283{
284 struct u132_udev *udev = kref_to_u132_udev(kref);
285 udev->udev_number = 0;
286 udev->usb_device = NULL;
287 udev->usb_addr = 0;
288 udev->enumeration = 0;
289}
290
291static inline void u132_udev_put_kref(struct u132 *u132, struct u132_udev *udev)
292{
293 kref_put(&udev->kref, u132_udev_delete);
294}
295
296static inline void u132_udev_get_kref(struct u132 *u132, struct u132_udev *udev)
297{
298 kref_get(&udev->kref);
299}
300
301static inline void u132_udev_init_kref(struct u132 *u132,
302 struct u132_udev *udev)
303{
304 kref_init(&udev->kref);
305}
306
307static inline void u132_ring_put_kref(struct u132 *u132, struct u132_ring *ring)
308{
309 kref_put(&u132->kref, u132_hcd_delete);
310}
311
312static void u132_ring_requeue_work(struct u132 *u132, struct u132_ring *ring,
313 unsigned int delta)
314{
315 if (delta > 0) {
316 if (queue_delayed_work(workqueue, &ring->scheduler, delta))
317 return;
318 } else if (queue_work(workqueue, &ring->scheduler))
319 return;
320 kref_put(&u132->kref, u132_hcd_delete);
321 return;
322}
323
324static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring,
325 unsigned int delta)
326{
327 kref_get(&u132->kref);
328 u132_ring_requeue_work(u132, ring, delta);
329 return;
330}
331
332static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring)
333{
334 if (cancel_delayed_work(&ring->scheduler)) {
335 kref_put(&u132->kref, u132_hcd_delete);
336 }
337}
338
339static void u132_endp_delete(struct kref *kref)
340{
341 struct u132_endp *endp = kref_to_u132_endp(kref);
342 struct u132 *u132 = endp->u132;
343 u8 usb_addr = endp->usb_addr;
344 u8 usb_endp = endp->usb_endp;
345 u8 address = u132->addr[usb_addr].address;
346 struct u132_udev *udev = &u132->udev[address];
347 u8 endp_number = endp->endp_number;
348 struct usb_host_endpoint *hep = endp->hep;
349 struct u132_ring *ring = endp->ring;
350 struct list_head *head = &endp->endp_ring;
351 ring->length -= 1;
352 if (endp == ring->curr_endp) {
353 if (list_empty(head)) {
354 ring->curr_endp = NULL;
355 list_del(head);
356 } else {
357 struct u132_endp *next_endp = list_entry(head->next,
358 struct u132_endp, endp_ring);
359 ring->curr_endp = next_endp;
360 list_del(head);
361 }} else
362 list_del(head);
363 if (endp->input) {
364 udev->endp_number_in[usb_endp] = 0;
365 u132_udev_put_kref(u132, udev);
366 }
367 if (endp->output) {
368 udev->endp_number_out[usb_endp] = 0;
369 u132_udev_put_kref(u132, udev);
370 }
371 u132->endp[endp_number - 1] = NULL;
372 hep->hcpriv = NULL;
373 kfree(endp);
374 u132_u132_put_kref(u132);
375}
376
377static inline void u132_endp_put_kref(struct u132 *u132, struct u132_endp *endp)
378{
379 kref_put(&endp->kref, u132_endp_delete);
380}
381
382static inline void u132_endp_get_kref(struct u132 *u132, struct u132_endp *endp)
383{
384 kref_get(&endp->kref);
385}
386
387static inline void u132_endp_init_kref(struct u132 *u132,
388 struct u132_endp *endp)
389{
390 kref_init(&endp->kref);
391 kref_get(&u132->kref);
392}
393
394static void u132_endp_queue_work(struct u132 *u132, struct u132_endp *endp,
395 unsigned int delta)
396{
397 if (delta > 0) {
398 if (queue_delayed_work(workqueue, &endp->scheduler, delta))
399 kref_get(&endp->kref);
400 } else if (queue_work(workqueue, &endp->scheduler))
401 kref_get(&endp->kref);
402 return;
403}
404
405static void u132_endp_cancel_work(struct u132 *u132, struct u132_endp *endp)
406{
407 if (cancel_delayed_work(&endp->scheduler))
408 kref_put(&endp->kref, u132_endp_delete);
409}
410
411static inline void u132_monitor_put_kref(struct u132 *u132)
412{
413 kref_put(&u132->kref, u132_hcd_delete);
414}
415
416static void u132_monitor_queue_work(struct u132 *u132, unsigned int delta)
417{
418 if (delta > 0) {
419 if (queue_delayed_work(workqueue, &u132->monitor, delta)) {
420 kref_get(&u132->kref);
421 }
422 } else if (queue_work(workqueue, &u132->monitor))
423 kref_get(&u132->kref);
424 return;
425}
426
427static void u132_monitor_requeue_work(struct u132 *u132, unsigned int delta)
428{
429 if (delta > 0) {
430 if (queue_delayed_work(workqueue, &u132->monitor, delta))
431 return;
432 } else if (queue_work(workqueue, &u132->monitor))
433 return;
434 kref_put(&u132->kref, u132_hcd_delete);
435 return;
436}
437
438static void u132_monitor_cancel_work(struct u132 *u132)
439{
440 if (cancel_delayed_work(&u132->monitor))
441 kref_put(&u132->kref, u132_hcd_delete);
442}
443
444static int read_roothub_info(struct u132 *u132)
445{
446 u32 revision;
447 int retval;
448 retval = u132_read_pcimem(u132, revision, &revision);
449 if (retval) {
450 dev_err(&u132->platform_dev->dev, "error %d accessing device co"
451 "ntrol\n", retval);
452 return retval;
453 } else if ((revision & 0xFF) == 0x10) {
454 } else if ((revision & 0xFF) == 0x11) {
455 } else {
456 dev_err(&u132->platform_dev->dev, "device revision is not valid"
457 " %08X\n", revision);
458 return -ENODEV;
459 }
460 retval = u132_read_pcimem(u132, control, &u132->hc_control);
461 if (retval) {
462 dev_err(&u132->platform_dev->dev, "error %d accessing device co"
463 "ntrol\n", retval);
464 return retval;
465 }
466 retval = u132_read_pcimem(u132, roothub.status,
467 &u132->hc_roothub_status);
468 if (retval) {
469 dev_err(&u132->platform_dev->dev, "error %d accessing device re"
470 "g roothub.status\n", retval);
471 return retval;
472 }
473 retval = u132_read_pcimem(u132, roothub.a, &u132->hc_roothub_a);
474 if (retval) {
475 dev_err(&u132->platform_dev->dev, "error %d accessing device re"
476 "g roothub.a\n", retval);
477 return retval;
478 }
479 {
480 int I = u132->num_ports;
481 int i = 0;
482 while (I-- > 0) {
483 retval = u132_read_pcimem(u132, roothub.portstatus[i],
484 &u132->hc_roothub_portstatus[i]);
485 if (retval) {
486 dev_err(&u132->platform_dev->dev, "error %d acc"
487 "essing device roothub.portstatus[%d]\n"
488 , retval, i);
489 return retval;
490 } else
491 i += 1;
492 }
493 }
494 return 0;
495}
496
497static void u132_hcd_monitor_work(void *data)
498{
499 struct u132 *u132 = data;
500 if (u132->going > 1) {
501 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
502 , u132->going);
503 u132_monitor_put_kref(u132);
504 return;
505 } else if (u132->going > 0) {
506 dev_err(&u132->platform_dev->dev, "device is being removed\n");
507 u132_monitor_put_kref(u132);
508 return;
509 } else {
510 int retval;
511 down(&u132->sw_lock);
512 retval = read_roothub_info(u132);
513 if (retval) {
514 struct usb_hcd *hcd = u132_to_hcd(u132);
515 u132_disable(u132);
516 u132->going = 1;
517 up(&u132->sw_lock);
518 usb_hc_died(hcd);
519 ftdi_elan_gone_away(u132->platform_dev);
520 u132_monitor_put_kref(u132);
521 return;
522 } else {
523 u132_monitor_requeue_work(u132, 500);
524 up(&u132->sw_lock);
525 return;
526 }
527 }
528}
529
530static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp,
531 struct urb *urb, int status)
532{
533 struct u132_ring *ring;
534 unsigned long irqs;
535 struct usb_hcd *hcd = u132_to_hcd(u132);
536 urb->error_count = 0;
537 urb->status = status;
538 urb->hcpriv = NULL;
539 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
540 endp->queue_next += 1;
541 if (ENDP_QUEUE_SIZE > --endp->queue_size) {
542 endp->active = 0;
543 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
544 } else {
545 struct list_head *next = endp->urb_more.next;
546 struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
547 urb_more);
548 list_del(next);
549 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
550 urbq->urb;
551 endp->active = 0;
552 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
553 kfree(urbq);
554 } down(&u132->scheduler_lock);
555 ring = endp->ring;
556 ring->in_use = 0;
557 u132_ring_cancel_work(u132, ring);
558 u132_ring_queue_work(u132, ring, 0);
559 up(&u132->scheduler_lock);
560 u132_endp_put_kref(u132, endp);
561 usb_hcd_giveback_urb(hcd, urb, NULL);
562 return;
563}
564
565static void u132_hcd_forget_urb(struct u132 *u132, struct u132_endp *endp,
566 struct urb *urb, int status)
567{
568 u132_endp_put_kref(u132, endp);
569}
570
571static void u132_hcd_abandon_urb(struct u132 *u132, struct u132_endp *endp,
572 struct urb *urb, int status)
573{
574 unsigned long irqs;
575 struct usb_hcd *hcd = u132_to_hcd(u132);
576 urb->error_count = 0;
577 urb->status = status;
578 urb->hcpriv = NULL;
579 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
580 endp->queue_next += 1;
581 if (ENDP_QUEUE_SIZE > --endp->queue_size) {
582 endp->active = 0;
583 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
584 } else {
585 struct list_head *next = endp->urb_more.next;
586 struct u132_urbq *urbq = list_entry(next, struct u132_urbq,
587 urb_more);
588 list_del(next);
589 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
590 urbq->urb;
591 endp->active = 0;
592 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
593 kfree(urbq);
594 } usb_hcd_giveback_urb(hcd, urb, NULL);
595 return;
596}
597
598static inline int edset_input(struct u132 *u132, struct u132_ring *ring,
599 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
600 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
601 int toggle_bits, int error_count, int condition_code, int repeat_number,
602 int halted, int skipped, int actual, int non_null))
603{
604 return usb_ftdi_elan_edset_input(u132->platform_dev, ring->number, endp,
605 urb, address, endp->usb_endp, toggle_bits, callback);
606}
607
608static inline int edset_setup(struct u132 *u132, struct u132_ring *ring,
609 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
610 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
611 int toggle_bits, int error_count, int condition_code, int repeat_number,
612 int halted, int skipped, int actual, int non_null))
613{
614 return usb_ftdi_elan_edset_setup(u132->platform_dev, ring->number, endp,
615 urb, address, endp->usb_endp, toggle_bits, callback);
616}
617
618static inline int edset_single(struct u132 *u132, struct u132_ring *ring,
619 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
620 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
621 int toggle_bits, int error_count, int condition_code, int repeat_number,
622 int halted, int skipped, int actual, int non_null))
623{
624 return usb_ftdi_elan_edset_single(u132->platform_dev, ring->number,
625 endp, urb, address, endp->usb_endp, toggle_bits, callback);
626}
627
628static inline int edset_output(struct u132 *u132, struct u132_ring *ring,
629 struct u132_endp *endp, struct urb *urb, u8 address, u8 toggle_bits,
630 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
631 int toggle_bits, int error_count, int condition_code, int repeat_number,
632 int halted, int skipped, int actual, int non_null))
633{
634 return usb_ftdi_elan_edset_output(u132->platform_dev, ring->number,
635 endp, urb, address, endp->usb_endp, toggle_bits, callback);
636}
637
638
639/*
640* must not LOCK sw_lock
641*
642*/
643static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf,
644 int len, int toggle_bits, int error_count, int condition_code,
645 int repeat_number, int halted, int skipped, int actual, int non_null)
646{
647 struct u132_endp *endp = data;
648 struct u132 *u132 = endp->u132;
649 u8 address = u132->addr[endp->usb_addr].address;
650 struct u132_udev *udev = &u132->udev[address];
651 down(&u132->scheduler_lock);
652 if (u132->going > 1) {
653 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
654 , u132->going);
655 up(&u132->scheduler_lock);
656 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
657 return;
658 } else if (endp->dequeueing) {
659 endp->dequeueing = 0;
660 up(&u132->scheduler_lock);
661 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
662 return;
663 } else if (u132->going > 0) {
664 dev_err(&u132->platform_dev->dev, "device is being removed urb="
665 "%p status=%d\n", urb, urb->status);
666 up(&u132->scheduler_lock);
667 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
668 return;
669 } else if (urb->status == -EINPROGRESS) {
670 struct u132_ring *ring = endp->ring;
671 u8 *u = urb->transfer_buffer + urb->actual_length;
672 u8 *b = buf;
673 int L = len;
674 while (L-- > 0) {
675 *u++ = *b++;
676 }
677 urb->actual_length += len;
678 if ((condition_code == TD_CC_NOERROR) &&
679 (urb->transfer_buffer_length > urb->actual_length)) {
680 endp->toggle_bits = toggle_bits;
681 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
682 1 & toggle_bits);
683 if (urb->actual_length > 0) {
684 int retval;
685 up(&u132->scheduler_lock);
686 retval = edset_single(u132, ring, endp, urb,
687 address, endp->toggle_bits,
688 u132_hcd_interrupt_recv);
689 if (retval == 0) {
690 } else
691 u132_hcd_giveback_urb(u132, endp, urb,
692 retval);
693 } else {
694 ring->in_use = 0;
695 endp->active = 0;
696 endp->jiffies = jiffies +
697 msecs_to_jiffies(urb->interval);
698 u132_ring_cancel_work(u132, ring);
699 u132_ring_queue_work(u132, ring, 0);
700 up(&u132->scheduler_lock);
701 u132_endp_put_kref(u132, endp);
702 }
703 return;
704 } else if ((condition_code == TD_DATAUNDERRUN) &&
705 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
706 endp->toggle_bits = toggle_bits;
707 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
708 1 & toggle_bits);
709 up(&u132->scheduler_lock);
710 u132_hcd_giveback_urb(u132, endp, urb, 0);
711 return;
712 } else {
713 if (condition_code == TD_CC_NOERROR) {
714 endp->toggle_bits = toggle_bits;
715 usb_settoggle(udev->usb_device, endp->usb_endp,
716 0, 1 & toggle_bits);
717 } else if (condition_code == TD_CC_STALL) {
718 endp->toggle_bits = 0x2;
719 usb_settoggle(udev->usb_device, endp->usb_endp,
720 0, 0);
721 } else {
722 endp->toggle_bits = 0x2;
723 usb_settoggle(udev->usb_device, endp->usb_endp,
724 0, 0);
725 dev_err(&u132->platform_dev->dev, "urb=%p givin"
726 "g back INTERRUPT %s\n", urb,
727 cc_to_text[condition_code]);
728 }
729 up(&u132->scheduler_lock);
730 u132_hcd_giveback_urb(u132, endp, urb,
731 cc_to_error[condition_code]);
732 return;
733 }
734 } else {
735 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
736 "s=%d\n", urb, urb->status);
737 up(&u132->scheduler_lock);
738 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
739 return;
740 }
741}
742
743static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf,
744 int len, int toggle_bits, int error_count, int condition_code,
745 int repeat_number, int halted, int skipped, int actual, int non_null)
746{
747 struct u132_endp *endp = data;
748 struct u132 *u132 = endp->u132;
749 u8 address = u132->addr[endp->usb_addr].address;
750 down(&u132->scheduler_lock);
751 if (u132->going > 1) {
752 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
753 , u132->going);
754 up(&u132->scheduler_lock);
755 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
756 return;
757 } else if (endp->dequeueing) {
758 endp->dequeueing = 0;
759 up(&u132->scheduler_lock);
760 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
761 return;
762 } else if (u132->going > 0) {
763 dev_err(&u132->platform_dev->dev, "device is being removed urb="
764 "%p status=%d\n", urb, urb->status);
765 up(&u132->scheduler_lock);
766 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
767 return;
768 } else if (urb->status == -EINPROGRESS) {
769 struct u132_ring *ring = endp->ring;
770 urb->actual_length += len;
771 endp->toggle_bits = toggle_bits;
772 if (urb->transfer_buffer_length > urb->actual_length) {
773 int retval;
774 up(&u132->scheduler_lock);
775 retval = edset_output(u132, ring, endp, urb, address,
776 endp->toggle_bits, u132_hcd_bulk_output_sent);
777 if (retval == 0) {
778 } else
779 u132_hcd_giveback_urb(u132, endp, urb, retval);
780 return;
781 } else {
782 up(&u132->scheduler_lock);
783 u132_hcd_giveback_urb(u132, endp, urb, 0);
784 return;
785 }
786 } else {
787 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
788 "s=%d\n", urb, urb->status);
789 up(&u132->scheduler_lock);
790 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
791 return;
792 }
793}
794
795static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf,
796 int len, int toggle_bits, int error_count, int condition_code,
797 int repeat_number, int halted, int skipped, int actual, int non_null)
798{
799 struct u132_endp *endp = data;
800 struct u132 *u132 = endp->u132;
801 u8 address = u132->addr[endp->usb_addr].address;
802 struct u132_udev *udev = &u132->udev[address];
803 down(&u132->scheduler_lock);
804 if (u132->going > 1) {
805 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
806 , u132->going);
807 up(&u132->scheduler_lock);
808 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
809 return;
810 } else if (endp->dequeueing) {
811 endp->dequeueing = 0;
812 up(&u132->scheduler_lock);
813 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
814 return;
815 } else if (u132->going > 0) {
816 dev_err(&u132->platform_dev->dev, "device is being removed urb="
817 "%p status=%d\n", urb, urb->status);
818 up(&u132->scheduler_lock);
819 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
820 return;
821 } else if (urb->status == -EINPROGRESS) {
822 struct u132_ring *ring = endp->ring;
823 u8 *u = urb->transfer_buffer + urb->actual_length;
824 u8 *b = buf;
825 int L = len;
826 while (L-- > 0) {
827 *u++ = *b++;
828 }
829 urb->actual_length += len;
830 if ((condition_code == TD_CC_NOERROR) &&
831 (urb->transfer_buffer_length > urb->actual_length)) {
832 int retval;
833 endp->toggle_bits = toggle_bits;
834 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
835 1 & toggle_bits);
836 up(&u132->scheduler_lock);
837 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
838 ring->number, endp, urb, address,
839 endp->usb_endp, endp->toggle_bits,
840 u132_hcd_bulk_input_recv);
841 if (retval == 0) {
842 } else
843 u132_hcd_giveback_urb(u132, endp, urb, retval);
844 return;
845 } else if (condition_code == TD_CC_NOERROR) {
846 endp->toggle_bits = toggle_bits;
847 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
848 1 & toggle_bits);
849 up(&u132->scheduler_lock);
850 u132_hcd_giveback_urb(u132, endp, urb,
851 cc_to_error[condition_code]);
852 return;
853 } else if ((condition_code == TD_DATAUNDERRUN) &&
854 ((urb->transfer_flags & URB_SHORT_NOT_OK) == 0)) {
855 endp->toggle_bits = toggle_bits;
856 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
857 1 & toggle_bits);
858 up(&u132->scheduler_lock);
859 u132_hcd_giveback_urb(u132, endp, urb, 0);
860 return;
861 } else if (condition_code == TD_DATAUNDERRUN) {
862 endp->toggle_bits = toggle_bits;
863 usb_settoggle(udev->usb_device, endp->usb_endp, 0,
864 1 & toggle_bits);
865 dev_warn(&u132->platform_dev->dev, "urb=%p(SHORT NOT OK"
866 ") giving back BULK IN %s\n", urb,
867 cc_to_text[condition_code]);
868 up(&u132->scheduler_lock);
869 u132_hcd_giveback_urb(u132, endp, urb, 0);
870 return;
871 } else if (condition_code == TD_CC_STALL) {
872 endp->toggle_bits = 0x2;
873 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
874 up(&u132->scheduler_lock);
875 u132_hcd_giveback_urb(u132, endp, urb,
876 cc_to_error[condition_code]);
877 return;
878 } else {
879 endp->toggle_bits = 0x2;
880 usb_settoggle(udev->usb_device, endp->usb_endp, 0, 0);
881 dev_err(&u132->platform_dev->dev, "urb=%p giving back B"
882 "ULK IN code=%d %s\n", urb, condition_code,
883 cc_to_text[condition_code]);
884 up(&u132->scheduler_lock);
885 u132_hcd_giveback_urb(u132, endp, urb,
886 cc_to_error[condition_code]);
887 return;
888 }
889 } else {
890 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
891 "s=%d\n", urb, urb->status);
892 up(&u132->scheduler_lock);
893 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
894 return;
895 }
896}
897
898static void u132_hcd_configure_empty_sent(void *data, struct urb *urb, u8 *buf,
899 int len, int toggle_bits, int error_count, int condition_code,
900 int repeat_number, int halted, int skipped, int actual, int non_null)
901{
902 struct u132_endp *endp = data;
903 struct u132 *u132 = endp->u132;
904 down(&u132->scheduler_lock);
905 if (u132->going > 1) {
906 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
907 , u132->going);
908 up(&u132->scheduler_lock);
909 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
910 return;
911 } else if (endp->dequeueing) {
912 endp->dequeueing = 0;
913 up(&u132->scheduler_lock);
914 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
915 return;
916 } else if (u132->going > 0) {
917 dev_err(&u132->platform_dev->dev, "device is being removed urb="
918 "%p status=%d\n", urb, urb->status);
919 up(&u132->scheduler_lock);
920 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
921 return;
922 } else if (urb->status == -EINPROGRESS) {
923 up(&u132->scheduler_lock);
924 u132_hcd_giveback_urb(u132, endp, urb, 0);
925 return;
926 } else {
927 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
928 "s=%d\n", urb, urb->status);
929 up(&u132->scheduler_lock);
930 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
931 return;
932 }
933}
934
935static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf,
936 int len, int toggle_bits, int error_count, int condition_code,
937 int repeat_number, int halted, int skipped, int actual, int non_null)
938{
939 struct u132_endp *endp = data;
940 struct u132 *u132 = endp->u132;
941 u8 address = u132->addr[endp->usb_addr].address;
942 down(&u132->scheduler_lock);
943 if (u132->going > 1) {
944 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
945 , u132->going);
946 up(&u132->scheduler_lock);
947 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
948 return;
949 } else if (endp->dequeueing) {
950 endp->dequeueing = 0;
951 up(&u132->scheduler_lock);
952 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
953 return;
954 } else if (u132->going > 0) {
955 dev_err(&u132->platform_dev->dev, "device is being removed urb="
956 "%p status=%d\n", urb, urb->status);
957 up(&u132->scheduler_lock);
958 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
959 return;
960 } else if (urb->status == -EINPROGRESS) {
961 struct u132_ring *ring = endp->ring;
962 u8 *u = urb->transfer_buffer;
963 u8 *b = buf;
964 int L = len;
965 while (L-- > 0) {
966 *u++ = *b++;
967 }
968 urb->actual_length = len;
969 if ((condition_code == TD_CC_NOERROR) || ((condition_code ==
970 TD_DATAUNDERRUN) && ((urb->transfer_flags &
971 URB_SHORT_NOT_OK) == 0))) {
972 int retval;
973 up(&u132->scheduler_lock);
974 retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
975 ring->number, endp, urb, address,
976 endp->usb_endp, 0x3,
977 u132_hcd_configure_empty_sent);
978 if (retval == 0) {
979 } else
980 u132_hcd_giveback_urb(u132, endp, urb, retval);
981 return;
982 } else if (condition_code == TD_CC_STALL) {
983 up(&u132->scheduler_lock);
984 dev_warn(&u132->platform_dev->dev, "giving back SETUP I"
985 "NPUT STALL urb %p\n", urb);
986 u132_hcd_giveback_urb(u132, endp, urb,
987 cc_to_error[condition_code]);
988 return;
989 } else {
990 up(&u132->scheduler_lock);
991 dev_err(&u132->platform_dev->dev, "giving back SETUP IN"
992 "PUT %s urb %p\n", cc_to_text[condition_code],
993 urb);
994 u132_hcd_giveback_urb(u132, endp, urb,
995 cc_to_error[condition_code]);
996 return;
997 }
998 } else {
999 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1000 "s=%d\n", urb, urb->status);
1001 up(&u132->scheduler_lock);
1002 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1003 return;
1004 }
1005}
1006
1007static void u132_hcd_configure_empty_recv(void *data, struct urb *urb, u8 *buf,
1008 int len, int toggle_bits, int error_count, int condition_code,
1009 int repeat_number, int halted, int skipped, int actual, int non_null)
1010{
1011 struct u132_endp *endp = data;
1012 struct u132 *u132 = endp->u132;
1013 down(&u132->scheduler_lock);
1014 if (u132->going > 1) {
1015 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1016 , u132->going);
1017 up(&u132->scheduler_lock);
1018 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1019 return;
1020 } else if (endp->dequeueing) {
1021 endp->dequeueing = 0;
1022 up(&u132->scheduler_lock);
1023 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1024 return;
1025 } else if (u132->going > 0) {
1026 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1027 "%p status=%d\n", urb, urb->status);
1028 up(&u132->scheduler_lock);
1029 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1030 return;
1031 } else if (urb->status == -EINPROGRESS) {
1032 up(&u132->scheduler_lock);
1033 u132_hcd_giveback_urb(u132, endp, urb, 0);
1034 return;
1035 } else {
1036 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1037 "s=%d\n", urb, urb->status);
1038 up(&u132->scheduler_lock);
1039 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1040 return;
1041 }
1042}
1043
1044static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf,
1045 int len, int toggle_bits, int error_count, int condition_code,
1046 int repeat_number, int halted, int skipped, int actual, int non_null)
1047{
1048 struct u132_endp *endp = data;
1049 struct u132 *u132 = endp->u132;
1050 u8 address = u132->addr[endp->usb_addr].address;
1051 down(&u132->scheduler_lock);
1052 if (u132->going > 1) {
1053 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1054 , u132->going);
1055 up(&u132->scheduler_lock);
1056 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1057 return;
1058 } else if (endp->dequeueing) {
1059 endp->dequeueing = 0;
1060 up(&u132->scheduler_lock);
1061 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1062 return;
1063 } else if (u132->going > 0) {
1064 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1065 "%p status=%d\n", urb, urb->status);
1066 up(&u132->scheduler_lock);
1067 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1068 return;
1069 } else if (urb->status == -EINPROGRESS) {
1070 if (usb_pipein(urb->pipe)) {
1071 int retval;
1072 struct u132_ring *ring = endp->ring;
1073 up(&u132->scheduler_lock);
1074 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1075 ring->number, endp, urb, address,
1076 endp->usb_endp, 0,
1077 u132_hcd_configure_input_recv);
1078 if (retval == 0) {
1079 } else
1080 u132_hcd_giveback_urb(u132, endp, urb, retval);
1081 return;
1082 } else {
1083 int retval;
1084 struct u132_ring *ring = endp->ring;
1085 up(&u132->scheduler_lock);
1086 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1087 ring->number, endp, urb, address,
1088 endp->usb_endp, 0,
1089 u132_hcd_configure_empty_recv);
1090 if (retval == 0) {
1091 } else
1092 u132_hcd_giveback_urb(u132, endp, urb, retval);
1093 return;
1094 }
1095 } else {
1096 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1097 "s=%d\n", urb, urb->status);
1098 up(&u132->scheduler_lock);
1099 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1100 return;
1101 }
1102}
1103
1104static void u132_hcd_enumeration_empty_recv(void *data, struct urb *urb,
1105 u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
1106 int repeat_number, int halted, int skipped, int actual, int non_null)
1107{
1108 struct u132_endp *endp = data;
1109 struct u132 *u132 = endp->u132;
1110 u8 address = u132->addr[endp->usb_addr].address;
1111 struct u132_udev *udev = &u132->udev[address];
1112 down(&u132->scheduler_lock);
1113 if (u132->going > 1) {
1114 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1115 , u132->going);
1116 up(&u132->scheduler_lock);
1117 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1118 return;
1119 } else if (endp->dequeueing) {
1120 endp->dequeueing = 0;
1121 up(&u132->scheduler_lock);
1122 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1123 return;
1124 } else if (u132->going > 0) {
1125 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1126 "%p status=%d\n", urb, urb->status);
1127 up(&u132->scheduler_lock);
1128 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1129 return;
1130 } else if (urb->status == -EINPROGRESS) {
1131 u132->addr[0].address = 0;
1132 endp->usb_addr = udev->usb_addr;
1133 up(&u132->scheduler_lock);
1134 u132_hcd_giveback_urb(u132, endp, urb, 0);
1135 return;
1136 } else {
1137 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1138 "s=%d\n", urb, urb->status);
1139 up(&u132->scheduler_lock);
1140 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1141 return;
1142 }
1143}
1144
1145static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb,
1146 u8 *buf, int len, int toggle_bits, int error_count, int condition_code,
1147 int repeat_number, int halted, int skipped, int actual, int non_null)
1148{
1149 struct u132_endp *endp = data;
1150 struct u132 *u132 = endp->u132;
1151 down(&u132->scheduler_lock);
1152 if (u132->going > 1) {
1153 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1154 , u132->going);
1155 up(&u132->scheduler_lock);
1156 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1157 return;
1158 } else if (endp->dequeueing) {
1159 endp->dequeueing = 0;
1160 up(&u132->scheduler_lock);
1161 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1162 return;
1163 } else if (u132->going > 0) {
1164 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1165 "%p status=%d\n", urb, urb->status);
1166 up(&u132->scheduler_lock);
1167 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1168 return;
1169 } else if (urb->status == -EINPROGRESS) {
1170 int retval;
1171 struct u132_ring *ring = endp->ring;
1172 up(&u132->scheduler_lock);
1173 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1174 ring->number, endp, urb, 0, endp->usb_endp, 0,
1175 u132_hcd_enumeration_empty_recv);
1176 if (retval == 0) {
1177 } else
1178 u132_hcd_giveback_urb(u132, endp, urb, retval);
1179 return;
1180 } else {
1181 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1182 "s=%d\n", urb, urb->status);
1183 up(&u132->scheduler_lock);
1184 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1185 return;
1186 }
1187}
1188
1189static void u132_hcd_initial_empty_sent(void *data, struct urb *urb, u8 *buf,
1190 int len, int toggle_bits, int error_count, int condition_code,
1191 int repeat_number, int halted, int skipped, int actual, int non_null)
1192{
1193 struct u132_endp *endp = data;
1194 struct u132 *u132 = endp->u132;
1195 down(&u132->scheduler_lock);
1196 if (u132->going > 1) {
1197 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1198 , u132->going);
1199 up(&u132->scheduler_lock);
1200 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1201 return;
1202 } else if (endp->dequeueing) {
1203 endp->dequeueing = 0;
1204 up(&u132->scheduler_lock);
1205 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1206 return;
1207 } else if (u132->going > 0) {
1208 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1209 "%p status=%d\n", urb, urb->status);
1210 up(&u132->scheduler_lock);
1211 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1212 return;
1213 } else if (urb->status == -EINPROGRESS) {
1214 up(&u132->scheduler_lock);
1215 u132_hcd_giveback_urb(u132, endp, urb, 0);
1216 return;
1217 } else {
1218 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1219 "s=%d\n", urb, urb->status);
1220 up(&u132->scheduler_lock);
1221 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1222 return;
1223 }
1224}
1225
1226static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf,
1227 int len, int toggle_bits, int error_count, int condition_code,
1228 int repeat_number, int halted, int skipped, int actual, int non_null)
1229{
1230 struct u132_endp *endp = data;
1231 struct u132 *u132 = endp->u132;
1232 u8 address = u132->addr[endp->usb_addr].address;
1233 down(&u132->scheduler_lock);
1234 if (u132->going > 1) {
1235 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1236 , u132->going);
1237 up(&u132->scheduler_lock);
1238 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1239 return;
1240 } else if (endp->dequeueing) {
1241 endp->dequeueing = 0;
1242 up(&u132->scheduler_lock);
1243 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1244 return;
1245 } else if (u132->going > 0) {
1246 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1247 "%p status=%d\n", urb, urb->status);
1248 up(&u132->scheduler_lock);
1249 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1250 return;
1251 } else if (urb->status == -EINPROGRESS) {
1252 int retval;
1253 struct u132_ring *ring = endp->ring;
1254 u8 *u = urb->transfer_buffer;
1255 u8 *b = buf;
1256 int L = len;
1257 while (L-- > 0) {
1258 *u++ = *b++;
1259 }
1260 urb->actual_length = len;
1261 up(&u132->scheduler_lock);
1262 retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
1263 ring->number, endp, urb, address, endp->usb_endp, 0x3,
1264 u132_hcd_initial_empty_sent);
1265 if (retval == 0) {
1266 } else
1267 u132_hcd_giveback_urb(u132, endp, urb, retval);
1268 return;
1269 } else {
1270 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1271 "s=%d\n", urb, urb->status);
1272 up(&u132->scheduler_lock);
1273 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1274 return;
1275 }
1276}
1277
1278static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
1279 int len, int toggle_bits, int error_count, int condition_code,
1280 int repeat_number, int halted, int skipped, int actual, int non_null)
1281{
1282 struct u132_endp *endp = data;
1283 struct u132 *u132 = endp->u132;
1284 u8 address = u132->addr[endp->usb_addr].address;
1285 down(&u132->scheduler_lock);
1286 if (u132->going > 1) {
1287 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1288 , u132->going);
1289 up(&u132->scheduler_lock);
1290 u132_hcd_forget_urb(u132, endp, urb, -ENODEV);
1291 return;
1292 } else if (endp->dequeueing) {
1293 endp->dequeueing = 0;
1294 up(&u132->scheduler_lock);
1295 u132_hcd_giveback_urb(u132, endp, urb, -EINTR);
1296 return;
1297 } else if (u132->going > 0) {
1298 dev_err(&u132->platform_dev->dev, "device is being removed urb="
1299 "%p status=%d\n", urb, urb->status);
1300 up(&u132->scheduler_lock);
1301 u132_hcd_giveback_urb(u132, endp, urb, -ENODEV);
1302 return;
1303 } else if (urb->status == -EINPROGRESS) {
1304 int retval;
1305 struct u132_ring *ring = endp->ring;
1306 up(&u132->scheduler_lock);
1307 retval = usb_ftdi_elan_edset_input(u132->platform_dev,
1308 ring->number, endp, urb, address, endp->usb_endp, 0,
1309 u132_hcd_initial_input_recv);
1310 if (retval == 0) {
1311 } else
1312 u132_hcd_giveback_urb(u132, endp, urb, retval);
1313 return;
1314 } else {
1315 dev_err(&u132->platform_dev->dev, "CALLBACK called urb=%p statu"
1316 "s=%d\n", urb, urb->status);
1317 up(&u132->scheduler_lock);
1318 u132_hcd_giveback_urb(u132, endp, urb, urb->status);
1319 return;
1320 }
1321}
1322
1323static void u132_hcd_ring_work_scheduler(void *data);
1324static void u132_hcd_endp_work_scheduler(void *data);
1325/*
1326* this work function is only executed from the work queue
1327*
1328*/
1329static void u132_hcd_ring_work_scheduler(void *data)
1330{
1331 struct u132_ring *ring = data;
1332 struct u132 *u132 = ring->u132;
1333 down(&u132->scheduler_lock);
1334 if (ring->in_use) {
1335 up(&u132->scheduler_lock);
1336 u132_ring_put_kref(u132, ring);
1337 return;
1338 } else if (ring->curr_endp) {
1339 struct u132_endp *last_endp = ring->curr_endp;
1340 struct list_head *scan;
1341 struct list_head *head = &last_endp->endp_ring;
1342 unsigned long wakeup = 0;
1343 list_for_each(scan, head) {
1344 struct u132_endp *endp = list_entry(scan,
1345 struct u132_endp, endp_ring);
1346 if (endp->queue_next == endp->queue_last) {
1347 } else if ((endp->delayed == 0)
1348 || time_after_eq(jiffies, endp->jiffies)) {
1349 ring->curr_endp = endp;
1350 u132_endp_cancel_work(u132, last_endp);
1351 u132_endp_queue_work(u132, last_endp, 0);
1352 up(&u132->scheduler_lock);
1353 u132_ring_put_kref(u132, ring);
1354 return;
1355 } else {
1356 unsigned long delta = endp->jiffies - jiffies;
1357 if (delta > wakeup)
1358 wakeup = delta;
1359 }
1360 }
1361 if (last_endp->queue_next == last_endp->queue_last) {
1362 } else if ((last_endp->delayed == 0) || time_after_eq(jiffies,
1363 last_endp->jiffies)) {
1364 u132_endp_cancel_work(u132, last_endp);
1365 u132_endp_queue_work(u132, last_endp, 0);
1366 up(&u132->scheduler_lock);
1367 u132_ring_put_kref(u132, ring);
1368 return;
1369 } else {
1370 unsigned long delta = last_endp->jiffies - jiffies;
1371 if (delta > wakeup)
1372 wakeup = delta;
1373 }
1374 if (wakeup > 0) {
1375 u132_ring_requeue_work(u132, ring, wakeup);
1376 up(&u132->scheduler_lock);
1377 return;
1378 } else {
1379 up(&u132->scheduler_lock);
1380 u132_ring_put_kref(u132, ring);
1381 return;
1382 }
1383 } else {
1384 up(&u132->scheduler_lock);
1385 u132_ring_put_kref(u132, ring);
1386 return;
1387 }
1388}
1389
1390static void u132_hcd_endp_work_scheduler(void *data)
1391{
1392 struct u132_ring *ring;
1393 struct u132_endp *endp = data;
1394 struct u132 *u132 = endp->u132;
1395 down(&u132->scheduler_lock);
1396 ring = endp->ring;
1397 if (endp->edset_flush) {
1398 endp->edset_flush = 0;
1399 if (endp->dequeueing)
1400 usb_ftdi_elan_edset_flush(u132->platform_dev,
1401 ring->number, endp);
1402 up(&u132->scheduler_lock);
1403 u132_endp_put_kref(u132, endp);
1404 return;
1405 } else if (endp->active) {
1406 up(&u132->scheduler_lock);
1407 u132_endp_put_kref(u132, endp);
1408 return;
1409 } else if (ring->in_use) {
1410 up(&u132->scheduler_lock);
1411 u132_endp_put_kref(u132, endp);
1412 return;
1413 } else if (endp->queue_next == endp->queue_last) {
1414 up(&u132->scheduler_lock);
1415 u132_endp_put_kref(u132, endp);
1416 return;
1417 } else if (endp->pipetype == PIPE_INTERRUPT) {
1418 u8 address = u132->addr[endp->usb_addr].address;
1419 if (ring->in_use) {
1420 up(&u132->scheduler_lock);
1421 u132_endp_put_kref(u132, endp);
1422 return;
1423 } else {
1424 int retval;
1425 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1426 endp->queue_next];
1427 endp->active = 1;
1428 ring->curr_endp = endp;
1429 ring->in_use = 1;
1430 up(&u132->scheduler_lock);
1431 retval = edset_single(u132, ring, endp, urb, address,
1432 endp->toggle_bits, u132_hcd_interrupt_recv);
1433 if (retval == 0) {
1434 } else
1435 u132_hcd_giveback_urb(u132, endp, urb, retval);
1436 return;
1437 }
1438 } else if (endp->pipetype == PIPE_CONTROL) {
1439 u8 address = u132->addr[endp->usb_addr].address;
1440 if (ring->in_use) {
1441 up(&u132->scheduler_lock);
1442 u132_endp_put_kref(u132, endp);
1443 return;
1444 } else if (address == 0) {
1445 int retval;
1446 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1447 endp->queue_next];
1448 endp->active = 1;
1449 ring->curr_endp = endp;
1450 ring->in_use = 1;
1451 up(&u132->scheduler_lock);
1452 retval = edset_setup(u132, ring, endp, urb, address,
1453 0x2, u132_hcd_initial_setup_sent);
1454 if (retval == 0) {
1455 } else
1456 u132_hcd_giveback_urb(u132, endp, urb, retval);
1457 return;
1458 } else if (endp->usb_addr == 0) {
1459 int retval;
1460 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1461 endp->queue_next];
1462 endp->active = 1;
1463 ring->curr_endp = endp;
1464 ring->in_use = 1;
1465 up(&u132->scheduler_lock);
1466 retval = edset_setup(u132, ring, endp, urb, 0, 0x2,
1467 u132_hcd_enumeration_address_sent);
1468 if (retval == 0) {
1469 } else
1470 u132_hcd_giveback_urb(u132, endp, urb, retval);
1471 return;
1472 } else {
1473 int retval;
1474 u8 address = u132->addr[endp->usb_addr].address;
1475 struct urb *urb = endp->urb_list[ENDP_QUEUE_MASK &
1476 endp->queue_next];
1477 endp->active = 1;
1478 ring->curr_endp = endp;
1479 ring->in_use = 1;
1480 up(&u132->scheduler_lock);
1481 retval = edset_setup(u132, ring, endp, urb, address,
1482 0x2, u132_hcd_configure_setup_sent);
1483 if (retval == 0) {
1484 } else
1485 u132_hcd_giveback_urb(u132, endp, urb, retval);
1486 return;
1487 }
1488 } else {
1489 if (endp->input) {
1490 u8 address = u132->addr[endp->usb_addr].address;
1491 if (ring->in_use) {
1492 up(&u132->scheduler_lock);
1493 u132_endp_put_kref(u132, endp);
1494 return;
1495 } else {
1496 int retval;
1497 struct urb *urb = endp->urb_list[
1498 ENDP_QUEUE_MASK & endp->queue_next];
1499 endp->active = 1;
1500 ring->curr_endp = endp;
1501 ring->in_use = 1;
1502 up(&u132->scheduler_lock);
1503 retval = edset_input(u132, ring, endp, urb,
1504 address, endp->toggle_bits,
1505 u132_hcd_bulk_input_recv);
1506 if (retval == 0) {
1507 } else
1508 u132_hcd_giveback_urb(u132, endp, urb,
1509 retval);
1510 return;
1511 }
1512 } else { /* output pipe */
1513 u8 address = u132->addr[endp->usb_addr].address;
1514 if (ring->in_use) {
1515 up(&u132->scheduler_lock);
1516 u132_endp_put_kref(u132, endp);
1517 return;
1518 } else {
1519 int retval;
1520 struct urb *urb = endp->urb_list[
1521 ENDP_QUEUE_MASK & endp->queue_next];
1522 endp->active = 1;
1523 ring->curr_endp = endp;
1524 ring->in_use = 1;
1525 up(&u132->scheduler_lock);
1526 retval = edset_output(u132, ring, endp, urb,
1527 address, endp->toggle_bits,
1528 u132_hcd_bulk_output_sent);
1529 if (retval == 0) {
1530 } else
1531 u132_hcd_giveback_urb(u132, endp, urb,
1532 retval);
1533 return;
1534 }
1535 }
1536 }
1537}
1538
1539static void port_power(struct u132 *u132, int pn, int is_on)
1540{
1541 u132->port[pn].power = is_on;
1542}
1543
1544static void u132_power(struct u132 *u132, int is_on)
1545{
1546 struct usb_hcd *hcd = u132_to_hcd(u132)
1547 ; /* hub is inactive unless the port is powered */
1548 if (is_on) {
1549 if (u132->power)
1550 return;
1551 u132->power = 1;
1552 hcd->self.controller->power.power_state = PMSG_ON;
1553 } else {
1554 u132->power = 0;
1555 hcd->state = HC_STATE_HALT;
1556 hcd->self.controller->power.power_state = PMSG_SUSPEND;
1557 }
1558}
1559
1560static int u132_periodic_reinit(struct u132 *u132)
1561{
1562 int retval;
1563 u32 fi = u132->hc_fminterval & 0x03fff;
1564 u32 fit;
1565 u32 fminterval;
1566 retval = u132_read_pcimem(u132, fminterval, &fminterval);
1567 if (retval)
1568 return retval;
1569 fit = fminterval & FIT;
1570 retval = u132_write_pcimem(u132, fminterval,
1571 (fit ^ FIT) | u132->hc_fminterval);
1572 if (retval)
1573 return retval;
1574 retval = u132_write_pcimem(u132, periodicstart,
1575 ((9 *fi) / 10) & 0x3fff);
1576 if (retval)
1577 return retval;
1578 return 0;
1579}
1580
1581static char *hcfs2string(int state)
1582{
1583 switch (state) {
1584 case OHCI_USB_RESET:
1585 return "reset";
1586 case OHCI_USB_RESUME:
1587 return "resume";
1588 case OHCI_USB_OPER:
1589 return "operational";
1590 case OHCI_USB_SUSPEND:
1591 return "suspend";
1592 }
1593 return "?";
1594}
1595
1596static int u132_usb_reset(struct u132 *u132)
1597{
1598 int retval;
1599 retval = u132_read_pcimem(u132, control, &u132->hc_control);
1600 if (retval)
1601 return retval;
1602 u132->hc_control &= OHCI_CTRL_RWC;
1603 retval = u132_write_pcimem(u132, control, u132->hc_control);
1604 if (retval)
1605 return retval;
1606 return 0;
1607}
1608
1609static int u132_init(struct u132 *u132)
1610{
1611 int retval;
1612 u32 control;
1613 u132_disable(u132);
1614 u132->next_statechange =
1615 jiffies; /* SMM owns the HC? not for long! */ {
1616 u32 control;
1617 retval = u132_read_pcimem(u132, control, &control);
1618 if (retval)
1619 return retval;
1620 if (control & OHCI_CTRL_IR) {
1621 u32 temp = 50;
1622 retval = u132_write_pcimem(u132, intrenable,
1623 OHCI_INTR_OC);
1624 if (retval)
1625 return retval;
1626 retval = u132_write_pcimem_byte(u132, cmdstatus,
1627 OHCI_OCR);
1628 if (retval)
1629 return retval;
1630 check:{
1631 retval = u132_read_pcimem(u132, control,
1632 &control);
1633 if (retval)
1634 return retval;
1635 }
1636 if (control & OHCI_CTRL_IR) {
1637 msleep(10);
1638 if (--temp == 0) {
1639 dev_err(&u132->platform_dev->dev, "USB "
1640 "HC takeover failed!(BIOS/SMM b"
1641 "ug) control=%08X\n", control);
1642 return -EBUSY;
1643 }
1644 goto check;
1645 }
1646 u132_usb_reset(u132);
1647 }
1648 }
1649 retval = u132_write_pcimem(u132, intrdisable, OHCI_INTR_MIE);
1650 if (retval)
1651 return retval;
1652 retval = u132_read_pcimem(u132, control, &control);
1653 if (retval)
1654 return retval;
1655 if (u132->num_ports == 0) {
1656 u32 rh_a = -1;
1657 retval = u132_read_pcimem(u132, roothub.a, &rh_a);
1658 if (retval)
1659 return retval;
1660 u132->num_ports = rh_a & RH_A_NDP;
1661 retval = read_roothub_info(u132);
1662 if (retval)
1663 return retval;
1664 }
1665 if (u132->num_ports > MAX_U132_PORTS) {
1666 return -EINVAL;
1667 }
1668 return 0;
1669}
1670
1671
1672/* Start an OHCI controller, set the BUS operational
1673* resets USB and controller
1674* enable interrupts
1675*/
1676static int u132_run(struct u132 *u132)
1677{
1678 int retval;
1679 u32 control;
1680 u32 status;
1681 u32 fminterval;
1682 u32 periodicstart;
1683 u32 cmdstatus;
1684 u32 roothub_a;
1685 int mask = OHCI_INTR_INIT;
1686 int first = u132->hc_fminterval == 0;
1687 int sleep_time = 0;
1688 int reset_timeout = 30; /* ... allow extra time */
1689 u132_disable(u132);
1690 if (first) {
1691 u32 temp;
1692 retval = u132_read_pcimem(u132, fminterval, &temp);
1693 if (retval)
1694 return retval;
1695 u132->hc_fminterval = temp & 0x3fff;
1696 if (u132->hc_fminterval != FI) {
1697 }
1698 u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16;
1699 }
1700 retval = u132_read_pcimem(u132, control, &u132->hc_control);
1701 if (retval)
1702 return retval;
1703 dev_info(&u132->platform_dev->dev, "resetting from state '%s', control "
1704 "= %08X\n", hcfs2string(u132->hc_control & OHCI_CTRL_HCFS),
1705 u132->hc_control);
1706 switch (u132->hc_control & OHCI_CTRL_HCFS) {
1707 case OHCI_USB_OPER:
1708 sleep_time = 0;
1709 break;
1710 case OHCI_USB_SUSPEND:
1711 case OHCI_USB_RESUME:
1712 u132->hc_control &= OHCI_CTRL_RWC;
1713 u132->hc_control |= OHCI_USB_RESUME;
1714 sleep_time = 10;
1715 break;
1716 default:
1717 u132->hc_control &= OHCI_CTRL_RWC;
1718 u132->hc_control |= OHCI_USB_RESET;
1719 sleep_time = 50;
1720 break;
1721 }
1722 retval = u132_write_pcimem(u132, control, u132->hc_control);
1723 if (retval)
1724 return retval;
1725 retval = u132_read_pcimem(u132, control, &control);
1726 if (retval)
1727 return retval;
1728 msleep(sleep_time);
1729 retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
1730 if (retval)
1731 return retval;
1732 if (!(roothub_a & RH_A_NPS)) {
1733 int temp; /* power down each port */
1734 for (temp = 0; temp < u132->num_ports; temp++) {
1735 retval = u132_write_pcimem(u132,
1736 roothub.portstatus[temp], RH_PS_LSDA);
1737 if (retval)
1738 return retval;
1739 }
1740 }
1741 retval = u132_read_pcimem(u132, control, &control);
1742 if (retval)
1743 return retval;
1744 retry:retval = u132_read_pcimem(u132, cmdstatus, &status);
1745 if (retval)
1746 return retval;
1747 retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_HCR);
1748 if (retval)
1749 return retval;
1750 extra:{
1751 retval = u132_read_pcimem(u132, cmdstatus, &status);
1752 if (retval)
1753 return retval;
1754 if (0 != (status & OHCI_HCR)) {
1755 if (--reset_timeout == 0) {
1756 dev_err(&u132->platform_dev->dev, "USB HC reset"
1757 " timed out!\n");
1758 return -ENODEV;
1759 } else {
1760 msleep(5);
1761 goto extra;
1762 }
1763 }
1764 }
1765 if (u132->flags & OHCI_QUIRK_INITRESET) {
1766 retval = u132_write_pcimem(u132, control, u132->hc_control);
1767 if (retval)
1768 return retval;
1769 retval = u132_read_pcimem(u132, control, &control);
1770 if (retval)
1771 return retval;
1772 }
1773 retval = u132_write_pcimem(u132, ed_controlhead, 0x00000000);
1774 if (retval)
1775 return retval;
1776 retval = u132_write_pcimem(u132, ed_bulkhead, 0x11000000);
1777 if (retval)
1778 return retval;
1779 retval = u132_write_pcimem(u132, hcca, 0x00000000);
1780 if (retval)
1781 return retval;
1782 retval = u132_periodic_reinit(u132);
1783 if (retval)
1784 return retval;
1785 retval = u132_read_pcimem(u132, fminterval, &fminterval);
1786 if (retval)
1787 return retval;
1788 retval = u132_read_pcimem(u132, periodicstart, &periodicstart);
1789 if (retval)
1790 return retval;
1791 if (0 == (fminterval & 0x3fff0000) || 0 == periodicstart) {
1792 if (!(u132->flags & OHCI_QUIRK_INITRESET)) {
1793 u132->flags |= OHCI_QUIRK_INITRESET;
1794 goto retry;
1795 } else
1796 dev_err(&u132->platform_dev->dev, "init err(%08x %04x)"
1797 "\n", fminterval, periodicstart);
1798 } /* start controller operations */
1799 u132->hc_control &= OHCI_CTRL_RWC;
1800 u132->hc_control |= OHCI_CONTROL_INIT | OHCI_CTRL_BLE | OHCI_USB_OPER;
1801 retval = u132_write_pcimem(u132, control, u132->hc_control);
1802 if (retval)
1803 return retval;
1804 retval = u132_write_pcimem_byte(u132, cmdstatus, OHCI_BLF);
1805 if (retval)
1806 return retval;
1807 retval = u132_read_pcimem(u132, cmdstatus, &cmdstatus);
1808 if (retval)
1809 return retval;
1810 retval = u132_read_pcimem(u132, control, &control);
1811 if (retval)
1812 return retval;
1813 u132_to_hcd(u132)->state = HC_STATE_RUNNING;
1814 retval = u132_write_pcimem(u132, roothub.status, RH_HS_DRWE);
1815 if (retval)
1816 return retval;
1817 retval = u132_write_pcimem(u132, intrstatus, mask);
1818 if (retval)
1819 return retval;
1820 retval = u132_write_pcimem(u132, intrdisable,
1821 OHCI_INTR_MIE | OHCI_INTR_OC | OHCI_INTR_RHSC | OHCI_INTR_FNO |
1822 OHCI_INTR_UE | OHCI_INTR_RD | OHCI_INTR_SF | OHCI_INTR_WDH |
1823 OHCI_INTR_SO);
1824 if (retval)
1825 return retval; /* handle root hub init quirks ... */
1826 retval = u132_read_pcimem(u132, roothub.a, &roothub_a);
1827 if (retval)
1828 return retval;
1829 roothub_a &= ~(RH_A_PSM | RH_A_OCPM);
1830 if (u132->flags & OHCI_QUIRK_SUPERIO) {
1831 roothub_a |= RH_A_NOCP;
1832 roothub_a &= ~(RH_A_POTPGT | RH_A_NPS);
1833 retval = u132_write_pcimem(u132, roothub.a, roothub_a);
1834 if (retval)
1835 return retval;
1836 } else if ((u132->flags & OHCI_QUIRK_AMD756) || distrust_firmware) {
1837 roothub_a |= RH_A_NPS;
1838 retval = u132_write_pcimem(u132, roothub.a, roothub_a);
1839 if (retval)
1840 return retval;
1841 }
1842 retval = u132_write_pcimem(u132, roothub.status, RH_HS_LPSC);
1843 if (retval)
1844 return retval;
1845 retval = u132_write_pcimem(u132, roothub.b,
1846 (roothub_a & RH_A_NPS) ? 0 : RH_B_PPCM);
1847 if (retval)
1848 return retval;
1849 retval = u132_read_pcimem(u132, control, &control);
1850 if (retval)
1851 return retval;
1852 mdelay((roothub_a >> 23) & 0x1fe);
1853 u132_to_hcd(u132)->state = HC_STATE_RUNNING;
1854 return 0;
1855}
1856
1857static void u132_hcd_stop(struct usb_hcd *hcd)
1858{
1859 struct u132 *u132 = hcd_to_u132(hcd);
1860 if (u132->going > 1) {
1861 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1862 , u132->going);
1863 } else if (u132->going > 0) {
1864 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
1865 "ed\n", hcd);
1866 } else {
1867 down(&u132->sw_lock);
1868 msleep(100);
1869 u132_power(u132, 0);
1870 up(&u132->sw_lock);
1871 }
1872}
1873
1874static int u132_hcd_start(struct usb_hcd *hcd)
1875{
1876 struct u132 *u132 = hcd_to_u132(hcd);
1877 if (u132->going > 1) {
1878 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1879 , u132->going);
1880 return -ENODEV;
1881 } else if (u132->going > 0) {
1882 dev_err(&u132->platform_dev->dev, "device is being removed\n");
1883 return -ESHUTDOWN;
1884 } else if (hcd->self.controller) {
1885 int retval;
1886 struct platform_device *pdev =
1887 to_platform_device(hcd->self.controller);
1888 u16 vendor = ((struct u132_platform_data *)
1889 (pdev->dev.platform_data))->vendor;
1890 u16 device = ((struct u132_platform_data *)
1891 (pdev->dev.platform_data))->device;
1892 down(&u132->sw_lock);
1893 msleep(10);
1894 if (vendor == PCI_VENDOR_ID_AMD && device == 0x740c) {
1895 u132->flags = OHCI_QUIRK_AMD756;
1896 } else if (vendor == PCI_VENDOR_ID_OPTI && device == 0xc861) {
1897 dev_err(&u132->platform_dev->dev, "WARNING: OPTi workar"
1898 "ounds unavailable\n");
1899 } else if (vendor == PCI_VENDOR_ID_COMPAQ && device == 0xa0f8)
1900 u132->flags |= OHCI_QUIRK_ZFMICRO;
1901 retval = u132_run(u132);
1902 if (retval) {
1903 u132_disable(u132);
1904 u132->going = 1;
1905 }
1906 msleep(100);
1907 up(&u132->sw_lock);
1908 return retval;
1909 } else {
1910 dev_err(&u132->platform_dev->dev, "platform_device missing\n");
1911 return -ENODEV;
1912 }
1913}
1914
1915static int u132_hcd_reset(struct usb_hcd *hcd)
1916{
1917 struct u132 *u132 = hcd_to_u132(hcd);
1918 if (u132->going > 1) {
1919 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
1920 , u132->going);
1921 return -ENODEV;
1922 } else if (u132->going > 0) {
1923 dev_err(&u132->platform_dev->dev, "device is being removed\n");
1924 return -ESHUTDOWN;
1925 } else {
1926 int retval;
1927 down(&u132->sw_lock);
1928 retval = u132_init(u132);
1929 if (retval) {
1930 u132_disable(u132);
1931 u132->going = 1;
1932 }
1933 up(&u132->sw_lock);
1934 return retval;
1935 }
1936}
1937
1938static int create_endpoint_and_queue_int(struct u132 *u132,
1939 struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb,
1940 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
1941 gfp_t mem_flags)
1942{
1943 struct u132_ring *ring;
1944 unsigned long irqs;
1945 u8 endp_number = ++u132->num_endpoints;
1946 struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
1947 kmalloc(sizeof(struct u132_endp), mem_flags);
1948 if (!endp) {
1949 return -ENOMEM;
1950 }
1951 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
1952 spin_lock_init(&endp->queue_lock.slock);
1953 INIT_LIST_HEAD(&endp->urb_more);
1954 ring = endp->ring = &u132->ring[0];
1955 if (ring->curr_endp) {
1956 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
1957 } else {
1958 INIT_LIST_HEAD(&endp->endp_ring);
1959 ring->curr_endp = endp;
1960 }
1961 ring->length += 1;
1962 endp->dequeueing = 0;
1963 endp->edset_flush = 0;
1964 endp->active = 0;
1965 endp->delayed = 0;
1966 endp->endp_number = endp_number;
1967 endp->u132 = u132;
1968 endp->hep = hep;
1969 endp->pipetype = usb_pipetype(urb->pipe);
1970 u132_endp_init_kref(u132, endp);
1971 if (usb_pipein(urb->pipe)) {
1972 endp->toggle_bits = 0x2;
1973 usb_settoggle(udev->usb_device, usb_endp, 0, 0);
1974 endp->input = 1;
1975 endp->output = 0;
1976 udev->endp_number_in[usb_endp] = endp_number;
1977 u132_udev_get_kref(u132, udev);
1978 } else {
1979 endp->toggle_bits = 0x2;
1980 usb_settoggle(udev->usb_device, usb_endp, 1, 0);
1981 endp->input = 0;
1982 endp->output = 1;
1983 udev->endp_number_out[usb_endp] = endp_number;
1984 u132_udev_get_kref(u132, udev);
1985 }
1986 urb->hcpriv = u132;
1987 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
1988 endp->delayed = 1;
1989 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
1990 endp->udev_number = address;
1991 endp->usb_addr = usb_addr;
1992 endp->usb_endp = usb_endp;
1993 endp->queue_size = 1;
1994 endp->queue_last = 0;
1995 endp->queue_next = 0;
1996 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
1997 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
1998 u132_endp_queue_work(u132, endp, msecs_to_jiffies(urb->interval));
1999 return 0;
2000}
2001
2002static int queue_int_on_old_endpoint(struct u132 *u132, struct u132_udev *udev,
2003 struct usb_host_endpoint *hep, struct urb *urb,
2004 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
2005 u8 usb_endp, u8 address)
2006{
2007 urb->hcpriv = u132;
2008 endp->delayed = 1;
2009 endp->jiffies = jiffies + msecs_to_jiffies(urb->interval);
2010 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2011 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2012 } else {
2013 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
2014 GFP_ATOMIC);
2015 if (urbq == NULL) {
2016 endp->queue_size -= 1;
2017 return -ENOMEM;
2018 } else {
2019 list_add_tail(&urbq->urb_more, &endp->urb_more);
2020 urbq->urb = urb;
2021 }
2022 }
2023 return 0;
2024}
2025
2026static int create_endpoint_and_queue_bulk(struct u132 *u132,
2027 struct u132_udev *udev, struct usb_host_endpoint *hep, struct urb *urb,
2028 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp, u8 address,
2029 gfp_t mem_flags)
2030{
2031 int ring_number;
2032 struct u132_ring *ring;
2033 unsigned long irqs;
2034 u8 endp_number = ++u132->num_endpoints;
2035 struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
2036 kmalloc(sizeof(struct u132_endp), mem_flags);
2037 if (!endp) {
2038 return -ENOMEM;
2039 }
2040 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
2041 spin_lock_init(&endp->queue_lock.slock);
2042 INIT_LIST_HEAD(&endp->urb_more);
2043 endp->dequeueing = 0;
2044 endp->edset_flush = 0;
2045 endp->active = 0;
2046 endp->delayed = 0;
2047 endp->endp_number = endp_number;
2048 endp->u132 = u132;
2049 endp->hep = hep;
2050 endp->pipetype = usb_pipetype(urb->pipe);
2051 u132_endp_init_kref(u132, endp);
2052 if (usb_pipein(urb->pipe)) {
2053 endp->toggle_bits = 0x2;
2054 usb_settoggle(udev->usb_device, usb_endp, 0, 0);
2055 ring_number = 3;
2056 endp->input = 1;
2057 endp->output = 0;
2058 udev->endp_number_in[usb_endp] = endp_number;
2059 u132_udev_get_kref(u132, udev);
2060 } else {
2061 endp->toggle_bits = 0x2;
2062 usb_settoggle(udev->usb_device, usb_endp, 1, 0);
2063 ring_number = 2;
2064 endp->input = 0;
2065 endp->output = 1;
2066 udev->endp_number_out[usb_endp] = endp_number;
2067 u132_udev_get_kref(u132, udev);
2068 }
2069 ring = endp->ring = &u132->ring[ring_number - 1];
2070 if (ring->curr_endp) {
2071 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
2072 } else {
2073 INIT_LIST_HEAD(&endp->endp_ring);
2074 ring->curr_endp = endp;
2075 }
2076 ring->length += 1;
2077 urb->hcpriv = u132;
2078 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
2079 endp->udev_number = address;
2080 endp->usb_addr = usb_addr;
2081 endp->usb_endp = usb_endp;
2082 endp->queue_size = 1;
2083 endp->queue_last = 0;
2084 endp->queue_next = 0;
2085 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2086 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2087 u132_endp_queue_work(u132, endp, 0);
2088 return 0;
2089}
2090
2091static int queue_bulk_on_old_endpoint(struct u132 *u132, struct u132_udev *udev,
2092 struct usb_host_endpoint *hep, struct urb *urb,
2093 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
2094 u8 usb_endp, u8 address)
2095{
2096 urb->hcpriv = u132;
2097 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2098 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2099 } else {
2100 struct u132_urbq *urbq = kmalloc(sizeof(struct u132_urbq),
2101 GFP_ATOMIC);
2102 if (urbq == NULL) {
2103 endp->queue_size -= 1;
2104 return -ENOMEM;
2105 } else {
2106 list_add_tail(&urbq->urb_more, &endp->urb_more);
2107 urbq->urb = urb;
2108 }
2109 }
2110 return 0;
2111}
2112
2113static int create_endpoint_and_queue_control(struct u132 *u132,
2114 struct usb_host_endpoint *hep, struct urb *urb,
2115 struct usb_device *usb_dev, u8 usb_addr, u8 usb_endp,
2116 gfp_t mem_flags)
2117{
2118 struct u132_ring *ring;
2119 u8 endp_number = ++u132->num_endpoints;
2120 struct u132_endp *endp = hep->hcpriv = u132->endp[endp_number - 1] =
2121 kmalloc(sizeof(struct u132_endp), mem_flags);
2122 if (!endp) {
2123 return -ENOMEM;
2124 }
2125 INIT_WORK(&endp->scheduler, u132_hcd_endp_work_scheduler, (void *)endp);
2126 spin_lock_init(&endp->queue_lock.slock);
2127 INIT_LIST_HEAD(&endp->urb_more);
2128 ring = endp->ring = &u132->ring[0];
2129 if (ring->curr_endp) {
2130 list_add_tail(&endp->endp_ring, &ring->curr_endp->endp_ring);
2131 } else {
2132 INIT_LIST_HEAD(&endp->endp_ring);
2133 ring->curr_endp = endp;
2134 }
2135 ring->length += 1;
2136 endp->dequeueing = 0;
2137 endp->edset_flush = 0;
2138 endp->active = 0;
2139 endp->delayed = 0;
2140 endp->endp_number = endp_number;
2141 endp->u132 = u132;
2142 endp->hep = hep;
2143 u132_endp_init_kref(u132, endp);
2144 u132_endp_get_kref(u132, endp);
2145 if (usb_addr == 0) {
2146 unsigned long irqs;
2147 u8 address = u132->addr[usb_addr].address;
2148 struct u132_udev *udev = &u132->udev[address];
2149 endp->udev_number = address;
2150 endp->usb_addr = usb_addr;
2151 endp->usb_endp = usb_endp;
2152 endp->input = 1;
2153 endp->output = 1;
2154 endp->pipetype = usb_pipetype(urb->pipe);
2155 u132_udev_init_kref(u132, udev);
2156 u132_udev_get_kref(u132, udev);
2157 udev->endp_number_in[usb_endp] = endp_number;
2158 udev->endp_number_out[usb_endp] = endp_number;
2159 urb->hcpriv = u132;
2160 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
2161 endp->queue_size = 1;
2162 endp->queue_last = 0;
2163 endp->queue_next = 0;
2164 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2165 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2166 u132_endp_queue_work(u132, endp, 0);
2167 return 0;
2168 } else { /*(usb_addr > 0) */
2169 unsigned long irqs;
2170 u8 address = u132->addr[usb_addr].address;
2171 struct u132_udev *udev = &u132->udev[address];
2172 endp->udev_number = address;
2173 endp->usb_addr = usb_addr;
2174 endp->usb_endp = usb_endp;
2175 endp->input = 1;
2176 endp->output = 1;
2177 endp->pipetype = usb_pipetype(urb->pipe);
2178 u132_udev_get_kref(u132, udev);
2179 udev->enumeration = 2;
2180 udev->endp_number_in[usb_endp] = endp_number;
2181 udev->endp_number_out[usb_endp] = endp_number;
2182 urb->hcpriv = u132;
2183 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
2184 endp->queue_size = 1;
2185 endp->queue_last = 0;
2186 endp->queue_next = 0;
2187 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] = urb;
2188 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2189 u132_endp_queue_work(u132, endp, 0);
2190 return 0;
2191 }
2192}
2193
2194static int queue_control_on_old_endpoint(struct u132 *u132,
2195 struct usb_host_endpoint *hep, struct urb *urb,
2196 struct usb_device *usb_dev, struct u132_endp *endp, u8 usb_addr,
2197 u8 usb_endp)
2198{
2199 if (usb_addr == 0) {
2200 if (usb_pipein(urb->pipe)) {
2201 urb->hcpriv = u132;
2202 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2203 endp->urb_list[ENDP_QUEUE_MASK &
2204 endp->queue_last++] = urb;
2205 } else {
2206 struct u132_urbq *urbq =
2207 kmalloc(sizeof(struct u132_urbq),
2208 GFP_ATOMIC);
2209 if (urbq == NULL) {
2210 endp->queue_size -= 1;
2211 return -ENOMEM;
2212 } else {
2213 list_add_tail(&urbq->urb_more,
2214 &endp->urb_more);
2215 urbq->urb = urb;
2216 }
2217 }
2218 return 0;
2219 } else { /* usb_pipeout(urb->pipe) */
2220 struct u132_addr *addr = &u132->addr[usb_dev->devnum];
2221 int I = MAX_U132_UDEVS;
2222 int i = 0;
2223 while (--I > 0) {
2224 struct u132_udev *udev = &u132->udev[++i];
2225 if (udev->usb_device) {
2226 continue;
2227 } else {
2228 udev->enumeration = 1;
2229 u132->addr[0].address = i;
2230 endp->udev_number = i;
2231 udev->udev_number = i;
2232 udev->usb_addr = usb_dev->devnum;
2233 u132_udev_init_kref(u132, udev);
2234 udev->endp_number_in[usb_endp] =
2235 endp->endp_number;
2236 u132_udev_get_kref(u132, udev);
2237 udev->endp_number_out[usb_endp] =
2238 endp->endp_number;
2239 udev->usb_device = usb_dev;
2240 ((u8 *) (urb->setup_packet))[2] =
2241 addr->address = i;
2242 u132_udev_get_kref(u132, udev);
2243 break;
2244 }
2245 }
2246 if (I == 0) {
2247 dev_err(&u132->platform_dev->dev, "run out of d"
2248 "evice space\n");
2249 return -EINVAL;
2250 }
2251 urb->hcpriv = u132;
2252 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2253 endp->urb_list[ENDP_QUEUE_MASK &
2254 endp->queue_last++] = urb;
2255 } else {
2256 struct u132_urbq *urbq =
2257 kmalloc(sizeof(struct u132_urbq),
2258 GFP_ATOMIC);
2259 if (urbq == NULL) {
2260 endp->queue_size -= 1;
2261 return -ENOMEM;
2262 } else {
2263 list_add_tail(&urbq->urb_more,
2264 &endp->urb_more);
2265 urbq->urb = urb;
2266 }
2267 }
2268 return 0;
2269 }
2270 } else { /*(usb_addr > 0) */
2271 u8 address = u132->addr[usb_addr].address;
2272 struct u132_udev *udev = &u132->udev[address];
2273 urb->hcpriv = u132;
2274 if (udev->enumeration == 2) {
2275 } else
2276 udev->enumeration = 2;
2277 if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
2278 endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
2279 urb;
2280 } else {
2281 struct u132_urbq *urbq =
2282 kmalloc(sizeof(struct u132_urbq), GFP_ATOMIC);
2283 if (urbq == NULL) {
2284 endp->queue_size -= 1;
2285 return -ENOMEM;
2286 } else {
2287 list_add_tail(&urbq->urb_more, &endp->urb_more);
2288 urbq->urb = urb;
2289 }
2290 }
2291 return 0;
2292 }
2293}
2294
2295static int u132_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *hep,
2296 struct urb *urb, gfp_t mem_flags)
2297{
2298 struct u132 *u132 = hcd_to_u132(hcd);
2299 if (irqs_disabled()) {
2300 if (__GFP_WAIT & mem_flags) {
2301 printk(KERN_ERR "invalid context for function that migh"
2302 "t sleep\n");
2303 return -EINVAL;
2304 }
2305 }
2306 if (u132->going > 1) {
2307 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2308 , u132->going);
2309 return -ENODEV;
2310 } else if (u132->going > 0) {
2311 dev_err(&u132->platform_dev->dev, "device is being removed urb="
2312 "%p status=%d\n", urb, urb->status);
2313 return -ESHUTDOWN;
2314 } else {
2315 u8 usb_addr = usb_pipedevice(urb->pipe);
2316 u8 usb_endp = usb_pipeendpoint(urb->pipe);
2317 struct usb_device *usb_dev = urb->dev;
2318 if (usb_pipetype(urb->pipe) == PIPE_INTERRUPT) {
2319 u8 address = u132->addr[usb_addr].address;
2320 struct u132_udev *udev = &u132->udev[address];
2321 struct u132_endp *endp = hep->hcpriv;
2322 urb->actual_length = 0;
2323 if (endp) {
2324 unsigned long irqs;
2325 int retval;
2326 spin_lock_irqsave(&endp->queue_lock.slock,
2327 irqs);
2328 retval = queue_int_on_old_endpoint(u132, udev,
2329 hep, urb, usb_dev, endp, usb_addr,
2330 usb_endp, address);
2331 spin_unlock_irqrestore(&endp->queue_lock.slock,
2332 irqs);
2333 if (retval) {
2334 return retval;
2335 } else {
2336 u132_endp_queue_work(u132, endp,
2337 msecs_to_jiffies(urb->interval))
2338 ;
2339 return 0;
2340 }
2341 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2342 return -EINVAL;
2343 } else { /*(endp == NULL) */
2344 return create_endpoint_and_queue_int(u132, udev,
2345 hep, urb, usb_dev, usb_addr, usb_endp,
2346 address, mem_flags);
2347 }
2348 } else if (usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS) {
2349 dev_err(&u132->platform_dev->dev, "the hardware does no"
2350 "t support PIPE_ISOCHRONOUS\n");
2351 return -EINVAL;
2352 } else if (usb_pipetype(urb->pipe) == PIPE_BULK) {
2353 u8 address = u132->addr[usb_addr].address;
2354 struct u132_udev *udev = &u132->udev[address];
2355 struct u132_endp *endp = hep->hcpriv;
2356 urb->actual_length = 0;
2357 if (endp) {
2358 unsigned long irqs;
2359 int retval;
2360 spin_lock_irqsave(&endp->queue_lock.slock,
2361 irqs);
2362 retval = queue_bulk_on_old_endpoint(u132, udev,
2363 hep, urb, usb_dev, endp, usb_addr,
2364 usb_endp, address);
2365 spin_unlock_irqrestore(&endp->queue_lock.slock,
2366 irqs);
2367 if (retval) {
2368 return retval;
2369 } else {
2370 u132_endp_queue_work(u132, endp, 0);
2371 return 0;
2372 }
2373 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2374 return -EINVAL;
2375 } else
2376 return create_endpoint_and_queue_bulk(u132,
2377 udev, hep, urb, usb_dev, usb_addr,
2378 usb_endp, address, mem_flags);
2379 } else {
2380 struct u132_endp *endp = hep->hcpriv;
2381 u16 urb_size = 8;
2382 u8 *b = urb->setup_packet;
2383 int i = 0;
2384 char data[30 *3 + 4];
2385 char *d = data;
2386 int m = (sizeof(data) - 1) / 3;
2387 int l = 0;
2388 data[0] = 0;
2389 while (urb_size-- > 0) {
2390 if (i > m) {
2391 } else if (i++ < m) {
2392 int w = sprintf(d, " %02X", *b++);
2393 d += w;
2394 l += w;
2395 } else
2396 d += sprintf(d, " ..");
2397 }
2398 if (endp) {
2399 unsigned long irqs;
2400 int retval;
2401 spin_lock_irqsave(&endp->queue_lock.slock,
2402 irqs);
2403 retval = queue_control_on_old_endpoint(u132,
2404 hep, urb, usb_dev, endp, usb_addr,
2405 usb_endp);
2406 spin_unlock_irqrestore(&endp->queue_lock.slock,
2407 irqs);
2408 if (retval) {
2409 return retval;
2410 } else {
2411 u132_endp_queue_work(u132, endp, 0);
2412 return 0;
2413 }
2414 } else if (u132->num_endpoints == MAX_U132_ENDPS) {
2415 return -EINVAL;
2416 } else
2417 return create_endpoint_and_queue_control(u132,
2418 hep, urb, usb_dev, usb_addr, usb_endp,
2419 mem_flags);
2420 }
2421 }
2422}
2423
2424static int dequeue_from_overflow_chain(struct u132 *u132,
2425 struct u132_endp *endp, struct urb *urb)
2426{
2427 struct list_head *scan;
2428 struct list_head *head = &endp->urb_more;
2429 list_for_each(scan, head) {
2430 struct u132_urbq *urbq = list_entry(scan, struct u132_urbq,
2431 urb_more);
2432 if (urbq->urb == urb) {
2433 struct usb_hcd *hcd = u132_to_hcd(u132);
2434 list_del(scan);
2435 endp->queue_size -= 1;
2436 urb->error_count = 0;
2437 urb->hcpriv = NULL;
2438 usb_hcd_giveback_urb(hcd, urb, NULL);
2439 return 0;
2440 } else
2441 continue;
2442 }
2443 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]=%p ring"
2444 "[%d] %c%c usb_endp=%d usb_addr=%d size=%d next=%04X last=%04X"
2445 "\n", urb, endp->endp_number, endp, endp->ring->number,
2446 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
2447 endp->usb_endp, endp->usb_addr, endp->queue_size,
2448 endp->queue_next, endp->queue_last);
2449 return -EINVAL;
2450}
2451
2452static int u132_endp_urb_dequeue(struct u132 *u132, struct u132_endp *endp,
2453 struct urb *urb)
2454{
2455 unsigned long irqs;
2456 spin_lock_irqsave(&endp->queue_lock.slock, irqs);
2457 if (endp->queue_size == 0) {
2458 dev_err(&u132->platform_dev->dev, "urb=%p not found in endp[%d]"
2459 "=%p ring[%d] %c%c usb_endp=%d usb_addr=%d\n", urb,
2460 endp->endp_number, endp, endp->ring->number,
2461 endp->input ? 'I' : ' ', endp->output ? 'O' : ' ',
2462 endp->usb_endp, endp->usb_addr);
2463 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2464 return -EINVAL;
2465 }
2466 if (urb == endp->urb_list[ENDP_QUEUE_MASK & endp->queue_next]) {
2467 if (endp->active) {
2468 endp->dequeueing = 1;
2469 endp->edset_flush = 1;
2470 u132_endp_queue_work(u132, endp, 0);
2471 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2472 urb->hcpriv = NULL;
2473 return 0;
2474 } else {
2475 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2476 u132_hcd_abandon_urb(u132, endp, urb, urb->status);
2477 return 0;
2478 }
2479 } else {
2480 u16 queue_list = 0;
2481 u16 queue_size = endp->queue_size;
2482 u16 queue_scan = endp->queue_next;
2483 struct urb **urb_slot = NULL;
2484 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
2485 if (urb == endp->urb_list[ENDP_QUEUE_MASK &
2486 ++queue_scan]) {
2487 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
2488 queue_scan];
2489 break;
2490 } else
2491 continue;
2492 }
2493 while (++queue_list < ENDP_QUEUE_SIZE && --queue_size > 0) {
2494 *urb_slot = endp->urb_list[ENDP_QUEUE_MASK &
2495 ++queue_scan];
2496 urb_slot = &endp->urb_list[ENDP_QUEUE_MASK &
2497 queue_scan];
2498 }
2499 if (urb_slot) {
2500 struct usb_hcd *hcd = u132_to_hcd(u132);
2501 endp->queue_size -= 1;
2502 if (list_empty(&endp->urb_more)) {
2503 spin_unlock_irqrestore(&endp->queue_lock.slock,
2504 irqs);
2505 } else {
2506 struct list_head *next = endp->urb_more.next;
2507 struct u132_urbq *urbq = list_entry(next,
2508 struct u132_urbq, urb_more);
2509 list_del(next);
2510 *urb_slot = urbq->urb;
2511 spin_unlock_irqrestore(&endp->queue_lock.slock,
2512 irqs);
2513 kfree(urbq);
2514 } urb->error_count = 0;
2515 urb->hcpriv = NULL;
2516 usb_hcd_giveback_urb(hcd, urb, NULL);
2517 return 0;
2518 } else if (list_empty(&endp->urb_more)) {
2519 dev_err(&u132->platform_dev->dev, "urb=%p not found in "
2520 "endp[%d]=%p ring[%d] %c%c usb_endp=%d usb_addr"
2521 "=%d size=%d next=%04X last=%04X\n", urb,
2522 endp->endp_number, endp, endp->ring->number,
2523 endp->input ? 'I' : ' ',
2524 endp->output ? 'O' : ' ', endp->usb_endp,
2525 endp->usb_addr, endp->queue_size,
2526 endp->queue_next, endp->queue_last);
2527 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2528 return -EINVAL;
2529 } else {
2530 int retval = dequeue_from_overflow_chain(u132, endp,
2531 urb);
2532 spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
2533 return retval;
2534 }
2535 }
2536}
2537
2538static int u132_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
2539{
2540 struct u132 *u132 = hcd_to_u132(hcd);
2541 if (u132->going > 2) {
2542 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2543 , u132->going);
2544 return -ENODEV;
2545 } else {
2546 u8 usb_addr = usb_pipedevice(urb->pipe);
2547 u8 usb_endp = usb_pipeendpoint(urb->pipe);
2548 u8 address = u132->addr[usb_addr].address;
2549 struct u132_udev *udev = &u132->udev[address];
2550 if (usb_pipein(urb->pipe)) {
2551 u8 endp_number = udev->endp_number_in[usb_endp];
2552 struct u132_endp *endp = u132->endp[endp_number - 1];
2553 return u132_endp_urb_dequeue(u132, endp, urb);
2554 } else {
2555 u8 endp_number = udev->endp_number_out[usb_endp];
2556 struct u132_endp *endp = u132->endp[endp_number - 1];
2557 return u132_endp_urb_dequeue(u132, endp, urb);
2558 }
2559 }
2560}
2561
2562static void u132_endpoint_disable(struct usb_hcd *hcd,
2563 struct usb_host_endpoint *hep)
2564{
2565 struct u132 *u132 = hcd_to_u132(hcd);
2566 if (u132->going > 2) {
2567 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2568 , u132->going);
2569 } else {
2570 struct u132_endp *endp = hep->hcpriv;
2571 if (endp)
2572 u132_endp_put_kref(u132, endp);
2573 }
2574}
2575
2576static int u132_get_frame(struct usb_hcd *hcd)
2577{
2578 struct u132 *u132 = hcd_to_u132(hcd);
2579 if (u132->going > 1) {
2580 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2581 , u132->going);
2582 return -ENODEV;
2583 } else if (u132->going > 0) {
2584 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2585 return -ESHUTDOWN;
2586 } else {
2587 int frame = 0;
2588 dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n");
2589 msleep(100);
2590 return frame;
2591 }
2592}
2593
2594static int u132_roothub_descriptor(struct u132 *u132,
2595 struct usb_hub_descriptor *desc)
2596{
2597 int retval;
2598 u16 temp;
2599 u32 rh_a = -1;
2600 u32 rh_b = -1;
2601 retval = u132_read_pcimem(u132, roothub.a, &rh_a);
2602 if (retval)
2603 return retval;
2604 desc->bDescriptorType = 0x29;
2605 desc->bPwrOn2PwrGood = (rh_a & RH_A_POTPGT) >> 24;
2606 desc->bHubContrCurrent = 0;
2607 desc->bNbrPorts = u132->num_ports;
2608 temp = 1 + (u132->num_ports / 8);
2609 desc->bDescLength = 7 + 2 *temp;
2610 temp = 0;
2611 if (rh_a & RH_A_NPS)
2612 temp |= 0x0002;
2613 if (rh_a & RH_A_PSM)
2614 temp |= 0x0001;
2615 if (rh_a & RH_A_NOCP) {
2616 temp |= 0x0010;
2617 } else if (rh_a & RH_A_OCPM)
2618 temp |= 0x0008;
2619 desc->wHubCharacteristics = cpu_to_le16(temp);
2620 retval = u132_read_pcimem(u132, roothub.b, &rh_b);
2621 if (retval)
2622 return retval;
2623 memset(desc->bitmap, 0xff, sizeof(desc->bitmap));
2624 desc->bitmap[0] = rh_b & RH_B_DR;
2625 if (u132->num_ports > 7) {
2626 desc->bitmap[1] = (rh_b & RH_B_DR) >> 8;
2627 desc->bitmap[2] = 0xff;
2628 } else
2629 desc->bitmap[1] = 0xff;
2630 return 0;
2631}
2632
2633static int u132_roothub_status(struct u132 *u132, __le32 *desc)
2634{
2635 u32 rh_status = -1;
2636 int ret_status = u132_read_pcimem(u132, roothub.status, &rh_status);
2637 *desc = cpu_to_le32(rh_status);
2638 return ret_status;
2639}
2640
2641static int u132_roothub_portstatus(struct u132 *u132, __le32 *desc, u16 wIndex)
2642{
2643 if (wIndex == 0 || wIndex > u132->num_ports) {
2644 return -EINVAL;
2645 } else {
2646 int port = wIndex - 1;
2647 u32 rh_portstatus = -1;
2648 int ret_portstatus = u132_read_pcimem(u132,
2649 roothub.portstatus[port], &rh_portstatus);
2650 *desc = cpu_to_le32(rh_portstatus);
2651 if (*(u16 *) (desc + 2)) {
2652 dev_info(&u132->platform_dev->dev, "Port %d Status Chan"
2653 "ge = %08X\n", port, *desc);
2654 }
2655 return ret_portstatus;
2656 }
2657}
2658
2659
2660/* this timer value might be vendor-specific ... */
2661#define PORT_RESET_HW_MSEC 10
2662#define PORT_RESET_MSEC 10
2663/* wrap-aware logic morphed from <linux/jiffies.h> */
2664#define tick_before(t1, t2) ((s16)(((s16)(t1))-((s16)(t2))) < 0)
2665static int u132_roothub_portreset(struct u132 *u132, int port_index)
2666{
2667 int retval;
2668 u32 fmnumber;
2669 u16 now;
2670 u16 reset_done;
2671 retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
2672 if (retval)
2673 return retval;
2674 now = fmnumber;
2675 reset_done = now + PORT_RESET_MSEC;
2676 do {
2677 u32 portstat;
2678 do {
2679 retval = u132_read_pcimem(u132,
2680 roothub.portstatus[port_index], &portstat);
2681 if (retval)
2682 return retval;
2683 if (RH_PS_PRS & portstat) {
2684 continue;
2685 } else
2686 break;
2687 } while (tick_before(now, reset_done));
2688 if (RH_PS_PRS & portstat)
2689 return -ENODEV;
2690 if (RH_PS_CCS & portstat) {
2691 if (RH_PS_PRSC & portstat) {
2692 retval = u132_write_pcimem(u132,
2693 roothub.portstatus[port_index],
2694 RH_PS_PRSC);
2695 if (retval)
2696 return retval;
2697 }
2698 } else
2699 break; /* start the next reset,
2700 sleep till it's probably done */
2701 retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
2702 RH_PS_PRS);
2703 if (retval)
2704 return retval;
2705 msleep(PORT_RESET_HW_MSEC);
2706 retval = u132_read_pcimem(u132, fmnumber, &fmnumber);
2707 if (retval)
2708 return retval;
2709 now = fmnumber;
2710 } while (tick_before(now, reset_done));
2711 return 0;
2712}
2713
2714static int u132_roothub_setportfeature(struct u132 *u132, u16 wValue,
2715 u16 wIndex)
2716{
2717 if (wIndex == 0 || wIndex > u132->num_ports) {
2718 return -EINVAL;
2719 } else {
2720 int retval;
2721 int port_index = wIndex - 1;
2722 struct u132_port *port = &u132->port[port_index];
2723 port->Status &= ~(1 << wValue);
2724 switch (wValue) {
2725 case USB_PORT_FEAT_SUSPEND:
2726 retval = u132_write_pcimem(u132,
2727 roothub.portstatus[port_index], RH_PS_PSS);
2728 if (retval)
2729 return retval;
2730 return 0;
2731 case USB_PORT_FEAT_POWER:
2732 retval = u132_write_pcimem(u132,
2733 roothub.portstatus[port_index], RH_PS_PPS);
2734 if (retval)
2735 return retval;
2736 return 0;
2737 case USB_PORT_FEAT_RESET:
2738 retval = u132_roothub_portreset(u132, port_index);
2739 if (retval)
2740 return retval;
2741 return 0;
2742 default:
2743 return -EPIPE;
2744 }
2745 }
2746}
2747
2748static int u132_roothub_clearportfeature(struct u132 *u132, u16 wValue,
2749 u16 wIndex)
2750{
2751 if (wIndex == 0 || wIndex > u132->num_ports) {
2752 return -EINVAL;
2753 } else {
2754 int port_index = wIndex - 1;
2755 u32 temp;
2756 int retval;
2757 struct u132_port *port = &u132->port[port_index];
2758 port->Status &= ~(1 << wValue);
2759 switch (wValue) {
2760 case USB_PORT_FEAT_ENABLE:
2761 temp = RH_PS_CCS;
2762 break;
2763 case USB_PORT_FEAT_C_ENABLE:
2764 temp = RH_PS_PESC;
2765 break;
2766 case USB_PORT_FEAT_SUSPEND:
2767 temp = RH_PS_POCI;
2768 if ((u132->hc_control & OHCI_CTRL_HCFS)
2769 != OHCI_USB_OPER) {
2770 dev_err(&u132->platform_dev->dev, "TODO resume_"
2771 "root_hub\n");
2772 }
2773 break;
2774 case USB_PORT_FEAT_C_SUSPEND:
2775 temp = RH_PS_PSSC;
2776 break;
2777 case USB_PORT_FEAT_POWER:
2778 temp = RH_PS_LSDA;
2779 break;
2780 case USB_PORT_FEAT_C_CONNECTION:
2781 temp = RH_PS_CSC;
2782 break;
2783 case USB_PORT_FEAT_C_OVER_CURRENT:
2784 temp = RH_PS_OCIC;
2785 break;
2786 case USB_PORT_FEAT_C_RESET:
2787 temp = RH_PS_PRSC;
2788 break;
2789 default:
2790 return -EPIPE;
2791 }
2792 retval = u132_write_pcimem(u132, roothub.portstatus[port_index],
2793 temp);
2794 if (retval)
2795 return retval;
2796 return 0;
2797 }
2798}
2799
2800
2801/* the virtual root hub timer IRQ checks for hub status*/
2802static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
2803{
2804 struct u132 *u132 = hcd_to_u132(hcd);
2805 if (u132->going > 1) {
2806 dev_err(&u132->platform_dev->dev, "device hcd=%p has been remov"
2807 "ed %d\n", hcd, u132->going);
2808 return -ENODEV;
2809 } else if (u132->going > 0) {
2810 dev_err(&u132->platform_dev->dev, "device hcd=%p is being remov"
2811 "ed\n", hcd);
2812 dump_stack();
2813 return -ESHUTDOWN;
2814 } else {
2815 int i, changed = 0, length = 1;
2816 if (u132->flags & OHCI_QUIRK_AMD756) {
2817 if ((u132->hc_roothub_a & RH_A_NDP) > MAX_ROOT_PORTS) {
2818 dev_err(&u132->platform_dev->dev, "bogus NDP, r"
2819 "ereads as NDP=%d\n",
2820 u132->hc_roothub_a & RH_A_NDP);
2821 goto done;
2822 }
2823 }
2824 if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) {
2825 buf[0] = changed = 1;
2826 } else
2827 buf[0] = 0;
2828 if (u132->num_ports > 7) {
2829 buf[1] = 0;
2830 length++;
2831 }
2832 for (i = 0; i < u132->num_ports; i++) {
2833 if (u132->hc_roothub_portstatus[i] & (RH_PS_CSC |
2834 RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC |
2835 RH_PS_PRSC)) {
2836 changed = 1;
2837 if (i < 7) {
2838 buf[0] |= 1 << (i + 1);
2839 } else
2840 buf[1] |= 1 << (i - 7);
2841 continue;
2842 }
2843 if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) {
2844 continue;
2845 }
2846 if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) {
2847 continue;
2848 }
2849 }
2850 done:return changed ? length : 0;
2851 }
2852}
2853
2854static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
2855 u16 wIndex, char *buf, u16 wLength)
2856{
2857 struct u132 *u132 = hcd_to_u132(hcd);
2858 if (u132->going > 1) {
2859 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2860 , u132->going);
2861 return -ENODEV;
2862 } else if (u132->going > 0) {
2863 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2864 return -ESHUTDOWN;
2865 } else {
2866 int retval = 0;
2867 down(&u132->sw_lock);
2868 switch (typeReq) {
2869 case ClearHubFeature:
2870 switch (wValue) {
2871 case C_HUB_OVER_CURRENT:
2872 case C_HUB_LOCAL_POWER:
2873 break;
2874 default:
2875 goto stall;
2876 }
2877 break;
2878 case SetHubFeature:
2879 switch (wValue) {
2880 case C_HUB_OVER_CURRENT:
2881 case C_HUB_LOCAL_POWER:
2882 break;
2883 default:
2884 goto stall;
2885 }
2886 break;
2887 case ClearPortFeature:{
2888 retval = u132_roothub_clearportfeature(u132,
2889 wValue, wIndex);
2890 if (retval)
2891 goto error;
2892 break;
2893 }
2894 case GetHubDescriptor:{
2895 retval = u132_roothub_descriptor(u132,
2896 (struct usb_hub_descriptor *)buf);
2897 if (retval)
2898 goto error;
2899 break;
2900 }
2901 case GetHubStatus:{
2902 retval = u132_roothub_status(u132,
2903 (__le32 *) buf);
2904 if (retval)
2905 goto error;
2906 break;
2907 }
2908 case GetPortStatus:{
2909 retval = u132_roothub_portstatus(u132,
2910 (__le32 *) buf, wIndex);
2911 if (retval)
2912 goto error;
2913 break;
2914 }
2915 case SetPortFeature:{
2916 retval = u132_roothub_setportfeature(u132,
2917 wValue, wIndex);
2918 if (retval)
2919 goto error;
2920 break;
2921 }
2922 default:
2923 goto stall;
2924 error:u132_disable(u132);
2925 u132->going = 1;
2926 break;
2927 stall:retval = -EPIPE;
2928 break;
2929 }
2930 up(&u132->sw_lock);
2931 return retval;
2932 }
2933}
2934
2935static int u132_start_port_reset(struct usb_hcd *hcd, unsigned port_num)
2936{
2937 struct u132 *u132 = hcd_to_u132(hcd);
2938 if (u132->going > 1) {
2939 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2940 , u132->going);
2941 return -ENODEV;
2942 } else if (u132->going > 0) {
2943 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2944 return -ESHUTDOWN;
2945 } else
2946 return 0;
2947}
2948
2949static void u132_hub_irq_enable(struct usb_hcd *hcd)
2950{
2951 struct u132 *u132 = hcd_to_u132(hcd);
2952 if (u132->going > 1) {
2953 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2954 , u132->going);
2955 } else if (u132->going > 0)
2956 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2957}
2958
2959
2960#ifdef CONFIG_PM
2961static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message)
2962{
2963 struct u132 *u132 = hcd_to_u132(hcd);
2964 if (u132->going > 1) {
2965 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2966 , u132->going);
2967 return -ENODEV;
2968 } else if (u132->going > 0) {
2969 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2970 return -ESHUTDOWN;
2971 } else
2972 return 0;
2973}
2974
2975static int u132_hcd_resume(struct usb_hcd *hcd)
2976{
2977 struct u132 *u132 = hcd_to_u132(hcd);
2978 if (u132->going > 1) {
2979 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2980 , u132->going);
2981 return -ENODEV;
2982 } else if (u132->going > 0) {
2983 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2984 return -ESHUTDOWN;
2985 } else
2986 return 0;
2987}
2988
2989static int u132_bus_suspend(struct usb_hcd *hcd)
2990{
2991 struct u132 *u132 = hcd_to_u132(hcd);
2992 if (u132->going > 1) {
2993 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
2994 , u132->going);
2995 return -ENODEV;
2996 } else if (u132->going > 0) {
2997 dev_err(&u132->platform_dev->dev, "device is being removed\n");
2998 return -ESHUTDOWN;
2999 } else
3000 return 0;
3001}
3002
3003static int u132_bus_resume(struct usb_hcd *hcd)
3004{
3005 struct u132 *u132 = hcd_to_u132(hcd);
3006 if (u132->going > 1) {
3007 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3008 , u132->going);
3009 return -ENODEV;
3010 } else if (u132->going > 0) {
3011 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3012 return -ESHUTDOWN;
3013 } else
3014 return 0;
3015}
3016
3017#else
3018#define u132_hcd_suspend NULL
3019#define u132_hcd_resume NULL
3020#define u132_bus_suspend NULL
3021#define u132_bus_resume NULL
3022#endif
3023static struct hc_driver u132_hc_driver = {
3024 .description = hcd_name,
3025 .hcd_priv_size = sizeof(struct u132),
3026 .irq = NULL,
3027 .flags = HCD_USB11 | HCD_MEMORY,
3028 .reset = u132_hcd_reset,
3029 .start = u132_hcd_start,
3030 .suspend = u132_hcd_suspend,
3031 .resume = u132_hcd_resume,
3032 .stop = u132_hcd_stop,
3033 .urb_enqueue = u132_urb_enqueue,
3034 .urb_dequeue = u132_urb_dequeue,
3035 .endpoint_disable = u132_endpoint_disable,
3036 .get_frame_number = u132_get_frame,
3037 .hub_status_data = u132_hub_status_data,
3038 .hub_control = u132_hub_control,
3039 .bus_suspend = u132_bus_suspend,
3040 .bus_resume = u132_bus_resume,
3041 .start_port_reset = u132_start_port_reset,
3042 .hub_irq_enable = u132_hub_irq_enable,
3043};
3044
3045/*
3046* This function may be called by the USB core whilst the "usb_all_devices_rwsem"
3047* is held for writing, thus this module must not call usb_remove_hcd()
3048* synchronously - but instead should immediately stop activity to the
3049* device and ansynchronously call usb_remove_hcd()
3050*/
3051static int __devexit u132_remove(struct platform_device *pdev)
3052{
3053 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3054 if (hcd) {
3055 struct u132 *u132 = hcd_to_u132(hcd);
3056 dump_stack();
3057 if (u132->going++ > 1) {
3058 return -ENODEV;
3059 } else {
3060 int rings = MAX_U132_RINGS;
3061 int endps = MAX_U132_ENDPS;
3062 msleep(100);
3063 down(&u132->sw_lock);
3064 u132_monitor_cancel_work(u132);
3065 while (rings-- > 0) {
3066 struct u132_ring *ring = &u132->ring[rings];
3067 u132_ring_cancel_work(u132, ring);
3068 } while (endps-- > 0) {
3069 struct u132_endp *endp = u132->endp[endps];
3070 if (endp)
3071 u132_endp_cancel_work(u132, endp);
3072 }
3073 u132->going += 1;
3074 printk(KERN_INFO "removing device u132.%d\n",
3075 u132->sequence_num);
3076 up(&u132->sw_lock);
3077 usb_remove_hcd(hcd);
3078 u132_u132_put_kref(u132);
3079 return 0;
3080 }
3081 } else
3082 return 0;
3083}
3084
3085static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
3086{
3087 int rings = MAX_U132_RINGS;
3088 int ports = MAX_U132_PORTS;
3089 int addrs = MAX_U132_ADDRS;
3090 int udevs = MAX_U132_UDEVS;
3091 int endps = MAX_U132_ENDPS;
3092 u132->board = pdev->dev.platform_data;
3093 u132->platform_dev = pdev;
3094 u132->power = 0;
3095 u132->reset = 0;
3096 init_MUTEX(&u132->sw_lock);
3097 init_MUTEX(&u132->scheduler_lock);
3098 while (rings-- > 0) {
3099 struct u132_ring *ring = &u132->ring[rings];
3100 ring->u132 = u132;
3101 ring->number = rings + 1;
3102 ring->length = 0;
3103 ring->curr_endp = NULL;
3104 INIT_WORK(&ring->scheduler, u132_hcd_ring_work_scheduler,
3105 (void *)ring);
3106 } down(&u132->sw_lock);
3107 INIT_WORK(&u132->monitor, u132_hcd_monitor_work, (void *)u132);
3108 while (ports-- > 0) {
3109 struct u132_port *port = &u132->port[ports];
3110 port->u132 = u132;
3111 port->reset = 0;
3112 port->enable = 0;
3113 port->power = 0;
3114 port->Status = 0;
3115 } while (addrs-- > 0) {
3116 struct u132_addr *addr = &u132->addr[addrs];
3117 addr->address = 0;
3118 } while (udevs-- > 0) {
3119 struct u132_udev *udev = &u132->udev[udevs];
3120 int i = ARRAY_SIZE(udev->endp_number_in);
3121 int o = ARRAY_SIZE(udev->endp_number_out);
3122 udev->usb_device = NULL;
3123 udev->udev_number = 0;
3124 udev->usb_addr = 0;
3125 udev->portnumber = 0;
3126 while (i-- > 0) {
3127 udev->endp_number_in[i] = 0;
3128 }
3129 while (o-- > 0) {
3130 udev->endp_number_out[o] = 0;
3131 }
3132 }
3133 while (endps-- > 0) {
3134 u132->endp[endps] = NULL;
3135 }
3136 up(&u132->sw_lock);
3137 return;
3138}
3139
3140static int __devinit u132_probe(struct platform_device *pdev)
3141{
3142 struct usb_hcd *hcd;
3143 msleep(100);
3144 if (u132_exiting > 0) {
3145 return -ENODEV;
3146 } /* refuse to confuse usbcore */
3147 if (pdev->dev.dma_mask) {
3148 return -EINVAL;
3149 }
3150 hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id);
3151 if (!hcd) {
3152 printk(KERN_ERR "failed to create the usb hcd struct for U132\n"
3153 );
3154 ftdi_elan_gone_away(pdev);
3155 return -ENOMEM;
3156 } else {
3157 int retval = 0;
3158 struct u132 *u132 = hcd_to_u132(hcd);
3159 hcd->rsrc_start = 0;
3160 down(&u132_module_lock);
3161 list_add_tail(&u132->u132_list, &u132_static_list);
3162 u132->sequence_num = ++u132_instances;
3163 up(&u132_module_lock);
3164 u132_u132_init_kref(u132);
3165 u132_initialise(u132, pdev);
3166 hcd->product_desc = "ELAN U132 Host Controller";
3167 retval = usb_add_hcd(hcd, 0, 0);
3168 if (retval != 0) {
3169 dev_err(&u132->platform_dev->dev, "init error %d\n",
3170 retval);
3171 u132_u132_put_kref(u132);
3172 return retval;
3173 } else {
3174 u132_monitor_queue_work(u132, 100);
3175 return 0;
3176 }
3177 }
3178}
3179
3180
3181#ifdef CONFIG_PM
3182/* for this device there's no useful distinction between the controller
3183* and its root hub, except that the root hub only gets direct PM calls
3184* when CONFIG_USB_SUSPEND is enabled.
3185*/
3186static int u132_suspend(struct platform_device *pdev, pm_message_t state)
3187{
3188 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3189 struct u132 *u132 = hcd_to_u132(hcd);
3190 if (u132->going > 1) {
3191 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3192 , u132->going);
3193 return -ENODEV;
3194 } else if (u132->going > 0) {
3195 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3196 return -ESHUTDOWN;
3197 } else {
3198 int retval = 0;
3199 if (state.event == PM_EVENT_FREEZE) {
3200 retval = u132_bus_suspend(hcd);
3201 } else if (state.event == PM_EVENT_SUSPEND) {
3202 int ports = MAX_U132_PORTS;
3203 while (ports-- > 0) {
3204 port_power(u132, ports, 0);
3205 }
3206 }
3207 if (retval == 0)
3208 pdev->dev.power.power_state = state;
3209 return retval;
3210 }
3211}
3212
3213static int u132_resume(struct platform_device *pdev)
3214{
3215 struct usb_hcd *hcd = platform_get_drvdata(pdev);
3216 struct u132 *u132 = hcd_to_u132(hcd);
3217 if (u132->going > 1) {
3218 dev_err(&u132->platform_dev->dev, "device has been removed %d\n"
3219 , u132->going);
3220 return -ENODEV;
3221 } else if (u132->going > 0) {
3222 dev_err(&u132->platform_dev->dev, "device is being removed\n");
3223 return -ESHUTDOWN;
3224 } else {
3225 int retval = 0;
3226 if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
3227 int ports = MAX_U132_PORTS;
3228 while (ports-- > 0) {
3229 port_power(u132, ports, 1);
3230 }
3231 retval = 0;
3232 } else {
3233 pdev->dev.power.power_state = PMSG_ON;
3234 retval = u132_bus_resume(hcd);
3235 }
3236 return retval;
3237 }
3238}
3239
3240#else
3241#define u132_suspend NULL
3242#define u132_resume NULL
3243#endif
3244/*
3245* this driver is loaded explicitely by ftdi_u132
3246*
3247* the platform_driver struct is static because it is per type of module
3248*/
3249static struct platform_driver u132_platform_driver = {
3250 .probe = u132_probe,
3251 .remove = __devexit_p(u132_remove),
3252 .suspend = u132_suspend,
3253 .resume = u132_resume,
3254 .driver = {
3255 .name = (char *)hcd_name,
3256 .owner = THIS_MODULE,
3257 },
3258};
3259static int __init u132_hcd_init(void)
3260{
3261 int retval;
3262 INIT_LIST_HEAD(&u132_static_list);
3263 u132_instances = 0;
3264 u132_exiting = 0;
3265 init_MUTEX(&u132_module_lock);
3266 if (usb_disabled())
3267 return -ENODEV;
3268 printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__,
3269 __DATE__);
3270 workqueue = create_singlethread_workqueue("u132");
3271 retval = platform_driver_register(&u132_platform_driver);
3272 return retval;
3273}
3274
3275
3276module_init(u132_hcd_init);
3277static void __exit u132_hcd_exit(void)
3278{
3279 struct u132 *u132;
3280 struct u132 *temp;
3281 down(&u132_module_lock);
3282 u132_exiting += 1;
3283 up(&u132_module_lock);
3284 list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) {
3285 platform_device_unregister(u132->platform_dev);
3286 } platform_driver_unregister(&u132_platform_driver);
3287 printk(KERN_INFO "u132-hcd driver deregistered\n");
3288 wait_event(u132_hcd_wait, u132_instances == 0);
3289 flush_workqueue(workqueue);
3290 destroy_workqueue(workqueue);
3291}
3292
3293
3294module_exit(u132_hcd_exit);
3295MODULE_LICENSE("GPL");
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index dc286a48cafd..e345f15b7d87 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -16,7 +16,7 @@
16 16
17#include "uhci-hcd.h" 17#include "uhci-hcd.h"
18 18
19#define uhci_debug_operations (* (struct file_operations *) NULL) 19#define uhci_debug_operations (* (const struct file_operations *) NULL)
20static struct dentry *uhci_debugfs_root; 20static struct dentry *uhci_debugfs_root;
21 21
22#ifdef DEBUG 22#ifdef DEBUG
@@ -428,7 +428,7 @@ struct uhci_debug {
428 428
429static int uhci_debug_open(struct inode *inode, struct file *file) 429static int uhci_debug_open(struct inode *inode, struct file *file)
430{ 430{
431 struct uhci_hcd *uhci = inode->u.generic_ip; 431 struct uhci_hcd *uhci = inode->i_private;
432 struct uhci_debug *up; 432 struct uhci_debug *up;
433 int ret = -ENOMEM; 433 int ret = -ENOMEM;
434 unsigned long flags; 434 unsigned long flags;
@@ -500,7 +500,7 @@ static int uhci_debug_release(struct inode *inode, struct file *file)
500} 500}
501 501
502#undef uhci_debug_operations 502#undef uhci_debug_operations
503static struct file_operations uhci_debug_operations = { 503static const struct file_operations uhci_debug_operations = {
504 .owner = THIS_MODULE, 504 .owner = THIS_MODULE,
505 .open = uhci_debug_open, 505 .open = uhci_debug_open,
506 .llseek = uhci_debug_lseek, 506 .llseek = uhci_debug_lseek,
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 4151f618602d..eb4eab98e8bf 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -734,6 +734,10 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
734 734
735 /* FIXME: Enable non-PME# remote wakeup? */ 735 /* FIXME: Enable non-PME# remote wakeup? */
736 736
737 /* make sure snapshot being resumed re-enumerates everything */
738 if (message.event == PM_EVENT_PRETHAW)
739 uhci_hc_died(uhci);
740
737done_okay: 741done_okay:
738 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 742 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
739done: 743done:
@@ -909,8 +913,7 @@ static int __init uhci_hcd_init(void)
909 return 0; 913 return 0;
910 914
911init_failed: 915init_failed:
912 if (kmem_cache_destroy(uhci_up_cachep)) 916 kmem_cache_destroy(uhci_up_cachep);
913 warn("not all urb_privs were freed!");
914 917
915up_failed: 918up_failed:
916 debugfs_remove(uhci_debugfs_root); 919 debugfs_remove(uhci_debugfs_root);
@@ -926,10 +929,7 @@ errbuf_failed:
926static void __exit uhci_hcd_cleanup(void) 929static void __exit uhci_hcd_cleanup(void)
927{ 930{
928 pci_unregister_driver(&uhci_pci_driver); 931 pci_unregister_driver(&uhci_pci_driver);
929 932 kmem_cache_destroy(uhci_up_cachep);
930 if (kmem_cache_destroy(uhci_up_cachep))
931 warn("not all urb_privs were freed!");
932
933 debugfs_remove(uhci_debugfs_root); 933 debugfs_remove(uhci_debugfs_root);
934 kfree(errbuf); 934 kfree(errbuf);
935} 935}
diff --git a/drivers/usb/host/uhci-hub.c b/drivers/usb/host/uhci-hub.c
index c545ef92fe29..16fb72eb6fc9 100644
--- a/drivers/usb/host/uhci-hub.c
+++ b/drivers/usb/host/uhci-hub.c
@@ -84,6 +84,7 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
84 unsigned long port_addr) 84 unsigned long port_addr)
85{ 85{
86 int status; 86 int status;
87 int i;
87 88
88 if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) { 89 if (inw(port_addr) & (USBPORTSC_SUSP | USBPORTSC_RD)) {
89 CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD); 90 CLR_RH_PORTSTAT(USBPORTSC_SUSP | USBPORTSC_RD);
@@ -92,9 +93,14 @@ static void uhci_finish_suspend(struct uhci_hcd *uhci, int port,
92 93
93 /* The controller won't actually turn off the RD bit until 94 /* The controller won't actually turn off the RD bit until
94 * it has had a chance to send a low-speed EOP sequence, 95 * it has had a chance to send a low-speed EOP sequence,
95 * which takes 3 bit times (= 2 microseconds). We'll delay 96 * which is supposed to take 3 bit times (= 2 microseconds).
96 * slightly longer for good luck. */ 97 * Experiments show that some controllers take longer, so
97 udelay(4); 98 * we'll poll for completion. */
99 for (i = 0; i < 10; ++i) {
100 if (!(inw(port_addr) & USBPORTSC_RD))
101 break;
102 udelay(1);
103 }
98 } 104 }
99 clear_bit(port, &uhci->resuming_ports); 105 clear_bit(port, &uhci->resuming_ports);
100} 106}
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 08daf400f985..ca6305c1d64c 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -424,7 +424,7 @@ static void mdc800_usb_download_notify (struct urb *urb, struct pt_regs *res)
424 ***************************************************************************/ 424 ***************************************************************************/
425 425
426static struct usb_driver mdc800_usb_driver; 426static struct usb_driver mdc800_usb_driver;
427static struct file_operations mdc800_device_ops; 427static const struct file_operations mdc800_device_ops;
428static struct usb_class_driver mdc800_class = { 428static struct usb_class_driver mdc800_class = {
429 .name = "mdc800%d", 429 .name = "mdc800%d",
430 .fops = &mdc800_device_ops, 430 .fops = &mdc800_device_ops,
@@ -941,7 +941,7 @@ static ssize_t mdc800_device_write (struct file *file, const char __user *buf, s
941****************************************************************************/ 941****************************************************************************/
942 942
943/* File Operations of this drivers */ 943/* File Operations of this drivers */
944static struct file_operations mdc800_device_ops = 944static const struct file_operations mdc800_device_ops =
945{ 945{
946 .owner = THIS_MODULE, 946 .owner = THIS_MODULE,
947 .read = mdc800_device_read, 947 .read = mdc800_device_read,
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 650103bc9618..a102a58fe361 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -205,10 +205,12 @@ config USB_TOUCHSCREEN
205 depends on USB && INPUT 205 depends on USB && INPUT
206 ---help--- 206 ---help---
207 USB Touchscreen driver for: 207 USB Touchscreen driver for:
208 - eGalax Touchkit USB 208 - eGalax Touchkit USB (also includes eTurboTouch CT-410/510/700)
209 - PanJit TouchSet USB 209 - PanJit TouchSet USB
210 - 3M MicroTouch USB 210 - 3M MicroTouch USB (EX II series)
211 - ITM 211 - ITM
212 - some other eTurboTouch
213 - Gunze AHL61
212 214
213 Have a look at <http://linux.chapter7.ch/touchkit/> for 215 Have a look at <http://linux.chapter7.ch/touchkit/> for
214 a usage description and the required user-space stuff. 216 a usage description and the required user-space stuff.
@@ -218,7 +220,7 @@ config USB_TOUCHSCREEN
218 220
219config USB_TOUCHSCREEN_EGALAX 221config USB_TOUCHSCREEN_EGALAX
220 default y 222 default y
221 bool "eGalax device support" if EMBEDDED 223 bool "eGalax, eTurboTouch CT-410/510/700 device support" if EMBEDDED
222 depends on USB_TOUCHSCREEN 224 depends on USB_TOUCHSCREEN
223 225
224config USB_TOUCHSCREEN_PANJIT 226config USB_TOUCHSCREEN_PANJIT
@@ -228,7 +230,7 @@ config USB_TOUCHSCREEN_PANJIT
228 230
229config USB_TOUCHSCREEN_3M 231config USB_TOUCHSCREEN_3M
230 default y 232 default y
231 bool "3M/Microtouch device support" if EMBEDDED 233 bool "3M/Microtouch EX II series device support" if EMBEDDED
232 depends on USB_TOUCHSCREEN 234 depends on USB_TOUCHSCREEN
233 235
234config USB_TOUCHSCREEN_ITM 236config USB_TOUCHSCREEN_ITM
@@ -236,6 +238,16 @@ config USB_TOUCHSCREEN_ITM
236 bool "ITM device support" if EMBEDDED 238 bool "ITM device support" if EMBEDDED
237 depends on USB_TOUCHSCREEN 239 depends on USB_TOUCHSCREEN
238 240
241config USB_TOUCHSCREEN_ETURBO
242 default y
243 bool "eTurboTouch (non-eGalax compatible) device support" if EMBEDDED
244 depends on USB_TOUCHSCREEN
245
246config USB_TOUCHSCREEN_GUNZE
247 default y
248 bool "Gunze AHL61 device support" if EMBEDDED
249 depends on USB_TOUCHSCREEN
250
239config USB_YEALINK 251config USB_YEALINK
240 tristate "Yealink usb-p1k voip phone" 252 tristate "Yealink usb-p1k voip phone"
241 depends on USB && INPUT && EXPERIMENTAL 253 depends on USB && INPUT && EXPERIMENTAL
@@ -326,3 +338,13 @@ config USB_APPLETOUCH
326 338
327 To compile this driver as a module, choose M here: the 339 To compile this driver as a module, choose M here: the
328 module will be called appletouch. 340 module will be called appletouch.
341
342config USB_TRANCEVIBRATOR
343 tristate "PlayStation 2 Trance Vibrator driver support"
344 depends on USB
345 help
346 Say Y here if you want to connect a PlayStation 2 Trance Vibrator
347 device to your computer's USB port.
348
349 To compile this driver as a module, choose M here: the
350 module will be called trancevibrator.
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 764114529c56..48551be324ac 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -3,6 +3,7 @@
3# 3#
4 4
5# Multipart objects. 5# Multipart objects.
6wacom-objs := wacom_sys.o wacom_wac.o
6usbhid-objs := hid-core.o 7usbhid-objs := hid-core.o
7 8
8# Optional parts of multipart objects. 9# Optional parts of multipart objects.
@@ -44,6 +45,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
44obj-$(CONFIG_USB_YEALINK) += yealink.o 45obj-$(CONFIG_USB_YEALINK) += yealink.o
45obj-$(CONFIG_USB_XPAD) += xpad.o 46obj-$(CONFIG_USB_XPAD) += xpad.o
46obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 47obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
48obj-$(CONFIG_USB_TRANCEVIBRATOR) += trancevibrator.o
47 49
48ifeq ($(CONFIG_USB_DEBUG),y) 50ifeq ($(CONFIG_USB_DEBUG),y)
49EXTRA_CFLAGS += -DDEBUG 51EXTRA_CFLAGS += -DDEBUG
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index 18c10e150ef3..d83603ba40ae 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -141,10 +141,7 @@ static int usb_acecad_probe(struct usb_interface *intf, const struct usb_device_
141 141
142 endpoint = &interface->endpoint[0].desc; 142 endpoint = &interface->endpoint[0].desc;
143 143
144 if (!(endpoint->bEndpointAddress & 0x80)) 144 if (!usb_endpoint_is_int_in(endpoint))
145 return -ENODEV;
146
147 if ((endpoint->bmAttributes & 3) != 3)
148 return -ENODEV; 145 return -ENODEV;
149 146
150 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); 147 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index 044faa07e297..0aa9cc2bfd69 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -436,10 +436,7 @@ static int atp_probe(struct usb_interface *iface, const struct usb_device_id *id
436 iface_desc = iface->cur_altsetting; 436 iface_desc = iface->cur_altsetting;
437 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 437 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
438 endpoint = &iface_desc->endpoint[i].desc; 438 endpoint = &iface_desc->endpoint[i].desc;
439 if (!int_in_endpointAddr && 439 if (!int_in_endpointAddr && usb_endpoint_is_int_in(endpoint)) {
440 (endpoint->bEndpointAddress & USB_DIR_IN) &&
441 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
442 == USB_ENDPOINT_XFER_INT)) {
443 /* we found an interrupt in endpoint */ 440 /* we found an interrupt in endpoint */
444 int_in_endpointAddr = endpoint->bEndpointAddress; 441 int_in_endpointAddr = endpoint->bEndpointAddress;
445 break; 442 break;
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 3719fcb04b8f..3558d7ed99b9 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -732,12 +732,8 @@ static int ati_remote_probe(struct usb_interface *interface, const struct usb_de
732 endpoint_in = &iface_host->endpoint[0].desc; 732 endpoint_in = &iface_host->endpoint[0].desc;
733 endpoint_out = &iface_host->endpoint[1].desc; 733 endpoint_out = &iface_host->endpoint[1].desc;
734 734
735 if (!(endpoint_in->bEndpointAddress & USB_DIR_IN)) { 735 if (!usb_endpoint_is_int_in(endpoint_in)) {
736 err("%s: Unexpected endpoint_in->bEndpointAddress\n", __FUNCTION__); 736 err("%s: Unexpected endpoint_in\n", __FUNCTION__);
737 return -ENODEV;
738 }
739 if ((endpoint_in->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) != USB_ENDPOINT_XFER_INT) {
740 err("%s: Unexpected endpoint_in->bmAttributes\n", __FUNCTION__);
741 return -ENODEV; 737 return -ENODEV;
742 } 738 }
743 if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { 739 if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) {
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 3305fb6079eb..2a3e9e9b4b3d 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1023,7 +1023,8 @@ static void hid_irq_in(struct urb *urb, struct pt_regs *regs)
1023 return; 1023 return;
1024 case -EILSEQ: /* protocol error or unplug */ 1024 case -EILSEQ: /* protocol error or unplug */
1025 case -EPROTO: /* protocol error or unplug */ 1025 case -EPROTO: /* protocol error or unplug */
1026 case -ETIMEDOUT: /* NAK */ 1026 case -ETIME: /* protocol error or unplug */
1027 case -ETIMEDOUT: /* Should never happen, but... */
1027 clear_bit(HID_IN_RUNNING, &hid->iofl); 1028 clear_bit(HID_IN_RUNNING, &hid->iofl);
1028 hid_io_error(hid); 1029 hid_io_error(hid);
1029 return; 1030 return;
@@ -1535,13 +1536,17 @@ void hid_init_reports(struct hid_device *hid)
1535#define USB_VENDOR_ID_GLAB 0x06c2 1536#define USB_VENDOR_ID_GLAB 0x06c2
1536#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 1537#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038
1537#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 1538#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039
1538#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
1539#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040 1539#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040
1540#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044
1541#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045
1542#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051
1540#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053 1543#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053
1544#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058
1541 1545
1542#define USB_VENDOR_ID_WISEGROUP 0x0925 1546#define USB_VENDOR_ID_WISEGROUP 0x0925
1543#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 1547#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101
1544#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 1548#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104
1549#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201
1545#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 1550#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866
1546 1551
1547#define USB_VENDOR_ID_WISEGROUP_LTD 0x6677 1552#define USB_VENDOR_ID_WISEGROUP_LTD 0x6677
@@ -1591,6 +1596,10 @@ void hid_init_reports(struct hid_device *hid)
1591 1596
1592#define USB_VENDOR_ID_YEALINK 0x6993 1597#define USB_VENDOR_ID_YEALINK 0x6993
1593#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001 1598#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001
1599
1600#define USB_VENDOR_ID_ALCOR 0x058f
1601#define USB_DEVICE_ID_ALCOR_USBRS232 0x9720
1602
1594/* 1603/*
1595 * Alphabetically sorted blacklist by quirk type. 1604 * Alphabetically sorted blacklist by quirk type.
1596 */ 1605 */
@@ -1608,6 +1617,7 @@ static const struct hid_blacklist {
1608 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE }, 1617 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22, HID_QUIRK_IGNORE },
1609 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE }, 1618 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23, HID_QUIRK_IGNORE },
1610 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE }, 1619 { USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24, HID_QUIRK_IGNORE },
1620 { USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232, HID_QUIRK_IGNORE },
1611 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE }, 1621 { USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD, HID_QUIRK_IGNORE },
1612 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE }, 1622 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW40, HID_QUIRK_IGNORE },
1613 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24, HID_QUIRK_IGNORE }, 1623 { USB_VENDOR_ID_CODEMERCS, USB_DEVICE_ID_CODEMERCS_IOW24, HID_QUIRK_IGNORE },
@@ -1620,9 +1630,12 @@ static const struct hid_blacklist {
1620 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE }, 1630 { USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5, HID_QUIRK_IGNORE },
1621 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, 1631 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
1622 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE }, 1632 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30, HID_QUIRK_IGNORE },
1623 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT, HID_QUIRK_IGNORE },
1624 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT, HID_QUIRK_IGNORE }, 1633 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT, HID_QUIRK_IGNORE },
1634 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT, HID_QUIRK_IGNORE },
1635 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT, HID_QUIRK_IGNORE },
1636 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT, HID_QUIRK_IGNORE },
1625 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT, HID_QUIRK_IGNORE }, 1637 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT, HID_QUIRK_IGNORE },
1638 { USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL, HID_QUIRK_IGNORE },
1626 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE }, 1639 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE, HID_QUIRK_IGNORE },
1627 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE }, 1640 { USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB, HID_QUIRK_IGNORE },
1628 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90, HID_QUIRK_IGNORE }, 1641 { USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90, HID_QUIRK_IGNORE },
@@ -1690,7 +1703,11 @@ static const struct hid_blacklist {
1690 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE }, 1703 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS, HID_QUIRK_IGNORE },
1691 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_IGNORE }, 1704 { USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1, HID_QUIRK_IGNORE },
1692 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100, HID_QUIRK_IGNORE }, 1705 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100, HID_QUIRK_IGNORE },
1706 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20, HID_QUIRK_IGNORE },
1707 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30, HID_QUIRK_IGNORE },
1693 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100, HID_QUIRK_IGNORE }, 1708 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100, HID_QUIRK_IGNORE },
1709 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108, HID_QUIRK_IGNORE },
1710 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118, HID_QUIRK_IGNORE },
1694 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200, HID_QUIRK_IGNORE }, 1711 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200, HID_QUIRK_IGNORE },
1695 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE }, 1712 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300, HID_QUIRK_IGNORE },
1696 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE }, 1713 { USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400, HID_QUIRK_IGNORE },
@@ -1701,6 +1718,7 @@ static const struct hid_blacklist {
1701 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE }, 1718 { USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS, HID_QUIRK_IGNORE },
1702 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1719 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1703 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1720 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1721 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT, HID_QUIRK_IGNORE },
1704 { USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K, HID_QUIRK_IGNORE }, 1722 { USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K, HID_QUIRK_IGNORE },
1705 1723
1706 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE }, 1724 { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE },
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index f6b839c257a7..a2b419d13740 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -722,7 +722,7 @@ inval:
722 return -EINVAL; 722 return -EINVAL;
723} 723}
724 724
725static struct file_operations hiddev_fops = { 725static const struct file_operations hiddev_fops = {
726 .owner = THIS_MODULE, 726 .owner = THIS_MODULE,
727 .read = hiddev_read, 727 .read = hiddev_read,
728 .write = hiddev_write, 728 .write = hiddev_write,
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index 86acb5f1907a..61966d719ca3 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -87,7 +87,7 @@ static void itmtouch_irq(struct urb *urb, struct pt_regs *regs)
87 case 0: 87 case 0:
88 /* success */ 88 /* success */
89 break; 89 break;
90 case -ETIMEDOUT: 90 case -ETIME:
91 /* this urb is timing out */ 91 /* this urb is timing out */
92 dbg("%s - urb timed out - was the device unplugged?", 92 dbg("%s - urb timed out - was the device unplugged?",
93 __FUNCTION__); 93 __FUNCTION__);
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 4723b310f277..a90359551575 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -420,8 +420,7 @@ static struct usb_endpoint_descriptor *keyspan_get_in_endpoint(struct usb_host_i
420 for (i = 0; i < iface->desc.bNumEndpoints; ++i) { 420 for (i = 0; i < iface->desc.bNumEndpoints; ++i) {
421 endpoint = &iface->endpoint[i].desc; 421 endpoint = &iface->endpoint[i].desc;
422 422
423 if ((endpoint->bEndpointAddress & USB_DIR_IN) && 423 if (usb_endpoint_is_int_in(endpoint)) {
424 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
425 /* we found our interrupt in endpoint */ 424 /* we found our interrupt in endpoint */
426 return endpoint; 425 return endpoint;
427 } 426 }
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index a9ccda8810e0..5dce951f2751 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -107,7 +107,7 @@ static void mtouchusb_irq(struct urb *urb, struct pt_regs *regs)
107 case 0: 107 case 0:
108 /* success */ 108 /* success */
109 break; 109 break;
110 case -ETIMEDOUT: 110 case -ETIME:
111 /* this urb is timing out */ 111 /* this urb is timing out */
112 dbg("%s - urb timed out - was the device unplugged?", 112 dbg("%s - urb timed out - was the device unplugged?",
113 __FUNCTION__); 113 __FUNCTION__);
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index b3c0d0c3eae9..f0f8db6810a2 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -313,9 +313,7 @@ static int powermate_probe(struct usb_interface *intf, const struct usb_device_i
313 313
314 interface = intf->cur_altsetting; 314 interface = intf->cur_altsetting;
315 endpoint = &interface->endpoint[0].desc; 315 endpoint = &interface->endpoint[0].desc;
316 if (!(endpoint->bEndpointAddress & 0x80)) 316 if (!usb_endpoint_is_int_in(endpoint))
317 return -EIO;
318 if ((endpoint->bmAttributes & 3) != 3)
319 return -EIO; 317 return -EIO;
320 318
321 usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 319 usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 0149043ffb97..30b9f820e7a8 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -201,7 +201,7 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
201 case 0: 201 case 0:
202 /* success */ 202 /* success */
203 break; 203 break;
204 case -ETIMEDOUT: 204 case -ETIME:
205 /* this urb is timing out */ 205 /* this urb is timing out */
206 dbg("%s - urb timed out - was the device unplugged?", 206 dbg("%s - urb timed out - was the device unplugged?",
207 __FUNCTION__); 207 __FUNCTION__);
diff --git a/drivers/usb/input/trancevibrator.c b/drivers/usb/input/trancevibrator.c
new file mode 100644
index 000000000000..33cd91d11eca
--- /dev/null
+++ b/drivers/usb/input/trancevibrator.c
@@ -0,0 +1,159 @@
1/*
2 * PlayStation 2 Trance Vibrator driver
3 *
4 * Copyright (C) 2006 Sam Hocevar <sam@zoy.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21/* Standard include files */
22#include <linux/kernel.h>
23#include <linux/errno.h>
24#include <linux/init.h>
25#include <linux/module.h>
26#include <linux/usb.h>
27
28/* Version Information */
29#define DRIVER_VERSION "v1.1"
30#define DRIVER_AUTHOR "Sam Hocevar, sam@zoy.org"
31#define DRIVER_DESC "PlayStation 2 Trance Vibrator driver"
32
33#define TRANCEVIBRATOR_VENDOR_ID 0x0b49 /* ASCII Corporation */
34#define TRANCEVIBRATOR_PRODUCT_ID 0x064f /* Trance Vibrator */
35
36static struct usb_device_id id_table [] = {
37 { USB_DEVICE(TRANCEVIBRATOR_VENDOR_ID, TRANCEVIBRATOR_PRODUCT_ID) },
38 { },
39};
40MODULE_DEVICE_TABLE (usb, id_table);
41
42/* Driver-local specific stuff */
43struct trancevibrator {
44 struct usb_device *udev;
45 unsigned int speed;
46};
47
48static ssize_t show_speed(struct device *dev, struct device_attribute *attr,
49 char *buf)
50{
51 struct usb_interface *intf = to_usb_interface(dev);
52 struct trancevibrator *tv = usb_get_intfdata(intf);
53
54 return sprintf(buf, "%d\n", tv->speed);
55}
56
57static ssize_t set_speed(struct device *dev, struct device_attribute *attr,
58 const char *buf, size_t count)
59{
60 struct usb_interface *intf = to_usb_interface(dev);
61 struct trancevibrator *tv = usb_get_intfdata(intf);
62 int temp, retval;
63
64 temp = simple_strtoul(buf, NULL, 10);
65 if (temp > 255)
66 temp = 255;
67 else if (temp < 0)
68 temp = 0;
69 tv->speed = temp;
70
71 dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed);
72
73 /* Set speed */
74 retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0),
75 0x01, /* vendor request: set speed */
76 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
77 tv->speed, /* speed value */
78 0, NULL, 0, USB_CTRL_GET_TIMEOUT);
79 if (retval) {
80 dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
81 return retval;
82 }
83 return count;
84}
85
86static DEVICE_ATTR(speed, S_IWUGO | S_IRUGO, show_speed, set_speed);
87
88static int tv_probe(struct usb_interface *interface,
89 const struct usb_device_id *id)
90{
91 struct usb_device *udev = interface_to_usbdev(interface);
92 struct trancevibrator *dev;
93 int retval;
94
95 dev = kzalloc(sizeof(struct trancevibrator), GFP_KERNEL);
96 if (dev == NULL) {
97 dev_err(&interface->dev, "Out of memory\n");
98 retval = -ENOMEM;
99 goto error;
100 }
101
102 dev->udev = usb_get_dev(udev);
103 usb_set_intfdata(interface, dev);
104 retval = device_create_file(&interface->dev, &dev_attr_speed);
105 if (retval)
106 goto error_create_file;
107
108 return 0;
109
110error_create_file:
111 usb_put_dev(udev);
112 usb_set_intfdata(interface, NULL);
113error:
114 kfree(dev);
115 return retval;
116}
117
118static void tv_disconnect(struct usb_interface *interface)
119{
120 struct trancevibrator *dev;
121
122 dev = usb_get_intfdata (interface);
123 usb_set_intfdata(interface, NULL);
124 device_remove_file(&interface->dev, &dev_attr_speed);
125 usb_put_dev(dev->udev);
126 kfree(dev);
127}
128
129/* USB subsystem object */
130static struct usb_driver tv_driver = {
131 .name = "trancevibrator",
132 .probe = tv_probe,
133 .disconnect = tv_disconnect,
134 .id_table = id_table,
135};
136
137static int __init tv_init(void)
138{
139 int retval = usb_register(&tv_driver);
140 if (retval) {
141 err("usb_register failed. Error number %d", retval);
142 return retval;
143 }
144
145 info(DRIVER_VERSION ":" DRIVER_DESC);
146 return 0;
147}
148
149static void __exit tv_exit(void)
150{
151 usb_deregister(&tv_driver);
152}
153
154module_init (tv_init);
155module_exit (tv_exit);
156
157MODULE_AUTHOR(DRIVER_AUTHOR);
158MODULE_DESCRIPTION(DRIVER_DESC);
159MODULE_LICENSE("GPL");
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 446935b671d9..0fb792be95ef 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -218,7 +218,7 @@ static void usb_mouse_disconnect(struct usb_interface *intf)
218 218
219static struct usb_device_id usb_mouse_id_table [] = { 219static struct usb_device_id usb_mouse_id_table [] = {
220 { USB_INTERFACE_INFO(3, 1, 2) }, 220 { USB_INTERFACE_INFO(3, 1, 2) },
221 { } /* Terminating entry */ 221 { } /* Terminating entry */
222}; 222};
223 223
224MODULE_DEVICE_TABLE (usb, usb_mouse_id_table); 224MODULE_DEVICE_TABLE (usb, usb_mouse_id_table);
diff --git a/drivers/usb/input/usbtouchscreen.c b/drivers/usb/input/usbtouchscreen.c
index a338bf4c2d78..4640d1000d83 100644
--- a/drivers/usb/input/usbtouchscreen.c
+++ b/drivers/usb/input/usbtouchscreen.c
@@ -2,9 +2,12 @@
2 * usbtouchscreen.c 2 * usbtouchscreen.c
3 * Driver for USB Touchscreens, supporting those devices: 3 * Driver for USB Touchscreens, supporting those devices:
4 * - eGalax Touchkit 4 * - eGalax Touchkit
5 * - 3M/Microtouch 5 * includes eTurboTouch CT-410/510/700
6 * - 3M/Microtouch EX II series
6 * - ITM 7 * - ITM
7 * - PanJit TouchSet 8 * - PanJit TouchSet
9 * - eTurboTouch
10 * - Gunze AHL61
8 * 11 *
9 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch> 12 * Copyright (C) 2004-2006 by Daniel Ritz <daniel.ritz@gmx.ch>
10 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 13 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
@@ -42,7 +45,7 @@
42#include <linux/usb/input.h> 45#include <linux/usb/input.h>
43 46
44 47
45#define DRIVER_VERSION "v0.3" 48#define DRIVER_VERSION "v0.4"
46#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" 49#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
47#define DRIVER_DESC "USB Touchscreen Driver" 50#define DRIVER_DESC "USB Touchscreen Driver"
48 51
@@ -60,6 +63,7 @@ struct usbtouch_device_info {
60 int flags; 63 int flags;
61 64
62 void (*process_pkt) (struct usbtouch_usb *usbtouch, struct pt_regs *regs, unsigned char *pkt, int len); 65 void (*process_pkt) (struct usbtouch_usb *usbtouch, struct pt_regs *regs, unsigned char *pkt, int len);
66 int (*get_pkt_len) (unsigned char *pkt, int len);
63 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press); 67 int (*read_data) (unsigned char *pkt, int *x, int *y, int *touch, int *press);
64 int (*init) (struct usbtouch_usb *usbtouch); 68 int (*init) (struct usbtouch_usb *usbtouch);
65}; 69};
@@ -81,8 +85,16 @@ struct usbtouch_usb {
81 char phys[64]; 85 char phys[64];
82}; 86};
83 87
84static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch, 88
85 struct pt_regs *regs, unsigned char *pkt, int len); 89#if defined(CONFIG_USB_TOUCHSCREEN_EGALAX) || defined(CONFIG_USB_TOUCHSCREEN_ETURBO)
90#define MULTI_PACKET
91#endif
92
93#ifdef MULTI_PACKET
94static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
95 struct pt_regs *regs,
96 unsigned char *pkt, int len);
97#endif
86 98
87/* device types */ 99/* device types */
88enum { 100enum {
@@ -91,14 +103,19 @@ enum {
91 DEVTYPE_PANJIT, 103 DEVTYPE_PANJIT,
92 DEVTYPE_3M, 104 DEVTYPE_3M,
93 DEVTYPE_ITM, 105 DEVTYPE_ITM,
106 DEVTYPE_ETURBO,
107 DEVTYPE_GUNZE,
94}; 108};
95 109
96static struct usb_device_id usbtouch_devices[] = { 110static struct usb_device_id usbtouch_devices[] = {
97#ifdef CONFIG_USB_TOUCHSCREEN_EGALAX 111#ifdef CONFIG_USB_TOUCHSCREEN_EGALAX
98 {USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX}, 112 {USB_DEVICE(0x3823, 0x0001), .driver_info = DEVTYPE_EGALAX},
113 {USB_DEVICE(0x3823, 0x0002), .driver_info = DEVTYPE_EGALAX},
99 {USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX}, 114 {USB_DEVICE(0x0123, 0x0001), .driver_info = DEVTYPE_EGALAX},
100 {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX}, 115 {USB_DEVICE(0x0eef, 0x0001), .driver_info = DEVTYPE_EGALAX},
101 {USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX}, 116 {USB_DEVICE(0x0eef, 0x0002), .driver_info = DEVTYPE_EGALAX},
117 {USB_DEVICE(0x1234, 0x0001), .driver_info = DEVTYPE_EGALAX},
118 {USB_DEVICE(0x1234, 0x0002), .driver_info = DEVTYPE_EGALAX},
102#endif 119#endif
103 120
104#ifdef CONFIG_USB_TOUCHSCREEN_PANJIT 121#ifdef CONFIG_USB_TOUCHSCREEN_PANJIT
@@ -116,6 +133,14 @@ static struct usb_device_id usbtouch_devices[] = {
116 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM}, 133 {USB_DEVICE(0x0403, 0xf9e9), .driver_info = DEVTYPE_ITM},
117#endif 134#endif
118 135
136#ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
137 {USB_DEVICE(0x1234, 0x5678), .driver_info = DEVTYPE_ETURBO},
138#endif
139
140#ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
141 {USB_DEVICE(0x0637, 0x0001), .driver_info = DEVTYPE_GUNZE},
142#endif
143
119 {} 144 {}
120}; 145};
121 146
@@ -140,82 +165,23 @@ static int egalax_read_data(unsigned char *pkt, int *x, int *y, int *touch, int
140 *touch = pkt[0] & 0x01; 165 *touch = pkt[0] & 0x01;
141 166
142 return 1; 167 return 1;
143
144} 168}
145 169
146static int egalax_get_pkt_len(unsigned char *buf) 170static int egalax_get_pkt_len(unsigned char *buf, int len)
147{ 171{
148 switch (buf[0] & EGALAX_PKT_TYPE_MASK) { 172 switch (buf[0] & EGALAX_PKT_TYPE_MASK) {
149 case EGALAX_PKT_TYPE_REPT: 173 case EGALAX_PKT_TYPE_REPT:
150 return 5; 174 return 5;
151 175
152 case EGALAX_PKT_TYPE_DIAG: 176 case EGALAX_PKT_TYPE_DIAG:
177 if (len < 2)
178 return -1;
179
153 return buf[1] + 2; 180 return buf[1] + 2;
154 } 181 }
155 182
156 return 0; 183 return 0;
157} 184}
158
159static void egalax_process(struct usbtouch_usb *usbtouch, struct pt_regs *regs,
160 unsigned char *pkt, int len)
161{
162 unsigned char *buffer;
163 int pkt_len, buf_len, pos;
164
165 /* if the buffer contains data, append */
166 if (unlikely(usbtouch->buf_len)) {
167 int tmp;
168
169 /* if only 1 byte in buffer, add another one to get length */
170 if (usbtouch->buf_len == 1)
171 usbtouch->buffer[1] = pkt[0];
172
173 pkt_len = egalax_get_pkt_len(usbtouch->buffer);
174
175 /* unknown packet: drop everything */
176 if (!pkt_len)
177 return;
178
179 /* append, process */
180 tmp = pkt_len - usbtouch->buf_len;
181 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
182 usbtouch_process_pkt(usbtouch, regs, usbtouch->buffer, pkt_len);
183
184 buffer = pkt + tmp;
185 buf_len = len - tmp;
186 } else {
187 buffer = pkt;
188 buf_len = len;
189 }
190
191 /* only one byte left in buffer */
192 if (unlikely(buf_len == 1)) {
193 usbtouch->buffer[0] = buffer[0];
194 usbtouch->buf_len = 1;
195 return;
196 }
197
198 /* loop over the buffer */
199 pos = 0;
200 while (pos < buf_len) {
201 /* get packet len */
202 pkt_len = egalax_get_pkt_len(buffer + pos);
203
204 /* unknown packet: drop everything */
205 if (unlikely(!pkt_len))
206 return;
207
208 /* full packet: process */
209 if (likely(pkt_len <= buf_len)) {
210 usbtouch_process_pkt(usbtouch, regs, buffer + pos, pkt_len);
211 } else {
212 /* incomplete packet: save in buffer */
213 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
214 usbtouch->buf_len = buf_len - pos;
215 }
216 pos += pkt_len;
217 }
218}
219#endif 185#endif
220 186
221 187
@@ -254,7 +220,7 @@ static int mtouch_read_data(unsigned char *pkt, int *x, int *y, int *touch, int
254 220
255static int mtouch_init(struct usbtouch_usb *usbtouch) 221static int mtouch_init(struct usbtouch_usb *usbtouch)
256{ 222{
257 int ret; 223 int ret, i;
258 224
259 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 225 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
260 MTOUCHUSB_RESET, 226 MTOUCHUSB_RESET,
@@ -264,15 +230,20 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
264 __FUNCTION__, ret); 230 __FUNCTION__, ret);
265 if (ret < 0) 231 if (ret < 0)
266 return ret; 232 return ret;
267 233 msleep(150);
268 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0), 234
269 MTOUCHUSB_ASYNC_REPORT, 235 for (i = 0; i < 3; i++) {
270 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 236 ret = usb_control_msg(usbtouch->udev, usb_rcvctrlpipe(usbtouch->udev, 0),
271 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT); 237 MTOUCHUSB_ASYNC_REPORT,
272 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d", 238 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
273 __FUNCTION__, ret); 239 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
274 if (ret < 0) 240 dbg("%s - usb_control_msg - MTOUCHUSB_ASYNC_REPORT - bytes|err: %d",
275 return ret; 241 __FUNCTION__, ret);
242 if (ret >= 0)
243 break;
244 if (ret != -EPIPE)
245 return ret;
246 }
276 247
277 return 0; 248 return 0;
278} 249}
@@ -296,6 +267,54 @@ static int itm_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *pr
296 267
297 268
298/***************************************************************************** 269/*****************************************************************************
270 * eTurboTouch part
271 */
272#ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
273static int eturbo_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
274{
275 unsigned int shift;
276
277 /* packets should start with sync */
278 if (!(pkt[0] & 0x80))
279 return 0;
280
281 shift = (6 - (pkt[0] & 0x03));
282 *x = ((pkt[3] << 7) | pkt[4]) >> shift;
283 *y = ((pkt[1] << 7) | pkt[2]) >> shift;
284 *touch = (pkt[0] & 0x10) ? 1 : 0;
285
286 return 1;
287}
288
289static int eturbo_get_pkt_len(unsigned char *buf, int len)
290{
291 if (buf[0] & 0x80)
292 return 5;
293 if (buf[0] == 0x01)
294 return 3;
295 return 0;
296}
297#endif
298
299
300/*****************************************************************************
301 * Gunze part
302 */
303#ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
304static int gunze_read_data(unsigned char *pkt, int *x, int *y, int *touch, int *press)
305{
306 if (!(pkt[0] & 0x80) || ((pkt[1] | pkt[2] | pkt[3]) & 0x80))
307 return 0;
308
309 *x = ((pkt[0] & 0x1F) << 7) | (pkt[2] & 0x7F);
310 *y = ((pkt[1] & 0x1F) << 7) | (pkt[3] & 0x7F);
311 *touch = pkt[0] & 0x20;
312
313 return 1;
314}
315#endif
316
317/*****************************************************************************
299 * the different device descriptors 318 * the different device descriptors
300 */ 319 */
301static struct usbtouch_device_info usbtouch_dev_info[] = { 320static struct usbtouch_device_info usbtouch_dev_info[] = {
@@ -307,7 +326,8 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
307 .max_yc = 0x07ff, 326 .max_yc = 0x07ff,
308 .rept_size = 16, 327 .rept_size = 16,
309 .flags = USBTOUCH_FLG_BUFFER, 328 .flags = USBTOUCH_FLG_BUFFER,
310 .process_pkt = egalax_process, 329 .process_pkt = usbtouch_process_multi,
330 .get_pkt_len = egalax_get_pkt_len,
311 .read_data = egalax_read_data, 331 .read_data = egalax_read_data,
312 }, 332 },
313#endif 333#endif
@@ -346,6 +366,31 @@ static struct usbtouch_device_info usbtouch_dev_info[] = {
346 .read_data = itm_read_data, 366 .read_data = itm_read_data,
347 }, 367 },
348#endif 368#endif
369
370#ifdef CONFIG_USB_TOUCHSCREEN_ETURBO
371 [DEVTYPE_ETURBO] = {
372 .min_xc = 0x0,
373 .max_xc = 0x07ff,
374 .min_yc = 0x0,
375 .max_yc = 0x07ff,
376 .rept_size = 8,
377 .flags = USBTOUCH_FLG_BUFFER,
378 .process_pkt = usbtouch_process_multi,
379 .get_pkt_len = eturbo_get_pkt_len,
380 .read_data = eturbo_read_data,
381 },
382#endif
383
384#ifdef CONFIG_USB_TOUCHSCREEN_GUNZE
385 [DEVTYPE_GUNZE] = {
386 .min_xc = 0x0,
387 .max_xc = 0x0fff,
388 .min_yc = 0x0,
389 .max_yc = 0x0fff,
390 .rept_size = 4,
391 .read_data = gunze_read_data,
392 },
393#endif
349}; 394};
350 395
351 396
@@ -377,6 +422,83 @@ static void usbtouch_process_pkt(struct usbtouch_usb *usbtouch,
377} 422}
378 423
379 424
425#ifdef MULTI_PACKET
426static void usbtouch_process_multi(struct usbtouch_usb *usbtouch,
427 struct pt_regs *regs,
428 unsigned char *pkt, int len)
429{
430 unsigned char *buffer;
431 int pkt_len, pos, buf_len, tmp;
432
433 /* process buffer */
434 if (unlikely(usbtouch->buf_len)) {
435 /* try to get size */
436 pkt_len = usbtouch->type->get_pkt_len(
437 usbtouch->buffer, usbtouch->buf_len);
438
439 /* drop? */
440 if (unlikely(!pkt_len))
441 goto out_flush_buf;
442
443 /* need to append -pkt_len bytes before able to get size */
444 if (unlikely(pkt_len < 0)) {
445 int append = -pkt_len;
446 if (unlikely(append > len))
447 append = len;
448 if (usbtouch->buf_len + append >= usbtouch->type->rept_size)
449 goto out_flush_buf;
450 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, append);
451 usbtouch->buf_len += append;
452
453 pkt_len = usbtouch->type->get_pkt_len(
454 usbtouch->buffer, usbtouch->buf_len);
455 if (pkt_len < 0)
456 return;
457 }
458
459 /* append */
460 tmp = pkt_len - usbtouch->buf_len;
461 if (usbtouch->buf_len + tmp >= usbtouch->type->rept_size)
462 goto out_flush_buf;
463 memcpy(usbtouch->buffer + usbtouch->buf_len, pkt, tmp);
464 usbtouch_process_pkt(usbtouch, regs, usbtouch->buffer, pkt_len);
465
466 buffer = pkt + tmp;
467 buf_len = len - tmp;
468 } else {
469 buffer = pkt;
470 buf_len = len;
471 }
472
473 /* loop over the received packet, process */
474 pos = 0;
475 while (pos < buf_len) {
476 /* get packet len */
477 pkt_len = usbtouch->type->get_pkt_len(buffer + pos, len);
478
479 /* unknown packet: drop everything */
480 if (unlikely(!pkt_len))
481 goto out_flush_buf;
482
483 /* full packet: process */
484 if (likely((pkt_len > 0) && (pkt_len <= buf_len - pos))) {
485 usbtouch_process_pkt(usbtouch, regs, buffer + pos, pkt_len);
486 } else {
487 /* incomplete packet: save in buffer */
488 memcpy(usbtouch->buffer, buffer + pos, buf_len - pos);
489 usbtouch->buf_len = buf_len - pos;
490 return;
491 }
492 pos += pkt_len;
493 }
494
495out_flush_buf:
496 usbtouch->buf_len = 0;
497 return;
498}
499#endif
500
501
380static void usbtouch_irq(struct urb *urb, struct pt_regs *regs) 502static void usbtouch_irq(struct urb *urb, struct pt_regs *regs)
381{ 503{
382 struct usbtouch_usb *usbtouch = urb->context; 504 struct usbtouch_usb *usbtouch = urb->context;
@@ -386,7 +508,7 @@ static void usbtouch_irq(struct urb *urb, struct pt_regs *regs)
386 case 0: 508 case 0:
387 /* success */ 509 /* success */
388 break; 510 break;
389 case -ETIMEDOUT: 511 case -ETIME:
390 /* this urb is timing out */ 512 /* this urb is timing out */
391 dbg("%s - urb timed out - was the device unplugged?", 513 dbg("%s - urb timed out - was the device unplugged?",
392 __FUNCTION__); 514 __FUNCTION__);
@@ -452,7 +574,7 @@ static int usbtouch_probe(struct usb_interface *intf,
452 struct usb_endpoint_descriptor *endpoint; 574 struct usb_endpoint_descriptor *endpoint;
453 struct usb_device *udev = interface_to_usbdev(intf); 575 struct usb_device *udev = interface_to_usbdev(intf);
454 struct usbtouch_device_info *type; 576 struct usbtouch_device_info *type;
455 int err; 577 int err = -ENOMEM;
456 578
457 interface = intf->cur_altsetting; 579 interface = intf->cur_altsetting;
458 endpoint = &interface->endpoint[0].desc; 580 endpoint = &interface->endpoint[0].desc;
@@ -526,6 +648,7 @@ static int usbtouch_probe(struct usb_interface *intf,
526 usbtouch->data, type->rept_size, 648 usbtouch->data, type->rept_size,
527 usbtouch_irq, usbtouch, endpoint->bInterval); 649 usbtouch_irq, usbtouch, endpoint->bInterval);
528 650
651 usbtouch->irq->dev = usbtouch->udev;
529 usbtouch->irq->transfer_dma = usbtouch->data_dma; 652 usbtouch->irq->transfer_dma = usbtouch->data_dma;
530 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 653 usbtouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
531 654
@@ -553,7 +676,7 @@ out_free_buffers:
553out_free: 676out_free:
554 input_free_device(input_dev); 677 input_free_device(input_dev);
555 kfree(usbtouch); 678 kfree(usbtouch);
556 return -ENOMEM; 679 return err;
557} 680}
558 681
559static void usbtouch_disconnect(struct usb_interface *intf) 682static void usbtouch_disconnect(struct usb_interface *intf)
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
deleted file mode 100644
index 369461a70b72..000000000000
--- a/drivers/usb/input/wacom.c
+++ /dev/null
@@ -1,1003 +0,0 @@
1/*
2 * USB Wacom Graphire and Wacom Intuos tablet support
3 *
4 * Copyright (c) 2000-2004 Vojtech Pavlik <vojtech@ucw.cz>
5 * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
6 * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
7 * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
8 * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
9 * Copyright (c) 2000 Daniel Egger <egger@suse.de>
10 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
11 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be>
12 * Copyright (c) 2002-2006 Ping Cheng <pingc@wacom.com>
13 *
14 * ChangeLog:
15 * v0.1 (vp) - Initial release
16 * v0.2 (aba) - Support for all buttons / combinations
17 * v0.3 (vp) - Support for Intuos added
18 * v0.4 (sm) - Support for more Intuos models, menustrip
19 * relative mode, proximity.
20 * v0.5 (vp) - Big cleanup, nifty features removed,
21 * they belong in userspace
22 * v1.8 (vp) - Submit URB only when operating, moved to CVS,
23 * use input_report_key instead of report_btn and
24 * other cleanups
25 * v1.11 (vp) - Add URB ->dev setting for new kernels
26 * v1.11 (jb) - Add support for the 4D Mouse & Lens
27 * v1.12 (de) - Add support for two more inking pen IDs
28 * v1.14 (vp) - Use new USB device id probing scheme.
29 * Fix Wacom Graphire mouse wheel
30 * v1.18 (vp) - Fix mouse wheel direction
31 * Make mouse relative
32 * v1.20 (fl) - Report tool id for Intuos devices
33 * - Multi tools support
34 * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
35 * - Add PL models support
36 * - Fix Wacom Graphire mouse wheel again
37 * v1.21 (vp) - Removed protocol descriptions
38 * - Added MISC_SERIAL for tool serial numbers
39 * (gb) - Identify version on module load.
40 * v1.21.1 (fl) - added Graphire2 support
41 * v1.21.2 (fl) - added Intuos2 support
42 * - added all the PL ids
43 * v1.21.3 (fl) - added another eraser id from Neil Okamoto
44 * - added smooth filter for Graphire from Peri Hankey
45 * - added PenPartner support from Olaf van Es
46 * - new tool ids from Ole Martin Bjoerndalen
47 * v1.29 (pc) - Add support for more tablets
48 * - Fix pressure reporting
49 * v1.30 (vp) - Merge 2.4 and 2.5 drivers
50 * - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
51 * - Cleanups here and there
52 * v1.30.1 (pi) - Added Graphire3 support
53 * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ...
54 * v1.43 (pc) - Added support for Cintiq 21UX
55 * - Fixed a Graphire bug
56 * - Merged wacom_intuos3_irq into wacom_intuos_irq
57 * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
58 * - Report Device IDs
59 * v1.45 (pc) - Added support for DTF 521, Intuos3 12x12 and 12x19
60 * - Minor data report fix
61 */
62
63/*
64 * This program is free software; you can redistribute it and/or modify
65 * it under the terms of the GNU General Public License as published by
66 * the Free Software Foundation; either version 2 of the License, or
67 * (at your option) any later version.
68 */
69
70#include <linux/kernel.h>
71#include <linux/slab.h>
72#include <linux/module.h>
73#include <linux/init.h>
74#include <linux/usb/input.h>
75#include <asm/unaligned.h>
76
77/*
78 * Version Information
79 */
80#define DRIVER_VERSION "v1.45"
81#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
82#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
83#define DRIVER_LICENSE "GPL"
84
85MODULE_AUTHOR(DRIVER_AUTHOR);
86MODULE_DESCRIPTION(DRIVER_DESC);
87MODULE_LICENSE(DRIVER_LICENSE);
88
89#define USB_VENDOR_ID_WACOM 0x056a
90#define STYLUS_DEVICE_ID 0x02
91#define CURSOR_DEVICE_ID 0x06
92#define ERASER_DEVICE_ID 0x0A
93
94enum {
95 PENPARTNER = 0,
96 GRAPHIRE,
97 WACOM_G4,
98 PL,
99 INTUOS,
100 INTUOS3,
101 INTUOS312,
102 INTUOS319,
103 CINTIQ,
104 MAX_TYPE
105};
106
107struct wacom_features {
108 char *name;
109 int pktlen;
110 int x_max;
111 int y_max;
112 int pressure_max;
113 int distance_max;
114 int type;
115 usb_complete_t irq;
116};
117
118struct wacom {
119 signed char *data;
120 dma_addr_t data_dma;
121 struct input_dev *dev;
122 struct usb_device *usbdev;
123 struct urb *irq;
124 struct wacom_features *features;
125 int tool[2];
126 int id[2];
127 __u32 serial[2];
128 char phys[32];
129};
130
131#define USB_REQ_GET_REPORT 0x01
132#define USB_REQ_SET_REPORT 0x09
133
134static int usb_get_report(struct usb_interface *intf, unsigned char type,
135 unsigned char id, void *buf, int size)
136{
137 return usb_control_msg(interface_to_usbdev(intf),
138 usb_rcvctrlpipe(interface_to_usbdev(intf), 0),
139 USB_REQ_GET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
140 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
141 buf, size, 100);
142}
143
144static int usb_set_report(struct usb_interface *intf, unsigned char type,
145 unsigned char id, void *buf, int size)
146{
147 return usb_control_msg(interface_to_usbdev(intf),
148 usb_sndctrlpipe(interface_to_usbdev(intf), 0),
149 USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
150 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
151 buf, size, 1000);
152}
153
154static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
155{
156 struct wacom *wacom = urb->context;
157 unsigned char *data = wacom->data;
158 struct input_dev *dev = wacom->dev;
159 int prox, pressure, id;
160 int retval;
161
162 switch (urb->status) {
163 case 0:
164 /* success */
165 break;
166 case -ECONNRESET:
167 case -ENOENT:
168 case -ESHUTDOWN:
169 /* this urb is terminated, clean up */
170 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
171 return;
172 default:
173 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
174 goto exit;
175 }
176
177 if (data[0] != 2) {
178 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
179 goto exit;
180 }
181
182 prox = data[1] & 0x40;
183
184 input_regs(dev, regs);
185
186 id = ERASER_DEVICE_ID;
187 if (prox) {
188
189 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
190 if (wacom->features->pressure_max > 255)
191 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
192 pressure += (wacom->features->pressure_max + 1) / 2;
193
194 /*
195 * if going from out of proximity into proximity select between the eraser
196 * and the pen based on the state of the stylus2 button, choose eraser if
197 * pressed else choose pen. if not a proximity change from out to in, send
198 * an out of proximity for previous tool then a in for new tool.
199 */
200 if (!wacom->tool[0]) {
201 /* Eraser bit set for DTF */
202 if (data[1] & 0x10)
203 wacom->tool[1] = BTN_TOOL_RUBBER;
204 else
205 /* Going into proximity select tool */
206 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
207 } else {
208 /* was entered with stylus2 pressed */
209 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
210 /* report out proximity for previous tool */
211 input_report_key(dev, wacom->tool[1], 0);
212 input_sync(dev);
213 wacom->tool[1] = BTN_TOOL_PEN;
214 goto exit;
215 }
216 }
217 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
218 /* Unknown tool selected default to pen tool */
219 wacom->tool[1] = BTN_TOOL_PEN;
220 id = STYLUS_DEVICE_ID;
221 }
222 input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */
223 input_report_abs(dev, ABS_MISC, id); /* report tool id */
224 input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
225 input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
226 input_report_abs(dev, ABS_PRESSURE, pressure);
227
228 input_report_key(dev, BTN_TOUCH, data[4] & 0x08);
229 input_report_key(dev, BTN_STYLUS, data[4] & 0x10);
230 /* Only allow the stylus2 button to be reported for the pen tool. */
231 input_report_key(dev, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
232 } else {
233 /* report proximity-out of a (valid) tool */
234 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
235 /* Unknown tool selected default to pen tool */
236 wacom->tool[1] = BTN_TOOL_PEN;
237 }
238 input_report_key(dev, wacom->tool[1], prox);
239 }
240
241 wacom->tool[0] = prox; /* Save proximity state */
242 input_sync(dev);
243
244 exit:
245 retval = usb_submit_urb (urb, GFP_ATOMIC);
246 if (retval)
247 err ("%s - usb_submit_urb failed with result %d",
248 __FUNCTION__, retval);
249}
250
251static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
252{
253 struct wacom *wacom = urb->context;
254 unsigned char *data = wacom->data;
255 struct input_dev *dev = wacom->dev;
256 int retval, id;
257
258 switch (urb->status) {
259 case 0:
260 /* success */
261 break;
262 case -ECONNRESET:
263 case -ENOENT:
264 case -ESHUTDOWN:
265 /* this urb is terminated, clean up */
266 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
267 return;
268 default:
269 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
270 goto exit;
271 }
272
273 if (data[0] != 2) {
274 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
275 goto exit;
276 }
277
278 input_regs(dev, regs);
279 if (data[1] & 0x04) {
280 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20);
281 input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
282 id = ERASER_DEVICE_ID;
283 } else {
284 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20);
285 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
286 id = STYLUS_DEVICE_ID;
287 }
288 input_report_abs(dev, ABS_MISC, id); /* report tool id */
289 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2]));
290 input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[4]));
291 input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6]));
292 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
293 input_report_key(dev, BTN_STYLUS2, data[1] & 0x10);
294
295 input_sync(dev);
296
297 exit:
298 retval = usb_submit_urb (urb, GFP_ATOMIC);
299 if (retval)
300 err ("%s - usb_submit_urb failed with result %d",
301 __FUNCTION__, retval);
302}
303
304static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
305{
306 struct wacom *wacom = urb->context;
307 unsigned char *data = wacom->data;
308 struct input_dev *dev = wacom->dev;
309 int retval;
310
311 switch (urb->status) {
312 case 0:
313 /* success */
314 break;
315 case -ECONNRESET:
316 case -ENOENT:
317 case -ESHUTDOWN:
318 /* this urb is terminated, clean up */
319 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
320 return;
321 default:
322 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
323 goto exit;
324 }
325
326 if (data[0] != 2) {
327 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
328 goto exit;
329 }
330
331 input_regs(dev, regs);
332 input_report_key(dev, BTN_TOOL_PEN, 1);
333 input_report_abs(dev, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
334 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1]));
335 input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3]));
336 input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
337 input_report_key(dev, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
338 input_report_key(dev, BTN_STYLUS, (data[5] & 0x40));
339 input_sync(dev);
340
341 exit:
342 retval = usb_submit_urb (urb, GFP_ATOMIC);
343 if (retval)
344 err ("%s - usb_submit_urb failed with result %d",
345 __FUNCTION__, retval);
346}
347
348static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
349{
350 struct wacom *wacom = urb->context;
351 unsigned char *data = wacom->data;
352 struct input_dev *dev = wacom->dev;
353 int x, y, id, rw;
354 int retval;
355
356 switch (urb->status) {
357 case 0:
358 /* success */
359 break;
360 case -ECONNRESET:
361 case -ENOENT:
362 case -ESHUTDOWN:
363 /* this urb is terminated, clean up */
364 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
365 return;
366 default:
367 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
368 goto exit;
369 }
370
371 if (data[0] == 99) return; /* for Volito tablets */
372
373 if (data[0] != 2) {
374 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
375 goto exit;
376 }
377
378 input_regs(dev, regs);
379
380 id = STYLUS_DEVICE_ID;
381 if (data[1] & 0x10) { /* in prox */
382
383 switch ((data[1] >> 5) & 3) {
384
385 case 0: /* Pen */
386 wacom->tool[0] = BTN_TOOL_PEN;
387 break;
388
389 case 1: /* Rubber */
390 wacom->tool[0] = BTN_TOOL_RUBBER;
391 id = ERASER_DEVICE_ID;
392 break;
393
394 case 2: /* Mouse with wheel */
395 input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
396 if (wacom->features->type == WACOM_G4) {
397 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
398 input_report_rel(dev, REL_WHEEL, -rw);
399 } else
400 input_report_rel(dev, REL_WHEEL, -(signed char) data[6]);
401 /* fall through */
402
403 case 3: /* Mouse without wheel */
404 wacom->tool[0] = BTN_TOOL_MOUSE;
405 id = CURSOR_DEVICE_ID;
406 input_report_key(dev, BTN_LEFT, data[1] & 0x01);
407 input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
408 if (wacom->features->type == WACOM_G4)
409 input_report_abs(dev, ABS_DISTANCE, data[6]);
410 else
411 input_report_abs(dev, ABS_DISTANCE, data[7]);
412 break;
413 }
414 }
415
416 if (data[1] & 0x90) {
417 x = le16_to_cpu(*(__le16 *) &data[2]);
418 y = le16_to_cpu(*(__le16 *) &data[4]);
419 input_report_abs(dev, ABS_X, x);
420 input_report_abs(dev, ABS_Y, y);
421 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
422 input_report_abs(dev, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
423 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
424 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
425 input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
426 }
427 }
428
429 if (data[1] & 0x10)
430 input_report_abs(dev, ABS_MISC, id); /* report tool id */
431 else
432 input_report_abs(dev, ABS_MISC, 0); /* reset tool id */
433 input_report_key(dev, wacom->tool[0], data[1] & 0x10);
434 input_sync(dev);
435
436 /* send pad data */
437 if (wacom->features->type == WACOM_G4) {
438 if ((wacom->serial[1] & 0xc0) != (data[7] & 0xf8)) {
439 wacom->id[1] = 1;
440 wacom->serial[1] = (data[7] & 0xf8);
441 input_report_key(dev, BTN_0, (data[7] & 0x40));
442 input_report_key(dev, BTN_4, (data[7] & 0x80));
443 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
444 input_report_rel(dev, REL_WHEEL, rw);
445 input_report_key(dev, BTN_TOOL_FINGER, 0xf0);
446 input_event(dev, EV_MSC, MSC_SERIAL, 0xf0);
447 } else if (wacom->id[1]) {
448 wacom->id[1] = 0;
449 input_report_key(dev, BTN_TOOL_FINGER, 0);
450 input_event(dev, EV_MSC, MSC_SERIAL, 0xf0);
451 }
452 input_sync(dev);
453 }
454 exit:
455 retval = usb_submit_urb (urb, GFP_ATOMIC);
456 if (retval)
457 err ("%s - usb_submit_urb failed with result %d",
458 __FUNCTION__, retval);
459}
460
461static int wacom_intuos_inout(struct urb *urb)
462{
463 struct wacom *wacom = urb->context;
464 unsigned char *data = wacom->data;
465 struct input_dev *dev = wacom->dev;
466 int idx;
467
468 /* tool number */
469 idx = data[1] & 0x01;
470
471 /* Enter report */
472 if ((data[1] & 0xfc) == 0xc0) {
473 /* serial number of the tool */
474 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
475 (data[4] << 20) + (data[5] << 12) +
476 (data[6] << 4) + (data[7] >> 4);
477
478 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
479 switch (wacom->id[idx]) {
480 case 0x812: /* Inking pen */
481 case 0x801: /* Intuos3 Inking pen */
482 case 0x012:
483 wacom->tool[idx] = BTN_TOOL_PENCIL;
484 break;
485 case 0x822: /* Pen */
486 case 0x842:
487 case 0x852:
488 case 0x823: /* Intuos3 Grip Pen */
489 case 0x813: /* Intuos3 Classic Pen */
490 case 0x885: /* Intuos3 Marker Pen */
491 case 0x022:
492 wacom->tool[idx] = BTN_TOOL_PEN;
493 break;
494 case 0x832: /* Stroke pen */
495 case 0x032:
496 wacom->tool[idx] = BTN_TOOL_BRUSH;
497 break;
498 case 0x007: /* Mouse 4D and 2D */
499 case 0x09c:
500 case 0x094:
501 case 0x017: /* Intuos3 2D Mouse */
502 wacom->tool[idx] = BTN_TOOL_MOUSE;
503 break;
504 case 0x096: /* Lens cursor */
505 case 0x097: /* Intuos3 Lens cursor */
506 wacom->tool[idx] = BTN_TOOL_LENS;
507 break;
508 case 0x82a: /* Eraser */
509 case 0x85a:
510 case 0x91a:
511 case 0xd1a:
512 case 0x0fa:
513 case 0x82b: /* Intuos3 Grip Pen Eraser */
514 case 0x81b: /* Intuos3 Classic Pen Eraser */
515 case 0x91b: /* Intuos3 Airbrush Eraser */
516 wacom->tool[idx] = BTN_TOOL_RUBBER;
517 break;
518 case 0xd12:
519 case 0x912:
520 case 0x112:
521 case 0x913: /* Intuos3 Airbrush */
522 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
523 break;
524 default: /* Unknown tool */
525 wacom->tool[idx] = BTN_TOOL_PEN;
526 }
527 if(!((wacom->tool[idx] == BTN_TOOL_LENS) &&
528 ((wacom->features->type == INTUOS312)
529 || (wacom->features->type == INTUOS319)))) {
530 input_report_abs(dev, ABS_MISC, wacom->id[idx]); /* report tool id */
531 input_report_key(dev, wacom->tool[idx], 1);
532 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
533 input_sync(dev);
534 }
535 return 1;
536 }
537
538 /* Exit report */
539 if ((data[1] & 0xfe) == 0x80) {
540 input_report_key(dev, wacom->tool[idx], 0);
541 input_report_abs(dev, ABS_MISC, 0); /* reset tool id */
542 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
543 input_sync(dev);
544 return 1;
545 }
546
547 if((wacom->tool[idx] == BTN_TOOL_LENS) && ((wacom->features->type == INTUOS312)
548 || (wacom->features->type == INTUOS319)))
549 return 1;
550 else
551 return 0;
552}
553
554static void wacom_intuos_general(struct urb *urb)
555{
556 struct wacom *wacom = urb->context;
557 unsigned char *data = wacom->data;
558 struct input_dev *dev = wacom->dev;
559 unsigned int t;
560
561 /* general pen packet */
562 if ((data[1] & 0xb8) == 0xa0) {
563 t = (data[6] << 2) | ((data[7] >> 6) & 3);
564 input_report_abs(dev, ABS_PRESSURE, t);
565 input_report_abs(dev, ABS_TILT_X,
566 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
567 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
568 input_report_key(dev, BTN_STYLUS, data[1] & 2);
569 input_report_key(dev, BTN_STYLUS2, data[1] & 4);
570 input_report_key(dev, BTN_TOUCH, t > 10);
571 }
572
573 /* airbrush second packet */
574 if ((data[1] & 0xbc) == 0xb4) {
575 input_report_abs(dev, ABS_WHEEL,
576 (data[6] << 2) | ((data[7] >> 6) & 3));
577 input_report_abs(dev, ABS_TILT_X,
578 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
579 input_report_abs(dev, ABS_TILT_Y, data[8] & 0x7f);
580 }
581 return;
582}
583
584static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
585{
586 struct wacom *wacom = urb->context;
587 unsigned char *data = wacom->data;
588 struct input_dev *dev = wacom->dev;
589 unsigned int t;
590 int idx;
591 int retval;
592
593 switch (urb->status) {
594 case 0:
595 /* success */
596 break;
597 case -ECONNRESET:
598 case -ENOENT:
599 case -ESHUTDOWN:
600 /* this urb is terminated, clean up */
601 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
602 return;
603 default:
604 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
605 goto exit;
606 }
607
608 if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
609 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
610 goto exit;
611 }
612
613 input_regs(dev, regs);
614
615 /* tool number */
616 idx = data[1] & 0x01;
617
618 /* pad packets. Works as a second tool and is always in prox */
619 if (data[0] == 12) {
620 /* initiate the pad as a device */
621 if (wacom->tool[1] != BTN_TOOL_FINGER)
622 wacom->tool[1] = BTN_TOOL_FINGER;
623
624 input_report_key(dev, BTN_0, (data[5] & 0x01));
625 input_report_key(dev, BTN_1, (data[5] & 0x02));
626 input_report_key(dev, BTN_2, (data[5] & 0x04));
627 input_report_key(dev, BTN_3, (data[5] & 0x08));
628 input_report_key(dev, BTN_4, (data[6] & 0x01));
629 input_report_key(dev, BTN_5, (data[6] & 0x02));
630 input_report_key(dev, BTN_6, (data[6] & 0x04));
631 input_report_key(dev, BTN_7, (data[6] & 0x08));
632 input_report_abs(dev, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
633 input_report_abs(dev, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
634
635 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2])
636 input_report_key(dev, wacom->tool[1], 1);
637 else
638 input_report_key(dev, wacom->tool[1], 0);
639 input_event(dev, EV_MSC, MSC_SERIAL, 0xffffffff);
640 input_sync(dev);
641 goto exit;
642 }
643
644 /* process in/out prox events */
645 if (wacom_intuos_inout(urb))
646 goto exit;
647
648 /* Cintiq doesn't send data when RDY bit isn't set */
649 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
650 goto exit;
651
652 if (wacom->features->type >= INTUOS3) {
653 input_report_abs(dev, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
654 input_report_abs(dev, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
655 input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
656 } else {
657 input_report_abs(dev, ABS_X, be16_to_cpu(*(__be16 *) &data[2]));
658 input_report_abs(dev, ABS_Y, be16_to_cpu(*(__be16 *) &data[4]));
659 input_report_abs(dev, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
660 }
661
662 /* process general packets */
663 wacom_intuos_general(urb);
664
665 /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
666 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
667
668 if (data[1] & 0x02) {
669 /* Rotation packet */
670 if (wacom->features->type >= INTUOS3) {
671 /* I3 marker pen rotation reported as wheel
672 * due to valuator limitation
673 */
674 t = (data[6] << 3) | ((data[7] >> 5) & 7);
675 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
676 ((t-1) / 2 + 450)) : (450 - t / 2) ;
677 input_report_abs(dev, ABS_WHEEL, t);
678 } else {
679 /* 4D mouse rotation packet */
680 t = (data[6] << 3) | ((data[7] >> 5) & 7);
681 input_report_abs(dev, ABS_RZ, (data[7] & 0x20) ?
682 ((t - 1) / 2) : -t / 2);
683 }
684
685 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) {
686 /* 4D mouse packet */
687 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
688 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
689 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
690
691 input_report_key(dev, BTN_SIDE, data[8] & 0x20);
692 input_report_key(dev, BTN_EXTRA, data[8] & 0x10);
693 t = (data[6] << 2) | ((data[7] >> 6) & 3);
694 input_report_abs(dev, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
695
696 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
697 /* 2D mouse packet */
698 input_report_key(dev, BTN_LEFT, data[8] & 0x04);
699 input_report_key(dev, BTN_MIDDLE, data[8] & 0x08);
700 input_report_key(dev, BTN_RIGHT, data[8] & 0x10);
701 input_report_rel(dev, REL_WHEEL, (data[8] & 0x01)
702 - ((data[8] & 0x02) >> 1));
703
704 /* I3 2D mouse side buttons */
705 if (wacom->features->type == INTUOS3) {
706 input_report_key(dev, BTN_SIDE, data[8] & 0x40);
707 input_report_key(dev, BTN_EXTRA, data[8] & 0x20);
708 }
709
710 } else if (wacom->features->type < INTUOS3) {
711 /* Lens cursor packets */
712 input_report_key(dev, BTN_LEFT, data[8] & 0x01);
713 input_report_key(dev, BTN_MIDDLE, data[8] & 0x02);
714 input_report_key(dev, BTN_RIGHT, data[8] & 0x04);
715 input_report_key(dev, BTN_SIDE, data[8] & 0x10);
716 input_report_key(dev, BTN_EXTRA, data[8] & 0x08);
717 }
718 }
719
720 input_report_abs(dev, ABS_MISC, wacom->id[idx]); /* report tool id */
721 input_report_key(dev, wacom->tool[idx], 1);
722 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
723 input_sync(dev);
724
725exit:
726 retval = usb_submit_urb (urb, GFP_ATOMIC);
727 if (retval)
728 err ("%s - usb_submit_urb failed with result %d",
729 __FUNCTION__, retval);
730}
731
732static struct wacom_features wacom_features[] = {
733 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_penpartner_irq },
734 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq },
735 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_graphire_irq },
736 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq },
737 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq },
738 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq },
739 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_graphire_irq },
740 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_graphire_irq },
741 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq },
742 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq },
743 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq },
744 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_graphire_irq },
745 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq },
746 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq },
747 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
748 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq },
749 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
750 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
751 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_pl_irq },
752 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_pl_irq },
753 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_pl_irq },
754 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq },
755 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq },
756 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq },
757 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_pl_irq },
758 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_pl_irq },
759 { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_pl_irq },
760 { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_pl_irq },
761 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_pl_irq },
762 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq },
763 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq },
764 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
765 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq },
766 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
767 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
768 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq },
769 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq },
770 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq },
771 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS312, wacom_intuos_irq },
772 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS319, wacom_intuos_irq },
773 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_intuos_irq },
774 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq },
775 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
776 { }
777};
778
779static struct usb_device_id wacom_ids[] = {
780 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
781 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
782 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
783 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
784 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
785 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
786 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
787 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
788 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
789 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
790 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
791 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
792 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
793 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
794 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
795 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
796 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
797 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
798 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
799 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
800 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
801 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
802 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
803 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
804 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
805 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
806 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
807 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
808 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC3) },
809 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
810 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
811 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
812 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
813 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
814 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
815 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
816 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
817 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
818 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
819 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
820 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
821 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
822 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
823 { }
824};
825
826MODULE_DEVICE_TABLE(usb, wacom_ids);
827
828static int wacom_open(struct input_dev *dev)
829{
830 struct wacom *wacom = dev->private;
831
832 wacom->irq->dev = wacom->usbdev;
833 if (usb_submit_urb(wacom->irq, GFP_KERNEL))
834 return -EIO;
835
836 return 0;
837}
838
839static void wacom_close(struct input_dev *dev)
840{
841 struct wacom *wacom = dev->private;
842
843 usb_kill_urb(wacom->irq);
844}
845
846static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
847{
848 struct usb_device *dev = interface_to_usbdev(intf);
849 struct usb_endpoint_descriptor *endpoint;
850 struct wacom *wacom;
851 struct input_dev *input_dev;
852 char rep_data[2], limit = 0;
853
854 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
855 input_dev = input_allocate_device();
856 if (!wacom || !input_dev)
857 goto fail1;
858
859 wacom->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
860 if (!wacom->data)
861 goto fail1;
862
863 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
864 if (!wacom->irq)
865 goto fail2;
866
867 wacom->usbdev = dev;
868 wacom->dev = input_dev;
869 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
870 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
871
872 wacom->features = wacom_features + (id - wacom_ids);
873 if (wacom->features->pktlen > 10)
874 BUG();
875
876 input_dev->name = wacom->features->name;
877 usb_to_input_id(dev, &input_dev->id);
878
879 input_dev->cdev.dev = &intf->dev;
880 input_dev->private = wacom;
881 input_dev->open = wacom_open;
882 input_dev->close = wacom_close;
883
884 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
885 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
886 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->x_max, 4, 0);
887 input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0);
888 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0);
889 input_dev->absbit[LONG(ABS_MISC)] |= BIT(ABS_MISC);
890
891 switch (wacom->features->type) {
892 case WACOM_G4:
893 input_dev->evbit[0] |= BIT(EV_MSC);
894 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
895 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
896 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
897 /* fall through */
898
899 case GRAPHIRE:
900 input_dev->evbit[0] |= BIT(EV_REL);
901 input_dev->relbit[0] |= BIT(REL_WHEEL);
902 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
903 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
904 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
905 break;
906
907 case INTUOS3:
908 case INTUOS312:
909 case INTUOS319:
910 case CINTIQ:
911 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
912 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
913 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
914 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
915 /* fall through */
916
917 case INTUOS:
918 input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
919 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
920 input_dev->relbit[0] |= BIT(REL_WHEEL);
921 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
922 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
923 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
924 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom->features->distance_max, 0, 0);
925 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
926 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
927 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
928 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
929 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
930 break;
931
932 case PL:
933 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);
934 break;
935 }
936
937 endpoint = &intf->cur_altsetting->endpoint[0].desc;
938
939 if (wacom->features->pktlen > 10)
940 BUG();
941
942 usb_fill_int_urb(wacom->irq, dev,
943 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
944 wacom->data, wacom->features->pktlen,
945 wacom->features->irq, wacom, endpoint->bInterval);
946 wacom->irq->transfer_dma = wacom->data_dma;
947 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
948
949 input_register_device(wacom->dev);
950
951 /* Ask the tablet to report tablet data. Repeat until it succeeds */
952 do {
953 rep_data[0] = 2;
954 rep_data[1] = 2;
955 usb_set_report(intf, 3, 2, rep_data, 2);
956 usb_get_report(intf, 3, 2, rep_data, 2);
957 } while (rep_data[1] != 2 && limit++ < 5);
958
959 usb_set_intfdata(intf, wacom);
960 return 0;
961
962fail2: usb_buffer_free(dev, 10, wacom->data, wacom->data_dma);
963fail1: input_free_device(input_dev);
964 kfree(wacom);
965 return -ENOMEM;
966}
967
968static void wacom_disconnect(struct usb_interface *intf)
969{
970 struct wacom *wacom = usb_get_intfdata (intf);
971
972 usb_set_intfdata(intf, NULL);
973 if (wacom) {
974 usb_kill_urb(wacom->irq);
975 input_unregister_device(wacom->dev);
976 usb_free_urb(wacom->irq);
977 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->data, wacom->data_dma);
978 kfree(wacom);
979 }
980}
981
982static struct usb_driver wacom_driver = {
983 .name = "wacom",
984 .probe = wacom_probe,
985 .disconnect = wacom_disconnect,
986 .id_table = wacom_ids,
987};
988
989static int __init wacom_init(void)
990{
991 int result = usb_register(&wacom_driver);
992 if (result == 0)
993 info(DRIVER_VERSION ":" DRIVER_DESC);
994 return result;
995}
996
997static void __exit wacom_exit(void)
998{
999 usb_deregister(&wacom_driver);
1000}
1001
1002module_init(wacom_init);
1003module_exit(wacom_exit);
diff --git a/drivers/usb/input/wacom.h b/drivers/usb/input/wacom.h
new file mode 100644
index 000000000000..832737b658cf
--- /dev/null
+++ b/drivers/usb/input/wacom.h
@@ -0,0 +1,132 @@
1/*
2 * drivers/usb/input/wacom.h
3 *
4 * USB Wacom Graphire and Wacom Intuos tablet support
5 *
6 * Copyright (c) 2000-2004 Vojtech Pavlik <vojtech@ucw.cz>
7 * Copyright (c) 2000 Andreas Bach Aaen <abach@stofanet.dk>
8 * Copyright (c) 2000 Clifford Wolf <clifford@clifford.at>
9 * Copyright (c) 2000 Sam Mosel <sam.mosel@computer.org>
10 * Copyright (c) 2000 James E. Blair <corvus@gnu.org>
11 * Copyright (c) 2000 Daniel Egger <egger@suse.de>
12 * Copyright (c) 2001 Frederic Lepied <flepied@mandrakesoft.com>
13 * Copyright (c) 2004 Panagiotis Issaris <panagiotis.issaris@mech.kuleuven.ac.be>
14 * Copyright (c) 2002-2006 Ping Cheng <pingc@wacom.com>
15 *
16 * ChangeLog:
17 * v0.1 (vp) - Initial release
18 * v0.2 (aba) - Support for all buttons / combinations
19 * v0.3 (vp) - Support for Intuos added
20 * v0.4 (sm) - Support for more Intuos models, menustrip
21 * relative mode, proximity.
22 * v0.5 (vp) - Big cleanup, nifty features removed,
23 * they belong in userspace
24 * v1.8 (vp) - Submit URB only when operating, moved to CVS,
25 * use input_report_key instead of report_btn and
26 * other cleanups
27 * v1.11 (vp) - Add URB ->dev setting for new kernels
28 * v1.11 (jb) - Add support for the 4D Mouse & Lens
29 * v1.12 (de) - Add support for two more inking pen IDs
30 * v1.14 (vp) - Use new USB device id probing scheme.
31 * Fix Wacom Graphire mouse wheel
32 * v1.18 (vp) - Fix mouse wheel direction
33 * Make mouse relative
34 * v1.20 (fl) - Report tool id for Intuos devices
35 * - Multi tools support
36 * - Corrected Intuos protocol decoding (airbrush, 4D mouse, lens cursor...)
37 * - Add PL models support
38 * - Fix Wacom Graphire mouse wheel again
39 * v1.21 (vp) - Removed protocol descriptions
40 * - Added MISC_SERIAL for tool serial numbers
41 * (gb) - Identify version on module load.
42 * v1.21.1 (fl) - added Graphire2 support
43 * v1.21.2 (fl) - added Intuos2 support
44 * - added all the PL ids
45 * v1.21.3 (fl) - added another eraser id from Neil Okamoto
46 * - added smooth filter for Graphire from Peri Hankey
47 * - added PenPartner support from Olaf van Es
48 * - new tool ids from Ole Martin Bjoerndalen
49 * v1.29 (pc) - Add support for more tablets
50 * - Fix pressure reporting
51 * v1.30 (vp) - Merge 2.4 and 2.5 drivers
52 * - Since 2.5 now has input_sync(), remove MSC_SERIAL abuse
53 * - Cleanups here and there
54 * v1.30.1 (pi) - Added Graphire3 support
55 * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ...
56 * v1.43 (pc) - Added support for Cintiq 21UX
57 * - Fixed a Graphire bug
58 * - Merged wacom_intuos3_irq into wacom_intuos_irq
59 * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
60 * - Report Device IDs
61 * v1.45 (pc) - Added support for DTF 521, Intuos3 12x12 and 12x19
62 * - Minor data report fix
63 * v1.46 (pc) - Split wacom.c into wacom_sys.c and wacom_wac.c,
64 * - where wacom_sys.c deals with system specific code,
65 * - and wacom_wac.c deals with Wacom specific code
66 */
67
68/*
69 * This program is free software; you can redistribute it and/or modify
70 * it under the terms of the GNU General Public License as published by
71 * the Free Software Foundation; either version 2 of the License, or
72 * (at your option) any later version.
73 */
74#ifndef WACOM_H
75#define WACOM_H
76#include <linux/kernel.h>
77#include <linux/slab.h>
78#include <linux/module.h>
79#include <linux/init.h>
80#include <linux/usb/input.h>
81#include <asm/unaligned.h>
82
83/*
84 * Version Information
85 */
86#define DRIVER_VERSION "v1.46"
87#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
88#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
89#define DRIVER_LICENSE "GPL"
90
91MODULE_AUTHOR(DRIVER_AUTHOR);
92MODULE_DESCRIPTION(DRIVER_DESC);
93MODULE_LICENSE(DRIVER_LICENSE);
94
95#define USB_VENDOR_ID_WACOM 0x056a
96
97struct wacom {
98 dma_addr_t data_dma;
99 struct input_dev *dev;
100 struct usb_device *usbdev;
101 struct urb *irq;
102 struct wacom_wac * wacom_wac;
103 char phys[32];
104};
105
106struct wacom_combo {
107 struct wacom * wacom;
108 struct urb * urb;
109 struct pt_regs *regs;
110};
111
112extern int wacom_wac_irq(struct wacom_wac * wacom_wac, void * wcombo);
113extern void wacom_sys_irq(struct urb *urb, struct pt_regs *regs);
114extern void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data);
115extern void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data);
116extern void wacom_report_key(void *wcombo, unsigned int key_type, int key_data);
117extern void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value);
118extern void wacom_input_regs(void *wcombo);
119extern void wacom_input_sync(void *wcombo);
120extern void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
121extern void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
122extern void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
123extern void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
124extern void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
125extern void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
126extern void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac);
127extern __u16 wacom_le16_to_cpu(unsigned char *data);
128extern __u16 wacom_be16_to_cpu(unsigned char *data);
129extern struct wacom_features * get_wacom_feature(const struct usb_device_id *id);
130extern const struct usb_device_id * get_device_table(void);
131
132#endif
diff --git a/drivers/usb/input/wacom_sys.c b/drivers/usb/input/wacom_sys.c
new file mode 100644
index 000000000000..7c3b52bdd9d6
--- /dev/null
+++ b/drivers/usb/input/wacom_sys.c
@@ -0,0 +1,315 @@
1/*
2 * drivers/usb/input/wacom_sys.c
3 *
4 * USB Wacom Graphire and Wacom Intuos tablet support - system specific code
5 */
6
7/*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include "wacom.h"
15#include "wacom_wac.h"
16
17#define USB_REQ_GET_REPORT 0x01
18#define USB_REQ_SET_REPORT 0x09
19
20static int usb_get_report(struct usb_interface *intf, unsigned char type,
21 unsigned char id, void *buf, int size)
22{
23 return usb_control_msg(interface_to_usbdev(intf),
24 usb_rcvctrlpipe(interface_to_usbdev(intf), 0),
25 USB_REQ_GET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
26 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
27 buf, size, 100);
28}
29
30static int usb_set_report(struct usb_interface *intf, unsigned char type,
31 unsigned char id, void *buf, int size)
32{
33 return usb_control_msg(interface_to_usbdev(intf),
34 usb_sndctrlpipe(interface_to_usbdev(intf), 0),
35 USB_REQ_SET_REPORT, USB_TYPE_CLASS | USB_RECIP_INTERFACE,
36 (type << 8) + id, intf->altsetting[0].desc.bInterfaceNumber,
37 buf, size, 1000);
38}
39
40static struct input_dev * get_input_dev(struct wacom_combo *wcombo)
41{
42 return wcombo->wacom->dev;
43}
44
45void wacom_sys_irq(struct urb *urb, struct pt_regs *regs)
46{
47 struct wacom *wacom = urb->context;
48 struct wacom_combo wcombo;
49 int retval;
50
51 switch (urb->status) {
52 case 0:
53 /* success */
54 break;
55 case -ECONNRESET:
56 case -ENOENT:
57 case -ESHUTDOWN:
58 /* this urb is terminated, clean up */
59 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
60 return;
61 default:
62 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status);
63 goto exit;
64 }
65
66 wcombo.wacom = wacom;
67 wcombo.urb = urb;
68 wcombo.regs = regs;
69
70 if (wacom_wac_irq(wacom->wacom_wac, (void *)&wcombo))
71 input_sync(get_input_dev(&wcombo));
72
73 exit:
74 retval = usb_submit_urb (urb, GFP_ATOMIC);
75 if (retval)
76 err ("%s - usb_submit_urb failed with result %d",
77 __FUNCTION__, retval);
78}
79
80void wacom_report_key(void *wcombo, unsigned int key_type, int key_data)
81{
82 input_report_key(get_input_dev((struct wacom_combo *)wcombo), key_type, key_data);
83 return;
84}
85
86void wacom_report_abs(void *wcombo, unsigned int abs_type, int abs_data)
87{
88 input_report_abs(get_input_dev((struct wacom_combo *)wcombo), abs_type, abs_data);
89 return;
90}
91
92void wacom_report_rel(void *wcombo, unsigned int rel_type, int rel_data)
93{
94 input_report_rel(get_input_dev((struct wacom_combo *)wcombo), rel_type, rel_data);
95 return;
96}
97
98void wacom_input_event(void *wcombo, unsigned int type, unsigned int code, int value)
99{
100 input_event(get_input_dev((struct wacom_combo *)wcombo), type, code, value);
101 return;
102}
103
104__u16 wacom_be16_to_cpu(unsigned char *data)
105{
106 __u16 value;
107 value = be16_to_cpu(*(__be16 *) data);
108 return value;
109}
110
111__u16 wacom_le16_to_cpu(unsigned char *data)
112{
113 __u16 value;
114 value = be16_to_cpu(*(__be16 *) data);
115 return value;
116}
117
118void wacom_input_regs(void *wcombo)
119{
120 input_regs(get_input_dev((struct wacom_combo *)wcombo), ((struct wacom_combo *)wcombo)->regs);
121 return;
122}
123
124void wacom_input_sync(void *wcombo)
125{
126 input_sync(get_input_dev((struct wacom_combo *)wcombo));
127 return;
128}
129
130static int wacom_open(struct input_dev *dev)
131{
132 struct wacom *wacom = dev->private;
133
134 wacom->irq->dev = wacom->usbdev;
135 if (usb_submit_urb(wacom->irq, GFP_KERNEL))
136 return -EIO;
137
138 return 0;
139}
140
141static void wacom_close(struct input_dev *dev)
142{
143 struct wacom *wacom = dev->private;
144
145 usb_kill_urb(wacom->irq);
146}
147
148void input_dev_g4(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
149{
150 input_dev->evbit[0] |= BIT(EV_MSC);
151 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
152 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
153 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
154}
155
156void input_dev_g(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
157{
158 input_dev->evbit[0] |= BIT(EV_REL);
159 input_dev->relbit[0] |= BIT(REL_WHEEL);
160 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE);
161 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_STYLUS2);
162 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
163}
164
165void input_dev_i3(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
166{
167 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
168 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
169 input_set_abs_params(input_dev, ABS_RX, 0, 4097, 0, 0);
170 input_set_abs_params(input_dev, ABS_RY, 0, 4097, 0, 0);
171}
172
173void input_dev_i(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
174{
175 input_dev->evbit[0] |= BIT(EV_MSC) | BIT(EV_REL);
176 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
177 input_dev->relbit[0] |= BIT(REL_WHEEL);
178 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_LEFT) | BIT(BTN_RIGHT) | BIT(BTN_MIDDLE) | BIT(BTN_SIDE) | BIT(BTN_EXTRA);
179 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER) | BIT(BTN_TOOL_MOUSE) | BIT(BTN_TOOL_BRUSH)
180 | BIT(BTN_TOOL_PENCIL) | BIT(BTN_TOOL_AIRBRUSH) | BIT(BTN_TOOL_LENS) | BIT(BTN_STYLUS2);
181 input_set_abs_params(input_dev, ABS_DISTANCE, 0, wacom_wac->features->distance_max, 0, 0);
182 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
183 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
184 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
185 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
186 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
187}
188
189void input_dev_pl(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
190{
191 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_STYLUS2) | BIT(BTN_TOOL_RUBBER);
192}
193
194void input_dev_pt(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
195{
196 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_RUBBER);
197}
198
199static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
200{
201 struct usb_device *dev = interface_to_usbdev(intf);
202 struct usb_endpoint_descriptor *endpoint;
203 struct wacom *wacom;
204 struct wacom_wac *wacom_wac;
205 struct input_dev *input_dev;
206 char rep_data[2], limit = 0;
207
208 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
209 wacom_wac = kzalloc(sizeof(struct wacom_wac), GFP_KERNEL);
210 input_dev = input_allocate_device();
211 if (!wacom || !input_dev || !wacom_wac)
212 goto fail1;
213
214 wacom_wac->data = usb_buffer_alloc(dev, 10, GFP_KERNEL, &wacom->data_dma);
215 if (!wacom_wac->data)
216 goto fail1;
217
218 wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
219 if (!wacom->irq)
220 goto fail2;
221
222 wacom->usbdev = dev;
223 wacom->dev = input_dev;
224 usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
225 strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
226
227 wacom_wac->features = get_wacom_feature(id);
228 if (wacom_wac->features->pktlen > 10)
229 BUG();
230
231 input_dev->name = wacom_wac->features->name;
232 wacom->wacom_wac = wacom_wac;
233 usb_to_input_id(dev, &input_dev->id);
234
235 input_dev->cdev.dev = &intf->dev;
236 input_dev->private = wacom;
237 input_dev->open = wacom_open;
238 input_dev->close = wacom_close;
239
240 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
241 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
242 input_set_abs_params(input_dev, ABS_X, 0, wacom_wac->features->x_max, 4, 0);
243 input_set_abs_params(input_dev, ABS_Y, 0, wacom_wac->features->y_max, 4, 0);
244 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom_wac->features->pressure_max, 0, 0);
245 input_dev->absbit[LONG(ABS_MISC)] |= BIT(ABS_MISC);
246
247 wacom_init_input_dev(input_dev, wacom_wac);
248
249 endpoint = &intf->cur_altsetting->endpoint[0].desc;
250
251 usb_fill_int_urb(wacom->irq, dev,
252 usb_rcvintpipe(dev, endpoint->bEndpointAddress),
253 wacom_wac->data, wacom_wac->features->pktlen,
254 wacom_wac->features->irq, wacom, endpoint->bInterval);
255 wacom->irq->transfer_dma = wacom->data_dma;
256 wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
257
258 input_register_device(wacom->dev);
259
260 /* Ask the tablet to report tablet data. Repeat until it succeeds */
261 do {
262 rep_data[0] = 2;
263 rep_data[1] = 2;
264 usb_set_report(intf, 3, 2, rep_data, 2);
265 usb_get_report(intf, 3, 2, rep_data, 2);
266 } while (rep_data[1] != 2 && limit++ < 5);
267
268 usb_set_intfdata(intf, wacom);
269 return 0;
270
271fail2: usb_buffer_free(dev, 10, wacom_wac->data, wacom->data_dma);
272fail1: input_free_device(input_dev);
273 kfree(wacom);
274 kfree(wacom_wac);
275 return -ENOMEM;
276}
277
278static void wacom_disconnect(struct usb_interface *intf)
279{
280 struct wacom *wacom = usb_get_intfdata (intf);
281
282 usb_set_intfdata(intf, NULL);
283 if (wacom) {
284 usb_kill_urb(wacom->irq);
285 input_unregister_device(wacom->dev);
286 usb_free_urb(wacom->irq);
287 usb_buffer_free(interface_to_usbdev(intf), 10, wacom->wacom_wac->data, wacom->data_dma);
288 kfree(wacom);
289 kfree(wacom->wacom_wac);
290 }
291}
292
293static struct usb_driver wacom_driver = {
294 .name = "wacom",
295 .probe = wacom_probe,
296 .disconnect = wacom_disconnect,
297};
298
299static int __init wacom_init(void)
300{
301 int result;
302 wacom_driver.id_table = get_device_table();
303 result = usb_register(&wacom_driver);
304 if (result == 0)
305 info(DRIVER_VERSION ":" DRIVER_DESC);
306 return result;
307}
308
309static void __exit wacom_exit(void)
310{
311 usb_deregister(&wacom_driver);
312}
313
314module_init(wacom_init);
315module_exit(wacom_exit);
diff --git a/drivers/usb/input/wacom_wac.c b/drivers/usb/input/wacom_wac.c
new file mode 100644
index 000000000000..85d458c98b6e
--- /dev/null
+++ b/drivers/usb/input/wacom_wac.c
@@ -0,0 +1,646 @@
1/*
2 * drivers/usb/input/wacom_wac.c
3 *
4 * USB Wacom Graphire and Wacom Intuos tablet support - Wacom specific code
5 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 */
14#include "wacom.h"
15#include "wacom_wac.h"
16
17static int wacom_penpartner_irq(struct wacom_wac *wacom, void *wcombo)
18{
19 unsigned char *data = wacom->data;
20
21 switch (data[0]) {
22 case 1:
23 wacom_input_regs(wcombo);
24 if (data[5] & 0x80) {
25 wacom->tool[0] = (data[5] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
26 wacom->id[0] = (data[5] & 0x20) ? ERASER_DEVICE_ID : STYLUS_DEVICE_ID;
27 wacom_report_key(wcombo, wacom->tool[0], 1);
28 wacom_report_abs(wcombo, ABS_MISC, wacom->id[0]); /* report tool id */
29 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
30 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
31 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
32 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -127));
33 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
34 } else {
35 wacom_report_key(wcombo, wacom->tool[0], 0);
36 wacom_report_abs(wcombo, ABS_MISC, 0); /* report tool id */
37 wacom_report_abs(wcombo, ABS_PRESSURE, -1);
38 wacom_report_key(wcombo, BTN_TOUCH, 0);
39 }
40 break;
41 case 2:
42 wacom_input_regs(wcombo);
43 wacom_report_key(wcombo, BTN_TOOL_PEN, 1);
44 wacom_report_abs(wcombo, ABS_MISC, STYLUS_DEVICE_ID); /* report tool id */
45 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[1]));
46 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[3]));
47 wacom_report_abs(wcombo, ABS_PRESSURE, (signed char)data[6] + 127);
48 wacom_report_key(wcombo, BTN_TOUCH, ((signed char)data[6] > -80) && !(data[5] & 0x20));
49 wacom_report_key(wcombo, BTN_STYLUS, (data[5] & 0x40));
50 break;
51 default:
52 printk(KERN_INFO "wacom_penpartner_irq: received unknown report #%d\n", data[0]);
53 return 0;
54 }
55 return 1;
56}
57
58static int wacom_pl_irq(struct wacom_wac *wacom, void *wcombo)
59{
60 unsigned char *data = wacom->data;
61 int prox, id, pressure;
62
63 if (data[0] != 2) {
64 dbg("wacom_pl_irq: received unknown report #%d", data[0]);
65 return 0;
66 }
67
68 prox = data[1] & 0x40;
69
70 wacom_input_regs(wcombo);
71
72 id = ERASER_DEVICE_ID;
73 if (prox) {
74
75 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
76 if (wacom->features->pressure_max > 255)
77 pressure = (pressure << 1) | ((data[4] >> 6) & 1);
78 pressure += (wacom->features->pressure_max + 1) / 2;
79
80 /*
81 * if going from out of proximity into proximity select between the eraser
82 * and the pen based on the state of the stylus2 button, choose eraser if
83 * pressed else choose pen. if not a proximity change from out to in, send
84 * an out of proximity for previous tool then a in for new tool.
85 */
86 if (!wacom->tool[0]) {
87 /* Eraser bit set for DTF */
88 if (data[1] & 0x10)
89 wacom->tool[1] = BTN_TOOL_RUBBER;
90 else
91 /* Going into proximity select tool */
92 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
93 } else {
94 /* was entered with stylus2 pressed */
95 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
96 /* report out proximity for previous tool */
97 wacom_report_key(wcombo, wacom->tool[1], 0);
98 wacom_input_sync(wcombo);
99 wacom->tool[1] = BTN_TOOL_PEN;
100 return 0;
101 }
102 }
103 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
104 /* Unknown tool selected default to pen tool */
105 wacom->tool[1] = BTN_TOOL_PEN;
106 id = STYLUS_DEVICE_ID;
107 }
108 wacom_report_key(wcombo, wacom->tool[1], prox); /* report in proximity for tool */
109 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
110 wacom_report_abs(wcombo, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
111 wacom_report_abs(wcombo, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
112 wacom_report_abs(wcombo, ABS_PRESSURE, pressure);
113
114 wacom_report_key(wcombo, BTN_TOUCH, data[4] & 0x08);
115 wacom_report_key(wcombo, BTN_STYLUS, data[4] & 0x10);
116 /* Only allow the stylus2 button to be reported for the pen tool. */
117 wacom_report_key(wcombo, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
118 } else {
119 /* report proximity-out of a (valid) tool */
120 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
121 /* Unknown tool selected default to pen tool */
122 wacom->tool[1] = BTN_TOOL_PEN;
123 }
124 wacom_report_key(wcombo, wacom->tool[1], prox);
125 }
126
127 wacom->tool[0] = prox; /* Save proximity state */
128 return 1;
129}
130
131static int wacom_ptu_irq(struct wacom_wac *wacom, void *wcombo)
132{
133 unsigned char *data = wacom->data;
134 int id;
135
136 if (data[0] != 2) {
137 printk(KERN_INFO "wacom_ptu_irq: received unknown report #%d\n", data[0]);
138 return 0;
139 }
140
141 wacom_input_regs(wcombo);
142 if (data[1] & 0x04) {
143 wacom_report_key(wcombo, BTN_TOOL_RUBBER, data[1] & 0x20);
144 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x08);
145 id = ERASER_DEVICE_ID;
146 } else {
147 wacom_report_key(wcombo, BTN_TOOL_PEN, data[1] & 0x20);
148 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
149 id = STYLUS_DEVICE_ID;
150 }
151 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
152 wacom_report_abs(wcombo, ABS_X, wacom_le16_to_cpu(&data[2]));
153 wacom_report_abs(wcombo, ABS_Y, wacom_le16_to_cpu(&data[4]));
154 wacom_report_abs(wcombo, ABS_PRESSURE, wacom_le16_to_cpu(&data[6]));
155 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
156 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x10);
157 return 1;
158}
159
160static int wacom_graphire_irq(struct wacom_wac *wacom, void *wcombo)
161{
162 unsigned char *data = wacom->data;
163 int x, y, id, rw;
164
165 if (data[0] != 2) {
166 dbg("wacom_graphire_irq: received unknown report #%d", data[0]);
167 return 0;
168 }
169
170 wacom_input_regs(wcombo);
171
172 id = STYLUS_DEVICE_ID;
173 if (data[1] & 0x10) { /* in prox */
174
175 switch ((data[1] >> 5) & 3) {
176
177 case 0: /* Pen */
178 wacom->tool[0] = BTN_TOOL_PEN;
179 break;
180
181 case 1: /* Rubber */
182 wacom->tool[0] = BTN_TOOL_RUBBER;
183 id = ERASER_DEVICE_ID;
184 break;
185
186 case 2: /* Mouse with wheel */
187 wacom_report_key(wcombo, BTN_MIDDLE, data[1] & 0x04);
188 if (wacom->features->type == WACOM_G4) {
189 rw = data[7] & 0x04 ? (data[7] & 0x03)-4 : (data[7] & 0x03);
190 wacom_report_rel(wcombo, REL_WHEEL, -rw);
191 } else
192 wacom_report_rel(wcombo, REL_WHEEL, -(signed char) data[6]);
193 /* fall through */
194
195 case 3: /* Mouse without wheel */
196 wacom->tool[0] = BTN_TOOL_MOUSE;
197 id = CURSOR_DEVICE_ID;
198 wacom_report_key(wcombo, BTN_LEFT, data[1] & 0x01);
199 wacom_report_key(wcombo, BTN_RIGHT, data[1] & 0x02);
200 if (wacom->features->type == WACOM_G4)
201 wacom_report_abs(wcombo, ABS_DISTANCE, data[6]);
202 else
203 wacom_report_abs(wcombo, ABS_DISTANCE, data[7]);
204 break;
205 }
206 }
207
208 if (data[1] & 0x90) {
209 x = wacom_le16_to_cpu(&data[2]);
210 y = wacom_le16_to_cpu(&data[4]);
211 wacom_report_abs(wcombo, ABS_X, x);
212 wacom_report_abs(wcombo, ABS_Y, y);
213 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
214 wacom_report_abs(wcombo, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
215 wacom_report_key(wcombo, BTN_TOUCH, data[1] & 0x01);
216 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 0x02);
217 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 0x04);
218 }
219 }
220
221 if (data[1] & 0x10)
222 wacom_report_abs(wcombo, ABS_MISC, id); /* report tool id */
223 else
224 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
225 wacom_report_key(wcombo, wacom->tool[0], data[1] & 0x10);
226 wacom_input_sync(wcombo);
227
228 /* send pad data */
229 if (wacom->features->type == WACOM_G4) {
230 if ( (wacom->serial[1] & 0xc0) != (data[7] & 0xf8) ) {
231 wacom->id[1] = 1;
232 wacom->serial[1] = (data[7] & 0xf8);
233 wacom_report_key(wcombo, BTN_0, (data[7] & 0x40));
234 wacom_report_key(wcombo, BTN_4, (data[7] & 0x80));
235 rw = ((data[7] & 0x18) >> 3) - ((data[7] & 0x20) >> 3);
236 wacom_report_rel(wcombo, REL_WHEEL, rw);
237 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0xf0);
238 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
239 } else if (wacom->id[1]) {
240 wacom->id[1] = 0;
241 wacom_report_key(wcombo, BTN_TOOL_FINGER, 0);
242 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xf0);
243 }
244 }
245 return 1;
246}
247
248static int wacom_intuos_inout(struct wacom_wac *wacom, void *wcombo)
249{
250 unsigned char *data = wacom->data;
251 int idx;
252
253 /* tool number */
254 idx = data[1] & 0x01;
255
256 /* Enter report */
257 if ((data[1] & 0xfc) == 0xc0) {
258 /* serial number of the tool */
259 wacom->serial[idx] = ((data[3] & 0x0f) << 28) +
260 (data[4] << 20) + (data[5] << 12) +
261 (data[6] << 4) + (data[7] >> 4);
262
263 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
264 switch (wacom->id[idx]) {
265 case 0x812: /* Inking pen */
266 case 0x801: /* Intuos3 Inking pen */
267 case 0x012:
268 wacom->tool[idx] = BTN_TOOL_PENCIL;
269 break;
270 case 0x822: /* Pen */
271 case 0x842:
272 case 0x852:
273 case 0x823: /* Intuos3 Grip Pen */
274 case 0x813: /* Intuos3 Classic Pen */
275 case 0x885: /* Intuos3 Marker Pen */
276 case 0x022:
277 wacom->tool[idx] = BTN_TOOL_PEN;
278 break;
279 case 0x832: /* Stroke pen */
280 case 0x032:
281 wacom->tool[idx] = BTN_TOOL_BRUSH;
282 break;
283 case 0x007: /* Mouse 4D and 2D */
284 case 0x09c:
285 case 0x094:
286 case 0x017: /* Intuos3 2D Mouse */
287 wacom->tool[idx] = BTN_TOOL_MOUSE;
288 break;
289 case 0x096: /* Lens cursor */
290 case 0x097: /* Intuos3 Lens cursor */
291 wacom->tool[idx] = BTN_TOOL_LENS;
292 break;
293 case 0x82a: /* Eraser */
294 case 0x85a:
295 case 0x91a:
296 case 0xd1a:
297 case 0x0fa:
298 case 0x82b: /* Intuos3 Grip Pen Eraser */
299 case 0x81b: /* Intuos3 Classic Pen Eraser */
300 case 0x91b: /* Intuos3 Airbrush Eraser */
301 wacom->tool[idx] = BTN_TOOL_RUBBER;
302 break;
303 case 0xd12:
304 case 0x912:
305 case 0x112:
306 case 0x913: /* Intuos3 Airbrush */
307 wacom->tool[idx] = BTN_TOOL_AIRBRUSH;
308 break;
309 default: /* Unknown tool */
310 wacom->tool[idx] = BTN_TOOL_PEN;
311 }
312 /* only large I3 support Lens Cursor */
313 if(!((wacom->tool[idx] == BTN_TOOL_LENS) &&
314 (wacom->features->type == INTUOS3))) {
315 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
316 wacom_report_key(wcombo, wacom->tool[idx], 1);
317 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
318 return 2;
319 }
320 return 1;
321 }
322
323 /* Exit report */
324 if ((data[1] & 0xfe) == 0x80) {
325 wacom_report_key(wcombo, wacom->tool[idx], 0);
326 wacom_report_abs(wcombo, ABS_MISC, 0); /* reset tool id */
327 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
328 return 2;
329 }
330 return 0;
331}
332
333static void wacom_intuos_general(struct wacom_wac *wacom, void *wcombo)
334{
335 unsigned char *data = wacom->data;
336 unsigned int t;
337
338 /* general pen packet */
339 if ((data[1] & 0xb8) == 0xa0) {
340 t = (data[6] << 2) | ((data[7] >> 6) & 3);
341 wacom_report_abs(wcombo, ABS_PRESSURE, t);
342 wacom_report_abs(wcombo, ABS_TILT_X,
343 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
344 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
345 wacom_report_key(wcombo, BTN_STYLUS, data[1] & 2);
346 wacom_report_key(wcombo, BTN_STYLUS2, data[1] & 4);
347 wacom_report_key(wcombo, BTN_TOUCH, t > 10);
348 }
349
350 /* airbrush second packet */
351 if ((data[1] & 0xbc) == 0xb4) {
352 wacom_report_abs(wcombo, ABS_WHEEL,
353 (data[6] << 2) | ((data[7] >> 6) & 3));
354 wacom_report_abs(wcombo, ABS_TILT_X,
355 ((data[7] << 1) & 0x7e) | (data[8] >> 7));
356 wacom_report_abs(wcombo, ABS_TILT_Y, data[8] & 0x7f);
357 }
358 return;
359}
360
361static int wacom_intuos_irq(struct wacom_wac *wacom, void *wcombo)
362{
363 unsigned char *data = wacom->data;
364 unsigned int t;
365 int idx, result;
366
367 if (data[0] != 2 && data[0] != 5 && data[0] != 6 && data[0] != 12) {
368 dbg("wacom_intuos_irq: received unknown report #%d", data[0]);
369 return 0;
370 }
371
372 wacom_input_regs(wcombo);
373
374 /* tool number */
375 idx = data[1] & 0x01;
376
377 /* pad packets. Works as a second tool and is always in prox */
378 if (data[0] == 12) {
379 /* initiate the pad as a device */
380 if (wacom->tool[1] != BTN_TOOL_FINGER)
381 wacom->tool[1] = BTN_TOOL_FINGER;
382
383 wacom_report_key(wcombo, BTN_0, (data[5] & 0x01));
384 wacom_report_key(wcombo, BTN_1, (data[5] & 0x02));
385 wacom_report_key(wcombo, BTN_2, (data[5] & 0x04));
386 wacom_report_key(wcombo, BTN_3, (data[5] & 0x08));
387 wacom_report_key(wcombo, BTN_4, (data[6] & 0x01));
388 wacom_report_key(wcombo, BTN_5, (data[6] & 0x02));
389 wacom_report_key(wcombo, BTN_6, (data[6] & 0x04));
390 wacom_report_key(wcombo, BTN_7, (data[6] & 0x08));
391 wacom_report_abs(wcombo, ABS_RX, ((data[1] & 0x1f) << 8) | data[2]);
392 wacom_report_abs(wcombo, ABS_RY, ((data[3] & 0x1f) << 8) | data[4]);
393
394 if((data[5] & 0x0f) | (data[6] & 0x0f) | (data[1] & 0x1f) | data[2])
395 wacom_report_key(wcombo, wacom->tool[1], 1);
396 else
397 wacom_report_key(wcombo, wacom->tool[1], 0);
398 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, 0xffffffff);
399 return 1;
400 }
401
402 /* process in/out prox events */
403 result = wacom_intuos_inout(wacom, wcombo);
404 if (result)
405 return result-1;
406
407 /* Cintiq doesn't send data when RDY bit isn't set */
408 if ((wacom->features->type == CINTIQ) && !(data[1] & 0x40))
409 return 0;
410
411 if (wacom->features->type >= INTUOS3) {
412 wacom_report_abs(wcombo, ABS_X, (data[2] << 9) | (data[3] << 1) | ((data[9] >> 1) & 1));
413 wacom_report_abs(wcombo, ABS_Y, (data[4] << 9) | (data[5] << 1) | (data[9] & 1));
414 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 2) & 0x3f));
415 } else {
416 wacom_report_abs(wcombo, ABS_X, wacom_be16_to_cpu(&data[2]));
417 wacom_report_abs(wcombo, ABS_Y, wacom_be16_to_cpu(&data[4]));
418 wacom_report_abs(wcombo, ABS_DISTANCE, ((data[9] >> 3) & 0x1f));
419 }
420
421 /* process general packets */
422 wacom_intuos_general(wacom, wcombo);
423
424 /* 4D mouse, 2D mouse, marker pen rotation, or Lens cursor packets */
425 if ((data[1] & 0xbc) == 0xa8 || (data[1] & 0xbe) == 0xb0) {
426
427 if (data[1] & 0x02) {
428 /* Rotation packet */
429 if (wacom->features->type >= INTUOS3) {
430 /* I3 marker pen rotation reported as wheel
431 * due to valuator limitation
432 */
433 t = (data[6] << 3) | ((data[7] >> 5) & 7);
434 t = (data[7] & 0x20) ? ((t > 900) ? ((t-1) / 2 - 1350) :
435 ((t-1) / 2 + 450)) : (450 - t / 2) ;
436 wacom_report_abs(wcombo, ABS_WHEEL, t);
437 } else {
438 /* 4D mouse rotation packet */
439 t = (data[6] << 3) | ((data[7] >> 5) & 7);
440 wacom_report_abs(wcombo, ABS_RZ, (data[7] & 0x20) ?
441 ((t - 1) / 2) : -t / 2);
442 }
443
444 } else if (!(data[1] & 0x10) && wacom->features->type < INTUOS3) {
445 /* 4D mouse packet */
446 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
447 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
448 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
449
450 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x20);
451 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x10);
452 t = (data[6] << 2) | ((data[7] >> 6) & 3);
453 wacom_report_abs(wcombo, ABS_THROTTLE, (data[8] & 0x08) ? -t : t);
454
455 } else if (wacom->tool[idx] == BTN_TOOL_MOUSE) {
456 /* 2D mouse packet */
457 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x04);
458 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x08);
459 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x10);
460 wacom_report_rel(wcombo, REL_WHEEL, (data[8] & 0x01)
461 - ((data[8] & 0x02) >> 1));
462
463 /* I3 2D mouse side buttons */
464 if (wacom->features->type == INTUOS3) {
465 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x40);
466 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x20);
467 }
468
469 } else if (wacom->features->type < INTUOS3) {
470 /* Lens cursor packets */
471 wacom_report_key(wcombo, BTN_LEFT, data[8] & 0x01);
472 wacom_report_key(wcombo, BTN_MIDDLE, data[8] & 0x02);
473 wacom_report_key(wcombo, BTN_RIGHT, data[8] & 0x04);
474 wacom_report_key(wcombo, BTN_SIDE, data[8] & 0x10);
475 wacom_report_key(wcombo, BTN_EXTRA, data[8] & 0x08);
476 }
477 }
478
479 wacom_report_abs(wcombo, ABS_MISC, wacom->id[idx]); /* report tool id */
480 wacom_report_key(wcombo, wacom->tool[idx], 1);
481 wacom_input_event(wcombo, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
482 return 1;
483}
484
485int wacom_wac_irq(struct wacom_wac *wacom_wac, void *wcombo)
486{
487 switch (wacom_wac->features->type) {
488 case PENPARTNER:
489 return (wacom_penpartner_irq(wacom_wac, wcombo));
490 break;
491 case PL:
492 return (wacom_pl_irq(wacom_wac, wcombo));
493 break;
494 case WACOM_G4:
495 case GRAPHIRE:
496 return (wacom_graphire_irq(wacom_wac, wcombo));
497 break;
498 case PTU:
499 return (wacom_ptu_irq(wacom_wac, wcombo));
500 break;
501 case INTUOS:
502 case INTUOS3:
503 case INTUOS3L:
504 case CINTIQ:
505 return (wacom_intuos_irq(wacom_wac, wcombo));
506 break;
507 default:
508 return 0;
509 }
510 return 0;
511}
512
513void wacom_init_input_dev(struct input_dev *input_dev, struct wacom_wac *wacom_wac)
514{
515 switch (wacom_wac->features->type) {
516 case WACOM_G4:
517 input_dev_g4(input_dev, wacom_wac);
518 /* fall through */
519 case GRAPHIRE:
520 input_dev_g(input_dev, wacom_wac);
521 break;
522 case INTUOS3:
523 case INTUOS3L:
524 case CINTIQ:
525 input_dev_i3(input_dev, wacom_wac);
526 /* fall through */
527 case INTUOS:
528 input_dev_i(input_dev, wacom_wac);
529 break;
530 case PL:
531 case PTU:
532 input_dev_pl(input_dev, wacom_wac);
533 break;
534 case PENPARTNER:
535 input_dev_pt(input_dev, wacom_wac);
536 break;
537 }
538 return;
539}
540
541static struct wacom_features wacom_features[] = {
542 { "Wacom Penpartner", 7, 5040, 3780, 255, 32, PENPARTNER, wacom_sys_irq },
543 { "Wacom Graphire", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq },
544 { "Wacom Graphire2 4x5", 8, 10206, 7422, 511, 32, GRAPHIRE, wacom_sys_irq },
545 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_sys_irq },
546 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_sys_irq },
547 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_sys_irq },
548 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, WACOM_G4, wacom_sys_irq },
549 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, WACOM_G4, wacom_sys_irq },
550 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq },
551 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq },
552 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_sys_irq },
553 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_sys_irq },
554 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_sys_irq },
555 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq},
556 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq },
557 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq },
558 { "Wacom Intuos 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq },
559 { "Wacom Intuos 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq},
560 { "Wacom PL400", 8, 5408, 4056, 255, 32, PL, wacom_sys_irq },
561 { "Wacom PL500", 8, 6144, 4608, 255, 32, PL, wacom_sys_irq },
562 { "Wacom PL600", 8, 6126, 4604, 255, 32, PL, wacom_sys_irq },
563 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_sys_irq },
564 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_sys_irq },
565 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_sys_irq },
566 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_sys_irq },
567 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq },
568 { "Wacom DTU710", 8, 34080, 27660, 511, 32, PL, wacom_sys_irq },
569 { "Wacom DTF521", 8, 6282, 4762, 511, 32, PL, wacom_sys_irq },
570 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_sys_irq },
571 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PTU, wacom_sys_irq },
572 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_sys_irq },
573 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq },
574 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_sys_irq },
575 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_sys_irq },
576 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_sys_irq },
577 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_sys_irq },
578 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_sys_irq },
579 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_sys_irq },
580 { "Wacom Intuos3 12x12", 10, 60960, 60960, 1023, 15, INTUOS3L, wacom_sys_irq },
581 { "Wacom Intuos3 12x19", 10, 97536, 60960, 1023, 15, INTUOS3L, wacom_sys_irq },
582 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_sys_irq },
583 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_sys_irq },
584 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_sys_irq },
585 { }
586};
587
588static struct usb_device_id wacom_ids[] = {
589 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x00) },
590 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x10) },
591 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x11) },
592 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
593 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
594 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
595 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
596 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
597 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
598 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
599 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
600 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
601 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
602 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
603 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
604 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
605 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x23) },
606 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x24) },
607 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x30) },
608 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x31) },
609 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x32) },
610 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
611 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
612 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
613 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
614 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
615 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
616 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
617 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC4) },
618 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
619 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
620 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
621 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
622 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
623 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
624 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
625 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
626 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
627 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB3) },
628 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB4) },
629 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
630 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
631 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
632 { }
633};
634
635const struct usb_device_id * get_device_table(void) {
636 const struct usb_device_id * id_table = wacom_ids;
637 return id_table;
638}
639
640struct wacom_features * get_wacom_feature(const struct usb_device_id * id) {
641 int index = id - wacom_ids;
642 struct wacom_features *wf = &wacom_features[index];
643 return wf;
644}
645
646MODULE_DEVICE_TABLE(usb, wacom_ids);
diff --git a/drivers/usb/input/wacom_wac.h b/drivers/usb/input/wacom_wac.h
new file mode 100644
index 000000000000..ceae7bf59d9f
--- /dev/null
+++ b/drivers/usb/input/wacom_wac.h
@@ -0,0 +1,48 @@
1/*
2 * drivers/usb/input/wacom_wac.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9#ifndef WACOM_WAC_H
10#define WACOM_WAC_H
11
12#define STYLUS_DEVICE_ID 0x02
13#define CURSOR_DEVICE_ID 0x06
14#define ERASER_DEVICE_ID 0x0A
15
16enum {
17 PENPARTNER = 0,
18 GRAPHIRE,
19 WACOM_G4,
20 PTU,
21 PL,
22 INTUOS,
23 INTUOS3,
24 INTUOS3L,
25 CINTIQ,
26 MAX_TYPE
27};
28
29struct wacom_features {
30 char *name;
31 int pktlen;
32 int x_max;
33 int y_max;
34 int pressure_max;
35 int distance_max;
36 int type;
37 usb_complete_t irq;
38};
39
40struct wacom_wac {
41 signed char *data;
42 int tool[2];
43 int id[2];
44 __u32 serial[2];
45 struct wacom_features *features;
46};
47
48#endif
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index 7b45fd3de911..7291e7a2717b 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -971,7 +971,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
971 DRIVER_VERSION, sizeof(DRIVER_VERSION)); 971 DRIVER_VERSION, sizeof(DRIVER_VERSION));
972 972
973 /* Register sysfs hooks (don't care about failure) */ 973 /* Register sysfs hooks (don't care about failure) */
974 sysfs_create_group(&intf->dev.kobj, &yld_attr_group); 974 ret = sysfs_create_group(&intf->dev.kobj, &yld_attr_group);
975 return 0; 975 return 0;
976} 976}
977 977
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index 88928a4be805..c29658f69e2a 100644
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -32,6 +32,16 @@ config USB_EMI26
32 To compile this driver as a module, choose M here: the 32 To compile this driver as a module, choose M here: the
33 module will be called emi26. 33 module will be called emi26.
34 34
35config USB_ADUTUX
36 tristate "ADU devices from Ontrak Control Systems (EXPERIMENTAL)"
37 depends on USB && EXPERIMENTAL
38 help
39 Say Y if you want to use an ADU device from Ontrak Control
40 Systems.
41
42 To compile this driver as a module, choose M here. The module
43 will be called adutux.
44
35config USB_AUERSWALD 45config USB_AUERSWALD
36 tristate "USB Auerswald ISDN support (EXPERIMENTAL)" 46 tristate "USB Auerswald ISDN support (EXPERIMENTAL)"
37 depends on USB && EXPERIMENTAL 47 depends on USB && EXPERIMENTAL
@@ -115,19 +125,36 @@ config USB_CYTHERM
115 To compile this driver as a module, choose M here: the 125 To compile this driver as a module, choose M here: the
116 module will be called cytherm. 126 module will be called cytherm.
117 127
118config USB_PHIDGETKIT 128config USB_PHIDGET
119 tristate "USB PhidgetKit support" 129 tristate "USB Phidgets drivers"
120 depends on USB 130 depends on USB
121 help 131 help
122 Say Y here if you want to connect a PhidgetKit USB device from 132 Say Y here to enable the various drivers for devices from
123 Phidgets Inc. 133 Phidgets inc.
134
135config USB_PHIDGETKIT
136 tristate "USB PhidgetInterfaceKit support"
137 depends on USB_PHIDGET
138 help
139 Say Y here if you want to connect a PhidgetInterfaceKit USB device
140 from Phidgets Inc.
124 141
125 To compile this driver as a module, choose M here: the 142 To compile this driver as a module, choose M here: the
126 module will be called phidgetkit. 143 module will be called phidgetkit.
127 144
145config USB_PHIDGETMOTORCONTROL
146 tristate "USB PhidgetMotorControl support"
147 depends on USB_PHIDGET
148 help
149 Say Y here if you want to connect a PhidgetMotorControl USB device
150 from Phidgets Inc.
151
152 To compile this driver as a module, choose M here: the
153 module will be called phidgetmotorcontrol.
154
128config USB_PHIDGETSERVO 155config USB_PHIDGETSERVO
129 tristate "USB PhidgetServo support" 156 tristate "USB PhidgetServo support"
130 depends on USB 157 depends on USB_PHIDGET
131 help 158 help
132 Say Y here if you want to connect an 1 or 4 Motor PhidgetServo 159 Say Y here if you want to connect an 1 or 4 Motor PhidgetServo
133 servo controller version 2.0 or 3.0. 160 servo controller version 2.0 or 3.0.
@@ -151,6 +178,30 @@ config USB_IDMOUSE
151 178
152 See also <http://www.fs.tum.de/~echtler/idmouse/>. 179 See also <http://www.fs.tum.de/~echtler/idmouse/>.
153 180
181config USB_FTDI_ELAN
182 tristate "Elan PCMCIA CardBus Adapter USB Client"
183 depends on USB
184 default M
185 help
186 ELAN's Uxxx series of adapters are USB to PCMCIA CardBus adapters.
187 Currently only the U132 adapter is available.
188
189 The U132 is specifically designed for CardBus PC cards that contain
190 an OHCI host controller. Typical PC cards are the Orange Mobile 3G
191 Option GlobeTrotter Fusion card. The U132 adapter will *NOT* work
192 with PC cards that do not contain an OHCI controller. To use a U132
193 adapter you will need this "ftdi-elan" module as well as the "u132-hcd"
194 module which is a USB host controller driver that talks to the OHCI
195 controller within CardBus card that are inserted in the U132 adapter.
196
197 This driver has been tested with a CardBus OHCI USB adapter, and
198 worked with a USB PEN Drive inserted into the first USB port of
199 the PCCARD. A rather pointless thing to do, but useful for testing.
200
201 See also the USB_U132_HCD entry "Elan U132 Adapter Host Controller"
202
203 It is safe to say M here.
204
154config USB_APPLEDISPLAY 205config USB_APPLEDISPLAY
155 tristate "Apple Cinema Display support" 206 tristate "Apple Cinema Display support"
156 depends on USB 207 depends on USB
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 2927260c5812..2be70fa259bf 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -3,22 +3,25 @@
3# (the ones that don't fit into any other categories) 3# (the ones that don't fit into any other categories)
4# 4#
5 5
6obj-$(CONFIG_USB_ADUTUX) += adutux.o
6obj-$(CONFIG_USB_AUERSWALD) += auerswald.o 7obj-$(CONFIG_USB_AUERSWALD) += auerswald.o
7obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o 8obj-$(CONFIG_USB_CYPRESS_CY7C63)+= cypress_cy7c63.o
8obj-$(CONFIG_USB_CYTHERM) += cytherm.o 9obj-$(CONFIG_USB_CYTHERM) += cytherm.o
9obj-$(CONFIG_USB_EMI26) += emi26.o 10obj-$(CONFIG_USB_EMI26) += emi26.o
10obj-$(CONFIG_USB_EMI62) += emi62.o 11obj-$(CONFIG_USB_EMI62) += emi62.o
12obj-$(CONFIG_USB_FTDI_ELAN) += ftdi-elan.o
11obj-$(CONFIG_USB_IDMOUSE) += idmouse.o 13obj-$(CONFIG_USB_IDMOUSE) += idmouse.o
12obj-$(CONFIG_USB_LCD) += usblcd.o 14obj-$(CONFIG_USB_LCD) += usblcd.o
13obj-$(CONFIG_USB_LD) += ldusb.o 15obj-$(CONFIG_USB_LD) += ldusb.o
14obj-$(CONFIG_USB_LED) += usbled.o 16obj-$(CONFIG_USB_LED) += usbled.o
15obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o 17obj-$(CONFIG_USB_LEGOTOWER) += legousbtower.o
18obj-$(CONFIG_USB_PHIDGET) += phidget.o
16obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o 19obj-$(CONFIG_USB_PHIDGETKIT) += phidgetkit.o
20obj-$(CONFIG_USB_PHIDGETMOTORCONTROL) += phidgetmotorcontrol.o
17obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o 21obj-$(CONFIG_USB_PHIDGETSERVO) += phidgetservo.o
18obj-$(CONFIG_USB_RIO500) += rio500.o 22obj-$(CONFIG_USB_RIO500) += rio500.o
19obj-$(CONFIG_USB_TEST) += usbtest.o 23obj-$(CONFIG_USB_TEST) += usbtest.o
20obj-$(CONFIG_USB_USS720) += uss720.o 24obj-$(CONFIG_USB_USS720) += uss720.o
21obj-$(CONFIG_USB_APPLEDISPLAY) += appledisplay.o
22 25
23obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ 26obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
24 27
diff --git a/drivers/usb/misc/adutux.c b/drivers/usb/misc/adutux.c
new file mode 100644
index 000000000000..d3963199b6ec
--- /dev/null
+++ b/drivers/usb/misc/adutux.c
@@ -0,0 +1,900 @@
1/*
2 * adutux - driver for ADU devices from Ontrak Control Systems
3 * This is an experimental driver. Use at your own risk.
4 * This driver is not supported by Ontrak Control Systems.
5 *
6 * Copyright (c) 2003 John Homppi (SCO, leave this notice here)
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * derived from the Lego USB Tower driver 0.56:
14 * Copyright (c) 2003 David Glance <davidgsf@sourceforge.net>
15 * 2001 Juergen Stuber <stuber@loria.fr>
16 * that was derived from USB Skeleton driver - 0.5
17 * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
18 *
19 */
20
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/init.h>
24#include <linux/slab.h>
25#include <linux/module.h>
26#include <linux/usb.h>
27#include <asm/uaccess.h>
28
29#ifdef CONFIG_USB_DEBUG
30static int debug = 5;
31#else
32static int debug = 1;
33#endif
34
35/* Use our own dbg macro */
36#undef dbg
37#define dbg(lvl, format, arg...) \
38do { \
39 if (debug >= lvl) \
40 printk(KERN_DEBUG __FILE__ " : " format " \n", ## arg); \
41} while (0)
42
43
44/* Version Information */
45#define DRIVER_VERSION "v0.0.13"
46#define DRIVER_AUTHOR "John Homppi"
47#define DRIVER_DESC "adutux (see www.ontrak.net)"
48
49/* Module parameters */
50module_param(debug, int, S_IRUGO | S_IWUSR);
51MODULE_PARM_DESC(debug, "Debug enabled or not");
52
53/* Define these values to match your device */
54#define ADU_VENDOR_ID 0x0a07
55#define ADU_PRODUCT_ID 0x0064
56
57/* table of devices that work with this driver */
58static struct usb_device_id device_table [] = {
59 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID) }, /* ADU100 */
60 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+20) }, /* ADU120 */
61 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+30) }, /* ADU130 */
62 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+100) }, /* ADU200 */
63 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+108) }, /* ADU208 */
64 { USB_DEVICE(ADU_VENDOR_ID, ADU_PRODUCT_ID+118) }, /* ADU218 */
65 { }/* Terminating entry */
66};
67
68MODULE_DEVICE_TABLE(usb, device_table);
69
70#ifdef CONFIG_USB_DYNAMIC_MINORS
71#define ADU_MINOR_BASE 0
72#else
73#define ADU_MINOR_BASE 67
74#endif
75
76/* we can have up to this number of device plugged in at once */
77#define MAX_DEVICES 16
78
79#define COMMAND_TIMEOUT (2*HZ) /* 60 second timeout for a command */
80
81/* Structure to hold all of our device specific stuff */
82struct adu_device {
83 struct semaphore sem; /* locks this structure */
84 struct usb_device* udev; /* save off the usb device pointer */
85 struct usb_interface* interface;
86 unsigned char minor; /* the starting minor number for this device */
87 char serial_number[8];
88
89 int open_count; /* number of times this port has been opened */
90
91 char* read_buffer_primary;
92 int read_buffer_length;
93 char* read_buffer_secondary;
94 int secondary_head;
95 int secondary_tail;
96 spinlock_t buflock;
97
98 wait_queue_head_t read_wait;
99 wait_queue_head_t write_wait;
100
101 char* interrupt_in_buffer;
102 struct usb_endpoint_descriptor* interrupt_in_endpoint;
103 struct urb* interrupt_in_urb;
104 int read_urb_finished;
105
106 char* interrupt_out_buffer;
107 struct usb_endpoint_descriptor* interrupt_out_endpoint;
108 struct urb* interrupt_out_urb;
109};
110
111/* prevent races between open() and disconnect */
112static DEFINE_MUTEX(disconnect_mutex);
113static struct usb_driver adu_driver;
114
115static void adu_debug_data(int level, const char *function, int size,
116 const unsigned char *data)
117{
118 int i;
119
120 if (debug < level)
121 return;
122
123 printk(KERN_DEBUG __FILE__": %s - length = %d, data = ",
124 function, size);
125 for (i = 0; i < size; ++i)
126 printk("%.2x ", data[i]);
127 printk("\n");
128}
129
130/**
131 * adu_abort_transfers
132 * aborts transfers and frees associated data structures
133 */
134static void adu_abort_transfers(struct adu_device *dev)
135{
136 dbg(2," %s : enter", __FUNCTION__);
137
138 if (dev == NULL) {
139 dbg(1," %s : dev is null", __FUNCTION__);
140 goto exit;
141 }
142
143 if (dev->udev == NULL) {
144 dbg(1," %s : udev is null", __FUNCTION__);
145 goto exit;
146 }
147
148 dbg(2," %s : udev state %d", __FUNCTION__, dev->udev->state);
149 if (dev->udev->state == USB_STATE_NOTATTACHED) {
150 dbg(1," %s : udev is not attached", __FUNCTION__);
151 goto exit;
152 }
153
154 /* shutdown transfer */
155 usb_unlink_urb(dev->interrupt_in_urb);
156 usb_unlink_urb(dev->interrupt_out_urb);
157
158exit:
159 dbg(2," %s : leave", __FUNCTION__);
160}
161
162static void adu_delete(struct adu_device *dev)
163{
164 dbg(2, "%s enter", __FUNCTION__);
165
166 adu_abort_transfers(dev);
167
168 /* free data structures */
169 usb_free_urb(dev->interrupt_in_urb);
170 usb_free_urb(dev->interrupt_out_urb);
171 kfree(dev->read_buffer_primary);
172 kfree(dev->read_buffer_secondary);
173 kfree(dev->interrupt_in_buffer);
174 kfree(dev->interrupt_out_buffer);
175 kfree(dev);
176
177 dbg(2, "%s : leave", __FUNCTION__);
178}
179
180static void adu_interrupt_in_callback(struct urb *urb, struct pt_regs *regs)
181{
182 struct adu_device *dev = urb->context;
183
184 dbg(4," %s : enter, status %d", __FUNCTION__, urb->status);
185 adu_debug_data(5, __FUNCTION__, urb->actual_length,
186 urb->transfer_buffer);
187
188 spin_lock(&dev->buflock);
189
190 if (urb->status != 0) {
191 if ((urb->status != -ENOENT) && (urb->status != -ECONNRESET)) {
192 dbg(1," %s : nonzero status received: %d",
193 __FUNCTION__, urb->status);
194 }
195 goto exit;
196 }
197
198 if (urb->actual_length > 0 && dev->interrupt_in_buffer[0] != 0x00) {
199 if (dev->read_buffer_length <
200 (4 * le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize)) -
201 (urb->actual_length)) {
202 memcpy (dev->read_buffer_primary +
203 dev->read_buffer_length,
204 dev->interrupt_in_buffer, urb->actual_length);
205
206 dev->read_buffer_length += urb->actual_length;
207 dbg(2," %s reading %d ", __FUNCTION__,
208 urb->actual_length);
209 } else {
210 dbg(1," %s : read_buffer overflow", __FUNCTION__);
211 }
212 }
213
214exit:
215 dev->read_urb_finished = 1;
216 spin_unlock(&dev->buflock);
217 /* always wake up so we recover from errors */
218 wake_up_interruptible(&dev->read_wait);
219 adu_debug_data(5, __FUNCTION__, urb->actual_length,
220 urb->transfer_buffer);
221 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status);
222}
223
224static void adu_interrupt_out_callback(struct urb *urb, struct pt_regs *regs)
225{
226 struct adu_device *dev = urb->context;
227
228 dbg(4," %s : enter, status %d", __FUNCTION__, urb->status);
229 adu_debug_data(5,__FUNCTION__, urb->actual_length, urb->transfer_buffer);
230
231 if (urb->status != 0) {
232 if ((urb->status != -ENOENT) &&
233 (urb->status != -ECONNRESET)) {
234 dbg(1, " %s :nonzero status received: %d",
235 __FUNCTION__, urb->status);
236 }
237 goto exit;
238 }
239
240 wake_up_interruptible(&dev->write_wait);
241exit:
242
243 adu_debug_data(5, __FUNCTION__, urb->actual_length,
244 urb->transfer_buffer);
245 dbg(4," %s : leave, status %d", __FUNCTION__, urb->status);
246}
247
248static int adu_open(struct inode *inode, struct file *file)
249{
250 struct adu_device *dev = NULL;
251 struct usb_interface *interface;
252 int subminor;
253 int retval = 0;
254
255 dbg(2,"%s : enter", __FUNCTION__);
256
257 subminor = iminor(inode);
258
259 mutex_lock(&disconnect_mutex);
260
261 interface = usb_find_interface(&adu_driver, subminor);
262 if (!interface) {
263 err("%s - error, can't find device for minor %d",
264 __FUNCTION__, subminor);
265 retval = -ENODEV;
266 goto exit_no_device;
267 }
268
269 dev = usb_get_intfdata(interface);
270 if (!dev) {
271 retval = -ENODEV;
272 goto exit_no_device;
273 }
274
275 /* lock this device */
276 if ((retval = down_interruptible(&dev->sem))) {
277 dbg(2, "%s : sem down failed", __FUNCTION__);
278 goto exit_no_device;
279 }
280
281 /* increment our usage count for the device */
282 ++dev->open_count;
283 dbg(2,"%s : open count %d", __FUNCTION__, dev->open_count);
284
285 /* save device in the file's private structure */
286 file->private_data = dev;
287
288 /* initialize in direction */
289 dev->read_buffer_length = 0;
290
291 /* fixup first read by having urb waiting for it */
292 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
293 usb_rcvintpipe(dev->udev,
294 dev->interrupt_in_endpoint->bEndpointAddress),
295 dev->interrupt_in_buffer,
296 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
297 adu_interrupt_in_callback, dev,
298 dev->interrupt_in_endpoint->bInterval);
299 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
300 dev->read_urb_finished = 0;
301 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
302 /* we ignore failure */
303 /* end of fixup for first read */
304
305 up(&dev->sem);
306
307exit_no_device:
308 mutex_unlock(&disconnect_mutex);
309 dbg(2,"%s : leave, return value %d ", __FUNCTION__, retval);
310
311 return retval;
312}
313
314static int adu_release_internal(struct adu_device *dev)
315{
316 int retval = 0;
317
318 dbg(2," %s : enter", __FUNCTION__);
319
320 if (dev->udev == NULL) {
321 /* the device was unplugged before the file was released */
322 adu_delete(dev);
323 goto exit;
324 }
325
326 /* decrement our usage count for the device */
327 --dev->open_count;
328 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
329 if (dev->open_count <= 0) {
330 adu_abort_transfers(dev);
331 dev->open_count = 0;
332 }
333
334exit:
335 dbg(2," %s : leave", __FUNCTION__);
336 return retval;
337}
338
339static int adu_release(struct inode *inode, struct file *file)
340{
341 struct adu_device *dev = NULL;
342 int retval = 0;
343
344 dbg(2," %s : enter", __FUNCTION__);
345
346 if (file == NULL) {
347 dbg(1," %s : file is NULL", __FUNCTION__);
348 retval = -ENODEV;
349 goto exit;
350 }
351
352 dev = file->private_data;
353
354 if (dev == NULL) {
355 dbg(1," %s : object is NULL", __FUNCTION__);
356 retval = -ENODEV;
357 goto exit;
358 }
359
360 /* lock our device */
361 down(&dev->sem); /* not interruptible */
362
363 if (dev->open_count <= 0) {
364 dbg(1," %s : device not opened", __FUNCTION__);
365 retval = -ENODEV;
366 goto exit;
367 }
368
369 /* do the work */
370 retval = adu_release_internal(dev);
371
372exit:
373 up(&dev->sem);
374 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
375 return retval;
376}
377
378static ssize_t adu_read(struct file *file, __user char *buffer, size_t count,
379 loff_t *ppos)
380{
381 struct adu_device *dev;
382 size_t bytes_read = 0;
383 size_t bytes_to_read = count;
384 int i;
385 int retval = 0;
386 int timeout = 0;
387 int should_submit = 0;
388 unsigned long flags;
389 DECLARE_WAITQUEUE(wait, current);
390
391 dbg(2," %s : enter, count = %Zd, file=%p", __FUNCTION__, count, file);
392
393 dev = file->private_data;
394 dbg(2," %s : dev=%p", __FUNCTION__, dev);
395 /* lock this object */
396 if (down_interruptible(&dev->sem))
397 return -ERESTARTSYS;
398
399 /* verify that the device wasn't unplugged */
400 if (dev->udev == NULL || dev->minor == 0) {
401 retval = -ENODEV;
402 err("No device or device unplugged %d", retval);
403 goto exit;
404 }
405
406 /* verify that some data was requested */
407 if (count == 0) {
408 dbg(1," %s : read request of 0 bytes", __FUNCTION__);
409 goto exit;
410 }
411
412 timeout = COMMAND_TIMEOUT;
413 dbg(2," %s : about to start looping", __FUNCTION__);
414 while (bytes_to_read) {
415 int data_in_secondary = dev->secondary_tail - dev->secondary_head;
416 dbg(2," %s : while, data_in_secondary=%d, status=%d",
417 __FUNCTION__, data_in_secondary,
418 dev->interrupt_in_urb->status);
419
420 if (data_in_secondary) {
421 /* drain secondary buffer */
422 int amount = bytes_to_read < data_in_secondary ? bytes_to_read : data_in_secondary;
423 i = copy_to_user(buffer, dev->read_buffer_secondary+dev->secondary_head, amount);
424 if (i < 0) {
425 retval = -EFAULT;
426 goto exit;
427 }
428 dev->secondary_head += (amount - i);
429 bytes_read += (amount - i);
430 bytes_to_read -= (amount - i);
431 if (i) {
432 retval = bytes_read ? bytes_read : -EFAULT;
433 goto exit;
434 }
435 } else {
436 /* we check the primary buffer */
437 spin_lock_irqsave (&dev->buflock, flags);
438 if (dev->read_buffer_length) {
439 /* we secure access to the primary */
440 char *tmp;
441 dbg(2," %s : swap, read_buffer_length = %d",
442 __FUNCTION__, dev->read_buffer_length);
443 tmp = dev->read_buffer_secondary;
444 dev->read_buffer_secondary = dev->read_buffer_primary;
445 dev->read_buffer_primary = tmp;
446 dev->secondary_head = 0;
447 dev->secondary_tail = dev->read_buffer_length;
448 dev->read_buffer_length = 0;
449 spin_unlock_irqrestore(&dev->buflock, flags);
450 /* we have a free buffer so use it */
451 should_submit = 1;
452 } else {
453 /* even the primary was empty - we may need to do IO */
454 if (dev->interrupt_in_urb->status == -EINPROGRESS) {
455 /* somebody is doing IO */
456 spin_unlock_irqrestore(&dev->buflock, flags);
457 dbg(2," %s : submitted already", __FUNCTION__);
458 } else {
459 /* we must initiate input */
460 dbg(2," %s : initiate input", __FUNCTION__);
461 dev->read_urb_finished = 0;
462
463 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
464 usb_rcvintpipe(dev->udev,
465 dev->interrupt_in_endpoint->bEndpointAddress),
466 dev->interrupt_in_buffer,
467 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
468 adu_interrupt_in_callback,
469 dev,
470 dev->interrupt_in_endpoint->bInterval);
471 retval = usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
472 if (!retval) {
473 spin_unlock_irqrestore(&dev->buflock, flags);
474 dbg(2," %s : submitted OK", __FUNCTION__);
475 } else {
476 if (retval == -ENOMEM) {
477 retval = bytes_read ? bytes_read : -ENOMEM;
478 }
479 spin_unlock_irqrestore(&dev->buflock, flags);
480 dbg(2," %s : submit failed", __FUNCTION__);
481 goto exit;
482 }
483 }
484
485 /* we wait for I/O to complete */
486 set_current_state(TASK_INTERRUPTIBLE);
487 add_wait_queue(&dev->read_wait, &wait);
488 if (!dev->read_urb_finished)
489 timeout = schedule_timeout(COMMAND_TIMEOUT);
490 else
491 set_current_state(TASK_RUNNING);
492 remove_wait_queue(&dev->read_wait, &wait);
493
494 if (timeout <= 0) {
495 dbg(2," %s : timeout", __FUNCTION__);
496 retval = bytes_read ? bytes_read : -ETIMEDOUT;
497 goto exit;
498 }
499
500 if (signal_pending(current)) {
501 dbg(2," %s : signal pending", __FUNCTION__);
502 retval = bytes_read ? bytes_read : -EINTR;
503 goto exit;
504 }
505 }
506 }
507 }
508
509 retval = bytes_read;
510 /* if the primary buffer is empty then use it */
511 if (should_submit && !dev->interrupt_in_urb->status==-EINPROGRESS) {
512 usb_fill_int_urb(dev->interrupt_in_urb,dev->udev,
513 usb_rcvintpipe(dev->udev,
514 dev->interrupt_in_endpoint->bEndpointAddress),
515 dev->interrupt_in_buffer,
516 le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize),
517 adu_interrupt_in_callback,
518 dev,
519 dev->interrupt_in_endpoint->bInterval);
520 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
521 dev->read_urb_finished = 0;
522 usb_submit_urb(dev->interrupt_in_urb, GFP_KERNEL);
523 /* we ignore failure */
524 }
525
526exit:
527 /* unlock the device */
528 up(&dev->sem);
529
530 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
531 return retval;
532}
533
534static ssize_t adu_write(struct file *file, const __user char *buffer,
535 size_t count, loff_t *ppos)
536{
537 struct adu_device *dev;
538 size_t bytes_written = 0;
539 size_t bytes_to_write;
540 size_t buffer_size;
541 int retval = 0;
542 int timeout = 0;
543
544 dbg(2," %s : enter, count = %Zd", __FUNCTION__, count);
545
546 dev = file->private_data;
547
548 /* lock this object */
549 down_interruptible(&dev->sem);
550
551 /* verify that the device wasn't unplugged */
552 if (dev->udev == NULL || dev->minor == 0) {
553 retval = -ENODEV;
554 err("No device or device unplugged %d", retval);
555 goto exit;
556 }
557
558 /* verify that we actually have some data to write */
559 if (count == 0) {
560 dbg(1," %s : write request of 0 bytes", __FUNCTION__);
561 goto exit;
562 }
563
564
565 while (count > 0) {
566 if (dev->interrupt_out_urb->status == -EINPROGRESS) {
567 timeout = COMMAND_TIMEOUT;
568
569 while (timeout > 0) {
570 if (signal_pending(current)) {
571 dbg(1," %s : interrupted", __FUNCTION__);
572 retval = -EINTR;
573 goto exit;
574 }
575 up(&dev->sem);
576 timeout = interruptible_sleep_on_timeout(&dev->write_wait, timeout);
577 down_interruptible(&dev->sem);
578 if (timeout > 0) {
579 break;
580 }
581 dbg(1," %s : interrupted timeout: %d", __FUNCTION__, timeout);
582 }
583
584
585 dbg(1," %s : final timeout: %d", __FUNCTION__, timeout);
586
587 if (timeout == 0) {
588 dbg(1, "%s - command timed out.", __FUNCTION__);
589 retval = -ETIMEDOUT;
590 goto exit;
591 }
592
593 dbg(4," %s : in progress, count = %Zd", __FUNCTION__, count);
594
595 } else {
596 dbg(4," %s : sending, count = %Zd", __FUNCTION__, count);
597
598 /* write the data into interrupt_out_buffer from userspace */
599 buffer_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
600 bytes_to_write = count > buffer_size ? buffer_size : count;
601 dbg(4," %s : buffer_size = %Zd, count = %Zd, bytes_to_write = %Zd",
602 __FUNCTION__, buffer_size, count, bytes_to_write);
603
604 if (copy_from_user(dev->interrupt_out_buffer, buffer, bytes_to_write) != 0) {
605 retval = -EFAULT;
606 goto exit;
607 }
608
609 /* send off the urb */
610 usb_fill_int_urb(
611 dev->interrupt_out_urb,
612 dev->udev,
613 usb_sndintpipe(dev->udev, dev->interrupt_out_endpoint->bEndpointAddress),
614 dev->interrupt_out_buffer,
615 bytes_to_write,
616 adu_interrupt_out_callback,
617 dev,
618 dev->interrupt_in_endpoint->bInterval);
619 /* dev->interrupt_in_urb->transfer_flags |= URB_ASYNC_UNLINK; */
620 dev->interrupt_out_urb->actual_length = bytes_to_write;
621 retval = usb_submit_urb(dev->interrupt_out_urb, GFP_KERNEL);
622 if (retval < 0) {
623 err("Couldn't submit interrupt_out_urb %d", retval);
624 goto exit;
625 }
626
627 buffer += bytes_to_write;
628 count -= bytes_to_write;
629
630 bytes_written += bytes_to_write;
631 }
632 }
633
634 retval = bytes_written;
635
636exit:
637 /* unlock the device */
638 up(&dev->sem);
639
640 dbg(2," %s : leave, return value %d", __FUNCTION__, retval);
641
642 return retval;
643}
644
645/* file operations needed when we register this driver */
646static struct file_operations adu_fops = {
647 .owner = THIS_MODULE,
648 .read = adu_read,
649 .write = adu_write,
650 .open = adu_open,
651 .release = adu_release,
652};
653
654/*
655 * usb class driver info in order to get a minor number from the usb core,
656 * and to have the device registered with devfs and the driver core
657 */
658static struct usb_class_driver adu_class = {
659 .name = "usb/adutux%d",
660 .fops = &adu_fops,
661 .minor_base = ADU_MINOR_BASE,
662};
663
664/**
665 * adu_probe
666 *
667 * Called by the usb core when a new device is connected that it thinks
668 * this driver might be interested in.
669 */
670static int adu_probe(struct usb_interface *interface,
671 const struct usb_device_id *id)
672{
673 struct usb_device *udev = interface_to_usbdev(interface);
674 struct adu_device *dev = NULL;
675 struct usb_host_interface *iface_desc;
676 struct usb_endpoint_descriptor *endpoint;
677 int retval = -ENODEV;
678 int in_end_size;
679 int out_end_size;
680 int i;
681
682 dbg(2," %s : enter", __FUNCTION__);
683
684 if (udev == NULL) {
685 dev_err(&interface->dev, "udev is NULL.\n");
686 goto exit;
687 }
688
689 /* allocate memory for our device state and intialize it */
690 dev = kzalloc(sizeof(struct adu_device), GFP_KERNEL);
691 if (dev == NULL) {
692 dev_err(&interface->dev, "Out of memory\n");
693 retval = -ENOMEM;
694 goto exit;
695 }
696
697 init_MUTEX(&dev->sem);
698 spin_lock_init(&dev->buflock);
699 dev->udev = udev;
700 init_waitqueue_head(&dev->read_wait);
701 init_waitqueue_head(&dev->write_wait);
702
703 iface_desc = &interface->altsetting[0];
704
705 /* set up the endpoint information */
706 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
707 endpoint = &iface_desc->endpoint[i].desc;
708
709 if (usb_endpoint_is_int_in(endpoint))
710 dev->interrupt_in_endpoint = endpoint;
711
712 if (usb_endpoint_is_int_out(endpoint))
713 dev->interrupt_out_endpoint = endpoint;
714 }
715 if (dev->interrupt_in_endpoint == NULL) {
716 dev_err(&interface->dev, "interrupt in endpoint not found\n");
717 goto error;
718 }
719 if (dev->interrupt_out_endpoint == NULL) {
720 dev_err(&interface->dev, "interrupt out endpoint not found\n");
721 goto error;
722 }
723
724 in_end_size = le16_to_cpu(dev->interrupt_in_endpoint->wMaxPacketSize);
725 out_end_size = le16_to_cpu(dev->interrupt_out_endpoint->wMaxPacketSize);
726
727 dev->read_buffer_primary = kmalloc((4 * in_end_size), GFP_KERNEL);
728 if (!dev->read_buffer_primary) {
729 dev_err(&interface->dev, "Couldn't allocate read_buffer_primary\n");
730 retval = -ENOMEM;
731 goto error;
732 }
733
734 /* debug code prime the buffer */
735 memset(dev->read_buffer_primary, 'a', in_end_size);
736 memset(dev->read_buffer_primary + in_end_size, 'b', in_end_size);
737 memset(dev->read_buffer_primary + (2 * in_end_size), 'c', in_end_size);
738 memset(dev->read_buffer_primary + (3 * in_end_size), 'd', in_end_size);
739
740 dev->read_buffer_secondary = kmalloc((4 * in_end_size), GFP_KERNEL);
741 if (!dev->read_buffer_secondary) {
742 dev_err(&interface->dev, "Couldn't allocate read_buffer_secondary\n");
743 retval = -ENOMEM;
744 goto error;
745 }
746
747 /* debug code prime the buffer */
748 memset(dev->read_buffer_secondary, 'e', in_end_size);
749 memset(dev->read_buffer_secondary + in_end_size, 'f', in_end_size);
750 memset(dev->read_buffer_secondary + (2 * in_end_size), 'g', in_end_size);
751 memset(dev->read_buffer_secondary + (3 * in_end_size), 'h', in_end_size);
752
753 dev->interrupt_in_buffer = kmalloc(in_end_size, GFP_KERNEL);
754 if (!dev->interrupt_in_buffer) {
755 dev_err(&interface->dev, "Couldn't allocate interrupt_in_buffer\n");
756 goto error;
757 }
758
759 /* debug code prime the buffer */
760 memset(dev->interrupt_in_buffer, 'i', in_end_size);
761
762 dev->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
763 if (!dev->interrupt_in_urb) {
764 dev_err(&interface->dev, "Couldn't allocate interrupt_in_urb\n");
765 goto error;
766 }
767 dev->interrupt_out_buffer = kmalloc(out_end_size, GFP_KERNEL);
768 if (!dev->interrupt_out_buffer) {
769 dev_err(&interface->dev, "Couldn't allocate interrupt_out_buffer\n");
770 goto error;
771 }
772 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
773 if (!dev->interrupt_out_urb) {
774 dev_err(&interface->dev, "Couldn't allocate interrupt_out_urb\n");
775 goto error;
776 }
777
778 if (!usb_string(udev, udev->descriptor.iSerialNumber, dev->serial_number,
779 sizeof(dev->serial_number))) {
780 dev_err(&interface->dev, "Could not retrieve serial number\n");
781 goto error;
782 }
783 dbg(2," %s : serial_number=%s", __FUNCTION__, dev->serial_number);
784
785 /* we can register the device now, as it is ready */
786 usb_set_intfdata(interface, dev);
787
788 retval = usb_register_dev(interface, &adu_class);
789
790 if (retval) {
791 /* something prevented us from registering this driver */
792 dev_err(&interface->dev, "Not able to get a minor for this device.\n");
793 usb_set_intfdata(interface, NULL);
794 goto error;
795 }
796
797 dev->minor = interface->minor;
798
799 /* let the user know what node this device is now attached to */
800 dev_info(&interface->dev, "ADU%d %s now attached to /dev/usb/adutux%d",
801 udev->descriptor.idProduct, dev->serial_number,
802 (dev->minor - ADU_MINOR_BASE));
803exit:
804 dbg(2," %s : leave, return value %p (dev)", __FUNCTION__, dev);
805
806 return retval;
807
808error:
809 adu_delete(dev);
810 return retval;
811}
812
813/**
814 * adu_disconnect
815 *
816 * Called by the usb core when the device is removed from the system.
817 */
818static void adu_disconnect(struct usb_interface *interface)
819{
820 struct adu_device *dev;
821 int minor;
822
823 dbg(2," %s : enter", __FUNCTION__);
824
825 mutex_lock(&disconnect_mutex); /* not interruptible */
826
827 dev = usb_get_intfdata(interface);
828 usb_set_intfdata(interface, NULL);
829
830 down(&dev->sem); /* not interruptible */
831
832 minor = dev->minor;
833
834 /* give back our minor */
835 usb_deregister_dev(interface, &adu_class);
836 dev->minor = 0;
837
838 /* if the device is not opened, then we clean up right now */
839 dbg(2," %s : open count %d", __FUNCTION__, dev->open_count);
840 if (!dev->open_count) {
841 up(&dev->sem);
842 adu_delete(dev);
843 } else {
844 dev->udev = NULL;
845 up(&dev->sem);
846 }
847
848 mutex_unlock(&disconnect_mutex);
849
850 dev_info(&interface->dev, "ADU device adutux%d now disconnected",
851 (minor - ADU_MINOR_BASE));
852
853 dbg(2," %s : leave", __FUNCTION__);
854}
855
856/* usb specific object needed to register this driver with the usb subsystem */
857static struct usb_driver adu_driver = {
858 .name = "adutux",
859 .probe = adu_probe,
860 .disconnect = adu_disconnect,
861 .id_table = device_table,
862};
863
864static int __init adu_init(void)
865{
866 int result;
867
868 dbg(2," %s : enter", __FUNCTION__);
869
870 /* register this driver with the USB subsystem */
871 result = usb_register(&adu_driver);
872 if (result < 0) {
873 err("usb_register failed for the "__FILE__" driver. "
874 "Error number %d", result);
875 goto exit;
876 }
877
878 info("adutux " DRIVER_DESC " " DRIVER_VERSION);
879 info("adutux is an experimental driver. Use at your own risk");
880
881exit:
882 dbg(2," %s : leave, return value %d", __FUNCTION__, result);
883
884 return result;
885}
886
887static void __exit adu_exit(void)
888{
889 dbg(2," %s : enter", __FUNCTION__);
890 /* deregister this driver with the USB subsystem */
891 usb_deregister(&adu_driver);
892 dbg(2," %s : leave", __FUNCTION__);
893}
894
895module_init(adu_init);
896module_exit(adu_exit);
897
898MODULE_AUTHOR(DRIVER_AUTHOR);
899MODULE_DESCRIPTION(DRIVER_DESC);
900MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 1fef36e71c57..4fd2110b3411 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -806,7 +806,7 @@ static void auerbuf_releasebuf( pauerbuf_t bp)
8060 Initial, OK 8060 Initial, OK
807-EINPROGRESS during submission until end 807-EINPROGRESS during submission until end
808-ENOENT if urb is unlinked 808-ENOENT if urb is unlinked
809-ETIMEDOUT Transfer timed out, NAK 809-ETIME Device did not respond
810-ENOMEM Memory Overflow 810-ENOMEM Memory Overflow
811-ENODEV Specified USB-device or bus doesn't exist 811-ENODEV Specified USB-device or bus doesn't exist
812-ENXIO URB already queued 812-ENXIO URB already queued
@@ -832,7 +832,7 @@ static int auerswald_status_retry (int status)
832{ 832{
833 switch (status) { 833 switch (status) {
834 case 0: 834 case 0:
835 case -ETIMEDOUT: 835 case -ETIME:
836 case -EOVERFLOW: 836 case -EOVERFLOW:
837 case -EAGAIN: 837 case -EAGAIN:
838 case -EPIPE: 838 case -EPIPE:
@@ -1858,7 +1858,7 @@ static int auerchar_release (struct inode *inode, struct file *file)
1858 1858
1859/*----------------------------------------------------------------------*/ 1859/*----------------------------------------------------------------------*/
1860/* File operation structure */ 1860/* File operation structure */
1861static struct file_operations auerswald_fops = 1861static const struct file_operations auerswald_fops =
1862{ 1862{
1863 .owner = THIS_MODULE, 1863 .owner = THIS_MODULE,
1864 .llseek = no_llseek, 1864 .llseek = no_llseek,
diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c
index 9c46746d5d00..b63b5f34b2aa 100644
--- a/drivers/usb/misc/cypress_cy7c63.c
+++ b/drivers/usb/misc/cypress_cy7c63.c
@@ -209,7 +209,7 @@ static int cypress_probe(struct usb_interface *interface,
209 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 209 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
210 if (dev == NULL) { 210 if (dev == NULL) {
211 dev_err(&interface->dev, "Out of memory!\n"); 211 dev_err(&interface->dev, "Out of memory!\n");
212 goto error; 212 goto error_mem;
213 } 213 }
214 214
215 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 215 dev->udev = usb_get_dev(interface_to_usbdev(interface));
@@ -218,15 +218,26 @@ static int cypress_probe(struct usb_interface *interface,
218 usb_set_intfdata(interface, dev); 218 usb_set_intfdata(interface, dev);
219 219
220 /* create device attribute files */ 220 /* create device attribute files */
221 device_create_file(&interface->dev, &dev_attr_port0); 221 retval = device_create_file(&interface->dev, &dev_attr_port0);
222 device_create_file(&interface->dev, &dev_attr_port1); 222 if (retval)
223 goto error;
224 retval = device_create_file(&interface->dev, &dev_attr_port1);
225 if (retval)
226 goto error;
223 227
224 /* let the user know that the device is now attached */ 228 /* let the user know that the device is now attached */
225 dev_info(&interface->dev, 229 dev_info(&interface->dev,
226 "Cypress CY7C63xxx device now attached\n"); 230 "Cypress CY7C63xxx device now attached\n");
231 return 0;
227 232
228 retval = 0;
229error: 233error:
234 device_remove_file(&interface->dev, &dev_attr_port0);
235 device_remove_file(&interface->dev, &dev_attr_port1);
236 usb_set_intfdata(interface, NULL);
237 usb_put_dev(dev->udev);
238 kfree(dev);
239
240error_mem:
230 return retval; 241 return retval;
231} 242}
232 243
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index b20bec445552..04e87acd6e46 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -353,7 +353,7 @@ static int cytherm_probe(struct usb_interface *interface,
353 dev = kzalloc (sizeof(struct usb_cytherm), GFP_KERNEL); 353 dev = kzalloc (sizeof(struct usb_cytherm), GFP_KERNEL);
354 if (dev == NULL) { 354 if (dev == NULL) {
355 dev_err (&interface->dev, "Out of memory\n"); 355 dev_err (&interface->dev, "Out of memory\n");
356 goto error; 356 goto error_mem;
357 } 357 }
358 358
359 dev->udev = usb_get_dev(udev); 359 dev->udev = usb_get_dev(udev);
@@ -362,18 +362,35 @@ static int cytherm_probe(struct usb_interface *interface,
362 362
363 dev->brightness = 0xFF; 363 dev->brightness = 0xFF;
364 364
365 device_create_file(&interface->dev, &dev_attr_brightness); 365 retval = device_create_file(&interface->dev, &dev_attr_brightness);
366 device_create_file(&interface->dev, &dev_attr_temp); 366 if (retval)
367 device_create_file(&interface->dev, &dev_attr_button); 367 goto error;
368 device_create_file(&interface->dev, &dev_attr_port0); 368 retval = device_create_file(&interface->dev, &dev_attr_temp);
369 device_create_file(&interface->dev, &dev_attr_port1); 369 if (retval)
370 goto error;
371 retval = device_create_file(&interface->dev, &dev_attr_button);
372 if (retval)
373 goto error;
374 retval = device_create_file(&interface->dev, &dev_attr_port0);
375 if (retval)
376 goto error;
377 retval = device_create_file(&interface->dev, &dev_attr_port1);
378 if (retval)
379 goto error;
370 380
371 dev_info (&interface->dev, 381 dev_info (&interface->dev,
372 "Cypress thermometer device now attached\n"); 382 "Cypress thermometer device now attached\n");
373 return 0; 383 return 0;
374 384error:
375 error: 385 device_remove_file(&interface->dev, &dev_attr_brightness);
386 device_remove_file(&interface->dev, &dev_attr_temp);
387 device_remove_file(&interface->dev, &dev_attr_button);
388 device_remove_file(&interface->dev, &dev_attr_port0);
389 device_remove_file(&interface->dev, &dev_attr_port1);
390 usb_set_intfdata (interface, NULL);
391 usb_put_dev(dev->udev);
376 kfree(dev); 392 kfree(dev);
393error_mem:
377 return retval; 394 return retval;
378} 395}
379 396
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c
new file mode 100644
index 000000000000..b88a09497c28
--- /dev/null
+++ b/drivers/usb/misc/ftdi-elan.c
@@ -0,0 +1,2809 @@
1/*
2* USB FTDI client driver for Elan Digital Systems's Uxxx adapters
3*
4* Copyright(C) 2006 Elan Digital Systems Limited
5* http://www.elandigitalsystems.com
6*
7* Author and Maintainer - Tony Olech - Elan Digital Systems
8* tony.olech@elandigitalsystems.com
9*
10* This program is free software;you can redistribute it and/or
11* modify it under the terms of the GNU General Public License as
12* published by the Free Software Foundation, version 2.
13*
14*
15* This driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
16* based on various USB client drivers in the 2.6.15 linux kernel
17* with constant reference to the 3rd Edition of Linux Device Drivers
18* published by O'Reilly
19*
20* The U132 adapter is a USB to CardBus adapter specifically designed
21* for PC cards that contain an OHCI host controller. Typical PC cards
22* are the Orange Mobile 3G Option GlobeTrotter Fusion card.
23*
24* The U132 adapter will *NOT *work with PC cards that do not contain
25* an OHCI controller. A simple way to test whether a PC card has an
26* OHCI controller as an interface is to insert the PC card directly
27* into a laptop(or desktop) with a CardBus slot and if "lspci" shows
28* a new USB controller and "lsusb -v" shows a new OHCI Host Controller
29* then there is a good chance that the U132 adapter will support the
30* PC card.(you also need the specific client driver for the PC card)
31*
32* Please inform the Author and Maintainer about any PC cards that
33* contain OHCI Host Controller and work when directly connected to
34* an embedded CardBus slot but do not work when they are connected
35* via an ELAN U132 adapter.
36*
37*/
38#include <linux/config.h>
39#include <linux/kernel.h>
40#include <linux/errno.h>
41#include <linux/init.h>
42#include <linux/list.h>
43#include <linux/ioctl.h>
44#include <linux/slab.h>
45#include <linux/module.h>
46#include <linux/kref.h>
47#include <asm/uaccess.h>
48#include <linux/usb.h>
49#include <linux/workqueue.h>
50#include <linux/platform_device.h>
51MODULE_AUTHOR("Tony Olech");
52MODULE_DESCRIPTION("FTDI ELAN driver");
53MODULE_LICENSE("GPL");
54#define INT_MODULE_PARM(n, v) static int n = v;module_param(n, int, 0444)
55extern struct platform_driver u132_platform_driver;
56static struct workqueue_struct *status_queue;
57static struct workqueue_struct *command_queue;
58static struct workqueue_struct *respond_queue;
59/*
60* ftdi_module_lock exists to protect access to global variables
61*
62*/
63static struct semaphore ftdi_module_lock;
64static int ftdi_instances = 0;
65static struct list_head ftdi_static_list;
66/*
67* end of the global variables protected by ftdi_module_lock
68*/
69#include "usb_u132.h"
70#define TD_DEVNOTRESP 5
71/* Define these values to match your devices*/
72#define USB_FTDI_ELAN_VENDOR_ID 0x0403
73#define USB_FTDI_ELAN_PRODUCT_ID 0xd6ea
74/* table of devices that work with this driver*/
75static struct usb_device_id ftdi_elan_table[] = {
76 {USB_DEVICE(USB_FTDI_ELAN_VENDOR_ID, USB_FTDI_ELAN_PRODUCT_ID)},
77 { /* Terminating entry */ }
78};
79
80MODULE_DEVICE_TABLE(usb, ftdi_elan_table);
81/* only the jtag(firmware upgrade device) interface requires
82* a device file and corresponding minor number, but the
83* interface is created unconditionally - I suppose it could
84* be configured or not according to a module parameter.
85* But since we(now) require one interface per device,
86* and since it unlikely that a normal installation would
87* require more than a couple of elan-ftdi devices, 8 seems
88* like a reasonable limit to have here, and if someone
89* really requires more than 8 devices, then they can frig the
90* code and recompile
91*/
92#define USB_FTDI_ELAN_MINOR_BASE 192
93#define COMMAND_BITS 5
94#define COMMAND_SIZE (1<<COMMAND_BITS)
95#define COMMAND_MASK (COMMAND_SIZE-1)
96struct u132_command {
97 u8 header;
98 u16 length;
99 u8 address;
100 u8 width;
101 u32 value;
102 int follows;
103 void *buffer;
104};
105#define RESPOND_BITS 5
106#define RESPOND_SIZE (1<<RESPOND_BITS)
107#define RESPOND_MASK (RESPOND_SIZE-1)
108struct u132_respond {
109 u8 header;
110 u8 address;
111 u32 *value;
112 int *result;
113 struct completion wait_completion;
114};
115struct u132_target {
116 void *endp;
117 struct urb *urb;
118 int toggle_bits;
119 int error_count;
120 int condition_code;
121 int repeat_number;
122 int halted;
123 int skipped;
124 int actual;
125 int non_null;
126 int active;
127 int abandoning;
128 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
129 int toggle_bits, int error_count, int condition_code,
130 int repeat_number, int halted, int skipped, int actual,
131 int non_null);
132};
133/* Structure to hold all of our device specific stuff*/
134struct usb_ftdi {
135 struct list_head ftdi_list;
136 struct semaphore u132_lock;
137 int command_next;
138 int command_head;
139 struct u132_command command[COMMAND_SIZE];
140 int respond_next;
141 int respond_head;
142 struct u132_respond respond[RESPOND_SIZE];
143 struct u132_target target[4];
144 char device_name[16];
145 unsigned synchronized:1;
146 unsigned enumerated:1;
147 unsigned registered:1;
148 unsigned initialized:1;
149 unsigned card_ejected:1;
150 int function;
151 int sequence_num;
152 int disconnected;
153 int gone_away;
154 int stuck_status;
155 int status_queue_delay;
156 struct semaphore sw_lock;
157 struct usb_device *udev;
158 struct usb_interface *interface;
159 struct usb_class_driver *class;
160 struct work_struct status_work;
161 struct work_struct command_work;
162 struct work_struct respond_work;
163 struct u132_platform_data platform_data;
164 struct resource resources[0];
165 struct platform_device platform_dev;
166 unsigned char *bulk_in_buffer;
167 size_t bulk_in_size;
168 size_t bulk_in_last;
169 size_t bulk_in_left;
170 __u8 bulk_in_endpointAddr;
171 __u8 bulk_out_endpointAddr;
172 struct kref kref;
173 u32 controlreg;
174 u8 response[4 + 1024];
175 int expected;
176 int recieved;
177 int ed_found;
178};
179#define kref_to_usb_ftdi(d) container_of(d, struct usb_ftdi, kref)
180#define platform_device_to_usb_ftdi(d) container_of(d, struct usb_ftdi, \
181 platform_dev)
182static struct usb_driver ftdi_elan_driver;
183static void ftdi_elan_delete(struct kref *kref)
184{
185 struct usb_ftdi *ftdi = kref_to_usb_ftdi(kref);
186 dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi);
187 usb_put_dev(ftdi->udev);
188 ftdi->disconnected += 1;
189 down(&ftdi_module_lock);
190 list_del_init(&ftdi->ftdi_list);
191 ftdi_instances -= 1;
192 up(&ftdi_module_lock);
193 kfree(ftdi->bulk_in_buffer);
194 ftdi->bulk_in_buffer = NULL;
195}
196
197static void ftdi_elan_put_kref(struct usb_ftdi *ftdi)
198{
199 kref_put(&ftdi->kref, ftdi_elan_delete);
200}
201
202static void ftdi_elan_get_kref(struct usb_ftdi *ftdi)
203{
204 kref_get(&ftdi->kref);
205}
206
207static void ftdi_elan_init_kref(struct usb_ftdi *ftdi)
208{
209 kref_init(&ftdi->kref);
210}
211
212static void ftdi_status_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
213{
214 if (delta > 0) {
215 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
216 return;
217 } else if (queue_work(status_queue, &ftdi->status_work))
218 return;
219 kref_put(&ftdi->kref, ftdi_elan_delete);
220 return;
221}
222
223static void ftdi_status_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
224{
225 if (delta > 0) {
226 if (queue_delayed_work(status_queue, &ftdi->status_work, delta))
227 kref_get(&ftdi->kref);
228 } else if (queue_work(status_queue, &ftdi->status_work))
229 kref_get(&ftdi->kref);
230 return;
231}
232
233static void ftdi_status_cancel_work(struct usb_ftdi *ftdi)
234{
235 if (cancel_delayed_work(&ftdi->status_work))
236 kref_put(&ftdi->kref, ftdi_elan_delete);
237}
238
239static void ftdi_command_requeue_work(struct usb_ftdi *ftdi, unsigned int delta)
240{
241 if (delta > 0) {
242 if (queue_delayed_work(command_queue, &ftdi->command_work,
243 delta))
244 return;
245 } else if (queue_work(command_queue, &ftdi->command_work))
246 return;
247 kref_put(&ftdi->kref, ftdi_elan_delete);
248 return;
249}
250
251static void ftdi_command_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
252{
253 if (delta > 0) {
254 if (queue_delayed_work(command_queue, &ftdi->command_work,
255 delta))
256 kref_get(&ftdi->kref);
257 } else if (queue_work(command_queue, &ftdi->command_work))
258 kref_get(&ftdi->kref);
259 return;
260}
261
262static void ftdi_command_cancel_work(struct usb_ftdi *ftdi)
263{
264 if (cancel_delayed_work(&ftdi->command_work))
265 kref_put(&ftdi->kref, ftdi_elan_delete);
266}
267
268static void ftdi_response_requeue_work(struct usb_ftdi *ftdi,
269 unsigned int delta)
270{
271 if (delta > 0) {
272 if (queue_delayed_work(respond_queue, &ftdi->respond_work,
273 delta))
274 return;
275 } else if (queue_work(respond_queue, &ftdi->respond_work))
276 return;
277 kref_put(&ftdi->kref, ftdi_elan_delete);
278 return;
279}
280
281static void ftdi_respond_queue_work(struct usb_ftdi *ftdi, unsigned int delta)
282{
283 if (delta > 0) {
284 if (queue_delayed_work(respond_queue, &ftdi->respond_work,
285 delta))
286 kref_get(&ftdi->kref);
287 } else if (queue_work(respond_queue, &ftdi->respond_work))
288 kref_get(&ftdi->kref);
289 return;
290}
291
292static void ftdi_response_cancel_work(struct usb_ftdi *ftdi)
293{
294 if (cancel_delayed_work(&ftdi->respond_work))
295 kref_put(&ftdi->kref, ftdi_elan_delete);
296}
297
298void ftdi_elan_gone_away(struct platform_device *pdev)
299{
300 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
301 ftdi->gone_away += 1;
302 ftdi_elan_put_kref(ftdi);
303}
304
305
306EXPORT_SYMBOL_GPL(ftdi_elan_gone_away);
307void ftdi_release_platform_dev(struct device *dev)
308{
309 dev->parent = NULL;
310}
311
312static void ftdi_elan_do_callback(struct usb_ftdi *ftdi,
313 struct u132_target *target, u8 *buffer, int length);
314static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi);
315static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi);
316static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi);
317static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi);
318static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi);
319static int ftdi_elan_synchronize(struct usb_ftdi *ftdi);
320static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi);
321static int ftdi_elan_command_engine(struct usb_ftdi *ftdi);
322static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi);
323static int ftdi_elan_hcd_init(struct usb_ftdi *ftdi)
324{
325 int result;
326 if (ftdi->platform_dev.dev.parent)
327 return -EBUSY;
328 ftdi_elan_get_kref(ftdi);
329 ftdi->platform_data.potpg = 100;
330 ftdi->platform_data.reset = NULL;
331 ftdi->platform_dev.id = ftdi->sequence_num;
332 ftdi->platform_dev.resource = ftdi->resources;
333 ftdi->platform_dev.num_resources = ARRAY_SIZE(ftdi->resources);
334 ftdi->platform_dev.dev.platform_data = &ftdi->platform_data;
335 ftdi->platform_dev.dev.parent = NULL;
336 ftdi->platform_dev.dev.release = ftdi_release_platform_dev;
337 ftdi->platform_dev.dev.dma_mask = NULL;
338 snprintf(ftdi->device_name, sizeof(ftdi->device_name), "u132_hcd");
339 ftdi->platform_dev.name = ftdi->device_name;
340 dev_info(&ftdi->udev->dev, "requesting module '%s'\n", "u132_hcd");
341 request_module("u132_hcd");
342 dev_info(&ftdi->udev->dev, "registering '%s'\n",
343 ftdi->platform_dev.name);
344 result = platform_device_register(&ftdi->platform_dev);
345 return result;
346}
347
348static void ftdi_elan_abandon_completions(struct usb_ftdi *ftdi)
349{
350 down(&ftdi->u132_lock);
351 while (ftdi->respond_next > ftdi->respond_head) {
352 struct u132_respond *respond = &ftdi->respond[RESPOND_MASK &
353 ftdi->respond_head++];
354 *respond->result = -ESHUTDOWN;
355 *respond->value = 0;
356 complete(&respond->wait_completion);
357 } up(&ftdi->u132_lock);
358}
359
360static void ftdi_elan_abandon_targets(struct usb_ftdi *ftdi)
361{
362 int ed_number = 4;
363 down(&ftdi->u132_lock);
364 while (ed_number-- > 0) {
365 struct u132_target *target = &ftdi->target[ed_number];
366 if (target->active == 1) {
367 target->condition_code = TD_DEVNOTRESP;
368 up(&ftdi->u132_lock);
369 ftdi_elan_do_callback(ftdi, target, NULL, 0);
370 down(&ftdi->u132_lock);
371 }
372 }
373 ftdi->recieved = 0;
374 ftdi->expected = 4;
375 ftdi->ed_found = 0;
376 up(&ftdi->u132_lock);
377}
378
379static void ftdi_elan_flush_targets(struct usb_ftdi *ftdi)
380{
381 int ed_number = 4;
382 down(&ftdi->u132_lock);
383 while (ed_number-- > 0) {
384 struct u132_target *target = &ftdi->target[ed_number];
385 target->abandoning = 1;
386 wait_1:if (target->active == 1) {
387 int command_size = ftdi->command_next -
388 ftdi->command_head;
389 if (command_size < COMMAND_SIZE) {
390 struct u132_command *command = &ftdi->command[
391 COMMAND_MASK & ftdi->command_next];
392 command->header = 0x80 | (ed_number << 5) | 0x4;
393 command->length = 0x00;
394 command->address = 0x00;
395 command->width = 0x00;
396 command->follows = 0;
397 command->value = 0;
398 command->buffer = &command->value;
399 ftdi->command_next += 1;
400 ftdi_elan_kick_command_queue(ftdi);
401 } else {
402 up(&ftdi->u132_lock);
403 msleep(100);
404 down(&ftdi->u132_lock);
405 goto wait_1;
406 }
407 }
408 wait_2:if (target->active == 1) {
409 int command_size = ftdi->command_next -
410 ftdi->command_head;
411 if (command_size < COMMAND_SIZE) {
412 struct u132_command *command = &ftdi->command[
413 COMMAND_MASK & ftdi->command_next];
414 command->header = 0x90 | (ed_number << 5);
415 command->length = 0x00;
416 command->address = 0x00;
417 command->width = 0x00;
418 command->follows = 0;
419 command->value = 0;
420 command->buffer = &command->value;
421 ftdi->command_next += 1;
422 ftdi_elan_kick_command_queue(ftdi);
423 } else {
424 up(&ftdi->u132_lock);
425 msleep(100);
426 down(&ftdi->u132_lock);
427 goto wait_2;
428 }
429 }
430 }
431 ftdi->recieved = 0;
432 ftdi->expected = 4;
433 ftdi->ed_found = 0;
434 up(&ftdi->u132_lock);
435}
436
437static void ftdi_elan_cancel_targets(struct usb_ftdi *ftdi)
438{
439 int ed_number = 4;
440 down(&ftdi->u132_lock);
441 while (ed_number-- > 0) {
442 struct u132_target *target = &ftdi->target[ed_number];
443 target->abandoning = 1;
444 wait:if (target->active == 1) {
445 int command_size = ftdi->command_next -
446 ftdi->command_head;
447 if (command_size < COMMAND_SIZE) {
448 struct u132_command *command = &ftdi->command[
449 COMMAND_MASK & ftdi->command_next];
450 command->header = 0x80 | (ed_number << 5) | 0x4;
451 command->length = 0x00;
452 command->address = 0x00;
453 command->width = 0x00;
454 command->follows = 0;
455 command->value = 0;
456 command->buffer = &command->value;
457 ftdi->command_next += 1;
458 ftdi_elan_kick_command_queue(ftdi);
459 } else {
460 up(&ftdi->u132_lock);
461 msleep(100);
462 down(&ftdi->u132_lock);
463 goto wait;
464 }
465 }
466 }
467 ftdi->recieved = 0;
468 ftdi->expected = 4;
469 ftdi->ed_found = 0;
470 up(&ftdi->u132_lock);
471}
472
473static void ftdi_elan_kick_command_queue(struct usb_ftdi *ftdi)
474{
475 ftdi_command_queue_work(ftdi, 0);
476 return;
477}
478
479static void ftdi_elan_command_work(void *data)
480{
481 struct usb_ftdi *ftdi = data;
482 if (ftdi->disconnected > 0) {
483 ftdi_elan_put_kref(ftdi);
484 return;
485 } else {
486 int retval = ftdi_elan_command_engine(ftdi);
487 if (retval == -ESHUTDOWN) {
488 ftdi->disconnected += 1;
489 } else if (retval == -ENODEV) {
490 ftdi->disconnected += 1;
491 } else if (retval)
492 dev_err(&ftdi->udev->dev, "command error %d\n", retval);
493 ftdi_command_requeue_work(ftdi, msecs_to_jiffies(10));
494 return;
495 }
496}
497
498static void ftdi_elan_kick_respond_queue(struct usb_ftdi *ftdi)
499{
500 ftdi_respond_queue_work(ftdi, 0);
501 return;
502}
503
504static void ftdi_elan_respond_work(void *data)
505{
506 struct usb_ftdi *ftdi = data;
507 if (ftdi->disconnected > 0) {
508 ftdi_elan_put_kref(ftdi);
509 return;
510 } else {
511 int retval = ftdi_elan_respond_engine(ftdi);
512 if (retval == 0) {
513 } else if (retval == -ESHUTDOWN) {
514 ftdi->disconnected += 1;
515 } else if (retval == -ENODEV) {
516 ftdi->disconnected += 1;
517 } else if (retval == -ENODEV) {
518 ftdi->disconnected += 1;
519 } else if (retval == -EILSEQ) {
520 ftdi->disconnected += 1;
521 } else {
522 ftdi->disconnected += 1;
523 dev_err(&ftdi->udev->dev, "respond error %d\n", retval);
524 }
525 if (ftdi->disconnected > 0) {
526 ftdi_elan_abandon_completions(ftdi);
527 ftdi_elan_abandon_targets(ftdi);
528 }
529 ftdi_response_requeue_work(ftdi, msecs_to_jiffies(10));
530 return;
531 }
532}
533
534
535/*
536* the sw_lock is initially held and will be freed
537* after the FTDI has been synchronized
538*
539*/
540static void ftdi_elan_status_work(void *data)
541{
542 struct usb_ftdi *ftdi = data;
543 int work_delay_in_msec = 0;
544 if (ftdi->disconnected > 0) {
545 ftdi_elan_put_kref(ftdi);
546 return;
547 } else if (ftdi->synchronized == 0) {
548 down(&ftdi->sw_lock);
549 if (ftdi_elan_synchronize(ftdi) == 0) {
550 ftdi->synchronized = 1;
551 ftdi_command_queue_work(ftdi, 1);
552 ftdi_respond_queue_work(ftdi, 1);
553 up(&ftdi->sw_lock);
554 work_delay_in_msec = 100;
555 } else {
556 dev_err(&ftdi->udev->dev, "synchronize failed\n");
557 up(&ftdi->sw_lock);
558 work_delay_in_msec = 10 *1000;
559 }
560 } else if (ftdi->stuck_status > 0) {
561 if (ftdi_elan_stuck_waiting(ftdi) == 0) {
562 ftdi->stuck_status = 0;
563 ftdi->synchronized = 0;
564 } else if ((ftdi->stuck_status++ % 60) == 1) {
565 dev_err(&ftdi->udev->dev, "WRONG type of card inserted "
566 "- please remove\n");
567 } else
568 dev_err(&ftdi->udev->dev, "WRONG type of card inserted "
569 "- checked %d times\n", ftdi->stuck_status);
570 work_delay_in_msec = 100;
571 } else if (ftdi->enumerated == 0) {
572 if (ftdi_elan_enumeratePCI(ftdi) == 0) {
573 ftdi->enumerated = 1;
574 work_delay_in_msec = 250;
575 } else
576 work_delay_in_msec = 1000;
577 } else if (ftdi->initialized == 0) {
578 if (ftdi_elan_setupOHCI(ftdi) == 0) {
579 ftdi->initialized = 1;
580 work_delay_in_msec = 500;
581 } else {
582 dev_err(&ftdi->udev->dev, "initialized failed - trying "
583 "again in 10 seconds\n");
584 work_delay_in_msec = 10 *1000;
585 }
586 } else if (ftdi->registered == 0) {
587 work_delay_in_msec = 10;
588 if (ftdi_elan_hcd_init(ftdi) == 0) {
589 ftdi->registered = 1;
590 } else
591 dev_err(&ftdi->udev->dev, "register failed\n");
592 work_delay_in_msec = 250;
593 } else {
594 if (ftdi_elan_checkingPCI(ftdi) == 0) {
595 work_delay_in_msec = 250;
596 } else if (ftdi->controlreg & 0x00400000) {
597 if (ftdi->gone_away > 0) {
598 dev_err(&ftdi->udev->dev, "PCI device eject con"
599 "firmed platform_dev.dev.parent=%p plat"
600 "form_dev.dev=%p\n",
601 ftdi->platform_dev.dev.parent,
602 &ftdi->platform_dev.dev);
603 platform_device_unregister(&ftdi->platform_dev);
604 ftdi->platform_dev.dev.parent = NULL;
605 ftdi->registered = 0;
606 ftdi->enumerated = 0;
607 ftdi->card_ejected = 0;
608 ftdi->initialized = 0;
609 ftdi->gone_away = 0;
610 } else
611 ftdi_elan_flush_targets(ftdi);
612 work_delay_in_msec = 250;
613 } else {
614 dev_err(&ftdi->udev->dev, "PCI device has disappeared\n"
615 );
616 ftdi_elan_cancel_targets(ftdi);
617 work_delay_in_msec = 500;
618 ftdi->enumerated = 0;
619 ftdi->initialized = 0;
620 }
621 }
622 if (ftdi->disconnected > 0) {
623 ftdi_elan_put_kref(ftdi);
624 return;
625 } else {
626 ftdi_status_requeue_work(ftdi,
627 msecs_to_jiffies(work_delay_in_msec));
628 return;
629 }
630}
631
632
633/*
634* file_operations for the jtag interface
635*
636* the usage count for the device is incremented on open()
637* and decremented on release()
638*/
639static int ftdi_elan_open(struct inode *inode, struct file *file)
640{
641 int subminor = iminor(inode);
642 struct usb_interface *interface = usb_find_interface(&ftdi_elan_driver,
643 subminor);
644 if (!interface) {
645 printk(KERN_ERR "can't find device for minor %d\n", subminor);
646 return -ENODEV;
647 } else {
648 struct usb_ftdi *ftdi = usb_get_intfdata(interface);
649 if (!ftdi) {
650 return -ENODEV;
651 } else {
652 if (down_interruptible(&ftdi->sw_lock)) {
653 return -EINTR;
654 } else {
655 ftdi_elan_get_kref(ftdi);
656 file->private_data = ftdi;
657 return 0;
658 }
659 }
660 }
661}
662
663static int ftdi_elan_release(struct inode *inode, struct file *file)
664{
665 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
666 if (ftdi == NULL)
667 return -ENODEV;
668 up(&ftdi->sw_lock); /* decrement the count on our device */
669 ftdi_elan_put_kref(ftdi);
670 return 0;
671}
672
673
674#define FTDI_ELAN_IOC_MAGIC 0xA1
675#define FTDI_ELAN_IOCDEBUG _IOC(_IOC_WRITE, FTDI_ELAN_IOC_MAGIC, 1, 132)
676static int ftdi_elan_ioctl(struct inode *inode, struct file *file,
677 unsigned int cmd, unsigned long arg)
678{
679 switch (cmd) {
680 case FTDI_ELAN_IOCDEBUG:{
681 char line[132];
682 int size = strncpy_from_user(line,
683 (const char __user *)arg, sizeof(line));
684 if (size < 0) {
685 return -EINVAL;
686 } else {
687 printk(KERN_ERR "TODO: ioctl %s\n", line);
688 return 0;
689 }
690 }
691 default:
692 return -EFAULT;
693 }
694}
695
696
697/*
698*
699* blocking bulk reads are used to get data from the device
700*
701*/
702static ssize_t ftdi_elan_read(struct file *file, char __user *buffer,
703 size_t count, loff_t *ppos)
704{
705 char data[30 *3 + 4];
706 char *d = data;
707 int m = (sizeof(data) - 1) / 3;
708 int bytes_read = 0;
709 int retry_on_empty = 10;
710 int retry_on_timeout = 5;
711 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
712 if (ftdi->disconnected > 0) {
713 return -ENODEV;
714 }
715 data[0] = 0;
716 have:if (ftdi->bulk_in_left > 0) {
717 if (count-- > 0) {
718 char *p = ++ftdi->bulk_in_last + ftdi->bulk_in_buffer;
719 ftdi->bulk_in_left -= 1;
720 if (bytes_read < m) {
721 d += sprintf(d, " %02X", 0x000000FF & *p);
722 } else if (bytes_read > m) {
723 } else
724 d += sprintf(d, " ..");
725 if (copy_to_user(buffer++, p, 1)) {
726 return -EFAULT;
727 } else {
728 bytes_read += 1;
729 goto have;
730 }
731 } else
732 return bytes_read;
733 }
734 more:if (count > 0) {
735 int packet_bytes = 0;
736 int retval = usb_bulk_msg(ftdi->udev,
737 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr),
738 ftdi->bulk_in_buffer, ftdi->bulk_in_size,
739 &packet_bytes, msecs_to_jiffies(50));
740 if (packet_bytes > 2) {
741 ftdi->bulk_in_left = packet_bytes - 2;
742 ftdi->bulk_in_last = 1;
743 goto have;
744 } else if (retval == -ETIMEDOUT) {
745 if (retry_on_timeout-- > 0) {
746 goto more;
747 } else if (bytes_read > 0) {
748 return bytes_read;
749 } else
750 return retval;
751 } else if (retval == 0) {
752 if (retry_on_empty-- > 0) {
753 goto more;
754 } else
755 return bytes_read;
756 } else
757 return retval;
758 } else
759 return bytes_read;
760}
761
762static void ftdi_elan_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
763{
764 struct usb_ftdi *ftdi = (struct usb_ftdi *)urb->context;
765 if (urb->status && !(urb->status == -ENOENT || urb->status ==
766 -ECONNRESET || urb->status == -ESHUTDOWN)) {
767 dev_err(&ftdi->udev->dev, "urb=%p write bulk status received: %"
768 "d\n", urb, urb->status);
769 }
770 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
771 urb->transfer_buffer, urb->transfer_dma);
772}
773
774static int fill_buffer_with_all_queued_commands(struct usb_ftdi *ftdi,
775 char *buf, int command_size, int total_size)
776{
777 int ed_commands = 0;
778 int b = 0;
779 int I = command_size;
780 int i = ftdi->command_head;
781 while (I-- > 0) {
782 struct u132_command *command = &ftdi->command[COMMAND_MASK &
783 i++];
784 int F = command->follows;
785 u8 *f = command->buffer;
786 if (command->header & 0x80) {
787 ed_commands |= 1 << (0x3 & (command->header >> 5));
788 }
789 buf[b++] = command->header;
790 buf[b++] = (command->length >> 0) & 0x00FF;
791 buf[b++] = (command->length >> 8) & 0x00FF;
792 buf[b++] = command->address;
793 buf[b++] = command->width;
794 while (F-- > 0) {
795 buf[b++] = *f++;
796 }
797 }
798 return ed_commands;
799}
800
801static int ftdi_elan_total_command_size(struct usb_ftdi *ftdi, int command_size)
802{
803 int total_size = 0;
804 int I = command_size;
805 int i = ftdi->command_head;
806 while (I-- > 0) {
807 struct u132_command *command = &ftdi->command[COMMAND_MASK &
808 i++];
809 total_size += 5 + command->follows;
810 } return total_size;
811}
812
813static int ftdi_elan_command_engine(struct usb_ftdi *ftdi)
814{
815 int retval;
816 char *buf;
817 int ed_commands;
818 int total_size;
819 struct urb *urb;
820 int command_size = ftdi->command_next - ftdi->command_head;
821 if (command_size == 0)
822 return 0;
823 total_size = ftdi_elan_total_command_size(ftdi, command_size);
824 urb = usb_alloc_urb(0, GFP_KERNEL);
825 if (!urb) {
826 dev_err(&ftdi->udev->dev, "could not get a urb to write %d comm"
827 "ands totaling %d bytes to the Uxxx\n", command_size,
828 total_size);
829 return -ENOMEM;
830 }
831 buf = usb_buffer_alloc(ftdi->udev, total_size, GFP_KERNEL,
832 &urb->transfer_dma);
833 if (!buf) {
834 dev_err(&ftdi->udev->dev, "could not get a buffer to write %d c"
835 "ommands totaling %d bytes to the Uxxx\n", command_size,
836 total_size);
837 usb_free_urb(urb);
838 return -ENOMEM;
839 }
840 ed_commands = fill_buffer_with_all_queued_commands(ftdi, buf,
841 command_size, total_size);
842 usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev,
843 ftdi->bulk_out_endpointAddr), buf, total_size,
844 ftdi_elan_write_bulk_callback, ftdi);
845 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
846 if (ed_commands) {
847 char diag[40 *3 + 4];
848 char *d = diag;
849 int m = total_size;
850 u8 *c = buf;
851 int s = (sizeof(diag) - 1) / 3;
852 diag[0] = 0;
853 while (s-- > 0 && m-- > 0) {
854 if (s > 0 || m == 0) {
855 d += sprintf(d, " %02X", *c++);
856 } else
857 d += sprintf(d, " ..");
858 }
859 }
860 retval = usb_submit_urb(urb, GFP_KERNEL);
861 if (retval) {
862 dev_err(&ftdi->udev->dev, "failed %d to submit urb %p to write "
863 "%d commands totaling %d bytes to the Uxxx\n", retval,
864 urb, command_size, total_size);
865 usb_buffer_free(ftdi->udev, total_size, buf, urb->transfer_dma);
866 usb_free_urb(urb);
867 return retval;
868 }
869 usb_free_urb(urb); /* release our reference to this urb,
870 the USB core will eventually free it entirely */
871 ftdi->command_head += command_size;
872 ftdi_elan_kick_respond_queue(ftdi);
873 return 0;
874}
875
876static void ftdi_elan_do_callback(struct usb_ftdi *ftdi,
877 struct u132_target *target, u8 *buffer, int length)
878{
879 struct urb *urb = target->urb;
880 int halted = target->halted;
881 int skipped = target->skipped;
882 int actual = target->actual;
883 int non_null = target->non_null;
884 int toggle_bits = target->toggle_bits;
885 int error_count = target->error_count;
886 int condition_code = target->condition_code;
887 int repeat_number = target->repeat_number;
888 void (*callback) (void *, struct urb *, u8 *, int, int, int, int, int,
889 int, int, int, int) = target->callback;
890 target->active -= 1;
891 target->callback = NULL;
892 (*callback) (target->endp, urb, buffer, length, toggle_bits,
893 error_count, condition_code, repeat_number, halted, skipped,
894 actual, non_null);
895}
896
897static char *have_ed_set_response(struct usb_ftdi *ftdi,
898 struct u132_target *target, u16 ed_length, int ed_number, int ed_type,
899 char *b)
900{
901 int payload = (ed_length >> 0) & 0x07FF;
902 down(&ftdi->u132_lock);
903 target->actual = 0;
904 target->non_null = (ed_length >> 15) & 0x0001;
905 target->repeat_number = (ed_length >> 11) & 0x000F;
906 if (ed_type == 0x02) {
907 if (payload == 0 || target->abandoning > 0) {
908 target->abandoning = 0;
909 up(&ftdi->u132_lock);
910 ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response,
911 payload);
912 ftdi->recieved = 0;
913 ftdi->expected = 4;
914 ftdi->ed_found = 0;
915 return ftdi->response;
916 } else {
917 ftdi->expected = 4 + payload;
918 ftdi->ed_found = 1;
919 up(&ftdi->u132_lock);
920 return b;
921 }
922 } else if (ed_type == 0x03) {
923 if (payload == 0 || target->abandoning > 0) {
924 target->abandoning = 0;
925 up(&ftdi->u132_lock);
926 ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response,
927 payload);
928 ftdi->recieved = 0;
929 ftdi->expected = 4;
930 ftdi->ed_found = 0;
931 return ftdi->response;
932 } else {
933 ftdi->expected = 4 + payload;
934 ftdi->ed_found = 1;
935 up(&ftdi->u132_lock);
936 return b;
937 }
938 } else if (ed_type == 0x01) {
939 target->abandoning = 0;
940 up(&ftdi->u132_lock);
941 ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response,
942 payload);
943 ftdi->recieved = 0;
944 ftdi->expected = 4;
945 ftdi->ed_found = 0;
946 return ftdi->response;
947 } else {
948 target->abandoning = 0;
949 up(&ftdi->u132_lock);
950 ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response,
951 payload);
952 ftdi->recieved = 0;
953 ftdi->expected = 4;
954 ftdi->ed_found = 0;
955 return ftdi->response;
956 }
957}
958
959static char *have_ed_get_response(struct usb_ftdi *ftdi,
960 struct u132_target *target, u16 ed_length, int ed_number, int ed_type,
961 char *b)
962{
963 down(&ftdi->u132_lock);
964 target->condition_code = TD_DEVNOTRESP;
965 target->actual = (ed_length >> 0) & 0x01FF;
966 target->non_null = (ed_length >> 15) & 0x0001;
967 target->repeat_number = (ed_length >> 11) & 0x000F;
968 up(&ftdi->u132_lock);
969 if (target->active)
970 ftdi_elan_do_callback(ftdi, target, NULL, 0);
971 target->abandoning = 0;
972 ftdi->recieved = 0;
973 ftdi->expected = 4;
974 ftdi->ed_found = 0;
975 return ftdi->response;
976}
977
978
979/*
980* The engine tries to empty the FTDI fifo
981*
982* all responses found in the fifo data are dispatched thus
983* the response buffer can only ever hold a maximum sized
984* response from the Uxxx.
985*
986*/
987static int ftdi_elan_respond_engine(struct usb_ftdi *ftdi)
988{
989 u8 *b = ftdi->response + ftdi->recieved;
990 int bytes_read = 0;
991 int retry_on_empty = 1;
992 int retry_on_timeout = 3;
993 int empty_packets = 0;
994 read:{
995 int packet_bytes = 0;
996 int retval = usb_bulk_msg(ftdi->udev,
997 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr),
998 ftdi->bulk_in_buffer, ftdi->bulk_in_size,
999 &packet_bytes, msecs_to_jiffies(500));
1000 char diag[30 *3 + 4];
1001 char *d = diag;
1002 int m = packet_bytes;
1003 u8 *c = ftdi->bulk_in_buffer;
1004 int s = (sizeof(diag) - 1) / 3;
1005 diag[0] = 0;
1006 while (s-- > 0 && m-- > 0) {
1007 if (s > 0 || m == 0) {
1008 d += sprintf(d, " %02X", *c++);
1009 } else
1010 d += sprintf(d, " ..");
1011 }
1012 if (packet_bytes > 2) {
1013 ftdi->bulk_in_left = packet_bytes - 2;
1014 ftdi->bulk_in_last = 1;
1015 goto have;
1016 } else if (retval == -ETIMEDOUT) {
1017 if (retry_on_timeout-- > 0) {
1018 dev_err(&ftdi->udev->dev, "TIMED OUT with packe"
1019 "t_bytes = %d with total %d bytes%s\n",
1020 packet_bytes, bytes_read, diag);
1021 goto more;
1022 } else if (bytes_read > 0) {
1023 dev_err(&ftdi->udev->dev, "ONLY %d bytes%s\n",
1024 bytes_read, diag);
1025 return -ENOMEM;
1026 } else {
1027 dev_err(&ftdi->udev->dev, "TIMED OUT with packe"
1028 "t_bytes = %d with total %d bytes%s\n",
1029 packet_bytes, bytes_read, diag);
1030 return -ENOMEM;
1031 }
1032 } else if (retval == -EILSEQ) {
1033 dev_err(&ftdi->udev->dev, "error = %d with packet_bytes"
1034 " = %d with total %d bytes%s\n", retval,
1035 packet_bytes, bytes_read, diag);
1036 return retval;
1037 } else if (retval) {
1038 dev_err(&ftdi->udev->dev, "error = %d with packet_bytes"
1039 " = %d with total %d bytes%s\n", retval,
1040 packet_bytes, bytes_read, diag);
1041 return retval;
1042 } else if (packet_bytes == 2) {
1043 unsigned char s0 = ftdi->bulk_in_buffer[0];
1044 unsigned char s1 = ftdi->bulk_in_buffer[1];
1045 empty_packets += 1;
1046 if (s0 == 0x31 && s1 == 0x60) {
1047 if (retry_on_empty-- > 0) {
1048 goto more;
1049 } else
1050 return 0;
1051 } else if (s0 == 0x31 && s1 == 0x00) {
1052 if (retry_on_empty-- > 0) {
1053 goto more;
1054 } else
1055 return 0;
1056 } else {
1057 if (retry_on_empty-- > 0) {
1058 goto more;
1059 } else
1060 return 0;
1061 }
1062 } else if (packet_bytes == 1) {
1063 if (retry_on_empty-- > 0) {
1064 goto more;
1065 } else
1066 return 0;
1067 } else {
1068 if (retry_on_empty-- > 0) {
1069 goto more;
1070 } else
1071 return 0;
1072 }
1073 }
1074 more:{
1075 goto read;
1076 }
1077 have:if (ftdi->bulk_in_left > 0) {
1078 u8 c = ftdi->bulk_in_buffer[++ftdi->bulk_in_last];
1079 bytes_read += 1;
1080 ftdi->bulk_in_left -= 1;
1081 if (ftdi->recieved == 0 && c == 0xFF) {
1082 goto have;
1083 } else
1084 *b++ = c;
1085 if (++ftdi->recieved < ftdi->expected) {
1086 goto have;
1087 } else if (ftdi->ed_found) {
1088 int ed_number = (ftdi->response[0] >> 5) & 0x03;
1089 u16 ed_length = (ftdi->response[2] << 8) |
1090 ftdi->response[1];
1091 struct u132_target *target = &ftdi->target[ed_number];
1092 int payload = (ed_length >> 0) & 0x07FF;
1093 char diag[30 *3 + 4];
1094 char *d = diag;
1095 int m = payload;
1096 u8 *c = 4 + ftdi->response;
1097 int s = (sizeof(diag) - 1) / 3;
1098 diag[0] = 0;
1099 while (s-- > 0 && m-- > 0) {
1100 if (s > 0 || m == 0) {
1101 d += sprintf(d, " %02X", *c++);
1102 } else
1103 d += sprintf(d, " ..");
1104 }
1105 ftdi_elan_do_callback(ftdi, target, 4 + ftdi->response,
1106 payload);
1107 ftdi->recieved = 0;
1108 ftdi->expected = 4;
1109 ftdi->ed_found = 0;
1110 b = ftdi->response;
1111 goto have;
1112 } else if (ftdi->expected == 8) {
1113 u8 buscmd;
1114 int respond_head = ftdi->respond_head++;
1115 struct u132_respond *respond = &ftdi->respond[
1116 RESPOND_MASK & respond_head];
1117 u32 data = ftdi->response[7];
1118 data <<= 8;
1119 data |= ftdi->response[6];
1120 data <<= 8;
1121 data |= ftdi->response[5];
1122 data <<= 8;
1123 data |= ftdi->response[4];
1124 *respond->value = data;
1125 *respond->result = 0;
1126 complete(&respond->wait_completion);
1127 ftdi->recieved = 0;
1128 ftdi->expected = 4;
1129 ftdi->ed_found = 0;
1130 b = ftdi->response;
1131 buscmd = (ftdi->response[0] >> 0) & 0x0F;
1132 if (buscmd == 0x00) {
1133 } else if (buscmd == 0x02) {
1134 } else if (buscmd == 0x06) {
1135 } else if (buscmd == 0x0A) {
1136 } else
1137 dev_err(&ftdi->udev->dev, "Uxxx unknown(%0X) va"
1138 "lue = %08X\n", buscmd, data);
1139 goto have;
1140 } else {
1141 if ((ftdi->response[0] & 0x80) == 0x00) {
1142 ftdi->expected = 8;
1143 goto have;
1144 } else {
1145 int ed_number = (ftdi->response[0] >> 5) & 0x03;
1146 int ed_type = (ftdi->response[0] >> 0) & 0x03;
1147 u16 ed_length = (ftdi->response[2] << 8) |
1148 ftdi->response[1];
1149 struct u132_target *target = &ftdi->target[
1150 ed_number];
1151 target->halted = (ftdi->response[0] >> 3) &
1152 0x01;
1153 target->skipped = (ftdi->response[0] >> 2) &
1154 0x01;
1155 target->toggle_bits = (ftdi->response[3] >> 6)
1156 & 0x03;
1157 target->error_count = (ftdi->response[3] >> 4)
1158 & 0x03;
1159 target->condition_code = (ftdi->response[
1160 3] >> 0) & 0x0F;
1161 if ((ftdi->response[0] & 0x10) == 0x00) {
1162 b = have_ed_set_response(ftdi, target,
1163 ed_length, ed_number, ed_type,
1164 b);
1165 goto have;
1166 } else {
1167 b = have_ed_get_response(ftdi, target,
1168 ed_length, ed_number, ed_type,
1169 b);
1170 goto have;
1171 }
1172 }
1173 }
1174 } else
1175 goto more;
1176}
1177
1178
1179/*
1180* create a urb, and a buffer for it, and copy the data to the urb
1181*
1182*/
1183static ssize_t ftdi_elan_write(struct file *file,
1184 const char __user *user_buffer, size_t count,
1185 loff_t *ppos)
1186{
1187 int retval = 0;
1188 struct urb *urb;
1189 char *buf;
1190 char data[30 *3 + 4];
1191 char *d = data;
1192 const char __user *s = user_buffer;
1193 int m = (sizeof(data) - 1) / 3;
1194 struct usb_ftdi *ftdi = (struct usb_ftdi *)file->private_data;
1195 if (ftdi->disconnected > 0) {
1196 return -ENODEV;
1197 }
1198 if (count == 0) {
1199 goto exit;
1200 }
1201 urb = usb_alloc_urb(0, GFP_KERNEL);
1202 if (!urb) {
1203 retval = -ENOMEM;
1204 goto error_1;
1205 }
1206 buf = usb_buffer_alloc(ftdi->udev, count, GFP_KERNEL,
1207 &urb->transfer_dma);
1208 if (!buf) {
1209 retval = -ENOMEM;
1210 goto error_2;
1211 }
1212 if (copy_from_user(buf, user_buffer, count)) {
1213 retval = -EFAULT;
1214 goto error_3;
1215 }
1216 usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev,
1217 ftdi->bulk_out_endpointAddr), buf, count,
1218 ftdi_elan_write_bulk_callback, ftdi);
1219 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1220 retval = usb_submit_urb(urb, GFP_KERNEL);
1221 if (retval) {
1222 dev_err(&ftdi->udev->dev, "failed submitting write urb, error %"
1223 "d\n", retval);
1224 goto error_4;
1225 }
1226 usb_free_urb(urb);
1227 exit:;
1228 if (count > m) {
1229 int I = m - 1;
1230 while (I-- > 0) {
1231 d += sprintf(d, " %02X", 0x000000FF & *s++);
1232 }
1233 d += sprintf(d, " ..");
1234 } else {
1235 int I = count;
1236 while (I-- > 0) {
1237 d += sprintf(d, " %02X", 0x000000FF & *s++);
1238 }
1239 }
1240 return count;
1241 error_4: error_3:usb_buffer_free(ftdi->udev, count, buf,
1242 urb->transfer_dma);
1243 error_2:usb_free_urb(urb);
1244 error_1:return retval;
1245}
1246
1247static struct file_operations ftdi_elan_fops = {
1248 .owner = THIS_MODULE,
1249 .llseek = no_llseek,
1250 .ioctl = ftdi_elan_ioctl,
1251 .read = ftdi_elan_read,
1252 .write = ftdi_elan_write,
1253 .open = ftdi_elan_open,
1254 .release = ftdi_elan_release,
1255};
1256
1257/*
1258* usb class driver info in order to get a minor number from the usb core,
1259* and to have the device registered with the driver core
1260*/
1261static struct usb_class_driver ftdi_elan_jtag_class = {
1262 .name = "ftdi-%d-jtag",
1263 .fops = &ftdi_elan_fops,
1264 .minor_base = USB_FTDI_ELAN_MINOR_BASE,
1265};
1266
1267/*
1268* the following definitions are for the
1269* ELAN FPGA state machgine processor that
1270* lies on the other side of the FTDI chip
1271*/
1272#define cPCIu132rd 0x0
1273#define cPCIu132wr 0x1
1274#define cPCIiord 0x2
1275#define cPCIiowr 0x3
1276#define cPCImemrd 0x6
1277#define cPCImemwr 0x7
1278#define cPCIcfgrd 0xA
1279#define cPCIcfgwr 0xB
1280#define cPCInull 0xF
1281#define cU132cmd_status 0x0
1282#define cU132flash 0x1
1283#define cPIDsetup 0x0
1284#define cPIDout 0x1
1285#define cPIDin 0x2
1286#define cPIDinonce 0x3
1287#define cCCnoerror 0x0
1288#define cCCcrc 0x1
1289#define cCCbitstuff 0x2
1290#define cCCtoggle 0x3
1291#define cCCstall 0x4
1292#define cCCnoresp 0x5
1293#define cCCbadpid1 0x6
1294#define cCCbadpid2 0x7
1295#define cCCdataoverrun 0x8
1296#define cCCdataunderrun 0x9
1297#define cCCbuffoverrun 0xC
1298#define cCCbuffunderrun 0xD
1299#define cCCnotaccessed 0xF
1300static int ftdi_elan_write_reg(struct usb_ftdi *ftdi, u32 data)
1301{
1302 wait:if (ftdi->disconnected > 0) {
1303 return -ENODEV;
1304 } else {
1305 int command_size;
1306 down(&ftdi->u132_lock);
1307 command_size = ftdi->command_next - ftdi->command_head;
1308 if (command_size < COMMAND_SIZE) {
1309 struct u132_command *command = &ftdi->command[
1310 COMMAND_MASK & ftdi->command_next];
1311 command->header = 0x00 | cPCIu132wr;
1312 command->length = 0x04;
1313 command->address = 0x00;
1314 command->width = 0x00;
1315 command->follows = 4;
1316 command->value = data;
1317 command->buffer = &command->value;
1318 ftdi->command_next += 1;
1319 ftdi_elan_kick_command_queue(ftdi);
1320 up(&ftdi->u132_lock);
1321 return 0;
1322 } else {
1323 up(&ftdi->u132_lock);
1324 msleep(100);
1325 goto wait;
1326 }
1327 }
1328}
1329
1330static int ftdi_elan_write_config(struct usb_ftdi *ftdi, int config_offset,
1331 u8 width, u32 data)
1332{
1333 u8 addressofs = config_offset / 4;
1334 wait:if (ftdi->disconnected > 0) {
1335 return -ENODEV;
1336 } else {
1337 int command_size;
1338 down(&ftdi->u132_lock);
1339 command_size = ftdi->command_next - ftdi->command_head;
1340 if (command_size < COMMAND_SIZE) {
1341 struct u132_command *command = &ftdi->command[
1342 COMMAND_MASK & ftdi->command_next];
1343 command->header = 0x00 | (cPCIcfgwr & 0x0F);
1344 command->length = 0x04;
1345 command->address = addressofs;
1346 command->width = 0x00 | (width & 0x0F);
1347 command->follows = 4;
1348 command->value = data;
1349 command->buffer = &command->value;
1350 ftdi->command_next += 1;
1351 ftdi_elan_kick_command_queue(ftdi);
1352 up(&ftdi->u132_lock);
1353 return 0;
1354 } else {
1355 up(&ftdi->u132_lock);
1356 msleep(100);
1357 goto wait;
1358 }
1359 }
1360}
1361
1362static int ftdi_elan_write_pcimem(struct usb_ftdi *ftdi, int mem_offset,
1363 u8 width, u32 data)
1364{
1365 u8 addressofs = mem_offset / 4;
1366 wait:if (ftdi->disconnected > 0) {
1367 return -ENODEV;
1368 } else {
1369 int command_size;
1370 down(&ftdi->u132_lock);
1371 command_size = ftdi->command_next - ftdi->command_head;
1372 if (command_size < COMMAND_SIZE) {
1373 struct u132_command *command = &ftdi->command[
1374 COMMAND_MASK & ftdi->command_next];
1375 command->header = 0x00 | (cPCImemwr & 0x0F);
1376 command->length = 0x04;
1377 command->address = addressofs;
1378 command->width = 0x00 | (width & 0x0F);
1379 command->follows = 4;
1380 command->value = data;
1381 command->buffer = &command->value;
1382 ftdi->command_next += 1;
1383 ftdi_elan_kick_command_queue(ftdi);
1384 up(&ftdi->u132_lock);
1385 return 0;
1386 } else {
1387 up(&ftdi->u132_lock);
1388 msleep(100);
1389 goto wait;
1390 }
1391 }
1392}
1393
1394int usb_ftdi_elan_write_pcimem(struct platform_device *pdev, int mem_offset,
1395 u8 width, u32 data)
1396{
1397 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1398 return ftdi_elan_write_pcimem(ftdi, mem_offset, width, data);
1399}
1400
1401
1402EXPORT_SYMBOL_GPL(usb_ftdi_elan_write_pcimem);
1403static int ftdi_elan_read_reg(struct usb_ftdi *ftdi, u32 *data)
1404{
1405 wait:if (ftdi->disconnected > 0) {
1406 return -ENODEV;
1407 } else {
1408 int command_size;
1409 int respond_size;
1410 down(&ftdi->u132_lock);
1411 command_size = ftdi->command_next - ftdi->command_head;
1412 respond_size = ftdi->respond_next - ftdi->respond_head;
1413 if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE)
1414 {
1415 struct u132_command *command = &ftdi->command[
1416 COMMAND_MASK & ftdi->command_next];
1417 struct u132_respond *respond = &ftdi->respond[
1418 RESPOND_MASK & ftdi->respond_next];
1419 int result = -ENODEV;
1420 respond->result = &result;
1421 respond->header = command->header = 0x00 | cPCIu132rd;
1422 command->length = 0x04;
1423 respond->address = command->address = cU132cmd_status;
1424 command->width = 0x00;
1425 command->follows = 0;
1426 command->value = 0;
1427 command->buffer = NULL;
1428 respond->value = data;
1429 init_completion(&respond->wait_completion);
1430 ftdi->command_next += 1;
1431 ftdi->respond_next += 1;
1432 ftdi_elan_kick_command_queue(ftdi);
1433 up(&ftdi->u132_lock);
1434 wait_for_completion(&respond->wait_completion);
1435 return result;
1436 } else {
1437 up(&ftdi->u132_lock);
1438 msleep(100);
1439 goto wait;
1440 }
1441 }
1442}
1443
1444int usb_ftdi_elan_read_reg(struct platform_device *pdev, u32 *data)
1445{
1446 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1447 return ftdi_elan_read_reg(ftdi, data);
1448}
1449
1450
1451EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_reg);
1452static int ftdi_elan_read_config(struct usb_ftdi *ftdi, int config_offset,
1453 u8 width, u32 *data)
1454{
1455 u8 addressofs = config_offset / 4;
1456 wait:if (ftdi->disconnected > 0) {
1457 return -ENODEV;
1458 } else {
1459 int command_size;
1460 int respond_size;
1461 down(&ftdi->u132_lock);
1462 command_size = ftdi->command_next - ftdi->command_head;
1463 respond_size = ftdi->respond_next - ftdi->respond_head;
1464 if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE)
1465 {
1466 struct u132_command *command = &ftdi->command[
1467 COMMAND_MASK & ftdi->command_next];
1468 struct u132_respond *respond = &ftdi->respond[
1469 RESPOND_MASK & ftdi->respond_next];
1470 int result = -ENODEV;
1471 respond->result = &result;
1472 respond->header = command->header = 0x00 | (cPCIcfgrd &
1473 0x0F);
1474 command->length = 0x04;
1475 respond->address = command->address = addressofs;
1476 command->width = 0x00 | (width & 0x0F);
1477 command->follows = 0;
1478 command->value = 0;
1479 command->buffer = NULL;
1480 respond->value = data;
1481 init_completion(&respond->wait_completion);
1482 ftdi->command_next += 1;
1483 ftdi->respond_next += 1;
1484 ftdi_elan_kick_command_queue(ftdi);
1485 up(&ftdi->u132_lock);
1486 wait_for_completion(&respond->wait_completion);
1487 return result;
1488 } else {
1489 up(&ftdi->u132_lock);
1490 msleep(100);
1491 goto wait;
1492 }
1493 }
1494}
1495
1496static int ftdi_elan_read_pcimem(struct usb_ftdi *ftdi, int mem_offset,
1497 u8 width, u32 *data)
1498{
1499 u8 addressofs = mem_offset / 4;
1500 wait:if (ftdi->disconnected > 0) {
1501 return -ENODEV;
1502 } else {
1503 int command_size;
1504 int respond_size;
1505 down(&ftdi->u132_lock);
1506 command_size = ftdi->command_next - ftdi->command_head;
1507 respond_size = ftdi->respond_next - ftdi->respond_head;
1508 if (command_size < COMMAND_SIZE && respond_size < RESPOND_SIZE)
1509 {
1510 struct u132_command *command = &ftdi->command[
1511 COMMAND_MASK & ftdi->command_next];
1512 struct u132_respond *respond = &ftdi->respond[
1513 RESPOND_MASK & ftdi->respond_next];
1514 int result = -ENODEV;
1515 respond->result = &result;
1516 respond->header = command->header = 0x00 | (cPCImemrd &
1517 0x0F);
1518 command->length = 0x04;
1519 respond->address = command->address = addressofs;
1520 command->width = 0x00 | (width & 0x0F);
1521 command->follows = 0;
1522 command->value = 0;
1523 command->buffer = NULL;
1524 respond->value = data;
1525 init_completion(&respond->wait_completion);
1526 ftdi->command_next += 1;
1527 ftdi->respond_next += 1;
1528 ftdi_elan_kick_command_queue(ftdi);
1529 up(&ftdi->u132_lock);
1530 wait_for_completion(&respond->wait_completion);
1531 return result;
1532 } else {
1533 up(&ftdi->u132_lock);
1534 msleep(100);
1535 goto wait;
1536 }
1537 }
1538}
1539
1540int usb_ftdi_elan_read_pcimem(struct platform_device *pdev, int mem_offset,
1541 u8 width, u32 *data)
1542{
1543 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1544 if (ftdi->initialized == 0) {
1545 return -ENODEV;
1546 } else
1547 return ftdi_elan_read_pcimem(ftdi, mem_offset, width, data);
1548}
1549
1550
1551EXPORT_SYMBOL_GPL(usb_ftdi_elan_read_pcimem);
1552static int ftdi_elan_edset_setup(struct usb_ftdi *ftdi, u8 ed_number,
1553 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1554 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1555 int toggle_bits, int error_count, int condition_code, int repeat_number,
1556 int halted, int skipped, int actual, int non_null))
1557{
1558 u8 ed = ed_number - 1;
1559 wait:if (ftdi->disconnected > 0) {
1560 return -ENODEV;
1561 } else if (ftdi->initialized == 0) {
1562 return -ENODEV;
1563 } else {
1564 int command_size;
1565 down(&ftdi->u132_lock);
1566 command_size = ftdi->command_next - ftdi->command_head;
1567 if (command_size < COMMAND_SIZE) {
1568 struct u132_target *target = &ftdi->target[ed];
1569 struct u132_command *command = &ftdi->command[
1570 COMMAND_MASK & ftdi->command_next];
1571 command->header = 0x80 | (ed << 5);
1572 command->length = 0x8007;
1573 command->address = (toggle_bits << 6) | (ep_number << 2)
1574 | (address << 0);
1575 command->width = usb_maxpacket(urb->dev, urb->pipe,
1576 usb_pipeout(urb->pipe));
1577 command->follows = 8;
1578 command->value = 0;
1579 command->buffer = urb->setup_packet;
1580 target->callback = callback;
1581 target->endp = endp;
1582 target->urb = urb;
1583 target->active = 1;
1584 ftdi->command_next += 1;
1585 ftdi_elan_kick_command_queue(ftdi);
1586 up(&ftdi->u132_lock);
1587 return 0;
1588 } else {
1589 up(&ftdi->u132_lock);
1590 msleep(100);
1591 goto wait;
1592 }
1593 }
1594}
1595
1596int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number,
1597 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1598 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1599 int toggle_bits, int error_count, int condition_code, int repeat_number,
1600 int halted, int skipped, int actual, int non_null))
1601{
1602 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1603 return ftdi_elan_edset_setup(ftdi, ed_number, endp, urb, address,
1604 ep_number, toggle_bits, callback);
1605}
1606
1607
1608EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_setup);
1609static int ftdi_elan_edset_input(struct usb_ftdi *ftdi, u8 ed_number,
1610 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1611 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1612 int toggle_bits, int error_count, int condition_code, int repeat_number,
1613 int halted, int skipped, int actual, int non_null))
1614{
1615 u8 ed = ed_number - 1;
1616 wait:if (ftdi->disconnected > 0) {
1617 return -ENODEV;
1618 } else if (ftdi->initialized == 0) {
1619 return -ENODEV;
1620 } else {
1621 int command_size;
1622 down(&ftdi->u132_lock);
1623 command_size = ftdi->command_next - ftdi->command_head;
1624 if (command_size < COMMAND_SIZE) {
1625 struct u132_target *target = &ftdi->target[ed];
1626 struct u132_command *command = &ftdi->command[
1627 COMMAND_MASK & ftdi->command_next];
1628 int remaining_length = urb->transfer_buffer_length -
1629 urb->actual_length;
1630 command->header = 0x82 | (ed << 5);
1631 if (remaining_length == 0) {
1632 command->length = 0x0000;
1633 } else if (remaining_length > 1024) {
1634 command->length = 0x8000 | 1023;
1635 } else
1636 command->length = 0x8000 | (remaining_length -
1637 1);
1638 command->address = (toggle_bits << 6) | (ep_number << 2)
1639 | (address << 0);
1640 command->width = usb_maxpacket(urb->dev, urb->pipe,
1641 usb_pipeout(urb->pipe));
1642 command->follows = 0;
1643 command->value = 0;
1644 command->buffer = NULL;
1645 target->callback = callback;
1646 target->endp = endp;
1647 target->urb = urb;
1648 target->active = 1;
1649 ftdi->command_next += 1;
1650 ftdi_elan_kick_command_queue(ftdi);
1651 up(&ftdi->u132_lock);
1652 return 0;
1653 } else {
1654 up(&ftdi->u132_lock);
1655 msleep(100);
1656 goto wait;
1657 }
1658 }
1659}
1660
1661int usb_ftdi_elan_edset_input(struct platform_device *pdev, u8 ed_number,
1662 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1663 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1664 int toggle_bits, int error_count, int condition_code, int repeat_number,
1665 int halted, int skipped, int actual, int non_null))
1666{
1667 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1668 return ftdi_elan_edset_input(ftdi, ed_number, endp, urb, address,
1669 ep_number, toggle_bits, callback);
1670}
1671
1672
1673EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_input);
1674static int ftdi_elan_edset_empty(struct usb_ftdi *ftdi, u8 ed_number,
1675 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1676 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1677 int toggle_bits, int error_count, int condition_code, int repeat_number,
1678 int halted, int skipped, int actual, int non_null))
1679{
1680 u8 ed = ed_number - 1;
1681 wait:if (ftdi->disconnected > 0) {
1682 return -ENODEV;
1683 } else if (ftdi->initialized == 0) {
1684 return -ENODEV;
1685 } else {
1686 int command_size;
1687 down(&ftdi->u132_lock);
1688 command_size = ftdi->command_next - ftdi->command_head;
1689 if (command_size < COMMAND_SIZE) {
1690 struct u132_target *target = &ftdi->target[ed];
1691 struct u132_command *command = &ftdi->command[
1692 COMMAND_MASK & ftdi->command_next];
1693 command->header = 0x81 | (ed << 5);
1694 command->length = 0x0000;
1695 command->address = (toggle_bits << 6) | (ep_number << 2)
1696 | (address << 0);
1697 command->width = usb_maxpacket(urb->dev, urb->pipe,
1698 usb_pipeout(urb->pipe));
1699 command->follows = 0;
1700 command->value = 0;
1701 command->buffer = NULL;
1702 target->callback = callback;
1703 target->endp = endp;
1704 target->urb = urb;
1705 target->active = 1;
1706 ftdi->command_next += 1;
1707 ftdi_elan_kick_command_queue(ftdi);
1708 up(&ftdi->u132_lock);
1709 return 0;
1710 } else {
1711 up(&ftdi->u132_lock);
1712 msleep(100);
1713 goto wait;
1714 }
1715 }
1716}
1717
1718int usb_ftdi_elan_edset_empty(struct platform_device *pdev, u8 ed_number,
1719 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1720 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1721 int toggle_bits, int error_count, int condition_code, int repeat_number,
1722 int halted, int skipped, int actual, int non_null))
1723{
1724 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1725 return ftdi_elan_edset_empty(ftdi, ed_number, endp, urb, address,
1726 ep_number, toggle_bits, callback);
1727}
1728
1729
1730EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_empty);
1731static int ftdi_elan_edset_output(struct usb_ftdi *ftdi, u8 ed_number,
1732 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1733 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1734 int toggle_bits, int error_count, int condition_code, int repeat_number,
1735 int halted, int skipped, int actual, int non_null))
1736{
1737 u8 ed = ed_number - 1;
1738 wait:if (ftdi->disconnected > 0) {
1739 return -ENODEV;
1740 } else if (ftdi->initialized == 0) {
1741 return -ENODEV;
1742 } else {
1743 int command_size;
1744 down(&ftdi->u132_lock);
1745 command_size = ftdi->command_next - ftdi->command_head;
1746 if (command_size < COMMAND_SIZE) {
1747 u8 *b;
1748 u16 urb_size;
1749 int i = 0;
1750 char data[30 *3 + 4];
1751 char *d = data;
1752 int m = (sizeof(data) - 1) / 3;
1753 int l = 0;
1754 struct u132_target *target = &ftdi->target[ed];
1755 struct u132_command *command = &ftdi->command[
1756 COMMAND_MASK & ftdi->command_next];
1757 command->header = 0x81 | (ed << 5);
1758 command->address = (toggle_bits << 6) | (ep_number << 2)
1759 | (address << 0);
1760 command->width = usb_maxpacket(urb->dev, urb->pipe,
1761 usb_pipeout(urb->pipe));
1762 command->follows = min(1024,
1763 urb->transfer_buffer_length -
1764 urb->actual_length);
1765 command->value = 0;
1766 command->buffer = urb->transfer_buffer +
1767 urb->actual_length;
1768 command->length = 0x8000 | (command->follows - 1);
1769 b = command->buffer;
1770 urb_size = command->follows;
1771 data[0] = 0;
1772 while (urb_size-- > 0) {
1773 if (i > m) {
1774 } else if (i++ < m) {
1775 int w = sprintf(d, " %02X", *b++);
1776 d += w;
1777 l += w;
1778 } else
1779 d += sprintf(d, " ..");
1780 }
1781 target->callback = callback;
1782 target->endp = endp;
1783 target->urb = urb;
1784 target->active = 1;
1785 ftdi->command_next += 1;
1786 ftdi_elan_kick_command_queue(ftdi);
1787 up(&ftdi->u132_lock);
1788 return 0;
1789 } else {
1790 up(&ftdi->u132_lock);
1791 msleep(100);
1792 goto wait;
1793 }
1794 }
1795}
1796
1797int usb_ftdi_elan_edset_output(struct platform_device *pdev, u8 ed_number,
1798 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1799 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1800 int toggle_bits, int error_count, int condition_code, int repeat_number,
1801 int halted, int skipped, int actual, int non_null))
1802{
1803 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1804 return ftdi_elan_edset_output(ftdi, ed_number, endp, urb, address,
1805 ep_number, toggle_bits, callback);
1806}
1807
1808
1809EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_output);
1810static int ftdi_elan_edset_single(struct usb_ftdi *ftdi, u8 ed_number,
1811 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1812 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1813 int toggle_bits, int error_count, int condition_code, int repeat_number,
1814 int halted, int skipped, int actual, int non_null))
1815{
1816 u8 ed = ed_number - 1;
1817 wait:if (ftdi->disconnected > 0) {
1818 return -ENODEV;
1819 } else if (ftdi->initialized == 0) {
1820 return -ENODEV;
1821 } else {
1822 int command_size;
1823 down(&ftdi->u132_lock);
1824 command_size = ftdi->command_next - ftdi->command_head;
1825 if (command_size < COMMAND_SIZE) {
1826 int remaining_length = urb->transfer_buffer_length -
1827 urb->actual_length;
1828 struct u132_target *target = &ftdi->target[ed];
1829 struct u132_command *command = &ftdi->command[
1830 COMMAND_MASK & ftdi->command_next];
1831 command->header = 0x83 | (ed << 5);
1832 if (remaining_length == 0) {
1833 command->length = 0x0000;
1834 } else if (remaining_length > 1024) {
1835 command->length = 0x8000 | 1023;
1836 } else
1837 command->length = 0x8000 | (remaining_length -
1838 1);
1839 command->address = (toggle_bits << 6) | (ep_number << 2)
1840 | (address << 0);
1841 command->width = usb_maxpacket(urb->dev, urb->pipe,
1842 usb_pipeout(urb->pipe));
1843 command->follows = 0;
1844 command->value = 0;
1845 command->buffer = NULL;
1846 target->callback = callback;
1847 target->endp = endp;
1848 target->urb = urb;
1849 target->active = 1;
1850 ftdi->command_next += 1;
1851 ftdi_elan_kick_command_queue(ftdi);
1852 up(&ftdi->u132_lock);
1853 return 0;
1854 } else {
1855 up(&ftdi->u132_lock);
1856 msleep(100);
1857 goto wait;
1858 }
1859 }
1860}
1861
1862int usb_ftdi_elan_edset_single(struct platform_device *pdev, u8 ed_number,
1863 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
1864 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
1865 int toggle_bits, int error_count, int condition_code, int repeat_number,
1866 int halted, int skipped, int actual, int non_null))
1867{
1868 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1869 return ftdi_elan_edset_single(ftdi, ed_number, endp, urb, address,
1870 ep_number, toggle_bits, callback);
1871}
1872
1873
1874EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_single);
1875static int ftdi_elan_edset_flush(struct usb_ftdi *ftdi, u8 ed_number,
1876 void *endp)
1877{
1878 u8 ed = ed_number - 1;
1879 if (ftdi->disconnected > 0) {
1880 return -ENODEV;
1881 } else if (ftdi->initialized == 0) {
1882 return -ENODEV;
1883 } else {
1884 struct u132_target *target = &ftdi->target[ed];
1885 down(&ftdi->u132_lock);
1886 if (target->abandoning > 0) {
1887 up(&ftdi->u132_lock);
1888 return 0;
1889 } else {
1890 target->abandoning = 1;
1891 wait_1:if (target->active == 1) {
1892 int command_size = ftdi->command_next -
1893 ftdi->command_head;
1894 if (command_size < COMMAND_SIZE) {
1895 struct u132_command *command =
1896 &ftdi->command[COMMAND_MASK &
1897 ftdi->command_next];
1898 command->header = 0x80 | (ed << 5) |
1899 0x4;
1900 command->length = 0x00;
1901 command->address = 0x00;
1902 command->width = 0x00;
1903 command->follows = 0;
1904 command->value = 0;
1905 command->buffer = &command->value;
1906 ftdi->command_next += 1;
1907 ftdi_elan_kick_command_queue(ftdi);
1908 } else {
1909 up(&ftdi->u132_lock);
1910 msleep(100);
1911 down(&ftdi->u132_lock);
1912 goto wait_1;
1913 }
1914 }
1915 up(&ftdi->u132_lock);
1916 return 0;
1917 }
1918 }
1919}
1920
1921int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number,
1922 void *endp)
1923{
1924 struct usb_ftdi *ftdi = platform_device_to_usb_ftdi(pdev);
1925 return ftdi_elan_edset_flush(ftdi, ed_number, endp);
1926}
1927
1928
1929EXPORT_SYMBOL_GPL(usb_ftdi_elan_edset_flush);
1930static int ftdi_elan_flush_input_fifo(struct usb_ftdi *ftdi)
1931{
1932 int retry_on_empty = 10;
1933 int retry_on_timeout = 5;
1934 int retry_on_status = 20;
1935 more:{
1936 int packet_bytes = 0;
1937 int retval = usb_bulk_msg(ftdi->udev,
1938 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr),
1939 ftdi->bulk_in_buffer, ftdi->bulk_in_size,
1940 &packet_bytes, msecs_to_jiffies(100));
1941 if (packet_bytes > 2) {
1942 char diag[30 *3 + 4];
1943 char *d = diag;
1944 int m = (sizeof(diag) - 1) / 3;
1945 char *b = ftdi->bulk_in_buffer;
1946 int bytes_read = 0;
1947 diag[0] = 0;
1948 while (packet_bytes-- > 0) {
1949 char c = *b++;
1950 if (bytes_read < m) {
1951 d += sprintf(d, " %02X",
1952 0x000000FF & c);
1953 } else if (bytes_read > m) {
1954 } else
1955 d += sprintf(d, " ..");
1956 bytes_read += 1;
1957 continue;
1958 }
1959 goto more;
1960 } else if (packet_bytes > 1) {
1961 char s1 = ftdi->bulk_in_buffer[0];
1962 char s2 = ftdi->bulk_in_buffer[1];
1963 if (s1 == 0x31 && s2 == 0x60) {
1964 return 0;
1965 } else if (retry_on_status-- > 0) {
1966 goto more;
1967 } else {
1968 dev_err(&ftdi->udev->dev, "STATUS ERROR retry l"
1969 "imit reached\n");
1970 return -EFAULT;
1971 }
1972 } else if (packet_bytes > 0) {
1973 char b1 = ftdi->bulk_in_buffer[0];
1974 dev_err(&ftdi->udev->dev, "only one byte flushed from F"
1975 "TDI = %02X\n", b1);
1976 if (retry_on_status-- > 0) {
1977 goto more;
1978 } else {
1979 dev_err(&ftdi->udev->dev, "STATUS ERROR retry l"
1980 "imit reached\n");
1981 return -EFAULT;
1982 }
1983 } else if (retval == -ETIMEDOUT) {
1984 if (retry_on_timeout-- > 0) {
1985 goto more;
1986 } else {
1987 dev_err(&ftdi->udev->dev, "TIMED OUT retry limi"
1988 "t reached\n");
1989 return -ENOMEM;
1990 }
1991 } else if (retval == 0) {
1992 if (retry_on_empty-- > 0) {
1993 goto more;
1994 } else {
1995 dev_err(&ftdi->udev->dev, "empty packet retry l"
1996 "imit reached\n");
1997 return -ENOMEM;
1998 }
1999 } else {
2000 dev_err(&ftdi->udev->dev, "error = %d\n", retval);
2001 return retval;
2002 }
2003 }
2004 return -1;
2005}
2006
2007
2008/*
2009* send the long flush sequence
2010*
2011*/
2012static int ftdi_elan_synchronize_flush(struct usb_ftdi *ftdi)
2013{
2014 int retval;
2015 struct urb *urb;
2016 char *buf;
2017 int I = 257;
2018 int i = 0;
2019 urb = usb_alloc_urb(0, GFP_KERNEL);
2020 if (!urb) {
2021 dev_err(&ftdi->udev->dev, "could not alloc a urb for flush sequ"
2022 "ence\n");
2023 return -ENOMEM;
2024 }
2025 buf = usb_buffer_alloc(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma);
2026 if (!buf) {
2027 dev_err(&ftdi->udev->dev, "could not get a buffer for flush seq"
2028 "uence\n");
2029 usb_free_urb(urb);
2030 return -ENOMEM;
2031 }
2032 while (I-- > 0)
2033 buf[i++] = 0x55;
2034 usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev,
2035 ftdi->bulk_out_endpointAddr), buf, i,
2036 ftdi_elan_write_bulk_callback, ftdi);
2037 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2038 retval = usb_submit_urb(urb, GFP_KERNEL);
2039 if (retval) {
2040 dev_err(&ftdi->udev->dev, "failed to submit urb containing the "
2041 "flush sequence\n");
2042 usb_buffer_free(ftdi->udev, i, buf, urb->transfer_dma);
2043 usb_free_urb(urb);
2044 return -ENOMEM;
2045 }
2046 usb_free_urb(urb);
2047 return 0;
2048}
2049
2050
2051/*
2052* send the reset sequence
2053*
2054*/
2055static int ftdi_elan_synchronize_reset(struct usb_ftdi *ftdi)
2056{
2057 int retval;
2058 struct urb *urb;
2059 char *buf;
2060 int I = 4;
2061 int i = 0;
2062 urb = usb_alloc_urb(0, GFP_KERNEL);
2063 if (!urb) {
2064 dev_err(&ftdi->udev->dev, "could not get a urb for the reset se"
2065 "quence\n");
2066 return -ENOMEM;
2067 }
2068 buf = usb_buffer_alloc(ftdi->udev, I, GFP_KERNEL, &urb->transfer_dma);
2069 if (!buf) {
2070 dev_err(&ftdi->udev->dev, "could not get a buffer for the reset"
2071 " sequence\n");
2072 usb_free_urb(urb);
2073 return -ENOMEM;
2074 }
2075 buf[i++] = 0x55;
2076 buf[i++] = 0xAA;
2077 buf[i++] = 0x5A;
2078 buf[i++] = 0xA5;
2079 usb_fill_bulk_urb(urb, ftdi->udev, usb_sndbulkpipe(ftdi->udev,
2080 ftdi->bulk_out_endpointAddr), buf, i,
2081 ftdi_elan_write_bulk_callback, ftdi);
2082 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
2083 retval = usb_submit_urb(urb, GFP_KERNEL);
2084 if (retval) {
2085 dev_err(&ftdi->udev->dev, "failed to submit urb containing the "
2086 "reset sequence\n");
2087 usb_buffer_free(ftdi->udev, i, buf, urb->transfer_dma);
2088 usb_free_urb(urb);
2089 return -ENOMEM;
2090 }
2091 usb_free_urb(urb);
2092 return 0;
2093}
2094
2095static int ftdi_elan_synchronize(struct usb_ftdi *ftdi)
2096{
2097 int retval;
2098 int long_stop = 10;
2099 int retry_on_timeout = 5;
2100 int retry_on_empty = 10;
2101 int err_count = 0;
2102 retval = ftdi_elan_flush_input_fifo(ftdi);
2103 if (retval)
2104 return retval;
2105 ftdi->bulk_in_left = 0;
2106 ftdi->bulk_in_last = -1;
2107 while (long_stop-- > 0) {
2108 int read_stop;
2109 int read_stuck;
2110 retval = ftdi_elan_synchronize_flush(ftdi);
2111 if (retval)
2112 return retval;
2113 retval = ftdi_elan_flush_input_fifo(ftdi);
2114 if (retval)
2115 return retval;
2116 reset:retval = ftdi_elan_synchronize_reset(ftdi);
2117 if (retval)
2118 return retval;
2119 read_stop = 100;
2120 read_stuck = 10;
2121 read:{
2122 int packet_bytes = 0;
2123 retval = usb_bulk_msg(ftdi->udev,
2124 usb_rcvbulkpipe(ftdi->udev,
2125 ftdi->bulk_in_endpointAddr),
2126 ftdi->bulk_in_buffer, ftdi->bulk_in_size,
2127 &packet_bytes, msecs_to_jiffies(500));
2128 if (packet_bytes > 2) {
2129 char diag[30 *3 + 4];
2130 char *d = diag;
2131 int m = (sizeof(diag) - 1) / 3;
2132 char *b = ftdi->bulk_in_buffer;
2133 int bytes_read = 0;
2134 unsigned char c = 0;
2135 diag[0] = 0;
2136 while (packet_bytes-- > 0) {
2137 c = *b++;
2138 if (bytes_read < m) {
2139 d += sprintf(d, " %02X", c);
2140 } else if (bytes_read > m) {
2141 } else
2142 d += sprintf(d, " ..");
2143 bytes_read += 1;
2144 continue;
2145 }
2146 if (c == 0x7E) {
2147 return 0;
2148 } else {
2149 if (c == 0x55) {
2150 goto read;
2151 } else if (read_stop-- > 0) {
2152 goto read;
2153 } else {
2154 dev_err(&ftdi->udev->dev, "retr"
2155 "y limit reached\n");
2156 continue;
2157 }
2158 }
2159 } else if (packet_bytes > 1) {
2160 unsigned char s1 = ftdi->bulk_in_buffer[0];
2161 unsigned char s2 = ftdi->bulk_in_buffer[1];
2162 if (s1 == 0x31 && s2 == 0x00) {
2163 if (read_stuck-- > 0) {
2164 goto read;
2165 } else
2166 goto reset;
2167 } else if (s1 == 0x31 && s2 == 0x60) {
2168 if (read_stop-- > 0) {
2169 goto read;
2170 } else {
2171 dev_err(&ftdi->udev->dev, "retr"
2172 "y limit reached\n");
2173 continue;
2174 }
2175 } else {
2176 if (read_stop-- > 0) {
2177 goto read;
2178 } else {
2179 dev_err(&ftdi->udev->dev, "retr"
2180 "y limit reached\n");
2181 continue;
2182 }
2183 }
2184 } else if (packet_bytes > 0) {
2185 if (read_stop-- > 0) {
2186 goto read;
2187 } else {
2188 dev_err(&ftdi->udev->dev, "retry limit "
2189 "reached\n");
2190 continue;
2191 }
2192 } else if (retval == -ETIMEDOUT) {
2193 if (retry_on_timeout-- > 0) {
2194 goto read;
2195 } else {
2196 dev_err(&ftdi->udev->dev, "TIMED OUT re"
2197 "try limit reached\n");
2198 continue;
2199 }
2200 } else if (retval == 0) {
2201 if (retry_on_empty-- > 0) {
2202 goto read;
2203 } else {
2204 dev_err(&ftdi->udev->dev, "empty packet"
2205 " retry limit reached\n");
2206 continue;
2207 }
2208 } else {
2209 err_count += 1;
2210 dev_err(&ftdi->udev->dev, "error = %d\n",
2211 retval);
2212 if (read_stop-- > 0) {
2213 goto read;
2214 } else {
2215 dev_err(&ftdi->udev->dev, "retry limit "
2216 "reached\n");
2217 continue;
2218 }
2219 }
2220 }
2221 }
2222 dev_err(&ftdi->udev->dev, "failed to synchronize\n");
2223 return -EFAULT;
2224}
2225
2226static int ftdi_elan_stuck_waiting(struct usb_ftdi *ftdi)
2227{
2228 int retry_on_empty = 10;
2229 int retry_on_timeout = 5;
2230 int retry_on_status = 50;
2231 more:{
2232 int packet_bytes = 0;
2233 int retval = usb_bulk_msg(ftdi->udev,
2234 usb_rcvbulkpipe(ftdi->udev, ftdi->bulk_in_endpointAddr),
2235 ftdi->bulk_in_buffer, ftdi->bulk_in_size,
2236 &packet_bytes, msecs_to_jiffies(1000));
2237 if (packet_bytes > 2) {
2238 char diag[30 *3 + 4];
2239 char *d = diag;
2240 int m = (sizeof(diag) - 1) / 3;
2241 char *b = ftdi->bulk_in_buffer;
2242 int bytes_read = 0;
2243 diag[0] = 0;
2244 while (packet_bytes-- > 0) {
2245 char c = *b++;
2246 if (bytes_read < m) {
2247 d += sprintf(d, " %02X",
2248 0x000000FF & c);
2249 } else if (bytes_read > m) {
2250 } else
2251 d += sprintf(d, " ..");
2252 bytes_read += 1;
2253 continue;
2254 }
2255 goto more;
2256 } else if (packet_bytes > 1) {
2257 char s1 = ftdi->bulk_in_buffer[0];
2258 char s2 = ftdi->bulk_in_buffer[1];
2259 if (s1 == 0x31 && s2 == 0x60) {
2260 return 0;
2261 } else if (retry_on_status-- > 0) {
2262 msleep(5);
2263 goto more;
2264 } else
2265 return -EFAULT;
2266 } else if (packet_bytes > 0) {
2267 char b1 = ftdi->bulk_in_buffer[0];
2268 dev_err(&ftdi->udev->dev, "only one byte flushed from F"
2269 "TDI = %02X\n", b1);
2270 if (retry_on_status-- > 0) {
2271 msleep(5);
2272 goto more;
2273 } else {
2274 dev_err(&ftdi->udev->dev, "STATUS ERROR retry l"
2275 "imit reached\n");
2276 return -EFAULT;
2277 }
2278 } else if (retval == -ETIMEDOUT) {
2279 if (retry_on_timeout-- > 0) {
2280 goto more;
2281 } else {
2282 dev_err(&ftdi->udev->dev, "TIMED OUT retry limi"
2283 "t reached\n");
2284 return -ENOMEM;
2285 }
2286 } else if (retval == 0) {
2287 if (retry_on_empty-- > 0) {
2288 goto more;
2289 } else {
2290 dev_err(&ftdi->udev->dev, "empty packet retry l"
2291 "imit reached\n");
2292 return -ENOMEM;
2293 }
2294 } else {
2295 dev_err(&ftdi->udev->dev, "error = %d\n", retval);
2296 return -ENOMEM;
2297 }
2298 }
2299 return -1;
2300}
2301
2302static int ftdi_elan_checkingPCI(struct usb_ftdi *ftdi)
2303{
2304 int UxxxStatus = ftdi_elan_read_reg(ftdi, &ftdi->controlreg);
2305 if (UxxxStatus)
2306 return UxxxStatus;
2307 if (ftdi->controlreg & 0x00400000) {
2308 if (ftdi->card_ejected) {
2309 } else {
2310 ftdi->card_ejected = 1;
2311 dev_err(&ftdi->udev->dev, "CARD EJECTED - controlreg = "
2312 "%08X\n", ftdi->controlreg);
2313 }
2314 return -ENODEV;
2315 } else {
2316 u8 fn = ftdi->function - 1;
2317 int activePCIfn = fn << 8;
2318 u32 pcidata;
2319 u32 pciVID;
2320 u32 pciPID;
2321 int reg = 0;
2322 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2323 &pcidata);
2324 if (UxxxStatus)
2325 return UxxxStatus;
2326 pciVID = pcidata & 0xFFFF;
2327 pciPID = (pcidata >> 16) & 0xFFFF;
2328 if (pciVID == ftdi->platform_data.vendor && pciPID ==
2329 ftdi->platform_data.device) {
2330 return 0;
2331 } else {
2332 dev_err(&ftdi->udev->dev, "vendor=%04X pciVID=%04X devi"
2333 "ce=%04X pciPID=%04X\n",
2334 ftdi->platform_data.vendor, pciVID,
2335 ftdi->platform_data.device, pciPID);
2336 return -ENODEV;
2337 }
2338 }
2339}
2340
2341static int ftdi_elan_enumeratePCI(struct usb_ftdi *ftdi)
2342{
2343 u32 latence_timer;
2344 u32 controlreg;
2345 int UxxxStatus;
2346 u32 pcidata;
2347 int reg = 0;
2348 int foundOHCI = 0;
2349 u8 fn;
2350 int activePCIfn = 0;
2351 u32 pciVID = 0;
2352 u32 pciPID = 0;
2353 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2354 if (UxxxStatus)
2355 return UxxxStatus;
2356 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000000L);
2357 if (UxxxStatus)
2358 return UxxxStatus;
2359 msleep(750);
2360 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x100);
2361 if (UxxxStatus)
2362 return UxxxStatus;
2363 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x00000200L | 0x500);
2364 if (UxxxStatus)
2365 return UxxxStatus;
2366 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2367 if (UxxxStatus)
2368 return UxxxStatus;
2369 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020CL | 0x000);
2370 if (UxxxStatus)
2371 return UxxxStatus;
2372 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020DL | 0x000);
2373 if (UxxxStatus)
2374 return UxxxStatus;
2375 msleep(250);
2376 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000020FL | 0x000);
2377 if (UxxxStatus)
2378 return UxxxStatus;
2379 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2380 if (UxxxStatus)
2381 return UxxxStatus;
2382 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x800);
2383 if (UxxxStatus)
2384 return UxxxStatus;
2385 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2386 if (UxxxStatus)
2387 return UxxxStatus;
2388 UxxxStatus = ftdi_elan_read_reg(ftdi, &controlreg);
2389 if (UxxxStatus)
2390 return UxxxStatus;
2391 msleep(1000);
2392 for (fn = 0; (fn < 4) && (!foundOHCI); fn++) {
2393 activePCIfn = fn << 8;
2394 ftdi->function = fn + 1;
2395 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2396 &pcidata);
2397 if (UxxxStatus)
2398 return UxxxStatus;
2399 pciVID = pcidata & 0xFFFF;
2400 pciPID = (pcidata >> 16) & 0xFFFF;
2401 if ((pciVID == 0x1045) && (pciPID == 0xc861)) {
2402 foundOHCI = 1;
2403 } else if ((pciVID == 0x1033) && (pciPID == 0x0035)) {
2404 foundOHCI = 1;
2405 } else if ((pciVID == 0x10b9) && (pciPID == 0x5237)) {
2406 foundOHCI = 1;
2407 } else if ((pciVID == 0x11c1) && (pciPID == 0x5802)) {
2408 foundOHCI = 1;
2409 } else if ((pciVID == 0x11AB) && (pciPID == 0x1FA6)) {
2410 }
2411 }
2412 if (foundOHCI == 0) {
2413 return -ENXIO;
2414 }
2415 ftdi->platform_data.vendor = pciVID;
2416 ftdi->platform_data.device = pciPID;
2417 UxxxStatus = ftdi_elan_write_reg(ftdi, 0x0000025FL | 0x2800);
2418 if (UxxxStatus)
2419 return UxxxStatus;
2420 reg = 16;
2421 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0,
2422 0xFFFFFFFF);
2423 if (UxxxStatus)
2424 return UxxxStatus;
2425 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2426 &pcidata);
2427 if (UxxxStatus)
2428 return UxxxStatus;
2429 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0,
2430 0xF0000000);
2431 if (UxxxStatus)
2432 return UxxxStatus;
2433 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2434 &pcidata);
2435 if (UxxxStatus)
2436 return UxxxStatus;
2437 reg = 12;
2438 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2439 &latence_timer);
2440 if (UxxxStatus)
2441 return UxxxStatus;
2442 latence_timer &= 0xFFFF00FF;
2443 latence_timer |= 0x00001600;
2444 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00,
2445 latence_timer);
2446 if (UxxxStatus)
2447 return UxxxStatus;
2448 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2449 &pcidata);
2450 if (UxxxStatus)
2451 return UxxxStatus;
2452 reg = 4;
2453 UxxxStatus = ftdi_elan_write_config(ftdi, activePCIfn | reg, 0x00,
2454 0x06);
2455 if (UxxxStatus)
2456 return UxxxStatus;
2457 UxxxStatus = ftdi_elan_read_config(ftdi, activePCIfn | reg, 0,
2458 &pcidata);
2459 if (UxxxStatus)
2460 return UxxxStatus;
2461 return 0;
2462}
2463
2464static int ftdi_elan_setupOHCI(struct usb_ftdi *ftdi)
2465{
2466 u32 pcidata;
2467 int U132Status;
2468 int reg;
2469 int reset_repeat = 0;
2470 do_reset:reg = 8;
2471 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x01);
2472 if (U132Status)
2473 return U132Status;
2474 reset_check:{
2475 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2476 if (U132Status)
2477 return U132Status;
2478 if (pcidata & 1) {
2479 msleep(500);
2480 if (reset_repeat++ > 100) {
2481 reset_repeat = 0;
2482 goto do_reset;
2483 } else
2484 goto reset_check;
2485 }
2486 }
2487 goto dump_regs;
2488 msleep(500);
2489 reg = 0x28;
2490 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x11000000);
2491 if (U132Status)
2492 return U132Status;
2493 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2494 if (U132Status)
2495 return U132Status;
2496 reg = 0x40;
2497 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf);
2498 if (U132Status)
2499 return U132Status;
2500 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2501 if (U132Status)
2502 return U132Status;
2503 reg = 0x34;
2504 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x2edf2edf);
2505 if (U132Status)
2506 return U132Status;
2507 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2508 if (U132Status)
2509 return U132Status;
2510 reg = 4;
2511 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0xA0);
2512 if (U132Status)
2513 return U132Status;
2514 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2515 if (U132Status)
2516 return U132Status;
2517 msleep(250);
2518 reg = 8;
2519 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x0e, 0x04);
2520 if (U132Status)
2521 return U132Status;
2522 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2523 if (U132Status)
2524 return U132Status;
2525 reg = 0x28;
2526 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2527 if (U132Status)
2528 return U132Status;
2529 reg = 8;
2530 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2531 if (U132Status)
2532 return U132Status;
2533 reg = 0x48;
2534 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x00001200);
2535 if (U132Status)
2536 return U132Status;
2537 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2538 if (U132Status)
2539 return U132Status;
2540 reg = 0x54;
2541 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2542 if (U132Status)
2543 return U132Status;
2544 reg = 0x58;
2545 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2546 if (U132Status)
2547 return U132Status;
2548 reg = 0x34;
2549 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x28002edf);
2550 if (U132Status)
2551 return U132Status;
2552 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2553 if (U132Status)
2554 return U132Status;
2555 msleep(100);
2556 reg = 0x50;
2557 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10000);
2558 if (U132Status)
2559 return U132Status;
2560 reg = 0x54;
2561 power_check:U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2562 if (U132Status)
2563 return U132Status;
2564 if (!(pcidata & 1)) {
2565 msleep(500);
2566 goto power_check;
2567 }
2568 msleep(3000);
2569 reg = 0x54;
2570 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2571 if (U132Status)
2572 return U132Status;
2573 reg = 0x58;
2574 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2575 if (U132Status)
2576 return U132Status;
2577 reg = 0x54;
2578 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02);
2579 if (U132Status)
2580 return U132Status;
2581 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2582 if (U132Status)
2583 return U132Status;
2584 reg = 0x54;
2585 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x10);
2586 if (U132Status)
2587 return U132Status;
2588 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2589 if (U132Status)
2590 return U132Status;
2591 msleep(750);
2592 reg = 0x54;
2593 if (0) {
2594 U132Status = ftdi_elan_write_pcimem(ftdi, reg, 0x00, 0x02);
2595 if (U132Status)
2596 return U132Status;
2597 }
2598 if (0) {
2599 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2600 if (U132Status)
2601 return U132Status;
2602 }
2603 reg = 0x54;
2604 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2605 if (U132Status)
2606 return U132Status;
2607 reg = 0x58;
2608 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2609 if (U132Status)
2610 return U132Status;
2611 dump_regs:for (reg = 0; reg <= 0x54; reg += 4) {
2612 U132Status = ftdi_elan_read_pcimem(ftdi, reg, 0, &pcidata);
2613 if (U132Status)
2614 return U132Status;
2615 }
2616 return 0;
2617}
2618
2619
2620/*
2621* we use only the first bulk-in and bulk-out endpoints
2622*/
2623static int ftdi_elan_probe(struct usb_interface *interface,
2624 const struct usb_device_id *id)
2625{
2626 struct usb_host_interface *iface_desc;
2627 struct usb_endpoint_descriptor *endpoint;
2628 size_t buffer_size;
2629 int i;
2630 int retval = -ENOMEM;
2631 struct usb_ftdi *ftdi = kmalloc(sizeof(struct usb_ftdi), GFP_KERNEL);
2632 if (ftdi == NULL) {
2633 printk(KERN_ERR "Out of memory\n");
2634 return -ENOMEM;
2635 }
2636 memset(ftdi, 0x00, sizeof(struct usb_ftdi));
2637 down(&ftdi_module_lock);
2638 list_add_tail(&ftdi->ftdi_list, &ftdi_static_list);
2639 ftdi->sequence_num = ++ftdi_instances;
2640 up(&ftdi_module_lock);
2641 ftdi_elan_init_kref(ftdi);
2642 init_MUTEX(&ftdi->sw_lock);
2643 ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
2644 ftdi->interface = interface;
2645 init_MUTEX(&ftdi->u132_lock);
2646 ftdi->expected = 4;
2647 iface_desc = interface->cur_altsetting;
2648 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
2649 endpoint = &iface_desc->endpoint[i].desc;
2650 if (!ftdi->bulk_in_endpointAddr &&
2651 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
2652 == USB_DIR_IN) && ((endpoint->bmAttributes &
2653 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2654 {
2655 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
2656 ftdi->bulk_in_size = buffer_size;
2657 ftdi->bulk_in_endpointAddr = endpoint->bEndpointAddress;
2658 ftdi->bulk_in_buffer = kmalloc(buffer_size, GFP_KERNEL);
2659 if (!ftdi->bulk_in_buffer) {
2660 dev_err(&ftdi->udev->dev, "Could not allocate b"
2661 "ulk_in_buffer\n");
2662 retval = -ENOMEM;
2663 goto error;
2664 }
2665 }
2666 if (!ftdi->bulk_out_endpointAddr &&
2667 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK)
2668 == USB_DIR_OUT) && ((endpoint->bmAttributes &
2669 USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK))
2670 {
2671 ftdi->bulk_out_endpointAddr =
2672 endpoint->bEndpointAddress;
2673 }
2674 }
2675 if (!(ftdi->bulk_in_endpointAddr && ftdi->bulk_out_endpointAddr)) {
2676 dev_err(&ftdi->udev->dev, "Could not find both bulk-in and bulk"
2677 "-out endpoints\n");
2678 retval = -ENODEV;
2679 goto error;
2680 }
2681 dev_info(&ftdi->udev->dev, "interface %d has I=%02X O=%02X\n",
2682 iface_desc->desc.bInterfaceNumber, ftdi->bulk_in_endpointAddr,
2683 ftdi->bulk_out_endpointAddr);
2684 usb_set_intfdata(interface, ftdi);
2685 if (iface_desc->desc.bInterfaceNumber == 0 &&
2686 ftdi->bulk_in_endpointAddr == 0x81 &&
2687 ftdi->bulk_out_endpointAddr == 0x02) {
2688 retval = usb_register_dev(interface, &ftdi_elan_jtag_class);
2689 if (retval) {
2690 dev_err(&ftdi->udev->dev, "Not able to get a minor for "
2691 "this device.\n");
2692 usb_set_intfdata(interface, NULL);
2693 retval = -ENOMEM;
2694 goto error;
2695 } else {
2696 ftdi->class = &ftdi_elan_jtag_class;
2697 dev_info(&ftdi->udev->dev, "USB FDTI=%p JTAG interface "
2698 "%d now attached to ftdi%d\n", ftdi,
2699 iface_desc->desc.bInterfaceNumber,
2700 interface->minor);
2701 return 0;
2702 }
2703 } else if (iface_desc->desc.bInterfaceNumber == 1 &&
2704 ftdi->bulk_in_endpointAddr == 0x83 &&
2705 ftdi->bulk_out_endpointAddr == 0x04) {
2706 ftdi->class = NULL;
2707 dev_info(&ftdi->udev->dev, "USB FDTI=%p ELAN interface %d now a"
2708 "ctivated\n", ftdi, iface_desc->desc.bInterfaceNumber);
2709 INIT_WORK(&ftdi->status_work, ftdi_elan_status_work,
2710 (void *)ftdi);
2711 INIT_WORK(&ftdi->command_work, ftdi_elan_command_work,
2712 (void *)ftdi);
2713 INIT_WORK(&ftdi->respond_work, ftdi_elan_respond_work,
2714 (void *)ftdi);
2715 ftdi_status_queue_work(ftdi, msecs_to_jiffies(3 *1000));
2716 return 0;
2717 } else {
2718 dev_err(&ftdi->udev->dev,
2719 "Could not find ELAN's U132 device\n");
2720 retval = -ENODEV;
2721 goto error;
2722 }
2723 error:if (ftdi) {
2724 ftdi_elan_put_kref(ftdi);
2725 }
2726 return retval;
2727}
2728
2729static void ftdi_elan_disconnect(struct usb_interface *interface)
2730{
2731 struct usb_ftdi *ftdi = usb_get_intfdata(interface);
2732 ftdi->disconnected += 1;
2733 if (ftdi->class) {
2734 int minor = interface->minor;
2735 struct usb_class_driver *class = ftdi->class;
2736 usb_set_intfdata(interface, NULL);
2737 usb_deregister_dev(interface, class);
2738 dev_info(&ftdi->udev->dev, "USB FTDI U132 jtag interface on min"
2739 "or %d now disconnected\n", minor);
2740 } else {
2741 ftdi_status_cancel_work(ftdi);
2742 ftdi_command_cancel_work(ftdi);
2743 ftdi_response_cancel_work(ftdi);
2744 ftdi_elan_abandon_completions(ftdi);
2745 ftdi_elan_abandon_targets(ftdi);
2746 if (ftdi->registered) {
2747 platform_device_unregister(&ftdi->platform_dev);
2748 ftdi->synchronized = 0;
2749 ftdi->enumerated = 0;
2750 ftdi->registered = 0;
2751 }
2752 flush_workqueue(status_queue);
2753 flush_workqueue(command_queue);
2754 flush_workqueue(respond_queue);
2755 ftdi->disconnected += 1;
2756 usb_set_intfdata(interface, NULL);
2757 dev_info(&ftdi->udev->dev, "USB FTDI U132 host controller inter"
2758 "face now disconnected\n");
2759 }
2760 ftdi_elan_put_kref(ftdi);
2761}
2762
2763static struct usb_driver ftdi_elan_driver = {
2764 .name = "ftdi-elan",
2765 .probe = ftdi_elan_probe,
2766 .disconnect = ftdi_elan_disconnect,
2767 .id_table = ftdi_elan_table,
2768};
2769static int __init ftdi_elan_init(void)
2770{
2771 int result;
2772 printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name,
2773 __TIME__, __DATE__);
2774 init_MUTEX(&ftdi_module_lock);
2775 INIT_LIST_HEAD(&ftdi_static_list);
2776 status_queue = create_singlethread_workqueue("ftdi-status-control");
2777 command_queue = create_singlethread_workqueue("ftdi-command-engine");
2778 respond_queue = create_singlethread_workqueue("ftdi-respond-engine");
2779 result = usb_register(&ftdi_elan_driver);
2780 if (result)
2781 printk(KERN_ERR "usb_register failed. Error number %d\n",
2782 result);
2783 return result;
2784}
2785
2786static void __exit ftdi_elan_exit(void)
2787{
2788 struct usb_ftdi *ftdi;
2789 struct usb_ftdi *temp;
2790 usb_deregister(&ftdi_elan_driver);
2791 printk(KERN_INFO "ftdi_u132 driver deregistered\n");
2792 list_for_each_entry_safe(ftdi, temp, &ftdi_static_list, ftdi_list) {
2793 ftdi_status_cancel_work(ftdi);
2794 ftdi_command_cancel_work(ftdi);
2795 ftdi_response_cancel_work(ftdi);
2796 } flush_workqueue(status_queue);
2797 destroy_workqueue(status_queue);
2798 status_queue = NULL;
2799 flush_workqueue(command_queue);
2800 destroy_workqueue(command_queue);
2801 command_queue = NULL;
2802 flush_workqueue(respond_queue);
2803 destroy_workqueue(respond_queue);
2804 respond_queue = NULL;
2805}
2806
2807
2808module_init(ftdi_elan_init);
2809module_exit(ftdi_elan_exit);
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index fcd69c52aea9..8e6e195a22ba 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -98,7 +98,7 @@ static int idmouse_probe(struct usb_interface *interface,
98static void idmouse_disconnect(struct usb_interface *interface); 98static void idmouse_disconnect(struct usb_interface *interface);
99 99
100/* file operation pointers */ 100/* file operation pointers */
101static struct file_operations idmouse_fops = { 101static const struct file_operations idmouse_fops = {
102 .owner = THIS_MODULE, 102 .owner = THIS_MODULE,
103 .read = idmouse_read, 103 .read = idmouse_read,
104 .open = idmouse_open, 104 .open = idmouse_open,
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index f30ab1fbb3c8..10b640339d8d 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -589,7 +589,7 @@ exit:
589} 589}
590 590
591/* file operations needed when we register this driver */ 591/* file operations needed when we register this driver */
592static struct file_operations ld_usb_fops = { 592static const struct file_operations ld_usb_fops = {
593 .owner = THIS_MODULE, 593 .owner = THIS_MODULE,
594 .read = ld_usb_read, 594 .read = ld_usb_read,
595 .write = ld_usb_write, 595 .write = ld_usb_write,
@@ -657,15 +657,11 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
657 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 657 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
658 endpoint = &iface_desc->endpoint[i].desc; 658 endpoint = &iface_desc->endpoint[i].desc;
659 659
660 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) && 660 if (usb_endpoint_is_int_in(endpoint))
661 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
662 dev->interrupt_in_endpoint = endpoint; 661 dev->interrupt_in_endpoint = endpoint;
663 }
664 662
665 if (((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT) && 663 if (usb_endpoint_is_int_out(endpoint))
666 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT)) {
667 dev->interrupt_out_endpoint = endpoint; 664 dev->interrupt_out_endpoint = endpoint;
668 }
669 } 665 }
670 if (dev->interrupt_in_endpoint == NULL) { 666 if (dev->interrupt_in_endpoint == NULL) {
671 dev_err(&intf->dev, "Interrupt in endpoint not found\n"); 667 dev_err(&intf->dev, "Interrupt in endpoint not found\n");
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 7699d970e680..77c36e63c7bf 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -259,7 +259,7 @@ static void tower_disconnect (struct usb_interface *interface);
259static DEFINE_MUTEX (disconnect_mutex); 259static DEFINE_MUTEX (disconnect_mutex);
260 260
261/* file operations needed when we register this driver */ 261/* file operations needed when we register this driver */
262static struct file_operations tower_fops = { 262static const struct file_operations tower_fops = {
263 .owner = THIS_MODULE, 263 .owner = THIS_MODULE,
264 .read = tower_read, 264 .read = tower_read,
265 .write = tower_write, 265 .write = tower_write,
diff --git a/drivers/usb/misc/phidget.c b/drivers/usb/misc/phidget.c
new file mode 100644
index 000000000000..735ed33f4f7f
--- /dev/null
+++ b/drivers/usb/misc/phidget.c
@@ -0,0 +1,43 @@
1/*
2 * USB Phidgets class
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/err.h>
16#include <linux/device.h>
17
18struct class *phidget_class;
19
20static int __init init_phidget(void)
21{
22 phidget_class = class_create(THIS_MODULE, "phidget");
23
24 if (IS_ERR(phidget_class))
25 return PTR_ERR(phidget_class);
26
27 return 0;
28}
29
30static void __exit cleanup_phidget(void)
31{
32 class_destroy(phidget_class);
33}
34
35EXPORT_SYMBOL_GPL(phidget_class);
36
37module_init(init_phidget);
38module_exit(cleanup_phidget);
39
40MODULE_LICENSE("GPL");
41MODULE_AUTHOR("Sean Young <sean@mess.org>");
42MODULE_DESCRIPTION("Container module for phidget class");
43
diff --git a/drivers/usb/misc/phidget.h b/drivers/usb/misc/phidget.h
new file mode 100644
index 000000000000..c4011907d431
--- /dev/null
+++ b/drivers/usb/misc/phidget.h
@@ -0,0 +1,12 @@
1/*
2 * USB Phidgets class
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12extern struct class *phidget_class;
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index bfbbbfbb92bc..9a8d137d39f9 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -20,6 +20,8 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/usb.h> 21#include <linux/usb.h>
22 22
23#include "phidget.h"
24
23#define DRIVER_AUTHOR "Sean Young <sean@mess.org>" 25#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
24#define DRIVER_DESC "USB PhidgetInterfaceKit Driver" 26#define DRIVER_DESC "USB PhidgetInterfaceKit Driver"
25 27
@@ -57,11 +59,15 @@ ifkit(8, 8, 4, 0);
57ifkit(0, 8, 8, 1); 59ifkit(0, 8, 8, 1);
58ifkit(0, 16, 16, 0); 60ifkit(0, 16, 16, 0);
59 61
62static unsigned long device_no;
63
60struct interfacekit { 64struct interfacekit {
61 struct usb_device *udev; 65 struct usb_device *udev;
62 struct usb_interface *intf; 66 struct usb_interface *intf;
63 struct driver_interfacekit *ifkit; 67 struct driver_interfacekit *ifkit;
68 struct device *dev;
64 unsigned long outputs; 69 unsigned long outputs;
70 int dev_no;
65 u8 inputs[MAX_INTERFACES]; 71 u8 inputs[MAX_INTERFACES];
66 u16 sensors[MAX_INTERFACES]; 72 u16 sensors[MAX_INTERFACES];
67 u8 lcd_files_on; 73 u8 lcd_files_on;
@@ -180,21 +186,24 @@ exit:
180} 186}
181 187
182#define set_lcd_line(number) \ 188#define set_lcd_line(number) \
183static ssize_t lcd_line_##number(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) \ 189static ssize_t lcd_line_##number(struct device *dev, \
184{ \ 190 struct device_attribute *attr, \
185 struct usb_interface *intf = to_usb_interface(dev); \ 191 const char *buf, size_t count) \
186 struct interfacekit *kit = usb_get_intfdata(intf); \ 192{ \
187 change_string(kit, buf, number - 1); \ 193 struct interfacekit *kit = dev_get_drvdata(dev); \
188 return count; \ 194 change_string(kit, buf, number - 1); \
189} \ 195 return count; \
190static DEVICE_ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number); 196}
197
198#define lcd_line_attr(number) \
199 __ATTR(lcd_line_##number, S_IWUGO, NULL, lcd_line_##number)
200
191set_lcd_line(1); 201set_lcd_line(1);
192set_lcd_line(2); 202set_lcd_line(2);
193 203
194static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 204static ssize_t set_backlight(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
195{ 205{
196 struct usb_interface *intf = to_usb_interface(dev); 206 struct interfacekit *kit = dev_get_drvdata(dev);
197 struct interfacekit *kit = usb_get_intfdata(intf);
198 int enabled; 207 int enabled;
199 unsigned char *buffer; 208 unsigned char *buffer;
200 int retval = -ENOMEM; 209 int retval = -ENOMEM;
@@ -226,23 +235,30 @@ exit:
226 kfree(buffer); 235 kfree(buffer);
227 return retval; 236 return retval;
228} 237}
229static DEVICE_ATTR(backlight, S_IWUGO, NULL, set_backlight); 238
239static struct device_attribute dev_lcd_line_attrs[] = {
240 lcd_line_attr(1),
241 lcd_line_attr(2),
242 __ATTR(backlight, S_IWUGO, NULL, set_backlight)
243};
230 244
231static void remove_lcd_files(struct interfacekit *kit) 245static void remove_lcd_files(struct interfacekit *kit)
232{ 246{
247 int i;
248
233 if (kit->lcd_files_on) { 249 if (kit->lcd_files_on) {
234 dev_dbg(&kit->udev->dev, "Removing lcd files\n"); 250 dev_dbg(&kit->udev->dev, "Removing lcd files\n");
235 device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_1); 251
236 device_remove_file(&kit->intf->dev, &dev_attr_lcd_line_2); 252 for (i=0; i<ARRAY_SIZE(dev_lcd_line_attrs); i++)
237 device_remove_file(&kit->intf->dev, &dev_attr_backlight); 253 device_remove_file(kit->dev, &dev_lcd_line_attrs[i]);
238 } 254 }
239} 255}
240 256
241static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 257static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
242{ 258{
243 struct usb_interface *intf = to_usb_interface(dev); 259 struct interfacekit *kit = dev_get_drvdata(dev);
244 struct interfacekit *kit = usb_get_intfdata(intf);
245 int enable; 260 int enable;
261 int i, rc;
246 262
247 if (kit->ifkit->has_lcd == 0) 263 if (kit->ifkit->has_lcd == 0)
248 return -ENODEV; 264 return -ENODEV;
@@ -253,9 +269,12 @@ static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *att
253 if (enable) { 269 if (enable) {
254 if (!kit->lcd_files_on) { 270 if (!kit->lcd_files_on) {
255 dev_dbg(&kit->udev->dev, "Adding lcd files\n"); 271 dev_dbg(&kit->udev->dev, "Adding lcd files\n");
256 device_create_file(&kit->intf->dev, &dev_attr_lcd_line_1); 272 for (i=0; i<ARRAY_SIZE(dev_lcd_line_attrs); i++) {
257 device_create_file(&kit->intf->dev, &dev_attr_lcd_line_2); 273 rc = device_create_file(kit->dev,
258 device_create_file(&kit->intf->dev, &dev_attr_backlight); 274 &dev_lcd_line_attrs[i]);
275 if (rc)
276 goto out;
277 }
259 kit->lcd_files_on = 1; 278 kit->lcd_files_on = 1;
260 } 279 }
261 } else { 280 } else {
@@ -266,7 +285,13 @@ static ssize_t enable_lcd_files(struct device *dev, struct device_attribute *att
266 } 285 }
267 286
268 return count; 287 return count;
288out:
289 while (i-- > 0)
290 device_remove_file(kit->dev, &dev_lcd_line_attrs[i]);
291
292 return rc;
269} 293}
294
270static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files); 295static DEVICE_ATTR(lcd, S_IWUGO, NULL, enable_lcd_files);
271 296
272static void interfacekit_irq(struct urb *urb, struct pt_regs *regs) 297static void interfacekit_irq(struct urb *urb, struct pt_regs *regs)
@@ -362,24 +387,24 @@ static void do_notify(void *data)
362 for (i=0; i<kit->ifkit->inputs; i++) { 387 for (i=0; i<kit->ifkit->inputs; i++) {
363 if (test_and_clear_bit(i, &kit->input_events)) { 388 if (test_and_clear_bit(i, &kit->input_events)) {
364 sprintf(sysfs_file, "input%d", i + 1); 389 sprintf(sysfs_file, "input%d", i + 1);
365 sysfs_notify(&kit->intf->dev.kobj, NULL, sysfs_file); 390 sysfs_notify(&kit->dev->kobj, NULL, sysfs_file);
366 } 391 }
367 } 392 }
368 393
369 for (i=0; i<kit->ifkit->sensors; i++) { 394 for (i=0; i<kit->ifkit->sensors; i++) {
370 if (test_and_clear_bit(i, &kit->sensor_events)) { 395 if (test_and_clear_bit(i, &kit->sensor_events)) {
371 sprintf(sysfs_file, "sensor%d", i + 1); 396 sprintf(sysfs_file, "sensor%d", i + 1);
372 sysfs_notify(&kit->intf->dev.kobj, NULL, sysfs_file); 397 sysfs_notify(&kit->dev->kobj, NULL, sysfs_file);
373 } 398 }
374 } 399 }
375} 400}
376 401
377#define show_set_output(value) \ 402#define show_set_output(value) \
378static ssize_t set_output##value(struct device *dev, struct device_attribute *attr, const char *buf, \ 403static ssize_t set_output##value(struct device *dev, \
379 size_t count) \ 404 struct device_attribute *attr, \
405 const char *buf, size_t count) \
380{ \ 406{ \
381 struct usb_interface *intf = to_usb_interface(dev); \ 407 struct interfacekit *kit = dev_get_drvdata(dev); \
382 struct interfacekit *kit = usb_get_intfdata(intf); \
383 int enabled; \ 408 int enabled; \
384 int retval; \ 409 int retval; \
385 \ 410 \
@@ -391,15 +416,19 @@ static ssize_t set_output##value(struct device *dev, struct device_attribute *at
391 return retval ? retval : count; \ 416 return retval ? retval : count; \
392} \ 417} \
393 \ 418 \
394static ssize_t show_output##value(struct device *dev, struct device_attribute *attr, char *buf) \ 419static ssize_t show_output##value(struct device *dev, \
420 struct device_attribute *attr, \
421 char *buf) \
395{ \ 422{ \
396 struct usb_interface *intf = to_usb_interface(dev); \ 423 struct interfacekit *kit = dev_get_drvdata(dev); \
397 struct interfacekit *kit = usb_get_intfdata(intf); \
398 \ 424 \
399 return sprintf(buf, "%d\n", !!test_bit(value - 1, &kit->outputs));\ 425 return sprintf(buf, "%d\n", !!test_bit(value - 1, &kit->outputs));\
400} \ 426}
401static DEVICE_ATTR(output##value, S_IWUGO | S_IRUGO, \ 427
402 show_output##value, set_output##value); 428#define output_attr(value) \
429 __ATTR(output##value, S_IWUGO | S_IRUGO, \
430 show_output##value, set_output##value)
431
403show_set_output(1); 432show_set_output(1);
404show_set_output(2); 433show_set_output(2);
405show_set_output(3); 434show_set_output(3);
@@ -417,15 +446,24 @@ show_set_output(14);
417show_set_output(15); 446show_set_output(15);
418show_set_output(16); 447show_set_output(16);
419 448
449static struct device_attribute dev_output_attrs[] = {
450 output_attr(1), output_attr(2), output_attr(3), output_attr(4),
451 output_attr(5), output_attr(6), output_attr(7), output_attr(8),
452 output_attr(9), output_attr(10), output_attr(11), output_attr(12),
453 output_attr(13), output_attr(14), output_attr(15), output_attr(16)
454};
455
420#define show_input(value) \ 456#define show_input(value) \
421static ssize_t show_input##value(struct device *dev, struct device_attribute *attr, char *buf) \ 457static ssize_t show_input##value(struct device *dev, \
458 struct device_attribute *attr, char *buf) \
422{ \ 459{ \
423 struct usb_interface *intf = to_usb_interface(dev); \ 460 struct interfacekit *kit = dev_get_drvdata(dev); \
424 struct interfacekit *kit = usb_get_intfdata(intf); \
425 \ 461 \
426 return sprintf(buf, "%d\n", (int)kit->inputs[value - 1]); \ 462 return sprintf(buf, "%d\n", (int)kit->inputs[value - 1]); \
427} \ 463}
428static DEVICE_ATTR(input##value, S_IRUGO, show_input##value, NULL); 464
465#define input_attr(value) \
466 __ATTR(input##value, S_IRUGO, show_input##value, NULL)
429 467
430show_input(1); 468show_input(1);
431show_input(2); 469show_input(2);
@@ -444,15 +482,25 @@ show_input(14);
444show_input(15); 482show_input(15);
445show_input(16); 483show_input(16);
446 484
485static struct device_attribute dev_input_attrs[] = {
486 input_attr(1), input_attr(2), input_attr(3), input_attr(4),
487 input_attr(5), input_attr(6), input_attr(7), input_attr(8),
488 input_attr(9), input_attr(10), input_attr(11), input_attr(12),
489 input_attr(13), input_attr(14), input_attr(15), input_attr(16)
490};
491
447#define show_sensor(value) \ 492#define show_sensor(value) \
448static ssize_t show_sensor##value(struct device *dev, struct device_attribute *attr, char *buf) \ 493static ssize_t show_sensor##value(struct device *dev, \
494 struct device_attribute *attr, \
495 char *buf) \
449{ \ 496{ \
450 struct usb_interface *intf = to_usb_interface(dev); \ 497 struct interfacekit *kit = dev_get_drvdata(dev); \
451 struct interfacekit *kit = usb_get_intfdata(intf); \
452 \ 498 \
453 return sprintf(buf, "%d\n", (int)kit->sensors[value - 1]); \ 499 return sprintf(buf, "%d\n", (int)kit->sensors[value - 1]); \
454} \ 500}
455static DEVICE_ATTR(sensor##value, S_IRUGO, show_sensor##value, NULL); 501
502#define sensor_attr(value) \
503 __ATTR(sensor##value, S_IRUGO, show_sensor##value, NULL)
456 504
457show_sensor(1); 505show_sensor(1);
458show_sensor(2); 506show_sensor(2);
@@ -463,6 +511,11 @@ show_sensor(6);
463show_sensor(7); 511show_sensor(7);
464show_sensor(8); 512show_sensor(8);
465 513
514static struct device_attribute dev_sensor_attrs[] = {
515 sensor_attr(1), sensor_attr(2), sensor_attr(3), sensor_attr(4),
516 sensor_attr(5), sensor_attr(6), sensor_attr(7), sensor_attr(8)
517};
518
466static int interfacekit_probe(struct usb_interface *intf, const struct usb_device_id *id) 519static int interfacekit_probe(struct usb_interface *intf, const struct usb_device_id *id)
467{ 520{
468 struct usb_device *dev = interface_to_usbdev(intf); 521 struct usb_device *dev = interface_to_usbdev(intf);
@@ -471,6 +524,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
471 struct interfacekit *kit; 524 struct interfacekit *kit;
472 struct driver_interfacekit *ifkit; 525 struct driver_interfacekit *ifkit;
473 int pipe, maxp, rc = -ENOMEM; 526 int pipe, maxp, rc = -ENOMEM;
527 int bit, value, i;
474 528
475 ifkit = (struct driver_interfacekit *)id->driver_info; 529 ifkit = (struct driver_interfacekit *)id->driver_info;
476 if (!ifkit) 530 if (!ifkit)
@@ -493,6 +547,7 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
493 if (!kit) 547 if (!kit)
494 goto out; 548 goto out;
495 549
550 kit->dev_no = -1;
496 kit->ifkit = ifkit; 551 kit->ifkit = ifkit;
497 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma); 552 kit->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &kit->data_dma);
498 if (!kit->data) 553 if (!kit->data)
@@ -513,85 +568,80 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic
513 568
514 usb_set_intfdata(intf, kit); 569 usb_set_intfdata(intf, kit);
515 570
571 do {
572 bit = find_first_zero_bit(&device_no, sizeof(device_no));
573 value = test_and_set_bit(bit, &device_no);
574 } while(value);
575 kit->dev_no = bit;
576
577 kit->dev = device_create(phidget_class, &kit->udev->dev, 0,
578 "interfacekit%d", kit->dev_no);
579 if (IS_ERR(kit->dev)) {
580 rc = PTR_ERR(kit->dev);
581 kit->dev = NULL;
582 goto out;
583 }
584 dev_set_drvdata(kit->dev, kit);
585
516 if (usb_submit_urb(kit->irq, GFP_KERNEL)) { 586 if (usb_submit_urb(kit->irq, GFP_KERNEL)) {
517 rc = -EIO; 587 rc = -EIO;
518 goto out; 588 goto out;
519 } 589 }
520 590
521 if (ifkit->outputs >= 4) { 591 for (i=0; i<ifkit->outputs; i++ ) {
522 device_create_file(&intf->dev, &dev_attr_output1); 592 rc = device_create_file(kit->dev, &dev_output_attrs[i]);
523 device_create_file(&intf->dev, &dev_attr_output2); 593 if (rc)
524 device_create_file(&intf->dev, &dev_attr_output3); 594 goto out2;
525 device_create_file(&intf->dev, &dev_attr_output4);
526 }
527 if (ifkit->outputs >= 8) {
528 device_create_file(&intf->dev, &dev_attr_output5);
529 device_create_file(&intf->dev, &dev_attr_output6);
530 device_create_file(&intf->dev, &dev_attr_output7);
531 device_create_file(&intf->dev, &dev_attr_output8);
532 }
533 if (ifkit->outputs == 16) {
534 device_create_file(&intf->dev, &dev_attr_output9);
535 device_create_file(&intf->dev, &dev_attr_output10);
536 device_create_file(&intf->dev, &dev_attr_output11);
537 device_create_file(&intf->dev, &dev_attr_output12);
538 device_create_file(&intf->dev, &dev_attr_output13);
539 device_create_file(&intf->dev, &dev_attr_output14);
540 device_create_file(&intf->dev, &dev_attr_output15);
541 device_create_file(&intf->dev, &dev_attr_output16);
542 } 595 }
543 596
544 if (ifkit->inputs >= 4) { 597 for (i=0; i<ifkit->inputs; i++ ) {
545 device_create_file(&intf->dev, &dev_attr_input1); 598 rc = device_create_file(kit->dev, &dev_input_attrs[i]);
546 device_create_file(&intf->dev, &dev_attr_input2); 599 if (rc)
547 device_create_file(&intf->dev, &dev_attr_input3); 600 goto out3;
548 device_create_file(&intf->dev, &dev_attr_input4);
549 }
550 if (ifkit->inputs >= 8) {
551 device_create_file(&intf->dev, &dev_attr_input5);
552 device_create_file(&intf->dev, &dev_attr_input6);
553 device_create_file(&intf->dev, &dev_attr_input7);
554 device_create_file(&intf->dev, &dev_attr_input8);
555 }
556 if (ifkit->inputs == 16) {
557 device_create_file(&intf->dev, &dev_attr_input9);
558 device_create_file(&intf->dev, &dev_attr_input10);
559 device_create_file(&intf->dev, &dev_attr_input11);
560 device_create_file(&intf->dev, &dev_attr_input12);
561 device_create_file(&intf->dev, &dev_attr_input13);
562 device_create_file(&intf->dev, &dev_attr_input14);
563 device_create_file(&intf->dev, &dev_attr_input15);
564 device_create_file(&intf->dev, &dev_attr_input16);
565 } 601 }
566 602
567 if (ifkit->sensors >= 4) { 603 for (i=0; i<ifkit->sensors; i++ ) {
568 device_create_file(&intf->dev, &dev_attr_sensor1); 604 rc = device_create_file(kit->dev, &dev_sensor_attrs[i]);
569 device_create_file(&intf->dev, &dev_attr_sensor2); 605 if (rc)
570 device_create_file(&intf->dev, &dev_attr_sensor3); 606 goto out4;
571 device_create_file(&intf->dev, &dev_attr_sensor4);
572 }
573 if (ifkit->sensors >= 7) {
574 device_create_file(&intf->dev, &dev_attr_sensor5);
575 device_create_file(&intf->dev, &dev_attr_sensor6);
576 device_create_file(&intf->dev, &dev_attr_sensor7);
577 } 607 }
578 if (ifkit->sensors == 8)
579 device_create_file(&intf->dev, &dev_attr_sensor8);
580 608
581 if (ifkit->has_lcd) 609 if (ifkit->has_lcd) {
582 device_create_file(&intf->dev, &dev_attr_lcd); 610 rc = device_create_file(kit->dev, &dev_attr_lcd);
611 if (rc)
612 goto out4;
613
614 }
583 615
584 dev_info(&intf->dev, "USB PhidgetInterfaceKit %d/%d/%d attached\n", 616 dev_info(&intf->dev, "USB PhidgetInterfaceKit %d/%d/%d attached\n",
585 ifkit->sensors, ifkit->inputs, ifkit->outputs); 617 ifkit->sensors, ifkit->inputs, ifkit->outputs);
586 618
587 return 0; 619 return 0;
588 620
621out4:
622 while (i-- > 0)
623 device_remove_file(kit->dev, &dev_sensor_attrs[i]);
624
625 i = ifkit->inputs;
626out3:
627 while (i-- > 0)
628 device_remove_file(kit->dev, &dev_input_attrs[i]);
629
630 i = ifkit->outputs;
631out2:
632 while (i-- > 0)
633 device_remove_file(kit->dev, &dev_output_attrs[i]);
589out: 634out:
590 if (kit) { 635 if (kit) {
591 if (kit->irq) 636 if (kit->irq)
592 usb_free_urb(kit->irq); 637 usb_free_urb(kit->irq);
593 if (kit->data) 638 if (kit->data)
594 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma); 639 usb_buffer_free(dev, URB_INT_SIZE, kit->data, kit->data_dma);
640 if (kit->dev)
641 device_unregister(kit->dev);
642 if (kit->dev_no >= 0)
643 clear_bit(kit->dev_no, &device_no);
644
595 kfree(kit); 645 kfree(kit);
596 } 646 }
597 647
@@ -601,6 +651,7 @@ out:
601static void interfacekit_disconnect(struct usb_interface *interface) 651static void interfacekit_disconnect(struct usb_interface *interface)
602{ 652{
603 struct interfacekit *kit; 653 struct interfacekit *kit;
654 int i;
604 655
605 kit = usb_get_intfdata(interface); 656 kit = usb_get_intfdata(interface);
606 usb_set_intfdata(interface, NULL); 657 usb_set_intfdata(interface, NULL);
@@ -613,73 +664,28 @@ static void interfacekit_disconnect(struct usb_interface *interface)
613 664
614 cancel_delayed_work(&kit->do_notify); 665 cancel_delayed_work(&kit->do_notify);
615 666
616 if (kit->ifkit->outputs >= 4) { 667 for (i=0; i<kit->ifkit->outputs; i++)
617 device_remove_file(&interface->dev, &dev_attr_output1); 668 device_remove_file(kit->dev, &dev_output_attrs[i]);
618 device_remove_file(&interface->dev, &dev_attr_output2);
619 device_remove_file(&interface->dev, &dev_attr_output3);
620 device_remove_file(&interface->dev, &dev_attr_output4);
621 }
622 if (kit->ifkit->outputs >= 8) {
623 device_remove_file(&interface->dev, &dev_attr_output5);
624 device_remove_file(&interface->dev, &dev_attr_output6);
625 device_remove_file(&interface->dev, &dev_attr_output7);
626 device_remove_file(&interface->dev, &dev_attr_output8);
627 }
628 if (kit->ifkit->outputs == 16) {
629 device_remove_file(&interface->dev, &dev_attr_output9);
630 device_remove_file(&interface->dev, &dev_attr_output10);
631 device_remove_file(&interface->dev, &dev_attr_output11);
632 device_remove_file(&interface->dev, &dev_attr_output12);
633 device_remove_file(&interface->dev, &dev_attr_output13);
634 device_remove_file(&interface->dev, &dev_attr_output14);
635 device_remove_file(&interface->dev, &dev_attr_output15);
636 device_remove_file(&interface->dev, &dev_attr_output16);
637 }
638 669
639 if (kit->ifkit->inputs >= 4) { 670 for (i=0; i<kit->ifkit->inputs; i++)
640 device_remove_file(&interface->dev, &dev_attr_input1); 671 device_remove_file(kit->dev, &dev_input_attrs[i]);
641 device_remove_file(&interface->dev, &dev_attr_input2);
642 device_remove_file(&interface->dev, &dev_attr_input3);
643 device_remove_file(&interface->dev, &dev_attr_input4);
644 }
645 if (kit->ifkit->inputs >= 8) {
646 device_remove_file(&interface->dev, &dev_attr_input5);
647 device_remove_file(&interface->dev, &dev_attr_input6);
648 device_remove_file(&interface->dev, &dev_attr_input7);
649 device_remove_file(&interface->dev, &dev_attr_input8);
650 }
651 if (kit->ifkit->inputs == 16) {
652 device_remove_file(&interface->dev, &dev_attr_input9);
653 device_remove_file(&interface->dev, &dev_attr_input10);
654 device_remove_file(&interface->dev, &dev_attr_input11);
655 device_remove_file(&interface->dev, &dev_attr_input12);
656 device_remove_file(&interface->dev, &dev_attr_input13);
657 device_remove_file(&interface->dev, &dev_attr_input14);
658 device_remove_file(&interface->dev, &dev_attr_input15);
659 device_remove_file(&interface->dev, &dev_attr_input16);
660 }
661 672
662 if (kit->ifkit->sensors >= 4) { 673 for (i=0; i<kit->ifkit->sensors; i++)
663 device_remove_file(&interface->dev, &dev_attr_sensor1); 674 device_remove_file(kit->dev, &dev_sensor_attrs[i]);
664 device_remove_file(&interface->dev, &dev_attr_sensor2); 675
665 device_remove_file(&interface->dev, &dev_attr_sensor3); 676 if (kit->ifkit->has_lcd) {
666 device_remove_file(&interface->dev, &dev_attr_sensor4); 677 device_remove_file(kit->dev, &dev_attr_lcd);
667 } 678 remove_lcd_files(kit);
668 if (kit->ifkit->sensors >= 7) {
669 device_remove_file(&interface->dev, &dev_attr_sensor5);
670 device_remove_file(&interface->dev, &dev_attr_sensor6);
671 device_remove_file(&interface->dev, &dev_attr_sensor7);
672 } 679 }
673 if (kit->ifkit->sensors == 8)
674 device_remove_file(&interface->dev, &dev_attr_sensor8);
675 680
676 if (kit->ifkit->has_lcd) 681 device_unregister(kit->dev);
677 device_remove_file(&interface->dev, &dev_attr_lcd);
678 682
679 dev_info(&interface->dev, "USB PhidgetInterfaceKit %d/%d/%d detached\n", 683 dev_info(&interface->dev, "USB PhidgetInterfaceKit %d/%d/%d detached\n",
680 kit->ifkit->sensors, kit->ifkit->inputs, kit->ifkit->outputs); 684 kit->ifkit->sensors, kit->ifkit->inputs, kit->ifkit->outputs);
681 685
682 usb_put_dev(kit->udev); 686 usb_put_dev(kit->udev);
687 clear_bit(kit->dev_no, &device_no);
688
683 kfree(kit); 689 kfree(kit);
684} 690}
685 691
diff --git a/drivers/usb/misc/phidgetmotorcontrol.c b/drivers/usb/misc/phidgetmotorcontrol.c
new file mode 100644
index 000000000000..6b59b620d616
--- /dev/null
+++ b/drivers/usb/misc/phidgetmotorcontrol.c
@@ -0,0 +1,466 @@
1/*
2 * USB Phidget MotorControl driver
3 *
4 * Copyright (C) 2006 Sean Young <sean@mess.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/errno.h>
14#include <linux/init.h>
15#include <linux/module.h>
16#include <linux/usb.h>
17
18#include "phidget.h"
19
20#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
21#define DRIVER_DESC "USB PhidgetMotorControl Driver"
22
23#define USB_VENDOR_ID_GLAB 0x06c2
24#define USB_DEVICE_ID_MOTORCONTROL 0x0058
25
26#define URB_INT_SIZE 8
27
28static unsigned long device_no;
29
30struct motorcontrol {
31 struct usb_device *udev;
32 struct usb_interface *intf;
33 struct device *dev;
34 int dev_no;
35 u8 inputs[4];
36 s8 desired_speed[2];
37 s8 speed[2];
38 s16 _current[2];
39 s8 acceleration[2];
40 struct urb *irq;
41 unsigned char *data;
42 dma_addr_t data_dma;
43
44 struct work_struct do_notify;
45 unsigned long input_events;
46 unsigned long speed_events;
47 unsigned long exceed_events;
48};
49
50static struct usb_device_id id_table[] = {
51 { USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_MOTORCONTROL) },
52 {}
53};
54MODULE_DEVICE_TABLE(usb, id_table);
55
56static int set_motor(struct motorcontrol *mc, int motor)
57{
58 u8 *buffer;
59 int speed, speed2, acceleration;
60 int retval;
61
62 buffer = kzalloc(8, GFP_KERNEL);
63 if (!buffer) {
64 dev_err(&mc->intf->dev, "%s - out of memory\n", __FUNCTION__);
65 return -ENOMEM;
66 }
67
68 acceleration = mc->acceleration[motor] * 10;
69 /* -127 <= speed <= 127 */
70 speed = (mc->desired_speed[motor] * 127) / 100;
71 /* -0x7300 <= speed2 <= 0x7300 */
72 speed2 = (mc->desired_speed[motor] * 230 * 128) / 100;
73
74 buffer[0] = motor;
75 buffer[1] = speed;
76 buffer[2] = acceleration >> 8;
77 buffer[3] = acceleration;
78 buffer[4] = speed2 >> 8;
79 buffer[5] = speed2;
80
81 retval = usb_control_msg(mc->udev,
82 usb_sndctrlpipe(mc->udev, 0),
83 0x09, 0x21, 0x0200, 0x0000, buffer, 8, 2000);
84
85 if (retval != 8)
86 dev_err(&mc->intf->dev, "usb_control_msg returned %d\n",
87 retval);
88 kfree(buffer);
89
90 return retval < 0 ? retval : 0;
91}
92
93static void motorcontrol_irq(struct urb *urb, struct pt_regs *regs)
94{
95 struct motorcontrol *mc = urb->context;
96 unsigned char *buffer = mc->data;
97 int i, level;
98 int status;
99
100 switch (urb->status) {
101 case 0: /* success */
102 break;
103 case -ECONNRESET: /* unlink */
104 case -ENOENT:
105 case -ESHUTDOWN:
106 return;
107 /* -EPIPE: should clear the halt */
108 default: /* error */
109 goto resubmit;
110 }
111
112 /* digital inputs */
113 for (i=0; i<4; i++) {
114 level = (buffer[0] >> i) & 1;
115 if (mc->inputs[i] != level) {
116 mc->inputs[i] = level;
117 set_bit(i, &mc->input_events);
118 }
119 }
120
121 /* motor speed */
122 if (buffer[2] == 0) {
123 for (i=0; i<2; i++) {
124 level = ((s8)buffer[4+i]) * 100 / 127;
125 if (mc->speed[i] != level) {
126 mc->speed[i] = level;
127 set_bit(i, &mc->speed_events);
128 }
129 }
130 } else {
131 int index = buffer[3] & 1;
132
133 level = ((s8)buffer[4] << 8) | buffer[5];
134 level = level * 100 / 29440;
135 if (mc->speed[index] != level) {
136 mc->speed[index] = level;
137 set_bit(index, &mc->speed_events);
138 }
139
140 level = ((s8)buffer[6] << 8) | buffer[7];
141 mc->_current[index] = level * 100 / 1572;
142 }
143
144 if (buffer[1] & 1)
145 set_bit(0, &mc->exceed_events);
146
147 if (buffer[1] & 2)
148 set_bit(1, &mc->exceed_events);
149
150 if (mc->input_events || mc->exceed_events || mc->speed_events)
151 schedule_work(&mc->do_notify);
152
153resubmit:
154 status = usb_submit_urb(urb, SLAB_ATOMIC);
155 if (status)
156 dev_err(&mc->intf->dev,
157 "can't resubmit intr, %s-%s/motorcontrol0, status %d",
158 mc->udev->bus->bus_name,
159 mc->udev->devpath, status);
160}
161
162static void do_notify(void *data)
163{
164 struct motorcontrol *mc = data;
165 int i;
166 char sysfs_file[8];
167
168 for (i=0; i<4; i++) {
169 if (test_and_clear_bit(i, &mc->input_events)) {
170 sprintf(sysfs_file, "input%d", i);
171 sysfs_notify(&mc->dev->kobj, NULL, sysfs_file);
172 }
173 }
174
175 for (i=0; i<2; i++) {
176 if (test_and_clear_bit(i, &mc->speed_events)) {
177 sprintf(sysfs_file, "speed%d", i);
178 sysfs_notify(&mc->dev->kobj, NULL, sysfs_file);
179 }
180 }
181
182 for (i=0; i<2; i++) {
183 if (test_and_clear_bit(i, &mc->exceed_events))
184 dev_warn(&mc->intf->dev,
185 "motor #%d exceeds 1.5 Amp current limit\n", i);
186 }
187}
188
189#define show_set_speed(value) \
190static ssize_t set_speed##value(struct device *dev, \
191 struct device_attribute *attr, \
192 const char *buf, size_t count) \
193{ \
194 struct motorcontrol *mc = dev_get_drvdata(dev); \
195 int speed; \
196 int retval; \
197 \
198 if (sscanf(buf, "%d", &speed) < 1) \
199 return -EINVAL; \
200 \
201 if (speed < -100 || speed > 100) \
202 return -EINVAL; \
203 \
204 mc->desired_speed[value] = speed; \
205 \
206 retval = set_motor(mc, value); \
207 \
208 return retval ? retval : count; \
209} \
210 \
211static ssize_t show_speed##value(struct device *dev, \
212 struct device_attribute *attr, \
213 char *buf) \
214{ \
215 struct motorcontrol *mc = dev_get_drvdata(dev); \
216 \
217 return sprintf(buf, "%d\n", mc->speed[value]); \
218}
219
220#define speed_attr(value) \
221 __ATTR(speed##value, S_IWUGO | S_IRUGO, \
222 show_speed##value, set_speed##value)
223
224show_set_speed(0);
225show_set_speed(1);
226
227#define show_set_acceleration(value) \
228static ssize_t set_acceleration##value(struct device *dev, \
229 struct device_attribute *attr, \
230 const char *buf, size_t count) \
231{ \
232 struct motorcontrol *mc = dev_get_drvdata(dev); \
233 int acceleration; \
234 int retval; \
235 \
236 if (sscanf(buf, "%d", &acceleration) < 1) \
237 return -EINVAL; \
238 \
239 if (acceleration < 0 || acceleration > 100) \
240 return -EINVAL; \
241 \
242 mc->acceleration[value] = acceleration; \
243 \
244 retval = set_motor(mc, value); \
245 \
246 return retval ? retval : count; \
247} \
248 \
249static ssize_t show_acceleration##value(struct device *dev, \
250 struct device_attribute *attr, \
251 char *buf) \
252{ \
253 struct motorcontrol *mc = dev_get_drvdata(dev); \
254 \
255 return sprintf(buf, "%d\n", mc->acceleration[value]); \
256}
257
258#define acceleration_attr(value) \
259 __ATTR(acceleration##value, S_IWUGO | S_IRUGO, \
260 show_acceleration##value, set_acceleration##value)
261
262show_set_acceleration(0);
263show_set_acceleration(1);
264
265#define show_current(value) \
266static ssize_t show_current##value(struct device *dev, \
267 struct device_attribute *attr, \
268 char *buf) \
269{ \
270 struct motorcontrol *mc = dev_get_drvdata(dev); \
271 \
272 return sprintf(buf, "%dmA\n", (int)mc->_current[value]); \
273}
274
275#define current_attr(value) \
276 __ATTR(current##value, S_IRUGO, show_current##value, NULL)
277
278show_current(0);
279show_current(1);
280
281#define show_input(value) \
282static ssize_t show_input##value(struct device *dev, \
283 struct device_attribute *attr, \
284 char *buf) \
285{ \
286 struct motorcontrol *mc = dev_get_drvdata(dev); \
287 \
288 return sprintf(buf, "%d\n", (int)mc->inputs[value]); \
289}
290
291#define input_attr(value) \
292 __ATTR(input##value, S_IRUGO, show_input##value, NULL)
293
294show_input(0);
295show_input(1);
296show_input(2);
297show_input(3);
298
299static struct device_attribute dev_attrs[] = {
300 input_attr(0),
301 input_attr(1),
302 input_attr(2),
303 input_attr(3),
304 speed_attr(0),
305 speed_attr(1),
306 acceleration_attr(0),
307 acceleration_attr(1),
308 current_attr(0),
309 current_attr(1)
310};
311
312static int motorcontrol_probe(struct usb_interface *intf, const struct usb_device_id *id)
313{
314 struct usb_device *dev = interface_to_usbdev(intf);
315 struct usb_host_interface *interface;
316 struct usb_endpoint_descriptor *endpoint;
317 struct motorcontrol *mc;
318 int pipe, maxp, rc = -ENOMEM;
319 int bit, value, i;
320
321 interface = intf->cur_altsetting;
322 if (interface->desc.bNumEndpoints != 1)
323 return -ENODEV;
324
325 endpoint = &interface->endpoint[0].desc;
326 if (!(endpoint->bEndpointAddress & 0x80))
327 return -ENODEV;
328
329 /*
330 * bmAttributes
331 */
332 pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress);
333 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
334
335 mc = kzalloc(sizeof(*mc), GFP_KERNEL);
336 if (!mc)
337 goto out;
338
339 mc->dev_no = -1;
340 mc->data = usb_buffer_alloc(dev, URB_INT_SIZE, SLAB_ATOMIC, &mc->data_dma);
341 if (!mc->data)
342 goto out;
343
344 mc->irq = usb_alloc_urb(0, GFP_KERNEL);
345 if (!mc->irq)
346 goto out;
347
348 mc->udev = usb_get_dev(dev);
349 mc->intf = intf;
350 mc->acceleration[0] = mc->acceleration[1] = 10;
351 INIT_WORK(&mc->do_notify, do_notify, mc);
352 usb_fill_int_urb(mc->irq, mc->udev, pipe, mc->data,
353 maxp > URB_INT_SIZE ? URB_INT_SIZE : maxp,
354 motorcontrol_irq, mc, endpoint->bInterval);
355 mc->irq->transfer_dma = mc->data_dma;
356 mc->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
357
358 usb_set_intfdata(intf, mc);
359
360 do {
361 bit = find_first_zero_bit(&device_no, sizeof(device_no));
362 value = test_and_set_bit(bit, &device_no);
363 } while(value);
364 mc->dev_no = bit;
365
366 mc->dev = device_create(phidget_class, &mc->udev->dev, 0,
367 "motorcontrol%d", mc->dev_no);
368 if (IS_ERR(mc->dev)) {
369 rc = PTR_ERR(mc->dev);
370 mc->dev = NULL;
371 goto out;
372 }
373
374 dev_set_drvdata(mc->dev, mc);
375
376 if (usb_submit_urb(mc->irq, GFP_KERNEL)) {
377 rc = -EIO;
378 goto out;
379 }
380
381 for (i=0; i<ARRAY_SIZE(dev_attrs); i++) {
382 rc = device_create_file(mc->dev, &dev_attrs[i]);
383 if (rc)
384 goto out2;
385 }
386
387 dev_info(&intf->dev, "USB PhidgetMotorControl attached\n");
388
389 return 0;
390out2:
391 while (i-- > 0)
392 device_remove_file(mc->dev, &dev_attrs[i]);
393out:
394 if (mc) {
395 if (mc->irq)
396 usb_free_urb(mc->irq);
397 if (mc->data)
398 usb_buffer_free(dev, URB_INT_SIZE, mc->data, mc->data_dma);
399 if (mc->dev)
400 device_unregister(mc->dev);
401 if (mc->dev_no >= 0)
402 clear_bit(mc->dev_no, &device_no);
403
404 kfree(mc);
405 }
406
407 return rc;
408}
409
410static void motorcontrol_disconnect(struct usb_interface *interface)
411{
412 struct motorcontrol *mc;
413 int i;
414
415 mc = usb_get_intfdata(interface);
416 usb_set_intfdata(interface, NULL);
417 if (!mc)
418 return;
419
420 usb_kill_urb(mc->irq);
421 usb_free_urb(mc->irq);
422 usb_buffer_free(mc->udev, URB_INT_SIZE, mc->data, mc->data_dma);
423
424 cancel_delayed_work(&mc->do_notify);
425
426 for (i=0; i<ARRAY_SIZE(dev_attrs); i++)
427 device_remove_file(mc->dev, &dev_attrs[i]);
428
429 device_unregister(mc->dev);
430
431 usb_put_dev(mc->udev);
432 clear_bit(mc->dev_no, &device_no);
433 kfree(mc);
434
435 dev_info(&interface->dev, "USB PhidgetMotorControl detached\n");
436}
437
438static struct usb_driver motorcontrol_driver = {
439 .name = "phidgetmotorcontrol",
440 .probe = motorcontrol_probe,
441 .disconnect = motorcontrol_disconnect,
442 .id_table = id_table
443};
444
445static int __init motorcontrol_init(void)
446{
447 int retval = 0;
448
449 retval = usb_register(&motorcontrol_driver);
450 if (retval)
451 err("usb_register failed. Error number %d", retval);
452
453 return retval;
454}
455
456static void __exit motorcontrol_exit(void)
457{
458 usb_deregister(&motorcontrol_driver);
459}
460
461module_init(motorcontrol_init);
462module_exit(motorcontrol_exit);
463
464MODULE_AUTHOR(DRIVER_AUTHOR);
465MODULE_DESCRIPTION(DRIVER_DESC);
466MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index c0df79c96538..7163f05c5b27 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * USB PhidgetServo driver 1.0 2 * USB PhidgetServo driver 1.0
3 * 3 *
4 * Copyright (C) 2004 Sean Young <sean@mess.org> 4 * Copyright (C) 2004, 2006 Sean Young <sean@mess.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -15,14 +15,6 @@
15 * 15 *
16 * CAUTION: Generally you should use 0 < degrees < 180 as anything else 16 * CAUTION: Generally you should use 0 < degrees < 180 as anything else
17 * is probably beyond the range of your servo and may damage it. 17 * is probably beyond the range of your servo and may damage it.
18 *
19 * Jun 16, 2004: Sean Young <sean@mess.org>
20 * - cleanups
21 * - was using memory after kfree()
22 * Aug 8, 2004: Sean Young <sean@mess.org>
23 * - set the highest angle as high as the hardware allows, there are
24 * some odd servos out there
25 *
26 */ 18 */
27 19
28#include <linux/kernel.h> 20#include <linux/kernel.h>
@@ -32,6 +24,8 @@
32#include <linux/module.h> 24#include <linux/module.h>
33#include <linux/usb.h> 25#include <linux/usb.h>
34 26
27#include "phidget.h"
28
35#define DRIVER_AUTHOR "Sean Young <sean@mess.org>" 29#define DRIVER_AUTHOR "Sean Young <sean@mess.org>"
36#define DRIVER_DESC "USB PhidgetServo Driver" 30#define DRIVER_DESC "USB PhidgetServo Driver"
37 31
@@ -70,8 +64,12 @@ static struct usb_device_id id_table[] = {
70 64
71MODULE_DEVICE_TABLE(usb, id_table); 65MODULE_DEVICE_TABLE(usb, id_table);
72 66
67static int unsigned long device_no;
68
73struct phidget_servo { 69struct phidget_servo {
74 struct usb_device *udev; 70 struct usb_device *udev;
71 struct device *dev;
72 int dev_no;
75 ulong type; 73 ulong type;
76 int pulse[4]; 74 int pulse[4];
77 int degrees[4]; 75 int degrees[4];
@@ -203,16 +201,16 @@ change_position_v20(struct phidget_servo *servo, int servo_no, int degrees,
203} 201}
204 202
205#define show_set(value) \ 203#define show_set(value) \
206static ssize_t set_servo##value (struct device *dev, struct device_attribute *attr, \ 204static ssize_t set_servo##value (struct device *dev, \
205 struct device_attribute *attr, \
207 const char *buf, size_t count) \ 206 const char *buf, size_t count) \
208{ \ 207{ \
209 int degrees, minutes, retval; \ 208 int degrees, minutes, retval; \
210 struct usb_interface *intf = to_usb_interface (dev); \ 209 struct phidget_servo *servo = dev_get_drvdata(dev); \
211 struct phidget_servo *servo = usb_get_intfdata (intf); \
212 \ 210 \
213 minutes = 0; \ 211 minutes = 0; \
214 /* must at least convert degrees */ \ 212 /* must at least convert degrees */ \
215 if (sscanf (buf, "%d.%d", &degrees, &minutes) < 1) { \ 213 if (sscanf(buf, "%d.%d", &degrees, &minutes) < 1) { \
216 return -EINVAL; \ 214 return -EINVAL; \
217 } \ 215 } \
218 \ 216 \
@@ -220,86 +218,127 @@ static ssize_t set_servo##value (struct device *dev, struct device_attribute *at
220 return -EINVAL; \ 218 return -EINVAL; \
221 \ 219 \
222 if (servo->type & SERVO_VERSION_30) \ 220 if (servo->type & SERVO_VERSION_30) \
223 retval = change_position_v30 (servo, value, degrees, \ 221 retval = change_position_v30(servo, value, degrees, \
224 minutes); \ 222 minutes); \
225 else \ 223 else \
226 retval = change_position_v20 (servo, value, degrees, \ 224 retval = change_position_v20(servo, value, degrees, \
227 minutes); \ 225 minutes); \
228 \ 226 \
229 return retval < 0 ? retval : count; \ 227 return retval < 0 ? retval : count; \
230} \ 228} \
231 \ 229 \
232static ssize_t show_servo##value (struct device *dev, struct device_attribute *attr, char *buf) \ 230static ssize_t show_servo##value (struct device *dev, \
231 struct device_attribute *attr, \
232 char *buf) \
233{ \ 233{ \
234 struct usb_interface *intf = to_usb_interface (dev); \ 234 struct phidget_servo *servo = dev_get_drvdata(dev); \
235 struct phidget_servo *servo = usb_get_intfdata (intf); \
236 \ 235 \
237 return sprintf (buf, "%d.%02d\n", servo->degrees[value], \ 236 return sprintf(buf, "%d.%02d\n", servo->degrees[value], \
238 servo->minutes[value]); \ 237 servo->minutes[value]); \
239} \ 238}
240static DEVICE_ATTR(servo##value, S_IWUGO | S_IRUGO, \
241 show_servo##value, set_servo##value);
242 239
240#define servo_attr(value) \
241 __ATTR(servo##value, S_IWUGO | S_IRUGO, \
242 show_servo##value, set_servo##value)
243show_set(0); 243show_set(0);
244show_set(1); 244show_set(1);
245show_set(2); 245show_set(2);
246show_set(3); 246show_set(3);
247 247
248static struct device_attribute dev_attrs[] = {
249 servo_attr(0), servo_attr(1), servo_attr(2), servo_attr(3)
250};
251
248static int 252static int
249servo_probe(struct usb_interface *interface, const struct usb_device_id *id) 253servo_probe(struct usb_interface *interface, const struct usb_device_id *id)
250{ 254{
251 struct usb_device *udev = interface_to_usbdev(interface); 255 struct usb_device *udev = interface_to_usbdev(interface);
252 struct phidget_servo *dev; 256 struct phidget_servo *dev;
257 int bit, value, rc;
258 int servo_count, i;
253 259
254 dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL); 260 dev = kzalloc(sizeof (struct phidget_servo), GFP_KERNEL);
255 if (dev == NULL) { 261 if (dev == NULL) {
256 dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__); 262 dev_err(&interface->dev, "%s - out of memory\n", __FUNCTION__);
257 return -ENOMEM; 263 rc = -ENOMEM;
264 goto out;
258 } 265 }
259 266
260 dev->udev = usb_get_dev(udev); 267 dev->udev = usb_get_dev(udev);
261 dev->type = id->driver_info; 268 dev->type = id->driver_info;
269 dev->dev_no = -1;
262 usb_set_intfdata(interface, dev); 270 usb_set_intfdata(interface, dev);
263 271
264 device_create_file(&interface->dev, &dev_attr_servo0); 272 do {
265 if (dev->type & SERVO_COUNT_QUAD) { 273 bit = find_first_zero_bit(&device_no, sizeof(device_no));
266 device_create_file(&interface->dev, &dev_attr_servo1); 274 value = test_and_set_bit(bit, &device_no);
267 device_create_file(&interface->dev, &dev_attr_servo2); 275 } while (value);
268 device_create_file(&interface->dev, &dev_attr_servo3); 276 dev->dev_no = bit;
277
278 dev->dev = device_create(phidget_class, &dev->udev->dev, 0,
279 "servo%d", dev->dev_no);
280 if (IS_ERR(dev->dev)) {
281 rc = PTR_ERR(dev->dev);
282 dev->dev = NULL;
283 goto out;
284 }
285
286 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
287
288 for (i=0; i<servo_count; i++) {
289 rc = device_create_file(dev->dev, &dev_attrs[i]);
290 if (rc)
291 goto out2;
269 } 292 }
270 293
271 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 attached\n", 294 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 attached\n",
272 dev->type & SERVO_COUNT_QUAD ? 4 : 1, 295 servo_count, dev->type & SERVO_VERSION_30 ? 3 : 2);
273 dev->type & SERVO_VERSION_30 ? 3 : 2);
274 296
275 if(!(dev->type & SERVO_VERSION_30)) 297 if (!(dev->type & SERVO_VERSION_30))
276 dev_info(&interface->dev, 298 dev_info(&interface->dev,
277 "WARNING: v2.0 not tested! Please report if it works.\n"); 299 "WARNING: v2.0 not tested! Please report if it works.\n");
278 300
279 return 0; 301 return 0;
302out2:
303 while (i-- > 0)
304 device_remove_file(dev->dev, &dev_attrs[i]);
305out:
306 if (dev) {
307 if (dev->dev)
308 device_unregister(dev->dev);
309 if (dev->dev_no >= 0)
310 clear_bit(dev->dev_no, &device_no);
311
312 kfree(dev);
313 }
314
315 return rc;
280} 316}
281 317
282static void 318static void
283servo_disconnect(struct usb_interface *interface) 319servo_disconnect(struct usb_interface *interface)
284{ 320{
285 struct phidget_servo *dev; 321 struct phidget_servo *dev;
322 int servo_count, i;
286 323
287 dev = usb_get_intfdata(interface); 324 dev = usb_get_intfdata(interface);
288 usb_set_intfdata(interface, NULL); 325 usb_set_intfdata(interface, NULL);
289 326
290 device_remove_file(&interface->dev, &dev_attr_servo0); 327 if (!dev)
291 if (dev->type & SERVO_COUNT_QUAD) { 328 return;
292 device_remove_file(&interface->dev, &dev_attr_servo1); 329
293 device_remove_file(&interface->dev, &dev_attr_servo2); 330 servo_count = dev->type & SERVO_COUNT_QUAD ? 4 : 1;
294 device_remove_file(&interface->dev, &dev_attr_servo3); 331
295 } 332 for (i=0; i<servo_count; i++)
333 device_remove_file(dev->dev, &dev_attrs[i]);
296 334
335 device_unregister(dev->dev);
297 usb_put_dev(dev->udev); 336 usb_put_dev(dev->udev);
298 337
299 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 detached\n", 338 dev_info(&interface->dev, "USB %d-Motor PhidgetServo v%d.0 detached\n",
300 dev->type & SERVO_COUNT_QUAD ? 4 : 1, 339 servo_count, dev->type & SERVO_VERSION_30 ? 3 : 2);
301 dev->type & SERVO_VERSION_30 ? 3 : 2);
302 340
341 clear_bit(dev->dev_no, &device_no);
303 kfree(dev); 342 kfree(dev);
304} 343}
305 344
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index e16582f3733c..a44124c7e851 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3179,7 +3179,7 @@ sisusb_compat_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
3179} 3179}
3180#endif 3180#endif
3181 3181
3182static struct file_operations usb_sisusb_fops = { 3182static const struct file_operations usb_sisusb_fops = {
3183 .owner = THIS_MODULE, 3183 .owner = THIS_MODULE,
3184 .open = sisusb_open, 3184 .open = sisusb_open,
3185 .release = sisusb_release, 3185 .release = sisusb_release,
diff --git a/drivers/usb/misc/usb_u132.h b/drivers/usb/misc/usb_u132.h
new file mode 100644
index 000000000000..551ba8906d62
--- /dev/null
+++ b/drivers/usb/misc/usb_u132.h
@@ -0,0 +1,97 @@
1/*
2* Common Header File for the Elan Digital Systems U132 adapter
3* this file should be included by both the "ftdi-u132" and
4* the "u132-hcd" modules.
5*
6* Copyright(C) 2006 Elan Digital Systems Limited
7*(http://www.elandigitalsystems.com)
8*
9* Author and Maintainer - Tony Olech - Elan Digital Systems
10*(tony.olech@elandigitalsystems.com)
11*
12* This program is free software;you can redistribute it and/or
13* modify it under the terms of the GNU General Public License as
14* published by the Free Software Foundation, version 2.
15*
16*
17* The driver was written by Tony Olech(tony.olech@elandigitalsystems.com)
18* based on various USB client drivers in the 2.6.15 linux kernel
19* with constant reference to the 3rd Edition of Linux Device Drivers
20* published by O'Reilly
21*
22* The U132 adapter is a USB to CardBus adapter specifically designed
23* for PC cards that contain an OHCI host controller. Typical PC cards
24* are the Orange Mobile 3G Option GlobeTrotter Fusion card.
25*
26* The U132 adapter will *NOT *work with PC cards that do not contain
27* an OHCI controller. A simple way to test whether a PC card has an
28* OHCI controller as an interface is to insert the PC card directly
29* into a laptop(or desktop) with a CardBus slot and if "lspci" shows
30* a new USB controller and "lsusb -v" shows a new OHCI Host Controller
31* then there is a good chance that the U132 adapter will support the
32* PC card.(you also need the specific client driver for the PC card)
33*
34* Please inform the Author and Maintainer about any PC cards that
35* contain OHCI Host Controller and work when directly connected to
36* an embedded CardBus slot but do not work when they are connected
37* via an ELAN U132 adapter.
38*
39* The driver consists of two modules, the "ftdi-u132" module is
40* a USB client driver that interfaces to the FTDI chip within
41* the U132 adapter manufactured by Elan Digital Systems, and the
42* "u132-hcd" module is a USB host controller driver that talks
43* to the OHCI controller within CardBus card that are inserted
44* in the U132 adapter.
45*
46* The "ftdi-u132" module should be loaded automatically by the
47* hot plug system when the U132 adapter is plugged in. The module
48* initialises the adapter which mostly consists of synchronising
49* the FTDI chip, before continuously polling the adapter to detect
50* PC card insertions. As soon as a PC card containing a recognised
51* OHCI controller is seen the "ftdi-u132" module explicitly requests
52* the kernel to load the "u132-hcd" module.
53*
54* The "ftdi-u132" module provides the interface to the inserted
55* PC card and the "u132-hcd" module uses the API to send and recieve
56* data. The API features call-backs, so that part of the "u132-hcd"
57* module code will run in the context of one of the kernel threads
58* of the "ftdi-u132" module.
59*
60*/
61int ftdi_elan_switch_on_diagnostics(int number);
62void ftdi_elan_gone_away(struct platform_device *pdev);
63void start_usb_lock_device_tracing(void);
64struct u132_platform_data {
65 u16 vendor;
66 u16 device;
67 u8 potpg;
68 void (*port_power) (struct device *dev, int is_on);
69 void (*reset) (struct device *dev);
70};
71int usb_ftdi_elan_edset_single(struct platform_device *pdev, u8 ed_number,
72 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
73 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
74 int toggle_bits, int error_count, int condition_code, int repeat_number,
75 int halted, int skipped, int actual, int non_null));
76int usb_ftdi_elan_edset_output(struct platform_device *pdev, u8 ed_number,
77 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
78 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
79 int toggle_bits, int error_count, int condition_code, int repeat_number,
80 int halted, int skipped, int actual, int non_null));
81int usb_ftdi_elan_edset_empty(struct platform_device *pdev, u8 ed_number,
82 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
83 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
84 int toggle_bits, int error_count, int condition_code, int repeat_number,
85 int halted, int skipped, int actual, int non_null));
86int usb_ftdi_elan_edset_input(struct platform_device *pdev, u8 ed_number,
87 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
88 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
89 int toggle_bits, int error_count, int condition_code, int repeat_number,
90 int halted, int skipped, int actual, int non_null));
91int usb_ftdi_elan_edset_setup(struct platform_device *pdev, u8 ed_number,
92 void *endp, struct urb *urb, u8 address, u8 ep_number, u8 toggle_bits,
93 void (*callback) (void *endp, struct urb *urb, u8 *buf, int len,
94 int toggle_bits, int error_count, int condition_code, int repeat_number,
95 int halted, int skipped, int actual, int non_null));
96int usb_ftdi_elan_edset_flush(struct platform_device *pdev, u8 ed_number,
97 void *endp);
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index e095772dd8e9..dbaca9f1efad 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -239,7 +239,7 @@ error:
239 return retval; 239 return retval;
240} 240}
241 241
242static struct file_operations lcd_fops = { 242static const struct file_operations lcd_fops = {
243 .owner = THIS_MODULE, 243 .owner = THIS_MODULE,
244 .read = lcd_read, 244 .read = lcd_read,
245 .write = lcd_write, 245 .write = lcd_write,
@@ -290,9 +290,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id
290 endpoint = &iface_desc->endpoint[i].desc; 290 endpoint = &iface_desc->endpoint[i].desc;
291 291
292 if (!dev->bulk_in_endpointAddr && 292 if (!dev->bulk_in_endpointAddr &&
293 (endpoint->bEndpointAddress & USB_DIR_IN) && 293 usb_endpoint_is_bulk_in(endpoint)) {
294 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
295 == USB_ENDPOINT_XFER_BULK)) {
296 /* we found a bulk in endpoint */ 294 /* we found a bulk in endpoint */
297 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 295 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
298 dev->bulk_in_size = buffer_size; 296 dev->bulk_in_size = buffer_size;
@@ -305,9 +303,7 @@ static int lcd_probe(struct usb_interface *interface, const struct usb_device_id
305 } 303 }
306 304
307 if (!dev->bulk_out_endpointAddr && 305 if (!dev->bulk_out_endpointAddr &&
308 !(endpoint->bEndpointAddress & USB_DIR_IN) && 306 usb_endpoint_is_bulk_out(endpoint)) {
309 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
310 == USB_ENDPOINT_XFER_BULK)) {
311 /* we found a bulk out endpoint */ 307 /* we found a bulk out endpoint */
312 dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; 308 dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;
313 } 309 }
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 0c5ee0ad6bb9..49c5c5c4c431 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -108,22 +108,34 @@ static int led_probe(struct usb_interface *interface, const struct usb_device_id
108 dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL); 108 dev = kzalloc(sizeof(struct usb_led), GFP_KERNEL);
109 if (dev == NULL) { 109 if (dev == NULL) {
110 dev_err(&interface->dev, "Out of memory\n"); 110 dev_err(&interface->dev, "Out of memory\n");
111 goto error; 111 goto error_mem;
112 } 112 }
113 113
114 dev->udev = usb_get_dev(udev); 114 dev->udev = usb_get_dev(udev);
115 115
116 usb_set_intfdata (interface, dev); 116 usb_set_intfdata (interface, dev);
117 117
118 device_create_file(&interface->dev, &dev_attr_blue); 118 retval = device_create_file(&interface->dev, &dev_attr_blue);
119 device_create_file(&interface->dev, &dev_attr_red); 119 if (retval)
120 device_create_file(&interface->dev, &dev_attr_green); 120 goto error;
121 retval = device_create_file(&interface->dev, &dev_attr_red);
122 if (retval)
123 goto error;
124 retval = device_create_file(&interface->dev, &dev_attr_green);
125 if (retval)
126 goto error;
121 127
122 dev_info(&interface->dev, "USB LED device now attached\n"); 128 dev_info(&interface->dev, "USB LED device now attached\n");
123 return 0; 129 return 0;
124 130
125error: 131error:
132 device_remove_file(&interface->dev, &dev_attr_blue);
133 device_remove_file(&interface->dev, &dev_attr_red);
134 device_remove_file(&interface->dev, &dev_attr_green);
135 usb_set_intfdata (interface, NULL);
136 usb_put_dev(dev->udev);
126 kfree(dev); 137 kfree(dev);
138error_mem:
127 return retval; 139 return retval;
128} 140}
129 141
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index 275a66f83058..394bbf2f68d4 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -265,7 +265,6 @@ static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus)
265 ubus->mon_bus = NULL; 265 ubus->mon_bus = NULL;
266 mbus->u_bus = NULL; 266 mbus->u_bus = NULL;
267 mb(); 267 mb();
268 // usb_bus_put(ubus);
269} 268}
270 269
271/* 270/*
@@ -297,12 +296,12 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus)
297 INIT_LIST_HEAD(&mbus->r_list); 296 INIT_LIST_HEAD(&mbus->r_list);
298 297
299 /* 298 /*
300 * This usb_bus_get here is superfluous, because we receive 299 * We don't need to take a reference to ubus, because we receive
301 * a notification if usb_bus is about to be removed. 300 * a notification if the bus is about to be removed.
302 */ 301 */
303 // usb_bus_get(ubus);
304 mbus->u_bus = ubus; 302 mbus->u_bus = ubus;
305 ubus->mon_bus = mbus; 303 ubus->mon_bus = mbus;
304 mbus->uses_dma = ubus->uses_dma;
306 305
307 rc = snprintf(name, NAMESZ, "%dt", ubus->busnum); 306 rc = snprintf(name, NAMESZ, "%dt", ubus->busnum);
308 if (rc <= 0 || rc >= NAMESZ) 307 if (rc <= 0 || rc >= NAMESZ)
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 1fe01d994a79..f6d1491256c4 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -28,7 +28,7 @@ static int mon_stat_open(struct inode *inode, struct file *file)
28 if ((sp = kmalloc(sizeof(struct snap), GFP_KERNEL)) == NULL) 28 if ((sp = kmalloc(sizeof(struct snap), GFP_KERNEL)) == NULL)
29 return -ENOMEM; 29 return -ENOMEM;
30 30
31 mbus = inode->u.generic_ip; 31 mbus = inode->i_private;
32 32
33 sp->slen = snprintf(sp->str, STAT_BUF_SIZE, 33 sp->slen = snprintf(sp->str, STAT_BUF_SIZE,
34 "nreaders %d events %u text_lost %u\n", 34 "nreaders %d events %u text_lost %u\n",
@@ -62,7 +62,7 @@ static int mon_stat_release(struct inode *inode, struct file *file)
62 return 0; 62 return 0;
63} 63}
64 64
65struct file_operations mon_fops_stat = { 65const struct file_operations mon_fops_stat = {
66 .owner = THIS_MODULE, 66 .owner = THIS_MODULE,
67 .open = mon_stat_open, 67 .open = mon_stat_open,
68 .llseek = no_llseek, 68 .llseek = no_llseek,
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index f961a770cee2..7a2346c53284 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -75,13 +75,13 @@ static void mon_text_ctor(void *, kmem_cache_t *, unsigned long);
75 */ 75 */
76 76
77static inline char mon_text_get_setup(struct mon_event_text *ep, 77static inline char mon_text_get_setup(struct mon_event_text *ep,
78 struct urb *urb, char ev_type) 78 struct urb *urb, char ev_type, struct mon_bus *mbus)
79{ 79{
80 80
81 if (!usb_pipecontrol(urb->pipe) || ev_type != 'S') 81 if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
82 return '-'; 82 return '-';
83 83
84 if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP) 84 if (mbus->uses_dma && (urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
85 return mon_dmapeek(ep->setup, urb->setup_dma, SETUP_MAX); 85 return mon_dmapeek(ep->setup, urb->setup_dma, SETUP_MAX);
86 if (urb->setup_packet == NULL) 86 if (urb->setup_packet == NULL)
87 return 'Z'; /* '0' would be not as pretty. */ 87 return 'Z'; /* '0' would be not as pretty. */
@@ -91,7 +91,7 @@ static inline char mon_text_get_setup(struct mon_event_text *ep,
91} 91}
92 92
93static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb, 93static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
94 int len, char ev_type) 94 int len, char ev_type, struct mon_bus *mbus)
95{ 95{
96 int pipe = urb->pipe; 96 int pipe = urb->pipe;
97 97
@@ -117,7 +117,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
117 * contain non-NULL garbage in case the upper level promised to 117 * contain non-NULL garbage in case the upper level promised to
118 * set DMA for the HCD. 118 * set DMA for the HCD.
119 */ 119 */
120 if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) 120 if (mbus->uses_dma && (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
121 return mon_dmapeek(ep->data, urb->transfer_dma, len); 121 return mon_dmapeek(ep->data, urb->transfer_dma, len);
122 122
123 if (urb->transfer_buffer == NULL) 123 if (urb->transfer_buffer == NULL)
@@ -161,8 +161,9 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
161 /* Collecting status makes debugging sense for submits, too */ 161 /* Collecting status makes debugging sense for submits, too */
162 ep->status = urb->status; 162 ep->status = urb->status;
163 163
164 ep->setup_flag = mon_text_get_setup(ep, urb, ev_type); 164 ep->setup_flag = mon_text_get_setup(ep, urb, ev_type, rp->r.m_bus);
165 ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type); 165 ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type,
166 rp->r.m_bus);
166 167
167 rp->nevents++; 168 rp->nevents++;
168 list_add_tail(&ep->e_link, &rp->e_list); 169 list_add_tail(&ep->e_link, &rp->e_list);
@@ -238,7 +239,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
238 int rc; 239 int rc;
239 240
240 mutex_lock(&mon_lock); 241 mutex_lock(&mon_lock);
241 mbus = inode->u.generic_ip; 242 mbus = inode->i_private;
242 ubus = mbus->u_bus; 243 ubus = mbus->u_bus;
243 244
244 rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL); 245 rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
@@ -401,7 +402,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
401 struct mon_event_text *ep; 402 struct mon_event_text *ep;
402 403
403 mutex_lock(&mon_lock); 404 mutex_lock(&mon_lock);
404 mbus = inode->u.generic_ip; 405 mbus = inode->i_private;
405 406
406 if (mbus->nreaders <= 0) { 407 if (mbus->nreaders <= 0) {
407 printk(KERN_ERR TAG ": consistency error on close\n"); 408 printk(KERN_ERR TAG ": consistency error on close\n");
@@ -435,7 +436,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
435 return 0; 436 return 0;
436} 437}
437 438
438struct file_operations mon_fops_text = { 439const struct file_operations mon_fops_text = {
439 .owner = THIS_MODULE, 440 .owner = THIS_MODULE,
440 .open = mon_text_open, 441 .open = mon_text_open,
441 .llseek = no_llseek, 442 .llseek = no_llseek,
diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h
index 33678c24ebee..ab9d02d5df77 100644
--- a/drivers/usb/mon/usb_mon.h
+++ b/drivers/usb/mon/usb_mon.h
@@ -20,6 +20,7 @@ struct mon_bus {
20 struct dentry *dent_s; /* Debugging file */ 20 struct dentry *dent_s; /* Debugging file */
21 struct dentry *dent_t; /* Text interface file */ 21 struct dentry *dent_t; /* Text interface file */
22 struct usb_bus *u_bus; 22 struct usb_bus *u_bus;
23 int uses_dma;
23 24
24 /* Ref */ 25 /* Ref */
25 int nreaders; /* Under mon_lock AND mbus->lock */ 26 int nreaders; /* Under mon_lock AND mbus->lock */
@@ -53,7 +54,7 @@ extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
53 54
54extern struct mutex mon_lock; 55extern struct mutex mon_lock;
55 56
56extern struct file_operations mon_fops_text; 57extern const struct file_operations mon_fops_text;
57extern struct file_operations mon_fops_stat; 58extern const struct file_operations mon_fops_stat;
58 59
59#endif /* __USB_MON_H */ 60#endif /* __USB_MON_H */
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 2e2bbc003e93..9b97aa6384c7 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * ASIX AX8817X based USB 2.0 Ethernet Devices 2 * ASIX AX8817X based USB 2.0 Ethernet Devices
3 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com> 3 * Copyright (C) 2003-2006 David Hollis <dhollis@davehollis.com>
4 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net> 4 * Copyright (C) 2005 Phil Chang <pchang23@sbcglobal.net>
5 * Copyright (C) 2006 James Painter <jamie.painter@iname.com>
5 * Copyright (c) 2002-2003 TiVo Inc. 6 * Copyright (c) 2002-2003 TiVo Inc.
6 * 7 *
7 * This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
@@ -36,6 +37,9 @@
36 37
37#include "usbnet.h" 38#include "usbnet.h"
38 39
40#define DRIVER_VERSION "14-Jun-2006"
41static const char driver_name [] = "asix";
42
39/* ASIX AX8817X based USB 2.0 Ethernet Devices */ 43/* ASIX AX8817X based USB 2.0 Ethernet Devices */
40 44
41#define AX_CMD_SET_SW_MII 0x06 45#define AX_CMD_SET_SW_MII 0x06
@@ -46,23 +50,25 @@
46#define AX_CMD_WRITE_EEPROM 0x0c 50#define AX_CMD_WRITE_EEPROM 0x0c
47#define AX_CMD_WRITE_ENABLE 0x0d 51#define AX_CMD_WRITE_ENABLE 0x0d
48#define AX_CMD_WRITE_DISABLE 0x0e 52#define AX_CMD_WRITE_DISABLE 0x0e
53#define AX_CMD_READ_RX_CTL 0x0f
49#define AX_CMD_WRITE_RX_CTL 0x10 54#define AX_CMD_WRITE_RX_CTL 0x10
50#define AX_CMD_READ_IPG012 0x11 55#define AX_CMD_READ_IPG012 0x11
51#define AX_CMD_WRITE_IPG0 0x12 56#define AX_CMD_WRITE_IPG0 0x12
52#define AX_CMD_WRITE_IPG1 0x13 57#define AX_CMD_WRITE_IPG1 0x13
58#define AX_CMD_READ_NODE_ID 0x13
53#define AX_CMD_WRITE_IPG2 0x14 59#define AX_CMD_WRITE_IPG2 0x14
54#define AX_CMD_WRITE_MULTI_FILTER 0x16 60#define AX_CMD_WRITE_MULTI_FILTER 0x16
55#define AX_CMD_READ_NODE_ID 0x17 61#define AX88172_CMD_READ_NODE_ID 0x17
56#define AX_CMD_READ_PHY_ID 0x19 62#define AX_CMD_READ_PHY_ID 0x19
57#define AX_CMD_READ_MEDIUM_STATUS 0x1a 63#define AX_CMD_READ_MEDIUM_STATUS 0x1a
58#define AX_CMD_WRITE_MEDIUM_MODE 0x1b 64#define AX_CMD_WRITE_MEDIUM_MODE 0x1b
59#define AX_CMD_READ_MONITOR_MODE 0x1c 65#define AX_CMD_READ_MONITOR_MODE 0x1c
60#define AX_CMD_WRITE_MONITOR_MODE 0x1d 66#define AX_CMD_WRITE_MONITOR_MODE 0x1d
67#define AX_CMD_READ_GPIOS 0x1e
61#define AX_CMD_WRITE_GPIOS 0x1f 68#define AX_CMD_WRITE_GPIOS 0x1f
62#define AX_CMD_SW_RESET 0x20 69#define AX_CMD_SW_RESET 0x20
63#define AX_CMD_SW_PHY_STATUS 0x21 70#define AX_CMD_SW_PHY_STATUS 0x21
64#define AX_CMD_SW_PHY_SELECT 0x22 71#define AX_CMD_SW_PHY_SELECT 0x22
65#define AX88772_CMD_READ_NODE_ID 0x13
66 72
67#define AX_MONITOR_MODE 0x01 73#define AX_MONITOR_MODE 0x01
68#define AX_MONITOR_LINK 0x02 74#define AX_MONITOR_LINK 0x02
@@ -70,15 +76,15 @@
70#define AX_MONITOR_HSFS 0x10 76#define AX_MONITOR_HSFS 0x10
71 77
72/* AX88172 Medium Status Register values */ 78/* AX88172 Medium Status Register values */
73#define AX_MEDIUM_FULL_DUPLEX 0x02 79#define AX88172_MEDIUM_FD 0x02
74#define AX_MEDIUM_TX_ABORT_ALLOW 0x04 80#define AX88172_MEDIUM_TX 0x04
75#define AX_MEDIUM_FLOW_CONTROL_EN 0x10 81#define AX88172_MEDIUM_FC 0x10
82#define AX88172_MEDIUM_DEFAULT \
83 ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC )
76 84
77#define AX_MCAST_FILTER_SIZE 8 85#define AX_MCAST_FILTER_SIZE 8
78#define AX_MAX_MCAST 64 86#define AX_MAX_MCAST 64
79 87
80#define AX_EEPROM_LEN 0x40
81
82#define AX_SWRESET_CLEAR 0x00 88#define AX_SWRESET_CLEAR 0x00
83#define AX_SWRESET_RR 0x01 89#define AX_SWRESET_RR 0x01
84#define AX_SWRESET_RT 0x02 90#define AX_SWRESET_RT 0x02
@@ -92,23 +98,78 @@
92#define AX88772_IPG1_DEFAULT 0x0c 98#define AX88772_IPG1_DEFAULT 0x0c
93#define AX88772_IPG2_DEFAULT 0x12 99#define AX88772_IPG2_DEFAULT 0x12
94 100
95#define AX88772_MEDIUM_FULL_DUPLEX 0x0002 101/* AX88772 & AX88178 Medium Mode Register */
96#define AX88772_MEDIUM_RESERVED 0x0004 102#define AX_MEDIUM_PF 0x0080
97#define AX88772_MEDIUM_RX_FC_ENABLE 0x0010 103#define AX_MEDIUM_JFE 0x0040
98#define AX88772_MEDIUM_TX_FC_ENABLE 0x0020 104#define AX_MEDIUM_TFC 0x0020
99#define AX88772_MEDIUM_PAUSE_FORMAT 0x0080 105#define AX_MEDIUM_RFC 0x0010
100#define AX88772_MEDIUM_RX_ENABLE 0x0100 106#define AX_MEDIUM_ENCK 0x0008
101#define AX88772_MEDIUM_100MB 0x0200 107#define AX_MEDIUM_AC 0x0004
102#define AX88772_MEDIUM_DEFAULT \ 108#define AX_MEDIUM_FD 0x0002
103 (AX88772_MEDIUM_FULL_DUPLEX | AX88772_MEDIUM_RX_FC_ENABLE | \ 109#define AX_MEDIUM_GM 0x0001
104 AX88772_MEDIUM_TX_FC_ENABLE | AX88772_MEDIUM_100MB | \ 110#define AX_MEDIUM_SM 0x1000
105 AX88772_MEDIUM_RESERVED | AX88772_MEDIUM_RX_ENABLE ) 111#define AX_MEDIUM_SBP 0x0800
112#define AX_MEDIUM_PS 0x0200
113#define AX_MEDIUM_RE 0x0100
114
115#define AX88178_MEDIUM_DEFAULT \
116 (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \
117 AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \
118 AX_MEDIUM_RE )
106 119
107#define AX_EEPROM_MAGIC 0xdeadbeef 120#define AX88772_MEDIUM_DEFAULT \
121 (AX_MEDIUM_FD | AX_MEDIUM_RFC | \
122 AX_MEDIUM_TFC | AX_MEDIUM_PS | \
123 AX_MEDIUM_AC | AX_MEDIUM_RE )
124
125/* AX88772 & AX88178 RX_CTL values */
126#define AX_RX_CTL_SO 0x0080
127#define AX_RX_CTL_AP 0x0020
128#define AX_RX_CTL_AM 0x0010
129#define AX_RX_CTL_AB 0x0008
130#define AX_RX_CTL_SEP 0x0004
131#define AX_RX_CTL_AMALL 0x0002
132#define AX_RX_CTL_PRO 0x0001
133#define AX_RX_CTL_MFB_2048 0x0000
134#define AX_RX_CTL_MFB_4096 0x0100
135#define AX_RX_CTL_MFB_8192 0x0200
136#define AX_RX_CTL_MFB_16384 0x0300
137
138#define AX_DEFAULT_RX_CTL \
139 (AX_RX_CTL_SO | AX_RX_CTL_AB )
140
141/* GPIO 0 .. 2 toggles */
142#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */
143#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */
144#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */
145#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */
146#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */
147#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */
148#define AX_GPIO_RESERVED 0x40 /* Reserved */
149#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */
150
151#define AX_EEPROM_MAGIC 0xdeadbeef
152#define AX88172_EEPROM_LEN 0x40
153#define AX88772_EEPROM_LEN 0xff
154
155#define PHY_MODE_MARVELL 0x0000
156#define MII_MARVELL_LED_CTRL 0x0018
157#define MII_MARVELL_STATUS 0x001b
158#define MII_MARVELL_CTRL 0x0014
159
160#define MARVELL_LED_MANUAL 0x0019
161
162#define MARVELL_STATUS_HWCFG 0x0004
163
164#define MARVELL_CTRL_TXDELAY 0x0002
165#define MARVELL_CTRL_RXDELAY 0x0080
108 166
109/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ 167/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
110struct asix_data { 168struct asix_data {
111 u8 multi_filter[AX_MCAST_FILTER_SIZE]; 169 u8 multi_filter[AX_MCAST_FILTER_SIZE];
170 u8 phymode;
171 u8 ledmode;
172 u8 eeprom_len;
112}; 173};
113 174
114struct ax88172_int_data { 175struct ax88172_int_data {
@@ -122,6 +183,8 @@ struct ax88172_int_data {
122static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 183static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
123 u16 size, void *data) 184 u16 size, void *data)
124{ 185{
186 devdbg(dev,"asix_read_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
187 cmd, value, index, size);
125 return usb_control_msg( 188 return usb_control_msg(
126 dev->udev, 189 dev->udev,
127 usb_rcvctrlpipe(dev->udev, 0), 190 usb_rcvctrlpipe(dev->udev, 0),
@@ -137,6 +200,8 @@ static int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
137static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 200static int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
138 u16 size, void *data) 201 u16 size, void *data)
139{ 202{
203 devdbg(dev,"asix_write_cmd() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
204 cmd, value, index, size);
140 return usb_control_msg( 205 return usb_control_msg(
141 dev->udev, 206 dev->udev,
142 usb_sndctrlpipe(dev->udev, 0), 207 usb_sndctrlpipe(dev->udev, 0),
@@ -161,12 +226,167 @@ static void asix_async_cmd_callback(struct urb *urb, struct pt_regs *regs)
161 usb_free_urb(urb); 226 usb_free_urb(urb);
162} 227}
163 228
229static void
230asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
231 u16 size, void *data)
232{
233 struct usb_ctrlrequest *req;
234 int status;
235 struct urb *urb;
236
237 devdbg(dev,"asix_write_cmd_async() cmd=0x%02x value=0x%04x index=0x%04x size=%d",
238 cmd, value, index, size);
239 if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) {
240 deverr(dev, "Error allocating URB in write_cmd_async!");
241 return;
242 }
243
244 if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) {
245 deverr(dev, "Failed to allocate memory for control request");
246 usb_free_urb(urb);
247 return;
248 }
249
250 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
251 req->bRequest = cmd;
252 req->wValue = value;
253 req->wIndex = index;
254 req->wLength = size;
255
256 usb_fill_control_urb(urb, dev->udev,
257 usb_sndctrlpipe(dev->udev, 0),
258 (void *)req, data, size,
259 asix_async_cmd_callback, req);
260
261 if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
262 deverr(dev, "Error submitting the control message: status=%d",
263 status);
264 kfree(req);
265 usb_free_urb(urb);
266 }
267}
268
269static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
270{
271 u8 *head;
272 u32 header;
273 char *packet;
274 struct sk_buff *ax_skb;
275 u16 size;
276
277 head = (u8 *) skb->data;
278 memcpy(&header, head, sizeof(header));
279 le32_to_cpus(&header);
280 packet = head + sizeof(header);
281
282 skb_pull(skb, 4);
283
284 while (skb->len > 0) {
285 if ((short)(header & 0x0000ffff) !=
286 ~((short)((header & 0xffff0000) >> 16))) {
287 deverr(dev,"asix_rx_fixup() Bad Header Length");
288 }
289 /* get the packet length */
290 size = (u16) (header & 0x0000ffff);
291
292 if ((skb->len) - ((size + 1) & 0xfffe) == 0)
293 return 2;
294 if (size > ETH_FRAME_LEN) {
295 deverr(dev,"asix_rx_fixup() Bad RX Length %d", size);
296 return 0;
297 }
298 ax_skb = skb_clone(skb, GFP_ATOMIC);
299 if (ax_skb) {
300 ax_skb->len = size;
301 ax_skb->data = packet;
302 ax_skb->tail = packet + size;
303 usbnet_skb_return(dev, ax_skb);
304 } else {
305 return 0;
306 }
307
308 skb_pull(skb, (size + 1) & 0xfffe);
309
310 if (skb->len == 0)
311 break;
312
313 head = (u8 *) skb->data;
314 memcpy(&header, head, sizeof(header));
315 le32_to_cpus(&header);
316 packet = head + sizeof(header);
317 skb_pull(skb, 4);
318 }
319
320 if (skb->len < 0) {
321 deverr(dev,"asix_rx_fixup() Bad SKB Length %d", skb->len);
322 return 0;
323 }
324 return 1;
325}
326
327static struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
328 gfp_t flags)
329{
330 int padlen;
331 int headroom = skb_headroom(skb);
332 int tailroom = skb_tailroom(skb);
333 u32 packet_len;
334 u32 padbytes = 0xffff0000;
335
336 padlen = ((skb->len + 4) % 512) ? 0 : 4;
337
338 if ((!skb_cloned(skb))
339 && ((headroom + tailroom) >= (4 + padlen))) {
340 if ((headroom < 4) || (tailroom < padlen)) {
341 skb->data = memmove(skb->head + 4, skb->data, skb->len);
342 skb->tail = skb->data + skb->len;
343 }
344 } else {
345 struct sk_buff *skb2;
346 skb2 = skb_copy_expand(skb, 4, padlen, flags);
347 dev_kfree_skb_any(skb);
348 skb = skb2;
349 if (!skb)
350 return NULL;
351 }
352
353 skb_push(skb, 4);
354 packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
355 memcpy(skb->data, &packet_len, sizeof(packet_len));
356
357 if ((skb->len % 512) == 0) {
358 memcpy( skb->tail, &padbytes, sizeof(padbytes));
359 skb_put(skb, sizeof(padbytes));
360 }
361 return skb;
362}
363
364static void asix_status(struct usbnet *dev, struct urb *urb)
365{
366 struct ax88172_int_data *event;
367 int link;
368
369 if (urb->actual_length < 8)
370 return;
371
372 event = urb->transfer_buffer;
373 link = event->link & 0x01;
374 if (netif_carrier_ok(dev->net) != link) {
375 if (link) {
376 netif_carrier_on(dev->net);
377 usbnet_defer_kevent (dev, EVENT_LINK_RESET );
378 } else
379 netif_carrier_off(dev->net);
380 devdbg(dev, "Link Status is: %d", link);
381 }
382}
383
164static inline int asix_set_sw_mii(struct usbnet *dev) 384static inline int asix_set_sw_mii(struct usbnet *dev)
165{ 385{
166 int ret; 386 int ret;
167 ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); 387 ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
168 if (ret < 0) 388 if (ret < 0)
169 devdbg(dev, "Failed to enable software MII access"); 389 deverr(dev, "Failed to enable software MII access");
170 return ret; 390 return ret;
171} 391}
172 392
@@ -175,24 +395,27 @@ static inline int asix_set_hw_mii(struct usbnet *dev)
175 int ret; 395 int ret;
176 ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); 396 ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
177 if (ret < 0) 397 if (ret < 0)
178 devdbg(dev, "Failed to enable hardware MII access"); 398 deverr(dev, "Failed to enable hardware MII access");
179 return ret; 399 return ret;
180} 400}
181 401
182static inline int asix_get_phyid(struct usbnet *dev) 402static inline int asix_get_phy_addr(struct usbnet *dev)
183{ 403{
184 int ret = 0; 404 int ret = 0;
185 void *buf; 405 void *buf;
186 406
407 devdbg(dev, "asix_get_phy_addr()");
408
187 buf = kmalloc(2, GFP_KERNEL); 409 buf = kmalloc(2, GFP_KERNEL);
188 if (!buf) 410 if (!buf)
189 goto out1; 411 goto out1;
190 412
191 if ((ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 413 if ((ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID,
192 0, 0, 2, buf)) < 2) { 414 0, 0, 2, buf)) < 2) {
193 devdbg(dev, "Error reading PHYID register: %02x", ret); 415 deverr(dev, "Error reading PHYID register: %02x", ret);
194 goto out2; 416 goto out2;
195 } 417 }
418 devdbg(dev, "asix_get_phy_addr() returning 0x%04x", *((u16 *)buf));
196 ret = *((u8 *)buf + 1); 419 ret = *((u8 *)buf + 1);
197out2: 420out2:
198 kfree(buf); 421 kfree(buf);
@@ -206,8 +429,29 @@ static int asix_sw_reset(struct usbnet *dev, u8 flags)
206 429
207 ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); 430 ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL);
208 if (ret < 0) 431 if (ret < 0)
209 devdbg(dev,"Failed to send software reset: %02x", ret); 432 deverr(dev,"Failed to send software reset: %02x", ret);
433
434 return ret;
435}
436
437static u16 asix_read_rx_ctl(struct usbnet *dev)
438{
439 u16 ret = 0;
440 void *buf;
441
442 buf = kmalloc(2, GFP_KERNEL);
443 if (!buf)
444 goto out1;
210 445
446 if ((ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL,
447 0, 0, 2, buf)) < 2) {
448 deverr(dev, "Error reading RX_CTL register: %02x", ret);
449 goto out2;
450 }
451 ret = le16_to_cpu(*((u16 *)buf));
452out2:
453 kfree(buf);
454out1:
211 return ret; 455 return ret;
212} 456}
213 457
@@ -215,82 +459,79 @@ static int asix_write_rx_ctl(struct usbnet *dev, u16 mode)
215{ 459{
216 int ret; 460 int ret;
217 461
462 devdbg(dev,"asix_write_rx_ctl() - mode = 0x%04x", mode);
218 ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); 463 ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
219 if (ret < 0) 464 if (ret < 0)
220 devdbg(dev, "Failed to write RX_CTL mode: %02x", ret); 465 deverr(dev, "Failed to write RX_CTL mode to 0x%04x: %02x",
466 mode, ret);
221 467
222 return ret; 468 return ret;
223} 469}
224 470
225static void asix_status(struct usbnet *dev, struct urb *urb) 471static u16 asix_read_medium_status(struct usbnet *dev)
226{ 472{
227 struct ax88172_int_data *event; 473 u16 ret = 0;
228 int link; 474 void *buf;
229 475
230 if (urb->actual_length < 8) 476 buf = kmalloc(2, GFP_KERNEL);
231 return; 477 if (!buf)
478 goto out1;
232 479
233 event = urb->transfer_buffer; 480 if ((ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS,
234 link = event->link & 0x01; 481 0, 0, 2, buf)) < 2) {
235 if (netif_carrier_ok(dev->net) != link) { 482 deverr(dev, "Error reading Medium Status register: %02x", ret);
236 if (link) { 483 goto out2;
237 netif_carrier_on(dev->net);
238 usbnet_defer_kevent (dev, EVENT_LINK_RESET );
239 } else
240 netif_carrier_off(dev->net);
241 devdbg(dev, "Link Status is: %d", link);
242 } 484 }
485 ret = le16_to_cpu(*((u16 *)buf));
486out2:
487 kfree(buf);
488out1:
489 return ret;
243} 490}
244 491
245static void 492static int asix_write_medium_mode(struct usbnet *dev, u16 mode)
246asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
247 u16 size, void *data)
248{ 493{
249 struct usb_ctrlrequest *req; 494 int ret;
250 int status;
251 struct urb *urb;
252 495
253 if ((urb = usb_alloc_urb(0, GFP_ATOMIC)) == NULL) { 496 devdbg(dev,"asix_write_medium_mode() - mode = 0x%04x", mode);
254 devdbg(dev, "Error allocating URB in write_cmd_async!"); 497 ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
255 return; 498 if (ret < 0)
256 } 499 deverr(dev, "Failed to write Medium Mode mode to 0x%04x: %02x",
500 mode, ret);
257 501
258 if ((req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC)) == NULL) { 502 return ret;
259 deverr(dev, "Failed to allocate memory for control request"); 503}
260 usb_free_urb(urb);
261 return;
262 }
263 504
264 req->bRequestType = USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE; 505static int asix_write_gpio(struct usbnet *dev, u16 value, int sleep)
265 req->bRequest = cmd; 506{
266 req->wValue = cpu_to_le16(value); 507 int ret;
267 req->wIndex = cpu_to_le16(index);
268 req->wLength = cpu_to_le16(size);
269 508
270 usb_fill_control_urb(urb, dev->udev, 509 devdbg(dev,"asix_write_gpio() - value = 0x%04x", value);
271 usb_sndctrlpipe(dev->udev, 0), 510 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL);
272 (void *)req, data, size, 511 if (ret < 0)
273 asix_async_cmd_callback, req); 512 deverr(dev, "Failed to write GPIO value 0x%04x: %02x",
513 value, ret);
274 514
275 if((status = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { 515 if (sleep)
276 deverr(dev, "Error submitting the control message: status=%d", 516 msleep(sleep);
277 status); 517
278 kfree(req); 518 return ret;
279 usb_free_urb(urb);
280 }
281} 519}
282 520
521/*
522 * AX88772 & AX88178 have a 16-bit RX_CTL value
523 */
283static void asix_set_multicast(struct net_device *net) 524static void asix_set_multicast(struct net_device *net)
284{ 525{
285 struct usbnet *dev = netdev_priv(net); 526 struct usbnet *dev = netdev_priv(net);
286 struct asix_data *data = (struct asix_data *)&dev->data; 527 struct asix_data *data = (struct asix_data *)&dev->data;
287 u8 rx_ctl = 0x8c; 528 u16 rx_ctl = AX_DEFAULT_RX_CTL;
288 529
289 if (net->flags & IFF_PROMISC) { 530 if (net->flags & IFF_PROMISC) {
290 rx_ctl |= 0x01; 531 rx_ctl |= AX_RX_CTL_PRO;
291 } else if (net->flags & IFF_ALLMULTI 532 } else if (net->flags & IFF_ALLMULTI
292 || net->mc_count > AX_MAX_MCAST) { 533 || net->mc_count > AX_MAX_MCAST) {
293 rx_ctl |= 0x02; 534 rx_ctl |= AX_RX_CTL_AMALL;
294 } else if (net->mc_count == 0) { 535 } else if (net->mc_count == 0) {
295 /* just broadcast and directed */ 536 /* just broadcast and directed */
296 } else { 537 } else {
@@ -317,7 +558,7 @@ static void asix_set_multicast(struct net_device *net)
317 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, 558 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
318 AX_MCAST_FILTER_SIZE, data->multi_filter); 559 AX_MCAST_FILTER_SIZE, data->multi_filter);
319 560
320 rx_ctl |= 0x10; 561 rx_ctl |= AX_RX_CTL_AM;
321 } 562 }
322 563
323 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); 564 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
@@ -333,50 +574,43 @@ static int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
333 (__u16)loc, 2, (u16 *)&res); 574 (__u16)loc, 2, (u16 *)&res);
334 asix_set_hw_mii(dev); 575 asix_set_hw_mii(dev);
335 576
336 return res & 0xffff; 577 devdbg(dev, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x", phy_id, loc, le16_to_cpu(res & 0xffff));
337}
338 578
339/* same as above, but converts resulting value to cpu byte order */ 579 return le16_to_cpu(res & 0xffff);
340static int asix_mdio_read_le(struct net_device *netdev, int phy_id, int loc)
341{
342 return le16_to_cpu(asix_mdio_read(netdev,phy_id, loc));
343} 580}
344 581
345static void 582static void
346asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) 583asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
347{ 584{
348 struct usbnet *dev = netdev_priv(netdev); 585 struct usbnet *dev = netdev_priv(netdev);
349 u16 res = val; 586 u16 res = cpu_to_le16(val);
350 587
588 devdbg(dev, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x", phy_id, loc, val);
351 asix_set_sw_mii(dev); 589 asix_set_sw_mii(dev);
352 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 590 asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id,
353 (__u16)loc, 2, (u16 *)&res); 591 (__u16)loc, 2, (u16 *)&res);
354 asix_set_hw_mii(dev); 592 asix_set_hw_mii(dev);
355} 593}
356 594
357/* same as above, but converts new value to le16 byte order before writing */ 595/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
358static void 596static u32 asix_get_phyid(struct usbnet *dev)
359asix_mdio_write_le(struct net_device *netdev, int phy_id, int loc, int val)
360{ 597{
361 asix_mdio_write( netdev, phy_id, loc, cpu_to_le16(val) ); 598 int phy_reg;
362} 599 u32 phy_id;
363 600
364static int ax88172_link_reset(struct usbnet *dev) 601 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
365{ 602 if (phy_reg < 0)
366 u16 lpa; 603 return 0;
367 u16 adv;
368 u16 res;
369 u8 mode;
370 604
371 mode = AX_MEDIUM_TX_ABORT_ALLOW | AX_MEDIUM_FLOW_CONTROL_EN; 605 phy_id = (phy_reg & 0xffff) << 16;
372 lpa = asix_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA);
373 adv = asix_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE);
374 res = mii_nway_result(lpa|adv);
375 if (res & LPA_DUPLEX)
376 mode |= AX_MEDIUM_FULL_DUPLEX;
377 asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
378 606
379 return 0; 607 phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
608 if (phy_reg < 0)
609 return 0;
610
611 phy_id |= (phy_reg & 0xffff);
612
613 return phy_id;
380} 614}
381 615
382static void 616static void
@@ -423,7 +657,10 @@ asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
423 657
424static int asix_get_eeprom_len(struct net_device *net) 658static int asix_get_eeprom_len(struct net_device *net)
425{ 659{
426 return AX_EEPROM_LEN; 660 struct usbnet *dev = netdev_priv(net);
661 struct asix_data *data = (struct asix_data *)&dev->data;
662
663 return data->eeprom_len;
427} 664}
428 665
429static int asix_get_eeprom(struct net_device *net, 666static int asix_get_eeprom(struct net_device *net,
@@ -453,9 +690,14 @@ static int asix_get_eeprom(struct net_device *net,
453static void asix_get_drvinfo (struct net_device *net, 690static void asix_get_drvinfo (struct net_device *net,
454 struct ethtool_drvinfo *info) 691 struct ethtool_drvinfo *info)
455{ 692{
693 struct usbnet *dev = netdev_priv(net);
694 struct asix_data *data = (struct asix_data *)&dev->data;
695
456 /* Inherit standard device info */ 696 /* Inherit standard device info */
457 usbnet_get_drvinfo(net, info); 697 usbnet_get_drvinfo(net, info);
458 info->eedump_len = 0x3e; 698 strncpy (info->driver, driver_name, sizeof info->driver);
699 strncpy (info->version, DRIVER_VERSION, sizeof info->version);
700 info->eedump_len = data->eeprom_len;
459} 701}
460 702
461static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd) 703static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
@@ -468,8 +710,34 @@ static int asix_get_settings(struct net_device *net, struct ethtool_cmd *cmd)
468static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd) 710static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
469{ 711{
470 struct usbnet *dev = netdev_priv(net); 712 struct usbnet *dev = netdev_priv(net);
713 int res = mii_ethtool_sset(&dev->mii,cmd);
714
715 /* link speed/duplex might have changed */
716 if (dev->driver_info->link_reset)
717 dev->driver_info->link_reset(dev);
718
719 return res;
720}
721
722static int asix_nway_reset(struct net_device *net)
723{
724 struct usbnet *dev = netdev_priv(net);
725
726 return mii_nway_restart(&dev->mii);
727}
728
729static u32 asix_get_link(struct net_device *net)
730{
731 struct usbnet *dev = netdev_priv(net);
471 732
472 return mii_ethtool_sset(&dev->mii,cmd); 733 return mii_link_ok(&dev->mii);
734}
735
736static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
737{
738 struct usbnet *dev = netdev_priv(net);
739
740 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
473} 741}
474 742
475/* We need to override some ethtool_ops so we require our 743/* We need to override some ethtool_ops so we require our
@@ -477,7 +745,8 @@ static int asix_set_settings(struct net_device *net, struct ethtool_cmd *cmd)
477 devices that may be connected at the same time. */ 745 devices that may be connected at the same time. */
478static struct ethtool_ops ax88172_ethtool_ops = { 746static struct ethtool_ops ax88172_ethtool_ops = {
479 .get_drvinfo = asix_get_drvinfo, 747 .get_drvinfo = asix_get_drvinfo,
480 .get_link = ethtool_op_get_link, 748 .get_link = asix_get_link,
749 .nway_reset = asix_nway_reset,
481 .get_msglevel = usbnet_get_msglevel, 750 .get_msglevel = usbnet_get_msglevel,
482 .set_msglevel = usbnet_set_msglevel, 751 .set_msglevel = usbnet_set_msglevel,
483 .get_wol = asix_get_wol, 752 .get_wol = asix_get_wol,
@@ -488,11 +757,66 @@ static struct ethtool_ops ax88172_ethtool_ops = {
488 .set_settings = asix_set_settings, 757 .set_settings = asix_set_settings,
489}; 758};
490 759
491static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) 760static void ax88172_set_multicast(struct net_device *net)
492{ 761{
493 struct usbnet *dev = netdev_priv(net); 762 struct usbnet *dev = netdev_priv(net);
763 struct asix_data *data = (struct asix_data *)&dev->data;
764 u8 rx_ctl = 0x8c;
494 765
495 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); 766 if (net->flags & IFF_PROMISC) {
767 rx_ctl |= 0x01;
768 } else if (net->flags & IFF_ALLMULTI
769 || net->mc_count > AX_MAX_MCAST) {
770 rx_ctl |= 0x02;
771 } else if (net->mc_count == 0) {
772 /* just broadcast and directed */
773 } else {
774 /* We use the 20 byte dev->data
775 * for our 8 byte filter buffer
776 * to avoid allocating memory that
777 * is tricky to free later */
778 struct dev_mc_list *mc_list = net->mc_list;
779 u32 crc_bits;
780 int i;
781
782 memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE);
783
784 /* Build the multicast hash filter. */
785 for (i = 0; i < net->mc_count; i++) {
786 crc_bits =
787 ether_crc(ETH_ALEN,
788 mc_list->dmi_addr) >> 26;
789 data->multi_filter[crc_bits >> 3] |=
790 1 << (crc_bits & 7);
791 mc_list = mc_list->next;
792 }
793
794 asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0,
795 AX_MCAST_FILTER_SIZE, data->multi_filter);
796
797 rx_ctl |= 0x10;
798 }
799
800 asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
801}
802
803static int ax88172_link_reset(struct usbnet *dev)
804{
805 u8 mode;
806 struct ethtool_cmd ecmd;
807
808 mii_check_media(&dev->mii, 1, 1);
809 mii_ethtool_gset(&dev->mii, &ecmd);
810 mode = AX88172_MEDIUM_DEFAULT;
811
812 if (ecmd.duplex != DUPLEX_FULL)
813 mode |= ~AX88172_MEDIUM_FD;
814
815 devdbg(dev, "ax88172_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
816
817 asix_write_medium_mode(dev, mode);
818
819 return 0;
496} 820}
497 821
498static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) 822static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
@@ -501,6 +825,9 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
501 void *buf; 825 void *buf;
502 int i; 826 int i;
503 unsigned long gpio_bits = dev->driver_info->data; 827 unsigned long gpio_bits = dev->driver_info->data;
828 struct asix_data *data = (struct asix_data *)&dev->data;
829
830 data->eeprom_len = AX88172_EEPROM_LEN;
504 831
505 usbnet_get_endpoints(dev,intf); 832 usbnet_get_endpoints(dev,intf);
506 833
@@ -519,12 +846,12 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
519 msleep(5); 846 msleep(5);
520 } 847 }
521 848
522 if ((ret = asix_write_rx_ctl(dev,0x80)) < 0) 849 if ((ret = asix_write_rx_ctl(dev, 0x80)) < 0)
523 goto out2; 850 goto out2;
524 851
525 /* Get the MAC address */ 852 /* Get the MAC address */
526 memset(buf, 0, ETH_ALEN); 853 memset(buf, 0, ETH_ALEN);
527 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 854 if ((ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID,
528 0, 0, 6, buf)) < 0) { 855 0, 0, 6, buf)) < 0) {
529 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret); 856 dbg("read AX_CMD_READ_NODE_ID failed: %d", ret);
530 goto out2; 857 goto out2;
@@ -537,14 +864,14 @@ static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf)
537 dev->mii.mdio_write = asix_mdio_write; 864 dev->mii.mdio_write = asix_mdio_write;
538 dev->mii.phy_id_mask = 0x3f; 865 dev->mii.phy_id_mask = 0x3f;
539 dev->mii.reg_num_mask = 0x1f; 866 dev->mii.reg_num_mask = 0x1f;
540 dev->mii.phy_id = asix_get_phyid(dev); 867 dev->mii.phy_id = asix_get_phy_addr(dev);
541 dev->net->do_ioctl = asix_ioctl; 868 dev->net->do_ioctl = asix_ioctl;
542 869
543 dev->net->set_multicast_list = asix_set_multicast; 870 dev->net->set_multicast_list = ax88172_set_multicast;
544 dev->net->ethtool_ops = &ax88172_ethtool_ops; 871 dev->net->ethtool_ops = &ax88172_ethtool_ops;
545 872
546 asix_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); 873 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
547 asix_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE, 874 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
548 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); 875 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
549 mii_nway_restart(&dev->mii); 876 mii_nway_restart(&dev->mii);
550 877
@@ -557,7 +884,8 @@ out1:
557 884
558static struct ethtool_ops ax88772_ethtool_ops = { 885static struct ethtool_ops ax88772_ethtool_ops = {
559 .get_drvinfo = asix_get_drvinfo, 886 .get_drvinfo = asix_get_drvinfo,
560 .get_link = ethtool_op_get_link, 887 .get_link = asix_get_link,
888 .nway_reset = asix_nway_reset,
561 .get_msglevel = usbnet_get_msglevel, 889 .get_msglevel = usbnet_get_msglevel,
562 .set_msglevel = usbnet_set_msglevel, 890 .set_msglevel = usbnet_set_msglevel,
563 .get_wol = asix_get_wol, 891 .get_wol = asix_get_wol,
@@ -568,10 +896,37 @@ static struct ethtool_ops ax88772_ethtool_ops = {
568 .set_settings = asix_set_settings, 896 .set_settings = asix_set_settings,
569}; 897};
570 898
899static int ax88772_link_reset(struct usbnet *dev)
900{
901 u16 mode;
902 struct ethtool_cmd ecmd;
903
904 mii_check_media(&dev->mii, 1, 1);
905 mii_ethtool_gset(&dev->mii, &ecmd);
906 mode = AX88772_MEDIUM_DEFAULT;
907
908 if (ecmd.speed != SPEED_100)
909 mode &= ~AX_MEDIUM_PS;
910
911 if (ecmd.duplex != DUPLEX_FULL)
912 mode &= ~AX_MEDIUM_FD;
913
914 devdbg(dev, "ax88772_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
915
916 asix_write_medium_mode(dev, mode);
917
918 return 0;
919}
920
571static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) 921static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
572{ 922{
573 int ret; 923 int ret;
574 void *buf; 924 void *buf;
925 u16 rx_ctl;
926 struct asix_data *data = (struct asix_data *)&dev->data;
927 u32 phyid;
928
929 data->eeprom_len = AX88772_EEPROM_LEN;
575 930
576 usbnet_get_endpoints(dev,intf); 931 usbnet_get_endpoints(dev,intf);
577 932
@@ -582,13 +937,12 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
582 goto out1; 937 goto out1;
583 } 938 }
584 939
585 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, 940 if ((ret = asix_write_gpio(dev,
586 0x00B0, 0, 0, buf)) < 0) 941 AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5)) < 0)
587 goto out2; 942 goto out2;
588 943
589 msleep(5);
590 if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 944 if ((ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT,
591 0x0001, 0, 0, buf)) < 0) { 945 0x0000, 0, 0, buf)) < 0) {
592 dbg("Select PHY #1 failed: %d", ret); 946 dbg("Select PHY #1 failed: %d", ret);
593 goto out2; 947 goto out2;
594 } 948 }
@@ -605,36 +959,34 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
605 goto out2; 959 goto out2;
606 960
607 msleep(150); 961 msleep(150);
608 if ((ret = asix_write_rx_ctl(dev, 0x00)) < 0) 962 rx_ctl = asix_read_rx_ctl(dev);
963 dbg("RX_CTL is 0x%04x after software reset", rx_ctl);
964 if ((ret = asix_write_rx_ctl(dev, 0x0000)) < 0)
609 goto out2; 965 goto out2;
610 966
967 rx_ctl = asix_read_rx_ctl(dev);
968 dbg("RX_CTL is 0x%04x setting to 0x0000", rx_ctl);
969
611 /* Get the MAC address */ 970 /* Get the MAC address */
612 memset(buf, 0, ETH_ALEN); 971 memset(buf, 0, ETH_ALEN);
613 if ((ret = asix_read_cmd(dev, AX88772_CMD_READ_NODE_ID, 972 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
614 0, 0, ETH_ALEN, buf)) < 0) { 973 0, 0, ETH_ALEN, buf)) < 0) {
615 dbg("Failed to read MAC address: %d", ret); 974 dbg("Failed to read MAC address: %d", ret);
616 goto out2; 975 goto out2;
617 } 976 }
618 memcpy(dev->net->dev_addr, buf, ETH_ALEN); 977 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
619 978
620 if ((ret = asix_set_sw_mii(dev)) < 0)
621 goto out2;
622
623 if (((ret = asix_read_cmd(dev, AX_CMD_READ_MII_REG,
624 0x0010, 2, 2, buf)) < 0)
625 || (*((u16 *)buf) != 0x003b)) {
626 dbg("Read PHY register 2 must be 0x3b00: %d", ret);
627 goto out2;
628 }
629
630 /* Initialize MII structure */ 979 /* Initialize MII structure */
631 dev->mii.dev = dev->net; 980 dev->mii.dev = dev->net;
632 dev->mii.mdio_read = asix_mdio_read; 981 dev->mii.mdio_read = asix_mdio_read;
633 dev->mii.mdio_write = asix_mdio_write; 982 dev->mii.mdio_write = asix_mdio_write;
634 dev->mii.phy_id_mask = 0xff; 983 dev->mii.phy_id_mask = 0x1f;
635 dev->mii.reg_num_mask = 0xff; 984 dev->mii.reg_num_mask = 0x1f;
636 dev->net->do_ioctl = asix_ioctl; 985 dev->net->do_ioctl = asix_ioctl;
637 dev->mii.phy_id = asix_get_phyid(dev); 986 dev->mii.phy_id = asix_get_phy_addr(dev);
987
988 phyid = asix_get_phyid(dev);
989 dbg("PHYID=0x%08x", phyid);
638 990
639 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0) 991 if ((ret = asix_sw_reset(dev, AX_SWRESET_PRL)) < 0)
640 goto out2; 992 goto out2;
@@ -649,16 +1001,13 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
649 dev->net->set_multicast_list = asix_set_multicast; 1001 dev->net->set_multicast_list = asix_set_multicast;
650 dev->net->ethtool_ops = &ax88772_ethtool_ops; 1002 dev->net->ethtool_ops = &ax88772_ethtool_ops;
651 1003
652 asix_mdio_write_le(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); 1004 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
653 asix_mdio_write_le(dev->net, dev->mii.phy_id, MII_ADVERTISE, 1005 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
654 ADVERTISE_ALL | ADVERTISE_CSMA); 1006 ADVERTISE_ALL | ADVERTISE_CSMA);
655 mii_nway_restart(&dev->mii); 1007 mii_nway_restart(&dev->mii);
656 1008
657 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, 1009 if ((ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT)) < 0)
658 AX88772_MEDIUM_DEFAULT, 0, 0, buf)) < 0) {
659 dbg("Write medium mode register: %d", ret);
660 goto out2; 1010 goto out2;
661 }
662 1011
663 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, 1012 if ((ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0,
664 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 1013 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT,
@@ -666,13 +1015,17 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
666 dbg("Write IPG,IPG1,IPG2 failed: %d", ret); 1015 dbg("Write IPG,IPG1,IPG2 failed: %d", ret);
667 goto out2; 1016 goto out2;
668 } 1017 }
669 if ((ret = asix_set_hw_mii(dev)) < 0)
670 goto out2;
671 1018
672 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 1019 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
673 if ((ret = asix_write_rx_ctl(dev, 0x0088)) < 0) 1020 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
674 goto out2; 1021 goto out2;
675 1022
1023 rx_ctl = asix_read_rx_ctl(dev);
1024 dbg("RX_CTL is 0x%04x after all initializations", rx_ctl);
1025
1026 rx_ctl = asix_read_medium_status(dev);
1027 dbg("Medium Status is 0x%04x after all initializations", rx_ctl);
1028
676 kfree(buf); 1029 kfree(buf);
677 1030
678 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ 1031 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
@@ -690,120 +1043,285 @@ out1:
690 return ret; 1043 return ret;
691} 1044}
692 1045
693static int ax88772_rx_fixup(struct usbnet *dev, struct sk_buff *skb) 1046static struct ethtool_ops ax88178_ethtool_ops = {
1047 .get_drvinfo = asix_get_drvinfo,
1048 .get_link = asix_get_link,
1049 .nway_reset = asix_nway_reset,
1050 .get_msglevel = usbnet_get_msglevel,
1051 .set_msglevel = usbnet_set_msglevel,
1052 .get_wol = asix_get_wol,
1053 .set_wol = asix_set_wol,
1054 .get_eeprom_len = asix_get_eeprom_len,
1055 .get_eeprom = asix_get_eeprom,
1056 .get_settings = asix_get_settings,
1057 .set_settings = asix_set_settings,
1058};
1059
1060static int marvell_phy_init(struct usbnet *dev)
694{ 1061{
695 u8 *head; 1062 struct asix_data *data = (struct asix_data *)&dev->data;
696 u32 header; 1063 u16 reg;
697 char *packet;
698 struct sk_buff *ax_skb;
699 u16 size;
700 1064
701 head = (u8 *) skb->data; 1065 devdbg(dev,"marvell_phy_init()");
702 memcpy(&header, head, sizeof(header));
703 le32_to_cpus(&header);
704 packet = head + sizeof(header);
705 1066
706 skb_pull(skb, 4); 1067 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS);
1068 devdbg(dev,"MII_MARVELL_STATUS = 0x%04x", reg);
707 1069
708 while (skb->len > 0) { 1070 asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL,
709 if ((short)(header & 0x0000ffff) != 1071 MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY);
710 ~((short)((header & 0xffff0000) >> 16))) {
711 devdbg(dev,"header length data is error");
712 }
713 /* get the packet length */
714 size = (u16) (header & 0x0000ffff);
715 1072
716 if ((skb->len) - ((size + 1) & 0xfffe) == 0) 1073 if (data->ledmode) {
717 return 2; 1074 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
718 if (size > ETH_FRAME_LEN) { 1075 MII_MARVELL_LED_CTRL);
719 devdbg(dev,"invalid rx length %d", size); 1076 devdbg(dev,"MII_MARVELL_LED_CTRL (1) = 0x%04x", reg);
720 return 0;
721 }
722 ax_skb = skb_clone(skb, GFP_ATOMIC);
723 if (ax_skb) {
724 ax_skb->len = size;
725 ax_skb->data = packet;
726 ax_skb->tail = packet + size;
727 usbnet_skb_return(dev, ax_skb);
728 } else {
729 return 0;
730 }
731 1077
732 skb_pull(skb, (size + 1) & 0xfffe); 1078 reg &= 0xf8ff;
1079 reg |= (1 + 0x0100);
1080 asix_mdio_write(dev->net, dev->mii.phy_id,
1081 MII_MARVELL_LED_CTRL, reg);
733 1082
734 if (skb->len == 0) 1083 reg = asix_mdio_read(dev->net, dev->mii.phy_id,
735 break; 1084 MII_MARVELL_LED_CTRL);
1085 devdbg(dev,"MII_MARVELL_LED_CTRL (2) = 0x%04x", reg);
1086 reg &= 0xfc0f;
1087 }
736 1088
737 head = (u8 *) skb->data; 1089 return 0;
738 memcpy(&header, head, sizeof(header)); 1090}
739 le32_to_cpus(&header); 1091
740 packet = head + sizeof(header); 1092static int marvell_led_status(struct usbnet *dev, u16 speed)
741 skb_pull(skb, 4); 1093{
1094 u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL);
1095
1096 devdbg(dev, "marvell_led_status() read 0x%04x", reg);
1097
1098 /* Clear out the center LED bits - 0x03F0 */
1099 reg &= 0xfc0f;
1100
1101 switch (speed) {
1102 case SPEED_1000:
1103 reg |= 0x03e0;
1104 break;
1105 case SPEED_100:
1106 reg |= 0x03b0;
1107 break;
1108 default:
1109 reg |= 0x02f0;
742 } 1110 }
743 1111
744 if (skb->len < 0) { 1112 devdbg(dev, "marvell_led_status() writing 0x%04x", reg);
745 devdbg(dev,"invalid rx length %d", skb->len); 1113 asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg);
746 return 0; 1114
1115 return 0;
1116}
1117
1118static int ax88178_link_reset(struct usbnet *dev)
1119{
1120 u16 mode;
1121 struct ethtool_cmd ecmd;
1122 struct asix_data *data = (struct asix_data *)&dev->data;
1123
1124 devdbg(dev,"ax88178_link_reset()");
1125
1126 mii_check_media(&dev->mii, 1, 1);
1127 mii_ethtool_gset(&dev->mii, &ecmd);
1128 mode = AX88178_MEDIUM_DEFAULT;
1129
1130 if (ecmd.speed == SPEED_1000)
1131 mode |= AX_MEDIUM_GM | AX_MEDIUM_ENCK;
1132 else if (ecmd.speed == SPEED_100)
1133 mode |= AX_MEDIUM_PS;
1134 else
1135 mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM);
1136
1137 if (ecmd.duplex == DUPLEX_FULL)
1138 mode |= AX_MEDIUM_FD;
1139 else
1140 mode &= ~AX_MEDIUM_FD;
1141
1142 devdbg(dev, "ax88178_link_reset() speed: %d duplex: %d setting mode to 0x%04x", ecmd.speed, ecmd.duplex, mode);
1143
1144 asix_write_medium_mode(dev, mode);
1145
1146 if (data->phymode == PHY_MODE_MARVELL && data->ledmode)
1147 marvell_led_status(dev, ecmd.speed);
1148
1149 return 0;
1150}
1151
1152static void ax88178_set_mfb(struct usbnet *dev)
1153{
1154 u16 mfb = AX_RX_CTL_MFB_16384;
1155 u16 rxctl;
1156 u16 medium;
1157 int old_rx_urb_size = dev->rx_urb_size;
1158
1159 if (dev->hard_mtu < 2048) {
1160 dev->rx_urb_size = 2048;
1161 mfb = AX_RX_CTL_MFB_2048;
1162 } else if (dev->hard_mtu < 4096) {
1163 dev->rx_urb_size = 4096;
1164 mfb = AX_RX_CTL_MFB_4096;
1165 } else if (dev->hard_mtu < 8192) {
1166 dev->rx_urb_size = 8192;
1167 mfb = AX_RX_CTL_MFB_8192;
1168 } else if (dev->hard_mtu < 16384) {
1169 dev->rx_urb_size = 16384;
1170 mfb = AX_RX_CTL_MFB_16384;
747 } 1171 }
748 return 1; 1172
1173 rxctl = asix_read_rx_ctl(dev);
1174 asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb);
1175
1176 medium = asix_read_medium_status(dev);
1177 if (dev->net->mtu > 1500)
1178 medium |= AX_MEDIUM_JFE;
1179 else
1180 medium &= ~AX_MEDIUM_JFE;
1181 asix_write_medium_mode(dev, medium);
1182
1183 if (dev->rx_urb_size > old_rx_urb_size)
1184 usbnet_unlink_rx_urbs(dev);
749} 1185}
750 1186
751static struct sk_buff *ax88772_tx_fixup(struct usbnet *dev, struct sk_buff *skb, 1187static int ax88178_change_mtu(struct net_device *net, int new_mtu)
752 gfp_t flags)
753{ 1188{
754 int padlen; 1189 struct usbnet *dev = netdev_priv(net);
755 int headroom = skb_headroom(skb); 1190 int ll_mtu = new_mtu + net->hard_header_len + 4;
756 int tailroom = skb_tailroom(skb);
757 u32 packet_len;
758 u32 padbytes = 0xffff0000;
759 1191
760 padlen = ((skb->len + 4) % 512) ? 0 : 4; 1192 devdbg(dev, "ax88178_change_mtu() new_mtu=%d", new_mtu);
761 1193
762 if ((!skb_cloned(skb)) 1194 if (new_mtu <= 0 || ll_mtu > 16384)
763 && ((headroom + tailroom) >= (4 + padlen))) { 1195 return -EINVAL;
764 if ((headroom < 4) || (tailroom < padlen)) { 1196
765 skb->data = memmove(skb->head + 4, skb->data, skb->len); 1197 if ((ll_mtu % dev->maxpacket) == 0)
766 skb->tail = skb->data + skb->len; 1198 return -EDOM;
767 } 1199
1200 net->mtu = new_mtu;
1201 dev->hard_mtu = net->mtu + net->hard_header_len;
1202 ax88178_set_mfb(dev);
1203
1204 return 0;
1205}
1206
1207static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf)
1208{
1209 struct asix_data *data = (struct asix_data *)&dev->data;
1210 int ret;
1211 void *buf;
1212 u16 eeprom;
1213 int gpio0 = 0;
1214 u32 phyid;
1215
1216 usbnet_get_endpoints(dev,intf);
1217
1218 buf = kmalloc(6, GFP_KERNEL);
1219 if(!buf) {
1220 dbg ("Cannot allocate memory for buffer");
1221 ret = -ENOMEM;
1222 goto out1;
1223 }
1224
1225 eeprom = 0;
1226 asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &eeprom);
1227 dbg("GPIO Status: 0x%04x", eeprom);
1228
1229 asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL);
1230 asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom);
1231 asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL);
1232
1233 dbg("EEPROM index 0x17 is 0x%04x", eeprom);
1234
1235 if (eeprom == 0xffff) {
1236 data->phymode = PHY_MODE_MARVELL;
1237 data->ledmode = 0;
1238 gpio0 = 1;
768 } else { 1239 } else {
769 struct sk_buff *skb2; 1240 data->phymode = eeprom & 7;
770 skb2 = skb_copy_expand(skb, 4, padlen, flags); 1241 data->ledmode = eeprom >> 8;
771 dev_kfree_skb_any(skb); 1242 gpio0 = (eeprom & 0x80) ? 0 : 1;
772 skb = skb2;
773 if (!skb)
774 return NULL;
775 } 1243 }
1244 dbg("GPIO0: %d, PhyMode: %d", gpio0, data->phymode);
776 1245
777 skb_push(skb, 4); 1246 asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40);
778 packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4); 1247 if ((eeprom >> 8) != 1) {
779 memcpy(skb->data, &packet_len, sizeof(packet_len)); 1248 asix_write_gpio(dev, 0x003c, 30);
1249 asix_write_gpio(dev, 0x001c, 300);
1250 asix_write_gpio(dev, 0x003c, 30);
1251 } else {
1252 dbg("gpio phymode == 1 path");
1253 asix_write_gpio(dev, AX_GPIO_GPO1EN, 30);
1254 asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30);
1255 }
780 1256
781 if ((skb->len % 512) == 0) { 1257 asix_sw_reset(dev, 0);
782 memcpy( skb->tail, &padbytes, sizeof(padbytes)); 1258 msleep(150);
783 skb_put(skb, sizeof(padbytes)); 1259
1260 asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD);
1261 msleep(150);
1262
1263 asix_write_rx_ctl(dev, 0);
1264
1265 /* Get the MAC address */
1266 memset(buf, 0, ETH_ALEN);
1267 if ((ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID,
1268 0, 0, ETH_ALEN, buf)) < 0) {
1269 dbg("Failed to read MAC address: %d", ret);
1270 goto out2;
784 } 1271 }
785 return skb; 1272 memcpy(dev->net->dev_addr, buf, ETH_ALEN);
786}
787 1273
788static int ax88772_link_reset(struct usbnet *dev) 1274 /* Initialize MII structure */
789{ 1275 dev->mii.dev = dev->net;
790 u16 lpa; 1276 dev->mii.mdio_read = asix_mdio_read;
791 u16 adv; 1277 dev->mii.mdio_write = asix_mdio_write;
792 u16 res; 1278 dev->mii.phy_id_mask = 0x1f;
793 u16 mode; 1279 dev->mii.reg_num_mask = 0xff;
1280 dev->mii.supports_gmii = 1;
1281 dev->net->do_ioctl = asix_ioctl;
1282 dev->mii.phy_id = asix_get_phy_addr(dev);
1283 dev->net->set_multicast_list = asix_set_multicast;
1284 dev->net->ethtool_ops = &ax88178_ethtool_ops;
1285 dev->net->change_mtu = &ax88178_change_mtu;
794 1286
795 mode = AX88772_MEDIUM_DEFAULT; 1287 phyid = asix_get_phyid(dev);
796 lpa = asix_mdio_read_le(dev->net, dev->mii.phy_id, MII_LPA); 1288 dbg("PHYID=0x%08x", phyid);
797 adv = asix_mdio_read_le(dev->net, dev->mii.phy_id, MII_ADVERTISE); 1289
798 res = mii_nway_result(lpa|adv); 1290 if (data->phymode == PHY_MODE_MARVELL) {
1291 marvell_phy_init(dev);
1292 msleep(60);
1293 }
1294
1295 asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR,
1296 BMCR_RESET | BMCR_ANENABLE);
1297 asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
1298 ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP);
1299 asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000,
1300 ADVERTISE_1000FULL);
1301
1302 mii_nway_restart(&dev->mii);
799 1303
800 if ((res & LPA_DUPLEX) == 0) 1304 if ((ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT)) < 0)
801 mode &= ~AX88772_MEDIUM_FULL_DUPLEX; 1305 goto out2;
802 if ((res & LPA_100) == 0) 1306
803 mode &= ~AX88772_MEDIUM_100MB; 1307 if ((ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL)) < 0)
804 asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); 1308 goto out2;
1309
1310 kfree(buf);
1311
1312 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */
1313 if (dev->driver_info->flags & FLAG_FRAMING_AX) {
1314 /* hard_mtu is still the default - the device does not support
1315 jumbo eth frames */
1316 dev->rx_urb_size = 2048;
1317 }
805 1318
806 return 0; 1319 return 0;
1320
1321out2:
1322 kfree(buf);
1323out1:
1324 return ret;
807} 1325}
808 1326
809static const struct driver_info ax8817x_info = { 1327static const struct driver_info ax8817x_info = {
@@ -853,8 +1371,19 @@ static const struct driver_info ax88772_info = {
853 .link_reset = ax88772_link_reset, 1371 .link_reset = ax88772_link_reset,
854 .reset = ax88772_link_reset, 1372 .reset = ax88772_link_reset,
855 .flags = FLAG_ETHER | FLAG_FRAMING_AX, 1373 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
856 .rx_fixup = ax88772_rx_fixup, 1374 .rx_fixup = asix_rx_fixup,
857 .tx_fixup = ax88772_tx_fixup, 1375 .tx_fixup = asix_tx_fixup,
1376};
1377
1378static const struct driver_info ax88178_info = {
1379 .description = "ASIX AX88178 USB 2.0 Ethernet",
1380 .bind = ax88178_bind,
1381 .status = asix_status,
1382 .link_reset = ax88178_link_reset,
1383 .reset = ax88178_link_reset,
1384 .flags = FLAG_ETHER | FLAG_FRAMING_AX,
1385 .rx_fixup = asix_rx_fixup,
1386 .tx_fixup = asix_tx_fixup,
858}; 1387};
859 1388
860static const struct usb_device_id products [] = { 1389static const struct usb_device_id products [] = {
@@ -913,7 +1442,7 @@ static const struct usb_device_id products [] = {
913}, { 1442}, {
914 // ASIX AX88178 10/100/1000 1443 // ASIX AX88178 10/100/1000
915 USB_DEVICE (0x0b95, 0x1780), 1444 USB_DEVICE (0x0b95, 0x1780),
916 .driver_info = (unsigned long) &ax88772_info, 1445 .driver_info = (unsigned long) &ax88178_info,
917}, { 1446}, {
918 // Linksys USB200M Rev 2 1447 // Linksys USB200M Rev 2
919 USB_DEVICE (0x13b1, 0x0018), 1448 USB_DEVICE (0x13b1, 0x0018),
@@ -922,6 +1451,14 @@ static const struct usb_device_id products [] = {
922 // 0Q0 cable ethernet 1451 // 0Q0 cable ethernet
923 USB_DEVICE (0x1557, 0x7720), 1452 USB_DEVICE (0x1557, 0x7720),
924 .driver_info = (unsigned long) &ax88772_info, 1453 .driver_info = (unsigned long) &ax88772_info,
1454}, {
1455 // DLink DUB-E100 H/W Ver B1
1456 USB_DEVICE (0x07d1, 0x3c05),
1457 .driver_info = (unsigned long) &ax88772_info,
1458}, {
1459 // Linksys USB1000
1460 USB_DEVICE (0x1737, 0x0039),
1461 .driver_info = (unsigned long) &ax88178_info,
925}, 1462},
926 { }, // END 1463 { }, // END
927}; 1464};
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index a9b6eeac3e3f..301baa72bac7 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -498,25 +498,24 @@ static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
498static struct sk_buff * 498static struct sk_buff *
499net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) 499net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
500{ 500{
501 int padlen;
502 struct sk_buff *skb2; 501 struct sk_buff *skb2;
503 struct nc_header *header = NULL; 502 struct nc_header *header = NULL;
504 struct nc_trailer *trailer = NULL; 503 struct nc_trailer *trailer = NULL;
504 int padlen = sizeof (struct nc_trailer);
505 int len = skb->len; 505 int len = skb->len;
506 506
507 padlen = ((len + sizeof (struct nc_header) 507 if (!((len + padlen + sizeof (struct nc_header)) & 0x01))
508 + sizeof (struct nc_trailer)) & 0x01) ? 0 : 1; 508 padlen++;
509 if (!skb_cloned(skb)) { 509 if (!skb_cloned(skb)) {
510 int headroom = skb_headroom(skb); 510 int headroom = skb_headroom(skb);
511 int tailroom = skb_tailroom(skb); 511 int tailroom = skb_tailroom(skb);
512 512
513 if ((padlen + sizeof (struct nc_trailer)) <= tailroom 513 if (padlen <= tailroom &&
514 && sizeof (struct nc_header) <= headroom) 514 sizeof(struct nc_header) <= headroom)
515 /* There's enough head and tail room */ 515 /* There's enough head and tail room */
516 goto encapsulate; 516 goto encapsulate;
517 517
518 if ((sizeof (struct nc_header) + padlen 518 if ((sizeof (struct nc_header) + padlen) <
519 + sizeof (struct nc_trailer)) <
520 (headroom + tailroom)) { 519 (headroom + tailroom)) {
521 /* There's enough total room, so just readjust */ 520 /* There's enough total room, so just readjust */
522 skb->data = memmove(skb->head 521 skb->data = memmove(skb->head
@@ -530,7 +529,7 @@ net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
530 /* Create a new skb to use with the correct size */ 529 /* Create a new skb to use with the correct size */
531 skb2 = skb_copy_expand(skb, 530 skb2 = skb_copy_expand(skb,
532 sizeof (struct nc_header), 531 sizeof (struct nc_header),
533 sizeof (struct nc_trailer) + padlen, 532 padlen,
534 flags); 533 flags);
535 dev_kfree_skb_any(skb); 534 dev_kfree_skb_any(skb);
536 if (!skb2) 535 if (!skb2)
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index ab21f960d255..b8e25af13f02 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -619,7 +619,7 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs)
619 switch (urb->status) { 619 switch (urb->status) {
620 case 0: 620 case 0:
621 break; 621 break;
622 case -ETIMEDOUT: 622 case -ETIME:
623 if (netif_msg_rx_err(pegasus)) 623 if (netif_msg_rx_err(pegasus))
624 pr_debug("%s: reset MAC\n", net->name); 624 pr_debug("%s: reset MAC\n", net->name);
625 pegasus->flags &= ~PEGASUS_RX_BUSY; 625 pegasus->flags &= ~PEGASUS_RX_BUSY;
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index a72685b96061..2364c2099387 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -438,7 +438,7 @@ static void read_bulk_callback(struct urb *urb, struct pt_regs *regs)
438 break; 438 break;
439 case -ENOENT: 439 case -ENOENT:
440 return; /* the urb is in unlink state */ 440 return; /* the urb is in unlink state */
441 case -ETIMEDOUT: 441 case -ETIME:
442 warn("may be reset is needed?.."); 442 warn("may be reset is needed?..");
443 goto goon; 443 goto goon;
444 default: 444 default:
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 54183e173a6d..98a522f1e264 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -61,8 +61,11 @@
61 * let the USB host controller be busy for 5msec or more before an irq 61 * let the USB host controller be busy for 5msec or more before an irq
62 * is required, under load. Jumbograms change the equation. 62 * is required, under load. Jumbograms change the equation.
63 */ 63 */
64#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) 64#define RX_MAX_QUEUE_MEMORY (60 * 1518)
65#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? 60 : 4) 65#define RX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
66 (RX_MAX_QUEUE_MEMORY/(dev)->rx_urb_size) : 4)
67#define TX_QLEN(dev) (((dev)->udev->speed == USB_SPEED_HIGH) ? \
68 (RX_MAX_QUEUE_MEMORY/(dev)->hard_mtu) : 4)
66 69
67// reawaken network queue this soon after stopping; else watchdog barks 70// reawaken network queue this soon after stopping; else watchdog barks
68#define TX_TIMEOUT_JIFFIES (5*HZ) 71#define TX_TIMEOUT_JIFFIES (5*HZ)
@@ -227,13 +230,23 @@ static int usbnet_change_mtu (struct net_device *net, int new_mtu)
227{ 230{
228 struct usbnet *dev = netdev_priv(net); 231 struct usbnet *dev = netdev_priv(net);
229 int ll_mtu = new_mtu + net->hard_header_len; 232 int ll_mtu = new_mtu + net->hard_header_len;
233 int old_hard_mtu = dev->hard_mtu;
234 int old_rx_urb_size = dev->rx_urb_size;
230 235
231 if (new_mtu <= 0 || ll_mtu > dev->hard_mtu) 236 if (new_mtu <= 0)
232 return -EINVAL; 237 return -EINVAL;
233 // no second zero-length packet read wanted after mtu-sized packets 238 // no second zero-length packet read wanted after mtu-sized packets
234 if ((ll_mtu % dev->maxpacket) == 0) 239 if ((ll_mtu % dev->maxpacket) == 0)
235 return -EDOM; 240 return -EDOM;
236 net->mtu = new_mtu; 241 net->mtu = new_mtu;
242
243 dev->hard_mtu = net->mtu + net->hard_header_len;
244 if (dev->rx_urb_size == old_hard_mtu) {
245 dev->rx_urb_size = dev->hard_mtu;
246 if (dev->rx_urb_size > old_rx_urb_size)
247 usbnet_unlink_rx_urbs(dev);
248 }
249
237 return 0; 250 return 0;
238} 251}
239 252
@@ -412,9 +425,9 @@ static void rx_complete (struct urb *urb, struct pt_regs *regs)
412 // we get controller i/o faults during khubd disconnect() delays. 425 // we get controller i/o faults during khubd disconnect() delays.
413 // throttle down resubmits, to avoid log floods; just temporarily, 426 // throttle down resubmits, to avoid log floods; just temporarily,
414 // so we still recover when the fault isn't a khubd delay. 427 // so we still recover when the fault isn't a khubd delay.
415 case -EPROTO: // ehci 428 case -EPROTO:
416 case -ETIMEDOUT: // ohci 429 case -ETIME:
417 case -EILSEQ: // uhci 430 case -EILSEQ:
418 dev->stats.rx_errors++; 431 dev->stats.rx_errors++;
419 if (!timer_pending (&dev->delay)) { 432 if (!timer_pending (&dev->delay)) {
420 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES); 433 mod_timer (&dev->delay, jiffies + THROTTLE_JIFFIES);
@@ -521,6 +534,17 @@ static int unlink_urbs (struct usbnet *dev, struct sk_buff_head *q)
521 return count; 534 return count;
522} 535}
523 536
537// Flush all pending rx urbs
538// minidrivers may need to do this when the MTU changes
539
540void usbnet_unlink_rx_urbs(struct usbnet *dev)
541{
542 if (netif_running(dev->net)) {
543 (void) unlink_urbs (dev, &dev->rxq);
544 tasklet_schedule(&dev->bh);
545 }
546}
547EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs);
524 548
525/*-------------------------------------------------------------------------*/ 549/*-------------------------------------------------------------------------*/
526 550
@@ -629,7 +653,7 @@ static int usbnet_open (struct net_device *net)
629 653
630 devinfo (dev, "open: enable queueing " 654 devinfo (dev, "open: enable queueing "
631 "(rx %d, tx %d) mtu %d %s framing", 655 "(rx %d, tx %d) mtu %d %s framing",
632 RX_QLEN (dev), TX_QLEN (dev), dev->net->mtu, 656 (int)RX_QLEN (dev), (int)TX_QLEN (dev), dev->net->mtu,
633 framing); 657 framing);
634 } 658 }
635 659
@@ -797,9 +821,9 @@ static void tx_complete (struct urb *urb, struct pt_regs *regs)
797 821
798 // like rx, tx gets controller i/o faults during khubd delays 822 // like rx, tx gets controller i/o faults during khubd delays
799 // and so it uses the same throttling mechanism. 823 // and so it uses the same throttling mechanism.
800 case -EPROTO: // ehci 824 case -EPROTO:
801 case -ETIMEDOUT: // ohci 825 case -ETIME:
802 case -EILSEQ: // uhci 826 case -EILSEQ:
803 if (!timer_pending (&dev->delay)) { 827 if (!timer_pending (&dev->delay)) {
804 mod_timer (&dev->delay, 828 mod_timer (&dev->delay,
805 jiffies + THROTTLE_JIFFIES); 829 jiffies + THROTTLE_JIFFIES);
diff --git a/drivers/usb/net/usbnet.h b/drivers/usb/net/usbnet.h
index 89fc4958eecf..c0746f0454af 100644
--- a/drivers/usb/net/usbnet.h
+++ b/drivers/usb/net/usbnet.h
@@ -166,6 +166,7 @@ struct skb_data { /* skb->cb is one of these */
166extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *); 166extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
167extern void usbnet_defer_kevent (struct usbnet *, int); 167extern void usbnet_defer_kevent (struct usbnet *, int);
168extern void usbnet_skb_return (struct usbnet *, struct sk_buff *); 168extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
169extern void usbnet_unlink_rx_urbs(struct usbnet *);
169 170
170extern u32 usbnet_get_msglevel (struct net_device *); 171extern u32 usbnet_get_msglevel (struct net_device *);
171extern void usbnet_set_msglevel (struct net_device *, u32); 172extern void usbnet_set_msglevel (struct net_device *, u32);
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index f5b9438c94f0..5076b9d97057 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -53,6 +53,15 @@ config USB_SERIAL_GENERIC
53 support" be compiled as a module for this driver to be used 53 support" be compiled as a module for this driver to be used
54 properly. 54 properly.
55 55
56config USB_SERIAL_AIRCABLE
57 tristate "AIRcable USB Bluetooth Dongle Driver (EXPERIMENTAL)"
58 depends on USB_SERIAL && EXPERIMENTAL
59 help
60 Say Y here if you want to use AIRcable USB Bluetoot Dongle.
61
62 To compile this driver as a module, choose M here: the module
63 will be called aircable.
64
56config USB_SERIAL_AIRPRIME 65config USB_SERIAL_AIRPRIME
57 tristate "USB AirPrime CDMA Wireless Driver" 66 tristate "USB AirPrime CDMA Wireless Driver"
58 depends on USB_SERIAL 67 depends on USB_SERIAL
@@ -413,6 +422,21 @@ config USB_SERIAL_MCT_U232
413 To compile this driver as a module, choose M here: the 422 To compile this driver as a module, choose M here: the
414 module will be called mct_u232. 423 module will be called mct_u232.
415 424
425config USB_SERIAL_MOS7840
426 tristate "USB Moschip 7840/7820 USB Serial Driver"
427 depends on USB_SERIAL
428 ---help---
429 Say Y here if you want to use a MCS7840 Quad-Serial or MCS7820
430 Dual-Serial port device from MosChip Semiconductor.
431
432 The MCS7840 and MCS7820 have been developed to connect a wide range
433 of standard serial devices to a USB host. The MCS7840 has a USB
434 device controller connected to four (4) individual UARTs while the
435 MCS7820 controller connects to two (2) individual UARTs.
436
437 To compile this driver as a module, choose M here: the
438 module will be called mos7840. If unsure, choose N.
439
416config USB_SERIAL_NAVMAN 440config USB_SERIAL_NAVMAN
417 tristate "USB Navman GPS device" 441 tristate "USB Navman GPS device"
418 depends on USB_SERIAL 442 depends on USB_SERIAL
@@ -526,5 +550,6 @@ config USB_EZUSB
526 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT 550 depends on USB_SERIAL_KEYSPAN_PDA || USB_SERIAL_XIRCOM || USB_SERIAL_KEYSPAN || USB_SERIAL_WHITEHEAT
527 default y 551 default y
528 552
553
529endmenu 554endmenu
530 555
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 8efed2ce1ba3..8dce83340e31 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -11,6 +11,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
11 11
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRCABLE) += aircable.o
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o 15obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
15obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o 16obj-$(CONFIG_USB_SERIAL_ARK3116) += ark3116.o
16obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 17obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
@@ -33,6 +34,7 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
33obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 34obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
34obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 35obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
35obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 36obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
37obj-$(CONFIG_USB_SERIAL_MOS7840) += mos7840.o
36obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o 38obj-$(CONFIG_USB_SERIAL_NAVMAN) += navman.o
37obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 39obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
38obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 40obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
diff --git a/drivers/usb/serial/aircable.c b/drivers/usb/serial/aircable.c
new file mode 100644
index 000000000000..2ccd9ded52a5
--- /dev/null
+++ b/drivers/usb/serial/aircable.c
@@ -0,0 +1,625 @@
1/*
2 * AIRcable USB Bluetooth Dongle Driver.
3 *
4 * Copyright (C) 2006 Manuel Francisco Naranjo (naranjo.manuel@gmail.com)
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License version 2 as published by the
7 * Free Software Foundation.
8 *
9 * The device works as an standard CDC device, it has 2 interfaces, the first
10 * one is for firmware access and the second is the serial one.
11 * The protocol is very simply, there are two posibilities reading or writing.
12 * When writting the first urb must have a Header that starts with 0x20 0x29 the
13 * next two bytes must say how much data will be sended.
14 * When reading the process is almost equal except that the header starts with
15 * 0x00 0x20.
16 *
17 * The device simply need some stuff to understand data comming from the usb
18 * buffer: The First and Second byte is used for a Header, the Third and Fourth
19 * tells the device the amount of information the package holds.
20 * Packages are 60 bytes long Header Stuff.
21 * When writting to the device the first two bytes of the header are 0x20 0x29
22 * When reading the bytes are 0x00 0x20, or 0x00 0x10, there is an strange
23 * situation, when too much data arrives to the device because it sends the data
24 * but with out the header. I will use a simply hack to override this situation,
25 * if there is data coming that does not contain any header, then that is data
26 * that must go directly to the tty, as there is no documentation about if there
27 * is any other control code, I will simply check for the first
28 * one.
29 *
30 * The driver registers himself with the USB-serial core and the USB Core. I had
31 * to implement a probe function agains USB-serial, because other way, the
32 * driver was attaching himself to both interfaces. I have tryed with different
33 * configurations of usb_serial_driver with out exit, only the probe function
34 * could handle this correctly.
35 *
36 * I have taken some info from a Greg Kroah-Hartman article:
37 * http://www.linuxjournal.com/article/6573
38 * And from Linux Device Driver Kit CD, which is a great work, the authors taken
39 * the work to recompile lots of information an knowladge in drivers development
40 * and made it all avaible inside a cd.
41 * URL: http://kernel.org/pub/linux/kernel/people/gregkh/ddk/
42 *
43 */
44
45#include <linux/tty.h>
46#include <linux/tty_flip.h>
47#include <linux/circ_buf.h>
48#include <linux/usb.h>
49#include <linux/usb/serial.h>
50
51static int debug;
52
53/* Vendor and Product ID */
54#define AIRCABLE_VID 0x16CA
55#define AIRCABLE_USB_PID 0x1502
56
57/* write buffer size defines */
58#define AIRCABLE_BUF_SIZE 2048
59
60/* Protocol Stuff */
61#define HCI_HEADER_LENGTH 0x4
62#define TX_HEADER_0 0x20
63#define TX_HEADER_1 0x29
64#define RX_HEADER_0 0x00
65#define RX_HEADER_1 0x20
66#define MAX_HCI_FRAMESIZE 60
67#define HCI_COMPLETE_FRAME 64
68
69/* rx_flags */
70#define THROTTLED 0x01
71#define ACTUALLY_THROTTLED 0x02
72
73/*
74 * Version Information
75 */
76#define DRIVER_VERSION "v1.0b2"
77#define DRIVER_AUTHOR "Naranjo, Manuel Francisco <naranjo.manuel@gmail.com>"
78#define DRIVER_DESC "AIRcable USB Driver"
79
80/* ID table that will be registered with USB core */
81static struct usb_device_id id_table [] = {
82 { USB_DEVICE(AIRCABLE_VID, AIRCABLE_USB_PID) },
83 { },
84};
85MODULE_DEVICE_TABLE(usb, id_table);
86
87
88/* Internal Structure */
89struct aircable_private {
90 spinlock_t rx_lock; /* spinlock for the receive lines */
91 struct circ_buf *tx_buf; /* write buffer */
92 struct circ_buf *rx_buf; /* read buffer */
93 int rx_flags; /* for throttilng */
94 struct work_struct rx_work; /* work cue for the receiving line */
95};
96
97/* Private methods */
98
99/* Circular Buffer Methods, code from ti_usb_3410_5052 used */
100/*
101 * serial_buf_clear
102 *
103 * Clear out all data in the circular buffer.
104 */
105static void serial_buf_clear(struct circ_buf *cb)
106{
107 cb->head = cb->tail = 0;
108}
109
110/*
111 * serial_buf_alloc
112 *
113 * Allocate a circular buffer and all associated memory.
114 */
115static struct circ_buf *serial_buf_alloc(void)
116{
117 struct circ_buf *cb;
118 cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL);
119 if (cb == NULL)
120 return NULL;
121 cb->buf = kmalloc(AIRCABLE_BUF_SIZE, GFP_KERNEL);
122 if (cb->buf == NULL) {
123 kfree(cb);
124 return NULL;
125 }
126 serial_buf_clear(cb);
127 return cb;
128}
129
130/*
131 * serial_buf_free
132 *
133 * Free the buffer and all associated memory.
134 */
135static void serial_buf_free(struct circ_buf *cb)
136{
137 kfree(cb->buf);
138 kfree(cb);
139}
140
141/*
142 * serial_buf_data_avail
143 *
144 * Return the number of bytes of data available in the circular
145 * buffer.
146 */
147static int serial_buf_data_avail(struct circ_buf *cb)
148{
149 return CIRC_CNT(cb->head,cb->tail,AIRCABLE_BUF_SIZE);
150}
151
152/*
153 * serial_buf_put
154 *
155 * Copy data data from a user buffer and put it into the circular buffer.
156 * Restrict to the amount of space available.
157 *
158 * Return the number of bytes copied.
159 */
160static int serial_buf_put(struct circ_buf *cb, const char *buf, int count)
161{
162 int c, ret = 0;
163 while (1) {
164 c = CIRC_SPACE_TO_END(cb->head, cb->tail, AIRCABLE_BUF_SIZE);
165 if (count < c)
166 c = count;
167 if (c <= 0)
168 break;
169 memcpy(cb->buf + cb->head, buf, c);
170 cb->head = (cb->head + c) & (AIRCABLE_BUF_SIZE-1);
171 buf += c;
172 count -= c;
173 ret= c;
174 }
175 return ret;
176}
177
178/*
179 * serial_buf_get
180 *
181 * Get data from the circular buffer and copy to the given buffer.
182 * Restrict to the amount of data available.
183 *
184 * Return the number of bytes copied.
185 */
186static int serial_buf_get(struct circ_buf *cb, char *buf, int count)
187{
188 int c, ret = 0;
189 while (1) {
190 c = CIRC_CNT_TO_END(cb->head, cb->tail, AIRCABLE_BUF_SIZE);
191 if (count < c)
192 c = count;
193 if (c <= 0)
194 break;
195 memcpy(buf, cb->buf + cb->tail, c);
196 cb->tail = (cb->tail + c) & (AIRCABLE_BUF_SIZE-1);
197 buf += c;
198 count -= c;
199 ret= c;
200 }
201 return ret;
202}
203
204/* End of circula buffer methods */
205
206static void aircable_send(struct usb_serial_port *port)
207{
208 int count, result;
209 struct aircable_private *priv = usb_get_serial_port_data(port);
210 unsigned char* buf;
211 dbg("%s - port %d", __FUNCTION__, port->number);
212 if (port->write_urb_busy)
213 return;
214
215 count = min(serial_buf_data_avail(priv->tx_buf), MAX_HCI_FRAMESIZE);
216 if (count == 0)
217 return;
218
219 buf = kzalloc(count + HCI_HEADER_LENGTH, GFP_ATOMIC);
220 if (!buf) {
221 err("%s- kzalloc(%d) failed.", __FUNCTION__,
222 count + HCI_HEADER_LENGTH);
223 return;
224 }
225
226 buf[0] = TX_HEADER_0;
227 buf[1] = TX_HEADER_1;
228 buf[2] = (unsigned char)count;
229 buf[3] = (unsigned char)(count >> 8);
230 serial_buf_get(priv->tx_buf,buf + HCI_HEADER_LENGTH, MAX_HCI_FRAMESIZE);
231
232 memcpy(port->write_urb->transfer_buffer, buf,
233 count + HCI_HEADER_LENGTH);
234
235 kfree(buf);
236 port->write_urb_busy = 1;
237 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
238 count + HCI_HEADER_LENGTH,
239 port->write_urb->transfer_buffer);
240 port->write_urb->transfer_buffer_length = count + HCI_HEADER_LENGTH;
241 port->write_urb->dev = port->serial->dev;
242 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
243
244 if (result) {
245 dev_err(&port->dev,
246 "%s - failed submitting write urb, error %d\n",
247 __FUNCTION__, result);
248 port->write_urb_busy = 0;
249 }
250
251 schedule_work(&port->work);
252}
253
254static void aircable_read(void *params)
255{
256 struct usb_serial_port *port = params;
257 struct aircable_private *priv = usb_get_serial_port_data(port);
258 struct tty_struct *tty;
259 unsigned char *data;
260 int count;
261 if (priv->rx_flags & THROTTLED){
262 if (priv->rx_flags & ACTUALLY_THROTTLED)
263 schedule_work(&priv->rx_work);
264 return;
265 }
266
267 /* By now I will flush data to the tty in packages of no more than
268 * 64 bytes, to ensure I do not get throttled.
269 * Ask USB mailing list for better aproach.
270 */
271 tty = port->tty;
272
273 if (!tty)
274 schedule_work(&priv->rx_work);
275
276 count = min(64, serial_buf_data_avail(priv->rx_buf));
277
278 if (count <= 0)
279 return; //We have finished sending everything.
280
281 tty_prepare_flip_string(tty, &data, count);
282 if (!data){
283 err("%s- kzalloc(%d) failed.", __FUNCTION__, count);
284 return;
285 }
286
287 serial_buf_get(priv->rx_buf, data, count);
288
289 tty_flip_buffer_push(tty);
290
291 if (serial_buf_data_avail(priv->rx_buf))
292 schedule_work(&priv->rx_work);
293
294 return;
295}
296/* End of private methods */
297
298static int aircable_probe(struct usb_serial *serial,
299 const struct usb_device_id *id)
300{
301 struct usb_host_interface *iface_desc = serial->interface->cur_altsetting;
302 struct usb_endpoint_descriptor *endpoint;
303 int num_bulk_out=0;
304 int i;
305
306 for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) {
307 endpoint = &iface_desc->endpoint[i].desc;
308 if (((endpoint->bEndpointAddress & 0x80) == 0x00) &&
309 ((endpoint->bmAttributes & 3) == 0x02)) {
310 /* we found our bulk out endpoint */
311 dbg("found bulk out on endpoint %d", i);
312 ++num_bulk_out;
313 }
314 }
315
316 if (num_bulk_out == 0) {
317 dbg("Invalid interface, discarding");
318 return -ENODEV;
319 }
320
321 return 0;
322}
323
324static int aircable_attach (struct usb_serial *serial)
325{
326 struct usb_serial_port *port = serial->port[0];
327 struct aircable_private *priv;
328
329 priv = kzalloc(sizeof(struct aircable_private), GFP_KERNEL);
330 if (!priv){
331 err("%s- kmalloc(%Zd) failed.", __FUNCTION__,
332 sizeof(struct aircable_private));
333 return -ENOMEM;
334 }
335
336 /* Allocation of Circular Buffers */
337 priv->tx_buf = serial_buf_alloc();
338 if (priv->tx_buf == NULL) {
339 kfree(priv);
340 return -ENOMEM;
341 }
342
343 priv->rx_buf = serial_buf_alloc();
344 if (priv->rx_buf == NULL) {
345 kfree(priv->tx_buf);
346 kfree(priv);
347 return -ENOMEM;
348 }
349
350 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
351 INIT_WORK(&priv->rx_work, aircable_read, port);
352
353 usb_set_serial_port_data(serial->port[0], priv);
354
355 return 0;
356}
357
358static void aircable_shutdown(struct usb_serial *serial)
359{
360
361 struct usb_serial_port *port = serial->port[0];
362 struct aircable_private *priv = usb_get_serial_port_data(port);
363
364 dbg("%s", __FUNCTION__);
365
366 if (priv) {
367 serial_buf_free(priv->tx_buf);
368 serial_buf_free(priv->rx_buf);
369 usb_set_serial_port_data(port, NULL);
370 kfree(priv);
371 }
372}
373
374static int aircable_write_room(struct usb_serial_port *port)
375{
376 struct aircable_private *priv = usb_get_serial_port_data(port);
377 return serial_buf_data_avail(priv->tx_buf);
378}
379
380static int aircable_write(struct usb_serial_port *port,
381 const unsigned char *source, int count)
382{
383 struct aircable_private *priv = usb_get_serial_port_data(port);
384 int temp;
385
386 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
387
388 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, source);
389
390 if (!count){
391 dbg("%s - write request of 0 bytes", __FUNCTION__);
392 return count;
393 }
394
395 temp = serial_buf_put(priv->tx_buf, source, count);
396
397 aircable_send(port);
398
399 if (count > AIRCABLE_BUF_SIZE)
400 count = AIRCABLE_BUF_SIZE;
401
402 return count;
403
404}
405
406static void aircable_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
407{
408 struct usb_serial_port *port = urb->context;
409 int result;
410
411 dbg("%s - urb->status: %d", __FUNCTION__ , urb->status);
412
413 /* This has been taken from cypress_m8.c cypress_write_int_callback */
414 switch (urb->status) {
415 case 0:
416 /* success */
417 break;
418 case -ECONNRESET:
419 case -ENOENT:
420 case -ESHUTDOWN:
421 /* this urb is terminated, clean up */
422 dbg("%s - urb shutting down with status: %d",
423 __FUNCTION__, urb->status);
424 port->write_urb_busy = 0;
425 return;
426 default:
427 /* error in the urb, so we have to resubmit it */
428 dbg("%s - Overflow in write", __FUNCTION__);
429 dbg("%s - nonzero write bulk status received: %d",
430 __FUNCTION__, urb->status);
431 port->write_urb->transfer_buffer_length = 1;
432 port->write_urb->dev = port->serial->dev;
433 result = usb_submit_urb(port->write_urb, GFP_KERNEL);
434 if (result)
435 dev_err(&urb->dev->dev,
436 "%s - failed resubmitting write urb, error %d\n",
437 __FUNCTION__, result);
438 else
439 return;
440 }
441
442 port->write_urb_busy = 0;
443
444 aircable_send(port);
445}
446
447static void aircable_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
448{
449 struct usb_serial_port *port = urb->context;
450 struct aircable_private *priv = usb_get_serial_port_data(port);
451 struct tty_struct *tty;
452 unsigned long no_packages, remaining, package_length, i;
453 int result, shift = 0;
454 unsigned char *temp;
455
456 dbg("%s - port %d", __FUNCTION__, port->number);
457
458 if (urb->status) {
459 dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
460 if (!port->open_count) {
461 dbg("%s - port is closed, exiting.", __FUNCTION__);
462 return;
463 }
464 if (urb->status == -EPROTO) {
465 dbg("%s - caught -EPROTO, resubmitting the urb",
466 __FUNCTION__);
467 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
468 usb_rcvbulkpipe(port->serial->dev,
469 port->bulk_in_endpointAddress),
470 port->read_urb->transfer_buffer,
471 port->read_urb->transfer_buffer_length,
472 aircable_read_bulk_callback, port);
473
474 result = usb_submit_urb(urb, GFP_ATOMIC);
475 if (result)
476 dev_err(&urb->dev->dev,
477 "%s - failed resubmitting read urb, error %d\n",
478 __FUNCTION__, result);
479 return;
480 }
481 dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
482 return;
483 }
484
485 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
486 urb->actual_length,urb->transfer_buffer);
487
488 tty = port->tty;
489 if (tty && urb->actual_length) {
490 if (urb->actual_length <= 2) {
491 /* This is an incomplete package */
492 serial_buf_put(priv->rx_buf, urb->transfer_buffer,
493 urb->actual_length);
494 } else {
495 temp = urb->transfer_buffer;
496 if (temp[0] == RX_HEADER_0)
497 shift = HCI_HEADER_LENGTH;
498
499 remaining = urb->actual_length;
500 no_packages = urb->actual_length / (HCI_COMPLETE_FRAME);
501
502 if (urb->actual_length % HCI_COMPLETE_FRAME != 0)
503 no_packages+=1;
504
505 for (i = 0; i < no_packages ;i++) {
506 if (remaining > (HCI_COMPLETE_FRAME))
507 package_length = HCI_COMPLETE_FRAME;
508 else
509 package_length = remaining;
510 remaining -= package_length;
511
512 serial_buf_put(priv->rx_buf,
513 urb->transfer_buffer + shift +
514 (HCI_COMPLETE_FRAME) * (i),
515 package_length - shift);
516 }
517 }
518 aircable_read(port);
519 }
520
521 /* Schedule the next read _if_ we are still open */
522 if (port->open_count) {
523 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
524 usb_rcvbulkpipe(port->serial->dev,
525 port->bulk_in_endpointAddress),
526 port->read_urb->transfer_buffer,
527 port->read_urb->transfer_buffer_length,
528 aircable_read_bulk_callback, port);
529
530 result = usb_submit_urb(urb, GFP_ATOMIC);
531 if (result)
532 dev_err(&urb->dev->dev,
533 "%s - failed resubmitting read urb, error %d\n",
534 __FUNCTION__, result);
535 }
536
537 return;
538}
539
540/* Based on ftdi_sio.c throttle */
541static void aircable_throttle(struct usb_serial_port *port)
542{
543 struct aircable_private *priv = usb_get_serial_port_data(port);
544 unsigned long flags;
545
546 dbg("%s - port %d", __FUNCTION__, port->number);
547
548 spin_lock_irqsave(&priv->rx_lock, flags);
549 priv->rx_flags |= THROTTLED;
550 spin_unlock_irqrestore(&priv->rx_lock, flags);
551}
552
553/* Based on ftdi_sio.c unthrottle */
554static void aircable_unthrottle(struct usb_serial_port *port)
555{
556 struct aircable_private *priv = usb_get_serial_port_data(port);
557 int actually_throttled;
558 unsigned long flags;
559
560 dbg("%s - port %d", __FUNCTION__, port->number);
561
562 spin_lock_irqsave(&priv->rx_lock, flags);
563 actually_throttled = priv->rx_flags & ACTUALLY_THROTTLED;
564 priv->rx_flags &= ~(THROTTLED | ACTUALLY_THROTTLED);
565 spin_unlock_irqrestore(&priv->rx_lock, flags);
566
567 if (actually_throttled)
568 schedule_work(&priv->rx_work);
569}
570
571static struct usb_serial_driver aircable_device = {
572 .description = "aircable",
573 .id_table = id_table,
574 .num_ports = 1,
575 .attach = aircable_attach,
576 .probe = aircable_probe,
577 .shutdown = aircable_shutdown,
578 .write = aircable_write,
579 .write_room = aircable_write_room,
580 .write_bulk_callback = aircable_write_bulk_callback,
581 .read_bulk_callback = aircable_read_bulk_callback,
582 .throttle = aircable_throttle,
583 .unthrottle = aircable_unthrottle,
584};
585
586static struct usb_driver aircable_driver = {
587 .name = "aircable",
588 .probe = usb_serial_probe,
589 .disconnect = usb_serial_disconnect,
590 .id_table = id_table,
591};
592
593static int __init aircable_init (void)
594{
595 int retval;
596 retval = usb_serial_register(&aircable_device);
597 if (retval)
598 goto failed_serial_register;
599 retval = usb_register(&aircable_driver);
600 if (retval)
601 goto failed_usb_register;
602 return 0;
603
604failed_serial_register:
605 usb_serial_deregister(&aircable_device);
606failed_usb_register:
607 return retval;
608}
609
610static void __exit aircable_exit (void)
611{
612 usb_deregister(&aircable_driver);
613 usb_serial_deregister(&aircable_device);
614}
615
616MODULE_AUTHOR(DRIVER_AUTHOR);
617MODULE_DESCRIPTION(DRIVER_DESC);
618MODULE_VERSION(DRIVER_VERSION);
619MODULE_LICENSE("GPL");
620
621module_init(aircable_init);
622module_exit(aircable_exit);
623
624module_param(debug, bool, S_IRUGO | S_IWUSR);
625MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 62082532a8b3..6e1a84a858d4 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * AirPrime CDMA Wireless Serial USB driver 2 * AirPrime CDMA Wireless Serial USB driver
3 * 3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de> 4 * Copyright (C) 2005-2006 Greg Kroah-Hartman <gregkh@suse.de>
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 version 7 * modify it under the terms of the GNU General Public License version
@@ -11,26 +11,264 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/tty.h> 13#include <linux/tty.h>
14#include <linux/tty_flip.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/usb.h> 16#include <linux/usb.h>
16#include <linux/usb/serial.h> 17#include <linux/usb/serial.h>
17 18
18static struct usb_device_id id_table [] = { 19static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */ 20 { USB_DEVICE(0x0c88, 0x17da) }, /* Kyocera Wireless KPC650/Passport */
20 { USB_DEVICE(0xf3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */ 21 { USB_DEVICE(0x0f3d, 0x0112) }, /* AirPrime CDMA Wireless PC Card */
21 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */ 22 { USB_DEVICE(0x1199, 0x0017) }, /* Sierra Wireless EM5625 */
23 { USB_DEVICE(0x1199, 0x0018) }, /* Sierra Wireless MC5720 */
22 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */ 24 { USB_DEVICE(0x1199, 0x0112) }, /* Sierra Wireless Aircard 580 */
23 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */ 25 { USB_DEVICE(0x1199, 0x0218) }, /* Sierra Wireless MC5720 */
26 { USB_DEVICE(0x1410, 0x1110) }, /* Novatel Wireless Merlin CDMA */
24 { }, 27 { },
25}; 28};
26MODULE_DEVICE_TABLE(usb, id_table); 29MODULE_DEVICE_TABLE(usb, id_table);
27 30
31#define URB_TRANSFER_BUFFER_SIZE 4096
32#define NUM_READ_URBS 4
33#define NUM_WRITE_URBS 4
34#define NUM_BULK_EPS 3
35#define MAX_BULK_EPS 6
36
37/* if overridden by the user, then use their value for the size of the
38 * read and write urbs, and the number of endpoints */
39static int buffer_size = URB_TRANSFER_BUFFER_SIZE;
40static int endpoints = NUM_BULK_EPS;
41static int debug;
42struct airprime_private {
43 spinlock_t lock;
44 int outstanding_urbs;
45 int throttled;
46 struct urb *read_urbp[NUM_READ_URBS];
47};
48
49static void airprime_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
50{
51 struct usb_serial_port *port = urb->context;
52 unsigned char *data = urb->transfer_buffer;
53 struct tty_struct *tty;
54 int result;
55
56 dbg("%s - port %d", __FUNCTION__, port->number);
57
58 if (urb->status) {
59 dbg("%s - nonzero read bulk status received: %d",
60 __FUNCTION__, urb->status);
61 /* something happened, so free up the memory for this urb */
62 if (urb->transfer_buffer) {
63 kfree (urb->transfer_buffer);
64 urb->transfer_buffer = NULL;
65 }
66 return;
67 }
68 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
69
70 tty = port->tty;
71 if (tty && urb->actual_length) {
72 tty_insert_flip_string (tty, data, urb->actual_length);
73 tty_flip_buffer_push (tty);
74 }
75
76 result = usb_submit_urb (urb, GFP_ATOMIC);
77 if (result)
78 dev_err(&port->dev, "%s - failed resubmitting read urb, error %d\n",
79 __FUNCTION__, result);
80 return;
81}
82
83static void airprime_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
84{
85 struct usb_serial_port *port = urb->context;
86 struct airprime_private *priv = usb_get_serial_port_data(port);
87 unsigned long flags;
88
89 dbg("%s - port %d", __FUNCTION__, port->number);
90
91 /* free up the transfer buffer, as usb_free_urb() does not do this */
92 kfree (urb->transfer_buffer);
93
94 if (urb->status)
95 dbg("%s - nonzero write bulk status received: %d",
96 __FUNCTION__, urb->status);
97 spin_lock_irqsave(&priv->lock, flags);
98 --priv->outstanding_urbs;
99 spin_unlock_irqrestore(&priv->lock, flags);
100
101 usb_serial_port_softint(port);
102}
103
104static int airprime_open(struct usb_serial_port *port, struct file *filp)
105{
106 struct airprime_private *priv = usb_get_serial_port_data(port);
107 struct usb_serial *serial = port->serial;
108 struct urb *urb;
109 char *buffer = NULL;
110 int i;
111 int result = 0;
112
113 dbg("%s - port %d", __FUNCTION__, port->number);
114
115 /* initialize our private data structure if it isn't already created */
116 if (!priv) {
117 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
118 if (!priv) {
119 result = -ENOMEM;
120 goto out;
121 }
122 spin_lock_init(&priv->lock);
123 usb_set_serial_port_data(port, priv);
124 }
125
126 for (i = 0; i < NUM_READ_URBS; ++i) {
127 buffer = kmalloc(buffer_size, GFP_KERNEL);
128 if (!buffer) {
129 dev_err(&port->dev, "%s - out of memory.\n",
130 __FUNCTION__);
131 result = -ENOMEM;
132 goto errout;
133 }
134 urb = usb_alloc_urb(0, GFP_KERNEL);
135 if (!urb) {
136 dev_err(&port->dev, "%s - no more urbs?\n",
137 __FUNCTION__);
138 result = -ENOMEM;
139 goto errout;
140 }
141 usb_fill_bulk_urb(urb, serial->dev,
142 usb_rcvbulkpipe(serial->dev,
143 port->bulk_out_endpointAddress),
144 buffer, buffer_size,
145 airprime_read_bulk_callback, port);
146 result = usb_submit_urb(urb, GFP_KERNEL);
147 if (result) {
148 dev_err(&port->dev,
149 "%s - failed submitting read urb %d for port %d, error %d\n",
150 __FUNCTION__, i, port->number, result);
151 goto errout;
152 }
153 /* remember this urb so we can kill it when the port is closed */
154 priv->read_urbp[i] = urb;
155 }
156 goto out;
157
158 errout:
159 /* some error happened, cancel any submitted urbs and clean up anything that
160 got allocated successfully */
161
162 for ( ; i >= 0; --i) {
163 urb = priv->read_urbp[i];
164 if (urb) {
165 /* This urb was submitted successfully. So we have to
166 cancel it.
167 Unlinking the urb will invoke read_bulk_callback()
168 with an error status, so its transfer buffer will
169 be freed there */
170 if (usb_unlink_urb (urb) != -EINPROGRESS) {
171 /* comments in drivers/usb/core/urb.c say this
172 can only happen if the urb was never submitted,
173 or has completed already.
174 Either way we may have to free the transfer
175 buffer here. */
176 if (urb->transfer_buffer) {
177 kfree (urb->transfer_buffer);
178 urb->transfer_buffer = NULL;
179 }
180 }
181 usb_free_urb (urb);
182 }
183 }
184
185 out:
186 return result;
187}
188
189static void airprime_close(struct usb_serial_port *port, struct file * filp)
190{
191 struct airprime_private *priv = usb_get_serial_port_data(port);
192 int i;
193
194 dbg("%s - port %d", __FUNCTION__, port->number);
195
196 /* killing the urb will invoke read_bulk_callback() with an error status,
197 so the transfer buffer will be freed there */
198 for (i = 0; i < NUM_READ_URBS; ++i) {
199 usb_kill_urb (priv->read_urbp[i]);
200 usb_free_urb (priv->read_urbp[i]);
201 }
202
203 /* free up private structure */
204 kfree (priv);
205 usb_set_serial_port_data(port, NULL);
206}
207
208static int airprime_write(struct usb_serial_port *port,
209 const unsigned char *buf, int count)
210{
211 struct airprime_private *priv = usb_get_serial_port_data(port);
212 struct usb_serial *serial = port->serial;
213 struct urb *urb;
214 unsigned char *buffer;
215 unsigned long flags;
216 int status;
217 dbg("%s - port %d", __FUNCTION__, port->number);
218
219 spin_lock_irqsave(&priv->lock, flags);
220 if (priv->outstanding_urbs > NUM_WRITE_URBS) {
221 spin_unlock_irqrestore(&priv->lock, flags);
222 dbg("%s - write limit hit\n", __FUNCTION__);
223 return 0;
224 }
225 spin_unlock_irqrestore(&priv->lock, flags);
226 buffer = kmalloc(count, GFP_ATOMIC);
227 if (!buffer) {
228 dev_err(&port->dev, "out of memory\n");
229 return -ENOMEM;
230 }
231 urb = usb_alloc_urb(0, GFP_ATOMIC);
232 if (!urb) {
233 dev_err(&port->dev, "no more free urbs\n");
234 kfree (buffer);
235 return -ENOMEM;
236 }
237 memcpy (buffer, buf, count);
238
239 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, buffer);
240
241 usb_fill_bulk_urb(urb, serial->dev,
242 usb_sndbulkpipe(serial->dev,
243 port->bulk_out_endpointAddress),
244 buffer, count,
245 airprime_write_bulk_callback, port);
246
247 /* send it down the pipe */
248 status = usb_submit_urb(urb, GFP_ATOMIC);
249 if (status) {
250 dev_err(&port->dev,
251 "%s - usb_submit_urb(write bulk) failed with status = %d\n",
252 __FUNCTION__, status);
253 count = status;
254 kfree (buffer);
255 } else {
256 spin_lock_irqsave(&priv->lock, flags);
257 ++priv->outstanding_urbs;
258 spin_unlock_irqrestore(&priv->lock, flags);
259 }
260 /* we are done with this urb, so let the host driver
261 * really free it when it is finished with it */
262 usb_free_urb (urb);
263 return count;
264}
265
28static struct usb_driver airprime_driver = { 266static struct usb_driver airprime_driver = {
29 .name = "airprime", 267 .name = "airprime",
30 .probe = usb_serial_probe, 268 .probe = usb_serial_probe,
31 .disconnect = usb_serial_disconnect, 269 .disconnect = usb_serial_disconnect,
32 .id_table = id_table, 270 .id_table = id_table,
33 .no_dynamic_id = 1, 271 .no_dynamic_id = 1,
34}; 272};
35 273
36static struct usb_serial_driver airprime_device = { 274static struct usb_serial_driver airprime_device = {
@@ -42,13 +280,17 @@ static struct usb_serial_driver airprime_device = {
42 .num_interrupt_in = NUM_DONT_CARE, 280 .num_interrupt_in = NUM_DONT_CARE,
43 .num_bulk_in = NUM_DONT_CARE, 281 .num_bulk_in = NUM_DONT_CARE,
44 .num_bulk_out = NUM_DONT_CARE, 282 .num_bulk_out = NUM_DONT_CARE,
45 .num_ports = 1, 283 .open = airprime_open,
284 .close = airprime_close,
285 .write = airprime_write,
46}; 286};
47 287
48static int __init airprime_init(void) 288static int __init airprime_init(void)
49{ 289{
50 int retval; 290 int retval;
51 291
292 airprime_device.num_ports =
293 (endpoints > 0 && endpoints <= MAX_BULK_EPS) ? endpoints : NUM_BULK_EPS;
52 retval = usb_serial_register(&airprime_device); 294 retval = usb_serial_register(&airprime_device);
53 if (retval) 295 if (retval)
54 return retval; 296 return retval;
@@ -60,6 +302,8 @@ static int __init airprime_init(void)
60 302
61static void __exit airprime_exit(void) 303static void __exit airprime_exit(void)
62{ 304{
305 dbg("%s", __FUNCTION__);
306
63 usb_deregister(&airprime_driver); 307 usb_deregister(&airprime_driver);
64 usb_serial_deregister(&airprime_device); 308 usb_serial_deregister(&airprime_device);
65} 309}
@@ -67,3 +311,10 @@ static void __exit airprime_exit(void)
67module_init(airprime_init); 311module_init(airprime_init);
68module_exit(airprime_exit); 312module_exit(airprime_exit);
69MODULE_LICENSE("GPL"); 313MODULE_LICENSE("GPL");
314
315module_param(debug, bool, S_IRUGO | S_IWUSR);
316MODULE_PARM_DESC(debug, "Debug enabled");
317module_param(buffer_size, int, 0);
318MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers in bytes (default 4096)");
319module_param(endpoints, int, 0);
320MODULE_PARM_DESC(endpoints, "Number of bulk EPs to configure (default 3)");
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index 970d9ef0a7a5..ca52f12f0e24 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -1,4 +1,7 @@
1/* 1/*
2 * Copyright (C) 2006
3 * Simon Schulz (ark3116_driver <at> auctionant.de)
4 *
2 * ark3116 5 * ark3116
3 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547, 6 * - implements a driver for the arkmicro ark3116 chipset (vendor=0x6547,
4 * productid=0x0232) (used in a datacable called KQ-U8A) 7 * productid=0x0232) (used in a datacable called KQ-U8A)
@@ -8,8 +11,6 @@
8 * 11 *
9 * - based on logs created by usbsnoopy 12 * - based on logs created by usbsnoopy
10 * 13 *
11 * Author : Simon Schulz [ark3116_driver<AT>auctionant.de]
12 *
13 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the 15 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your 16 * Free Software Foundation; either version 2 of the License, or (at your
@@ -22,6 +23,8 @@
22#include <linux/module.h> 23#include <linux/module.h>
23#include <linux/usb.h> 24#include <linux/usb.h>
24#include <linux/usb/serial.h> 25#include <linux/usb/serial.h>
26#include <linux/serial.h>
27#include <asm/uaccess.h>
25 28
26 29
27static int debug; 30static int debug;
@@ -43,10 +46,10 @@ static inline void ARK3116_SND(struct usb_serial *serial, int seq,
43{ 46{
44 int result; 47 int result;
45 result = usb_control_msg(serial->dev, 48 result = usb_control_msg(serial->dev,
46 usb_sndctrlpipe(serial->dev,0), 49 usb_sndctrlpipe(serial->dev, 0),
47 request, requesttype, value, index, 50 request, requesttype, value, index,
48 NULL,0x00, 1000); 51 NULL, 0x00, 1000);
49 dbg("%03d > ok",seq); 52 dbg("%03d > ok", seq);
50} 53}
51 54
52static inline void ARK3116_RCV(struct usb_serial *serial, int seq, 55static inline void ARK3116_RCV(struct usb_serial *serial, int seq,
@@ -56,27 +59,25 @@ static inline void ARK3116_RCV(struct usb_serial *serial, int seq,
56{ 59{
57 int result; 60 int result;
58 result = usb_control_msg(serial->dev, 61 result = usb_control_msg(serial->dev,
59 usb_rcvctrlpipe(serial->dev,0), 62 usb_rcvctrlpipe(serial->dev, 0),
60 request, requesttype, value, index, 63 request, requesttype, value, index,
61 buf, 0x0000001, 1000); 64 buf, 0x0000001, 1000);
62 if (result) 65 if (result)
63 dbg("%03d < %d bytes [0x%02X]",seq, result, buf[0]); 66 dbg("%03d < %d bytes [0x%02X]", seq, result, buf[0]);
64 else 67 else
65 dbg("%03d < 0 bytes", seq); 68 dbg("%03d < 0 bytes", seq);
66} 69}
67 70
68
69static inline void ARK3116_RCV_QUIET(struct usb_serial *serial, 71static inline void ARK3116_RCV_QUIET(struct usb_serial *serial,
70 __u8 request, __u8 requesttype, 72 __u8 request, __u8 requesttype,
71 __u16 value, __u16 index, char *buf) 73 __u16 value, __u16 index, char *buf)
72{ 74{
73 usb_control_msg(serial->dev, 75 usb_control_msg(serial->dev,
74 usb_rcvctrlpipe(serial->dev,0), 76 usb_rcvctrlpipe(serial->dev, 0),
75 request, requesttype, value, index, 77 request, requesttype, value, index,
76 buf, 0x0000001, 1000); 78 buf, 0x0000001, 1000);
77} 79}
78 80
79
80static int ark3116_attach(struct usb_serial *serial) 81static int ark3116_attach(struct usb_serial *serial)
81{ 82{
82 char *buf; 83 char *buf;
@@ -84,10 +85,10 @@ static int ark3116_attach(struct usb_serial *serial)
84 int i; 85 int i;
85 86
86 for (i = 0; i < serial->num_ports; ++i) { 87 for (i = 0; i < serial->num_ports; ++i) {
87 priv = kmalloc (sizeof (struct ark3116_private), GFP_KERNEL); 88 priv = kmalloc(sizeof (struct ark3116_private), GFP_KERNEL);
88 if (!priv) 89 if (!priv)
89 goto cleanup; 90 goto cleanup;
90 memset (priv, 0x00, sizeof (struct ark3116_private)); 91 memset(priv, 0x00, sizeof (struct ark3116_private));
91 spin_lock_init(&priv->lock); 92 spin_lock_init(&priv->lock);
92 93
93 usb_set_serial_port_data(serial->port[i], priv); 94 usb_set_serial_port_data(serial->port[i], priv);
@@ -95,63 +96,62 @@ static int ark3116_attach(struct usb_serial *serial)
95 96
96 buf = kmalloc(1, GFP_KERNEL); 97 buf = kmalloc(1, GFP_KERNEL);
97 if (!buf) { 98 if (!buf) {
98 dbg("error kmalloc -> out of mem ?"); 99 dbg("error kmalloc -> out of mem?");
99 goto cleanup; 100 goto cleanup;
100 } 101 }
101 102
102 /* 3 */ 103 /* 3 */
103 ARK3116_SND(serial, 3,0xFE,0x40,0x0008,0x0002); 104 ARK3116_SND(serial, 3, 0xFE, 0x40, 0x0008, 0x0002);
104 ARK3116_SND(serial, 4,0xFE,0x40,0x0008,0x0001); 105 ARK3116_SND(serial, 4, 0xFE, 0x40, 0x0008, 0x0001);
105 ARK3116_SND(serial, 5,0xFE,0x40,0x0000,0x0008); 106 ARK3116_SND(serial, 5, 0xFE, 0x40, 0x0000, 0x0008);
106 ARK3116_SND(serial, 6,0xFE,0x40,0x0000,0x000B); 107 ARK3116_SND(serial, 6, 0xFE, 0x40, 0x0000, 0x000B);
107 108
108 /* <-- seq7 */ 109 /* <-- seq7 */
109 ARK3116_RCV(serial, 7,0xFE,0xC0,0x0000,0x0003, 0x00, buf); 110 ARK3116_RCV(serial, 7, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf);
110 ARK3116_SND(serial, 8,0xFE,0x40,0x0080,0x0003); 111 ARK3116_SND(serial, 8, 0xFE, 0x40, 0x0080, 0x0003);
111 ARK3116_SND(serial, 9,0xFE,0x40,0x001A,0x0000); 112 ARK3116_SND(serial, 9, 0xFE, 0x40, 0x001A, 0x0000);
112 ARK3116_SND(serial,10,0xFE,0x40,0x0000,0x0001); 113 ARK3116_SND(serial, 10, 0xFE, 0x40, 0x0000, 0x0001);
113 ARK3116_SND(serial,11,0xFE,0x40,0x0000,0x0003); 114 ARK3116_SND(serial, 11, 0xFE, 0x40, 0x0000, 0x0003);
114 115
115 /* <-- seq12 */ 116 /* <-- seq12 */
116 ARK3116_RCV(serial,12,0xFE,0xC0,0x0000,0x0004, 0x00, buf); 117 ARK3116_RCV(serial, 12, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
117 ARK3116_SND(serial,13,0xFE,0x40,0x0000,0x0004); 118 ARK3116_SND(serial, 13, 0xFE, 0x40, 0x0000, 0x0004);
118 119
119 /* 14 */ 120 /* 14 */
120 ARK3116_RCV(serial,14,0xFE,0xC0,0x0000,0x0004, 0x00, buf); 121 ARK3116_RCV(serial, 14, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
121 ARK3116_SND(serial,15,0xFE,0x40,0x0000,0x0004); 122 ARK3116_SND(serial, 15, 0xFE, 0x40, 0x0000, 0x0004);
122 123
123 /* 16 */ 124 /* 16 */
124 ARK3116_RCV(serial,16,0xFE,0xC0,0x0000,0x0004, 0x00, buf); 125 ARK3116_RCV(serial, 16, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
125 /* --> seq17 */ 126 /* --> seq17 */
126 ARK3116_SND(serial,17,0xFE,0x40,0x0001,0x0004); 127 ARK3116_SND(serial, 17, 0xFE, 0x40, 0x0001, 0x0004);
127 128
128 /* <-- seq18 */ 129 /* <-- seq18 */
129 ARK3116_RCV(serial,18,0xFE,0xC0,0x0000,0x0004, 0x01, buf); 130 ARK3116_RCV(serial, 18, 0xFE, 0xC0, 0x0000, 0x0004, 0x01, buf);
130 131
131 /* --> seq19 */ 132 /* --> seq19 */
132 ARK3116_SND(serial,19,0xFE,0x40,0x0003,0x0004); 133 ARK3116_SND(serial, 19, 0xFE, 0x40, 0x0003, 0x0004);
133
134 134
135 /* <-- seq20 */ 135 /* <-- seq20 */
136 /* seems like serial port status info (RTS, CTS,...) */ 136 /* seems like serial port status info (RTS, CTS, ...) */
137 /* returns modem control line status ?! */ 137 /* returns modem control line status?! */
138 ARK3116_RCV(serial,20,0xFE,0xC0,0x0000,0x0006, 0xFF, buf); 138 ARK3116_RCV(serial, 20, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
139 139
140 /* set 9600 baud & do some init ?! */ 140 /* set 9600 baud & do some init?! */
141 ARK3116_SND(serial,147,0xFE,0x40,0x0083,0x0003); 141 ARK3116_SND(serial, 147, 0xFE, 0x40, 0x0083, 0x0003);
142 ARK3116_SND(serial,148,0xFE,0x40,0x0038,0x0000); 142 ARK3116_SND(serial, 148, 0xFE, 0x40, 0x0038, 0x0000);
143 ARK3116_SND(serial,149,0xFE,0x40,0x0001,0x0001); 143 ARK3116_SND(serial, 149, 0xFE, 0x40, 0x0001, 0x0001);
144 ARK3116_SND(serial,150,0xFE,0x40,0x0003,0x0003); 144 ARK3116_SND(serial, 150, 0xFE, 0x40, 0x0003, 0x0003);
145 ARK3116_RCV(serial,151,0xFE,0xC0,0x0000,0x0004,0x03, buf); 145 ARK3116_RCV(serial, 151, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
146 ARK3116_SND(serial,152,0xFE,0x40,0x0000,0x0003); 146 ARK3116_SND(serial, 152, 0xFE, 0x40, 0x0000, 0x0003);
147 ARK3116_RCV(serial,153,0xFE,0xC0,0x0000,0x0003,0x00, buf); 147 ARK3116_RCV(serial, 153, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf);
148 ARK3116_SND(serial,154,0xFE,0x40,0x0003,0x0003); 148 ARK3116_SND(serial, 154, 0xFE, 0x40, 0x0003, 0x0003);
149 149
150 kfree(buf); 150 kfree(buf);
151 return(0); 151 return 0;
152 152
153cleanup: 153cleanup:
154 for (--i; i>=0; --i) 154 for (--i; i >= 0; --i)
155 usb_set_serial_port_data(serial->port[i], NULL); 155 usb_set_serial_port_data(serial->port[i], NULL);
156 return -ENOMEM; 156 return -ENOMEM;
157} 157}
@@ -180,7 +180,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
180 spin_lock_irqsave(&priv->lock, flags); 180 spin_lock_irqsave(&priv->lock, flags);
181 if (!priv->termios_initialized) { 181 if (!priv->termios_initialized) {
182 *(port->tty->termios) = tty_std_termios; 182 *(port->tty->termios) = tty_std_termios;
183 port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 183 port->tty->termios->c_cflag = B9600 | CS8
184 | CREAD | HUPCL | CLOCAL;
184 priv->termios_initialized = 1; 185 priv->termios_initialized = 1;
185 } 186 }
186 spin_unlock_irqrestore(&priv->lock, flags); 187 spin_unlock_irqrestore(&priv->lock, flags);
@@ -204,8 +205,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
204 } 205 }
205 206
206 /* set data bit count (8/7/6/5) */ 207 /* set data bit count (8/7/6/5) */
207 if (cflag & CSIZE){ 208 if (cflag & CSIZE) {
208 switch (cflag & CSIZE){ 209 switch (cflag & CSIZE) {
209 case CS5: 210 case CS5:
210 config |= 0x00; 211 config |= 0x00;
211 dbg("setting CS5"); 212 dbg("setting CS5");
@@ -219,7 +220,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
219 dbg("setting CS7"); 220 dbg("setting CS7");
220 break; 221 break;
221 default: 222 default:
222 err ("CSIZE was set but not CS5-CS8, using CS8!"); 223 err("CSIZE was set but not CS5-CS8, using CS8!");
224 /* fall through */
223 case CS8: 225 case CS8:
224 config |= 0x03; 226 config |= 0x03;
225 dbg("setting CS8"); 227 dbg("setting CS8");
@@ -227,8 +229,8 @@ static void ark3116_set_termios(struct usb_serial_port *port,
227 } 229 }
228 } 230 }
229 231
230 /* set parity (NONE,EVEN,ODD) */ 232 /* set parity (NONE/EVEN/ODD) */
231 if (cflag & PARENB){ 233 if (cflag & PARENB) {
232 if (cflag & PARODD) { 234 if (cflag & PARODD) {
233 config |= 0x08; 235 config |= 0x08;
234 dbg("setting parity to ODD"); 236 dbg("setting parity to ODD");
@@ -240,20 +242,19 @@ static void ark3116_set_termios(struct usb_serial_port *port,
240 dbg("setting parity to NONE"); 242 dbg("setting parity to NONE");
241 } 243 }
242 244
243 /* SET STOPBIT (1/2) */ 245 /* set stop bit (1/2) */
244 if (cflag & CSTOPB) { 246 if (cflag & CSTOPB) {
245 config |= 0x04; 247 config |= 0x04;
246 dbg ("setting 2 stop bits"); 248 dbg("setting 2 stop bits");
247 } else { 249 } else {
248 dbg ("setting 1 stop bit"); 250 dbg("setting 1 stop bit");
249 } 251 }
250 252
251 253 /* set baudrate */
252 /* set baudrate: */
253 baud = 0; 254 baud = 0;
254 switch (cflag & CBAUD){ 255 switch (cflag & CBAUD) {
255 case B0: 256 case B0:
256 err("can't set 0baud, using 9600 instead"); 257 err("can't set 0 baud, using 9600 instead");
257 break; 258 break;
258 case B75: baud = 75; break; 259 case B75: baud = 75; break;
259 case B150: baud = 150; break; 260 case B150: baud = 150; break;
@@ -285,38 +286,40 @@ static void ark3116_set_termios(struct usb_serial_port *port,
285 */ 286 */
286 if (baud == 460800) 287 if (baud == 460800)
287 /* strange, for 460800 the formula is wrong 288 /* strange, for 460800 the formula is wrong
288 * (dont use round(), then 9600baud is wrong) */ 289 * if using round() then 9600baud is wrong) */
289 ark3116_baud = 7; 290 ark3116_baud = 7;
290 else 291 else
291 ark3116_baud = 3000000 / baud; 292 ark3116_baud = 3000000 / baud;
292 293
293 /* ? */ 294 /* ? */
294 ARK3116_RCV(serial,0,0xFE,0xC0,0x0000,0x0003, 0x03, buf); 295 ARK3116_RCV(serial, 0, 0xFE, 0xC0, 0x0000, 0x0003, 0x03, buf);
296
295 /* offset = buf[0]; */ 297 /* offset = buf[0]; */
296 /* offset = 0x03; */ 298 /* offset = 0x03; */
297 /* dbg("using 0x%04X as target for 0x0003:",0x0080+offset); */ 299 /* dbg("using 0x%04X as target for 0x0003:", 0x0080 + offset); */
298
299 300
300 /* set baudrate */ 301 /* set baudrate */
301 dbg("setting baudrate to %d (->reg=%d)",baud,ark3116_baud); 302 dbg("setting baudrate to %d (->reg=%d)", baud, ark3116_baud);
302 ARK3116_SND(serial,147,0xFE,0x40,0x0083,0x0003); 303 ARK3116_SND(serial, 147, 0xFE, 0x40, 0x0083, 0x0003);
303 ARK3116_SND(serial,148,0xFE,0x40,(ark3116_baud & 0x00FF) ,0x0000); 304 ARK3116_SND(serial, 148, 0xFE, 0x40,
304 ARK3116_SND(serial,149,0xFE,0x40,(ark3116_baud & 0xFF00)>>8,0x0001); 305 (ark3116_baud & 0x00FF), 0x0000);
305 ARK3116_SND(serial,150,0xFE,0x40,0x0003,0x0003); 306 ARK3116_SND(serial, 149, 0xFE, 0x40,
307 (ark3116_baud & 0xFF00) >> 8, 0x0001);
308 ARK3116_SND(serial, 150, 0xFE, 0x40, 0x0003, 0x0003);
306 309
307 /* ? */ 310 /* ? */
308 ARK3116_RCV(serial,151,0xFE,0xC0,0x0000,0x0004,0x03, buf); 311 ARK3116_RCV(serial, 151, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
309 ARK3116_SND(serial,152,0xFE,0x40,0x0000,0x0003); 312 ARK3116_SND(serial, 152, 0xFE, 0x40, 0x0000, 0x0003);
310 313
311 /* set data bit count, stop bit count & parity: */ 314 /* set data bit count, stop bit count & parity: */
312 dbg("updating bit count, stop bit or parity (cfg=0x%02X)", config); 315 dbg("updating bit count, stop bit or parity (cfg=0x%02X)", config);
313 ARK3116_RCV(serial,153,0xFE,0xC0,0x0000,0x0003,0x00, buf); 316 ARK3116_RCV(serial, 153, 0xFE, 0xC0, 0x0000, 0x0003, 0x00, buf);
314 ARK3116_SND(serial,154,0xFE,0x40,config,0x0003); 317 ARK3116_SND(serial, 154, 0xFE, 0x40, config, 0x0003);
315 318
316 if (cflag & CRTSCTS) 319 if (cflag & CRTSCTS)
317 dbg("CRTSCTS not supported by chipset ?!"); 320 dbg("CRTSCTS not supported by chipset?!");
318 321
319 /* TEST ARK3116_SND(154,0xFE,0x40,0xFFFF, 0x0006); */ 322 /* TEST ARK3116_SND(154, 0xFE, 0x40, 0xFFFF, 0x0006); */
320 323
321 kfree(buf); 324 kfree(buf);
322 return; 325 return;
@@ -329,11 +332,11 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
329 char *buf; 332 char *buf;
330 int result = 0; 333 int result = 0;
331 334
332 dbg("%s - port %d", __FUNCTION__, port->number); 335 dbg("%s - port %d", __FUNCTION__, port->number);
333 336
334 buf = kmalloc(1, GFP_KERNEL); 337 buf = kmalloc(1, GFP_KERNEL);
335 if (!buf) { 338 if (!buf) {
336 dbg("error kmalloc -> out of mem ?"); 339 dbg("error kmalloc -> out of mem?");
337 return -ENOMEM; 340 return -ENOMEM;
338 } 341 }
339 342
@@ -342,44 +345,68 @@ static int ark3116_open(struct usb_serial_port *port, struct file *filp)
342 return result; 345 return result;
343 346
344 /* open */ 347 /* open */
345 ARK3116_RCV(serial,111,0xFE,0xC0,0x0000,0x0003, 0x02, buf); 348 ARK3116_RCV(serial, 111, 0xFE, 0xC0, 0x0000, 0x0003, 0x02, buf);
346 349
347 ARK3116_SND(serial,112,0xFE,0x40,0x0082,0x0003); 350 ARK3116_SND(serial, 112, 0xFE, 0x40, 0x0082, 0x0003);
348 ARK3116_SND(serial,113,0xFE,0x40,0x001A,0x0000); 351 ARK3116_SND(serial, 113, 0xFE, 0x40, 0x001A, 0x0000);
349 ARK3116_SND(serial,114,0xFE,0x40,0x0000,0x0001); 352 ARK3116_SND(serial, 114, 0xFE, 0x40, 0x0000, 0x0001);
350 ARK3116_SND(serial,115,0xFE,0x40,0x0002,0x0003); 353 ARK3116_SND(serial, 115, 0xFE, 0x40, 0x0002, 0x0003);
351 354
352 ARK3116_RCV(serial,116,0xFE,0xC0,0x0000,0x0004, 0x03, buf); 355 ARK3116_RCV(serial, 116, 0xFE, 0xC0, 0x0000, 0x0004, 0x03, buf);
353 ARK3116_SND(serial,117,0xFE,0x40,0x0002,0x0004); 356 ARK3116_SND(serial, 117, 0xFE, 0x40, 0x0002, 0x0004);
354 357
355 ARK3116_RCV(serial,118,0xFE,0xC0,0x0000,0x0004, 0x02, buf); 358 ARK3116_RCV(serial, 118, 0xFE, 0xC0, 0x0000, 0x0004, 0x02, buf);
356 ARK3116_SND(serial,119,0xFE,0x40,0x0000,0x0004); 359 ARK3116_SND(serial, 119, 0xFE, 0x40, 0x0000, 0x0004);
357 360
358 ARK3116_RCV(serial,120,0xFE,0xC0,0x0000,0x0004, 0x00, buf); 361 ARK3116_RCV(serial, 120, 0xFE, 0xC0, 0x0000, 0x0004, 0x00, buf);
359 362
360 ARK3116_SND(serial,121,0xFE,0x40,0x0001,0x0004); 363 ARK3116_SND(serial, 121, 0xFE, 0x40, 0x0001, 0x0004);
361 364
362 ARK3116_RCV(serial,122,0xFE,0xC0,0x0000,0x0004, 0x01, buf); 365 ARK3116_RCV(serial, 122, 0xFE, 0xC0, 0x0000, 0x0004, 0x01, buf);
363 366
364 ARK3116_SND(serial,123,0xFE,0x40,0x0003,0x0004); 367 ARK3116_SND(serial, 123, 0xFE, 0x40, 0x0003, 0x0004);
365 368
366 /* returns different values (control lines ?!) */ 369 /* returns different values (control lines?!) */
367 ARK3116_RCV(serial,124,0xFE,0xC0,0x0000,0x0006, 0xFF, buf); 370 ARK3116_RCV(serial, 124, 0xFE, 0xC0, 0x0000, 0x0006, 0xFF, buf);
368 371
369 /* initialise termios: */ 372 /* initialise termios */
370 if (port->tty) 373 if (port->tty)
371 ark3116_set_termios(port, &tmp_termios); 374 ark3116_set_termios(port, &tmp_termios);
372 375
373 kfree(buf); 376 kfree(buf);
374 377
375 return result; 378 return result;
376
377} 379}
378 380
379static int ark3116_ioctl(struct usb_serial_port *port, struct file *file, 381static int ark3116_ioctl(struct usb_serial_port *port, struct file *file,
380 unsigned int cmd, unsigned long arg) 382 unsigned int cmd, unsigned long arg)
381{ 383{
382 dbg("ioctl not supported yet..."); 384 struct serial_struct serstruct;
385 void __user *user_arg = (void __user *)arg;
386
387 switch (cmd) {
388 case TIOCGSERIAL:
389 /* XXX: Some of these values are probably wrong. */
390 memset(&serstruct, 0, sizeof (serstruct));
391 serstruct.type = PORT_16654;
392 serstruct.line = port->serial->minor;
393 serstruct.port = port->number;
394 serstruct.custom_divisor = 0;
395 serstruct.baud_base = 460800;
396
397 if (copy_to_user(user_arg, &serstruct, sizeof (serstruct)))
398 return -EFAULT;
399
400 return 0;
401 case TIOCSSERIAL:
402 if (copy_from_user(&serstruct, user_arg, sizeof (serstruct)))
403 return -EFAULT;
404 return 0;
405 default:
406 dbg("%s cmd 0x%04x not supported", __FUNCTION__, cmd);
407 break;
408 }
409
383 return -ENOIOCTLCMD; 410 return -ENOIOCTLCMD;
384} 411}
385 412
@@ -389,7 +416,7 @@ static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file)
389 char *buf; 416 char *buf;
390 char temp; 417 char temp;
391 418
392 /* seems like serial port status info (RTS, CTS,...) is stored 419 /* seems like serial port status info (RTS, CTS, ...) is stored
393 * in reg(?) 0x0006 420 * in reg(?) 0x0006
394 * pcb connection point 11 = GND -> sets bit4 of response 421 * pcb connection point 11 = GND -> sets bit4 of response
395 * pcb connection point 7 = GND -> sets bit6 of response 422 * pcb connection point 7 = GND -> sets bit6 of response
@@ -401,16 +428,16 @@ static int ark3116_tiocmget(struct usb_serial_port *port, struct file *file)
401 return -ENOMEM; 428 return -ENOMEM;
402 } 429 }
403 430
404 /* read register: */ 431 /* read register */
405 ARK3116_RCV_QUIET(serial,0xFE,0xC0,0x0000,0x0006,buf); 432 ARK3116_RCV_QUIET(serial, 0xFE, 0xC0, 0x0000, 0x0006, buf);
406 temp = buf[0]; 433 temp = buf[0];
407 kfree(buf); 434 kfree(buf);
408 435
409 /* i do not really know if bit4=CTS and bit6=DSR... was just a 436 /* i do not really know if bit4=CTS and bit6=DSR... just a
410 * quick guess !! 437 * quick guess!
411 */ 438 */
412 return (temp & (1<<4) ? TIOCM_CTS : 0) | 439 return (temp & (1<<4) ? TIOCM_CTS : 0)
413 (temp & (1<<6) ? TIOCM_DSR : 0); 440 | (temp & (1<<6) ? TIOCM_DSR : 0);
414} 441}
415 442
416static struct usb_driver ark3116_driver = { 443static struct usb_driver ark3116_driver = {
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index ee70fddcab60..e1173c1aee37 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -129,6 +129,9 @@ struct cypress_private {
129 int cmd_ctrl; /* always set this to 1 before issuing a command */ 129 int cmd_ctrl; /* always set this to 1 before issuing a command */
130 struct cypress_buf *buf; /* write buffer */ 130 struct cypress_buf *buf; /* write buffer */
131 int write_urb_in_use; /* write urb in use indicator */ 131 int write_urb_in_use; /* write urb in use indicator */
132 int write_urb_interval; /* interval to use for write urb */
133 int read_urb_interval; /* interval to use for read urb */
134 int comm_is_ok; /* true if communication is (still) ok */
132 int termios_initialized; 135 int termios_initialized;
133 __u8 line_control; /* holds dtr / rts value */ 136 __u8 line_control; /* holds dtr / rts value */
134 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */ 137 __u8 current_status; /* received from last read - info on dsr,cts,cd,ri,etc */
@@ -168,6 +171,7 @@ static int cypress_tiocmset (struct usb_serial_port *port, struct file *file,
168static int cypress_chars_in_buffer (struct usb_serial_port *port); 171static int cypress_chars_in_buffer (struct usb_serial_port *port);
169static void cypress_throttle (struct usb_serial_port *port); 172static void cypress_throttle (struct usb_serial_port *port);
170static void cypress_unthrottle (struct usb_serial_port *port); 173static void cypress_unthrottle (struct usb_serial_port *port);
174static void cypress_set_dead (struct usb_serial_port *port);
171static void cypress_read_int_callback (struct urb *urb, struct pt_regs *regs); 175static void cypress_read_int_callback (struct urb *urb, struct pt_regs *regs);
172static void cypress_write_int_callback (struct urb *urb, struct pt_regs *regs); 176static void cypress_write_int_callback (struct urb *urb, struct pt_regs *regs);
173/* baud helper functions */ 177/* baud helper functions */
@@ -288,6 +292,9 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
288 292
289 priv = usb_get_serial_port_data(port); 293 priv = usb_get_serial_port_data(port);
290 294
295 if (!priv->comm_is_ok)
296 return -ENODEV;
297
291 switch(cypress_request_type) { 298 switch(cypress_request_type) {
292 case CYPRESS_SET_CONFIG: 299 case CYPRESS_SET_CONFIG:
293 300
@@ -365,13 +372,12 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
365 if (tries++ >= 3) 372 if (tries++ >= 3)
366 break; 373 break;
367 374
368 if (retval == EPIPE) 375 } while (retval != 8 && retval != -ENODEV);
369 usb_clear_halt(port->serial->dev, 0x00);
370 } while (retval != 8 && retval != ENODEV);
371 376
372 if (retval != 8) 377 if (retval != 8) {
373 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval); 378 err("%s - failed sending serial line settings - %d", __FUNCTION__, retval);
374 else { 379 cypress_set_dead(port);
380 } else {
375 spin_lock_irqsave(&priv->lock, flags); 381 spin_lock_irqsave(&priv->lock, flags);
376 priv->baud_rate = new_baudrate; 382 priv->baud_rate = new_baudrate;
377 priv->cbr_mask = baud_mask; 383 priv->cbr_mask = baud_mask;
@@ -392,12 +398,11 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
392 if (tries++ >= 3) 398 if (tries++ >= 3)
393 break; 399 break;
394 400
395 if (retval == EPIPE) 401 } while (retval != 5 && retval != -ENODEV);
396 usb_clear_halt(port->serial->dev, 0x00);
397 } while (retval != 5 && retval != ENODEV);
398 402
399 if (retval != 5) { 403 if (retval != 5) {
400 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval); 404 err("%s - failed to retrieve serial line settings - %d", __FUNCTION__, retval);
405 cypress_set_dead(port);
401 return retval; 406 return retval;
402 } else { 407 } else {
403 spin_lock_irqsave(&priv->lock, flags); 408 spin_lock_irqsave(&priv->lock, flags);
@@ -419,6 +424,24 @@ static int cypress_serial_control (struct usb_serial_port *port, unsigned baud_m
419} /* cypress_serial_control */ 424} /* cypress_serial_control */
420 425
421 426
427static void cypress_set_dead(struct usb_serial_port *port)
428{
429 struct cypress_private *priv = usb_get_serial_port_data(port);
430 unsigned long flags;
431
432 spin_lock_irqsave(&priv->lock, flags);
433 if (!priv->comm_is_ok) {
434 spin_unlock_irqrestore(&priv->lock, flags);
435 return;
436 }
437 priv->comm_is_ok = 0;
438 spin_unlock_irqrestore(&priv->lock, flags);
439
440 err("cypress_m8 suspending failing port %d - interval might be too short",
441 port->number);
442}
443
444
422/* given a baud mask, it will return integer baud on success */ 445/* given a baud mask, it will return integer baud on success */
423static int mask_to_rate (unsigned mask) 446static int mask_to_rate (unsigned mask)
424{ 447{
@@ -472,13 +495,15 @@ static unsigned rate_to_mask (int rate)
472static int generic_startup (struct usb_serial *serial) 495static int generic_startup (struct usb_serial *serial)
473{ 496{
474 struct cypress_private *priv; 497 struct cypress_private *priv;
498 struct usb_serial_port *port = serial->port[0];
475 499
476 dbg("%s - port %d", __FUNCTION__, serial->port[0]->number); 500 dbg("%s - port %d", __FUNCTION__, port->number);
477 501
478 priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL); 502 priv = kzalloc(sizeof (struct cypress_private), GFP_KERNEL);
479 if (!priv) 503 if (!priv)
480 return -ENOMEM; 504 return -ENOMEM;
481 505
506 priv->comm_is_ok = !0;
482 spin_lock_init(&priv->lock); 507 spin_lock_init(&priv->lock);
483 priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE); 508 priv->buf = cypress_buf_alloc(CYPRESS_BUF_SIZE);
484 if (priv->buf == NULL) { 509 if (priv->buf == NULL) {
@@ -489,13 +514,24 @@ static int generic_startup (struct usb_serial *serial)
489 514
490 usb_reset_configuration (serial->dev); 515 usb_reset_configuration (serial->dev);
491 516
492 interval = 1;
493 priv->cmd_ctrl = 0; 517 priv->cmd_ctrl = 0;
494 priv->line_control = 0; 518 priv->line_control = 0;
495 priv->termios_initialized = 0; 519 priv->termios_initialized = 0;
496 priv->rx_flags = 0; 520 priv->rx_flags = 0;
497 priv->cbr_mask = B300; 521 priv->cbr_mask = B300;
498 usb_set_serial_port_data(serial->port[0], priv); 522 if (interval > 0) {
523 priv->write_urb_interval = interval;
524 priv->read_urb_interval = interval;
525 dbg("%s - port %d read & write intervals forced to %d",
526 __FUNCTION__,port->number,interval);
527 } else {
528 priv->write_urb_interval = port->interrupt_out_urb->interval;
529 priv->read_urb_interval = port->interrupt_in_urb->interval;
530 dbg("%s - port %d intervals: read=%d write=%d",
531 __FUNCTION__,port->number,
532 priv->read_urb_interval,priv->write_urb_interval);
533 }
534 usb_set_serial_port_data(port, priv);
499 535
500 return 0; 536 return 0;
501} 537}
@@ -585,6 +621,9 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
585 621
586 dbg("%s - port %d", __FUNCTION__, port->number); 622 dbg("%s - port %d", __FUNCTION__, port->number);
587 623
624 if (!priv->comm_is_ok)
625 return -EIO;
626
588 /* clear halts before open */ 627 /* clear halts before open */
589 usb_clear_halt(serial->dev, 0x81); 628 usb_clear_halt(serial->dev, 0x81);
590 usb_clear_halt(serial->dev, 0x02); 629 usb_clear_halt(serial->dev, 0x02);
@@ -624,11 +663,12 @@ static int cypress_open (struct usb_serial_port *port, struct file *filp)
624 usb_fill_int_urb(port->interrupt_in_urb, serial->dev, 663 usb_fill_int_urb(port->interrupt_in_urb, serial->dev,
625 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress), 664 usb_rcvintpipe(serial->dev, port->interrupt_in_endpointAddress),
626 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length, 665 port->interrupt_in_urb->transfer_buffer, port->interrupt_in_urb->transfer_buffer_length,
627 cypress_read_int_callback, port, interval); 666 cypress_read_int_callback, port, priv->read_urb_interval);
628 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 667 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
629 668
630 if (result){ 669 if (result){
631 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 670 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result);
671 cypress_set_dead(port);
632 } 672 }
633 673
634 return result; 674 return result;
@@ -733,6 +773,9 @@ static void cypress_send(struct usb_serial_port *port)
733 struct cypress_private *priv = usb_get_serial_port_data(port); 773 struct cypress_private *priv = usb_get_serial_port_data(port);
734 unsigned long flags; 774 unsigned long flags;
735 775
776 if (!priv->comm_is_ok)
777 return;
778
736 dbg("%s - port %d", __FUNCTION__, port->number); 779 dbg("%s - port %d", __FUNCTION__, port->number);
737 dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size); 780 dbg("%s - interrupt out size is %d", __FUNCTION__, port->interrupt_out_size);
738 781
@@ -806,14 +849,16 @@ send:
806 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, port->interrupt_out_size, 849 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, port->interrupt_out_size,
807 port->interrupt_out_urb->transfer_buffer); 850 port->interrupt_out_urb->transfer_buffer);
808 851
809 port->interrupt_out_urb->transfer_buffer_length = actual_size; 852 usb_fill_int_urb(port->interrupt_out_urb, port->serial->dev,
810 port->interrupt_out_urb->dev = port->serial->dev; 853 usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
811 port->interrupt_out_urb->interval = interval; 854 port->interrupt_out_buffer, port->interrupt_out_size,
855 cypress_write_int_callback, port, priv->write_urb_interval);
812 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC); 856 result = usb_submit_urb (port->interrupt_out_urb, GFP_ATOMIC);
813 if (result) { 857 if (result) {
814 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, 858 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__,
815 result); 859 result);
816 priv->write_urb_in_use = 0; 860 priv->write_urb_in_use = 0;
861 cypress_set_dead(port);
817 } 862 }
818 863
819 spin_lock_irqsave(&priv->lock, flags); 864 spin_lock_irqsave(&priv->lock, flags);
@@ -1214,13 +1259,18 @@ static void cypress_unthrottle (struct usb_serial_port *port)
1214 priv->rx_flags = 0; 1259 priv->rx_flags = 0;
1215 spin_unlock_irqrestore(&priv->lock, flags); 1260 spin_unlock_irqrestore(&priv->lock, flags);
1216 1261
1262 if (!priv->comm_is_ok)
1263 return;
1264
1217 if (actually_throttled) { 1265 if (actually_throttled) {
1218 port->interrupt_in_urb->dev = port->serial->dev; 1266 port->interrupt_in_urb->dev = port->serial->dev;
1219 1267
1220 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1268 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1221 if (result) 1269 if (result) {
1222 dev_err(&port->dev, "%s - failed submitting read urb, " 1270 dev_err(&port->dev, "%s - failed submitting read urb, "
1223 "error %d\n", __FUNCTION__, result); 1271 "error %d\n", __FUNCTION__, result);
1272 cypress_set_dead(port);
1273 }
1224 } 1274 }
1225} 1275}
1226 1276
@@ -1240,9 +1290,22 @@ static void cypress_read_int_callback(struct urb *urb, struct pt_regs *regs)
1240 1290
1241 dbg("%s - port %d", __FUNCTION__, port->number); 1291 dbg("%s - port %d", __FUNCTION__, port->number);
1242 1292
1243 if (urb->status) { 1293 switch (urb->status) {
1244 dbg("%s - nonzero read status received: %d", __FUNCTION__, 1294 case 0: /* success */
1245 urb->status); 1295 break;
1296 case -ECONNRESET:
1297 case -ENOENT:
1298 case -ESHUTDOWN:
1299 /* precursor to disconnect so just go away */
1300 return;
1301 case -EPIPE:
1302 usb_clear_halt(port->serial->dev,0x81);
1303 break;
1304 default:
1305 /* something ugly is going on... */
1306 dev_err(&urb->dev->dev,"%s - unexpected nonzero read status received: %d\n",
1307 __FUNCTION__,urb->status);
1308 cypress_set_dead(port);
1246 return; 1309 return;
1247 } 1310 }
1248 1311
@@ -1343,18 +1406,20 @@ continue_read:
1343 1406
1344 /* Continue trying to always read... unless the port has closed. */ 1407 /* Continue trying to always read... unless the port has closed. */
1345 1408
1346 if (port->open_count > 0) { 1409 if (port->open_count > 0 && priv->comm_is_ok) {
1347 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev, 1410 usb_fill_int_urb(port->interrupt_in_urb, port->serial->dev,
1348 usb_rcvintpipe(port->serial->dev, 1411 usb_rcvintpipe(port->serial->dev,
1349 port->interrupt_in_endpointAddress), 1412 port->interrupt_in_endpointAddress),
1350 port->interrupt_in_urb->transfer_buffer, 1413 port->interrupt_in_urb->transfer_buffer,
1351 port->interrupt_in_urb->transfer_buffer_length, 1414 port->interrupt_in_urb->transfer_buffer_length,
1352 cypress_read_int_callback, port, interval); 1415 cypress_read_int_callback, port, priv->read_urb_interval);
1353 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); 1416 result = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);
1354 if (result) 1417 if (result) {
1355 dev_err(&urb->dev->dev, "%s - failed resubmitting " 1418 dev_err(&urb->dev->dev, "%s - failed resubmitting "
1356 "read urb, error %d\n", __FUNCTION__, 1419 "read urb, error %d\n", __FUNCTION__,
1357 result); 1420 result);
1421 cypress_set_dead(port);
1422 }
1358 } 1423 }
1359 1424
1360 return; 1425 return;
@@ -1380,20 +1445,26 @@ static void cypress_write_int_callback(struct urb *urb, struct pt_regs *regs)
1380 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 1445 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status);
1381 priv->write_urb_in_use = 0; 1446 priv->write_urb_in_use = 0;
1382 return; 1447 return;
1383 case -EPIPE: /* no break needed */ 1448 case -EPIPE: /* no break needed; clear halt and resubmit */
1449 if (!priv->comm_is_ok)
1450 break;
1384 usb_clear_halt(port->serial->dev, 0x02); 1451 usb_clear_halt(port->serial->dev, 0x02);
1385 default:
1386 /* error in the urb, so we have to resubmit it */ 1452 /* error in the urb, so we have to resubmit it */
1387 dbg("%s - Overflow in write", __FUNCTION__);
1388 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 1453 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status);
1389 port->interrupt_out_urb->transfer_buffer_length = 1; 1454 port->interrupt_out_urb->transfer_buffer_length = 1;
1390 port->interrupt_out_urb->dev = port->serial->dev; 1455 port->interrupt_out_urb->dev = port->serial->dev;
1391 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC); 1456 result = usb_submit_urb(port->interrupt_out_urb, GFP_ATOMIC);
1392 if (result) 1457 if (!result)
1393 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
1394 __FUNCTION__, result);
1395 else
1396 return; 1458 return;
1459 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n",
1460 __FUNCTION__, result);
1461 cypress_set_dead(port);
1462 break;
1463 default:
1464 dev_err(&urb->dev->dev,"%s - unexpected nonzero write status received: %d\n",
1465 __FUNCTION__,urb->status);
1466 cypress_set_dead(port);
1467 break;
1397 } 1468 }
1398 1469
1399 priv->write_urb_in_use = 0; 1470 priv->write_urb_in_use = 0;
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index c6115aa1b445..1f7b72553f37 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1101,25 +1101,29 @@ static ssize_t store_event_char(struct device *dev, struct device_attribute *att
1101static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer); 1101static DEVICE_ATTR(latency_timer, S_IWUSR | S_IRUGO, show_latency_timer, store_latency_timer);
1102static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char); 1102static DEVICE_ATTR(event_char, S_IWUSR, NULL, store_event_char);
1103 1103
1104static void create_sysfs_attrs(struct usb_serial *serial) 1104static int create_sysfs_attrs(struct usb_serial *serial)
1105{ 1105{
1106 struct ftdi_private *priv; 1106 struct ftdi_private *priv;
1107 struct usb_device *udev; 1107 struct usb_device *udev;
1108 int retval = 0;
1108 1109
1109 dbg("%s",__FUNCTION__); 1110 dbg("%s",__FUNCTION__);
1110 1111
1111 priv = usb_get_serial_port_data(serial->port[0]); 1112 priv = usb_get_serial_port_data(serial->port[0]);
1112 udev = serial->dev; 1113 udev = serial->dev;
1113 1114
1114 /* XXX I've no idea if the original SIO supports the event_char 1115 /* XXX I've no idea if the original SIO supports the event_char
1115 * sysfs parameter, so I'm playing it safe. */ 1116 * sysfs parameter, so I'm playing it safe. */
1116 if (priv->chip_type != SIO) { 1117 if (priv->chip_type != SIO) {
1117 dbg("sysfs attributes for %s", ftdi_chip_name[priv->chip_type]); 1118 dbg("sysfs attributes for %s", ftdi_chip_name[priv->chip_type]);
1118 device_create_file(&udev->dev, &dev_attr_event_char); 1119 retval = device_create_file(&udev->dev, &dev_attr_event_char);
1119 if (priv->chip_type == FT232BM || priv->chip_type == FT2232C) { 1120 if ((!retval) &&
1120 device_create_file(&udev->dev, &dev_attr_latency_timer); 1121 (priv->chip_type == FT232BM || priv->chip_type == FT2232C)) {
1122 retval = device_create_file(&udev->dev,
1123 &dev_attr_latency_timer);
1121 } 1124 }
1122 } 1125 }
1126 return retval;
1123} 1127}
1124 1128
1125static void remove_sysfs_attrs(struct usb_serial *serial) 1129static void remove_sysfs_attrs(struct usb_serial *serial)
@@ -1162,7 +1166,8 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1162 struct usb_serial_port *port = serial->port[0]; 1166 struct usb_serial_port *port = serial->port[0];
1163 struct ftdi_private *priv; 1167 struct ftdi_private *priv;
1164 struct ftdi_sio_quirk *quirk; 1168 struct ftdi_sio_quirk *quirk;
1165 1169 int retval;
1170
1166 dbg("%s",__FUNCTION__); 1171 dbg("%s",__FUNCTION__);
1167 1172
1168 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1173 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
@@ -1203,15 +1208,18 @@ static int ftdi_sio_attach (struct usb_serial *serial)
1203 usb_set_serial_port_data(serial->port[0], priv); 1208 usb_set_serial_port_data(serial->port[0], priv);
1204 1209
1205 ftdi_determine_type (serial->port[0]); 1210 ftdi_determine_type (serial->port[0]);
1206 create_sysfs_attrs(serial); 1211 retval = create_sysfs_attrs(serial);
1212 if (retval)
1213 dev_err(&serial->dev->dev, "Error creating sysfs files, "
1214 "continuing\n");
1207 1215
1208 /* Check for device requiring special set up. */ 1216 /* Check for device requiring special set up. */
1209 quirk = (struct ftdi_sio_quirk *)usb_get_serial_data(serial); 1217 quirk = (struct ftdi_sio_quirk *)usb_get_serial_data(serial);
1210 if (quirk && quirk->setup) { 1218 if (quirk && quirk->setup) {
1211 quirk->setup(serial); 1219 quirk->setup(serial);
1212 } 1220 }
1213 1221
1214 return (0); 1222 return 0;
1215} /* ftdi_sio_attach */ 1223} /* ftdi_sio_attach */
1216 1224
1217 1225
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 727852634be9..4b1196a8b09e 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Garmin GPS driver 2 * Garmin GPS driver
3 * 3 *
4 * Copyright (C) 2004 Hermann Kneissel herkne@users.sourceforge.net 4 * Copyright (C) 2006 Hermann Kneissel herkne@users.sourceforge.net
5 * 5 *
6 * The latest version of the driver can be found at 6 * The latest version of the driver can be found at
7 * http://sourceforge.net/projects/garmin-gps/ 7 * http://sourceforge.net/projects/garmin-gps/
@@ -37,6 +37,8 @@
37#include <linux/usb.h> 37#include <linux/usb.h>
38#include <linux/usb/serial.h> 38#include <linux/usb/serial.h>
39 39
40#include <linux/version.h>
41
40/* the mode to be set when the port ist opened */ 42/* the mode to be set when the port ist opened */
41static int initial_mode = 1; 43static int initial_mode = 1;
42 44
@@ -50,7 +52,7 @@ static int debug = 0;
50 */ 52 */
51 53
52#define VERSION_MAJOR 0 54#define VERSION_MAJOR 0
53#define VERSION_MINOR 23 55#define VERSION_MINOR 28
54 56
55#define _STR(s) #s 57#define _STR(s) #s
56#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b) 58#define _DRIVER_VERSION(a,b) "v" _STR(a) "." _STR(b)
@@ -164,7 +166,8 @@ struct garmin_data {
164#define FLAGS_SESSION_REPLY1_SEEN 0x0080 166#define FLAGS_SESSION_REPLY1_SEEN 0x0080
165#define FLAGS_SESSION_REPLY2_SEEN 0x0040 167#define FLAGS_SESSION_REPLY2_SEEN 0x0040
166#define FLAGS_BULK_IN_ACTIVE 0x0020 168#define FLAGS_BULK_IN_ACTIVE 0x0020
167#define FLAGS_THROTTLED 0x0010 169#define FLAGS_BULK_IN_RESTART 0x0010
170#define FLAGS_THROTTLED 0x0008
168#define CLEAR_HALT_REQUIRED 0x0001 171#define CLEAR_HALT_REQUIRED 0x0001
169 172
170#define FLAGS_QUEUING 0x0100 173#define FLAGS_QUEUING 0x0100
@@ -224,7 +227,7 @@ static struct usb_driver garmin_driver = {
224 .probe = usb_serial_probe, 227 .probe = usb_serial_probe,
225 .disconnect = usb_serial_disconnect, 228 .disconnect = usb_serial_disconnect,
226 .id_table = id_table, 229 .id_table = id_table,
227 .no_dynamic_id = 1, 230 .no_dynamic_id = 1,
228}; 231};
229 232
230 233
@@ -270,7 +273,7 @@ static inline int isAbortTrfCmnd(const unsigned char *buf)
270 273
271 274
272static void send_to_tty(struct usb_serial_port *port, 275static void send_to_tty(struct usb_serial_port *port,
273 char *data, unsigned int actual_length) 276 char *data, unsigned int actual_length)
274{ 277{
275 struct tty_struct *tty = port->tty; 278 struct tty_struct *tty = port->tty;
276 279
@@ -294,15 +297,15 @@ static void send_to_tty(struct usb_serial_port *port,
294 * queue a received (usb-)packet for later processing 297 * queue a received (usb-)packet for later processing
295 */ 298 */
296static int pkt_add(struct garmin_data * garmin_data_p, 299static int pkt_add(struct garmin_data * garmin_data_p,
297 unsigned char *data, unsigned int data_length) 300 unsigned char *data, unsigned int data_length)
298{ 301{
302 int state = 0;
299 int result = 0; 303 int result = 0;
300 unsigned long flags; 304 unsigned long flags;
301 struct garmin_packet *pkt; 305 struct garmin_packet *pkt;
302 306
303 /* process only packets containg data ... */ 307 /* process only packets containg data ... */
304 if (data_length) { 308 if (data_length) {
305 garmin_data_p->flags |= FLAGS_QUEUING;
306 pkt = kmalloc(sizeof(struct garmin_packet)+data_length, 309 pkt = kmalloc(sizeof(struct garmin_packet)+data_length,
307 GFP_ATOMIC); 310 GFP_ATOMIC);
308 if (pkt == NULL) { 311 if (pkt == NULL) {
@@ -313,14 +316,16 @@ static int pkt_add(struct garmin_data * garmin_data_p,
313 memcpy(pkt->data, data, data_length); 316 memcpy(pkt->data, data, data_length);
314 317
315 spin_lock_irqsave(&garmin_data_p->lock, flags); 318 spin_lock_irqsave(&garmin_data_p->lock, flags);
319 garmin_data_p->flags |= FLAGS_QUEUING;
316 result = list_empty(&garmin_data_p->pktlist); 320 result = list_empty(&garmin_data_p->pktlist);
317 pkt->seq = garmin_data_p->seq_counter++; 321 pkt->seq = garmin_data_p->seq_counter++;
318 list_add_tail(&pkt->list, &garmin_data_p->pktlist); 322 list_add_tail(&pkt->list, &garmin_data_p->pktlist);
323 state = garmin_data_p->state;
319 spin_unlock_irqrestore(&garmin_data_p->lock, flags); 324 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
320 325
321 /* in serial mode, if someone is waiting for data from 326 /* in serial mode, if someone is waiting for data from
322 the device, iconvert and send the next packet to tty. */ 327 the device, iconvert and send the next packet to tty. */
323 if (result && (garmin_data_p->state == STATE_GSP_WAIT_DATA)) { 328 if (result && (state == STATE_GSP_WAIT_DATA)) {
324 gsp_next_packet(garmin_data_p); 329 gsp_next_packet(garmin_data_p);
325 } 330 }
326 } 331 }
@@ -370,9 +375,9 @@ static void pkt_clear(struct garmin_data * garmin_data_p)
370static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id) 375static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
371{ 376{
372 __u8 pkt[10]; 377 __u8 pkt[10];
373 __u8 cksum = 0; 378 __u8 cksum = 0;
374 __u8 *ptr = pkt; 379 __u8 *ptr = pkt;
375 unsigned l = 0; 380 unsigned l = 0;
376 381
377 dbg("%s - pkt-id: 0x%X.", __FUNCTION__, 0xFF & pkt_id); 382 dbg("%s - pkt-id: 0x%X.", __FUNCTION__, 0xFF & pkt_id);
378 383
@@ -416,7 +421,7 @@ static int gsp_send_ack(struct garmin_data * garmin_data_p, __u8 pkt_id)
416static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count) 421static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
417{ 422{
418 const __u8* recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET; 423 const __u8* recpkt = garmin_data_p->inbuffer+GSP_INITIAL_OFFSET;
419 __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer; 424 __le32 *usbdata = (__le32 *) garmin_data_p->inbuffer;
420 425
421 int cksum = 0; 426 int cksum = 0;
422 int n = 0; 427 int n = 0;
@@ -447,11 +452,11 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
447 n++; 452 n++;
448 } 453 }
449 454
450 if ((0xff & (cksum + *recpkt)) != 0) { 455 if ((0xff & (cksum + *recpkt)) != 0) {
451 dbg("%s - invalid checksum, expected %02x, got %02x", 456 dbg("%s - invalid checksum, expected %02x, got %02x",
452 __FUNCTION__, 0xff & -cksum, 0xff & *recpkt); 457 __FUNCTION__, 0xff & -cksum, 0xff & *recpkt);
453 return -EINVPKT; 458 return -EINVPKT;
454 } 459 }
455 460
456 usbdata[0] = __cpu_to_le32(GARMIN_LAYERID_APPL); 461 usbdata[0] = __cpu_to_le32(GARMIN_LAYERID_APPL);
457 usbdata[1] = __cpu_to_le32(pktid); 462 usbdata[1] = __cpu_to_le32(pktid);
@@ -491,20 +496,28 @@ static int gsp_rec_packet(struct garmin_data * garmin_data_p, int count)
491 */ 496 */
492 497
493static int gsp_receive(struct garmin_data * garmin_data_p, 498static int gsp_receive(struct garmin_data * garmin_data_p,
494 const unsigned char *buf, int count) 499 const unsigned char *buf, int count)
495{ 500{
501 unsigned long flags;
496 int offs = 0; 502 int offs = 0;
497 int ack_or_nak_seen = 0; 503 int ack_or_nak_seen = 0;
498 int i = 0; 504 int i = 0;
499 __u8 *dest = garmin_data_p->inbuffer; 505 __u8 *dest;
500 int size = garmin_data_p->insize; 506 int size;
501 // dleSeen: set if last byte read was a DLE 507 // dleSeen: set if last byte read was a DLE
502 int dleSeen = garmin_data_p->flags & FLAGS_GSP_DLESEEN; 508 int dleSeen;
503 // skip: if set, skip incoming data until possible start of 509 // skip: if set, skip incoming data until possible start of
504 // new packet 510 // new packet
505 int skip = garmin_data_p->flags & FLAGS_GSP_SKIP; 511 int skip;
506 __u8 data; 512 __u8 data;
507 513
514 spin_lock_irqsave(&garmin_data_p->lock, flags);
515 dest = garmin_data_p->inbuffer;
516 size = garmin_data_p->insize;
517 dleSeen = garmin_data_p->flags & FLAGS_GSP_DLESEEN;
518 skip = garmin_data_p->flags & FLAGS_GSP_SKIP;
519 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
520
508 dbg("%s - dle=%d skip=%d size=%d count=%d", 521 dbg("%s - dle=%d skip=%d size=%d count=%d",
509 __FUNCTION__, dleSeen, skip, size, count); 522 __FUNCTION__, dleSeen, skip, size, count);
510 523
@@ -572,6 +585,8 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
572 } 585 }
573 } 586 }
574 587
588 spin_lock_irqsave(&garmin_data_p->lock, flags);
589
575 garmin_data_p->insize = size; 590 garmin_data_p->insize = size;
576 591
577 // copy flags back to structure 592 // copy flags back to structure
@@ -587,6 +602,11 @@ static int gsp_receive(struct garmin_data * garmin_data_p,
587 602
588 if (ack_or_nak_seen) { 603 if (ack_or_nak_seen) {
589 garmin_data_p->state = STATE_GSP_WAIT_DATA; 604 garmin_data_p->state = STATE_GSP_WAIT_DATA;
605 }
606
607 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
608
609 if (ack_or_nak_seen) {
590 gsp_next_packet(garmin_data_p); 610 gsp_next_packet(garmin_data_p);
591 } 611 }
592 612
@@ -676,7 +696,7 @@ static int gsp_send(struct garmin_data * garmin_data_p,
676 src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH; 696 src = garmin_data_p->outbuffer+GARMIN_PKTHDR_LENGTH;
677 if (k > (GARMIN_PKTHDR_LENGTH-2)) { 697 if (k > (GARMIN_PKTHDR_LENGTH-2)) {
678 /* can't add stuffing DLEs in place, move data to end 698 /* can't add stuffing DLEs in place, move data to end
679 of buffer ... */ 699 of buffer ... */
680 dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen; 700 dst = garmin_data_p->outbuffer+GPS_OUT_BUFSIZ-datalen;
681 memcpy(dst, src, datalen); 701 memcpy(dst, src, datalen);
682 src = dst; 702 src = dst;
@@ -755,8 +775,9 @@ static void gsp_next_packet(struct garmin_data * garmin_data_p)
755 * or even incomplete packets 775 * or even incomplete packets
756 */ 776 */
757static int nat_receive(struct garmin_data * garmin_data_p, 777static int nat_receive(struct garmin_data * garmin_data_p,
758 const unsigned char *buf, int count) 778 const unsigned char *buf, int count)
759{ 779{
780 unsigned long flags;
760 __u8 * dest; 781 __u8 * dest;
761 int offs = 0; 782 int offs = 0;
762 int result = count; 783 int result = count;
@@ -803,7 +824,9 @@ static int nat_receive(struct garmin_data * garmin_data_p,
803 /* if this was an abort-transfer command, 824 /* if this was an abort-transfer command,
804 flush all queued data. */ 825 flush all queued data. */
805 if (isAbortTrfCmnd(garmin_data_p->inbuffer)) { 826 if (isAbortTrfCmnd(garmin_data_p->inbuffer)) {
827 spin_lock_irqsave(&garmin_data_p->lock, flags);
806 garmin_data_p->flags |= FLAGS_DROP_DATA; 828 garmin_data_p->flags |= FLAGS_DROP_DATA;
829 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
807 pkt_clear(garmin_data_p); 830 pkt_clear(garmin_data_p);
808 } 831 }
809 } 832 }
@@ -839,12 +862,15 @@ static void priv_status_resp(struct usb_serial_port *port)
839 862
840static int process_resetdev_request(struct usb_serial_port *port) 863static int process_resetdev_request(struct usb_serial_port *port)
841{ 864{
865 unsigned long flags;
842 int status; 866 int status;
843 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 867 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
844 868
869 spin_lock_irqsave(&garmin_data_p->lock, flags);
845 garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED); 870 garmin_data_p->flags &= ~(CLEAR_HALT_REQUIRED);
846 garmin_data_p->state = STATE_RESET; 871 garmin_data_p->state = STATE_RESET;
847 garmin_data_p->serial_num = 0; 872 garmin_data_p->serial_num = 0;
873 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
848 874
849 usb_kill_urb (port->interrupt_in_urb); 875 usb_kill_urb (port->interrupt_in_urb);
850 dbg("%s - usb_reset_device", __FUNCTION__ ); 876 dbg("%s - usb_reset_device", __FUNCTION__ );
@@ -862,6 +888,7 @@ static int process_resetdev_request(struct usb_serial_port *port)
862 */ 888 */
863static int garmin_clear(struct garmin_data * garmin_data_p) 889static int garmin_clear(struct garmin_data * garmin_data_p)
864{ 890{
891 unsigned long flags;
865 int status = 0; 892 int status = 0;
866 893
867 struct usb_serial_port *port = garmin_data_p->port; 894 struct usb_serial_port *port = garmin_data_p->port;
@@ -875,8 +902,10 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
875 /* flush all queued data */ 902 /* flush all queued data */
876 pkt_clear(garmin_data_p); 903 pkt_clear(garmin_data_p);
877 904
905 spin_lock_irqsave(&garmin_data_p->lock, flags);
878 garmin_data_p->insize = 0; 906 garmin_data_p->insize = 0;
879 garmin_data_p->outsize = 0; 907 garmin_data_p->outsize = 0;
908 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
880 909
881 return status; 910 return status;
882} 911}
@@ -888,6 +917,7 @@ static int garmin_clear(struct garmin_data * garmin_data_p)
888 917
889static int garmin_init_session(struct usb_serial_port *port) 918static int garmin_init_session(struct usb_serial_port *port)
890{ 919{
920 unsigned long flags;
891 struct usb_serial *serial = port->serial; 921 struct usb_serial *serial = port->serial;
892 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 922 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
893 int status = 0; 923 int status = 0;
@@ -913,7 +943,9 @@ static int garmin_init_session(struct usb_serial_port *port)
913 943
914 if (status >= 0) { 944 if (status >= 0) {
915 945
946 spin_lock_irqsave(&garmin_data_p->lock, flags);
916 garmin_data_p->ignorePkts++; 947 garmin_data_p->ignorePkts++;
948 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
917 949
918 /* not needed, but the win32 driver does it too ... */ 950 /* not needed, but the win32 driver does it too ... */
919 status = garmin_write_bulk(port, 951 status = garmin_write_bulk(port,
@@ -921,7 +953,9 @@ static int garmin_init_session(struct usb_serial_port *port)
921 sizeof(GARMIN_START_SESSION_REQ2)); 953 sizeof(GARMIN_START_SESSION_REQ2));
922 if (status >= 0) { 954 if (status >= 0) {
923 status = 0; 955 status = 0;
956 spin_lock_irqsave(&garmin_data_p->lock, flags);
924 garmin_data_p->ignorePkts++; 957 garmin_data_p->ignorePkts++;
958 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
925 } 959 }
926 } 960 }
927 } 961 }
@@ -935,6 +969,7 @@ static int garmin_init_session(struct usb_serial_port *port)
935 969
936static int garmin_open (struct usb_serial_port *port, struct file *filp) 970static int garmin_open (struct usb_serial_port *port, struct file *filp)
937{ 971{
972 unsigned long flags;
938 int status = 0; 973 int status = 0;
939 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 974 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
940 975
@@ -948,9 +983,11 @@ static int garmin_open (struct usb_serial_port *port, struct file *filp)
948 if (port->tty) 983 if (port->tty)
949 port->tty->low_latency = 1; 984 port->tty->low_latency = 1;
950 985
986 spin_lock_irqsave(&garmin_data_p->lock, flags);
951 garmin_data_p->mode = initial_mode; 987 garmin_data_p->mode = initial_mode;
952 garmin_data_p->count = 0; 988 garmin_data_p->count = 0;
953 garmin_data_p->flags = 0; 989 garmin_data_p->flags = 0;
990 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
954 991
955 /* shutdown any bulk reads that might be going on */ 992 /* shutdown any bulk reads that might be going on */
956 usb_kill_urb (port->write_urb); 993 usb_kill_urb (port->write_urb);
@@ -996,6 +1033,7 @@ static void garmin_close (struct usb_serial_port *port, struct file * filp)
996 1033
997static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs) 1034static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
998{ 1035{
1036 unsigned long flags;
999 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1037 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1000 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1038 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1001 1039
@@ -1007,7 +1045,9 @@ static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1007 if (urb->status) { 1045 if (urb->status) {
1008 dbg("%s - nonzero write bulk status received: %d", 1046 dbg("%s - nonzero write bulk status received: %d",
1009 __FUNCTION__, urb->status); 1047 __FUNCTION__, urb->status);
1048 spin_lock_irqsave(&garmin_data_p->lock, flags);
1010 garmin_data_p->flags |= CLEAR_HALT_REQUIRED; 1049 garmin_data_p->flags |= CLEAR_HALT_REQUIRED;
1050 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1011 } 1051 }
1012 1052
1013 usb_serial_port_softint(port); 1053 usb_serial_port_softint(port);
@@ -1015,8 +1055,9 @@ static void garmin_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
1015 1055
1016 1056
1017static int garmin_write_bulk (struct usb_serial_port *port, 1057static int garmin_write_bulk (struct usb_serial_port *port,
1018 const unsigned char *buf, int count) 1058 const unsigned char *buf, int count)
1019{ 1059{
1060 unsigned long flags;
1020 struct usb_serial *serial = port->serial; 1061 struct usb_serial *serial = port->serial;
1021 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1062 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1022 struct urb *urb; 1063 struct urb *urb;
@@ -1026,7 +1067,9 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1026 dbg("%s - port %d, state %d", __FUNCTION__, port->number, 1067 dbg("%s - port %d, state %d", __FUNCTION__, port->number,
1027 garmin_data_p->state); 1068 garmin_data_p->state);
1028 1069
1070 spin_lock_irqsave(&garmin_data_p->lock, flags);
1029 garmin_data_p->flags &= ~FLAGS_DROP_DATA; 1071 garmin_data_p->flags &= ~FLAGS_DROP_DATA;
1072 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1030 1073
1031 buffer = kmalloc (count, GFP_ATOMIC); 1074 buffer = kmalloc (count, GFP_ATOMIC);
1032 if (!buffer) { 1075 if (!buffer) {
@@ -1053,7 +1096,9 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1053 urb->transfer_flags |= URB_ZERO_PACKET; 1096 urb->transfer_flags |= URB_ZERO_PACKET;
1054 1097
1055 if (GARMIN_LAYERID_APPL == getLayerId(buffer)) { 1098 if (GARMIN_LAYERID_APPL == getLayerId(buffer)) {
1099 spin_lock_irqsave(&garmin_data_p->lock, flags);
1056 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN; 1100 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN;
1101 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1057 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { 1102 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
1058 pkt_clear(garmin_data_p); 1103 pkt_clear(garmin_data_p);
1059 garmin_data_p->state = STATE_GSP_WAIT_DATA; 1104 garmin_data_p->state = STATE_GSP_WAIT_DATA;
@@ -1087,8 +1132,9 @@ static int garmin_write_bulk (struct usb_serial_port *port,
1087 1132
1088 1133
1089static int garmin_write (struct usb_serial_port *port, 1134static int garmin_write (struct usb_serial_port *port,
1090 const unsigned char *buf, int count) 1135 const unsigned char *buf, int count)
1091{ 1136{
1137 unsigned long flags;
1092 int pktid, pktsiz, len; 1138 int pktid, pktsiz, len;
1093 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1139 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1094 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt; 1140 __le32 *privpkt = (__le32 *)garmin_data_p->privpkt;
@@ -1139,7 +1185,9 @@ static int garmin_write (struct usb_serial_port *port,
1139 break; 1185 break;
1140 1186
1141 case PRIV_PKTID_RESET_REQ: 1187 case PRIV_PKTID_RESET_REQ:
1188 spin_lock_irqsave(&garmin_data_p->lock, flags);
1142 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN; 1189 garmin_data_p->flags |= FLAGS_APP_REQ_SEEN;
1190 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1143 break; 1191 break;
1144 1192
1145 case PRIV_PKTID_SET_DEF_MODE: 1193 case PRIV_PKTID_SET_DEF_MODE:
@@ -1155,6 +1203,8 @@ static int garmin_write (struct usb_serial_port *port,
1155 } 1203 }
1156 } 1204 }
1157 1205
1206 garmin_data_p->ignorePkts = 0;
1207
1158 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) { 1208 if (garmin_data_p->mode == MODE_GARMIN_SERIAL) {
1159 return gsp_receive(garmin_data_p, buf, count); 1209 return gsp_receive(garmin_data_p, buf, count);
1160 } else { /* MODE_NATIVE */ 1210 } else { /* MODE_NATIVE */
@@ -1177,10 +1227,10 @@ static int garmin_chars_in_buffer (struct usb_serial_port *port)
1177{ 1227{
1178 /* 1228 /*
1179 * Report back the number of bytes currently in our input buffer. 1229 * Report back the number of bytes currently in our input buffer.
1180 * Will this lock up the driver - the buffer contains an incomplete 1230 * Will this lock up the driver - the buffer contains an incomplete
1181 * package which will not be written to the device until it 1231 * package which will not be written to the device until it
1182 * has been completed ? 1232 * has been completed ?
1183 */ 1233 */
1184 //struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1234 //struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1185 //return garmin_data_p->insize; 1235 //return garmin_data_p->insize;
1186 return 0; 1236 return 0;
@@ -1190,6 +1240,8 @@ static int garmin_chars_in_buffer (struct usb_serial_port *port)
1190static void garmin_read_process(struct garmin_data * garmin_data_p, 1240static void garmin_read_process(struct garmin_data * garmin_data_p,
1191 unsigned char *data, unsigned data_length) 1241 unsigned char *data, unsigned data_length)
1192{ 1242{
1243 unsigned long flags;
1244
1193 if (garmin_data_p->flags & FLAGS_DROP_DATA) { 1245 if (garmin_data_p->flags & FLAGS_DROP_DATA) {
1194 /* abort-transfer cmd is actice */ 1246 /* abort-transfer cmd is actice */
1195 dbg("%s - pkt dropped", __FUNCTION__); 1247 dbg("%s - pkt dropped", __FUNCTION__);
@@ -1200,11 +1252,14 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1200 if a reset is required or not when closing 1252 if a reset is required or not when closing
1201 the device */ 1253 the device */
1202 if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY, 1254 if (0 == memcmp(data, GARMIN_APP_LAYER_REPLY,
1203 sizeof(GARMIN_APP_LAYER_REPLY))) 1255 sizeof(GARMIN_APP_LAYER_REPLY))) {
1256 spin_lock_irqsave(&garmin_data_p->lock, flags);
1204 garmin_data_p->flags |= FLAGS_APP_RESP_SEEN; 1257 garmin_data_p->flags |= FLAGS_APP_RESP_SEEN;
1258 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1259 }
1205 1260
1206 /* if throttling is active or postprecessing is required 1261 /* if throttling is active or postprecessing is required
1207 put the received data in th input queue, otherwise 1262 put the received data in the input queue, otherwise
1208 send it directly to the tty port */ 1263 send it directly to the tty port */
1209 if (garmin_data_p->flags & FLAGS_QUEUING) { 1264 if (garmin_data_p->flags & FLAGS_QUEUING) {
1210 pkt_add(garmin_data_p, data, data_length); 1265 pkt_add(garmin_data_p, data, data_length);
@@ -1221,6 +1276,7 @@ static void garmin_read_process(struct garmin_data * garmin_data_p,
1221 1276
1222static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs) 1277static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1223{ 1278{
1279 unsigned long flags;
1224 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1280 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1225 struct usb_serial *serial = port->serial; 1281 struct usb_serial *serial = port->serial;
1226 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1282 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
@@ -1245,19 +1301,30 @@ static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1245 1301
1246 garmin_read_process(garmin_data_p, data, urb->actual_length); 1302 garmin_read_process(garmin_data_p, data, urb->actual_length);
1247 1303
1248 /* Continue trying to read until nothing more is received */ 1304 if (urb->actual_length == 0 &&
1249 if (urb->actual_length > 0) { 1305 0 != (garmin_data_p->flags & FLAGS_BULK_IN_RESTART)) {
1250 usb_fill_bulk_urb (port->read_urb, serial->dev, 1306 spin_lock_irqsave(&garmin_data_p->lock, flags);
1251 usb_rcvbulkpipe (serial->dev, 1307 garmin_data_p->flags &= ~FLAGS_BULK_IN_RESTART;
1252 port->bulk_in_endpointAddress), 1308 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1253 port->read_urb->transfer_buffer,
1254 port->read_urb->transfer_buffer_length,
1255 garmin_read_bulk_callback, port);
1256 status = usb_submit_urb(port->read_urb, GFP_ATOMIC); 1309 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1257 if (status) 1310 if (status)
1258 dev_err(&port->dev, 1311 dev_err(&port->dev,
1259 "%s - failed resubmitting read urb, error %d\n", 1312 "%s - failed resubmitting read urb, error %d\n",
1260 __FUNCTION__, status); 1313 __FUNCTION__, status);
1314 } else if (urb->actual_length > 0) {
1315 /* Continue trying to read until nothing more is received */
1316 if (0 == (garmin_data_p->flags & FLAGS_THROTTLED)) {
1317 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1318 if (status)
1319 dev_err(&port->dev,
1320 "%s - failed resubmitting read urb, error %d\n",
1321 __FUNCTION__, status);
1322 }
1323 } else {
1324 dbg("%s - end of bulk data", __FUNCTION__);
1325 spin_lock_irqsave(&garmin_data_p->lock, flags);
1326 garmin_data_p->flags &= ~FLAGS_BULK_IN_ACTIVE;
1327 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1261 } 1328 }
1262 return; 1329 return;
1263} 1330}
@@ -1265,6 +1332,7 @@ static void garmin_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
1265 1332
1266static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs) 1333static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs)
1267{ 1334{
1335 unsigned long flags;
1268 int status; 1336 int status;
1269 struct usb_serial_port *port = (struct usb_serial_port *)urb->context; 1337 struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
1270 struct usb_serial *serial = port->serial; 1338 struct usb_serial *serial = port->serial;
@@ -1297,25 +1365,41 @@ static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs)
1297 1365
1298 dbg("%s - bulk data available.", __FUNCTION__); 1366 dbg("%s - bulk data available.", __FUNCTION__);
1299 1367
1300 /* bulk data available */ 1368 if (0 == (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
1301 usb_fill_bulk_urb (port->read_urb, serial->dev, 1369
1302 usb_rcvbulkpipe (serial->dev, 1370 /* bulk data available */
1303 port->bulk_in_endpointAddress), 1371 usb_fill_bulk_urb (port->read_urb, serial->dev,
1304 port->read_urb->transfer_buffer, 1372 usb_rcvbulkpipe (serial->dev,
1305 port->read_urb->transfer_buffer_length, 1373 port->bulk_in_endpointAddress),
1306 garmin_read_bulk_callback, port); 1374 port->read_urb->transfer_buffer,
1307 status = usb_submit_urb(port->read_urb, GFP_KERNEL); 1375 port->read_urb->transfer_buffer_length,
1308 if (status) { 1376 garmin_read_bulk_callback, port);
1309 dev_err(&port->dev, 1377 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1310 "%s - failed submitting read urb, error %d\n", 1378 if (status) {
1311 __FUNCTION__, status); 1379 dev_err(&port->dev,
1380 "%s - failed submitting read urb, error %d\n",
1381 __FUNCTION__, status);
1382 } else {
1383 spin_lock_irqsave(&garmin_data_p->lock, flags);
1384 garmin_data_p->flags |= FLAGS_BULK_IN_ACTIVE;
1385 /* do not send this packet to the user */
1386 garmin_data_p->ignorePkts = 1;
1387 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1388 }
1389 } else {
1390 /* bulk-in transfer still active */
1391 spin_lock_irqsave(&garmin_data_p->lock, flags);
1392 garmin_data_p->flags |= FLAGS_BULK_IN_RESTART;
1393 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1312 } 1394 }
1313 1395
1314 } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY)) 1396 } else if (urb->actual_length == (4+sizeof(GARMIN_START_SESSION_REPLY))
1315 && 0 == memcmp(data, GARMIN_START_SESSION_REPLY, 1397 && 0 == memcmp(data, GARMIN_START_SESSION_REPLY,
1316 sizeof(GARMIN_START_SESSION_REPLY))) { 1398 sizeof(GARMIN_START_SESSION_REPLY))) {
1317 1399
1400 spin_lock_irqsave(&garmin_data_p->lock, flags);
1318 garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN; 1401 garmin_data_p->flags |= FLAGS_SESSION_REPLY1_SEEN;
1402 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1319 1403
1320 /* save the serial number */ 1404 /* save the serial number */
1321 garmin_data_p->serial_num 1405 garmin_data_p->serial_num
@@ -1330,7 +1414,9 @@ static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs)
1330 ignore it. */ 1414 ignore it. */
1331 dbg("%s - pkt ignored (%d)", 1415 dbg("%s - pkt ignored (%d)",
1332 __FUNCTION__, garmin_data_p->ignorePkts); 1416 __FUNCTION__, garmin_data_p->ignorePkts);
1417 spin_lock_irqsave(&garmin_data_p->lock, flags);
1333 garmin_data_p->ignorePkts--; 1418 garmin_data_p->ignorePkts--;
1419 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1334 } else { 1420 } else {
1335 garmin_read_process(garmin_data_p, data, urb->actual_length); 1421 garmin_read_process(garmin_data_p, data, urb->actual_length);
1336 } 1422 }
@@ -1351,18 +1437,20 @@ static void garmin_read_int_callback (struct urb *urb, struct pt_regs *regs)
1351 */ 1437 */
1352static int garmin_flush_queue(struct garmin_data * garmin_data_p) 1438static int garmin_flush_queue(struct garmin_data * garmin_data_p)
1353{ 1439{
1440 unsigned long flags;
1354 struct garmin_packet *pkt; 1441 struct garmin_packet *pkt;
1355 1442
1356 if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) { 1443 if ((garmin_data_p->flags & FLAGS_THROTTLED) == 0) {
1357 pkt = pkt_pop(garmin_data_p); 1444 pkt = pkt_pop(garmin_data_p);
1358 if (pkt != NULL) { 1445 if (pkt != NULL) {
1359
1360 send_to_tty(garmin_data_p->port, pkt->data, pkt->size); 1446 send_to_tty(garmin_data_p->port, pkt->data, pkt->size);
1361 kfree(pkt); 1447 kfree(pkt);
1362 mod_timer(&garmin_data_p->timer, (1)+jiffies); 1448 mod_timer(&garmin_data_p->timer, (1)+jiffies);
1363 1449
1364 } else { 1450 } else {
1451 spin_lock_irqsave(&garmin_data_p->lock, flags);
1365 garmin_data_p->flags &= ~FLAGS_QUEUING; 1452 garmin_data_p->flags &= ~FLAGS_QUEUING;
1453 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1366 } 1454 }
1367 } 1455 }
1368 return 0; 1456 return 0;
@@ -1371,26 +1459,41 @@ static int garmin_flush_queue(struct garmin_data * garmin_data_p)
1371 1459
1372static void garmin_throttle (struct usb_serial_port *port) 1460static void garmin_throttle (struct usb_serial_port *port)
1373{ 1461{
1462 unsigned long flags;
1374 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1463 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1375 1464
1376 dbg("%s - port %d", __FUNCTION__, port->number); 1465 dbg("%s - port %d", __FUNCTION__, port->number);
1377 /* set flag, data received will be put into a queue 1466 /* set flag, data received will be put into a queue
1378 for later processing */ 1467 for later processing */
1468 spin_lock_irqsave(&garmin_data_p->lock, flags);
1379 garmin_data_p->flags |= FLAGS_QUEUING|FLAGS_THROTTLED; 1469 garmin_data_p->flags |= FLAGS_QUEUING|FLAGS_THROTTLED;
1470 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1380} 1471}
1381 1472
1382 1473
1383static void garmin_unthrottle (struct usb_serial_port *port) 1474static void garmin_unthrottle (struct usb_serial_port *port)
1384{ 1475{
1476 unsigned long flags;
1385 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port); 1477 struct garmin_data * garmin_data_p = usb_get_serial_port_data(port);
1478 int status;
1386 1479
1387 dbg("%s - port %d", __FUNCTION__, port->number); 1480 dbg("%s - port %d", __FUNCTION__, port->number);
1481 spin_lock_irqsave(&garmin_data_p->lock, flags);
1388 garmin_data_p->flags &= ~FLAGS_THROTTLED; 1482 garmin_data_p->flags &= ~FLAGS_THROTTLED;
1483 spin_unlock_irqrestore(&garmin_data_p->lock, flags);
1389 1484
1390 /* in native mode send queued data to tty, in 1485 /* in native mode send queued data to tty, in
1391 serial mode nothing needs to be done here */ 1486 serial mode nothing needs to be done here */
1392 if (garmin_data_p->mode == MODE_NATIVE) 1487 if (garmin_data_p->mode == MODE_NATIVE)
1393 garmin_flush_queue(garmin_data_p); 1488 garmin_flush_queue(garmin_data_p);
1489
1490 if (0 != (garmin_data_p->flags & FLAGS_BULK_IN_ACTIVE)) {
1491 status = usb_submit_urb(port->read_urb, GFP_ATOMIC);
1492 if (status)
1493 dev_err(&port->dev,
1494 "%s - failed resubmitting read urb, error %d\n",
1495 __FUNCTION__, status);
1496 }
1394} 1497}
1395 1498
1396 1499
@@ -1420,11 +1523,12 @@ static int garmin_attach (struct usb_serial *serial)
1420 1523
1421 dbg("%s", __FUNCTION__); 1524 dbg("%s", __FUNCTION__);
1422 1525
1423 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); 1526 garmin_data_p = kmalloc (sizeof(struct garmin_data), GFP_KERNEL);
1424 if (garmin_data_p == NULL) { 1527 if (garmin_data_p == NULL) {
1425 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__); 1528 dev_err(&port->dev, "%s - Out of memory\n", __FUNCTION__);
1426 return -ENOMEM; 1529 return -ENOMEM;
1427 } 1530 }
1531 memset (garmin_data_p, 0, sizeof(struct garmin_data));
1428 init_timer(&garmin_data_p->timer); 1532 init_timer(&garmin_data_p->timer);
1429 spin_lock_init(&garmin_data_p->lock); 1533 spin_lock_init(&garmin_data_p->lock);
1430 INIT_LIST_HEAD(&garmin_data_p->pktlist); 1534 INIT_LIST_HEAD(&garmin_data_p->pktlist);
@@ -1459,10 +1563,10 @@ static void garmin_shutdown (struct usb_serial *serial)
1459/* All of the device info needed */ 1563/* All of the device info needed */
1460static struct usb_serial_driver garmin_device = { 1564static struct usb_serial_driver garmin_device = {
1461 .driver = { 1565 .driver = {
1462 .owner = THIS_MODULE, 1566 .owner = THIS_MODULE,
1463 .name = "garmin_gps", 1567 .name = "garmin_gps",
1464 }, 1568 },
1465 .description = "Garmin GPS usb/tty", 1569 .description = "Garmin GPS usb/tty",
1466 .id_table = id_table, 1570 .id_table = id_table,
1467 .num_interrupt_in = 1, 1571 .num_interrupt_in = 1,
1468 .num_bulk_in = 1, 1572 .num_bulk_in = 1,
@@ -1483,6 +1587,7 @@ static struct usb_serial_driver garmin_device = {
1483}; 1587};
1484 1588
1485 1589
1590
1486static int __init garmin_init (void) 1591static int __init garmin_init (void)
1487{ 1592{
1488 int retval; 1593 int retval;
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index 9840bade79f9..bfc6998cd16f 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -652,11 +652,6 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
652 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE; 652 port->bulk_out_size = port->write_urb->transfer_buffer_length = URBDATA_SIZE;
653 653
654 msleep(1000*initial_wait); 654 msleep(1000*initial_wait);
655 /* Start reading from the device */
656 usb_fill_bulk_urb(port->read_urb, serial->dev,
657 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
658 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
659 ipaq_read_bulk_callback, port);
660 655
661 /* 656 /*
662 * Send out control message observed in win98 sniffs. Not sure what 657 * Send out control message observed in win98 sniffs. Not sure what
@@ -670,18 +665,31 @@ static int ipaq_open(struct usb_serial_port *port, struct file *filp)
670 result = usb_control_msg(serial->dev, 665 result = usb_control_msg(serial->dev,
671 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, 666 usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21,
672 0x1, 0, NULL, 0, 100); 667 0x1, 0, NULL, 0, 100);
673 if (result == 0) { 668 if (!result)
674 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 669 break;
675 if (result) { 670
676 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
677 goto error;
678 }
679 return 0;
680 }
681 msleep(1000); 671 msleep(1000);
682 } 672 }
683 err("%s - failed doing control urb, error %d", __FUNCTION__, result); 673
684 goto error; 674 if (!retries && result) {
675 err("%s - failed doing control urb, error %d", __FUNCTION__,
676 result);
677 goto error;
678 }
679
680 /* Start reading from the device */
681 usb_fill_bulk_urb(port->read_urb, serial->dev,
682 usb_rcvbulkpipe(serial->dev, port->bulk_in_endpointAddress),
683 port->read_urb->transfer_buffer, port->read_urb->transfer_buffer_length,
684 ipaq_read_bulk_callback, port);
685
686 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
687 if (result) {
688 err("%s - failed submitting read urb, error %d", __FUNCTION__, result);
689 goto error;
690 }
691
692 return 0;
685 693
686enomem: 694enomem:
687 result = -ENOMEM; 695 result = -ENOMEM;
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
new file mode 100644
index 000000000000..95bf57166c59
--- /dev/null
+++ b/drivers/usb/serial/mos7840.c
@@ -0,0 +1,2962 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 *
16 * Clean ups from Moschip version and a few ioctl implementations by:
17 * Paul B Schroeder <pschroeder "at" uplogix "dot" com>
18 *
19 * Originally based on drivers/usb/serial/io_edgeport.c which is:
20 * Copyright (C) 2000 Inside Out Networks, All rights reserved.
21 * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
22 *
23 */
24
25#include <linux/kernel.h>
26#include <linux/errno.h>
27#include <linux/init.h>
28#include <linux/slab.h>
29#include <linux/tty.h>
30#include <linux/tty_driver.h>
31#include <linux/tty_flip.h>
32#include <linux/module.h>
33#include <linux/serial.h>
34#include <linux/usb.h>
35#include <linux/usb/serial.h>
36#include <asm/uaccess.h>
37
38/*
39 * Version Information
40 */
41#define DRIVER_VERSION "1.3.1"
42#define DRIVER_DESC "Moschip 7840/7820 USB Serial Driver"
43
44/*
45 * 16C50 UART register defines
46 */
47
48#define LCR_BITS_5 0x00 /* 5 bits/char */
49#define LCR_BITS_6 0x01 /* 6 bits/char */
50#define LCR_BITS_7 0x02 /* 7 bits/char */
51#define LCR_BITS_8 0x03 /* 8 bits/char */
52#define LCR_BITS_MASK 0x03 /* Mask for bits/char field */
53
54#define LCR_STOP_1 0x00 /* 1 stop bit */
55#define LCR_STOP_1_5 0x04 /* 1.5 stop bits (if 5 bits/char) */
56#define LCR_STOP_2 0x04 /* 2 stop bits (if 6-8 bits/char) */
57#define LCR_STOP_MASK 0x04 /* Mask for stop bits field */
58
59#define LCR_PAR_NONE 0x00 /* No parity */
60#define LCR_PAR_ODD 0x08 /* Odd parity */
61#define LCR_PAR_EVEN 0x18 /* Even parity */
62#define LCR_PAR_MARK 0x28 /* Force parity bit to 1 */
63#define LCR_PAR_SPACE 0x38 /* Force parity bit to 0 */
64#define LCR_PAR_MASK 0x38 /* Mask for parity field */
65
66#define LCR_SET_BREAK 0x40 /* Set Break condition */
67#define LCR_DL_ENABLE 0x80 /* Enable access to divisor latch */
68
69#define MCR_DTR 0x01 /* Assert DTR */
70#define MCR_RTS 0x02 /* Assert RTS */
71#define MCR_OUT1 0x04 /* Loopback only: Sets state of RI */
72#define MCR_MASTER_IE 0x08 /* Enable interrupt outputs */
73#define MCR_LOOPBACK 0x10 /* Set internal (digital) loopback mode */
74#define MCR_XON_ANY 0x20 /* Enable any char to exit XOFF mode */
75
76#define MOS7840_MSR_CTS 0x10 /* Current state of CTS */
77#define MOS7840_MSR_DSR 0x20 /* Current state of DSR */
78#define MOS7840_MSR_RI 0x40 /* Current state of RI */
79#define MOS7840_MSR_CD 0x80 /* Current state of CD */
80
81/*
82 * Defines used for sending commands to port
83 */
84
85#define WAIT_FOR_EVER (HZ * 0 ) /* timeout urb is wait for ever */
86#define MOS_WDR_TIMEOUT (HZ * 5 ) /* default urb timeout */
87
88#define MOS_PORT1 0x0200
89#define MOS_PORT2 0x0300
90#define MOS_VENREG 0x0000
91#define MOS_MAX_PORT 0x02
92#define MOS_WRITE 0x0E
93#define MOS_READ 0x0D
94
95/* Requests */
96#define MCS_RD_RTYPE 0xC0
97#define MCS_WR_RTYPE 0x40
98#define MCS_RDREQ 0x0D
99#define MCS_WRREQ 0x0E
100#define MCS_CTRL_TIMEOUT 500
101#define VENDOR_READ_LENGTH (0x01)
102
103#define MAX_NAME_LEN 64
104
105#define ZLP_REG1 0x3A //Zero_Flag_Reg1 58
106#define ZLP_REG5 0x3E //Zero_Flag_Reg5 62
107
108/* For higher baud Rates use TIOCEXBAUD */
109#define TIOCEXBAUD 0x5462
110
111/* vendor id and device id defines */
112
113#define USB_VENDOR_ID_MOSCHIP 0x9710
114#define MOSCHIP_DEVICE_ID_7840 0x7840
115#define MOSCHIP_DEVICE_ID_7820 0x7820
116
117/* Interrupt Rotinue Defines */
118
119#define SERIAL_IIR_RLS 0x06
120#define SERIAL_IIR_MS 0x00
121
122/*
123 * Emulation of the bit mask on the LINE STATUS REGISTER.
124 */
125#define SERIAL_LSR_DR 0x0001
126#define SERIAL_LSR_OE 0x0002
127#define SERIAL_LSR_PE 0x0004
128#define SERIAL_LSR_FE 0x0008
129#define SERIAL_LSR_BI 0x0010
130
131#define MOS_MSR_DELTA_CTS 0x10
132#define MOS_MSR_DELTA_DSR 0x20
133#define MOS_MSR_DELTA_RI 0x40
134#define MOS_MSR_DELTA_CD 0x80
135
136// Serial Port register Address
137#define INTERRUPT_ENABLE_REGISTER ((__u16)(0x01))
138#define FIFO_CONTROL_REGISTER ((__u16)(0x02))
139#define LINE_CONTROL_REGISTER ((__u16)(0x03))
140#define MODEM_CONTROL_REGISTER ((__u16)(0x04))
141#define LINE_STATUS_REGISTER ((__u16)(0x05))
142#define MODEM_STATUS_REGISTER ((__u16)(0x06))
143#define SCRATCH_PAD_REGISTER ((__u16)(0x07))
144#define DIVISOR_LATCH_LSB ((__u16)(0x00))
145#define DIVISOR_LATCH_MSB ((__u16)(0x01))
146
147#define CLK_MULTI_REGISTER ((__u16)(0x02))
148#define CLK_START_VALUE_REGISTER ((__u16)(0x03))
149
150#define SERIAL_LCR_DLAB ((__u16)(0x0080))
151
152/*
153 * URB POOL related defines
154 */
155#define NUM_URBS 16 /* URB Count */
156#define URB_TRANSFER_BUFFER_SIZE 32 /* URB Size */
157
158
159static struct usb_device_id moschip_port_id_table[] = {
160 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
161 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
162 {} /* terminating entry */
163};
164
165static __devinitdata struct usb_device_id moschip_id_table_combined[] = {
166 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7840)},
167 {USB_DEVICE(USB_VENDOR_ID_MOSCHIP, MOSCHIP_DEVICE_ID_7820)},
168 {} /* terminating entry */
169};
170
171MODULE_DEVICE_TABLE(usb, moschip_id_table_combined);
172
173/* This structure holds all of the local port information */
174
175struct moschip_port {
176 int port_num; /*Actual port number in the device(1,2,etc) */
177 struct urb *write_urb; /* write URB for this port */
178 struct urb *read_urb; /* read URB for this port */
179 __u8 shadowLCR; /* last LCR value received */
180 __u8 shadowMCR; /* last MCR value received */
181 char open;
182 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */
183 wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */
184 int delta_msr_cond;
185 struct async_icount icount;
186 struct usb_serial_port *port; /* loop back to the owner of this object */
187
188 /*Offsets */
189 __u8 SpRegOffset;
190 __u8 ControlRegOffset;
191 __u8 DcrRegOffset;
192 //for processing control URBS in interrupt context
193 struct urb *control_urb;
194 char *ctrl_buf;
195 int MsrLsr;
196
197 struct urb *write_urb_pool[NUM_URBS];
198};
199
200
201static int debug;
202static int mos7840_num_ports; //this says the number of ports in the device
203static int mos7840_num_open_ports;
204
205
206/*
207 * mos7840_set_reg_sync
208 * To set the Control register by calling usb_fill_control_urb function
209 * by passing usb_sndctrlpipe function as parameter.
210 */
211
212static int mos7840_set_reg_sync(struct usb_serial_port *port, __u16 reg,
213 __u16 val)
214{
215 struct usb_device *dev = port->serial->dev;
216 val = val & 0x00ff;
217 dbg("mos7840_set_reg_sync offset is %x, value %x\n", reg, val);
218
219 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
220 MCS_WR_RTYPE, val, reg, NULL, 0,
221 MOS_WDR_TIMEOUT);
222}
223
224/*
225 * mos7840_get_reg_sync
226 * To set the Uart register by calling usb_fill_control_urb function by
227 * passing usb_rcvctrlpipe function as parameter.
228 */
229
230static int mos7840_get_reg_sync(struct usb_serial_port *port, __u16 reg,
231 __u16 * val)
232{
233 struct usb_device *dev = port->serial->dev;
234 int ret = 0;
235
236 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
237 MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH,
238 MOS_WDR_TIMEOUT);
239 dbg("mos7840_get_reg_sync offset is %x, return val %x\n", reg, *val);
240 *val = (*val) & 0x00ff;
241 return ret;
242}
243
244/*
245 * mos7840_set_uart_reg
246 * To set the Uart register by calling usb_fill_control_urb function by
247 * passing usb_sndctrlpipe function as parameter.
248 */
249
250static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg,
251 __u16 val)
252{
253
254 struct usb_device *dev = port->serial->dev;
255 val = val & 0x00ff;
256 // For the UART control registers, the application number need to be Or'ed
257 if (mos7840_num_ports == 4) {
258 val |=
259 (((__u16) port->number - (__u16) (port->serial->minor)) +
260 1) << 8;
261 dbg("mos7840_set_uart_reg application number is %x\n", val);
262 } else {
263 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
264 val |=
265 (((__u16) port->number -
266 (__u16) (port->serial->minor)) + 1) << 8;
267 dbg("mos7840_set_uart_reg application number is %x\n",
268 val);
269 } else {
270 val |=
271 (((__u16) port->number -
272 (__u16) (port->serial->minor)) + 2) << 8;
273 dbg("mos7840_set_uart_reg application number is %x\n",
274 val);
275 }
276 }
277 return usb_control_msg(dev, usb_sndctrlpipe(dev, 0), MCS_WRREQ,
278 MCS_WR_RTYPE, val, reg, NULL, 0,
279 MOS_WDR_TIMEOUT);
280
281}
282
283/*
284 * mos7840_get_uart_reg
285 * To set the Control register by calling usb_fill_control_urb function
286 * by passing usb_rcvctrlpipe function as parameter.
287 */
288static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg,
289 __u16 * val)
290{
291 struct usb_device *dev = port->serial->dev;
292 int ret = 0;
293 __u16 Wval;
294
295 //dbg("application number is %4x \n",(((__u16)port->number - (__u16)(port->serial->minor))+1)<<8);
296 /*Wval is same as application number */
297 if (mos7840_num_ports == 4) {
298 Wval =
299 (((__u16) port->number - (__u16) (port->serial->minor)) +
300 1) << 8;
301 dbg("mos7840_get_uart_reg application number is %x\n", Wval);
302 } else {
303 if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) {
304 Wval =
305 (((__u16) port->number -
306 (__u16) (port->serial->minor)) + 1) << 8;
307 dbg("mos7840_get_uart_reg application number is %x\n",
308 Wval);
309 } else {
310 Wval =
311 (((__u16) port->number -
312 (__u16) (port->serial->minor)) + 2) << 8;
313 dbg("mos7840_get_uart_reg application number is %x\n",
314 Wval);
315 }
316 }
317 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
318 MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH,
319 MOS_WDR_TIMEOUT);
320 *val = (*val) & 0x00ff;
321 return ret;
322}
323
324static void mos7840_dump_serial_port(struct moschip_port *mos7840_port)
325{
326
327 dbg("***************************************\n");
328 dbg("SpRegOffset is %2x\n", mos7840_port->SpRegOffset);
329 dbg("ControlRegOffset is %2x \n", mos7840_port->ControlRegOffset);
330 dbg("DCRRegOffset is %2x \n", mos7840_port->DcrRegOffset);
331 dbg("***************************************\n");
332
333}
334
335/************************************************************************/
336/************************************************************************/
337/* I N T E R F A C E F U N C T I O N S */
338/* I N T E R F A C E F U N C T I O N S */
339/************************************************************************/
340/************************************************************************/
341
342static inline void mos7840_set_port_private(struct usb_serial_port *port,
343 struct moschip_port *data)
344{
345 usb_set_serial_port_data(port, (void *)data);
346}
347
348static inline struct moschip_port *mos7840_get_port_private(struct
349 usb_serial_port
350 *port)
351{
352 return (struct moschip_port *)usb_get_serial_port_data(port);
353}
354
355static int mos7840_handle_new_msr(struct moschip_port *port, __u8 new_msr)
356{
357 struct moschip_port *mos7840_port;
358 struct async_icount *icount;
359 mos7840_port = port;
360 icount = &mos7840_port->icount;
361 if (new_msr &
362 (MOS_MSR_DELTA_CTS | MOS_MSR_DELTA_DSR | MOS_MSR_DELTA_RI |
363 MOS_MSR_DELTA_CD)) {
364 icount = &mos7840_port->icount;
365
366 /* update input line counters */
367 if (new_msr & MOS_MSR_DELTA_CTS) {
368 icount->cts++;
369 }
370 if (new_msr & MOS_MSR_DELTA_DSR) {
371 icount->dsr++;
372 }
373 if (new_msr & MOS_MSR_DELTA_CD) {
374 icount->dcd++;
375 }
376 if (new_msr & MOS_MSR_DELTA_RI) {
377 icount->rng++;
378 }
379 }
380
381 return 0;
382}
383
384static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
385{
386 struct async_icount *icount;
387
388 dbg("%s - %02x", __FUNCTION__, new_lsr);
389
390 if (new_lsr & SERIAL_LSR_BI) {
391 //
392 // Parity and Framing errors only count if they
393 // occur exclusive of a break being
394 // received.
395 //
396 new_lsr &= (__u8) (SERIAL_LSR_OE | SERIAL_LSR_BI);
397 }
398
399 /* update input line counters */
400 icount = &port->icount;
401 if (new_lsr & SERIAL_LSR_BI) {
402 icount->brk++;
403 }
404 if (new_lsr & SERIAL_LSR_OE) {
405 icount->overrun++;
406 }
407 if (new_lsr & SERIAL_LSR_PE) {
408 icount->parity++;
409 }
410 if (new_lsr & SERIAL_LSR_FE) {
411 icount->frame++;
412 }
413
414 return 0;
415}
416
417/************************************************************************/
418/************************************************************************/
419/* U S B C A L L B A C K F U N C T I O N S */
420/* U S B C A L L B A C K F U N C T I O N S */
421/************************************************************************/
422/************************************************************************/
423
424static void mos7840_control_callback(struct urb *urb, struct pt_regs *regs)
425{
426 unsigned char *data;
427 struct moschip_port *mos7840_port;
428 __u8 regval = 0x0;
429
430 if (!urb) {
431 dbg("%s", "Invalid Pointer !!!!:\n");
432 return;
433 }
434
435 switch (urb->status) {
436 case 0:
437 /* success */
438 break;
439 case -ECONNRESET:
440 case -ENOENT:
441 case -ESHUTDOWN:
442 /* this urb is terminated, clean up */
443 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
444 urb->status);
445 return;
446 default:
447 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
448 urb->status);
449 goto exit;
450 }
451
452 mos7840_port = (struct moschip_port *)urb->context;
453
454 dbg("%s urb buffer size is %d\n", __FUNCTION__, urb->actual_length);
455 dbg("%s mos7840_port->MsrLsr is %d port %d\n", __FUNCTION__,
456 mos7840_port->MsrLsr, mos7840_port->port_num);
457 data = urb->transfer_buffer;
458 regval = (__u8) data[0];
459 dbg("%s data is %x\n", __FUNCTION__, regval);
460 if (mos7840_port->MsrLsr == 0)
461 mos7840_handle_new_msr(mos7840_port, regval);
462 else if (mos7840_port->MsrLsr == 1)
463 mos7840_handle_new_lsr(mos7840_port, regval);
464
465 exit:
466 return;
467}
468
469static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
470 __u16 * val)
471{
472 struct usb_device *dev = mcs->port->serial->dev;
473 struct usb_ctrlrequest *dr = NULL;
474 unsigned char *buffer = NULL;
475 int ret = 0;
476 buffer = (__u8 *) mcs->ctrl_buf;
477
478// dr=(struct usb_ctrlrequest *)(buffer);
479 dr = (void *)(buffer + 2);
480 dr->bRequestType = MCS_RD_RTYPE;
481 dr->bRequest = MCS_RDREQ;
482 dr->wValue = cpu_to_le16(Wval); //0;
483 dr->wIndex = cpu_to_le16(reg);
484 dr->wLength = cpu_to_le16(2);
485
486 usb_fill_control_urb(mcs->control_urb, dev, usb_rcvctrlpipe(dev, 0),
487 (unsigned char *)dr, buffer, 2,
488 mos7840_control_callback, mcs);
489 mcs->control_urb->transfer_buffer_length = 2;
490 ret = usb_submit_urb(mcs->control_urb, GFP_ATOMIC);
491 return ret;
492}
493
494/*****************************************************************************
495 * mos7840_interrupt_callback
496 * this is the callback function for when we have received data on the
497 * interrupt endpoint.
498 *****************************************************************************/
499
500static void mos7840_interrupt_callback(struct urb *urb, struct pt_regs *regs)
501{
502 int result;
503 int length;
504 struct moschip_port *mos7840_port;
505 struct usb_serial *serial;
506 __u16 Data;
507 unsigned char *data;
508 __u8 sp[5], st;
509 int i;
510 __u16 wval;
511
512 dbg("%s", " : Entering\n");
513 if (!urb) {
514 dbg("%s", "Invalid Pointer !!!!:\n");
515 return;
516 }
517
518 switch (urb->status) {
519 case 0:
520 /* success */
521 break;
522 case -ECONNRESET:
523 case -ENOENT:
524 case -ESHUTDOWN:
525 /* this urb is terminated, clean up */
526 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
527 urb->status);
528 return;
529 default:
530 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
531 urb->status);
532 goto exit;
533 }
534
535 length = urb->actual_length;
536 data = urb->transfer_buffer;
537
538 serial = (struct usb_serial *)urb->context;
539
540 /* Moschip get 5 bytes
541 * Byte 1 IIR Port 1 (port.number is 0)
542 * Byte 2 IIR Port 2 (port.number is 1)
543 * Byte 3 IIR Port 3 (port.number is 2)
544 * Byte 4 IIR Port 4 (port.number is 3)
545 * Byte 5 FIFO status for both */
546
547 if (length && length > 5) {
548 dbg("%s \n", "Wrong data !!!");
549 return;
550 }
551
552 sp[0] = (__u8) data[0];
553 sp[1] = (__u8) data[1];
554 sp[2] = (__u8) data[2];
555 sp[3] = (__u8) data[3];
556 st = (__u8) data[4];
557
558 for (i = 0; i < serial->num_ports; i++) {
559 mos7840_port = mos7840_get_port_private(serial->port[i]);
560 wval =
561 (((__u16) serial->port[i]->number -
562 (__u16) (serial->minor)) + 1) << 8;
563 if (mos7840_port->open) {
564 if (sp[i] & 0x01) {
565 dbg("SP%d No Interrupt !!!\n", i);
566 } else {
567 switch (sp[i] & 0x0f) {
568 case SERIAL_IIR_RLS:
569 dbg("Serial Port %d: Receiver status error or ", i);
570 dbg("address bit detected in 9-bit mode\n");
571 mos7840_port->MsrLsr = 1;
572 mos7840_get_reg(mos7840_port, wval,
573 LINE_STATUS_REGISTER,
574 &Data);
575 break;
576 case SERIAL_IIR_MS:
577 dbg("Serial Port %d: Modem status change\n", i);
578 mos7840_port->MsrLsr = 0;
579 mos7840_get_reg(mos7840_port, wval,
580 MODEM_STATUS_REGISTER,
581 &Data);
582 break;
583 }
584 }
585 }
586 }
587 exit:
588 result = usb_submit_urb(urb, GFP_ATOMIC);
589 if (result) {
590 dev_err(&urb->dev->dev,
591 "%s - Error %d submitting interrupt urb\n",
592 __FUNCTION__, result);
593 }
594
595 return;
596
597}
598
599static int mos7840_port_paranoia_check(struct usb_serial_port *port,
600 const char *function)
601{
602 if (!port) {
603 dbg("%s - port == NULL", function);
604 return -1;
605 }
606 if (!port->serial) {
607 dbg("%s - port->serial == NULL", function);
608 return -1;
609 }
610
611 return 0;
612}
613
614/* Inline functions to check the sanity of a pointer that is passed to us */
615static int mos7840_serial_paranoia_check(struct usb_serial *serial,
616 const char *function)
617{
618 if (!serial) {
619 dbg("%s - serial == NULL", function);
620 return -1;
621 }
622 if (!serial->type) {
623 dbg("%s - serial->type == NULL!", function);
624 return -1;
625 }
626
627 return 0;
628}
629
630static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
631 const char *function)
632{
633 /* if no port was specified, or it fails a paranoia check */
634 if (!port ||
635 mos7840_port_paranoia_check(port, function) ||
636 mos7840_serial_paranoia_check(port->serial, function)) {
637 /* then say that we don't have a valid usb_serial thing, which will * end up genrating -ENODEV return values */
638 return NULL;
639 }
640
641 return port->serial;
642}
643
644/*****************************************************************************
645 * mos7840_bulk_in_callback
646 * this is the callback function for when we have received data on the
647 * bulk in endpoint.
648 *****************************************************************************/
649
650static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
651{
652 int status;
653 unsigned char *data;
654 struct usb_serial *serial;
655 struct usb_serial_port *port;
656 struct moschip_port *mos7840_port;
657 struct tty_struct *tty;
658
659 if (!urb) {
660 dbg("%s", "Invalid Pointer !!!!:\n");
661 return;
662 }
663
664 if (urb->status) {
665 dbg("nonzero read bulk status received: %d", urb->status);
666 return;
667 }
668
669 mos7840_port = (struct moschip_port *)urb->context;
670 if (!mos7840_port) {
671 dbg("%s", "NULL mos7840_port pointer \n");
672 return;
673 }
674
675 port = (struct usb_serial_port *)mos7840_port->port;
676 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
677 dbg("%s", "Port Paranoia failed \n");
678 return;
679 }
680
681 serial = mos7840_get_usb_serial(port, __FUNCTION__);
682 if (!serial) {
683 dbg("%s\n", "Bad serial pointer ");
684 return;
685 }
686
687 dbg("%s\n", "Entering... \n");
688
689 data = urb->transfer_buffer;
690
691 dbg("%s", "Entering ........... \n");
692
693 if (urb->actual_length) {
694 tty = mos7840_port->port->tty;
695 if (tty) {
696 tty_buffer_request_room(tty, urb->actual_length);
697 tty_insert_flip_string(tty, data, urb->actual_length);
698 dbg(" %s \n", data);
699 tty_flip_buffer_push(tty);
700 }
701 mos7840_port->icount.rx += urb->actual_length;
702 dbg("mos7840_port->icount.rx is %d:\n",
703 mos7840_port->icount.rx);
704 }
705
706 if (!mos7840_port->read_urb) {
707 dbg("%s", "URB KILLED !!!\n");
708 return;
709 }
710
711 if (mos7840_port->read_urb->status != -EINPROGRESS) {
712 mos7840_port->read_urb->dev = serial->dev;
713
714 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
715
716 if (status) {
717 dbg(" usb_submit_urb(read bulk) failed, status = %d",
718 status);
719 }
720 }
721}
722
723/*****************************************************************************
724 * mos7840_bulk_out_data_callback
725 * this is the callback function for when we have finished sending serial data
726 * on the bulk out endpoint.
727 *****************************************************************************/
728
729static void mos7840_bulk_out_data_callback(struct urb *urb,
730 struct pt_regs *regs)
731{
732 struct moschip_port *mos7840_port;
733 struct tty_struct *tty;
734 if (!urb) {
735 dbg("%s", "Invalid Pointer !!!!:\n");
736 return;
737 }
738
739 if (urb->status) {
740 dbg("nonzero write bulk status received:%d\n", urb->status);
741 return;
742 }
743
744 mos7840_port = (struct moschip_port *)urb->context;
745 if (!mos7840_port) {
746 dbg("%s", "NULL mos7840_port pointer \n");
747 return;
748 }
749
750 if (mos7840_port_paranoia_check(mos7840_port->port, __FUNCTION__)) {
751 dbg("%s", "Port Paranoia failed \n");
752 return;
753 }
754
755 dbg("%s \n", "Entering .........");
756
757 tty = mos7840_port->port->tty;
758
759 if (tty && mos7840_port->open) {
760 /* let the tty driver wakeup if it has a special *
761 * write_wakeup function */
762
763 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
764 && tty->ldisc.write_wakeup) {
765 (tty->ldisc.write_wakeup) (tty);
766 }
767
768 /* tell the tty driver that something has changed */
769 wake_up_interruptible(&tty->write_wait);
770 }
771
772}
773
774/************************************************************************/
775/* D R I V E R T T Y I N T E R F A C E F U N C T I O N S */
776/************************************************************************/
777#ifdef MCSSerialProbe
778static int mos7840_serial_probe(struct usb_serial *serial,
779 const struct usb_device_id *id)
780{
781
782 /*need to implement the mode_reg reading and updating\
783 structures usb_serial_ device_type\
784 (i.e num_ports, num_bulkin,bulkout etc) */
785 /* Also we can update the changes attach */
786 return 1;
787}
788#endif
789
790/*****************************************************************************
791 * mos7840_open
792 * this function is called by the tty driver when a port is opened
793 * If successful, we return 0
794 * Otherwise we return a negative error number.
795 *****************************************************************************/
796
797static int mos7840_open(struct usb_serial_port *port, struct file *filp)
798{
799 int response;
800 int j;
801 struct usb_serial *serial;
802 struct urb *urb;
803 __u16 Data;
804 int status;
805 struct moschip_port *mos7840_port;
806
807 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
808 dbg("%s", "Port Paranoia failed \n");
809 return -ENODEV;
810 }
811
812 mos7840_num_open_ports++;
813 serial = port->serial;
814
815 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) {
816 dbg("%s", "Serial Paranoia failed \n");
817 return -ENODEV;
818 }
819
820 mos7840_port = mos7840_get_port_private(port);
821
822 if (mos7840_port == NULL)
823 return -ENODEV;
824
825 usb_clear_halt(serial->dev, port->write_urb->pipe);
826 usb_clear_halt(serial->dev, port->read_urb->pipe);
827
828 /* Initialising the write urb pool */
829 for (j = 0; j < NUM_URBS; ++j) {
830 urb = usb_alloc_urb(0, SLAB_ATOMIC);
831 mos7840_port->write_urb_pool[j] = urb;
832
833 if (urb == NULL) {
834 err("No more urbs???");
835 continue;
836 }
837
838 urb->transfer_buffer = NULL;
839 urb->transfer_buffer =
840 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
841 if (!urb->transfer_buffer) {
842 err("%s-out of memory for urb buffers.", __FUNCTION__);
843 continue;
844 }
845 }
846
847/*****************************************************************************
848 * Initialize MCS7840 -- Write Init values to corresponding Registers
849 *
850 * Register Index
851 * 1 : IER
852 * 2 : FCR
853 * 3 : LCR
854 * 4 : MCR
855 *
856 * 0x08 : SP1/2 Control Reg
857 *****************************************************************************/
858
859//NEED to check the following Block
860
861 status = 0;
862 Data = 0x0;
863 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
864 if (status < 0) {
865 dbg("Reading Spreg failed\n");
866 return -1;
867 }
868 Data |= 0x80;
869 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
870 if (status < 0) {
871 dbg("writing Spreg failed\n");
872 return -1;
873 }
874
875 Data &= ~0x80;
876 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
877 if (status < 0) {
878 dbg("writing Spreg failed\n");
879 return -1;
880 }
881//End of block to be checked
882
883 status = 0;
884 Data = 0x0;
885 status =
886 mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
887 if (status < 0) {
888 dbg("Reading Controlreg failed\n");
889 return -1;
890 }
891 Data |= 0x08; //Driver done bit
892 Data |= 0x20; //rx_disable
893 status = 0;
894 status =
895 mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
896 if (status < 0) {
897 dbg("writing Controlreg failed\n");
898 return -1;
899 }
900 //do register settings here
901 // Set all regs to the device default values.
902 ////////////////////////////////////
903 // First Disable all interrupts.
904 ////////////////////////////////////
905
906 Data = 0x00;
907 status = 0;
908 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
909 if (status < 0) {
910 dbg("disableing interrupts failed\n");
911 return -1;
912 }
913 // Set FIFO_CONTROL_REGISTER to the default value
914 Data = 0x00;
915 status = 0;
916 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
917 if (status < 0) {
918 dbg("Writing FIFO_CONTROL_REGISTER failed\n");
919 return -1;
920 }
921
922 Data = 0xcf;
923 status = 0;
924 status = mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
925 if (status < 0) {
926 dbg("Writing FIFO_CONTROL_REGISTER failed\n");
927 return -1;
928 }
929
930 Data = 0x03;
931 status = 0;
932 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
933 mos7840_port->shadowLCR = Data;
934
935 Data = 0x0b;
936 status = 0;
937 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
938 mos7840_port->shadowMCR = Data;
939
940 Data = 0x00;
941 status = 0;
942 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
943 mos7840_port->shadowLCR = Data;
944
945 Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80
946 status = 0;
947 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
948
949 Data = 0x0c;
950 status = 0;
951 status = mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
952
953 Data = 0x0;
954 status = 0;
955 status = mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
956
957 Data = 0x00;
958 status = 0;
959 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
960
961 Data = Data & ~SERIAL_LCR_DLAB;
962 status = 0;
963 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
964 mos7840_port->shadowLCR = Data;
965
966 //clearing Bulkin and Bulkout Fifo
967 Data = 0x0;
968 status = 0;
969 status = mos7840_get_reg_sync(port, mos7840_port->SpRegOffset, &Data);
970
971 Data = Data | 0x0c;
972 status = 0;
973 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
974
975 Data = Data & ~0x0c;
976 status = 0;
977 status = mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
978 //Finally enable all interrupts
979 Data = 0x0;
980 Data = 0x0c;
981 status = 0;
982 status = mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
983
984 //clearing rx_disable
985 Data = 0x0;
986 status = 0;
987 status =
988 mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
989 Data = Data & ~0x20;
990 status = 0;
991 status =
992 mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
993
994 // rx_negate
995 Data = 0x0;
996 status = 0;
997 status =
998 mos7840_get_reg_sync(port, mos7840_port->ControlRegOffset, &Data);
999 Data = Data | 0x10;
1000 status = 0;
1001 status =
1002 mos7840_set_reg_sync(port, mos7840_port->ControlRegOffset, Data);
1003
1004 /* force low_latency on so that our tty_push actually forces *
1005 * the data through,otherwise it is scheduled, and with *
1006 * high data rates (like with OHCI) data can get lost. */
1007
1008 if (port->tty)
1009 port->tty->low_latency = 1;
1010/* Check to see if we've set up our endpoint info yet *
1011 * (can't set it up in mos7840_startup as the structures *
1012 * were not set up at that time.) */
1013 if (mos7840_num_open_ports == 1) {
1014 if (serial->port[0]->interrupt_in_buffer == NULL) {
1015
1016 /* set up interrupt urb */
1017
1018 usb_fill_int_urb(serial->port[0]->interrupt_in_urb,
1019 serial->dev,
1020 usb_rcvintpipe(serial->dev,
1021 serial->port[0]->
1022 interrupt_in_endpointAddress),
1023 serial->port[0]->interrupt_in_buffer,
1024 serial->port[0]->interrupt_in_urb->
1025 transfer_buffer_length,
1026 mos7840_interrupt_callback,
1027 serial,
1028 serial->port[0]->interrupt_in_urb->
1029 interval);
1030
1031 /* start interrupt read for mos7840 *
1032 * will continue as long as mos7840 is connected */
1033
1034 response =
1035 usb_submit_urb(serial->port[0]->interrupt_in_urb,
1036 GFP_KERNEL);
1037 if (response) {
1038 err("%s - Error %d submitting interrupt urb",
1039 __FUNCTION__, response);
1040 }
1041
1042 }
1043
1044 }
1045
1046 /* see if we've set up our endpoint info yet *
1047 * (can't set it up in mos7840_startup as the *
1048 * structures were not set up at that time.) */
1049
1050 dbg("port number is %d \n", port->number);
1051 dbg("serial number is %d \n", port->serial->minor);
1052 dbg("Bulkin endpoint is %d \n", port->bulk_in_endpointAddress);
1053 dbg("BulkOut endpoint is %d \n", port->bulk_out_endpointAddress);
1054 dbg("Interrupt endpoint is %d \n", port->interrupt_in_endpointAddress);
1055 dbg("port's number in the device is %d\n", mos7840_port->port_num);
1056 mos7840_port->read_urb = port->read_urb;
1057
1058 /* set up our bulk in urb */
1059
1060 usb_fill_bulk_urb(mos7840_port->read_urb,
1061 serial->dev,
1062 usb_rcvbulkpipe(serial->dev,
1063 port->bulk_in_endpointAddress),
1064 port->bulk_in_buffer,
1065 mos7840_port->read_urb->transfer_buffer_length,
1066 mos7840_bulk_in_callback, mos7840_port);
1067
1068 dbg("mos7840_open: bulkin endpoint is %d\n",
1069 port->bulk_in_endpointAddress);
1070 response = usb_submit_urb(mos7840_port->read_urb, GFP_KERNEL);
1071 if (response) {
1072 err("%s - Error %d submitting control urb", __FUNCTION__,
1073 response);
1074 }
1075
1076 /* initialize our wait queues */
1077 init_waitqueue_head(&mos7840_port->wait_chase);
1078 init_waitqueue_head(&mos7840_port->delta_msr_wait);
1079
1080 /* initialize our icount structure */
1081 memset(&(mos7840_port->icount), 0x00, sizeof(mos7840_port->icount));
1082
1083 /* initialize our port settings */
1084 mos7840_port->shadowMCR = MCR_MASTER_IE; /* Must set to enable ints! */
1085 /* send a open port command */
1086 mos7840_port->open = 1;
1087 //mos7840_change_port_settings(mos7840_port,old_termios);
1088 mos7840_port->icount.tx = 0;
1089 mos7840_port->icount.rx = 0;
1090
1091 dbg("\n\nusb_serial serial:%x mos7840_port:%x\n usb_serial_port port:%x\n\n", (unsigned int)serial, (unsigned int)mos7840_port, (unsigned int)port);
1092
1093 return 0;
1094
1095}
1096
1097/*****************************************************************************
1098 * mos7840_chars_in_buffer
1099 * this function is called by the tty driver when it wants to know how many
1100 * bytes of data we currently have outstanding in the port (data that has
1101 * been written, but hasn't made it out the port yet)
1102 * If successful, we return the number of bytes left to be written in the
1103 * system,
1104 * Otherwise we return a negative error number.
1105 *****************************************************************************/
1106
1107static int mos7840_chars_in_buffer(struct usb_serial_port *port)
1108{
1109 int i;
1110 int chars = 0;
1111 struct moschip_port *mos7840_port;
1112
1113 dbg("%s \n", " mos7840_chars_in_buffer:entering ...........");
1114
1115 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1116 dbg("%s", "Invalid port \n");
1117 return -1;
1118 }
1119
1120 mos7840_port = mos7840_get_port_private(port);
1121 if (mos7840_port == NULL) {
1122 dbg("%s \n", "mos7840_break:leaving ...........");
1123 return -1;
1124 }
1125
1126 for (i = 0; i < NUM_URBS; ++i) {
1127 if (mos7840_port->write_urb_pool[i]->status == -EINPROGRESS) {
1128 chars += URB_TRANSFER_BUFFER_SIZE;
1129 }
1130 }
1131 dbg("%s - returns %d", __FUNCTION__, chars);
1132 return (chars);
1133
1134}
1135
1136/************************************************************************
1137 *
1138 * mos7840_block_until_tx_empty
1139 *
1140 * This function will block the close until one of the following:
1141 * 1. TX count are 0
1142 * 2. The mos7840 has stopped
1143 * 3. A timout of 3 seconds without activity has expired
1144 *
1145 ************************************************************************/
1146static void mos7840_block_until_tx_empty(struct moschip_port *mos7840_port)
1147{
1148 int timeout = HZ / 10;
1149 int wait = 30;
1150 int count;
1151
1152 while (1) {
1153
1154 count = mos7840_chars_in_buffer(mos7840_port->port);
1155
1156 /* Check for Buffer status */
1157 if (count <= 0) {
1158 return;
1159 }
1160
1161 /* Block the thread for a while */
1162 interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
1163 timeout);
1164
1165 /* No activity.. count down section */
1166 wait--;
1167 if (wait == 0) {
1168 dbg("%s - TIMEOUT", __FUNCTION__);
1169 return;
1170 } else {
1171 /* Reset timout value back to seconds */
1172 wait = 30;
1173 }
1174 }
1175}
1176
1177/*****************************************************************************
1178 * mos7840_close
1179 * this function is called by the tty driver when a port is closed
1180 *****************************************************************************/
1181
1182static void mos7840_close(struct usb_serial_port *port, struct file *filp)
1183{
1184 struct usb_serial *serial;
1185 struct moschip_port *mos7840_port;
1186 int j;
1187 __u16 Data;
1188
1189 dbg("%s\n", "mos7840_close:entering...");
1190
1191 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1192 dbg("%s", "Port Paranoia failed \n");
1193 return;
1194 }
1195
1196 serial = mos7840_get_usb_serial(port, __FUNCTION__);
1197 if (!serial) {
1198 dbg("%s", "Serial Paranoia failed \n");
1199 return;
1200 }
1201
1202 mos7840_port = mos7840_get_port_private(port);
1203
1204 if (mos7840_port == NULL) {
1205 return;
1206 }
1207
1208 for (j = 0; j < NUM_URBS; ++j)
1209 usb_kill_urb(mos7840_port->write_urb_pool[j]);
1210
1211 /* Freeing Write URBs */
1212 for (j = 0; j < NUM_URBS; ++j) {
1213 if (mos7840_port->write_urb_pool[j]) {
1214 if (mos7840_port->write_urb_pool[j]->transfer_buffer)
1215 kfree(mos7840_port->write_urb_pool[j]->
1216 transfer_buffer);
1217
1218 usb_free_urb(mos7840_port->write_urb_pool[j]);
1219 }
1220 }
1221
1222 if (serial->dev) {
1223 /* flush and block until tx is empty */
1224 mos7840_block_until_tx_empty(mos7840_port);
1225 }
1226
1227 /* While closing port, shutdown all bulk read, write *
1228 * and interrupt read if they exists */
1229 if (serial->dev) {
1230
1231 if (mos7840_port->write_urb) {
1232 dbg("%s", "Shutdown bulk write\n");
1233 usb_kill_urb(mos7840_port->write_urb);
1234 }
1235
1236 if (mos7840_port->read_urb) {
1237 dbg("%s", "Shutdown bulk read\n");
1238 usb_kill_urb(mos7840_port->read_urb);
1239 }
1240 if ((&mos7840_port->control_urb)) {
1241 dbg("%s", "Shutdown control read\n");
1242 // usb_kill_urb (mos7840_port->control_urb);
1243
1244 }
1245 }
1246// if(mos7840_port->ctrl_buf != NULL)
1247// kfree(mos7840_port->ctrl_buf);
1248 mos7840_num_open_ports--;
1249 dbg("mos7840_num_open_ports in close%d:in port%d\n",
1250 mos7840_num_open_ports, port->number);
1251 if (mos7840_num_open_ports == 0) {
1252 if (serial->port[0]->interrupt_in_urb) {
1253 dbg("%s", "Shutdown interrupt_in_urb\n");
1254 }
1255 }
1256
1257 if (mos7840_port->write_urb) {
1258 /* if this urb had a transfer buffer already (old tx) free it */
1259
1260 if (mos7840_port->write_urb->transfer_buffer != NULL) {
1261 kfree(mos7840_port->write_urb->transfer_buffer);
1262 }
1263 usb_free_urb(mos7840_port->write_urb);
1264 }
1265
1266 Data = 0x0;
1267 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
1268
1269 Data = 0x00;
1270 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
1271
1272 mos7840_port->open = 0;
1273
1274 dbg("%s \n", "Leaving ............");
1275}
1276
1277/************************************************************************
1278 *
1279 * mos7840_block_until_chase_response
1280 *
1281 * This function will block the close until one of the following:
1282 * 1. Response to our Chase comes from mos7840
1283 * 2. A timout of 10 seconds without activity has expired
1284 * (1K of mos7840 data @ 2400 baud ==> 4 sec to empty)
1285 *
1286 ************************************************************************/
1287
1288static void mos7840_block_until_chase_response(struct moschip_port
1289 *mos7840_port)
1290{
1291 int timeout = 1 * HZ;
1292 int wait = 10;
1293 int count;
1294
1295 while (1) {
1296 count = mos7840_chars_in_buffer(mos7840_port->port);
1297
1298 /* Check for Buffer status */
1299 if (count <= 0) {
1300 return;
1301 }
1302
1303 /* Block the thread for a while */
1304 interruptible_sleep_on_timeout(&mos7840_port->wait_chase,
1305 timeout);
1306 /* No activity.. count down section */
1307 wait--;
1308 if (wait == 0) {
1309 dbg("%s - TIMEOUT", __FUNCTION__);
1310 return;
1311 } else {
1312 /* Reset timout value back to seconds */
1313 wait = 10;
1314 }
1315 }
1316
1317}
1318
1319/*****************************************************************************
1320 * mos7840_break
1321 * this function sends a break to the port
1322 *****************************************************************************/
1323static void mos7840_break(struct usb_serial_port *port, int break_state)
1324{
1325 unsigned char data;
1326 struct usb_serial *serial;
1327 struct moschip_port *mos7840_port;
1328
1329 dbg("%s \n", "Entering ...........");
1330 dbg("mos7840_break: Start\n");
1331
1332 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1333 dbg("%s", "Port Paranoia failed \n");
1334 return;
1335 }
1336
1337 serial = mos7840_get_usb_serial(port, __FUNCTION__);
1338 if (!serial) {
1339 dbg("%s", "Serial Paranoia failed \n");
1340 return;
1341 }
1342
1343 mos7840_port = mos7840_get_port_private(port);
1344
1345 if (mos7840_port == NULL) {
1346 return;
1347 }
1348
1349 if (serial->dev) {
1350
1351 /* flush and block until tx is empty */
1352 mos7840_block_until_chase_response(mos7840_port);
1353 }
1354
1355 if (break_state == -1) {
1356 data = mos7840_port->shadowLCR | LCR_SET_BREAK;
1357 } else {
1358 data = mos7840_port->shadowLCR & ~LCR_SET_BREAK;
1359 }
1360
1361 mos7840_port->shadowLCR = data;
1362 dbg("mcs7840_break mos7840_port->shadowLCR is %x\n",
1363 mos7840_port->shadowLCR);
1364 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER,
1365 mos7840_port->shadowLCR);
1366
1367 return;
1368}
1369
1370/*****************************************************************************
1371 * mos7840_write_room
1372 * this function is called by the tty driver when it wants to know how many
1373 * bytes of data we can accept for a specific port.
1374 * If successful, we return the amount of room that we have for this port
1375 * Otherwise we return a negative error number.
1376 *****************************************************************************/
1377
1378static int mos7840_write_room(struct usb_serial_port *port)
1379{
1380 int i;
1381 int room = 0;
1382 struct moschip_port *mos7840_port;
1383
1384 dbg("%s \n", " mos7840_write_room:entering ...........");
1385
1386 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1387 dbg("%s", "Invalid port \n");
1388 dbg("%s \n", " mos7840_write_room:leaving ...........");
1389 return -1;
1390 }
1391
1392 mos7840_port = mos7840_get_port_private(port);
1393 if (mos7840_port == NULL) {
1394 dbg("%s \n", "mos7840_break:leaving ...........");
1395 return -1;
1396 }
1397
1398 for (i = 0; i < NUM_URBS; ++i) {
1399 if (mos7840_port->write_urb_pool[i]->status != -EINPROGRESS) {
1400 room += URB_TRANSFER_BUFFER_SIZE;
1401 }
1402 }
1403
1404 dbg("%s - returns %d", __FUNCTION__, room);
1405 return (room);
1406
1407}
1408
1409/*****************************************************************************
1410 * mos7840_write
1411 * this function is called by the tty driver when data should be written to
1412 * the port.
1413 * If successful, we return the number of bytes written, otherwise we
1414 * return a negative error number.
1415 *****************************************************************************/
1416
1417static int mos7840_write(struct usb_serial_port *port,
1418 const unsigned char *data, int count)
1419{
1420 int status;
1421 int i;
1422 int bytes_sent = 0;
1423 int transfer_size;
1424 int from_user = 0;
1425
1426 struct moschip_port *mos7840_port;
1427 struct usb_serial *serial;
1428 struct urb *urb;
1429 //__u16 Data;
1430 const unsigned char *current_position = data;
1431 unsigned char *data1;
1432 dbg("%s \n", "entering ...........");
1433 //dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",mos7840_port->shadowLCR);
1434
1435#ifdef NOTMOS7840
1436 Data = 0x00;
1437 status = 0;
1438 status = mos7840_get_uart_reg(port, LINE_CONTROL_REGISTER, &Data);
1439 mos7840_port->shadowLCR = Data;
1440 dbg("mos7840_write: LINE_CONTROL_REGISTER is %x\n", Data);
1441 dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
1442 mos7840_port->shadowLCR);
1443
1444 //Data = 0x03;
1445 //status = mos7840_set_uart_reg(port,LINE_CONTROL_REGISTER,Data);
1446 //mos7840_port->shadowLCR=Data;//Need to add later
1447
1448 Data |= SERIAL_LCR_DLAB; //data latch enable in LCR 0x80
1449 status = 0;
1450 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1451
1452 //Data = 0x0c;
1453 //status = mos7840_set_uart_reg(port,DIVISOR_LATCH_LSB,Data);
1454 Data = 0x00;
1455 status = 0;
1456 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_LSB, &Data);
1457 dbg("mos7840_write:DLL value is %x\n", Data);
1458
1459 Data = 0x0;
1460 status = 0;
1461 status = mos7840_get_uart_reg(port, DIVISOR_LATCH_MSB, &Data);
1462 dbg("mos7840_write:DLM value is %x\n", Data);
1463
1464 Data = Data & ~SERIAL_LCR_DLAB;
1465 dbg("mos7840_write: mos7840_port->shadowLCR is %x\n",
1466 mos7840_port->shadowLCR);
1467 status = 0;
1468 status = mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1469#endif
1470
1471 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1472 dbg("%s", "Port Paranoia failed \n");
1473 return -1;
1474 }
1475
1476 serial = port->serial;
1477 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) {
1478 dbg("%s", "Serial Paranoia failed \n");
1479 return -1;
1480 }
1481
1482 mos7840_port = mos7840_get_port_private(port);
1483 if (mos7840_port == NULL) {
1484 dbg("%s", "mos7840_port is NULL\n");
1485 return -1;
1486 }
1487
1488 /* try to find a free urb in the list */
1489 urb = NULL;
1490
1491 for (i = 0; i < NUM_URBS; ++i) {
1492 if (mos7840_port->write_urb_pool[i]->status != -EINPROGRESS) {
1493 urb = mos7840_port->write_urb_pool[i];
1494 dbg("\nURB:%d", i);
1495 break;
1496 }
1497 }
1498
1499 if (urb == NULL) {
1500 dbg("%s - no more free urbs", __FUNCTION__);
1501 goto exit;
1502 }
1503
1504 if (urb->transfer_buffer == NULL) {
1505 urb->transfer_buffer =
1506 kmalloc(URB_TRANSFER_BUFFER_SIZE, GFP_KERNEL);
1507
1508 if (urb->transfer_buffer == NULL) {
1509 err("%s no more kernel memory...", __FUNCTION__);
1510 goto exit;
1511 }
1512 }
1513 transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
1514
1515 if (from_user) {
1516 if (copy_from_user
1517 (urb->transfer_buffer, current_position, transfer_size)) {
1518 bytes_sent = -EFAULT;
1519 goto exit;
1520 }
1521 } else {
1522 memcpy(urb->transfer_buffer, current_position, transfer_size);
1523 }
1524
1525 /* fill urb with data and submit */
1526 usb_fill_bulk_urb(urb,
1527 serial->dev,
1528 usb_sndbulkpipe(serial->dev,
1529 port->bulk_out_endpointAddress),
1530 urb->transfer_buffer,
1531 transfer_size,
1532 mos7840_bulk_out_data_callback, mos7840_port);
1533
1534 data1 = urb->transfer_buffer;
1535 dbg("\nbulkout endpoint is %d", port->bulk_out_endpointAddress);
1536
1537 /* send it down the pipe */
1538 status = usb_submit_urb(urb, GFP_ATOMIC);
1539
1540 if (status) {
1541 err("%s - usb_submit_urb(write bulk) failed with status = %d",
1542 __FUNCTION__, status);
1543 bytes_sent = status;
1544 goto exit;
1545 }
1546 bytes_sent = transfer_size;
1547 mos7840_port->icount.tx += transfer_size;
1548 dbg("mos7840_port->icount.tx is %d:\n", mos7840_port->icount.tx);
1549 exit:
1550
1551 return bytes_sent;
1552
1553}
1554
1555/*****************************************************************************
1556 * mos7840_throttle
1557 * this function is called by the tty driver when it wants to stop the data
1558 * being read from the port.
1559 *****************************************************************************/
1560
1561static void mos7840_throttle(struct usb_serial_port *port)
1562{
1563 struct moschip_port *mos7840_port;
1564 struct tty_struct *tty;
1565 int status;
1566
1567 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1568 dbg("%s", "Invalid port \n");
1569 return;
1570 }
1571
1572 dbg("- port %d\n", port->number);
1573
1574 mos7840_port = mos7840_get_port_private(port);
1575
1576 if (mos7840_port == NULL)
1577 return;
1578
1579 if (!mos7840_port->open) {
1580 dbg("%s\n", "port not opened");
1581 return;
1582 }
1583
1584 dbg("%s", "Entering .......... \n");
1585
1586 tty = port->tty;
1587 if (!tty) {
1588 dbg("%s - no tty available", __FUNCTION__);
1589 return;
1590 }
1591
1592 /* if we are implementing XON/XOFF, send the stop character */
1593 if (I_IXOFF(tty)) {
1594 unsigned char stop_char = STOP_CHAR(tty);
1595 status = mos7840_write(port, &stop_char, 1);
1596 if (status <= 0) {
1597 return;
1598 }
1599 }
1600
1601 /* if we are implementing RTS/CTS, toggle that line */
1602 if (tty->termios->c_cflag & CRTSCTS) {
1603 mos7840_port->shadowMCR &= ~MCR_RTS;
1604 status = 0;
1605 status =
1606 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1607 mos7840_port->shadowMCR);
1608
1609 if (status < 0) {
1610 return;
1611 }
1612 }
1613
1614 return;
1615}
1616
1617/*****************************************************************************
1618 * mos7840_unthrottle
1619 * this function is called by the tty driver when it wants to resume the data
1620 * being read from the port (called after SerialThrottle is called)
1621 *****************************************************************************/
1622static void mos7840_unthrottle(struct usb_serial_port *port)
1623{
1624 struct tty_struct *tty;
1625 int status;
1626 struct moschip_port *mos7840_port = mos7840_get_port_private(port);
1627
1628 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1629 dbg("%s", "Invalid port \n");
1630 return;
1631 }
1632
1633 if (mos7840_port == NULL)
1634 return;
1635
1636 if (!mos7840_port->open) {
1637 dbg("%s - port not opened", __FUNCTION__);
1638 return;
1639 }
1640
1641 dbg("%s", "Entering .......... \n");
1642
1643 tty = port->tty;
1644 if (!tty) {
1645 dbg("%s - no tty available", __FUNCTION__);
1646 return;
1647 }
1648
1649 /* if we are implementing XON/XOFF, send the start character */
1650 if (I_IXOFF(tty)) {
1651 unsigned char start_char = START_CHAR(tty);
1652 status = mos7840_write(port, &start_char, 1);
1653 if (status <= 0) {
1654 return;
1655 }
1656 }
1657
1658 /* if we are implementing RTS/CTS, toggle that line */
1659 if (tty->termios->c_cflag & CRTSCTS) {
1660 mos7840_port->shadowMCR |= MCR_RTS;
1661 status = 0;
1662 status =
1663 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER,
1664 mos7840_port->shadowMCR);
1665 if (status < 0) {
1666 return;
1667 }
1668 }
1669
1670 return;
1671}
1672
1673static int mos7840_tiocmget(struct usb_serial_port *port, struct file *file)
1674{
1675 struct moschip_port *mos7840_port;
1676 unsigned int result;
1677 __u16 msr;
1678 __u16 mcr;
1679 int status = 0;
1680 mos7840_port = mos7840_get_port_private(port);
1681
1682 dbg("%s - port %d", __FUNCTION__, port->number);
1683
1684 if (mos7840_port == NULL)
1685 return -ENODEV;
1686
1687 status = mos7840_get_uart_reg(port, MODEM_STATUS_REGISTER, &msr);
1688 status = mos7840_get_uart_reg(port, MODEM_CONTROL_REGISTER, &mcr);
1689 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0)
1690 | ((mcr & MCR_RTS) ? TIOCM_RTS : 0)
1691 | ((mcr & MCR_LOOPBACK) ? TIOCM_LOOP : 0)
1692 | ((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0)
1693 | ((msr & MOS7840_MSR_CD) ? TIOCM_CAR : 0)
1694 | ((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0)
1695 | ((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0);
1696
1697 dbg("%s - 0x%04X", __FUNCTION__, result);
1698
1699 return result;
1700}
1701
1702static int mos7840_tiocmset(struct usb_serial_port *port, struct file *file,
1703 unsigned int set, unsigned int clear)
1704{
1705 struct moschip_port *mos7840_port;
1706 unsigned int mcr;
1707 unsigned int status;
1708
1709 dbg("%s - port %d", __FUNCTION__, port->number);
1710
1711 mos7840_port = mos7840_get_port_private(port);
1712
1713 if (mos7840_port == NULL)
1714 return -ENODEV;
1715
1716 mcr = mos7840_port->shadowMCR;
1717 if (clear & TIOCM_RTS)
1718 mcr &= ~MCR_RTS;
1719 if (clear & TIOCM_DTR)
1720 mcr &= ~MCR_DTR;
1721 if (clear & TIOCM_LOOP)
1722 mcr &= ~MCR_LOOPBACK;
1723
1724 if (set & TIOCM_RTS)
1725 mcr |= MCR_RTS;
1726 if (set & TIOCM_DTR)
1727 mcr |= MCR_DTR;
1728 if (set & TIOCM_LOOP)
1729 mcr |= MCR_LOOPBACK;
1730
1731 mos7840_port->shadowMCR = mcr;
1732
1733 status = 0;
1734 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, mcr);
1735 if (status < 0) {
1736 dbg("setting MODEM_CONTROL_REGISTER Failed\n");
1737 return -1;
1738 }
1739
1740 return 0;
1741}
1742
1743/*****************************************************************************
1744 * mos7840_calc_baud_rate_divisor
1745 * this function calculates the proper baud rate divisor for the specified
1746 * baud rate.
1747 *****************************************************************************/
1748static int mos7840_calc_baud_rate_divisor(int baudRate, int *divisor,
1749 __u16 * clk_sel_val)
1750{
1751
1752 dbg("%s - %d", __FUNCTION__, baudRate);
1753
1754 if (baudRate <= 115200) {
1755 *divisor = 115200 / baudRate;
1756 *clk_sel_val = 0x0;
1757 }
1758 if ((baudRate > 115200) && (baudRate <= 230400)) {
1759 *divisor = 230400 / baudRate;
1760 *clk_sel_val = 0x10;
1761 } else if ((baudRate > 230400) && (baudRate <= 403200)) {
1762 *divisor = 403200 / baudRate;
1763 *clk_sel_val = 0x20;
1764 } else if ((baudRate > 403200) && (baudRate <= 460800)) {
1765 *divisor = 460800 / baudRate;
1766 *clk_sel_val = 0x30;
1767 } else if ((baudRate > 460800) && (baudRate <= 806400)) {
1768 *divisor = 806400 / baudRate;
1769 *clk_sel_val = 0x40;
1770 } else if ((baudRate > 806400) && (baudRate <= 921600)) {
1771 *divisor = 921600 / baudRate;
1772 *clk_sel_val = 0x50;
1773 } else if ((baudRate > 921600) && (baudRate <= 1572864)) {
1774 *divisor = 1572864 / baudRate;
1775 *clk_sel_val = 0x60;
1776 } else if ((baudRate > 1572864) && (baudRate <= 3145728)) {
1777 *divisor = 3145728 / baudRate;
1778 *clk_sel_val = 0x70;
1779 }
1780 return 0;
1781
1782#ifdef NOTMCS7840
1783
1784 for (i = 0; i < ARRAY_SIZE(mos7840_divisor_table); i++) {
1785 if (mos7840_divisor_table[i].BaudRate == baudrate) {
1786 *divisor = mos7840_divisor_table[i].Divisor;
1787 return 0;
1788 }
1789 }
1790
1791 /* After trying for all the standard baud rates *
1792 * Try calculating the divisor for this baud rate */
1793
1794 if (baudrate > 75 && baudrate < 230400) {
1795 /* get the divisor */
1796 custom = (__u16) (230400L / baudrate);
1797
1798 /* Check for round off */
1799 round1 = (__u16) (2304000L / baudrate);
1800 round = (__u16) (round1 - (custom * 10));
1801 if (round > 4) {
1802 custom++;
1803 }
1804 *divisor = custom;
1805
1806 dbg(" Baud %d = %d\n", baudrate, custom);
1807 return 0;
1808 }
1809
1810 dbg("%s\n", " Baud calculation Failed...");
1811 return -1;
1812#endif
1813}
1814
1815/*****************************************************************************
1816 * mos7840_send_cmd_write_baud_rate
1817 * this function sends the proper command to change the baud rate of the
1818 * specified port.
1819 *****************************************************************************/
1820
1821static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port,
1822 int baudRate)
1823{
1824 int divisor = 0;
1825 int status;
1826 __u16 Data;
1827 unsigned char number;
1828 __u16 clk_sel_val;
1829 struct usb_serial_port *port;
1830
1831 if (mos7840_port == NULL)
1832 return -1;
1833
1834 port = (struct usb_serial_port *)mos7840_port->port;
1835 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1836 dbg("%s", "Invalid port \n");
1837 return -1;
1838 }
1839
1840 if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) {
1841 dbg("%s", "Invalid Serial \n");
1842 return -1;
1843 }
1844
1845 dbg("%s", "Entering .......... \n");
1846
1847 number = mos7840_port->port->number - mos7840_port->port->serial->minor;
1848
1849 dbg("%s - port = %d, baud = %d", __FUNCTION__,
1850 mos7840_port->port->number, baudRate);
1851 //reset clk_uart_sel in spregOffset
1852 if (baudRate > 115200) {
1853#ifdef HW_flow_control
1854 //NOTE: need to see the pther register to modify
1855 //setting h/w flow control bit to 1;
1856 status = 0;
1857 Data = 0x2b;
1858 mos7840_port->shadowMCR = Data;
1859 status =
1860 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
1861 if (status < 0) {
1862 dbg("Writing spreg failed in set_serial_baud\n");
1863 return -1;
1864 }
1865#endif
1866
1867 } else {
1868#ifdef HW_flow_control
1869 //setting h/w flow control bit to 0;
1870 status = 0;
1871 Data = 0xb;
1872 mos7840_port->shadowMCR = Data;
1873 status =
1874 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
1875 if (status < 0) {
1876 dbg("Writing spreg failed in set_serial_baud\n");
1877 return -1;
1878 }
1879#endif
1880
1881 }
1882
1883 if (1) //baudRate <= 115200)
1884 {
1885 clk_sel_val = 0x0;
1886 Data = 0x0;
1887 status = 0;
1888 status =
1889 mos7840_calc_baud_rate_divisor(baudRate, &divisor,
1890 &clk_sel_val);
1891 status =
1892 mos7840_get_reg_sync(port, mos7840_port->SpRegOffset,
1893 &Data);
1894 if (status < 0) {
1895 dbg("reading spreg failed in set_serial_baud\n");
1896 return -1;
1897 }
1898 Data = (Data & 0x8f) | clk_sel_val;
1899 status = 0;
1900 status =
1901 mos7840_set_reg_sync(port, mos7840_port->SpRegOffset, Data);
1902 if (status < 0) {
1903 dbg("Writing spreg failed in set_serial_baud\n");
1904 return -1;
1905 }
1906 /* Calculate the Divisor */
1907
1908 if (status) {
1909 err("%s - bad baud rate", __FUNCTION__);
1910 dbg("%s\n", "bad baud rate");
1911 return status;
1912 }
1913 /* Enable access to divisor latch */
1914 Data = mos7840_port->shadowLCR | SERIAL_LCR_DLAB;
1915 mos7840_port->shadowLCR = Data;
1916 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1917
1918 /* Write the divisor */
1919 Data = (unsigned char)(divisor & 0xff);
1920 dbg("set_serial_baud Value to write DLL is %x\n", Data);
1921 mos7840_set_uart_reg(port, DIVISOR_LATCH_LSB, Data);
1922
1923 Data = (unsigned char)((divisor & 0xff00) >> 8);
1924 dbg("set_serial_baud Value to write DLM is %x\n", Data);
1925 mos7840_set_uart_reg(port, DIVISOR_LATCH_MSB, Data);
1926
1927 /* Disable access to divisor latch */
1928 Data = mos7840_port->shadowLCR & ~SERIAL_LCR_DLAB;
1929 mos7840_port->shadowLCR = Data;
1930 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
1931
1932 }
1933
1934 return status;
1935}
1936
1937/*****************************************************************************
1938 * mos7840_change_port_settings
1939 * This routine is called to set the UART on the device to match
1940 * the specified new settings.
1941 *****************************************************************************/
1942
1943static void mos7840_change_port_settings(struct moschip_port *mos7840_port,
1944 struct termios *old_termios)
1945{
1946 struct tty_struct *tty;
1947 int baud;
1948 unsigned cflag;
1949 unsigned iflag;
1950 __u8 lData;
1951 __u8 lParity;
1952 __u8 lStop;
1953 int status;
1954 __u16 Data;
1955 struct usb_serial_port *port;
1956 struct usb_serial *serial;
1957
1958 if (mos7840_port == NULL)
1959 return;
1960
1961 port = (struct usb_serial_port *)mos7840_port->port;
1962
1963 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
1964 dbg("%s", "Invalid port \n");
1965 return;
1966 }
1967
1968 if (mos7840_serial_paranoia_check(port->serial, __FUNCTION__)) {
1969 dbg("%s", "Invalid Serial \n");
1970 return;
1971 }
1972
1973 serial = port->serial;
1974
1975 dbg("%s - port %d", __FUNCTION__, mos7840_port->port->number);
1976
1977 if (!mos7840_port->open) {
1978 dbg("%s - port not opened", __FUNCTION__);
1979 return;
1980 }
1981
1982 tty = mos7840_port->port->tty;
1983
1984 if ((!tty) || (!tty->termios)) {
1985 dbg("%s - no tty structures", __FUNCTION__);
1986 return;
1987 }
1988
1989 dbg("%s", "Entering .......... \n");
1990
1991 lData = LCR_BITS_8;
1992 lStop = LCR_STOP_1;
1993 lParity = LCR_PAR_NONE;
1994
1995 cflag = tty->termios->c_cflag;
1996 iflag = tty->termios->c_iflag;
1997
1998 /* Change the number of bits */
1999 if (cflag & CSIZE) {
2000 switch (cflag & CSIZE) {
2001 case CS5:
2002 lData = LCR_BITS_5;
2003 break;
2004
2005 case CS6:
2006 lData = LCR_BITS_6;
2007 break;
2008
2009 case CS7:
2010 lData = LCR_BITS_7;
2011 break;
2012 default:
2013 case CS8:
2014 lData = LCR_BITS_8;
2015 break;
2016 }
2017 }
2018 /* Change the Parity bit */
2019 if (cflag & PARENB) {
2020 if (cflag & PARODD) {
2021 lParity = LCR_PAR_ODD;
2022 dbg("%s - parity = odd", __FUNCTION__);
2023 } else {
2024 lParity = LCR_PAR_EVEN;
2025 dbg("%s - parity = even", __FUNCTION__);
2026 }
2027
2028 } else {
2029 dbg("%s - parity = none", __FUNCTION__);
2030 }
2031
2032 if (cflag & CMSPAR) {
2033 lParity = lParity | 0x20;
2034 }
2035
2036 /* Change the Stop bit */
2037 if (cflag & CSTOPB) {
2038 lStop = LCR_STOP_2;
2039 dbg("%s - stop bits = 2", __FUNCTION__);
2040 } else {
2041 lStop = LCR_STOP_1;
2042 dbg("%s - stop bits = 1", __FUNCTION__);
2043 }
2044
2045 /* Update the LCR with the correct value */
2046 mos7840_port->shadowLCR &=
2047 ~(LCR_BITS_MASK | LCR_STOP_MASK | LCR_PAR_MASK);
2048 mos7840_port->shadowLCR |= (lData | lParity | lStop);
2049
2050 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is %x\n",
2051 mos7840_port->shadowLCR);
2052 /* Disable Interrupts */
2053 Data = 0x00;
2054 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
2055
2056 Data = 0x00;
2057 mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
2058
2059 Data = 0xcf;
2060 mos7840_set_uart_reg(port, FIFO_CONTROL_REGISTER, Data);
2061
2062 /* Send the updated LCR value to the mos7840 */
2063 Data = mos7840_port->shadowLCR;
2064
2065 mos7840_set_uart_reg(port, LINE_CONTROL_REGISTER, Data);
2066
2067 Data = 0x00b;
2068 mos7840_port->shadowMCR = Data;
2069 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
2070 Data = 0x00b;
2071 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
2072
2073 /* set up the MCR register and send it to the mos7840 */
2074
2075 mos7840_port->shadowMCR = MCR_MASTER_IE;
2076 if (cflag & CBAUD) {
2077 mos7840_port->shadowMCR |= (MCR_DTR | MCR_RTS);
2078 }
2079
2080 if (cflag & CRTSCTS) {
2081 mos7840_port->shadowMCR |= (MCR_XON_ANY);
2082
2083 } else {
2084 mos7840_port->shadowMCR &= ~(MCR_XON_ANY);
2085 }
2086
2087 Data = mos7840_port->shadowMCR;
2088 mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
2089
2090 /* Determine divisor based on baud rate */
2091 baud = tty_get_baud_rate(tty);
2092
2093 if (!baud) {
2094 /* pick a default, any default... */
2095 dbg("%s\n", "Picked default baud...");
2096 baud = 9600;
2097 }
2098
2099 dbg("%s - baud rate = %d", __FUNCTION__, baud);
2100 status = mos7840_send_cmd_write_baud_rate(mos7840_port, baud);
2101
2102 /* Enable Interrupts */
2103 Data = 0x0c;
2104 mos7840_set_uart_reg(port, INTERRUPT_ENABLE_REGISTER, Data);
2105
2106 if (mos7840_port->read_urb->status != -EINPROGRESS) {
2107 mos7840_port->read_urb->dev = serial->dev;
2108
2109 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2110
2111 if (status) {
2112 dbg(" usb_submit_urb(read bulk) failed, status = %d",
2113 status);
2114 }
2115 }
2116 wake_up(&mos7840_port->delta_msr_wait);
2117 mos7840_port->delta_msr_cond = 1;
2118 dbg("mos7840_change_port_settings mos7840_port->shadowLCR is End %x\n",
2119 mos7840_port->shadowLCR);
2120
2121 return;
2122}
2123
2124/*****************************************************************************
2125 * mos7840_set_termios
2126 * this function is called by the tty driver when it wants to change
2127 * the termios structure
2128 *****************************************************************************/
2129
2130static void mos7840_set_termios(struct usb_serial_port *port,
2131 struct termios *old_termios)
2132{
2133 int status;
2134 unsigned int cflag;
2135 struct usb_serial *serial;
2136 struct moschip_port *mos7840_port;
2137 struct tty_struct *tty;
2138 dbg("mos7840_set_termios: START\n");
2139 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
2140 dbg("%s", "Invalid port \n");
2141 return;
2142 }
2143
2144 serial = port->serial;
2145
2146 if (mos7840_serial_paranoia_check(serial, __FUNCTION__)) {
2147 dbg("%s", "Invalid Serial \n");
2148 return;
2149 }
2150
2151 mos7840_port = mos7840_get_port_private(port);
2152
2153 if (mos7840_port == NULL)
2154 return;
2155
2156 tty = port->tty;
2157
2158 if (!port->tty || !port->tty->termios) {
2159 dbg("%s - no tty or termios", __FUNCTION__);
2160 return;
2161 }
2162
2163 if (!mos7840_port->open) {
2164 dbg("%s - port not opened", __FUNCTION__);
2165 return;
2166 }
2167
2168 dbg("%s\n", "setting termios - ");
2169
2170 cflag = tty->termios->c_cflag;
2171
2172 if (!cflag) {
2173 dbg("%s %s\n", __FUNCTION__, "cflag is NULL");
2174 return;
2175 }
2176
2177 /* check that they really want us to change something */
2178 if (old_termios) {
2179 if ((cflag == old_termios->c_cflag) &&
2180 (RELEVANT_IFLAG(tty->termios->c_iflag) ==
2181 RELEVANT_IFLAG(old_termios->c_iflag))) {
2182 dbg("%s\n", "Nothing to change");
2183 return;
2184 }
2185 }
2186
2187 dbg("%s - clfag %08x iflag %08x", __FUNCTION__,
2188 tty->termios->c_cflag, RELEVANT_IFLAG(tty->termios->c_iflag));
2189
2190 if (old_termios) {
2191 dbg("%s - old clfag %08x old iflag %08x", __FUNCTION__,
2192 old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag));
2193 }
2194
2195 dbg("%s - port %d", __FUNCTION__, port->number);
2196
2197 /* change the port settings to the new ones specified */
2198
2199 mos7840_change_port_settings(mos7840_port, old_termios);
2200
2201 if (!mos7840_port->read_urb) {
2202 dbg("%s", "URB KILLED !!!!!\n");
2203 return;
2204 }
2205
2206 if (mos7840_port->read_urb->status != -EINPROGRESS) {
2207 mos7840_port->read_urb->dev = serial->dev;
2208 status = usb_submit_urb(mos7840_port->read_urb, GFP_ATOMIC);
2209 if (status) {
2210 dbg(" usb_submit_urb(read bulk) failed, status = %d",
2211 status);
2212 }
2213 }
2214 return;
2215}
2216
2217/*****************************************************************************
2218 * mos7840_get_lsr_info - get line status register info
2219 *
2220 * Purpose: Let user call ioctl() to get info when the UART physically
2221 * is emptied. On bus types like RS485, the transmitter must
2222 * release the bus after transmitting. This must be done when
2223 * the transmit shift register is empty, not be done when the
2224 * transmit holding register is empty. This functionality
2225 * allows an RS485 driver to be written in user space.
2226 *****************************************************************************/
2227
2228static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
2229 unsigned int *value)
2230{
2231 int count;
2232 unsigned int result = 0;
2233
2234 count = mos7840_chars_in_buffer(mos7840_port->port);
2235 if (count == 0) {
2236 dbg("%s -- Empty", __FUNCTION__);
2237 result = TIOCSER_TEMT;
2238 }
2239
2240 if (copy_to_user(value, &result, sizeof(int)))
2241 return -EFAULT;
2242 return 0;
2243}
2244
2245/*****************************************************************************
2246 * mos7840_get_bytes_avail - get number of bytes available
2247 *
2248 * Purpose: Let user call ioctl to get the count of number of bytes available.
2249 *****************************************************************************/
2250
2251static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
2252 unsigned int *value)
2253{
2254 unsigned int result = 0;
2255 struct tty_struct *tty = mos7840_port->port->tty;
2256
2257 if (!tty)
2258 return -ENOIOCTLCMD;
2259
2260 result = tty->read_cnt;
2261
2262 dbg("%s(%d) = %d", __FUNCTION__, mos7840_port->port->number, result);
2263 if (copy_to_user(value, &result, sizeof(int)))
2264 return -EFAULT;
2265
2266 return -ENOIOCTLCMD;
2267}
2268
2269/*****************************************************************************
2270 * mos7840_set_modem_info
2271 * function to set modem info
2272 *****************************************************************************/
2273
2274static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
2275 unsigned int cmd, unsigned int *value)
2276{
2277 unsigned int mcr;
2278 unsigned int arg;
2279 __u16 Data;
2280 int status;
2281 struct usb_serial_port *port;
2282
2283 if (mos7840_port == NULL)
2284 return -1;
2285
2286 port = (struct usb_serial_port *)mos7840_port->port;
2287 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
2288 dbg("%s", "Invalid port \n");
2289 return -1;
2290 }
2291
2292 mcr = mos7840_port->shadowMCR;
2293
2294 if (copy_from_user(&arg, value, sizeof(int)))
2295 return -EFAULT;
2296
2297 switch (cmd) {
2298 case TIOCMBIS:
2299 if (arg & TIOCM_RTS)
2300 mcr |= MCR_RTS;
2301 if (arg & TIOCM_DTR)
2302 mcr |= MCR_RTS;
2303 if (arg & TIOCM_LOOP)
2304 mcr |= MCR_LOOPBACK;
2305 break;
2306
2307 case TIOCMBIC:
2308 if (arg & TIOCM_RTS)
2309 mcr &= ~MCR_RTS;
2310 if (arg & TIOCM_DTR)
2311 mcr &= ~MCR_RTS;
2312 if (arg & TIOCM_LOOP)
2313 mcr &= ~MCR_LOOPBACK;
2314 break;
2315
2316 case TIOCMSET:
2317 /* turn off the RTS and DTR and LOOPBACK
2318 * and then only turn on what was asked to */
2319 mcr &= ~(MCR_RTS | MCR_DTR | MCR_LOOPBACK);
2320 mcr |= ((arg & TIOCM_RTS) ? MCR_RTS : 0);
2321 mcr |= ((arg & TIOCM_DTR) ? MCR_DTR : 0);
2322 mcr |= ((arg & TIOCM_LOOP) ? MCR_LOOPBACK : 0);
2323 break;
2324 }
2325
2326 mos7840_port->shadowMCR = mcr;
2327
2328 Data = mos7840_port->shadowMCR;
2329 status = 0;
2330 status = mos7840_set_uart_reg(port, MODEM_CONTROL_REGISTER, Data);
2331 if (status < 0) {
2332 dbg("setting MODEM_CONTROL_REGISTER Failed\n");
2333 return -1;
2334 }
2335
2336 return 0;
2337}
2338
2339/*****************************************************************************
2340 * mos7840_get_modem_info
2341 * function to get modem info
2342 *****************************************************************************/
2343
2344static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
2345 unsigned int *value)
2346{
2347 unsigned int result = 0;
2348 __u16 msr;
2349 unsigned int mcr = mos7840_port->shadowMCR;
2350 int status = 0;
2351 status =
2352 mos7840_get_uart_reg(mos7840_port->port, MODEM_STATUS_REGISTER,
2353 &msr);
2354 result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) /* 0x002 */
2355 |((mcr & MCR_RTS) ? TIOCM_RTS : 0) /* 0x004 */
2356 |((msr & MOS7840_MSR_CTS) ? TIOCM_CTS : 0) /* 0x020 */
2357 |((msr & MOS7840_MSR_CD) ? TIOCM_CAR : 0) /* 0x040 */
2358 |((msr & MOS7840_MSR_RI) ? TIOCM_RI : 0) /* 0x080 */
2359 |((msr & MOS7840_MSR_DSR) ? TIOCM_DSR : 0); /* 0x100 */
2360
2361 dbg("%s -- %x", __FUNCTION__, result);
2362
2363 if (copy_to_user(value, &result, sizeof(int)))
2364 return -EFAULT;
2365 return 0;
2366}
2367
2368/*****************************************************************************
2369 * mos7840_get_serial_info
2370 * function to get information about serial port
2371 *****************************************************************************/
2372
2373static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
2374 struct serial_struct *retinfo)
2375{
2376 struct serial_struct tmp;
2377
2378 if (mos7840_port == NULL)
2379 return -1;
2380
2381 if (!retinfo)
2382 return -EFAULT;
2383
2384 memset(&tmp, 0, sizeof(tmp));
2385
2386 tmp.type = PORT_16550A;
2387 tmp.line = mos7840_port->port->serial->minor;
2388 tmp.port = mos7840_port->port->number;
2389 tmp.irq = 0;
2390 tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
2391 tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE;
2392 tmp.baud_base = 9600;
2393 tmp.close_delay = 5 * HZ;
2394 tmp.closing_wait = 30 * HZ;
2395
2396 if (copy_to_user(retinfo, &tmp, sizeof(*retinfo)))
2397 return -EFAULT;
2398 return 0;
2399}
2400
2401/*****************************************************************************
2402 * SerialIoctl
2403 * this function handles any ioctl calls to the driver
2404 *****************************************************************************/
2405
2406static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
2407 unsigned int cmd, unsigned long arg)
2408{
2409 struct moschip_port *mos7840_port;
2410 struct tty_struct *tty;
2411
2412 struct async_icount cnow;
2413 struct async_icount cprev;
2414 struct serial_icounter_struct icount;
2415 int mosret = 0;
2416 int retval;
2417 struct tty_ldisc *ld;
2418
2419 if (mos7840_port_paranoia_check(port, __FUNCTION__)) {
2420 dbg("%s", "Invalid port \n");
2421 return -1;
2422 }
2423
2424 mos7840_port = mos7840_get_port_private(port);
2425 tty = mos7840_port->port->tty;
2426
2427 if (mos7840_port == NULL)
2428 return -1;
2429
2430 dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
2431
2432 switch (cmd) {
2433 /* return number of bytes available */
2434
2435 case TIOCINQ:
2436 dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
2437 return mos7840_get_bytes_avail(mos7840_port,
2438 (unsigned int *)arg);
2439 break;
2440
2441 case TIOCOUTQ:
2442 dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
2443 return put_user(tty->driver->chars_in_buffer ?
2444 tty->driver->chars_in_buffer(tty) : 0,
2445 (int __user *)arg);
2446 break;
2447
2448 case TCFLSH:
2449 retval = tty_check_change(tty);
2450 if (retval)
2451 return retval;
2452
2453 ld = tty_ldisc_ref(tty);
2454 switch (arg) {
2455 case TCIFLUSH:
2456 if (ld && ld->flush_buffer)
2457 ld->flush_buffer(tty);
2458 break;
2459 case TCIOFLUSH:
2460 if (ld && ld->flush_buffer)
2461 ld->flush_buffer(tty);
2462 /* fall through */
2463 case TCOFLUSH:
2464 if (tty->driver->flush_buffer)
2465 tty->driver->flush_buffer(tty);
2466 break;
2467 default:
2468 tty_ldisc_deref(ld);
2469 return -EINVAL;
2470 }
2471 tty_ldisc_deref(ld);
2472 return 0;
2473
2474 case TCGETS:
2475 if (kernel_termios_to_user_termios
2476 ((struct termios __user *)arg, tty->termios))
2477 return -EFAULT;
2478 return 0;
2479
2480 case TIOCSERGETLSR:
2481 dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
2482 return mos7840_get_lsr_info(mos7840_port, (unsigned int *)arg);
2483 return 0;
2484
2485 case TIOCMBIS:
2486 case TIOCMBIC:
2487 case TIOCMSET:
2488 dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
2489 port->number);
2490 mosret =
2491 mos7840_set_modem_info(mos7840_port, cmd,
2492 (unsigned int *)arg);
2493 return mosret;
2494
2495 case TIOCMGET:
2496 dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
2497 return mos7840_get_modem_info(mos7840_port,
2498 (unsigned int *)arg);
2499
2500 case TIOCGSERIAL:
2501 dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
2502 return mos7840_get_serial_info(mos7840_port,
2503 (struct serial_struct *)arg);
2504
2505 case TIOCSSERIAL:
2506 dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
2507 break;
2508
2509 case TIOCMIWAIT:
2510 dbg("%s (%d) TIOCMIWAIT", __FUNCTION__, port->number);
2511 cprev = mos7840_port->icount;
2512 while (1) {
2513 //interruptible_sleep_on(&mos7840_port->delta_msr_wait);
2514 mos7840_port->delta_msr_cond = 0;
2515 wait_event_interruptible(mos7840_port->delta_msr_wait,
2516 (mos7840_port->
2517 delta_msr_cond == 1));
2518
2519 /* see if a signal did it */
2520 if (signal_pending(current))
2521 return -ERESTARTSYS;
2522 cnow = mos7840_port->icount;
2523 if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr &&
2524 cnow.dcd == cprev.dcd && cnow.cts == cprev.cts)
2525 return -EIO; /* no change => error */
2526 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
2527 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
2528 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) ||
2529 ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) {
2530 return 0;
2531 }
2532 cprev = cnow;
2533 }
2534 /* NOTREACHED */
2535 break;
2536
2537 case TIOCGICOUNT:
2538 cnow = mos7840_port->icount;
2539 icount.cts = cnow.cts;
2540 icount.dsr = cnow.dsr;
2541 icount.rng = cnow.rng;
2542 icount.dcd = cnow.dcd;
2543 icount.rx = cnow.rx;
2544 icount.tx = cnow.tx;
2545 icount.frame = cnow.frame;
2546 icount.overrun = cnow.overrun;
2547 icount.parity = cnow.parity;
2548 icount.brk = cnow.brk;
2549 icount.buf_overrun = cnow.buf_overrun;
2550
2551 dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
2552 port->number, icount.rx, icount.tx);
2553 if (copy_to_user((void *)arg, &icount, sizeof(icount)))
2554 return -EFAULT;
2555 return 0;
2556
2557 case TIOCEXBAUD:
2558 return 0;
2559 default:
2560 break;
2561 }
2562
2563 return -ENOIOCTLCMD;
2564}
2565
2566static int mos7840_calc_num_ports(struct usb_serial *serial)
2567{
2568
2569 dbg("numberofendpoints: %d \n",
2570 (int)serial->interface->cur_altsetting->desc.bNumEndpoints);
2571 dbg("numberofendpoints: %d \n",
2572 (int)serial->interface->altsetting->desc.bNumEndpoints);
2573 if (serial->interface->cur_altsetting->desc.bNumEndpoints == 5) {
2574 mos7840_num_ports = 2;
2575 serial->type->num_ports = 2;
2576 } else if (serial->interface->cur_altsetting->desc.bNumEndpoints == 9) {
2577 mos7840_num_ports = 4;
2578 serial->type->num_bulk_in = 4;
2579 serial->type->num_bulk_out = 4;
2580 serial->type->num_ports = 4;
2581 }
2582
2583 return mos7840_num_ports;
2584}
2585
2586/****************************************************************************
2587 * mos7840_startup
2588 ****************************************************************************/
2589
2590static int mos7840_startup(struct usb_serial *serial)
2591{
2592 struct moschip_port *mos7840_port;
2593 struct usb_device *dev;
2594 int i, status;
2595
2596 __u16 Data;
2597 dbg("%s \n", " mos7840_startup :entering..........");
2598
2599 if (!serial) {
2600 dbg("%s\n", "Invalid Handler");
2601 return -1;
2602 }
2603
2604 dev = serial->dev;
2605
2606 dbg("%s\n", "Entering...");
2607
2608 /* we set up the pointers to the endpoints in the mos7840_open *
2609 * function, as the structures aren't created yet. */
2610
2611 /* set up port private structures */
2612 for (i = 0; i < serial->num_ports; ++i) {
2613 mos7840_port = kmalloc(sizeof(struct moschip_port), GFP_KERNEL);
2614 if (mos7840_port == NULL) {
2615 err("%s - Out of memory", __FUNCTION__);
2616 return -ENOMEM;
2617 }
2618 memset(mos7840_port, 0, sizeof(struct moschip_port));
2619
2620 /* Initialize all port interrupt end point to port 0 int endpoint *
2621 * Our device has only one interrupt end point comman to all port */
2622
2623 mos7840_port->port = serial->port[i];
2624 mos7840_set_port_private(serial->port[i], mos7840_port);
2625
2626 mos7840_port->port_num = ((serial->port[i]->number -
2627 (serial->port[i]->serial->minor)) +
2628 1);
2629
2630 if (mos7840_port->port_num == 1) {
2631 mos7840_port->SpRegOffset = 0x0;
2632 mos7840_port->ControlRegOffset = 0x1;
2633 mos7840_port->DcrRegOffset = 0x4;
2634 } else if ((mos7840_port->port_num == 2)
2635 && (mos7840_num_ports == 4)) {
2636 mos7840_port->SpRegOffset = 0x8;
2637 mos7840_port->ControlRegOffset = 0x9;
2638 mos7840_port->DcrRegOffset = 0x16;
2639 } else if ((mos7840_port->port_num == 2)
2640 && (mos7840_num_ports == 2)) {
2641 mos7840_port->SpRegOffset = 0xa;
2642 mos7840_port->ControlRegOffset = 0xb;
2643 mos7840_port->DcrRegOffset = 0x19;
2644 } else if ((mos7840_port->port_num == 3)
2645 && (mos7840_num_ports == 4)) {
2646 mos7840_port->SpRegOffset = 0xa;
2647 mos7840_port->ControlRegOffset = 0xb;
2648 mos7840_port->DcrRegOffset = 0x19;
2649 } else if ((mos7840_port->port_num == 4)
2650 && (mos7840_num_ports == 4)) {
2651 mos7840_port->SpRegOffset = 0xc;
2652 mos7840_port->ControlRegOffset = 0xd;
2653 mos7840_port->DcrRegOffset = 0x1c;
2654 }
2655 mos7840_dump_serial_port(mos7840_port);
2656
2657 mos7840_set_port_private(serial->port[i], mos7840_port);
2658
2659 //enable rx_disable bit in control register
2660
2661 status =
2662 mos7840_get_reg_sync(serial->port[i],
2663 mos7840_port->ControlRegOffset, &Data);
2664 if (status < 0) {
2665 dbg("Reading ControlReg failed status-0x%x\n", status);
2666 break;
2667 } else
2668 dbg("ControlReg Reading success val is %x, status%d\n",
2669 Data, status);
2670 Data |= 0x08; //setting driver done bit
2671 Data |= 0x04; //sp1_bit to have cts change reflect in modem status reg
2672
2673 //Data |= 0x20; //rx_disable bit
2674 status = 0;
2675 status =
2676 mos7840_set_reg_sync(serial->port[i],
2677 mos7840_port->ControlRegOffset, Data);
2678 if (status < 0) {
2679 dbg("Writing ControlReg failed(rx_disable) status-0x%x\n", status);
2680 break;
2681 } else
2682 dbg("ControlReg Writing success(rx_disable) status%d\n",
2683 status);
2684
2685 //Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 and 0x24 in DCR3
2686 Data = 0x01;
2687 status = 0;
2688 status =
2689 mos7840_set_reg_sync(serial->port[i],
2690 (__u16) (mos7840_port->DcrRegOffset +
2691 0), Data);
2692 if (status < 0) {
2693 dbg("Writing DCR0 failed status-0x%x\n", status);
2694 break;
2695 } else
2696 dbg("DCR0 Writing success status%d\n", status);
2697
2698 Data = 0x05;
2699 status = 0;
2700 status =
2701 mos7840_set_reg_sync(serial->port[i],
2702 (__u16) (mos7840_port->DcrRegOffset +
2703 1), Data);
2704 if (status < 0) {
2705 dbg("Writing DCR1 failed status-0x%x\n", status);
2706 break;
2707 } else
2708 dbg("DCR1 Writing success status%d\n", status);
2709
2710 Data = 0x24;
2711 status = 0;
2712 status =
2713 mos7840_set_reg_sync(serial->port[i],
2714 (__u16) (mos7840_port->DcrRegOffset +
2715 2), Data);
2716 if (status < 0) {
2717 dbg("Writing DCR2 failed status-0x%x\n", status);
2718 break;
2719 } else
2720 dbg("DCR2 Writing success status%d\n", status);
2721
2722 // write values in clkstart0x0 and clkmulti 0x20
2723 Data = 0x0;
2724 status = 0;
2725 status =
2726 mos7840_set_reg_sync(serial->port[i],
2727 CLK_START_VALUE_REGISTER, Data);
2728 if (status < 0) {
2729 dbg("Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
2730 break;
2731 } else
2732 dbg("CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2733
2734 Data = 0x20;
2735 status = 0;
2736 status =
2737 mos7840_set_reg_sync(serial->port[i], CLK_MULTI_REGISTER,
2738 Data);
2739 if (status < 0) {
2740 dbg("Writing CLK_MULTI_REGISTER failed status-0x%x\n",
2741 status);
2742 break;
2743 } else
2744 dbg("CLK_MULTI_REGISTER Writing success status%d\n",
2745 status);
2746
2747 //write value 0x0 to scratchpad register
2748 Data = 0x00;
2749 status = 0;
2750 status =
2751 mos7840_set_uart_reg(serial->port[i], SCRATCH_PAD_REGISTER,
2752 Data);
2753 if (status < 0) {
2754 dbg("Writing SCRATCH_PAD_REGISTER failed status-0x%x\n",
2755 status);
2756 break;
2757 } else
2758 dbg("SCRATCH_PAD_REGISTER Writing success status%d\n",
2759 status);
2760
2761 //Zero Length flag register
2762 if ((mos7840_port->port_num != 1)
2763 && (mos7840_num_ports == 2)) {
2764
2765 Data = 0xff;
2766 status = 0;
2767 status = mos7840_set_reg_sync(serial->port[i],
2768 (__u16) (ZLP_REG1 +
2769 ((__u16)
2770 mos7840_port->
2771 port_num)),
2772 Data);
2773 dbg("ZLIP offset%x\n",
2774 (__u16) (ZLP_REG1 +
2775 ((__u16) mos7840_port->port_num)));
2776 if (status < 0) {
2777 dbg("Writing ZLP_REG%d failed status-0x%x\n",
2778 i + 2, status);
2779 break;
2780 } else
2781 dbg("ZLP_REG%d Writing success status%d\n",
2782 i + 2, status);
2783 } else {
2784 Data = 0xff;
2785 status = 0;
2786 status = mos7840_set_reg_sync(serial->port[i],
2787 (__u16) (ZLP_REG1 +
2788 ((__u16)
2789 mos7840_port->
2790 port_num) -
2791 0x1), Data);
2792 dbg("ZLIP offset%x\n",
2793 (__u16) (ZLP_REG1 +
2794 ((__u16) mos7840_port->port_num) - 0x1));
2795 if (status < 0) {
2796 dbg("Writing ZLP_REG%d failed status-0x%x\n",
2797 i + 1, status);
2798 break;
2799 } else
2800 dbg("ZLP_REG%d Writing success status%d\n",
2801 i + 1, status);
2802
2803 }
2804 mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC);
2805 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2806
2807 }
2808
2809 //Zero Length flag enable
2810 Data = 0x0f;
2811 status = 0;
2812 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2813 if (status < 0) {
2814 dbg("Writing ZLP_REG5 failed status-0x%x\n", status);
2815 return -1;
2816 } else
2817 dbg("ZLP_REG5 Writing success status%d\n", status);
2818
2819 /* setting configuration feature to one */
2820 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2821 (__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ);
2822 return 0;
2823}
2824
2825/****************************************************************************
2826 * mos7840_shutdown
2827 * This function is called whenever the device is removed from the usb bus.
2828 ****************************************************************************/
2829
2830static void mos7840_shutdown(struct usb_serial *serial)
2831{
2832 int i;
2833 struct moschip_port *mos7840_port;
2834 dbg("%s \n", " shutdown :entering..........");
2835
2836 if (!serial) {
2837 dbg("%s", "Invalid Handler \n");
2838 return;
2839 }
2840
2841 /* check for the ports to be closed,close the ports and disconnect */
2842
2843 /* free private structure allocated for serial port *
2844 * stop reads and writes on all ports */
2845
2846 for (i = 0; i < serial->num_ports; ++i) {
2847 mos7840_port = mos7840_get_port_private(serial->port[i]);
2848 kfree(mos7840_port->ctrl_buf);
2849 usb_kill_urb(mos7840_port->control_urb);
2850 kfree(mos7840_port);
2851 mos7840_set_port_private(serial->port[i], NULL);
2852 }
2853
2854 dbg("%s\n", "Thank u :: ");
2855
2856}
2857
2858static struct usb_serial_driver moschip7840_4port_device = {
2859 .driver = {
2860 .owner = THIS_MODULE,
2861 .name = "mos7840",
2862 },
2863 .description = DRIVER_DESC,
2864 .id_table = moschip_port_id_table,
2865 .num_interrupt_in = 1, //NUM_DONT_CARE,//1,
2866#ifdef check
2867 .num_bulk_in = 4,
2868 .num_bulk_out = 4,
2869 .num_ports = 4,
2870#endif
2871 .open = mos7840_open,
2872 .close = mos7840_close,
2873 .write = mos7840_write,
2874 .write_room = mos7840_write_room,
2875 .chars_in_buffer = mos7840_chars_in_buffer,
2876 .throttle = mos7840_throttle,
2877 .unthrottle = mos7840_unthrottle,
2878 .calc_num_ports = mos7840_calc_num_ports,
2879#ifdef MCSSerialProbe
2880 .probe = mos7840_serial_probe,
2881#endif
2882 .ioctl = mos7840_ioctl,
2883 .set_termios = mos7840_set_termios,
2884 .break_ctl = mos7840_break,
2885 .tiocmget = mos7840_tiocmget,
2886 .tiocmset = mos7840_tiocmset,
2887 .attach = mos7840_startup,
2888 .shutdown = mos7840_shutdown,
2889 .read_bulk_callback = mos7840_bulk_in_callback,
2890 .read_int_callback = mos7840_interrupt_callback,
2891};
2892
2893static struct usb_driver io_driver = {
2894 .name = "mos7840",
2895 .probe = usb_serial_probe,
2896 .disconnect = usb_serial_disconnect,
2897 .id_table = moschip_id_table_combined,
2898};
2899
2900/****************************************************************************
2901 * moschip7840_init
2902 * This is called by the module subsystem, or on startup to initialize us
2903 ****************************************************************************/
2904static int __init moschip7840_init(void)
2905{
2906 int retval;
2907
2908 dbg("%s \n", " mos7840_init :entering..........");
2909
2910 /* Register with the usb serial */
2911 retval = usb_serial_register(&moschip7840_4port_device);
2912
2913 if (retval)
2914 goto failed_port_device_register;
2915
2916 dbg("%s\n", "Entring...");
2917 info(DRIVER_DESC " " DRIVER_VERSION);
2918
2919 /* Register with the usb */
2920 retval = usb_register(&io_driver);
2921
2922 if (retval)
2923 goto failed_usb_register;
2924
2925 if (retval == 0) {
2926 dbg("%s\n", "Leaving...");
2927 return 0;
2928 }
2929
2930 failed_usb_register:
2931 usb_serial_deregister(&moschip7840_4port_device);
2932
2933 failed_port_device_register:
2934
2935 return retval;
2936}
2937
2938/****************************************************************************
2939 * moschip7840_exit
2940 * Called when the driver is about to be unloaded.
2941 ****************************************************************************/
2942static void __exit moschip7840_exit(void)
2943{
2944
2945 dbg("%s \n", " mos7840_exit :entering..........");
2946
2947 usb_deregister(&io_driver);
2948
2949 usb_serial_deregister(&moschip7840_4port_device);
2950
2951 dbg("%s\n", "Entring...");
2952}
2953
2954module_init(moschip7840_init);
2955module_exit(moschip7840_exit);
2956
2957/* Module information */
2958MODULE_DESCRIPTION(DRIVER_DESC);
2959MODULE_LICENSE("GPL");
2960
2961module_param(debug, bool, S_IRUGO | S_IWUSR);
2962MODULE_PARM_DESC(debug, "Debug enabled or not");
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 65e4d046951a..1036d436ed23 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -81,10 +81,11 @@ static struct usb_device_id id_table [] = {
81 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) }, 81 { USB_DEVICE(SPEEDDRAGON_VENDOR_ID, SPEEDDRAGON_PRODUCT_ID) },
82 { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) }, 82 { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) },
83 { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) }, 83 { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) },
84 { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) },
84 { } /* Terminating entry */ 85 { } /* Terminating entry */
85}; 86};
86 87
87MODULE_DEVICE_TABLE (usb, id_table); 88MODULE_DEVICE_TABLE(usb, id_table);
88 89
89static struct usb_driver pl2303_driver = { 90static struct usb_driver pl2303_driver = {
90 .name = "pl2303", 91 .name = "pl2303",
@@ -127,65 +128,6 @@ static struct usb_driver pl2303_driver = {
127#define UART_OVERRUN_ERROR 0x40 128#define UART_OVERRUN_ERROR 0x40
128#define UART_CTS 0x80 129#define UART_CTS 0x80
129 130
130/* function prototypes for a PL2303 serial converter */
131static int pl2303_open (struct usb_serial_port *port, struct file *filp);
132static void pl2303_close (struct usb_serial_port *port, struct file *filp);
133static void pl2303_set_termios (struct usb_serial_port *port,
134 struct termios *old);
135static int pl2303_ioctl (struct usb_serial_port *port, struct file *file,
136 unsigned int cmd, unsigned long arg);
137static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs);
138static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
139static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
140static int pl2303_write (struct usb_serial_port *port,
141 const unsigned char *buf, int count);
142static void pl2303_send (struct usb_serial_port *port);
143static int pl2303_write_room(struct usb_serial_port *port);
144static int pl2303_chars_in_buffer(struct usb_serial_port *port);
145static void pl2303_break_ctl(struct usb_serial_port *port,int break_state);
146static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file);
147static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
148 unsigned int set, unsigned int clear);
149static int pl2303_startup (struct usb_serial *serial);
150static void pl2303_shutdown (struct usb_serial *serial);
151static struct pl2303_buf *pl2303_buf_alloc(unsigned int size);
152static void pl2303_buf_free(struct pl2303_buf *pb);
153static void pl2303_buf_clear(struct pl2303_buf *pb);
154static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb);
155static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb);
156static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
157 unsigned int count);
158static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
159 unsigned int count);
160
161
162/* All of the device info needed for the PL2303 SIO serial converter */
163static struct usb_serial_driver pl2303_device = {
164 .driver = {
165 .owner = THIS_MODULE,
166 .name = "pl2303",
167 },
168 .id_table = id_table,
169 .num_interrupt_in = NUM_DONT_CARE,
170 .num_bulk_in = 1,
171 .num_bulk_out = 1,
172 .num_ports = 1,
173 .open = pl2303_open,
174 .close = pl2303_close,
175 .write = pl2303_write,
176 .ioctl = pl2303_ioctl,
177 .break_ctl = pl2303_break_ctl,
178 .set_termios = pl2303_set_termios,
179 .tiocmget = pl2303_tiocmget,
180 .tiocmset = pl2303_tiocmset,
181 .read_bulk_callback = pl2303_read_bulk_callback,
182 .read_int_callback = pl2303_read_int_callback,
183 .write_bulk_callback = pl2303_write_bulk_callback,
184 .write_room = pl2303_write_room,
185 .chars_in_buffer = pl2303_chars_in_buffer,
186 .attach = pl2303_startup,
187 .shutdown = pl2303_shutdown,
188};
189 131
190enum pl2303_type { 132enum pl2303_type {
191 type_0, /* don't know the difference between type 0 and */ 133 type_0, /* don't know the difference between type 0 and */
@@ -204,8 +146,166 @@ struct pl2303_private {
204 enum pl2303_type type; 146 enum pl2303_type type;
205}; 147};
206 148
149/*
150 * pl2303_buf_alloc
151 *
152 * Allocate a circular buffer and all associated memory.
153 */
154static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
155{
156 struct pl2303_buf *pb;
157
158 if (size == 0)
159 return NULL;
160
161 pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
162 if (pb == NULL)
163 return NULL;
164
165 pb->buf_buf = kmalloc(size, GFP_KERNEL);
166 if (pb->buf_buf == NULL) {
167 kfree(pb);
168 return NULL;
169 }
170
171 pb->buf_size = size;
172 pb->buf_get = pb->buf_put = pb->buf_buf;
207 173
208static int pl2303_startup (struct usb_serial *serial) 174 return pb;
175}
176
177/*
178 * pl2303_buf_free
179 *
180 * Free the buffer and all associated memory.
181 */
182static void pl2303_buf_free(struct pl2303_buf *pb)
183{
184 if (pb) {
185 kfree(pb->buf_buf);
186 kfree(pb);
187 }
188}
189
190/*
191 * pl2303_buf_clear
192 *
193 * Clear out all data in the circular buffer.
194 */
195static void pl2303_buf_clear(struct pl2303_buf *pb)
196{
197 if (pb != NULL)
198 pb->buf_get = pb->buf_put;
199 /* equivalent to a get of all data available */
200}
201
202/*
203 * pl2303_buf_data_avail
204 *
205 * Return the number of bytes of data available in the circular
206 * buffer.
207 */
208static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
209{
210 if (pb == NULL)
211 return 0;
212
213 return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
214}
215
216/*
217 * pl2303_buf_space_avail
218 *
219 * Return the number of bytes of space available in the circular
220 * buffer.
221 */
222static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
223{
224 if (pb == NULL)
225 return 0;
226
227 return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
228}
229
230/*
231 * pl2303_buf_put
232 *
233 * Copy data data from a user buffer and put it into the circular buffer.
234 * Restrict to the amount of space available.
235 *
236 * Return the number of bytes copied.
237 */
238static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
239 unsigned int count)
240{
241 unsigned int len;
242
243 if (pb == NULL)
244 return 0;
245
246 len = pl2303_buf_space_avail(pb);
247 if (count > len)
248 count = len;
249
250 if (count == 0)
251 return 0;
252
253 len = pb->buf_buf + pb->buf_size - pb->buf_put;
254 if (count > len) {
255 memcpy(pb->buf_put, buf, len);
256 memcpy(pb->buf_buf, buf+len, count - len);
257 pb->buf_put = pb->buf_buf + count - len;
258 } else {
259 memcpy(pb->buf_put, buf, count);
260 if (count < len)
261 pb->buf_put += count;
262 else /* count == len */
263 pb->buf_put = pb->buf_buf;
264 }
265
266 return count;
267}
268
269/*
270 * pl2303_buf_get
271 *
272 * Get data from the circular buffer and copy to the given buffer.
273 * Restrict to the amount of data available.
274 *
275 * Return the number of bytes copied.
276 */
277static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
278 unsigned int count)
279{
280 unsigned int len;
281
282 if (pb == NULL)
283 return 0;
284
285 len = pl2303_buf_data_avail(pb);
286 if (count > len)
287 count = len;
288
289 if (count == 0)
290 return 0;
291
292 len = pb->buf_buf + pb->buf_size - pb->buf_get;
293 if (count > len) {
294 memcpy(buf, pb->buf_get, len);
295 memcpy(buf+len, pb->buf_buf, count - len);
296 pb->buf_get = pb->buf_buf + count - len;
297 } else {
298 memcpy(buf, pb->buf_get, count);
299 if (count < len)
300 pb->buf_get += count;
301 else /* count == len */
302 pb->buf_get = pb->buf_buf;
303 }
304
305 return count;
306}
307
308static int pl2303_startup(struct usb_serial *serial)
209{ 309{
210 struct pl2303_private *priv; 310 struct pl2303_private *priv;
211 enum pl2303_type type = type_0; 311 enum pl2303_type type = type_0;
@@ -247,36 +347,17 @@ cleanup:
247 return -ENOMEM; 347 return -ENOMEM;
248} 348}
249 349
250static int set_control_lines (struct usb_device *dev, u8 value) 350static int set_control_lines(struct usb_device *dev, u8 value)
251{ 351{
252 int retval; 352 int retval;
253 353
254 retval = usb_control_msg (dev, usb_sndctrlpipe (dev, 0), 354 retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
255 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE, 355 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
256 value, 0, NULL, 0, 100); 356 value, 0, NULL, 0, 100);
257 dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval); 357 dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval);
258 return retval; 358 return retval;
259} 359}
260 360
261static int pl2303_write (struct usb_serial_port *port, const unsigned char *buf, int count)
262{
263 struct pl2303_private *priv = usb_get_serial_port_data(port);
264 unsigned long flags;
265
266 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
267
268 if (!count)
269 return count;
270
271 spin_lock_irqsave(&priv->lock, flags);
272 count = pl2303_buf_put(priv->buf, buf, count);
273 spin_unlock_irqrestore(&priv->lock, flags);
274
275 pl2303_send(port);
276
277 return count;
278}
279
280static void pl2303_send(struct usb_serial_port *port) 361static void pl2303_send(struct usb_serial_port *port)
281{ 362{
282 int count, result; 363 int count, result;
@@ -293,7 +374,7 @@ static void pl2303_send(struct usb_serial_port *port)
293 } 374 }
294 375
295 count = pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer, 376 count = pl2303_buf_get(priv->buf, port->write_urb->transfer_buffer,
296 port->bulk_out_size); 377 port->bulk_out_size);
297 378
298 if (count == 0) { 379 if (count == 0) {
299 spin_unlock_irqrestore(&priv->lock, flags); 380 spin_unlock_irqrestore(&priv->lock, flags);
@@ -304,13 +385,15 @@ static void pl2303_send(struct usb_serial_port *port)
304 385
305 spin_unlock_irqrestore(&priv->lock, flags); 386 spin_unlock_irqrestore(&priv->lock, flags);
306 387
307 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count, port->write_urb->transfer_buffer); 388 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,
389 port->write_urb->transfer_buffer);
308 390
309 port->write_urb->transfer_buffer_length = count; 391 port->write_urb->transfer_buffer_length = count;
310 port->write_urb->dev = port->serial->dev; 392 port->write_urb->dev = port->serial->dev;
311 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 393 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
312 if (result) { 394 if (result) {
313 dev_err(&port->dev, "%s - failed submitting write urb, error %d\n", __FUNCTION__, result); 395 dev_err(&port->dev, "%s - failed submitting write urb,"
396 " error %d\n", __FUNCTION__, result);
314 priv->write_urb_in_use = 0; 397 priv->write_urb_in_use = 0;
315 // TODO: reschedule pl2303_send 398 // TODO: reschedule pl2303_send
316 } 399 }
@@ -318,6 +401,26 @@ static void pl2303_send(struct usb_serial_port *port)
318 usb_serial_port_softint(port); 401 usb_serial_port_softint(port);
319} 402}
320 403
404static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
405 int count)
406{
407 struct pl2303_private *priv = usb_get_serial_port_data(port);
408 unsigned long flags;
409
410 dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
411
412 if (!count)
413 return count;
414
415 spin_lock_irqsave(&priv->lock, flags);
416 count = pl2303_buf_put(priv->buf, buf, count);
417 spin_unlock_irqrestore(&priv->lock, flags);
418
419 pl2303_send(port);
420
421 return count;
422}
423
321static int pl2303_write_room(struct usb_serial_port *port) 424static int pl2303_write_room(struct usb_serial_port *port)
322{ 425{
323 struct pl2303_private *priv = usb_get_serial_port_data(port); 426 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -350,7 +453,8 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
350 return chars; 453 return chars;
351} 454}
352 455
353static void pl2303_set_termios (struct usb_serial_port *port, struct termios *old_termios) 456static void pl2303_set_termios(struct usb_serial_port *port,
457 struct termios *old_termios)
354{ 458{
355 struct usb_serial *serial = port->serial; 459 struct usb_serial *serial = port->serial;
356 struct pl2303_private *priv = usb_get_serial_port_data(port); 460 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -371,7 +475,8 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
371 spin_lock_irqsave(&priv->lock, flags); 475 spin_lock_irqsave(&priv->lock, flags);
372 if (!priv->termios_initialized) { 476 if (!priv->termios_initialized) {
373 *(port->tty->termios) = tty_std_termios; 477 *(port->tty->termios) = tty_std_termios;
374 port->tty->termios->c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; 478 port->tty->termios->c_cflag = B9600 | CS8 | CREAD |
479 HUPCL | CLOCAL;
375 priv->termios_initialized = 1; 480 priv->termios_initialized = 1;
376 } 481 }
377 spin_unlock_irqrestore(&priv->lock, flags); 482 spin_unlock_irqrestore(&priv->lock, flags);
@@ -380,24 +485,24 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
380 /* check that they really want us to change something */ 485 /* check that they really want us to change something */
381 if (old_termios) { 486 if (old_termios) {
382 if ((cflag == old_termios->c_cflag) && 487 if ((cflag == old_termios->c_cflag) &&
383 (RELEVANT_IFLAG(port->tty->termios->c_iflag) == RELEVANT_IFLAG(old_termios->c_iflag))) { 488 (RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
384 dbg("%s - nothing to change...", __FUNCTION__); 489 RELEVANT_IFLAG(old_termios->c_iflag))) {
385 return; 490 dbg("%s - nothing to change...", __FUNCTION__);
491 return;
386 } 492 }
387 } 493 }
388 494
389 buf = kzalloc (7, GFP_KERNEL); 495 buf = kzalloc(7, GFP_KERNEL);
390 if (!buf) { 496 if (!buf) {
391 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__); 497 dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
392 return; 498 return;
393 } 499 }
394
395 i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0),
396 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
397 0, 0, buf, 7, 100);
398 dbg ("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
399 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
400 500
501 i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
502 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
503 0, 0, buf, 7, 100);
504 dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
505 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
401 506
402 if (cflag & CSIZE) { 507 if (cflag & CSIZE) {
403 switch (cflag & CSIZE) { 508 switch (cflag & CSIZE) {
@@ -429,7 +534,8 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
429 case B230400: baud = 230400; break; 534 case B230400: baud = 230400; break;
430 case B460800: baud = 460800; break; 535 case B460800: baud = 460800; break;
431 default: 536 default:
432 dev_err(&port->dev, "pl2303 driver does not support the baudrate requested (fix it)\n"); 537 dev_err(&port->dev, "pl2303 driver does not support"
538 " the baudrate requested (fix it)\n");
433 break; 539 break;
434 } 540 }
435 dbg("%s - baud = %d", __FUNCTION__, baud); 541 dbg("%s - baud = %d", __FUNCTION__, baud);
@@ -469,10 +575,10 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
469 dbg("%s - parity = none", __FUNCTION__); 575 dbg("%s - parity = none", __FUNCTION__);
470 } 576 }
471 577
472 i = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0), 578 i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
473 SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE, 579 SET_LINE_REQUEST, SET_LINE_REQUEST_TYPE,
474 0, 0, buf, 7, 100); 580 0, 0, buf, 7, 100);
475 dbg ("0x21:0x20:0:0 %d", i); 581 dbg("0x21:0x20:0:0 %d", i);
476 582
477 /* change control lines if we are switching to or from B0 */ 583 /* change control lines if we are switching to or from B0 */
478 spin_lock_irqsave(&priv->lock, flags); 584 spin_lock_irqsave(&priv->lock, flags);
@@ -488,13 +594,13 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
488 } else { 594 } else {
489 spin_unlock_irqrestore(&priv->lock, flags); 595 spin_unlock_irqrestore(&priv->lock, flags);
490 } 596 }
491 597
492 buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0; 598 buf[0] = buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = 0;
493 599
494 i = usb_control_msg (serial->dev, usb_rcvctrlpipe (serial->dev, 0), 600 i = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
495 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE, 601 GET_LINE_REQUEST, GET_LINE_REQUEST_TYPE,
496 0, 0, buf, 7, 100); 602 0, 0, buf, 7, 100);
497 dbg ("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i, 603 dbg("0xa1:0x21:0:0 %d - %x %x %x %x %x %x %x", i,
498 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 604 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
499 605
500 if (cflag & CRTSCTS) { 606 if (cflag & CRTSCTS) {
@@ -503,18 +609,82 @@ static void pl2303_set_termios (struct usb_serial_port *port, struct termios *ol
503 index = 0x61; 609 index = 0x61;
504 else 610 else
505 index = 0x41; 611 index = 0x41;
506 i = usb_control_msg(serial->dev, 612 i = usb_control_msg(serial->dev,
507 usb_sndctrlpipe(serial->dev, 0), 613 usb_sndctrlpipe(serial->dev, 0),
508 VENDOR_WRITE_REQUEST, 614 VENDOR_WRITE_REQUEST,
509 VENDOR_WRITE_REQUEST_TYPE, 615 VENDOR_WRITE_REQUEST_TYPE,
510 0x0, index, NULL, 0, 100); 616 0x0, index, NULL, 0, 100);
511 dbg ("0x40:0x1:0x0:0x%x %d", index, i); 617 dbg("0x40:0x1:0x0:0x%x %d", index, i);
618 }
619
620 kfree(buf);
621}
622
623static void pl2303_close(struct usb_serial_port *port, struct file *filp)
624{
625 struct pl2303_private *priv = usb_get_serial_port_data(port);
626 unsigned long flags;
627 unsigned int c_cflag;
628 int bps;
629 long timeout;
630 wait_queue_t wait;
631
632 dbg("%s - port %d", __FUNCTION__, port->number);
633
634 /* wait for data to drain from the buffer */
635 spin_lock_irqsave(&priv->lock, flags);
636 timeout = PL2303_CLOSING_WAIT;
637 init_waitqueue_entry(&wait, current);
638 add_wait_queue(&port->tty->write_wait, &wait);
639 for (;;) {
640 set_current_state(TASK_INTERRUPTIBLE);
641 if (pl2303_buf_data_avail(priv->buf) == 0 ||
642 timeout == 0 || signal_pending(current) ||
643 !usb_get_intfdata(port->serial->interface)) /* disconnect */
644 break;
645 spin_unlock_irqrestore(&priv->lock, flags);
646 timeout = schedule_timeout(timeout);
647 spin_lock_irqsave(&priv->lock, flags);
512 } 648 }
649 set_current_state(TASK_RUNNING);
650 remove_wait_queue(&port->tty->write_wait, &wait);
651 /* clear out any remaining data in the buffer */
652 pl2303_buf_clear(priv->buf);
653 spin_unlock_irqrestore(&priv->lock, flags);
654
655 /* wait for characters to drain from the device */
656 /* (this is long enough for the entire 256 byte */
657 /* pl2303 hardware buffer to drain with no flow */
658 /* control for data rates of 1200 bps or more, */
659 /* for lower rates we should really know how much */
660 /* data is in the buffer to compute a delay */
661 /* that is not unnecessarily long) */
662 bps = tty_get_baud_rate(port->tty);
663 if (bps > 1200)
664 timeout = max((HZ*2560)/bps,HZ/10);
665 else
666 timeout = 2*HZ;
667 schedule_timeout_interruptible(timeout);
513 668
514 kfree (buf); 669 /* shutdown our urbs */
670 dbg("%s - shutting down urbs", __FUNCTION__);
671 usb_kill_urb(port->write_urb);
672 usb_kill_urb(port->read_urb);
673 usb_kill_urb(port->interrupt_in_urb);
674
675 if (port->tty) {
676 c_cflag = port->tty->termios->c_cflag;
677 if (c_cflag & HUPCL) {
678 /* drop DTR and RTS */
679 spin_lock_irqsave(&priv->lock, flags);
680 priv->line_control = 0;
681 spin_unlock_irqrestore(&priv->lock, flags);
682 set_control_lines(port->serial->dev, 0);
683 }
684 }
515} 685}
516 686
517static int pl2303_open (struct usb_serial_port *port, struct file *filp) 687static int pl2303_open(struct usb_serial_port *port, struct file *filp)
518{ 688{
519 struct termios tmp_termios; 689 struct termios tmp_termios;
520 struct usb_serial *serial = port->serial; 690 struct usb_serial *serial = port->serial;
@@ -568,98 +738,35 @@ static int pl2303_open (struct usb_serial_port *port, struct file *filp)
568 738
569 /* Setup termios */ 739 /* Setup termios */
570 if (port->tty) { 740 if (port->tty) {
571 pl2303_set_termios (port, &tmp_termios); 741 pl2303_set_termios(port, &tmp_termios);
572 } 742 }
573 743
574 //FIXME: need to assert RTS and DTR if CRTSCTS off 744 //FIXME: need to assert RTS and DTR if CRTSCTS off
575 745
576 dbg("%s - submitting read urb", __FUNCTION__); 746 dbg("%s - submitting read urb", __FUNCTION__);
577 port->read_urb->dev = serial->dev; 747 port->read_urb->dev = serial->dev;
578 result = usb_submit_urb (port->read_urb, GFP_KERNEL); 748 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
579 if (result) { 749 if (result) {
580 dev_err(&port->dev, "%s - failed submitting read urb, error %d\n", __FUNCTION__, result); 750 dev_err(&port->dev, "%s - failed submitting read urb,"
581 pl2303_close (port, NULL); 751 " error %d\n", __FUNCTION__, result);
752 pl2303_close(port, NULL);
582 return -EPROTO; 753 return -EPROTO;
583 } 754 }
584 755
585 dbg("%s - submitting interrupt urb", __FUNCTION__); 756 dbg("%s - submitting interrupt urb", __FUNCTION__);
586 port->interrupt_in_urb->dev = serial->dev; 757 port->interrupt_in_urb->dev = serial->dev;
587 result = usb_submit_urb (port->interrupt_in_urb, GFP_KERNEL); 758 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
588 if (result) { 759 if (result) {
589 dev_err(&port->dev, "%s - failed submitting interrupt urb, error %d\n", __FUNCTION__, result); 760 dev_err(&port->dev, "%s - failed submitting interrupt urb,"
590 pl2303_close (port, NULL); 761 " error %d\n", __FUNCTION__, result);
762 pl2303_close(port, NULL);
591 return -EPROTO; 763 return -EPROTO;
592 } 764 }
593 return 0; 765 return 0;
594} 766}
595 767
596 768static int pl2303_tiocmset(struct usb_serial_port *port, struct file *file,
597static void pl2303_close (struct usb_serial_port *port, struct file *filp) 769 unsigned int set, unsigned int clear)
598{
599 struct pl2303_private *priv = usb_get_serial_port_data(port);
600 unsigned long flags;
601 unsigned int c_cflag;
602 int bps;
603 long timeout;
604 wait_queue_t wait;
605
606 dbg("%s - port %d", __FUNCTION__, port->number);
607
608 /* wait for data to drain from the buffer */
609 spin_lock_irqsave(&priv->lock, flags);
610 timeout = PL2303_CLOSING_WAIT;
611 init_waitqueue_entry(&wait, current);
612 add_wait_queue(&port->tty->write_wait, &wait);
613 for (;;) {
614 set_current_state(TASK_INTERRUPTIBLE);
615 if (pl2303_buf_data_avail(priv->buf) == 0
616 || timeout == 0 || signal_pending(current)
617 || !usb_get_intfdata(port->serial->interface)) /* disconnect */
618 break;
619 spin_unlock_irqrestore(&priv->lock, flags);
620 timeout = schedule_timeout(timeout);
621 spin_lock_irqsave(&priv->lock, flags);
622 }
623 set_current_state(TASK_RUNNING);
624 remove_wait_queue(&port->tty->write_wait, &wait);
625 /* clear out any remaining data in the buffer */
626 pl2303_buf_clear(priv->buf);
627 spin_unlock_irqrestore(&priv->lock, flags);
628
629 /* wait for characters to drain from the device */
630 /* (this is long enough for the entire 256 byte */
631 /* pl2303 hardware buffer to drain with no flow */
632 /* control for data rates of 1200 bps or more, */
633 /* for lower rates we should really know how much */
634 /* data is in the buffer to compute a delay */
635 /* that is not unnecessarily long) */
636 bps = tty_get_baud_rate(port->tty);
637 if (bps > 1200)
638 timeout = max((HZ*2560)/bps,HZ/10);
639 else
640 timeout = 2*HZ;
641 schedule_timeout_interruptible(timeout);
642
643 /* shutdown our urbs */
644 dbg("%s - shutting down urbs", __FUNCTION__);
645 usb_kill_urb(port->write_urb);
646 usb_kill_urb(port->read_urb);
647 usb_kill_urb(port->interrupt_in_urb);
648
649 if (port->tty) {
650 c_cflag = port->tty->termios->c_cflag;
651 if (c_cflag & HUPCL) {
652 /* drop DTR and RTS */
653 spin_lock_irqsave(&priv->lock, flags);
654 priv->line_control = 0;
655 spin_unlock_irqrestore (&priv->lock, flags);
656 set_control_lines (port->serial->dev, 0);
657 }
658 }
659}
660
661static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
662 unsigned int set, unsigned int clear)
663{ 770{
664 struct pl2303_private *priv = usb_get_serial_port_data(port); 771 struct pl2303_private *priv = usb_get_serial_port_data(port);
665 unsigned long flags; 772 unsigned long flags;
@@ -668,7 +775,7 @@ static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
668 if (!usb_get_intfdata(port->serial->interface)) 775 if (!usb_get_intfdata(port->serial->interface))
669 return -ENODEV; 776 return -ENODEV;
670 777
671 spin_lock_irqsave (&priv->lock, flags); 778 spin_lock_irqsave(&priv->lock, flags);
672 if (set & TIOCM_RTS) 779 if (set & TIOCM_RTS)
673 priv->line_control |= CONTROL_RTS; 780 priv->line_control |= CONTROL_RTS;
674 if (set & TIOCM_DTR) 781 if (set & TIOCM_DTR)
@@ -678,12 +785,12 @@ static int pl2303_tiocmset (struct usb_serial_port *port, struct file *file,
678 if (clear & TIOCM_DTR) 785 if (clear & TIOCM_DTR)
679 priv->line_control &= ~CONTROL_DTR; 786 priv->line_control &= ~CONTROL_DTR;
680 control = priv->line_control; 787 control = priv->line_control;
681 spin_unlock_irqrestore (&priv->lock, flags); 788 spin_unlock_irqrestore(&priv->lock, flags);
682 789
683 return set_control_lines (port->serial->dev, control); 790 return set_control_lines(port->serial->dev, control);
684} 791}
685 792
686static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file) 793static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
687{ 794{
688 struct pl2303_private *priv = usb_get_serial_port_data(port); 795 struct pl2303_private *priv = usb_get_serial_port_data(port);
689 unsigned long flags; 796 unsigned long flags;
@@ -696,10 +803,10 @@ static int pl2303_tiocmget (struct usb_serial_port *port, struct file *file)
696 if (!usb_get_intfdata(port->serial->interface)) 803 if (!usb_get_intfdata(port->serial->interface))
697 return -ENODEV; 804 return -ENODEV;
698 805
699 spin_lock_irqsave (&priv->lock, flags); 806 spin_lock_irqsave(&priv->lock, flags);
700 mcr = priv->line_control; 807 mcr = priv->line_control;
701 status = priv->line_status; 808 status = priv->line_status;
702 spin_unlock_irqrestore (&priv->lock, flags); 809 spin_unlock_irqrestore(&priv->lock, flags);
703 810
704 result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0) 811 result = ((mcr & CONTROL_DTR) ? TIOCM_DTR : 0)
705 | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0) 812 | ((mcr & CONTROL_RTS) ? TIOCM_RTS : 0)
@@ -721,22 +828,22 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
721 unsigned int status; 828 unsigned int status;
722 unsigned int changed; 829 unsigned int changed;
723 830
724 spin_lock_irqsave (&priv->lock, flags); 831 spin_lock_irqsave(&priv->lock, flags);
725 prevstatus = priv->line_status; 832 prevstatus = priv->line_status;
726 spin_unlock_irqrestore (&priv->lock, flags); 833 spin_unlock_irqrestore(&priv->lock, flags);
727 834
728 while (1) { 835 while (1) {
729 interruptible_sleep_on(&priv->delta_msr_wait); 836 interruptible_sleep_on(&priv->delta_msr_wait);
730 /* see if a signal did it */ 837 /* see if a signal did it */
731 if (signal_pending(current)) 838 if (signal_pending(current))
732 return -ERESTARTSYS; 839 return -ERESTARTSYS;
733 840
734 spin_lock_irqsave (&priv->lock, flags); 841 spin_lock_irqsave(&priv->lock, flags);
735 status = priv->line_status; 842 status = priv->line_status;
736 spin_unlock_irqrestore (&priv->lock, flags); 843 spin_unlock_irqrestore(&priv->lock, flags);
737 844
738 changed=prevstatus^status; 845 changed=prevstatus^status;
739 846
740 if (((arg & TIOCM_RNG) && (changed & UART_RING)) || 847 if (((arg & TIOCM_RNG) && (changed & UART_RING)) ||
741 ((arg & TIOCM_DSR) && (changed & UART_DSR)) || 848 ((arg & TIOCM_DSR) && (changed & UART_DSR)) ||
742 ((arg & TIOCM_CD) && (changed & UART_DCD)) || 849 ((arg & TIOCM_CD) && (changed & UART_DCD)) ||
@@ -749,7 +856,8 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
749 return 0; 856 return 0;
750} 857}
751 858
752static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg) 859static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
860 unsigned int cmd, unsigned long arg)
753{ 861{
754 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd); 862 dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
755 863
@@ -766,7 +874,7 @@ static int pl2303_ioctl (struct usb_serial_port *port, struct file *file, unsign
766 return -ENOIOCTLCMD; 874 return -ENOIOCTLCMD;
767} 875}
768 876
769static void pl2303_break_ctl (struct usb_serial_port *port, int break_state) 877static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
770{ 878{
771 struct usb_serial *serial = port->serial; 879 struct usb_serial *serial = port->serial;
772 u16 state; 880 u16 state;
@@ -780,15 +888,14 @@ static void pl2303_break_ctl (struct usb_serial_port *port, int break_state)
780 state = BREAK_ON; 888 state = BREAK_ON;
781 dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on"); 889 dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on");
782 890
783 result = usb_control_msg (serial->dev, usb_sndctrlpipe (serial->dev, 0), 891 result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
784 BREAK_REQUEST, BREAK_REQUEST_TYPE, state, 892 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
785 0, NULL, 0, 100); 893 0, NULL, 0, 100);
786 if (result) 894 if (result)
787 dbg("%s - error sending break = %d", __FUNCTION__, result); 895 dbg("%s - error sending break = %d", __FUNCTION__, result);
788} 896}
789 897
790 898static void pl2303_shutdown(struct usb_serial *serial)
791static void pl2303_shutdown (struct usb_serial *serial)
792{ 899{
793 int i; 900 int i;
794 struct pl2303_private *priv; 901 struct pl2303_private *priv;
@@ -802,7 +909,7 @@ static void pl2303_shutdown (struct usb_serial *serial)
802 kfree(priv); 909 kfree(priv);
803 usb_set_serial_port_data(serial->port[i], NULL); 910 usb_set_serial_port_data(serial->port[i], NULL);
804 } 911 }
805 } 912 }
806} 913}
807 914
808static void pl2303_update_line_status(struct usb_serial_port *port, 915static void pl2303_update_line_status(struct usb_serial_port *port,
@@ -814,29 +921,33 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
814 unsigned long flags; 921 unsigned long flags;
815 u8 status_idx = UART_STATE; 922 u8 status_idx = UART_STATE;
816 u8 length = UART_STATE + 1; 923 u8 length = UART_STATE + 1;
924 u16 idv, idp;
925
926 idv = le16_to_cpu(port->serial->dev->descriptor.idVendor);
927 idp = le16_to_cpu(port->serial->dev->descriptor.idProduct);
817 928
818 if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && 929
819 (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65 || 930 if (idv == SIEMENS_VENDOR_ID) {
820 le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_SX1 || 931 if (idp == SIEMENS_PRODUCT_ID_X65 ||
821 le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X75)) { 932 idp == SIEMENS_PRODUCT_ID_SX1 ||
822 length = 1; 933 idp == SIEMENS_PRODUCT_ID_X75) {
823 status_idx = 0; 934
935 length = 1;
936 status_idx = 0;
937 }
824 } 938 }
825 939
826 if (actual_length < length) 940 if (actual_length < length)
827 goto exit; 941 return;
828 942
829 /* Save off the uart status for others to look at */ 943 /* Save off the uart status for others to look at */
830 spin_lock_irqsave(&priv->lock, flags); 944 spin_lock_irqsave(&priv->lock, flags);
831 priv->line_status = data[status_idx]; 945 priv->line_status = data[status_idx];
832 spin_unlock_irqrestore(&priv->lock, flags); 946 spin_unlock_irqrestore(&priv->lock, flags);
833 wake_up_interruptible (&priv->delta_msr_wait); 947 wake_up_interruptible(&priv->delta_msr_wait);
834
835exit:
836 return;
837} 948}
838 949
839static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs) 950static void pl2303_read_int_callback(struct urb *urb, struct pt_regs *regs)
840{ 951{
841 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 952 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
842 unsigned char *data = urb->transfer_buffer; 953 unsigned char *data = urb->transfer_buffer;
@@ -853,25 +964,29 @@ static void pl2303_read_int_callback (struct urb *urb, struct pt_regs *regs)
853 case -ENOENT: 964 case -ENOENT:
854 case -ESHUTDOWN: 965 case -ESHUTDOWN:
855 /* this urb is terminated, clean up */ 966 /* this urb is terminated, clean up */
856 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 967 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
968 urb->status);
857 return; 969 return;
858 default: 970 default:
859 dbg("%s - nonzero urb status received: %d", __FUNCTION__, urb->status); 971 dbg("%s - nonzero urb status received: %d", __FUNCTION__,
972 urb->status);
860 goto exit; 973 goto exit;
861 } 974 }
862 975
863 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, urb->transfer_buffer); 976 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
977 urb->actual_length, urb->transfer_buffer);
978
864 pl2303_update_line_status(port, data, actual_length); 979 pl2303_update_line_status(port, data, actual_length);
865 980
866exit: 981exit:
867 status = usb_submit_urb (urb, GFP_ATOMIC); 982 status = usb_submit_urb(urb, GFP_ATOMIC);
868 if (status) 983 if (status)
869 dev_err(&urb->dev->dev, "%s - usb_submit_urb failed with result %d\n", 984 dev_err(&urb->dev->dev,
985 "%s - usb_submit_urb failed with result %d\n",
870 __FUNCTION__, status); 986 __FUNCTION__, status);
871} 987}
872 988
873 989static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
874static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
875{ 990{
876 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 991 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
877 struct pl2303_private *priv = usb_get_serial_port_data(port); 992 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -892,20 +1007,25 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
892 return; 1007 return;
893 } 1008 }
894 if (urb->status == -EPROTO) { 1009 if (urb->status == -EPROTO) {
895 /* PL2303 mysteriously fails with -EPROTO reschedule the read */ 1010 /* PL2303 mysteriously fails with -EPROTO reschedule
896 dbg("%s - caught -EPROTO, resubmitting the urb", __FUNCTION__); 1011 * the read */
1012 dbg("%s - caught -EPROTO, resubmitting the urb",
1013 __FUNCTION__);
897 urb->status = 0; 1014 urb->status = 0;
898 urb->dev = port->serial->dev; 1015 urb->dev = port->serial->dev;
899 result = usb_submit_urb(urb, GFP_ATOMIC); 1016 result = usb_submit_urb(urb, GFP_ATOMIC);
900 if (result) 1017 if (result)
901 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1018 dev_err(&urb->dev->dev, "%s - failed"
1019 " resubmitting read urb, error %d\n",
1020 __FUNCTION__, result);
902 return; 1021 return;
903 } 1022 }
904 dbg("%s - unable to handle the error, exiting.", __FUNCTION__); 1023 dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
905 return; 1024 return;
906 } 1025 }
907 1026
908 usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data); 1027 usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
1028 urb->actual_length, data);
909 1029
910 /* get tty_flag from status */ 1030 /* get tty_flag from status */
911 tty_flag = TTY_NORMAL; 1031 tty_flag = TTY_NORMAL;
@@ -914,7 +1034,7 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
914 status = priv->line_status; 1034 status = priv->line_status;
915 priv->line_status &= ~UART_STATE_TRANSIENT_MASK; 1035 priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
916 spin_unlock_irqrestore(&priv->lock, flags); 1036 spin_unlock_irqrestore(&priv->lock, flags);
917 wake_up_interruptible (&priv->delta_msr_wait); 1037 wake_up_interruptible(&priv->delta_msr_wait);
918 1038
919 /* break takes precedence over parity, */ 1039 /* break takes precedence over parity, */
920 /* which takes precedence over framing errors */ 1040 /* which takes precedence over framing errors */
@@ -933,8 +1053,8 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
933 if (status & UART_OVERRUN_ERROR) 1053 if (status & UART_OVERRUN_ERROR)
934 tty_insert_flip_char(tty, 0, TTY_OVERRUN); 1054 tty_insert_flip_char(tty, 0, TTY_OVERRUN);
935 for (i = 0; i < urb->actual_length; ++i) 1055 for (i = 0; i < urb->actual_length; ++i)
936 tty_insert_flip_char (tty, data[i], tty_flag); 1056 tty_insert_flip_char(tty, data[i], tty_flag);
937 tty_flip_buffer_push (tty); 1057 tty_flip_buffer_push(tty);
938 } 1058 }
939 1059
940 /* Schedule the next read _if_ we are still open */ 1060 /* Schedule the next read _if_ we are still open */
@@ -942,15 +1062,14 @@ static void pl2303_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
942 urb->dev = port->serial->dev; 1062 urb->dev = port->serial->dev;
943 result = usb_submit_urb(urb, GFP_ATOMIC); 1063 result = usb_submit_urb(urb, GFP_ATOMIC);
944 if (result) 1064 if (result)
945 dev_err(&urb->dev->dev, "%s - failed resubmitting read urb, error %d\n", __FUNCTION__, result); 1065 dev_err(&urb->dev->dev, "%s - failed resubmitting"
1066 " read urb, error %d\n", __FUNCTION__, result);
946 } 1067 }
947 1068
948 return; 1069 return;
949} 1070}
950 1071
951 1072static void pl2303_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
952
953static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
954{ 1073{
955 struct usb_serial_port *port = (struct usb_serial_port *) urb->context; 1074 struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
956 struct pl2303_private *priv = usb_get_serial_port_data(port); 1075 struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -966,18 +1085,21 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
966 case -ENOENT: 1085 case -ENOENT:
967 case -ESHUTDOWN: 1086 case -ESHUTDOWN:
968 /* this urb is terminated, clean up */ 1087 /* this urb is terminated, clean up */
969 dbg("%s - urb shutting down with status: %d", __FUNCTION__, urb->status); 1088 dbg("%s - urb shutting down with status: %d", __FUNCTION__,
1089 urb->status);
970 priv->write_urb_in_use = 0; 1090 priv->write_urb_in_use = 0;
971 return; 1091 return;
972 default: 1092 default:
973 /* error in the urb, so we have to resubmit it */ 1093 /* error in the urb, so we have to resubmit it */
974 dbg("%s - Overflow in write", __FUNCTION__); 1094 dbg("%s - Overflow in write", __FUNCTION__);
975 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__, urb->status); 1095 dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
1096 urb->status);
976 port->write_urb->transfer_buffer_length = 1; 1097 port->write_urb->transfer_buffer_length = 1;
977 port->write_urb->dev = port->serial->dev; 1098 port->write_urb->dev = port->serial->dev;
978 result = usb_submit_urb (port->write_urb, GFP_ATOMIC); 1099 result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
979 if (result) 1100 if (result)
980 dev_err(&urb->dev->dev, "%s - failed resubmitting write urb, error %d\n", __FUNCTION__, result); 1101 dev_err(&urb->dev->dev, "%s - failed resubmitting write"
1102 " urb, error %d\n", __FUNCTION__, result);
981 else 1103 else
982 return; 1104 return;
983 } 1105 }
@@ -988,191 +1110,38 @@ static void pl2303_write_bulk_callback (struct urb *urb, struct pt_regs *regs)
988 pl2303_send(port); 1110 pl2303_send(port);
989} 1111}
990 1112
1113/* All of the device info needed for the PL2303 SIO serial converter */
1114static struct usb_serial_driver pl2303_device = {
1115 .driver = {
1116 .owner = THIS_MODULE,
1117 .name = "pl2303",
1118 },
1119 .id_table = id_table,
1120 .num_interrupt_in = NUM_DONT_CARE,
1121 .num_bulk_in = 1,
1122 .num_bulk_out = 1,
1123 .num_ports = 1,
1124 .open = pl2303_open,
1125 .close = pl2303_close,
1126 .write = pl2303_write,
1127 .ioctl = pl2303_ioctl,
1128 .break_ctl = pl2303_break_ctl,
1129 .set_termios = pl2303_set_termios,
1130 .tiocmget = pl2303_tiocmget,
1131 .tiocmset = pl2303_tiocmset,
1132 .read_bulk_callback = pl2303_read_bulk_callback,
1133 .read_int_callback = pl2303_read_int_callback,
1134 .write_bulk_callback = pl2303_write_bulk_callback,
1135 .write_room = pl2303_write_room,
1136 .chars_in_buffer = pl2303_chars_in_buffer,
1137 .attach = pl2303_startup,
1138 .shutdown = pl2303_shutdown,
1139};
991 1140
992/* 1141static int __init pl2303_init(void)
993 * pl2303_buf_alloc
994 *
995 * Allocate a circular buffer and all associated memory.
996 */
997
998static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
999{
1000
1001 struct pl2303_buf *pb;
1002
1003
1004 if (size == 0)
1005 return NULL;
1006
1007 pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
1008 if (pb == NULL)
1009 return NULL;
1010
1011 pb->buf_buf = kmalloc(size, GFP_KERNEL);
1012 if (pb->buf_buf == NULL) {
1013 kfree(pb);
1014 return NULL;
1015 }
1016
1017 pb->buf_size = size;
1018 pb->buf_get = pb->buf_put = pb->buf_buf;
1019
1020 return pb;
1021
1022}
1023
1024
1025/*
1026 * pl2303_buf_free
1027 *
1028 * Free the buffer and all associated memory.
1029 */
1030
1031static void pl2303_buf_free(struct pl2303_buf *pb)
1032{
1033 if (pb) {
1034 kfree(pb->buf_buf);
1035 kfree(pb);
1036 }
1037}
1038
1039
1040/*
1041 * pl2303_buf_clear
1042 *
1043 * Clear out all data in the circular buffer.
1044 */
1045
1046static void pl2303_buf_clear(struct pl2303_buf *pb)
1047{
1048 if (pb != NULL)
1049 pb->buf_get = pb->buf_put;
1050 /* equivalent to a get of all data available */
1051}
1052
1053
1054/*
1055 * pl2303_buf_data_avail
1056 *
1057 * Return the number of bytes of data available in the circular
1058 * buffer.
1059 */
1060
1061static unsigned int pl2303_buf_data_avail(struct pl2303_buf *pb)
1062{
1063 if (pb != NULL)
1064 return ((pb->buf_size + pb->buf_put - pb->buf_get) % pb->buf_size);
1065 else
1066 return 0;
1067}
1068
1069
1070/*
1071 * pl2303_buf_space_avail
1072 *
1073 * Return the number of bytes of space available in the circular
1074 * buffer.
1075 */
1076
1077static unsigned int pl2303_buf_space_avail(struct pl2303_buf *pb)
1078{
1079 if (pb != NULL)
1080 return ((pb->buf_size + pb->buf_get - pb->buf_put - 1) % pb->buf_size);
1081 else
1082 return 0;
1083}
1084
1085
1086/*
1087 * pl2303_buf_put
1088 *
1089 * Copy data data from a user buffer and put it into the circular buffer.
1090 * Restrict to the amount of space available.
1091 *
1092 * Return the number of bytes copied.
1093 */
1094
1095static unsigned int pl2303_buf_put(struct pl2303_buf *pb, const char *buf,
1096 unsigned int count)
1097{
1098
1099 unsigned int len;
1100
1101
1102 if (pb == NULL)
1103 return 0;
1104
1105 len = pl2303_buf_space_avail(pb);
1106 if (count > len)
1107 count = len;
1108
1109 if (count == 0)
1110 return 0;
1111
1112 len = pb->buf_buf + pb->buf_size - pb->buf_put;
1113 if (count > len) {
1114 memcpy(pb->buf_put, buf, len);
1115 memcpy(pb->buf_buf, buf+len, count - len);
1116 pb->buf_put = pb->buf_buf + count - len;
1117 } else {
1118 memcpy(pb->buf_put, buf, count);
1119 if (count < len)
1120 pb->buf_put += count;
1121 else /* count == len */
1122 pb->buf_put = pb->buf_buf;
1123 }
1124
1125 return count;
1126
1127}
1128
1129
1130/*
1131 * pl2303_buf_get
1132 *
1133 * Get data from the circular buffer and copy to the given buffer.
1134 * Restrict to the amount of data available.
1135 *
1136 * Return the number of bytes copied.
1137 */
1138
1139static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
1140 unsigned int count)
1141{
1142
1143 unsigned int len;
1144
1145
1146 if (pb == NULL)
1147 return 0;
1148
1149 len = pl2303_buf_data_avail(pb);
1150 if (count > len)
1151 count = len;
1152
1153 if (count == 0)
1154 return 0;
1155
1156 len = pb->buf_buf + pb->buf_size - pb->buf_get;
1157 if (count > len) {
1158 memcpy(buf, pb->buf_get, len);
1159 memcpy(buf+len, pb->buf_buf, count - len);
1160 pb->buf_get = pb->buf_buf + count - len;
1161 } else {
1162 memcpy(buf, pb->buf_get, count);
1163 if (count < len)
1164 pb->buf_get += count;
1165 else /* count == len */
1166 pb->buf_get = pb->buf_buf;
1167 }
1168
1169 return count;
1170
1171}
1172
1173static int __init pl2303_init (void)
1174{ 1142{
1175 int retval; 1143 int retval;
1144
1176 retval = usb_serial_register(&pl2303_device); 1145 retval = usb_serial_register(&pl2303_device);
1177 if (retval) 1146 if (retval)
1178 goto failed_usb_serial_register; 1147 goto failed_usb_serial_register;
@@ -1187,14 +1156,12 @@ failed_usb_serial_register:
1187 return retval; 1156 return retval;
1188} 1157}
1189 1158
1190 1159static void __exit pl2303_exit(void)
1191static void __exit pl2303_exit (void)
1192{ 1160{
1193 usb_deregister (&pl2303_driver); 1161 usb_deregister(&pl2303_driver);
1194 usb_serial_deregister (&pl2303_device); 1162 usb_serial_deregister(&pl2303_device);
1195} 1163}
1196 1164
1197
1198module_init(pl2303_init); 1165module_init(pl2303_init);
1199module_exit(pl2303_exit); 1166module_exit(pl2303_exit);
1200 1167
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 55195e76eb6f..762cc290ef58 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -89,3 +89,7 @@
89/* Belkin "F5U257" Serial Adapter */ 89/* Belkin "F5U257" Serial Adapter */
90#define BELKIN_VENDOR_ID 0x050d 90#define BELKIN_VENDOR_ID 0x050d
91#define BELKIN_PRODUCT_ID 0x0257 91#define BELKIN_PRODUCT_ID 0x0257
92
93/* Alcor Micro Corp. USB 2.0 TO RS-232 */
94#define ALCOR_VENDOR_ID 0x058F
95#define ALCOR_PRODUCT_ID 0x9720
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index e06a41bd0f3b..0222d92842b8 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -676,33 +676,29 @@ int usb_serial_probe(struct usb_interface *interface,
676 iface_desc = interface->cur_altsetting; 676 iface_desc = interface->cur_altsetting;
677 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 677 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
678 endpoint = &iface_desc->endpoint[i].desc; 678 endpoint = &iface_desc->endpoint[i].desc;
679 679
680 if ((endpoint->bEndpointAddress & 0x80) && 680 if (usb_endpoint_is_bulk_in(endpoint)) {
681 ((endpoint->bmAttributes & 3) == 0x02)) {
682 /* we found a bulk in endpoint */ 681 /* we found a bulk in endpoint */
683 dbg("found bulk in on endpoint %d", i); 682 dbg("found bulk in on endpoint %d", i);
684 bulk_in_endpoint[num_bulk_in] = endpoint; 683 bulk_in_endpoint[num_bulk_in] = endpoint;
685 ++num_bulk_in; 684 ++num_bulk_in;
686 } 685 }
687 686
688 if (((endpoint->bEndpointAddress & 0x80) == 0x00) && 687 if (usb_endpoint_is_bulk_out(endpoint)) {
689 ((endpoint->bmAttributes & 3) == 0x02)) {
690 /* we found a bulk out endpoint */ 688 /* we found a bulk out endpoint */
691 dbg("found bulk out on endpoint %d", i); 689 dbg("found bulk out on endpoint %d", i);
692 bulk_out_endpoint[num_bulk_out] = endpoint; 690 bulk_out_endpoint[num_bulk_out] = endpoint;
693 ++num_bulk_out; 691 ++num_bulk_out;
694 } 692 }
695 693
696 if ((endpoint->bEndpointAddress & 0x80) && 694 if (usb_endpoint_is_int_in(endpoint)) {
697 ((endpoint->bmAttributes & 3) == 0x03)) {
698 /* we found a interrupt in endpoint */ 695 /* we found a interrupt in endpoint */
699 dbg("found interrupt in on endpoint %d", i); 696 dbg("found interrupt in on endpoint %d", i);
700 interrupt_in_endpoint[num_interrupt_in] = endpoint; 697 interrupt_in_endpoint[num_interrupt_in] = endpoint;
701 ++num_interrupt_in; 698 ++num_interrupt_in;
702 } 699 }
703 700
704 if (((endpoint->bEndpointAddress & 0x80) == 0x00) && 701 if (usb_endpoint_is_int_out(endpoint)) {
705 ((endpoint->bmAttributes & 3) == 0x03)) {
706 /* we found an interrupt out endpoint */ 702 /* we found an interrupt out endpoint */
707 dbg("found interrupt out on endpoint %d", i); 703 dbg("found interrupt out on endpoint %d", i);
708 interrupt_out_endpoint[num_interrupt_out] = endpoint; 704 interrupt_out_endpoint[num_interrupt_out] = endpoint;
@@ -716,14 +712,15 @@ int usb_serial_probe(struct usb_interface *interface,
716 if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) && 712 if (((le16_to_cpu(dev->descriptor.idVendor) == PL2303_VENDOR_ID) &&
717 (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) || 713 (le16_to_cpu(dev->descriptor.idProduct) == PL2303_PRODUCT_ID)) ||
718 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && 714 ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) &&
719 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID))) { 715 (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) ||
716 ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) &&
717 (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) {
720 if (interface != dev->actconfig->interface[0]) { 718 if (interface != dev->actconfig->interface[0]) {
721 /* check out the endpoints of the other interface*/ 719 /* check out the endpoints of the other interface*/
722 iface_desc = dev->actconfig->interface[0]->cur_altsetting; 720 iface_desc = dev->actconfig->interface[0]->cur_altsetting;
723 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { 721 for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
724 endpoint = &iface_desc->endpoint[i].desc; 722 endpoint = &iface_desc->endpoint[i].desc;
725 if ((endpoint->bEndpointAddress & 0x80) && 723 if (usb_endpoint_is_int_in(endpoint)) {
726 ((endpoint->bmAttributes & 3) == 0x03)) {
727 /* we found a interrupt in endpoint */ 724 /* we found a interrupt in endpoint */
728 dbg("found interrupt in for Prolific device on separate interface"); 725 dbg("found interrupt in for Prolific device on separate interface");
729 interrupt_in_endpoint[num_interrupt_in] = endpoint; 726 interrupt_in_endpoint[num_interrupt_in] = endpoint;
@@ -937,7 +934,10 @@ int usb_serial_probe(struct usb_interface *interface,
937 934
938 snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number); 935 snprintf (&port->dev.bus_id[0], sizeof(port->dev.bus_id), "ttyUSB%d", port->number);
939 dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id); 936 dbg ("%s - registering %s", __FUNCTION__, port->dev.bus_id);
940 device_register (&port->dev); 937 retval = device_register(&port->dev);
938 if (retval)
939 dev_err(&port->dev, "Error registering port device, "
940 "continuing\n");
941 } 941 }
942 942
943 usb_serial_console_init (debug, minor); 943 usb_serial_console_init (debug, minor);
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index be9eec225743..86e48c42d6af 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -135,6 +135,18 @@ config USB_STORAGE_ONETOUCH
135 this input in any keybinding software. (e.g. gnome's keyboard short- 135 this input in any keybinding software. (e.g. gnome's keyboard short-
136 cuts) 136 cuts)
137 137
138config USB_STORAGE_KARMA
139 bool "Support for Rio Karma music player"
140 depends on USB_STORAGE
141 help
142 Say Y here to include additional code to support the Rio Karma
143 USB interface.
144
145 This code places the Rio Karma into mass storage mode, enabling
146 it to be mounted as an ordinary filesystem. Performing an eject
147 on the resulting scsi device node returns the Karma to normal
148 operation.
149
138config USB_LIBUSUAL 150config USB_LIBUSUAL
139 bool "The shared table of common (or usual) storage devices" 151 bool "The shared table of common (or usual) storage devices"
140 depends on USB 152 depends on USB
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 8cbba22508a4..023969b4385b 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -20,6 +20,7 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
20usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o 20usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o 21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
23usb-storage-obj-$(CONFIG_USB_STORAGE_KARMA) += karma.o
23 24
24usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 25usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
25 initializers.o $(usb-storage-obj-y) 26 initializers.o $(usb-storage-obj-y)
diff --git a/drivers/usb/storage/initializers.c b/drivers/usb/storage/initializers.c
index ab173b30076e..5b06f9240d05 100644
--- a/drivers/usb/storage/initializers.c
+++ b/drivers/usb/storage/initializers.c
@@ -45,12 +45,6 @@
45#include "debug.h" 45#include "debug.h"
46#include "transport.h" 46#include "transport.h"
47 47
48#define RIO_MSC 0x08
49#define RIOP_INIT "RIOP\x00\x01\x08"
50#define RIOP_INIT_LEN 7
51#define RIO_SEND_LEN 40
52#define RIO_RECV_LEN 0x200
53
54/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target 48/* This places the Shuttle/SCM USB<->SCSI bridge devices in multi-target
55 * mode */ 49 * mode */
56int usb_stor_euscsi_init(struct us_data *us) 50int usb_stor_euscsi_init(struct us_data *us)
@@ -97,70 +91,3 @@ int usb_stor_ucr61s2b_init(struct us_data *us)
97 91
98 return (res ? -1 : 0); 92 return (res ? -1 : 0);
99} 93}
100
101/* Place the Rio Karma into mass storage mode.
102 *
103 * The initialization begins by sending 40 bytes starting
104 * RIOP\x00\x01\x08\x00, which the device will ack with a 512-byte
105 * packet with the high four bits set and everything else null.
106 *
107 * Next, we send RIOP\x80\x00\x08\x00. Each time, a 512 byte response
108 * must be read, but we must loop until byte 5 in the response is 0x08,
109 * indicating success. */
110int rio_karma_init(struct us_data *us)
111{
112 int result, partial;
113 char *recv;
114 unsigned long timeout;
115
116 // us->iobuf is big enough to hold cmd but not receive
117 if (!(recv = kmalloc(RIO_RECV_LEN, GFP_KERNEL)))
118 goto die_nomem;
119
120 US_DEBUGP("Initializing Karma...\n");
121
122 memset(us->iobuf, 0, RIO_SEND_LEN);
123 memcpy(us->iobuf, RIOP_INIT, RIOP_INIT_LEN);
124
125 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
126 us->iobuf, RIO_SEND_LEN, &partial);
127 if (result != USB_STOR_XFER_GOOD)
128 goto die;
129
130 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
131 recv, RIO_RECV_LEN, &partial);
132 if (result != USB_STOR_XFER_GOOD)
133 goto die;
134
135 us->iobuf[4] = 0x80;
136 us->iobuf[5] = 0;
137 timeout = jiffies + msecs_to_jiffies(3000);
138 for (;;) {
139 US_DEBUGP("Sending init command\n");
140 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
141 us->iobuf, RIO_SEND_LEN, &partial);
142 if (result != USB_STOR_XFER_GOOD)
143 goto die;
144
145 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
146 recv, RIO_RECV_LEN, &partial);
147 if (result != USB_STOR_XFER_GOOD)
148 goto die;
149
150 if (recv[5] == RIO_MSC)
151 break;
152 if (time_after(jiffies, timeout))
153 goto die;
154 msleep(10);
155 }
156 US_DEBUGP("Karma initialized.\n");
157 kfree(recv);
158 return 0;
159
160die:
161 kfree(recv);
162die_nomem:
163 US_DEBUGP("Could not initialize karma.\n");
164 return USB_STOR_TRANSPORT_FAILED;
165}
166
diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h
index 927f7781080f..e2967a4d48a2 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -47,4 +47,3 @@ int usb_stor_euscsi_init(struct us_data *us);
47/* This function is required to activate all four slots on the UCR-61S2B 47/* This function is required to activate all four slots on the UCR-61S2B
48 * flash reader */ 48 * flash reader */
49int usb_stor_ucr61s2b_init(struct us_data *us); 49int usb_stor_ucr61s2b_init(struct us_data *us);
50int rio_karma_init(struct us_data *us);
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
new file mode 100644
index 000000000000..0d79ae5683f7
--- /dev/null
+++ b/drivers/usb/storage/karma.c
@@ -0,0 +1,155 @@
1/* Driver for Rio Karma
2 *
3 * (c) 2006 Bob Copeland <me@bobcopeland.com>
4 * (c) 2006 Keith Bennett <keith@mcs.st-and.ac.uk>
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 as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <scsi/scsi.h>
22#include <scsi/scsi_cmnd.h>
23#include <scsi/scsi_device.h>
24
25#include "usb.h"
26#include "transport.h"
27#include "debug.h"
28#include "karma.h"
29
30#define RIO_PREFIX "RIOP\x00"
31#define RIO_PREFIX_LEN 5
32#define RIO_SEND_LEN 40
33#define RIO_RECV_LEN 0x200
34
35#define RIO_ENTER_STORAGE 0x1
36#define RIO_LEAVE_STORAGE 0x2
37#define RIO_RESET 0xC
38
39extern int usb_stor_Bulk_transport(struct scsi_cmnd *, struct us_data *);
40
41struct karma_data {
42 int in_storage;
43 char *recv;
44};
45
46/*
47 * Send commands to Rio Karma.
48 *
49 * For each command we send 40 bytes starting 'RIOP\0' followed by
50 * the command number and a sequence number, which the device will ack
51 * with a 512-byte packet with the high four bits set and everything
52 * else null. Then we send 'RIOP\x80' followed by a zero and the
53 * sequence number, until byte 5 in the response repeats the sequence
54 * number.
55 */
56static int rio_karma_send_command(char cmd, struct us_data *us)
57{
58 int result, partial;
59 unsigned long timeout;
60 static unsigned char seq = 1;
61 struct karma_data *data = (struct karma_data *) us->extra;
62
63 US_DEBUGP("karma: sending command %04x\n", cmd);
64 memset(us->iobuf, 0, RIO_SEND_LEN);
65 memcpy(us->iobuf, RIO_PREFIX, RIO_PREFIX_LEN);
66 us->iobuf[5] = cmd;
67 us->iobuf[6] = seq;
68
69 timeout = jiffies + msecs_to_jiffies(6000);
70 for (;;) {
71 result = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
72 us->iobuf, RIO_SEND_LEN, &partial);
73 if (result != USB_STOR_XFER_GOOD)
74 goto err;
75
76 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
77 data->recv, RIO_RECV_LEN, &partial);
78 if (result != USB_STOR_XFER_GOOD)
79 goto err;
80
81 if (data->recv[5] == seq)
82 break;
83
84 if (time_after(jiffies, timeout))
85 goto err;
86
87 us->iobuf[4] = 0x80;
88 us->iobuf[5] = 0;
89 msleep(50);
90 }
91
92 seq++;
93 if (seq == 0)
94 seq = 1;
95
96 US_DEBUGP("karma: sent command %04x\n", cmd);
97 return 0;
98err:
99 US_DEBUGP("karma: command %04x failed\n", cmd);
100 return USB_STOR_TRANSPORT_FAILED;
101}
102
103/*
104 * Trap START_STOP and READ_10 to leave/re-enter storage mode.
105 * Everything else is propagated to the normal bulk layer.
106 */
107int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us)
108{
109 int ret;
110 struct karma_data *data = (struct karma_data *) us->extra;
111
112 if (srb->cmnd[0] == READ_10 && !data->in_storage) {
113 ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
114 if (ret)
115 return ret;
116
117 data->in_storage = 1;
118 return usb_stor_Bulk_transport(srb, us);
119 } else if (srb->cmnd[0] == START_STOP) {
120 ret = rio_karma_send_command(RIO_LEAVE_STORAGE, us);
121 if (ret)
122 return ret;
123
124 data->in_storage = 0;
125 return rio_karma_send_command(RIO_RESET, us);
126 }
127 return usb_stor_Bulk_transport(srb, us);
128}
129
130static void rio_karma_destructor(void *extra)
131{
132 struct karma_data *data = (struct karma_data *) extra;
133 kfree(data->recv);
134}
135
136int rio_karma_init(struct us_data *us)
137{
138 int ret = 0;
139 struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
140 if (!data)
141 goto out;
142
143 data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO);
144 if (!data->recv) {
145 kfree(data);
146 goto out;
147 }
148
149 us->extra = data;
150 us->extra_destructor = rio_karma_destructor;
151 ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
152 data->in_storage = (ret == 0);
153out:
154 return ret;
155}
diff --git a/drivers/usb/storage/karma.h b/drivers/usb/storage/karma.h
new file mode 100644
index 000000000000..8a60972af8c5
--- /dev/null
+++ b/drivers/usb/storage/karma.h
@@ -0,0 +1,7 @@
1#ifndef _KARMA_USB_H
2#define _KARMA_USB_H
3
4extern int rio_karma_init(struct us_data *us);
5extern int rio_karma_transport(struct scsi_cmnd *srb, struct us_data *us);
6
7#endif
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
index b1ec4a718547..599ad10a761b 100644
--- a/drivers/usb/storage/libusual.c
+++ b/drivers/usb/storage/libusual.c
@@ -8,6 +8,7 @@
8#include <linux/usb.h> 8#include <linux/usb.h>
9#include <linux/usb_usual.h> 9#include <linux/usb_usual.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/kthread.h>
11 12
12/* 13/*
13 */ 14 */
@@ -117,7 +118,7 @@ static int usu_probe(struct usb_interface *intf,
117 const struct usb_device_id *id) 118 const struct usb_device_id *id)
118{ 119{
119 unsigned long type; 120 unsigned long type;
120 int rc; 121 struct task_struct* task;
121 unsigned long flags; 122 unsigned long flags;
122 123
123 type = USB_US_TYPE(id->driver_info); 124 type = USB_US_TYPE(id->driver_info);
@@ -132,8 +133,9 @@ static int usu_probe(struct usb_interface *intf,
132 stat[type].fls |= USU_MOD_FL_THREAD; 133 stat[type].fls |= USU_MOD_FL_THREAD;
133 spin_unlock_irqrestore(&usu_lock, flags); 134 spin_unlock_irqrestore(&usu_lock, flags);
134 135
135 rc = kernel_thread(usu_probe_thread, (void*)type, CLONE_VM); 136 task = kthread_run(usu_probe_thread, (void*)type, "libusual_%d", type);
136 if (rc < 0) { 137 if (IS_ERR(task)) {
138 int rc = PTR_ERR(task);
137 printk(KERN_WARNING "libusual: " 139 printk(KERN_WARNING "libusual: "
138 "Unable to start the thread for %s: %d\n", 140 "Unable to start the thread for %s: %d\n",
139 bias_names[type], rc); 141 bias_names[type], rc);
@@ -175,8 +177,6 @@ static int usu_probe_thread(void *arg)
175 int rc; 177 int rc;
176 unsigned long flags; 178 unsigned long flags;
177 179
178 daemonize("libusual_%d", type); /* "usb-storage" is kinda too long */
179
180 /* A completion does not work here because it's counted. */ 180 /* A completion does not work here because it's counted. */
181 down(&usu_init_notify); 181 down(&usu_init_notify);
182 up(&usu_init_notify); 182 up(&usu_init_notify);
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 313920d980c9..f843a0bcf107 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -135,6 +135,7 @@ int onetouch_connect_input(struct us_data *ss)
135 struct usb_onetouch *onetouch; 135 struct usb_onetouch *onetouch;
136 struct input_dev *input_dev; 136 struct input_dev *input_dev;
137 int pipe, maxp; 137 int pipe, maxp;
138 int error = -ENOMEM;
138 139
139 interface = ss->pusb_intf->cur_altsetting; 140 interface = ss->pusb_intf->cur_altsetting;
140 141
@@ -211,15 +212,18 @@ int onetouch_connect_input(struct us_data *ss)
211 ss->suspend_resume_hook = usb_onetouch_pm_hook; 212 ss->suspend_resume_hook = usb_onetouch_pm_hook;
212#endif 213#endif
213 214
214 input_register_device(onetouch->dev); 215 error = input_register_device(onetouch->dev);
216 if (error)
217 goto fail3;
215 218
216 return 0; 219 return 0;
217 220
221 fail3: usb_free_urb(onetouch->irq);
218 fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN, 222 fail2: usb_buffer_free(udev, ONETOUCH_PKT_LEN,
219 onetouch->data, onetouch->data_dma); 223 onetouch->data, onetouch->data_dma);
220 fail1: kfree(onetouch); 224 fail1: kfree(onetouch);
221 input_free_device(input_dev); 225 input_free_device(input_dev);
222 return -ENOMEM; 226 return error;
223} 227}
224 228
225void onetouch_release_input(void *onetouch_) 229void onetouch_release_input(void *onetouch_)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index a4b7df9ff8c1..e1072d52d641 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -72,12 +72,27 @@ static const char* host_info(struct Scsi_Host *host)
72 72
73static int slave_alloc (struct scsi_device *sdev) 73static int slave_alloc (struct scsi_device *sdev)
74{ 74{
75 struct us_data *us = host_to_us(sdev->host);
76
75 /* 77 /*
76 * Set the INQUIRY transfer length to 36. We don't use any of 78 * Set the INQUIRY transfer length to 36. We don't use any of
77 * the extra data and many devices choke if asked for more or 79 * the extra data and many devices choke if asked for more or
78 * less than 36 bytes. 80 * less than 36 bytes.
79 */ 81 */
80 sdev->inquiry_len = 36; 82 sdev->inquiry_len = 36;
83
84 /*
85 * The UFI spec treates the Peripheral Qualifier bits in an
86 * INQUIRY result as reserved and requires devices to set them
87 * to 0. However the SCSI spec requires these bits to be set
88 * to 3 to indicate when a LUN is not present.
89 *
90 * Let the scanning code know if this target merely sets
91 * Peripheral Device Type to 0x1f to indicate no LUN.
92 */
93 if (us->subclass == US_SC_UFI)
94 sdev->sdev_target->pdt_1f_for_no_lun = 1;
95
81 return 0; 96 return 0;
82} 97}
83 98
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index d6acc92a4ae3..f23514c4e649 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -294,11 +294,6 @@ static int interpret_urb_result(struct us_data *us, unsigned int pipe,
294 return USB_STOR_XFER_ERROR; 294 return USB_STOR_XFER_ERROR;
295 return USB_STOR_XFER_STALLED; 295 return USB_STOR_XFER_STALLED;
296 296
297 /* timeout or excessively long NAK */
298 case -ETIMEDOUT:
299 US_DEBUGP("-- timeout or NAK\n");
300 return USB_STOR_XFER_ERROR;
301
302 /* babble - the device tried to send more than we wanted to read */ 297 /* babble - the device tried to send more than we wanted to read */
303 case -EOVERFLOW: 298 case -EOVERFLOW:
304 US_DEBUGP("-- babble\n"); 299 US_DEBUGP("-- babble\n");
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index b130e170b4a8..40bf159f7d54 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -218,10 +218,12 @@ UNUSUAL_DEV( 0x0457, 0x0151, 0x0100, 0x0100,
218 US_SC_DEVICE, US_PR_DEVICE, NULL, 218 US_SC_DEVICE, US_PR_DEVICE, NULL,
219 US_FL_NOT_LOCKABLE ), 219 US_FL_NOT_LOCKABLE ),
220 220
221#ifdef CONFIG_USB_STORAGE_KARMA
221UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101, 222UNUSUAL_DEV( 0x045a, 0x5210, 0x0101, 0x0101,
222 "Rio", 223 "Rio",
223 "Rio Karma", 224 "Rio Karma",
224 US_SC_SCSI, US_PR_BULK, rio_karma_init, 0), 225 US_SC_SCSI, US_PR_KARMA, rio_karma_init, 0),
226#endif
225 227
226/* Patch submitted by Philipp Friedrich <philipp@void.at> */ 228/* Patch submitted by Philipp Friedrich <philipp@void.at> */
227UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100, 229UNUSUAL_DEV( 0x0482, 0x0100, 0x0100, 0x0100,
@@ -631,6 +633,13 @@ UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
631 "Digital Camera EX-20 DSC", 633 "Digital Camera EX-20 DSC",
632 US_SC_8070, US_PR_DEVICE, NULL, 0 ), 634 US_SC_8070, US_PR_DEVICE, NULL, 0 ),
633 635
636/* Reported by <Hendryk.Pfeiffer@gmx.de> */
637UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000,
638 "LaCie",
639 "DVD+-RW",
640 US_SC_DEVICE, US_PR_DEVICE, NULL,
641 US_FL_GO_SLOW ),
642
634/* Submitted by Joel Bourquard <numlock@freesurf.ch> 643/* Submitted by Joel Bourquard <numlock@freesurf.ch>
635 * Some versions of this device need the SubClass and Protocol overrides 644 * Some versions of this device need the SubClass and Protocol overrides
636 * while others don't. 645 * while others don't.
@@ -1254,6 +1263,13 @@ UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1254 US_SC_DEVICE, US_PR_DEVICE, NULL, 1263 US_SC_DEVICE, US_PR_DEVICE, NULL,
1255 US_FL_NO_WP_DETECT ), 1264 US_FL_NO_WP_DETECT ),
1256 1265
1266/* Reported by Jan Mate <mate@fiit.stuba.sk> */
1267UNUSUAL_DEV( 0x0fce, 0xe030, 0x0000, 0x0000,
1268 "Sony Ericsson",
1269 "P990i",
1270 US_SC_DEVICE, US_PR_DEVICE, NULL,
1271 US_FL_FIX_CAPACITY ),
1272
1257/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */ 1273/* Reported by Emmanuel Vasilakis <evas@forthnet.gr> */
1258UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000, 1274UNUSUAL_DEV( 0x0fce, 0xe031, 0x0000, 0x0000,
1259 "Sony Ericsson", 1275 "Sony Ericsson",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8d7bdcb5924d..b8d6031b0975 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -98,6 +98,9 @@
98#ifdef CONFIG_USB_STORAGE_ALAUDA 98#ifdef CONFIG_USB_STORAGE_ALAUDA
99#include "alauda.h" 99#include "alauda.h"
100#endif 100#endif
101#ifdef CONFIG_USB_STORAGE_KARMA
102#include "karma.h"
103#endif
101 104
102/* Some informational data */ 105/* Some informational data */
103MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 106MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -646,6 +649,14 @@ static int get_transport(struct us_data *us)
646 break; 649 break;
647#endif 650#endif
648 651
652#ifdef CONFIG_USB_STORAGE_KARMA
653 case US_PR_KARMA:
654 us->transport_name = "Rio Karma/Bulk";
655 us->transport = rio_karma_transport;
656 us->transport_reset = usb_stor_Bulk_reset;
657 break;
658#endif
659
649 default: 660 default:
650 return -EIO; 661 return -EIO;
651 } 662 }
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index b362039792b3..1b51d3187a95 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * USB Skeleton driver - 2.0 2 * USB Skeleton driver - 2.2
3 * 3 *
4 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) 4 * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
5 * 5 *
@@ -7,9 +7,8 @@
7 * modify it under the terms of the GNU General Public License as 7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation, version 2. 8 * published by the Free Software Foundation, version 2.
9 * 9 *
10 * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c 10 * This driver is based on the 2.6.3 version of drivers/usb/usb-skeleton.c
11 * but has been rewritten to be easy to read and use, as no locks are now 11 * but has been rewritten to be easier to read and use.
12 * needed anymore.
13 * 12 *
14 */ 13 */
15 14
@@ -21,6 +20,7 @@
21#include <linux/kref.h> 20#include <linux/kref.h>
22#include <asm/uaccess.h> 21#include <asm/uaccess.h>
23#include <linux/usb.h> 22#include <linux/usb.h>
23#include <linux/mutex.h>
24 24
25 25
26/* Define these values to match your devices */ 26/* Define these values to match your devices */
@@ -32,38 +32,39 @@ static struct usb_device_id skel_table [] = {
32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 32 { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) },
33 { } /* Terminating entry */ 33 { } /* Terminating entry */
34}; 34};
35MODULE_DEVICE_TABLE (usb, skel_table); 35MODULE_DEVICE_TABLE(usb, skel_table);
36 36
37 37
38/* Get a minor range for your devices from the usb maintainer */ 38/* Get a minor range for your devices from the usb maintainer */
39#define USB_SKEL_MINOR_BASE 192 39#define USB_SKEL_MINOR_BASE 192
40 40
41/* our private defines. if this grows any larger, use your own .h file */ 41/* our private defines. if this grows any larger, use your own .h file */
42#define MAX_TRANSFER ( PAGE_SIZE - 512 ) 42#define MAX_TRANSFER (PAGE_SIZE - 512)
43#define WRITES_IN_FLIGHT 8 43#define WRITES_IN_FLIGHT 8
44 44
45/* Structure to hold all of our device specific stuff */ 45/* Structure to hold all of our device specific stuff */
46struct usb_skel { 46struct usb_skel {
47 struct usb_device * udev; /* the usb device for this device */ 47 struct usb_device *dev; /* the usb device for this device */
48 struct usb_interface * interface; /* the interface for this device */ 48 struct usb_interface *interface; /* the interface for this device */
49 struct semaphore limit_sem; /* limiting the number of writes in progress */ 49 struct semaphore limit_sem; /* limiting the number of writes in progress */
50 unsigned char * bulk_in_buffer; /* the buffer to receive data */ 50 unsigned char *bulk_in_buffer; /* the buffer to receive data */
51 size_t bulk_in_size; /* the size of the receive buffer */ 51 size_t bulk_in_size; /* the size of the receive buffer */
52 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ 52 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
53 __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */ 53 __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
54 struct kref kref; 54 struct kref kref;
55 struct mutex io_mutex; /* synchronize I/O with disconnect */
55}; 56};
56#define to_skel_dev(d) container_of(d, struct usb_skel, kref) 57#define to_skel_dev(d) container_of(d, struct usb_skel, kref)
57 58
58static struct usb_driver skel_driver; 59static struct usb_driver skel_driver;
59 60
60static void skel_delete(struct kref *kref) 61static void skel_delete(struct kref *kref)
61{ 62{
62 struct usb_skel *dev = to_skel_dev(kref); 63 struct usb_skel *dev = to_skel_dev(kref);
63 64
64 usb_put_dev(dev->udev); 65 usb_put_dev(dev->udev);
65 kfree (dev->bulk_in_buffer); 66 kfree(dev->bulk_in_buffer);
66 kfree (dev); 67 kfree(dev);
67} 68}
68 69
69static int skel_open(struct inode *inode, struct file *file) 70static int skel_open(struct inode *inode, struct file *file)
@@ -89,6 +90,11 @@ static int skel_open(struct inode *inode, struct file *file)
89 goto exit; 90 goto exit;
90 } 91 }
91 92
93 /* prevent the device from being autosuspended */
94 retval = usb_autopm_get_interface(interface);
95 if (retval)
96 goto exit;
97
92 /* increment our usage count for the device */ 98 /* increment our usage count for the device */
93 kref_get(&dev->kref); 99 kref_get(&dev->kref);
94 100
@@ -107,6 +113,12 @@ static int skel_release(struct inode *inode, struct file *file)
107 if (dev == NULL) 113 if (dev == NULL)
108 return -ENODEV; 114 return -ENODEV;
109 115
116 /* allow the device to be autosuspended */
117 mutex_lock(&dev->io_mutex);
118 if (dev->interface)
119 usb_autopm_put_interface(dev->interface);
120 mutex_unlock(&dev->io_mutex);
121
110 /* decrement the count on our device */ 122 /* decrement the count on our device */
111 kref_put(&dev->kref, skel_delete); 123 kref_put(&dev->kref, skel_delete);
112 return 0; 124 return 0;
@@ -115,11 +127,17 @@ static int skel_release(struct inode *inode, struct file *file)
115static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t *ppos) 127static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
116{ 128{
117 struct usb_skel *dev; 129 struct usb_skel *dev;
118 int retval = 0; 130 int retval;
119 int bytes_read; 131 int bytes_read;
120 132
121 dev = (struct usb_skel *)file->private_data; 133 dev = (struct usb_skel *)file->private_data;
122 134
135 mutex_lock(&dev->io_mutex);
136 if (!dev->interface) { /* disconnect() was called */
137 retval = -ENODEV;
138 goto exit;
139 }
140
123 /* do a blocking bulk read to get data from the device */ 141 /* do a blocking bulk read to get data from the device */
124 retval = usb_bulk_msg(dev->udev, 142 retval = usb_bulk_msg(dev->udev,
125 usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr), 143 usb_rcvbulkpipe(dev->udev, dev->bulk_in_endpointAddr),
@@ -135,6 +153,8 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, loff_t *
135 retval = bytes_read; 153 retval = bytes_read;
136 } 154 }
137 155
156exit:
157 mutex_unlock(&dev->io_mutex);
138 return retval; 158 return retval;
139} 159}
140 160
@@ -145,16 +165,16 @@ static void skel_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
145 dev = (struct usb_skel *)urb->context; 165 dev = (struct usb_skel *)urb->context;
146 166
147 /* sync/async unlink faults aren't errors */ 167 /* sync/async unlink faults aren't errors */
148 if (urb->status && 168 if (urb->status &&
149 !(urb->status == -ENOENT || 169 !(urb->status == -ENOENT ||
150 urb->status == -ECONNRESET || 170 urb->status == -ECONNRESET ||
151 urb->status == -ESHUTDOWN)) { 171 urb->status == -ESHUTDOWN)) {
152 dbg("%s - nonzero write bulk status received: %d", 172 err("%s - nonzero write bulk status received: %d",
153 __FUNCTION__, urb->status); 173 __FUNCTION__, urb->status);
154 } 174 }
155 175
156 /* free up our allocated buffer */ 176 /* free up our allocated buffer */
157 usb_buffer_free(urb->dev, urb->transfer_buffer_length, 177 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
158 urb->transfer_buffer, urb->transfer_dma); 178 urb->transfer_buffer, urb->transfer_dma);
159 up(&dev->limit_sem); 179 up(&dev->limit_sem);
160} 180}
@@ -179,6 +199,12 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
179 goto exit; 199 goto exit;
180 } 200 }
181 201
202 mutex_lock(&dev->io_mutex);
203 if (!dev->interface) { /* disconnect() was called */
204 retval = -ENODEV;
205 goto error;
206 }
207
182 /* create a urb, and a buffer for it, and copy the data to the urb */ 208 /* create a urb, and a buffer for it, and copy the data to the urb */
183 urb = usb_alloc_urb(0, GFP_KERNEL); 209 urb = usb_alloc_urb(0, GFP_KERNEL);
184 if (!urb) { 210 if (!urb) {
@@ -213,17 +239,22 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
213 /* release our reference to this urb, the USB core will eventually free it entirely */ 239 /* release our reference to this urb, the USB core will eventually free it entirely */
214 usb_free_urb(urb); 240 usb_free_urb(urb);
215 241
216exit: 242 mutex_unlock(&dev->io_mutex);
217 return writesize; 243 return writesize;
218 244
219error: 245error:
220 usb_buffer_free(dev->udev, writesize, buf, urb->transfer_dma); 246 if (urb) {
221 usb_free_urb(urb); 247 usb_buffer_free(dev->udev, writesize, buf, urb->transfer_dma);
248 usb_free_urb(urb);
249 }
250 mutex_unlock(&dev->io_mutex);
222 up(&dev->limit_sem); 251 up(&dev->limit_sem);
252
253exit:
223 return retval; 254 return retval;
224} 255}
225 256
226static struct file_operations skel_fops = { 257static const struct file_operations skel_fops = {
227 .owner = THIS_MODULE, 258 .owner = THIS_MODULE,
228 .read = skel_read, 259 .read = skel_read,
229 .write = skel_write, 260 .write = skel_write,
@@ -231,7 +262,7 @@ static struct file_operations skel_fops = {
231 .release = skel_release, 262 .release = skel_release,
232}; 263};
233 264
234/* 265/*
235 * usb class driver info in order to get a minor number from the usb core, 266 * usb class driver info in order to get a minor number from the usb core,
236 * and to have the device registered with the driver core 267 * and to have the device registered with the driver core
237 */ 268 */
@@ -243,7 +274,7 @@ static struct usb_class_driver skel_class = {
243 274
244static int skel_probe(struct usb_interface *interface, const struct usb_device_id *id) 275static int skel_probe(struct usb_interface *interface, const struct usb_device_id *id)
245{ 276{
246 struct usb_skel *dev = NULL; 277 struct usb_skel *dev;
247 struct usb_host_interface *iface_desc; 278 struct usb_host_interface *iface_desc;
248 struct usb_endpoint_descriptor *endpoint; 279 struct usb_endpoint_descriptor *endpoint;
249 size_t buffer_size; 280 size_t buffer_size;
@@ -252,12 +283,13 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
252 283
253 /* allocate memory for our device state and initialize it */ 284 /* allocate memory for our device state and initialize it */
254 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 285 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
255 if (dev == NULL) { 286 if (!dev) {
256 err("Out of memory"); 287 err("Out of memory");
257 goto error; 288 goto error;
258 } 289 }
259 kref_init(&dev->kref); 290 kref_init(&dev->kref);
260 sema_init(&dev->limit_sem, WRITES_IN_FLIGHT); 291 sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
292 mutex_init(&dev->io_mutex);
261 293
262 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 294 dev->udev = usb_get_dev(interface_to_usbdev(interface));
263 dev->interface = interface; 295 dev->interface = interface;
@@ -269,10 +301,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
269 endpoint = &iface_desc->endpoint[i].desc; 301 endpoint = &iface_desc->endpoint[i].desc;
270 302
271 if (!dev->bulk_in_endpointAddr && 303 if (!dev->bulk_in_endpointAddr &&
272 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 304 usb_endpoint_is_bulk_in(endpoint)) {
273 == USB_DIR_IN) &&
274 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
275 == USB_ENDPOINT_XFER_BULK)) {
276 /* we found a bulk in endpoint */ 305 /* we found a bulk in endpoint */
277 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize); 306 buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
278 dev->bulk_in_size = buffer_size; 307 dev->bulk_in_size = buffer_size;
@@ -285,10 +314,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
285 } 314 }
286 315
287 if (!dev->bulk_out_endpointAddr && 316 if (!dev->bulk_out_endpointAddr &&
288 ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) 317 usb_endpoint_is_bulk_out(endpoint)) {
289 == USB_DIR_OUT) &&
290 ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK)
291 == USB_ENDPOINT_XFER_BULK)) {
292 /* we found a bulk out endpoint */ 318 /* we found a bulk out endpoint */
293 dev->bulk_out_endpointAddr = endpoint->bEndpointAddress; 319 dev->bulk_out_endpointAddr = endpoint->bEndpointAddress;
294 } 320 }
@@ -334,6 +360,11 @@ static void skel_disconnect(struct usb_interface *interface)
334 /* give back our minor */ 360 /* give back our minor */
335 usb_deregister_dev(interface, &skel_class); 361 usb_deregister_dev(interface, &skel_class);
336 362
363 /* prevent more I/O from starting */
364 mutex_lock(&dev->io_mutex);
365 dev->interface = NULL;
366 mutex_unlock(&dev->io_mutex);
367
337 unlock_kernel(); 368 unlock_kernel();
338 369
339 /* decrement our usage count */ 370 /* decrement our usage count */
@@ -367,7 +398,7 @@ static void __exit usb_skel_exit(void)
367 usb_deregister(&skel_driver); 398 usb_deregister(&skel_driver);
368} 399}
369 400
370module_init (usb_skel_init); 401module_init(usb_skel_init);
371module_exit (usb_skel_exit); 402module_exit(usb_skel_exit);
372 403
373MODULE_LICENSE("GPL"); 404MODULE_LICENSE("GPL");
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index e308ed2d249a..365de5dcc888 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2621,25 +2621,28 @@ static int radeon_restore_pci_cfg(struct radeonfb_info *rinfo)
2621} 2621}
2622 2622
2623 2623
2624int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state) 2624int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
2625{ 2625{
2626 struct fb_info *info = pci_get_drvdata(pdev); 2626 struct fb_info *info = pci_get_drvdata(pdev);
2627 struct radeonfb_info *rinfo = info->par; 2627 struct radeonfb_info *rinfo = info->par;
2628 int i; 2628 int i;
2629 2629
2630 if (state.event == pdev->dev.power.power_state.event) 2630 if (mesg.event == pdev->dev.power.power_state.event)
2631 return 0; 2631 return 0;
2632 2632
2633 printk(KERN_DEBUG "radeonfb (%s): suspending to state: %d...\n", 2633 printk(KERN_DEBUG "radeonfb (%s): suspending for event: %d...\n",
2634 pci_name(pdev), state.event); 2634 pci_name(pdev), mesg.event);
2635 2635
2636 /* For suspend-to-disk, we cheat here. We don't suspend anything and 2636 /* For suspend-to-disk, we cheat here. We don't suspend anything and
2637 * let fbcon continue drawing until we are all set. That shouldn't 2637 * let fbcon continue drawing until we are all set. That shouldn't
2638 * really cause any problem at this point, provided that the wakeup 2638 * really cause any problem at this point, provided that the wakeup
2639 * code knows that any state in memory may not match the HW 2639 * code knows that any state in memory may not match the HW
2640 */ 2640 */
2641 if (state.event == PM_EVENT_FREEZE) 2641 switch (mesg.event) {
2642 case PM_EVENT_FREEZE: /* about to take snapshot */
2643 case PM_EVENT_PRETHAW: /* before restoring snapshot */
2642 goto done; 2644 goto done;
2645 }
2643 2646
2644 acquire_console_sem(); 2647 acquire_console_sem();
2645 2648
@@ -2706,7 +2709,7 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t state)
2706 release_console_sem(); 2709 release_console_sem();
2707 2710
2708 done: 2711 done:
2709 pdev->dev.power.power_state = state; 2712 pdev->dev.power.power_state = mesg;
2710 2713
2711 return 0; 2714 return 0;
2712} 2715}
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index ffc72ae3ada8..fe1488374f62 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -20,7 +20,7 @@
20 20
21#include <asm/cpu/dac.h> 21#include <asm/cpu/dac.h>
22#include <asm/hp6xx/hp6xx.h> 22#include <asm/hp6xx/hp6xx.h>
23#include <asm/hd64461/hd64461.h> 23#include <asm/hd64461.h>
24 24
25#define HP680_MAX_INTENSITY 255 25#define HP680_MAX_INTENSITY 255
26#define HP680_DEFAULT_INTENSITY 10 26#define HP680_DEFAULT_INTENSITY 10
@@ -163,6 +163,6 @@ static void __exit hp680bl_exit(void)
163module_init(hp680bl_init); 163module_init(hp680bl_init);
164module_exit(hp680bl_exit); 164module_exit(hp680bl_exit);
165 165
166MODULE_AUTHOR("Andriy Skulysh <askulysh@image.kiev.ua>"); 166MODULE_AUTHOR("Andriy Skulysh <askulysh@gmail.com>");
167MODULE_DESCRIPTION("HP Jornada 680 Backlight Driver"); 167MODULE_DESCRIPTION("HP Jornada 680 Backlight Driver");
168MODULE_LICENSE("GPL"); 168MODULE_LICENSE("GPL");
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 4444bef68fba..aa3935df852a 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -6,7 +6,7 @@ menu "Console display driver support"
6 6
7config VGA_CONSOLE 7config VGA_CONSOLE
8 bool "VGA text console" if EMBEDDED || !X86 8 bool "VGA text console" if EMBEDDED || !X86
9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE 9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !FRV && !ARCH_VERSATILE && !SUPERH
10 default y 10 default y
11 help 11 help
12 Saying Y here will allow you to use Linux in text mode through a 12 Saying Y here will allow you to use Linux in text mode through a
diff --git a/drivers/video/hitfb.c b/drivers/video/hitfb.c
index 4cc6b454265e..3afb472763c0 100644
--- a/drivers/video/hitfb.c
+++ b/drivers/video/hitfb.c
@@ -4,7 +4,7 @@
4 * (C) 1999 Mihai Spatar 4 * (C) 1999 Mihai Spatar
5 * (C) 2000 YAEGASHI Takeshi 5 * (C) 2000 YAEGASHI Takeshi
6 * (C) 2003, 2004 Paul Mundt 6 * (C) 2003, 2004 Paul Mundt
7 * (C) 2003, 2004 Andriy Skulysh 7 * (C) 2003, 2004, 2006 Andriy Skulysh
8 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public 9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of this archive for 10 * License. See the file COPYING in the main directory of this archive for
@@ -20,18 +20,16 @@
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/platform_device.h>
23#include <linux/fb.h> 24#include <linux/fb.h>
24 25
25#include <asm/machvec.h> 26#include <asm/machvec.h>
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <asm/pgtable.h> 28#include <asm/pgtable.h>
28#include <asm/io.h> 29#include <asm/io.h>
29#include <asm/hd64461/hd64461.h> 30#include <asm/hd64461.h>
30
31#ifdef MACH_HP600
32#include <asm/cpu/dac.h> 31#include <asm/cpu/dac.h>
33#include <asm/hp6xx/hp6xx.h> 32#include <asm/hp6xx/hp6xx.h>
34#endif
35 33
36#define WIDTH 640 34#define WIDTH 640
37 35
@@ -45,7 +43,6 @@ static struct fb_var_screeninfo hitfb_var __initdata = {
45static struct fb_fix_screeninfo hitfb_fix __initdata = { 43static struct fb_fix_screeninfo hitfb_fix __initdata = {
46 .id = "Hitachi HD64461", 44 .id = "Hitachi HD64461",
47 .type = FB_TYPE_PACKED_PIXELS, 45 .type = FB_TYPE_PACKED_PIXELS,
48 .ypanstep = 8,
49 .accel = FB_ACCEL_NONE, 46 .accel = FB_ACCEL_NONE,
50}; 47};
51 48
@@ -73,26 +70,14 @@ static inline void hitfb_accel_set_dest(int truecolor, u16 dx, u16 dy,
73 if (truecolor) 70 if (truecolor)
74 saddr <<= 1; 71 saddr <<= 1;
75 72
76 fb_writew(width, HD64461_BBTDWR); 73 fb_writew(width-1, HD64461_BBTDWR);
77 fb_writew(height, HD64461_BBTDHR); 74 fb_writew(height-1, HD64461_BBTDHR);
78 75
79 fb_writew(saddr & 0xffff, HD64461_BBTDSARL); 76 fb_writew(saddr & 0xffff, HD64461_BBTDSARL);
80 fb_writew(saddr >> 16, HD64461_BBTDSARH); 77 fb_writew(saddr >> 16, HD64461_BBTDSARH);
81 78
82} 79}
83 80
84static inline void hitfb_accel_solidfill(int truecolor, u16 dx, u16 dy,
85 u16 width, u16 height, u16 color)
86{
87 hitfb_accel_set_dest(truecolor, dx, dy, width, height);
88
89 fb_writew(0x00f0, HD64461_BBTROPR);
90 fb_writew(16, HD64461_BBTMDR);
91 fb_writew(color, HD64461_GRSCR);
92
93 hitfb_accel_start(truecolor);
94}
95
96static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx, 81static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx,
97 u16 dy, u16 width, u16 height, u16 rop, 82 u16 dy, u16 width, u16 height, u16 rop,
98 u32 mask_addr) 83 u32 mask_addr)
@@ -100,6 +85,8 @@ static inline void hitfb_accel_bitblt(int truecolor, u16 sx, u16 sy, u16 dx,
100 u32 saddr, daddr; 85 u32 saddr, daddr;
101 u32 maddr = 0; 86 u32 maddr = 0;
102 87
88 height--;
89 width--;
103 fb_writew(rop, HD64461_BBTROPR); 90 fb_writew(rop, HD64461_BBTROPR);
104 if ((sy < dy) || ((sy == dy) && (sx <= dx))) { 91 if ((sy < dy) || ((sy == dy) && (sx <= dx))) {
105 saddr = WIDTH * (sy + height) + sx + width; 92 saddr = WIDTH * (sy + height) + sx + width;
@@ -146,6 +133,7 @@ static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
146 if (rect->rop != ROP_COPY) 133 if (rect->rop != ROP_COPY)
147 cfb_fillrect(p, rect); 134 cfb_fillrect(p, rect);
148 else { 135 else {
136 hitfb_accel_wait();
149 fb_writew(0x00f0, HD64461_BBTROPR); 137 fb_writew(0x00f0, HD64461_BBTROPR);
150 fb_writew(16, HD64461_BBTMDR); 138 fb_writew(16, HD64461_BBTMDR);
151 139
@@ -161,16 +149,15 @@ static void hitfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
161 rect->height); 149 rect->height);
162 hitfb_accel_start(0); 150 hitfb_accel_start(0);
163 } 151 }
164 hitfb_accel_wait();
165 } 152 }
166} 153}
167 154
168static void hitfb_copyarea(struct fb_info *p, const struct fb_copyarea *area) 155static void hitfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
169{ 156{
157 hitfb_accel_wait();
170 hitfb_accel_bitblt(p->var.bits_per_pixel == 16, area->sx, area->sy, 158 hitfb_accel_bitblt(p->var.bits_per_pixel == 16, area->sx, area->sy,
171 area->dx, area->dy, area->width, area->height, 159 area->dx, area->dy, area->width, area->height,
172 0x00cc, 0); 160 0x00cc, 0);
173 hitfb_accel_wait();
174} 161}
175 162
176static int hitfb_pan_display(struct fb_var_screeninfo *var, 163static int hitfb_pan_display(struct fb_var_screeninfo *var,
@@ -182,7 +169,7 @@ static int hitfb_pan_display(struct fb_var_screeninfo *var,
182 if (xoffset != 0) 169 if (xoffset != 0)
183 return -EINVAL; 170 return -EINVAL;
184 171
185 fb_writew(yoffset, HD64461_LCDCBAR); 172 fb_writew((yoffset*info->fix.line_length)>>10, HD64461_LCDCBAR);
186 173
187 return 0; 174 return 0;
188} 175}
@@ -192,12 +179,6 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
192 unsigned short v; 179 unsigned short v;
193 180
194 if (blank_mode) { 181 if (blank_mode) {
195#ifdef MACH_HP600
196 sh_dac_disable(DAC_LCD_BRIGHTNESS);
197 v = fb_readw(HD64461_GPBDR);
198 v |= HD64461_GPBDR_LCDOFF;
199 fb_writew(v, HD64461_GPBDR);
200#endif
201 v = fb_readw(HD64461_LDR1); 182 v = fb_readw(HD64461_LDR1);
202 v &= ~HD64461_LDR1_DON; 183 v &= ~HD64461_LDR1_DON;
203 fb_writew(v, HD64461_LDR1); 184 fb_writew(v, HD64461_LDR1);
@@ -213,19 +194,18 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
213 v = fb_readw(HD64461_STBCR); 194 v = fb_readw(HD64461_STBCR);
214 v &= ~HD64461_STBCR_SLCDST; 195 v &= ~HD64461_STBCR_SLCDST;
215 fb_writew(v, HD64461_STBCR); 196 fb_writew(v, HD64461_STBCR);
216#ifdef MACH_HP600
217 sh_dac_enable(DAC_LCD_BRIGHTNESS);
218 v = fb_readw(HD64461_GPBDR);
219 v &= ~HD64461_GPBDR_LCDOFF;
220 fb_writew(v, HD64461_GPBDR);
221#endif
222 v = fb_readw(HD64461_LDR1);
223 v |= HD64461_LDR1_DON;
224 fb_writew(v, HD64461_LDR1);
225 197
226 v = fb_readw(HD64461_LCDCCR); 198 v = fb_readw(HD64461_LCDCCR);
227 v &= ~HD64461_LCDCCR_MOFF; 199 v &= ~(HD64461_LCDCCR_MOFF | HD64461_LCDCCR_STREQ);
228 fb_writew(v, HD64461_LCDCCR); 200 fb_writew(v, HD64461_LCDCCR);
201
202 do {
203 v = fb_readw(HD64461_LCDCCR);
204 } while(v&HD64461_LCDCCR_STBACK);
205
206 v = fb_readw(HD64461_LDR1);
207 v |= HD64461_LDR1_DON;
208 fb_writew(v, HD64461_LDR1);
229 } 209 }
230 return 0; 210 return 0;
231} 211}
@@ -233,7 +213,7 @@ int hitfb_blank(int blank_mode, struct fb_info *info)
233static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green, 213static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
234 unsigned blue, unsigned transp, struct fb_info *info) 214 unsigned blue, unsigned transp, struct fb_info *info)
235{ 215{
236 if (regno >= info->cmap.len) 216 if (regno >= 256)
237 return 1; 217 return 1;
238 218
239 switch (info->var.bits_per_pixel) { 219 switch (info->var.bits_per_pixel) {
@@ -244,6 +224,8 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
244 fb_writew(blue >> 10, HD64461_CPTWDR); 224 fb_writew(blue >> 10, HD64461_CPTWDR);
245 break; 225 break;
246 case 16: 226 case 16:
227 if (regno >= 16)
228 return 1;
247 ((u32 *) (info->pseudo_palette))[regno] = 229 ((u32 *) (info->pseudo_palette))[regno] =
248 ((red & 0xf800)) | 230 ((red & 0xf800)) |
249 ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11); 231 ((green & 0xfc00) >> 5) | ((blue & 0xf800) >> 11);
@@ -252,26 +234,113 @@ static int hitfb_setcolreg(unsigned regno, unsigned red, unsigned green,
252 return 0; 234 return 0;
253} 235}
254 236
237static int hitfb_sync(struct fb_info *info)
238{
239 hitfb_accel_wait();
240
241 return 0;
242}
243
244static int hitfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
245{
246 int maxy;
247
248 var->xres = info->var.xres;
249 var->xres_virtual = info->var.xres;
250 var->yres = info->var.yres;
251
252 if ((var->bits_per_pixel != 8) && (var->bits_per_pixel != 16))
253 var->bits_per_pixel = info->var.bits_per_pixel;
254
255 if (var->yres_virtual < var->yres)
256 var->yres_virtual = var->yres;
257
258 maxy = info->fix.smem_len / var->xres;
259
260 if (var->bits_per_pixel == 16)
261 maxy /= 2;
262
263 if (var->yres_virtual > maxy)
264 var->yres_virtual = maxy;
265
266 var->xoffset = 0;
267 var->yoffset = 0;
268
269 switch (var->bits_per_pixel) {
270 case 8:
271 var->red.offset = 0;
272 var->red.length = 8;
273 var->green.offset = 0;
274 var->green.length = 8;
275 var->blue.offset = 0;
276 var->blue.length = 8;
277 var->transp.offset = 0;
278 var->transp.length = 0;
279 break;
280 case 16: /* RGB 565 */
281 var->red.offset = 11;
282 var->red.length = 5;
283 var->green.offset = 5;
284 var->green.length = 6;
285 var->blue.offset = 0;
286 var->blue.length = 5;
287 var->transp.offset = 0;
288 var->transp.length = 0;
289 break;
290 }
291
292 return 0;
293}
294
295static int hitfb_set_par(struct fb_info *info)
296{
297 unsigned short ldr3;
298
299 switch (info->var.bits_per_pixel) {
300 case 8:
301 info->fix.line_length = info->var.xres;
302 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
303 info->fix.ypanstep = 16;
304 break;
305 case 16:
306 info->fix.line_length = info->var.xres*2;
307 info->fix.visual = FB_VISUAL_TRUECOLOR;
308 info->fix.ypanstep = 8;
309 break;
310 }
311
312 fb_writew(info->fix.line_length, HD64461_LCDCLOR);
313 ldr3 = fb_readw(HD64461_LDR3);
314 ldr3 &= ~15;
315 ldr3 |= (info->var.bits_per_pixel == 8) ? 4 : 8;
316 fb_writew(ldr3, HD64461_LDR3);
317 return 0;
318}
319
255static struct fb_ops hitfb_ops = { 320static struct fb_ops hitfb_ops = {
256 .owner = THIS_MODULE, 321 .owner = THIS_MODULE,
322 .fb_check_var = hitfb_check_var,
323 .fb_set_par = hitfb_set_par,
257 .fb_setcolreg = hitfb_setcolreg, 324 .fb_setcolreg = hitfb_setcolreg,
258 .fb_blank = hitfb_blank, 325 .fb_blank = hitfb_blank,
326 .fb_sync = hitfb_sync,
259 .fb_pan_display = hitfb_pan_display, 327 .fb_pan_display = hitfb_pan_display,
260 .fb_fillrect = hitfb_fillrect, 328 .fb_fillrect = hitfb_fillrect,
261 .fb_copyarea = hitfb_copyarea, 329 .fb_copyarea = hitfb_copyarea,
262 .fb_imageblit = cfb_imageblit, 330 .fb_imageblit = cfb_imageblit,
263}; 331};
264 332
265int __init hitfb_init(void) 333static int __init hitfb_probe(struct platform_device *dev)
266{ 334{
267 unsigned short lcdclor, ldr3, ldvndr; 335 unsigned short lcdclor, ldr3, ldvndr;
268 int size;
269 336
270 if (fb_get_options("hitfb", NULL)) 337 if (fb_get_options("hitfb", NULL))
271 return -ENODEV; 338 return -ENODEV;
272 339
340 hitfb_fix.mmio_start = CONFIG_HD64461_IOBASE+0x1000;
341 hitfb_fix.mmio_len = 0x1000;
273 hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000; 342 hitfb_fix.smem_start = CONFIG_HD64461_IOBASE + 0x02000000;
274 hitfb_fix.smem_len = (MACH_HP690) ? 1024 * 1024 : 512 * 1024; 343 hitfb_fix.smem_len = 512 * 1024;
275 344
276 lcdclor = fb_readw(HD64461_LCDCLOR); 345 lcdclor = fb_readw(HD64461_LCDCLOR);
277 ldvndr = fb_readw(HD64461_LDVNDR); 346 ldvndr = fb_readw(HD64461_LDVNDR);
@@ -321,12 +390,12 @@ int __init hitfb_init(void)
321 fb_info.var = hitfb_var; 390 fb_info.var = hitfb_var;
322 fb_info.fix = hitfb_fix; 391 fb_info.fix = hitfb_fix;
323 fb_info.pseudo_palette = pseudo_palette; 392 fb_info.pseudo_palette = pseudo_palette;
324 fb_info.flags = FBINFO_DEFAULT; 393 fb_info.flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
394 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
325 395
326 fb_info.screen_base = (void *)hitfb_fix.smem_start; 396 fb_info.screen_base = (void *)hitfb_fix.smem_start;
327 397
328 size = (fb_info.var.bits_per_pixel == 8) ? 256 : 16; 398 fb_alloc_cmap(&fb_info.cmap, 256, 0);
329 fb_alloc_cmap(&fb_info.cmap, size, 0);
330 399
331 if (register_framebuffer(&fb_info) < 0) 400 if (register_framebuffer(&fb_info) < 0)
332 return -EINVAL; 401 return -EINVAL;
@@ -336,9 +405,75 @@ int __init hitfb_init(void)
336 return 0; 405 return 0;
337} 406}
338 407
408static int __devexit hitfb_remove(struct platform_device *dev)
409{
410 return unregister_framebuffer(&fb_info);
411}
412
413#ifdef CONFIG_PM
414static int hitfb_suspend(struct platform_device *dev, pm_message_t state)
415{
416 u16 v;
417
418 hitfb_blank(1,0);
419 v = fb_readw(HD64461_STBCR);
420 v |= HD64461_STBCR_SLCKE_IST;
421 fb_writew(v, HD64461_STBCR);
422
423 return 0;
424}
425
426static int hitfb_resume(struct platform_device *dev)
427{
428 u16 v;
429
430 v = fb_readw(HD64461_STBCR);
431 v &= ~HD64461_STBCR_SLCKE_OST;
432 msleep(100);
433 v = fb_readw(HD64461_STBCR);
434 v &= ~HD64461_STBCR_SLCKE_IST;
435 fb_writew(v, HD64461_STBCR);
436 hitfb_blank(0,0);
437
438 return 0;
439}
440#endif
441
442static struct platform_driver hitfb_driver = {
443 .probe = hitfb_probe,
444 .remove = __devexit_p(hitfb_remove),
445#ifdef CONFIG_PM
446 .suspend = hitfb_suspend,
447 .resume = hitfb_resume,
448#endif
449 .driver = {
450 .name = "hitfb",
451 },
452};
453
454static struct platform_device hitfb_device = {
455 .name = "hitfb",
456 .id = -1,
457};
458
459static int __init hitfb_init(void)
460{
461 int ret;
462
463 ret = platform_driver_register(&hitfb_driver);
464 if (!ret) {
465 ret = platform_device_register(&hitfb_device);
466 if (ret)
467 platform_driver_unregister(&hitfb_driver);
468 }
469 return ret;
470}
471
472
339static void __exit hitfb_exit(void) 473static void __exit hitfb_exit(void)
340{ 474{
341 unregister_framebuffer(&fb_info); 475 platform_device_unregister(&hitfb_device);
476 platform_driver_unregister(&hitfb_driver);
342} 477}
343 478
344module_init(hitfb_init); 479module_init(hitfb_init);
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c
index c1f7b49975dd..7d06b38e80a0 100644
--- a/drivers/video/i810/i810-i2c.c
+++ b/drivers/video/i810/i810-i2c.c
@@ -98,7 +98,6 @@ static int i810_setup_i2c_bus(struct i810fb_i2c_chan *chan, const char *name)
98 chan->algo.getsda = i810i2c_getsda; 98 chan->algo.getsda = i810i2c_getsda;
99 chan->algo.getscl = i810i2c_getscl; 99 chan->algo.getscl = i810i2c_getscl;
100 chan->algo.udelay = 10; 100 chan->algo.udelay = 10;
101 chan->algo.mdelay = 10;
102 chan->algo.timeout = (HZ/2); 101 chan->algo.timeout = (HZ/2);
103 chan->algo.data = chan; 102 chan->algo.data = chan;
104 103
diff --git a/drivers/video/i810/i810_main.c b/drivers/video/i810/i810_main.c
index a6ca02f2156a..d42edaccb84c 100644
--- a/drivers/video/i810/i810_main.c
+++ b/drivers/video/i810/i810_main.c
@@ -1554,15 +1554,17 @@ static struct fb_ops i810fb_ops __devinitdata = {
1554/*********************************************************************** 1554/***********************************************************************
1555 * Power Management * 1555 * Power Management *
1556 ***********************************************************************/ 1556 ***********************************************************************/
1557static int i810fb_suspend(struct pci_dev *dev, pm_message_t state) 1557static int i810fb_suspend(struct pci_dev *dev, pm_message_t mesg)
1558{ 1558{
1559 struct fb_info *info = pci_get_drvdata(dev); 1559 struct fb_info *info = pci_get_drvdata(dev);
1560 struct i810fb_par *par = info->par; 1560 struct i810fb_par *par = info->par;
1561 1561
1562 par->cur_state = state.event; 1562 par->cur_state = mesg.event;
1563 1563
1564 if (state.event == PM_EVENT_FREEZE) { 1564 switch (mesg.event) {
1565 dev->dev.power.power_state = state; 1565 case PM_EVENT_FREEZE:
1566 case PM_EVENT_PRETHAW:
1567 dev->dev.power.power_state = mesg;
1566 return 0; 1568 return 0;
1567 } 1569 }
1568 1570
@@ -1578,7 +1580,7 @@ static int i810fb_suspend(struct pci_dev *dev, pm_message_t state)
1578 1580
1579 pci_save_state(dev); 1581 pci_save_state(dev);
1580 pci_disable_device(dev); 1582 pci_disable_device(dev);
1581 pci_set_power_state(dev, pci_choose_state(dev, state)); 1583 pci_set_power_state(dev, pci_choose_state(dev, mesg));
1582 release_console_sem(); 1584 release_console_sem();
1583 1585
1584 return 0; 1586 return 0;
diff --git a/drivers/video/matrox/i2c-matroxfb.c b/drivers/video/matrox/i2c-matroxfb.c
index 57abbae5520f..795c1a99a680 100644
--- a/drivers/video/matrox/i2c-matroxfb.c
+++ b/drivers/video/matrox/i2c-matroxfb.c
@@ -95,12 +95,12 @@ static struct i2c_adapter matrox_i2c_adapter_template =
95 95
96static struct i2c_algo_bit_data matrox_i2c_algo_template = 96static struct i2c_algo_bit_data matrox_i2c_algo_template =
97{ 97{
98 NULL, 98 .setsda = matroxfb_gpio_setsda,
99 matroxfb_gpio_setsda, 99 .setscl = matroxfb_gpio_setscl,
100 matroxfb_gpio_setscl, 100 .getsda = matroxfb_gpio_getsda,
101 matroxfb_gpio_getsda, 101 .getscl = matroxfb_gpio_getscl,
102 matroxfb_gpio_getscl, 102 .udelay = 10,
103 10, 10, 100, 103 .timeout = 100,
104}; 104};
105 105
106static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo, 106static int i2c_bus_reg(struct i2c_bit_adapter* b, struct matrox_fb_info* minfo,
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index d4f850117874..f8cd4c519aeb 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -950,24 +950,25 @@ static struct fb_ops nvidia_fb_ops = {
950}; 950};
951 951
952#ifdef CONFIG_PM 952#ifdef CONFIG_PM
953static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t state) 953static int nvidiafb_suspend(struct pci_dev *dev, pm_message_t mesg)
954{ 954{
955 struct fb_info *info = pci_get_drvdata(dev); 955 struct fb_info *info = pci_get_drvdata(dev);
956 struct nvidia_par *par = info->par; 956 struct nvidia_par *par = info->par;
957 957
958 if (mesg.event == PM_EVENT_PRETHAW)
959 mesg.event = PM_EVENT_FREEZE;
958 acquire_console_sem(); 960 acquire_console_sem();
959 par->pm_state = state.event; 961 par->pm_state = mesg.event;
960 962
961 if (state.event == PM_EVENT_FREEZE) { 963 if (mesg.event == PM_EVENT_SUSPEND) {
962 dev->dev.power.power_state = state;
963 } else {
964 fb_set_suspend(info, 1); 964 fb_set_suspend(info, 1);
965 nvidiafb_blank(FB_BLANK_POWERDOWN, info); 965 nvidiafb_blank(FB_BLANK_POWERDOWN, info);
966 nvidia_write_regs(par, &par->SavedReg); 966 nvidia_write_regs(par, &par->SavedReg);
967 pci_save_state(dev); 967 pci_save_state(dev);
968 pci_disable_device(dev); 968 pci_disable_device(dev);
969 pci_set_power_state(dev, pci_choose_state(dev, state)); 969 pci_set_power_state(dev, pci_choose_state(dev, mesg));
970 } 970 }
971 dev->dev.power.power_state = mesg;
971 972
972 release_console_sem(); 973 release_console_sem();
973 return 0; 974 return 0;
diff --git a/drivers/video/pvr2fb.c b/drivers/video/pvr2fb.c
index 940ba2be55e9..78dc59a1751b 100644
--- a/drivers/video/pvr2fb.c
+++ b/drivers/video/pvr2fb.c
@@ -187,7 +187,7 @@ static short do_blank = 0; /* (Un)Blank the screen */
187static unsigned int is_blanked = 0; /* Is the screen blanked? */ 187static unsigned int is_blanked = 0; /* Is the screen blanked? */
188 188
189#ifdef CONFIG_SH_STORE_QUEUES 189#ifdef CONFIG_SH_STORE_QUEUES
190static struct sq_mapping *pvr2fb_map; 190static unsigned long pvr2fb_map;
191#endif 191#endif
192 192
193#ifdef CONFIG_SH_DMA 193#ifdef CONFIG_SH_DMA
@@ -213,15 +213,17 @@ static irqreturn_t pvr2fb_interrupt(int irq, void *dev_id, struct pt_regs *fp);
213static int pvr2_init_cable(void); 213static int pvr2_init_cable(void);
214static int pvr2_get_param(const struct pvr2_params *p, const char *s, 214static int pvr2_get_param(const struct pvr2_params *p, const char *s,
215 int val, int size); 215 int val, int size);
216#ifdef CONFIG_SH_DMA
216static ssize_t pvr2fb_write(struct file *file, const char *buf, 217static ssize_t pvr2fb_write(struct file *file, const char *buf,
217 size_t count, loff_t *ppos); 218 size_t count, loff_t *ppos);
219#endif
218 220
219static struct fb_ops pvr2fb_ops = { 221static struct fb_ops pvr2fb_ops = {
220 .owner = THIS_MODULE, 222 .owner = THIS_MODULE,
221 .fb_setcolreg = pvr2fb_setcolreg, 223 .fb_setcolreg = pvr2fb_setcolreg,
222 .fb_blank = pvr2fb_blank, 224 .fb_blank = pvr2fb_blank,
223 .fb_check_var = pvr2fb_check_var, 225 .fb_check_var = pvr2fb_check_var,
224 .fb_set_par = pvr2fb_set_par, 226 .fb_set_par = pvr2fb_set_par,
225#ifdef CONFIG_SH_DMA 227#ifdef CONFIG_SH_DMA
226 .fb_write = pvr2fb_write, 228 .fb_write = pvr2fb_write,
227#endif 229#endif
@@ -783,7 +785,7 @@ static int __init pvr2fb_common_init(void)
783 goto out_err; 785 goto out_err;
784 } 786 }
785 787
786 fb_memset((unsigned long)fb_info->screen_base, 0, pvr2_fix.smem_len); 788 fb_memset(fb_info->screen_base, 0, pvr2_fix.smem_len);
787 789
788 pvr2_fix.ypanstep = nopan ? 0 : 1; 790 pvr2_fix.ypanstep = nopan ? 0 : 1;
789 pvr2_fix.ywrapstep = nowrap ? 0 : 1; 791 pvr2_fix.ywrapstep = nowrap ? 0 : 1;
@@ -820,7 +822,7 @@ static int __init pvr2fb_common_init(void)
820 modememused >> 10, (unsigned long)(fb_info->fix.smem_len >> 10)); 822 modememused >> 10, (unsigned long)(fb_info->fix.smem_len >> 10));
821 printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n", 823 printk("fb%d: Mode %dx%d-%d pitch = %ld cable: %s video output: %s\n",
822 fb_info->node, fb_info->var.xres, fb_info->var.yres, 824 fb_info->node, fb_info->var.xres, fb_info->var.yres,
823 fb_info->var.bits_per_pixel, 825 fb_info->var.bits_per_pixel,
824 get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel), 826 get_line_length(fb_info->var.xres, fb_info->var.bits_per_pixel),
825 (char *)pvr2_get_param(cables, NULL, cable_type, 3), 827 (char *)pvr2_get_param(cables, NULL, cable_type, 3),
826 (char *)pvr2_get_param(outputs, NULL, video_output, 3)); 828 (char *)pvr2_get_param(outputs, NULL, video_output, 3));
@@ -829,10 +831,10 @@ static int __init pvr2fb_common_init(void)
829 printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node); 831 printk(KERN_NOTICE "fb%d: registering with SQ API\n", fb_info->node);
830 832
831 pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len, 833 pvr2fb_map = sq_remap(fb_info->fix.smem_start, fb_info->fix.smem_len,
832 fb_info->fix.id); 834 fb_info->fix.id, pgprot_val(PAGE_SHARED));
833 835
834 printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n", 836 printk(KERN_NOTICE "fb%d: Mapped video memory to SQ addr 0x%lx\n",
835 fb_info->node, pvr2fb_map->sq_addr); 837 fb_info->node, pvr2fb_map);
836#endif 838#endif
837 839
838 return 0; 840 return 0;
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index e83befd16d63..d7d810dbf0bd 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -148,7 +148,6 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
148 chan->adapter.algo_data = &chan->algo; 148 chan->adapter.algo_data = &chan->algo;
149 chan->adapter.dev.parent = &chan->par->pcidev->dev; 149 chan->adapter.dev.parent = &chan->par->pcidev->dev;
150 chan->algo.udelay = 40; 150 chan->algo.udelay = 40;
151 chan->algo.mdelay = 5;
152 chan->algo.timeout = 20; 151 chan->algo.timeout = 20;
153 chan->algo.data = chan; 152 chan->algo.data = chan;
154 153
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c
index 461e094e7b45..82b3deaae02d 100644
--- a/drivers/video/savage/savagefb_driver.c
+++ b/drivers/video/savage/savagefb_driver.c
@@ -2323,24 +2323,24 @@ static void __devexit savagefb_remove(struct pci_dev *dev)
2323 } 2323 }
2324} 2324}
2325 2325
2326static int savagefb_suspend(struct pci_dev* dev, pm_message_t state) 2326static int savagefb_suspend(struct pci_dev *dev, pm_message_t mesg)
2327{ 2327{
2328 struct fb_info *info = pci_get_drvdata(dev); 2328 struct fb_info *info = pci_get_drvdata(dev);
2329 struct savagefb_par *par = info->par; 2329 struct savagefb_par *par = info->par;
2330 2330
2331 DBG("savagefb_suspend"); 2331 DBG("savagefb_suspend");
2332 2332
2333 2333 if (mesg.event == PM_EVENT_PRETHAW)
2334 par->pm_state = state.event; 2334 mesg.event = PM_EVENT_FREEZE;
2335 par->pm_state = mesg.event;
2336 dev->dev.power.power_state = mesg;
2335 2337
2336 /* 2338 /*
2337 * For PM_EVENT_FREEZE, do not power down so the console 2339 * For PM_EVENT_FREEZE, do not power down so the console
2338 * can remain active. 2340 * can remain active.
2339 */ 2341 */
2340 if (state.event == PM_EVENT_FREEZE) { 2342 if (mesg.event == PM_EVENT_FREEZE)
2341 dev->dev.power.power_state = state;
2342 return 0; 2343 return 0;
2343 }
2344 2344
2345 acquire_console_sem(); 2345 acquire_console_sem();
2346 fb_set_suspend(info, 1); 2346 fb_set_suspend(info, 1);
@@ -2353,7 +2353,7 @@ static int savagefb_suspend(struct pci_dev* dev, pm_message_t state)
2353 savage_disable_mmio(par); 2353 savage_disable_mmio(par);
2354 pci_save_state(dev); 2354 pci_save_state(dev);
2355 pci_disable_device(dev); 2355 pci_disable_device(dev);
2356 pci_set_power_state(dev, pci_choose_state(dev, state)); 2356 pci_set_power_state(dev, pci_choose_state(dev, mesg));
2357 release_console_sem(); 2357 release_console_sem();
2358 2358
2359 return 0; 2359 return 0;
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index eae50c9d6dc4..7a7ec2d1d2f4 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -204,7 +204,6 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
204 inode->i_mode = mode; 204 inode->i_mode = mode;
205 inode->i_uid = current->fsuid; 205 inode->i_uid = current->fsuid;
206 inode->i_gid = current->fsgid; 206 inode->i_gid = current->fsgid;
207 inode->i_blksize = sb->s_blocksize;
208 inode->i_blocks = 0; 207 inode->i_blocks = 0;
209 inode->i_rdev = 0; 208 inode->i_rdev = 0;
210 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 209 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -950,9 +949,8 @@ v9fs_stat2inode(struct v9fs_stat *stat, struct inode *inode,
950 949
951 inode->i_size = stat->length; 950 inode->i_size = stat->length;
952 951
953 inode->i_blksize = sb->s_blocksize;
954 inode->i_blocks = 952 inode->i_blocks =
955 (inode->i_size + inode->i_blksize - 1) >> sb->s_blocksize_bits; 953 (inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
956} 954}
957 955
958/** 956/**
diff --git a/fs/Kconfig b/fs/Kconfig
index a27002668bd3..d311198bba43 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -826,6 +826,25 @@ config PROC_VMCORE
826 help 826 help
827 Exports the dump image of crashed kernel in ELF format. 827 Exports the dump image of crashed kernel in ELF format.
828 828
829config PROC_SYSCTL
830 bool "Sysctl support (/proc/sys)" if EMBEDDED
831 depends on PROC_FS
832 select SYSCTL
833 default y
834 ---help---
835 The sysctl interface provides a means of dynamically changing
836 certain kernel parameters and variables on the fly without requiring
837 a recompile of the kernel or reboot of the system. The primary
838 interface is through /proc/sys. If you say Y here a tree of
839 modifiable sysctl entries will be generated beneath the
840 /proc/sys directory. They are explained in the files
841 in <file:Documentation/sysctl/>. Note that enabling this
842 option will enlarge the kernel by at least 8 KB.
843
844 As it is generally a good thing, you should say Y here unless
845 building a kernel for install/rescue disks or your system is very
846 limited in memory.
847
829config SYSFS 848config SYSFS
830 bool "sysfs file system support" if EMBEDDED 849 bool "sysfs file system support" if EMBEDDED
831 default y 850 default y
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 534f3eecc985..7e7a04be1278 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -269,7 +269,6 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
269 inode->i_ino = obj->file_id; 269 inode->i_ino = obj->file_id;
270 inode->i_size = obj->size; 270 inode->i_size = obj->size;
271 inode->i_nlink = 2; 271 inode->i_nlink = 2;
272 inode->i_blksize = PAGE_SIZE;
273 inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >> 272 inode->i_blocks = (inode->i_size + sb->s_blocksize - 1) >>
274 sb->s_blocksize_bits; 273 sb->s_blocksize_bits;
275 274
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 82011019494c..9ade139086fc 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -251,8 +251,7 @@ static int init_inodecache(void)
251 251
252static void destroy_inodecache(void) 252static void destroy_inodecache(void)
253{ 253{
254 if (kmem_cache_destroy(adfs_inode_cachep)) 254 kmem_cache_destroy(adfs_inode_cachep);
255 printk(KERN_INFO "adfs_inode_cache: not all structures were freed\n");
256} 255}
257 256
258static struct super_operations adfs_sops = { 257static struct super_operations adfs_sops = {
@@ -339,11 +338,10 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent)
339 338
340 sb->s_flags |= MS_NODIRATIME; 339 sb->s_flags |= MS_NODIRATIME;
341 340
342 asb = kmalloc(sizeof(*asb), GFP_KERNEL); 341 asb = kzalloc(sizeof(*asb), GFP_KERNEL);
343 if (!asb) 342 if (!asb)
344 return -ENOMEM; 343 return -ENOMEM;
345 sb->s_fs_info = asb; 344 sb->s_fs_info = asb;
346 memset(asb, 0, sizeof(*asb));
347 345
348 /* set default options */ 346 /* set default options */
349 asb->s_uid = 0; 347 asb->s_uid = 0;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 17352011ab67..5ea72c3a16c3 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -109,8 +109,7 @@ static int init_inodecache(void)
109 109
110static void destroy_inodecache(void) 110static void destroy_inodecache(void)
111{ 111{
112 if (kmem_cache_destroy(affs_inode_cachep)) 112 kmem_cache_destroy(affs_inode_cachep);
113 printk(KERN_INFO "affs_inode_cache: not all structures were freed\n");
114} 113}
115 114
116static struct super_operations affs_sops = { 115static struct super_operations affs_sops = {
@@ -280,11 +279,10 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
280 sb->s_op = &affs_sops; 279 sb->s_op = &affs_sops;
281 sb->s_flags |= MS_NODIRATIME; 280 sb->s_flags |= MS_NODIRATIME;
282 281
283 sbi = kmalloc(sizeof(struct affs_sb_info), GFP_KERNEL); 282 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
284 if (!sbi) 283 if (!sbi)
285 return -ENOMEM; 284 return -ENOMEM;
286 sb->s_fs_info = sbi; 285 sb->s_fs_info = sbi;
287 memset(sbi, 0, sizeof(*sbi));
288 init_MUTEX(&sbi->s_bmlock); 286 init_MUTEX(&sbi->s_bmlock);
289 287
290 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, 288 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 4ebb30a50ed5..6f37754906c2 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -72,7 +72,6 @@ static int afs_inode_map_status(struct afs_vnode *vnode)
72 inode->i_ctime.tv_sec = vnode->status.mtime_server; 72 inode->i_ctime.tv_sec = vnode->status.mtime_server;
73 inode->i_ctime.tv_nsec = 0; 73 inode->i_ctime.tv_nsec = 0;
74 inode->i_atime = inode->i_mtime = inode->i_ctime; 74 inode->i_atime = inode->i_mtime = inode->i_ctime;
75 inode->i_blksize = PAGE_CACHE_SIZE;
76 inode->i_blocks = 0; 75 inode->i_blocks = 0;
77 inode->i_version = vnode->fid.unique; 76 inode->i_version = vnode->fid.unique;
78 inode->i_mapping->a_ops = &afs_fs_aops; 77 inode->i_mapping->a_ops = &afs_fs_aops;
diff --git a/fs/afs/vlocation.c b/fs/afs/vlocation.c
index 331f730a1fb3..782ee7c600ca 100644
--- a/fs/afs/vlocation.c
+++ b/fs/afs/vlocation.c
@@ -281,11 +281,10 @@ int afs_vlocation_lookup(struct afs_cell *cell,
281 spin_unlock(&cell->vl_gylock); 281 spin_unlock(&cell->vl_gylock);
282 282
283 /* not in the cell's in-memory lists - create a new record */ 283 /* not in the cell's in-memory lists - create a new record */
284 vlocation = kmalloc(sizeof(struct afs_vlocation), GFP_KERNEL); 284 vlocation = kzalloc(sizeof(struct afs_vlocation), GFP_KERNEL);
285 if (!vlocation) 285 if (!vlocation)
286 return -ENOMEM; 286 return -ENOMEM;
287 287
288 memset(vlocation, 0, sizeof(struct afs_vlocation));
289 atomic_set(&vlocation->usage, 1); 288 atomic_set(&vlocation->usage, 1);
290 INIT_LIST_HEAD(&vlocation->link); 289 INIT_LIST_HEAD(&vlocation->link);
291 rwlock_init(&vlocation->lock); 290 rwlock_init(&vlocation->lock);
diff --git a/fs/afs/volume.c b/fs/afs/volume.c
index 0ff4b86476e3..768c6dbd323a 100644
--- a/fs/afs/volume.c
+++ b/fs/afs/volume.c
@@ -186,11 +186,10 @@ int afs_volume_lookup(const char *name, struct afs_cell *cell, int rwpath,
186 _debug("creating new volume record"); 186 _debug("creating new volume record");
187 187
188 ret = -ENOMEM; 188 ret = -ENOMEM;
189 volume = kmalloc(sizeof(struct afs_volume), GFP_KERNEL); 189 volume = kzalloc(sizeof(struct afs_volume), GFP_KERNEL);
190 if (!volume) 190 if (!volume)
191 goto error_up; 191 goto error_up;
192 192
193 memset(volume, 0, sizeof(struct afs_volume));
194 atomic_set(&volume->usage, 1); 193 atomic_set(&volume->usage, 1);
195 volume->type = type; 194 volume->type = type;
196 volume->type_force = force; 195 volume->type_force = force;
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
index af2efbbb5d76..2c9759baad61 100644
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -129,10 +129,9 @@ int autofs_fill_super(struct super_block *s, void *data, int silent)
129 struct autofs_sb_info *sbi; 129 struct autofs_sb_info *sbi;
130 int minproto, maxproto; 130 int minproto, maxproto;
131 131
132 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 132 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
133 if ( !sbi ) 133 if ( !sbi )
134 goto fail_unlock; 134 goto fail_unlock;
135 memset(sbi, 0, sizeof(*sbi));
136 DPRINTK(("autofs: starting up, sbi = %p\n",sbi)); 135 DPRINTK(("autofs: starting up, sbi = %p\n",sbi));
137 136
138 s->s_fs_info = sbi; 137 s->s_fs_info = sbi;
@@ -217,7 +216,6 @@ static void autofs_read_inode(struct inode *inode)
217 inode->i_nlink = 2; 216 inode->i_nlink = 2;
218 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 217 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
219 inode->i_blocks = 0; 218 inode->i_blocks = 0;
220 inode->i_blksize = 1024;
221 219
222 if ( ino == AUTOFS_ROOT_INO ) { 220 if ( ino == AUTOFS_ROOT_INO ) {
223 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 221 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
@@ -242,7 +240,7 @@ static void autofs_read_inode(struct inode *inode)
242 240
243 inode->i_op = &autofs_symlink_inode_operations; 241 inode->i_op = &autofs_symlink_inode_operations;
244 sl = &sbi->symlink[n]; 242 sl = &sbi->symlink[n];
245 inode->u.generic_ip = sl; 243 inode->i_private = sl;
246 inode->i_mode = S_IFLNK | S_IRWXUGO; 244 inode->i_mode = S_IFLNK | S_IRWXUGO;
247 inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = sl->mtime; 245 inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = sl->mtime;
248 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0; 246 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = 0;
diff --git a/fs/autofs/symlink.c b/fs/autofs/symlink.c
index 52e8772b066e..c74f2eb65775 100644
--- a/fs/autofs/symlink.c
+++ b/fs/autofs/symlink.c
@@ -15,7 +15,7 @@
15/* Nothing to release.. */ 15/* Nothing to release.. */
16static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd) 16static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd)
17{ 17{
18 char *s=((struct autofs_symlink *)dentry->d_inode->u.generic_ip)->data; 18 char *s=((struct autofs_symlink *)dentry->d_inode->i_private)->data;
19 nd_set_link(nd, s); 19 nd_set_link(nd, s);
20 return NULL; 20 return NULL;
21} 21}
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 11a6a9ae51b7..800ce876caec 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -447,7 +447,6 @@ struct inode *autofs4_get_inode(struct super_block *sb,
447 inode->i_uid = 0; 447 inode->i_uid = 0;
448 inode->i_gid = 0; 448 inode->i_gid = 0;
449 } 449 }
450 inode->i_blksize = PAGE_CACHE_SIZE;
451 inode->i_blocks = 0; 450 inode->i_blocks = 0;
452 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 451 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
453 452
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 5100f984783f..27e17f96cada 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -137,7 +137,9 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)
137 nd.flags = LOOKUP_DIRECTORY; 137 nd.flags = LOOKUP_DIRECTORY;
138 ret = (dentry->d_op->d_revalidate)(dentry, &nd); 138 ret = (dentry->d_op->d_revalidate)(dentry, &nd);
139 139
140 if (!ret) { 140 if (ret <= 0) {
141 if (ret < 0)
142 status = ret;
141 dcache_dir_close(inode, file); 143 dcache_dir_close(inode, file);
142 goto out; 144 goto out;
143 } 145 }
@@ -400,13 +402,23 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
400 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb); 402 struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
401 int oz_mode = autofs4_oz_mode(sbi); 403 int oz_mode = autofs4_oz_mode(sbi);
402 int flags = nd ? nd->flags : 0; 404 int flags = nd ? nd->flags : 0;
403 int status = 0; 405 int status = 1;
404 406
405 /* Pending dentry */ 407 /* Pending dentry */
406 if (autofs4_ispending(dentry)) { 408 if (autofs4_ispending(dentry)) {
407 if (!oz_mode) 409 /* The daemon never causes a mount to trigger */
408 status = try_to_fill_dentry(dentry, flags); 410 if (oz_mode)
409 return !status; 411 return 1;
412
413 /*
414 * A zero status is success otherwise we have a
415 * negative error code.
416 */
417 status = try_to_fill_dentry(dentry, flags);
418 if (status == 0)
419 return 1;
420
421 return status;
410 } 422 }
411 423
412 /* Negative dentry.. invalidate if "old" */ 424 /* Negative dentry.. invalidate if "old" */
@@ -421,9 +433,19 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
421 DPRINTK("dentry=%p %.*s, emptydir", 433 DPRINTK("dentry=%p %.*s, emptydir",
422 dentry, dentry->d_name.len, dentry->d_name.name); 434 dentry, dentry->d_name.len, dentry->d_name.name);
423 spin_unlock(&dcache_lock); 435 spin_unlock(&dcache_lock);
424 if (!oz_mode) 436 /* The daemon never causes a mount to trigger */
425 status = try_to_fill_dentry(dentry, flags); 437 if (oz_mode)
426 return !status; 438 return 1;
439
440 /*
441 * A zero status is success otherwise we have a
442 * negative error code.
443 */
444 status = try_to_fill_dentry(dentry, flags);
445 if (status == 0)
446 return 1;
447
448 return status;
427 } 449 }
428 spin_unlock(&dcache_lock); 450 spin_unlock(&dcache_lock);
429 451
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index 50cfca5c7efd..57020c7a7e65 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -365,7 +365,6 @@ befs_read_inode(struct inode *inode)
365 inode->i_mtime.tv_nsec = 0; /* lower 16 bits are not a time */ 365 inode->i_mtime.tv_nsec = 0; /* lower 16 bits are not a time */
366 inode->i_ctime = inode->i_mtime; 366 inode->i_ctime = inode->i_mtime;
367 inode->i_atime = inode->i_mtime; 367 inode->i_atime = inode->i_mtime;
368 inode->i_blksize = befs_sb->block_size;
369 368
370 befs_ino->i_inode_num = fsrun_to_cpu(sb, raw_inode->inode_num); 369 befs_ino->i_inode_num = fsrun_to_cpu(sb, raw_inode->inode_num);
371 befs_ino->i_parent = fsrun_to_cpu(sb, raw_inode->parent); 370 befs_ino->i_parent = fsrun_to_cpu(sb, raw_inode->parent);
@@ -446,9 +445,7 @@ befs_init_inodecache(void)
446static void 445static void
447befs_destroy_inodecache(void) 446befs_destroy_inodecache(void)
448{ 447{
449 if (kmem_cache_destroy(befs_inode_cachep)) 448 kmem_cache_destroy(befs_inode_cachep);
450 printk(KERN_ERR "befs_destroy_inodecache: "
451 "not all structures were freed\n");
452} 449}
453 450
454/* 451/*
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 26fad9621738..dcf04cb13283 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -102,7 +102,7 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode,
102 inode->i_uid = current->fsuid; 102 inode->i_uid = current->fsuid;
103 inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; 103 inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
104 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 104 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
105 inode->i_blocks = inode->i_blksize = 0; 105 inode->i_blocks = 0;
106 inode->i_op = &bfs_file_inops; 106 inode->i_op = &bfs_file_inops;
107 inode->i_fop = &bfs_file_operations; 107 inode->i_fop = &bfs_file_operations;
108 inode->i_mapping->a_ops = &bfs_aops; 108 inode->i_mapping->a_ops = &bfs_aops;
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index cf74f3d4d966..ed27ffb3459e 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -76,7 +76,6 @@ static void bfs_read_inode(struct inode * inode)
76 inode->i_size = BFS_FILESIZE(di); 76 inode->i_size = BFS_FILESIZE(di);
77 inode->i_blocks = BFS_FILEBLOCKS(di); 77 inode->i_blocks = BFS_FILEBLOCKS(di);
78 if (inode->i_size || inode->i_blocks) dprintf("Registered inode with %lld size, %ld blocks\n", inode->i_size, inode->i_blocks); 78 if (inode->i_size || inode->i_blocks) dprintf("Registered inode with %lld size, %ld blocks\n", inode->i_size, inode->i_blocks);
79 inode->i_blksize = PAGE_SIZE;
80 inode->i_atime.tv_sec = le32_to_cpu(di->i_atime); 79 inode->i_atime.tv_sec = le32_to_cpu(di->i_atime);
81 inode->i_mtime.tv_sec = le32_to_cpu(di->i_mtime); 80 inode->i_mtime.tv_sec = le32_to_cpu(di->i_mtime);
82 inode->i_ctime.tv_sec = le32_to_cpu(di->i_ctime); 81 inode->i_ctime.tv_sec = le32_to_cpu(di->i_ctime);
@@ -268,8 +267,7 @@ static int init_inodecache(void)
268 267
269static void destroy_inodecache(void) 268static void destroy_inodecache(void)
270{ 269{
271 if (kmem_cache_destroy(bfs_inode_cachep)) 270 kmem_cache_destroy(bfs_inode_cachep);
272 printk(KERN_INFO "bfs_inode_cache: not all structures were freed\n");
273} 271}
274 272
275static struct super_operations bfs_sops = { 273static struct super_operations bfs_sops = {
@@ -311,11 +309,10 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
311 unsigned i, imap_len; 309 unsigned i, imap_len;
312 struct bfs_sb_info * info; 310 struct bfs_sb_info * info;
313 311
314 info = kmalloc(sizeof(*info), GFP_KERNEL); 312 info = kzalloc(sizeof(*info), GFP_KERNEL);
315 if (!info) 313 if (!info)
316 return -ENOMEM; 314 return -ENOMEM;
317 s->s_fs_info = info; 315 s->s_fs_info = info;
318 memset(info, 0, sizeof(*info));
319 316
320 sb_set_blocksize(s, BFS_BSIZE); 317 sb_set_blocksize(s, BFS_BSIZE);
321 318
@@ -338,10 +335,9 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
338 + BFS_ROOT_INO - 1; 335 + BFS_ROOT_INO - 1;
339 336
340 imap_len = info->si_lasti/8 + 1; 337 imap_len = info->si_lasti/8 + 1;
341 info->si_imap = kmalloc(imap_len, GFP_KERNEL); 338 info->si_imap = kzalloc(imap_len, GFP_KERNEL);
342 if (!info->si_imap) 339 if (!info->si_imap)
343 goto out; 340 goto out;
344 memset(info->si_imap, 0, imap_len);
345 for (i=0; i<BFS_ROOT_INO; i++) 341 for (i=0; i<BFS_ROOT_INO; i++)
346 set_bit(i, info->si_imap); 342 set_bit(i, info->si_imap);
347 343
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 64802aabd1ac..dfd8cfb7fb5d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -515,7 +515,8 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
515{ 515{
516 unsigned int random_variable = 0; 516 unsigned int random_variable = 0;
517 517
518 if (current->flags & PF_RANDOMIZE) { 518 if ((current->flags & PF_RANDOMIZE) &&
519 !(current->personality & ADDR_NO_RANDOMIZE)) {
519 random_variable = get_random_int() & STACK_RND_MASK; 520 random_variable = get_random_int() & STACK_RND_MASK;
520 random_variable <<= PAGE_SHIFT; 521 random_variable <<= PAGE_SHIFT;
521 } 522 }
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index 34ebbc191e46..66ba137f8661 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -507,7 +507,6 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
507 inode->i_mode = mode; 507 inode->i_mode = mode;
508 inode->i_uid = 0; 508 inode->i_uid = 0;
509 inode->i_gid = 0; 509 inode->i_gid = 0;
510 inode->i_blksize = PAGE_CACHE_SIZE;
511 inode->i_blocks = 0; 510 inode->i_blocks = 0;
512 inode->i_atime = inode->i_mtime = inode->i_ctime = 511 inode->i_atime = inode->i_mtime = inode->i_ctime =
513 current_fs_time(inode->i_sb); 512 current_fs_time(inode->i_sb);
@@ -517,7 +516,7 @@ static struct inode *bm_get_inode(struct super_block *sb, int mode)
517 516
518static void bm_clear_inode(struct inode *inode) 517static void bm_clear_inode(struct inode *inode)
519{ 518{
520 kfree(inode->u.generic_ip); 519 kfree(inode->i_private);
521} 520}
522 521
523static void kill_node(Node *e) 522static void kill_node(Node *e)
@@ -545,7 +544,7 @@ static void kill_node(Node *e)
545static ssize_t 544static ssize_t
546bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) 545bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos)
547{ 546{
548 Node *e = file->f_dentry->d_inode->u.generic_ip; 547 Node *e = file->f_dentry->d_inode->i_private;
549 loff_t pos = *ppos; 548 loff_t pos = *ppos;
550 ssize_t res; 549 ssize_t res;
551 char *page; 550 char *page;
@@ -579,7 +578,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
579 size_t count, loff_t *ppos) 578 size_t count, loff_t *ppos)
580{ 579{
581 struct dentry *root; 580 struct dentry *root;
582 Node *e = file->f_dentry->d_inode->u.generic_ip; 581 Node *e = file->f_dentry->d_inode->i_private;
583 int res = parse_command(buffer, count); 582 int res = parse_command(buffer, count);
584 583
585 switch (res) { 584 switch (res) {
@@ -646,7 +645,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
646 } 645 }
647 646
648 e->dentry = dget(dentry); 647 e->dentry = dget(dentry);
649 inode->u.generic_ip = e; 648 inode->i_private = e;
650 inode->i_fop = &bm_entry_operations; 649 inode->i_fop = &bm_entry_operations;
651 650
652 d_instantiate(dentry, inode); 651 d_instantiate(dentry, inode);
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 3483d3cf8087..0009346d827f 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -19,11 +19,30 @@
19#include <linux/kobj_map.h> 19#include <linux/kobj_map.h>
20#include <linux/cdev.h> 20#include <linux/cdev.h>
21#include <linux/mutex.h> 21#include <linux/mutex.h>
22#include <linux/backing-dev.h>
22 23
23#ifdef CONFIG_KMOD 24#ifdef CONFIG_KMOD
24#include <linux/kmod.h> 25#include <linux/kmod.h>
25#endif 26#endif
26 27
28/*
29 * capabilities for /dev/mem, /dev/kmem and similar directly mappable character
30 * devices
31 * - permits shared-mmap for read, write and/or exec
32 * - does not permit private mmap in NOMMU mode (can't do COW)
33 * - no readahead or I/O queue unplugging required
34 */
35struct backing_dev_info directly_mappable_cdev_bdi = {
36 .capabilities = (
37#ifdef CONFIG_MMU
38 /* permit private copies of the data to be taken */
39 BDI_CAP_MAP_COPY |
40#endif
41 /* permit direct mmap, for read, write or exec */
42 BDI_CAP_MAP_DIRECT |
43 BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP),
44};
45
27static struct kobj_map *cdev_map; 46static struct kobj_map *cdev_map;
28 47
29static DEFINE_MUTEX(chrdevs_lock); 48static DEFINE_MUTEX(chrdevs_lock);
@@ -461,3 +480,4 @@ EXPORT_SYMBOL(cdev_del);
461EXPORT_SYMBOL(cdev_add); 480EXPORT_SYMBOL(cdev_add);
462EXPORT_SYMBOL(register_chrdev); 481EXPORT_SYMBOL(register_chrdev);
463EXPORT_SYMBOL(unregister_chrdev); 482EXPORT_SYMBOL(unregister_chrdev);
483EXPORT_SYMBOL(directly_mappable_cdev_bdi);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index c3ef1c0d0e68..22bcf4d7e7ae 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -253,7 +253,6 @@ cifs_alloc_inode(struct super_block *sb)
253 file data or metadata */ 253 file data or metadata */
254 cifs_inode->clientCanCacheRead = FALSE; 254 cifs_inode->clientCanCacheRead = FALSE;
255 cifs_inode->clientCanCacheAll = FALSE; 255 cifs_inode->clientCanCacheAll = FALSE;
256 cifs_inode->vfs_inode.i_blksize = CIFS_MAX_MSGSIZE;
257 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */ 256 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
258 cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME; 257 cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;
259 INIT_LIST_HEAD(&cifs_inode->openFileList); 258 INIT_LIST_HEAD(&cifs_inode->openFileList);
@@ -699,8 +698,7 @@ cifs_init_inodecache(void)
699static void 698static void
700cifs_destroy_inodecache(void) 699cifs_destroy_inodecache(void)
701{ 700{
702 if (kmem_cache_destroy(cifs_inode_cachep)) 701 kmem_cache_destroy(cifs_inode_cachep);
703 printk(KERN_WARNING "cifs_inode_cache: error freeing\n");
704} 702}
705 703
706static int 704static int
@@ -778,13 +776,9 @@ static void
778cifs_destroy_request_bufs(void) 776cifs_destroy_request_bufs(void)
779{ 777{
780 mempool_destroy(cifs_req_poolp); 778 mempool_destroy(cifs_req_poolp);
781 if (kmem_cache_destroy(cifs_req_cachep)) 779 kmem_cache_destroy(cifs_req_cachep);
782 printk(KERN_WARNING
783 "cifs_destroy_request_cache: error not all structures were freed\n");
784 mempool_destroy(cifs_sm_req_poolp); 780 mempool_destroy(cifs_sm_req_poolp);
785 if (kmem_cache_destroy(cifs_sm_req_cachep)) 781 kmem_cache_destroy(cifs_sm_req_cachep);
786 printk(KERN_WARNING
787 "cifs_destroy_request_cache: cifs_small_rq free error\n");
788} 782}
789 783
790static int 784static int
@@ -819,13 +813,8 @@ static void
819cifs_destroy_mids(void) 813cifs_destroy_mids(void)
820{ 814{
821 mempool_destroy(cifs_mid_poolp); 815 mempool_destroy(cifs_mid_poolp);
822 if (kmem_cache_destroy(cifs_mid_cachep)) 816 kmem_cache_destroy(cifs_mid_cachep);
823 printk(KERN_WARNING 817 kmem_cache_destroy(cifs_oplock_cachep);
824 "cifs_destroy_mids: error not all structures were freed\n");
825
826 if (kmem_cache_destroy(cifs_oplock_cachep))
827 printk(KERN_WARNING
828 "error not all oplock structures were freed\n");
829} 818}
830 819
831static int cifs_oplock_thread(void * dummyarg) 820static int cifs_oplock_thread(void * dummyarg)
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 9aeb58a7d369..b27b34537bf2 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -216,10 +216,9 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
216 216
217 if (allocation_size < end_of_file) 217 if (allocation_size < end_of_file)
218 cFYI(1, ("May be sparse file, allocation less than file size")); 218 cFYI(1, ("May be sparse file, allocation less than file size"));
219 cFYI(1, ("File Size %ld and blocks %llu and blocksize %ld", 219 cFYI(1, ("File Size %ld and blocks %llu",
220 (unsigned long)tmp_inode->i_size, 220 (unsigned long)tmp_inode->i_size,
221 (unsigned long long)tmp_inode->i_blocks, 221 (unsigned long long)tmp_inode->i_blocks));
222 tmp_inode->i_blksize));
223 if (S_ISREG(tmp_inode->i_mode)) { 222 if (S_ISREG(tmp_inode->i_mode)) {
224 cFYI(1, ("File inode")); 223 cFYI(1, ("File inode"));
225 tmp_inode->i_op = &cifs_file_inode_ops; 224 tmp_inode->i_op = &cifs_file_inode_ops;
diff --git a/fs/coda/coda_linux.c b/fs/coda/coda_linux.c
index 5597080cb811..95a54253c047 100644
--- a/fs/coda/coda_linux.c
+++ b/fs/coda/coda_linux.c
@@ -110,8 +110,6 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
110 inode->i_nlink = attr->va_nlink; 110 inode->i_nlink = attr->va_nlink;
111 if (attr->va_size != -1) 111 if (attr->va_size != -1)
112 inode->i_size = attr->va_size; 112 inode->i_size = attr->va_size;
113 if (attr->va_blocksize != -1)
114 inode->i_blksize = attr->va_blocksize;
115 if (attr->va_size != -1) 113 if (attr->va_size != -1)
116 inode->i_blocks = (attr->va_size + 511) >> 9; 114 inode->i_blocks = (attr->va_size + 511) >> 9;
117 if (attr->va_atime.tv_sec != -1) 115 if (attr->va_atime.tv_sec != -1)
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 71f2ea632e53..8651ea6a23b7 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -513,7 +513,7 @@ static int coda_venus_readdir(struct file *filp, filldir_t filldir,
513 ino_t ino; 513 ino_t ino;
514 int ret, i; 514 int ret, i;
515 515
516 vdir = (struct venus_dirent *)kmalloc(sizeof(*vdir), GFP_KERNEL); 516 vdir = kmalloc(sizeof(*vdir), GFP_KERNEL);
517 if (!vdir) return -ENOMEM; 517 if (!vdir) return -ENOMEM;
518 518
519 i = filp->f_pos; 519 i = filp->f_pos;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 87f1dc8aa24b..88d123321164 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -80,8 +80,7 @@ int coda_init_inodecache(void)
80 80
81void coda_destroy_inodecache(void) 81void coda_destroy_inodecache(void)
82{ 82{
83 if (kmem_cache_destroy(coda_inode_cachep)) 83 kmem_cache_destroy(coda_inode_cachep);
84 printk(KERN_INFO "coda_inode_cache: not all structures were freed\n");
85} 84}
86 85
87static int coda_remount(struct super_block *sb, int *flags, char *data) 86static int coda_remount(struct super_block *sb, int *flags, char *data)
diff --git a/fs/compat.c b/fs/compat.c
index e31e9cf96647..ce982f6e8c80 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1855,7 +1855,7 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1855 1855
1856 } while (!ret && !timeout && tsp && (ts.tv_sec || ts.tv_nsec)); 1856 } while (!ret && !timeout && tsp && (ts.tv_sec || ts.tv_nsec));
1857 1857
1858 if (tsp && !(current->personality & STICKY_TIMEOUTS)) { 1858 if (ret == 0 && tsp && !(current->personality & STICKY_TIMEOUTS)) {
1859 struct compat_timespec rts; 1859 struct compat_timespec rts;
1860 1860
1861 rts.tv_sec = timeout / HZ; 1861 rts.tv_sec = timeout / HZ;
@@ -1866,7 +1866,8 @@ asmlinkage long compat_sys_pselect7(int n, compat_ulong_t __user *inp,
1866 } 1866 }
1867 if (compat_timespec_compare(&rts, &ts) >= 0) 1867 if (compat_timespec_compare(&rts, &ts) >= 0)
1868 rts = ts; 1868 rts = ts;
1869 copy_to_user(tsp, &rts, sizeof(rts)); 1869 if (copy_to_user(tsp, &rts, sizeof(rts)))
1870 ret = -EFAULT;
1870 } 1871 }
1871 1872
1872 if (ret == -ERESTARTNOHAND) { 1873 if (ret == -ERESTARTNOHAND) {
diff --git a/fs/configfs/file.c b/fs/configfs/file.c
index f499803743e0..85105e50f7db 100644
--- a/fs/configfs/file.c
+++ b/fs/configfs/file.c
@@ -274,9 +274,8 @@ static int check_perm(struct inode * inode, struct file * file)
274 /* No error? Great, allocate a buffer for the file, and store it 274 /* No error? Great, allocate a buffer for the file, and store it
275 * it in file->private_data for easy access. 275 * it in file->private_data for easy access.
276 */ 276 */
277 buffer = kmalloc(sizeof(struct configfs_buffer),GFP_KERNEL); 277 buffer = kzalloc(sizeof(struct configfs_buffer),GFP_KERNEL);
278 if (buffer) { 278 if (buffer) {
279 memset(buffer,0,sizeof(struct configfs_buffer));
280 init_MUTEX(&buffer->sem); 279 init_MUTEX(&buffer->sem);
281 buffer->needs_read_fill = 1; 280 buffer->needs_read_fill = 1;
282 buffer->ops = ops; 281 buffer->ops = ops;
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index e14488ca6411..fb18917954a9 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -76,11 +76,10 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
76 76
77 if (!sd_iattr) { 77 if (!sd_iattr) {
78 /* setting attributes for the first time, allocate now */ 78 /* setting attributes for the first time, allocate now */
79 sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL); 79 sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL);
80 if (!sd_iattr) 80 if (!sd_iattr)
81 return -ENOMEM; 81 return -ENOMEM;
82 /* assign default attributes */ 82 /* assign default attributes */
83 memset(sd_iattr, 0, sizeof(struct iattr));
84 sd_iattr->ia_mode = sd->s_mode; 83 sd_iattr->ia_mode = sd->s_mode;
85 sd_iattr->ia_uid = 0; 84 sd_iattr->ia_uid = 0;
86 sd_iattr->ia_gid = 0; 85 sd_iattr->ia_gid = 0;
@@ -136,7 +135,6 @@ struct inode * configfs_new_inode(mode_t mode, struct configfs_dirent * sd)
136{ 135{
137 struct inode * inode = new_inode(configfs_sb); 136 struct inode * inode = new_inode(configfs_sb);
138 if (inode) { 137 if (inode) {
139 inode->i_blksize = PAGE_CACHE_SIZE;
140 inode->i_blocks = 0; 138 inode->i_blocks = 0;
141 inode->i_mapping->a_ops = &configfs_aops; 139 inode->i_mapping->a_ops = &configfs_aops;
142 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info; 140 inode->i_mapping->backing_dev_info = &configfs_backing_dev_info;
diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
index 223c0431042d..ad96b6990715 100644
--- a/fs/cramfs/inode.c
+++ b/fs/cramfs/inode.c
@@ -73,7 +73,6 @@ static int cramfs_iget5_set(struct inode *inode, void *opaque)
73 inode->i_uid = cramfs_inode->uid; 73 inode->i_uid = cramfs_inode->uid;
74 inode->i_size = cramfs_inode->size; 74 inode->i_size = cramfs_inode->size;
75 inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1; 75 inode->i_blocks = (cramfs_inode->size - 1) / 512 + 1;
76 inode->i_blksize = PAGE_CACHE_SIZE;
77 inode->i_gid = cramfs_inode->gid; 76 inode->i_gid = cramfs_inode->gid;
78 /* Struct copy intentional */ 77 /* Struct copy intentional */
79 inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime; 78 inode->i_mtime = inode->i_atime = inode->i_ctime = zerotime;
@@ -242,11 +241,10 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
242 241
243 sb->s_flags |= MS_RDONLY; 242 sb->s_flags |= MS_RDONLY;
244 243
245 sbi = kmalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL); 244 sbi = kzalloc(sizeof(struct cramfs_sb_info), GFP_KERNEL);
246 if (!sbi) 245 if (!sbi)
247 return -ENOMEM; 246 return -ENOMEM;
248 sb->s_fs_info = sbi; 247 sb->s_fs_info = sbi;
249 memset(sbi, 0, sizeof(struct cramfs_sb_info));
250 248
251 /* Invalidate the read buffers on mount: think disk change.. */ 249 /* Invalidate the read buffers on mount: think disk change.. */
252 mutex_lock(&read_mutex); 250 mutex_lock(&read_mutex);
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index 39640fd03458..bf3901ab1744 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -32,8 +32,8 @@ static ssize_t default_write_file(struct file *file, const char __user *buf,
32 32
33static int default_open(struct inode *inode, struct file *file) 33static int default_open(struct inode *inode, struct file *file)
34{ 34{
35 if (inode->u.generic_ip) 35 if (inode->i_private)
36 file->private_data = inode->u.generic_ip; 36 file->private_data = inode->i_private;
37 37
38 return 0; 38 return 0;
39} 39}
@@ -55,12 +55,11 @@ static u64 debugfs_u8_get(void *data)
55DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n"); 55DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
56 56
57/** 57/**
58 * debugfs_create_u8 - create a file in the debugfs filesystem that is used to read and write an unsigned 8 bit value. 58 * debugfs_create_u8 - create a debugfs file that is used to read and write an unsigned 8-bit value
59 *
60 * @name: a pointer to a string containing the name of the file to create. 59 * @name: a pointer to a string containing the name of the file to create.
61 * @mode: the permission that the file should have 60 * @mode: the permission that the file should have
62 * @parent: a pointer to the parent dentry for this file. This should be a 61 * @parent: a pointer to the parent dentry for this file. This should be a
63 * directory dentry if set. If this paramater is NULL, then the 62 * directory dentry if set. If this parameter is %NULL, then the
64 * file will be created in the root of the debugfs filesystem. 63 * file will be created in the root of the debugfs filesystem.
65 * @value: a pointer to the variable that the file should read to and write 64 * @value: a pointer to the variable that the file should read to and write
66 * from. 65 * from.
@@ -72,11 +71,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%llu\n");
72 * This function will return a pointer to a dentry if it succeeds. This 71 * This function will return a pointer to a dentry if it succeeds. This
73 * pointer must be passed to the debugfs_remove() function when the file is 72 * pointer must be passed to the debugfs_remove() function when the file is
74 * to be removed (no automatic cleanup happens if your module is unloaded, 73 * to be removed (no automatic cleanup happens if your module is unloaded,
75 * you are responsible here.) If an error occurs, NULL will be returned. 74 * you are responsible here.) If an error occurs, %NULL will be returned.
76 * 75 *
77 * If debugfs is not enabled in the kernel, the value -ENODEV will be 76 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
78 * returned. It is not wise to check for this value, but rather, check for 77 * returned. It is not wise to check for this value, but rather, check for
79 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 78 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
80 * code. 79 * code.
81 */ 80 */
82struct dentry *debugfs_create_u8(const char *name, mode_t mode, 81struct dentry *debugfs_create_u8(const char *name, mode_t mode,
@@ -97,12 +96,11 @@ static u64 debugfs_u16_get(void *data)
97DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n"); 96DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
98 97
99/** 98/**
100 * debugfs_create_u16 - create a file in the debugfs filesystem that is used to read and write an unsigned 16 bit value. 99 * debugfs_create_u16 - create a debugfs file that is used to read and write an unsigned 16-bit value
101 *
102 * @name: a pointer to a string containing the name of the file to create. 100 * @name: a pointer to a string containing the name of the file to create.
103 * @mode: the permission that the file should have 101 * @mode: the permission that the file should have
104 * @parent: a pointer to the parent dentry for this file. This should be a 102 * @parent: a pointer to the parent dentry for this file. This should be a
105 * directory dentry if set. If this paramater is NULL, then the 103 * directory dentry if set. If this parameter is %NULL, then the
106 * file will be created in the root of the debugfs filesystem. 104 * file will be created in the root of the debugfs filesystem.
107 * @value: a pointer to the variable that the file should read to and write 105 * @value: a pointer to the variable that the file should read to and write
108 * from. 106 * from.
@@ -114,11 +112,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u16, debugfs_u16_get, debugfs_u16_set, "%llu\n");
114 * This function will return a pointer to a dentry if it succeeds. This 112 * This function will return a pointer to a dentry if it succeeds. This
115 * pointer must be passed to the debugfs_remove() function when the file is 113 * pointer must be passed to the debugfs_remove() function when the file is
116 * to be removed (no automatic cleanup happens if your module is unloaded, 114 * to be removed (no automatic cleanup happens if your module is unloaded,
117 * you are responsible here.) If an error occurs, NULL will be returned. 115 * you are responsible here.) If an error occurs, %NULL will be returned.
118 * 116 *
119 * If debugfs is not enabled in the kernel, the value -ENODEV will be 117 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
120 * returned. It is not wise to check for this value, but rather, check for 118 * returned. It is not wise to check for this value, but rather, check for
121 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 119 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
122 * code. 120 * code.
123 */ 121 */
124struct dentry *debugfs_create_u16(const char *name, mode_t mode, 122struct dentry *debugfs_create_u16(const char *name, mode_t mode,
@@ -139,12 +137,11 @@ static u64 debugfs_u32_get(void *data)
139DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n"); 137DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
140 138
141/** 139/**
142 * debugfs_create_u32 - create a file in the debugfs filesystem that is used to read and write an unsigned 32 bit value. 140 * debugfs_create_u32 - create a debugfs file that is used to read and write an unsigned 32-bit value
143 *
144 * @name: a pointer to a string containing the name of the file to create. 141 * @name: a pointer to a string containing the name of the file to create.
145 * @mode: the permission that the file should have 142 * @mode: the permission that the file should have
146 * @parent: a pointer to the parent dentry for this file. This should be a 143 * @parent: a pointer to the parent dentry for this file. This should be a
147 * directory dentry if set. If this paramater is NULL, then the 144 * directory dentry if set. If this parameter is %NULL, then the
148 * file will be created in the root of the debugfs filesystem. 145 * file will be created in the root of the debugfs filesystem.
149 * @value: a pointer to the variable that the file should read to and write 146 * @value: a pointer to the variable that the file should read to and write
150 * from. 147 * from.
@@ -156,11 +153,11 @@ DEFINE_SIMPLE_ATTRIBUTE(fops_u32, debugfs_u32_get, debugfs_u32_set, "%llu\n");
156 * This function will return a pointer to a dentry if it succeeds. This 153 * This function will return a pointer to a dentry if it succeeds. This
157 * pointer must be passed to the debugfs_remove() function when the file is 154 * pointer must be passed to the debugfs_remove() function when the file is
158 * to be removed (no automatic cleanup happens if your module is unloaded, 155 * to be removed (no automatic cleanup happens if your module is unloaded,
159 * you are responsible here.) If an error occurs, NULL will be returned. 156 * you are responsible here.) If an error occurs, %NULL will be returned.
160 * 157 *
161 * If debugfs is not enabled in the kernel, the value -ENODEV will be 158 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
162 * returned. It is not wise to check for this value, but rather, check for 159 * returned. It is not wise to check for this value, but rather, check for
163 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 160 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
164 * code. 161 * code.
165 */ 162 */
166struct dentry *debugfs_create_u32(const char *name, mode_t mode, 163struct dentry *debugfs_create_u32(const char *name, mode_t mode,
@@ -219,12 +216,11 @@ static const struct file_operations fops_bool = {
219}; 216};
220 217
221/** 218/**
222 * debugfs_create_bool - create a file in the debugfs filesystem that is used to read and write a boolean value. 219 * debugfs_create_bool - create a debugfs file that is used to read and write a boolean value
223 *
224 * @name: a pointer to a string containing the name of the file to create. 220 * @name: a pointer to a string containing the name of the file to create.
225 * @mode: the permission that the file should have 221 * @mode: the permission that the file should have
226 * @parent: a pointer to the parent dentry for this file. This should be a 222 * @parent: a pointer to the parent dentry for this file. This should be a
227 * directory dentry if set. If this paramater is NULL, then the 223 * directory dentry if set. If this parameter is %NULL, then the
228 * file will be created in the root of the debugfs filesystem. 224 * file will be created in the root of the debugfs filesystem.
229 * @value: a pointer to the variable that the file should read to and write 225 * @value: a pointer to the variable that the file should read to and write
230 * from. 226 * from.
@@ -236,11 +232,11 @@ static const struct file_operations fops_bool = {
236 * This function will return a pointer to a dentry if it succeeds. This 232 * This function will return a pointer to a dentry if it succeeds. This
237 * pointer must be passed to the debugfs_remove() function when the file is 233 * pointer must be passed to the debugfs_remove() function when the file is
238 * to be removed (no automatic cleanup happens if your module is unloaded, 234 * to be removed (no automatic cleanup happens if your module is unloaded,
239 * you are responsible here.) If an error occurs, NULL will be returned. 235 * you are responsible here.) If an error occurs, %NULL will be returned.
240 * 236 *
241 * If debugfs is not enabled in the kernel, the value -ENODEV will be 237 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
242 * returned. It is not wise to check for this value, but rather, check for 238 * returned. It is not wise to check for this value, but rather, check for
243 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 239 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
244 * code. 240 * code.
245 */ 241 */
246struct dentry *debugfs_create_bool(const char *name, mode_t mode, 242struct dentry *debugfs_create_bool(const char *name, mode_t mode,
@@ -264,13 +260,11 @@ static struct file_operations fops_blob = {
264}; 260};
265 261
266/** 262/**
267 * debugfs_create_blob - create a file in the debugfs filesystem that is 263 * debugfs_create_blob - create a debugfs file that is used to read and write a binary blob
268 * used to read and write a binary blob.
269 *
270 * @name: a pointer to a string containing the name of the file to create. 264 * @name: a pointer to a string containing the name of the file to create.
271 * @mode: the permission that the file should have 265 * @mode: the permission that the file should have
272 * @parent: a pointer to the parent dentry for this file. This should be a 266 * @parent: a pointer to the parent dentry for this file. This should be a
273 * directory dentry if set. If this paramater is NULL, then the 267 * directory dentry if set. If this parameter is %NULL, then the
274 * file will be created in the root of the debugfs filesystem. 268 * file will be created in the root of the debugfs filesystem.
275 * @blob: a pointer to a struct debugfs_blob_wrapper which contains a pointer 269 * @blob: a pointer to a struct debugfs_blob_wrapper which contains a pointer
276 * to the blob data and the size of the data. 270 * to the blob data and the size of the data.
@@ -282,11 +276,11 @@ static struct file_operations fops_blob = {
282 * This function will return a pointer to a dentry if it succeeds. This 276 * This function will return a pointer to a dentry if it succeeds. This
283 * pointer must be passed to the debugfs_remove() function when the file is 277 * pointer must be passed to the debugfs_remove() function when the file is
284 * to be removed (no automatic cleanup happens if your module is unloaded, 278 * to be removed (no automatic cleanup happens if your module is unloaded,
285 * you are responsible here.) If an error occurs, NULL will be returned. 279 * you are responsible here.) If an error occurs, %NULL will be returned.
286 * 280 *
287 * If debugfs is not enabled in the kernel, the value -ENODEV will be 281 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
288 * returned. It is not wise to check for this value, but rather, check for 282 * returned. It is not wise to check for this value, but rather, check for
289 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 283 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
290 * code. 284 * code.
291 */ 285 */
292struct dentry *debugfs_create_blob(const char *name, mode_t mode, 286struct dentry *debugfs_create_blob(const char *name, mode_t mode,
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index e8ae3042b806..269e649e6dc6 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -40,7 +40,6 @@ static struct inode *debugfs_get_inode(struct super_block *sb, int mode, dev_t d
40 inode->i_mode = mode; 40 inode->i_mode = mode;
41 inode->i_uid = 0; 41 inode->i_uid = 0;
42 inode->i_gid = 0; 42 inode->i_gid = 0;
43 inode->i_blksize = PAGE_CACHE_SIZE;
44 inode->i_blocks = 0; 43 inode->i_blocks = 0;
45 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 44 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
46 switch (mode & S_IFMT) { 45 switch (mode & S_IFMT) {
@@ -162,14 +161,13 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
162 161
163/** 162/**
164 * debugfs_create_file - create a file in the debugfs filesystem 163 * debugfs_create_file - create a file in the debugfs filesystem
165 *
166 * @name: a pointer to a string containing the name of the file to create. 164 * @name: a pointer to a string containing the name of the file to create.
167 * @mode: the permission that the file should have 165 * @mode: the permission that the file should have
168 * @parent: a pointer to the parent dentry for this file. This should be a 166 * @parent: a pointer to the parent dentry for this file. This should be a
169 * directory dentry if set. If this paramater is NULL, then the 167 * directory dentry if set. If this paramater is NULL, then the
170 * file will be created in the root of the debugfs filesystem. 168 * file will be created in the root of the debugfs filesystem.
171 * @data: a pointer to something that the caller will want to get to later 169 * @data: a pointer to something that the caller will want to get to later
172 * on. The inode.u.generic_ip pointer will point to this value on 170 * on. The inode.i_private pointer will point to this value on
173 * the open() call. 171 * the open() call.
174 * @fops: a pointer to a struct file_operations that should be used for 172 * @fops: a pointer to a struct file_operations that should be used for
175 * this file. 173 * this file.
@@ -182,11 +180,11 @@ static int debugfs_create_by_name(const char *name, mode_t mode,
182 * This function will return a pointer to a dentry if it succeeds. This 180 * This function will return a pointer to a dentry if it succeeds. This
183 * pointer must be passed to the debugfs_remove() function when the file is 181 * pointer must be passed to the debugfs_remove() function when the file is
184 * to be removed (no automatic cleanup happens if your module is unloaded, 182 * to be removed (no automatic cleanup happens if your module is unloaded,
185 * you are responsible here.) If an error occurs, NULL will be returned. 183 * you are responsible here.) If an error occurs, %NULL will be returned.
186 * 184 *
187 * If debugfs is not enabled in the kernel, the value -ENODEV will be 185 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
188 * returned. It is not wise to check for this value, but rather, check for 186 * returned. It is not wise to check for this value, but rather, check for
189 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 187 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
190 * code. 188 * code.
191 */ 189 */
192struct dentry *debugfs_create_file(const char *name, mode_t mode, 190struct dentry *debugfs_create_file(const char *name, mode_t mode,
@@ -210,7 +208,7 @@ struct dentry *debugfs_create_file(const char *name, mode_t mode,
210 208
211 if (dentry->d_inode) { 209 if (dentry->d_inode) {
212 if (data) 210 if (data)
213 dentry->d_inode->u.generic_ip = data; 211 dentry->d_inode->i_private = data;
214 if (fops) 212 if (fops)
215 dentry->d_inode->i_fop = fops; 213 dentry->d_inode->i_fop = fops;
216 } 214 }
@@ -221,7 +219,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
221 219
222/** 220/**
223 * debugfs_create_dir - create a directory in the debugfs filesystem 221 * debugfs_create_dir - create a directory in the debugfs filesystem
224 *
225 * @name: a pointer to a string containing the name of the directory to 222 * @name: a pointer to a string containing the name of the directory to
226 * create. 223 * create.
227 * @parent: a pointer to the parent dentry for this file. This should be a 224 * @parent: a pointer to the parent dentry for this file. This should be a
@@ -233,11 +230,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
233 * This function will return a pointer to a dentry if it succeeds. This 230 * This function will return a pointer to a dentry if it succeeds. This
234 * pointer must be passed to the debugfs_remove() function when the file is 231 * pointer must be passed to the debugfs_remove() function when the file is
235 * to be removed (no automatic cleanup happens if your module is unloaded, 232 * to be removed (no automatic cleanup happens if your module is unloaded,
236 * you are responsible here.) If an error occurs, NULL will be returned. 233 * you are responsible here.) If an error occurs, %NULL will be returned.
237 * 234 *
238 * If debugfs is not enabled in the kernel, the value -ENODEV will be 235 * If debugfs is not enabled in the kernel, the value -%ENODEV will be
239 * returned. It is not wise to check for this value, but rather, check for 236 * returned. It is not wise to check for this value, but rather, check for
240 * NULL or !NULL instead as to eliminate the need for #ifdef in the calling 237 * %NULL or !%NULL instead as to eliminate the need for #ifdef in the calling
241 * code. 238 * code.
242 */ 239 */
243struct dentry *debugfs_create_dir(const char *name, struct dentry *parent) 240struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
@@ -250,7 +247,6 @@ EXPORT_SYMBOL_GPL(debugfs_create_dir);
250 247
251/** 248/**
252 * debugfs_remove - removes a file or directory from the debugfs filesystem 249 * debugfs_remove - removes a file or directory from the debugfs filesystem
253 *
254 * @dentry: a pointer to a the dentry of the file or directory to be 250 * @dentry: a pointer to a the dentry of the file or directory to be
255 * removed. 251 * removed.
256 * 252 *
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index f7aef5bb584a..5f7b5a6025bf 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -113,7 +113,6 @@ devpts_fill_super(struct super_block *s, void *data, int silent)
113 inode->i_ino = 1; 113 inode->i_ino = 1;
114 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 114 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
115 inode->i_blocks = 0; 115 inode->i_blocks = 0;
116 inode->i_blksize = 1024;
117 inode->i_uid = inode->i_gid = 0; 116 inode->i_uid = inode->i_gid = 0;
118 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR; 117 inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
119 inode->i_op = &simple_dir_inode_operations; 118 inode->i_op = &simple_dir_inode_operations;
@@ -172,12 +171,11 @@ int devpts_pty_new(struct tty_struct *tty)
172 return -ENOMEM; 171 return -ENOMEM;
173 172
174 inode->i_ino = number+2; 173 inode->i_ino = number+2;
175 inode->i_blksize = 1024;
176 inode->i_uid = config.setuid ? config.uid : current->fsuid; 174 inode->i_uid = config.setuid ? config.uid : current->fsuid;
177 inode->i_gid = config.setgid ? config.gid : current->fsgid; 175 inode->i_gid = config.setgid ? config.gid : current->fsgid;
178 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 176 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
179 init_special_inode(inode, S_IFCHR|config.mode, device); 177 init_special_inode(inode, S_IFCHR|config.mode, device);
180 inode->u.generic_ip = tty; 178 inode->i_private = tty;
181 179
182 dentry = get_node(number); 180 dentry = get_node(number);
183 if (!IS_ERR(dentry) && !dentry->d_inode) 181 if (!IS_ERR(dentry) && !dentry->d_inode)
@@ -196,7 +194,7 @@ struct tty_struct *devpts_get_tty(int number)
196 tty = NULL; 194 tty = NULL;
197 if (!IS_ERR(dentry)) { 195 if (!IS_ERR(dentry)) {
198 if (dentry->d_inode) 196 if (dentry->d_inode)
199 tty = dentry->d_inode->u.generic_ip; 197 tty = dentry->d_inode->i_private;
200 dput(dentry); 198 dput(dentry);
201 } 199 }
202 200
diff --git a/fs/efs/super.c b/fs/efs/super.c
index 8ac2462ae5dd..b3f50651eb6b 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -90,8 +90,7 @@ static int init_inodecache(void)
90 90
91static void destroy_inodecache(void) 91static void destroy_inodecache(void)
92{ 92{
93 if (kmem_cache_destroy(efs_inode_cachep)) 93 kmem_cache_destroy(efs_inode_cachep);
94 printk(KERN_INFO "efs_inode_cache: not all structures were freed\n");
95} 94}
96 95
97static void efs_put_super(struct super_block *s) 96static void efs_put_super(struct super_block *s)
@@ -248,11 +247,10 @@ static int efs_fill_super(struct super_block *s, void *d, int silent)
248 struct buffer_head *bh; 247 struct buffer_head *bh;
249 struct inode *root; 248 struct inode *root;
250 249
251 sb = kmalloc(sizeof(struct efs_sb_info), GFP_KERNEL); 250 sb = kzalloc(sizeof(struct efs_sb_info), GFP_KERNEL);
252 if (!sb) 251 if (!sb)
253 return -ENOMEM; 252 return -ENOMEM;
254 s->s_fs_info = sb; 253 s->s_fs_info = sb;
255 memset(sb, 0, sizeof(struct efs_sb_info));
256 254
257 s->s_magic = EFS_SUPER_MAGIC; 255 s->s_magic = EFS_SUPER_MAGIC;
258 if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) { 256 if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) {
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 3a3567433b92..8d544334bcd2 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -1590,7 +1590,6 @@ static struct inode *ep_eventpoll_inode(void)
1590 inode->i_uid = current->fsuid; 1590 inode->i_uid = current->fsuid;
1591 inode->i_gid = current->fsgid; 1591 inode->i_gid = current->fsgid;
1592 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1592 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1593 inode->i_blksize = PAGE_SIZE;
1594 return inode; 1593 return inode;
1595 1594
1596eexit_1: 1595eexit_1:
diff --git a/fs/exec.c b/fs/exec.c
index 54135df2a966..97df6e0aeaee 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -595,7 +595,7 @@ static int de_thread(struct task_struct *tsk)
595 if (!newsighand) 595 if (!newsighand)
596 return -ENOMEM; 596 return -ENOMEM;
597 597
598 if (thread_group_empty(current)) 598 if (thread_group_empty(tsk))
599 goto no_thread_group; 599 goto no_thread_group;
600 600
601 /* 601 /*
@@ -620,17 +620,17 @@ static int de_thread(struct task_struct *tsk)
620 * Reparenting needs write_lock on tasklist_lock, 620 * Reparenting needs write_lock on tasklist_lock,
621 * so it is safe to do it under read_lock. 621 * so it is safe to do it under read_lock.
622 */ 622 */
623 if (unlikely(current->group_leader == child_reaper)) 623 if (unlikely(tsk->group_leader == child_reaper))
624 child_reaper = current; 624 child_reaper = tsk;
625 625
626 zap_other_threads(current); 626 zap_other_threads(tsk);
627 read_unlock(&tasklist_lock); 627 read_unlock(&tasklist_lock);
628 628
629 /* 629 /*
630 * Account for the thread group leader hanging around: 630 * Account for the thread group leader hanging around:
631 */ 631 */
632 count = 1; 632 count = 1;
633 if (!thread_group_leader(current)) { 633 if (!thread_group_leader(tsk)) {
634 count = 2; 634 count = 2;
635 /* 635 /*
636 * The SIGALRM timer survives the exec, but needs to point 636 * The SIGALRM timer survives the exec, but needs to point
@@ -639,14 +639,14 @@ static int de_thread(struct task_struct *tsk)
639 * synchronize with any firing (by calling del_timer_sync) 639 * synchronize with any firing (by calling del_timer_sync)
640 * before we can safely let the old group leader die. 640 * before we can safely let the old group leader die.
641 */ 641 */
642 sig->tsk = current; 642 sig->tsk = tsk;
643 spin_unlock_irq(lock); 643 spin_unlock_irq(lock);
644 if (hrtimer_cancel(&sig->real_timer)) 644 if (hrtimer_cancel(&sig->real_timer))
645 hrtimer_restart(&sig->real_timer); 645 hrtimer_restart(&sig->real_timer);
646 spin_lock_irq(lock); 646 spin_lock_irq(lock);
647 } 647 }
648 while (atomic_read(&sig->count) > count) { 648 while (atomic_read(&sig->count) > count) {
649 sig->group_exit_task = current; 649 sig->group_exit_task = tsk;
650 sig->notify_count = count; 650 sig->notify_count = count;
651 __set_current_state(TASK_UNINTERRUPTIBLE); 651 __set_current_state(TASK_UNINTERRUPTIBLE);
652 spin_unlock_irq(lock); 652 spin_unlock_irq(lock);
@@ -662,13 +662,13 @@ static int de_thread(struct task_struct *tsk)
662 * do is to wait for the thread group leader to become inactive, 662 * do is to wait for the thread group leader to become inactive,
663 * and to assume its PID: 663 * and to assume its PID:
664 */ 664 */
665 if (!thread_group_leader(current)) { 665 if (!thread_group_leader(tsk)) {
666 /* 666 /*
667 * Wait for the thread group leader to be a zombie. 667 * Wait for the thread group leader to be a zombie.
668 * It should already be zombie at this point, most 668 * It should already be zombie at this point, most
669 * of the time. 669 * of the time.
670 */ 670 */
671 leader = current->group_leader; 671 leader = tsk->group_leader;
672 while (leader->exit_state != EXIT_ZOMBIE) 672 while (leader->exit_state != EXIT_ZOMBIE)
673 yield(); 673 yield();
674 674
@@ -682,12 +682,12 @@ static int de_thread(struct task_struct *tsk)
682 * When we take on its identity by switching to its PID, we 682 * When we take on its identity by switching to its PID, we
683 * also take its birthdate (always earlier than our own). 683 * also take its birthdate (always earlier than our own).
684 */ 684 */
685 current->start_time = leader->start_time; 685 tsk->start_time = leader->start_time;
686 686
687 write_lock_irq(&tasklist_lock); 687 write_lock_irq(&tasklist_lock);
688 688
689 BUG_ON(leader->tgid != current->tgid); 689 BUG_ON(leader->tgid != tsk->tgid);
690 BUG_ON(current->pid == current->tgid); 690 BUG_ON(tsk->pid == tsk->tgid);
691 /* 691 /*
692 * An exec() starts a new thread group with the 692 * An exec() starts a new thread group with the
693 * TGID of the previous thread group. Rehash the 693 * TGID of the previous thread group. Rehash the
@@ -696,24 +696,21 @@ static int de_thread(struct task_struct *tsk)
696 */ 696 */
697 697
698 /* Become a process group leader with the old leader's pid. 698 /* Become a process group leader with the old leader's pid.
699 * Note: The old leader also uses thispid until release_task 699 * The old leader becomes a thread of the this thread group.
700 * Note: The old leader also uses this pid until release_task
700 * is called. Odd but simple and correct. 701 * is called. Odd but simple and correct.
701 */ 702 */
702 detach_pid(current, PIDTYPE_PID); 703 detach_pid(tsk, PIDTYPE_PID);
703 current->pid = leader->pid; 704 tsk->pid = leader->pid;
704 attach_pid(current, PIDTYPE_PID, current->pid); 705 attach_pid(tsk, PIDTYPE_PID, tsk->pid);
705 attach_pid(current, PIDTYPE_PGID, current->signal->pgrp); 706 transfer_pid(leader, tsk, PIDTYPE_PGID);
706 attach_pid(current, PIDTYPE_SID, current->signal->session); 707 transfer_pid(leader, tsk, PIDTYPE_SID);
707 list_replace_rcu(&leader->tasks, &current->tasks); 708 list_replace_rcu(&leader->tasks, &tsk->tasks);
708 709
709 current->group_leader = current; 710 tsk->group_leader = tsk;
710 leader->group_leader = current; 711 leader->group_leader = tsk;
711 712
712 /* Reduce leader to a thread */ 713 tsk->exit_signal = SIGCHLD;
713 detach_pid(leader, PIDTYPE_PGID);
714 detach_pid(leader, PIDTYPE_SID);
715
716 current->exit_signal = SIGCHLD;
717 714
718 BUG_ON(leader->exit_state != EXIT_ZOMBIE); 715 BUG_ON(leader->exit_state != EXIT_ZOMBIE);
719 leader->exit_state = EXIT_DEAD; 716 leader->exit_state = EXIT_DEAD;
@@ -753,7 +750,7 @@ no_thread_group:
753 spin_lock(&oldsighand->siglock); 750 spin_lock(&oldsighand->siglock);
754 spin_lock_nested(&newsighand->siglock, SINGLE_DEPTH_NESTING); 751 spin_lock_nested(&newsighand->siglock, SINGLE_DEPTH_NESTING);
755 752
756 rcu_assign_pointer(current->sighand, newsighand); 753 rcu_assign_pointer(tsk->sighand, newsighand);
757 recalc_sigpending(); 754 recalc_sigpending();
758 755
759 spin_unlock(&newsighand->siglock); 756 spin_unlock(&newsighand->siglock);
@@ -764,7 +761,7 @@ no_thread_group:
764 kmem_cache_free(sighand_cachep, oldsighand); 761 kmem_cache_free(sighand_cachep, oldsighand);
765 } 762 }
766 763
767 BUG_ON(!thread_group_leader(current)); 764 BUG_ON(!thread_group_leader(tsk));
768 return 0; 765 return 0;
769} 766}
770 767
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index da52b4a5db64..7c420b800c34 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -89,8 +89,8 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size)
89 size_t n; 89 size_t n;
90 90
91 *size = ext2_acl_size(acl->a_count); 91 *size = ext2_acl_size(acl->a_count);
92 ext_acl = (ext2_acl_header *)kmalloc(sizeof(ext2_acl_header) + 92 ext_acl = kmalloc(sizeof(ext2_acl_header) + acl->a_count *
93 acl->a_count * sizeof(ext2_acl_entry), GFP_KERNEL); 93 sizeof(ext2_acl_entry), GFP_KERNEL);
94 if (!ext_acl) 94 if (!ext_acl)
95 return ERR_PTR(-ENOMEM); 95 return ERR_PTR(-ENOMEM);
96 ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION); 96 ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION);
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c
index 695f69ccf908..2cb545bf0f3c 100644
--- a/fs/ext2/ialloc.c
+++ b/fs/ext2/ialloc.c
@@ -574,7 +574,6 @@ got:
574 inode->i_mode = mode; 574 inode->i_mode = mode;
575 575
576 inode->i_ino = ino; 576 inode->i_ino = ino;
577 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */
578 inode->i_blocks = 0; 577 inode->i_blocks = 0;
579 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 578 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
580 memset(ei->i_data, 0, sizeof(ei->i_data)); 579 memset(ei->i_data, 0, sizeof(ei->i_data));
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index fb4d3220eb8d..dd4e14c221e0 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1094,7 +1094,6 @@ void ext2_read_inode (struct inode * inode)
1094 brelse (bh); 1094 brelse (bh);
1095 goto bad_inode; 1095 goto bad_inode;
1096 } 1096 }
1097 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */
1098 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); 1097 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
1099 ei->i_flags = le32_to_cpu(raw_inode->i_flags); 1098 ei->i_flags = le32_to_cpu(raw_inode->i_flags);
1100 ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); 1099 ei->i_faddr = le32_to_cpu(raw_inode->i_faddr);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 4286ff6330b6..513cd421ac0b 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -184,8 +184,7 @@ static int init_inodecache(void)
184 184
185static void destroy_inodecache(void) 185static void destroy_inodecache(void)
186{ 186{
187 if (kmem_cache_destroy(ext2_inode_cachep)) 187 kmem_cache_destroy(ext2_inode_cachep);
188 printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n");
189} 188}
190 189
191static void ext2_clear_inode(struct inode *inode) 190static void ext2_clear_inode(struct inode *inode)
@@ -544,17 +543,24 @@ static int ext2_check_descriptors (struct super_block * sb)
544 int i; 543 int i;
545 int desc_block = 0; 544 int desc_block = 0;
546 struct ext2_sb_info *sbi = EXT2_SB(sb); 545 struct ext2_sb_info *sbi = EXT2_SB(sb);
547 unsigned long block = le32_to_cpu(sbi->s_es->s_first_data_block); 546 unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
547 unsigned long last_block;
548 struct ext2_group_desc * gdp = NULL; 548 struct ext2_group_desc * gdp = NULL;
549 549
550 ext2_debug ("Checking group descriptors"); 550 ext2_debug ("Checking group descriptors");
551 551
552 for (i = 0; i < sbi->s_groups_count; i++) 552 for (i = 0; i < sbi->s_groups_count; i++)
553 { 553 {
554 if (i == sbi->s_groups_count - 1)
555 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
556 else
557 last_block = first_block +
558 (EXT2_BLOCKS_PER_GROUP(sb) - 1);
559
554 if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) 560 if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0)
555 gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; 561 gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data;
556 if (le32_to_cpu(gdp->bg_block_bitmap) < block || 562 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
557 le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) 563 le32_to_cpu(gdp->bg_block_bitmap) > last_block)
558 { 564 {
559 ext2_error (sb, "ext2_check_descriptors", 565 ext2_error (sb, "ext2_check_descriptors",
560 "Block bitmap for group %d" 566 "Block bitmap for group %d"
@@ -562,8 +568,8 @@ static int ext2_check_descriptors (struct super_block * sb)
562 i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); 568 i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
563 return 0; 569 return 0;
564 } 570 }
565 if (le32_to_cpu(gdp->bg_inode_bitmap) < block || 571 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
566 le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) 572 le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
567 { 573 {
568 ext2_error (sb, "ext2_check_descriptors", 574 ext2_error (sb, "ext2_check_descriptors",
569 "Inode bitmap for group %d" 575 "Inode bitmap for group %d"
@@ -571,9 +577,9 @@ static int ext2_check_descriptors (struct super_block * sb)
571 i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); 577 i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
572 return 0; 578 return 0;
573 } 579 }
574 if (le32_to_cpu(gdp->bg_inode_table) < block || 580 if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
575 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >= 581 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
576 block + EXT2_BLOCKS_PER_GROUP(sb)) 582 last_block)
577 { 583 {
578 ext2_error (sb, "ext2_check_descriptors", 584 ext2_error (sb, "ext2_check_descriptors",
579 "Inode table for group %d" 585 "Inode table for group %d"
@@ -581,7 +587,7 @@ static int ext2_check_descriptors (struct super_block * sb)
581 i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); 587 i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
582 return 0; 588 return 0;
583 } 589 }
584 block += EXT2_BLOCKS_PER_GROUP(sb); 590 first_block += EXT2_BLOCKS_PER_GROUP(sb);
585 gdp++; 591 gdp++;
586 } 592 }
587 return 1; 593 return 1;
@@ -648,11 +654,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
648 int i, j; 654 int i, j;
649 __le32 features; 655 __le32 features;
650 656
651 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 657 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
652 if (!sbi) 658 if (!sbi)
653 return -ENOMEM; 659 return -ENOMEM;
654 sb->s_fs_info = sbi; 660 sb->s_fs_info = sbi;
655 memset(sbi, 0, sizeof(*sbi));
656 661
657 /* 662 /*
658 * See what the current blocksize for the device is, and 663 * See what the current blocksize for the device is, and
@@ -861,10 +866,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
861 866
862 if (EXT2_BLOCKS_PER_GROUP(sb) == 0) 867 if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
863 goto cantfind_ext2; 868 goto cantfind_ext2;
864 sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - 869 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
865 le32_to_cpu(es->s_first_data_block) + 870 le32_to_cpu(es->s_first_data_block) - 1)
866 EXT2_BLOCKS_PER_GROUP(sb) - 1) / 871 / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
867 EXT2_BLOCKS_PER_GROUP(sb);
868 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / 872 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
869 EXT2_DESC_PER_BLOCK(sb); 873 EXT2_DESC_PER_BLOCK(sb);
870 sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); 874 sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 86ae8e93adb9..af52a7f8b291 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -521,11 +521,10 @@ bad_block: ext2_error(sb, "ext2_xattr_set",
521 } 521 }
522 } else { 522 } else {
523 /* Allocate a buffer where we construct the new block. */ 523 /* Allocate a buffer where we construct the new block. */
524 header = kmalloc(sb->s_blocksize, GFP_KERNEL); 524 header = kzalloc(sb->s_blocksize, GFP_KERNEL);
525 error = -ENOMEM; 525 error = -ENOMEM;
526 if (header == NULL) 526 if (header == NULL)
527 goto cleanup; 527 goto cleanup;
528 memset(header, 0, sb->s_blocksize);
529 end = (char *)header + sb->s_blocksize; 528 end = (char *)header + sb->s_blocksize;
530 header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC); 529 header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC);
531 header->h_blocks = header->h_refcount = cpu_to_le32(1); 530 header->h_blocks = header->h_refcount = cpu_to_le32(1);
diff --git a/fs/ext3/acl.c b/fs/ext3/acl.c
index 0d21d558b87a..1e5038d9a01b 100644
--- a/fs/ext3/acl.c
+++ b/fs/ext3/acl.c
@@ -90,8 +90,8 @@ ext3_acl_to_disk(const struct posix_acl *acl, size_t *size)
90 size_t n; 90 size_t n;
91 91
92 *size = ext3_acl_size(acl->a_count); 92 *size = ext3_acl_size(acl->a_count);
93 ext_acl = (ext3_acl_header *)kmalloc(sizeof(ext3_acl_header) + 93 ext_acl = kmalloc(sizeof(ext3_acl_header) + acl->a_count *
94 acl->a_count * sizeof(ext3_acl_entry), GFP_KERNEL); 94 sizeof(ext3_acl_entry), GFP_KERNEL);
95 if (!ext_acl) 95 if (!ext_acl)
96 return ERR_PTR(-ENOMEM); 96 return ERR_PTR(-ENOMEM);
97 ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION); 97 ext_acl->a_version = cpu_to_le32(EXT3_ACL_VERSION);
@@ -258,7 +258,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type,
258 default: 258 default:
259 return -EINVAL; 259 return -EINVAL;
260 } 260 }
261 if (acl) { 261 if (acl) {
262 value = ext3_acl_to_disk(acl, &size); 262 value = ext3_acl_to_disk(acl, &size);
263 if (IS_ERR(value)) 263 if (IS_ERR(value))
264 return (int)PTR_ERR(value); 264 return (int)PTR_ERR(value);
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 063d994bda0b..b41a7d7e20f0 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -38,6 +38,13 @@
38 38
39#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1) 39#define in_range(b, first, len) ((b) >= (first) && (b) <= (first) + (len) - 1)
40 40
41/**
42 * ext3_get_group_desc() -- load group descriptor from disk
43 * @sb: super block
44 * @block_group: given block group
45 * @bh: pointer to the buffer head to store the block
46 * group descriptor
47 */
41struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb, 48struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
42 unsigned int block_group, 49 unsigned int block_group,
43 struct buffer_head ** bh) 50 struct buffer_head ** bh)
@@ -73,8 +80,12 @@ struct ext3_group_desc * ext3_get_group_desc(struct super_block * sb,
73 return desc + offset; 80 return desc + offset;
74} 81}
75 82
76/* 83/**
77 * Read the bitmap for a given block_group, reading into the specified 84 * read_block_bitmap()
85 * @sb: super block
86 * @block_group: given block group
87 *
88 * Read the bitmap for a given block_group, reading into the specified
78 * slot in the superblock's bitmap cache. 89 * slot in the superblock's bitmap cache.
79 * 90 *
80 * Return buffer_head on success or NULL in case of failure. 91 * Return buffer_head on success or NULL in case of failure.
@@ -103,15 +114,22 @@ error_out:
103 * Operations include: 114 * Operations include:
104 * dump, find, add, remove, is_empty, find_next_reservable_window, etc. 115 * dump, find, add, remove, is_empty, find_next_reservable_window, etc.
105 * 116 *
106 * We use sorted double linked list for the per-filesystem reservation 117 * We use a red-black tree to represent per-filesystem reservation
107 * window list. (like in vm_region). 118 * windows.
119 *
120 */
121
122/**
123 * __rsv_window_dump() -- Dump the filesystem block allocation reservation map
124 * @rb_root: root of per-filesystem reservation rb tree
125 * @verbose: verbose mode
126 * @fn: function which wishes to dump the reservation map
108 * 127 *
109 * Initially, we keep those small operations in the abstract functions, 128 * If verbose is turned on, it will print the whole block reservation
110 * so later if we need a better searching tree than double linked-list, 129 * windows(start, end). Otherwise, it will only print out the "bad" windows,
111 * we could easily switch to that without changing too much 130 * those windows that overlap with their immediate neighbors.
112 * code.
113 */ 131 */
114#if 0 132#if 1
115static void __rsv_window_dump(struct rb_root *root, int verbose, 133static void __rsv_window_dump(struct rb_root *root, int verbose,
116 const char *fn) 134 const char *fn)
117{ 135{
@@ -129,7 +147,7 @@ restart:
129 rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node); 147 rsv = list_entry(n, struct ext3_reserve_window_node, rsv_node);
130 if (verbose) 148 if (verbose)
131 printk("reservation window 0x%p " 149 printk("reservation window 0x%p "
132 "start: %d, end: %d\n", 150 "start: %lu, end: %lu\n",
133 rsv, rsv->rsv_start, rsv->rsv_end); 151 rsv, rsv->rsv_start, rsv->rsv_end);
134 if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) { 152 if (rsv->rsv_start && rsv->rsv_start >= rsv->rsv_end) {
135 printk("Bad reservation %p (start >= end)\n", 153 printk("Bad reservation %p (start >= end)\n",
@@ -161,6 +179,22 @@ restart:
161#define rsv_window_dump(root, verbose) do {} while (0) 179#define rsv_window_dump(root, verbose) do {} while (0)
162#endif 180#endif
163 181
182/**
183 * goal_in_my_reservation()
184 * @rsv: inode's reservation window
185 * @grp_goal: given goal block relative to the allocation block group
186 * @group: the current allocation block group
187 * @sb: filesystem super block
188 *
189 * Test if the given goal block (group relative) is within the file's
190 * own block reservation window range.
191 *
192 * If the reservation window is outside the goal allocation group, return 0;
193 * grp_goal (given goal block) could be -1, which means no specific
194 * goal block. In this case, always return 1.
195 * If the goal block is within the reservation window, return 1;
196 * otherwise, return 0;
197 */
164static int 198static int
165goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal, 199goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal,
166 unsigned int group, struct super_block * sb) 200 unsigned int group, struct super_block * sb)
@@ -168,7 +202,7 @@ goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal,
168 ext3_fsblk_t group_first_block, group_last_block; 202 ext3_fsblk_t group_first_block, group_last_block;
169 203
170 group_first_block = ext3_group_first_block_no(sb, group); 204 group_first_block = ext3_group_first_block_no(sb, group);
171 group_last_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; 205 group_last_block = group_first_block + (EXT3_BLOCKS_PER_GROUP(sb) - 1);
172 206
173 if ((rsv->_rsv_start > group_last_block) || 207 if ((rsv->_rsv_start > group_last_block) ||
174 (rsv->_rsv_end < group_first_block)) 208 (rsv->_rsv_end < group_first_block))
@@ -179,7 +213,11 @@ goal_in_my_reservation(struct ext3_reserve_window *rsv, ext3_grpblk_t grp_goal,
179 return 1; 213 return 1;
180} 214}
181 215
182/* 216/**
217 * search_reserve_window()
218 * @rb_root: root of reservation tree
219 * @goal: target allocation block
220 *
183 * Find the reserved window which includes the goal, or the previous one 221 * Find the reserved window which includes the goal, or the previous one
184 * if the goal is not in any window. 222 * if the goal is not in any window.
185 * Returns NULL if there are no windows or if all windows start after the goal. 223 * Returns NULL if there are no windows or if all windows start after the goal.
@@ -216,6 +254,13 @@ search_reserve_window(struct rb_root *root, ext3_fsblk_t goal)
216 return rsv; 254 return rsv;
217} 255}
218 256
257/**
258 * ext3_rsv_window_add() -- Insert a window to the block reservation rb tree.
259 * @sb: super block
260 * @rsv: reservation window to add
261 *
262 * Must be called with rsv_lock hold.
263 */
219void ext3_rsv_window_add(struct super_block *sb, 264void ext3_rsv_window_add(struct super_block *sb,
220 struct ext3_reserve_window_node *rsv) 265 struct ext3_reserve_window_node *rsv)
221{ 266{
@@ -236,14 +281,25 @@ void ext3_rsv_window_add(struct super_block *sb,
236 p = &(*p)->rb_left; 281 p = &(*p)->rb_left;
237 else if (start > this->rsv_end) 282 else if (start > this->rsv_end)
238 p = &(*p)->rb_right; 283 p = &(*p)->rb_right;
239 else 284 else {
285 rsv_window_dump(root, 1);
240 BUG(); 286 BUG();
287 }
241 } 288 }
242 289
243 rb_link_node(node, parent, p); 290 rb_link_node(node, parent, p);
244 rb_insert_color(node, root); 291 rb_insert_color(node, root);
245} 292}
246 293
294/**
295 * ext3_rsv_window_remove() -- unlink a window from the reservation rb tree
296 * @sb: super block
297 * @rsv: reservation window to remove
298 *
299 * Mark the block reservation window as not allocated, and unlink it
300 * from the filesystem reservation window rb tree. Must be called with
301 * rsv_lock hold.
302 */
247static void rsv_window_remove(struct super_block *sb, 303static void rsv_window_remove(struct super_block *sb,
248 struct ext3_reserve_window_node *rsv) 304 struct ext3_reserve_window_node *rsv)
249{ 305{
@@ -253,11 +309,39 @@ static void rsv_window_remove(struct super_block *sb,
253 rb_erase(&rsv->rsv_node, &EXT3_SB(sb)->s_rsv_window_root); 309 rb_erase(&rsv->rsv_node, &EXT3_SB(sb)->s_rsv_window_root);
254} 310}
255 311
312/*
313 * rsv_is_empty() -- Check if the reservation window is allocated.
314 * @rsv: given reservation window to check
315 *
316 * returns 1 if the end block is EXT3_RESERVE_WINDOW_NOT_ALLOCATED.
317 */
256static inline int rsv_is_empty(struct ext3_reserve_window *rsv) 318static inline int rsv_is_empty(struct ext3_reserve_window *rsv)
257{ 319{
258 /* a valid reservation end block could not be 0 */ 320 /* a valid reservation end block could not be 0 */
259 return (rsv->_rsv_end == EXT3_RESERVE_WINDOW_NOT_ALLOCATED); 321 return rsv->_rsv_end == EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
260} 322}
323
324/**
325 * ext3_init_block_alloc_info()
326 * @inode: file inode structure
327 *
328 * Allocate and initialize the reservation window structure, and
329 * link the window to the ext3 inode structure at last
330 *
331 * The reservation window structure is only dynamically allocated
332 * and linked to ext3 inode the first time the open file
333 * needs a new block. So, before every ext3_new_block(s) call, for
334 * regular files, we should check whether the reservation window
335 * structure exists or not. In the latter case, this function is called.
336 * Fail to do so will result in block reservation being turned off for that
337 * open file.
338 *
339 * This function is called from ext3_get_blocks_handle(), also called
340 * when setting the reservation window size through ioctl before the file
341 * is open for write (needs block allocation).
342 *
343 * Needs truncate_mutex protection prior to call this function.
344 */
261void ext3_init_block_alloc_info(struct inode *inode) 345void ext3_init_block_alloc_info(struct inode *inode)
262{ 346{
263 struct ext3_inode_info *ei = EXT3_I(inode); 347 struct ext3_inode_info *ei = EXT3_I(inode);
@@ -271,7 +355,7 @@ void ext3_init_block_alloc_info(struct inode *inode)
271 rsv->rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED; 355 rsv->rsv_start = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
272 rsv->rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED; 356 rsv->rsv_end = EXT3_RESERVE_WINDOW_NOT_ALLOCATED;
273 357
274 /* 358 /*
275 * if filesystem is mounted with NORESERVATION, the goal 359 * if filesystem is mounted with NORESERVATION, the goal
276 * reservation window size is set to zero to indicate 360 * reservation window size is set to zero to indicate
277 * block reservation is off 361 * block reservation is off
@@ -287,6 +371,19 @@ void ext3_init_block_alloc_info(struct inode *inode)
287 ei->i_block_alloc_info = block_i; 371 ei->i_block_alloc_info = block_i;
288} 372}
289 373
374/**
375 * ext3_discard_reservation()
376 * @inode: inode
377 *
378 * Discard(free) block reservation window on last file close, or truncate
379 * or at last iput().
380 *
381 * It is being called in three cases:
382 * ext3_release_file(): last writer close the file
383 * ext3_clear_inode(): last iput(), when nobody link to this file.
384 * ext3_truncate(): when the block indirect map is about to change.
385 *
386 */
290void ext3_discard_reservation(struct inode *inode) 387void ext3_discard_reservation(struct inode *inode)
291{ 388{
292 struct ext3_inode_info *ei = EXT3_I(inode); 389 struct ext3_inode_info *ei = EXT3_I(inode);
@@ -306,7 +403,14 @@ void ext3_discard_reservation(struct inode *inode)
306 } 403 }
307} 404}
308 405
309/* Free given blocks, update quota and i_blocks field */ 406/**
407 * ext3_free_blocks_sb() -- Free given blocks and update quota
408 * @handle: handle to this transaction
409 * @sb: super block
410 * @block: start physcial block to free
411 * @count: number of blocks to free
412 * @pdquot_freed_blocks: pointer to quota
413 */
310void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb, 414void ext3_free_blocks_sb(handle_t *handle, struct super_block *sb,
311 ext3_fsblk_t block, unsigned long count, 415 ext3_fsblk_t block, unsigned long count,
312 unsigned long *pdquot_freed_blocks) 416 unsigned long *pdquot_freed_blocks)
@@ -419,8 +523,8 @@ do_more:
419 } 523 }
420 /* @@@ This prevents newly-allocated data from being 524 /* @@@ This prevents newly-allocated data from being
421 * freed and then reallocated within the same 525 * freed and then reallocated within the same
422 * transaction. 526 * transaction.
423 * 527 *
424 * Ideally we would want to allow that to happen, but to 528 * Ideally we would want to allow that to happen, but to
425 * do so requires making journal_forget() capable of 529 * do so requires making journal_forget() capable of
426 * revoking the queued write of a data block, which 530 * revoking the queued write of a data block, which
@@ -433,7 +537,7 @@ do_more:
433 * safe not to set the allocation bit in the committed 537 * safe not to set the allocation bit in the committed
434 * bitmap, because we know that there is no outstanding 538 * bitmap, because we know that there is no outstanding
435 * activity on the buffer any more and so it is safe to 539 * activity on the buffer any more and so it is safe to
436 * reallocate it. 540 * reallocate it.
437 */ 541 */
438 BUFFER_TRACE(bitmap_bh, "set in b_committed_data"); 542 BUFFER_TRACE(bitmap_bh, "set in b_committed_data");
439 J_ASSERT_BH(bitmap_bh, 543 J_ASSERT_BH(bitmap_bh,
@@ -490,7 +594,13 @@ error_return:
490 return; 594 return;
491} 595}
492 596
493/* Free given blocks, update quota and i_blocks field */ 597/**
598 * ext3_free_blocks() -- Free given blocks and update quota
599 * @handle: handle for this transaction
600 * @inode: inode
601 * @block: start physical block to free
602 * @count: number of blocks to count
603 */
494void ext3_free_blocks(handle_t *handle, struct inode *inode, 604void ext3_free_blocks(handle_t *handle, struct inode *inode,
495 ext3_fsblk_t block, unsigned long count) 605 ext3_fsblk_t block, unsigned long count)
496{ 606{
@@ -508,7 +618,11 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
508 return; 618 return;
509} 619}
510 620
511/* 621/**
622 * ext3_test_allocatable()
623 * @nr: given allocation block group
624 * @bh: bufferhead contains the bitmap of the given block group
625 *
512 * For ext3 allocations, we must not reuse any blocks which are 626 * For ext3 allocations, we must not reuse any blocks which are
513 * allocated in the bitmap buffer's "last committed data" copy. This 627 * allocated in the bitmap buffer's "last committed data" copy. This
514 * prevents deletes from freeing up the page for reuse until we have 628 * prevents deletes from freeing up the page for reuse until we have
@@ -518,7 +632,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode,
518 * data would allow the old block to be overwritten before the 632 * data would allow the old block to be overwritten before the
519 * transaction committed (because we force data to disk before commit). 633 * transaction committed (because we force data to disk before commit).
520 * This would lead to corruption if we crashed between overwriting the 634 * This would lead to corruption if we crashed between overwriting the
521 * data and committing the delete. 635 * data and committing the delete.
522 * 636 *
523 * @@@ We may want to make this allocation behaviour conditional on 637 * @@@ We may want to make this allocation behaviour conditional on
524 * data-writes at some point, and disable it for metadata allocations or 638 * data-writes at some point, and disable it for metadata allocations or
@@ -541,6 +655,16 @@ static int ext3_test_allocatable(ext3_grpblk_t nr, struct buffer_head *bh)
541 return ret; 655 return ret;
542} 656}
543 657
658/**
659 * bitmap_search_next_usable_block()
660 * @start: the starting block (group relative) of the search
661 * @bh: bufferhead contains the block group bitmap
662 * @maxblocks: the ending block (group relative) of the reservation
663 *
664 * The bitmap search --- search forward alternately through the actual
665 * bitmap on disk and the last-committed copy in journal, until we find a
666 * bit free in both bitmaps.
667 */
544static ext3_grpblk_t 668static ext3_grpblk_t
545bitmap_search_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh, 669bitmap_search_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
546 ext3_grpblk_t maxblocks) 670 ext3_grpblk_t maxblocks)
@@ -548,11 +672,6 @@ bitmap_search_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
548 ext3_grpblk_t next; 672 ext3_grpblk_t next;
549 struct journal_head *jh = bh2jh(bh); 673 struct journal_head *jh = bh2jh(bh);
550 674
551 /*
552 * The bitmap search --- search forward alternately through the actual
553 * bitmap and the last-committed copy until we find a bit free in
554 * both
555 */
556 while (start < maxblocks) { 675 while (start < maxblocks) {
557 next = ext3_find_next_zero_bit(bh->b_data, maxblocks, start); 676 next = ext3_find_next_zero_bit(bh->b_data, maxblocks, start);
558 if (next >= maxblocks) 677 if (next >= maxblocks)
@@ -562,14 +681,20 @@ bitmap_search_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
562 jbd_lock_bh_state(bh); 681 jbd_lock_bh_state(bh);
563 if (jh->b_committed_data) 682 if (jh->b_committed_data)
564 start = ext3_find_next_zero_bit(jh->b_committed_data, 683 start = ext3_find_next_zero_bit(jh->b_committed_data,
565 maxblocks, next); 684 maxblocks, next);
566 jbd_unlock_bh_state(bh); 685 jbd_unlock_bh_state(bh);
567 } 686 }
568 return -1; 687 return -1;
569} 688}
570 689
571/* 690/**
572 * Find an allocatable block in a bitmap. We honour both the bitmap and 691 * find_next_usable_block()
692 * @start: the starting block (group relative) to find next
693 * allocatable block in bitmap.
694 * @bh: bufferhead contains the block group bitmap
695 * @maxblocks: the ending block (group relative) for the search
696 *
697 * Find an allocatable block in a bitmap. We honor both the bitmap and
573 * its last-committed copy (if that exists), and perform the "most 698 * its last-committed copy (if that exists), and perform the "most
574 * appropriate allocation" algorithm of looking for a free block near 699 * appropriate allocation" algorithm of looking for a free block near
575 * the initial goal; then for a free byte somewhere in the bitmap; then 700 * the initial goal; then for a free byte somewhere in the bitmap; then
@@ -584,7 +709,7 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
584 709
585 if (start > 0) { 710 if (start > 0) {
586 /* 711 /*
587 * The goal was occupied; search forward for a free 712 * The goal was occupied; search forward for a free
588 * block within the next XX blocks. 713 * block within the next XX blocks.
589 * 714 *
590 * end_goal is more or less random, but it has to be 715 * end_goal is more or less random, but it has to be
@@ -620,7 +745,11 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
620 return here; 745 return here;
621} 746}
622 747
623/* 748/**
749 * claim_block()
750 * @block: the free block (group relative) to allocate
751 * @bh: the bufferhead containts the block group bitmap
752 *
624 * We think we can allocate this block in this bitmap. Try to set the bit. 753 * We think we can allocate this block in this bitmap. Try to set the bit.
625 * If that succeeds then check that nobody has allocated and then freed the 754 * If that succeeds then check that nobody has allocated and then freed the
626 * block since we saw that is was not marked in b_committed_data. If it _was_ 755 * block since we saw that is was not marked in b_committed_data. If it _was_
@@ -646,7 +775,26 @@ claim_block(spinlock_t *lock, ext3_grpblk_t block, struct buffer_head *bh)
646 return ret; 775 return ret;
647} 776}
648 777
649/* 778/**
779 * ext3_try_to_allocate()
780 * @sb: superblock
781 * @handle: handle to this transaction
782 * @group: given allocation block group
783 * @bitmap_bh: bufferhead holds the block bitmap
784 * @grp_goal: given target block within the group
785 * @count: target number of blocks to allocate
786 * @my_rsv: reservation window
787 *
788 * Attempt to allocate blocks within a give range. Set the range of allocation
789 * first, then find the first free bit(s) from the bitmap (within the range),
790 * and at last, allocate the blocks by claiming the found free bit as allocated.
791 *
792 * To set the range of this allocation:
793 * if there is a reservation window, only try to allocate block(s) from the
794 * file's own reservation window;
795 * Otherwise, the allocation range starts from the give goal block, ends at
796 * the block group's last block.
797 *
650 * If we failed to allocate the desired block then we may end up crossing to a 798 * If we failed to allocate the desired block then we may end up crossing to a
651 * new bitmap. In that case we must release write access to the old one via 799 * new bitmap. In that case we must release write access to the old one via
652 * ext3_journal_release_buffer(), else we'll run out of credits. 800 * ext3_journal_release_buffer(), else we'll run out of credits.
@@ -703,7 +851,8 @@ repeat:
703 } 851 }
704 start = grp_goal; 852 start = grp_goal;
705 853
706 if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) { 854 if (!claim_block(sb_bgl_lock(EXT3_SB(sb), group),
855 grp_goal, bitmap_bh)) {
707 /* 856 /*
708 * The block was allocated by another thread, or it was 857 * The block was allocated by another thread, or it was
709 * allocated and then freed by another thread 858 * allocated and then freed by another thread
@@ -718,7 +867,8 @@ repeat:
718 grp_goal++; 867 grp_goal++;
719 while (num < *count && grp_goal < end 868 while (num < *count && grp_goal < end
720 && ext3_test_allocatable(grp_goal, bitmap_bh) 869 && ext3_test_allocatable(grp_goal, bitmap_bh)
721 && claim_block(sb_bgl_lock(EXT3_SB(sb), group), grp_goal, bitmap_bh)) { 870 && claim_block(sb_bgl_lock(EXT3_SB(sb), group),
871 grp_goal, bitmap_bh)) {
722 num++; 872 num++;
723 grp_goal++; 873 grp_goal++;
724 } 874 }
@@ -730,12 +880,12 @@ fail_access:
730} 880}
731 881
732/** 882/**
733 * find_next_reservable_window(): 883 * find_next_reservable_window():
734 * find a reservable space within the given range. 884 * find a reservable space within the given range.
735 * It does not allocate the reservation window for now: 885 * It does not allocate the reservation window for now:
736 * alloc_new_reservation() will do the work later. 886 * alloc_new_reservation() will do the work later.
737 * 887 *
738 * @search_head: the head of the searching list; 888 * @search_head: the head of the searching list;
739 * This is not necessarily the list head of the whole filesystem 889 * This is not necessarily the list head of the whole filesystem
740 * 890 *
741 * We have both head and start_block to assist the search 891 * We have both head and start_block to assist the search
@@ -743,12 +893,12 @@ fail_access:
743 * but we will shift to the place where start_block is, 893 * but we will shift to the place where start_block is,
744 * then start from there, when looking for a reservable space. 894 * then start from there, when looking for a reservable space.
745 * 895 *
746 * @size: the target new reservation window size 896 * @size: the target new reservation window size
747 * 897 *
748 * @group_first_block: the first block we consider to start 898 * @group_first_block: the first block we consider to start
749 * the real search from 899 * the real search from
750 * 900 *
751 * @last_block: 901 * @last_block:
752 * the maximum block number that our goal reservable space 902 * the maximum block number that our goal reservable space
753 * could start from. This is normally the last block in this 903 * could start from. This is normally the last block in this
754 * group. The search will end when we found the start of next 904 * group. The search will end when we found the start of next
@@ -756,10 +906,10 @@ fail_access:
756 * This could handle the cross boundary reservation window 906 * This could handle the cross boundary reservation window
757 * request. 907 * request.
758 * 908 *
759 * basically we search from the given range, rather than the whole 909 * basically we search from the given range, rather than the whole
760 * reservation double linked list, (start_block, last_block) 910 * reservation double linked list, (start_block, last_block)
761 * to find a free region that is of my size and has not 911 * to find a free region that is of my size and has not
762 * been reserved. 912 * been reserved.
763 * 913 *
764 */ 914 */
765static int find_next_reservable_window( 915static int find_next_reservable_window(
@@ -812,7 +962,7 @@ static int find_next_reservable_window(
812 /* 962 /*
813 * Found a reserveable space big enough. We could 963 * Found a reserveable space big enough. We could
814 * have a reservation across the group boundary here 964 * have a reservation across the group boundary here
815 */ 965 */
816 break; 966 break;
817 } 967 }
818 } 968 }
@@ -848,7 +998,7 @@ static int find_next_reservable_window(
848} 998}
849 999
850/** 1000/**
851 * alloc_new_reservation()--allocate a new reservation window 1001 * alloc_new_reservation()--allocate a new reservation window
852 * 1002 *
853 * To make a new reservation, we search part of the filesystem 1003 * To make a new reservation, we search part of the filesystem
854 * reservation list (the list that inside the group). We try to 1004 * reservation list (the list that inside the group). We try to
@@ -897,7 +1047,7 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
897 spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock; 1047 spinlock_t *rsv_lock = &EXT3_SB(sb)->s_rsv_window_lock;
898 1048
899 group_first_block = ext3_group_first_block_no(sb, group); 1049 group_first_block = ext3_group_first_block_no(sb, group);
900 group_end_block = group_first_block + EXT3_BLOCKS_PER_GROUP(sb) - 1; 1050 group_end_block = group_first_block + (EXT3_BLOCKS_PER_GROUP(sb) - 1);
901 1051
902 if (grp_goal < 0) 1052 if (grp_goal < 0)
903 start_block = group_first_block; 1053 start_block = group_first_block;
@@ -929,9 +1079,10 @@ static int alloc_new_reservation(struct ext3_reserve_window_node *my_rsv,
929 if ((my_rsv->rsv_alloc_hit > 1079 if ((my_rsv->rsv_alloc_hit >
930 (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) { 1080 (my_rsv->rsv_end - my_rsv->rsv_start + 1) / 2)) {
931 /* 1081 /*
932 * if we previously allocation hit ration is greater than half 1082 * if the previously allocation hit ratio is
933 * we double the size of reservation window next time 1083 * greater than 1/2, then we double the size of
934 * otherwise keep the same 1084 * the reservation window the next time,
1085 * otherwise we keep the same size window
935 */ 1086 */
936 size = size * 2; 1087 size = size * 2;
937 if (size > EXT3_MAX_RESERVE_BLOCKS) 1088 if (size > EXT3_MAX_RESERVE_BLOCKS)
@@ -1010,6 +1161,23 @@ retry:
1010 goto retry; 1161 goto retry;
1011} 1162}
1012 1163
1164/**
1165 * try_to_extend_reservation()
1166 * @my_rsv: given reservation window
1167 * @sb: super block
1168 * @size: the delta to extend
1169 *
1170 * Attempt to expand the reservation window large enough to have
1171 * required number of free blocks
1172 *
1173 * Since ext3_try_to_allocate() will always allocate blocks within
1174 * the reservation window range, if the window size is too small,
1175 * multiple blocks allocation has to stop at the end of the reservation
1176 * window. To make this more efficient, given the total number of
1177 * blocks needed and the current size of the window, we try to
1178 * expand the reservation window size if necessary on a best-effort
1179 * basis before ext3_new_blocks() tries to allocate blocks,
1180 */
1013static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv, 1181static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1014 struct super_block *sb, int size) 1182 struct super_block *sb, int size)
1015{ 1183{
@@ -1035,7 +1203,17 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1035 spin_unlock(rsv_lock); 1203 spin_unlock(rsv_lock);
1036} 1204}
1037 1205
1038/* 1206/**
1207 * ext3_try_to_allocate_with_rsv()
1208 * @sb: superblock
1209 * @handle: handle to this transaction
1210 * @group: given allocation block group
1211 * @bitmap_bh: bufferhead holds the block bitmap
1212 * @grp_goal: given target block within the group
1213 * @count: target number of blocks to allocate
1214 * @my_rsv: reservation window
1215 * @errp: pointer to store the error code
1216 *
1039 * This is the main function used to allocate a new block and its reservation 1217 * This is the main function used to allocate a new block and its reservation
1040 * window. 1218 * window.
1041 * 1219 *
@@ -1051,9 +1229,7 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1051 * reservation), and there are lots of free blocks, but they are all 1229 * reservation), and there are lots of free blocks, but they are all
1052 * being reserved. 1230 * being reserved.
1053 * 1231 *
1054 * We use a sorted double linked list for the per-filesystem reservation list. 1232 * We use a red-black tree for the per-filesystem reservation list.
1055 * The insert, remove and find a free space(non-reserved) operations for the
1056 * sorted double linked list should be fast.
1057 * 1233 *
1058 */ 1234 */
1059static ext3_grpblk_t 1235static ext3_grpblk_t
@@ -1063,7 +1239,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1063 struct ext3_reserve_window_node * my_rsv, 1239 struct ext3_reserve_window_node * my_rsv,
1064 unsigned long *count, int *errp) 1240 unsigned long *count, int *errp)
1065{ 1241{
1066 ext3_fsblk_t group_first_block; 1242 ext3_fsblk_t group_first_block, group_last_block;
1067 ext3_grpblk_t ret = 0; 1243 ext3_grpblk_t ret = 0;
1068 int fatal; 1244 int fatal;
1069 unsigned long num = *count; 1245 unsigned long num = *count;
@@ -1100,6 +1276,7 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1100 * first block is the block number of the first block in this group 1276 * first block is the block number of the first block in this group
1101 */ 1277 */
1102 group_first_block = ext3_group_first_block_no(sb, group); 1278 group_first_block = ext3_group_first_block_no(sb, group);
1279 group_last_block = group_first_block + (EXT3_BLOCKS_PER_GROUP(sb) - 1);
1103 1280
1104 /* 1281 /*
1105 * Basically we will allocate a new block from inode's reservation 1282 * Basically we will allocate a new block from inode's reservation
@@ -1118,7 +1295,8 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1118 */ 1295 */
1119 while (1) { 1296 while (1) {
1120 if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) || 1297 if (rsv_is_empty(&my_rsv->rsv_window) || (ret < 0) ||
1121 !goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb)) { 1298 !goal_in_my_reservation(&my_rsv->rsv_window,
1299 grp_goal, group, sb)) {
1122 if (my_rsv->rsv_goal_size < *count) 1300 if (my_rsv->rsv_goal_size < *count)
1123 my_rsv->rsv_goal_size = *count; 1301 my_rsv->rsv_goal_size = *count;
1124 ret = alloc_new_reservation(my_rsv, grp_goal, sb, 1302 ret = alloc_new_reservation(my_rsv, grp_goal, sb,
@@ -1126,17 +1304,21 @@ ext3_try_to_allocate_with_rsv(struct super_block *sb, handle_t *handle,
1126 if (ret < 0) 1304 if (ret < 0)
1127 break; /* failed */ 1305 break; /* failed */
1128 1306
1129 if (!goal_in_my_reservation(&my_rsv->rsv_window, grp_goal, group, sb)) 1307 if (!goal_in_my_reservation(&my_rsv->rsv_window,
1308 grp_goal, group, sb))
1130 grp_goal = -1; 1309 grp_goal = -1;
1131 } else if (grp_goal > 0 && (my_rsv->rsv_end-grp_goal+1) < *count) 1310 } else if (grp_goal > 0 &&
1311 (my_rsv->rsv_end-grp_goal+1) < *count)
1132 try_to_extend_reservation(my_rsv, sb, 1312 try_to_extend_reservation(my_rsv, sb,
1133 *count-my_rsv->rsv_end + grp_goal - 1); 1313 *count-my_rsv->rsv_end + grp_goal - 1);
1134 1314
1135 if ((my_rsv->rsv_start >= group_first_block + EXT3_BLOCKS_PER_GROUP(sb)) 1315 if ((my_rsv->rsv_start > group_last_block) ||
1136 || (my_rsv->rsv_end < group_first_block)) 1316 (my_rsv->rsv_end < group_first_block)) {
1317 rsv_window_dump(&EXT3_SB(sb)->s_rsv_window_root, 1);
1137 BUG(); 1318 BUG();
1138 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh, grp_goal, 1319 }
1139 &num, &my_rsv->rsv_window); 1320 ret = ext3_try_to_allocate(sb, handle, group, bitmap_bh,
1321 grp_goal, &num, &my_rsv->rsv_window);
1140 if (ret >= 0) { 1322 if (ret >= 0) {
1141 my_rsv->rsv_alloc_hit += num; 1323 my_rsv->rsv_alloc_hit += num;
1142 *count = num; 1324 *count = num;
@@ -1161,6 +1343,12 @@ out:
1161 return ret; 1343 return ret;
1162} 1344}
1163 1345
1346/**
1347 * ext3_has_free_blocks()
1348 * @sbi: in-core super block structure.
1349 *
1350 * Check if filesystem has at least 1 free block available for allocation.
1351 */
1164static int ext3_has_free_blocks(struct ext3_sb_info *sbi) 1352static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
1165{ 1353{
1166 ext3_fsblk_t free_blocks, root_blocks; 1354 ext3_fsblk_t free_blocks, root_blocks;
@@ -1175,11 +1363,17 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)
1175 return 1; 1363 return 1;
1176} 1364}
1177 1365
1178/* 1366/**
1367 * ext3_should_retry_alloc()
1368 * @sb: super block
1369 * @retries number of attemps has been made
1370 *
1179 * ext3_should_retry_alloc() is called when ENOSPC is returned, and if 1371 * ext3_should_retry_alloc() is called when ENOSPC is returned, and if
1180 * it is profitable to retry the operation, this function will wait 1372 * it is profitable to retry the operation, this function will wait
1181 * for the current or commiting transaction to complete, and then 1373 * for the current or commiting transaction to complete, and then
1182 * return TRUE. 1374 * return TRUE.
1375 *
1376 * if the total number of retries exceed three times, return FALSE.
1183 */ 1377 */
1184int ext3_should_retry_alloc(struct super_block *sb, int *retries) 1378int ext3_should_retry_alloc(struct super_block *sb, int *retries)
1185{ 1379{
@@ -1191,13 +1385,19 @@ int ext3_should_retry_alloc(struct super_block *sb, int *retries)
1191 return journal_force_commit_nested(EXT3_SB(sb)->s_journal); 1385 return journal_force_commit_nested(EXT3_SB(sb)->s_journal);
1192} 1386}
1193 1387
1194/* 1388/**
1195 * ext3_new_block uses a goal block to assist allocation. If the goal is 1389 * ext3_new_blocks() -- core block(s) allocation function
1196 * free, or there is a free block within 32 blocks of the goal, that block 1390 * @handle: handle to this transaction
1197 * is allocated. Otherwise a forward search is made for a free block; within 1391 * @inode: file inode
1198 * each block group the search first looks for an entire free byte in the block 1392 * @goal: given target block(filesystem wide)
1199 * bitmap, and then for any free bit if that fails. 1393 * @count: target number of blocks to allocate
1200 * This function also updates quota and i_blocks field. 1394 * @errp: error code
1395 *
1396 * ext3_new_blocks uses a goal block to assist allocation. It tries to
1397 * allocate block(s) from the block group contains the goal block first. If that
1398 * fails, it will try to allocate block(s) from other block groups without
1399 * any specific goal block.
1400 *
1201 */ 1401 */
1202ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode, 1402ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
1203 ext3_fsblk_t goal, unsigned long *count, int *errp) 1403 ext3_fsblk_t goal, unsigned long *count, int *errp)
@@ -1303,7 +1503,7 @@ retry_alloc:
1303 smp_rmb(); 1503 smp_rmb();
1304 1504
1305 /* 1505 /*
1306 * Now search the rest of the groups. We assume that 1506 * Now search the rest of the groups. We assume that
1307 * i and gdp correctly point to the last group visited. 1507 * i and gdp correctly point to the last group visited.
1308 */ 1508 */
1309 for (bgi = 0; bgi < ngroups; bgi++) { 1509 for (bgi = 0; bgi < ngroups; bgi++) {
@@ -1428,7 +1628,7 @@ allocated:
1428 1628
1429 spin_lock(sb_bgl_lock(sbi, group_no)); 1629 spin_lock(sb_bgl_lock(sbi, group_no));
1430 gdp->bg_free_blocks_count = 1630 gdp->bg_free_blocks_count =
1431 cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count) - num); 1631 cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num);
1432 spin_unlock(sb_bgl_lock(sbi, group_no)); 1632 spin_unlock(sb_bgl_lock(sbi, group_no));
1433 percpu_counter_mod(&sbi->s_freeblocks_counter, -num); 1633 percpu_counter_mod(&sbi->s_freeblocks_counter, -num);
1434 1634
@@ -1471,6 +1671,12 @@ ext3_fsblk_t ext3_new_block(handle_t *handle, struct inode *inode,
1471 return ext3_new_blocks(handle, inode, goal, &count, errp); 1671 return ext3_new_blocks(handle, inode, goal, &count, errp);
1472} 1672}
1473 1673
1674/**
1675 * ext3_count_free_blocks() -- count filesystem free blocks
1676 * @sb: superblock
1677 *
1678 * Adds up the number of free blocks from each block group.
1679 */
1474ext3_fsblk_t ext3_count_free_blocks(struct super_block *sb) 1680ext3_fsblk_t ext3_count_free_blocks(struct super_block *sb)
1475{ 1681{
1476 ext3_fsblk_t desc_count; 1682 ext3_fsblk_t desc_count;
diff --git a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c
index ce4f82b9e528..b9176eed98d1 100644
--- a/fs/ext3/bitmap.c
+++ b/fs/ext3/bitmap.c
@@ -20,7 +20,7 @@ unsigned long ext3_count_free (struct buffer_head * map, unsigned int numchars)
20 unsigned int i; 20 unsigned int i;
21 unsigned long sum = 0; 21 unsigned long sum = 0;
22 22
23 if (!map) 23 if (!map)
24 return (0); 24 return (0);
25 for (i = 0; i < numchars; i++) 25 for (i = 0; i < numchars; i++)
26 sum += nibblemap[map->b_data[i] & 0xf] + 26 sum += nibblemap[map->b_data[i] & 0xf] +
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index fbb0d4ed07d4..429acbb4e064 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -59,7 +59,7 @@ static unsigned char get_dtype(struct super_block *sb, int filetype)
59 59
60 return (ext3_filetype_table[filetype]); 60 return (ext3_filetype_table[filetype]);
61} 61}
62 62
63 63
64int ext3_check_dir_entry (const char * function, struct inode * dir, 64int ext3_check_dir_entry (const char * function, struct inode * dir,
65 struct ext3_dir_entry_2 * de, 65 struct ext3_dir_entry_2 * de,
@@ -67,7 +67,7 @@ int ext3_check_dir_entry (const char * function, struct inode * dir,
67 unsigned long offset) 67 unsigned long offset)
68{ 68{
69 const char * error_msg = NULL; 69 const char * error_msg = NULL;
70 const int rlen = le16_to_cpu(de->rec_len); 70 const int rlen = le16_to_cpu(de->rec_len);
71 71
72 if (rlen < EXT3_DIR_REC_LEN(1)) 72 if (rlen < EXT3_DIR_REC_LEN(1))
73 error_msg = "rec_len is smaller than minimal"; 73 error_msg = "rec_len is smaller than minimal";
@@ -162,7 +162,7 @@ revalidate:
162 * to make sure. */ 162 * to make sure. */
163 if (filp->f_version != inode->i_version) { 163 if (filp->f_version != inode->i_version) {
164 for (i = 0; i < sb->s_blocksize && i < offset; ) { 164 for (i = 0; i < sb->s_blocksize && i < offset; ) {
165 de = (struct ext3_dir_entry_2 *) 165 de = (struct ext3_dir_entry_2 *)
166 (bh->b_data + i); 166 (bh->b_data + i);
167 /* It's too expensive to do a full 167 /* It's too expensive to do a full
168 * dirent test each time round this 168 * dirent test each time round this
@@ -181,7 +181,7 @@ revalidate:
181 filp->f_version = inode->i_version; 181 filp->f_version = inode->i_version;
182 } 182 }
183 183
184 while (!error && filp->f_pos < inode->i_size 184 while (!error && filp->f_pos < inode->i_size
185 && offset < sb->s_blocksize) { 185 && offset < sb->s_blocksize) {
186 de = (struct ext3_dir_entry_2 *) (bh->b_data + offset); 186 de = (struct ext3_dir_entry_2 *) (bh->b_data + offset);
187 if (!ext3_check_dir_entry ("ext3_readdir", inode, de, 187 if (!ext3_check_dir_entry ("ext3_readdir", inode, de,
@@ -229,7 +229,7 @@ out:
229/* 229/*
230 * These functions convert from the major/minor hash to an f_pos 230 * These functions convert from the major/minor hash to an f_pos
231 * value. 231 * value.
232 * 232 *
233 * Currently we only use major hash numer. This is unfortunate, but 233 * Currently we only use major hash numer. This is unfortunate, but
234 * on 32-bit machines, the same VFS interface is used for lseek and 234 * on 32-bit machines, the same VFS interface is used for lseek and
235 * llseek, so if we use the 64 bit offset, then the 32-bit versions of 235 * llseek, so if we use the 64 bit offset, then the 32-bit versions of
@@ -250,7 +250,7 @@ out:
250struct fname { 250struct fname {
251 __u32 hash; 251 __u32 hash;
252 __u32 minor_hash; 252 __u32 minor_hash;
253 struct rb_node rb_hash; 253 struct rb_node rb_hash;
254 struct fname *next; 254 struct fname *next;
255 __u32 inode; 255 __u32 inode;
256 __u8 name_len; 256 __u8 name_len;
@@ -343,10 +343,9 @@ int ext3_htree_store_dirent(struct file *dir_file, __u32 hash,
343 343
344 /* Create and allocate the fname structure */ 344 /* Create and allocate the fname structure */
345 len = sizeof(struct fname) + dirent->name_len + 1; 345 len = sizeof(struct fname) + dirent->name_len + 1;
346 new_fn = kmalloc(len, GFP_KERNEL); 346 new_fn = kzalloc(len, GFP_KERNEL);
347 if (!new_fn) 347 if (!new_fn)
348 return -ENOMEM; 348 return -ENOMEM;
349 memset(new_fn, 0, len);
350 new_fn->hash = hash; 349 new_fn->hash = hash;
351 new_fn->minor_hash = minor_hash; 350 new_fn->minor_hash = minor_hash;
352 new_fn->inode = le32_to_cpu(dirent->inode); 351 new_fn->inode = le32_to_cpu(dirent->inode);
@@ -410,7 +409,7 @@ static int call_filldir(struct file * filp, void * dirent,
410 curr_pos = hash2pos(fname->hash, fname->minor_hash); 409 curr_pos = hash2pos(fname->hash, fname->minor_hash);
411 while (fname) { 410 while (fname) {
412 error = filldir(dirent, fname->name, 411 error = filldir(dirent, fname->name,
413 fname->name_len, curr_pos, 412 fname->name_len, curr_pos,
414 fname->inode, 413 fname->inode,
415 get_dtype(sb, fname->file_type)); 414 get_dtype(sb, fname->file_type));
416 if (error) { 415 if (error) {
@@ -465,7 +464,7 @@ static int ext3_dx_readdir(struct file * filp,
465 /* 464 /*
466 * Fill the rbtree if we have no more entries, 465 * Fill the rbtree if we have no more entries,
467 * or the inode has changed since we last read in the 466 * or the inode has changed since we last read in the
468 * cached entries. 467 * cached entries.
469 */ 468 */
470 if ((!info->curr_node) || 469 if ((!info->curr_node) ||
471 (filp->f_version != inode->i_version)) { 470 (filp->f_version != inode->i_version)) {
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index 1efefb630ea9..994efd189f4e 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -100,7 +100,7 @@ ext3_file_write(struct kiocb *iocb, const char __user *buf, size_t count, loff_t
100 100
101force_commit: 101force_commit:
102 err = ext3_force_commit(inode->i_sb); 102 err = ext3_force_commit(inode->i_sb);
103 if (err) 103 if (err)
104 return err; 104 return err;
105 return ret; 105 return ret;
106} 106}
diff --git a/fs/ext3/fsync.c b/fs/ext3/fsync.c
index 49382a208e05..dd1fd3c0fc05 100644
--- a/fs/ext3/fsync.c
+++ b/fs/ext3/fsync.c
@@ -8,14 +8,14 @@
8 * Universite Pierre et Marie Curie (Paris VI) 8 * Universite Pierre et Marie Curie (Paris VI)
9 * from 9 * from
10 * linux/fs/minix/truncate.c Copyright (C) 1991, 1992 Linus Torvalds 10 * linux/fs/minix/truncate.c Copyright (C) 1991, 1992 Linus Torvalds
11 * 11 *
12 * ext3fs fsync primitive 12 * ext3fs fsync primitive
13 * 13 *
14 * Big-endian to little-endian byte-swapping/bitmaps by 14 * Big-endian to little-endian byte-swapping/bitmaps by
15 * David S. Miller (davem@caip.rutgers.edu), 1995 15 * David S. Miller (davem@caip.rutgers.edu), 1995
16 * 16 *
17 * Removed unnecessary code duplication for little endian machines 17 * Removed unnecessary code duplication for little endian machines
18 * and excessive __inline__s. 18 * and excessive __inline__s.
19 * Andi Kleen, 1997 19 * Andi Kleen, 1997
20 * 20 *
21 * Major simplications and cleanup - we only need to do the metadata, because 21 * Major simplications and cleanup - we only need to do the metadata, because
diff --git a/fs/ext3/hash.c b/fs/ext3/hash.c
index 5a2d1235ead0..deeb27b5ba83 100644
--- a/fs/ext3/hash.c
+++ b/fs/ext3/hash.c
@@ -4,7 +4,7 @@
4 * Copyright (C) 2002 by Theodore Ts'o 4 * Copyright (C) 2002 by Theodore Ts'o
5 * 5 *
6 * This file is released under the GPL v2. 6 * This file is released under the GPL v2.
7 * 7 *
8 * This file may be redistributed under the terms of the GNU Public 8 * This file may be redistributed under the terms of the GNU Public
9 * License. 9 * License.
10 */ 10 */
@@ -80,11 +80,11 @@ static void str2hashbuf(const char *msg, int len, __u32 *buf, int num)
80 * Returns the hash of a filename. If len is 0 and name is NULL, then 80 * Returns the hash of a filename. If len is 0 and name is NULL, then
81 * this function can be used to test whether or not a hash version is 81 * this function can be used to test whether or not a hash version is
82 * supported. 82 * supported.
83 * 83 *
84 * The seed is an 4 longword (32 bits) "secret" which can be used to 84 * The seed is an 4 longword (32 bits) "secret" which can be used to
85 * uniquify a hash. If the seed is all zero's, then some default seed 85 * uniquify a hash. If the seed is all zero's, then some default seed
86 * may be used. 86 * may be used.
87 * 87 *
88 * A particular hash version specifies whether or not the seed is 88 * A particular hash version specifies whether or not the seed is
89 * represented, and whether or not the returned hash is 32 bits or 64 89 * represented, and whether or not the returned hash is 32 bits or 64
90 * bits. 32 bit hashes will return 0 for the minor hash. 90 * bits. 32 bit hashes will return 0 for the minor hash.
@@ -95,7 +95,7 @@ int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
95 __u32 minor_hash = 0; 95 __u32 minor_hash = 0;
96 const char *p; 96 const char *p;
97 int i; 97 int i;
98 __u32 in[8], buf[4]; 98 __u32 in[8], buf[4];
99 99
100 /* Initialize the default seed for the hash checksum functions */ 100 /* Initialize the default seed for the hash checksum functions */
101 buf[0] = 0x67452301; 101 buf[0] = 0x67452301;
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 36546ed36a14..e45dbd651736 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -202,7 +202,7 @@ error_return:
202static int find_group_dir(struct super_block *sb, struct inode *parent) 202static int find_group_dir(struct super_block *sb, struct inode *parent)
203{ 203{
204 int ngroups = EXT3_SB(sb)->s_groups_count; 204 int ngroups = EXT3_SB(sb)->s_groups_count;
205 int freei, avefreei; 205 unsigned int freei, avefreei;
206 struct ext3_group_desc *desc, *best_desc = NULL; 206 struct ext3_group_desc *desc, *best_desc = NULL;
207 struct buffer_head *bh; 207 struct buffer_head *bh;
208 int group, best_group = -1; 208 int group, best_group = -1;
@@ -216,7 +216,7 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
216 continue; 216 continue;
217 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei) 217 if (le16_to_cpu(desc->bg_free_inodes_count) < avefreei)
218 continue; 218 continue;
219 if (!best_desc || 219 if (!best_desc ||
220 (le16_to_cpu(desc->bg_free_blocks_count) > 220 (le16_to_cpu(desc->bg_free_blocks_count) >
221 le16_to_cpu(best_desc->bg_free_blocks_count))) { 221 le16_to_cpu(best_desc->bg_free_blocks_count))) {
222 best_group = group; 222 best_group = group;
@@ -226,30 +226,30 @@ static int find_group_dir(struct super_block *sb, struct inode *parent)
226 return best_group; 226 return best_group;
227} 227}
228 228
229/* 229/*
230 * Orlov's allocator for directories. 230 * Orlov's allocator for directories.
231 * 231 *
232 * We always try to spread first-level directories. 232 * We always try to spread first-level directories.
233 * 233 *
234 * If there are blockgroups with both free inodes and free blocks counts 234 * If there are blockgroups with both free inodes and free blocks counts
235 * not worse than average we return one with smallest directory count. 235 * not worse than average we return one with smallest directory count.
236 * Otherwise we simply return a random group. 236 * Otherwise we simply return a random group.
237 * 237 *
238 * For the rest rules look so: 238 * For the rest rules look so:
239 * 239 *
240 * It's OK to put directory into a group unless 240 * It's OK to put directory into a group unless
241 * it has too many directories already (max_dirs) or 241 * it has too many directories already (max_dirs) or
242 * it has too few free inodes left (min_inodes) or 242 * it has too few free inodes left (min_inodes) or
243 * it has too few free blocks left (min_blocks) or 243 * it has too few free blocks left (min_blocks) or
244 * it's already running too large debt (max_debt). 244 * it's already running too large debt (max_debt).
245 * Parent's group is prefered, if it doesn't satisfy these 245 * Parent's group is prefered, if it doesn't satisfy these
246 * conditions we search cyclically through the rest. If none 246 * conditions we search cyclically through the rest. If none
247 * of the groups look good we just look for a group with more 247 * of the groups look good we just look for a group with more
248 * free inodes than average (starting at parent's group). 248 * free inodes than average (starting at parent's group).
249 * 249 *
250 * Debt is incremented each time we allocate a directory and decremented 250 * Debt is incremented each time we allocate a directory and decremented
251 * when we allocate an inode, within 0--255. 251 * when we allocate an inode, within 0--255.
252 */ 252 */
253 253
254#define INODE_COST 64 254#define INODE_COST 64
255#define BLOCK_COST 256 255#define BLOCK_COST 256
@@ -261,10 +261,10 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent)
261 struct ext3_super_block *es = sbi->s_es; 261 struct ext3_super_block *es = sbi->s_es;
262 int ngroups = sbi->s_groups_count; 262 int ngroups = sbi->s_groups_count;
263 int inodes_per_group = EXT3_INODES_PER_GROUP(sb); 263 int inodes_per_group = EXT3_INODES_PER_GROUP(sb);
264 int freei, avefreei; 264 unsigned int freei, avefreei;
265 ext3_fsblk_t freeb, avefreeb; 265 ext3_fsblk_t freeb, avefreeb;
266 ext3_fsblk_t blocks_per_dir; 266 ext3_fsblk_t blocks_per_dir;
267 int ndirs; 267 unsigned int ndirs;
268 int max_debt, max_dirs, min_inodes; 268 int max_debt, max_dirs, min_inodes;
269 ext3_grpblk_t min_blocks; 269 ext3_grpblk_t min_blocks;
270 int group = -1, i; 270 int group = -1, i;
@@ -454,7 +454,7 @@ struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
454 group = find_group_dir(sb, dir); 454 group = find_group_dir(sb, dir);
455 else 455 else
456 group = find_group_orlov(sb, dir); 456 group = find_group_orlov(sb, dir);
457 } else 457 } else
458 group = find_group_other(sb, dir); 458 group = find_group_other(sb, dir);
459 459
460 err = -ENOSPC; 460 err = -ENOSPC;
@@ -559,7 +559,6 @@ got:
559 559
560 inode->i_ino = ino; 560 inode->i_ino = ino;
561 /* This is the optimal IO size (for stat), not the fs block size */ 561 /* This is the optimal IO size (for stat), not the fs block size */
562 inode->i_blksize = PAGE_SIZE;
563 inode->i_blocks = 0; 562 inode->i_blocks = 0;
564 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 563 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
565 564
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 84be02e93652..dcf4f1dd108b 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -13,11 +13,11 @@
13 * Copyright (C) 1991, 1992 Linus Torvalds 13 * Copyright (C) 1991, 1992 Linus Torvalds
14 * 14 *
15 * Goal-directed block allocation by Stephen Tweedie 15 * Goal-directed block allocation by Stephen Tweedie
16 * (sct@redhat.com), 1993, 1998 16 * (sct@redhat.com), 1993, 1998
17 * Big-endian to little-endian byte-swapping/bitmaps by 17 * Big-endian to little-endian byte-swapping/bitmaps by
18 * David S. Miller (davem@caip.rutgers.edu), 1995 18 * David S. Miller (davem@caip.rutgers.edu), 1995
19 * 64-bit file support on 64-bit platforms by Jakub Jelinek 19 * 64-bit file support on 64-bit platforms by Jakub Jelinek
20 * (jj@sunsite.ms.mff.cuni.cz) 20 * (jj@sunsite.ms.mff.cuni.cz)
21 * 21 *
22 * Assorted race fixes, rewrite of ext3_get_block() by Al Viro, 2000 22 * Assorted race fixes, rewrite of ext3_get_block() by Al Viro, 2000
23 */ 23 */
@@ -55,7 +55,7 @@ static int ext3_inode_is_fast_symlink(struct inode *inode)
55/* 55/*
56 * The ext3 forget function must perform a revoke if we are freeing data 56 * The ext3 forget function must perform a revoke if we are freeing data
57 * which has been journaled. Metadata (eg. indirect blocks) must be 57 * which has been journaled. Metadata (eg. indirect blocks) must be
58 * revoked in all cases. 58 * revoked in all cases.
59 * 59 *
60 * "bh" may be NULL: a metadata block may have been freed from memory 60 * "bh" may be NULL: a metadata block may have been freed from memory
61 * but there may still be a record of it in the journal, and that record 61 * but there may still be a record of it in the journal, and that record
@@ -105,7 +105,7 @@ int ext3_forget(handle_t *handle, int is_metadata, struct inode *inode,
105 * Work out how many blocks we need to proceed with the next chunk of a 105 * Work out how many blocks we need to proceed with the next chunk of a
106 * truncate transaction. 106 * truncate transaction.
107 */ 107 */
108static unsigned long blocks_for_truncate(struct inode *inode) 108static unsigned long blocks_for_truncate(struct inode *inode)
109{ 109{
110 unsigned long needed; 110 unsigned long needed;
111 111
@@ -122,13 +122,13 @@ static unsigned long blocks_for_truncate(struct inode *inode)
122 122
123 /* But we need to bound the transaction so we don't overflow the 123 /* But we need to bound the transaction so we don't overflow the
124 * journal. */ 124 * journal. */
125 if (needed > EXT3_MAX_TRANS_DATA) 125 if (needed > EXT3_MAX_TRANS_DATA)
126 needed = EXT3_MAX_TRANS_DATA; 126 needed = EXT3_MAX_TRANS_DATA;
127 127
128 return EXT3_DATA_TRANS_BLOCKS(inode->i_sb) + needed; 128 return EXT3_DATA_TRANS_BLOCKS(inode->i_sb) + needed;
129} 129}
130 130
131/* 131/*
132 * Truncate transactions can be complex and absolutely huge. So we need to 132 * Truncate transactions can be complex and absolutely huge. So we need to
133 * be able to restart the transaction at a conventient checkpoint to make 133 * be able to restart the transaction at a conventient checkpoint to make
134 * sure we don't overflow the journal. 134 * sure we don't overflow the journal.
@@ -136,9 +136,9 @@ static unsigned long blocks_for_truncate(struct inode *inode)
136 * start_transaction gets us a new handle for a truncate transaction, 136 * start_transaction gets us a new handle for a truncate transaction,
137 * and extend_transaction tries to extend the existing one a bit. If 137 * and extend_transaction tries to extend the existing one a bit. If
138 * extend fails, we need to propagate the failure up and restart the 138 * extend fails, we need to propagate the failure up and restart the
139 * transaction in the top-level truncate loop. --sct 139 * transaction in the top-level truncate loop. --sct
140 */ 140 */
141static handle_t *start_transaction(struct inode *inode) 141static handle_t *start_transaction(struct inode *inode)
142{ 142{
143 handle_t *result; 143 handle_t *result;
144 144
@@ -215,12 +215,12 @@ void ext3_delete_inode (struct inode * inode)
215 ext3_orphan_del(handle, inode); 215 ext3_orphan_del(handle, inode);
216 EXT3_I(inode)->i_dtime = get_seconds(); 216 EXT3_I(inode)->i_dtime = get_seconds();
217 217
218 /* 218 /*
219 * One subtle ordering requirement: if anything has gone wrong 219 * One subtle ordering requirement: if anything has gone wrong
220 * (transaction abort, IO errors, whatever), then we can still 220 * (transaction abort, IO errors, whatever), then we can still
221 * do these next steps (the fs will already have been marked as 221 * do these next steps (the fs will already have been marked as
222 * having errors), but we can't free the inode if the mark_dirty 222 * having errors), but we can't free the inode if the mark_dirty
223 * fails. 223 * fails.
224 */ 224 */
225 if (ext3_mark_inode_dirty(handle, inode)) 225 if (ext3_mark_inode_dirty(handle, inode))
226 /* If that failed, just do the required in-core inode clear. */ 226 /* If that failed, just do the required in-core inode clear. */
@@ -398,7 +398,7 @@ no_block:
398 * + if there is a block to the left of our position - allocate near it. 398 * + if there is a block to the left of our position - allocate near it.
399 * + if pointer will live in indirect block - allocate near that block. 399 * + if pointer will live in indirect block - allocate near that block.
400 * + if pointer will live in inode - allocate in the same 400 * + if pointer will live in inode - allocate in the same
401 * cylinder group. 401 * cylinder group.
402 * 402 *
403 * In the latter case we colour the starting block by the callers PID to 403 * In the latter case we colour the starting block by the callers PID to
404 * prevent it from clashing with concurrent allocations for a different inode 404 * prevent it from clashing with concurrent allocations for a different inode
@@ -470,7 +470,7 @@ static ext3_fsblk_t ext3_find_goal(struct inode *inode, long block,
470 * ext3_blks_to_allocate: Look up the block map and count the number 470 * ext3_blks_to_allocate: Look up the block map and count the number
471 * of direct blocks need to be allocated for the given branch. 471 * of direct blocks need to be allocated for the given branch.
472 * 472 *
473 * @branch: chain of indirect blocks 473 * @branch: chain of indirect blocks
474 * @k: number of blocks need for indirect blocks 474 * @k: number of blocks need for indirect blocks
475 * @blks: number of data blocks to be mapped. 475 * @blks: number of data blocks to be mapped.
476 * @blocks_to_boundary: the offset in the indirect block 476 * @blocks_to_boundary: the offset in the indirect block
@@ -744,7 +744,7 @@ static int ext3_splice_branch(handle_t *handle, struct inode *inode,
744 jbd_debug(5, "splicing indirect only\n"); 744 jbd_debug(5, "splicing indirect only\n");
745 BUFFER_TRACE(where->bh, "call ext3_journal_dirty_metadata"); 745 BUFFER_TRACE(where->bh, "call ext3_journal_dirty_metadata");
746 err = ext3_journal_dirty_metadata(handle, where->bh); 746 err = ext3_journal_dirty_metadata(handle, where->bh);
747 if (err) 747 if (err)
748 goto err_out; 748 goto err_out;
749 } else { 749 } else {
750 /* 750 /*
@@ -1098,7 +1098,7 @@ static int walk_page_buffers( handle_t *handle,
1098 1098
1099 for ( bh = head, block_start = 0; 1099 for ( bh = head, block_start = 0;
1100 ret == 0 && (bh != head || !block_start); 1100 ret == 0 && (bh != head || !block_start);
1101 block_start = block_end, bh = next) 1101 block_start = block_end, bh = next)
1102 { 1102 {
1103 next = bh->b_this_page; 1103 next = bh->b_this_page;
1104 block_end = block_start + blocksize; 1104 block_end = block_start + blocksize;
@@ -1137,7 +1137,7 @@ static int walk_page_buffers( handle_t *handle,
1137 * So what we do is to rely on the fact that journal_stop/journal_start 1137 * So what we do is to rely on the fact that journal_stop/journal_start
1138 * will _not_ run commit under these circumstances because handle->h_ref 1138 * will _not_ run commit under these circumstances because handle->h_ref
1139 * is elevated. We'll still have enough credits for the tiny quotafile 1139 * is elevated. We'll still have enough credits for the tiny quotafile
1140 * write. 1140 * write.
1141 */ 1141 */
1142static int do_journal_get_write_access(handle_t *handle, 1142static int do_journal_get_write_access(handle_t *handle,
1143 struct buffer_head *bh) 1143 struct buffer_head *bh)
@@ -1282,7 +1282,7 @@ static int ext3_journalled_commit_write(struct file *file,
1282 if (inode->i_size > EXT3_I(inode)->i_disksize) { 1282 if (inode->i_size > EXT3_I(inode)->i_disksize) {
1283 EXT3_I(inode)->i_disksize = inode->i_size; 1283 EXT3_I(inode)->i_disksize = inode->i_size;
1284 ret2 = ext3_mark_inode_dirty(handle, inode); 1284 ret2 = ext3_mark_inode_dirty(handle, inode);
1285 if (!ret) 1285 if (!ret)
1286 ret = ret2; 1286 ret = ret2;
1287 } 1287 }
1288 ret2 = ext3_journal_stop(handle); 1288 ret2 = ext3_journal_stop(handle);
@@ -1291,7 +1291,7 @@ static int ext3_journalled_commit_write(struct file *file,
1291 return ret; 1291 return ret;
1292} 1292}
1293 1293
1294/* 1294/*
1295 * bmap() is special. It gets used by applications such as lilo and by 1295 * bmap() is special. It gets used by applications such as lilo and by
1296 * the swapper to find the on-disk block of a specific piece of data. 1296 * the swapper to find the on-disk block of a specific piece of data.
1297 * 1297 *
@@ -1300,10 +1300,10 @@ static int ext3_journalled_commit_write(struct file *file,
1300 * filesystem and enables swap, then they may get a nasty shock when the 1300 * filesystem and enables swap, then they may get a nasty shock when the
1301 * data getting swapped to that swapfile suddenly gets overwritten by 1301 * data getting swapped to that swapfile suddenly gets overwritten by
1302 * the original zero's written out previously to the journal and 1302 * the original zero's written out previously to the journal and
1303 * awaiting writeback in the kernel's buffer cache. 1303 * awaiting writeback in the kernel's buffer cache.
1304 * 1304 *
1305 * So, if we see any bmap calls here on a modified, data-journaled file, 1305 * So, if we see any bmap calls here on a modified, data-journaled file,
1306 * take extra steps to flush any blocks which might be in the cache. 1306 * take extra steps to flush any blocks which might be in the cache.
1307 */ 1307 */
1308static sector_t ext3_bmap(struct address_space *mapping, sector_t block) 1308static sector_t ext3_bmap(struct address_space *mapping, sector_t block)
1309{ 1309{
@@ -1312,16 +1312,16 @@ static sector_t ext3_bmap(struct address_space *mapping, sector_t block)
1312 int err; 1312 int err;
1313 1313
1314 if (EXT3_I(inode)->i_state & EXT3_STATE_JDATA) { 1314 if (EXT3_I(inode)->i_state & EXT3_STATE_JDATA) {
1315 /* 1315 /*
1316 * This is a REALLY heavyweight approach, but the use of 1316 * This is a REALLY heavyweight approach, but the use of
1317 * bmap on dirty files is expected to be extremely rare: 1317 * bmap on dirty files is expected to be extremely rare:
1318 * only if we run lilo or swapon on a freshly made file 1318 * only if we run lilo or swapon on a freshly made file
1319 * do we expect this to happen. 1319 * do we expect this to happen.
1320 * 1320 *
1321 * (bmap requires CAP_SYS_RAWIO so this does not 1321 * (bmap requires CAP_SYS_RAWIO so this does not
1322 * represent an unprivileged user DOS attack --- we'd be 1322 * represent an unprivileged user DOS attack --- we'd be
1323 * in trouble if mortal users could trigger this path at 1323 * in trouble if mortal users could trigger this path at
1324 * will.) 1324 * will.)
1325 * 1325 *
1326 * NB. EXT3_STATE_JDATA is not set on files other than 1326 * NB. EXT3_STATE_JDATA is not set on files other than
1327 * regular files. If somebody wants to bmap a directory 1327 * regular files. If somebody wants to bmap a directory
@@ -1457,7 +1457,7 @@ static int ext3_ordered_writepage(struct page *page,
1457 */ 1457 */
1458 1458
1459 /* 1459 /*
1460 * And attach them to the current transaction. But only if 1460 * And attach them to the current transaction. But only if
1461 * block_write_full_page() succeeded. Otherwise they are unmapped, 1461 * block_write_full_page() succeeded. Otherwise they are unmapped,
1462 * and generally junk. 1462 * and generally junk.
1463 */ 1463 */
@@ -1644,7 +1644,7 @@ static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
1644 } 1644 }
1645 } 1645 }
1646 1646
1647 ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 1647 ret = blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
1648 offset, nr_segs, 1648 offset, nr_segs,
1649 ext3_get_block, NULL); 1649 ext3_get_block, NULL);
1650 1650
@@ -2025,7 +2025,7 @@ static void ext3_free_data(handle_t *handle, struct inode *inode,
2025 __le32 *first, __le32 *last) 2025 __le32 *first, __le32 *last)
2026{ 2026{
2027 ext3_fsblk_t block_to_free = 0; /* Starting block # of a run */ 2027 ext3_fsblk_t block_to_free = 0; /* Starting block # of a run */
2028 unsigned long count = 0; /* Number of blocks in the run */ 2028 unsigned long count = 0; /* Number of blocks in the run */
2029 __le32 *block_to_free_p = NULL; /* Pointer into inode/ind 2029 __le32 *block_to_free_p = NULL; /* Pointer into inode/ind
2030 corresponding to 2030 corresponding to
2031 block_to_free */ 2031 block_to_free */
@@ -2054,7 +2054,7 @@ static void ext3_free_data(handle_t *handle, struct inode *inode,
2054 } else if (nr == block_to_free + count) { 2054 } else if (nr == block_to_free + count) {
2055 count++; 2055 count++;
2056 } else { 2056 } else {
2057 ext3_clear_blocks(handle, inode, this_bh, 2057 ext3_clear_blocks(handle, inode, this_bh,
2058 block_to_free, 2058 block_to_free,
2059 count, block_to_free_p, p); 2059 count, block_to_free_p, p);
2060 block_to_free = nr; 2060 block_to_free = nr;
@@ -2115,7 +2115,7 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
2115 */ 2115 */
2116 if (!bh) { 2116 if (!bh) {
2117 ext3_error(inode->i_sb, "ext3_free_branches", 2117 ext3_error(inode->i_sb, "ext3_free_branches",
2118 "Read failure, inode=%ld, block="E3FSBLK, 2118 "Read failure, inode=%lu, block="E3FSBLK,
2119 inode->i_ino, nr); 2119 inode->i_ino, nr);
2120 continue; 2120 continue;
2121 } 2121 }
@@ -2184,7 +2184,7 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
2184 *p = 0; 2184 *p = 0;
2185 BUFFER_TRACE(parent_bh, 2185 BUFFER_TRACE(parent_bh,
2186 "call ext3_journal_dirty_metadata"); 2186 "call ext3_journal_dirty_metadata");
2187 ext3_journal_dirty_metadata(handle, 2187 ext3_journal_dirty_metadata(handle,
2188 parent_bh); 2188 parent_bh);
2189 } 2189 }
2190 } 2190 }
@@ -2632,9 +2632,6 @@ void ext3_read_inode(struct inode * inode)
2632 * recovery code: that's fine, we're about to complete 2632 * recovery code: that's fine, we're about to complete
2633 * the process of deleting those. */ 2633 * the process of deleting those. */
2634 } 2634 }
2635 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size
2636 * (for stat), not the fs block
2637 * size */
2638 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); 2635 inode->i_blocks = le32_to_cpu(raw_inode->i_blocks);
2639 ei->i_flags = le32_to_cpu(raw_inode->i_flags); 2636 ei->i_flags = le32_to_cpu(raw_inode->i_flags);
2640#ifdef EXT3_FRAGMENTS 2637#ifdef EXT3_FRAGMENTS
@@ -2704,7 +2701,7 @@ void ext3_read_inode(struct inode * inode)
2704 if (raw_inode->i_block[0]) 2701 if (raw_inode->i_block[0])
2705 init_special_inode(inode, inode->i_mode, 2702 init_special_inode(inode, inode->i_mode,
2706 old_decode_dev(le32_to_cpu(raw_inode->i_block[0]))); 2703 old_decode_dev(le32_to_cpu(raw_inode->i_block[0])));
2707 else 2704 else
2708 init_special_inode(inode, inode->i_mode, 2705 init_special_inode(inode, inode->i_mode,
2709 new_decode_dev(le32_to_cpu(raw_inode->i_block[1]))); 2706 new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
2710 } 2707 }
@@ -2724,8 +2721,8 @@ bad_inode:
2724 * 2721 *
2725 * The caller must have write access to iloc->bh. 2722 * The caller must have write access to iloc->bh.
2726 */ 2723 */
2727static int ext3_do_update_inode(handle_t *handle, 2724static int ext3_do_update_inode(handle_t *handle,
2728 struct inode *inode, 2725 struct inode *inode,
2729 struct ext3_iloc *iloc) 2726 struct ext3_iloc *iloc)
2730{ 2727{
2731 struct ext3_inode *raw_inode = ext3_raw_inode(iloc); 2728 struct ext3_inode *raw_inode = ext3_raw_inode(iloc);
@@ -2900,7 +2897,7 @@ int ext3_write_inode(struct inode *inode, int wait)
2900 * commit will leave the blocks being flushed in an unused state on 2897 * commit will leave the blocks being flushed in an unused state on
2901 * disk. (On recovery, the inode will get truncated and the blocks will 2898 * disk. (On recovery, the inode will get truncated and the blocks will
2902 * be freed, so we have a strong guarantee that no future commit will 2899 * be freed, so we have a strong guarantee that no future commit will
2903 * leave these blocks visible to the user.) 2900 * leave these blocks visible to the user.)
2904 * 2901 *
2905 * Called with inode->sem down. 2902 * Called with inode->sem down.
2906 */ 2903 */
@@ -3043,13 +3040,13 @@ int ext3_mark_iloc_dirty(handle_t *handle,
3043 return err; 3040 return err;
3044} 3041}
3045 3042
3046/* 3043/*
3047 * On success, We end up with an outstanding reference count against 3044 * On success, We end up with an outstanding reference count against
3048 * iloc->bh. This _must_ be cleaned up later. 3045 * iloc->bh. This _must_ be cleaned up later.
3049 */ 3046 */
3050 3047
3051int 3048int
3052ext3_reserve_inode_write(handle_t *handle, struct inode *inode, 3049ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
3053 struct ext3_iloc *iloc) 3050 struct ext3_iloc *iloc)
3054{ 3051{
3055 int err = 0; 3052 int err = 0;
@@ -3139,7 +3136,7 @@ out:
3139} 3136}
3140 3137
3141#if 0 3138#if 0
3142/* 3139/*
3143 * Bind an inode's backing buffer_head into this transaction, to prevent 3140 * Bind an inode's backing buffer_head into this transaction, to prevent
3144 * it from being flushed to disk early. Unlike 3141 * it from being flushed to disk early. Unlike
3145 * ext3_reserve_inode_write, this leaves behind no bh reference and 3142 * ext3_reserve_inode_write, this leaves behind no bh reference and
@@ -3157,7 +3154,7 @@ static int ext3_pin_inode(handle_t *handle, struct inode *inode)
3157 BUFFER_TRACE(iloc.bh, "get_write_access"); 3154 BUFFER_TRACE(iloc.bh, "get_write_access");
3158 err = journal_get_write_access(handle, iloc.bh); 3155 err = journal_get_write_access(handle, iloc.bh);
3159 if (!err) 3156 if (!err)
3160 err = ext3_journal_dirty_metadata(handle, 3157 err = ext3_journal_dirty_metadata(handle,
3161 iloc.bh); 3158 iloc.bh);
3162 brelse(iloc.bh); 3159 brelse(iloc.bh);
3163 } 3160 }
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 2aa7101b27cd..85d132c37ee0 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -15,13 +15,13 @@
15 * Big-endian to little-endian byte-swapping/bitmaps by 15 * Big-endian to little-endian byte-swapping/bitmaps by
16 * David S. Miller (davem@caip.rutgers.edu), 1995 16 * David S. Miller (davem@caip.rutgers.edu), 1995
17 * Directory entry file type support and forward compatibility hooks 17 * Directory entry file type support and forward compatibility hooks
18 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998 18 * for B-tree directories by Theodore Ts'o (tytso@mit.edu), 1998
19 * Hash Tree Directory indexing (c) 19 * Hash Tree Directory indexing (c)
20 * Daniel Phillips, 2001 20 * Daniel Phillips, 2001
21 * Hash Tree Directory indexing porting 21 * Hash Tree Directory indexing porting
22 * Christopher Li, 2002 22 * Christopher Li, 2002
23 * Hash Tree Directory indexing cleanup 23 * Hash Tree Directory indexing cleanup
24 * Theodore Ts'o, 2002 24 * Theodore Ts'o, 2002
25 */ 25 */
26 26
27#include <linux/fs.h> 27#include <linux/fs.h>
@@ -76,7 +76,7 @@ static struct buffer_head *ext3_append(handle_t *handle,
76#ifdef DX_DEBUG 76#ifdef DX_DEBUG
77#define dxtrace(command) command 77#define dxtrace(command) command
78#else 78#else
79#define dxtrace(command) 79#define dxtrace(command)
80#endif 80#endif
81 81
82struct fake_dirent 82struct fake_dirent
@@ -169,7 +169,7 @@ static struct ext3_dir_entry_2* dx_pack_dirents (char *base, int size);
169static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block); 169static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block);
170static int ext3_htree_next_block(struct inode *dir, __u32 hash, 170static int ext3_htree_next_block(struct inode *dir, __u32 hash,
171 struct dx_frame *frame, 171 struct dx_frame *frame,
172 struct dx_frame *frames, 172 struct dx_frame *frames,
173 __u32 *start_hash); 173 __u32 *start_hash);
174static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry, 174static struct buffer_head * ext3_dx_find_entry(struct dentry *dentry,
175 struct ext3_dir_entry_2 **res_dir, int *err); 175 struct ext3_dir_entry_2 **res_dir, int *err);
@@ -250,7 +250,7 @@ static void dx_show_index (char * label, struct dx_entry *entries)
250} 250}
251 251
252struct stats 252struct stats
253{ 253{
254 unsigned names; 254 unsigned names;
255 unsigned space; 255 unsigned space;
256 unsigned bcount; 256 unsigned bcount;
@@ -278,7 +278,7 @@ static struct stats dx_show_leaf(struct dx_hash_info *hinfo, struct ext3_dir_ent
278 ((char *) de - base)); 278 ((char *) de - base));
279 } 279 }
280 space += EXT3_DIR_REC_LEN(de->name_len); 280 space += EXT3_DIR_REC_LEN(de->name_len);
281 names++; 281 names++;
282 } 282 }
283 de = (struct ext3_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len)); 283 de = (struct ext3_dir_entry_2 *) ((char *) de + le16_to_cpu(de->rec_len));
284 } 284 }
@@ -464,7 +464,7 @@ static void dx_release (struct dx_frame *frames)
464 */ 464 */
465static int ext3_htree_next_block(struct inode *dir, __u32 hash, 465static int ext3_htree_next_block(struct inode *dir, __u32 hash,
466 struct dx_frame *frame, 466 struct dx_frame *frame,
467 struct dx_frame *frames, 467 struct dx_frame *frames,
468 __u32 *start_hash) 468 __u32 *start_hash)
469{ 469{
470 struct dx_frame *p; 470 struct dx_frame *p;
@@ -632,7 +632,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
632 } 632 }
633 count += ret; 633 count += ret;
634 hashval = ~0; 634 hashval = ~0;
635 ret = ext3_htree_next_block(dir, HASH_NB_ALWAYS, 635 ret = ext3_htree_next_block(dir, HASH_NB_ALWAYS,
636 frame, frames, &hashval); 636 frame, frames, &hashval);
637 *next_hash = hashval; 637 *next_hash = hashval;
638 if (ret < 0) { 638 if (ret < 0) {
@@ -649,7 +649,7 @@ int ext3_htree_fill_tree(struct file *dir_file, __u32 start_hash,
649 break; 649 break;
650 } 650 }
651 dx_release(frames); 651 dx_release(frames);
652 dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n", 652 dxtrace(printk("Fill tree: returned %d entries, next hash: %x\n",
653 count, *next_hash)); 653 count, *next_hash));
654 return count; 654 return count;
655errout: 655errout:
@@ -1050,7 +1050,7 @@ struct dentry *ext3_get_parent(struct dentry *child)
1050 parent = ERR_PTR(-ENOMEM); 1050 parent = ERR_PTR(-ENOMEM);
1051 } 1051 }
1052 return parent; 1052 return parent;
1053} 1053}
1054 1054
1055#define S_SHIFT 12 1055#define S_SHIFT 12
1056static unsigned char ext3_type_by_mode[S_IFMT >> S_SHIFT] = { 1056static unsigned char ext3_type_by_mode[S_IFMT >> S_SHIFT] = {
@@ -1198,7 +1198,7 @@ errout:
1198 * add_dirent_to_buf will attempt search the directory block for 1198 * add_dirent_to_buf will attempt search the directory block for
1199 * space. It will return -ENOSPC if no space is available, and -EIO 1199 * space. It will return -ENOSPC if no space is available, and -EIO
1200 * and -EEXIST if directory entry already exists. 1200 * and -EEXIST if directory entry already exists.
1201 * 1201 *
1202 * NOTE! bh is NOT released in the case where ENOSPC is returned. In 1202 * NOTE! bh is NOT released in the case where ENOSPC is returned. In
1203 * all other cases bh is released. 1203 * all other cases bh is released.
1204 */ 1204 */
@@ -1572,7 +1572,7 @@ cleanup:
1572 * ext3_delete_entry deletes a directory entry by merging it with the 1572 * ext3_delete_entry deletes a directory entry by merging it with the
1573 * previous entry 1573 * previous entry
1574 */ 1574 */
1575static int ext3_delete_entry (handle_t *handle, 1575static int ext3_delete_entry (handle_t *handle,
1576 struct inode * dir, 1576 struct inode * dir,
1577 struct ext3_dir_entry_2 * de_del, 1577 struct ext3_dir_entry_2 * de_del,
1578 struct buffer_head * bh) 1578 struct buffer_head * bh)
@@ -1643,12 +1643,12 @@ static int ext3_add_nondir(handle_t *handle,
1643 * is so far negative - it has no inode. 1643 * is so far negative - it has no inode.
1644 * 1644 *
1645 * If the create succeeds, we fill in the inode information 1645 * If the create succeeds, we fill in the inode information
1646 * with d_instantiate(). 1646 * with d_instantiate().
1647 */ 1647 */
1648static int ext3_create (struct inode * dir, struct dentry * dentry, int mode, 1648static int ext3_create (struct inode * dir, struct dentry * dentry, int mode,
1649 struct nameidata *nd) 1649 struct nameidata *nd)
1650{ 1650{
1651 handle_t *handle; 1651 handle_t *handle;
1652 struct inode * inode; 1652 struct inode * inode;
1653 int err, retries = 0; 1653 int err, retries = 0;
1654 1654
@@ -1688,7 +1688,7 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry,
1688 1688
1689retry: 1689retry:
1690 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 1690 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
1691 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + 1691 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 +
1692 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 1692 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
1693 if (IS_ERR(handle)) 1693 if (IS_ERR(handle))
1694 return PTR_ERR(handle); 1694 return PTR_ERR(handle);
@@ -1813,10 +1813,10 @@ static int empty_dir (struct inode * inode)
1813 de1 = (struct ext3_dir_entry_2 *) 1813 de1 = (struct ext3_dir_entry_2 *)
1814 ((char *) de + le16_to_cpu(de->rec_len)); 1814 ((char *) de + le16_to_cpu(de->rec_len));
1815 if (le32_to_cpu(de->inode) != inode->i_ino || 1815 if (le32_to_cpu(de->inode) != inode->i_ino ||
1816 !le32_to_cpu(de1->inode) || 1816 !le32_to_cpu(de1->inode) ||
1817 strcmp (".", de->name) || 1817 strcmp (".", de->name) ||
1818 strcmp ("..", de1->name)) { 1818 strcmp ("..", de1->name)) {
1819 ext3_warning (inode->i_sb, "empty_dir", 1819 ext3_warning (inode->i_sb, "empty_dir",
1820 "bad directory (dir #%lu) - no `.' or `..'", 1820 "bad directory (dir #%lu) - no `.' or `..'",
1821 inode->i_ino); 1821 inode->i_ino);
1822 brelse (bh); 1822 brelse (bh);
@@ -1883,7 +1883,7 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1883 * being truncated, or files being unlinked. */ 1883 * being truncated, or files being unlinked. */
1884 1884
1885 /* @@@ FIXME: Observation from aviro: 1885 /* @@@ FIXME: Observation from aviro:
1886 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block 1886 * I think I can trigger J_ASSERT in ext3_orphan_add(). We block
1887 * here (on lock_super()), so race with ext3_link() which might bump 1887 * here (on lock_super()), so race with ext3_link() which might bump
1888 * ->i_nlink. For, say it, character device. Not a regular file, 1888 * ->i_nlink. For, say it, character device. Not a regular file,
1889 * not a directory, not a symlink and ->i_nlink > 0. 1889 * not a directory, not a symlink and ->i_nlink > 0.
@@ -1919,8 +1919,8 @@ int ext3_orphan_add(handle_t *handle, struct inode *inode)
1919 if (!err) 1919 if (!err)
1920 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); 1920 list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan);
1921 1921
1922 jbd_debug(4, "superblock will point to %ld\n", inode->i_ino); 1922 jbd_debug(4, "superblock will point to %lu\n", inode->i_ino);
1923 jbd_debug(4, "orphan inode %ld will point to %d\n", 1923 jbd_debug(4, "orphan inode %lu will point to %d\n",
1924 inode->i_ino, NEXT_ORPHAN(inode)); 1924 inode->i_ino, NEXT_ORPHAN(inode));
1925out_unlock: 1925out_unlock:
1926 unlock_super(sb); 1926 unlock_super(sb);
@@ -2129,7 +2129,7 @@ static int ext3_symlink (struct inode * dir,
2129 2129
2130retry: 2130retry:
2131 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + 2131 handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
2132 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + 2132 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 +
2133 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb)); 2133 2*EXT3_QUOTA_INIT_BLOCKS(dir->i_sb));
2134 if (IS_ERR(handle)) 2134 if (IS_ERR(handle))
2135 return PTR_ERR(handle); 2135 return PTR_ERR(handle);
@@ -2227,7 +2227,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
2227 DQUOT_INIT(new_dentry->d_inode); 2227 DQUOT_INIT(new_dentry->d_inode);
2228 handle = ext3_journal_start(old_dir, 2 * 2228 handle = ext3_journal_start(old_dir, 2 *
2229 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + 2229 EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) +
2230 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); 2230 EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
2231 if (IS_ERR(handle)) 2231 if (IS_ERR(handle))
2232 return PTR_ERR(handle); 2232 return PTR_ERR(handle);
2233 2233
@@ -2393,4 +2393,4 @@ struct inode_operations ext3_special_inode_operations = {
2393 .removexattr = generic_removexattr, 2393 .removexattr = generic_removexattr,
2394#endif 2394#endif
2395 .permission = ext3_permission, 2395 .permission = ext3_permission,
2396}; 2396};
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 5e1337fd878a..b73cba12f79c 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -336,7 +336,7 @@ static int verify_reserved_gdb(struct super_block *sb,
336 unsigned five = 5; 336 unsigned five = 5;
337 unsigned seven = 7; 337 unsigned seven = 7;
338 unsigned grp; 338 unsigned grp;
339 __u32 *p = (__u32 *)primary->b_data; 339 __le32 *p = (__le32 *)primary->b_data;
340 int gdbackups = 0; 340 int gdbackups = 0;
341 341
342 while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) { 342 while ((grp = ext3_list_backups(sb, &three, &five, &seven)) < end) {
@@ -380,7 +380,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
380 struct buffer_head *dind; 380 struct buffer_head *dind;
381 int gdbackups; 381 int gdbackups;
382 struct ext3_iloc iloc; 382 struct ext3_iloc iloc;
383 __u32 *data; 383 __le32 *data;
384 int err; 384 int err;
385 385
386 if (test_opt(sb, DEBUG)) 386 if (test_opt(sb, DEBUG))
@@ -417,7 +417,7 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
417 goto exit_bh; 417 goto exit_bh;
418 } 418 }
419 419
420 data = (__u32 *)dind->b_data; 420 data = (__le32 *)dind->b_data;
421 if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) { 421 if (le32_to_cpu(data[gdb_num % EXT3_ADDR_PER_BLOCK(sb)]) != gdblock) {
422 ext3_warning(sb, __FUNCTION__, 422 ext3_warning(sb, __FUNCTION__,
423 "new group %u GDT block "E3FSBLK" not reserved", 423 "new group %u GDT block "E3FSBLK" not reserved",
@@ -439,8 +439,8 @@ static int add_new_gdb(handle_t *handle, struct inode *inode,
439 if ((err = ext3_reserve_inode_write(handle, inode, &iloc))) 439 if ((err = ext3_reserve_inode_write(handle, inode, &iloc)))
440 goto exit_dindj; 440 goto exit_dindj;
441 441
442 n_group_desc = (struct buffer_head **)kmalloc((gdb_num + 1) * 442 n_group_desc = kmalloc((gdb_num + 1) * sizeof(struct buffer_head *),
443 sizeof(struct buffer_head *), GFP_KERNEL); 443 GFP_KERNEL);
444 if (!n_group_desc) { 444 if (!n_group_desc) {
445 err = -ENOMEM; 445 err = -ENOMEM;
446 ext3_warning (sb, __FUNCTION__, 446 ext3_warning (sb, __FUNCTION__,
@@ -519,7 +519,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
519 struct buffer_head *dind; 519 struct buffer_head *dind;
520 struct ext3_iloc iloc; 520 struct ext3_iloc iloc;
521 ext3_fsblk_t blk; 521 ext3_fsblk_t blk;
522 __u32 *data, *end; 522 __le32 *data, *end;
523 int gdbackups = 0; 523 int gdbackups = 0;
524 int res, i; 524 int res, i;
525 int err; 525 int err;
@@ -536,8 +536,8 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
536 } 536 }
537 537
538 blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count; 538 blk = EXT3_SB(sb)->s_sbh->b_blocknr + 1 + EXT3_SB(sb)->s_gdb_count;
539 data = (__u32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count; 539 data = (__le32 *)dind->b_data + EXT3_SB(sb)->s_gdb_count;
540 end = (__u32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb); 540 end = (__le32 *)dind->b_data + EXT3_ADDR_PER_BLOCK(sb);
541 541
542 /* Get each reserved primary GDT block and verify it holds backups */ 542 /* Get each reserved primary GDT block and verify it holds backups */
543 for (res = 0; res < reserved_gdb; res++, blk++) { 543 for (res = 0; res < reserved_gdb; res++, blk++) {
@@ -545,7 +545,8 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
545 ext3_warning(sb, __FUNCTION__, 545 ext3_warning(sb, __FUNCTION__,
546 "reserved block "E3FSBLK 546 "reserved block "E3FSBLK
547 " not at offset %ld", 547 " not at offset %ld",
548 blk, (long)(data - (__u32 *)dind->b_data)); 548 blk,
549 (long)(data - (__le32 *)dind->b_data));
549 err = -EINVAL; 550 err = -EINVAL;
550 goto exit_bh; 551 goto exit_bh;
551 } 552 }
@@ -560,7 +561,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
560 goto exit_bh; 561 goto exit_bh;
561 } 562 }
562 if (++data >= end) 563 if (++data >= end)
563 data = (__u32 *)dind->b_data; 564 data = (__le32 *)dind->b_data;
564 } 565 }
565 566
566 for (i = 0; i < reserved_gdb; i++) { 567 for (i = 0; i < reserved_gdb; i++) {
@@ -584,7 +585,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
584 blk = input->group * EXT3_BLOCKS_PER_GROUP(sb); 585 blk = input->group * EXT3_BLOCKS_PER_GROUP(sb);
585 for (i = 0; i < reserved_gdb; i++) { 586 for (i = 0; i < reserved_gdb; i++) {
586 int err2; 587 int err2;
587 data = (__u32 *)primary[i]->b_data; 588 data = (__le32 *)primary[i]->b_data;
588 /* printk("reserving backup %lu[%u] = %lu\n", 589 /* printk("reserving backup %lu[%u] = %lu\n",
589 primary[i]->b_blocknr, gdbackups, 590 primary[i]->b_blocknr, gdbackups,
590 blk + primary[i]->b_blocknr); */ 591 blk + primary[i]->b_blocknr); */
@@ -689,7 +690,7 @@ exit_err:
689 "can't update backup for group %d (err %d), " 690 "can't update backup for group %d (err %d), "
690 "forcing fsck on next reboot", group, err); 691 "forcing fsck on next reboot", group, err);
691 sbi->s_mount_state &= ~EXT3_VALID_FS; 692 sbi->s_mount_state &= ~EXT3_VALID_FS;
692 sbi->s_es->s_state &= ~cpu_to_le16(EXT3_VALID_FS); 693 sbi->s_es->s_state &= cpu_to_le16(~EXT3_VALID_FS);
693 mark_buffer_dirty(sbi->s_sbh); 694 mark_buffer_dirty(sbi->s_sbh);
694 } 695 }
695} 696}
@@ -730,6 +731,18 @@ int ext3_group_add(struct super_block *sb, struct ext3_new_group_data *input)
730 return -EPERM; 731 return -EPERM;
731 } 732 }
732 733
734 if (le32_to_cpu(es->s_blocks_count) + input->blocks_count <
735 le32_to_cpu(es->s_blocks_count)) {
736 ext3_warning(sb, __FUNCTION__, "blocks_count overflow\n");
737 return -EINVAL;
738 }
739
740 if (le32_to_cpu(es->s_inodes_count) + EXT3_INODES_PER_GROUP(sb) <
741 le32_to_cpu(es->s_inodes_count)) {
742 ext3_warning(sb, __FUNCTION__, "inodes_count overflow\n");
743 return -EINVAL;
744 }
745
733 if (reserved_gdb || gdb_off == 0) { 746 if (reserved_gdb || gdb_off == 0) {
734 if (!EXT3_HAS_COMPAT_FEATURE(sb, 747 if (!EXT3_HAS_COMPAT_FEATURE(sb,
735 EXT3_FEATURE_COMPAT_RESIZE_INODE)){ 748 EXT3_FEATURE_COMPAT_RESIZE_INODE)){
@@ -958,6 +971,11 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
958 971
959 add = EXT3_BLOCKS_PER_GROUP(sb) - last; 972 add = EXT3_BLOCKS_PER_GROUP(sb) - last;
960 973
974 if (o_blocks_count + add < o_blocks_count) {
975 ext3_warning(sb, __FUNCTION__, "blocks_count overflow");
976 return -EINVAL;
977 }
978
961 if (o_blocks_count + add > n_blocks_count) 979 if (o_blocks_count + add > n_blocks_count)
962 add = n_blocks_count - o_blocks_count; 980 add = n_blocks_count - o_blocks_count;
963 981
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 3559086eee5f..8bfd56ef18ca 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -45,7 +45,7 @@
45static int ext3_load_journal(struct super_block *, struct ext3_super_block *, 45static int ext3_load_journal(struct super_block *, struct ext3_super_block *,
46 unsigned long journal_devnum); 46 unsigned long journal_devnum);
47static int ext3_create_journal(struct super_block *, struct ext3_super_block *, 47static int ext3_create_journal(struct super_block *, struct ext3_super_block *,
48 int); 48 unsigned int);
49static void ext3_commit_super (struct super_block * sb, 49static void ext3_commit_super (struct super_block * sb,
50 struct ext3_super_block * es, 50 struct ext3_super_block * es,
51 int sync); 51 int sync);
@@ -62,13 +62,13 @@ static void ext3_unlockfs(struct super_block *sb);
62static void ext3_write_super (struct super_block * sb); 62static void ext3_write_super (struct super_block * sb);
63static void ext3_write_super_lockfs(struct super_block *sb); 63static void ext3_write_super_lockfs(struct super_block *sb);
64 64
65/* 65/*
66 * Wrappers for journal_start/end. 66 * Wrappers for journal_start/end.
67 * 67 *
68 * The only special thing we need to do here is to make sure that all 68 * The only special thing we need to do here is to make sure that all
69 * journal_end calls result in the superblock being marked dirty, so 69 * journal_end calls result in the superblock being marked dirty, so
70 * that sync() will call the filesystem's write_super callback if 70 * that sync() will call the filesystem's write_super callback if
71 * appropriate. 71 * appropriate.
72 */ 72 */
73handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks) 73handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks)
74{ 74{
@@ -90,11 +90,11 @@ handle_t *ext3_journal_start_sb(struct super_block *sb, int nblocks)
90 return journal_start(journal, nblocks); 90 return journal_start(journal, nblocks);
91} 91}
92 92
93/* 93/*
94 * The only special thing we need to do here is to make sure that all 94 * The only special thing we need to do here is to make sure that all
95 * journal_stop calls result in the superblock being marked dirty, so 95 * journal_stop calls result in the superblock being marked dirty, so
96 * that sync() will call the filesystem's write_super callback if 96 * that sync() will call the filesystem's write_super callback if
97 * appropriate. 97 * appropriate.
98 */ 98 */
99int __ext3_journal_stop(const char *where, handle_t *handle) 99int __ext3_journal_stop(const char *where, handle_t *handle)
100{ 100{
@@ -159,20 +159,21 @@ static void ext3_handle_error(struct super_block *sb)
159 if (sb->s_flags & MS_RDONLY) 159 if (sb->s_flags & MS_RDONLY)
160 return; 160 return;
161 161
162 if (test_opt (sb, ERRORS_RO)) { 162 if (!test_opt (sb, ERRORS_CONT)) {
163 printk (KERN_CRIT "Remounting filesystem read-only\n");
164 sb->s_flags |= MS_RDONLY;
165 } else {
166 journal_t *journal = EXT3_SB(sb)->s_journal; 163 journal_t *journal = EXT3_SB(sb)->s_journal;
167 164
168 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; 165 EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT;
169 if (journal) 166 if (journal)
170 journal_abort(journal, -EIO); 167 journal_abort(journal, -EIO);
171 } 168 }
169 if (test_opt (sb, ERRORS_RO)) {
170 printk (KERN_CRIT "Remounting filesystem read-only\n");
171 sb->s_flags |= MS_RDONLY;
172 }
173 ext3_commit_super(sb, es, 1);
172 if (test_opt(sb, ERRORS_PANIC)) 174 if (test_opt(sb, ERRORS_PANIC))
173 panic("EXT3-fs (device %s): panic forced after error\n", 175 panic("EXT3-fs (device %s): panic forced after error\n",
174 sb->s_id); 176 sb->s_id);
175 ext3_commit_super(sb, es, 1);
176} 177}
177 178
178void ext3_error (struct super_block * sb, const char * function, 179void ext3_error (struct super_block * sb, const char * function,
@@ -369,16 +370,16 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
369{ 370{
370 struct list_head *l; 371 struct list_head *l;
371 372
372 printk(KERN_ERR "sb orphan head is %d\n", 373 printk(KERN_ERR "sb orphan head is %d\n",
373 le32_to_cpu(sbi->s_es->s_last_orphan)); 374 le32_to_cpu(sbi->s_es->s_last_orphan));
374 375
375 printk(KERN_ERR "sb_info orphan list:\n"); 376 printk(KERN_ERR "sb_info orphan list:\n");
376 list_for_each(l, &sbi->s_orphan) { 377 list_for_each(l, &sbi->s_orphan) {
377 struct inode *inode = orphan_list_entry(l); 378 struct inode *inode = orphan_list_entry(l);
378 printk(KERN_ERR " " 379 printk(KERN_ERR " "
379 "inode %s:%ld at %p: mode %o, nlink %d, next %d\n", 380 "inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
380 inode->i_sb->s_id, inode->i_ino, inode, 381 inode->i_sb->s_id, inode->i_ino, inode,
381 inode->i_mode, inode->i_nlink, 382 inode->i_mode, inode->i_nlink,
382 NEXT_ORPHAN(inode)); 383 NEXT_ORPHAN(inode));
383 } 384 }
384} 385}
@@ -475,7 +476,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
475 inode_init_once(&ei->vfs_inode); 476 inode_init_once(&ei->vfs_inode);
476 } 477 }
477} 478}
478 479
479static int init_inodecache(void) 480static int init_inodecache(void)
480{ 481{
481 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache", 482 ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",
@@ -490,8 +491,7 @@ static int init_inodecache(void)
490 491
491static void destroy_inodecache(void) 492static void destroy_inodecache(void)
492{ 493{
493 if (kmem_cache_destroy(ext3_inode_cachep)) 494 kmem_cache_destroy(ext3_inode_cachep);
494 printk(KERN_INFO "ext3_inode_cache: not all structures were freed\n");
495} 495}
496 496
497static void ext3_clear_inode(struct inode *inode) 497static void ext3_clear_inode(struct inode *inode)
@@ -733,8 +733,8 @@ static match_table_t tokens = {
733 733
734static ext3_fsblk_t get_sb_block(void **data) 734static ext3_fsblk_t get_sb_block(void **data)
735{ 735{
736 ext3_fsblk_t sb_block; 736 ext3_fsblk_t sb_block;
737 char *options = (char *) *data; 737 char *options = (char *) *data;
738 738
739 if (!options || strncmp(options, "sb=", 3) != 0) 739 if (!options || strncmp(options, "sb=", 3) != 0)
740 return 1; /* Default location */ 740 return 1; /* Default location */
@@ -753,7 +753,7 @@ static ext3_fsblk_t get_sb_block(void **data)
753} 753}
754 754
755static int parse_options (char *options, struct super_block *sb, 755static int parse_options (char *options, struct super_block *sb,
756 unsigned long *inum, unsigned long *journal_devnum, 756 unsigned int *inum, unsigned long *journal_devnum,
757 ext3_fsblk_t *n_blocks_count, int is_remount) 757 ext3_fsblk_t *n_blocks_count, int is_remount)
758{ 758{
759 struct ext3_sb_info *sbi = EXT3_SB(sb); 759 struct ext3_sb_info *sbi = EXT3_SB(sb);
@@ -1174,7 +1174,8 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
1174static int ext3_check_descriptors (struct super_block * sb) 1174static int ext3_check_descriptors (struct super_block * sb)
1175{ 1175{
1176 struct ext3_sb_info *sbi = EXT3_SB(sb); 1176 struct ext3_sb_info *sbi = EXT3_SB(sb);
1177 ext3_fsblk_t block = le32_to_cpu(sbi->s_es->s_first_data_block); 1177 ext3_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
1178 ext3_fsblk_t last_block;
1178 struct ext3_group_desc * gdp = NULL; 1179 struct ext3_group_desc * gdp = NULL;
1179 int desc_block = 0; 1180 int desc_block = 0;
1180 int i; 1181 int i;
@@ -1183,12 +1184,17 @@ static int ext3_check_descriptors (struct super_block * sb)
1183 1184
1184 for (i = 0; i < sbi->s_groups_count; i++) 1185 for (i = 0; i < sbi->s_groups_count; i++)
1185 { 1186 {
1187 if (i == sbi->s_groups_count - 1)
1188 last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1;
1189 else
1190 last_block = first_block +
1191 (EXT3_BLOCKS_PER_GROUP(sb) - 1);
1192
1186 if ((i % EXT3_DESC_PER_BLOCK(sb)) == 0) 1193 if ((i % EXT3_DESC_PER_BLOCK(sb)) == 0)
1187 gdp = (struct ext3_group_desc *) 1194 gdp = (struct ext3_group_desc *)
1188 sbi->s_group_desc[desc_block++]->b_data; 1195 sbi->s_group_desc[desc_block++]->b_data;
1189 if (le32_to_cpu(gdp->bg_block_bitmap) < block || 1196 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
1190 le32_to_cpu(gdp->bg_block_bitmap) >= 1197 le32_to_cpu(gdp->bg_block_bitmap) > last_block)
1191 block + EXT3_BLOCKS_PER_GROUP(sb))
1192 { 1198 {
1193 ext3_error (sb, "ext3_check_descriptors", 1199 ext3_error (sb, "ext3_check_descriptors",
1194 "Block bitmap for group %d" 1200 "Block bitmap for group %d"
@@ -1197,9 +1203,8 @@ static int ext3_check_descriptors (struct super_block * sb)
1197 le32_to_cpu(gdp->bg_block_bitmap)); 1203 le32_to_cpu(gdp->bg_block_bitmap));
1198 return 0; 1204 return 0;
1199 } 1205 }
1200 if (le32_to_cpu(gdp->bg_inode_bitmap) < block || 1206 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
1201 le32_to_cpu(gdp->bg_inode_bitmap) >= 1207 le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
1202 block + EXT3_BLOCKS_PER_GROUP(sb))
1203 { 1208 {
1204 ext3_error (sb, "ext3_check_descriptors", 1209 ext3_error (sb, "ext3_check_descriptors",
1205 "Inode bitmap for group %d" 1210 "Inode bitmap for group %d"
@@ -1208,9 +1213,9 @@ static int ext3_check_descriptors (struct super_block * sb)
1208 le32_to_cpu(gdp->bg_inode_bitmap)); 1213 le32_to_cpu(gdp->bg_inode_bitmap));
1209 return 0; 1214 return 0;
1210 } 1215 }
1211 if (le32_to_cpu(gdp->bg_inode_table) < block || 1216 if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
1212 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >= 1217 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >
1213 block + EXT3_BLOCKS_PER_GROUP(sb)) 1218 last_block)
1214 { 1219 {
1215 ext3_error (sb, "ext3_check_descriptors", 1220 ext3_error (sb, "ext3_check_descriptors",
1216 "Inode table for group %d" 1221 "Inode table for group %d"
@@ -1219,7 +1224,7 @@ static int ext3_check_descriptors (struct super_block * sb)
1219 le32_to_cpu(gdp->bg_inode_table)); 1224 le32_to_cpu(gdp->bg_inode_table));
1220 return 0; 1225 return 0;
1221 } 1226 }
1222 block += EXT3_BLOCKS_PER_GROUP(sb); 1227 first_block += EXT3_BLOCKS_PER_GROUP(sb);
1223 gdp++; 1228 gdp++;
1224 } 1229 }
1225 1230
@@ -1301,17 +1306,17 @@ static void ext3_orphan_cleanup (struct super_block * sb,
1301 DQUOT_INIT(inode); 1306 DQUOT_INIT(inode);
1302 if (inode->i_nlink) { 1307 if (inode->i_nlink) {
1303 printk(KERN_DEBUG 1308 printk(KERN_DEBUG
1304 "%s: truncating inode %ld to %Ld bytes\n", 1309 "%s: truncating inode %lu to %Ld bytes\n",
1305 __FUNCTION__, inode->i_ino, inode->i_size); 1310 __FUNCTION__, inode->i_ino, inode->i_size);
1306 jbd_debug(2, "truncating inode %ld to %Ld bytes\n", 1311 jbd_debug(2, "truncating inode %lu to %Ld bytes\n",
1307 inode->i_ino, inode->i_size); 1312 inode->i_ino, inode->i_size);
1308 ext3_truncate(inode); 1313 ext3_truncate(inode);
1309 nr_truncates++; 1314 nr_truncates++;
1310 } else { 1315 } else {
1311 printk(KERN_DEBUG 1316 printk(KERN_DEBUG
1312 "%s: deleting unreferenced inode %ld\n", 1317 "%s: deleting unreferenced inode %lu\n",
1313 __FUNCTION__, inode->i_ino); 1318 __FUNCTION__, inode->i_ino);
1314 jbd_debug(2, "deleting unreferenced inode %ld\n", 1319 jbd_debug(2, "deleting unreferenced inode %lu\n",
1315 inode->i_ino); 1320 inode->i_ino);
1316 nr_orphans++; 1321 nr_orphans++;
1317 } 1322 }
@@ -1390,7 +1395,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1390 ext3_fsblk_t sb_block = get_sb_block(&data); 1395 ext3_fsblk_t sb_block = get_sb_block(&data);
1391 ext3_fsblk_t logic_sb_block; 1396 ext3_fsblk_t logic_sb_block;
1392 unsigned long offset = 0; 1397 unsigned long offset = 0;
1393 unsigned long journal_inum = 0; 1398 unsigned int journal_inum = 0;
1394 unsigned long journal_devnum = 0; 1399 unsigned long journal_devnum = 0;
1395 unsigned long def_mount_opts; 1400 unsigned long def_mount_opts;
1396 struct inode *root; 1401 struct inode *root;
@@ -1401,11 +1406,10 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1401 int needs_recovery; 1406 int needs_recovery;
1402 __le32 features; 1407 __le32 features;
1403 1408
1404 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 1409 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1405 if (!sbi) 1410 if (!sbi)
1406 return -ENOMEM; 1411 return -ENOMEM;
1407 sb->s_fs_info = sbi; 1412 sb->s_fs_info = sbi;
1408 memset(sbi, 0, sizeof(*sbi));
1409 sbi->s_mount_opt = 0; 1413 sbi->s_mount_opt = 0;
1410 sbi->s_resuid = EXT3_DEF_RESUID; 1414 sbi->s_resuid = EXT3_DEF_RESUID;
1411 sbi->s_resgid = EXT3_DEF_RESGID; 1415 sbi->s_resgid = EXT3_DEF_RESGID;
@@ -1483,7 +1487,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1483 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || 1487 (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) ||
1484 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) || 1488 EXT3_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
1485 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U))) 1489 EXT3_HAS_INCOMPAT_FEATURE(sb, ~0U)))
1486 printk(KERN_WARNING 1490 printk(KERN_WARNING
1487 "EXT3-fs warning: feature flags set on rev 0 fs, " 1491 "EXT3-fs warning: feature flags set on rev 0 fs, "
1488 "running e2fsck is recommended\n"); 1492 "running e2fsck is recommended\n");
1489 /* 1493 /*
@@ -1509,7 +1513,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1509 1513
1510 if (blocksize < EXT3_MIN_BLOCK_SIZE || 1514 if (blocksize < EXT3_MIN_BLOCK_SIZE ||
1511 blocksize > EXT3_MAX_BLOCK_SIZE) { 1515 blocksize > EXT3_MAX_BLOCK_SIZE) {
1512 printk(KERN_ERR 1516 printk(KERN_ERR
1513 "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n", 1517 "EXT3-fs: Unsupported filesystem blocksize %d on %s.\n",
1514 blocksize, sb->s_id); 1518 blocksize, sb->s_id);
1515 goto failed_mount; 1519 goto failed_mount;
@@ -1533,14 +1537,14 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1533 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize; 1537 offset = (sb_block * EXT3_MIN_BLOCK_SIZE) % blocksize;
1534 bh = sb_bread(sb, logic_sb_block); 1538 bh = sb_bread(sb, logic_sb_block);
1535 if (!bh) { 1539 if (!bh) {
1536 printk(KERN_ERR 1540 printk(KERN_ERR
1537 "EXT3-fs: Can't read superblock on 2nd try.\n"); 1541 "EXT3-fs: Can't read superblock on 2nd try.\n");
1538 goto failed_mount; 1542 goto failed_mount;
1539 } 1543 }
1540 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); 1544 es = (struct ext3_super_block *)(((char *)bh->b_data) + offset);
1541 sbi->s_es = es; 1545 sbi->s_es = es;
1542 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { 1546 if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
1543 printk (KERN_ERR 1547 printk (KERN_ERR
1544 "EXT3-fs: Magic mismatch, very weird !\n"); 1548 "EXT3-fs: Magic mismatch, very weird !\n");
1545 goto failed_mount; 1549 goto failed_mount;
1546 } 1550 }
@@ -1622,10 +1626,9 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1622 1626
1623 if (EXT3_BLOCKS_PER_GROUP(sb) == 0) 1627 if (EXT3_BLOCKS_PER_GROUP(sb) == 0)
1624 goto cantfind_ext3; 1628 goto cantfind_ext3;
1625 sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - 1629 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
1626 le32_to_cpu(es->s_first_data_block) + 1630 le32_to_cpu(es->s_first_data_block) - 1)
1627 EXT3_BLOCKS_PER_GROUP(sb) - 1) / 1631 / EXT3_BLOCKS_PER_GROUP(sb)) + 1;
1628 EXT3_BLOCKS_PER_GROUP(sb);
1629 db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) / 1632 db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) /
1630 EXT3_DESC_PER_BLOCK(sb); 1633 EXT3_DESC_PER_BLOCK(sb);
1631 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), 1634 sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *),
@@ -1820,7 +1823,7 @@ out_fail:
1820/* 1823/*
1821 * Setup any per-fs journal parameters now. We'll do this both on 1824 * Setup any per-fs journal parameters now. We'll do this both on
1822 * initial mount, once the journal has been initialised but before we've 1825 * initial mount, once the journal has been initialised but before we've
1823 * done any recovery; and again on any subsequent remount. 1826 * done any recovery; and again on any subsequent remount.
1824 */ 1827 */
1825static void ext3_init_journal_params(struct super_block *sb, journal_t *journal) 1828static void ext3_init_journal_params(struct super_block *sb, journal_t *journal)
1826{ 1829{
@@ -1840,7 +1843,8 @@ static void ext3_init_journal_params(struct super_block *sb, journal_t *journal)
1840 spin_unlock(&journal->j_state_lock); 1843 spin_unlock(&journal->j_state_lock);
1841} 1844}
1842 1845
1843static journal_t *ext3_get_journal(struct super_block *sb, int journal_inum) 1846static journal_t *ext3_get_journal(struct super_block *sb,
1847 unsigned int journal_inum)
1844{ 1848{
1845 struct inode *journal_inode; 1849 struct inode *journal_inode;
1846 journal_t *journal; 1850 journal_t *journal;
@@ -1975,7 +1979,7 @@ static int ext3_load_journal(struct super_block *sb,
1975 unsigned long journal_devnum) 1979 unsigned long journal_devnum)
1976{ 1980{
1977 journal_t *journal; 1981 journal_t *journal;
1978 int journal_inum = le32_to_cpu(es->s_journal_inum); 1982 unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
1979 dev_t journal_dev; 1983 dev_t journal_dev;
1980 int err = 0; 1984 int err = 0;
1981 int really_read_only; 1985 int really_read_only;
@@ -2061,7 +2065,7 @@ static int ext3_load_journal(struct super_block *sb,
2061 2065
2062static int ext3_create_journal(struct super_block * sb, 2066static int ext3_create_journal(struct super_block * sb,
2063 struct ext3_super_block * es, 2067 struct ext3_super_block * es,
2064 int journal_inum) 2068 unsigned int journal_inum)
2065{ 2069{
2066 journal_t *journal; 2070 journal_t *journal;
2067 2071
@@ -2074,7 +2078,7 @@ static int ext3_create_journal(struct super_block * sb,
2074 if (!(journal = ext3_get_journal(sb, journal_inum))) 2078 if (!(journal = ext3_get_journal(sb, journal_inum)))
2075 return -EINVAL; 2079 return -EINVAL;
2076 2080
2077 printk(KERN_INFO "EXT3-fs: creating new journal on inode %d\n", 2081 printk(KERN_INFO "EXT3-fs: creating new journal on inode %u\n",
2078 journal_inum); 2082 journal_inum);
2079 2083
2080 if (journal_create(journal)) { 2084 if (journal_create(journal)) {
@@ -2342,10 +2346,8 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data)
2342 */ 2346 */
2343 ext3_clear_journal_err(sb, es); 2347 ext3_clear_journal_err(sb, es);
2344 sbi->s_mount_state = le16_to_cpu(es->s_state); 2348 sbi->s_mount_state = le16_to_cpu(es->s_state);
2345 if ((ret = ext3_group_extend(sb, es, n_blocks_count))) { 2349 if ((err = ext3_group_extend(sb, es, n_blocks_count)))
2346 err = ret;
2347 goto restore_opts; 2350 goto restore_opts;
2348 }
2349 if (!ext3_setup_super (sb, es, 0)) 2351 if (!ext3_setup_super (sb, es, 0))
2350 sb->s_flags &= ~MS_RDONLY; 2352 sb->s_flags &= ~MS_RDONLY;
2351 } 2353 }
@@ -2734,7 +2736,7 @@ static int __init init_ext3_fs(void)
2734out: 2736out:
2735 destroy_inodecache(); 2737 destroy_inodecache();
2736out1: 2738out1:
2737 exit_ext3_xattr(); 2739 exit_ext3_xattr();
2738 return err; 2740 return err;
2739} 2741}
2740 2742
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
index a44a0562203a..f86f2482f01d 100644
--- a/fs/ext3/xattr.c
+++ b/fs/ext3/xattr.c
@@ -75,7 +75,7 @@
75 75
76#ifdef EXT3_XATTR_DEBUG 76#ifdef EXT3_XATTR_DEBUG
77# define ea_idebug(inode, f...) do { \ 77# define ea_idebug(inode, f...) do { \
78 printk(KERN_DEBUG "inode %s:%ld: ", \ 78 printk(KERN_DEBUG "inode %s:%lu: ", \
79 inode->i_sb->s_id, inode->i_ino); \ 79 inode->i_sb->s_id, inode->i_ino); \
80 printk(f); \ 80 printk(f); \
81 printk("\n"); \ 81 printk("\n"); \
@@ -233,7 +233,7 @@ ext3_xattr_block_get(struct inode *inode, int name_index, const char *name,
233 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); 233 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
234 if (ext3_xattr_check_block(bh)) { 234 if (ext3_xattr_check_block(bh)) {
235bad_block: ext3_error(inode->i_sb, __FUNCTION__, 235bad_block: ext3_error(inode->i_sb, __FUNCTION__,
236 "inode %ld: bad block "E3FSBLK, inode->i_ino, 236 "inode %lu: bad block "E3FSBLK, inode->i_ino,
237 EXT3_I(inode)->i_file_acl); 237 EXT3_I(inode)->i_file_acl);
238 error = -EIO; 238 error = -EIO;
239 goto cleanup; 239 goto cleanup;
@@ -375,7 +375,7 @@ ext3_xattr_block_list(struct inode *inode, char *buffer, size_t buffer_size)
375 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount)); 375 atomic_read(&(bh->b_count)), le32_to_cpu(BHDR(bh)->h_refcount));
376 if (ext3_xattr_check_block(bh)) { 376 if (ext3_xattr_check_block(bh)) {
377 ext3_error(inode->i_sb, __FUNCTION__, 377 ext3_error(inode->i_sb, __FUNCTION__,
378 "inode %ld: bad block "E3FSBLK, inode->i_ino, 378 "inode %lu: bad block "E3FSBLK, inode->i_ino,
379 EXT3_I(inode)->i_file_acl); 379 EXT3_I(inode)->i_file_acl);
380 error = -EIO; 380 error = -EIO;
381 goto cleanup; 381 goto cleanup;
@@ -647,7 +647,7 @@ ext3_xattr_block_find(struct inode *inode, struct ext3_xattr_info *i,
647 le32_to_cpu(BHDR(bs->bh)->h_refcount)); 647 le32_to_cpu(BHDR(bs->bh)->h_refcount));
648 if (ext3_xattr_check_block(bs->bh)) { 648 if (ext3_xattr_check_block(bs->bh)) {
649 ext3_error(sb, __FUNCTION__, 649 ext3_error(sb, __FUNCTION__,
650 "inode %ld: bad block "E3FSBLK, inode->i_ino, 650 "inode %lu: bad block "E3FSBLK, inode->i_ino,
651 EXT3_I(inode)->i_file_acl); 651 EXT3_I(inode)->i_file_acl);
652 error = -EIO; 652 error = -EIO;
653 goto cleanup; 653 goto cleanup;
@@ -848,7 +848,7 @@ cleanup_dquot:
848 848
849bad_block: 849bad_block:
850 ext3_error(inode->i_sb, __FUNCTION__, 850 ext3_error(inode->i_sb, __FUNCTION__,
851 "inode %ld: bad block "E3FSBLK, inode->i_ino, 851 "inode %lu: bad block "E3FSBLK, inode->i_ino,
852 EXT3_I(inode)->i_file_acl); 852 EXT3_I(inode)->i_file_acl);
853 goto cleanup; 853 goto cleanup;
854 854
@@ -1077,14 +1077,14 @@ ext3_xattr_delete_inode(handle_t *handle, struct inode *inode)
1077 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl); 1077 bh = sb_bread(inode->i_sb, EXT3_I(inode)->i_file_acl);
1078 if (!bh) { 1078 if (!bh) {
1079 ext3_error(inode->i_sb, __FUNCTION__, 1079 ext3_error(inode->i_sb, __FUNCTION__,
1080 "inode %ld: block "E3FSBLK" read error", inode->i_ino, 1080 "inode %lu: block "E3FSBLK" read error", inode->i_ino,
1081 EXT3_I(inode)->i_file_acl); 1081 EXT3_I(inode)->i_file_acl);
1082 goto cleanup; 1082 goto cleanup;
1083 } 1083 }
1084 if (BHDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) || 1084 if (BHDR(bh)->h_magic != cpu_to_le32(EXT3_XATTR_MAGIC) ||
1085 BHDR(bh)->h_blocks != cpu_to_le32(1)) { 1085 BHDR(bh)->h_blocks != cpu_to_le32(1)) {
1086 ext3_error(inode->i_sb, __FUNCTION__, 1086 ext3_error(inode->i_sb, __FUNCTION__,
1087 "inode %ld: bad block "E3FSBLK, inode->i_ino, 1087 "inode %lu: bad block "E3FSBLK, inode->i_ino,
1088 EXT3_I(inode)->i_file_acl); 1088 EXT3_I(inode)->i_file_acl);
1089 goto cleanup; 1089 goto cleanup;
1090 } 1090 }
@@ -1211,7 +1211,7 @@ again:
1211 bh = sb_bread(inode->i_sb, ce->e_block); 1211 bh = sb_bread(inode->i_sb, ce->e_block);
1212 if (!bh) { 1212 if (!bh) {
1213 ext3_error(inode->i_sb, __FUNCTION__, 1213 ext3_error(inode->i_sb, __FUNCTION__,
1214 "inode %ld: block %lu read error", 1214 "inode %lu: block %lu read error",
1215 inode->i_ino, (unsigned long) ce->e_block); 1215 inode->i_ino, (unsigned long) ce->e_block);
1216 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >= 1216 } else if (le32_to_cpu(BHDR(bh)->h_refcount) >=
1217 EXT3_XATTR_REFCOUNT_MAX) { 1217 EXT3_XATTR_REFCOUNT_MAX) {
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 97b967b84fc6..82cc4f59e3ba 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -58,8 +58,7 @@ int __init fat_cache_init(void)
58 58
59void fat_cache_destroy(void) 59void fat_cache_destroy(void)
60{ 60{
61 if (kmem_cache_destroy(fat_cache_cachep)) 61 kmem_cache_destroy(fat_cache_cachep);
62 printk(KERN_INFO "fat_cache: not all structures were freed\n");
63} 62}
64 63
65static inline struct fat_cache *fat_cache_alloc(struct inode *inode) 64static inline struct fat_cache *fat_cache_alloc(struct inode *inode)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index 31b7174176ba..ab96ae823753 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -50,14 +50,14 @@ static int fat_add_cluster(struct inode *inode)
50 return err; 50 return err;
51} 51}
52 52
53static int __fat_get_blocks(struct inode *inode, sector_t iblock, 53static inline int __fat_get_block(struct inode *inode, sector_t iblock,
54 unsigned long *max_blocks, 54 unsigned long *max_blocks,
55 struct buffer_head *bh_result, int create) 55 struct buffer_head *bh_result, int create)
56{ 56{
57 struct super_block *sb = inode->i_sb; 57 struct super_block *sb = inode->i_sb;
58 struct msdos_sb_info *sbi = MSDOS_SB(sb); 58 struct msdos_sb_info *sbi = MSDOS_SB(sb);
59 sector_t phys;
60 unsigned long mapped_blocks; 59 unsigned long mapped_blocks;
60 sector_t phys;
61 int err, offset; 61 int err, offset;
62 62
63 err = fat_bmap(inode, iblock, &phys, &mapped_blocks); 63 err = fat_bmap(inode, iblock, &phys, &mapped_blocks);
@@ -73,7 +73,7 @@ static int __fat_get_blocks(struct inode *inode, sector_t iblock,
73 73
74 if (iblock != MSDOS_I(inode)->mmu_private >> sb->s_blocksize_bits) { 74 if (iblock != MSDOS_I(inode)->mmu_private >> sb->s_blocksize_bits) {
75 fat_fs_panic(sb, "corrupted file size (i_pos %lld, %lld)", 75 fat_fs_panic(sb, "corrupted file size (i_pos %lld, %lld)",
76 MSDOS_I(inode)->i_pos, MSDOS_I(inode)->mmu_private); 76 MSDOS_I(inode)->i_pos, MSDOS_I(inode)->mmu_private);
77 return -EIO; 77 return -EIO;
78 } 78 }
79 79
@@ -93,34 +93,29 @@ static int __fat_get_blocks(struct inode *inode, sector_t iblock,
93 err = fat_bmap(inode, iblock, &phys, &mapped_blocks); 93 err = fat_bmap(inode, iblock, &phys, &mapped_blocks);
94 if (err) 94 if (err)
95 return err; 95 return err;
96
96 BUG_ON(!phys); 97 BUG_ON(!phys);
97 BUG_ON(*max_blocks != mapped_blocks); 98 BUG_ON(*max_blocks != mapped_blocks);
98 set_buffer_new(bh_result); 99 set_buffer_new(bh_result);
99 map_bh(bh_result, sb, phys); 100 map_bh(bh_result, sb, phys);
101
100 return 0; 102 return 0;
101} 103}
102 104
103static int fat_get_blocks(struct inode *inode, sector_t iblock, 105static int fat_get_block(struct inode *inode, sector_t iblock,
104 struct buffer_head *bh_result, int create) 106 struct buffer_head *bh_result, int create)
105{ 107{
106 struct super_block *sb = inode->i_sb; 108 struct super_block *sb = inode->i_sb;
107 int err;
108 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; 109 unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
110 int err;
109 111
110 err = __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create); 112 err = __fat_get_block(inode, iblock, &max_blocks, bh_result, create);
111 if (err) 113 if (err)
112 return err; 114 return err;
113 bh_result->b_size = max_blocks << sb->s_blocksize_bits; 115 bh_result->b_size = max_blocks << sb->s_blocksize_bits;
114 return 0; 116 return 0;
115} 117}
116 118
117static int fat_get_block(struct inode *inode, sector_t iblock,
118 struct buffer_head *bh_result, int create)
119{
120 unsigned long max_blocks = 1;
121 return __fat_get_blocks(inode, iblock, &max_blocks, bh_result, create);
122}
123
124static int fat_writepage(struct page *page, struct writeback_control *wbc) 119static int fat_writepage(struct page *page, struct writeback_control *wbc)
125{ 120{
126 return block_write_full_page(page, fat_get_block, wbc); 121 return block_write_full_page(page, fat_get_block, wbc);
@@ -188,7 +183,7 @@ static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
188 * condition of fat_get_block() and ->truncate(). 183 * condition of fat_get_block() and ->truncate().
189 */ 184 */
190 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov, 185 return blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
191 offset, nr_segs, fat_get_blocks, NULL); 186 offset, nr_segs, fat_get_block, NULL);
192} 187}
193 188
194static sector_t _fat_bmap(struct address_space *mapping, sector_t block) 189static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
@@ -375,8 +370,6 @@ static int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
375 inode->i_flags |= S_IMMUTABLE; 370 inode->i_flags |= S_IMMUTABLE;
376 } 371 }
377 MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED; 372 MSDOS_I(inode)->i_attrs = de->attr & ATTR_UNUSED;
378 /* this is as close to the truth as we can get ... */
379 inode->i_blksize = sbi->cluster_size;
380 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) 373 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
381 & ~((loff_t)sbi->cluster_size - 1)) >> 9; 374 & ~((loff_t)sbi->cluster_size - 1)) >> 9;
382 inode->i_mtime.tv_sec = 375 inode->i_mtime.tv_sec =
@@ -528,8 +521,7 @@ static int __init fat_init_inodecache(void)
528 521
529static void __exit fat_destroy_inodecache(void) 522static void __exit fat_destroy_inodecache(void)
530{ 523{
531 if (kmem_cache_destroy(fat_inode_cachep)) 524 kmem_cache_destroy(fat_inode_cachep);
532 printk(KERN_INFO "fat_inode_cache: not all structures were freed\n");
533} 525}
534 526
535static int fat_remount(struct super_block *sb, int *flags, char *data) 527static int fat_remount(struct super_block *sb, int *flags, char *data)
@@ -1137,7 +1129,6 @@ static int fat_read_root(struct inode *inode)
1137 MSDOS_I(inode)->i_start = 0; 1129 MSDOS_I(inode)->i_start = 0;
1138 inode->i_size = sbi->dir_entries * sizeof(struct msdos_dir_entry); 1130 inode->i_size = sbi->dir_entries * sizeof(struct msdos_dir_entry);
1139 } 1131 }
1140 inode->i_blksize = sbi->cluster_size;
1141 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1)) 1132 inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
1142 & ~((loff_t)sbi->cluster_size - 1)) >> 9; 1133 & ~((loff_t)sbi->cluster_size - 1)) >> 9;
1143 MSDOS_I(inode)->i_logstart = 0; 1134 MSDOS_I(inode)->i_logstart = 0;
@@ -1168,11 +1159,10 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
1168 long error; 1159 long error;
1169 char buf[50]; 1160 char buf[50];
1170 1161
1171 sbi = kmalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); 1162 sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL);
1172 if (!sbi) 1163 if (!sbi)
1173 return -ENOMEM; 1164 return -ENOMEM;
1174 sb->s_fs_info = sbi; 1165 sb->s_fs_info = sbi;
1175 memset(sbi, 0, sizeof(struct msdos_sb_info));
1176 1166
1177 sb->s_flags |= MS_NODIRATIME; 1167 sb->s_flags |= MS_NODIRATIME;
1178 sb->s_magic = MSDOS_SUPER_MAGIC; 1168 sb->s_magic = MSDOS_SUPER_MAGIC;
diff --git a/fs/file.c b/fs/file.c
index b3c6b82e6a9d..8d3bfca7714b 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -281,10 +281,8 @@ static struct fdtable *alloc_fdtable(int nr)
281out2: 281out2:
282 nfds = fdt->max_fdset; 282 nfds = fdt->max_fdset;
283out: 283out:
284 if (new_openset) 284 free_fdset(new_openset, nfds);
285 free_fdset(new_openset, nfds); 285 free_fdset(new_execset, nfds);
286 if (new_execset)
287 free_fdset(new_execset, nfds);
288 kfree(fdt); 286 kfree(fdt);
289 return NULL; 287 return NULL;
290} 288}
diff --git a/fs/file_table.c b/fs/file_table.c
index 0131ba06e1ee..bc35a40417d7 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -169,7 +169,7 @@ void fastcall __fput(struct file *file)
169 if (file->f_op && file->f_op->release) 169 if (file->f_op && file->f_op->release)
170 file->f_op->release(inode, file); 170 file->f_op->release(inode, file);
171 security_file_free(file); 171 security_file_free(file);
172 if (unlikely(inode->i_cdev != NULL)) 172 if (unlikely(S_ISCHR(inode->i_mode) && inode->i_cdev != NULL))
173 cdev_put(inode->i_cdev); 173 cdev_put(inode->i_cdev);
174 fops_put(file->f_op); 174 fops_put(file->f_op);
175 if (file->f_mode & FMODE_WRITE) 175 if (file->f_mode & FMODE_WRITE)
diff --git a/fs/freevxfs/vxfs.h b/fs/freevxfs/vxfs.h
index d35979a58743..c8a92652612a 100644
--- a/fs/freevxfs/vxfs.h
+++ b/fs/freevxfs/vxfs.h
@@ -252,7 +252,7 @@ enum {
252 * Get filesystem private data from VFS inode. 252 * Get filesystem private data from VFS inode.
253 */ 253 */
254#define VXFS_INO(ip) \ 254#define VXFS_INO(ip) \
255 ((struct vxfs_inode_info *)(ip)->u.generic_ip) 255 ((struct vxfs_inode_info *)(ip)->i_private)
256 256
257/* 257/*
258 * Get filesystem private data from VFS superblock. 258 * Get filesystem private data from VFS superblock.
diff --git a/fs/freevxfs/vxfs_inode.c b/fs/freevxfs/vxfs_inode.c
index ca6a39714771..4786d51ad3bd 100644
--- a/fs/freevxfs/vxfs_inode.c
+++ b/fs/freevxfs/vxfs_inode.c
@@ -239,11 +239,10 @@ vxfs_iinit(struct inode *ip, struct vxfs_inode_info *vip)
239 ip->i_ctime.tv_nsec = 0; 239 ip->i_ctime.tv_nsec = 0;
240 ip->i_mtime.tv_nsec = 0; 240 ip->i_mtime.tv_nsec = 0;
241 241
242 ip->i_blksize = PAGE_SIZE;
243 ip->i_blocks = vip->vii_blocks; 242 ip->i_blocks = vip->vii_blocks;
244 ip->i_generation = vip->vii_gen; 243 ip->i_generation = vip->vii_gen;
245 244
246 ip->u.generic_ip = (void *)vip; 245 ip->i_private = vip;
247 246
248} 247}
249 248
@@ -338,5 +337,5 @@ vxfs_read_inode(struct inode *ip)
338void 337void
339vxfs_clear_inode(struct inode *ip) 338vxfs_clear_inode(struct inode *ip)
340{ 339{
341 kmem_cache_free(vxfs_inode_cachep, ip->u.generic_ip); 340 kmem_cache_free(vxfs_inode_cachep, ip->i_private);
342} 341}
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index 46fe60b2da23..79ec1f23d4d2 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -23,7 +23,7 @@ static struct fuse_conn *fuse_ctl_file_conn_get(struct file *file)
23{ 23{
24 struct fuse_conn *fc; 24 struct fuse_conn *fc;
25 mutex_lock(&fuse_mutex); 25 mutex_lock(&fuse_mutex);
26 fc = file->f_dentry->d_inode->u.generic_ip; 26 fc = file->f_dentry->d_inode->i_private;
27 if (fc) 27 if (fc)
28 fc = fuse_conn_get(fc); 28 fc = fuse_conn_get(fc);
29 mutex_unlock(&fuse_mutex); 29 mutex_unlock(&fuse_mutex);
@@ -98,7 +98,7 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
98 inode->i_op = iop; 98 inode->i_op = iop;
99 inode->i_fop = fop; 99 inode->i_fop = fop;
100 inode->i_nlink = nlink; 100 inode->i_nlink = nlink;
101 inode->u.generic_ip = fc; 101 inode->i_private = fc;
102 d_add(dentry, inode); 102 d_add(dentry, inode);
103 return dentry; 103 return dentry;
104} 104}
@@ -150,7 +150,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
150 150
151 for (i = fc->ctl_ndents - 1; i >= 0; i--) { 151 for (i = fc->ctl_ndents - 1; i >= 0; i--) {
152 struct dentry *dentry = fc->ctl_dentry[i]; 152 struct dentry *dentry = fc->ctl_dentry[i];
153 dentry->d_inode->u.generic_ip = NULL; 153 dentry->d_inode->i_private = NULL;
154 d_drop(dentry); 154 d_drop(dentry);
155 dput(dentry); 155 dput(dentry);
156 } 156 }
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 7d25092262ae..cb7cadb0b790 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -118,7 +118,6 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr)
118 inode->i_uid = attr->uid; 118 inode->i_uid = attr->uid;
119 inode->i_gid = attr->gid; 119 inode->i_gid = attr->gid;
120 i_size_write(inode, attr->size); 120 i_size_write(inode, attr->size);
121 inode->i_blksize = PAGE_CACHE_SIZE;
122 inode->i_blocks = attr->blocks; 121 inode->i_blocks = attr->blocks;
123 inode->i_atime.tv_sec = attr->atime; 122 inode->i_atime.tv_sec = attr->atime;
124 inode->i_atime.tv_nsec = attr->atimensec; 123 inode->i_atime.tv_nsec = attr->atimensec;
diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 13231dd5ce66..0d200068d0af 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -249,10 +249,9 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
249 sb = tree->inode->i_sb; 249 sb = tree->inode->i_sb;
250 size = sizeof(struct hfs_bnode) + tree->pages_per_bnode * 250 size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
251 sizeof(struct page *); 251 sizeof(struct page *);
252 node = kmalloc(size, GFP_KERNEL); 252 node = kzalloc(size, GFP_KERNEL);
253 if (!node) 253 if (!node)
254 return NULL; 254 return NULL;
255 memset(node, 0, size);
256 node->tree = tree; 255 node->tree = tree;
257 node->this = cnid; 256 node->this = cnid;
258 set_bit(HFS_BNODE_NEW, &node->flags); 257 set_bit(HFS_BNODE_NEW, &node->flags);
diff --git a/fs/hfs/btree.c b/fs/hfs/btree.c
index 400357994319..5fd0ed71f923 100644
--- a/fs/hfs/btree.c
+++ b/fs/hfs/btree.c
@@ -21,10 +21,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
21 struct page *page; 21 struct page *page;
22 unsigned int size; 22 unsigned int size;
23 23
24 tree = kmalloc(sizeof(*tree), GFP_KERNEL); 24 tree = kzalloc(sizeof(*tree), GFP_KERNEL);
25 if (!tree) 25 if (!tree)
26 return NULL; 26 return NULL;
27 memset(tree, 0, sizeof(*tree));
28 27
29 init_MUTEX(&tree->tree_lock); 28 init_MUTEX(&tree->tree_lock);
30 spin_lock_init(&tree->hash_lock); 29 spin_lock_init(&tree->hash_lock);
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 315cf44a90b2..d05641c35fc9 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -154,7 +154,6 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)
154 inode->i_gid = current->fsgid; 154 inode->i_gid = current->fsgid;
155 inode->i_nlink = 1; 155 inode->i_nlink = 1;
156 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 156 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
157 inode->i_blksize = HFS_SB(sb)->alloc_blksz;
158 HFS_I(inode)->flags = 0; 157 HFS_I(inode)->flags = 0;
159 HFS_I(inode)->rsrc_inode = NULL; 158 HFS_I(inode)->rsrc_inode = NULL;
160 HFS_I(inode)->fs_blocks = 0; 159 HFS_I(inode)->fs_blocks = 0;
@@ -284,7 +283,6 @@ static int hfs_read_inode(struct inode *inode, void *data)
284 inode->i_uid = hsb->s_uid; 283 inode->i_uid = hsb->s_uid;
285 inode->i_gid = hsb->s_gid; 284 inode->i_gid = hsb->s_gid;
286 inode->i_nlink = 1; 285 inode->i_nlink = 1;
287 inode->i_blksize = HFS_SB(inode->i_sb)->alloc_blksz;
288 286
289 if (idata->key) 287 if (idata->key)
290 HFS_I(inode)->cat_key = *idata->key; 288 HFS_I(inode)->cat_key = *idata->key;
diff --git a/fs/hfs/super.c b/fs/hfs/super.c
index 34937ee83ab1..d43b4fcc8ad3 100644
--- a/fs/hfs/super.c
+++ b/fs/hfs/super.c
@@ -356,11 +356,10 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
356 struct inode *root_inode; 356 struct inode *root_inode;
357 int res; 357 int res;
358 358
359 sbi = kmalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); 359 sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL);
360 if (!sbi) 360 if (!sbi)
361 return -ENOMEM; 361 return -ENOMEM;
362 sb->s_fs_info = sbi; 362 sb->s_fs_info = sbi;
363 memset(sbi, 0, sizeof(struct hfs_sb_info));
364 INIT_HLIST_HEAD(&sbi->rsrc_inodes); 363 INIT_HLIST_HEAD(&sbi->rsrc_inodes);
365 364
366 res = -EINVAL; 365 res = -EINVAL;
@@ -455,8 +454,7 @@ static int __init init_hfs_fs(void)
455static void __exit exit_hfs_fs(void) 454static void __exit exit_hfs_fs(void)
456{ 455{
457 unregister_filesystem(&hfs_fs_type); 456 unregister_filesystem(&hfs_fs_type);
458 if (kmem_cache_destroy(hfs_inode_cachep)) 457 kmem_cache_destroy(hfs_inode_cachep);
459 printk(KERN_ERR "hfs_inode_cache: not all structures were freed\n");
460} 458}
461 459
462module_init(init_hfs_fs) 460module_init(init_hfs_fs)
diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 77bf434da679..29da6574ba77 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -409,10 +409,9 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
409 sb = tree->inode->i_sb; 409 sb = tree->inode->i_sb;
410 size = sizeof(struct hfs_bnode) + tree->pages_per_bnode * 410 size = sizeof(struct hfs_bnode) + tree->pages_per_bnode *
411 sizeof(struct page *); 411 sizeof(struct page *);
412 node = kmalloc(size, GFP_KERNEL); 412 node = kzalloc(size, GFP_KERNEL);
413 if (!node) 413 if (!node)
414 return NULL; 414 return NULL;
415 memset(node, 0, size);
416 node->tree = tree; 415 node->tree = tree;
417 node->this = cnid; 416 node->this = cnid;
418 set_bit(HFS_BNODE_NEW, &node->flags); 417 set_bit(HFS_BNODE_NEW, &node->flags);
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index cfc852fdd1b5..a9b9e872e29a 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -24,10 +24,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
24 struct page *page; 24 struct page *page;
25 unsigned int size; 25 unsigned int size;
26 26
27 tree = kmalloc(sizeof(*tree), GFP_KERNEL); 27 tree = kzalloc(sizeof(*tree), GFP_KERNEL);
28 if (!tree) 28 if (!tree)
29 return NULL; 29 return NULL;
30 memset(tree, 0, sizeof(*tree));
31 30
32 init_MUTEX(&tree->tree_lock); 31 init_MUTEX(&tree->tree_lock);
33 spin_lock_init(&tree->hash_lock); 32 spin_lock_init(&tree->hash_lock);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 924ecdef8091..0eb1a6092668 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -304,7 +304,6 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
304 inode->i_gid = current->fsgid; 304 inode->i_gid = current->fsgid;
305 inode->i_nlink = 1; 305 inode->i_nlink = 1;
306 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 306 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
307 inode->i_blksize = HFSPLUS_SB(sb).alloc_blksz;
308 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); 307 INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
309 init_MUTEX(&HFSPLUS_I(inode).extents_lock); 308 init_MUTEX(&HFSPLUS_I(inode).extents_lock);
310 atomic_set(&HFSPLUS_I(inode).opencnt, 0); 309 atomic_set(&HFSPLUS_I(inode).opencnt, 0);
@@ -407,7 +406,6 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
407 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset); 406 type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset);
408 407
409 HFSPLUS_I(inode).dev = 0; 408 HFSPLUS_I(inode).dev = 0;
410 inode->i_blksize = HFSPLUS_SB(inode->i_sb).alloc_blksz;
411 if (type == HFSPLUS_FOLDER) { 409 if (type == HFSPLUS_FOLDER) {
412 struct hfsplus_cat_folder *folder = &entry.folder; 410 struct hfsplus_cat_folder *folder = &entry.folder;
413 411
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index d279d5924f28..194eede52fa4 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -493,8 +493,7 @@ static int __init init_hfsplus_fs(void)
493static void __exit exit_hfsplus_fs(void) 493static void __exit exit_hfsplus_fs(void)
494{ 494{
495 unregister_filesystem(&hfsplus_fs_type); 495 unregister_filesystem(&hfsplus_fs_type);
496 if (kmem_cache_destroy(hfsplus_inode_cachep)) 496 kmem_cache_destroy(hfsplus_inode_cachep);
497 printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n");
498} 497}
499 498
500module_init(init_hfsplus_fs) 499module_init(init_hfsplus_fs)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index b82e3d9c8790..322e876c35ed 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -156,7 +156,6 @@ static int read_name(struct inode *ino, char *name)
156 ino->i_mode = i_mode; 156 ino->i_mode = i_mode;
157 ino->i_nlink = i_nlink; 157 ino->i_nlink = i_nlink;
158 ino->i_size = i_size; 158 ino->i_size = i_size;
159 ino->i_blksize = i_blksize;
160 ino->i_blocks = i_blocks; 159 ino->i_blocks = i_blocks;
161 return(0); 160 return(0);
162} 161}
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c
index 2807aa833e62..b52b7381d10f 100644
--- a/fs/hpfs/buffer.c
+++ b/fs/hpfs/buffer.c
@@ -76,7 +76,7 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe
76 return NULL; 76 return NULL;
77 } 77 }
78 78
79 qbh->data = data = (char *)kmalloc(2048, GFP_NOFS); 79 qbh->data = data = kmalloc(2048, GFP_NOFS);
80 if (!data) { 80 if (!data) {
81 printk("HPFS: hpfs_map_4sectors: out of memory\n"); 81 printk("HPFS: hpfs_map_4sectors: out of memory\n");
82 goto bail; 82 goto bail;
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 56f2c338c4d9..bcf6ee36e065 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -17,7 +17,6 @@ void hpfs_init_inode(struct inode *i)
17 i->i_gid = hpfs_sb(sb)->sb_gid; 17 i->i_gid = hpfs_sb(sb)->sb_gid;
18 i->i_mode = hpfs_sb(sb)->sb_mode; 18 i->i_mode = hpfs_sb(sb)->sb_mode;
19 hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv; 19 hpfs_inode->i_conv = hpfs_sb(sb)->sb_conv;
20 i->i_blksize = 512;
21 i->i_size = -1; 20 i->i_size = -1;
22 i->i_blocks = -1; 21 i->i_blocks = -1;
23 22
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 8fe51c343786..450b5e0b4785 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -203,8 +203,7 @@ static int init_inodecache(void)
203 203
204static void destroy_inodecache(void) 204static void destroy_inodecache(void)
205{ 205{
206 if (kmem_cache_destroy(hpfs_inode_cachep)) 206 kmem_cache_destroy(hpfs_inode_cachep);
207 printk(KERN_INFO "hpfs_inode_cache: not all structures were freed\n");
208} 207}
209 208
210/* 209/*
@@ -462,11 +461,10 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent)
462 461
463 int o; 462 int o;
464 463
465 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 464 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
466 if (!sbi) 465 if (!sbi)
467 return -ENOMEM; 466 return -ENOMEM;
468 s->s_fs_info = sbi; 467 s->s_fs_info = sbi;
469 memset(sbi, 0, sizeof(*sbi));
470 468
471 sbi->sb_bmp_dir = NULL; 469 sbi->sb_bmp_dir = NULL;
472 sbi->sb_cp_table = NULL; 470 sbi->sb_cp_table = NULL;
diff --git a/fs/hppfs/hppfs_kern.c b/fs/hppfs/hppfs_kern.c
index 3a9bdf58166f..dcb6d2e988b8 100644
--- a/fs/hppfs/hppfs_kern.c
+++ b/fs/hppfs/hppfs_kern.c
@@ -152,7 +152,6 @@ static void hppfs_read_inode(struct inode *ino)
152 ino->i_mode = proc_ino->i_mode; 152 ino->i_mode = proc_ino->i_mode;
153 ino->i_nlink = proc_ino->i_nlink; 153 ino->i_nlink = proc_ino->i_nlink;
154 ino->i_size = proc_ino->i_size; 154 ino->i_size = proc_ino->i_size;
155 ino->i_blksize = proc_ino->i_blksize;
156 ino->i_blocks = proc_ino->i_blocks; 155 ino->i_blocks = proc_ino->i_blocks;
157} 156}
158 157
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index c3920c96dadf..e025a31b4c64 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -357,7 +357,6 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid,
357 inode->i_mode = mode; 357 inode->i_mode = mode;
358 inode->i_uid = uid; 358 inode->i_uid = uid;
359 inode->i_gid = gid; 359 inode->i_gid = gid;
360 inode->i_blksize = HPAGE_SIZE;
361 inode->i_blocks = 0; 360 inode->i_blocks = 0;
362 inode->i_mapping->a_ops = &hugetlbfs_aops; 361 inode->i_mapping->a_ops = &hugetlbfs_aops;
363 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info; 362 inode->i_mapping->backing_dev_info =&hugetlbfs_backing_dev_info;
diff --git a/fs/inode.c b/fs/inode.c
index 0bf9f0444a96..f5c04dd9ae8a 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -163,7 +163,7 @@ static struct inode *alloc_inode(struct super_block *sb)
163 bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info; 163 bdi = sb->s_bdev->bd_inode->i_mapping->backing_dev_info;
164 mapping->backing_dev_info = bdi; 164 mapping->backing_dev_info = bdi;
165 } 165 }
166 memset(&inode->u, 0, sizeof(inode->u)); 166 inode->i_private = 0;
167 inode->i_mapping = mapping; 167 inode->i_mapping = mapping;
168 } 168 }
169 return inode; 169 return inode;
@@ -254,9 +254,9 @@ void clear_inode(struct inode *inode)
254 DQUOT_DROP(inode); 254 DQUOT_DROP(inode);
255 if (inode->i_sb && inode->i_sb->s_op->clear_inode) 255 if (inode->i_sb && inode->i_sb->s_op->clear_inode)
256 inode->i_sb->s_op->clear_inode(inode); 256 inode->i_sb->s_op->clear_inode(inode);
257 if (inode->i_bdev) 257 if (S_ISBLK(inode->i_mode) && inode->i_bdev)
258 bd_forget(inode); 258 bd_forget(inode);
259 if (inode->i_cdev) 259 if (S_ISCHR(inode->i_mode) && inode->i_cdev)
260 cd_forget(inode); 260 cd_forget(inode);
261 inode->i_state = I_CLEAR; 261 inode->i_state = I_CLEAR;
262} 262}
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 14391361c886..4527692f432b 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -96,9 +96,7 @@ static int init_inodecache(void)
96 96
97static void destroy_inodecache(void) 97static void destroy_inodecache(void)
98{ 98{
99 if (kmem_cache_destroy(isofs_inode_cachep)) 99 kmem_cache_destroy(isofs_inode_cachep);
100 printk(KERN_INFO "iso_inode_cache: not all structures were "
101 "freed\n");
102} 100}
103 101
104static int isofs_remount(struct super_block *sb, int *flags, char *data) 102static int isofs_remount(struct super_block *sb, int *flags, char *data)
@@ -557,11 +555,10 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent)
557 struct iso9660_options opt; 555 struct iso9660_options opt;
558 struct isofs_sb_info * sbi; 556 struct isofs_sb_info * sbi;
559 557
560 sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); 558 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
561 if (!sbi) 559 if (!sbi)
562 return -ENOMEM; 560 return -ENOMEM;
563 s->s_fs_info = sbi; 561 s->s_fs_info = sbi;
564 memset(sbi, 0, sizeof(*sbi));
565 562
566 if (!parse_options((char *)data, &opt)) 563 if (!parse_options((char *)data, &opt))
567 goto out_freesbi; 564 goto out_freesbi;
@@ -1238,7 +1235,7 @@ static void isofs_read_inode(struct inode *inode)
1238 } 1235 }
1239 inode->i_uid = sbi->s_uid; 1236 inode->i_uid = sbi->s_uid;
1240 inode->i_gid = sbi->s_gid; 1237 inode->i_gid = sbi->s_gid;
1241 inode->i_blocks = inode->i_blksize = 0; 1238 inode->i_blocks = 0;
1242 1239
1243 ei->i_format_parm[0] = 0; 1240 ei->i_format_parm[0] = 0;
1244 ei->i_format_parm[1] = 0; 1241 ei->i_format_parm[1] = 0;
@@ -1294,7 +1291,6 @@ static void isofs_read_inode(struct inode *inode)
1294 isonum_711 (de->ext_attr_length)); 1291 isonum_711 (de->ext_attr_length));
1295 1292
1296 /* Set the number of blocks for stat() - should be done before RR */ 1293 /* Set the number of blocks for stat() - should be done before RR */
1297 inode->i_blksize = PAGE_CACHE_SIZE; /* For stat() only */
1298 inode->i_blocks = (inode->i_size + 511) >> 9; 1294 inode->i_blocks = (inode->i_size + 511) >> 9;
1299 1295
1300 /* 1296 /*
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index 47678a26c13b..0208cc7ac5d0 100644
--- a/fs/jbd/checkpoint.c
+++ b/fs/jbd/checkpoint.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/fs/checkpoint.c 2 * linux/fs/checkpoint.c
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 * 5 *
6 * Copyright 1999 Red Hat Software --- All Rights Reserved 6 * Copyright 1999 Red Hat Software --- All Rights Reserved
@@ -9,8 +9,8 @@
9 * the terms of the GNU General Public License, version 2, or at your 9 * the terms of the GNU General Public License, version 2, or at your
10 * option, any later version, incorporated herein by reference. 10 * option, any later version, incorporated herein by reference.
11 * 11 *
12 * Checkpoint routines for the generic filesystem journaling code. 12 * Checkpoint routines for the generic filesystem journaling code.
13 * Part of the ext2fs journaling system. 13 * Part of the ext2fs journaling system.
14 * 14 *
15 * Checkpointing is the process of ensuring that a section of the log is 15 * Checkpointing is the process of ensuring that a section of the log is
16 * committed fully to disk, so that that portion of the log can be 16 * committed fully to disk, so that that portion of the log can be
@@ -145,6 +145,7 @@ void __log_wait_for_space(journal_t *journal)
145 * jbd_unlock_bh_state(). 145 * jbd_unlock_bh_state().
146 */ 146 */
147static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) 147static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh)
148 __releases(journal->j_list_lock)
148{ 149{
149 get_bh(bh); 150 get_bh(bh);
150 spin_unlock(&journal->j_list_lock); 151 spin_unlock(&journal->j_list_lock);
@@ -225,7 +226,7 @@ __flush_batch(journal_t *journal, struct buffer_head **bhs, int *batch_count)
225 * Try to flush one buffer from the checkpoint list to disk. 226 * Try to flush one buffer from the checkpoint list to disk.
226 * 227 *
227 * Return 1 if something happened which requires us to abort the current 228 * Return 1 if something happened which requires us to abort the current
228 * scan of the checkpoint list. 229 * scan of the checkpoint list.
229 * 230 *
230 * Called with j_list_lock held and drops it if 1 is returned 231 * Called with j_list_lock held and drops it if 1 is returned
231 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it 232 * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it
@@ -269,7 +270,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
269 * possibly block, while still holding the journal lock. 270 * possibly block, while still holding the journal lock.
270 * We cannot afford to let the transaction logic start 271 * We cannot afford to let the transaction logic start
271 * messing around with this buffer before we write it to 272 * messing around with this buffer before we write it to
272 * disk, as that would break recoverability. 273 * disk, as that would break recoverability.
273 */ 274 */
274 BUFFER_TRACE(bh, "queue"); 275 BUFFER_TRACE(bh, "queue");
275 get_bh(bh); 276 get_bh(bh);
@@ -292,7 +293,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh,
292 * Perform an actual checkpoint. We take the first transaction on the 293 * Perform an actual checkpoint. We take the first transaction on the
293 * list of transactions to be checkpointed and send all its buffers 294 * list of transactions to be checkpointed and send all its buffers
294 * to disk. We submit larger chunks of data at once. 295 * to disk. We submit larger chunks of data at once.
295 * 296 *
296 * The journal should be locked before calling this function. 297 * The journal should be locked before calling this function.
297 */ 298 */
298int log_do_checkpoint(journal_t *journal) 299int log_do_checkpoint(journal_t *journal)
@@ -303,10 +304,10 @@ int log_do_checkpoint(journal_t *journal)
303 304
304 jbd_debug(1, "Start checkpoint\n"); 305 jbd_debug(1, "Start checkpoint\n");
305 306
306 /* 307 /*
307 * First thing: if there are any transactions in the log which 308 * First thing: if there are any transactions in the log which
308 * don't need checkpointing, just eliminate them from the 309 * don't need checkpointing, just eliminate them from the
309 * journal straight away. 310 * journal straight away.
310 */ 311 */
311 result = cleanup_journal_tail(journal); 312 result = cleanup_journal_tail(journal);
312 jbd_debug(1, "cleanup_journal_tail returned %d\n", result); 313 jbd_debug(1, "cleanup_journal_tail returned %d\n", result);
@@ -384,9 +385,9 @@ out:
384 * we have already got rid of any since the last update of the log tail 385 * we have already got rid of any since the last update of the log tail
385 * in the journal superblock. If so, we can instantly roll the 386 * in the journal superblock. If so, we can instantly roll the
386 * superblock forward to remove those transactions from the log. 387 * superblock forward to remove those transactions from the log.
387 * 388 *
388 * Return <0 on error, 0 on success, 1 if there was nothing to clean up. 389 * Return <0 on error, 0 on success, 1 if there was nothing to clean up.
389 * 390 *
390 * Called with the journal lock held. 391 * Called with the journal lock held.
391 * 392 *
392 * This is the only part of the journaling code which really needs to be 393 * This is the only part of the journaling code which really needs to be
@@ -403,8 +404,8 @@ int cleanup_journal_tail(journal_t *journal)
403 unsigned long blocknr, freed; 404 unsigned long blocknr, freed;
404 405
405 /* OK, work out the oldest transaction remaining in the log, and 406 /* OK, work out the oldest transaction remaining in the log, and
406 * the log block it starts at. 407 * the log block it starts at.
407 * 408 *
408 * If the log is now empty, we need to work out which is the 409 * If the log is now empty, we need to work out which is the
409 * next transaction ID we will write, and where it will 410 * next transaction ID we will write, and where it will
410 * start. */ 411 * start. */
@@ -479,7 +480,7 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released)
479 if (!jh) 480 if (!jh)
480 return 0; 481 return 0;
481 482
482 last_jh = jh->b_cpprev; 483 last_jh = jh->b_cpprev;
483 do { 484 do {
484 jh = next_jh; 485 jh = next_jh;
485 next_jh = jh->b_cpnext; 486 next_jh = jh->b_cpnext;
@@ -557,7 +558,7 @@ out:
557 return ret; 558 return ret;
558} 559}
559 560
560/* 561/*
561 * journal_remove_checkpoint: called after a buffer has been committed 562 * journal_remove_checkpoint: called after a buffer has been committed
562 * to disk (either by being write-back flushed to disk, or being 563 * to disk (either by being write-back flushed to disk, or being
563 * committed to the log). 564 * committed to the log).
@@ -635,7 +636,7 @@ out:
635 * Called with the journal locked. 636 * Called with the journal locked.
636 * Called with j_list_lock held. 637 * Called with j_list_lock held.
637 */ 638 */
638void __journal_insert_checkpoint(struct journal_head *jh, 639void __journal_insert_checkpoint(struct journal_head *jh,
639 transaction_t *transaction) 640 transaction_t *transaction)
640{ 641{
641 JBUFFER_TRACE(jh, "entry"); 642 JBUFFER_TRACE(jh, "entry");
@@ -657,7 +658,7 @@ void __journal_insert_checkpoint(struct journal_head *jh,
657 658
658/* 659/*
659 * We've finished with this transaction structure: adios... 660 * We've finished with this transaction structure: adios...
660 * 661 *
661 * The transaction must have no links except for the checkpoint by this 662 * The transaction must have no links except for the checkpoint by this
662 * point. 663 * point.
663 * 664 *
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index f66724ce443a..2fc66c3e6681 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -181,7 +181,7 @@ loop:
181 transaction->t_expires)) 181 transaction->t_expires))
182 should_sleep = 0; 182 should_sleep = 0;
183 if (journal->j_flags & JFS_UNMOUNT) 183 if (journal->j_flags & JFS_UNMOUNT)
184 should_sleep = 0; 184 should_sleep = 0;
185 if (should_sleep) { 185 if (should_sleep) {
186 spin_unlock(&journal->j_state_lock); 186 spin_unlock(&journal->j_state_lock);
187 schedule(); 187 schedule();
@@ -271,7 +271,7 @@ static void journal_kill_thread(journal_t *journal)
271int journal_write_metadata_buffer(transaction_t *transaction, 271int journal_write_metadata_buffer(transaction_t *transaction,
272 struct journal_head *jh_in, 272 struct journal_head *jh_in,
273 struct journal_head **jh_out, 273 struct journal_head **jh_out,
274 int blocknr) 274 unsigned long blocknr)
275{ 275{
276 int need_copy_out = 0; 276 int need_copy_out = 0;
277 int done_copy_out = 0; 277 int done_copy_out = 0;
@@ -578,7 +578,7 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp)
578 * this is a no-op. If needed, we can use j_blk_offset - everything is 578 * this is a no-op. If needed, we can use j_blk_offset - everything is
579 * ready. 579 * ready.
580 */ 580 */
581int journal_bmap(journal_t *journal, unsigned long blocknr, 581int journal_bmap(journal_t *journal, unsigned long blocknr,
582 unsigned long *retp) 582 unsigned long *retp)
583{ 583{
584 int err = 0; 584 int err = 0;
@@ -696,13 +696,13 @@ fail:
696 * @bdev: Block device on which to create the journal 696 * @bdev: Block device on which to create the journal
697 * @fs_dev: Device which hold journalled filesystem for this journal. 697 * @fs_dev: Device which hold journalled filesystem for this journal.
698 * @start: Block nr Start of journal. 698 * @start: Block nr Start of journal.
699 * @len: Lenght of the journal in blocks. 699 * @len: Length of the journal in blocks.
700 * @blocksize: blocksize of journalling device 700 * @blocksize: blocksize of journalling device
701 * @returns: a newly created journal_t * 701 * @returns: a newly created journal_t *
702 * 702 *
703 * journal_init_dev creates a journal which maps a fixed contiguous 703 * journal_init_dev creates a journal which maps a fixed contiguous
704 * range of blocks on an arbitrary block device. 704 * range of blocks on an arbitrary block device.
705 * 705 *
706 */ 706 */
707journal_t * journal_init_dev(struct block_device *bdev, 707journal_t * journal_init_dev(struct block_device *bdev,
708 struct block_device *fs_dev, 708 struct block_device *fs_dev,
@@ -739,11 +739,11 @@ journal_t * journal_init_dev(struct block_device *bdev,
739 739
740 return journal; 740 return journal;
741} 741}
742 742
743/** 743/**
744 * journal_t * journal_init_inode () - creates a journal which maps to a inode. 744 * journal_t * journal_init_inode () - creates a journal which maps to a inode.
745 * @inode: An inode to create the journal in 745 * @inode: An inode to create the journal in
746 * 746 *
747 * journal_init_inode creates a journal which maps an on-disk inode as 747 * journal_init_inode creates a journal which maps an on-disk inode as
748 * the journal. The inode must exist already, must support bmap() and 748 * the journal. The inode must exist already, must support bmap() and
749 * must have all data blocks preallocated. 749 * must have all data blocks preallocated.
@@ -763,7 +763,7 @@ journal_t * journal_init_inode (struct inode *inode)
763 journal->j_inode = inode; 763 journal->j_inode = inode;
764 jbd_debug(1, 764 jbd_debug(1,
765 "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", 765 "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n",
766 journal, inode->i_sb->s_id, inode->i_ino, 766 journal, inode->i_sb->s_id, inode->i_ino,
767 (long long) inode->i_size, 767 (long long) inode->i_size,
768 inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize); 768 inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize);
769 769
@@ -798,10 +798,10 @@ journal_t * journal_init_inode (struct inode *inode)
798 return journal; 798 return journal;
799} 799}
800 800
801/* 801/*
802 * If the journal init or create aborts, we need to mark the journal 802 * If the journal init or create aborts, we need to mark the journal
803 * superblock as being NULL to prevent the journal destroy from writing 803 * superblock as being NULL to prevent the journal destroy from writing
804 * back a bogus superblock. 804 * back a bogus superblock.
805 */ 805 */
806static void journal_fail_superblock (journal_t *journal) 806static void journal_fail_superblock (journal_t *journal)
807{ 807{
@@ -820,7 +820,7 @@ static void journal_fail_superblock (journal_t *journal)
820static int journal_reset(journal_t *journal) 820static int journal_reset(journal_t *journal)
821{ 821{
822 journal_superblock_t *sb = journal->j_superblock; 822 journal_superblock_t *sb = journal->j_superblock;
823 unsigned int first, last; 823 unsigned long first, last;
824 824
825 first = be32_to_cpu(sb->s_first); 825 first = be32_to_cpu(sb->s_first);
826 last = be32_to_cpu(sb->s_maxlen); 826 last = be32_to_cpu(sb->s_maxlen);
@@ -844,13 +844,13 @@ static int journal_reset(journal_t *journal)
844 return 0; 844 return 0;
845} 845}
846 846
847/** 847/**
848 * int journal_create() - Initialise the new journal file 848 * int journal_create() - Initialise the new journal file
849 * @journal: Journal to create. This structure must have been initialised 849 * @journal: Journal to create. This structure must have been initialised
850 * 850 *
851 * Given a journal_t structure which tells us which disk blocks we can 851 * Given a journal_t structure which tells us which disk blocks we can
852 * use, create a new journal superblock and initialise all of the 852 * use, create a new journal superblock and initialise all of the
853 * journal fields from scratch. 853 * journal fields from scratch.
854 **/ 854 **/
855int journal_create(journal_t *journal) 855int journal_create(journal_t *journal)
856{ 856{
@@ -915,7 +915,7 @@ int journal_create(journal_t *journal)
915 return journal_reset(journal); 915 return journal_reset(journal);
916} 916}
917 917
918/** 918/**
919 * void journal_update_superblock() - Update journal sb on disk. 919 * void journal_update_superblock() - Update journal sb on disk.
920 * @journal: The journal to update. 920 * @journal: The journal to update.
921 * @wait: Set to '0' if you don't want to wait for IO completion. 921 * @wait: Set to '0' if you don't want to wait for IO completion.
@@ -939,7 +939,7 @@ void journal_update_superblock(journal_t *journal, int wait)
939 journal->j_transaction_sequence) { 939 journal->j_transaction_sequence) {
940 jbd_debug(1,"JBD: Skipping superblock update on recovered sb " 940 jbd_debug(1,"JBD: Skipping superblock update on recovered sb "
941 "(start %ld, seq %d, errno %d)\n", 941 "(start %ld, seq %d, errno %d)\n",
942 journal->j_tail, journal->j_tail_sequence, 942 journal->j_tail, journal->j_tail_sequence,
943 journal->j_errno); 943 journal->j_errno);
944 goto out; 944 goto out;
945 } 945 }
@@ -1062,7 +1062,7 @@ static int load_superblock(journal_t *journal)
1062/** 1062/**
1063 * int journal_load() - Read journal from disk. 1063 * int journal_load() - Read journal from disk.
1064 * @journal: Journal to act on. 1064 * @journal: Journal to act on.
1065 * 1065 *
1066 * Given a journal_t structure which tells us which disk blocks contain 1066 * Given a journal_t structure which tells us which disk blocks contain
1067 * a journal, read the journal from disk to initialise the in-memory 1067 * a journal, read the journal from disk to initialise the in-memory
1068 * structures. 1068 * structures.
@@ -1094,7 +1094,7 @@ int journal_load(journal_t *journal)
1094 /* 1094 /*
1095 * Create a slab for this blocksize 1095 * Create a slab for this blocksize
1096 */ 1096 */
1097 err = journal_create_jbd_slab(cpu_to_be32(sb->s_blocksize)); 1097 err = journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize));
1098 if (err) 1098 if (err)
1099 return err; 1099 return err;
1100 1100
@@ -1172,9 +1172,9 @@ void journal_destroy(journal_t *journal)
1172 * @compat: bitmask of compatible features 1172 * @compat: bitmask of compatible features
1173 * @ro: bitmask of features that force read-only mount 1173 * @ro: bitmask of features that force read-only mount
1174 * @incompat: bitmask of incompatible features 1174 * @incompat: bitmask of incompatible features
1175 * 1175 *
1176 * Check whether the journal uses all of a given set of 1176 * Check whether the journal uses all of a given set of
1177 * features. Return true (non-zero) if it does. 1177 * features. Return true (non-zero) if it does.
1178 **/ 1178 **/
1179 1179
1180int journal_check_used_features (journal_t *journal, unsigned long compat, 1180int journal_check_used_features (journal_t *journal, unsigned long compat,
@@ -1203,7 +1203,7 @@ int journal_check_used_features (journal_t *journal, unsigned long compat,
1203 * @compat: bitmask of compatible features 1203 * @compat: bitmask of compatible features
1204 * @ro: bitmask of features that force read-only mount 1204 * @ro: bitmask of features that force read-only mount
1205 * @incompat: bitmask of incompatible features 1205 * @incompat: bitmask of incompatible features
1206 * 1206 *
1207 * Check whether the journaling code supports the use of 1207 * Check whether the journaling code supports the use of
1208 * all of a given set of features on this journal. Return true 1208 * all of a given set of features on this journal. Return true
1209 * (non-zero) if it can. */ 1209 * (non-zero) if it can. */
@@ -1241,7 +1241,7 @@ int journal_check_available_features (journal_t *journal, unsigned long compat,
1241 * @incompat: bitmask of incompatible features 1241 * @incompat: bitmask of incompatible features
1242 * 1242 *
1243 * Mark a given journal feature as present on the 1243 * Mark a given journal feature as present on the
1244 * superblock. Returns true if the requested features could be set. 1244 * superblock. Returns true if the requested features could be set.
1245 * 1245 *
1246 */ 1246 */
1247 1247
@@ -1327,7 +1327,7 @@ static int journal_convert_superblock_v1(journal_t *journal,
1327/** 1327/**
1328 * int journal_flush () - Flush journal 1328 * int journal_flush () - Flush journal
1329 * @journal: Journal to act on. 1329 * @journal: Journal to act on.
1330 * 1330 *
1331 * Flush all data for a given journal to disk and empty the journal. 1331 * Flush all data for a given journal to disk and empty the journal.
1332 * Filesystems can use this when remounting readonly to ensure that 1332 * Filesystems can use this when remounting readonly to ensure that
1333 * recovery does not need to happen on remount. 1333 * recovery does not need to happen on remount.
@@ -1394,7 +1394,7 @@ int journal_flush(journal_t *journal)
1394 * int journal_wipe() - Wipe journal contents 1394 * int journal_wipe() - Wipe journal contents
1395 * @journal: Journal to act on. 1395 * @journal: Journal to act on.
1396 * @write: flag (see below) 1396 * @write: flag (see below)
1397 * 1397 *
1398 * Wipe out all of the contents of a journal, safely. This will produce 1398 * Wipe out all of the contents of a journal, safely. This will produce
1399 * a warning if the journal contains any valid recovery information. 1399 * a warning if the journal contains any valid recovery information.
1400 * Must be called between journal_init_*() and journal_load(). 1400 * Must be called between journal_init_*() and journal_load().
@@ -1449,7 +1449,7 @@ static const char *journal_dev_name(journal_t *journal, char *buffer)
1449 1449
1450/* 1450/*
1451 * Journal abort has very specific semantics, which we describe 1451 * Journal abort has very specific semantics, which we describe
1452 * for journal abort. 1452 * for journal abort.
1453 * 1453 *
1454 * Two internal function, which provide abort to te jbd layer 1454 * Two internal function, which provide abort to te jbd layer
1455 * itself are here. 1455 * itself are here.
@@ -1504,7 +1504,7 @@ static void __journal_abort_soft (journal_t *journal, int errno)
1504 * Perform a complete, immediate shutdown of the ENTIRE 1504 * Perform a complete, immediate shutdown of the ENTIRE
1505 * journal (not of a single transaction). This operation cannot be 1505 * journal (not of a single transaction). This operation cannot be
1506 * undone without closing and reopening the journal. 1506 * undone without closing and reopening the journal.
1507 * 1507 *
1508 * The journal_abort function is intended to support higher level error 1508 * The journal_abort function is intended to support higher level error
1509 * recovery mechanisms such as the ext2/ext3 remount-readonly error 1509 * recovery mechanisms such as the ext2/ext3 remount-readonly error
1510 * mode. 1510 * mode.
@@ -1538,7 +1538,7 @@ static void __journal_abort_soft (journal_t *journal, int errno)
1538 * supply an errno; a null errno implies that absolutely no further 1538 * supply an errno; a null errno implies that absolutely no further
1539 * writes are done to the journal (unless there are any already in 1539 * writes are done to the journal (unless there are any already in
1540 * progress). 1540 * progress).
1541 * 1541 *
1542 */ 1542 */
1543 1543
1544void journal_abort(journal_t *journal, int errno) 1544void journal_abort(journal_t *journal, int errno)
@@ -1546,7 +1546,7 @@ void journal_abort(journal_t *journal, int errno)
1546 __journal_abort_soft(journal, errno); 1546 __journal_abort_soft(journal, errno);
1547} 1547}
1548 1548
1549/** 1549/**
1550 * int journal_errno () - returns the journal's error state. 1550 * int journal_errno () - returns the journal's error state.
1551 * @journal: journal to examine. 1551 * @journal: journal to examine.
1552 * 1552 *
@@ -1570,7 +1570,7 @@ int journal_errno(journal_t *journal)
1570 return err; 1570 return err;
1571} 1571}
1572 1572
1573/** 1573/**
1574 * int journal_clear_err () - clears the journal's error state 1574 * int journal_clear_err () - clears the journal's error state
1575 * @journal: journal to act on. 1575 * @journal: journal to act on.
1576 * 1576 *
@@ -1590,7 +1590,7 @@ int journal_clear_err(journal_t *journal)
1590 return err; 1590 return err;
1591} 1591}
1592 1592
1593/** 1593/**
1594 * void journal_ack_err() - Ack journal err. 1594 * void journal_ack_err() - Ack journal err.
1595 * @journal: journal to act on. 1595 * @journal: journal to act on.
1596 * 1596 *
@@ -1612,7 +1612,7 @@ int journal_blocks_per_page(struct inode *inode)
1612 1612
1613/* 1613/*
1614 * Simple support for retrying memory allocations. Introduced to help to 1614 * Simple support for retrying memory allocations. Introduced to help to
1615 * debug different VM deadlock avoidance strategies. 1615 * debug different VM deadlock avoidance strategies.
1616 */ 1616 */
1617void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry) 1617void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1618{ 1618{
@@ -2047,13 +2047,7 @@ static int __init journal_init(void)
2047{ 2047{
2048 int ret; 2048 int ret;
2049 2049
2050/* Static check for data structure consistency. There's no code 2050 BUILD_BUG_ON(sizeof(struct journal_superblock_s) != 1024);
2051 * invoked --- we'll just get a linker failure if things aren't right.
2052 */
2053 extern void journal_bad_superblock_size(void);
2054 if (sizeof(struct journal_superblock_s) != 1024)
2055 journal_bad_superblock_size();
2056
2057 2051
2058 ret = journal_init_caches(); 2052 ret = journal_init_caches();
2059 if (ret != 0) 2053 if (ret != 0)
diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c
index de5bafb4e853..445eed6ce5dc 100644
--- a/fs/jbd/recovery.c
+++ b/fs/jbd/recovery.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/fs/recovery.c 2 * linux/fs/recovery.c
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1999
5 * 5 *
6 * Copyright 1999-2000 Red Hat Software --- All Rights Reserved 6 * Copyright 1999-2000 Red Hat Software --- All Rights Reserved
@@ -10,7 +10,7 @@
10 * option, any later version, incorporated herein by reference. 10 * option, any later version, incorporated herein by reference.
11 * 11 *
12 * Journal recovery routines for the generic filesystem journaling code; 12 * Journal recovery routines for the generic filesystem journaling code;
13 * part of the ext2fs journaling system. 13 * part of the ext2fs journaling system.
14 */ 14 */
15 15
16#ifndef __KERNEL__ 16#ifndef __KERNEL__
@@ -25,9 +25,9 @@
25 25
26/* 26/*
27 * Maintain information about the progress of the recovery job, so that 27 * Maintain information about the progress of the recovery job, so that
28 * the different passes can carry information between them. 28 * the different passes can carry information between them.
29 */ 29 */
30struct recovery_info 30struct recovery_info
31{ 31{
32 tid_t start_transaction; 32 tid_t start_transaction;
33 tid_t end_transaction; 33 tid_t end_transaction;
@@ -116,7 +116,7 @@ static int do_readahead(journal_t *journal, unsigned int start)
116 err = 0; 116 err = 0;
117 117
118failed: 118failed:
119 if (nbufs) 119 if (nbufs)
120 journal_brelse_array(bufs, nbufs); 120 journal_brelse_array(bufs, nbufs);
121 return err; 121 return err;
122} 122}
@@ -128,7 +128,7 @@ failed:
128 * Read a block from the journal 128 * Read a block from the journal
129 */ 129 */
130 130
131static int jread(struct buffer_head **bhp, journal_t *journal, 131static int jread(struct buffer_head **bhp, journal_t *journal,
132 unsigned int offset) 132 unsigned int offset)
133{ 133{
134 int err; 134 int err;
@@ -212,14 +212,14 @@ do { \
212/** 212/**
213 * journal_recover - recovers a on-disk journal 213 * journal_recover - recovers a on-disk journal
214 * @journal: the journal to recover 214 * @journal: the journal to recover
215 * 215 *
216 * The primary function for recovering the log contents when mounting a 216 * The primary function for recovering the log contents when mounting a
217 * journaled device. 217 * journaled device.
218 * 218 *
219 * Recovery is done in three passes. In the first pass, we look for the 219 * Recovery is done in three passes. In the first pass, we look for the
220 * end of the log. In the second, we assemble the list of revoke 220 * end of the log. In the second, we assemble the list of revoke
221 * blocks. In the third and final pass, we replay any un-revoked blocks 221 * blocks. In the third and final pass, we replay any un-revoked blocks
222 * in the log. 222 * in the log.
223 */ 223 */
224int journal_recover(journal_t *journal) 224int journal_recover(journal_t *journal)
225{ 225{
@@ -231,10 +231,10 @@ int journal_recover(journal_t *journal)
231 memset(&info, 0, sizeof(info)); 231 memset(&info, 0, sizeof(info));
232 sb = journal->j_superblock; 232 sb = journal->j_superblock;
233 233
234 /* 234 /*
235 * The journal superblock's s_start field (the current log head) 235 * The journal superblock's s_start field (the current log head)
236 * is always zero if, and only if, the journal was cleanly 236 * is always zero if, and only if, the journal was cleanly
237 * unmounted. 237 * unmounted.
238 */ 238 */
239 239
240 if (!sb->s_start) { 240 if (!sb->s_start) {
@@ -253,7 +253,7 @@ int journal_recover(journal_t *journal)
253 jbd_debug(0, "JBD: recovery, exit status %d, " 253 jbd_debug(0, "JBD: recovery, exit status %d, "
254 "recovered transactions %u to %u\n", 254 "recovered transactions %u to %u\n",
255 err, info.start_transaction, info.end_transaction); 255 err, info.start_transaction, info.end_transaction);
256 jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n", 256 jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n",
257 info.nr_replays, info.nr_revoke_hits, info.nr_revokes); 257 info.nr_replays, info.nr_revoke_hits, info.nr_revokes);
258 258
259 /* Restart the log at the next transaction ID, thus invalidating 259 /* Restart the log at the next transaction ID, thus invalidating
@@ -268,15 +268,15 @@ int journal_recover(journal_t *journal)
268/** 268/**
269 * journal_skip_recovery - Start journal and wipe exiting records 269 * journal_skip_recovery - Start journal and wipe exiting records
270 * @journal: journal to startup 270 * @journal: journal to startup
271 * 271 *
272 * Locate any valid recovery information from the journal and set up the 272 * Locate any valid recovery information from the journal and set up the
273 * journal structures in memory to ignore it (presumably because the 273 * journal structures in memory to ignore it (presumably because the
274 * caller has evidence that it is out of date). 274 * caller has evidence that it is out of date).
275 * This function does'nt appear to be exorted.. 275 * This function does'nt appear to be exorted..
276 * 276 *
277 * We perform one pass over the journal to allow us to tell the user how 277 * We perform one pass over the journal to allow us to tell the user how
278 * much recovery information is being erased, and to let us initialise 278 * much recovery information is being erased, and to let us initialise
279 * the journal transaction sequence numbers to the next unused ID. 279 * the journal transaction sequence numbers to the next unused ID.
280 */ 280 */
281int journal_skip_recovery(journal_t *journal) 281int journal_skip_recovery(journal_t *journal)
282{ 282{
@@ -297,7 +297,7 @@ int journal_skip_recovery(journal_t *journal)
297#ifdef CONFIG_JBD_DEBUG 297#ifdef CONFIG_JBD_DEBUG
298 int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence); 298 int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence);
299#endif 299#endif
300 jbd_debug(0, 300 jbd_debug(0,
301 "JBD: ignoring %d transaction%s from the journal.\n", 301 "JBD: ignoring %d transaction%s from the journal.\n",
302 dropped, (dropped == 1) ? "" : "s"); 302 dropped, (dropped == 1) ? "" : "s");
303 journal->j_transaction_sequence = ++info.end_transaction; 303 journal->j_transaction_sequence = ++info.end_transaction;
@@ -314,7 +314,7 @@ static int do_one_pass(journal_t *journal,
314 unsigned long next_log_block; 314 unsigned long next_log_block;
315 int err, success = 0; 315 int err, success = 0;
316 journal_superblock_t * sb; 316 journal_superblock_t * sb;
317 journal_header_t * tmp; 317 journal_header_t * tmp;
318 struct buffer_head * bh; 318 struct buffer_head * bh;
319 unsigned int sequence; 319 unsigned int sequence;
320 int blocktype; 320 int blocktype;
@@ -324,10 +324,10 @@ static int do_one_pass(journal_t *journal,
324 MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t)) 324 MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t))
325 / sizeof(journal_block_tag_t)); 325 / sizeof(journal_block_tag_t));
326 326
327 /* 327 /*
328 * First thing is to establish what we expect to find in the log 328 * First thing is to establish what we expect to find in the log
329 * (in terms of transaction IDs), and where (in terms of log 329 * (in terms of transaction IDs), and where (in terms of log
330 * block offsets): query the superblock. 330 * block offsets): query the superblock.
331 */ 331 */
332 332
333 sb = journal->j_superblock; 333 sb = journal->j_superblock;
@@ -344,7 +344,7 @@ static int do_one_pass(journal_t *journal,
344 * Now we walk through the log, transaction by transaction, 344 * Now we walk through the log, transaction by transaction,
345 * making sure that each transaction has a commit block in the 345 * making sure that each transaction has a commit block in the
346 * expected place. Each complete transaction gets replayed back 346 * expected place. Each complete transaction gets replayed back
347 * into the main filesystem. 347 * into the main filesystem.
348 */ 348 */
349 349
350 while (1) { 350 while (1) {
@@ -379,8 +379,8 @@ static int do_one_pass(journal_t *journal,
379 next_log_block++; 379 next_log_block++;
380 wrap(journal, next_log_block); 380 wrap(journal, next_log_block);
381 381
382 /* What kind of buffer is it? 382 /* What kind of buffer is it?
383 * 383 *
384 * If it is a descriptor block, check that it has the 384 * If it is a descriptor block, check that it has the
385 * expected sequence number. Otherwise, we're all done 385 * expected sequence number. Otherwise, we're all done
386 * here. */ 386 * here. */
@@ -394,7 +394,7 @@ static int do_one_pass(journal_t *journal,
394 394
395 blocktype = be32_to_cpu(tmp->h_blocktype); 395 blocktype = be32_to_cpu(tmp->h_blocktype);
396 sequence = be32_to_cpu(tmp->h_sequence); 396 sequence = be32_to_cpu(tmp->h_sequence);
397 jbd_debug(3, "Found magic %d, sequence %d\n", 397 jbd_debug(3, "Found magic %d, sequence %d\n",
398 blocktype, sequence); 398 blocktype, sequence);
399 399
400 if (sequence != next_commit_ID) { 400 if (sequence != next_commit_ID) {
@@ -438,7 +438,7 @@ static int do_one_pass(journal_t *journal,
438 /* Recover what we can, but 438 /* Recover what we can, but
439 * report failure at the end. */ 439 * report failure at the end. */
440 success = err; 440 success = err;
441 printk (KERN_ERR 441 printk (KERN_ERR
442 "JBD: IO error %d recovering " 442 "JBD: IO error %d recovering "
443 "block %ld in log\n", 443 "block %ld in log\n",
444 err, io_block); 444 err, io_block);
@@ -452,7 +452,7 @@ static int do_one_pass(journal_t *journal,
452 * revoked, then we're all done 452 * revoked, then we're all done
453 * here. */ 453 * here. */
454 if (journal_test_revoke 454 if (journal_test_revoke
455 (journal, blocknr, 455 (journal, blocknr,
456 next_commit_ID)) { 456 next_commit_ID)) {
457 brelse(obh); 457 brelse(obh);
458 ++info->nr_revoke_hits; 458 ++info->nr_revoke_hits;
@@ -465,7 +465,7 @@ static int do_one_pass(journal_t *journal,
465 blocknr, 465 blocknr,
466 journal->j_blocksize); 466 journal->j_blocksize);
467 if (nbh == NULL) { 467 if (nbh == NULL) {
468 printk(KERN_ERR 468 printk(KERN_ERR
469 "JBD: Out of memory " 469 "JBD: Out of memory "
470 "during recovery.\n"); 470 "during recovery.\n");
471 err = -ENOMEM; 471 err = -ENOMEM;
@@ -537,7 +537,7 @@ static int do_one_pass(journal_t *journal,
537 } 537 }
538 538
539 done: 539 done:
540 /* 540 /*
541 * We broke out of the log scan loop: either we came to the 541 * We broke out of the log scan loop: either we came to the
542 * known end of the log or we found an unexpected block in the 542 * known end of the log or we found an unexpected block in the
543 * log. If the latter happened, then we know that the "current" 543 * log. If the latter happened, then we know that the "current"
@@ -567,7 +567,7 @@ static int do_one_pass(journal_t *journal,
567 567
568/* Scan a revoke record, marking all blocks mentioned as revoked. */ 568/* Scan a revoke record, marking all blocks mentioned as revoked. */
569 569
570static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, 570static int scan_revoke_records(journal_t *journal, struct buffer_head *bh,
571 tid_t sequence, struct recovery_info *info) 571 tid_t sequence, struct recovery_info *info)
572{ 572{
573 journal_revoke_header_t *header; 573 journal_revoke_header_t *header;
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c
index a56144183462..c532429d8d9b 100644
--- a/fs/jbd/revoke.c
+++ b/fs/jbd/revoke.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/fs/revoke.c 2 * linux/fs/revoke.c
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 2000 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 2000
5 * 5 *
6 * Copyright 2000 Red Hat corp --- All Rights Reserved 6 * Copyright 2000 Red Hat corp --- All Rights Reserved
@@ -15,10 +15,10 @@
15 * Revoke is the mechanism used to prevent old log records for deleted 15 * Revoke is the mechanism used to prevent old log records for deleted
16 * metadata from being replayed on top of newer data using the same 16 * metadata from being replayed on top of newer data using the same
17 * blocks. The revoke mechanism is used in two separate places: 17 * blocks. The revoke mechanism is used in two separate places:
18 * 18 *
19 * + Commit: during commit we write the entire list of the current 19 * + Commit: during commit we write the entire list of the current
20 * transaction's revoked blocks to the journal 20 * transaction's revoked blocks to the journal
21 * 21 *
22 * + Recovery: during recovery we record the transaction ID of all 22 * + Recovery: during recovery we record the transaction ID of all
23 * revoked blocks. If there are multiple revoke records in the log 23 * revoked blocks. If there are multiple revoke records in the log
24 * for a single block, only the last one counts, and if there is a log 24 * for a single block, only the last one counts, and if there is a log
@@ -29,7 +29,7 @@
29 * single transaction: 29 * single transaction:
30 * 30 *
31 * Block is revoked and then journaled: 31 * Block is revoked and then journaled:
32 * The desired end result is the journaling of the new block, so we 32 * The desired end result is the journaling of the new block, so we
33 * cancel the revoke before the transaction commits. 33 * cancel the revoke before the transaction commits.
34 * 34 *
35 * Block is journaled and then revoked: 35 * Block is journaled and then revoked:
@@ -41,7 +41,7 @@
41 * transaction must have happened after the block was journaled and so 41 * transaction must have happened after the block was journaled and so
42 * the revoke must take precedence. 42 * the revoke must take precedence.
43 * 43 *
44 * Block is revoked and then written as data: 44 * Block is revoked and then written as data:
45 * The data write is allowed to succeed, but the revoke is _not_ 45 * The data write is allowed to succeed, but the revoke is _not_
46 * cancelled. We still need to prevent old log records from 46 * cancelled. We still need to prevent old log records from
47 * overwriting the new data. We don't even need to clear the revoke 47 * overwriting the new data. We don't even need to clear the revoke
@@ -54,7 +54,7 @@
54 * buffer has not been revoked, and cancel_revoke 54 * buffer has not been revoked, and cancel_revoke
55 * need do nothing. 55 * need do nothing.
56 * RevokeValid set, Revoked set: 56 * RevokeValid set, Revoked set:
57 * buffer has been revoked. 57 * buffer has been revoked.
58 */ 58 */
59 59
60#ifndef __KERNEL__ 60#ifndef __KERNEL__
@@ -77,7 +77,7 @@ static kmem_cache_t *revoke_table_cache;
77 journal replay, this involves recording the transaction ID of the 77 journal replay, this involves recording the transaction ID of the
78 last transaction to revoke this block. */ 78 last transaction to revoke this block. */
79 79
80struct jbd_revoke_record_s 80struct jbd_revoke_record_s
81{ 81{
82 struct list_head hash; 82 struct list_head hash;
83 tid_t sequence; /* Used for recovery only */ 83 tid_t sequence; /* Used for recovery only */
@@ -90,8 +90,8 @@ struct jbd_revoke_table_s
90{ 90{
91 /* It is conceivable that we might want a larger hash table 91 /* It is conceivable that we might want a larger hash table
92 * for recovery. Must be a power of two. */ 92 * for recovery. Must be a power of two. */
93 int hash_size; 93 int hash_size;
94 int hash_shift; 94 int hash_shift;
95 struct list_head *hash_table; 95 struct list_head *hash_table;
96}; 96};
97 97
@@ -301,22 +301,22 @@ void journal_destroy_revoke(journal_t *journal)
301 301
302#ifdef __KERNEL__ 302#ifdef __KERNEL__
303 303
304/* 304/*
305 * journal_revoke: revoke a given buffer_head from the journal. This 305 * journal_revoke: revoke a given buffer_head from the journal. This
306 * prevents the block from being replayed during recovery if we take a 306 * prevents the block from being replayed during recovery if we take a
307 * crash after this current transaction commits. Any subsequent 307 * crash after this current transaction commits. Any subsequent
308 * metadata writes of the buffer in this transaction cancel the 308 * metadata writes of the buffer in this transaction cancel the
309 * revoke. 309 * revoke.
310 * 310 *
311 * Note that this call may block --- it is up to the caller to make 311 * Note that this call may block --- it is up to the caller to make
312 * sure that there are no further calls to journal_write_metadata 312 * sure that there are no further calls to journal_write_metadata
313 * before the revoke is complete. In ext3, this implies calling the 313 * before the revoke is complete. In ext3, this implies calling the
314 * revoke before clearing the block bitmap when we are deleting 314 * revoke before clearing the block bitmap when we are deleting
315 * metadata. 315 * metadata.
316 * 316 *
317 * Revoke performs a journal_forget on any buffer_head passed in as a 317 * Revoke performs a journal_forget on any buffer_head passed in as a
318 * parameter, but does _not_ forget the buffer_head if the bh was only 318 * parameter, but does _not_ forget the buffer_head if the bh was only
319 * found implicitly. 319 * found implicitly.
320 * 320 *
321 * bh_in may not be a journalled buffer - it may have come off 321 * bh_in may not be a journalled buffer - it may have come off
322 * the hash tables without an attached journal_head. 322 * the hash tables without an attached journal_head.
@@ -325,7 +325,7 @@ void journal_destroy_revoke(journal_t *journal)
325 * by one. 325 * by one.
326 */ 326 */
327 327
328int journal_revoke(handle_t *handle, unsigned long blocknr, 328int journal_revoke(handle_t *handle, unsigned long blocknr,
329 struct buffer_head *bh_in) 329 struct buffer_head *bh_in)
330{ 330{
331 struct buffer_head *bh = NULL; 331 struct buffer_head *bh = NULL;
@@ -487,7 +487,7 @@ void journal_switch_revoke_table(journal_t *journal)
487 else 487 else
488 journal->j_revoke = journal->j_revoke_table[0]; 488 journal->j_revoke = journal->j_revoke_table[0];
489 489
490 for (i = 0; i < journal->j_revoke->hash_size; i++) 490 for (i = 0; i < journal->j_revoke->hash_size; i++)
491 INIT_LIST_HEAD(&journal->j_revoke->hash_table[i]); 491 INIT_LIST_HEAD(&journal->j_revoke->hash_table[i]);
492} 492}
493 493
@@ -498,7 +498,7 @@ void journal_switch_revoke_table(journal_t *journal)
498 * Called with the journal lock held. 498 * Called with the journal lock held.
499 */ 499 */
500 500
501void journal_write_revoke_records(journal_t *journal, 501void journal_write_revoke_records(journal_t *journal,
502 transaction_t *transaction) 502 transaction_t *transaction)
503{ 503{
504 struct journal_head *descriptor; 504 struct journal_head *descriptor;
@@ -507,7 +507,7 @@ void journal_write_revoke_records(journal_t *journal,
507 struct list_head *hash_list; 507 struct list_head *hash_list;
508 int i, offset, count; 508 int i, offset, count;
509 509
510 descriptor = NULL; 510 descriptor = NULL;
511 offset = 0; 511 offset = 0;
512 count = 0; 512 count = 0;
513 513
@@ -519,10 +519,10 @@ void journal_write_revoke_records(journal_t *journal,
519 hash_list = &revoke->hash_table[i]; 519 hash_list = &revoke->hash_table[i];
520 520
521 while (!list_empty(hash_list)) { 521 while (!list_empty(hash_list)) {
522 record = (struct jbd_revoke_record_s *) 522 record = (struct jbd_revoke_record_s *)
523 hash_list->next; 523 hash_list->next;
524 write_one_revoke_record(journal, transaction, 524 write_one_revoke_record(journal, transaction,
525 &descriptor, &offset, 525 &descriptor, &offset,
526 record); 526 record);
527 count++; 527 count++;
528 list_del(&record->hash); 528 list_del(&record->hash);
@@ -534,14 +534,14 @@ void journal_write_revoke_records(journal_t *journal,
534 jbd_debug(1, "Wrote %d revoke records\n", count); 534 jbd_debug(1, "Wrote %d revoke records\n", count);
535} 535}
536 536
537/* 537/*
538 * Write out one revoke record. We need to create a new descriptor 538 * Write out one revoke record. We need to create a new descriptor
539 * block if the old one is full or if we have not already created one. 539 * block if the old one is full or if we have not already created one.
540 */ 540 */
541 541
542static void write_one_revoke_record(journal_t *journal, 542static void write_one_revoke_record(journal_t *journal,
543 transaction_t *transaction, 543 transaction_t *transaction,
544 struct journal_head **descriptorp, 544 struct journal_head **descriptorp,
545 int *offsetp, 545 int *offsetp,
546 struct jbd_revoke_record_s *record) 546 struct jbd_revoke_record_s *record)
547{ 547{
@@ -584,21 +584,21 @@ static void write_one_revoke_record(journal_t *journal,
584 *descriptorp = descriptor; 584 *descriptorp = descriptor;
585 } 585 }
586 586
587 * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) = 587 * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) =
588 cpu_to_be32(record->blocknr); 588 cpu_to_be32(record->blocknr);
589 offset += 4; 589 offset += 4;
590 *offsetp = offset; 590 *offsetp = offset;
591} 591}
592 592
593/* 593/*
594 * Flush a revoke descriptor out to the journal. If we are aborting, 594 * Flush a revoke descriptor out to the journal. If we are aborting,
595 * this is a noop; otherwise we are generating a buffer which needs to 595 * this is a noop; otherwise we are generating a buffer which needs to
596 * be waited for during commit, so it has to go onto the appropriate 596 * be waited for during commit, so it has to go onto the appropriate
597 * journal buffer list. 597 * journal buffer list.
598 */ 598 */
599 599
600static void flush_descriptor(journal_t *journal, 600static void flush_descriptor(journal_t *journal,
601 struct journal_head *descriptor, 601 struct journal_head *descriptor,
602 int offset) 602 int offset)
603{ 603{
604 journal_revoke_header_t *header; 604 journal_revoke_header_t *header;
@@ -618,7 +618,7 @@ static void flush_descriptor(journal_t *journal,
618} 618}
619#endif 619#endif
620 620
621/* 621/*
622 * Revoke support for recovery. 622 * Revoke support for recovery.
623 * 623 *
624 * Recovery needs to be able to: 624 * Recovery needs to be able to:
@@ -629,7 +629,7 @@ static void flush_descriptor(journal_t *journal,
629 * check whether a given block in a given transaction should be replayed 629 * check whether a given block in a given transaction should be replayed
630 * (ie. has not been revoked by a revoke record in that or a subsequent 630 * (ie. has not been revoked by a revoke record in that or a subsequent
631 * transaction) 631 * transaction)
632 * 632 *
633 * empty the revoke table after recovery. 633 * empty the revoke table after recovery.
634 */ 634 */
635 635
@@ -637,11 +637,11 @@ static void flush_descriptor(journal_t *journal,
637 * First, setting revoke records. We create a new revoke record for 637 * First, setting revoke records. We create a new revoke record for
638 * every block ever revoked in the log as we scan it for recovery, and 638 * every block ever revoked in the log as we scan it for recovery, and
639 * we update the existing records if we find multiple revokes for a 639 * we update the existing records if we find multiple revokes for a
640 * single block. 640 * single block.
641 */ 641 */
642 642
643int journal_set_revoke(journal_t *journal, 643int journal_set_revoke(journal_t *journal,
644 unsigned long blocknr, 644 unsigned long blocknr,
645 tid_t sequence) 645 tid_t sequence)
646{ 646{
647 struct jbd_revoke_record_s *record; 647 struct jbd_revoke_record_s *record;
@@ -653,18 +653,18 @@ int journal_set_revoke(journal_t *journal,
653 if (tid_gt(sequence, record->sequence)) 653 if (tid_gt(sequence, record->sequence))
654 record->sequence = sequence; 654 record->sequence = sequence;
655 return 0; 655 return 0;
656 } 656 }
657 return insert_revoke_hash(journal, blocknr, sequence); 657 return insert_revoke_hash(journal, blocknr, sequence);
658} 658}
659 659
660/* 660/*
661 * Test revoke records. For a given block referenced in the log, has 661 * Test revoke records. For a given block referenced in the log, has
662 * that block been revoked? A revoke record with a given transaction 662 * that block been revoked? A revoke record with a given transaction
663 * sequence number revokes all blocks in that transaction and earlier 663 * sequence number revokes all blocks in that transaction and earlier
664 * ones, but later transactions still need replayed. 664 * ones, but later transactions still need replayed.
665 */ 665 */
666 666
667int journal_test_revoke(journal_t *journal, 667int journal_test_revoke(journal_t *journal,
668 unsigned long blocknr, 668 unsigned long blocknr,
669 tid_t sequence) 669 tid_t sequence)
670{ 670{
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index f5169a96260e..e1b3c8af4d17 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/fs/transaction.c 2 * linux/fs/transaction.c
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 * 5 *
6 * Copyright 1998 Red Hat corp --- All Rights Reserved 6 * Copyright 1998 Red Hat corp --- All Rights Reserved
@@ -10,7 +10,7 @@
10 * option, any later version, incorporated herein by reference. 10 * option, any later version, incorporated herein by reference.
11 * 11 *
12 * Generic filesystem transaction handling code; part of the ext2fs 12 * Generic filesystem transaction handling code; part of the ext2fs
13 * journaling system. 13 * journaling system.
14 * 14 *
15 * This file manages transactions (compound commits managed by the 15 * This file manages transactions (compound commits managed by the
16 * journaling code) and handles (individual atomic operations by the 16 * journaling code) and handles (individual atomic operations by the
@@ -74,7 +74,7 @@ get_transaction(journal_t *journal, transaction_t *transaction)
74 * start_this_handle: Given a handle, deal with any locking or stalling 74 * start_this_handle: Given a handle, deal with any locking or stalling
75 * needed to make sure that there is enough journal space for the handle 75 * needed to make sure that there is enough journal space for the handle
76 * to begin. Attach the handle to a transaction and set up the 76 * to begin. Attach the handle to a transaction and set up the
77 * transaction's buffer credits. 77 * transaction's buffer credits.
78 */ 78 */
79 79
80static int start_this_handle(journal_t *journal, handle_t *handle) 80static int start_this_handle(journal_t *journal, handle_t *handle)
@@ -117,7 +117,7 @@ repeat_locked:
117 if (is_journal_aborted(journal) || 117 if (is_journal_aborted(journal) ||
118 (journal->j_errno != 0 && !(journal->j_flags & JFS_ACK_ERR))) { 118 (journal->j_errno != 0 && !(journal->j_flags & JFS_ACK_ERR))) {
119 spin_unlock(&journal->j_state_lock); 119 spin_unlock(&journal->j_state_lock);
120 ret = -EROFS; 120 ret = -EROFS;
121 goto out; 121 goto out;
122 } 122 }
123 123
@@ -182,7 +182,7 @@ repeat_locked:
182 goto repeat; 182 goto repeat;
183 } 183 }
184 184
185 /* 185 /*
186 * The commit code assumes that it can get enough log space 186 * The commit code assumes that it can get enough log space
187 * without forcing a checkpoint. This is *critical* for 187 * without forcing a checkpoint. This is *critical* for
188 * correctness: a checkpoint of a buffer which is also 188 * correctness: a checkpoint of a buffer which is also
@@ -191,7 +191,7 @@ repeat_locked:
191 * 191 *
192 * We must therefore ensure the necessary space in the journal 192 * We must therefore ensure the necessary space in the journal
193 * *before* starting to dirty potentially checkpointed buffers 193 * *before* starting to dirty potentially checkpointed buffers
194 * in the new transaction. 194 * in the new transaction.
195 * 195 *
196 * The worst part is, any transaction currently committing can 196 * The worst part is, any transaction currently committing can
197 * reduce the free space arbitrarily. Be careful to account for 197 * reduce the free space arbitrarily. Be careful to account for
@@ -246,13 +246,13 @@ static handle_t *new_handle(int nblocks)
246} 246}
247 247
248/** 248/**
249 * handle_t *journal_start() - Obtain a new handle. 249 * handle_t *journal_start() - Obtain a new handle.
250 * @journal: Journal to start transaction on. 250 * @journal: Journal to start transaction on.
251 * @nblocks: number of block buffer we might modify 251 * @nblocks: number of block buffer we might modify
252 * 252 *
253 * We make sure that the transaction can guarantee at least nblocks of 253 * We make sure that the transaction can guarantee at least nblocks of
254 * modified buffers in the log. We block until the log can guarantee 254 * modified buffers in the log. We block until the log can guarantee
255 * that much space. 255 * that much space.
256 * 256 *
257 * This function is visible to journal users (like ext3fs), so is not 257 * This function is visible to journal users (like ext3fs), so is not
258 * called with the journal already locked. 258 * called with the journal already locked.
@@ -292,11 +292,11 @@ handle_t *journal_start(journal_t *journal, int nblocks)
292 * int journal_extend() - extend buffer credits. 292 * int journal_extend() - extend buffer credits.
293 * @handle: handle to 'extend' 293 * @handle: handle to 'extend'
294 * @nblocks: nr blocks to try to extend by. 294 * @nblocks: nr blocks to try to extend by.
295 * 295 *
296 * Some transactions, such as large extends and truncates, can be done 296 * Some transactions, such as large extends and truncates, can be done
297 * atomically all at once or in several stages. The operation requests 297 * atomically all at once or in several stages. The operation requests
298 * a credit for a number of buffer modications in advance, but can 298 * a credit for a number of buffer modications in advance, but can
299 * extend its credit if it needs more. 299 * extend its credit if it needs more.
300 * 300 *
301 * journal_extend tries to give the running handle more buffer credits. 301 * journal_extend tries to give the running handle more buffer credits.
302 * It does not guarantee that allocation - this is a best-effort only. 302 * It does not guarantee that allocation - this is a best-effort only.
@@ -363,7 +363,7 @@ out:
363 * int journal_restart() - restart a handle . 363 * int journal_restart() - restart a handle .
364 * @handle: handle to restart 364 * @handle: handle to restart
365 * @nblocks: nr credits requested 365 * @nblocks: nr credits requested
366 * 366 *
367 * Restart a handle for a multi-transaction filesystem 367 * Restart a handle for a multi-transaction filesystem
368 * operation. 368 * operation.
369 * 369 *
@@ -462,7 +462,7 @@ void journal_lock_updates(journal_t *journal)
462/** 462/**
463 * void journal_unlock_updates (journal_t* journal) - release barrier 463 * void journal_unlock_updates (journal_t* journal) - release barrier
464 * @journal: Journal to release the barrier on. 464 * @journal: Journal to release the barrier on.
465 * 465 *
466 * Release a transaction barrier obtained with journal_lock_updates(). 466 * Release a transaction barrier obtained with journal_lock_updates().
467 * 467 *
468 * Should be called without the journal lock held. 468 * Should be called without the journal lock held.
@@ -547,8 +547,8 @@ repeat:
547 jbd_lock_bh_state(bh); 547 jbd_lock_bh_state(bh);
548 548
549 /* We now hold the buffer lock so it is safe to query the buffer 549 /* We now hold the buffer lock so it is safe to query the buffer
550 * state. Is the buffer dirty? 550 * state. Is the buffer dirty?
551 * 551 *
552 * If so, there are two possibilities. The buffer may be 552 * If so, there are two possibilities. The buffer may be
553 * non-journaled, and undergoing a quite legitimate writeback. 553 * non-journaled, and undergoing a quite legitimate writeback.
554 * Otherwise, it is journaled, and we don't expect dirty buffers 554 * Otherwise, it is journaled, and we don't expect dirty buffers
@@ -566,7 +566,7 @@ repeat:
566 */ 566 */
567 if (jh->b_transaction) { 567 if (jh->b_transaction) {
568 J_ASSERT_JH(jh, 568 J_ASSERT_JH(jh,
569 jh->b_transaction == transaction || 569 jh->b_transaction == transaction ||
570 jh->b_transaction == 570 jh->b_transaction ==
571 journal->j_committing_transaction); 571 journal->j_committing_transaction);
572 if (jh->b_next_transaction) 572 if (jh->b_next_transaction)
@@ -580,7 +580,7 @@ repeat:
580 */ 580 */
581 JBUFFER_TRACE(jh, "Unexpected dirty buffer"); 581 JBUFFER_TRACE(jh, "Unexpected dirty buffer");
582 jbd_unexpected_dirty_buffer(jh); 582 jbd_unexpected_dirty_buffer(jh);
583 } 583 }
584 584
585 unlock_buffer(bh); 585 unlock_buffer(bh);
586 586
@@ -653,7 +653,7 @@ repeat:
653 * buffer had better remain locked during the kmalloc, 653 * buffer had better remain locked during the kmalloc,
654 * but that should be true --- we hold the journal lock 654 * but that should be true --- we hold the journal lock
655 * still and the buffer is already on the BUF_JOURNAL 655 * still and the buffer is already on the BUF_JOURNAL
656 * list so won't be flushed. 656 * list so won't be flushed.
657 * 657 *
658 * Subtle point, though: if this is a get_undo_access, 658 * Subtle point, though: if this is a get_undo_access,
659 * then we will be relying on the frozen_data to contain 659 * then we will be relying on the frozen_data to contain
@@ -765,8 +765,8 @@ int journal_get_write_access(handle_t *handle, struct buffer_head *bh)
765 * manually rather than reading off disk), then we need to keep the 765 * manually rather than reading off disk), then we need to keep the
766 * buffer_head locked until it has been completely filled with new 766 * buffer_head locked until it has been completely filled with new
767 * data. In this case, we should be able to make the assertion that 767 * data. In this case, we should be able to make the assertion that
768 * the bh is not already part of an existing transaction. 768 * the bh is not already part of an existing transaction.
769 * 769 *
770 * The buffer should already be locked by the caller by this point. 770 * The buffer should already be locked by the caller by this point.
771 * There is no lock ranking violation: it was a newly created, 771 * There is no lock ranking violation: it was a newly created,
772 * unlocked buffer beforehand. */ 772 * unlocked buffer beforehand. */
@@ -778,7 +778,7 @@ int journal_get_write_access(handle_t *handle, struct buffer_head *bh)
778 * 778 *
779 * Call this if you create a new bh. 779 * Call this if you create a new bh.
780 */ 780 */
781int journal_get_create_access(handle_t *handle, struct buffer_head *bh) 781int journal_get_create_access(handle_t *handle, struct buffer_head *bh)
782{ 782{
783 transaction_t *transaction = handle->h_transaction; 783 transaction_t *transaction = handle->h_transaction;
784 journal_t *journal = transaction->t_journal; 784 journal_t *journal = transaction->t_journal;
@@ -847,13 +847,13 @@ out:
847 * do not reuse freed space until the deallocation has been committed, 847 * do not reuse freed space until the deallocation has been committed,
848 * since if we overwrote that space we would make the delete 848 * since if we overwrote that space we would make the delete
849 * un-rewindable in case of a crash. 849 * un-rewindable in case of a crash.
850 * 850 *
851 * To deal with that, journal_get_undo_access requests write access to a 851 * To deal with that, journal_get_undo_access requests write access to a
852 * buffer for parts of non-rewindable operations such as delete 852 * buffer for parts of non-rewindable operations such as delete
853 * operations on the bitmaps. The journaling code must keep a copy of 853 * operations on the bitmaps. The journaling code must keep a copy of
854 * the buffer's contents prior to the undo_access call until such time 854 * the buffer's contents prior to the undo_access call until such time
855 * as we know that the buffer has definitely been committed to disk. 855 * as we know that the buffer has definitely been committed to disk.
856 * 856 *
857 * We never need to know which transaction the committed data is part 857 * We never need to know which transaction the committed data is part
858 * of, buffers touched here are guaranteed to be dirtied later and so 858 * of, buffers touched here are guaranteed to be dirtied later and so
859 * will be committed to a new transaction in due course, at which point 859 * will be committed to a new transaction in due course, at which point
@@ -911,13 +911,13 @@ out:
911 return err; 911 return err;
912} 912}
913 913
914/** 914/**
915 * int journal_dirty_data() - mark a buffer as containing dirty data which 915 * int journal_dirty_data() - mark a buffer as containing dirty data which
916 * needs to be flushed before we can commit the 916 * needs to be flushed before we can commit the
917 * current transaction. 917 * current transaction.
918 * @handle: transaction 918 * @handle: transaction
919 * @bh: bufferhead to mark 919 * @bh: bufferhead to mark
920 * 920 *
921 * The buffer is placed on the transaction's data list and is marked as 921 * The buffer is placed on the transaction's data list and is marked as
922 * belonging to the transaction. 922 * belonging to the transaction.
923 * 923 *
@@ -946,15 +946,15 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh)
946 946
947 /* 947 /*
948 * What if the buffer is already part of a running transaction? 948 * What if the buffer is already part of a running transaction?
949 * 949 *
950 * There are two cases: 950 * There are two cases:
951 * 1) It is part of the current running transaction. Refile it, 951 * 1) It is part of the current running transaction. Refile it,
952 * just in case we have allocated it as metadata, deallocated 952 * just in case we have allocated it as metadata, deallocated
953 * it, then reallocated it as data. 953 * it, then reallocated it as data.
954 * 2) It is part of the previous, still-committing transaction. 954 * 2) It is part of the previous, still-committing transaction.
955 * If all we want to do is to guarantee that the buffer will be 955 * If all we want to do is to guarantee that the buffer will be
956 * written to disk before this new transaction commits, then 956 * written to disk before this new transaction commits, then
957 * being sure that the *previous* transaction has this same 957 * being sure that the *previous* transaction has this same
958 * property is sufficient for us! Just leave it on its old 958 * property is sufficient for us! Just leave it on its old
959 * transaction. 959 * transaction.
960 * 960 *
@@ -1076,18 +1076,18 @@ no_journal:
1076 return 0; 1076 return 0;
1077} 1077}
1078 1078
1079/** 1079/**
1080 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata 1080 * int journal_dirty_metadata() - mark a buffer as containing dirty metadata
1081 * @handle: transaction to add buffer to. 1081 * @handle: transaction to add buffer to.
1082 * @bh: buffer to mark 1082 * @bh: buffer to mark
1083 * 1083 *
1084 * mark dirty metadata which needs to be journaled as part of the current 1084 * mark dirty metadata which needs to be journaled as part of the current
1085 * transaction. 1085 * transaction.
1086 * 1086 *
1087 * The buffer is placed on the transaction's metadata list and is marked 1087 * The buffer is placed on the transaction's metadata list and is marked
1088 * as belonging to the transaction. 1088 * as belonging to the transaction.
1089 * 1089 *
1090 * Returns error number or 0 on success. 1090 * Returns error number or 0 on success.
1091 * 1091 *
1092 * Special care needs to be taken if the buffer already belongs to the 1092 * Special care needs to be taken if the buffer already belongs to the
1093 * current committing transaction (in which case we should have frozen 1093 * current committing transaction (in which case we should have frozen
@@ -1135,11 +1135,11 @@ int journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
1135 1135
1136 set_buffer_jbddirty(bh); 1136 set_buffer_jbddirty(bh);
1137 1137
1138 /* 1138 /*
1139 * Metadata already on the current transaction list doesn't 1139 * Metadata already on the current transaction list doesn't
1140 * need to be filed. Metadata on another transaction's list must 1140 * need to be filed. Metadata on another transaction's list must
1141 * be committing, and will be refiled once the commit completes: 1141 * be committing, and will be refiled once the commit completes:
1142 * leave it alone for now. 1142 * leave it alone for now.
1143 */ 1143 */
1144 if (jh->b_transaction != transaction) { 1144 if (jh->b_transaction != transaction) {
1145 JBUFFER_TRACE(jh, "already on other transaction"); 1145 JBUFFER_TRACE(jh, "already on other transaction");
@@ -1165,7 +1165,7 @@ out:
1165 return 0; 1165 return 0;
1166} 1166}
1167 1167
1168/* 1168/*
1169 * journal_release_buffer: undo a get_write_access without any buffer 1169 * journal_release_buffer: undo a get_write_access without any buffer
1170 * updates, if the update decided in the end that it didn't need access. 1170 * updates, if the update decided in the end that it didn't need access.
1171 * 1171 *
@@ -1176,20 +1176,20 @@ journal_release_buffer(handle_t *handle, struct buffer_head *bh)
1176 BUFFER_TRACE(bh, "entry"); 1176 BUFFER_TRACE(bh, "entry");
1177} 1177}
1178 1178
1179/** 1179/**
1180 * void journal_forget() - bforget() for potentially-journaled buffers. 1180 * void journal_forget() - bforget() for potentially-journaled buffers.
1181 * @handle: transaction handle 1181 * @handle: transaction handle
1182 * @bh: bh to 'forget' 1182 * @bh: bh to 'forget'
1183 * 1183 *
1184 * We can only do the bforget if there are no commits pending against the 1184 * We can only do the bforget if there are no commits pending against the
1185 * buffer. If the buffer is dirty in the current running transaction we 1185 * buffer. If the buffer is dirty in the current running transaction we
1186 * can safely unlink it. 1186 * can safely unlink it.
1187 * 1187 *
1188 * bh may not be a journalled buffer at all - it may be a non-JBD 1188 * bh may not be a journalled buffer at all - it may be a non-JBD
1189 * buffer which came off the hashtable. Check for this. 1189 * buffer which came off the hashtable. Check for this.
1190 * 1190 *
1191 * Decrements bh->b_count by one. 1191 * Decrements bh->b_count by one.
1192 * 1192 *
1193 * Allow this call even if the handle has aborted --- it may be part of 1193 * Allow this call even if the handle has aborted --- it may be part of
1194 * the caller's cleanup after an abort. 1194 * the caller's cleanup after an abort.
1195 */ 1195 */
@@ -1237,7 +1237,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh)
1237 1237
1238 drop_reserve = 1; 1238 drop_reserve = 1;
1239 1239
1240 /* 1240 /*
1241 * We are no longer going to journal this buffer. 1241 * We are no longer going to journal this buffer.
1242 * However, the commit of this transaction is still 1242 * However, the commit of this transaction is still
1243 * important to the buffer: the delete that we are now 1243 * important to the buffer: the delete that we are now
@@ -1246,7 +1246,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh)
1246 * 1246 *
1247 * So, if we have a checkpoint on the buffer, we should 1247 * So, if we have a checkpoint on the buffer, we should
1248 * now refile the buffer on our BJ_Forget list so that 1248 * now refile the buffer on our BJ_Forget list so that
1249 * we know to remove the checkpoint after we commit. 1249 * we know to remove the checkpoint after we commit.
1250 */ 1250 */
1251 1251
1252 if (jh->b_cp_transaction) { 1252 if (jh->b_cp_transaction) {
@@ -1264,7 +1264,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh)
1264 } 1264 }
1265 } 1265 }
1266 } else if (jh->b_transaction) { 1266 } else if (jh->b_transaction) {
1267 J_ASSERT_JH(jh, (jh->b_transaction == 1267 J_ASSERT_JH(jh, (jh->b_transaction ==
1268 journal->j_committing_transaction)); 1268 journal->j_committing_transaction));
1269 /* However, if the buffer is still owned by a prior 1269 /* However, if the buffer is still owned by a prior
1270 * (committing) transaction, we can't drop it yet... */ 1270 * (committing) transaction, we can't drop it yet... */
@@ -1294,7 +1294,7 @@ drop:
1294/** 1294/**
1295 * int journal_stop() - complete a transaction 1295 * int journal_stop() - complete a transaction
1296 * @handle: tranaction to complete. 1296 * @handle: tranaction to complete.
1297 * 1297 *
1298 * All done for a particular handle. 1298 * All done for a particular handle.
1299 * 1299 *
1300 * There is not much action needed here. We just return any remaining 1300 * There is not much action needed here. We just return any remaining
@@ -1303,7 +1303,7 @@ drop:
1303 * filesystem is marked for synchronous update. 1303 * filesystem is marked for synchronous update.
1304 * 1304 *
1305 * journal_stop itself will not usually return an error, but it may 1305 * journal_stop itself will not usually return an error, but it may
1306 * do so in unusual circumstances. In particular, expect it to 1306 * do so in unusual circumstances. In particular, expect it to
1307 * return -EIO if a journal_abort has been executed since the 1307 * return -EIO if a journal_abort has been executed since the
1308 * transaction began. 1308 * transaction began.
1309 */ 1309 */
@@ -1373,7 +1373,7 @@ int journal_stop(handle_t *handle)
1373 if (handle->h_sync || 1373 if (handle->h_sync ||
1374 transaction->t_outstanding_credits > 1374 transaction->t_outstanding_credits >
1375 journal->j_max_transaction_buffers || 1375 journal->j_max_transaction_buffers ||
1376 time_after_eq(jiffies, transaction->t_expires)) { 1376 time_after_eq(jiffies, transaction->t_expires)) {
1377 /* Do this even for aborted journals: an abort still 1377 /* Do this even for aborted journals: an abort still
1378 * completes the commit thread, it just doesn't write 1378 * completes the commit thread, it just doesn't write
1379 * anything to disk. */ 1379 * anything to disk. */
@@ -1388,7 +1388,7 @@ int journal_stop(handle_t *handle)
1388 1388
1389 /* 1389 /*
1390 * Special case: JFS_SYNC synchronous updates require us 1390 * Special case: JFS_SYNC synchronous updates require us
1391 * to wait for the commit to complete. 1391 * to wait for the commit to complete.
1392 */ 1392 */
1393 if (handle->h_sync && !(current->flags & PF_MEMALLOC)) 1393 if (handle->h_sync && !(current->flags & PF_MEMALLOC))
1394 err = log_wait_commit(journal, tid); 1394 err = log_wait_commit(journal, tid);
@@ -1439,7 +1439,7 @@ int journal_force_commit(journal_t *journal)
1439 * jbd_lock_bh_state(jh2bh(jh)) is held. 1439 * jbd_lock_bh_state(jh2bh(jh)) is held.
1440 */ 1440 */
1441 1441
1442static inline void 1442static inline void
1443__blist_add_buffer(struct journal_head **list, struct journal_head *jh) 1443__blist_add_buffer(struct journal_head **list, struct journal_head *jh)
1444{ 1444{
1445 if (!*list) { 1445 if (!*list) {
@@ -1454,7 +1454,7 @@ __blist_add_buffer(struct journal_head **list, struct journal_head *jh)
1454 } 1454 }
1455} 1455}
1456 1456
1457/* 1457/*
1458 * Remove a buffer from a transaction list, given the transaction's list 1458 * Remove a buffer from a transaction list, given the transaction's list
1459 * head pointer. 1459 * head pointer.
1460 * 1460 *
@@ -1475,7 +1475,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
1475 jh->b_tnext->b_tprev = jh->b_tprev; 1475 jh->b_tnext->b_tprev = jh->b_tprev;
1476} 1476}
1477 1477
1478/* 1478/*
1479 * Remove a buffer from the appropriate transaction list. 1479 * Remove a buffer from the appropriate transaction list.
1480 * 1480 *
1481 * Note that this function can *change* the value of 1481 * Note that this function can *change* the value of
@@ -1595,17 +1595,17 @@ out:
1595} 1595}
1596 1596
1597 1597
1598/** 1598/**
1599 * int journal_try_to_free_buffers() - try to free page buffers. 1599 * int journal_try_to_free_buffers() - try to free page buffers.
1600 * @journal: journal for operation 1600 * @journal: journal for operation
1601 * @page: to try and free 1601 * @page: to try and free
1602 * @unused_gfp_mask: unused 1602 * @unused_gfp_mask: unused
1603 * 1603 *
1604 * 1604 *
1605 * For all the buffers on this page, 1605 * For all the buffers on this page,
1606 * if they are fully written out ordered data, move them onto BUF_CLEAN 1606 * if they are fully written out ordered data, move them onto BUF_CLEAN
1607 * so try_to_free_buffers() can reap them. 1607 * so try_to_free_buffers() can reap them.
1608 * 1608 *
1609 * This function returns non-zero if we wish try_to_free_buffers() 1609 * This function returns non-zero if we wish try_to_free_buffers()
1610 * to be called. We do this if the page is releasable by try_to_free_buffers(). 1610 * to be called. We do this if the page is releasable by try_to_free_buffers().
1611 * We also do it if the page has locked or dirty buffers and the caller wants 1611 * We also do it if the page has locked or dirty buffers and the caller wants
@@ -1629,7 +1629,7 @@ out:
1629 * cannot happen because we never reallocate freed data as metadata 1629 * cannot happen because we never reallocate freed data as metadata
1630 * while the data is part of a transaction. Yes? 1630 * while the data is part of a transaction. Yes?
1631 */ 1631 */
1632int journal_try_to_free_buffers(journal_t *journal, 1632int journal_try_to_free_buffers(journal_t *journal,
1633 struct page *page, gfp_t unused_gfp_mask) 1633 struct page *page, gfp_t unused_gfp_mask)
1634{ 1634{
1635 struct buffer_head *head; 1635 struct buffer_head *head;
@@ -1697,7 +1697,7 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1697} 1697}
1698 1698
1699/* 1699/*
1700 * journal_invalidatepage 1700 * journal_invalidatepage
1701 * 1701 *
1702 * This code is tricky. It has a number of cases to deal with. 1702 * This code is tricky. It has a number of cases to deal with.
1703 * 1703 *
@@ -1705,15 +1705,15 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1705 * 1705 *
1706 * i_size must be updated on disk before we start calling invalidatepage on the 1706 * i_size must be updated on disk before we start calling invalidatepage on the
1707 * data. 1707 * data.
1708 * 1708 *
1709 * This is done in ext3 by defining an ext3_setattr method which 1709 * This is done in ext3 by defining an ext3_setattr method which
1710 * updates i_size before truncate gets going. By maintaining this 1710 * updates i_size before truncate gets going. By maintaining this
1711 * invariant, we can be sure that it is safe to throw away any buffers 1711 * invariant, we can be sure that it is safe to throw away any buffers
1712 * attached to the current transaction: once the transaction commits, 1712 * attached to the current transaction: once the transaction commits,
1713 * we know that the data will not be needed. 1713 * we know that the data will not be needed.
1714 * 1714 *
1715 * Note however that we can *not* throw away data belonging to the 1715 * Note however that we can *not* throw away data belonging to the
1716 * previous, committing transaction! 1716 * previous, committing transaction!
1717 * 1717 *
1718 * Any disk blocks which *are* part of the previous, committing 1718 * Any disk blocks which *are* part of the previous, committing
1719 * transaction (and which therefore cannot be discarded immediately) are 1719 * transaction (and which therefore cannot be discarded immediately) are
@@ -1732,7 +1732,7 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
1732 * don't make guarantees about the order in which data hits disk --- in 1732 * don't make guarantees about the order in which data hits disk --- in
1733 * particular we don't guarantee that new dirty data is flushed before 1733 * particular we don't guarantee that new dirty data is flushed before
1734 * transaction commit --- so it is always safe just to discard data 1734 * transaction commit --- so it is always safe just to discard data
1735 * immediately in that mode. --sct 1735 * immediately in that mode. --sct
1736 */ 1736 */
1737 1737
1738/* 1738/*
@@ -1876,9 +1876,9 @@ zap_buffer_unlocked:
1876 return may_free; 1876 return may_free;
1877} 1877}
1878 1878
1879/** 1879/**
1880 * void journal_invalidatepage() 1880 * void journal_invalidatepage()
1881 * @journal: journal to use for flush... 1881 * @journal: journal to use for flush...
1882 * @page: page to flush 1882 * @page: page to flush
1883 * @offset: length of page to invalidate. 1883 * @offset: length of page to invalidate.
1884 * 1884 *
@@ -1886,7 +1886,7 @@ zap_buffer_unlocked:
1886 * 1886 *
1887 */ 1887 */
1888void journal_invalidatepage(journal_t *journal, 1888void journal_invalidatepage(journal_t *journal,
1889 struct page *page, 1889 struct page *page,
1890 unsigned long offset) 1890 unsigned long offset)
1891{ 1891{
1892 struct buffer_head *head, *bh, *next; 1892 struct buffer_head *head, *bh, *next;
@@ -1908,7 +1908,7 @@ void journal_invalidatepage(journal_t *journal,
1908 next = bh->b_this_page; 1908 next = bh->b_this_page;
1909 1909
1910 if (offset <= curr_off) { 1910 if (offset <= curr_off) {
1911 /* This block is wholly outside the truncation point */ 1911 /* This block is wholly outside the truncation point */
1912 lock_buffer(bh); 1912 lock_buffer(bh);
1913 may_free &= journal_unmap_buffer(journal, bh); 1913 may_free &= journal_unmap_buffer(journal, bh);
1914 unlock_buffer(bh); 1914 unlock_buffer(bh);
@@ -1924,8 +1924,8 @@ void journal_invalidatepage(journal_t *journal,
1924 } 1924 }
1925} 1925}
1926 1926
1927/* 1927/*
1928 * File a buffer on the given transaction list. 1928 * File a buffer on the given transaction list.
1929 */ 1929 */
1930void __journal_file_buffer(struct journal_head *jh, 1930void __journal_file_buffer(struct journal_head *jh,
1931 transaction_t *transaction, int jlist) 1931 transaction_t *transaction, int jlist)
@@ -1948,7 +1948,7 @@ void __journal_file_buffer(struct journal_head *jh,
1948 * with __jbd_unexpected_dirty_buffer()'s handling of dirty 1948 * with __jbd_unexpected_dirty_buffer()'s handling of dirty
1949 * state. */ 1949 * state. */
1950 1950
1951 if (jlist == BJ_Metadata || jlist == BJ_Reserved || 1951 if (jlist == BJ_Metadata || jlist == BJ_Reserved ||
1952 jlist == BJ_Shadow || jlist == BJ_Forget) { 1952 jlist == BJ_Shadow || jlist == BJ_Forget) {
1953 if (test_clear_buffer_dirty(bh) || 1953 if (test_clear_buffer_dirty(bh) ||
1954 test_clear_buffer_jbddirty(bh)) 1954 test_clear_buffer_jbddirty(bh))
@@ -2008,7 +2008,7 @@ void journal_file_buffer(struct journal_head *jh,
2008 jbd_unlock_bh_state(jh2bh(jh)); 2008 jbd_unlock_bh_state(jh2bh(jh));
2009} 2009}
2010 2010
2011/* 2011/*
2012 * Remove a buffer from its current buffer list in preparation for 2012 * Remove a buffer from its current buffer list in preparation for
2013 * dropping it from its current transaction entirely. If the buffer has 2013 * dropping it from its current transaction entirely. If the buffer has
2014 * already started to be used by a subsequent transaction, refile the 2014 * already started to be used by a subsequent transaction, refile the
@@ -2060,7 +2060,7 @@ void __journal_refile_buffer(struct journal_head *jh)
2060 * to the caller to remove the journal_head if necessary. For the 2060 * to the caller to remove the journal_head if necessary. For the
2061 * unlocked journal_refile_buffer call, the caller isn't going to be 2061 * unlocked journal_refile_buffer call, the caller isn't going to be
2062 * doing anything else to the buffer so we need to do the cleanup 2062 * doing anything else to the buffer so we need to do the cleanup
2063 * ourselves to avoid a jh leak. 2063 * ourselves to avoid a jh leak.
2064 * 2064 *
2065 * *** The journal_head may be freed by this call! *** 2065 * *** The journal_head may be freed by this call! ***
2066 */ 2066 */
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index 93068697a9bf..f5cf9c93e243 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -364,12 +364,11 @@ jffs_new_inode(const struct inode * dir, struct jffs_raw_inode *raw_inode,
364 inode->i_ctime.tv_nsec = 0; 364 inode->i_ctime.tv_nsec = 0;
365 inode->i_mtime.tv_nsec = 0; 365 inode->i_mtime.tv_nsec = 0;
366 inode->i_atime.tv_nsec = 0; 366 inode->i_atime.tv_nsec = 0;
367 inode->i_blksize = PAGE_SIZE;
368 inode->i_blocks = (inode->i_size + 511) >> 9; 367 inode->i_blocks = (inode->i_size + 511) >> 9;
369 368
370 f = jffs_find_file(c, raw_inode->ino); 369 f = jffs_find_file(c, raw_inode->ino);
371 370
372 inode->u.generic_ip = (void *)f; 371 inode->i_private = (void *)f;
373 insert_inode_hash(inode); 372 insert_inode_hash(inode);
374 373
375 return inode; 374 return inode;
@@ -442,7 +441,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
442 }); 441 });
443 442
444 result = -ENOTDIR; 443 result = -ENOTDIR;
445 if (!(old_dir_f = (struct jffs_file *)old_dir->u.generic_ip)) { 444 if (!(old_dir_f = old_dir->i_private)) {
446 D(printk("jffs_rename(): Old dir invalid.\n")); 445 D(printk("jffs_rename(): Old dir invalid.\n"));
447 goto jffs_rename_end; 446 goto jffs_rename_end;
448 } 447 }
@@ -456,7 +455,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
456 455
457 /* Find the new directory. */ 456 /* Find the new directory. */
458 result = -ENOTDIR; 457 result = -ENOTDIR;
459 if (!(new_dir_f = (struct jffs_file *)new_dir->u.generic_ip)) { 458 if (!(new_dir_f = new_dir->i_private)) {
460 D(printk("jffs_rename(): New dir invalid.\n")); 459 D(printk("jffs_rename(): New dir invalid.\n"));
461 goto jffs_rename_end; 460 goto jffs_rename_end;
462 } 461 }
@@ -593,7 +592,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
593 } 592 }
594 else { 593 else {
595 ddino = ((struct jffs_file *) 594 ddino = ((struct jffs_file *)
596 inode->u.generic_ip)->pino; 595 inode->i_private)->pino;
597 } 596 }
598 D3(printk("jffs_readdir(): \"..\" %u\n", ddino)); 597 D3(printk("jffs_readdir(): \"..\" %u\n", ddino));
599 if (filldir(dirent, "..", 2, filp->f_pos, ddino, DT_DIR) < 0) { 598 if (filldir(dirent, "..", 2, filp->f_pos, ddino, DT_DIR) < 0) {
@@ -604,7 +603,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
604 } 603 }
605 filp->f_pos++; 604 filp->f_pos++;
606 } 605 }
607 f = ((struct jffs_file *)inode->u.generic_ip)->children; 606 f = ((struct jffs_file *)inode->i_private)->children;
608 607
609 j = 2; 608 j = 2;
610 while(f && (f->deleted || j++ < filp->f_pos )) { 609 while(f && (f->deleted || j++ < filp->f_pos )) {
@@ -652,7 +651,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
652 lock_kernel(); 651 lock_kernel();
653 652
654 D3({ 653 D3({
655 char *s = (char *)kmalloc(len + 1, GFP_KERNEL); 654 char *s = kmalloc(len + 1, GFP_KERNEL);
656 memcpy(s, name, len); 655 memcpy(s, name, len);
657 s[len] = '\0'; 656 s[len] = '\0';
658 printk("jffs_lookup(): dir: 0x%p, name: \"%s\"\n", dir, s); 657 printk("jffs_lookup(): dir: 0x%p, name: \"%s\"\n", dir, s);
@@ -668,7 +667,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
668 } 667 }
669 668
670 r = -EACCES; 669 r = -EACCES;
671 if (!(d = (struct jffs_file *)dir->u.generic_ip)) { 670 if (!(d = (struct jffs_file *)dir->i_private)) {
672 D(printk("jffs_lookup(): No such inode! (%lu)\n", 671 D(printk("jffs_lookup(): No such inode! (%lu)\n",
673 dir->i_ino)); 672 dir->i_ino));
674 goto jffs_lookup_end; 673 goto jffs_lookup_end;
@@ -739,7 +738,7 @@ jffs_do_readpage_nolock(struct file *file, struct page *page)
739 unsigned long read_len; 738 unsigned long read_len;
740 int result; 739 int result;
741 struct inode *inode = (struct inode*)page->mapping->host; 740 struct inode *inode = (struct inode*)page->mapping->host;
742 struct jffs_file *f = (struct jffs_file *)inode->u.generic_ip; 741 struct jffs_file *f = (struct jffs_file *)inode->i_private;
743 struct jffs_control *c = (struct jffs_control *)inode->i_sb->s_fs_info; 742 struct jffs_control *c = (struct jffs_control *)inode->i_sb->s_fs_info;
744 int r; 743 int r;
745 loff_t offset; 744 loff_t offset;
@@ -828,7 +827,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
828 }); 827 });
829 828
830 lock_kernel(); 829 lock_kernel();
831 dir_f = (struct jffs_file *)dir->u.generic_ip; 830 dir_f = dir->i_private;
832 831
833 ASSERT(if (!dir_f) { 832 ASSERT(if (!dir_f) {
834 printk(KERN_ERR "jffs_mkdir(): No reference to a " 833 printk(KERN_ERR "jffs_mkdir(): No reference to a "
@@ -972,7 +971,7 @@ jffs_remove(struct inode *dir, struct dentry *dentry, int type)
972 kfree(_name); 971 kfree(_name);
973 }); 972 });
974 973
975 dir_f = (struct jffs_file *) dir->u.generic_ip; 974 dir_f = dir->i_private;
976 c = dir_f->c; 975 c = dir_f->c;
977 976
978 result = -ENOENT; 977 result = -ENOENT;
@@ -1082,7 +1081,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
1082 if (!old_valid_dev(rdev)) 1081 if (!old_valid_dev(rdev))
1083 return -EINVAL; 1082 return -EINVAL;
1084 lock_kernel(); 1083 lock_kernel();
1085 dir_f = (struct jffs_file *)dir->u.generic_ip; 1084 dir_f = dir->i_private;
1086 c = dir_f->c; 1085 c = dir_f->c;
1087 1086
1088 D3(printk (KERN_NOTICE "mknod(): down biglock\n")); 1087 D3(printk (KERN_NOTICE "mknod(): down biglock\n"));
@@ -1173,8 +1172,8 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1173 lock_kernel(); 1172 lock_kernel();
1174 D1({ 1173 D1({
1175 int len = dentry->d_name.len; 1174 int len = dentry->d_name.len;
1176 char *_name = (char *)kmalloc(len + 1, GFP_KERNEL); 1175 char *_name = kmalloc(len + 1, GFP_KERNEL);
1177 char *_symname = (char *)kmalloc(symname_len + 1, GFP_KERNEL); 1176 char *_symname = kmalloc(symname_len + 1, GFP_KERNEL);
1178 memcpy(_name, dentry->d_name.name, len); 1177 memcpy(_name, dentry->d_name.name, len);
1179 _name[len] = '\0'; 1178 _name[len] = '\0';
1180 memcpy(_symname, symname, symname_len); 1179 memcpy(_symname, symname, symname_len);
@@ -1186,7 +1185,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1186 kfree(_symname); 1185 kfree(_symname);
1187 }); 1186 });
1188 1187
1189 dir_f = (struct jffs_file *)dir->u.generic_ip; 1188 dir_f = dir->i_private;
1190 ASSERT(if (!dir_f) { 1189 ASSERT(if (!dir_f) {
1191 printk(KERN_ERR "jffs_symlink(): No reference to a " 1190 printk(KERN_ERR "jffs_symlink(): No reference to a "
1192 "jffs_file struct in inode.\n"); 1191 "jffs_file struct in inode.\n");
@@ -1282,14 +1281,14 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
1282 lock_kernel(); 1281 lock_kernel();
1283 D1({ 1282 D1({
1284 int len = dentry->d_name.len; 1283 int len = dentry->d_name.len;
1285 char *s = (char *)kmalloc(len + 1, GFP_KERNEL); 1284 char *s = kmalloc(len + 1, GFP_KERNEL);
1286 memcpy(s, dentry->d_name.name, len); 1285 memcpy(s, dentry->d_name.name, len);
1287 s[len] = '\0'; 1286 s[len] = '\0';
1288 printk("jffs_create(): dir: 0x%p, name: \"%s\"\n", dir, s); 1287 printk("jffs_create(): dir: 0x%p, name: \"%s\"\n", dir, s);
1289 kfree(s); 1288 kfree(s);
1290 }); 1289 });
1291 1290
1292 dir_f = (struct jffs_file *)dir->u.generic_ip; 1291 dir_f = dir->i_private;
1293 ASSERT(if (!dir_f) { 1292 ASSERT(if (!dir_f) {
1294 printk(KERN_ERR "jffs_create(): No reference to a " 1293 printk(KERN_ERR "jffs_create(): No reference to a "
1295 "jffs_file struct in inode.\n"); 1294 "jffs_file struct in inode.\n");
@@ -1403,9 +1402,9 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
1403 goto out_isem; 1402 goto out_isem;
1404 } 1403 }
1405 1404
1406 if (!(f = (struct jffs_file *)inode->u.generic_ip)) { 1405 if (!(f = inode->i_private)) {
1407 D(printk("jffs_file_write(): inode->u.generic_ip = 0x%p\n", 1406 D(printk("jffs_file_write(): inode->i_private = 0x%p\n",
1408 inode->u.generic_ip)); 1407 inode->i_private));
1409 goto out_isem; 1408 goto out_isem;
1410 } 1409 }
1411 1410
@@ -1693,7 +1692,7 @@ jffs_read_inode(struct inode *inode)
1693 mutex_unlock(&c->fmc->biglock); 1692 mutex_unlock(&c->fmc->biglock);
1694 return; 1693 return;
1695 } 1694 }
1696 inode->u.generic_ip = (void *)f; 1695 inode->i_private = f;
1697 inode->i_mode = f->mode; 1696 inode->i_mode = f->mode;
1698 inode->i_nlink = f->nlink; 1697 inode->i_nlink = f->nlink;
1699 inode->i_uid = f->uid; 1698 inode->i_uid = f->uid;
@@ -1706,7 +1705,6 @@ jffs_read_inode(struct inode *inode)
1706 inode->i_mtime.tv_nsec = 1705 inode->i_mtime.tv_nsec =
1707 inode->i_ctime.tv_nsec = 0; 1706 inode->i_ctime.tv_nsec = 0;
1708 1707
1709 inode->i_blksize = PAGE_SIZE;
1710 inode->i_blocks = (inode->i_size + 511) >> 9; 1708 inode->i_blocks = (inode->i_size + 511) >> 9;
1711 if (S_ISREG(inode->i_mode)) { 1709 if (S_ISREG(inode->i_mode)) {
1712 inode->i_op = &jffs_file_inode_operations; 1710 inode->i_op = &jffs_file_inode_operations;
@@ -1748,7 +1746,7 @@ jffs_delete_inode(struct inode *inode)
1748 lock_kernel(); 1746 lock_kernel();
1749 inode->i_size = 0; 1747 inode->i_size = 0;
1750 inode->i_blocks = 0; 1748 inode->i_blocks = 0;
1751 inode->u.generic_ip = NULL; 1749 inode->i_private = NULL;
1752 clear_inode(inode); 1750 clear_inode(inode);
1753 if (inode->i_nlink == 0) { 1751 if (inode->i_nlink == 0) {
1754 c = (struct jffs_control *) inode->i_sb->s_fs_info; 1752 c = (struct jffs_control *) inode->i_sb->s_fs_info;
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index 9000f1effedf..4a543e114970 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -488,13 +488,11 @@ jffs_create_file(struct jffs_control *c,
488{ 488{
489 struct jffs_file *f; 489 struct jffs_file *f;
490 490
491 if (!(f = (struct jffs_file *)kmalloc(sizeof(struct jffs_file), 491 if (!(f = kzalloc(sizeof(*f), GFP_KERNEL))) {
492 GFP_KERNEL))) {
493 D(printk("jffs_create_file(): Failed!\n")); 492 D(printk("jffs_create_file(): Failed!\n"));
494 return NULL; 493 return NULL;
495 } 494 }
496 no_jffs_file++; 495 no_jffs_file++;
497 memset(f, 0, sizeof(struct jffs_file));
498 f->ino = raw_inode->ino; 496 f->ino = raw_inode->ino;
499 f->pino = raw_inode->pino; 497 f->pino = raw_inode->pino;
500 f->nlink = raw_inode->nlink; 498 f->nlink = raw_inode->nlink;
@@ -516,7 +514,7 @@ jffs_create_control(struct super_block *sb)
516 514
517 D2(printk("jffs_create_control()\n")); 515 D2(printk("jffs_create_control()\n"));
518 516
519 if (!(c = (struct jffs_control *)kmalloc(s, GFP_KERNEL))) { 517 if (!(c = kmalloc(s, GFP_KERNEL))) {
520 goto fail_control; 518 goto fail_control;
521 } 519 }
522 DJM(no_jffs_control++); 520 DJM(no_jffs_control++);
@@ -524,7 +522,7 @@ jffs_create_control(struct super_block *sb)
524 c->gc_task = NULL; 522 c->gc_task = NULL;
525 c->hash_len = JFFS_HASH_SIZE; 523 c->hash_len = JFFS_HASH_SIZE;
526 s = sizeof(struct list_head) * c->hash_len; 524 s = sizeof(struct list_head) * c->hash_len;
527 if (!(c->hash = (struct list_head *)kmalloc(s, GFP_KERNEL))) { 525 if (!(c->hash = kmalloc(s, GFP_KERNEL))) {
528 goto fail_hash; 526 goto fail_hash;
529 } 527 }
530 DJM(no_hash++); 528 DJM(no_hash++);
@@ -593,8 +591,7 @@ jffs_add_virtual_root(struct jffs_control *c)
593 D2(printk("jffs_add_virtual_root(): " 591 D2(printk("jffs_add_virtual_root(): "
594 "Creating a virtual root directory.\n")); 592 "Creating a virtual root directory.\n"));
595 593
596 if (!(root = (struct jffs_file *)kmalloc(sizeof(struct jffs_file), 594 if (!(root = kmalloc(sizeof(struct jffs_file), GFP_KERNEL))) {
597 GFP_KERNEL))) {
598 return -ENOMEM; 595 return -ENOMEM;
599 } 596 }
600 no_jffs_file++; 597 no_jffs_file++;
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 7d8ca1aeace2..29b68d939bd9 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -94,8 +94,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
94 struct mtd_info *mtd; 94 struct mtd_info *mtd;
95 95
96 D3(printk("jffs_build_begin()\n")); 96 D3(printk("jffs_build_begin()\n"));
97 fmc = (struct jffs_fmcontrol *)kmalloc(sizeof(struct jffs_fmcontrol), 97 fmc = kmalloc(sizeof(*fmc), GFP_KERNEL);
98 GFP_KERNEL);
99 if (!fmc) { 98 if (!fmc) {
100 D(printk("jffs_build_begin(): Allocation of " 99 D(printk("jffs_build_begin(): Allocation of "
101 "struct jffs_fmcontrol failed!\n")); 100 "struct jffs_fmcontrol failed!\n"));
@@ -486,8 +485,7 @@ jffs_add_node(struct jffs_node *node)
486 485
487 D3(printk("jffs_add_node(): ino = %u\n", node->ino)); 486 D3(printk("jffs_add_node(): ino = %u\n", node->ino));
488 487
489 ref = (struct jffs_node_ref *)kmalloc(sizeof(struct jffs_node_ref), 488 ref = kmalloc(sizeof(*ref), GFP_KERNEL);
490 GFP_KERNEL);
491 if (!ref) 489 if (!ref)
492 return -ENOMEM; 490 return -ENOMEM;
493 491
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 4780f82825d6..72d9909d95ff 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -263,7 +263,6 @@ void jffs2_read_inode (struct inode *inode)
263 263
264 inode->i_nlink = f->inocache->nlink; 264 inode->i_nlink = f->inocache->nlink;
265 265
266 inode->i_blksize = PAGE_SIZE;
267 inode->i_blocks = (inode->i_size + 511) >> 9; 266 inode->i_blocks = (inode->i_size + 511) >> 9;
268 267
269 switch (inode->i_mode & S_IFMT) { 268 switch (inode->i_mode & S_IFMT) {
@@ -449,7 +448,6 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_i
449 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC; 448 inode->i_atime = inode->i_ctime = inode->i_mtime = CURRENT_TIME_SEC;
450 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime)); 449 ri->atime = ri->mtime = ri->ctime = cpu_to_je32(I_SEC(inode->i_mtime));
451 450
452 inode->i_blksize = PAGE_SIZE;
453 inode->i_blocks = 0; 451 inode->i_blocks = 0;
454 inode->i_size = 0; 452 inode->i_size = 0;
455 453
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 68e3953419b4..6de374513c01 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -119,10 +119,9 @@ static int jffs2_get_sb_mtd(struct file_system_type *fs_type,
119 struct jffs2_sb_info *c; 119 struct jffs2_sb_info *c;
120 int ret; 120 int ret;
121 121
122 c = kmalloc(sizeof(*c), GFP_KERNEL); 122 c = kzalloc(sizeof(*c), GFP_KERNEL);
123 if (!c) 123 if (!c)
124 return -ENOMEM; 124 return -ENOMEM;
125 memset(c, 0, sizeof(*c));
126 c->mtd = mtd; 125 c->mtd = mtd;
127 126
128 sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c); 127 sb = sget(fs_type, jffs2_sb_compare, jffs2_sb_set, c);
diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c
index 4d52593a5fc6..4c74f0944f7e 100644
--- a/fs/jfs/jfs_extent.c
+++ b/fs/jfs/jfs_extent.c
@@ -468,7 +468,7 @@ int extRecord(struct inode *ip, xad_t * xp)
468int extFill(struct inode *ip, xad_t * xp) 468int extFill(struct inode *ip, xad_t * xp)
469{ 469{
470 int rc, nbperpage = JFS_SBI(ip->i_sb)->nbperpage; 470 int rc, nbperpage = JFS_SBI(ip->i_sb)->nbperpage;
471 s64 blkno = offsetXAD(xp) >> ip->i_blksize; 471 s64 blkno = offsetXAD(xp) >> ip->i_blkbits;
472 472
473// assert(ISSPARSE(ip)); 473// assert(ISSPARSE(ip));
474 474
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index ccbe60aff83d..369d7f39c040 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -3115,7 +3115,6 @@ static int copy_from_dinode(struct dinode * dip, struct inode *ip)
3115 ip->i_mtime.tv_nsec = le32_to_cpu(dip->di_mtime.tv_nsec); 3115 ip->i_mtime.tv_nsec = le32_to_cpu(dip->di_mtime.tv_nsec);
3116 ip->i_ctime.tv_sec = le32_to_cpu(dip->di_ctime.tv_sec); 3116 ip->i_ctime.tv_sec = le32_to_cpu(dip->di_ctime.tv_sec);
3117 ip->i_ctime.tv_nsec = le32_to_cpu(dip->di_ctime.tv_nsec); 3117 ip->i_ctime.tv_nsec = le32_to_cpu(dip->di_ctime.tv_nsec);
3118 ip->i_blksize = ip->i_sb->s_blocksize;
3119 ip->i_blocks = LBLK2PBLK(ip->i_sb, le64_to_cpu(dip->di_nblocks)); 3118 ip->i_blocks = LBLK2PBLK(ip->i_sb, le64_to_cpu(dip->di_nblocks));
3120 ip->i_generation = le32_to_cpu(dip->di_gen); 3119 ip->i_generation = le32_to_cpu(dip->di_gen);
3121 3120
diff --git a/fs/jfs/jfs_inode.c b/fs/jfs/jfs_inode.c
index 495df402916d..bffaca9ae3a2 100644
--- a/fs/jfs/jfs_inode.c
+++ b/fs/jfs/jfs_inode.c
@@ -115,7 +115,6 @@ struct inode *ialloc(struct inode *parent, umode_t mode)
115 } 115 }
116 jfs_inode->mode2 |= mode; 116 jfs_inode->mode2 |= mode;
117 117
118 inode->i_blksize = sb->s_blocksize;
119 inode->i_blocks = 0; 118 inode->i_blocks = 0;
120 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; 119 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
121 jfs_inode->otime = inode->i_ctime.tv_sec; 120 jfs_inode->otime = inode->i_ctime.tv_sec;
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index e1e0a6e6ebdf..f5afc129d6b1 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -257,7 +257,7 @@ static sector_t metapage_get_blocks(struct inode *inode, sector_t lblock,
257 int rc = 0; 257 int rc = 0;
258 int xflag; 258 int xflag;
259 s64 xaddr; 259 s64 xaddr;
260 sector_t file_blocks = (inode->i_size + inode->i_blksize - 1) >> 260 sector_t file_blocks = (inode->i_size + inode->i_sb->s_blocksize - 1) >>
261 inode->i_blkbits; 261 inode->i_blkbits;
262 262
263 if (lblock >= file_blocks) 263 if (lblock >= file_blocks)
diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c
index efbb586bed4b..3856efc399c1 100644
--- a/fs/jfs/jfs_txnmgr.c
+++ b/fs/jfs/jfs_txnmgr.c
@@ -282,7 +282,7 @@ int txInit(void)
282 TxLockVHWM = (nTxLock * 8) / 10; 282 TxLockVHWM = (nTxLock * 8) / 10;
283 283
284 size = sizeof(struct tblock) * nTxBlock; 284 size = sizeof(struct tblock) * nTxBlock;
285 TxBlock = (struct tblock *) vmalloc(size); 285 TxBlock = vmalloc(size);
286 if (TxBlock == NULL) 286 if (TxBlock == NULL)
287 return -ENOMEM; 287 return -ENOMEM;
288 288
@@ -307,7 +307,7 @@ int txInit(void)
307 * tlock id = 0 is reserved. 307 * tlock id = 0 is reserved.
308 */ 308 */
309 size = sizeof(struct tlock) * nTxLock; 309 size = sizeof(struct tlock) * nTxLock;
310 TxLock = (struct tlock *) vmalloc(size); 310 TxLock = vmalloc(size);
311 if (TxLock == NULL) { 311 if (TxLock == NULL) {
312 vfree(TxBlock); 312 vfree(TxBlock);
313 return -ENOMEM; 313 return -ENOMEM;
diff --git a/fs/libfs.c b/fs/libfs.c
index ac02ea602c3d..8db5afb7b0a7 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -383,7 +383,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
383 return -ENOMEM; 383 return -ENOMEM;
384 inode->i_mode = S_IFDIR | 0755; 384 inode->i_mode = S_IFDIR | 0755;
385 inode->i_uid = inode->i_gid = 0; 385 inode->i_uid = inode->i_gid = 0;
386 inode->i_blksize = PAGE_CACHE_SIZE;
387 inode->i_blocks = 0; 386 inode->i_blocks = 0;
388 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 387 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
389 inode->i_op = &simple_dir_inode_operations; 388 inode->i_op = &simple_dir_inode_operations;
@@ -405,7 +404,6 @@ int simple_fill_super(struct super_block *s, int magic, struct tree_descr *files
405 goto out; 404 goto out;
406 inode->i_mode = S_IFREG | files->mode; 405 inode->i_mode = S_IFREG | files->mode;
407 inode->i_uid = inode->i_gid = 0; 406 inode->i_uid = inode->i_gid = 0;
408 inode->i_blksize = PAGE_CACHE_SIZE;
409 inode->i_blocks = 0; 407 inode->i_blocks = 0;
410 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 408 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
411 inode->i_fop = files->ops; 409 inode->i_fop = files->ops;
@@ -547,7 +545,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
547 545
548 attr->get = get; 546 attr->get = get;
549 attr->set = set; 547 attr->set = set;
550 attr->data = inode->u.generic_ip; 548 attr->data = inode->i_private;
551 attr->fmt = fmt; 549 attr->fmt = fmt;
552 mutex_init(&attr->mutex); 550 mutex_init(&attr->mutex);
553 551
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 52774feab93f..f95cc3f3c42d 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -160,7 +160,7 @@ static void nlmclnt_prepare_reclaim(struct nlm_host *host)
160 */ 160 */
161 list_splice_init(&host->h_granted, &host->h_reclaim); 161 list_splice_init(&host->h_granted, &host->h_reclaim);
162 162
163 dprintk("NLM: reclaiming locks for host %s", host->h_name); 163 dprintk("NLM: reclaiming locks for host %s\n", host->h_name);
164} 164}
165 165
166static void nlmclnt_finish_reclaim(struct nlm_host *host) 166static void nlmclnt_finish_reclaim(struct nlm_host *host)
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 50dbb67ae0c4..271e2165fff6 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -100,7 +100,7 @@ static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_
100 res = __nlm_find_lockowner(host, owner); 100 res = __nlm_find_lockowner(host, owner);
101 if (res == NULL) { 101 if (res == NULL) {
102 spin_unlock(&host->h_lock); 102 spin_unlock(&host->h_lock);
103 new = (struct nlm_lockowner *)kmalloc(sizeof(*new), GFP_KERNEL); 103 new = kmalloc(sizeof(*new), GFP_KERNEL);
104 spin_lock(&host->h_lock); 104 spin_lock(&host->h_lock);
105 res = __nlm_find_lockowner(host, owner); 105 res = __nlm_find_lockowner(host, owner);
106 if (res == NULL && new != NULL) { 106 if (res == NULL && new != NULL) {
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 703fb038c813..a0d0b58ce7a4 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -99,9 +99,9 @@ nlm_lookup_host(int server, struct sockaddr_in *sin,
99 /* Ooops, no host found, create it */ 99 /* Ooops, no host found, create it */
100 dprintk("lockd: creating host entry\n"); 100 dprintk("lockd: creating host entry\n");
101 101
102 if (!(host = (struct nlm_host *) kmalloc(sizeof(*host), GFP_KERNEL))) 102 host = kzalloc(sizeof(*host), GFP_KERNEL);
103 if (!host)
103 goto nohost; 104 goto nohost;
104 memset(host, 0, sizeof(*host));
105 105
106 addr = sin->sin_addr.s_addr; 106 addr = sin->sin_addr.s_addr;
107 sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr)); 107 sprintf(host->h_name, "%u.%u.%u.%u", NIPQUAD(addr));
diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c
index 01b4db9e5466..a92dd98f8401 100644
--- a/fs/lockd/svcsubs.c
+++ b/fs/lockd/svcsubs.c
@@ -100,11 +100,10 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
100 nlm_debug_print_fh("creating file for", f); 100 nlm_debug_print_fh("creating file for", f);
101 101
102 nfserr = nlm_lck_denied_nolocks; 102 nfserr = nlm_lck_denied_nolocks;
103 file = (struct nlm_file *) kmalloc(sizeof(*file), GFP_KERNEL); 103 file = kzalloc(sizeof(*file), GFP_KERNEL);
104 if (!file) 104 if (!file)
105 goto out_unlock; 105 goto out_unlock;
106 106
107 memset(file, 0, sizeof(*file));
108 memcpy(&file->f_handle, f, sizeof(struct nfs_fh)); 107 memcpy(&file->f_handle, f, sizeof(struct nfs_fh));
109 file->f_hash = hash; 108 file->f_hash = hash;
110 init_MUTEX(&file->f_sema); 109 init_MUTEX(&file->f_sema);
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index 4a6abc49418e..df6b1075b549 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -254,7 +254,7 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
254 inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; 254 inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
255 inode->i_ino = j; 255 inode->i_ino = j;
256 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 256 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
257 inode->i_blocks = inode->i_blksize = 0; 257 inode->i_blocks = 0;
258 memset(&minix_i(inode)->u, 0, sizeof(minix_i(inode)->u)); 258 memset(&minix_i(inode)->u, 0, sizeof(minix_i(inode)->u));
259 insert_inode_hash(inode); 259 insert_inode_hash(inode);
260 mark_inode_dirty(inode); 260 mark_inode_dirty(inode);
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 330ff9fc7cf0..c11a4b9fb863 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -90,8 +90,7 @@ static int init_inodecache(void)
90 90
91static void destroy_inodecache(void) 91static void destroy_inodecache(void)
92{ 92{
93 if (kmem_cache_destroy(minix_inode_cachep)) 93 kmem_cache_destroy(minix_inode_cachep);
94 printk(KERN_INFO "minix_inode_cache: not all structures were freed\n");
95} 94}
96 95
97static struct super_operations minix_sops = { 96static struct super_operations minix_sops = {
@@ -145,11 +144,10 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
145 struct inode *root_inode; 144 struct inode *root_inode;
146 struct minix_sb_info *sbi; 145 struct minix_sb_info *sbi;
147 146
148 sbi = kmalloc(sizeof(struct minix_sb_info), GFP_KERNEL); 147 sbi = kzalloc(sizeof(struct minix_sb_info), GFP_KERNEL);
149 if (!sbi) 148 if (!sbi)
150 return -ENOMEM; 149 return -ENOMEM;
151 s->s_fs_info = sbi; 150 s->s_fs_info = sbi;
152 memset(sbi, 0, sizeof(struct minix_sb_info));
153 151
154 /* N.B. These should be compile-time tests. 152 /* N.B. These should be compile-time tests.
155 Unfortunately that is impossible. */ 153 Unfortunately that is impossible. */
@@ -207,10 +205,9 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
207 if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0) 205 if (sbi->s_imap_blocks == 0 || sbi->s_zmap_blocks == 0)
208 goto out_illegal_sb; 206 goto out_illegal_sb;
209 i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh); 207 i = (sbi->s_imap_blocks + sbi->s_zmap_blocks) * sizeof(bh);
210 map = kmalloc(i, GFP_KERNEL); 208 map = kzalloc(i, GFP_KERNEL);
211 if (!map) 209 if (!map)
212 goto out_no_map; 210 goto out_no_map;
213 memset(map, 0, i);
214 sbi->s_imap = &map[0]; 211 sbi->s_imap = &map[0];
215 sbi->s_zmap = &map[sbi->s_imap_blocks]; 212 sbi->s_zmap = &map[sbi->s_imap_blocks];
216 213
@@ -399,7 +396,7 @@ static void V1_minix_read_inode(struct inode * inode)
399 inode->i_mtime.tv_nsec = 0; 396 inode->i_mtime.tv_nsec = 0;
400 inode->i_atime.tv_nsec = 0; 397 inode->i_atime.tv_nsec = 0;
401 inode->i_ctime.tv_nsec = 0; 398 inode->i_ctime.tv_nsec = 0;
402 inode->i_blocks = inode->i_blksize = 0; 399 inode->i_blocks = 0;
403 for (i = 0; i < 9; i++) 400 for (i = 0; i < 9; i++)
404 minix_inode->u.i1_data[i] = raw_inode->i_zone[i]; 401 minix_inode->u.i1_data[i] = raw_inode->i_zone[i];
405 minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); 402 minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0]));
@@ -432,7 +429,7 @@ static void V2_minix_read_inode(struct inode * inode)
432 inode->i_mtime.tv_nsec = 0; 429 inode->i_mtime.tv_nsec = 0;
433 inode->i_atime.tv_nsec = 0; 430 inode->i_atime.tv_nsec = 0;
434 inode->i_ctime.tv_nsec = 0; 431 inode->i_ctime.tv_nsec = 0;
435 inode->i_blocks = inode->i_blksize = 0; 432 inode->i_blocks = 0;
436 for (i = 0; i < 10; i++) 433 for (i = 0; i < 10; i++)
437 minix_inode->u.i2_data[i] = raw_inode->i_zone[i]; 434 minix_inode->u.i2_data[i] = raw_inode->i_zone[i];
438 minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0])); 435 minix_set_inode(inode, old_decode_dev(raw_inode->i_zone[0]));
diff --git a/fs/namei.c b/fs/namei.c
index 6b591c01b09f..808e4ea2bb94 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -372,6 +372,30 @@ void release_open_intent(struct nameidata *nd)
372 fput(nd->intent.open.file); 372 fput(nd->intent.open.file);
373} 373}
374 374
375static inline struct dentry *
376do_revalidate(struct dentry *dentry, struct nameidata *nd)
377{
378 int status = dentry->d_op->d_revalidate(dentry, nd);
379 if (unlikely(status <= 0)) {
380 /*
381 * The dentry failed validation.
382 * If d_revalidate returned 0 attempt to invalidate
383 * the dentry otherwise d_revalidate is asking us
384 * to return a fail status.
385 */
386 if (!status) {
387 if (!d_invalidate(dentry)) {
388 dput(dentry);
389 dentry = NULL;
390 }
391 } else {
392 dput(dentry);
393 dentry = ERR_PTR(status);
394 }
395 }
396 return dentry;
397}
398
375/* 399/*
376 * Internal lookup() using the new generic dcache. 400 * Internal lookup() using the new generic dcache.
377 * SMP-safe 401 * SMP-safe
@@ -386,12 +410,9 @@ static struct dentry * cached_lookup(struct dentry * parent, struct qstr * name,
386 if (!dentry) 410 if (!dentry)
387 dentry = d_lookup(parent, name); 411 dentry = d_lookup(parent, name);
388 412
389 if (dentry && dentry->d_op && dentry->d_op->d_revalidate) { 413 if (dentry && dentry->d_op && dentry->d_op->d_revalidate)
390 if (!dentry->d_op->d_revalidate(dentry, nd) && !d_invalidate(dentry)) { 414 dentry = do_revalidate(dentry, nd);
391 dput(dentry); 415
392 dentry = NULL;
393 }
394 }
395 return dentry; 416 return dentry;
396} 417}
397 418
@@ -484,10 +505,9 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, s
484 */ 505 */
485 mutex_unlock(&dir->i_mutex); 506 mutex_unlock(&dir->i_mutex);
486 if (result->d_op && result->d_op->d_revalidate) { 507 if (result->d_op && result->d_op->d_revalidate) {
487 if (!result->d_op->d_revalidate(result, nd) && !d_invalidate(result)) { 508 result = do_revalidate(result, nd);
488 dput(result); 509 if (!result)
489 result = ERR_PTR(-ENOENT); 510 result = ERR_PTR(-ENOENT);
490 }
491 } 511 }
492 return result; 512 return result;
493} 513}
@@ -767,12 +787,12 @@ need_lookup:
767 goto done; 787 goto done;
768 788
769need_revalidate: 789need_revalidate:
770 if (dentry->d_op->d_revalidate(dentry, nd)) 790 dentry = do_revalidate(dentry, nd);
771 goto done; 791 if (!dentry)
772 if (d_invalidate(dentry)) 792 goto need_lookup;
773 goto done; 793 if (IS_ERR(dentry))
774 dput(dentry); 794 goto fail;
775 goto need_lookup; 795 goto done;
776 796
777fail: 797fail:
778 return PTR_ERR(dentry); 798 return PTR_ERR(dentry);
diff --git a/fs/namespace.c b/fs/namespace.c
index fa7ed6a9fc2d..36d180858136 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -17,6 +17,7 @@
17#include <linux/acct.h> 17#include <linux/acct.h>
18#include <linux/capability.h> 18#include <linux/capability.h>
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/sysfs.h>
20#include <linux/seq_file.h> 21#include <linux/seq_file.h>
21#include <linux/namespace.h> 22#include <linux/namespace.h>
22#include <linux/namei.h> 23#include <linux/namei.h>
@@ -28,15 +29,6 @@
28 29
29extern int __init init_rootfs(void); 30extern int __init init_rootfs(void);
30 31
31#ifdef CONFIG_SYSFS
32extern int __init sysfs_init(void);
33#else
34static inline int sysfs_init(void)
35{
36 return 0;
37}
38#endif
39
40/* spinlock for vfsmount related operations, inplace of dcache_lock */ 32/* spinlock for vfsmount related operations, inplace of dcache_lock */
41__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock); 33__cacheline_aligned_in_smp DEFINE_SPINLOCK(vfsmount_lock);
42 34
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index 1ddf77b0b825..42e3bef270c9 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -81,8 +81,7 @@ static int init_inodecache(void)
81 81
82static void destroy_inodecache(void) 82static void destroy_inodecache(void)
83{ 83{
84 if (kmem_cache_destroy(ncp_inode_cachep)) 84 kmem_cache_destroy(ncp_inode_cachep);
85 printk(KERN_INFO "ncp_inode_cache: not all structures were freed\n");
86} 85}
87 86
88static int ncp_remount(struct super_block *sb, int *flags, char* data) 87static int ncp_remount(struct super_block *sb, int *flags, char* data)
@@ -224,7 +223,6 @@ static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo)
224 inode->i_nlink = 1; 223 inode->i_nlink = 1;
225 inode->i_uid = server->m.uid; 224 inode->i_uid = server->m.uid;
226 inode->i_gid = server->m.gid; 225 inode->i_gid = server->m.gid;
227 inode->i_blksize = NCP_BLOCK_SIZE;
228 226
229 ncp_update_dates(inode, &nwinfo->i); 227 ncp_update_dates(inode, &nwinfo->i);
230 ncp_update_inode(inode, nwinfo); 228 ncp_update_inode(inode, nwinfo);
@@ -411,11 +409,10 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
411#endif 409#endif
412 struct ncp_entry_info finfo; 410 struct ncp_entry_info finfo;
413 411
414 server = kmalloc(sizeof(struct ncp_server), GFP_KERNEL); 412 server = kzalloc(sizeof(struct ncp_server), GFP_KERNEL);
415 if (!server) 413 if (!server)
416 return -ENOMEM; 414 return -ENOMEM;
417 sb->s_fs_info = server; 415 sb->s_fs_info = server;
418 memset(server, 0, sizeof(struct ncp_server));
419 416
420 error = -EFAULT; 417 error = -EFAULT;
421 if (raw_data == NULL) 418 if (raw_data == NULL)
diff --git a/fs/ncpfs/symlink.c b/fs/ncpfs/symlink.c
index ca92c2406635..e3d26c1bd105 100644
--- a/fs/ncpfs/symlink.c
+++ b/fs/ncpfs/symlink.c
@@ -48,7 +48,7 @@ static int ncp_symlink_readpage(struct file *file, struct page *page)
48 char *buf = kmap(page); 48 char *buf = kmap(page);
49 49
50 error = -ENOMEM; 50 error = -ENOMEM;
51 rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL); 51 rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
52 if (!rawlink) 52 if (!rawlink)
53 goto fail; 53 goto fail;
54 54
@@ -126,7 +126,7 @@ int ncp_symlink(struct inode *dir, struct dentry *dentry, const char *symname) {
126 /* EPERM is returned by VFS if symlink procedure does not exist */ 126 /* EPERM is returned by VFS if symlink procedure does not exist */
127 return -EPERM; 127 return -EPERM;
128 128
129 rawlink=(char *)kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL); 129 rawlink = kmalloc(NCP_MAX_SYMLINK_SIZE, GFP_KERNEL);
130 if (!rawlink) 130 if (!rawlink)
131 return -ENOMEM; 131 return -ENOMEM;
132 132
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 57133678db16..841c99a9b11c 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -20,11 +20,6 @@
20#include "delegation.h" 20#include "delegation.h"
21#include "internal.h" 21#include "internal.h"
22 22
23static struct nfs_delegation *nfs_alloc_delegation(void)
24{
25 return (struct nfs_delegation *)kmalloc(sizeof(struct nfs_delegation), GFP_KERNEL);
26}
27
28static void nfs_free_delegation(struct nfs_delegation *delegation) 23static void nfs_free_delegation(struct nfs_delegation *delegation)
29{ 24{
30 if (delegation->cred) 25 if (delegation->cred)
@@ -124,7 +119,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct
124 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR))) 119 if ((nfsi->cache_validity & (NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATTR)))
125 __nfs_revalidate_inode(NFS_SERVER(inode), inode); 120 __nfs_revalidate_inode(NFS_SERVER(inode), inode);
126 121
127 delegation = nfs_alloc_delegation(); 122 delegation = kmalloc(sizeof(*delegation), GFP_KERNEL);
128 if (delegation == NULL) 123 if (delegation == NULL)
129 return -ENOMEM; 124 return -ENOMEM;
130 memcpy(delegation->stateid.data, res->delegation.data, 125 memcpy(delegation->stateid.data, res->delegation.data,
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 76ca1cbc38f9..377839bed172 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -855,6 +855,5 @@ int __init nfs_init_directcache(void)
855 */ 855 */
856void nfs_destroy_directcache(void) 856void nfs_destroy_directcache(void)
857{ 857{
858 if (kmem_cache_destroy(nfs_direct_cachep)) 858 kmem_cache_destroy(nfs_direct_cachep);
859 printk(KERN_INFO "nfs_direct_cache: not all structures were freed\n");
860} 859}
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index e8c143d182c4..bc9376ca86cd 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -277,10 +277,8 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
277 * report the blocks in 512byte units 277 * report the blocks in 512byte units
278 */ 278 */
279 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used); 279 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
280 inode->i_blksize = inode->i_sb->s_blocksize;
281 } else { 280 } else {
282 inode->i_blocks = fattr->du.nfs2.blocks; 281 inode->i_blocks = fattr->du.nfs2.blocks;
283 inode->i_blksize = fattr->du.nfs2.blocksize;
284 } 282 }
285 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); 283 nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
286 nfsi->attrtimeo_timestamp = jiffies; 284 nfsi->attrtimeo_timestamp = jiffies;
@@ -443,7 +441,7 @@ static struct nfs_open_context *alloc_nfs_open_context(struct vfsmount *mnt, str
443{ 441{
444 struct nfs_open_context *ctx; 442 struct nfs_open_context *ctx;
445 443
446 ctx = (struct nfs_open_context *)kmalloc(sizeof(*ctx), GFP_KERNEL); 444 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
447 if (ctx != NULL) { 445 if (ctx != NULL) {
448 atomic_set(&ctx->count, 1); 446 atomic_set(&ctx->count, 1);
449 ctx->dentry = dget(dentry); 447 ctx->dentry = dget(dentry);
@@ -969,10 +967,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
969 * report the blocks in 512byte units 967 * report the blocks in 512byte units
970 */ 968 */
971 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used); 969 inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
972 inode->i_blksize = inode->i_sb->s_blocksize;
973 } else { 970 } else {
974 inode->i_blocks = fattr->du.nfs2.blocks; 971 inode->i_blocks = fattr->du.nfs2.blocks;
975 inode->i_blksize = fattr->du.nfs2.blocksize;
976 } 972 }
977 973
978 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && 974 if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 &&
@@ -1134,8 +1130,7 @@ static int __init nfs_init_inodecache(void)
1134 1130
1135static void nfs_destroy_inodecache(void) 1131static void nfs_destroy_inodecache(void)
1136{ 1132{
1137 if (kmem_cache_destroy(nfs_inode_cachep)) 1133 kmem_cache_destroy(nfs_inode_cachep);
1138 printk(KERN_INFO "nfs_inode_cache: not all structures were freed\n");
1139} 1134}
1140 1135
1141/* 1136/*
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 77b00684894d..60408646176b 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -26,6 +26,11 @@ LIST_HEAD(nfs_automount_list);
26static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list); 26static DECLARE_WORK(nfs_automount_task, nfs_expire_automounts, &nfs_automount_list);
27int nfs_mountpoint_expiry_timeout = 500 * HZ; 27int nfs_mountpoint_expiry_timeout = 500 * HZ;
28 28
29static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
30 const struct dentry *dentry,
31 struct nfs_fh *fh,
32 struct nfs_fattr *fattr);
33
29/* 34/*
30 * nfs_path - reconstruct the path given an arbitrary dentry 35 * nfs_path - reconstruct the path given an arbitrary dentry
31 * @base - arbitrary string to prepend to the path 36 * @base - arbitrary string to prepend to the path
@@ -209,9 +214,10 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
209 * @fattr - attributes for new root inode 214 * @fattr - attributes for new root inode
210 * 215 *
211 */ 216 */
212struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent, 217static struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
213 const struct dentry *dentry, struct nfs_fh *fh, 218 const struct dentry *dentry,
214 struct nfs_fattr *fattr) 219 struct nfs_fh *fh,
220 struct nfs_fattr *fattr)
215{ 221{
216 struct nfs_clone_mount mountdata = { 222 struct nfs_clone_mount mountdata = {
217 .sb = mnt_parent->mnt_sb, 223 .sb = mnt_parent->mnt_sb,
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index f8688eaa0001..3b234d4601e7 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -449,7 +449,7 @@ nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr
449 struct nfs_fattr res; 449 struct nfs_fattr res;
450 } *ptr; 450 } *ptr;
451 451
452 ptr = (struct unlinkxdr *)kmalloc(sizeof(*ptr), GFP_KERNEL); 452 ptr = kmalloc(sizeof(*ptr), GFP_KERNEL);
453 if (!ptr) 453 if (!ptr)
454 return -ENOMEM; 454 return -ENOMEM;
455 ptr->arg.fh = NFS_FH(dir->d_inode); 455 ptr->arg.fh = NFS_FH(dir->d_inode);
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 36e902a88ca1..829af323f288 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -392,7 +392,6 @@ int __init nfs_init_nfspagecache(void)
392 392
393void nfs_destroy_nfspagecache(void) 393void nfs_destroy_nfspagecache(void)
394{ 394{
395 if (kmem_cache_destroy(nfs_page_cachep)) 395 kmem_cache_destroy(nfs_page_cachep);
396 printk(KERN_INFO "nfs_page: not all structures were freed\n");
397} 396}
398 397
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c
index 630e50647bbb..4529cc4f3f8f 100644
--- a/fs/nfs/proc.c
+++ b/fs/nfs/proc.c
@@ -352,7 +352,7 @@ nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *
352{ 352{
353 struct nfs_diropargs *arg; 353 struct nfs_diropargs *arg;
354 354
355 arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL); 355 arg = kmalloc(sizeof(*arg), GFP_KERNEL);
356 if (!arg) 356 if (!arg)
357 return -ENOMEM; 357 return -ENOMEM;
358 arg->fh = NFS_FH(dir->d_inode); 358 arg->fh = NFS_FH(dir->d_inode);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 69f1549da2b9..c2e49c397a27 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -737,6 +737,5 @@ int __init nfs_init_readpagecache(void)
737void nfs_destroy_readpagecache(void) 737void nfs_destroy_readpagecache(void)
738{ 738{
739 mempool_destroy(nfs_rdata_mempool); 739 mempool_destroy(nfs_rdata_mempool);
740 if (kmem_cache_destroy(nfs_rdata_cachep)) 740 kmem_cache_destroy(nfs_rdata_cachep);
741 printk(KERN_INFO "nfs_read_data: not all structures were freed\n");
742} 741}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index c12effb46fe5..b674462793d3 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1565,7 +1565,6 @@ void nfs_destroy_writepagecache(void)
1565{ 1565{
1566 mempool_destroy(nfs_commit_mempool); 1566 mempool_destroy(nfs_commit_mempool);
1567 mempool_destroy(nfs_wdata_mempool); 1567 mempool_destroy(nfs_wdata_mempool);
1568 if (kmem_cache_destroy(nfs_wdata_cachep)) 1568 kmem_cache_destroy(nfs_wdata_cachep);
1569 printk(KERN_INFO "nfs_write_data: not all structures were freed\n");
1570} 1569}
1571 1570
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index bea6b9478114..b1902ebaab41 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -573,10 +573,9 @@ idmap_lookup(struct svc_rqst *rqstp,
573 struct idmap_defer_req *mdr; 573 struct idmap_defer_req *mdr;
574 int ret; 574 int ret;
575 575
576 mdr = kmalloc(sizeof(*mdr), GFP_KERNEL); 576 mdr = kzalloc(sizeof(*mdr), GFP_KERNEL);
577 if (!mdr) 577 if (!mdr)
578 return -ENOMEM; 578 return -ENOMEM;
579 memset(mdr, 0, sizeof(*mdr));
580 atomic_set(&mdr->count, 1); 579 atomic_set(&mdr->count, 1);
581 init_waitqueue_head(&mdr->waitq); 580 init_waitqueue_head(&mdr->waitq);
582 mdr->req.defer = idmap_defer; 581 mdr->req.defer = idmap_defer;
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 9daa0b9feb8d..ebcf226a9e4a 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -339,8 +339,7 @@ alloc_client(struct xdr_netobj name)
339{ 339{
340 struct nfs4_client *clp; 340 struct nfs4_client *clp;
341 341
342 if ((clp = kmalloc(sizeof(struct nfs4_client), GFP_KERNEL))!= NULL) { 342 if ((clp = kzalloc(sizeof(struct nfs4_client), GFP_KERNEL))!= NULL) {
343 memset(clp, 0, sizeof(*clp));
344 if ((clp->cl_name.data = kmalloc(name.len, GFP_KERNEL)) != NULL) { 343 if ((clp->cl_name.data = kmalloc(name.len, GFP_KERNEL)) != NULL) {
345 memcpy(clp->cl_name.data, name.data, name.len); 344 memcpy(clp->cl_name.data, name.data, name.len);
346 clp->cl_name.len = name.len; 345 clp->cl_name.len = name.len;
@@ -1006,13 +1005,10 @@ alloc_init_file(struct inode *ino)
1006static void 1005static void
1007nfsd4_free_slab(kmem_cache_t **slab) 1006nfsd4_free_slab(kmem_cache_t **slab)
1008{ 1007{
1009 int status;
1010
1011 if (*slab == NULL) 1008 if (*slab == NULL)
1012 return; 1009 return;
1013 status = kmem_cache_destroy(*slab); 1010 kmem_cache_destroy(*slab);
1014 *slab = NULL; 1011 *slab = NULL;
1015 WARN_ON(status);
1016} 1012}
1017 1013
1018static void 1014static void
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index d1e2c6f9f05e..85c36b8ca452 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1149,8 +1149,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
1149 * Allocate a buffer to store the current name being processed 1149 * Allocate a buffer to store the current name being processed
1150 * converted to format determined by current NLS. 1150 * converted to format determined by current NLS.
1151 */ 1151 */
1152 name = (u8*)kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, 1152 name = kmalloc(NTFS_MAX_NAME_LEN * NLS_MAX_CHARSET_SIZE + 1, GFP_NOFS);
1153 GFP_NOFS);
1154 if (unlikely(!name)) { 1153 if (unlikely(!name)) {
1155 err = -ENOMEM; 1154 err = -ENOMEM;
1156 goto err_out; 1155 goto err_out;
@@ -1191,7 +1190,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
1191 * map the mft record without deadlocking. 1190 * map the mft record without deadlocking.
1192 */ 1191 */
1193 rc = le32_to_cpu(ctx->attr->data.resident.value_length); 1192 rc = le32_to_cpu(ctx->attr->data.resident.value_length);
1194 ir = (INDEX_ROOT*)kmalloc(rc, GFP_NOFS); 1193 ir = kmalloc(rc, GFP_NOFS);
1195 if (unlikely(!ir)) { 1194 if (unlikely(!ir)) {
1196 err = -ENOMEM; 1195 err = -ENOMEM;
1197 goto err_out; 1196 goto err_out;
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index d313f356e66a..933dbd89c2a4 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -137,7 +137,7 @@ static int ntfs_init_locked_inode(struct inode *vi, ntfs_attr *na)
137 137
138 BUG_ON(!na->name); 138 BUG_ON(!na->name);
139 i = na->name_len * sizeof(ntfschar); 139 i = na->name_len * sizeof(ntfschar);
140 ni->name = (ntfschar*)kmalloc(i + sizeof(ntfschar), GFP_ATOMIC); 140 ni->name = kmalloc(i + sizeof(ntfschar), GFP_ATOMIC);
141 if (!ni->name) 141 if (!ni->name)
142 return -ENOMEM; 142 return -ENOMEM;
143 memcpy(ni->name, na->name, i); 143 memcpy(ni->name, na->name, i);
@@ -556,8 +556,6 @@ static int ntfs_read_locked_inode(struct inode *vi)
556 556
557 /* Setup the generic vfs inode parts now. */ 557 /* Setup the generic vfs inode parts now. */
558 558
559 /* This is the optimal IO size (for stat), not the fs block size. */
560 vi->i_blksize = PAGE_CACHE_SIZE;
561 /* 559 /*
562 * This is for checking whether an inode has changed w.r.t. a file so 560 * This is for checking whether an inode has changed w.r.t. a file so
563 * that the file can be updated if necessary (compare with f_version). 561 * that the file can be updated if necessary (compare with f_version).
@@ -1234,7 +1232,6 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
1234 base_ni = NTFS_I(base_vi); 1232 base_ni = NTFS_I(base_vi);
1235 1233
1236 /* Just mirror the values from the base inode. */ 1234 /* Just mirror the values from the base inode. */
1237 vi->i_blksize = base_vi->i_blksize;
1238 vi->i_version = base_vi->i_version; 1235 vi->i_version = base_vi->i_version;
1239 vi->i_uid = base_vi->i_uid; 1236 vi->i_uid = base_vi->i_uid;
1240 vi->i_gid = base_vi->i_gid; 1237 vi->i_gid = base_vi->i_gid;
@@ -1504,7 +1501,6 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1504 ni = NTFS_I(vi); 1501 ni = NTFS_I(vi);
1505 base_ni = NTFS_I(base_vi); 1502 base_ni = NTFS_I(base_vi);
1506 /* Just mirror the values from the base inode. */ 1503 /* Just mirror the values from the base inode. */
1507 vi->i_blksize = base_vi->i_blksize;
1508 vi->i_version = base_vi->i_version; 1504 vi->i_version = base_vi->i_version;
1509 vi->i_uid = base_vi->i_uid; 1505 vi->i_uid = base_vi->i_uid;
1510 vi->i_gid = base_vi->i_gid; 1506 vi->i_gid = base_vi->i_gid;
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 2438c00ec0ce..584260fd6848 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -331,7 +331,7 @@ map_err_out:
331 ntfs_inode **tmp; 331 ntfs_inode **tmp;
332 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *); 332 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *);
333 333
334 tmp = (ntfs_inode **)kmalloc(new_size, GFP_NOFS); 334 tmp = kmalloc(new_size, GFP_NOFS);
335 if (unlikely(!tmp)) { 335 if (unlikely(!tmp)) {
336 ntfs_error(base_ni->vol->sb, "Failed to allocate " 336 ntfs_error(base_ni->vol->sb, "Failed to allocate "
337 "internal buffer."); 337 "internal buffer.");
@@ -2638,11 +2638,6 @@ mft_rec_already_initialized:
2638 } 2638 }
2639 vi->i_ino = bit; 2639 vi->i_ino = bit;
2640 /* 2640 /*
2641 * This is the optimal IO size (for stat), not the fs block
2642 * size.
2643 */
2644 vi->i_blksize = PAGE_CACHE_SIZE;
2645 /*
2646 * This is for checking whether an inode has changed w.r.t. a 2641 * This is for checking whether an inode has changed w.r.t. a
2647 * file so that the file can be updated if necessary (compare 2642 * file so that the file can be updated if necessary (compare
2648 * with f_version). 2643 * with f_version).
@@ -2893,7 +2888,7 @@ rollback:
2893 if (!(base_ni->nr_extents & 3)) { 2888 if (!(base_ni->nr_extents & 3)) {
2894 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*); 2889 int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*);
2895 2890
2896 extent_nis = (ntfs_inode**)kmalloc(new_size, GFP_NOFS); 2891 extent_nis = kmalloc(new_size, GFP_NOFS);
2897 if (unlikely(!extent_nis)) { 2892 if (unlikely(!extent_nis)) {
2898 ntfs_error(vol->sb, "Failed to allocate internal " 2893 ntfs_error(vol->sb, "Failed to allocate internal "
2899 "buffer during rollback.%s", es); 2894 "buffer during rollback.%s", es);
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 74e0ee8fce72..6b2712f10dd2 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -3248,32 +3248,14 @@ ictx_err_out:
3248 3248
3249static void __exit exit_ntfs_fs(void) 3249static void __exit exit_ntfs_fs(void)
3250{ 3250{
3251 int err = 0;
3252
3253 ntfs_debug("Unregistering NTFS driver."); 3251 ntfs_debug("Unregistering NTFS driver.");
3254 3252
3255 unregister_filesystem(&ntfs_fs_type); 3253 unregister_filesystem(&ntfs_fs_type);
3256 3254 kmem_cache_destroy(ntfs_big_inode_cache);
3257 if (kmem_cache_destroy(ntfs_big_inode_cache) && (err = 1)) 3255 kmem_cache_destroy(ntfs_inode_cache);
3258 printk(KERN_CRIT "NTFS: Failed to destory %s.\n", 3256 kmem_cache_destroy(ntfs_name_cache);
3259 ntfs_big_inode_cache_name); 3257 kmem_cache_destroy(ntfs_attr_ctx_cache);
3260 if (kmem_cache_destroy(ntfs_inode_cache) && (err = 1)) 3258 kmem_cache_destroy(ntfs_index_ctx_cache);
3261 printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
3262 ntfs_inode_cache_name);
3263 if (kmem_cache_destroy(ntfs_name_cache) && (err = 1))
3264 printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
3265 ntfs_name_cache_name);
3266 if (kmem_cache_destroy(ntfs_attr_ctx_cache) && (err = 1))
3267 printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
3268 ntfs_attr_ctx_cache_name);
3269 if (kmem_cache_destroy(ntfs_index_ctx_cache) && (err = 1))
3270 printk(KERN_CRIT "NTFS: Failed to destory %s.\n",
3271 ntfs_index_ctx_cache_name);
3272 if (err)
3273 printk(KERN_CRIT "NTFS: This causes memory to leak! There is "
3274 "probably a BUG in the driver! Please report "
3275 "you saw this message to "
3276 "linux-ntfs-dev@lists.sourceforge.net\n");
3277 /* Unregister the ntfs sysctls. */ 3259 /* Unregister the ntfs sysctls. */
3278 ntfs_sysctl(0); 3260 ntfs_sysctl(0);
3279} 3261}
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
index b123c0fa6bf6..a1b572196fe4 100644
--- a/fs/ntfs/unistr.c
+++ b/fs/ntfs/unistr.c
@@ -350,7 +350,7 @@ int ntfs_ucstonls(const ntfs_volume *vol, const ntfschar *ins,
350 } 350 }
351 if (!ns) { 351 if (!ns) {
352 ns_len = ins_len * NLS_MAX_CHARSET_SIZE; 352 ns_len = ins_len * NLS_MAX_CHARSET_SIZE;
353 ns = (unsigned char*)kmalloc(ns_len + 1, GFP_NOFS); 353 ns = kmalloc(ns_len + 1, GFP_NOFS);
354 if (!ns) 354 if (!ns)
355 goto mem_err_out; 355 goto mem_err_out;
356 } 356 }
@@ -365,7 +365,7 @@ retry: wc = nls->uni2char(le16_to_cpu(ins[i]), ns + o,
365 else if (wc == -ENAMETOOLONG && ns != *outs) { 365 else if (wc == -ENAMETOOLONG && ns != *outs) {
366 unsigned char *tc; 366 unsigned char *tc;
367 /* Grow in multiples of 64 bytes. */ 367 /* Grow in multiples of 64 bytes. */
368 tc = (unsigned char*)kmalloc((ns_len + 64) & 368 tc = kmalloc((ns_len + 64) &
369 ~63, GFP_NOFS); 369 ~63, GFP_NOFS);
370 if (tc) { 370 if (tc) {
371 memcpy(tc, ns, ns_len); 371 memcpy(tc, ns, ns_len);
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index 033ad1701232..0368c6402182 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -335,7 +335,6 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb)
335 inode->i_mode = mode; 335 inode->i_mode = mode;
336 inode->i_uid = current->fsuid; 336 inode->i_uid = current->fsuid;
337 inode->i_gid = current->fsgid; 337 inode->i_gid = current->fsgid;
338 inode->i_blksize = PAGE_CACHE_SIZE;
339 inode->i_blocks = 0; 338 inode->i_blocks = 0;
340 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 339 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
341 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 340 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -362,7 +361,6 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
362 inode->i_mode = mode; 361 inode->i_mode = mode;
363 inode->i_uid = current->fsuid; 362 inode->i_uid = current->fsuid;
364 inode->i_gid = current->fsgid; 363 inode->i_gid = current->fsgid;
365 inode->i_blksize = PAGE_CACHE_SIZE;
366 inode->i_blocks = 0; 364 inode->i_blocks = 0;
367 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; 365 inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info;
368 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 366 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
@@ -629,9 +627,7 @@ static void __exit exit_dlmfs_fs(void)
629 flush_workqueue(user_dlm_worker); 627 flush_workqueue(user_dlm_worker);
630 destroy_workqueue(user_dlm_worker); 628 destroy_workqueue(user_dlm_worker);
631 629
632 if (kmem_cache_destroy(dlmfs_inode_cache)) 630 kmem_cache_destroy(dlmfs_inode_cache);
633 printk(KERN_INFO "dlmfs_inode_cache: not all structures "
634 "were freed\n");
635} 631}
636 632
637MODULE_AUTHOR("Oracle"); 633MODULE_AUTHOR("Oracle");
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index de887063dcfc..8801e41afe80 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2052,7 +2052,7 @@ static int ocfs2_dlm_debug_open(struct inode *inode, struct file *file)
2052 mlog_errno(ret); 2052 mlog_errno(ret);
2053 goto out; 2053 goto out;
2054 } 2054 }
2055 osb = (struct ocfs2_super *) inode->u.generic_ip; 2055 osb = inode->i_private;
2056 ocfs2_get_dlm_debug(osb->osb_dlm_debug); 2056 ocfs2_get_dlm_debug(osb->osb_dlm_debug);
2057 priv->p_dlm_debug = osb->osb_dlm_debug; 2057 priv->p_dlm_debug = osb->osb_dlm_debug;
2058 INIT_LIST_HEAD(&priv->p_iter_res.l_debug_list); 2058 INIT_LIST_HEAD(&priv->p_iter_res.l_debug_list);
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 69d3db569166..16e8e74dc966 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -269,7 +269,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
269 inode->i_mode = le16_to_cpu(fe->i_mode); 269 inode->i_mode = le16_to_cpu(fe->i_mode);
270 inode->i_uid = le32_to_cpu(fe->i_uid); 270 inode->i_uid = le32_to_cpu(fe->i_uid);
271 inode->i_gid = le32_to_cpu(fe->i_gid); 271 inode->i_gid = le32_to_cpu(fe->i_gid);
272 inode->i_blksize = (u32)osb->s_clustersize;
273 272
274 /* Fast symlinks will have i_size but no allocated clusters. */ 273 /* Fast symlinks will have i_size but no allocated clusters. */
275 if (S_ISLNK(inode->i_mode) && !fe->i_clusters) 274 if (S_ISLNK(inode->i_mode) && !fe->i_clusters)
@@ -1258,8 +1257,6 @@ leave:
1258void ocfs2_refresh_inode(struct inode *inode, 1257void ocfs2_refresh_inode(struct inode *inode,
1259 struct ocfs2_dinode *fe) 1258 struct ocfs2_dinode *fe)
1260{ 1259{
1261 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1262
1263 spin_lock(&OCFS2_I(inode)->ip_lock); 1260 spin_lock(&OCFS2_I(inode)->ip_lock);
1264 1261
1265 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters); 1262 OCFS2_I(inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
@@ -1270,7 +1267,6 @@ void ocfs2_refresh_inode(struct inode *inode,
1270 inode->i_uid = le32_to_cpu(fe->i_uid); 1267 inode->i_uid = le32_to_cpu(fe->i_uid);
1271 inode->i_gid = le32_to_cpu(fe->i_gid); 1268 inode->i_gid = le32_to_cpu(fe->i_gid);
1272 inode->i_mode = le16_to_cpu(fe->i_mode); 1269 inode->i_mode = le16_to_cpu(fe->i_mode);
1273 inode->i_blksize = (u32) osb->s_clustersize;
1274 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0) 1270 if (S_ISLNK(inode->i_mode) && le32_to_cpu(fe->i_clusters) == 0)
1275 inode->i_blocks = 0; 1271 inode->i_blocks = 0;
1276 else 1272 else
diff --git a/fs/partitions/efi.c b/fs/partitions/efi.c
index 63730282ad81..1bea610078b3 100644
--- a/fs/partitions/efi.c
+++ b/fs/partitions/efi.c
@@ -238,10 +238,9 @@ alloc_read_gpt_entries(struct block_device *bdev, gpt_header *gpt)
238 le32_to_cpu(gpt->sizeof_partition_entry); 238 le32_to_cpu(gpt->sizeof_partition_entry);
239 if (!count) 239 if (!count)
240 return NULL; 240 return NULL;
241 pte = kmalloc(count, GFP_KERNEL); 241 pte = kzalloc(count, GFP_KERNEL);
242 if (!pte) 242 if (!pte)
243 return NULL; 243 return NULL;
244 memset(pte, 0, count);
245 244
246 if (read_lba(bdev, le64_to_cpu(gpt->partition_entry_lba), 245 if (read_lba(bdev, le64_to_cpu(gpt->partition_entry_lba),
247 (u8 *) pte, 246 (u8 *) pte,
@@ -269,10 +268,9 @@ alloc_read_gpt_header(struct block_device *bdev, u64 lba)
269 if (!bdev) 268 if (!bdev)
270 return NULL; 269 return NULL;
271 270
272 gpt = kmalloc(sizeof (gpt_header), GFP_KERNEL); 271 gpt = kzalloc(sizeof (gpt_header), GFP_KERNEL);
273 if (!gpt) 272 if (!gpt)
274 return NULL; 273 return NULL;
275 memset(gpt, 0, sizeof (gpt_header));
276 274
277 if (read_lba(bdev, lba, (u8 *) gpt, 275 if (read_lba(bdev, lba, (u8 *) gpt,
278 sizeof (gpt_header)) < sizeof (gpt_header)) { 276 sizeof (gpt_header)) < sizeof (gpt_header)) {
@@ -526,9 +524,8 @@ find_valid_gpt(struct block_device *bdev, gpt_header **gpt, gpt_entry **ptes)
526 lastlba = last_lba(bdev); 524 lastlba = last_lba(bdev);
527 if (!force_gpt) { 525 if (!force_gpt) {
528 /* This will be added to the EFI Spec. per Intel after v1.02. */ 526 /* This will be added to the EFI Spec. per Intel after v1.02. */
529 legacymbr = kmalloc(sizeof (*legacymbr), GFP_KERNEL); 527 legacymbr = kzalloc(sizeof (*legacymbr), GFP_KERNEL);
530 if (legacymbr) { 528 if (legacymbr) {
531 memset(legacymbr, 0, sizeof (*legacymbr));
532 read_lba(bdev, 0, (u8 *) legacymbr, 529 read_lba(bdev, 0, (u8 *) legacymbr,
533 sizeof (*legacymbr)); 530 sizeof (*legacymbr));
534 good_pmbr = is_pmbr_valid(legacymbr, lastlba); 531 good_pmbr = is_pmbr_valid(legacymbr, lastlba);
diff --git a/fs/pipe.c b/fs/pipe.c
index 20352573e025..f3b6f71e9d0b 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -879,7 +879,6 @@ static struct inode * get_pipe_inode(void)
879 inode->i_uid = current->fsuid; 879 inode->i_uid = current->fsuid;
880 inode->i_gid = current->fsgid; 880 inode->i_gid = current->fsgid;
881 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 881 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
882 inode->i_blksize = PAGE_SIZE;
883 882
884 return inode; 883 return inode;
885 884
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 146a434ba944..987c773dbb20 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -28,6 +28,7 @@ do { \
28 (vmi)->largest_chunk = 0; \ 28 (vmi)->largest_chunk = 0; \
29} while(0) 29} while(0)
30 30
31extern int nommu_vma_show(struct seq_file *, struct vm_area_struct *);
31#endif 32#endif
32 33
33extern void create_seq_entry(char *name, mode_t mode, const struct file_operations *f); 34extern void create_seq_entry(char *name, mode_t mode, const struct file_operations *f);
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 6a984f64edd7..3ceff3857272 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -279,12 +279,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
279 tsz = elf_buflen - *fpos; 279 tsz = elf_buflen - *fpos;
280 if (buflen < tsz) 280 if (buflen < tsz)
281 tsz = buflen; 281 tsz = buflen;
282 elf_buf = kmalloc(elf_buflen, GFP_ATOMIC); 282 elf_buf = kzalloc(elf_buflen, GFP_ATOMIC);
283 if (!elf_buf) { 283 if (!elf_buf) {
284 read_unlock(&kclist_lock); 284 read_unlock(&kclist_lock);
285 return -ENOMEM; 285 return -ENOMEM;
286 } 286 }
287 memset(elf_buf, 0, elf_buflen);
288 elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen); 287 elf_kcore_store_hdr(elf_buf, nphdr, elf_buflen);
289 read_unlock(&kclist_lock); 288 read_unlock(&kclist_lock);
290 if (copy_to_user(buffer, elf_buf + *fpos, tsz)) { 289 if (copy_to_user(buffer, elf_buf + *fpos, tsz)) {
@@ -330,10 +329,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
330 unsigned long curstart = start; 329 unsigned long curstart = start;
331 unsigned long cursize = tsz; 330 unsigned long cursize = tsz;
332 331
333 elf_buf = kmalloc(tsz, GFP_KERNEL); 332 elf_buf = kzalloc(tsz, GFP_KERNEL);
334 if (!elf_buf) 333 if (!elf_buf)
335 return -ENOMEM; 334 return -ENOMEM;
336 memset(elf_buf, 0, tsz);
337 335
338 read_lock(&vmlist_lock); 336 read_lock(&vmlist_lock);
339 for (m=vmlist; m && cursize; m=m->next) { 337 for (m=vmlist; m && cursize; m=m->next) {
diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
index cff10ab1af63..d7dbdf9e0f49 100644
--- a/fs/proc/nommu.c
+++ b/fs/proc/nommu.c
@@ -33,19 +33,15 @@
33#include "internal.h" 33#include "internal.h"
34 34
35/* 35/*
36 * display a list of all the VMAs the kernel knows about 36 * display a single VMA to a sequenced file
37 * - nommu kernals have a single flat list
38 */ 37 */
39static int nommu_vma_list_show(struct seq_file *m, void *v) 38int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma)
40{ 39{
41 struct vm_area_struct *vma;
42 unsigned long ino = 0; 40 unsigned long ino = 0;
43 struct file *file; 41 struct file *file;
44 dev_t dev = 0; 42 dev_t dev = 0;
45 int flags, len; 43 int flags, len;
46 44
47 vma = rb_entry((struct rb_node *) v, struct vm_area_struct, vm_rb);
48
49 flags = vma->vm_flags; 45 flags = vma->vm_flags;
50 file = vma->vm_file; 46 file = vma->vm_file;
51 47
@@ -78,6 +74,18 @@ static int nommu_vma_list_show(struct seq_file *m, void *v)
78 return 0; 74 return 0;
79} 75}
80 76
77/*
78 * display a list of all the VMAs the kernel knows about
79 * - nommu kernals have a single flat list
80 */
81static int nommu_vma_list_show(struct seq_file *m, void *v)
82{
83 struct vm_area_struct *vma;
84
85 vma = rb_entry((struct rb_node *) v, struct vm_area_struct, vm_rb);
86 return nommu_vma_show(m, vma);
87}
88
81static void *nommu_vma_list_start(struct seq_file *m, loff_t *_pos) 89static void *nommu_vma_list_start(struct seq_file *m, loff_t *_pos)
82{ 90{
83 struct rb_node *_rb; 91 struct rb_node *_rb;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 0a163a4f7764..6b769afac55a 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -122,11 +122,6 @@ struct mem_size_stats
122 unsigned long private_dirty; 122 unsigned long private_dirty;
123}; 123};
124 124
125__attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma)
126{
127 return NULL;
128}
129
130static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats *mss) 125static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats *mss)
131{ 126{
132 struct proc_maps_private *priv = m->private; 127 struct proc_maps_private *priv = m->private;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 4616ed50ffcd..091aa8e48e02 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -138,25 +138,63 @@ out:
138} 138}
139 139
140/* 140/*
141 * Albert D. Cahalan suggested to fake entries for the traditional 141 * display mapping lines for a particular process's /proc/pid/maps
142 * sections here. This might be worth investigating.
143 */ 142 */
144static int show_map(struct seq_file *m, void *v) 143static int show_map(struct seq_file *m, void *_vml)
145{ 144{
146 return 0; 145 struct vm_list_struct *vml = _vml;
146 return nommu_vma_show(m, vml->vma);
147} 147}
148
148static void *m_start(struct seq_file *m, loff_t *pos) 149static void *m_start(struct seq_file *m, loff_t *pos)
149{ 150{
151 struct proc_maps_private *priv = m->private;
152 struct vm_list_struct *vml;
153 struct mm_struct *mm;
154 loff_t n = *pos;
155
156 /* pin the task and mm whilst we play with them */
157 priv->task = get_pid_task(priv->pid, PIDTYPE_PID);
158 if (!priv->task)
159 return NULL;
160
161 mm = get_task_mm(priv->task);
162 if (!mm) {
163 put_task_struct(priv->task);
164 priv->task = NULL;
165 return NULL;
166 }
167
168 down_read(&mm->mmap_sem);
169
170 /* start from the Nth VMA */
171 for (vml = mm->context.vmlist; vml; vml = vml->next)
172 if (n-- == 0)
173 return vml;
150 return NULL; 174 return NULL;
151} 175}
152static void m_stop(struct seq_file *m, void *v) 176
177static void m_stop(struct seq_file *m, void *_vml)
153{ 178{
179 struct proc_maps_private *priv = m->private;
180
181 if (priv->task) {
182 struct mm_struct *mm = priv->task->mm;
183 up_read(&mm->mmap_sem);
184 mmput(mm);
185 put_task_struct(priv->task);
186 }
154} 187}
155static void *m_next(struct seq_file *m, void *v, loff_t *pos) 188
189static void *m_next(struct seq_file *m, void *_vml, loff_t *pos)
156{ 190{
157 return NULL; 191 struct vm_list_struct *vml = _vml;
192
193 (*pos)++;
194 return vml ? vml->next : NULL;
158} 195}
159static struct seq_operations proc_pid_maps_op = { 196
197static struct seq_operations proc_pid_maps_ops = {
160 .start = m_start, 198 .start = m_start,
161 .next = m_next, 199 .next = m_next,
162 .stop = m_stop, 200 .stop = m_stop,
@@ -165,11 +203,19 @@ static struct seq_operations proc_pid_maps_op = {
165 203
166static int maps_open(struct inode *inode, struct file *file) 204static int maps_open(struct inode *inode, struct file *file)
167{ 205{
168 int ret; 206 struct proc_maps_private *priv;
169 ret = seq_open(file, &proc_pid_maps_op); 207 int ret = -ENOMEM;
170 if (!ret) { 208
171 struct seq_file *m = file->private_data; 209 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
172 m->private = NULL; 210 if (priv) {
211 priv->pid = proc_pid(inode);
212 ret = seq_open(file, &proc_pid_maps_ops);
213 if (!ret) {
214 struct seq_file *m = file->private_data;
215 m->private = priv;
216 } else {
217 kfree(priv);
218 }
173 } 219 }
174 return ret; 220 return ret;
175} 221}
@@ -178,6 +224,6 @@ struct file_operations proc_maps_operations = {
178 .open = maps_open, 224 .open = maps_open,
179 .read = seq_read, 225 .read = seq_read,
180 .llseek = seq_lseek, 226 .llseek = seq_lseek,
181 .release = seq_release, 227 .release = seq_release_private,
182}; 228};
183 229
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 5a903491e697..5a41db2a218d 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -358,11 +358,10 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent)
358 const char *errmsg; 358 const char *errmsg;
359 struct qnx4_sb_info *qs; 359 struct qnx4_sb_info *qs;
360 360
361 qs = kmalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL); 361 qs = kzalloc(sizeof(struct qnx4_sb_info), GFP_KERNEL);
362 if (!qs) 362 if (!qs)
363 return -ENOMEM; 363 return -ENOMEM;
364 s->s_fs_info = qs; 364 s->s_fs_info = qs;
365 memset(qs, 0, sizeof(struct qnx4_sb_info));
366 365
367 sb_set_blocksize(s, QNX4_BLOCK_SIZE); 366 sb_set_blocksize(s, QNX4_BLOCK_SIZE);
368 367
@@ -497,7 +496,6 @@ static void qnx4_read_inode(struct inode *inode)
497 inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->di_ctime); 496 inode->i_ctime.tv_sec = le32_to_cpu(raw_inode->di_ctime);
498 inode->i_ctime.tv_nsec = 0; 497 inode->i_ctime.tv_nsec = 0;
499 inode->i_blocks = le32_to_cpu(raw_inode->di_first_xtnt.xtnt_size); 498 inode->i_blocks = le32_to_cpu(raw_inode->di_first_xtnt.xtnt_size);
500 inode->i_blksize = QNX4_DIR_ENTRY_SIZE;
501 499
502 memcpy(qnx4_inode, raw_inode, QNX4_DIR_ENTRY_SIZE); 500 memcpy(qnx4_inode, raw_inode, QNX4_DIR_ENTRY_SIZE);
503 if (S_ISREG(inode->i_mode)) { 501 if (S_ISREG(inode->i_mode)) {
@@ -557,9 +555,7 @@ static int init_inodecache(void)
557 555
558static void destroy_inodecache(void) 556static void destroy_inodecache(void)
559{ 557{
560 if (kmem_cache_destroy(qnx4_inode_cachep)) 558 kmem_cache_destroy(qnx4_inode_cachep);
561 printk(KERN_INFO
562 "qnx4_inode_cache: not all structures were freed\n");
563} 559}
564 560
565static int qnx4_get_sb(struct file_system_type *fs_type, 561static int qnx4_get_sb(struct file_system_type *fs_type,
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index b9677335cc8d..bc0e51662424 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -58,7 +58,6 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)
58 inode->i_mode = mode; 58 inode->i_mode = mode;
59 inode->i_uid = current->fsuid; 59 inode->i_uid = current->fsuid;
60 inode->i_gid = current->fsgid; 60 inode->i_gid = current->fsgid;
61 inode->i_blksize = PAGE_CACHE_SIZE;
62 inode->i_blocks = 0; 61 inode->i_blocks = 0;
63 inode->i_mapping->a_ops = &ramfs_aops; 62 inode->i_mapping->a_ops = &ramfs_aops;
64 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info; 63 inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index 52f1e2136546..8810fda0da46 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -17,8 +17,6 @@
17#include <linux/writeback.h> 17#include <linux/writeback.h>
18#include <linux/quotaops.h> 18#include <linux/quotaops.h>
19 19
20extern int reiserfs_default_io_size; /* default io size devuned in super.c */
21
22static int reiserfs_commit_write(struct file *f, struct page *page, 20static int reiserfs_commit_write(struct file *f, struct page *page,
23 unsigned from, unsigned to); 21 unsigned from, unsigned to);
24static int reiserfs_prepare_write(struct file *f, struct page *page, 22static int reiserfs_prepare_write(struct file *f, struct page *page,
@@ -1122,7 +1120,6 @@ static void init_inode(struct inode *inode, struct path *path)
1122 ih = PATH_PITEM_HEAD(path); 1120 ih = PATH_PITEM_HEAD(path);
1123 1121
1124 copy_key(INODE_PKEY(inode), &(ih->ih_key)); 1122 copy_key(INODE_PKEY(inode), &(ih->ih_key));
1125 inode->i_blksize = reiserfs_default_io_size;
1126 1123
1127 INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list)); 1124 INIT_LIST_HEAD(&(REISERFS_I(inode)->i_prealloc_list));
1128 REISERFS_I(inode)->i_flags = 0; 1125 REISERFS_I(inode)->i_flags = 0;
@@ -1877,7 +1874,6 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1877 } 1874 }
1878 // these do not go to on-disk stat data 1875 // these do not go to on-disk stat data
1879 inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid); 1876 inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid);
1880 inode->i_blksize = reiserfs_default_io_size;
1881 1877
1882 // store in in-core inode the key of stat data and version all 1878 // store in in-core inode the key of stat data and version all
1883 // object items will have (directory items will have old offset 1879 // object items will have (directory items will have old offset
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 5567328f1041..b40d4d64d598 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -530,9 +530,7 @@ static int init_inodecache(void)
530 530
531static void destroy_inodecache(void) 531static void destroy_inodecache(void)
532{ 532{
533 if (kmem_cache_destroy(reiserfs_inode_cachep)) 533 kmem_cache_destroy(reiserfs_inode_cachep);
534 reiserfs_warning(NULL,
535 "reiserfs_inode_cache: not all structures were freed");
536} 534}
537 535
538/* we don't mark inodes dirty, we just log them */ 536/* we don't mark inodes dirty, we just log them */
@@ -725,12 +723,6 @@ static const arg_desc_t error_actions[] = {
725 {NULL, 0, 0}, 723 {NULL, 0, 0},
726}; 724};
727 725
728int reiserfs_default_io_size = 128 * 1024; /* Default recommended I/O size is 128k.
729 There might be broken applications that are
730 confused by this. Use nolargeio mount option
731 to get usual i/o size = PAGE_SIZE.
732 */
733
734/* proceed only one option from a list *cur - string containing of mount options 726/* proceed only one option from a list *cur - string containing of mount options
735 opts - array of options which are accepted 727 opts - array of options which are accepted
736 opt_arg - if option is found and requires an argument and if it is specifed 728 opt_arg - if option is found and requires an argument and if it is specifed
@@ -959,19 +951,8 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
959 } 951 }
960 952
961 if (c == 'w') { 953 if (c == 'w') {
962 char *p = NULL; 954 reiserfs_warning(s, "reiserfs: nolargeio option is no longer supported");
963 int val = simple_strtoul(arg, &p, 0); 955 return 0;
964
965 if (*p != '\0') {
966 reiserfs_warning(s,
967 "reiserfs_parse_options: non-numeric value %s for nolargeio option",
968 arg);
969 return 0;
970 }
971 if (val)
972 reiserfs_default_io_size = PAGE_SIZE;
973 else
974 reiserfs_default_io_size = 128 * 1024;
975 } 956 }
976 957
977 if (c == 'j') { 958 if (c == 'j') {
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 22eed61ebf69..ddcd9e1ef282 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -589,8 +589,7 @@ static int init_inodecache(void)
589 589
590static void destroy_inodecache(void) 590static void destroy_inodecache(void)
591{ 591{
592 if (kmem_cache_destroy(romfs_inode_cachep)) 592 kmem_cache_destroy(romfs_inode_cachep);
593 printk(KERN_INFO "romfs_inode_cache: not all structures were freed\n");
594} 593}
595 594
596static int romfs_remount(struct super_block *sb, int *flags, char *data) 595static int romfs_remount(struct super_block *sb, int *flags, char *data)
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index a1ed657c3c84..2c122ee83adb 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -89,8 +89,7 @@ static int init_inodecache(void)
89 89
90static void destroy_inodecache(void) 90static void destroy_inodecache(void)
91{ 91{
92 if (kmem_cache_destroy(smb_inode_cachep)) 92 kmem_cache_destroy(smb_inode_cachep);
93 printk(KERN_INFO "smb_inode_cache: not all structures were freed\n");
94} 93}
95 94
96static int smb_remount(struct super_block *sb, int *flags, char *data) 95static int smb_remount(struct super_block *sb, int *flags, char *data)
@@ -167,7 +166,6 @@ smb_get_inode_attr(struct inode *inode, struct smb_fattr *fattr)
167 fattr->f_mtime = inode->i_mtime; 166 fattr->f_mtime = inode->i_mtime;
168 fattr->f_ctime = inode->i_ctime; 167 fattr->f_ctime = inode->i_ctime;
169 fattr->f_atime = inode->i_atime; 168 fattr->f_atime = inode->i_atime;
170 fattr->f_blksize= inode->i_blksize;
171 fattr->f_blocks = inode->i_blocks; 169 fattr->f_blocks = inode->i_blocks;
172 170
173 fattr->attr = SMB_I(inode)->attr; 171 fattr->attr = SMB_I(inode)->attr;
@@ -201,7 +199,6 @@ smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr)
201 inode->i_uid = fattr->f_uid; 199 inode->i_uid = fattr->f_uid;
202 inode->i_gid = fattr->f_gid; 200 inode->i_gid = fattr->f_gid;
203 inode->i_ctime = fattr->f_ctime; 201 inode->i_ctime = fattr->f_ctime;
204 inode->i_blksize= fattr->f_blksize;
205 inode->i_blocks = fattr->f_blocks; 202 inode->i_blocks = fattr->f_blocks;
206 inode->i_size = fattr->f_size; 203 inode->i_size = fattr->f_size;
207 inode->i_mtime = fattr->f_mtime; 204 inode->i_mtime = fattr->f_mtime;
diff --git a/fs/smbfs/proc.c b/fs/smbfs/proc.c
index c3495059889d..40e174db9872 100644
--- a/fs/smbfs/proc.c
+++ b/fs/smbfs/proc.c
@@ -1826,7 +1826,6 @@ smb_init_dirent(struct smb_sb_info *server, struct smb_fattr *fattr)
1826 fattr->f_nlink = 1; 1826 fattr->f_nlink = 1;
1827 fattr->f_uid = server->mnt->uid; 1827 fattr->f_uid = server->mnt->uid;
1828 fattr->f_gid = server->mnt->gid; 1828 fattr->f_gid = server->mnt->gid;
1829 fattr->f_blksize = SMB_ST_BLKSIZE;
1830 fattr->f_unix = 0; 1829 fattr->f_unix = 0;
1831} 1830}
1832 1831
diff --git a/fs/smbfs/request.c b/fs/smbfs/request.c
index c8e96195b96e..0fb74697abc4 100644
--- a/fs/smbfs/request.c
+++ b/fs/smbfs/request.c
@@ -49,8 +49,7 @@ int smb_init_request_cache(void)
49 49
50void smb_destroy_request_cache(void) 50void smb_destroy_request_cache(void)
51{ 51{
52 if (kmem_cache_destroy(req_cachep)) 52 kmem_cache_destroy(req_cachep);
53 printk(KERN_INFO "smb_destroy_request_cache: not all structures were freed\n");
54} 53}
55 54
56/* 55/*
diff --git a/fs/stat.c b/fs/stat.c
index 3a44dcf97da2..60a31d5e5966 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -14,6 +14,7 @@
14#include <linux/namei.h> 14#include <linux/namei.h>
15#include <linux/security.h> 15#include <linux/security.h>
16#include <linux/syscalls.h> 16#include <linux/syscalls.h>
17#include <linux/pagemap.h>
17 18
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include <asm/unistd.h> 20#include <asm/unistd.h>
@@ -32,7 +33,7 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
32 stat->ctime = inode->i_ctime; 33 stat->ctime = inode->i_ctime;
33 stat->size = i_size_read(inode); 34 stat->size = i_size_read(inode);
34 stat->blocks = inode->i_blocks; 35 stat->blocks = inode->i_blocks;
35 stat->blksize = inode->i_blksize; 36 stat->blksize = (1 << inode->i_blkbits);
36} 37}
37 38
38EXPORT_SYMBOL(generic_fillattr); 39EXPORT_SYMBOL(generic_fillattr);
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index c16a93c353c0..98022e41cda1 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/errno.h> 11#include <linux/errno.h>
12#include <linux/fs.h> 12#include <linux/fs.h>
13#include <linux/kernel.h>
13#include <linux/kobject.h> 14#include <linux/kobject.h>
14#include <linux/module.h> 15#include <linux/module.h>
15#include <linux/slab.h> 16#include <linux/slab.h>
@@ -176,7 +177,6 @@ const struct file_operations bin_fops = {
176 * sysfs_create_bin_file - create binary file for object. 177 * sysfs_create_bin_file - create binary file for object.
177 * @kobj: object. 178 * @kobj: object.
178 * @attr: attribute descriptor. 179 * @attr: attribute descriptor.
179 *
180 */ 180 */
181 181
182int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr) 182int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
@@ -191,13 +191,16 @@ int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
191 * sysfs_remove_bin_file - remove binary file for object. 191 * sysfs_remove_bin_file - remove binary file for object.
192 * @kobj: object. 192 * @kobj: object.
193 * @attr: attribute descriptor. 193 * @attr: attribute descriptor.
194 *
195 */ 194 */
196 195
197int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr) 196void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
198{ 197{
199 sysfs_hash_and_remove(kobj->dentry,attr->attr.name); 198 if (sysfs_hash_and_remove(kobj->dentry, attr->attr.name) < 0) {
200 return 0; 199 printk(KERN_ERR "%s: "
200 "bad dentry or inode or no such file: \"%s\"\n",
201 __FUNCTION__, attr->attr.name);
202 dump_stack();
203 }
201} 204}
202 205
203EXPORT_SYMBOL_GPL(sysfs_create_bin_file); 206EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 61c42430cba3..5f3d725d1125 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -43,7 +43,7 @@ static struct sysfs_dirent * sysfs_new_dirent(struct sysfs_dirent * parent_sd,
43 43
44 memset(sd, 0, sizeof(*sd)); 44 memset(sd, 0, sizeof(*sd));
45 atomic_set(&sd->s_count, 1); 45 atomic_set(&sd->s_count, 1);
46 atomic_set(&sd->s_event, 0); 46 atomic_set(&sd->s_event, 1);
47 INIT_LIST_HEAD(&sd->s_children); 47 INIT_LIST_HEAD(&sd->s_children);
48 list_add(&sd->s_sibling, &parent_sd->s_children); 48 list_add(&sd->s_sibling, &parent_sd->s_children);
49 sd->s_element = element; 49 sd->s_element = element;
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 9889e54e1f13..e79e38d52c00 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -12,6 +12,7 @@
12#include <linux/namei.h> 12#include <linux/namei.h>
13#include <linux/backing-dev.h> 13#include <linux/backing-dev.h>
14#include <linux/capability.h> 14#include <linux/capability.h>
15#include <linux/errno.h>
15#include "sysfs.h" 16#include "sysfs.h"
16 17
17extern struct super_block * sysfs_sb; 18extern struct super_block * sysfs_sb;
@@ -124,7 +125,6 @@ struct inode * sysfs_new_inode(mode_t mode, struct sysfs_dirent * sd)
124{ 125{
125 struct inode * inode = new_inode(sysfs_sb); 126 struct inode * inode = new_inode(sysfs_sb);
126 if (inode) { 127 if (inode) {
127 inode->i_blksize = PAGE_CACHE_SIZE;
128 inode->i_blocks = 0; 128 inode->i_blocks = 0;
129 inode->i_mapping->a_ops = &sysfs_aops; 129 inode->i_mapping->a_ops = &sysfs_aops;
130 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; 130 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info;
@@ -234,17 +234,18 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent)
234 } 234 }
235} 235}
236 236
237void sysfs_hash_and_remove(struct dentry * dir, const char * name) 237int sysfs_hash_and_remove(struct dentry * dir, const char * name)
238{ 238{
239 struct sysfs_dirent * sd; 239 struct sysfs_dirent * sd;
240 struct sysfs_dirent * parent_sd; 240 struct sysfs_dirent * parent_sd;
241 int found = 0;
241 242
242 if (!dir) 243 if (!dir)
243 return; 244 return -ENOENT;
244 245
245 if (dir->d_inode == NULL) 246 if (dir->d_inode == NULL)
246 /* no inode means this hasn't been made visible yet */ 247 /* no inode means this hasn't been made visible yet */
247 return; 248 return -ENOENT;
248 249
249 parent_sd = dir->d_fsdata; 250 parent_sd = dir->d_fsdata;
250 mutex_lock(&dir->d_inode->i_mutex); 251 mutex_lock(&dir->d_inode->i_mutex);
@@ -255,8 +256,11 @@ void sysfs_hash_and_remove(struct dentry * dir, const char * name)
255 list_del_init(&sd->s_sibling); 256 list_del_init(&sd->s_sibling);
256 sysfs_drop_dentry(sd, dir); 257 sysfs_drop_dentry(sd, dir);
257 sysfs_put(sd); 258 sysfs_put(sd);
259 found = 1;
258 break; 260 break;
259 } 261 }
260 } 262 }
261 mutex_unlock(&dir->d_inode->i_mutex); 263 mutex_unlock(&dir->d_inode->i_mutex);
264
265 return found ? 0 : -ENOENT;
262} 266}
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index d2eac3ceed5f..f50e3cc2ded8 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/mount.h>
6#include <linux/module.h> 7#include <linux/module.h>
7#include <linux/kobject.h> 8#include <linux/kobject.h>
8#include <linux/namei.h> 9#include <linux/namei.h>
@@ -82,10 +83,19 @@ exit1:
82 */ 83 */
83int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) 84int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
84{ 85{
85 struct dentry * dentry = kobj->dentry; 86 struct dentry *dentry = NULL;
86 int error = -EEXIST; 87 int error = -EEXIST;
87 88
88 BUG_ON(!kobj || !kobj->dentry || !name); 89 BUG_ON(!name);
90
91 if (!kobj) {
92 if (sysfs_mount && sysfs_mount->mnt_sb)
93 dentry = sysfs_mount->mnt_sb->s_root;
94 } else
95 dentry = kobj->dentry;
96
97 if (!dentry)
98 return -EFAULT;
89 99
90 mutex_lock(&dentry->d_inode->i_mutex); 100 mutex_lock(&dentry->d_inode->i_mutex);
91 if (!sysfs_dirent_exist(dentry->d_fsdata, name)) 101 if (!sysfs_dirent_exist(dentry->d_fsdata, name))
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 3651ffb5ec09..6f3d6bd52887 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -10,7 +10,7 @@ extern int sysfs_make_dirent(struct sysfs_dirent *, struct dentry *, void *,
10 umode_t, int); 10 umode_t, int);
11 11
12extern int sysfs_add_file(struct dentry *, const struct attribute *, int); 12extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
13extern void sysfs_hash_and_remove(struct dentry * dir, const char * name); 13extern int sysfs_hash_and_remove(struct dentry * dir, const char * name);
14extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name); 14extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name);
15 15
16extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **); 16extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
diff --git a/fs/sysv/ialloc.c b/fs/sysv/ialloc.c
index 9b585d1081c0..115ab0d6f4bc 100644
--- a/fs/sysv/ialloc.c
+++ b/fs/sysv/ialloc.c
@@ -170,7 +170,7 @@ struct inode * sysv_new_inode(const struct inode * dir, mode_t mode)
170 inode->i_uid = current->fsuid; 170 inode->i_uid = current->fsuid;
171 inode->i_ino = fs16_to_cpu(sbi, ino); 171 inode->i_ino = fs16_to_cpu(sbi, ino);
172 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 172 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
173 inode->i_blocks = inode->i_blksize = 0; 173 inode->i_blocks = 0;
174 memset(SYSV_I(inode)->i_data, 0, sizeof(SYSV_I(inode)->i_data)); 174 memset(SYSV_I(inode)->i_data, 0, sizeof(SYSV_I(inode)->i_data));
175 SYSV_I(inode)->i_dir_start_lookup = 0; 175 SYSV_I(inode)->i_dir_start_lookup = 0;
176 insert_inode_hash(inode); 176 insert_inode_hash(inode);
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index 58b2d22142ba..d63c5e48b050 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -201,7 +201,7 @@ static void sysv_read_inode(struct inode *inode)
201 inode->i_ctime.tv_nsec = 0; 201 inode->i_ctime.tv_nsec = 0;
202 inode->i_atime.tv_nsec = 0; 202 inode->i_atime.tv_nsec = 0;
203 inode->i_mtime.tv_nsec = 0; 203 inode->i_mtime.tv_nsec = 0;
204 inode->i_blocks = inode->i_blksize = 0; 204 inode->i_blocks = 0;
205 205
206 si = SYSV_I(inode); 206 si = SYSV_I(inode);
207 for (block = 0; block < 10+1+1+1; block++) 207 for (block = 0; block < 10+1+1+1; block++)
diff --git a/fs/sysv/super.c b/fs/sysv/super.c
index 876639b93321..350cba5d6803 100644
--- a/fs/sysv/super.c
+++ b/fs/sysv/super.c
@@ -369,10 +369,9 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
369 if (64 != sizeof (struct sysv_inode)) 369 if (64 != sizeof (struct sysv_inode))
370 panic("sysv fs: bad inode size"); 370 panic("sysv fs: bad inode size");
371 371
372 sbi = kmalloc(sizeof(struct sysv_sb_info), GFP_KERNEL); 372 sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
373 if (!sbi) 373 if (!sbi)
374 return -ENOMEM; 374 return -ENOMEM;
375 memset(sbi, 0, sizeof(struct sysv_sb_info));
376 375
377 sbi->s_sb = sb; 376 sbi->s_sb = sb;
378 sbi->s_block_base = 0; 377 sbi->s_block_base = 0;
@@ -453,10 +452,9 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
453 if (64 != sizeof (struct sysv_inode)) 452 if (64 != sizeof (struct sysv_inode))
454 panic("sysv fs: bad i-node size"); 453 panic("sysv fs: bad i-node size");
455 454
456 sbi = kmalloc(sizeof(struct sysv_sb_info), GFP_KERNEL); 455 sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
457 if (!sbi) 456 if (!sbi)
458 return -ENOMEM; 457 return -ENOMEM;
459 memset(sbi, 0, sizeof(struct sysv_sb_info));
460 458
461 sbi->s_sb = sb; 459 sbi->s_sb = sb;
462 sbi->s_block_base = 0; 460 sbi->s_block_base = 0;
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 33323473e3c4..8206983f2ebf 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -121,7 +121,6 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
121 UDF_I_LOCATION(inode).logicalBlockNum = block; 121 UDF_I_LOCATION(inode).logicalBlockNum = block;
122 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum; 122 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
123 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); 123 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
124 inode->i_blksize = PAGE_SIZE;
125 inode->i_blocks = 0; 124 inode->i_blocks = 0;
126 UDF_I_LENEATTR(inode) = 0; 125 UDF_I_LENEATTR(inode) = 0;
127 UDF_I_LENALLOC(inode) = 0; 126 UDF_I_LENALLOC(inode) = 0;
@@ -130,14 +129,12 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
130 { 129 {
131 UDF_I_EFE(inode) = 1; 130 UDF_I_EFE(inode) = 1;
132 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); 131 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
133 UDF_I_DATA(inode) = kmalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL); 132 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
134 memset(UDF_I_DATA(inode), 0x00, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry));
135 } 133 }
136 else 134 else
137 { 135 {
138 UDF_I_EFE(inode) = 0; 136 UDF_I_EFE(inode) = 0;
139 UDF_I_DATA(inode) = kmalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL); 137 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
140 memset(UDF_I_DATA(inode), 0x00, inode->i_sb->s_blocksize - sizeof(struct fileEntry));
141 } 138 }
142 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB)) 139 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_AD_IN_ICB))
143 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 140 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 605f5111b6d8..b223b32db991 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -916,8 +916,6 @@ __udf_read_inode(struct inode *inode)
916 * i_nlink = 1 916 * i_nlink = 1
917 * i_op = NULL; 917 * i_op = NULL;
918 */ 918 */
919 inode->i_blksize = PAGE_SIZE;
920
921 bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); 919 bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident);
922 920
923 if (!bh) 921 if (!bh)
diff --git a/fs/udf/super.c b/fs/udf/super.c
index fcce1a21a51b..5dd356cbbda6 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -156,8 +156,7 @@ static int init_inodecache(void)
156 156
157static void destroy_inodecache(void) 157static void destroy_inodecache(void)
158{ 158{
159 if (kmem_cache_destroy(udf_inode_cachep)) 159 kmem_cache_destroy(udf_inode_cachep);
160 printk(KERN_INFO "udf_inode_cache: not all structures were freed\n");
161} 160}
162 161
163/* Superblock operations */ 162/* Superblock operations */
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 9501dcd3b213..2ad1259c6eca 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -255,7 +255,6 @@ cg_found:
255 inode->i_gid = current->fsgid; 255 inode->i_gid = current->fsgid;
256 256
257 inode->i_ino = cg * uspi->s_ipg + bit; 257 inode->i_ino = cg * uspi->s_ipg + bit;
258 inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */
259 inode->i_blocks = 0; 258 inode->i_blocks = 0;
260 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; 259 inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
261 ufsi->i_flags = UFS_I(dir)->i_flags; 260 ufsi->i_flags = UFS_I(dir)->i_flags;
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 30c6e8a9446c..ee1eaa6f4ec2 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -741,7 +741,6 @@ void ufs_read_inode(struct inode * inode)
741 ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino)); 741 ufs1_read_inode(inode, ufs_inode + ufs_inotofsbo(inode->i_ino));
742 } 742 }
743 743
744 inode->i_blksize = PAGE_SIZE;/*This is the optimal IO size (for stat)*/
745 inode->i_version++; 744 inode->i_version++;
746 ufsi->i_lastfrag = 745 ufsi->i_lastfrag =
747 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift; 746 (inode->i_size + uspi->s_fsize - 1) >> uspi->s_fshift;
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 992ee0b87cc3..ec79e3091d1b 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -611,11 +611,10 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
611 611
612 UFSD("ENTER\n"); 612 UFSD("ENTER\n");
613 613
614 sbi = kmalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); 614 sbi = kzalloc(sizeof(struct ufs_sb_info), GFP_KERNEL);
615 if (!sbi) 615 if (!sbi)
616 goto failed_nomem; 616 goto failed_nomem;
617 sb->s_fs_info = sbi; 617 sb->s_fs_info = sbi;
618 memset(sbi, 0, sizeof(struct ufs_sb_info));
619 618
620 UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); 619 UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));
621 620
@@ -1245,8 +1244,7 @@ static int init_inodecache(void)
1245 1244
1246static void destroy_inodecache(void) 1245static void destroy_inodecache(void)
1247{ 1246{
1248 if (kmem_cache_destroy(ufs_inode_cachep)) 1247 kmem_cache_destroy(ufs_inode_cachep);
1249 printk(KERN_INFO "ufs_inode_cache: not all structures were freed\n");
1250} 1248}
1251 1249
1252#ifdef CONFIG_QUOTA 1250#ifdef CONFIG_QUOTA
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index 939bd84bc7ee..0e8293c5a32f 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -91,8 +91,8 @@ kmem_zone_free(kmem_zone_t *zone, void *ptr)
91static inline void 91static inline void
92kmem_zone_destroy(kmem_zone_t *zone) 92kmem_zone_destroy(kmem_zone_t *zone)
93{ 93{
94 if (zone && kmem_cache_destroy(zone)) 94 if (zone)
95 BUG(); 95 kmem_cache_destroy(zone);
96} 96}
97 97
98extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); 98extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index 3d4f6dff2113..41cfcba7ce49 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -370,7 +370,7 @@ xfs_file_readdir(
370 370
371 /* Try fairly hard to get memory */ 371 /* Try fairly hard to get memory */
372 do { 372 do {
373 if ((read_buf = (caddr_t)kmalloc(rlen, GFP_KERNEL))) 373 if ((read_buf = kmalloc(rlen, GFP_KERNEL)))
374 break; 374 break;
375 rlen >>= 1; 375 rlen >>= 1;
376 } while (rlen >= 1024); 376 } while (rlen >= 1024);
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index d9180020de63..22e3b714f629 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -553,13 +553,13 @@ xfs_vn_follow_link(
553 ASSERT(dentry); 553 ASSERT(dentry);
554 ASSERT(nd); 554 ASSERT(nd);
555 555
556 link = (char *)kmalloc(MAXPATHLEN+1, GFP_KERNEL); 556 link = kmalloc(MAXPATHLEN+1, GFP_KERNEL);
557 if (!link) { 557 if (!link) {
558 nd_set_link(nd, ERR_PTR(-ENOMEM)); 558 nd_set_link(nd, ERR_PTR(-ENOMEM));
559 return NULL; 559 return NULL;
560 } 560 }
561 561
562 uio = (uio_t *)kmalloc(sizeof(uio_t), GFP_KERNEL); 562 uio = kmalloc(sizeof(uio_t), GFP_KERNEL);
563 if (!uio) { 563 if (!uio) {
564 kfree(link); 564 kfree(link);
565 nd_set_link(nd, ERR_PTR(-ENOMEM)); 565 nd_set_link(nd, ERR_PTR(-ENOMEM));
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 4754f342a5d3..9df9ed37d219 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -171,7 +171,6 @@ xfs_revalidate_inode(
171 break; 171 break;
172 } 172 }
173 173
174 inode->i_blksize = xfs_preferred_iosize(mp);
175 inode->i_generation = ip->i_d.di_gen; 174 inode->i_generation = ip->i_d.di_gen;
176 i_size_write(inode, ip->i_d.di_size); 175 i_size_write(inode, ip->i_d.di_size);
177 inode->i_blocks = 176 inode->i_blocks =
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 6628d96b6fd6..553fa731ade5 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -122,7 +122,6 @@ vn_revalidate_core(
122 inode->i_blocks = vap->va_nblocks; 122 inode->i_blocks = vap->va_nblocks;
123 inode->i_mtime = vap->va_mtime; 123 inode->i_mtime = vap->va_mtime;
124 inode->i_ctime = vap->va_ctime; 124 inode->i_ctime = vap->va_ctime;
125 inode->i_blksize = vap->va_blocksize;
126 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE) 125 if (vap->va_xflags & XFS_XFLAG_IMMUTABLE)
127 inode->i_flags |= S_IMMUTABLE; 126 inode->i_flags |= S_IMMUTABLE;
128 else 127 else
diff --git a/include/asm-arm/arch-pxa/udc.h b/include/asm-arm/arch-pxa/udc.h
index 30548a30c773..121cd241115d 100644
--- a/include/asm-arm/arch-pxa/udc.h
+++ b/include/asm-arm/arch-pxa/udc.h
@@ -12,6 +12,14 @@ struct pxa2xx_udc_mach_info {
12 void (*udc_command)(int cmd); 12 void (*udc_command)(int cmd);
13#define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */ 13#define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */
14#define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */ 14#define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */
15
16 /* Boards following the design guidelines in the developer's manual,
17 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
18 * VBUS IRQ and omit the methods above. Store the GPIO number
19 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
20 */
21 u16 gpio_vbus; /* high == vbus present */
22 u16 gpio_pullup; /* high == pullup activated */
15}; 23};
16 24
17extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info); 25extern void pxa_set_udc_info(struct pxa2xx_udc_mach_info *info);
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index 1e891f860ef3..2ab4078334bf 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -377,6 +377,7 @@
377#endif 377#endif
378 378
379#ifdef __KERNEL__ 379#ifdef __KERNEL__
380#include <linux/err.h>
380#include <linux/linkage.h> 381#include <linux/linkage.h>
381 382
382#define __sys2(x) #x 383#define __sys2(x) #x
@@ -396,7 +397,7 @@
396 397
397#define __syscall_return(type, res) \ 398#define __syscall_return(type, res) \
398do { \ 399do { \
399 if ((unsigned long)(res) >= (unsigned long)(-129)) { \ 400 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
400 errno = -(res); \ 401 errno = -(res); \
401 res = -1; \ 402 res = -1; \
402 } \ 403 } \
diff --git a/include/asm-arm26/unistd.h b/include/asm-arm26/unistd.h
index 70eb6d91cfd0..c6d2436c9d34 100644
--- a/include/asm-arm26/unistd.h
+++ b/include/asm-arm26/unistd.h
@@ -311,6 +311,7 @@
311#define __ARM_NR_usr26 (__ARM_NR_BASE+3) 311#define __ARM_NR_usr26 (__ARM_NR_BASE+3)
312 312
313#ifdef __KERNEL__ 313#ifdef __KERNEL__
314#include <linux/err.h>
314#include <linux/linkage.h> 315#include <linux/linkage.h>
315 316
316#define __sys2(x) #x 317#define __sys2(x) #x
@@ -322,7 +323,7 @@
322 323
323#define __syscall_return(type, res) \ 324#define __syscall_return(type, res) \
324do { \ 325do { \
325 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 326 if ((unsigned long)(res) >= (unsigned long)-MAX_ERRNO) { \
326 errno = -(res); \ 327 errno = -(res); \
327 res = -1; \ 328 res = -1; \
328 } \ 329 } \
diff --git a/include/asm-frv/unistd.h b/include/asm-frv/unistd.h
index b80dbd839475..d104d1b91d39 100644
--- a/include/asm-frv/unistd.h
+++ b/include/asm-frv/unistd.h
@@ -320,6 +320,7 @@
320#ifdef __KERNEL__ 320#ifdef __KERNEL__
321 321
322#define NR_syscalls 310 322#define NR_syscalls 310
323#include <linux/err.h>
323 324
324/* 325/*
325 * process the return value of a syscall, consigning it to one of two possible fates 326 * process the return value of a syscall, consigning it to one of two possible fates
@@ -329,7 +330,7 @@
329#define __syscall_return(type, res) \ 330#define __syscall_return(type, res) \
330do { \ 331do { \
331 unsigned long __sr2 = (res); \ 332 unsigned long __sr2 = (res); \
332 if (__builtin_expect(__sr2 >= (unsigned long)(-4095), 0)) { \ 333 if (__builtin_expect(__sr2 >= (unsigned long)(-MAX_ERRNO), 0)) { \
333 errno = (-__sr2); \ 334 errno = (-__sr2); \
334 __sr2 = ~0UL; \ 335 __sr2 = ~0UL; \
335 } \ 336 } \
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 253ae1328271..69240b52f8e1 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -118,15 +118,15 @@
118 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \ 118 __ksymtab_strings : AT(ADDR(__ksymtab_strings) - LOAD_OFFSET) { \
119 *(__ksymtab_strings) \ 119 *(__ksymtab_strings) \
120 } \ 120 } \
121 __end_rodata = .; \
122 . = ALIGN(4096); \
123 \ 121 \
124 /* Built-in module parameters. */ \ 122 /* Built-in module parameters. */ \
125 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 123 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
126 VMLINUX_SYMBOL(__start___param) = .; \ 124 VMLINUX_SYMBOL(__start___param) = .; \
127 *(__param) \ 125 *(__param) \
128 VMLINUX_SYMBOL(__stop___param) = .; \ 126 VMLINUX_SYMBOL(__stop___param) = .; \
129 } 127 } \
128 __end_rodata = .; \
129 . = ALIGN(4096);
130 130
131#define SECURITY_INIT \ 131#define SECURITY_INIT \
132 .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \ 132 .security_initcall.init : AT(ADDR(.security_initcall.init) - LOAD_OFFSET) { \
diff --git a/include/asm-h8300/unistd.h b/include/asm-h8300/unistd.h
index 226dd596c2da..a2dd90462d80 100644
--- a/include/asm-h8300/unistd.h
+++ b/include/asm-h8300/unistd.h
@@ -295,14 +295,14 @@
295#ifdef __KERNEL__ 295#ifdef __KERNEL__
296 296
297#define NR_syscalls 289 297#define NR_syscalls 289
298#include <linux/err.h>
298 299
299 300/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
300/* user-visible error numbers are in the range -1 - -122: see
301 <asm-m68k/errno.h> */ 301 <asm-m68k/errno.h> */
302 302
303#define __syscall_return(type, res) \ 303#define __syscall_return(type, res) \
304do { \ 304do { \
305 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 305 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
306 /* avoid using res which is declared to be in register d0; \ 306 /* avoid using res which is declared to be in register d0; \
307 errno might expand to a function call and clobber it. */ \ 307 errno might expand to a function call and clobber it. */ \
308 int __err = -(res); \ 308 int __err = -(res); \
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h
index 20f523954218..6016632d032f 100644
--- a/include/asm-i386/acpi.h
+++ b/include/asm-i386/acpi.h
@@ -131,21 +131,7 @@ static inline void disable_acpi(void)
131extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); 131extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
132 132
133#ifdef CONFIG_X86_IO_APIC 133#ifdef CONFIG_X86_IO_APIC
134extern int skip_ioapic_setup;
135extern int acpi_skip_timer_override; 134extern int acpi_skip_timer_override;
136
137static inline void disable_ioapic_setup(void)
138{
139 skip_ioapic_setup = 1;
140}
141
142static inline int ioapic_setup_disabled(void)
143{
144 return skip_ioapic_setup;
145}
146
147#else
148static inline void disable_ioapic_setup(void) { }
149#endif 135#endif
150 136
151static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 137static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
diff --git a/include/asm-i386/alternative-asm.i b/include/asm-i386/alternative-asm.i
new file mode 100644
index 000000000000..6c47e3b9484b
--- /dev/null
+++ b/include/asm-i386/alternative-asm.i
@@ -0,0 +1,14 @@
1#include <linux/config.h>
2
3#ifdef CONFIG_SMP
4 .macro LOCK_PREFIX
51: lock
6 .section .smp_locks,"a"
7 .align 4
8 .long 1b
9 .previous
10 .endm
11#else
12 .macro LOCK_PREFIX
13 .endm
14#endif
diff --git a/include/asm-i386/apic.h b/include/asm-i386/apic.h
index 2c1e371cebb6..3a42b7d6fc92 100644
--- a/include/asm-i386/apic.h
+++ b/include/asm-i386/apic.h
@@ -16,20 +16,8 @@
16#define APIC_VERBOSE 1 16#define APIC_VERBOSE 1
17#define APIC_DEBUG 2 17#define APIC_DEBUG 2
18 18
19extern int enable_local_apic;
20extern int apic_verbosity; 19extern int apic_verbosity;
21 20
22static inline void lapic_disable(void)
23{
24 enable_local_apic = -1;
25 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
26}
27
28static inline void lapic_enable(void)
29{
30 enable_local_apic = 1;
31}
32
33/* 21/*
34 * Define the default level of output to be very little 22 * Define the default level of output to be very little
35 * This can be turned up by using apic=verbose for more 23 * This can be turned up by using apic=verbose for more
@@ -42,6 +30,8 @@ static inline void lapic_enable(void)
42 } while (0) 30 } while (0)
43 31
44 32
33extern void generic_apic_probe(void);
34
45#ifdef CONFIG_X86_LOCAL_APIC 35#ifdef CONFIG_X86_LOCAL_APIC
46 36
47/* 37/*
@@ -117,8 +107,6 @@ extern void enable_APIC_timer(void);
117 107
118extern void enable_NMI_through_LVT0 (void * dummy); 108extern void enable_NMI_through_LVT0 (void * dummy);
119 109
120extern int disable_timer_pin_1;
121
122void smp_send_timer_broadcast_ipi(struct pt_regs *regs); 110void smp_send_timer_broadcast_ipi(struct pt_regs *regs);
123void switch_APIC_timer_to_ipi(void *cpumask); 111void switch_APIC_timer_to_ipi(void *cpumask);
124void switch_ipi_to_APIC_timer(void *cpumask); 112void switch_ipi_to_APIC_timer(void *cpumask);
diff --git a/include/asm-i386/desc.h b/include/asm-i386/desc.h
index 89b8b82c82b3..5874ef119ffd 100644
--- a/include/asm-i386/desc.h
+++ b/include/asm-i386/desc.h
@@ -33,50 +33,99 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
33 return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address; 33 return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
34} 34}
35 35
36/*
37 * This is the ldt that every process will get unless we need
38 * something other than this.
39 */
40extern struct desc_struct default_ldt[];
41extern struct desc_struct idt_table[];
42extern void set_intr_gate(unsigned int irq, void * addr);
43
44static inline void pack_descriptor(__u32 *a, __u32 *b,
45 unsigned long base, unsigned long limit, unsigned char type, unsigned char flags)
46{
47 *a = ((base & 0xffff) << 16) | (limit & 0xffff);
48 *b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
49 (limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20);
50}
51
52static inline void pack_gate(__u32 *a, __u32 *b,
53 unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
54{
55 *a = (seg << 16) | (base & 0xffff);
56 *b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
57}
58
59#define DESCTYPE_LDT 0x82 /* present, system, DPL-0, LDT */
60#define DESCTYPE_TSS 0x89 /* present, system, DPL-0, 32-bit TSS */
61#define DESCTYPE_TASK 0x85 /* present, system, DPL-0, task gate */
62#define DESCTYPE_INT 0x8e /* present, system, DPL-0, interrupt gate */
63#define DESCTYPE_TRAP 0x8f /* present, system, DPL-0, trap gate */
64#define DESCTYPE_DPL3 0x60 /* DPL-3 */
65#define DESCTYPE_S 0x10 /* !system */
66
36#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8)) 67#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
37#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8)) 68#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))
38 69
39#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr)) 70#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
40#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr)) 71#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
41#define load_tr(tr) __asm__ __volatile("ltr %0"::"mr" (tr)) 72#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr))
42#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"mr" (ldt)) 73#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt))
43 74
44#define store_gdt(dtr) __asm__ ("sgdt %0":"=m" (*dtr)) 75#define store_gdt(dtr) __asm__ ("sgdt %0":"=m" (*dtr))
45#define store_idt(dtr) __asm__ ("sidt %0":"=m" (*dtr)) 76#define store_idt(dtr) __asm__ ("sidt %0":"=m" (*dtr))
46#define store_tr(tr) __asm__ ("str %0":"=mr" (tr)) 77#define store_tr(tr) __asm__ ("str %0":"=m" (tr))
47#define store_ldt(ldt) __asm__ ("sldt %0":"=mr" (ldt)) 78#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt))
48 79
49/* 80#if TLS_SIZE != 24
50 * This is the ldt that every process will get unless we need 81# error update this code.
51 * something other than this. 82#endif
52 */
53extern struct desc_struct default_ldt[];
54extern void set_intr_gate(unsigned int irq, void * addr);
55 83
56#define _set_tssldt_desc(n,addr,limit,type) \ 84static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
57__asm__ __volatile__ ("movw %w3,0(%2)\n\t" \
58 "movw %w1,2(%2)\n\t" \
59 "rorl $16,%1\n\t" \
60 "movb %b1,4(%2)\n\t" \
61 "movb %4,5(%2)\n\t" \
62 "movb $0,6(%2)\n\t" \
63 "movb %h1,7(%2)\n\t" \
64 "rorl $16,%1" \
65 : "=m"(*(n)) : "q" (addr), "r"(n), "ir"(limit), "i"(type))
66
67static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, void *addr)
68{ 85{
69 _set_tssldt_desc(&get_cpu_gdt_table(cpu)[entry], (int)addr, 86#define C(i) get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
70 offsetof(struct tss_struct, __cacheline_filler) - 1, 0x89); 87 C(0); C(1); C(2);
88#undef C
71} 89}
72 90
73#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) 91static inline void write_dt_entry(void *dt, int entry, __u32 entry_a, __u32 entry_b)
92{
93 __u32 *lp = (__u32 *)((char *)dt + entry*8);
94 *lp = entry_a;
95 *(lp+1) = entry_b;
96}
97
98#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
99#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
100#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
101
102static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
103{
104 __u32 a, b;
105 pack_gate(&a, &b, (unsigned long)addr, seg, type, 0);
106 write_idt_entry(idt_table, gate, a, b);
107}
74 108
75static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size) 109static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
76{ 110{
77 _set_tssldt_desc(&get_cpu_gdt_table(cpu)[GDT_ENTRY_LDT], (int)addr, ((size << 3)-1), 0x82); 111 __u32 a, b;
112 pack_descriptor(&a, &b, (unsigned long)addr,
113 offsetof(struct tss_struct, __cacheline_filler) - 1,
114 DESCTYPE_TSS, 0);
115 write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
78} 116}
79 117
118static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entries)
119{
120 __u32 a, b;
121 pack_descriptor(&a, &b, (unsigned long)addr,
122 entries * sizeof(struct desc_struct) - 1,
123 DESCTYPE_LDT, 0);
124 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
125}
126
127#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
128
80#define LDT_entry_a(info) \ 129#define LDT_entry_a(info) \
81 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff)) 130 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
82 131
@@ -102,24 +151,6 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
102 (info)->seg_not_present == 1 && \ 151 (info)->seg_not_present == 1 && \
103 (info)->useable == 0 ) 152 (info)->useable == 0 )
104 153
105static inline void write_ldt_entry(void *ldt, int entry, __u32 entry_a, __u32 entry_b)
106{
107 __u32 *lp = (__u32 *)((char *)ldt + entry*8);
108 *lp = entry_a;
109 *(lp+1) = entry_b;
110}
111
112#if TLS_SIZE != 24
113# error update this code.
114#endif
115
116static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
117{
118#define C(i) get_cpu_gdt_table(cpu)[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]
119 C(0); C(1); C(2);
120#undef C
121}
122
123static inline void clear_LDT(void) 154static inline void clear_LDT(void)
124{ 155{
125 int cpu = get_cpu(); 156 int cpu = get_cpu();
diff --git a/include/asm-i386/dwarf2.h b/include/asm-i386/dwarf2.h
index 2280f6272f80..6d66398a307d 100644
--- a/include/asm-i386/dwarf2.h
+++ b/include/asm-i386/dwarf2.h
@@ -1,8 +1,6 @@
1#ifndef _DWARF2_H 1#ifndef _DWARF2_H
2#define _DWARF2_H 2#define _DWARF2_H
3 3
4#include <linux/config.h>
5
6#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
7#warning "asm/dwarf2.h should be only included in pure assembly files" 5#warning "asm/dwarf2.h should be only included in pure assembly files"
8#endif 6#endif
@@ -28,6 +26,13 @@
28#define CFI_RESTORE .cfi_restore 26#define CFI_RESTORE .cfi_restore
29#define CFI_REMEMBER_STATE .cfi_remember_state 27#define CFI_REMEMBER_STATE .cfi_remember_state
30#define CFI_RESTORE_STATE .cfi_restore_state 28#define CFI_RESTORE_STATE .cfi_restore_state
29#define CFI_UNDEFINED .cfi_undefined
30
31#ifdef CONFIG_AS_CFI_SIGNAL_FRAME
32#define CFI_SIGNAL_FRAME .cfi_signal_frame
33#else
34#define CFI_SIGNAL_FRAME
35#endif
31 36
32#else 37#else
33 38
@@ -48,6 +53,8 @@
48#define CFI_RESTORE ignore 53#define CFI_RESTORE ignore
49#define CFI_REMEMBER_STATE ignore 54#define CFI_REMEMBER_STATE ignore
50#define CFI_RESTORE_STATE ignore 55#define CFI_RESTORE_STATE ignore
56#define CFI_UNDEFINED ignore
57#define CFI_SIGNAL_FRAME ignore
51 58
52#endif 59#endif
53 60
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index ca82acb8cb1f..f7514fb6e8e4 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -18,7 +18,7 @@
18 18
19#define E820_RAM 1 19#define E820_RAM 1
20#define E820_RESERVED 2 20#define E820_RESERVED 2
21#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */ 21#define E820_ACPI 3
22#define E820_NVS 4 22#define E820_NVS 4
23 23
24#define HIGH_MEMORY (1024*1024) 24#define HIGH_MEMORY (1024*1024)
diff --git a/include/asm-i386/frame.i b/include/asm-i386/frame.i
new file mode 100644
index 000000000000..4d68ddce18b6
--- /dev/null
+++ b/include/asm-i386/frame.i
@@ -0,0 +1,24 @@
1#include <linux/config.h>
2#include <asm/dwarf2.h>
3
4/* The annotation hides the frame from the unwinder and makes it look
5 like a ordinary ebp save/restore. This avoids some special cases for
6 frame pointer later */
7#ifdef CONFIG_FRAME_POINTER
8 .macro FRAME
9 pushl %ebp
10 CFI_ADJUST_CFA_OFFSET 4
11 CFI_REL_OFFSET ebp,0
12 movl %esp,%ebp
13 .endm
14 .macro ENDFRAME
15 popl %ebp
16 CFI_ADJUST_CFA_OFFSET -4
17 CFI_RESTORE ebp
18 .endm
19#else
20 .macro FRAME
21 .endm
22 .macro ENDFRAME
23 .endm
24#endif
diff --git a/include/asm-i386/genapic.h b/include/asm-i386/genapic.h
index b3783a32abee..8ffbb0f07457 100644
--- a/include/asm-i386/genapic.h
+++ b/include/asm-i386/genapic.h
@@ -1,6 +1,8 @@
1#ifndef _ASM_GENAPIC_H 1#ifndef _ASM_GENAPIC_H
2#define _ASM_GENAPIC_H 1 2#define _ASM_GENAPIC_H 1
3 3
4#include <asm/mpspec.h>
5
4/* 6/*
5 * Generic APIC driver interface. 7 * Generic APIC driver interface.
6 * 8 *
@@ -63,14 +65,25 @@ struct genapic {
63 unsigned (*get_apic_id)(unsigned long x); 65 unsigned (*get_apic_id)(unsigned long x);
64 unsigned long apic_id_mask; 66 unsigned long apic_id_mask;
65 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask); 67 unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
66 68
69#ifdef CONFIG_SMP
67 /* ipi */ 70 /* ipi */
68 void (*send_IPI_mask)(cpumask_t mask, int vector); 71 void (*send_IPI_mask)(cpumask_t mask, int vector);
69 void (*send_IPI_allbutself)(int vector); 72 void (*send_IPI_allbutself)(int vector);
70 void (*send_IPI_all)(int vector); 73 void (*send_IPI_all)(int vector);
74#endif
71}; 75};
72 76
73#define APICFUNC(x) .x = x 77#define APICFUNC(x) .x = x,
78
79/* More functions could be probably marked IPIFUNC and save some space
80 in UP GENERICARCH kernels, but I don't have the nerve right now
81 to untangle this mess. -AK */
82#ifdef CONFIG_SMP
83#define IPIFUNC(x) APICFUNC(x)
84#else
85#define IPIFUNC(x)
86#endif
74 87
75#define APIC_INIT(aname, aprobe) { \ 88#define APIC_INIT(aname, aprobe) { \
76 .name = aname, \ 89 .name = aname, \
@@ -80,33 +93,33 @@ struct genapic {
80 .no_balance_irq = NO_BALANCE_IRQ, \ 93 .no_balance_irq = NO_BALANCE_IRQ, \
81 .ESR_DISABLE = esr_disable, \ 94 .ESR_DISABLE = esr_disable, \
82 .apic_destination_logical = APIC_DEST_LOGICAL, \ 95 .apic_destination_logical = APIC_DEST_LOGICAL, \
83 APICFUNC(apic_id_registered), \ 96 APICFUNC(apic_id_registered) \
84 APICFUNC(target_cpus), \ 97 APICFUNC(target_cpus) \
85 APICFUNC(check_apicid_used), \ 98 APICFUNC(check_apicid_used) \
86 APICFUNC(check_apicid_present), \ 99 APICFUNC(check_apicid_present) \
87 APICFUNC(init_apic_ldr), \ 100 APICFUNC(init_apic_ldr) \
88 APICFUNC(ioapic_phys_id_map), \ 101 APICFUNC(ioapic_phys_id_map) \
89 APICFUNC(clustered_apic_check), \ 102 APICFUNC(clustered_apic_check) \
90 APICFUNC(multi_timer_check), \ 103 APICFUNC(multi_timer_check) \
91 APICFUNC(apicid_to_node), \ 104 APICFUNC(apicid_to_node) \
92 APICFUNC(cpu_to_logical_apicid), \ 105 APICFUNC(cpu_to_logical_apicid) \
93 APICFUNC(cpu_present_to_apicid), \ 106 APICFUNC(cpu_present_to_apicid) \
94 APICFUNC(apicid_to_cpu_present), \ 107 APICFUNC(apicid_to_cpu_present) \
95 APICFUNC(mpc_apic_id), \ 108 APICFUNC(mpc_apic_id) \
96 APICFUNC(setup_portio_remap), \ 109 APICFUNC(setup_portio_remap) \
97 APICFUNC(check_phys_apicid_present), \ 110 APICFUNC(check_phys_apicid_present) \
98 APICFUNC(mpc_oem_bus_info), \ 111 APICFUNC(mpc_oem_bus_info) \
99 APICFUNC(mpc_oem_pci_bus), \ 112 APICFUNC(mpc_oem_pci_bus) \
100 APICFUNC(mps_oem_check), \ 113 APICFUNC(mps_oem_check) \
101 APICFUNC(get_apic_id), \ 114 APICFUNC(get_apic_id) \
102 .apic_id_mask = APIC_ID_MASK, \ 115 .apic_id_mask = APIC_ID_MASK, \
103 APICFUNC(cpu_mask_to_apicid), \ 116 APICFUNC(cpu_mask_to_apicid) \
104 APICFUNC(acpi_madt_oem_check), \ 117 APICFUNC(acpi_madt_oem_check) \
105 APICFUNC(send_IPI_mask), \ 118 IPIFUNC(send_IPI_mask) \
106 APICFUNC(send_IPI_allbutself), \ 119 IPIFUNC(send_IPI_allbutself) \
107 APICFUNC(send_IPI_all), \ 120 IPIFUNC(send_IPI_all) \
108 APICFUNC(enable_apic_mode), \ 121 APICFUNC(enable_apic_mode) \
109 APICFUNC(phys_pkg_id), \ 122 APICFUNC(phys_pkg_id) \
110 } 123 }
111 124
112extern struct genapic *genapic; 125extern struct genapic *genapic;
diff --git a/include/asm-i386/intel_arch_perfmon.h b/include/asm-i386/intel_arch_perfmon.h
index 134ea9cc5283..b52cd60a075b 100644
--- a/include/asm-i386/intel_arch_perfmon.h
+++ b/include/asm-i386/intel_arch_perfmon.h
@@ -14,6 +14,18 @@
14 14
15#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c) 15#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c)
16#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) 16#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
17#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT (1 << 0) 17#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX (0)
18#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \
19 (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX))
20
21union cpuid10_eax {
22 struct {
23 unsigned int version_id:8;
24 unsigned int num_counters:8;
25 unsigned int bit_width:8;
26 unsigned int mask_length:8;
27 } split;
28 unsigned int full;
29};
18 30
19#endif /* X86_INTEL_ARCH_PERFMON_H */ 31#endif /* X86_INTEL_ARCH_PERFMON_H */
diff --git a/include/asm-i386/io_apic.h b/include/asm-i386/io_apic.h
index 5092e819b8a2..5d309275a1dc 100644
--- a/include/asm-i386/io_apic.h
+++ b/include/asm-i386/io_apic.h
@@ -188,6 +188,16 @@ static inline void io_apic_modify(unsigned int apic, unsigned int reg, unsigned
188/* 1 if "noapic" boot option passed */ 188/* 1 if "noapic" boot option passed */
189extern int skip_ioapic_setup; 189extern int skip_ioapic_setup;
190 190
191static inline void disable_ioapic_setup(void)
192{
193 skip_ioapic_setup = 1;
194}
195
196static inline int ioapic_setup_disabled(void)
197{
198 return skip_ioapic_setup;
199}
200
191/* 201/*
192 * If we use the IO-APIC for IRQ routing, disable automatic 202 * If we use the IO-APIC for IRQ routing, disable automatic
193 * assignment of PCI IRQ's. 203 * assignment of PCI IRQ's.
@@ -206,6 +216,7 @@ extern int (*ioapic_renumber_irq)(int ioapic, int irq);
206 216
207#else /* !CONFIG_X86_IO_APIC */ 217#else /* !CONFIG_X86_IO_APIC */
208#define io_apic_assign_pci_irqs 0 218#define io_apic_assign_pci_irqs 0
219static inline void disable_ioapic_setup(void) { }
209#endif 220#endif
210 221
211extern int assign_irq_vector(int irq); 222extern int assign_irq_vector(int irq);
diff --git a/include/asm-i386/kexec.h b/include/asm-i386/kexec.h
index 53f0e06672dc..4dfc9f5ed031 100644
--- a/include/asm-i386/kexec.h
+++ b/include/asm-i386/kexec.h
@@ -1,6 +1,26 @@
1#ifndef _I386_KEXEC_H 1#ifndef _I386_KEXEC_H
2#define _I386_KEXEC_H 2#define _I386_KEXEC_H
3 3
4#define PA_CONTROL_PAGE 0
5#define VA_CONTROL_PAGE 1
6#define PA_PGD 2
7#define VA_PGD 3
8#define PA_PTE_0 4
9#define VA_PTE_0 5
10#define PA_PTE_1 6
11#define VA_PTE_1 7
12#ifdef CONFIG_X86_PAE
13#define PA_PMD_0 8
14#define VA_PMD_0 9
15#define PA_PMD_1 10
16#define VA_PMD_1 11
17#define PAGES_NR 12
18#else
19#define PAGES_NR 8
20#endif
21
22#ifndef __ASSEMBLY__
23
4#include <asm/fixmap.h> 24#include <asm/fixmap.h>
5#include <asm/ptrace.h> 25#include <asm/ptrace.h>
6#include <asm/string.h> 26#include <asm/string.h>
@@ -72,5 +92,12 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
72 newregs->eip = (unsigned long)current_text_addr(); 92 newregs->eip = (unsigned long)current_text_addr();
73 } 93 }
74} 94}
95asmlinkage NORET_TYPE void
96relocate_kernel(unsigned long indirection_page,
97 unsigned long control_page,
98 unsigned long start_address,
99 unsigned int has_pae) ATTRIB_NORET;
100
101#endif /* __ASSEMBLY__ */
75 102
76#endif /* _I386_KEXEC_H */ 103#endif /* _I386_KEXEC_H */
diff --git a/include/asm-i386/mach-es7000/mach_apic.h b/include/asm-i386/mach-es7000/mach_apic.h
index b5f3f0d0b2bc..26333685a7fb 100644
--- a/include/asm-i386/mach-es7000/mach_apic.h
+++ b/include/asm-i386/mach-es7000/mach_apic.h
@@ -123,9 +123,13 @@ extern u8 cpu_2_logical_apicid[];
123/* Mapping from cpu number to logical apicid */ 123/* Mapping from cpu number to logical apicid */
124static inline int cpu_to_logical_apicid(int cpu) 124static inline int cpu_to_logical_apicid(int cpu)
125{ 125{
126#ifdef CONFIG_SMP
126 if (cpu >= NR_CPUS) 127 if (cpu >= NR_CPUS)
127 return BAD_APICID; 128 return BAD_APICID;
128 return (int)cpu_2_logical_apicid[cpu]; 129 return (int)cpu_2_logical_apicid[cpu];
130#else
131 return logical_smp_processor_id();
132#endif
129} 133}
130 134
131static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused) 135static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused)
diff --git a/include/asm-i386/mach-summit/mach_apic.h b/include/asm-i386/mach-summit/mach_apic.h
index 9fd073286289..a81b05961595 100644
--- a/include/asm-i386/mach-summit/mach_apic.h
+++ b/include/asm-i386/mach-summit/mach_apic.h
@@ -46,10 +46,12 @@ extern u8 cpu_2_logical_apicid[];
46static inline void init_apic_ldr(void) 46static inline void init_apic_ldr(void)
47{ 47{
48 unsigned long val, id; 48 unsigned long val, id;
49 int i, count; 49 int count = 0;
50 u8 lid;
51 u8 my_id = (u8)hard_smp_processor_id(); 50 u8 my_id = (u8)hard_smp_processor_id();
52 u8 my_cluster = (u8)apicid_cluster(my_id); 51 u8 my_cluster = (u8)apicid_cluster(my_id);
52#ifdef CONFIG_SMP
53 u8 lid;
54 int i;
53 55
54 /* Create logical APIC IDs by counting CPUs already in cluster. */ 56 /* Create logical APIC IDs by counting CPUs already in cluster. */
55 for (count = 0, i = NR_CPUS; --i >= 0; ) { 57 for (count = 0, i = NR_CPUS; --i >= 0; ) {
@@ -57,6 +59,7 @@ static inline void init_apic_ldr(void)
57 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster) 59 if (lid != BAD_APICID && apicid_cluster(lid) == my_cluster)
58 ++count; 60 ++count;
59 } 61 }
62#endif
60 /* We only have a 4 wide bitmap in cluster mode. If a deranged 63 /* We only have a 4 wide bitmap in cluster mode. If a deranged
61 * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */ 64 * BIOS puts 5 CPUs in one APIC cluster, we're hosed. */
62 BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT); 65 BUG_ON(count >= XAPIC_DEST_CPUS_SHIFT);
@@ -91,9 +94,13 @@ static inline int apicid_to_node(int logical_apicid)
91/* Mapping from cpu number to logical apicid */ 94/* Mapping from cpu number to logical apicid */
92static inline int cpu_to_logical_apicid(int cpu) 95static inline int cpu_to_logical_apicid(int cpu)
93{ 96{
97#ifdef CONFIG_SMP
94 if (cpu >= NR_CPUS) 98 if (cpu >= NR_CPUS)
95 return BAD_APICID; 99 return BAD_APICID;
96 return (int)cpu_2_logical_apicid[cpu]; 100 return (int)cpu_2_logical_apicid[cpu];
101#else
102 return logical_smp_processor_id();
103#endif
97} 104}
98 105
99static inline int cpu_present_to_apicid(int mps_cpu) 106static inline int cpu_present_to_apicid(int mps_cpu)
diff --git a/include/asm-i386/mutex.h b/include/asm-i386/mutex.h
index 05a538531229..7a17d9e58ad6 100644
--- a/include/asm-i386/mutex.h
+++ b/include/asm-i386/mutex.h
@@ -30,14 +30,10 @@ do { \
30 \ 30 \
31 __asm__ __volatile__( \ 31 __asm__ __volatile__( \
32 LOCK_PREFIX " decl (%%eax) \n" \ 32 LOCK_PREFIX " decl (%%eax) \n" \
33 " js 2f \n" \ 33 " jns 1f \n" \
34 " call "#fail_fn" \n" \
34 "1: \n" \ 35 "1: \n" \
35 \ 36 \
36 LOCK_SECTION_START("") \
37 "2: call "#fail_fn" \n" \
38 " jmp 1b \n" \
39 LOCK_SECTION_END \
40 \
41 :"=a" (dummy) \ 37 :"=a" (dummy) \
42 : "a" (count) \ 38 : "a" (count) \
43 : "memory", "ecx", "edx"); \ 39 : "memory", "ecx", "edx"); \
@@ -86,14 +82,10 @@ do { \
86 \ 82 \
87 __asm__ __volatile__( \ 83 __asm__ __volatile__( \
88 LOCK_PREFIX " incl (%%eax) \n" \ 84 LOCK_PREFIX " incl (%%eax) \n" \
89 " jle 2f \n" \ 85 " jg 1f \n" \
86 " call "#fail_fn" \n" \
90 "1: \n" \ 87 "1: \n" \
91 \ 88 \
92 LOCK_SECTION_START("") \
93 "2: call "#fail_fn" \n" \
94 " jmp 1b \n" \
95 LOCK_SECTION_END \
96 \
97 :"=a" (dummy) \ 89 :"=a" (dummy) \
98 : "a" (count) \ 90 : "a" (count) \
99 : "memory", "ecx", "edx"); \ 91 : "memory", "ecx", "edx"); \
diff --git a/include/asm-i386/nmi.h b/include/asm-i386/nmi.h
index 67d994799999..303bcd4592bb 100644
--- a/include/asm-i386/nmi.h
+++ b/include/asm-i386/nmi.h
@@ -6,32 +6,29 @@
6 6
7#include <linux/pm.h> 7#include <linux/pm.h>
8 8
9struct pt_regs;
10
11typedef int (*nmi_callback_t)(struct pt_regs * regs, int cpu);
12
13/** 9/**
14 * set_nmi_callback 10 * do_nmi_callback
15 * 11 *
16 * Set a handler for an NMI. Only one handler may be 12 * Check to see if a callback exists and execute it. Return 1
17 * set. Return 1 if the NMI was handled. 13 * if the handler exists and was handled successfully.
18 */ 14 */
19void set_nmi_callback(nmi_callback_t callback); 15int do_nmi_callback(struct pt_regs *regs, int cpu);
20 16
21/** 17extern int nmi_watchdog_enabled;
22 * unset_nmi_callback 18extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
23 * 19extern int avail_to_resrv_perfctr_nmi(unsigned int);
24 * Remove the handler previously set. 20extern int reserve_perfctr_nmi(unsigned int);
25 */ 21extern void release_perfctr_nmi(unsigned int);
26void unset_nmi_callback(void); 22extern int reserve_evntsel_nmi(unsigned int);
27 23extern void release_evntsel_nmi(unsigned int);
28extern void setup_apic_nmi_watchdog (void); 24
29extern int reserve_lapic_nmi(void); 25extern void setup_apic_nmi_watchdog (void *);
30extern void release_lapic_nmi(void); 26extern void stop_apic_nmi_watchdog (void *);
31extern void disable_timer_nmi_watchdog(void); 27extern void disable_timer_nmi_watchdog(void);
32extern void enable_timer_nmi_watchdog(void); 28extern void enable_timer_nmi_watchdog(void);
33extern void nmi_watchdog_tick (struct pt_regs * regs); 29extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason);
34 30
31extern atomic_t nmi_active;
35extern unsigned int nmi_watchdog; 32extern unsigned int nmi_watchdog;
36#define NMI_DEFAULT -1 33#define NMI_DEFAULT -1
37#define NMI_NONE 0 34#define NMI_NONE 0
diff --git a/include/asm-i386/pgtable.h b/include/asm-i386/pgtable.h
index 0dc051a8078b..541b3e234335 100644
--- a/include/asm-i386/pgtable.h
+++ b/include/asm-i386/pgtable.h
@@ -411,8 +411,6 @@ extern pte_t *lookup_address(unsigned long address);
411 static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;} 411 static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;}
412#endif 412#endif
413 413
414extern void noexec_setup(const char *str);
415
416#if defined(CONFIG_HIGHPTE) 414#if defined(CONFIG_HIGHPTE)
417#define pte_offset_map(dir, address) \ 415#define pte_offset_map(dir, address) \
418 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) 416 ((pte_t *)kmap_atomic(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
diff --git a/include/asm-i386/ptrace.h b/include/asm-i386/ptrace.h
index 1910880fcd40..a4a0e5207db5 100644
--- a/include/asm-i386/ptrace.h
+++ b/include/asm-i386/ptrace.h
@@ -27,6 +27,7 @@ struct pt_regs {
27#ifdef __KERNEL__ 27#ifdef __KERNEL__
28 28
29#include <asm/vm86.h> 29#include <asm/vm86.h>
30#include <asm/segment.h>
30 31
31struct task_struct; 32struct task_struct;
32extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code); 33extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
@@ -40,18 +41,14 @@ extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int erro
40 */ 41 */
41static inline int user_mode(struct pt_regs *regs) 42static inline int user_mode(struct pt_regs *regs)
42{ 43{
43 return (regs->xcs & 3) != 0; 44 return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;
44} 45}
45static inline int user_mode_vm(struct pt_regs *regs) 46static inline int user_mode_vm(struct pt_regs *regs)
46{ 47{
47 return ((regs->xcs & 3) | (regs->eflags & VM_MASK)) != 0; 48 return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;
48} 49}
49#define instruction_pointer(regs) ((regs)->eip) 50#define instruction_pointer(regs) ((regs)->eip)
50#if defined(CONFIG_SMP) && defined(CONFIG_FRAME_POINTER)
51extern unsigned long profile_pc(struct pt_regs *regs); 51extern unsigned long profile_pc(struct pt_regs *regs);
52#else
53#define profile_pc(regs) instruction_pointer(regs)
54#endif
55#endif /* __KERNEL__ */ 52#endif /* __KERNEL__ */
56 53
57#endif 54#endif
diff --git a/include/asm-i386/rwlock.h b/include/asm-i386/rwlock.h
index 87c069ccba08..c3e5db32fa48 100644
--- a/include/asm-i386/rwlock.h
+++ b/include/asm-i386/rwlock.h
@@ -20,52 +20,6 @@
20#define RW_LOCK_BIAS 0x01000000 20#define RW_LOCK_BIAS 0x01000000
21#define RW_LOCK_BIAS_STR "0x01000000" 21#define RW_LOCK_BIAS_STR "0x01000000"
22 22
23#define __build_read_lock_ptr(rw, helper) \ 23/* Code is in asm-i386/spinlock.h */
24 asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t" \
25 "jns 1f\n" \
26 "call " helper "\n\t" \
27 "1:\n" \
28 ::"a" (rw) : "memory")
29
30#define __build_read_lock_const(rw, helper) \
31 asm volatile(LOCK_PREFIX " subl $1,%0\n\t" \
32 "jns 1f\n" \
33 "pushl %%eax\n\t" \
34 "leal %0,%%eax\n\t" \
35 "call " helper "\n\t" \
36 "popl %%eax\n\t" \
37 "1:\n" \
38 :"+m" (*(volatile int *)rw) : : "memory")
39
40#define __build_read_lock(rw, helper) do { \
41 if (__builtin_constant_p(rw)) \
42 __build_read_lock_const(rw, helper); \
43 else \
44 __build_read_lock_ptr(rw, helper); \
45 } while (0)
46
47#define __build_write_lock_ptr(rw, helper) \
48 asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
49 "jz 1f\n" \
50 "call " helper "\n\t" \
51 "1:\n" \
52 ::"a" (rw) : "memory")
53
54#define __build_write_lock_const(rw, helper) \
55 asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
56 "jz 1f\n" \
57 "pushl %%eax\n\t" \
58 "leal %0,%%eax\n\t" \
59 "call " helper "\n\t" \
60 "popl %%eax\n\t" \
61 "1:\n" \
62 :"+m" (*(volatile int *)rw) : : "memory")
63
64#define __build_write_lock(rw, helper) do { \
65 if (__builtin_constant_p(rw)) \
66 __build_write_lock_const(rw, helper); \
67 else \
68 __build_write_lock_ptr(rw, helper); \
69 } while (0)
70 24
71#endif 25#endif
diff --git a/include/asm-i386/rwsem.h b/include/asm-i386/rwsem.h
index 43113f5608eb..bc598d6388e3 100644
--- a/include/asm-i386/rwsem.h
+++ b/include/asm-i386/rwsem.h
@@ -99,17 +99,9 @@ static inline void __down_read(struct rw_semaphore *sem)
99 __asm__ __volatile__( 99 __asm__ __volatile__(
100 "# beginning down_read\n\t" 100 "# beginning down_read\n\t"
101LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */ 101LOCK_PREFIX " incl (%%eax)\n\t" /* adds 0x00000001, returns the old value */
102 " js 2f\n\t" /* jump if we weren't granted the lock */ 102 " jns 1f\n"
103 " call call_rwsem_down_read_failed\n"
103 "1:\n\t" 104 "1:\n\t"
104 LOCK_SECTION_START("")
105 "2:\n\t"
106 " pushl %%ecx\n\t"
107 " pushl %%edx\n\t"
108 " call rwsem_down_read_failed\n\t"
109 " popl %%edx\n\t"
110 " popl %%ecx\n\t"
111 " jmp 1b\n"
112 LOCK_SECTION_END
113 "# ending down_read\n\t" 105 "# ending down_read\n\t"
114 : "+m" (sem->count) 106 : "+m" (sem->count)
115 : "a" (sem) 107 : "a" (sem)
@@ -151,15 +143,9 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
151 "# beginning down_write\n\t" 143 "# beginning down_write\n\t"
152LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */ 144LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtract 0x0000ffff, returns the old value */
153 " testl %%edx,%%edx\n\t" /* was the count 0 before? */ 145 " testl %%edx,%%edx\n\t" /* was the count 0 before? */
154 " jnz 2f\n\t" /* jump if we weren't granted the lock */ 146 " jz 1f\n"
155 "1:\n\t" 147 " call call_rwsem_down_write_failed\n"
156 LOCK_SECTION_START("") 148 "1:\n"
157 "2:\n\t"
158 " pushl %%ecx\n\t"
159 " call rwsem_down_write_failed\n\t"
160 " popl %%ecx\n\t"
161 " jmp 1b\n"
162 LOCK_SECTION_END
163 "# ending down_write" 149 "# ending down_write"
164 : "+m" (sem->count), "=d" (tmp) 150 : "+m" (sem->count), "=d" (tmp)
165 : "a" (sem), "1" (tmp) 151 : "a" (sem), "1" (tmp)
@@ -193,17 +179,9 @@ static inline void __up_read(struct rw_semaphore *sem)
193 __asm__ __volatile__( 179 __asm__ __volatile__(
194 "# beginning __up_read\n\t" 180 "# beginning __up_read\n\t"
195LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */ 181LOCK_PREFIX " xadd %%edx,(%%eax)\n\t" /* subtracts 1, returns the old value */
196 " js 2f\n\t" /* jump if the lock is being waited upon */ 182 " jns 1f\n\t"
197 "1:\n\t" 183 " call call_rwsem_wake\n"
198 LOCK_SECTION_START("") 184 "1:\n"
199 "2:\n\t"
200 " decw %%dx\n\t" /* do nothing if still outstanding active readers */
201 " jnz 1b\n\t"
202 " pushl %%ecx\n\t"
203 " call rwsem_wake\n\t"
204 " popl %%ecx\n\t"
205 " jmp 1b\n"
206 LOCK_SECTION_END
207 "# ending __up_read\n" 185 "# ending __up_read\n"
208 : "+m" (sem->count), "=d" (tmp) 186 : "+m" (sem->count), "=d" (tmp)
209 : "a" (sem), "1" (tmp) 187 : "a" (sem), "1" (tmp)
@@ -219,17 +197,9 @@ static inline void __up_write(struct rw_semaphore *sem)
219 "# beginning __up_write\n\t" 197 "# beginning __up_write\n\t"
220 " movl %2,%%edx\n\t" 198 " movl %2,%%edx\n\t"
221LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */ 199LOCK_PREFIX " xaddl %%edx,(%%eax)\n\t" /* tries to transition 0xffff0001 -> 0x00000000 */
222 " jnz 2f\n\t" /* jump if the lock is being waited upon */ 200 " jz 1f\n"
201 " call call_rwsem_wake\n"
223 "1:\n\t" 202 "1:\n\t"
224 LOCK_SECTION_START("")
225 "2:\n\t"
226 " decw %%dx\n\t" /* did the active count reduce to 0? */
227 " jnz 1b\n\t" /* jump back if not */
228 " pushl %%ecx\n\t"
229 " call rwsem_wake\n\t"
230 " popl %%ecx\n\t"
231 " jmp 1b\n"
232 LOCK_SECTION_END
233 "# ending __up_write\n" 203 "# ending __up_write\n"
234 : "+m" (sem->count) 204 : "+m" (sem->count)
235 : "a" (sem), "i" (-RWSEM_ACTIVE_WRITE_BIAS) 205 : "a" (sem), "i" (-RWSEM_ACTIVE_WRITE_BIAS)
@@ -244,17 +214,9 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
244 __asm__ __volatile__( 214 __asm__ __volatile__(
245 "# beginning __downgrade_write\n\t" 215 "# beginning __downgrade_write\n\t"
246LOCK_PREFIX " addl %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */ 216LOCK_PREFIX " addl %2,(%%eax)\n\t" /* transitions 0xZZZZ0001 -> 0xYYYY0001 */
247 " js 2f\n\t" /* jump if the lock is being waited upon */ 217 " jns 1f\n\t"
218 " call call_rwsem_downgrade_wake\n"
248 "1:\n\t" 219 "1:\n\t"
249 LOCK_SECTION_START("")
250 "2:\n\t"
251 " pushl %%ecx\n\t"
252 " pushl %%edx\n\t"
253 " call rwsem_downgrade_wake\n\t"
254 " popl %%edx\n\t"
255 " popl %%ecx\n\t"
256 " jmp 1b\n"
257 LOCK_SECTION_END
258 "# ending __downgrade_write\n" 220 "# ending __downgrade_write\n"
259 : "+m" (sem->count) 221 : "+m" (sem->count)
260 : "a" (sem), "i" (-RWSEM_WAITING_BIAS) 222 : "a" (sem), "i" (-RWSEM_WAITING_BIAS)
diff --git a/include/asm-i386/segment.h b/include/asm-i386/segment.h
index faf995307b9e..b7ab59685ba7 100644
--- a/include/asm-i386/segment.h
+++ b/include/asm-i386/segment.h
@@ -83,6 +83,11 @@
83 83
84#define GDT_SIZE (GDT_ENTRIES * 8) 84#define GDT_SIZE (GDT_ENTRIES * 8)
85 85
86/* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */
87#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
88/* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
89#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
90
86/* Simple and small GDT entries for booting only */ 91/* Simple and small GDT entries for booting only */
87 92
88#define GDT_ENTRY_BOOT_CS 2 93#define GDT_ENTRY_BOOT_CS 2
@@ -112,4 +117,16 @@
112 */ 117 */
113#define IDT_ENTRIES 256 118#define IDT_ENTRIES 256
114 119
120/* Bottom two bits of selector give the ring privilege level */
121#define SEGMENT_RPL_MASK 0x3
122/* Bit 2 is table indicator (LDT/GDT) */
123#define SEGMENT_TI_MASK 0x4
124
125/* User mode is privilege level 3 */
126#define USER_RPL 0x3
127/* LDT segment has TI set, GDT has it cleared */
128#define SEGMENT_LDT 0x4
129#define SEGMENT_GDT 0x0
130
131#define get_kernel_rpl() 0
115#endif 132#endif
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index d51e800acf29..4e34a468c383 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -100,13 +100,10 @@ static inline void down(struct semaphore * sem)
100 __asm__ __volatile__( 100 __asm__ __volatile__(
101 "# atomic down operation\n\t" 101 "# atomic down operation\n\t"
102 LOCK_PREFIX "decl %0\n\t" /* --sem->count */ 102 LOCK_PREFIX "decl %0\n\t" /* --sem->count */
103 "js 2f\n" 103 "jns 2f\n"
104 "1:\n" 104 "\tlea %0,%%eax\n\t"
105 LOCK_SECTION_START("") 105 "call __down_failed\n"
106 "2:\tlea %0,%%eax\n\t" 106 "2:"
107 "call __down_failed\n\t"
108 "jmp 1b\n"
109 LOCK_SECTION_END
110 :"+m" (sem->count) 107 :"+m" (sem->count)
111 : 108 :
112 :"memory","ax"); 109 :"memory","ax");
@@ -123,16 +120,13 @@ static inline int down_interruptible(struct semaphore * sem)
123 might_sleep(); 120 might_sleep();
124 __asm__ __volatile__( 121 __asm__ __volatile__(
125 "# atomic interruptible down operation\n\t" 122 "# atomic interruptible down operation\n\t"
123 "xorl %0,%0\n\t"
126 LOCK_PREFIX "decl %1\n\t" /* --sem->count */ 124 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
127 "js 2f\n\t" 125 "jns 2f\n\t"
128 "xorl %0,%0\n" 126 "lea %1,%%eax\n\t"
129 "1:\n" 127 "call __down_failed_interruptible\n"
130 LOCK_SECTION_START("") 128 "2:"
131 "2:\tlea %1,%%eax\n\t" 129 :"=&a" (result), "+m" (sem->count)
132 "call __down_failed_interruptible\n\t"
133 "jmp 1b\n"
134 LOCK_SECTION_END
135 :"=a" (result), "+m" (sem->count)
136 : 130 :
137 :"memory"); 131 :"memory");
138 return result; 132 return result;
@@ -148,16 +142,13 @@ static inline int down_trylock(struct semaphore * sem)
148 142
149 __asm__ __volatile__( 143 __asm__ __volatile__(
150 "# atomic interruptible down operation\n\t" 144 "# atomic interruptible down operation\n\t"
145 "xorl %0,%0\n\t"
151 LOCK_PREFIX "decl %1\n\t" /* --sem->count */ 146 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
152 "js 2f\n\t" 147 "jns 2f\n\t"
153 "xorl %0,%0\n" 148 "lea %1,%%eax\n\t"
154 "1:\n"
155 LOCK_SECTION_START("")
156 "2:\tlea %1,%%eax\n\t"
157 "call __down_failed_trylock\n\t" 149 "call __down_failed_trylock\n\t"
158 "jmp 1b\n" 150 "2:\n"
159 LOCK_SECTION_END 151 :"=&a" (result), "+m" (sem->count)
160 :"=a" (result), "+m" (sem->count)
161 : 152 :
162 :"memory"); 153 :"memory");
163 return result; 154 return result;
@@ -166,22 +157,16 @@ static inline int down_trylock(struct semaphore * sem)
166/* 157/*
167 * Note! This is subtle. We jump to wake people up only if 158 * Note! This is subtle. We jump to wake people up only if
168 * the semaphore was negative (== somebody was waiting on it). 159 * the semaphore was negative (== somebody was waiting on it).
169 * The default case (no contention) will result in NO
170 * jumps for both down() and up().
171 */ 160 */
172static inline void up(struct semaphore * sem) 161static inline void up(struct semaphore * sem)
173{ 162{
174 __asm__ __volatile__( 163 __asm__ __volatile__(
175 "# atomic up operation\n\t" 164 "# atomic up operation\n\t"
176 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ 165 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
177 "jle 2f\n" 166 "jg 1f\n\t"
178 "1:\n" 167 "lea %0,%%eax\n\t"
179 LOCK_SECTION_START("") 168 "call __up_wakeup\n"
180 "2:\tlea %0,%%eax\n\t" 169 "1:"
181 "call __up_wakeup\n\t"
182 "jmp 1b\n"
183 LOCK_SECTION_END
184 ".subsection 0\n"
185 :"+m" (sem->count) 170 :"+m" (sem->count)
186 : 171 :
187 :"memory","ax"); 172 :"memory","ax");
diff --git a/include/asm-i386/smp.h b/include/asm-i386/smp.h
index 142d10e34ade..32ac8c91d5c5 100644
--- a/include/asm-i386/smp.h
+++ b/include/asm-i386/smp.h
@@ -80,17 +80,12 @@ static inline int hard_smp_processor_id(void)
80 return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID)); 80 return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID));
81} 81}
82#endif 82#endif
83
84static __inline int logical_smp_processor_id(void)
85{
86 /* we don't want to mark this access volatile - bad code generation */
87 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
88}
89
90#endif 83#endif
91 84
92extern int __cpu_disable(void); 85extern int __cpu_disable(void);
93extern void __cpu_die(unsigned int cpu); 86extern void __cpu_die(unsigned int cpu);
87extern unsigned int num_processors;
88
94#endif /* !__ASSEMBLY__ */ 89#endif /* !__ASSEMBLY__ */
95 90
96#else /* CONFIG_SMP */ 91#else /* CONFIG_SMP */
@@ -100,4 +95,15 @@ extern void __cpu_die(unsigned int cpu);
100#define NO_PROC_ID 0xFF /* No processor magic marker */ 95#define NO_PROC_ID 0xFF /* No processor magic marker */
101 96
102#endif 97#endif
98
99#ifndef __ASSEMBLY__
100#ifdef CONFIG_X86_LOCAL_APIC
101static __inline int logical_smp_processor_id(void)
102{
103 /* we don't want to mark this access volatile - bad code generation */
104 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
105}
106#endif
107#endif
108
103#endif 109#endif
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index d1020363c41a..b0b3043f05e1 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -4,8 +4,12 @@
4#include <asm/atomic.h> 4#include <asm/atomic.h>
5#include <asm/rwlock.h> 5#include <asm/rwlock.h>
6#include <asm/page.h> 6#include <asm/page.h>
7#include <asm/processor.h>
7#include <linux/compiler.h> 8#include <linux/compiler.h>
8 9
10#define CLI_STRING "cli"
11#define STI_STRING "sti"
12
9/* 13/*
10 * Your basic SMP spinlocks, allowing only a single CPU anywhere 14 * Your basic SMP spinlocks, allowing only a single CPU anywhere
11 * 15 *
@@ -17,67 +21,64 @@
17 * (the type definitions are in asm/spinlock_types.h) 21 * (the type definitions are in asm/spinlock_types.h)
18 */ 22 */
19 23
20#define __raw_spin_is_locked(x) \ 24static inline int __raw_spin_is_locked(raw_spinlock_t *x)
21 (*(volatile signed char *)(&(x)->slock) <= 0) 25{
22 26 return *(volatile signed char *)(&(x)->slock) <= 0;
23#define __raw_spin_lock_string \ 27}
24 "\n1:\t" \
25 LOCK_PREFIX " ; decb %0\n\t" \
26 "jns 3f\n" \
27 "2:\t" \
28 "rep;nop\n\t" \
29 "cmpb $0,%0\n\t" \
30 "jle 2b\n\t" \
31 "jmp 1b\n" \
32 "3:\n\t"
33
34/*
35 * NOTE: there's an irqs-on section here, which normally would have to be
36 * irq-traced, but on CONFIG_TRACE_IRQFLAGS we never use
37 * __raw_spin_lock_string_flags().
38 */
39#define __raw_spin_lock_string_flags \
40 "\n1:\t" \
41 LOCK_PREFIX " ; decb %0\n\t" \
42 "jns 5f\n" \
43 "2:\t" \
44 "testl $0x200, %1\n\t" \
45 "jz 4f\n\t" \
46 "sti\n" \
47 "3:\t" \
48 "rep;nop\n\t" \
49 "cmpb $0, %0\n\t" \
50 "jle 3b\n\t" \
51 "cli\n\t" \
52 "jmp 1b\n" \
53 "4:\t" \
54 "rep;nop\n\t" \
55 "cmpb $0, %0\n\t" \
56 "jg 1b\n\t" \
57 "jmp 4b\n" \
58 "5:\n\t"
59 28
60static inline void __raw_spin_lock(raw_spinlock_t *lock) 29static inline void __raw_spin_lock(raw_spinlock_t *lock)
61{ 30{
62 asm(__raw_spin_lock_string : "+m" (lock->slock) : : "memory"); 31 asm volatile("\n1:\t"
32 LOCK_PREFIX " ; decb %0\n\t"
33 "jns 3f\n"
34 "2:\t"
35 "rep;nop\n\t"
36 "cmpb $0,%0\n\t"
37 "jle 2b\n\t"
38 "jmp 1b\n"
39 "3:\n\t"
40 : "+m" (lock->slock) : : "memory");
63} 41}
64 42
65/* 43/*
66 * It is easier for the lock validator if interrupts are not re-enabled 44 * It is easier for the lock validator if interrupts are not re-enabled
67 * in the middle of a lock-acquire. This is a performance feature anyway 45 * in the middle of a lock-acquire. This is a performance feature anyway
68 * so we turn it off: 46 * so we turn it off:
47 *
48 * NOTE: there's an irqs-on section here, which normally would have to be
49 * irq-traced, but on CONFIG_TRACE_IRQFLAGS we never use this variant.
69 */ 50 */
70#ifndef CONFIG_PROVE_LOCKING 51#ifndef CONFIG_PROVE_LOCKING
71static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags) 52static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
72{ 53{
73 asm(__raw_spin_lock_string_flags : "+m" (lock->slock) : "r" (flags) : "memory"); 54 asm volatile(
55 "\n1:\t"
56 LOCK_PREFIX " ; decb %0\n\t"
57 "jns 5f\n"
58 "2:\t"
59 "testl $0x200, %1\n\t"
60 "jz 4f\n\t"
61 STI_STRING "\n"
62 "3:\t"
63 "rep;nop\n\t"
64 "cmpb $0, %0\n\t"
65 "jle 3b\n\t"
66 CLI_STRING "\n\t"
67 "jmp 1b\n"
68 "4:\t"
69 "rep;nop\n\t"
70 "cmpb $0, %0\n\t"
71 "jg 1b\n\t"
72 "jmp 4b\n"
73 "5:\n\t"
74 : "+m" (lock->slock) : "r" (flags) : "memory");
74} 75}
75#endif 76#endif
76 77
77static inline int __raw_spin_trylock(raw_spinlock_t *lock) 78static inline int __raw_spin_trylock(raw_spinlock_t *lock)
78{ 79{
79 char oldval; 80 char oldval;
80 __asm__ __volatile__( 81 asm volatile(
81 "xchgb %b0,%1" 82 "xchgb %b0,%1"
82 :"=q" (oldval), "+m" (lock->slock) 83 :"=q" (oldval), "+m" (lock->slock)
83 :"0" (0) : "memory"); 84 :"0" (0) : "memory");
@@ -93,38 +94,29 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
93 94
94#if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE) 95#if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE)
95 96
96#define __raw_spin_unlock_string \
97 "movb $1,%0" \
98 :"+m" (lock->slock) : : "memory"
99
100
101static inline void __raw_spin_unlock(raw_spinlock_t *lock) 97static inline void __raw_spin_unlock(raw_spinlock_t *lock)
102{ 98{
103 __asm__ __volatile__( 99 asm volatile("movb $1,%0" : "+m" (lock->slock) :: "memory");
104 __raw_spin_unlock_string
105 );
106} 100}
107 101
108#else 102#else
109 103
110#define __raw_spin_unlock_string \
111 "xchgb %b0, %1" \
112 :"=q" (oldval), "+m" (lock->slock) \
113 :"0" (oldval) : "memory"
114
115static inline void __raw_spin_unlock(raw_spinlock_t *lock) 104static inline void __raw_spin_unlock(raw_spinlock_t *lock)
116{ 105{
117 char oldval = 1; 106 char oldval = 1;
118 107
119 __asm__ __volatile__( 108 asm volatile("xchgb %b0, %1"
120 __raw_spin_unlock_string 109 : "=q" (oldval), "+m" (lock->slock)
121 ); 110 : "0" (oldval) : "memory");
122} 111}
123 112
124#endif 113#endif
125 114
126#define __raw_spin_unlock_wait(lock) \ 115static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
127 do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0) 116{
117 while (__raw_spin_is_locked(lock))
118 cpu_relax();
119}
128 120
129/* 121/*
130 * Read-write spinlocks, allowing multiple readers 122 * Read-write spinlocks, allowing multiple readers
@@ -151,22 +143,36 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
151 * read_can_lock - would read_trylock() succeed? 143 * read_can_lock - would read_trylock() succeed?
152 * @lock: the rwlock in question. 144 * @lock: the rwlock in question.
153 */ 145 */
154#define __raw_read_can_lock(x) ((int)(x)->lock > 0) 146static inline int __raw_read_can_lock(raw_rwlock_t *x)
147{
148 return (int)(x)->lock > 0;
149}
155 150
156/** 151/**
157 * write_can_lock - would write_trylock() succeed? 152 * write_can_lock - would write_trylock() succeed?
158 * @lock: the rwlock in question. 153 * @lock: the rwlock in question.
159 */ 154 */
160#define __raw_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS) 155static inline int __raw_write_can_lock(raw_rwlock_t *x)
156{
157 return (x)->lock == RW_LOCK_BIAS;
158}
161 159
162static inline void __raw_read_lock(raw_rwlock_t *rw) 160static inline void __raw_read_lock(raw_rwlock_t *rw)
163{ 161{
164 __build_read_lock(rw, "__read_lock_failed"); 162 asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t"
163 "jns 1f\n"
164 "call __read_lock_failed\n\t"
165 "1:\n"
166 ::"a" (rw) : "memory");
165} 167}
166 168
167static inline void __raw_write_lock(raw_rwlock_t *rw) 169static inline void __raw_write_lock(raw_rwlock_t *rw)
168{ 170{
169 __build_write_lock(rw, "__write_lock_failed"); 171 asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",(%0)\n\t"
172 "jz 1f\n"
173 "call __write_lock_failed\n\t"
174 "1:\n"
175 ::"a" (rw) : "memory");
170} 176}
171 177
172static inline int __raw_read_trylock(raw_rwlock_t *lock) 178static inline int __raw_read_trylock(raw_rwlock_t *lock)
diff --git a/include/asm-i386/stacktrace.h b/include/asm-i386/stacktrace.h
new file mode 100644
index 000000000000..7d1f6a5cbfca
--- /dev/null
+++ b/include/asm-i386/stacktrace.h
@@ -0,0 +1 @@
#include <asm-x86_64/stacktrace.h>
diff --git a/include/asm-i386/therm_throt.h b/include/asm-i386/therm_throt.h
new file mode 100644
index 000000000000..399bf6026b16
--- /dev/null
+++ b/include/asm-i386/therm_throt.h
@@ -0,0 +1,9 @@
1#ifndef __ASM_I386_THERM_THROT_H__
2#define __ASM_I386_THERM_THROT_H__ 1
3
4#include <asm/atomic.h>
5
6extern atomic_t therm_throt_en;
7int therm_throt_process(int curr);
8
9#endif /* __ASM_I386_THERM_THROT_H__ */
diff --git a/include/asm-i386/tlbflush.h b/include/asm-i386/tlbflush.h
index d57ca5c540b6..360648b0f2b3 100644
--- a/include/asm-i386/tlbflush.h
+++ b/include/asm-i386/tlbflush.h
@@ -36,8 +36,6 @@
36 : "memory"); \ 36 : "memory"); \
37 } while (0) 37 } while (0)
38 38
39extern unsigned long pgkern_mask;
40
41# define __flush_tlb_all() \ 39# define __flush_tlb_all() \
42 do { \ 40 do { \
43 if (cpu_has_pge) \ 41 if (cpu_has_pge) \
@@ -49,7 +47,7 @@ extern unsigned long pgkern_mask;
49#define cpu_has_invlpg (boot_cpu_data.x86 > 3) 47#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
50 48
51#define __flush_tlb_single(addr) \ 49#define __flush_tlb_single(addr) \
52 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr)) 50 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
53 51
54#ifdef CONFIG_X86_INVLPG 52#ifdef CONFIG_X86_INVLPG
55# define __flush_tlb_one(addr) __flush_tlb_single(addr) 53# define __flush_tlb_one(addr) __flush_tlb_single(addr)
diff --git a/include/asm-i386/tsc.h b/include/asm-i386/tsc.h
index 97b828ce31e0..c13933185c1c 100644
--- a/include/asm-i386/tsc.h
+++ b/include/asm-i386/tsc.h
@@ -6,7 +6,6 @@
6#ifndef _ASM_i386_TSC_H 6#ifndef _ASM_i386_TSC_H
7#define _ASM_i386_TSC_H 7#define _ASM_i386_TSC_H
8 8
9#include <linux/config.h>
10#include <asm/processor.h> 9#include <asm/processor.h>
11 10
12/* 11/*
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index fc1c8ddae149..bd9987087adc 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -323,18 +323,20 @@
323#define __NR_tee 315 323#define __NR_tee 315
324#define __NR_vmsplice 316 324#define __NR_vmsplice 316
325#define __NR_move_pages 317 325#define __NR_move_pages 317
326#define __NR_getcpu 318
326 327
327#ifdef __KERNEL__ 328#ifdef __KERNEL__
328 329
329#define NR_syscalls 318 330#define NR_syscalls 319
331#include <linux/err.h>
330 332
331/* 333/*
332 * user-visible error numbers are in the range -1 - -128: see 334 * user-visible error numbers are in the range -1 - -MAX_ERRNO: see
333 * <asm-i386/errno.h> 335 * <asm-i386/errno.h>
334 */ 336 */
335#define __syscall_return(type, res) \ 337#define __syscall_return(type, res) \
336do { \ 338do { \
337 if ((unsigned long)(res) >= (unsigned long)(-(128 + 1))) { \ 339 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
338 errno = -(res); \ 340 errno = -(res); \
339 res = -1; \ 341 res = -1; \
340 } \ 342 } \
diff --git a/include/asm-i386/unwind.h b/include/asm-i386/unwind.h
index 4c1a0b968569..5031d693b89d 100644
--- a/include/asm-i386/unwind.h
+++ b/include/asm-i386/unwind.h
@@ -18,6 +18,7 @@ struct unwind_frame_info
18{ 18{
19 struct pt_regs regs; 19 struct pt_regs regs;
20 struct task_struct *task; 20 struct task_struct *task;
21 unsigned call_frame:1;
21}; 22};
22 23
23#define UNW_PC(frame) (frame)->regs.eip 24#define UNW_PC(frame) (frame)->regs.eip
@@ -28,6 +29,8 @@ struct unwind_frame_info
28#define FRAME_LINK_OFFSET 0 29#define FRAME_LINK_OFFSET 0
29#define STACK_BOTTOM(tsk) STACK_LIMIT((tsk)->thread.esp0) 30#define STACK_BOTTOM(tsk) STACK_LIMIT((tsk)->thread.esp0)
30#define STACK_TOP(tsk) ((tsk)->thread.esp0) 31#define STACK_TOP(tsk) ((tsk)->thread.esp0)
32#else
33#define UNW_FP(frame) ((void)(frame), 0)
31#endif 34#endif
32#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1)) 35#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1))
33 36
@@ -42,6 +45,10 @@ struct unwind_frame_info
42 PTREGS_INFO(edi), \ 45 PTREGS_INFO(edi), \
43 PTREGS_INFO(eip) 46 PTREGS_INFO(eip)
44 47
48#define UNW_DEFAULT_RA(raItem, dataAlign) \
49 ((raItem).where == Memory && \
50 !((raItem).value * (dataAlign) + 4))
51
45static inline void arch_unw_init_frame_info(struct unwind_frame_info *info, 52static inline void arch_unw_init_frame_info(struct unwind_frame_info *info,
46 /*const*/ struct pt_regs *regs) 53 /*const*/ struct pt_regs *regs)
47{ 54{
@@ -88,6 +95,7 @@ static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
88 95
89#define UNW_PC(frame) ((void)(frame), 0) 96#define UNW_PC(frame) ((void)(frame), 0)
90#define UNW_SP(frame) ((void)(frame), 0) 97#define UNW_SP(frame) ((void)(frame), 0)
98#define UNW_FP(frame) ((void)(frame), 0)
91 99
92static inline int arch_unw_user_mode(const void *info) 100static inline int arch_unw_user_mode(const void *info)
93{ 101{
diff --git a/include/asm-ia64/esi.h b/include/asm-ia64/esi.h
new file mode 100644
index 000000000000..84aac0e0b583
--- /dev/null
+++ b/include/asm-ia64/esi.h
@@ -0,0 +1,30 @@
1/*
2 * ESI service calls.
3 *
4 * Copyright (c) Copyright 2005-2006 Hewlett-Packard Development Company, L.P.
5 * Alex Williamson <alex.williamson@hp.com>
6 */
7#ifndef esi_h
8#define esi_h
9
10#include <linux/efi.h>
11
12#define ESI_QUERY 0x00000001
13#define ESI_OPEN_HANDLE 0x02000000
14#define ESI_CLOSE_HANDLE 0x02000001
15
16enum esi_proc_type {
17 ESI_PROC_SERIALIZED, /* calls need to be serialized */
18 ESI_PROC_MP_SAFE, /* MP-safe, but not reentrant */
19 ESI_PROC_REENTRANT /* MP-safe and reentrant */
20};
21
22extern int ia64_esi_init (void);
23extern struct ia64_sal_retval esi_call_phys (void *, u64 *);
24extern int ia64_esi_call(efi_guid_t, struct ia64_sal_retval *,
25 enum esi_proc_type,
26 u64, u64, u64, u64, u64, u64, u64, u64);
27extern int ia64_esi_call_phys(efi_guid_t, struct ia64_sal_retval *, u64, u64,
28 u64, u64, u64, u64, u64, u64);
29
30#endif /* esi_h */
diff --git a/include/asm-ia64/futex.h b/include/asm-ia64/futex.h
index 6a332a9f099c..07d77f3a8cbe 100644
--- a/include/asm-ia64/futex.h
+++ b/include/asm-ia64/futex.h
@@ -1,6 +1,124 @@
1#ifndef _ASM_FUTEX_H 1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H 2#define _ASM_FUTEX_H
3 3
4#include <asm-generic/futex.h> 4#include <linux/futex.h>
5#include <asm/errno.h>
6#include <asm/system.h>
7#include <asm/uaccess.h>
5 8
6#endif 9#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
10do { \
11 register unsigned long r8 __asm ("r8") = 0; \
12 __asm__ __volatile__( \
13 " mf;; \n" \
14 "[1:] " insn ";; \n" \
15 " .xdata4 \"__ex_table\", 1b-., 2f-. \n" \
16 "[2:]" \
17 : "+r" (r8), "=r" (oldval) \
18 : "r" (uaddr), "r" (oparg) \
19 : "memory"); \
20 ret = r8; \
21} while (0)
22
23#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
24do { \
25 register unsigned long r8 __asm ("r8") = 0; \
26 int val, newval; \
27 do { \
28 __asm__ __volatile__( \
29 " mf;; \n" \
30 "[1:] ld4 %3=[%4];; \n" \
31 " mov %2=%3 \n" \
32 insn ";; \n" \
33 " mov ar.ccv=%2;; \n" \
34 "[2:] cmpxchg4.acq %1=[%4],%3,ar.ccv;; \n" \
35 " .xdata4 \"__ex_table\", 1b-., 3f-.\n" \
36 " .xdata4 \"__ex_table\", 2b-., 3f-.\n" \
37 "[3:]" \
38 : "+r" (r8), "=r" (val), "=&r" (oldval), \
39 "=&r" (newval) \
40 : "r" (uaddr), "r" (oparg) \
41 : "memory"); \
42 if (unlikely (r8)) \
43 break; \
44 } while (unlikely (val != oldval)); \
45 ret = r8; \
46} while (0)
47
48static inline int
49futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
50{
51 int op = (encoded_op >> 28) & 7;
52 int cmp = (encoded_op >> 24) & 15;
53 int oparg = (encoded_op << 8) >> 20;
54 int cmparg = (encoded_op << 20) >> 20;
55 int oldval = 0, ret;
56 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
57 oparg = 1 << oparg;
58
59 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
60 return -EFAULT;
61
62 inc_preempt_count();
63
64 switch (op) {
65 case FUTEX_OP_SET:
66 __futex_atomic_op1("xchg4 %1=[%2],%3", ret, oldval, uaddr,
67 oparg);
68 break;
69 case FUTEX_OP_ADD:
70 __futex_atomic_op2("add %3=%3,%5", ret, oldval, uaddr, oparg);
71 break;
72 case FUTEX_OP_OR:
73 __futex_atomic_op2("or %3=%3,%5", ret, oldval, uaddr, oparg);
74 break;
75 case FUTEX_OP_ANDN:
76 __futex_atomic_op2("and %3=%3,%5", ret, oldval, uaddr,
77 ~oparg);
78 break;
79 case FUTEX_OP_XOR:
80 __futex_atomic_op2("xor %3=%3,%5", ret, oldval, uaddr, oparg);
81 break;
82 default:
83 ret = -ENOSYS;
84 }
85
86 dec_preempt_count();
87
88 if (!ret) {
89 switch (cmp) {
90 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
91 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
92 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
93 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
94 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
95 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
96 default: ret = -ENOSYS;
97 }
98 }
99 return ret;
100}
101
102static inline int
103futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
104{
105 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
106 return -EFAULT;
107
108 {
109 register unsigned long r8 __asm ("r8");
110 __asm__ __volatile__(
111 " mf;; \n"
112 " mov ar.ccv=%3;; \n"
113 "[1:] cmpxchg4.acq %0=[%1],%2,ar.ccv \n"
114 " .xdata4 \"__ex_table\", 1b-., 2f-. \n"
115 "[2:]"
116 : "=r" (r8)
117 : "r" (uaddr), "r" (newval),
118 "rO" ((long) (unsigned) oldval)
119 : "memory");
120 return r8;
121 }
122}
123
124#endif /* _ASM_FUTEX_H */
diff --git a/include/asm-ia64/kprobes.h b/include/asm-ia64/kprobes.h
index 938904910115..1b45b71c79b9 100644
--- a/include/asm-ia64/kprobes.h
+++ b/include/asm-ia64/kprobes.h
@@ -29,7 +29,8 @@
29#include <linux/percpu.h> 29#include <linux/percpu.h>
30#include <asm/break.h> 30#include <asm/break.h>
31 31
32#define MAX_INSN_SIZE 16 32#define __ARCH_WANT_KPROBES_INSN_SLOT
33#define MAX_INSN_SIZE 1
33#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6) 34#define BREAK_INST (long)(__IA64_BREAK_KPROBE << 6)
34 35
35typedef union cmp_inst { 36typedef union cmp_inst {
@@ -94,7 +95,7 @@ struct kprobe_ctlblk {
94#define IP_RELATIVE_PREDICT_OPCODE (7) 95#define IP_RELATIVE_PREDICT_OPCODE (7)
95#define LONG_BRANCH_OPCODE (0xC) 96#define LONG_BRANCH_OPCODE (0xC)
96#define LONG_CALL_OPCODE (0xD) 97#define LONG_CALL_OPCODE (0xD)
97#define arch_remove_kprobe(p) do {} while (0) 98#define flush_insn_slot(p) do { } while (0)
98 99
99typedef struct kprobe_opcode { 100typedef struct kprobe_opcode {
100 bundle_t bundle; 101 bundle_t bundle;
@@ -108,7 +109,7 @@ struct fnptr {
108/* Architecture specific copy of original instruction*/ 109/* Architecture specific copy of original instruction*/
109struct arch_specific_insn { 110struct arch_specific_insn {
110 /* copy of the instruction to be emulated */ 111 /* copy of the instruction to be emulated */
111 kprobe_opcode_t insn; 112 kprobe_opcode_t *insn;
112 #define INST_FLAG_FIX_RELATIVE_IP_ADDR 1 113 #define INST_FLAG_FIX_RELATIVE_IP_ADDR 1
113 #define INST_FLAG_FIX_BRANCH_REG 2 114 #define INST_FLAG_FIX_BRANCH_REG 2
114 #define INST_FLAG_BREAK_INST 4 115 #define INST_FLAG_BREAK_INST 4
@@ -125,6 +126,6 @@ static inline void jprobe_return(void)
125} 126}
126extern void invalidate_stacked_regs(void); 127extern void invalidate_stacked_regs(void);
127extern void flush_register_stack(void); 128extern void flush_register_stack(void);
128extern void flush_insn_slot(struct kprobe *p); 129extern void arch_remove_kprobe(struct kprobe *p);
129 130
130#endif /* _ASM_KPROBES_H */ 131#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-ia64/mca_asm.h b/include/asm-ia64/mca_asm.h
index 27c9203d8ce3..76203f9a8718 100644
--- a/include/asm-ia64/mca_asm.h
+++ b/include/asm-ia64/mca_asm.h
@@ -197,9 +197,9 @@
197 movl temp2 = start_addr; \ 197 movl temp2 = start_addr; \
198 ;; \ 198 ;; \
199 mov cr.iip = temp2; \ 199 mov cr.iip = temp2; \
200 movl gp = __gp \
200 ;; \ 201 ;; \
201 DATA_PA_TO_VA(sp, temp1); \ 202 DATA_PA_TO_VA(sp, temp1); \
202 DATA_PA_TO_VA(gp, temp2); \
203 srlz.i; \ 203 srlz.i; \
204 ;; \ 204 ;; \
205 nop 1; \ 205 nop 1; \
diff --git a/include/asm-ia64/meminit.h b/include/asm-ia64/meminit.h
index 6a33a07b3f1d..c3b1f862e6e7 100644
--- a/include/asm-ia64/meminit.h
+++ b/include/asm-ia64/meminit.h
@@ -55,6 +55,7 @@ extern void efi_memmap_init(unsigned long *, unsigned long *);
55 extern unsigned long vmalloc_end; 55 extern unsigned long vmalloc_end;
56 extern struct page *vmem_map; 56 extern struct page *vmem_map;
57 extern int find_largest_hole (u64 start, u64 end, void *arg); 57 extern int find_largest_hole (u64 start, u64 end, void *arg);
58 extern int register_active_ranges (u64 start, u64 end, void *arg);
58 extern int create_mem_map_page_table (u64 start, u64 end, void *arg); 59 extern int create_mem_map_page_table (u64 start, u64 end, void *arg);
59 extern int vmemmap_find_next_valid_pfn(int, int); 60 extern int vmemmap_find_next_valid_pfn(int, int);
60#else 61#else
diff --git a/include/asm-ia64/module.h b/include/asm-ia64/module.h
index 85c82bd819f2..d2da61e4c49b 100644
--- a/include/asm-ia64/module.h
+++ b/include/asm-ia64/module.h
@@ -28,7 +28,8 @@ struct mod_arch_specific {
28#define Elf_Ehdr Elf64_Ehdr 28#define Elf_Ehdr Elf64_Ehdr
29 29
30#define MODULE_PROC_FAMILY "ia64" 30#define MODULE_PROC_FAMILY "ia64"
31#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY 31#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY \
32 "gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__)
32 33
33#define ARCH_SHF_SMALL SHF_IA_64_SHORT 34#define ARCH_SHF_SMALL SHF_IA_64_SHORT
34 35
diff --git a/include/asm-ia64/numa.h b/include/asm-ia64/numa.h
index e0a1d173e42d..7d5e2ccc37a0 100644
--- a/include/asm-ia64/numa.h
+++ b/include/asm-ia64/numa.h
@@ -69,6 +69,8 @@ extern void unmap_cpu_from_node(int cpu, int nid);
69 69
70 70
71#else /* !CONFIG_NUMA */ 71#else /* !CONFIG_NUMA */
72#define map_cpu_to_node(cpu, nid) do{}while(0)
73#define unmap_cpu_from_node(cpu, nid) do{}while(0)
72 74
73#define paddr_to_nid(addr) 0 75#define paddr_to_nid(addr) 0
74 76
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index 20a8d618c845..2c8fd92d0ece 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -78,6 +78,7 @@
78#define PAL_VM_TR_READ 261 /* read contents of translation register */ 78#define PAL_VM_TR_READ 261 /* read contents of translation register */
79#define PAL_GET_PSTATE 262 /* get the current P-state */ 79#define PAL_GET_PSTATE 262 /* get the current P-state */
80#define PAL_SET_PSTATE 263 /* set the P-state */ 80#define PAL_SET_PSTATE 263 /* set the P-state */
81#define PAL_BRAND_INFO 274 /* Processor branding information */
81 82
82#ifndef __ASSEMBLY__ 83#ifndef __ASSEMBLY__
83 84
@@ -963,7 +964,8 @@ static inline s64
963ia64_pal_cache_read (pal_cache_line_id_u_t line_id, u64 physical_addr) 964ia64_pal_cache_read (pal_cache_line_id_u_t line_id, u64 physical_addr)
964{ 965{
965 struct ia64_pal_retval iprv; 966 struct ia64_pal_retval iprv;
966 PAL_CALL(iprv, PAL_CACHE_READ, line_id.pclid_data, physical_addr, 0); 967 PAL_CALL_PHYS_STK(iprv, PAL_CACHE_READ, line_id.pclid_data,
968 physical_addr, 0);
967 return iprv.status; 969 return iprv.status;
968} 970}
969 971
@@ -985,7 +987,8 @@ static inline s64
985ia64_pal_cache_write (pal_cache_line_id_u_t line_id, u64 physical_addr, u64 data) 987ia64_pal_cache_write (pal_cache_line_id_u_t line_id, u64 physical_addr, u64 data)
986{ 988{
987 struct ia64_pal_retval iprv; 989 struct ia64_pal_retval iprv;
988 PAL_CALL(iprv, PAL_CACHE_WRITE, line_id.pclid_data, physical_addr, data); 990 PAL_CALL_PHYS_STK(iprv, PAL_CACHE_WRITE, line_id.pclid_data,
991 physical_addr, data);
989 return iprv.status; 992 return iprv.status;
990} 993}
991 994
@@ -1133,6 +1136,15 @@ ia64_pal_set_pstate (u64 pstate_index)
1133 return iprv.status; 1136 return iprv.status;
1134} 1137}
1135 1138
1139/* Processor branding information*/
1140static inline s64
1141ia64_pal_get_brand_info (char *brand_info)
1142{
1143 struct ia64_pal_retval iprv;
1144 PAL_CALL_STK(iprv, PAL_BRAND_INFO, 0, (u64)brand_info, 0);
1145 return iprv.status;
1146}
1147
1136/* Cause the processor to enter LIGHT HALT state, where prefetching and execution are 1148/* Cause the processor to enter LIGHT HALT state, where prefetching and execution are
1137 * suspended, but cache and TLB coherency is maintained. 1149 * suspended, but cache and TLB coherency is maintained.
1138 */ 1150 */
diff --git a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
index 265f4824db0e..5830d36fd8e6 100644
--- a/include/asm-ia64/processor.h
+++ b/include/asm-ia64/processor.h
@@ -20,12 +20,6 @@
20#include <asm/ustack.h> 20#include <asm/ustack.h>
21 21
22#define IA64_NUM_DBG_REGS 8 22#define IA64_NUM_DBG_REGS 8
23/*
24 * Limits for PMC and PMD are set to less than maximum architected values
25 * but should be sufficient for a while
26 */
27#define IA64_NUM_PMC_REGS 64
28#define IA64_NUM_PMD_REGS 64
29 23
30#define DEFAULT_MAP_BASE __IA64_UL_CONST(0x2000000000000000) 24#define DEFAULT_MAP_BASE __IA64_UL_CONST(0x2000000000000000)
31#define DEFAULT_TASK_SIZE __IA64_UL_CONST(0xa000000000000000) 25#define DEFAULT_TASK_SIZE __IA64_UL_CONST(0xa000000000000000)
@@ -163,6 +157,7 @@ struct cpuinfo_ia64 {
163 __u8 family; 157 __u8 family;
164 __u8 archrev; 158 __u8 archrev;
165 char vendor[16]; 159 char vendor[16];
160 char *model_name;
166 161
167#ifdef CONFIG_NUMA 162#ifdef CONFIG_NUMA
168 struct ia64_node_data *node_data; 163 struct ia64_node_data *node_data;
@@ -262,13 +257,9 @@ struct thread_struct {
262# define INIT_THREAD_IA32 257# define INIT_THREAD_IA32
263#endif /* CONFIG_IA32_SUPPORT */ 258#endif /* CONFIG_IA32_SUPPORT */
264#ifdef CONFIG_PERFMON 259#ifdef CONFIG_PERFMON
265 __u64 pmcs[IA64_NUM_PMC_REGS];
266 __u64 pmds[IA64_NUM_PMD_REGS];
267 void *pfm_context; /* pointer to detailed PMU context */ 260 void *pfm_context; /* pointer to detailed PMU context */
268 unsigned long pfm_needs_checking; /* when >0, pending perfmon work on kernel exit */ 261 unsigned long pfm_needs_checking; /* when >0, pending perfmon work on kernel exit */
269# define INIT_THREAD_PM .pmcs = {0UL, }, \ 262# define INIT_THREAD_PM .pfm_context = NULL, \
270 .pmds = {0UL, }, \
271 .pfm_context = NULL, \
272 .pfm_needs_checking = 0UL, 263 .pfm_needs_checking = 0UL,
273#else 264#else
274# define INIT_THREAD_PM 265# define INIT_THREAD_PM
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index 74bde1c2bb1a..60fd4ae014f6 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -126,6 +126,7 @@ extern void smp_send_reschedule (int cpu);
126extern void lock_ipi_calllock(void); 126extern void lock_ipi_calllock(void);
127extern void unlock_ipi_calllock(void); 127extern void unlock_ipi_calllock(void);
128extern void identify_siblings (struct cpuinfo_ia64 *); 128extern void identify_siblings (struct cpuinfo_ia64 *);
129extern int is_multithreading_enabled(void);
129 130
130#else 131#else
131 132
diff --git a/include/asm-ia64/unistd.h b/include/asm-ia64/unistd.h
index f581662c5ab8..bb0eb727dcd0 100644
--- a/include/asm-ia64/unistd.h
+++ b/include/asm-ia64/unistd.h
@@ -286,7 +286,8 @@
286/* 1294, 1295 reserved for pselect/ppoll */ 286/* 1294, 1295 reserved for pselect/ppoll */
287#define __NR_unshare 1296 287#define __NR_unshare 1296
288#define __NR_splice 1297 288#define __NR_splice 1297
289/* 1298, 1299 reserved for set_robust_list/get_robust_list */ 289#define __NR_set_robust_list 1298
290#define __NR_get_robust_list 1299
290#define __NR_sync_file_range 1300 291#define __NR_sync_file_range 1300
291#define __NR_tee 1301 292#define __NR_tee 1301
292#define __NR_vmsplice 1302 293#define __NR_vmsplice 1302
diff --git a/include/asm-m32r/spinlock.h b/include/asm-m32r/spinlock.h
index f94c1a673569..f9f90727a4a1 100644
--- a/include/asm-m32r/spinlock.h
+++ b/include/asm-m32r/spinlock.h
@@ -298,7 +298,14 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
298 ); 298 );
299} 299}
300 300
301#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) 301static inline int __raw_read_trylock(raw_rwlock_t *lock)
302{
303 atomic_t *count = (atomic_t*)lock;
304 if (atomic_dec_return(count) >= 0)
305 return 1;
306 atomic_inc(count);
307 return 0;
308}
302 309
303static inline int __raw_write_trylock(raw_rwlock_t *lock) 310static inline int __raw_write_trylock(raw_rwlock_t *lock)
304{ 311{
diff --git a/include/asm-m32r/system.h b/include/asm-m32r/system.h
index 9e618afec6ed..4ce0619f6989 100644
--- a/include/asm-m32r/system.h
+++ b/include/asm-m32r/system.h
@@ -328,15 +328,15 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
328#define smp_rmb() rmb() 328#define smp_rmb() rmb()
329#define smp_wmb() wmb() 329#define smp_wmb() wmb()
330#define smp_read_barrier_depends() read_barrier_depends() 330#define smp_read_barrier_depends() read_barrier_depends()
331#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
331#else 332#else
332#define smp_mb() barrier() 333#define smp_mb() barrier()
333#define smp_rmb() barrier() 334#define smp_rmb() barrier()
334#define smp_wmb() barrier() 335#define smp_wmb() barrier()
335#define smp_read_barrier_depends() do { } while (0) 336#define smp_read_barrier_depends() do { } while (0)
337#define set_mb(var, value) do { var = value; barrier(); } while (0)
336#endif 338#endif
337 339
338#define set_mb(var, value) do { xchg(&var, value); } while (0)
339
340#define arch_align_stack(x) (x) 340#define arch_align_stack(x) (x)
341 341
342#endif /* _ASM_M32R_SYSTEM_H */ 342#endif /* _ASM_M32R_SYSTEM_H */
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index 89f376e6229f..5c6a9ac6cf1a 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -296,8 +296,9 @@
296#ifdef __KERNEL__ 296#ifdef __KERNEL__
297 297
298#define NR_syscalls 285 298#define NR_syscalls 285
299#include <linux/err.h>
299 300
300/* user-visible error numbers are in the range -1 - -124: see 301/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
301 * <asm-m32r/errno.h> 302 * <asm-m32r/errno.h>
302 */ 303 */
303 304
@@ -305,7 +306,7 @@
305 306
306#define __syscall_return(type, res) \ 307#define __syscall_return(type, res) \
307do { \ 308do { \
308 if ((unsigned long)(res) >= (unsigned long)(-(124 + 1))) { \ 309 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
309 /* Avoid using "res" which is declared to be in register r0; \ 310 /* Avoid using "res" which is declared to be in register r0; \
310 errno might expand to a function call and clobber it. */ \ 311 errno might expand to a function call and clobber it. */ \
311 int __err = -(res); \ 312 int __err = -(res); \
diff --git a/include/asm-m68k/unistd.h b/include/asm-m68k/unistd.h
index 7c0b6296b45c..751632b904db 100644
--- a/include/asm-m68k/unistd.h
+++ b/include/asm-m68k/unistd.h
@@ -288,13 +288,14 @@
288#ifdef __KERNEL__ 288#ifdef __KERNEL__
289 289
290#define NR_syscalls 282 290#define NR_syscalls 282
291#include <linux/err.h>
291 292
292/* user-visible error numbers are in the range -1 - -124: see 293/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
293 <asm-m68k/errno.h> */ 294 <asm-m68k/errno.h> */
294 295
295#define __syscall_return(type, res) \ 296#define __syscall_return(type, res) \
296do { \ 297do { \
297 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 298 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
298 /* avoid using res which is declared to be in register d0; \ 299 /* avoid using res which is declared to be in register d0; \
299 errno might expand to a function call and clobber it. */ \ 300 errno might expand to a function call and clobber it. */ \
300 int __err = -(res); \ 301 int __err = -(res); \
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index 1b2abdf281e1..21fdc37c5c2c 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -289,13 +289,14 @@
289#ifdef __KERNEL__ 289#ifdef __KERNEL__
290 290
291#define NR_syscalls 282 291#define NR_syscalls 282
292#include <linux/err.h>
292 293
293/* user-visible error numbers are in the range -1 - -122: see 294/* user-visible error numbers are in the range -1 - -MAX_ERRNO: see
294 <asm-m68k/errno.h> */ 295 <asm-m68k/errno.h> */
295 296
296#define __syscall_return(type, res) \ 297#define __syscall_return(type, res) \
297do { \ 298do { \
298 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 299 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
299 /* avoid using res which is declared to be in register d0; \ 300 /* avoid using res which is declared to be in register d0; \
300 errno might expand to a function call and clobber it. */ \ 301 errno might expand to a function call and clobber it. */ \
301 int __err = -(res); \ 302 int __err = -(res); \
diff --git a/include/asm-mips/Kbuild b/include/asm-mips/Kbuild
index c68e1680da01..7897f05e3165 100644
--- a/include/asm-mips/Kbuild
+++ b/include/asm-mips/Kbuild
@@ -1 +1,3 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2
3header-y += cachectl.h sgidefs.h sysmips.h
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index 3b745e76f429..78c35ec46362 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -112,8 +112,7 @@
112 * Valid machtype for group GALILEO 112 * Valid machtype for group GALILEO
113 */ 113 */
114#define MACH_GROUP_GALILEO 11 /* Galileo Eval Boards */ 114#define MACH_GROUP_GALILEO 11 /* Galileo Eval Boards */
115#define MACH_EV96100 0 /* EV96100 */ 115#define MACH_EV64120A 0 /* EV64120A */
116#define MACH_EV64120A 1 /* EV64120A */
117 116
118/* 117/*
119 * Valid machtype for group MOMENCO 118 * Valid machtype for group MOMENCO
diff --git a/include/asm-mips/cacheflush.h b/include/asm-mips/cacheflush.h
index 47bc8f6c20d2..36416fdfcf68 100644
--- a/include/asm-mips/cacheflush.h
+++ b/include/asm-mips/cacheflush.h
@@ -21,7 +21,6 @@
21 * - flush_cache_range(vma, start, end) flushes a range of pages 21 * - flush_cache_range(vma, start, end) flushes a range of pages
22 * - flush_icache_range(start, end) flush a range of instructions 22 * - flush_icache_range(start, end) flush a range of instructions
23 * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache 23 * - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache
24 * - flush_icache_page(vma, pg) flushes(invalidates) a page for icache
25 * 24 *
26 * MIPS specific flush operations: 25 * MIPS specific flush operations:
27 * 26 *
@@ -39,7 +38,7 @@ extern void __flush_dcache_page(struct page *page);
39 38
40static inline void flush_dcache_page(struct page *page) 39static inline void flush_dcache_page(struct page *page)
41{ 40{
42 if (cpu_has_dc_aliases) 41 if (cpu_has_dc_aliases || !cpu_has_ic_fills_f_dc)
43 __flush_dcache_page(page); 42 __flush_dcache_page(page);
44 43
45} 44}
@@ -47,8 +46,13 @@ static inline void flush_dcache_page(struct page *page)
47#define flush_dcache_mmap_lock(mapping) do { } while (0) 46#define flush_dcache_mmap_lock(mapping) do { } while (0)
48#define flush_dcache_mmap_unlock(mapping) do { } while (0) 47#define flush_dcache_mmap_unlock(mapping) do { } while (0)
49 48
50extern void (*flush_icache_page)(struct vm_area_struct *vma, 49extern void (*__flush_icache_page)(struct vm_area_struct *vma,
51 struct page *page); 50 struct page *page);
51static inline void flush_icache_page(struct vm_area_struct *vma,
52 struct page *page)
53{
54}
55
52extern void (*flush_icache_range)(unsigned long start, unsigned long end); 56extern void (*flush_icache_range)(unsigned long start, unsigned long end);
53#define flush_cache_vmap(start, end) flush_cache_all() 57#define flush_cache_vmap(start, end) flush_cache_all()
54#define flush_cache_vunmap(start, end) flush_cache_all() 58#define flush_cache_vunmap(start, end) flush_cache_all()
@@ -60,7 +64,7 @@ static inline void copy_to_user_page(struct vm_area_struct *vma,
60 if (cpu_has_dc_aliases) 64 if (cpu_has_dc_aliases)
61 flush_cache_page(vma, vaddr, page_to_pfn(page)); 65 flush_cache_page(vma, vaddr, page_to_pfn(page));
62 memcpy(dst, src, len); 66 memcpy(dst, src, len);
63 flush_icache_page(vma, page); 67 __flush_icache_page(vma, page);
64} 68}
65 69
66static inline void copy_from_user_page(struct vm_area_struct *vma, 70static inline void copy_from_user_page(struct vm_area_struct *vma,
diff --git a/include/asm-mips/fcntl.h b/include/asm-mips/fcntl.h
index 787220e6c1fc..00a50ec1c19f 100644
--- a/include/asm-mips/fcntl.h
+++ b/include/asm-mips/fcntl.h
@@ -25,8 +25,6 @@
25 25
26#define F_SETOWN 24 /* for sockets. */ 26#define F_SETOWN 24 /* for sockets. */
27#define F_GETOWN 23 /* for sockets. */ 27#define F_GETOWN 23 /* for sockets. */
28#define F_SETSIG 10 /* for sockets. */
29#define F_GETSIG 11 /* for sockets. */
30 28
31#ifndef __mips64 29#ifndef __mips64
32#define F_GETLK64 33 /* using 'struct flock64' */ 30#define F_GETLK64 33 /* using 'struct flock64' */
diff --git a/include/asm-mips/galileo-boards/gt96100.h b/include/asm-mips/galileo-boards/gt96100.h
deleted file mode 100644
index aabd1b629c19..000000000000
--- a/include/asm-mips/galileo-boards/gt96100.h
+++ /dev/null
@@ -1,427 +0,0 @@
1/*
2 * Copyright 2000 MontaVista Software Inc.
3 * Author: MontaVista Software, Inc.
4 * stevel@mvista.com or source@mvista.com
5 *
6 * This program is free software; you can distribute it and/or modify it
7 * under the terms of the GNU General Public License (Version 2) as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
18 *
19 * Register offsets of the MIPS GT96100 Advanced Communication Controller.
20 */
21#ifndef _GT96100_H
22#define _GT96100_H
23
24/*
25 * Galileo GT96100 internal register base.
26 */
27#define MIPS_GT96100_BASE (KSEG1ADDR(0x14000000))
28
29#define GT96100_WRITE(ofs, data) \
30 *(volatile u32 *)(MIPS_GT96100_BASE+ofs) = cpu_to_le32(data)
31#define GT96100_READ(ofs) \
32 le32_to_cpu(*(volatile u32 *)(MIPS_GT96100_BASE+ofs))
33
34#define GT96100_ETH_IO_SIZE 0x4000
35
36/************************************************************************
37 * Register offset addresses follow
38 ************************************************************************/
39
40/* CPU Interface Control Registers */
41#define GT96100_CPU_INTERF_CONFIG 0x000000
42
43/* Ethernet Ports */
44#define GT96100_ETH_PHY_ADDR_REG 0x080800
45#define GT96100_ETH_SMI_REG 0x080810
46/*
47 These are offsets to port 0 registers. Add GT96100_ETH_IO_SIZE to
48 get offsets to port 1 registers.
49*/
50#define GT96100_ETH_PORT_CONFIG 0x084800
51#define GT96100_ETH_PORT_CONFIG_EXT 0x084808
52#define GT96100_ETH_PORT_COMM 0x084810
53#define GT96100_ETH_PORT_STATUS 0x084818
54#define GT96100_ETH_SER_PARAM 0x084820
55#define GT96100_ETH_HASH_TBL_PTR 0x084828
56#define GT96100_ETH_FLOW_CNTRL_SRC_ADDR_L 0x084830
57#define GT96100_ETH_FLOW_CNTRL_SRC_ADDR_H 0x084838
58#define GT96100_ETH_SDMA_CONFIG 0x084840
59#define GT96100_ETH_SDMA_COMM 0x084848
60#define GT96100_ETH_INT_CAUSE 0x084850
61#define GT96100_ETH_INT_MASK 0x084858
62#define GT96100_ETH_1ST_RX_DESC_PTR0 0x084880
63#define GT96100_ETH_1ST_RX_DESC_PTR1 0x084884
64#define GT96100_ETH_1ST_RX_DESC_PTR2 0x084888
65#define GT96100_ETH_1ST_RX_DESC_PTR3 0x08488C
66#define GT96100_ETH_CURR_RX_DESC_PTR0 0x0848A0
67#define GT96100_ETH_CURR_RX_DESC_PTR1 0x0848A4
68#define GT96100_ETH_CURR_RX_DESC_PTR2 0x0848A8
69#define GT96100_ETH_CURR_RX_DESC_PTR3 0x0848AC
70#define GT96100_ETH_CURR_TX_DESC_PTR0 0x0848E0
71#define GT96100_ETH_CURR_TX_DESC_PTR1 0x0848E4
72#define GT96100_ETH_MIB_COUNT_BASE 0x085800
73
74/* SDMAs */
75#define GT96100_SDMA_GROUP_CONFIG 0x101AF0
76/* SDMA Group 0 */
77#define GT96100_SDMA_G0_CHAN0_CONFIG 0x000900
78#define GT96100_SDMA_G0_CHAN0_COMM 0x000908
79#define GT96100_SDMA_G0_CHAN0_RX_DESC_BASE 0x008900
80#define GT96100_SDMA_G0_CHAN0_CURR_RX_DESC_PTR 0x008910
81#define GT96100_SDMA_G0_CHAN0_TX_DESC_BASE 0x00C900
82#define GT96100_SDMA_G0_CHAN0_CURR_TX_DESC_PTR 0x00C910
83#define GT96100_SDMA_G0_CHAN0_1ST_TX_DESC_PTR 0x00C914
84#define GT96100_SDMA_G0_CHAN1_CONFIG 0x010900
85#define GT96100_SDMA_G0_CHAN1_COMM 0x010908
86#define GT96100_SDMA_G0_CHAN1_RX_DESC_BASE 0x018900
87#define GT96100_SDMA_G0_CHAN1_CURR_RX_DESC_PTR 0x018910
88#define GT96100_SDMA_G0_CHAN1_TX_DESC_BASE 0x01C900
89#define GT96100_SDMA_G0_CHAN1_CURR_TX_DESC_PTR 0x01C910
90#define GT96100_SDMA_G0_CHAN1_1ST_TX_DESC_PTR 0x01C914
91#define GT96100_SDMA_G0_CHAN2_CONFIG 0x020900
92#define GT96100_SDMA_G0_CHAN2_COMM 0x020908
93#define GT96100_SDMA_G0_CHAN2_RX_DESC_BASE 0x028900
94#define GT96100_SDMA_G0_CHAN2_CURR_RX_DESC_PTR 0x028910
95#define GT96100_SDMA_G0_CHAN2_TX_DESC_BASE 0x02C900
96#define GT96100_SDMA_G0_CHAN2_CURR_TX_DESC_PTR 0x02C910
97#define GT96100_SDMA_G0_CHAN2_1ST_TX_DESC_PTR 0x02C914
98#define GT96100_SDMA_G0_CHAN3_CONFIG 0x030900
99#define GT96100_SDMA_G0_CHAN3_COMM 0x030908
100#define GT96100_SDMA_G0_CHAN3_RX_DESC_BASE 0x038900
101#define GT96100_SDMA_G0_CHAN3_CURR_RX_DESC_PTR 0x038910
102#define GT96100_SDMA_G0_CHAN3_TX_DESC_BASE 0x03C900
103#define GT96100_SDMA_G0_CHAN3_CURR_TX_DESC_PTR 0x03C910
104#define GT96100_SDMA_G0_CHAN3_1ST_TX_DESC_PTR 0x03C914
105#define GT96100_SDMA_G0_CHAN4_CONFIG 0x040900
106#define GT96100_SDMA_G0_CHAN4_COMM 0x040908
107#define GT96100_SDMA_G0_CHAN4_RX_DESC_BASE 0x048900
108#define GT96100_SDMA_G0_CHAN4_CURR_RX_DESC_PTR 0x048910
109#define GT96100_SDMA_G0_CHAN4_TX_DESC_BASE 0x04C900
110#define GT96100_SDMA_G0_CHAN4_CURR_TX_DESC_PTR 0x04C910
111#define GT96100_SDMA_G0_CHAN4_1ST_TX_DESC_PTR 0x04C914
112#define GT96100_SDMA_G0_CHAN5_CONFIG 0x050900
113#define GT96100_SDMA_G0_CHAN5_COMM 0x050908
114#define GT96100_SDMA_G0_CHAN5_RX_DESC_BASE 0x058900
115#define GT96100_SDMA_G0_CHAN5_CURR_RX_DESC_PTR 0x058910
116#define GT96100_SDMA_G0_CHAN5_TX_DESC_BASE 0x05C900
117#define GT96100_SDMA_G0_CHAN5_CURR_TX_DESC_PTR 0x05C910
118#define GT96100_SDMA_G0_CHAN5_1ST_TX_DESC_PTR 0x05C914
119#define GT96100_SDMA_G0_CHAN6_CONFIG 0x060900
120#define GT96100_SDMA_G0_CHAN6_COMM 0x060908
121#define GT96100_SDMA_G0_CHAN6_RX_DESC_BASE 0x068900
122#define GT96100_SDMA_G0_CHAN6_CURR_RX_DESC_PTR 0x068910
123#define GT96100_SDMA_G0_CHAN6_TX_DESC_BASE 0x06C900
124#define GT96100_SDMA_G0_CHAN6_CURR_TX_DESC_PTR 0x06C910
125#define GT96100_SDMA_G0_CHAN6_1ST_TX_DESC_PTR 0x06C914
126#define GT96100_SDMA_G0_CHAN7_CONFIG 0x070900
127#define GT96100_SDMA_G0_CHAN7_COMM 0x070908
128#define GT96100_SDMA_G0_CHAN7_RX_DESC_BASE 0x078900
129#define GT96100_SDMA_G0_CHAN7_CURR_RX_DESC_PTR 0x078910
130#define GT96100_SDMA_G0_CHAN7_TX_DESC_BASE 0x07C900
131#define GT96100_SDMA_G0_CHAN7_CURR_TX_DESC_PTR 0x07C910
132#define GT96100_SDMA_G0_CHAN7_1ST_TX_DESC_PTR 0x07C914
133/* SDMA Group 1 */
134#define GT96100_SDMA_G1_CHAN0_CONFIG 0x100900
135#define GT96100_SDMA_G1_CHAN0_COMM 0x100908
136#define GT96100_SDMA_G1_CHAN0_RX_DESC_BASE 0x108900
137#define GT96100_SDMA_G1_CHAN0_CURR_RX_DESC_PTR 0x108910
138#define GT96100_SDMA_G1_CHAN0_TX_DESC_BASE 0x10C900
139#define GT96100_SDMA_G1_CHAN0_CURR_TX_DESC_PTR 0x10C910
140#define GT96100_SDMA_G1_CHAN0_1ST_TX_DESC_PTR 0x10C914
141#define GT96100_SDMA_G1_CHAN1_CONFIG 0x110900
142#define GT96100_SDMA_G1_CHAN1_COMM 0x110908
143#define GT96100_SDMA_G1_CHAN1_RX_DESC_BASE 0x118900
144#define GT96100_SDMA_G1_CHAN1_CURR_RX_DESC_PTR 0x118910
145#define GT96100_SDMA_G1_CHAN1_TX_DESC_BASE 0x11C900
146#define GT96100_SDMA_G1_CHAN1_CURR_TX_DESC_PTR 0x11C910
147#define GT96100_SDMA_G1_CHAN1_1ST_TX_DESC_PTR 0x11C914
148#define GT96100_SDMA_G1_CHAN2_CONFIG 0x120900
149#define GT96100_SDMA_G1_CHAN2_COMM 0x120908
150#define GT96100_SDMA_G1_CHAN2_RX_DESC_BASE 0x128900
151#define GT96100_SDMA_G1_CHAN2_CURR_RX_DESC_PTR 0x128910
152#define GT96100_SDMA_G1_CHAN2_TX_DESC_BASE 0x12C900
153#define GT96100_SDMA_G1_CHAN2_CURR_TX_DESC_PTR 0x12C910
154#define GT96100_SDMA_G1_CHAN2_1ST_TX_DESC_PTR 0x12C914
155#define GT96100_SDMA_G1_CHAN3_CONFIG 0x130900
156#define GT96100_SDMA_G1_CHAN3_COMM 0x130908
157#define GT96100_SDMA_G1_CHAN3_RX_DESC_BASE 0x138900
158#define GT96100_SDMA_G1_CHAN3_CURR_RX_DESC_PTR 0x138910
159#define GT96100_SDMA_G1_CHAN3_TX_DESC_BASE 0x13C900
160#define GT96100_SDMA_G1_CHAN3_CURR_TX_DESC_PTR 0x13C910
161#define GT96100_SDMA_G1_CHAN3_1ST_TX_DESC_PTR 0x13C914
162#define GT96100_SDMA_G1_CHAN4_CONFIG 0x140900
163#define GT96100_SDMA_G1_CHAN4_COMM 0x140908
164#define GT96100_SDMA_G1_CHAN4_RX_DESC_BASE 0x148900
165#define GT96100_SDMA_G1_CHAN4_CURR_RX_DESC_PTR 0x148910
166#define GT96100_SDMA_G1_CHAN4_TX_DESC_BASE 0x14C900
167#define GT96100_SDMA_G1_CHAN4_CURR_TX_DESC_PTR 0x14C910
168#define GT96100_SDMA_G1_CHAN4_1ST_TX_DESC_PTR 0x14C914
169#define GT96100_SDMA_G1_CHAN5_CONFIG 0x150900
170#define GT96100_SDMA_G1_CHAN5_COMM 0x150908
171#define GT96100_SDMA_G1_CHAN5_RX_DESC_BASE 0x158900
172#define GT96100_SDMA_G1_CHAN5_CURR_RX_DESC_PTR 0x158910
173#define GT96100_SDMA_G1_CHAN5_TX_DESC_BASE 0x15C900
174#define GT96100_SDMA_G1_CHAN5_CURR_TX_DESC_PTR 0x15C910
175#define GT96100_SDMA_G1_CHAN5_1ST_TX_DESC_PTR 0x15C914
176#define GT96100_SDMA_G1_CHAN6_CONFIG 0x160900
177#define GT96100_SDMA_G1_CHAN6_COMM 0x160908
178#define GT96100_SDMA_G1_CHAN6_RX_DESC_BASE 0x168900
179#define GT96100_SDMA_G1_CHAN6_CURR_RX_DESC_PTR 0x168910
180#define GT96100_SDMA_G1_CHAN6_TX_DESC_BASE 0x16C900
181#define GT96100_SDMA_G1_CHAN6_CURR_TX_DESC_PTR 0x16C910
182#define GT96100_SDMA_G1_CHAN6_1ST_TX_DESC_PTR 0x16C914
183#define GT96100_SDMA_G1_CHAN7_CONFIG 0x170900
184#define GT96100_SDMA_G1_CHAN7_COMM 0x170908
185#define GT96100_SDMA_G1_CHAN7_RX_DESC_BASE 0x178900
186#define GT96100_SDMA_G1_CHAN7_CURR_RX_DESC_PTR 0x178910
187#define GT96100_SDMA_G1_CHAN7_TX_DESC_BASE 0x17C900
188#define GT96100_SDMA_G1_CHAN7_CURR_TX_DESC_PTR 0x17C910
189#define GT96100_SDMA_G1_CHAN7_1ST_TX_DESC_PTR 0x17C914
190/* MPSCs */
191#define GT96100_MPSC0_MAIN_CONFIG_LOW 0x000A00
192#define GT96100_MPSC0_MAIN_CONFIG_HIGH 0x000A04
193#define GT96100_MPSC0_PROTOCOL_CONFIG 0x000A08
194#define GT96100_MPSC_CHAN0_REG1 0x000A0C
195#define GT96100_MPSC_CHAN0_REG2 0x000A10
196#define GT96100_MPSC_CHAN0_REG3 0x000A14
197#define GT96100_MPSC_CHAN0_REG4 0x000A18
198#define GT96100_MPSC_CHAN0_REG5 0x000A1C
199#define GT96100_MPSC_CHAN0_REG6 0x000A20
200#define GT96100_MPSC_CHAN0_REG7 0x000A24
201#define GT96100_MPSC_CHAN0_REG8 0x000A28
202#define GT96100_MPSC_CHAN0_REG9 0x000A2C
203#define GT96100_MPSC_CHAN0_REG10 0x000A30
204#define GT96100_MPSC_CHAN0_REG11 0x000A34
205#define GT96100_MPSC1_MAIN_CONFIG_LOW 0x008A00
206#define GT96100_MPSC1_MAIN_CONFIG_HIGH 0x008A04
207#define GT96100_MPSC1_PROTOCOL_CONFIG 0x008A08
208#define GT96100_MPSC_CHAN1_REG1 0x008A0C
209#define GT96100_MPSC_CHAN1_REG2 0x008A10
210#define GT96100_MPSC_CHAN1_REG3 0x008A14
211#define GT96100_MPSC_CHAN1_REG4 0x008A18
212#define GT96100_MPSC_CHAN1_REG5 0x008A1C
213#define GT96100_MPSC_CHAN1_REG6 0x008A20
214#define GT96100_MPSC_CHAN1_REG7 0x008A24
215#define GT96100_MPSC_CHAN1_REG8 0x008A28
216#define GT96100_MPSC_CHAN1_REG9 0x008A2C
217#define GT96100_MPSC_CHAN1_REG10 0x008A30
218#define GT96100_MPSC_CHAN1_REG11 0x008A34
219#define GT96100_MPSC2_MAIN_CONFIG_LOW 0x010A00
220#define GT96100_MPSC2_MAIN_CONFIG_HIGH 0x010A04
221#define GT96100_MPSC2_PROTOCOL_CONFIG 0x010A08
222#define GT96100_MPSC_CHAN2_REG1 0x010A0C
223#define GT96100_MPSC_CHAN2_REG2 0x010A10
224#define GT96100_MPSC_CHAN2_REG3 0x010A14
225#define GT96100_MPSC_CHAN2_REG4 0x010A18
226#define GT96100_MPSC_CHAN2_REG5 0x010A1C
227#define GT96100_MPSC_CHAN2_REG6 0x010A20
228#define GT96100_MPSC_CHAN2_REG7 0x010A24
229#define GT96100_MPSC_CHAN2_REG8 0x010A28
230#define GT96100_MPSC_CHAN2_REG9 0x010A2C
231#define GT96100_MPSC_CHAN2_REG10 0x010A30
232#define GT96100_MPSC_CHAN2_REG11 0x010A34
233#define GT96100_MPSC3_MAIN_CONFIG_LOW 0x018A00
234#define GT96100_MPSC3_MAIN_CONFIG_HIGH 0x018A04
235#define GT96100_MPSC3_PROTOCOL_CONFIG 0x018A08
236#define GT96100_MPSC_CHAN3_REG1 0x018A0C
237#define GT96100_MPSC_CHAN3_REG2 0x018A10
238#define GT96100_MPSC_CHAN3_REG3 0x018A14
239#define GT96100_MPSC_CHAN3_REG4 0x018A18
240#define GT96100_MPSC_CHAN3_REG5 0x018A1C
241#define GT96100_MPSC_CHAN3_REG6 0x018A20
242#define GT96100_MPSC_CHAN3_REG7 0x018A24
243#define GT96100_MPSC_CHAN3_REG8 0x018A28
244#define GT96100_MPSC_CHAN3_REG9 0x018A2C
245#define GT96100_MPSC_CHAN3_REG10 0x018A30
246#define GT96100_MPSC_CHAN3_REG11 0x018A34
247#define GT96100_MPSC4_MAIN_CONFIG_LOW 0x020A00
248#define GT96100_MPSC4_MAIN_CONFIG_HIGH 0x020A04
249#define GT96100_MPSC4_PROTOCOL_CONFIG 0x020A08
250#define GT96100_MPSC_CHAN4_REG1 0x020A0C
251#define GT96100_MPSC_CHAN4_REG2 0x020A10
252#define GT96100_MPSC_CHAN4_REG3 0x020A14
253#define GT96100_MPSC_CHAN4_REG4 0x020A18
254#define GT96100_MPSC_CHAN4_REG5 0x020A1C
255#define GT96100_MPSC_CHAN4_REG6 0x020A20
256#define GT96100_MPSC_CHAN4_REG7 0x020A24
257#define GT96100_MPSC_CHAN4_REG8 0x020A28
258#define GT96100_MPSC_CHAN4_REG9 0x020A2C
259#define GT96100_MPSC_CHAN4_REG10 0x020A30
260#define GT96100_MPSC_CHAN4_REG11 0x020A34
261#define GT96100_MPSC5_MAIN_CONFIG_LOW 0x028A00
262#define GT96100_MPSC5_MAIN_CONFIG_HIGH 0x028A04
263#define GT96100_MPSC5_PROTOCOL_CONFIG 0x028A08
264#define GT96100_MPSC_CHAN5_REG1 0x028A0C
265#define GT96100_MPSC_CHAN5_REG2 0x028A10
266#define GT96100_MPSC_CHAN5_REG3 0x028A14
267#define GT96100_MPSC_CHAN5_REG4 0x028A18
268#define GT96100_MPSC_CHAN5_REG5 0x028A1C
269#define GT96100_MPSC_CHAN5_REG6 0x028A20
270#define GT96100_MPSC_CHAN5_REG7 0x028A24
271#define GT96100_MPSC_CHAN5_REG8 0x028A28
272#define GT96100_MPSC_CHAN5_REG9 0x028A2C
273#define GT96100_MPSC_CHAN5_REG10 0x028A30
274#define GT96100_MPSC_CHAN5_REG11 0x028A34
275#define GT96100_MPSC6_MAIN_CONFIG_LOW 0x030A00
276#define GT96100_MPSC6_MAIN_CONFIG_HIGH 0x030A04
277#define GT96100_MPSC6_PROTOCOL_CONFIG 0x030A08
278#define GT96100_MPSC_CHAN6_REG1 0x030A0C
279#define GT96100_MPSC_CHAN6_REG2 0x030A10
280#define GT96100_MPSC_CHAN6_REG3 0x030A14
281#define GT96100_MPSC_CHAN6_REG4 0x030A18
282#define GT96100_MPSC_CHAN6_REG5 0x030A1C
283#define GT96100_MPSC_CHAN6_REG6 0x030A20
284#define GT96100_MPSC_CHAN6_REG7 0x030A24
285#define GT96100_MPSC_CHAN6_REG8 0x030A28
286#define GT96100_MPSC_CHAN6_REG9 0x030A2C
287#define GT96100_MPSC_CHAN6_REG10 0x030A30
288#define GT96100_MPSC_CHAN6_REG11 0x030A34
289#define GT96100_MPSC7_MAIN_CONFIG_LOW 0x038A00
290#define GT96100_MPSC7_MAIN_CONFIG_HIGH 0x038A04
291#define GT96100_MPSC7_PROTOCOL_CONFIG 0x038A08
292#define GT96100_MPSC_CHAN7_REG1 0x038A0C
293#define GT96100_MPSC_CHAN7_REG2 0x038A10
294#define GT96100_MPSC_CHAN7_REG3 0x038A14
295#define GT96100_MPSC_CHAN7_REG4 0x038A18
296#define GT96100_MPSC_CHAN7_REG5 0x038A1C
297#define GT96100_MPSC_CHAN7_REG6 0x038A20
298#define GT96100_MPSC_CHAN7_REG7 0x038A24
299#define GT96100_MPSC_CHAN7_REG8 0x038A28
300#define GT96100_MPSC_CHAN7_REG9 0x038A2C
301#define GT96100_MPSC_CHAN7_REG10 0x038A30
302#define GT96100_MPSC_CHAN7_REG11 0x038A34
303/* FlexTDMs */
304/* TDPR0 - Transmit Dual Port RAM. block size 0xff */
305#define GT96100_FXTDM0_TDPR0_BLK0_BASE 0x000B00
306#define GT96100_FXTDM0_TDPR0_BLK1_BASE 0x001B00
307#define GT96100_FXTDM0_TDPR0_BLK2_BASE 0x002B00
308#define GT96100_FXTDM0_TDPR0_BLK3_BASE 0x003B00
309/* RDPR0 - Receive Dual Port RAM. block size 0xff */
310#define GT96100_FXTDM0_RDPR0_BLK0_BASE 0x004B00
311#define GT96100_FXTDM0_RDPR0_BLK1_BASE 0x005B00
312#define GT96100_FXTDM0_RDPR0_BLK2_BASE 0x006B00
313#define GT96100_FXTDM0_RDPR0_BLK3_BASE 0x007B00
314#define GT96100_FXTDM0_TX_READ_PTR 0x008B00
315#define GT96100_FXTDM0_RX_READ_PTR 0x008B04
316#define GT96100_FXTDM0_CONFIG 0x008B08
317#define GT96100_FXTDM0_AUX_CHANA_TX 0x008B0C
318#define GT96100_FXTDM0_AUX_CHANA_RX 0x008B10
319#define GT96100_FXTDM0_AUX_CHANB_TX 0x008B14
320#define GT96100_FXTDM0_AUX_CHANB_RX 0x008B18
321#define GT96100_FXTDM1_TDPR1_BLK0_BASE 0x010B00
322#define GT96100_FXTDM1_TDPR1_BLK1_BASE 0x011B00
323#define GT96100_FXTDM1_TDPR1_BLK2_BASE 0x012B00
324#define GT96100_FXTDM1_TDPR1_BLK3_BASE 0x013B00
325#define GT96100_FXTDM1_RDPR1_BLK0_BASE 0x014B00
326#define GT96100_FXTDM1_RDPR1_BLK1_BASE 0x015B00
327#define GT96100_FXTDM1_RDPR1_BLK2_BASE 0x016B00
328#define GT96100_FXTDM1_RDPR1_BLK3_BASE 0x017B00
329#define GT96100_FXTDM1_TX_READ_PTR 0x018B00
330#define GT96100_FXTDM1_RX_READ_PTR 0x018B04
331#define GT96100_FXTDM1_CONFIG 0x018B08
332#define GT96100_FXTDM1_AUX_CHANA_TX 0x018B0C
333#define GT96100_FXTDM1_AUX_CHANA_RX 0x018B10
334#define GT96100_FLTDM1_AUX_CHANB_TX 0x018B14
335#define GT96100_FLTDM1_AUX_CHANB_RX 0x018B18
336#define GT96100_FLTDM2_TDPR2_BLK0_BASE 0x020B00
337#define GT96100_FLTDM2_TDPR2_BLK1_BASE 0x021B00
338#define GT96100_FLTDM2_TDPR2_BLK2_BASE 0x022B00
339#define GT96100_FLTDM2_TDPR2_BLK3_BASE 0x023B00
340#define GT96100_FLTDM2_RDPR2_BLK0_BASE 0x024B00
341#define GT96100_FLTDM2_RDPR2_BLK1_BASE 0x025B00
342#define GT96100_FLTDM2_RDPR2_BLK2_BASE 0x026B00
343#define GT96100_FLTDM2_RDPR2_BLK3_BASE 0x027B00
344#define GT96100_FLTDM2_TX_READ_PTR 0x028B00
345#define GT96100_FLTDM2_RX_READ_PTR 0x028B04
346#define GT96100_FLTDM2_CONFIG 0x028B08
347#define GT96100_FLTDM2_AUX_CHANA_TX 0x028B0C
348#define GT96100_FLTDM2_AUX_CHANA_RX 0x028B10
349#define GT96100_FLTDM2_AUX_CHANB_TX 0x028B14
350#define GT96100_FLTDM2_AUX_CHANB_RX 0x028B18
351#define GT96100_FLTDM3_TDPR3_BLK0_BASE 0x030B00
352#define GT96100_FLTDM3_TDPR3_BLK1_BASE 0x031B00
353#define GT96100_FLTDM3_TDPR3_BLK2_BASE 0x032B00
354#define GT96100_FLTDM3_TDPR3_BLK3_BASE 0x033B00
355#define GT96100_FXTDM3_RDPR3_BLK0_BASE 0x034B00
356#define GT96100_FXTDM3_RDPR3_BLK1_BASE 0x035B00
357#define GT96100_FXTDM3_RDPR3_BLK2_BASE 0x036B00
358#define GT96100_FXTDM3_RDPR3_BLK3_BASE 0x037B00
359#define GT96100_FXTDM3_TX_READ_PTR 0x038B00
360#define GT96100_FXTDM3_RX_READ_PTR 0x038B04
361#define GT96100_FXTDM3_CONFIG 0x038B08
362#define GT96100_FXTDM3_AUX_CHANA_TX 0x038B0C
363#define GT96100_FXTDM3_AUX_CHANA_RX 0x038B10
364#define GT96100_FXTDM3_AUX_CHANB_TX 0x038B14
365#define GT96100_FXTDM3_AUX_CHANB_RX 0x038B18
366/* Baud Rate Generators */
367#define GT96100_BRG0_CONFIG 0x102A00
368#define GT96100_BRG0_BAUD_TUNE 0x102A04
369#define GT96100_BRG1_CONFIG 0x102A08
370#define GT96100_BRG1_BAUD_TUNE 0x102A0C
371#define GT96100_BRG2_CONFIG 0x102A10
372#define GT96100_BRG2_BAUD_TUNE 0x102A14
373#define GT96100_BRG3_CONFIG 0x102A18
374#define GT96100_BRG3_BAUD_TUNE 0x102A1C
375#define GT96100_BRG4_CONFIG 0x102A20
376#define GT96100_BRG4_BAUD_TUNE 0x102A24
377#define GT96100_BRG5_CONFIG 0x102A28
378#define GT96100_BRG5_BAUD_TUNE 0x102A2C
379#define GT96100_BRG6_CONFIG 0x102A30
380#define GT96100_BRG6_BAUD_TUNE 0x102A34
381#define GT96100_BRG7_CONFIG 0x102A38
382#define GT96100_BRG7_BAUD_TUNE 0x102A3C
383/* Routing Registers */
384#define GT96100_ROUTE_MAIN 0x101A00
385#define GT96100_ROUTE_RX_CLOCK 0x101A10
386#define GT96100_ROUTE_TX_CLOCK 0x101A20
387/* General Purpose Ports */
388#define GT96100_GPP_CONFIG0 0x100A00
389#define GT96100_GPP_CONFIG1 0x100A04
390#define GT96100_GPP_CONFIG2 0x100A08
391#define GT96100_GPP_CONFIG3 0x100A0C
392#define GT96100_GPP_IO0 0x100A20
393#define GT96100_GPP_IO1 0x100A24
394#define GT96100_GPP_IO2 0x100A28
395#define GT96100_GPP_IO3 0x100A2C
396#define GT96100_GPP_DATA0 0x100A40
397#define GT96100_GPP_DATA1 0x100A44
398#define GT96100_GPP_DATA2 0x100A48
399#define GT96100_GPP_DATA3 0x100A4C
400#define GT96100_GPP_LEVEL0 0x100A60
401#define GT96100_GPP_LEVEL1 0x100A64
402#define GT96100_GPP_LEVEL2 0x100A68
403#define GT96100_GPP_LEVEL3 0x100A6C
404/* Watchdog */
405#define GT96100_WD_CONFIG 0x101A80
406#define GT96100_WD_VALUE 0x101A84
407/* Communication Unit Arbiter */
408#define GT96100_COMM_UNIT_ARBTR_CONFIG 0x101AC0
409/* PCI Arbiters */
410#define GT96100_PCI0_ARBTR_CONFIG 0x101AE0
411#define GT96100_PCI1_ARBTR_CONFIG 0x101AE4
412/* CIU Arbiter */
413#define GT96100_CIU_ARBITER_CONFIG 0x101AC0
414/* Interrupt Controller */
415#define GT96100_MAIN_CAUSE 0x000C18
416#define GT96100_INT0_MAIN_MASK 0x000C1C
417#define GT96100_INT1_MAIN_MASK 0x000C24
418#define GT96100_HIGH_CAUSE 0x000C98
419#define GT96100_INT0_HIGH_MASK 0x000C9C
420#define GT96100_INT1_HIGH_MASK 0x000CA4
421#define GT96100_INT0_SELECT 0x000C70
422#define GT96100_INT1_SELECT 0x000C74
423#define GT96100_SERIAL_CAUSE 0x103A00
424#define GT96100_SERINT0_MASK 0x103A80
425#define GT96100_SERINT1_MASK 0x103A88
426
427#endif /* _GT96100_H */
diff --git a/include/asm-mips/hazards.h b/include/asm-mips/hazards.h
index 25f5e8a4177d..0fe02945feba 100644
--- a/include/asm-mips/hazards.h
+++ b/include/asm-mips/hazards.h
@@ -12,102 +12,95 @@
12 12
13 13
14#ifdef __ASSEMBLY__ 14#ifdef __ASSEMBLY__
15 15#define ASMMACRO(name, code...) .macro name; code; .endm
16 .macro _ssnop
17 sll $0, $0, 1
18 .endm
19
20 .macro _ehb
21 sll $0, $0, 3
22 .endm
23
24/*
25 * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent
26 * use of the JTLB for instructions should not occur for 4 cpu cycles and use
27 * for data translations should not occur for 3 cpu cycles.
28 */
29#ifdef CONFIG_CPU_RM9000
30
31 .macro mtc0_tlbw_hazard
32 .set push
33 .set mips32
34 _ssnop; _ssnop; _ssnop; _ssnop
35 .set pop
36 .endm
37
38 .macro tlbw_eret_hazard
39 .set push
40 .set mips32
41 _ssnop; _ssnop; _ssnop; _ssnop
42 .set pop
43 .endm
44
45#else 16#else
46 17
47/* 18#define ASMMACRO(name, code...) \
48 * The taken branch will result in a two cycle penalty for the two killed 19__asm__(".macro " #name "; " #code "; .endm"); \
49 * instructions on R4000 / R4400. Other processors only have a single cycle 20 \
50 * hazard so this is nice trick to have an optimal code for a range of 21static inline void name(void) \
51 * processors. 22{ \
52 */ 23 __asm__ __volatile__ (#name); \
53 .macro mtc0_tlbw_hazard 24}
54 b . + 8
55 .endm
56 25
57 .macro tlbw_eret_hazard
58 .endm
59#endif 26#endif
60 27
28ASMMACRO(_ssnop,
29 sll $0, $0, 1
30 )
31
32ASMMACRO(_ehb,
33 sll $0, $0, 3
34 )
35
61/* 36/*
62 * mtc0->mfc0 hazard 37 * TLB hazards
63 * The 24K has a 2 cycle mtc0/mfc0 execution hazard.
64 * It is a MIPS32R2 processor so ehb will clear the hazard.
65 */ 38 */
39#if defined(CONFIG_CPU_MIPSR2)
66 40
67#ifdef CONFIG_CPU_MIPSR2
68/* 41/*
69 * Use a macro for ehb unless explicit support for MIPSR2 is enabled 42 * MIPSR2 defines ehb for hazard avoidance
70 */ 43 */
71 44
72#define irq_enable_hazard \ 45ASMMACRO(mtc0_tlbw_hazard,
46 _ehb
47 )
48ASMMACRO(tlbw_use_hazard,
49 _ehb
50 )
51ASMMACRO(tlb_probe_hazard,
52 _ehb
53 )
54ASMMACRO(irq_enable_hazard,
55 )
56ASMMACRO(irq_disable_hazard,
73 _ehb 57 _ehb
74 58 )
75#define irq_disable_hazard \ 59ASMMACRO(back_to_back_c0_hazard,
76 _ehb 60 _ehb
77 61 )
78#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000)
79
80/* 62/*
81 * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. 63 * gcc has a tradition of misscompiling the previous construct using the
64 * address of a label as argument to inline assembler. Gas otoh has the
65 * annoying difference between la and dla which are only usable for 32-bit
66 * rsp. 64-bit code, so can't be used without conditional compilation.
67 * The alterantive is switching the assembler to 64-bit code which happens
68 * to work right even for 32-bit code ...
82 */ 69 */
70#define instruction_hazard() \
71do { \
72 unsigned long tmp; \
73 \
74 __asm__ __volatile__( \
75 " .set mips64r2 \n" \
76 " dla %0, 1f \n" \
77 " jr.hb %0 \n" \
78 " .set mips0 \n" \
79 "1: \n" \
80 : "=r" (tmp)); \
81} while (0)
83 82
84#define irq_enable_hazard 83#elif defined(CONFIG_CPU_R10000)
85
86#define irq_disable_hazard
87
88#else
89 84
90/* 85/*
91 * Classic MIPS needs 1 - 3 nops or ssnops 86 * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer.
92 */ 87 */
93#define irq_enable_hazard
94#define irq_disable_hazard \
95 _ssnop; _ssnop; _ssnop
96 88
97#endif 89ASMMACRO(mtc0_tlbw_hazard,
98 90 )
99#else /* __ASSEMBLY__ */ 91ASMMACRO(tlbw_use_hazard,
100 92 )
101__asm__( 93ASMMACRO(tlb_probe_hazard,
102 " .macro _ssnop \n" 94 )
103 " sll $0, $0, 1 \n" 95ASMMACRO(irq_enable_hazard,
104 " .endm \n" 96 )
105 " \n" 97ASMMACRO(irq_disable_hazard,
106 " .macro _ehb \n" 98 )
107 " sll $0, $0, 3 \n" 99ASMMACRO(back_to_back_c0_hazard,
108 " .endm \n"); 100 )
101#define instruction_hazard() do { } while (0)
109 102
110#ifdef CONFIG_CPU_RM9000 103#elif defined(CONFIG_CPU_RM9000)
111 104
112/* 105/*
113 * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent 106 * RM9000 hazards. When the JTLB is updated by tlbwi or tlbwr, a subsequent
@@ -115,176 +108,73 @@ __asm__(
115 * for data translations should not occur for 3 cpu cycles. 108 * for data translations should not occur for 3 cpu cycles.
116 */ 109 */
117 110
118#define mtc0_tlbw_hazard() \ 111ASMMACRO(mtc0_tlbw_hazard,
119 __asm__ __volatile__( \ 112 _ssnop; _ssnop; _ssnop; _ssnop
120 " .set mips32 \n" \ 113 )
121 " _ssnop \n" \ 114ASMMACRO(tlbw_use_hazard,
122 " _ssnop \n" \ 115 _ssnop; _ssnop; _ssnop; _ssnop
123 " _ssnop \n" \ 116 )
124 " _ssnop \n" \ 117ASMMACRO(tlb_probe_hazard,
125 " .set mips0 \n") 118 _ssnop; _ssnop; _ssnop; _ssnop
126 119 )
127#define tlbw_use_hazard() \ 120ASMMACRO(irq_enable_hazard,
128 __asm__ __volatile__( \ 121 )
129 " .set mips32 \n" \ 122ASMMACRO(irq_disable_hazard,
130 " _ssnop \n" \ 123 )
131 " _ssnop \n" \ 124ASMMACRO(back_to_back_c0_hazard,
132 " _ssnop \n" \ 125 )
133 " _ssnop \n" \ 126#define instruction_hazard() do { } while (0)
134 " .set mips0 \n")
135
136#else
137
138/*
139 * Overkill warning ...
140 */
141#define mtc0_tlbw_hazard() \
142 __asm__ __volatile__( \
143 " .set noreorder \n" \
144 " nop \n" \
145 " nop \n" \
146 " nop \n" \
147 " nop \n" \
148 " nop \n" \
149 " nop \n" \
150 " .set reorder \n")
151
152#define tlbw_use_hazard() \
153 __asm__ __volatile__( \
154 " .set noreorder \n" \
155 " nop \n" \
156 " nop \n" \
157 " nop \n" \
158 " nop \n" \
159 " nop \n" \
160 " nop \n" \
161 " .set reorder \n")
162
163#endif
164
165/*
166 * Interrupt enable/disable hazards
167 * Some processors have hazards when modifying
168 * the status register to change the interrupt state
169 */
170
171#ifdef CONFIG_CPU_MIPSR2
172
173__asm__(" .macro irq_enable_hazard \n"
174 " _ehb \n"
175 " .endm \n"
176 " \n"
177 " .macro irq_disable_hazard \n"
178 " _ehb \n"
179 " .endm \n");
180 127
181#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) 128#elif defined(CONFIG_CPU_SB1)
182 129
183/* 130/*
184 * R10000 rocks - all hazards handled in hardware, so this becomes a nobrainer. 131 * Mostly like R4000 for historic reasons
185 */ 132 */
186 133ASMMACRO(mtc0_tlbw_hazard,
187__asm__( 134 )
188 " .macro irq_enable_hazard \n" 135ASMMACRO(tlbw_use_hazard,
189 " .endm \n" 136 )
190 " \n" 137ASMMACRO(tlb_probe_hazard,
191 " .macro irq_disable_hazard \n" 138 )
192 " .endm \n"); 139ASMMACRO(irq_enable_hazard,
140 )
141ASMMACRO(irq_disable_hazard,
142 _ssnop; _ssnop; _ssnop
143 )
144ASMMACRO(back_to_back_c0_hazard,
145 )
146#define instruction_hazard() do { } while (0)
193 147
194#else 148#else
195 149
196/* 150/*
197 * Default for classic MIPS processors. Assume worst case hazards but don't 151 * Finally the catchall case for all other processors including R4000, R4400,
198 * care about the irq_enable_hazard - sooner or later the hardware will 152 * R4600, R4700, R5000, RM7000, NEC VR41xx etc.
199 * enable it and we don't care when exactly.
200 */
201
202__asm__(
203 " # \n"
204 " # There is a hazard but we do not care \n"
205 " # \n"
206 " .macro\tirq_enable_hazard \n"
207 " .endm \n"
208 " \n"
209 " .macro\tirq_disable_hazard \n"
210 " _ssnop \n"
211 " _ssnop \n"
212 " _ssnop \n"
213 " .endm \n");
214
215#endif
216
217#define irq_enable_hazard() \
218 __asm__ __volatile__("irq_enable_hazard")
219#define irq_disable_hazard() \
220 __asm__ __volatile__("irq_disable_hazard")
221
222
223/*
224 * Back-to-back hazards -
225 * 153 *
226 * What is needed to separate a move to cp0 from a subsequent read from the 154 * The taken branch will result in a two cycle penalty for the two killed
227 * same cp0 register? 155 * instructions on R4000 / R4400. Other processors only have a single cycle
228 */ 156 * hazard so this is nice trick to have an optimal code for a range of
229#ifdef CONFIG_CPU_MIPSR2 157 * processors.
230
231__asm__(" .macro back_to_back_c0_hazard \n"
232 " _ehb \n"
233 " .endm \n");
234
235#elif defined(CONFIG_CPU_R10000) || defined(CONFIG_CPU_RM9000) || \
236 defined(CONFIG_CPU_SB1)
237
238__asm__(" .macro back_to_back_c0_hazard \n"
239 " .endm \n");
240
241#else
242
243__asm__(" .macro back_to_back_c0_hazard \n"
244 " .set noreorder \n"
245 " _ssnop \n"
246 " _ssnop \n"
247 " _ssnop \n"
248 " .set reorder \n"
249 " .endm");
250
251#endif
252
253#define back_to_back_c0_hazard() \
254 __asm__ __volatile__("back_to_back_c0_hazard")
255
256
257/*
258 * Instruction execution hazard
259 */
260#ifdef CONFIG_CPU_MIPSR2
261/*
262 * gcc has a tradition of misscompiling the previous construct using the
263 * address of a label as argument to inline assembler. Gas otoh has the
264 * annoying difference between la and dla which are only usable for 32-bit
265 * rsp. 64-bit code, so can't be used without conditional compilation.
266 * The alterantive is switching the assembler to 64-bit code which happens
267 * to work right even for 32-bit code ...
268 */ 158 */
269#define instruction_hazard() \ 159ASMMACRO(mtc0_tlbw_hazard,
270do { \ 160 nop
271 unsigned long tmp; \ 161 )
272 \ 162ASMMACRO(tlbw_use_hazard,
273 __asm__ __volatile__( \ 163 nop; nop; nop
274 " .set mips64r2 \n" \ 164 )
275 " dla %0, 1f \n" \ 165ASMMACRO(tlb_probe_hazard,
276 " jr.hb %0 \n" \ 166 nop; nop; nop
277 " .set mips0 \n" \ 167 )
278 "1: \n" \ 168ASMMACRO(irq_enable_hazard,
279 : "=r" (tmp)); \ 169 )
280} while (0) 170ASMMACRO(irq_disable_hazard,
281 171 nop; nop; nop
282#else 172 )
173ASMMACRO(back_to_back_c0_hazard,
174 _ssnop; _ssnop; _ssnop;
175 )
283#define instruction_hazard() do { } while (0) 176#define instruction_hazard() do { } while (0)
284#endif
285
286extern void mips_ihb(void);
287 177
288#endif /* __ASSEMBLY__ */ 178#endif
289 179
290#endif /* _ASM_HAZARDS_H */ 180#endif /* _ASM_HAZARDS_H */
diff --git a/include/asm-mips/irq.h b/include/asm-mips/irq.h
index 896550bad322..d35c61776a02 100644
--- a/include/asm-mips/irq.h
+++ b/include/asm-mips/irq.h
@@ -76,8 +76,4 @@ extern int setup_irq_smtc(unsigned int irq, struct irqaction * new,
76 unsigned long hwmask); 76 unsigned long hwmask);
77#endif /* CONFIG_MIPS_MT_SMTC */ 77#endif /* CONFIG_MIPS_MT_SMTC */
78 78
79#ifdef CONFIG_SMP
80#define ARCH_HAS_IRQ_PER_CPU
81#endif
82
83#endif /* _ASM_IRQ_H */ 79#endif /* _ASM_IRQ_H */
diff --git a/include/asm-mips/mach-atlas/mc146818rtc.h b/include/asm-mips/mach-atlas/mc146818rtc.h
index 397522ea5565..a73a5698420c 100644
--- a/include/asm-mips/mach-atlas/mc146818rtc.h
+++ b/include/asm-mips/mach-atlas/mc146818rtc.h
@@ -28,10 +28,12 @@
28#include <asm/mips-boards/atlas.h> 28#include <asm/mips-boards/atlas.h>
29#include <asm/mips-boards/atlasint.h> 29#include <asm/mips-boards/atlasint.h>
30 30
31#define ARCH_RTC_LOCATION
32
31#define RTC_PORT(x) (ATLAS_RTC_ADR_REG + (x) * 8) 33#define RTC_PORT(x) (ATLAS_RTC_ADR_REG + (x) * 8)
32#define RTC_IO_EXTENT 0x100 34#define RTC_IO_EXTENT 0x100
33#define RTC_IOMAPPED 0 35#define RTC_IOMAPPED 0
34#define RTC_IRQ ATLASINT_RTC 36#define RTC_IRQ ATLAS_INT_RTC
35 37
36static inline unsigned char CMOS_READ(unsigned long addr) 38static inline unsigned char CMOS_READ(unsigned long addr)
37{ 39{
diff --git a/include/asm-mips/mach-ev96100/mach-gt64120.h b/include/asm-mips/mach-ev96100/mach-gt64120.h
deleted file mode 100644
index 0ef1e6c25acf..000000000000
--- a/include/asm-mips/mach-ev96100/mach-gt64120.h
+++ /dev/null
@@ -1,46 +0,0 @@
1/*
2 * This is a direct copy of the ev96100.h file, with a global
3 * search and replace. The numbers are the same.
4 *
5 * The reason I'm duplicating this is so that the 64120/96100
6 * defines won't be confusing in the source code.
7 */
8#ifndef _ASM_GT64120_EV96100_GT64120_DEP_H
9#define _ASM_GT64120_EV96100_GT64120_DEP_H
10
11/*
12 * GT96100 config space base address
13 */
14#define GT64120_BASE (KSEG1ADDR(0x14000000))
15
16/*
17 * PCI Bus allocation
18 *
19 * (Guessing ...)
20 */
21#define GT_PCI_MEM_BASE 0x12000000UL
22#define GT_PCI_MEM_SIZE 0x02000000UL
23#define GT_PCI_IO_BASE 0x10000000UL
24#define GT_PCI_IO_SIZE 0x02000000UL
25#define GT_ISA_IO_BASE PCI_IO_BASE
26
27/*
28 * Duart I/O ports.
29 */
30#define EV96100_COM1_BASE_ADDR (0xBD000000 + 0x20)
31#define EV96100_COM2_BASE_ADDR (0xBD000000 + 0x00)
32
33
34/*
35 * EV96100 interrupt controller register base.
36 */
37#define EV96100_ICTRL_REGS_BASE (KSEG1ADDR(0x1f000000))
38
39/*
40 * EV96100 UART register base.
41 */
42#define EV96100_UART0_REGS_BASE EV96100_COM1_BASE_ADDR
43#define EV96100_UART1_REGS_BASE EV96100_COM2_BASE_ADDR
44#define EV96100_BASE_BAUD ( 3686400 / 16 )
45
46#endif /* _ASM_GT64120_EV96100_GT64120_DEP_H */
diff --git a/include/asm-mips/mach-excite/excite.h b/include/asm-mips/mach-excite/excite.h
index 130bd4b8edce..4c29ba44992c 100644
--- a/include/asm-mips/mach-excite/excite.h
+++ b/include/asm-mips/mach-excite/excite.h
@@ -7,7 +7,7 @@
7 7
8#define EXCITE_CPU_EXT_CLOCK 100000000 8#define EXCITE_CPU_EXT_CLOCK 100000000
9 9
10#if !defined(__ASSEMBLER__) 10#if !defined(__ASSEMBLY__)
11void __init excite_kgdb_init(void); 11void __init excite_kgdb_init(void);
12void excite_procfs_init(void); 12void excite_procfs_init(void);
13extern unsigned long memsize; 13extern unsigned long memsize;
diff --git a/arch/mips/basler/excite/excite_fpga.h b/include/asm-mips/mach-excite/excite_fpga.h
index 38fcda703a0b..38fcda703a0b 100644
--- a/arch/mips/basler/excite/excite_fpga.h
+++ b/include/asm-mips/mach-excite/excite_fpga.h
diff --git a/include/asm-mips/mach-qemu/cpu-feature-overrides.h b/include/asm-mips/mach-qemu/cpu-feature-overrides.h
index f4e370e27168..529445dacedb 100644
--- a/include/asm-mips/mach-qemu/cpu-feature-overrides.h
+++ b/include/asm-mips/mach-qemu/cpu-feature-overrides.h
@@ -20,7 +20,7 @@
20 20
21#define cpu_has_llsc 1 21#define cpu_has_llsc 1
22#define cpu_has_vtag_icache 0 22#define cpu_has_vtag_icache 0
23#define cpu_has_dc_aliases (PAGE_SIZE < 0x4000) 23#define cpu_has_dc_aliases 0
24#define cpu_has_ic_fills_f_dc 0 24#define cpu_has_ic_fills_f_dc 0
25 25
26#define cpu_has_dsp 0 26#define cpu_has_dsp 0
diff --git a/include/asm-mips/mips-boards/atlasint.h b/include/asm-mips/mips-boards/atlasint.h
index fd7ebc54fa90..b15e4ea0b091 100644
--- a/include/asm-mips/mips-boards/atlasint.h
+++ b/include/asm-mips/mips-boards/atlasint.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 1999, 2006 MIPS Technologies, Inc. All rights reserved.
3 * Copyright (C) 1999 MIPS Technologies, Inc. All rights reserved. 3 * Authors: Carsten Langgaard <carstenl@mips.com>
4 * Maciej W. Rozycki <macro@mips.com>
4 * 5 *
5 * ######################################################################## 6 * ########################################################################
6 * 7 *
@@ -25,41 +26,88 @@
25#ifndef _MIPS_ATLASINT_H 26#ifndef _MIPS_ATLASINT_H
26#define _MIPS_ATLASINT_H 27#define _MIPS_ATLASINT_H
27 28
28#define ATLASINT_BASE 1 29/*
29#define ATLASINT_UART (ATLASINT_BASE+0) 30 * Interrupts 0..7 are used for Atlas CPU interrupts (nonEIC mode)
30#define ATLASINT_TIM0 (ATLASINT_BASE+1) 31 */
31#define ATLASINT_RES2 (ATLASINT_BASE+2) 32#define MIPSCPU_INT_BASE 0
32#define ATLASINT_RES3 (ATLASINT_BASE+3) 33
33#define ATLASINT_RTC (ATLASINT_BASE+4) 34/* CPU interrupt offsets */
34#define ATLASINT_COREHI (ATLASINT_BASE+5) 35#define MIPSCPU_INT_SW0 0
35#define ATLASINT_CORELO (ATLASINT_BASE+6) 36#define MIPSCPU_INT_SW1 1
36#define ATLASINT_RES7 (ATLASINT_BASE+7) 37#define MIPSCPU_INT_MB0 2
37#define ATLASINT_PCIA (ATLASINT_BASE+8) 38#define MIPSCPU_INT_ATLAS MIPSCPU_INT_MB0
38#define ATLASINT_PCIB (ATLASINT_BASE+9) 39#define MIPSCPU_INT_MB1 3
39#define ATLASINT_PCIC (ATLASINT_BASE+10) 40#define MIPSCPU_INT_MB2 4
40#define ATLASINT_PCID (ATLASINT_BASE+11) 41#define MIPSCPU_INT_MB3 5
41#define ATLASINT_ENUM (ATLASINT_BASE+12) 42#define MIPSCPU_INT_MB4 6
42#define ATLASINT_DEG (ATLASINT_BASE+13) 43#define MIPSCPU_INT_CPUCTR 7
43#define ATLASINT_ATXFAIL (ATLASINT_BASE+14) 44
44#define ATLASINT_INTA (ATLASINT_BASE+15) 45/*
45#define ATLASINT_INTB (ATLASINT_BASE+16) 46 * Interrupts 8..39 are used for Atlas interrupt controller interrupts
46#define ATLASINT_ETH ATLASINT_INTB 47 */
47#define ATLASINT_INTC (ATLASINT_BASE+17) 48#define ATLAS_INT_BASE 8
48#define ATLASINT_SCSI ATLASINT_INTC 49#define ATLAS_INT_UART (ATLAS_INT_BASE + 0)
49#define ATLASINT_INTD (ATLASINT_BASE+18) 50#define ATLAS_INT_TIM0 (ATLAS_INT_BASE + 1)
50#define ATLASINT_SERR (ATLASINT_BASE+19) 51#define ATLAS_INT_RES2 (ATLAS_INT_BASE + 2)
51#define ATLASINT_RES20 (ATLASINT_BASE+20) 52#define ATLAS_INT_RES3 (ATLAS_INT_BASE + 3)
52#define ATLASINT_RES21 (ATLASINT_BASE+21) 53#define ATLAS_INT_RTC (ATLAS_INT_BASE + 4)
53#define ATLASINT_RES22 (ATLASINT_BASE+22) 54#define ATLAS_INT_COREHI (ATLAS_INT_BASE + 5)
54#define ATLASINT_RES23 (ATLASINT_BASE+23) 55#define ATLAS_INT_CORELO (ATLAS_INT_BASE + 6)
55#define ATLASINT_RES24 (ATLASINT_BASE+24) 56#define ATLAS_INT_RES7 (ATLAS_INT_BASE + 7)
56#define ATLASINT_RES25 (ATLASINT_BASE+25) 57#define ATLAS_INT_PCIA (ATLAS_INT_BASE + 8)
57#define ATLASINT_RES26 (ATLASINT_BASE+26) 58#define ATLAS_INT_PCIB (ATLAS_INT_BASE + 9)
58#define ATLASINT_RES27 (ATLASINT_BASE+27) 59#define ATLAS_INT_PCIC (ATLAS_INT_BASE + 10)
59#define ATLASINT_RES28 (ATLASINT_BASE+28) 60#define ATLAS_INT_PCID (ATLAS_INT_BASE + 11)
60#define ATLASINT_RES29 (ATLASINT_BASE+29) 61#define ATLAS_INT_ENUM (ATLAS_INT_BASE + 12)
61#define ATLASINT_RES30 (ATLASINT_BASE+30) 62#define ATLAS_INT_DEG (ATLAS_INT_BASE + 13)
62#define ATLASINT_RES31 (ATLASINT_BASE+31) 63#define ATLAS_INT_ATXFAIL (ATLAS_INT_BASE + 14)
63#define ATLASINT_END (ATLASINT_BASE+31) 64#define ATLAS_INT_INTA (ATLAS_INT_BASE + 15)
65#define ATLAS_INT_INTB (ATLAS_INT_BASE + 16)
66#define ATLAS_INT_ETH ATLAS_INT_INTB
67#define ATLAS_INT_INTC (ATLAS_INT_BASE + 17)
68#define ATLAS_INT_SCSI ATLAS_INT_INTC
69#define ATLAS_INT_INTD (ATLAS_INT_BASE + 18)
70#define ATLAS_INT_SERR (ATLAS_INT_BASE + 19)
71#define ATLAS_INT_RES20 (ATLAS_INT_BASE + 20)
72#define ATLAS_INT_RES21 (ATLAS_INT_BASE + 21)
73#define ATLAS_INT_RES22 (ATLAS_INT_BASE + 22)
74#define ATLAS_INT_RES23 (ATLAS_INT_BASE + 23)
75#define ATLAS_INT_RES24 (ATLAS_INT_BASE + 24)
76#define ATLAS_INT_RES25 (ATLAS_INT_BASE + 25)
77#define ATLAS_INT_RES26 (ATLAS_INT_BASE + 26)
78#define ATLAS_INT_RES27 (ATLAS_INT_BASE + 27)
79#define ATLAS_INT_RES28 (ATLAS_INT_BASE + 28)
80#define ATLAS_INT_RES29 (ATLAS_INT_BASE + 29)
81#define ATLAS_INT_RES30 (ATLAS_INT_BASE + 30)
82#define ATLAS_INT_RES31 (ATLAS_INT_BASE + 31)
83#define ATLAS_INT_END (ATLAS_INT_BASE + 31)
84
85/*
86 * Interrupts 64..127 are used for Soc-it Classic interrupts
87 */
88#define MSC01C_INT_BASE 64
89
90/* SOC-it Classic interrupt offsets */
91#define MSC01C_INT_TMR 0
92#define MSC01C_INT_PCI 1
93
94/*
95 * Interrupts 64..127 are used for Soc-it EIC interrupts
96 */
97#define MSC01E_INT_BASE 64
98
99/* SOC-it EIC interrupt offsets */
100#define MSC01E_INT_SW0 1
101#define MSC01E_INT_SW1 2
102#define MSC01E_INT_MB0 3
103#define MSC01E_INT_ATLAS MSC01E_INT_MB0
104#define MSC01E_INT_MB1 4
105#define MSC01E_INT_MB2 5
106#define MSC01E_INT_MB3 6
107#define MSC01E_INT_MB4 7
108#define MSC01E_INT_TMR 8
109#define MSC01E_INT_PCI 9
110#define MSC01E_INT_PERFCTR 10
111#define MSC01E_INT_CPUCTR 11
64 112
65#endif /* !(_MIPS_ATLASINT_H) */ 113#endif /* !(_MIPS_ATLASINT_H) */
diff --git a/include/asm-mips/mmu_context.h b/include/asm-mips/mmu_context.h
index 18b69de87daa..fe065d6070ca 100644
--- a/include/asm-mips/mmu_context.h
+++ b/include/asm-mips/mmu_context.h
@@ -262,10 +262,10 @@ drop_mmu_context(struct mm_struct *mm, unsigned cpu)
262 /* See comments for similar code above */ 262 /* See comments for similar code above */
263 prevvpe = dvpe(); 263 prevvpe = dvpe();
264 oldasid = (read_c0_entryhi() & ASID_MASK); 264 oldasid = (read_c0_entryhi() & ASID_MASK);
265 if(smtc_live_asid[mytlb][oldasid]) { 265 if (smtc_live_asid[mytlb][oldasid]) {
266 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu); 266 smtc_live_asid[mytlb][oldasid] &= ~(0x1 << cpu);
267 if(smtc_live_asid[mytlb][oldasid] == 0) 267 if(smtc_live_asid[mytlb][oldasid] == 0)
268 smtc_flush_tlb_asid(oldasid); 268 smtc_flush_tlb_asid(oldasid);
269 } 269 }
270 /* See comments for similar code above */ 270 /* See comments for similar code above */
271 write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK) 271 write_c0_entryhi((read_c0_entryhi() & ~HW_ASID_MASK)
diff --git a/include/asm-mips/page.h b/include/asm-mips/page.h
index 219d359861f3..85b258ee7090 100644
--- a/include/asm-mips/page.h
+++ b/include/asm-mips/page.h
@@ -34,6 +34,8 @@
34 34
35#ifndef __ASSEMBLY__ 35#ifndef __ASSEMBLY__
36 36
37#include <asm/cpu-features.h>
38
37extern void clear_page(void * page); 39extern void clear_page(void * page);
38extern void copy_page(void * to, void * from); 40extern void copy_page(void * to, void * from);
39 41
@@ -53,7 +55,7 @@ static inline void clear_user_page(void *addr, unsigned long vaddr,
53 extern void (*flush_data_cache_page)(unsigned long addr); 55 extern void (*flush_data_cache_page)(unsigned long addr);
54 56
55 clear_page(addr); 57 clear_page(addr);
56 if (pages_do_alias((unsigned long) addr, vaddr)) 58 if (pages_do_alias((unsigned long) addr, vaddr & PAGE_MASK))
57 flush_data_cache_page((unsigned long)addr); 59 flush_data_cache_page((unsigned long)addr);
58} 60}
59 61
@@ -63,7 +65,8 @@ static inline void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
63 extern void (*flush_data_cache_page)(unsigned long addr); 65 extern void (*flush_data_cache_page)(unsigned long addr);
64 66
65 copy_page(vto, vfrom); 67 copy_page(vto, vfrom);
66 if (pages_do_alias((unsigned long)vto, vaddr)) 68 if (!cpu_has_ic_fills_f_dc ||
69 pages_do_alias((unsigned long)vto, vaddr & PAGE_MASK))
67 flush_data_cache_page((unsigned long)vto); 70 flush_data_cache_page((unsigned long)vto);
68} 71}
69 72
@@ -74,15 +77,17 @@ static inline void copy_user_page(void *vto, void *vfrom, unsigned long vaddr,
74 #ifdef CONFIG_CPU_MIPS32 77 #ifdef CONFIG_CPU_MIPS32
75 typedef struct { unsigned long pte_low, pte_high; } pte_t; 78 typedef struct { unsigned long pte_low, pte_high; } pte_t;
76 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) 79 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
80 #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
77 #else 81 #else
78 typedef struct { unsigned long long pte; } pte_t; 82 typedef struct { unsigned long long pte; } pte_t;
79 #define pte_val(x) ((x).pte) 83 #define pte_val(x) ((x).pte)
84 #define __pte(x) ((pte_t) { (x) } )
80 #endif 85 #endif
81#else 86#else
82typedef struct { unsigned long pte; } pte_t; 87typedef struct { unsigned long pte; } pte_t;
83#define pte_val(x) ((x).pte) 88#define pte_val(x) ((x).pte)
84#endif
85#define __pte(x) ((pte_t) { (x) } ) 89#define __pte(x) ((pte_t) { (x) } )
90#endif
86 91
87/* 92/*
88 * For 3-level pagetables we defines these ourselves, for 2-level the 93 * For 3-level pagetables we defines these ourselves, for 2-level the
diff --git a/include/asm-mips/pgtable-64.h b/include/asm-mips/pgtable-64.h
index c59a1e21f5b0..d05fb6f38aa7 100644
--- a/include/asm-mips/pgtable-64.h
+++ b/include/asm-mips/pgtable-64.h
@@ -93,8 +93,12 @@
93#define PTRS_PER_PMD ((PAGE_SIZE << PMD_ORDER) / sizeof(pmd_t)) 93#define PTRS_PER_PMD ((PAGE_SIZE << PMD_ORDER) / sizeof(pmd_t))
94#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t)) 94#define PTRS_PER_PTE ((PAGE_SIZE << PTE_ORDER) / sizeof(pte_t))
95 95
96#if PGDIR_SIZE >= TASK_SIZE
97#define USER_PTRS_PER_PGD (1)
98#else
96#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) 99#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE)
97#define FIRST_USER_ADDRESS 0 100#endif
101#define FIRST_USER_ADDRESS 0UL
98 102
99#define VMALLOC_START MAP_BASE 103#define VMALLOC_START MAP_BASE
100#define VMALLOC_END \ 104#define VMALLOC_END \
diff --git a/include/asm-mips/ptrace.h b/include/asm-mips/ptrace.h
index 4113316ee0da..4fb0fc43ffd7 100644
--- a/include/asm-mips/ptrace.h
+++ b/include/asm-mips/ptrace.h
@@ -10,8 +10,6 @@
10#define _ASM_PTRACE_H 10#define _ASM_PTRACE_H
11 11
12 12
13#include <asm/isadep.h>
14
15/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ 13/* 0 - 31 are integer registers, 32 - 63 are fp registers. */
16#define FPR_BASE 32 14#define FPR_BASE 32
17#define PC 64 15#define PC 64
@@ -73,6 +71,7 @@ struct pt_regs {
73#ifdef __KERNEL__ 71#ifdef __KERNEL__
74 72
75#include <linux/linkage.h> 73#include <linux/linkage.h>
74#include <asm/isadep.h>
76 75
77/* 76/*
78 * Does the process account for user or for system time? 77 * Does the process account for user or for system time?
diff --git a/include/asm-mips/serial.h b/include/asm-mips/serial.h
index 584bd9c0ab2e..035637c67e7c 100644
--- a/include/asm-mips/serial.h
+++ b/include/asm-mips/serial.h
@@ -52,9 +52,9 @@
52#endif 52#endif
53 53
54/* 54/*
55 * Both Galileo boards have the same UART mappings. 55 * Galileo EV64120 evaluation board
56 */ 56 */
57#if defined (CONFIG_MIPS_EV96100) || defined (CONFIG_MIPS_EV64120) 57#ifdef CONFIG_MIPS_EV64120
58#include <asm/galileo-boards/ev96100.h> 58#include <asm/galileo-boards/ev96100.h>
59#include <asm/galileo-boards/ev96100int.h> 59#include <asm/galileo-boards/ev96100int.h>
60#define EV96100_SERIAL_PORT_DEFNS \ 60#define EV96100_SERIAL_PORT_DEFNS \
diff --git a/include/asm-mips/sibyte/sb1250_defs.h b/include/asm-mips/sibyte/sb1250_defs.h
index 335dbaf1d831..a885491217c1 100644
--- a/include/asm-mips/sibyte/sb1250_defs.h
+++ b/include/asm-mips/sibyte/sb1250_defs.h
@@ -212,7 +212,7 @@
212 * Note: you'll need to define uint32_t and uint64_t in your headers. 212 * Note: you'll need to define uint32_t and uint64_t in your headers.
213 */ 213 */
214 214
215#if !defined(__ASSEMBLER__) 215#if !defined(__ASSEMBLY__)
216#define _SB_MAKE64(x) ((uint64_t)(x)) 216#define _SB_MAKE64(x) ((uint64_t)(x))
217#define _SB_MAKE32(x) ((uint32_t)(x)) 217#define _SB_MAKE32(x) ((uint32_t)(x))
218#else 218#else
@@ -251,9 +251,9 @@
251 */ 251 */
252 252
253 253
254#if defined(__mips64) && !defined(__ASSEMBLER__) 254#if defined(__mips64) && !defined(__ASSEMBLY__)
255#define SBWRITECSR(csr,val) *((volatile uint64_t *) PHYS_TO_K1(csr)) = (val) 255#define SBWRITECSR(csr,val) *((volatile uint64_t *) PHYS_TO_K1(csr)) = (val)
256#define SBREADCSR(csr) (*((volatile uint64_t *) PHYS_TO_K1(csr))) 256#define SBREADCSR(csr) (*((volatile uint64_t *) PHYS_TO_K1(csr)))
257#endif /* __ASSEMBLER__ */ 257#endif /* __ASSEMBLY__ */
258 258
259#endif 259#endif
diff --git a/include/asm-mips/sibyte/sb1250_scd.h b/include/asm-mips/sibyte/sb1250_scd.h
index f4178bdcfcb0..7ed0bb611e56 100644
--- a/include/asm-mips/sibyte/sb1250_scd.h
+++ b/include/asm-mips/sibyte/sb1250_scd.h
@@ -149,7 +149,7 @@
149 * (For the assembler version, sysrev and dest may be the same register. 149 * (For the assembler version, sysrev and dest may be the same register.
150 * Also, it clobbers AT.) 150 * Also, it clobbers AT.)
151 */ 151 */
152#ifdef __ASSEMBLER__ 152#ifdef __ASSEMBLY__
153#define SYS_SOC_TYPE(dest, sysrev) \ 153#define SYS_SOC_TYPE(dest, sysrev) \
154 .set push ; \ 154 .set push ; \
155 .set reorder ; \ 155 .set reorder ; \
diff --git a/include/asm-mips/signal.h b/include/asm-mips/signal.h
index 87a1dff95199..8b391a2f0814 100644
--- a/include/asm-mips/signal.h
+++ b/include/asm-mips/signal.h
@@ -108,17 +108,8 @@ typedef unsigned long old_sigset_t; /* at least 32 bits */
108#define SIG_BLOCK 1 /* for blocking signals */ 108#define SIG_BLOCK 1 /* for blocking signals */
109#define SIG_UNBLOCK 2 /* for unblocking signals */ 109#define SIG_UNBLOCK 2 /* for unblocking signals */
110#define SIG_SETMASK 3 /* for setting the signal mask */ 110#define SIG_SETMASK 3 /* for setting the signal mask */
111#define SIG_SETMASK32 256 /* Goodie from SGI for BSD compatibility:
112 set only the low 32 bit of the sigset. */
113 111
114/* Type of a signal handler. */ 112#include <asm-generic/signal.h>
115typedef void __signalfn_t(int);
116typedef __signalfn_t __user *__sighandler_t;
117
118/* Fake signal functions */
119#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
120#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
121#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
122 113
123struct sigaction { 114struct sigaction {
124 unsigned int sa_flags; 115 unsigned int sa_flags;
diff --git a/include/asm-mips/spinlock.h b/include/asm-mips/spinlock.h
index 669b8e349ff2..4c1a1b53aeaf 100644
--- a/include/asm-mips/spinlock.h
+++ b/include/asm-mips/spinlock.h
@@ -239,7 +239,51 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw)
239 : "memory"); 239 : "memory");
240} 240}
241 241
242#define __raw_read_trylock(lock) generic__raw_read_trylock(lock) 242static inline int __raw_read_trylock(raw_rwlock_t *rw)
243{
244 unsigned int tmp;
245 int ret;
246
247 if (R10000_LLSC_WAR) {
248 __asm__ __volatile__(
249 " .set noreorder # __raw_read_trylock \n"
250 " li %2, 0 \n"
251 "1: ll %1, %3 \n"
252 " bnez %1, 2f \n"
253 " addu %1, 1 \n"
254 " sc %1, %0 \n"
255 " beqzl %1, 1b \n"
256 " .set reorder \n"
257#ifdef CONFIG_SMP
258 " sync \n"
259#endif
260 " li %2, 1 \n"
261 "2: \n"
262 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
263 : "m" (rw->lock)
264 : "memory");
265 } else {
266 __asm__ __volatile__(
267 " .set noreorder # __raw_read_trylock \n"
268 " li %2, 0 \n"
269 "1: ll %1, %3 \n"
270 " bnez %1, 2f \n"
271 " addu %1, 1 \n"
272 " sc %1, %0 \n"
273 " beqz %1, 1b \n"
274 " .set reorder \n"
275#ifdef CONFIG_SMP
276 " sync \n"
277#endif
278 " li %2, 1 \n"
279 "2: \n"
280 : "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
281 : "m" (rw->lock)
282 : "memory");
283 }
284
285 return ret;
286}
243 287
244static inline int __raw_write_trylock(raw_rwlock_t *rw) 288static inline int __raw_write_trylock(raw_rwlock_t *rw)
245{ 289{
@@ -283,4 +327,5 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)
283 return ret; 327 return ret;
284} 328}
285 329
330
286#endif /* _ASM_SPINLOCK_H */ 331#endif /* _ASM_SPINLOCK_H */
diff --git a/include/asm-mips/timex.h b/include/asm-mips/timex.h
index 98aa737b34aa..b80de8e0fbbd 100644
--- a/include/asm-mips/timex.h
+++ b/include/asm-mips/timex.h
@@ -8,6 +8,8 @@
8#ifndef _ASM_TIMEX_H 8#ifndef _ASM_TIMEX_H
9#define _ASM_TIMEX_H 9#define _ASM_TIMEX_H
10 10
11#ifdef __KERNEL__
12
11#include <asm/mipsregs.h> 13#include <asm/mipsregs.h>
12 14
13/* 15/*
@@ -51,4 +53,6 @@ static inline cycles_t get_cycles (void)
51 return read_c0_count(); 53 return read_c0_count();
52} 54}
53 55
56#endif /* __KERNEL__ */
57
54#endif /* _ASM_TIMEX_H */ 58#endif /* _ASM_TIMEX_H */
diff --git a/include/asm-mips/unistd.h b/include/asm-mips/unistd.h
index 610ccb8a50b3..c39142920fe6 100644
--- a/include/asm-mips/unistd.h
+++ b/include/asm-mips/unistd.h
@@ -313,7 +313,7 @@
313#define __NR_mknodat (__NR_Linux + 290) 313#define __NR_mknodat (__NR_Linux + 290)
314#define __NR_fchownat (__NR_Linux + 291) 314#define __NR_fchownat (__NR_Linux + 291)
315#define __NR_futimesat (__NR_Linux + 292) 315#define __NR_futimesat (__NR_Linux + 292)
316#define __NR_fstatat (__NR_Linux + 293) 316#define __NR_fstatat64 (__NR_Linux + 293)
317#define __NR_unlinkat (__NR_Linux + 294) 317#define __NR_unlinkat (__NR_Linux + 294)
318#define __NR_renameat (__NR_Linux + 295) 318#define __NR_renameat (__NR_Linux + 295)
319#define __NR_linkat (__NR_Linux + 296) 319#define __NR_linkat (__NR_Linux + 296)
@@ -329,16 +329,18 @@
329#define __NR_tee (__NR_Linux + 306) 329#define __NR_tee (__NR_Linux + 306)
330#define __NR_vmsplice (__NR_Linux + 307) 330#define __NR_vmsplice (__NR_Linux + 307)
331#define __NR_move_pages (__NR_Linux + 308) 331#define __NR_move_pages (__NR_Linux + 308)
332#define __NR_set_robust_list (__NR_Linux + 309)
333#define __NR_get_robust_list (__NR_Linux + 310)
332 334
333/* 335/*
334 * Offset of the last Linux o32 flavoured syscall 336 * Offset of the last Linux o32 flavoured syscall
335 */ 337 */
336#define __NR_Linux_syscalls 308 338#define __NR_Linux_syscalls 310
337 339
338#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 340#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
339 341
340#define __NR_O32_Linux 4000 342#define __NR_O32_Linux 4000
341#define __NR_O32_Linux_syscalls 308 343#define __NR_O32_Linux_syscalls 310
342 344
343#if _MIPS_SIM == _MIPS_SIM_ABI64 345#if _MIPS_SIM == _MIPS_SIM_ABI64
344 346
@@ -598,7 +600,7 @@
598#define __NR_mknodat (__NR_Linux + 249) 600#define __NR_mknodat (__NR_Linux + 249)
599#define __NR_fchownat (__NR_Linux + 250) 601#define __NR_fchownat (__NR_Linux + 250)
600#define __NR_futimesat (__NR_Linux + 251) 602#define __NR_futimesat (__NR_Linux + 251)
601#define __NR_fstatat (__NR_Linux + 252) 603#define __NR_newfstatat (__NR_Linux + 252)
602#define __NR_unlinkat (__NR_Linux + 253) 604#define __NR_unlinkat (__NR_Linux + 253)
603#define __NR_renameat (__NR_Linux + 254) 605#define __NR_renameat (__NR_Linux + 254)
604#define __NR_linkat (__NR_Linux + 255) 606#define __NR_linkat (__NR_Linux + 255)
@@ -614,16 +616,18 @@
614#define __NR_tee (__NR_Linux + 265) 616#define __NR_tee (__NR_Linux + 265)
615#define __NR_vmsplice (__NR_Linux + 266) 617#define __NR_vmsplice (__NR_Linux + 266)
616#define __NR_move_pages (__NR_Linux + 267) 618#define __NR_move_pages (__NR_Linux + 267)
619#define __NR_set_robust_list (__NR_Linux + 268)
620#define __NR_get_robust_list (__NR_Linux + 269)
617 621
618/* 622/*
619 * Offset of the last Linux 64-bit flavoured syscall 623 * Offset of the last Linux 64-bit flavoured syscall
620 */ 624 */
621#define __NR_Linux_syscalls 267 625#define __NR_Linux_syscalls 269
622 626
623#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 627#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
624 628
625#define __NR_64_Linux 5000 629#define __NR_64_Linux 5000
626#define __NR_64_Linux_syscalls 267 630#define __NR_64_Linux_syscalls 269
627 631
628#if _MIPS_SIM == _MIPS_SIM_NABI32 632#if _MIPS_SIM == _MIPS_SIM_NABI32
629 633
@@ -887,7 +891,7 @@
887#define __NR_mknodat (__NR_Linux + 253) 891#define __NR_mknodat (__NR_Linux + 253)
888#define __NR_fchownat (__NR_Linux + 254) 892#define __NR_fchownat (__NR_Linux + 254)
889#define __NR_futimesat (__NR_Linux + 255) 893#define __NR_futimesat (__NR_Linux + 255)
890#define __NR_fstatat (__NR_Linux + 256) 894#define __NR_newfstatat (__NR_Linux + 256)
891#define __NR_unlinkat (__NR_Linux + 257) 895#define __NR_unlinkat (__NR_Linux + 257)
892#define __NR_renameat (__NR_Linux + 258) 896#define __NR_renameat (__NR_Linux + 258)
893#define __NR_linkat (__NR_Linux + 259) 897#define __NR_linkat (__NR_Linux + 259)
@@ -903,16 +907,18 @@
903#define __NR_tee (__NR_Linux + 269) 907#define __NR_tee (__NR_Linux + 269)
904#define __NR_vmsplice (__NR_Linux + 270) 908#define __NR_vmsplice (__NR_Linux + 270)
905#define __NR_move_pages (__NR_Linux + 271) 909#define __NR_move_pages (__NR_Linux + 271)
910#define __NR_set_robust_list (__NR_Linux + 272)
911#define __NR_get_robust_list (__NR_Linux + 273)
906 912
907/* 913/*
908 * Offset of the last N32 flavoured syscall 914 * Offset of the last N32 flavoured syscall
909 */ 915 */
910#define __NR_Linux_syscalls 271 916#define __NR_Linux_syscalls 273
911 917
912#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 918#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
913 919
914#define __NR_N32_Linux 6000 920#define __NR_N32_Linux 6000
915#define __NR_N32_Linux_syscalls 271 921#define __NR_N32_Linux_syscalls 273
916 922
917#ifdef __KERNEL__ 923#ifdef __KERNEL__
918 924
diff --git a/include/asm-mips/user.h b/include/asm-mips/user.h
index 89bf8b4cab3c..61f2a093b91b 100644
--- a/include/asm-mips/user.h
+++ b/include/asm-mips/user.h
@@ -8,6 +8,8 @@
8#ifndef _ASM_USER_H 8#ifndef _ASM_USER_H
9#define _ASM_USER_H 9#define _ASM_USER_H
10 10
11#ifdef __KERNEL__
12
11#include <asm/page.h> 13#include <asm/page.h>
12#include <asm/reg.h> 14#include <asm/reg.h>
13 15
@@ -55,4 +57,6 @@ struct user {
55#define HOST_DATA_START_ADDR (u.start_data) 57#define HOST_DATA_START_ADDR (u.start_data)
56#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG) 58#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
57 59
60#endif /* __KERNEL__ */
61
58#endif /* _ASM_USER_H */ 62#endif /* _ASM_USER_H */
diff --git a/include/asm-s390/unistd.h b/include/asm-s390/unistd.h
index 02b942d85c37..d49c54cb5505 100644
--- a/include/asm-s390/unistd.h
+++ b/include/asm-s390/unistd.h
@@ -342,9 +342,11 @@
342 342
343#ifdef __KERNEL__ 343#ifdef __KERNEL__
344 344
345#include <linux/err.h>
346
345#define __syscall_return(type, res) \ 347#define __syscall_return(type, res) \
346do { \ 348do { \
347 if ((unsigned long)(res) >= (unsigned long)(-4095)) {\ 349 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
348 errno = -(res); \ 350 errno = -(res); \
349 res = -1; \ 351 res = -1; \
350 } \ 352 } \
diff --git a/include/asm-sh/addrspace.h b/include/asm-sh/addrspace.h
index 720afc11c2ca..b860218e402e 100644
--- a/include/asm-sh/addrspace.h
+++ b/include/asm-sh/addrspace.h
@@ -14,11 +14,19 @@
14#include <asm/cpu/addrspace.h> 14#include <asm/cpu/addrspace.h>
15 15
16/* Memory segments (32bit Privileged mode addresses) */ 16/* Memory segments (32bit Privileged mode addresses) */
17#ifndef CONFIG_CPU_SH2A
17#define P0SEG 0x00000000 18#define P0SEG 0x00000000
18#define P1SEG 0x80000000 19#define P1SEG 0x80000000
19#define P2SEG 0xa0000000 20#define P2SEG 0xa0000000
20#define P3SEG 0xc0000000 21#define P3SEG 0xc0000000
21#define P4SEG 0xe0000000 22#define P4SEG 0xe0000000
23#else
24#define P0SEG 0x00000000
25#define P1SEG 0x00000000
26#define P2SEG 0x20000000
27#define P3SEG 0x00000000
28#define P4SEG 0x80000000
29#endif
22 30
23/* Returns the privileged segment base of a given address */ 31/* Returns the privileged segment base of a given address */
24#define PXSEG(a) (((unsigned long)(a)) & 0xe0000000) 32#define PXSEG(a) (((unsigned long)(a)) & 0xe0000000)
diff --git a/include/asm-sh/adx/io.h b/include/asm-sh/adx/io.h
deleted file mode 100644
index ab1225f1d557..000000000000
--- a/include/asm-sh/adx/io.h
+++ /dev/null
@@ -1,86 +0,0 @@
1/*
2 * include/asm-sh/io_adx.h
3 *
4 * Copyright (C) 2001 A&D Co., Ltd.
5 *
6 * This file may be copied or modified under the terms of the GNU
7 * General Public License. See linux/COPYING for more information.
8 *
9 * IO functions for an A&D ADX Board
10 */
11
12#ifndef _ASM_SH_IO_ADX_H
13#define _ASM_SH_IO_ADX_H
14
15#include <asm/io_generic.h>
16
17extern unsigned char adx_inb(unsigned long port);
18extern unsigned short adx_inw(unsigned long port);
19extern unsigned int adx_inl(unsigned long port);
20
21extern void adx_outb(unsigned char value, unsigned long port);
22extern void adx_outw(unsigned short value, unsigned long port);
23extern void adx_outl(unsigned int value, unsigned long port);
24
25extern unsigned char adx_inb_p(unsigned long port);
26extern void adx_outb_p(unsigned char value, unsigned long port);
27
28extern void adx_insb(unsigned long port, void *addr, unsigned long count);
29extern void adx_insw(unsigned long port, void *addr, unsigned long count);
30extern void adx_insl(unsigned long port, void *addr, unsigned long count);
31extern void adx_outsb(unsigned long port, const void *addr, unsigned long count);
32extern void adx_outsw(unsigned long port, const void *addr, unsigned long count);
33extern void adx_outsl(unsigned long port, const void *addr, unsigned long count);
34
35extern unsigned char adx_readb(unsigned long addr);
36extern unsigned short adx_readw(unsigned long addr);
37extern unsigned int adx_readl(unsigned long addr);
38extern void adx_writeb(unsigned char b, unsigned long addr);
39extern void adx_writew(unsigned short b, unsigned long addr);
40extern void adx_writel(unsigned int b, unsigned long addr);
41
42extern void * adx_ioremap(unsigned long offset, unsigned long size);
43extern void adx_iounmap(void *addr);
44
45extern unsigned long adx_isa_port2addr(unsigned long offset);
46
47extern void setup_adx(void);
48extern void init_adx_IRQ(void);
49
50#ifdef __WANT_IO_DEF
51
52#define __inb adx_inb
53#define __inw adx_inw
54#define __inl adx_inl
55#define __outb adx_outb
56#define __outw adx_outw
57#define __outl adx_outl
58
59#define __inb_p adx_inb_p
60#define __inw_p adx_inw
61#define __inl_p adx_inl
62#define __outb_p adx_outb_p
63#define __outw_p adx_outw
64#define __outl_p adx_outl
65
66#define __insb adx_insb
67#define __insw adx_insw
68#define __insl adx_insl
69#define __outsb adx_outsb
70#define __outsw adx_outsw
71#define __outsl adx_outsl
72
73#define __readb adx_readb
74#define __readw adx_readw
75#define __readl adx_readl
76#define __writeb adx_writeb
77#define __writew adx_writew
78#define __writel adx_writel
79
80#define __isa_port2addr adx_isa_port2addr
81#define __ioremap adx_ioremap
82#define __iounmap adx_iounmap
83
84#endif
85
86#endif /* _ASM_SH_IO_AANDD_H */
diff --git a/include/asm-sh/apm.h b/include/asm-sh/apm.h
new file mode 100644
index 000000000000..8b091e93651f
--- /dev/null
+++ b/include/asm-sh/apm.h
@@ -0,0 +1,46 @@
1/*
2 * Copyright 2006 (c) Andriy Skulysh <askulysh@gmail.com>
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 */
9
10#ifndef __ASM_SH_APM_H
11#define __ASM_SH_APM_H
12
13#define APM_AC_OFFLINE 0
14#define APM_AC_ONLINE 1
15#define APM_AC_BACKUP 2
16#define APM_AC_UNKNOWN 0xff
17
18#define APM_BATTERY_STATUS_HIGH 0
19#define APM_BATTERY_STATUS_LOW 1
20#define APM_BATTERY_STATUS_CRITICAL 2
21#define APM_BATTERY_STATUS_CHARGING 3
22#define APM_BATTERY_STATUS_NOT_PRESENT 4
23#define APM_BATTERY_STATUS_UNKNOWN 0xff
24
25#define APM_BATTERY_LIFE_UNKNOWN 0xFFFF
26#define APM_BATTERY_LIFE_MINUTES 0x8000
27#define APM_BATTERY_LIFE_VALUE_MASK 0x7FFF
28
29#define APM_BATTERY_FLAG_HIGH (1 << 0)
30#define APM_BATTERY_FLAG_LOW (1 << 1)
31#define APM_BATTERY_FLAG_CRITICAL (1 << 2)
32#define APM_BATTERY_FLAG_CHARGING (1 << 3)
33#define APM_BATTERY_FLAG_NOT_PRESENT (1 << 7)
34#define APM_BATTERY_FLAG_UNKNOWN 0xff
35
36#define APM_UNITS_MINS 0
37#define APM_UNITS_SECS 1
38#define APM_UNITS_UNKNOWN -1
39
40
41extern int (*apm_get_info)(char *buf, char **start, off_t fpos, int length);
42extern int apm_suspended;
43
44void apm_queue_event(apm_event_t event);
45
46#endif
diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h
index fb627de217f2..8bdc1ba56f73 100644
--- a/include/asm-sh/atomic.h
+++ b/include/asm-sh/atomic.h
@@ -14,6 +14,7 @@ typedef struct { volatile int counter; } atomic_t;
14#define atomic_read(v) ((v)->counter) 14#define atomic_read(v) ((v)->counter)
15#define atomic_set(v,i) ((v)->counter = (i)) 15#define atomic_set(v,i) ((v)->counter = (i))
16 16
17#include <linux/compiler.h>
17#include <asm/system.h> 18#include <asm/system.h>
18 19
19/* 20/*
@@ -21,49 +22,110 @@ typedef struct { volatile int counter; } atomic_t;
21 * forward to code at the end of this object's .text section, then 22 * forward to code at the end of this object's .text section, then
22 * branch back to restart the operation. 23 * branch back to restart the operation.
23 */ 24 */
24 25static inline void atomic_add(int i, atomic_t *v)
25static __inline__ void atomic_add(int i, atomic_t * v)
26{ 26{
27#ifdef CONFIG_CPU_SH4A
28 unsigned long tmp;
29
30 __asm__ __volatile__ (
31"1: movli.l @%3, %0 ! atomic_add \n"
32" add %2, %0 \n"
33" movco.l %0, @%3 \n"
34" bf 1b \n"
35 : "=&z" (tmp), "=r" (&v->counter)
36 : "r" (i), "r" (&v->counter)
37 : "t");
38#else
27 unsigned long flags; 39 unsigned long flags;
28 40
29 local_irq_save(flags); 41 local_irq_save(flags);
30 *(long *)v += i; 42 *(long *)v += i;
31 local_irq_restore(flags); 43 local_irq_restore(flags);
44#endif
32} 45}
33 46
34static __inline__ void atomic_sub(int i, atomic_t *v) 47static inline void atomic_sub(int i, atomic_t *v)
35{ 48{
49#ifdef CONFIG_CPU_SH4A
50 unsigned long tmp;
51
52 __asm__ __volatile__ (
53"1: movli.l @%3, %0 ! atomic_sub \n"
54" sub %2, %0 \n"
55" movco.l %0, @%3 \n"
56" bf 1b \n"
57 : "=&z" (tmp), "=r" (&v->counter)
58 : "r" (i), "r" (&v->counter)
59 : "t");
60#else
36 unsigned long flags; 61 unsigned long flags;
37 62
38 local_irq_save(flags); 63 local_irq_save(flags);
39 *(long *)v -= i; 64 *(long *)v -= i;
40 local_irq_restore(flags); 65 local_irq_restore(flags);
66#endif
41} 67}
42 68
43static __inline__ int atomic_add_return(int i, atomic_t * v) 69/*
70 * SH-4A note:
71 *
72 * We basically get atomic_xxx_return() for free compared with
73 * atomic_xxx(). movli.l/movco.l require r0 due to the instruction
74 * encoding, so the retval is automatically set without having to
75 * do any special work.
76 */
77static inline int atomic_add_return(int i, atomic_t *v)
44{ 78{
45 unsigned long temp, flags; 79 unsigned long temp;
80
81#ifdef CONFIG_CPU_SH4A
82 __asm__ __volatile__ (
83"1: movli.l @%3, %0 ! atomic_add_return \n"
84" add %2, %0 \n"
85" movco.l %0, @%3 \n"
86" bf 1b \n"
87" synco \n"
88 : "=&z" (temp), "=r" (&v->counter)
89 : "r" (i), "r" (&v->counter)
90 : "t");
91#else
92 unsigned long flags;
46 93
47 local_irq_save(flags); 94 local_irq_save(flags);
48 temp = *(long *)v; 95 temp = *(long *)v;
49 temp += i; 96 temp += i;
50 *(long *)v = temp; 97 *(long *)v = temp;
51 local_irq_restore(flags); 98 local_irq_restore(flags);
99#endif
52 100
53 return temp; 101 return temp;
54} 102}
55 103
56#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0) 104#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
57 105
58static __inline__ int atomic_sub_return(int i, atomic_t * v) 106static inline int atomic_sub_return(int i, atomic_t *v)
59{ 107{
60 unsigned long temp, flags; 108 unsigned long temp;
109
110#ifdef CONFIG_CPU_SH4A
111 __asm__ __volatile__ (
112"1: movli.l @%3, %0 ! atomic_sub_return \n"
113" sub %2, %0 \n"
114" movco.l %0, @%3 \n"
115" bf 1b \n"
116" synco \n"
117 : "=&z" (temp), "=r" (&v->counter)
118 : "r" (i), "r" (&v->counter)
119 : "t");
120#else
121 unsigned long flags;
61 122
62 local_irq_save(flags); 123 local_irq_save(flags);
63 temp = *(long *)v; 124 temp = *(long *)v;
64 temp -= i; 125 temp -= i;
65 *(long *)v = temp; 126 *(long *)v = temp;
66 local_irq_restore(flags); 127 local_irq_restore(flags);
128#endif
67 129
68 return temp; 130 return temp;
69} 131}
@@ -118,22 +180,48 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
118} 180}
119#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 181#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
120 182
121static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v) 183static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
122{ 184{
185#ifdef CONFIG_CPU_SH4A
186 unsigned long tmp;
187
188 __asm__ __volatile__ (
189"1: movli.l @%3, %0 ! atomic_clear_mask \n"
190" and %2, %0 \n"
191" movco.l %0, @%3 \n"
192" bf 1b \n"
193 : "=&z" (tmp), "=r" (&v->counter)
194 : "r" (~mask), "r" (&v->counter)
195 : "t");
196#else
123 unsigned long flags; 197 unsigned long flags;
124 198
125 local_irq_save(flags); 199 local_irq_save(flags);
126 *(long *)v &= ~mask; 200 *(long *)v &= ~mask;
127 local_irq_restore(flags); 201 local_irq_restore(flags);
202#endif
128} 203}
129 204
130static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v) 205static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
131{ 206{
207#ifdef CONFIG_CPU_SH4A
208 unsigned long tmp;
209
210 __asm__ __volatile__ (
211"1: movli.l @%3, %0 ! atomic_set_mask \n"
212" or %2, %0 \n"
213" movco.l %0, @%3 \n"
214" bf 1b \n"
215 : "=&z" (tmp), "=r" (&v->counter)
216 : "r" (mask), "r" (&v->counter)
217 : "t");
218#else
132 unsigned long flags; 219 unsigned long flags;
133 220
134 local_irq_save(flags); 221 local_irq_save(flags);
135 *(long *)v |= mask; 222 *(long *)v |= mask;
136 local_irq_restore(flags); 223 local_irq_restore(flags);
224#endif
137} 225}
138 226
139/* Atomic operations are already serializing on SH */ 227/* Atomic operations are already serializing on SH */
diff --git a/include/asm-sh/auxvec.h b/include/asm-sh/auxvec.h
index fc21e4db5881..1b6916e63e90 100644
--- a/include/asm-sh/auxvec.h
+++ b/include/asm-sh/auxvec.h
@@ -1,4 +1,18 @@
1#ifndef __ASM_SH_AUXVEC_H 1#ifndef __ASM_SH_AUXVEC_H
2#define __ASM_SH_AUXVEC_H 2#define __ASM_SH_AUXVEC_H
3 3
4/*
5 * Architecture-neutral AT_ values in 0-17, leave some room
6 * for more of them.
7 */
8
9#ifdef CONFIG_VSYSCALL
10/*
11 * Only define this in the vsyscall case, the entry point to
12 * the vsyscall page gets placed here. The kernel will attempt
13 * to build a gate VMA we don't care about otherwise..
14 */
15#define AT_SYSINFO_EHDR 33
16#endif
17
4#endif /* __ASM_SH_AUXVEC_H */ 18#endif /* __ASM_SH_AUXVEC_H */
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index e34f82508568..1c16792cee1d 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -6,7 +6,7 @@
6/* For __swab32 */ 6/* For __swab32 */
7#include <asm/byteorder.h> 7#include <asm/byteorder.h>
8 8
9static __inline__ void set_bit(int nr, volatile void * addr) 9static inline void set_bit(int nr, volatile void * addr)
10{ 10{
11 int mask; 11 int mask;
12 volatile unsigned int *a = addr; 12 volatile unsigned int *a = addr;
@@ -24,7 +24,7 @@ static __inline__ void set_bit(int nr, volatile void * addr)
24 */ 24 */
25#define smp_mb__before_clear_bit() barrier() 25#define smp_mb__before_clear_bit() barrier()
26#define smp_mb__after_clear_bit() barrier() 26#define smp_mb__after_clear_bit() barrier()
27static __inline__ void clear_bit(int nr, volatile void * addr) 27static inline void clear_bit(int nr, volatile void * addr)
28{ 28{
29 int mask; 29 int mask;
30 volatile unsigned int *a = addr; 30 volatile unsigned int *a = addr;
@@ -37,7 +37,7 @@ static __inline__ void clear_bit(int nr, volatile void * addr)
37 local_irq_restore(flags); 37 local_irq_restore(flags);
38} 38}
39 39
40static __inline__ void change_bit(int nr, volatile void * addr) 40static inline void change_bit(int nr, volatile void * addr)
41{ 41{
42 int mask; 42 int mask;
43 volatile unsigned int *a = addr; 43 volatile unsigned int *a = addr;
@@ -50,7 +50,7 @@ static __inline__ void change_bit(int nr, volatile void * addr)
50 local_irq_restore(flags); 50 local_irq_restore(flags);
51} 51}
52 52
53static __inline__ int test_and_set_bit(int nr, volatile void * addr) 53static inline int test_and_set_bit(int nr, volatile void * addr)
54{ 54{
55 int mask, retval; 55 int mask, retval;
56 volatile unsigned int *a = addr; 56 volatile unsigned int *a = addr;
@@ -66,7 +66,7 @@ static __inline__ int test_and_set_bit(int nr, volatile void * addr)
66 return retval; 66 return retval;
67} 67}
68 68
69static __inline__ int test_and_clear_bit(int nr, volatile void * addr) 69static inline int test_and_clear_bit(int nr, volatile void * addr)
70{ 70{
71 int mask, retval; 71 int mask, retval;
72 volatile unsigned int *a = addr; 72 volatile unsigned int *a = addr;
@@ -82,7 +82,7 @@ static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
82 return retval; 82 return retval;
83} 83}
84 84
85static __inline__ int test_and_change_bit(int nr, volatile void * addr) 85static inline int test_and_change_bit(int nr, volatile void * addr)
86{ 86{
87 int mask, retval; 87 int mask, retval;
88 volatile unsigned int *a = addr; 88 volatile unsigned int *a = addr;
@@ -100,7 +100,7 @@ static __inline__ int test_and_change_bit(int nr, volatile void * addr)
100 100
101#include <asm-generic/bitops/non-atomic.h> 101#include <asm-generic/bitops/non-atomic.h>
102 102
103static __inline__ unsigned long ffz(unsigned long word) 103static inline unsigned long ffz(unsigned long word)
104{ 104{
105 unsigned long result; 105 unsigned long result;
106 106
@@ -120,7 +120,7 @@ static __inline__ unsigned long ffz(unsigned long word)
120 * 120 *
121 * Undefined if no bit exists, so code should check against 0 first. 121 * Undefined if no bit exists, so code should check against 0 first.
122 */ 122 */
123static __inline__ unsigned long __ffs(unsigned long word) 123static inline unsigned long __ffs(unsigned long word)
124{ 124{
125 unsigned long result; 125 unsigned long result;
126 126
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index a6de3d06a3d9..b4000c8bf31b 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -32,6 +32,10 @@ static void __init check_bugs(void)
32 case CPU_SH7750 ... CPU_SH4_501: 32 case CPU_SH7750 ... CPU_SH4_501:
33 *p++ = '4'; 33 *p++ = '4';
34 break; 34 break;
35 case CPU_SH7770 ... CPU_SH7781:
36 *p++ = '4';
37 *p++ = 'a';
38 break;
35 default: 39 default:
36 *p++ = '?'; 40 *p++ = '?';
37 *p++ = '!'; 41 *p++ = '!';
diff --git a/include/asm-sh/cache.h b/include/asm-sh/cache.h
index 656fdfe9e8b4..e3a180cf5062 100644
--- a/include/asm-sh/cache.h
+++ b/include/asm-sh/cache.h
@@ -10,7 +10,6 @@
10#ifdef __KERNEL__ 10#ifdef __KERNEL__
11 11
12#include <asm/cpu/cache.h> 12#include <asm/cpu/cache.h>
13#include <asm/cpu/cacheflush.h>
14 13
15#define SH_CACHE_VALID 1 14#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2 15#define SH_CACHE_UPDATED 2
@@ -23,24 +22,31 @@
23#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1)) 22#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1))
24 23
25struct cache_info { 24struct cache_info {
26 unsigned int ways; 25 unsigned int ways; /* Number of cache ways */
27 unsigned int sets; 26 unsigned int sets; /* Number of cache sets */
28 unsigned int linesz; 27 unsigned int linesz; /* Cache line size (bytes) */
29 28
30 unsigned int way_incr; 29 unsigned int way_size; /* sets * line size */
31 30
31 /*
32 * way_incr is the address offset for accessing the next way
33 * in memory mapped cache array ops.
34 */
35 unsigned int way_incr;
32 unsigned int entry_shift; 36 unsigned int entry_shift;
33 unsigned int entry_mask; 37 unsigned int entry_mask;
34 38
39 /*
40 * Compute a mask which selects the address bits which overlap between
41 * 1. those used to select the cache set during indexing
42 * 2. those in the physical page number.
43 */
44 unsigned int alias_mask;
45
46 unsigned int n_aliases; /* Number of aliases */
47
35 unsigned long flags; 48 unsigned long flags;
36}; 49};
37 50
38/* Flush (write-back only) a region (smaller than a page) */
39extern void __flush_wback_region(void *start, int size);
40/* Flush (write-back & invalidate) a region (smaller than a page) */
41extern void __flush_purge_region(void *start, int size);
42/* Flush (invalidate only) a region (smaller than a page) */
43extern void __flush_invalidate_region(void *start, int size);
44
45#endif /* __KERNEL__ */ 51#endif /* __KERNEL__ */
46#endif /* __ASM_SH_CACHE_H */ 52#endif /* __ASM_SH_CACHE_H */
diff --git a/include/asm-sh/cacheflush.h b/include/asm-sh/cacheflush.h
index 9dfb33edb008..07f62ec9ff0c 100644
--- a/include/asm-sh/cacheflush.h
+++ b/include/asm-sh/cacheflush.h
@@ -2,6 +2,7 @@
2#define __ASM_SH_CACHEFLUSH_H 2#define __ASM_SH_CACHEFLUSH_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/mm.h>
5#include <asm/cpu/cacheflush.h> 6#include <asm/cpu/cacheflush.h>
6 7
7/* Flush (write-back only) a region (smaller than a page) */ 8/* Flush (write-back only) a region (smaller than a page) */
@@ -27,5 +28,7 @@ extern void __flush_invalidate_region(void *start, int size);
27 memcpy(dst, src, len); \ 28 memcpy(dst, src, len); \
28 } while (0) 29 } while (0)
29 30
31#define HAVE_ARCH_UNMAPPED_AREA
32
30#endif /* __KERNEL__ */ 33#endif /* __KERNEL__ */
31#endif /* __ASM_SH_CACHEFLUSH_H */ 34#endif /* __ASM_SH_CACHEFLUSH_H */
diff --git a/include/asm-sh/cat68701/io.h b/include/asm-sh/cat68701/io.h
deleted file mode 100644
index 753b8466ad11..000000000000
--- a/include/asm-sh/cat68701/io.h
+++ /dev/null
@@ -1,22 +0,0 @@
1/*
2 * include/asm-sh/io_cat68701.h
3 *
4 * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
5 * 2001 Yutarou Ebihar (ebihara@si-linux.com)
6 *
7 * May be copied or modified under the terms of the GNU General Public
8 * License. See linux/COPYING for more information.
9 *
10 * IO functions for an AONE Corp. CAT-68701 SH7708 Borad
11 */
12
13#ifndef _ASM_SH_IO_CAT68701_H
14#define _ASM_SH_IO_CAT68701_H
15
16extern unsigned long cat68701_isa_port2addr(unsigned long offset);
17extern int cat68701_irq_demux(int irq);
18
19extern void init_cat68701_IRQ(void);
20extern void heartbeat_cat68701(void);
21
22#endif /* _ASM_SH_IO_CAT68701_H */
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
index fa03b30c4269..08168afe6746 100644
--- a/include/asm-sh/checksum.h
+++ b/include/asm-sh/checksum.h
@@ -159,6 +159,7 @@ static __inline__ unsigned short ip_compute_csum(unsigned char * buff, int len)
159} 159}
160 160
161#define _HAVE_ARCH_IPV6_CSUM 161#define _HAVE_ARCH_IPV6_CSUM
162#ifdef CONFIG_IPV6
162static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, 163static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
163 struct in6_addr *daddr, 164 struct in6_addr *daddr,
164 __u32 len, 165 __u32 len,
@@ -194,6 +195,7 @@ static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr,
194 195
195 return csum_fold(sum); 196 return csum_fold(sum);
196} 197}
198#endif
197 199
198/* 200/*
199 * Copy and checksum to user 201 * Copy and checksum to user
diff --git a/include/asm-sh/cpu-features.h b/include/asm-sh/cpu-features.h
new file mode 100644
index 000000000000..4bccd7c032f9
--- /dev/null
+++ b/include/asm-sh/cpu-features.h
@@ -0,0 +1,24 @@
1#ifndef __ASM_SH_CPU_FEATURES_H
2#define __ASM_SH_CPU_FEATURES_H
3
4/*
5 * Processor flags
6 *
7 * Note: When adding a new flag, keep cpu_flags[] in
8 * arch/sh/kernel/setup.c in sync so symbolic name
9 * mapping of the processor flags has a chance of being
10 * reasonably accurate.
11 *
12 * These flags are also available through the ELF
13 * auxiliary vector as AT_HWCAP.
14 */
15#define CPU_HAS_FPU 0x0001 /* Hardware FPU support */
16#define CPU_HAS_P2_FLUSH_BUG 0x0002 /* Need to flush the cache in P2 area */
17#define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */
18#define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */
19#define CPU_HAS_PERF_COUNTER 0x0010 /* Hardware performance counters */
20#define CPU_HAS_PTEA 0x0020 /* PTEA register */
21#define CPU_HAS_LLSC 0x0040 /* movli.l/movco.l */
22#define CPU_HAS_L2_CACHE 0x0080 /* Secondary cache / URAM */
23
24#endif /* __ASM_SH_CPU_FEATURES_H */
diff --git a/include/asm-sh/cpu-sh2/shmparam.h b/include/asm-sh/cpu-sh2/shmparam.h
deleted file mode 100644
index 817c1821ee4b..000000000000
--- a/include/asm-sh/cpu-sh2/shmparam.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-sh/cpu-sh2/shmparam.h
3 *
4 * Copyright (C) 2003 Paul Mundt
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#ifndef __ASM_CPU_SH2_SHMPARAM_H
11#define __ASM_CPU_SH2_SHMPARAM_H
12
13#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
14
15#endif /* __ASM_CPU_SH2_SHMPARAM_H */
16
diff --git a/include/asm-sh/cpu-sh3/cache.h b/include/asm-sh/cpu-sh3/cache.h
index 406aa8d9b947..ffe08d2813f9 100644
--- a/include/asm-sh/cpu-sh3/cache.h
+++ b/include/asm-sh/cpu-sh3/cache.h
@@ -26,12 +26,10 @@
26#define CCR_CACHE_ENABLE CCR_CACHE_CE 26#define CCR_CACHE_ENABLE CCR_CACHE_CE
27#define CCR_CACHE_INVALIDATE CCR_CACHE_CF 27#define CCR_CACHE_INVALIDATE CCR_CACHE_CF
28 28
29#if defined(CONFIG_CPU_SUBTYPE_SH7705) 29#if defined(CONFIG_CPU_SUBTYPE_SH7705) || defined(CONFIG_CPU_SUBTYPE_SH7710)
30#define CCR3 0xa40000b4 30#define CCR3 0xa40000b4
31#define CCR_CACHE_16KB 0x00010000 31#define CCR_CACHE_16KB 0x00010000
32#define CCR_CACHE_32KB 0x00020000 32#define CCR_CACHE_32KB 0x00020000
33#endif 33#endif
34 34
35
36#endif /* __ASM_CPU_SH3_CACHE_H */ 35#endif /* __ASM_CPU_SH3_CACHE_H */
37
diff --git a/include/asm-sh/cpu-sh3/cacheflush.h b/include/asm-sh/cpu-sh3/cacheflush.h
index f51aed00c68f..03fde97a7fd0 100644
--- a/include/asm-sh/cpu-sh3/cacheflush.h
+++ b/include/asm-sh/cpu-sh3/cacheflush.h
@@ -10,7 +10,7 @@
10#ifndef __ASM_CPU_SH3_CACHEFLUSH_H 10#ifndef __ASM_CPU_SH3_CACHEFLUSH_H
11#define __ASM_CPU_SH3_CACHEFLUSH_H 11#define __ASM_CPU_SH3_CACHEFLUSH_H
12 12
13/* 13/*
14 * Cache flushing: 14 * Cache flushing:
15 * 15 *
16 * - flush_cache_all() flushes entire cache 16 * - flush_cache_all() flushes entire cache
@@ -35,53 +35,33 @@
35 /* 32KB cache, 4kb PAGE sizes need to check bit 12 */ 35 /* 32KB cache, 4kb PAGE sizes need to check bit 12 */
36#define CACHE_ALIAS 0x00001000 36#define CACHE_ALIAS 0x00001000
37 37
38struct page;
39struct mm_struct;
40struct vm_area_struct;
41
42extern void flush_cache_all(void);
43extern void flush_cache_mm(struct mm_struct *mm);
44extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
45 unsigned long end);
46extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
47extern void flush_dcache_page(struct page *pg);
48extern void flush_icache_range(unsigned long start, unsigned long end);
49extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
50
51#define flush_dcache_mmap_lock(mapping) do { } while (0)
52#define flush_dcache_mmap_unlock(mapping) do { } while (0)
53
54/* SH3 has unified cache so no special action needed here */
55#define flush_cache_sigtramp(vaddr) do { } while (0)
56#define flush_page_to_ram(page) do { } while (0)
57#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
58
59#define p3_cache_init() do { } while (0)
60
61#define PG_mapped PG_arch_1 38#define PG_mapped PG_arch_1
62 39
63/* We provide our own get_unmapped_area to avoid cache alias issue */ 40void flush_cache_all(void);
64#define HAVE_ARCH_UNMAPPED_AREA 41void flush_cache_mm(struct mm_struct *mm);
65 42void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
43 unsigned long end);
44void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
45void flush_dcache_page(struct page *pg);
46void flush_icache_range(unsigned long start, unsigned long end);
47void flush_icache_page(struct vm_area_struct *vma, struct page *page);
66#else 48#else
67
68#define flush_cache_all() do { } while (0) 49#define flush_cache_all() do { } while (0)
69#define flush_cache_mm(mm) do { } while (0) 50#define flush_cache_mm(mm) do { } while (0)
70#define flush_cache_range(vma, start, end) do { } while (0) 51#define flush_cache_range(vma, start, end) do { } while (0)
71#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) 52#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
72#define flush_dcache_page(page) do { } while (0) 53#define flush_dcache_page(page) do { } while (0)
73#define flush_dcache_mmap_lock(mapping) do { } while (0)
74#define flush_dcache_mmap_unlock(mapping) do { } while (0)
75#define flush_icache_range(start, end) do { } while (0) 54#define flush_icache_range(start, end) do { } while (0)
76#define flush_icache_page(vma,pg) do { } while (0) 55#define flush_icache_page(vma,pg) do { } while (0)
77#define flush_icache_user_range(vma,pg,adr,len) do { } while (0) 56#endif
78#define flush_cache_sigtramp(vaddr) do { } while (0)
79 57
80#define p3_cache_init() do { } while (0) 58#define flush_dcache_mmap_lock(mapping) do { } while (0)
59#define flush_dcache_mmap_unlock(mapping) do { } while (0)
81 60
82#define HAVE_ARCH_UNMAPPED_AREA 61/* SH3 has unified cache so no special action needed here */
62#define flush_cache_sigtramp(vaddr) do { } while (0)
63#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
83 64
84#endif 65#define p3_cache_init() do { } while (0)
85 66
86#endif /* __ASM_CPU_SH3_CACHEFLUSH_H */ 67#endif /* __ASM_CPU_SH3_CACHEFLUSH_H */
87
diff --git a/include/asm-sh/cpu-sh3/freq.h b/include/asm-sh/cpu-sh3/freq.h
index b61b6e331df0..273f3229785c 100644
--- a/include/asm-sh/cpu-sh3/freq.h
+++ b/include/asm-sh/cpu-sh3/freq.h
@@ -18,5 +18,9 @@
18#define MIN_DIVISOR_NR 0 18#define MIN_DIVISOR_NR 0
19#define MAX_DIVISOR_NR 4 19#define MAX_DIVISOR_NR 4
20 20
21#define FRQCR_CKOEN 0x0100
22#define FRQCR_PLLEN 0x0080
23#define FRQCR_PSTBY 0x0040
24
21#endif /* __ASM_CPU_SH3_FREQ_H */ 25#endif /* __ASM_CPU_SH3_FREQ_H */
22 26
diff --git a/include/asm-sh/cpu-sh3/mmu_context.h b/include/asm-sh/cpu-sh3/mmu_context.h
index a844ea0965b6..bccb7ddb438b 100644
--- a/include/asm-sh/cpu-sh3/mmu_context.h
+++ b/include/asm-sh/cpu-sh3/mmu_context.h
@@ -27,8 +27,12 @@
27#define TRA 0xffffffd0 27#define TRA 0xffffffd0
28#define EXPEVT 0xffffffd4 28#define EXPEVT 0xffffffd4
29 29
30#if defined(CONFIG_CPU_SUBTYPE_SH7707) || defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 30#if defined(CONFIG_CPU_SUBTYPE_SH7707) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7705) 31 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
33 defined(CONFIG_CPU_SUBTYPE_SH7300) || \
34 defined(CONFIG_CPU_SUBTYPE_SH7705) || \
35 defined(CONFIG_CPU_SUBTYPE_SH7710)
32#define INTEVT 0xa4000000 /* INTEVTE2(0xa4000000) */ 36#define INTEVT 0xa4000000 /* INTEVTE2(0xa4000000) */
33#else 37#else
34#define INTEVT 0xffffffd8 38#define INTEVT 0xffffffd8
diff --git a/include/asm-sh/cpu-sh3/shmparam.h b/include/asm-sh/cpu-sh3/shmparam.h
deleted file mode 100644
index da5b5eec81ee..000000000000
--- a/include/asm-sh/cpu-sh3/shmparam.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-sh/cpu-sh3/shmparam.h
3 *
4 * Copyright (C) 1999 Niibe Yutaka
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#ifndef __ASM_CPU_SH3_SHMPARAM_H
11#define __ASM_CPU_SH3_SHMPARAM_H
12
13#define SHMLBA PAGE_SIZE /* attach addr a multiple of this */
14
15#endif /* __ASM_CPU_SH3_SHMPARAM_H */
16
diff --git a/include/asm-sh/cpu-sh3/timer.h b/include/asm-sh/cpu-sh3/timer.h
index 3d8e95e8d10c..b2394cf76f49 100644
--- a/include/asm-sh/cpu-sh3/timer.h
+++ b/include/asm-sh/cpu-sh3/timer.h
@@ -20,9 +20,14 @@
20 * SH7710 20 * SH7710
21 * SH7720 21 * SH7720
22 * SH7300 22 * SH7300
23 * SH7710
23 * --------------------------------------------------------------------------- 24 * ---------------------------------------------------------------------------
24 */ 25 */
25 26
27#if !defined(CONFIG_CPU_SUBTYPE_SH7727)
28#define TMU_TOCR 0xfffffe90 /* Byte access */
29#endif
30
26#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7710) 31#if defined(CONFIG_CPU_SUBTYPE_SH7300) || defined(CONFIG_CPU_SUBTYPE_SH7710)
27#define TMU_TSTR 0xa412fe92 /* Byte access */ 32#define TMU_TSTR 0xa412fe92 /* Byte access */
28 33
@@ -39,9 +44,6 @@
39#define TMU2_TCR 0xa412feb4 /* Word access */ 44#define TMU2_TCR 0xa412feb4 /* Word access */
40 45
41#else 46#else
42#if !defined(CONFIG_CPU_SUBTYPE_SH7727)
43#define TMU_TOCR 0xfffffe90 /* Byte access */
44#endif
45#define TMU_TSTR 0xfffffe92 /* Byte access */ 47#define TMU_TSTR 0xfffffe92 /* Byte access */
46 48
47#define TMU0_TCOR 0xfffffe94 /* Long access */ 49#define TMU0_TCOR 0xfffffe94 /* Long access */
diff --git a/include/asm-sh/cpu-sh3/ubc.h b/include/asm-sh/cpu-sh3/ubc.h
index 0f809dec4e17..9d308cbe9b29 100644
--- a/include/asm-sh/cpu-sh3/ubc.h
+++ b/include/asm-sh/cpu-sh3/ubc.h
@@ -11,6 +11,19 @@
11#ifndef __ASM_CPU_SH3_UBC_H 11#ifndef __ASM_CPU_SH3_UBC_H
12#define __ASM_CPU_SH3_UBC_H 12#define __ASM_CPU_SH3_UBC_H
13 13
14#if defined(CONFIG_CPU_SUBTYPE_SH7710)
15#define UBC_BARA 0xa4ffffb0
16#define UBC_BAMRA 0xa4ffffb4
17#define UBC_BBRA 0xa4ffffb8
18#define UBC_BASRA 0xffffffe4
19#define UBC_BARB 0xa4ffffa0
20#define UBC_BAMRB 0xa4ffffa4
21#define UBC_BBRB 0xa4ffffa8
22#define UBC_BASRB 0xffffffe8
23#define UBC_BDRB 0xa4ffff90
24#define UBC_BDMRB 0xa4ffff94
25#define UBC_BRCR 0xa4ffff98
26#else
14#define UBC_BARA 0xffffffb0 27#define UBC_BARA 0xffffffb0
15#define UBC_BAMRA 0xffffffb4 28#define UBC_BAMRA 0xffffffb4
16#define UBC_BBRA 0xffffffb8 29#define UBC_BBRA 0xffffffb8
@@ -22,6 +35,6 @@
22#define UBC_BDRB 0xffffff90 35#define UBC_BDRB 0xffffff90
23#define UBC_BDMRB 0xffffff94 36#define UBC_BDMRB 0xffffff94
24#define UBC_BRCR 0xffffff98 37#define UBC_BRCR 0xffffff98
38#endif
25 39
26#endif /* __ASM_CPU_SH3_UBC_H */ 40#endif /* __ASM_CPU_SH3_UBC_H */
27
diff --git a/include/asm-sh/cpu-sh4/addrspace.h b/include/asm-sh/cpu-sh4/addrspace.h
index 727634d886ce..bb2e1b03060c 100644
--- a/include/asm-sh/cpu-sh4/addrspace.h
+++ b/include/asm-sh/cpu-sh4/addrspace.h
@@ -22,5 +22,8 @@
22#define P4SEG_TLB_DATA 0xf7000000 22#define P4SEG_TLB_DATA 0xf7000000
23#define P4SEG_REG_BASE 0xff000000 23#define P4SEG_REG_BASE 0xff000000
24 24
25#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
26#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
27
25#endif /* __ASM_CPU_SH4_ADDRSPACE_H */ 28#endif /* __ASM_CPU_SH4_ADDRSPACE_H */
26 29
diff --git a/include/asm-sh/cpu-sh4/cache.h b/include/asm-sh/cpu-sh4/cache.h
index 1fe20359312c..6e9c7e6ee8e4 100644
--- a/include/asm-sh/cpu-sh4/cache.h
+++ b/include/asm-sh/cpu-sh4/cache.h
@@ -22,7 +22,9 @@
22#define CCR_CACHE_ICE 0x0100 /* Instruction Cache Enable */ 22#define CCR_CACHE_ICE 0x0100 /* Instruction Cache Enable */
23#define CCR_CACHE_ICI 0x0800 /* IC Invalidate */ 23#define CCR_CACHE_ICI 0x0800 /* IC Invalidate */
24#define CCR_CACHE_IIX 0x8000 /* IC Index Enable */ 24#define CCR_CACHE_IIX 0x8000 /* IC Index Enable */
25#ifndef CONFIG_CPU_SUBTYPE_SH7780
25#define CCR_CACHE_EMODE 0x80000000 /* EMODE Enable */ 26#define CCR_CACHE_EMODE 0x80000000 /* EMODE Enable */
27#endif
26 28
27/* Default CCR setup: 8k+16k-byte cache,P1-wb,enable */ 29/* Default CCR setup: 8k+16k-byte cache,P1-wb,enable */
28#define CCR_CACHE_ENABLE (CCR_CACHE_OCE|CCR_CACHE_ICE) 30#define CCR_CACHE_ENABLE (CCR_CACHE_OCE|CCR_CACHE_ICE)
diff --git a/include/asm-sh/cpu-sh4/cacheflush.h b/include/asm-sh/cpu-sh4/cacheflush.h
index f323567e085f..515fd574267c 100644
--- a/include/asm-sh/cpu-sh4/cacheflush.h
+++ b/include/asm-sh/cpu-sh4/cacheflush.h
@@ -16,40 +16,29 @@
16 * caching; in which case they're only semi-broken), 16 * caching; in which case they're only semi-broken),
17 * so we need them. 17 * so we need them.
18 */ 18 */
19 19void flush_cache_all(void);
20/* Page is 4K, OC size is 16K, there are four lines. */ 20void flush_cache_mm(struct mm_struct *mm);
21#define CACHE_ALIAS 0x00003000 21void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
22 22 unsigned long end);
23struct page; 23void flush_cache_page(struct vm_area_struct *vma, unsigned long addr,
24struct mm_struct; 24 unsigned long pfn);
25struct vm_area_struct; 25void flush_dcache_page(struct page *pg);
26
27extern void flush_cache_all(void);
28extern void flush_cache_mm(struct mm_struct *mm);
29extern void flush_cache_range(struct vm_area_struct *vma, unsigned long start,
30 unsigned long end);
31extern void flush_cache_page(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn);
32extern void flush_dcache_page(struct page *pg);
33 26
34#define flush_dcache_mmap_lock(mapping) do { } while (0) 27#define flush_dcache_mmap_lock(mapping) do { } while (0)
35#define flush_dcache_mmap_unlock(mapping) do { } while (0) 28#define flush_dcache_mmap_unlock(mapping) do { } while (0)
36 29
37extern void flush_icache_range(unsigned long start, unsigned long end); 30void flush_icache_range(unsigned long start, unsigned long end);
38extern void flush_cache_sigtramp(unsigned long addr); 31void flush_cache_sigtramp(unsigned long addr);
39extern void flush_icache_user_range(struct vm_area_struct *vma, 32void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
40 struct page *page, unsigned long addr, 33 unsigned long addr, int len);
41 int len);
42 34
43#define flush_icache_page(vma,pg) do { } while (0) 35#define flush_icache_page(vma,pg) do { } while (0)
44 36
45/* Initialization of P3 area for copy_user_page */ 37/* Initialization of P3 area for copy_user_page */
46extern void p3_cache_init(void); 38void p3_cache_init(void);
47 39
48#define PG_mapped PG_arch_1 40#define PG_mapped PG_arch_1
49 41
50/* We provide our own get_unmapped_area to avoid cache alias issue */
51#define HAVE_ARCH_UNMAPPED_AREA
52
53#ifdef CONFIG_MMU 42#ifdef CONFIG_MMU
54extern int remap_area_pages(unsigned long addr, unsigned long phys_addr, 43extern int remap_area_pages(unsigned long addr, unsigned long phys_addr,
55 unsigned long size, unsigned long flags); 44 unsigned long size, unsigned long flags);
@@ -61,4 +50,3 @@ static inline int remap_area_pages(unsigned long addr, unsigned long phys_addr,
61} 50}
62#endif /* CONFIG_MMU */ 51#endif /* CONFIG_MMU */
63#endif /* __ASM_CPU_SH4_CACHEFLUSH_H */ 52#endif /* __ASM_CPU_SH4_CACHEFLUSH_H */
64
diff --git a/include/asm-sh/cpu-sh4/dma-sh7780.h b/include/asm-sh/cpu-sh4/dma-sh7780.h
new file mode 100644
index 000000000000..6c90d28331b2
--- /dev/null
+++ b/include/asm-sh/cpu-sh4/dma-sh7780.h
@@ -0,0 +1,39 @@
1#ifndef __ASM_SH_CPU_SH4_DMA_SH7780_H
2#define __ASM_SH_CPU_SH4_DMA_SH7780_H
3
4#define REQ_HE 0x000000C0
5#define REQ_H 0x00000080
6#define REQ_LE 0x00000040
7#define TM_BURST 0x0000020
8#define TS_8 0x00000000
9#define TS_16 0x00000008
10#define TS_32 0x00000010
11#define TS_16BLK 0x00000018
12#define TS_32BLK 0x00100000
13
14/*
15 * The SuperH DMAC supports a number of transmit sizes, we list them here,
16 * with their respective values as they appear in the CHCR registers.
17 *
18 * Defaults to a 64-bit transfer size.
19 */
20enum {
21 XMIT_SZ_8BIT,
22 XMIT_SZ_16BIT,
23 XMIT_SZ_32BIT,
24 XMIT_SZ_128BIT,
25 XMIT_SZ_256BIT,
26};
27
28/*
29 * The DMA count is defined as the number of bytes to transfer.
30 */
31static unsigned int __attribute__ ((used)) ts_shift[] = {
32 [XMIT_SZ_8BIT] = 0,
33 [XMIT_SZ_16BIT] = 1,
34 [XMIT_SZ_32BIT] = 2,
35 [XMIT_SZ_128BIT] = 4,
36 [XMIT_SZ_256BIT] = 5,
37};
38
39#endif /* __ASM_SH_CPU_SH4_DMA_SH7780_H */
diff --git a/include/asm-sh/cpu-sh4/dma.h b/include/asm-sh/cpu-sh4/dma.h
index 0dfe61f14802..3e4b3e6d80c0 100644
--- a/include/asm-sh/cpu-sh4/dma.h
+++ b/include/asm-sh/cpu-sh4/dma.h
@@ -1,11 +1,17 @@
1#ifndef __ASM_CPU_SH4_DMA_H 1#ifndef __ASM_CPU_SH4_DMA_H
2#define __ASM_CPU_SH4_DMA_H 2#define __ASM_CPU_SH4_DMA_H
3 3
4#define DMAOR_INIT ( 0x8000 | DMAOR_DME )
5
4#ifdef CONFIG_CPU_SH4A 6#ifdef CONFIG_CPU_SH4A
5#define SH_DMAC_BASE 0xfc808020 7#define SH_DMAC_BASE 0xfc808020
8
9#define CHCR_TS_MASK 0x18
10#define CHCR_TS_SHIFT 3
11
12#include <asm/cpu/dma-sh7780.h>
6#else 13#else
7#define SH_DMAC_BASE 0xffa00000 14#define SH_DMAC_BASE 0xffa00000
8#endif
9 15
10/* Definitions for the SuperH DMAC */ 16/* Definitions for the SuperH DMAC */
11#define TM_BURST 0x0000080 17#define TM_BURST 0x0000080
@@ -19,8 +25,6 @@
19 25
20#define DMAOR_COD 0x00000008 26#define DMAOR_COD 0x00000008
21 27
22#define DMAOR_INIT ( 0x8000 | DMAOR_DME )
23
24/* 28/*
25 * The SuperH DMAC supports a number of transmit sizes, we list them here, 29 * The SuperH DMAC supports a number of transmit sizes, we list them here,
26 * with their respective values as they appear in the CHCR registers. 30 * with their respective values as they appear in the CHCR registers.
@@ -45,5 +49,6 @@ static unsigned int ts_shift[] __attribute__ ((used)) = {
45 [XMIT_SZ_32BIT] = 2, 49 [XMIT_SZ_32BIT] = 2,
46 [XMIT_SZ_256BIT] = 5, 50 [XMIT_SZ_256BIT] = 5,
47}; 51};
52#endif
48 53
49#endif /* __ASM_CPU_SH4_DMA_H */ 54#endif /* __ASM_CPU_SH4_DMA_H */
diff --git a/include/asm-sh/cpu-sh4/shmparam.h b/include/asm-sh/cpu-sh4/shmparam.h
deleted file mode 100644
index a5a0aa9425fe..000000000000
--- a/include/asm-sh/cpu-sh4/shmparam.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * include/asm-sh/cpu-sh4/shmparam.h
3 *
4 * Copyright (C) 1999 Niibe Yutaka
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#ifndef __ASM_CPU_SH4_SHMPARAM_H
11#define __ASM_CPU_SH4_SHMPARAM_H
12
13/*
14 * SH-4 has D-cache alias issue
15 */
16#define SHMLBA (PAGE_SIZE*4) /* attach addr a multiple of this */
17
18#endif /* __ASM_CPU_SH4_SHMPARAM_H */
19
diff --git a/include/asm-sh/cpu-sh4/sq.h b/include/asm-sh/cpu-sh4/sq.h
index 366b09166d3b..586d6491816a 100644
--- a/include/asm-sh/cpu-sh4/sq.h
+++ b/include/asm-sh/cpu-sh4/sq.h
@@ -17,7 +17,7 @@
17 * Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be 17 * Store queues range from e0000000-e3fffffc, allowing approx. 64MB to be
18 * mapped to any physical address space. Since data is written (and aligned) 18 * mapped to any physical address space. Since data is written (and aligned)
19 * to 32-byte boundaries, we need to be sure that all allocations are aligned. 19 * to 32-byte boundaries, we need to be sure that all allocations are aligned.
20 */ 20 */
21#define SQ_SIZE 32 21#define SQ_SIZE 32
22#define SQ_ALIGN_MASK (~(SQ_SIZE - 1)) 22#define SQ_ALIGN_MASK (~(SQ_SIZE - 1))
23#define SQ_ALIGN(addr) (((addr)+SQ_SIZE-1) & SQ_ALIGN_MASK) 23#define SQ_ALIGN(addr) (((addr)+SQ_SIZE-1) & SQ_ALIGN_MASK)
@@ -26,23 +26,10 @@
26#define SQ_QACR1 (P4SEG_REG_BASE + 0x3c) 26#define SQ_QACR1 (P4SEG_REG_BASE + 0x3c)
27#define SQ_ADDRMAX (P4SEG_STORE_QUE + 0x04000000) 27#define SQ_ADDRMAX (P4SEG_STORE_QUE + 0x04000000)
28 28
29struct sq_mapping {
30 const char *name;
31
32 unsigned long sq_addr;
33 unsigned long addr;
34 unsigned int size;
35
36 struct list_head list;
37};
38
39/* arch/sh/kernel/cpu/sh4/sq.c */ 29/* arch/sh/kernel/cpu/sh4/sq.c */
40extern struct sq_mapping *sq_remap(unsigned long phys, unsigned int size, const char *name); 30unsigned long sq_remap(unsigned long phys, unsigned int size,
41extern void sq_unmap(struct sq_mapping *map); 31 const char *name, unsigned long flags);
42 32void sq_unmap(unsigned long vaddr);
43extern void sq_clear(unsigned long addr, unsigned int len); 33void sq_flush_range(unsigned long start, unsigned int len);
44extern void sq_flush(void *addr);
45extern void sq_flush_range(unsigned long start, unsigned int len);
46 34
47#endif /* __ASM_CPU_SH4_SQ_H */ 35#endif /* __ASM_CPU_SH4_SQ_H */
48
diff --git a/include/asm-sh/cqreek/cqreek.h b/include/asm-sh/cqreek/cqreek.h
deleted file mode 100644
index 09aecc06693e..000000000000
--- a/include/asm-sh/cqreek/cqreek.h
+++ /dev/null
@@ -1,27 +0,0 @@
1#ifndef __ASM_SH_CQREEK_CQREEK_H
2#define __ASM_SH_CQREEK_CQREEK_H
3
4#define BRIDGE_FEATURE 0x0002
5
6#define BRIDGE_IDE_CTRL 0x0018
7#define BRIDGE_IDE_INTR_LVL 0x001A
8#define BRIDGE_IDE_INTR_MASK 0x001C
9#define BRIDGE_IDE_INTR_STAT 0x001E
10
11#define BRIDGE_ISA_CTRL 0x0028
12#define BRIDGE_ISA_INTR_LVL 0x002A
13#define BRIDGE_ISA_INTR_MASK 0x002C
14#define BRIDGE_ISA_INTR_STAT 0x002E
15
16/* arch/sh/boards/cqreek/setup.c */
17extern void setup_cqreek(void);
18
19/* arch/sh/boards/cqreek/irq.c */
20extern int cqreek_has_ide, cqreek_has_isa;
21extern void init_cqreek_IRQ(void);
22
23/* arch/sh/boards/cqreek/io.c */
24extern unsigned long cqreek_port2addr(unsigned long port);
25
26#endif /* __ASM_SH_CQREEK_CQREEK_H */
27
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index 124968f9866e..56cd4b977232 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -141,25 +141,35 @@ static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg,
141 } 141 }
142} 142}
143 143
144static void dma_sync_single_for_cpu(struct device *dev, 144static inline void dma_sync_single_for_cpu(struct device *dev,
145 dma_addr_t dma_handle, size_t size, 145 dma_addr_t dma_handle, size_t size,
146 enum dma_data_direction dir) 146 enum dma_data_direction dir)
147 __attribute__ ((alias("dma_sync_single"))); 147{
148 dma_sync_single(dev, dma_handle, size, dir);
149}
150
151static inline void dma_sync_single_for_device(struct device *dev,
152 dma_addr_t dma_handle,
153 size_t size,
154 enum dma_data_direction dir)
155{
156 dma_sync_single(dev, dma_handle, size, dir);
157}
148 158
149static void dma_sync_single_for_device(struct device *dev, 159static inline void dma_sync_sg_for_cpu(struct device *dev,
150 dma_addr_t dma_handle, size_t size, 160 struct scatterlist *sg, int nelems,
151 enum dma_data_direction dir) 161 enum dma_data_direction dir)
152 __attribute__ ((alias("dma_sync_single"))); 162{
163 dma_sync_sg(dev, sg, nelems, dir);
164}
153 165
154static void dma_sync_sg_for_cpu(struct device *dev, 166static inline void dma_sync_sg_for_device(struct device *dev,
155 struct scatterlist *sg, int nelems, 167 struct scatterlist *sg, int nelems,
156 enum dma_data_direction dir) 168 enum dma_data_direction dir)
157 __attribute__ ((alias("dma_sync_sg"))); 169{
170 dma_sync_sg(dev, sg, nelems, dir);
171}
158 172
159static void dma_sync_sg_for_device(struct device *dev,
160 struct scatterlist *sg, int nelems,
161 enum dma_data_direction dir)
162 __attribute__ ((alias("dma_sync_sg")));
163 173
164static inline int dma_get_cache_alignment(void) 174static inline int dma_get_cache_alignment(void)
165{ 175{
@@ -174,6 +184,4 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
174{ 184{
175 return dma_addr == 0; 185 return dma_addr == 0;
176} 186}
177
178#endif /* __ASM_SH_DMA_MAPPING_H */ 187#endif /* __ASM_SH_DMA_MAPPING_H */
179
diff --git a/include/asm-sh/dma.h b/include/asm-sh/dma.h
index e62a6d0ed932..d9daa028689f 100644
--- a/include/asm-sh/dma.h
+++ b/include/asm-sh/dma.h
@@ -89,6 +89,7 @@ struct dma_channel {
89 wait_queue_head_t wait_queue; 89 wait_queue_head_t wait_queue;
90 90
91 struct sys_device dev; 91 struct sys_device dev;
92 char *name;
92}; 93};
93 94
94struct dma_info { 95struct dma_info {
diff --git a/include/asm-sh/dmida/io.h b/include/asm-sh/dmida/io.h
deleted file mode 100644
index 21bd416c01c3..000000000000
--- a/include/asm-sh/dmida/io.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef __ASM_SH_DMIDA_IO_H
2#define __ASM_SH_DMIDA_IO_H
3
4/*
5 * Nothing special here.. just use the generic cchip io routines.
6 */
7#include <asm/hd64465/io.h>
8
9#endif /* __ASM_SH_DMIDA_IO_H */
10
diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h
index 1b63dfeea4f2..3a07ab40ac4d 100644
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -1,6 +1,11 @@
1#ifndef __ASM_SH_ELF_H 1#ifndef __ASM_SH_ELF_H
2#define __ASM_SH_ELF_H 2#define __ASM_SH_ELF_H
3 3
4#include <asm/processor.h>
5#include <asm/auxvec.h>
6#include <asm/ptrace.h>
7#include <asm/user.h>
8
4/* SH relocation types */ 9/* SH relocation types */
5#define R_SH_NONE 0 10#define R_SH_NONE 0
6#define R_SH_DIR32 1 11#define R_SH_DIR32 1
@@ -46,9 +51,6 @@
46 * ELF register definitions.. 51 * ELF register definitions..
47 */ 52 */
48 53
49#include <asm/ptrace.h>
50#include <asm/user.h>
51
52typedef unsigned long elf_greg_t; 54typedef unsigned long elf_greg_t;
53 55
54#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t)) 56#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
@@ -91,7 +93,7 @@ typedef struct user_fpu_struct elf_fpregset_t;
91 instruction set this CPU supports. This could be done in user space, 93 instruction set this CPU supports. This could be done in user space,
92 but it's not easy, and we've already done it here. */ 94 but it's not easy, and we've already done it here. */
93 95
94#define ELF_HWCAP (0) 96#define ELF_HWCAP (boot_cpu_data.flags)
95 97
96/* This yields a string that ld.so will use to load implementation 98/* This yields a string that ld.so will use to load implementation
97 specific libraries for optimization. This is more specific in 99 specific libraries for optimization. This is more specific in
@@ -119,4 +121,24 @@ extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
119#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 121#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
120#endif 122#endif
121 123
124#ifdef CONFIG_VSYSCALL
125/* vDSO has arch_setup_additional_pages */
126#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
127struct linux_binprm;
128extern int arch_setup_additional_pages(struct linux_binprm *bprm,
129 int executable_stack);
130
131extern unsigned int vdso_enabled;
132extern void __kernel_vsyscall;
133
134#define VDSO_BASE ((unsigned long)current->mm->context.vdso)
135#define VDSO_SYM(x) (VDSO_BASE + (unsigned long)(x))
136
137#define ARCH_DLINFO \
138do { \
139 if (vdso_enabled) \
140 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \
141} while (0)
142#endif /* CONFIG_VSYSCALL */
143
122#endif /* __ASM_SH_ELF_H */ 144#endif /* __ASM_SH_ELF_H */
diff --git a/include/asm-sh/fixmap.h b/include/asm-sh/fixmap.h
index 412bccaa07e6..458e9fa59545 100644
--- a/include/asm-sh/fixmap.h
+++ b/include/asm-sh/fixmap.h
@@ -25,7 +25,7 @@
25 * addresses. The point is to have a constant address at 25 * addresses. The point is to have a constant address at
26 * compile time, but to set the physical address only 26 * compile time, but to set the physical address only
27 * in the boot process. We allocate these special addresses 27 * in the boot process. We allocate these special addresses
28 * from the end of virtual memory (0xfffff000) backwards. 28 * from the end of P3 backwards.
29 * Also this lets us do fail-safe vmalloc(), we 29 * Also this lets us do fail-safe vmalloc(), we
30 * can guarantee that these special addresses and 30 * can guarantee that these special addresses and
31 * vmalloc()-ed addresses never overlap. 31 * vmalloc()-ed addresses never overlap.
diff --git a/include/asm-sh/flat.h b/include/asm-sh/flat.h
index f29072e1c87e..0d5cc04ab005 100644
--- a/include/asm-sh/flat.h
+++ b/include/asm-sh/flat.h
@@ -13,7 +13,7 @@
13#define __ASM_SH_FLAT_H 13#define __ASM_SH_FLAT_H
14 14
15#define flat_stack_align(sp) /* nothing needed */ 15#define flat_stack_align(sp) /* nothing needed */
16#define flat_argvp_envp_on_stack() 1 16#define flat_argvp_envp_on_stack() 0
17#define flat_old_ram_flag(flags) (flags) 17#define flat_old_ram_flag(flags) (flags)
18#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) 18#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
19#define flat_get_addr_from_rp(rp, relval, flags) get_unaligned(rp) 19#define flat_get_addr_from_rp(rp, relval, flags) get_unaligned(rp)
diff --git a/include/asm-sh/harp/harp.h b/include/asm-sh/harp/harp.h
deleted file mode 100644
index b2fbcfae9940..000000000000
--- a/include/asm-sh/harp/harp.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) 2001 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 * Defintions applicable to the STMicroelectronics ST40STB1 HARP and
8 * compatible boards.
9 */
10
11#if defined(CONFIG_SH_STB1_HARP)
12
13#define EPLD_BASE 0xa0800000
14
15#define EPLD_LED (EPLD_BASE+0x000c0000)
16#define EPLD_INTSTAT0 (EPLD_BASE+0x00200000)
17#define EPLD_INTSTAT1 (EPLD_BASE+0x00240000)
18#define EPLD_INTMASK0 (EPLD_BASE+0x00280000)
19#define EPLD_INTMASK1 (EPLD_BASE+0x002c0000)
20#define EPLD_PAGEADDR (EPLD_BASE+0x00300000)
21#define EPLD_REVID1 (EPLD_BASE+0x00380000)
22#define EPLD_REVID2 (EPLD_BASE+0x003c0000)
23
24#define EPLD_LED_ON 1
25#define EPLD_LED_OFF 0
26
27#elif defined(CONFIG_SH_STB1_OVERDRIVE)
28
29#define EPLD_BASE 0xa7000000
30
31#define EPLD_REVID (EPLD_BASE+0x00000000)
32#define EPLD_LED (EPLD_BASE+0x00040000)
33#define EPLD_INTMASK0 (EPLD_BASE+0x001c0000)
34#define EPLD_INTMASK1 (EPLD_BASE+0x00200000)
35#define EPLD_INTSTAT0 (EPLD_BASE+0x00240000)
36#define EPLD_INTSTAT1 (EPLD_BASE+0x00280000)
37
38#define EPLD_LED_ON 0
39#define EPLD_LED_OFF 1
40
41#else
42#error Unknown board
43#endif
diff --git a/include/asm-sh/harp/io.h b/include/asm-sh/harp/io.h
deleted file mode 100644
index 68f39e0b39de..000000000000
--- a/include/asm-sh/harp/io.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef __ASM_SH_HARP_IO_H
2#define __ASM_SH_HARP_IO_H
3
4/*
5 * Nothing special here.. just use the generic cchip io routines.
6 */
7#include <asm/hd64465/io.h>
8
9#endif /* __ASM_SH_HARP_IO_H */
10
diff --git a/include/asm-sh/hd64461/hd64461.h b/include/asm-sh/hd64461.h
index 87f13d24c630..27e5c34e2659 100644
--- a/include/asm-sh/hd64461/hd64461.h
+++ b/include/asm-sh/hd64461.h
@@ -40,7 +40,12 @@
40#define HD64461_LCDCBAR 0x11000 40#define HD64461_LCDCBAR 0x11000
41#define HD64461_LCDCLOR 0x11002 41#define HD64461_LCDCLOR 0x11002
42#define HD64461_LCDCCR 0x11004 42#define HD64461_LCDCCR 0x11004
43#define HD64461_LCDCCR_MOFF 0x80 43#define HD64461_LCDCCR_STBACK 0x0400
44#define HD64461_LCDCCR_STREQ 0x0100
45#define HD64461_LCDCCR_MOFF 0x0080
46#define HD64461_LCDCCR_REFSEL 0x0040
47#define HD64461_LCDCCR_EPON 0x0020
48#define HD64461_LCDCCR_SPON 0x0010
44 49
45#define HD64461_LDR1 0x11010 50#define HD64461_LDR1 0x11010
46#define HD64461_LDR1_DON 0x01 51#define HD64461_LDR1_DON 0x01
@@ -54,9 +59,9 @@
54#define HD64461_LDVSPR 0x1101c 59#define HD64461_LDVSPR 0x1101c
55#define HD64461_LDR3 0x1101e 60#define HD64461_LDR3 0x1101e
56 61
57#define HD64461_CPTWAR 0x11030 62#define HD64461_CPTWAR 0x11030
58#define HD64461_CPTWDR 0x11032 63#define HD64461_CPTWDR 0x11032
59#define HD64461_CPTRAR 0x11034 64#define HD64461_CPTRAR 0x11034
60#define HD64461_CPTRDR 0x11036 65#define HD64461_CPTRDR 0x11036
61 66
62#define HD64461_GRDOR 0x11040 67#define HD64461_GRDOR 0x11040
@@ -111,7 +116,7 @@
111#define HD64461_PCCISR_BVD1 0x01 /* battery 1 */ 116#define HD64461_PCCISR_BVD1 0x01 /* battery 1 */
112 117
113#define HD64461_PCCISR_PCD_MASK 0x0c /* card detect */ 118#define HD64461_PCCISR_PCD_MASK 0x0c /* card detect */
114#define HD64461_PCCISR_BVD_MASK 0x03 /* battery voltage */ 119#define HD64461_PCCISR_BVD_MASK 0x03 /* battery voltage */
115#define HD64461_PCCISR_BVD_BATGOOD 0x03 /* battery good */ 120#define HD64461_PCCISR_BVD_BATGOOD 0x03 /* battery good */
116#define HD64461_PCCISR_BVD_BATWARN 0x01 /* battery low warning */ 121#define HD64461_PCCISR_BVD_BATWARN 0x01 /* battery low warning */
117#define HD64461_PCCISR_BVD_BATDEAD1 0x02 /* battery dead */ 122#define HD64461_PCCISR_BVD_BATDEAD1 0x02 /* battery dead */
@@ -139,11 +144,11 @@
139 144
140/* PCC Card Status Change Interrupt Enable Register */ 145/* PCC Card Status Change Interrupt Enable Register */
141#define HD64461_PCCCSCIER_CRE 0x80 /* change reset enable */ 146#define HD64461_PCCCSCIER_CRE 0x80 /* change reset enable */
142#define HD64461_PCCCSCIER_IREQE_MASK 0x60 /* IREQ enable */ 147#define HD64461_PCCCSCIER_IREQE_MASK 0x60 /* IREQ enable */
143#define HD64461_PCCCSCIER_IREQE_DISABLED 0x00 /* IREQ disabled */ 148#define HD64461_PCCCSCIER_IREQE_DISABLED 0x00 /* IREQ disabled */
144#define HD64461_PCCCSCIER_IREQE_LEVEL 0x20 /* IREQ level-triggered */ 149#define HD64461_PCCCSCIER_IREQE_LEVEL 0x20 /* IREQ level-triggered */
145#define HD64461_PCCCSCIER_IREQE_FALLING 0x40 /* IREQ falling-edge-trig */ 150#define HD64461_PCCCSCIER_IREQE_FALLING 0x40 /* IREQ falling-edge-trig */
146#define HD64461_PCCCSCIER_IREQE_RISING 0x60 /* IREQ rising-edge-trig */ 151#define HD64461_PCCCSCIER_IREQE_RISING 0x60 /* IREQ rising-edge-trig */
147 152
148#define HD64461_PCCCSCIER_SCE 0x10 /* status change enable */ 153#define HD64461_PCCCSCIER_SCE 0x10 /* status change enable */
149#define HD64461_PCCCSCIER_CDE 0x08 /* card detect change enable */ 154#define HD64461_PCCCSCIER_CDE 0x08 /* card detect change enable */
@@ -155,7 +160,6 @@
155#define HD64461_PCCSCR_VCC1 0x02 /* voltage control pin 1 */ 160#define HD64461_PCCSCR_VCC1 0x02 /* voltage control pin 1 */
156#define HD64461_PCCSCR_SWP 0x01 /* write protect */ 161#define HD64461_PCCSCR_SWP 0x01 /* write protect */
157 162
158
159#define HD64461_P0OCR 0x1202a 163#define HD64461_P0OCR 0x1202a
160#define HD64461_P1OCR 0x1202c 164#define HD64461_P1OCR 0x1202c
161#define HD64461_PGCR 0x1202e 165#define HD64461_PGCR 0x1202e
@@ -180,23 +184,25 @@
180#define HD64461_NIRR 0x15000 184#define HD64461_NIRR 0x15000
181#define HD64461_NIMR 0x15002 185#define HD64461_NIMR 0x15002
182 186
183#ifndef CONFIG_HD64461_IOBASE
184#define CONFIG_HD64461_IOBASE 0xb0000000
185#endif
186#ifndef CONFIG_HD64461_IRQ
187#define CONFIG_HD64461_IRQ 36
188#endif
189
190#define HD64461_IRQBASE OFFCHIP_IRQ_BASE 187#define HD64461_IRQBASE OFFCHIP_IRQ_BASE
191#define HD64461_IRQ_NUM 16 188#define HD64461_IRQ_NUM 16
192 189
193#define HD64461_IRQ_UART (HD64461_IRQBASE+5) 190#define HD64461_IRQ_UART (HD64461_IRQBASE+5)
194#define HD64461_IRQ_IRDA (HD64461_IRQBASE+6) 191#define HD64461_IRQ_IRDA (HD64461_IRQBASE+6)
195#define HD64461_IRQ_TMU1 (HD64461_IRQBASE+9) 192#define HD64461_IRQ_TMU1 (HD64461_IRQBASE+9)
196#define HD64461_IRQ_TMU0 (HD64461_IRQBASE+10) 193#define HD64461_IRQ_TMU0 (HD64461_IRQBASE+10)
197#define HD64461_IRQ_GPIO (HD64461_IRQBASE+11) 194#define HD64461_IRQ_GPIO (HD64461_IRQBASE+11)
198#define HD64461_IRQ_AFE (HD64461_IRQBASE+12) 195#define HD64461_IRQ_AFE (HD64461_IRQBASE+12)
199#define HD64461_IRQ_PCC1 (HD64461_IRQBASE+13) 196#define HD64461_IRQ_PCC1 (HD64461_IRQBASE+13)
200#define HD64461_IRQ_PCC0 (HD64461_IRQBASE+14) 197#define HD64461_IRQ_PCC0 (HD64461_IRQBASE+14)
198
199#define __IO_PREFIX hd64461
200#include <asm/io_generic.h>
201
202/* arch/sh/cchips/hd6446x/hd64461/setup.c */
203int hd64461_irq_demux(int irq);
204void hd64461_register_irq_demux(int irq,
205 int (*demux) (int irq, void *dev), void *dev);
206void hd64461_unregister_irq_demux(int irq);
201 207
202#endif 208#endif
diff --git a/include/asm-sh/hd64461/io.h b/include/asm-sh/hd64461/io.h
deleted file mode 100644
index 67f2489088d9..000000000000
--- a/include/asm-sh/hd64461/io.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * include/asm-sh/io_hd64461.h
3 *
4 * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * IO functions for an HD64461
10 */
11
12#ifndef _ASM_SH_IO_HD64461_H
13#define _ASM_SH_IO_HD64461_H
14
15extern unsigned char hd64461_inb(unsigned long port);
16extern unsigned short hd64461_inw(unsigned long port);
17extern unsigned int hd64461_inl(unsigned long port);
18
19extern void hd64461_outb(unsigned char value, unsigned long port);
20extern void hd64461_outw(unsigned short value, unsigned long port);
21extern void hd64461_outl(unsigned int value, unsigned long port);
22
23extern unsigned char hd64461_inb_p(unsigned long port);
24extern void hd64461_outb_p(unsigned char value, unsigned long port);
25
26extern void hd64461_insb(unsigned long port, void *addr, unsigned long count);
27extern void hd64461_insw(unsigned long port, void *addr, unsigned long count);
28extern void hd64461_insl(unsigned long port, void *addr, unsigned long count);
29
30extern void hd64461_outsb(unsigned long port, const void *buffer, unsigned long count);
31extern void hd64461_outsw(unsigned long port, const void *buffer, unsigned long count);
32extern void hd64461_outsl(unsigned long port, const void *buffer, unsigned long count);
33
34extern unsigned short hd64461_readw(unsigned long addr);
35extern void hd64461_writew(unsigned short b, unsigned long addr);
36
37
38extern int hd64461_irq_demux(int irq);
39extern void hd64461_register_irq_demux(int irq,
40 int (*demux)(int irq, void *dev), void *dev);
41extern void hd64461_unregister_irq_demux(int irq);
42
43#endif /* _ASM_SH_IO_HD64461_H */
diff --git a/include/asm-sh/hp6xx/hp6xx.h b/include/asm-sh/hp6xx/hp6xx.h
index a26247fd3d87..f35134c159dd 100644
--- a/include/asm-sh/hp6xx/hp6xx.h
+++ b/include/asm-sh/hp6xx/hp6xx.h
@@ -2,16 +2,33 @@
2#define __ASM_SH_HP6XX_H 2#define __ASM_SH_HP6XX_H
3 3
4/* 4/*
5 * Copyright (C) 2003 Andriy Skulysh 5 * Copyright (C) 2003, 2004, 2005 Andriy Skulysh
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
6 */ 11 */
7 12
8#define HP680_TS_IRQ IRQ3_IRQ 13#define HP680_BTN_IRQ IRQ0_IRQ
14#define HP680_TS_IRQ IRQ3_IRQ
15#define HP680_HD64461_IRQ IRQ4_IRQ
9 16
10#define DAC_LCD_BRIGHTNESS 0 17#define DAC_LCD_BRIGHTNESS 0
11#define DAC_SPEAKER_VOLUME 1 18#define DAC_SPEAKER_VOLUME 1
12 19
20#define PGDR_OPENED 0x01
21#define PGDR_MAIN_BATTERY_OUT 0x04
22#define PGDR_PLAY_BUTTON 0x08
23#define PGDR_REWIND_BUTTON 0x10
24#define PGDR_RECORD_BUTTON 0x20
25
13#define PHDR_TS_PEN_DOWN 0x08 26#define PHDR_TS_PEN_DOWN 0x08
14 27
28#define PJDR_LED_BLINK 0x02
29
30#define PKDR_LED_GREEN 0x10
31
15#define SCPDR_TS_SCAN_ENABLE 0x20 32#define SCPDR_TS_SCAN_ENABLE 0x20
16#define SCPDR_TS_SCAN_Y 0x02 33#define SCPDR_TS_SCAN_Y 0x02
17#define SCPDR_TS_SCAN_X 0x01 34#define SCPDR_TS_SCAN_X 0x01
@@ -21,11 +38,43 @@
21 38
22#define ADC_CHANNEL_TS_Y 1 39#define ADC_CHANNEL_TS_Y 1
23#define ADC_CHANNEL_TS_X 2 40#define ADC_CHANNEL_TS_X 2
41#define ADC_CHANNEL_BATTERY 3
42#define ADC_CHANNEL_BACKUP 4
43#define ADC_CHANNEL_CHARGE 5
24 44
25#define HD64461_GPADR_SPEAKER 0x01 45#define HD64461_GPADR_SPEAKER 0x01
26#define HD64461_GPADR_PCMCIA0 (0x02|0x08) 46#define HD64461_GPADR_PCMCIA0 (0x02|0x08)
47
27#define HD64461_GPBDR_LCDOFF 0x01 48#define HD64461_GPBDR_LCDOFF 0x01
49#define HD64461_GPBDR_LCD_CONTRAST_MASK 0x78
28#define HD64461_GPBDR_LED_RED 0x80 50#define HD64461_GPBDR_LED_RED 0x80
29 51
52#include <asm/hd64461.h>
53#include <asm/io.h>
54
55#define PJDR 0xa4000130
56#define PKDR 0xa4000132
57
58static inline void hp6xx_led_red(int on)
59{
60 u16 v16;
61 v16 = ctrl_inw(CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
62 if (on)
63 ctrl_outw(v16 & (~HD64461_GPBDR_LED_RED), CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
64 else
65 ctrl_outw(v16 | HD64461_GPBDR_LED_RED, CONFIG_HD64461_IOBASE + HD64461_GPBDR - 0x10000);
66}
67
68static inline void hp6xx_led_green(int on)
69{
70 u8 v8;
71
72 v8 = ctrl_inb(PKDR);
73 if (on)
74 ctrl_outb(v8 & (~PKDR_LED_GREEN), PKDR);
75 else
76 ctrl_outb(v8 | PKDR_LED_GREEN, PKDR);
77}
78
30 79
31#endif /* __ASM_SH_HP6XX_H */ 80#endif /* __ASM_SH_HP6XX_H */
diff --git a/include/asm-sh/hp6xx/io.h b/include/asm-sh/hp6xx/io.h
index 731798003550..2044476ab199 100644
--- a/include/asm-sh/hp6xx/io.h
+++ b/include/asm-sh/hp6xx/io.h
@@ -4,7 +4,7 @@
4/* 4/*
5 * Nothing special here.. just use the generic cchip io routines. 5 * Nothing special here.. just use the generic cchip io routines.
6 */ 6 */
7#include <asm/hd64461/io.h> 7#include <asm/hd64461.h>
8 8
9#endif /* __ASM_SH_HP6XX_IO_H */ 9#endif /* __ASM_SH_HP6XX_IO_H */
10 10
diff --git a/include/asm-sh/hs7751rvoip/hs7751rvoip.h b/include/asm-sh/hs7751rvoip/hs7751rvoip.h
index 5f995f937a44..c4cff9d33927 100644
--- a/include/asm-sh/hs7751rvoip/hs7751rvoip.h
+++ b/include/asm-sh/hs7751rvoip/hs7751rvoip.h
@@ -19,8 +19,6 @@
19#define PA_OUTPORTR 0xa400000e /* Output Port Reguster */ 19#define PA_OUTPORTR 0xa400000e /* Output Port Reguster */
20#define PA_VERREG 0xa4000014 /* FPGA Version Register */ 20#define PA_VERREG 0xa4000014 /* FPGA Version Register */
21 21
22#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
23#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
24#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */ 22#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
25 23
26#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */ 24#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
@@ -44,4 +42,13 @@
44#define IRQ_RINGING 4 /* Ringing IRQ */ 42#define IRQ_RINGING 4 /* Ringing IRQ */
45#define IRQ_CODEC 5 /* CODEC IRQ */ 43#define IRQ_CODEC 5 /* CODEC IRQ */
46 44
45#define __IO_PREFIX hs7751rvoip
46#include <asm/io_generic.h>
47
48/* arch/sh/boards/renesas/hs7751rvoip/irq.c */
49void init_hs7751rvoip_IRQ(void);
50
51/* arch/sh/boards/renesas/hs7751rvoip/io.c */
52void *hs7751rvoip_ioremap(unsigned long, unsigned long);
53
47#endif /* __ASM_SH_RENESAS_HS7751RVOIP */ 54#endif /* __ASM_SH_RENESAS_HS7751RVOIP */
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index 894e64b2d5f0..ed12d38e8c00 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -107,6 +107,9 @@
107#define __raw_writew(v, a) __writew(v, (void __iomem *)(a)) 107#define __raw_writew(v, a) __writew(v, (void __iomem *)(a))
108#define __raw_writel(v, a) __writel(v, (void __iomem *)(a)) 108#define __raw_writel(v, a) __writel(v, (void __iomem *)(a))
109 109
110void __raw_writesl(unsigned long addr, const void *data, int longlen);
111void __raw_readsl(unsigned long addr, void *data, int longlen);
112
110/* 113/*
111 * The platform header files may define some of these macros to use 114 * The platform header files may define some of these macros to use
112 * the inlined versions where appropriate. These macros may also be 115 * the inlined versions where appropriate. These macros may also be
@@ -132,6 +135,9 @@
132# define writel(v,a) ({ __raw_writel((v),(a)); mb(); }) 135# define writel(v,a) ({ __raw_writel((v),(a)); mb(); })
133#endif 136#endif
134 137
138#define writesl __raw_writesl
139#define readsl __raw_readsl
140
135#define readb_relaxed(a) readb(a) 141#define readb_relaxed(a) readb(a)
136#define readw_relaxed(a) readw(a) 142#define readw_relaxed(a) readw(a)
137#define readl_relaxed(a) readl(a) 143#define readl_relaxed(a) readl(a)
@@ -209,8 +215,14 @@ static inline void ctrl_outl(unsigned int b, unsigned long addr)
209 *(volatile unsigned long*)addr = b; 215 *(volatile unsigned long*)addr = b;
210} 216}
211 217
218static inline void ctrl_delay(void)
219{
220 ctrl_inw(P2SEG);
221}
222
212#define IO_SPACE_LIMIT 0xffffffff 223#define IO_SPACE_LIMIT 0xffffffff
213 224
225#ifdef CONFIG_MMU
214/* 226/*
215 * Change virtual addresses to physical addresses and vv. 227 * Change virtual addresses to physical addresses and vv.
216 * These are trivial on the 1:1 Linux/SuperH mapping 228 * These are trivial on the 1:1 Linux/SuperH mapping
@@ -224,6 +236,10 @@ static inline void *phys_to_virt(unsigned long address)
224{ 236{
225 return (void *)P1SEGADDR(address); 237 return (void *)P1SEGADDR(address);
226} 238}
239#else
240#define phys_to_virt(address) ((void *)(address))
241#define virt_to_phys(address) ((unsigned long)(address))
242#endif
227 243
228#define virt_to_bus virt_to_phys 244#define virt_to_bus virt_to_phys
229#define bus_to_virt phys_to_virt 245#define bus_to_virt phys_to_virt
diff --git a/include/asm-sh/irq-sh73180.h b/include/asm-sh/irq-sh73180.h
index d705252be260..b28af9a69d72 100644
--- a/include/asm-sh/irq-sh73180.h
+++ b/include/asm-sh/irq-sh73180.h
@@ -311,6 +311,4 @@
311#define IRQ6_PRIORITY 1 311#define IRQ6_PRIORITY 1
312#define IRQ7_PRIORITY 1 312#define IRQ7_PRIORITY 1
313 313
314int shmse_irq_demux(int irq);
315
316#endif /* __ASM_SH_IRQ_SH73180_H */ 314#endif /* __ASM_SH_IRQ_SH73180_H */
diff --git a/include/asm-sh/irq-sh7343.h b/include/asm-sh/irq-sh7343.h
new file mode 100644
index 000000000000..5d15419b53b0
--- /dev/null
+++ b/include/asm-sh/irq-sh7343.h
@@ -0,0 +1,317 @@
1#ifndef __ASM_SH_IRQ_SH7343_H
2#define __ASM_SH_IRQ_SH7343_H
3
4/*
5 * linux/include/asm-sh/irq-sh7343.h
6 *
7 * Copyright (C) 2006 Kenati Technologies Inc.
8 * Andre Mccurdy <andre@kenati.com>
9 * Ranjit Deshpande <ranjit@kenati.com>
10 */
11
12#undef INTC_IPRA
13#undef INTC_IPRB
14#undef INTC_IPRC
15#undef INTC_IPRD
16
17#undef DMTE0_IRQ
18#undef DMTE1_IRQ
19#undef DMTE2_IRQ
20#undef DMTE3_IRQ
21#undef DMTE4_IRQ
22#undef DMTE5_IRQ
23#undef DMTE6_IRQ
24#undef DMTE7_IRQ
25#undef DMAE_IRQ
26#undef DMA_IPR_ADDR
27#undef DMA_IPR_POS
28#undef DMA_PRIORITY
29
30#undef INTC_IMCR0
31#undef INTC_IMCR1
32#undef INTC_IMCR2
33#undef INTC_IMCR3
34#undef INTC_IMCR4
35#undef INTC_IMCR5
36#undef INTC_IMCR6
37#undef INTC_IMCR7
38#undef INTC_IMCR8
39#undef INTC_IMCR9
40#undef INTC_IMCR10
41
42
43#define INTC_IPRA 0xA4080000UL
44#define INTC_IPRB 0xA4080004UL
45#define INTC_IPRC 0xA4080008UL
46#define INTC_IPRD 0xA408000CUL
47#define INTC_IPRE 0xA4080010UL
48#define INTC_IPRF 0xA4080014UL
49#define INTC_IPRG 0xA4080018UL
50#define INTC_IPRH 0xA408001CUL
51#define INTC_IPRI 0xA4080020UL
52#define INTC_IPRJ 0xA4080024UL
53#define INTC_IPRK 0xA4080028UL
54#define INTC_IPRL 0xA408002CUL
55
56#define INTC_IMR0 0xA4080080UL
57#define INTC_IMR1 0xA4080084UL
58#define INTC_IMR2 0xA4080088UL
59#define INTC_IMR3 0xA408008CUL
60#define INTC_IMR4 0xA4080090UL
61#define INTC_IMR5 0xA4080094UL
62#define INTC_IMR6 0xA4080098UL
63#define INTC_IMR7 0xA408009CUL
64#define INTC_IMR8 0xA40800A0UL
65#define INTC_IMR9 0xA40800A4UL
66#define INTC_IMR10 0xA40800A8UL
67#define INTC_IMR11 0xA40800ACUL
68
69#define INTC_IMCR0 0xA40800C0UL
70#define INTC_IMCR1 0xA40800C4UL
71#define INTC_IMCR2 0xA40800C8UL
72#define INTC_IMCR3 0xA40800CCUL
73#define INTC_IMCR4 0xA40800D0UL
74#define INTC_IMCR5 0xA40800D4UL
75#define INTC_IMCR6 0xA40800D8UL
76#define INTC_IMCR7 0xA40800DCUL
77#define INTC_IMCR8 0xA40800E0UL
78#define INTC_IMCR9 0xA40800E4UL
79#define INTC_IMCR10 0xA40800E8UL
80#define INTC_IMCR11 0xA40800ECUL
81
82#define INTC_ICR0 0xA4140000UL
83#define INTC_ICR1 0xA414001CUL
84
85#define INTMSK0 0xa4140044
86#define INTMSKCLR0 0xa4140064
87#define INTC_INTPRI0 0xa4140010
88
89/*
90 NOTE:
91
92 *_IRQ = (INTEVT2 - 0x200)/0x20
93*/
94
95/* TMU0 */
96#define TMU0_IRQ 16
97#define TMU0_IPR_ADDR INTC_IPRA
98#define TMU0_IPR_POS 3
99#define TMU0_PRIORITY 2
100
101#define TIMER_IRQ 16
102#define TIMER_IPR_ADDR INTC_IPRA
103#define TIMER_IPR_POS 3
104#define TIMER_PRIORITY 2
105
106/* TMU1 */
107#define TMU1_IRQ 17
108#define TMU1_IPR_ADDR INTC_IPRA
109#define TMU1_IPR_POS 2
110#define TMU1_PRIORITY 2
111
112/* TMU2 */
113#define TMU2_IRQ 18
114#define TMU2_IPR_ADDR INTC_IPRA
115#define TMU2_IPR_POS 1
116#define TMU2_PRIORITY 2
117
118/* LCDC */
119#define LCDC_IRQ 28
120#define LCDC_IPR_ADDR INTC_IPRB
121#define LCDC_IPR_POS 2
122#define LCDC_PRIORITY 2
123
124/* VIO (Video I/O) */
125#define CEU_IRQ 52
126#define BEU_IRQ 53
127#define VEU_IRQ 54
128#define VOU_IRQ 55
129#define VIO_IPR_ADDR INTC_IPRE
130#define VIO_IPR_POS 2
131#define VIO_PRIORITY 2
132
133/* MFI (Multi Functional Interface) */
134#define MFI_IRQ 56
135#define MFI_IPR_ADDR INTC_IPRE
136#define MFI_IPR_POS 1
137#define MFI_PRIORITY 2
138
139/* VPU (Video Processing Unit) */
140#define VPU_IRQ 60
141#define VPU_IPR_ADDR INTC_IPRE
142#define VPU_IPR_POS 0
143#define VPU_PRIORITY 2
144
145/* 3DG */
146#define TDG_IRQ 63
147#define TDG_IPR_ADDR INTC_IPRJ
148#define TDG_IPR_POS 2
149#define TDG_PRIORITY 2
150
151/* DMAC(1) */
152#define DMTE0_IRQ 48
153#define DMTE1_IRQ 49
154#define DMTE2_IRQ 50
155#define DMTE3_IRQ 51
156#define DMA1_IPR_ADDR INTC_IPRE
157#define DMA1_IPR_POS 3
158#define DMA1_PRIORITY 7
159
160/* DMAC(2) */
161#define DMTE4_IRQ 76
162#define DMTE5_IRQ 77
163#define DMA2_IPR_ADDR INTC_IPRF
164#define DMA2_IPR_POS 2
165#define DMA2_PRIORITY 7
166
167/* SCIF0 */
168#define SCIF_ERI_IRQ 80
169#define SCIF_RXI_IRQ 81
170#define SCIF_BRI_IRQ 82
171#define SCIF_TXI_IRQ 83
172#define SCIF_IPR_ADDR INTC_IPRG
173#define SCIF_IPR_POS 3
174#define SCIF_PRIORITY 3
175
176/* SIOF0 */
177#define SIOF0_IRQ 84
178#define SIOF0_IPR_ADDR INTC_IPRH
179#define SIOF0_IPR_POS 3
180#define SIOF0_PRIORITY 3
181
182/* FLCTL (Flash Memory Controller) */
183#define FLSTE_IRQ 92
184#define FLTEND_IRQ 93
185#define FLTRQ0_IRQ 94
186#define FLTRQ1_IRQ 95
187#define FLCTL_IPR_ADDR INTC_IPRH
188#define FLCTL_IPR_POS 1
189#define FLCTL_PRIORITY 3
190
191/* IIC(0) (IIC Bus Interface) */
192#define IIC0_ALI_IRQ 96
193#define IIC0_TACKI_IRQ 97
194#define IIC0_WAITI_IRQ 98
195#define IIC0_DTEI_IRQ 99
196#define IIC0_IPR_ADDR INTC_IPRH
197#define IIC0_IPR_POS 0
198#define IIC0_PRIORITY 3
199
200/* IIC(1) (IIC Bus Interface) */
201#define IIC1_ALI_IRQ 44
202#define IIC1_TACKI_IRQ 45
203#define IIC1_WAITI_IRQ 46
204#define IIC1_DTEI_IRQ 47
205#define IIC1_IPR_ADDR INTC_IPRI
206#define IIC1_IPR_POS 0
207#define IIC1_PRIORITY 3
208
209/* SIO0 */
210#define SIO0_IRQ 88
211#define SIO0_IPR_ADDR INTC_IPRI
212#define SIO0_IPR_POS 3
213#define SIO0_PRIORITY 3
214
215/* SDHI */
216#define SDHI_SDHII0_IRQ 100
217#define SDHI_SDHII1_IRQ 101
218#define SDHI_SDHII2_IRQ 102
219#define SDHI_SDHII3_IRQ 103
220#define SDHI_IPR_ADDR INTC_IPRK
221#define SDHI_IPR_POS 0
222#define SDHI_PRIORITY 3
223
224/* SIU (Sound Interface Unit) */
225#define SIU_IRQ 108
226#define SIU_IPR_ADDR INTC_IPRJ
227#define SIU_IPR_POS 1
228#define SIU_PRIORITY 3
229
230#define PORT_PACR 0xA4050100UL
231#define PORT_PBCR 0xA4050102UL
232#define PORT_PCCR 0xA4050104UL
233#define PORT_PDCR 0xA4050106UL
234#define PORT_PECR 0xA4050108UL
235#define PORT_PFCR 0xA405010AUL
236#define PORT_PGCR 0xA405010CUL
237#define PORT_PHCR 0xA405010EUL
238#define PORT_PJCR 0xA4050110UL
239#define PORT_PKCR 0xA4050112UL
240#define PORT_PLCR 0xA4050114UL
241#define PORT_SCPCR 0xA4050116UL
242#define PORT_PMCR 0xA4050118UL
243#define PORT_PNCR 0xA405011AUL
244#define PORT_PQCR 0xA405011CUL
245#define PORT_PRCR 0xA405011EUL
246#define PORT_PTCR 0xA405014CUL
247#define PORT_PUCR 0xA405014EUL
248#define PORT_PVCR 0xA4050150UL
249
250#define PORT_PSELA 0xA4050140UL
251#define PORT_PSELB 0xA4050142UL
252#define PORT_PSELC 0xA4050144UL
253#define PORT_PSELE 0xA4050158UL
254
255#define PORT_HIZCRA 0xA4050146UL
256#define PORT_HIZCRB 0xA4050148UL
257#define PORT_DRVCR 0xA405014AUL
258
259#define PORT_PADR 0xA4050120UL
260#define PORT_PBDR 0xA4050122UL
261#define PORT_PCDR 0xA4050124UL
262#define PORT_PDDR 0xA4050126UL
263#define PORT_PEDR 0xA4050128UL
264#define PORT_PFDR 0xA405012AUL
265#define PORT_PGDR 0xA405012CUL
266#define PORT_PHDR 0xA405012EUL
267#define PORT_PJDR 0xA4050130UL
268#define PORT_PKDR 0xA4050132UL
269#define PORT_PLDR 0xA4050134UL
270#define PORT_SCPDR 0xA4050136UL
271#define PORT_PMDR 0xA4050138UL
272#define PORT_PNDR 0xA405013AUL
273#define PORT_PQDR 0xA405013CUL
274#define PORT_PRDR 0xA405013EUL
275#define PORT_PTDR 0xA405016CUL
276#define PORT_PUDR 0xA405016EUL
277#define PORT_PVDR 0xA4050170UL
278
279#define IRQ0_IRQ 32
280#define IRQ1_IRQ 33
281#define IRQ2_IRQ 34
282#define IRQ3_IRQ 35
283#define IRQ4_IRQ 36
284#define IRQ5_IRQ 37
285#define IRQ6_IRQ 38
286#define IRQ7_IRQ 39
287
288#define INTPRI00 0xA4140010UL
289
290#define IRQ0_IPR_ADDR INTPRI00
291#define IRQ1_IPR_ADDR INTPRI00
292#define IRQ2_IPR_ADDR INTPRI00
293#define IRQ3_IPR_ADDR INTPRI00
294#define IRQ4_IPR_ADDR INTPRI00
295#define IRQ5_IPR_ADDR INTPRI00
296#define IRQ6_IPR_ADDR INTPRI00
297#define IRQ7_IPR_ADDR INTPRI00
298
299#define IRQ0_IPR_POS 7
300#define IRQ1_IPR_POS 6
301#define IRQ2_IPR_POS 5
302#define IRQ3_IPR_POS 4
303#define IRQ4_IPR_POS 3
304#define IRQ5_IPR_POS 2
305#define IRQ6_IPR_POS 1
306#define IRQ7_IPR_POS 0
307
308#define IRQ0_PRIORITY 1
309#define IRQ1_PRIORITY 1
310#define IRQ2_PRIORITY 1
311#define IRQ3_PRIORITY 1
312#define IRQ4_PRIORITY 1
313#define IRQ5_PRIORITY 1
314#define IRQ6_PRIORITY 1
315#define IRQ7_PRIORITY 1
316
317#endif /* __ASM_SH_IRQ_SH7343_H */
diff --git a/include/asm-sh/irq-sh7780.h b/include/asm-sh/irq-sh7780.h
index 7f90315cd830..895c5780e454 100644
--- a/include/asm-sh/irq-sh7780.h
+++ b/include/asm-sh/irq-sh7780.h
@@ -145,11 +145,6 @@
145#define TMU_CH5_IPR_POS 1 145#define TMU_CH5_IPR_POS 1
146#define TMU_CH5_PRIORITY 2 146#define TMU_CH5_PRIORITY 2
147 147
148#define RTC_IRQ 22
149#define RTC_IPR_ADDR INTC_INT2PRI1
150#define RTC_IPR_POS 0
151#define RTC_PRIORITY TIMER_PRIORITY
152
153/* SCIF0 */ 148/* SCIF0 */
154#define SCIF0_ERI_IRQ 40 149#define SCIF0_ERI_IRQ 40
155#define SCIF0_RXI_IRQ 41 150#define SCIF0_RXI_IRQ 41
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index 611e67cd0627..0e5f365aff70 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -192,7 +192,7 @@
192 192
193#if defined (CONFIG_CPU_SUBTYPE_SH7707) || defined (CONFIG_CPU_SUBTYPE_SH7708) || \ 193#if defined (CONFIG_CPU_SUBTYPE_SH7707) || defined (CONFIG_CPU_SUBTYPE_SH7708) || \
194 defined (CONFIG_CPU_SUBTYPE_SH7709) || defined (CONFIG_CPU_SUBTYPE_SH7750) || \ 194 defined (CONFIG_CPU_SUBTYPE_SH7709) || defined (CONFIG_CPU_SUBTYPE_SH7750) || \
195 defined (CONFIG_CPU_SUBTYPE_SH7751) 195 defined (CONFIG_CPU_SUBTYPE_SH7751) || defined (CONFIG_CPU_SUBTYPE_SH7706)
196#define SCI_ERI_IRQ 23 196#define SCI_ERI_IRQ 23
197#define SCI_RXI_IRQ 24 197#define SCI_RXI_IRQ 24
198#define SCI_TXI_IRQ 25 198#define SCI_TXI_IRQ 25
@@ -207,6 +207,7 @@
207#define SCIF0_IPR_POS 3 207#define SCIF0_IPR_POS 3
208#define SCIF0_PRIORITY 3 208#define SCIF0_PRIORITY 3
209#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 209#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
210 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
210 defined(CONFIG_CPU_SUBTYPE_SH7707) || \ 211 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
211 defined(CONFIG_CPU_SUBTYPE_SH7709) 212 defined(CONFIG_CPU_SUBTYPE_SH7709)
212#define SCIF_ERI_IRQ 56 213#define SCIF_ERI_IRQ 56
@@ -261,9 +262,12 @@
261#elif defined(CONFIG_CPU_SUBTYPE_SH7708) 262#elif defined(CONFIG_CPU_SUBTYPE_SH7708)
262# define ONCHIP_NR_IRQS 32 263# define ONCHIP_NR_IRQS 32
263#elif defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 264#elif defined(CONFIG_CPU_SUBTYPE_SH7709) || \
265 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
264 defined(CONFIG_CPU_SUBTYPE_SH7705) 266 defined(CONFIG_CPU_SUBTYPE_SH7705)
265# define ONCHIP_NR_IRQS 64 // Actually 61 267# define ONCHIP_NR_IRQS 64 // Actually 61
266# define PINT_NR_IRQS 16 268# define PINT_NR_IRQS 16
269#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
270# define ONCHIP_NR_IRQS 104
267#elif defined(CONFIG_CPU_SUBTYPE_SH7750) 271#elif defined(CONFIG_CPU_SUBTYPE_SH7750)
268# define ONCHIP_NR_IRQS 48 // Actually 44 272# define ONCHIP_NR_IRQS 48 // Actually 44
269#elif defined(CONFIG_CPU_SUBTYPE_SH7751) 273#elif defined(CONFIG_CPU_SUBTYPE_SH7751)
@@ -275,7 +279,8 @@
275#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1) 279#elif defined(CONFIG_CPU_SUBTYPE_ST40STB1)
276# define ONCHIP_NR_IRQS 144 280# define ONCHIP_NR_IRQS 144
277#elif defined(CONFIG_CPU_SUBTYPE_SH7300) || \ 281#elif defined(CONFIG_CPU_SUBTYPE_SH7300) || \
278 defined(CONFIG_CPU_SUBTYPE_SH73180) 282 defined(CONFIG_CPU_SUBTYPE_SH73180) || \
283 defined(CONFIG_CPU_SUBTYPE_SH7343)
279# define ONCHIP_NR_IRQS 109 284# define ONCHIP_NR_IRQS 109
280#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 285#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
281# define ONCHIP_NR_IRQS 111 286# define ONCHIP_NR_IRQS 111
@@ -311,6 +316,8 @@
311# define OFFCHIP_NR_IRQS 4 316# define OFFCHIP_NR_IRQS 4
312#elif defined(CONFIG_SH_R7780RP) 317#elif defined(CONFIG_SH_R7780RP)
313# define OFFCHIP_NR_IRQS 16 318# define OFFCHIP_NR_IRQS 16
319#elif defined(CONFIG_SH_7343_SOLUTION_ENGINE)
320# define OFFCHIP_NR_IRQS 12
314#elif defined(CONFIG_SH_UNKNOWN) 321#elif defined(CONFIG_SH_UNKNOWN)
315# define OFFCHIP_NR_IRQS 16 /* Must also be last */ 322# define OFFCHIP_NR_IRQS 16 /* Must also be last */
316#else 323#else
@@ -335,6 +342,11 @@ extern void make_maskreg_irq(unsigned int irq);
335extern unsigned short *irq_mask_register; 342extern unsigned short *irq_mask_register;
336 343
337/* 344/*
345 * PINT IRQs
346 */
347void init_IRQ_pint(void);
348
349/*
338 * Function for "on chip support modules". 350 * Function for "on chip support modules".
339 */ 351 */
340extern void make_ipr_irq(unsigned int irq, unsigned int addr, 352extern void make_ipr_irq(unsigned int irq, unsigned int addr,
@@ -471,8 +483,10 @@ extern int ipr_irq_demux(int irq);
471 483
472#define INTC_ICR 0xfffffee0UL 484#define INTC_ICR 0xfffffee0UL
473#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 485#elif defined(CONFIG_CPU_SUBTYPE_SH7705) || \
486 defined(CONFIG_CPU_SUBTYPE_SH7706) || \
474 defined(CONFIG_CPU_SUBTYPE_SH7707) || \ 487 defined(CONFIG_CPU_SUBTYPE_SH7707) || \
475 defined(CONFIG_CPU_SUBTYPE_SH7709) 488 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
489 defined(CONFIG_CPU_SUBTYPE_SH7710)
476#define INTC_IRR0 0xa4000004UL 490#define INTC_IRR0 0xa4000004UL
477#define INTC_IRR1 0xa4000006UL 491#define INTC_IRR1 0xa4000006UL
478#define INTC_IRR2 0xa4000008UL 492#define INTC_IRR2 0xa4000008UL
@@ -491,8 +505,105 @@ extern int ipr_irq_demux(int irq);
491#define INTC_IPRF 0xa4080000UL 505#define INTC_IPRF 0xa4080000UL
492#define INTC_IPRG 0xa4080002UL 506#define INTC_IPRG 0xa4080002UL
493#define INTC_IPRH 0xa4080004UL 507#define INTC_IPRH 0xa4080004UL
494#endif 508#elif defined(CONFIG_CPU_SUBTYPE_SH7710)
509/* Interrupt Controller Registers */
510#undef INTC_IPRA
511#undef INTC_IPRB
512#define INTC_IPRA 0xA414FEE2UL
513#define INTC_IPRB 0xA414FEE4UL
514#define INTC_IPRF 0xA4080000UL
515#define INTC_IPRG 0xA4080002UL
516#define INTC_IPRH 0xA4080004UL
517#define INTC_IPRI 0xA4080006UL
518
519#undef INTC_ICR0
520#undef INTC_ICR1
521#define INTC_ICR0 0xA414FEE0UL
522#define INTC_ICR1 0xA4140010UL
523
524#define INTC_IRR0 0xa4000004UL
525#define INTC_IRR1 0xa4000006UL
526#define INTC_IRR2 0xa4000008UL
527#define INTC_IRR3 0xa400000AUL
528#define INTC_IRR4 0xa400000CUL
529#define INTC_IRR5 0xa4080020UL
530#define INTC_IRR7 0xa4080024UL
531#define INTC_IRR8 0xa4080026UL
532
533/* Interrupt numbers */
534#define TIMER2_IRQ 18
535#define TIMER2_IPR_ADDR INTC_IPRA
536#define TIMER2_IPR_POS 1
537#define TIMER2_PRIORITY 2
538
539/* WDT */
540#define WDT_IRQ 27
541#define WDT_IPR_ADDR INTC_IPRB
542#define WDT_IPR_POS 3
543#define WDT_PRIORITY 2
544
545#define SCIF0_ERI_IRQ 52
546#define SCIF0_RXI_IRQ 53
547#define SCIF0_BRI_IRQ 54
548#define SCIF0_TXI_IRQ 55
549#define SCIF0_IPR_ADDR INTC_IPRE
550#define SCIF0_IPR_POS 2
551#define SCIF0_PRIORITY 3
552
553#define DMTE4_IRQ 76
554#define DMTE5_IRQ 77
555#define DMA2_IPR_ADDR INTC_IPRF
556#define DMA2_IPR_POS 2
557#define DMA2_PRIORITY 7
495 558
559#define IPSEC_IRQ 79
560#define IPSEC_IPR_ADDR INTC_IPRF
561#define IPSEC_IPR_POS 3
562#define IPSEC_PRIORITY 3
563
564/* EDMAC */
565#define EDMAC0_IRQ 80
566#define EDMAC0_IPR_ADDR INTC_IPRG
567#define EDMAC0_IPR_POS 3
568#define EDMAC0_PRIORITY 3
569
570#define EDMAC1_IRQ 81
571#define EDMAC1_IPR_ADDR INTC_IPRG
572#define EDMAC1_IPR_POS 2
573#define EDMAC1_PRIORITY 3
574
575#define EDMAC2_IRQ 82
576#define EDMAC2_IPR_ADDR INTC_IPRG
577#define EDMAC2_IPR_POS 1
578#define EDMAC2_PRIORITY 3
579
580/* SIOF */
581#define SIOF0_ERI_IRQ 96
582#define SIOF0_TXI_IRQ 97
583#define SIOF0_RXI_IRQ 98
584#define SIOF0_CCI_IRQ 99
585#define SIOF0_IPR_ADDR INTC_IPRH
586#define SIOF0_IPR_POS 0
587#define SIOF0_PRIORITY 7
588
589#define SIOF1_ERI_IRQ 100
590#define SIOF1_TXI_IRQ 101
591#define SIOF1_RXI_IRQ 102
592#define SIOF1_CCI_IRQ 103
593#define SIOF1_IPR_ADDR INTC_IPRI
594#define SIOF1_IPR_POS 1
595#define SIOF1_PRIORITY 7
596#endif /* CONFIG_CPU_SUBTYPE_SH7710 */
597
598#if defined(CONFIG_CPU_SUBTYPE_SH7710)
599#define PORT_PACR 0xa4050100UL
600#define PORT_PBCR 0xa4050102UL
601#define PORT_PCCR 0xa4050104UL
602#define PORT_PETCR 0xa4050106UL
603#define PORT_PADR 0xa4050120UL
604#define PORT_PBDR 0xa4050122UL
605#define PORT_PCDR 0xa4050124UL
606#else
496#define PORT_PACR 0xa4000100UL 607#define PORT_PACR 0xa4000100UL
497#define PORT_PBCR 0xa4000102UL 608#define PORT_PBCR 0xa4000102UL
498#define PORT_PCCR 0xa4000104UL 609#define PORT_PCCR 0xa4000104UL
@@ -501,6 +612,7 @@ extern int ipr_irq_demux(int irq);
501#define PORT_PBDR 0xa4000122UL 612#define PORT_PBDR 0xa4000122UL
502#define PORT_PCDR 0xa4000124UL 613#define PORT_PCDR 0xa4000124UL
503#define PORT_PFDR 0xa400012aUL 614#define PORT_PFDR 0xa400012aUL
615#endif
504 616
505#define IRQ0_IRQ 32 617#define IRQ0_IRQ 32
506#define IRQ1_IRQ 33 618#define IRQ1_IRQ 33
@@ -577,7 +689,7 @@ extern int ipr_irq_demux(int irq);
577#define NR_INTC2_IRQS 64 689#define NR_INTC2_IRQS 64
578#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 690#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
579#define INTC2_BASE 0xffd40000 691#define INTC2_BASE 0xffd40000
580#define INTC2_FIRST_IRQ 22 692#define INTC2_FIRST_IRQ 21
581#define INTC2_INTMSK_OFFSET (0x38) 693#define INTC2_INTMSK_OFFSET (0x38)
582#define INTC2_INTMSKCLR_OFFSET (0x3c) 694#define INTC2_INTMSKCLR_OFFSET (0x3c)
583#define NR_INTC2_IRQS 60 695#define NR_INTC2_IRQS 60
@@ -594,6 +706,8 @@ void intc2_add_clear_irq(int irq, int (*fn)(int));
594 706
595#endif 707#endif
596 708
709extern int shmse_irq_demux(int irq);
710
597static inline int generic_irq_demux(int irq) 711static inline int generic_irq_demux(int irq)
598{ 712{
599 return irq; 713 return irq;
@@ -605,8 +719,21 @@ static inline int generic_irq_demux(int irq)
605#define irq_canonicalize(irq) (irq) 719#define irq_canonicalize(irq) (irq)
606#define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq)) 720#define irq_demux(irq) __irq_demux(sh_mv.mv_irq_demux(irq))
607 721
722#ifdef CONFIG_4KSTACKS
723extern void irq_ctx_init(int cpu);
724extern void irq_ctx_exit(int cpu);
725# define __ARCH_HAS_DO_SOFTIRQ
726#else
727# define irq_ctx_init(cpu) do { } while (0)
728# define irq_ctx_exit(cpu) do { } while (0)
729#endif
730
608#if defined(CONFIG_CPU_SUBTYPE_SH73180) 731#if defined(CONFIG_CPU_SUBTYPE_SH73180)
609#include <asm/irq-sh73180.h> 732#include <asm/irq-sh73180.h>
610#endif 733#endif
611 734
735#if defined(CONFIG_CPU_SUBTYPE_SH7343)
736#include <asm/irq-sh7343.h>
737#endif
738
612#endif /* __ASM_SH_IRQ_H */ 739#endif /* __ASM_SH_IRQ_H */
diff --git a/include/asm-sh/kexec.h b/include/asm-sh/kexec.h
index 9dfe59f6fcb5..9d235af20cdd 100644
--- a/include/asm-sh/kexec.h
+++ b/include/asm-sh/kexec.h
@@ -23,11 +23,10 @@
23/* The native architecture */ 23/* The native architecture */
24#define KEXEC_ARCH KEXEC_ARCH_SH 24#define KEXEC_ARCH KEXEC_ARCH_SH
25 25
26#ifndef __ASSEMBLY__ 26#define MAX_NOTE_BYTES 1024
27 27
28extern void machine_shutdown(void); 28/* Provide a dummy definition to avoid build failures. */
29extern void *crash_notes; 29static inline void crash_setup_regs(struct pt_regs *newregs,
30 30 struct pt_regs *oldregs) { }
31#endif /* __ASSEMBLY__ */
32 31
33#endif /* _SH_KEXEC_H */ 32#endif /* _SH_KEXEC_H */
diff --git a/include/asm-sh/kgdb.h b/include/asm-sh/kgdb.h
index 1653ffb75fbe..7b26f53fe343 100644
--- a/include/asm-sh/kgdb.h
+++ b/include/asm-sh/kgdb.h
@@ -128,4 +128,19 @@ extern int setjmp(jmp_buf __jmpb);
128#define KGDB_ASSERT(condition, message) 128#define KGDB_ASSERT(condition, message)
129#endif 129#endif
130 130
131/* Taken from sh-stub.c of GDB 4.18 */
132static const char hexchars[] = "0123456789abcdef";
133
134/* Get high hex bits */
135static inline char highhex(const int x)
136{
137 return hexchars[(x >> 4) & 0xf];
138}
139
140/* Get low hex bits */
141static inline char lowhex(const int x)
142{
143 return hexchars[x & 0xf];
144}
145
131#endif 146#endif
diff --git a/include/asm-sh/landisk/gio.h b/include/asm-sh/landisk/gio.h
new file mode 100644
index 000000000000..3fce4c451a46
--- /dev/null
+++ b/include/asm-sh/landisk/gio.h
@@ -0,0 +1,45 @@
1#ifndef __ASM_SH_LANDISK_GIO_H
2#define __ASM_SH_LANDISK_GIO_H
3
4#include <linux/ioctl.h>
5
6/* version */
7#define VERSION_STR "1.00"
8
9/* Driver name */
10#define GIO_DRIVER_NAME "/dev/giodrv"
11
12/* Use 'k' as magic number */
13#define GIODRV_IOC_MAGIC 'k'
14
15#define GIODRV_IOCRESET _IO(GIODRV_IOC_MAGIC, 0)
16/*
17 * S means "Set" through a ptr,
18 * T means "Tell" directly
19 * G means "Get" (to a pointed var)
20 * Q means "Query", response is on the return value
21 * X means "eXchange": G and S atomically
22 * H means "sHift": T and Q atomically
23 */
24#define GIODRV_IOCSGIODATA1 _IOW(GIODRV_IOC_MAGIC, 1, unsigned char *)
25#define GIODRV_IOCGGIODATA1 _IOR(GIODRV_IOC_MAGIC, 2, unsigned char *)
26#define GIODRV_IOCSGIODATA2 _IOW(GIODRV_IOC_MAGIC, 3, unsigned short *)
27#define GIODRV_IOCGGIODATA2 _IOR(GIODRV_IOC_MAGIC, 4, unsigned short *)
28#define GIODRV_IOCSGIODATA4 _IOW(GIODRV_IOC_MAGIC, 5, unsigned long *)
29#define GIODRV_IOCGGIODATA4 _IOR(GIODRV_IOC_MAGIC, 6, unsigned long *)
30#define GIODRV_IOCSGIOSETADDR _IOW(GIODRV_IOC_MAGIC, 7, unsigned long *)
31#define GIODRV_IOCHARDRESET _IO(GIODRV_IOC_MAGIC, 8) /* debugging tool */
32
33#define GIODRV_IOCSGIO_LED _IOW(GIODRV_IOC_MAGIC, 9, unsigned long *)
34#define GIODRV_IOCGGIO_LED _IOR(GIODRV_IOC_MAGIC, 10, unsigned long *)
35#define GIODRV_IOCSGIO_BUZZER _IOW(GIODRV_IOC_MAGIC, 11, unsigned long *)
36#define GIODRV_IOCGGIO_LANDISK _IOR(GIODRV_IOC_MAGIC, 14, unsigned long *)
37#define GIODRV_IOCGGIO_BTN _IOR(GIODRV_IOC_MAGIC, 22, unsigned long *)
38#define GIODRV_IOCSGIO_BTNPID _IOW(GIODRV_IOC_MAGIC, 23, unsigned long *)
39#define GIODRV_IOCGGIO_BTNPID _IOR(GIODRV_IOC_MAGIC, 24, unsigned long *)
40
41#define GIODRV_IOC_MAXNR 8
42#define GIO_READ 0x00000000
43#define GIO_WRITE 0x00000001
44
45#endif /* __ASM_SH_LANDISK_GIO_H */
diff --git a/include/asm-sh/landisk/ide.h b/include/asm-sh/landisk/ide.h
new file mode 100644
index 000000000000..6490e28415ed
--- /dev/null
+++ b/include/asm-sh/landisk/ide.h
@@ -0,0 +1,14 @@
1/*
2 * modifed by kogiidena
3 * 2005.03.03
4 */
5
6#ifndef __ASM_SH_LANDISK_IDE_H
7#define __ASM_SH_LANDISK_IDE_H
8
9/* Nothing to see here.. */
10#include <asm/landisk/iodata_landisk.h>
11#define IRQ_CFCARD IRQ_FATA /* CF Card IRQ */
12#define IRQ_PCMCIA IRQ_ATA /* PCMCIA IRQ */
13
14#endif /* __ASM_SH_LANDISK_IDE_H */
diff --git a/include/asm-sh/landisk/iodata_landisk.h b/include/asm-sh/landisk/iodata_landisk.h
new file mode 100644
index 000000000000..c74d3c73f377
--- /dev/null
+++ b/include/asm-sh/landisk/iodata_landisk.h
@@ -0,0 +1,79 @@
1#ifndef __ASM_SH_IODATA_LANDISK_H
2#define __ASM_SH_IODATA_LANDISK_H
3
4/*
5 * linux/include/asm-sh/landisk/iodata_landisk.h
6 *
7 * Copyright (C) 2000 Atom Create Engineering Co., Ltd.
8 *
9 * IO-DATA LANDISK support
10 */
11
12/* Box specific addresses. */
13
14#define PA_USB 0xa4000000 /* USB Controller M66590 */
15
16#define PA_ATARST 0xb0000000 /* ATA/FATA Access Control Register */
17#define PA_LED 0xb0000001 /* LED Control Register */
18#define PA_STATUS 0xb0000002 /* Switch Status Register */
19#define PA_SHUTDOWN 0xb0000003 /* Shutdown Control Register */
20#define PA_PCIPME 0xb0000004 /* PCI PME Status Register */
21#define PA_IMASK 0xb0000005 /* Interrupt Mask Register */
22/* 2003.10.31 I-O DATA NSD NWG add. for shutdown port clear */
23#define PA_PWRINT_CLR 0xb0000006 /* Shutdown Interrupt clear Register */
24
25#define PA_LCD_CLRDSP 0x00 /* LCD Clear Display Offset */
26#define PA_LCD_RTNHOME 0x00 /* LCD Return Home Offset */
27#define PA_LCD_ENTMODE 0x00 /* LCD Entry Mode Offset */
28#define PA_LCD_DSPCTL 0x00 /* LCD Display ON/OFF Control Offset */
29#define PA_LCD_FUNC 0x00 /* LCD Function Set Offset */
30#define PA_LCD_CGRAM 0x00 /* LCD Set CGRAM Address Offset */
31#define PA_LCD_DDRAM 0x00 /* LCD Set DDRAM Address Offset */
32#define PA_LCD_RDFLAG 0x01 /* LCD Read Busy Flag Offset */
33#define PA_LCD_WTDATA 0x02 /* LCD Write Datat to RAM Offset */
34#define PA_LCD_RDDATA 0x03 /* LCD Read Data from RAM Offset */
35#define PA_PIDE_OFFSET 0x40 /* CF IDE Offset */
36#define PA_SIDE_OFFSET 0x40 /* HDD IDE Offset */
37
38#define IRQ_PCIINTA 5 /* PCI INTA IRQ */
39#define IRQ_PCIINTB 6 /* PCI INTB IRQ */
40#define IRQ_PCIINDC 7 /* PCI INTC IRQ */
41#define IRQ_PCIINTD 8 /* PCI INTD IRQ */
42#define IRQ_ATA 9 /* ATA IRQ */
43#define IRQ_FATA 10 /* FATA IRQ */
44#define IRQ_POWER 11 /* Power Switch IRQ */
45#define IRQ_BUTTON 12 /* USL-5P Button IRQ */
46#define IRQ_FAULT 13 /* USL-5P Fault IRQ */
47
48#define SHUTDOWN_BTN_MAJOR 99 /* Shutdown button device major no. */
49
50#define SHUTDOWN_LOOP_CNT 5 /* Shutdown button Detection loop */
51#define SHUTDOWN_DELAY 200 /* Shutdown button delay value(ms) */
52
53
54/* added by kogiidena */
55/*
56 * landisk_ledparam
57 *
58 * led ------10 -6543210 -6543210 -6543210
59 * |000000..|0.......|0.......|U.......|
60 * | HARD |fastblik| blink | on |
61 *
62 * led0: power U:update flag
63 * led1: error
64 * led2: usb1
65 * led3: usb2
66 * led4: usb3
67 * led5: usb4
68 * led6: usb5
69 *
70 */
71extern int landisk_ledparam; /* from setup.c */
72extern int landisk_buzzerparam; /* from setup.c */
73extern int landisk_arch; /* from setup.c */
74
75#define __IO_PREFIX landisk
76#include <asm/io_generic.h>
77
78#endif /* __ASM_SH_IODATA_LANDISK_H */
79
diff --git a/include/asm-sh/machvec.h b/include/asm-sh/machvec.h
index 550501fa4fed..70389b72ffef 100644
--- a/include/asm-sh/machvec.h
+++ b/include/asm-sh/machvec.h
@@ -8,17 +8,18 @@
8 */ 8 */
9 9
10#ifndef _ASM_SH_MACHVEC_H 10#ifndef _ASM_SH_MACHVEC_H
11#define _ASM_SH_MACHVEC_H 1 11#define _ASM_SH_MACHVEC_H
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/time.h> 14#include <linux/time.h>
15
16#include <asm/machtypes.h> 15#include <asm/machtypes.h>
17#include <asm/machvec_init.h> 16#include <asm/machvec_init.h>
18 17
19struct device; 18struct device;
20 19
21struct sh_machine_vector { 20struct sh_machine_vector {
21 void (*mv_setup)(char **cmdline_p);
22 const char *mv_name;
22 int mv_nr_irqs; 23 int mv_nr_irqs;
23 24
24 u8 (*mv_inb)(unsigned long); 25 u8 (*mv_inb)(unsigned long);
@@ -65,4 +66,6 @@ struct sh_machine_vector {
65 66
66extern struct sh_machine_vector sh_mv; 67extern struct sh_machine_vector sh_mv;
67 68
69#define get_system_type() sh_mv.mv_name
70
68#endif /* _ASM_SH_MACHVEC_H */ 71#endif /* _ASM_SH_MACHVEC_H */
diff --git a/include/asm-sh/mc146818rtc.h b/include/asm-sh/mc146818rtc.h
index 1707cfb2915d..0aee96a97330 100644
--- a/include/asm-sh/mc146818rtc.h
+++ b/include/asm-sh/mc146818rtc.h
@@ -4,173 +4,4 @@
4#ifndef _ASM_MC146818RTC_H 4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H 5#define _ASM_MC146818RTC_H
6 6
7#ifdef CONFIG_SH_MPC1211
8#undef _ASM_MC146818RTC_H
9#undef RTC_IRQ
10#include <asm/mpc1211/mc146818rtc.h>
11#else
12
13#include <asm/rtc.h>
14
15#define RTC_ALWAYS_BCD 1
16
17/* FIXME:RTC Interrupt feature is not implemented yet. */
18#undef RTC_IRQ
19#define RTC_IRQ 0
20
21#if defined(CONFIG_CPU_SH3)
22#define RTC_PORT(n) (R64CNT+(n)*2)
23#define CMOS_READ(addr) __CMOS_READ(addr,b)
24#define CMOS_WRITE(val,addr) __CMOS_WRITE(val,addr,b)
25
26#elif defined(CONFIG_SH_SECUREEDGE5410)
27#include <asm/snapgear/io.h>
28
29#define RTC_PORT(n) SECUREEDGE_IOPORT_ADDR
30#define CMOS_READ(addr) secureedge5410_cmos_read(addr)
31#define CMOS_WRITE(val,addr) secureedge5410_cmos_write(val,addr)
32extern unsigned char secureedge5410_cmos_read(int addr);
33extern void secureedge5410_cmos_write(unsigned char val, int addr);
34
35#elif defined(CONFIG_CPU_SH4)
36#define RTC_PORT(n) (R64CNT+(n)*4)
37#define CMOS_READ(addr) __CMOS_READ(addr,w)
38#define CMOS_WRITE(val,addr) __CMOS_WRITE(val,addr,w)
39#endif
40
41#define __CMOS_READ(addr, s) ({ \
42 unsigned char val=0, rcr1, rcr2, r64cnt, retry; \
43 switch(addr) { \
44 case RTC_SECONDS: \
45 val = ctrl_inb(RSECCNT); \
46 break; \
47 case RTC_SECONDS_ALARM: \
48 val = ctrl_inb(RSECAR); \
49 break; \
50 case RTC_MINUTES: \
51 val = ctrl_inb(RMINCNT); \
52 break; \
53 case RTC_MINUTES_ALARM: \
54 val = ctrl_inb(RMINAR); \
55 break; \
56 case RTC_HOURS: \
57 val = ctrl_inb(RHRCNT); \
58 break; \
59 case RTC_HOURS_ALARM: \
60 val = ctrl_inb(RHRAR); \
61 break; \
62 case RTC_DAY_OF_WEEK: \
63 val = ctrl_inb(RWKCNT); \
64 break; \
65 case RTC_DAY_OF_MONTH: \
66 val = ctrl_inb(RDAYCNT); \
67 break; \
68 case RTC_MONTH: \
69 val = ctrl_inb(RMONCNT); \
70 break; \
71 case RTC_YEAR: \
72 val = ctrl_in##s(RYRCNT); \
73 break; \
74 case RTC_REG_A: /* RTC_FREQ_SELECT */ \
75 rcr2 = ctrl_inb(RCR2); \
76 val = (rcr2 & RCR2_PESMASK) >> 4; \
77 rcr1 = ctrl_inb(RCR1); \
78 rcr1 = (rcr1 & (RCR1_CIE | RCR1_AIE)) | RCR1_AF;\
79 retry = 0; \
80 do { \
81 ctrl_outb(rcr1, RCR1); /* clear CF */ \
82 r64cnt = ctrl_inb(R64CNT); \
83 } while((ctrl_inb(RCR1) & RCR1_CF) && retry++ < 1000);\
84 r64cnt ^= RTC_BIT_INVERTED; \
85 if(r64cnt == 0x7f || r64cnt == 0) \
86 val |= RTC_UIP; \
87 break; \
88 case RTC_REG_B: /* RTC_CONTROL */ \
89 rcr1 = ctrl_inb(RCR1); \
90 rcr2 = ctrl_inb(RCR2); \
91 if(rcr1 & RCR1_CIE) val |= RTC_UIE; \
92 if(rcr1 & RCR1_AIE) val |= RTC_AIE; \
93 if(rcr2 & RCR2_PESMASK) val |= RTC_PIE; \
94 if(!(rcr2 & RCR2_START))val |= RTC_SET; \
95 val |= RTC_24H; \
96 break; \
97 case RTC_REG_C: /* RTC_INTR_FLAGS */ \
98 rcr1 = ctrl_inb(RCR1); \
99 rcr1 &= ~(RCR1_CF | RCR1_AF); \
100 ctrl_outb(rcr1, RCR1); \
101 rcr2 = ctrl_inb(RCR2); \
102 rcr2 &= ~RCR2_PEF; \
103 ctrl_outb(rcr2, RCR2); \
104 break; \
105 case RTC_REG_D: /* RTC_VALID */ \
106 /* Always valid ... */ \
107 val = RTC_VRT; \
108 break; \
109 default: \
110 break; \
111 } \
112 val; \
113})
114
115#define __CMOS_WRITE(val, addr, s) ({ \
116 unsigned char rcr1,rcr2; \
117 switch(addr) { \
118 case RTC_SECONDS: \
119 ctrl_outb(val, RSECCNT); \
120 break; \
121 case RTC_SECONDS_ALARM: \
122 ctrl_outb(val, RSECAR); \
123 break; \
124 case RTC_MINUTES: \
125 ctrl_outb(val, RMINCNT); \
126 break; \
127 case RTC_MINUTES_ALARM: \
128 ctrl_outb(val, RMINAR); \
129 break; \
130 case RTC_HOURS: \
131 ctrl_outb(val, RHRCNT); \
132 break; \
133 case RTC_HOURS_ALARM: \
134 ctrl_outb(val, RHRAR); \
135 break; \
136 case RTC_DAY_OF_WEEK: \
137 ctrl_outb(val, RWKCNT); \
138 break; \
139 case RTC_DAY_OF_MONTH: \
140 ctrl_outb(val, RDAYCNT); \
141 break; \
142 case RTC_MONTH: \
143 ctrl_outb(val, RMONCNT); \
144 break; \
145 case RTC_YEAR: \
146 ctrl_out##s((ctrl_in##s(RYRCNT) & 0xff00) | (val & 0xff), RYRCNT);\
147 break; \
148 case RTC_REG_A: /* RTC_FREQ_SELECT */ \
149 rcr2 = ctrl_inb(RCR2); \
150 if((val & RTC_DIV_CTL) == RTC_DIV_RESET2) \
151 rcr2 |= RCR2_RESET; \
152 ctrl_outb(rcr2, RCR2); \
153 break; \
154 case RTC_REG_B: /* RTC_CONTROL */ \
155 rcr1 = (ctrl_inb(RCR1) & 0x99) | RCR1_AF; \
156 if(val & RTC_AIE) rcr1 |= RCR1_AIE; \
157 else rcr1 &= ~RCR1_AIE; \
158 if(val & RTC_UIE) rcr1 |= RCR1_CIE; \
159 else rcr1 &= ~RCR1_CIE; \
160 ctrl_outb(rcr1, RCR1); \
161 rcr2 = ctrl_inb(RCR2); \
162 if(val & RTC_SET) rcr2 &= ~RCR2_START; \
163 else rcr2 |= RCR2_START; \
164 ctrl_outb(rcr2, RCR2); \
165 break; \
166 case RTC_REG_C: /* RTC_INTR_FLAGS */ \
167 break; \
168 case RTC_REG_D: /* RTC_VALID */ \
169 break; \
170 default: \
171 break; \
172 } \
173})
174
175#endif /* CONFIG_SH_MPC1211 */
176#endif /* _ASM_MC146818RTC_H */ 7#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-sh/mmu.h b/include/asm-sh/mmu.h
index 72f07be6117f..cf47df79bb94 100644
--- a/include/asm-sh/mmu.h
+++ b/include/asm-sh/mmu.h
@@ -3,27 +3,76 @@
3 3
4#if !defined(CONFIG_MMU) 4#if !defined(CONFIG_MMU)
5 5
6struct mm_rblock_struct {
7 int size;
8 int refcount;
9 void *kblock;
10};
11
12struct mm_tblock_struct {
13 struct mm_rblock_struct *rblock;
14 struct mm_tblock_struct *next;
15};
16
17typedef struct { 6typedef struct {
18 struct mm_tblock_struct tblock; 7 struct vm_list_struct *vmlist;
19 unsigned long end_brk; 8 unsigned long end_brk;
20} mm_context_t; 9} mm_context_t;
21 10
22#else 11#else
23 12
24/* Default "unsigned long" context */ 13/* Default "unsigned long" context */
25typedef unsigned long mm_context_t; 14typedef unsigned long mm_context_id_t;
15
16typedef struct {
17 mm_context_id_t id;
18 void *vdso;
19} mm_context_t;
26 20
27#endif /* CONFIG_MMU */ 21#endif /* CONFIG_MMU */
28#endif /* __MMH_H */ 22
23/*
24 * Privileged Space Mapping Buffer (PMB) definitions
25 */
26#define PMB_PASCR 0xff000070
27#define PMB_IRMCR 0xff000078
28
29#define PMB_ADDR 0xf6100000
30#define PMB_DATA 0xf7100000
31#define PMB_ENTRY_MAX 16
32#define PMB_E_MASK 0x0000000f
33#define PMB_E_SHIFT 8
34
35#define PMB_SZ_16M 0x00000000
36#define PMB_SZ_64M 0x00000010
37#define PMB_SZ_128M 0x00000080
38#define PMB_SZ_512M 0x00000090
39#define PMB_SZ_MASK PMB_SZ_512M
40#define PMB_C 0x00000008
41#define PMB_WT 0x00000001
42#define PMB_UB 0x00000200
43#define PMB_V 0x00000100
44
45#define PMB_NO_ENTRY (-1)
46
47struct pmb_entry;
48
49struct pmb_entry {
50 unsigned long vpn;
51 unsigned long ppn;
52 unsigned long flags;
53
54 /*
55 * 0 .. NR_PMB_ENTRIES for specific entry selection, or
56 * PMB_NO_ENTRY to search for a free one
57 */
58 int entry;
59
60 struct pmb_entry *next;
61 /* Adjacent entry link for contiguous multi-entry mappings */
62 struct pmb_entry *link;
63};
64
65/* arch/sh/mm/pmb.c */
66int __set_pmb_entry(unsigned long vpn, unsigned long ppn,
67 unsigned long flags, int *entry);
68int set_pmb_entry(struct pmb_entry *pmbe);
69void clear_pmb_entry(struct pmb_entry *pmbe);
70struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn,
71 unsigned long flags);
72void pmb_free(struct pmb_entry *pmbe);
73long pmb_remap(unsigned long virt, unsigned long phys,
74 unsigned long size, unsigned long flags);
75void pmb_unmap(unsigned long addr);
76
77#endif /* __MMU_H */
29 78
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index 6760d064bd02..c7088efe579a 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -49,7 +49,7 @@ get_mmu_context(struct mm_struct *mm)
49 unsigned long mc = mmu_context_cache; 49 unsigned long mc = mmu_context_cache;
50 50
51 /* Check if we have old version of context. */ 51 /* Check if we have old version of context. */
52 if (((mm->context ^ mc) & MMU_CONTEXT_VERSION_MASK) == 0) 52 if (((mm->context.id ^ mc) & MMU_CONTEXT_VERSION_MASK) == 0)
53 /* It's up to date, do nothing */ 53 /* It's up to date, do nothing */
54 return; 54 return;
55 55
@@ -68,7 +68,7 @@ get_mmu_context(struct mm_struct *mm)
68 if (!mc) 68 if (!mc)
69 mmu_context_cache = mc = MMU_CONTEXT_FIRST_VERSION; 69 mmu_context_cache = mc = MMU_CONTEXT_FIRST_VERSION;
70 } 70 }
71 mm->context = mc; 71 mm->context.id = mc;
72} 72}
73 73
74/* 74/*
@@ -78,7 +78,7 @@ get_mmu_context(struct mm_struct *mm)
78static __inline__ int init_new_context(struct task_struct *tsk, 78static __inline__ int init_new_context(struct task_struct *tsk,
79 struct mm_struct *mm) 79 struct mm_struct *mm)
80{ 80{
81 mm->context = NO_CONTEXT; 81 mm->context.id = NO_CONTEXT;
82 82
83 return 0; 83 return 0;
84} 84}
@@ -123,7 +123,7 @@ static __inline__ unsigned long get_asid(void)
123static __inline__ void activate_context(struct mm_struct *mm) 123static __inline__ void activate_context(struct mm_struct *mm)
124{ 124{
125 get_mmu_context(mm); 125 get_mmu_context(mm);
126 set_asid(mm->context & MMU_CONTEXT_ASID_MASK); 126 set_asid(mm->context.id & MMU_CONTEXT_ASID_MASK);
127} 127}
128 128
129/* MMU_TTB can be used for optimizing the fault handling. 129/* MMU_TTB can be used for optimizing the fault handling.
@@ -174,9 +174,7 @@ static inline void enable_mmu(void)
174{ 174{
175 /* Enable MMU */ 175 /* Enable MMU */
176 ctrl_outl(MMU_CONTROL_INIT, MMUCR); 176 ctrl_outl(MMU_CONTROL_INIT, MMUCR);
177 177 ctrl_barrier();
178 /* The manual suggests doing some nops after turning on the MMU */
179 __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop\n\t");
180 178
181 if (mmu_context_cache == NO_CONTEXT) 179 if (mmu_context_cache == NO_CONTEXT)
182 mmu_context_cache = MMU_CONTEXT_FIRST_VERSION; 180 mmu_context_cache = MMU_CONTEXT_FIRST_VERSION;
@@ -191,7 +189,8 @@ static inline void disable_mmu(void)
191 cr = ctrl_inl(MMUCR); 189 cr = ctrl_inl(MMUCR);
192 cr &= ~MMU_CONTROL_INIT; 190 cr &= ~MMU_CONTROL_INIT;
193 ctrl_outl(cr, MMUCR); 191 ctrl_outl(cr, MMUCR);
194 __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop\n\t"); 192
193 ctrl_barrier();
195} 194}
196#else 195#else
197/* 196/*
diff --git a/include/asm-sh/overdrive/fpga.h b/include/asm-sh/overdrive/fpga.h
deleted file mode 100644
index 1cd87992c124..000000000000
--- a/include/asm-sh/overdrive/fpga.h
+++ /dev/null
@@ -1,15 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 */
8
9#ifndef __FPGA_OD_H__
10#define __FPGA_OD_H__
11
12/* This routine will program up the fpga which interfaces to the galileo */
13int init_overdrive_fpga(void);
14
15#endif
diff --git a/include/asm-sh/overdrive/gt64111.h b/include/asm-sh/overdrive/gt64111.h
deleted file mode 100644
index 01d58bc13a44..000000000000
--- a/include/asm-sh/overdrive/gt64111.h
+++ /dev/null
@@ -1,109 +0,0 @@
1#ifndef _GT64111_H_
2#define _GT64111_H_
3
4#define MASTER_INTERFACE 0x0
5#define RAS10_LO_DEC_ADR 0x8
6#define RAS10_HI_DEC_ADR 0x10
7#define RAS32_LO_DEC_ADR 0x18
8#define RAS32_HI_DEC_ADR 0x20
9#define CS20_LO_DEC_ADR 0x28
10#define CS20_HI_DEC_ADR 0x30
11#define CS3_LO_DEC_ADR 0x38
12#define CS3_HI_DEC_ADR 0x40
13#define PCI_IO_LO_DEC_ADR 0x48
14#define PCI_IO_HI_DEC_ADR 0x50
15#define PCI_MEM0_LO_DEC_ADR 0x58
16#define PCI_MEM0_HI_DEC_ADR 0x60
17#define INTERNAL_SPACE_DEC 0x68
18#define BUS_ERR_ADR_LO_CPU 0x70
19#define READONLY0 0x78
20#define PCI_MEM1_LO_DEC_ADR 0x80
21#define PCI_MEM1_HI_DEC_ADR 0x88
22#define RAS0_LO_DEC_ADR 0x400
23#define RAS0_HI_DEC_ADR 0x404
24#define RAS1_LO_DEC_ADR 0x408
25#define RAS1_HI_DEC_ADR 0x40c
26#define RAS2_LO_DEC_ADR 0x410
27#define RAS2_HI_DEC_ADR 0x414
28#define RAS3_LO_DEC_ADR 0x418
29#define RAS3_HI_DEC_ADR 0x41c
30#define DEV_CS0_LO_DEC_ADR 0x420
31#define DEV_CS0_HI_DEC_ADR 0x424
32#define DEV_CS1_LO_DEC_ADR 0x428
33#define DEV_CS1_HI_DEC_ADR 0x42c
34#define DEV_CS2_LO_DEC_ADR 0x430
35#define DEV_CS2_HI_DEC_ADR 0x434
36#define DEV_CS3_LO_DEC_ADR 0x438
37#define DEV_CS3_HI_DEC_ADR 0x43c
38#define DEV_BOOTCS_LO_DEC_ADR 0x440
39#define DEV_BOOTCS_HI_DEC_ADR 0x444
40#define DEV_ADR_DEC_ERR 0x470
41#define DRAM_CFG 0x448
42#define DRAM_BANK0_PARMS 0x44c
43#define DRAM_BANK1_PARMS 0x450
44#define DRAM_BANK2_PARMS 0x454
45#define DRAM_BANK3_PARMS 0x458
46#define DEV_BANK0_PARMS 0x45c
47#define DEV_BANK1_PARMS 0x460
48#define DEV_BANK2_PARMS 0x464
49#define DEV_BANK3_PARMS 0x468
50#define DEV_BOOT_BANK_PARMS 0x46c
51#define CH0_DMA_BYTECOUNT 0x800
52#define CH1_DMA_BYTECOUNT 0x804
53#define CH2_DMA_BYTECOUNT 0x808
54#define CH3_DMA_BYTECOUNT 0x80c
55#define CH0_DMA_SRC_ADR 0x810
56#define CH1_DMA_SRC_ADR 0x814
57#define CH2_DMA_SRC_ADR 0x818
58#define CH3_DMA_SRC_ADR 0x81c
59#define CH0_DMA_DST_ADR 0x820
60#define CH1_DMA_DST_ADR 0x824
61#define CH2_DMA_DST_ADR 0x828
62#define CH3_DMA_DST_ADR 0x82c
63#define CH0_NEXT_REC_PTR 0x830
64#define CH1_NEXT_REC_PTR 0x834
65#define CH2_NEXT_REC_PTR 0x838
66#define CH3_NEXT_REC_PTR 0x83c
67#define CH0_CTRL 0x840
68#define CH1_CTRL 0x844
69#define CH2_CTRL 0x848
70#define CH3_CTRL 0x84c
71#define DMA_ARBITER 0x860
72#define TIMER0 0x850
73#define TIMER1 0x854
74#define TIMER2 0x858
75#define TIMER3 0x85c
76#define TIMER_CTRL 0x864
77#define PCI_CMD 0xc00
78#define PCI_TIMEOUT 0xc04
79#define PCI_RAS10_BANK_SIZE 0xc08
80#define PCI_RAS32_BANK_SIZE 0xc0c
81#define PCI_CS20_BANK_SIZE 0xc10
82#define PCI_CS3_BANK_SIZE 0xc14
83#define PCI_SERRMASK 0xc28
84#define PCI_INTACK 0xc34
85#define PCI_BAR_EN 0xc3c
86#define PCI_CFG_ADR 0xcf8
87#define PCI_CFG_DATA 0xcfc
88#define PCI_INTCAUSE 0xc18
89#define PCI_MAST_MASK 0xc1c
90#define PCI_PCIMASK 0xc24
91#define BAR_ENABLE_ADR 0xc3c
92
93/* These are config registers, accessible via PCI space */
94#define PCI_CONFIG_RAS10_BASE_ADR 0x010
95#define PCI_CONFIG_RAS32_BASE_ADR 0x014
96#define PCI_CONFIG_CS20_BASE_ADR 0x018
97#define PCI_CONFIG_CS3_BASE_ADR 0x01c
98#define PCI_CONFIG_INT_REG_MM_ADR 0x020
99#define PCI_CONFIG_INT_REG_IO_ADR 0x024
100#define PCI_CONFIG_BOARD_VENDOR 0x02c
101#define PCI_CONFIG_ROM_ADR 0x030
102#define PCI_CONFIG_INT_PIN_LINE 0x03c
103
104
105
106
107
108#endif
109
diff --git a/include/asm-sh/overdrive/io.h b/include/asm-sh/overdrive/io.h
deleted file mode 100644
index 0dba700e9643..000000000000
--- a/include/asm-sh/overdrive/io.h
+++ /dev/null
@@ -1,39 +0,0 @@
1/*
2 * include/asm-sh/io_od.h
3 *
4 * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * IO functions for an STMicroelectronics Overdrive
10 */
11
12#ifndef _ASM_SH_IO_OD_H
13#define _ASM_SH_IO_OD_H
14
15extern unsigned char od_inb(unsigned long port);
16extern unsigned short od_inw(unsigned long port);
17extern unsigned int od_inl(unsigned long port);
18
19extern void od_outb(unsigned char value, unsigned long port);
20extern void od_outw(unsigned short value, unsigned long port);
21extern void od_outl(unsigned int value, unsigned long port);
22
23extern unsigned char od_inb_p(unsigned long port);
24extern unsigned short od_inw_p(unsigned long port);
25extern unsigned int od_inl_p(unsigned long port);
26extern void od_outb_p(unsigned char value, unsigned long port);
27extern void od_outw_p(unsigned short value, unsigned long port);
28extern void od_outl_p(unsigned int value, unsigned long port);
29
30extern void od_insb(unsigned long port, void *addr, unsigned long count);
31extern void od_insw(unsigned long port, void *addr, unsigned long count);
32extern void od_insl(unsigned long port, void *addr, unsigned long count);
33extern void od_outsb(unsigned long port, const void *addr, unsigned long count);
34extern void od_outsw(unsigned long port, const void *addr, unsigned long count);
35extern void od_outsl(unsigned long port, const void *addr, unsigned long count);
36
37extern unsigned long od_isa_port2addr(unsigned long offset);
38
39#endif /* _ASM_SH_IO_OD_H */
diff --git a/include/asm-sh/overdrive/overdrive.h b/include/asm-sh/overdrive/overdrive.h
deleted file mode 100644
index fc746c244f83..000000000000
--- a/include/asm-sh/overdrive/overdrive.h
+++ /dev/null
@@ -1,88 +0,0 @@
1/*
2 * Copyright (C) 2000 David J. Mckay (david.mckay@st.com)
3 *
4 * May be copied or modified under the terms of the GNU General Public
5 * License. See linux/COPYING for more information.
6 *
7 */
8
9
10#ifndef __OVERDRIVE_H__
11#define __OVERDRIVE_H__
12
13#define OVERDRIVE_INT_CT 0xa3a00000
14#define OVERDRIVE_INT_DT 0xa3b00000
15
16#define OVERDRIVE_CTRL 0xa3000000
17
18/* Shoving all these bits into the same register is not a good idea.
19 * As soon as I get a spare moment, I'll change the FPGA and put each
20 * bit in a separate register
21 */
22
23#define VALID_CTRL_BITS 0x1f
24
25#define ENABLE_RS232_MASK 0x1e
26#define DISABLE_RS232_BIT 0x01
27
28#define ENABLE_NMI_MASK 0x1d
29#define DISABLE_NMI_BIT 0x02
30
31#define RESET_PCI_MASK 0x1b
32#define ENABLE_PCI_BIT 0x04
33
34#define ENABLE_LED_MASK 0x17
35#define DISABLE_LED_BIT 0x08
36
37#define RESET_FPGA_MASK 0x0f
38#define ENABLE_FPGA_BIT 0x10
39
40
41#define FPGA_DCLK_ADDRESS 0xA3C00000
42
43#define FPGA_DATA 0x01 /* W */
44#define FPGA_CONFDONE 0x02 /* R */
45#define FPGA_NOT_STATUS 0x04 /* R */
46#define FPGA_INITDONE 0x08 /* R */
47
48#define FPGA_TIMEOUT 100000
49
50
51/* Interrupts for the overdrive. Note that these numbers have
52 * nothing to do with the actual IRQ numbers they appear on,
53 * this is all programmable. This is simply the position in the
54 * INT_CT register.
55 */
56
57#define OVERDRIVE_PCI_INTA 0
58#define OVERDRIVE_PCI_INTB 1
59#define OVERDRIVE_PCI_INTC 2
60#define OVERDRIVE_PCI_INTD 3
61#define OVERDRIVE_GALILEO_INT 4
62#define OVERDRIVE_GALILEO_LOCAL_INT 5
63#define OVERDRIVE_AUDIO_INT 6
64#define OVERDRIVE_KEYBOARD_INT 7
65
66/* Which Linux IRQ should we assign to each interrupt source? */
67#define OVERDRIVE_PCI_IRQ1 2
68#ifdef CONFIG_HACKED_NE2K
69#define OVERDRIVE_PCI_IRQ2 7
70#else
71#define OVERDRIVE_PCI_IRQ2 2
72#undef OVERDRIVE_PCI_INTB
73#define OVERDRIVE_PCI_INTB OVERDRIVE_PCI_INTA
74
75#endif
76
77/* Put the ESS solo audio chip on IRQ 4 */
78#define OVERDRIVE_ESS_IRQ 4
79
80/* Where the memory behind the PCI bus appears */
81#define PCI_DRAM_BASE 0xb7000000
82#define PCI_DRAM_SIZE (16*1024*1024)
83#define PCI_DRAM_FINISH (PCI_DRAM_BASE+PCI_DRAM_SIZE-1)
84
85/* Where the IO region appears in the memory */
86#define PCI_GTIO_BASE 0xb8000000
87
88#endif
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index 6f7eb8a3aba5..ca8b26d90475 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -16,7 +16,13 @@
16 16
17/* PAGE_SHIFT determines the page size */ 17/* PAGE_SHIFT determines the page size */
18#define PAGE_SHIFT 12 18#define PAGE_SHIFT 12
19
20#ifdef __ASSEMBLY__
21#define PAGE_SIZE (1 << PAGE_SHIFT)
22#else
19#define PAGE_SIZE (1UL << PAGE_SHIFT) 23#define PAGE_SIZE (1UL << PAGE_SHIFT)
24#endif
25
20#define PAGE_MASK (~(PAGE_SIZE-1)) 26#define PAGE_MASK (~(PAGE_SIZE-1))
21#define PTE_MASK PAGE_MASK 27#define PTE_MASK PAGE_MASK
22 28
@@ -30,7 +36,6 @@
30#define HPAGE_SIZE (1UL << HPAGE_SHIFT) 36#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
31#define HPAGE_MASK (~(HPAGE_SIZE-1)) 37#define HPAGE_MASK (~(HPAGE_SIZE-1))
32#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT) 38#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
33#define ARCH_HAS_SETCLEAR_HUGE_PTE
34#endif 39#endif
35 40
36#ifdef __KERNEL__ 41#ifdef __KERNEL__
@@ -39,10 +44,18 @@
39extern void (*clear_page)(void *to); 44extern void (*clear_page)(void *to);
40extern void (*copy_page)(void *to, void *from); 45extern void (*copy_page)(void *to, void *from);
41 46
47extern unsigned long shm_align_mask;
48
49#ifdef CONFIG_MMU
42extern void clear_page_slow(void *to); 50extern void clear_page_slow(void *to);
43extern void copy_page_slow(void *to, void *from); 51extern void copy_page_slow(void *to, void *from);
52#else
53extern void clear_page_nommu(void *to);
54extern void copy_page_nommu(void *to, void *from);
55#endif
44 56
45#if defined(CONFIG_SH7705_CACHE_32KB) && defined(CONFIG_MMU) 57#if defined(CONFIG_MMU) && (defined(CONFIG_CPU_SH4) || \
58 defined(CONFIG_SH7705_CACHE_32KB))
46struct page; 59struct page;
47extern void clear_user_page(void *to, unsigned long address, struct page *pg); 60extern void clear_user_page(void *to, unsigned long address, struct page *pg);
48extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); 61extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
@@ -51,29 +64,20 @@ extern void __copy_user_page(void *to, void *from, void *orig_to);
51#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU) 64#elif defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH3) || !defined(CONFIG_MMU)
52#define clear_user_page(page, vaddr, pg) clear_page(page) 65#define clear_user_page(page, vaddr, pg) clear_page(page)
53#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 66#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
54#elif defined(CONFIG_CPU_SH4)
55struct page;
56extern void clear_user_page(void *to, unsigned long address, struct page *pg);
57extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
58extern void __clear_user_page(void *to, void *orig_to);
59extern void __copy_user_page(void *to, void *from, void *orig_to);
60#endif 67#endif
61 68
62/* 69/*
63 * These are used to make use of C type-checking.. 70 * These are used to make use of C type-checking..
64 */ 71 */
65typedef struct { unsigned long pte; } pte_t; 72typedef struct { unsigned long pte; } pte_t;
66typedef struct { unsigned long pmd; } pmd_t;
67typedef struct { unsigned long pgd; } pgd_t; 73typedef struct { unsigned long pgd; } pgd_t;
68typedef struct { unsigned long pgprot; } pgprot_t; 74typedef struct { unsigned long pgprot; } pgprot_t;
69 75
70#define pte_val(x) ((x).pte) 76#define pte_val(x) ((x).pte)
71#define pmd_val(x) ((x).pmd)
72#define pgd_val(x) ((x).pgd) 77#define pgd_val(x) ((x).pgd)
73#define pgprot_val(x) ((x).pgprot) 78#define pgprot_val(x) ((x).pgprot)
74 79
75#define __pte(x) ((pte_t) { (x) } ) 80#define __pte(x) ((pte_t) { (x) } )
76#define __pmd(x) ((pmd_t) { (x) } )
77#define __pgd(x) ((pgd_t) { (x) } ) 81#define __pgd(x) ((pgd_t) { (x) } )
78#define __pgprot(x) ((pgprot_t) { (x) } ) 82#define __pgprot(x) ((pgprot_t) { (x) } )
79 83
@@ -93,7 +97,7 @@ typedef struct { unsigned long pgprot; } pgprot_t;
93#define __MEMORY_START CONFIG_MEMORY_START 97#define __MEMORY_START CONFIG_MEMORY_START
94#define __MEMORY_SIZE CONFIG_MEMORY_SIZE 98#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
95 99
96#define PAGE_OFFSET (0x80000000UL) 100#define PAGE_OFFSET CONFIG_PAGE_OFFSET
97#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) 101#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
98#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 102#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
99 103
@@ -115,5 +119,10 @@ typedef struct { unsigned long pgprot; } pgprot_t;
115#include <asm-generic/memory_model.h> 119#include <asm-generic/memory_model.h>
116#include <asm-generic/page.h> 120#include <asm-generic/page.h>
117 121
122/* vDSO support */
123#ifdef CONFIG_VSYSCALL
124#define __HAVE_ARCH_GATE_AREA
125#endif
126
118#endif /* __KERNEL__ */ 127#endif /* __KERNEL__ */
119#endif /* __ASM_SH_PAGE_H */ 128#endif /* __ASM_SH_PAGE_H */
diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h
index 0a523c85b11c..6ccc948fe216 100644
--- a/include/asm-sh/pci.h
+++ b/include/asm-sh/pci.h
@@ -32,6 +32,34 @@ extern struct pci_channel board_pci_channels[];
32#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start 32#define PCIBIOS_MIN_IO board_pci_channels->io_resource->start
33#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start 33#define PCIBIOS_MIN_MEM board_pci_channels->mem_resource->start
34 34
35/*
36 * I/O routine helpers
37 */
38#ifdef CONFIG_CPU_SUBTYPE_SH7780
39#define PCI_IO_AREA 0xFE400000
40#define PCI_IO_SIZE 0x00400000
41#else
42#define PCI_IO_AREA 0xFE240000
43#define PCI_IO_SIZE 0X00040000
44#endif
45
46#define PCI_MEM_SIZE 0x01000000
47
48#define SH4_PCIIOBR_MASK 0xFFFC0000
49#define pci_ioaddr(addr) (PCI_IO_AREA + (addr & ~SH4_PCIIOBR_MASK))
50
51#if defined(CONFIG_PCI)
52#define is_pci_ioaddr(port) \
53 (((port) >= PCIBIOS_MIN_IO) && \
54 ((port) < (PCIBIOS_MIN_IO + PCI_IO_SIZE)))
55#define is_pci_memaddr(port) \
56 (((port) >= PCIBIOS_MIN_MEM) && \
57 ((port) < (PCIBIOS_MIN_MEM + PCI_MEM_SIZE)))
58#else
59#define is_pci_ioaddr(port) (0)
60#define is_pci_memaddr(port) (0)
61#endif
62
35struct pci_dev; 63struct pci_dev;
36 64
37extern void pcibios_set_master(struct pci_dev *dev); 65extern void pcibios_set_master(struct pci_dev *dev);
@@ -87,15 +115,6 @@ static inline void pcibios_penalize_isa_irq(int irq, int active)
87 */ 115 */
88#define pci_dac_dma_supported(pci_dev, mask) (0) 116#define pci_dac_dma_supported(pci_dev, mask) (0)
89 117
90/* These macros should be used after a pci_map_sg call has been done
91 * to get bus addresses of each of the SG entries and their lengths.
92 * You should only work with the number of sg entries pci_map_sg
93 * returns, or alternatively stop on the first sg_dma_len(sg) which
94 * is 0.
95 */
96#define sg_dma_address(sg) (virt_to_bus((sg)->dma_address))
97#define sg_dma_len(sg) ((sg)->length)
98
99#ifdef CONFIG_PCI 118#ifdef CONFIG_PCI
100static inline void pci_dma_burst_advice(struct pci_dev *pdev, 119static inline void pci_dma_burst_advice(struct pci_dev *pdev,
101 enum pci_dma_burst_strategy *strat, 120 enum pci_dma_burst_strategy *strat,
@@ -107,11 +126,12 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
107#endif 126#endif
108 127
109/* Board-specific fixup routines. */ 128/* Board-specific fixup routines. */
110extern void pcibios_fixup(void); 129void pcibios_fixup(void);
111extern void pcibios_fixup_irqs(void); 130int pcibios_init_platform(void);
131int pcibios_map_platform_irq(struct pci_dev *dev, u8 slot, u8 pin);
112 132
113#ifdef CONFIG_PCI_AUTO 133#ifdef CONFIG_PCI_AUTO
114extern int pciauto_assign_resources(int busno, struct pci_channel *hose); 134int pciauto_assign_resources(int busno, struct pci_channel *hose);
115#endif 135#endif
116 136
117static inline void pcibios_add_platform_entries(struct pci_dev *dev) 137static inline void pcibios_add_platform_entries(struct pci_dev *dev)
diff --git a/include/asm-sh/pgalloc.h b/include/asm-sh/pgalloc.h
index f4f233f7a4f5..e841465ab4d2 100644
--- a/include/asm-sh/pgalloc.h
+++ b/include/asm-sh/pgalloc.h
@@ -1,15 +1,6 @@
1#ifndef __ASM_SH_PGALLOC_H 1#ifndef __ASM_SH_PGALLOC_H
2#define __ASM_SH_PGALLOC_H 2#define __ASM_SH_PGALLOC_H
3 3
4#include <linux/threads.h>
5#include <linux/slab.h>
6#include <linux/mm.h>
7
8#define pgd_quicklist ((unsigned long *)0)
9#define pmd_quicklist ((unsigned long *)0)
10#define pte_quicklist ((unsigned long *)0)
11#define pgtable_cache_size 0L
12
13#define pmd_populate_kernel(mm, pmd, pte) \ 4#define pmd_populate_kernel(mm, pmd, pte) \
14 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))) 5 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
15 6
@@ -24,38 +15,24 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
24 */ 15 */
25static inline pgd_t *pgd_alloc(struct mm_struct *mm) 16static inline pgd_t *pgd_alloc(struct mm_struct *mm)
26{ 17{
27 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t)); 18 return (pgd_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
28 pgd_t *pgd = (pgd_t *)kmalloc(pgd_size, GFP_KERNEL);
29
30 if (pgd)
31 memset(pgd, 0, pgd_size);
32
33 return pgd;
34} 19}
35 20
36static inline void pgd_free(pgd_t *pgd) 21static inline void pgd_free(pgd_t *pgd)
37{ 22{
38 kfree(pgd); 23 free_page((unsigned long)pgd);
39} 24}
40 25
41static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, 26static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
42 unsigned long address) 27 unsigned long address)
43{ 28{
44 pte_t *pte; 29 return (pte_t *)__get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
45
46 pte = (pte_t *) __get_free_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
47
48 return pte;
49} 30}
50 31
51static inline struct page *pte_alloc_one(struct mm_struct *mm, 32static inline struct page *pte_alloc_one(struct mm_struct *mm,
52 unsigned long address) 33 unsigned long address)
53{ 34{
54 struct page *pte; 35 return alloc_page(GFP_KERNEL | __GFP_REPEAT | __GFP_ZERO);
55
56 pte = alloc_pages(GFP_KERNEL|__GFP_REPEAT|__GFP_ZERO, 0);
57
58 return pte;
59} 36}
60 37
61static inline void pte_free_kernel(pte_t *pte) 38static inline void pte_free_kernel(pte_t *pte)
@@ -75,14 +52,8 @@ static inline void pte_free(struct page *pte)
75 * inside the pgd, so has no extra memory associated with it. 52 * inside the pgd, so has no extra memory associated with it.
76 */ 53 */
77 54
78#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
79#define pmd_free(x) do { } while (0) 55#define pmd_free(x) do { } while (0)
80#define __pmd_free_tlb(tlb,x) do { } while (0) 56#define __pmd_free_tlb(tlb,x) do { } while (0)
81#define pgd_populate(mm, pmd, pte) BUG()
82#define check_pgt_cache() do { } while (0) 57#define check_pgt_cache() do { } while (0)
83 58
84#ifdef CONFIG_CPU_SH4
85#define PG_mapped PG_arch_1
86#endif
87
88#endif /* __ASM_SH_PGALLOC_H */ 59#endif /* __ASM_SH_PGALLOC_H */
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index 40d41a78041e..2c8682ad1012 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -1,42 +1,42 @@
1#ifndef __ASM_SH_PGTABLE_H
2#define __ASM_SH_PGTABLE_H
3
4#include <asm-generic/4level-fixup.h>
5
6/* 1/*
2 * This file contains the functions and defines necessary to modify and
3 * use the SuperH page table tree.
4 *
7 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
8 * Copyright (C) 2002, 2003, 2004 Paul Mundt 6 * Copyright (C) 2002 - 2005 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this
10 * archive for more details.
9 */ 11 */
12#ifndef __ASM_SH_PGTABLE_H
13#define __ASM_SH_PGTABLE_H
10 14
11#include <asm/pgtable-2level.h> 15#include <asm-generic/pgtable-nopmd.h>
16#include <asm/page.h>
17
18#define PTRS_PER_PGD 1024
12 19
13/*
14 * This file contains the functions and defines necessary to modify and use
15 * the SuperH page table tree.
16 */
17#ifndef __ASSEMBLY__ 20#ifndef __ASSEMBLY__
18#include <asm/processor.h>
19#include <asm/addrspace.h> 21#include <asm/addrspace.h>
20#include <asm/fixmap.h> 22#include <asm/fixmap.h>
21#include <linux/threads.h>
22 23
23extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 24extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
24extern void paging_init(void); 25extern void paging_init(void);
25 26
26/* 27/*
27 * Basically we have the same two-level (which is the logical three level
28 * Linux page table layout folded) page tables as the i386.
29 */
30
31/*
32 * ZERO_PAGE is a global shared page that is always zero: used 28 * ZERO_PAGE is a global shared page that is always zero: used
33 * for zero-mapped memory areas etc.. 29 * for zero-mapped memory areas etc..
34 */ 30 */
35extern unsigned long empty_zero_page[1024]; 31extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
36#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page)) 32#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
37 33
38#endif /* !__ASSEMBLY__ */ 34#endif /* !__ASSEMBLY__ */
39 35
36/* traditional two-level paging structure */
37#define PGDIR_SHIFT 22
38#define PTRS_PER_PMD 1
39#define PTRS_PER_PTE 1024
40#define PMD_SIZE (1UL << PMD_SHIFT) 40#define PMD_SIZE (1UL << PMD_SHIFT)
41#define PMD_MASK (~(PMD_SIZE-1)) 41#define PMD_MASK (~(PMD_SIZE-1))
42#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 42#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
@@ -47,7 +47,6 @@ extern unsigned long empty_zero_page[1024];
47 47
48#define PTE_PHYS_MASK 0x1ffff000 48#define PTE_PHYS_MASK 0x1ffff000
49 49
50#ifndef __ASSEMBLY__
51/* 50/*
52 * First 1MB map is used by fixed purpose. 51 * First 1MB map is used by fixed purpose.
53 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c) 52 * Currently only 4-enty (16kB) is used (see arch/sh/mm/cache.c)
@@ -55,20 +54,41 @@ extern unsigned long empty_zero_page[1024];
55#define VMALLOC_START (P3SEG+0x00100000) 54#define VMALLOC_START (P3SEG+0x00100000)
56#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE) 55#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
57 56
58#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */ 57/*
59#define _PAGE_HW_SHARED 0x002 /* SH-bit : page is shared among processes */ 58 * Linux PTEL encoding.
60#define _PAGE_DIRTY 0x004 /* D-bit : page changed */ 59 *
61#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */ 60 * Hardware and software bit definitions for the PTEL value:
62#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */ 61 *
63#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */ 62 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4).
64#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */ 63 *
65#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */ 64 * - Bit 1 is the SH-bit, but is unused on SH-3 due to an MMU bug (the
66#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */ 65 * hardware PTEL value can't have the SH-bit set when MMUCR.IX is set,
67#define _PAGE_PROTNONE 0x200 /* software: if not present */ 66 * which is the default in cpu-sh3/mmu_context.h:MMU_CONTROL_INIT).
68#define _PAGE_ACCESSED 0x400 /* software: page referenced */ 67 *
69#define _PAGE_U0_SHARED 0x800 /* software: page is shared in user space */ 68 * In order to keep this relatively clean, do not use these for defining
70 69 * SH-3 specific flags until all of the other unused bits have been
71#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */ 70 * exhausted.
71 *
72 * - Bit 9 is reserved by everyone and used by _PAGE_PROTNONE.
73 *
74 * - Bits 10 and 11 are low bits of the PPN that are reserved on >= 4K pages.
75 * Bit 10 is used for _PAGE_ACCESSED, bit 11 remains unused.
76 *
77 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future
78 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS.
79 */
80#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */
81#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */
82#define _PAGE_DIRTY 0x004 /* D-bit : page changed */
83#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */
84#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */
85#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */
86#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed */
87#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
88#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
89#define _PAGE_PROTNONE 0x200 /* software: if not present */
90#define _PAGE_ACCESSED 0x400 /* software: page referenced */
91#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
72 92
73/* software: moves to PTEA.TC (Timing Control) */ 93/* software: moves to PTEA.TC (Timing Control) */
74#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */ 94#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */
@@ -83,23 +103,17 @@ extern unsigned long empty_zero_page[1024];
83#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */ 103#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */
84#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */ 104#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */
85 105
86 106/* Mask which drops unused bits from the PTEL value */
87/* Mask which drop software flags 107#ifdef CONFIG_CPU_SH3
88 * We also drop WT bit since it is used for _PAGE_FILE 108#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED| \
89 * bit in this implementation. 109 _PAGE_FILE | _PAGE_SZ1 | \
90 */ 110 _PAGE_HW_SHARED)
91#define _PAGE_CLEAR_FLAGS (_PAGE_WT | _PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_U0_SHARED)
92
93#if defined(CONFIG_CPU_SH3)
94/*
95 * MMU on SH-3 has bug on SH-bit: We can't use it if MMUCR.IX=1.
96 * Work around: Just drop SH-bit.
97 */
98#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS | _PAGE_HW_SHARED))
99#else 111#else
100#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 112#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE)
101#endif 113#endif
102 114
115#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS))
116
103/* Hardware flags: SZ0=1 (4k-byte) */ 117/* Hardware flags: SZ0=1 (4k-byte) */
104#define _PAGE_FLAGS_HARD _PAGE_SZ0 118#define _PAGE_FLAGS_HARD _PAGE_SZ0
105 119
@@ -109,15 +123,15 @@ extern unsigned long empty_zero_page[1024];
109#define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1) 123#define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1)
110#endif 124#endif
111 125
112#define _PAGE_SHARED _PAGE_U0_SHARED
113
114#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY) 126#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
115#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY) 127#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
116#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_SHARED) 128#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
129
130#ifndef __ASSEMBLY__
117 131
118#ifdef CONFIG_MMU 132#ifdef CONFIG_MMU
119#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD) 133#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD)
120#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_SHARED | _PAGE_FLAGS_HARD) 134#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_CACHABLE |_PAGE_ACCESSED | _PAGE_FLAGS_HARD)
121#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 135#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
122#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD) 136#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
123#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD) 137#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
@@ -137,12 +151,13 @@ extern unsigned long empty_zero_page[1024];
137#define PAGE_KERNEL_PCC __pgprot(0) 151#define PAGE_KERNEL_PCC __pgprot(0)
138#endif 152#endif
139 153
154#endif /* __ASSEMBLY__ */
155
140/* 156/*
141 * As i386 and MIPS, SuperH can't do page protection for execute, and 157 * As i386 and MIPS, SuperH can't do page protection for execute, and
142 * considers that the same as a read. Also, write permissions imply 158 * considers that the same as a read. Also, write permissions imply
143 * read permissions. This is the closest we can get.. 159 * read permissions. This is the closest we can get..
144 */ 160 */
145
146#define __P000 PAGE_NONE 161#define __P000 PAGE_NONE
147#define __P001 PAGE_READONLY 162#define __P001 PAGE_READONLY
148#define __P010 PAGE_COPY 163#define __P010 PAGE_COPY
@@ -161,6 +176,26 @@ extern unsigned long empty_zero_page[1024];
161#define __S110 PAGE_SHARED 176#define __S110 PAGE_SHARED
162#define __S111 PAGE_SHARED 177#define __S111 PAGE_SHARED
163 178
179#ifndef __ASSEMBLY__
180
181/*
182 * Certain architectures need to do special things when PTEs
183 * within a page table are directly modified. Thus, the following
184 * hook is made available.
185 */
186#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
187#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
188
189/*
190 * (pmds are folded into pgds so this doesn't get actually called,
191 * but the define is needed for a generic inline function.)
192 */
193#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
194
195#define pte_pfn(x) ((unsigned long)(((x).pte >> PAGE_SHIFT)))
196#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
197#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
198
164#define pte_none(x) (!pte_val(x)) 199#define pte_none(x) (!pte_val(x))
165#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 200#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
166#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 201#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
@@ -171,7 +206,7 @@ extern unsigned long empty_zero_page[1024];
171#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE) 206#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
172 207
173#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 208#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
174#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) 209#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK)
175 210
176/* 211/*
177 * The following only work if pte_present() is true. 212 * The following only work if pte_present() is true.
@@ -248,6 +283,11 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
248#define pte_unmap(pte) do { } while (0) 283#define pte_unmap(pte) do { } while (0)
249#define pte_unmap_nested(pte) do { } while (0) 284#define pte_unmap_nested(pte) do { } while (0)
250 285
286#define pte_ERROR(e) \
287 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
288#define pgd_ERROR(e) \
289 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
290
251struct vm_area_struct; 291struct vm_area_struct;
252extern void update_mmu_cache(struct vm_area_struct * vma, 292extern void update_mmu_cache(struct vm_area_struct * vma,
253 unsigned long address, pte_t pte); 293 unsigned long address, pte_t pte);
@@ -272,8 +312,6 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
272 312
273typedef pte_t *pte_addr_t; 313typedef pte_t *pte_addr_t;
274 314
275#endif /* !__ASSEMBLY__ */
276
277#define kern_addr_valid(addr) (1) 315#define kern_addr_valid(addr) (1)
278 316
279#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 317#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
@@ -301,5 +339,5 @@ extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t
301 339
302#include <asm-generic/pgtable.h> 340#include <asm-generic/pgtable.h>
303 341
342#endif /* !__ASSEMBLY__ */
304#endif /* __ASM_SH_PAGE_H */ 343#endif /* __ASM_SH_PAGE_H */
305
diff --git a/include/asm-sh/pm.h b/include/asm-sh/pm.h
new file mode 100644
index 000000000000..56fdbd6b1c94
--- /dev/null
+++ b/include/asm-sh/pm.h
@@ -0,0 +1,17 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright 2006 (c) Andriy Skulysh <askulysh@gmail.com>
7 *
8 */
9#ifndef __ASM_SH_PM_H
10#define __ASM_SH_PM_H
11
12extern u8 wakeup_start;
13extern u8 wakeup_end;
14
15void pm_enter(void);
16
17#endif
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index eeb0f48bb99e..474773853cd1 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -14,6 +14,7 @@
14#include <asm/types.h> 14#include <asm/types.h>
15#include <asm/cache.h> 15#include <asm/cache.h>
16#include <asm/ptrace.h> 16#include <asm/ptrace.h>
17#include <asm/cpu-features.h>
17 18
18/* 19/*
19 * Default implementation of macro that returns current 20 * Default implementation of macro that returns current
@@ -38,27 +39,30 @@ enum cpu_type {
38 CPU_SH7604, 39 CPU_SH7604,
39 40
40 /* SH-3 types */ 41 /* SH-3 types */
41 CPU_SH7705, CPU_SH7707, CPU_SH7708, CPU_SH7708S, CPU_SH7708R, 42 CPU_SH7705, CPU_SH7706, CPU_SH7707,
42 CPU_SH7709, CPU_SH7709A, CPU_SH7729, CPU_SH7300, 43 CPU_SH7708, CPU_SH7708S, CPU_SH7708R,
44 CPU_SH7709, CPU_SH7709A, CPU_SH7710,
45 CPU_SH7729, CPU_SH7300,
43 46
44 /* SH-4 types */ 47 /* SH-4 types */
45 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 48 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
46 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501, 49 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501,
47 CPU_SH73180, CPU_SH7770, CPU_SH7780, CPU_SH7781, 50 CPU_SH73180, CPU_SH7343, CPU_SH7770, CPU_SH7780, CPU_SH7781,
48 51
49 /* Unknown subtype */ 52 /* Unknown subtype */
50 CPU_SH_NONE 53 CPU_SH_NONE
51}; 54};
52 55
53struct sh_cpuinfo { 56struct sh_cpuinfo {
54 enum cpu_type type; 57 unsigned int type;
55 unsigned long loops_per_jiffy; 58 unsigned long loops_per_jiffy;
56 59
57 struct cache_info icache; 60 struct cache_info icache; /* Primary I-cache */
58 struct cache_info dcache; 61 struct cache_info dcache; /* Primary D-cache */
62 struct cache_info scache; /* Secondary cache */
59 63
60 unsigned long flags; 64 unsigned long flags;
61}; 65} __attribute__ ((aligned(SMP_CACHE_BYTES)));
62 66
63extern struct sh_cpuinfo boot_cpu_data; 67extern struct sh_cpuinfo boot_cpu_data;
64 68
@@ -125,17 +129,6 @@ union sh_fpu_union {
125 struct sh_fpu_soft_struct soft; 129 struct sh_fpu_soft_struct soft;
126}; 130};
127 131
128/*
129 * Processor flags
130 */
131
132#define CPU_HAS_FPU 0x0001 /* Hardware FPU support */
133#define CPU_HAS_P2_FLUSH_BUG 0x0002 /* Need to flush the cache in P2 area */
134#define CPU_HAS_MMU_PAGE_ASSOC 0x0004 /* SH3: TLB way selection bit support */
135#define CPU_HAS_DSP 0x0008 /* SH-DSP: DSP support */
136#define CPU_HAS_PERF_COUNTER 0x0010 /* Hardware performance counters */
137#define CPU_HAS_PTEA 0x0020 /* PTEA register */
138
139struct thread_struct { 132struct thread_struct {
140 unsigned long sp; 133 unsigned long sp;
141 unsigned long pc; 134 unsigned long pc;
@@ -149,6 +142,10 @@ struct thread_struct {
149 union sh_fpu_union fpu; 142 union sh_fpu_union fpu;
150}; 143};
151 144
145typedef struct {
146 unsigned long seg;
147} mm_segment_t;
148
152/* Count of active tasks with UBC settings */ 149/* Count of active tasks with UBC settings */
153extern int ubc_usercnt; 150extern int ubc_usercnt;
154 151
@@ -266,5 +263,24 @@ extern unsigned long get_wchan(struct task_struct *p);
266#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory") 263#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
267#define cpu_relax() barrier() 264#define cpu_relax() barrier()
268 265
266#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH3) || \
267 defined(CONFIG_CPU_SH4)
268#define PREFETCH_STRIDE L1_CACHE_BYTES
269#define ARCH_HAS_PREFETCH
270#define ARCH_HAS_PREFETCHW
271static inline void prefetch(void *x)
272{
273 __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
274}
275
276#define prefetchw(x) prefetch(x)
277#endif
278
279#ifdef CONFIG_VSYSCALL
280extern int vsyscall_init(void);
281#else
282#define vsyscall_init() do { } while (0)
283#endif
284
269#endif /* __KERNEL__ */ 285#endif /* __KERNEL__ */
270#endif /* __ASM_SH_PROCESSOR_H */ 286#endif /* __ASM_SH_PROCESSOR_H */
diff --git a/include/asm-sh/r7780rp/ide.h b/include/asm-sh/r7780rp/ide.h
new file mode 100644
index 000000000000..a1ed78e0f617
--- /dev/null
+++ b/include/asm-sh/r7780rp/ide.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_R7780RP_IDE_H
2#define __ASM_SH_R7780RP_IDE_H
3
4/* Nothing to see here.. */
5#include <asm/mach/r7780rp.h>
6
7#endif /* __ASM_SH_R7780RP_IDE_H */
8
diff --git a/include/asm-sh/r7780rp/r7780rp.h b/include/asm-sh/r7780rp/r7780rp.h
new file mode 100644
index 000000000000..f95d9dba31a2
--- /dev/null
+++ b/include/asm-sh/r7780rp/r7780rp.h
@@ -0,0 +1,177 @@
1#ifndef __ASM_SH_RENESAS_R7780RP_H
2#define __ASM_SH_RENESAS_R7780RP_H
3
4/*
5 * linux/include/asm-sh/r7780rp.h
6 *
7 * Copyright (C) 2000 Atom Create Engineering Co., Ltd.
8 *
9 * Renesas Solutions Highlander R7780RP support
10 */
11
12/* Box specific addresses. */
13#if defined(CONFIG_SH_R7780MP)
14#define PA_BCR 0xa4000000 /* FPGA */
15#define PA_IRLMSK (PA_BCR+0x0000) /* Interrupt Mask control */
16#define PA_IRLMON (PA_BCR+0x0002) /* Interrupt Status control */
17#define PA_IRLPRI1 (PA_BCR+0x0004) /* Interrupt Priorty 1 */
18#define PA_IRLPRI2 (PA_BCR+0x0006) /* Interrupt Priorty 2 */
19#define PA_IRLPRI3 (PA_BCR+0x0008) /* Interrupt Priorty 3 */
20#define PA_IRLPRI4 (PA_BCR+0x000a) /* Interrupt Priorty 4 */
21#define PA_RSTCTL (PA_BCR+0x000c) /* Reset Control */
22#define PA_PCIBD (PA_BCR+0x000e) /* PCI Board detect control */
23#define PA_PCICD (PA_BCR+0x0010) /* PCI Conector detect control */
24#define PA_EXTGIO (PA_BCR+0x0016) /* Extension GPIO Control */
25#define PA_IVDRMON (PA_BCR+0x0018) /* iVDR Moniter control */
26#define PA_IVDRCTL (PA_BCR+0x001a) /* iVDR control */
27#define PA_OBLED (PA_BCR+0x001c) /* On Board LED control */
28#define PA_OBSW (PA_BCR+0x001e) /* On Board Switch control */
29#define PA_AUDIOSEL (PA_BCR+0x0020) /* Sound Interface Select control */
30#define PA_EXTPLR (PA_BCR+0x001e) /* Extention Pin Polarity control */
31#define PA_TPCTL (PA_BCR+0x0100) /* Touch Panel Access control */
32#define PA_TPDCKCTL (PA_BCR+0x0102) /* Touch Panel Access data control */
33#define PA_TPCTLCLR (PA_BCR+0x0104) /* Touch Panel Access control */
34#define PA_TPXPOS (PA_BCR+0x0106) /* Touch Panel X position control */
35#define PA_TPYPOS (PA_BCR+0x0108) /* Touch Panel Y position control */
36#define PA_DBSW (PA_BCR+0x0200) /* Debug Board Switch control */
37#define PA_CFCTL (PA_BCR+0x0300) /* CF Timing control */
38#define PA_CFPOW (PA_BCR+0x0302) /* CF Power control */
39#define PA_CFCDINTCLR (PA_BCR+0x0304) /* CF Insert Interrupt clear */
40#define PA_SCSMR0 (PA_BCR+0x0400) /* SCIF0 Serial mode control */
41#define PA_SCBRR0 (PA_BCR+0x0404) /* SCIF0 Bit rate control */
42#define PA_SCSCR0 (PA_BCR+0x0408) /* SCIF0 Serial control */
43#define PA_SCFTDR0 (PA_BCR+0x040c) /* SCIF0 Send FIFO control */
44#define PA_SCFSR0 (PA_BCR+0x0410) /* SCIF0 Serial status control */
45#define PA_SCFRDR0 (PA_BCR+0x0414) /* SCIF0 Receive FIFO control */
46#define PA_SCFCR0 (PA_BCR+0x0418) /* SCIF0 FIFO control */
47#define PA_SCTFDR0 (PA_BCR+0x041c) /* SCIF0 Send FIFO data control */
48#define PA_SCRFDR0 (PA_BCR+0x0420) /* SCIF0 Receive FIFO data control */
49#define PA_SCSPTR0 (PA_BCR+0x0424) /* SCIF0 Serial Port control */
50#define PA_SCLSR0 (PA_BCR+0x0428) /* SCIF0 Line Status control */
51#define PA_SCRER0 (PA_BCR+0x042c) /* SCIF0 Serial Error control */
52#define PA_SCSMR1 (PA_BCR+0x0500) /* SCIF1 Serial mode control */
53#define PA_SCBRR1 (PA_BCR+0x0504) /* SCIF1 Bit rate control */
54#define PA_SCSCR1 (PA_BCR+0x0508) /* SCIF1 Serial control */
55#define PA_SCFTDR1 (PA_BCR+0x050c) /* SCIF1 Send FIFO control */
56#define PA_SCFSR1 (PA_BCR+0x0510) /* SCIF1 Serial status control */
57#define PA_SCFRDR1 (PA_BCR+0x0514) /* SCIF1 Receive FIFO control */
58#define PA_SCFCR1 (PA_BCR+0x0518) /* SCIF1 FIFO control */
59#define PA_SCTFDR1 (PA_BCR+0x051c) /* SCIF1 Send FIFO data control */
60#define PA_SCRFDR1 (PA_BCR+0x0520) /* SCIF1 Receive FIFO data control */
61#define PA_SCSPTR1 (PA_BCR+0x0524) /* SCIF1 Serial Port control */
62#define PA_SCLSR1 (PA_BCR+0x0528) /* SCIF1 Line Status control */
63#define PA_SCRER1 (PA_BCR+0x052c) /* SCIF1 Serial Error control */
64#define PA_ICCR (PA_BCR+0x0600) /* Serial control */
65#define PA_SAR (PA_BCR+0x0602) /* Serial Slave control */
66#define PA_MDR (PA_BCR+0x0604) /* Serial Mode control */
67#define PA_ADR1 (PA_BCR+0x0606) /* Serial Address1 control */
68#define PA_DAR1 (PA_BCR+0x0646) /* Serial Data1 control */
69#define PA_VERREG (PA_BCR+0x0700) /* FPGA Version Register */
70#define PA_POFF (PA_BCR+0x0800) /* System Power Off control */
71#define PA_PMR (PA_BCR+0x0900) /* */
72
73#define PA_AX88796L 0xa4100400 /* AX88796L Area */
74#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */
75#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
76#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
77#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
78#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */
79
80#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
81
82#define IRQ_PCISLOT1 65 /* PCI Slot #1 IRQ */
83#define IRQ_PCISLOT2 66 /* PCI Slot #2 IRQ */
84#define IRQ_PCISLOT3 67 /* PCI Slot #3 IRQ */
85#define IRQ_PCISLOT4 68 /* PCI Slot #4 IRQ */
86#define IRQ_CFCARD 1 /* CF Card IRQ */
87// #define IRQ_CFINST 0 /* CF Card Insert IRQ */
88#define IRQ_TP 2 /* Touch Panel IRQ */
89#define IRQ_SCI1 3 /* SCI1 IRQ */
90#define IRQ_SCI0 4 /* SCI0 IRQ */
91#define IRQ_2SERIAL 5 /* Serial IRQ */
92#define IRQ_RTC 6 /* RTC A / B IRQ */
93#define IRQ_EXTENTION6 7 /* EXT6n IRQ */
94#define IRQ_EXTENTION5 8 /* EXT5n IRQ */
95#define IRQ_EXTENTION4 9 /* EXT4n IRQ */
96#define IRQ_EXTENTION2 10 /* EXT2n IRQ */
97#define IRQ_EXTENTION1 11 /* EXT1n IRQ */
98#define IRQ_ONETH 13 /* On board Ethernet IRQ */
99#define IRQ_PSW 14 /* Push Switch IRQ */
100
101#else /* R7780RP */
102
103#define PA_BCR 0xa5000000 /* FPGA */
104#define PA_IRLMSK (PA_BCR+0x0000) /* Interrupt Mask control */
105#define PA_IRLMON (PA_BCR+0x0002) /* Interrupt Status control */
106#define PA_SDPOW (PA_BCR+0x0004) /* SD Power control */
107#define PA_RSTCTL (PA_BCR+0x0006) /* Device Reset control */
108#define PA_PCIBD (PA_BCR+0x0008) /* PCI Board detect control */
109#define PA_PCICD (PA_BCR+0x000a) /* PCI Conector detect control */
110#define PA_ZIGIO1 (PA_BCR+0x000c) /* Zigbee IO control 1 */
111#define PA_ZIGIO2 (PA_BCR+0x000e) /* Zigbee IO control 2 */
112#define PA_ZIGIO3 (PA_BCR+0x0010) /* Zigbee IO control 3 */
113#define PA_ZIGIO4 (PA_BCR+0x0012) /* Zigbee IO control 4 */
114#define PA_IVDRMON (PA_BCR+0x0014) /* iVDR Moniter control */
115#define PA_IVDRCTL (PA_BCR+0x0016) /* iVDR control */
116#define PA_OBLED (PA_BCR+0x0018) /* On Board LED control */
117#define PA_OBSW (PA_BCR+0x001a) /* On Board Switch control */
118#define PA_AUDIOSEL (PA_BCR+0x001c) /* Sound Interface Select control */
119#define PA_EXTPLR (PA_BCR+0x001e) /* Extention Pin Polarity control */
120#define PA_TPCTL (PA_BCR+0x0100) /* Touch Panel Access control */
121#define PA_TPDCKCTL (PA_BCR+0x0102) /* Touch Panel Access data control */
122#define PA_TPCTLCLR (PA_BCR+0x0104) /* Touch Panel Access control */
123#define PA_TPXPOS (PA_BCR+0x0106) /* Touch Panel X position control */
124#define PA_TPYPOS (PA_BCR+0x0108) /* Touch Panel Y position control */
125#define PA_DBDET (PA_BCR+0x0200) /* Debug Board detect control */
126#define PA_DBDISPCTL (PA_BCR+0x0202) /* Debug Board Dot timing control */
127#define PA_DBSW (PA_BCR+0x0204) /* Debug Board Switch control */
128#define PA_CFCTL (PA_BCR+0x0300) /* CF Timing control */
129#define PA_CFPOW (PA_BCR+0x0302) /* CF Power control */
130#define PA_CFCDINTCLR (PA_BCR+0x0304) /* CF Insert Interrupt clear */
131#define PA_SCSMR (PA_BCR+0x0400) /* SCIF Serial mode control */
132#define PA_SCBRR (PA_BCR+0x0402) /* SCIF Bit rate control */
133#define PA_SCSCR (PA_BCR+0x0404) /* SCIF Serial control */
134#define PA_SCFDTR (PA_BCR+0x0406) /* SCIF Send FIFO control */
135#define PA_SCFSR (PA_BCR+0x0408) /* SCIF Serial status control */
136#define PA_SCFRDR (PA_BCR+0x040a) /* SCIF Receive FIFO control */
137#define PA_SCFCR (PA_BCR+0x040c) /* SCIF FIFO control */
138#define PA_SCFDR (PA_BCR+0x040e) /* SCIF FIFO data control */
139#define PA_SCLSR (PA_BCR+0x0412) /* SCIF Line Status control */
140#define PA_ICCR (PA_BCR+0x0500) /* Serial control */
141#define PA_SAR (PA_BCR+0x0502) /* Serial Slave control */
142#define PA_MDR (PA_BCR+0x0504) /* Serial Mode control */
143#define PA_ADR1 (PA_BCR+0x0506) /* Serial Address1 control */
144#define PA_DAR1 (PA_BCR+0x0546) /* Serial Data1 control */
145#define PA_VERREG (PA_BCR+0x0600) /* FPGA Version Register */
146
147#define PA_AX88796L 0xa5800400 /* AX88796L Area */
148#define PA_SC1602BSLB 0xa6000000 /* SC1602BSLB Area */
149#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
150#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
151#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
152#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */
153
154#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
155
156#define IRQ_PCISLOT1 0 /* PCI Slot #1 IRQ */
157#define IRQ_PCISLOT2 1 /* PCI Slot #2 IRQ */
158#define IRQ_PCISLOT3 2 /* PCI Slot #3 IRQ */
159#define IRQ_PCISLOT4 3 /* PCI Slot #4 IRQ */
160#define IRQ_CFCARD 4 /* CF Card IRQ */
161#define IRQ_CFINST 5 /* CF Card Insert IRQ */
162#define IRQ_M66596 6 /* M66596 IRQ */
163#define IRQ_SDCARD 7 /* SD Card IRQ */
164#define IRQ_TUCHPANEL 8 /* Touch Panel IRQ */
165#define IRQ_SCI 9 /* SCI IRQ */
166#define IRQ_2SERIAL 10 /* Serial IRQ */
167#define IRQ_EXTENTION 11 /* EXTn IRQ */
168#define IRQ_ONETH 12 /* On board Ethernet IRQ */
169#define IRQ_PSW 13 /* Push Switch IRQ */
170#define IRQ_ZIGBEE 14 /* Ziggbee IO IRQ */
171
172#endif /* CONFIG_SH_R7780MP */
173
174#define __IO_PREFIX r7780rp
175#include <asm/io_generic.h>
176
177#endif /* __ASM_SH_RENESAS_R7780RP */
diff --git a/include/asm-sh/rtc.h b/include/asm-sh/rtc.h
index cea9cdf9b925..91aacc96151b 100644
--- a/include/asm-sh/rtc.h
+++ b/include/asm-sh/rtc.h
@@ -1,29 +1,8 @@
1#ifndef _ASM_RTC_H 1#ifndef _ASM_RTC_H
2#define _ASM_RTC_H 2#define _ASM_RTC_H
3#ifdef __KERNEL__
4 3
5#include <asm/machvec.h>
6#include <asm/cpu/rtc.h>
7
8extern void sh_rtc_gettimeofday(struct timespec *ts);
9extern int sh_rtc_settimeofday(const time_t secs);
10extern void (*board_time_init)(void); 4extern void (*board_time_init)(void);
11extern void (*rtc_get_time)(struct timespec *); 5extern void (*rtc_sh_get_time)(struct timespec *);
12extern int (*rtc_set_time)(const time_t); 6extern int (*rtc_sh_set_time)(const time_t);
13
14/* RCR1 Bits */
15#define RCR1_CF 0x80 /* Carry Flag */
16#define RCR1_CIE 0x10 /* Carry Interrupt Enable */
17#define RCR1_AIE 0x08 /* Alarm Interrupt Enable */
18#define RCR1_AF 0x01 /* Alarm Flag */
19
20/* RCR2 Bits */
21#define RCR2_PEF 0x80 /* PEriodic interrupt Flag */
22#define RCR2_PESMASK 0x70 /* Periodic interrupt Set */
23#define RCR2_RTCEN 0x08 /* ENable RTC */
24#define RCR2_ADJ 0x04 /* ADJustment (30-second) */
25#define RCR2_RESET 0x02 /* Reset bit */
26#define RCR2_START 0x01 /* Start bit */
27 7
28#endif /* __KERNEL__ */
29#endif /* _ASM_RTC_H */ 8#endif /* _ASM_RTC_H */
diff --git a/include/asm-sh/rts7751r2d/rts7751r2d.h b/include/asm-sh/rts7751r2d/rts7751r2d.h
index 4e09ba597e9a..b112ae221fd1 100644
--- a/include/asm-sh/rts7751r2d/rts7751r2d.h
+++ b/include/asm-sh/rts7751r2d/rts7751r2d.h
@@ -41,8 +41,6 @@
41 41
42#define PA_AX88796L 0xaa000400 /* AX88796L Area */ 42#define PA_AX88796L 0xaa000400 /* AX88796L Area */
43#define PA_VOYAGER 0xab000000 /* VOYAGER GX Area */ 43#define PA_VOYAGER 0xab000000 /* VOYAGER GX Area */
44#define PA_AREA5_IO 0xb4000000 /* Area 5 IO Memory */
45#define PA_AREA6_IO 0xb8000000 /* Area 6 IO Memory */
46#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */ 44#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
47#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */ 45#define AX88796L_IO_BASE 0x1000 /* AX88796L IO Base Address */
48 46
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h
index 7b91df140022..d19e7cd3b023 100644
--- a/include/asm-sh/scatterlist.h
+++ b/include/asm-sh/scatterlist.h
@@ -10,4 +10,13 @@ struct scatterlist {
10 10
11#define ISA_DMA_THRESHOLD (0x1fffffff) 11#define ISA_DMA_THRESHOLD (0x1fffffff)
12 12
13/* These macros should be used after a pci_map_sg call has been done
14 * to get bus addresses of each of the SG entries and their lengths.
15 * You should only work with the number of sg entries pci_map_sg
16 * returns, or alternatively stop on the first sg_dma_len(sg) which
17 * is 0.
18 */
19#define sg_dma_address(sg) ((sg)->dma_address)
20#define sg_dma_len(sg) ((sg)->length)
21
13#endif /* !(__ASM_SH_SCATTERLIST_H) */ 22#endif /* !(__ASM_SH_SCATTERLIST_H) */
diff --git a/include/asm-sh/sci.h b/include/asm-sh/sci.h
new file mode 100644
index 000000000000..52e73660c129
--- /dev/null
+++ b/include/asm-sh/sci.h
@@ -0,0 +1,34 @@
1#ifndef __ASM_SH_SCI_H
2#define __ASM_SH_SCI_H
3
4#include <linux/serial_core.h>
5
6/*
7 * Generic header for SuperH SCI(F)
8 *
9 * Do not place SH-specific parts in here, sh64 and h8300 depend on this too.
10 */
11
12/* Offsets into the sci_port->irqs array */
13enum {
14 SCIx_ERI_IRQ,
15 SCIx_RXI_IRQ,
16 SCIx_TXI_IRQ,
17 SCIx_BRI_IRQ,
18 SCIx_NR_IRQS,
19};
20
21/*
22 * Platform device specific platform_data struct
23 */
24struct plat_sci_port {
25 void __iomem *membase; /* io cookie */
26 unsigned long mapbase; /* resource base */
27 unsigned int irqs[SCIx_NR_IRQS]; /* ERI, RXI, TXI, BRI */
28 unsigned int type; /* SCI / SCIF / IRDA */
29 upf_t flags; /* UPF_* flags */
30};
31
32int early_sci_setup(struct uart_port *port);
33
34#endif /* __ASM_SH_SCI_H */
diff --git a/include/asm-sh/se/se.h b/include/asm-sh/se.h
index 791c5da0388a..a1832154a3aa 100644
--- a/include/asm-sh/se/se.h
+++ b/include/asm-sh/se.h
@@ -74,4 +74,7 @@
74#define IRQ_STNIC 10 74#define IRQ_STNIC 10
75#endif 75#endif
76 76
77#define __IO_PREFIX se
78#include <asm/io_generic.h>
79
77#endif /* __ASM_SH_HITACHI_SE_H */ 80#endif /* __ASM_SH_HITACHI_SE_H */
diff --git a/include/asm-sh/se/io.h b/include/asm-sh/se/io.h
deleted file mode 100644
index 9eeb86cd6cef..000000000000
--- a/include/asm-sh/se/io.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * include/asm-sh/io_se.h
3 *
4 * Copyright 2000 Stuart Menefy (stuart.menefy@st.com)
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * IO functions for an Hitachi SolutionEngine
10 */
11
12#ifndef _ASM_SH_IO_SE_H
13#define _ASM_SH_IO_SE_H
14
15extern unsigned char se_inb(unsigned long port);
16extern unsigned short se_inw(unsigned long port);
17extern unsigned int se_inl(unsigned long port);
18
19extern void se_outb(unsigned char value, unsigned long port);
20extern void se_outw(unsigned short value, unsigned long port);
21extern void se_outl(unsigned int value, unsigned long port);
22
23extern unsigned char se_inb_p(unsigned long port);
24extern void se_outb_p(unsigned char value, unsigned long port);
25
26extern void se_insb(unsigned long port, void *addr, unsigned long count);
27extern void se_insw(unsigned long port, void *addr, unsigned long count);
28extern void se_insl(unsigned long port, void *addr, unsigned long count);
29extern void se_outsb(unsigned long port, const void *addr, unsigned long count);
30extern void se_outsw(unsigned long port, const void *addr, unsigned long count);
31extern void se_outsl(unsigned long port, const void *addr, unsigned long count);
32
33extern unsigned long se_isa_port2addr(unsigned long offset);
34
35#endif /* _ASM_SH_IO_SE_H */
diff --git a/include/asm-sh/se7300/se7300.h b/include/asm-sh/se7300.h
index 3ec1ded86c97..4e24edccb30d 100644
--- a/include/asm-sh/se7300/se7300.h
+++ b/include/asm-sh/se7300.h
@@ -58,4 +58,7 @@
58#define PA_LCD1 0xb8000000 58#define PA_LCD1 0xb8000000
59#define PA_LCD2 0xb8800000 59#define PA_LCD2 0xb8800000
60 60
61#define __IO_PREFIX sh7300se
62#include <asm/io_generic.h>
63
61#endif /* __ASM_SH_HITACHI_SE7300_H */ 64#endif /* __ASM_SH_HITACHI_SE7300_H */
diff --git a/include/asm-sh/se7300/io.h b/include/asm-sh/se7300/io.h
deleted file mode 100644
index c6af85529714..000000000000
--- a/include/asm-sh/se7300/io.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * include/asm-sh/se7300/io.h
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 * IO functions for SH-Mobile(SH7300) SolutionEngine
6 */
7
8#ifndef _ASM_SH_IO_7300SE_H
9#define _ASM_SH_IO_7300SE_H
10
11extern unsigned char sh7300se_inb(unsigned long port);
12extern unsigned short sh7300se_inw(unsigned long port);
13extern unsigned int sh7300se_inl(unsigned long port);
14
15extern void sh7300se_outb(unsigned char value, unsigned long port);
16extern void sh7300se_outw(unsigned short value, unsigned long port);
17extern void sh7300se_outl(unsigned int value, unsigned long port);
18
19extern unsigned char sh7300se_inb_p(unsigned long port);
20extern void sh7300se_outb_p(unsigned char value, unsigned long port);
21
22extern void sh7300se_insb(unsigned long port, void *addr, unsigned long count);
23extern void sh7300se_insw(unsigned long port, void *addr, unsigned long count);
24extern void sh7300se_insl(unsigned long port, void *addr, unsigned long count);
25extern void sh7300se_outsb(unsigned long port, const void *addr, unsigned long count);
26extern void sh7300se_outsw(unsigned long port, const void *addr, unsigned long count);
27extern void sh7300se_outsl(unsigned long port, const void *addr, unsigned long count);
28
29#endif /* _ASM_SH_IO_7300SE_H */
diff --git a/include/asm-sh/se73180/se73180.h b/include/asm-sh/se73180.h
index f5b93e39e768..3a4acb3e38a1 100644
--- a/include/asm-sh/se73180/se73180.h
+++ b/include/asm-sh/se73180.h
@@ -59,4 +59,7 @@
59#define PA_LCD1 0xb8000000 59#define PA_LCD1 0xb8000000
60#define PA_LCD2 0xb8800000 60#define PA_LCD2 0xb8800000
61 61
62#define __IO_PREFIX sh73180se
63#include <asm/io_generic.h>
64
62#endif /* __ASM_SH_HITACHI_SE73180_H */ 65#endif /* __ASM_SH_HITACHI_SE73180_H */
diff --git a/include/asm-sh/se73180/io.h b/include/asm-sh/se73180/io.h
deleted file mode 100644
index c9cb1b9412c6..000000000000
--- a/include/asm-sh/se73180/io.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * include/asm-sh/se73180/io.h
3 *
4 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
5 * Based on include/asm-sh/se7300/io.h
6 *
7 * IO functions for SH-Mobile3(SH73180) SolutionEngine
8 *
9 */
10
11#ifndef _ASM_SH_IO_73180SE_H
12#define _ASM_SH_IO_73180SE_H
13
14extern unsigned char sh73180se_inb(unsigned long port);
15extern unsigned short sh73180se_inw(unsigned long port);
16extern unsigned int sh73180se_inl(unsigned long port);
17
18extern void sh73180se_outb(unsigned char value, unsigned long port);
19extern void sh73180se_outw(unsigned short value, unsigned long port);
20extern void sh73180se_outl(unsigned int value, unsigned long port);
21
22extern unsigned char sh73180se_inb_p(unsigned long port);
23extern void sh73180se_outb_p(unsigned char value, unsigned long port);
24
25extern void sh73180se_insb(unsigned long port, void *addr, unsigned long count);
26extern void sh73180se_insw(unsigned long port, void *addr, unsigned long count);
27extern void sh73180se_insl(unsigned long port, void *addr, unsigned long count);
28extern void sh73180se_outsb(unsigned long port, const void *addr, unsigned long count);
29extern void sh73180se_outsw(unsigned long port, const void *addr, unsigned long count);
30extern void sh73180se_outsl(unsigned long port, const void *addr, unsigned long count);
31
32#endif /* _ASM_SH_IO_73180SE_H */
diff --git a/include/asm-sh/se7343.h b/include/asm-sh/se7343.h
new file mode 100644
index 000000000000..e7914a54aa96
--- /dev/null
+++ b/include/asm-sh/se7343.h
@@ -0,0 +1,82 @@
1#ifndef __ASM_SH_HITACHI_SE7343_H
2#define __ASM_SH_HITACHI_SE7343_H
3
4/*
5 * include/asm-sh/se/se7343.h
6 *
7 * Copyright (C) 2003 Takashi Kusuda <kusuda-takashi@hitachi-ul.co.jp>
8 *
9 * SH-Mobile SolutionEngine 7343 support
10 */
11
12/* Box specific addresses. */
13
14/* Area 0 */
15#define PA_ROM 0x00000000 /* EPROM */
16#define PA_ROM_SIZE 0x00400000 /* EPROM size 4M byte(Actually 2MB) */
17#define PA_FROM 0x00400000 /* Flash ROM */
18#define PA_FROM_SIZE 0x00400000 /* Flash size 4M byte */
19#define PA_SRAM 0x00800000 /* SRAM */
20#define PA_FROM_SIZE 0x00400000 /* SRAM size 4M byte */
21/* Area 1 */
22#define PA_EXT1 0x04000000
23#define PA_EXT1_SIZE 0x04000000
24/* Area 2 */
25#define PA_EXT2 0x08000000
26#define PA_EXT2_SIZE 0x04000000
27/* Area 3 */
28#define PA_SDRAM 0x0c000000
29#define PA_SDRAM_SIZE 0x04000000
30/* Area 4 */
31#define PA_PCIC 0x10000000 /* MR-SHPC-01 PCMCIA */
32#define PA_MRSHPC 0xb03fffe0 /* MR-SHPC-01 PCMCIA controller */
33#define PA_MRSHPC_MW1 0xb0400000 /* MR-SHPC-01 memory window base */
34#define PA_MRSHPC_MW2 0xb0500000 /* MR-SHPC-01 attribute window base */
35#define PA_MRSHPC_IO 0xb0600000 /* MR-SHPC-01 I/O window base */
36#define MRSHPC_OPTION (PA_MRSHPC + 6)
37#define MRSHPC_CSR (PA_MRSHPC + 8)
38#define MRSHPC_ISR (PA_MRSHPC + 10)
39#define MRSHPC_ICR (PA_MRSHPC + 12)
40#define MRSHPC_CPWCR (PA_MRSHPC + 14)
41#define MRSHPC_MW0CR1 (PA_MRSHPC + 16)
42#define MRSHPC_MW1CR1 (PA_MRSHPC + 18)
43#define MRSHPC_IOWCR1 (PA_MRSHPC + 20)
44#define MRSHPC_MW0CR2 (PA_MRSHPC + 22)
45#define MRSHPC_MW1CR2 (PA_MRSHPC + 24)
46#define MRSHPC_IOWCR2 (PA_MRSHPC + 26)
47#define MRSHPC_CDCR (PA_MRSHPC + 28)
48#define MRSHPC_PCIC_INFO (PA_MRSHPC + 30)
49#define PA_LED 0xb0C00000 /* LED */
50#define LED_SHIFT 0
51#define PA_DIPSW 0xb0900000 /* Dip switch 31 */
52#define PA_CPLD_MODESET 0xb1400004 /* CPLD Mode set register */
53#define PA_CPLD_ST 0xb1400008 /* CPLD Interrupt status register */
54#define PA_CPLD_IMSK 0xb140000a /* CPLD Interrupt mask register */
55/* Area 5 */
56#define PA_EXT5 0x14000000
57#define PA_EXT5_SIZE 0x04000000
58/* Area 6 */
59#define PA_LCD1 0xb8000000
60#define PA_LCD2 0xb8800000
61
62#define __IO_PREFIX sh7343se
63#include <asm/io_generic.h>
64
65/* External Multiplexed interrupts */
66#define PC_IRQ0 OFFCHIP_IRQ_BASE
67#define PC_IRQ1 (PC_IRQ0 + 1)
68#define PC_IRQ2 (PC_IRQ1 + 1)
69#define PC_IRQ3 (PC_IRQ2 + 1)
70
71#define EXT_IRQ0 (PC_IRQ3 + 1)
72#define EXT_IRQ1 (EXT_IRQ0 + 1)
73#define EXT_IRQ2 (EXT_IRQ1 + 1)
74#define EXT_IRQ3 (EXT_IRQ2 + 1)
75
76#define USB_IRQ0 (EXT_IRQ3 + 1)
77#define USB_IRQ1 (USB_IRQ0 + 1)
78
79#define UART_IRQ0 (USB_IRQ1 + 1)
80#define UART_IRQ1 (UART_IRQ0 + 1)
81
82#endif /* __ASM_SH_HITACHI_SE7343_H */
diff --git a/include/asm-sh/se7751/se7751.h b/include/asm-sh/se7751.h
index 738e22bebdfb..88cd379d9084 100644
--- a/include/asm-sh/se7751/se7751.h
+++ b/include/asm-sh/se7751.h
@@ -65,4 +65,7 @@
65 65
66#define IRQ_79C973 13 66#define IRQ_79C973 13
67 67
68#define __IO_PREFIX sh7751se
69#include <asm/io_generic.h>
70
68#endif /* __ASM_SH_HITACHI_7751SE_H */ 71#endif /* __ASM_SH_HITACHI_7751SE_H */
diff --git a/include/asm-sh/se7751/io.h b/include/asm-sh/se7751/io.h
deleted file mode 100644
index 78d8f5744bc5..000000000000
--- a/include/asm-sh/se7751/io.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * include/asm-sh/io_7751se.h
3 *
4 * Modified version of io_se.h for the 7751se-specific functions.
5 *
6 * May be copied or modified under the terms of the GNU General Public
7 * License. See linux/COPYING for more information.
8 *
9 * IO functions for an Hitachi SolutionEngine
10 */
11
12#ifndef _ASM_SH_IO_7751SE_H
13#define _ASM_SH_IO_7751SE_H
14
15extern unsigned char sh7751se_inb(unsigned long port);
16extern unsigned short sh7751se_inw(unsigned long port);
17extern unsigned int sh7751se_inl(unsigned long port);
18
19extern void sh7751se_outb(unsigned char value, unsigned long port);
20extern void sh7751se_outw(unsigned short value, unsigned long port);
21extern void sh7751se_outl(unsigned int value, unsigned long port);
22
23extern unsigned char sh7751se_inb_p(unsigned long port);
24extern void sh7751se_outb_p(unsigned char value, unsigned long port);
25
26extern void sh7751se_insb(unsigned long port, void *addr, unsigned long count);
27extern void sh7751se_insw(unsigned long port, void *addr, unsigned long count);
28extern void sh7751se_insl(unsigned long port, void *addr, unsigned long count);
29extern void sh7751se_outsb(unsigned long port, const void *addr, unsigned long count);
30extern void sh7751se_outsw(unsigned long port, const void *addr, unsigned long count);
31extern void sh7751se_outsl(unsigned long port, const void *addr, unsigned long count);
32
33extern unsigned char sh7751se_readb(unsigned long addr);
34extern unsigned short sh7751se_readw(unsigned long addr);
35extern unsigned int sh7751se_readl(unsigned long addr);
36extern void sh7751se_writeb(unsigned char b, unsigned long addr);
37extern void sh7751se_writew(unsigned short b, unsigned long addr);
38extern void sh7751se_writel(unsigned int b, unsigned long addr);
39
40extern unsigned long sh7751se_isa_port2addr(unsigned long offset);
41
42#endif /* _ASM_SH_IO_7751SE_H */
diff --git a/include/asm-sh/setup.h b/include/asm-sh/setup.h
index d19de7c8df4e..34ca8a7f06ba 100644
--- a/include/asm-sh/setup.h
+++ b/include/asm-sh/setup.h
@@ -4,5 +4,7 @@
4 4
5#define COMMAND_LINE_SIZE 256 5#define COMMAND_LINE_SIZE 256
6 6
7int setup_early_printk(char *);
8
7#endif /* _SH_SETUP_H */ 9#endif /* _SH_SETUP_H */
8#endif /* __KERNEL__ */ 10#endif /* __KERNEL__ */
diff --git a/include/asm-sh/sfp-machine.h b/include/asm-sh/sfp-machine.h
new file mode 100644
index 000000000000..8a6399a8cfe0
--- /dev/null
+++ b/include/asm-sh/sfp-machine.h
@@ -0,0 +1,86 @@
1/* Machine-dependent software floating-point definitions.
2 SuperH kernel version.
3 Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Richard Henderson (rth@cygnus.com),
6 Jakub Jelinek (jj@ultra.linux.cz),
7 David S. Miller (davem@redhat.com) and
8 Peter Maydell (pmaydell@chiark.greenend.org.uk).
9
10 The GNU C Library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public License as
12 published by the Free Software Foundation; either version 2 of the
13 License, or (at your option) any later version.
14
15 The GNU C Library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
19
20 You should have received a copy of the GNU Library General Public
21 License along with the GNU C Library; see the file COPYING.LIB. If
22 not, write to the Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
24
25#ifndef _SFP_MACHINE_H
26#define _SFP_MACHINE_H
27
28#include <linux/config.h>
29
30#define _FP_W_TYPE_SIZE 32
31#define _FP_W_TYPE unsigned long
32#define _FP_WS_TYPE signed long
33#define _FP_I_TYPE long
34
35#define _FP_MUL_MEAT_S(R,X,Y) \
36 _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
37#define _FP_MUL_MEAT_D(R,X,Y) \
38 _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
39#define _FP_MUL_MEAT_Q(R,X,Y) \
40 _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
41
42#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
43#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
44#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
45
46#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
47#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
48#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
49#define _FP_NANSIGN_S 0
50#define _FP_NANSIGN_D 0
51#define _FP_NANSIGN_Q 0
52
53#define _FP_KEEPNANFRACP 1
54
55/*
56 * If one NaN is signaling and the other is not,
57 * we choose that one, otherwise we choose X.
58 */
59#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
60 do { \
61 if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
62 && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
63 { \
64 R##_s = Y##_s; \
65 _FP_FRAC_COPY_##wc(R,Y); \
66 } \
67 else \
68 { \
69 R##_s = X##_s; \
70 _FP_FRAC_COPY_##wc(R,X); \
71 } \
72 R##_c = FP_CLS_NAN; \
73 } while (0)
74
75//#define FP_ROUNDMODE FPSCR_RM
76#define FP_DENORM_ZERO 1/*FPSCR_DN*/
77
78/* Exception flags. */
79#define FP_EX_INVALID (1<<4)
80#define FP_EX_DIVZERO (1<<3)
81#define FP_EX_OVERFLOW (1<<2)
82#define FP_EX_UNDERFLOW (1<<1)
83#define FP_EX_INEXACT (1<<0)
84
85#endif
86
diff --git a/include/asm-sh/sh03/io.h b/include/asm-sh/sh03/io.h
index 25792e9831ea..df3b187ef883 100644
--- a/include/asm-sh/sh03/io.h
+++ b/include/asm-sh/sh03/io.h
@@ -33,14 +33,6 @@
33#define IRL3_IPR_POS 0 33#define IRL3_IPR_POS 0
34#define IRL3_PRIORITY 4 34#define IRL3_PRIORITY 4
35 35
36 36void heartbeat_sh03(void);
37extern unsigned long sh03_isa_port2addr(unsigned long offset);
38
39extern void setup_sh03(void);
40extern void init_sh03_IRQ(void);
41extern void heartbeat_sh03(void);
42
43extern void sh03_rtc_gettimeofday(struct timeval *tv);
44extern int sh03_rtc_settimeofday(const struct timeval *tv);
45 37
46#endif /* _ASM_SH_IO_SH03_H */ 38#endif /* _ASM_SH_IO_SH03_H */
diff --git a/include/asm-sh/sh2000/sh2000.h b/include/asm-sh/sh2000/sh2000.h
deleted file mode 100644
index 8d547324d59a..000000000000
--- a/include/asm-sh/sh2000/sh2000.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH_SH2000_SH2000_H
2#define __ASM_SH_SH2000_SH2000_H
3
4/* arch/sh/boards/sh2000/setup.c */
5extern int setup_sh2000(void);
6
7#endif /* __ASM_SH_SH2000_SH2000_H */
8
diff --git a/include/asm-sh/shmin/shmin.h b/include/asm-sh/shmin/shmin.h
new file mode 100644
index 000000000000..36ba138a81fb
--- /dev/null
+++ b/include/asm-sh/shmin/shmin.h
@@ -0,0 +1,9 @@
1#ifndef __ASM_SH_SHMIN_H
2#define __ASM_SH_SHMIN_H
3
4#define SHMIN_IO_BASE 0xb0000000UL
5
6#define SHMIN_NE_IRQ IRQ2_IRQ
7#define SHMIN_NE_BASE 0x300
8
9#endif
diff --git a/include/asm-sh/shmparam.h b/include/asm-sh/shmparam.h
index 0a95604b9b66..ba1758d90106 100644
--- a/include/asm-sh/shmparam.h
+++ b/include/asm-sh/shmparam.h
@@ -1,8 +1,22 @@
1/*
2 * include/asm-sh/shmparam.h
3 *
4 * Copyright (C) 1999 Niibe Yutaka
5 * Copyright (C) 2006 Paul Mundt
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 */
1#ifndef __ASM_SH_SHMPARAM_H 11#ifndef __ASM_SH_SHMPARAM_H
2#define __ASM_SH_SHMPARAM_H 12#define __ASM_SH_SHMPARAM_H
3#ifdef __KERNEL__
4 13
5#include <asm/cpu/shmparam.h> 14/*
15 * SH-4 and SH-3 7705 have an aliasing dcache. Bump this up to a sensible value
16 * for everyone, and work out the specifics from the probed cache descriptor.
17 */
18#define SHMLBA 0x4000 /* attach addr a multiple of this */
19
20#define __ARCH_FORCE_SHMLBA
6 21
7#endif /* __KERNEL__ */
8#endif /* __ASM_SH_SHMPARAM_H */ 22#endif /* __ASM_SH_SHMPARAM_H */
diff --git a/include/asm-sh/se/smc37c93x.h b/include/asm-sh/smc37c93x.h
index 585da2a8fc45..585da2a8fc45 100644
--- a/include/asm-sh/se/smc37c93x.h
+++ b/include/asm-sh/smc37c93x.h
diff --git a/include/asm-sh/smp.h b/include/asm-sh/smp.h
index f57c4fe9692a..71ecddf70db3 100644
--- a/include/asm-sh/smp.h
+++ b/include/asm-sh/smp.h
@@ -19,11 +19,6 @@
19#include <asm/atomic.h> 19#include <asm/atomic.h>
20#include <asm/current.h> 20#include <asm/current.h>
21 21
22extern cpumask_t cpu_online_map;
23extern cpumask_t cpu_possible_map;
24
25#define cpu_online(cpu) cpu_isset(cpu, cpu_online_map)
26
27#define raw_smp_processor_id() (current_thread_info()->cpu) 22#define raw_smp_processor_id() (current_thread_info()->cpu)
28 23
29/* I've no idea what the real meaning of this is */ 24/* I've no idea what the real meaning of this is */
diff --git a/include/asm-sh/snapgear/io.h b/include/asm-sh/snapgear.h
index bfa97ac06280..6b5e4ddc073a 100644
--- a/include/asm-sh/snapgear/io.h
+++ b/include/asm-sh/snapgear.h
@@ -40,21 +40,8 @@
40#define IRL3_PRIORITY 4 40#define IRL3_PRIORITY 4
41#endif 41#endif
42 42
43extern unsigned char snapgear_inb(unsigned long port); 43#define __IO_PREFIX snapgear
44extern unsigned short snapgear_inw(unsigned long port); 44#include <asm/io_generic.h>
45extern unsigned int snapgear_inl(unsigned long port);
46
47extern void snapgear_outb(unsigned char value, unsigned long port);
48extern void snapgear_outw(unsigned short value, unsigned long port);
49extern void snapgear_outl(unsigned int value, unsigned long port);
50
51extern unsigned char snapgear_inb_p(unsigned long port);
52extern void snapgear_outb_p(unsigned char value, unsigned long port);
53
54extern void snapgear_insl(unsigned long port, void *addr, unsigned long count);
55extern void snapgear_outsl(unsigned long port, const void *addr, unsigned long count);
56
57extern unsigned long snapgear_isa_port2addr(unsigned long offset);
58 45
59#ifdef CONFIG_SH_SECUREEDGE5410 46#ifdef CONFIG_SH_SECUREEDGE5410
60/* 47/*
@@ -79,14 +66,14 @@ extern unsigned long snapgear_isa_port2addr(unsigned long offset);
79 * D12 - RTS RESET 66 * D12 - RTS RESET
80 */ 67 */
81 68
82 #define SECUREEDGE_IOPORT_ADDR ((volatile short *) 0xb0000000) 69#define SECUREEDGE_IOPORT_ADDR ((volatile short *) 0xb0000000)
83 extern unsigned short secureedge5410_ioport; 70extern unsigned short secureedge5410_ioport;
84 71
85 #define SECUREEDGE_WRITE_IOPORT(val, mask) (*SECUREEDGE_IOPORT_ADDR = \ 72#define SECUREEDGE_WRITE_IOPORT(val, mask) (*SECUREEDGE_IOPORT_ADDR = \
86 (secureedge5410_ioport = \ 73 (secureedge5410_ioport = \
87 ((secureedge5410_ioport & ~(mask)) | ((val) & (mask))))) 74 ((secureedge5410_ioport & ~(mask)) | ((val) & (mask)))))
88 #define SECUREEDGE_READ_IOPORT() \ 75#define SECUREEDGE_READ_IOPORT() \
89 ((*SECUREEDGE_IOPORT_ADDR&0x0817) | (secureedge5410_ioport&~0x0817)) 76 ((*SECUREEDGE_IOPORT_ADDR&0x0817) | (secureedge5410_ioport&~0x0817))
90#endif 77#endif
91 78
92#endif /* _ASM_SH_IO_SNAPGEAR_H */ 79#endif /* _ASM_SH_IO_SNAPGEAR_H */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index ad35ad4958f4..6c1f8fde5ac4 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 2002 Paul Mundt 6 * Copyright (C) 2002 Paul Mundt
7 */ 7 */
8 8
9#include <asm/types.h>
9 10
10/* 11/*
11 * switch_to() should switch tasks to task nr n, first 12 * switch_to() should switch tasks to task nr n, first
@@ -66,13 +67,20 @@ static inline void sched_cacheflush(void)
66{ 67{
67} 68}
68 69
69#define nop() __asm__ __volatile__ ("nop") 70#ifdef CONFIG_CPU_SH4A
70 71#define __icbi() \
71 72{ \
72#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) 73 unsigned long __addr; \
74 __addr = 0xa8000000; \
75 __asm__ __volatile__( \
76 "icbi %0\n\t" \
77 : /* no output */ \
78 : "m" (__m(__addr))); \
79}
80#endif
73 81
74static __inline__ unsigned long tas(volatile int *m) 82static inline unsigned long tas(volatile int *m)
75{ /* #define tas(ptr) (xchg((ptr),1)) */ 83{
76 unsigned long retval; 84 unsigned long retval;
77 85
78 __asm__ __volatile__ ("tas.b @%1\n\t" 86 __asm__ __volatile__ ("tas.b @%1\n\t"
@@ -81,12 +89,33 @@ static __inline__ unsigned long tas(volatile int *m)
81 return retval; 89 return retval;
82} 90}
83 91
84extern void __xchg_called_with_bad_pointer(void); 92/*
85 93 * A brief note on ctrl_barrier(), the control register write barrier.
86#define mb() __asm__ __volatile__ ("": : :"memory") 94 *
87#define rmb() mb() 95 * Legacy SH cores typically require a sequence of 8 nops after
88#define wmb() __asm__ __volatile__ ("": : :"memory") 96 * modification of a control register in order for the changes to take
97 * effect. On newer cores (like the sh4a and sh5) this is accomplished
98 * with icbi.
99 *
100 * Also note that on sh4a in the icbi case we can forego a synco for the
101 * write barrier, as it's not necessary for control registers.
102 *
103 * Historically we have only done this type of barrier for the MMUCR, but
104 * it's also necessary for the CCR, so we make it generic here instead.
105 */
106#ifdef CONFIG_CPU_SH4A
107#define mb() __asm__ __volatile__ ("synco": : :"memory")
108#define rmb() mb()
109#define wmb() __asm__ __volatile__ ("synco": : :"memory")
110#define ctrl_barrier() __icbi()
111#define read_barrier_depends() do { } while(0)
112#else
113#define mb() __asm__ __volatile__ ("": : :"memory")
114#define rmb() mb()
115#define wmb() __asm__ __volatile__ ("": : :"memory")
116#define ctrl_barrier() __asm__ __volatile__ ("nop;nop;nop;nop;nop;nop;nop;nop")
89#define read_barrier_depends() do { } while(0) 117#define read_barrier_depends() do { } while(0)
118#endif
90 119
91#ifdef CONFIG_SMP 120#ifdef CONFIG_SMP
92#define smp_mb() mb() 121#define smp_mb() mb()
@@ -103,7 +132,8 @@ extern void __xchg_called_with_bad_pointer(void);
103#define set_mb(var, value) do { xchg(&var, value); } while (0) 132#define set_mb(var, value) do { xchg(&var, value); } while (0)
104 133
105/* Interrupt Control */ 134/* Interrupt Control */
106static __inline__ void local_irq_enable(void) 135#ifdef CONFIG_CPU_HAS_SR_RB
136static inline void local_irq_enable(void)
107{ 137{
108 unsigned long __dummy0, __dummy1; 138 unsigned long __dummy0, __dummy1;
109 139
@@ -116,8 +146,22 @@ static __inline__ void local_irq_enable(void)
116 : "1" (~0x000000f0) 146 : "1" (~0x000000f0)
117 : "memory"); 147 : "memory");
118} 148}
149#else
150static inline void local_irq_enable(void)
151{
152 unsigned long __dummy0, __dummy1;
153
154 __asm__ __volatile__ (
155 "stc sr, %0\n\t"
156 "and %1, %0\n\t"
157 "ldc %0, sr\n\t"
158 : "=&r" (__dummy0), "=r" (__dummy1)
159 : "1" (~0x000000f0)
160 : "memory");
161}
162#endif
119 163
120static __inline__ void local_irq_disable(void) 164static inline void local_irq_disable(void)
121{ 165{
122 unsigned long __dummy; 166 unsigned long __dummy;
123 __asm__ __volatile__("stc sr, %0\n\t" 167 __asm__ __volatile__("stc sr, %0\n\t"
@@ -128,6 +172,31 @@ static __inline__ void local_irq_disable(void)
128 : "memory"); 172 : "memory");
129} 173}
130 174
175static inline void set_bl_bit(void)
176{
177 unsigned long __dummy0, __dummy1;
178
179 __asm__ __volatile__ ("stc sr, %0\n\t"
180 "or %2, %0\n\t"
181 "and %3, %0\n\t"
182 "ldc %0, sr"
183 : "=&r" (__dummy0), "=r" (__dummy1)
184 : "r" (0x10000000), "r" (0xffffff0f)
185 : "memory");
186}
187
188static inline void clear_bl_bit(void)
189{
190 unsigned long __dummy0, __dummy1;
191
192 __asm__ __volatile__ ("stc sr, %0\n\t"
193 "and %2, %0\n\t"
194 "ldc %0, sr"
195 : "=&r" (__dummy0), "=r" (__dummy1)
196 : "1" (~0x10000000)
197 : "memory");
198}
199
131#define local_save_flags(x) \ 200#define local_save_flags(x) \
132 __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" ) 201 __asm__("stc sr, %0; and #0xf0, %0" : "=&z" (x) :/**/: "memory" )
133 202
@@ -138,7 +207,7 @@ static __inline__ void local_irq_disable(void)
138 (flags != 0); \ 207 (flags != 0); \
139}) 208})
140 209
141static __inline__ unsigned long local_irq_save(void) 210static inline unsigned long local_irq_save(void)
142{ 211{
143 unsigned long flags, __dummy; 212 unsigned long flags, __dummy;
144 213
@@ -154,35 +223,9 @@ static __inline__ unsigned long local_irq_save(void)
154 return flags; 223 return flags;
155} 224}
156 225
157#ifdef DEBUG_CLI_STI 226#define local_irq_restore(x) do { \
158static __inline__ void local_irq_restore(unsigned long x)
159{
160 if ((x & 0x000000f0) != 0x000000f0)
161 local_irq_enable();
162 else {
163 unsigned long flags;
164 local_save_flags(flags);
165
166 if (flags == 0) {
167 extern void dump_stack(void);
168 printk(KERN_ERR "BUG!\n");
169 dump_stack();
170 local_irq_disable();
171 }
172 }
173}
174#else
175#define local_irq_restore(x) do { \
176 if ((x & 0x000000f0) != 0x000000f0) \
177 local_irq_enable(); \
178} while (0)
179#endif
180
181#define really_restore_flags(x) do { \
182 if ((x & 0x000000f0) != 0x000000f0) \ 227 if ((x & 0x000000f0) != 0x000000f0) \
183 local_irq_enable(); \ 228 local_irq_enable(); \
184 else \
185 local_irq_disable(); \
186} while (0) 229} while (0)
187 230
188/* 231/*
@@ -210,8 +253,8 @@ do { \
210#define back_to_P1() \ 253#define back_to_P1() \
211do { \ 254do { \
212 unsigned long __dummy; \ 255 unsigned long __dummy; \
256 ctrl_barrier(); \
213 __asm__ __volatile__( \ 257 __asm__ __volatile__( \
214 "nop;nop;nop;nop;nop;nop;nop\n\t" \
215 "mov.l 1f, %0\n\t" \ 258 "mov.l 1f, %0\n\t" \
216 "jmp @%0\n\t" \ 259 "jmp @%0\n\t" \
217 " nop\n\t" \ 260 " nop\n\t" \
@@ -224,7 +267,7 @@ do { \
224/* For spinlocks etc */ 267/* For spinlocks etc */
225#define local_irq_save(x) x = local_irq_save() 268#define local_irq_save(x) x = local_irq_save()
226 269
227static __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val) 270static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
228{ 271{
229 unsigned long flags, retval; 272 unsigned long flags, retval;
230 273
@@ -235,7 +278,7 @@ static __inline__ unsigned long xchg_u32(volatile int * m, unsigned long val)
235 return retval; 278 return retval;
236} 279}
237 280
238static __inline__ unsigned long xchg_u8(volatile unsigned char * m, unsigned long val) 281static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
239{ 282{
240 unsigned long flags, retval; 283 unsigned long flags, retval;
241 284
@@ -246,20 +289,70 @@ static __inline__ unsigned long xchg_u8(volatile unsigned char * m, unsigned lon
246 return retval; 289 return retval;
247} 290}
248 291
249static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, int size) 292extern void __xchg_called_with_bad_pointer(void);
293
294#define __xchg(ptr, x, size) \
295({ \
296 unsigned long __xchg__res; \
297 volatile void *__xchg_ptr = (ptr); \
298 switch (size) { \
299 case 4: \
300 __xchg__res = xchg_u32(__xchg_ptr, x); \
301 break; \
302 case 1: \
303 __xchg__res = xchg_u8(__xchg_ptr, x); \
304 break; \
305 default: \
306 __xchg_called_with_bad_pointer(); \
307 __xchg__res = x; \
308 break; \
309 } \
310 \
311 __xchg__res; \
312})
313
314#define xchg(ptr,x) \
315 ((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr))))
316
317static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
318 unsigned long new)
319{
320 __u32 retval;
321 unsigned long flags;
322
323 local_irq_save(flags);
324 retval = *m;
325 if (retval == old)
326 *m = new;
327 local_irq_restore(flags); /* implies memory barrier */
328 return retval;
329}
330
331/* This function doesn't exist, so you'll get a linker error
332 * if something tries to do an invalid cmpxchg(). */
333extern void __cmpxchg_called_with_bad_pointer(void);
334
335#define __HAVE_ARCH_CMPXCHG 1
336
337static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old,
338 unsigned long new, int size)
250{ 339{
251 switch (size) { 340 switch (size) {
252 case 4: 341 case 4:
253 return xchg_u32(ptr, x); 342 return __cmpxchg_u32(ptr, old, new);
254 break;
255 case 1:
256 return xchg_u8(ptr, x);
257 break;
258 } 343 }
259 __xchg_called_with_bad_pointer(); 344 __cmpxchg_called_with_bad_pointer();
260 return x; 345 return old;
261} 346}
262 347
348#define cmpxchg(ptr,o,n) \
349 ({ \
350 __typeof__(*(ptr)) _o_ = (o); \
351 __typeof__(*(ptr)) _n_ = (n); \
352 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
353 (unsigned long)_n_, sizeof(*(ptr))); \
354 })
355
263/* XXX 356/* XXX
264 * disable hlt during certain critical i/o operations 357 * disable hlt during certain critical i/o operations
265 */ 358 */
diff --git a/include/asm-sh/systemh/io.h b/include/asm-sh/systemh/io.h
deleted file mode 100644
index 327849b49db8..000000000000
--- a/include/asm-sh/systemh/io.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * include/asm-sh/systemh/io.h
3 *
4 * Stupid I/O definitions for SystemH, cloned from SE7751.
5 *
6 * Copyright (C) 2003 Paul Mundt
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
12#ifndef __ASM_SH_SYSTEMH_IO_H
13#define __ASM_SH_SYSTEMH_IO_H
14
15extern unsigned char sh7751systemh_inb(unsigned long port);
16extern unsigned short sh7751systemh_inw(unsigned long port);
17extern unsigned int sh7751systemh_inl(unsigned long port);
18
19extern void sh7751systemh_outb(unsigned char value, unsigned long port);
20extern void sh7751systemh_outw(unsigned short value, unsigned long port);
21extern void sh7751systemh_outl(unsigned int value, unsigned long port);
22
23extern unsigned char sh7751systemh_inb_p(unsigned long port);
24extern void sh7751systemh_outb_p(unsigned char value, unsigned long port);
25
26extern void sh7751systemh_insb(unsigned long port, void *addr, unsigned long count);
27extern void sh7751systemh_insw(unsigned long port, void *addr, unsigned long count);
28extern void sh7751systemh_insl(unsigned long port, void *addr, unsigned long count);
29extern void sh7751systemh_outsb(unsigned long port, const void *addr, unsigned long count);
30extern void sh7751systemh_outsw(unsigned long port, const void *addr, unsigned long count);
31extern void sh7751systemh_outsl(unsigned long port, const void *addr, unsigned long count);
32
33extern unsigned char sh7751systemh_readb(unsigned long addr);
34extern unsigned short sh7751systemh_readw(unsigned long addr);
35extern unsigned int sh7751systemh_readl(unsigned long addr);
36extern void sh7751systemh_writeb(unsigned char b, unsigned long addr);
37extern void sh7751systemh_writew(unsigned short b, unsigned long addr);
38extern void sh7751systemh_writel(unsigned int b, unsigned long addr);
39
40extern unsigned long sh7751systemh_isa_port2addr(unsigned long offset);
41
42#endif /* __ASM_SH_SYSTEMH_IO_H */
43
diff --git a/include/asm-sh/systemh/7751systemh.h b/include/asm-sh/systemh7751.h
index 4170531bdbd9..b143bb2a2ca7 100644
--- a/include/asm-sh/systemh/7751systemh.h
+++ b/include/asm-sh/systemh7751.h
@@ -65,4 +65,7 @@
65 65
66#define IRQ_79C973 13 66#define IRQ_79C973 13
67 67
68#define __IO_PREFIX sh7751systemh
69#include <asm/io_generic.h>
70
68#endif /* __ASM_SH_SYSTEMH_7751SYSTEMH_H */ 71#endif /* __ASM_SH_SYSTEMH_7751SYSTEMH_H */
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 7345350d98c0..3ebc3f9039eb 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -9,8 +9,8 @@
9 * Copyright (C) 2002 David Howells (dhowells@redhat.com) 9 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
10 * - Incorporating suggestions made by Linus Torvalds and Dave Miller 10 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
11 */ 11 */
12
13#ifdef __KERNEL__ 12#ifdef __KERNEL__
13#include <asm/page.h>
14 14
15#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
16#include <asm/processor.h> 16#include <asm/processor.h>
@@ -21,7 +21,10 @@ struct thread_info {
21 unsigned long flags; /* low level flags */ 21 unsigned long flags; /* low level flags */
22 __u32 cpu; 22 __u32 cpu;
23 int preempt_count; /* 0 => preemptable, <0 => BUG */ 23 int preempt_count; /* 0 => preemptable, <0 => BUG */
24 mm_segment_t addr_limit; /* thread address space */
24 struct restart_block restart_block; 25 struct restart_block restart_block;
26 unsigned long previous_sp; /* sp of previous stack in case
27 of nested IRQ stacks */
25 __u8 supervisor_stack[0]; 28 __u8 supervisor_stack[0];
26}; 29};
27 30
@@ -29,6 +32,13 @@ struct thread_info {
29 32
30#define PREEMPT_ACTIVE 0x10000000 33#define PREEMPT_ACTIVE 0x10000000
31 34
35#ifdef CONFIG_4KSTACKS
36#define THREAD_SIZE (PAGE_SIZE)
37#else
38#define THREAD_SIZE (PAGE_SIZE * 2)
39#endif
40#define STACK_WARN (THREAD_SIZE / 8)
41
32/* 42/*
33 * macros/functions for gaining access to the thread information structure 43 * macros/functions for gaining access to the thread information structure
34 */ 44 */
@@ -40,6 +50,7 @@ struct thread_info {
40 .flags = 0, \ 50 .flags = 0, \
41 .cpu = 0, \ 51 .cpu = 0, \
42 .preempt_count = 1, \ 52 .preempt_count = 1, \
53 .addr_limit = KERNEL_DS, \
43 .restart_block = { \ 54 .restart_block = { \
44 .fn = do_no_restart_syscall, \ 55 .fn = do_no_restart_syscall, \
45 }, \ 56 }, \
@@ -48,24 +59,42 @@ struct thread_info {
48#define init_thread_info (init_thread_union.thread_info) 59#define init_thread_info (init_thread_union.thread_info)
49#define init_stack (init_thread_union.stack) 60#define init_stack (init_thread_union.stack)
50 61
62/* how to get the current stack pointer from C */
63register unsigned long current_stack_pointer asm("r15") __attribute_used__;
64
51/* how to get the thread information struct from C */ 65/* how to get the thread information struct from C */
52static inline struct thread_info *current_thread_info(void) 66static inline struct thread_info *current_thread_info(void)
53{ 67{
54 struct thread_info *ti; 68 struct thread_info *ti;
69#ifdef CONFIG_CPU_HAS_SR_RB
55 __asm__("stc r7_bank, %0" : "=r" (ti)); 70 __asm__("stc r7_bank, %0" : "=r" (ti));
71#else
72 unsigned long __dummy;
73
74 __asm__ __volatile__ (
75 "mov r15, %0\n\t"
76 "and %1, %0\n\t"
77 : "=&r" (ti), "=r" (__dummy)
78 : "1" (~(THREAD_SIZE - 1))
79 : "memory");
80#endif
81
56 return ti; 82 return ti;
57} 83}
58 84
59/* thread information allocation */ 85/* thread information allocation */
60#define THREAD_SIZE (2*PAGE_SIZE) 86#ifdef CONFIG_DEBUG_STACK_USAGE
61#define alloc_thread_info(ti) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1)) 87#define alloc_thread_info(ti) kzalloc(THREAD_SIZE, GFP_KERNEL)
62#define free_thread_info(ti) free_pages((unsigned long) (ti), 1) 88#else
89#define alloc_thread_info(ti) kmalloc(THREAD_SIZE, GFP_KERNEL)
90#endif
91#define free_thread_info(ti) kfree(ti)
63 92
64#else /* !__ASSEMBLY__ */ 93#else /* !__ASSEMBLY__ */
65 94
66/* how to get the thread information struct from ASM */ 95/* how to get the thread information struct from ASM */
67#define GET_THREAD_INFO(reg) \ 96#define GET_THREAD_INFO(reg) \
68 stc r7_bank, reg 97 stc r7_bank, reg
69 98
70#endif 99#endif
71 100
@@ -79,18 +108,18 @@ static inline struct thread_info *current_thread_info(void)
79#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ 108#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
80#define TIF_SIGPENDING 2 /* signal pending */ 109#define TIF_SIGPENDING 2 /* signal pending */
81#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 110#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
111#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
82#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 112#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
83#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 113#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
84#define TIF_MEMDIE 18 114#define TIF_MEMDIE 18
85#define TIF_USERSPACE 31 /* true if FS sets userspace */
86 115
87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 116#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
88#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 117#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
89#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 118#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
90#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 119#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
120#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
91#define _TIF_USEDFPU (1<<TIF_USEDFPU) 121#define _TIF_USEDFPU (1<<TIF_USEDFPU)
92#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 122#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
93#define _TIF_USERSPACE (1<<TIF_USERSPACE)
94 123
95#define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */ 124#define _TIF_WORK_MASK 0x000000FE /* work to do on interrupt/exception return */
96#define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */ 125#define _TIF_ALLWORK_MASK 0x000000FF /* work to do on any return to u-space */
diff --git a/include/asm-sh/timer.h b/include/asm-sh/timer.h
index dd6579c0b04c..c7ab28095ba0 100644
--- a/include/asm-sh/timer.h
+++ b/include/asm-sh/timer.h
@@ -6,6 +6,8 @@
6 6
7struct sys_timer_ops { 7struct sys_timer_ops {
8 int (*init)(void); 8 int (*init)(void);
9 int (*start)(void);
10 int (*stop)(void);
9 unsigned long (*get_offset)(void); 11 unsigned long (*get_offset)(void);
10 unsigned long (*get_frequency)(void); 12 unsigned long (*get_frequency)(void);
11}; 13};
diff --git a/include/asm-sh/titan.h b/include/asm-sh/titan.h
new file mode 100644
index 000000000000..270a4f4bc8a9
--- /dev/null
+++ b/include/asm-sh/titan.h
@@ -0,0 +1,43 @@
1/*
2 * Platform defintions for Titan
3 */
4
5#ifndef _ASM_SH_TITAN_TITAN_H
6#define _ASM_SH_TITAN_TITAN_H
7
8#define __IO_PREFIX titan
9#include <asm/io_generic.h>
10
11/* IRQ assignments */
12#define TITAN_IRQ_WAN 2 /* eth0 (WAN) */
13#define TITAN_IRQ_LAN 5 /* eth1 (LAN) */
14#define TITAN_IRQ_MPCIA 8 /* mPCI A */
15#define TITAN_IRQ_MPCIB 11 /* mPCI B */
16#define TITAN_IRQ_USB 11 /* USB */
17
18/*
19 * The external interrupt lines, these take up ints 0 - 15 inclusive
20 * depending on the priority for the interrupt. In fact the priority
21 * is the interrupt :-)
22 */
23#define IRL0_IRQ 0
24#define IRL0_IPR_ADDR INTC_IPRD
25#define IRL0_IPR_POS 3
26#define IRL0_PRIORITY 8
27
28#define IRL1_IRQ 1
29#define IRL1_IPR_ADDR INTC_IPRD
30#define IRL1_IPR_POS 2
31#define IRL1_PRIORITY 8
32
33#define IRL2_IRQ 2
34#define IRL2_IPR_ADDR INTC_IPRD
35#define IRL2_IPR_POS 1
36#define IRL2_PRIORITY 8
37
38#define IRL3_IRQ 3
39#define IRL3_IPR_ADDR INTC_IPRD
40#define IRL3_IPR_POS 0
41#define IRL3_PRIORITY 8
42
43#endif
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h
index 2cb01861e7c5..5c49ed6715f2 100644
--- a/include/asm-sh/uaccess.h
+++ b/include/asm-sh/uaccess.h
@@ -16,21 +16,9 @@
16#include <linux/errno.h> 16#include <linux/errno.h>
17#include <linux/sched.h> 17#include <linux/sched.h>
18 18
19/*
20 * NOTE: Macro/functions in this file depends on threads_info.h implementation.
21 * Assumes:
22 * TI_FLAGS == 8
23 * TIF_USERSPACE == 31
24 * USER_ADDR_LIMIT == 0x80000000
25 */
26
27#define VERIFY_READ 0 19#define VERIFY_READ 0
28#define VERIFY_WRITE 1 20#define VERIFY_WRITE 1
29 21
30typedef struct {
31 unsigned int is_user_space;
32} mm_segment_t;
33
34/* 22/*
35 * The fs value determines whether argument validity checking should be 23 * The fs value determines whether argument validity checking should be
36 * performed or not. If get_fs() == USER_DS, checking is performed, with 24 * performed or not. If get_fs() == USER_DS, checking is performed, with
@@ -40,16 +28,18 @@ typedef struct {
40 */ 28 */
41 29
42#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) }) 30#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
43#define segment_eq(a,b) ((a).is_user_space == (b).is_user_space)
44 31
45#define USER_ADDR_LIMIT 0x80000000 32#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
33#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
46 34
47#define KERNEL_DS MAKE_MM_SEG(0) 35#define segment_eq(a,b) ((a).seg == (b).seg)
48#define USER_DS MAKE_MM_SEG(1)
49 36
50#define get_ds() (KERNEL_DS) 37#define get_ds() (KERNEL_DS)
51 38
52#if !defined(CONFIG_MMU) 39#if !defined(CONFIG_MMU)
40/* NOMMU is always true */
41#define __addr_ok(addr) (1)
42
53static inline mm_segment_t get_fs(void) 43static inline mm_segment_t get_fs(void)
54{ 44{
55 return USER_DS; 45 return USER_DS;
@@ -76,31 +66,11 @@ static inline int __access_ok(unsigned long addr, unsigned long size)
76 return ((addr >= memory_start) && ((addr + size) < memory_end)); 66 return ((addr >= memory_start) && ((addr + size) < memory_end));
77} 67}
78#else /* CONFIG_MMU */ 68#else /* CONFIG_MMU */
79static inline mm_segment_t get_fs(void) 69#define __addr_ok(addr) \
80{ 70 ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
81 return MAKE_MM_SEG(test_thread_flag(TIF_USERSPACE));
82}
83 71
84static inline void set_fs(mm_segment_t s) 72#define get_fs() (current_thread_info()->addr_limit)
85{ 73#define set_fs(x) (current_thread_info()->addr_limit = (x))
86 unsigned long ti, flag;
87 __asm__ __volatile__(
88 "stc r7_bank, %0\n\t"
89 "mov.l @(8,%0), %1\n\t"
90 "shal %1\n\t"
91 "cmp/pl %2\n\t"
92 "rotcr %1\n\t"
93 "mov.l %1, @(8,%0)"
94 : "=&r" (ti), "=&r" (flag)
95 : "r" (s.is_user_space)
96 : "t");
97/****
98 if (s.is_user_space)
99 set_thread_flag(TIF_USERSPACE);
100 else
101 clear_thread_flag(TIF_USERSPACE);
102****/
103}
104 74
105/* 75/*
106 * __access_ok: Check if address with size is OK or not. 76 * __access_ok: Check if address with size is OK or not.
@@ -108,7 +78,7 @@ static inline void set_fs(mm_segment_t s)
108 * We do three checks: 78 * We do three checks:
109 * (1) is it user space? 79 * (1) is it user space?
110 * (2) addr + size --> carry? 80 * (2) addr + size --> carry?
111 * (3) addr + size >= 0x80000000 (USER_ADDR_LIMIT) 81 * (3) addr + size >= 0x80000000 (PAGE_OFFSET)
112 * 82 *
113 * (1) (2) (3) | RESULT 83 * (1) (2) (3) | RESULT
114 * 0 0 0 | ok 84 * 0 0 0 | ok
@@ -201,6 +171,7 @@ do { \
201 __gu_err; \ 171 __gu_err; \
202}) 172})
203 173
174#ifdef CONFIG_MMU
204#define __get_user_check(x,ptr,size) \ 175#define __get_user_check(x,ptr,size) \
205({ \ 176({ \
206 long __gu_err, __gu_val; \ 177 long __gu_err, __gu_val; \
@@ -290,6 +261,18 @@ __asm__("stc r7_bank, %1\n\t" \
290 : "r" (addr) \ 261 : "r" (addr) \
291 : "t"); \ 262 : "t"); \
292}) 263})
264#else /* CONFIG_MMU */
265#define __get_user_check(x,ptr,size) \
266({ \
267 long __gu_err, __gu_val; \
268 if (__access_ok((unsigned long)(ptr), (size))) { \
269 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
270 (x) = (__typeof__(*(ptr)))__gu_val; \
271 } else \
272 __gu_err = -EFAULT; \
273 __gu_err; \
274})
275#endif
293 276
294#define __get_user_asm(x, addr, err, insn) \ 277#define __get_user_asm(x, addr, err, insn) \
295({ \ 278({ \
@@ -541,7 +524,7 @@ static __inline__ long __strnlen_user(const char __user *__s, long __n)
541 "3:\n\t" 524 "3:\n\t"
542 "mov.l 4f, %1\n\t" 525 "mov.l 4f, %1\n\t"
543 "jmp @%1\n\t" 526 "jmp @%1\n\t"
544 " mov %5, %0\n" 527 " mov #0, %0\n"
545 ".balign 4\n" 528 ".balign 4\n"
546 "4: .long 2b\n" 529 "4: .long 2b\n"
547 ".previous\n" 530 ".previous\n"
@@ -550,26 +533,20 @@ static __inline__ long __strnlen_user(const char __user *__s, long __n)
550 " .long 1b,3b\n" 533 " .long 1b,3b\n"
551 ".previous" 534 ".previous"
552 : "=z" (res), "=&r" (__dummy) 535 : "=z" (res), "=&r" (__dummy)
553 : "0" (0), "r" (__s), "r" (__n), "i" (-EFAULT) 536 : "0" (0), "r" (__s), "r" (__n)
554 : "t"); 537 : "t");
555 return res; 538 return res;
556} 539}
557 540
558static __inline__ long strnlen_user(const char __user *s, long n) 541static __inline__ long strnlen_user(const char __user *s, long n)
559{ 542{
560 if (!access_ok(VERIFY_READ, s, n)) 543 if (!__addr_ok(s))
561 return 0; 544 return 0;
562 else 545 else
563 return __strnlen_user(s, n); 546 return __strnlen_user(s, n);
564} 547}
565 548
566static __inline__ long strlen_user(const char __user *s) 549#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
567{
568 if (!access_ok(VERIFY_READ, s, 0))
569 return 0;
570 else
571 return __strnlen_user(s, ~0UL >> 1);
572}
573 550
574/* 551/*
575 * The exception table consists of pairs of addresses: the first is the 552 * The exception table consists of pairs of addresses: the first is the
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index 76b5430cb458..5d5e9f94def5 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -292,25 +292,51 @@
292#define __NR_mq_getsetattr (__NR_mq_open+5) 292#define __NR_mq_getsetattr (__NR_mq_open+5)
293#define __NR_kexec_load 283 293#define __NR_kexec_load 283
294#define __NR_waitid 284 294#define __NR_waitid 284
295#define __NR_add_key 285 295/* #define __NR_sys_setaltroot 285 */
296#define __NR_request_key 286 296#define __NR_add_key 286
297#define __NR_keyctl 287 297#define __NR_request_key 287
298#define __NR_ioprio_set 288 298#define __NR_keyctl 288
299#define __NR_ioprio_get 289 299#define __NR_ioprio_set 289
300#define __NR_inotify_init 290 300#define __NR_ioprio_get 290
301#define __NR_inotify_add_watch 291 301#define __NR_inotify_init 291
302#define __NR_inotify_rm_watch 292 302#define __NR_inotify_add_watch 292
303#define __NR_inotify_rm_watch 293
304#define __NR_migrate_pages 294
305#define __NR_openat 295
306#define __NR_mkdirat 296
307#define __NR_mknodat 297
308#define __NR_fchownat 298
309#define __NR_futimesat 299
310#define __NR_newfstatat 300
311#define __NR_unlinkat 301
312#define __NR_renameat 302
313#define __NR_linkat 303
314#define __NR_symlinkat 304
315#define __NR_readlinkat 305
316#define __NR_fchmodat 306
317#define __NR_faccessat 307
318#define __NR_pselect6 308
319#define __NR_ppoll 309
320#define __NR_unshare 310
321#define __NR_set_robust_list 311
322#define __NR_get_robust_list 312
323#define __NR_splice 313
324#define __NR_sync_file_range 314
325#define __NR_tee 315
326#define __NR_vmsplice 316
303 327
304 328#define NR_syscalls 317
305#define NR_syscalls 293
306 329
307#ifdef __KERNEL__ 330#ifdef __KERNEL__
308 331
309/* user-visible error numbers are in the range -1 - -124: see <asm-sh/errno.h> */ 332#include <linux/err.h>
333
334/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
335 * see <asm-sh/errno.h> */
310 336
311#define __syscall_return(type, res) \ 337#define __syscall_return(type, res) \
312do { \ 338do { \
313 if ((unsigned long)(res) >= (unsigned long)(-124)) { \ 339 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
314 /* Avoid using "res" which is declared to be in register r0; \ 340 /* Avoid using "res" which is declared to be in register r0; \
315 errno might expand to a function call and clobber it. */ \ 341 errno might expand to a function call and clobber it. */ \
316 int __err = -(res); \ 342 int __err = -(res); \
@@ -444,6 +470,7 @@ __syscall_return(type,__sc0); \
444#define __ARCH_WANT_SYS_SIGPENDING 470#define __ARCH_WANT_SYS_SIGPENDING
445#define __ARCH_WANT_SYS_SIGPROCMASK 471#define __ARCH_WANT_SYS_SIGPROCMASK
446#define __ARCH_WANT_SYS_RT_SIGACTION 472#define __ARCH_WANT_SYS_RT_SIGACTION
473#define __ARCH_WANT_SYS_RT_SIGSUSPEND
447 474
448#ifdef __KERNEL_SYSCALLS__ 475#ifdef __KERNEL_SYSCALLS__
449 476
diff --git a/include/asm-sh/rts7751r2d/voyagergx_reg.h b/include/asm-sh/voyagergx.h
index f031b5d6cf54..99b0807d1c9f 100644
--- a/include/asm-sh/rts7751r2d/voyagergx_reg.h
+++ b/include/asm-sh/voyagergx.h
@@ -1,5 +1,5 @@
1/* -------------------------------------------------------------------- */ 1/* -------------------------------------------------------------------- */
2/* voyagergx_reg.h */ 2/* voyagergx.h */
3/* -------------------------------------------------------------------- */ 3/* -------------------------------------------------------------------- */
4/* This program is free software; you can redistribute it and/or modify 4/* This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/include/asm-sh/watchdog.h b/include/asm-sh/watchdog.h
index 09ca41972a11..d19ea62ef8c6 100644
--- a/include/asm-sh/watchdog.h
+++ b/include/asm-sh/watchdog.h
@@ -62,7 +62,6 @@
62 62
63/** 63/**
64 * sh_wdt_read_cnt - Read from Counter 64 * sh_wdt_read_cnt - Read from Counter
65 *
66 * Reads back the WTCNT value. 65 * Reads back the WTCNT value.
67 */ 66 */
68static inline __u8 sh_wdt_read_cnt(void) 67static inline __u8 sh_wdt_read_cnt(void)
@@ -72,7 +71,6 @@ static inline __u8 sh_wdt_read_cnt(void)
72 71
73/** 72/**
74 * sh_wdt_write_cnt - Write to Counter 73 * sh_wdt_write_cnt - Write to Counter
75 *
76 * @val: Value to write 74 * @val: Value to write
77 * 75 *
78 * Writes the given value @val to the lower byte of the timer counter. 76 * Writes the given value @val to the lower byte of the timer counter.
@@ -95,7 +93,6 @@ static inline __u8 sh_wdt_read_csr(void)
95 93
96/** 94/**
97 * sh_wdt_write_csr - Write to Control/Status Register 95 * sh_wdt_write_csr - Write to Control/Status Register
98 *
99 * @val: Value to write 96 * @val: Value to write
100 * 97 *
101 * Writes the given value @val to the lower byte of the control/status 98 * Writes the given value @val to the lower byte of the control/status
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh64/unistd.h
index 9a1590fffc15..c113566bef33 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh64/unistd.h
@@ -347,8 +347,10 @@
347#ifdef __KERNEL__ 347#ifdef __KERNEL__
348 348
349#define NR_syscalls 321 349#define NR_syscalls 321
350#include <linux/err.h>
350 351
351/* user-visible error numbers are in the range -1 - -125: see <asm-sh64/errno.h> */ 352/* user-visible error numbers are in the range -1 - -MAX_ERRNO:
353 * see <asm-sh64/errno.h> */
352 354
353#define __syscall_return(type, res) \ 355#define __syscall_return(type, res) \
354do { \ 356do { \
@@ -358,7 +360,7 @@ do { \
358 ** life easier in the system call epilogue (see entry.S) \ 360 ** life easier in the system call epilogue (see entry.S) \
359 */ \ 361 */ \
360 register unsigned long __sr2 __asm__ ("r2") = res; \ 362 register unsigned long __sr2 __asm__ ("r2") = res; \
361 if ((unsigned long)(res) >= (unsigned long)(-125)) { \ 363 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
362 errno = -(res); \ 364 errno = -(res); \
363 __sr2 = -1; \ 365 __sr2 = -1; \
364 } \ 366 } \
diff --git a/include/asm-um/alternative-asm.i b/include/asm-um/alternative-asm.i
new file mode 100644
index 000000000000..cae9faca132f
--- /dev/null
+++ b/include/asm-um/alternative-asm.i
@@ -0,0 +1,6 @@
1#ifndef __UM_ALTERNATIVE_ASM_I
2#define __UM_ALTERNATIVE_ASM_I
3
4#include "asm/arch/alternative-asm.i"
5
6#endif
diff --git a/include/asm-um/frame.i b/include/asm-um/frame.i
new file mode 100644
index 000000000000..09d5dca5d928
--- /dev/null
+++ b/include/asm-um/frame.i
@@ -0,0 +1,6 @@
1#ifndef __UM_FRAME_I
2#define __UM_FRAME_I
3
4#include "asm/arch/frame.i"
5
6#endif
diff --git a/include/asm-um/processor-generic.h b/include/asm-um/processor-generic.h
index afa4fe1ca9f1..d99bbddffdb9 100644
--- a/include/asm-um/processor-generic.h
+++ b/include/asm-um/processor-generic.h
@@ -13,6 +13,7 @@ struct task_struct;
13#include "asm/ptrace.h" 13#include "asm/ptrace.h"
14#include "choose-mode.h" 14#include "choose-mode.h"
15#include "registers.h" 15#include "registers.h"
16#include "sysdep/archsetjmp.h"
16 17
17struct mm_struct; 18struct mm_struct;
18 19
@@ -43,8 +44,7 @@ struct thread_struct {
43#endif 44#endif
44#ifdef CONFIG_MODE_SKAS 45#ifdef CONFIG_MODE_SKAS
45 struct { 46 struct {
46 void *switch_buf; 47 jmp_buf switch_buf;
47 void *fork_buf;
48 int mm_count; 48 int mm_count;
49 } skas; 49 } skas;
50#endif 50#endif
@@ -138,7 +138,7 @@ extern struct cpuinfo_um cpu_data[];
138 138
139#ifdef CONFIG_MODE_SKAS 139#ifdef CONFIG_MODE_SKAS
140#define KSTK_REG(tsk, reg) \ 140#define KSTK_REG(tsk, reg) \
141 get_thread_reg(reg, tsk->thread.mode.skas.switch_buf) 141 get_thread_reg(reg, &tsk->thread.mode.skas.switch_buf)
142#else 142#else
143#define KSTK_REG(tsk, reg) (0xbadbabe) 143#define KSTK_REG(tsk, reg) (0xbadbabe)
144#endif 144#endif
diff --git a/include/asm-um/ptrace-x86_64.h b/include/asm-um/ptrace-x86_64.h
index 2074483e6ca4..03b4af4ac09a 100644
--- a/include/asm-um/ptrace-x86_64.h
+++ b/include/asm-um/ptrace-x86_64.h
@@ -16,12 +16,15 @@
16 16
17#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64 17#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
18 18
19/* Also defined in sysdep/ptrace.h, so may already be defined. */
20#ifndef FS_BASE
19#define FS_BASE (21 * sizeof(unsigned long)) 21#define FS_BASE (21 * sizeof(unsigned long))
20#define GS_BASE (22 * sizeof(unsigned long)) 22#define GS_BASE (22 * sizeof(unsigned long))
21#define DS (23 * sizeof(unsigned long)) 23#define DS (23 * sizeof(unsigned long))
22#define ES (24 * sizeof(unsigned long)) 24#define ES (24 * sizeof(unsigned long))
23#define FS (25 * sizeof(unsigned long)) 25#define FS (25 * sizeof(unsigned long))
24#define GS (26 * sizeof(unsigned long)) 26#define GS (26 * sizeof(unsigned long))
27#endif
25 28
26#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs) 29#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs)
27#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs) 30#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs)
diff --git a/include/asm-v850/unistd.h b/include/asm-v850/unistd.h
index bcb44bfe577a..552b7c873a57 100644
--- a/include/asm-v850/unistd.h
+++ b/include/asm-v850/unistd.h
@@ -238,12 +238,13 @@
238#ifdef __KERNEL__ 238#ifdef __KERNEL__
239 239
240#include <asm/clinkage.h> 240#include <asm/clinkage.h>
241#include <linux/err.h>
241 242
242#define __syscall_return(type, res) \ 243#define __syscall_return(type, res) \
243 do { \ 244 do { \
244 /* user-visible error numbers are in the range -1 - -124: \ 245 /* user-visible error numbers are in the range -1 - -MAX_ERRNO: \
245 see <asm-v850/errno.h> */ \ 246 see <asm-v850/errno.h> */ \
246 if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-125), 0)) { \ 247 if (__builtin_expect ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO), 0)) { \
247 errno = -(res); \ 248 errno = -(res); \
248 res = -1; \ 249 res = -1; \
249 } \ 250 } \
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index 2c95a319c056..ed59aa4c6ff9 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -155,8 +155,6 @@ extern void acpi_reserve_bootmem(void);
155 155
156#endif /*CONFIG_ACPI_SLEEP*/ 156#endif /*CONFIG_ACPI_SLEEP*/
157 157
158#define boot_cpu_physical_apicid boot_cpu_id
159
160extern int acpi_disabled; 158extern int acpi_disabled;
161extern int acpi_pci_disabled; 159extern int acpi_pci_disabled;
162 160
diff --git a/include/asm-x86_64/alternative-asm.i b/include/asm-x86_64/alternative-asm.i
new file mode 100644
index 000000000000..e4041f4fa4dc
--- /dev/null
+++ b/include/asm-x86_64/alternative-asm.i
@@ -0,0 +1,14 @@
1#include <linux/config.h>
2
3#ifdef CONFIG_SMP
4 .macro LOCK_PREFIX
51: lock
6 .section .smp_locks,"a"
7 .align 8
8 .quad 1b
9 .previous
10 .endm
11#else
12 .macro LOCK_PREFIX
13 .endm
14#endif
diff --git a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
index 9c96a0a8d1bd..9e66d32330c9 100644
--- a/include/asm-x86_64/apic.h
+++ b/include/asm-x86_64/apic.h
@@ -17,6 +17,8 @@
17 17
18extern int apic_verbosity; 18extern int apic_verbosity;
19extern int apic_runs_main_timer; 19extern int apic_runs_main_timer;
20extern int ioapic_force;
21extern int apic_mapped;
20 22
21/* 23/*
22 * Define the default level of output to be very little 24 * Define the default level of output to be very little
@@ -29,8 +31,6 @@ extern int apic_runs_main_timer;
29 printk(s, ##a); \ 31 printk(s, ##a); \
30 } while (0) 32 } while (0)
31 33
32#ifdef CONFIG_X86_LOCAL_APIC
33
34struct pt_regs; 34struct pt_regs;
35 35
36/* 36/*
@@ -95,17 +95,12 @@ extern void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector,
95#define K8_APIC_EXT_INT_MSG_EXT 0x7 95#define K8_APIC_EXT_INT_MSG_EXT 0x7
96#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0 96#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0
97 97
98extern int disable_timer_pin_1;
99
100
101void smp_send_timer_broadcast_ipi(void); 98void smp_send_timer_broadcast_ipi(void);
102void switch_APIC_timer_to_ipi(void *cpumask); 99void switch_APIC_timer_to_ipi(void *cpumask);
103void switch_ipi_to_APIC_timer(void *cpumask); 100void switch_ipi_to_APIC_timer(void *cpumask);
104 101
105#define ARCH_APICTIMER_STOPS_ON_C3 1 102#define ARCH_APICTIMER_STOPS_ON_C3 1
106 103
107#endif /* CONFIG_X86_LOCAL_APIC */
108
109extern unsigned boot_cpu_id; 104extern unsigned boot_cpu_id;
110 105
111#endif /* __ASM_APIC_H */ 106#endif /* __ASM_APIC_H */
diff --git a/include/asm-x86_64/bitops.h b/include/asm-x86_64/bitops.h
index f7ba57b1cc08..5b535eaf5309 100644
--- a/include/asm-x86_64/bitops.h
+++ b/include/asm-x86_64/bitops.h
@@ -399,6 +399,8 @@ static __inline__ int fls(int x)
399 return r+1; 399 return r+1;
400} 400}
401 401
402#define ARCH_HAS_FAST_MULTIPLIER 1
403
402#include <asm-generic/bitops/hweight.h> 404#include <asm-generic/bitops/hweight.h>
403 405
404#endif /* __KERNEL__ */ 406#endif /* __KERNEL__ */
diff --git a/include/asm-x86_64/calgary.h b/include/asm-x86_64/calgary.h
index 4e3919524240..6b93f5a3a5c8 100644
--- a/include/asm-x86_64/calgary.h
+++ b/include/asm-x86_64/calgary.h
@@ -24,7 +24,6 @@
24#ifndef _ASM_X86_64_CALGARY_H 24#ifndef _ASM_X86_64_CALGARY_H
25#define _ASM_X86_64_CALGARY_H 25#define _ASM_X86_64_CALGARY_H
26 26
27#include <linux/config.h>
28#include <linux/spinlock.h> 27#include <linux/spinlock.h>
29#include <linux/device.h> 28#include <linux/device.h>
30#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
@@ -34,12 +33,12 @@ struct iommu_table {
34 unsigned long it_base; /* mapped address of tce table */ 33 unsigned long it_base; /* mapped address of tce table */
35 unsigned long it_hint; /* Hint for next alloc */ 34 unsigned long it_hint; /* Hint for next alloc */
36 unsigned long *it_map; /* A simple allocation bitmap for now */ 35 unsigned long *it_map; /* A simple allocation bitmap for now */
36 void __iomem *bbar; /* Bridge BAR */
37 u64 tar_val; /* Table Address Register */
38 struct timer_list watchdog_timer;
37 spinlock_t it_lock; /* Protects it_map */ 39 spinlock_t it_lock; /* Protects it_map */
38 unsigned int it_size; /* Size of iommu table in entries */ 40 unsigned int it_size; /* Size of iommu table in entries */
39 unsigned char it_busno; /* Bus number this table belongs to */ 41 unsigned char it_busno; /* Bus number this table belongs to */
40 void __iomem *bbar;
41 u64 tar_val;
42 struct timer_list watchdog_timer;
43}; 42};
44 43
45#define TCE_TABLE_SIZE_UNSPECIFIED ~0 44#define TCE_TABLE_SIZE_UNSPECIFIED ~0
diff --git a/include/asm-x86_64/dwarf2.h b/include/asm-x86_64/dwarf2.h
index 0744db777676..eedc08526b0b 100644
--- a/include/asm-x86_64/dwarf2.h
+++ b/include/asm-x86_64/dwarf2.h
@@ -13,7 +13,7 @@
13 away for older version. 13 away for older version.
14 */ 14 */
15 15
16#ifdef CONFIG_UNWIND_INFO 16#ifdef CONFIG_AS_CFI
17 17
18#define CFI_STARTPROC .cfi_startproc 18#define CFI_STARTPROC .cfi_startproc
19#define CFI_ENDPROC .cfi_endproc 19#define CFI_ENDPROC .cfi_endproc
@@ -28,6 +28,11 @@
28#define CFI_REMEMBER_STATE .cfi_remember_state 28#define CFI_REMEMBER_STATE .cfi_remember_state
29#define CFI_RESTORE_STATE .cfi_restore_state 29#define CFI_RESTORE_STATE .cfi_restore_state
30#define CFI_UNDEFINED .cfi_undefined 30#define CFI_UNDEFINED .cfi_undefined
31#ifdef CONFIG_AS_CFI_SIGNAL_FRAME
32#define CFI_SIGNAL_FRAME .cfi_signal_frame
33#else
34#define CFI_SIGNAL_FRAME
35#endif
31 36
32#else 37#else
33 38
@@ -45,6 +50,7 @@
45#define CFI_REMEMBER_STATE # 50#define CFI_REMEMBER_STATE #
46#define CFI_RESTORE_STATE # 51#define CFI_RESTORE_STATE #
47#define CFI_UNDEFINED # 52#define CFI_UNDEFINED #
53#define CFI_SIGNAL_FRAME #
48 54
49#endif 55#endif
50 56
diff --git a/include/asm-x86_64/e820.h b/include/asm-x86_64/e820.h
index f65674832318..fa2086774105 100644
--- a/include/asm-x86_64/e820.h
+++ b/include/asm-x86_64/e820.h
@@ -19,13 +19,9 @@
19 19
20#define E820_RAM 1 20#define E820_RAM 1
21#define E820_RESERVED 2 21#define E820_RESERVED 2
22#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */ 22#define E820_ACPI 3
23#define E820_NVS 4 23#define E820_NVS 4
24 24
25#define HIGH_MEMORY (1024*1024)
26
27#define LOWMEMSIZE() (0x9f000)
28
29#ifndef __ASSEMBLY__ 25#ifndef __ASSEMBLY__
30struct e820entry { 26struct e820entry {
31 u64 addr; /* start of memory segment */ 27 u64 addr; /* start of memory segment */
@@ -51,13 +47,11 @@ extern void e820_print_map(char *who);
51extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type); 47extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
52extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type); 48extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
53 49
54extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end);
55extern void e820_setup_gap(void); 50extern void e820_setup_gap(void);
56extern unsigned long e820_hole_size(unsigned long start_pfn, 51extern void e820_register_active_regions(int nid,
57 unsigned long end_pfn); 52 unsigned long start_pfn, unsigned long end_pfn);
58 53
59extern void __init parse_memopt(char *p, char **end); 54extern void finish_e820_parsing(void);
60extern void __init parse_memmapopt(char *p, char **end);
61 55
62extern struct e820map e820; 56extern struct e820map e820;
63 57
diff --git a/include/asm-x86_64/fixmap.h b/include/asm-x86_64/fixmap.h
index 0b4ffbd1a125..1b620db5b9e3 100644
--- a/include/asm-x86_64/fixmap.h
+++ b/include/asm-x86_64/fixmap.h
@@ -37,13 +37,9 @@ enum fixed_addresses {
37 VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1, 37 VSYSCALL_FIRST_PAGE = VSYSCALL_LAST_PAGE + ((VSYSCALL_END-VSYSCALL_START) >> PAGE_SHIFT) - 1,
38 VSYSCALL_HPET, 38 VSYSCALL_HPET,
39 FIX_HPET_BASE, 39 FIX_HPET_BASE,
40#ifdef CONFIG_X86_LOCAL_APIC
41 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 40 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
42#endif
43#ifdef CONFIG_X86_IO_APIC
44 FIX_IO_APIC_BASE_0, 41 FIX_IO_APIC_BASE_0,
45 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, 42 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
46#endif
47 __end_of_fixed_addresses 43 __end_of_fixed_addresses
48}; 44};
49 45
diff --git a/include/asm-x86_64/genapic.h b/include/asm-x86_64/genapic.h
index 50b38e7c58e4..81e714665344 100644
--- a/include/asm-x86_64/genapic.h
+++ b/include/asm-x86_64/genapic.h
@@ -16,7 +16,6 @@ struct genapic {
16 char *name; 16 char *name;
17 u32 int_delivery_mode; 17 u32 int_delivery_mode;
18 u32 int_dest_mode; 18 u32 int_dest_mode;
19 u32 int_delivery_dest; /* for quick IPIs */
20 int (*apic_id_registered)(void); 19 int (*apic_id_registered)(void);
21 cpumask_t (*target_cpus)(void); 20 cpumask_t (*target_cpus)(void);
22 void (*init_apic_ldr)(void); 21 void (*init_apic_ldr)(void);
diff --git a/include/asm-x86_64/i387.h b/include/asm-x86_64/i387.h
index cba8a3b0cded..0217b74cc9fc 100644
--- a/include/asm-x86_64/i387.h
+++ b/include/asm-x86_64/i387.h
@@ -24,6 +24,7 @@ extern unsigned int mxcsr_feature_mask;
24extern void mxcsr_feature_mask_init(void); 24extern void mxcsr_feature_mask_init(void);
25extern void init_fpu(struct task_struct *child); 25extern void init_fpu(struct task_struct *child);
26extern int save_i387(struct _fpstate __user *buf); 26extern int save_i387(struct _fpstate __user *buf);
27extern asmlinkage void math_state_restore(void);
27 28
28/* 29/*
29 * FPU lazy state save handling... 30 * FPU lazy state save handling...
@@ -31,7 +32,9 @@ extern int save_i387(struct _fpstate __user *buf);
31 32
32#define unlazy_fpu(tsk) do { \ 33#define unlazy_fpu(tsk) do { \
33 if (task_thread_info(tsk)->status & TS_USEDFPU) \ 34 if (task_thread_info(tsk)->status & TS_USEDFPU) \
34 save_init_fpu(tsk); \ 35 save_init_fpu(tsk); \
36 else \
37 tsk->fpu_counter = 0; \
35} while (0) 38} while (0)
36 39
37/* Ignore delayed exceptions from user space */ 40/* Ignore delayed exceptions from user space */
@@ -134,8 +137,8 @@ static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
134#else 137#else
135 : [fx] "cdaSDb" (fx), "0" (0)); 138 : [fx] "cdaSDb" (fx), "0" (0));
136#endif 139#endif
137 if (unlikely(err)) 140 if (unlikely(err) && __clear_user(fx, sizeof(struct i387_fxsave_struct)))
138 __clear_user(fx, sizeof(struct i387_fxsave_struct)); 141 err = -EFAULT;
139 /* No need to clear here because the caller clears USED_MATH */ 142 /* No need to clear here because the caller clears USED_MATH */
140 return err; 143 return err;
141} 144}
diff --git a/include/asm-x86_64/intel_arch_perfmon.h b/include/asm-x86_64/intel_arch_perfmon.h
index 59c396431569..8633331420ec 100644
--- a/include/asm-x86_64/intel_arch_perfmon.h
+++ b/include/asm-x86_64/intel_arch_perfmon.h
@@ -14,6 +14,18 @@
14 14
15#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c) 15#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_SEL (0x3c)
16#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8) 16#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_UMASK (0x00 << 8)
17#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT (1 << 0) 17#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX (0)
18#define ARCH_PERFMON_UNHALTED_CORE_CYCLES_PRESENT \
19 (1 << (ARCH_PERFMON_UNHALTED_CORE_CYCLES_INDEX))
20
21union cpuid10_eax {
22 struct {
23 unsigned int version_id:8;
24 unsigned int num_counters:8;
25 unsigned int bit_width:8;
26 unsigned int mask_length:8;
27 } split;
28 unsigned int full;
29};
18 30
19#endif /* X86_64_INTEL_ARCH_PERFMON_H */ 31#endif /* X86_64_INTEL_ARCH_PERFMON_H */
diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h
index fb7a0909a174..5d1b5c68e36e 100644
--- a/include/asm-x86_64/io_apic.h
+++ b/include/asm-x86_64/io_apic.h
@@ -10,8 +10,6 @@
10 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar 10 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
11 */ 11 */
12 12
13#ifdef CONFIG_X86_IO_APIC
14
15#ifdef CONFIG_PCI_MSI 13#ifdef CONFIG_PCI_MSI
16static inline int use_pci_vector(void) {return 1;} 14static inline int use_pci_vector(void) {return 1;}
17static inline void disable_edge_ioapic_vector(unsigned int vector) { } 15static inline void disable_edge_ioapic_vector(unsigned int vector) { }
@@ -209,10 +207,6 @@ extern int timer_uses_ioapic_pin_0;
209 207
210extern int sis_apic_bug; /* dummy */ 208extern int sis_apic_bug; /* dummy */
211 209
212#else /* !CONFIG_X86_IO_APIC */
213#define io_apic_assign_pci_irqs 0
214#endif
215
216extern int assign_irq_vector(int irq); 210extern int assign_irq_vector(int irq);
217 211
218void enable_NMI_through_LVT0 (void * dummy); 212void enable_NMI_through_LVT0 (void * dummy);
diff --git a/include/asm-x86_64/irq.h b/include/asm-x86_64/irq.h
index 9db5a1b4f7b1..43469d8ab71a 100644
--- a/include/asm-x86_64/irq.h
+++ b/include/asm-x86_64/irq.h
@@ -44,9 +44,7 @@ static __inline__ int irq_canonicalize(int irq)
44 return ((irq == 2) ? 9 : irq); 44 return ((irq == 2) ? 9 : irq);
45} 45}
46 46
47#ifdef CONFIG_X86_LOCAL_APIC
48#define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */ 47#define ARCH_HAS_NMI_WATCHDOG /* See include/linux/nmi.h */
49#endif
50 48
51#ifdef CONFIG_HOTPLUG_CPU 49#ifdef CONFIG_HOTPLUG_CPU
52#include <linux/cpumask.h> 50#include <linux/cpumask.h>
diff --git a/include/asm-x86_64/kexec.h b/include/asm-x86_64/kexec.h
index c564bae03433..5fab957e1091 100644
--- a/include/asm-x86_64/kexec.h
+++ b/include/asm-x86_64/kexec.h
@@ -1,6 +1,27 @@
1#ifndef _X86_64_KEXEC_H 1#ifndef _X86_64_KEXEC_H
2#define _X86_64_KEXEC_H 2#define _X86_64_KEXEC_H
3 3
4#define PA_CONTROL_PAGE 0
5#define VA_CONTROL_PAGE 1
6#define PA_PGD 2
7#define VA_PGD 3
8#define PA_PUD_0 4
9#define VA_PUD_0 5
10#define PA_PMD_0 6
11#define VA_PMD_0 7
12#define PA_PTE_0 8
13#define VA_PTE_0 9
14#define PA_PUD_1 10
15#define VA_PUD_1 11
16#define PA_PMD_1 12
17#define VA_PMD_1 13
18#define PA_PTE_1 14
19#define VA_PTE_1 15
20#define PA_TABLE_PAGE 16
21#define PAGES_NR 17
22
23#ifndef __ASSEMBLY__
24
4#include <linux/string.h> 25#include <linux/string.h>
5 26
6#include <asm/page.h> 27#include <asm/page.h>
@@ -64,4 +85,12 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
64 newregs->rip = (unsigned long)current_text_addr(); 85 newregs->rip = (unsigned long)current_text_addr();
65 } 86 }
66} 87}
88
89NORET_TYPE void
90relocate_kernel(unsigned long indirection_page,
91 unsigned long page_list,
92 unsigned long start_address) ATTRIB_NORET;
93
94#endif /* __ASSEMBLY__ */
95
67#endif /* _X86_64_KEXEC_H */ 96#endif /* _X86_64_KEXEC_H */
diff --git a/include/asm-x86_64/linkage.h b/include/asm-x86_64/linkage.h
index 291c2d01c44f..b5f39d0189ce 100644
--- a/include/asm-x86_64/linkage.h
+++ b/include/asm-x86_64/linkage.h
@@ -1,6 +1,6 @@
1#ifndef __ASM_LINKAGE_H 1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H 2#define __ASM_LINKAGE_H
3 3
4/* Nothing to see here... */ 4#define __ALIGN .p2align 4,,15
5 5
6#endif 6#endif
diff --git a/include/asm-x86_64/mach_apic.h b/include/asm-x86_64/mach_apic.h
index 0acea44c9377..d33422450c00 100644
--- a/include/asm-x86_64/mach_apic.h
+++ b/include/asm-x86_64/mach_apic.h
@@ -16,7 +16,6 @@
16 16
17#define INT_DELIVERY_MODE (genapic->int_delivery_mode) 17#define INT_DELIVERY_MODE (genapic->int_delivery_mode)
18#define INT_DEST_MODE (genapic->int_dest_mode) 18#define INT_DEST_MODE (genapic->int_dest_mode)
19#define INT_DELIVERY_DEST (genapic->int_delivery_dest)
20#define TARGET_CPUS (genapic->target_cpus()) 19#define TARGET_CPUS (genapic->target_cpus())
21#define apic_id_registered (genapic->apic_id_registered) 20#define apic_id_registered (genapic->apic_id_registered)
22#define init_apic_ldr (genapic->init_apic_ldr) 21#define init_apic_ldr (genapic->init_apic_ldr)
diff --git a/include/asm-x86_64/mce.h b/include/asm-x86_64/mce.h
index d13687dfd691..5a11146d6d9c 100644
--- a/include/asm-x86_64/mce.h
+++ b/include/asm-x86_64/mce.h
@@ -99,6 +99,8 @@ static inline void mce_amd_feature_init(struct cpuinfo_x86 *c)
99} 99}
100#endif 100#endif
101 101
102void mce_log_therm_throt_event(unsigned int cpu, __u64 status);
103
102extern atomic_t mce_entry; 104extern atomic_t mce_entry;
103 105
104#endif 106#endif
diff --git a/include/asm-x86_64/mmx.h b/include/asm-x86_64/mmx.h
deleted file mode 100644
index 46b71da99869..000000000000
--- a/include/asm-x86_64/mmx.h
+++ /dev/null
@@ -1,14 +0,0 @@
1#ifndef _ASM_MMX_H
2#define _ASM_MMX_H
3
4/*
5 * MMX 3Dnow! helper operations
6 */
7
8#include <linux/types.h>
9
10extern void *_mmx_memcpy(void *to, const void *from, size_t size);
11extern void mmx_clear_page(void *page);
12extern void mmx_copy_page(void *to, void *from);
13
14#endif
diff --git a/include/asm-x86_64/mpspec.h b/include/asm-x86_64/mpspec.h
index 14fc3ddd9031..017fddb61dc5 100644
--- a/include/asm-x86_64/mpspec.h
+++ b/include/asm-x86_64/mpspec.h
@@ -159,13 +159,7 @@ struct mpc_config_lintsrc
159#define MAX_MP_BUSSES 256 159#define MAX_MP_BUSSES 256
160/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */ 160/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */
161#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4) 161#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4)
162enum mp_bustype { 162extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
163 MP_BUS_ISA = 1,
164 MP_BUS_EISA,
165 MP_BUS_PCI,
166 MP_BUS_MCA
167};
168extern unsigned char mp_bus_id_to_type [MAX_MP_BUSSES];
169extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES]; 163extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
170 164
171extern unsigned int boot_cpu_physical_apicid; 165extern unsigned int boot_cpu_physical_apicid;
@@ -178,18 +172,15 @@ extern int mp_irq_entries;
178extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES]; 172extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
179extern int mpc_default_type; 173extern int mpc_default_type;
180extern unsigned long mp_lapic_addr; 174extern unsigned long mp_lapic_addr;
181extern int pic_mode;
182 175
183#ifdef CONFIG_ACPI 176#ifdef CONFIG_ACPI
184extern void mp_register_lapic (u8 id, u8 enabled); 177extern void mp_register_lapic (u8 id, u8 enabled);
185extern void mp_register_lapic_address (u64 address); 178extern void mp_register_lapic_address (u64 address);
186 179
187#ifdef CONFIG_X86_IO_APIC
188extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base); 180extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
189extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi); 181extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
190extern void mp_config_acpi_legacy_irqs (void); 182extern void mp_config_acpi_legacy_irqs (void);
191extern int mp_register_gsi (u32 gsi, int triggering, int polarity); 183extern int mp_register_gsi (u32 gsi, int triggering, int polarity);
192#endif /*CONFIG_X86_IO_APIC*/
193#endif 184#endif
194 185
195extern int using_apic_timer; 186extern int using_apic_timer;
diff --git a/include/asm-x86_64/msr.h b/include/asm-x86_64/msr.h
index 10f8b51cec8b..37e194169fac 100644
--- a/include/asm-x86_64/msr.h
+++ b/include/asm-x86_64/msr.h
@@ -66,14 +66,25 @@
66#define rdtscl(low) \ 66#define rdtscl(low) \
67 __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") 67 __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
68 68
69#define rdtscp(low,high,aux) \
70 asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux))
71
69#define rdtscll(val) do { \ 72#define rdtscll(val) do { \
70 unsigned int __a,__d; \ 73 unsigned int __a,__d; \
71 asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \ 74 asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
72 (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \ 75 (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
73} while(0) 76} while(0)
74 77
78#define rdtscpll(val, aux) do { \
79 unsigned long __a, __d; \
80 asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \
81 (val) = (__d << 32) | __a; \
82} while (0)
83
75#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) 84#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
76 85
86#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0)
87
77#define rdpmc(counter,low,high) \ 88#define rdpmc(counter,low,high) \
78 __asm__ __volatile__("rdpmc" \ 89 __asm__ __volatile__("rdpmc" \
79 : "=a" (low), "=d" (high) \ 90 : "=a" (low), "=d" (high) \
diff --git a/include/asm-x86_64/mutex.h b/include/asm-x86_64/mutex.h
index 06fab6de2a88..16396b1de3e4 100644
--- a/include/asm-x86_64/mutex.h
+++ b/include/asm-x86_64/mutex.h
@@ -25,13 +25,9 @@ do { \
25 \ 25 \
26 __asm__ __volatile__( \ 26 __asm__ __volatile__( \
27 LOCK_PREFIX " decl (%%rdi) \n" \ 27 LOCK_PREFIX " decl (%%rdi) \n" \
28 " js 2f \n" \ 28 " jns 1f \n" \
29 "1: \n" \ 29 " call "#fail_fn" \n" \
30 \ 30 "1:" \
31 LOCK_SECTION_START("") \
32 "2: call "#fail_fn" \n" \
33 " jmp 1b \n" \
34 LOCK_SECTION_END \
35 \ 31 \
36 :"=D" (dummy) \ 32 :"=D" (dummy) \
37 : "D" (v) \ 33 : "D" (v) \
@@ -75,13 +71,9 @@ do { \
75 \ 71 \
76 __asm__ __volatile__( \ 72 __asm__ __volatile__( \
77 LOCK_PREFIX " incl (%%rdi) \n" \ 73 LOCK_PREFIX " incl (%%rdi) \n" \
78 " jle 2f \n" \ 74 " jg 1f \n" \
79 "1: \n" \ 75 " call "#fail_fn" \n" \
80 \ 76 "1: " \
81 LOCK_SECTION_START("") \
82 "2: call "#fail_fn" \n" \
83 " jmp 1b \n" \
84 LOCK_SECTION_END \
85 \ 77 \
86 :"=D" (dummy) \ 78 :"=D" (dummy) \
87 : "D" (v) \ 79 : "D" (v) \
diff --git a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
index efb45c894d76..cbf2669bca71 100644
--- a/include/asm-x86_64/nmi.h
+++ b/include/asm-x86_64/nmi.h
@@ -7,24 +7,13 @@
7#include <linux/pm.h> 7#include <linux/pm.h>
8#include <asm/io.h> 8#include <asm/io.h>
9 9
10struct pt_regs;
11
12typedef int (*nmi_callback_t)(struct pt_regs * regs, int cpu);
13
14/**
15 * set_nmi_callback
16 *
17 * Set a handler for an NMI. Only one handler may be
18 * set. Return 1 if the NMI was handled.
19 */
20void set_nmi_callback(nmi_callback_t callback);
21
22/** 10/**
23 * unset_nmi_callback 11 * do_nmi_callback
24 * 12 *
25 * Remove the handler previously set. 13 * Check to see if a callback exists and execute it. Return 1
14 * if the handler exists and was handled successfully.
26 */ 15 */
27void unset_nmi_callback(void); 16int do_nmi_callback(struct pt_regs *regs, int cpu);
28 17
29#ifdef CONFIG_PM 18#ifdef CONFIG_PM
30 19
@@ -48,25 +37,32 @@ static inline void unset_nmi_pm_callback(struct pm_dev * dev)
48#endif /* CONFIG_PM */ 37#endif /* CONFIG_PM */
49 38
50extern void default_do_nmi(struct pt_regs *); 39extern void default_do_nmi(struct pt_regs *);
51extern void die_nmi(char *str, struct pt_regs *regs); 40extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
52 41
53#define get_nmi_reason() inb(0x61) 42#define get_nmi_reason() inb(0x61)
54 43
55extern int panic_on_timeout; 44extern int panic_on_timeout;
56extern int unknown_nmi_panic; 45extern int unknown_nmi_panic;
46extern int nmi_watchdog_enabled;
57 47
58extern int check_nmi_watchdog(void); 48extern int check_nmi_watchdog(void);
59 49extern int avail_to_resrv_perfctr_nmi_bit(unsigned int);
60extern void setup_apic_nmi_watchdog (void); 50extern int avail_to_resrv_perfctr_nmi(unsigned int);
61extern int reserve_lapic_nmi(void); 51extern int reserve_perfctr_nmi(unsigned int);
62extern void release_lapic_nmi(void); 52extern void release_perfctr_nmi(unsigned int);
53extern int reserve_evntsel_nmi(unsigned int);
54extern void release_evntsel_nmi(unsigned int);
55
56extern void setup_apic_nmi_watchdog (void *);
57extern void stop_apic_nmi_watchdog (void *);
63extern void disable_timer_nmi_watchdog(void); 58extern void disable_timer_nmi_watchdog(void);
64extern void enable_timer_nmi_watchdog(void); 59extern void enable_timer_nmi_watchdog(void);
65extern void nmi_watchdog_tick (struct pt_regs * regs, unsigned reason); 60extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason);
66 61
67extern void nmi_watchdog_default(void); 62extern void nmi_watchdog_default(void);
68extern int setup_nmi_watchdog(char *); 63extern int setup_nmi_watchdog(char *);
69 64
65extern atomic_t nmi_active;
70extern unsigned int nmi_watchdog; 66extern unsigned int nmi_watchdog;
71#define NMI_DEFAULT -1 67#define NMI_DEFAULT -1
72#define NMI_NONE 0 68#define NMI_NONE 0
diff --git a/include/asm-x86_64/pci-direct.h b/include/asm-x86_64/pci-direct.h
index 036b6ca5b53b..eba9cb471df3 100644
--- a/include/asm-x86_64/pci-direct.h
+++ b/include/asm-x86_64/pci-direct.h
@@ -2,47 +2,15 @@
2#define ASM_PCI_DIRECT_H 1 2#define ASM_PCI_DIRECT_H 1
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <asm/io.h>
6 5
7/* Direct PCI access. This is used for PCI accesses in early boot before 6/* Direct PCI access. This is used for PCI accesses in early boot before
8 the PCI subsystem works. */ 7 the PCI subsystem works. */
9 8
10#define PDprintk(x...) 9extern u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset);
10extern u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset);
11extern u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset);
12extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val);
11 13
12static inline u32 read_pci_config(u8 bus, u8 slot, u8 func, u8 offset) 14extern int early_pci_allowed(void);
13{
14 u32 v;
15 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
16 v = inl(0xcfc);
17 if (v != 0xffffffff)
18 PDprintk("%x reading 4 from %x: %x\n", slot, offset, v);
19 return v;
20}
21
22static inline u8 read_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset)
23{
24 u8 v;
25 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
26 v = inb(0xcfc + (offset&3));
27 PDprintk("%x reading 1 from %x: %x\n", slot, offset, v);
28 return v;
29}
30
31static inline u16 read_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset)
32{
33 u16 v;
34 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
35 v = inw(0xcfc + (offset&2));
36 PDprintk("%x reading 2 from %x: %x\n", slot, offset, v);
37 return v;
38}
39
40static inline void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset,
41 u32 val)
42{
43 PDprintk("%x writing to %x: %x\n", slot, offset, val);
44 outl(0x80000000 | (bus<<16) | (slot<<11) | (func<<8) | offset, 0xcf8);
45 outl(val, 0xcfc);
46}
47 15
48#endif 16#endif
diff --git a/include/asm-x86_64/pda.h b/include/asm-x86_64/pda.h
index b47c3df9ed1d..14996d962bac 100644
--- a/include/asm-x86_64/pda.h
+++ b/include/asm-x86_64/pda.h
@@ -9,20 +9,24 @@
9 9
10/* Per processor datastructure. %gs points to it while the kernel runs */ 10/* Per processor datastructure. %gs points to it while the kernel runs */
11struct x8664_pda { 11struct x8664_pda {
12 struct task_struct *pcurrent; /* Current process */ 12 struct task_struct *pcurrent; /* 0 Current process */
13 unsigned long data_offset; /* Per cpu data offset from linker address */ 13 unsigned long data_offset; /* 8 Per cpu data offset from linker
14 unsigned long kernelstack; /* top of kernel stack for current */ 14 address */
15 unsigned long oldrsp; /* user rsp for system call */ 15 unsigned long kernelstack; /* 16 top of kernel stack for current */
16#if DEBUG_STKSZ > EXCEPTION_STKSZ 16 unsigned long oldrsp; /* 24 user rsp for system call */
17 unsigned long debugstack; /* #DB/#BP stack. */ 17 int irqcount; /* 32 Irq nesting counter. Starts with -1 */
18 int cpunumber; /* 36 Logical CPU number */
19#ifdef CONFIG_CC_STACKPROTECTOR
20 unsigned long stack_canary; /* 40 stack canary value */
21 /* gcc-ABI: this canary MUST be at
22 offset 40!!! */
18#endif 23#endif
19 int irqcount; /* Irq nesting counter. Starts with -1 */ 24 char *irqstackptr;
20 int cpunumber; /* Logical CPU number */
21 char *irqstackptr; /* top of irqstack */
22 int nodenumber; /* number of current node */ 25 int nodenumber; /* number of current node */
23 unsigned int __softirq_pending; 26 unsigned int __softirq_pending;
24 unsigned int __nmi_count; /* number of NMI on this CPUs */ 27 unsigned int __nmi_count; /* number of NMI on this CPUs */
25 int mmu_state; 28 short mmu_state;
29 short isidle;
26 struct mm_struct *active_mm; 30 struct mm_struct *active_mm;
27 unsigned apic_timer_irqs; 31 unsigned apic_timer_irqs;
28} ____cacheline_aligned_in_smp; 32} ____cacheline_aligned_in_smp;
@@ -36,44 +40,69 @@ extern struct x8664_pda boot_cpu_pda[];
36 * There is no fast way to get the base address of the PDA, all the accesses 40 * There is no fast way to get the base address of the PDA, all the accesses
37 * have to mention %fs/%gs. So it needs to be done this Torvaldian way. 41 * have to mention %fs/%gs. So it needs to be done this Torvaldian way.
38 */ 42 */
39#define sizeof_field(type,field) (sizeof(((type *)0)->field)) 43extern void __bad_pda_field(void) __attribute__((noreturn));
40#define typeof_field(type,field) typeof(((type *)0)->field)
41 44
42extern void __bad_pda_field(void); 45/*
46 * proxy_pda doesn't actually exist, but tell gcc it is accessed for
47 * all PDA accesses so it gets read/write dependencies right.
48 */
49extern struct x8664_pda _proxy_pda;
43 50
44#define pda_offset(field) offsetof(struct x8664_pda, field) 51#define pda_offset(field) offsetof(struct x8664_pda, field)
45 52
46#define pda_to_op(op,field,val) do { \ 53#define pda_to_op(op,field,val) do { \
47 typedef typeof_field(struct x8664_pda, field) T__; \ 54 typedef typeof(_proxy_pda.field) T__; \
48 switch (sizeof_field(struct x8664_pda, field)) { \ 55 if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \
49case 2: \ 56 switch (sizeof(_proxy_pda.field)) { \
50asm volatile(op "w %0,%%gs:%P1"::"ri" ((T__)val),"i"(pda_offset(field)):"memory"); break; \ 57 case 2: \
51case 4: \ 58 asm(op "w %1,%%gs:%c2" : \
52asm volatile(op "l %0,%%gs:%P1"::"ri" ((T__)val),"i"(pda_offset(field)):"memory"); break; \ 59 "+m" (_proxy_pda.field) : \
53case 8: \ 60 "ri" ((T__)val), \
54asm volatile(op "q %0,%%gs:%P1"::"ri" ((T__)val),"i"(pda_offset(field)):"memory"); break; \ 61 "i"(pda_offset(field))); \
55 default: __bad_pda_field(); \ 62 break; \
56 } \ 63 case 4: \
64 asm(op "l %1,%%gs:%c2" : \
65 "+m" (_proxy_pda.field) : \
66 "ri" ((T__)val), \
67 "i" (pda_offset(field))); \
68 break; \
69 case 8: \
70 asm(op "q %1,%%gs:%c2": \
71 "+m" (_proxy_pda.field) : \
72 "ri" ((T__)val), \
73 "i"(pda_offset(field))); \
74 break; \
75 default: \
76 __bad_pda_field(); \
77 } \
57 } while (0) 78 } while (0)
58 79
59/* 80#define pda_from_op(op,field) ({ \
60 * AK: PDA read accesses should be neither volatile nor have an memory clobber. 81 typeof(_proxy_pda.field) ret__; \
61 * Unfortunately removing them causes all hell to break lose currently. 82 switch (sizeof(_proxy_pda.field)) { \
62 */ 83 case 2: \
63#define pda_from_op(op,field) ({ \ 84 asm(op "w %%gs:%c1,%0" : \
64 typeof_field(struct x8664_pda, field) ret__; \ 85 "=r" (ret__) : \
65 switch (sizeof_field(struct x8664_pda, field)) { \ 86 "i" (pda_offset(field)), \
66case 2: \ 87 "m" (_proxy_pda.field)); \
67asm volatile(op "w %%gs:%P1,%0":"=r" (ret__):"i"(pda_offset(field)):"memory"); break;\ 88 break; \
68case 4: \ 89 case 4: \
69asm volatile(op "l %%gs:%P1,%0":"=r" (ret__):"i"(pda_offset(field)):"memory"); break;\ 90 asm(op "l %%gs:%c1,%0": \
70case 8: \ 91 "=r" (ret__): \
71asm volatile(op "q %%gs:%P1,%0":"=r" (ret__):"i"(pda_offset(field)):"memory"); break;\ 92 "i" (pda_offset(field)), \
72 default: __bad_pda_field(); \ 93 "m" (_proxy_pda.field)); \
73 } \ 94 break; \
95 case 8: \
96 asm(op "q %%gs:%c1,%0": \
97 "=r" (ret__) : \
98 "i" (pda_offset(field)), \
99 "m" (_proxy_pda.field)); \
100 break; \
101 default: \
102 __bad_pda_field(); \
103 } \
74 ret__; }) 104 ret__; })
75 105
76
77#define read_pda(field) pda_from_op("mov",field) 106#define read_pda(field) pda_from_op("mov",field)
78#define write_pda(field,val) pda_to_op("mov",field,val) 107#define write_pda(field,val) pda_to_op("mov",field,val)
79#define add_pda(field,val) pda_to_op("add",field,val) 108#define add_pda(field,val) pda_to_op("add",field,val)
diff --git a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
index bffb2f886a51..285756010c51 100644
--- a/include/asm-x86_64/percpu.h
+++ b/include/asm-x86_64/percpu.h
@@ -11,6 +11,16 @@
11 11
12#include <asm/pda.h> 12#include <asm/pda.h>
13 13
14#ifdef CONFIG_MODULES
15# define PERCPU_MODULE_RESERVE 8192
16#else
17# define PERCPU_MODULE_RESERVE 0
18#endif
19
20#define PERCPU_ENOUGH_ROOM \
21 (ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES) + \
22 PERCPU_MODULE_RESERVE)
23
14#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset) 24#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
15#define __my_cpu_offset() read_pda(data_offset) 25#define __my_cpu_offset() read_pda(data_offset)
16 26
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 51eba2395171..6899e770b173 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -21,12 +21,9 @@ extern unsigned long __supported_pte_mask;
21 21
22#define swapper_pg_dir init_level4_pgt 22#define swapper_pg_dir init_level4_pgt
23 23
24extern int nonx_setup(char *str);
25extern void paging_init(void); 24extern void paging_init(void);
26extern void clear_kernel_mapping(unsigned long addr, unsigned long size); 25extern void clear_kernel_mapping(unsigned long addr, unsigned long size);
27 26
28extern unsigned long pgkern_mask;
29
30/* 27/*
31 * ZERO_PAGE is a global shared page that is always zero: used 28 * ZERO_PAGE is a global shared page that is always zero: used
32 * for zero-mapped memory areas etc.. 29 * for zero-mapped memory areas etc..
@@ -265,7 +262,7 @@ static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
265#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT) 262#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
266static inline int pte_user(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 263static inline int pte_user(pte_t pte) { return pte_val(pte) & _PAGE_USER; }
267static inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 264static inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER; }
268static inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_USER; } 265static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); }
269static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; } 266static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
270static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; } 267static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
271static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; } 268static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
@@ -278,11 +275,12 @@ static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) &
278static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; } 275static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; }
279static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; } 276static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; }
280static inline pte_t pte_mkread(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; } 277static inline pte_t pte_mkread(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; }
281static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_USER)); return pte; } 278static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_NX)); return pte; }
282static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; } 279static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
283static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; } 280static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
284static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; } 281static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
285static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_PSE)); return pte; } 282static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_PSE)); return pte; }
283static inline pte_t pte_clrhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_PSE)); return pte; }
286 284
287struct vm_area_struct; 285struct vm_area_struct;
288 286
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index 038fe1f47e6f..c28fc2db2171 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -24,8 +24,6 @@ extern void mtrr_bp_init(void);
24#define mtrr_bp_init() do {} while (0) 24#define mtrr_bp_init() do {} while (0)
25#endif 25#endif
26extern void init_memory_mapping(unsigned long start, unsigned long end); 26extern void init_memory_mapping(unsigned long start, unsigned long end);
27extern void size_zones(unsigned long *z, unsigned long *h,
28 unsigned long start_pfn, unsigned long end_pfn);
29 27
30extern void system_call(void); 28extern void system_call(void);
31extern int kernel_syscall(void); 29extern int kernel_syscall(void);
@@ -51,10 +49,8 @@ extern unsigned long long monotonic_base;
51extern int sysctl_vsyscall; 49extern int sysctl_vsyscall;
52extern int nohpet; 50extern int nohpet;
53extern unsigned long vxtime_hz; 51extern unsigned long vxtime_hz;
52extern void time_init_gtod(void);
54 53
55extern int numa_setup(char *opt);
56
57extern int setup_early_printk(char *);
58extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2))); 54extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
59 55
60extern void early_identify_cpu(struct cpuinfo_x86 *c); 56extern void early_identify_cpu(struct cpuinfo_x86 *c);
@@ -91,7 +87,7 @@ extern void syscall32_cpu_init(void);
91 87
92extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end); 88extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end);
93 89
94extern void check_ioapic(void); 90extern void early_quirks(void);
95extern void check_efer(void); 91extern void check_efer(void);
96 92
97extern int unhandled_signal(struct task_struct *tsk, int sig); 93extern int unhandled_signal(struct task_struct *tsk, int sig);
@@ -103,13 +99,7 @@ extern void select_idle_routine(const struct cpuinfo_x86 *c);
103extern unsigned long table_start, table_end; 99extern unsigned long table_start, table_end;
104 100
105extern int exception_trace; 101extern int exception_trace;
106extern int using_apic_timer;
107extern int disable_apic;
108extern unsigned cpu_khz; 102extern unsigned cpu_khz;
109extern int ioapic_force;
110extern int skip_ioapic_setup;
111extern int acpi_ht;
112extern int acpi_disabled;
113 103
114extern void no_iommu_init(void); 104extern void no_iommu_init(void);
115extern int force_iommu, no_iommu; 105extern int force_iommu, no_iommu;
@@ -131,7 +121,8 @@ extern int fix_aperture;
131 121
132extern int reboot_force; 122extern int reboot_force;
133extern int notsc_setup(char *); 123extern int notsc_setup(char *);
134extern int setup_additional_cpus(char *); 124
125extern int gsi_irq_sharing(int gsi);
135 126
136extern void smp_local_timer_interrupt(struct pt_regs * regs); 127extern void smp_local_timer_interrupt(struct pt_regs * regs);
137 128
diff --git a/include/asm-x86_64/rwlock.h b/include/asm-x86_64/rwlock.h
index dea0e9459264..72aeebed920b 100644
--- a/include/asm-x86_64/rwlock.h
+++ b/include/asm-x86_64/rwlock.h
@@ -18,69 +18,9 @@
18#ifndef _ASM_X86_64_RWLOCK_H 18#ifndef _ASM_X86_64_RWLOCK_H
19#define _ASM_X86_64_RWLOCK_H 19#define _ASM_X86_64_RWLOCK_H
20 20
21#include <linux/stringify.h>
22
23#define RW_LOCK_BIAS 0x01000000 21#define RW_LOCK_BIAS 0x01000000
24#define RW_LOCK_BIAS_STR "0x01000000" 22#define RW_LOCK_BIAS_STR "0x01000000"
25
26#define __build_read_lock_ptr(rw, helper) \
27 asm volatile(LOCK_PREFIX "subl $1,(%0)\n\t" \
28 "js 2f\n" \
29 "1:\n" \
30 LOCK_SECTION_START("") \
31 "2:\tcall " helper "\n\t" \
32 "jmp 1b\n" \
33 LOCK_SECTION_END \
34 ::"a" (rw) : "memory")
35
36#define __build_read_lock_const(rw, helper) \
37 asm volatile(LOCK_PREFIX "subl $1,%0\n\t" \
38 "js 2f\n" \
39 "1:\n" \
40 LOCK_SECTION_START("") \
41 "2:\tpushq %%rax\n\t" \
42 "leaq %0,%%rax\n\t" \
43 "call " helper "\n\t" \
44 "popq %%rax\n\t" \
45 "jmp 1b\n" \
46 LOCK_SECTION_END \
47 :"=m" (*((volatile int *)rw))::"memory")
48
49#define __build_read_lock(rw, helper) do { \
50 if (__builtin_constant_p(rw)) \
51 __build_read_lock_const(rw, helper); \
52 else \
53 __build_read_lock_ptr(rw, helper); \
54 } while (0)
55
56#define __build_write_lock_ptr(rw, helper) \
57 asm volatile(LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
58 "jnz 2f\n" \
59 "1:\n" \
60 LOCK_SECTION_START("") \
61 "2:\tcall " helper "\n\t" \
62 "jmp 1b\n" \
63 LOCK_SECTION_END \
64 ::"a" (rw) : "memory")
65
66#define __build_write_lock_const(rw, helper) \
67 asm volatile(LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
68 "jnz 2f\n" \
69 "1:\n" \
70 LOCK_SECTION_START("") \
71 "2:\tpushq %%rax\n\t" \
72 "leaq %0,%%rax\n\t" \
73 "call " helper "\n\t" \
74 "popq %%rax\n\t" \
75 "jmp 1b\n" \
76 LOCK_SECTION_END \
77 :"=m" (*((volatile long *)rw))::"memory")
78 23
79#define __build_write_lock(rw, helper) do { \ 24/* Actual code is in asm/spinlock.h or in arch/x86_64/lib/rwlock.S */
80 if (__builtin_constant_p(rw)) \
81 __build_write_lock_const(rw, helper); \
82 else \
83 __build_write_lock_ptr(rw, helper); \
84 } while (0)
85 25
86#endif 26#endif
diff --git a/include/asm-x86_64/segment.h b/include/asm-x86_64/segment.h
index d4bed33fb32c..334ddcdd8f92 100644
--- a/include/asm-x86_64/segment.h
+++ b/include/asm-x86_64/segment.h
@@ -20,15 +20,16 @@
20#define __USER_CS 0x33 /* 6*8+3 */ 20#define __USER_CS 0x33 /* 6*8+3 */
21#define __USER32_DS __USER_DS 21#define __USER32_DS __USER_DS
22 22
23#define GDT_ENTRY_TLS 1
24#define GDT_ENTRY_TSS 8 /* needs two entries */ 23#define GDT_ENTRY_TSS 8 /* needs two entries */
25#define GDT_ENTRY_LDT 10 /* needs two entries */ 24#define GDT_ENTRY_LDT 10 /* needs two entries */
26#define GDT_ENTRY_TLS_MIN 12 25#define GDT_ENTRY_TLS_MIN 12
27#define GDT_ENTRY_TLS_MAX 14 26#define GDT_ENTRY_TLS_MAX 14
28/* 15 free */
29 27
30#define GDT_ENTRY_TLS_ENTRIES 3 28#define GDT_ENTRY_TLS_ENTRIES 3
31 29
30#define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
31#define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
32
32/* TLS indexes for 64bit - hardcoded in arch_prctl */ 33/* TLS indexes for 64bit - hardcoded in arch_prctl */
33#define FS_TLS 0 34#define FS_TLS 0
34#define GS_TLS 1 35#define GS_TLS 1
diff --git a/include/asm-x86_64/semaphore.h b/include/asm-x86_64/semaphore.h
index 064df08b9a0f..107bd90429e8 100644
--- a/include/asm-x86_64/semaphore.h
+++ b/include/asm-x86_64/semaphore.h
@@ -107,12 +107,9 @@ static inline void down(struct semaphore * sem)
107 __asm__ __volatile__( 107 __asm__ __volatile__(
108 "# atomic down operation\n\t" 108 "# atomic down operation\n\t"
109 LOCK_PREFIX "decl %0\n\t" /* --sem->count */ 109 LOCK_PREFIX "decl %0\n\t" /* --sem->count */
110 "js 2f\n" 110 "jns 1f\n\t"
111 "1:\n" 111 "call __down_failed\n"
112 LOCK_SECTION_START("") 112 "1:"
113 "2:\tcall __down_failed\n\t"
114 "jmp 1b\n"
115 LOCK_SECTION_END
116 :"=m" (sem->count) 113 :"=m" (sem->count)
117 :"D" (sem) 114 :"D" (sem)
118 :"memory"); 115 :"memory");
@@ -130,14 +127,11 @@ static inline int down_interruptible(struct semaphore * sem)
130 127
131 __asm__ __volatile__( 128 __asm__ __volatile__(
132 "# atomic interruptible down operation\n\t" 129 "# atomic interruptible down operation\n\t"
130 "xorl %0,%0\n\t"
133 LOCK_PREFIX "decl %1\n\t" /* --sem->count */ 131 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
134 "js 2f\n\t" 132 "jns 2f\n\t"
135 "xorl %0,%0\n" 133 "call __down_failed_interruptible\n"
136 "1:\n" 134 "2:\n"
137 LOCK_SECTION_START("")
138 "2:\tcall __down_failed_interruptible\n\t"
139 "jmp 1b\n"
140 LOCK_SECTION_END
141 :"=a" (result), "=m" (sem->count) 135 :"=a" (result), "=m" (sem->count)
142 :"D" (sem) 136 :"D" (sem)
143 :"memory"); 137 :"memory");
@@ -154,14 +148,11 @@ static inline int down_trylock(struct semaphore * sem)
154 148
155 __asm__ __volatile__( 149 __asm__ __volatile__(
156 "# atomic interruptible down operation\n\t" 150 "# atomic interruptible down operation\n\t"
151 "xorl %0,%0\n\t"
157 LOCK_PREFIX "decl %1\n\t" /* --sem->count */ 152 LOCK_PREFIX "decl %1\n\t" /* --sem->count */
158 "js 2f\n\t" 153 "jns 2f\n\t"
159 "xorl %0,%0\n" 154 "call __down_failed_trylock\n\t"
160 "1:\n" 155 "2:\n"
161 LOCK_SECTION_START("")
162 "2:\tcall __down_failed_trylock\n\t"
163 "jmp 1b\n"
164 LOCK_SECTION_END
165 :"=a" (result), "=m" (sem->count) 156 :"=a" (result), "=m" (sem->count)
166 :"D" (sem) 157 :"D" (sem)
167 :"memory","cc"); 158 :"memory","cc");
@@ -179,12 +170,9 @@ static inline void up(struct semaphore * sem)
179 __asm__ __volatile__( 170 __asm__ __volatile__(
180 "# atomic up operation\n\t" 171 "# atomic up operation\n\t"
181 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */ 172 LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
182 "jle 2f\n" 173 "jg 1f\n\t"
183 "1:\n" 174 "call __up_wakeup\n"
184 LOCK_SECTION_START("") 175 "1:"
185 "2:\tcall __up_wakeup\n\t"
186 "jmp 1b\n"
187 LOCK_SECTION_END
188 :"=m" (sem->count) 176 :"=m" (sem->count)
189 :"D" (sem) 177 :"D" (sem)
190 :"memory"); 178 :"memory");
diff --git a/include/asm-x86_64/signal.h b/include/asm-x86_64/signal.h
index 3ede2a61973a..4581f978b299 100644
--- a/include/asm-x86_64/signal.h
+++ b/include/asm-x86_64/signal.h
@@ -24,10 +24,6 @@ typedef struct {
24} sigset_t; 24} sigset_t;
25 25
26 26
27struct pt_regs;
28asmlinkage int do_signal(struct pt_regs *regs, sigset_t *oldset);
29
30
31#else 27#else
32/* Here we must cater to libcs that poke about in kernel headers. */ 28/* Here we must cater to libcs that poke about in kernel headers. */
33 29
diff --git a/include/asm-x86_64/smp.h b/include/asm-x86_64/smp.h
index ce97f65e1d10..d6b7c057edba 100644
--- a/include/asm-x86_64/smp.h
+++ b/include/asm-x86_64/smp.h
@@ -4,27 +4,18 @@
4/* 4/*
5 * We need the APIC definitions automatically as part of 'smp.h' 5 * We need the APIC definitions automatically as part of 'smp.h'
6 */ 6 */
7#ifndef __ASSEMBLY__
8#include <linux/threads.h> 7#include <linux/threads.h>
9#include <linux/cpumask.h> 8#include <linux/cpumask.h>
10#include <linux/bitops.h> 9#include <linux/bitops.h>
11extern int disable_apic; 10extern int disable_apic;
12#endif
13 11
14#ifdef CONFIG_X86_LOCAL_APIC
15#ifndef __ASSEMBLY__
16#include <asm/fixmap.h> 12#include <asm/fixmap.h>
17#include <asm/mpspec.h> 13#include <asm/mpspec.h>
18#ifdef CONFIG_X86_IO_APIC
19#include <asm/io_apic.h> 14#include <asm/io_apic.h>
20#endif
21#include <asm/apic.h> 15#include <asm/apic.h>
22#include <asm/thread_info.h> 16#include <asm/thread_info.h>
23#endif
24#endif
25 17
26#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
27#ifndef ASSEMBLY
28 19
29#include <asm/pda.h> 20#include <asm/pda.h>
30 21
@@ -42,7 +33,6 @@ extern cpumask_t cpu_initialized;
42 33
43extern void smp_alloc_memory(void); 34extern void smp_alloc_memory(void);
44extern volatile unsigned long smp_invalidate_needed; 35extern volatile unsigned long smp_invalidate_needed;
45extern int pic_mode;
46extern void lock_ipi_call_lock(void); 36extern void lock_ipi_call_lock(void);
47extern void unlock_ipi_call_lock(void); 37extern void unlock_ipi_call_lock(void);
48extern int smp_num_siblings; 38extern int smp_num_siblings;
@@ -74,20 +64,16 @@ static inline int hard_smp_processor_id(void)
74 return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID)); 64 return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID));
75} 65}
76 66
77extern int safe_smp_processor_id(void);
78extern int __cpu_disable(void); 67extern int __cpu_disable(void);
79extern void __cpu_die(unsigned int cpu); 68extern void __cpu_die(unsigned int cpu);
80extern void prefill_possible_map(void); 69extern void prefill_possible_map(void);
81extern unsigned num_processors; 70extern unsigned num_processors;
82extern unsigned disabled_cpus; 71extern unsigned disabled_cpus;
83 72
84#endif /* !ASSEMBLY */
85
86#define NO_PROC_ID 0xFF /* No processor magic marker */ 73#define NO_PROC_ID 0xFF /* No processor magic marker */
87 74
88#endif 75#endif
89 76
90#ifndef ASSEMBLY
91/* 77/*
92 * Some lowlevel functions might want to know about 78 * Some lowlevel functions might want to know about
93 * the real APIC ID <-> CPU # mapping. 79 * the real APIC ID <-> CPU # mapping.
@@ -109,11 +95,8 @@ static inline int cpu_present_to_apicid(int mps_cpu)
109 return BAD_APICID; 95 return BAD_APICID;
110} 96}
111 97
112#endif /* !ASSEMBLY */
113
114#ifndef CONFIG_SMP 98#ifndef CONFIG_SMP
115#define stack_smp_processor_id() 0 99#define stack_smp_processor_id() 0
116#define safe_smp_processor_id() 0
117#define cpu_logical_map(x) (x) 100#define cpu_logical_map(x) (x)
118#else 101#else
119#include <asm/thread_info.h> 102#include <asm/thread_info.h>
@@ -125,19 +108,23 @@ static inline int cpu_present_to_apicid(int mps_cpu)
125}) 108})
126#endif 109#endif
127 110
128#ifndef __ASSEMBLY__
129static __inline int logical_smp_processor_id(void) 111static __inline int logical_smp_processor_id(void)
130{ 112{
131 /* we don't want to mark this access volatile - bad code generation */ 113 /* we don't want to mark this access volatile - bad code generation */
132 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR)); 114 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
133} 115}
134#endif
135 116
136#ifdef CONFIG_SMP 117#ifdef CONFIG_SMP
137#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu] 118#define cpu_physical_id(cpu) x86_cpu_to_apicid[cpu]
138#else 119#else
139#define cpu_physical_id(cpu) boot_cpu_id 120#define cpu_physical_id(cpu) boot_cpu_id
140#endif 121static inline int smp_call_function_single(int cpuid, void (*func) (void *info),
141 122 void *info, int retry, int wait)
123{
124 /* Disable interrupts here? */
125 func(info);
126 return 0;
127}
128#endif /* !CONFIG_SMP */
142#endif 129#endif
143 130
diff --git a/include/asm-x86_64/spinlock.h b/include/asm-x86_64/spinlock.h
index 248a79f0eaff..3daf5b005905 100644
--- a/include/asm-x86_64/spinlock.h
+++ b/include/asm-x86_64/spinlock.h
@@ -4,6 +4,7 @@
4#include <asm/atomic.h> 4#include <asm/atomic.h>
5#include <asm/rwlock.h> 5#include <asm/rwlock.h>
6#include <asm/page.h> 6#include <asm/page.h>
7#include <asm/processor.h>
7 8
8/* 9/*
9 * Your basic SMP spinlocks, allowing only a single CPU anywhere 10 * Your basic SMP spinlocks, allowing only a single CPU anywhere
@@ -16,31 +17,23 @@
16 * (the type definitions are in asm/spinlock_types.h) 17 * (the type definitions are in asm/spinlock_types.h)
17 */ 18 */
18 19
19#define __raw_spin_is_locked(x) \ 20static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
20 (*(volatile signed int *)(&(x)->slock) <= 0) 21{
21 22 return *(volatile signed int *)(&(lock)->slock) <= 0;
22#define __raw_spin_lock_string \ 23}
23 "\n1:\t" \
24 LOCK_PREFIX " ; decl %0\n\t" \
25 "js 2f\n" \
26 LOCK_SECTION_START("") \
27 "2:\t" \
28 "rep;nop\n\t" \
29 "cmpl $0,%0\n\t" \
30 "jle 2b\n\t" \
31 "jmp 1b\n" \
32 LOCK_SECTION_END
33
34#define __raw_spin_lock_string_up \
35 "\n\tdecl %0"
36
37#define __raw_spin_unlock_string \
38 "movl $1,%0" \
39 :"=m" (lock->slock) : : "memory"
40 24
41static inline void __raw_spin_lock(raw_spinlock_t *lock) 25static inline void __raw_spin_lock(raw_spinlock_t *lock)
42{ 26{
43 asm volatile(__raw_spin_lock_string : "=m" (lock->slock) : : "memory"); 27 asm volatile(
28 "\n1:\t"
29 LOCK_PREFIX " ; decl %0\n\t"
30 "jns 2f\n"
31 "3:\n"
32 "rep;nop\n\t"
33 "cmpl $0,%0\n\t"
34 "jle 3b\n\t"
35 "jmp 1b\n"
36 "2:\t" : "=m" (lock->slock) : : "memory");
44} 37}
45 38
46#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock) 39#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
@@ -49,7 +42,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
49{ 42{
50 int oldval; 43 int oldval;
51 44
52 __asm__ __volatile__( 45 asm volatile(
53 "xchgl %0,%1" 46 "xchgl %0,%1"
54 :"=q" (oldval), "=m" (lock->slock) 47 :"=q" (oldval), "=m" (lock->slock)
55 :"0" (0) : "memory"); 48 :"0" (0) : "memory");
@@ -59,13 +52,14 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)
59 52
60static inline void __raw_spin_unlock(raw_spinlock_t *lock) 53static inline void __raw_spin_unlock(raw_spinlock_t *lock)
61{ 54{
62 __asm__ __volatile__( 55 asm volatile("movl $1,%0" :"=m" (lock->slock) :: "memory");
63 __raw_spin_unlock_string
64 );
65} 56}
66 57
67#define __raw_spin_unlock_wait(lock) \ 58static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
68 do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0) 59{
60 while (__raw_spin_is_locked(lock))
61 cpu_relax();
62}
69 63
70/* 64/*
71 * Read-write spinlocks, allowing multiple readers 65 * Read-write spinlocks, allowing multiple readers
@@ -79,26 +73,34 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
79 * 73 *
80 * On x86, we implement read-write locks as a 32-bit counter 74 * On x86, we implement read-write locks as a 32-bit counter
81 * with the high bit (sign) being the "contended" bit. 75 * with the high bit (sign) being the "contended" bit.
82 *
83 * The inline assembly is non-obvious. Think about it.
84 *
85 * Changed to use the same technique as rw semaphores. See
86 * semaphore.h for details. -ben
87 *
88 * the helpers are in arch/i386/kernel/semaphore.c
89 */ 76 */
90 77
91#define __raw_read_can_lock(x) ((int)(x)->lock > 0) 78static inline int __raw_read_can_lock(raw_rwlock_t *lock)
92#define __raw_write_can_lock(x) ((x)->lock == RW_LOCK_BIAS) 79{
80 return (int)(lock)->lock > 0;
81}
82
83static inline int __raw_write_can_lock(raw_rwlock_t *lock)
84{
85 return (lock)->lock == RW_LOCK_BIAS;
86}
93 87
94static inline void __raw_read_lock(raw_rwlock_t *rw) 88static inline void __raw_read_lock(raw_rwlock_t *rw)
95{ 89{
96 __build_read_lock(rw, "__read_lock_failed"); 90 asm volatile(LOCK_PREFIX "subl $1,(%0)\n\t"
91 "jns 1f\n"
92 "call __read_lock_failed\n"
93 "1:\n"
94 ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory");
97} 95}
98 96
99static inline void __raw_write_lock(raw_rwlock_t *rw) 97static inline void __raw_write_lock(raw_rwlock_t *rw)
100{ 98{
101 __build_write_lock(rw, "__write_lock_failed"); 99 asm volatile(LOCK_PREFIX "subl %1,(%0)\n\t"
100 "jz 1f\n"
101 "\tcall __write_lock_failed\n\t"
102 "1:\n"
103 ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory");
102} 104}
103 105
104static inline int __raw_read_trylock(raw_rwlock_t *lock) 106static inline int __raw_read_trylock(raw_rwlock_t *lock)
diff --git a/include/asm-x86_64/stacktrace.h b/include/asm-x86_64/stacktrace.h
new file mode 100644
index 000000000000..5eb9799bef76
--- /dev/null
+++ b/include/asm-x86_64/stacktrace.h
@@ -0,0 +1,18 @@
1#ifndef _ASM_STACKTRACE_H
2#define _ASM_STACKTRACE_H 1
3
4/* Generic stack tracer with callbacks */
5
6struct stacktrace_ops {
7 void (*warning)(void *data, char *msg);
8 /* msg must contain %s for the symbol */
9 void (*warning_symbol)(void *data, char *msg, unsigned long symbol);
10 void (*address)(void *data, unsigned long address);
11 /* On negative return stop dumping */
12 int (*stack)(void *data, char *name);
13};
14
15void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack,
16 struct stacktrace_ops *ops, void *data);
17
18#endif
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index 6bf170bceae1..bd376bc8c4ab 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -14,12 +14,13 @@
14#define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t" 14#define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
15 15
16/* frame pointer must be last for get_wchan */ 16/* frame pointer must be last for get_wchan */
17#define SAVE_CONTEXT "pushq %%rbp ; movq %%rsi,%%rbp\n\t" 17#define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
18#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp\n\t" 18#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
19 19
20#define __EXTRA_CLOBBER \ 20#define __EXTRA_CLOBBER \
21 ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15" 21 ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
22 22
23/* Save restore flags to clear handle leaking NT */
23#define switch_to(prev,next,last) \ 24#define switch_to(prev,next,last) \
24 asm volatile(SAVE_CONTEXT \ 25 asm volatile(SAVE_CONTEXT \
25 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ 26 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
diff --git a/include/asm-x86_64/tce.h b/include/asm-x86_64/tce.h
index 53e9a68b3336..dbb047febc5e 100644
--- a/include/asm-x86_64/tce.h
+++ b/include/asm-x86_64/tce.h
@@ -24,7 +24,6 @@
24#ifndef _ASM_X86_64_TCE_H 24#ifndef _ASM_X86_64_TCE_H
25#define _ASM_X86_64_TCE_H 25#define _ASM_X86_64_TCE_H
26 26
27extern void* tce_table_kva[];
28extern unsigned int specified_table_size; 27extern unsigned int specified_table_size;
29struct iommu_table; 28struct iommu_table;
30 29
diff --git a/include/asm-x86_64/therm_throt.h b/include/asm-x86_64/therm_throt.h
new file mode 100644
index 000000000000..5aac059007ba
--- /dev/null
+++ b/include/asm-x86_64/therm_throt.h
@@ -0,0 +1 @@
#include <asm-i386/therm_throt.h>
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 2029b00351f3..787a08114b48 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -114,11 +114,14 @@ static inline struct thread_info *stack_thread_info(void)
114#define TIF_IRET 5 /* force IRET */ 114#define TIF_IRET 5 /* force IRET */
115#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 115#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
116#define TIF_SECCOMP 8 /* secure computing */ 116#define TIF_SECCOMP 8 /* secure computing */
117#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
117/* 16 free */ 118/* 16 free */
118#define TIF_IA32 17 /* 32bit process */ 119#define TIF_IA32 17 /* 32bit process */
119#define TIF_FORK 18 /* ret_from_fork */ 120#define TIF_FORK 18 /* ret_from_fork */
120#define TIF_ABI_PENDING 19 121#define TIF_ABI_PENDING 19
121#define TIF_MEMDIE 20 122#define TIF_MEMDIE 20
123#define TIF_DEBUG 21 /* uses debug registers */
124#define TIF_IO_BITMAP 22 /* uses I/O bitmap */
122 125
123#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 126#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
124#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 127#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
@@ -128,9 +131,12 @@ static inline struct thread_info *stack_thread_info(void)
128#define _TIF_IRET (1<<TIF_IRET) 131#define _TIF_IRET (1<<TIF_IRET)
129#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 132#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
130#define _TIF_SECCOMP (1<<TIF_SECCOMP) 133#define _TIF_SECCOMP (1<<TIF_SECCOMP)
134#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
131#define _TIF_IA32 (1<<TIF_IA32) 135#define _TIF_IA32 (1<<TIF_IA32)
132#define _TIF_FORK (1<<TIF_FORK) 136#define _TIF_FORK (1<<TIF_FORK)
133#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 137#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
138#define _TIF_DEBUG (1<<TIF_DEBUG)
139#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP)
134 140
135/* work to do on interrupt/exception return */ 141/* work to do on interrupt/exception return */
136#define _TIF_WORK_MASK \ 142#define _TIF_WORK_MASK \
@@ -138,6 +144,9 @@ static inline struct thread_info *stack_thread_info(void)
138/* work to do on any return to user space */ 144/* work to do on any return to user space */
139#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) 145#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP)
140 146
147/* flags to check in __switch_to() */
148#define _TIF_WORK_CTXSW (_TIF_DEBUG|_TIF_IO_BITMAP)
149
141#define PREEMPT_ACTIVE 0x10000000 150#define PREEMPT_ACTIVE 0x10000000
142 151
143/* 152/*
diff --git a/include/asm-x86_64/tlbflush.h b/include/asm-x86_64/tlbflush.h
index d16d5b60f419..983bd296c81a 100644
--- a/include/asm-x86_64/tlbflush.h
+++ b/include/asm-x86_64/tlbflush.h
@@ -4,44 +4,44 @@
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <asm/processor.h> 5#include <asm/processor.h>
6 6
7#define __flush_tlb() \ 7static inline unsigned long get_cr3(void)
8 do { \ 8{
9 unsigned long tmpreg; \ 9 unsigned long cr3;
10 \ 10 asm volatile("mov %%cr3,%0" : "=r" (cr3));
11 __asm__ __volatile__( \ 11 return cr3;
12 "movq %%cr3, %0; # flush TLB \n" \ 12}
13 "movq %0, %%cr3; \n" \
14 : "=r" (tmpreg) \
15 :: "memory"); \
16 } while (0)
17 13
18/* 14static inline void set_cr3(unsigned long cr3)
19 * Global pages have to be flushed a bit differently. Not a real 15{
20 * performance problem because this does not happen often. 16 asm volatile("mov %0,%%cr3" :: "r" (cr3) : "memory");
21 */ 17}
22#define __flush_tlb_global() \ 18
23 do { \ 19static inline void __flush_tlb(void)
24 unsigned long tmpreg, cr4, cr4_orig; \ 20{
25 \ 21 set_cr3(get_cr3());
26 __asm__ __volatile__( \ 22}
27 "movq %%cr4, %2; # turn off PGE \n" \ 23
28 "movq %2, %1; \n" \ 24static inline unsigned long get_cr4(void)
29 "andq %3, %1; \n" \ 25{
30 "movq %1, %%cr4; \n" \ 26 unsigned long cr4;
31 "movq %%cr3, %0; # flush TLB \n" \ 27 asm volatile("mov %%cr4,%0" : "=r" (cr4));
32 "movq %0, %%cr3; \n" \ 28 return cr4;
33 "movq %2, %%cr4; # turn PGE back on \n" \ 29}
34 : "=&r" (tmpreg), "=&r" (cr4), "=&r" (cr4_orig) \ 30
35 : "i" (~X86_CR4_PGE) \ 31static inline void set_cr4(unsigned long cr4)
36 : "memory"); \ 32{
37 } while (0) 33 asm volatile("mov %0,%%cr4" :: "r" (cr4) : "memory");
38 34}
39extern unsigned long pgkern_mask; 35
40 36static inline void __flush_tlb_all(void)
41#define __flush_tlb_all() __flush_tlb_global() 37{
38 unsigned long cr4 = get_cr4();
39 set_cr4(cr4 & ~X86_CR4_PGE); /* clear PGE */
40 set_cr4(cr4); /* write old PGE again and flush TLBs */
41}
42 42
43#define __flush_tlb_one(addr) \ 43#define __flush_tlb_one(addr) \
44 __asm__ __volatile__("invlpg %0": :"m" (*(char *) addr)) 44 __asm__ __volatile__("invlpg (%0)" :: "r" (addr) : "memory")
45 45
46 46
47/* 47/*
diff --git a/include/asm-x86_64/uaccess.h b/include/asm-x86_64/uaccess.h
index 1e1fa003daa3..e856570c0689 100644
--- a/include/asm-x86_64/uaccess.h
+++ b/include/asm-x86_64/uaccess.h
@@ -84,7 +84,7 @@ struct exception_table_entry
84 */ 84 */
85 85
86#define __get_user_x(size,ret,x,ptr) \ 86#define __get_user_x(size,ret,x,ptr) \
87 __asm__ __volatile__("call __get_user_" #size \ 87 asm volatile("call __get_user_" #size \
88 :"=a" (ret),"=d" (x) \ 88 :"=a" (ret),"=d" (x) \
89 :"c" (ptr) \ 89 :"c" (ptr) \
90 :"r8") 90 :"r8")
@@ -101,7 +101,7 @@ struct exception_table_entry
101 case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \ 101 case 8: __get_user_x(8,__ret_gu,__val_gu,ptr); break; \
102 default: __get_user_bad(); break; \ 102 default: __get_user_bad(); break; \
103 } \ 103 } \
104 (x) = (__typeof__(*(ptr)))__val_gu; \ 104 (x) = (typeof(*(ptr)))__val_gu; \
105 __ret_gu; \ 105 __ret_gu; \
106}) 106})
107 107
@@ -112,7 +112,7 @@ extern void __put_user_8(void);
112extern void __put_user_bad(void); 112extern void __put_user_bad(void);
113 113
114#define __put_user_x(size,ret,x,ptr) \ 114#define __put_user_x(size,ret,x,ptr) \
115 __asm__ __volatile__("call __put_user_" #size \ 115 asm volatile("call __put_user_" #size \
116 :"=a" (ret) \ 116 :"=a" (ret) \
117 :"c" (ptr),"d" (x) \ 117 :"c" (ptr),"d" (x) \
118 :"r8") 118 :"r8")
@@ -139,7 +139,7 @@ extern void __put_user_bad(void);
139#define __put_user_check(x,ptr,size) \ 139#define __put_user_check(x,ptr,size) \
140({ \ 140({ \
141 int __pu_err; \ 141 int __pu_err; \
142 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 142 typeof(*(ptr)) __user *__pu_addr = (ptr); \
143 switch (size) { \ 143 switch (size) { \
144 case 1: __put_user_x(1,__pu_err,x,__pu_addr); break; \ 144 case 1: __put_user_x(1,__pu_err,x,__pu_addr); break; \
145 case 2: __put_user_x(2,__pu_err,x,__pu_addr); break; \ 145 case 2: __put_user_x(2,__pu_err,x,__pu_addr); break; \
@@ -173,7 +173,7 @@ struct __large_struct { unsigned long buf[100]; };
173 * aliasing issues. 173 * aliasing issues.
174 */ 174 */
175#define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \ 175#define __put_user_asm(x, addr, err, itype, rtype, ltype, errno) \
176 __asm__ __volatile__( \ 176 asm volatile( \
177 "1: mov"itype" %"rtype"1,%2\n" \ 177 "1: mov"itype" %"rtype"1,%2\n" \
178 "2:\n" \ 178 "2:\n" \
179 ".section .fixup,\"ax\"\n" \ 179 ".section .fixup,\"ax\"\n" \
@@ -193,7 +193,7 @@ struct __large_struct { unsigned long buf[100]; };
193 int __gu_err; \ 193 int __gu_err; \
194 unsigned long __gu_val; \ 194 unsigned long __gu_val; \
195 __get_user_size(__gu_val,(ptr),(size),__gu_err); \ 195 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
196 (x) = (__typeof__(*(ptr)))__gu_val; \ 196 (x) = (typeof(*(ptr)))__gu_val; \
197 __gu_err; \ 197 __gu_err; \
198}) 198})
199 199
@@ -217,7 +217,7 @@ do { \
217} while (0) 217} while (0)
218 218
219#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \ 219#define __get_user_asm(x, addr, err, itype, rtype, ltype, errno) \
220 __asm__ __volatile__( \ 220 asm volatile( \
221 "1: mov"itype" %2,%"rtype"1\n" \ 221 "1: mov"itype" %2,%"rtype"1\n" \
222 "2:\n" \ 222 "2:\n" \
223 ".section .fixup,\"ax\"\n" \ 223 ".section .fixup,\"ax\"\n" \
@@ -237,15 +237,20 @@ do { \
237 */ 237 */
238 238
239/* Handles exceptions in both to and from, but doesn't do access_ok */ 239/* Handles exceptions in both to and from, but doesn't do access_ok */
240extern unsigned long copy_user_generic(void *to, const void *from, unsigned len); 240__must_check unsigned long
241 241copy_user_generic(void *to, const void *from, unsigned len);
242extern unsigned long copy_to_user(void __user *to, const void *from, unsigned len); 242
243extern unsigned long copy_from_user(void *to, const void __user *from, unsigned len); 243__must_check unsigned long
244extern unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len); 244copy_to_user(void __user *to, const void *from, unsigned len);
245 245__must_check unsigned long
246static __always_inline int __copy_from_user(void *dst, const void __user *src, unsigned size) 246copy_from_user(void *to, const void __user *from, unsigned len);
247__must_check unsigned long
248copy_in_user(void __user *to, const void __user *from, unsigned len);
249
250static __always_inline __must_check
251int __copy_from_user(void *dst, const void __user *src, unsigned size)
247{ 252{
248 int ret = 0; 253 int ret = 0;
249 if (!__builtin_constant_p(size)) 254 if (!__builtin_constant_p(size))
250 return copy_user_generic(dst,(__force void *)src,size); 255 return copy_user_generic(dst,(__force void *)src,size);
251 switch (size) { 256 switch (size) {
@@ -272,9 +277,10 @@ static __always_inline int __copy_from_user(void *dst, const void __user *src, u
272 } 277 }
273} 278}
274 279
275static __always_inline int __copy_to_user(void __user *dst, const void *src, unsigned size) 280static __always_inline __must_check
281int __copy_to_user(void __user *dst, const void *src, unsigned size)
276{ 282{
277 int ret = 0; 283 int ret = 0;
278 if (!__builtin_constant_p(size)) 284 if (!__builtin_constant_p(size))
279 return copy_user_generic((__force void *)dst,src,size); 285 return copy_user_generic((__force void *)dst,src,size);
280 switch (size) { 286 switch (size) {
@@ -303,10 +309,10 @@ static __always_inline int __copy_to_user(void __user *dst, const void *src, uns
303 } 309 }
304} 310}
305 311
306 312static __always_inline __must_check
307static __always_inline int __copy_in_user(void __user *dst, const void __user *src, unsigned size) 313int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
308{ 314{
309 int ret = 0; 315 int ret = 0;
310 if (!__builtin_constant_p(size)) 316 if (!__builtin_constant_p(size))
311 return copy_user_generic((__force void *)dst,(__force void *)src,size); 317 return copy_user_generic((__force void *)dst,(__force void *)src,size);
312 switch (size) { 318 switch (size) {
@@ -344,15 +350,17 @@ static __always_inline int __copy_in_user(void __user *dst, const void __user *s
344 } 350 }
345} 351}
346 352
347long strncpy_from_user(char *dst, const char __user *src, long count); 353__must_check long
348long __strncpy_from_user(char *dst, const char __user *src, long count); 354strncpy_from_user(char *dst, const char __user *src, long count);
349long strnlen_user(const char __user *str, long n); 355__must_check long
350long __strnlen_user(const char __user *str, long n); 356__strncpy_from_user(char *dst, const char __user *src, long count);
351long strlen_user(const char __user *str); 357__must_check long strnlen_user(const char __user *str, long n);
352unsigned long clear_user(void __user *mem, unsigned long len); 358__must_check long __strnlen_user(const char __user *str, long n);
353unsigned long __clear_user(void __user *mem, unsigned long len); 359__must_check long strlen_user(const char __user *str);
354 360__must_check unsigned long clear_user(void __user *mem, unsigned long len);
355#define __copy_to_user_inatomic __copy_to_user 361__must_check unsigned long __clear_user(void __user *mem, unsigned long len);
356#define __copy_from_user_inatomic __copy_from_user 362
363__must_check long __copy_from_user_inatomic(void *dst, const void __user *src, unsigned size);
364#define __copy_to_user_inatomic copy_user_generic
357 365
358#endif /* __X86_64_UACCESS_H */ 366#endif /* __X86_64_UACCESS_H */
diff --git a/include/asm-x86_64/unistd.h b/include/asm-x86_64/unistd.h
index 80fd48e84bbb..6137146516d3 100644
--- a/include/asm-x86_64/unistd.h
+++ b/include/asm-x86_64/unistd.h
@@ -600,9 +600,9 @@ __SYSCALL(__NR_fchmodat, sys_fchmodat)
600#define __NR_faccessat 269 600#define __NR_faccessat 269
601__SYSCALL(__NR_faccessat, sys_faccessat) 601__SYSCALL(__NR_faccessat, sys_faccessat)
602#define __NR_pselect6 270 602#define __NR_pselect6 270
603__SYSCALL(__NR_pselect6, sys_ni_syscall) /* for now */ 603__SYSCALL(__NR_pselect6, sys_pselect6)
604#define __NR_ppoll 271 604#define __NR_ppoll 271
605__SYSCALL(__NR_ppoll, sys_ni_syscall) /* for now */ 605__SYSCALL(__NR_ppoll, sys_ppoll)
606#define __NR_unshare 272 606#define __NR_unshare 272
607__SYSCALL(__NR_unshare, sys_unshare) 607__SYSCALL(__NR_unshare, sys_unshare)
608#define __NR_set_robust_list 273 608#define __NR_set_robust_list 273
@@ -623,16 +623,17 @@ __SYSCALL(__NR_move_pages, sys_move_pages)
623#ifdef __KERNEL__ 623#ifdef __KERNEL__
624 624
625#define __NR_syscall_max __NR_move_pages 625#define __NR_syscall_max __NR_move_pages
626#include <linux/err.h>
626 627
627#ifndef __NO_STUBS 628#ifndef __NO_STUBS
628 629
629/* user-visible error numbers are in the range -1 - -4095 */ 630/* user-visible error numbers are in the range -1 - -MAX_ERRNO */
630 631
631#define __syscall_clobber "r11","rcx","memory" 632#define __syscall_clobber "r11","rcx","memory"
632 633
633#define __syscall_return(type, res) \ 634#define __syscall_return(type, res) \
634do { \ 635do { \
635 if ((unsigned long)(res) >= (unsigned long)(-127)) { \ 636 if ((unsigned long)(res) >= (unsigned long)(-MAX_ERRNO)) { \
636 errno = -(res); \ 637 errno = -(res); \
637 res = -1; \ 638 res = -1; \
638 } \ 639 } \
@@ -658,6 +659,7 @@ do { \
658#define __ARCH_WANT_SYS_SIGPENDING 659#define __ARCH_WANT_SYS_SIGPENDING
659#define __ARCH_WANT_SYS_SIGPROCMASK 660#define __ARCH_WANT_SYS_SIGPROCMASK
660#define __ARCH_WANT_SYS_RT_SIGACTION 661#define __ARCH_WANT_SYS_RT_SIGACTION
662#define __ARCH_WANT_SYS_RT_SIGSUSPEND
661#define __ARCH_WANT_SYS_TIME 663#define __ARCH_WANT_SYS_TIME
662#define __ARCH_WANT_COMPAT_SYS_TIME 664#define __ARCH_WANT_COMPAT_SYS_TIME
663 665
diff --git a/include/asm-x86_64/unwind.h b/include/asm-x86_64/unwind.h
index 1f6e9bfb569e..2e7ff10fd775 100644
--- a/include/asm-x86_64/unwind.h
+++ b/include/asm-x86_64/unwind.h
@@ -18,6 +18,7 @@ struct unwind_frame_info
18{ 18{
19 struct pt_regs regs; 19 struct pt_regs regs;
20 struct task_struct *task; 20 struct task_struct *task;
21 unsigned call_frame:1;
21}; 22};
22 23
23#define UNW_PC(frame) (frame)->regs.rip 24#define UNW_PC(frame) (frame)->regs.rip
@@ -57,6 +58,10 @@ struct unwind_frame_info
57 PTREGS_INFO(r15), \ 58 PTREGS_INFO(r15), \
58 PTREGS_INFO(rip) 59 PTREGS_INFO(rip)
59 60
61#define UNW_DEFAULT_RA(raItem, dataAlign) \
62 ((raItem).where == Memory && \
63 !((raItem).value * (dataAlign) + 8))
64
60static inline void arch_unw_init_frame_info(struct unwind_frame_info *info, 65static inline void arch_unw_init_frame_info(struct unwind_frame_info *info,
61 /*const*/ struct pt_regs *regs) 66 /*const*/ struct pt_regs *regs)
62{ 67{
@@ -94,8 +99,8 @@ static inline int arch_unw_user_mode(const struct unwind_frame_info *info)
94 99
95#else 100#else
96 101
97#define UNW_PC(frame) ((void)(frame), 0) 102#define UNW_PC(frame) ((void)(frame), 0UL)
98#define UNW_SP(frame) ((void)(frame), 0) 103#define UNW_SP(frame) ((void)(frame), 0UL)
99 104
100static inline int arch_unw_user_mode(const void *info) 105static inline int arch_unw_user_mode(const void *info)
101{ 106{
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index 146b24402a5f..2281e9399b96 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -4,6 +4,7 @@
4enum vsyscall_num { 4enum vsyscall_num {
5 __NR_vgettimeofday, 5 __NR_vgettimeofday,
6 __NR_vtime, 6 __NR_vtime,
7 __NR_vgetcpu,
7}; 8};
8 9
9#define VSYSCALL_START (-10UL << 20) 10#define VSYSCALL_START (-10UL << 20)
@@ -15,6 +16,7 @@ enum vsyscall_num {
15#include <linux/seqlock.h> 16#include <linux/seqlock.h>
16 17
17#define __section_vxtime __attribute__ ((unused, __section__ (".vxtime"), aligned(16))) 18#define __section_vxtime __attribute__ ((unused, __section__ (".vxtime"), aligned(16)))
19#define __section_vgetcpu_mode __attribute__ ((unused, __section__ (".vgetcpu_mode"), aligned(16)))
18#define __section_wall_jiffies __attribute__ ((unused, __section__ (".wall_jiffies"), aligned(16))) 20#define __section_wall_jiffies __attribute__ ((unused, __section__ (".wall_jiffies"), aligned(16)))
19#define __section_jiffies __attribute__ ((unused, __section__ (".jiffies"), aligned(16))) 21#define __section_jiffies __attribute__ ((unused, __section__ (".jiffies"), aligned(16)))
20#define __section_sys_tz __attribute__ ((unused, __section__ (".sys_tz"), aligned(16))) 22#define __section_sys_tz __attribute__ ((unused, __section__ (".sys_tz"), aligned(16)))
@@ -26,6 +28,9 @@ enum vsyscall_num {
26#define VXTIME_HPET 2 28#define VXTIME_HPET 2
27#define VXTIME_PMTMR 3 29#define VXTIME_PMTMR 3
28 30
31#define VGETCPU_RDTSCP 1
32#define VGETCPU_LSL 2
33
29struct vxtime_data { 34struct vxtime_data {
30 long hpet_address; /* HPET base address */ 35 long hpet_address; /* HPET base address */
31 int last; 36 int last;
@@ -40,6 +45,7 @@ struct vxtime_data {
40 45
41/* vsyscall space (readonly) */ 46/* vsyscall space (readonly) */
42extern struct vxtime_data __vxtime; 47extern struct vxtime_data __vxtime;
48extern int __vgetcpu_mode;
43extern struct timespec __xtime; 49extern struct timespec __xtime;
44extern volatile unsigned long __jiffies; 50extern volatile unsigned long __jiffies;
45extern unsigned long __wall_jiffies; 51extern unsigned long __wall_jiffies;
@@ -48,6 +54,7 @@ extern seqlock_t __xtime_lock;
48 54
49/* kernel space (writeable) */ 55/* kernel space (writeable) */
50extern struct vxtime_data vxtime; 56extern struct vxtime_data vxtime;
57extern int vgetcpu_mode;
51extern unsigned long wall_jiffies; 58extern unsigned long wall_jiffies;
52extern struct timezone sys_tz; 59extern struct timezone sys_tz;
53extern int sysctl_vsyscall; 60extern int sysctl_vsyscall;
@@ -55,6 +62,8 @@ extern seqlock_t xtime_lock;
55 62
56extern int sysctl_vsyscall; 63extern int sysctl_vsyscall;
57 64
65extern void vsyscall_set_cpu(int cpu);
66
58#define ARCH_HAVE_XTIME_LOCK 1 67#define ARCH_HAVE_XTIME_LOCK 1
59 68
60#endif /* __KERNEL__ */ 69#endif /* __KERNEL__ */
diff --git a/include/linux/aer.h b/include/linux/aer.h
new file mode 100644
index 000000000000..402e178b38eb
--- /dev/null
+++ b/include/linux/aer.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright (C) 2006 Intel Corp.
3 * Tom Long Nguyen (tom.l.nguyen@intel.com)
4 * Zhang Yanmin (yanmin.zhang@intel.com)
5 */
6
7#ifndef _AER_H_
8#define _AER_H_
9
10#if defined(CONFIG_PCIEAER)
11/* pci-e port driver needs this function to enable aer */
12extern int pci_enable_pcie_error_reporting(struct pci_dev *dev);
13extern int pci_find_aer_capability(struct pci_dev *dev);
14extern int pci_disable_pcie_error_reporting(struct pci_dev *dev);
15extern int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev);
16#else
17#define pci_enable_pcie_error_reporting(dev) do { } while (0)
18#define pci_find_aer_capability(dev) do { } while (0)
19#define pci_disable_pcie_error_reporting(dev) do { } while (0)
20#define pci_cleanup_aer_uncorrect_error_status(dev) do { } while (0)
21#endif
22
23#endif //_AER_H_
24
diff --git a/include/linux/cdev.h b/include/linux/cdev.h
index 2216638962d2..ee5f53f2ca15 100644
--- a/include/linux/cdev.h
+++ b/include/linux/cdev.h
@@ -23,5 +23,7 @@ void cdev_del(struct cdev *);
23 23
24void cd_forget(struct inode *); 24void cd_forget(struct inode *);
25 25
26extern struct backing_dev_info directly_mappable_cdev_bdi;
27
26#endif 28#endif
27#endif 29#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 9b4f11094937..060b96112ec6 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -99,6 +99,11 @@ extern void __chk_io_ptr(void __iomem *);
99#define __must_check 99#define __must_check
100#endif 100#endif
101 101
102#ifndef CONFIG_ENABLE_MUST_CHECK
103#undef __must_check
104#define __must_check
105#endif
106
102/* 107/*
103 * Allow us to avoid 'defined but not used' warnings on functions and data, 108 * Allow us to avoid 'defined but not used' warnings on functions and data,
104 * as well as force them to be emitted to the assembly file. 109 * as well as force them to be emitted to the assembly file.
diff --git a/include/linux/device.h b/include/linux/device.h
index 1e5f30da98bc..662e6a10144e 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -15,6 +15,7 @@
15#include <linux/kobject.h> 15#include <linux/kobject.h>
16#include <linux/klist.h> 16#include <linux/klist.h>
17#include <linux/list.h> 17#include <linux/list.h>
18#include <linux/compiler.h>
18#include <linux/types.h> 19#include <linux/types.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/pm.h> 21#include <linux/pm.h>
@@ -51,14 +52,17 @@ struct bus_type {
51 int (*probe)(struct device * dev); 52 int (*probe)(struct device * dev);
52 int (*remove)(struct device * dev); 53 int (*remove)(struct device * dev);
53 void (*shutdown)(struct device * dev); 54 void (*shutdown)(struct device * dev);
54 int (*suspend)(struct device * dev, pm_message_t state); 55
55 int (*resume)(struct device * dev); 56 int (*suspend)(struct device * dev, pm_message_t state);
57 int (*suspend_late)(struct device * dev, pm_message_t state);
58 int (*resume_early)(struct device * dev);
59 int (*resume)(struct device * dev);
56}; 60};
57 61
58extern int bus_register(struct bus_type * bus); 62extern int __must_check bus_register(struct bus_type * bus);
59extern void bus_unregister(struct bus_type * bus); 63extern void bus_unregister(struct bus_type * bus);
60 64
61extern void bus_rescan_devices(struct bus_type * bus); 65extern int __must_check bus_rescan_devices(struct bus_type * bus);
62 66
63/* iterator helpers for buses */ 67/* iterator helpers for buses */
64 68
@@ -67,9 +71,9 @@ int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data,
67struct device * bus_find_device(struct bus_type *bus, struct device *start, 71struct device * bus_find_device(struct bus_type *bus, struct device *start,
68 void *data, int (*match)(struct device *, void *)); 72 void *data, int (*match)(struct device *, void *));
69 73
70int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, 74int __must_check bus_for_each_drv(struct bus_type *bus,
71 void * data, int (*fn)(struct device_driver *, void *)); 75 struct device_driver *start, void *data,
72 76 int (*fn)(struct device_driver *, void *));
73 77
74/* driverfs interface for exporting bus attributes */ 78/* driverfs interface for exporting bus attributes */
75 79
@@ -82,7 +86,8 @@ struct bus_attribute {
82#define BUS_ATTR(_name,_mode,_show,_store) \ 86#define BUS_ATTR(_name,_mode,_show,_store) \
83struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) 87struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store)
84 88
85extern int bus_create_file(struct bus_type *, struct bus_attribute *); 89extern int __must_check bus_create_file(struct bus_type *,
90 struct bus_attribute *);
86extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 91extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
87 92
88struct device_driver { 93struct device_driver {
@@ -101,16 +106,18 @@ struct device_driver {
101 void (*shutdown) (struct device * dev); 106 void (*shutdown) (struct device * dev);
102 int (*suspend) (struct device * dev, pm_message_t state); 107 int (*suspend) (struct device * dev, pm_message_t state);
103 int (*resume) (struct device * dev); 108 int (*resume) (struct device * dev);
109
110 unsigned int multithread_probe:1;
104}; 111};
105 112
106 113
107extern int driver_register(struct device_driver * drv); 114extern int __must_check driver_register(struct device_driver * drv);
108extern void driver_unregister(struct device_driver * drv); 115extern void driver_unregister(struct device_driver * drv);
109 116
110extern struct device_driver * get_driver(struct device_driver * drv); 117extern struct device_driver * get_driver(struct device_driver * drv);
111extern void put_driver(struct device_driver * drv); 118extern void put_driver(struct device_driver * drv);
112extern struct device_driver *driver_find(const char *name, struct bus_type *bus); 119extern struct device_driver *driver_find(const char *name, struct bus_type *bus);
113 120extern int driver_probe_done(void);
114 121
115/* driverfs interface for exporting driver attributes */ 122/* driverfs interface for exporting driver attributes */
116 123
@@ -123,16 +130,17 @@ struct driver_attribute {
123#define DRIVER_ATTR(_name,_mode,_show,_store) \ 130#define DRIVER_ATTR(_name,_mode,_show,_store) \
124struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) 131struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store)
125 132
126extern int driver_create_file(struct device_driver *, struct driver_attribute *); 133extern int __must_check driver_create_file(struct device_driver *,
134 struct driver_attribute *);
127extern void driver_remove_file(struct device_driver *, struct driver_attribute *); 135extern void driver_remove_file(struct device_driver *, struct driver_attribute *);
128 136
129extern int driver_for_each_device(struct device_driver * drv, struct device * start, 137extern int __must_check driver_for_each_device(struct device_driver * drv,
130 void * data, int (*fn)(struct device *, void *)); 138 struct device *start, void *data,
139 int (*fn)(struct device *, void *));
131struct device * driver_find_device(struct device_driver *drv, 140struct device * driver_find_device(struct device_driver *drv,
132 struct device *start, void *data, 141 struct device *start, void *data,
133 int (*match)(struct device *, void *)); 142 int (*match)(struct device *, void *));
134 143
135
136/* 144/*
137 * device classes 145 * device classes
138 */ 146 */
@@ -146,17 +154,26 @@ struct class {
146 struct list_head interfaces; 154 struct list_head interfaces;
147 struct semaphore sem; /* locks both the children and interfaces lists */ 155 struct semaphore sem; /* locks both the children and interfaces lists */
148 156
157 struct kobject *virtual_dir;
158
149 struct class_attribute * class_attrs; 159 struct class_attribute * class_attrs;
150 struct class_device_attribute * class_dev_attrs; 160 struct class_device_attribute * class_dev_attrs;
161 struct device_attribute * dev_attrs;
151 162
152 int (*uevent)(struct class_device *dev, char **envp, 163 int (*uevent)(struct class_device *dev, char **envp,
153 int num_envp, char *buffer, int buffer_size); 164 int num_envp, char *buffer, int buffer_size);
165 int (*dev_uevent)(struct device *dev, char **envp, int num_envp,
166 char *buffer, int buffer_size);
154 167
155 void (*release)(struct class_device *dev); 168 void (*release)(struct class_device *dev);
156 void (*class_release)(struct class *class); 169 void (*class_release)(struct class *class);
170 void (*dev_release)(struct device *dev);
171
172 int (*suspend)(struct device *, pm_message_t state);
173 int (*resume)(struct device *);
157}; 174};
158 175
159extern int class_register(struct class *); 176extern int __must_check class_register(struct class *);
160extern void class_unregister(struct class *); 177extern void class_unregister(struct class *);
161 178
162 179
@@ -169,7 +186,8 @@ struct class_attribute {
169#define CLASS_ATTR(_name,_mode,_show,_store) \ 186#define CLASS_ATTR(_name,_mode,_show,_store) \
170struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) 187struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store)
171 188
172extern int class_create_file(struct class *, const struct class_attribute *); 189extern int __must_check class_create_file(struct class *,
190 const struct class_attribute *);
173extern void class_remove_file(struct class *, const struct class_attribute *); 191extern void class_remove_file(struct class *, const struct class_attribute *);
174 192
175struct class_device_attribute { 193struct class_device_attribute {
@@ -182,7 +200,7 @@ struct class_device_attribute {
182struct class_device_attribute class_device_attr_##_name = \ 200struct class_device_attribute class_device_attr_##_name = \
183 __ATTR(_name,_mode,_show,_store) 201 __ATTR(_name,_mode,_show,_store)
184 202
185extern int class_device_create_file(struct class_device *, 203extern int __must_check class_device_create_file(struct class_device *,
186 const struct class_device_attribute *); 204 const struct class_device_attribute *);
187 205
188/** 206/**
@@ -242,10 +260,10 @@ class_set_devdata (struct class_device *dev, void *data)
242} 260}
243 261
244 262
245extern int class_device_register(struct class_device *); 263extern int __must_check class_device_register(struct class_device *);
246extern void class_device_unregister(struct class_device *); 264extern void class_device_unregister(struct class_device *);
247extern void class_device_initialize(struct class_device *); 265extern void class_device_initialize(struct class_device *);
248extern int class_device_add(struct class_device *); 266extern int __must_check class_device_add(struct class_device *);
249extern void class_device_del(struct class_device *); 267extern void class_device_del(struct class_device *);
250 268
251extern int class_device_rename(struct class_device *, char *); 269extern int class_device_rename(struct class_device *, char *);
@@ -255,7 +273,7 @@ extern void class_device_put(struct class_device *);
255 273
256extern void class_device_remove_file(struct class_device *, 274extern void class_device_remove_file(struct class_device *,
257 const struct class_device_attribute *); 275 const struct class_device_attribute *);
258extern int class_device_create_bin_file(struct class_device *, 276extern int __must_check class_device_create_bin_file(struct class_device *,
259 struct bin_attribute *); 277 struct bin_attribute *);
260extern void class_device_remove_bin_file(struct class_device *, 278extern void class_device_remove_bin_file(struct class_device *,
261 struct bin_attribute *); 279 struct bin_attribute *);
@@ -266,22 +284,23 @@ struct class_interface {
266 284
267 int (*add) (struct class_device *, struct class_interface *); 285 int (*add) (struct class_device *, struct class_interface *);
268 void (*remove) (struct class_device *, struct class_interface *); 286 void (*remove) (struct class_device *, struct class_interface *);
287 int (*add_dev) (struct device *, struct class_interface *);
288 void (*remove_dev) (struct device *, struct class_interface *);
269}; 289};
270 290
271extern int class_interface_register(struct class_interface *); 291extern int __must_check class_interface_register(struct class_interface *);
272extern void class_interface_unregister(struct class_interface *); 292extern void class_interface_unregister(struct class_interface *);
273 293
274extern struct class *class_create(struct module *owner, char *name); 294extern struct class *class_create(struct module *owner, const char *name);
275extern void class_destroy(struct class *cls); 295extern void class_destroy(struct class *cls);
276extern struct class_device *class_device_create(struct class *cls, 296extern struct class_device *class_device_create(struct class *cls,
277 struct class_device *parent, 297 struct class_device *parent,
278 dev_t devt, 298 dev_t devt,
279 struct device *device, 299 struct device *device,
280 char *fmt, ...) 300 const char *fmt, ...)
281 __attribute__((format(printf,5,6))); 301 __attribute__((format(printf,5,6)));
282extern void class_device_destroy(struct class *cls, dev_t devt); 302extern void class_device_destroy(struct class *cls, dev_t devt);
283 303
284
285/* interface for exporting device attributes */ 304/* interface for exporting device attributes */
286struct device_attribute { 305struct device_attribute {
287 struct attribute attr; 306 struct attribute attr;
@@ -294,8 +313,13 @@ struct device_attribute {
294#define DEVICE_ATTR(_name,_mode,_show,_store) \ 313#define DEVICE_ATTR(_name,_mode,_show,_store) \
295struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) 314struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store)
296 315
297extern int device_create_file(struct device *device, struct device_attribute * entry); 316extern int __must_check device_create_file(struct device *device,
317 struct device_attribute * entry);
298extern void device_remove_file(struct device * dev, struct device_attribute * attr); 318extern void device_remove_file(struct device * dev, struct device_attribute * attr);
319extern int __must_check device_create_bin_file(struct device *dev,
320 struct bin_attribute *attr);
321extern void device_remove_bin_file(struct device *dev,
322 struct bin_attribute *attr);
299struct device { 323struct device {
300 struct klist klist_children; 324 struct klist klist_children;
301 struct klist_node knode_parent; /* node in sibling list */ 325 struct klist_node knode_parent; /* node in sibling list */
@@ -305,6 +329,7 @@ struct device {
305 329
306 struct kobject kobj; 330 struct kobject kobj;
307 char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 331 char bus_id[BUS_ID_SIZE]; /* position on parent bus */
332 unsigned is_registered:1;
308 struct device_attribute uevent_attr; 333 struct device_attribute uevent_attr;
309 struct device_attribute *devt_attr; 334 struct device_attribute *devt_attr;
310 335
@@ -338,6 +363,7 @@ struct device {
338 struct list_head node; 363 struct list_head node;
339 struct class *class; /* optional*/ 364 struct class *class; /* optional*/
340 dev_t devt; /* dev_t, creates the sysfs "dev" */ 365 dev_t devt; /* dev_t, creates the sysfs "dev" */
366 struct attribute_group **groups; /* optional groups */
341 367
342 void (*release)(struct device * dev); 368 void (*release)(struct device * dev);
343}; 369};
@@ -356,38 +382,41 @@ dev_set_drvdata (struct device *dev, void *data)
356 382
357static inline int device_is_registered(struct device *dev) 383static inline int device_is_registered(struct device *dev)
358{ 384{
359 return klist_node_attached(&dev->knode_bus); 385 return dev->is_registered;
360} 386}
361 387
362/* 388/*
363 * High level routines for use by the bus drivers 389 * High level routines for use by the bus drivers
364 */ 390 */
365extern int device_register(struct device * dev); 391extern int __must_check device_register(struct device * dev);
366extern void device_unregister(struct device * dev); 392extern void device_unregister(struct device * dev);
367extern void device_initialize(struct device * dev); 393extern void device_initialize(struct device * dev);
368extern int device_add(struct device * dev); 394extern int __must_check device_add(struct device * dev);
369extern void device_del(struct device * dev); 395extern void device_del(struct device * dev);
370extern int device_for_each_child(struct device *, void *, 396extern int __must_check device_for_each_child(struct device *, void *,
371 int (*fn)(struct device *, void *)); 397 int (*fn)(struct device *, void *));
398extern int device_rename(struct device *dev, char *new_name);
372 399
373/* 400/*
374 * Manual binding of a device to driver. See drivers/base/bus.c 401 * Manual binding of a device to driver. See drivers/base/bus.c
375 * for information on use. 402 * for information on use.
376 */ 403 */
377extern void device_bind_driver(struct device * dev); 404extern int __must_check device_bind_driver(struct device *dev);
378extern void device_release_driver(struct device * dev); 405extern void device_release_driver(struct device * dev);
379extern int device_attach(struct device * dev); 406extern int __must_check device_attach(struct device * dev);
380extern void driver_attach(struct device_driver * drv); 407extern int __must_check driver_attach(struct device_driver *drv);
381extern void device_reprobe(struct device *dev); 408extern int __must_check device_reprobe(struct device *dev);
382 409
383/* 410/*
384 * Easy functions for dynamically creating devices on the fly 411 * Easy functions for dynamically creating devices on the fly
385 */ 412 */
386extern struct device *device_create(struct class *cls, struct device *parent, 413extern struct device *device_create(struct class *cls, struct device *parent,
387 dev_t devt, char *fmt, ...) 414 dev_t devt, const char *fmt, ...)
388 __attribute__((format(printf,4,5))); 415 __attribute__((format(printf,4,5)));
389extern void device_destroy(struct class *cls, dev_t devt); 416extern void device_destroy(struct class *cls, dev_t devt);
390 417
418extern int virtual_device_parent(struct device *dev);
419
391/* 420/*
392 * Platform "fixup" functions - allow the platform to have their say 421 * Platform "fixup" functions - allow the platform to have their say
393 * about devices and actions that the general device layer doesn't 422 * about devices and actions that the general device layer doesn't
@@ -412,7 +441,7 @@ extern void device_shutdown(void);
412 441
413 442
414/* drivers/base/firmware.c */ 443/* drivers/base/firmware.c */
415extern int firmware_register(struct subsystem *); 444extern int __must_check firmware_register(struct subsystem *);
416extern void firmware_unregister(struct subsystem *); 445extern void firmware_unregister(struct subsystem *);
417 446
418/* debugging and troubleshooting/diagnostic helpers. */ 447/* debugging and troubleshooting/diagnostic helpers. */
diff --git a/include/linux/edd.h b/include/linux/edd.h
index 162512b886f7..b2b3e68aa512 100644
--- a/include/linux/edd.h
+++ b/include/linux/edd.h
@@ -52,6 +52,7 @@
52#define EDD_CL_EQUALS 0x3d646465 /* "edd=" */ 52#define EDD_CL_EQUALS 0x3d646465 /* "edd=" */
53#define EDD_CL_OFF 0x666f /* "of" for off */ 53#define EDD_CL_OFF 0x666f /* "of" for off */
54#define EDD_CL_SKIP 0x6b73 /* "sk" for skipmbr */ 54#define EDD_CL_SKIP 0x6b73 /* "sk" for skipmbr */
55#define EDD_CL_ON 0x6e6f /* "on" for on */
55 56
56#ifndef __ASSEMBLY__ 57#ifndef __ASSEMBLY__
57 58
diff --git a/include/linux/eisa.h b/include/linux/eisa.h
index 4079242dced8..1ff7c1392525 100644
--- a/include/linux/eisa.h
+++ b/include/linux/eisa.h
@@ -3,8 +3,8 @@
3 3
4#include <linux/ioport.h> 4#include <linux/ioport.h>
5#include <linux/device.h> 5#include <linux/device.h>
6#include <linux/mod_devicetable.h>
6 7
7#define EISA_SIG_LEN 8
8#define EISA_MAX_SLOTS 8 8#define EISA_MAX_SLOTS 8
9 9
10#define EISA_MAX_RESOURCES 4 10#define EISA_MAX_RESOURCES 4
@@ -27,12 +27,6 @@
27#define EISA_CONFIG_ENABLED 1 27#define EISA_CONFIG_ENABLED 1
28#define EISA_CONFIG_FORCED 2 28#define EISA_CONFIG_FORCED 2
29 29
30/* The EISA signature, in ASCII form, null terminated */
31struct eisa_device_id {
32 char sig[EISA_SIG_LEN];
33 unsigned long driver_data;
34};
35
36/* There is not much we can say about an EISA device, apart from 30/* There is not much we can say about an EISA device, apart from
37 * signature, slot number, and base address. dma_mask is set by 31 * signature, slot number, and base address. dma_mask is set by
38 * default to parent device mask..*/ 32 * default to parent device mask..*/
diff --git a/include/linux/err.h b/include/linux/err.h
index cd3b367f7445..1ab1d44f8d3b 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -15,6 +15,8 @@
15 */ 15 */
16#define MAX_ERRNO 4095 16#define MAX_ERRNO 4095
17 17
18#ifndef __ASSEMBLY__
19
18#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) 20#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
19 21
20static inline void *ERR_PTR(long error) 22static inline void *ERR_PTR(long error)
@@ -32,4 +34,6 @@ static inline long IS_ERR(const void *ptr)
32 return IS_ERR_VALUE((unsigned long)ptr); 34 return IS_ERR_VALUE((unsigned long)ptr);
33} 35}
34 36
37#endif
38
35#endif /* _LINUX_ERR_H */ 39#endif /* _LINUX_ERR_H */
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 0eed918b3816..cc08f56750da 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -460,7 +460,7 @@ struct ext3_super_block {
460 */ 460 */
461 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ 461 __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
462 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ 462 __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
463 __u16 s_reserved_gdt_blocks; /* Per group desc for online growth */ 463 __le16 s_reserved_gdt_blocks; /* Per group desc for online growth */
464 /* 464 /*
465 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. 465 * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
466 */ 466 */
@@ -473,7 +473,7 @@ struct ext3_super_block {
473 __u8 s_reserved_char_pad; 473 __u8 s_reserved_char_pad;
474 __u16 s_reserved_word_pad; 474 __u16 s_reserved_word_pad;
475 __le32 s_default_mount_opts; 475 __le32 s_default_mount_opts;
476 __le32 s_first_meta_bg; /* First metablock block group */ 476 __le32 s_first_meta_bg; /* First metablock block group */
477 __u32 s_reserved[190]; /* Padding to the end of the block */ 477 __u32 s_reserved[190]; /* Padding to the end of the block */
478}; 478};
479 479
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
index 2f18b9511f21..4395e5206746 100644
--- a/include/linux/ext3_fs_i.h
+++ b/include/linux/ext3_fs_i.h
@@ -35,7 +35,7 @@ struct ext3_reserve_window {
35}; 35};
36 36
37struct ext3_reserve_window_node { 37struct ext3_reserve_window_node {
38 struct rb_node rsv_node; 38 struct rb_node rsv_node;
39 __u32 rsv_goal_size; 39 __u32 rsv_goal_size;
40 __u32 rsv_alloc_hit; 40 __u32 rsv_alloc_hit;
41 struct ext3_reserve_window rsv_window; 41 struct ext3_reserve_window rsv_window;
diff --git a/include/linux/ext3_jbd.h b/include/linux/ext3_jbd.h
index c8307c02dd07..ce0e6109aff0 100644
--- a/include/linux/ext3_jbd.h
+++ b/include/linux/ext3_jbd.h
@@ -23,7 +23,7 @@
23 23
24/* Define the number of blocks we need to account to a transaction to 24/* Define the number of blocks we need to account to a transaction to
25 * modify one block of data. 25 * modify one block of data.
26 * 26 *
27 * We may have to touch one inode, one bitmap buffer, up to three 27 * We may have to touch one inode, one bitmap buffer, up to three
28 * indirection blocks, the group and superblock summaries, and the data 28 * indirection blocks, the group and superblock summaries, and the data
29 * block to complete the transaction. */ 29 * block to complete the transaction. */
@@ -88,16 +88,16 @@
88#endif 88#endif
89 89
90int 90int
91ext3_mark_iloc_dirty(handle_t *handle, 91ext3_mark_iloc_dirty(handle_t *handle,
92 struct inode *inode, 92 struct inode *inode,
93 struct ext3_iloc *iloc); 93 struct ext3_iloc *iloc);
94 94
95/* 95/*
96 * On success, We end up with an outstanding reference count against 96 * On success, We end up with an outstanding reference count against
97 * iloc->bh. This _must_ be cleaned up later. 97 * iloc->bh. This _must_ be cleaned up later.
98 */ 98 */
99 99
100int ext3_reserve_inode_write(handle_t *handle, struct inode *inode, 100int ext3_reserve_inode_write(handle_t *handle, struct inode *inode,
101 struct ext3_iloc *iloc); 101 struct ext3_iloc *iloc);
102 102
103int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode); 103int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1d3e601ece73..8f74dfbb2edd 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -512,7 +512,6 @@ struct inode {
512 struct timespec i_mtime; 512 struct timespec i_mtime;
513 struct timespec i_ctime; 513 struct timespec i_ctime;
514 unsigned int i_blkbits; 514 unsigned int i_blkbits;
515 unsigned long i_blksize;
516 unsigned long i_version; 515 unsigned long i_version;
517 blkcnt_t i_blocks; 516 blkcnt_t i_blocks;
518 unsigned short i_bytes; 517 unsigned short i_bytes;
@@ -528,11 +527,12 @@ struct inode {
528#ifdef CONFIG_QUOTA 527#ifdef CONFIG_QUOTA
529 struct dquot *i_dquot[MAXQUOTAS]; 528 struct dquot *i_dquot[MAXQUOTAS];
530#endif 529#endif
531 /* These three should probably be a union */
532 struct list_head i_devices; 530 struct list_head i_devices;
533 struct pipe_inode_info *i_pipe; 531 union {
534 struct block_device *i_bdev; 532 struct pipe_inode_info *i_pipe;
535 struct cdev *i_cdev; 533 struct block_device *i_bdev;
534 struct cdev *i_cdev;
535 };
536 int i_cindex; 536 int i_cindex;
537 537
538 __u32 i_generation; 538 __u32 i_generation;
@@ -554,9 +554,7 @@ struct inode {
554 554
555 atomic_t i_writecount; 555 atomic_t i_writecount;
556 void *i_security; 556 void *i_security;
557 union { 557 void *i_private; /* fs or device private pointer */
558 void *generic_ip;
559 } u;
560#ifdef __NEED_I_SIZE_ORDERED 558#ifdef __NEED_I_SIZE_ORDERED
561 seqcount_t i_size_seqcount; 559 seqcount_t i_size_seqcount;
562#endif 560#endif
diff --git a/include/linux/getcpu.h b/include/linux/getcpu.h
new file mode 100644
index 000000000000..031ed3780e45
--- /dev/null
+++ b/include/linux/getcpu.h
@@ -0,0 +1,16 @@
1#ifndef _LINUX_GETCPU_H
2#define _LINUX_GETCPU_H 1
3
4/* Cache for getcpu() to speed it up. Results might be upto a jiffie
5 out of date, but will be faster.
6 User programs should not refer to the contents of this structure.
7 It is only a cache for vgetcpu(). It might change in future kernels.
8 The user program must store this information per thread (__thread)
9 If you want 100% accurate information pass NULL instead. */
10struct getcpu_cache {
11 unsigned long t0;
12 unsigned long t1;
13 unsigned long res[4];
14};
15
16#endif
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index 8b34aabfe4c6..bf2b6bc3f6fd 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -67,7 +67,12 @@ struct vm_area_struct;
67#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \ 67#define GFP_HIGHUSER (__GFP_WAIT | __GFP_IO | __GFP_FS | __GFP_HARDWALL | \
68 __GFP_HIGHMEM) 68 __GFP_HIGHMEM)
69 69
70#ifdef CONFIG_NUMA
70#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY) 71#define GFP_THISNODE (__GFP_THISNODE | __GFP_NOWARN | __GFP_NORETRY)
72#else
73#define GFP_THISNODE 0
74#endif
75
71 76
72/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some 77/* Flag - indicates that the buffer will be suitable for DMA. Ignored on some
73 platforms, used as appropriate on others */ 78 platforms, used as appropriate on others */
diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h
index d5ebbb29aeae..d4b333938f73 100644
--- a/include/linux/hdlc.h
+++ b/include/linux/hdlc.h
@@ -11,95 +11,46 @@
11#ifndef __HDLC_H 11#ifndef __HDLC_H
12#define __HDLC_H 12#define __HDLC_H
13 13
14#define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */
15
16#define CLOCK_DEFAULT 0 /* Default setting */
17#define CLOCK_EXT 1 /* External TX and RX clock - DTE */
18#define CLOCK_INT 2 /* Internal TX and RX clock - DCE */
19#define CLOCK_TXINT 3 /* Internal TX and external RX clock */
20#define CLOCK_TXFROMRX 4 /* TX clock derived from external RX clock */
21
22
23#define ENCODING_DEFAULT 0 /* Default setting */
24#define ENCODING_NRZ 1
25#define ENCODING_NRZI 2
26#define ENCODING_FM_MARK 3
27#define ENCODING_FM_SPACE 4
28#define ENCODING_MANCHESTER 5
29
30
31#define PARITY_DEFAULT 0 /* Default setting */
32#define PARITY_NONE 1 /* No parity */
33#define PARITY_CRC16_PR0 2 /* CRC16, initial value 0x0000 */
34#define PARITY_CRC16_PR1 3 /* CRC16, initial value 0xFFFF */
35#define PARITY_CRC16_PR0_CCITT 4 /* CRC16, initial 0x0000, ITU-T version */
36#define PARITY_CRC16_PR1_CCITT 5 /* CRC16, initial 0xFFFF, ITU-T version */
37#define PARITY_CRC32_PR0_CCITT 6 /* CRC32, initial value 0x00000000 */
38#define PARITY_CRC32_PR1_CCITT 7 /* CRC32, initial value 0xFFFFFFFF */
39
40#define LMI_DEFAULT 0 /* Default setting */
41#define LMI_NONE 1 /* No LMI, all PVCs are static */
42#define LMI_ANSI 2 /* ANSI Annex D */
43#define LMI_CCITT 3 /* ITU-T Annex A */
44#define LMI_CISCO 4 /* The "original" LMI, aka Gang of Four */
45 14
46#define HDLC_MAX_MTU 1500 /* Ethernet 1500 bytes */ 15#define HDLC_MAX_MTU 1500 /* Ethernet 1500 bytes */
16#if 0
47#define HDLC_MAX_MRU (HDLC_MAX_MTU + 10 + 14 + 4) /* for ETH+VLAN over FR */ 17#define HDLC_MAX_MRU (HDLC_MAX_MTU + 10 + 14 + 4) /* for ETH+VLAN over FR */
18#else
19#define HDLC_MAX_MRU 1600 /* as required for FR network */
20#endif
48 21
49 22
50#ifdef __KERNEL__ 23#ifdef __KERNEL__
51 24
52#include <linux/skbuff.h> 25#include <linux/skbuff.h>
53#include <linux/netdevice.h> 26#include <linux/netdevice.h>
54#include <net/syncppp.h>
55#include <linux/hdlc/ioctl.h> 27#include <linux/hdlc/ioctl.h>
56 28
57 29
58typedef struct { /* Used in Cisco and PPP mode */ 30/* Used by all network devices here, pointed to by netdev_priv(dev) */
59 u8 address; 31struct hdlc_device_desc {
60 u8 control; 32 int (*netif_rx)(struct sk_buff *skb);
61 u16 protocol;
62}__attribute__ ((packed)) hdlc_header;
63
64
65
66typedef struct {
67 u32 type; /* code */
68 u32 par1;
69 u32 par2;
70 u16 rel; /* reliability */
71 u32 time;
72}__attribute__ ((packed)) cisco_packet;
73#define CISCO_PACKET_LEN 18
74#define CISCO_BIG_PACKET_LEN 20
75
76
77
78typedef struct pvc_device_struct {
79 struct net_device *master;
80 struct net_device *main;
81 struct net_device *ether; /* bridged Ethernet interface */
82 struct pvc_device_struct *next; /* Sorted in ascending DLCI order */
83 int dlci;
84 int open_count;
85
86 struct {
87 unsigned int new: 1;
88 unsigned int active: 1;
89 unsigned int exist: 1;
90 unsigned int deleted: 1;
91 unsigned int fecn: 1;
92 unsigned int becn: 1;
93 unsigned int bandwidth; /* Cisco LMI reporting only */
94 }state;
95}pvc_device;
96
97
98
99typedef struct hdlc_device_struct {
100 /* To be initialized by hardware driver */
101 struct net_device_stats stats; 33 struct net_device_stats stats;
102 34};
35
36/* This structure is a private property of HDLC protocols.
37 Hardware drivers have no interest here */
38
39struct hdlc_proto {
40 int (*open)(struct net_device *dev);
41 void (*close)(struct net_device *dev);
42 void (*start)(struct net_device *dev); /* if open & DCD */
43 void (*stop)(struct net_device *dev); /* if open & !DCD */
44 void (*detach)(struct net_device *dev);
45 int (*ioctl)(struct net_device *dev, struct ifreq *ifr);
46 unsigned short (*type_trans)(struct sk_buff *skb,
47 struct net_device *dev);
48 struct module *module;
49 struct hdlc_proto *next; /* next protocol in the list */
50};
51
52
53typedef struct hdlc_device {
103 /* used by HDLC layer to take control over HDLC device from hw driver*/ 54 /* used by HDLC layer to take control over HDLC device from hw driver*/
104 int (*attach)(struct net_device *dev, 55 int (*attach)(struct net_device *dev,
105 unsigned short encoding, unsigned short parity); 56 unsigned short encoding, unsigned short parity);
@@ -107,82 +58,18 @@ typedef struct hdlc_device_struct {
107 /* hardware driver must handle this instead of dev->hard_start_xmit */ 58 /* hardware driver must handle this instead of dev->hard_start_xmit */
108 int (*xmit)(struct sk_buff *skb, struct net_device *dev); 59 int (*xmit)(struct sk_buff *skb, struct net_device *dev);
109 60
110
111 /* Things below are for HDLC layer internal use only */ 61 /* Things below are for HDLC layer internal use only */
112 struct { 62 const struct hdlc_proto *proto;
113 int (*open)(struct net_device *dev);
114 void (*close)(struct net_device *dev);
115
116 /* if open & DCD */
117 void (*start)(struct net_device *dev);
118 /* if open & !DCD */
119 void (*stop)(struct net_device *dev);
120
121 void (*detach)(struct hdlc_device_struct *hdlc);
122 int (*netif_rx)(struct sk_buff *skb);
123 unsigned short (*type_trans)(struct sk_buff *skb,
124 struct net_device *dev);
125 int id; /* IF_PROTO_HDLC/CISCO/FR/etc. */
126 }proto;
127
128 int carrier; 63 int carrier;
129 int open; 64 int open;
130 spinlock_t state_lock; 65 spinlock_t state_lock;
131 66 void *state;
132 union {
133 struct {
134 fr_proto settings;
135 pvc_device *first_pvc;
136 int dce_pvc_count;
137
138 struct timer_list timer;
139 unsigned long last_poll;
140 int reliable;
141 int dce_changed;
142 int request;
143 int fullrep_sent;
144 u32 last_errors; /* last errors bit list */
145 u8 n391cnt;
146 u8 txseq; /* TX sequence number */
147 u8 rxseq; /* RX sequence number */
148 }fr;
149
150 struct {
151 cisco_proto settings;
152
153 struct timer_list timer;
154 unsigned long last_poll;
155 int up;
156 int request_sent;
157 u32 txseq; /* TX sequence number */
158 u32 rxseq; /* RX sequence number */
159 }cisco;
160
161 struct {
162 raw_hdlc_proto settings;
163 }raw_hdlc;
164
165 struct {
166 struct ppp_device pppdev;
167 struct ppp_device *syncppp_ptr;
168 int (*old_change_mtu)(struct net_device *dev,
169 int new_mtu);
170 }ppp;
171 }state;
172 void *priv; 67 void *priv;
173}hdlc_device; 68}hdlc_device;
174 69
175 70
176 71
177int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr); 72/* Exported from hdlc module */
178int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr);
179int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr);
180int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr);
181int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr);
182int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr);
183
184
185/* Exported from hdlc.o */
186 73
187/* Called by hardware driver when a user requests HDLC service */ 74/* Called by hardware driver when a user requests HDLC service */
188int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); 75int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
@@ -191,17 +78,21 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
191#define register_hdlc_device(dev) register_netdev(dev) 78#define register_hdlc_device(dev) register_netdev(dev)
192void unregister_hdlc_device(struct net_device *dev); 79void unregister_hdlc_device(struct net_device *dev);
193 80
81
82void register_hdlc_protocol(struct hdlc_proto *proto);
83void unregister_hdlc_protocol(struct hdlc_proto *proto);
84
194struct net_device *alloc_hdlcdev(void *priv); 85struct net_device *alloc_hdlcdev(void *priv);
195 86
196static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev) 87
88static __inline__ struct hdlc_device_desc* dev_to_desc(struct net_device *dev)
197{ 89{
198 return netdev_priv(dev); 90 return netdev_priv(dev);
199} 91}
200 92
201 93static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev)
202static __inline__ pvc_device* dev_to_pvc(struct net_device *dev)
203{ 94{
204 return (pvc_device*)dev->priv; 95 return netdev_priv(dev) + sizeof(struct hdlc_device_desc);
205} 96}
206 97
207 98
@@ -225,18 +116,14 @@ int hdlc_open(struct net_device *dev);
225/* Must be called by hardware driver when HDLC device is being closed */ 116/* Must be called by hardware driver when HDLC device is being closed */
226void hdlc_close(struct net_device *dev); 117void hdlc_close(struct net_device *dev);
227 118
119int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
120 int (*rx)(struct sk_buff *skb), size_t size);
228/* May be used by hardware driver to gain control over HDLC device */ 121/* May be used by hardware driver to gain control over HDLC device */
229static __inline__ void hdlc_proto_detach(hdlc_device *hdlc) 122void detach_hdlc_protocol(struct net_device *dev);
230{
231 if (hdlc->proto.detach)
232 hdlc->proto.detach(hdlc);
233 hdlc->proto.detach = NULL;
234}
235
236 123
237static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev) 124static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev)
238{ 125{
239 return &dev_to_hdlc(dev)->stats; 126 return &dev_to_desc(dev)->stats;
240} 127}
241 128
242 129
@@ -248,8 +135,8 @@ static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
248 skb->mac.raw = skb->data; 135 skb->mac.raw = skb->data;
249 skb->dev = dev; 136 skb->dev = dev;
250 137
251 if (hdlc->proto.type_trans) 138 if (hdlc->proto->type_trans)
252 return hdlc->proto.type_trans(skb, dev); 139 return hdlc->proto->type_trans(skb, dev);
253 else 140 else
254 return htons(ETH_P_HDLC); 141 return htons(ETH_P_HDLC);
255} 142}
diff --git a/include/linux/hdlc/ioctl.h b/include/linux/hdlc/ioctl.h
index 78430ba3ea69..583972364357 100644
--- a/include/linux/hdlc/ioctl.h
+++ b/include/linux/hdlc/ioctl.h
@@ -1,6 +1,39 @@
1#ifndef __HDLC_IOCTL_H__ 1#ifndef __HDLC_IOCTL_H__
2#define __HDLC_IOCTL_H__ 2#define __HDLC_IOCTL_H__
3 3
4
5#define GENERIC_HDLC_VERSION 4 /* For synchronization with sethdlc utility */
6
7#define CLOCK_DEFAULT 0 /* Default setting */
8#define CLOCK_EXT 1 /* External TX and RX clock - DTE */
9#define CLOCK_INT 2 /* Internal TX and RX clock - DCE */
10#define CLOCK_TXINT 3 /* Internal TX and external RX clock */
11#define CLOCK_TXFROMRX 4 /* TX clock derived from external RX clock */
12
13
14#define ENCODING_DEFAULT 0 /* Default setting */
15#define ENCODING_NRZ 1
16#define ENCODING_NRZI 2
17#define ENCODING_FM_MARK 3
18#define ENCODING_FM_SPACE 4
19#define ENCODING_MANCHESTER 5
20
21
22#define PARITY_DEFAULT 0 /* Default setting */
23#define PARITY_NONE 1 /* No parity */
24#define PARITY_CRC16_PR0 2 /* CRC16, initial value 0x0000 */
25#define PARITY_CRC16_PR1 3 /* CRC16, initial value 0xFFFF */
26#define PARITY_CRC16_PR0_CCITT 4 /* CRC16, initial 0x0000, ITU-T version */
27#define PARITY_CRC16_PR1_CCITT 5 /* CRC16, initial 0xFFFF, ITU-T version */
28#define PARITY_CRC32_PR0_CCITT 6 /* CRC32, initial value 0x00000000 */
29#define PARITY_CRC32_PR1_CCITT 7 /* CRC32, initial value 0xFFFFFFFF */
30
31#define LMI_DEFAULT 0 /* Default setting */
32#define LMI_NONE 1 /* No LMI, all PVCs are static */
33#define LMI_ANSI 2 /* ANSI Annex D */
34#define LMI_CCITT 3 /* ITU-T Annex A */
35#define LMI_CISCO 4 /* The "original" LMI, aka Gang of Four */
36
4typedef struct { 37typedef struct {
5 unsigned int clock_rate; /* bits per second */ 38 unsigned int clock_rate; /* bits per second */
6 unsigned int clock_type; /* internal, external, TX-internal etc. */ 39 unsigned int clock_type; /* internal, external, TX-internal etc. */
diff --git a/include/linux/i2c-algo-bit.h b/include/linux/i2c-algo-bit.h
index c0e7fab28ce3..c8f8df25c7e0 100644
--- a/include/linux/i2c-algo-bit.h
+++ b/include/linux/i2c-algo-bit.h
@@ -40,7 +40,6 @@ struct i2c_algo_bit_data {
40 /* local settings */ 40 /* local settings */
41 int udelay; /* half-clock-cycle time in microsecs */ 41 int udelay; /* half-clock-cycle time in microsecs */
42 /* i.e. clock is (500 / udelay) KHz */ 42 /* i.e. clock is (500 / udelay) KHz */
43 int mdelay; /* in millisecs, unused */
44 int timeout; /* in jiffies */ 43 int timeout; /* in jiffies */
45}; 44};
46 45
diff --git a/include/linux/i2c-algo-pcf.h b/include/linux/i2c-algo-pcf.h
index 18b0adf57a3d..9908f3fc4839 100644
--- a/include/linux/i2c-algo-pcf.h
+++ b/include/linux/i2c-algo-pcf.h
@@ -35,7 +35,6 @@ struct i2c_algo_pcf_data {
35 35
36 /* local settings */ 36 /* local settings */
37 int udelay; 37 int udelay;
38 int mdelay;
39 int timeout; 38 int timeout;
40}; 39};
41 40
diff --git a/include/linux/i2c-algo-sibyte.h b/include/linux/i2c-algo-sibyte.h
deleted file mode 100644
index 03914ded8614..000000000000
--- a/include/linux/i2c-algo-sibyte.h
+++ /dev/null
@@ -1,33 +0,0 @@
1/*
2 * Copyright (C) 2001,2002,2003 Broadcom Corporation
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 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef I2C_ALGO_SIBYTE_H
20#define I2C_ALGO_SIBYTE_H 1
21
22#include <linux/i2c.h>
23
24struct i2c_algo_sibyte_data {
25 void *data; /* private data */
26 int bus; /* which bus */
27 void *reg_base; /* CSR base */
28};
29
30int i2c_sibyte_add_bus(struct i2c_adapter *, int speed);
31int i2c_sibyte_del_bus(struct i2c_adapter *);
32
33#endif /* I2C_ALGO_SIBYTE_H */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index eb0628a7ecc6..9b5d04768c2c 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -64,14 +64,6 @@ extern int i2c_master_recv(struct i2c_client *,char* ,int);
64 */ 64 */
65extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num); 65extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
66 66
67/*
68 * Some adapter types (i.e. PCF 8584 based ones) may support slave behaviuor.
69 * This is not tested/implemented yet and will change in the future.
70 */
71extern int i2c_slave_send(struct i2c_client *,char*,int);
72extern int i2c_slave_recv(struct i2c_client *,char*,int);
73
74
75 67
76/* This is the very generalized SMBus access routine. You probably do not 68/* This is the very generalized SMBus access routine. You probably do not
77 want to use this, though; one of the functions below may be much easier, 69 want to use this, though; one of the functions below may be much easier,
@@ -201,10 +193,6 @@ struct i2c_algorithm {
201 unsigned short flags, char read_write, 193 unsigned short flags, char read_write,
202 u8 command, int size, union i2c_smbus_data * data); 194 u8 command, int size, union i2c_smbus_data * data);
203 195
204 /* --- these optional/future use for some adapter types.*/
205 int (*slave_send)(struct i2c_adapter *,char*,int);
206 int (*slave_recv)(struct i2c_adapter *,char*,int);
207
208 /* --- ioctl like call to set div. parameters. */ 196 /* --- ioctl like call to set div. parameters. */
209 int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long); 197 int (*algo_control)(struct i2c_adapter *, unsigned int, unsigned long);
210 198
@@ -220,7 +208,7 @@ struct i2c_adapter {
220 struct module *owner; 208 struct module *owner;
221 unsigned int id; 209 unsigned int id;
222 unsigned int class; 210 unsigned int class;
223 struct i2c_algorithm *algo;/* the algorithm to access the bus */ 211 const struct i2c_algorithm *algo; /* the algorithm to access the bus */
224 void *algo_data; 212 void *algo_data;
225 213
226 /* --- administration stuff. */ 214 /* --- administration stuff. */
diff --git a/include/linux/if.h b/include/linux/if.h
index cd080d765324..8018c2e22c0c 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -59,6 +59,8 @@
59#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */ 59#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */
60#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */ 60#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */
61#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ 61#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
62#define IFF_BONDING 0x20 /* bonding master or slave */
63#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */
62 64
63#define IF_GET_IFACE 0x0001 /* for querying only */ 65#define IF_GET_IFACE 0x0001 /* for querying only */
64#define IF_GET_PROTO 0x0002 66#define IF_GET_PROTO 0x0002
diff --git a/include/linux/init.h b/include/linux/init.h
index 6667785dd1ff..e92b1455d7af 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -68,6 +68,7 @@ extern initcall_t __security_initcall_start[], __security_initcall_end[];
68 68
69/* Defined in init/main.c */ 69/* Defined in init/main.c */
70extern char saved_command_line[]; 70extern char saved_command_line[];
71extern unsigned int reset_devices;
71 72
72/* used by init/main.c */ 73/* used by init/main.c */
73extern void setup_arch(char **); 74extern void setup_arch(char **);
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index a04c154c5207..a6d9daa38c6d 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * linux/include/linux/jbd.h 2 * linux/include/linux/jbd.h
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com> 4 * Written by Stephen C. Tweedie <sct@redhat.com>
5 * 5 *
6 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved 6 * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
@@ -64,7 +64,7 @@ extern int journal_enable_debug;
64 if ((n) <= journal_enable_debug) { \ 64 if ((n) <= journal_enable_debug) { \
65 printk (KERN_DEBUG "(%s, %d): %s: ", \ 65 printk (KERN_DEBUG "(%s, %d): %s: ", \
66 __FILE__, __LINE__, __FUNCTION__); \ 66 __FILE__, __LINE__, __FUNCTION__); \
67 printk (f, ## a); \ 67 printk (f, ## a); \
68 } \ 68 } \
69 } while (0) 69 } while (0)
70#else 70#else
@@ -97,8 +97,8 @@ extern void jbd_slab_free(void *ptr, size_t size);
97 * number of outstanding buffers possible at any time. When the 97 * number of outstanding buffers possible at any time. When the
98 * operation completes, any buffer credits not used are credited back to 98 * operation completes, any buffer credits not used are credited back to
99 * the transaction, so that at all times we know how many buffers the 99 * the transaction, so that at all times we know how many buffers the
100 * outstanding updates on a transaction might possibly touch. 100 * outstanding updates on a transaction might possibly touch.
101 * 101 *
102 * This is an opaque datatype. 102 * This is an opaque datatype.
103 **/ 103 **/
104typedef struct handle_s handle_t; /* Atomic operation type */ 104typedef struct handle_s handle_t; /* Atomic operation type */
@@ -108,7 +108,7 @@ typedef struct handle_s handle_t; /* Atomic operation type */
108 * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem. 108 * typedef journal_t - The journal_t maintains all of the journaling state information for a single filesystem.
109 * 109 *
110 * journal_t is linked to from the fs superblock structure. 110 * journal_t is linked to from the fs superblock structure.
111 * 111 *
112 * We use the journal_t to keep track of all outstanding transaction 112 * We use the journal_t to keep track of all outstanding transaction
113 * activity on the filesystem, and to manage the state of the log 113 * activity on the filesystem, and to manage the state of the log
114 * writing process. 114 * writing process.
@@ -128,7 +128,7 @@ typedef struct journal_s journal_t; /* Journal control structure */
128 * On-disk structures 128 * On-disk structures
129 */ 129 */
130 130
131/* 131/*
132 * Descriptor block types: 132 * Descriptor block types:
133 */ 133 */
134 134
@@ -149,8 +149,8 @@ typedef struct journal_header_s
149} journal_header_t; 149} journal_header_t;
150 150
151 151
152/* 152/*
153 * The block tag: used to describe a single buffer in the journal 153 * The block tag: used to describe a single buffer in the journal
154 */ 154 */
155typedef struct journal_block_tag_s 155typedef struct journal_block_tag_s
156{ 156{
@@ -158,9 +158,9 @@ typedef struct journal_block_tag_s
158 __be32 t_flags; /* See below */ 158 __be32 t_flags; /* See below */
159} journal_block_tag_t; 159} journal_block_tag_t;
160 160
161/* 161/*
162 * The revoke descriptor: used on disk to describe a series of blocks to 162 * The revoke descriptor: used on disk to describe a series of blocks to
163 * be revoked from the log 163 * be revoked from the log
164 */ 164 */
165typedef struct journal_revoke_header_s 165typedef struct journal_revoke_header_s
166{ 166{
@@ -201,9 +201,9 @@ typedef struct journal_superblock_s
201 201
202/* 0x0024 */ 202/* 0x0024 */
203 /* Remaining fields are only valid in a version-2 superblock */ 203 /* Remaining fields are only valid in a version-2 superblock */
204 __be32 s_feature_compat; /* compatible feature set */ 204 __be32 s_feature_compat; /* compatible feature set */
205 __be32 s_feature_incompat; /* incompatible feature set */ 205 __be32 s_feature_incompat; /* incompatible feature set */
206 __be32 s_feature_ro_compat; /* readonly-compatible feature set */ 206 __be32 s_feature_ro_compat; /* readonly-compatible feature set */
207/* 0x0030 */ 207/* 0x0030 */
208 __u8 s_uuid[16]; /* 128-bit uuid for journal */ 208 __u8 s_uuid[16]; /* 128-bit uuid for journal */
209 209
@@ -374,10 +374,10 @@ struct jbd_revoke_table_s;
374 **/ 374 **/
375 375
376/* Docbook can't yet cope with the bit fields, but will leave the documentation 376/* Docbook can't yet cope with the bit fields, but will leave the documentation
377 * in so it can be fixed later. 377 * in so it can be fixed later.
378 */ 378 */
379 379
380struct handle_s 380struct handle_s
381{ 381{
382 /* Which compound transaction is this update a part of? */ 382 /* Which compound transaction is this update a part of? */
383 transaction_t *h_transaction; 383 transaction_t *h_transaction;
@@ -435,7 +435,7 @@ struct handle_s
435 * 435 *
436 */ 436 */
437 437
438struct transaction_s 438struct transaction_s
439{ 439{
440 /* Pointer to the journal for this transaction. [no locking] */ 440 /* Pointer to the journal for this transaction. [no locking] */
441 journal_t *t_journal; 441 journal_t *t_journal;
@@ -455,7 +455,7 @@ struct transaction_s
455 T_RUNDOWN, 455 T_RUNDOWN,
456 T_FLUSH, 456 T_FLUSH,
457 T_COMMIT, 457 T_COMMIT,
458 T_FINISHED 458 T_FINISHED
459 } t_state; 459 } t_state;
460 460
461 /* 461 /*
@@ -569,7 +569,7 @@ struct transaction_s
569 * journal_t. 569 * journal_t.
570 * @j_flags: General journaling state flags 570 * @j_flags: General journaling state flags
571 * @j_errno: Is there an outstanding uncleared error on the journal (from a 571 * @j_errno: Is there an outstanding uncleared error on the journal (from a
572 * prior abort)? 572 * prior abort)?
573 * @j_sb_buffer: First part of superblock buffer 573 * @j_sb_buffer: First part of superblock buffer
574 * @j_superblock: Second part of superblock buffer 574 * @j_superblock: Second part of superblock buffer
575 * @j_format_version: Version of the superblock format 575 * @j_format_version: Version of the superblock format
@@ -583,7 +583,7 @@ struct transaction_s
583 * @j_wait_transaction_locked: Wait queue for waiting for a locked transaction 583 * @j_wait_transaction_locked: Wait queue for waiting for a locked transaction
584 * to start committing, or for a barrier lock to be released 584 * to start committing, or for a barrier lock to be released
585 * @j_wait_logspace: Wait queue for waiting for checkpointing to complete 585 * @j_wait_logspace: Wait queue for waiting for checkpointing to complete
586 * @j_wait_done_commit: Wait queue for waiting for commit to complete 586 * @j_wait_done_commit: Wait queue for waiting for commit to complete
587 * @j_wait_checkpoint: Wait queue to trigger checkpointing 587 * @j_wait_checkpoint: Wait queue to trigger checkpointing
588 * @j_wait_commit: Wait queue to trigger commit 588 * @j_wait_commit: Wait queue to trigger commit
589 * @j_wait_updates: Wait queue to wait for updates to complete 589 * @j_wait_updates: Wait queue to wait for updates to complete
@@ -592,7 +592,7 @@ struct transaction_s
592 * @j_tail: Journal tail - identifies the oldest still-used block in the 592 * @j_tail: Journal tail - identifies the oldest still-used block in the
593 * journal. 593 * journal.
594 * @j_free: Journal free - how many free blocks are there in the journal? 594 * @j_free: Journal free - how many free blocks are there in the journal?
595 * @j_first: The block number of the first usable block 595 * @j_first: The block number of the first usable block
596 * @j_last: The block number one beyond the last usable block 596 * @j_last: The block number one beyond the last usable block
597 * @j_dev: Device where we store the journal 597 * @j_dev: Device where we store the journal
598 * @j_blocksize: blocksize for the location where we store the journal. 598 * @j_blocksize: blocksize for the location where we store the journal.
@@ -604,12 +604,12 @@ struct transaction_s
604 * @j_list_lock: Protects the buffer lists and internal buffer state. 604 * @j_list_lock: Protects the buffer lists and internal buffer state.
605 * @j_inode: Optional inode where we store the journal. If present, all journal 605 * @j_inode: Optional inode where we store the journal. If present, all journal
606 * block numbers are mapped into this inode via bmap(). 606 * block numbers are mapped into this inode via bmap().
607 * @j_tail_sequence: Sequence number of the oldest transaction in the log 607 * @j_tail_sequence: Sequence number of the oldest transaction in the log
608 * @j_transaction_sequence: Sequence number of the next transaction to grant 608 * @j_transaction_sequence: Sequence number of the next transaction to grant
609 * @j_commit_sequence: Sequence number of the most recently committed 609 * @j_commit_sequence: Sequence number of the most recently committed
610 * transaction 610 * transaction
611 * @j_commit_request: Sequence number of the most recent transaction wanting 611 * @j_commit_request: Sequence number of the most recent transaction wanting
612 * commit 612 * commit
613 * @j_uuid: Uuid of client object. 613 * @j_uuid: Uuid of client object.
614 * @j_task: Pointer to the current commit thread for this journal 614 * @j_task: Pointer to the current commit thread for this journal
615 * @j_max_transaction_buffers: Maximum number of metadata buffers to allow in a 615 * @j_max_transaction_buffers: Maximum number of metadata buffers to allow in a
@@ -699,7 +699,7 @@ struct journal_s
699 wait_queue_head_t j_wait_updates; 699 wait_queue_head_t j_wait_updates;
700 700
701 /* Semaphore for locking against concurrent checkpoints */ 701 /* Semaphore for locking against concurrent checkpoints */
702 struct mutex j_checkpoint_mutex; 702 struct mutex j_checkpoint_mutex;
703 703
704 /* 704 /*
705 * Journal head: identifies the first unused block in the journal. 705 * Journal head: identifies the first unused block in the journal.
@@ -732,7 +732,7 @@ struct journal_s
732 */ 732 */
733 struct block_device *j_dev; 733 struct block_device *j_dev;
734 int j_blocksize; 734 int j_blocksize;
735 unsigned int j_blk_offset; 735 unsigned long j_blk_offset;
736 736
737 /* 737 /*
738 * Device which holds the client fs. For internal journal this will be 738 * Device which holds the client fs. For internal journal this will be
@@ -823,8 +823,8 @@ struct journal_s
823 void *j_private; 823 void *j_private;
824}; 824};
825 825
826/* 826/*
827 * Journal flag definitions 827 * Journal flag definitions
828 */ 828 */
829#define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */ 829#define JFS_UNMOUNT 0x001 /* Journal thread is being destroyed */
830#define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */ 830#define JFS_ABORT 0x002 /* Journaling has been aborted for errors. */
@@ -833,7 +833,7 @@ struct journal_s
833#define JFS_LOADED 0x010 /* The journal superblock has been loaded */ 833#define JFS_LOADED 0x010 /* The journal superblock has been loaded */
834#define JFS_BARRIER 0x020 /* Use IDE barriers */ 834#define JFS_BARRIER 0x020 /* Use IDE barriers */
835 835
836/* 836/*
837 * Function declarations for the journaling transaction and buffer 837 * Function declarations for the journaling transaction and buffer
838 * management 838 * management
839 */ 839 */
@@ -862,11 +862,11 @@ int __journal_remove_checkpoint(struct journal_head *);
862void __journal_insert_checkpoint(struct journal_head *, transaction_t *); 862void __journal_insert_checkpoint(struct journal_head *, transaction_t *);
863 863
864/* Buffer IO */ 864/* Buffer IO */
865extern int 865extern int
866journal_write_metadata_buffer(transaction_t *transaction, 866journal_write_metadata_buffer(transaction_t *transaction,
867 struct journal_head *jh_in, 867 struct journal_head *jh_in,
868 struct journal_head **jh_out, 868 struct journal_head **jh_out,
869 int blocknr); 869 unsigned long blocknr);
870 870
871/* Transaction locking */ 871/* Transaction locking */
872extern void __wait_on_journal (journal_t *); 872extern void __wait_on_journal (journal_t *);
@@ -890,7 +890,7 @@ static inline handle_t *journal_current_handle(void)
890/* The journaling code user interface: 890/* The journaling code user interface:
891 * 891 *
892 * Create and destroy handles 892 * Create and destroy handles
893 * Register buffer modifications against the current transaction. 893 * Register buffer modifications against the current transaction.
894 */ 894 */
895 895
896extern handle_t *journal_start(journal_t *, int nblocks); 896extern handle_t *journal_start(journal_t *, int nblocks);
@@ -917,11 +917,11 @@ extern journal_t * journal_init_dev(struct block_device *bdev,
917 int start, int len, int bsize); 917 int start, int len, int bsize);
918extern journal_t * journal_init_inode (struct inode *); 918extern journal_t * journal_init_inode (struct inode *);
919extern int journal_update_format (journal_t *); 919extern int journal_update_format (journal_t *);
920extern int journal_check_used_features 920extern int journal_check_used_features
921 (journal_t *, unsigned long, unsigned long, unsigned long); 921 (journal_t *, unsigned long, unsigned long, unsigned long);
922extern int journal_check_available_features 922extern int journal_check_available_features
923 (journal_t *, unsigned long, unsigned long, unsigned long); 923 (journal_t *, unsigned long, unsigned long, unsigned long);
924extern int journal_set_features 924extern int journal_set_features
925 (journal_t *, unsigned long, unsigned long, unsigned long); 925 (journal_t *, unsigned long, unsigned long, unsigned long);
926extern int journal_create (journal_t *); 926extern int journal_create (journal_t *);
927extern int journal_load (journal_t *journal); 927extern int journal_load (journal_t *journal);
@@ -1015,7 +1015,7 @@ do { \
1015 * bit, when set, indicates that we have had a fatal error somewhere, 1015 * bit, when set, indicates that we have had a fatal error somewhere,
1016 * either inside the journaling layer or indicated to us by the client 1016 * either inside the journaling layer or indicated to us by the client
1017 * (eg. ext3), and that we and should not commit any further 1017 * (eg. ext3), and that we and should not commit any further
1018 * transactions. 1018 * transactions.
1019 */ 1019 */
1020 1020
1021static inline int is_journal_aborted(journal_t *journal) 1021static inline int is_journal_aborted(journal_t *journal)
@@ -1082,7 +1082,7 @@ static inline int jbd_space_needed(journal_t *journal)
1082#define BJ_Reserved 7 /* Buffer is reserved for access by journal */ 1082#define BJ_Reserved 7 /* Buffer is reserved for access by journal */
1083#define BJ_Locked 8 /* Locked for I/O during commit */ 1083#define BJ_Locked 8 /* Locked for I/O during commit */
1084#define BJ_Types 9 1084#define BJ_Types 9
1085 1085
1086extern int jbd_blocks_per_page(struct inode *inode); 1086extern int jbd_blocks_per_page(struct inode *inode);
1087 1087
1088#ifdef __KERNEL__ 1088#ifdef __KERNEL__
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 329ebcffa106..c8d5f207c3d4 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -115,6 +115,21 @@ static inline u64 get_jiffies_64(void)
115 ((long)(a) - (long)(b) >= 0)) 115 ((long)(a) - (long)(b) >= 0))
116#define time_before_eq(a,b) time_after_eq(b,a) 116#define time_before_eq(a,b) time_after_eq(b,a)
117 117
118/* Same as above, but does so with platform independent 64bit types.
119 * These must be used when utilizing jiffies_64 (i.e. return value of
120 * get_jiffies_64() */
121#define time_after64(a,b) \
122 (typecheck(__u64, a) && \
123 typecheck(__u64, b) && \
124 ((__s64)(b) - (__s64)(a) < 0))
125#define time_before64(a,b) time_after64(b,a)
126
127#define time_after_eq64(a,b) \
128 (typecheck(__u64, a) && \
129 typecheck(__u64, b) && \
130 ((__s64)(a) - (__s64)(b) >= 0))
131#define time_before_eq64(a,b) time_after_eq64(b,a)
132
118/* 133/*
119 * Have the 32 bit jiffies value wrap 5 minutes after boot 134 * Have the 32 bit jiffies value wrap 5 minutes after boot
120 * so jiffies wrap bugs show up earlier. 135 * so jiffies wrap bugs show up earlier.
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index e44a37e2c71c..4d00988dad03 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -187,6 +187,7 @@ extern void bust_spinlocks(int yes);
187extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */ 187extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in progress */
188extern int panic_timeout; 188extern int panic_timeout;
189extern int panic_on_oops; 189extern int panic_on_oops;
190extern int panic_on_unrecovered_nmi;
190extern int tainted; 191extern int tainted;
191extern const char *print_tainted(void); 192extern const char *print_tainted(void);
192extern void add_taint(unsigned); 193extern void add_taint(unsigned);
@@ -349,4 +350,11 @@ struct sysinfo {
349/* Trap pasters of __FUNCTION__ at compile-time */ 350/* Trap pasters of __FUNCTION__ at compile-time */
350#define __FUNCTION__ (__func__) 351#define __FUNCTION__ (__func__)
351 352
353/* This helps us to avoid #ifdef CONFIG_NUMA */
354#ifdef CONFIG_NUMA
355#define NUMA_BUILD 1
356#else
357#define NUMA_BUILD 0
358#endif
359
352#endif 360#endif
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 2d229327959e..bcd9cd173c2c 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -20,6 +20,7 @@
20#include <linux/types.h> 20#include <linux/types.h>
21#include <linux/list.h> 21#include <linux/list.h>
22#include <linux/sysfs.h> 22#include <linux/sysfs.h>
23#include <linux/compiler.h>
23#include <linux/spinlock.h> 24#include <linux/spinlock.h>
24#include <linux/rwsem.h> 25#include <linux/rwsem.h>
25#include <linux/kref.h> 26#include <linux/kref.h>
@@ -71,12 +72,12 @@ static inline const char * kobject_name(const struct kobject * kobj)
71extern void kobject_init(struct kobject *); 72extern void kobject_init(struct kobject *);
72extern void kobject_cleanup(struct kobject *); 73extern void kobject_cleanup(struct kobject *);
73 74
74extern int kobject_add(struct kobject *); 75extern int __must_check kobject_add(struct kobject *);
75extern void kobject_del(struct kobject *); 76extern void kobject_del(struct kobject *);
76 77
77extern int kobject_rename(struct kobject *, const char *new_name); 78extern int __must_check kobject_rename(struct kobject *, const char *new_name);
78 79
79extern int kobject_register(struct kobject *); 80extern int __must_check kobject_register(struct kobject *);
80extern void kobject_unregister(struct kobject *); 81extern void kobject_unregister(struct kobject *);
81 82
82extern struct kobject * kobject_get(struct kobject *); 83extern struct kobject * kobject_get(struct kobject *);
@@ -128,8 +129,8 @@ struct kset {
128 129
129 130
130extern void kset_init(struct kset * k); 131extern void kset_init(struct kset * k);
131extern int kset_add(struct kset * k); 132extern int __must_check kset_add(struct kset * k);
132extern int kset_register(struct kset * k); 133extern int __must_check kset_register(struct kset * k);
133extern void kset_unregister(struct kset * k); 134extern void kset_unregister(struct kset * k);
134 135
135static inline struct kset * to_kset(struct kobject * kobj) 136static inline struct kset * to_kset(struct kobject * kobj)
@@ -239,7 +240,7 @@ extern struct subsystem hypervisor_subsys;
239 (obj)->subsys.kset.kobj.kset = &(_subsys).kset 240 (obj)->subsys.kset.kobj.kset = &(_subsys).kset
240 241
241extern void subsystem_init(struct subsystem *); 242extern void subsystem_init(struct subsystem *);
242extern int subsystem_register(struct subsystem *); 243extern int __must_check subsystem_register(struct subsystem *);
243extern void subsystem_unregister(struct subsystem *); 244extern void subsystem_unregister(struct subsystem *);
244 245
245static inline struct subsystem * subsys_get(struct subsystem * s) 246static inline struct subsystem * subsys_get(struct subsystem * s)
@@ -258,7 +259,8 @@ struct subsys_attribute {
258 ssize_t (*store)(struct subsystem *, const char *, size_t); 259 ssize_t (*store)(struct subsystem *, const char *, size_t);
259}; 260};
260 261
261extern int subsys_create_file(struct subsystem * , struct subsys_attribute *); 262extern int __must_check subsys_create_file(struct subsystem * ,
263 struct subsys_attribute *);
262 264
263#if defined(CONFIG_HOTPLUG) 265#if defined(CONFIG_HOTPLUG)
264void kobject_uevent(struct kobject *kobj, enum kobject_action action); 266void kobject_uevent(struct kobject *kobj, enum kobject_action action);
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 932021f872d5..6c9873f88287 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -35,9 +35,13 @@
35#endif 35#endif
36 36
37#define KPROBE_ENTRY(name) \ 37#define KPROBE_ENTRY(name) \
38 .section .kprobes.text, "ax"; \ 38 .pushsection .kprobes.text, "ax"; \
39 ENTRY(name) 39 ENTRY(name)
40 40
41#define KPROBE_END(name) \
42 END(name); \
43 .popsection
44
41#ifndef END 45#ifndef END
42#define END(name) \ 46#define END(name) \
43 .size name, .-name 47 .size name, .-name
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 856f0ee7e84a..7b703b6d4358 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -16,6 +16,7 @@
16#include <linux/mutex.h> 16#include <linux/mutex.h>
17#include <linux/debug_locks.h> 17#include <linux/debug_locks.h>
18#include <linux/backing-dev.h> 18#include <linux/backing-dev.h>
19#include <linux/mm_types.h>
19 20
20struct mempolicy; 21struct mempolicy;
21struct anon_vma; 22struct anon_vma;
@@ -198,6 +199,7 @@ struct vm_operations_struct {
198 void (*open)(struct vm_area_struct * area); 199 void (*open)(struct vm_area_struct * area);
199 void (*close)(struct vm_area_struct * area); 200 void (*close)(struct vm_area_struct * area);
200 struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int *type); 201 struct page * (*nopage)(struct vm_area_struct * area, unsigned long address, int *type);
202 unsigned long (*nopfn)(struct vm_area_struct * area, unsigned long address);
201 int (*populate)(struct vm_area_struct * area, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int nonblock); 203 int (*populate)(struct vm_area_struct * area, unsigned long address, unsigned long len, pgprot_t prot, unsigned long pgoff, int nonblock);
202 204
203 /* notification that a previously read-only page is about to become 205 /* notification that a previously read-only page is about to become
@@ -215,62 +217,6 @@ struct vm_operations_struct {
215struct mmu_gather; 217struct mmu_gather;
216struct inode; 218struct inode;
217 219
218/*
219 * Each physical page in the system has a struct page associated with
220 * it to keep track of whatever it is we are using the page for at the
221 * moment. Note that we have no way to track which tasks are using
222 * a page, though if it is a pagecache page, rmap structures can tell us
223 * who is mapping it.
224 */
225struct page {
226 unsigned long flags; /* Atomic flags, some possibly
227 * updated asynchronously */
228 atomic_t _count; /* Usage count, see below. */
229 atomic_t _mapcount; /* Count of ptes mapped in mms,
230 * to show when page is mapped
231 * & limit reverse map searches.
232 */
233 union {
234 struct {
235 unsigned long private; /* Mapping-private opaque data:
236 * usually used for buffer_heads
237 * if PagePrivate set; used for
238 * swp_entry_t if PageSwapCache;
239 * indicates order in the buddy
240 * system if PG_buddy is set.
241 */
242 struct address_space *mapping; /* If low bit clear, points to
243 * inode address_space, or NULL.
244 * If page mapped as anonymous
245 * memory, low bit is set, and
246 * it points to anon_vma object:
247 * see PAGE_MAPPING_ANON below.
248 */
249 };
250#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
251 spinlock_t ptl;
252#endif
253 };
254 pgoff_t index; /* Our offset within mapping. */
255 struct list_head lru; /* Pageout list, eg. active_list
256 * protected by zone->lru_lock !
257 */
258 /*
259 * On machines where all RAM is mapped into kernel address space,
260 * we can simply calculate the virtual address. On machines with
261 * highmem some memory is mapped into kernel virtual memory
262 * dynamically, so we need a place to store that address.
263 * Note that this field could be 16 bits on x86 ... ;)
264 *
265 * Architectures with slow multiplication can define
266 * WANT_PAGE_VIRTUAL in asm/page.h
267 */
268#if defined(WANT_PAGE_VIRTUAL)
269 void *virtual; /* Kernel virtual address (NULL if
270 not kmapped, ie. highmem) */
271#endif /* WANT_PAGE_VIRTUAL */
272};
273
274#define page_private(page) ((page)->private) 220#define page_private(page) ((page)->private)
275#define set_page_private(page, v) ((page)->private = (v)) 221#define set_page_private(page, v) ((page)->private = (v))
276 222
@@ -501,7 +447,11 @@ static inline struct zone *page_zone(struct page *page)
501 447
502static inline unsigned long zone_to_nid(struct zone *zone) 448static inline unsigned long zone_to_nid(struct zone *zone)
503{ 449{
504 return zone->zone_pgdat->node_id; 450#ifdef CONFIG_NUMA
451 return zone->node;
452#else
453 return 0;
454#endif
505} 455}
506 456
507static inline unsigned long page_to_nid(struct page *page) 457static inline unsigned long page_to_nid(struct page *page)
@@ -546,11 +496,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
546 */ 496 */
547#include <linux/vmstat.h> 497#include <linux/vmstat.h>
548 498
549#ifndef CONFIG_DISCONTIGMEM
550/* The array of struct pages - for discontigmem use pgdat->lmem_map */
551extern struct page *mem_map;
552#endif
553
554static __always_inline void *lowmem_page_address(struct page *page) 499static __always_inline void *lowmem_page_address(struct page *page)
555{ 500{
556 return __va(page_to_pfn(page) << PAGE_SHIFT); 501 return __va(page_to_pfn(page) << PAGE_SHIFT);
@@ -650,6 +595,12 @@ static inline int page_mapped(struct page *page)
650#define NOPAGE_OOM ((struct page *) (-1)) 595#define NOPAGE_OOM ((struct page *) (-1))
651 596
652/* 597/*
598 * Error return values for the *_nopfn functions
599 */
600#define NOPFN_SIGBUS ((unsigned long) -1)
601#define NOPFN_OOM ((unsigned long) -2)
602
603/*
653 * Different kinds of faults, as returned by handle_mm_fault(). 604 * Different kinds of faults, as returned by handle_mm_fault().
654 * Used to decide whether a process gets delivered SIGBUS or 605 * Used to decide whether a process gets delivered SIGBUS or
655 * just gets major/minor fault counters bumped up. 606 * just gets major/minor fault counters bumped up.
@@ -937,6 +888,56 @@ extern void free_area_init(unsigned long * zones_size);
937extern void free_area_init_node(int nid, pg_data_t *pgdat, 888extern void free_area_init_node(int nid, pg_data_t *pgdat,
938 unsigned long * zones_size, unsigned long zone_start_pfn, 889 unsigned long * zones_size, unsigned long zone_start_pfn,
939 unsigned long *zholes_size); 890 unsigned long *zholes_size);
891#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
892/*
893 * With CONFIG_ARCH_POPULATES_NODE_MAP set, an architecture may initialise its
894 * zones, allocate the backing mem_map and account for memory holes in a more
895 * architecture independent manner. This is a substitute for creating the
896 * zone_sizes[] and zholes_size[] arrays and passing them to
897 * free_area_init_node()
898 *
899 * An architecture is expected to register range of page frames backed by
900 * physical memory with add_active_range() before calling
901 * free_area_init_nodes() passing in the PFN each zone ends at. At a basic
902 * usage, an architecture is expected to do something like
903 *
904 * unsigned long max_zone_pfns[MAX_NR_ZONES] = {max_dma, max_normal_pfn,
905 * max_highmem_pfn};
906 * for_each_valid_physical_page_range()
907 * add_active_range(node_id, start_pfn, end_pfn)
908 * free_area_init_nodes(max_zone_pfns);
909 *
910 * If the architecture guarantees that there are no holes in the ranges
911 * registered with add_active_range(), free_bootmem_active_regions()
912 * will call free_bootmem_node() for each registered physical page range.
913 * Similarly sparse_memory_present_with_active_regions() calls
914 * memory_present() for each range when SPARSEMEM is enabled.
915 *
916 * See mm/page_alloc.c for more information on each function exposed by
917 * CONFIG_ARCH_POPULATES_NODE_MAP
918 */
919extern void free_area_init_nodes(unsigned long *max_zone_pfn);
920extern void add_active_range(unsigned int nid, unsigned long start_pfn,
921 unsigned long end_pfn);
922extern void shrink_active_range(unsigned int nid, unsigned long old_end_pfn,
923 unsigned long new_end_pfn);
924extern void push_node_boundaries(unsigned int nid, unsigned long start_pfn,
925 unsigned long end_pfn);
926extern void remove_all_active_ranges(void);
927extern unsigned long absent_pages_in_range(unsigned long start_pfn,
928 unsigned long end_pfn);
929extern void get_pfn_range_for_nid(unsigned int nid,
930 unsigned long *start_pfn, unsigned long *end_pfn);
931extern unsigned long find_min_pfn_with_active_regions(void);
932extern unsigned long find_max_pfn_with_active_regions(void);
933extern void free_bootmem_with_active_regions(int nid,
934 unsigned long max_low_pfn);
935extern void sparse_memory_present_with_active_regions(int nid);
936#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
937extern int early_pfn_to_nid(unsigned long pfn);
938#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
939#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
940extern void set_dma_reserve(unsigned long new_dma_reserve);
940extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long); 941extern void memmap_init_zone(unsigned long, int, unsigned long, unsigned long);
941extern void setup_per_zone_pages_min(void); 942extern void setup_per_zone_pages_min(void);
942extern void mem_init(void); 943extern void mem_init(void);
@@ -1130,7 +1131,7 @@ void drop_slab(void);
1130extern int randomize_va_space; 1131extern int randomize_va_space;
1131#endif 1132#endif
1132 1133
1133const char *arch_vma_name(struct vm_area_struct *vma); 1134__attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma);
1134 1135
1135#endif /* __KERNEL__ */ 1136#endif /* __KERNEL__ */
1136#endif /* _LINUX_MM_H */ 1137#endif /* _LINUX_MM_H */
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
new file mode 100644
index 000000000000..c3852fd4a1cc
--- /dev/null
+++ b/include/linux/mm_types.h
@@ -0,0 +1,67 @@
1#ifndef _LINUX_MM_TYPES_H
2#define _LINUX_MM_TYPES_H
3
4#include <linux/types.h>
5#include <linux/threads.h>
6#include <linux/list.h>
7#include <linux/spinlock.h>
8
9struct address_space;
10
11/*
12 * Each physical page in the system has a struct page associated with
13 * it to keep track of whatever it is we are using the page for at the
14 * moment. Note that we have no way to track which tasks are using
15 * a page, though if it is a pagecache page, rmap structures can tell us
16 * who is mapping it.
17 */
18struct page {
19 unsigned long flags; /* Atomic flags, some possibly
20 * updated asynchronously */
21 atomic_t _count; /* Usage count, see below. */
22 atomic_t _mapcount; /* Count of ptes mapped in mms,
23 * to show when page is mapped
24 * & limit reverse map searches.
25 */
26 union {
27 struct {
28 unsigned long private; /* Mapping-private opaque data:
29 * usually used for buffer_heads
30 * if PagePrivate set; used for
31 * swp_entry_t if PageSwapCache;
32 * indicates order in the buddy
33 * system if PG_buddy is set.
34 */
35 struct address_space *mapping; /* If low bit clear, points to
36 * inode address_space, or NULL.
37 * If page mapped as anonymous
38 * memory, low bit is set, and
39 * it points to anon_vma object:
40 * see PAGE_MAPPING_ANON below.
41 */
42 };
43#if NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS
44 spinlock_t ptl;
45#endif
46 };
47 pgoff_t index; /* Our offset within mapping. */
48 struct list_head lru; /* Pageout list, eg. active_list
49 * protected by zone->lru_lock !
50 */
51 /*
52 * On machines where all RAM is mapped into kernel address space,
53 * we can simply calculate the virtual address. On machines with
54 * highmem some memory is mapped into kernel virtual memory
55 * dynamically, so we need a place to store that address.
56 * Note that this field could be 16 bits on x86 ... ;)
57 *
58 * Architectures with slow multiplication can define
59 * WANT_PAGE_VIRTUAL in asm/page.h
60 */
61#if defined(WANT_PAGE_VIRTUAL)
62 void *virtual; /* Kernel virtual address (NULL if
63 not kmapped, ie. highmem) */
64#endif /* WANT_PAGE_VIRTUAL */
65};
66
67#endif /* _LINUX_MM_TYPES_H */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 3693f1a52788..59855b8718a0 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -58,6 +58,7 @@ enum zone_stat_item {
58 NR_WRITEBACK, 58 NR_WRITEBACK,
59 NR_UNSTABLE_NFS, /* NFS unstable pages */ 59 NR_UNSTABLE_NFS, /* NFS unstable pages */
60 NR_BOUNCE, 60 NR_BOUNCE,
61 NR_VMSCAN_WRITE,
61#ifdef CONFIG_NUMA 62#ifdef CONFIG_NUMA
62 NUMA_HIT, /* allocated in intended node */ 63 NUMA_HIT, /* allocated in intended node */
63 NUMA_MISS, /* allocated in non intended node */ 64 NUMA_MISS, /* allocated in non intended node */
@@ -167,6 +168,7 @@ struct zone {
167 unsigned long lowmem_reserve[MAX_NR_ZONES]; 168 unsigned long lowmem_reserve[MAX_NR_ZONES];
168 169
169#ifdef CONFIG_NUMA 170#ifdef CONFIG_NUMA
171 int node;
170 /* 172 /*
171 * zone reclaim becomes active if more unmapped pages exist. 173 * zone reclaim becomes active if more unmapped pages exist.
172 */ 174 */
@@ -305,6 +307,18 @@ struct zonelist {
305 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited 307 struct zone *zones[MAX_NUMNODES * MAX_NR_ZONES + 1]; // NULL delimited
306}; 308};
307 309
310#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
311struct node_active_region {
312 unsigned long start_pfn;
313 unsigned long end_pfn;
314 int nid;
315};
316#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
317
318#ifndef CONFIG_DISCONTIGMEM
319/* The array of struct pages - for discontigmem use pgdat->lmem_map */
320extern struct page *mem_map;
321#endif
308 322
309/* 323/*
310 * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM 324 * The pg_data_t structure is used in machines with CONFIG_DISCONTIGMEM
@@ -518,7 +532,8 @@ extern struct zone *next_zone(struct zone *zone);
518 532
519#endif 533#endif
520 534
521#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID 535#if !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) && \
536 !defined(CONFIG_ARCH_POPULATES_NODE_MAP)
522#define early_pfn_to_nid(nid) (0UL) 537#define early_pfn_to_nid(nid) (0UL)
523#endif 538#endif
524 539
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index f7ca0b09075d..e0c393cc7240 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -308,4 +308,16 @@ struct input_device_id {
308 kernel_ulong_t driver_info; 308 kernel_ulong_t driver_info;
309}; 309};
310 310
311/* EISA */
312
313#define EISA_SIG_LEN 8
314
315/* The EISA signature, in ASCII form, null terminated */
316struct eisa_device_id {
317 char sig[EISA_SIG_LEN];
318 kernel_ulong_t driver_data;
319};
320
321#define EISA_DEVICE_MODALIAS_FMT "eisa:s%s"
322
311#endif /* LINUX_MOD_DEVICETABLE_H */ 323#endif /* LINUX_MOD_DEVICETABLE_H */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 43289127b458..13d6d4eb8b3a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -334,7 +334,6 @@ struct net_device
334 334
335 335
336 struct net_device_stats* (*get_stats)(struct net_device *dev); 336 struct net_device_stats* (*get_stats)(struct net_device *dev);
337 struct iw_statistics* (*get_wireless_stats)(struct net_device *dev);
338 337
339 /* List of functions to handle Wireless Extensions (instead of ioctl). 338 /* List of functions to handle Wireless Extensions (instead of ioctl).
340 * See <net/iw_handler.h> for details. Jean II */ 339 * See <net/iw_handler.h> for details. Jean II */
@@ -1016,7 +1015,8 @@ static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
1016} 1015}
1017 1016
1018/* On bonding slaves other than the currently active slave, suppress 1017/* On bonding slaves other than the currently active slave, suppress
1019 * duplicates except for 802.3ad ETH_P_SLOW and alb non-mcast/bcast. 1018 * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and
1019 * ARP on active-backup slaves with arp_validate enabled.
1020 */ 1020 */
1021static inline int skb_bond_should_drop(struct sk_buff *skb) 1021static inline int skb_bond_should_drop(struct sk_buff *skb)
1022{ 1022{
@@ -1025,6 +1025,10 @@ static inline int skb_bond_should_drop(struct sk_buff *skb)
1025 1025
1026 if (master && 1026 if (master &&
1027 (dev->priv_flags & IFF_SLAVE_INACTIVE)) { 1027 (dev->priv_flags & IFF_SLAVE_INACTIVE)) {
1028 if ((dev->priv_flags & IFF_SLAVE_NEEDARP) &&
1029 skb->protocol == __constant_htons(ETH_P_ARP))
1030 return 0;
1031
1028 if (master->priv_flags & IFF_MASTER_ALB) { 1032 if (master->priv_flags & IFF_MASTER_ALB) {
1029 if (skb->pkt_type != PACKET_BROADCAST && 1033 if (skb->pkt_type != PACKET_BROADCAST &&
1030 skb->pkt_type != PACKET_MULTICAST) 1034 skb->pkt_type != PACKET_MULTICAST)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 36f5bcf513b0..98c9b9f667a5 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -315,10 +315,6 @@ extern void nfs_end_data_update(struct inode *);
315extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx); 315extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
316extern void put_nfs_open_context(struct nfs_open_context *ctx); 316extern void put_nfs_open_context(struct nfs_open_context *ctx);
317extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode); 317extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, int mode);
318extern struct vfsmount *nfs_do_submount(const struct vfsmount *mnt_parent,
319 const struct dentry *dentry,
320 struct nfs_fh *fh,
321 struct nfs_fattr *fattr);
322 318
323/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */ 319/* linux/net/ipv4/ipconfig.c: trims ip addr off front of name, too. */
324extern u32 root_nfs_parse_addr(char *name); /*__init*/ 320extern u32 root_nfs_parse_addr(char *name); /*__init*/
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index f9edcd2ff3c8..31a3cb617ce0 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -269,14 +269,8 @@ fill_post_wcc(struct svc_fh *fhp)
269 fhp->fh_post_uid = inode->i_uid; 269 fhp->fh_post_uid = inode->i_uid;
270 fhp->fh_post_gid = inode->i_gid; 270 fhp->fh_post_gid = inode->i_gid;
271 fhp->fh_post_size = inode->i_size; 271 fhp->fh_post_size = inode->i_size;
272 if (inode->i_blksize) { 272 fhp->fh_post_blksize = BLOCK_SIZE;
273 fhp->fh_post_blksize = inode->i_blksize; 273 fhp->fh_post_blocks = inode->i_blocks;
274 fhp->fh_post_blocks = inode->i_blocks;
275 } else {
276 fhp->fh_post_blksize = BLOCK_SIZE;
277 /* how much do we care for accuracy with MinixFS? */
278 fhp->fh_post_blocks = (inode->i_size+511) >> 9;
279 }
280 fhp->fh_post_rdev[0] = htonl((u32)imajor(inode)); 274 fhp->fh_post_rdev[0] = htonl((u32)imajor(inode));
281 fhp->fh_post_rdev[1] = htonl((u32)iminor(inode)); 275 fhp->fh_post_rdev[1] = htonl((u32)iminor(inode));
282 fhp->fh_post_atime = inode->i_atime; 276 fhp->fh_post_atime = inode->i_atime;
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8565b81d7fbc..5c3a4176eb64 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -49,6 +49,7 @@
49#include <linux/types.h> 49#include <linux/types.h>
50#include <linux/ioport.h> 50#include <linux/ioport.h>
51#include <linux/list.h> 51#include <linux/list.h>
52#include <linux/compiler.h>
52#include <linux/errno.h> 53#include <linux/errno.h>
53#include <linux/device.h> 54#include <linux/device.h>
54 55
@@ -346,6 +347,8 @@ struct pci_driver {
346 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */ 347 int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
347 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */ 348 void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
348 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */ 349 int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
350 int (*suspend_late) (struct pci_dev *dev, pm_message_t state);
351 int (*resume_early) (struct pci_dev *dev);
349 int (*resume) (struct pci_dev *dev); /* Device woken up */ 352 int (*resume) (struct pci_dev *dev); /* Device woken up */
350 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */ 353 int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
351 void (*shutdown) (struct pci_dev *dev); 354 void (*shutdown) (struct pci_dev *dev);
@@ -353,6 +356,8 @@ struct pci_driver {
353 struct pci_error_handlers *err_handler; 356 struct pci_error_handlers *err_handler;
354 struct device_driver driver; 357 struct device_driver driver;
355 struct pci_dynids dynids; 358 struct pci_dynids dynids;
359
360 int multithread_probe;
356}; 361};
357 362
358#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) 363#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver)
@@ -401,7 +406,7 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */
401extern struct list_head pci_devices; /* list of all devices */ 406extern struct list_head pci_devices; /* list of all devices */
402 407
403void pcibios_fixup_bus(struct pci_bus *); 408void pcibios_fixup_bus(struct pci_bus *);
404int pcibios_enable_device(struct pci_dev *, int mask); 409int __must_check pcibios_enable_device(struct pci_dev *, int mask);
405char *pcibios_setup (char *str); 410char *pcibios_setup (char *str);
406 411
407/* Used only when drivers/pci/setup.c is used */ 412/* Used only when drivers/pci/setup.c is used */
@@ -428,7 +433,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
428struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); 433struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn);
429void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); 434void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
430unsigned int pci_scan_child_bus(struct pci_bus *bus); 435unsigned int pci_scan_child_bus(struct pci_bus *bus);
431void pci_bus_add_device(struct pci_dev *dev); 436int __must_check pci_bus_add_device(struct pci_dev *dev);
432void pci_read_bridge_bases(struct pci_bus *child); 437void pci_read_bridge_bases(struct pci_bus *child);
433struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); 438struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);
434int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); 439int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
@@ -436,6 +441,7 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
436extern void pci_dev_put(struct pci_dev *dev); 441extern void pci_dev_put(struct pci_dev *dev);
437extern void pci_remove_bus(struct pci_bus *b); 442extern void pci_remove_bus(struct pci_bus *b);
438extern void pci_remove_bus_device(struct pci_dev *dev); 443extern void pci_remove_bus_device(struct pci_dev *dev);
444extern void pci_stop_bus_device(struct pci_dev *dev);
439void pci_setup_cardbus(struct pci_bus *bus); 445void pci_setup_cardbus(struct pci_bus *bus);
440 446
441/* Generic PCI functions exported to card drivers */ 447/* Generic PCI functions exported to card drivers */
@@ -488,19 +494,19 @@ static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val
488 return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); 494 return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val);
489} 495}
490 496
491int pci_enable_device(struct pci_dev *dev); 497int __must_check pci_enable_device(struct pci_dev *dev);
492int pci_enable_device_bars(struct pci_dev *dev, int mask); 498int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask);
493void pci_disable_device(struct pci_dev *dev); 499void pci_disable_device(struct pci_dev *dev);
494void pci_set_master(struct pci_dev *dev); 500void pci_set_master(struct pci_dev *dev);
495#define HAVE_PCI_SET_MWI 501#define HAVE_PCI_SET_MWI
496int pci_set_mwi(struct pci_dev *dev); 502int __must_check pci_set_mwi(struct pci_dev *dev);
497void pci_clear_mwi(struct pci_dev *dev); 503void pci_clear_mwi(struct pci_dev *dev);
498void pci_intx(struct pci_dev *dev, int enable); 504void pci_intx(struct pci_dev *dev, int enable);
499int pci_set_dma_mask(struct pci_dev *dev, u64 mask); 505int pci_set_dma_mask(struct pci_dev *dev, u64 mask);
500int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask); 506int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask);
501void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 507void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
502int pci_assign_resource(struct pci_dev *dev, int i); 508int __must_check pci_assign_resource(struct pci_dev *dev, int i);
503int pci_assign_resource_fixed(struct pci_dev *dev, int i); 509int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i);
504void pci_restore_bars(struct pci_dev *dev); 510void pci_restore_bars(struct pci_dev *dev);
505 511
506/* ROM control related routines */ 512/* ROM control related routines */
@@ -526,23 +532,24 @@ void pdev_sort_resources(struct pci_dev *, struct resource_list *);
526void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *), 532void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
527 int (*)(struct pci_dev *, u8, u8)); 533 int (*)(struct pci_dev *, u8, u8));
528#define HAVE_PCI_REQ_REGIONS 2 534#define HAVE_PCI_REQ_REGIONS 2
529int pci_request_regions(struct pci_dev *, const char *); 535int __must_check pci_request_regions(struct pci_dev *, const char *);
530void pci_release_regions(struct pci_dev *); 536void pci_release_regions(struct pci_dev *);
531int pci_request_region(struct pci_dev *, int, const char *); 537int __must_check pci_request_region(struct pci_dev *, int, const char *);
532void pci_release_region(struct pci_dev *, int); 538void pci_release_region(struct pci_dev *, int);
533 539
534/* drivers/pci/bus.c */ 540/* drivers/pci/bus.c */
535int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res, 541int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
536 resource_size_t size, resource_size_t align, 542 struct resource *res, resource_size_t size,
537 resource_size_t min, unsigned int type_mask, 543 resource_size_t align, resource_size_t min,
538 void (*alignf)(void *, struct resource *, 544 unsigned int type_mask,
539 resource_size_t, resource_size_t), 545 void (*alignf)(void *, struct resource *,
540 void *alignf_data); 546 resource_size_t, resource_size_t),
547 void *alignf_data);
541void pci_enable_bridges(struct pci_bus *bus); 548void pci_enable_bridges(struct pci_bus *bus);
542 549
543/* Proper probing supporting hot-pluggable devices */ 550/* Proper probing supporting hot-pluggable devices */
544int __pci_register_driver(struct pci_driver *, struct module *); 551int __must_check __pci_register_driver(struct pci_driver *, struct module *);
545static inline int pci_register_driver(struct pci_driver *driver) 552static inline int __must_check pci_register_driver(struct pci_driver *driver)
546{ 553{
547 return __pci_register_driver(driver, THIS_MODULE); 554 return __pci_register_driver(driver, THIS_MODULE);
548} 555}
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 6a1e09834559..ab032ceafa84 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -1411,6 +1411,7 @@
1411#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 1411#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
1412#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 1412#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017
1413#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 1413#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103
1414#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
1414#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 1415#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
1415#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 1416#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
1416#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203 1417#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203
@@ -1482,9 +1483,6 @@
1482#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430 1483#define PCI_DEVICE_ID_MARVELL_GT64260 0x6430
1483#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460 1484#define PCI_DEVICE_ID_MARVELL_MV64360 0x6460
1484#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480 1485#define PCI_DEVICE_ID_MARVELL_MV64460 0x6480
1485#define PCI_DEVICE_ID_MARVELL_GT96100 0x9652
1486#define PCI_DEVICE_ID_MARVELL_GT96100A 0x9653
1487
1488 1486
1489#define PCI_VENDOR_ID_V3 0x11b0 1487#define PCI_VENDOR_ID_V3 0x11b0
1490#define PCI_DEVICE_ID_V3_V960 0x0001 1488#define PCI_DEVICE_ID_V3_V960 0x0001
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index 96930cb5927c..7d0e26cba420 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -196,7 +196,7 @@
196#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */ 196#define PCI_CAP_ID_MSI 0x05 /* Message Signalled Interrupts */
197#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */ 197#define PCI_CAP_ID_CHSWP 0x06 /* CompactPCI HotSwap */
198#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */ 198#define PCI_CAP_ID_PCIX 0x07 /* PCI-X */
199#define PCI_CAP_ID_HT_IRQCONF 0x08 /* HyperTransport IRQ Configuration */ 199#define PCI_CAP_ID_HT 0x08 /* HyperTransport */
200#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */ 200#define PCI_CAP_ID_VNDR 0x09 /* Vendor specific capability */
201#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */ 201#define PCI_CAP_ID_SHPC 0x0C /* PCI Standard Hot-Plug Controller */
202#define PCI_CAP_ID_EXP 0x10 /* PCI Express */ 202#define PCI_CAP_ID_EXP 0x10 /* PCI Express */
diff --git a/include/linux/pcieport_if.h b/include/linux/pcieport_if.h
index b44e01a70914..6cd91e3f9820 100644
--- a/include/linux/pcieport_if.h
+++ b/include/linux/pcieport_if.h
@@ -62,6 +62,12 @@ struct pcie_port_service_driver {
62 int (*suspend) (struct pcie_device *dev, pm_message_t state); 62 int (*suspend) (struct pcie_device *dev, pm_message_t state);
63 int (*resume) (struct pcie_device *dev); 63 int (*resume) (struct pcie_device *dev);
64 64
65 /* Service Error Recovery Handler */
66 struct pci_error_handlers *err_handler;
67
68 /* Link Reset Capability - AER service driver specific */
69 pci_ers_result_t (*reset_link) (struct pci_dev *dev);
70
65 const struct pcie_port_service_id *id_table; 71 const struct pcie_port_service_id *id_table;
66 struct device_driver driver; 72 struct device_driver driver;
67}; 73};
diff --git a/include/linux/pid.h b/include/linux/pid.h
index 29960b03bef7..93da7e2d9f30 100644
--- a/include/linux/pid.h
+++ b/include/linux/pid.h
@@ -76,6 +76,8 @@ extern int FASTCALL(attach_pid(struct task_struct *task,
76 enum pid_type type, int nr)); 76 enum pid_type type, int nr));
77 77
78extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type)); 78extern void FASTCALL(detach_pid(struct task_struct *task, enum pid_type));
79extern void FASTCALL(transfer_pid(struct task_struct *old,
80 struct task_struct *new, enum pid_type));
79 81
80/* 82/*
81 * look up a PID in the hash table. Must be called with the tasklist_lock 83 * look up a PID in the hash table. Must be called with the tasklist_lock
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 782090c68932..29cd6dee13db 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -49,6 +49,8 @@ struct platform_driver {
49 int (*remove)(struct platform_device *); 49 int (*remove)(struct platform_device *);
50 void (*shutdown)(struct platform_device *); 50 void (*shutdown)(struct platform_device *);
51 int (*suspend)(struct platform_device *, pm_message_t state); 51 int (*suspend)(struct platform_device *, pm_message_t state);
52 int (*suspend_late)(struct platform_device *, pm_message_t state);
53 int (*resume_early)(struct platform_device *);
52 int (*resume)(struct platform_device *); 54 int (*resume)(struct platform_device *);
53 struct device_driver driver; 55 struct device_driver driver;
54}; 56};
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 658c1b93d5bb..6b27e07aef19 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -142,29 +142,61 @@ typedef struct pm_message {
142} pm_message_t; 142} pm_message_t;
143 143
144/* 144/*
145 * There are 4 important states driver can be in: 145 * Several driver power state transitions are externally visible, affecting
146 * ON -- driver is working 146 * the state of pending I/O queues and (for drivers that touch hardware)
147 * FREEZE -- stop operations and apply whatever policy is applicable to a 147 * interrupts, wakeups, DMA, and other hardware state. There may also be
148 * suspended driver of that class, freeze queues for block like IDE 148 * internal transitions to various low power modes, which are transparent
149 * does, drop packets for ethernet, etc... stop DMA engine too etc... 149 * to the rest of the driver stack (such as a driver that's ON gating off
150 * so a consistent image can be saved; but do not power any hardware 150 * clocks which are not in active use).
151 * down.
152 * SUSPEND - like FREEZE, but hardware is doing as much powersaving as
153 * possible. Roughly pci D3.
154 * 151 *
155 * Unfortunately, current drivers only recognize numeric values 0 (ON) and 3 152 * One transition is triggered by resume(), after a suspend() call; the
156 * (SUSPEND). We'll need to fix the drivers. So yes, putting 3 to all different 153 * message is implicit:
157 * defines is intentional, and will go away as soon as drivers are fixed. Also 154 *
158 * note that typedef is neccessary, we'll probably want to switch to 155 * ON Driver starts working again, responding to hardware events
159 * typedef struct pm_message_t { int event; int flags; } pm_message_t 156 * and software requests. The hardware may have gone through
160 * or something similar soon. 157 * a power-off reset, or it may have maintained state from the
158 * previous suspend() which the driver will rely on while
159 * resuming. On most platforms, there are no restrictions on
160 * availability of resources like clocks during resume().
161 *
162 * Other transitions are triggered by messages sent using suspend(). All
163 * these transitions quiesce the driver, so that I/O queues are inactive.
164 * That commonly entails turning off IRQs and DMA; there may be rules
165 * about how to quiesce that are specific to the bus or the device's type.
166 * (For example, network drivers mark the link state.) Other details may
167 * differ according to the message:
168 *
169 * SUSPEND Quiesce, enter a low power device state appropriate for
170 * the upcoming system state (such as PCI_D3hot), and enable
171 * wakeup events as appropriate.
172 *
173 * FREEZE Quiesce operations so that a consistent image can be saved;
174 * but do NOT otherwise enter a low power device state, and do
175 * NOT emit system wakeup events.
176 *
177 * PRETHAW Quiesce as if for FREEZE; additionally, prepare for restoring
178 * the system from a snapshot taken after an earlier FREEZE.
179 * Some drivers will need to reset their hardware state instead
180 * of preserving it, to ensure that it's never mistaken for the
181 * state which that earlier snapshot had set up.
182 *
183 * A minimally power-aware driver treats all messages as SUSPEND, fully
184 * reinitializes its device during resume() -- whether or not it was reset
185 * during the suspend/resume cycle -- and can't issue wakeup events.
186 *
187 * More power-aware drivers may also use low power states at runtime as
188 * well as during system sleep states like PM_SUSPEND_STANDBY. They may
189 * be able to use wakeup events to exit from runtime low-power states,
190 * or from system low-power states such as standby or suspend-to-RAM.
161 */ 191 */
162 192
163#define PM_EVENT_ON 0 193#define PM_EVENT_ON 0
164#define PM_EVENT_FREEZE 1 194#define PM_EVENT_FREEZE 1
165#define PM_EVENT_SUSPEND 2 195#define PM_EVENT_SUSPEND 2
196#define PM_EVENT_PRETHAW 3
166 197
167#define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, }) 198#define PMSG_FREEZE ((struct pm_message){ .event = PM_EVENT_FREEZE, })
199#define PMSG_PRETHAW ((struct pm_message){ .event = PM_EVENT_PRETHAW, })
168#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, }) 200#define PMSG_SUSPEND ((struct pm_message){ .event = PM_EVENT_SUSPEND, })
169#define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, }) 201#define PMSG_ON ((struct pm_message){ .event = PM_EVENT_ON, })
170 202
@@ -190,6 +222,7 @@ extern void device_resume(void);
190extern suspend_disk_method_t pm_disk_mode; 222extern suspend_disk_method_t pm_disk_mode;
191 223
192extern int device_suspend(pm_message_t state); 224extern int device_suspend(pm_message_t state);
225extern int device_prepare_suspend(pm_message_t state);
193 226
194#define device_set_wakeup_enable(dev,val) \ 227#define device_set_wakeup_enable(dev,val) \
195 ((dev)->power.should_wakeup = !!(val)) 228 ((dev)->power.should_wakeup = !!(val))
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 3435ca38dd14..57f70bc8b24b 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -268,7 +268,9 @@ static inline struct proc_dir_entry *PDE(const struct inode *inode)
268struct proc_maps_private { 268struct proc_maps_private {
269 struct pid *pid; 269 struct pid *pid;
270 struct task_struct *task; 270 struct task_struct *task;
271#ifdef CONFIG_MMU
271 struct vm_area_struct *tail_vma; 272 struct vm_area_struct *tail_vma;
273#endif
272}; 274};
273 275
274#endif /* _LINUX_PROC_FS_H */ 276#endif /* _LINUX_PROC_FS_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 34ed0d99b1bd..9d4aa7f95bc8 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -819,6 +819,11 @@ struct task_struct {
819 unsigned did_exec:1; 819 unsigned did_exec:1;
820 pid_t pid; 820 pid_t pid;
821 pid_t tgid; 821 pid_t tgid;
822
823#ifdef CONFIG_CC_STACKPROTECTOR
824 /* Canary value for the -fstack-protector gcc feature */
825 unsigned long stack_canary;
826#endif
822 /* 827 /*
823 * pointers to (original) parent process, youngest child, younger sibling, 828 * pointers to (original) parent process, youngest child, younger sibling,
824 * older sibling, respectively. (p->father can be replaced with 829 * older sibling, respectively. (p->father can be replaced with
@@ -865,6 +870,15 @@ struct task_struct {
865 struct key *thread_keyring; /* keyring private to this thread */ 870 struct key *thread_keyring; /* keyring private to this thread */
866 unsigned char jit_keyring; /* default keyring to attach requested keys to */ 871 unsigned char jit_keyring; /* default keyring to attach requested keys to */
867#endif 872#endif
873 /*
874 * fpu_counter contains the number of consecutive context switches
875 * that the FPU is used. If this is over a threshold, the lazy fpu
876 * saving becomes unlazy to save the trap. This is an unsigned char
877 * so that after 256 times the counter wraps and the behavior turns
878 * lazy again; this to deal with bursty apps that only use FPU for
879 * a short time
880 */
881 unsigned char fpu_counter;
868 int oomkilladj; /* OOM kill score adjustment (bit shift). */ 882 int oomkilladj; /* OOM kill score adjustment (bit shift). */
869 char comm[TASK_COMM_LEN]; /* executable name excluding path 883 char comm[TASK_COMM_LEN]; /* executable name excluding path
870 - access with [gs]et_task_comm (which lock 884 - access with [gs]et_task_comm (which lock
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 66d6eb78d1c6..a96fd9310d55 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -60,7 +60,7 @@ extern void __init kmem_cache_init(void);
60extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, 60extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long,
61 void (*)(void *, kmem_cache_t *, unsigned long), 61 void (*)(void *, kmem_cache_t *, unsigned long),
62 void (*)(void *, kmem_cache_t *, unsigned long)); 62 void (*)(void *, kmem_cache_t *, unsigned long));
63extern int kmem_cache_destroy(kmem_cache_t *); 63extern void kmem_cache_destroy(kmem_cache_t *);
64extern int kmem_cache_shrink(kmem_cache_t *); 64extern int kmem_cache_shrink(kmem_cache_t *);
65extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t); 65extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
66extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); 66extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
@@ -249,7 +249,7 @@ struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t,
249 unsigned long, 249 unsigned long,
250 void (*)(void *, struct kmem_cache *, unsigned long), 250 void (*)(void *, struct kmem_cache *, unsigned long),
251 void (*)(void *, struct kmem_cache *, unsigned long)); 251 void (*)(void *, struct kmem_cache *, unsigned long));
252int kmem_cache_destroy(struct kmem_cache *c); 252void kmem_cache_destroy(struct kmem_cache *c);
253void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags); 253void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags);
254void *kmem_cache_zalloc(struct kmem_cache *, gfp_t); 254void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
255void kmem_cache_free(struct kmem_cache *c, void *b); 255void kmem_cache_free(struct kmem_cache *c, void *b);
diff --git a/include/linux/smb.h b/include/linux/smb.h
index 6df3b1501559..f098dff93f6b 100644
--- a/include/linux/smb.h
+++ b/include/linux/smb.h
@@ -89,7 +89,6 @@ struct smb_fattr {
89 struct timespec f_atime; 89 struct timespec f_atime;
90 struct timespec f_mtime; 90 struct timespec f_mtime;
91 struct timespec f_ctime; 91 struct timespec f_ctime;
92 unsigned long f_blksize;
93 unsigned long f_blocks; 92 unsigned long f_blocks;
94 int f_unix; 93 int f_unix;
95}; 94};
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index 9cc81e572224..50e2b01e517c 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -5,15 +5,16 @@
5struct stack_trace { 5struct stack_trace {
6 unsigned int nr_entries, max_entries; 6 unsigned int nr_entries, max_entries;
7 unsigned long *entries; 7 unsigned long *entries;
8 int skip; /* input argument: How many entries to skip */
9 int all_contexts; /* input argument: if true do than one stack */
8}; 10};
9 11
10extern void save_stack_trace(struct stack_trace *trace, 12extern void save_stack_trace(struct stack_trace *trace,
11 struct task_struct *task, int all_contexts, 13 struct task_struct *task);
12 unsigned int skip);
13 14
14extern void print_stack_trace(struct stack_trace *trace, int spaces); 15extern void print_stack_trace(struct stack_trace *trace, int spaces);
15#else 16#else
16# define save_stack_trace(trace, task, all, skip) do { } while (0) 17# define save_stack_trace(trace, task) do { } while (0)
17# define print_stack_trace(trace) do { } while (0) 18# define print_stack_trace(trace) do { } while (0)
18#endif 19#endif
19 20
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 008f04c56737..3f0f716225ec 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -53,6 +53,7 @@ struct mq_attr;
53struct compat_stat; 53struct compat_stat;
54struct compat_timeval; 54struct compat_timeval;
55struct robust_list_head; 55struct robust_list_head;
56struct getcpu_cache;
56 57
57#include <linux/types.h> 58#include <linux/types.h>
58#include <linux/aio_abi.h> 59#include <linux/aio_abi.h>
@@ -596,5 +597,6 @@ asmlinkage long sys_get_robust_list(int pid,
596 size_t __user *len_ptr); 597 size_t __user *len_ptr);
597asmlinkage long sys_set_robust_list(struct robust_list_head __user *head, 598asmlinkage long sys_set_robust_list(struct robust_list_head __user *head,
598 size_t len); 599 size_t len);
600asmlinkage long sys_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *cache);
599 601
600#endif 602#endif
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index eca555781d05..1b24bd45e080 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -150,6 +150,8 @@ enum
150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */ 150 KERN_IA64_UNALIGNED=72, /* int: ia64 unaligned userland trap enable */
151 KERN_COMPAT_LOG=73, /* int: print compat layer messages */ 151 KERN_COMPAT_LOG=73, /* int: print compat layer messages */
152 KERN_MAX_LOCK_DEPTH=74, 152 KERN_MAX_LOCK_DEPTH=74,
153 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
154 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
153}; 155};
154 156
155 157
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 1ea5d3cda6ae..6d5c43d31dec 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -10,6 +10,7 @@
10#ifndef _SYSFS_H_ 10#ifndef _SYSFS_H_
11#define _SYSFS_H_ 11#define _SYSFS_H_
12 12
13#include <linux/compiler.h>
13#include <asm/atomic.h> 14#include <asm/atomic.h>
14 15
15struct kobject; 16struct kobject;
@@ -86,40 +87,44 @@ struct sysfs_dirent {
86 87
87#ifdef CONFIG_SYSFS 88#ifdef CONFIG_SYSFS
88 89
89extern int 90extern int __must_check
90sysfs_create_dir(struct kobject *); 91sysfs_create_dir(struct kobject *);
91 92
92extern void 93extern void
93sysfs_remove_dir(struct kobject *); 94sysfs_remove_dir(struct kobject *);
94 95
95extern int 96extern int __must_check
96sysfs_rename_dir(struct kobject *, const char *new_name); 97sysfs_rename_dir(struct kobject *, const char *new_name);
97 98
98extern int 99extern int __must_check
99sysfs_create_file(struct kobject *, const struct attribute *); 100sysfs_create_file(struct kobject *, const struct attribute *);
100 101
101extern int 102extern int __must_check
102sysfs_update_file(struct kobject *, const struct attribute *); 103sysfs_update_file(struct kobject *, const struct attribute *);
103 104
104extern int 105extern int __must_check
105sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode); 106sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode);
106 107
107extern void 108extern void
108sysfs_remove_file(struct kobject *, const struct attribute *); 109sysfs_remove_file(struct kobject *, const struct attribute *);
109 110
110extern int 111extern int __must_check
111sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name); 112sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name);
112 113
113extern void 114extern void
114sysfs_remove_link(struct kobject *, const char * name); 115sysfs_remove_link(struct kobject *, const char * name);
115 116
116int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr); 117int __must_check sysfs_create_bin_file(struct kobject *kobj,
117int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr); 118 struct bin_attribute *attr);
119void sysfs_remove_bin_file(struct kobject *kobj, struct bin_attribute *attr);
118 120
119int sysfs_create_group(struct kobject *, const struct attribute_group *); 121int __must_check sysfs_create_group(struct kobject *,
122 const struct attribute_group *);
120void sysfs_remove_group(struct kobject *, const struct attribute_group *); 123void sysfs_remove_group(struct kobject *, const struct attribute_group *);
121void sysfs_notify(struct kobject * k, char *dir, char *attr); 124void sysfs_notify(struct kobject * k, char *dir, char *attr);
122 125
126extern int __must_check sysfs_init(void);
127
123#else /* CONFIG_SYSFS */ 128#else /* CONFIG_SYSFS */
124 129
125static inline int sysfs_create_dir(struct kobject * k) 130static inline int sysfs_create_dir(struct kobject * k)
@@ -191,6 +196,11 @@ static inline void sysfs_notify(struct kobject * k, char *dir, char *attr)
191{ 196{
192} 197}
193 198
199static inline int __must_check sysfs_init(void)
200{
201 return 0;
202}
203
194#endif /* CONFIG_SYSFS */ 204#endif /* CONFIG_SYSFS */
195 205
196#endif /* _SYSFS_H_ */ 206#endif /* _SYSFS_H_ */
diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 391e7ed1eb3f..a48d7f11c7be 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -19,4 +19,26 @@ static inline unsigned long __copy_from_user_nocache(void *to,
19 19
20#endif /* ARCH_HAS_NOCACHE_UACCESS */ 20#endif /* ARCH_HAS_NOCACHE_UACCESS */
21 21
22/**
23 * probe_kernel_address(): safely attempt to read from a location
24 * @addr: address to read from - its type is type typeof(retval)*
25 * @retval: read into this variable
26 *
27 * Safely read from address @addr into variable @revtal. If a kernel fault
28 * happens, handle that and return -EFAULT.
29 * We ensure that the __get_user() is executed in atomic context so that
30 * do_page_fault() doesn't attempt to take mmap_sem. This makes
31 * probe_kernel_address() suitable for use within regions where the caller
32 * already holds mmap_sem, or other locks which nest inside mmap_sem.
33 */
34#define probe_kernel_address(addr, retval) \
35 ({ \
36 long ret; \
37 \
38 inc_preempt_count(); \
39 ret = __get_user(retval, addr); \
40 dec_preempt_count(); \
41 ret; \
42 })
43
22#endif /* __LINUX_UACCESS_H__ */ 44#endif /* __LINUX_UACCESS_H__ */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index d2bd0c8e0154..0da15b0b02be 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -19,6 +19,7 @@
19#include <linux/fs.h> /* for struct file_operations */ 19#include <linux/fs.h> /* for struct file_operations */
20#include <linux/completion.h> /* for struct completion */ 20#include <linux/completion.h> /* for struct completion */
21#include <linux/sched.h> /* for current && schedule_timeout */ 21#include <linux/sched.h> /* for current && schedule_timeout */
22#include <linux/mutex.h> /* for struct mutex */
22 23
23struct usb_device; 24struct usb_device;
24struct usb_driver; 25struct usb_driver;
@@ -102,8 +103,13 @@ enum usb_interface_condition {
102 * number from the USB core by calling usb_register_dev(). 103 * number from the USB core by calling usb_register_dev().
103 * @condition: binding state of the interface: not bound, binding 104 * @condition: binding state of the interface: not bound, binding
104 * (in probe()), bound to a driver, or unbinding (in disconnect()) 105 * (in probe()), bound to a driver, or unbinding (in disconnect())
106 * @is_active: flag set when the interface is bound and not suspended.
107 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
108 * capability during autosuspend.
105 * @dev: driver model's view of this device 109 * @dev: driver model's view of this device
106 * @class_dev: driver model's class view of this device. 110 * @class_dev: driver model's class view of this device.
111 * @pm_usage_cnt: PM usage counter for this interface; autosuspend is not
112 * allowed unless the counter is 0.
107 * 113 *
108 * USB device drivers attach to interfaces on a physical device. Each 114 * USB device drivers attach to interfaces on a physical device. Each
109 * interface encapsulates a single high level function, such as feeding 115 * interface encapsulates a single high level function, such as feeding
@@ -142,8 +148,12 @@ struct usb_interface {
142 int minor; /* minor number this interface is 148 int minor; /* minor number this interface is
143 * bound to */ 149 * bound to */
144 enum usb_interface_condition condition; /* state of binding */ 150 enum usb_interface_condition condition; /* state of binding */
151 unsigned is_active:1; /* the interface is not suspended */
152 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
153
145 struct device dev; /* interface specific device info */ 154 struct device dev; /* interface specific device info */
146 struct class_device *class_dev; 155 struct class_device *class_dev;
156 int pm_usage_cnt; /* usage counter for autosuspend */
147}; 157};
148#define to_usb_interface(d) container_of(d, struct usb_interface, dev) 158#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
149#define interface_to_usbdev(intf) \ 159#define interface_to_usbdev(intf) \
@@ -254,8 +264,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
254 264
255/* ----------------------------------------------------------------------- */ 265/* ----------------------------------------------------------------------- */
256 266
257struct usb_operations;
258
259/* USB device number allocation bitmap */ 267/* USB device number allocation bitmap */
260struct usb_devmap { 268struct usb_devmap {
261 unsigned long devicemap[128 / (8*sizeof(unsigned long))]; 269 unsigned long devicemap[128 / (8*sizeof(unsigned long))];
@@ -268,6 +276,7 @@ struct usb_bus {
268 struct device *controller; /* host/master side hardware */ 276 struct device *controller; /* host/master side hardware */
269 int busnum; /* Bus number (in order of reg) */ 277 int busnum; /* Bus number (in order of reg) */
270 char *bus_name; /* stable id (PCI slot_name etc) */ 278 char *bus_name; /* stable id (PCI slot_name etc) */
279 u8 uses_dma; /* Does the host controller use DMA? */
271 u8 otg_port; /* 0, or number of OTG/HNP port */ 280 u8 otg_port; /* 0, or number of OTG/HNP port */
272 unsigned is_b_host:1; /* true during some HNP roleswitches */ 281 unsigned is_b_host:1; /* true during some HNP roleswitches */
273 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 282 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
@@ -276,10 +285,8 @@ struct usb_bus {
276 * round-robin allocation */ 285 * round-robin allocation */
277 286
278 struct usb_devmap devmap; /* device address allocation map */ 287 struct usb_devmap devmap; /* device address allocation map */
279 struct usb_operations *op; /* Operations (specific to the HC) */
280 struct usb_device *root_hub; /* Root hub */ 288 struct usb_device *root_hub; /* Root hub */
281 struct list_head bus_list; /* list of busses */ 289 struct list_head bus_list; /* list of busses */
282 void *hcpriv; /* Host Controller private data */
283 290
284 int bandwidth_allocated; /* on this bus: how much of the time 291 int bandwidth_allocated; /* on this bus: how much of the time
285 * reserved for periodic (intr/iso) 292 * reserved for periodic (intr/iso)
@@ -294,8 +301,6 @@ struct usb_bus {
294 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 301 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
295 302
296 struct class_device *class_dev; /* class device for this bus */ 303 struct class_device *class_dev; /* class device for this bus */
297 struct kref kref; /* reference counting for this bus */
298 void (*release)(struct usb_bus *bus);
299 304
300#if defined(CONFIG_USB_MON) 305#if defined(CONFIG_USB_MON)
301 struct mon_bus *mon_bus; /* non-null when associated */ 306 struct mon_bus *mon_bus; /* non-null when associated */
@@ -350,6 +355,7 @@ struct usb_device {
350 355
351 unsigned short bus_mA; /* Current available from the bus */ 356 unsigned short bus_mA; /* Current available from the bus */
352 u8 portnum; /* Parent port number (origin 1) */ 357 u8 portnum; /* Parent port number (origin 1) */
358 u8 level; /* Number of USB hub ancestors */
353 359
354 int have_langid; /* whether string_langid is valid */ 360 int have_langid; /* whether string_langid is valid */
355 int string_langid; /* language ID for strings */ 361 int string_langid; /* language ID for strings */
@@ -373,6 +379,15 @@ struct usb_device {
373 379
374 int maxchild; /* Number of ports if hub */ 380 int maxchild; /* Number of ports if hub */
375 struct usb_device *children[USB_MAXCHILDREN]; 381 struct usb_device *children[USB_MAXCHILDREN];
382
383#ifdef CONFIG_PM
384 struct work_struct autosuspend; /* for delayed autosuspends */
385 struct mutex pm_mutex; /* protects PM operations */
386 int pm_usage_cnt; /* usage counter for autosuspend */
387
388 unsigned auto_pm:1; /* autosuspend/resume in progress */
389 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */
390#endif
376}; 391};
377#define to_usb_device(d) container_of(d, struct usb_device, dev) 392#define to_usb_device(d) container_of(d, struct usb_device, dev)
378 393
@@ -384,7 +399,7 @@ extern void usb_put_dev(struct usb_device *dev);
384#define usb_unlock_device(udev) up(&(udev)->dev.sem) 399#define usb_unlock_device(udev) up(&(udev)->dev.sem)
385#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem) 400#define usb_trylock_device(udev) down_trylock(&(udev)->dev.sem)
386extern int usb_lock_device_for_reset(struct usb_device *udev, 401extern int usb_lock_device_for_reset(struct usb_device *udev,
387 struct usb_interface *iface); 402 const struct usb_interface *iface);
388 403
389/* USB port reset for device reinitialization */ 404/* USB port reset for device reinitialization */
390extern int usb_reset_device(struct usb_device *dev); 405extern int usb_reset_device(struct usb_device *dev);
@@ -393,6 +408,17 @@ extern int usb_reset_composite_device(struct usb_device *dev,
393 408
394extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); 409extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
395 410
411/* USB autosuspend and autoresume */
412#ifdef CONFIG_USB_SUSPEND
413extern int usb_autopm_get_interface(struct usb_interface *intf);
414extern void usb_autopm_put_interface(struct usb_interface *intf);
415
416#else
417#define usb_autopm_get_interface(intf) 0
418#define usb_autopm_put_interface(intf) do {} while (0)
419#endif
420
421
396/*-------------------------------------------------------------------------*/ 422/*-------------------------------------------------------------------------*/
397 423
398/* for drivers using iso endpoints */ 424/* for drivers using iso endpoints */
@@ -423,10 +449,10 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface,
423 449
424extern struct usb_interface *usb_find_interface(struct usb_driver *drv, 450extern struct usb_interface *usb_find_interface(struct usb_driver *drv,
425 int minor); 451 int minor);
426extern struct usb_interface *usb_ifnum_to_if(struct usb_device *dev, 452extern struct usb_interface *usb_ifnum_to_if(const struct usb_device *dev,
427 unsigned ifnum); 453 unsigned ifnum);
428extern struct usb_host_interface *usb_altnum_to_altsetting( 454extern struct usb_host_interface *usb_altnum_to_altsetting(
429 struct usb_interface *intf, unsigned int altnum); 455 const struct usb_interface *intf, unsigned int altnum);
430 456
431 457
432/** 458/**
@@ -464,6 +490,20 @@ static inline int usb_make_path (struct usb_device *dev, char *buf,
464 490
465/*-------------------------------------------------------------------------*/ 491/*-------------------------------------------------------------------------*/
466 492
493extern int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd);
494extern int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd);
495extern int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd);
496extern int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd);
497extern int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd);
498extern int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd);
499extern int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd);
500extern int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd);
501extern int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd);
502extern int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd);
503extern int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd);
504
505/*-------------------------------------------------------------------------*/
506
467#define USB_DEVICE_ID_MATCH_DEVICE \ 507#define USB_DEVICE_ID_MATCH_DEVICE \
468 (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) 508 (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
469#define USB_DEVICE_ID_MATCH_DEV_RANGE \ 509#define USB_DEVICE_ID_MATCH_DEV_RANGE \
@@ -540,7 +580,17 @@ struct usb_dynids {
540}; 580};
541 581
542/** 582/**
543 * struct usb_driver - identifies USB driver to usbcore 583 * struct usbdrv_wrap - wrapper for driver-model structure
584 * @driver: The driver-model core driver structure.
585 * @for_devices: Non-zero for device drivers, 0 for interface drivers.
586 */
587struct usbdrv_wrap {
588 struct device_driver driver;
589 int for_devices;
590};
591
592/**
593 * struct usb_driver - identifies USB interface driver to usbcore
544 * @name: The driver name should be unique among USB drivers, 594 * @name: The driver name should be unique among USB drivers,
545 * and should normally be the same as the module name. 595 * and should normally be the same as the module name.
546 * @probe: Called to see if the driver is willing to manage a particular 596 * @probe: Called to see if the driver is willing to manage a particular
@@ -567,12 +617,14 @@ struct usb_dynids {
567 * or your driver's probe function will never get called. 617 * or your driver's probe function will never get called.
568 * @dynids: used internally to hold the list of dynamically added device 618 * @dynids: used internally to hold the list of dynamically added device
569 * ids for this driver. 619 * ids for this driver.
570 * @driver: the driver model core driver structure. 620 * @drvwrap: Driver-model core structure wrapper.
571 * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be 621 * @no_dynamic_id: if set to 1, the USB core will not allow dynamic ids to be
572 * added to this driver by preventing the sysfs file from being created. 622 * added to this driver by preventing the sysfs file from being created.
623 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
624 * for interfaces bound to this driver.
573 * 625 *
574 * USB drivers must provide a name, probe() and disconnect() methods, 626 * USB interface drivers must provide a name, probe() and disconnect()
575 * and an id_table. Other driver fields are optional. 627 * methods, and an id_table. Other driver fields are optional.
576 * 628 *
577 * The id_table is used in hotplugging. It holds a set of descriptors, 629 * The id_table is used in hotplugging. It holds a set of descriptors,
578 * and specialized data may be associated with each entry. That table 630 * and specialized data may be associated with each entry. That table
@@ -606,10 +658,44 @@ struct usb_driver {
606 const struct usb_device_id *id_table; 658 const struct usb_device_id *id_table;
607 659
608 struct usb_dynids dynids; 660 struct usb_dynids dynids;
609 struct device_driver driver; 661 struct usbdrv_wrap drvwrap;
610 unsigned int no_dynamic_id:1; 662 unsigned int no_dynamic_id:1;
663 unsigned int supports_autosuspend:1;
611}; 664};
612#define to_usb_driver(d) container_of(d, struct usb_driver, driver) 665#define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver)
666
667/**
668 * struct usb_device_driver - identifies USB device driver to usbcore
669 * @name: The driver name should be unique among USB drivers,
670 * and should normally be the same as the module name.
671 * @probe: Called to see if the driver is willing to manage a particular
672 * device. If it is, probe returns zero and uses dev_set_drvdata()
673 * to associate driver-specific data with the device. If unwilling
674 * to manage the device, return a negative errno value.
675 * @disconnect: Called when the device is no longer accessible, usually
676 * because it has been (or is being) disconnected or the driver's
677 * module is being unloaded.
678 * @suspend: Called when the device is going to be suspended by the system.
679 * @resume: Called when the device is being resumed by the system.
680 * @drvwrap: Driver-model core structure wrapper.
681 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
682 * for devices bound to this driver.
683 *
684 * USB drivers must provide all the fields listed above except drvwrap.
685 */
686struct usb_device_driver {
687 const char *name;
688
689 int (*probe) (struct usb_device *udev);
690 void (*disconnect) (struct usb_device *udev);
691
692 int (*suspend) (struct usb_device *udev, pm_message_t message);
693 int (*resume) (struct usb_device *udev);
694 struct usbdrv_wrap drvwrap;
695 unsigned int supports_autosuspend:1;
696};
697#define to_usb_device_driver(d) container_of(d, struct usb_device_driver, \
698 drvwrap.driver)
613 699
614extern struct bus_type usb_bus_type; 700extern struct bus_type usb_bus_type;
615 701
@@ -633,13 +719,17 @@ struct usb_class_driver {
633 * use these in module_init()/module_exit() 719 * use these in module_init()/module_exit()
634 * and don't forget MODULE_DEVICE_TABLE(usb, ...) 720 * and don't forget MODULE_DEVICE_TABLE(usb, ...)
635 */ 721 */
636int usb_register_driver(struct usb_driver *, struct module *); 722extern int usb_register_driver(struct usb_driver *, struct module *);
637static inline int usb_register(struct usb_driver *driver) 723static inline int usb_register(struct usb_driver *driver)
638{ 724{
639 return usb_register_driver(driver, THIS_MODULE); 725 return usb_register_driver(driver, THIS_MODULE);
640} 726}
641extern void usb_deregister(struct usb_driver *); 727extern void usb_deregister(struct usb_driver *);
642 728
729extern int usb_register_device_driver(struct usb_device_driver *,
730 struct module *);
731extern void usb_deregister_device_driver(struct usb_device_driver *);
732
643extern int usb_register_dev(struct usb_interface *intf, 733extern int usb_register_dev(struct usb_interface *intf,
644 struct usb_class_driver *class_driver); 734 struct usb_class_driver *class_driver);
645extern void usb_deregister_dev(struct usb_interface *intf, 735extern void usb_deregister_dev(struct usb_interface *intf,
@@ -885,7 +975,7 @@ struct urb
885 * @setup_packet: pointer to the setup_packet buffer 975 * @setup_packet: pointer to the setup_packet buffer
886 * @transfer_buffer: pointer to the transfer buffer 976 * @transfer_buffer: pointer to the transfer buffer
887 * @buffer_length: length of the transfer buffer 977 * @buffer_length: length of the transfer buffer
888 * @complete: pointer to the usb_complete_t function 978 * @complete_fn: pointer to the usb_complete_t function
889 * @context: what to set the urb context to. 979 * @context: what to set the urb context to.
890 * 980 *
891 * Initializes a control urb with the proper information needed to submit 981 * Initializes a control urb with the proper information needed to submit
@@ -897,7 +987,7 @@ static inline void usb_fill_control_urb (struct urb *urb,
897 unsigned char *setup_packet, 987 unsigned char *setup_packet,
898 void *transfer_buffer, 988 void *transfer_buffer,
899 int buffer_length, 989 int buffer_length,
900 usb_complete_t complete, 990 usb_complete_t complete_fn,
901 void *context) 991 void *context)
902{ 992{
903 spin_lock_init(&urb->lock); 993 spin_lock_init(&urb->lock);
@@ -906,7 +996,7 @@ static inline void usb_fill_control_urb (struct urb *urb,
906 urb->setup_packet = setup_packet; 996 urb->setup_packet = setup_packet;
907 urb->transfer_buffer = transfer_buffer; 997 urb->transfer_buffer = transfer_buffer;
908 urb->transfer_buffer_length = buffer_length; 998 urb->transfer_buffer_length = buffer_length;
909 urb->complete = complete; 999 urb->complete = complete_fn;
910 urb->context = context; 1000 urb->context = context;
911} 1001}
912 1002
@@ -917,7 +1007,7 @@ static inline void usb_fill_control_urb (struct urb *urb,
917 * @pipe: the endpoint pipe 1007 * @pipe: the endpoint pipe
918 * @transfer_buffer: pointer to the transfer buffer 1008 * @transfer_buffer: pointer to the transfer buffer
919 * @buffer_length: length of the transfer buffer 1009 * @buffer_length: length of the transfer buffer
920 * @complete: pointer to the usb_complete_t function 1010 * @complete_fn: pointer to the usb_complete_t function
921 * @context: what to set the urb context to. 1011 * @context: what to set the urb context to.
922 * 1012 *
923 * Initializes a bulk urb with the proper information needed to submit it 1013 * Initializes a bulk urb with the proper information needed to submit it
@@ -928,7 +1018,7 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
928 unsigned int pipe, 1018 unsigned int pipe,
929 void *transfer_buffer, 1019 void *transfer_buffer,
930 int buffer_length, 1020 int buffer_length,
931 usb_complete_t complete, 1021 usb_complete_t complete_fn,
932 void *context) 1022 void *context)
933{ 1023{
934 spin_lock_init(&urb->lock); 1024 spin_lock_init(&urb->lock);
@@ -936,7 +1026,7 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
936 urb->pipe = pipe; 1026 urb->pipe = pipe;
937 urb->transfer_buffer = transfer_buffer; 1027 urb->transfer_buffer = transfer_buffer;
938 urb->transfer_buffer_length = buffer_length; 1028 urb->transfer_buffer_length = buffer_length;
939 urb->complete = complete; 1029 urb->complete = complete_fn;
940 urb->context = context; 1030 urb->context = context;
941} 1031}
942 1032
@@ -947,7 +1037,7 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
947 * @pipe: the endpoint pipe 1037 * @pipe: the endpoint pipe
948 * @transfer_buffer: pointer to the transfer buffer 1038 * @transfer_buffer: pointer to the transfer buffer
949 * @buffer_length: length of the transfer buffer 1039 * @buffer_length: length of the transfer buffer
950 * @complete: pointer to the usb_complete_t function 1040 * @complete_fn: pointer to the usb_complete_t function
951 * @context: what to set the urb context to. 1041 * @context: what to set the urb context to.
952 * @interval: what to set the urb interval to, encoded like 1042 * @interval: what to set the urb interval to, encoded like
953 * the endpoint descriptor's bInterval value. 1043 * the endpoint descriptor's bInterval value.
@@ -963,7 +1053,7 @@ static inline void usb_fill_int_urb (struct urb *urb,
963 unsigned int pipe, 1053 unsigned int pipe,
964 void *transfer_buffer, 1054 void *transfer_buffer,
965 int buffer_length, 1055 int buffer_length,
966 usb_complete_t complete, 1056 usb_complete_t complete_fn,
967 void *context, 1057 void *context,
968 int interval) 1058 int interval)
969{ 1059{
@@ -972,7 +1062,7 @@ static inline void usb_fill_int_urb (struct urb *urb,
972 urb->pipe = pipe; 1062 urb->pipe = pipe;
973 urb->transfer_buffer = transfer_buffer; 1063 urb->transfer_buffer = transfer_buffer;
974 urb->transfer_buffer_length = buffer_length; 1064 urb->transfer_buffer_length = buffer_length;
975 urb->complete = complete; 1065 urb->complete = complete_fn;
976 urb->context = context; 1066 urb->context = context;
977 if (dev->speed == USB_SPEED_HIGH) 1067 if (dev->speed == USB_SPEED_HIGH)
978 urb->interval = 1 << (interval - 1); 1068 urb->interval = 1 << (interval - 1);
@@ -990,7 +1080,6 @@ extern int usb_submit_urb(struct urb *urb, gfp_t mem_flags);
990extern int usb_unlink_urb(struct urb *urb); 1080extern int usb_unlink_urb(struct urb *urb);
991extern void usb_kill_urb(struct urb *urb); 1081extern void usb_kill_urb(struct urb *urb);
992 1082
993#define HAVE_USB_BUFFERS
994void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1083void *usb_buffer_alloc (struct usb_device *dev, size_t size,
995 gfp_t mem_flags, dma_addr_t *dma); 1084 gfp_t mem_flags, dma_addr_t *dma);
996void usb_buffer_free (struct usb_device *dev, size_t size, 1085void usb_buffer_free (struct usb_device *dev, size_t size,
@@ -1003,14 +1092,14 @@ void usb_buffer_unmap (struct urb *urb);
1003#endif 1092#endif
1004 1093
1005struct scatterlist; 1094struct scatterlist;
1006int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe, 1095int usb_buffer_map_sg(const struct usb_device *dev, unsigned pipe,
1007 struct scatterlist *sg, int nents); 1096 struct scatterlist *sg, int nents);
1008#if 0 1097#if 0
1009void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe, 1098void usb_buffer_dmasync_sg(const struct usb_device *dev, unsigned pipe,
1010 struct scatterlist *sg, int n_hw_ents); 1099 struct scatterlist *sg, int n_hw_ents);
1011#endif 1100#endif
1012void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe, 1101void usb_buffer_unmap_sg(const struct usb_device *dev, unsigned pipe,
1013 struct scatterlist *sg, int n_hw_ents); 1102 struct scatterlist *sg, int n_hw_ents);
1014 1103
1015/*-------------------------------------------------------------------* 1104/*-------------------------------------------------------------------*
1016 * SYNCHRONOUS CALL SUPPORT * 1105 * SYNCHRONOUS CALL SUPPORT *
@@ -1038,6 +1127,9 @@ extern int usb_clear_halt(struct usb_device *dev, int pipe);
1038extern int usb_reset_configuration(struct usb_device *dev); 1127extern int usb_reset_configuration(struct usb_device *dev);
1039extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate); 1128extern int usb_set_interface(struct usb_device *dev, int ifnum, int alternate);
1040 1129
1130/* this request isn't really synchronous, but it belongs with the others */
1131extern int usb_driver_set_configuration(struct usb_device *udev, int config);
1132
1041/* 1133/*
1042 * timeouts, in milliseconds, used for sending/receiving control messages 1134 * timeouts, in milliseconds, used for sending/receiving control messages
1043 * they typically complete within a few frames (msec) after they're issued 1135 * they typically complete within a few frames (msec) after they're issued
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
new file mode 100644
index 000000000000..6bd235994dc2
--- /dev/null
+++ b/include/linux/usb/audio.h
@@ -0,0 +1,53 @@
1/*
2 * <linux/usb/audio.h> -- USB Audio definitions.
3 *
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
7 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This file holds USB constants and structures defined
12 * by the USB Device Class Definition for Audio Devices.
13 * Comments below reference relevant sections of that document:
14 *
15 * http://www.usb.org/developers/devclass_docs/audio10.pdf
16 */
17
18#ifndef __LINUX_USB_AUDIO_H
19#define __LINUX_USB_AUDIO_H
20
21#include <linux/types.h>
22
23/* A.2 Audio Interface Subclass Codes */
24#define USB_SUBCLASS_AUDIOCONTROL 0x01
25#define USB_SUBCLASS_AUDIOSTREAMING 0x02
26#define USB_SUBCLASS_MIDISTREAMING 0x03
27
28/* 4.3.2 Class-Specific AC Interface Descriptor */
29struct usb_ac_header_descriptor {
30 __u8 bLength; // 8+n
31 __u8 bDescriptorType; // USB_DT_CS_INTERFACE
32 __u8 bDescriptorSubtype; // USB_MS_HEADER
33 __le16 bcdADC; // 0x0100
34 __le16 wTotalLength; // includes Unit and Terminal desc.
35 __u8 bInCollection; // n
36 __u8 baInterfaceNr[]; // [n]
37} __attribute__ ((packed));
38
39#define USB_DT_AC_HEADER_SIZE(n) (8+(n))
40
41/* As above, but more useful for defining your own descriptors: */
42#define DECLARE_USB_AC_HEADER_DESCRIPTOR(n) \
43struct usb_ac_header_descriptor_##n { \
44 __u8 bLength; \
45 __u8 bDescriptorType; \
46 __u8 bDescriptorSubtype; \
47 __le16 bcdADC; \
48 __le16 wTotalLength; \
49 __u8 bInCollection; \
50 __u8 baInterfaceNr[n]; \
51} __attribute__ ((packed))
52
53#endif
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
new file mode 100644
index 000000000000..11a97d5ffd34
--- /dev/null
+++ b/include/linux/usb/midi.h
@@ -0,0 +1,112 @@
1/*
2 * <linux/usb/midi.h> -- USB MIDI definitions.
3 *
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
7 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This file holds USB constants and structures defined
12 * by the USB Device Class Definition for MIDI Devices.
13 * Comments below reference relevant sections of that document:
14 *
15 * http://www.usb.org/developers/devclass_docs/midi10.pdf
16 */
17
18#ifndef __LINUX_USB_MIDI_H
19#define __LINUX_USB_MIDI_H
20
21#include <linux/types.h>
22
23/* A.1 MS Class-Specific Interface Descriptor Subtypes */
24#define USB_MS_HEADER 0x01
25#define USB_MS_MIDI_IN_JACK 0x02
26#define USB_MS_MIDI_OUT_JACK 0x03
27#define USB_MS_ELEMENT 0x04
28
29/* A.2 MS Class-Specific Endpoint Descriptor Subtypes */
30#define USB_MS_GENERAL 0x01
31
32/* A.3 MS MIDI IN and OUT Jack Types */
33#define USB_MS_EMBEDDED 0x01
34#define USB_MS_EXTERNAL 0x02
35
36/* 6.1.2.1 Class-Specific MS Interface Header Descriptor */
37struct usb_ms_header_descriptor {
38 __u8 bLength;
39 __u8 bDescriptorType;
40 __u8 bDescriptorSubtype;
41 __le16 bcdMSC;
42 __le16 wTotalLength;
43} __attribute__ ((packed));
44
45#define USB_DT_MS_HEADER_SIZE 7
46
47/* 6.1.2.2 MIDI IN Jack Descriptor */
48struct usb_midi_in_jack_descriptor {
49 __u8 bLength;
50 __u8 bDescriptorType; // USB_DT_CS_INTERFACE
51 __u8 bDescriptorSubtype; // USB_MS_MIDI_IN_JACK
52 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL
53 __u8 bJackID;
54 __u8 iJack;
55} __attribute__ ((packed));
56
57#define USB_DT_MIDI_IN_SIZE 6
58
59struct usb_midi_source_pin {
60 __u8 baSourceID;
61 __u8 baSourcePin;
62} __attribute__ ((packed));
63
64/* 6.1.2.3 MIDI OUT Jack Descriptor */
65struct usb_midi_out_jack_descriptor {
66 __u8 bLength;
67 __u8 bDescriptorType; // USB_DT_CS_INTERFACE
68 __u8 bDescriptorSubtype; // USB_MS_MIDI_OUT_JACK
69 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL
70 __u8 bJackID;
71 __u8 bNrInputPins; // p
72 struct usb_midi_source_pin pins[]; // [p]
73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */
74} __attribute__ ((packed));
75
76#define USB_DT_MIDI_OUT_SIZE(p) (7 + 2 * (p))
77
78/* As above, but more useful for defining your own descriptors: */
79#define DECLARE_USB_MIDI_OUT_JACK_DESCRIPTOR(p) \
80struct usb_midi_out_jack_descriptor_##p { \
81 __u8 bLength; \
82 __u8 bDescriptorType; \
83 __u8 bDescriptorSubtype; \
84 __u8 bJackType; \
85 __u8 bJackID; \
86 __u8 bNrInputPins; \
87 struct usb_midi_source_pin pins[p]; \
88 __u8 iJack; \
89} __attribute__ ((packed))
90
91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
92struct usb_ms_endpoint_descriptor {
93 __u8 bLength; // 4+n
94 __u8 bDescriptorType; // USB_DT_CS_ENDPOINT
95 __u8 bDescriptorSubtype; // USB_MS_GENERAL
96 __u8 bNumEmbMIDIJack; // n
97 __u8 baAssocJackID[]; // [n]
98} __attribute__ ((packed));
99
100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
101
102/* As above, but more useful for defining your own descriptors: */
103#define DECLARE_USB_MS_ENDPOINT_DESCRIPTOR(n) \
104struct usb_ms_endpoint_descriptor_##n { \
105 __u8 bLength; \
106 __u8 bDescriptorType; \
107 __u8 bDescriptorSubtype; \
108 __u8 bNumEmbMIDIJack; \
109 __u8 baAssocJackID[n]; \
110} __attribute__ ((packed))
111
112#endif
diff --git a/include/linux/usb_otg.h b/include/linux/usb/otg.h
index f827f6e203c2..9897f7a818c5 100644
--- a/include/linux/usb_otg.h
+++ b/include/linux/usb/otg.h
@@ -1,4 +1,4 @@
1// include/linux/usb_otg.h 1// include/linux/usb/otg.h
2 2
3/* 3/*
4 * These APIs may be used between USB controllers. USB device drivers 4 * These APIs may be used between USB controllers. USB device drivers
@@ -52,7 +52,7 @@ struct otg_transceiver {
52 u16 port_change; 52 u16 port_change;
53 53
54 /* bind/unbind the host controller */ 54 /* bind/unbind the host controller */
55 int (*set_host)(struct otg_transceiver *otg, 55 int (*set_host)(struct otg_transceiver *otg,
56 struct usb_bus *host); 56 struct usb_bus *host);
57 57
58 /* bind/unbind the peripheral controller */ 58 /* bind/unbind the peripheral controller */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index e7fc5fed5b98..2ae76fe52ff7 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -108,6 +108,9 @@ enum { US_DO_ALL_FLAGS };
108#ifdef CONFIG_USB_STORAGE_ALAUDA 108#ifdef CONFIG_USB_STORAGE_ALAUDA
109#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */ 109#define US_PR_ALAUDA 0xf4 /* Alauda chipsets */
110#endif 110#endif
111#ifdef CONFIG_USB_STORAGE_KARMA
112#define US_PR_KARMA 0xf5 /* Rio Karma */
113#endif
111 114
112#define US_PR_DEVICE 0xff /* Use device's value */ 115#define US_PR_DEVICE 0xff /* Use device's value */
113 116
diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
index 46919f9f5eb3..4d0909e53595 100644
--- a/include/linux/vermagic.h
+++ b/include/linux/vermagic.h
@@ -24,5 +24,5 @@
24#define VERMAGIC_STRING \ 24#define VERMAGIC_STRING \
25 UTS_RELEASE " " \ 25 UTS_RELEASE " " \
26 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \ 26 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
27 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_ARCH_VERMAGIC \ 27 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_ARCH_VERMAGIC
28 "gcc-" __stringify(__GNUC__) "." __stringify(__GNUC_MINOR__) 28
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index dee88c6b6fa7..ce5f1482e6be 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -62,7 +62,6 @@ extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
62extern struct vm_struct *get_vm_area_node(unsigned long size, 62extern struct vm_struct *get_vm_area_node(unsigned long size,
63 unsigned long flags, int node); 63 unsigned long flags, int node);
64extern struct vm_struct *remove_vm_area(void *addr); 64extern struct vm_struct *remove_vm_area(void *addr);
65extern struct vm_struct *__remove_vm_area(void *addr);
66extern int map_vm_area(struct vm_struct *area, pgprot_t prot, 65extern int map_vm_area(struct vm_struct *area, pgprot_t prot,
67 struct page ***pages); 66 struct page ***pages);
68extern void unmap_vm_area(struct vm_struct *area); 67extern void unmap_vm_area(struct vm_struct *area);
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 13588564b42b..a50a0130fd9e 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * This file define a set of standard wireless extensions 2 * This file define a set of standard wireless extensions
3 * 3 *
4 * Version : 20 17.2.06 4 * Version : 21 14.3.06
5 * 5 *
6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com> 6 * Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved. 7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
@@ -69,9 +69,14 @@
69 69
70/***************************** INCLUDES *****************************/ 70/***************************** INCLUDES *****************************/
71 71
72/* This header is used in user-space, therefore need to be sanitised
73 * for that purpose. Those includes are usually not compatible with glibc.
74 * To know which includes to use in user-space, check iwlib.h. */
75#ifdef __KERNEL__
72#include <linux/types.h> /* for "caddr_t" et al */ 76#include <linux/types.h> /* for "caddr_t" et al */
73#include <linux/socket.h> /* for "struct sockaddr" et al */ 77#include <linux/socket.h> /* for "struct sockaddr" et al */
74#include <linux/if.h> /* for IFNAMSIZ and co... */ 78#include <linux/if.h> /* for IFNAMSIZ and co... */
79#endif /* __KERNEL__ */
75 80
76/***************************** VERSION *****************************/ 81/***************************** VERSION *****************************/
77/* 82/*
@@ -80,7 +85,7 @@
80 * (there is some stuff that will be added in the future...) 85 * (there is some stuff that will be added in the future...)
81 * I just plan to increment with each new version. 86 * I just plan to increment with each new version.
82 */ 87 */
83#define WIRELESS_EXT 20 88#define WIRELESS_EXT 21
84 89
85/* 90/*
86 * Changes : 91 * Changes :
@@ -208,6 +213,14 @@
208 * V19 to V20 213 * V19 to V20
209 * ---------- 214 * ----------
210 * - RtNetlink requests support (SET/GET) 215 * - RtNetlink requests support (SET/GET)
216 *
217 * V20 to V21
218 * ----------
219 * - Remove (struct net_device *)->get_wireless_stats()
220 * - Change length in ESSID and NICK to strlen() instead of strlen()+1
221 * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
222 * - Power/Retry relative values no longer * 100000
223 * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI
211 */ 224 */
212 225
213/**************************** CONSTANTS ****************************/ 226/**************************** CONSTANTS ****************************/
@@ -448,6 +461,7 @@
448#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */ 461#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
449#define IW_QUAL_LEVEL_INVALID 0x20 462#define IW_QUAL_LEVEL_INVALID 0x20
450#define IW_QUAL_NOISE_INVALID 0x40 463#define IW_QUAL_NOISE_INVALID 0x40
464#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
451#define IW_QUAL_ALL_INVALID 0x70 465#define IW_QUAL_ALL_INVALID 0x70
452 466
453/* Frequency flags */ 467/* Frequency flags */
@@ -500,10 +514,12 @@
500#define IW_RETRY_TYPE 0xF000 /* Type of parameter */ 514#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
501#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/ 515#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
502#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */ 516#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
503#define IW_RETRY_MODIFIER 0x000F /* Modify a parameter */ 517#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
504#define IW_RETRY_MIN 0x0001 /* Value is a minimum */ 518#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
505#define IW_RETRY_MAX 0x0002 /* Value is a maximum */ 519#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
506#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */ 520#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
521#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
522#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
507 523
508/* Scanning request flags */ 524/* Scanning request flags */
509#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */ 525#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
@@ -1017,7 +1033,7 @@ struct iw_range
1017 /* Note : this frequency list doesn't need to fit channel numbers, 1033 /* Note : this frequency list doesn't need to fit channel numbers,
1018 * because each entry contain its channel index */ 1034 * because each entry contain its channel index */
1019 1035
1020 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */ 1036 __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
1021}; 1037};
1022 1038
1023/* 1039/*
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index 810462f8a374..bb495b7f4680 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -341,7 +341,7 @@ extern int video_usercopy(struct inode *inode, struct file *file,
341extern struct video_device* video_devdata(struct file*); 341extern struct video_device* video_devdata(struct file*);
342 342
343#define to_video_device(cd) container_of(cd, struct video_device, class_dev) 343#define to_video_device(cd) container_of(cd, struct video_device, class_dev)
344static inline int 344static inline int __must_check
345video_device_create_file(struct video_device *vfd, 345video_device_create_file(struct video_device *vfd,
346 struct class_device_attribute *attr) 346 struct class_device_attribute *attr)
347{ 347{
diff --git a/init/Kconfig b/init/Kconfig
index 9a7656f0b5ec..4381006dd666 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -273,21 +273,24 @@ config UID16
273 This enables the legacy 16-bit UID syscall wrappers. 273 This enables the legacy 16-bit UID syscall wrappers.
274 274
275config SYSCTL 275config SYSCTL
276 bool "Sysctl support" if EMBEDDED 276 bool
277 default y 277
278config SYSCTL_SYSCALL
279 bool "Sysctl syscall support"
280 default n
281 select SYSCTL
278 ---help--- 282 ---help---
279 The sysctl interface provides a means of dynamically changing 283 Enable the deprecated sysctl system call. sys_sysctl uses
280 certain kernel parameters and variables on the fly without requiring 284 binary paths that have been found to be a major pain to maintain
281 a recompile of the kernel or reboot of the system. The primary 285 and use. The interface in /proc/sys is now the primary and what
282 interface consists of a system call, but if you say Y to "/proc 286 everyone uses.
283 file system support", a tree of modifiable sysctl entries will be 287
284 generated beneath the /proc/sys directory. They are explained in the 288 Nothing has been using the binary sysctl interface for some time
285 files in <file:Documentation/sysctl/>. Note that enabling this 289 time now so nothing should break if you disable sysctl syscall
286 option will enlarge the kernel by at least 8 KB. 290 support, and you kernel will get marginally smaller.
287 291
288 As it is generally a good thing, you should say Y here unless 292 Unless you have an application that uses the sys_syscall interface
289 building a kernel for install/rescue disks or your system is very 293 you should probably say N here.
290 limited in memory.
291 294
292config KALLSYMS 295config KALLSYMS
293 bool "Load all symbols for debugging/kksymoops" if EMBEDDED 296 bool "Load all symbols for debugging/kksymoops" if EMBEDDED
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 94aeec7aa917..b290aadb1d3f 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -8,6 +8,7 @@
8#include <linux/security.h> 8#include <linux/security.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/mount.h> 10#include <linux/mount.h>
11#include <linux/device.h>
11 12
12#include <linux/nfs_fs.h> 13#include <linux/nfs_fs.h>
13#include <linux/nfs_fs_sb.h> 14#include <linux/nfs_fs_sb.h>
@@ -403,6 +404,10 @@ void __init prepare_namespace(void)
403 ssleep(root_delay); 404 ssleep(root_delay);
404 } 405 }
405 406
407 /* wait for the known devices to complete their probing */
408 while (driver_probe_done() != 0)
409 msleep(100);
410
406 md_run_setup(); 411 md_run_setup();
407 412
408 if (saved_root_name[0]) { 413 if (saved_root_name[0]) {
diff --git a/init/main.c b/init/main.c
index 8651a720a092..0766e69712b2 100644
--- a/init/main.c
+++ b/init/main.c
@@ -128,6 +128,18 @@ static char *ramdisk_execute_command;
128static unsigned int max_cpus = NR_CPUS; 128static unsigned int max_cpus = NR_CPUS;
129 129
130/* 130/*
131 * If set, this is an indication to the drivers that reset the underlying
132 * device before going ahead with the initialization otherwise driver might
133 * rely on the BIOS and skip the reset operation.
134 *
135 * This is useful if kernel is booting in an unreliable environment.
136 * For ex. kdump situaiton where previous kernel has crashed, BIOS has been
137 * skipped and devices will be in unknown state.
138 */
139unsigned int reset_devices;
140EXPORT_SYMBOL(reset_devices);
141
142/*
131 * Setup routine for controlling SMP activation 143 * Setup routine for controlling SMP activation
132 * 144 *
133 * Command-line option of "nosmp" or "maxcpus=0" will disable SMP 145 * Command-line option of "nosmp" or "maxcpus=0" will disable SMP
@@ -153,6 +165,14 @@ static int __init maxcpus(char *str)
153 165
154__setup("maxcpus=", maxcpus); 166__setup("maxcpus=", maxcpus);
155 167
168static int __init set_reset_devices(char *str)
169{
170 reset_devices = 1;
171 return 1;
172}
173
174__setup("reset_devices", set_reset_devices);
175
156static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, }; 176static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
157char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, }; 177char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
158static const char *panic_later, *panic_param; 178static const char *panic_later, *panic_param;
@@ -162,16 +182,19 @@ extern struct obs_kernel_param __setup_start[], __setup_end[];
162static int __init obsolete_checksetup(char *line) 182static int __init obsolete_checksetup(char *line)
163{ 183{
164 struct obs_kernel_param *p; 184 struct obs_kernel_param *p;
185 int had_early_param = 0;
165 186
166 p = __setup_start; 187 p = __setup_start;
167 do { 188 do {
168 int n = strlen(p->str); 189 int n = strlen(p->str);
169 if (!strncmp(line, p->str, n)) { 190 if (!strncmp(line, p->str, n)) {
170 if (p->early) { 191 if (p->early) {
171 /* Already done in parse_early_param? (Needs 192 /* Already done in parse_early_param?
172 * exact match on param part) */ 193 * (Needs exact match on param part).
194 * Keep iterating, as we can have early
195 * params and __setups of same names 8( */
173 if (line[n] == '\0' || line[n] == '=') 196 if (line[n] == '\0' || line[n] == '=')
174 return 1; 197 had_early_param = 1;
175 } else if (!p->setup_func) { 198 } else if (!p->setup_func) {
176 printk(KERN_WARNING "Parameter %s is obsolete," 199 printk(KERN_WARNING "Parameter %s is obsolete,"
177 " ignored\n", p->str); 200 " ignored\n", p->str);
@@ -181,7 +204,8 @@ static int __init obsolete_checksetup(char *line)
181 } 204 }
182 p++; 205 p++;
183 } while (p < __setup_end); 206 } while (p < __setup_end);
184 return 0; 207
208 return had_early_param;
185} 209}
186 210
187/* 211/*
@@ -464,6 +488,7 @@ asmlinkage void __init start_kernel(void)
464 * Need to run as early as possible, to initialize the 488 * Need to run as early as possible, to initialize the
465 * lockdep hash: 489 * lockdep hash:
466 */ 490 */
491 unwind_init();
467 lockdep_init(); 492 lockdep_init();
468 493
469 local_irq_disable(); 494 local_irq_disable();
@@ -502,7 +527,6 @@ asmlinkage void __init start_kernel(void)
502 __stop___param - __start___param, 527 __stop___param - __start___param,
503 &unknown_bootoption); 528 &unknown_bootoption);
504 sort_main_extable(); 529 sort_main_extable();
505 unwind_init();
506 trap_init(); 530 trap_init();
507 rcu_init(); 531 rcu_init();
508 init_IRQ(); 532 init_IRQ();
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 02e6f6798972..840f8a6fb85f 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -115,7 +115,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode,
115 inode->i_mode = mode; 115 inode->i_mode = mode;
116 inode->i_uid = current->fsuid; 116 inode->i_uid = current->fsuid;
117 inode->i_gid = current->fsgid; 117 inode->i_gid = current->fsgid;
118 inode->i_blksize = PAGE_CACHE_SIZE;
119 inode->i_blocks = 0; 118 inode->i_blocks = 0;
120 inode->i_mtime = inode->i_ctime = inode->i_atime = 119 inode->i_mtime = inode->i_ctime = inode->i_atime =
121 CURRENT_TIME; 120 CURRENT_TIME;
@@ -1275,10 +1274,7 @@ out_filesystem:
1275out_sysctl: 1274out_sysctl:
1276 if (mq_sysctl_table) 1275 if (mq_sysctl_table)
1277 unregister_sysctl_table(mq_sysctl_table); 1276 unregister_sysctl_table(mq_sysctl_table);
1278 if (kmem_cache_destroy(mqueue_inode_cachep)) { 1277 kmem_cache_destroy(mqueue_inode_cachep);
1279 printk(KERN_INFO
1280 "mqueue_inode_cache: not all structures were freed\n");
1281 }
1282 return error; 1278 return error;
1283} 1279}
1284 1280
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index cff41511269f..1b32c2c04c15 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -289,7 +289,6 @@ static struct inode *cpuset_new_inode(mode_t mode)
289 inode->i_mode = mode; 289 inode->i_mode = mode;
290 inode->i_uid = current->fsuid; 290 inode->i_uid = current->fsuid;
291 inode->i_gid = current->fsgid; 291 inode->i_gid = current->fsgid;
292 inode->i_blksize = PAGE_CACHE_SIZE;
293 inode->i_blocks = 0; 292 inode->i_blocks = 0;
294 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 293 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
295 inode->i_mapping->backing_dev_info = &cpuset_backing_dev_info; 294 inode->i_mapping->backing_dev_info = &cpuset_backing_dev_info;
diff --git a/kernel/fork.c b/kernel/fork.c
index f9b014e3e700..a0dad84567c9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -45,6 +45,7 @@
45#include <linux/cn_proc.h> 45#include <linux/cn_proc.h>
46#include <linux/delayacct.h> 46#include <linux/delayacct.h>
47#include <linux/taskstats_kern.h> 47#include <linux/taskstats_kern.h>
48#include <linux/random.h>
48 49
49#include <asm/pgtable.h> 50#include <asm/pgtable.h>
50#include <asm/pgalloc.h> 51#include <asm/pgalloc.h>
@@ -175,6 +176,10 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
175 tsk->thread_info = ti; 176 tsk->thread_info = ti;
176 setup_thread_stack(tsk, orig); 177 setup_thread_stack(tsk, orig);
177 178
179#ifdef CONFIG_CC_STACKPROTECTOR
180 tsk->stack_canary = get_random_int();
181#endif
182
178 /* One for us, one for whoever does the "release_task()" (usually parent) */ 183 /* One for us, one for whoever does the "release_task()" (usually parent) */
179 atomic_set(&tsk->usage,2); 184 atomic_set(&tsk->usage,2);
180 atomic_set(&tsk->fs_excl, 0); 185 atomic_set(&tsk->fs_excl, 0);
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 9bad17884513..c088e5542e84 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -224,7 +224,14 @@ static int save_trace(struct stack_trace *trace)
224 trace->max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries; 224 trace->max_entries = MAX_STACK_TRACE_ENTRIES - nr_stack_trace_entries;
225 trace->entries = stack_trace + nr_stack_trace_entries; 225 trace->entries = stack_trace + nr_stack_trace_entries;
226 226
227 save_stack_trace(trace, NULL, 0, 3); 227 trace->skip = 3;
228 trace->all_contexts = 0;
229
230 /* Make sure to not recurse in case the the unwinder needs to tak
231e locks. */
232 lockdep_off();
233 save_stack_trace(trace, NULL);
234 lockdep_on();
228 235
229 trace->max_entries = trace->nr_entries; 236 trace->max_entries = trace->nr_entries;
230 237
diff --git a/kernel/panic.c b/kernel/panic.c
index 8010b9b17aca..6ceb664fb52a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -21,6 +21,7 @@
21#include <linux/debug_locks.h> 21#include <linux/debug_locks.h>
22 22
23int panic_on_oops; 23int panic_on_oops;
24int panic_on_unrecovered_nmi;
24int tainted; 25int tainted;
25static int pause_on_oops; 26static int pause_on_oops;
26static int pause_on_oops_flag; 27static int pause_on_oops_flag;
@@ -270,3 +271,15 @@ void oops_exit(void)
270{ 271{
271 do_oops_enter_exit(); 272 do_oops_enter_exit();
272} 273}
274
275#ifdef CONFIG_CC_STACKPROTECTOR
276/*
277 * Called when gcc's -fstack-protector feature is used, and
278 * gcc detects corruption of the on-stack canary value
279 */
280void __stack_chk_fail(void)
281{
282 panic("stack-protector: Kernel stack is corrupted");
283}
284EXPORT_SYMBOL(__stack_chk_fail);
285#endif
diff --git a/kernel/pid.c b/kernel/pid.c
index 93e212f20671..8387e8c68193 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -223,9 +223,6 @@ int fastcall attach_pid(struct task_struct *task, enum pid_type type, int nr)
223 struct pid_link *link; 223 struct pid_link *link;
224 struct pid *pid; 224 struct pid *pid;
225 225
226 WARN_ON(!task->pid); /* to be removed soon */
227 WARN_ON(!nr); /* to be removed soon */
228
229 link = &task->pids[type]; 226 link = &task->pids[type];
230 link->pid = pid = find_pid(nr); 227 link->pid = pid = find_pid(nr);
231 hlist_add_head_rcu(&link->node, &pid->tasks[type]); 228 hlist_add_head_rcu(&link->node, &pid->tasks[type]);
@@ -252,6 +249,15 @@ void fastcall detach_pid(struct task_struct *task, enum pid_type type)
252 free_pid(pid); 249 free_pid(pid);
253} 250}
254 251
252/* transfer_pid is an optimization of attach_pid(new), detach_pid(old) */
253void fastcall transfer_pid(struct task_struct *old, struct task_struct *new,
254 enum pid_type type)
255{
256 new->pids[type].pid = old->pids[type].pid;
257 hlist_replace_rcu(&old->pids[type].node, &new->pids[type].node);
258 old->pids[type].pid = NULL;
259}
260
255struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type) 261struct task_struct * fastcall pid_task(struct pid *pid, enum pid_type type)
256{ 262{
257 struct task_struct *result = NULL; 263 struct task_struct *result = NULL;
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 4b6e2f18e056..825068ca3479 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -64,6 +64,17 @@ config PM_TRACE
64 CAUTION: this option will cause your machine's real-time clock to be 64 CAUTION: this option will cause your machine's real-time clock to be
65 set to an invalid time after a resume. 65 set to an invalid time after a resume.
66 66
67config PM_SYSFS_DEPRECATED
68 bool "Driver model /sys/devices/.../power/state files (DEPRECATED)"
69 depends on PM && SYSFS
70 default n
71 help
72 The driver model started out with a sysfs file intended to provide
73 a userspace hook for device power management. This feature has never
74 worked very well, except for limited testing purposes, and so it will
75 be removed. It's not clear that a generic mechanism could really
76 handle the wide variability of device power states; any replacements
77 are likely to be bus or driver specific.
67 78
68config SOFTWARE_SUSPEND 79config SOFTWARE_SUSPEND
69 bool "Software Suspend" 80 bool "Software Suspend"
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 7c7b9b65e365..d72234942798 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -103,7 +103,7 @@ static void unprepare_processes(void)
103} 103}
104 104
105/** 105/**
106 * pm_suspend_disk - The granpappy of power management. 106 * pm_suspend_disk - The granpappy of hibernation power management.
107 * 107 *
108 * If we're going through the firmware, then get it over with quickly. 108 * If we're going through the firmware, then get it over with quickly.
109 * 109 *
@@ -212,7 +212,7 @@ static int software_resume(void)
212 212
213 pr_debug("PM: Preparing devices for restore.\n"); 213 pr_debug("PM: Preparing devices for restore.\n");
214 214
215 if ((error = device_suspend(PMSG_FREEZE))) { 215 if ((error = device_suspend(PMSG_PRETHAW))) {
216 printk("Some devices failed to suspend\n"); 216 printk("Some devices failed to suspend\n");
217 swsusp_free(); 217 swsusp_free();
218 goto Thaw; 218 goto Thaw;
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 8ef677ea0cea..0b66659dc516 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -247,6 +247,9 @@ int swsusp_suspend(void)
247 restore_processor_state(); 247 restore_processor_state();
248Restore_highmem: 248Restore_highmem:
249 restore_highmem(); 249 restore_highmem();
250 /* NOTE: device_power_up() is just a resume() for devices
251 * that suspended with irqs off ... no overall powerup.
252 */
250 device_power_up(); 253 device_power_up();
251Enable_irqs: 254Enable_irqs:
252 local_irq_enable(); 255 local_irq_enable();
@@ -256,8 +259,12 @@ Enable_irqs:
256int swsusp_resume(void) 259int swsusp_resume(void)
257{ 260{
258 int error; 261 int error;
262
259 local_irq_disable(); 263 local_irq_disable();
260 if (device_power_down(PMSG_FREEZE)) 264 /* NOTE: device_power_down() is just a suspend() with irqs off;
265 * it has no special "power things down" semantics
266 */
267 if (device_power_down(PMSG_PRETHAW))
261 printk(KERN_ERR "Some devices failed to power down, very bad\n"); 268 printk(KERN_ERR "Some devices failed to power down, very bad\n");
262 /* We'll ignore saved state, but this gets preempt count (etc) right */ 269 /* We'll ignore saved state, but this gets preempt count (etc) right */
263 save_processor_state(); 270 save_processor_state();
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 2e4499f3e4d9..72825c853cd7 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -196,7 +196,7 @@ static int snapshot_ioctl(struct inode *inode, struct file *filp,
196 snapshot_free_unused_memory(&data->handle); 196 snapshot_free_unused_memory(&data->handle);
197 down(&pm_sem); 197 down(&pm_sem);
198 pm_prepare_console(); 198 pm_prepare_console();
199 error = device_suspend(PMSG_FREEZE); 199 error = device_suspend(PMSG_PRETHAW);
200 if (!error) { 200 if (!error) {
201 error = swsusp_resume(); 201 error = swsusp_resume();
202 device_resume(); 202 device_resume();
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 9a111f70145c..8aad0331d82e 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -241,60 +241,6 @@ int ptrace_detach(struct task_struct *child, unsigned int data)
241 return 0; 241 return 0;
242} 242}
243 243
244/*
245 * Access another process' address space.
246 * Source/target buffer must be kernel space,
247 * Do not walk the page table directly, use get_user_pages
248 */
249
250int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
251{
252 struct mm_struct *mm;
253 struct vm_area_struct *vma;
254 struct page *page;
255 void *old_buf = buf;
256
257 mm = get_task_mm(tsk);
258 if (!mm)
259 return 0;
260
261 down_read(&mm->mmap_sem);
262 /* ignore errors, just check how much was sucessfully transfered */
263 while (len) {
264 int bytes, ret, offset;
265 void *maddr;
266
267 ret = get_user_pages(tsk, mm, addr, 1,
268 write, 1, &page, &vma);
269 if (ret <= 0)
270 break;
271
272 bytes = len;
273 offset = addr & (PAGE_SIZE-1);
274 if (bytes > PAGE_SIZE-offset)
275 bytes = PAGE_SIZE-offset;
276
277 maddr = kmap(page);
278 if (write) {
279 copy_to_user_page(vma, page, addr,
280 maddr + offset, buf, bytes);
281 set_page_dirty_lock(page);
282 } else {
283 copy_from_user_page(vma, page, addr,
284 buf, maddr + offset, bytes);
285 }
286 kunmap(page);
287 page_cache_release(page);
288 len -= bytes;
289 buf += bytes;
290 addr += bytes;
291 }
292 up_read(&mm->mmap_sem);
293 mmput(mm);
294
295 return buf - old_buf;
296}
297
298int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len) 244int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len)
299{ 245{
300 int copied = 0; 246 int copied = 0;
diff --git a/kernel/relay.c b/kernel/relay.c
index 33345e73485c..85786ff2a4f9 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -669,7 +669,7 @@ EXPORT_SYMBOL_GPL(relay_flush);
669 */ 669 */
670static int relay_file_open(struct inode *inode, struct file *filp) 670static int relay_file_open(struct inode *inode, struct file *filp)
671{ 671{
672 struct rchan_buf *buf = inode->u.generic_ip; 672 struct rchan_buf *buf = inode->i_private;
673 kref_get(&buf->kref); 673 kref_get(&buf->kref);
674 filp->private_data = buf; 674 filp->private_data = buf;
675 675
diff --git a/kernel/resource.c b/kernel/resource.c
index 46286434af80..9db38a1a7520 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -344,12 +344,11 @@ EXPORT_SYMBOL(allocate_resource);
344 * 344 *
345 * Returns 0 on success, -EBUSY if the resource can't be inserted. 345 * Returns 0 on success, -EBUSY if the resource can't be inserted.
346 * 346 *
347 * This function is equivalent of request_resource when no conflict 347 * This function is equivalent to request_resource when no conflict
348 * happens. If a conflict happens, and the conflicting resources 348 * happens. If a conflict happens, and the conflicting resources
349 * entirely fit within the range of the new resource, then the new 349 * entirely fit within the range of the new resource, then the new
350 * resource is inserted and the conflicting resources become childs of 350 * resource is inserted and the conflicting resources become children of
351 * the new resource. Otherwise the new resource becomes the child of 351 * the new resource.
352 * the conflicting resource
353 */ 352 */
354int insert_resource(struct resource *parent, struct resource *new) 353int insert_resource(struct resource *parent, struct resource *new)
355{ 354{
@@ -357,20 +356,21 @@ int insert_resource(struct resource *parent, struct resource *new)
357 struct resource *first, *next; 356 struct resource *first, *next;
358 357
359 write_lock(&resource_lock); 358 write_lock(&resource_lock);
360 begin:
361 result = 0;
362 first = __request_resource(parent, new);
363 if (!first)
364 goto out;
365 359
366 result = -EBUSY; 360 for (;; parent = first) {
367 if (first == parent) 361 result = 0;
368 goto out; 362 first = __request_resource(parent, new);
363 if (!first)
364 goto out;
369 365
370 /* Resource fully contained by the clashing resource? Recurse into it */ 366 result = -EBUSY;
371 if (first->start <= new->start && first->end >= new->end) { 367 if (first == parent)
372 parent = first; 368 goto out;
373 goto begin; 369
370 if ((first->start > new->start) || (first->end < new->end))
371 break;
372 if ((first->start == new->start) && (first->end == new->end))
373 break;
374 } 374 }
375 375
376 for (next = first; ; next = next->sibling) { 376 for (next = first; ; next = next->sibling) {
diff --git a/kernel/signal.c b/kernel/signal.c
index bfdb5686fa3e..05853a7337e3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2577,6 +2577,11 @@ asmlinkage long sys_rt_sigsuspend(sigset_t __user *unewset, size_t sigsetsize)
2577} 2577}
2578#endif /* __ARCH_WANT_SYS_RT_SIGSUSPEND */ 2578#endif /* __ARCH_WANT_SYS_RT_SIGSUSPEND */
2579 2579
2580__attribute__((weak)) const char *arch_vma_name(struct vm_area_struct *vma)
2581{
2582 return NULL;
2583}
2584
2580void __init signals_init(void) 2585void __init signals_init(void)
2581{ 2586{
2582 sigqueue_cachep = 2587 sigqueue_cachep =
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index fb524b009eef..9644a41e0bef 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -7,6 +7,11 @@
7 * 7 *
8 * This file contains the spinlock/rwlock implementations for the 8 * This file contains the spinlock/rwlock implementations for the
9 * SMP and the DEBUG_SPINLOCK cases. (UP-nondebug inlines them) 9 * SMP and the DEBUG_SPINLOCK cases. (UP-nondebug inlines them)
10 *
11 * Note that some architectures have special knowledge about the
12 * stack frames of these functions in their profile_pc. If you
13 * change anything significant here that could change the stack
14 * frame contact the architecture maintainers.
10 */ 15 */
11 16
12#include <linux/linkage.h> 17#include <linux/linkage.h>
diff --git a/kernel/sys.c b/kernel/sys.c
index e236f98f7ec5..3f894775488d 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -28,6 +28,7 @@
28#include <linux/tty.h> 28#include <linux/tty.h>
29#include <linux/signal.h> 29#include <linux/signal.h>
30#include <linux/cn_proc.h> 30#include <linux/cn_proc.h>
31#include <linux/getcpu.h>
31 32
32#include <linux/compat.h> 33#include <linux/compat.h>
33#include <linux/syscalls.h> 34#include <linux/syscalls.h>
@@ -2062,3 +2063,33 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
2062 } 2063 }
2063 return error; 2064 return error;
2064} 2065}
2066
2067asmlinkage long sys_getcpu(unsigned __user *cpup, unsigned __user *nodep,
2068 struct getcpu_cache __user *cache)
2069{
2070 int err = 0;
2071 int cpu = raw_smp_processor_id();
2072 if (cpup)
2073 err |= put_user(cpu, cpup);
2074 if (nodep)
2075 err |= put_user(cpu_to_node(cpu), nodep);
2076 if (cache) {
2077 /*
2078 * The cache is not needed for this implementation,
2079 * but make sure user programs pass something
2080 * valid. vsyscall implementations can instead make
2081 * good use of the cache. Only use t0 and t1 because
2082 * these are available in both 32bit and 64bit ABI (no
2083 * need for a compat_getcpu). 32bit has enough
2084 * padding
2085 */
2086 unsigned long t0, t1;
2087 get_user(t0, &cache->t0);
2088 get_user(t1, &cache->t1);
2089 t0++;
2090 t1++;
2091 put_user(t0, &cache->t0);
2092 put_user(t1, &cache->t1);
2093 }
2094 return err ? -EFAULT : 0;
2095}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index fd43c3e6786b..8bfa7d117c54 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -76,8 +76,9 @@ extern int compat_log;
76 76
77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) 77#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
78int unknown_nmi_panic; 78int unknown_nmi_panic;
79extern int proc_unknown_nmi_panic(ctl_table *, int, struct file *, 79int nmi_watchdog_enabled;
80 void __user *, size_t *, loff_t *); 80extern int proc_nmi_enabled(struct ctl_table *, int , struct file *,
81 void __user *, size_t *, loff_t *);
81#endif 82#endif
82 83
83/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */ 84/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
@@ -136,8 +137,11 @@ extern int no_unaligned_warning;
136extern int max_lock_depth; 137extern int max_lock_depth;
137#endif 138#endif
138 139
139static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, 140#ifdef CONFIG_SYSCTL_SYSCALL
140 ctl_table *, void **); 141static int parse_table(int __user *, int, void __user *, size_t __user *,
142 void __user *, size_t, ctl_table *, void **);
143#endif
144
141static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 145static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
142 void __user *buffer, size_t *lenp, loff_t *ppos); 146 void __user *buffer, size_t *lenp, loff_t *ppos);
143 147
@@ -164,7 +168,7 @@ int sysctl_legacy_va_layout;
164 168
165/* /proc declarations: */ 169/* /proc declarations: */
166 170
167#ifdef CONFIG_PROC_FS 171#ifdef CONFIG_PROC_SYSCTL
168 172
169static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *); 173static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
170static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *); 174static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
@@ -628,11 +632,27 @@ static ctl_table kern_table[] = {
628 .data = &unknown_nmi_panic, 632 .data = &unknown_nmi_panic,
629 .maxlen = sizeof (int), 633 .maxlen = sizeof (int),
630 .mode = 0644, 634 .mode = 0644,
631 .proc_handler = &proc_unknown_nmi_panic, 635 .proc_handler = &proc_dointvec,
636 },
637 {
638 .ctl_name = KERN_NMI_WATCHDOG,
639 .procname = "nmi_watchdog",
640 .data = &nmi_watchdog_enabled,
641 .maxlen = sizeof (int),
642 .mode = 0644,
643 .proc_handler = &proc_nmi_enabled,
632 }, 644 },
633#endif 645#endif
634#if defined(CONFIG_X86) 646#if defined(CONFIG_X86)
635 { 647 {
648 .ctl_name = KERN_PANIC_ON_NMI,
649 .procname = "panic_on_unrecovered_nmi",
650 .data = &panic_on_unrecovered_nmi,
651 .maxlen = sizeof(int),
652 .mode = 0644,
653 .proc_handler = &proc_dointvec,
654 },
655 {
636 .ctl_name = KERN_BOOTLOADER_TYPE, 656 .ctl_name = KERN_BOOTLOADER_TYPE,
637 .procname = "bootloader_type", 657 .procname = "bootloader_type",
638 .data = &bootloader_type, 658 .data = &bootloader_type,
@@ -1149,12 +1169,13 @@ static void start_unregistering(struct ctl_table_header *p)
1149 1169
1150void __init sysctl_init(void) 1170void __init sysctl_init(void)
1151{ 1171{
1152#ifdef CONFIG_PROC_FS 1172#ifdef CONFIG_PROC_SYSCTL
1153 register_proc_table(root_table, proc_sys_root, &root_table_header); 1173 register_proc_table(root_table, proc_sys_root, &root_table_header);
1154 init_irq_proc(); 1174 init_irq_proc();
1155#endif 1175#endif
1156} 1176}
1157 1177
1178#ifdef CONFIG_SYSCTL_SYSCALL
1158int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp, 1179int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1159 void __user *newval, size_t newlen) 1180 void __user *newval, size_t newlen)
1160{ 1181{
@@ -1208,6 +1229,7 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1208 unlock_kernel(); 1229 unlock_kernel();
1209 return error; 1230 return error;
1210} 1231}
1232#endif /* CONFIG_SYSCTL_SYSCALL */
1211 1233
1212/* 1234/*
1213 * ctl_perm does NOT grant the superuser all rights automatically, because 1235 * ctl_perm does NOT grant the superuser all rights automatically, because
@@ -1234,6 +1256,7 @@ static inline int ctl_perm(ctl_table *table, int op)
1234 return test_perm(table->mode, op); 1256 return test_perm(table->mode, op);
1235} 1257}
1236 1258
1259#ifdef CONFIG_SYSCTL_SYSCALL
1237static int parse_table(int __user *name, int nlen, 1260static int parse_table(int __user *name, int nlen,
1238 void __user *oldval, size_t __user *oldlenp, 1261 void __user *oldval, size_t __user *oldlenp,
1239 void __user *newval, size_t newlen, 1262 void __user *newval, size_t newlen,
@@ -1323,6 +1346,7 @@ int do_sysctl_strategy (ctl_table *table,
1323 } 1346 }
1324 return 0; 1347 return 0;
1325} 1348}
1349#endif /* CONFIG_SYSCTL_SYSCALL */
1326 1350
1327/** 1351/**
1328 * register_sysctl_table - register a sysctl hierarchy 1352 * register_sysctl_table - register a sysctl hierarchy
@@ -1410,7 +1434,7 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table,
1410 else 1434 else
1411 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1435 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1412 spin_unlock(&sysctl_lock); 1436 spin_unlock(&sysctl_lock);
1413#ifdef CONFIG_PROC_FS 1437#ifdef CONFIG_PROC_SYSCTL
1414 register_proc_table(table, proc_sys_root, tmp); 1438 register_proc_table(table, proc_sys_root, tmp);
1415#endif 1439#endif
1416 return tmp; 1440 return tmp;
@@ -1428,18 +1452,31 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1428 might_sleep(); 1452 might_sleep();
1429 spin_lock(&sysctl_lock); 1453 spin_lock(&sysctl_lock);
1430 start_unregistering(header); 1454 start_unregistering(header);
1431#ifdef CONFIG_PROC_FS 1455#ifdef CONFIG_PROC_SYSCTL
1432 unregister_proc_table(header->ctl_table, proc_sys_root); 1456 unregister_proc_table(header->ctl_table, proc_sys_root);
1433#endif 1457#endif
1434 spin_unlock(&sysctl_lock); 1458 spin_unlock(&sysctl_lock);
1435 kfree(header); 1459 kfree(header);
1436} 1460}
1437 1461
1462#else /* !CONFIG_SYSCTL */
1463struct ctl_table_header * register_sysctl_table(ctl_table * table,
1464 int insert_at_head)
1465{
1466 return NULL;
1467}
1468
1469void unregister_sysctl_table(struct ctl_table_header * table)
1470{
1471}
1472
1473#endif /* CONFIG_SYSCTL */
1474
1438/* 1475/*
1439 * /proc/sys support 1476 * /proc/sys support
1440 */ 1477 */
1441 1478
1442#ifdef CONFIG_PROC_FS 1479#ifdef CONFIG_PROC_SYSCTL
1443 1480
1444/* Scan the sysctl entries in table and add them all into /proc */ 1481/* Scan the sysctl entries in table and add them all into /proc */
1445static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set) 1482static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
@@ -2301,6 +2338,7 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2301#endif /* CONFIG_PROC_FS */ 2338#endif /* CONFIG_PROC_FS */
2302 2339
2303 2340
2341#ifdef CONFIG_SYSCTL_SYSCALL
2304/* 2342/*
2305 * General sysctl support routines 2343 * General sysctl support routines
2306 */ 2344 */
@@ -2443,11 +2481,19 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2443 return 1; 2481 return 1;
2444} 2482}
2445 2483
2446#else /* CONFIG_SYSCTL */ 2484#else /* CONFIG_SYSCTL_SYSCALL */
2447 2485
2448 2486
2449asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2487asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2450{ 2488{
2489 static int msg_count;
2490
2491 if (msg_count < 5) {
2492 msg_count++;
2493 printk(KERN_INFO
2494 "warning: process `%s' used the removed sysctl "
2495 "system call\n", current->comm);
2496 }
2451 return -ENOSYS; 2497 return -ENOSYS;
2452} 2498}
2453 2499
@@ -2479,73 +2525,7 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2479 return -ENOSYS; 2525 return -ENOSYS;
2480} 2526}
2481 2527
2482int proc_dostring(ctl_table *table, int write, struct file *filp, 2528#endif /* CONFIG_SYSCTL_SYSCALL */
2483 void __user *buffer, size_t *lenp, loff_t *ppos)
2484{
2485 return -ENOSYS;
2486}
2487
2488int proc_dointvec(ctl_table *table, int write, struct file *filp,
2489 void __user *buffer, size_t *lenp, loff_t *ppos)
2490{
2491 return -ENOSYS;
2492}
2493
2494int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2495 void __user *buffer, size_t *lenp, loff_t *ppos)
2496{
2497 return -ENOSYS;
2498}
2499
2500int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2501 void __user *buffer, size_t *lenp, loff_t *ppos)
2502{
2503 return -ENOSYS;
2504}
2505
2506int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2507 void __user *buffer, size_t *lenp, loff_t *ppos)
2508{
2509 return -ENOSYS;
2510}
2511
2512int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2513 void __user *buffer, size_t *lenp, loff_t *ppos)
2514{
2515 return -ENOSYS;
2516}
2517
2518int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2519 void __user *buffer, size_t *lenp, loff_t *ppos)
2520{
2521 return -ENOSYS;
2522}
2523
2524int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2525 void __user *buffer, size_t *lenp, loff_t *ppos)
2526{
2527 return -ENOSYS;
2528}
2529
2530int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2531 struct file *filp,
2532 void __user *buffer,
2533 size_t *lenp, loff_t *ppos)
2534{
2535 return -ENOSYS;
2536}
2537
2538struct ctl_table_header * register_sysctl_table(ctl_table * table,
2539 int insert_at_head)
2540{
2541 return NULL;
2542}
2543
2544void unregister_sysctl_table(struct ctl_table_header * table)
2545{
2546}
2547
2548#endif /* CONFIG_SYSCTL */
2549 2529
2550/* 2530/*
2551 * No sense putting this after each symbol definition, twice, 2531 * No sense putting this after each symbol definition, twice,
diff --git a/kernel/unwind.c b/kernel/unwind.c
index f69c804c8e62..3430475fcd88 100644
--- a/kernel/unwind.c
+++ b/kernel/unwind.c
@@ -603,6 +603,7 @@ int unwind(struct unwind_frame_info *frame)
603#define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs]) 603#define FRAME_REG(r, t) (((t *)frame)[reg_info[r].offs])
604 const u32 *fde = NULL, *cie = NULL; 604 const u32 *fde = NULL, *cie = NULL;
605 const u8 *ptr = NULL, *end = NULL; 605 const u8 *ptr = NULL, *end = NULL;
606 unsigned long pc = UNW_PC(frame) - frame->call_frame;
606 unsigned long startLoc = 0, endLoc = 0, cfa; 607 unsigned long startLoc = 0, endLoc = 0, cfa;
607 unsigned i; 608 unsigned i;
608 signed ptrType = -1; 609 signed ptrType = -1;
@@ -612,7 +613,7 @@ int unwind(struct unwind_frame_info *frame)
612 613
613 if (UNW_PC(frame) == 0) 614 if (UNW_PC(frame) == 0)
614 return -EINVAL; 615 return -EINVAL;
615 if ((table = find_table(UNW_PC(frame))) != NULL 616 if ((table = find_table(pc)) != NULL
616 && !(table->size & (sizeof(*fde) - 1))) { 617 && !(table->size & (sizeof(*fde) - 1))) {
617 unsigned long tableSize = table->size; 618 unsigned long tableSize = table->size;
618 619
@@ -647,7 +648,7 @@ int unwind(struct unwind_frame_info *frame)
647 ptrType & DW_EH_PE_indirect 648 ptrType & DW_EH_PE_indirect
648 ? ptrType 649 ? ptrType
649 : ptrType & (DW_EH_PE_FORM|DW_EH_PE_signed)); 650 : ptrType & (DW_EH_PE_FORM|DW_EH_PE_signed));
650 if (UNW_PC(frame) >= startLoc && UNW_PC(frame) < endLoc) 651 if (pc >= startLoc && pc < endLoc)
651 break; 652 break;
652 cie = NULL; 653 cie = NULL;
653 } 654 }
@@ -657,16 +658,28 @@ int unwind(struct unwind_frame_info *frame)
657 state.cieEnd = ptr; /* keep here temporarily */ 658 state.cieEnd = ptr; /* keep here temporarily */
658 ptr = (const u8 *)(cie + 2); 659 ptr = (const u8 *)(cie + 2);
659 end = (const u8 *)(cie + 1) + *cie; 660 end = (const u8 *)(cie + 1) + *cie;
661 frame->call_frame = 1;
660 if ((state.version = *ptr) != 1) 662 if ((state.version = *ptr) != 1)
661 cie = NULL; /* unsupported version */ 663 cie = NULL; /* unsupported version */
662 else if (*++ptr) { 664 else if (*++ptr) {
663 /* check if augmentation size is first (and thus present) */ 665 /* check if augmentation size is first (and thus present) */
664 if (*ptr == 'z') { 666 if (*ptr == 'z') {
665 /* check for ignorable (or already handled) 667 while (++ptr < end && *ptr) {
666 * nul-terminated augmentation string */ 668 switch(*ptr) {
667 while (++ptr < end && *ptr) 669 /* check for ignorable (or already handled)
668 if (strchr("LPR", *ptr) == NULL) 670 * nul-terminated augmentation string */
671 case 'L':
672 case 'P':
673 case 'R':
674 continue;
675 case 'S':
676 frame->call_frame = 0;
677 continue;
678 default:
669 break; 679 break;
680 }
681 break;
682 }
670 } 683 }
671 if (ptr >= end || *ptr) 684 if (ptr >= end || *ptr)
672 cie = NULL; 685 cie = NULL;
@@ -755,7 +768,7 @@ int unwind(struct unwind_frame_info *frame)
755 state.org = startLoc; 768 state.org = startLoc;
756 memcpy(&state.cfa, &badCFA, sizeof(state.cfa)); 769 memcpy(&state.cfa, &badCFA, sizeof(state.cfa));
757 /* process instructions */ 770 /* process instructions */
758 if (!processCFI(ptr, end, UNW_PC(frame), ptrType, &state) 771 if (!processCFI(ptr, end, pc, ptrType, &state)
759 || state.loc > endLoc 772 || state.loc > endLoc
760 || state.regs[retAddrReg].where == Nowhere 773 || state.regs[retAddrReg].where == Nowhere
761 || state.cfa.reg >= ARRAY_SIZE(reg_info) 774 || state.cfa.reg >= ARRAY_SIZE(reg_info)
@@ -763,6 +776,11 @@ int unwind(struct unwind_frame_info *frame)
763 || state.cfa.offs % sizeof(unsigned long)) 776 || state.cfa.offs % sizeof(unsigned long))
764 return -EIO; 777 return -EIO;
765 /* update frame */ 778 /* update frame */
779#ifndef CONFIG_AS_CFI_SIGNAL_FRAME
780 if(frame->call_frame
781 && !UNW_DEFAULT_RA(state.regs[retAddrReg], state.dataAlign))
782 frame->call_frame = 0;
783#endif
766 cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs; 784 cfa = FRAME_REG(state.cfa.reg, unsigned long) + state.cfa.offs;
767 startLoc = min((unsigned long)UNW_SP(frame), cfa); 785 startLoc = min((unsigned long)UNW_SP(frame), cfa);
768 endLoc = max((unsigned long)UNW_SP(frame), cfa); 786 endLoc = max((unsigned long)UNW_SP(frame), cfa);
@@ -866,6 +884,7 @@ int unwind_init_frame_info(struct unwind_frame_info *info,
866 /*const*/ struct pt_regs *regs) 884 /*const*/ struct pt_regs *regs)
867{ 885{
868 info->task = tsk; 886 info->task = tsk;
887 info->call_frame = 0;
869 arch_unw_init_frame_info(info, regs); 888 arch_unw_init_frame_info(info, regs);
870 889
871 return 0; 890 return 0;
@@ -879,6 +898,7 @@ int unwind_init_blocked(struct unwind_frame_info *info,
879 struct task_struct *tsk) 898 struct task_struct *tsk)
880{ 899{
881 info->task = tsk; 900 info->task = tsk;
901 info->call_frame = 0;
882 arch_unw_init_blocked(info); 902 arch_unw_init_blocked(info);
883 903
884 return 0; 904 return 0;
@@ -894,6 +914,7 @@ int unwind_init_running(struct unwind_frame_info *info,
894 void *arg) 914 void *arg)
895{ 915{
896 info->task = current; 916 info->task = current;
917 info->call_frame = 0;
897 918
898 return arch_unwind_init_running(info, callback, arg); 919 return arch_unwind_init_running(info, callback, arg);
899} 920}
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 3f21cc79a134..b0f5ca72599f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -8,6 +8,13 @@ config PRINTK_TIME
8 operations. This is useful for identifying long delays 8 operations. This is useful for identifying long delays
9 in kernel startup. 9 in kernel startup.
10 10
11config ENABLE_MUST_CHECK
12 bool "Enable __must_check logic"
13 default y
14 help
15 Enable the __must_check logic in the kernel build. Disable this to
16 suppress the "warning: ignoring return value of 'foo', declared with
17 attribute warn_unused_result" messages.
11 18
12config MAGIC_SYSRQ 19config MAGIC_SYSRQ
13 bool "Magic SysRq key" 20 bool "Magic SysRq key"
@@ -218,7 +225,7 @@ config LOCKDEP
218 bool 225 bool
219 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT 226 depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
220 select STACKTRACE 227 select STACKTRACE
221 select FRAME_POINTER 228 select FRAME_POINTER if !X86
222 select KALLSYMS 229 select KALLSYMS
223 select KALLSYMS_ALL 230 select KALLSYMS_ALL
224 231
@@ -277,7 +284,7 @@ config DEBUG_HIGHMEM
277config DEBUG_BUGVERBOSE 284config DEBUG_BUGVERBOSE
278 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED 285 bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EMBEDDED
279 depends on BUG 286 depends on BUG
280 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || X86_32 || FRV 287 depends on ARM || ARM26 || AVR32 || M32R || M68K || SPARC32 || SPARC64 || X86_32 || FRV || SUPERH
281 default !EMBEDDED 288 default !EMBEDDED
282 help 289 help
283 Say Y here to make BUG() panics output the file name and line number 290 Say Y here to make BUG() panics output the file name and line number
@@ -315,7 +322,7 @@ config DEBUG_VM
315 322
316config FRAME_POINTER 323config FRAME_POINTER
317 bool "Compile the kernel with frame pointers" 324 bool "Compile the kernel with frame pointers"
318 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32) 325 depends on DEBUG_KERNEL && (X86 || CRIS || M68K || M68KNOMMU || FRV || UML || S390 || AVR32 || SUPERH)
319 default y if DEBUG_INFO && UML 326 default y if DEBUG_INFO && UML
320 help 327 help
321 If you say Y here the resulting kernel image will be slightly larger 328 If you say Y here the resulting kernel image will be slightly larger
diff --git a/lib/hweight.c b/lib/hweight.c
index 438257671708..360556a7803d 100644
--- a/lib/hweight.c
+++ b/lib/hweight.c
@@ -1,5 +1,6 @@
1#include <linux/module.h> 1#include <linux/module.h>
2#include <asm/types.h> 2#include <asm/types.h>
3#include <asm/bitops.h>
3 4
4/** 5/**
5 * hweightN - returns the hamming weight of a N-bit word 6 * hweightN - returns the hamming weight of a N-bit word
@@ -40,14 +41,19 @@ unsigned long hweight64(__u64 w)
40#if BITS_PER_LONG == 32 41#if BITS_PER_LONG == 32
41 return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w); 42 return hweight32((unsigned int)(w >> 32)) + hweight32((unsigned int)w);
42#elif BITS_PER_LONG == 64 43#elif BITS_PER_LONG == 64
44#ifdef ARCH_HAS_FAST_MULTIPLIER
45 w -= (w >> 1) & 0x5555555555555555ul;
46 w = (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
47 w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful;
48 return (w * 0x0101010101010101ul) >> 56;
49#else
43 __u64 res = w - ((w >> 1) & 0x5555555555555555ul); 50 __u64 res = w - ((w >> 1) & 0x5555555555555555ul);
44 res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul); 51 res = (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
45 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful; 52 res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
46 res = res + (res >> 8); 53 res = res + (res >> 8);
47 res = res + (res >> 16); 54 res = res + (res >> 16);
48 return (res + (res >> 32)) & 0x00000000000000FFul; 55 return (res + (res >> 32)) & 0x00000000000000FFul;
49#else 56#endif
50#error BITS_PER_LONG not defined
51#endif 57#endif
52} 58}
53EXPORT_SYMBOL(hweight64); 59EXPORT_SYMBOL(hweight64);
diff --git a/lib/klist.c b/lib/klist.c
index 9c94f0b163a1..120bd175aa78 100644
--- a/lib/klist.c
+++ b/lib/klist.c
@@ -123,12 +123,10 @@ EXPORT_SYMBOL_GPL(klist_add_tail);
123static void klist_release(struct kref * kref) 123static void klist_release(struct kref * kref)
124{ 124{
125 struct klist_node * n = container_of(kref, struct klist_node, n_ref); 125 struct klist_node * n = container_of(kref, struct klist_node, n_ref);
126 void (*put)(struct klist_node *) = n->n_klist->put; 126
127 list_del(&n->n_node); 127 list_del(&n->n_node);
128 complete(&n->n_removed); 128 complete(&n->n_removed);
129 n->n_klist = NULL; 129 n->n_klist = NULL;
130 if (put)
131 put(n);
132} 130}
133 131
134static int klist_dec_and_del(struct klist_node * n) 132static int klist_dec_and_del(struct klist_node * n)
@@ -145,10 +143,14 @@ static int klist_dec_and_del(struct klist_node * n)
145void klist_del(struct klist_node * n) 143void klist_del(struct klist_node * n)
146{ 144{
147 struct klist * k = n->n_klist; 145 struct klist * k = n->n_klist;
146 void (*put)(struct klist_node *) = k->put;
148 147
149 spin_lock(&k->k_lock); 148 spin_lock(&k->k_lock);
150 klist_dec_and_del(n); 149 if (!klist_dec_and_del(n))
150 put = NULL;
151 spin_unlock(&k->k_lock); 151 spin_unlock(&k->k_lock);
152 if (put)
153 put(n);
152} 154}
153 155
154EXPORT_SYMBOL_GPL(klist_del); 156EXPORT_SYMBOL_GPL(klist_del);
@@ -161,10 +163,7 @@ EXPORT_SYMBOL_GPL(klist_del);
161 163
162void klist_remove(struct klist_node * n) 164void klist_remove(struct klist_node * n)
163{ 165{
164 struct klist * k = n->n_klist; 166 klist_del(n);
165 spin_lock(&k->k_lock);
166 klist_dec_and_del(n);
167 spin_unlock(&k->k_lock);
168 wait_for_completion(&n->n_removed); 167 wait_for_completion(&n->n_removed);
169} 168}
170 169
@@ -260,12 +259,15 @@ static struct klist_node * to_klist_node(struct list_head * n)
260struct klist_node * klist_next(struct klist_iter * i) 259struct klist_node * klist_next(struct klist_iter * i)
261{ 260{
262 struct list_head * next; 261 struct list_head * next;
262 struct klist_node * lnode = i->i_cur;
263 struct klist_node * knode = NULL; 263 struct klist_node * knode = NULL;
264 void (*put)(struct klist_node *) = i->i_klist->put;
264 265
265 spin_lock(&i->i_klist->k_lock); 266 spin_lock(&i->i_klist->k_lock);
266 if (i->i_cur) { 267 if (lnode) {
267 next = i->i_cur->n_node.next; 268 next = lnode->n_node.next;
268 klist_dec_and_del(i->i_cur); 269 if (!klist_dec_and_del(lnode))
270 put = NULL;
269 } else 271 } else
270 next = i->i_head->next; 272 next = i->i_head->next;
271 273
@@ -275,6 +277,8 @@ struct klist_node * klist_next(struct klist_iter * i)
275 } 277 }
276 i->i_cur = knode; 278 i->i_cur = knode;
277 spin_unlock(&i->i_klist->k_lock); 279 spin_unlock(&i->i_klist->k_lock);
280 if (put && lnode)
281 put(lnode);
278 return knode; 282 return knode;
279} 283}
280 284
diff --git a/lib/kobject.c b/lib/kobject.c
index 8e7c71993487..1699eb9161f3 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -407,6 +407,7 @@ static struct kobj_type dir_ktype = {
407struct kobject *kobject_add_dir(struct kobject *parent, const char *name) 407struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
408{ 408{
409 struct kobject *k; 409 struct kobject *k;
410 int ret;
410 411
411 if (!parent) 412 if (!parent)
412 return NULL; 413 return NULL;
@@ -418,7 +419,13 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name)
418 k->parent = parent; 419 k->parent = parent;
419 k->ktype = &dir_ktype; 420 k->ktype = &dir_ktype;
420 kobject_set_name(k, name); 421 kobject_set_name(k, name);
421 kobject_register(k); 422 ret = kobject_register(k);
423 if (ret < 0) {
424 printk(KERN_WARNING "kobject_add_dir: "
425 "kobject_register error: %d\n", ret);
426 kobject_del(k);
427 return NULL;
428 }
422 429
423 return k; 430 return k;
424} 431}
diff --git a/mm/memory.c b/mm/memory.c
index 92a3ebd8d795..601159a46ab6 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2256,6 +2256,54 @@ oom:
2256} 2256}
2257 2257
2258/* 2258/*
2259 * do_no_pfn() tries to create a new page mapping for a page without
2260 * a struct_page backing it
2261 *
2262 * As this is called only for pages that do not currently exist, we
2263 * do not need to flush old virtual caches or the TLB.
2264 *
2265 * We enter with non-exclusive mmap_sem (to exclude vma changes,
2266 * but allow concurrent faults), and pte mapped but not yet locked.
2267 * We return with mmap_sem still held, but pte unmapped and unlocked.
2268 *
2269 * It is expected that the ->nopfn handler always returns the same pfn
2270 * for a given virtual mapping.
2271 *
2272 * Mark this `noinline' to prevent it from bloating the main pagefault code.
2273 */
2274static noinline int do_no_pfn(struct mm_struct *mm, struct vm_area_struct *vma,
2275 unsigned long address, pte_t *page_table, pmd_t *pmd,
2276 int write_access)
2277{
2278 spinlock_t *ptl;
2279 pte_t entry;
2280 unsigned long pfn;
2281 int ret = VM_FAULT_MINOR;
2282
2283 pte_unmap(page_table);
2284 BUG_ON(!(vma->vm_flags & VM_PFNMAP));
2285 BUG_ON(is_cow_mapping(vma->vm_flags));
2286
2287 pfn = vma->vm_ops->nopfn(vma, address & PAGE_MASK);
2288 if (pfn == NOPFN_OOM)
2289 return VM_FAULT_OOM;
2290 if (pfn == NOPFN_SIGBUS)
2291 return VM_FAULT_SIGBUS;
2292
2293 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
2294
2295 /* Only go through if we didn't race with anybody else... */
2296 if (pte_none(*page_table)) {
2297 entry = pfn_pte(pfn, vma->vm_page_prot);
2298 if (write_access)
2299 entry = maybe_mkwrite(pte_mkdirty(entry), vma);
2300 set_pte_at(mm, address, page_table, entry);
2301 }
2302 pte_unmap_unlock(page_table, ptl);
2303 return ret;
2304}
2305
2306/*
2259 * Fault of a previously existing named mapping. Repopulate the pte 2307 * Fault of a previously existing named mapping. Repopulate the pte
2260 * from the encoded file_pte if possible. This enables swappable 2308 * from the encoded file_pte if possible. This enables swappable
2261 * nonlinear vmas. 2309 * nonlinear vmas.
@@ -2317,11 +2365,17 @@ static inline int handle_pte_fault(struct mm_struct *mm,
2317 old_entry = entry = *pte; 2365 old_entry = entry = *pte;
2318 if (!pte_present(entry)) { 2366 if (!pte_present(entry)) {
2319 if (pte_none(entry)) { 2367 if (pte_none(entry)) {
2320 if (!vma->vm_ops || !vma->vm_ops->nopage) 2368 if (vma->vm_ops) {
2321 return do_anonymous_page(mm, vma, address, 2369 if (vma->vm_ops->nopage)
2322 pte, pmd, write_access); 2370 return do_no_page(mm, vma, address,
2323 return do_no_page(mm, vma, address, 2371 pte, pmd,
2324 pte, pmd, write_access); 2372 write_access);
2373 if (unlikely(vma->vm_ops->nopfn))
2374 return do_no_pfn(mm, vma, address, pte,
2375 pmd, write_access);
2376 }
2377 return do_anonymous_page(mm, vma, address,
2378 pte, pmd, write_access);
2325 } 2379 }
2326 if (pte_file(entry)) 2380 if (pte_file(entry))
2327 return do_file_page(mm, vma, address, 2381 return do_file_page(mm, vma, address,
@@ -2550,3 +2604,56 @@ int in_gate_area_no_task(unsigned long addr)
2550} 2604}
2551 2605
2552#endif /* __HAVE_ARCH_GATE_AREA */ 2606#endif /* __HAVE_ARCH_GATE_AREA */
2607
2608/*
2609 * Access another process' address space.
2610 * Source/target buffer must be kernel space,
2611 * Do not walk the page table directly, use get_user_pages
2612 */
2613int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
2614{
2615 struct mm_struct *mm;
2616 struct vm_area_struct *vma;
2617 struct page *page;
2618 void *old_buf = buf;
2619
2620 mm = get_task_mm(tsk);
2621 if (!mm)
2622 return 0;
2623
2624 down_read(&mm->mmap_sem);
2625 /* ignore errors, just check how much was sucessfully transfered */
2626 while (len) {
2627 int bytes, ret, offset;
2628 void *maddr;
2629
2630 ret = get_user_pages(tsk, mm, addr, 1,
2631 write, 1, &page, &vma);
2632 if (ret <= 0)
2633 break;
2634
2635 bytes = len;
2636 offset = addr & (PAGE_SIZE-1);
2637 if (bytes > PAGE_SIZE-offset)
2638 bytes = PAGE_SIZE-offset;
2639
2640 maddr = kmap(page);
2641 if (write) {
2642 copy_to_user_page(vma, page, addr,
2643 maddr + offset, buf, bytes);
2644 set_page_dirty_lock(page);
2645 } else {
2646 copy_from_user_page(vma, page, addr,
2647 buf, maddr + offset, bytes);
2648 }
2649 kunmap(page);
2650 page_cache_release(page);
2651 len -= bytes;
2652 buf += bytes;
2653 addr += bytes;
2654 }
2655 up_read(&mm->mmap_sem);
2656 mmput(mm);
2657
2658 return buf - old_buf;
2659}
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 38f89650bc84..cf18f0942553 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1136,7 +1136,9 @@ static unsigned interleave_nodes(struct mempolicy *policy)
1136 */ 1136 */
1137unsigned slab_node(struct mempolicy *policy) 1137unsigned slab_node(struct mempolicy *policy)
1138{ 1138{
1139 switch (policy->policy) { 1139 int pol = policy ? policy->policy : MPOL_DEFAULT;
1140
1141 switch (pol) {
1140 case MPOL_INTERLEAVE: 1142 case MPOL_INTERLEAVE:
1141 return interleave_nodes(policy); 1143 return interleave_nodes(policy);
1142 1144
diff --git a/mm/nommu.c b/mm/nommu.c
index d99dea31e443..564540662192 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -122,26 +122,50 @@ unsigned int kobjsize(const void *objp)
122} 122}
123 123
124/* 124/*
125 * The nommu dodgy version :-) 125 * get a list of pages in an address range belonging to the specified process
126 * and indicate the VMA that covers each page
127 * - this is potentially dodgy as we may end incrementing the page count of a
128 * slab page or a secondary page from a compound page
129 * - don't permit access to VMAs that don't support it, such as I/O mappings
126 */ 130 */
127int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, 131int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
128 unsigned long start, int len, int write, int force, 132 unsigned long start, int len, int write, int force,
129 struct page **pages, struct vm_area_struct **vmas) 133 struct page **pages, struct vm_area_struct **vmas)
130{ 134{
135 struct vm_area_struct *vma;
136 unsigned long vm_flags;
131 int i; 137 int i;
132 static struct vm_area_struct dummy_vma; 138
139 /* calculate required read or write permissions.
140 * - if 'force' is set, we only require the "MAY" flags.
141 */
142 vm_flags = write ? (VM_WRITE | VM_MAYWRITE) : (VM_READ | VM_MAYREAD);
143 vm_flags &= force ? (VM_MAYREAD | VM_MAYWRITE) : (VM_READ | VM_WRITE);
133 144
134 for (i = 0; i < len; i++) { 145 for (i = 0; i < len; i++) {
146 vma = find_vma(mm, start);
147 if (!vma)
148 goto finish_or_fault;
149
150 /* protect what we can, including chardevs */
151 if (vma->vm_flags & (VM_IO | VM_PFNMAP) ||
152 !(vm_flags & vma->vm_flags))
153 goto finish_or_fault;
154
135 if (pages) { 155 if (pages) {
136 pages[i] = virt_to_page(start); 156 pages[i] = virt_to_page(start);
137 if (pages[i]) 157 if (pages[i])
138 page_cache_get(pages[i]); 158 page_cache_get(pages[i]);
139 } 159 }
140 if (vmas) 160 if (vmas)
141 vmas[i] = &dummy_vma; 161 vmas[i] = vma;
142 start += PAGE_SIZE; 162 start += PAGE_SIZE;
143 } 163 }
144 return(i); 164
165 return i;
166
167finish_or_fault:
168 return i ? : -EFAULT;
145} 169}
146 170
147EXPORT_SYMBOL(get_user_pages); 171EXPORT_SYMBOL(get_user_pages);
@@ -286,6 +310,77 @@ static void show_process_blocks(void)
286} 310}
287#endif /* DEBUG */ 311#endif /* DEBUG */
288 312
313/*
314 * add a VMA into a process's mm_struct in the appropriate place in the list
315 * - should be called with mm->mmap_sem held writelocked
316 */
317static void add_vma_to_mm(struct mm_struct *mm, struct vm_list_struct *vml)
318{
319 struct vm_list_struct **ppv;
320
321 for (ppv = &current->mm->context.vmlist; *ppv; ppv = &(*ppv)->next)
322 if ((*ppv)->vma->vm_start > vml->vma->vm_start)
323 break;
324
325 vml->next = *ppv;
326 *ppv = vml;
327}
328
329/*
330 * look up the first VMA in which addr resides, NULL if none
331 * - should be called with mm->mmap_sem at least held readlocked
332 */
333struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
334{
335 struct vm_list_struct *loop, *vml;
336
337 /* search the vm_start ordered list */
338 vml = NULL;
339 for (loop = mm->context.vmlist; loop; loop = loop->next) {
340 if (loop->vma->vm_start > addr)
341 break;
342 vml = loop;
343 }
344
345 if (vml && vml->vma->vm_end > addr)
346 return vml->vma;
347
348 return NULL;
349}
350EXPORT_SYMBOL(find_vma);
351
352/*
353 * find a VMA
354 * - we don't extend stack VMAs under NOMMU conditions
355 */
356struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
357{
358 return find_vma(mm, addr);
359}
360
361/*
362 * look up the first VMA exactly that exactly matches addr
363 * - should be called with mm->mmap_sem at least held readlocked
364 */
365static inline struct vm_area_struct *find_vma_exact(struct mm_struct *mm,
366 unsigned long addr)
367{
368 struct vm_list_struct *vml;
369
370 /* search the vm_start ordered list */
371 for (vml = mm->context.vmlist; vml; vml = vml->next) {
372 if (vml->vma->vm_start == addr)
373 return vml->vma;
374 if (vml->vma->vm_start > addr)
375 break;
376 }
377
378 return NULL;
379}
380
381/*
382 * find a VMA in the global tree
383 */
289static inline struct vm_area_struct *find_nommu_vma(unsigned long start) 384static inline struct vm_area_struct *find_nommu_vma(unsigned long start)
290{ 385{
291 struct vm_area_struct *vma; 386 struct vm_area_struct *vma;
@@ -305,6 +400,9 @@ static inline struct vm_area_struct *find_nommu_vma(unsigned long start)
305 return NULL; 400 return NULL;
306} 401}
307 402
403/*
404 * add a VMA in the global tree
405 */
308static void add_nommu_vma(struct vm_area_struct *vma) 406static void add_nommu_vma(struct vm_area_struct *vma)
309{ 407{
310 struct vm_area_struct *pvma; 408 struct vm_area_struct *pvma;
@@ -351,6 +449,9 @@ static void add_nommu_vma(struct vm_area_struct *vma)
351 rb_insert_color(&vma->vm_rb, &nommu_vma_tree); 449 rb_insert_color(&vma->vm_rb, &nommu_vma_tree);
352} 450}
353 451
452/*
453 * delete a VMA from the global list
454 */
354static void delete_nommu_vma(struct vm_area_struct *vma) 455static void delete_nommu_vma(struct vm_area_struct *vma)
355{ 456{
356 struct address_space *mapping; 457 struct address_space *mapping;
@@ -828,8 +929,7 @@ unsigned long do_mmap_pgoff(struct file *file,
828 realalloc += kobjsize(vml); 929 realalloc += kobjsize(vml);
829 askedalloc += sizeof(*vml); 930 askedalloc += sizeof(*vml);
830 931
831 vml->next = current->mm->context.vmlist; 932 add_vma_to_mm(current->mm, vml);
832 current->mm->context.vmlist = vml;
833 933
834 up_write(&nommu_vma_sem); 934 up_write(&nommu_vma_sem);
835 935
@@ -908,6 +1008,11 @@ static void put_vma(struct vm_area_struct *vma)
908 } 1008 }
909} 1009}
910 1010
1011/*
1012 * release a mapping
1013 * - under NOMMU conditions the parameters must match exactly to the mapping to
1014 * be removed
1015 */
911int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len) 1016int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len)
912{ 1017{
913 struct vm_list_struct *vml, **parent; 1018 struct vm_list_struct *vml, **parent;
@@ -917,10 +1022,13 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len)
917 printk("do_munmap:\n"); 1022 printk("do_munmap:\n");
918#endif 1023#endif
919 1024
920 for (parent = &mm->context.vmlist; *parent; parent = &(*parent)->next) 1025 for (parent = &mm->context.vmlist; *parent; parent = &(*parent)->next) {
1026 if ((*parent)->vma->vm_start > addr)
1027 break;
921 if ((*parent)->vma->vm_start == addr && 1028 if ((*parent)->vma->vm_start == addr &&
922 ((len == 0) || ((*parent)->vma->vm_end == end))) 1029 ((len == 0) || ((*parent)->vma->vm_end == end)))
923 goto found; 1030 goto found;
1031 }
924 1032
925 printk("munmap of non-mmaped memory by process %d (%s): %p\n", 1033 printk("munmap of non-mmaped memory by process %d (%s): %p\n",
926 current->pid, current->comm, (void *) addr); 1034 current->pid, current->comm, (void *) addr);
@@ -946,7 +1054,20 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len)
946 return 0; 1054 return 0;
947} 1055}
948 1056
949/* Release all mmaps. */ 1057asmlinkage long sys_munmap(unsigned long addr, size_t len)
1058{
1059 int ret;
1060 struct mm_struct *mm = current->mm;
1061
1062 down_write(&mm->mmap_sem);
1063 ret = do_munmap(mm, addr, len);
1064 up_write(&mm->mmap_sem);
1065 return ret;
1066}
1067
1068/*
1069 * Release all mappings
1070 */
950void exit_mmap(struct mm_struct * mm) 1071void exit_mmap(struct mm_struct * mm)
951{ 1072{
952 struct vm_list_struct *tmp; 1073 struct vm_list_struct *tmp;
@@ -973,37 +1094,26 @@ void exit_mmap(struct mm_struct * mm)
973 } 1094 }
974} 1095}
975 1096
976asmlinkage long sys_munmap(unsigned long addr, size_t len)
977{
978 int ret;
979 struct mm_struct *mm = current->mm;
980
981 down_write(&mm->mmap_sem);
982 ret = do_munmap(mm, addr, len);
983 up_write(&mm->mmap_sem);
984 return ret;
985}
986
987unsigned long do_brk(unsigned long addr, unsigned long len) 1097unsigned long do_brk(unsigned long addr, unsigned long len)
988{ 1098{
989 return -ENOMEM; 1099 return -ENOMEM;
990} 1100}
991 1101
992/* 1102/*
993 * Expand (or shrink) an existing mapping, potentially moving it at the 1103 * expand (or shrink) an existing mapping, potentially moving it at the same
994 * same time (controlled by the MREMAP_MAYMOVE flag and available VM space) 1104 * time (controlled by the MREMAP_MAYMOVE flag and available VM space)
995 * 1105 *
996 * MREMAP_FIXED option added 5-Dec-1999 by Benjamin LaHaise 1106 * under NOMMU conditions, we only permit changing a mapping's size, and only
997 * This option implies MREMAP_MAYMOVE. 1107 * as long as it stays within the hole allocated by the kmalloc() call in
1108 * do_mmap_pgoff() and the block is not shareable
998 * 1109 *
999 * on uClinux, we only permit changing a mapping's size, and only as long as it stays within the 1110 * MREMAP_FIXED is not supported under NOMMU conditions
1000 * hole allocated by the kmalloc() call in do_mmap_pgoff() and the block is not shareable
1001 */ 1111 */
1002unsigned long do_mremap(unsigned long addr, 1112unsigned long do_mremap(unsigned long addr,
1003 unsigned long old_len, unsigned long new_len, 1113 unsigned long old_len, unsigned long new_len,
1004 unsigned long flags, unsigned long new_addr) 1114 unsigned long flags, unsigned long new_addr)
1005{ 1115{
1006 struct vm_list_struct *vml = NULL; 1116 struct vm_area_struct *vma;
1007 1117
1008 /* insanity checks first */ 1118 /* insanity checks first */
1009 if (new_len == 0) 1119 if (new_len == 0)
@@ -1012,58 +1122,46 @@ unsigned long do_mremap(unsigned long addr,
1012 if (flags & MREMAP_FIXED && new_addr != addr) 1122 if (flags & MREMAP_FIXED && new_addr != addr)
1013 return (unsigned long) -EINVAL; 1123 return (unsigned long) -EINVAL;
1014 1124
1015 for (vml = current->mm->context.vmlist; vml; vml = vml->next) 1125 vma = find_vma_exact(current->mm, addr);
1016 if (vml->vma->vm_start == addr) 1126 if (!vma)
1017 goto found; 1127 return (unsigned long) -EINVAL;
1018
1019 return (unsigned long) -EINVAL;
1020 1128
1021 found: 1129 if (vma->vm_end != vma->vm_start + old_len)
1022 if (vml->vma->vm_end != vml->vma->vm_start + old_len)
1023 return (unsigned long) -EFAULT; 1130 return (unsigned long) -EFAULT;
1024 1131
1025 if (vml->vma->vm_flags & VM_MAYSHARE) 1132 if (vma->vm_flags & VM_MAYSHARE)
1026 return (unsigned long) -EPERM; 1133 return (unsigned long) -EPERM;
1027 1134
1028 if (new_len > kobjsize((void *) addr)) 1135 if (new_len > kobjsize((void *) addr))
1029 return (unsigned long) -ENOMEM; 1136 return (unsigned long) -ENOMEM;
1030 1137
1031 /* all checks complete - do it */ 1138 /* all checks complete - do it */
1032 vml->vma->vm_end = vml->vma->vm_start + new_len; 1139 vma->vm_end = vma->vm_start + new_len;
1033 1140
1034 askedalloc -= old_len; 1141 askedalloc -= old_len;
1035 askedalloc += new_len; 1142 askedalloc += new_len;
1036 1143
1037 return vml->vma->vm_start; 1144 return vma->vm_start;
1038} 1145}
1039 1146
1040/* 1147asmlinkage unsigned long sys_mremap(unsigned long addr,
1041 * Look up the first VMA which satisfies addr < vm_end, NULL if none 1148 unsigned long old_len, unsigned long new_len,
1042 */ 1149 unsigned long flags, unsigned long new_addr)
1043struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
1044{ 1150{
1045 struct vm_list_struct *vml; 1151 unsigned long ret;
1046
1047 for (vml = mm->context.vmlist; vml; vml = vml->next)
1048 if (addr >= vml->vma->vm_start && addr < vml->vma->vm_end)
1049 return vml->vma;
1050 1152
1051 return NULL; 1153 down_write(&current->mm->mmap_sem);
1154 ret = do_mremap(addr, old_len, new_len, flags, new_addr);
1155 up_write(&current->mm->mmap_sem);
1156 return ret;
1052} 1157}
1053 1158
1054EXPORT_SYMBOL(find_vma);
1055
1056struct page *follow_page(struct vm_area_struct *vma, unsigned long address, 1159struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
1057 unsigned int foll_flags) 1160 unsigned int foll_flags)
1058{ 1161{
1059 return NULL; 1162 return NULL;
1060} 1163}
1061 1164
1062struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
1063{
1064 return NULL;
1065}
1066
1067int remap_pfn_range(struct vm_area_struct *vma, unsigned long from, 1165int remap_pfn_range(struct vm_area_struct *vma, unsigned long from,
1068 unsigned long to, unsigned long size, pgprot_t prot) 1166 unsigned long to, unsigned long size, pgprot_t prot)
1069{ 1167{
@@ -1206,3 +1304,44 @@ struct page *filemap_nopage(struct vm_area_struct *area,
1206 BUG(); 1304 BUG();
1207 return NULL; 1305 return NULL;
1208} 1306}
1307
1308/*
1309 * Access another process' address space.
1310 * - source/target buffer must be kernel space
1311 */
1312int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
1313{
1314 struct vm_area_struct *vma;
1315 struct mm_struct *mm;
1316
1317 if (addr + len < addr)
1318 return 0;
1319
1320 mm = get_task_mm(tsk);
1321 if (!mm)
1322 return 0;
1323
1324 down_read(&mm->mmap_sem);
1325
1326 /* the access must start within one of the target process's mappings */
1327 vma = find_vma(mm, addr);
1328 if (vma) {
1329 /* don't overrun this mapping */
1330 if (addr + len >= vma->vm_end)
1331 len = vma->vm_end - addr;
1332
1333 /* only read or write mappings where it is permitted */
1334 if (write && vma->vm_flags & VM_MAYWRITE)
1335 len -= copy_to_user((void *) addr, buf, len);
1336 else if (!write && vma->vm_flags & VM_MAYREAD)
1337 len -= copy_from_user(buf, (void *) addr, len);
1338 else
1339 len = 0;
1340 } else {
1341 len = 0;
1342 }
1343
1344 up_read(&mm->mmap_sem);
1345 mmput(mm);
1346 return len;
1347}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 9810f0a60db7..4f59d90b81e6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -37,6 +37,8 @@
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <linux/mempolicy.h> 38#include <linux/mempolicy.h>
39#include <linux/stop_machine.h> 39#include <linux/stop_machine.h>
40#include <linux/sort.h>
41#include <linux/pfn.h>
40 42
41#include <asm/tlbflush.h> 43#include <asm/tlbflush.h>
42#include <asm/div64.h> 44#include <asm/div64.h>
@@ -102,6 +104,38 @@ int min_free_kbytes = 1024;
102 104
103unsigned long __meminitdata nr_kernel_pages; 105unsigned long __meminitdata nr_kernel_pages;
104unsigned long __meminitdata nr_all_pages; 106unsigned long __meminitdata nr_all_pages;
107static unsigned long __initdata dma_reserve;
108
109#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
110 /*
111 * MAX_ACTIVE_REGIONS determines the maxmimum number of distinct
112 * ranges of memory (RAM) that may be registered with add_active_range().
113 * Ranges passed to add_active_range() will be merged if possible
114 * so the number of times add_active_range() can be called is
115 * related to the number of nodes and the number of holes
116 */
117 #ifdef CONFIG_MAX_ACTIVE_REGIONS
118 /* Allow an architecture to set MAX_ACTIVE_REGIONS to save memory */
119 #define MAX_ACTIVE_REGIONS CONFIG_MAX_ACTIVE_REGIONS
120 #else
121 #if MAX_NUMNODES >= 32
122 /* If there can be many nodes, allow up to 50 holes per node */
123 #define MAX_ACTIVE_REGIONS (MAX_NUMNODES*50)
124 #else
125 /* By default, allow up to 256 distinct regions */
126 #define MAX_ACTIVE_REGIONS 256
127 #endif
128 #endif
129
130 struct node_active_region __initdata early_node_map[MAX_ACTIVE_REGIONS];
131 int __initdata nr_nodemap_entries;
132 unsigned long __initdata arch_zone_lowest_possible_pfn[MAX_NR_ZONES];
133 unsigned long __initdata arch_zone_highest_possible_pfn[MAX_NR_ZONES];
134#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
135 unsigned long __initdata node_boundary_start_pfn[MAX_NUMNODES];
136 unsigned long __initdata node_boundary_end_pfn[MAX_NUMNODES];
137#endif /* CONFIG_MEMORY_HOTPLUG_RESERVE */
138#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
105 139
106#ifdef CONFIG_DEBUG_VM 140#ifdef CONFIG_DEBUG_VM
107static int page_outside_zone_boundaries(struct zone *zone, struct page *page) 141static int page_outside_zone_boundaries(struct zone *zone, struct page *page)
@@ -908,7 +942,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order,
908 */ 942 */
909 do { 943 do {
910 zone = *z; 944 zone = *z;
911 if (unlikely((gfp_mask & __GFP_THISNODE) && 945 if (unlikely(NUMA_BUILD && (gfp_mask & __GFP_THISNODE) &&
912 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat)) 946 zone->zone_pgdat != zonelist->zones[0]->zone_pgdat))
913 break; 947 break;
914 if ((alloc_flags & ALLOC_CPUSET) && 948 if ((alloc_flags & ALLOC_CPUSET) &&
@@ -1222,14 +1256,12 @@ unsigned int nr_free_pagecache_pages(void)
1222{ 1256{
1223 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER)); 1257 return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER));
1224} 1258}
1225#ifdef CONFIG_NUMA 1259
1226static void show_node(struct zone *zone) 1260static inline void show_node(struct zone *zone)
1227{ 1261{
1228 printk("Node %ld ", zone_to_nid(zone)); 1262 if (NUMA_BUILD)
1263 printk("Node %ld ", zone_to_nid(zone));
1229} 1264}
1230#else
1231#define show_node(zone) do { } while (0)
1232#endif
1233 1265
1234void si_meminfo(struct sysinfo *val) 1266void si_meminfo(struct sysinfo *val)
1235{ 1267{
@@ -1271,34 +1303,30 @@ void si_meminfo_node(struct sysinfo *val, int nid)
1271 */ 1303 */
1272void show_free_areas(void) 1304void show_free_areas(void)
1273{ 1305{
1274 int cpu, temperature; 1306 int cpu;
1275 unsigned long active; 1307 unsigned long active;
1276 unsigned long inactive; 1308 unsigned long inactive;
1277 unsigned long free; 1309 unsigned long free;
1278 struct zone *zone; 1310 struct zone *zone;
1279 1311
1280 for_each_zone(zone) { 1312 for_each_zone(zone) {
1281 show_node(zone); 1313 if (!populated_zone(zone))
1282 printk("%s per-cpu:", zone->name);
1283
1284 if (!populated_zone(zone)) {
1285 printk(" empty\n");
1286 continue; 1314 continue;
1287 } else 1315
1288 printk("\n"); 1316 show_node(zone);
1317 printk("%s per-cpu:\n", zone->name);
1289 1318
1290 for_each_online_cpu(cpu) { 1319 for_each_online_cpu(cpu) {
1291 struct per_cpu_pageset *pageset; 1320 struct per_cpu_pageset *pageset;
1292 1321
1293 pageset = zone_pcp(zone, cpu); 1322 pageset = zone_pcp(zone, cpu);
1294 1323
1295 for (temperature = 0; temperature < 2; temperature++) 1324 printk("CPU %4d: Hot: hi:%5d, btch:%4d usd:%4d "
1296 printk("cpu %d %s: high %d, batch %d used:%d\n", 1325 "Cold: hi:%5d, btch:%4d usd:%4d\n",
1297 cpu, 1326 cpu, pageset->pcp[0].high,
1298 temperature ? "cold" : "hot", 1327 pageset->pcp[0].batch, pageset->pcp[0].count,
1299 pageset->pcp[temperature].high, 1328 pageset->pcp[1].high, pageset->pcp[1].batch,
1300 pageset->pcp[temperature].batch, 1329 pageset->pcp[1].count);
1301 pageset->pcp[temperature].count);
1302 } 1330 }
1303 } 1331 }
1304 1332
@@ -1320,6 +1348,9 @@ void show_free_areas(void)
1320 for_each_zone(zone) { 1348 for_each_zone(zone) {
1321 int i; 1349 int i;
1322 1350
1351 if (!populated_zone(zone))
1352 continue;
1353
1323 show_node(zone); 1354 show_node(zone);
1324 printk("%s" 1355 printk("%s"
1325 " free:%lukB" 1356 " free:%lukB"
@@ -1352,12 +1383,11 @@ void show_free_areas(void)
1352 for_each_zone(zone) { 1383 for_each_zone(zone) {
1353 unsigned long nr[MAX_ORDER], flags, order, total = 0; 1384 unsigned long nr[MAX_ORDER], flags, order, total = 0;
1354 1385
1386 if (!populated_zone(zone))
1387 continue;
1388
1355 show_node(zone); 1389 show_node(zone);
1356 printk("%s: ", zone->name); 1390 printk("%s: ", zone->name);
1357 if (!populated_zone(zone)) {
1358 printk("empty\n");
1359 continue;
1360 }
1361 1391
1362 spin_lock_irqsave(&zone->lock, flags); 1392 spin_lock_irqsave(&zone->lock, flags);
1363 for (order = 0; order < MAX_ORDER; order++) { 1393 for (order = 0; order < MAX_ORDER; order++) {
@@ -1561,7 +1591,7 @@ static int __meminit __build_all_zonelists(void *dummy)
1561void __meminit build_all_zonelists(void) 1591void __meminit build_all_zonelists(void)
1562{ 1592{
1563 if (system_state == SYSTEM_BOOTING) { 1593 if (system_state == SYSTEM_BOOTING) {
1564 __build_all_zonelists(0); 1594 __build_all_zonelists(NULL);
1565 cpuset_init_current_mems_allowed(); 1595 cpuset_init_current_mems_allowed();
1566 } else { 1596 } else {
1567 /* we have to stop all cpus to guaranntee there is no user 1597 /* we have to stop all cpus to guaranntee there is no user
@@ -1642,25 +1672,6 @@ static inline unsigned long wait_table_bits(unsigned long size)
1642 1672
1643#define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) 1673#define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1))
1644 1674
1645static void __init calculate_zone_totalpages(struct pglist_data *pgdat,
1646 unsigned long *zones_size, unsigned long *zholes_size)
1647{
1648 unsigned long realtotalpages, totalpages = 0;
1649 enum zone_type i;
1650
1651 for (i = 0; i < MAX_NR_ZONES; i++)
1652 totalpages += zones_size[i];
1653 pgdat->node_spanned_pages = totalpages;
1654
1655 realtotalpages = totalpages;
1656 if (zholes_size)
1657 for (i = 0; i < MAX_NR_ZONES; i++)
1658 realtotalpages -= zholes_size[i];
1659 pgdat->node_present_pages = realtotalpages;
1660 printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages);
1661}
1662
1663
1664/* 1675/*
1665 * Initially all pages are reserved - free ones are freed 1676 * Initially all pages are reserved - free ones are freed
1666 * up by free_all_bootmem() once the early boot process is 1677 * up by free_all_bootmem() once the early boot process is
@@ -1818,6 +1829,9 @@ static int __cpuinit process_zones(int cpu)
1818 1829
1819 for_each_zone(zone) { 1830 for_each_zone(zone) {
1820 1831
1832 if (!populated_zone(zone))
1833 continue;
1834
1821 zone_pcp(zone, cpu) = kmalloc_node(sizeof(struct per_cpu_pageset), 1835 zone_pcp(zone, cpu) = kmalloc_node(sizeof(struct per_cpu_pageset),
1822 GFP_KERNEL, cpu_to_node(cpu)); 1836 GFP_KERNEL, cpu_to_node(cpu));
1823 if (!zone_pcp(zone, cpu)) 1837 if (!zone_pcp(zone, cpu))
@@ -1977,6 +1991,366 @@ __meminit int init_currently_empty_zone(struct zone *zone,
1977 return 0; 1991 return 0;
1978} 1992}
1979 1993
1994#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
1995/*
1996 * Basic iterator support. Return the first range of PFNs for a node
1997 * Note: nid == MAX_NUMNODES returns first region regardless of node
1998 */
1999static int __init first_active_region_index_in_nid(int nid)
2000{
2001 int i;
2002
2003 for (i = 0; i < nr_nodemap_entries; i++)
2004 if (nid == MAX_NUMNODES || early_node_map[i].nid == nid)
2005 return i;
2006
2007 return -1;
2008}
2009
2010/*
2011 * Basic iterator support. Return the next active range of PFNs for a node
2012 * Note: nid == MAX_NUMNODES returns next region regardles of node
2013 */
2014static int __init next_active_region_index_in_nid(int index, int nid)
2015{
2016 for (index = index + 1; index < nr_nodemap_entries; index++)
2017 if (nid == MAX_NUMNODES || early_node_map[index].nid == nid)
2018 return index;
2019
2020 return -1;
2021}
2022
2023#ifndef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
2024/*
2025 * Required by SPARSEMEM. Given a PFN, return what node the PFN is on.
2026 * Architectures may implement their own version but if add_active_range()
2027 * was used and there are no special requirements, this is a convenient
2028 * alternative
2029 */
2030int __init early_pfn_to_nid(unsigned long pfn)
2031{
2032 int i;
2033
2034 for (i = 0; i < nr_nodemap_entries; i++) {
2035 unsigned long start_pfn = early_node_map[i].start_pfn;
2036 unsigned long end_pfn = early_node_map[i].end_pfn;
2037
2038 if (start_pfn <= pfn && pfn < end_pfn)
2039 return early_node_map[i].nid;
2040 }
2041
2042 return 0;
2043}
2044#endif /* CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID */
2045
2046/* Basic iterator support to walk early_node_map[] */
2047#define for_each_active_range_index_in_nid(i, nid) \
2048 for (i = first_active_region_index_in_nid(nid); i != -1; \
2049 i = next_active_region_index_in_nid(i, nid))
2050
2051/**
2052 * free_bootmem_with_active_regions - Call free_bootmem_node for each active range
2053 * @nid: The node to free memory on. If MAX_NUMNODES, all nodes are freed
2054 * @max_low_pfn: The highest PFN that till be passed to free_bootmem_node
2055 *
2056 * If an architecture guarantees that all ranges registered with
2057 * add_active_ranges() contain no holes and may be freed, this
2058 * this function may be used instead of calling free_bootmem() manually.
2059 */
2060void __init free_bootmem_with_active_regions(int nid,
2061 unsigned long max_low_pfn)
2062{
2063 int i;
2064
2065 for_each_active_range_index_in_nid(i, nid) {
2066 unsigned long size_pages = 0;
2067 unsigned long end_pfn = early_node_map[i].end_pfn;
2068
2069 if (early_node_map[i].start_pfn >= max_low_pfn)
2070 continue;
2071
2072 if (end_pfn > max_low_pfn)
2073 end_pfn = max_low_pfn;
2074
2075 size_pages = end_pfn - early_node_map[i].start_pfn;
2076 free_bootmem_node(NODE_DATA(early_node_map[i].nid),
2077 PFN_PHYS(early_node_map[i].start_pfn),
2078 size_pages << PAGE_SHIFT);
2079 }
2080}
2081
2082/**
2083 * sparse_memory_present_with_active_regions - Call memory_present for each active range
2084 * @nid: The node to call memory_present for. If MAX_NUMNODES, all nodes will be used
2085 *
2086 * If an architecture guarantees that all ranges registered with
2087 * add_active_ranges() contain no holes and may be freed, this
2088 * this function may be used instead of calling memory_present() manually.
2089 */
2090void __init sparse_memory_present_with_active_regions(int nid)
2091{
2092 int i;
2093
2094 for_each_active_range_index_in_nid(i, nid)
2095 memory_present(early_node_map[i].nid,
2096 early_node_map[i].start_pfn,
2097 early_node_map[i].end_pfn);
2098}
2099
2100/**
2101 * push_node_boundaries - Push node boundaries to at least the requested boundary
2102 * @nid: The nid of the node to push the boundary for
2103 * @start_pfn: The start pfn of the node
2104 * @end_pfn: The end pfn of the node
2105 *
2106 * In reserve-based hot-add, mem_map is allocated that is unused until hotadd
2107 * time. Specifically, on x86_64, SRAT will report ranges that can potentially
2108 * be hotplugged even though no physical memory exists. This function allows
2109 * an arch to push out the node boundaries so mem_map is allocated that can
2110 * be used later.
2111 */
2112#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
2113void __init push_node_boundaries(unsigned int nid,
2114 unsigned long start_pfn, unsigned long end_pfn)
2115{
2116 printk(KERN_DEBUG "Entering push_node_boundaries(%u, %lu, %lu)\n",
2117 nid, start_pfn, end_pfn);
2118
2119 /* Initialise the boundary for this node if necessary */
2120 if (node_boundary_end_pfn[nid] == 0)
2121 node_boundary_start_pfn[nid] = -1UL;
2122
2123 /* Update the boundaries */
2124 if (node_boundary_start_pfn[nid] > start_pfn)
2125 node_boundary_start_pfn[nid] = start_pfn;
2126 if (node_boundary_end_pfn[nid] < end_pfn)
2127 node_boundary_end_pfn[nid] = end_pfn;
2128}
2129
2130/* If necessary, push the node boundary out for reserve hotadd */
2131static void __init account_node_boundary(unsigned int nid,
2132 unsigned long *start_pfn, unsigned long *end_pfn)
2133{
2134 printk(KERN_DEBUG "Entering account_node_boundary(%u, %lu, %lu)\n",
2135 nid, *start_pfn, *end_pfn);
2136
2137 /* Return if boundary information has not been provided */
2138 if (node_boundary_end_pfn[nid] == 0)
2139 return;
2140
2141 /* Check the boundaries and update if necessary */
2142 if (node_boundary_start_pfn[nid] < *start_pfn)
2143 *start_pfn = node_boundary_start_pfn[nid];
2144 if (node_boundary_end_pfn[nid] > *end_pfn)
2145 *end_pfn = node_boundary_end_pfn[nid];
2146}
2147#else
2148void __init push_node_boundaries(unsigned int nid,
2149 unsigned long start_pfn, unsigned long end_pfn) {}
2150
2151static void __init account_node_boundary(unsigned int nid,
2152 unsigned long *start_pfn, unsigned long *end_pfn) {}
2153#endif
2154
2155
2156/**
2157 * get_pfn_range_for_nid - Return the start and end page frames for a node
2158 * @nid: The nid to return the range for. If MAX_NUMNODES, the min and max PFN are returned
2159 * @start_pfn: Passed by reference. On return, it will have the node start_pfn
2160 * @end_pfn: Passed by reference. On return, it will have the node end_pfn
2161 *
2162 * It returns the start and end page frame of a node based on information
2163 * provided by an arch calling add_active_range(). If called for a node
2164 * with no available memory, a warning is printed and the start and end
2165 * PFNs will be 0
2166 */
2167void __init get_pfn_range_for_nid(unsigned int nid,
2168 unsigned long *start_pfn, unsigned long *end_pfn)
2169{
2170 int i;
2171 *start_pfn = -1UL;
2172 *end_pfn = 0;
2173
2174 for_each_active_range_index_in_nid(i, nid) {
2175 *start_pfn = min(*start_pfn, early_node_map[i].start_pfn);
2176 *end_pfn = max(*end_pfn, early_node_map[i].end_pfn);
2177 }
2178
2179 if (*start_pfn == -1UL) {
2180 printk(KERN_WARNING "Node %u active with no memory\n", nid);
2181 *start_pfn = 0;
2182 }
2183
2184 /* Push the node boundaries out if requested */
2185 account_node_boundary(nid, start_pfn, end_pfn);
2186}
2187
2188/*
2189 * Return the number of pages a zone spans in a node, including holes
2190 * present_pages = zone_spanned_pages_in_node() - zone_absent_pages_in_node()
2191 */
2192unsigned long __init zone_spanned_pages_in_node(int nid,
2193 unsigned long zone_type,
2194 unsigned long *ignored)
2195{
2196 unsigned long node_start_pfn, node_end_pfn;
2197 unsigned long zone_start_pfn, zone_end_pfn;
2198
2199 /* Get the start and end of the node and zone */
2200 get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn);
2201 zone_start_pfn = arch_zone_lowest_possible_pfn[zone_type];
2202 zone_end_pfn = arch_zone_highest_possible_pfn[zone_type];
2203
2204 /* Check that this node has pages within the zone's required range */
2205 if (zone_end_pfn < node_start_pfn || zone_start_pfn > node_end_pfn)
2206 return 0;
2207
2208 /* Move the zone boundaries inside the node if necessary */
2209 zone_end_pfn = min(zone_end_pfn, node_end_pfn);
2210 zone_start_pfn = max(zone_start_pfn, node_start_pfn);
2211
2212 /* Return the spanned pages */
2213 return zone_end_pfn - zone_start_pfn;
2214}
2215
2216/*
2217 * Return the number of holes in a range on a node. If nid is MAX_NUMNODES,
2218 * then all holes in the requested range will be accounted for
2219 */
2220unsigned long __init __absent_pages_in_range(int nid,
2221 unsigned long range_start_pfn,
2222 unsigned long range_end_pfn)
2223{
2224 int i = 0;
2225 unsigned long prev_end_pfn = 0, hole_pages = 0;
2226 unsigned long start_pfn;
2227
2228 /* Find the end_pfn of the first active range of pfns in the node */
2229 i = first_active_region_index_in_nid(nid);
2230 if (i == -1)
2231 return 0;
2232
2233 /* Account for ranges before physical memory on this node */
2234 if (early_node_map[i].start_pfn > range_start_pfn)
2235 hole_pages = early_node_map[i].start_pfn - range_start_pfn;
2236
2237 prev_end_pfn = early_node_map[i].start_pfn;
2238
2239 /* Find all holes for the zone within the node */
2240 for (; i != -1; i = next_active_region_index_in_nid(i, nid)) {
2241
2242 /* No need to continue if prev_end_pfn is outside the zone */
2243 if (prev_end_pfn >= range_end_pfn)
2244 break;
2245
2246 /* Make sure the end of the zone is not within the hole */
2247 start_pfn = min(early_node_map[i].start_pfn, range_end_pfn);
2248 prev_end_pfn = max(prev_end_pfn, range_start_pfn);
2249
2250 /* Update the hole size cound and move on */
2251 if (start_pfn > range_start_pfn) {
2252 BUG_ON(prev_end_pfn > start_pfn);
2253 hole_pages += start_pfn - prev_end_pfn;
2254 }
2255 prev_end_pfn = early_node_map[i].end_pfn;
2256 }
2257
2258 /* Account for ranges past physical memory on this node */
2259 if (range_end_pfn > prev_end_pfn)
2260 hole_pages = range_end_pfn -
2261 max(range_start_pfn, prev_end_pfn);
2262
2263 return hole_pages;
2264}
2265
2266/**
2267 * absent_pages_in_range - Return number of page frames in holes within a range
2268 * @start_pfn: The start PFN to start searching for holes
2269 * @end_pfn: The end PFN to stop searching for holes
2270 *
2271 * It returns the number of pages frames in memory holes within a range
2272 */
2273unsigned long __init absent_pages_in_range(unsigned long start_pfn,
2274 unsigned long end_pfn)
2275{
2276 return __absent_pages_in_range(MAX_NUMNODES, start_pfn, end_pfn);
2277}
2278
2279/* Return the number of page frames in holes in a zone on a node */
2280unsigned long __init zone_absent_pages_in_node(int nid,
2281 unsigned long zone_type,
2282 unsigned long *ignored)
2283{
2284 unsigned long node_start_pfn, node_end_pfn;
2285 unsigned long zone_start_pfn, zone_end_pfn;
2286
2287 get_pfn_range_for_nid(nid, &node_start_pfn, &node_end_pfn);
2288 zone_start_pfn = max(arch_zone_lowest_possible_pfn[zone_type],
2289 node_start_pfn);
2290 zone_end_pfn = min(arch_zone_highest_possible_pfn[zone_type],
2291 node_end_pfn);
2292
2293 return __absent_pages_in_range(nid, zone_start_pfn, zone_end_pfn);
2294}
2295
2296/* Return the zone index a PFN is in */
2297int memmap_zone_idx(struct page *lmem_map)
2298{
2299 int i;
2300 unsigned long phys_addr = virt_to_phys(lmem_map);
2301 unsigned long pfn = phys_addr >> PAGE_SHIFT;
2302
2303 for (i = 0; i < MAX_NR_ZONES; i++)
2304 if (pfn < arch_zone_highest_possible_pfn[i])
2305 break;
2306
2307 return i;
2308}
2309#else
2310static inline unsigned long zone_spanned_pages_in_node(int nid,
2311 unsigned long zone_type,
2312 unsigned long *zones_size)
2313{
2314 return zones_size[zone_type];
2315}
2316
2317static inline unsigned long zone_absent_pages_in_node(int nid,
2318 unsigned long zone_type,
2319 unsigned long *zholes_size)
2320{
2321 if (!zholes_size)
2322 return 0;
2323
2324 return zholes_size[zone_type];
2325}
2326
2327static inline int memmap_zone_idx(struct page *lmem_map)
2328{
2329 return MAX_NR_ZONES;
2330}
2331#endif
2332
2333static void __init calculate_node_totalpages(struct pglist_data *pgdat,
2334 unsigned long *zones_size, unsigned long *zholes_size)
2335{
2336 unsigned long realtotalpages, totalpages = 0;
2337 enum zone_type i;
2338
2339 for (i = 0; i < MAX_NR_ZONES; i++)
2340 totalpages += zone_spanned_pages_in_node(pgdat->node_id, i,
2341 zones_size);
2342 pgdat->node_spanned_pages = totalpages;
2343
2344 realtotalpages = totalpages;
2345 for (i = 0; i < MAX_NR_ZONES; i++)
2346 realtotalpages -=
2347 zone_absent_pages_in_node(pgdat->node_id, i,
2348 zholes_size);
2349 pgdat->node_present_pages = realtotalpages;
2350 printk(KERN_DEBUG "On node %d totalpages: %lu\n", pgdat->node_id,
2351 realtotalpages);
2352}
2353
1980/* 2354/*
1981 * Set up the zone data structures: 2355 * Set up the zone data structures:
1982 * - mark all pages reserved 2356 * - mark all pages reserved
@@ -1998,11 +2372,34 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
1998 2372
1999 for (j = 0; j < MAX_NR_ZONES; j++) { 2373 for (j = 0; j < MAX_NR_ZONES; j++) {
2000 struct zone *zone = pgdat->node_zones + j; 2374 struct zone *zone = pgdat->node_zones + j;
2001 unsigned long size, realsize; 2375 unsigned long size, realsize, memmap_pages;
2002 2376
2003 realsize = size = zones_size[j]; 2377 size = zone_spanned_pages_in_node(nid, j, zones_size);
2004 if (zholes_size) 2378 realsize = size - zone_absent_pages_in_node(nid, j,
2005 realsize -= zholes_size[j]; 2379 zholes_size);
2380
2381 /*
2382 * Adjust realsize so that it accounts for how much memory
2383 * is used by this zone for memmap. This affects the watermark
2384 * and per-cpu initialisations
2385 */
2386 memmap_pages = (size * sizeof(struct page)) >> PAGE_SHIFT;
2387 if (realsize >= memmap_pages) {
2388 realsize -= memmap_pages;
2389 printk(KERN_DEBUG
2390 " %s zone: %lu pages used for memmap\n",
2391 zone_names[j], memmap_pages);
2392 } else
2393 printk(KERN_WARNING
2394 " %s zone: %lu pages exceeds realsize %lu\n",
2395 zone_names[j], memmap_pages, realsize);
2396
2397 /* Account for reserved DMA pages */
2398 if (j == ZONE_DMA && realsize > dma_reserve) {
2399 realsize -= dma_reserve;
2400 printk(KERN_DEBUG " DMA zone: %lu pages reserved\n",
2401 dma_reserve);
2402 }
2006 2403
2007 if (!is_highmem_idx(j)) 2404 if (!is_highmem_idx(j))
2008 nr_kernel_pages += realsize; 2405 nr_kernel_pages += realsize;
@@ -2011,6 +2408,7 @@ static void __meminit free_area_init_core(struct pglist_data *pgdat,
2011 zone->spanned_pages = size; 2408 zone->spanned_pages = size;
2012 zone->present_pages = realsize; 2409 zone->present_pages = realsize;
2013#ifdef CONFIG_NUMA 2410#ifdef CONFIG_NUMA
2411 zone->node = nid;
2014 zone->min_unmapped_pages = (realsize*sysctl_min_unmapped_ratio) 2412 zone->min_unmapped_pages = (realsize*sysctl_min_unmapped_ratio)
2015 / 100; 2413 / 100;
2016 zone->min_slab_pages = (realsize * sysctl_min_slab_ratio) / 100; 2414 zone->min_slab_pages = (realsize * sysctl_min_slab_ratio) / 100;
@@ -2073,8 +2471,13 @@ static void __init alloc_node_mem_map(struct pglist_data *pgdat)
2073 /* 2471 /*
2074 * With no DISCONTIG, the global mem_map is just set as node 0's 2472 * With no DISCONTIG, the global mem_map is just set as node 0's
2075 */ 2473 */
2076 if (pgdat == NODE_DATA(0)) 2474 if (pgdat == NODE_DATA(0)) {
2077 mem_map = NODE_DATA(0)->node_mem_map; 2475 mem_map = NODE_DATA(0)->node_mem_map;
2476#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
2477 if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
2478 mem_map -= pgdat->node_start_pfn;
2479#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
2480 }
2078#endif 2481#endif
2079#endif /* CONFIG_FLAT_NODE_MEM_MAP */ 2482#endif /* CONFIG_FLAT_NODE_MEM_MAP */
2080} 2483}
@@ -2085,13 +2488,255 @@ void __meminit free_area_init_node(int nid, struct pglist_data *pgdat,
2085{ 2488{
2086 pgdat->node_id = nid; 2489 pgdat->node_id = nid;
2087 pgdat->node_start_pfn = node_start_pfn; 2490 pgdat->node_start_pfn = node_start_pfn;
2088 calculate_zone_totalpages(pgdat, zones_size, zholes_size); 2491 calculate_node_totalpages(pgdat, zones_size, zholes_size);
2089 2492
2090 alloc_node_mem_map(pgdat); 2493 alloc_node_mem_map(pgdat);
2091 2494
2092 free_area_init_core(pgdat, zones_size, zholes_size); 2495 free_area_init_core(pgdat, zones_size, zholes_size);
2093} 2496}
2094 2497
2498#ifdef CONFIG_ARCH_POPULATES_NODE_MAP
2499/**
2500 * add_active_range - Register a range of PFNs backed by physical memory
2501 * @nid: The node ID the range resides on
2502 * @start_pfn: The start PFN of the available physical memory
2503 * @end_pfn: The end PFN of the available physical memory
2504 *
2505 * These ranges are stored in an early_node_map[] and later used by
2506 * free_area_init_nodes() to calculate zone sizes and holes. If the
2507 * range spans a memory hole, it is up to the architecture to ensure
2508 * the memory is not freed by the bootmem allocator. If possible
2509 * the range being registered will be merged with existing ranges.
2510 */
2511void __init add_active_range(unsigned int nid, unsigned long start_pfn,
2512 unsigned long end_pfn)
2513{
2514 int i;
2515
2516 printk(KERN_DEBUG "Entering add_active_range(%d, %lu, %lu) "
2517 "%d entries of %d used\n",
2518 nid, start_pfn, end_pfn,
2519 nr_nodemap_entries, MAX_ACTIVE_REGIONS);
2520
2521 /* Merge with existing active regions if possible */
2522 for (i = 0; i < nr_nodemap_entries; i++) {
2523 if (early_node_map[i].nid != nid)
2524 continue;
2525
2526 /* Skip if an existing region covers this new one */
2527 if (start_pfn >= early_node_map[i].start_pfn &&
2528 end_pfn <= early_node_map[i].end_pfn)
2529 return;
2530
2531 /* Merge forward if suitable */
2532 if (start_pfn <= early_node_map[i].end_pfn &&
2533 end_pfn > early_node_map[i].end_pfn) {
2534 early_node_map[i].end_pfn = end_pfn;
2535 return;
2536 }
2537
2538 /* Merge backward if suitable */
2539 if (start_pfn < early_node_map[i].end_pfn &&
2540 end_pfn >= early_node_map[i].start_pfn) {
2541 early_node_map[i].start_pfn = start_pfn;
2542 return;
2543 }
2544 }
2545
2546 /* Check that early_node_map is large enough */
2547 if (i >= MAX_ACTIVE_REGIONS) {
2548 printk(KERN_CRIT "More than %d memory regions, truncating\n",
2549 MAX_ACTIVE_REGIONS);
2550 return;
2551 }
2552
2553 early_node_map[i].nid = nid;
2554 early_node_map[i].start_pfn = start_pfn;
2555 early_node_map[i].end_pfn = end_pfn;
2556 nr_nodemap_entries = i + 1;
2557}
2558
2559/**
2560 * shrink_active_range - Shrink an existing registered range of PFNs
2561 * @nid: The node id the range is on that should be shrunk
2562 * @old_end_pfn: The old end PFN of the range
2563 * @new_end_pfn: The new PFN of the range
2564 *
2565 * i386 with NUMA use alloc_remap() to store a node_mem_map on a local node.
2566 * The map is kept at the end physical page range that has already been
2567 * registered with add_active_range(). This function allows an arch to shrink
2568 * an existing registered range.
2569 */
2570void __init shrink_active_range(unsigned int nid, unsigned long old_end_pfn,
2571 unsigned long new_end_pfn)
2572{
2573 int i;
2574
2575 /* Find the old active region end and shrink */
2576 for_each_active_range_index_in_nid(i, nid)
2577 if (early_node_map[i].end_pfn == old_end_pfn) {
2578 early_node_map[i].end_pfn = new_end_pfn;
2579 break;
2580 }
2581}
2582
2583/**
2584 * remove_all_active_ranges - Remove all currently registered regions
2585 * During discovery, it may be found that a table like SRAT is invalid
2586 * and an alternative discovery method must be used. This function removes
2587 * all currently registered regions.
2588 */
2589void __init remove_all_active_ranges()
2590{
2591 memset(early_node_map, 0, sizeof(early_node_map));
2592 nr_nodemap_entries = 0;
2593#ifdef CONFIG_MEMORY_HOTPLUG_RESERVE
2594 memset(node_boundary_start_pfn, 0, sizeof(node_boundary_start_pfn));
2595 memset(node_boundary_end_pfn, 0, sizeof(node_boundary_end_pfn));
2596#endif /* CONFIG_MEMORY_HOTPLUG_RESERVE */
2597}
2598
2599/* Compare two active node_active_regions */
2600static int __init cmp_node_active_region(const void *a, const void *b)
2601{
2602 struct node_active_region *arange = (struct node_active_region *)a;
2603 struct node_active_region *brange = (struct node_active_region *)b;
2604
2605 /* Done this way to avoid overflows */
2606 if (arange->start_pfn > brange->start_pfn)
2607 return 1;
2608 if (arange->start_pfn < brange->start_pfn)
2609 return -1;
2610
2611 return 0;
2612}
2613
2614/* sort the node_map by start_pfn */
2615static void __init sort_node_map(void)
2616{
2617 sort(early_node_map, (size_t)nr_nodemap_entries,
2618 sizeof(struct node_active_region),
2619 cmp_node_active_region, NULL);
2620}
2621
2622/* Find the lowest pfn for a node. This depends on a sorted early_node_map */
2623unsigned long __init find_min_pfn_for_node(unsigned long nid)
2624{
2625 int i;
2626
2627 /* Assuming a sorted map, the first range found has the starting pfn */
2628 for_each_active_range_index_in_nid(i, nid)
2629 return early_node_map[i].start_pfn;
2630
2631 printk(KERN_WARNING "Could not find start_pfn for node %lu\n", nid);
2632 return 0;
2633}
2634
2635/**
2636 * find_min_pfn_with_active_regions - Find the minimum PFN registered
2637 *
2638 * It returns the minimum PFN based on information provided via
2639 * add_active_range()
2640 */
2641unsigned long __init find_min_pfn_with_active_regions(void)
2642{
2643 return find_min_pfn_for_node(MAX_NUMNODES);
2644}
2645
2646/**
2647 * find_max_pfn_with_active_regions - Find the maximum PFN registered
2648 *
2649 * It returns the maximum PFN based on information provided via
2650 * add_active_range()
2651 */
2652unsigned long __init find_max_pfn_with_active_regions(void)
2653{
2654 int i;
2655 unsigned long max_pfn = 0;
2656
2657 for (i = 0; i < nr_nodemap_entries; i++)
2658 max_pfn = max(max_pfn, early_node_map[i].end_pfn);
2659
2660 return max_pfn;
2661}
2662
2663/**
2664 * free_area_init_nodes - Initialise all pg_data_t and zone data
2665 * @arch_max_dma_pfn: The maximum PFN usable for ZONE_DMA
2666 * @arch_max_dma32_pfn: The maximum PFN usable for ZONE_DMA32
2667 * @arch_max_low_pfn: The maximum PFN usable for ZONE_NORMAL
2668 * @arch_max_high_pfn: The maximum PFN usable for ZONE_HIGHMEM
2669 *
2670 * This will call free_area_init_node() for each active node in the system.
2671 * Using the page ranges provided by add_active_range(), the size of each
2672 * zone in each node and their holes is calculated. If the maximum PFN
2673 * between two adjacent zones match, it is assumed that the zone is empty.
2674 * For example, if arch_max_dma_pfn == arch_max_dma32_pfn, it is assumed
2675 * that arch_max_dma32_pfn has no pages. It is also assumed that a zone
2676 * starts where the previous one ended. For example, ZONE_DMA32 starts
2677 * at arch_max_dma_pfn.
2678 */
2679void __init free_area_init_nodes(unsigned long *max_zone_pfn)
2680{
2681 unsigned long nid;
2682 enum zone_type i;
2683
2684 /* Record where the zone boundaries are */
2685 memset(arch_zone_lowest_possible_pfn, 0,
2686 sizeof(arch_zone_lowest_possible_pfn));
2687 memset(arch_zone_highest_possible_pfn, 0,
2688 sizeof(arch_zone_highest_possible_pfn));
2689 arch_zone_lowest_possible_pfn[0] = find_min_pfn_with_active_regions();
2690 arch_zone_highest_possible_pfn[0] = max_zone_pfn[0];
2691 for (i = 1; i < MAX_NR_ZONES; i++) {
2692 arch_zone_lowest_possible_pfn[i] =
2693 arch_zone_highest_possible_pfn[i-1];
2694 arch_zone_highest_possible_pfn[i] =
2695 max(max_zone_pfn[i], arch_zone_lowest_possible_pfn[i]);
2696 }
2697
2698 /* Regions in the early_node_map can be in any order */
2699 sort_node_map();
2700
2701 /* Print out the zone ranges */
2702 printk("Zone PFN ranges:\n");
2703 for (i = 0; i < MAX_NR_ZONES; i++)
2704 printk(" %-8s %8lu -> %8lu\n",
2705 zone_names[i],
2706 arch_zone_lowest_possible_pfn[i],
2707 arch_zone_highest_possible_pfn[i]);
2708
2709 /* Print out the early_node_map[] */
2710 printk("early_node_map[%d] active PFN ranges\n", nr_nodemap_entries);
2711 for (i = 0; i < nr_nodemap_entries; i++)
2712 printk(" %3d: %8lu -> %8lu\n", early_node_map[i].nid,
2713 early_node_map[i].start_pfn,
2714 early_node_map[i].end_pfn);
2715
2716 /* Initialise every node */
2717 for_each_online_node(nid) {
2718 pg_data_t *pgdat = NODE_DATA(nid);
2719 free_area_init_node(nid, pgdat, NULL,
2720 find_min_pfn_for_node(nid), NULL);
2721 }
2722}
2723#endif /* CONFIG_ARCH_POPULATES_NODE_MAP */
2724
2725/**
2726 * set_dma_reserve - Account the specified number of pages reserved in ZONE_DMA
2727 * @new_dma_reserve - The number of pages to mark reserved
2728 *
2729 * The per-cpu batchsize and zone watermarks are determined by present_pages.
2730 * In the DMA zone, a significant percentage may be consumed by kernel image
2731 * and other unfreeable allocations which can skew the watermarks badly. This
2732 * function may optionally be used to account for unfreeable pages in
2733 * ZONE_DMA. The effect will be lower watermarks and smaller per-cpu batchsize
2734 */
2735void __init set_dma_reserve(unsigned long new_dma_reserve)
2736{
2737 dma_reserve = new_dma_reserve;
2738}
2739
2095#ifndef CONFIG_NEED_MULTIPLE_NODES 2740#ifndef CONFIG_NEED_MULTIPLE_NODES
2096static bootmem_data_t contig_bootmem_data; 2741static bootmem_data_t contig_bootmem_data;
2097struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data }; 2742struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data };
diff --git a/mm/shmem.c b/mm/shmem.c
index 8631be45b40d..eda907c3a86a 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1351,7 +1351,6 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev)
1351 inode->i_mode = mode; 1351 inode->i_mode = mode;
1352 inode->i_uid = current->fsuid; 1352 inode->i_uid = current->fsuid;
1353 inode->i_gid = current->fsgid; 1353 inode->i_gid = current->fsgid;
1354 inode->i_blksize = PAGE_CACHE_SIZE;
1355 inode->i_blocks = 0; 1354 inode->i_blocks = 0;
1356 inode->i_mapping->a_ops = &shmem_aops; 1355 inode->i_mapping->a_ops = &shmem_aops;
1357 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info; 1356 inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
@@ -2157,8 +2156,7 @@ static int init_inodecache(void)
2157 2156
2158static void destroy_inodecache(void) 2157static void destroy_inodecache(void)
2159{ 2158{
2160 if (kmem_cache_destroy(shmem_inode_cachep)) 2159 kmem_cache_destroy(shmem_inode_cachep);
2161 printk(KERN_INFO "shmem_inode_cache: not all structures were freed\n");
2162} 2160}
2163 2161
2164static const struct address_space_operations shmem_aops = { 2162static const struct address_space_operations shmem_aops = {
diff --git a/mm/slab.c b/mm/slab.c
index 7a48eb1a60c8..792bfe320a8b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -972,7 +972,39 @@ static int transfer_objects(struct array_cache *to,
972 return nr; 972 return nr;
973} 973}
974 974
975#ifdef CONFIG_NUMA 975#ifndef CONFIG_NUMA
976
977#define drain_alien_cache(cachep, alien) do { } while (0)
978#define reap_alien(cachep, l3) do { } while (0)
979
980static inline struct array_cache **alloc_alien_cache(int node, int limit)
981{
982 return (struct array_cache **)BAD_ALIEN_MAGIC;
983}
984
985static inline void free_alien_cache(struct array_cache **ac_ptr)
986{
987}
988
989static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
990{
991 return 0;
992}
993
994static inline void *alternate_node_alloc(struct kmem_cache *cachep,
995 gfp_t flags)
996{
997 return NULL;
998}
999
1000static inline void *__cache_alloc_node(struct kmem_cache *cachep,
1001 gfp_t flags, int nodeid)
1002{
1003 return NULL;
1004}
1005
1006#else /* CONFIG_NUMA */
1007
976static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int); 1008static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
977static void *alternate_node_alloc(struct kmem_cache *, gfp_t); 1009static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
978 1010
@@ -1101,26 +1133,6 @@ static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1101 } 1133 }
1102 return 1; 1134 return 1;
1103} 1135}
1104
1105#else
1106
1107#define drain_alien_cache(cachep, alien) do { } while (0)
1108#define reap_alien(cachep, l3) do { } while (0)
1109
1110static inline struct array_cache **alloc_alien_cache(int node, int limit)
1111{
1112 return (struct array_cache **)BAD_ALIEN_MAGIC;
1113}
1114
1115static inline void free_alien_cache(struct array_cache **ac_ptr)
1116{
1117}
1118
1119static inline int cache_free_alien(struct kmem_cache *cachep, void *objp)
1120{
1121 return 0;
1122}
1123
1124#endif 1136#endif
1125 1137
1126static int __cpuinit cpuup_callback(struct notifier_block *nfb, 1138static int __cpuinit cpuup_callback(struct notifier_block *nfb,
@@ -1564,7 +1576,13 @@ static void *kmem_getpages(struct kmem_cache *cachep, gfp_t flags, int nodeid)
1564 */ 1576 */
1565 flags |= __GFP_COMP; 1577 flags |= __GFP_COMP;
1566#endif 1578#endif
1567 flags |= cachep->gfpflags; 1579
1580 /*
1581 * Under NUMA we want memory on the indicated node. We will handle
1582 * the needed fallback ourselves since we want to serve from our
1583 * per node object lists first for other nodes.
1584 */
1585 flags |= cachep->gfpflags | GFP_THISNODE;
1568 1586
1569 page = alloc_pages_node(nodeid, flags, cachep->gfporder); 1587 page = alloc_pages_node(nodeid, flags, cachep->gfporder);
1570 if (!page) 1588 if (!page)
@@ -2442,7 +2460,6 @@ EXPORT_SYMBOL(kmem_cache_shrink);
2442 * @cachep: the cache to destroy 2460 * @cachep: the cache to destroy
2443 * 2461 *
2444 * Remove a struct kmem_cache object from the slab cache. 2462 * Remove a struct kmem_cache object from the slab cache.
2445 * Returns 0 on success.
2446 * 2463 *
2447 * It is expected this function will be called by a module when it is 2464 * It is expected this function will be called by a module when it is
2448 * unloaded. This will remove the cache completely, and avoid a duplicate 2465 * unloaded. This will remove the cache completely, and avoid a duplicate
@@ -2454,7 +2471,7 @@ EXPORT_SYMBOL(kmem_cache_shrink);
2454 * The caller must guarantee that noone will allocate memory from the cache 2471 * The caller must guarantee that noone will allocate memory from the cache
2455 * during the kmem_cache_destroy(). 2472 * during the kmem_cache_destroy().
2456 */ 2473 */
2457int kmem_cache_destroy(struct kmem_cache *cachep) 2474void kmem_cache_destroy(struct kmem_cache *cachep)
2458{ 2475{
2459 BUG_ON(!cachep || in_interrupt()); 2476 BUG_ON(!cachep || in_interrupt());
2460 2477
@@ -2475,7 +2492,7 @@ int kmem_cache_destroy(struct kmem_cache *cachep)
2475 list_add(&cachep->next, &cache_chain); 2492 list_add(&cachep->next, &cache_chain);
2476 mutex_unlock(&cache_chain_mutex); 2493 mutex_unlock(&cache_chain_mutex);
2477 unlock_cpu_hotplug(); 2494 unlock_cpu_hotplug();
2478 return 1; 2495 return;
2479 } 2496 }
2480 2497
2481 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) 2498 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU))
@@ -2483,7 +2500,6 @@ int kmem_cache_destroy(struct kmem_cache *cachep)
2483 2500
2484 __kmem_cache_destroy(cachep); 2501 __kmem_cache_destroy(cachep);
2485 unlock_cpu_hotplug(); 2502 unlock_cpu_hotplug();
2486 return 0;
2487} 2503}
2488EXPORT_SYMBOL(kmem_cache_destroy); 2504EXPORT_SYMBOL(kmem_cache_destroy);
2489 2505
@@ -3030,14 +3046,6 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
3030 void *objp; 3046 void *objp;
3031 struct array_cache *ac; 3047 struct array_cache *ac;
3032 3048
3033#ifdef CONFIG_NUMA
3034 if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) {
3035 objp = alternate_node_alloc(cachep, flags);
3036 if (objp != NULL)
3037 return objp;
3038 }
3039#endif
3040
3041 check_irq_off(); 3049 check_irq_off();
3042 ac = cpu_cache_get(cachep); 3050 ac = cpu_cache_get(cachep);
3043 if (likely(ac->avail)) { 3051 if (likely(ac->avail)) {
@@ -3055,12 +3063,24 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
3055 gfp_t flags, void *caller) 3063 gfp_t flags, void *caller)
3056{ 3064{
3057 unsigned long save_flags; 3065 unsigned long save_flags;
3058 void *objp; 3066 void *objp = NULL;
3059 3067
3060 cache_alloc_debugcheck_before(cachep, flags); 3068 cache_alloc_debugcheck_before(cachep, flags);
3061 3069
3062 local_irq_save(save_flags); 3070 local_irq_save(save_flags);
3063 objp = ____cache_alloc(cachep, flags); 3071
3072 if (unlikely(NUMA_BUILD &&
3073 current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY)))
3074 objp = alternate_node_alloc(cachep, flags);
3075
3076 if (!objp)
3077 objp = ____cache_alloc(cachep, flags);
3078 /*
3079 * We may just have run out of memory on the local node.
3080 * __cache_alloc_node() knows how to locate memory on other nodes
3081 */
3082 if (NUMA_BUILD && !objp)
3083 objp = __cache_alloc_node(cachep, flags, numa_node_id());
3064 local_irq_restore(save_flags); 3084 local_irq_restore(save_flags);
3065 objp = cache_alloc_debugcheck_after(cachep, flags, objp, 3085 objp = cache_alloc_debugcheck_after(cachep, flags, objp,
3066 caller); 3086 caller);
@@ -3079,7 +3099,7 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3079{ 3099{
3080 int nid_alloc, nid_here; 3100 int nid_alloc, nid_here;
3081 3101
3082 if (in_interrupt()) 3102 if (in_interrupt() || (flags & __GFP_THISNODE))
3083 return NULL; 3103 return NULL;
3084 nid_alloc = nid_here = numa_node_id(); 3104 nid_alloc = nid_here = numa_node_id();
3085 if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD)) 3105 if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
@@ -3092,6 +3112,28 @@ static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
3092} 3112}
3093 3113
3094/* 3114/*
3115 * Fallback function if there was no memory available and no objects on a
3116 * certain node and we are allowed to fall back. We mimick the behavior of
3117 * the page allocator. We fall back according to a zonelist determined by
3118 * the policy layer while obeying cpuset constraints.
3119 */
3120void *fallback_alloc(struct kmem_cache *cache, gfp_t flags)
3121{
3122 struct zonelist *zonelist = &NODE_DATA(slab_node(current->mempolicy))
3123 ->node_zonelists[gfp_zone(flags)];
3124 struct zone **z;
3125 void *obj = NULL;
3126
3127 for (z = zonelist->zones; *z && !obj; z++)
3128 if (zone_idx(*z) <= ZONE_NORMAL &&
3129 cpuset_zone_allowed(*z, flags))
3130 obj = __cache_alloc_node(cache,
3131 flags | __GFP_THISNODE,
3132 zone_to_nid(*z));
3133 return obj;
3134}
3135
3136/*
3095 * A interface to enable slab creation on nodeid 3137 * A interface to enable slab creation on nodeid
3096 */ 3138 */
3097static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, 3139static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
@@ -3144,11 +3186,15 @@ retry:
3144must_grow: 3186must_grow:
3145 spin_unlock(&l3->list_lock); 3187 spin_unlock(&l3->list_lock);
3146 x = cache_grow(cachep, flags, nodeid); 3188 x = cache_grow(cachep, flags, nodeid);
3189 if (x)
3190 goto retry;
3147 3191
3148 if (!x) 3192 if (!(flags & __GFP_THISNODE))
3149 return NULL; 3193 /* Unable to grow the cache. Fall back to other nodes. */
3194 return fallback_alloc(cachep, flags);
3195
3196 return NULL;
3150 3197
3151 goto retry;
3152done: 3198done:
3153 return obj; 3199 return obj;
3154} 3200}
diff --git a/mm/slob.c b/mm/slob.c
index 20188627347c..542394184a58 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -270,10 +270,9 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
270} 270}
271EXPORT_SYMBOL(kmem_cache_create); 271EXPORT_SYMBOL(kmem_cache_create);
272 272
273int kmem_cache_destroy(struct kmem_cache *c) 273void kmem_cache_destroy(struct kmem_cache *c)
274{ 274{
275 slob_free(c, sizeof(struct kmem_cache)); 275 slob_free(c, sizeof(struct kmem_cache));
276 return 0;
277} 276}
278EXPORT_SYMBOL(kmem_cache_destroy); 277EXPORT_SYMBOL(kmem_cache_destroy);
279 278
diff --git a/mm/truncate.c b/mm/truncate.c
index c6ab55ec6883..a654928323dc 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -9,6 +9,7 @@
9 9
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/swap.h>
12#include <linux/module.h> 13#include <linux/module.h>
13#include <linux/pagemap.h> 14#include <linux/pagemap.h>
14#include <linux/pagevec.h> 15#include <linux/pagevec.h>
@@ -52,36 +53,26 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
52/* 53/*
53 * This is for invalidate_inode_pages(). That function can be called at 54 * This is for invalidate_inode_pages(). That function can be called at
54 * any time, and is not supposed to throw away dirty pages. But pages can 55 * any time, and is not supposed to throw away dirty pages. But pages can
55 * be marked dirty at any time too. So we re-check the dirtiness inside 56 * be marked dirty at any time too, so use remove_mapping which safely
56 * ->tree_lock. That provides exclusion against the __set_page_dirty 57 * discards clean, unused pages.
57 * functions.
58 * 58 *
59 * Returns non-zero if the page was successfully invalidated. 59 * Returns non-zero if the page was successfully invalidated.
60 */ 60 */
61static int 61static int
62invalidate_complete_page(struct address_space *mapping, struct page *page) 62invalidate_complete_page(struct address_space *mapping, struct page *page)
63{ 63{
64 int ret;
65
64 if (page->mapping != mapping) 66 if (page->mapping != mapping)
65 return 0; 67 return 0;
66 68
67 if (PagePrivate(page) && !try_to_release_page(page, 0)) 69 if (PagePrivate(page) && !try_to_release_page(page, 0))
68 return 0; 70 return 0;
69 71
70 write_lock_irq(&mapping->tree_lock); 72 ret = remove_mapping(mapping, page);
71 if (PageDirty(page))
72 goto failed;
73 if (page_count(page) != 2) /* caller's ref + pagecache ref */
74 goto failed;
75
76 BUG_ON(PagePrivate(page));
77 __remove_from_page_cache(page);
78 write_unlock_irq(&mapping->tree_lock);
79 ClearPageUptodate(page); 73 ClearPageUptodate(page);
80 page_cache_release(page); /* pagecache ref */ 74
81 return 1; 75 return ret;
82failed:
83 write_unlock_irq(&mapping->tree_lock);
84 return 0;
85} 76}
86 77
87/** 78/**
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 9aad8b0cc6ee..1ac191ce5641 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -241,7 +241,6 @@ struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
241 241
242/** 242/**
243 * get_vm_area - reserve a contingous kernel virtual area 243 * get_vm_area - reserve a contingous kernel virtual area
244 *
245 * @size: size of the area 244 * @size: size of the area
246 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC 245 * @flags: %VM_IOREMAP for I/O mappings or VM_ALLOC
247 * 246 *
@@ -273,7 +272,7 @@ static struct vm_struct *__find_vm_area(void *addr)
273} 272}
274 273
275/* Caller must hold vmlist_lock */ 274/* Caller must hold vmlist_lock */
276struct vm_struct *__remove_vm_area(void *addr) 275static struct vm_struct *__remove_vm_area(void *addr)
277{ 276{
278 struct vm_struct **p, *tmp; 277 struct vm_struct **p, *tmp;
279 278
@@ -296,7 +295,6 @@ found:
296 295
297/** 296/**
298 * remove_vm_area - find and remove a contingous kernel virtual area 297 * remove_vm_area - find and remove a contingous kernel virtual area
299 *
300 * @addr: base address 298 * @addr: base address
301 * 299 *
302 * Search for the kernel VM area starting at @addr, and remove it. 300 * Search for the kernel VM area starting at @addr, and remove it.
@@ -355,7 +353,6 @@ void __vunmap(void *addr, int deallocate_pages)
355 353
356/** 354/**
357 * vfree - release memory allocated by vmalloc() 355 * vfree - release memory allocated by vmalloc()
358 *
359 * @addr: memory base address 356 * @addr: memory base address
360 * 357 *
361 * Free the virtually contiguous memory area starting at @addr, as 358 * Free the virtually contiguous memory area starting at @addr, as
@@ -373,7 +370,6 @@ EXPORT_SYMBOL(vfree);
373 370
374/** 371/**
375 * vunmap - release virtual mapping obtained by vmap() 372 * vunmap - release virtual mapping obtained by vmap()
376 *
377 * @addr: memory base address 373 * @addr: memory base address
378 * 374 *
379 * Free the virtually contiguous memory area starting at @addr, 375 * Free the virtually contiguous memory area starting at @addr,
@@ -390,7 +386,6 @@ EXPORT_SYMBOL(vunmap);
390 386
391/** 387/**
392 * vmap - map an array of pages into virtually contiguous space 388 * vmap - map an array of pages into virtually contiguous space
393 *
394 * @pages: array of page pointers 389 * @pages: array of page pointers
395 * @count: number of pages to map 390 * @count: number of pages to map
396 * @flags: vm_area->flags 391 * @flags: vm_area->flags
@@ -471,7 +466,6 @@ void *__vmalloc_area(struct vm_struct *area, gfp_t gfp_mask, pgprot_t prot)
471 466
472/** 467/**
473 * __vmalloc_node - allocate virtually contiguous memory 468 * __vmalloc_node - allocate virtually contiguous memory
474 *
475 * @size: allocation size 469 * @size: allocation size
476 * @gfp_mask: flags for the page level allocator 470 * @gfp_mask: flags for the page level allocator
477 * @prot: protection mask for the allocated pages 471 * @prot: protection mask for the allocated pages
@@ -505,9 +499,7 @@ EXPORT_SYMBOL(__vmalloc);
505 499
506/** 500/**
507 * vmalloc - allocate virtually contiguous memory 501 * vmalloc - allocate virtually contiguous memory
508 *
509 * @size: allocation size 502 * @size: allocation size
510 *
511 * Allocate enough pages to cover @size from the page level 503 * Allocate enough pages to cover @size from the page level
512 * allocator and map them into contiguous kernel virtual space. 504 * allocator and map them into contiguous kernel virtual space.
513 * 505 *
@@ -521,11 +513,11 @@ void *vmalloc(unsigned long size)
521EXPORT_SYMBOL(vmalloc); 513EXPORT_SYMBOL(vmalloc);
522 514
523/** 515/**
524 * vmalloc_user - allocate virtually contiguous memory which has 516 * vmalloc_user - allocate zeroed virtually contiguous memory for userspace
525 * been zeroed so it can be mapped to userspace without 517 * @size: allocation size
526 * leaking data.
527 * 518 *
528 * @size: allocation size 519 * The resulting memory area is zeroed so it can be mapped to userspace
520 * without leaking data.
529 */ 521 */
530void *vmalloc_user(unsigned long size) 522void *vmalloc_user(unsigned long size)
531{ 523{
@@ -544,7 +536,6 @@ EXPORT_SYMBOL(vmalloc_user);
544 536
545/** 537/**
546 * vmalloc_node - allocate memory on a specific node 538 * vmalloc_node - allocate memory on a specific node
547 *
548 * @size: allocation size 539 * @size: allocation size
549 * @node: numa node 540 * @node: numa node
550 * 541 *
@@ -566,7 +557,6 @@ EXPORT_SYMBOL(vmalloc_node);
566 557
567/** 558/**
568 * vmalloc_exec - allocate virtually contiguous, executable memory 559 * vmalloc_exec - allocate virtually contiguous, executable memory
569 *
570 * @size: allocation size 560 * @size: allocation size
571 * 561 *
572 * Kernel-internal function to allocate enough pages to cover @size 562 * Kernel-internal function to allocate enough pages to cover @size
@@ -584,7 +574,6 @@ void *vmalloc_exec(unsigned long size)
584 574
585/** 575/**
586 * vmalloc_32 - allocate virtually contiguous memory (32bit addressable) 576 * vmalloc_32 - allocate virtually contiguous memory (32bit addressable)
587 *
588 * @size: allocation size 577 * @size: allocation size
589 * 578 *
590 * Allocate enough 32bit PA addressable pages to cover @size from the 579 * Allocate enough 32bit PA addressable pages to cover @size from the
@@ -597,11 +586,11 @@ void *vmalloc_32(unsigned long size)
597EXPORT_SYMBOL(vmalloc_32); 586EXPORT_SYMBOL(vmalloc_32);
598 587
599/** 588/**
600 * vmalloc_32_user - allocate virtually contiguous memory (32bit 589 * vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory
601 * addressable) which is zeroed so it can be
602 * mapped to userspace without leaking data.
603 *
604 * @size: allocation size 590 * @size: allocation size
591 *
592 * The resulting memory area is 32bit addressable and zeroed so it can be
593 * mapped to userspace without leaking data.
605 */ 594 */
606void *vmalloc_32_user(unsigned long size) 595void *vmalloc_32_user(unsigned long size)
607{ 596{
@@ -695,7 +684,6 @@ finished:
695 684
696/** 685/**
697 * remap_vmalloc_range - map vmalloc pages to userspace 686 * remap_vmalloc_range - map vmalloc pages to userspace
698 *
699 * @vma: vma to cover (map full range of vma) 687 * @vma: vma to cover (map full range of vma)
700 * @addr: vmalloc memory 688 * @addr: vmalloc memory
701 * @pgoff: number of pages into addr before first page to map 689 * @pgoff: number of pages into addr before first page to map
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 87779dda4ec6..eca70310adb2 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -19,6 +19,7 @@
19#include <linux/pagemap.h> 19#include <linux/pagemap.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include <linux/highmem.h> 21#include <linux/highmem.h>
22#include <linux/vmstat.h>
22#include <linux/file.h> 23#include <linux/file.h>
23#include <linux/writeback.h> 24#include <linux/writeback.h>
24#include <linux/blkdev.h> 25#include <linux/blkdev.h>
@@ -370,7 +371,7 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)
370 /* synchronous write or broken a_ops? */ 371 /* synchronous write or broken a_ops? */
371 ClearPageReclaim(page); 372 ClearPageReclaim(page);
372 } 373 }
373 374 inc_zone_page_state(page, NR_VMSCAN_WRITE);
374 return PAGE_SUCCESS; 375 return PAGE_SUCCESS;
375 } 376 }
376 377
@@ -383,11 +384,30 @@ int remove_mapping(struct address_space *mapping, struct page *page)
383 BUG_ON(mapping != page_mapping(page)); 384 BUG_ON(mapping != page_mapping(page));
384 385
385 write_lock_irq(&mapping->tree_lock); 386 write_lock_irq(&mapping->tree_lock);
386
387 /* 387 /*
388 * The non-racy check for busy page. It is critical to check 388 * The non racy check for a busy page.
389 * PageDirty _after_ making sure that the page is freeable and 389 *
390 * not in use by anybody. (pagecache + us == 2) 390 * Must be careful with the order of the tests. When someone has
391 * a ref to the page, it may be possible that they dirty it then
392 * drop the reference. So if PageDirty is tested before page_count
393 * here, then the following race may occur:
394 *
395 * get_user_pages(&page);
396 * [user mapping goes away]
397 * write_to(page);
398 * !PageDirty(page) [good]
399 * SetPageDirty(page);
400 * put_page(page);
401 * !page_count(page) [good, discard it]
402 *
403 * [oops, our write_to data is lost]
404 *
405 * Reversing the order of the tests ensures such a situation cannot
406 * escape unnoticed. The smp_rmb is needed to ensure the page->flags
407 * load is not satisfied before that of page->_count.
408 *
409 * Note that if SetPageDirty is always performed via set_page_dirty,
410 * and thus under tree_lock, then this ordering is not required.
391 */ 411 */
392 if (unlikely(page_count(page) != 2)) 412 if (unlikely(page_count(page) != 2))
393 goto cannot_free; 413 goto cannot_free;
diff --git a/mm/vmstat.c b/mm/vmstat.c
index 490d8c1a0ded..a2b6a9f96e5c 100644
--- a/mm/vmstat.c
+++ b/mm/vmstat.c
@@ -371,7 +371,7 @@ void zone_statistics(struct zonelist *zonelist, struct zone *z)
371 __inc_zone_state(z, NUMA_MISS); 371 __inc_zone_state(z, NUMA_MISS);
372 __inc_zone_state(zonelist->zones[0], NUMA_FOREIGN); 372 __inc_zone_state(zonelist->zones[0], NUMA_FOREIGN);
373 } 373 }
374 if (z->zone_pgdat == NODE_DATA(numa_node_id())) 374 if (z->node == numa_node_id())
375 __inc_zone_state(z, NUMA_LOCAL); 375 __inc_zone_state(z, NUMA_LOCAL);
376 else 376 else
377 __inc_zone_state(z, NUMA_OTHER); 377 __inc_zone_state(z, NUMA_OTHER);
@@ -465,6 +465,7 @@ static char *vmstat_text[] = {
465 "nr_writeback", 465 "nr_writeback",
466 "nr_unstable", 466 "nr_unstable",
467 "nr_bounce", 467 "nr_bounce",
468 "nr_vmscan_write",
468 469
469#ifdef CONFIG_NUMA 470#ifdef CONFIG_NUMA
470 "numa_hit", 471 "numa_hit",
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 13472762b18b..f47f319bb7dc 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -344,8 +344,6 @@ static ssize_t wireless_show(struct class_device *cd, char *buf,
344 if(dev->wireless_handlers && 344 if(dev->wireless_handlers &&
345 dev->wireless_handlers->get_wireless_stats) 345 dev->wireless_handlers->get_wireless_stats)
346 iw = dev->wireless_handlers->get_wireless_stats(dev); 346 iw = dev->wireless_handlers->get_wireless_stats(dev);
347 else if (dev->get_wireless_stats)
348 iw = dev->get_wireless_stats(dev);
349 if (iw != NULL) 347 if (iw != NULL)
350 ret = (*format)(iw, buf); 348 ret = (*format)(iw, buf);
351 } 349 }
@@ -465,8 +463,7 @@ int netdev_register_sysfs(struct net_device *net)
465 *groups++ = &netstat_group; 463 *groups++ = &netstat_group;
466 464
467#ifdef WIRELESS_EXT 465#ifdef WIRELESS_EXT
468 if (net->get_wireless_stats 466 if (net->wireless_handlers && net->wireless_handlers->get_wireless_stats)
469 || (net->wireless_handlers && net->wireless_handlers->get_wireless_stats))
470 *groups++ = &wireless_group; 467 *groups++ = &wireless_group;
471#endif 468#endif
472 469
diff --git a/net/core/wireless.c b/net/core/wireless.c
index 3168fca312f7..ffff0da46c6e 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -68,6 +68,14 @@
68 * 68 *
69 * v8 - 17.02.06 - Jean II 69 * v8 - 17.02.06 - Jean II
70 * o RtNetlink requests support (SET/GET) 70 * o RtNetlink requests support (SET/GET)
71 *
72 * v8b - 03.08.06 - Herbert Xu
73 * o Fix Wireless Event locking issues.
74 *
75 * v9 - 14.3.06 - Jean II
76 * o Change length in ESSID and NICK to strlen() instead of strlen()+1
77 * o Make standard_ioctl_num and standard_event_num unsigned
78 * o Remove (struct net_device *)->get_wireless_stats()
71 */ 79 */
72 80
73/***************************** INCLUDES *****************************/ 81/***************************** INCLUDES *****************************/
@@ -234,24 +242,24 @@ static const struct iw_ioctl_description standard_ioctl[] = {
234 [SIOCSIWESSID - SIOCIWFIRST] = { 242 [SIOCSIWESSID - SIOCIWFIRST] = {
235 .header_type = IW_HEADER_TYPE_POINT, 243 .header_type = IW_HEADER_TYPE_POINT,
236 .token_size = 1, 244 .token_size = 1,
237 .max_tokens = IW_ESSID_MAX_SIZE + 1, 245 .max_tokens = IW_ESSID_MAX_SIZE,
238 .flags = IW_DESCR_FLAG_EVENT, 246 .flags = IW_DESCR_FLAG_EVENT,
239 }, 247 },
240 [SIOCGIWESSID - SIOCIWFIRST] = { 248 [SIOCGIWESSID - SIOCIWFIRST] = {
241 .header_type = IW_HEADER_TYPE_POINT, 249 .header_type = IW_HEADER_TYPE_POINT,
242 .token_size = 1, 250 .token_size = 1,
243 .max_tokens = IW_ESSID_MAX_SIZE + 1, 251 .max_tokens = IW_ESSID_MAX_SIZE,
244 .flags = IW_DESCR_FLAG_DUMP, 252 .flags = IW_DESCR_FLAG_DUMP,
245 }, 253 },
246 [SIOCSIWNICKN - SIOCIWFIRST] = { 254 [SIOCSIWNICKN - SIOCIWFIRST] = {
247 .header_type = IW_HEADER_TYPE_POINT, 255 .header_type = IW_HEADER_TYPE_POINT,
248 .token_size = 1, 256 .token_size = 1,
249 .max_tokens = IW_ESSID_MAX_SIZE + 1, 257 .max_tokens = IW_ESSID_MAX_SIZE,
250 }, 258 },
251 [SIOCGIWNICKN - SIOCIWFIRST] = { 259 [SIOCGIWNICKN - SIOCIWFIRST] = {
252 .header_type = IW_HEADER_TYPE_POINT, 260 .header_type = IW_HEADER_TYPE_POINT,
253 .token_size = 1, 261 .token_size = 1,
254 .max_tokens = IW_ESSID_MAX_SIZE + 1, 262 .max_tokens = IW_ESSID_MAX_SIZE,
255 }, 263 },
256 [SIOCSIWRATE - SIOCIWFIRST] = { 264 [SIOCSIWRATE - SIOCIWFIRST] = {
257 .header_type = IW_HEADER_TYPE_PARAM, 265 .header_type = IW_HEADER_TYPE_PARAM,
@@ -338,8 +346,8 @@ static const struct iw_ioctl_description standard_ioctl[] = {
338 .max_tokens = sizeof(struct iw_pmksa), 346 .max_tokens = sizeof(struct iw_pmksa),
339 }, 347 },
340}; 348};
341static const int standard_ioctl_num = (sizeof(standard_ioctl) / 349static const unsigned standard_ioctl_num = (sizeof(standard_ioctl) /
342 sizeof(struct iw_ioctl_description)); 350 sizeof(struct iw_ioctl_description));
343 351
344/* 352/*
345 * Meta-data about all the additional standard Wireless Extension events 353 * Meta-data about all the additional standard Wireless Extension events
@@ -389,8 +397,8 @@ static const struct iw_ioctl_description standard_event[] = {
389 .max_tokens = sizeof(struct iw_pmkid_cand), 397 .max_tokens = sizeof(struct iw_pmkid_cand),
390 }, 398 },
391}; 399};
392static const int standard_event_num = (sizeof(standard_event) / 400static const unsigned standard_event_num = (sizeof(standard_event) /
393 sizeof(struct iw_ioctl_description)); 401 sizeof(struct iw_ioctl_description));
394 402
395/* Size (in bytes) of the various private data types */ 403/* Size (in bytes) of the various private data types */
396static const char iw_priv_type_size[] = { 404static const char iw_priv_type_size[] = {
@@ -465,17 +473,6 @@ static inline struct iw_statistics *get_wireless_stats(struct net_device *dev)
465 (dev->wireless_handlers->get_wireless_stats != NULL)) 473 (dev->wireless_handlers->get_wireless_stats != NULL))
466 return dev->wireless_handlers->get_wireless_stats(dev); 474 return dev->wireless_handlers->get_wireless_stats(dev);
467 475
468 /* Old location, field to be removed in next WE */
469 if(dev->get_wireless_stats) {
470 static int printed_message;
471
472 if (!printed_message++)
473 printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
474 dev->name);
475
476 return dev->get_wireless_stats(dev);
477 }
478
479 /* Not found */ 476 /* Not found */
480 return (struct iw_statistics *) NULL; 477 return (struct iw_statistics *) NULL;
481} 478}
@@ -1843,8 +1840,33 @@ int wireless_rtnetlink_set(struct net_device * dev,
1843 */ 1840 */
1844 1841
1845#ifdef WE_EVENT_RTNETLINK 1842#ifdef WE_EVENT_RTNETLINK
1843/* ---------------------------------------------------------------- */
1844/*
1845 * Locking...
1846 * ----------
1847 *
1848 * Thanks to Herbert Xu <herbert@gondor.apana.org.au> for fixing
1849 * the locking issue in here and implementing this code !
1850 *
1851 * The issue : wireless_send_event() is often called in interrupt context,
1852 * while the Netlink layer can never be called in interrupt context.
1853 * The fully formed RtNetlink events are queued, and then a tasklet is run
1854 * to feed those to Netlink.
1855 * The skb_queue is interrupt safe, and its lock is not held while calling
1856 * Netlink, so there is no possibility of dealock.
1857 * Jean II
1858 */
1859
1846static struct sk_buff_head wireless_nlevent_queue; 1860static struct sk_buff_head wireless_nlevent_queue;
1847 1861
1862static int __init wireless_nlevent_init(void)
1863{
1864 skb_queue_head_init(&wireless_nlevent_queue);
1865 return 0;
1866}
1867
1868subsys_initcall(wireless_nlevent_init);
1869
1848static void wireless_nlevent_process(unsigned long data) 1870static void wireless_nlevent_process(unsigned long data)
1849{ 1871{
1850 struct sk_buff *skb; 1872 struct sk_buff *skb;
@@ -1921,13 +1943,6 @@ static inline void rtmsg_iwinfo(struct net_device * dev,
1921 tasklet_schedule(&wireless_nlevent_tasklet); 1943 tasklet_schedule(&wireless_nlevent_tasklet);
1922} 1944}
1923 1945
1924static int __init wireless_nlevent_init(void)
1925{
1926 skb_queue_head_init(&wireless_nlevent_queue);
1927 return 0;
1928}
1929
1930subsys_initcall(wireless_nlevent_init);
1931#endif /* WE_EVENT_RTNETLINK */ 1946#endif /* WE_EVENT_RTNETLINK */
1932 1947
1933/* ---------------------------------------------------------------- */ 1948/* ---------------------------------------------------------------- */
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
index 75320b6842ab..2aa779d18f38 100644
--- a/net/ieee80211/softmac/ieee80211softmac_wx.c
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -80,10 +80,10 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
80 * If it's our network, ignore the change, we're already doing it! 80 * If it's our network, ignore the change, we're already doing it!
81 */ 81 */
82 if((sm->associnfo.associating || sm->associated) && 82 if((sm->associnfo.associating || sm->associated) &&
83 (data->essid.flags && data->essid.length && extra)) { 83 (data->essid.flags && data->essid.length)) {
84 /* Get the associating network */ 84 /* Get the associating network */
85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid); 85 n = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
86 if(n && n->essid.len == (data->essid.length - 1) && 86 if(n && n->essid.len == data->essid.length &&
87 !memcmp(n->essid.data, extra, n->essid.len)) { 87 !memcmp(n->essid.data, extra, n->essid.len)) {
88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n", 88 dprintk(KERN_INFO PFX "Already associating or associated to "MAC_FMT"\n",
89 MAC_ARG(sm->associnfo.bssid)); 89 MAC_ARG(sm->associnfo.bssid));
@@ -109,8 +109,8 @@ ieee80211softmac_wx_set_essid(struct net_device *net_dev,
109 sm->associnfo.static_essid = 0; 109 sm->associnfo.static_essid = 0;
110 sm->associnfo.assoc_wait = 0; 110 sm->associnfo.assoc_wait = 0;
111 111
112 if (data->essid.flags && data->essid.length && extra /*required?*/) { 112 if (data->essid.flags && data->essid.length) {
113 length = min(data->essid.length - 1, IW_ESSID_MAX_SIZE); 113 length = min((int)data->essid.length, IW_ESSID_MAX_SIZE);
114 if (length) { 114 if (length) {
115 memcpy(sm->associnfo.req_essid.data, extra, length); 115 memcpy(sm->associnfo.req_essid.data, extra, length);
116 sm->associnfo.static_essid = 1; 116 sm->associnfo.static_essid = 1;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index dfa504fe383f..700c6e061a04 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -488,7 +488,6 @@ rpc_get_inode(struct super_block *sb, int mode)
488 return NULL; 488 return NULL;
489 inode->i_mode = mode; 489 inode->i_mode = mode;
490 inode->i_uid = inode->i_gid = 0; 490 inode->i_uid = inode->i_gid = 0;
491 inode->i_blksize = PAGE_CACHE_SIZE;
492 inode->i_blocks = 0; 491 inode->i_blocks = 0;
493 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 492 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
494 switch(mode & S_IFMT) { 493 switch(mode & S_IFMT) {
@@ -858,7 +857,6 @@ int register_rpc_pipefs(void)
858 857
859void unregister_rpc_pipefs(void) 858void unregister_rpc_pipefs(void)
860{ 859{
861 if (kmem_cache_destroy(rpc_inode_cachep)) 860 kmem_cache_destroy(rpc_inode_cachep);
862 printk(KERN_WARNING "RPC: unable to free inode cache\n");
863 unregister_filesystem(&rpc_pipe_fs_type); 861 unregister_filesystem(&rpc_pipe_fs_type);
864} 862}
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 6390461a9756..a1ab4eed41f4 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -1059,10 +1059,10 @@ rpc_destroy_mempool(void)
1059 mempool_destroy(rpc_buffer_mempool); 1059 mempool_destroy(rpc_buffer_mempool);
1060 if (rpc_task_mempool) 1060 if (rpc_task_mempool)
1061 mempool_destroy(rpc_task_mempool); 1061 mempool_destroy(rpc_task_mempool);
1062 if (rpc_task_slabp && kmem_cache_destroy(rpc_task_slabp)) 1062 if (rpc_task_slabp)
1063 printk(KERN_INFO "rpc_task: not all structures were freed\n"); 1063 kmem_cache_destroy(rpc_task_slabp);
1064 if (rpc_buffer_slabp && kmem_cache_destroy(rpc_buffer_slabp)) 1064 if (rpc_buffer_slabp)
1065 printk(KERN_INFO "rpc_buffers: not all structures were freed\n"); 1065 kmem_cache_destroy(rpc_buffer_slabp);
1066} 1066}
1067 1067
1068int 1068int
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 3d523899fdc0..4f5ff19b992b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -63,6 +63,13 @@ as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
63 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ 63 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
64 else echo "$(2)"; fi ;) 64 else echo "$(2)"; fi ;)
65 65
66# as-instr
67# Usage: cflags-y += $(call as-instr, instr, option1, option2)
68
69as-instr = $(shell if echo -e "$(1)" | $(AS) >/dev/null 2>&1 -W -Z -o astest$$$$.out ; \
70 then echo "$(2)"; else echo "$(3)"; fi; \
71 rm -f astest$$$$.out)
72
66# cc-option 73# cc-option
67# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) 74# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
68 75
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
new file mode 100644
index 000000000000..325c0a1b03b6
--- /dev/null
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -0,0 +1,6 @@
1#!/bin/sh
2
3echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
4if [ "$?" -eq "0" ] ; then
5 echo $2
6fi
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index de76da80443f..f61c9ccef6aa 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -444,6 +444,14 @@ static int do_input_entry(const char *filename, struct input_device_id *id,
444 return 1; 444 return 1;
445} 445}
446 446
447static int do_eisa_entry(const char *filename, struct eisa_device_id *eisa,
448 char *alias)
449{
450 if (eisa->sig[0])
451 sprintf(alias, EISA_DEVICE_MODALIAS_FMT "*", eisa->sig);
452 return 1;
453}
454
447/* Ignore any prefix, eg. v850 prepends _ */ 455/* Ignore any prefix, eg. v850 prepends _ */
448static inline int sym_is(const char *symbol, const char *name) 456static inline int sym_is(const char *symbol, const char *name)
449{ 457{
@@ -547,6 +555,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
547 do_table(symval, sym->st_size, 555 do_table(symval, sym->st_size,
548 sizeof(struct input_device_id), "input", 556 sizeof(struct input_device_id), "input",
549 do_input_entry, mod); 557 do_input_entry, mod);
558 else if (sym_is(symname, "__mod_eisa_device_table"))
559 do_table(symval, sym->st_size,
560 sizeof(struct eisa_device_id), "eisa",
561 do_eisa_entry, mod);
550} 562}
551 563
552/* Now add out buffered information to the generated C source */ 564/* Now add out buffered information to the generated C source */
diff --git a/security/inode.c b/security/inode.c
index 47eb63480dac..49ee51529396 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -44,8 +44,8 @@ static ssize_t default_write_file(struct file *file, const char __user *buf,
44 44
45static int default_open(struct inode *inode, struct file *file) 45static int default_open(struct inode *inode, struct file *file)
46{ 46{
47 if (inode->u.generic_ip) 47 if (inode->i_private)
48 file->private_data = inode->u.generic_ip; 48 file->private_data = inode->i_private;
49 49
50 return 0; 50 return 0;
51} 51}
@@ -64,7 +64,6 @@ static struct inode *get_inode(struct super_block *sb, int mode, dev_t dev)
64 inode->i_mode = mode; 64 inode->i_mode = mode;
65 inode->i_uid = 0; 65 inode->i_uid = 0;
66 inode->i_gid = 0; 66 inode->i_gid = 0;
67 inode->i_blksize = PAGE_CACHE_SIZE;
68 inode->i_blocks = 0; 67 inode->i_blocks = 0;
69 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 68 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
70 switch (mode & S_IFMT) { 69 switch (mode & S_IFMT) {
@@ -194,7 +193,7 @@ static int create_by_name(const char *name, mode_t mode,
194 * directory dentry if set. If this paramater is NULL, then the 193 * directory dentry if set. If this paramater is NULL, then the
195 * file will be created in the root of the securityfs filesystem. 194 * file will be created in the root of the securityfs filesystem.
196 * @data: a pointer to something that the caller will want to get to later 195 * @data: a pointer to something that the caller will want to get to later
197 * on. The inode.u.generic_ip pointer will point to this value on 196 * on. The inode.i_private pointer will point to this value on
198 * the open() call. 197 * the open() call.
199 * @fops: a pointer to a struct file_operations that should be used for 198 * @fops: a pointer to a struct file_operations that should be used for
200 * this file. 199 * this file.
@@ -240,7 +239,7 @@ struct dentry *securityfs_create_file(const char *name, mode_t mode,
240 if (fops) 239 if (fops)
241 dentry->d_inode->i_fop = fops; 240 dentry->d_inode->i_fop = fops;
242 if (data) 241 if (data)
243 dentry->d_inode->u.generic_ip = data; 242 dentry->d_inode->i_private = data;
244 } 243 }
245exit: 244exit:
246 return dentry; 245 return dentry;
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 00534c302ba2..bab7b386cb8d 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -771,7 +771,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
771 if (ret) { 771 if (ret) {
772 ret->i_mode = mode; 772 ret->i_mode = mode;
773 ret->i_uid = ret->i_gid = 0; 773 ret->i_uid = ret->i_gid = 0;
774 ret->i_blksize = PAGE_CACHE_SIZE;
775 ret->i_blocks = 0; 774 ret->i_blocks = 0;
776 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME; 775 ret->i_atime = ret->i_mtime = ret->i_ctime = CURRENT_TIME;
777 } 776 }
diff --git a/sound/oss/sh_dac_audio.c b/sound/oss/sh_dac_audio.c
index 7b168d85f4ab..83ff8a71f716 100644
--- a/sound/oss/sh_dac_audio.c
+++ b/sound/oss/sh_dac_audio.c
@@ -1,3 +1,14 @@
1/*
2 * sound/oss/sh_dac_audio.c
3 *
4 * SH DAC based sound :(
5 *
6 * Copyright (C) 2004,2005 Andriy Skulysh
7 *
8 * This file is subject to the terms and conditions of the GNU General Public
9 * License. See the file "COPYING" in the main directory of this archive
10 * for more details.
11 */
1#include <linux/module.h> 12#include <linux/module.h>
2#include <linux/init.h> 13#include <linux/init.h>
3#include <linux/sched.h> 14#include <linux/sched.h>
@@ -6,18 +17,17 @@
6#include <linux/fs.h> 17#include <linux/fs.h>
7#include <linux/sound.h> 18#include <linux/sound.h>
8#include <linux/soundcard.h> 19#include <linux/soundcard.h>
20#include <linux/interrupt.h>
9#include <asm/io.h> 21#include <asm/io.h>
10#include <asm/uaccess.h> 22#include <asm/uaccess.h>
11#include <asm/irq.h> 23#include <asm/irq.h>
12#include <asm/delay.h> 24#include <asm/delay.h>
13#include <linux/interrupt.h> 25#include <asm/clock.h>
14
15#include <asm/cpu/dac.h> 26#include <asm/cpu/dac.h>
16 27#include <asm/cpu/timer.h>
17#ifdef MACH_HP600 28#include <asm/machvec.h>
18#include <asm/hp6xx/hp6xx.h> 29#include <asm/hp6xx/hp6xx.h>
19#include <asm/hd64461/hd64461.h> 30#include <asm/hd64461.h>
20#endif
21 31
22#define MODNAME "sh_dac_audio" 32#define MODNAME "sh_dac_audio"
23 33
@@ -26,11 +36,6 @@
26#define TMU1_TCR_INIT 0x0020 /* Clock/4, rising edge; interrupt on */ 36#define TMU1_TCR_INIT 0x0020 /* Clock/4, rising edge; interrupt on */
27#define TMU1_TSTR_INIT 0x02 /* Bit to turn on TMU1 */ 37#define TMU1_TSTR_INIT 0x02 /* Bit to turn on TMU1 */
28 38
29#define TMU_TSTR 0xfffffe92
30#define TMU1_TCOR 0xfffffea0
31#define TMU1_TCNT 0xfffffea4
32#define TMU1_TCR 0xfffffea8
33
34#define BUFFER_SIZE 48000 39#define BUFFER_SIZE 48000
35 40
36static int rate; 41static int rate;
@@ -71,34 +76,37 @@ static void dac_audio_sync(void)
71 76
72static void dac_audio_start(void) 77static void dac_audio_start(void)
73{ 78{
74#ifdef MACH_HP600 79 if (mach_is_hp6xx()) {
75 u16 v; 80 u16 v = inw(HD64461_GPADR);
76 v = inw(HD64461_GPADR); 81 v &= ~HD64461_GPADR_SPEAKER;
77 v &= ~HD64461_GPADR_SPEAKER; 82 outw(v, HD64461_GPADR);
78 outw(v, HD64461_GPADR); 83 }
79#endif 84
80 sh_dac_enable(CONFIG_SOUND_SH_DAC_AUDIO_CHANNEL); 85 sh_dac_enable(CONFIG_SOUND_SH_DAC_AUDIO_CHANNEL);
81 ctrl_outw(TMU1_TCR_INIT, TMU1_TCR); 86 ctrl_outw(TMU1_TCR_INIT, TMU1_TCR);
82} 87}
83static void dac_audio_stop(void) 88static void dac_audio_stop(void)
84{ 89{
85#ifdef MACH_HP600
86 u16 v;
87#endif
88 dac_audio_stop_timer(); 90 dac_audio_stop_timer();
89#ifdef MACH_HP600 91
90 v = inw(HD64461_GPADR); 92 if (mach_is_hp6xx()) {
91 v |= HD64461_GPADR_SPEAKER; 93 u16 v = inw(HD64461_GPADR);
92 outw(v, HD64461_GPADR); 94 v |= HD64461_GPADR_SPEAKER;
93#endif 95 outw(v, HD64461_GPADR);
96 }
97
98 sh_dac_output(0, CONFIG_SOUND_SH_DAC_AUDIO_CHANNEL);
94 sh_dac_disable(CONFIG_SOUND_SH_DAC_AUDIO_CHANNEL); 99 sh_dac_disable(CONFIG_SOUND_SH_DAC_AUDIO_CHANNEL);
95} 100}
96 101
97static void dac_audio_set_rate(void) 102static void dac_audio_set_rate(void)
98{ 103{
99 unsigned long interval; 104 unsigned long interval;
105 struct clk *clk;
100 106
101 interval = (current_cpu_data.module_clock / 4) / rate; 107 clk = clk_get("module_clk");
108 interval = (clk_get_rate(clk) / 4) / rate;
109 clk_put(clk);
102 ctrl_outl(interval, TMU1_TCOR); 110 ctrl_outl(interval, TMU1_TCOR);
103 ctrl_outl(interval, TMU1_TCNT); 111 ctrl_outl(interval, TMU1_TCNT);
104} 112}
diff --git a/sound/usb/usbmidi.c b/sound/usb/usbmidi.c
index 5105b6b05748..abe29dadd979 100644
--- a/sound/usb/usbmidi.c
+++ b/sound/usb/usbmidi.c
@@ -181,9 +181,9 @@ static int snd_usbmidi_urb_error(int status)
181 case -ENODEV: 181 case -ENODEV:
182 return -ENODEV; 182 return -ENODEV;
183 /* errors that might occur during unplugging */ 183 /* errors that might occur during unplugging */
184 case -EPROTO: /* EHCI */ 184 case -EPROTO:
185 case -ETIMEDOUT: /* OHCI */ 185 case -ETIME:
186 case -EILSEQ: /* UHCI */ 186 case -EILSEQ:
187 return -EIO; 187 return -EIO;
188 default: 188 default:
189 snd_printk(KERN_ERR "urb status %d\n", status); 189 snd_printk(KERN_ERR "urb status %d\n", status);